@sanity/workbench-cli 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,6 +61,22 @@ declare function toWorkbenchPayload(workbench: DeployableWorkbenchApp | null, {
61
61
  } | null;
62
62
  title: string;
63
63
  }): Partial<WorkbenchDeployPayload>;
64
+ declare function fetchDeploySummaryDetails(organizationId: string): Promise<{
65
+ organizationName: string | null;
66
+ userName: string | null;
67
+ }>;
68
+ declare function formatDeploySummary(options: {
69
+ applicationId: string;
70
+ created: boolean;
71
+ durationMs: number;
72
+ isApp: boolean;
73
+ organizationId: string;
74
+ organizationName?: string | null;
75
+ showAppIdHint: boolean;
76
+ title: string;
77
+ url: string;
78
+ userName?: string | null;
79
+ }): string;
64
80
  type ApplicationType = 'coreApp' | 'studio';
65
81
  interface Application {
66
82
  id: string;
@@ -181,5 +197,5 @@ declare function selectWorkbenchAppId({ appId, flags, organizationId, type }: {
181
197
  organizationId: string | undefined;
182
198
  type: ApplicationType;
183
199
  }): Promise<string | undefined>;
184
- export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
200
+ export { type Application, type BrettAccess, type BrettWorkspace, type CreatedApplication, type DeployedInterface, type DeployedView, type DeployedWebWorker, type ResolvedMediaLibraryConfig, type WorkbenchDeployPayload, createCoreApp, createStudio, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplication, getApplicationUrl, getWorkbench, getWorkbenchUrl, listApplications, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, summarizeInterfaces, toWorkbenchPayload };
185
201
  //# sourceMappingURL=deploy.d.ts.map
@@ -1,5 +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
4
  export { createCoreApp, createStudio, deployWorkbenchApp } from '../actions/deploy/deployWorkbenchApp.js';
4
5
  export { getWorkbench } from '../actions/deploy/getWorkbench.js';
5
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 {\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 {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\n"],"names":["deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","selectWorkbenchAppId","summarizeInterfaces","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SACEA,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,oBAAoB,QAAO,4CAA2C;AAC9E,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
1
+ {"version":3,"sources":["../../src/_exports/deploy.ts"],"sourcesContent":["export {\n deployConfig,\n resolveInstallationId,\n summarizeConfig,\n} from '../actions/deploy/deployConfig.js'\nexport {toWorkbenchPayload, type WorkbenchDeployPayload} from '../actions/deploy/deployPayload.js'\nexport {fetchDeploySummaryDetails, formatDeploySummary} 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 {type ResolvedMediaLibraryConfig, resolveWorkbenchConfig} from '../resolveWorkbenchConfig.js'\nexport {\n type Application,\n type BrettAccess,\n type BrettWorkspace,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '../services/applications.js'\n"],"names":["deployConfig","resolveInstallationId","summarizeConfig","toWorkbenchPayload","fetchDeploySummaryDetails","formatDeploySummary","createCoreApp","createStudio","deployWorkbenchApp","getWorkbench","selectWorkbenchAppId","summarizeInterfaces","resolveWorkbenchConfig","getApplication","getApplicationUrl","getWorkbenchUrl","listApplications"],"mappings":"AAAA,SACEA,YAAY,EACZC,qBAAqB,EACrBC,eAAe,QACV,oCAAmC;AAC1C,SAAQC,kBAAkB,QAAoC,qCAAoC;AAClG,SAAQC,yBAAyB,EAAEC,mBAAmB,QAAO,qCAAoC;AACjG,SACEC,aAAa,EAEbC,YAAY,EACZC,kBAAkB,QACb,0CAAyC;AAChD,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,oBAAoB,QAAO,4CAA2C;AAC9E,SAIEC,mBAAmB,QACd,2CAA0C;AACjD,SAAyCC,sBAAsB,QAAO,+BAA8B;AACpG,SAIEC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,8BAA6B"}
@@ -33,9 +33,10 @@ interface StartWorkbenchDevOptions {
33
33
  reactStrictMode: boolean;
34
34
  /** Start the app/studio dev server — the CLI owns the server, this orchestrates it. */
35
35
  startAppServer: (params: {
36
- announceUrl: boolean;
37
36
  cliConfig: CliConfig;
38
37
  httpPort: number;
38
+ isRestarting?: boolean;
39
+ quiet?: boolean;
39
40
  }) => Promise<AppServerResult>;
40
41
  workDir: string;
41
42
  }
@@ -0,0 +1,36 @@
1
+ import { styleText } from 'node:util';
2
+ import { logSymbols } from '@sanity/cli-core/ux';
3
+ import { getOrganization } from '../../services/organizations.js';
4
+ import { getCurrentUser } from '../../services/users.js';
5
+ import { formatSummary, SUMMARY_LOOKUP_TIMEOUT_MS } from '../summary.js';
6
+ export async function fetchDeploySummaryDetails(organizationId) {
7
+ const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS);
8
+ const [organizationName, userName] = await Promise.all([
9
+ getOrganization(organizationId, signal).then((org)=>org.name).catch(()=>null),
10
+ getCurrentUser(signal).then((user)=>user.name).catch(()=>null)
11
+ ]);
12
+ return {
13
+ organizationName,
14
+ userName
15
+ };
16
+ }
17
+ export function formatDeploySummary(options) {
18
+ const { applicationId, created, durationMs, isApp, showAppIdHint, title, url, userName } = options;
19
+ const summary = formatSummary({
20
+ durationMs,
21
+ heading: `${title} deployed`,
22
+ isApp,
23
+ organization: options.organizationName ?? options.organizationId,
24
+ title,
25
+ url,
26
+ version: userName ? `just now by ${userName}` : 'just now'
27
+ });
28
+ const result = created ? `Created ${title} as a new ${isApp ? 'application' : 'studio'}.` : `Updated ${title}.`;
29
+ const success = styleText('green', ` ${logSymbols.success} ${result}`);
30
+ const appIdHint = showAppIdHint ? `\n ${styleText('dim', 'Add')} deployment.appId: "${applicationId}" ${styleText('dim', 'to sanity.cli.ts so the next deploy updates it')}\n` : '';
31
+ return `${summary}
32
+ ${success}
33
+ ${appIdHint}`;
34
+ }
35
+
36
+ //# sourceMappingURL=deploySummary.js.map
@@ -0,0 +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 fetchDeploySummaryDetails(organizationId: string) {\n const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS)\n const [organizationName, userName] = await Promise.all([\n getOrganization(organizationId, signal)\n .then((org) => org.name)\n .catch(() => null),\n getCurrentUser(signal)\n .then((user) => user.name)\n .catch(() => null),\n ])\n\n return {organizationName, userName}\n}\n\nexport function formatDeploySummary(options: {\n applicationId: string\n created: boolean\n durationMs: number\n isApp: boolean\n organizationId: string\n organizationName?: string | null\n showAppIdHint: boolean\n title: string\n url: string\n userName?: string | null\n}): string {\n const {applicationId, created, durationMs, isApp, showAppIdHint, title, url, userName} = options\n\n const summary = formatSummary({\n durationMs,\n heading: `${title} deployed`,\n isApp,\n organization: options.organizationName ?? options.organizationId,\n title,\n url,\n version: userName ? `just now by ${userName}` : 'just now',\n })\n const result = created\n ? `Created ${title} as a new ${isApp ? 'application' : 'studio'}.`\n : `Updated ${title}.`\n const success = styleText('green', ` ${logSymbols.success} ${result}`)\n const appIdHint = showAppIdHint\n ? `\\n ${styleText('dim', 'Add')} deployment.appId: \"${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"],"names":["styleText","logSymbols","getOrganization","getCurrentUser","formatSummary","SUMMARY_LOOKUP_TIMEOUT_MS","fetchDeploySummaryDetails","organizationId","signal","AbortSignal","timeout","organizationName","userName","Promise","all","then","org","name","catch","user","formatDeploySummary","options","applicationId","created","durationMs","isApp","showAppIdHint","title","url","summary","heading","organization","version","result","success","appIdHint"],"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,OAAO,eAAeC,0BAA0BC,cAAsB;IACpE,MAAMC,SAASC,YAAYC,OAAO,CAACL;IACnC,MAAM,CAACM,kBAAkBC,SAAS,GAAG,MAAMC,QAAQC,GAAG,CAAC;QACrDZ,gBAAgBK,gBAAgBC,QAC7BO,IAAI,CAAC,CAACC,MAAQA,IAAIC,IAAI,EACtBC,KAAK,CAAC,IAAM;QACff,eAAeK,QACZO,IAAI,CAAC,CAACI,OAASA,KAAKF,IAAI,EACxBC,KAAK,CAAC,IAAM;KAChB;IAED,OAAO;QAACP;QAAkBC;IAAQ;AACpC;AAEA,OAAO,SAASQ,oBAAoBC,OAWnC;IACC,MAAM,EAACC,aAAa,EAAEC,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,aAAa,EAAEC,KAAK,EAAEC,GAAG,EAAEhB,QAAQ,EAAC,GAAGS;IAEzF,MAAMQ,UAAUzB,cAAc;QAC5BoB;QACAM,SAAS,GAAGH,MAAM,SAAS,CAAC;QAC5BF;QACAM,cAAcV,QAAQV,gBAAgB,IAAIU,QAAQd,cAAc;QAChEoB;QACAC;QACAI,SAASpB,WAAW,CAAC,YAAY,EAAEA,UAAU,GAAG;IAClD;IACA,MAAMqB,SAASV,UACX,CAAC,QAAQ,EAAEI,MAAM,UAAU,EAAEF,QAAQ,gBAAgB,SAAS,CAAC,CAAC,GAChE,CAAC,QAAQ,EAAEE,MAAM,CAAC,CAAC;IACvB,MAAMO,UAAUlC,UAAU,SAAS,CAAC,EAAE,EAAEC,WAAWiC,OAAO,CAAC,CAAC,EAAED,QAAQ;IACtE,MAAME,YAAYT,gBACd,CAAC,IAAI,EAAE1B,UAAU,OAAO,OAAO,oBAAoB,EAAEsB,cAAc,EAAE,EAAEtB,UAAU,OAAO,kDAAkD,EAAE,CAAC,GAC7I;IAEJ,OAAO,GAAG6B,QAAQ;AACpB,EAAEK,QAAQ;AACV,EAAEC,WAAW;AACb"}
@@ -34,7 +34,9 @@ const noop = async ()=>{};
34
34
  const freshConfig = await getCliConfigUncached(workDir);
35
35
  await closeCurrent();
36
36
  closeCurrent = noop;
37
- const result = await start(freshConfig);
37
+ const result = await start(freshConfig, {
38
+ isRestarting: true
39
+ });
38
40
  if (!result.started) {
39
41
  // The server already reported why (e.g. organizationId was removed).
40
42
  throw new Error('Dev server did not restart after the view/web worker change');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/dev/appServerSupervisor.ts"],"sourcesContent":["import {type CliConfig, getCliConfigUncached} from '@sanity/cli-core'\nimport {type ViteDevServer} from 'vite'\n\n/**\n * Minimal shape the supervisor needs back from a started app/studio dev server.\n * The not-started arm is reserved for expected early exits the server already\n * reported (e.g. a missing organization id) — a failure to *boot* still throws.\n */\nexport type AppServerResult =\n | {close: () => Promise<void>; server: ViteDevServer; started: true}\n | {reason: string; started: false}\n\n/** Start the app/studio dev server for a given config (port + URL intent baked in by the caller). */\nexport type StartAppServer = (cliConfig: CliConfig) => Promise<AppServerResult>\n\nconst noop = async () => {}\n\nexport interface AppServerSupervisor {\n /** Stop the server once, waiting out any rebuild already in flight. */\n close: () => Promise<void>\n /** Tear down the running server and bring it back up with a freshly-loaded config. */\n rebuild: () => Promise<ViteDevServer>\n /** The currently-live dev server; re-points after a rebuild. */\n readonly server: ViteDevServer\n}\n\n/**\n * Own the app/studio dev server's lifecycle behind the dev-server registry seam.\n *\n * Adding or removing a view/web worker rebuilds the federation remote: its\n * module-federation `exposes` map and codegen artifacts are computed once at\n * server start, so a newly-declared interface has no expose until the server is\n * recreated — `server.restart()` can't do it (it reuses the inline config).\n * `rebuild` therefore tears the server down and starts a fresh one with a\n * reloaded config; the registry watcher calls it when the interface set changes.\n *\n * Returns the not-started result verbatim when the initial boot is an expected\n * early exit, so the caller can skip the rest of the orchestration.\n */\nexport async function startAppServerSupervisor(options: {\n cliConfig: CliConfig\n start: StartAppServer\n workDir: string\n}): Promise<{reason: string; started: false} | {started: true; supervisor: AppServerSupervisor}> {\n const {cliConfig, start, workDir} = options\n\n const initial = await start(cliConfig)\n if (!initial.started) return {reason: initial.reason, started: false}\n\n // `closeCurrent` repoints at the replacement only once a rebuild succeeds, so a\n // failed rebuild (old server already closed) leaves nothing for close() to re-close.\n let server = initial.server\n let closeCurrent = initial.close\n let closed = false\n // close() waits on this so a rebuild racing teardown can't orphan the replacement.\n // Rejections are the watcher's (warn + retry); the tracked copy is swallowed.\n let rebuildInFlight: Promise<unknown> = Promise.resolve()\n\n const runRebuild = async (): Promise<ViteDevServer> => {\n // Refuse once shutting down — a config save in the teardown window must not\n // boot a replacement nobody owns.\n if (closed) throw new Error('Dev server is shutting down')\n const freshConfig = await getCliConfigUncached(workDir)\n await closeCurrent()\n closeCurrent = noop\n const result = await start(freshConfig)\n if (!result.started) {\n // The server already reported why (e.g. organizationId was removed).\n throw new Error('Dev server did not restart after the view/web worker change')\n }\n server = result.server\n closeCurrent = result.close\n return server\n }\n\n return {\n started: true,\n supervisor: {\n async close() {\n closed = true\n await rebuildInFlight\n await closeCurrent()\n },\n rebuild() {\n const rebuild = runRebuild()\n rebuildInFlight = rebuild.catch(() => {})\n return rebuild\n },\n get server() {\n return server\n },\n },\n }\n}\n"],"names":["getCliConfigUncached","noop","startAppServerSupervisor","options","cliConfig","start","workDir","initial","started","reason","server","closeCurrent","close","closed","rebuildInFlight","Promise","resolve","runRebuild","Error","freshConfig","result","supervisor","rebuild","catch"],"mappings":"AAAA,SAAwBA,oBAAoB,QAAO,mBAAkB;AAerE,MAAMC,OAAO,WAAa;AAW1B;;;;;;;;;;;;CAYC,GACD,OAAO,eAAeC,yBAAyBC,OAI9C;IACC,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGH;IAEpC,MAAMI,UAAU,MAAMF,MAAMD;IAC5B,IAAI,CAACG,QAAQC,OAAO,EAAE,OAAO;QAACC,QAAQF,QAAQE,MAAM;QAAED,SAAS;IAAK;IAEpE,gFAAgF;IAChF,qFAAqF;IACrF,IAAIE,SAASH,QAAQG,MAAM;IAC3B,IAAIC,eAAeJ,QAAQK,KAAK;IAChC,IAAIC,SAAS;IACb,mFAAmF;IACnF,8EAA8E;IAC9E,IAAIC,kBAAoCC,QAAQC,OAAO;IAEvD,MAAMC,aAAa;QACjB,4EAA4E;QAC5E,kCAAkC;QAClC,IAAIJ,QAAQ,MAAM,IAAIK,MAAM;QAC5B,MAAMC,cAAc,MAAMnB,qBAAqBM;QAC/C,MAAMK;QACNA,eAAeV;QACf,MAAMmB,SAAS,MAAMf,MAAMc;QAC3B,IAAI,CAACC,OAAOZ,OAAO,EAAE;YACnB,qEAAqE;YACrE,MAAM,IAAIU,MAAM;QAClB;QACAR,SAASU,OAAOV,MAAM;QACtBC,eAAeS,OAAOR,KAAK;QAC3B,OAAOF;IACT;IAEA,OAAO;QACLF,SAAS;QACTa,YAAY;YACV,MAAMT;gBACJC,SAAS;gBACT,MAAMC;gBACN,MAAMH;YACR;YACAW;gBACE,MAAMA,UAAUL;gBAChBH,kBAAkBQ,QAAQC,KAAK,CAAC,KAAO;gBACvC,OAAOD;YACT;YACA,IAAIZ;gBACF,OAAOA;YACT;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/dev/appServerSupervisor.ts"],"sourcesContent":["import {type CliConfig, getCliConfigUncached} from '@sanity/cli-core'\nimport {type ViteDevServer} from 'vite'\n\n/**\n * Minimal shape the supervisor needs back from a started app/studio dev server.\n * The not-started arm is reserved for expected early exits the server already\n * reported (e.g. a missing organization id) — a failure to *boot* still throws.\n */\nexport type AppServerResult =\n | {close: () => Promise<void>; server: ViteDevServer; started: true}\n | {reason: string; started: false}\n\n/** Start the app/studio dev server for a given config (port + URL intent baked in by the caller). */\nexport type StartAppServer = (\n cliConfig: CliConfig,\n options?: {isRestarting?: boolean},\n) => Promise<AppServerResult>\n\nconst noop = async () => {}\n\nexport interface AppServerSupervisor {\n /** Stop the server once, waiting out any rebuild already in flight. */\n close: () => Promise<void>\n /** Tear down the running server and bring it back up with a freshly-loaded config. */\n rebuild: () => Promise<ViteDevServer>\n /** The currently-live dev server; re-points after a rebuild. */\n readonly server: ViteDevServer\n}\n\n/**\n * Own the app/studio dev server's lifecycle behind the dev-server registry seam.\n *\n * Adding or removing a view/web worker rebuilds the federation remote: its\n * module-federation `exposes` map and codegen artifacts are computed once at\n * server start, so a newly-declared interface has no expose until the server is\n * recreated — `server.restart()` can't do it (it reuses the inline config).\n * `rebuild` therefore tears the server down and starts a fresh one with a\n * reloaded config; the registry watcher calls it when the interface set changes.\n *\n * Returns the not-started result verbatim when the initial boot is an expected\n * early exit, so the caller can skip the rest of the orchestration.\n */\nexport async function startAppServerSupervisor(options: {\n cliConfig: CliConfig\n start: StartAppServer\n workDir: string\n}): Promise<{reason: string; started: false} | {started: true; supervisor: AppServerSupervisor}> {\n const {cliConfig, start, workDir} = options\n\n const initial = await start(cliConfig)\n if (!initial.started) return {reason: initial.reason, started: false}\n\n // `closeCurrent` repoints at the replacement only once a rebuild succeeds, so a\n // failed rebuild (old server already closed) leaves nothing for close() to re-close.\n let server = initial.server\n let closeCurrent = initial.close\n let closed = false\n // close() waits on this so a rebuild racing teardown can't orphan the replacement.\n // Rejections are the watcher's (warn + retry); the tracked copy is swallowed.\n let rebuildInFlight: Promise<unknown> = Promise.resolve()\n\n const runRebuild = async (): Promise<ViteDevServer> => {\n // Refuse once shutting down — a config save in the teardown window must not\n // boot a replacement nobody owns.\n if (closed) throw new Error('Dev server is shutting down')\n const freshConfig = await getCliConfigUncached(workDir)\n await closeCurrent()\n closeCurrent = noop\n const result = await start(freshConfig, {isRestarting: true})\n if (!result.started) {\n // The server already reported why (e.g. organizationId was removed).\n throw new Error('Dev server did not restart after the view/web worker change')\n }\n server = result.server\n closeCurrent = result.close\n return server\n }\n\n return {\n started: true,\n supervisor: {\n async close() {\n closed = true\n await rebuildInFlight\n await closeCurrent()\n },\n rebuild() {\n const rebuild = runRebuild()\n rebuildInFlight = rebuild.catch(() => {})\n return rebuild\n },\n get server() {\n return server\n },\n },\n }\n}\n"],"names":["getCliConfigUncached","noop","startAppServerSupervisor","options","cliConfig","start","workDir","initial","started","reason","server","closeCurrent","close","closed","rebuildInFlight","Promise","resolve","runRebuild","Error","freshConfig","result","isRestarting","supervisor","rebuild","catch"],"mappings":"AAAA,SAAwBA,oBAAoB,QAAO,mBAAkB;AAkBrE,MAAMC,OAAO,WAAa;AAW1B;;;;;;;;;;;;CAYC,GACD,OAAO,eAAeC,yBAAyBC,OAI9C;IACC,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGH;IAEpC,MAAMI,UAAU,MAAMF,MAAMD;IAC5B,IAAI,CAACG,QAAQC,OAAO,EAAE,OAAO;QAACC,QAAQF,QAAQE,MAAM;QAAED,SAAS;IAAK;IAEpE,gFAAgF;IAChF,qFAAqF;IACrF,IAAIE,SAASH,QAAQG,MAAM;IAC3B,IAAIC,eAAeJ,QAAQK,KAAK;IAChC,IAAIC,SAAS;IACb,mFAAmF;IACnF,8EAA8E;IAC9E,IAAIC,kBAAoCC,QAAQC,OAAO;IAEvD,MAAMC,aAAa;QACjB,4EAA4E;QAC5E,kCAAkC;QAClC,IAAIJ,QAAQ,MAAM,IAAIK,MAAM;QAC5B,MAAMC,cAAc,MAAMnB,qBAAqBM;QAC/C,MAAMK;QACNA,eAAeV;QACf,MAAMmB,SAAS,MAAMf,MAAMc,aAAa;YAACE,cAAc;QAAI;QAC3D,IAAI,CAACD,OAAOZ,OAAO,EAAE;YACnB,qEAAqE;YACrE,MAAM,IAAIU,MAAM;QAClB;QACAR,SAASU,OAAOV,MAAM;QACtBC,eAAeS,OAAOR,KAAK;QAC3B,OAAOF;IACT;IAEA,OAAO;QACLF,SAAS;QACTc,YAAY;YACV,MAAMV;gBACJC,SAAS;gBACT,MAAMC;gBACN,MAAMH;YACR;YACAY;gBACE,MAAMA,UAAUN;gBAChBH,kBAAkBS,QAAQC,KAAK,CAAC,KAAO;gBACvC,OAAOD;YACT;YACA,IAAIb;gBACF,OAAOA;YACT;QACF;IACF;AACF"}
@@ -0,0 +1,33 @@
1
+ import { emitKeypressEvents } from 'node:readline';
2
+ import { styleText } from 'node:util';
3
+ import open from 'open';
4
+ export function bindDevShortcuts({ output, quit, url }) {
5
+ const { stdin } = process;
6
+ if (!stdin.isTTY) return async ()=>{};
7
+ const onKeypress = (_, key = {})=>{
8
+ const isWindows = process.platform === 'win32';
9
+ if (key.ctrl && key.name === 'c' && !isWindows) {
10
+ // Raw mode stops the terminal from signalling the process group, so the parent (pnpm) needs it too.
11
+ process.kill(0, 'SIGINT');
12
+ } else if (key.name === 'q' || key.ctrl && (key.name === 'c' || key.name === 'd')) {
13
+ quit();
14
+ } else if (key.ctrl && key.name === 'z' && !isWindows) {
15
+ stdin.setRawMode(false);
16
+ process.once('SIGCONT', ()=>stdin.setRawMode(true));
17
+ process.kill(0, 'SIGTSTP');
18
+ } else if (key.name === 'o') {
19
+ open(url).catch((err)=>output.warn(`Could not open ${url}: ${err.message}`));
20
+ }
21
+ };
22
+ emitKeypressEvents(stdin);
23
+ stdin.setRawMode(true);
24
+ stdin.on('keypress', onKeypress);
25
+ output.log(` ${styleText('dim', 'press')} o ${styleText('dim', 'to open ·')} q ${styleText('dim', 'to quit')}\n`);
26
+ return async ()=>{
27
+ stdin.off('keypress', onKeypress);
28
+ stdin.setRawMode(false);
29
+ stdin.pause();
30
+ };
31
+ }
32
+
33
+ //# sourceMappingURL=bindDevShortcuts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/dev/bindDevShortcuts.ts"],"sourcesContent":["import {emitKeypressEvents, type Key} from 'node:readline'\nimport {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\nimport open from 'open'\n\nexport function bindDevShortcuts({\n output,\n quit,\n url,\n}: {\n output: Output\n quit: () => void\n url: string\n}): () => Promise<void> {\n const {stdin} = process\n if (!stdin.isTTY) return async () => {}\n\n const onKeypress = (_: string | undefined, key: Key = {}) => {\n const isWindows = process.platform === 'win32'\n\n if (key.ctrl && key.name === 'c' && !isWindows) {\n // Raw mode stops the terminal from signalling the process group, so the parent (pnpm) needs it too.\n process.kill(0, 'SIGINT')\n } else if (key.name === 'q' || (key.ctrl && (key.name === 'c' || key.name === 'd'))) {\n quit()\n } else if (key.ctrl && key.name === 'z' && !isWindows) {\n stdin.setRawMode(false)\n process.once('SIGCONT', () => stdin.setRawMode(true))\n process.kill(0, 'SIGTSTP')\n } else if (key.name === 'o') {\n open(url).catch((err) => output.warn(`Could not open ${url}: ${err.message}`))\n }\n }\n\n emitKeypressEvents(stdin)\n stdin.setRawMode(true)\n stdin.on('keypress', onKeypress)\n output.log(\n ` ${styleText('dim', 'press')} o ${styleText('dim', 'to open ·')} q ${styleText('dim', 'to quit')}\\n`,\n )\n\n return async () => {\n stdin.off('keypress', onKeypress)\n stdin.setRawMode(false)\n stdin.pause()\n }\n}\n"],"names":["emitKeypressEvents","styleText","open","bindDevShortcuts","output","quit","url","stdin","process","isTTY","onKeypress","_","key","isWindows","platform","ctrl","name","kill","setRawMode","once","catch","err","warn","message","on","log","off","pause"],"mappings":"AAAA,SAAQA,kBAAkB,QAAiB,gBAAe;AA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AAC;QACjBX,MAAMoB,KAAK;IACb;AACF"}
@@ -0,0 +1,49 @@
1
+ import { spinner } from '@sanity/cli-core/ux';
2
+ import { getOrganizationApplication } from '../../services/applications.js';
3
+ import { getOrganization } from '../../services/organizations.js';
4
+ import { getUser } from '../../services/users.js';
5
+ import { SUMMARY_LOOKUP_TIMEOUT_MS } from '../summary.js';
6
+ const PENDING = Symbol('pending');
7
+ export async function fetchDevSummaryDetails({ idOrSlug, organizationId }) {
8
+ if (!organizationId) return {};
9
+ const signal = AbortSignal.timeout(SUMMARY_LOOKUP_TIMEOUT_MS);
10
+ const organizationName = getOrganization(organizationId, signal).then((org)=>org.name).catch(()=>null);
11
+ if (!idOrSlug) {
12
+ return {
13
+ organizationName: await organizationName
14
+ };
15
+ }
16
+ let deployment;
17
+ try {
18
+ const application = await getOrganizationApplication(organizationId, idOrSlug, signal);
19
+ const active = application?.activeDeployment;
20
+ if (active) {
21
+ const deployedBy = await getUser(active.deployedBy, signal).then((user)=>user.displayName).catch(()=>null);
22
+ deployment = {
23
+ createdAt: active.createdAt,
24
+ deployedBy
25
+ };
26
+ } else {
27
+ deployment = null;
28
+ }
29
+ } catch {
30
+ // Left undefined: a failed lookup must not read as "not deployed".
31
+ }
32
+ return {
33
+ deployment,
34
+ organizationName: await organizationName
35
+ };
36
+ }
37
+ export async function waitForDevSummaryDetails(details) {
38
+ const settled = await Promise.race([
39
+ details,
40
+ new Promise((resolve)=>setImmediate(resolve, PENDING))
41
+ ]);
42
+ if (settled !== PENDING) return settled;
43
+ const spin = spinner('Loading organization and deployment details').start();
44
+ const result = await details;
45
+ spin.stop();
46
+ return result;
47
+ }
48
+
49
+ //# sourceMappingURL=devSummary.js.map
@@ -0,0 +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,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from 'node:util';
2
+ import { isWorkbenchApp } from '../../defineApp.js';
2
3
  import { createServerLifecycle, toDisplayHost } from '../../util/serverOrchestration.js';
4
+ import { formatSummary } from '../summary.js';
3
5
  import { startAppServerSupervisor } from './appServerSupervisor.js';
6
+ import { bindDevShortcuts } from './bindDevShortcuts.js';
7
+ import { fetchDevSummaryDetails, waitForDevSummaryDetails } from './devSummary.js';
4
8
  import { startDevServerRegistration } from './startDevServerRegistration.js';
5
9
  import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './startWorkbenchDevServer.js';
6
10
  /**
@@ -18,7 +22,6 @@ import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './star
18
22
  // shell) that still bridges the registry.
19
23
  if (process.env.SANITY_INTERNAL_IS_WORKBENCH_REMOTE === 'true') {
20
24
  const remote = await startAppServer({
21
- announceUrl: true,
22
25
  cliConfig,
23
26
  httpPort
24
27
  });
@@ -38,6 +41,13 @@ import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './star
38
41
  // Unwound in reverse on any failure or on close(): the watcher stops before
39
42
  // the app server, and the supervisor waits out an in-flight rebuild.
40
43
  const { close, closers, installSignalHandlers } = createServerLifecycle();
44
+ const startedAt = Date.now();
45
+ const app = isWorkbenchApp(cliConfig.app) ? cliConfig.app : undefined;
46
+ const organizationId = cliConfig.app?.organizationId;
47
+ const details = fetchDevSummaryDetails({
48
+ idOrSlug: app && (cliConfig.deployment?.appId ?? app.slug),
49
+ organizationId
50
+ });
41
51
  const workbench = await startWorkbenchDevServer({
42
52
  cacheDir,
43
53
  cliConfig,
@@ -51,13 +61,13 @@ import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './star
51
61
  // A running workbench owns the configured port; the app server takes the next.
52
62
  // Without one it claims the configured port and announces its own URL.
53
63
  const appPort = workbench.workbenchAvailable ? workbench.workbenchPort + 1 : httpPort;
54
- const announceUrl = !workbench.workbenchAvailable;
55
64
  const supervised = await startAppServerSupervisor({
56
65
  cliConfig,
57
- start: (config)=>startAppServer({
58
- announceUrl,
66
+ start: (config, { isRestarting } = {})=>startAppServer({
59
67
  cliConfig: config,
60
- httpPort: appPort
68
+ httpPort: appPort,
69
+ isRestarting,
70
+ quiet: workbench.workbenchAvailable
61
71
  }),
62
72
  workDir
63
73
  }).catch(async (err)=>{
@@ -94,14 +104,39 @@ import { startWorkbenchDevServer, startWorkbenchRemoteCoordinator } from './star
94
104
  await close();
95
105
  throw err;
96
106
  }
107
+ const durationMs = Date.now() - startedAt;
108
+ const { deployment, organizationName } = workbench.workbenchAvailable ? await waitForDevSummaryDetails(details) : {};
109
+ installSignalHandlers();
97
110
  if (workbench.workbenchAvailable) {
98
- const appUrl = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`;
99
- output.log(`Dashboard dev server started at ${styleText([
100
- 'blue',
101
- 'underline'
102
- ], appUrl)}`);
111
+ 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
+ output.log(formatSummary({
125
+ durationMs,
126
+ heading: 'Sanity Dashboard ready',
127
+ isApp,
128
+ organization: organizationName ?? organizationId,
129
+ title: app?.title,
130
+ url,
131
+ version
132
+ }));
133
+ const quit = ()=>void close().then(()=>process.exit(0));
134
+ closers.push(bindDevShortcuts({
135
+ output,
136
+ quit,
137
+ url
138
+ }));
103
139
  }
104
- installSignalHandlers();
105
140
  return {
106
141
  close
107
142
  };
@@ -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 {createServerLifecycle, toDisplayHost} from '../../util/serverOrchestration.js'\nimport {type AppServerResult, startAppServerSupervisor} from './appServerSupervisor.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 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 announceUrl: boolean\n cliConfig: CliConfig\n httpPort: number\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({announceUrl: true, 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\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 const announceUrl = !workbench.workbenchAvailable\n\n const supervised = await startAppServerSupervisor({\n cliConfig,\n start: (config) => startAppServer({announceUrl, cliConfig: config, httpPort: appPort}),\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 if (workbench.workbenchAvailable) {\n const appUrl = `http://${toDisplayHost(workbench.httpHost)}:${workbench.workbenchPort}${dashboardAppPath ?? ''}`\n output.log(`Dashboard dev server started at ${styleText(['blue', 'underline'], appUrl)}`)\n }\n\n installSignalHandlers()\n\n return {close}\n}\n"],"names":["styleText","createServerLifecycle","toDisplayHost","startAppServerSupervisor","startDevServerRegistration","startWorkbenchDevServer","startWorkbenchRemoteCoordinator","startWorkbenchDev","options","cacheDir","checkForDeprecatedAppId","cliConfig","extractManifest","httpHost","httpPort","isApp","output","reactStrictMode","startAppServer","workDir","process","env","SANITY_INTERNAL_IS_WORKBENCH_REMOTE","remote","announceUrl","started","close","coordinator","server","closers","installSignalHandlers","workbench","push","appPort","workbenchAvailable","workbenchPort","supervised","start","config","catch","err","supervisor","dashboardAppPath","registration","onInterfaceSetChange","rebuild","path","appUrl","log"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAInC,SAAQC,qBAAqB,EAAEC,aAAa,QAAO,oCAAmC;AACtF,SAA8BC,wBAAwB,QAAO,2BAA0B;AAEvF,SAAQC,0BAA0B,QAAO,kCAAiC;AAC1E,SACEC,uBAAuB,EACvBC,+BAA+B,QAC1B,+BAA8B;AA4BrC;;;;;;;;;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;YAACM,aAAa;YAAMb;YAAWG;QAAQ;QAC3E,IAAI,CAACS,OAAOE,OAAO,EAAE,OAAO;YAACC,OAAO,WAAa;QAAC;QAElD,MAAMC,cAAcrB,gCAAgC;YAACsB,QAAQL,OAAOK,MAAM;QAAA;QAE1E,OAAO;YACLF,OAAO;gBACL,MAAMC,YAAYD,KAAK;gBACvB,MAAMH,OAAOG,KAAK;YACpB;QACF;IACF;IAEA,4EAA4E;IAC5E,qEAAqE;IACrE,MAAM,EAACA,KAAK,EAAEG,OAAO,EAAEC,qBAAqB,EAAC,GA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;IAC1F;IAEAjB;IAEA,OAAO;QAACJ;IAAK;AACf"}
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} 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 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?.title,\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","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,QAAO,qBAAoB;AACjD,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;AA6BrC;;;;;;;;;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,GAAGhC;IAChD,MAAMiC,YAAYC,KAAKC,GAAG;IAC1B,MAAMC,MAAMrC,eA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AM2B;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,EAAE/D,cAAc2C,UAAU5B,QAAQ,EAAE,CAAC,EAAE4B,UAAUI,aAAa,GAAGS,oBAAoB,IAAI;QAC7G,IAAIQ,UAAU;QAEd,IAAIxB,YAAY;YACd,MAAMyB,OAAO,IAAIhC,KAAKO,WAAW0B,SAAS,EAAEC,kBAAkB,CAAC,SAAS;gBACtEC,KAAK;gBACLC,OAAO;gBACPC,MAAM;YACR;YACA,MAAMC,KAAK/B,WAAWgC,UAAU,GAAG,CAAC,IAAI,EAAEhC,WAAWgC,UAAU,EAAE,GAAG;YACpER,UAAU,CAAC,cAAc,EAAEnE,UAAU,OAAO,CAAC,WAAW,EAAEoE,OAAOM,IAAI,GAAG;QAC1E,OAAO,IAAI/B,eAAe,MAAM;YAC9BwB,UAAU,CAAC,cAAc,EAAEnE,UAAU,OAAO,mBAAmB;QACjE;QAEAqB,OAAOuD,GAAG,CACRxE,cAAc;YACZ4D;YACAa,SAAS;YACTzD;YACA0D,cAAcb,oBAAoBzB;YAClCuC,OAAOzC,KAAKyC;YACZb;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"}
@@ -0,0 +1,19 @@
1
+ import { styleText } from 'node:util';
2
+ export const SUMMARY_LOOKUP_TIMEOUT_MS = 3000;
3
+ export function formatSummary({ durationMs, heading, isApp, organization, title, url, version }) {
4
+ const seconds = (durationMs / 1000).toFixed(1);
5
+ const titleRow = title ? `\n ${(isApp ? 'App' : 'Studio').padEnd(12)} ${title}` : '';
6
+ const link = styleText([
7
+ 'blue',
8
+ 'underline'
9
+ ], url);
10
+ const versionRow = version ? `\n Version ${version}` : '';
11
+ return `
12
+ ${heading} in ${seconds}s
13
+
14
+ Organization ${organization}${titleRow}
15
+ URL ${link}${versionRow}
16
+ `;
17
+ }
18
+
19
+ //# sourceMappingURL=summary.js.map
@@ -0,0 +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: 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 link = styleText(['blue', 'underline'], url)\n const versionRow = version ? `\\n Version ${version}` : ''\n\n return `\n ${heading} in ${seconds}s\n\n Organization ${organization}${titleRow}\n URL ${link}${versionRow}\n`\n}\n"],"names":["styleText","SUMMARY_LOOKUP_TIMEOUT_MS","formatSummary","durationMs","heading","isApp","organization","title","url","version","seconds","toFixed","titleRow","padEnd","link","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,OAAOd,UAAU;QAAC;QAAQ;KAAY,EAAEQ;IAC9C,MAAMO,aAAaN,UAAU,CAAC,oBAAoB,EAAEA,SAAS,GAAG;IAEhE,OAAO,CAAC;EACR,EAAEL,QAAQ,IAAI,EAAEM,QAAQ;;kBAER,EAAEJ,eAAeM,SAAS;kBAC1B,EAAEE,OAAOC,WAAW;AACtC,CAAC;AACD"}
@@ -27,6 +27,28 @@ export async function getApplication(applicationId) {
27
27
  throw err;
28
28
  }
