import type { ComputedRef } from 'vue'; import type { AddNewBlockEvent, AddNewBlocksEvent, MoveBlockEvent, MoveMultipleBlocksEvent } from '../events/index.js'; import type { PluginConfigInput } from '../types/pluginConfig.js'; import type { EntityTranslation, MappedState, Validation } from '../types/state.js'; import type { BlockBundleDefinition, EntityTypeBundleInfo, EntityTypeInfo, FieldConfig } from '../types/definitions.js'; import type { EditBlockEvent } from '../features/edit/types.js'; import type { UserPermissions } from '../types/permissions.js'; import type { BlokkliUser } from '../types/user.js'; export interface MutationResponseLike { success: boolean; state?: T; errors?: string[]; violations?: Validation[]; } export interface GenericAdapterResponse { success: boolean; data: T; errors?: string[]; } export type UpdateEntityFieldValueEvent = { fieldName: string; fieldValue: string; }; type AdapterFormFrameBuilderResult = { url: string; }; type AdapterFormFrameBuilderBlockAdd = { id: 'block:add'; data: AddNewBlockEvent; }; type AdapterFormFrameBuilderBlockTranslate = { id: 'block:translate'; data: EditBlockEvent; langcode: string; }; type AdapterFormFrameBuilderBlockEdit = { id: 'block:edit'; data: EditBlockEvent; }; type AdapterFormFrameBuilderEntityEdit = { id: 'entity:edit'; }; type AdapterFormFrameBuilderEntityTranslate = { id: 'entity:translate'; translation: EntityTranslation; }; type AdapterFormFrameBuilderBatchTranslate = { id: 'batchTranslate'; }; export type AdapterFormFrameBuilder = AdapterFormFrameBuilderBlockAdd | AdapterFormFrameBuilderBlockEdit | AdapterFormFrameBuilderBlockTranslate | AdapterFormFrameBuilderEntityEdit | AdapterFormFrameBuilderEntityTranslate | AdapterFormFrameBuilderBatchTranslate; export interface AdapterContext { entityType: string; entityUuid: string; entityBundle: string; language: string; } export type BlokkliAdapterSearchResults = { items: T[]; total: number; perPage: number; filters: PluginConfigInput[]; }; export type AdapterSearchArguments = { page: number; filters: Record; }; export interface BlokkliAdapter { /** * Load the state. */ loadState(): Promise; /** * Load the unchanged state. */ loadStateAtIndex?: (index: number) => Promise; mapState(state: T): MappedState; getUserPermissions: () => Promise; /** * Return the user currently editing. Must always return a non-null user; * adapters should treat this as a hard requirement (anonymous editing is * not supported by features that consume the user provider). */ getCurrentUser: () => Promise; /** * Return the list of users that can be referenced in the editor (e.g. for * `@` mentions in comments). Called lazily on demand and cached by the * user provider, so this may be a relatively expensive operation. * * Optional. Adapters that don't implement this expose an empty user list * to consumers — mention pickers will simply show no suggestions. */ getBlokkliUsers?: () => Promise; /** * Get disabled features at runtime. * * For example, the "Translation" feature can be disabled if the current * entity does not support translations. * * For features that are always disabled, use the `alterFeatures` option of * the module to remove them entirely. */ getDisabledFeatures?: () => Promise; /** * Return a list of all types. */ getAllBundles(): Promise; /** * Get the field configurations. */ getFieldConfig(): Promise; /** * Optional: map a root block bundle to the block bundles that are allowed * anywhere within its subtree ("bundle scopes"). * * When provided, the editor resolves a nested field's effective * `allowedBundles` by walking up to the root block and filtering: a bundle * that appears in ANY scope value ("scoped" bundle) is kept for a field only * if it belongs to that field's root bundle scope. Bundles that appear in no * scope are never restricted. Use this to keep domain blocks confined to the * shell they belong to, recursively through nested layout blocks. */ getBundleScopes?: () => Promise>; /** * Add a new block. */ addNewBlock(e: AddNewBlockEvent): Promise>; /** * Add multiple new blocks at once. */ addNewBlocks?(e: AddNewBlocksEvent): Promise>; /** * Move an item. */ moveBlock(e: MoveBlockEvent): Promise>; /** * Move multiple items. */ moveMultipleBlocks(e: MoveMultipleBlocksEvent): Promise>; /** * Get the last changed timestamp for the edit state. */ getLastChanged?: () => Promise; /** * Build the URL for forms. */ formFrameBuilder?: (e: AdapterFormFrameBuilder) => AdapterFormFrameBuilderResult | undefined; userSettings?: { /** * Load user settings. */ load: () => Promise>; /** * Persist user settings. */ persist: (settings: string) => Promise; }; getEntityTypeInfo?: (entityType: string) => EntityTypeInfo | null; getEntityBundleInfo?: (entityType: string, bundle: string) => EntityTypeBundleInfo | null; } /** * Methods that adapter extensions can implement. * Features augment this interface via module augmentation to add extensible methods. * These methods can be implemented by both the base adapter AND extensions. */ export interface AdapterExtensionMethods { } /** * The full adapter type combining core methods with extensible methods. */ export type FullBlokkliAdapter = BlokkliAdapter & Partial>; export type BlokkliAdapterFactory = (ctx: ComputedRef) => Promise> | FullBlokkliAdapter; export type AdapterMethods = keyof BlokkliAdapter | keyof AdapterExtensionMethods; export declare function defineBlokkliEditAdapter(cb: BlokkliAdapterFactory): BlokkliAdapterFactory; /** * An adapter extension (with namespace assigned by build system). */ export interface BlokkliAdapterExtension { /** * Unique namespace (e.g., '@my-org/ai'). * Assigned by the build system from registerAdapterExtension(). */ namespace: string; /** * Extension methods. */ methods: Partial>; } /** * Factory type for extension files. * Just returns methods - namespace is assigned externally. */ export type BlokkliAdapterExtensionFactory = (ctx: ComputedRef) => Promise>> | Partial>; /** * Define an adapter extension. * The namespace is NOT specified here - it's assigned via registerAdapterExtension(). */ export declare function defineBlokkliAdapterExtension(factory: BlokkliAdapterExtensionFactory): BlokkliAdapterExtensionFactory; export {};