import { PluginSystemContext } from "./createPluginSystemContext.js"; import { Plugin } from "./definePlugin.js"; import { CustomTypeCreateHookBase } from "./hooks/customType-create.js"; import { CustomTypeDeleteHookBase } from "./hooks/customType-delete.js"; import { CustomTypeReadHookBase } from "./hooks/customType-read.js"; import { CustomTypeRenameHookBase } from "./hooks/customType-rename.js"; import { CustomTypeUpdateHookBase } from "./hooks/customType-update.js"; import { CustomTypeLibraryReadHookBase } from "./hooks/customTypeLibrary-read.js"; import { DebugHookBase } from "./hooks/debug.js"; import { ProjectInitHookBase } from "./hooks/project-init.js"; import { SliceCreateHookBase } from "./hooks/slice-create.js"; import { SliceDeleteHookBase } from "./hooks/slice-delete.js"; import { SliceReadHookBase } from "./hooks/slice-read.js"; import { SliceRenameHookBase } from "./hooks/slice-rename.js"; import { SliceUpdateHookBase } from "./hooks/slice-update.js"; import { SliceLibraryReadHookBase } from "./hooks/sliceLibrary-read.js"; import { Hook } from "./lib/HookSystem.js"; /** * A value optionally wrapped in a `PromiseLike`. * * @typeParam T - The value that can optionally be wrapped. */ export type Promisable = T | PromiseLike; /** * A generic type for a user-provided plugin options. Prefer using a * plugin-specific type over this type. */ export type PluginOptions = Record; /** * A string, object, or instance representing a registered plugin. * * @typeParam TPluginOptions - User-provided options for the plugin. */ export type PrismicConfigPluginRegistration = string | Plugin | { resolve: string | Plugin; options?: TPluginOptions; }; /** * Prismic configuration from `prismic.config.js`. */ export type PrismicConfig = { repositoryName: string; adapter: PrismicConfigPluginRegistration; libraries?: string[]; apiEndpoint?: string; }; /** * Prismic project metadata. */ export type PrismicProject = { /** * An absolute path to project root. */ root: string; /** * Prismic `prismic.config.json` content, validated. */ config: PrismicConfig; }; /** * A Slice Library's metadata. */ export type SliceLibrary = { id: string; }; /** * A hook handler. */ export type PluginHook = (data: TData) => Promisable; /** * Extra arguments provided to hooks when called. * * @typeParam TPluginOptions - User-provided options for the hook's plugin. */ export type PluginHookExtraArgs = [context: PluginSystemContext]; /** * Utility type to extend a hook handler's type with Plugin System-specific * extra arguments. * * @typeParam THook - Hook handler to extend. * @typeParam TPluginOptions - User-provided options for the hook's plugin. */ export type ExtendPluginSystemHook, TPluginOptions extends PluginOptions = PluginOptions> = (...args: [ ...args: Parameters, ...extraArgs: PluginHookExtraArgs ]) => ReturnType; /** * Hook types. */ export declare const PluginHookType: { readonly slice_create: "slice:create"; readonly slice_update: "slice:update"; readonly slice_rename: "slice:rename"; readonly slice_delete: "slice:delete"; readonly slice_read: "slice:read"; readonly sliceLibrary_read: "slice-library:read"; readonly customType_create: "custom-type:create"; readonly customType_update: "custom-type:update"; readonly customType_rename: "custom-type:rename"; readonly customType_delete: "custom-type:delete"; readonly customType_read: "custom-type:read"; readonly customTypeLibrary_read: "custom-type-library:read"; readonly snippet_read: "snippet:read"; readonly project_init: "project:init"; readonly debug: "debug"; }; /** * Hook types. */ export type PluginHookTypes = (typeof PluginHookType)[keyof typeof PluginHookType]; /** * Plugin hook handlers. */ export type PluginHooks = { [PluginHookType.slice_create]: Hook; [PluginHookType.slice_update]: Hook; [PluginHookType.slice_rename]: Hook; [PluginHookType.slice_delete]: Hook; [PluginHookType.slice_read]: Hook; [PluginHookType.sliceLibrary_read]: Hook; [PluginHookType.customType_create]: Hook; [PluginHookType.customType_update]: Hook; [PluginHookType.customType_rename]: Hook; [PluginHookType.customType_delete]: Hook; [PluginHookType.customType_read]: Hook; [PluginHookType.customTypeLibrary_read]: Hook; [PluginHookType.project_init]: Hook; [PluginHookType.debug]: Hook; };