@sanity/workbench-cli 2.11.0 → 2.13.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 (39) hide show
  1. package/dist/_exports/_internal_worker_bus.d.ts +1 -1
  2. package/dist/_exports/build.d.ts +8 -2
  3. package/dist/_exports/build.js +1 -0
  4. package/dist/_exports/build.js.map +1 -1
  5. package/dist/_exports/{contract-D_HnLQtT.d.ts → contract-C4Y6gi-b.d.ts} +1 -14
  6. package/dist/_exports/{defineApp-4hImcIIe.d.ts → defineApp-vbUu_rBA.d.ts} +1 -8
  7. package/dist/_exports/{defineService-DUaxVpWq.d.ts → defineService-D_DFLM8x.d.ts} +2 -2
  8. package/dist/_exports/deploy.d.ts +8 -16
  9. package/dist/_exports/deploy.js +0 -1
  10. package/dist/_exports/deploy.js.map +1 -1
  11. package/dist/_exports/dev.d.ts +1 -1
  12. package/dist/_exports/index.d.ts +3 -3
  13. package/dist/_exports/preview.d.ts +1 -1
  14. package/dist/_exports/{registry-CIoKFIDw.d.ts → registry-DCjjQ1sS.d.ts} +1 -3
  15. package/dist/_exports/{resolveWorkbenchConfig-DEttN7ks.d.ts → resolveWorkbenchConfig-CgKD8AJ7.d.ts} +3 -3
  16. package/dist/_exports/{summarizeInterfaces-Co97VU2z.d.ts → summarizeInterfaces-CeV5Umpj.d.ts} +3 -3
  17. package/dist/_exports/undeploy.d.ts +2 -2
  18. package/dist/actions/{deploy/checkBuiltOutput.js → build/readBuiltManifest.js} +12 -9
  19. package/dist/actions/build/readBuiltManifest.js.map +1 -0
  20. package/dist/actions/deploy/deployWorkbenchApp.js +4 -7
  21. package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -1
  22. package/dist/actions/dev/registry.js +17 -17
  23. package/dist/actions/dev/registry.js.map +1 -1
  24. package/dist/actions/dev/startDevServerRegistration.js +4 -3
  25. package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
  26. package/dist/actions/dev/startWorkbenchDevServer.js +12 -9
  27. package/dist/actions/dev/startWorkbenchDevServer.js.map +1 -1
  28. package/dist/actions/preview/serveBuiltApplication.js +3 -3
  29. package/dist/actions/preview/serveBuiltApplication.js.map +1 -1
  30. package/dist/contract.js +5 -3
  31. package/dist/contract.js.map +1 -1
  32. package/dist/defineApp.js +1 -1
  33. package/dist/defineApp.js.map +1 -1
  34. package/dist/deriveInterfaces.js +3 -3
  35. package/dist/deriveInterfaces.js.map +1 -1
  36. package/dist/services/applications.js +2 -2
  37. package/dist/services/applications.js.map +1 -1
  38. package/package.json +4 -4
  39. package/dist/actions/deploy/checkBuiltOutput.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as ServiceBus } from "./defineService-DUaxVpWq.js";
1
+ import { n as ServiceBus } from "./defineService-D_DFLM8x.js";
2
2
  /**
3
3
  * The worker's side of the `workbench.bus.*` wire contract. The host relays
4
4
  * each request to the Dashboard bus and stamps it with the worker's identity,
@@ -1,5 +1,11 @@
1
- import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-DEttN7ks.js";
1
+ import { a as resolveAppEntry, i as WorkbenchExposes, n as resolveWorkbenchConfig, o as resolveWorkbenchApp, r as ResolvedWorkbenchApp, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-CgKD8AJ7.js";
2
2
  import { InlineConfig, PluginOption } from "vite";
3
+ /**
4
+ * Resolves to the parsed federation manifest in `sourceDir`. A workbench build
5
+ * may also emit a standalone `index.html`, so the manifest, not `index.html`,
6
+ * is the marker that `sanity build` produced a federation build.
7
+ */
8
+ declare function readBuiltManifest(sourceDir: string): Promise<Record<string, unknown>>;
3
9
  /**
4
10
  * Resource bindings ride in a dedicated module in the app's bundle rather than an
5
11
  * index.html script tag, so both standalone studios and federated apps resolve
@@ -114,5 +120,5 @@ declare function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<Pl
114
120
  * its own id from the applications API.
115
121
  */
116
122
  declare function buildAppId(app: ResolvedWorkbenchApp): Promise<string>;
117
- export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, type ResolvedMediaLibraryConfig, type WorkbenchExposes, buildAppId, buildFederatedApp, resolveAppEntry, resolveWorkbenchApp, resolveWorkbenchConfig, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup, workbenchOptimizeDeps, workbenchVitePlugins };
123
+ export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, type ResolvedMediaLibraryConfig, type WorkbenchExposes, buildAppId, buildFederatedApp, readBuiltManifest, resolveAppEntry, resolveWorkbenchApp, resolveWorkbenchConfig, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup, workbenchOptimizeDeps, workbenchVitePlugins };
118
124
  //# sourceMappingURL=build.d.ts.map
@@ -3,6 +3,7 @@
3
3
  // resolver the build reads declared views/web workers from. The build needs no
4
4
  // deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded
5
5
  // view (`getWorkbench`) is the deploy entry's export.
6
+ export { readBuiltManifest } from '../actions/build/readBuiltManifest.js';
6
7
  export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup } from '../actions/build/resource-bindings.js';
7
8
  export { buildFederatedApp } from '../actions/build/vite/discover-shared-dependencies.js';
