@sanity/cli-core 2.1.2 → 2.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.
- package/README.md +224 -1
- package/dist/SanityCommand.d.ts +454 -0
- package/dist/SanityCommand.js +5 -4
- package/dist/SanityCommand.js.map +1 -1
- package/dist/_exports/browser.d.ts +21 -0
- package/dist/_exports/browser.js +5 -0
- package/dist/_exports/browser.js.map +1 -0
- package/dist/_exports/config.d.ts +653 -0
- package/dist/_exports/config.js +18 -0
- package/dist/_exports/config.js.map +1 -0
- package/dist/_exports/debug.d.ts +20 -0
- package/dist/_exports/debug.js.map +1 -0
- package/dist/_exports/errors.d.ts +67 -0
- package/dist/_exports/errors.js +5 -0
- package/dist/_exports/errors.js.map +1 -0
- package/dist/_exports/index.d.ts +30 -33
- package/dist/_exports/index.js +42 -39
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/package-manager.d.ts +191 -0
- package/dist/_exports/package-manager.js +3 -0
- package/dist/_exports/package-manager.js.map +1 -1
- package/dist/_exports/schemas.d.ts +227 -0
- package/dist/_exports/schemas.js +4 -0
- package/dist/_exports/schemas.js.map +1 -0
- package/dist/_exports/tasks.d.ts +120 -0
- package/dist/_exports/tasks.js +4 -0
- package/dist/_exports/tasks.js.map +1 -0
- package/dist/_exports/telemetry.d.ts +156 -0
- package/dist/_exports/telemetry.js +7 -0
- package/dist/_exports/telemetry.js.map +1 -0
- package/dist/_exports/types.d.ts +444 -0
- package/dist/_exports/types.js +3 -0
- package/dist/_exports/types.js.map +1 -0
- package/dist/_exports/util.d.ts +132 -0
- package/dist/_exports/util.js +16 -0
- package/dist/_exports/util.js.map +1 -0
- package/dist/_exports/ux.d.ts +15 -0
- package/dist/_exports/ux.js +6 -4
- package/dist/_exports/ux.js.map +1 -1
- package/dist/apiClient.d.ts +79 -0
- package/dist/{services/apiClient.js → apiClient.js} +2 -2
- package/dist/{services/apiClient.js.map → apiClient.js.map} +1 -1
- package/dist/config/cli/cliTokenCache.js.map +1 -0
- package/dist/{services → config/cli}/cliUserConfig.js +31 -6
- package/dist/config/cli/cliUserConfig.js.map +1 -0
- package/dist/config/cli/getCliConfig.js +1 -1
- package/dist/config/cli/getCliConfig.js.map +1 -1
- package/dist/config/cli/schemas.js +1 -0
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/cli/workbenchApp.js +19 -38
- package/dist/config/cli/workbenchApp.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +1 -1
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
- package/dist/config/studio/readStudioConfig.worker.js +1 -1
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
- package/dist/exitCodes.d.ts +23 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js +2 -2
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
- package/dist/telemetry/getCliTelemetry.js +3 -2
- package/dist/telemetry/getCliTelemetry.js.map +1 -1
- package/dist/telemetry/getTelemetryBaseInfo.js +1 -1
- package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -1
- package/dist/util/environment/mockBrowserEnvironment.js +3 -2
- package/dist/util/environment/mockBrowserEnvironment.js.map +1 -1
- package/dist/util/environment/setupBrowserStubs.js +1 -1
- package/dist/util/environment/setupBrowserStubs.js.map +1 -1
- package/dist/util/getSanityConfigDir.js +1 -0
- package/dist/util/getSanityConfigDir.js.map +1 -1
- package/dist/util/getSanityEnvVar.js +1 -0
- package/dist/util/getSanityEnvVar.js.map +1 -1
- package/dist/util/getSanityUrl.js +1 -0
- package/dist/util/getSanityUrl.js.map +1 -1
- package/dist/util/getWorkspace.js +1 -0
- package/dist/util/getWorkspace.js.map +1 -1
- package/dist/util/importModule.js +1 -1
- package/dist/util/importModule.js.map +1 -1
- package/dist/util/promisifyWorker.js +1 -1
- package/dist/util/promisifyWorker.js.map +1 -1
- package/package.json +57 -9
- package/dist/debug.js.map +0 -1
- package/dist/services/cliTokenCache.js.map +0 -1
- package/dist/services/cliUserConfig.js.map +0 -1
- package/dist/services/getCliToken.js +0 -26
- package/dist/services/getCliToken.js.map +0 -1
- /package/dist/{debug.js → _exports/debug.js} +0 -0
- /package/dist/{services → config/cli}/cliTokenCache.js +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { ConfigEnv } from "vite";
|
|
2
|
+
import { EnvironmentConfig } from "babel-plugin-react-compiler";
|
|
3
|
+
import { ExternalFunction } from "babel-plugin-react-compiler";
|
|
4
|
+
import { InlineConfig } from "vite";
|
|
5
|
+
import { Logger } from "babel-plugin-react-compiler";
|
|
6
|
+
import { z } from "zod/mini";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare const cliConfigSchema: z.ZodMiniObject<
|
|
12
|
+
{
|
|
13
|
+
api: z.ZodMiniOptional<
|
|
14
|
+
z.ZodMiniObject<
|
|
15
|
+
{
|
|
16
|
+
dataset: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
projectId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
18
|
+
},
|
|
19
|
+
z.core.$strip
|
|
20
|
+
>
|
|
21
|
+
>;
|
|
22
|
+
app: z.ZodMiniOptional<
|
|
23
|
+
z.ZodMiniObject<
|
|
24
|
+
{
|
|
25
|
+
entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
26
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
27
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
28
|
+
organizationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
|
+
},
|
|
31
|
+
z.core.$strip
|
|
32
|
+
>
|
|
33
|
+
>;
|
|
34
|
+
autoUpdates: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
35
|
+
deployment: z.ZodMiniOptional<
|
|
36
|
+
z.ZodMiniObject<
|
|
37
|
+
{
|
|
38
|
+
appId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
39
|
+
autoUpdates: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
40
|
+
},
|
|
41
|
+
z.core.$strip
|
|
42
|
+
>
|
|
43
|
+
>;
|
|
44
|
+
graphql: z.ZodMiniOptional<
|
|
45
|
+
z.ZodMiniArray<
|
|
46
|
+
z.ZodMiniObject<
|
|
47
|
+
{
|
|
48
|
+
filterSuffix: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
49
|
+
generation: z.ZodMiniOptional<
|
|
50
|
+
z.ZodMiniEnum<{
|
|
51
|
+
gen1: "gen1";
|
|
52
|
+
gen2: "gen2";
|
|
53
|
+
gen3: "gen3";
|
|
54
|
+
}>
|
|
55
|
+
>;
|
|
56
|
+
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
57
|
+
nonNullDocumentFields: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
58
|
+
playground: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
59
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
60
|
+
tag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
61
|
+
workspace: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
62
|
+
},
|
|
63
|
+
z.core.$strip
|
|
64
|
+
>
|
|
65
|
+
>
|
|
66
|
+
>;
|
|
67
|
+
mediaLibrary: z.ZodMiniOptional<
|
|
68
|
+
z.ZodMiniObject<
|
|
69
|
+
{
|
|
70
|
+
aspectsPath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
71
|
+
},
|
|
72
|
+
z.core.$strip
|
|
73
|
+
>
|
|
74
|
+
>;
|
|
75
|
+
project: z.ZodMiniOptional<
|
|
76
|
+
z.ZodMiniObject<
|
|
77
|
+
{
|
|
78
|
+
basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
79
|
+
},
|
|
80
|
+
z.core.$strip
|
|
81
|
+
>
|
|
82
|
+
>;
|
|
83
|
+
reactCompiler: z.ZodMiniOptional<
|
|
84
|
+
z.ZodMiniCustom<
|
|
85
|
+
Partial<{
|
|
86
|
+
environment: Partial<EnvironmentConfig>;
|
|
87
|
+
logger: Logger | null;
|
|
88
|
+
gating: ExternalFunction | null;
|
|
89
|
+
dynamicGating: {
|
|
90
|
+
source: string;
|
|
91
|
+
} | null;
|
|
92
|
+
panicThreshold: "none" | "all_errors" | "critical_errors";
|
|
93
|
+
noEmit: boolean;
|
|
94
|
+
compilationMode: "syntax" | "infer" | "annotation" | "all";
|
|
95
|
+
eslintSuppressionRules: Array<string> | null | undefined;
|
|
96
|
+
flowSuppressions: boolean;
|
|
97
|
+
ignoreUseNoForget: boolean;
|
|
98
|
+
customOptOutDirectives: string[] | null;
|
|
99
|
+
sources: Array<string> | ((filename: string) => boolean) | null;
|
|
100
|
+
enableReanimatedCheck: boolean;
|
|
101
|
+
target:
|
|
102
|
+
| "17"
|
|
103
|
+
| "18"
|
|
104
|
+
| "19"
|
|
105
|
+
| {
|
|
106
|
+
kind: "donotuse_meta_internal";
|
|
107
|
+
runtimeModule: string;
|
|
108
|
+
};
|
|
109
|
+
}>,
|
|
110
|
+
Partial<{
|
|
111
|
+
environment: Partial<EnvironmentConfig>;
|
|
112
|
+
logger: Logger | null;
|
|
113
|
+
gating: ExternalFunction | null;
|
|
114
|
+
dynamicGating: {
|
|
115
|
+
source: string;
|
|
116
|
+
} | null;
|
|
117
|
+
panicThreshold: "none" | "all_errors" | "critical_errors";
|
|
118
|
+
noEmit: boolean;
|
|
119
|
+
compilationMode: "syntax" | "infer" | "annotation" | "all";
|
|
120
|
+
eslintSuppressionRules: Array<string> | null | undefined;
|
|
121
|
+
flowSuppressions: boolean;
|
|
122
|
+
ignoreUseNoForget: boolean;
|
|
123
|
+
customOptOutDirectives: string[] | null;
|
|
124
|
+
sources: Array<string> | ((filename: string) => boolean) | null;
|
|
125
|
+
enableReanimatedCheck: boolean;
|
|
126
|
+
target:
|
|
127
|
+
| "17"
|
|
128
|
+
| "18"
|
|
129
|
+
| "19"
|
|
130
|
+
| {
|
|
131
|
+
kind: "donotuse_meta_internal";
|
|
132
|
+
runtimeModule: string;
|
|
133
|
+
};
|
|
134
|
+
}>
|
|
135
|
+
>
|
|
136
|
+
>;
|
|
137
|
+
reactStrictMode: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
138
|
+
schemaExtraction: z.ZodMiniOptional<
|
|
139
|
+
z.ZodMiniObject<
|
|
140
|
+
{
|
|
141
|
+
enabled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
142
|
+
enforceRequiredFields: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
143
|
+
path: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
144
|
+
watchPatterns: z.ZodMiniOptional<
|
|
145
|
+
z.ZodMiniArray<z.ZodMiniString<string>>
|
|
146
|
+
>;
|
|
147
|
+
workspace: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
148
|
+
},
|
|
149
|
+
z.core.$strip
|
|
150
|
+
>
|
|
151
|
+
>;
|
|
152
|
+
server: z.ZodMiniOptional<
|
|
153
|
+
z.ZodMiniObject<
|
|
154
|
+
{
|
|
155
|
+
hostname: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
156
|
+
port: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
157
|
+
},
|
|
158
|
+
z.core.$strip
|
|
159
|
+
>
|
|
160
|
+
>;
|
|
161
|
+
studioHost: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
162
|
+
unstable_bundledDev: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
163
|
+
vite: z.ZodMiniOptional<z.ZodMiniCustom<UserViteConfig, UserViteConfig>>;
|
|
164
|
+
typegen: z.ZodMiniOptional<
|
|
165
|
+
z.ZodMiniCustom<
|
|
166
|
+
Partial<TypeGenConfig> & {
|
|
167
|
+
enabled?: boolean;
|
|
168
|
+
},
|
|
169
|
+
Partial<TypeGenConfig> & {
|
|
170
|
+
enabled?: boolean;
|
|
171
|
+
}
|
|
172
|
+
>
|
|
173
|
+
>;
|
|
174
|
+
},
|
|
175
|
+
z.core.$strip
|
|
176
|
+
>;
|
|
177
|
+
|
|
178
|
+
export declare type CoreAppManifest = z.infer<typeof coreAppManifestSchema>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Core-app application manifest. Mirrors the workbench's
|
|
182
|
+
* `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the
|
|
183
|
+
* CLI produces the payload in full.
|
|
184
|
+
*/
|
|
185
|
+
export declare const coreAppManifestSchema: z.ZodMiniObject<
|
|
186
|
+
{
|
|
187
|
+
group: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
188
|
+
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
189
|
+
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
190
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
191
|
+
version: z.ZodMiniString<string>;
|
|
192
|
+
},
|
|
193
|
+
z.core.$strip
|
|
194
|
+
>;
|
|
195
|
+
|
|
196
|
+
export declare type StudioManifest = z.infer<typeof studioManifestSchema>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Studio application manifest (serialized `create-manifest.json`). Kept loose so
|
|
200
|
+
* the CLI isn't coupled to the workbench's evolving client-side schema — the
|
|
201
|
+
* workbench consumer is authoritative on the inner shape. See its
|
|
202
|
+
* `ClientManifest` for the fields clients expect.
|
|
203
|
+
*/
|
|
204
|
+
export declare const studioManifestSchema: z.ZodMiniRecord<
|
|
205
|
+
z.ZodMiniString<string>,
|
|
206
|
+
z.ZodMiniUnknown
|
|
207
|
+
>;
|
|
208
|
+
|
|
209
|
+
declare interface TypeGenConfig {
|
|
210
|
+
formatGeneratedCode: boolean;
|
|
211
|
+
generates: string;
|
|
212
|
+
overloadClientMethods: boolean;
|
|
213
|
+
path: string | string[];
|
|
214
|
+
schema: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
declare type UserViteConfig =
|
|
221
|
+
| ((
|
|
222
|
+
config: InlineConfig,
|
|
223
|
+
env: ConfigEnv,
|
|
224
|
+
) => InlineConfig | Promise<InlineConfig>)
|
|
225
|
+
| InlineConfig;
|
|
226
|
+
|
|
227
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/schemas.ts"],"sourcesContent":["export {cliConfigSchema} from '../config/cli/schemas.js'\nexport {\n type CoreAppManifest,\n coreAppManifestSchema,\n type StudioManifest,\n studioManifestSchema,\n} from '../manifest.js'\n"],"names":["cliConfigSchema","coreAppManifestSchema","studioManifestSchema"],"mappings":"AAAA,SAAQA,eAAe,QAAO,2BAA0B;AACxD,SAEEC,qBAAqB,EAErBC,oBAAoB,QACf,iBAAgB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { URL as URL_2 } from "node:url";
|
|
2
|
+
import { Worker as Worker_2 } from "node:worker_threads";
|
|
3
|
+
import { WorkerOptions as WorkerOptions_2 } 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_2;
|
|
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_2,
|
|
81
|
+
"name"
|
|
82
|
+
> {
|
|
83
|
+
studioRootPath: string;
|
|
84
|
+
/** Optional timeout in milliseconds. If the worker does not respond within this time, it will be terminated and the promise 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_2,
|
|
115
|
+
"name"
|
|
116
|
+
> {
|
|
117
|
+
rootPath: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/tasks.ts"],"sourcesContent":["export {createStudioWorker, studioWorkerTask} from '../loaders/studio/studioWorkerTask.js'\nexport {tsxWorkerTask} from '../loaders/tsx/tsxWorkerTask.js'\n"],"names":["createStudioWorker","studioWorkerTask","tsxWorkerTask"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,gBAAgB,QAAO,wCAAuC;AAC1F,SAAQC,aAAa,QAAO,kCAAiC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Telemetry only. Should be as lean as possible.
|
|
2
|
+
// TODO: need to remove OCLIF dependency in the following file
|
|
3
|
+
export { clearCliTelemetry, CLI_TELEMETRY_SYMBOL, getCliTelemetry, reportCliTraceError, setCliTelemetry } from '../telemetry/getCliTelemetry.js';
|
|
4
|
+
export { getTelemetryBaseInfo } from '../telemetry/getTelemetryBaseInfo.js';
|
|
5
|
+
export { noopLogger } from '../telemetry/noopTelemetry.js';
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/telemetry.ts"],"sourcesContent":["// Telemetry only. Should be as lean as possible.\n// TODO: need to remove OCLIF dependency in the following file\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n reportCliTraceError,\n setCliTelemetry,\n} from '../telemetry/getCliTelemetry.js'\nexport {getTelemetryBaseInfo} from '../telemetry/getTelemetryBaseInfo.js'\nexport {noopLogger} from '../telemetry/noopTelemetry.js'\n"],"names":["clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","reportCliTraceError","setCliTelemetry","getTelemetryBaseInfo","noopLogger"],"mappings":"AAAA,iDAAiD;AACjD,8DAA8D;AAC9D,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,mBAAmB,EACnBC,eAAe,QACV,kCAAiC;AACxC,SAAQC,oBAAoB,QAAO,uCAAsC;AACzE,SAAQC,UAAU,QAAO,gCAA+B"}
|