Add MaybePromise
This commit is contained in:
@@ -67,7 +67,7 @@ export interface BuiltinsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @alpha
|
// @alpha
|
||||||
export type CapabilitiesApprover = (widget: WidgetDescriptor, requestedCapabilities: Set<string>) => Set<string> | Promise<Set<string> | undefined> | undefined;
|
export type CapabilitiesApprover = (widget: WidgetDescriptor, requestedCapabilities: Set<string>) => MaybePromise<Set<string> | undefined>;
|
||||||
|
|
||||||
// @alpha @deprecated (undocumented)
|
// @alpha @deprecated (undocumented)
|
||||||
export interface ChatExportCustomisations<ExportFormat, ExportType> {
|
export interface ChatExportCustomisations<ExportFormat, ExportType> {
|
||||||
@@ -186,7 +186,7 @@ export interface I18nApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @alpha
|
// @alpha
|
||||||
export type IdentityApprover = (widget: WidgetDescriptor) => boolean | Promise<boolean> | undefined;
|
export type IdentityApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>;
|
||||||
|
|
||||||
// @alpha @deprecated (undocumented)
|
// @alpha @deprecated (undocumented)
|
||||||
export type LegacyCustomisations<T extends object> = (customisations: T) => void;
|
export type LegacyCustomisations<T extends object> = (customisations: T) => void;
|
||||||
@@ -242,6 +242,9 @@ export interface MatrixEvent {
|
|||||||
unsigned: Record<string, unknown>;
|
unsigned: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @public
|
||||||
|
export type MaybePromise<T> = T | PromiseLike<T>;
|
||||||
|
|
||||||
// @alpha @deprecated (undocumented)
|
// @alpha @deprecated (undocumented)
|
||||||
export interface Media {
|
export interface Media {
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
@@ -334,7 +337,7 @@ export type OriginalMessageComponentProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @alpha
|
// @alpha
|
||||||
export type PreloadApprover = (widget: WidgetDescriptor) => boolean | Promise<boolean> | undefined;
|
export type PreloadApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>;
|
||||||
|
|
||||||
// @public
|
// @public
|
||||||
export interface Profile {
|
export interface Profile {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type { MaybePromise } from "../utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A description of a widget passed to approver callbacks.
|
* A description of a widget passed to approver callbacks.
|
||||||
* Contains the information needed to make approval decisions.
|
* Contains the information needed to make approval decisions.
|
||||||
@@ -31,14 +33,14 @@ export type WidgetDescriptor = {
|
|||||||
* Return `true` to auto-approve, or any other value to defer to the default consent flow.
|
* Return `true` to auto-approve, or any other value to defer to the default consent flow.
|
||||||
* @alpha Subject to change.
|
* @alpha Subject to change.
|
||||||
*/
|
*/
|
||||||
export type PreloadApprover = (widget: WidgetDescriptor) => boolean | Promise<boolean> | undefined;
|
export type PreloadApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>;
|
||||||
/**
|
/**
|
||||||
* Callback that decides whether a widget should be auto-approved to receive
|
* Callback that decides whether a widget should be auto-approved to receive
|
||||||
* the user's OpenID identity token.
|
* the user's OpenID identity token.
|
||||||
* Return `true` to auto-approve, or any other value to defer to the default consent flow.
|
* Return `true` to auto-approve, or any other value to defer to the default consent flow.
|
||||||
* @alpha Subject to change.
|
* @alpha Subject to change.
|
||||||
*/
|
*/
|
||||||
export type IdentityApprover = (widget: WidgetDescriptor) => boolean | Promise<boolean> | undefined;
|
export type IdentityApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>;
|
||||||
/**
|
/**
|
||||||
* Callback that decides which of a widget's requested capabilities should be auto-approved.
|
* Callback that decides which of a widget's requested capabilities should be auto-approved.
|
||||||
* Return a `Set` of approved capability strings, or `undefined` to defer to the default consent flow.
|
* Return a `Set` of approved capability strings, or `undefined` to defer to the default consent flow.
|
||||||
@@ -47,7 +49,7 @@ export type IdentityApprover = (widget: WidgetDescriptor) => boolean | Promise<b
|
|||||||
export type CapabilitiesApprover = (
|
export type CapabilitiesApprover = (
|
||||||
widget: WidgetDescriptor,
|
widget: WidgetDescriptor,
|
||||||
requestedCapabilities: Set<string>,
|
requestedCapabilities: Set<string>,
|
||||||
) => Set<string> | Promise<Set<string> | undefined> | undefined;
|
) => MaybePromise<Set<string> | undefined>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API for modules to auto-approve widget preloading, identity token requests, and capability requests.
|
* API for modules to auto-approve widget preloading, identity token requests, and capability requests.
|
||||||
|
|||||||
@@ -24,3 +24,4 @@ export type * from "./api/stores";
|
|||||||
export type * from "./api/client";
|
export type * from "./api/client";
|
||||||
export type * from "./api/widget-lifecycle";
|
export type * from "./api/widget-lifecycle";
|
||||||
export * from "./api/watchable";
|
export * from "./api/watchable";
|
||||||
|
export type * from "./utils";
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2026 Element Creations Ltd.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A value that may be a direct value or a Promise resolving to that value.
|
||||||
|
* Useful for callback APIs that can operate synchronously or asynchronously.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export type MaybePromise<T> = T | PromiseLike<T>;
|
||||||
Reference in New Issue
Block a user