@sanity/workbench-cli 2.0.1 → 2.1.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 (34) hide show
  1. package/dist/_exports/_internal_render.d.ts +12 -0
  2. package/dist/_exports/_internal_render.js +3 -0
  3. package/dist/_exports/_internal_render.js.map +1 -0
  4. package/dist/_exports/build.d.ts +13 -253
  5. package/dist/_exports/contract-DyG11fQ7.d.ts +45 -0
  6. package/dist/_exports/defineApp-DSvQx8rf.d.ts +151 -0
  7. package/dist/_exports/deploy.d.ts +94 -427
  8. package/dist/_exports/dev.d.ts +26 -196
  9. package/dist/_exports/index.d.ts +74 -407
  10. package/dist/_exports/init.d.ts +5 -9
  11. package/dist/_exports/preview.d.ts +20 -187
  12. package/dist/_exports/registry-DI7hnTof.d.ts +102 -0
  13. package/dist/_exports/resolveWorkbenchApp-Be9eU8mu.d.ts +41 -0
  14. package/dist/_exports/summarizeInterfaces-DLsq6P43.d.ts +62 -0
  15. package/dist/_exports/undeploy.d.ts +15 -296
  16. package/dist/actions/build/vite/plugins/plugin-module-federation.js +7 -15
  17. package/dist/actions/build/vite/plugins/plugin-module-federation.js.map +1 -1
  18. package/dist/actions/dev/registry.js +9 -0
  19. package/dist/actions/dev/registry.js.map +1 -1
  20. package/dist/actions/dev/startDevServerRegistration.js +50 -3
  21. package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
  22. package/dist/actions/dev/startWorkbenchDevServer.js +15 -36
  23. package/dist/actions/dev/startWorkbenchDevServer.js.map +1 -1
  24. package/dist/actions/dev/writeWorkbenchRuntime.js +2 -2
  25. package/dist/actions/dev/writeWorkbenchRuntime.js.map +1 -1
  26. package/dist/defineApp.js +1 -4
  27. package/dist/defineApp.js.map +1 -1
  28. package/dist/renderDashboard.js +63 -0
  29. package/dist/renderDashboard.js.map +1 -0
  30. package/dist/services/applications.js +7 -7
  31. package/dist/services/applications.js.map +1 -1
  32. package/dist/services/installations.js +4 -4
  33. package/dist/services/installations.js.map +1 -1
  34. package/package.json +13 -7
@@ -0,0 +1,12 @@
1
+ declare global {
2
+ var __SANITY_STAGING__: boolean | undefined;
3
+ }
4
+ interface DashboardConfig {
5
+ organizationId: string;
6
+ }
7
+ interface RenderDashboardOptions {
8
+ reactStrictMode?: boolean;
9
+ }
10
+ declare function renderDashboard(rootElement: HTMLElement | null, config: DashboardConfig, options?: RenderDashboardOptions): Promise<() => void>;
11
+ export { renderDashboard };
12
+ //# sourceMappingURL=_internal_render.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { renderDashboard } from '../renderDashboard.js';
2
+
3
+ //# sourceMappingURL=_internal_render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/_exports/_internal_render.ts"],"sourcesContent":["export {renderDashboard} from '../renderDashboard.js'\n"],"names":["renderDashboard"],"mappings":"AAAA,SAAQA,eAAe,QAAO,wBAAuB"}
@@ -1,248 +1,5 @@
1
- import { AppVisibility } from "@sanity/cli-core";
2
- import { CliConfig } from "@sanity/cli-core";
1
+ import { n as WorkbenchExposes, r as resolveWorkbenchApp, t as ResolvedWorkbenchApp } from "./resolveWorkbenchApp-Be9eU8mu.js";
3
2
  import { PluginOption } from "vite";
