@sanity/cli-core 3.0.0 → 3.2.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.
Files changed (64) hide show
  1. package/README.md +7 -6
  2. package/dist/NonInteractiveError-CSLT5y93.d.ts +13 -0
  3. package/dist/ProjectRootNotFoundError-RgthN9uy.d.ts +47 -0
  4. package/dist/SanityCommand.d.ts +26 -355
  5. package/dist/SanityCommand.js +5 -0
  6. package/dist/SanityCommand.js.map +1 -1
  7. package/dist/_exports/browser.d.ts +2 -21
  8. package/dist/_exports/config.d.ts +5 -661
  9. package/dist/_exports/debug.d.ts +4 -8
  10. package/dist/_exports/debug.js +3 -3
  11. package/dist/_exports/debug.js.map +1 -1
  12. package/dist/_exports/errors.d.ts +12 -77
  13. package/dist/_exports/index.d.ts +34 -1674
  14. package/dist/_exports/package-manager.d.ts +14 -207
  15. package/dist/_exports/request.d.ts +52 -69
  16. package/dist/_exports/request.js +5 -4
  17. package/dist/_exports/request.js.map +1 -1
  18. package/dist/_exports/schemas.d.ts +2 -235
  19. package/dist/_exports/tasks.d.ts +2 -120
  20. package/dist/_exports/telemetry.d.ts +2 -156
  21. package/dist/_exports/types.d.ts +9 -475
  22. package/dist/_exports/types.js.map +1 -1
  23. package/dist/_exports/undeploy.d.ts +38 -51
  24. package/dist/_exports/util.d.ts +6 -137
  25. package/dist/_exports/ux.d.ts +31 -102
  26. package/dist/apiClient-DXlF5ZV3.d.ts +65 -0
  27. package/dist/apiClient.d.ts +2 -79
  28. package/dist/apiClient.js +69 -47
  29. package/dist/apiClient.js.map +1 -1
  30. package/dist/cliConfig-DrUV6Wp6.d.ts +197 -0
  31. package/dist/config/cli/schemas.js.map +1 -1
  32. package/dist/config/cli/types/cliConfig.js.map +1 -1
  33. package/dist/errors/NonInteractiveError.js +2 -1
  34. package/dist/errors/NonInteractiveError.js.map +1 -1
  35. package/dist/errors/ProjectRootNotFoundError.js +2 -1
  36. package/dist/errors/ProjectRootNotFoundError.js.map +1 -1
  37. package/dist/errors/enrichAuthError.js +48 -0
  38. package/dist/errors/enrichAuthError.js.map +1 -0
  39. package/dist/errors/getErrorMessage.js +3 -1
  40. package/dist/errors/getErrorMessage.js.map +1 -1
  41. package/dist/executionContext.d.ts +21 -20
  42. package/dist/executionContext.js.map +1 -1
  43. package/dist/exitCodes.d.ts +3 -3
  44. package/dist/findStudioConfigPath-DeBa0pMT.d.ts +265 -0
  45. package/dist/getWorkspace-CU32E6Uo.d.ts +54 -0
  46. package/dist/mockBrowserEnvironment-BjFQPb2W.d.ts +19 -0
  47. package/dist/noopTelemetry-BJRIvASI.d.ts +64 -0
  48. package/dist/readPackageJson-Cr_lbjVR.d.ts +67 -0
  49. package/dist/recursivelyResolveProjectRoot-BE54uEP6.d.ts +18 -0
  50. package/dist/request/createRequester.js +39 -50
  51. package/dist/request/createRequester.js.map +1 -1
  52. package/dist/request/nodeReadableFromWeb.js +64 -0
  53. package/dist/request/nodeReadableFromWeb.js.map +1 -0
  54. package/dist/resolveLocalPackage-Dr-TNTyk.d.ts +78 -0
  55. package/dist/safeStructuredClone-CWB0MXmH.d.ts +58 -0
  56. package/dist/schemas-Y-KwP413.d.ts +100 -0
  57. package/dist/timer-Dwu2TIgB.d.ts +14 -0
  58. package/dist/tsxWorkerTask-CxG3fWbU.d.ts +97 -0
  59. package/dist/types-CwJLTYDj.d.ts +23 -0
  60. package/dist/types-ZNH3prAd.d.ts +91 -0
  61. package/dist/workbenchApp-CSYpReA-.d.ts +22 -0
  62. package/package.json +16 -12
  63. package/dist/request/createIsolatedRequester.js +0 -75
  64. package/dist/request/createIsolatedRequester.js.map +0 -1
