@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,197 @@
1
+ import { PluginOptions } from "babel-plugin-react-compiler";
2
+ import { ReactCompilerOptions } from "oxc-transform-react";
3
+ import { ConfigEnv, InlineConfig } from "vite";
4
+ /**
5
+ * @public
6
+ */
7
+ type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig;
8
+ /**
9
+ * Configuration for React Compiler.
10
+ *
11
+ * The `transform` field selects which React Compiler transform to run; the
12
+ * remaining options are passed to the selected transform:
13
+ *
14
+ * - `'babel'` (default) - the Babel plugin
15
+ * ({@link https://www.npmjs.com/package/babel-plugin-react-compiler | babel-plugin-react-compiler}
16
+ * must be installed in your project)
17
+ * - `'oxc'` (experimental) - the native Rust port
18
+ * ({@link https://www.npmjs.com/package/oxc-transform-react | oxc-transform-react}
19
+ * must be installed in your project)
20
+ *
21
+ * @public
22
+ */
23
+ type ReactCompilerConfig = (PluginOptions & {
24
+ transform?: 'babel';
25
+ }) | (ReactCompilerOptions & {
26
+ transform: 'oxc';
27
+ });
28
+ interface TypeGenConfig {
29
+ formatGeneratedCode: boolean;
30
+ generates: string;
31
+ overloadClientMethods: boolean;
32
+ path: string | string[];
33
+ schema: string;
34
+ }
35
+ /**
36
+ * Dashboard visibility an application can declare. Mirrors Brett's canonical
37
+ * `VISIBILITIES` — the source of truth lives in the application service.
38
+ * @public
39
+ */
40
+ declare const APP_VISIBILITIES: readonly ["default", "unlisted", "disabled"];
41
+ /** @public */
42
+ type AppVisibility = (typeof APP_VISIBILITIES)[number];
43
+ /**
44
+ * @public
45
+ */
46
+ interface CliConfig {
47
+ /** The project ID and dataset the Sanity CLI should use to run its commands */
48
+ api?: {
49
+ dataset?: string;
50
+ projectId?: string;
51
+ };
52
+ /** Configuration for custom Sanity apps built with the App SDK */
53
+ app?: {
54
+ /** The entrypoint for your custom app. By default, `src/App.tsx` */
55
+ entry?: string;
56
+ /**
57
+ * Path to an icon file relative to project root.
58
+ * The file must be an SVG.
59
+ */
60
+ icon?: string;
61
+ /** @deprecated Use deployment.appId */
62
+ id?: string;
63
+ /** The ID for the Sanity organization that manages this application */
64
+ organizationId?: string;
65
+ /** The title of the custom app, as it is seen in Dashboard UI */
66
+ title?: string;
67
+ /** Dashboard visibility of the application. Defaults to `default`. */
68
+ visibility?: AppVisibility;
69
+ };
70
+ /** @deprecated Use deployment.autoUpdates */
71
+ autoUpdates?: boolean;
72
+ /** Options for custom app and Studio deployments */
73
+ deployment?: {
74
+ /**
75
+ * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.
76
+ * Get your app ID by either:
77
+ * 1. Checking the output of `sanity deploy`, or
78
+ * 2. Checking your project’s Studio tab at https://sanity.io/manage
79
+ *
80
+ * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.
81
+ * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}
82
+ */
83
+ appId?: string;
84
+ /**
85
+ * Enable automatic updates for your Studio or custom app’s Sanity dependencies.
86
+ * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}
87
+ */
88
+ autoUpdates?: boolean;
89
+ };
90
+ /** Define the GraphQL APIs that the CLI can deploy and interact with */
91
+ graphql?: Array<{
92
+ filterSuffix?: string;
93
+ generation?: 'gen1' | 'gen2' | 'gen3';
94
+ id?: string;
95
+ nonNullDocumentFields?: boolean;
96
+ playground?: boolean;
97
+ source?: string;
98
+ tag?: string;
99
+ workspace?: string;
100
+ }>;
101
+ /** Configuration for the Media Library */
102
+ mediaLibrary?: {
103
+ /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */
104
+ aspectsPath?: string;
105
+ };
106
+ /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */
107
+ project?: {
108
+ basePath?: string;
109
+ };
110
+ /**
111
+ * Configuration options for React Compiler. Pass `true` to enable it with
112
+ * the default (babel) transform, or an object to configure it — see
113
+ * {@link ReactCompilerConfig} for choosing between the babel and the
114
+ * experimental oxc transform.
115
+ */
116
+ reactCompiler?: boolean | ReactCompilerConfig;
117
+ /** Wraps the Studio in \<React.StrictMode\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE="true"|"false". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */
118
+ reactStrictMode?: boolean;
119
+ /**
120
+ * Configuration for schema extraction (`sanity schema extract`)
121
+ */
122
+ schemaExtraction?: {
123
+ /**
124
+ * Enable schema extraction as part of sanity dev and sanity build
125
+ */
126
+ enabled?: boolean;
127
+ /**
128
+ * When true, schema fields marked as required will be non-optional in the output.
129
+ * Defaults to `false`
130
+ */
131
+ enforceRequiredFields?: boolean;
132
+ /**
133
+ * Output path for the extracted schema file.
134
+ * Defaults to `schema.json` in the working directory.
135
+ */
136
+ path?: string;
137
+ /**
138
+ * Additional glob patterns to watch for schema changes in watch mode.
139
+ * These extend the default patterns:
140
+ * - `sanity.config.{js,jsx,ts,tsx,mjs}`
141
+ * - `schema*\/**\/*.{js,jsx,ts,tsx,mjs}`
142
+ */
143
+ watchPatterns?: string[];
144
+ /**
145
+ * The name of the workspace to generate a schema for. Required if your Sanity project has more than one
146
+ * workspace.
147
+ */
148
+ workspace?: string;
149
+ };
150
+ /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */
151
+ server?: {
152
+ hostname?: string;
153
+ port?: number;
154
+ };
155
+ /** @deprecated Use deployment.appId */
156
+ studioHost?: string;
157
+ /**
158
+ * Configuration for Sanity typegen
159
+ */
160
+ typegen?: Partial<TypeGenConfig> & {
161
+ /**
162
+ * Enable typegen as part of sanity dev and sanity build.
163
+ * When enabled, types are generated on startup and when files change.
164
+ * Defaults to `false`
165
+ */
166
+ enabled?: boolean;
167
+ };
168
+ /**
169
+ * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled
170
+ * files during development, which can speed up startup and reloads for large projects.
171
+ * Defaults to `false`.
172
+ *
173
+ * Unstable: may change or be removed without notice while the underlying Vite
174
+ * feature (`experimental.bundledDev`) is experimental.
175
+ * {@link https://vite.dev/guide/rolldown#full-bundle-mode}
176
+ */
177
+ unstable_bundledDev?: boolean;
178
+ /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */
179
+ vite?: UserViteConfig;
180
+ }
181
+ /**
182
+ * A raw key-value store for CLI user configuration.
183
+ * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on
184
+ * arbitrary keys without schema validation.
185
+ *
186
+ * @public
187
+ */
188
+ interface ConfigStore {
189
+ /** Remove a key from the config file. */
190
+ delete: (key: string) => void;
191
+ /** Read a value by key. Returns `undefined` if the key does not exist. */
192
+ get: (key: string) => unknown;
193
+ /** Write a value by key, merging it into the existing config. */
194
+ set: (key: string, value: unknown) => void;
195
+ }
196
+ export { ReactCompilerConfig as a, ConfigStore as i, AppVisibility as n, TypeGenConfig as o, CliConfig as r, UserViteConfig as s, APP_VISIBILITIES as t };
197
+ //# sourceMappingURL=cliConfig-DrUV6Wp6.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {APP_VISIBILITIES, type CliConfig, type TypeGenConfig} from './types/cliConfig.js'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n visibility: z.optional(z.enum(APP_VISIBILITIES)),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n unstable_bundledDev: z.optional(z.boolean()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","APP_VISIBILITIES","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","visibility","enum","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","enabled","enforceRequiredFields","path","watchPatterns","server","hostname","port","number","studioHost","unstable_bundledDev","vite","typegen"],"mappings":"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"}
1
+ {"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\nimport {\n APP_VISIBILITIES,\n type CliConfig,\n type ReactCompilerConfig,\n type TypeGenConfig,\n} from './types/cliConfig.js'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n visibility: z.optional(z.enum(APP_VISIBILITIES)),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<boolean | ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n unstable_bundledDev: z.optional(z.boolean()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","APP_VISIBILITIES","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","visibility","enum","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","enabled","enforceRequiredFields","path","watchPatterns","server","hostname","port","number","studioHost","unstable_bundledDev","vite","typegen"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAYA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
1
+ {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as BabelReactCompilerOptions} from 'babel-plugin-react-compiler'\nimport {type ReactCompilerOptions as OxcReactCompilerOptions} from 'oxc-transform-react'\n\nimport {type UserViteConfig} from './userViteConfig'\n\n/**\n * Configuration for React Compiler.\n *\n * The `transform` field selects which React Compiler transform to run; the\n * remaining options are passed to the selected transform:\n *\n * - `'babel'` (default) - the Babel plugin\n * ({@link https://www.npmjs.com/package/babel-plugin-react-compiler | babel-plugin-react-compiler}\n * must be installed in your project)\n * - `'oxc'` (experimental) - the native Rust port\n * ({@link https://www.npmjs.com/package/oxc-transform-react | oxc-transform-react}\n * must be installed in your project)\n *\n * @public\n */\nexport type ReactCompilerConfig =\n | (BabelReactCompilerOptions & {transform?: 'babel'})\n | (OxcReactCompilerOptions & {transform: 'oxc'})\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /**\n * Configuration options for React Compiler. Pass `true` to enable it with\n * the default (babel) transform, or an object to configure it — see\n * {@link ReactCompilerConfig} for choosing between the babel and the\n * experimental oxc transform.\n */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAgCA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
@@ -1,4 +1,5 @@
1
1
  import { CLIError } from '@oclif/core/errors';
2
+ import { exitCodes } from '../exitCodes.js';
2
3
  /**
3
4
  * Error thrown when a prompt is attempted in a non-interactive environment
4
5
  * (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error
@@ -9,7 +10,7 @@ import { CLIError } from '@oclif/core/errors';
9
10
  constructor(promptName){
10
11
  super(`Cannot run "${promptName}" prompt in a non-interactive environment. ` + 'Provide the required value via flags or environment variables, or run in an interactive terminal.', {
11
12
  code: 'NON_INTERACTIVE',
12
- exit: 1
13
+ exit: exitCodes.RUNTIME_ERROR
13
14
  });
14
15
  this.name = 'NonInteractiveError';
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/NonInteractiveError.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\n\n/**\n * Error thrown when a prompt is attempted in a non-interactive environment\n * (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error\n * to provide appropriate fallback behavior.\n *\n * Extends `CLIError` to suppress stack traces in user-facing output.\n */\nexport class NonInteractiveError extends CLIError {\n constructor(promptName: string) {\n super(\n `Cannot run \"${promptName}\" prompt in a non-interactive environment. ` +\n 'Provide the required value via flags or environment variables, or run in an interactive terminal.',\n {code: 'NON_INTERACTIVE', exit: 1},\n )\n this.name = 'NonInteractiveError'\n }\n}\n"],"names":["CLIError","NonInteractiveError","promptName","code","exit","name"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAE3C;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA4BD;IACvC,YAAYE,UAAkB,CAAE;QAC9B,KAAK,CACH,CAAC,YAAY,EAAEA,WAAW,2CAA2C,CAAC,GACpE,qGACF;YAACC,MAAM;YAAmBC,MAAM;QAAC;QAEnC,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
1
+ {"version":3,"sources":["../../src/errors/NonInteractiveError.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\n\nimport {exitCodes} from '../exitCodes.js'\n\n/**\n * Error thrown when a prompt is attempted in a non-interactive environment\n * (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error\n * to provide appropriate fallback behavior.\n *\n * Extends `CLIError` to suppress stack traces in user-facing output.\n */\nexport class NonInteractiveError extends CLIError {\n constructor(promptName: string) {\n super(\n `Cannot run \"${promptName}\" prompt in a non-interactive environment. ` +\n 'Provide the required value via flags or environment variables, or run in an interactive terminal.',\n {code: 'NON_INTERACTIVE', exit: exitCodes.RUNTIME_ERROR},\n )\n this.name = 'NonInteractiveError'\n }\n}\n"],"names":["CLIError","exitCodes","NonInteractiveError","promptName","code","exit","RUNTIME_ERROR","name"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAE3C,SAAQC,SAAS,QAAO,kBAAiB;AAEzC;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA4BF;IACvC,YAAYG,UAAkB,CAAE;QAC9B,KAAK,CACH,CAAC,YAAY,EAAEA,WAAW,2CAA2C,CAAC,GACpE,qGACF;YAACC,MAAM;YAAmBC,MAAMJ,UAAUK,aAAa;QAAA;QAEzD,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
@@ -1,4 +1,5 @@
1
1
  import { CLIError } from '@oclif/core/errors';
2
+ import { exitCodes } from '../exitCodes.js';
2
3
  import { isRecord } from '../util/isRecord.js';
3
4
  /**
4
5
  * Error thrown when a project root directory cannot be found.
@@ -13,7 +14,7 @@ import { isRecord } from '../util/isRecord.js';
13
14
  constructor(message, options){
14
15
  super(message, {
15
16
  code: 'PROJECT_ROOT_NOT_FOUND',
16
- exit: 1,
17
+ exit: exitCodes.RUNTIME_ERROR,
17
18
  suggestions: options?.suggestions
18
19
  });
19
20
  this.name = 'ProjectRootNotFoundError';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/ProjectRootNotFoundError.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\n\nimport {isRecord} from '../util/isRecord.js'\n\n/**\n * Error thrown when a project root directory cannot be found.\n *\n * This occurs when the CLI is run outside a Sanity project directory\n * (one containing `sanity.config.(ts|js)` or `sanity.cli.(ts|js)`).\n *\n * Extends `CLIError` to suppress stack traces in user-facing output.\n *\n * @internal\n */\nexport class ProjectRootNotFoundError extends CLIError {\n constructor(message: string, options?: {cause?: Error; suggestions?: string[]}) {\n super(message, {code: 'PROJECT_ROOT_NOT_FOUND', exit: 1, suggestions: options?.suggestions})\n this.name = 'ProjectRootNotFoundError'\n if (options?.cause) {\n this.cause = options.cause\n }\n }\n}\n\n/**\n * Returns whether or not the given error is a `ProjectRootNotFoundError`\n *\n * @param err - The error to check\n * @returns `true` if the error is a `ProjectRootNotFoundError`, `false` otherwise\n * @internal\n */\nexport function isProjectRootNotFoundError(err: unknown): err is ProjectRootNotFoundError {\n return (\n isRecord(err) &&\n 'name' in err &&\n err.name === 'ProjectRootNotFoundError' &&\n 'code' in err &&\n err.code === 'PROJECT_ROOT_NOT_FOUND' &&\n 'message' in err &&\n typeof err.message === 'string'\n )\n}\n"],"names":["CLIError","isRecord","ProjectRootNotFoundError","message","options","code","exit","suggestions","name","cause","isProjectRootNotFoundError","err"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAE3C,SAAQC,QAAQ,QAAO,sBAAqB;AAE5C;;;;;;;;;CASC,GACD,OAAO,MAAMC,iCAAiCF;IAC5C,YAAYG,OAAe,EAAEC,OAAiD,CAAE;QAC9E,KAAK,CAACD,SAAS;YAACE,MAAM;YAA0BC,MAAM;YAAGC,aAAaH,SAASG;QAAW;QAC1F,IAAI,CAACC,IAAI,GAAG;QACZ,IAAIJ,SAASK,OAAO;YAClB,IAAI,CAACA,KAAK,GAAGL,QAAQK,KAAK;QAC5B;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,2BAA2BC,GAAY;IACrD,OACEV,SAASU,QACT,UAAUA,OACVA,IAAIH,IAAI,KAAK,8BACb,UAAUG,OACVA,IAAIN,IAAI,KAAK,4BACb,aAAaM,OACb,OAAOA,IAAIR,OAAO,KAAK;AAE3B"}
1
+ {"version":3,"sources":["../../src/errors/ProjectRootNotFoundError.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\n\nimport {exitCodes} from '../exitCodes.js'\nimport {isRecord} from '../util/isRecord.js'\n\n/**\n * Error thrown when a project root directory cannot be found.\n *\n * This occurs when the CLI is run outside a Sanity project directory\n * (one containing `sanity.config.(ts|js)` or `sanity.cli.(ts|js)`).\n *\n * Extends `CLIError` to suppress stack traces in user-facing output.\n *\n * @internal\n */\nexport class ProjectRootNotFoundError extends CLIError {\n constructor(message: string, options?: {cause?: Error; suggestions?: string[]}) {\n super(message, {\n code: 'PROJECT_ROOT_NOT_FOUND',\n exit: exitCodes.RUNTIME_ERROR,\n suggestions: options?.suggestions,\n })\n this.name = 'ProjectRootNotFoundError'\n if (options?.cause) {\n this.cause = options.cause\n }\n }\n}\n\n/**\n * Returns whether or not the given error is a `ProjectRootNotFoundError`\n *\n * @param err - The error to check\n * @returns `true` if the error is a `ProjectRootNotFoundError`, `false` otherwise\n * @internal\n */\nexport function isProjectRootNotFoundError(err: unknown): err is ProjectRootNotFoundError {\n return (\n isRecord(err) &&\n 'name' in err &&\n err.name === 'ProjectRootNotFoundError' &&\n 'code' in err &&\n err.code === 'PROJECT_ROOT_NOT_FOUND' &&\n 'message' in err &&\n typeof err.message === 'string'\n )\n}\n"],"names":["CLIError","exitCodes","isRecord","ProjectRootNotFoundError","message","options","code","exit","RUNTIME_ERROR","suggestions","name","cause","isProjectRootNotFoundError","err"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAE3C,SAAQC,SAAS,QAAO,kBAAiB;AACzC,SAAQC,QAAQ,QAAO,sBAAqB;AAE5C;;;;;;;;;CASC,GACD,OAAO,MAAMC,iCAAiCH;IAC5C,YAAYI,OAAe,EAAEC,OAAiD,CAAE;QAC9E,KAAK,CAACD,SAAS;YACbE,MAAM;YACNC,MAAMN,UAAUO,aAAa;YAC7BC,aAAaJ,SAASI;QACxB;QACA,IAAI,CAACC,IAAI,GAAG;QACZ,IAAIL,SAASM,OAAO;YAClB,IAAI,CAACA,KAAK,GAAGN,QAAQM,KAAK;QAC5B;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,2BAA2BC,GAAY;IACrD,OACEX,SAASW,QACT,UAAUA,OACVA,IAAIH,IAAI,KAAK,8BACb,UAAUG,OACVA,IAAIP,IAAI,KAAK,4BACb,aAAaO,OACb,OAAOA,IAAIT,OAAO,KAAK;AAE3B"}
@@ -0,0 +1,48 @@
1
+ import { styleText } from 'node:util';
2
+ import { isHttpError } from '@sanity/client';
3
+ import { generateHelpUrl } from '../util/generateHelpUrl.js';
4
+ import { getSanityUrl } from '../util/getSanityUrl.js';
5
+ const enrichedErrors = new WeakSet();
6
+ /**
7
+ * Append login/membership guidance to 401 API errors.
8
+ *
9
+ * Replaces the `onError` requester middleware used with client v7. The client
10
+ * request handler applies the hint after errors have been normalized. Mutates
11
+ * the error message (matching the old middleware behavior) and is idempotent.
12
+ *
13
+ * @param err - The error to enrich
14
+ * @returns The same error, with an enriched message when it is a 401
15
+ * @internal
16
+ */ export function enrichAuthError(err) {
17
+ if (typeof err !== 'object' || err === null || enrichedErrors.has(err)) return err;
18
+ if (!isHttpError(err) || err.statusCode !== 401) return err;
19
+ enrichedErrors.add(err);
20
+ const projectId = projectIdFromUrl(err.response.url);
21
+ if (projectId && isProjectUserNotFoundError(err.response.body)) {
22
+ err.message = `${err.message}. Add this account as a project member: ${getSanityUrl(`/manage/project/${encodeURIComponent(projectId)}/members`)}.`;
23
+ return err;
24
+ }
25
+ err.message = `${err.message}. You may need to login again with ${styleText('cyan', 'sanity login')}.\nFor more information, see ${generateHelpUrl('cli-errors')}.`;
26
+ return err;
27
+ }
28
+ /**
29
+ * Derive the project ID from a project-hostname API URL
30
+ * (`<projectId>.api.sanity.io` or `.work`). Global-host requests return
31
+ * `undefined`, mirroring the old middleware which only knew the project ID
32
+ * for project-scoped clients.
33
+ */ function projectIdFromUrl(url) {
34
+ if (typeof url !== 'string') return undefined;
35
+ try {
36
+ const host = new URL(url).hostname;
37
+ return /^([a-z0-9-]+)\.api\.sanity\.(?:io|work)$/.exec(host)?.[1];
38
+ } catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ function isProjectUserNotFoundError(body) {
43
+ if (typeof body !== 'object' || body === null || !('error' in body)) return false;
44
+ const { error } = body;
45
+ return typeof error === 'object' && error !== null && 'type' in error && error.type === 'projectUserNotFoundError';
46
+ }
47
+
48
+ //# sourceMappingURL=enrichAuthError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/errors/enrichAuthError.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {isHttpError} from '@sanity/client'\n\nimport {generateHelpUrl} from '../util/generateHelpUrl.js'\nimport {getSanityUrl} from '../util/getSanityUrl.js'\n\nconst enrichedErrors = new WeakSet<object>()\n\n/**\n * Append login/membership guidance to 401 API errors.\n *\n * Replaces the `onError` requester middleware used with client v7. The client\n * request handler applies the hint after errors have been normalized. Mutates\n * the error message (matching the old middleware behavior) and is idempotent.\n *\n * @param err - The error to enrich\n * @returns The same error, with an enriched message when it is a 401\n * @internal\n */\nexport function enrichAuthError<T>(err: T): T {\n if (typeof err !== 'object' || err === null || enrichedErrors.has(err)) return err\n if (!isHttpError(err) || err.statusCode !== 401) return err\n enrichedErrors.add(err)\n\n const projectId = projectIdFromUrl(err.response.url)\n if (projectId && isProjectUserNotFoundError(err.response.body)) {\n err.message = `${err.message}. Add this account as a project member: ${getSanityUrl(`/manage/project/${encodeURIComponent(projectId)}/members`)}.`\n return err\n }\n\n err.message = `${err.message}. You may need to login again with ${styleText('cyan', 'sanity login')}.\\nFor more information, see ${generateHelpUrl('cli-errors')}.`\n return err\n}\n\n/**\n * Derive the project ID from a project-hostname API URL\n * (`<projectId>.api.sanity.io` or `.work`). Global-host requests return\n * `undefined`, mirroring the old middleware which only knew the project ID\n * for project-scoped clients.\n */\nfunction projectIdFromUrl(url: unknown): string | undefined {\n if (typeof url !== 'string') return undefined\n try {\n const host = new URL(url).hostname\n return /^([a-z0-9-]+)\\.api\\.sanity\\.(?:io|work)$/.exec(host)?.[1]\n } catch {\n return undefined\n }\n}\n\nfunction isProjectUserNotFoundError(\n body: unknown,\n): body is {error: {type: 'projectUserNotFoundError'}} {\n if (typeof body !== 'object' || body === null || !('error' in body)) return false\n\n const {error} = body\n return (\n typeof error === 'object' &&\n error !== null &&\n 'type' in error &&\n error.type === 'projectUserNotFoundError'\n )\n}\n"],"names":["styleText","isHttpError","generateHelpUrl","getSanityUrl","enrichedErrors","WeakSet","enrichAuthError","err","has","statusCode","add","projectId","projectIdFromUrl","response","url","isProjectUserNotFoundError","body","message","encodeURIComponent","undefined","host","URL","hostname","exec","error","type"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,WAAW,QAAO,iBAAgB;AAE1C,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AAEpD,MAAMC,iBAAiB,IAAIC;AAE3B;;;;;;;;;;CAUC,GACD,OAAO,SAASC,gBAAmBC,GAAM;IACvC,IAAI,OAAOA,QAAQ,YAAYA,QAAQ,QAAQH,eAAeI,GAAG,CAACD,MAAM,OAAOA;IAC/E,IAAI,CAACN,YAAYM,QAAQA,IAAIE,UAAU,KAAK,KAAK,OAAOF;IACxDH,eAAeM,GAAG,CAACH;IAEnB,MAAMI,YAAYC,iBAAiBL,IAAIM,QAAQ,CAACC,GAAG;IACnD,IAAIH,aAAaI,2BAA2BR,IAAIM,QAAQ,CAACG,IAAI,GAAG;QAC9DT,IAAIU,OAAO,GAAG,GAAGV,IAAIU,OAAO,CAAC,wCAAwC,EAAEd,aAAa,CAAC,gBAAgB,EAAEe,mBAAmBP,WAAW,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClJ,OAAOJ;IACT;IAEAA,IAAIU,OAAO,GAAG,GAAGV,IAAIU,OAAO,CAAC,mCAAmC,EAAEjB,UAAU,QAAQ,gBAAgB,6BAA6B,EAAEE,gBAAgB,cAAc,CAAC,CAAC;IACnK,OAAOK;AACT;AAEA;;;;;CAKC,GACD,SAASK,iBAAiBE,GAAY;IACpC,IAAI,OAAOA,QAAQ,UAAU,OAAOK;IACpC,IAAI;QACF,MAAMC,OAAO,IAAIC,IAAIP,KAAKQ,QAAQ;QAClC,OAAO,2CAA2CC,IAAI,CAACH,OAAO,CAAC,EAAE;IACnE,EAAE,OAAM;QACN,OAAOD;IACT;AACF;AAEA,SAASJ,2BACPC,IAAa;IAEb,IAAI,OAAOA,SAAS,YAAYA,SAAS,QAAQ,CAAE,CAAA,WAAWA,IAAG,GAAI,OAAO;IAE5E,MAAM,EAACQ,KAAK,EAAC,GAAGR;IAChB,OACE,OAAOQ,UAAU,YACjBA,UAAU,QACV,UAAUA,SACVA,MAAMC,IAAI,KAAK;AAEnB"}
@@ -1,4 +1,5 @@
1
1
  import { isHttpError } from '@sanity/client';
2
+ import { enrichAuthError } from './enrichAuthError.js';
2
3
  /**
3
4
  * Coerce an unknown thrown value into an Error instance.
4
5
  *
@@ -16,8 +17,9 @@ import { isHttpError } from '@sanity/client';
16
17
  * @internal
17
18
  */ export function getErrorMessage(err) {
18
19
  if (isHttpError(err)) {
20
+ enrichAuthError(err);
19
21
  const body = err.response.body;
20
- if (typeof body === 'object' && body !== null && 'message' in body && typeof body.message === 'string') {
22
+ if (typeof body === 'object' && body !== null && 'message' in body && typeof body.message === 'string' && err.statusCode !== 401) {
21
23
  return body.message;
22
24
  }
23
25
  return err.message || 'HTTP error';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\n/**\n * Coerce an unknown thrown value into an Error instance.\n *\n * @param value - The thrown value\n * @returns An Error instance (the original if already an Error, otherwise a new one)\n * @internal\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string'\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","toError","value","Error","String","getErrorMessage","err","body","response","message"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C;;;;;;CAMC,GACD,OAAO,SAASC,QAAQC,KAAc;IACpC,OAAOA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF;AAC3D;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBC,GAAY;IAC1C,IAAIN,YAAYM,MAAM;QACpB,MAAMC,OAAOD,IAAIE,QAAQ,CAACD,IAAI;QAC9B,IACE,OAAOA,SAAS,YAChBA,SAAS,QACT,aAAaA,QACb,OAAOA,KAAKE,OAAO,KAAK,UACxB;YACA,OAAOF,KAAKE,OAAO;QACrB;QACA,OAAOH,IAAIG,OAAO,IAAI;IACxB;IACA,OAAOH,eAAeH,QAAQG,IAAIG,OAAO,GAAG;AAC9C"}
1
+ {"version":3,"sources":["../../src/errors/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\nimport {enrichAuthError} from './enrichAuthError.js'\n\n/**\n * Coerce an unknown thrown value into an Error instance.\n *\n * @param value - The thrown value\n * @returns An Error instance (the original if already an Error, otherwise a new one)\n * @internal\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n enrichAuthError(err)\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string' &&\n err.statusCode !== 401\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","enrichAuthError","toError","value","Error","String","getErrorMessage","err","body","response","message","statusCode"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C,SAAQC,eAAe,QAAO,uBAAsB;AAEpD;;;;;;CAMC,GACD,OAAO,SAASC,QAAQC,KAAc;IACpC,OAAOA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF;AAC3D;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBC,GAAY;IAC1C,IAAIP,YAAYO,MAAM;QACpBN,gBAAgBM;QAChB,MAAMC,OAAOD,IAAIE,QAAQ,CAACD,IAAI;QAC9B,IACE,OAAOA,SAAS,YAChBA,SAAS,QACT,aAAaA,QACb,OAAOA,KAAKE,OAAO,KAAK,YACxBH,IAAII,UAAU,KAAK,KACnB;YACA,OAAOH,KAAKE,OAAO;QACrB;QACA,OAAOH,IAAIG,OAAO,IAAI;IACxB;IACA,OAAOH,eAAeH,QAAQG,IAAIG,OAAO,GAAG;AAC9C"}
@@ -1,3 +1,10 @@
1
+ import { FetchFunction } from "get-it";
2
+ /**
3
+ * Sanity deployment environment used by a programmatic CLI invocation.
4
+ *
5
+ * @public
6
+ */
7
+ type SanityEnvironment = 'production' | 'staging';
1
8
  /**
2
9
  * Explicit, per-invocation execution context for running CLI commands
3
10
  * programmatically (e.g. from an MCP server or another embedding host).
@@ -23,7 +30,14 @@
23
30
  *
24
31
  * @public
25
32
  */
26
- export declare interface CliExecutionContext {
33
+ interface CliExecutionContext {
34
+ /**
35
+ * Fetch implementation for API requests made during this invocation.
36
+ * Overrides the CLI's default transport (get-it's undici-backed Node
37
+ * fetch). The execution context's transport hygiene — such as stripping
38
+ * the embedding process's lineage header — is applied on top of it.
39
+ */
40
+ fetch?: FetchFunction;
27
41
  /**
28
42
  * Sanity deployment environment to use for this invocation.
29
43
  * Overrides `SANITY_INTERNAL_ENV`.
@@ -45,16 +59,6 @@ export declare interface CliExecutionContext {
45
59
  */
46
60
  token?: string;
47
61
  }
48
-
49
- /**
50
- * Get the active execution context, if any. Returns `undefined` when running
51
- * as the regular CLI (process-global behavior applies).
52
- *
53
- * @public
54
- */
55
- export declare function getCliExecutionContext():
56
- CliExecutionContext | undefined;
57
-
58
62
  /**
59
63
  * Run `fn` with the given execution context active. The context is visible
60
64
  * (via {@link getCliExecutionContext}) to all code in the async call graph of
@@ -63,16 +67,13 @@ export declare function getCliExecutionContext():
63
67
  *
64
68
  * @public
65
69
  */
66
- export declare function runWithCliExecutionContext<T>(
67
- context: CliExecutionContext,
68
- fn: () => T,
69
- ): T;
70
-
70
+ declare function runWithCliExecutionContext<T>(context: CliExecutionContext, fn: () => T): T;
71
71
  /**
72
- * Sanity deployment environment used by a programmatic CLI invocation.
72
+ * Get the active execution context, if any. Returns `undefined` when running
73
+ * as the regular CLI (process-global behavior applies).
73
74
  *
74
75
  * @public
75
76
  */
76
- export declare type SanityEnvironment = "production" | "staging";
77
-
78
- export {};
77
+ declare function getCliExecutionContext(): CliExecutionContext | undefined;
78
+ export { CliExecutionContext, SanityEnvironment, getCliExecutionContext, runWithCliExecutionContext };
79
+ //# sourceMappingURL=executionContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/executionContext.ts"],"sourcesContent":["import {AsyncLocalStorage} from 'node:async_hooks'\n\n/**\n * Sanity deployment environment used by a programmatic CLI invocation.\n *\n * @public\n */\nexport type SanityEnvironment = 'production' | 'staging'\n\n/**\n * Explicit, per-invocation execution context for running CLI commands\n * programmatically (e.g. from an MCP server or another embedding host).\n *\n * When a context is active, it overrides the process-global defaults the CLI\n * normally relies on:\n *\n * - `token` takes precedence over `SANITY_AUTH_TOKEN` and the stored CLI\n * config token, and never touches the process-wide token cache\n * - the embedding process's `X_SANITY_LINEAGE` is never propagated to API\n * requests\n * - `stdout`/`stderr` receive the output that commands would otherwise write\n * to the process streams\n * - debug logging is disabled, even when the embedding process enables it\n * - interactivity checks report non-interactive, so commands fail fast with\n * actionable errors instead of prompting\n * - project root resolution from the filesystem is disabled: commands never\n * read (or execute) `sanity.config.ts`/`sanity.cli.ts` files found near the\n * host process's cwd, so project context must come from explicit flags\n * (e.g. `--project-id`)\n *\n * The CLI binary never enters a context, so its behavior is unchanged.\n *\n * @public\n */\nexport interface CliExecutionContext {\n /**\n * Sanity deployment environment to use for this invocation.\n * Overrides `SANITY_INTERNAL_ENV`.\n */\n sanityEnv?: SanityEnvironment\n\n /**\n * Sink for output the command would otherwise write to `process.stderr`.\n * Called once per line, without a trailing newline.\n */\n stderr?: (line: string) => void\n\n /**\n * Sink for output the command would otherwise write to `process.stdout`.\n * Called once per line, without a trailing newline.\n */\n stdout?: (line: string) => void\n\n /**\n * Auth token to use for API clients created during this invocation.\n * Overrides `SANITY_AUTH_TOKEN` and the stored CLI config token.\n */\n token?: string\n}\n\n// Anchored on globalThis (same pattern as CLI_TELEMETRY_SYMBOL) so that the\n// context survives dual module instances: an embedding host may import this\n// module from source (e.g. via vitest or a bundler) while oclif loads command\n// classes from dist, and both must observe the same AsyncLocalStorage.\nconst STORAGE_SYMBOL = Symbol.for('sanity.cli.executionContext')\n\nconst globalStorage = globalThis as {\n [STORAGE_SYMBOL]?: AsyncLocalStorage<CliExecutionContext>\n}\n\nconst storage = (globalStorage[STORAGE_SYMBOL] ??= new AsyncLocalStorage<CliExecutionContext>())\n\n/**\n * Run `fn` with the given execution context active. The context is visible\n * (via {@link getCliExecutionContext}) to all code in the async call graph of\n * `fn`, and invisible to everything else — concurrent invocations with\n * different contexts are fully isolated.\n *\n * @public\n */\nexport function runWithCliExecutionContext<T>(context: CliExecutionContext, fn: () => T): T {\n return storage.run(context, fn)\n}\n\n/**\n * Get the active execution context, if any. Returns `undefined` when running\n * as the regular CLI (process-global behavior applies).\n *\n * @public\n */\nexport function getCliExecutionContext(): CliExecutionContext | undefined {\n return storage.getStore()\n}\n"],"names":["AsyncLocalStorage","STORAGE_SYMBOL","Symbol","for","globalStorage","globalThis","storage","runWithCliExecutionContext","context","fn","run","getCliExecutionContext","getStore"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,mBAAkB;AA4DlD,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,uEAAuE;AACvE,MAAMC,iBAAiBC,OAAOC,GAAG,CAAC;AAElC,MAAMC,gBAAgBC;AAItB,MAAMC,UAAWF,aAAa,CAACH,eAAe,KAAK,IAAID;AAEvD;;;;;;;CAOC,GACD,OAAO,SAASO,2BAA8BC,OAA4B,EAAEC,EAAW;IACrF,OAAOH,QAAQI,GAAG,CAACF,SAASC;AAC9B;AAEA;;;;;CAKC,GACD,OAAO,SAASE;IACd,OAAOL,QAAQM,QAAQ;AACzB"}
1
+ {"version":3,"sources":["../src/executionContext.ts"],"sourcesContent":["import {AsyncLocalStorage} from 'node:async_hooks'\n\nimport {type FetchFunction} from 'get-it'\n\n/**\n * Sanity deployment environment used by a programmatic CLI invocation.\n *\n * @public\n */\nexport type SanityEnvironment = 'production' | 'staging'\n\n/**\n * Explicit, per-invocation execution context for running CLI commands\n * programmatically (e.g. from an MCP server or another embedding host).\n *\n * When a context is active, it overrides the process-global defaults the CLI\n * normally relies on:\n *\n * - `token` takes precedence over `SANITY_AUTH_TOKEN` and the stored CLI\n * config token, and never touches the process-wide token cache\n * - the embedding process's `X_SANITY_LINEAGE` is never propagated to API\n * requests\n * - `stdout`/`stderr` receive the output that commands would otherwise write\n * to the process streams\n * - debug logging is disabled, even when the embedding process enables it\n * - interactivity checks report non-interactive, so commands fail fast with\n * actionable errors instead of prompting\n * - project root resolution from the filesystem is disabled: commands never\n * read (or execute) `sanity.config.ts`/`sanity.cli.ts` files found near the\n * host process's cwd, so project context must come from explicit flags\n * (e.g. `--project-id`)\n *\n * The CLI binary never enters a context, so its behavior is unchanged.\n *\n * @public\n */\nexport interface CliExecutionContext {\n /**\n * Fetch implementation for API requests made during this invocation.\n * Overrides the CLI's default transport (get-it's undici-backed Node\n * fetch). The execution context's transport hygiene — such as stripping\n * the embedding process's lineage header — is applied on top of it.\n */\n fetch?: FetchFunction\n\n /**\n * Sanity deployment environment to use for this invocation.\n * Overrides `SANITY_INTERNAL_ENV`.\n */\n sanityEnv?: SanityEnvironment\n\n /**\n * Sink for output the command would otherwise write to `process.stderr`.\n * Called once per line, without a trailing newline.\n */\n stderr?: (line: string) => void\n\n /**\n * Sink for output the command would otherwise write to `process.stdout`.\n * Called once per line, without a trailing newline.\n */\n stdout?: (line: string) => void\n\n /**\n * Auth token to use for API clients created during this invocation.\n * Overrides `SANITY_AUTH_TOKEN` and the stored CLI config token.\n */\n token?: string\n}\n\n// Anchored on globalThis (same pattern as CLI_TELEMETRY_SYMBOL) so that the\n// context survives dual module instances: an embedding host may import this\n// module from source (e.g. via vitest or a bundler) while oclif loads command\n// classes from dist, and both must observe the same AsyncLocalStorage.\nconst STORAGE_SYMBOL = Symbol.for('sanity.cli.executionContext')\n\nconst globalStorage = globalThis as {\n [STORAGE_SYMBOL]?: AsyncLocalStorage<CliExecutionContext>\n}\n\nconst storage = (globalStorage[STORAGE_SYMBOL] ??= new AsyncLocalStorage<CliExecutionContext>())\n\n/**\n * Run `fn` with the given execution context active. The context is visible\n * (via {@link getCliExecutionContext}) to all code in the async call graph of\n * `fn`, and invisible to everything else — concurrent invocations with\n * different contexts are fully isolated.\n *\n * @public\n */\nexport function runWithCliExecutionContext<T>(context: CliExecutionContext, fn: () => T): T {\n return storage.run(context, fn)\n}\n\n/**\n * Get the active execution context, if any. Returns `undefined` when running\n * as the regular CLI (process-global behavior applies).\n *\n * @public\n */\nexport function getCliExecutionContext(): CliExecutionContext | undefined {\n return storage.getStore()\n}\n"],"names":["AsyncLocalStorage","STORAGE_SYMBOL","Symbol","for","globalStorage","globalThis","storage","runWithCliExecutionContext","context","fn","run","getCliExecutionContext","getStore"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,mBAAkB;AAsElD,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,uEAAuE;AACvE,MAAMC,iBAAiBC,OAAOC,GAAG,CAAC;AAElC,MAAMC,gBAAgBC;AAItB,MAAMC,UAAWF,aAAa,CAACH,eAAe,KAAK,IAAID;AAEvD;;;;;;;CAOC,GACD,OAAO,SAASO,2BAA8BC,OAA4B,EAAEC,EAAW;IACrF,OAAOH,QAAQI,GAAG,CAACF,SAASC;AAC9B;AAEA;;;;;CAKC,GACD,OAAO,SAASE;IACd,OAAOL,QAAQM,QAAQ;AACzB"}
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @see CLAUDE.md "Exit Code Convention" for usage guidance and examples.
9
9
  */
10
- export declare const exitCodes: {
10
+ declare const exitCodes: {
11
11
  /** Something went wrong that is not the user's fault (API errors, network, missing config, etc.). */
12
12
  readonly RUNTIME_ERROR: 1;
13
13
  /** The user interrupted via Ctrl+C (128 + SIGINT). Handled by SanityCommand.catch(). */
@@ -19,5 +19,5 @@ export declare const exitCodes: {
19
19
  /** The user declined a confirmation or chose not to proceed. */
20
20
  readonly USER_ABORT: 3;
21
21
  };
22
-
23
- export {};
22
+ export { exitCodes };
23
+ //# sourceMappingURL=exitCodes.d.ts.map