@sanity/workbench-cli 2.22.0 → 2.22.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,6 +1,6 @@
1
- import { _ as DASHBOARD_CONFIG_CONTRACT_VERSION } from "./defineApp-DUi9ZfpT.js";
2
- import { i as resolveWorkbenchApp, n as WorkbenchExposes, r as resolveAppEntry, t as ResolvedWorkbenchApp } from "./resolveWorkbenchApp-C_rqQBQP.js";
3
- import { t as resolveWorkbenchConfig } from "./resolveWorkbenchConfig-C_o8npN0.js";
1
+ import { _ as DASHBOARD_CONFIG_CONTRACT_VERSION, w as MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION } from "./defineApp-zjy9NZQF.js";
2
+ import { i as resolveWorkbenchApp, n as WorkbenchExposes, r as resolveAppEntry, t as ResolvedWorkbenchApp } from "./resolveWorkbenchApp-Cqyc0Rgf.js";
3
+ import { t as resolveWorkbenchConfig } from "./resolveWorkbenchConfig-DVIYlkMD.js";
4
4
  import { CliConfig } from "@sanity/cli-core";
5
5
  import { InlineConfig, PluginOption } from "vite";
6
6
  /** Starts the organization and deployment lookup beside a `sanity build`; `undefined` outside the Dashboard. */
@@ -136,5 +136,5 @@ declare function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<Pl
136
136
  * its own id from the applications API.
137
137
  */
138
138
  declare function buildAppId(app: ResolvedWorkbenchApp): Promise<string>;
139
- export { DASHBOARD_CONFIG_CONTRACT_VERSION, RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, type WorkbenchExposes, buildAppId, buildFederatedApp, readBuiltManifest, resolveAppEntry, resolveWorkbenchApp, resolveWorkbenchConfig, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup, startBuildSummary, workbenchOptimizeDeps, workbenchVitePlugins };
139
+ export { DASHBOARD_CONFIG_CONTRACT_VERSION, MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION, RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, type WorkbenchExposes, buildAppId, buildFederatedApp, readBuiltManifest, resolveAppEntry, resolveWorkbenchApp, resolveWorkbenchConfig, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup, startBuildSummary, workbenchOptimizeDeps, workbenchVitePlugins };
140
140
  //# sourceMappingURL=build.d.ts.map
@@ -10,7 +10,7 @@ export { buildFederatedApp } from '../actions/build/vite/discover-shared-depende
10
10
  export { workbenchOptimizeDeps } from '../actions/build/vite/optimize-deps.js';
11
11
  export { workbenchVitePlugins } from '../actions/build/vite/workbench-vite-plugins.js';
12
12
  export { buildAppId } from '../appId.js';
13
- export { DASHBOARD_CONFIG_CONTRACT_VERSION } from '../contract.js';
13
+ export { DASHBOARD_CONFIG_CONTRACT_VERSION, MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION } from '../contract.js';
14
14
  export { resolveAppEntry, resolveWorkbenchApp } from '../resolveWorkbenchApp.js';
15
15
  export { resolveWorkbenchConfig } from '../resolveWorkbenchConfig.js';
16
16
 
@@ -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 {startBuildSummary} from '../actions/build/buildSummary.js'\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 {DASHBOARD_CONFIG_CONTRACT_VERSION} from '../contract.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["startBuildSummary","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","DASHBOARD_CONFIG_CONTRACT_VERSION","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SAAQA,iBAAiB,QAAO,mCAAkC;AAClE,SAAQC,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,SAAQC,iCAAiC,QAAO,iBAAgB;AAChE,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,SAAQC,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 {startBuildSummary} from '../actions/build/buildSummary.js'\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 DASHBOARD_CONFIG_CONTRACT_VERSION,\n MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION,\n} from '../contract.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["startBuildSummary","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","DASHBOARD_CONFIG_CONTRACT_VERSION","MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SAAQA,iBAAiB,QAAO,mCAAkC;AAClE,SAAQC,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,iCAAiC,EACjCC,qCAAqC,QAChC,iBAAgB;AACvB,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,SAAQC,sBAAsB,QAAO,+BAA8B"}
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod/mini";
2
2
  /** @internal */
3
3
  declare const WEB_WORKER_CONTRACT_VERSION = 1;
4
+ declare const MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION = 1;
4
5
  declare const DASHBOARD_CONFIG_CONTRACT_VERSION = 1;
5
6
  /**
6
7
  * A view component. The return is opaque so the runtime helpers carry no React
@@ -373,5 +374,5 @@ declare function isWorkbenchConfig(app: unknown): app is WorkbenchConfig;
373
374
  */
374
375
  declare function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): MediaLibraryConfig;
375
376
  declare function defineDashboard(input: DefineDashboardInput): DashboardConfig;
376
- export { ViewDeclaration as A, defineWebWorker as B, DockGroup as C, TileViewDeclaration as D, TileSize as E, WindowViewDeclaration as F, WorkbenchConfigValue as I, defineAssetSourceView as L, WEB_WORKER_CONTRACT_VERSION as M, WebWorkerDeclaration as N, ViewComponent as O, WebWorkerType as P, definePanelView as R, DefineWindowViewInput as S, ServiceType as T, defineWindowView as V, DASHBOARD_CONFIG_CONTRACT_VERSION as _, DefineMediaLibraryInput as a, DefineTileViewInput as b, WorkbenchApp as c, defineDashboard as d, isWorkbenchApp as f, AssetSourceViewDeclaration as g, unstable_defineMediaLibrary as h, DefineDashboardInput as i, ViewSurface as j, ViewComponentBaseProps as k, WorkbenchConfig as l, resolveAppTitle as m, DefineAppInput as n, MediaLibraryConfig as o, isWorkbenchConfig as p, DefineAppResult as r, MediaLibraryField as s, DashboardConfig as t, defineApplication as u, DefineAssetSourceViewInput as v, PanelViewDeclaration as w, DefineWebWorkerInput as x, DefinePanelViewInput as y, defineTileView as z };
377
- //# sourceMappingURL=defineApp-DUi9ZfpT.d.ts.map
377
+ export { ViewComponentBaseProps as A, defineTileView as B, DockGroup as C, TileSize as D, ServiceType as E, WebWorkerType as F, defineWindowView as H, WindowViewDeclaration as I, WorkbenchConfigValue as L, ViewSurface as M, WEB_WORKER_CONTRACT_VERSION as N, TileViewDeclaration as O, WebWorkerDeclaration as P, defineAssetSourceView as R, DefineWindowViewInput as S, PanelViewDeclaration as T, defineWebWorker as V, DASHBOARD_CONFIG_CONTRACT_VERSION as _, DefineMediaLibraryInput as a, DefineTileViewInput as b, WorkbenchApp as c, defineDashboard as d, isWorkbenchApp as f, AssetSourceViewDeclaration as g, unstable_defineMediaLibrary as h, DefineDashboardInput as i, ViewDeclaration as j, ViewComponent as k, WorkbenchConfig as l, resolveAppTitle as m, DefineAppInput as n, MediaLibraryConfig as o, isWorkbenchConfig as p, DefineAppResult as r, MediaLibraryField as s, DashboardConfig as t, defineApplication as u, DefineAssetSourceViewInput as v, MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION as w, DefineWebWorkerInput as x, DefinePanelViewInput as y, definePanelView as z };
378
+ //# sourceMappingURL=defineApp-zjy9NZQF.d.ts.map
@@ -1,9 +1,9 @@
1
- import { I as WorkbenchConfigValue } from "./defineApp-DUi9ZfpT.js";
2
- import { t as resolveWorkbenchConfig } from "./resolveWorkbenchConfig-C_o8npN0.js";
3
- import { a as DeployedInterface, c as summarizeInterfaces, l as DeployableWorkbenchApp, n as fetchOrganizationSummary, o as DeployedView, r as formatDeploySummary, s as DeployedWebWorker, t as fetchDeploySummaryDetails, u as getWorkbench } from "./deploySummary-BPgEW1qt.js";
1
+ import { L as WorkbenchConfigValue } from "./defineApp-zjy9NZQF.js";
2
+ import { t as resolveWorkbenchConfig } from "./resolveWorkbenchConfig-DVIYlkMD.js";
3
+ import { a as DeployedInterface, c as summarizeInterfaces, l as DeployableWorkbenchApp, n as fetchOrganizationSummary, o as DeployedView, r as formatDeploySummary, s as DeployedWebWorker, t as fetchDeploySummaryDetails, u as getWorkbench } from "./deploySummary-D43W05vj.js";
4
4
  import { AppVisibility, CliConfig } from "@sanity/cli-core";
5
5
  import { ImageFile } from "@sanity/cli-core/images";
6
- import "node:zlib";
6
+ import "node:stream";
7
7
  import { ApplicationBase } from "@sanity/sdk";
8
8
  /**
9
9
  * The org's active installation for an app type, or `undefined` when none is
@@ -27,10 +27,9 @@ declare function summarizeConfig(config: WorkbenchConfigValue): string;
27
27
  * @internal
28
28
  */
29
29
  declare function deployConfig(options: {
30
- appType: string;
30
+ appType: WorkbenchConfigValue['appType'];
31
31
  installationId: string;
32
32
  sourceDir: string;
33
- version: string;
34
33
  }): Promise<void>;
35
34
  /** What a workbench app contributes to a deploy payload. */