@@ -0,0 +1,64 @@
1
+ import { Readable } from 'node:stream';
2
+ /**
3
+ * Convert a Web `ReadableStream` to a Node.js `Readable`.
4
+ *
5
+ * Prefer this over `Readable.fromWeb()` while the CLI engines range includes
6
+ * Node versions where `fromWeb` is still experimental (`>=22.12 <22.17`).
7
+ *
8
+ * @param stream - Web readable stream of bytes
9
+ * @returns A Node.js readable stream yielding the same chunks
10
+ * @public
11
+ */ export function nodeReadableFromWeb(stream) {
12
+ const reader = stream.getReader();
13
+ let reading = false;
14
+ let ended = false;
15
+ let released = false;
16
+ const releaseLock = ()=>{
17
+ if (released) return;
18
+ released = true;
19
+ reader.releaseLock();
20
+ };
21
+ return new Readable({
22
+ destroy (error, callback) {
23
+ if (ended) {
24
+ releaseLock();
25
+ callback(error);
26
+ return;
27
+ }
28
+ ended = true;
29
+ reader.cancel(error ?? undefined).then(()=>{
30
+ releaseLock();
31
+ callback(error);
32
+ }, (cancelError)=>{
33
+ releaseLock();
34
+ callback(error ?? toError(cancelError));
35
+ });
36
+ },
37
+ read () {
38
+ if (reading || ended) return;
39
+ reading = true;
40
+ reader.read().then(({ done, value })=>{
41
+ reading = false;
42
+ if (ended) return;
43
+ if (done) {
44
+ ended = true;
45
+ releaseLock();
46
+ this.push(null);
47
+ return;
48
+ }
49
+ this.push(value);
50
+ }, (error)=>{
51
+ reading = false;
52
+ if (ended) return;
53
+ ended = true;
54
+ releaseLock();
55
+ this.destroy(toError(error));
56
+ });
57
+ }
58
+ });
59
+ }
60
+ function toError(error) {
61
+ return error instanceof Error ? error : new Error(String(error));
62
+ }
63
+
64
+ //# sourceMappingURL=nodeReadableFromWeb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/request/nodeReadableFromWeb.ts"],"sourcesContent":["import {Readable} from 'node:stream'\n\n/**\n * Convert a Web `ReadableStream` to a Node.js `Readable`.\n *\n * Prefer this over `Readable.fromWeb()` while the CLI engines range includes\n * Node versions where `fromWeb` is still experimental (`>=22.12 <22.17`).\n *\n * @param stream - Web readable stream of bytes\n * @returns A Node.js readable stream yielding the same chunks\n * @public\n */\nexport function nodeReadableFromWeb(stream: ReadableStream<Uint8Array>): Readable {\n const reader = stream.getReader()\n let reading = false\n let ended = false\n let released = false\n\n const releaseLock = () => {\n if (released) return\n released = true\n reader.releaseLock()\n }\n\n return new Readable({\n destroy(error, callback) {\n if (ended) {\n releaseLock()\n callback(error)\n return\n }\n\n ended = true\n reader.cancel(error ?? undefined).then(\n () => {\n releaseLock()\n callback(error)\n },\n (cancelError: unknown) => {\n releaseLock()\n callback(error ?? toError(cancelError))\n },\n )\n },\n read() {\n if (reading || ended) return\n reading = true\n reader.read().then(\n ({done, value}) => {\n reading = false\n if (ended) return\n if (done) {\n ended = true\n releaseLock()\n this.push(null)\n return\n }\n this.push(value)\n },\n (error: unknown) => {\n reading = false\n if (ended) return\n ended = true\n releaseLock()\n this.destroy(toError(error))\n },\n )\n },\n })\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error))\n}\n"],"names":["Readable","nodeReadableFromWeb","stream","reader","getReader","reading","ended","released","releaseLock","destroy","error","callback","cancel","undefined","then","cancelError","toError","read","done","value","push","Error","String"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,cAAa;AAEpC;;;;;;;;;CASC,GACD,OAAO,SAASC,oBAAoBC,MAAkC;IACpE,MAAMC,SAASD,OAAOE,SAAS;IAC/B,IAAIC,UAAU;IACd,IAAIC,QAAQ;IACZ,IAAIC,WAAW;IAEf,MAAMC,cAAc;QAClB,IAAID,UAAU;QACdA,WAAW;QACXJ,OAAOK,WAAW;IACpB;IAEA,OAAO,IAAIR,SAAS;QAClBS,SAAQC,KAAK,EAAEC,QAAQ;YACrB,IAAIL,OAAO;gBACTE;gBACAG,SAASD;gBACT;YACF;YAEAJ,QAAQ;YACRH,OAAOS,MAAM,CAACF,SAASG,WAAWC,IAAI,CACpC;gBACEN;gBACAG,SAASD;YACX,GACA,CAACK;gBACCP;gBACAG,SAASD,SAASM,QAAQD;YAC5B;QAEJ;QACAE;YACE,IAAIZ,WAAWC,OAAO;YACtBD,UAAU;YACVF,OAAOc,IAAI,GAAGH,IAAI,CAChB,CAAC,EAACI,IAAI,EAAEC,KAAK,EAAC;gBACZd,UAAU;gBACV,IAAIC,OAAO;gBACX,IAAIY,MAAM;oBACRZ,QAAQ;oBACRE;oBACA,IAAI,CAACY,IAAI,CAAC;oBACV;gBACF;gBACA,IAAI,CAACA,IAAI,CAACD;YACZ,GACA,CAACT;gBACCL,UAAU;gBACV,IAAIC,OAAO;gBACXA,QAAQ;gBACRE;gBACA,IAAI,CAACC,OAAO,CAACO,QAAQN;YACvB;QAEJ;IACF;AACF;AAEA,SAASM,QAAQN,KAAc;IAC7B,OAAOA,iBAAiBW,QAAQX,QAAQ,IAAIW,MAAMC,OAAOZ;AAC3D"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Get the version of a package installed locally.
3
+ *
4
+ * @param moduleName - The name of the package in npm.
5
+ * @param workDir - The working directory to resolve the module from. (aka project root)
6
+ * @returns The version of the package installed locally.
7
+ * @internal
8
+ */
9
+ declare function getLocalPackageVersion(moduleName: string, workDir: string): Promise<string | null>;
10
+ /**
11
+ * Resolve the filesystem directory of a locally installed package using Node
12
+ * module resolution. Works correctly with hoisted packages in monorepos/workspaces,
13
+ * pnpm symlinks, and other non-standard node_modules layouts.
14
+ *
15
+ * @param moduleName - The name of the package in npm.
16
+ * @param workDir - The working directory to resolve the module from. (aka project root)
17
+ * @returns The absolute path to the package directory.
18
+ * @internal
19
+ */
20
+ declare function getLocalPackageDir(moduleName: string, workDir: string): string;
21
+ /**
22
+ * Resolves and imports a package from the local project's node_modules,
23
+ * relative to the given working directory. This avoids circular dependencies
24
+ * and ensures the correct version of the package is used.
25
+ *
26
+ * @param packageName - The name of the package to resolve (e.g., 'sanity')
27
+ * @param workDir - The working directory to resolve the package from
28
+ * @returns The imported module
29
+ * @throws If the package cannot be resolved or imported
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const {createSchema} = await resolveLocalPackage('sanity', workDir)
34
+ * ```
35
+ *
36
+ * @internal
37
+ */
38
+ declare function resolveLocalPackage<T = unknown>(packageName: string, workDir: string): Promise<T>;
39
+ /**
40
+ * Resolves the URL of a package from the local project's node_modules,
41
+ * relative to the given working directory, without importing it.
42
+ *
43
+ * @param packageName - The name of the package to resolve (e.g., 'sanity')
44
+ * @param workDir - The working directory to resolve the package from
45
+ * @returns The resolved URL of the package entry point
46
+ * @throws If the package cannot be resolved
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * // Resolve a transitive dependency via its parent package:
51
+ * const sanityUrl = resolveLocalPackagePath('sanity', workDir)
52
+ * const uiUrl = resolveLocalPackagePathFrom('@sanity/ui', sanityUrl)
53
+ * ```
54
+ *
55
+ * @internal
56
+ */
57
+ declare function resolveLocalPackagePath(packageName: string, workDir: string): URL;
58
+ /**
59
+ * Resolves and imports a package relative to another resolved module URL.
60
+ * Useful for resolving transitive dependencies that may not be directly
61
+ * accessible from the project root (e.g., in pnpm strict mode).
62
+ *
63
+ * @param packageName - The name of the package to resolve
64
+ * @param parentUrl - The URL of the parent module to resolve from
65
+ * @returns The imported module
66
+ * @throws If the package cannot be resolved or imported
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const sanityUrl = resolveLocalPackagePath('sanity', workDir)
71
+ * const ui = await resolveLocalPackageFrom<typeof import('@sanity/ui')>('@sanity/ui', sanityUrl)
72
+ * ```
73
+ *
74
+ * @internal
75
+ */
76
+ declare function resolveLocalPackageFrom<T = unknown>(packageName: string, parentUrl: URL): Promise<T>;
77
+ export { getLocalPackageVersion as a, getLocalPackageDir as i, resolveLocalPackageFrom as n, resolveLocalPackagePath as r, resolveLocalPackage as t };
78
+ //# sourceMappingURL=resolveLocalPackage-Dr-TNTyk.d.ts.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * This function is a replacement for built in dynamic import
3
+ * This handles the case for windows file paths especially for absolute paths.
4
+ *
5
+ * @param source - File path
6
+ */
7
+ declare function doImport(source: string): Promise<any>;
8
+ interface ImportModuleOptions {
9
+ /**
10
+ * Whether to return the default export of the module.
11
+ * Default: true
12
+ */
13
+ default?: boolean;
14
+ /**
15
+ * Path to the tsconfig file to use for the import. If not provided, the tsconfig
16
+ * will be inferred from the nearest `tsconfig.json` file.
17
+ */
18
+ tsconfigPath?: string;
19
+ }
20
+ /**
21
+ * Imports a module using jiti and returns its exports.
22
+ * This is a thin wrapper around tsx to allow swapping out the underlying implementation in the future if needed.
23
+ *
24
+ * @param filePath - Path to the module to import.
25
+ * @param options - Options for the importModule function.
26
+ * @returns The exported module.
27
+ *
28
+ * @internal
29
+ */
30
+ declare function importModule<T = unknown>(filePath: string | URL, options?: ImportModuleOptions): Promise<T>;
31
+ declare const isCi: () => boolean;
32
+ declare function isInteractive(): boolean;
33
+ /**
34
+ * Checks if the environment is staging.
35
+ *
36
+ * @returns True if the environment is staging, false otherwise
37
+ * @internal
38
+ */
39
+ declare function isStaging(): boolean;
40
+ /**
41
+ * Normalizes a path for cross-platform comparison by converting backslashes to forward slashes.
42
+ * Useful for converting windows paths to unix paths.
43
+ *
44
+ * @param path - Path to normalize
45
+ * @returns Normalized path with forward slashes
46
+ * @public
47
+ */
48
+ declare function normalizePath(path: string): string;
49
+ /**
50
+ * `structuredClone()`, but doesn't throw on non-clonable values - instead it drops them.
51
+ *
52
+ * @param obj - The object to clone.
53
+ * @returns The cloned object.
54
+ * @internal
55
+ */
56
+ declare function safeStructuredClone<T>(obj: T): T;
57
+ export { isCi as a, isInteractive as i, normalizePath as n, importModule as o, isStaging as r, doImport as s, safeStructuredClone as t };
58
+ //# sourceMappingURL=safeStructuredClone-CWB0MXmH.d.ts.map
@@ -0,0 +1,100 @@
1
+ import { a as ReactCompilerConfig, o as TypeGenConfig, s as UserViteConfig } from "./cliConfig-DrUV6Wp6.js";
2
+ import { z } from "zod/mini";
3
+ /**
4
+ * @public
5
+ */
6
+ declare const cliConfigSchema: z.ZodMiniObject<{
7
+ api: z.ZodMiniOptional<z.ZodMiniObject<{
8
+ dataset: z.ZodMiniOptional<z.ZodMiniString<string>>;
9
+ projectId: z.ZodMiniOptional<z.ZodMiniString<string>>;
10
+ }, z.core.$strip>>;
11
+ app: z.ZodMiniOptional<z.ZodMiniObject<{
12
+ entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
13
+ icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
14
+ id: z.ZodMiniOptional<z.ZodMiniString<string>>;
15
+ organizationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
16
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
17
+ visibility: z.ZodMiniOptional<z.ZodMiniEnum<{
18
+ default: "default";
19
+ unlisted: "unlisted";
20
+ disabled: "disabled";
21
+ }>>;
22
+ }, z.core.$strip>>;
23
+ autoUpdates: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
24
+ deployment: z.ZodMiniOptional<z.ZodMiniObject<{
25
+ appId: z.ZodMiniOptional<z.ZodMiniString<string>>;
26
+ autoUpdates: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
27
+ }, z.core.$strip>>;
28
+ graphql: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
29
+ filterSuffix: z.ZodMiniOptional<z.ZodMiniString<string>>;
30
+ generation: z.ZodMiniOptional<z.ZodMiniEnum<{
31
+ gen1: "gen1";
32
+ gen2: "gen2";
33
+ gen3: "gen3";
34
+ }>>;
35
+ id: z.ZodMiniOptional<z.ZodMiniString<string>>;
36
+ nonNullDocumentFields: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
37
+ playground: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
38
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
39
+ tag: z.ZodMiniOptional<z.ZodMiniString<string>>;
40
+ workspace: z.ZodMiniOptional<z.ZodMiniString<string>>;
41
+ }, z.core.$strip>>>;
42
+ mediaLibrary: z.ZodMiniOptional<z.ZodMiniObject<{
43
+ aspectsPath: z.ZodMiniOptional<z.ZodMiniString<string>>;
44
+ }, z.core.$strip>>;
45
+ project: z.ZodMiniOptional<z.ZodMiniObject<{
46
+ basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
47
+ }, z.core.$strip>>;
48
+ reactCompiler: z.ZodMiniOptional<z.ZodMiniCustom<boolean | ReactCompilerConfig, boolean | ReactCompilerConfig>>;
49
+ reactStrictMode: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
50
+ schemaExtraction: z.ZodMiniOptional<z.ZodMiniObject<{
51
+ enabled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
52
+ enforceRequiredFields: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
53
+ path: z.ZodMiniOptional<z.ZodMiniString<string>>;
54
+ watchPatterns: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
55
+ workspace: z.ZodMiniOptional<z.ZodMiniString<string>>;
56
+ }, z.core.$strip>>;
57
+ server: z.ZodMiniOptional<z.ZodMiniObject<{
58
+ hostname: z.ZodMiniOptional<z.ZodMiniString<string>>;
59
+ port: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
60
+ }, z.core.$strip>>;
61
+ studioHost: z.ZodMiniOptional<z.ZodMiniString<string>>;
62
+ unstable_bundledDev: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
63
+ vite: z.ZodMiniOptional<z.ZodMiniCustom<UserViteConfig, UserViteConfig>>;
64
+ typegen: z.ZodMiniOptional<z.ZodMiniCustom<Partial<TypeGenConfig> & {
65
+ enabled?: boolean;
66
+ }, Partial<TypeGenConfig> & {
67
+ enabled?: boolean;
68
+ }>>;
69
+ }, z.core.$strip>;
70
+ /**
71
+ * Studio/app manifest schemas. They live in cli-core because more than one
72
+ * package validates manifests: the CLI extracts and writes them, and the
73
+ * workbench dev-server registry stores and rebroadcasts them. Keeping the
74
+ * contract here lets both validate against the same schema without depending on
75
+ * each other.
76
+ */
77
+ /**
78
+ * Core-app application manifest. Mirrors the workbench's
79
+ * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the
80
+ * CLI produces the payload in full.
81
+ */
82
+ declare const coreAppManifestSchema: z.ZodMiniObject<{
83
+ group: z.ZodMiniOptional<z.ZodMiniString<string>>;
84
+ icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
85
+ priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
86
+ slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
87
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
88
+ version: z.ZodMiniString<string>;
89
+ }, z.core.$strip>;
90
+ type CoreAppManifest = z.infer<typeof coreAppManifestSchema>;
91
+ /**
92
+ * Studio application manifest (serialized `create-manifest.json`). Kept loose so
93
+ * the CLI isn't coupled to the workbench's evolving client-side schema — the
94
+ * workbench consumer is authoritative on the inner shape. See its
95
+ * `ClientManifest` for the fields clients expect.
96
+ */
97
+ declare const studioManifestSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
98
+ type StudioManifest = z.infer<typeof studioManifestSchema>;
99
+ export { cliConfigSchema as a, studioManifestSchema as i, StudioManifest as n, coreAppManifestSchema as r, CoreAppManifest as t };
100
+ //# sourceMappingURL=schemas-Y-KwP413.d.ts.map
@@ -0,0 +1,14 @@
1
+ declare function colorizeJson(input: unknown): string;
2
+ interface TimeMeasurer {
3
+ end: (name: string) => number;
4
+ getTimings: () => Record<string, number>;
5
+ start: (name: string) => void;
6
+ }
7
+ /**
8
+ * Starts a terminal timer
9
+ *
10
+ * @internal
11
+ */
12
+ declare function getTimer(): TimeMeasurer;
13
+ export { colorizeJson as n, getTimer as t };
14
+ //# sourceMappingURL=timer-Dwu2TIgB.d.ts.map
@@ -0,0 +1,97 @@
1
+ import { n as RequireProps } from "./types-CwJLTYDj.js";
2
+ import { Worker, WorkerOptions } from "node:worker_threads";
3
+ import { URL as URL$1 } from "node:url";
4
+ /**
5
+ * Options for the studio worker task
6
+ *
7
+ * @internal
8
+ */
9
+ interface StudioWorkerTaskOptions extends RequireProps<WorkerOptions, 'name'> {
10
+ studioRootPath: string;
11
+ /** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */
12
+ timeout?: number;
13
+ }
14
+ /**
15
+ * Executes a worker file in a Sanity Studio browser context.
16
+ *
17
+ * This uses a combination of vite for "bundling" + jsdom for emulating a browser
18
+ * environment under the hood, which means that the same thing that will work in vite
19
+ * _should_ work in the worker - to a degree. If the user has defined any typescript
20
+ * path aliases, these will have to be added as aliases to the vite config - the same
21
+ * behavior as you would see with regular vite. Other things that are accounted for:
22
+ *
23
+ * - TypeScript support (+JSX, enums and other "compilation needed" features)
24
+ * - CSS, font and other file imports will resolve to a file path
25
+ * - CSS module imports will resolve to a javascript object of class names
26
+ * - Environment variables are available both as `import.meta.env` and `process.env`,
27
+ * and `.env` files are loaded in the same way that they would in a Sanity studio.
28
+ * - Browser globals not available in a Node.js environment but _are_ provided by JSDOM
29
+ * are defined directly to the Node environment as globals. While this polutes the
30
+ * global namespace, it is done only in the worker thread.
31
+ * - Certain browser globals that are _not_ available in JSDOM are also provided to the
32
+ * global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.
33
+ * These are provided with a minimal stub implementation to make them not crash.
34
+ *
35
+ * @param filePath - Path to the worker file (`.ts` works and is encouraged)
36
+ * @param options - Options to pass to the worker
37
+ * @returns A promise that resolves with the message from the worker
38
+ * @throws If the file does not exist
39
+ * @throws If the worker exits with a non-zero code
40
+ * @internal
41
+ */
42
+ declare function studioWorkerTask<T = unknown>(filePath: URL, options: StudioWorkerTaskOptions): Promise<T>;
43
+ /**
44
+ * Creates a new worker for a studio worker task.
45
+ *
46
+ * This uses a combination of vite for "bundling" + jsdom for emulating a browser
47
+ * environment under the hood, which means that the same thing that will work in vite
48
+ * _should_ work in the worker - to a degree. If the user has defined any typescript
49
+ * path aliases, these will have to be added as aliases to the vite config - the same
50
+ * behavior as you would see with regular vite. Other things that are accounted for:
51
+ *
52
+ * - TypeScript support (+JSX, enums and other "compilation needed" features)
53
+ * - CSS, font and other file imports will resolve to a file path
54
+ * - CSS module imports will resolve to a javascript object of class names
55
+ * - Environment variables are available both as `import.meta.env` and `process.env`,
56
+ * and `.env` files are loaded in the same way that they would in a Sanity studio.
57
+ * - Browser globals not available in a Node.js environment but _are_ provided by JSDOM
58
+ * are defined directly to the Node environment as globals. While this polutes the
59
+ * global namespace, it is done only in the worker thread.
60
+ * - Certain browser globals that are _not_ available in JSDOM are also provided to the
61
+ * global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.
62
+ * These are provided with a minimal stub implementation to make them not crash.
63
+ *
64
+ * @param filePath - Path to the worker file (`.ts` works and is encouraged)
65
+ * @param options - Options to pass to the worker
66
+ * @returns A promise that resolves with the message from the worker
67
+ * @throws If the file does not exist
68
+ * @throws If the worker exits with a non-zero code
69
+ * @internal
70
+ */
71
+ declare function createStudioWorker(filePath: URL, options: StudioWorkerTaskOptions): Worker;
72
+ /**
73
+ * Options for the tsx worker task
74
+ *
75
+ * @internal
76
+ */
77
+ interface TsxWorkerTaskOptions extends RequireProps<WorkerOptions, 'name'> {
78
+ rootPath: string;
79
+ }
80
+ /**
81
+ * Executes a worker file with tsx registered. This means you can import other
82
+ * typescript with fairly rich syntax, and still have that only apply to the worker
83
+ * thread instead of the full parent process. The worker should emit a message when
84
+ * complete using `parentPort`. Once it has received a single message will resolve the
85
+ * returned promise with that message. If you are expecting multiple messages, you will
86
+ * have to implement another method ;)
87
+ *
88
+ * @param filePath - Path to the worker file
89
+ * @param options - Options to pass to the worker
90
+ * @returns A promise that resolves with the message from the worker
91
+ * @throws If the file does not exist
92
+ * @throws If the worker exits with a non-zero code
93
+ * @internal
94
+ */
95
+ declare function tsxWorkerTask<T = unknown>(filePath: URL$1, options: TsxWorkerTaskOptions): Promise<T>;
96
+ export { createStudioWorker as n, studioWorkerTask as r, tsxWorkerTask as t };
97
+ //# sourceMappingURL=tsxWorkerTask-CxG3fWbU.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { Command } from "@oclif/core";
2
+ interface Output {
3
+ error: Command['error'];
4
+ log: Command['log'];
5
+ warn: Command['warn'];
6
+ }
7
+ type RequireProps<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
8
+ type SanityOrgUser = {
9
+ /**
10
+ * Null when authenticating with an API token rather than a user account —
11
+ * robot tokens resolve to a user whose `email` and `familyName` are null.
12
+ * Use `getUserDisplayName()` for anything user-facing.
13
+ */
14
+ email: string | null;
15
+ id: string;
16
+ name: string;
17
+ profileImage?: string;
18
+ /** `sanity-token` is returned when authenticating with an API token. */
19
+ provider: 'github' | 'google' | 'sanity' | 'sanity-token' | `saml-${string}`;
20
+ tosAcceptedAt?: string;
21
+ };
22
+ export { RequireProps as n, SanityOrgUser as r, Output as t };
23
+ //# sourceMappingURL=types-CwJLTYDj.d.ts.map
@@ -0,0 +1,91 @@
1
+ /**
2
+ * 'unknown' - we don't know if the user has consented or not (e.g. something went wrong)
3
+ * 'unset' - the user has not yet been asked for consent
4
+ * 'granted' - the user has consented
5
+ * 'denied' - the user has denied consent
6
+ */
7
+ declare type ConsentStatus = 'undetermined' | 'unset' | 'granted' | 'denied';
8
+ declare interface DeferredEvent<Data = unknown, Event extends DefinedTelemetryLog<Data> = DefinedTelemetryLog<Data>> {
9
+ createdAt: string;
10
+ event: Event;
11
+ data: Data;
12
+ }
13
+ declare interface DefinedTelemetryLog<Schema> {
14
+ type: 'log';
15
+ /** Unique name of the event */
16
+ name: string;
17
+ /** Event version. Increment this by 1 whenever the shape of the data changes in a non-backwards compatible way */
18
+ version: number;
19
+ /** Description of log event */
20
+ description?: string;
21
+ /**
22
+ * Max sample rate of this event.
23
+ * Calling telemetry.log(EventDefinition, data) repeatedly will submit at most one event every specified time interval (in milliseconds)
24
+ * */
25
+ maxSampleRate?: number;
26
+ /** Data schema. Will not be accessible at runtime */
27
+ schema: Schema;
28
+ }
29
+ declare interface DefinedTelemetryTrace<Data = void, Context = void> {
30
+ type: 'trace';
31
+ /** Unique name of the trace */
32
+ name: string;
33
+ /** Trace version. Increment this by 1 whenever the shape of the data changes in a non-backwards compatible way */
34
+ version: number;
35
+ /** Description of trace */
36
+ description?: string;
37
+ /** Data schema. Will not be accessible at runtime */
38
+ schema: Data;
39
+ /** Contextual data schema. Will not be accessible at runtime */
40
+ context: Context;
41
+ }
42
+ /**
43
+ * Note that `sessionId` is removed from the signature of these functions
44
+ */
45
+ declare interface TelemetryLogger<UserProperties> {
46
+ updateUserProperties(properties: UserProperties): void;
47
+ resume(events: DeferredEvent[]): void;
48
+ log<Data>(event: DefinedTelemetryLog<Data>, data: Data): void;
49
+ log<Data extends void>(event: DefinedTelemetryLog<Data>): void;
50
+ trace<Data>(event: DefinedTelemetryTrace<Data>, context?: unknown): TelemetryTrace<UserProperties, Data>;
51
+ }
52
+ declare interface TelemetryTrace<UserProperties, Data> {
53
+ start(): void;
54
+ log(data: Data): void;
55
+ error(error: Error): void;
56
+ complete(): void;
57
+ newContext(name: string): TelemetryLogger<UserProperties>;
58
+ await<P extends Promise<Data>>(promise: P): P;
59
+ await<P extends Promise<unknown>>(promise: P, finalData: Data): P;
60
+ }
61
+ type ConsentInformation = {
62
+ reason: 'fetchError' | 'unauthenticated';
63
+ status: Extract<ConsentStatus, 'undetermined'>;
64
+ } | {
65
+ reason?: 'localOverride';
66
+ status: Extract<ConsentStatus, 'denied'>;
67
+ } | {
68
+ reason?: never;
69
+ status: Extract<ConsentStatus, 'granted'>;
70
+ } | {
71
+ reason?: never;
72
+ status: Extract<ConsentStatus, 'unset'>;
73
+ };
74
+ /**
75
+ * @public
76
+ */
77
+ interface TelemetryUserProperties {
78
+ cliVersion: string;
79
+ cpuArchitecture: string;
80
+ machinePlatform: string;
81
+ runtime: string;
82
+ runtimeVersion: string;
83
+ dataset?: string;
84
+ projectId?: string;
85
+ }
86
+ /**
87
+ * @public
88
+ */
89
+ type CLITelemetryStore = TelemetryLogger<TelemetryUserProperties>;
90
+ export { ConsentInformation as n, TelemetryUserProperties as r, CLITelemetryStore as t };
91
+ //# sourceMappingURL=types-ZNH3prAd.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { r as CliConfig } from "./cliConfig-DrUV6Wp6.js";
2
+ /**
3
+ * Boolean brand check — used for config-load routing, kept exported for
4
+ * backward compatibility. For the typed narrowing (the app's declared fields),
5
+ * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.
6
+ */
7
+ declare function isWorkbenchApp(app: CliConfig['app']): boolean;
8
+ declare const APPLICATION_TYPES: readonly ["coreApp", "studio", "canvas", "dashboard", "media-library"];
9
+ /** The resolved kind of a workbench app — `studio` or one of the SDK app types. */
10
+ type ApplicationType = (typeof APPLICATION_TYPES)[number];
11
+ /**
12
+ * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The
13
+ * branded `app` bypasses the legacy `app` schema (which would strip its identity
14
+ * fields and the brand); every other field is still validated.
15
+ *
16
+ * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere
17
+ * downstream. The value lands on a clone, never the caller's object, so
18
+ * re-parsing the same `app` for another directory can't inherit a stale guess.
19
+ */
20
+ declare function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig;
21
+ export { isWorkbenchApp as n, parseWorkbenchCliConfig as r, ApplicationType as t };
22
+ //# sourceMappingURL=workbenchApp-CSYpReA-.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",
@@ -109,50 +109,54 @@
109
109
  "dependencies": {
110
110
  "@inquirer/prompts": "^8.5.2",
111
111
  "@oclif/core": "^4.11.14",
112
- "@sanity/client": "^7.25.0",
112
+ "@sanity/client": "^8.1.0",
113
113
  "boxen": "^8.0.1",
114
- "debug": "^4.4.3",
115
114
  "empathic": "^2.0.1",
116
- "get-it": "^8.8.0",
115
+ "get-it": "^9.5.0",
117
116
  "get-tsconfig": "^4.14.0",
118
117
  "import-meta-resolve": "^4.2.0",
119
118
  "jiti": "^2.7.0",
120
119
  "jsdom": "^29.1.1",
121
120
  "json-lexer": "^1.2.0",
122
121
  "log-symbols": "^7.0.1",
122
+ "obug": "^2.1.4",
123
123
  "ora": "^9.0.0",
124
124
  "rxjs": "^7.8.2",
125
- "tsx": "^4.23.1",
126
- "vite": "^8.2.0",
125
+ "tsx": "^4.23.12",
126
+ "vite": "^8.2.1",
127
127
  "vite-node": "^6.0.0",
128
128
  "wrap-ansi": "^9.0.2",
129
129
  "zod": "^4.4.3"
130
130
  },
