import { type Ref, type ComputedRef } from '#imports'; import type { AdapterContext, FullBlokkliAdapter } from '#blokkli/editor/adapter'; import type { StateProvider } from './state.js'; export type HostEntitySearchResultLabelMap = { label: string; bundles: Record; }; export type HostEntitySearchResultItem = { /** * The ID of the host entity. */ id: string; /** * The UUID of the host entity. */ uuid: string; /** * The entity type of the host entity. */ entityType: string; /** * The entity bundle of the host entity. */ bundle: string; /** * The label of the host entity. */ label: string; /** * The url to start editing. */ url: string; /** * If an edit state exists: The time when the edit state was last changed. */ lastChanged: string | null; /** * If an edit state exists: The ID of the owner of the edit state. */ uid: string | null; /** * Optional additional context used for searching (e.g. SKU, internal ID). * * Not displayed in the UI, but included in the fzf search. */ context?: string; }; export type HostEntitySearchResult = { items: HostEntitySearchResultItem[]; /** * A map with keys that are entity types. */ labelMap: HostEntitySearchResultLabelMap; }; export type WorkspacesProvider = { /** * Whether the host entities have been fetched. */ isLoaded: Readonly>; /** * Whether the host entities are currently being fetched. */ isLoading: Readonly>; /** * Loaded items minus the current entity, in workspace default sort order: * entries with edit states first → current user as owner → most-recent → * alphabetic by label. */ defaultSorted: ComputedRef; /** * Load the host entities. Idempotent — concurrent calls share the same * in-flight promise, and resolved data is reused on subsequent calls. */ ensureLoaded: () => Promise; /** * Run a fuzzy search over loaded items. Resolves to fzf-ordered results * (excluding the current entity). An empty/whitespace query resolves to []. */ search: (query: string) => Promise; /** * Translated label for a bundle key, falling back to the key itself. */ getBundleLabel: (bundle: string) => string; }; declare module '#blokkli/editor/adapter' { interface BlokkliAdapter { /** * Search for host entities. */ getHostEntities?: () => Promise; } } export default function workspacesProvider(adapter: FullBlokkliAdapter, context: ComputedRef, state: StateProvider): WorkspacesProvider;