36
35
  interface WorkbenchDeployPayload {
@@ -1,5 +1,5 @@
1
- import { P as WebWorkerType, j as ViewSurface } from "./defineApp-DUi9ZfpT.js";
2
- import { n as WorkbenchExposes, t as ResolvedWorkbenchApp } from "./resolveWorkbenchApp-C_rqQBQP.js";
1
+ import { F as WebWorkerType, M as ViewSurface } from "./defineApp-zjy9NZQF.js";
2
+ import { n as WorkbenchExposes, t as ResolvedWorkbenchApp } from "./resolveWorkbenchApp-Cqyc0Rgf.js";
3
3
  import { CliConfig } from "@sanity/cli-core";
4
4
  import { z } from "zod/mini";
5
5
  /**
@@ -105,4 +105,4 @@ declare function formatUndeploySummary(options: {
105
105
  userName?: string | null;
106
106
  }): string;
107
107
  export { DeployedInterface as a, summarizeInterfaces as c, formatUndeploySummary as i, DeployableWorkbenchApp as l, fetchOrganizationSummary as n, DeployedView as o, formatDeploySummary as r, DeployedWebWorker as s, fetchDeploySummaryDetails as t, getWorkbench as u };
108
- //# sourceMappingURL=deploySummary-BPgEW1qt.d.ts.map
108
+ //# sourceMappingURL=deploySummary-D43W05vj.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as DevServerManifest } from "./registry-DysyB1F6.js";
1
+ import { t as DevServerManifest } from "./registry-NsrUoJAF.js";
2
2
  import { CliConfig, Output } from "@sanity/cli-core";
3
3
  import { ViteDevServer } from "vite";
4
4
  /**
@@ -1,19 +1,15 @@
1
- import { A as ViewDeclaration, B as defineWebWorker, C as DockGroup, D as TileViewDeclaration, E as TileSize, F as WindowViewDeclaration, L as defineAssetSourceView, M as WEB_WORKER_CONTRACT_VERSION, N as WebWorkerDeclaration, O as ViewComponent, P as WebWorkerType, R as definePanelView, S as DefineWindowViewInput, T as ServiceType, V as defineWindowView, a as DefineMediaLibraryInput, b as DefineTileViewInput, c as WorkbenchApp, d as defineDashboard, f as isWorkbenchApp, g as AssetSourceViewDeclaration, h as unstable_defineMediaLibrary, i as DefineDashboardInput, j as ViewSurface, k as ViewComponentBaseProps, l as WorkbenchConfig, m as resolveAppTitle, n as DefineAppInput, o as MediaLibraryConfig, p as isWorkbenchConfig, r as DefineAppResult, s as MediaLibraryField, t as DashboardConfig, u as defineApplication, v as DefineAssetSourceViewInput, w as PanelViewDeclaration, x as DefineWebWorkerInput, y as DefinePanelViewInput, z as defineTileView } from "./defineApp-DUi9ZfpT.js";
2
- import { View, ViewApplication, WebWorkerProps, WebWorkerProps as WebWorkerProps$1 } from "@sanity/sdk/dashboard";
1
+ import { A as ViewComponentBaseProps, B as defineTileView, C as DockGroup, D as TileSize, E as ServiceType, F as WebWorkerType, H as defineWindowView, I as WindowViewDeclaration, M as ViewSurface, N as WEB_WORKER_CONTRACT_VERSION, O as TileViewDeclaration, P as WebWorkerDeclaration, R as defineAssetSourceView, S as DefineWindowViewInput, T as PanelViewDeclaration, V as defineWebWorker, a as DefineMediaLibraryInput, b as DefineTileViewInput, c as WorkbenchApp, d as defineDashboard, f as isWorkbenchApp, g as AssetSourceViewDeclaration, h as unstable_defineMediaLibrary, i as DefineDashboardInput, j as ViewDeclaration, k as ViewComponent, l as WorkbenchConfig, m as resolveAppTitle, n as DefineAppInput, o as MediaLibraryConfig, p as isWorkbenchConfig, r as DefineAppResult, s as MediaLibraryField, t as DashboardConfig, u as defineApplication, v as DefineAssetSourceViewInput, x as DefineWebWorkerInput, y as DefinePanelViewInput, z as definePanelView } from "./defineApp-zjy9NZQF.js";
2
+ import { DashboardApplication, View, WebWorkerProps, WebWorkerProps as WebWorkerProps$1 } from "@sanity/sdk/dashboard";
3
3
  import { CurrentUser } from "@sanity/sdk";
4
4
  import { AssetSourceComponentProps } from "@sanity/types";
5
5
  interface ApplicationsContext {
6
- applications: readonly (ViewApplication & {
7
- views: readonly View<{
8
- includeApplication: false;
9
- }>[];
10
- })[];
6
+ applications: readonly DashboardApplication[];
11
7
  currentUser: CurrentUser;
12
8
  }
13
9
  interface DefineDashboardConfigInput {
14
10
  applications?: {
15
- hidden?: (references: readonly ViewApplication['reference'][], context: ApplicationsContext) => readonly ViewApplication['reference'][];
16
- visible?: (references: readonly ViewApplication['reference'][], context: ApplicationsContext) => readonly ViewApplication['reference'][];
11
+ hidden?: (references: readonly DashboardApplication['reference'][], context: ApplicationsContext) => readonly DashboardApplication['reference'][];
12
+ visible?: (references: readonly DashboardApplication['reference'][], context: ApplicationsContext) => readonly DashboardApplication['reference'][];
17
13
  };
18
14
  views?: (views: readonly View[], context: {
19
15
  currentUser: CurrentUser;
@@ -1,4 +1,4 @@
1
- import { t as DevServerManifest } from "./registry-DysyB1F6.js";
1
+ import { t as DevServerManifest } from "./registry-NsrUoJAF.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. */
@@ -1,4 +1,4 @@
1
- import "./defineApp-DUi9ZfpT.js";
1
+ import "./defineApp-zjy9NZQF.js";
2
2
  import { z } from "zod/mini";
3
3
  declare const devServerManifestSchema: z.ZodMiniObject<{
4
4
  applicationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -136,4 +136,4 @@ declare const devServerManifestSchema: z.ZodMiniObject<{
136
136
  */
137
137
  type DevServerManifest = z.infer<typeof devServerManifestSchema>;
138
138
  export { DevServerManifest as t };
139
- //# sourceMappingURL=registry-DysyB1F6.d.ts.map
139
+ //# sourceMappingURL=registry-NsrUoJAF.d.ts.map
@@ -1,4 +1,4 @@
1
- import { I as WorkbenchConfigValue, n as DefineAppInput } from "./defineApp-DUi9ZfpT.js";
1
+ import { L as WorkbenchConfigValue, n as DefineAppInput } from "./defineApp-zjy9NZQF.js";
2
2
  import { AppVisibility, CliConfig } from "@sanity/cli-core";
3
3
  /**
4
4
  * Bundled so adding a declaration family touches this type and the artifact
@@ -50,4 +50,4 @@ declare function resolveAppEntry(app: CliConfig['app']): string | undefined;
50
50
  */
51
51
  declare function resolveWorkbenchApp(cliConfig: CliConfig | null | undefined): ResolvedWorkbenchApp | null;
52
52
  export { resolveWorkbenchApp as i, WorkbenchExposes as n, resolveAppEntry as r, ResolvedWorkbenchApp as t };
53
- //# sourceMappingURL=resolveWorkbenchApp-C_rqQBQP.d.ts.map
53
+ //# sourceMappingURL=resolveWorkbenchApp-Cqyc0Rgf.d.ts.map
@@ -1,4 +1,4 @@
1
- import { l as WorkbenchConfig } from "./defineApp-DUi9ZfpT.js";
1
+ import { l as WorkbenchConfig } from "./defineApp-zjy9NZQF.js";
2
2
  import { CliConfig } from "@sanity/cli-core";
3
3
  /**
4
4
  * Resolve the workbench config for a CLI config, or `null` when it carries no
@@ -7,4 +7,4 @@ import { CliConfig } from "@sanity/cli-core";
7
7
  */
8
8
  declare function resolveWorkbenchConfig(cliConfig: CliConfig | null | undefined): WorkbenchConfig | null;
9
9
  export { resolveWorkbenchConfig as t };
10
- //# sourceMappingURL=resolveWorkbenchConfig-C_o8npN0.d.ts.map
10
+ //# sourceMappingURL=resolveWorkbenchConfig-DVIYlkMD.d.ts.map
@@ -1,6 +1,6 @@
1
- import { l as WorkbenchConfig } from "./defineApp-DUi9ZfpT.js";
2
- import { i as formatUndeploySummary, l as DeployableWorkbenchApp, o as DeployedView, s as DeployedWebWorker } from "./deploySummary-BPgEW1qt.js";
3
- import "node:zlib";
1
+ import { l as WorkbenchConfig } from "./defineApp-zjy9NZQF.js";
2
+ import { i as formatUndeploySummary, l as DeployableWorkbenchApp, o as DeployedView, s as DeployedWebWorker } from "./deploySummary-D43W05vj.js";
3
+ import "node:stream";
4
4
  import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
5
5
  interface ConfigSnapshot {
6
6
  id: string;
@@ -1,7 +1,8 @@
1
1
  import { basename, dirname } from 'node:path';
2
- import { createGzip } from 'node:zlib';
3
2
  import { subdebug } from '@sanity/cli-core';
3
+ import { nodeReadableFromWeb } from '@sanity/cli-core/request';
4
4
  import { c as createTar } from 'tar';
5
+ import { configContractVersion } from '../../contract.js';
5
6
  import { createConfig, resolveSingletonInstallationId } from '../../services/installations.js';
6
7
  import { summarizeGroup } from './summarizeInterfaces.js';
7
8
  const debug = subdebug('deploy');
@@ -49,15 +50,16 @@ const debug = subdebug('deploy');
49
50
  * reaches this mutating step.
50
51
  * @internal
51
52
  */ export async function deployConfig(options) {
52
- const { appType, installationId, sourceDir, version } = options;
53
- const tarball = createTar({
54
- cwd: dirname(sourceDir)
53
+ const { appType, installationId, sourceDir } = options;
54
+ const tarball = nodeReadableFromWeb(createTar({
55
+ cwd: dirname(sourceDir),
56
+ gzip: true
55
57
  }, [
56
58
  basename(sourceDir)
57
- ]).pipe(createGzip());
59
+ ]));
58
60
  await createConfig(installationId, {
59
61
  tarball,
60
- version
62
+ version: configContractVersion(appType)
61
63
  });
62
64
  debug('Deployed config for app type: %s', appType);
63
65
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployConfig.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {c as createTar} from 'tar'\n\nimport {type WorkbenchConfigValue} from '../../contract.js'\nimport {createConfig, resolveSingletonInstallationId} from '../../services/installations.js'\nimport {summarizeGroup} from './summarizeInterfaces.js'\n\nconst debug = subdebug('deploy')\n\n/**\n * The org's active installation for an app type, or `undefined` when none is\n * installed. Read-only, so `--dry-run` can report deployability.\n * @internal\n */\nexport async function resolveInstallationId(options: {\n appType: string\n organizationId: string\n}): Promise<string | undefined> {\n switch (options.appType) {\n case 'media-library': {\n return resolveSingletonInstallationId(options.organizationId, 'media-library')\n }\n default: {\n throw new Error(`Cannot create config for unknown app type: ${options.appType}`)\n }\n }\n}\n\n/**\n * A report heading and item list for a config; a media library's `fields` are\n * one of potentially many shapes.\n * @internal\n */\nexport function summarizeConfig(config: WorkbenchConfigValue): string {\n const {appType} = config\n\n switch (appType) {\n case 'dashboard': {\n return `Dashboard configuration: ${config.src}`\n }\n case 'media-library': {\n return summarizeGroup('Media library fields', config.fields)\n }\n default: {\n appType satisfies never\n throw new Error(`Cannot summarize unknown app type: ${appType as string}`)\n }\n }\n}\n\n/**\n * Upload the built module-federation remote to the installation as its config\n * snapshot. `installationId` is resolved by the caller so `--dry-run` never\n * reaches this mutating step.\n * @internal\n */\nexport async function deployConfig(options: {\n appType: string\n installationId: string\n sourceDir: string\n version: string\n}): Promise<void> {\n const {appType, installationId, sourceDir, version} = options\n const tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n await createConfig(installationId, {tarball, version})\n\n debug('Deployed config for app type: %s', appType)\n}\n"],"names":["basename","dirname","createGzip","subdebug","c","createTar","createConfig","resolveSingletonInstallationId","summarizeGroup","debug","resolveInstallationId","options","appType","organizationId","Error","summarizeConfig","config","src","fields","deployConfig","installationId","sourceDir","version","tarball","cwd","pipe"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAGlC,SAAQC,YAAY,EAAEC,8BAA8B,QAAO,kCAAiC;AAC5F,SAAQC,cAAc,QAAO,2BAA0B;AAEvD,MAAMC,QAAQN,SAAS;AAEvB;;;;CAIC,GACD,OAAO,eAAeO,sBAAsBC,OAG3C;IACC,OAAQA,QAAQC,OAAO;QACrB,KAAK;YAAiB;gBACpB,OAAOL,+BAA+BI,QAAQE,cAAc,EAAE;YAChE;QACA;YAAS;gBACP,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEH,QAAQC,OAAO,EAAE;YACjF;IACF;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASG,gBAAgBC,MAA4B;IAC1D,MAAM,EAACJ,OAAO,EAAC,GAAGI;IAElB,OAAQJ;QACN,KAAK;YAAa;gBAChB,OAAO,CAAC,yBAAyB,EAAEI,OAAOC,GAAG,EAAE;YACjD;QACA,KAAK;YAAiB;gBACpB,OAAOT,eAAe,wBAAwBQ,OAAOE,MAAM;YAC7D;QACA;YAAS;gBACPN;gBACA,MAAM,IAAIE,MAAM,CAAC,mCAAmC,EAAEF,SAAmB;YAC3E;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeO,aAAaR,OAKlC;IACC,MAAM,EAACC,OAAO,EAAEQ,cAAc,EAAEC,SAAS,EAAEC,OAAO,EAAC,GAAGX;IACtD,MAAMY,UAAUlB,UAAU;QAACmB,KAAKvB,QAAQoB;IAAU,GAAG;QAACrB,SAASqB;KAAW,EAAEI,IAAI,CAACvB;IACjF,MAAMI,aAAac,gBAAgB;QAACG;QAASD;IAAO;IAEpDb,MAAM,oCAAoCG;AAC5C"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployConfig.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\nimport {c as createTar} from 'tar'\n\nimport {configContractVersion, type WorkbenchConfigValue} from '../../contract.js'\nimport {createConfig, resolveSingletonInstallationId} from '../../services/installations.js'\nimport {summarizeGroup} from './summarizeInterfaces.js'\n\nconst debug = subdebug('deploy')\n\n/**\n * The org's active installation for an app type, or `undefined` when none is\n * installed. Read-only, so `--dry-run` can report deployability.\n * @internal\n */\nexport async function resolveInstallationId(options: {\n appType: string\n organizationId: string\n}): Promise<string | undefined> {\n switch (options.appType) {\n case 'media-library': {\n return resolveSingletonInstallationId(options.organizationId, 'media-library')\n }\n default: {\n throw new Error(`Cannot create config for unknown app type: ${options.appType}`)\n }\n }\n}\n\n/**\n * A report heading and item list for a config; a media library's `fields` are\n * one of potentially many shapes.\n * @internal\n */\nexport function summarizeConfig(config: WorkbenchConfigValue): string {\n const {appType} = config\n\n switch (appType) {\n case 'dashboard': {\n return `Dashboard configuration: ${config.src}`\n }\n case 'media-library': {\n return summarizeGroup('Media library fields', config.fields)\n }\n default: {\n appType satisfies never\n throw new Error(`Cannot summarize unknown app type: ${appType as string}`)\n }\n }\n}\n\n/**\n * Upload the built module-federation remote to the installation as its config\n * snapshot. `installationId` is resolved by the caller so `--dry-run` never\n * reaches this mutating step.\n * @internal\n */\nexport async function deployConfig(options: {\n appType: WorkbenchConfigValue['appType']\n installationId: string\n sourceDir: string\n}): Promise<void> {\n const {appType, installationId, sourceDir} = options\n const tarball = nodeReadableFromWeb(\n createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]),\n )\n await createConfig(installationId, {tarball, version: configContractVersion(appType)})\n\n debug('Deployed config for app type: %s', appType)\n}\n"],"names":["basename","dirname","subdebug","nodeReadableFromWeb","c","createTar","configContractVersion","createConfig","resolveSingletonInstallationId","summarizeGroup","debug","resolveInstallationId","options","appType","organizationId","Error","summarizeConfig","config","src","fields","deployConfig","installationId","sourceDir","tarball","cwd","gzip","version"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAE3C,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,mBAAmB,QAAO,2BAA0B;AAC5D,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAAQC,qBAAqB,QAAkC,oBAAmB;AAClF,SAAQC,YAAY,EAAEC,8BAA8B,QAAO,kCAAiC;AAC5F,SAAQC,cAAc,QAAO,2BAA0B;AAEvD,MAAMC,QAAQR,SAAS;AAEvB;;;;CAIC,GACD,OAAO,eAAeS,sBAAsBC,OAG3C;IACC,OAAQA,QAAQC,OAAO;QACrB,KAAK;YAAiB;gBACpB,OAAOL,+BAA+BI,QAAQE,cAAc,EAAE;YAChE;QACA;YAAS;gBACP,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEH,QAAQC,OAAO,EAAE;YACjF;IACF;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASG,gBAAgBC,MAA4B;IAC1D,MAAM,EAACJ,OAAO,EAAC,GAAGI;IAElB,OAAQJ;QACN,KAAK;YAAa;gBAChB,OAAO,CAAC,yBAAyB,EAAEI,OAAOC,GAAG,EAAE;YACjD;QACA,KAAK;YAAiB;gBACpB,OAAOT,eAAe,wBAAwBQ,OAAOE,MAAM;YAC7D;QACA;YAAS;gBACPN;gBACA,MAAM,IAAIE,MAAM,CAAC,mCAAmC,EAAEF,SAAmB;YAC3E;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeO,aAAaR,OAIlC;IACC,MAAM,EAACC,OAAO,EAAEQ,cAAc,EAAEC,SAAS,EAAC,GAAGV;IAC7C,MAAMW,UAAUpB,oBACdE,UAAU;QAACmB,KAAKvB,QAAQqB;QAAYG,MAAM;IAAI,GAAG;QAACzB,SAASsB;KAAW;IAExE,MAAMf,aAAac,gBAAgB;QAACE;QAASG,SAASpB,sBAAsBO;IAAQ;IAEpFH,MAAM,oCAAoCG;AAC5C"}
@@ -1,6 +1,6 @@
1
1
  import { basename, dirname } from 'node:path';
2
- import { createGzip } from 'node:zlib';
3
2
  import { getErrorMessage } from '@sanity/cli-core/errors';
3
+ import { nodeReadableFromWeb } from '@sanity/cli-core/request';
4
4
  import { spinner } from '@sanity/cli-core/ux';
5
5
  import { c as createTar } from 'tar';
6
6
  import { deriveInterfaces } from '../../deriveInterfaces.js';
@@ -101,11 +101,12 @@ function toBrettInterface(iface) {
101
101
  * @internal
102
102
  */ export async function deployWorkbenchApp(options) {
103
103
  const { access, app, applicationId, icon, isApp, isAutoUpdating, isExternal = false, label = 'Deploying...', mfManifest, onDeployed, slug, sourceDir, title, version, visibility, workDir, workspaces } = options;
104
- const tarball = isExternal ? undefined : createTar({
105
- cwd: dirname(sourceDir)
104
+ const tarball = isExternal ? undefined : nodeReadableFromWeb(createTar({
105
+ cwd: dirname(sourceDir),
106
+ gzip: true
106
107
  }, [
107
108
  basename(sourceDir)
108
- ]).pipe(createGzip());
109
+ ]));
109
110
  // Read before deploying, so a bad icon path fails while nothing is live.
110
111
  const interfaces = await Promise.all(deriveInterfaces(app, {
111
112
  appTitle: title,
@@ -1 +1 @@
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 {type ImageFile} from '@sanity/cli-core/images'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {readAppIcon} from '../../readAppIcon.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n removeApplicationIcon,\n setApplicationIcon,\n setInterfaceIcon,\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): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return declaration\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'panel': {\n const {icon: _icon, surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'window': {\n const {icon: _icon, surface, ...view} = declaration\n return {...view, type: 'app'}\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 `slug`/`visibility` when set)\n * and its icon from config. The deploy endpoint ignores these, so a redeploy\n * patches them here alongside the new deployment. No `icon` removes the\n * application's icon. Each interface's `icon` goes on the interface Brett created for it.\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?: ImageFile\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 workDir: string\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 workDir,\n workspaces,\n } = options\n const tarball = isExternal\n ? undefined\n : createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n // Read before deploying, so a bad icon path fails while nothing is live.\n const interfaces = await Promise.all(\n deriveInterfaces(app, {appTitle: title, isApp}).map(async (iface) => ({\n brett: toBrettInterface(iface),\n icon: 'icon' in iface && iface.icon ? await readAppIcon(workDir, iface.icon) : undefined,\n })),\n )\n\n const spin = spinner(label).start()\n try {\n const deployment = await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: interfaces.map(({brett}) => brett),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n if (icon) {\n try {\n await setApplicationIcon(applicationId, icon)\n } catch (error) {\n throw toIconRejection(\n error,\n 'The app icon was rejected',\n \"The deployment is live with the application's previous icon. Change `app.icon`\",\n )\n }\n } else {\n await removeApplicationIcon(applicationId)\n }\n for (const {\n brett: {name, type},\n icon: interfaceIcon,\n } of interfaces) {\n if (!interfaceIcon) continue\n\n const iface = deployment.interfaces.find((i) => i.type === type && i.name === name)\n if (!iface) {\n throw new Error(\n `The deployment is live, but has no ${type} interface named \"${name}\" to set its icon on.`,\n )\n }\n try {\n await setInterfaceIcon(applicationId, iface.id, interfaceIcon)\n } catch (error) {\n throw toIconRejection(\n error,\n `The icon of view \"${name}\" was rejected`,\n \"The deployment is live without it. Change the view's `icon`\",\n )\n }\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\n/** A 4xx on an icon upload is the image being rejected; name the server's reason. */\nfunction toIconRejection(error: unknown, rejected: string, fix: string): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `${rejected}: ${getErrorMessage(error)}. ${fix} in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["basename","dirname","createGzip","getErrorMessage","spinner","c","createTar","deriveInterfaces","readAppIcon","createApplication","createDeployment","deleteApplication","removeApplicationIcon","setApplicationIcon","setInterfaceIcon","updateApplication","toBrettInterface","iface","id","_id","src","_src","declaration","surface","view","type","icon","_icon","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","isApp","isAutoUpdating","isExternal","label","mfManifest","onDeployed","slug","sourceDir","title","version","visibility","workDir","workspaces","tarball","undefined","cwd","pipe","interfaces","Promise","all","appTitle","map","brett","deployment","toSlugRejection","toIconRejection","name","interfaceIcon","find","i","Error","clear","statusCode","cause","rejected","fix"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,UAAU,QAAO,YAAW;AAGpC,SAAQC,eAAe,QAAO,0BAAyB;AAEvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAAQC,WAAW,QAAO,uBAAsB;AAChD,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB;IAC/C,MAAM,EAACC,IAAIC,GAAG,EAAEC,KAAKC,IAAI,EAAE,GAAGC,aAAY,GAAGL;IAC7C,IAAI,UAAUK,aAAa,OAAOA;IAElC,OAAQA,YAAYC,OAAO;QACzB,KAAK;YAAgB;gBACnB,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;gBAAO;YAChC;QACA,KAAK;YAAS;gBACZ,MAAM,EAACG,MAAMC,KAAK,EAAEJ,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBACxC,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;gBAAO;YAChC;QACA,KAAK;YAAQ;gBACX,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GA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AEH,IAAI,KAAKA;YAC9E,IAAI,CAACnD,OAAO;gBACV,MAAM,IAAIuD,MACR,CAAC,mCAAmC,EAAE/C,KAAK,kBAAkB,EAAE2C,KAAK,qBAAqB,CAAC;YAE9F;YACA,IAAI;gBACF,MAAMtD,iBAAiB2B,eAAexB,MAAMC,EAAE,EAAEmD;YAClD,EAAE,OAAOlC,OAAO;gBACd,MAAMgC,gBACJhC,OACA,CAAC,kBAAkB,EAAEiC,KAAK,cAAc,CAAC,EACzC;YAEJ;QACF;QACAtC,KAAKG,OAAO;IACd,EAAE,OAAOE,OAAO;QACdL,KAAK2C,KAAK;QACV,MAAMtC;IACR;AACF;AAEA;;;;;CAKC,GACD,SAAS+B,gBAAgB/B,KAAc,EAAEa,IAAwB;IAC/D,MAAM0B,aAAcvC,OAAiCuC;IACrD,IAAI,CAAC1B,QAAQ0B,eAAelB,aAAakB,aAAa,OAAOA,cAAc,KAAK,OAAOvC;IACvF,OAAO,IAAIqC,MACT,CAAC,MAAM,EAAExB,KAAK,gBAAgB,EAAE7C,gBAAgBgC,OAAO,oHAAoH,CAAC,EAC5K;QAACwC,OAAOxC;IAAK;AAEjB;AAEA,mFAAmF,GACnF,SAASgC,gBAAgBhC,KAAc,EAAEyC,QAAgB,EAAEC,GAAW;IACpE,MAAMH,aAAcvC,OAAiCuC;IACrD,IAAIA,eAAelB,aAAakB,aAAa,OAAOA,cAAc,KAAK,OAAOvC;IAC9E,OAAO,IAAIqC,MACT,GAAGI,SAAS,EAAE,EAAEzE,gBAAgBgC,OAAO,EAAE,EAAE0C,IAAI,mCAAmC,CAAC,EACnF;QAACF,OAAOxC;IAAK;AAEjB"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployWorkbenchApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type ImageFile} from '@sanity/cli-core/images'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {c as createTar} from 'tar'\n\nimport {type DerivedInterface, deriveInterfaces} from '../../deriveInterfaces.js'\nimport {readAppIcon} from '../../readAppIcon.js'\nimport {\n type Application,\n type BrettAccess,\n type BrettInterface,\n type BrettWorkspace,\n createApplication,\n createDeployment,\n deleteApplication,\n removeApplicationIcon,\n setApplicationIcon,\n setInterfaceIcon,\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): BrettInterface {\n const {id: _id, src: _src, ...declaration} = iface\n if ('type' in declaration) return declaration\n\n switch (declaration.surface) {\n case 'asset_source': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'panel': {\n const {icon: _icon, surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'tile': {\n const {surface, ...view} = declaration\n return {...view, type: surface}\n }\n case 'window': {\n const {icon: _icon, surface, ...view} = declaration\n return {...view, type: 'app'}\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 `slug`/`visibility` when set)\n * and its icon from config. The deploy endpoint ignores these, so a redeploy\n * patches them here alongside the new deployment. No `icon` removes the\n * application's icon. Each interface's `icon` goes on the interface Brett created for it.\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?: ImageFile\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 workDir: string\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 workDir,\n workspaces,\n } = options\n const tarball = isExternal\n ? undefined\n : nodeReadableFromWeb(createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]))\n\n // Read before deploying, so a bad icon path fails while nothing is live.\n const interfaces = await Promise.all(\n deriveInterfaces(app, {appTitle: title, isApp}).map(async (iface) => ({\n brett: toBrettInterface(iface),\n icon: 'icon' in iface && iface.icon ? await readAppIcon(workDir, iface.icon) : undefined,\n })),\n )\n\n const spin = spinner(label).start()\n try {\n const deployment = await createDeployment({\n access,\n applicationId,\n // Brett assigns the id and resolves modules by `moduleId`, so neither travels.\n interfaces: interfaces.map(({brett}) => brett),\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n })\n onDeployed?.()\n try {\n await updateApplication(applicationId, {\n title,\n ...(slug ? {slug} : {}),\n ...(visibility ? {visibility} : {}),\n })\n } catch (error) {\n throw toSlugRejection(error, slug)\n }\n if (icon) {\n try {\n await setApplicationIcon(applicationId, icon)\n } catch (error) {\n throw toIconRejection(\n error,\n 'The app icon was rejected',\n \"The deployment is live with the application's previous icon. Change `app.icon`\",\n )\n }\n } else {\n await removeApplicationIcon(applicationId)\n }\n for (const {\n brett: {name, type},\n icon: interfaceIcon,\n } of interfaces) {\n if (!interfaceIcon) continue\n\n const iface = deployment.interfaces.find((i) => i.type === type && i.name === name)\n if (!iface) {\n throw new Error(\n `The deployment is live, but has no ${type} interface named \"${name}\" to set its icon on.`,\n )\n }\n try {\n await setInterfaceIcon(applicationId, iface.id, interfaceIcon)\n } catch (error) {\n throw toIconRejection(\n error,\n `The icon of view \"${name}\" was rejected`,\n \"The deployment is live without it. Change the view's `icon`\",\n )\n }\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\n/** A 4xx on an icon upload is the image being rejected; name the server's reason. */\nfunction toIconRejection(error: unknown, rejected: string, fix: string): unknown {\n const statusCode = (error as {statusCode?: number})?.statusCode\n if (statusCode === undefined || statusCode < 400 || statusCode >= 500) return error\n return new Error(\n `${rejected}: ${getErrorMessage(error)}. ${fix} in sanity.cli.ts and deploy again.`,\n {cause: error},\n )\n}\n"],"names":["basename","dirname","getErrorMessage","nodeReadableFromWeb","spinner","c","createTar","deriveInterfaces","readAppIcon","createApplication","createDeployment","deleteApplication","removeApplicationIcon","setApplicationIcon","setInterfaceIcon","updateApplication","toBrettInterface","iface","id","_id","src","_src","declaration","surface","view","type","icon","_icon","createCoreApp","options","spin","start","application","succeed","rollback","error","fail","createStudio","deployWorkbenchApp","access","app","applicationId","isApp","isAutoUpdating","isExternal","label","mfManifest","onDeployed","slug","sourceDir","title","version","visibility","workDir","workspaces","tarball","undefined","cwd","gzip","interfaces","Promise","all","appTitle","map","brett","deployment","toSlugRejection","toIconRejection","name","interfaceIcon","find","i","Error","clear","statusCode","cause","rejected","fix"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAG3C,SAAQC,eAAe,QAAO,0BAAyB;AAEvD,SAAQC,mBAAmB,QAAO,2BAA0B;AAC5D,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAA+BC,gBAAgB,QAAO,4BAA2B;AACjF,SAAQC,WAAW,QAAO,uBAAsB;AAChD,SAKEC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,QACZ,iCAAgC;AAWvC,SAASC,iBAAiBC,KAAuB;IAC/C,MAAM,EAACC,IAAIC,GAAG,EAAEC,KAAKC,IAAI,EAAE,GAAGC,aAAY,GAAGL;IAC7C,IAAI,UAAUK,aAAa,OAAOA;IAElC,OAAQA,YAAYC,OAAO;QACzB,KAAK;YAAgB;gBACnB,MAAM,EAACA,OAAO,EAAE,GAAGC,MAAK,GAAGF;gBAC3B,OAAO;oBAAC,GAAGE,IAAI;oBAAEC,MAAMF;gBAAO;YAChC;QACA,KAAK;YAAS;gBACZ,MAAM,EAACG,MAAMC,KAAK,EAAEJ,O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2
- import { createGzip } from 'node:zlib';
3
2
  import { subdebug } from '@sanity/cli-core';
3
+ import { nodeReadableFromWeb } from '@sanity/cli-core/request';
4
4
  import { c as createTar } from 'tar';
5
5
  import { configContractVersion } from '../../contract.js';
6
6
  import { createDashboard, createDashboardConfig, deleteDashboard } from '../../services/dashboard-configs.js';
@@ -8,11 +8,12 @@ const debug = subdebug('deploy');
8
8
  export async function uploadDashboardConfig(options) {
9
9
  const { dashboard, organizationId, sourceDir } = options;
10
10
  const version = configContractVersion('dashboard');
11
- const tarball = createTar({
12
- cwd: dirname(sourceDir)
11
+ const tarball = nodeReadableFromWeb(createTar({
12
+ cwd: dirname(sourceDir),
13
+ gzip: true
13
14
  }, [
14
15
  basename(sourceDir)
15
- ]).pipe(createGzip());
16
+ ]));
16
17
  if (dashboard) {
17
18
  return createDashboardConfig(dashboard.id, {
18
19
  tarball,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/uploadDashboardConfig.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {createGzip} from 'node:zlib'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {c as createTar} from 'tar'\n\nimport {configContractVersion} from '../../contract.js'\nimport {\n createDashboard,\n createDashboardConfig,\n type Dashboard,\n deleteDashboard,\n} from '../../services/dashboard-configs.js'\n\nconst debug = subdebug('deploy')\n\nexport async function uploadDashboardConfig(options: {\n dashboard: Dashboard | undefined\n organizationId: string\n sourceDir: string\n}): Promise<void> {\n const {dashboard, organizationId, sourceDir} = options\n const version = configContractVersion('dashboard')\n const tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n if (dashboard) {\n return createDashboardConfig(dashboard.id, {tarball, version})\n }\n\n const created = await createDashboard(organizationId)\n\n try {\n return await createDashboardConfig(created.id, {tarball, version})\n } catch (err) {\n await deleteDashboard(created.id).catch((cleanupErr) =>\n debug(\n 'Failed to remove Dashboard %s after a failed config upload: %O',\n created.id,\n cleanupErr,\n ),\n )\n throw err\n }\n}\n"],"names":["basename","dirname","createGzip","subdebug","c","createTar","configContractVersion","createDashboard","createDashboardConfig","deleteDashboard","debug","uploadDashboardConfig","options","dashboard","organizationId","sourceDir","version","tarball","cwd","pipe","id","created","err","catch","cleanupErr"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAAQC,qBAAqB,QAAO,oBAAmB;AACvD,SACEC,eAAe,EACfC,qBAAqB,EAErBC,eAAe,QACV,sCAAqC;AAE5C,MAAMC,QAAQP,SAAS;AAEvB,OAAO,eAAeQ,sBAAsBC,OAI3C;IACC,MAAM,EAACC,SAAS,EAAEC,cAAc,EAAEC,SAAS,EAAC,GAAGH;IAC/C,MAAMI,UAAUV,sBAAsB;IACtC,MAAMW,UAAUZ,UAAU;QAACa,KAAKjB,QAAQc;IAAU,GAAG;QAACf,SAASe;KAAW,EAAEI,IAAI,CAACjB;IAEjF,IAAIW,WAAW;QACb,OAAOL,sBAAsBK,UAAUO,EAAE,EAAE;YAACH;YAASD;QAAO;IAC9D;IAEA,MAAMK,UAAU,MAAMd,gBAAgBO;IAEtC,IAAI;QACF,OAAO,MAAMN,sBAAsBa,QAAQD,EAAE,EAAE;YAACH;YAASD;QAAO;IAClE,EAAE,OAAOM,KAAK;QACZ,MAAMb,gBAAgBY,QAAQD,EAAE,EAAEG,KAAK,CAAC,CAACC,aACvCd,MACE,kEACAW,QAAQD,EAAE,EACVI;QAGJ,MAAMF;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/uploadDashboardConfig.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\nimport {c as createTar} from 'tar'\n\nimport {configContractVersion} from '../../contract.js'\nimport {\n createDashboard,\n createDashboardConfig,\n type Dashboard,\n deleteDashboard,\n} from '../../services/dashboard-configs.js'\n\nconst debug = subdebug('deploy')\n\nexport async function uploadDashboardConfig(options: {\n dashboard: Dashboard | undefined\n organizationId: string\n sourceDir: string\n}): Promise<void> {\n const {dashboard, organizationId, sourceDir} = options\n const version = configContractVersion('dashboard')\n const tarball = nodeReadableFromWeb(\n createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]),\n )\n\n if (dashboard) {\n return createDashboardConfig(dashboard.id, {tarball, version})\n }\n\n const created = await createDashboard(organizationId)\n\n try {\n return await createDashboardConfig(created.id, {tarball, version})\n } catch (err) {\n await deleteDashboard(created.id).catch((cleanupErr) =>\n debug(\n 'Failed to remove Dashboard %s after a failed config upload: %O',\n created.id,\n cleanupErr,\n ),\n )\n throw err\n }\n}\n"],"names":["basename","dirname","subdebug","nodeReadableFromWeb","c","createTar","configContractVersion","createDashboard","createDashboardConfig","deleteDashboard","debug","uploadDashboardConfig","options","dashboard","organizationId","sourceDir","version","tarball","cwd","gzip","id","created","err","catch","cleanupErr"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAE3C,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,mBAAmB,QAAO,2BAA0B;AAC5D,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAAQC,qBAAqB,QAAO,oBAAmB;AACvD,SACEC,eAAe,EACfC,qBAAqB,EAErBC,eAAe,QACV,sCAAqC;AAE5C,MAAMC,QAAQR,SAAS;AAEvB,OAAO,eAAeS,sBAAsBC,OAI3C;IACC,MAAM,EAACC,SAAS,EAAEC,cAAc,EAAEC,SAAS,EAAC,GAAGH;IAC/C,MAAMI,UAAUV,sBAAsB;IACtC,MAAMW,UAAUd,oBACdE,UAAU;QAACa,KAAKjB,QAAQc;QAAYI,MAAM;IAAI,GAAG;QAACnB,SAASe;KAAW;IAGxE,IAAIF,WAAW;QACb,OAAOL,sBAAsBK,UAAUO,EAAE,EAAE;YAACH;YAASD;QAAO;IAC9D;IAEA,MAAMK,UAAU,MAAMd,gBAAgBO;IAEtC,IAAI;QACF,OAAO,MAAMN,sBAAsBa,QAAQD,EAAE,EAAE;YAACH;YAASD;QAAO;IAClE,EAAE,OAAOM,KAAK;QACZ,MAAMb,gBAAgBY,QAAQD,EAAE,EAAEG,KAAK,CAAC,CAACC,aACvCd,MACE,kEACAW,QAAQD,EAAE,EACVI;QAGJ,MAAMF;IACR;AACF"}
package/dist/contract.js CHANGED
@@ -5,7 +5,7 @@ import { z } from 'zod/mini';
5
5
  /** @internal */ export const VIEW_CONTRACT_VERSION = 2;
6
6
  /** @internal */ export const WEB_WORKER_CONTRACT_VERSION = 1;
7
7
  /** @internal */ export const WINDOW_CONTRACT_VERSION = 1;
8
- /** @internal */ export const MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION = 1;
8
+ export const MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION = 1;
9
9
  export const DASHBOARD_CONFIG_CONTRACT_VERSION = 1;
10
10
  export const DASHBOARD_CONFIG_TYPE = 'dashboard_config';
11
11
  /** Component slots per view surface; windows load outside the component artifact path. @internal */ export const VIEW_COMPONENTS = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contract.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n// Shared module-federation extension contract: interface (view/web worker) and\n// config declaration schemas, plus the versions the build stamps.\n// `zod/mini` keeps the bundle small.\n\n/** @internal */\nexport const VIEW_CONTRACT_VERSION = 2\n\n/** @internal */\nexport const WEB_WORKER_CONTRACT_VERSION = 1\n\n/** @internal */\nexport const WINDOW_CONTRACT_VERSION = 1\n\n/** @internal */\nexport const MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION = 1\n\nexport const DASHBOARD_CONFIG_CONTRACT_VERSION = 1\n\nexport const DASHBOARD_CONFIG_TYPE = 'dashboard_config'\n\n/**\n * A view component. The return is opaque so the runtime helpers carry no React\n * dependency — the generated artifact renders it with the app's own React.\n * @public\n */\nexport type ViewComponent<TProps> = (props: TProps) => unknown\n\n/** @public */\nexport interface ViewComponentBaseProps<TView> {\n view: TView\n}\n\n/** Component slots per view surface; windows load outside the component artifact path. @internal */\nexport const VIEW_COMPONENTS = {\n asset_source: ['asset_source'],\n panel: ['title', 'panel'],\n tile: ['tile'],\n window: [],\n} as const satisfies Record<string, readonly string[]>\n\n/** @public */\nexport type ViewSurface = keyof typeof VIEW_COMPONENTS\n\n/**\n * A tile's footprint family — the shape it occupies on the dashboard. Modelled\n * on iOS WidgetKit families, not a linear scale: `banner` is full-width and\n * shallow, which a `small`→`large` magnitude can't express. The host maps a\n * family to a layout slot; the component reads it to render per footprint.\n * @public\n */\nexport const TileSizeSchema = z.enum(['small', 'large', 'banner'])\n\n/** @public */\nexport type TileSize = z.infer<typeof TileSizeSchema>\n\n/** @public */\nexport type WebWorkerType = 'worker'\n\n/**\n * @deprecated Use `WebWorkerType`.\n * @public\n */\nexport type ServiceType = WebWorkerType\n\nconst DockGroupSchema = z.enum(['system', 'applications'])\n\n/** @public */\nexport type DockGroup = z.output<typeof DockGroupSchema>\n\n/** @internal */\nexport const DockSchema = z.object({\n group: z.optional(DockGroupSchema),\n order: z.optional(z.number()),\n})\n\n/** @internal */\nexport type Dock = z.infer<typeof DockSchema>\n\nconst PanelDockSchema = z.object({order: z.optional(z.number())})\n\n/** @internal */\nexport const ViewPlacementMetadataSchema = z.object({\n dock: z.optional(DockSchema),\n icon: z.optional(z.string()),\n})\n\n/** @internal */\nexport type ViewPlacementMetadata = z.infer<typeof ViewPlacementMetadataSchema>\n\n/**\n * A tile's interface metadata: its footprint `size` and an optional `order`\n * the dashboard sorts on, ascending. Both are authored as top-level view fields\n * (see {@link InterfaceDeclarationSchema}) but stored on the record as metadata.\n * @internal\n */\nexport const TileInterfaceMetadataSchema = z.object({\n order: z.optional(z.number()),\n size: TileSizeSchema,\n})\n\n/** @internal */\nexport type TileInterfaceMetadata = z.infer<typeof TileInterfaceMetadataSchema>\n\n/**\n * The contract version each interface type advertises, so the host can check it\n * renders/runs what it expects.\n * @internal\n */\nconst INTERFACE_CONTRACT_VERSIONS = {\n asset_source: VIEW_CONTRACT_VERSION,\n panel: VIEW_CONTRACT_VERSION,\n tile: VIEW_CONTRACT_VERSION,\n window: WINDOW_CONTRACT_VERSION,\n worker: WEB_WORKER_CONTRACT_VERSION,\n} as const satisfies Record<string, number>\n\n/** Every interface type an app exposes — a window, a view, or a web worker. */\nexport type InterfaceKind = keyof typeof INTERFACE_CONTRACT_VERSIONS\n\n/** @internal */\nexport function interfaceContractVersion(kind: InterfaceKind): string {\n return String(INTERFACE_CONTRACT_VERSIONS[kind])\n}\n\n/**\n * The module-federation id a build exposes an interface at. Dev stamps the same\n * id a deploy would, so the workbench loads a local interface like a deployed one.\n * @internal\n */\nexport function interfaceModuleId(kind: string, name: string): string {\n switch (kind) {\n case 'asset_source':\n case 'panel':\n case 'tile': {\n return `views/${name}`\n }\n case 'window': {\n return 'App'\n }\n case 'worker': {\n return `services/${name}`\n }\n default: {\n throw new Error(`Cannot derive a moduleId for unknown interface kind: ${kind}`)\n }\n }\n}\n\n// Shared `name` + `src`; `kind` only tailors the validation message.\nfunction extensionDeclarationFields(kind: 'Field' | 'View' | 'Web worker') {\n const pattern = /^[a-zA-Z0-9_-]+$/\n return {\n name: z.string().check(z.regex(pattern, `${kind} \\`name\\` must match ${pattern}`)),\n src: z.string(),\n }\n}\n\n// Every interface shares `name` + `src` + a display `title`,\n// which Brett requires on the record each becomes.\nfunction interfaceDeclarationFields(kind: 'View' | 'Web worker') {\n return {\n ...extensionDeclarationFields(kind),\n title: z.string(`${kind} \\`title\\` is required`),\n }\n}\n\nconst PanelViewSchema = z.object({\n surface: z.literal('panel'),\n ...interfaceDeclarationFields('View'),\n dock: z.optional(PanelDockSchema),\n icon: z.optional(z.string()),\n})\n\n/** @public */\nexport type PanelViewDeclaration = z.output<typeof PanelViewSchema>\n\n/** @public */\nexport type DefinePanelViewInput = Omit<PanelViewDeclaration, 'surface'>\n\n/** @public */\nexport function definePanelView(view: DefinePanelViewInput): PanelViewDeclaration {\n return {...view, surface: 'panel'}\n}\n\nconst WindowViewSchema = z.object({\n surface: z.literal('window'),\n ...interfaceDeclarationFields('View'),\n dock: z.optional(DockSchema),\n icon: z.optional(z.string()),\n})\n\n/** @public */\nexport type WindowViewDeclaration = z.output<typeof WindowViewSchema>\n\n/** @public */\nexport type DefineWindowViewInput = Omit<WindowViewDeclaration, 'surface'>\n\n/** @public */\nexport function defineWindowView(view: DefineWindowViewInput): WindowViewDeclaration {\n return {...view, surface: 'window'}\n}\n\nconst AssetSourceViewSchema = z.object({\n surface: z.literal('asset_source'),\n ...interfaceDeclarationFields('View'),\n})\n\n/** @public */\nexport type AssetSourceViewDeclaration = z.output<typeof AssetSourceViewSchema>\n\n/** @public */\nexport type DefineAssetSourceViewInput = Omit<AssetSourceViewDeclaration, 'surface'>\n\n/** @public */\nexport function defineAssetSourceView(\n view: DefineAssetSourceViewInput,\n): AssetSourceViewDeclaration {\n return {...view, surface: 'asset_source'}\n}\n\nconst TileViewSchema = z.object({\n surface: z.literal('tile'),\n ...interfaceDeclarationFields('View'),\n /** Sort position within its layout track, ascending. Optional. */\n order: z.optional(z.number()),\n /** Footprint family the dashboard lays the tile out by. */\n size: TileSizeSchema,\n})\n\n/** @public */\nexport type TileViewDeclaration = z.output<typeof TileViewSchema>\n\n/** @public */\nexport type DefineTileViewInput = Omit<TileViewDeclaration, 'surface'>\n\n/** @public */\nexport function defineTileView(view: DefineTileViewInput): TileViewDeclaration {\n return {...view, surface: 'tile'}\n}\n\n/** @internal */\nexport const InterfaceDeclarationSchema = z.discriminatedUnion('surface', [\n WindowViewSchema,\n PanelViewSchema,\n AssetSourceViewSchema,\n TileViewSchema,\n])\n\n/** @public */\nexport type ViewDeclaration = z.output<typeof InterfaceDeclarationSchema>\n\nconst WebWorkerSchema = z.object({\n type: z.literal('worker'),\n ...interfaceDeclarationFields('Web worker'),\n})\n\n/** @public */\nexport type WebWorkerDeclaration = z.output<typeof WebWorkerSchema>\n\n/** @public */\nexport type DefineWebWorkerInput = Omit<WebWorkerDeclaration, 'type'>\n\n/** @public */\nexport function defineWebWorker(webWorker: DefineWebWorkerInput): WebWorkerDeclaration {\n return {...webWorker, type: 'worker'}\n}\n\n/** @internal */\nexport const WebWorkerDeclarationSchema = z.discriminatedUnion('type', [WebWorkerSchema])\n\nconst MediaLibraryFieldSchema = z.object({\n ...extensionDeclarationFields('Field'),\n public: z.optional(z.boolean()),\n title: z.string(),\n})\n\n/**\n * Stamped where the config crosses a boundary so the authoring model doesn't carry a constant discriminator.\n * @internal\n */\nexport const INSTALLATION_CONFIG_TYPE = 'installation_config'\n\n// `appType` is stamped by `unstable_defineMediaLibrary`, never authored.\nconst MediaLibraryConfigSchema = z.object({\n appType: z.literal('media-library'),\n fields: z\n .array(MediaLibraryFieldSchema)\n .check(\n z.refine(\n (fields) => new Set(fields.map((field) => field.name)).size === fields.length,\n 'Field `name` must be unique within a media library',\n ),\n ),\n})\n\nconst DashboardConfigSchema = z.object({\n appType: z.literal('dashboard'),\n src: z.string('Dashboard configuration `src` must be a path to the configuration file'),\n})\n\n/**\n * A workbench config's built value, keyed by `appType`; deploys as a versioned\n * snapshot, not an interface.\n * @internal\n */\nexport const ConfigSchema = z.discriminatedUnion('appType', [\n DashboardConfigSchema,\n MediaLibraryConfigSchema,\n])\n\n/**\n * The config value, keyed by `appType`, the build expands into a federation\n * remote and the deploy summarizes.\n * @internal\n */\nexport type WorkbenchConfigValue = z.output<typeof ConfigSchema>\n\nconst CONFIG_CONTRACT_VERSIONS: Record<WorkbenchConfigValue['appType'], number> = {\n dashboard: DASHBOARD_CONFIG_CONTRACT_VERSION,\n 'media-library': MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION,\n}\n\n/** @internal */\nexport function configContractVersion(appType: WorkbenchConfigValue['appType']): string {\n return String(CONFIG_CONTRACT_VERSIONS[appType])\n}\n"],"names":["z","VIEW_CONTRACT_VERSION","WEB_WORKER_CONTRACT_VERSION","WINDOW_CONTRACT_VERSION","MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION","DASHBOARD_CONFIG_CONTRACT_VERSION","DASHBOARD_CONFIG_TYPE","VIEW_COMPONENTS","asset_source","panel","tile","window","TileSizeSchema","enum","DockGroupSchema","DockSchema","object","group","optional","order","number","PanelDockSchema","ViewPlacementMetadataSchema","dock","icon","string","TileInterfaceMetadataSchema","size","INTERFACE_CONTRACT_VERSIONS","worker","interfaceContractVersion","kind","String","interfaceModuleId","name","Error","extensionDeclarationFields","pattern","check","regex","src","interfaceDeclarationFields","title","PanelViewSchema","surface","literal","definePanelView","view","WindowViewSchema","defineWindowView","AssetSourceViewSchema","defineAssetSourceView","TileViewSchema","defineTileView","InterfaceDeclarationSchema","discriminatedUnion","WebWorkerSchema","type","defineWebWorker","webWorker","WebWorkerDeclarationSchema","MediaLibraryFieldSchema","public","boolean","INSTALLATION_CONFIG_TYPE","MediaLibraryConfigSchema","appType","fields","array","refine","Set","map","field","length","DashboardConfigSchema","ConfigSchema","CONFIG_CONTRACT_VERSIONS","dashboard","configContractVersion"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B,+EAA+E;AAC/E,kEAAkE;AAClE,qCAAqC;AAErC,cAAc,GACd,OAAO,MAAMC,wBAAwB,EAAC;AAEtC,cAAc,GACd,OAAO,MAAMC,8BAA8B,EAAC;AAE5C,cAAc,GACd,OAAO,MAAMC,0BAA0B,EAAC;AAExC,cAAc,GACd,OAAO,MAAMC,wCAAwC,EAAC;AAEtD,OAAO,MAAMC,oCAAoC,EAAC;AAElD,OAAO,MAAMC,wBAAwB,mBAAkB;AAcvD,kGAAkG,GAClG,OAAO,MAAMC,kBAAkB;IAC7BC,cAAc;QAAC;KAAe;IAC9BC,OAAO;QAAC;QAAS;KAAQ;IACzBC,MAAM;QAAC;KAAO;IACdC,QAAQ,EAAE;AACZ,EAAsD;AAKtD;;;;;;CAMC,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C,QAAUA,MAAMtC,IAAI,GAAGP,IAAI,KAAKwC,OAAOM,MAAM,EAC7E;AAGR;AAEA,MAAMC,wBAAwB1E,EAAEgB,MAAM,CAAC;IACrCkD,SAASlE,EAAE6C,OAAO,CAAC;IACnBL,KAAKxC,EAAEyB,MAAM,CAAC;AAChB;AAEA;;;;CAIC,GACD,OAAO,MAAMkD,eAAe3E,EAAEuD,kBAAkB,CAAC,WAAW;IAC1DmB;IACAT;CACD,EAAC;AASF,MAAMW,2BAA4E;IAChFC,WAAWxE;IACX,iBAAiBD;AACnB;AAEA,cAAc,GACd,OAAO,SAAS0E,sBAAsBZ,OAAwC;IAC5E,OAAOlC,OAAO4C,wBAAwB,CAACV,QAAQ;AACjD"}
1
+ {"version":3,"sources":["../src/contract.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n// Shared module-federation extension contract: interface (view/web worker) and\n// config declaration schemas, plus the versions the build stamps.\n// `zod/mini` keeps the bundle small.\n\n/** @internal */\nexport const VIEW_CONTRACT_VERSION = 2\n\n/** @internal */\nexport const WEB_WORKER_CONTRACT_VERSION = 1\n\n/** @internal */\nexport const WINDOW_CONTRACT_VERSION = 1\n\nexport const MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION = 1\n\nexport const DASHBOARD_CONFIG_CONTRACT_VERSION = 1\n\nexport const DASHBOARD_CONFIG_TYPE = 'dashboard_config'\n\n/**\n * A view component. The return is opaque so the runtime helpers carry no React\n * dependency — the generated artifact renders it with the app's own React.\n * @public\n */\nexport type ViewComponent<TProps> = (props: TProps) => unknown\n\n/** @public */\nexport interface ViewComponentBaseProps<TView> {\n view: TView\n}\n\n/** Component slots per view surface; windows load outside the component artifact path. @internal */\nexport const VIEW_COMPONENTS = {\n asset_source: ['asset_source'],\n panel: ['title', 'panel'],\n tile: ['tile'],\n window: [],\n} as const satisfies Record<string, readonly string[]>\n\n/** @public */\nexport type ViewSurface = keyof typeof VIEW_COMPONENTS\n\n/**\n * A tile's footprint family — the shape it occupies on the dashboard. Modelled\n * on iOS WidgetKit families, not a linear scale: `banner` is full-width and\n * shallow, which a `small`→`large` magnitude can't express. The host maps a\n * family to a layout slot; the component reads it to render per footprint.\n * @public\n */\nexport const TileSizeSchema = z.enum(['small', 'large', 'banner'])\n\n/** @public */\nexport type TileSize = z.infer<typeof TileSizeSchema>\n\n/** @public */\nexport type WebWorkerType = 'worker'\n\n/**\n * @deprecated Use `WebWorkerType`.\n * @public\n */\nexport type ServiceType = WebWorkerType\n\nconst DockGroupSchema = z.enum(['system', 'applications'])\n\n/** @public */\nexport type DockGroup = z.output<typeof DockGroupSchema>\n\n/** @internal */\nexport const DockSchema = z.object({\n group: z.optional(DockGroupSchema),\n order: z.optional(z.number()),\n})\n\n/** @internal */\nexport type Dock = z.infer<typeof DockSchema>\n\nconst PanelDockSchema = z.object({order: z.optional(z.number())})\n\n/** @internal */\nexport const ViewPlacementMetadataSchema = z.object({\n dock: z.optional(DockSchema),\n icon: z.optional(z.string()),\n})\n\n/** @internal */\nexport type ViewPlacementMetadata = z.infer<typeof ViewPlacementMetadataSchema>\n\n/**\n * A tile's interface metadata: its footprint `size` and an optional `order`\n * the dashboard sorts on, ascending. Both are authored as top-level view fields\n * (see {@link InterfaceDeclarationSchema}) but stored on the record as metadata.\n * @internal\n */\nexport const TileInterfaceMetadataSchema = z.object({\n order: z.optional(z.number()),\n size: TileSizeSchema,\n})\n\n/** @internal */\nexport type TileInterfaceMetadata = z.infer<typeof TileInterfaceMetadataSchema>\n\n/**\n * The contract version each interface type advertises, so the host can check it\n * renders/runs what it expects.\n * @internal\n */\nconst INTERFACE_CONTRACT_VERSIONS = {\n asset_source: VIEW_CONTRACT_VERSION,\n panel: VIEW_CONTRACT_VERSION,\n tile: VIEW_CONTRACT_VERSION,\n window: WINDOW_CONTRACT_VERSION,\n worker: WEB_WORKER_CONTRACT_VERSION,\n} as const satisfies Record<string, number>\n\n/** Every interface type an app exposes — a window, a view, or a web worker. */\nexport type InterfaceKind = keyof typeof INTERFACE_CONTRACT_VERSIONS\n\n/** @internal */\nexport function interfaceContractVersion(kind: InterfaceKind): string {\n return String(INTERFACE_CONTRACT_VERSIONS[kind])\n}\n\n/**\n * The module-federation id a build exposes an interface at. Dev stamps the same\n * id a deploy would, so the workbench loads a local interface like a deployed one.\n * @internal\n */\nexport function interfaceModuleId(kind: string, name: string): string {\n switch (kind) {\n case 'asset_source':\n case 'panel':\n case 'tile': {\n return `views/${name}`\n }\n case 'window': {\n return 'App'\n }\n case 'worker': {\n return `services/${name}`\n }\n default: {\n throw new Error(`Cannot derive a moduleId for unknown interface kind: ${kind}`)\n }\n }\n}\n\n// Shared `name` + `src`; `kind` only tailors the validation message.\nfunction extensionDeclarationFields(kind: 'Field' | 'View' | 'Web worker') {\n const pattern = /^[a-zA-Z0-9_-]+$/\n return {\n name: z.string().check(z.regex(pattern, `${kind} \\`name\\` must match ${pattern}`)),\n src: z.string(),\n }\n}\n\n// Every interface shares `name` + `src` + a display `title`,\n// which Brett requires on the record each becomes.\nfunction interfaceDeclarationFields(kind: 'View' | 'Web worker') {\n return {\n ...extensionDeclarationFields(kind),\n title: z.string(`${kind} \\`title\\` is required`),\n }\n}\n\nconst PanelViewSchema = z.object({\n surface: z.literal('panel'),\n ...interfaceDeclarationFields('View'),\n dock: z.optional(PanelDockSchema),\n icon: z.optional(z.string()),\n})\n\n/** @public */\nexport type PanelViewDeclaration = z.output<typeof PanelViewSchema>\n\n/** @public */\nexport type DefinePanelViewInput = Omit<PanelViewDeclaration, 'surface'>\n\n/** @public */\nexport function definePanelView(view: DefinePanelViewInput): PanelViewDeclaration {\n return {...view, surface: 'panel'}\n}\n\nconst WindowViewSchema = z.object({\n surface: z.literal('window'),\n ...interfaceDeclarationFields('View'),\n dock: z.optional(DockSchema),\n icon: z.optional(z.string()),\n})\n\n/** @public */\nexport type WindowViewDeclaration = z.output<typeof WindowViewSchema>\n\n/** @public */\nexport type DefineWindowViewInput = Omit<WindowViewDeclaration, 'surface'>\n\n/** @public */\nexport function defineWindowView(view: DefineWindowViewInput): WindowViewDeclaration {\n return {...view, surface: 'window'}\n}\n\nconst AssetSourceViewSchema = z.object({\n surface: z.literal('asset_source'),\n ...interfaceDeclarationFields('View'),\n})\n\n/** @public */\nexport type AssetSourceViewDeclaration = z.output<typeof AssetSourceViewSchema>\n\n/** @public */\nexport type DefineAssetSourceViewInput = Omit<AssetSourceViewDeclaration, 'surface'>\n\n/** @public */\nexport function defineAssetSourceView(\n view: DefineAssetSourceViewInput,\n): AssetSourceViewDeclaration {\n return {...view, surface: 'asset_source'}\n}\n\nconst TileViewSchema = z.object({\n surface: z.literal('tile'),\n ...interfaceDeclarationFields('View'),\n /** Sort position within its layout track, ascending. Optional. */\n order: z.optional(z.number()),\n /** Footprint family the dashboard lays the tile out by. */\n size: TileSizeSchema,\n})\n\n/** @public */\nexport type TileViewDeclaration = z.output<typeof TileViewSchema>\n\n/** @public */\nexport type DefineTileViewInput = Omit<TileViewDeclaration, 'surface'>\n\n/** @public */\nexport function defineTileView(view: DefineTileViewInput): TileViewDeclaration {\n return {...view, surface: 'tile'}\n}\n\n/** @internal */\nexport const InterfaceDeclarationSchema = z.discriminatedUnion('surface', [\n WindowViewSchema,\n PanelViewSchema,\n AssetSourceViewSchema,\n TileViewSchema,\n])\n\n/** @public */\nexport type ViewDeclaration = z.output<typeof InterfaceDeclarationSchema>\n\nconst WebWorkerSchema = z.object({\n type: z.literal('worker'),\n ...interfaceDeclarationFields('Web worker'),\n})\n\n/** @public */\nexport type WebWorkerDeclaration = z.output<typeof WebWorkerSchema>\n\n/** @public */\nexport type DefineWebWorkerInput = Omit<WebWorkerDeclaration, 'type'>\n\n/** @public */\nexport function defineWebWorker(webWorker: DefineWebWorkerInput): WebWorkerDeclaration {\n return {...webWorker, type: 'worker'}\n}\n\n/** @internal */\nexport const WebWorkerDeclarationSchema = z.discriminatedUnion('type', [WebWorkerSchema])\n\nconst MediaLibraryFieldSchema = z.object({\n ...extensionDeclarationFields('Field'),\n public: z.optional(z.boolean()),\n title: z.string(),\n})\n\n/**\n * Stamped where the config crosses a boundary so the authoring model doesn't carry a constant discriminator.\n * @internal\n */\nexport const INSTALLATION_CONFIG_TYPE = 'installation_config'\n\n// `appType` is stamped by `unstable_defineMediaLibrary`, never authored.\nconst MediaLibraryConfigSchema = z.object({\n appType: z.literal('media-library'),\n fields: z\n .array(MediaLibraryFieldSchema)\n .check(\n z.refine(\n (fields) => new Set(fields.map((field) => field.name)).size === fields.length,\n 'Field `name` must be unique within a media library',\n ),\n ),\n})\n\nconst DashboardConfigSchema = z.object({\n appType: z.literal('dashboard'),\n src: z.string('Dashboard configuration `src` must be a path to the configuration file'),\n})\n\n/**\n * A workbench config's built value, keyed by `appType`; deploys as a versioned\n * snapshot, not an interface.\n * @internal\n */\nexport const ConfigSchema = z.discriminatedUnion('appType', [\n DashboardConfigSchema,\n MediaLibraryConfigSchema,\n])\n\n/**\n * The config value, keyed by `appType`, the build expands into a federation\n * remote and the deploy summarizes.\n * @internal\n */\nexport type WorkbenchConfigValue = z.output<typeof ConfigSchema>\n\nconst CONFIG_CONTRACT_VERSIONS: Record<WorkbenchConfigValue['appType'], number> = {\n dashboard: DASHBOARD_CONFIG_CONTRACT_VERSION,\n 'media-library': MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION,\n}\n\n/** @internal */\nexport function configContractVersion(appType: WorkbenchConfigValue['appType']): string {\n return String(CONFIG_CONTRACT_VERSIONS[appType])\n}\n"],"names":["z","VIEW_CONTRACT_VERSION","WEB_WORKER_CONTRACT_VERSION","WINDOW_CONTRACT_VERSION","MEDIA_LIBRARY_CONFIG_CONTRACT_VERSION","DASHBOARD_CONFIG_CONTRACT_VERSION","DASHBOARD_CONFIG_TYPE","VIEW_COMPONENTS","asset_source","panel","tile","window","TileSizeSchema","enum","DockGroupSchema","DockSchema","object","group","optional","order","number","PanelDockSchema","ViewPlacementMetadataSchema","dock","icon","string","TileInterfaceMetadataSchema","size","INTERFACE_CONTRACT_VERSIONS","worker","interfaceContractVersion","kind","String","interfaceModuleId","name","Error","extensionDeclarationFields","pattern","check","regex","src","interfaceDeclarationFields","title","PanelViewSchema","surface","literal","definePanelView","view","WindowViewSchema","defineWindowView","AssetSourceViewSchema","defineAssetSourceView","TileViewSchema","defineTileView","InterfaceDeclarationSchema","discriminatedUnion","WebWorkerSchema","type","defineWebWorker","webWorker","WebWorkerDeclarationSchema","MediaLibraryFieldSchema","public","boolean","INSTALLATION_CONFIG_TYPE","MediaLibraryConfigSchema","appType","fields","array","refine","Set","map","field","length","DashboardConfigSchema","ConfigSchema","CONFIG_CONTRACT_VERSIONS","dashboard","configContractVersion"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B,+EAA+E;AAC/E,kEAAkE;AAClE,qCAAqC;AAErC,cAAc,GACd,OAAO,MAAMC,wBAAwB,EAAC;AAEtC,cAAc,GACd,OAAO,MAAMC,8BAA8B,EAAC;AAE5C,cAAc,GACd,OAAO,MAAMC,0BAA0B,EAAC;AAExC,OAAO,MAAMC,wCAAwC,EAAC;AAEtD,OAAO,MAAMC,oCAAoC,EAAC;AAElD,OAAO,MAAMC,wBAAwB,mBAAkB;AAcvD,kGAAkG,GAClG,OAAO,MAAMC,kBAAkB;IAC7BC,cAAc;QAAC;KAAe;IAC9BC,OAAO;QAAC;QAAS;KAAQ;IACzBC,MAAM;QAAC;KAAO;IACdC,QAAQ,EAAE;AACZ,EAAsD;AAKtD;;;;;;CAMC,GACD,OAAO,MAAMC,iBAAiBZ,EAAEa,IAAI,CAAC;IAAC;IAAS;IAAS;CAAS,EAAC;AAclE,MAAMC,kBAAkBd,EAAEa,IAAI,CAAC;IAAC;IAAU;CAAe;AAKzD,cAAc,GACd,OAAO,MAAME,aAAaf,EAAEgB,MAAM,CAAC;IACjCC,OAAOjB,EAAEkB,QAAQ,CAACJ;IAClBK,OAAOnB,EAAEkB,QAAQ,CAAClB,EAAEoB,MAAM;AAC5B,GAAE;AAKF,MAAMC,kBAAkBrB,EAAEgB,MAAM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AiBD;AACnB;AAEA,cAAc,GACd,OAAO,SAAS0E,sBAAsBZ,OAAwC;IAC5E,OAAOlC,OAAO4C,wBAAwB,CAACV,QAAQ;AACjD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dashboardConfig.ts"],"sourcesContent":["import {type CurrentUser} from '@sanity/sdk'\nimport {type View, type ViewApplication} from '@sanity/sdk/dashboard'\n\ninterface ApplicationsContext {\n applications: readonly (ViewApplication & {\n views: readonly View<{includeApplication: false}>[]\n })[]\n currentUser: CurrentUser\n}\n\ninterface DefineDashboardConfigInput {\n applications?: {\n hidden?: (\n references: readonly ViewApplication['reference'][],\n context: ApplicationsContext,\n ) => readonly ViewApplication['reference'][]\n visible?: (\n references: readonly ViewApplication['reference'][],\n context: ApplicationsContext,\n ) => readonly ViewApplication['reference'][]\n }\n views?: (views: readonly View[], context: {currentUser: CurrentUser}) => readonly View[]\n}\n\nexport function defineDashboardConfig(\n config: DefineDashboardConfigInput,\n): DefineDashboardConfigInput {\n return config\n}\n"],"names":["defineDashboardConfig","config"],"mappings":"AAwBA,OAAO,SAASA,sBACdC,MAAkC;IAElC,OAAOA;AACT"}
1
+ {"version":3,"sources":["../src/dashboardConfig.ts"],"sourcesContent":["import {type CurrentUser} from '@sanity/sdk'\nimport {type DashboardApplication, type View} from '@sanity/sdk/dashboard'\n\ninterface ApplicationsContext {\n applications: readonly DashboardApplication[]\n currentUser: CurrentUser\n}\n\ninterface DefineDashboardConfigInput {\n applications?: {\n hidden?: (\n references: readonly DashboardApplication['reference'][],\n context: ApplicationsContext,\n ) => readonly DashboardApplication['reference'][]\n visible?: (\n references: readonly DashboardApplication['reference'][],\n context: ApplicationsContext,\n ) => readonly DashboardApplication['reference'][]\n }\n views?: (views: readonly View[], context: {currentUser: CurrentUser}) => readonly View[]\n}\n\nexport function defineDashboardConfig(\n config: DefineDashboardConfigInput,\n): DefineDashboardConfigInput {\n return config\n}\n"],"names":["defineDashboardConfig","config"],"mappings":"AAsBA,OAAO,SAASA,sBACdC,MAAkC;IAElC,OAAOA;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/applications.ts"],"sourcesContent":["import {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {type AppVisibility, getGlobalCliClient} from '@sanity/cli-core'\nimport {type ImageFile} from '@sanity/cli-core/images'\nimport {isStaging} from '@sanity/cli-core/util'\nimport {type ApplicationBase} from '@sanity/sdk'\nimport FormData from 'form-data'\n\nimport {type TileInterfaceMetadata, type ViewPlacementMetadata} from '../contract.js'\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport type ApplicationType = 'coreApp' | 'studio'\n\nexport type Application = ApplicationBase\n\ninterface BrettInterfaceBase {\n moduleId: string\n name: string\n title: string\n version: string\n}\n\n/**\n * An interface as Brett stores it, discriminated on `type`. `moduleId` is\n * remote-relative — the host prepends the app's id. Brett assigns the id.\n * @internal\n */\nexport type BrettInterface =\n | (BrettInterfaceBase & {metadata: null; type: 'asset_source'})\n | (BrettInterfaceBase & {metadata: null; type: 'worker'})\n | (BrettInterfaceBase & {metadata: TileInterfaceMetadata; type: 'tile'})\n | (BrettInterfaceBase & {metadata: ViewPlacementMetadata | null; type: 'app'})\n | (BrettInterfaceBase & {metadata: ViewPlacementMetadata | null; type: 'panel'})\n\n/**\n * A resource a deployment may interact with, as Brett stores it. Per-deployment\n * and forbidden for singletons (the server 400s).\n */\nexport interface BrettAccess {\n resourceId: string\n resourceType: 'canvas' | 'dashboard' | 'dataset' | 'media-library'\n}\n\n/** A studio workspace as Brett stores it. */\nexport interface BrettWorkspace {\n dataset: string\n projectId: string\n /** Lexicon schema descriptor id; Brett requires one per workspace. */\n schemaDescriptorId: string\n\n basePath?: string\n icon?: string\n name?: string\n subtitle?: string\n title?: string\n}\n\n/**\n * The organization's Dashboard, on its host slug when it has one. Sessions are\n * per origin and the org ID host redirects to the slug host, so a link to the\n * org ID host would make the user sign in again.\n */\nexport function getWorkbenchUrl(organizationId: string, hostSlug?: string | null): string {\n const host = (hostSlug ?? organizationId).toLowerCase()\n return `https://${host}.${isStaging() ? 'run.sanity.work' : 'sanity.run'}`\n}\n\n/** Where a deployed application is served on its organization's workbench. */\nexport function getApplicationUrl(\n application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'>,\n hostSlug?: string | null,\n): string {\n const segment = application.type === 'studio' ? 'studios' : 'applications'\n return `${getWorkbenchUrl(application.organizationId, hostSlug)}/${segment}/${application.slug ?? application.id}`\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\nexport async function getApplication(applicationId: string): Promise<Application | null> {\n const client = await getClient()\n try {\n return await client.request({url: `/applications/${applicationId}`})\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode === 404) return null\n throw err\n }\n}\n\nexport async function getOrganizationApplication(\n organizationId: string,\n idOrSlug: string,\n signal?: AbortSignal,\n): Promise<\n (Application & {activeDeployment: {createdAt: string; deployedBy: string} | null}) | null\n> {\n const client = await getGlobalCliClient({\n apiVersion: APP_WORKBENCH_API_VERSION,\n ignoreWarnings: ['This is an experimental API version', 'which will change without warning'],\n requireUser: true,\n })\n try {\n return await client.request({\n query: {include: 'activeDeployment'},\n signal,\n url: `/organizations/${organizationId}/applications/${idOrSlug}`,\n })\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode === 404) return null\n throw err\n }\n}\n\n/** Every application in an organization, in one page (`limit=none`). */\nexport async function listApplications(organizationId: string): Promise<Application[]> {\n const client = await getClient()\n const {data}: {data: Application[]} = await client.request({\n query: {limit: 'none', organizationId},\n url: '/applications',\n })\n return data\n}\n\n/**\n * Create an application record (no deployment), so the CLI can build with the\n * returned id, then ship it via {@link createDeployment}.\n */\nexport async function createApplication(options: {\n /** The origin a customer serves the build from; Brett then never hosts a bundle for it. */\n externalUrl?: string\n isSingleton?: boolean\n name?: string\n organizationId: string\n projectId?: string\n slug: string\n title: string\n type: ApplicationType\n visibility?: AppVisibility\n}): Promise<Application> {\n const {externalUrl, isSingleton, name, organizationId, projectId, slug, title, type, visibility} =\n options\n const client = await getClient()\n return client.request({\n body: {\n organizationId,\n slug,\n title,\n type,\n // Identity, distinct from the slug address. Omitted → Brett defaults it to slug.\n ...(name ? {name} : {}),\n // Brett requires `isSingleton` on `POST /applications`, so the request\n // builder keeps forwarding it even though the CLI itself never sets it.\n ...(isSingleton === undefined ? {} : {isSingleton}),\n ...(visibility ? {visibility} : {}),\n ...(externalUrl ? {externalUrl} : {}),\n // Studio config is set once, at create — it's immutable on redeploy.\n ...(projectId ? {config: {studio: {projectId}}} : {}),\n },\n method: 'POST',\n url: `/applications`,\n })\n}\n\n/** Mutable application fields the deploy flow patches after create. */\nexport interface ApplicationUpdate {\n /** The address the application is served at; renaming moves it. */\n slug?: string\n title?: string\n visibility?: AppVisibility\n}\n\n// Patch an application's mutable fields.\nexport async function updateApplication(\n applicationId: string,\n update: ApplicationUpdate,\n): Promise<void> {\n const client = await getClient()\n await client.request({body: update, method: 'PATCH', url: `/applications/${applicationId}`})\n}\n\n/** Upload the application's icon, replacing any it has. */\nexport async function setApplicationIcon(applicationId: string, icon: ImageFile): Promise<void> {\n const client = await getClient()\n await client.request({\n body: icon.image,\n headers: {'Content-Type': icon.contentType},\n method: 'PUT',\n url: `/applications/${applicationId}/icon`,\n })\n}\n\n/** Remove the application's icon; removing one that isn't set changes nothing. */\nexport async function removeApplicationIcon(applicationId: string): Promise<void> {\n const client = await getClient()\n await client.request({method: 'DELETE', url: `/applications/${applicationId}/icon`})\n}\n\n/** Upload an app or panel interface's icon, replacing any it has. */\nexport async function setInterfaceIcon(\n applicationId: string,\n interfaceId: string,\n icon: ImageFile,\n): Promise<void> {\n const client = await getClient()\n await client.request({\n body: icon.image,\n headers: {'Content-Type': icon.contentType},\n method: 'PUT',\n url: `/applications/${applicationId}/interfaces/${interfaceId}/icon`,\n })\n}\n\n/**\n * Deploy a new active version to an existing application. `mfManifest` is the\n * build's federation manifest; `tarball` is omitted for an external application,\n * whose build the customer serves themselves.\n */\nexport async function createDeployment(options: {\n access?: readonly BrettAccess[]\n applicationId: string\n interfaces: readonly BrettInterface[]\n isAutoUpdating: boolean\n mfManifest: Record<string, unknown>\n tarball?: Gzip\n version: string\n workspaces?: readonly BrettWorkspace[]\n}): Promise<{id: string; interfaces: {id: string; name: string; type: BrettInterface['type']}[]}> {\n const {\n access,\n applicationId,\n interfaces,\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n } = options\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n appendDeploymentParts(formData, {access, interfaces, mfManifest, tarball, version, workspaces})\n return request(`/applications/${applicationId}/deployments`, formData)\n}\n\n/** Soft-deletes the application and all its deployments; already deleted counts as done. */\nexport async function deleteApplication(applicationId: string): Promise<void> {\n const client = await getClient()\n try {\n await client.request({method: 'DELETE', url: `/applications/${applicationId}`})\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode !== 404) throw err\n }\n}\n\nfunction appendDeploymentParts(\n formData: FormData,\n {\n access,\n interfaces,\n mfManifest,\n tarball,\n version,\n workspaces,\n }: {\n access?: readonly BrettAccess[]\n interfaces: readonly BrettInterface[]\n mfManifest: Record<string, unknown>\n tarball?: Gzip\n version: string\n workspaces?: readonly BrettWorkspace[]\n },\n): void {\n formData.append('version', version)\n appendJson(formData, 'interfaces', interfaces)\n // Studio-only — the server rejects a workspaces part on non-studio types.\n if (workspaces?.length) appendJson(formData, 'workspaces', workspaces)\n // Per-deployment; forbidden for singletons, so callers omit it there.\n if (access?.length) appendJson(formData, 'access', access)\n appendJson(formData, 'mfManifest', mfManifest)\n // Last: the server requires every field part to precede the tarball.\n if (tarball) {\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n }\n}\n\n/** Structured parts must arrive as JSON so the server parses them. */\nfunction appendJson(formData: FormData, name: string, value: unknown): void {\n formData.append(name, JSON.stringify(value), {contentType: 'application/json'})\n}\n\nasync function request<T>(url: string, formData: FormData): Promise<T> {\n const client = await getClient()\n return client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url,\n })\n}\n"],"names":["PassThrough","getGlobalCliClient","isStaging","FormData","APP_WORKBENCH_API_VERSION","getWorkbenchUrl","organizationId","hostSlug","host","toLowerCase","getApplicationUrl","application","segment","type","slug","id","getClient","apiVersion","requireUser","getApplication","applicationId","client","request","url","err","statusCode","getOrganizationApplication","idOrSlug","signal","ignoreWarnings","query","include","listApplications","data","limit","createApplication","options","externalUrl","isSingleton","name","projectId","title","visibility","body","undefined","config","studio","method","updateApplication","update","setApplicationIcon","icon","image","headers","contentType","removeApplicationIcon","setInterfaceIcon","interfaceId","createDeployment","access","interfaces","isAutoUpdating","mfManifest","tarball","version","workspaces","formData","append","toString","appendDeploymentParts","deleteApplication","appendJson","length","filename","value","JSON","stringify","pipe","getHeaders"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAA4BC,kBAAkB,QAAO,mBAAkB;AAEvE,SAAQC,SAAS,QAAO,wBAAuB;AAE/C,OAAOC,cAAc,YAAW;AAGhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAgDzD;;;;CAIC,GACD,OAAO,SAASC,gBAAgBC,cAAsB,EAAEC,QAAwB;IAC9E,MAAMC,OAAO,AAACD,CAAAA,YAAYD,cAAa,EAAGG,WAAW;IACrD,OAAO,CAAC,QAAQ,EAAED,KAAK,CAAC,EAAEN,cAAc,oBAAoB,cAAc;AAC5E;AAEA,4EAA4E,GAC5E,OAAO,SAASQ,kBACdC,WAAyE,EACzEJ,QAAwB;IAExB,MAAMK,UAAUD,YAAYE,IAAI,KAAK,WAAW,YAAY;IAC5D,OAAO,GAAGR,gBAAgBM,YAAYL,cAAc,EAAEC,UAAU,CAAC,EAAEK,QAAQ,CAAC,EAAED,YAAYG,IAAI,IAAIH,YAAYI,EAAE,EAAE;AACpH;AAEA,eAAeC;IACb,OAAOf,mBAAmB;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AM,CAAC,WAAWJ,SAAS;YAACT,aAAa;YAAoBmB,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASF,WAAWL,QAAkB,EAAE3B,IAAY,EAAEmC,KAAc;IAClER,SAASC,MAAM,CAAC5B,MAAMoC,KAAKC,SAAS,CAACF,QAAQ;QAACpB,aAAa;IAAkB;AAC/E;AAEA,eAAehC,QAAWC,GAAW,EAAE2C,QAAkB;IACvD,MAAM7C,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBqB,MAAMuB,SAASW,IAAI,CAAC,IAAI7E;QACxBqD,SAASa,SAASY,UAAU;QAC5B/B,QAAQ;QACRxB;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/services/applications.ts"],"sourcesContent":["import {PassThrough, type Readable} from 'node:stream'\n\nimport {type AppVisibility, getGlobalCliClient} from '@sanity/cli-core'\nimport {type ImageFile} from '@sanity/cli-core/images'\nimport {isStaging} from '@sanity/cli-core/util'\nimport {type ApplicationBase} from '@sanity/sdk'\nimport FormData from 'form-data'\n\nimport {type TileInterfaceMetadata, type ViewPlacementMetadata} from '../contract.js'\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport type ApplicationType = 'coreApp' | 'studio'\n\nexport type Application = ApplicationBase\n\ninterface BrettInterfaceBase {\n moduleId: string\n name: string\n title: string\n version: string\n}\n\n/**\n * An interface as Brett stores it, discriminated on `type`. `moduleId` is\n * remote-relative — the host prepends the app's id. Brett assigns the id.\n * @internal\n */\nexport type BrettInterface =\n | (BrettInterfaceBase & {metadata: null; type: 'asset_source'})\n | (BrettInterfaceBase & {metadata: null; type: 'worker'})\n | (BrettInterfaceBase & {metadata: TileInterfaceMetadata; type: 'tile'})\n | (BrettInterfaceBase & {metadata: ViewPlacementMetadata | null; type: 'app'})\n | (BrettInterfaceBase & {metadata: ViewPlacementMetadata | null; type: 'panel'})\n\n/**\n * A resource a deployment may interact with, as Brett stores it. Per-deployment\n * and forbidden for singletons (the server 400s).\n */\nexport interface BrettAccess {\n resourceId: string\n resourceType: 'canvas' | 'dashboard' | 'dataset' | 'media-library'\n}\n\n/** A studio workspace as Brett stores it. */\nexport interface BrettWorkspace {\n dataset: string\n projectId: string\n /** Lexicon schema descriptor id; Brett requires one per workspace. */\n schemaDescriptorId: string\n\n basePath?: string\n icon?: string\n name?: string\n subtitle?: string\n title?: string\n}\n\n/**\n * The organization's Dashboard, on its host slug when it has one. Sessions are\n * per origin and the org ID host redirects to the slug host, so a link to the\n * org ID host would make the user sign in again.\n */\nexport function getWorkbenchUrl(organizationId: string, hostSlug?: string | null): string {\n const host = (hostSlug ?? organizationId).toLowerCase()\n return `https://${host}.${isStaging() ? 'run.sanity.work' : 'sanity.run'}`\n}\n\n/** Where a deployed application is served on its organization's workbench. */\nexport function getApplicationUrl(\n application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'>,\n hostSlug?: string | null,\n): string {\n const segment = application.type === 'studio' ? 'studios' : 'applications'\n return `${getWorkbenchUrl(application.organizationId, hostSlug)}/${segment}/${application.slug ?? application.id}`\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\nexport async function getApplication(applicationId: string): Promise<Application | null> {\n const client = await getClient()\n try {\n return await client.request({url: `/applications/${applicationId}`})\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode === 404) return null\n throw err\n }\n}\n\nexport async function getOrganizationApplication(\n organizationId: string,\n idOrSlug: string,\n signal?: AbortSignal,\n): Promise<\n (Application & {activeDeployment: {createdAt: string; deployedBy: string} | null}) | null\n> {\n const client = await getGlobalCliClient({\n apiVersion: APP_WORKBENCH_API_VERSION,\n ignoreWarnings: ['This is an experimental API version', 'which will change without warning'],\n requireUser: true,\n })\n try {\n return await client.request({\n query: {include: 'activeDeployment'},\n signal,\n url: `/organizations/${organizationId}/applications/${idOrSlug}`,\n })\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode === 404) return null\n throw err\n }\n}\n\n/** Every application in an organization, in one page (`limit=none`). */\nexport async function listApplications(organizationId: string): Promise<Application[]> {\n const client = await getClient()\n const {data}: {data: Application[]} = await client.request({\n query: {limit: 'none', organizationId},\n url: '/applications',\n })\n return data\n}\n\n/**\n * Create an application record (no deployment), so the CLI can build with the\n * returned id, then ship it via {@link createDeployment}.\n */\nexport async function createApplication(options: {\n /** The origin a customer serves the build from; Brett then never hosts a bundle for it. */\n externalUrl?: string\n isSingleton?: boolean\n name?: string\n organizationId: string\n projectId?: string\n slug: string\n title: string\n type: ApplicationType\n visibility?: AppVisibility\n}): Promise<Application> {\n const {externalUrl, isSingleton, name, organizationId, projectId, slug, title, type, visibility} =\n options\n const client = await getClient()\n return client.request({\n body: {\n organizationId,\n slug,\n title,\n type,\n // Identity, distinct from the slug address. Omitted → Brett defaults it to slug.\n ...(name ? {name} : {}),\n // Brett requires `isSingleton` on `POST /applications`, so the request\n // builder keeps forwarding it even though the CLI itself never sets it.\n ...(isSingleton === undefined ? {} : {isSingleton}),\n ...(visibility ? {visibility} : {}),\n ...(externalUrl ? {externalUrl} : {}),\n // Studio config is set once, at create — it's immutable on redeploy.\n ...(projectId ? {config: {studio: {projectId}}} : {}),\n },\n method: 'POST',\n url: `/applications`,\n })\n}\n\n/** Mutable application fields the deploy flow patches after create. */\nexport interface ApplicationUpdate {\n /** The address the application is served at; renaming moves it. */\n slug?: string\n title?: string\n visibility?: AppVisibility\n}\n\n// Patch an application's mutable fields.\nexport async function updateApplication(\n applicationId: string,\n update: ApplicationUpdate,\n): Promise<void> {\n const client = await getClient()\n await client.request({body: update, method: 'PATCH', url: `/applications/${applicationId}`})\n}\n\n/** Upload the application's icon, replacing any it has. */\nexport async function setApplicationIcon(applicationId: string, icon: ImageFile): Promise<void> {\n const client = await getClient()\n await client.request({\n body: icon.image,\n headers: {'Content-Type': icon.contentType},\n method: 'PUT',\n url: `/applications/${applicationId}/icon`,\n })\n}\n\n/** Remove the application's icon; removing one that isn't set changes nothing. */\nexport async function removeApplicationIcon(applicationId: string): Promise<void> {\n const client = await getClient()\n await client.request({method: 'DELETE', url: `/applications/${applicationId}/icon`})\n}\n\n/** Upload an app or panel interface's icon, replacing any it has. */\nexport async function setInterfaceIcon(\n applicationId: string,\n interfaceId: string,\n icon: ImageFile,\n): Promise<void> {\n const client = await getClient()\n await client.request({\n body: icon.image,\n headers: {'Content-Type': icon.contentType},\n method: 'PUT',\n url: `/applications/${applicationId}/interfaces/${interfaceId}/icon`,\n })\n}\n\n/**\n * Deploy a new active version to an existing application. `mfManifest` is the\n * build's federation manifest; `tarball` is omitted for an external application,\n * whose build the customer serves themselves.\n */\nexport async function createDeployment(options: {\n access?: readonly BrettAccess[]\n applicationId: string\n interfaces: readonly BrettInterface[]\n isAutoUpdating: boolean\n mfManifest: Record<string, unknown>\n tarball?: Readable\n version: string\n workspaces?: readonly BrettWorkspace[]\n}): Promise<{id: string; interfaces: {id: string; name: string; type: BrettInterface['type']}[]}> {\n const {\n access,\n applicationId,\n interfaces,\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n } = options\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n appendDeploymentParts(formData, {access, interfaces, mfManifest, tarball, version, workspaces})\n return request(`/applications/${applicationId}/deployments`, formData)\n}\n\n/** Soft-deletes the application and all its deployments; already deleted counts as done. */\nexport async function deleteApplication(applicationId: string): Promise<void> {\n const client = await getClient()\n try {\n await client.request({method: 'DELETE', url: `/applications/${applicationId}`})\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode !== 404) throw err\n }\n}\n\nfunction appendDeploymentParts(\n formData: FormData,\n {\n access,\n interfaces,\n mfManifest,\n tarball,\n version,\n workspaces,\n }: {\n access?: readonly BrettAccess[]\n interfaces: readonly BrettInterface[]\n mfManifest: Record<string, unknown>\n tarball?: Readable\n version: string\n workspaces?: readonly BrettWorkspace[]\n },\n): void {\n formData.append('version', version)\n appendJson(formData, 'interfaces', interfaces)\n // Studio-only — the server rejects a workspaces part on non-studio types.\n if (workspaces?.length) appendJson(formData, 'workspaces', workspaces)\n // Per-deployment; forbidden for singletons, so callers omit it there.\n if (access?.length) appendJson(formData, 'access', access)\n appendJson(formData, 'mfManifest', mfManifest)\n // Last: the server requires every field part to precede the tarball.\n if (tarball) {\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n }\n}\n\n/** Structured parts must arrive as JSON so the server parses them. */\nfunction appendJson(formData: FormData, name: string, value: unknown): void {\n formData.append(name, JSON.stringify(value), {contentType: 'application/json'})\n}\n\nasync function request<T>(url: string, formData: FormData): Promise<T> {\n const client = await getClient()\n return client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url,\n })\n}\n"],"names":["PassThrough","getGlobalCliClient","isStaging","FormData","APP_WORKBENCH_API_VERSION","getWorkbenchUrl","organizationId","hostSlug","host","toLowerCase","getApplicationUrl","application","segment","type","slug","id","getClient","apiVersion","requireUser","getApplication","applicationId","client","request","url","err","statusCode","getOrganizationApplication","idOrSlug","signal","ignoreWarnings","query","include","listApplications","data","limit","createApplication","options","externalUrl","isSingleton","name","projectId","title","visibility","body","undefined","config","studio","method","updateApplication","update","setApplicationIcon","icon","image","headers","contentType","removeApplicationIcon","setInterfaceIcon","interfaceId","createDeployment","access","interfaces","isAutoUpdating","mfManifest","tarball","version","workspaces","formData","append","toString","appendDeploymentParts","deleteApplication","appendJson","length","filename","value","JSON","stringify","pipe","getHeaders"],"mappings":"AAAA,SAAQA,WAAW,QAAsB,cAAa;AAEtD,SAA4BC,kBAAkB,QAAO,mBAAkB;AAEvE,SAAQC,SAAS,QAAO,wBAAuB;AAE/C,OAAOC,cAAc,YAAW;AAGhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAgDzD;;;;CAIC,GACD,OAAO,SAASC,gBAAgBC,cAAsB,EAAEC,QAAwB;IAC9E,MAAMC,OAAO,AAACD,CAAAA,YAAYD,cAAa,EAAGG,WAAW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sBACPH,QAAkB,EAClB,EACEP,MAAM,EACNC,UAAU,EACVE,UAAU,EACVC,OAAO,EACPC,OAAO,EACPC,UAAU,EAQX;IAEDC,SAASC,MAAM,CAAC,WAAWH;IAC3BO,WAAWL,UAAU,cAAcN;IACnC,0EAA0E;IAC1E,IAAIK,YAAYO,QAAQD,WAAWL,UAAU,cAAcD;IAC3D,sEAAsE;IACtE,IAAIN,QAAQa,QAAQD,WAAWL,UAAU,UAAUP;IACnDY,WAAWL,UAAU,cAAcJ;IACnC,qEAAqE;IACrE,IAAIC,SAAS;QACXG,SAASC,MAAM,CAAC,WAAWJ,SAAS;YAACT,aAAa;YAAoBmB,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASF,WAAWL,QAAkB,EAAE3B,IAAY,EAAEmC,KAAc;IAClER,SAASC,MAAM,CAAC5B,MAAMoC,KAAKC,SAAS,CAACF,QAAQ;QAACpB,aAAa;IAAkB;AAC/E;AAEA,eAAehC,QAAWC,GAAW,EAAE2C,QAAkB;IACvD,MAAM7C,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBqB,MAAMuB,SAASW,IAAI,CAAC,IAAI7E;QACxBqD,SAASa,SAASY,UAAU;QAC5B/B,QAAQ;QACRxB;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/dashboard-configs.ts"],"sourcesContent":["import {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\n\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport interface Dashboard {\n id: string\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\nexport async function getOrganizationDashboard(\n organizationId: string,\n): Promise<Dashboard | undefined> {\n const client = await getClient()\n const {data}: {data: Dashboard[]} = await client.request({\n query: {organizationId},\n url: '/applications/dashboards',\n })\n return data[0]\n}\n\nexport async function createDashboard(organizationId: string): Promise<Dashboard> {\n const client = await getClient()\n return client.request({\n body: {organizationId},\n method: 'POST',\n url: '/applications/dashboards',\n })\n}\n\nexport async function createDashboardConfig(\n dashboardId: string,\n {tarball, version}: {tarball: Gzip; version: string},\n): Promise<void> {\n const formData = new FormData()\n formData.append('version', version)\n formData.append('tarball', tarball, {\n contentType: 'application/gzip',\n filename: 'dashboard-config.tar.gz',\n })\n\n const client = await getClient()\n await client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url: `/applications/dashboards/${dashboardId}/configs`,\n })\n}\n\nexport async function deleteDashboard(dashboardId: string): Promise<void> {\n const client = await getClient()\n await client.request({method: 'DELETE', url: `/applications/dashboards/${dashboardId}`})\n}\n"],"names":["PassThrough","getGlobalCliClient","FormData","APP_WORKBENCH_API_VERSION","getClient","apiVersion","requireUser","getOrganizationDashboard","organizationId","client","data","request","query","url","createDashboard","body","method","createDashboardConfig","dashboardId","tarball","version","formData","append","contentType","filename","pipe","headers","getHeaders","deleteDashboard"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAAQC,kBAAkB,QAAO,mBAAkB;AACnD,OAAOC,cAAc,YAAW;AAEhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAMzD,eAAeC;IACb,OAAOH,mBAAmB;QAACI,YAAYF;QAA2BG,aAAa;IAAI;AACrF;AAEA,OAAO,eAAeC,yBACpBC,cAAsB;IAEtB,MAAMC,SAAS,MAAML;IACrB,MAAM,EAACM,IAAI,EAAC,GAAwB,MAAMD,OAAOE,OAAO,CAAC;QACvDC,OAAO;YAACJ;QAAc;QACtBK,KAAK;IACP;IACA,OAAOH,IAAI,CAAC,EAAE;AAChB;AAEA,OAAO,eAAeI,gBAAgBN,cAAsB;IAC1D,MAAMC,SAAS,MAAML;IACrB,OAAOK,OAAOE,OAAO,CAAC;QACpBI,MAAM;YAACP;QAAc;QACrBQ,QAAQ;QACRH,KAAK;IACP;AACF;AAEA,OAAO,eAAeI,sBACpBC,WAAmB,EACnB,EAACC,OAAO,EAAEC,OAAO,EAAmC;IAEpD,MAAMC,WAAW,IAAInB;IACrBmB,SAASC,MAAM,CAAC,WAAWF;IAC3BC,SAASC,MAAM,CAAC,WAAWH,SAAS;QAClCI,aAAa;QACbC,UAAU;IACZ;IAEA,MAAMf,SAAS,MAAML;IACrB,MAAMK,OAAOE,OAAO,CAAC;QACnBI,MAAMM,SAASI,IAAI,CAAC,IAAIzB;QACxB0B,SAASL,SAASM,UAAU;QAC5BX,QAAQ;QACRH,KAAK,CAAC,yBAAyB,EAAEK,YAAY,QAAQ,CAAC;IACxD;AACF;AAEA,OAAO,eAAeU,gBAAgBV,WAAmB;IACvD,MAAMT,SAAS,MAAML;IACrB,MAAMK,OAAOE,OAAO,CAAC;QAACK,QAAQ;QAAUH,KAAK,CAAC,yBAAyB,EAAEK,aAAa;IAAA;AACxF"}
1
+ {"version":3,"sources":["../../src/services/dashboard-configs.ts"],"sourcesContent":["import {PassThrough, type Readable} from 'node:stream'\n\nimport {getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\n\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport interface Dashboard {\n id: string\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\nexport async function getOrganizationDashboard(\n organizationId: string,\n): Promise<Dashboard | undefined> {\n const client = await getClient()\n const {data}: {data: Dashboard[]} = await client.request({\n query: {organizationId},\n url: '/applications/dashboards',\n })\n return data[0]\n}\n\nexport async function createDashboard(organizationId: string): Promise<Dashboard> {\n const client = await getClient()\n return client.request({\n body: {organizationId},\n method: 'POST',\n url: '/applications/dashboards',\n })\n}\n\nexport async function createDashboardConfig(\n dashboardId: string,\n {tarball, version}: {tarball: Readable; version: string},\n): Promise<void> {\n const formData = new FormData()\n formData.append('version', version)\n formData.append('tarball', tarball, {\n contentType: 'application/gzip',\n filename: 'dashboard-config.tar.gz',\n })\n\n const client = await getClient()\n await client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url: `/applications/dashboards/${dashboardId}/configs`,\n })\n}\n\nexport async function deleteDashboard(dashboardId: string): Promise<void> {\n const client = await getClient()\n await client.request({method: 'DELETE', url: `/applications/dashboards/${dashboardId}`})\n}\n"],"names":["PassThrough","getGlobalCliClient","FormData","APP_WORKBENCH_API_VERSION","getClient","apiVersion","requireUser","getOrganizationDashboard","organizationId","client","data","request","query","url","createDashboard","body","method","createDashboardConfig","dashboardId","tarball","version","formData","append","contentType","filename","pipe","headers","getHeaders","deleteDashboard"],"mappings":"AAAA,SAAQA,WAAW,QAAsB,cAAa;AAEtD,SAAQC,kBAAkB,QAAO,mBAAkB;AACnD,OAAOC,cAAc,YAAW;AAEhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAMzD,eAAeC;IACb,OAAOH,mBAAmB;QAACI,YAAYF;QAA2BG,aAAa;IAAI;AACrF;AAEA,OAAO,eAAeC,yBACpBC,cAAsB;IAEtB,MAAMC,SAAS,MAAML;IACrB,MAAM,EAACM,IAAI,EAAC,GAAwB,MAAMD,OAAOE,OAAO,CAAC;QACvDC,OAAO;YAACJ;QAAc;QACtBK,KAAK;IACP;IACA,OAAOH,IAAI,CAAC,EAAE;AAChB;AAEA,OAAO,eAAeI,gBAAgBN,cAAsB;IAC1D,MAAMC,SAAS,MAAML;IACrB,OAAOK,OAAOE,OAAO,CAAC;QACpBI,MAAM;YAACP;QAAc;QACrBQ,QAAQ;QACRH,KAAK;IACP;AACF;AAEA,OAAO,eAAeI,sBACpBC,WAAmB,EACnB,EAACC,OAAO,EAAEC,OAAO,EAAuC;IAExD,MAAMC,WAAW,IAAInB;IACrBmB,SAASC,MAAM,CAAC,WAAWF;IAC3BC,SAASC,MAAM,CAAC,WAAWH,SAAS;QAClCI,aAAa;QACbC,UAAU;IACZ;IAEA,MAAMf,SAAS,MAAML;IACrB,MAAMK,OAAOE,OAAO,CAAC;QACnBI,MAAMM,SAASI,IAAI,CAAC,IAAIzB;QACxB0B,SAASL,SAASM,UAAU;QAC5BX,QAAQ;QACRH,KAAK,CAAC,yBAAyB,EAAEK,YAAY,QAAQ,CAAC;IACxD;AACF;AAEA,OAAO,eAAeU,gBAAgBV,WAAmB;IACvD,MAAMT,SAAS,MAAML;IACrB,MAAMK,OAAOE,OAAO,CAAC;QAACK,QAAQ;QAAUH,KAAK,CAAC,yBAAyB,EAAEK,aAAa;IAAA;AACxF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/installations.ts"],"sourcesContent":["import {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\n\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport interface ConfigSnapshot {\n id: string\n\n createdAt?: string\n deployedBy?: string\n /** Whether this snapshot is the one being served; at most one per installation. */\n isActive?: boolean\n}\n\ninterface InstallationListItem {\n id: string\n\n application?: {name?: string}\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\n/** The org's active singleton installation, matched on its application name. */\nexport async function resolveSingletonInstallationId(\n organizationId: string,\n appType: string,\n): Promise<string | undefined> {\n const client = await getClient()\n // `limit=none` returns every installation in one response, no pagination.\n const {data}: {data: InstallationListItem[]} = await client.request({\n query: {limit: 'none', organizationId},\n url: '/installations',\n })\n return data.find((item) => item.application?.name === appType)?.id\n}\n\n/** Upload a config snapshot to the installation as a multipart tarball. */\nexport async function createConfig(\n installationId: string,\n {tarball, version}: {tarball: Gzip; version: string},\n): Promise<void> {\n const formData = new FormData()\n formData.append('version', version)\n formData.append('tarball', tarball, {\n contentType: 'application/gzip',\n filename: 'installation-config.tar.gz',\n })\n\n const client = await getClient()\n await client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url: `/installations/${installationId}/configs`,\n })\n}\n\n/** The installation's deployed config snapshots, newest first. */\nexport async function listConfigs(installationId: string): Promise<ConfigSnapshot[]> {\n const client = await getClient()\n const {data}: {data: ConfigSnapshot[]} = await client.request({\n query: {limit: 'none'},\n url: `/installations/${installationId}/configs`,\n })\n return data\n}\n\n/**\n * Soft-deletes one config snapshot; its content is purged once superseded.\n * Already deleted counts as done, so a partially-failed undeploy can re-run.\n */\nexport async function deleteConfig(installationId: string, configId: string): Promise<void> {\n const client = await getClient()\n try {\n await client.request({\n method: 'DELETE',\n url: `/installations/${installationId}/configs/${configId}`,\n })\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode !== 404) throw err\n }\n}\n"],"names":["PassThrough","getGlobalCliClient","FormData","APP_WORKBENCH_API_VERSION","getClient","apiVersion","requireUser","resolveSingletonInstallationId","organizationId","appType","client","data","request","query","limit","url","find","item","application","name","id","createConfig","installationId","tarball","version","formData","append","contentType","filename","body","pipe","headers","getHeaders","method","listConfigs","deleteConfig","configId","err","statusCode"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAAQC,kBAAkB,QAAO,mBAAkB;AACnD,OAAOC,cAAc,YAAW;AAEhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAiBzD,eAAeC;IACb,OAAOH,mBAAmB;QAACI,YAAYF;QAA2BG,aAAa;IAAI;AACrF;AAEA,8EAA8E,GAC9E,OAAO,eAAeC,+BACpBC,cAAsB,EACtBC,OAAe;IAEf,MAAMC,SAAS,MAAMN;IACrB,0EAA0E;IAC1E,MAAM,EAACO,IAAI,EAAC,GAAmC,MAAMD,OAAOE,OAAO,CAAC;QAClEC,OAAO;YAACC,OAAO;YAAQN;QAAc;QACrCO,KAAK;IACP;IACA,OAAOJ,KAAKK,IAAI,CAAC,CAACC,OAASA,KAAKC,WAAW,EAAEC,SAASV,UAAUW;AAClE;AAEA,yEAAyE,GACzE,OAAO,eAAeC,aACpBC,cAAsB,EACtB,EAACC,OAAO,EAAEC,OAAO,EAAmC;IAEpD,MAAMC,WAAW,IAAIvB;IACrBuB,SAASC,MAAM,CAAC,WAAWF;IAC3BC,SAASC,MAAM,CAAC,WAAWH,SAAS;QAClCI,aAAa;QACbC,UAAU;IACZ;IAEA,MAAMlB,SAAS,MAAMN;IACrB,MAAMM,OAAOE,OAAO,CAAC;QACnBiB,MAAMJ,SAASK,IAAI,CAAC,IAAI9B;QACxB+B,SAASN,SAASO,UAAU;QAC5BC,QAAQ;QACRlB,KAAK,CAAC,eAAe,EAAEO,eAAe,QAAQ,CAAC;IACjD;AACF;AAEA,gEAAgE,GAChE,OAAO,eAAeY,YAAYZ,cAAsB;IACtD,MAAMZ,SAAS,MAAMN;IACrB,MAAM,EAACO,IAAI,EAAC,GAA6B,MAAMD,OAAOE,OAAO,CAAC;QAC5DC,OAAO;YAACC,OAAO;QAAM;QACrBC,KAAK,CAAC,eAAe,EAAEO,eAAe,QAAQ,CAAC;IACjD;IACA,OAAOX;AACT;AAEA;;;CAGC,GACD,OAAO,eAAewB,aAAab,cAAsB,EAAEc,QAAgB;IACzE,MAAM1B,SAAS,MAAMN;IACrB,IAAI;QACF,MAAMM,OAAOE,OAAO,CAAC;YACnBqB,QAAQ;YACRlB,KAAK,CAAC,eAAe,EAAEO,eAAe,SAAS,EAAEc,UAAU;QAC7D;IACF,EAAE,OAAOC,KAAK;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,MAAMD;IAChE;AACF"}
1
+ {"version":3,"sources":["../../src/services/installations.ts"],"sourcesContent":["import {PassThrough, type Readable} from 'node:stream'\n\nimport {getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\n\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport interface ConfigSnapshot {\n id: string\n\n createdAt?: string\n deployedBy?: string\n /** Whether this snapshot is the one being served; at most one per installation. */\n isActive?: boolean\n}\n\ninterface InstallationListItem {\n id: string\n\n application?: {name?: string}\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\n/** The org's active singleton installation, matched on its application name. */\nexport async function resolveSingletonInstallationId(\n organizationId: string,\n appType: string,\n): Promise<string | undefined> {\n const client = await getClient()\n // `limit=none` returns every installation in one response, no pagination.\n const {data}: {data: InstallationListItem[]} = await client.request({\n query: {limit: 'none', organizationId},\n url: '/installations',\n })\n return data.find((item) => item.application?.name === appType)?.id\n}\n\n/** Upload a config snapshot to the installation as a multipart tarball. */\nexport async function createConfig(\n installationId: string,\n {tarball, version}: {tarball: Readable; version: string},\n): Promise<void> {\n const formData = new FormData()\n formData.append('version', version)\n formData.append('tarball', tarball, {\n contentType: 'application/gzip',\n filename: 'installation-config.tar.gz',\n })\n\n const client = await getClient()\n await client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url: `/installations/${installationId}/configs`,\n })\n}\n\n/** The installation's deployed config snapshots, newest first. */\nexport async function listConfigs(installationId: string): Promise<ConfigSnapshot[]> {\n const client = await getClient()\n const {data}: {data: ConfigSnapshot[]} = await client.request({\n query: {limit: 'none'},\n url: `/installations/${installationId}/configs`,\n })\n return data\n}\n\n/**\n * Soft-deletes one config snapshot; its content is purged once superseded.\n * Already deleted counts as done, so a partially-failed undeploy can re-run.\n */\nexport async function deleteConfig(installationId: string, configId: string): Promise<void> {\n const client = await getClient()\n try {\n await client.request({\n method: 'DELETE',\n url: `/installations/${installationId}/configs/${configId}`,\n })\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode !== 404) throw err\n }\n}\n"],"names":["PassThrough","getGlobalCliClient","FormData","APP_WORKBENCH_API_VERSION","getClient","apiVersion","requireUser","resolveSingletonInstallationId","organizationId","appType","client","data","request","query","limit","url","find","item","application","name","id","createConfig","installationId","tarball","version","formData","append","contentType","filename","body","pipe","headers","getHeaders","method","listConfigs","deleteConfig","configId","err","statusCode"],"mappings":"AAAA,SAAQA,WAAW,QAAsB,cAAa;A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B,SAAS,MAAMN;IACrB,IAAI;QACF,MAAMM,OAAOE,OAAO,CAAC;YACnBqB,QAAQ;YACRlB,KAAK,CAAC,eAAe,EAAEO,eAAe,SAAS,EAAEc,UAAU;QAC7D;IACF,EAAE,OAAOC,KAAK;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,MAAMD;IAChE;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/workbench-cli",
3
- "version": "2.22.0",
3
+ "version": "2.22.2",
4
4
  "description": "Internal implementation detail of the Sanity CLI's unstable workbench support. Not intended for direct use.",
5
5
  "homepage": "https://github.com/sanity-io/cli",
6
6
  "bugs": "https://github.com/sanity-io/cli/issues",
@@ -68,15 +68,15 @@
68
68
  "@module-federation/runtime": "2.9.4",
69
69
  "@module-federation/vite": "1.25.1",
70
70
  "@sanity/cli-core": "^3.18.0",
71
- "@sanity/sdk": "^3.17.0",
72
- "@sanity/types": "^6.25.0",
73
- "@vitejs/plugin-react": "^6.3.0",
71
+ "@sanity/sdk": "^3.18.0",
72
+ "@sanity/types": "^6.26.0",
73
+ "@vitejs/plugin-react": "^6.3.1",
74
74
  "form-data": "^4.0.6",
75
75
  "open": "^11.0.4",
76
76
  "rxjs": "^7.8.2",
77
77
  "semver": "^7.8.6",
78
- "tar": "^7.5.23",
79
- "vite": "^8.4.0",
78
+ "tar": "^8.0.2",
79
+ "vite": "^8.4.1",
80
80
  "zod": "^4.6.7"
81
81
  },
82
82
  "devDependencies": {
@@ -87,8 +87,8 @@
87
87
  "@sanity/pkg-utils": "^12.3.4",
88
88
  "@swc/cli": "^0.8.2",
89
89
  "@swc/core": "^1.16.22",
90
- "@types/node": "^22.20.5",
91
- "@types/react": "^19.3.0",
90
+ "@types/node": "^22.20.7",
91
+ "@types/react": "^19.3.3",
92
92
  "@types/semver": "^7.8.0",
93
93
  "@vitest/coverage-istanbul": "^5.1.1",
94
94
  "jsdom": "^29.1.1",