UNPKG

datocms-plugin-sdk

Version:
32 lines (31 loc) 2.2 kB
import type { SchemaTypes } from '@datocms/cma-client'; import { FullConnectParameters } from './connect'; import { Ctx } from './ctx/base'; import { ImposedSizePluginFrameCtx, SelfResizingPluginFrameCtx } from './ctx/pluginFrame'; type Field = SchemaTypes.Field; type ItemType = SchemaTypes.ItemType; export type AwaitedReturnType<T extends (...args: any) => any> = Awaited<ReturnType<T>>; type ModeForPluginFrameCtx<T> = T extends ImposedSizePluginFrameCtx<infer Mode, any, any> ? Mode : never; export type MaybePromise<T> = T | Promise<T>; export declare function pick<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>; export declare function omit<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>; export declare function fromOneFieldIntoMultipleAndResultsById<Result>(fn: ((field: Field, ctx: Ctx<any, any> & { itemType: ItemType; }) => Result) | undefined): (fields: Field[], ctx: Ctx<any, any>) => Record<string, Result> | undefined; export type Methods = { getSettings: () => Promise<Properties>; }; export type Properties<Mode extends string = string> = { mode: Mode; }; type OnChangeListenerFn = (newSettings: any) => void; export type ExtractRenderHooks<T extends Record<string, unknown>> = { [K in keyof T as K extends `render${string}` ? K : never]: T[K]; }; export type Bootstrapper<H extends keyof ExtractRenderHooks<FullConnectParameters>> = { (connectConfiguration: Partial<ExtractRenderHooks<FullConnectParameters>>, methods: Methods, initialProperties: Properties): undefined | OnChangeListenerFn; mode: H; }; export declare function containedRenderModeBootstrapper<Ctx extends SelfResizingPluginFrameCtx<any, {}, {}>>(mode: ModeForPluginFrameCtx<Ctx>, callConfigurationMethod: (connectConfiguration: Partial<ExtractRenderHooks<FullConnectParameters>>, ctx: Ctx) => void): Bootstrapper<Ctx['mode']>; export declare function fullScreenRenderModeBootstrapper<Ctx extends ImposedSizePluginFrameCtx<any, {}, {}>>(mode: ModeForPluginFrameCtx<Ctx>, callConfigurationMethod: (connectConfiguration: Partial<ExtractRenderHooks<FullConnectParameters>>, ctx: Ctx) => void): Bootstrapper<Ctx['mode']>; export {};