@sanity/workbench-cli 2.21.0 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/build.d.ts +10 -3
- package/dist/_exports/build.js +2 -0
- package/dist/_exports/build.js.map +1 -1
- package/dist/_exports/{defineApp-COehpvlC.d.ts → defineApp-DUi9ZfpT.d.ts} +3 -2
- package/dist/_exports/deploy.d.ts +11 -6
- package/dist/_exports/deploy.js +1 -1
- package/dist/_exports/deploy.js.map +1 -1
- package/dist/_exports/{deploySummary-DU7_Vcyq.d.ts → deploySummary-BPgEW1qt.d.ts} +22 -5
- package/dist/_exports/dev.d.ts +2 -2
- package/dist/_exports/index.d.ts +5 -9
- package/dist/_exports/preview.d.ts +1 -1
- package/dist/_exports/{registry-Da2PAcT1.d.ts → registry-DysyB1F6.d.ts} +2 -2
- package/dist/_exports/{resolveWorkbenchApp-Bn0tsSDM.d.ts → resolveWorkbenchApp-C_rqQBQP.d.ts} +2 -2
- package/dist/_exports/{resolveWorkbenchConfig-DkrkqN9H.d.ts → resolveWorkbenchConfig-C_o8npN0.d.ts} +2 -2
- package/dist/_exports/undeploy.d.ts +2 -2
- package/dist/actions/build/buildSummary.js +34 -0
- package/dist/actions/build/buildSummary.js.map +1 -0
- package/dist/actions/deploy/deploySummary.js +25 -8
- package/dist/actions/deploy/deploySummary.js.map +1 -1
- package/dist/actions/dev/devSummary.js +12 -0
- package/dist/actions/dev/devSummary.js.map +1 -1
- package/dist/actions/dev/startWorkbenchDev.js +2 -15
- package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
- package/dist/actions/preview/startWorkbenchPreview.js +28 -7
- package/dist/actions/preview/startWorkbenchPreview.js.map +1 -1
- package/dist/actions/summary.js +3 -4
- package/dist/actions/summary.js.map +1 -1
- package/dist/actions/undeploy/workbenchUndeployAdapter.js +8 -3
- package/dist/actions/undeploy/workbenchUndeployAdapter.js.map +1 -1
- package/dist/dashboardConfig.js.map +1 -1
- package/dist/services/applications.js +10 -5
- package/dist/services/applications.js.map +1 -1
- package/dist/services/organizations.js +2 -1
- package/dist/services/organizations.js.map +1 -1
- package/package.json +10 -10
package/dist/_exports/build.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
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";
|
|
4
|
+
import { CliConfig } from "@sanity/cli-core";
|
|
3
5
|
import { InlineConfig, PluginOption } from "vite";
|
|
6
|
+
/** Starts the organization and deployment lookup beside a `sanity build`; `undefined` outside the Dashboard. */
|
|
7
|
+
declare function startBuildSummary({ cliConfig, isApp }: {
|
|
8
|
+
cliConfig: CliConfig;
|
|
9
|
+
isApp: boolean;
|
|
10
|
+
}): (() => Promise<string>) | undefined;
|
|
4
11
|
/**
|
|
5
12
|
* Resolves to the parsed federation manifest in `sourceDir`. A workbench build
|
|
6
13
|
* may also emit a standalone `index.html`, so the manifest, not `index.html`,
|
|
@@ -129,5 +136,5 @@ declare function workbenchVitePlugins(options: WorkbenchViteOptions): Promise<Pl
|
|
|
129
136
|
* its own id from the applications API.
|
|
130
137
|
*/
|
|
131
138
|
declare function buildAppId(app: ResolvedWorkbenchApp): Promise<string>;
|
|
132
|
-
export { 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, workbenchOptimizeDeps, workbenchVitePlugins };
|
|
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 };
|
|
133
140
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/_exports/build.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
// resolver the build reads declared views/web workers from. The build needs no
|
|
4
4
|
// deploy-time guards, so it takes the bare `resolveWorkbenchApp` — the guarded
|
|
5
5
|
// view (`getWorkbench`) is the deploy entry's export.
|
|
6
|
+
export { startBuildSummary } from '../actions/build/buildSummary.js';
|
|
6
7
|
export { readBuiltManifest } from '../actions/build/readBuiltManifest.js';
|
|
7
8
|
export { RESOURCE_BINDINGS_CHUNK_NAME, RESOURCE_BINDINGS_ENTRY_IMPORT, RESOURCE_BINDINGS_FILENAME, RESOURCE_BINDINGS_MODULE_SOURCE, RESOURCE_BINDINGS_TOKEN, resourceBindingsChunkFileName, resourceBindingsCodeSplittingGroup } from '../actions/build/resource-bindings.js';
|
|
8
9
|
export { buildFederatedApp } from '../actions/build/vite/discover-shared-dependencies.js';
|
|
9
10
|
export { workbenchOptimizeDeps } from '../actions/build/vite/optimize-deps.js';
|
|
10
11
|
export { workbenchVitePlugins } from '../actions/build/vite/workbench-vite-plugins.js';
|
|
11
12
|
export { buildAppId } from '../appId.js';
|
|
13
|
+
export { DASHBOARD_CONFIG_CONTRACT_VERSION } from '../contract.js';
|
|
12
14
|
export { resolveAppEntry, resolveWorkbenchApp } from '../resolveWorkbenchApp.js';
|
|
13
15
|
export { resolveWorkbenchConfig } from '../resolveWorkbenchConfig.js';
|
|
14
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 {readBuiltManifest} from '../actions/build/readBuiltManifest.js'\nexport {\n RESOURCE_BINDINGS_CHUNK_NAME,\n RESOURCE_BINDINGS_ENTRY_IMPORT,\n RESOURCE_BINDINGS_FILENAME,\n RESOURCE_BINDINGS_MODULE_SOURCE,\n RESOURCE_BINDINGS_TOKEN,\n resourceBindingsChunkFileName,\n resourceBindingsCodeSplittingGroup,\n} from '../actions/build/resource-bindings.js'\nexport {buildFederatedApp} from '../actions/build/vite/discover-shared-dependencies.js'\nexport {workbenchOptimizeDeps} from '../actions/build/vite/optimize-deps.js'\nexport {workbenchVitePlugins} from '../actions/build/vite/workbench-vite-plugins.js'\nexport {buildAppId} from '../appId.js'\nexport {\n resolveAppEntry,\n resolveWorkbenchApp,\n type WorkbenchExposes,\n} from '../resolveWorkbenchApp.js'\nexport {resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\n"],"names":["readBuiltManifest","RESOURCE_BINDINGS_CHUNK_NAME","RESOURCE_BINDINGS_ENTRY_IMPORT","RESOURCE_BINDINGS_FILENAME","RESOURCE_BINDINGS_MODULE_SOURCE","RESOURCE_BINDINGS_TOKEN","resourceBindingsChunkFileName","resourceBindingsCodeSplittingGroup","buildFederatedApp","workbenchOptimizeDeps","workbenchVitePlugins","buildAppId","resolveAppEntry","resolveWorkbenchApp","resolveWorkbenchConfig"],"mappings":"AAAA,iEAAiE;AACjE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AAEtD,SAAQA,iBAAiB,QAAO,wCAAuC;AACvE,SACEC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,uBAAuB,EACvBC,6BAA6B,EAC7BC,kCAAkC,QAC7B,wCAAuC;AAC9C,SAAQC,iBAAiB,QAAO,wDAAuD;AACvF,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,oBAAoB,QAAO,kDAAiD;AACpF,SAAQC,UAAU,QAAO,cAAa;AACtC,SACEC,eAAe,EACfC,mBAAmB,QAEd,4BAA2B;AAClC,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 {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,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 DASHBOARD_CONFIG_CONTRACT_VERSION = 1;
|
|
4
5
|
/**
|
|
5
6
|
* A view component. The return is opaque so the runtime helpers carry no React
|
|
6
7
|
* dependency — the generated artifact renders it with the app's own React.
|
|
@@ -372,5 +373,5 @@ declare function isWorkbenchConfig(app: unknown): app is WorkbenchConfig;
|
|
|
372
373
|
*/
|
|
373
374
|
declare function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): MediaLibraryConfig;
|
|
374
375
|
declare function defineDashboard(input: DefineDashboardInput): DashboardConfig;
|
|
375
|
-
export {
|
|
376
|
-
//# sourceMappingURL=defineApp-
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as resolveWorkbenchConfig } from "./resolveWorkbenchConfig-
|
|
3
|
-
import { a as
|
|
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";
|
|
4
4
|
import { AppVisibility, CliConfig } from "@sanity/cli-core";
|
|
5
5
|
import { ImageFile } from "@sanity/cli-core/images";
|
|
6
6
|
import "node:zlib";
|
|
@@ -76,9 +76,14 @@ interface BrettWorkspace {
|
|
|
76
76
|
subtitle?: string;
|
|
77
77
|
title?: string;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The organization's Dashboard, on its host slug when it has one. Sessions are
|
|
81
|
+
* per origin and the org ID host redirects to the slug host, so a link to the
|
|
82
|
+
* org ID host would make the user sign in again.
|
|
83
|
+
*/
|
|
84
|
+
declare function getWorkbenchUrl(organizationId: string, hostSlug?: string | null): string;
|
|
80
85
|
/** Where a deployed application is served on its organization's workbench. */
|
|
81
|
-
declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'
|
|
86
|
+
declare function getApplicationUrl(application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'>, hostSlug?: string | null): string;
|
|
82
87
|
declare function getApplication(applicationId: string): Promise<Application | null>;
|
|
83
88
|
/** Every application in an organization, in one page (`limit=none`). */
|
|
84
89
|
declare function listApplications(organizationId: string): Promise<Application[]>;
|
|
@@ -191,5 +196,5 @@ interface AppIcon extends ImageFile {
|
|
|
191
196
|
* @internal
|
|
192
197
|
*/
|
|
193
198
|
declare function readAppIcon(workDir: string, iconPath: string): Promise<AppIcon>;
|
|
194
|
-
export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplication, getApplicationUrl, getOrganizationDashboard, getWorkbench, getWorkbenchUrl, listApplications, readAppIcon, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, summarizeInterfaces, toWorkbenchPayload, uploadDashboardConfig };
|
|
199
|
+
export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, fetchOrganizationSummary, formatDeploySummary, getApplication, getApplicationUrl, getOrganizationDashboard, getWorkbench, getWorkbenchUrl, listApplications, readAppIcon, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, summarizeInterfaces, toWorkbenchPayload, uploadDashboardConfig };
|
|
195
200
|
//# sourceMappingURL=deploy.d.ts.map
|
package/dist/_exports/deploy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { deployConfig, resolveInstallationId, summarizeConfig } from '../actions/deploy/deployConfig.js';
|
|
2
2
|
export { toWorkbenchPayload } from '../actions/deploy/deployPayload.js';
|
|
3
|
-
export { fetchDeploySummaryDetails, formatDeploySummary } from '../actions/deploy/deploySummary.js';
|
|
3
|
+
export { fetchDeploySummaryDetails, fetchOrganizationSummary, formatDeploySummary } from '../actions/deploy/deploySummary.js';
|
|
4
4
|
export { createCoreApp, createStudio, deployWorkbenchApp } from '../actions/deploy/deployWorkbenchApp.js';
|
|
5
5
|
export { getWorkbench } from '../actions/deploy/getWorkbench.js';
|
|
6
6
|
export { selectWorkbenchAppId } from '../actions/deploy/selectWorkbenchAppId.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {fetchDeploySummaryDetails
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {\n fetchDeploySummaryDetails,\n fetchOrganizationSummary,\n formatDeploySummary,\n} from '../actions/deploy/deploySummary.js'\nexport {\n createCoreApp,\n type CreatedApplication,\n createStudio,\n deployWorkbenchApp,\n} from '../actions/deploy/deployWorkbenchApp.js'\nexport {getWorkbench} from '../actions/deploy/getWorkbench.js'\nexport {selectWorkbenchAppId} from '../actions/deploy/selectWorkbenchAppId.js'\nexport {\n type DeployedInterface,\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../actions/deploy/summarizeInterfaces.js'\nexport {uploadDashboardConfig} from '../actions/deploy/uploadDashboardConfig.js'\nexport {readAppIcon} from '../readAppIcon.js'\nexport {resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\nexport {getOrganizationDashboard} from '../services/dashboard-configs.js'\n"],"names":["deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","fetchDeploySummaryDetails","fetchOrganizationSummary","formatDeploySummary","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","selectWorkbenchAppId","summarizeInterfaces","uploadDashboardConfig","readAppIcon","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications","getOrganizationDashboard"],"mappings":"AAAA,SACEA,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SACEC,yBAAyB,EACzBC,wBAAwB,EACxBC,mBAAmB,QACd,qCAAoC;AAC3C,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,oBAAoB,QAAO,4CAA2C;AAC9E,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAQC,qBAAqB,QAAO,6CAA4C;AAChF,SAAQC,WAAW,QAAO,oBAAmB;AAC7C,SAAQC,sBAAsB,QAAO,+BAA8B;AACnE,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B;AACpC,SAAQC,wBAAwB,QAAO,mCAAkC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as WorkbenchExposes, t as ResolvedWorkbenchApp } from "./resolveWorkbenchApp-
|
|
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";
|
|
3
3
|
import { CliConfig } from "@sanity/cli-core";
|
|
4
4
|
import { z } from "zod/mini";
|
|
5
5
|
/**
|
|
@@ -61,7 +61,21 @@ declare function summarizeInterfaces({ views, webWorkers }: WorkbenchExposes): {
|
|
|
61
61
|
services: DeployedWebWorker[];
|
|
62
62
|
views: DeployedView[];
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The organization's name, and its host slug for Dashboard URLs. A failed or
|
|
66
|
+
* slow (over 3s) lookup reads as `null`, so a deploy falls back to the org ID
|
|
67
|
+
* host instead of failing.
|
|
68
|
+
*/
|
|
69
|
+
declare function fetchOrganizationSummary(organizationId: string): Promise<{
|
|
70
|
+
hostSlug: string | null;
|
|
71
|
+
organizationName: string | null;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* The organization and deployer for a deploy's summary. Pass the command's
|
|
75
|
+
* {@link fetchOrganizationSummary} lookup to share it rather than look the org up again.
|
|
76
|
+
*/
|
|
77
|
+
declare function fetchDeploySummaryDetails(organizationId: string, organization?: ReturnType<typeof fetchOrganizationSummary>): Promise<{
|
|
78
|
+
hostSlug: string | null;
|
|
65
79
|
organizationName: string | null;
|
|
66
80
|
userName: string | null;
|
|
67
81
|
}>;
|
|
@@ -85,7 +99,10 @@ declare function formatUndeploySummary(options: {
|
|
|
85
99
|
organizationId: string;
|
|
86
100
|
organizationName?: string | null;
|
|
87
101
|
title: string;
|
|
102
|
+
/** Omitted for a config, which has no app or studio of its own to name. */
|
|
103
|
+
type?: 'coreApp' | 'studio';
|
|
88
104
|
url: string;
|
|
105
|
+
userName?: string | null;
|
|
89
106
|
}): string;
|
|
90
|
-
export {
|
|
91
|
-
//# sourceMappingURL=deploySummary-
|
|
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
|
package/dist/_exports/dev.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as DevServerManifest } from "./registry-
|
|
2
|
-
import { ViteDevServer } from "vite";
|
|
1
|
+
import { t as DevServerManifest } from "./registry-DysyB1F6.js";
|
|
3
2
|
import { CliConfig, Output } from "@sanity/cli-core";
|
|
3
|
+
import { ViteDevServer } from "vite";
|
|
4
4
|
/**
|
|
5
5
|
* Minimal shape the supervisor needs back from a started app/studio dev server.
|
|
6
6
|
* The not-started arm is reserved for expected early exits the server already
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
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 { 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
|
|
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
|
|
16
|
-
visible?: (references: readonly
|
|
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-
|
|
1
|
+
import { t as DevServerManifest } from "./registry-DysyB1F6.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-
|
|
1
|
+
import "./defineApp-DUi9ZfpT.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-
|
|
139
|
+
//# sourceMappingURL=registry-DysyB1F6.d.ts.map
|
package/dist/_exports/{resolveWorkbenchApp-Bn0tsSDM.d.ts → resolveWorkbenchApp-C_rqQBQP.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as WorkbenchConfigValue, n as DefineAppInput } from "./defineApp-DUi9ZfpT.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-
|
|
53
|
+
//# sourceMappingURL=resolveWorkbenchApp-C_rqQBQP.d.ts.map
|
package/dist/_exports/{resolveWorkbenchConfig-DkrkqN9H.d.ts → resolveWorkbenchConfig-C_o8npN0.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as WorkbenchConfig } from "./defineApp-
|
|
1
|
+
import { l as WorkbenchConfig } from "./defineApp-DUi9ZfpT.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-
|
|
10
|
+
//# sourceMappingURL=resolveWorkbenchConfig-C_o8npN0.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as WorkbenchConfig } from "./defineApp-
|
|
2
|
-
import {
|
|
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
3
|
import "node:zlib";
|
|
4
4
|
import { UndeployAdapter, UndeployApplicationTarget, UndeployConfigTarget } from "@sanity/cli-core/undeploy";
|
|
5
5
|
interface ConfigSnapshot {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isWorkbenchApp, resolveAppTitle } from '../../defineApp.js';
|
|
2
|
+
import { resolveWorkbenchConfig } from '../../resolveWorkbenchConfig.js';
|
|
3
|
+
import { fetchDevSummaryDetails, formatLocalVersion } from '../dev/devSummary.js';
|
|
4
|
+
import { formatSummary } from '../summary.js';
|
|
5
|
+
const CONFIG_TITLES = {
|
|
6
|
+
dashboard: 'Dashboard configuration',
|
|
7
|
+
'media-library': 'Media Library configuration'
|
|
8
|
+
};
|
|
9
|
+
/** Starts the organization and deployment lookup beside a `sanity build`; `undefined` outside the Dashboard. */ export function startBuildSummary({ cliConfig, isApp }) {
|
|
10
|
+
const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined;
|
|
11
|
+
const config = resolveWorkbenchConfig(cliConfig);
|
|
12
|
+
const title = app ? resolveAppTitle(app) : config && CONFIG_TITLES[config.appType];
|
|
13
|
+
if (!title) return undefined;
|
|
14
|
+
const startedAt = Date.now();
|
|
15
|
+
const organizationId = cliConfig.app?.organizationId;
|
|
16
|
+
const details = fetchDevSummaryDetails({
|
|
17
|
+
idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),
|
|
18
|
+
organizationId
|
|
19
|
+
});
|
|
20
|
+
return async ()=>{
|
|
21
|
+
const durationMs = Date.now() - startedAt;
|
|
22
|
+
const { deployment, organizationName } = await details;
|
|
23
|
+
return formatSummary({
|
|
24
|
+
durationMs,
|
|
25
|
+
heading: `${title} built`,
|
|
26
|
+
isApp,
|
|
27
|
+
organization: organizationName ?? organizationId,
|
|
28
|
+
title: app && title,
|
|
29
|
+
version: formatLocalVersion('local build', deployment)
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=buildSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildSummary.ts"],"sourcesContent":["import {type CliConfig} from '@sanity/cli-core'\n\nimport {isWorkbenchApp, resolveAppTitle} from '../../defineApp.js'\nimport {resolveWorkbenchConfig} from '../../resolveWorkbenchConfig.js'\nimport {fetchDevSummaryDetails, formatLocalVersion} from '../dev/devSummary.js'\nimport {formatSummary} from '../summary.js'\n\nconst CONFIG_TITLES = {\n dashboard: 'Dashboard configuration',\n 'media-library': 'Media Library configuration',\n}\n\n/** Starts the organization and deployment lookup beside a `sanity build`; `undefined` outside the Dashboard. */\nexport function startBuildSummary({\n cliConfig,\n isApp,\n}: {\n cliConfig: CliConfig\n isApp: boolean\n}): (() => Promise<string>) | undefined {\n const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined\n const config = resolveWorkbenchConfig(cliConfig)\n const title = app ? resolveAppTitle(app) : config && CONFIG_TITLES[config.appType]\n if (!title) return undefined\n\n const startedAt = Date.now()\n const organizationId = cliConfig.app?.organizationId\n const details = fetchDevSummaryDetails({\n idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),\n organizationId,\n })\n\n return async () => {\n const durationMs = Date.now() - startedAt\n const {deployment, organizationName} = await details\n\n return formatSummary({\n durationMs,\n heading: `${title} built`,\n isApp,\n organization: organizationName ?? organizationId,\n title: app && title,\n version: formatLocalVersion('local build', deployment),\n })\n }\n}\n"],"names":["isWorkbenchApp","resolveAppTitle","resolveWorkbenchConfig","fetchDevSummaryDetails","formatLocalVersion","formatSummary","CONFIG_TITLES","dashboard","startBuildSummary","cliConfig","isApp","app","undefined","config","title","appType","startedAt","Date","now","organizationId","details","idOrSlug","deployment","appId","slug","durationMs","organizationName","heading","organization","version"],"mappings":"AAEA,SAAQA,cAAc,EAAEC,eAAe,QAAO,qBAAoB;AAClE,SAAQC,sBAAsB,QAAO,kCAAiC;AACtE,SAAQC,sBAAsB,EAAEC,kBAAkB,QAAO,uBAAsB;AAC/E,SAAQC,aAAa,QAAO,gBAAe;AAE3C,MAAMC,gBAAgB;IACpBC,WAAW;IACX,iBAAiB;AACnB;AAEA,8GAA8G,GAC9G,OAAO,SAASC,kBAAkB,EAChCC,SAAS,EACTC,KAAK,EAIN;IACC,MAAMC,MAAMX,eAAeS,UAAUE,GAAG,IAAIF,UAAUE,GAAG,GAAGC;IAC5D,MAAMC,SAASX,uBAAuBO;IACtC,MAAMK,QAAQH,MAAMV,gBAAgBU,OAAOE,UAAUP,aAAa,CAACO,OAAOE,OAAO,CAAC;IAClF,IAAI,CAACD,OAAO,OAAOF;IAEnB,MAAMI,YAAYC,KAAKC,GAAG;IAC1B,MAAMC,iBAAiBV,UAAUE,GAAG,EAAEQ;IACtC,MAAMC,UAAUjB,uBAAuB;QACrCkB,UAAUV,OAAQF,CAAAA,UAAUa,UAAU,EAAEC,SAASZ,IAAIa,IAAI,AAAD;QACxDL;IACF;IAEA,OAAO;QACL,MAAMM,aAAaR,KAAKC,GAAG,KAAKF;QAChC,MAAM,EAACM,UAAU,EAAEI,gBAAgB,EAAC,GAAG,MAAMN;QAE7C,OAAOf,cAAc;YACnBoB;YACAE,SAAS,GAAGb,MAAM,MAAM,CAAC;YACzBJ;YACAkB,cAAcF,oBAAoBP;YAClCL,OAAOH,OAAOG;YACde,SAASzB,mBAAmB,eAAekB;QAC7C;IACF;AACF"}
|
|
@@ -3,13 +3,27 @@ import { logSymbols } from '@sanity/cli-core/ux';
|
|
|
3
3
|
import { getOrganization } from '../../services/organizations.js';
|
|
4
4
|
import { getCurrentUser } from '../../services/users.js';
|
|
5
5
|
import { formatSummary, SUMMARY_LOOKUP_TIMEOUT_MS } from '../summary.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The organization's name, and its host slug for Dashboard URLs. A failed or
|
|
8
|
+
* slow (over 3s) lookup reads as `null`, so a deploy falls back to the org ID
|
|
9
|
+
* host instead of failing.
|
|
10
|
+
*/ export async function fetchOrganizationSummary(organizationId) {
|
|
11
|
+
const organization = await getOrganization(organizationId, AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS)).catch(()=>null);
|
|
12
|
+
return {
|
|
13
|
+
hostSlug: organization?.slug ?? null,
|
|
14
|
+
organizationName: organization?.name ?? null
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The organization and deployer for a deploy's summary. Pass the command's
|
|
19
|
+
* {@link fetchOrganizationSummary} lookup to share it rather than look the org up again.
|
|
20
|
+
*/ export async function fetchDeploySummaryDetails(organizationId, organization) {
|
|
21
|
+
const [{ hostSlug, organizationName }, userName] = await Promise.all([
|
|
22
|
+
organization ?? fetchOrganizationSummary(organizationId),
|
|
23
|
+
getCurrentUser(AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS)).then((user)=>user.name).catch(()=>null)
|
|
11
24
|
]);
|
|
12
25
|
return {
|
|
26
|
+
hostSlug,
|
|
13
27
|
organizationName,
|
|
14
28
|
userName
|
|
15
29
|
};
|
|
@@ -42,14 +56,17 @@ export function formatUndeploySummary(options) {
|
|
|
42
56
|
const summary = formatSummary({
|
|
43
57
|
durationMs: options.durationMs,
|
|
44
58
|
heading: `${options.title} undeployed`,
|
|
45
|
-
isApp:
|
|
59
|
+
isApp: options.type === 'coreApp',
|
|
46
60
|
organization: options.organizationName ?? options.organizationId,
|
|
47
|
-
|
|
61
|
+
title: options.type ? options.title : undefined,
|
|
62
|
+
url: options.url,
|
|
63
|
+
version: options.userName ? `removed just now by ${options.userName}` : 'removed just now'
|
|
48
64
|
});
|
|
49
65
|
const success = styleText('green', ` ${logSymbols.success} Deleted ${options.title}.`);
|
|
66
|
+
const appIdHint = options.type ? `\n ${styleText('dim', 'Remove')} deployment.appId ${styleText('dim', 'from sanity.cli.ts so the next deploy creates a new one')}\n` : '';
|
|
50
67
|
return `${summary}
|
|
51
68
|
${success}
|
|
52
|
-
`;
|
|
69
|
+
${appIdHint}`;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
//# sourceMappingURL=deploySummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deploySummary.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {logSymbols} from '@sanity/cli-core/ux'\n\nimport {getOrganization} from '../../services/organizations.js'\nimport {getCurrentUser} from '../../services/users.js'\nimport {formatSummary, SUMMARY_LOOKUP_TIMEOUT_MS} from '../summary.js'\n\nexport async function
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deploySummary.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {logSymbols} from '@sanity/cli-core/ux'\n\nimport {getOrganization} from '../../services/organizations.js'\nimport {getCurrentUser} from '../../services/users.js'\nimport {formatSummary, SUMMARY_LOOKUP_TIMEOUT_MS} from '../summary.js'\n\n/**\n * The organization's name, and its host slug for Dashboard URLs. A failed or\n * slow (over 3s) lookup reads as `null`, so a deploy falls back to the org ID\n * host instead of failing.\n */\nexport async function fetchOrganizationSummary(organizationId: string) {\n const organization = await getOrganization(\n organizationId,\n AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS),\n ).catch(() => null)\n\n return {hostSlug: organization?.slug ?? null, organizationName: organization?.name ?? null}\n}\n\n/**\n * The organization and deployer for a deploy's summary. Pass the command's\n * {@link fetchOrganizationSummary} lookup to share it rather than look the org up again.\n */\nexport async function fetchDeploySummaryDetails(\n organizationId: string,\n organization?: ReturnType<typeof fetchOrganizationSummary>,\n) {\n const [{hostSlug, organizationName}, userName] = await Promise.all([\n organization ?? fetchOrganizationSummary(organizationId),\n getCurrentUser(AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS))\n .then((user) => user.name)\n .catch(() => null),\n ])\n\n return {hostSlug, organizationName, userName}\n}\n\nconst CREATED_AS = {config: '', coreApp: ' as a new application', studio: ' as a new studio'}\n\nexport function formatDeploySummary(\n options: (\n | {applicationId: string; showAppIdHint: boolean; type: 'coreApp' | 'studio'}\n | {type: 'config'}\n ) & {\n created: boolean\n durationMs: number\n organizationId: string\n organizationName?: string | null\n title: string\n url: string\n userName?: string | null\n },\n): string {\n const {created, durationMs, title, url, userName} = options\n\n const summary = formatSummary({\n durationMs,\n heading: `${title} deployed`,\n isApp: options.type === 'coreApp',\n organization: options.organizationName ?? options.organizationId,\n // A config has no app or studio of its own to name.\n title: options.type === 'config' ? undefined : title,\n url,\n version: userName ? `just now by ${userName}` : 'just now',\n })\n const result = created ? `Created ${title}${CREATED_AS[options.type]}.` : `Updated ${title}.`\n const success = styleText('green', ` ${logSymbols.success} ${result}`)\n const appIdHint =\n options.type !== 'config' && options.showAppIdHint\n ? `\\n ${styleText('dim', 'Add')} deployment.appId: \"${options.applicationId}\" ${styleText('dim', 'to sanity.cli.ts so the next deploy updates it')}\\n`\n : ''\n\n return `${summary}\n${success}\n${appIdHint}`\n}\n\nexport function formatUndeploySummary(options: {\n durationMs: number\n organizationId: string\n organizationName?: string | null\n title: string\n /** Omitted for a config, which has no app or studio of its own to name. */\n type?: 'coreApp' | 'studio'\n url: string\n userName?: string | null\n}): string {\n const summary = formatSummary({\n durationMs: options.durationMs,\n heading: `${options.title} undeployed`,\n isApp: options.type === 'coreApp',\n organization: options.organizationName ?? options.organizationId,\n title: options.type ? options.title : undefined,\n url: options.url,\n version: options.userName ? `removed just now by ${options.userName}` : 'removed just now',\n })\n const success = styleText('green', ` ${logSymbols.success} Deleted ${options.title}.`)\n const appIdHint = options.type\n ? `\\n ${styleText('dim', 'Remove')} deployment.appId ${styleText('dim', 'from sanity.cli.ts so the next deploy creates a new one')}\\n`\n : ''\n\n return `${summary}\n${success}\n${appIdHint}`\n}\n"],"names":["styleText","logSymbols","getOrganization","getCurrentUser","formatSummary","SUMMARY_LOOKUP_TIMEOUT_MS","fetchOrganizationSummary","organizationId","organization","AbortSignal","timeout","catch","hostSlug","slug","organizationName","name","fetchDeploySummaryDetails","userName","Promise","all","then","user","CREATED_AS","config","coreApp","studio","formatDeploySummary","options","created","durationMs","title","url","summary","heading","isApp","type","undefined","version","result","success","appIdHint","showAppIdHint","applicationId","formatUndeploySummary"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,UAAU,QAAO,sBAAqB;AAE9C,SAAQC,eAAe,QAAO,kCAAiC;AAC/D,SAAQC,cAAc,QAAO,0BAAyB;AACtD,SAAQC,aAAa,EAAEC,yBAAyB,QAAO,gBAAe;AAEtE;;;;CAIC,GACD,OAAO,eAAeC,yBAAyBC,cAAsB;IACnE,MAAMC,eAAe,MAAMN,gBACzBK,gBACAE,YAAYC,OAAO,CAACL,4BACpBM,KAAK,CAAC,IAAM;IAEd,OAAO;QAACC,UAAUJ,cAAcK,QAAQ;QAAMC,kBAAkBN,cAAcO,QAAQ;IAAI;AAC5F;AAEA;;;CAGC,GACD,OAAO,eAAeC,0BACpBT,cAAsB,EACtBC,YAA0D;IAE1D,MAAM,CAAC,EAACI,QAA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V,EAAEC,WAAW;AACb;AAEA,OAAO,SAASG,sBAAsBhB,OASrC;IACC,MAAMK,UAAU5B,cAAc;QAC5ByB,YAAYF,QAAQE,UAAU;QAC9BI,SAAS,GAAGN,QAAQG,KAAK,CAAC,WAAW,CAAC;QACtCI,OAAOP,QAAQQ,IAAI,KAAK;QACxB3B,cAAcmB,QAAQb,gBAAgB,IAAIa,QAAQpB,cAAc;QAChEuB,OAAOH,QAAQQ,IAAI,GAAGR,QAAQG,KAAK,GAAGM;QACtCL,KAAKJ,QAAQI,GAAG;QAChBM,SAASV,QAAQV,QAAQ,GAAG,CAAC,oBAAoB,EAAEU,QAAQV,QAAQ,EAAE,GAAG;IAC1E;IACA,MAAMsB,UAAUvC,UAAU,SAAS,CAAC,EAAE,EAAEC,WAAWsC,OAAO,CAAC,SAAS,EAAEZ,QAAQG,KAAK,CAAC,CAAC,CAAC;IACtF,MAAMU,YAAYb,QAAQQ,IAAI,GAC1B,CAAC,IAAI,EAAEnC,UAAU,OAAO,UAAU,kBAAkB,EAAEA,UAAU,OAAO,2DAA2D,EAAE,CAAC,GACrI;IAEJ,OAAO,GAAGgC,QAAQ;AACpB,EAAEO,QAAQ;AACV,EAAEC,WAAW;AACb"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
1
2
|
import { spinner } from '@sanity/cli-core/ux';
|
|
2
3
|
import { getOrganizationApplication } from '../../services/applications.js';
|
|
3
4
|
import { getOrganization } from '../../services/organizations.js';
|
|
@@ -45,5 +46,16 @@ export async function waitForDevSummaryDetails(details) {
|
|
|
45
46
|
spin.stop();
|
|
46
47
|
return result;
|
|
47
48
|
}
|
|
49
|
+
export function formatLocalVersion(label, deployment) {
|
|
50
|
+
if (deployment === null) return `${label} ${styleText('dim', '· not deployed')}`;
|
|
51
|
+
if (!deployment) return '';
|
|
52
|
+
const date = new Date(deployment.createdAt).toLocaleDateString('en-US', {
|
|
53
|
+
day: 'numeric',
|
|
54
|
+
month: 'short',
|
|
55
|
+
year: 'numeric'
|
|
56
|
+
});
|
|
57
|
+
const by = deployment.deployedBy ? ` by ${deployment.deployedBy}` : '';
|
|
58
|
+
return `${label} ${styleText('dim', `· deployed ${date}${by}`)}`;
|
|
59
|
+
}
|
|
48
60
|
|
|
49
61
|
//# sourceMappingURL=devSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/dev/devSummary.ts"],"sourcesContent":["import {spinner} from '@sanity/cli-core/ux'\n\nimport {getOrganizationApplication} from '../../services/applications.js'\nimport {getOrganization} from '../../services/organizations.js'\nimport {getUser} from '../../services/users.js'\nimport {SUMMARY_LOOKUP_TIMEOUT_MS} from '../summary.js'\n\nconst PENDING = Symbol('pending')\n\nexport interface DevSummaryDetails {\n /** `null` when the app has no active deployment, `undefined` when the lookup failed or was skipped. */\n deployment?: {createdAt: string; deployedBy: string | null} | null\n organizationName?: string | null\n}\n\nexport async function fetchDevSummaryDetails({\n idOrSlug,\n organizationId,\n}: {\n idOrSlug?: string\n organizationId?: string\n}): Promise<DevSummaryDetails> {\n if (!organizationId) return {}\n\n const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS)\n const organizationName = getOrganization(organizationId, signal)\n .then((org) => org.name)\n .catch(() => null)\n\n if (!idOrSlug) {\n return {organizationName: await organizationName}\n }\n\n let deployment: DevSummaryDetails['deployment']\n\n try {\n const application = await getOrganizationApplication(organizationId, idOrSlug, signal)\n const active = application?.activeDeployment\n\n if (active) {\n const deployedBy = await getUser(active.deployedBy, signal)\n .then((user) => user.displayName)\n .catch(() => null)\n deployment = {createdAt: active.createdAt, deployedBy}\n } else {\n deployment = null\n }\n } catch {\n // Left undefined: a failed lookup must not read as \"not deployed\".\n }\n\n return {deployment, organizationName: await organizationName}\n}\n\nexport async function waitForDevSummaryDetails(\n details: Promise<DevSummaryDetails>,\n): Promise<DevSummaryDetails> {\n const settled = await Promise.race([\n details,\n new Promise<typeof PENDING>((resolve) => setImmediate(resolve, PENDING)),\n ])\n\n if (settled !== PENDING) return settled\n\n const spin = spinner('Loading organization and deployment details').start()\n const result = await details\n spin.stop()\n\n return result\n}\n"],"names":["spinner","getOrganizationApplication","getOrganization","getUser","SUMMARY_LOOKUP_TIMEOUT_MS","PENDING","Symbol","fetchDevSummaryDetails","idOrSlug","organizationId","signal","AbortSignal","timeout","organizationName","then","org","name","catch","deployment","application","active","activeDeployment","deployedBy","user","displayName","createdAt","waitForDevSummaryDetails","details","settled","Promise","race","resolve","setImmediate","spin","start","result","stop"],"mappings":"AAAA,SAAQA,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,0BAA0B,QAAO,iCAAgC;AACzE,SAAQC,eAAe,QAAO,kCAAiC;AAC/D,SAAQC,OAAO,QAAO,0BAAyB;AAC/C,SAAQC,yBAAyB,QAAO,gBAAe;AAEvD,MAAMC,UAAUC,OAAO;AAQvB,OAAO,eAAeC,uBAAuB,EAC3CC,QAAQ,EACRC,cAAc,EAIf;IACC,IAAI,CAACA,gBAAgB,OAAO,CAAC;IAE7B,MAAMC,SAASC,YAAYC,OAAO,CAACR;IACnC,MAAMS,mBAAmBX,gBAAgBO,gBAAgBC,QACtDI,IAAI,CAAC,CAACC,MAAQA,IAAIC,IAAI,EACtBC,KAAK,CAAC,IAAM;IAEf,IAAI,CAACT,UAAU;QACb,OAAO;YAACK,kBAAkB,MAAMA;QAAgB;IAClD;IAEA,IAAIK;IAEJ,IAAI;QACF,MAAMC,cAAc,MAAMlB,2BAA2BQ,gBAAgBD,UAAUE;QAC/E,MAAMU,SAASD,aAAaE;QAE5B,IAAID,QAAQ;YACV,MAAME,aAAa,MAAMnB,QAAQiB,OAAOE,UAAU,EAAEZ,QACjDI,IAAI,CAAC,CAACS,OAASA,KAAKC,WAAW,EAC/BP,KAAK,CAAC,IAAM;YACfC,aAAa;gBAACO,WAAWL,OAAOK,SAAS;gBAAEH;YAAU;QACvD,OAAO;YACLJ,aAAa;QACf;IACF,EAAE,OAAM;IACN,mEAAmE;IACrE;IAEA,OAAO;QAACA;QAAYL,kBAAkB,MAAMA;IAAgB;AAC9D;AAEA,OAAO,eAAea,yBACpBC,OAAmC;IAEnC,MAAMC,UAAU,MAAMC,QAAQC,IAAI,CAAC;QACjCH;QACA,IAAIE,QAAwB,CAACE,UAAYC,aAAaD,SAAS1B;KAChE;IAED,IAAIuB,YAAYvB,SAAS,OAAOuB;IAEhC,MAAMK,OAAOjC,QAAQ,+CAA+CkC,KAAK;IACzE,MAAMC,SAAS,MAAMR;IACrBM,KAAKG,IAAI;IAET,OAAOD;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/dev/devSummary.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {getOrganizationApplication} from '../../services/applications.js'\nimport {getOrganization} from '../../services/organizations.js'\nimport {getUser} from '../../services/users.js'\nimport {SUMMARY_LOOKUP_TIMEOUT_MS} from '../summary.js'\n\nconst PENDING = Symbol('pending')\n\nexport interface DevSummaryDetails {\n /** `null` when the app has no active deployment, `undefined` when the lookup failed or was skipped. */\n deployment?: {createdAt: string; deployedBy: string | null} | null\n organizationName?: string | null\n}\n\nexport async function fetchDevSummaryDetails({\n idOrSlug,\n organizationId,\n}: {\n idOrSlug?: string\n organizationId?: string\n}): Promise<DevSummaryDetails> {\n if (!organizationId) return {}\n\n const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS)\n const organizationName = getOrganization(organizationId, signal)\n .then((org) => org.name)\n .catch(() => null)\n\n if (!idOrSlug) {\n return {organizationName: await organizationName}\n }\n\n let deployment: DevSummaryDetails['deployment']\n\n try {\n const application = await getOrganizationApplication(organizationId, idOrSlug, signal)\n const active = application?.activeDeployment\n\n if (active) {\n const deployedBy = await getUser(active.deployedBy, signal)\n .then((user) => user.displayName)\n .catch(() => null)\n deployment = {createdAt: active.createdAt, deployedBy}\n } else {\n deployment = null\n }\n } catch {\n // Left undefined: a failed lookup must not read as \"not deployed\".\n }\n\n return {deployment, organizationName: await organizationName}\n}\n\nexport async function waitForDevSummaryDetails(\n details: Promise<DevSummaryDetails>,\n): Promise<DevSummaryDetails> {\n const settled = await Promise.race([\n details,\n new Promise<typeof PENDING>((resolve) => setImmediate(resolve, PENDING)),\n ])\n\n if (settled !== PENDING) return settled\n\n const spin = spinner('Loading organization and deployment details').start()\n const result = await details\n spin.stop()\n\n return result\n}\n\nexport function formatLocalVersion(\n label: string,\n deployment: DevSummaryDetails['deployment'],\n): string {\n if (deployment === null) return `${label} ${styleText('dim', '· not deployed')}`\n if (!deployment) return ''\n\n const date = new Date(deployment.createdAt).toLocaleDateString('en-US', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n const by = deployment.deployedBy ? ` by ${deployment.deployedBy}` : ''\n\n return `${label} ${styleText('dim', `· deployed ${date}${by}`)}`\n}\n"],"names":["styleText","spinner","getOrganizationApplication","getOrganization","getUser","SUMMARY_LOOKUP_TIMEOUT_MS","PENDING","Symbol","fetchDevSummaryDetails","idOrSlug","organizationId","signal","AbortSignal","timeout","organizationName","then","org","name","catch","deployment","application","active","activeDeployment","deployedBy","user","displayName","createdAt","waitForDevSummaryDetails","details","settled","Promise","race","resolve","setImmediate","spin","start","result","stop","formatLocalVersion","label","date","Date","toLocaleDateString","day","month","year","by"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,0BAA0B,QAAO,iCAAgC;AACzE,SAAQC,eAAe,QAAO,kCAAiC;AAC/D,SAAQC,OAAO,QAAO,0BAAyB;AAC/C,SAAQC,yBAAyB,QAAO,gBAAe;AAEvD,MAAMC,UAAUC,OAAO;AAQvB,OAAO,eAAeC,uBAAuB,EAC3CC,QAAQ,EACRC,cAAc,EAIf;IACC,IAAI,CAACA,gBAAgB,OAAO,CAAC;IAE7B,MAAMC,SAASC,YAAYC,OAAO,CAACR;IACnC,MAAMS,mBAAmBX,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EAAE,GAAG;IAEpE,OAAO,GAAGgB,MAAM,CAAC,EAAEvC,UAAU,OAAO,CAAC,WAAW,EAAEwC,OAAOM,IAAI,GAAG;AAClE"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { styleText } from 'node:util';
|
|
2
1
|
import { isWorkbenchApp, resolveAppTitle } from '../../defineApp.js';
|
|
3
2
|
import { createServerLifecycle, toDisplayHost } from '../../util/serverOrchestration.js';
|
|
4
3
|
import { formatSummary } from '../summary.js';
|
|
5
4
|
import { startAppServerSupervisor } from './appServerSupervisor.js';
|
|
6
5
|
import { bindDevShortcuts } from './bindDevShortcuts.js';
|
|
7
|
-
import { fetchDevSummaryDetails, waitForDevSummaryDetails } from './devSummary.js';
|
|
6
|
+
import { fetchDevSummaryDetails, formatLocalVersion, waitForDevSummaryDetails } from './devSummary.js';
|
|
8
7
|
import { startDevServerRegistration } from './startDevServerRegistration.js';
|
|
9
8
|
import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './startWorkbenchDevServer.js';
|
|
10
9
|
/**
|
|
@@ -109,18 +108,6 @@ import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './star
|
|
|
109
108
|
installSignalHandlers();
|
|
110
109
|
if (workbench.workbenchAvailable) {
|
|
111
110
|
const url = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`;
|
|
112
|
-
let version = '';
|
|
113
|
-
if (deployment) {
|
|
114
|
-
const date = new Date(deployment.createdAt).toLocaleDateString('en-US', {
|
|
115
|
-
day: 'numeric',
|
|
116
|
-
month: 'short',
|
|
117
|
-
year: 'numeric'
|
|
118
|
-
});
|
|
119
|
-
const by = deployment.deployedBy ? ` by ${deployment.deployedBy}` : '';
|
|
120
|
-
version = `local preview ${styleText('dim', `· deployed ${date}${by}`)}`;
|
|
121
|
-
} else if (deployment === null) {
|
|
122
|
-
version = `local preview ${styleText('dim', '· not deployed')}`;
|
|
123
|
-
}
|
|
124
111
|
output.log(formatSummary({
|
|
125
112
|
durationMs,
|
|
126
113
|
heading: 'Sanity Dashboard ready',
|
|
@@ -128,7 +115,7 @@ import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './star
|
|
|
128
115
|
organization: organizationName ?? organizationId,
|
|
129
116
|
title: app && resolveAppTitle(app),
|
|
130
117
|
url,
|
|
131
|
-
version
|
|
118
|
+
version: formatLocalVersion('local preview', deployment)
|
|
132
119
|
}));
|
|
133
120
|
const quit = ()=>void close().then(()=>process.exit(0));
|
|
134
121
|
closers.push(bindDevShortcuts({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/dev/startWorkbenchDev.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type CliConfig, type Output} from '@sanity/cli-core'\n\nimport {isWorkbenchApp, resolveAppTitle} from '../../defineApp.js'\nimport {createServerLifecycle, toDisplayHost} from '../../util/serverOrchestration.js'\nimport {formatSummary} from '../summary.js'\nimport {type AppServerResult, startAppServerSupervisor} from './appServerSupervisor.js'\nimport {bindDevShortcuts} from './bindDevShortcuts.js'\nimport {fetchDevSummaryDetails, waitForDevSummaryDetails} from './devSummary.js'\nimport {type DevServerManifest} from './registry.js'\nimport {startDevServerRegistration} from './startDevServerRegistration.js'\nimport {\n startWorkbenchDevServer,\n startWorkbenchRemoteCoordinator,\n} from './startWorkbenchDevServer.js'\n\nexport interface StartWorkbenchDevOptions {\n /** Directory for the workbench Vite server's dependency cache. */\n cacheDir: string\n /** CLI-domain `app.id`/`deployment.appId` deprecation check, run before registering. */\n checkForDeprecatedAppId: () => void\n cliConfig: CliConfig\n /** Extract the project manifest to inline into the registry (studio-vs-app handled by the CLI). */\n extractManifest: (params: {\n applicationId?: string\n configPath: string\n /** Where the app server serves the app's icon. */\n iconUrl?: string\n workDir: string\n }) => Promise<DevServerManifest['manifest']>\n httpHost: string | undefined\n httpPort: number\n isApp: boolean\n output: Output\n reactStrictMode: boolean\n /** Start the app/studio dev server — the CLI owns the server, this orchestrates it. */\n startAppServer: (params: {\n cliConfig: CliConfig\n httpPort: number\n isRestarting?: boolean\n quiet?: boolean\n }) => Promise<AppServerResult>\n workDir: string\n}\n\n/**\n * Orchestrate the dev servers a workbench project needs: a singleton workbench\n * Vite server plus the app/studio dev server it renders, wired to the dev-server\n * registry so view/web worker edits re-sync live.\n *\n * A running workbench claims the configured port, so the app server binds the\n * next one. If the workbench can't start (package or port unavailable), the app\n * server falls back to the configured port and announces its own URL, exactly as\n * a plain `sanity dev` would.\n */\nexport async function startWorkbenchDev(\n options: StartWorkbenchDevOptions,\n): Promise<{close: () => Promise<void>}> {\n const {\n cacheDir,\n checkForDeprecatedAppId,\n cliConfig,\n extractManifest,\n httpHost,\n httpPort,\n isApp,\n output,\n reactStrictMode,\n startAppServer,\n workDir,\n } = options\n\n // The remote can't render itself, so it runs as a plain app server (not the\n // shell) that still bridges the registry.\n if (process.env.SANITY_INTERNAL_IS_WORKBENCH_REMOTE === 'true') {\n const remote = await startAppServer({cliConfig, httpPort})\n if (!remote.started) return {close: async () => {}}\n\n const coordinator = startWorkbenchRemoteCoordinator({server: remote.server})\n\n return {\n close: async () => {\n await coordinator.close()\n await remote.close()\n },\n }\n }\n\n // Unwound in reverse on any failure or on close(): the watcher stops before\n // the app server, and the supervisor waits out an in-flight rebuild.\n const {close, closers, installSignalHandlers} = createServerLifecycle()\n const startedAt = Date.now()\n const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined\n const organizationId = cliConfig.app?.organizationId\n const details = fetchDevSummaryDetails({\n idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),\n organizationId,\n })\n\n const workbench = await startWorkbenchDevServer({\n cacheDir,\n cliConfig,\n httpHost,\n httpPort,\n output,\n reactStrictMode,\n workDir,\n })\n closers.push(workbench.close)\n\n // A running workbench owns the configured port; the app server takes the next.\n // Without one it claims the configured port and announces its own URL.\n const appPort = workbench.workbenchAvailable ? workbench.workbenchPort + 1 : httpPort\n\n const supervised = await startAppServerSupervisor({\n cliConfig,\n start: (config, {isRestarting} = {}) =>\n startAppServer({\n cliConfig: config,\n httpPort: appPort,\n isRestarting,\n quiet: workbench.workbenchAvailable,\n }),\n workDir,\n }).catch(async (err) => {\n await close()\n throw err\n })\n\n if (!supervised.started) {\n // The app server already reported why (e.g. missing organization id). Hand\n // back a close that releases the workbench lock; nothing else came up.\n return {close}\n }\n const {supervisor} = supervised\n closers.push(supervisor.close)\n\n let dashboardAppPath: string | undefined\n try {\n // The deprecated-id check and manifest extractor are CLI-domain, injected here.\n checkForDeprecatedAppId()\n const registration = await startDevServerRegistration({\n cliConfig,\n extractManifest,\n isApp,\n onInterfaceSetChange: () => supervisor.rebuild(),\n output,\n server: supervisor.server,\n workDir,\n })\n closers.push(registration.close)\n dashboardAppPath = registration.path\n } catch (err) {\n // Registration runs after both servers are up; a failure here would leak the\n // workbench lock and dev servers without this teardown.\n await close()\n throw err\n }\n\n const durationMs = Date.now() - startedAt\n const {deployment, organizationName} = workbench.workbenchAvailable\n ? await waitForDevSummaryDetails(details)\n : {}\n\n installSignalHandlers()\n\n if (workbench.workbenchAvailable) {\n const url = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`\n let version = ''\n\n if (deployment) {\n const date = new Date(deployment.createdAt).toLocaleDateString('en-US', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n const by = deployment.deployedBy ? ` by ${deployment.deployedBy}` : ''\n version = `local preview ${styleText('dim', `· deployed ${date}${by}`)}`\n } else if (deployment === null) {\n version = `local preview ${styleText('dim', '· not deployed')}`\n }\n\n output.log(\n formatSummary({\n durationMs,\n heading: 'Sanity Dashboard ready',\n isApp,\n organization: organizationName ?? organizationId,\n title: app && resolveAppTitle(app),\n url,\n version,\n }),\n )\n\n const quit = () => void close().then(() => process.exit(0))\n closers.push(bindDevShortcuts({output, quit, url}))\n }\n\n return {close}\n}\n"],"names":["styleText","isWorkbenchApp","resolveAppTitle","createServerLifecycle","toDisplayHost","formatSummary","startAppServerSupervisor","bindDevShortcuts","fetchDevSummaryDetails","waitForDevSummaryDetails","startDevServerRegistration","startWorkbenchDevServer","startWorkbenchRemoteCoordinator","startWorkbenchDev","options","cacheDir","checkForDeprecatedAppId","cliConfig","extractManifest","httpHost","httpPort","isApp","output","reactStrictMode","startAppServer","workDir","process","env","SANITY_INTERNAL_IS_WORKBENCH_REMOTE","remote","started","close","coordinator","server","closers","installSignalHandlers","startedAt","Date","now","app","undefined","organizationId","details","idOrSlug","deployment","appId","slug","workbench","push","appPort","workbenchAvailable","workbenchPort","supervised","start","config","isRestarting","quiet","catch","err","supervisor","dashboardAppPath","registration","onInterfaceSetChange","rebuild","path","durationMs","organizationName","url","version","date","createdAt","toLocaleDateString","day","month","year","by","deployedBy","log","heading","organization","title","quit","then","exit"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAInC,SAAQC,cAAc,EAAEC,eAAe,QAAO,qBAAoB;AAClE,SAAQC,qBAAqB,EAAEC,aAAa,QAAO,oCAAmC;AACtF,SAAQC,aAAa,QAAO,gBAAe;AAC3C,SAA8BC,wBAAwB,QAAO,2BAA0B;AACvF,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,sBAAsB,EAAEC,wBAAwB,QAAO,kBAAiB;AAEhF,SAAQC,0BAA0B,QAAO,kCAAiC;AAC1E,SACEC,uBAAuB,EACvBC,+BAA+B,QAC1B,+BAA8B;AA+BrC;;;;;;;;;CASC,GACD,OAAO,eAAeC,kBACpBC,OAAiC;IAEjC,MAAM,EACJC,QAAQ,EACRC,uBAAuB,EACvBC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,eAAe,EACfC,cAAc,EACdC,OAAO,EACR,GAAGX;IAEJ,4EAA4E;IAC5E,0CAA0C;IAC1C,IAAIY,QAAQC,GAAG,CAACC,mCAAmC,KAAK,QAAQ;QAC9D,MAAMC,SAAS,MAAML,eAA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YACA0D,cAAcb,oBAAoBzB;YAClCuC,OAAOzC,OAAOrC,gBAAgBqC;YAC9B4B;YACAC;QACF;QAGF,MAAMa,OAAO,IAAM,KAAKlD,QAAQmD,IAAI,CAAC,IAAMxD,QAAQyD,IAAI,CAAC;QACxDjD,QAAQc,IAAI,CAACzC,iBAAiB;YAACe;YAAQ2D;YAAMd;QAAG;IAClD;IAEA,OAAO;QAACpC;IAAK;AACf"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/dev/startWorkbenchDev.ts"],"sourcesContent":["import {type CliConfig, type Output} from '@sanity/cli-core'\n\nimport {isWorkbenchApp, resolveAppTitle} from '../../defineApp.js'\nimport {createServerLifecycle, toDisplayHost} from '../../util/serverOrchestration.js'\nimport {formatSummary} from '../summary.js'\nimport {type AppServerResult, startAppServerSupervisor} from './appServerSupervisor.js'\nimport {bindDevShortcuts} from './bindDevShortcuts.js'\nimport {fetchDevSummaryDetails, formatLocalVersion, waitForDevSummaryDetails} from './devSummary.js'\nimport {type DevServerManifest} from './registry.js'\nimport {startDevServerRegistration} from './startDevServerRegistration.js'\nimport {\n startWorkbenchDevServer,\n startWorkbenchRemoteCoordinator,\n} from './startWorkbenchDevServer.js'\n\nexport interface StartWorkbenchDevOptions {\n /** Directory for the workbench Vite server's dependency cache. */\n cacheDir: string\n /** CLI-domain `app.id`/`deployment.appId` deprecation check, run before registering. */\n checkForDeprecatedAppId: () => void\n cliConfig: CliConfig\n /** Extract the project manifest to inline into the registry (studio-vs-app handled by the CLI). */\n extractManifest: (params: {\n applicationId?: string\n configPath: string\n /** Where the app server serves the app's icon. */\n iconUrl?: string\n workDir: string\n }) => Promise<DevServerManifest['manifest']>\n httpHost: string | undefined\n httpPort: number\n isApp: boolean\n output: Output\n reactStrictMode: boolean\n /** Start the app/studio dev server — the CLI owns the server, this orchestrates it. */\n startAppServer: (params: {\n cliConfig: CliConfig\n httpPort: number\n isRestarting?: boolean\n quiet?: boolean\n }) => Promise<AppServerResult>\n workDir: string\n}\n\n/**\n * Orchestrate the dev servers a workbench project needs: a singleton workbench\n * Vite server plus the app/studio dev server it renders, wired to the dev-server\n * registry so view/web worker edits re-sync live.\n *\n * A running workbench claims the configured port, so the app server binds the\n * next one. If the workbench can't start (package or port unavailable), the app\n * server falls back to the configured port and announces its own URL, exactly as\n * a plain `sanity dev` would.\n */\nexport async function startWorkbenchDev(\n options: StartWorkbenchDevOptions,\n): Promise<{close: () => Promise<void>}> {\n const {\n cacheDir,\n checkForDeprecatedAppId,\n cliConfig,\n extractManifest,\n httpHost,\n httpPort,\n isApp,\n output,\n reactStrictMode,\n startAppServer,\n workDir,\n } = options\n\n // The remote can't render itself, so it runs as a plain app server (not the\n // shell) that still bridges the registry.\n if (process.env.SANITY_INTERNAL_IS_WORKBENCH_REMOTE === 'true') {\n const remote = await startAppServer({cliConfig, httpPort})\n if (!remote.started) return {close: async () => {}}\n\n const coordinator = startWorkbenchRemoteCoordinator({server: remote.server})\n\n return {\n close: async () => {\n await coordinator.close()\n await remote.close()\n },\n }\n }\n\n // Unwound in reverse on any failure or on close(): the watcher stops before\n // the app server, and the supervisor waits out an in-flight rebuild.\n const {close, closers, installSignalHandlers} = createServerLifecycle()\n const startedAt = Date.now()\n const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined\n const organizationId = cliConfig.app?.organizationId\n const details = fetchDevSummaryDetails({\n idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),\n organizationId,\n })\n\n const workbench = await startWorkbenchDevServer({\n cacheDir,\n cliConfig,\n httpHost,\n httpPort,\n output,\n reactStrictMode,\n workDir,\n })\n closers.push(workbench.close)\n\n // A running workbench owns the configured port; the app server takes the next.\n // Without one it claims the configured port and announces its own URL.\n const appPort = workbench.workbenchAvailable ? workbench.workbenchPort + 1 : httpPort\n\n const supervised = await startAppServerSupervisor({\n cliConfig,\n start: (config, {isRestarting} = {}) =>\n startAppServer({\n cliConfig: config,\n httpPort: appPort,\n isRestarting,\n quiet: workbench.workbenchAvailable,\n }),\n workDir,\n }).catch(async (err) => {\n await close()\n throw err\n })\n\n if (!supervised.started) {\n // The app server already reported why (e.g. missing organization id). Hand\n // back a close that releases the workbench lock; nothing else came up.\n return {close}\n }\n const {supervisor} = supervised\n closers.push(supervisor.close)\n\n let dashboardAppPath: string | undefined\n try {\n // The deprecated-id check and manifest extractor are CLI-domain, injected here.\n checkForDeprecatedAppId()\n const registration = await startDevServerRegistration({\n cliConfig,\n extractManifest,\n isApp,\n onInterfaceSetChange: () => supervisor.rebuild(),\n output,\n server: supervisor.server,\n workDir,\n })\n closers.push(registration.close)\n dashboardAppPath = registration.path\n } catch (err) {\n // Registration runs after both servers are up; a failure here would leak the\n // workbench lock and dev servers without this teardown.\n await close()\n throw err\n }\n\n const durationMs = Date.now() - startedAt\n const {deployment, organizationName} = workbench.workbenchAvailable\n ? await waitForDevSummaryDetails(details)\n : {}\n\n installSignalHandlers()\n\n if (workbench.workbenchAvailable) {\n const url = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`\n\n output.log(\n formatSummary({\n durationMs,\n heading: 'Sanity Dashboard ready',\n isApp,\n organization: organizationName ?? organizationId,\n title: app && resolveAppTitle(app),\n url,\n version: formatLocalVersion('local preview', deployment),\n }),\n )\n\n const quit = () => void close().then(() => process.exit(0))\n closers.push(bindDevShortcuts({output, quit, url}))\n }\n\n return {close}\n}\n"],"names":["isWorkbenchApp","resolveAppTitle","createServerLifecycle","toDisplayHost","formatSummary","startAppServerSupervisor","bindDevShortcuts","fetchDevSummaryDetails","formatLocalVersion","waitForDevSummaryDetails","startDevServerRegistration","startWorkbenchDevServer","startWorkbenchRemoteCoordinator","startWorkbenchDev","options","cacheDir","checkForDeprecatedAppId","cliConfig","extractManifest","httpHost","httpPort","isApp","output","reactStrictMode","startAppServer","workDir","process","env","SANITY_INTERNAL_IS_WORKBENCH_REMOTE","remote","started","close","coordinator","server","closers","installSignalHandlers","startedAt","Date","now","app","undefined","organizationId","details","idOrSlug","deployment","appId","slug","workbench","push","appPort","workbenchAvailable","workbenchPort","supervised","start","config","isRestarting","quiet","catch","err","supervisor","dashboardAppPath","registration","onInterfaceSetChange","rebuild","path","durationMs","organizationName","url","log","heading","organization","title","version","quit","then","exit"],"mappings":"AAEA,SAAQA,cAAc,EAAEC,eAAe,QAAO,qBAAoB;AAClE,SAAQC,qBAAqB,EAAEC,aAAa,QAAO,oCAAmC;AACtF,SAAQC,aAAa,QAAO,gBAAe;AAC3C,SAA8BC,wBAAwB,QAAO,2BAA0B;AACvF,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,sBAAsB,EAAEC,kBAAkB,EAAEC,wBAAwB,QAAO,kBAAiB;AAEpG,SAAQC,0BAA0B,QAAO,kCAAiC;AAC1E,SACEC,uBAAuB,EACvBC,+BAA+B,QAC1B,+BAA8B;AA+BrC;;;;;;;;;CASC,GACD,OAAO,eAAeC,kBACpBC,OAAiC;IAEjC,MAAM,EACJC,QAAQ,EACRC,uBAAuB,EACvBC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,eAAe,EACfC,cAAc,EACdC,OAAO,EACR,GAAGX;IAEJ,4EAA4E;IAC5E,0CAA0C;IAC1C,IAAIY,QAAQC,GAAG,CAACC,mCAAmC,KAAK,QAAQ;QAC9D,MAAMC,SAAS,MAAML,eAAe;YAACP;YAAWG;QAAQ;QACxD,IAAI,CAACS,OAAOC,OAAO,EAAE,OAAO;YAACC,OAAO,WAAa;QAAC;QAElD,MAAMC,cAAcpB,gCAAgC;YAACqB,QAAQJ,OAAOI,MAAM;QAAA;QAE1E,OAAO;YACLF,OAAO;gBACL,MAAMC,YAAYD,KAAK;gBACvB,MAAMF,OAAOE,KAAK;YACpB;QACF;IACF;IAEA,4EAA4E;IAC5E,qEAAqE;IACrE,MAAM,EAACA,KAAK,EAAEG,OAAO,EAAEC,qBAAqB,EAAC,GAAGjC;IAChD,MAAMkC,YAAYC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A6E;QAC7E,wDAAwD;QACxD,MAAM3B;QACN,MAAM2B;IACR;IAEA,MAAMO,aAAa5B,KAAKC,GAAG,KAAKF;IAChC,MAAM,EAACQ,UAAU,EAAEsB,gBAAgB,EAAC,GAAGnB,UAAUG,kBAAkB,GAC/D,MAAMzC,yBAAyBiC,WAC/B,CAAC;IAELP;IAEA,IAAIY,UAAUG,kBAAkB,EAAE;QAChC,MAAMiB,MAAM,CAAC,OAAO,EAAEhE,cAAc4C,UAAU5B,QAAQ,EAAE,CAAC,EAAE4B,UAAUI,aAAa,GAAGS,oBAAoB,IAAI;QAE7GtC,OAAO8C,GAAG,CACRhE,cAAc;YACZ6D;YACAI,SAAS;YACThD;YACAiD,cAAcJ,oBAAoBzB;YAClC8B,OAAOhC,OAAOtC,gBAAgBsC;YAC9B4B;YACAK,SAAShE,mBAAmB,iBAAiBoC;QAC/C;QAGF,MAAM6B,OAAO,IAAM,KAAK1C,QAAQ2C,IAAI,CAAC,IAAMhD,QAAQiD,IAAI,CAAC;QACxDzC,QAAQc,IAAI,CAAC1C,iBAAiB;YAACgB;YAAQmD;YAAMN;QAAG;IAClD;IAEA,OAAO;QAACpC;IAAK;AACf"}
|
|
@@ -3,15 +3,18 @@ import path from 'node:path';
|
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
4
|
import { findProjectRoot } from '@sanity/cli-core';
|
|
5
5
|
import { buildAppId, SANITY_APP_ID_FILE } from '../../appId.js';
|
|
6
|
-
import { isWorkbenchApp } from '../../defineApp.js';
|
|
6
|
+
import { isWorkbenchApp, resolveAppTitle } from '../../defineApp.js';
|
|
7
7
|
import { deriveInterfaces } from '../../deriveInterfaces.js';
|
|
8
8
|
import { readAppIcon, toUrlPath } from '../../readAppIcon.js';
|
|
9
9
|
import { resolveWorkbenchApp } from '../../resolveWorkbenchApp.js';
|
|
10
10
|
import { resolveWorkbenchConfig } from '../../resolveWorkbenchConfig.js';
|
|
11
11
|
import { createServerLifecycle, toDisplayHost } from '../../util/serverOrchestration.js';
|
|
12
|
+
import { bindDevShortcuts } from '../dev/bindDevShortcuts.js';
|
|
12
13
|
import { deriveConfigs } from '../dev/deriveConfigs.js';
|
|
14
|
+
import { fetchDevSummaryDetails, formatLocalVersion, waitForDevSummaryDetails } from '../dev/devSummary.js';
|
|
13
15
|
import { dashboardPath, findServerConflict, localAppIdentity, registerDevServer } from '../dev/registry.js';
|
|
14
16
|
import { startWorkbenchDevServer } from '../dev/startWorkbenchDevServer.js';
|
|
17
|
+
import { formatSummary } from '../summary.js';
|
|
15
18
|
import { serveBuiltApplication } from './serveBuiltApplication.js';
|
|
16
19
|
/**
|
|
17
20
|
* `sanity start` for a workbench app: serve a production build the way dev serves
|
|
@@ -39,6 +42,11 @@ import { serveBuiltApplication } from './serveBuiltApplication.js';
|
|
|
39
42
|
if (conflict) {
|
|
40
43
|
throw new Error(`${conflict}. Stop that server first.`);
|
|
41
44
|
}
|
|
45
|
+
const startedAt = Date.now();
|
|
46
|
+
const details = fetchDevSummaryDetails({
|
|
47
|
+
idOrSlug: workbenchApp && (applicationId ?? workbenchApp.slug),
|
|
48
|
+
organizationId
|
|
49
|
+
});
|
|
42
50
|
const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined;
|
|
43
51
|
const appIcon = isApp ? app?.icon : undefined;
|
|
44
52
|
const iconUrlPath = (iconPath)=>`/${toUrlPath(workDir, path.resolve(workDir, iconPath))}`;
|
|
@@ -115,12 +123,26 @@ import { serveBuiltApplication } from './serveBuiltApplication.js';
|
|
|
115
123
|
await close();
|
|
116
124
|
throw err;
|
|
117
125
|
}
|
|
126
|
+
const durationMs = Date.now() - startedAt;
|
|
127
|
+
const { deployment, organizationName } = workbench.workbenchAvailable ? await waitForDevSummaryDetails(details) : {};
|
|
128
|
+
installSignalHandlers();
|
|
118
129
|
if (workbench.workbenchAvailable) {
|
|
119
|
-
const
|
|
120
|
-
output.log(
|
|
121
|
-
|
|
122
|
-
'
|
|
123
|
-
|
|
130
|
+
const url = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`;
|
|
131
|
+
output.log(formatSummary({
|
|
132
|
+
durationMs,
|
|
133
|
+
heading: 'Sanity Dashboard ready',
|
|
134
|
+
isApp,
|
|
135
|
+
organization: organizationName ?? organizationId,
|
|
136
|
+
title: app && resolveAppTitle(app),
|
|
137
|
+
url,
|
|
138
|
+
version: formatLocalVersion('local build', deployment)
|
|
139
|
+
}));
|
|
140
|
+
const quit = ()=>void close().then(()=>process.exit(0));
|
|
141
|
+
closers.push(bindDevShortcuts({
|
|
142
|
+
output,
|
|
143
|
+
quit,
|
|
144
|
+
url
|
|
145
|
+
}));
|
|
124
146
|
} else {
|
|
125
147
|
const remoteUrl = `http://${toDisplayHost(remote.host)}:${remote.port}`;
|
|
126
148
|
output.log(`Serving build at ${styleText([
|
|
@@ -128,7 +150,6 @@ import { serveBuiltApplication } from './serveBuiltApplication.js';
|
|
|
128
150
|
'underline'
|
|
129
151
|
], remoteUrl)}`);
|
|
130
152
|
}
|
|
131
|
-
installSignalHandlers();
|
|
132
153
|
return {
|
|
133
154
|
close
|
|
134
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/preview/startWorkbenchPreview.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type CliConfig, findProjectRoot, type Output} from '@sanity/cli-core'\n\nimport {buildAppId, SANITY_APP_ID_FILE} from '../../appId.js'\nimport {isWorkbenchApp} from '../../defineApp.js'\nimport {deriveInterfaces} from '../../deriveInterfaces.js'\nimport {readAppIcon, toUrlPath} from '../../readAppIcon.js'\nimport {type ResolvedWorkbenchApp, resolveWorkbenchApp} from '../../resolveWorkbenchApp.js'\nimport {resolveWorkbenchConfig} from '../../resolveWorkbenchConfig.js'\nimport {createServerLifecycle, toDisplayHost} from '../../util/serverOrchestration.js'\nimport {deriveConfigs} from '../dev/deriveConfigs.js'\nimport {\n dashboardPath,\n type DevServerManifest,\n findServerConflict,\n localAppIdentity,\n registerDevServer,\n} from '../dev/registry.js'\nimport {startWorkbenchDevServer} from '../dev/startWorkbenchDevServer.js'\nimport {serveBuiltApplication} from './serveBuiltApplication.js'\n\nexport interface StartWorkbenchPreviewOptions {\n /** Directory for the workbench Vite server's dependency cache. */\n cacheDir: string\n /** CLI-domain `app.id`/`deployment.appId` deprecation check, run before registering. */\n checkForDeprecatedAppId: () => void\n cliConfig: CliConfig\n /** Extract the project manifest to inline into the registry (studio-vs-app handled by the CLI). */\n extractManifest: (params: {\n applicationId?: string\n configPath: string\n /** Where the preview serves the app's icon. */\n iconUrl?: string\n workDir: string\n }) => Promise<DevServerManifest['manifest']>\n httpHost: string\n httpPort: number\n isApp: boolean\n /** The built `dist` directory to serve as the federation remote. */\n outDir: string\n output: Output\n reactStrictMode: boolean\n workDir: string\n}\n\n/**\n * `sanity start` for a workbench app: serve a production build the way dev serves\n * a live one. The same singleton workbench shell renders it and the same registry\n * advertises it — only the remote differs, static files from the build output\n * instead of a live Vite dev server. There's no config watcher or rebuild: a\n * build is fixed, so nothing re-syncs.\n *\n * A running workbench claims the configured port, so the built remote binds the\n * next one. Without one the remote takes the configured port and announces its\n * own URL.\n */\nexport async function startWorkbenchPreview(\n options: StartWorkbenchPreviewOptions,\n): Promise<{close: () => Promise<void>}> {\n const {\n cacheDir,\n checkForDeprecatedAppId,\n cliConfig,\n extractManifest,\n httpHost,\n httpPort,\n isApp,\n outDir,\n output,\n reactStrictMode,\n workDir,\n } = options\n\n // Resolved before any server starts, so a bad icon path, a project that isn't set\n // up for the Dashboard, or one it already serves fails with nothing to tear down.\n const {id, workbenchApp} = await resolvePreviewTarget(cliConfig, outDir)\n const applicationId = workbenchApp ? cliConfig.deployment?.appId : undefined\n const organizationId = cliConfig.app?.organizationId\n const conflict = findServerConflict({\n applicationId,\n id,\n organizationId,\n slug: workbenchApp?.slug,\n })\n\n if (conflict) {\n throw new Error(`${conflict}. Stop that server first.`)\n }\n\n const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined\n const appIcon = isApp ? app?.icon : undefined\n const iconUrlPath = (iconPath: string) =>\n `/${toUrlPath(workDir, path.resolve(workDir, iconPath))}`\n const icons = await Promise.all(\n [appIcon, ...(app?.views ?? []).map((view) => ('icon' in view ? view.icon : undefined))]\n .filter((iconPath) => iconPath !== undefined)\n .map(async (iconPath) => ({\n ...(await readAppIcon(workDir, iconPath)),\n path: iconUrlPath(iconPath),\n })),\n )\n\n const {close, closers, installSignalHandlers} = createServerLifecycle()\n\n const workbench = await startWorkbenchDevServer({\n cacheDir,\n cliConfig,\n httpHost,\n httpPort,\n output,\n reactStrictMode,\n workDir,\n })\n closers.push(workbench.close)\n\n const remotePort = workbench.workbenchAvailable ? workbench.workbenchPort + 1 : httpPort\n\n const remote = await serveBuiltApplication({\n cacheDir,\n httpHost,\n httpPort: remotePort,\n icons,\n outDir,\n workDir,\n }).catch(async (err) => {\n await close()\n throw err\n })\n closers.push(remote.close)\n\n let dashboardAppPath: string | undefined\n try {\n // Callers provide CLI-only validation and manifest extraction to keep them\n // out of workbench-cli.\n checkForDeprecatedAppId()\n const configPath = (await findProjectRoot(workDir)).path\n const configs = await deriveConfigs(cliConfig)\n const interfaces = deriveInterfaces(cliConfig.app, {\n iconUrl: (iconPath) => `http://${remote.host}:${remote.port}${iconUrlPath(iconPath)}`,\n isApp,\n })\n const registration = registerDevServer({\n applicationId,\n configs,\n host: remote.host,\n id,\n interfaces,\n manifest: await extractManifest({\n applicationId: id,\n configPath,\n iconUrl: appIcon && `http://${remote.host}:${remote.port}${iconUrlPath(appIcon)}`,\n workDir,\n }),\n manifestUpdatedAt: new Date().toISOString(),\n organizationId,\n port: remote.port,\n projectId: cliConfig?.api?.projectId,\n ...(workbenchApp && localAppIdentity(workbenchApp)),\n type: isApp ? 'coreApp' : 'studio',\n workDir,\n })\n closers.push(async () => registration.release())\n dashboardAppPath = dashboardPath({\n id,\n interfaces,\n slug: workbenchApp?.slug,\n type: isApp ? 'coreApp' : 'studio',\n })\n } catch (err) {\n await close()\n throw err\n }\n\n if (workbench.workbenchAvailable) {\n const appUrl = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`\n output.log(`Dashboard preview server started at ${styleText(['blue', 'underline'], appUrl)}`)\n } else {\n const remoteUrl = `http://${toDisplayHost(remote.host)}:${remote.port}`\n output.log(`Serving build at ${styleText(['blue', 'underline'], remoteUrl)}`)\n }\n\n installSignalHandlers()\n\n return {close}\n}\n\n/**\n * What the preview registers: a config under its own id namespace (as in dev),\n * or the workbench app under the id its build inlined.\n */\nasync function resolvePreviewTarget(\n cliConfig: CliConfig,\n outDir: string,\n): Promise<{id: string; workbenchApp?: ResolvedWorkbenchApp}> {\n const config = resolveWorkbenchConfig(cliConfig)\n\n if (config) {\n return {id: `config:${config.appType}`}\n }\n\n const workbenchApp = resolveWorkbenchApp(cliConfig)\n\n if (!workbenchApp) {\n throw new Error(\n '`sanity start` was invoked in an application that is not set up for the Dashboard',\n )\n }\n\n return {id: (await readInlinedAppId(outDir)) ?? (await buildAppId(workbenchApp)), workbenchApp}\n}\n\n/** The id the build inlined into its bundle, or undefined when absent. */\nasync function readInlinedAppId(outDir: string): Promise<string | undefined> {\n try {\n return (await readFile(path.join(outDir, SANITY_APP_ID_FILE), 'utf8')).trim() || undefined\n } catch {\n return undefined\n }\n}\n"],"names":["readFile","path","styleText","findProjectRoot","buildAppId","SANITY_APP_ID_FILE","isWorkbenchApp","deriveInterfaces","readAppIcon","toUrlPath","resolveWorkbenchApp","resolveWorkbenchConfig","createServerLifecycle","toDisplayHost","deriveConfigs","dashboardPath","findServerConflict","localAppIdentity","registerDevServer","startWorkbenchDevServer","serveBuiltApplication","startWorkbenchPreview","options","cacheDir","checkForDeprecatedAppId","cliConfig","extractManifest","httpHost","httpPort","isApp","outDir","output","reactStrictMode","workDir","id","workbenchApp","resolvePreviewTarget","applicationId","deployment","appId","undefined","organizationId","app","conflict","slug","Error","appIcon","icon","iconUrlPath","iconPath","resolve","icons","Promise","all","views","map","view","filter","close","closers","installSignalHandlers","workbench","push","remotePort","workbenchAvailable","workbenchPort","remote","catch","err","dashboardAppPath","configPath","configs","interfaces","iconUrl","host","port","registration","manifest","manifestUpdatedAt","Date","toISOString","projectId","api","type","release","appUrl","log","remoteUrl","config","appType","readInlinedAppId","join","trim"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAwBC,eAAe,QAAoB,mBAAkB;AAE7E,SAAQC,UAAU,EAAEC,kBAAkB,QAAO,iBAAgB;AAC7D,SAAQC,cAAc,QAAO,qBAAoB;AACjD,SAAQC,gBAAgB,QAAO,4BAA2B;AAC1D,SAAQC,WAAW,EAAEC,SAAS,QAAO,uBAAsB;AAC3D,SAAmCC,mBAAmB,QAAO,+BAA8B;AAC3F,SAAQC,sBAAsB,QAAO,kCAAiC;AACtE,SAAQC,qBAAqB,EAAEC,aAAa,QAAO,oCAAmC;AACtF,SAAQC,aAAa,QAAO,0BAAyB;AACrD,SACEC,aAAa,EAEbC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,QACZ,qBAAoB;AAC3B,SAAQC,uBAAuB,QAAO,oCAAmC;AACzE,SAAQC,qBAAqB,QAAO,6BAA4B;AA0BhE;;;;;;;;;;CAUC,GACD,OAAO,eAAeC,sBACpBC,OAAqC;IAErC,MAAM,EACJC,QAAQ,EACRC,uBAAuB,EACvBC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,eAAe,EACfC,OAAO,EACR,GAAGX;IAEJ,kFAAkF;IAClF,kFAAkF;IAClF,MAAM,EAACY,EAAE,EAAEC,YAAY,EAAC,GAAG,MAAMC,qBAAqBX,WAAWK;IACjE,MAAMO,gBAAgBF,eAAeV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;SAAY,EAAEmF,SAAS;IAC9F,OAAO;QACL,MAAME,YAAY,CAAC,OAAO,EAAE1E,cAAcqD,OAAOQ,IAAI,EAAE,CAAC,EAAER,OAAOS,IAAI,EAAE;QACvE5C,OAAOuD,GAAG,CAAC,CAAC,iBAAiB,EAAEpF,UAAU;YAAC;YAAQ;SAAY,EAAEqF,YAAY;IAC9E;IAEA3B;IAEA,OAAO;QAACF;IAAK;AACf;AAEA;;;CAGC,GACD,eAAetB,qBACbX,SAAoB,EACpBK,MAAc;IAEd,MAAM0D,SAAS7E,uBAAuBc;IAEtC,IAAI+D,QAAQ;QACV,OAAO;YAACtD,IAAI,CAAC,OAAO,EAAEsD,OAAOC,OAAO,EAAE;QAAA;IACxC;IAEA,MAAMtD,eAAezB,oBAAoBe;IAEzC,IAAI,CAACU,cAAc;QACjB,MAAM,IAAIU,MACR;IAEJ;IAEA,OAAO;QAACX,IAAI,AAAC,MAAMwD,iBAAiB5D,WAAa,MAAM1B,WAAW+B;QAAgBA;IAAY;AAChG;AAEA,wEAAwE,GACxE,eAAeuD,iBAAiB5D,MAAc;IAC5C,IAAI;QACF,OAAO,AAAC,CAAA,MAAM9B,SAASC,KAAK0F,IAAI,CAAC7D,QAAQzB,qBAAqB,OAAM,EAAGuF,IAAI,MAAMpD;IACnF,EAAE,OAAM;QACN,OAAOA;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/preview/startWorkbenchPreview.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type CliConfig, findProjectRoot, type Output} from '@sanity/cli-core'\n\nimport {buildAppId, SANITY_APP_ID_FILE} from '../../appId.js'\nimport {isWorkbenchApp, resolveAppTitle} from '../../defineApp.js'\nimport {deriveInterfaces} from '../../deriveInterfaces.js'\nimport {readAppIcon, toUrlPath} from '../../readAppIcon.js'\nimport {type ResolvedWorkbenchApp, resolveWorkbenchApp} from '../../resolveWorkbenchApp.js'\nimport {resolveWorkbenchConfig} from '../../resolveWorkbenchConfig.js'\nimport {createServerLifecycle, toDisplayHost} from '../../util/serverOrchestration.js'\nimport {bindDevShortcuts} from '../dev/bindDevShortcuts.js'\nimport {deriveConfigs} from '../dev/deriveConfigs.js'\nimport {\n fetchDevSummaryDetails,\n formatLocalVersion,\n waitForDevSummaryDetails,\n} from '../dev/devSummary.js'\nimport {\n dashboardPath,\n type DevServerManifest,\n findServerConflict,\n localAppIdentity,\n registerDevServer,\n} from '../dev/registry.js'\nimport {startWorkbenchDevServer} from '../dev/startWorkbenchDevServer.js'\nimport {formatSummary} from '../summary.js'\nimport {serveBuiltApplication} from './serveBuiltApplication.js'\n\nexport interface StartWorkbenchPreviewOptions {\n /** Directory for the workbench Vite server's dependency cache. */\n cacheDir: string\n /** CLI-domain `app.id`/`deployment.appId` deprecation check, run before registering. */\n checkForDeprecatedAppId: () => void\n cliConfig: CliConfig\n /** Extract the project manifest to inline into the registry (studio-vs-app handled by the CLI). */\n extractManifest: (params: {\n applicationId?: string\n configPath: string\n /** Where the preview serves the app's icon. */\n iconUrl?: string\n workDir: string\n }) => Promise<DevServerManifest['manifest']>\n httpHost: string\n httpPort: number\n isApp: boolean\n /** The built `dist` directory to serve as the federation remote. */\n outDir: string\n output: Output\n reactStrictMode: boolean\n workDir: string\n}\n\n/**\n * `sanity start` for a workbench app: serve a production build the way dev serves\n * a live one. The same singleton workbench shell renders it and the same registry\n * advertises it — only the remote differs, static files from the build output\n * instead of a live Vite dev server. There's no config watcher or rebuild: a\n * build is fixed, so nothing re-syncs.\n *\n * A running workbench claims the configured port, so the built remote binds the\n * next one. Without one the remote takes the configured port and announces its\n * own URL.\n */\nexport async function startWorkbenchPreview(\n options: StartWorkbenchPreviewOptions,\n): Promise<{close: () => Promise<void>}> {\n const {\n cacheDir,\n checkForDeprecatedAppId,\n cliConfig,\n extractManifest,\n httpHost,\n httpPort,\n isApp,\n outDir,\n output,\n reactStrictMode,\n workDir,\n } = options\n\n // Resolved before any server starts, so a bad icon path, a project that isn't set\n // up for the Dashboard, or one it already serves fails with nothing to tear down.\n const {id, workbenchApp} = await resolvePreviewTarget(cliConfig, outDir)\n const applicationId = workbenchApp ? cliConfig.deployment?.appId : undefined\n const organizationId = cliConfig.app?.organizationId\n const conflict = findServerConflict({\n applicationId,\n id,\n organizationId,\n slug: workbenchApp?.slug,\n })\n\n if (conflict) {\n throw new Error(`${conflict}. Stop that server first.`)\n }\n\n const startedAt = Date.now()\n const details = fetchDevSummaryDetails({\n idOrSlug: workbenchApp && (applicationId ?? workbenchApp.slug),\n organizationId,\n })\n const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined\n const appIcon = isApp ? app?.icon : undefined\n const iconUrlPath = (iconPath: string) =>\n `/${toUrlPath(workDir, path.resolve(workDir, iconPath))}`\n const icons = await Promise.all(\n [appIcon, ...(app?.views ?? []).map((view) => ('icon' in view ? view.icon : undefined))]\n .filter((iconPath) => iconPath !== undefined)\n .map(async (iconPath) => ({\n ...(await readAppIcon(workDir, iconPath)),\n path: iconUrlPath(iconPath),\n })),\n )\n\n const {close, closers, installSignalHandlers} = createServerLifecycle()\n\n const workbench = await startWorkbenchDevServer({\n cacheDir,\n cliConfig,\n httpHost,\n httpPort,\n output,\n reactStrictMode,\n workDir,\n })\n closers.push(workbench.close)\n\n const remotePort = workbench.workbenchAvailable ? workbench.workbenchPort + 1 : httpPort\n\n const remote = await serveBuiltApplication({\n cacheDir,\n httpHost,\n httpPort: remotePort,\n icons,\n outDir,\n workDir,\n }).catch(async (err) => {\n await close()\n throw err\n })\n closers.push(remote.close)\n\n let dashboardAppPath: string | undefined\n try {\n // Callers provide CLI-only validation and manifest extraction to keep them\n // out of workbench-cli.\n checkForDeprecatedAppId()\n const configPath = (await findProjectRoot(workDir)).path\n const configs = await deriveConfigs(cliConfig)\n const interfaces = deriveInterfaces(cliConfig.app, {\n iconUrl: (iconPath) => `http://${remote.host}:${remote.port}${iconUrlPath(iconPath)}`,\n isApp,\n })\n const registration = registerDevServer({\n applicationId,\n configs,\n host: remote.host,\n id,\n interfaces,\n manifest: await extractManifest({\n applicationId: id,\n configPath,\n iconUrl: appIcon && `http://${remote.host}:${remote.port}${iconUrlPath(appIcon)}`,\n workDir,\n }),\n manifestUpdatedAt: new Date().toISOString(),\n organizationId,\n port: remote.port,\n projectId: cliConfig?.api?.projectId,\n ...(workbenchApp && localAppIdentity(workbenchApp)),\n type: isApp ? 'coreApp' : 'studio',\n workDir,\n })\n closers.push(async () => registration.release())\n dashboardAppPath = dashboardPath({\n id,\n interfaces,\n slug: workbenchApp?.slug,\n type: isApp ? 'coreApp' : 'studio',\n })\n } catch (err) {\n await close()\n throw err\n }\n\n const durationMs = Date.now() - startedAt\n const {deployment, organizationName} = workbench.workbenchAvailable\n ? await waitForDevSummaryDetails(details)\n : {}\n\n installSignalHandlers()\n\n if (workbench.workbenchAvailable) {\n const url = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`\n output.log(\n formatSummary({\n durationMs,\n heading: 'Sanity Dashboard ready',\n isApp,\n organization: organizationName ?? organizationId,\n title: app && resolveAppTitle(app),\n url,\n version: formatLocalVersion('local build', deployment),\n }),\n )\n\n const quit = () => void close().then(() => process.exit(0))\n closers.push(bindDevShortcuts({output, quit, url}))\n } else {\n const remoteUrl = `http://${toDisplayHost(remote.host)}:${remote.port}`\n output.log(`Serving build at ${styleText(['blue', 'underline'], remoteUrl)}`)\n }\n\n return {close}\n}\n\n/**\n * What the preview registers: a config under its own id namespace (as in dev),\n * or the workbench app under the id its build inlined.\n */\nasync function resolvePreviewTarget(\n cliConfig: CliConfig,\n outDir: string,\n): Promise<{id: string; workbenchApp?: ResolvedWorkbenchApp}> {\n const config = resolveWorkbenchConfig(cliConfig)\n\n if (config) {\n return {id: `config:${config.appType}`}\n }\n\n const workbenchApp = resolveWorkbenchApp(cliConfig)\n\n if (!workbenchApp) {\n throw new Error(\n '`sanity start` was invoked in an application that is not set up for the Dashboard',\n )\n }\n\n return {id: (await readInlinedAppId(outDir)) ?? (await buildAppId(workbenchApp)), workbenchApp}\n}\n\n/** The id the build inlined into its bundle, or undefined when absent. */\nasync function readInlinedAppId(outDir: string): Promise<string | undefined> {\n try {\n return (await readFile(path.join(outDir, SANITY_APP_ID_FILE), 'utf8')).trim() || undefined\n } catch {\n return undefined\n }\n}\n"],"names":["readFile","path","styleText","findProjectRoot","buildAppId","SANITY_APP_ID_FILE","isWorkbenchApp","resolveAppTitle","deriveInterfaces","readAppIcon","toUrlPath","resolveWorkbenchApp","resolveWorkbenchConfig","createServerLifecycle","toDisplayHost","bindDevShortcuts","deriveConfigs","fetchDevSummaryDetails","formatLocalVersion","waitForDevSummaryDetails","dashboardPath","findServerConflict","localAppIdentity","registerDevServer","startWorkbenchDevServer","formatSummary","serveBuiltApplication","startWorkbenchPreview","options","cacheDir","checkForDeprecatedAppId","cliConfig","extractManifest","httpHost","httpPort","isApp","outDir","output","reactStrictMode","workDir","id","workbenchApp","resolvePreviewTarget","applicationId","deployment","appId","undefined","organizationId","app","conflict","slug","Error","startedAt","Date","now","details","idOrSlug","appIcon","icon","iconUrlPath","iconPath","resolve","icons","Promise","all","views","map","view","filter","close","closers","installSignalHandlers","workbench","push","remotePort","workbenchAvailable","workbenchPort","remote","catch","err","dashboardAppPath","configPath","configs","interfaces","iconUrl","host","port","registration","manifest","manifestUpdatedAt","toISOString","projectId","api","type","release","durationMs","organizationName","url","log","heading","organization","title","version","quit","then","process","exit","remoteUrl","config","appType","readInlinedAppId","join","trim"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAwBC,eAAe,QAAoB,mBAAkB;AAE7E,SAAQC,UAAU,EAAEC,kBAAkB,QAAO,iBAAgB;AAC7D,SAAQC,cAAc,EAAEC,eAAe,QAAO,qBAAoB;AAClE,SAAQC,gBAAgB,QAAO,4BAA2B;AA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pF,mBAAmB,eAAe0B;QAC7C;QAGF,MAAM2D,OAAO,IAAM,KAAKlC,QAAQmC,IAAI,CAAC,IAAMC,QAAQC,IAAI,CAAC;QACxDpC,QAAQG,IAAI,CAAC1D,iBAAiB;YAACsB;YAAQkE;YAAMN;QAAG;IAClD,OAAO;QACL,MAAMU,YAAY,CAAC,OAAO,EAAE7F,cAAc+D,OAAOQ,IAAI,EAAE,CAAC,EAAER,OAAOS,IAAI,EAAE;QACvEjD,OAAO6D,GAAG,CAAC,CAAC,iBAAiB,EAAEhG,UAAU;YAAC;YAAQ;SAAY,EAAEyG,YAAY;IAC9E;IAEA,OAAO;QAACtC;IAAK;AACf;AAEA;;;CAGC,GACD,eAAe3B,qBACbX,SAAoB,EACpBK,MAAc;IAEd,MAAMwE,SAAShG,uBAAuBmB;IAEtC,IAAI6E,QAAQ;QACV,OAAO;YAACpE,IAAI,CAAC,OAAO,EAAEoE,OAAOC,OAAO,EAAE;QAAA;IACxC;IAEA,MAAMpE,eAAe9B,oBAAoBoB;IAEzC,IAAI,CAACU,cAAc;QACjB,MAAM,IAAIU,MACR;IAEJ;IAEA,OAAO;QAACX,IAAI,AAAC,MAAMsE,iBAAiB1E,WAAa,MAAMhC,WAAWqC;QAAgBA;IAAY;AAChG;AAEA,wEAAwE,GACxE,eAAeqE,iBAAiB1E,MAAc;IAC5C,IAAI;QACF,OAAO,AAAC,CAAA,MAAMpC,SAASC,KAAK8G,IAAI,CAAC3E,QAAQ/B,qBAAqB,OAAM,EAAG2G,IAAI,MAAMlE;IACnF,EAAE,OAAM;QACN,OAAOA;IACT;AACF"}
|
package/dist/actions/summary.js
CHANGED
|
@@ -3,16 +3,15 @@ export const SUMMARY_LOOKUP_TIMEOUT_MS = 3000;
|
|
|
3
3
|
export function formatSummary({ durationMs, heading, isApp, organization, title, url, version }) {
|
|
4
4
|
const seconds = (durationMs / 1000).toFixed(1);
|
|
5
5
|
const titleRow = title ? `\n ${(isApp ? 'App' : 'Studio').padEnd(12)} ${title}` : '';
|
|
6
|
-
const
|
|
6
|
+
const urlRow = url ? `\n URL ${styleText([
|
|
7
7
|
'blue',
|
|
8
8
|
'underline'
|
|
9
|
-
], url);
|
|
9
|
+
], url)}` : '';
|
|
10
10
|
const versionRow = version ? `\n Version ${version}` : '';
|
|
11
11
|
return `
|
|
12
12
|
${heading} in ${seconds}s
|
|
13
13
|
|
|
14
|
-
Organization ${organization}${titleRow}
|
|
15
|
-
URL ${link}${versionRow}
|
|
14
|
+
Organization ${organization}${titleRow}${urlRow}${versionRow}
|
|
16
15
|
`;
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/summary.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nexport const SUMMARY_LOOKUP_TIMEOUT_MS = 3000\n\nexport function formatSummary({\n durationMs,\n heading,\n isApp,\n organization,\n title,\n url,\n version,\n}: {\n durationMs: number\n heading: string\n isApp: boolean\n organization?: string\n title?: string\n url
|
|
1
|
+
{"version":3,"sources":["../../src/actions/summary.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nexport const SUMMARY_LOOKUP_TIMEOUT_MS = 3000\n\nexport function formatSummary({\n durationMs,\n heading,\n isApp,\n organization,\n title,\n url,\n version,\n}: {\n durationMs: number\n heading: string\n isApp: boolean\n organization?: string\n title?: string\n url?: string\n version?: string\n}): string {\n const seconds = (durationMs / 1000).toFixed(1)\n const titleRow = title ? `\\n ${(isApp ? 'App' : 'Studio').padEnd(12)} ${title}` : ''\n const urlRow = url ? `\\n URL ${styleText(['blue', 'underline'], url)}` : ''\n const versionRow = version ? `\\n Version ${version}` : ''\n\n return `\n ${heading} in ${seconds}s\n\n Organization ${organization}${titleRow}${urlRow}${versionRow}\n`\n}\n"],"names":["styleText","SUMMARY_LOOKUP_TIMEOUT_MS","formatSummary","durationMs","heading","isApp","organization","title","url","version","seconds","toFixed","titleRow","padEnd","urlRow","versionRow"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,OAAO,MAAMC,4BAA4B,KAAI;AAE7C,OAAO,SAASC,cAAc,EAC5BC,UAAU,EACVC,OAAO,EACPC,KAAK,EACLC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,OAAO,EASR;IACC,MAAMC,UAAU,AAACP,CAAAA,aAAa,IAAG,EAAGQ,OAAO,CAAC;IAC5C,MAAMC,WAAWL,QAAQ,CAAC,MAAM,EAAE,AAACF,CAAAA,QAAQ,QAAQ,QAAO,EAAGQ,MAAM,CAAC,IAAI,EAAE,EAAEN,OAAO,GAAG;IACtF,MAAMO,SAASN,MAAM,CAAC,oBAAoB,EAAER,UAAU;QAAC;QAAQ;KAAY,EAAEQ,MAAM,GAAG;IACtF,MAAMO,aAAaN,UAAU,CAAC,oBAAoB,EAAEA,SAAS,GAAG;IAEhE,OAAO,CAAC;EACR,EAAEL,QAAQ,IAAI,EAAEM,QAAQ;;kBAER,EAAEJ,eAAeM,WAAWE,SAASC,WAAW;AAClE,CAAC;AACD"}
|
|
@@ -2,6 +2,7 @@ import { deleteApplication, getApplication, getApplicationUrl, getWorkbenchUrl }
|
|
|
2
2
|
import { deleteDashboard, getOrganizationDashboard } from '../../services/dashboard-configs.js';
|
|
3
3
|
import { deleteConfig, listConfigs } from '../../services/installations.js';
|
|
4
4
|
import { resolveInstallationId, summarizeConfig } from '../deploy/deployConfig.js';
|
|
5
|
+
import { fetchOrganizationSummary } from '../deploy/deploySummary.js';
|
|
5
6
|
import { summarizeInterfaces } from '../deploy/summarizeInterfaces.js';
|
|
6
7
|
/**
|
|
7
8
|
* The undeploy adapter for workbench apps and configs, mirroring what a
|
|
@@ -70,11 +71,13 @@ async function resolveApplicationTarget({ appId, type, workbench }) {
|
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
const { lines, services, views } = summarizeInterfaces(workbench);
|
|
74
|
+
const { hostSlug } = await fetchOrganizationSummary(application.organizationId);
|
|
73
75
|
return {
|
|
74
76
|
target: {
|
|
75
77
|
application,
|
|
76
78
|
deletes: 'application',
|
|
77
79
|
id: application.id,
|
|
80
|
+
organizationId: application.organizationId,
|
|
78
81
|
payload: {
|
|
79
82
|
appId: application.id,
|
|
80
83
|
services,
|
|
@@ -88,7 +91,7 @@ async function resolveApplicationTarget({ appId, type, workbench }) {
|
|
|
88
91
|
url: getApplicationUrl({
|
|
89
92
|
...application,
|
|
90
93
|
type
|
|
91
|
-
}),
|
|
94
|
+
}, hostSlug),
|
|
92
95
|
views
|
|
93
96
|
},
|
|
94
97
|
type: 'found'
|
|
@@ -121,6 +124,7 @@ async function resolveConfigTarget({ config, organizationId }) {
|
|
|
121
124
|
}
|
|
122
125
|
};
|
|
123
126
|
}
|
|
127
|
+
const { hostSlug } = await fetchOrganizationSummary(organizationId);
|
|
124
128
|
return {
|
|
125
129
|
installationId,
|
|
126
130
|
resolution: {
|
|
@@ -139,7 +143,7 @@ async function resolveConfigTarget({ config, organizationId }) {
|
|
|
139
143
|
],
|
|
140
144
|
title: 'Media Library configuration',
|
|
141
145
|
type: 'coreApp',
|
|
142
|
-
url: getWorkbenchUrl(organizationId)
|
|
146
|
+
url: getWorkbenchUrl(organizationId, hostSlug)
|
|
143
147
|
},
|
|
144
148
|
type: 'found'
|
|
145
149
|
}
|
|
@@ -156,6 +160,7 @@ async function resolveDashboardConfigTarget(config) {
|
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
162
|
}
|
|
163
|
+
const { hostSlug } = await fetchOrganizationSummary(organizationId);
|
|
159
164
|
return {
|
|
160
165
|
dashboardId: dashboard.id,
|
|
161
166
|
resolution: {
|
|
@@ -174,7 +179,7 @@ async function resolveDashboardConfigTarget(config) {
|
|
|
174
179
|
],
|
|
175
180
|
title: 'Dashboard configuration',
|
|
176
181
|
type: 'coreApp',
|
|
177
|
-
url: getWorkbenchUrl(organizationId)
|
|
182
|
+
url: getWorkbenchUrl(organizationId, hostSlug)
|
|
178
183
|
},
|
|
179
184
|
type: 'found'
|
|
180
185
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/undeploy/workbenchUndeployAdapter.ts"],"sourcesContent":["import {\n type UndeployAdapter,\n type UndeployApplicationTarget,\n type UndeployConfigTarget,\n type UndeployTargetResolution,\n} from '@sanity/cli-core/undeploy'\n\nimport {\n type DashboardConfig,\n type MediaLibraryConfig,\n type WorkbenchConfig,\n} from '../../defineApp.js'\nimport {\n deleteApplication,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n} from '../../services/applications.js'\nimport {deleteDashboard, getOrganizationDashboard} from '../../services/dashboard-configs.js'\nimport {type ConfigSnapshot, deleteConfig, listConfigs} from '../../services/installations.js'\nimport {resolveInstallationId, summarizeConfig} from '../deploy/deployConfig.js'\nimport {type DeployableWorkbenchApp} from '../deploy/getWorkbench.js'\nimport {\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../deploy/summarizeInterfaces.js'\n\n/** The workbench extension of the shared target; serializes into `--json` as-is. */\nexport type WorkbenchUndeployTarget =\n | (UndeployApplicationTarget & {\n services: DeployedWebWorker[]\n views: DeployedView[]\n })\n | (UndeployConfigTarget & {\n configs: ConfigSnapshot[]\n })\n\n/**\n * The undeploy adapter for workbench apps and configs, mirroring what a\n * workbench deploy creates: an app that exposes interfaces deletes its Brett\n * application (the server soft-deletes its deployments and refuses singletons\n * with active installations); a config deletes its deployed config instead\n * (installation snapshots, or the dashboard configuration). The two are severed at the source,\n * so exactly one of `workbench`/`config` is supplied and the brand decides the path.\n */\nexport function createWorkbenchUndeployAdapter(options: {\n appId: string | undefined\n config?: WorkbenchConfig\n organizationId: string | undefined\n type: 'coreApp' | 'studio'\n workbench?: DeployableWorkbenchApp\n}): UndeployAdapter<WorkbenchUndeployTarget> {\n const {appId, config, organizationId, type, workbench} = options\n // Workbench-internal, so kept off the reported target; resolveTarget stashes it for the delete.\n let installationId: string | undefined\n let dashboardId: string | undefined\n\n return {\n resolveTarget: async () => {\n if (!config) {\n if (!workbench) throw new Error('No Dashboard app or config to undeploy')\n return resolveApplicationTarget({appId, type, workbench})\n }\n\n if (config.appType === 'dashboard') {\n const resolved = await resolveDashboardConfigTarget(config)\n dashboardId = resolved.dashboardId\n return resolved.resolution\n }\n\n const resolved = await resolveConfigTarget({config, organizationId})\n installationId = resolved.installationId\n return resolved.resolution\n },\n type,\n async undeploy(target) {\n if (dashboardId) {\n await deleteDashboard(dashboardId)\n return\n }\n\n if (target.deletes === 'config') {\n if (!installationId) throw new Error('No installation resolved for the config undeploy')\n for (const snapshot of target.configs) {\n await deleteConfig(installationId, snapshot.id)\n }\n return\n }\n await deleteApplication(target.id)\n },\n }\n}\n\nasync function resolveApplicationTarget({\n appId,\n type,\n workbench,\n}: {\n appId: string | undefined\n type: 'coreApp' | 'studio'\n workbench: DeployableWorkbenchApp\n}): Promise<UndeployTargetResolution<WorkbenchUndeployTarget>> {\n if (!appId) {\n return {\n message: 'No `deployment.appId` configured',\n solution: 'Add `deployment.appId` to sanity.cli.ts',\n type: 'none',\n }\n }\n\n const application = await getApplication(appId)\n if (!application) {\n return {message: 'Application with the given ID does not exist', type: 'none'}\n }\n\n const {lines, services, views} = summarizeInterfaces(workbench)\n return {\n target: {\n application,\n deletes: 'application',\n id: application.id,\n payload: {appId: application.id, services, type, views},\n services,\n summary: lines,\n title: application.title,\n type,\n url: getApplicationUrl({...application, type}),\n views,\n },\n type: 'found',\n }\n}\n\nasync function resolveConfigTarget({\n config,\n organizationId,\n}: {\n config: MediaLibraryConfig\n organizationId: string | undefined\n}): Promise<{\n installationId?: string\n resolution: UndeployTargetResolution<WorkbenchUndeployTarget>\n}> {\n const {appType} = config\n if (!organizationId) {\n throw new Error(\n 'sanity.cli.ts does not contain an organization identifier (\"app.organizationId\"), which is required to resolve the installation',\n )\n }\n\n const installationId = await resolveInstallationId({appType, organizationId})\n if (!installationId) {\n return {\n resolution: {\n message: `No active \"${appType}\" installation for organization \"${organizationId}\"`,\n type: 'none',\n },\n }\n }\n\n const configs = await listConfigs(installationId)\n if (configs.length === 0) {\n return {\n installationId,\n resolution: {\n message: `No deployed config for the \"${appType}\" installation`,\n type: 'none',\n },\n }\n }\n\n return {\n installationId,\n resolution: {\n target: {\n configs,\n deletes: 'config',\n id: null,\n organizationId,\n payload: {\n appId: null,\n config: summarizeConfig(config),\n type: 'coreApp',\n },\n summary: [summarizeConfig(config)],\n title: 'Media Library configuration',\n type: 'coreApp',\n url: getWorkbenchUrl(organizationId),\n },\n type: 'found',\n },\n }\n}\n\nasync function resolveDashboardConfigTarget(config: DashboardConfig): Promise<{\n dashboardId?: string\n resolution: UndeployTargetResolution<WorkbenchUndeployTarget>\n}> {\n const {organizationId} = config\n const dashboard = await getOrganizationDashboard(organizationId)\n if (!dashboard) {\n return {\n resolution: {\n message: `No deployed dashboard configuration for organization \"${organizationId}\"`,\n type: 'none',\n },\n }\n }\n\n return {\n dashboardId: dashboard.id,\n resolution: {\n target: {\n configs: [],\n deletes: 'config',\n id: null,\n organizationId,\n payload: {appId: null, config: summarizeConfig(config), type: 'coreApp'},\n summary: [summarizeConfig(config)],\n title: 'Dashboard configuration',\n type: 'coreApp',\n url: getWorkbenchUrl(organizationId),\n },\n type: 'found',\n },\n }\n}\n"],"names":["deleteApplication","getApplication","getApplicationUrl","getWorkbenchUrl","deleteDashboard","getOrganizationDashboard","deleteConfig","listConfigs","resolveInstallationId","summarizeConfig","summarizeInterfaces","createWorkbenchUndeployAdapter","options","appId","config","organizationId","type","workbench","installationId","dashboardId","resolveTarget","Error","resolveApplicationTarget","appType","resolved","resolveDashboardConfigTarget","resolution","resolveConfigTarget","undeploy","target","deletes","snapshot","configs","id","message","solution","application","lines","services","views","payload","summary","title","url","length","dashboard"],"mappings":"AAYA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,QACV,iCAAgC;AACvC,SAAQC,eAAe,EAAEC,wBAAwB,QAAO,sCAAqC;AAC7F,SAA6BC,YAAY,EAAEC,WAAW,QAAO,kC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BY;YACvB;YACAC,MAAM;QACR;IACF;AACF;AAEA,eAAeS,6BAA6BX,MAAuB;IAIjE,MAAM,EAACC,cAAc,EAAC,GAAGD;IACzB,MAAM+B,YAAY,MAAMxC,yBAAyBU;IACjD,IAAI,CAAC8B,WAAW;QACd,OAAO;YACLnB,YAAY;gBACVQ,SAAS,CAAC,sDAAsD,EAAEnB,eAAe,CAAC,CAAC;gBACnFC,MAAM;YACR;QACF;IACF;IAEA,OAAO;QACLG,aAAa0B,UAAUZ,EAAE;QACzBP,YAAY;YACVG,QAAQ;gBACNG,SAAS,EAAE;gBACXF,SAAS;gBACTG,IAAI;gBACJlB;gBACAyB,SAAS;oBAAC3B,OAAO;oBAAMC,QAAQL,gBAAgBK;oBAASE,MAAM;gBAAS;gBACvEyB,SAAS;oBAAChC,gBAAgBK;iBAAQ;gBAClC4B,OAAO;gBACP1B,MAAM;gBACN2B,KAAKxC,gBAAgBY;YACvB;YACAC,MAAM;QACR;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/undeploy/workbenchUndeployAdapter.ts"],"sourcesContent":["import {\n type UndeployAdapter,\n type UndeployApplicationTarget,\n type UndeployConfigTarget,\n type UndeployTargetResolution,\n} from '@sanity/cli-core/undeploy'\n\nimport {\n type DashboardConfig,\n type MediaLibraryConfig,\n type WorkbenchConfig,\n} from '../../defineApp.js'\nimport {\n deleteApplication,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n} from '../../services/applications.js'\nimport {deleteDashboard, getOrganizationDashboard} from '../../services/dashboard-configs.js'\nimport {type ConfigSnapshot, deleteConfig, listConfigs} from '../../services/installations.js'\nimport {resolveInstallationId, summarizeConfig} from '../deploy/deployConfig.js'\nimport {fetchOrganizationSummary} from '../deploy/deploySummary.js'\nimport {type DeployableWorkbenchApp} from '../deploy/getWorkbench.js'\nimport {\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '../deploy/summarizeInterfaces.js'\n\n/** The workbench extension of the shared target; serializes into `--json` as-is. */\nexport type WorkbenchUndeployTarget =\n | (UndeployApplicationTarget & {\n services: DeployedWebWorker[]\n views: DeployedView[]\n })\n | (UndeployConfigTarget & {\n configs: ConfigSnapshot[]\n })\n\n/**\n * The undeploy adapter for workbench apps and configs, mirroring what a\n * workbench deploy creates: an app that exposes interfaces deletes its Brett\n * application (the server soft-deletes its deployments and refuses singletons\n * with active installations); a config deletes its deployed config instead\n * (installation snapshots, or the dashboard configuration). The two are severed at the source,\n * so exactly one of `workbench`/`config` is supplied and the brand decides the path.\n */\nexport function createWorkbenchUndeployAdapter(options: {\n appId: string | undefined\n config?: WorkbenchConfig\n organizationId: string | undefined\n type: 'coreApp' | 'studio'\n workbench?: DeployableWorkbenchApp\n}): UndeployAdapter<WorkbenchUndeployTarget> {\n const {appId, config, organizationId, type, workbench} = options\n // Workbench-internal, so kept off the reported target; resolveTarget stashes it for the delete.\n let installationId: string | undefined\n let dashboardId: string | undefined\n\n return {\n resolveTarget: async () => {\n if (!config) {\n if (!workbench) throw new Error('No Dashboard app or config to undeploy')\n return resolveApplicationTarget({appId, type, workbench})\n }\n\n if (config.appType === 'dashboard') {\n const resolved = await resolveDashboardConfigTarget(config)\n dashboardId = resolved.dashboardId\n return resolved.resolution\n }\n\n const resolved = await resolveConfigTarget({config, organizationId})\n installationId = resolved.installationId\n return resolved.resolution\n },\n type,\n async undeploy(target) {\n if (dashboardId) {\n await deleteDashboard(dashboardId)\n return\n }\n\n if (target.deletes === 'config') {\n if (!installationId) throw new Error('No installation resolved for the config undeploy')\n for (const snapshot of target.configs) {\n await deleteConfig(installationId, snapshot.id)\n }\n return\n }\n await deleteApplication(target.id)\n },\n }\n}\n\nasync function resolveApplicationTarget({\n appId,\n type,\n workbench,\n}: {\n appId: string | undefined\n type: 'coreApp' | 'studio'\n workbench: DeployableWorkbenchApp\n}): Promise<UndeployTargetResolution<WorkbenchUndeployTarget>> {\n if (!appId) {\n return {\n message: 'No `deployment.appId` configured',\n solution: 'Add `deployment.appId` to sanity.cli.ts',\n type: 'none',\n }\n }\n\n const application = await getApplication(appId)\n if (!application) {\n return {message: 'Application with the given ID does not exist', type: 'none'}\n }\n\n const {lines, services, views} = summarizeInterfaces(workbench)\n const {hostSlug} = await fetchOrganizationSummary(application.organizationId)\n return {\n target: {\n application,\n deletes: 'application',\n id: application.id,\n organizationId: application.organizationId,\n payload: {appId: application.id, services, type, views},\n services,\n summary: lines,\n title: application.title,\n type,\n url: getApplicationUrl({...application, type}, hostSlug),\n views,\n },\n type: 'found',\n }\n}\n\nasync function resolveConfigTarget({\n config,\n organizationId,\n}: {\n config: MediaLibraryConfig\n organizationId: string | undefined\n}): Promise<{\n installationId?: string\n resolution: UndeployTargetResolution<WorkbenchUndeployTarget>\n}> {\n const {appType} = config\n if (!organizationId) {\n throw new Error(\n 'sanity.cli.ts does not contain an organization identifier (\"app.organizationId\"), which is required to resolve the installation',\n )\n }\n\n const installationId = await resolveInstallationId({appType, organizationId})\n if (!installationId) {\n return {\n resolution: {\n message: `No active \"${appType}\" installation for organization \"${organizationId}\"`,\n type: 'none',\n },\n }\n }\n\n const configs = await listConfigs(installationId)\n if (configs.length === 0) {\n return {\n installationId,\n resolution: {\n message: `No deployed config for the \"${appType}\" installation`,\n type: 'none',\n },\n }\n }\n\n const {hostSlug} = await fetchOrganizationSummary(organizationId)\n return {\n installationId,\n resolution: {\n target: {\n configs,\n deletes: 'config',\n id: null,\n organizationId,\n payload: {\n appId: null,\n config: summarizeConfig(config),\n type: 'coreApp',\n },\n summary: [summarizeConfig(config)],\n title: 'Media Library configuration',\n type: 'coreApp',\n url: getWorkbenchUrl(organizationId, hostSlug),\n },\n type: 'found',\n },\n }\n}\n\nasync function resolveDashboardConfigTarget(config: DashboardConfig): Promise<{\n dashboardId?: string\n resolution: UndeployTargetResolution<WorkbenchUndeployTarget>\n}> {\n const {organizationId} = config\n const dashboard = await getOrganizationDashboard(organizationId)\n if (!dashboard) {\n return {\n resolution: {\n message: `No deployed dashboard configuration for organization \"${organizationId}\"`,\n type: 'none',\n },\n }\n }\n\n const {hostSlug} = await fetchOrganizationSummary(organizationId)\n return {\n dashboardId: dashboard.id,\n resolution: {\n target: {\n configs: [],\n deletes: 'config',\n id: null,\n organizationId,\n payload: {appId: null, config: summarizeConfig(config), type: 'coreApp'},\n summary: [summarizeConfig(config)],\n title: 'Dashboard configuration',\n type: 'coreApp',\n url: getWorkbenchUrl(organizationId, hostSlug),\n },\n type: 'found',\n },\n }\n}\n"],"names":["deleteApplication","getApplication","getApplicationUrl","getWorkbenchUrl","deleteDashboard","getOrganizationDashboard","deleteConfig","listConfigs","resolveInstallationId","summarizeConfig","fetchOrganizationSummary","summarizeInterfaces","createWorkbenchUndeployAdapter","options","appId","config","organizationId","type","workbench","installationId","dashboardId","resolveTarget","Error","resolveApplicationTarget","appType","resolved","resolveDashboardConfigTarget","resolution","resolveConfigTarget","undeploy","target","deletes","snapshot","configs","id","message","solution","application","lines","services","views","hostSlug","payload","summary","title","url","length","dashboard"],"mappings":"AAYA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,QACV,iCAAgC;AACvC,SAAQC,eAAe,EAAEC,wBAAwB,QAAO,sCAAqC;AAC7F,SAA6BC,YAAY,EAAEC,WAAW,QAAO,kCAAiC;AAC9F,SAAQC,qBAAqB,EAAEC,eAAe,QAAO,4BAA2B;AAChF,SAAQC,wBAAwB,QAAO,6BAA4B;AAEnE,SAGEC,mBAAmB,QACd,mCAAkC;AAYzC;;;;;;;CAOC,GACD,OAAO,SAASC,+BAA+BC,OAM9C;IACC,MAAM,EAACC,KAAK,EAAEC,MAAM,EAAEC,cAAc,EAAEC,IAAI,EAAEC,SAAS,EAAC,GAAGL;IACzD,gGAAgG;IAChG,IAAIM;IACJ,IAAIC;IAEJ,OAAO;QACLC,eAAe;YACb,IAAI,CAACN,QAAQ;gBACX,IAAI,CAACG,WAAW,MAAM,IAAII,MAAM;gBAChC,OAAOC,yBAAyB;oBAACT;oBAA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AAsD,EAAEnB,eAAe,CAAC,CAAC;gBACnFC,MAAM;YACR;QACF;IACF;IAEA,MAAM,EAACwB,QAAQ,EAAC,GAAG,MAAM/B,yBAAyBM;IAClD,OAAO;QACLI,aAAa2B,UAAUb,EAAE;QACzBP,YAAY;YACVG,QAAQ;gBACNG,SAAS,EAAE;gBACXF,SAAS;gBACTG,IAAI;gBACJlB;gBACA0B,SAAS;oBAAC5B,OAAO;oBAAMC,QAAQN,gBAAgBM;oBAASE,MAAM;gBAAS;gBACvE0B,SAAS;oBAAClC,gBAAgBM;iBAAQ;gBAClC6B,OAAO;gBACP3B,MAAM;gBACN4B,KAAK1C,gBAAgBa,gBAAgByB;YACvC;YACAxB,MAAM;QACR;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dashboardConfig.ts"],"sourcesContent":["import {type CurrentUser} from '@sanity/sdk'\nimport {type
|
|
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"}
|
|
@@ -3,12 +3,17 @@ import { getGlobalCliClient } from '@sanity/cli-core';
|
|
|
3
3
|
import { isStaging } from '@sanity/cli-core/util';
|
|
4
4
|
import FormData from 'form-data';
|
|
5
5
|
import { APP_WORKBENCH_API_VERSION } from './apiVersion.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The organization's Dashboard, on its host slug when it has one. Sessions are
|
|
8
|
+
* per origin and the org ID host redirects to the slug host, so a link to the
|
|
9
|
+
* org ID host would make the user sign in again.
|
|
10
|
+
*/ export function getWorkbenchUrl(organizationId, hostSlug) {
|
|
11
|
+
const host = (hostSlug ?? organizationId).toLowerCase();
|
|
12
|
+
return `https://${host}.${isStaging() ? 'run.sanity.work' : 'sanity.run'}`;
|
|
13
|
+
}
|
|
14
|
+
/** Where a deployed application is served on its organization's workbench. */ export function getApplicationUrl(application, hostSlug) {
|
|
10
15
|
const segment = application.type === 'studio' ? 'studios' : 'applications';
|
|
11
|
-
return `${getWorkbenchUrl(application.organizationId)}/${segment}/${application.slug ?? application.id}`;
|
|
16
|
+
return `${getWorkbenchUrl(application.organizationId, hostSlug)}/${segment}/${application.slug ?? application.id}`;
|
|
12
17
|
}
|
|
13
18
|
async function getClient() {
|
|
14
19
|
return getGlobalCliClient({
|
|
@@ -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\nexport function getWorkbenchUrl(organizationId: string): string {\n return `https://${organizationId.toLowerCase()}.${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): string {\n const segment = application.type === 'studio' ? 'studios' : 'applications'\n return `${getWorkbenchUrl(application.organizationId)}/${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","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,OAAO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;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,MAAMD;IAChE;AACF;AAEA,SAAS6C,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,IAAI3E;QACxBmD,SAASa,SAASY,UAAU;QAC5B/B,QAAQ;QACRxB;IACF;AACF"}
|
|
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;QAACgB,YAAYb;QAA2Bc,aAAa;IAAI;AACrF;AAEA,OAAO,eAAeC,eAAeC,aAAqB;IACxD,MAAMC,SAAS,MAAML;IACrB,IAAI;QACF,OAAO,MAAMK,OAAOC,OAAO,CAAC;YAACC,KAAK,CAAC,cAAc,EAAEH,eAAe;QAAA;IACpE,EAAE,OAAOI,KAAK;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,OAAO;QAC/D,MAAMD;IACR;AACF;AAEA,OAAO,eAAeE,2BACpBpB,cAAsB,EACtBqB,QAAgB,EAChBC,MAAoB;IAIpB,MAAMP,SAAS,MAAMpB,mBAAmB;QACtCgB,YAAY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B/B,QAAQ;QACRxB;IACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getGlobalCliClient } from '@sanity/cli-core';
|
|
2
|
-
|
|
2
|
+
// From this version `slug` is the org's host slug: `null` when the org has none or can't use one.
|
|
3
|
+
const ORGANIZATIONS_API_VERSION = 'v2026-11-27';
|
|
3
4
|
export async function getOrganization(organizationId, signal) {
|
|
4
5
|
const client = await getGlobalCliClient({
|
|
5
6
|
apiVersion: ORGANIZATIONS_API_VERSION,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/organizations.ts"],"sourcesContent":["import {getGlobalCliClient} from '@sanity/cli-core'\n\nconst ORGANIZATIONS_API_VERSION = '
|
|
1
|
+
{"version":3,"sources":["../../src/services/organizations.ts"],"sourcesContent":["import {getGlobalCliClient} from '@sanity/cli-core'\n\n// From this version `slug` is the org's host slug: `null` when the org has none or can't use one.\nconst ORGANIZATIONS_API_VERSION = 'v2026-11-27'\n\nexport async function getOrganization(\n organizationId: string,\n signal?: AbortSignal,\n): Promise<{name: string; slug: string | null}> {\n const client = await getGlobalCliClient({\n apiVersion: ORGANIZATIONS_API_VERSION,\n requireUser: true,\n })\n\n return client.request({signal, url: `/organizations/${organizationId}`})\n}\n"],"names":["getGlobalCliClient","ORGANIZATIONS_API_VERSION","getOrganization","organizationId","signal","client","apiVersion","requireUser","request","url"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,mBAAkB;AAEnD,kGAAkG;AAClG,MAAMC,4BAA4B;AAElC,OAAO,eAAeC,gBACpBC,cAAsB,EACtBC,MAAoB;IAEpB,MAAMC,SAAS,MAAML,mBAAmB;QACtCM,YAAYL;QACZM,aAAa;IACf;IAEA,OAAOF,OAAOG,OAAO,CAAC;QAACJ;QAAQK,KAAK,CAAC,eAAe,EAAEN,gBAAgB;IAAA;AACxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/workbench-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.1",
|
|
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",
|
|
@@ -66,29 +66,29 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@module-federation/runtime": "2.9.4",
|
|
69
|
-
"@module-federation/vite": "1.25.
|
|
70
|
-
"@sanity/cli-core": "^3.
|
|
71
|
-
"@sanity/sdk": "^3.
|
|
72
|
-
"@sanity/types": "^6.
|
|
73
|
-
"@vitejs/plugin-react": "^6.3.
|
|
69
|
+
"@module-federation/vite": "1.25.1",
|
|
70
|
+
"@sanity/cli-core": "^3.18.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
78
|
"tar": "^7.5.23",
|
|
79
|
-
"vite": "^8.4.
|
|
79
|
+
"vite": "^8.4.1",
|
|
80
80
|
"zod": "^4.6.7"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@repo/oxc-config": "0.0.0",
|
|
84
84
|
"@repo/package.config": "0.0.1",
|
|
85
85
|
"@repo/tsconfig": "3.70.0",
|
|
86
|
-
"@sanity/cli-test": "
|
|
86
|
+
"@sanity/cli-test": "28.0.0",
|
|
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.
|
|
91
|
-
"@types/react": "^19.3.
|
|
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",
|