@sanity/workbench-cli 2.19.1 → 2.21.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 +3 -2
- package/dist/_exports/build.js.map +1 -1
- package/dist/_exports/defineApp-COehpvlC.d.ts +376 -0
- package/dist/_exports/deploy.d.ts +22 -44
- package/dist/_exports/deploy.js +2 -0
- package/dist/_exports/deploy.js.map +1 -1
- package/dist/_exports/{summarizeInterfaces-AM-QbtIA.d.ts → deploySummary-DU7_Vcyq.d.ts} +30 -4
- package/dist/_exports/dev.d.ts +1 -1
- 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-DZWnj09G.d.ts → registry-Da2PAcT1.d.ts} +17 -11
- package/dist/_exports/{resolveWorkbenchConfig-_iD6fVUH.d.ts → resolveWorkbenchApp-Bn0tsSDM.d.ts} +5 -20
- package/dist/_exports/resolveWorkbenchConfig-DkrkqN9H.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/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 +24 -5
- package/dist/actions/deploy/deploySummary.js.map +1 -1
- package/dist/actions/deploy/deployWorkbenchApp.js +31 -13
- package/dist/actions/deploy/deployWorkbenchApp.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/registry.js +34 -20
- package/dist/actions/dev/registry.js.map +1 -1
- package/dist/actions/dev/startDevServerRegistration.js +20 -11
- package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
- package/dist/actions/dev/startWorkbenchDev.js +2 -2
- package/dist/actions/dev/startWorkbenchDev.js.map +1 -1
- package/dist/actions/preview/serveBuiltApplication.js +9 -7
- package/dist/actions/preview/serveBuiltApplication.js.map +1 -1
- package/dist/actions/preview/startWorkbenchPreview.js +52 -19
- package/dist/actions/preview/startWorkbenchPreview.js.map +1 -1
- package/dist/actions/undeploy/workbenchUndeployAdapter.js +50 -3
- package/dist/actions/undeploy/workbenchUndeployAdapter.js.map +1 -1
- package/dist/contract.js +20 -3
- 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 +24 -13
- package/dist/deriveInterfaces.js.map +1 -1
- package/dist/readAppIcon.js +3 -3
- package/dist/readAppIcon.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 +12 -1
- 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/package.json +8 -8
- package/dist/_exports/contract-WrU3aOYd.d.ts +0 -187
- package/dist/_exports/defineApp-9ppP3UQR.d.ts +0 -175
package/dist/readAppIcon.js
CHANGED
|
@@ -2,13 +2,13 @@ import { relative, resolve, sep } from 'node:path';
|
|
|
2
2
|
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
3
3
|
import { readImageFile } from '@sanity/cli-core/images';
|
|
4
4
|
/**
|
|
5
|
-
* Read the image `
|
|
5
|
+
* Read the image an `icon` path points at. The path is relative to the project
|
|
6
6
|
* root and must stay inside it.
|
|
7
7
|
* @internal
|
|
8
8
|
*/ export async function readAppIcon(workDir, iconPath) {
|
|
9
9
|
const file = resolve(workDir, iconPath);
|
|
10
10
|
if (relative(workDir, file).startsWith('..')) {
|
|
11
|
-
throw new Error(`
|
|
11
|
+
throw new Error(`Icon "${iconPath}" is outside the project directory. Move the image into the project and update the icon path in sanity.cli.ts.`);
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
return {
|
|
@@ -16,7 +16,7 @@ import { readImageFile } from '@sanity/cli-core/images';
|
|
|
16
16
|
file
|
|
17
17
|
};
|
|
18
18
|
} catch (err) {
|
|
19
|
-
throw new Error(`Can't use
|
|
19
|
+
throw new Error(`Can't use icon "${iconPath}": ${getErrorMessage(err)}`, {
|
|
20
20
|
cause: err
|
|
21
21
|
});
|
|
22
22
|
}
|
package/dist/readAppIcon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/readAppIcon.ts"],"sourcesContent":["import {relative, resolve, sep} from 'node:path'\n\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type ImageFile, readImageFile} from '@sanity/cli-core/images'\n\n/**\n * An app's `icon` image, read from its project.\n * @internal\n */\nexport interface AppIcon extends ImageFile {\n /** Absolute path to the file. */\n file: string\n}\n\n/**\n * Read the image `
|
|
1
|
+
{"version":3,"sources":["../src/readAppIcon.ts"],"sourcesContent":["import {relative, resolve, sep} from 'node:path'\n\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type ImageFile, readImageFile} from '@sanity/cli-core/images'\n\n/**\n * An app's or view's `icon` image, read from its project.\n * @internal\n */\nexport interface AppIcon extends ImageFile {\n /** Absolute path to the file. */\n file: string\n}\n\n/**\n * Read the image an `icon` path points at. The path is relative to the project\n * root and must stay inside it.\n * @internal\n */\nexport async function readAppIcon(workDir: string, iconPath: string): Promise<AppIcon> {\n const file = resolve(workDir, iconPath)\n if (relative(workDir, file).startsWith('..')) {\n throw new Error(\n `Icon \"${iconPath}\" is outside the project directory. Move the image into the project and update the icon path in sanity.cli.ts.`,\n )\n }\n\n try {\n return {...(await readImageFile(file)), file}\n } catch (err) {\n throw new Error(`Can't use icon \"${iconPath}\": ${getErrorMessage(err)}`, {cause: err})\n }\n}\n\n/**\n * The URL path a server rooted at `dir` serves `file` at, without a leading slash.\n * @internal\n */\nexport function toUrlPath(dir: string, file: string): string {\n return relative(dir, file)\n .split(sep)\n .map((segment) => encodeURIComponent(segment))\n .join('/')\n}\n"],"names":["relative","resolve","sep","getErrorMessage","readImageFile","readAppIcon","workDir","iconPath","file","startsWith","Error","err","cause","toUrlPath","dir","split","map","segment","encodeURIComponent","join"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,GAAG,QAAO,YAAW;AAEhD,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAwBC,aAAa,QAAO,0BAAyB;AAWrE;;;;CAIC,GACD,OAAO,eAAeC,YAAYC,OAAe,EAAEC,QAAgB;IACjE,MAAMC,OAAOP,QAAQK,SAASC;IAC9B,IAAIP,SAASM,SAASE,MAAMC,UAAU,CAAC,OAAO;QAC5C,MAAM,IAAIC,MACR,CAAC,MAAM,EAAEH,SAAS,8GAA8G,CAAC;IAErI;IAEA,IAAI;QACF,OAAO;YAAC,GAAI,MAAMH,cAAcI,KAAK;YAAGA;QAAI;IAC9C,EAAE,OAAOG,KAAK;QACZ,MAAM,IAAID,MAAM,CAAC,gBAAgB,EAAEH,SAAS,GAAG,EAAEJ,gBAAgBQ,MAAM,EAAE;YAACC,OAAOD;QAAG;IACtF;AACF;AAEA;;;CAGC,GACD,OAAO,SAASE,UAAUC,GAAW,EAAEN,IAAY;IACjD,OAAOR,SAASc,KAAKN,MAClBO,KAAK,CAACb,KACNc,GAAG,CAAC,CAACC,UAAYC,mBAAmBD,UACpCE,IAAI,CAAC;AACV"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// each build their command-specific view on top of this one brand-check +
|
|
6
6
|
// extraction, so the discrimination lives in exactly one place.
|
|
7
7
|
import { defineWindowView } from './contract.js';
|
|
8
|
-
import { isWorkbenchApp } from './defineApp.js';
|
|
8
|
+
import { isWorkbenchApp, resolveAppTitle } from './defineApp.js';
|
|
9
9
|
import { formatWorkbenchAppErrors, validateWorkbenchApp } from './validateWorkbenchApp.js';
|
|
10
10
|
/**
|
|
11
11
|
* The module behind the app's `./App` expose. `entry` is shorthand for a window view.
|
|
@@ -16,7 +16,7 @@ import { formatWorkbenchAppErrors, validateWorkbenchApp } from './validateWorkbe
|
|
|
16
16
|
defineWindowView({
|
|
17
17
|
name: app.name ?? app.slug,
|
|
18
18
|
src: app.entry,
|
|
19
|
-
title: app
|
|
19
|
+
title: resolveAppTitle(app)
|
|
20
20
|
}),
|
|
21
21
|
...app.views ?? []
|
|
22
22
|
];
|
|
@@ -44,6 +44,7 @@ import { formatWorkbenchAppErrors, validateWorkbenchApp } from './validateWorkbe
|
|
|
44
44
|
name: app.name ?? app.slug,
|
|
45
45
|
organizationId: app.organizationId,
|
|
46
46
|
slug: app.slug,
|
|
47
|
+
title: resolveAppTitle(app),
|
|
47
48
|
views: app.views ?? [],
|
|
48
49
|
visibility: app.visibility,
|
|
49
50
|
webWorkers: app.webWorkers ?? []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolveWorkbenchApp.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `defineApplication` app into its declared interfaces, or `null` for a plain\n// project — and for a config (a branded `unstable_defineMediaLibrary`), which\n// is not an app. The build and deploy accessors (actions/build, actions/deploy)\n// each build their command-specific view on top of this one brand-check +\n// extraction, so the discrimination lives in exactly one place.\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\n\nimport {defineWindowView, type WorkbenchConfigValue} from './contract.js'\nimport {type DefineAppInput, isWorkbenchApp} from './defineApp.js'\nimport {formatWorkbenchAppErrors, validateWorkbenchApp} from './validateWorkbenchApp.js'\n\n/**\n * Bundled so adding a declaration family touches this type and the artifact\n * expanders, not every hop of build/dev plumbing in between. `config` is sourced\n * from `resolveWorkbenchConfig` (a config is not an app), not from this resolver.\n * @internal\n */\nexport interface WorkbenchExposes {\n config?: WorkbenchConfigValue\n views?: DefineAppInput['views']\n webWorkers?: DefineAppInput['webWorkers']\n}\n\n/** @public */\nexport interface ResolvedWorkbenchApp {\n /**\n * Stable identity, distinct from the `slug` address. Defaults to `slug`, and is\n * what every identity key (build id, interface ids) is built from.\n */\n readonly name: string\n /** Organization that owns the app — part of its build-id identity. */\n readonly organizationId: string\n readonly slug: string\n\n /** Views the app declares. */\n readonly views: NonNullable<DefineAppInput['views']>\n\n /** Background web workers the app declares. */\n readonly webWorkers: NonNullable<DefineAppInput['webWorkers']>\n\n /** Resolved app kind — `studio` or one of the SDK app types. */\n readonly applicationType?: string\n /** SDK app-view entrypoint, when declared. */\n readonly entry?: string\n /** Path to the app's icon SVG, resolved and shipped to Brett on deploy. */\n readonly icon?: string\n /** Explicit singleton flag for Sanity-owned apps. */\n readonly isSingleton?: boolean\n /** Dashboard visibility declared by the app; `undefined` when unset. */\n readonly visibility?: AppVisibility\n}\n\n/**\n * The module behind the app's `./App` expose. `entry` is shorthand for a window view.\n * @internal\n */\nexport function resolveAppEntry(app: CliConfig['app']): string | undefined {\n if (!isWorkbenchApp(app)) return app?.entry\n\n const views =\n app.entry === undefined\n ? (app.views ?? [])\n : [\n defineWindowView({name: app.name ?? app.slug
|
|
1
|
+
{"version":3,"sources":["../src/resolveWorkbenchApp.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `defineApplication` app into its declared interfaces, or `null` for a plain\n// project — and for a config (a branded `unstable_defineMediaLibrary`), which\n// is not an app. The build and deploy accessors (actions/build, actions/deploy)\n// each build their command-specific view on top of this one brand-check +\n// extraction, so the discrimination lives in exactly one place.\n\nimport {type AppVisibility, type CliConfig} from '@sanity/cli-core'\n\nimport {defineWindowView, type WorkbenchConfigValue} from './contract.js'\nimport {type DefineAppInput, isWorkbenchApp, resolveAppTitle} from './defineApp.js'\nimport {formatWorkbenchAppErrors, validateWorkbenchApp} from './validateWorkbenchApp.js'\n\n/**\n * Bundled so adding a declaration family touches this type and the artifact\n * expanders, not every hop of build/dev plumbing in between. `config` is sourced\n * from `resolveWorkbenchConfig` (a config is not an app), not from this resolver.\n * @internal\n */\nexport interface WorkbenchExposes {\n config?: WorkbenchConfigValue\n views?: DefineAppInput['views']\n webWorkers?: DefineAppInput['webWorkers']\n}\n\n/** @public */\nexport interface ResolvedWorkbenchApp {\n /**\n * Stable identity, distinct from the `slug` address. Defaults to `slug`, and is\n * what every identity key (build id, interface ids) is built from.\n */\n readonly name: string\n /** Organization that owns the app — part of its build-id identity. */\n readonly organizationId: string\n readonly slug: string\n /** Display title: the declared `title`, else {@link resolveAppTitle}'s fallback. */\n readonly title: string\n\n /** Views the app declares. */\n readonly views: NonNullable<DefineAppInput['views']>\n\n /** Background web workers the app declares. */\n readonly webWorkers: NonNullable<DefineAppInput['webWorkers']>\n\n /** Resolved app kind — `studio` or one of the SDK app types. */\n readonly applicationType?: string\n /** SDK app-view entrypoint, when declared. */\n readonly entry?: string\n /** Path to the app's icon SVG, resolved and shipped to Brett on deploy. */\n readonly icon?: string\n /** Explicit singleton flag for Sanity-owned apps. */\n readonly isSingleton?: boolean\n /** Dashboard visibility declared by the app; `undefined` when unset. */\n readonly visibility?: AppVisibility\n}\n\n/**\n * The module behind the app's `./App` expose. `entry` is shorthand for a window view.\n * @internal\n */\nexport function resolveAppEntry(app: CliConfig['app']): string | undefined {\n if (!isWorkbenchApp(app)) return app?.entry\n\n const views =\n app.entry === undefined\n ? (app.views ?? [])\n : [\n defineWindowView({\n name: app.name ?? app.slug,\n src: app.entry,\n title: resolveAppTitle(app),\n }),\n ...(app.views ?? []),\n ]\n\n return views.find((view) => view.surface === 'window')?.src\n}\n\n/**\n * Resolve the workbench app for a CLI config, or `null` for a plain project or a\n * config (which is not an app — read it with `resolveWorkbenchConfig`).\n * @public\n */\nexport function resolveWorkbenchApp(\n cliConfig: CliConfig | null | undefined,\n): ResolvedWorkbenchApp | null {\n const app = cliConfig?.app\n // A config carries a distinct brand, so `isWorkbenchApp` is false for it — it\n // resolves to `null` here, like a plain project.\n if (!isWorkbenchApp(app)) return null\n\n const errors = validateWorkbenchApp(app)\n if (errors.length > 0) throw new Error(formatWorkbenchAppErrors(errors))\n\n return {\n applicationType: app.applicationType,\n entry: app.entry,\n icon: app.icon,\n ...(app.isSingleton === undefined ? {} : {isSingleton: app.isSingleton}),\n // Identity defaults to the address, so existing apps behave identically.\n name: app.name ?? app.slug,\n organizationId: app.organizationId,\n slug: app.slug,\n title: resolveAppTitle(app),\n views: app.views ?? [],\n visibility: app.visibility,\n webWorkers: app.webWorkers ?? [],\n }\n}\n"],"names":["defineWindowView","isWorkbenchApp","resolveAppTitle","formatWorkbenchAppErrors","validateWorkbenchApp","resolveAppEntry","app","entry","views","undefined","name","slug","src","title","find","view","surface","resolveWorkbenchApp","cliConfig","errors","length","Error","applicationType","icon","isSingleton","organizationId","visibility","webWorkers"],"mappings":"AAAA,gEAAgE;AAChE,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,0EAA0E;AAC1E,gEAAgE;AAIhE,SAAQA,gBAAgB,QAAkC,gBAAe;AACzE,SAA6BC,cAAc,EAAEC,eAAe,QAAO,iBAAgB;AAC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a CLI config's branded
|
|
2
|
-
// `unstable_defineMediaLibrary` config into its target
|
|
3
|
-
// `
|
|
4
|
-
// (a plain project or an app). The deploy/undeploy/build paths
|
|
5
|
-
// second resolver; app-only callers keep using `resolveWorkbenchApp`.
|
|
2
|
+
// `unstable_defineMediaLibrary` or `defineDashboard` config into its target
|
|
3
|
+
// `appType`, owning `organizationId`, and payload, or `null` when the config is
|
|
4
|
+
// not a config (a plain project or an app). The deploy/undeploy/build paths
|
|
5
|
+
// consult this second resolver; app-only callers keep using `resolveWorkbenchApp`.
|
|
6
|
+
import { z } from 'zod/mini';
|
|
6
7
|
import { ConfigSchema } from './contract.js';
|
|
7
8
|
import { isWorkbenchConfig } from './defineApp.js';
|
|
8
9
|
/**
|
|
9
10
|
* Resolve the workbench config for a CLI config, or `null` when it carries no
|
|
10
|
-
* config brand (a plain project or an app).
|
|
11
|
-
* Library, so the resolved shape is a {@link ResolvedMediaLibraryConfig}.
|
|
11
|
+
* config brand (a plain project or an app).
|
|
12
12
|
* @public
|
|
13
13
|
*/ export function resolveWorkbenchConfig(cliConfig) {
|
|
14
14
|
const app = cliConfig?.app;
|
|
15
15
|
if (!isWorkbenchConfig(app)) return null;
|
|
16
|
-
const result = ConfigSchema.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
16
|
+
const result = z.intersection(ConfigSchema, z.object({
|
|
17
|
+
organizationId: z.string("Config `organizationId` is required — pass the owning organization's ID")
|
|
18
|
+
})).safeParse(app);
|
|
20
19
|
if (!result.success) {
|
|
21
|
-
throw new Error(`Invalid
|
|
20
|
+
throw new Error(`Invalid ${app.appType} config:\n${z.prettifyError(result.error)}`);
|
|
22
21
|
}
|
|
23
|
-
return
|
|
24
|
-
appType: app.appType,
|
|
25
|
-
fields: app.fields,
|
|
26
|
-
organizationId: app.organizationId
|
|
27
|
-
};
|
|
22
|
+
return app;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
//# sourceMappingURL=resolveWorkbenchConfig.js.map
|
|
@@ -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"}
|
|
@@ -4,7 +4,7 @@ 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
6
|
export function getWorkbenchUrl(organizationId) {
|
|
7
|
-
return `https://${organizationId}.${isStaging() ? 'run.sanity.work' : 'sanity.run'}`;
|
|
7
|
+
return `https://${organizationId.toLowerCase()}.${isStaging() ? 'run.sanity.work' : 'sanity.run'}`;
|
|
8
8
|
}
|
|
9
9
|
/** Where a deployed application is served on its organization's workbench. */ export function getApplicationUrl(application) {
|
|
10
10
|
const segment = application.type === 'studio' ? 'studios' : 'applications';
|
|
@@ -127,6 +127,17 @@ export async function updateApplication(applicationId, update) {
|
|
|
127
127
|
url: `/applications/${applicationId}/icon`
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
+
/** Upload an app or panel interface's icon, replacing any it has. */ export async function setInterfaceIcon(applicationId, interfaceId, icon) {
|
|
131
|
+
const client = await getClient();
|
|
132
|
+
await client.request({
|
|
133
|
+
body: icon.image,
|
|
134
|
+
headers: {
|
|
135
|
+
'Content-Type': icon.contentType
|
|
136
|
+
},
|
|
137
|
+
method: 'PUT',
|
|
138
|
+
url: `/applications/${applicationId}/interfaces/${interfaceId}/icon`
|
|
139
|
+
});
|
|
140
|
+
}
|
|
130
141
|
/**
|
|
131
142
|
* Deploy a new active version to an existing application. `mfManifest` is the
|
|
132
143
|
* build's federation manifest; `tarball` is omitted for an external application,
|
|
@@ -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/**\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","setApplicationIcon","icon","image","headers","contentType","removeApplicationIcon","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,cAAc,EAAEH,eAAe;QAAA;IACpE,EAAE,OAAOI,KAAK;QACZ,IAAI,AAACA,KAA+BC,eAAe,KAAK,OAAO;QAC/D,MAAMD;IACR;AACF;AAEA,OAAO,eAAeE,2BACpBjB,cAAsB,EACtBkB,QAAgB,EAChBC,MAAoB;IAIpB,MAAMP,SAAS,MAAMjB,mBAAmB;QACtCa,YAAYV;QACZsB,gBAAgB;YAAC;YAAuC;SAAoC;QAC5FX,aAAa;IACf;IACA,IAAI;QACF,OAAO,MAAMG,OAA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,KAA+BC,eAAe,KAAK,MAAMD;IAChE;AACF;AAEA,SAAS2C,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;YAACP,aAAa;YAAoBiB,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASF,WAAWL,QAAkB,EAAEzB,IAAY,EAAEiC,KAAc;IAClER,SAASC,MAAM,CAAC1B,MAAMkC,KAAKC,SAAS,CAACF,QAAQ;QAAClB,aAAa;IAAkB;AAC/E;AAEA,eAAehC,QAAWC,GAAW,EAAEyC,QAAkB;IACvD,MAAM3C,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBqB,MAAMqB,SAASW,IAAI,CAAC,IAAIxE;QACxBkD,SAASW,SAASY,UAAU;QAC5B7B,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\nexport function getWorkbenchUrl(organizationId: string): string {\n return `https://${organizationId.toLowerCase()}.${isStaging() ? 'run.sanity.work' : 'sanity.run'}`\n}\n\n/** Where a deployed application is served on its organization's workbench. */\nexport function getApplicationUrl(\n application: Pick<Application, 'id' | 'organizationId' | 'slug' | 'type'>,\n): string {\n const segment = application.type === 'studio' ? 'studios' : 'applications'\n return `${getWorkbenchUrl(application.organizationId)}/${segment}/${application.slug ?? application.id}`\n}\n\nasync function getClient() {\n return getGlobalCliClient({apiVersion: APP_WORKBENCH_API_VERSION, requireUser: true})\n}\n\nexport async function getApplication(applicationId: string): Promise<Application | null> {\n const client = await getClient()\n try {\n return await client.request({url: `/applications/${applicationId}`})\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode === 404) return null\n throw err\n }\n}\n\nexport async function getOrganizationApplication(\n organizationId: string,\n idOrSlug: string,\n signal?: AbortSignal,\n): Promise<\n (Application & {activeDeployment: {createdAt: string; deployedBy: string} | null}) | null\n> {\n const client = await getGlobalCliClient({\n apiVersion: APP_WORKBENCH_API_VERSION,\n ignoreWarnings: ['This is an experimental API version', 'which will change without warning'],\n requireUser: true,\n })\n try {\n return await client.request({\n query: {include: 'activeDeployment'},\n signal,\n url: `/organizations/${organizationId}/applications/${idOrSlug}`,\n })\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode === 404) return null\n throw err\n }\n}\n\n/** Every application in an organization, in one page (`limit=none`). */\nexport async function listApplications(organizationId: string): Promise<Application[]> {\n const client = await getClient()\n const {data}: {data: Application[]} = await client.request({\n query: {limit: 'none', organizationId},\n url: '/applications',\n })\n return data\n}\n\n/**\n * Create an application record (no deployment), so the CLI can build with the\n * returned id, then ship it via {@link createDeployment}.\n */\nexport async function createApplication(options: {\n /** The origin a customer serves the build from; Brett then never hosts a bundle for it. */\n externalUrl?: string\n isSingleton?: boolean\n name?: string\n organizationId: string\n projectId?: string\n slug: string\n title: string\n type: ApplicationType\n visibility?: AppVisibility\n}): Promise<Application> {\n const {externalUrl, isSingleton, name, organizationId, projectId, slug, title, type, visibility} =\n options\n const client = await getClient()\n return client.request({\n body: {\n organizationId,\n slug,\n title,\n type,\n // Identity, distinct from the slug address. Omitted → Brett defaults it to slug.\n ...(name ? {name} : {}),\n // Brett requires `isSingleton` on `POST /applications`, so the request\n // builder keeps forwarding it even though the CLI itself never sets it.\n ...(isSingleton === undefined ? {} : {isSingleton}),\n ...(visibility ? {visibility} : {}),\n ...(externalUrl ? {externalUrl} : {}),\n // Studio config is set once, at create — it's immutable on redeploy.\n ...(projectId ? {config: {studio: {projectId}}} : {}),\n },\n method: 'POST',\n url: `/applications`,\n })\n}\n\n/** Mutable application fields the deploy flow patches after create. */\nexport interface ApplicationUpdate {\n /** The address the application is served at; renaming moves it. */\n slug?: string\n title?: string\n visibility?: AppVisibility\n}\n\n// Patch an application's mutable fields.\nexport async function updateApplication(\n applicationId: string,\n update: ApplicationUpdate,\n): Promise<void> {\n const client = await getClient()\n await client.request({body: update, method: 'PATCH', url: `/applications/${applicationId}`})\n}\n\n/** Upload the application's icon, replacing any it has. */\nexport async function setApplicationIcon(applicationId: string, icon: ImageFile): Promise<void> {\n const client = await getClient()\n await client.request({\n body: icon.image,\n headers: {'Content-Type': icon.contentType},\n method: 'PUT',\n url: `/applications/${applicationId}/icon`,\n })\n}\n\n/** Remove the application's icon; removing one that isn't set changes nothing. */\nexport async function removeApplicationIcon(applicationId: string): Promise<void> {\n const client = await getClient()\n await client.request({method: 'DELETE', url: `/applications/${applicationId}/icon`})\n}\n\n/** Upload an app or panel interface's icon, replacing any it has. */\nexport async function setInterfaceIcon(\n applicationId: string,\n interfaceId: string,\n icon: ImageFile,\n): Promise<void> {\n const client = await getClient()\n await client.request({\n body: icon.image,\n headers: {'Content-Type': icon.contentType},\n method: 'PUT',\n url: `/applications/${applicationId}/interfaces/${interfaceId}/icon`,\n })\n}\n\n/**\n * Deploy a new active version to an existing application. `mfManifest` is the\n * build's federation manifest; `tarball` is omitted for an external application,\n * whose build the customer serves themselves.\n */\nexport async function createDeployment(options: {\n access?: readonly BrettAccess[]\n applicationId: string\n interfaces: readonly BrettInterface[]\n isAutoUpdating: boolean\n mfManifest: Record<string, unknown>\n tarball?: Gzip\n version: string\n workspaces?: readonly BrettWorkspace[]\n}): Promise<{id: string; interfaces: {id: string; name: string; type: BrettInterface['type']}[]}> {\n const {\n access,\n applicationId,\n interfaces,\n isAutoUpdating,\n mfManifest,\n tarball,\n version,\n workspaces,\n } = options\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n appendDeploymentParts(formData, {access, interfaces, mfManifest, tarball, version, workspaces})\n return request(`/applications/${applicationId}/deployments`, formData)\n}\n\n/** Soft-deletes the application and all its deployments; already deleted counts as done. */\nexport async function deleteApplication(applicationId: string): Promise<void> {\n const client = await getClient()\n try {\n await client.request({method: 'DELETE', url: `/applications/${applicationId}`})\n } catch (err) {\n if ((err as {statusCode?: number})?.statusCode !== 404) throw err\n }\n}\n\nfunction appendDeploymentParts(\n formData: FormData,\n {\n access,\n interfaces,\n mfManifest,\n tarball,\n version,\n workspaces,\n }: {\n access?: readonly BrettAccess[]\n interfaces: readonly BrettInterface[]\n mfManifest: Record<string, unknown>\n tarball?: Gzip\n version: string\n workspaces?: readonly BrettWorkspace[]\n },\n): void {\n formData.append('version', version)\n appendJson(formData, 'interfaces', interfaces)\n // Studio-only — the server rejects a workspaces part on non-studio types.\n if (workspaces?.length) appendJson(formData, 'workspaces', workspaces)\n // Per-deployment; forbidden for singletons, so callers omit it there.\n if (access?.length) appendJson(formData, 'access', access)\n appendJson(formData, 'mfManifest', mfManifest)\n // Last: the server requires every field part to precede the tarball.\n if (tarball) {\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n }\n}\n\n/** Structured parts must arrive as JSON so the server parses them. */\nfunction appendJson(formData: FormData, name: string, value: unknown): void {\n formData.append(name, JSON.stringify(value), {contentType: 'application/json'})\n}\n\nasync function request<T>(url: string, formData: FormData): Promise<T> {\n const client = await getClient()\n return client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n url,\n })\n}\n"],"names":["PassThrough","getGlobalCliClient","isStaging","FormData","APP_WORKBENCH_API_VERSION","getWorkbenchUrl","organizationId","toLowerCase","getApplicationUrl","application","segment","type","slug","id","getClient","apiVersion","requireUser","getApplication","applicationId","client","request","url","err","statusCode","getOrganizationApplication","idOrSlug","signal","ignoreWarnings","query","include","listApplications","data","limit","createApplication","options","externalUrl","isSingleton","name","projectId","title","visibility","body","undefined","config","studio","method","updateApplication","update","setApplicationIcon","icon","image","headers","contentType","removeApplicationIcon","setInterfaceIcon","interfaceId","createDeployment","access","interfaces","isAutoUpdating","mfManifest","tarball","version","workspaces","formData","append","toString","appendDeploymentParts","deleteApplication","appendJson","length","filename","value","JSON","stringify","pipe","getHeaders"],"mappings":"AAAA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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,SAAS6C,sBACPH,QAAkB,EAClB,EACEP,MAAM,EACNC,UAAU,EACVE,UAAU,EACVC,OAAO,EACPC,OAAO,EACPC,UAAU,EAQX;IAEDC,SAASC,MAAM,CAAC,WAAWH;IAC3BO,WAAWL,UAAU,cAAcN;IACnC,0EAA0E;IAC1E,IAAIK,YAAYO,QAAQD,WAAWL,UAAU,cAAcD;IAC3D,sEAAsE;IACtE,IAAIN,QAAQa,QAAQD,WAAWL,UAAU,UAAUP;IACnDY,WAAWL,UAAU,cAAcJ;IACnC,qEAAqE;IACrE,IAAIC,SAAS;QACXG,SAASC,MAAM,CAAC,WAAWJ,SAAS;YAACT,aAAa;YAAoBmB,UAAU;QAAY;IAC9F;AACF;AAEA,oEAAoE,GACpE,SAASF,WAAWL,QAAkB,EAAE3B,IAAY,EAAEmC,KAAc;IAClER,SAASC,MAAM,CAAC5B,MAAMoC,KAAKC,SAAS,CAACF,QAAQ;QAACpB,aAAa;IAAkB;AAC/E;AAEA,eAAehC,QAAWC,GAAW,EAAE2C,QAAkB;IACvD,MAAM7C,SAAS,MAAML;IACrB,OAAOK,OAAOC,OAAO,CAAC;QACpBqB,MAAMuB,SAASW,IAAI,CAAC,IAAI3E;QACxBmD,SAASa,SAASY,UAAU;QAC5B/B,QAAQ;QACRxB;IACF;AACF"}
|
|
@@ -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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/workbench-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.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.0",
|
|
70
|
+
"@sanity/cli-core": "^3.17.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": "27.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,187 +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
|
-
title: z.ZodMiniString<string>;
|
|
55
|
-
name: z.ZodMiniString<string>;
|
|
56
|
-
src: z.ZodMiniString<string>;
|
|
57
|
-
surface: z.ZodMiniLiteral<"panel">;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
/** @public */
|
|
60
|
-
type PanelView = z.output<typeof PanelViewSchema>;
|
|
61
|
-
/** @public */
|
|
62
|
-
type DefinePanelViewInput = Omit<PanelView, 'surface'>;
|
|
63
|
-
/** @public */
|
|
64
|
-
declare function definePanelView(view: DefinePanelViewInput): PanelView;
|
|
65
|
-
declare const WindowViewSchema: z.ZodMiniObject<{
|
|
66
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
67
|
-
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
68
|
-
system: "system";
|
|
69
|
-
applications: "applications";
|
|
70
|
-
}>>;
|
|
71
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
72
|
-
}, z.core.$strip>>;
|
|
73
|
-
title: z.ZodMiniString<string>;
|
|
74
|
-
name: z.ZodMiniString<string>;
|
|
75
|
-
src: z.ZodMiniString<string>;
|
|
76
|
-
surface: z.ZodMiniLiteral<"window">;
|
|
77
|
-
}, z.core.$strip>;
|
|
78
|
-
/** @public */
|
|
79
|
-
type WindowView = z.output<typeof WindowViewSchema>;
|
|
80
|
-
/** @public */
|
|
81
|
-
type DefineWindowViewInput = Omit<WindowView, 'surface'>;
|
|
82
|
-
/** @public */
|
|
83
|
-
declare function defineWindowView(view: DefineWindowViewInput): WindowView;
|
|
84
|
-
declare const AssetSourceViewSchema: z.ZodMiniObject<{
|
|
85
|
-
title: z.ZodMiniString<string>;
|
|
86
|
-
name: z.ZodMiniString<string>;
|
|
87
|
-
src: z.ZodMiniString<string>;
|
|
88
|
-
surface: z.ZodMiniLiteral<"asset_source">;
|
|
89
|
-
}, z.core.$strip>;
|
|
90
|
-
/** @public */
|
|
91
|
-
type AssetSourceView = z.output<typeof AssetSourceViewSchema>;
|
|
92
|
-
/** @public */
|
|
93
|
-
type DefineAssetSourceViewInput = Omit<AssetSourceView, 'surface'>;
|
|
94
|
-
/** @public */
|
|
95
|
-
declare function defineAssetSourceView(view: DefineAssetSourceViewInput): AssetSourceView;
|
|
96
|
-
declare const TileViewSchema: z.ZodMiniObject<{
|
|
97
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
98
|
-
size: z.ZodMiniEnum<{
|
|
99
|
-
small: "small";
|
|
100
|
-
large: "large";
|
|
101
|
-
banner: "banner";
|
|
102
|
-
}>;
|
|
103
|
-
title: z.ZodMiniString<string>;
|
|
104
|
-
name: z.ZodMiniString<string>;
|
|
105
|
-
src: z.ZodMiniString<string>;
|
|
106
|
-
surface: z.ZodMiniLiteral<"tile">;
|
|
107
|
-
}, z.core.$strip>;
|
|
108
|
-
/** @public */
|
|
109
|
-
type TileView = z.output<typeof TileViewSchema>;
|
|
110
|
-
/** @public */
|
|
111
|
-
type DefineTileViewInput = Omit<TileView, 'surface'>;
|
|
112
|
-
/** @public */
|
|
113
|
-
declare function defineTileView(view: DefineTileViewInput): TileView;
|
|
114
|
-
/** @internal */
|
|
115
|
-
declare const InterfaceDeclarationSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
116
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
117
|
-
group: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
118
|
-
system: "system";
|
|
119
|
-
applications: "applications";
|
|
120
|
-
}>>;
|
|
121
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
122
|
-
}, z.core.$strip>>;
|
|
123
|
-
title: z.ZodMiniString<string>;
|
|
124
|
-
name: z.ZodMiniString<string>;
|
|
125
|
-
src: z.ZodMiniString<string>;
|
|
126
|
-
surface: z.ZodMiniLiteral<"window">;
|
|
127
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
128
|
-
dock: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
129
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
130
|
-
}, z.core.$strip>>;
|
|
131
|
-
title: z.ZodMiniString<string>;
|
|
132
|
-
name: z.ZodMiniString<string>;
|
|
133
|
-
src: z.ZodMiniString<string>;
|
|
134
|
-
surface: z.ZodMiniLiteral<"panel">;
|
|
135
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
136
|
-
title: z.ZodMiniString<string>;
|
|
137
|
-
name: z.ZodMiniString<string>;
|
|
138
|
-
src: z.ZodMiniString<string>;
|
|
139
|
-
surface: z.ZodMiniLiteral<"asset_source">;
|
|
140
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
141
|
-
order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
142
|
-
size: z.ZodMiniEnum<{
|
|
143
|
-
small: "small";
|
|
144
|
-
large: "large";
|
|
145
|
-
banner: "banner";
|
|
146
|
-
}>;
|
|
147
|
-
title: z.ZodMiniString<string>;
|
|
148
|
-
name: z.ZodMiniString<string>;
|
|
149
|
-
src: z.ZodMiniString<string>;
|
|
150
|
-
surface: z.ZodMiniLiteral<"tile">;
|
|
151
|
-
}, z.core.$strip>], "surface">;
|
|
152
|
-
/** @public */
|
|
153
|
-
type ViewDeclaration = z.output<typeof InterfaceDeclarationSchema>;
|
|
154
|
-
declare const WebWorkerSchema: z.ZodMiniObject<{
|
|
155
|
-
title: z.ZodMiniString<string>;
|
|
156
|
-
name: z.ZodMiniString<string>;
|
|
157
|
-
src: z.ZodMiniString<string>;
|
|
158
|
-
type: z.ZodMiniLiteral<"worker">;
|
|
159
|
-
}, z.core.$strip>;
|
|
160
|
-
/** @public */
|
|
161
|
-
type WebWorker = z.output<typeof WebWorkerSchema>;
|
|
162
|
-
/** @public */
|
|
163
|
-
type DefineWebWorkerInput = Omit<WebWorker, 'type'>;
|
|
164
|
-
/** @public */
|
|
165
|
-
declare function defineWebWorker(webWorker: DefineWebWorkerInput): WebWorker;
|
|
166
|
-
/**
|
|
167
|
-
* A workbench config's built value, keyed by `appType`; deploys as a versioned
|
|
168
|
-
* snapshot, not an interface.
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
declare const ConfigSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
172
|
-
appType: z.ZodMiniLiteral<"media-library">;
|
|
173
|
-
fields: z.ZodMiniArray<z.ZodMiniObject<{
|
|
174
|
-
public: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
175
|
-
title: z.ZodMiniString<string>;
|
|
176
|
-
name: z.ZodMiniString<string>;
|
|
177
|
-
src: z.ZodMiniString<string>;
|
|
178
|
-
}, z.core.$strip>>;
|
|
179
|
-
}, z.core.$strip>], "appType">;
|
|
180
|
-
/**
|
|
181
|
-
* The `{appType, fields}` config value the build expands into a federation
|
|
182
|
-
* remote and the deploy summarizes.
|
|
183
|
-
* @internal
|
|
184
|
-
*/
|
|
185
|
-
type WorkbenchConfigValue = z.output<typeof ConfigSchema>;
|
|
186
|
-
export { defineTileView as C, definePanelView as S, defineWindowView as T, WebWorker as _, DefineWebWorkerInput as a, WorkbenchConfigValue as b, PanelView as c, TileView 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, AssetSourceView as t, TileSize as u, WebWorkerType as v, defineWebWorker as w, defineAssetSourceView as x, WindowView as y };
|
|
187
|
-
//# sourceMappingURL=contract-WrU3aOYd.d.ts.map
|