@sanity/workbench-cli 1.2.0 → 1.3.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.
Files changed (42) hide show
  1. package/dist/_exports/build.d.ts +22 -17
  2. package/dist/_exports/deploy.d.ts +156 -20
  3. package/dist/_exports/deploy.js +3 -1
  4. package/dist/_exports/deploy.js.map +1 -1
  5. package/dist/_exports/dev.d.ts +6 -3
  6. package/dist/_exports/index.d.ts +16 -13
  7. package/dist/actions/build/artifact.js +2 -2
  8. package/dist/actions/build/artifact.js.map +1 -1
  9. package/dist/actions/build/configs/artifact.js +5 -5
  10. package/dist/actions/build/configs/artifact.js.map +1 -1
  11. package/dist/actions/deploy/apiVersion.js +5 -0
  12. package/dist/actions/deploy/apiVersion.js.map +1 -0
  13. package/dist/actions/deploy/buildExposes.js +56 -0
  14. package/dist/actions/deploy/buildExposes.js.map +1 -0
  15. package/dist/actions/deploy/{deployInstallationConfig.js → deployConfig.js} +10 -11
  16. package/dist/actions/deploy/deployConfig.js.map +1 -0
  17. package/dist/actions/deploy/deployWorkbenchApp.js +185 -0
  18. package/dist/actions/deploy/deployWorkbenchApp.js.map +1 -0
  19. package/dist/actions/deploy/getWorkbench.js +4 -4
  20. package/dist/actions/deploy/getWorkbench.js.map +1 -1
  21. package/dist/actions/dev/deriveInterfaces.js +33 -19
  22. package/dist/actions/dev/deriveInterfaces.js.map +1 -1
  23. package/dist/actions/dev/exposesSetId.js +6 -6
  24. package/dist/actions/dev/exposesSetId.js.map +1 -1
  25. package/dist/actions/dev/registry.js +14 -5
  26. package/dist/actions/dev/registry.js.map +1 -1
  27. package/dist/actions/dev/startDevManifestWatcher.js +2 -2
  28. package/dist/actions/dev/startDevManifestWatcher.js.map +1 -1
  29. package/dist/actions/dev/startDevServerRegistration.js +7 -7
  30. package/dist/actions/dev/startDevServerRegistration.js.map +1 -1
  31. package/dist/actions/dev/startWorkbenchDevServer.js +9 -6
  32. package/dist/actions/dev/startWorkbenchDevServer.js.map +1 -1
  33. package/dist/actions/dev/writeWorkbenchRuntime.js +4 -1
  34. package/dist/actions/dev/writeWorkbenchRuntime.js.map +1 -1
  35. package/dist/contract.js +16 -8
  36. package/dist/contract.js.map +1 -1
  37. package/dist/defineApp.js +25 -20
  38. package/dist/defineApp.js.map +1 -1
  39. package/dist/resolveWorkbenchApp.js +4 -3
  40. package/dist/resolveWorkbenchApp.js.map +1 -1
  41. package/package.json +3 -3
  42. package/dist/actions/deploy/deployInstallationConfig.js.map +0 -1
package/dist/defineApp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod/mini';
2
- import { InstallationConfigSchema, InterfaceDeclarationSchema, ServiceDeclarationSchema } from './contract.js';
2
+ import { ConfigSchema, InterfaceDeclarationSchema, ServiceDeclarationSchema } from './contract.js';
3
3
  /** Allowed characters for an app `name`. */ const APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
4
4
  /**
5
5
  * Internal application discriminator. Sanity-owned singleton apps only;
@@ -27,6 +27,12 @@ import { InstallationConfigSchema, InterfaceDeclarationSchema, ServiceDeclaratio
27
27
  * from the public `DefineAppInput` type.
28
28
  * @internal
29
29
  */ applicationType: z.optional(ApplicationType),
30
+ /**
31
+ * Deployed as a versioned snapshot on the app's org installation, not the
32
+ * application service. Singletons only. Internal, so excluded from the public
33
+ * `DefineAppInput` and set via `@ts-expect-error` like `applicationType`.
34
+ * @internal
35
+ */ config: z.optional(ConfigSchema),
30
36
  /**
31
37
  * App entrypoint module. Defaults to `./src/App.tsx` when omitted. The build
32
38
  * derives the app's navigable `app` view from it. SDK apps only — setting it
@@ -34,12 +40,6 @@ import { InstallationConfigSchema, InterfaceDeclarationSchema, ServiceDeclaratio
34
40
  */ entry: z.optional(z.string()),
35
41
  /** Dock group to render in. Defaults to `dock.applications` when omitted. */ group: z.optional(DockGroupSchema),
36
42
  /** Optional icon override (path to an SVG). Wins over manifest/studio icon. */ icon: z.optional(z.string()),
37
- /**
38
- * Deployed as a versioned snapshot on the app's org installation, not the
39
- * application service. Singletons only. Internal, so excluded from the public
40
- * `DefineAppInput` and set via `@ts-expect-error` like `applicationType`.
41
- * @internal
42
- */ installationConfig: z.optional(InstallationConfigSchema),
43
43
  /**
44
44
  * Sanity-owned app deployed once, installed per org; excluded from the public `DefineAppInput`.
45
45
  * @internal
@@ -53,6 +53,11 @@ import { InstallationConfigSchema, InterfaceDeclarationSchema, ServiceDeclaratio
53
53
  * application service on deploy, not into the app manifest. Service `name`s
54
54
  * must be unique within the app.
55
55
  */ services: z.optional(z.array(ServiceDeclarationSchema).check(z.refine((services)=>new Set(services.map((service)=>service.name)).size === services.length, 'Service `name` must be unique within an app'))),
56
+ /**
57
+ * Hostname the application is created at on first deploy. Generated when
58
+ * omitted; redeploys target `deployment.appId` and ignore it. SDK apps
59
+ * only — studios use `studioHost` in sanity.cli.ts.
60
+ */ slug: z.optional(z.string()),
56
61
  /** User-facing app title. Wins over studio.config.ts title on merge. */ title: z.string(),
