@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
@@ -1,120 +1,2 @@
1
- import { URL as URL_2 } from "node:url";
2
- import { Worker } from "node:worker_threads";
3
- import { WorkerOptions } from "node:worker_threads";
4
-
5
- /**
6
- * Creates a new worker for a studio worker task.
7
- *
8
- * This uses a combination of vite for "bundling" + jsdom for emulating a browser
9
- * environment under the hood, which means that the same thing that will work in vite
10
- * _should_ work in the worker - to a degree. If the user has defined any typescript
11
- * path aliases, these will have to be added as aliases to the vite config - the same
12
- * behavior as you would see with regular vite. Other things that are accounted for:
13
- *
14
- * - TypeScript support (+JSX, enums and other "compilation needed" features)
15
- * - CSS, font and other file imports will resolve to a file path
16
- * - CSS module imports will resolve to a javascript object of class names
17
- * - Environment variables are available both as `import.meta.env` and `process.env`,
18
- * and `.env` files are loaded in the same way that they would in a Sanity studio.
19
- * - Browser globals not available in a Node.js environment but _are_ provided by JSDOM
20
- * are defined directly to the Node environment as globals. While this polutes the
21
- * global namespace, it is done only in the worker thread.
22
- * - Certain browser globals that are _not_ available in JSDOM are also provided to the
23
- * global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.
24
- * These are provided with a minimal stub implementation to make them not crash.
25
- *
26
- * @param filePath - Path to the worker file (`.ts` works and is encouraged)
27
- * @param options - Options to pass to the worker
28
- * @returns A promise that resolves with the message from the worker
29
- * @throws If the file does not exist
30
- * @throws If the worker exits with a non-zero code
31
- * @internal
32
- */
33
- export declare function createStudioWorker(
34
- filePath: URL,
35
- options: StudioWorkerTaskOptions,
36
- ): Worker;
37
-
38
- declare type RequireProps<T, K extends keyof T> = Omit<T, K> &
39
- Required<Pick<T, K>>;
40
-
41
- /**
42
- * Executes a worker file in a Sanity Studio browser context.
43
- *
44
- * This uses a combination of vite for "bundling" + jsdom for emulating a browser
45
- * environment under the hood, which means that the same thing that will work in vite
46
- * _should_ work in the worker - to a degree. If the user has defined any typescript
47
- * path aliases, these will have to be added as aliases to the vite config - the same
48
- * behavior as you would see with regular vite. Other things that are accounted for:
49
- *
50
- * - TypeScript support (+JSX, enums and other "compilation needed" features)
51
- * - CSS, font and other file imports will resolve to a file path
52
- * - CSS module imports will resolve to a javascript object of class names
53
- * - Environment variables are available both as `import.meta.env` and `process.env`,
54
- * and `.env` files are loaded in the same way that they would in a Sanity studio.
55
- * - Browser globals not available in a Node.js environment but _are_ provided by JSDOM
56
- * are defined directly to the Node environment as globals. While this polutes the
57
- * global namespace, it is done only in the worker thread.
58
- * - Certain browser globals that are _not_ available in JSDOM are also provided to the
59
- * global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.
60
- * These are provided with a minimal stub implementation to make them not crash.
61
- *
62
- * @param filePath - Path to the worker file (`.ts` works and is encouraged)
63
- * @param options - Options to pass to the worker
64
- * @returns A promise that resolves with the message from the worker
65
- * @throws If the file does not exist
66
- * @throws If the worker exits with a non-zero code
67
- * @internal
68
- */
69
- export declare function studioWorkerTask<T = unknown>(
70
- filePath: URL,
71
- options: StudioWorkerTaskOptions,
72
- ): Promise<T>;
73
-
74
- /**
75
- * Options for the studio worker task
76
- *
77
- * @internal
78
- */
79
- declare interface StudioWorkerTaskOptions extends RequireProps<
80
- WorkerOptions,
81
- "name"
82
- > {
83
- studioRootPath: string;
84
- /** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */
85
- timeout?: number;
86
- }
87
-
88
- /**
89
- * Executes a worker file with tsx registered. This means you can import other
90
- * typescript with fairly rich syntax, and still have that only apply to the worker
91
- * thread instead of the full parent process. The worker should emit a message when
92
- * complete using `parentPort`. Once it has received a single message will resolve the
93
- * returned promise with that message. If you are expecting multiple messages, you will
94
- * have to implement another method ;)
95
- *
96
- * @param filePath - Path to the worker file
97
- * @param options - Options to pass to the worker
98
- * @returns A promise that resolves with the message from the worker
99
- * @throws If the file does not exist
100
- * @throws If the worker exits with a non-zero code
101
- * @internal
102
- */
103
- export declare function tsxWorkerTask<T = unknown>(
104
- filePath: URL_2,
105
- options: TsxWorkerTaskOptions,
106
- ): Promise<T>;
107
-
108
- /**
109
- * Options for the tsx worker task
110
- *
111
- * @internal
112
- */
113
- declare interface TsxWorkerTaskOptions extends RequireProps<
114
- WorkerOptions,
115
- "name"
116
- > {
117
- rootPath: string;
118
- }
119
-
120
- export {};
1
+ import { n as createStudioWorker, r as studioWorkerTask, t as tsxWorkerTask } from "../tsxWorkerTask-CxG3fWbU.js";
2
+ export { createStudioWorker, studioWorkerTask, tsxWorkerTask };
@@ -1,156 +1,2 @@
1
- /**
2
- * Clears the global CLI telemetry store.
3
- * @internal
4
- */
5
- export declare function clearCliTelemetry(): void;
6
-
7
- /**
8
- * @public
9
- * Symbol used to store CLI telemetry state on globalThis.
10
- * Use the accessor functions instead of accessing this directly.
11
- */
12
- export declare const CLI_TELEMETRY_SYMBOL: unique symbol;
13
-
14
- /**
15
- * @public
16
- */
17
- declare type CLITelemetryStore = TelemetryLogger<TelemetryUserProperties>;
18
-
19
- declare interface DeferredEvent<
20
- Data = unknown,
21
- Event extends DefinedTelemetryLog<Data> = DefinedTelemetryLog<Data>,
22
- > {
23
- createdAt: string;
24
- event: Event;
25
- data: Data;
26
- }
27
-
28
- declare interface DefinedTelemetryLog<Schema> {
29
- type: "log";
30
- /** Unique name of the event */
31
- name: string;
32
- /** Event version. Increment this by 1 whenever the shape of the data changes in a non-backwards compatible way */
33
- version: number;
34
- /** Description of log event */
35
- description?: string;
36
- /**
37
- * Max sample rate of this event.
38
- * Calling telemetry.log(EventDefinition, data) repeatedly will submit at most one event every specified time interval (in milliseconds)
39
- * */
40
- maxSampleRate?: number;
41
- /** Data schema. Will not be accessible at runtime */
42
- schema: Schema;
43
- }
44
-
45
- declare interface DefinedTelemetryTrace<Data = void, Context = void> {
46
- type: "trace";
47
- /** Unique name of the trace */
48
- name: string;
49
- /** Trace version. Increment this by 1 whenever the shape of the data changes in a non-backwards compatible way */
50
- version: number;
51
- /** Description of trace */
52
- description?: string;
53
- /** Data schema. Will not be accessible at runtime */
54
- schema: Data;
55
- /** Contextual data schema. Will not be accessible at runtime */
56
- context: Context;
57
- }
58
-
59
- /**
60
- * @public
61
- */
62
- export declare function getCliTelemetry(): CLITelemetryStore;
63
-
64
- /**
65
- * Gets the base telemetry information needed for file operations.
66
- *
67
- * This shared utility extracts common logic used by:
68
- * - `generateTelemetryFilePath` - for generating session-specific file paths
69
- * - `findTelemetryFiles` - for discovering all telemetry files via glob patterns
70
- *
71
- * @returns Promise resolving to base telemetry information
72
- * @throws Error if no auth token is found
73
- * @internal
74
- */
75
- export declare function getTelemetryBaseInfo(): Promise<TelemetryBaseInfo>;
76
-
77
- /**
78
- * Fallback logger used when telemetry has not been initialized.
79
- * Exported for use in tests only — do not use in plugins or external code.
80
- * @internal
81
- */
82
- export declare const noopLogger: CLITelemetryStore;
83
-
84
- /**
85
- * Reports an error to the CLI command trace. Called from SanityCommand.catch()
86
- * for real command errors (not user aborts).
87
- * @internal
88
- */
89
- export declare function reportCliTraceError(error: Error): void;
90
-
91
- /**
92
- * Sets the global CLI telemetry state.
93
- * @internal
94
- */
95
- export declare function setCliTelemetry(
96
- telemetry: CLITelemetryStore,
97
- options?: {
98
- reportTraceError?: TraceErrorReporter;
99
- },
100
- ): void;
101
-
102
- /**
103
- * Base information needed for telemetry file operations.
104
- * Contains common data used by both file path generation and pattern matching.
105
- */
106
- declare interface TelemetryBaseInfo {
107
- /** Base filename pattern without sessionId suffix */
108
- basePattern: string;
109
- /** Base directory where telemetry files are stored */
110
- directory: string;
111
- /** Environment: 'staging' or 'production' */
112
- environment: string;
113
- /** Hashed token (first 8 chars of SHA256) for privacy */
114
- hashedToken: string;
115
- }
116
-
117
- /**
118
- * Note that `sessionId` is removed from the signature of these functions
119
- */
120
- declare interface TelemetryLogger<UserProperties> {
121
- updateUserProperties(properties: UserProperties): void;
122
- resume(events: DeferredEvent[]): void;
123
- log<Data>(event: DefinedTelemetryLog<Data>, data: Data): void;
124
- log<Data extends void>(event: DefinedTelemetryLog<Data>): void;
125
- trace<Data>(
126
- event: DefinedTelemetryTrace<Data>,
127
- context?: unknown,
128
- ): TelemetryTrace<UserProperties, Data>;
129
- }
130
-
131
- declare interface TelemetryTrace<UserProperties, Data> {
132
- start(): void;
133
- log(data: Data): void;
134
- error(error: Error): void;
135
- complete(): void;
136
- newContext(name: string): TelemetryLogger<UserProperties>;
137
- await<P extends Promise<Data>>(promise: P): P;
138
- await<P extends Promise<unknown>>(promise: P, finalData: Data): P;
139
- }
140
-
141
- /**
142
- * @public
143
- */
144
- declare interface TelemetryUserProperties {
145
- cliVersion: string;
146
- cpuArchitecture: string;
147
- machinePlatform: string;
148
- runtime: string;
149
- runtimeVersion: string;
150
- dataset?: string;
151
- projectId?: string;
152
- }
153
-
154
- declare type TraceErrorReporter = (error: Error) => void;
155
-
156
- export {};
1
+ import { a as getCliTelemetry, i as clearCliTelemetry, n as getTelemetryBaseInfo, o as reportCliTraceError, r as CLI_TELEMETRY_SYMBOL, s as setCliTelemetry, t as noopLogger } from "../noopTelemetry-BJRIvASI.js";
2
+ export { CLI_TELEMETRY_SYMBOL, clearCliTelemetry, getCliTelemetry, getTelemetryBaseInfo, noopLogger, reportCliTraceError, setCliTelemetry };