4
- import { z } from "zod/mini";
5
-
6
- /** The `asset_source` variant of an app's `views`. @public */
7
- declare type AssetSourceView = Extract<
8
- NonNullable<z.output<typeof DefineAppInputSchema>["views"]>[number],
9
- {
10
- type: "asset_source";
11
- }
12
- >;
13
-
14
- /**
15
- * The `build`/`start` id — a hash of the app's declared shape (its identity, not
16
- * its code), so the bundle inlined by `sanity build` and the registry entry
17
- * advertised by `sanity start` resolve to the same id. `sanity deploy` resolves
18
- * its own id from the applications API.
19
- */
20
- export declare function buildAppId(app: ResolvedWorkbenchApp): Promise<string>;
21
-
22
- /**
23
- * User-facing input for `unstable_defineApp`. Excludes the internal
24
- * `applicationType`, `isSingleton`, and `config` — validated by the schema but
25
- * not part of the public surface (Sanity-owned apps set them via
26
- * `@ts-expect-error`). A union: an app declares an app `entry` (navigable) or
27
- * panel `views`, never both — but `asset_source` and `tile` views are separate
28
- * kinds and may accompany either.
29
- * @public
30
- */
31
- declare type DefineAppInput = Omit<
32
- z.output<typeof DefineAppInputSchema>,
33
- "applicationType" | "config" | "entry" | "isSingleton" | "views"
34
- > &
35
- (
36
- | {
37
- entry?: never;
38
- views?: NonNullable<z.output<typeof DefineAppInputSchema>["views"]>;
39
- }
40
- | {
41
- entry?: string;
42
- views?: (AssetSourceView | TileView)[];
43
- }
44
- );
45
-
46
- /**
47
- * Runtime-validation schema for `unstable_defineApp`.
48
- * @internal
49
- */
50
- declare const DefineAppInputSchema: z.ZodMiniObject<
51
- {
52
- applicationType: z.ZodMiniOptional<
53
- z.ZodMiniEnum<{
54
- "media-library": "media-library";
55
- coreApp: "coreApp";
56
- studio: "studio";
57
- canvas: "canvas";
58
- dashboard: "dashboard";
59
- }>
60
- >;
61
- config: z.ZodMiniOptional<
62
- z.ZodMiniDiscriminatedUnion<
63
- [
64
- z.ZodMiniObject<
65
- {
66
- appType: z.ZodMiniLiteral<"media-library">;
67
- fields: z.ZodMiniArray<
68
- z.ZodMiniObject<
69
- {
70
- public: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
71
- title: z.ZodMiniString<string>;
72
- name: z.ZodMiniString<string>;
73
- src: z.ZodMiniString<string>;
74
- },
75
- z.core.$strip
76
- >
77
- >;
78
- },
79
- z.core.$strip
80
- >,
81
- ],
82
- "appType"
83
- >
84
- >;
85
- entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
86
- group: z.ZodMiniOptional<
87
- z.ZodMiniEnum<{
88
- "dock.system": "dock.system";
89
- "dock.applications": "dock.applications";
90
- "dock.user": "dock.user";
91
- }>
92
- >;
93
- icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
94
- isSingleton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
95
- organizationId: z.ZodMiniString<string>;
96
- priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
97
- services: z.ZodMiniOptional<
98
- z.ZodMiniArray<
99
- z.ZodMiniDiscriminatedUnion<
100
- [
101
- z.ZodMiniObject<
102
- {
103
- title: z.ZodMiniString<string>;
104
- name: z.ZodMiniString<string>;
105
- src: z.ZodMiniString<string>;
106
- type: z.ZodMiniLiteral<"worker">;
107
- },
108
- z.core.$strip
109
- >,
110
- ],
111
- "type"
112
- >
113
- >
114
- >;
115
- slug: z.ZodMiniString<string>;
116
- title: z.ZodMiniString<string>;
117
- views: z.ZodMiniOptional<
118
- z.ZodMiniArray<
119
- z.ZodMiniDiscriminatedUnion<
120
- [
121
- z.ZodMiniObject<
122
- {
123
- title: z.ZodMiniString<string>;
124
- name: z.ZodMiniString<string>;
125
- src: z.ZodMiniString<string>;
126
- type: z.ZodMiniLiteral<"panel">;
127
- },
128
- z.core.$strip
129
- >,
130
- z.ZodMiniObject<
131
- {
132
- title: z.ZodMiniString<string>;
133
- name: z.ZodMiniString<string>;
134
- src: z.ZodMiniString<string>;
135
- type: z.ZodMiniLiteral<"asset_source">;
136
- },
137
- z.core.$strip
138
- >,
139
- z.ZodMiniObject<
140
- {
141
- priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
142
- size: z.ZodMiniEnum<{
143
- small: "small";
144
- large: "large";
145
- banner: "banner";
146
- }>;
147
- title: z.ZodMiniString<string>;
148
- name: z.ZodMiniString<string>;
149
- src: z.ZodMiniString<string>;
150
- type: z.ZodMiniLiteral<"tile">;
151
- },
152
- z.core.$strip
153
- >,
154
- ],
155
- "type"
156
- >
157
- >
158
- >;
159
- visibility: z.ZodMiniOptional<
160
- z.ZodMiniEnum<{
161
- default: "default";
162
- unlisted: "unlisted";
163
- disabled: "disabled";
164
- }>
165
- >;
166
- },
167
- z.core.$strip
168
- >;
169
-
170
- /**
171
- * The branded result of `unstable_defineApp`. Carries the same fields as the
172
- * input plus the internal brand — users only ever see `DefineAppInput`.
173
- * @public
174
- */
175
- declare type DefineAppResult = DefineAppInput & {
176
- readonly [WORKBENCH_APP]: true;
177
- };
178
-
179
- /** @public */
180
- declare interface ResolvedWorkbenchApp {
181
- /** Organization that owns the app — part of its build-id identity. */
182
- readonly organizationId: string;
183
- /** Background worker services the app declares. */
184
- readonly services: NonNullable<DefineAppInput["services"]>;
185
- readonly slug: string;
186
- /** Dock panel views the app declares. */
187
- readonly views: NonNullable<DefineAppInput["views"]>;
188
- /** Resolved app kind — `studio` or one of the SDK app types. */
189
- readonly applicationType?: string;
190
- /** Deploys on its own path, separate from the interfaces. */
191
- readonly config?: WorkbenchApp["config"];
192
- /** SDK app-view entrypoint, when declared. */
193
- readonly entry?: string;
194
- /** Path to the app's icon SVG, resolved and shipped to Brett on deploy. */
195
- readonly icon?: string;
196
- /** Explicit singleton flag (a Sanity-owned app); `undefined` when the app doesn't set it. */
197
- readonly isSingleton?: boolean;
198
- /** Dashboard visibility declared by the app; `undefined` when unset. */
199
- readonly visibility?: AppVisibility;
200
- }
201
-
202
- /**
203
- * Resolve the workbench app for a CLI config, or `null` for a plain project.
204
- * @public
205
- */
206
- export declare function resolveWorkbenchApp(
207
- cliConfig: CliConfig | null | undefined,
208
- ): ResolvedWorkbenchApp | null;
209
-
210
- /** The `tile` variant of an app's `views`. @public */
211
- declare type TileView = Extract<
212
- NonNullable<z.output<typeof DefineAppInputSchema>["views"]>[number],
213
- {
214
- type: "tile";
215
- }
216
- >;
217
-
218
- /**
219
- * Nominal brand the CLI discriminates on to enable the workbench build/deploy
220
- * codepath. Registered via `Symbol.for` so the marker survives module-realm
221
- * boundaries — `@sanity/cli-core` re-derives the same global symbol with
222
- * `Symbol.for` rather than importing it, so it stays internal to this module.
223
- */
224
- declare const WORKBENCH_APP: unique symbol;
225
-
226
- /**
227
- * A branded app as the CLI reads it — the full schema shape, including the
228
- * internal fields `DefineAppInput` omits. Schema-derived so the narrowing
229
- * can't drift from what the schema validates.
230
- * @public
231
- */
232
- declare type WorkbenchApp = DefineAppResult &
233
- z.output<typeof DefineAppInputSchema>;
234
-
235
- /**
236
- * Bundled so adding a declaration family touches this type and the artifact
237
- * expanders, not every hop of build/dev plumbing in between.
238
- * @internal
239
- */
240
- export declare interface WorkbenchExposes {
241
- config?: WorkbenchApp["config"];
242
- services?: DefineAppInput["services"];
243
- views?: DefineAppInput["views"];
244
- }
245
-
246
3
  /**
247
4
  * Dep pre-bundling inputs for a workbench app's dev server.
248
5
  *
@@ -267,7 +24,7 @@ export declare interface WorkbenchExposes {
267
24
  * @param exposes - The app's declared views/services/config.
268
25
  * @internal
269
26
  */