57
62
  /**
58
63
  * Views the app exposes (e.g. dock panels). Metadata only — built into
@@ -67,13 +72,13 @@ z.refine((input)=>!(input.applicationType === 'studio' && input.entry !== undefi
67
72
  path: [
68
73
  'entry'
69
74
  ]
70
- })).check(// An installation config belongs to a Sanity-owned singleton (the Media
75
+ })).check(// An config belongs to a Sanity-owned singleton (the Media
71
76
  // Library). A non-singleton declaring one is rejected — see
72
- // {@link readInstallationConfig} for the runtime guard.
73
- z.refine((input)=>!(input.installationConfig && !input.isSingleton), {
74
- error: '`installationConfig` is only supported for singleton apps',
77
+ // {@link readConfig} for the runtime guard.
78
+ z.refine((input)=>!(input.config && !input.isSingleton), {
79
+ error: '`config` is only supported for singleton apps',
75
80
  path: [
76
- 'installationConfig'
81
+ 'config'
77
82
  ]
78
83
  }));
79
84
  /**
@@ -90,16 +95,16 @@ z.refine((input)=>!(input.installationConfig && !input.isSingleton), {
90
95
  return typeof app === 'object' && app !== null && WORKBENCH_APP in app;
91
96
  }
92
97
  /**
93
- * The app's installation config, or `undefined` when it declares none. Throws
98
+ * The app's config, or `undefined` when it declares none. Throws
94
99
  * when a non-singleton declares one — configs belong to Sanity-owned singletons,
95
100
  * so build/dev/deploy all read it through here to reject the combination
96
101
  * consistently.
97
102
  * @internal
98
- */ export function readInstallationConfig(app) {
99
- if (app.installationConfig && !app.isSingleton) {
100
- throw new Error('`installationConfig` is only supported for singleton apps');
103
+ */ export function readConfig(app) {
104
+ if (app.config && !app.isSingleton) {
105
+ throw new Error('`config` is only supported for singleton apps');
101
106
  }
102
- return app.installationConfig;
107
+ return app.config;
103
108
  }
104
109
  /**
105
110
  * Declare a Sanity Workbench application. Identity at runtime — returns the same
@@ -116,13 +121,13 @@ z.refine((input)=>!(input.installationConfig && !input.isSingleton), {
116
121
  });
117
122
  }
118
123
  /**
119
- * Declare the Sanity Media Library as a workbench app — a singleton whose `fields` become its installation config.
124
+ * Declare the Sanity Media Library as a workbench app — a singleton whose `fields` become its config.
120
125
  * @public
121
126
  */ export function unstable_defineMediaLibrary(input) {
122
127
  return unstable_defineApp({
123
- // @ts-expect-error -- `applicationType`/`isSingleton`/`installationConfig` are internal, excluded from `DefineAppInput`; Sanity-owned apps set them
128
+ // @ts-expect-error -- `applicationType`/`isSingleton`/`config` are internal, excluded from `DefineAppInput`; Sanity-owned apps set them
124
129
  applicationType: 'media-library',
125
- installationConfig: input.fields?.length ? {
130
+ config: input.fields?.length ? {
126
131
  appType: 'media-library',
127
132
  fields: input.fields
128
133
  } : undefined,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defineApp.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\nimport {\n InstallationConfigSchema,\n InterfaceDeclarationSchema,\n ServiceDeclarationSchema,\n} from './contract.js'\n\n/** Allowed characters for an app `name`. */\nconst APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/\n\n/**\n * Internal application discriminator. Sanity-owned singleton apps only;\n * validated by the schema but excluded from the public `DefineAppInput` type.\n */\nconst ApplicationType = z.enum(['coreApp', 'studio', 'canvas', 'dashboard', 'media-library'])\n\n/** Dock groups an app can place itself into. */\nconst DockGroupSchema = z.enum(['dock.system', 'dock.applications', 'dock.user'])\n\n/**\n * Dock group identifier. The API does not block a user app from declaring a\n * reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned\n * apps ahead.\n * @public\n */\nexport type DockGroup = z.output<typeof DockGroupSchema>\n\n/**\n * Runtime-validation schema for `unstable_defineApp`. Validates the full shape\n * including the internal `applicationType`; the user-facing `DefineAppInput`\n * type below omits that field.\n * @internal\n */\nexport const DefineAppInputSchema = z\n .object({\n /**\n * Internal — Sanity-owned singleton apps only. Validated here but excluded\n * from the public `DefineAppInput` type.\n * @internal\n */\n applicationType: z.optional(ApplicationType),\n /**\n * App entrypoint module. Defaults to `./src/App.tsx` when omitted. The build\n * derives the app's navigable `app` view from it. SDK apps only — setting it\n * on a studio is rejected (studio app views are not yet implemented).\n */\n entry: z.optional(z.string()),\n /** Dock group to render in. Defaults to `dock.applications` when omitted. */\n group: z.optional(DockGroupSchema),\n /** Optional icon override (path to an SVG). Wins over manifest/studio icon. */\n icon: z.optional(z.string()),\n /**\n * Deployed as a versioned snapshot on the app's org installation, not the\n * application service. Singletons only. Internal, so excluded from the public\n * `DefineAppInput` and set via `@ts-expect-error` like `applicationType`.\n * @internal\n */\n installationConfig: z.optional(InstallationConfigSchema),\n /**\n * Sanity-owned app deployed once, installed per org; excluded from the public `DefineAppInput`.\n * @internal\n */\n isSingleton: z.optional(z.boolean()),\n /** Unique app identifier — must match `APP_NAME_PATTERN`. */\n name: z.string().check(z.regex(APP_NAME_PATTERN, 'App `name` must match /^[a-zA-Z0-9_-]+$/')),\n /** Organization that owns the app — the workbench runs and deploys against it. */\n organizationId: z.string(\n \"App `organizationId` is required — pass the owning organization's ID to `unstable_defineApp`\",\n ),\n /** Sort position within the group, ascending. Defaults to `100` when omitted. */\n priority: z.optional(z.number()),\n /**\n * Background services the app runs (e.g. a `worker` emitting dock badges).\n * Metadata only — built into worker artifacts and persisted to the\n * application service on deploy, not into the app manifest. Service `name`s\n * must be unique within the app.\n */\n services: z.optional(\n z\n .array(ServiceDeclarationSchema)\n .check(\n z.refine(\n (services) => new Set(services.map((service) => service.name)).size === services.length,\n 'Service `name` must be unique within an app',\n ),\n ),\n ),\n /** User-facing app title. Wins over studio.config.ts title on merge. */\n title: z.string(),\n /**\n * Views the app exposes (e.g. dock panels). Metadata only — built into\n * render artifacts and persisted to the application service on deploy, not\n * into the app manifest. View `name`s must be unique within the app.\n */\n views: z.optional(\n z\n .array(InterfaceDeclarationSchema)\n .check(\n z.refine(\n (views) => new Set(views.map((view) => view.name)).size === views.length,\n 'View `name` must be unique within an app',\n ),\n ),\n ),\n })\n .check(\n // Studio app views are not implemented yet. A studio that declares `entry`\n // (the SDK app-view entrypoint) is rejected here rather than silently\n // generating one; studios keep navigating via their existing render path.\n z.refine((input) => !(input.applicationType === 'studio' && input.entry !== undefined), {\n error: 'App views for studios are not implemented yet',\n path: ['entry'],\n }),\n )\n .check(\n // An installation config belongs to a Sanity-owned singleton (the Media\n // Library). A non-singleton declaring one is rejected — see\n // {@link readInstallationConfig} for the runtime guard.\n z.refine((input) => !(input.installationConfig && !input.isSingleton), {\n error: '`installationConfig` is only supported for singleton apps',\n path: ['installationConfig'],\n }),\n )\n\n/**\n * User-facing input for `unstable_defineApp`. Excludes the internal\n * `applicationType`, `isSingleton`, and `installationConfig` — validated by the\n * schema but not part of the public surface (Sanity-owned apps set them via\n * `@ts-expect-error`).\n * @public\n */\nexport type DefineAppInput = Omit<\n z.output<typeof DefineAppInputSchema>,\n 'applicationType' | 'installationConfig' | 'isSingleton'\n>\n\n/**\n * Nominal brand the CLI discriminates on to enable the workbench build/deploy\n * codepath. Registered via `Symbol.for` so the marker survives module-realm\n * boundaries — `@sanity/cli-core` re-derives the same global symbol with\n * `Symbol.for` rather than importing it, so it stays internal to this module.\n */\nconst WORKBENCH_APP: unique symbol = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * The branded result of `unstable_defineApp`. Carries the same fields as the\n * input plus the internal brand — users only ever see `DefineAppInput`.\n * @public\n */\nexport interface DefineAppResult extends DefineAppInput {\n readonly [WORKBENCH_APP]: true\n}\n\n/**\n * A branded app as the CLI reads it — the full schema shape, including the\n * internal fields `DefineAppInput` omits. Schema-derived so the narrowing\n * can't drift from what the schema validates.\n * @public\n */\nexport type WorkbenchApp = DefineAppResult & z.output<typeof DefineAppInputSchema>\n\n/**\n * Whether `app` is a branded `unstable_defineApp(...)` result — the sole\n * workbench opt-in.\n * @public\n */\nexport function isWorkbenchApp(app: unknown): app is WorkbenchApp {\n return typeof app === 'object' && app !== null && WORKBENCH_APP in app\n}\n\n/**\n * The app's installation config, or `undefined` when it declares none. Throws\n * when a non-singleton declares one — configs belong to Sanity-owned singletons,\n * so build/dev/deploy all read it through here to reject the combination\n * consistently.\n * @internal\n */\nexport function readInstallationConfig(\n app: WorkbenchApp,\n): WorkbenchApp['installationConfig'] | undefined {\n if (app.installationConfig && !app.isSingleton) {\n throw new Error('`installationConfig` is only supported for singleton apps')\n }\n return app.installationConfig\n}\n\n/**\n * Declare a Sanity Workbench application. Identity at runtime — returns the same\n * object reference, tagged with the workbench brand. Field validation (the\n * `name` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;\n * this helper stays a thin, pure identity wrapper.\n * @public\n */\nexport function unstable_defineApp(input: DefineAppInput): DefineAppResult {\n return Object.defineProperty(input, WORKBENCH_APP, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n }) as DefineAppResult\n}\n\n/**\n * One custom field a media library exposes. `src` default-exports a `defineField(...)` schema type.\n * @public\n */\nexport interface MediaLibraryField {\n /** Unique within the media library. */\n name: string\n src: string\n title: string\n\n /** Readable outside the owning organization. */\n public?: boolean\n}\n\n/**\n * Sanity-owned singleton, so authors don't name or title the app — only `organizationId` is required.\n * @public\n */\nexport interface DefineMediaLibraryInput {\n /** Organization that owns the media library — the CLI runs and deploys against it. */\n organizationId: string\n\n fields?: MediaLibraryField[]\n}\n\n/**\n * Declare the Sanity Media Library as a workbench app — a singleton whose `fields` become its installation config.\n * @public\n */\nexport function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): DefineAppResult {\n return unstable_defineApp({\n // @ts-expect-error -- `applicationType`/`isSingleton`/`installationConfig` are internal, excluded from `DefineAppInput`; Sanity-owned apps set them\n applicationType: 'media-library',\n installationConfig: input.fields?.length\n ? {appType: 'media-library', fields: input.fields}\n : undefined,\n isSingleton: true,\n name: 'media-library',\n organizationId: input.organizationId,\n title: 'Media Library',\n })\n}\n"],"names":["z","InstallationConfigSchema","InterfaceDeclarationSchema","ServiceDeclarationSchema","APP_NAME_PATTERN","ApplicationType","enum","DockGroupSchema","DefineAppInputSchema","object","applicationType","optional","entry","string","group","icon","installationConfig","isSingleton","boolean","name","check","regex","organizationId","priority","number","services","array","refine","Set","map","service","size","length","title","views","view","input","undefined","error","path","WORKBENCH_APP","Symbol","for","isWorkbenchApp","app","readInstallationConfig","Error","unstable_defineApp","Object","defineProperty","configurable","enumerable","value","writable","unstable_defineMediaLibrary","fields","appType"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B,SACEC,wBAAwB,EACxBC,0BAA0B,EAC1BC,wBAAwB,QACnB,gBAAe;AAEtB,0CAA0C,GAC1C,MAAMC,mBAAmB;AAEzB;;;CAGC,GACD,MAAMC,kBAAkBL,EAAEM,IAAI,CAAC;IAAC;IAAW;IAAU;IAAU;IAAa;CAAgB;AAE5F,8CAA8C,GAC9C,MAAMC,kBAAkBP,EAAEM,IAAI,CAAC;IAAC;IAAe;IAAqB;CAAY;AAUhF;;;;;CAKC,GACD,OAAO,MAAME,uBAAuBR,EACjCS,MAAM,CAAC;IACN;;;;KAIC,GACDC,iBAAiBV,EAAEW,QAAQ,CAACN;IAC5B;;;;KAIC,GACDO,OAAOZ,EAAEW,QAAQ,CAACX,EAAEa,MAAM;IAC1B,2EAA2E,GAC3EC,OAAOd,EAAEW,QAAQ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A,CAAAA,MAAMpB,kBAAkB,IAAI,CAACoB,MAAMnB,WAAW,AAAD,GAAI;IACrEqB,OAAO;IACPC,MAAM;QAAC;KAAqB;AAC9B,IACD;AAcH;;;;;CAKC,GACD,MAAMC,gBAA+BC,OAAOC,GAAG,CAAC;AAmBhD;;;;CAIC,GACD,OAAO,SAASC,eAAeC,GAAY;IACzC,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,iBAAiBI;AACrE;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,uBACdD,GAAiB;IAEjB,IAAIA,IAAI5B,kBAAkB,IAAI,CAAC4B,IAAI3B,WAAW,EAAE;QAC9C,MAAM,IAAI6B,MAAM;IAClB;IACA,OAAOF,IAAI5B,kBAAkB;AAC/B;AAEA;;;;;;CAMC,GACD,OAAO,SAAS+B,mBAAmBX,KAAqB;IACtD,OAAOY,OAAOC,cAAc,CAACb,OAAOI,eAAe;QACjDU,cAAc;QACdC,YAAY;QACZC,OAAO;QACPC,UAAU;IACZ;AACF;AA2BA;;;CAGC,GACD,OAAO,SAASC,4BAA4BlB,KAA8B;IACxE,OAAOW,mBAAmB;QACxB,oJAAoJ;QACpJrC,iBAAiB;QACjBM,oBAAoBoB,MAAMmB,MAAM,EAAEvB,SAC9B;YAACwB,SAAS;YAAiBD,QAAQnB,MAAMmB,MAAM;QAAA,IAC/ClB;QACJpB,aAAa;QACbE,MAAM;QACNG,gBAAgBc,MAAMd,cAAc;QACpCW,OAAO;IACT;AACF"}
1
+ {"version":3,"sources":["../src/defineApp.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\nimport {ConfigSchema, InterfaceDeclarationSchema, ServiceDeclarationSchema} from './contract.js'\n\n/** Allowed characters for an app `name`. */\nconst APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/\n\n/**\n * Internal application discriminator. Sanity-owned singleton apps only;\n * validated by the schema but excluded from the public `DefineAppInput` type.\n */\nconst ApplicationType = z.enum(['coreApp', 'studio', 'canvas', 'dashboard', 'media-library'])\n\n/** Dock groups an app can place itself into. */\nconst DockGroupSchema = z.enum(['dock.system', 'dock.applications', 'dock.user'])\n\n/**\n * Dock group identifier. The API does not block a user app from declaring a\n * reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned\n * apps ahead.\n * @public\n */\nexport type DockGroup = z.output<typeof DockGroupSchema>\n\n/**\n * Runtime-validation schema for `unstable_defineApp`. Validates the full shape\n * including the internal `applicationType`; the user-facing `DefineAppInput`\n * type below omits that field.\n * @internal\n */\nexport const DefineAppInputSchema = z\n .object({\n /**\n * Internal — Sanity-owned singleton apps only. Validated here but excluded\n * from the public `DefineAppInput` type.\n * @internal\n */\n applicationType: z.optional(ApplicationType),\n /**\n * Deployed as a versioned snapshot on the app's org installation, not the\n * application service. Singletons only. Internal, so excluded from the public\n * `DefineAppInput` and set via `@ts-expect-error` like `applicationType`.\n * @internal\n */\n config: z.optional(ConfigSchema),\n /**\n * App entrypoint module. Defaults to `./src/App.tsx` when omitted. The build\n * derives the app's navigable `app` view from it. SDK apps only — setting it\n * on a studio is rejected (studio app views are not yet implemented).\n */\n entry: z.optional(z.string()),\n /** Dock group to render in. Defaults to `dock.applications` when omitted. */\n group: z.optional(DockGroupSchema),\n /** Optional icon override (path to an SVG). Wins over manifest/studio icon. */\n icon: z.optional(z.string()),\n /**\n * Sanity-owned app deployed once, installed per org; excluded from the public `DefineAppInput`.\n * @internal\n */\n isSingleton: z.optional(z.boolean()),\n /** Unique app identifier — must match `APP_NAME_PATTERN`. */\n name: z.string().check(z.regex(APP_NAME_PATTERN, 'App `name` must match /^[a-zA-Z0-9_-]+$/')),\n /** Organization that owns the app — the workbench runs and deploys against it. */\n organizationId: z.string(\n \"App `organizationId` is required — pass the owning organization's ID to `unstable_defineApp`\",\n ),\n /** Sort position within the group, ascending. Defaults to `100` when omitted. */\n priority: z.optional(z.number()),\n /**\n * Background services the app runs (e.g. a `worker` emitting dock badges).\n * Metadata only — built into worker artifacts and persisted to the\n * application service on deploy, not into the app manifest. Service `name`s\n * must be unique within the app.\n */\n services: z.optional(\n z\n .array(ServiceDeclarationSchema)\n .check(\n z.refine(\n (services) => new Set(services.map((service) => service.name)).size === services.length,\n 'Service `name` must be unique within an app',\n ),\n ),\n ),\n /**\n * Hostname the application is created at on first deploy. Generated when\n * omitted; redeploys target `deployment.appId` and ignore it. SDK apps\n * only — studios use `studioHost` in sanity.cli.ts.\n */\n slug: z.optional(z.string()),\n /** User-facing app title. Wins over studio.config.ts title on merge. */\n title: z.string(),\n /**\n * Views the app exposes (e.g. dock panels). Metadata only — built into\n * render artifacts and persisted to the application service on deploy, not\n * into the app manifest. View `name`s must be unique within the app.\n */\n views: z.optional(\n z\n .array(InterfaceDeclarationSchema)\n .check(\n z.refine(\n (views) => new Set(views.map((view) => view.name)).size === views.length,\n 'View `name` must be unique within an app',\n ),\n ),\n ),\n })\n .check(\n // Studio app views are not implemented yet. A studio that declares `entry`\n // (the SDK app-view entrypoint) is rejected here rather than silently\n // generating one; studios keep navigating via their existing render path.\n z.refine((input) => !(input.applicationType === 'studio' && input.entry !== undefined), {\n error: 'App views for studios are not implemented yet',\n path: ['entry'],\n }),\n )\n .check(\n // An config belongs to a Sanity-owned singleton (the Media\n // Library). A non-singleton declaring one is rejected — see\n // {@link readConfig} for the runtime guard.\n z.refine((input) => !(input.config && !input.isSingleton), {\n error: '`config` is only supported for singleton apps',\n path: ['config'],\n }),\n )\n\n/**\n * User-facing input for `unstable_defineApp`. Excludes the internal\n * `applicationType`, `isSingleton`, and `config` — validated by the\n * schema but not part of the public surface (Sanity-owned apps set them via\n * `@ts-expect-error`).\n * @public\n */\nexport type DefineAppInput = Omit<\n z.output<typeof DefineAppInputSchema>,\n 'applicationType' | 'config' | 'isSingleton'\n>\n\n/**\n * Nominal brand the CLI discriminates on to enable the workbench build/deploy\n * codepath. Registered via `Symbol.for` so the marker survives module-realm\n * boundaries — `@sanity/cli-core` re-derives the same global symbol with\n * `Symbol.for` rather than importing it, so it stays internal to this module.\n */\nconst WORKBENCH_APP: unique symbol = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * The branded result of `unstable_defineApp`. Carries the same fields as the\n * input plus the internal brand — users only ever see `DefineAppInput`.\n * @public\n */\nexport interface DefineAppResult extends DefineAppInput {\n readonly [WORKBENCH_APP]: true\n}\n\n/**\n * A branded app as the CLI reads it — the full schema shape, including the\n * internal fields `DefineAppInput` omits. Schema-derived so the narrowing\n * can't drift from what the schema validates.\n * @public\n */\nexport type WorkbenchApp = DefineAppResult & z.output<typeof DefineAppInputSchema>\n\n/**\n * Whether `app` is a branded `unstable_defineApp(...)` result — the sole\n * workbench opt-in.\n * @public\n */\nexport function isWorkbenchApp(app: unknown): app is WorkbenchApp {\n return typeof app === 'object' && app !== null && WORKBENCH_APP in app\n}\n\n/**\n * The app's config, or `undefined` when it declares none. Throws\n * when a non-singleton declares one — configs belong to Sanity-owned singletons,\n * so build/dev/deploy all read it through here to reject the combination\n * consistently.\n * @internal\n */\nexport function readConfig(app: WorkbenchApp): WorkbenchApp['config'] | undefined {\n if (app.config && !app.isSingleton) {\n throw new Error('`config` is only supported for singleton apps')\n }\n return app.config\n}\n\n/**\n * Declare a Sanity Workbench application. Identity at runtime — returns the same\n * object reference, tagged with the workbench brand. Field validation (the\n * `name` pattern etc.) runs at build time in the CLI via `DefineAppInputSchema`;\n * this helper stays a thin, pure identity wrapper.\n * @public\n */\nexport function unstable_defineApp(input: DefineAppInput): DefineAppResult {\n return Object.defineProperty(input, WORKBENCH_APP, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n }) as DefineAppResult\n}\n\n/**\n * One custom field a media library exposes. `src` default-exports a `defineField(...)` schema type.\n * @public\n */\nexport interface MediaLibraryField {\n /** Unique within the media library. */\n name: string\n src: string\n title: string\n\n /** Readable outside the owning organization. */\n public?: boolean\n}\n\n/**\n * Sanity-owned singleton, so authors don't name or title the app — only `organizationId` is required.\n * @public\n */\nexport interface DefineMediaLibraryInput {\n /** Organization that owns the media library — the CLI runs and deploys against it. */\n organizationId: string\n\n fields?: MediaLibraryField[]\n}\n\n/**\n * Declare the Sanity Media Library as a workbench app — a singleton whose `fields` become its config.\n * @public\n */\nexport function unstable_defineMediaLibrary(input: DefineMediaLibraryInput): DefineAppResult {\n return unstable_defineApp({\n // @ts-expect-error -- `applicationType`/`isSingleton`/`config` are internal, excluded from `DefineAppInput`; Sanity-owned apps set them\n applicationType: 'media-library',\n config: input.fields?.length ? {appType: 'media-library', fields: input.fields} : undefined,\n isSingleton: true,\n name: 'media-library',\n organizationId: input.organizationId,\n title: 'Media Library',\n })\n}\n"],"names":["z","ConfigSchema","InterfaceDeclarationSchema","ServiceDeclarationSchema","APP_NAME_PATTERN","ApplicationType","enum","DockGroupSchema","DefineAppInputSchema","object","applicationType","optional","config","entry","string","group","icon","isSingleton","boolean","name","check","regex","organizationId","priority","number","services","array","refine","Set","map","service","size","length","slug","title","views","view","input","undefined","error","path","WORKBENCH_APP","Symbol","for","isWorkbenchApp","app","readConfig","Error","unstable_defineApp","Object","defineProperty","configurable","enumerable","value","writable","unstable_defineMediaLibrary","fields","appType"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B,SAAQC,YAAY,EAAEC,0BAA0B,EAAEC,wBAAwB,QAAO,gBAAe;AAEhG,0CAA0C,GAC1C,MAAMC,mBAAmB;AAEzB;;;CAGC,GACD,MAAMC,kBAAkBL,EAAEM,IAAI,CAAC;IAAC;IAAW;IAAU;IAAU;IAAa;CAAgB;AAE5F,8CAA8C,GAC9C,MAAMC,kBAAkBP,EAAEM,IAAI,CAAC;IAAC;IAAe;IAAqB;CAAY;AAUhF;;;;;CAKC,GACD,OAAO,MAAME,uBAAuBR,EACjCS,MAAM,CAAC;IACN;;;;KAIC,GACDC,iBAAiBV,EAAEW,QAAQ,CAACN;IAC5B;;;;;KAKC,GACDO,QAAQZ,EAAEW,QAAQ,CAACV;IACnB;;;;KAIC,GACDY,OAAOb,EAAEW,QAAQ,CAACX,EAAEc,MAAM;IA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4CAA4C;AAC5CpB,EAAE2B,MAAM,CAAC,CAACU,QAAU,CAAEA,CAAAA,MAAMzB,MAAM,IAAI,CAACyB,MAAMpB,WAAW,AAAD,GAAI;IACzDsB,OAAO;IACPC,MAAM;QAAC;KAAS;AAClB,IACD;AAcH;;;;;CAKC,GACD,MAAMC,gBAA+BC,OAAOC,GAAG,CAAC;AAmBhD;;;;CAIC,GACD,OAAO,SAASC,eAAeC,GAAY;IACzC,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,iBAAiBI;AACrE;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,WAAWD,GAAiB;IAC1C,IAAIA,IAAIjC,MAAM,IAAI,CAACiC,IAAI5B,WAAW,EAAE;QAClC,MAAM,IAAI8B,MAAM;IAClB;IACA,OAAOF,IAAIjC,MAAM;AACnB;AAEA;;;;;;CAMC,GACD,OAAO,SAASoC,mBAAmBX,KAAqB;IACtD,OAAOY,OAAOC,cAAc,CAACb,OAAOI,eAAe;QACjDU,cAAc;QACdC,YAAY;QACZC,OAAO;QACPC,UAAU;IACZ;AACF;AA2BA;;;CAGC,GACD,OAAO,SAASC,4BAA4BlB,KAA8B;IACxE,OAAOW,mBAAmB;QACxB,wIAAwI;QACxItC,iBAAiB;QACjBE,QAAQyB,MAAMmB,MAAM,EAAExB,SAAS;YAACyB,SAAS;YAAiBD,QAAQnB,MAAMmB,MAAM;QAAA,IAAIlB;QAClFrB,aAAa;QACbE,MAAM;QACNG,gBAAgBe,MAAMf,cAAc;QACpCY,OAAO;IACT;AACF"}
@@ -3,7 +3,7 @@
3
3
  // project. The build and deploy accessors (actions/build, actions/deploy) each
4
4
  // build their command-specific view on top of this one brand-check +
5
5
  // extraction, so the discrimination lives in exactly one place.
6
- import { isWorkbenchApp, readInstallationConfig } from './defineApp.js';
6
+ import { isWorkbenchApp, readConfig } from './defineApp.js';
7
7
  /**
8
8
  * Resolve the workbench app for a CLI config, or `null` for a plain project.
9
9
  * @public
@@ -12,11 +12,12 @@ import { isWorkbenchApp, readInstallationConfig } from './defineApp.js';
12
12
  if (!isWorkbenchApp(app)) return null;
13
13
  return {
14
14
  applicationType: app.applicationType,
15
+ config: readConfig(app),
15
16
  entry: app.entry,
16
- installationConfig: readInstallationConfig(app),
17
- isSingleton: app.isSingleton ?? false,
17
+ isSingleton: app.isSingleton,
18
18
  name: app.name,
19
19
  services: app.services ?? [],
20
+ slug: app.slug,
20
21
  views: app.views ?? []
21
22
  };
22
23
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resolveWorkbenchApp.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `unstable_defineApp` app into its declared interfaces, or `null` for a plain\n// project. The build and deploy accessors (actions/build, actions/deploy) each\n// 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 CliConfig} from '@sanity/cli-core'\n\nimport {\n type DefineAppInput,\n isWorkbenchApp,\n readInstallationConfig,\n type WorkbenchApp,\n} from './defineApp.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.\n * @internal\n */\nexport interface WorkbenchExposes {\n installationConfig?: WorkbenchApp['installationConfig']\n services?: DefineAppInput['services']\n views?: DefineAppInput['views']\n}\n\n/** @public */\nexport interface ResolvedWorkbenchApp {\n /** A Sanity-owned singleton (e.g. the Media Library) — deploys its config, not an application. */\n readonly isSingleton: boolean\n /** The app's unique `name` from `unstable_defineApp`. */\n readonly name: string\n /** Background worker services the app declares. */\n readonly services: NonNullable<DefineAppInput['services']>\n\n /** Dock panel views the app declares. */\n readonly views: NonNullable<DefineAppInput['views']>\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 /** Deploys on its own path, separate from the interfaces. */\n readonly installationConfig?: WorkbenchApp['installationConfig']\n}\n\n/**\n * Resolve the workbench app for a CLI config, or `null` for a plain project.\n * @public\n */\nexport function resolveWorkbenchApp(\n cliConfig: CliConfig | null | undefined,\n): ResolvedWorkbenchApp | null {\n const app = cliConfig?.app\n if (!isWorkbenchApp(app)) return null\n\n return {\n applicationType: app.applicationType,\n entry: app.entry,\n installationConfig: readInstallationConfig(app),\n isSingleton: app.isSingleton ?? false,\n name: app.name,\n services: app.services ?? [],\n views: app.views ?? [],\n }\n}\n"],"names":["isWorkbenchApp","readInstallationConfig","resolveWorkbenchApp","cliConfig","app","applicationType","entry","installationConfig","isSingleton","name","services","views"],"mappings":"AAAA,gEAAgE;AAChE,+EAA+E;AAC/E,+EAA+E;AAC/E,qEAAqE;AACrE,gEAAgE;AAIhE,SAEEA,cAAc,EACdC,sBAAsB,QAEjB,iBAAgB;AAiCvB;;;CAGC,GACD,OAAO,SAASC,oBACdC,SAAuC;IAEvC,MAAMC,MAAMD,WAAWC;IACvB,IAAI,CAACJ,eAAeI,MAAM,OAAO;IAEjC,OAAO;QACLC,iBAAiBD,IAAIC,eAAe;QACpCC,OAAOF,IAAIE,KAAK;QAChBC,oBAAoBN,uBAAuBG;QAC3CI,aAAaJ,IAAII,WAAW,IAAI;QAChCC,MAAML,IAAIK,IAAI;QACdC,UAAUN,IAAIM,QAAQ,IAAI,EAAE;QAC5BC,OAAOP,IAAIO,KAAK,IAAI,EAAE;IACxB;AACF"}
1
+ {"version":3,"sources":["../src/resolveWorkbenchApp.ts"],"sourcesContent":["// Package-internal shared resolver: turn a CLI config's branded\n// `unstable_defineApp` app into its declared interfaces, or `null` for a plain\n// project. The build and deploy accessors (actions/build, actions/deploy) each\n// 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 CliConfig} from '@sanity/cli-core'\n\nimport {type DefineAppInput, isWorkbenchApp, readConfig, type WorkbenchApp} from './defineApp.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.\n * @internal\n */\nexport interface WorkbenchExposes {\n config?: WorkbenchApp['config']\n services?: DefineAppInput['services']\n views?: DefineAppInput['views']\n}\n\n/** @public */\nexport interface ResolvedWorkbenchApp {\n /** The app's unique `name` from `unstable_defineApp`. */\n readonly name: string\n /** Background worker services the app declares. */\n readonly services: NonNullable<DefineAppInput['services']>\n\n /** Dock panel views the app declares. */\n readonly views: NonNullable<DefineAppInput['views']>\n\n /** Resolved app kind — `studio` or one of the SDK app types. */\n readonly applicationType?: string\n /** Deploys on its own path, separate from the interfaces. */\n readonly config?: WorkbenchApp['config']\n /** SDK app-view entrypoint, when declared. */\n readonly entry?: string\n /** Explicit singleton flag (a Sanity-owned app); `undefined` when the app doesn't set it. */\n readonly isSingleton?: boolean\n /** Hostname the application is created at on first deploy. */\n readonly slug?: string\n}\n\n/**\n * Resolve the workbench app for a CLI config, or `null` for a plain project.\n * @public\n */\nexport function resolveWorkbenchApp(\n cliConfig: CliConfig | null | undefined,\n): ResolvedWorkbenchApp | null {\n const app = cliConfig?.app\n if (!isWorkbenchApp(app)) return null\n\n return {\n applicationType: app.applicationType,\n config: readConfig(app),\n entry: app.entry,\n isSingleton: app.isSingleton,\n name: app.name,\n services: app.services ?? [],\n slug: app.slug,\n views: app.views ?? [],\n }\n}\n"],"names":["isWorkbenchApp","readConfig","resolveWorkbenchApp","cliConfig","app","applicationType","config","entry","isSingleton","name","services","slug","views"],"mappings":"AAAA,gEAAgE;AAChE,+EAA+E;AAC/E,+EAA+E;AAC/E,qEAAqE;AACrE,gEAAgE;AAIhE,SAA6BA,cAAc,EAAEC,UAAU,QAA0B,iBAAgB;AAmCjG;;;CAGC,GACD,OAAO,SAASC,oBACdC,SAAuC;IAEvC,MAAMC,MAAMD,WAAWC;IACvB,IAAI,CAACJ,eAAeI,MAAM,OAAO;IAEjC,OAAO;QACLC,iBAAiBD,IAAIC,eAAe;QACpCC,QAAQL,WAAWG;QACnBG,OAAOH,IAAIG,KAAK;QAChBC,aAAaJ,IAAII,WAAW;QAC5BC,MAAML,IAAIK,IAAI;QACdC,UAAUN,IAAIM,QAAQ,IAAI,EAAE;QAC5BC,MAAMP,IAAIO,IAAI;QACdC,OAAOR,IAAIQ,KAAK,IAAI,EAAE;IACxB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/workbench-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.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",
@@ -45,13 +45,13 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@module-federation/vite": "1.16.11",
48
+ "@module-federation/vite": "1.16.14",
49
49
  "@vitejs/plugin-react": "^6.0.3",
50
50
  "form-data": "^4.0.5",
51
51
  "tar-fs": "^3.1.2",
52
52
  "vite": "^8.1.3",
53
53
  "zod": "^4.4.3",
54
- "@sanity/cli-core": "^2.2.0"
54
+ "@sanity/cli-core": "^2.3.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@eslint/compat": "^2.1.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployInstallationConfig.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {PassThrough} from 'node:stream'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {getGlobalCliClient, type Output, subdebug} from '@sanity/cli-core'\nimport FormData from 'form-data'\nimport {pack} from 'tar-fs'\n\n// Brett's app-registry endpoints live behind the experimental `vX` version.\nconst INSTALLATIONS_API_VERSION = 'vX'\n\nconst debug = subdebug('deploy')\n\ninterface InstallationListItem {\n id: string\n\n application?: {slug?: string}\n}\n\n/**\n * The org's active installation for an app type, or `undefined` when none is\n * installed. Read-only, so `--dry-run` can report deployability.\n * @internal\n */\nexport async function resolveInstallationId(options: {\n appType: string\n organizationId: string\n}): Promise<string | undefined> {\n switch (options.appType) {\n case 'media-library': {\n return resolveSingletonInstallationId(options.organizationId, 'media-library')\n }\n default: {\n throw new Error(`Cannot create installation config for unknown app type: ${options.appType}`)\n }\n }\n}\n\n/**\n * A report heading and item list for a config; a media library's `fields` are\n * one of potentially many shapes.\n * @internal\n */\nexport function summarizeInstallationConfig(config: {\n appType: string\n fields: {name: string; title: string}[]\n}): string {\n switch (config.appType) {\n case 'media-library': {\n const items = config.fields.map((field) => ` ${field.title} (${field.name})`).join('\\n')\n return `Media library fields:\\n${items}`\n }\n default: {\n throw new Error(`Cannot create installation config for unknown app type: ${config.appType}`)\n }\n }\n}\n\n/**\n * Upload the built module-federation remote to the installation as its config\n * snapshot. `installationId` is resolved by the caller so `--dry-run` never\n * reaches this mutating step.\n * @internal\n */\nexport async function deployInstallationConfig(options: {\n appType: string\n installationId: string\n output: Output\n sourceDir: string\n version: string\n}): Promise<void> {\n const {appType, installationId, output, sourceDir, version} = options\n const tarball = pack(dirname(sourceDir), {entries: [basename(sourceDir)]}).pipe(createGzip())\n const formData = new FormData()\n formData.append('version', version)\n formData.append('tarball', tarball, {\n contentType: 'application/gzip',\n filename: 'installation-config.tar.gz',\n })\n\n const client = await getGlobalCliClient({\n apiVersion: INSTALLATIONS_API_VERSION,\n requireUser: true,\n })\n await client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n uri: `/installations/${installationId}/configs`,\n })\n\n debug('Deployed installation config for app type: %s', appType)\n output.log(`\\n🚀 ${styleText('bold', 'Success!')} Installation config deployed`)\n}\n\n/** The org's active singleton installation, matched on its slug. */\nasync function resolveSingletonInstallationId(\n organizationId: string,\n slug: string,\n): Promise<string | undefined> {\n const client = await getGlobalCliClient({\n apiVersion: INSTALLATIONS_API_VERSION,\n requireUser: true,\n })\n // `limit=none` returns every installation in one response, no pagination.\n const {data}: {data: InstallationListItem[]} = await client.request({\n query: {limit: 'none', organizationId},\n uri: '/installations',\n })\n return data.find((item) => item.application?.slug === slug)?.id\n}\n"],"names":["basename","dirname","PassThrough","styleText","createGzip","getGlobalCliClient","subdebug","FormData","pack","INSTALLATIONS_API_VERSION","debug","resolveInstallationId","options","appType","resolveSingletonInstallationId","organizationId","Error","summarizeInstallationConfig","config","items","fields","map","field","title","name","join","deployInstallationConfig","installationId","output","sourceDir","version","tarball","entries","pipe","formData","append","contentType","filename","client","apiVersion","requireUser","request","body","headers","getHeaders","method","uri","log","slug","data","query","limit","find","item","application","id"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,WAAW,QAAO,cAAa;AACvC,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAAQC,kBAAkB,EAAeC,QAAQ,QAAO,mBAAkB;AAC1E,OAAOC,cAAc,YAAW;AAChC,SAAQC,IAAI,QAAO,SAAQ;AAE3B,4EAA4E;AAC5E,MAAMC,4BAA4B;AAElC,MAAMC,QAAQJ,SAAS;AAQvB;;;;CAIC,GACD,OAAO,eAAeK,sBAAsBC,OAG3C;IACC,OAAQA,QAAQC,OAAO;QACrB,KAAK;YAAiB;gBACpB,OAAOC,+BAA+BF,QAAQG,cAAc,EAAE;YAChE;QACA;YAAS;gBACP,MAAM,IAAIC,MAAM,CAAC,wDAAwD,EAAEJ,QAAQC,OAAO,EAAE;YAC9F;IACF;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASI,4BAA4BC,MAG3C;IACC,OAAQA,OAAOL,OAAO;QACpB,KAAK;YAAiB;gBACpB,MAAMM,QAAQD,OAAOE,MAAM,CAACC,GAAG,CAAC,CAACC,QAAU,CAAC,EAAE,EAAEA,MAAMC,KAAK,CAAC,EAAE,EAAED,MAAME,IAAI,CAAC,CAAC,CAAC,EAAEC,IAAI,CAAC;gBACpF,OAAO,CAAC,uBAAuB,EAAEN,OAAO;YAC1C;QACA;YAAS;gBACP,MAAM,IAAIH,MAAM,CAAC,wDAAwD,EAAEE,OAAOL,OAAO,EAAE;YAC7F;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAea,yBAAy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