@sanity/workbench-cli 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,92 @@
1
- import { AppVisibility } from "@sanity/cli-core";
2
- import { CliConfig } from "@sanity/cli-core";
3
- import { Output } from "@sanity/cli-core";
4
- import { z } from "zod/mini";
5
-
6
- export declare interface Application {
1
+ import { i as getWorkbench, n as summarizeInterfaces, r as DeployableWorkbenchApp, t as DeployedInterface } from "./summarizeInterfaces-DBGiAwNT.js";
2
+ import "./contract-DyG11fQ7.js";
3
+ import { AppVisibility, CliConfig, Output } from "@sanity/cli-core";
4
+ import "node:zlib";
5
+ /**
6
+ * Throws unless `sourceDir` is a directory holding a federation build.
7
+ * A workbench build always emits a module-federation remote, and may
8
+ * additionally emit a standalone `index.html` SPA (workbench remotes). Either
9
+ * way `mf-manifest.json` is the reliable marker that `sanity build` produced a
10
+ * federation build, so that — not `index.html` — is what we check for.
11
+ */
12
+ declare function checkBuiltOutput(sourceDir: string): Promise<void>;
13
+ /**
14
+ * The org's active installation for an app type, or `undefined` when none is
15
+ * installed. Read-only, so `--dry-run` can report deployability.
16
+ * @internal
17
+ */
18
+ declare function resolveInstallationId(options: {
19
+ appType: string;
20
+ organizationId: string;
21
+ }): Promise<string | undefined>;
22
+ /**
23
+ * A report heading and item list for a config; a media library's `fields` are
24
+ * one of potentially many shapes.
25
+ * @internal
26
+ */
27
+ declare function summarizeConfig(config: {
28
+ appType: string;
29
+ fields: {
30
+ name: string;
31
+ src: string;
32
+ title: string;
33
+ }[];
34
+ }): string;
35
+ /**
36
+ * Upload the built module-federation remote to the installation as its config
37
+ * snapshot. `installationId` is resolved by the caller so `--dry-run` never
38
+ * reaches this mutating step.
39
+ * @internal
40
+ */
41
+ declare function deployConfig(options: {
42
+ appType: string;
43
+ installationId: string;
44
+ organizationId: string;
45
+ output: Output;
46
+ sourceDir: string;
47
+ version: string;
48
+ }): Promise<void>;
49
+ /** What a workbench app contributes to a deploy payload. */
50
+ interface WorkbenchDeployPayload {
51
+ slug: string;
52
+ title: string;
53
+ /** Media-library config summary. */
54
+ config?: string;
55
+ isSingleton?: boolean;
56
+ services?: DeployedInterface[];
57
+ views?: DeployedInterface[];
58
+ visibility?: string;
59
+ }
60
+ /**
61
+ * Gated once so a plain app can't pick up a stray key: without a workbench
62
+ * there is nothing to contribute. `views` and `services` travel together.
63
+ */
64
+ declare function toWorkbenchPayload(workbench: DeployableWorkbenchApp | null, { config, interfaces, title }: {
65
+ config?: string;
66
+ interfaces: {
67
+ services: DeployedInterface[];
68
+ views: DeployedInterface[];
69
+ } | null;
70
+ title: string;
71
+ }): Partial<WorkbenchDeployPayload>;
72
+ type ApplicationType = 'coreApp' | 'studio';
73
+ interface Application {
7
74
  id: string;
8
75
  organizationId: string;
9
76
  slug: string | null;
10
77
  title: string;
11
78
  type: ApplicationType;
12
79
  }
13
-
14
- declare type ApplicationType = "coreApp" | "studio";
15
-
16
- /** The `asset_source` variant of an app's `views`. @public */
17
- declare type AssetSourceView = Extract<
18
- NonNullable<z.output<typeof DefineAppInputSchema>["views"]>[number],
19
- {
20
- type: "asset_source";
21
- }
22
- >;
23
-
24
80
  /**
25
81
  * A resource a deployment may interact with, as Brett stores it. Per-deployment
26
82
  * and forbidden for singletons (the server 400s).
27
83
  */
28
- export declare interface BrettAccess {
84
+ interface BrettAccess {
29
85
  resourceId: string;
30
- resourceType: "canvas" | "dashboard" | "dataset" | "media-library";
86
+ resourceType: 'canvas' | 'dashboard' | 'dataset' | 'media-library';
31
87
  }
32
-
33
88
  /** A studio workspace as Brett stores it. */
34
- export declare interface BrettWorkspace {
89
+ interface BrettWorkspace {
35
90
  dataset: string;
36
91
  projectId: string;
37
92
  /** Lexicon schema descriptor id; Brett requires one per workspace. */
@@ -42,251 +97,43 @@ export declare interface BrettWorkspace {
42
97
  subtitle?: string;
43
98
  title?: string;
44
99
  }
45
-
100
+ declare function getWorkbenchUrl(organizationId: string): string;
101
+ /** Where a deployed application is served on its organization's workbench. */
102
+ declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'type'>): string;
103
+ declare function getApplication(applicationId: string): Promise<Application | null>;
104
+ /** Every application in an organization, in one page (`limit=none`). */
105
+ declare function listApplications(organizationId: string): Promise<Application[]>;
46
106
  /**
47
- * Throws unless `sourceDir` is a directory holding a federation build.
48
- * A workbench build always emits a module-federation remote, and may
49
- * additionally emit a standalone `index.html` SPA (workbench remotes). Either
50
- * way `mf-manifest.json` is the reliable marker that `sanity build` produced a
51
- * federation build, so that — not `index.html` — is what we check for.
107
+ * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.
108
+ * @internal
52
109
  */
53
- export declare function checkBuiltOutput(sourceDir: string): Promise<void>;
54
-
110
+ interface CreatedApplication {
111
+ application: Application;
112
+ rollback: () => Promise<void>;
113
+ }
55
114
  /**
56
115
  * Create a coreApp record (no deployment), so the CLI can build with its id
57
116
  * before shipping the first deployment. First deploy only.
58
117
  * @internal
59
118
  */
60
- export declare function createCoreApp(options: {
119
+ declare function createCoreApp(options: {
61
120
  isSingleton?: boolean;
62
121
  organizationId: string;
63
122
  slug: string;
64
123
  title: string;
65
124
  visibility?: AppVisibility;
66
125
  }): Promise<CreatedApplication>;
67
-
68
- /**
69
- * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.
70
- * @internal
71
- */
72
- export declare interface CreatedApplication {
73
- application: Application;
74
- rollback: () => Promise<void>;
75
- }
76
-
77
126
  /**
78
127
  * Create a studio record (no deployment).
79
128
  * @internal
80
129
  */
81
- export declare function createStudio(options: {
130
+ declare function createStudio(options: {
82
131
  organizationId: string;
83
132
  projectId: string | undefined;
84
133
  slug: string;
85
134
  title: string;
86
135
  visibility?: AppVisibility;
87
136
  }): Promise<CreatedApplication>;
88
-
89
- /**
90
- * User-facing input for `unstable_defineApp`. Excludes the internal
91
- * `applicationType`, `isSingleton`, and `config` — validated by the schema but
92
- * not part of the public surface (Sanity-owned apps set them via
93
- * `@ts-expect-error`). A union: an app declares an app `entry` (navigable) or
94
- * panel `views`, never both — but `asset_source` and `tile` views are separate
95
- * kinds and may accompany either.
96
- * @public
97
- */
98
- declare type DefineAppInput = Omit<
99
- z.output<typeof DefineAppInputSchema>,
100
- "applicationType" | "config" | "entry" | "isSingleton" | "views"
101
- > &
102
- (
103
- | {
104
- entry?: never;
105
- views?: NonNullable<z.output<typeof DefineAppInputSchema>["views"]>;
106
- }
107
- | {
108
- entry?: string;
109
- views?: (AssetSourceView | TileView)[];
110
- }
111
- );
112
-
113
- /**
114
- * Runtime-validation schema for `unstable_defineApp`.
115
- * @internal
116
- */
117
- declare const DefineAppInputSchema: z.ZodMiniObject<
118
- {
119
- applicationType: z.ZodMiniOptional<
120
- z.ZodMiniEnum<{
121
- "media-library": "media-library";
122
- coreApp: "coreApp";
123
- studio: "studio";
124
- canvas: "canvas";
125
- dashboard: "dashboard";
126
- }>
127
- >;
128
- config: z.ZodMiniOptional<
129
- z.ZodMiniDiscriminatedUnion<
130
- [
131
- z.ZodMiniObject<
132
- {
133
- appType: z.ZodMiniLiteral<"media-library">;
134
- fields: z.ZodMiniArray<
135
- z.ZodMiniObject<
136
- {
137
- public: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
138
- title: z.ZodMiniString<string>;
139
- name: z.ZodMiniString<string>;
140
- src: z.ZodMiniString<string>;
141
- },
142
- z.core.$strip
143
- >
144
- >;
145
- },
146
- z.core.$strip
147
- >,
148
- ],
149
- "appType"
150
- >
151
- >;
152
- entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
153
- group: z.ZodMiniOptional<
154
- z.ZodMiniEnum<{
155
- "dock.system": "dock.system";
156
- "dock.applications": "dock.applications";
157
- "dock.user": "dock.user";
158
- }>
159
- >;
160
- icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
161
- isSingleton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
162
- organizationId: z.ZodMiniString<string>;
163
- priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
164
- services: z.ZodMiniOptional<
165
- z.ZodMiniArray<
166
- z.ZodMiniDiscriminatedUnion<
167
- [
168
- z.ZodMiniObject<
169
- {
170
- title: z.ZodMiniString<string>;
171
- name: z.ZodMiniString<string>;
172
- src: z.ZodMiniString<string>;
173
- type: z.ZodMiniLiteral<"worker">;
174
- },
175
- z.core.$strip
176
- >,
177
- ],
178
- "type"
179
- >
180
- >
181
- >;
182
- slug: z.ZodMiniString<string>;
183
- title: z.ZodMiniString<string>;
184
- views: z.ZodMiniOptional<
185
- z.ZodMiniArray<
186
- z.ZodMiniDiscriminatedUnion<
187
- [
188
- z.ZodMiniObject<
189
- {
190
- title: z.ZodMiniString<string>;
191
- name: z.ZodMiniString<string>;
192
- src: z.ZodMiniString<string>;
193
- type: z.ZodMiniLiteral<"panel">;
194
- },
195
- z.core.$strip
196
- >,
197
- z.ZodMiniObject<
198
- {
199
- title: z.ZodMiniString<string>;
200
- name: z.ZodMiniString<string>;
201
- src: z.ZodMiniString<string>;
202
- type: z.ZodMiniLiteral<"asset_source">;
203
- },
204
- z.core.$strip
205
- >,
206
- z.ZodMiniObject<
207
- {
208
- priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
209
- size: z.ZodMiniEnum<{
210
- small: "small";
211
- large: "large";
212
- banner: "banner";
213
- }>;
214
- title: z.ZodMiniString<string>;
215
- name: z.ZodMiniString<string>;
216
- src: z.ZodMiniString<string>;
217
- type: z.ZodMiniLiteral<"tile">;
218
- },
219
- z.core.$strip
220
- >,
221
- ],
222
- "type"
223
- >
224
- >
225
- >;
226
- visibility: z.ZodMiniOptional<
227
- z.ZodMiniEnum<{
228
- default: "default";
229
- unlisted: "unlisted";
230
- disabled: "disabled";
231
- }>
232
- >;
233
- },
234
- z.core.$strip
235
- >;
236
-
237
- /**
238
- * The branded result of `unstable_defineApp`. Carries the same fields as the
239
- * input plus the internal brand — users only ever see `DefineAppInput`.
240
- * @public
241
- */
242
- declare type DefineAppResult = DefineAppInput & {
243
- readonly [WORKBENCH_APP]: true;
244
- };
245
-
246
- declare interface DeployableWorkbenchApp extends ResolvedWorkbenchApp {
247
- /**
248
- * Throws when the app exposes nothing (no entry, view, service, or config) —
249
- * the remote would have nothing to load. Gated before any prompt or API call.
250
- */
251
- assertDeployable(): void;
252
- /**
253
- * Validates the app's declared views into the application-service payload.
254
- * Throws when a view declaration is malformed.
255
- */
256
- buildViewDeploymentPayload(applicationId: string): ViewDeploymentPayload;
257
- /**
258
- * A singleton (the Media Library) that carries an config — deploy
259
- * persists the config to the org's installation. Independent of the interfaces,
260
- * which register regardless; non-singletons never carry a config.
261
- */
262
- deploySingletonConfig: boolean;
263
- /** Declares something to host as an application — an entry, view, or service. */
264
- hasInterfaces: boolean;
265
- }
266
-
267
- /**
268
- * Upload the built module-federation remote to the installation as its config
269
- * snapshot. `installationId` is resolved by the caller so `--dry-run` never
270
- * reaches this mutating step.
271
- * @internal
272
- */
273
- export declare function deployConfig(options: {
274
- appType: string;
275
- installationId: string;
276
- organizationId: string;
277
- output: Output;
278
- sourceDir: string;
279
- version: string;
280
- }): Promise<void>;
281
-
282
- /** A view or service as the deploy report and `--json` output surface it. */
283
- export declare interface DeployedInterface {
284
- name: string;
285
- src: string;
286
- title: string;
287
- type: string;
288
- }
289
-
290
137
  /**
291
138
  * Ship a deployment to an already-created (or `deployment.appId`) application,
292
139
  * then sync its mutable metadata (`title`, and `icon`/`visibility` when set)
@@ -298,9 +145,9 @@ export declare interface DeployedInterface {
298
145
  * application once it has an active deployment.
299
146
  * @internal
300
147
  */
301
- export declare function deployWorkbenchApp(options: {
148
+ declare function deployWorkbenchApp(options: {
302
149
  access?: readonly BrettAccess[];
303
- app: CliConfig["app"];
150
+ app: CliConfig['app'];
304
151
  applicationId: string;
305
152
  icon?: string;
306
153
  isApp: boolean;
@@ -313,185 +160,5 @@ export declare function deployWorkbenchApp(options: {
313
160
  visibility?: AppVisibility;
314
161
  workspaces?: readonly BrettWorkspace[];
315
162
  }): Promise<void>;
316
-
317
- export declare function getApplication(
318
- applicationId: string,
319
- ): Promise<Application | null>;
320
-
321
- /** Where a deployed application is served on its organization's workbench. */
322
- export declare function getApplicationUrl(
323
- application: Pick<Application, "id" | "organizationId" | "type">,
324
- ): string;
325
-
326
- export declare function getWorkbench(
327
- cliConfig: CliConfig | null | undefined,
328
- ): DeployableWorkbenchApp | null;
329
-
330
- export declare function getWorkbenchUrl(organizationId: string): string;
331
-
332
- /** Every application in an organization, in one page (`limit=none`). */
333
- export declare function listApplications(
334
- organizationId: string,
335
- ): Promise<Application[]>;
336
-
337
- /** @public */
338
- declare interface ResolvedWorkbenchApp {
339
- /** Organization that owns the app — part of its build-id identity. */
340
- readonly organizationId: string;
341
- /** Background worker services the app declares. */
342
- readonly services: NonNullable<DefineAppInput["services"]>;
343
- readonly slug: string;
344
- /** Dock panel views the app declares. */
345
- readonly views: NonNullable<DefineAppInput["views"]>;
346
- /** Resolved app kind — `studio` or one of the SDK app types. */
347
- readonly applicationType?: string;
348
- /** Deploys on its own path, separate from the interfaces. */
349
- readonly config?: WorkbenchApp["config"];
350
- /** SDK app-view entrypoint, when declared. */
351
- readonly entry?: string;
352
- /** Path to the app's icon SVG, resolved and shipped to Brett on deploy. */
353
- readonly icon?: string;
354
- /** Explicit singleton flag (a Sanity-owned app); `undefined` when the app doesn't set it. */
355
- readonly isSingleton?: boolean;
356
- /** Dashboard visibility declared by the app; `undefined` when unset. */
357
- readonly visibility?: AppVisibility;
358
- }
359
-
360
- /**
361
- * The org's active installation for an app type, or `undefined` when none is
362
- * installed. Read-only, so `--dry-run` can report deployability.
363
- * @internal
364
- */
365
- export declare function resolveInstallationId(options: {
366
- appType: string;
367
- organizationId: string;
368
- }): Promise<string | undefined>;
369
-
370
- /**
371
- * A report heading and item list for a config; a media library's `fields` are
372
- * one of potentially many shapes.
373
- * @internal
374
- */
375
- export declare function summarizeConfig(config: {
376
- appType: string;
377
- fields: {
378
- name: string;
379
- src: string;
380
- title: string;
381
- }[];
382
- }): string;
383
-
384
- /**
385
- * One report line per non-empty group, alongside the records `--json` reports.
386
- * @internal
387
- */
388
- export declare function summarizeInterfaces({
389
- services,
390
- views,
391
- }: WorkbenchExposes): {
392
- lines: string[];
393
- services: DeployedInterface[];
394
- views: DeployedInterface[];
395
- };
396
-
397
- /** The `tile` variant of an app's `views`. @public */
398
- declare type TileView = Extract<
399
- NonNullable<z.output<typeof DefineAppInputSchema>["views"]>[number],
400
- {
401
- type: "tile";
402
- }
403
- >;
404
-
405
- /**
406
- * Gated once so a plain app can't pick up a stray key: without a workbench
407
- * there is nothing to contribute. `views` and `services` travel together.
408
- */
409
- export declare function toWorkbenchPayload(
410
- workbench: DeployableWorkbenchApp | null,
411
- {
412
- config,
413
- interfaces,
414
- title,
415
- }: {
416
- config?: string;
417
- interfaces: {
418
- services: DeployedInterface[];
419
- views: DeployedInterface[];
420
- } | null;
421
- title: string;
422
- },
423
- ): Partial<WorkbenchDeployPayload>;
424
-
425
- declare type ViewDeploymentPayload = z.infer<
426
- typeof viewDeploymentPayloadSchema
427
- >;
428
-
429
- /**
430
- * Payload registering an app's views with the application service on deploy.
431
- *
432
- * Phase 1 stub: the service that stores views does not exist yet, so the
433
- * payload is validated and logged only — never sent. Builds the contract the
434
- * application-service endpoint will accept.
435
- */
436
- declare const viewDeploymentPayloadSchema: z.ZodMiniObject<
437
- {
438
- applicationId: z.ZodMiniString<string>;
439
- views: z.ZodMiniArray<
440
- z.ZodMiniObject<
441
- {
442
- name: z.ZodMiniString<string>;
443
- src: z.ZodMiniString<string>;
444
- type: z.ZodMiniEnum<{
445
- asset_source: "asset_source";
446
- panel: "panel";
447
- tile: "tile";
448
- }>;
449
- },
450
- z.core.$loose
451
- >
452
- >;
453
- },
454
- z.core.$strip
455
- >;
456
-
457
- /**
458
- * Nominal brand the CLI discriminates on to enable the workbench build/deploy
459
- * codepath. Registered via `Symbol.for` so the marker survives module-realm
460
- * boundaries — `@sanity/cli-core` re-derives the same global symbol with
461
- * `Symbol.for` rather than importing it, so it stays internal to this module.
462
- */
463
- declare const WORKBENCH_APP: unique symbol;
464
-
465
- /**
466
- * A branded app as the CLI reads it — the full schema shape, including the
467
- * internal fields `DefineAppInput` omits. Schema-derived so the narrowing
468
- * can't drift from what the schema validates.
469
- * @public
470
- */
471
- declare type WorkbenchApp = DefineAppResult &
472
- z.output<typeof DefineAppInputSchema>;
473
-
474
- /** What a workbench app contributes to a deploy payload. */
475
- export declare interface WorkbenchDeployPayload {
476
- slug: string;
477
- title: string;
478
- /** Media-library config summary. */
479
- config?: string;
480
- isSingleton?: boolean;
481
- services?: DeployedInterface[];
482
- views?: DeployedInterface[];
483
- visibility?: string;
484
- }
485
-
486
- /**
487
- * Bundled so adding a declaration family touches this type and the artifact
488
- * expanders, not every hop of build/dev plumbing in between.
489
- * @internal
490
- */
491
- declare interface WorkbenchExposes {
492
- config?: WorkbenchApp["config"];
493
- services?: DefineAppInput["services"];
494
- views?: DefineAppInput["views"];
495
- }
496
-
497
- export {};
163
+ export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type WorkbenchDeployPayload, checkBuiltOutput, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
164
+ //# sourceMappingURL=deploy.d.ts.map