8
9
  export { workbenchOptimizeDeps } from '../actions/build/vite/optimize-deps.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/build.ts"],"sourcesContent":["// Node-only build entry: the module-federation Vite plugins that\n// `@sanity/cli-build`'s `getViteConfig` swaps in for a workbench app, plus the\n// resolver the build reads declared views/web workers from. The build needs no\n// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded\n// view (`getWorkbench`) is the deploy entry's export.\n\nexport {\n RESOURCE_BINDINGS_CHUNK_NAME,\n RESOURCE_BINDINGS_ENTRY_IMPORT,\n RESOURCE_BINDINGS_FILENAME,\n RESOURCE_BINDINGS_MODULE_SOURCE,\n RESOURCE_BINDINGS_TOKEN,\n resourceBindingsChunkFileName,\n resourceBindingsCodeSplittingGroup,\n} from '../actions/build/resource-bindings.js'\nexport {buildFederatedApp} from '../actions/build/vite/discover-shared-dependencies.js'\nexport {workbenchOptimizeDeps} from '../actions/build/vite/optimize-deps.js'\nexport {workbenchVitePlugins} from '../actions/build/vite/workbench-vite-plugins.js'\nexport {buildAppId} from '../appId.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["RESOURCE_BINDINGS_CHUNK_NAME","RESOURCE_BINDINGS_ENTRY_IMPORT","RESOURCE_BINDINGS_FILENAME","RESOURCE_BINDINGS_MODULE_SOURCE","RESOURCE_BINDINGS_TOKEN","resourceBindingsChunkFileName","resourceBindingsCodeSplittingGroup","buildFederatedApp","workbenchOptimizeDeps","workbenchVitePlugins","buildAppId","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SACEA,4BAA4B,EAC5BC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,uBAAuB,EACvBC,6BAA6B,EAC7BC,kCAAkC,QAC7B,wCAAuC;AAC9C,SAAQC,iBAAiB,QAAO,wDAAuD;AACvF,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,oBAAoB,QAAO,kDAAiD;AACpF,SAAQC,UAAU,QAAO,cAAa;AACtC,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,SAAyCC,sBAAsB,QAAO,+BAA8B"}
1
+ {"version":3,"sources":["../../src/_exports/build.ts"],"sourcesContent":["// Node-only build entry: the module-federation Vite plugins that\n// `@sanity/cli-build`'s `getViteConfig` swaps in for a workbench app, plus the\n// resolver the build reads declared views/web workers from. The build needs no\n// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded\n// view (`getWorkbench`) is the deploy entry's export.\n\nexport {readBuiltManifest} from '../actions/build/readBuiltManifest.js'\nexport {\n RESOURCE_BINDINGS_CHUNK_NAME,\n RESOURCE_BINDINGS_ENTRY_IMPORT,\n RESOURCE_BINDINGS_FILENAME,\n RESOURCE_BINDINGS_MODULE_SOURCE,\n RESOURCE_BINDINGS_TOKEN,\n resourceBindingsChunkFileName,\n resourceBindingsCodeSplittingGroup,\n} from '../actions/build/resource-bindings.js'\nexport {buildFederatedApp} from '../actions/build/vite/discover-shared-dependencies.js'\nexport {workbenchOptimizeDeps} from '../actions/build/vite/optimize-deps.js'\nexport {workbenchVitePlugins} from '../actions/build/vite/workbench-vite-plugins.js'\nexport {buildAppId} from '../appId.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["readBuiltManifest","RESOURCE_BINDINGS_CHUNK_NAME","RESOURCE_BINDINGS_ENTRY_IMPORT","RESOURCE_BINDINGS_FILENAME","RESOURCE_BINDINGS_MODULE_SOURCE","RESOURCE_BINDINGS_TOKEN","resourceBindingsChunkFileName","resourceBindingsCodeSplittingGroup","buildFederatedApp","workbenchOptimizeDeps","workbenchVitePlugins","buildAppId","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SAAQA,iBAAiB,QAAO,wCAAuC;AACvE,SACEC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,uBAAuB,EACvBC,6BAA6B,EAC7BC,kCAAkC,QAC7B,wCAAuC;AAC9C,SAAQC,iBAAiB,QAAO,wDAAuD;AACvF,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,oBAAoB,QAAO,kDAAiD;AACpF,SAAQC,UAAU,QAAO,cAAa;AACtC,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,SAAyCC,sBAAsB,QAAO,+BAA8B"}
@@ -41,17 +41,11 @@ type ServiceType = 'worker';
41
41
  declare const DockGroupSchema: z.ZodMiniEnum<{
42
42
  system: "system";
43
43
  applications: "applications";
44
- user: "user";
45
44
  }>;
46
45
  /** @public */
47
46
  type DockGroup = z.output<typeof DockGroupSchema>;
48
47
  declare const PanelViewSchema: z.ZodMiniObject<{
49
48
  dock: z.ZodMiniOptional<z.ZodMiniObject<{
50
- group: z.ZodMiniOptional<z.ZodMiniEnum<{
51
- system: "system";
52
- applications: "applications";
53
- user: "user";
54
- }>>;
55
49
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
56
50
  }, z.core.$strip>>;
57
51
  title: z.ZodMiniString<string>;
@@ -70,7 +64,6 @@ declare const WindowViewSchema: z.ZodMiniObject<{
70
64
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
71
65
  system: "system";
72
66
  applications: "applications";
73
- user: "user";
74
67
  }>>;
75
68
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
76
69
  }, z.core.$strip>>;
@@ -121,7 +114,6 @@ declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMini
121
114
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
122
115
  system: "system";
123
116
  applications: "applications";
124
- user: "user";
125
117
  }>>;
126
118
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
127
119
  }, z.core.$strip>>;
@@ -131,11 +123,6 @@ declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMini
131
123
  surface: z.ZodMiniLiteral<"window">;
132
124
  }, z.core.$strip>, z.ZodMiniObject<{
133
125
  dock: z.ZodMiniOptional<z.ZodMiniObject<{
134
- group: z.ZodMiniOptional<z.ZodMiniEnum<{
135
- system: "system";
136
- applications: "applications";
137
- user: "user";
138
- }>>;
139
126
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
140
127
  }, z.core.$strip>>;
141
128
  title: z.ZodMiniString<string>;
@@ -194,4 +181,4 @@ declare const ConfigSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
194
181
  */
195
182
  type WorkbenchConfigValue = z.output<typeof ConfigSchema>;
196
183
  export { defineTileView as C, definePanelView as S, defineWindowView as T, ViewSurface as _, DefineWebWorkerInput as a, WorkbenchConfigValue as b, PanelView as c, TileSize as d, TileView as f, ViewDeclaration as g, ViewComponentBaseProps as h, DefineTileViewInput as i, SERVICE_CONTRACT_VERSION as l, ViewComponent as m, DefineAssetSourceViewInput as n, DefineWindowViewInput as o, VIEW_CONTRACT_VERSION as p, DefinePanelViewInput as r, DockGroup as s, AssetSourceView as t, ServiceType as u, WebWorker as v, defineWebWorker as w, defineAssetSourceView as x, WindowView as y };
197
- //# sourceMappingURL=contract-D_HnLQtT.d.ts.map
184
+ //# sourceMappingURL=contract-C4Y6gi-b.d.ts.map
@@ -14,7 +14,6 @@ declare const DefineAppInputSchema: z.ZodMiniObject<{
14
14
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
15
15
  system: "system";
16
16
  applications: "applications";
17
- user: "user";
18
17
  }>>;
19
18
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
20
19
  }, z.core.$strip>>;
