Sanity Library Reference Docs
    Preparing search index...
    • Compare the generated runtime under root with the runtime config requires, reading root and writing nothing.

      root is the directory holding the config file, which is where a generated tree lives; nothing is read outside it and the working directory is never consulted. configFile is that file's name as found there, because every generated module imports its deployment from it.

      GeneratedRuntimeAlignment.divergences is what a regeneration settles. A complete gate reports the returned plan's own unsettled entries as well, because regenerating settles none of those: its orphaned stubs, its case collisions, its orphaned registry, and the blueprint wiring it could not insert.

      A complete gate verifies separately that the config module exports each deployment under the name deploymentExportIdentifier returns. An empty divergence list and a settled plan do not mean the tree compiles: without those exports the generated modules cannot resolve their deployment, and every file on disk still matches.

      Throws when the definitions cannot produce a runtime at all, and when they produce one this root cannot hold: an effect name or deployment name that cannot be embedded in generated code, or a dependency a generated function imports for which the root's package.json declares no version.

      Parameters

      • args: {
            compiler?: typeof ts;
            config: {
                deployments: {
                    definitions: DefinedWorkflow[];
                    expectedMinReaderModel?: number;
                    name: string;
                    resourceAliases?: {
                        name: string;
                        resource:
                            | { id: string; type: "dataset" }
                            | { id: string; type: "canvas" }
                            | { id: string; type: "media-library" }
                            | { id: string; type: "dashboard" };
                    }[];
                    runtime?: RuntimeBlock;
                    tag: string;
                    workflowResource: | { id: string; type: "dataset" }
                    | { id: string; type: "canvas" }
                    | { id: string; type: "media-library" }
                    | { id: string; type: "dashboard" };
                }[];
                telemetry?: WorkflowTelemetryLogger;
            };
            configFile: string;
            root: string;
        }
        • Optionalcompiler?: typeof ts

          TypeScript 6 compiler API for wiring an existing sanity.blueprint.ts. Pass it when the installed typescript package is absent or does not expose that API.

        • config: {
              deployments: {
                  definitions: DefinedWorkflow[];
                  expectedMinReaderModel?: number;
                  name: string;
                  resourceAliases?: {
                      name: string;
                      resource:
                          | { id: string; type: "dataset" }
                          | { id: string; type: "canvas" }
                          | { id: string; type: "media-library" }
                          | { id: string; type: "dashboard" };
                  }[];
                  runtime?: RuntimeBlock;
                  tag: string;
                  workflowResource: | { id: string; type: "dataset" }
                  | { id: string; type: "canvas" }
                  | { id: string; type: "media-library" }
                  | { id: string; type: "dashboard" };
              }[];
              telemetry?: WorkflowTelemetryLogger;
          }
        • configFile: string
        • root: string

      Returns GeneratedRuntimeAlignment

      Report which generated files beside a project's sanity.workflow.ts no longer match its definitions. A gate that also refuses the plan's unsettled entries reads them from plan.

      import {dirname} from 'node:path'

      import {generatedRuntimeAlignment} from '@sanity/workflow-blueprint/generate'

      // `configPath` is the absolute path of the project's sanity.workflow.ts, and
      // `config` the validated config it exports.
      const {divergences} = generatedRuntimeAlignment({
      root: dirname(configPath),
      config,
      configFile: 'sanity.workflow.ts',
      })

      for (const divergence of divergences) {
      console.log(`${divergence.reason}: ${divergence.path}`)
      }