UNPKG

@imgly/plugin-ai-apps-web

Version:

AI apps orchestration plugin for the CE.SDK editor

95 lines (94 loc) 3.46 kB
import CreativeEditorSDK from '@cesdk/cesdk-js'; import type { AssetDefinition, AssetQueryData, AssetSource, AssetsQueryResult } from '@cesdk/engine'; /** * A custom AssetSource implementation that manages assets from an array or dynamic function * and provides functionality to mark assets as active. */ export declare class CustomAssetSource implements AssetSource { /** The unique id of the asset source */ id: string; /** Array of assets or function that returns assets */ private assetsOrProvider; /** Set of IDs for active assets */ private activeAssetIds; private loaderDisposer; private cesdk; /** * Creates a new instance of CustomAssetSource * * @param id - The unique identifier for this asset source * @param assetsOrProvider - Array of asset definitions or function that returns asset definitions */ constructor(id: string, cesdk: CreativeEditorSDK, assetsOrProvider?: AssetDefinition[] | (() => AssetDefinition[])); /** * Get all current assets definitions used by this asset source */ getCurrentAssets(): AssetDefinition[]; /** * Find assets based on the provided query data * Supports pagination, searching, filtering, and active-first sorting * * @param queryData - Query parameters to filter and sort assets * @returns Promise with the query results */ findAssets(queryData: AssetQueryData): Promise<AssetsQueryResult | undefined>; updateLabel(assetId: string, label: (currentLabel: string) => string, locale: string): void; getLabel(assetId: string, locale: string): string | undefined; /** * Set an asset as active by its ID * * @param assetId - The ID of the asset to mark as active */ setAssetActive(assetId: string): void; setAssetLoading(assetId: string, loading: boolean): void; /** * Set an asset as inactive by its ID * * @param assetId - The ID of the asset to mark as inactive */ setAssetInactive(assetId: string): void; /** * Clear all active assets */ clearActiveAssets(): void; /** * Check if an asset is marked as active * * @param assetId - The ID of the asset to check * @returns True if the asset is active, false otherwise */ isAssetActive(assetId: string): boolean; /** * Add an asset to this source * * @param asset - The asset definition to add */ addAsset(asset: AssetDefinition): void; /** * Remove an asset from this source * * @param assetId - The ID of the asset to remove */ removeAsset(assetId: string): void; /** * Get all available groups from the assets * * @returns Array of unique group names */ getGroups(): Promise<string[]>; /** * Returns the supported MIME types for this asset source * * @returns Array of supported MIME types */ getSupportedMimeTypes(): string[]; } /** * Helper function to create a CustomAssetSource instance * * @param id - The unique identifier for this asset source * @param assetsOrProvider - Array of asset definitions or function that returns asset definitions * @returns A new CustomAssetSource instance */ export declare function createCustomAssetSource(id: string, cesdk: CreativeEditorSDK, assetsOrProvider?: AssetDefinition[] | (() => AssetDefinition[])): CustomAssetSource; export default CustomAssetSource;