@@ -30,7 +29,6 @@ declare const DefineAppInputSchema: z.ZodMiniObject<{
30
29
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
31
30
  system: "system";
32
31
  applications: "applications";
33
- user: "user";
34
32
  }>>;
35
33
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
36
34
  }, z.core.$strip>>;
@@ -40,11 +38,6 @@ declare const DefineAppInputSchema: z.ZodMiniObject<{
40
38
  surface: z.ZodMiniLiteral<"window">;
41
39
  }, z.core.$strip>, z.ZodMiniObject<{
42
40
  dock: z.ZodMiniOptional<z.ZodMiniObject<{
43
- group: z.ZodMiniOptional<z.ZodMiniEnum<{
44
- system: "system";
45
- applications: "applications";
46
- user: "user";
47
- }>>;
48
41
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
49
42
  }, z.core.$strip>>;
50
43
  title: z.ZodMiniString<string>;
@@ -179,4 +172,4 @@ declare function isWorkbenchConfig(app: unknown): app is WorkbenchConfig;
179
172
  */
180
173
  declare function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): WorkbenchConfig;
181
174
  export { WorkbenchApp as a, isWorkbenchApp as c, MediaLibraryField as i, isWorkbenchConfig as l, DefineAppResult as n, WorkbenchConfig as o, DefineMediaLibraryInput as r, defineApplication as s, DefineAppInput as t, unstable_defineMediaLibrary as u };
182
- //# sourceMappingURL=defineApp-4hImcIIe.d.ts.map
175
+ //# sourceMappingURL=defineApp-vbUu_rBA.d.ts.map
@@ -1,4 +1,4 @@
1
- import { l as SERVICE_CONTRACT_VERSION, u as ServiceType } from "./contract-D_HnLQtT.js";
1
+ import { l as SERVICE_CONTRACT_VERSION, u as ServiceType } from "./contract-C4Y6gi-b.js";
2
2
  import { EventTopic, MessageBus, MessageBusAbortOptions, MessageBusMessage, PayloadOf, ReplyOf, StateTopic, ValueOf } from "@sanity/sdk/dashboard";
3
3
  /**
4
4
  * The service's own declaration, surfaced to the callback.
@@ -93,4 +93,4 @@ interface DefinedService<TType extends ServiceType = ServiceType> {
93
93
  */
94
94
  declare function unstable_defineService<TType extends ServiceType>(type: TType, run: ServiceCallbacksByType[TType]): DefinedService<TType>;
95
95
  export { ServiceInfo as a, ServiceContext as i, ServiceBus as n, unstable_defineService as o, ServiceCallback as r, DefinedService as t };
96
- //# sourceMappingURL=defineService-DUaxVpWq.d.ts.map
96
+ //# sourceMappingURL=defineService-D_DFLM8x.d.ts.map
@@ -1,16 +1,8 @@
1
- import "./contract-D_HnLQtT.js";
2
- import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-DEttN7ks.js";
3
- import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-Co97VU2z.js";
1
+ import "./contract-C4Y6gi-b.js";
2
+ import { n as resolveWorkbenchConfig, t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-CgKD8AJ7.js";
3
+ import { a as DeployableWorkbenchApp, i as summarizeInterfaces, n as DeployedView, o as getWorkbench, r as DeployedWebWorker, t as DeployedInterface } from "./summarizeInterfaces-CeV5Umpj.js";
4
4
  import { AppVisibility, CliConfig, Output } from "@sanity/cli-core";
5
5
  import "node:zlib";
6
- /**
7
- * Throws unless `sourceDir` is a directory holding a federation build.
8
- * A workbench build always emits a module-federation remote, and may
9
- * additionally emit a standalone `index.html` SPA (workbench remotes). Either
10
- * way `mf-manifest.json` is the reliable marker that `sanity build` produced a
11
- * federation build, so that — not `index.html` — is what we check for.
12
- */
13
- declare function checkBuiltOutput(sourceDir: string): Promise<void>;
14
6
  /**
15
7
  * The org's active installation for an app type, or `undefined` when none is
16
8
  * installed. Read-only, so `--dry-run` can report deployability.
@@ -101,7 +93,7 @@ interface BrettWorkspace {
101
93
  }
102
94
  declare function getWorkbenchUrl(organizationId: string): string;
103
95
  /** Where a deployed application is served on its organization's workbench. */
104
- declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'type'>): string;
96
+ declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'>): string;
105
97
  declare function getApplication(applicationId: string): Promise<Application | null>;
106
98
  /** Every application in an organization, in one page (`limit=none`). */
107
99
  declare function listApplications(organizationId: string): Promise<Application[]>;