270
- export declare function workbenchOptimizeDeps(options: {
27
+ declare function workbenchOptimizeDeps(options: {
271
28
  appSources: readonly string[];
272
29
  cwd: string;
273
30
  exposes?: WorkbenchExposes;
@@ -275,8 +32,7 @@ export declare function workbenchOptimizeDeps(options: {
275
32
  entries: string[];
276
33
  include: string[];
277
34
  };
278
-
279
- declare interface WorkbenchViteOptions {
35
+ interface WorkbenchViteOptions {
280
36
  /** Project root — read for the federation remote name, and the plugin workDir. */
281
37
  cwd: string;
282
38
  /**
@@ -294,10 +50,14 @@ declare interface WorkbenchViteOptions {
294
50
  /** App (vs studio) build — selects the discriminated federation option shape. */
295
51
  isApp?: boolean;
296
52
  }
297
-
298
53
  /** Build the Vite plugins for a workbench app's module-federation remote. */
299
- export declare function workbenchVitePlugins(
300
- options: WorkbenchViteOptions,
301
- ): Promise<PluginOption>;
302
-
303
- export {};
54
+ declare function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<PluginOption>;
55
+ /**
56
+ * The `build`/`start` id — a hash of the app's declared shape (its identity, not
57
+ * its code), so the bundle inlined by `sanity build` and the registry entry
58
+ * advertised by `sanity start` resolve to the same id. `sanity deploy` resolves
59
+ * its own id from the applications API.
60
+ */
61
+ declare function buildAppId(app: ResolvedWorkbenchApp): Promise<string>;
62
+ export { type WorkbenchExposes, buildAppId, resolveWorkbenchApp, workbenchOptimizeDeps, workbenchVitePlugins };
63
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1,45 @@
1
+ import { z } from "zod/mini";
2
+ /** @internal */
3
+ declare const VIEW_CONTRACT_VERSION = 1;
4
+ /** @internal */
5
+ declare const SERVICE_CONTRACT_VERSION = 1;
6
+ /**
7
+ * A view component. The return is opaque so the runtime helpers carry no React
8
+ * dependency — the generated artifact renders it with the app's own React.
9
+ * @public
10
+ */
11
+ type ViewComponent<TProps> = (props: TProps) => unknown;
12
+ /** @public */
13
+ interface ViewComponentBaseProps<TView> {
14
+ view: TView;
15
+ }
16
+ /**
17
+ * Component slots each interface type exposes, in render order. Source of truth
18
+ * for {@link InterfaceType} and the build; add a type by registering it here.
19
+ * @internal
20
+ */
21
+ declare const VIEW_COMPONENTS: {
22
+ readonly asset_source: readonly ["asset_source"];
23
+ readonly panel: readonly ["title", "panel"];
24
+ readonly tile: readonly ["tile"];
25
+ };
26
+ /** @public */
27
+ type InterfaceType = keyof typeof VIEW_COMPONENTS;
28
+ /**
29
+ * A tile's footprint family — the shape it occupies on the dashboard. Modelled
30
+ * on iOS WidgetKit families, not a linear scale: `banner` is full-width and
31
+ * shallow, which a `small`→`large` magnitude can't express. The host maps a
32
+ * family to a layout slot; the component reads it to render per footprint.
33
+ * @public
34
+ */
35
+ declare const TileSizeSchema: z.ZodMiniEnum<{
36
+ small: "small";
37
+ large: "large";
38
+ banner: "banner";
39
+ }>;
40
+ /** @public */
41
+ type TileSize = z.infer<typeof TileSizeSchema>;
42
+ /** @public */
43
+ type ServiceType = 'worker';
44
+ export { VIEW_CONTRACT_VERSION as a, TileSize as i, SERVICE_CONTRACT_VERSION as n, ViewComponent as o, ServiceType as r, ViewComponentBaseProps as s, InterfaceType as t };
45
+ //# sourceMappingURL=contract-DyG11fQ7.d.ts.map
@@ -0,0 +1,151 @@
1
+ import { z } from "zod/mini";
2
+ /** Dock groups an app can place itself into. */
3
+ declare const DockGroupSchema: z.ZodMiniEnum<{
4
+ "dock.system": "dock.system";
5
+ "dock.applications": "dock.applications";
6
+ "dock.user": "dock.user";
7
+ }>;
8
+ /**
9
+ * Dock group identifier. The API does not block a user app from declaring a
10
+ * reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned
11
+ * apps ahead.
12
+ * @public
13
+ */
14
+ type DockGroup = z.output<typeof DockGroupSchema>;
15
+ /**
16
+ * Runtime-validation schema for `unstable_defineApp`.
17
+ * @internal
18
+ */
19
+ declare const DefineAppInputSchema: z.ZodMiniObject<{
20
+ applicationType: z.ZodMiniOptional<z.ZodMiniEnum<{
21
+ coreApp: "coreApp";
22
+ studio: "studio";
23
+ canvas: "canvas";
24
+ dashboard: "dashboard";
25
+ "media-library": "media-library";
26
+ }>>;
27
+ config: z.ZodMiniOptional<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
28
+ appType: z.ZodMiniLiteral<"media-library">;
29
+ fields: z.ZodMiniArray<z.ZodMiniObject<{
30
+ public: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
31
+ title: z.ZodMiniString<string>;
32
+ name: z.ZodMiniString<string>;
33
+ src: z.ZodMiniString<string>;
34
+ }, z.core.$strip>>;
35
+ }, z.core.$strip>], "appType">>;
36
+ entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
37
+ group: z.ZodMiniOptional<z.ZodMiniEnum<{
38
+ "dock.system": "dock.system";
39
+ "dock.applications": "dock.applications";
40
+ "dock.user": "dock.user";
41
+ }>>;
42
+ icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
43
+ isSingleton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
44
+ organizationId: z.ZodMiniString<string>;
45
+ priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
46
+ services: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
47
+ title: z.ZodMiniString<string>;
48
+ name: z.ZodMiniString<string>;
49
+ src: z.ZodMiniString<string>;
50
+ type: z.ZodMiniLiteral<"worker">;
51
+ }, z.core.$strip>], "type">>>;
52
+ slug: z.ZodMiniString<string>;
53
+ title: z.ZodMiniString<string>;
54
+ views: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
55
+ title: z.ZodMiniString<string>;
56
+ name: z.ZodMiniString<string>;
57
+ src: z.ZodMiniString<string>;
58
+ type: z.ZodMiniLiteral<"panel">;
59
+ }, z.core.$strip>, z.ZodMiniObject<{
60
+ title: z.ZodMiniString<string>;
61
+ name: z.ZodMiniString<string>;
62
+ src: z.ZodMiniString<string>;
63
+ type: z.ZodMiniLiteral<"asset_source">;
64
+ }, z.core.$strip>, z.ZodMiniObject<{
65
+ priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
66
+ size: z.ZodMiniEnum<{
67
+ small: "small";
68
+ large: "large";
69
+ banner: "banner";
70
+ }>;
71
+ title: z.ZodMiniString<string>;
72
+ name: z.ZodMiniString<string>;
73
+ src: z.ZodMiniString<string>;
74
+ type: z.ZodMiniLiteral<"tile">;
75
+ }, z.core.$strip>], "type">>>;
76
+ visibility: z.ZodMiniOptional<z.ZodMiniEnum<{
77
+ default: "default";
78
+ unlisted: "unlisted";
79
+ disabled: "disabled";
80
+ }>>;
81
+ }, z.core.$strip>;
82
+ /**
83
+ * User-facing input for `unstable_defineApp`. Excludes the internal
84
+ * `applicationType`, `isSingleton`, and `config`.
85
+ * @public
86
+ */
87
+ type DefineAppInput = Omit<z.output<typeof DefineAppInputSchema>, 'applicationType' | 'config' | 'isSingleton'>;
88
+ /**
89
+ * Nominal brand the CLI discriminates on to enable the workbench build/deploy
90
+ * codepath. Registered via `Symbol.for` so the marker survives module-realm
91
+ * boundaries — `@sanity/cli-core` re-derives the same global symbol with
92
+ * `Symbol.for` rather than importing it, so it stays internal to this module.
93
+ */
94
+ declare const WORKBENCH_APP: unique symbol;
95
+ /**
96
+ * The branded result of `unstable_defineApp`. Carries the same fields as the
97
+ * input plus the internal brand — users only ever see `DefineAppInput`.
98
+ * @public
99
+ */
100
+ type DefineAppResult = DefineAppInput & {
101
+ readonly [WORKBENCH_APP]: true;
102
+ };
103
+ /**
104
+ * A branded app as the CLI reads it — the full schema shape, including the
105
+ * internal fields `DefineAppInput` omits. Schema-derived so the narrowing
106
+ * can't drift from what the schema validates.
107
+ * @public
108
+ */
109
+ type WorkbenchApp = DefineAppResult & z.output<typeof DefineAppInputSchema>;
110
+ /**
111
+ * Whether `app` is a branded `unstable_defineApp(...)` result — the sole
112
+ * workbench opt-in.
113
+ * @public
114
+ */
115
+ declare function isWorkbenchApp(app: unknown): app is WorkbenchApp;
116
+ /**
117
+ * Declare a Sanity Workbench application. Identity at runtime — returns the same
118
+ * object reference, tagged with the workbench brand. Field validation (the
119
+ * `slug` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;
120
+ * this helper stays a thin, pure identity wrapper.
121
+ * @public
122
+ */
123
+ declare function unstable_defineApp(input: DefineAppInput): DefineAppResult;
124
+ /**
125
+ * One custom field a media library exposes. `src` default-exports a `defineField(...)` schema type.
126
+ * @public
127
+ */
128
+ interface MediaLibraryField {
129
+ /** Unique within the media library. */
130
+ name: string;
131
+ src: string;
132
+ title: string;
133
+ /** Readable outside the owning organization. */
134
+ public?: boolean;
135
+ }
136
+ /**
137
+ * Sanity-owned singleton, so authors don't name or title the app — only `organizationId` is required.
138
+ * @public
139
+ */
140
+ interface DefineMediaLibraryInput {
141
+ /** Organization that owns the media library — the CLI runs and deploys against it. */
142
+ organizationId: string;
143
+ fields?: MediaLibraryField[];
144
+ }
145
+ /**
146
+ * Declare the Sanity Media Library as a workbench app — a singleton whose `fields` become its config.
147
+ * @public
148
+ */
149
+ declare function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): DefineAppResult;
150
+ export { MediaLibraryField as a, unstable_defineApp as c, DockGroup as i, unstable_defineMediaLibrary as l, DefineAppResult as n, WorkbenchApp as o, DefineMediaLibraryInput as r, isWorkbenchApp as s, DefineAppInput as t };
151
+ //# sourceMappingURL=defineApp-DSvQx8rf.d.ts.map