What a layouts control calls, and nothing more. WorkspaceRepository implements it, with importDocument and exportDocument besides; a host that keeps layouts on its own server can implement it directly. The widget tier takes this contract as a type, so a widget host loads the workspace tier only when it passes one.

A change given expectedRevision is refused with an error named WorkspaceConflictError unless the catalog is at that revision, and a change that commits moves the catalog forward by exactly one revision.

interface WorkspaceStore {
    captureIndicatorTemplate(chart: Chart): IndicatorTemplatePayload;
    createTemplate(
        name: string,
        input: IndicatorTemplateInput,
        options?: WorkspaceOperationOptions,
    ): Promise<IndicatorTemplateDocument>;
    createWorkspace(
        name: string,
        input: WorkspacePayload,
        options?: WorkspaceOperationOptions,
    ): Promise<WorkspaceDocument>;
    duplicate(
        kind: WorkspaceKind,
        id: string,
        name: string,
        options?: WorkspaceOperationOptions,
    ): Promise<WorkspaceDocument | IndicatorTemplateDocument>;
    load(): Promise<WorkspaceCatalog>;
    openWorkspace(
        id: string,
        options?: WorkspaceOpenOptions,
    ): Promise<WorkspaceDocument>;
    planIndicatorTemplateState(
        chart: Chart,
        incoming: IndicatorTemplateInput,
        mode: IndicatorTemplateMode,
        options?: IndicatorTemplateApplyOptions,
    ): IndicatorTemplatePlan;
    remove(
        kind: WorkspaceKind,
        id: string,
        options?: WorkspaceOperationOptions,
    ): Promise<void>;
    rename(
        kind: WorkspaceKind,
        id: string,
        name: string,
        options?: WorkspaceOperationOptions,
    ): Promise<void>;
    saveTemplate(
        id: string,
        input: IndicatorTemplateInput,
        options?: WorkspaceOperationOptions,
    ): Promise<IndicatorTemplateDocument>;
    saveWorkspace(
        id: string,
        input: WorkspacePayload,
        options?: WorkspaceOperationOptions,
    ): Promise<WorkspaceDocument>;
    setAutosave(
        enabled: boolean,
        options?: WorkspaceOperationOptions,
    ): Promise<void>;
    subscribe(listener: (catalog: WorkspaceCatalog) => void): () => void;
}

Implemented by

Methods

  • captureIndicatorTemplate (since 2.5.10): a chart's studies with their panes and scales, for createTemplate. The widget's indicator picker reads it through the store it is given, so the widget tier never loads this tier on its own. Without it the picker saves the plain study list.

    Parameters

    Returns IndicatorTemplatePayload

  • Called with a detached copy of the catalog after each change this store commits, before that change's promise resolves: a control learns the revision its next change is checked against here. Returns the unsubscribe.

    Parameters

    Returns () => void