export type LoadingState = { hasData: boolean; isLoading: boolean; }; export interface WidgetConfigContext { /** * Gets the title of the widget. * * @returns the title of the widget */ getTitle: () => Promise; /** * Sets the title of the widget. * * @param title - The title to set. */ setTitle: (title: string) => Promise; /** * Gets the data of the widget. * * @returns the data of the widget */ getData: () => Promise>; /** * Gets the data version of the widget. * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget. * Use it to upgrade the widget data to a new version when loading the widget. * * @returns the data version of the widget */ getDataVersion: () => Promise; /** * Sets the data of the widget. * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget. * Use it to upgrade the widget data to a new version when loading the widget. * * @param data - The data to set. * @param dataVersion - The data version to set. */ setData: (data: Record, dataVersion: number) => Promise; /** * Sets the loading state of the widget. * * @param loadingState - The loading state to set. */ setLoadingState: (loadingState: LoadingState) => Promise; /** * Opens the edit mode of the widget. */ openEditMode: () => Promise; /** * Closes the edit mode of the widget. */ closeEditMode: () => Promise; /** * The poll interval of the widget. * * @returns the poll interval of the widget */ pollInterval?: number; } export interface WidgetConfigRuntimeApi { /** * Gets the data of the widget. */ getWidgetData: () => Promise>; /** * Sets the data of the widget. * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget. * Use it to upgrade the widget data to a new version when loading the widget. * * @param data the data to set * @param dataVersion the data version to set * @param title the title to set */ setWidgetData: (data: Record, dataVersion: number, title?: string) => Promise; /** * Gets the data version of the widget. * Dataversion is used to make it easy for you to see what dataVersion is saved in the widget. * Use it to upgrade the widget data to a new version when loading the widget. */ getWidgetDataVersion: () => Promise; /** * Gets the title of the widget. */ getWidgetTitle: () => Promise; /** * Sets the title of the widget. */ setWidgetTitle: (title: string) => Promise; /** * Opens the edit mode of the widget. */ openEditMode: () => Promise; /** * Closes the edit mode of the widget. */ closeEditMode: () => Promise; /** * Sets the loading state of the widget. */ setLoadingState: (loadingState: LoadingState) => Promise; /** * Gets the poll interval of the widget. */ getWidgetPollInterval: () => Promise; }