@sanity/cli-core 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { i as ConfigStore, o as TypeGenConfig, r as CliConfig } from "../cliConfig-DUt8uaF6.js";
2
2
  import { _ as CliTokenInfo, a as getStudioWorkspaces, c as findProjectRoot, d as getCliConfigUncached, f as getCliToken, g as setCliUserConfig, h as getUserConfig, i as isStudioConfig, l as getCliConfigSync, m as getCliUserConfig, n as tryFindStudioConfigPath, o as getStudioConfig, p as getCliTokenInfo, r as findPathForFiles, s as findProjectRootSync, t as findStudioConfigPath, u as getCliConfig, v as clearCliTokenCache } from "../findStudioConfigPath-BV4DCesQ.js";
3
- import { n as isWorkbenchApp, r as parseWorkbenchCliConfig } from "../workbenchApp-BkQHUXxH.js";
3
+ import { n as isWorkbenchApp, r as parseWorkbenchCliConfig } from "../workbenchApp-DVKwpTyU.js";
4
4
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
5
5
  export { type CliConfig, type CliTokenInfo, type ConfigStore, type TypeGenConfig, clearCliTokenCache, findPathForFiles, findProjectRoot, findProjectRootSync, findStudioConfigPath, getCliConfig, getCliConfigSync, getCliConfigUncached, getCliToken, getCliTokenInfo, getCliUserConfig, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getStudioConfig, getStudioWorkspaces, getUserConfig, getWorkspace, isStudioConfig, isWorkbenchApp, parseWorkbenchCliConfig, setCliUserConfig, tryFindStudioConfigPath };
@@ -6,7 +6,7 @@ import { n as RequireProps, r as SanityOrgUser, t as Output } from "../types-CwJ
6
6
  import { SanityCommand, SanityCommandInterface } from "../SanityCommand.js";
7
7
  import { t as mockBrowserEnvironment } from "../mockBrowserEnvironment-BjFQPb2W.js";
8
8
  import { _ as CliTokenInfo, a as getStudioWorkspaces, c as findProjectRoot, d as getCliConfigUncached, f as getCliToken, g as setCliUserConfig, h as getUserConfig, i as isStudioConfig, l as getCliConfigSync, m as getCliUserConfig, n as tryFindStudioConfigPath, o as getStudioConfig, p as getCliTokenInfo, r as findPathForFiles, s as findProjectRootSync, t as findStudioConfigPath, u as getCliConfig, v as clearCliTokenCache } from "../findStudioConfigPath-BV4DCesQ.js";
9
- import { n as isWorkbenchApp, t as ApplicationType } from "../workbenchApp-BkQHUXxH.js";
9
+ import { n as isWorkbenchApp, t as ApplicationType } from "../workbenchApp-DVKwpTyU.js";
10
10
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
11
11
  import { debug, subdebug } from "./debug.js";
12
12
  import { t as NonInteractiveError } from "../NonInteractiveError-CSLT5y93.js";
@@ -18,7 +18,7 @@ import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r
18
18
  import { a as getLocalPackageVersion, i as getLocalPackageDir, n as resolveLocalPackageFrom, r as resolveLocalPackagePath, t as resolveLocalPackage } from "../resolveLocalPackage-Dr-TNTyk.js";
19
19
  import { n as ReadPackageJsonOptions, r as readPackageJson, t as PackageJson } from "../readPackageJson-Cr_lbjVR.js";
20
20
  import { n as colorizeJson, t as getTimer } from "../timer-Dwu2TIgB.js";
