Sanity Library Reference Docs
    Preparing search index...

    Interface StructureContext

    Interface for the structure builder context.

    interface StructureContext {
        advancedVersionControl: { enabled: boolean };
        authenticated: boolean;
        currentUser: CurrentUser;
        dataset: string;
        document: {
            actions: (
                props: PartialContext<DocumentActionsContext>,
            ) => DocumentActionComponent[];
            badges: (
                props: PartialContext<DocumentBadgesContext>,
            ) => DocumentBadgeComponent[];
            drafts: { enabled: boolean };
            inspectors: (
                props: PartialContext<DocumentInspectorContext>,
            ) => DocumentInspector[];
            resolveNewDocumentOptions: (
                context: NewDocumentCreationContext,
            ) => InitialValueTemplateItem[];
            resolveProductionUrl: (
                context: PartialContext<ResolveProductionUrlContext>,
            ) => Promise<string>;
            unstable_comments: {
                enabled: (props: DocumentCommentsEnabledContext) => boolean;
            };
            unstable_languageFilter: (
                props: PartialContext<DocumentLanguageFilterContext>,
            ) => DocumentLanguageFilterComponent[];
        };
        form: {
            components?: FormComponents;
            file: { assetSources: AssetSource[]; directUploads: boolean };
            image: { assetSources: AssetSource[]; directUploads: boolean };
            unstable?: {
                CustomMarkers?: FormBuilderCustomMarkersComponent;
                Markers?: FormBuilderMarkersComponent;
            };
        };
        getClient: (clientOptions: SourceClientOptions) => SanityClient;
        getStructureBuilder: () => StructureBuilder;
        mediaLibrary?: MediaLibraryConfig;
        name: string;
        onUncaughtError?: (error: Error, errorInfo: ErrorInfo) => void;
        perspectiveStack: StackablePerspective[];
        projectId: string;
        releases?: {
            actions?: (
                props: PartialContext<ReleaseActionsContext>,
            ) => ReleaseActionComponent[];
            enabled?: boolean;
            limit?: number;
        };
        resolveDocumentNode: (
            options: { documentId?: string; schemaType: string },
        ) => DocumentBuilder;
        scheduledDrafts?: { enabled: boolean };
        schema: Schema;
        search: {
            enableLegacySearch?: boolean;
            filters: SearchFilterDefinition<string>[];
            operators: SearchOperatorDefinition<any>[];
            strategy?: "groqLegacy" | "groq2024";
            unstable_partialIndexing?: { enabled: boolean };
        };
        studio?: { components?: StudioComponents };
        tasks?: { enabled: boolean };
        templates: Template<any, any>[];
        title: string;
        tools: Tool<any>[];
        type: "source";
    }

    Hierarchy (View Summary)

    Index

    Properties

    advancedVersionControl: { enabled: boolean }

    Advanced version control provides features such as inline content diffs in Studio to make resolving conflicts across document versions easier.

    Type declaration

    • Betaenabled: boolean

      Control whether advanced version control functionality is enabled.

      Advanced version control provides features such as inline content diffs in Studio to make resolving conflicts across document versions easier.

    authenticated: boolean

    Whether the user is authenticated.

    currentUser: CurrentUser

    The current user of the source.

    dataset: string

    The name of the dataset.

    document: {
        actions: (
            props: PartialContext<DocumentActionsContext>,
        ) => DocumentActionComponent[];
        badges: (
            props: PartialContext<DocumentBadgesContext>,
        ) => DocumentBadgeComponent[];
        drafts: { enabled: boolean };
        inspectors: (
            props: PartialContext<DocumentInspectorContext>,
        ) => DocumentInspector[];
        resolveNewDocumentOptions: (
            context: NewDocumentCreationContext,
        ) => InitialValueTemplateItem[];
        resolveProductionUrl: (
            context: PartialContext<ResolveProductionUrlContext>,
        ) => Promise<string>;
        unstable_comments: {
            enabled: (props: DocumentCommentsEnabledContext) => boolean;
        };
        unstable_languageFilter: (
            props: PartialContext<DocumentLanguageFilterContext>,
        ) => DocumentLanguageFilterComponent[];
    }

    Document-related functionality.

    Type declaration

    form: {
        components?: FormComponents;
        file: { assetSources: AssetSource[]; directUploads: boolean };
        image: { assetSources: AssetSource[]; directUploads: boolean };
        unstable?: {
            CustomMarkers?: FormBuilderCustomMarkersComponent;
            Markers?: FormBuilderMarkersComponent;
        };
    }

    Form-related functionality.

    Type declaration

    • Optional Betacomponents?: FormComponents

      Components for the form.

    • Betafile: { assetSources: AssetSource[]; directUploads: boolean }

      File-related functionality.

      • assetSources: AssetSource[]

        The asset sources.

      • directUploads: boolean

        Whether direct uploads are enabled.

    • Betaimage: { assetSources: AssetSource[]; directUploads: boolean }

      Image-related functionality.

      • assetSources: AssetSource[]

        The asset sources.

      • directUploads: boolean

        Whether direct uploads are enabled.

    • Optional Betaunstable?: {
          CustomMarkers?: FormBuilderCustomMarkersComponent;
          Markers?: FormBuilderMarkersComponent;
      }

      these have not been migrated over and are not merged by the form builder

    getClient: (clientOptions: SourceClientOptions) => SanityClient

    Returns a client instance.

    Type declaration

    getStructureBuilder: () => StructureBuilder

    Get structure builder

    Type declaration

    mediaLibrary?: MediaLibraryConfig

    Config for the Sanity Media Library asset source integration.

    name: string

    The name of the source.

    onUncaughtError?: (error: Error, errorInfo: ErrorInfo) => void

    Configuration for error handling.

    perspectiveStack: StackablePerspective[]

    The stacked array of perspective ids ordered chronologically to represent the state of documents at the given point in time. It can be used as the perspective param in the client to get the correct view of the documents. ["published"] | ["drafts"] | ["releaseId2", "releaseId1", "drafts"] See PerspectiveStack

    projectId: string

    The ID of the project.

    releases?: {
        actions?: (
            props: PartialContext<ReleaseActionsContext>,
        ) => ReleaseActionComponent[];
        enabled?: boolean;
        limit?: number;
    }

    Type declaration

    resolveDocumentNode: (
        options: { documentId?: string; schemaType: string },
    ) => DocumentBuilder

    Resolve document method

    Type declaration

      • (options: { documentId?: string; schemaType: string }): DocumentBuilder
      • Parameters

        • options: { documentId?: string; schemaType: string }

          an object holding the documentId and schemaType for the document node being resolved.

        Returns DocumentBuilder

        a document node builder, or null/undefined if no document node should be returned. See DocumentBuilder

    scheduledDrafts?: { enabled: boolean }
    schema: Schema

    The schema of the source.

    search: {
        enableLegacySearch?: boolean;
        filters: SearchFilterDefinition<string>[];
        operators: SearchOperatorDefinition<any>[];
        strategy?: "groqLegacy" | "groq2024";
        unstable_partialIndexing?: { enabled: boolean };
    }
    studio?: { components?: StudioComponents }

    Type declaration

    tasks?: { enabled: boolean }
    templates: Template<any, any>[]

    The templates of the source.

    title: string

    The title of the source.

    tools: Tool<any>[]

    The tools of the source.

    type: "source"

    The type of the source.