UNPKG

alinea

Version:
44 lines (43 loc) 1.73 kB
import type { Preview } from 'alinea/core/Preview'; import type { ComponentType } from 'react'; import { type HasWorkspace } from './Internal.js'; import { Root } from './Root.js'; import type { Schema } from './Schema.js'; export interface WorkspaceMeta { /** A directory which contains the json entry files */ source: string; /** The directory where media files are placed in case a file backend is used */ mediaDir?: string; /** The main theme color used in the dashboard */ color?: string; icon?: ComponentType; preview?: Preview; } type Roots = Record<string, Root>; export interface RootsDefinition { [key: string]: Root; } export type Workspace<Definition extends Roots = Roots> = Definition & HasWorkspace; export declare namespace Workspace { function data(workspace: Workspace): WorkspaceInternal; function roots(workspace: Workspace): Roots; function label(workspace: Workspace): string; function preview(workspace: Workspace): Preview | undefined; function isWorkspace(value: any): value is Workspace; function defaultMediaRoot(workspace: Workspace): string; function defaultRoot(workspace: Workspace): string; function validate(workspace: Workspace, schema: Schema): void; function referencedViews(workspace: Workspace): string[]; } export interface WorkspaceConfig<Definition> extends WorkspaceMeta { roots: Definition; } export interface WorkspaceInternal extends WorkspaceConfig<RootsDefinition> { label: string; color: string; } /** Create a workspace */ export declare function workspace<Roots extends RootsDefinition>( /** The name of the workspace */ label: string, config: WorkspaceConfig<Roots>): Workspace<Roots>; export {};