21
- import { i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-PPIe9Jz0.js";
21
+ import { i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-D1LxkXeZ.js";
22
22
  import { WorkerOptions } from "node:worker_threads";
23
23
  interface PromisifyWorkerOptions extends WorkerOptions {
24
24
  /**
@@ -1,2 +1,2 @@
1
- import { a as cliConfigSchema, i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-PPIe9Jz0.js";
1
+ import { a as cliConfigSchema, i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-D1LxkXeZ.js";
2
2
  export { type CoreAppManifest, type StudioManifest, cliConfigSchema, coreAppManifestSchema, studioManifestSchema };
@@ -3,7 +3,7 @@ import { t as ProjectRootResult } from "../recursivelyResolveProjectRoot-BE54uEP
3
3
  import { n as ConsentInformation, r as TelemetryUserProperties, t as CLITelemetryStore } from "../types-ZNH3prAd.js";
4
4
  import { n as RequireProps, r as SanityOrgUser, t as Output } from "../types-CwJLTYDj.js";
5
5
  import { SanityCommandInterface } from "../SanityCommand.js";
6
- import { t as ApplicationType } from "../workbenchApp-BkQHUXxH.js";
6
+ import { t as ApplicationType } from "../workbenchApp-DVKwpTyU.js";
7
7
  import { n as ReadPackageJsonOptions, t as PackageJson } from "../readPackageJson-Cr_lbjVR.js";
8
- import { n as StudioManifest, t as CoreAppManifest } from "../schemas-PPIe9Jz0.js";
8
+ import { n as StudioManifest, t as CoreAppManifest } from "../schemas-D1LxkXeZ.js";
9
9
  export type { ApplicationType, CLITelemetryStore, CliConfig, ConfigStore, ConsentInformation, CoreAppManifest, Output, PackageJson, ProjectRootResult, ReactCompilerConfig, ReadPackageJsonOptions, RequireProps, SanityCommandInterface, SanityOrgUser, StudioManifest, TelemetryUserProperties, TypeGenConfig, UserViteConfig };
@@ -1,6 +1,14 @@
1
1
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
2
2
  import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-CWB0MXmH.js";
3
3
  declare function getCoreAppUrl(organizationId: string, appId: string): string;
4
+ /**
5
+ * Checks if the given value is a record (javascript objectish)
6
+ *
7
+ * @param value - Value to check
8
+ * @returns True if the value is a record, false otherwise
9
+ * @internal
10
+ */
11
+ declare function isRecord(value: unknown): value is Record<string, unknown>;
4
12
  declare function isTrueish(value: string | undefined): boolean;
5
- export { doImport, getCoreAppUrl, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getWorkspace, importModule, isCi, isInteractive, isStaging, isTrueish, normalizePath, safeStructuredClone };
13
+ export { doImport, getCoreAppUrl, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getWorkspace, importModule, isCi, isInteractive, isRecord, isStaging, isTrueish, normalizePath, safeStructuredClone };
6
14
  //# sourceMappingURL=util.d.ts.map
@@ -9,6 +9,7 @@ export { getWorkspace } from '../util/getWorkspace.js';
9
9
  export { importModule } from '../util/importModule.js';
10
10
  export { isCi } from '../util/isCi.js';
11
11
  export { isInteractive } from '../util/isInteractive.js';
12
+ export { isRecord } from '../util/isRecord.js';
12
13
  export { isStaging } from '../util/isStaging.js';
13
14
  export { isTrueish } from '../util/isTrueish.js';
14
15
  export { normalizePath } from '../util/normalizePath.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/util.ts"],"sourcesContent":["// Pure in-memory and zero dep utilities\n//\nexport {doImport} from '../util/doImport.js'\nexport {getCoreAppUrl} from '../util/getCoreAppUrl.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {isTrueish} from '../util/isTrueish.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\n"],"names":["doImport","getCoreAppUrl","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isStaging","isTrueish","normalizePath","safeStructuredClone"],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,SAAQA,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,mBAAmB,QAAO,iCAAgC"}
1
+ {"version":3,"sources":["../../src/_exports/util.ts"],"sourcesContent":["// Pure in-memory and zero dep utilities\n//\nexport {doImport} from '../util/doImport.js'\nexport {getCoreAppUrl} from '../util/getCoreAppUrl.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isRecord} from '../util/isRecord.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {isTrueish} from '../util/isTrueish.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\n"],"names":["doImport","getCoreAppUrl","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isRecord","isStaging","isTrueish","normalizePath","safeStructuredClone"],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,SAAQA,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,mBAAmB,QAAO,iCAAgC"}
@@ -5,7 +5,7 @@ import { NotFoundError } from '../../errors/NotFoundError.js';
5
5
  import { importModule } from '../../util/importModule.js';
6
6
  import { findPathForFiles } from '../util/findConfigsPaths.js';
7
7
  import { cliConfigSchema } from './schemas.js';
8
- import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
8
+ import { isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig } from './workbenchApp.js';
9
9
  const cache = new Map();
10
10
  /**
11
11
  * Get the CLI config for a project, given the root path.
@@ -83,9 +83,10 @@ const cache = new Map();
83
83
  cause: err
84
84
  });
85
85
  }
86
- // Branch as early as possible: a branded `unstable_defineApp(...)` opts into
87
- // workbench behavior, so its `app` skips the legacy `app` schema entirely.
88
- if (isWorkbenchApp(cliConfig?.app)) {
86
+ // Branch as early as possible: a branded `defineApplication(...)` app or a
87
+ // branded `unstable_defineMediaLibrary(...)` config opts into workbench
88
+ // behavior, so its `app` skips the legacy `app` schema entirely.
89
+ if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {
89
90
  return parseWorkbenchCliConfig(cliConfig, dirname(configPath));
90
91
  }
91
92
  const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../_exports/debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AACzC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,oBAAmB;AAEzE,MAAMC,QAAQ,IAAIC;AAElB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,aAAaC,QAAgB;IAC3C,MAAMC,SAASJ,MAAMK,GAAG,CAACF;IACzB,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,MAAME,UAAUC,qBAAqBJ,UAAUK,KAAK,CAAC,CAACC;QACpDT,MAAMU,MAAM,CAACP;QACb,MAAMM;IACR;IAEAT,MAAMW,GAAG,CAACR,UAAUG;IACpB,OAAOA;AACT;AAEA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,eAAeC,qBAAqBJ,QAAgB;IACzD,MAAMS,QAAQ,MAAMhB,iBAAiBO,UAAU;QAAC;QAAiB;KAAgB;IACjF,MAAMU,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IAEtD,IAAIH,YAAYI,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIvB,cAAc,CAAC,uBAAuB,EAAES,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAIU,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MACR,CAAC,iCAAiC,EAAEL,YAAYM,GAAG,CAAC,CAACJ,OAASA,KAAKA,IAAI,EAAEK,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1F;IAEA,MAAMC,aAAaR,WAAW,CAAC,EAAE,CAACE,IAAI;IAEtCtB,MAAM,CAAC,yBAAyB,EAAE4B,YAAY;IAE9C,wEAAwE;IACxE,+EAA+E;IAC/E,4EAA4E;IAC5E,iEAAiE;IACjE,MAAMC,aAAa/B,cAAc,YAAYgC,GAAG;IAChD,OAAOD,WAAWtB,KAAK,CAACqB,WAAW;IAEnC,IAAIG;IACJ,IAAI;QACF,MAAMC,SAAS,MAAM9B,aAAwB0B;QAE7C5B,MAAM,yBAAyBgC;QAE/BD,YAAYC;IACd,EAAE,OAAOhB,KAAK;QACZhB,MAAM,kDAAkDgB;QAExD,MAAM,IAAIS,MAAM,+BAA+B;YAACQ,OAAOjB;QAAG;IAC5D;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAIX,eAAe0B,WAAWG,MAAM;QAClC,OAAO5B,wBAAwByB,WAAWhC,QAAQ6B;IACpD;IAEA,MAAM,EAACO,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGjC,gBAAgBkC,SAAS,CAACP;IACzD,IAAI,CAACM,SAAS;QACZrC,MAAM,CAAC,oBAAoB,EAAEoC,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAId,MAAM,CAAC,oBAAoB,EAAEW,MAAMG,OAAO,EAAE,EAAE;YAACN,OAAOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../_exports/debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `defineApplication(...)` app or a\n // branded `unstable_defineMediaLibrary(...)` config opts into workbench\n // behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","isWorkbenchConfig","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AACzC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAO,oBAAmB;AAE5F,MAAMC,QAAQ,IAAIC;AAElB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,aAAaC,QAAgB;IAC3C,MAAMC,SAASJ,MAAMK,GAAG,CAACF;IACzB,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,MAAME,UAAUC,qBAAqBJ,UAAUK,KAAK,CAAC,CAACC;QACpDT,MAAMU,MAAM,CAACP;QACb,MAAMM;IACR;IAEAT,MAAMW,GAAG,CAACR,UAAUG;IACpB,OAAOA;AACT;AAEA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,eAAeC,qBAAqBJ,QAAgB;IACzD,MAAMS,QAAQ,MAAMjB,iBAAiBQ,UAAU;QAAC;QAAiB;KAAgB;IACjF,MAAMU,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IAEtD,IAAIH,YAAYI,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIxB,cAAc,CAAC,uBAAuB,EAAEU,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAIU,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MACR,CAAC,iCAAiC,EAAEL,YAAYM,GAAG,CAAC,CAACJ,OAASA,KAAKA,IAAI,EAAEK,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1F;IAEA,MAAMC,aAAaR,WAAW,CAAC,EAAE,CAACE,IAAI;IAEtCvB,MAAM,CAAC,yBAAyB,EAAE6B,YAAY;IAE9C,wEAAwE;IACxE,+EAA+E;IAC/E,4EAA4E;IAC5E,iEAAiE;IACjE,MAAMC,aAAahC,cAAc,YAAYiC,GAAG;IAChD,OAAOD,WAAWtB,KAAK,CAACqB,WAAW;IAEnC,IAAIG;IACJ,IAAI;QACF,MAAMC,SAAS,MAAM/B,aAAwB2B;QAE7C7B,MAAM,yBAAyBiC;QAE/BD,YAAYC;IACd,EAAE,OAAOhB,KAAK;QACZjB,MAAM,kDAAkDiB;QAExD,MAAM,IAAIS,MAAM,+BAA+B;YAACQ,OAAOjB;QAAG;IAC5D;IAEA,2EAA2E;IAC3E,wEAAwE;IACxE,iEAAiE;IACjE,IAAIZ,eAAe2B,WAAWG,QAAQ7B,kBAAkB0B,WAAWG,MAAM;QACvE,OAAO5B,wBAAwByB,WAAWjC,QAAQ8B;IACpD;IAEA,MAAM,EAACO,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGlC,gBAAgBmC,SAAS,CAACP;IACzD,IAAI,CAACM,SAAS;QACZtC,MAAM,CAAC,oBAAoB,EAAEqC,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAId,MAAM,CAAC,oBAAoB,EAAEW,MAAMG,OAAO,EAAE,EAAE;YAACN,OAAOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
@@ -5,7 +5,7 @@ import { register } from 'tsx/esm/api';
5
5
  import { NotFoundError } from '../../errors/NotFoundError.js';
6
6
  import { tryGetDefaultExport } from '../../util/tryGetDefaultExport.js';
7
7
  import { cliConfigSchema } from './schemas.js';
8
- import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
8
+ import { isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig } from './workbenchApp.js';
9
9
  /**
10
10
  * Get the CLI config for a project synchronously, given the root path.
11
11
  *
@@ -40,9 +40,10 @@ import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
40
40
  } finally{
41
41
  unregister();
42
42
  }
43
- // Branch as early as possible: a branded `unstable_defineApp(...)` opts into
44
- // workbench behavior, so its `app` skips the legacy `app` schema entirely.
45
- if (isWorkbenchApp(cliConfig?.app)) {
43
+ // Branch as early as possible: a branded `defineApplication(...)` app or a
44
+ // branded `unstable_defineMediaLibrary(...)` config opts into workbench
45
+ // behavior, so its `app` skips the legacy `app` schema entirely.
46
+ if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {
46
47
  return parseWorkbenchCliConfig(cliConfig, rootPath);
47
48
  }
48
49
  const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/getCliConfigSync.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {createRequire} from 'node:module'\nimport {join} from 'node:path'\n\nimport {register} from 'tsx/esm/api'\n\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {tryGetDefaultExport} from '../../util/tryGetDefaultExport.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\n/**\n * Get the CLI config for a project synchronously, given the root path.\n *\n * This loads the CLI config in the main thread using tsx/register for TypeScript support.\n * Note: This is a synchronous operation and does not use worker threads like the async version.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfigSync(rootPath: string): CliConfig {\n const possiblePaths = ['sanity.cli.ts', 'sanity.cli.js'].map((file) => join(rootPath, file))\n const configPaths = possiblePaths.filter((path) => existsSync(path))\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`)\n }\n\n const configPath = configPaths[0]\n\n // Register tsx for TypeScript support\n const unregister = register()\n\n let cliConfig: CliConfig | undefined\n try {\n // Use createRequire for synchronous loading in ESM contexts\n // This works when tsx loader is active\n const require = createRequire(import.meta.url)\n const loaded = require(configPath)\n cliConfig = tryGetDefaultExport(loaded) as CliConfig | undefined\n } finally {\n unregister()\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, rootPath)\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`)\n }\n\n // There is a minor difference here because of the `vite` property and how the types\n // aren't as specific as our manually typed `CliConfig` type, thus the cast.\n return data as CliConfig\n}\n"],"names":["existsSync","createRequire","join","register","NotFoundError","tryGetDefaultExport","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","getCliConfigSync","rootPath","possiblePaths","map","file","configPaths","filter","path","length","Error","configPath","unregister","cliConfig","require","url","loaded","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,aAAa,QAAO,cAAa;AACzC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,oBAAmB;AAEzE;;;;;;;;;CASC,GACD,OAAO,SAASC,iBAAiBC,QAAgB;IAC/C,MAAMC,gBAAgB;QAAC;QAAiB;KAAgB,CAACC,GAAG,CAAC,CAACC,OAASX,KAAKQ,UAAUG;IACtF,MAAMC,cAAcH,cAAcI,MAAM,CAAC,CAACC,OAAShB,WAAWgB;IAE9D,IAAIF,YAAYG,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIb,cAAc,CAAC,uBAAuB,EAAEM,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAII,YAAYG,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEJ,YAAYZ,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/E;IAEA,MAAMiB,aAAaL,WAAW,CAAC,EAAE;IAEjC,sCAAsC;IACtC,MAAMM,aAAajB;IAEnB,IAAIkB;IACJ,IAAI;QACF,4DAA4D;QAC5D,uCAAuC;QACvC,MAAMC,UAAUrB,cAAc,YAAYsB,GAAG;QAC7C,MAAMC,SAASF,QAAQH;QACvBE,YAAYhB,oBAAoBmB;IAClC,SAAU;QACRJ;IACF;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAIb,eAAec,WAAWI,MAAM;QAClC,OAAOjB,wBAAwBa,WAAWX;IAC5C;IAEA,MAAM,EAACgB,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGtB,gBAAgBuB,SAAS,CAACR;IACzD,IAAI,CAACO,SAAS;QACZ,MAAM,IAAIV,MAAM,CAAC,oBAAoB,EAAES,MAAMG,OAAO,EAAE;IACxD;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,OAAOJ;AACT"}
1
+ {"version":3,"sources":["../../../src/config/cli/getCliConfigSync.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {createRequire} from 'node:module'\nimport {join} from 'node:path'\n\nimport {register} from 'tsx/esm/api'\n\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {tryGetDefaultExport} from '../../util/tryGetDefaultExport.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig} from './workbenchApp.js'\n\n/**\n * Get the CLI config for a project synchronously, given the root path.\n *\n * This loads the CLI config in the main thread using tsx/register for TypeScript support.\n * Note: This is a synchronous operation and does not use worker threads like the async version.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfigSync(rootPath: string): CliConfig {\n const possiblePaths = ['sanity.cli.ts', 'sanity.cli.js'].map((file) => join(rootPath, file))\n const configPaths = possiblePaths.filter((path) => existsSync(path))\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`)\n }\n\n const configPath = configPaths[0]\n\n // Register tsx for TypeScript support\n const unregister = register()\n\n let cliConfig: CliConfig | undefined\n try {\n // Use createRequire for synchronous loading in ESM contexts\n // This works when tsx loader is active\n const require = createRequire(import.meta.url)\n const loaded = require(configPath)\n cliConfig = tryGetDefaultExport(loaded) as CliConfig | undefined\n } finally {\n unregister()\n }\n\n // Branch as early as possible: a branded `defineApplication(...)` app or a\n // branded `unstable_defineMediaLibrary(...)` config opts into workbench\n // behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, rootPath)\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`)\n }\n\n // There is a minor difference here because of the `vite` property and how the types\n // aren't as specific as our manually typed `CliConfig` type, thus the cast.\n return data as CliConfig\n}\n"],"names":["existsSync","createRequire","join","register","NotFoundError","tryGetDefaultExport","cliConfigSchema","isWorkbenchApp","isWorkbenchConfig","parseWorkbenchCliConfig","getCliConfigSync","rootPath","possiblePaths","map","file","configPaths","filter","path","length","Error","configPath","unregister","cliConfig","require","url","loaded","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,aAAa,QAAO,cAAa;AACzC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAO,oBAAmB;AAE5F;;;;;;;;;CASC,GACD,OAAO,SAASC,iBAAiBC,QAAgB;IAC/C,MAAMC,gBAAgB;QAAC;QAAiB;KAAgB,CAACC,GAAG,CAAC,CAACC,OAASZ,KAAKS,UAAUG;IACtF,MAAMC,cAAcH,cAAcI,MAAM,CAAC,CAACC,OAASjB,WAAWiB;IAE9D,IAAIF,YAAYG,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAId,cAAc,CAAC,uBAAuB,EAAEO,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAII,YAAYG,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEJ,YAAYb,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/E;IAEA,MAAMkB,aAAaL,WAAW,CAAC,EAAE;IAEjC,sCAAsC;IACtC,MAAMM,aAAalB;IAEnB,IAAImB;IACJ,IAAI;QACF,4DAA4D;QAC5D,uCAAuC;QACvC,MAAMC,UAAUtB,cAAc,YAAYuB,GAAG;QAC7C,MAAMC,SAASF,QAAQH;QACvBE,YAAYjB,oBAAoBoB;IAClC,SAAU;QACRJ;IACF;IAEA,2EAA2E;IAC3E,wEAAwE;IACxE,iEAAiE;IACjE,IAAId,eAAee,WAAWI,QAAQlB,kBAAkBc,WAAWI,MAAM;QACvE,OAAOjB,wBAAwBa,WAAWX;IAC5C;IAEA,MAAM,EAACgB,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGvB,gBAAgBwB,SAAS,CAACR;IACzD,IAAI,CAACO,SAAS;QACZ,MAAM,IAAIV,MAAM,CAAC,oBAAoB,EAAES,MAAMG,OAAO,EAAE;IACxD;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,OAAOJ;AACT"}
@@ -1,10 +1,12 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import { z } from 'zod/mini';
3
4
  import { cliConfigSchema } from './schemas.js';
4
5
  // Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that
5
6
  // import would cycle (it depends on cli-core) and pull workbench code into the
6
7
  // hot config-load path.
7
8
  const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
9
+ const WORKBENCH_CONFIG_BRAND = Symbol.for('sanity.workbench.defineConfig');
8
10
  /**
9
11
  * Boolean brand check — used for config-load routing, kept exported for
10
12
  * backward compatibility. For the typed narrowing (the app's declared fields),
@@ -12,6 +14,13 @@ const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
12
14
  */ export function isWorkbenchApp(app) {
13
15
  return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app;
14
16
  }
17
+ /**
18
+ * Boolean brand check for a branded `unstable_defineMediaLibrary(...)` config.
19
+ * A config is not an app — it lives in `cliConfig.app` but skips the legacy `app`
20
+ * schema and `applicationType` stamping, and resolves via `resolveWorkbenchConfig`.
21
+ */ export function isWorkbenchConfig(app) {
22
+ return typeof app === 'object' && app !== null && WORKBENCH_CONFIG_BRAND in app;
23
+ }
15
24
  const STUDIO_CONFIG_FILES = [
16
25
  'sanity.config.ts',
17
26
  'sanity.config.tsx',
@@ -21,23 +30,20 @@ const STUDIO_CONFIG_FILES = [
21
30
  'sanity.config.cjs'
22
31
  ];
23
32
  // Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`
24
- // schema — `unstable_defineApp` doesn't validate, so the loader is the first
33
+ // schema — `defineApplication` doesn't validate, so the loader is the first
25
34
  // place `applicationType` can be checked. Kept in sync by a test there.
26
35
  const APPLICATION_TYPES = [
27
36
  'coreApp',
28
37
  'studio',
29
38
  'canvas',
30
- 'dashboard',
31
- 'media-library'
39
+ 'dashboard'
32
40
  ];
33
- function isApplicationType(value) {
34
- return typeof value === 'string' && APPLICATION_TYPES.includes(value);
35
- }
41
+ const applicationTypeSchema = z.enum(APPLICATION_TYPES);
36
42
  /** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */ function detectApplicationType(projectDir) {
37
43
  return STUDIO_CONFIG_FILES.some((file)=>existsSync(join(projectDir, file))) ? 'studio' : 'coreApp';
38
44
  }
39
45
  /**
40
- * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The
46
+ * Parse a config whose `app` is a branded `defineApplication(...)` result. The
41
47
  * branded `app` bypasses the legacy `app` schema (which would strip its identity
42
48
  * fields and the brand); every other field is still validated.
43
49
  *
@@ -52,15 +58,22 @@ function isApplicationType(value) {
52
58
  cause: error
53
59
  });
54
60
  }
55
- const explicit = app.applicationType;
56
- if (explicit !== undefined && !isApplicationType(explicit)) {
57
- throw new Error(`Invalid \`applicationType\` "${explicit}" in \`unstable_defineApp\` — expected one of: ${APPLICATION_TYPES.join(', ')}`);
58
- }
59
- const applicationType = explicit ?? detectApplicationType(projectDir);
60
61
  // Clone via property descriptors, not spread — carries over the non-enumerable
61
62
  // brand and avoids mutating the caller's object.
62
63
  const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app));
63
- resolvedApp.applicationType = applicationType;
64
+ // A config is not an app: it carries no `applicationType` (it targets one by
65
+ // `appType`), so skip detection/stamping and pass its branded shape through.
66
+ if (isWorkbenchConfig(app)) {
67
+ return {
68
+ ...data,
69
+ app: resolvedApp
70
+ };
71
+ }
72
+ const explicit = app.applicationType;
73
+ if (explicit !== undefined && !applicationTypeSchema.safeParse(explicit).success) {
74
+ throw new Error(`Invalid \`applicationType\` "${explicit}" in \`defineApplication\` — expected one of: ${APPLICATION_TYPES.join(', ')}`);
75
+ }
76
+ resolvedApp.applicationType = explicit ?? detectApplicationType(projectDir);
64
77
  return {
65
78
  ...data,
66
79
  app: resolvedApp
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n// Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that\n// import would cycle (it depends on cli-core) and pull workbench code into the\n// hot config-load path.\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * Boolean brand check — used for config-load routing, kept exported for\n * backward compatibility. For the typed narrowing (the app's declared fields),\n * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.\n */\nexport function isWorkbenchApp(app: CliConfig['app']): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`\n// schema — `unstable_defineApp` doesn't validate, so the loader is the first\n// place `applicationType` can be checked. Kept in sync by a test there.\nconst APPLICATION_TYPES = ['coreApp', 'studio', 'canvas', 'dashboard', 'media-library'] as const\n\n/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */\nexport type ApplicationType = (typeof APPLICATION_TYPES)[number]\n\nfunction isApplicationType(value: unknown): value is ApplicationType {\n return typeof value === 'string' && (APPLICATION_TYPES as readonly string[]).includes(value)\n}\n\n/** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The\n * branded `app` bypasses the legacy `app` schema (which would strip its identity\n * fields and the brand); every other field is still validated.\n *\n * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere\n * downstream. The value lands on a clone, never the caller's object, so\n * re-parsing the same `app` for another directory can't inherit a stale guess.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !isApplicationType(explicit)) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`unstable_defineApp\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n const applicationType = explicit ?? detectApplicationType(projectDir)\n\n // Clone via property descriptors, not spread — carries over the non-enumerable\n // brand and avoids mutating the caller's object.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n resolvedApp.applicationType = applicationType\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","isWorkbenchApp","app","STUDIO_CONFIG_FILES","APPLICATION_TYPES","isApplicationType","value","includes","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","explicit","applicationType","undefined","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,eAAe,QAAO,eAAc;AAG5C,+EAA+E;AAC/E,+EAA+E;AAC/E,wBAAwB;AACxB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AAEvC;;;;CAIC,GACD,OAAO,SAASC,eAAeC,GAAqB;IAClD,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,uBAAuBI;AAC3E;AAEA,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,MAAMC,oBAAoB;IAAC;IAAW;IAAU;IAAU;IAAa;CAAgB;AAKvF,SAASC,kBAAkBC,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAY,AAACF,kBAAwCG,QAAQ,CAACD;AACxF;AAEA,wFAAwF,GACxF,SAASE,sBAAsBC,UAAkB;IAC/C,OAAON,oBAAoBO,IAAI,CAAC,CAACC,OAAShB,WAAWC,KAAKa,YAAYE,UAClE,WACA;AACN;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,wBAAwBC,SAAkB,EAAEJ,UAAkB;IAC5E,MAAM,EAACP,GAAG,EAAE,GAAGY,MAAK,GAAGD;IAGvB,MAAM,EAACE,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGpB,gBAAgBqB,SAAS,CAACJ;IACzD,IAAI,CAACG,SAAS;QACZ,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEH,MAAMI,OAAO,EAAE,EAAE;YAACC,OAAOL;QAAK;IACvE;IAEA,MAAMM,WAAWpB,IAAIqB,eAAe;IACpC,IAAID,aAAaE,aAAa,CAACnB,kBAAkBiB,WAAW;QAC1D,MAAM,IAAIH,MACR,CAAC,6BAA6B,EAAEG,SAAS,+CAA+C,EAAElB,kBAAkBR,IAAI,CAAC,OAAO;IAE5H;IACA,MAAM2B,kBAAkBD,YAAYd,sBAAsBC;IAE1D,+EAA+E;IAC/E,iDAAiD;IACjD,MAAMgB,cAAcC,OAAOC,gBAAgB,CAAC,CAAC,GAAGD,OAAOE,yBAAyB,CAAC1B;IAIjFuB,YAAYF,eAAe,GAAGA;IAE9B,OAAO;QAAC,GAAGR,IAAI;QAAEb,KAAKuB;IAAW;AACnC"}
1
+ {"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {z} from 'zod/mini'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n// Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that\n// import would cycle (it depends on cli-core) and pull workbench code into the\n// hot config-load path.\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\nconst WORKBENCH_CONFIG_BRAND = Symbol.for('sanity.workbench.defineConfig')\n\n/**\n * Boolean brand check — used for config-load routing, kept exported for\n * backward compatibility. For the typed narrowing (the app's declared fields),\n * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.\n */\nexport function isWorkbenchApp(app: unknown): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\n/**\n * Boolean brand check for a branded `unstable_defineMediaLibrary(...)` config.\n * A config is not an app — it lives in `cliConfig.app` but skips the legacy `app`\n * schema and `applicationType` stamping, and resolves via `resolveWorkbenchConfig`.\n */\nexport function isWorkbenchConfig(app: unknown): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_CONFIG_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`\n// schema — `defineApplication` doesn't validate, so the loader is the first\n// place `applicationType` can be checked. Kept in sync by a test there.\nconst APPLICATION_TYPES = ['coreApp', 'studio', 'canvas', 'dashboard'] as const\nconst applicationTypeSchema = z.enum(APPLICATION_TYPES)\n\n/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */\nexport type ApplicationType = z.infer<typeof applicationTypeSchema>\n\n/** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `defineApplication(...)` result. The\n * branded `app` bypasses the legacy `app` schema (which would strip its identity\n * fields and the brand); every other field is still validated.\n *\n * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere\n * downstream. The value lands on a clone, never the caller's object, so\n * re-parsing the same `app` for another directory can't inherit a stale guess.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n // Clone via property descriptors, not spread — carries over the non-enumerable\n // brand and avoids mutating the caller's object.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n\n // A config is not an app: it carries no `applicationType` (it targets one by\n // `appType`), so skip detection/stamping and pass its branded shape through.\n if (isWorkbenchConfig(app)) {\n return {...data, app: resolvedApp} as CliConfig\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !applicationTypeSchema.safeParse(explicit).success) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`defineApplication\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n resolvedApp.applicationType = explicit ?? detectApplicationType(projectDir)\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","z","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","WORKBENCH_CONFIG_BRAND","isWorkbenchApp","app","isWorkbenchConfig","STUDIO_CONFIG_FILES","APPLICATION_TYPES","applicationTypeSchema","enum","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors","explicit","applicationType","undefined"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,eAAe,QAAO,eAAc;AAG5C,+EAA+E;AAC/E,+EAA+E;AAC/E,wBAAwB;AACxB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AACvC,MAAMC,yBAAyBF,OAAOC,GAAG,CAAC;AAE1C;;;;CAIC,GACD,OAAO,SAASE,eAAeC,GAAY;IACzC,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQL,uBAAuBK;AAC3E;AAEA;;;;CAIC,GACD,OAAO,SAASC,kBAAkBD,GAAY;IAC5C,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQF,0BAA0BE;AAC9E;AAEA,MAAME,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,8EAA8E;AAC9E,4EAA4E;AAC5E,wEAAwE;AACxE,MAAMC,oBAAoB;IAAC;IAAW;IAAU;IAAU;CAAY;AACtE,MAAMC,wBAAwBX,EAAEY,IAAI,CAACF;AAKrC,wFAAwF,GACxF,SAASG,sBAAsBC,UAAkB;IAC/C,OAAOL,oBAAoBM,IAAI,CAAC,CAACC,OAASlB,WAAWC,KAAKe,YAAYE,UAClE,WACA;AACN;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,wBAAwBC,SAAkB,EAAEJ,UAAkB;IAC5E,MAAM,EAACP,GAAG,EAAE,GAAGY,MAAK,GAAGD;IAGvB,MAAM,EAACE,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGrB,gBAAgBsB,SAAS,CAACJ;IACzD,IAAI,CAACG,SAAS;QACZ,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEH,MAAMI,OAAO,EAAE,EAAE;YAACC,OAAOL;QAAK;IACvE;IAEA,+EAA+E;IAC/E,iDAAiD;IACjD,MAAMM,cAAcC,OAAOC,gBAAgB,CAAC,CAAC,GAAGD,OAAOE,yBAAyB,CAACvB;IAKjF,6EAA6E;IAC7E,6EAA6E;IAC7E,IAAIC,kBAAkBD,MAAM;QAC1B,OAAO;YAAC,GAAGa,IAAI;YAAEb,KAAKoB;QAAW;IACnC;IAEA,MAAMI,WAAWxB,IAAIyB,eAAe;IACpC,IAAID,aAAaE,aAAa,CAACtB,sBAAsBY,SAAS,CAACQ,UAAUT,OAAO,EAAE;QAChF,MAAM,IAAIE,MACR,CAAC,6BAA6B,EAAEO,SAAS,8CAA8C,EAAErB,kBAAkBX,IAAI,CAAC,OAAO;IAE3H;IACA4B,YAAYK,eAAe,GAAGD,YAAYlB,sBAAsBC;IAEhE,OAAO;QAAC,GAAGM,IAAI;QAAEb,KAAKoB;IAAW;AACnC"}
package/dist/manifest.js CHANGED
@@ -10,9 +10,15 @@ import { z } from 'zod/mini';
10
10
  * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the
11
11
  * CLI produces the payload in full.
12
12
  */ export const coreAppManifestSchema = z.object({
13
- group: z.optional(z.string()),
13
+ dock: z.optional(z.object({
14
+ group: z.optional(z.enum([
15
+ 'dock.system',
16
+ 'dock.applications',
17
+ 'dock.user'
18
+ ])),
19
+ order: z.optional(z.number())
20
+ })),
14
21
  icon: z.optional(z.string()),
15
- priority: z.optional(z.number()),
16
22
  slug: z.optional(z.string()),
17
23
  title: z.optional(z.string()),
18
24
  version: z.string()
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/manifest.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n/**\n * Studio/app manifest schemas. They live in cli-core because more than one\n * package validates manifests: the CLI extracts and writes them, and the\n * workbench dev-server registry stores and rebroadcasts them. Keeping the\n * contract here lets both validate against the same schema without depending on\n * each other.\n */\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the\n * CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n group: z.optional(z.string()),\n icon: z.optional(z.string()),\n priority: z.optional(z.number()),\n slug: z.optional(z.string()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\n/**\n * Studio application manifest (serialized `create-manifest.json`). Kept loose so\n * the CLI isn't coupled to the workbench's evolving client-side schema — the\n * workbench consumer is authoritative on the inner shape. See its\n * `ClientManifest` for the fields clients expect.\n */\nexport const studioManifestSchema = z.record(z.string(), z.unknown())\n\nexport type StudioManifest = z.infer<typeof studioManifestSchema>\n"],"names":["z","coreAppManifestSchema","object","group","optional","string","icon","priority","number","slug","title","version","studioManifestSchema","record","unknown"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBD,EAAEE,MAAM,CAAC;IAC5CC,OAAOH,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BC,MAAMN,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBE,UAAUP,EAAEI,QAAQ,CAACJ,EAAEQ,MAAM;IAC7BC,MAAMT,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBK,OAAOV,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BM,SAASX,EAAEK,MAAM;AACnB,GAAE;AAIF;;;;;CAKC,GACD,OAAO,MAAMO,uBAAuBZ,EAAEa,MAAM,CAACb,EAAEK,MAAM,IAAIL,EAAEc,OAAO,IAAG"}
1
+ {"version":3,"sources":["../src/manifest.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n/**\n * Studio/app manifest schemas. They live in cli-core because more than one\n * package validates manifests: the CLI extracts and writes them, and the\n * workbench dev-server registry stores and rebroadcasts them. Keeping the\n * contract here lets both validate against the same schema without depending on\n * each other.\n */\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the\n * CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n dock: z.optional(\n z.object({\n group: z.optional(z.enum(['dock.system', 'dock.applications', 'dock.user'])),\n order: z.optional(z.number()),\n }),\n ),\n icon: z.optional(z.string()),\n slug: z.optional(z.string()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\n/**\n * Studio application manifest (serialized `create-manifest.json`). Kept loose so\n * the CLI isn't coupled to the workbench's evolving client-side schema — the\n * workbench consumer is authoritative on the inner shape. See its\n * `ClientManifest` for the fields clients expect.\n */\nexport const studioManifestSchema = z.record(z.string(), z.unknown())\n\nexport type StudioManifest = z.infer<typeof studioManifestSchema>\n"],"names":["z","coreAppManifestSchema","object","dock","optional","group","enum","order","number","icon","string","slug","title","version","studioManifestSchema","record","unknown"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBD,EAAEE,MAAM,CAAC;IAC5CC,MAAMH,EAAEI,QAAQ,CACdJ,EAAEE,MAAM,CAAC;QACPG,OAAOL,EAAEI,QAAQ,CAACJ,EAAEM,IAAI,CAAC;YAAC;YAAe;YAAqB;SAAY;QAC1EC,OAAOP,EAAEI,QAAQ,CAACJ,EAAEQ,MAAM;IAC5B;IAEFC,MAAMT,EAAEI,QAAQ,CAACJ,EAAEU,MAAM;IACzBC,MAAMX,EAAEI,QAAQ,CAACJ,EAAEU,MAAM;IACzBE,OAAOZ,EAAEI,QAAQ,CAACJ,EAAEU,MAAM;IAC1BG,SAASb,EAAEU,MAAM;AACnB,GAAE;AAIF;;;;;CAKC,GACD,OAAO,MAAMI,uBAAuBd,EAAEe,MAAM,CAACf,EAAEU,MAAM,IAAIV,EAAEgB,OAAO,IAAG"}
@@ -80,9 +80,15 @@ declare const cliConfigSchema: z.ZodMiniObject<{
80
80
  * CLI produces the payload in full.
81
81
  */
82
82
  declare const coreAppManifestSchema: z.ZodMiniObject<{
83
- group: z.ZodMiniOptional<z.ZodMiniString<string>>;
83
+ dock: z.ZodMiniOptional<z.ZodMiniObject<{
84
+ group: z.ZodMiniOptional<z.ZodMiniEnum<{
85
+ "dock.system": "dock.system";
86
+ "dock.applications": "dock.applications";
87
+ "dock.user": "dock.user";
88
+ }>>;
89
+ order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
90
+ }, z.core.$strip>>;
84
91
  icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
85
- priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
86
92
  slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
87
93
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
88
94
  version: z.ZodMiniString<string>;
@@ -97,4 +103,4 @@ type CoreAppManifest = z.infer<typeof coreAppManifestSchema>;
97
103
  declare const studioManifestSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
98
104
  type StudioManifest = z.infer<typeof studioManifestSchema>;
99
105
  export { cliConfigSchema as a, studioManifestSchema as i, StudioManifest as n, coreAppManifestSchema as r, CoreAppManifest as t };
100
- //# sourceMappingURL=schemas-PPIe9Jz0.d.ts.map
106
+ //# sourceMappingURL=schemas-D1LxkXeZ.d.ts.map
@@ -1,15 +1,21 @@
1
1
  import { r as CliConfig } from "./cliConfig-DUt8uaF6.js";
2
+ import { z } from "zod/mini";
2
3
  /**
3
4
  * Boolean brand check — used for config-load routing, kept exported for
4
5
  * backward compatibility. For the typed narrowing (the app's declared fields),
5
6
  * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.
6
7
  */
7
- declare function isWorkbenchApp(app: CliConfig['app']): boolean;
8
- declare const APPLICATION_TYPES: readonly ["coreApp", "studio", "canvas", "dashboard", "media-library"];
8
+ declare function isWorkbenchApp(app: unknown): boolean;
9
+ declare const applicationTypeSchema: z.ZodMiniEnum<{
10
+ coreApp: "coreApp";
11
+ studio: "studio";
12
+ canvas: "canvas";
13
+ dashboard: "dashboard";
14
+ }>;
9
15
  /** The resolved kind of a workbench app — `studio` or one of the SDK app types. */
10
- type ApplicationType = (typeof APPLICATION_TYPES)[number];
16
+ type ApplicationType = z.infer<typeof applicationTypeSchema>;
11
17
  /**
12
- * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The
18
+ * Parse a config whose `app` is a branded `defineApplication(...)` result. The
13
19
  * branded `app` bypasses the legacy `app` schema (which would strip its identity
14
20
  * fields and the brand); every other field is still validated.
15
21
  *
@@ -19,4 +25,4 @@ type ApplicationType = (typeof APPLICATION_TYPES)[number];
19
25
  */
20
26
  declare function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig;
21
27
  export { isWorkbenchApp as n, parseWorkbenchCliConfig as r, ApplicationType as t };
22
- //# sourceMappingURL=workbenchApp-BkQHUXxH.d.ts.map
28
+ //# sourceMappingURL=workbenchApp-DVKwpTyU.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",