@@ -149,9 +141,8 @@ declare function createStudio(options: {
149
141
  * sync — so a caller can disarm a create-time rollback that must not delete an
150
142
  * application once it has an active deployment.
151
143
  *
152
- * The build's `mf-manifest.json` ships with every deployment. `isExternal`
153
- * skips the tarball: the customer serves the build from the application's
154
- * registered origin.
144
+ * `isExternal` skips the tarball: the customer serves the build from the
145
+ * application's registered origin.
155
146
  * @internal
156
147
  */
157
148
  declare function deployWorkbenchApp(options: {
@@ -163,6 +154,7 @@ declare function deployWorkbenchApp(options: {
163
154
  isAutoUpdating: boolean;
164
155
  isExternal?: boolean;
165
156
  label?: string;
157
+ mfManifest: Record<string, unknown>;
166
158
  onDeployed?: () => void;
167
159
  /**
168
160
  * The address from config. Only `createApplication` used to send it, so an
@@ -175,5 +167,5 @@ declare function deployWorkbenchApp(options: {
175
167
  visibility?: AppVisibility;
176
168
  workspaces?: readonly BrettWorkspace[];
177
169
  }): Promise<void>;
178
- export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, checkBuiltOutput, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, resolveWorkbenchConfig, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
170
+ export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, resolveWorkbenchConfig, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
179
171
  //# sourceMappingURL=deploy.d.ts.map
@@ -1,4 +1,3 @@
1
- export { checkBuiltOutput } from '../actions/deploy/checkBuiltOutput.js';
2
1
  export { deployConfig, resolveInstallationId, summarizeConfig } from '../actions/deploy/deployConfig.js';
3
2
  export { toWorkbenchPayload } from '../actions/deploy/deployPayload.js';
4
3
  export { createCoreApp, createStudio, deployWorkbenchApp } from '../actions/deploy/deployWorkbenchApp.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {checkBuiltOutput} from '../actions/deploy/checkBuiltOutput.js'\nexport {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {\n createCoreApp,\n type CreatedApplication,\n createStudio,\n deployWorkbenchApp,\n} from '../actions/deploy/deployWorkbenchApp.js'\nexport {getWorkbench} from '../actions/deploy/getWorkbench.js'\nexport {\n type DeployedInterface,\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../actions/deploy/summarizeInterfaces.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\n"],"names":["checkBuiltOutput","deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","summarizeInterfaces","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wCAAuC;AACtE,SACEC,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
1
+ {"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {\n createCoreApp,\n type CreatedApplication,\n createStudio,\n deployWorkbenchApp,\n} from '../actions/deploy/deployWorkbenchApp.js'\nexport {getWorkbench} from '../actions/deploy/getWorkbench.js'\nexport {\n type DeployedInterface,\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../actions/deploy/summarizeInterfaces.js'\nexport {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\n"],"names":["deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","summarizeInterfaces","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SACEA,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
@@ -1,4 +1,4 @@
1
- import { t as DevServerManifest } from "./registry-CIoKFIDw.js";
1
+ import { t as DevServerManifest } from "./registry-DCjjQ1sS.js";
2
2
  import { ViteDevServer } from "vite";
3
3
  import { CliConfig, Output } from "@sanity/cli-core";
4
4
  /**
@@ -1,6 +1,6 @@
1
- import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as ViewSurface, a as DefineWebWorkerInput, c as PanelView, d as TileSize, f as TileView, g as ViewDeclaration, h as ViewComponentBaseProps, i as DefineTileViewInput, m as ViewComponent, n as DefineAssetSourceViewInput, o as DefineWindowViewInput, p as VIEW_CONTRACT_VERSION, r as DefinePanelViewInput, s as DockGroup, t as AssetSourceView, u as ServiceType, v as WebWorker, w as defineWebWorker, x as defineAssetSourceView, y as WindowView } from "./contract-D_HnLQtT.js";
2
- import { a as ServiceInfo, i as ServiceContext, n as ServiceBus, o as unstable_defineService, r as ServiceCallback, t as DefinedService } from "./defineService-DUaxVpWq.js";
3
- import { a as WorkbenchApp, c as isWorkbenchApp, i as MediaLibraryField, l as isWorkbenchConfig, n as DefineAppResult, o as WorkbenchConfig, r as DefineMediaLibraryInput, s as defineApplication, t as DefineAppInput, u as unstable_defineMediaLibrary } from "./defineApp-4hImcIIe.js";
1
+ import { C as defineTileView, S as definePanelView, T as defineWindowView, _ as ViewSurface, a as DefineWebWorkerInput, c as PanelView, d as TileSize, f as TileView, g as ViewDeclaration, h as ViewComponentBaseProps, i as DefineTileViewInput, m as ViewComponent, n as DefineAssetSourceViewInput, o as DefineWindowViewInput, p as VIEW_CONTRACT_VERSION, r as DefinePanelViewInput, s as DockGroup, t as AssetSourceView, u as ServiceType, v as WebWorker, w as defineWebWorker, x as defineAssetSourceView, y as WindowView } from "./contract-C4Y6gi-b.js";
2
+ import { a as ServiceInfo, i as ServiceContext, n as ServiceBus, o as unstable_defineService, r as ServiceCallback, t as DefinedService } from "./defineService-D_DFLM8x.js";
3
+ import { a as WorkbenchApp, c as isWorkbenchApp, i as MediaLibraryField, l as isWorkbenchConfig, n as DefineAppResult, o as WorkbenchConfig, r as DefineMediaLibraryInput, s as defineApplication, t as DefineAppInput, u as unstable_defineMediaLibrary } from "./defineApp-vbUu_rBA.js";
4
4
  import { AssetSourceComponentProps } from "@sanity/types";
5
5
  /** @public */
6
6
  type WindowViewProps = ViewComponentBaseProps<{
@@ -1,4 +1,4 @@
1
- import { t as DevServerManifest } from "./registry-CIoKFIDw.js";
1
+ import { t as DevServerManifest } from "./registry-DCjjQ1sS.js";
2
2
  import { CliConfig, Output } from "@sanity/cli-core";
3
3
  interface StartWorkbenchPreviewOptions {
4
4
  /** Directory for the workbench Vite server's dependency cache. */
@@ -20,7 +20,6 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
20
20
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
21
21
  system: "system";
22
22
  applications: "applications";
23
- user: "user";
24
23
  }>>;
25
24
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
26
25
  }, z.core.$strip>;
@@ -38,7 +37,6 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
38
37
  group: z.ZodMiniOptional<z.ZodMiniEnum<{
39
38
  system: "system";
40
39
  applications: "applications";
41
- user: "user";
42
40
  }>>;
43
41
  order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
44
42
  }, z.core.$strip>;
@@ -129,4 +127,4 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
129
127
  */
130
128
  type DevServerManifest = z.infer<typeof devServerManifestSchema>;
131
129
  export { DevServerManifest as t };
132
- //# sourceMappingURL=registry-CIoKFIDw.d.ts.map
130
+ //# sourceMappingURL=registry-DCjjQ1sS.d.ts.map
@@ -1,5 +1,5 @@
1
- import { b as WorkbenchConfigValue } from "./contract-D_HnLQtT.js";
2
- import { t as DefineAppInput } from "./defineApp-4hImcIIe.js";
1
+ import { b as WorkbenchConfigValue } from "./contract-C4Y6gi-b.js";
2
+ import { t as DefineAppInput } from "./defineApp-vbUu_rBA.js";
3
3
  import { AppVisibility, CliConfig } from "@sanity/cli-core";
4
4
  /**
5
5
  * Bundled so adding a declaration family touches this type and the artifact
@@ -65,4 +65,4 @@ interface ResolvedMediaLibraryConfig {
65
65
  */
66
66
  declare function resolveWorkbenchConfig(cliConfig: CliConfig | null | undefined): ResolvedMediaLibraryConfig | null;
67
67
  export { resolveAppEntry as a, WorkbenchExposes as i, resolveWorkbenchConfig as n, resolveWorkbenchApp as o, ResolvedWorkbenchApp as r, ResolvedMediaLibraryConfig as t };
68
- //# sourceMappingURL=resolveWorkbenchConfig-DEttN7ks.d.ts.map
68
+ //# sourceMappingURL=resolveWorkbenchConfig-CgKD8AJ7.d.ts.map
@@ -1,5 +1,5 @@
1
- import { _ as ViewSurface, u as ServiceType } from "./contract-D_HnLQtT.js";
2
- import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-DEttN7ks.js";
1
+ import { _ as ViewSurface, u as ServiceType } from "./contract-C4Y6gi-b.js";
2
+ import { i as WorkbenchExposes, r as ResolvedWorkbenchApp } from "./resolveWorkbenchConfig-CgKD8AJ7.js";
3
3
  import { z } from "zod/mini";
4
4
  import { CliConfig } from "@sanity/cli-core";
5
5
  /**
@@ -62,4 +62,4 @@ declare function summarizeInterfaces({ views, webWorkers }: WorkbenchExposes): {
62
62
  views: DeployedView[];
63
63
  };
64
64
  export { DeployableWorkbenchApp as a, summarizeInterfaces as i, DeployedView as n, getWorkbench as o, DeployedWebWorker as r, DeployedInterface as t };
65
- //# sourceMappingURL=summarizeInterfaces-Co97VU2z.d.ts.map
65
+ //# sourceMappingURL=summarizeInterfaces-CeV5Umpj.d.ts.map
@@ -1,5 +1,5 @@
1
- import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-DEttN7ks.js";
2
- import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-Co97VU2z.js";
1
+ import { t as ResolvedMediaLibraryConfig } from "./resolveWorkbenchConfig-CgKD8AJ7.js";
2
+ import { a as DeployableWorkbenchApp, n as DeployedView, r as DeployedWebWorker } from "./summarizeInterfaces-CeV5Umpj.js";
3
3
  import "node:zlib";
4
4
  import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
5
5
  interface ConfigSnapshot {
@@ -11,12 +11,10 @@ import { join } from 'node:path';
11
11
  return error;
12
12
  }
13
13
  /**
14
- * Throws unless `sourceDir` is a directory holding a federation build.
15
- * A workbench build always emits a module-federation remote, and may
16
- * additionally emit a standalone `index.html` SPA (workbench remotes). Either
17
- * way `mf-manifest.json` is the reliable marker that `sanity build` produced a
18
- * federation build, so that — not `index.html` — is what we check for.
19
- */ export async function checkBuiltOutput(sourceDir) {
14
+ * Resolves to the parsed federation manifest in `sourceDir`. A workbench build
15
+ * may also emit a standalone `index.html`, so the manifest, not `index.html`,
16
+ * is the marker that `sanity build` produced a federation build.
17
+ */ export async function readBuiltManifest(sourceDir) {
20
18
  try {
21
19
  const stats = await stat(sourceDir);
22
20
  if (!stats.isDirectory()) {
@@ -32,17 +30,22 @@ import { join } from 'node:path';
32
30
  manifest = await readFile(manifestPath, 'utf8');
33
31
  } catch (err) {
34
32
  if (err.code === 'ENOENT') {
35
- throw buildNotFound(`"${manifestPath}" does not exist. ` + 'The deploy directory must contain a federation build created with "sanity build".');
33
+ throw buildNotFound(`"${manifestPath}" does not exist; a federation build created with "sanity build" writes it.`);
36
34
  }
37
35
  throw err;
38
36
  }
39
37
  // Every deploy sends this file to the API, so a corrupt one must fail here
40
38
  // rather than after the application is created.
39
+ let parsed;
41
40
  try {
42
- JSON.parse(manifest);
41
+ parsed = JSON.parse(manifest);
43
42
  } catch {
44
43
  throw new Error(`"${manifestPath}" is not valid JSON. Run "sanity build" again to regenerate it.`);
45
44
  }
45
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
46
+ throw new Error(`"${manifestPath}" is not a JSON object. Run "sanity build" again to regenerate it.`);
47
+ }
48
+ return parsed;
46
49
  }
47
50
 
48
- //# sourceMappingURL=checkBuiltOutput.js.map
51
+ //# sourceMappingURL=readBuiltManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/build/readBuiltManifest.ts"],"sourcesContent":["import {readFile, stat} from 'node:fs/promises'\nimport {join} from 'node:path'\n\n/**\n * A genuinely-missing-build error, named so callers can offer the \"run sanity\n * build\" hint (the `preview` command keys off this name, matching how the studio\n * path keys off a missing `index.html`). Only the missing cases get it — real\n * I/O failures keep their own name so they surface as themselves.\n */\nfunction buildNotFound(message: string): Error {\n const error = new Error(message)\n error.name = 'BUILD_NOT_FOUND'\n return error\n}\n\n/**\n * Resolves to the parsed federation manifest in `sourceDir`. A workbench build\n * may also emit a standalone `index.html`, so the manifest, not `index.html`,\n * is the marker that `sanity build` produced a federation build.\n */\nexport async function readBuiltManifest(sourceDir: string): Promise<Record<string, unknown>> {\n try {\n const stats = await stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`\"${sourceDir}\" is not a directory`)\n }\n } catch (err) {\n if (err.code === 'ENOENT') throw buildNotFound(`Directory \"${sourceDir}\" does not exist`)\n throw err\n }\n\n const manifestPath = join(sourceDir, 'mf-manifest.json')\n let manifest: string\n try {\n manifest = await readFile(manifestPath, 'utf8')\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw buildNotFound(\n `\"${manifestPath}\" does not exist; a federation build created with \"sanity build\" writes it.`,\n )\n }\n throw err\n }\n\n // Every deploy sends this file to the API, so a corrupt one must fail here\n // rather than after the application is created.\n let parsed: unknown\n try {\n parsed = JSON.parse(manifest)\n } catch {\n throw new Error(\n `\"${manifestPath}\" is not valid JSON. Run \"sanity build\" again to regenerate it.`,\n )\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error(\n `\"${manifestPath}\" is not a JSON object. Run \"sanity build\" again to regenerate it.`,\n )\n }\n return parsed as Record<string, unknown>\n}\n"],"names":["readFile","stat","join","buildNotFound","message","error","Error","name","readBuiltManifest","sourceDir","stats","isDirectory","err","code","manifestPath","manifest","parsed","JSON","parse","Array","isArray"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,IAAI,QAAO,mBAAkB;AAC/C,SAAQC,IAAI,QAAO,YAAW;AAE9B;;;;;CAKC,GACD,SAASC,cAAcC,OAAe;IACpC,MAAMC,QAAQ,IAAIC,MAAMF;IACxBC,MAAME,IAAI,GAAG;IACb,OAAOF;AACT;AAEA;;;;CAIC,GACD,OAAO,eAAeG,kBAAkBC,SAAiB;IACvD,IAAI;QACF,MAAMC,QAAQ,MAAMT,KAAKQ;QACzB,IAAI,CAACC,MAAMC,WAAW,IAAI;YACxB,MAAM,IAAIL,MAAM,CAAC,CAAC,EAAEG,UAAU,oBAAoB,CAAC;QACrD;IACF,EAAE,OAAOG,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU,MAAMV,cAAc,CAAC,WAAW,EAAEM,UAAU,gBAAgB,CAAC;QACxF,MAAMG;IACR;IAEA,MAAME,eAAeZ,KAAKO,WAAW;IACrC,IAAIM;IACJ,IAAI;QACFA,WAAW,MAAMf,SAASc,cAAc;IAC1C,EAAE,OAAOF,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;YACzB,MAAMV,cACJ,CAAC,CAAC,EAAEW,aAAa,2EAA2E,CAAC;QAEjG;QACA,MAAMF;IACR;IAEA,2EAA2E;IAC3E,gDAAgD;IAChD,IAAII;IACJ,IAAI;QACFA,SAASC,KAAKC,KAAK,CAACH;IACtB,EAAE,OAAM;QACN,MAAM,IAAIT,MACR,CAAC,CAAC,EAAEQ,aAAa,+DAA+D,CAAC;IAErF;IACA,IAAI,OAAOE,WAAW,YAAYA,WAAW,QAAQG,MAAMC,OAAO,CAACJ,SAAS;QAC1E,MAAM,IAAIV,MACR,CAAC,CAAC,EAAEQ,aAAa,kEAAkE,CAAC;IAExF;IACA,OAAOE;AACT"}
@@ -1,5 +1,4 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { basename, dirname, join } from 'node:path';
1
+ import { basename, dirname } from 'node:path';
3
2
  import { createGzip } from 'node:zlib';
4
3
  import { getErrorMessage } from '@sanity/cli-core/errors';
5
4
  import { spinner } from '@sanity/cli-core/ux';
@@ -102,13 +101,11 @@ function toBrettInterface(iface, version) {
102
101
  * sync — so a caller can disarm a create-time rollback that must not delete an
103
102
  * application once it has an active deployment.
104
103
  *
105
- * The build's `mf-manifest.json` ships with every deployment. `isExternal`
106
- * skips the tarball: the customer serves the build from the application's
107
- * registered origin.
104
+ * `isExternal` skips the tarball: the customer serves the build from the
105
+ * application's registered origin.
108
106
  * @internal
109
107
  */ export async function deployWorkbenchApp(options) {
110
- const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
111
- const mfManifest = JSON.parse(await readFile(join(sourceDir, 'mf-manifest.json'), 'utf8'));
108
+ const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', mfManifest, onDeployed, slug, sourceDir, title, version, visibility, workspaces } = options;
112
109
  const tarball = isExternal ? undefined : createTar({
113
110
  cwd: dirname(sourceDir)
114
111
  }, [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployWorkbenchApp.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {basename, dirname, join} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n updateApplication,\n} from '../../services/applications.js'\n\n/**\n * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.\n * @internal\n */\nexport interface CreatedApplication {\n application: Application\n rollback: () => Promise<void>\n}\n\nfunction toBrettInterface(iface: DerivedInterface, version: string): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return {...declaration, version}\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app', version}\n }\n }\n}\n\n/**\n * Create a coreApp record (no deployment), so the CLI can build with its id\n * before shipping the first deployment. First deploy only.\n * @internal\n */\nexport async function createCoreApp(options: {\n isSingleton?: boolean\n name?: string\n organizationId: string\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating application...').start()\n try {\n const application = await createApplication({...options, type: 'coreApp'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Create a studio record (no deployment).\n * @internal\n */\nexport async function createStudio(options: {\n externalUrl?: string\n name?: string\n organizationId: string\n projectId: string | undefined\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating studio...').start()\n try {\n const application = await createApplication({...options, type: 'studio'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Ship a deployment to an already-created (or `deployment.appId`) application,\n * then sync its mutable metadata (`title`, and `icon`/`slug`/`visibility` when\n * set) from config. The deploy endpoint ignores these, so a redeploy patches\n * them here alongside the new deployment.\n *\n * `onDeployed` fires the instant the deployment is live, before the metadata\n * sync — so a caller can disarm a create-time rollback that must not delete an\n * application once it has an active deployment.\n *\n * The build's `mf-manifest.json` ships with every deployment. `isExternal`\n * skips the tarball: the customer serves the build from the application's\n * registered origin.\n * @internal\n */\nexport async function deployWorkbenchApp(options: {\n access?: readonly BrettAccess[]\n app: CliConfig['app']\n applicationId: string\n icon?: string\n isApp: boolean\n isAutoUpdating: boolean\n isExternal?: boolean\n label?: string\n onDeployed?: () => void\n /**\n * The address from config. Only `createApplication` used to send it, so an\n * app with a `deployment.appId` kept whatever slug it was created at.\n */\n slug?: string\n sourceDir: string\n title: string\n version: string\n visibility?: AppVisibility\n workspaces?: readonly BrettWorkspace[]\n}): Promise<void> {\n const {\n access,\n app,\n applicationId,\n icon,\n isApp,\n isAutoUpdating,\n isExternal = false,\n label = 'Deploying...',\n onDeployed,\n slug,\n sourceDir,\n title,\n version,\n visibility,\n workspaces,\n } = options\n const mfManifest = JSON.parse(await readFile(join(sourceDir, 'mf-manifest.json'), 'utf8'))\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner(label).start()\n try {\n await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: deriveInterfaces(app, {appTitle: title, isApp}).map((iface) =>\n toBrettInterface(iface, version),\n ),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(icon ? {icon} : {}),\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n spin.succeed()\n } catch (error) {\n spin.clear()\n throw error\n }\n}\n\n/**\n * The slug is the one synced field the server validates — it must be free\n * within the organization, and a singleton app only accepts its reserved\n * identifiers — so a 4xx on the metadata patch is a rejected rename. Name the\n * slug and the server's reason; anything else propagates untouched.\n */\nfunction toSlugRejection(error: unknown, slug: string | undefined): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (!slug || statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `Slug \"${slug}\" was rejected: ${getErrorMessage(error)}. The deployment is live at the application's previous slug — change \\`app.slug\\` in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["readFile","basename","dirname","join","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","createApplication","createDeployment","deleteApplication","updateApplication","toBrettInterface","iface","version","id","_id","src","_src","declaration","surface","view","type","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","icon","isApp","isAutoUpdating","isExternal","label","onDeployed","slug","sourceDir","title","visibility","workspaces","mfManifest","JSON","parse","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAO,YAAW;AACjD,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB,EAAEC,OAAe;IAChE,MAAM,EAACC,IAAIC,GAAG,EAAEC,KAAKC,IAAI,EAAE,GAAGC,aAAY,GAAGN;IAC7C,IAAI,UAAUM,aAAa,OAAO;QAAC,GAAGA,WAAW;QAAEL;IAAO;IAE1D,OAAQK,YAAYC,OAAO;QACzB,KAAK;YAAgB;gBACnB,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;oBAASN;gBAAO;YACzC;QACA,KAAK;YAAS;gBAC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AAC,EAC5K;QAACgC,OAAOhC;IAAK;AAEjB"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployWorkbenchApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n updateApplication,\n} from '../../services/applications.js'\n\n/**\n * `rollback` undoes the creation, so a later failure leaves no record stranded at the slug.\n * @internal\n */\nexport interface CreatedApplication {\n application: Application\n rollback: () => Promise<void>\n}\n\nfunction toBrettInterface(iface: DerivedInterface, version: string): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return {...declaration, version}\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'panel': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface, version}\n }\n case 'window': {\n const {surface, ...view} = declaration\n return {...view, type: 'app', version}\n }\n }\n}\n\n/**\n * Create a coreApp record (no deployment), so the CLI can build with its id\n * before shipping the first deployment. First deploy only.\n * @internal\n */\nexport async function createCoreApp(options: {\n isSingleton?: boolean\n name?: string\n organizationId: string\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating application...').start()\n try {\n const application = await createApplication({...options, type: 'coreApp'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Create a studio record (no deployment).\n * @internal\n */\nexport async function createStudio(options: {\n externalUrl?: string\n name?: string\n organizationId: string\n projectId: string | undefined\n slug: string\n title: string\n visibility?: AppVisibility\n}): Promise<CreatedApplication> {\n const spin = spinner('Creating studio...').start()\n try {\n const application = await createApplication({...options, type: 'studio'})\n spin.succeed()\n return {application, rollback: () => deleteApplication(application.id)}\n } catch (error) {\n spin.fail()\n throw error\n }\n}\n\n/**\n * Ship a deployment to an already-created (or `deployment.appId`) application,\n * then sync its mutable metadata (`title`, and `icon`/`slug`/`visibility` when\n * set) from config. The deploy endpoint ignores these, so a redeploy patches\n * them here alongside the new deployment.\n *\n * `onDeployed` fires the instant the deployment is live, before the metadata\n * sync — so a caller can disarm a create-time rollback that must not delete an\n * application once it has an active deployment.\n *\n * `isExternal` skips the tarball: the customer serves the build from the\n * application's registered origin.\n * @internal\n */\nexport async function deployWorkbenchApp(options: {\n access?: readonly BrettAccess[]\n app: CliConfig['app']\n applicationId: string\n icon?: string\n isApp: boolean\n isAutoUpdating: boolean\n isExternal?: boolean\n label?: string\n mfManifest: Record<string, unknown>\n onDeployed?: () => void\n /**\n * The address from config. Only `createApplication` used to send it, so an\n * app with a `deployment.appId` kept whatever slug it was created at.\n */\n slug?: string\n sourceDir: string\n title: string\n version: string\n visibility?: AppVisibility\n workspaces?: readonly BrettWorkspace[]\n}): Promise<void> {\n const {\n access,\n app,\n applicationId,\n icon,\n isApp,\n isAutoUpdating,\n isExternal = false,\n label = 'Deploying...',\n mfManifest,\n onDeployed,\n slug,\n sourceDir,\n title,\n version,\n visibility,\n workspaces,\n } = options\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner(label).start()\n try {\n await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: deriveInterfaces(app, {appTitle: title, isApp}).map((iface) =>\n toBrettInterface(iface, version),\n ),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(icon ? {icon} : {}),\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n spin.succeed()\n } catch (error) {\n spin.clear()\n throw error\n }\n}\n\n/**\n * The slug is the one synced field the server validates — it must be free\n * within the organization, and a singleton app only accepts its reserved\n * identifiers — so a 4xx on the metadata patch is a rejected rename. Name the\n * slug and the server's reason; anything else propagates untouched.\n */\nfunction toSlugRejection(error: unknown, slug: string | undefined): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (!slug || statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `Slug \"${slug}\" was rejected: ${getErrorMessage(error)}. The deployment is live at the application's previous slug — change \\`app.slug\\` in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["basename","dirname","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","createApplication","createDeployment","deleteApplication","updateApplication","toBrettInterface","iface","version","id","_id","src","_src","declaration","surface","view","type","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","icon","isApp","isAutoUpdating","isExternal","label","mfManifest","onDeployed","slug","sourceDir","title","visibility","workspaces","tarball","undefined","cwd","pipe","interfaces","appTitle","map","toSlugRejection","clear","statusCode","Error","cause"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB,EAAEC,OAAe;IAChE,MAAM,EAACC,IAAIC,GAAG,EAAEC,KAAKC,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AAc,EAAEc,IAAwB;IAC/D,MAAMc,aAAc5B,OAAiC4B;IACrD,IAAI,CAACd,QAAQc,eAAeR,aAAaQ,aAAa,OAAOA,cAAc,KAAK,OAAO5B;IACvF,OAAO,IAAI6B,MACT,CAAC,MAAM,EAAEf,KAAK,gBAAgB,EAAEzC,gBAAgB2B,OAAO,oHAAoH,CAAC,EAC5K;QAAC8B,OAAO9B;IAAK;AAEjB"}
@@ -15,9 +15,9 @@ import { getProcessStartTime, isOurProcess } from './processLiveness.js';
15
15
  * plus its inlined manifest and interfaces. The workbench reads these to
16
16
  * discover and render local apps. Written by `registerDevServer`, watched by
17
17
  * `watchRegistry`.
18
- * - `workbench.lock` — a single machine-wide lock, so only one workbench shell
19
- * runs at a time and later `dev`s register into it instead of starting their
20
- * own. Managed by `acquireWorkbenchLock` / `readWorkbenchLock`.
18
+ * - `workbench-<organizationId>.lock` — one lock per organization, so only one
19
+ * workbench shell per org runs at a time and later `dev`s register into it
20
+ * instead of starting their own. Managed by `acquireWorkbenchLock` / `readWorkbenchLock`.
21
21
  *
22
22
  * Both files belong to the process that created them and must not outlive it.
23
23
  * Three things keep that true: an explicit `release()` on clean shutdown, an
@@ -299,7 +299,7 @@ function runExitCleanups() {
299
299
  }
300
300
  };
301
301
  }
302
- // The workbench singleton lock — "one workbench per machine". Lives in the same
302
+ // The workbench singleton lock — "one workbench per organization". Lives in the same
303
303
  // registry dir and shares the liveness/prune model: a stale lock left by a
304
304
  // crashed process is pruned on read so the next acquire isn't blocked forever.
305
305
  const workbenchLockSchema = z.object({
@@ -313,8 +313,8 @@ const workbenchLockSchema = z.object({
313
313
  /**
314
314
  * Read the workbench lock file and return its contents if the holding
315
315
  * process is still alive. Prunes stale locks from crashed processes.
316
- */ export function readWorkbenchLock() {
317
- const file = readLockFile();
316
+ */ export function readWorkbenchLock(organizationId) {
317
+ const file = readLockFile(organizationId);
318
318
  // File doesn't exist — nothing to prune, nothing to return
319
319
  if (!file) return undefined;
320
320
  // Past this point the file exists. Anything that isn't a live, valid lock
@@ -327,7 +327,7 @@ const workbenchLockSchema = z.object({
327
327
  devDebug('Workbench process is alive at pid %d on port %d', data.pid, data.port);
328
328
  return data;
329
329
  }
330
- pruneWorkbenchLock(getLockPath());
330
+ pruneWorkbenchLock(getLockPath(organizationId));
331
331
  return undefined;
332
332
  }
333
333
  const LOCK_READY_TIMEOUT_MS = 10_000;
@@ -335,30 +335,30 @@ const LOCK_READY_POLL_MS = 50;
335
335
  /**
336
336
  * Read the workbench lock once its holder's shell is listening, so the port is
337
337
  * the bound one. Returns the lock as-is after {@link LOCK_READY_TIMEOUT_MS}.
338
- */ export async function waitForWorkbenchLock() {
338
+ */ export async function waitForWorkbenchLock(organizationId) {
339
339
  const deadline = Date.now() + LOCK_READY_TIMEOUT_MS;
340
- let lock = readWorkbenchLock();
340
+ let lock = readWorkbenchLock(organizationId);
341
341
  // Read the raw file here: `readWorkbenchLock` spawns `ps`/PowerShell per call
342
342
  // and deletes a lock it catches half-written by `updatePort`.
343
343
  while(lock?.ready === false && Date.now() < deadline){
344
344
  await new Promise((resolve)=>setTimeout(resolve, LOCK_READY_POLL_MS));
345
- const file = readLockFile();
345
+ const file = readLockFile(organizationId);
346
346
  if (!file) break;
347
347
  lock = file.data ?? lock;
348
348
  }
349
349
  if (lock?.ready === false && Date.now() >= deadline) {
350
350
  devDebug('Workbench lock not ready after %d ms, using port %d', LOCK_READY_TIMEOUT_MS, lock.port);
351
351
  }
352
- return readWorkbenchLock();
352
+ return readWorkbenchLock(organizationId);
353
353
  }
354
- const getLockPath = ()=>join(getRegistryDir(), 'workbench.lock');
354
+ const getLockPath = (organizationId)=>join(getRegistryDir(), `workbench-${organizationId}.lock`);
355
355
  /**
356
356
  * Read the lock file with no liveness check and no pruning. `undefined` when
357
357
  * there is no file; `data` is `undefined` when its contents don't parse.
358
- */ function readLockFile() {
358
+ */ function readLockFile(organizationId) {
359
359
  let contents;
360
360
  try {
361
- contents = readFileSync(getLockPath(), 'utf8');
361
+ contents = readFileSync(getLockPath(organizationId), 'utf8');
362
362
  } catch {
363
363
  return undefined;
364
364
  }
@@ -400,7 +400,7 @@ function pruneWorkbenchLock(lockPath) {
400
400
  mkdirSync(registryDir, {
401
401
  recursive: true
402
402
  });
403
- const lockPath = getLockPath();
403
+ const lockPath = getLockPath(info.organizationId);
404
404
  const startedAt = ownStartedAt();
405
405
  const lockData = {
406
406
  host: info.host,
@@ -421,7 +421,7 @@ function pruneWorkbenchLock(lockPath) {
421
421
  // it after our own release must not be clobbered.
422
422
  const detachExitCleanup = unlinkOnProcessExit(lockPath, ()=>{
423
423
  if (released) return false;
424
- const disk = readLockFile()?.data;
424
+ const disk = readLockFile(info.organizationId)?.data;
425
425
  return disk?.pid === process.pid && disk.startedAt === startedAt;
426
426
  });
427
427
  return {
@@ -446,7 +446,7 @@ function pruneWorkbenchLock(lockPath) {
446
446
  devDebug('Failed to acquire workbench lock: %s', err instanceof Error ? err.message : String(err));
447
447
  if (!isNodeError(err) || err.code !== 'EEXIST') return undefined;
448
448
  // Lock exists — check if the holder is still alive
449
- const existing = readWorkbenchLock();
449
+ const existing = readWorkbenchLock(info.organizationId);
450
450
  if (existing) return undefined;
451
451
  // Stale lock was pruned by readWorkbenchLock — retry (with guard against infinite recursion)
452
452
  if (retries <= 0) return undefined;