import * as StackbitTypes from './index';
export interface CustomControlWindow {
    stackbit: {
        onUpdate?: (options: OnUpdateOptions) => void;
        options?: OnUpdateOptions;
        runAction: (options: RunCustomActionOption) => Promise<unknown>;
    };
}
export type UpdateOperationWithoutKey<Type extends StackbitTypes.UpdateOperation, Key extends keyof Type> = Type extends StackbitTypes.UpdateOperation ? Omit<Type, Key> : never;
export type UpdateOperationWithoutModelField = UpdateOperationWithoutKey<StackbitTypes.UpdateOperation, 'modelField'>;
export interface OnUpdateOptions {
    /**
     * The `init` flag specifies whether the `onUpdate` function runs for the first time or is called due to an update of the document or its fields.
     */
    init: boolean;
    /**
     * The `currentLocale` specifies the currently selected locale in the Stackbit UI.
     */
    currentLocale?: string;
    /**
     * The `currentPageUrl` specifies the currently viewed page in the Stackbit UI.
     */
    currentPageUrl?: string;
    /**
     * The root {@link DocumentWithSource} of the edited field.
     */
    document: Omit<StackbitTypes.DocumentWithSource, 'context'>;
    /**
     * The {@link Model} of the `document`
     */
    model: StackbitTypes.ClientModel;
    /**
     * The key path from the `document` to the edited field.
     * The fieldPath does not include keys for data containers like object
     * `fields` and list `items`.
     *
     * @example
     * {
     *   document = {
     *     type: 'document',
     *     id: 'xyz',
     *     modelName: 'landing_page',
     *     status: 'published',
     *     ...
     *     fields: {
     *       title: {
     *         type: 'string',
     *         value: 'Welcome',
     *       },
     *       button: {
     *         type: 'object',
     *         fields: {
     *           label: {
     *             type: 'string',
     *             value: 'Sign In'
     *           }
     *         }
     *       }
     *     }
     *   },
     *   fieldPath: ['button', 'label'],
     * }
     */
    fieldPath: StackbitTypes.FieldPath;
    /**
     * The {@link DocumentField} of the edited field. This object can also be
     * found in the `document` at the specified `fieldPath`.
     */
    documentField: StackbitTypes.DocumentField | StackbitTypes.DocumentListFieldItems;
    /**
     * The {@link Model} of the edited field.
     */
    modelField: StackbitTypes.ClientField;
    /**
     * The `close` method can be used to close a modal dialog for fields with
     * `controlType` set to 'custom-modal-html'.
     */
    close: () => void;
    /**
     * The `navigate` method can be used to open a different document or a nested
     * field within the current document.
     * Returns a flag, which indicates operation was successful.
     */
    navigate: (options: {
        fieldPath: StackbitTypes.FieldPath;
    } | {
        srcType: string;
        srcProjectId: string;
        srcDocumentId: string;
        fieldPath?: StackbitTypes.FieldPath;
    }) => Promise<boolean>;
    /**
     * The `setDesiredControlSize` can be used to define a desired size for the
     * control's iframe.
     */
    setDesiredControlSize: (size: {
        width?: number;
        height?: number;
    }) => void;
    /**
     * The `updateDocument` method is used to update the edited field. This
     * method receives an options object with the `operations` attribute
     * containing an array of {@link UpdateOperation} (without the `modelField`).
     *
     * @example
     * options.updateDocument({
     *   operations: [
     *     {
     *       opType: 'set',
     *       fieldPath: options.fieldPath,
     *       field: { type: 'string', value: 'new value' }
     *     },
     *     {
     *       opType: 'insert',
     *       fieldPath: ['tags'],
     *       index: 0,
     *       item: {
     *         type: 'string',
     *         value: 'new tag'
     *       }
     *     }
     *   ]
     * })
     */
    updateDocument: (options: {
        operations: UpdateOperationWithoutModelField[];
    }) => Promise<void>;
}
export interface RunCustomActionOption {
    /**
     * The name of the action to run. By default, the action is searched within the current field actions.
     * To execute an action from a different field in the same or another document, specify additional properties
     * such as `fieldPath`, `srcDocumentId`, `srcType`, and `srcProjectId`.
     * To execute global or bulk actions specify `actionType`.
     */
    actionName: string;
    /**
     * The field path specifies the location of the field containing the action to run. By default, the current
     * field's path is used. If `srcDocumentId` is specified, `fieldPath` should indicate the location of the field in that document.
     */
    fieldPath?: StackbitTypes.FieldPath;
    /**
     * The `srcType` specifies the content source containing the action to run. By default, the current content source type is used.
     * If your project has multiple content sources of the same type, you must also specify the `srcProjectId`.
     */
    srcType?: string;
    /**
     * The `srcProjectId` specifies the content source project ID containing the action to run.
     */
    srcProjectId?: string;
    /**
     * The `srcDocumentId` specifies the document containing the action to run. By default, the current document's ID is used.
     */
    srcDocumentId?: string;
    /**
     * The document or field locale for which to run the action. Actions executed in the context of localized documents or fields
     * are scoped to a specific locale. For example, an editor may execute the same 'translate' action for a field
     * in two different locales simultaneously.
     */
    locale?: string;
    /**
     * The input data for the action. If the action has required fields in its `inputData` but the `inputData` option is not provided,
     * the visual editor will present a modal to collect the input data from the user.
     */
    inputData?: Record<string, any>;
    /**
     * Set `actionType` to 'global' or 'bulk' to run global or bulk actions, respectively. If `actionType` is set to 'bulk',
     * you must also specify `actionTarget.objects`.
     */
    actionType?: StackbitTypes.CustomActionGlobal['type'] | StackbitTypes.CustomActionBulk['type'];
    /**
     * When `actionType` is 'bulk', `actionTarget` is used to provide the target documents for the action to be run for
     */
    actionTarget?: {
        objects?: {
            srcType: string;
            srcProjectId: string;
            srcDocumentId: string;
        }[];
    };
}
//# sourceMappingURL=custom-control-types.d.ts.map