29
29
  }
30
+ export async function getOrganizationApplication(organizationId, idOrSlug, signal) {
31
+ const client = await getGlobalCliClient({
32
+ apiVersion: APP_WORKBENCH_API_VERSION,
33
+ ignoreWarnings: [
34
+ 'This is an experimental API version',
35
+ 'which will change without warning'
36
+ ],
37
+ requireUser: true
38
+ });
39
+ try {
40
+ return await client.request({
41
+ query: {
42
+ include: 'activeDeployment'
43
+ },
44
+ signal,
45
+ url: `/organizations/${organizationId}/applications/${idOrSlug}`
46
+ });
47
+ } catch (err) {
48
+ if (err?.statusCode === 404) return null;
49
+ throw err;
50
+ }
51
+ }
30
52
  /** Every application in an organization, in one page (`limit=none`). */ export async function listApplications(organizationId) {
31
53
  const client = await getClient();
32
54
  const { data } = await client.request({
@@ -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 {isStaging} from '@sanity/cli-core/util'\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 interface Application {\n id: string\n organizationId: string\n slug: string | null\n title: string\n type: ApplicationType\n\n /** Set when the customer serves the build; such an application never receives a tarball. */\n externalUrl?: string\n}\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}.${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\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 icon?: string | null\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/**\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}> {\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","getApplicationUrl","application","segment","type","slug","id","getClient","apiVersion","requireUser","getApplication","applicationId","client","request","url","err","statusCode","listApplications","data","query","limit","createApplication","options","externalUrl","isSingleton","name","projectId","title","visibility","body","undefined","config","studio","method","updateApplication","update","createDeployment","access","interfaces","isAutoUpdating","mfManifest","tarball","version","workspaces","formData","append","toString","appendDeploymentParts","deleteApplication","appendJson","length","contentType","filename","value","JSON","stringify","pipe","headers","getHeaders"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAA4BC,kBAAkB,QAAO,mBAAkB;AACvE,SAAQC,SAAS,QAAO,wBAAuB;AAC/C,OAAOC,cAAc,YAAW;AAGhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAyDzD,OAAO,SAASC,gBAAgBC,cAAsB;IACpD,OAAO,CAAC,QAAQ,EAAEA,eAAe,CAAC,EAAEJ,cAAc,oBAAoB,cAAc;AACtF;AAEA,4EAA4E,GAC5E,OAAO,SAASK,kBACdC,WAAyE;IAEzE,MAAMC,UAAUD,YAAYE,IAAI,KAAK,WAAW,YAAY;IAC5D,OAAO,GAAGL,gBAAgBG,YAAYF,cAAc,EAAE,CAAC,EAAEG,QAAQ,CAAC,EAAED,YAAYG,IAAI,IAAIH,YAAYI,EAAE,EAAE;AAC1G;AAEA,eAAeC;IACb,OAAOZ,mBAAmB;QAACa,YAAYV;QAA2BW,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,sEAAsE,GACtE,OAAO,eAAeE,iBAAiBjB,cAAsB;IAC3D,MAAMY,SAAS,MAAML;IACrB,MAAM,EAACW,IAAI,EAAC,GAA0B,MAAMN,OAAOC,OAAO,CAAC;QACzDM,OAAO;YAACC,OAAO;YAAQpB;QAAc;QACrCc,KAAK;IACP;IACA,OAAOI;AACT;AAEA;;;CAG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IAAU;IAC7F,OAAO9B,QAAQ,CAAC,cAAc,EAAEF,cAAc,YAAY,CAAC,EAAEiC;AAC/D;AAEA,0FAA0F,GAC1F,OAAO,eAAeI,kBAAkBrC,aAAqB;IAC3D,MAAMC,SAAS,MAAML;IACrB,IAAI;QACF,MAAMK,OAAOC,OAAO,CAAC;YAACoB,QAAQ;YAAUnB,KAAK,CAAC,cAAc,EAAEH,eAAe;QAAA;IAC/E,EAAE,OAAOI,KAAK;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,MAAMD;IAChE;AACF;AAEA,SAASgC,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;YAACU,aAAa;YAAoBC,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASH,WAAWL,QAAkB,EAAEnB,IAAY,EAAE4B,KAAc;IAClET,SAASC,MAAM,CAACpB,MAAM6B,KAAKC,SAAS,CAACF,QAAQ;QAACF,aAAa;IAAkB;AAC/E;AAEA,eAAetC,QAAWC,GAAW,EAAE8B,QAAkB;IACvD,MAAMhC,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBgB,MAAMe,SAASY,IAAI,CAAC,IAAI9D;QACxB+D,SAASb,SAASc,UAAU;QAC5BzB,QAAQ;QACRnB;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 {isStaging} from '@sanity/cli-core/util'\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 interface Application {\n id: string\n organizationId: string\n slug: string | null\n title: string\n type: ApplicationType\n\n /** Set when the customer serves the build; such an application never receives a tarball. */\n externalUrl?: string\n}\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}.${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 icon?: string | null\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/**\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}> {\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","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","createDeployment","access","interfaces","isAutoUpdating","mfManifest","tarball","version","workspaces","formData","append","toString","appendDeploymentParts","deleteApplication","appendJson","length","contentType","filename","value","JSON","stringify","pipe","headers","getHeaders"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAA4BC,kBAAkB,QAAO,mBAAkB;AACvE,SAAQC,SAAS,QAAO,wBAAuB;AAC/C,OAAOC,cAAc,YAAW;AAGhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAyDzD,OAAO,SAASC,gBAAgBC,cAAsB;IACpD,OAAO,CAAC,QAAQ,EAAEA,eAAe,CAAC,EAAEJ,cAAc,oBAAoB,cAAc;AACtF;AAEA,4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cAAc,EAAEF,cAAc,YAAY,CAAC,EAAEsC;AAC/D;AAEA,0FAA0F,GAC1F,OAAO,eAAeI,kBAAkB1C,aAAqB;IAC3D,MAAMC,SAAS,MAAML;IACrB,IAAI;QACF,MAAMK,OAAOC,OAAO,CAAC;YAACyB,QAAQ;YAAUxB,KAAK,CAAC,cAAc,EAAEH,eAAe;QAAA;IAC/E,EAAE,OAAOI,KAAK;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,MAAMD;IAChE;AACF;AAEA,SAASqC,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;YAACU,aAAa;YAAoBC,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASH,WAAWL,QAAkB,EAAEnB,IAAY,EAAE4B,KAAc;IAClET,SAASC,MAAM,CAACpB,MAAM6B,KAAKC,SAAS,CAACF,QAAQ;QAACF,aAAa;IAAkB;AAC/E;AAEA,eAAe3C,QAAWC,GAAW,EAAEmC,QAAkB;IACvD,MAAMrC,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBqB,MAAMe,SAASY,IAAI,CAAC,IAAInE;QACxBoE,SAASb,SAASc,UAAU;QAC5BzB,QAAQ;QACRxB;IACF;AACF"}
@@ -0,0 +1,14 @@
1
+ import { getGlobalCliClient } from '@sanity/cli-core';
2
+ const ORGANIZATIONS_API_VERSION = 'v2025-05-14';
3
+ export async function getOrganization(organizationId, signal) {
4
+ const client = await getGlobalCliClient({
5
+ apiVersion: ORGANIZATIONS_API_VERSION,
6
+ requireUser: true
7
+ });
8
+ return client.request({
9
+ signal,
10
+ url: `/organizations/${organizationId}`
11
+ });
12
+ }
13
+
14
+ //# sourceMappingURL=organizations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/services/organizations.ts"],"sourcesContent":["import {getGlobalCliClient} from '@sanity/cli-core'\n\nconst ORGANIZATIONS_API_VERSION = 'v2025-05-14'\n\nexport async function getOrganization(\n organizationId: string,\n signal?: AbortSignal,\n): Promise<{name: string}> {\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,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"}
@@ -0,0 +1,24 @@
1
+ import { getGlobalCliClient } from '@sanity/cli-core';
2
+ const USERS_API_VERSION = 'v2025-05-14';
3
+ export async function getUser(userId, signal) {
4
+ const client = await getGlobalCliClient({
5
+ apiVersion: USERS_API_VERSION,
6
+ requireUser: true
7
+ });
8
+ return client.request({
9
+ signal,
10
+ url: `/users/${userId}`
11
+ });
12
+ }
13
+ export async function getCurrentUser(signal) {
14
+ const client = await getGlobalCliClient({
15
+ apiVersion: USERS_API_VERSION,
16
+ requireUser: true
17
+ });
18
+ return client.request({
19
+ signal,
20
+ url: '/users/me'
21
+ });
22
+ }
23
+
24
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/services/users.ts"],"sourcesContent":["import {getGlobalCliClient} from '@sanity/cli-core'\n\nconst USERS_API_VERSION = 'v2025-05-14'\n\nexport async function getUser(\n userId: string,\n signal?: AbortSignal,\n): Promise<{displayName: string}> {\n const client = await getGlobalCliClient({apiVersion: USERS_API_VERSION, requireUser: true})\n\n return client.request({signal, url: `/users/${userId}`})\n}\n\nexport async function getCurrentUser(signal?: AbortSignal): Promise<{name: string}> {\n const client = await getGlobalCliClient({apiVersion: USERS_API_VERSION, requireUser: true})\n\n return client.request({signal, url: '/users/me'})\n}\n"],"names":["getGlobalCliClient","USERS_API_VERSION","getUser","userId","signal","client","apiVersion","requireUser","request","url","getCurrentUser"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,mBAAkB;AAEnD,MAAMC,oBAAoB;AAE1B,OAAO,eAAeC,QACpBC,MAAc,EACdC,MAAoB;IAEpB,MAAMC,SAAS,MAAML,mBAAmB;QAACM,YAAYL;QAAmBM,aAAa;IAAI;IAEzF,OAAOF,OAAOG,OAAO,CAAC;QAACJ;QAAQK,KAAK,CAAC,OAAO,EAAEN,QAAQ;IAAA;AACxD;AAEA,OAAO,eAAeO,eAAeN,MAAoB;IACvD,MAAMC,SAAS,MAAML,mBAAmB;QAACM,YAAYL;QAAmBM,aAAa;IAAI;IAEzF,OAAOF,OAAOG,OAAO,CAAC;QAACJ;QAAQK,KAAK;IAAW;AACjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/workbench-cli",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
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",
@@ -72,6 +72,7 @@
72
72
  "@sanity/types": "^6.22.0",
73
73
  "@vitejs/plugin-react": "^6.3.0",
74
74
  "form-data": "^4.0.6",
75
+ "open": "^11.0.4",
75
76
  "rxjs": "^7.8.2",
76
77
  "semver": "^7.8.6",
77
78
  "tar": "^7.5.23",