131
131
  "devDependencies": {
132
132
  "@eslint/compat": "^2.1.0",
133
- "@sanity/pkg-utils": "^11.0.17",
133
+ "@sanity/pkg-utils": "^12.2.0",
134
134
  "@sanity/telemetry": "^1.1.0",
135
135
  "@swc/cli": "^0.8.1",
136
136
  "@swc/core": "^1.15.43",
137
- "@types/debug": "^4.1.13",
138
137
  "@types/jsdom": "^28.0.3",
139
138
  "@types/node": "^22.20.0",
140
139
  "babel-plugin-react-compiler": "^1.0.0",
141
140
  "eslint": "^10.7.0",
141
+ "oxc-transform-react": "^0.145.0",
142
142
  "publint": "^0.3.21",
143
143
  "sanity": "^6.7.0",
144
144
  "typescript": "^6.0.3",
145
- "vitest": "^4.1.10",
145
+ "vitest": "^4.1.11",
146
146
  "@repo/package.config": "0.0.1",
147
- "@sanity/eslint-config-cli": "1.1.3",
148
- "@repo/tsconfig": "3.70.0"
147
+ "@repo/tsconfig": "3.70.0",
148
+ "@sanity/eslint-config-cli": "1.1.3"
149
149
  },
150
150
  "peerDependencies": {
151
- "babel-plugin-react-compiler": "*"
151
+ "babel-plugin-react-compiler": "*",
152
+ "oxc-transform-react": "*"
152
153
  },
153
154
  "peerDependenciesMeta": {
154
155
  "babel-plugin-react-compiler": {
155
156
  "optional": true
157
+ },
158
+ "oxc-transform-react": {
159
+ "optional": true
156
160
  }
157
161
  },
158
162
  "engines": {