import type { FieldType } from './field-type'; import type { DefinedParameters, InstallationParameterType, ParameterDefinition } from './widget-parameters'; import type { DefaultElements, BasicMetaSysProps, SysLink, MakeRequest } from '../common-types'; import type { SetRequired, RequireExactlyOne } from 'type-fest'; type ExtensionSysProps = BasicMetaSysProps & { space: SysLink; environment: SysLink; srcdocSha256?: string; }; export type ExtensionProps = { sys: ExtensionSysProps; extension: { /** * Extension name */ name: string; /** * Field types where an extension can be used */ fieldTypes: FieldType[]; /** * URL where the root HTML document of the extension can be found */ src?: string; /** * String representation of the extension (e.g. inline HTML code) */ srcdoc?: string; /** * Parameter definitions */ parameters?: { instance?: ParameterDefinition[]; installation?: ParameterDefinition[]; }; /** * Controls the location of the extension. If true it will be rendered on the sidebar instead of replacing the field's editing control */ sidebar?: boolean; }; /** * Values for installation parameters */ parameters?: DefinedParameters; }; export type CreateExtensionProps = { extension: RequireExactlyOne, 'src' | 'srcdoc'>; }; export interface Extension extends ExtensionProps, DefaultElements { /** * Sends an update to the server with any changes made to the object's properties * @return Object returned from the server with updated changes. * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '' * }) * * client.getSpace('') * .then((space) => space.getEnvironment('')) * .then((environment) => environment.getUiExtension('')) * .then((extension) => { * extension.extension.name = 'New UI Extension name' * return extension.update() * }) * .then((extension) => console.log(`UI Extension ${extension.sys.id} updated.`)) * .catch(console.error) * ``` */ update(): Promise; /** * Deletes this object on the server. * @return Promise for the deletion. It contains no data, but the Promise error case should be handled. * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '' * }) * * client.getSpace('') * .then((space) => space.getEnvironment('')) * .then((environment) => environment.getUiExtension('')) * .then((extension) => extension.delete()) * .then(() => console.log(`UI Extension deleted.`)) * .catch(console.error) * ``` */ delete(): Promise; } /** * @private * @param makeRequest - function to make requests via an adapter * @param data - Raw UI Extension data * @return Wrapped UI Extension data */ export declare function wrapExtension(makeRequest: MakeRequest, data: ExtensionProps): Extension; /** * @private */ export declare const wrapExtensionCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp) => import("../common-types").Collection; export {};