@sanity/workbench-cli 2.20.0 → 2.22.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.
- package/dist/_exports/build.d.ts +10 -2
- package/dist/_exports/build.js +2 -0
- package/dist/_exports/build.js.map +1 -1
- package/dist/_exports/defineApp-DUi9ZfpT.d.ts +377 -0
- package/dist/_exports/deploy.d.ts +25 -43
- package/dist/_exports/deploy.js +3 -1
- package/dist/_exports/deploy.js.map +1 -1
- package/dist/_exports/{summarizeInterfaces-BKIMEFzw.d.ts → deploySummary-BPgEW1qt.d.ts} +47 -4
- package/dist/_exports/dev.d.ts +2 -2
- package/dist/_exports/index.d.ts +22 -4
- package/dist/_exports/index.js +2 -1
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/preview.d.ts +1 -1
- package/dist/_exports/{registry-BI8kZVpy.d.ts → registry-DysyB1F6.d.ts} +11 -7
- package/dist/_exports/{resolveWorkbenchConfig-Eex64aAA.d.ts → resolveWorkbenchApp-C_rqQBQP.d.ts} +5 -20
- package/dist/_exports/resolveWorkbenchConfig-C_o8npN0.d.ts +10 -0
- package/dist/_exports/undeploy.d.ts +6 -6
- package/dist/_exports/undeploy.js +1 -0
- package/dist/_exports/undeploy.js.map +1 -1
- package/dist/actions/build/artifact.js +20 -1
- package/dist/actions/build/artifact.js.map +1 -1
- package/dist/actions/build/buildSummary.js +34 -0
- package/dist/actions/build/buildSummary.js.map +1 -0
- package/dist/actions/build/configs/artifact.js +10 -50
- package/dist/actions/build/configs/artifact.js.map +1 -1
- package/dist/actions/build/dashboardConfig/artifact.js +25 -0
- package/dist/actions/build/dashboardConfig/artifact.js.map +1 -0
- package/dist/actions/build/hotConfigListeners.js +34 -0
- package/dist/actions/build/hotConfigListeners.js.map +1 -0
- package/dist/actions/build/vite/optimize-deps.js +2 -1
- package/dist/actions/build/vite/optimize-deps.js.map +1 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js +3 -1
- package/dist/actions/build/vite/plugins/plugin-sanity-extension-artifacts.js.map +1 -1
- package/dist/actions/deploy/deployConfig.js +9 -7
- package/dist/actions/deploy/deployConfig.js.map +1 -1
- package/dist/actions/deploy/deployPayload.js.map +1 -1
- package/dist/actions/deploy/deploySummary.js +46 -10
- package/dist/actions/deploy/deploySummary.js.map +1 -1
- package/dist/actions/deploy/uploadDashboardConfig.js +34 -0
- package/dist/actions/deploy/uploadDashboardConfig.js.map +1 -0
- package/dist/actions/dev/deriveConfigs.js +17 -13
- package/dist/actions/dev/deriveConfigs.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/registry.js +34 -20
- package/dist/actions/dev/registry.js.map +1 -1
- package/dist/actions/dev/startDevServerRegistration.js +9 -5
- package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
- package/dist/actions/dev/startWorkbenchDev.js +4 -17
- package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
- package/dist/actions/preview/startWorkbenchPreview.js +67 -18
- 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 +57 -5
- package/dist/actions/undeploy/workbenchUndeployAdapter.js.map +1 -1
- package/dist/contract.js +14 -0
- package/dist/contract.js.map +1 -1
- package/dist/dashboardConfig.js +5 -0
- package/dist/dashboardConfig.js.map +1 -0
- package/dist/defineApp.js +25 -2
- package/dist/defineApp.js.map +1 -1
- package/dist/deriveInterfaces.js +2 -2
- package/dist/deriveInterfaces.js.map +1 -1
- package/dist/resolveWorkbenchApp.js +3 -2
- package/dist/resolveWorkbenchApp.js.map +1 -1
- package/dist/resolveWorkbenchConfig.js +11 -16
- package/dist/resolveWorkbenchConfig.js.map +1 -1
- package/dist/services/applications.js +10 -5
- package/dist/services/applications.js.map +1 -1
- package/dist/services/dashboard-configs.js +54 -0
- package/dist/services/dashboard-configs.js.map +1 -0
- package/dist/services/organizations.js +2 -1
- package/dist/services/organizations.js.map +1 -1
- package/package.json +8 -8
- package/dist/_exports/contract-BeAds4Yi.d.ts +0 -191
- package/dist/_exports/defineApp-DSXAAr3V.d.ts +0 -177
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolveWorkbenchConfig.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `unstable_defineMediaLibrary` config into its target `appType`, owning
|
|
1
|
+
{"version":3,"sources":["../src/resolveWorkbenchConfig.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `unstable_defineMediaLibrary` or `defineDashboard` config into its target\n// `appType`, owning `organizationId`, and payload, or `null` when the config is\n// not a config (a plain project or an app). The deploy/undeploy/build paths\n// consult this second resolver; app-only callers keep using `resolveWorkbenchApp`.\n\nimport {type CliConfig} from '@sanity/cli-core'\nimport {z} from 'zod/mini'\n\nimport {ConfigSchema} from './contract.js'\nimport {isWorkbenchConfig, type WorkbenchConfig} from './defineApp.js'\n\n/**\n * Resolve the workbench config for a CLI config, or `null` when it carries no\n * config brand (a plain project or an app).\n * @public\n */\nexport function resolveWorkbenchConfig(\n cliConfig: CliConfig | null | undefined,\n): WorkbenchConfig | null {\n const app = cliConfig?.app\n if (!isWorkbenchConfig(app)) return null\n\n const result = z\n .intersection(\n ConfigSchema,\n z.object({\n organizationId: z.string(\n \"Config `organizationId` is required — pass the owning organization's ID\",\n ),\n }),\n )\n .safeParse(app)\n if (!result.success) {\n throw new Error(`Invalid ${app.appType} config:\\n${z.prettifyError(result.error)}`)\n }\n\n return app\n}\n"],"names":["z","ConfigSchema","isWorkbenchConfig","resolveWorkbenchConfig","cliConfig","app","result","intersection","object","organizationId","string","safeParse","success","Error","appType","prettifyError","error"],"mappings":"AAAA,gEAAgE;AAChE,4EAA4E;AAC5E,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF;AAGnF,SAAQA,CAAC,QAAO,WAAU;AAE1B,SAAQC,YAAY,QAAO,gBAAe;AAC1C,SAAQC,iBAAiB,QAA6B,iBAAgB;AAEtE;;;;CAIC,GACD,OAAO,SAASC,uBACdC,SAAuC;IAEvC,MAAMC,MAAMD,WAAWC;IACvB,IAAI,CAACH,kBAAkBG,MAAM,OAAO;IAEpC,MAAMC,SAASN,EACZO,YAAY,CACXN,cACAD,EAAEQ,MAAM,CAAC;QACPC,gBAAgBT,EAAEU,MAAM,CACtB;IAEJ,IAEDC,SAAS,CAACN;IACb,IAAI,CAACC,OAAOM,OAAO,EAAE;QACnB,MAAM,IAAIC,MAAM,CAAC,QAAQ,EAAER,IAAIS,OAAO,CAAC,UAAU,EAAEd,EAAEe,aAAa,CAACT,OAAOU,KAAK,GAAG;IACpF;IAEA,OAAOX;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 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 /** 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","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;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,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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,IAAI1E;QACxBkD,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;IAEx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AAU,cAAcN;IACnC,0EAA0E;IAC1E,IAAIK,YAAYO,QAAQD,WAAWL,UAAU,cAAcD;IAC3D,sEAAsE;IACtE,IAAIN,QAAQa,QAAQD,WAAWL,UAAU,UAAUP;IACnDY,WAAWL,UAAU,cAAcJ;IACnC,qEAAqE;IACrE,IAAIC,SAAS;QACXG,SAASC,MAAM,CAAC,WAAWJ,SAAS;YAACT,aAAa;YAAoBmB,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASF,WAAWL,QAAkB,EAAE3B,IAAY,EAAEmC,KAAc;IAClER,SAASC,MAAM,CAAC5B,MAAMoC,KAAKC,SAAS,CAACF,QAAQ;QAACpB,aAAa;IAAkB;AAC/E;AAEA,eAAehC,QAAWC,GAAW,EAAE2C,QAAkB;IACvD,MAAM7C,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBqB,MAAMuB,SAASW,IAAI,CAAC,IAAI7E;QACxBqD,SAASa,SAASY,UAAU;QAC5B/B,QAAQ;QACRxB;IACF;AACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PassThrough } from 'node:stream';
|
|
2
|
+
import { getGlobalCliClient } from '@sanity/cli-core';
|
|
3
|
+
import FormData from 'form-data';
|
|
4
|
+
import { APP_WORKBENCH_API_VERSION } from './apiVersion.js';
|
|
5
|
+
async function getClient() {
|
|
6
|
+
return getGlobalCliClient({
|
|
7
|
+
apiVersion: APP_WORKBENCH_API_VERSION,
|
|
8
|
+
requireUser: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export async function getOrganizationDashboard(organizationId) {
|
|
12
|
+
const client = await getClient();
|
|
13
|
+
const { data } = await client.request({
|
|
14
|
+
query: {
|
|
15
|
+
organizationId
|
|
16
|
+
},
|
|
17
|
+
url: '/applications/dashboards'
|
|
18
|
+
});
|
|
19
|
+
return data[0];
|
|
20
|
+
}
|
|
21
|
+
export async function createDashboard(organizationId) {
|
|
22
|
+
const client = await getClient();
|
|
23
|
+
return client.request({
|
|
24
|
+
body: {
|
|
25
|
+
organizationId
|
|
26
|
+
},
|
|
27
|
+
method: 'POST',
|
|
28
|
+
url: '/applications/dashboards'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export async function createDashboardConfig(dashboardId, { tarball, version }) {
|
|
32
|
+
const formData = new FormData();
|
|
33
|
+
formData.append('version', version);
|
|
34
|
+
formData.append('tarball', tarball, {
|
|
35
|
+
contentType: 'application/gzip',
|
|
36
|
+
filename: 'dashboard-config.tar.gz'
|
|
37
|
+
});
|
|
38
|
+
const client = await getClient();
|
|
39
|
+
await client.request({
|
|
40
|
+
body: formData.pipe(new PassThrough()),
|
|
41
|
+
headers: formData.getHeaders(),
|
|
42
|
+
method: 'POST',
|
|
43
|
+
url: `/applications/dashboards/${dashboardId}/configs`
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export async function deleteDashboard(dashboardId) {
|
|
47
|
+
const client = await getClient();
|
|
48
|
+
await client.request({
|
|
49
|
+
method: 'DELETE',
|
|
50
|
+
url: `/applications/dashboards/${dashboardId}`
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=dashboard-configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/services/dashboard-configs.ts"],"sourcesContent":["import {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\n\nimport {APP_WORKBENCH_API_VERSION} from './apiVersion.js'\n\nexport interface Dashboard {\n id: string\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\nexport async function getOrganizationDashboard(\n organizationId: string,\n): Promise<Dashboard | undefined> {\n const client = await getClient()\n const {data}: {data: Dashboard[]} = await client.request({\n query: {organizationId},\n url: '/applications/dashboards',\n })\n return data[0]\n}\n\nexport async function createDashboard(organizationId: string): Promise<Dashboard> {\n const client = await getClient()\n return client.request({\n body: {organizationId},\n method: 'POST',\n url: '/applications/dashboards',\n })\n}\n\nexport async function createDashboardConfig(\n dashboardId: string,\n {tarball, version}: {tarball: Gzip; version: string},\n): Promise<void> {\n const formData = new FormData()\n formData.append('version', version)\n formData.append('tarball', tarball, {\n contentType: 'application/gzip',\n filename: 'dashboard-config.tar.gz',\n })\n\n const client = await getClient()\n await client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url: `/applications/dashboards/${dashboardId}/configs`,\n })\n}\n\nexport async function deleteDashboard(dashboardId: string): Promise<void> {\n const client = await getClient()\n await client.request({method: 'DELETE', url: `/applications/dashboards/${dashboardId}`})\n}\n"],"names":["PassThrough","getGlobalCliClient","FormData","APP_WORKBENCH_API_VERSION","getClient","apiVersion","requireUser","getOrganizationDashboard","organizationId","client","data","request","query","url","createDashboard","body","method","createDashboardConfig","dashboardId","tarball","version","formData","append","contentType","filename","pipe","headers","getHeaders","deleteDashboard"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAAQC,kBAAkB,QAAO,mBAAkB;AACnD,OAAOC,cAAc,YAAW;AAEhC,SAAQC,yBAAyB,QAAO,kBAAiB;AAMzD,eAAeC;IACb,OAAOH,mBAAmB;QAACI,YAAYF;QAA2BG,aAAa;IAAI;AACrF;AAEA,OAAO,eAAeC,yBACpBC,cAAsB;IAEtB,MAAMC,SAAS,MAAML;IACrB,MAAM,EAACM,IAAI,EAAC,GAAwB,MAAMD,OAAOE,OAAO,CAAC;QACvDC,OAAO;YAACJ;QAAc;QACtBK,KAAK;IACP;IACA,OAAOH,IAAI,CAAC,EAAE;AAChB;AAEA,OAAO,eAAeI,gBAAgBN,cAAsB;IAC1D,MAAMC,SAAS,MAAML;IACrB,OAAOK,OAAOE,OAAO,CAAC;QACpBI,MAAM;YAACP;QAAc;QACrBQ,QAAQ;QACRH,KAAK;IACP;AACF;AAEA,OAAO,eAAeI,sBACpBC,WAAmB,EACnB,EAACC,OAAO,EAAEC,OAAO,EAAmC;IAEpD,MAAMC,WAAW,IAAInB;IACrBmB,SAASC,MAAM,CAAC,WAAWF;IAC3BC,SAASC,MAAM,CAAC,WAAWH,SAAS;QAClCI,aAAa;QACbC,UAAU;IACZ;IAEA,MAAMf,SAAS,MAAML;IACrB,MAAMK,OAAOE,OAAO,CAAC;QACnBI,MAAMM,SAASI,IAAI,CAAC,IAAIzB;QACxB0B,SAASL,SAASM,UAAU;QAC5BX,QAAQ;QACRH,KAAK,CAAC,yBAAyB,EAAEK,YAAY,QAAQ,CAAC;IACxD;AACF;AAEA,OAAO,eAAeU,gBAAgBV,WAAmB;IACvD,MAAMT,SAAS,MAAML;IACrB,MAAMK,OAAOE,OAAO,CAAC;QAACK,QAAQ;QAAUH,KAAK,CAAC,yBAAyB,EAAEK,aAAa;IAAA;AACxF"}
|
|
@@ -1,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.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",
|
|
@@ -65,25 +65,25 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@module-federation/runtime": "2.9.
|
|
69
|
-
"@module-federation/vite": "1.
|
|
70
|
-
"@sanity/cli-core": "^3.
|
|
71
|
-
"@sanity/sdk": "^3.
|
|
72
|
-
"@sanity/types": "^6.
|
|
68
|
+
"@module-federation/runtime": "2.9.4",
|
|
69
|
+
"@module-federation/vite": "1.25.1",
|
|
70
|
+
"@sanity/cli-core": "^3.18.0",
|
|
71
|
+
"@sanity/sdk": "^3.17.0",
|
|
72
|
+
"@sanity/types": "^6.25.0",
|
|
73
73
|
"@vitejs/plugin-react": "^6.3.0",
|
|
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.
|
|
79
|
+
"vite": "^8.4.0",
|
|
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",
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/mini";
|
|
2
|
-
/** @internal */
|
|
3
|
-
declare const WEB_WORKER_CONTRACT_VERSION = 1;
|
|
4
|
-
/**
|
|
5
|
-
* A view component. The return is opaque so the runtime helpers carry no React
|
|
6
|
-
* dependency — the generated artifact renders it with the app's own React.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
type ViewComponent<TProps> = (props: TProps) => unknown;
|
|
10
|
-
/** @public */
|
|
11
|
-
interface ViewComponentBaseProps<TView> {
|
|
12
|
-
view: TView;
|
|
13
|
-
}
|
|
14
|
-
/** Component slots per view surface; windows load outside the component artifact path. @internal */
|
|
15
|
-
declare const VIEW_COMPONENTS: {
|
|
16
|
-
readonly asset_source: readonly ["asset_source"];
|
|
17
|
-
readonly panel: readonly ["title", "panel"];
|
|
18
|
-
readonly tile: readonly ["tile"];
|
|
19
|
-
readonly window: readonly [];
|
|
20
|
-
};
|
|
21
|
-
/** @public */
|
|
22
|
-
type ViewSurface = keyof typeof VIEW_COMPONENTS;
|
|
23
|
-
/**
|
|
24
|
-
* A tile's footprint family — the shape it occupies on the dashboard. Modelled
|
|
25
|
-
* on iOS WidgetKit families, not a linear scale: `banner` is full-width and
|
|
26
|
-
* shallow, which a `small`→`large` magnitude can't express. The host maps a
|
|
27
|
-
* family to a layout slot; the component reads it to render per footprint.
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
declare const TileSizeSchema: z.ZodMiniEnum<{
|
|
31
|
-
small: "small";
|
|
32
|
-
large: "large";
|
|
33
|
-
banner: "banner";
|
|
34
|
-
}>;
|
|
35
|
-
/** @public */
|
|
36
|
-
type TileSize = z.infer<typeof TileSizeSchema>;
|
|
37
|
-
/** @public */
|
|
38
|
-
type WebWorkerType = 'worker';
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use `WebWorkerType`.
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
type ServiceType = WebWorkerType;
|
|
44
|
-
declare const DockGroupSchema: z.ZodMiniEnum<{
|
|
45
|
-
system: "system";
|
|
46
|
-
applications: "applications";
|
|
47
|
-
}>;
|
|
48
|
-
/** @public */
|
|
49
|
-
type DockGroup = z.output<typeof DockGroupSchema>;
|
|
50
|
-
declare const PanelViewSchema: z.ZodMiniObject<{
|
|
51
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
52
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
53
|
-
}, z.core.$strip>>;
|
|
54
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
55
|
-
title: z.ZodMiniString<string>;
|
|
56
|
-
name: z.ZodMiniString<string>;
|
|
57
|
-
src: z.ZodMiniString<string>;
|
|
58
|
-
surface: z.ZodMiniLiteral<"panel">;
|
|
59
|
-
}, z.core.$strip>;
|
|
60
|
-
/** @public */
|
|
61
|
-
type PanelViewDeclaration = z.output<typeof PanelViewSchema>;
|
|
62
|
-
/** @public */
|
|
63
|
-
type DefinePanelViewInput = Omit<PanelViewDeclaration, 'surface'>;
|
|
64
|
-
/** @public */
|
|
65
|
-
declare function definePanelView(view: DefinePanelViewInput): PanelViewDeclaration;
|
|
66
|
-
declare const WindowViewSchema: z.ZodMiniObject<{
|
|
67
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
68
|
-
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
69
|
-
system: "system";
|
|
70
|
-
applications: "applications";
|
|
71
|
-
}>>;
|
|
72
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
73
|
-
}, z.core.$strip>>;
|
|
74
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
75
|
-
title: z.ZodMiniString<string>;
|
|
76
|
-
name: z.ZodMiniString<string>;
|
|
77
|
-
src: z.ZodMiniString<string>;
|
|
78
|
-
surface: z.ZodMiniLiteral<"window">;
|
|
79
|
-
}, z.core.$strip>;
|
|
80
|
-
/** @public */
|
|
81
|
-
type WindowViewDeclaration = z.output<typeof WindowViewSchema>;
|
|
82
|
-
/** @public */
|
|
83
|
-
type DefineWindowViewInput = Omit<WindowViewDeclaration, 'surface'>;
|
|
84
|
-
/** @public */
|
|
85
|
-
declare function defineWindowView(view: DefineWindowViewInput): WindowViewDeclaration;
|
|
86
|
-
declare const AssetSourceViewSchema: z.ZodMiniObject<{
|
|
87
|
-
title: z.ZodMiniString<string>;
|
|
88
|
-
name: z.ZodMiniString<string>;
|
|
89
|
-
src: z.ZodMiniString<string>;
|
|
90
|
-
surface: z.ZodMiniLiteral<"asset_source">;
|
|
91
|
-
}, z.core.$strip>;
|
|
92
|
-
/** @public */
|
|
93
|
-
type AssetSourceViewDeclaration = z.output<typeof AssetSourceViewSchema>;
|
|
94
|
-
/** @public */
|
|
95
|
-
type DefineAssetSourceViewInput = Omit<AssetSourceViewDeclaration, 'surface'>;
|
|
96
|
-
/** @public */
|
|
97
|
-
declare function defineAssetSourceView(view: DefineAssetSourceViewInput): AssetSourceViewDeclaration;
|
|
98
|
-
declare const TileViewSchema: z.ZodMiniObject<{
|
|
99
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
100
|
-
size: z.ZodMiniEnum<{
|
|
101
|
-
small: "small";
|
|
102
|
-
large: "large";
|
|
103
|
-
banner: "banner";
|
|
104
|
-
}>;
|
|
105
|
-
title: z.ZodMiniString<string>;
|
|
106
|
-
name: z.ZodMiniString<string>;
|
|
107
|
-
src: z.ZodMiniString<string>;
|
|
108
|
-
surface: z.ZodMiniLiteral<"tile">;
|
|
109
|
-
}, z.core.$strip>;
|
|
110
|
-
/** @public */
|
|
111
|
-
type TileViewDeclaration = z.output<typeof TileViewSchema>;
|
|
112
|
-
/** @public */
|
|
113
|
-
type DefineTileViewInput = Omit<TileViewDeclaration, 'surface'>;
|
|
114
|
-
/** @public */
|
|
115
|
-
declare function defineTileView(view: DefineTileViewInput): TileViewDeclaration;
|
|
116
|
-
/** @internal */
|
|
117
|
-
declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
118
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
119
|
-
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
120
|
-
system: "system";
|
|
121
|
-
applications: "applications";
|
|
122
|
-
}>>;
|
|
123
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
124
|
-
}, z.core.$strip>>;
|
|
125
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
126
|
-
title: z.ZodMiniString<string>;
|
|
127
|
-
name: z.ZodMiniString<string>;
|
|
128
|
-
src: z.ZodMiniString<string>;
|
|
129
|
-
surface: z.ZodMiniLiteral<"window">;
|
|
130
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
131
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
132
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
133
|
-
}, z.core.$strip>>;
|
|
134
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
135
|
-
title: z.ZodMiniString<string>;
|
|
136
|
-
name: z.ZodMiniString<string>;
|
|
137
|
-
src: z.ZodMiniString<string>;
|
|
138
|
-
surface: z.ZodMiniLiteral<"panel">;
|
|
139
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
140
|
-
title: z.ZodMiniString<string>;
|
|
141
|
-
name: z.ZodMiniString<string>;
|
|
142
|
-
src: z.ZodMiniString<string>;
|
|
143
|
-
surface: z.ZodMiniLiteral<"asset_source">;
|
|
144
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
145
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
146
|
-
size: z.ZodMiniEnum<{
|
|
147
|
-
small: "small";
|
|
148
|
-
large: "large";
|
|
149
|
-
banner: "banner";
|
|
150
|
-
}>;
|
|
151
|
-
title: z.ZodMiniString<string>;
|
|
152
|
-
name: z.ZodMiniString<string>;
|
|
153
|
-
src: z.ZodMiniString<string>;
|
|
154
|
-
surface: z.ZodMiniLiteral<"tile">;
|
|
155
|
-
}, z.core.$strip>], "surface">;
|
|
156
|
-
/** @public */
|
|
157
|
-
type ViewDeclaration = z.output<typeof InterfaceDeclarationSchema>;
|
|
158
|
-
declare const WebWorkerSchema: z.ZodMiniObject<{
|
|
159
|
-
title: z.ZodMiniString<string>;
|
|
160
|
-
name: z.ZodMiniString<string>;
|
|
161
|
-
src: z.ZodMiniString<string>;
|
|
162
|
-
type: z.ZodMiniLiteral<"worker">;
|
|
163
|
-
}, z.core.$strip>;
|
|
164
|
-
/** @public */
|
|
165
|
-
type WebWorkerDeclaration = z.output<typeof WebWorkerSchema>;
|
|
166
|
-
/** @public */
|
|
167
|
-
type DefineWebWorkerInput = Omit<WebWorkerDeclaration, 'type'>;
|
|
168
|
-
/** @public */
|
|
169
|
-
declare function defineWebWorker(webWorker: DefineWebWorkerInput): WebWorkerDeclaration;
|
|
170
|
-
/**
|
|
171
|
-
* A workbench config's built value, keyed by `appType`; deploys as a versioned
|
|
172
|
-
* snapshot, not an interface.
|
|
173
|
-
* @internal
|
|
174
|
-
*/
|
|
175
|
-
declare const ConfigSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
176
|
-
appType: z.ZodMiniLiteral<"media-library">;
|
|
177
|
-
fields: z.ZodMiniArray<z.ZodMiniObject<{
|
|
178
|
-
public: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
179
|
-
title: z.ZodMiniString<string>;
|
|
180
|
-
name: z.ZodMiniString<string>;
|
|
181
|
-
src: z.ZodMiniString<string>;
|
|
182
|
-
}, z.core.$strip>>;
|
|
183
|
-
}, z.core.$strip>], "appType">;
|
|
184
|
-
/**
|
|
185
|
-
* The `{appType, fields}` config value the build expands into a federation
|
|
186
|
-
* remote and the deploy summarizes.
|
|
187
|
-
* @internal
|
|
188
|
-
*/
|
|
189
|
-
type WorkbenchConfigValue = z.output<typeof ConfigSchema>;
|
|
190
|
-
export { defineTileView as C, definePanelView as S, defineWindowView as T, WebWorkerDeclaration as _, DefineWebWorkerInput as a, WorkbenchConfigValue as b, PanelViewDeclaration as c, TileViewDeclaration as d, ViewComponent as f, WEB_WORKER_CONTRACT_VERSION as g, ViewSurface as h, DefineTileViewInput as i, ServiceType as l, ViewDeclaration as m, DefineAssetSourceViewInput as n, DefineWindowViewInput as o, ViewComponentBaseProps as p, DefinePanelViewInput as r, DockGroup as s, AssetSourceViewDeclaration as t, TileSize as u, WebWorkerType as v, defineWebWorker as w, defineAssetSourceView as x, WindowViewDeclaration as y };
|
|
191
|
-
//# sourceMappingURL=contract-BeAds4Yi.d.ts.map
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/mini";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime-validation schema for `defineApplication`.
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
declare const DefineAppInputSchema: z.ZodMiniObject<{
|
|
7
|
-
applicationType: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
8
|
-
coreApp: "coreApp";
|
|
9
|
-
studio: "studio";
|
|
10
|
-
canvas: "canvas";
|
|
11
|
-
dashboard: "dashboard";
|
|
12
|
-
}>>;
|
|
13
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
14
|
-
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
15
|
-
system: "system";
|
|
16
|
-
applications: "applications";
|
|
17
|
-
}>>;
|
|
18
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
19
|
-
}, z.core.$strip>>;
|
|
20
|
-
entry: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
22
|
-
isSingleton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
23
|
-
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
24
|
-
organizationId: z.ZodMiniString<string>;
|
|
25
|
-
slug: z.ZodMiniString<string>;
|
|
26
|
-
title: z.ZodMiniString<string>;
|
|
27
|
-
views: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
28
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
29
|
-
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
30
|
-
system: "system";
|
|
31
|
-
applications: "applications";
|
|
32
|
-
}>>;
|
|
33
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
34
|
-
}, z.core.$strip>>;
|
|
35
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
36
|
-
title: z.ZodMiniString<string>;
|
|
37
|
-
name: z.ZodMiniString<string>;
|
|
38
|
-
src: z.ZodMiniString<string>;
|
|
39
|
-
surface: z.ZodMiniLiteral<"window">;
|
|
40
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
41
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
42
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
43
|
-
}, z.core.$strip>>;
|
|
44
|
-
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
-
title: z.ZodMiniString<string>;
|
|
46
|
-
name: z.ZodMiniString<string>;
|
|
47
|
-
src: z.ZodMiniString<string>;
|
|
48
|
-
surface: z.ZodMiniLiteral<"panel">;
|
|
49
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
50
|
-
title: z.ZodMiniString<string>;
|
|
51
|
-
name: z.ZodMiniString<string>;
|
|
52
|
-
src: z.ZodMiniString<string>;
|
|
53
|
-
surface: z.ZodMiniLiteral<"asset_source">;
|
|
54
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
55
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
56
|
-
size: z.ZodMiniEnum<{
|
|
57
|
-
small: "small";
|
|
58
|
-
large: "large";
|
|
59
|
-
banner: "banner";
|
|
60
|
-
}>;
|
|
61
|
-
title: z.ZodMiniString<string>;
|
|
62
|
-
name: z.ZodMiniString<string>;
|
|
63
|
-
src: z.ZodMiniString<string>;
|
|
64
|
-
surface: z.ZodMiniLiteral<"tile">;
|
|
65
|
-
}, z.core.$strip>], "surface">>>;
|
|
66
|
-
visibility: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
67
|
-
default: "default";
|
|
68
|
-
unlisted: "unlisted";
|
|
69
|
-
disabled: "disabled";
|
|
70
|
-
}>>;
|
|
71
|
-
webWorkers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
72
|
-
title: z.ZodMiniString<string>;
|
|
73
|
-
name: z.ZodMiniString<string>;
|
|
74
|
-
src: z.ZodMiniString<string>;
|
|
75
|
-
type: z.ZodMiniLiteral<"worker">;
|
|
76
|
-
}, z.core.$strip>], "type">>>;
|
|
77
|
-
}, z.core.$strip>;
|
|
78
|
-
/**
|
|
79
|
-
* User-facing input for `defineApplication`. Excludes the internal
|
|
80
|
-
* `applicationType` and `isSingleton`.
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
type DefineAppInput = Omit<z.output<typeof DefineAppInputSchema>, 'applicationType' | 'isSingleton'>;
|
|
84
|
-
/**
|
|
85
|
-
* Nominal brand the CLI discriminates on to enable the workbench build/deploy
|
|
86
|
-
* codepath. Registered via `Symbol.for` so the marker survives module-realm
|
|
87
|
-
* boundaries — `@sanity/cli-core` re-derives the same global symbol with
|
|
88
|
-
* `Symbol.for` rather than importing it, so it stays internal to this module.
|
|
89
|
-
*/
|
|
90
|
-
declare const WORKBENCH_APP: unique symbol;
|
|
91
|
-
/**
|
|
92
|
-
* The branded result of `defineApplication`. Carries the same fields as the
|
|
93
|
-
* input plus the internal brand — users only ever see `DefineAppInput`.
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
type DefineAppResult = { [K in keyof DefineAppInput]: Exclude<DefineAppInput[K], undefined>; } & {
|
|
97
|
-
readonly [WORKBENCH_APP]: true;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* A branded app as the CLI reads it — the full schema shape, including the
|
|
101
|
-
* internal fields `DefineAppInput` omits. Schema-derived so the narrowing
|
|
102
|
-
* can't drift from what the schema validates.
|
|
103
|
-
* @public
|
|
104
|
-
*/
|
|
105
|
-
type WorkbenchApp = DefineAppResult & z.output<typeof DefineAppInputSchema>;
|
|
106
|
-
/**
|
|
107
|
-
* Whether `app` is a branded `defineApplication(...)` result — the sole
|
|
108
|
-
* workbench opt-in.
|
|
109
|
-
* @public
|
|
110
|
-
*/
|
|
111
|
-
declare function isWorkbenchApp(app: unknown): app is WorkbenchApp;
|
|
112
|
-
/**
|
|
113
|
-
* Declare a Sanity Dashboard application. Identity at runtime — returns the same
|
|
114
|
-
* object reference, tagged with the Dashboard brand. Field validation (the
|
|
115
|
-
* `slug` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;
|
|
116
|
-
* this helper stays a thin, pure identity wrapper.
|
|
117
|
-
* @public
|
|
118
|
-
*/
|
|
119
|
-
declare function defineApplication(input: DefineAppInput): DefineAppResult;
|
|
120
|
-
/**
|
|
121
|
-
* One custom field a media library exposes. `src` default-exports a `defineField(...)` schema type.
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
interface MediaLibraryField {
|
|
125
|
-
/** Unique within the media library. */
|
|
126
|
-
name: string;
|
|
127
|
-
src: string;
|
|
128
|
-
title: string;
|
|
129
|
-
/** Readable outside the owning organization. */
|
|
130
|
-
public?: boolean;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Sanity-owned singleton, so authors don't name or title the app — only `organizationId` is required.
|
|
134
|
-
* @public
|
|
135
|
-
*/
|
|
136
|
-
interface DefineMediaLibraryInput {
|
|
137
|
-
/** Organization that owns the media library — the CLI runs and deploys against it. */
|
|
138
|
-
organizationId: string;
|
|
139
|
-
fields?: MediaLibraryField[];
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Nominal brand the CLI discriminates a config on. A config is *not* an app: it
|
|
143
|
-
* carries no `slug`/`title`/application identity, only a target `appType`, its
|
|
144
|
-
* owning `organizationId`, and its `fields`. Registered via `Symbol.for` so the
|
|
145
|
-
* marker survives module-realm boundaries — `@sanity/cli-core` re-derives the
|
|
146
|
-
* same global symbol rather than importing it.
|
|
147
|
-
*/
|
|
148
|
-
declare const WORKBENCH_CONFIG: unique symbol;
|
|
149
|
-
/**
|
|
150
|
-
* A branded workbench config as the CLI reads it: bound to its target app by
|
|
151
|
-
* `appType`, not carrying its own app identity. The deploy/undeploy/build paths
|
|
152
|
-
* discriminate it via {@link isWorkbenchConfig}.
|
|
153
|
-
* @public
|
|
154
|
-
*/
|
|
155
|
-
interface WorkbenchConfig {
|
|
156
|
-
appType: 'media-library';
|
|
157
|
-
fields: MediaLibraryField[];
|
|
158
|
-
organizationId: string;
|
|
159
|
-
readonly [WORKBENCH_CONFIG]: true;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Whether `app` is a branded `unstable_defineMediaLibrary(...)` config — a
|
|
163
|
-
* config-carrier rather than an app. Configs live in `cliConfig.app` alongside
|
|
164
|
-
* apps but resolve through `resolveWorkbenchConfig`, not `resolveWorkbenchApp`.
|
|
165
|
-
* @public
|
|
166
|
-
*/
|
|
167
|
-
declare function isWorkbenchConfig(app: unknown): app is WorkbenchConfig;
|
|
168
|
-
/**
|
|
169
|
-
* Declare the Sanity Media Library config. The Media Library is a Sanity-owned
|
|
170
|
-
* singleton, so this is not an app — it carries no slug or title, only the
|
|
171
|
-
* target `appType`, its owning organization, and the `fields` it contributes to
|
|
172
|
-
* the installation's config.
|
|
173
|
-
* @public
|
|
174
|
-
*/
|
|
175
|
-
declare function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): WorkbenchConfig;
|
|
176
|
-
export { WorkbenchApp as a, isWorkbenchApp as c, MediaLibraryField as i, isWorkbenchConfig as l, DefineAppResult as n, WorkbenchConfig as o, DefineMediaLibraryInput as r, defineApplication as s, DefineAppInput as t, unstable_defineMediaLibrary as u };
|
|
177
|
-
//# sourceMappingURL=defineApp-DSXAAr3V.d.ts.map
|