import { EditorAPI, EditorResponse, Id } from '../types/CommonTypes'; import { ConnectorInstance, ConnectorMappingDirection, ConnectorMappingType, ConnectorOptions, ConnectorRegistration, ConnectorState, ConnectorToEngineMapping, ConnectorType, EngineToConnectorMapping } from '../types/ConnectorTypes'; /** * The ConnectorController manages lifetime of all available connectors, regardless of the type, in the * document. Use it to add/remove connectors to a template, or set specific configuration. * * The way CHILI Studio handles different sources of resources is called 'Connectors'. A Connectors is an * implementation of a set of capabilities we need to interact with a certain external resource management system. * In essence a connector is the combination of a Javascript snippet and some metadata. The Javascript snippet * is loaded in the studio engine using a sandboxed Javascript execution engine (QuickJs). This allows us to * execute the media connector both on web using webassembly and on the server side during e.g. animation output * generation. * This controller is an interface to the running connector instance inside the studio engine. The engine will * automatically register the 'grafx-media' and 'grafx-font' connectors. Custom connectors need to be registered * manually. */ export declare class ConnectorController { #private; /** * @ignore */ constructor(editorAPI: EditorAPI, localConfig: Map); /** * Gets a connector by its id * @param id the id of the connector * @returns connector */ getById: (id: Id) => Promise>; /** * Gets all available connectors of a 'ConnectorType' * @param type type of connector you want to get * @returns list of all available connectors of a 'ConnectorType' */ getAllByType: (type: ConnectorType) => Promise>; /** * Registers a new connector in the SDK. After successful registration, depending * on the connector type, the connector can be configured and used in the template * Remember to add custom authentication information after registering the connector * @param registration registration object containing all details about the connector * @returns the Id of the newly created connector, this Id should be used going forward. */ register: (registration: ConnectorRegistration) => Promise>; /** * Unregisters a connector from the document. * @param id the id of the connector to unregister * @returns */ unregister: (id: Id) => Promise>; /** * Configures a registered connector. A configurator helper is passed as an argument * of the callback for you to setup your connector. * @param id the id of your registered connector * @param configurationCallback callback to setup the connector * @returns */ configure: (id: Id, configurationCallback: (configurator: ConnectorConfigurator) => Promise) => Promise>; /** * Gets the current state a connector is in, to wait until a connector is ready to be used, use the 'waitToBeReady' * method in this controller. * @param id the id of your registered connector you want to make sure it is loaded * @returns connector state */ getState: (id: Id) => Promise>; /** * Gets the mapped data from connector. * @param id the id of your registered connector * @param direction the mapping direction * @returns mappings */ getMappings(id: string, direction: ConnectorMappingDirection.engineToConnector): Promise>; getMappings(id: string, direction: ConnectorMappingDirection.connectorToEngine): Promise>; getMappings(id: string, direction?: undefined): Promise>; /** * Gets the options from the connector. * @param id the id of your registered connector * @returns options */ getOptions: (id: string) => Promise>; /** * Connectors are loaded asynchronously in the editor engine, this causes some challenges while configuring them. To make sure * an action on the connector will be available, it's advised to await this method. After the Promise resolves we are sure * the connector is up and running. This is used internally by the configure method to ensure correct execution. It's especially * useful during startup of the SDK / right after the loadDocument call. * @param id the id of your registered connector you want to make sure it is loaded * @returns */ waitToBeReady: (id: Id, timeoutMilliseconds?: number) => Promise>; /** * Updates the mappings for a given connector. * @param id the id of your registered connector * @param mappings An array of mapping objects * @returns */ updateMappings: (id: Id, mappings: ConnectorMappingType[]) => Promise>; /** * Sets the mappings for a given connector, replacing the existing mappings with the new ones. * @param id the id of your registered connector * @param mappings An array of mapping objects to set * @returns */ applyMappings: (id: Id, mappings: ConnectorMappingType[]) => Promise>; /** * Sets HTTP headers on every local connector instance of the given type that uses the given remote (Environment API) connector id. * It's applicable as for already registered connectors as well as for future one with same remote connector id. * * @param remoteConnectorId unique id of the remote connector from the Environment API (grafx source) * @param headers HTTP headers to set on the connector * @returns EditorResponse with null on success; error if the engine call fails */ setHttpHeaders: (remoteConnectorId: string, headers: Record) => Promise>; } /** * Helper to setup your connector */ declare class ConnectorConfigurator { #private; /** * @ignore */ constructor(id: Id, res: EditorAPI); /** * Allows to customize the context data a connector can work with. The options data * will be available using the context parameter in the connector implementation code. * @param options object containing key value data to pass to connector context * @returns */ setOptions: (options: ConnectorOptions) => Promise>; /** * Allows to map variables or strings to connector context data. * By defining the mappings, we can trigger re-download of assets (dynamic asset provider) * or populate filters for the query endpoint. The mapped data will be available using * the context parameter in the connector implementation code. * * For the variables the mapping should follow the format "var.[variable id]". e.g. var.6B29FC40-CA47-1067-B31D-00DD010662DA * * @param mappings collection of mappings to set to this connector * @returns */ setMappings: (mappings: ConnectorMappingType[]) => Promise>; /** * This method sets the HTTP headers for the 'staticKey' authentication type. * These additional headers will be added to all connector http calls. * Can only be used after a connector has been registered. (if you are using a grafx connector no registration is needed) * @param headerName name of the header * @param headerValue value of the header * @returns */ setHttpHeader: (headerName: string, headerValue: string) => Promise>; } export {};