@elytracms/studio 0.0.79 → 0.0.81

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 (107) hide show
  1. package/convex/contract-parity.test.ts +1 -1
  2. package/convex/functions.ts +13 -3
  3. package/convex/http-routes.test.ts +143 -0
  4. package/convex/http.ts +19 -9
  5. package/convex/schema.ts +0 -19
  6. package/convex/users.ts +1 -1
  7. package/dist/components/app-views/default-modules.d.ts +141 -44
  8. package/dist/components/app-views/default-modules.js +229 -65
  9. package/dist/components/app-views/default-modules.js.map +1 -1
  10. package/dist/components/app-views/module.d.ts +38 -0
  11. package/dist/components/app-views/module.js.map +1 -1
  12. package/dist/components/app-views/sidebar.d.ts +5 -2
  13. package/dist/components/app-views/sidebar.js +16 -5
  14. package/dist/components/app-views/sidebar.js.map +1 -1
  15. package/dist/components/app-views/studio-config.d.ts +27 -0
  16. package/dist/components/app-views/studio-config.js.map +1 -1
  17. package/dist/components/builder/canvas-render-context.js +7 -1
  18. package/dist/components/builder/canvas-render-context.js.map +1 -1
  19. package/dist/components/builder/reuse-context.js +7 -1
  20. package/dist/components/builder/reuse-context.js.map +1 -1
  21. package/dist/components/builder/reuse.d.ts +94 -16
  22. package/dist/components/builder/reuse.js +201 -19
  23. package/dist/components/builder/reuse.js.map +1 -1
  24. package/dist/components/cms/bulk-actions.js +3 -1
  25. package/dist/components/cms/bulk-actions.js.map +1 -1
  26. package/dist/components/cms/cell-edit.js +6 -2
  27. package/dist/components/cms/cell-edit.js.map +1 -1
  28. package/dist/components/cms/cms-store.d.ts +40 -13
  29. package/dist/components/cms/cms-store.js +50 -22
  30. package/dist/components/cms/cms-store.js.map +1 -1
  31. package/dist/components/cms/collection-table.js +2 -2
  32. package/dist/components/cms/collection-table.js.map +1 -1
  33. package/dist/components/cms/date-input-core.d.ts +21 -0
  34. package/dist/components/cms/date-input-core.js +20 -0
  35. package/dist/components/cms/date-input-core.js.map +1 -1
  36. package/dist/components/cms/date-input.d.ts +9 -1
  37. package/dist/components/cms/date-input.js +2 -2
  38. package/dist/components/cms/date-input.js.map +1 -1
  39. package/dist/components/cms/detail-editor.js +11 -5
  40. package/dist/components/cms/detail-editor.js.map +1 -1
  41. package/dist/components/cms/editable-cell.js +2 -1
  42. package/dist/components/cms/editable-cell.js.map +1 -1
  43. package/dist/components/cms/field-control.js +4 -2
  44. package/dist/components/cms/field-control.js.map +1 -1
  45. package/dist/components/cms/field-renderer.js +8 -1
  46. package/dist/components/cms/field-renderer.js.map +1 -1
  47. package/dist/components/cms/import-export.js +2 -1
  48. package/dist/components/cms/import-export.js.map +1 -1
  49. package/dist/components/cms/issues-pane.d.ts +4 -2
  50. package/dist/components/cms/issues-pane.js +6 -4
  51. package/dist/components/cms/issues-pane.js.map +1 -1
  52. package/dist/components/cms/scalar-value-editor.js +2 -1
  53. package/dist/components/cms/scalar-value-editor.js.map +1 -1
  54. package/dist/components/components/transfer-dialog.js +10 -12
  55. package/dist/components/components/transfer-dialog.js.map +1 -1
  56. package/dist/components/project-list.d.ts +9 -3
  57. package/dist/components/project-list.js +11 -5
  58. package/dist/components/project-list.js.map +1 -1
  59. package/dist/components/project-switcher.d.ts +3 -1
  60. package/dist/components/project-switcher.js +4 -2
  61. package/dist/components/project-switcher.js.map +1 -1
  62. package/dist/components/redirects/redirects-store.d.ts +21 -0
  63. package/dist/components/redirects/redirects-store.js +17 -4
  64. package/dist/components/redirects/redirects-store.js.map +1 -1
  65. package/dist/components/section-nav.js +102 -4
  66. package/dist/components/section-nav.js.map +1 -1
  67. package/dist/customization.d.ts +7 -0
  68. package/dist/customization.js.map +1 -1
  69. package/dist/lib/data/collection-content.d.ts +6 -1
  70. package/dist/lib/data/collection-content.js +50 -12
  71. package/dist/lib/data/collection-content.js.map +1 -1
  72. package/dist/lib/i18n/messages.de.js +132 -0
  73. package/dist/lib/i18n/messages.de.js.map +1 -1
  74. package/dist/lib/i18n/messages.en.d.ts +103 -0
  75. package/dist/lib/i18n/messages.en.js +146 -0
  76. package/dist/lib/i18n/messages.en.js.map +1 -1
  77. package/dist/lib/locale/binding-fallback.d.ts +8 -1
  78. package/dist/lib/locale/binding-fallback.js +8 -1
  79. package/dist/lib/locale/binding-fallback.js.map +1 -1
  80. package/dist/lib/locale/locale-store.d.ts +41 -9
  81. package/dist/lib/locale/locale-store.js +34 -15
  82. package/dist/lib/locale/locale-store.js.map +1 -1
  83. package/dist/lib/locale/locale-switcher.d.ts +3 -1
  84. package/dist/lib/locale/locale-switcher.js +4 -2
  85. package/dist/lib/locale/locale-switcher.js.map +1 -1
  86. package/dist/lib/locale/use-studio-locale.d.ts +9 -4
  87. package/dist/lib/locale/use-studio-locale.js.map +1 -1
  88. package/dist/lib/persistence/convex-adapter.d.ts +1 -3
  89. package/dist/lib/persistence/convex-adapter.js +0 -55
  90. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  91. package/dist/lib/persona/labels.d.ts +42 -1
  92. package/dist/lib/persona/labels.js +57 -0
  93. package/dist/lib/persona/labels.js.map +1 -1
  94. package/dist/lib/routes/route-issues.d.ts +9 -0
  95. package/dist/lib/routes/route-issues.js +117 -0
  96. package/dist/lib/routes/route-issues.js.map +1 -0
  97. package/dist/lib/workspace/config-issues.d.ts +54 -0
  98. package/dist/lib/workspace/config-issues.js +70 -0
  99. package/dist/lib/workspace/config-issues.js.map +1 -0
  100. package/dist/lib/workspace/index.d.ts +9 -0
  101. package/dist/lib/workspace/index.js +11 -0
  102. package/dist/lib/workspace/index.js.map +1 -1
  103. package/dist/lib/workspace/switcher-source.d.ts +20 -3
  104. package/dist/lib/workspace/switcher-source.js.map +1 -1
  105. package/package.json +2 -2
  106. package/convex/cliTokens.ts +0 -63
  107. package/convex/sync.ts +0 -297
@@ -0,0 +1,117 @@
1
+ import { createRouter, isHierarchyTemplate, routeReachabilityIssues } from '@elytracms/core/cms-core';
2
+ /**
3
+ * The studio's URL-map validation (EC-469) — the pure core.
4
+ *
5
+ * `createRouter` has always computed structural issues (**route conflicts** and
6
+ * **redirect loops**) and, before this, no studio surface showed them. The delivery
7
+ * content client exposes them as `routerIssues`, but that path never reaches the
8
+ * studio: its only producer, the Convex `createContent` kit, has no studio caller —
9
+ * it serves the delivery host. So the studio computes them from the two inputs it
10
+ * already holds, which is also the only way it can: routes come from config
11
+ * (`resolveDeploymentRoutes`), redirects come from the editorial rail.
12
+ *
13
+ * This is NOT a revived Routes view (EC-303 retired that, correctly — routes are
14
+ * code). It is validation of the code + data the studio already reads.
15
+ *
16
+ * **Fidelity is the whole point**, so both of delivery's input rules are applied
17
+ * here, not approximated:
18
+ *
19
+ * - **Hierarchy mounts are filtered out** (`content/client.ts` does exactly this
20
+ * before constructing its router). A mount (`/:path*`, EC-218) is resolved
21
+ * per-request against the parent chain, not by the router. Counting it as a route
22
+ * makes `/:slug` + `/:path*` look like a conflict — measured — which the runtime
23
+ * does not consider one. A false alarm here would be worse than no alarm: it would
24
+ * teach developers to ignore the surface.
25
+ * - **Only ENABLED redirects count** (the Convex content kit filters `row.enabled`).
26
+ * `enabled` is the switch for *pausing* a redirect, so a paused chain is not live
27
+ * and must not be reported as a loop.
28
+ *
29
+ * `unknown-route-target` is deliberately NOT produced by the ROUTER here. Despite the
30
+ * ticket's framing it is not a router issue: the *resolver* raises it per resolved URL
31
+ * against the documents that exist (`content/client.ts`), so it needs a URL and a
32
+ * document pool, neither of which a project-level check has.
33
+ *
34
+ * ## Unreachable declarations (EC-484)
35
+ *
36
+ * Beside the two router codes, this reports declarations that serve NOTHING —
37
+ * measured, previously silent everywhere: an all-dynamic route (`/:slug`) matching
38
+ * every URL at a depth a hierarchy mount serves; and a catch-all with a dynamic prefix
39
+ * (`/:lang/:path*`), which every router drops and no mount is built from.
40
+ *
41
+ * **EC-488 narrowed the first one.** It used to mean the mount's root pages 404 though
42
+ * they exist in the studio; the resolver now falls through to the mounts when a matched
43
+ * route resolves no document, so those pages serve and the finding is a `warning` about
44
+ * content-decided precedence (a page whose composed path collides with the route
45
+ * collection's slug is still silently shadowed). The severity comes from the shared
46
+ * `routeReachabilityIssues`, so this surface tracks it without a change here.
47
+ *
48
+ * This one belongs in the studio, unlike the mount-vs-mount conflicts EC-482 left to
49
+ * `elytra doctor`, because of who meets the symptom: a 404 on a page the editor can
50
+ * see in the studio is what an editor reports and a developer cannot reproduce from a
51
+ * document. Naming it at the rail foot turns "the About page is broken" into a route
52
+ * id. It is also not a new precedent — this function has surfaced the code-side
53
+ * `route-conflict` since EC-469.
54
+ *
55
+ * The COLLECTION-dependent half of EC-484 (a mount whose collection has no `parent`
56
+ * self-relation, so it can never compose a path) is not here: this core is given
57
+ * routes and redirects, and `elytra doctor` — which loads the collections anyway —
58
+ * reports it at build time, where a developer fixes it.
59
+ */
60
+ /**
61
+ * Collapse the several reports of ONE redirect cycle into one finding.
62
+ *
63
+ * `createRouter` walks every redirect and reports a loop per distinct loop *entry
64
+ * point* (`routes.ts`, EC-020) — correct for a machine, but a 2-hop cycle then reads
65
+ * as two separate bugs at the rail foot, and fixing one makes both vanish. Every
66
+ * rotation of a cycle visits the same set of paths, so the sorted member set is a
67
+ * stable identity for the cycle: dedupe on it, keep the first, and two genuinely
68
+ * different cycles still report separately. Presentation only — nothing is hidden, and
69
+ * `createRouter`'s shared behaviour is untouched.
70
+ */
71
+ function collapseLoops(issues) {
72
+ const seen = new Set();
73
+ const out = [];
74
+ for (const issue of issues) {
75
+ if (issue.code !== 'redirect-loop') {
76
+ out.push(issue);
77
+ continue;
78
+ }
79
+ const chain = issue.meta?.chain;
80
+ const key = Array.isArray(chain)
81
+ ? [...new Set(chain.map(String))].sort().join('|')
82
+ : issue.path.join('/');
83
+ if (seen.has(key))
84
+ continue;
85
+ seen.add(key);
86
+ out.push(issue);
87
+ }
88
+ return out;
89
+ }
90
+ /** Project the stored editorial records onto the routing shape delivery resolves. */
91
+ function liveRedirects(redirects) {
92
+ return redirects
93
+ .filter((entry) => entry.enabled)
94
+ .map((entry) => ({
95
+ id: entry.id,
96
+ from: entry.from,
97
+ to: entry.to,
98
+ permanent: entry.permanent,
99
+ }));
100
+ }
101
+ /**
102
+ * The project's structural URL-map issues: route conflicts (from config routes),
103
+ * redirect loops (from the enabled editorial redirects), and declarations that cannot
104
+ * serve content at all (EC-484). Pure and total — it never throws, and an empty result
105
+ * means "no structural problem", not "not checked".
106
+ */
107
+ export function routeValidationIssues(routes, redirects = []) {
108
+ const routable = routes.filter((route) => !isHierarchyTemplate(route));
109
+ return [
110
+ ...collapseLoops(createRouter(routable, liveRedirects(redirects)).issues),
111
+ // Routes only: the reachability checks that need the collection set stay with
112
+ // `elytra doctor`, which has it. Passing no collections is the documented way to
113
+ // ask for exactly the route-side half.
114
+ ...routeReachabilityIssues(routes),
115
+ ];
116
+ }
117
+ //# sourceMappingURL=route-issues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-issues.js","sourceRoot":"","sources":["../../../src/lib/routes/route-issues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAIrG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;;;;;;;;GAUG;AACH,SAAS,aAAa,CAAC,MAAqC;IAC1D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,GAAG,GAAyB,EAAE,CAAA;IACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YACnC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACf,SAAQ;QACV,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,CAAA;QAC/B,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAC9B,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;YAClD,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACxB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAQ;QAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACb,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACjB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,qFAAqF;AACrF,SAAS,aAAa,CAAC,SAAmC;IACxD,OAAO,SAAS;SACb,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;SAChC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACf,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC,CAAC,CAAA;AACP,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA8B,EAC9B,YAAsC,EAAE;IAExC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAA;IACtE,OAAO;QACL,GAAG,aAAa,CAAC,YAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;QACzE,8EAA8E;QAC9E,iFAAiF;QACjF,uCAAuC;QACvC,GAAG,uBAAuB,CAAC,MAAM,CAAC;KACnC,CAAA;AACH,CAAC","sourcesContent":["import { createRouter, isHierarchyTemplate, routeReachabilityIssues } from '@elytracms/core/cms-core'\nimport type { CmsValidationIssue, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core'\nimport type { RedirectEntry } from '@elytracms/core/persistence'\n\n/**\n * The studio's URL-map validation (EC-469) — the pure core.\n *\n * `createRouter` has always computed structural issues (**route conflicts** and\n * **redirect loops**) and, before this, no studio surface showed them. The delivery\n * content client exposes them as `routerIssues`, but that path never reaches the\n * studio: its only producer, the Convex `createContent` kit, has no studio caller —\n * it serves the delivery host. So the studio computes them from the two inputs it\n * already holds, which is also the only way it can: routes come from config\n * (`resolveDeploymentRoutes`), redirects come from the editorial rail.\n *\n * This is NOT a revived Routes view (EC-303 retired that, correctly — routes are\n * code). It is validation of the code + data the studio already reads.\n *\n * **Fidelity is the whole point**, so both of delivery's input rules are applied\n * here, not approximated:\n *\n * - **Hierarchy mounts are filtered out** (`content/client.ts` does exactly this\n * before constructing its router). A mount (`/:path*`, EC-218) is resolved\n * per-request against the parent chain, not by the router. Counting it as a route\n * makes `/:slug` + `/:path*` look like a conflict — measured — which the runtime\n * does not consider one. A false alarm here would be worse than no alarm: it would\n * teach developers to ignore the surface.\n * - **Only ENABLED redirects count** (the Convex content kit filters `row.enabled`).\n * `enabled` is the switch for *pausing* a redirect, so a paused chain is not live\n * and must not be reported as a loop.\n *\n * `unknown-route-target` is deliberately NOT produced by the ROUTER here. Despite the\n * ticket's framing it is not a router issue: the *resolver* raises it per resolved URL\n * against the documents that exist (`content/client.ts`), so it needs a URL and a\n * document pool, neither of which a project-level check has.\n *\n * ## Unreachable declarations (EC-484)\n *\n * Beside the two router codes, this reports declarations that serve NOTHING —\n * measured, previously silent everywhere: an all-dynamic route (`/:slug`) matching\n * every URL at a depth a hierarchy mount serves; and a catch-all with a dynamic prefix\n * (`/:lang/:path*`), which every router drops and no mount is built from.\n *\n * **EC-488 narrowed the first one.** It used to mean the mount's root pages 404 though\n * they exist in the studio; the resolver now falls through to the mounts when a matched\n * route resolves no document, so those pages serve and the finding is a `warning` about\n * content-decided precedence (a page whose composed path collides with the route\n * collection's slug is still silently shadowed). The severity comes from the shared\n * `routeReachabilityIssues`, so this surface tracks it without a change here.\n *\n * This one belongs in the studio, unlike the mount-vs-mount conflicts EC-482 left to\n * `elytra doctor`, because of who meets the symptom: a 404 on a page the editor can\n * see in the studio is what an editor reports and a developer cannot reproduce from a\n * document. Naming it at the rail foot turns \"the About page is broken\" into a route\n * id. It is also not a new precedent — this function has surfaced the code-side\n * `route-conflict` since EC-469.\n *\n * The COLLECTION-dependent half of EC-484 (a mount whose collection has no `parent`\n * self-relation, so it can never compose a path) is not here: this core is given\n * routes and redirects, and `elytra doctor` — which loads the collections anyway —\n * reports it at build time, where a developer fixes it.\n */\n\n/**\n * Collapse the several reports of ONE redirect cycle into one finding.\n *\n * `createRouter` walks every redirect and reports a loop per distinct loop *entry\n * point* (`routes.ts`, EC-020) — correct for a machine, but a 2-hop cycle then reads\n * as two separate bugs at the rail foot, and fixing one makes both vanish. Every\n * rotation of a cycle visits the same set of paths, so the sorted member set is a\n * stable identity for the cycle: dedupe on it, keep the first, and two genuinely\n * different cycles still report separately. Presentation only — nothing is hidden, and\n * `createRouter`'s shared behaviour is untouched.\n */\nfunction collapseLoops(issues: readonly CmsValidationIssue[]): CmsValidationIssue[] {\n const seen = new Set<string>()\n const out: CmsValidationIssue[] = []\n for (const issue of issues) {\n if (issue.code !== 'redirect-loop') {\n out.push(issue)\n continue\n }\n const chain = issue.meta?.chain\n const key = Array.isArray(chain)\n ? [...new Set(chain.map(String))].sort().join('|')\n : issue.path.join('/')\n if (seen.has(key)) continue\n seen.add(key)\n out.push(issue)\n }\n return out\n}\n\n/** Project the stored editorial records onto the routing shape delivery resolves. */\nfunction liveRedirects(redirects: readonly RedirectEntry[]): RedirectRecord[] {\n return redirects\n .filter((entry) => entry.enabled)\n .map((entry) => ({\n id: entry.id,\n from: entry.from,\n to: entry.to,\n permanent: entry.permanent,\n }))\n}\n\n/**\n * The project's structural URL-map issues: route conflicts (from config routes),\n * redirect loops (from the enabled editorial redirects), and declarations that cannot\n * serve content at all (EC-484). Pure and total — it never throws, and an empty result\n * means \"no structural problem\", not \"not checked\".\n */\nexport function routeValidationIssues(\n routes: readonly RouteRecord[],\n redirects: readonly RedirectEntry[] = [],\n): readonly CmsValidationIssue[] {\n const routable = routes.filter((route) => !isHierarchyTemplate(route))\n return [\n ...collapseLoops(createRouter(routable, liveRedirects(redirects)).issues),\n // Routes only: the reachability checks that need the collection set stay with\n // `elytra doctor`, which has it. Passing no collections is the documented way to\n // ask for exactly the route-side half.\n ...routeReachabilityIssues(routes),\n ]\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { CollectionDef } from '@elytracms/core/cms-core';
2
+ import type { CustomizationIssue } from '@elytracms/core/studio-core';
3
+ /**
4
+ * EC-479 — project-level configuration findings for the section-rail foot.
5
+ *
6
+ * The engine used to fill a missing declaration with its own `cms-core` fixtures:
7
+ * `?? sampleFilterableCollections` in the CMS store, `?? sampleDocuments` beside
8
+ * it, `?? sampleLocaleConfig` in the locale store. A studio whose config never
9
+ * arrived therefore looked *configured* — it showed six documents about Ada
10
+ * Lovelace under a four-collection schema, in `en/de`, none of which the project
11
+ * had declared. The owner's ruling (2026-07-30): "fixtures should only show in the
12
+ * playground, but not be hard-wired in the engine".
13
+ *
14
+ * With the fallbacks retired the same state renders as an empty CMS, which on its
15
+ * own is the OTHER silent failure — the house rule bans both ("if you are writing
16
+ * a fallback that hides a broken state, that *is* the bug"). This module is the
17
+ * third option: say so, at the rail foot, where EC-467's reuse issues and EC-469's
18
+ * URL-map issues already report project-level problems, on every studio surface.
19
+ *
20
+ * Pure and deterministic — no config-holder reads, no React. The caller supplies
21
+ * the resolved config (`resolveDeploymentCollections()`), which is also what makes
22
+ * this testable against a synthetic project instead of the live one.
23
+ */
24
+ /**
25
+ * The extension-point name stamped on these issues. Not a customization registry
26
+ * like `'sidebar'`/`'fieldRenderers'` — the finding is about the project's own
27
+ * declarations, so it locates the config, not an override list.
28
+ */
29
+ export declare const PROJECT_CONFIG_POINT = "project";
30
+ /**
31
+ * Catalog keys for the issues below (EC-478). Named here, next to the producer, so
32
+ * the studio's i18n parity test asserts coverage against the producer rather than a
33
+ * hand-copied list — the same shape as `default-modules.tsx`'s `KEYSPACE_KEYS`.
34
+ */
35
+ export declare const PROJECT_CONFIG_ISSUE_KEYS: {
36
+ readonly noCollections: "customization.issue.noCollections";
37
+ };
38
+ /**
39
+ * Report what the project has NOT declared but the studio cannot work without.
40
+ *
41
+ * Today that is exactly one thing: collections. A studio with none has no content
42
+ * model at all — the CMS rail expands to nothing, every list is empty, and before
43
+ * EC-479 the store quietly substituted the engine's sample schema so none of that
44
+ * was visible. The remedy is one line in `elytra.config.ts`, which is why the
45
+ * message names the file.
46
+ *
47
+ * Deliberately NOT reported here: an absent locale config. A `Project` only exists
48
+ * for a config-declared project and `resolveWorkspaceConfig` gives every one of
49
+ * them a `locales` array, so "no locales" is unreachable from the rail's vantage
50
+ * point; the CMS session guards it directly instead (`CmsProvider`), where it is
51
+ * both reachable and actionable. Reporting an unreachable state would be copy
52
+ * nobody can trigger — see the task file's found-but-left note on that default.
53
+ */
54
+ export declare function projectConfigIssues(collections: readonly CollectionDef[]): CustomizationIssue[];
@@ -0,0 +1,70 @@
1
+ /**
2
+ * EC-479 — project-level configuration findings for the section-rail foot.
3
+ *
4
+ * The engine used to fill a missing declaration with its own `cms-core` fixtures:
5
+ * `?? sampleFilterableCollections` in the CMS store, `?? sampleDocuments` beside
6
+ * it, `?? sampleLocaleConfig` in the locale store. A studio whose config never
7
+ * arrived therefore looked *configured* — it showed six documents about Ada
8
+ * Lovelace under a four-collection schema, in `en/de`, none of which the project
9
+ * had declared. The owner's ruling (2026-07-30): "fixtures should only show in the
10
+ * playground, but not be hard-wired in the engine".
11
+ *
12
+ * With the fallbacks retired the same state renders as an empty CMS, which on its
13
+ * own is the OTHER silent failure — the house rule bans both ("if you are writing
14
+ * a fallback that hides a broken state, that *is* the bug"). This module is the
15
+ * third option: say so, at the rail foot, where EC-467's reuse issues and EC-469's
16
+ * URL-map issues already report project-level problems, on every studio surface.
17
+ *
18
+ * Pure and deterministic — no config-holder reads, no React. The caller supplies
19
+ * the resolved config (`resolveDeploymentCollections()`), which is also what makes
20
+ * this testable against a synthetic project instead of the live one.
21
+ */
22
+ /**
23
+ * The extension-point name stamped on these issues. Not a customization registry
24
+ * like `'sidebar'`/`'fieldRenderers'` — the finding is about the project's own
25
+ * declarations, so it locates the config, not an override list.
26
+ */
27
+ export const PROJECT_CONFIG_POINT = 'project';
28
+ /** The file a developer fixes these findings in — interpolated, never localized. */
29
+ const CONFIG_FILE = 'elytra.config.ts';
30
+ /**
31
+ * Catalog keys for the issues below (EC-478). Named here, next to the producer, so
32
+ * the studio's i18n parity test asserts coverage against the producer rather than a
33
+ * hand-copied list — the same shape as `default-modules.tsx`'s `KEYSPACE_KEYS`.
34
+ */
35
+ export const PROJECT_CONFIG_ISSUE_KEYS = {
36
+ noCollections: 'customization.issue.noCollections',
37
+ };
38
+ /**
39
+ * Report what the project has NOT declared but the studio cannot work without.
40
+ *
41
+ * Today that is exactly one thing: collections. A studio with none has no content
42
+ * model at all — the CMS rail expands to nothing, every list is empty, and before
43
+ * EC-479 the store quietly substituted the engine's sample schema so none of that
44
+ * was visible. The remedy is one line in `elytra.config.ts`, which is why the
45
+ * message names the file.
46
+ *
47
+ * Deliberately NOT reported here: an absent locale config. A `Project` only exists
48
+ * for a config-declared project and `resolveWorkspaceConfig` gives every one of
49
+ * them a `locales` array, so "no locales" is unreachable from the rail's vantage
50
+ * point; the CMS session guards it directly instead (`CmsProvider`), where it is
51
+ * both reachable and actionable. Reporting an unreachable state would be copy
52
+ * nobody can trigger — see the task file's found-but-left note on that default.
53
+ */
54
+ export function projectConfigIssues(collections) {
55
+ if (collections.length > 0)
56
+ return [];
57
+ return [
58
+ {
59
+ code: 'missing-configuration',
60
+ severity: 'error',
61
+ message: `This project declares no content collections. Add them to "${CONFIG_FILE}" — the studio shows your schema or none, never sample content.`,
62
+ messageRef: {
63
+ key: PROJECT_CONFIG_ISSUE_KEYS.noCollections,
64
+ vars: { file: CONFIG_FILE },
65
+ },
66
+ point: PROJECT_CONFIG_POINT,
67
+ },
68
+ ];
69
+ }
70
+ //# sourceMappingURL=config-issues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-issues.js","sourceRoot":"","sources":["../../../src/lib/workspace/config-issues.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAA;AAE7C,oFAAoF;AACpF,MAAM,WAAW,GAAG,kBAAkB,CAAA;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,aAAa,EAAE,mCAAmC;CAC1C,CAAA;AAEV;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAAqC;IAErC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAA;IACrC,OAAO;QACL;YACE,IAAI,EAAE,uBAAuB;YAC7B,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,8DAA8D,WAAW,iEAAiE;YACnJ,UAAU,EAAE;gBACV,GAAG,EAAE,yBAAyB,CAAC,aAAa;gBAC5C,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;aAC5B;YACD,KAAK,EAAE,oBAAoB;SAC5B;KACF,CAAA;AACH,CAAC","sourcesContent":["import type { CollectionDef } from '@elytracms/core/cms-core'\nimport type { CustomizationIssue } from '@elytracms/core/studio-core'\n\n/**\n * EC-479 — project-level configuration findings for the section-rail foot.\n *\n * The engine used to fill a missing declaration with its own `cms-core` fixtures:\n * `?? sampleFilterableCollections` in the CMS store, `?? sampleDocuments` beside\n * it, `?? sampleLocaleConfig` in the locale store. A studio whose config never\n * arrived therefore looked *configured* — it showed six documents about Ada\n * Lovelace under a four-collection schema, in `en/de`, none of which the project\n * had declared. The owner's ruling (2026-07-30): \"fixtures should only show in the\n * playground, but not be hard-wired in the engine\".\n *\n * With the fallbacks retired the same state renders as an empty CMS, which on its\n * own is the OTHER silent failure — the house rule bans both (\"if you are writing\n * a fallback that hides a broken state, that *is* the bug\"). This module is the\n * third option: say so, at the rail foot, where EC-467's reuse issues and EC-469's\n * URL-map issues already report project-level problems, on every studio surface.\n *\n * Pure and deterministic — no config-holder reads, no React. The caller supplies\n * the resolved config (`resolveDeploymentCollections()`), which is also what makes\n * this testable against a synthetic project instead of the live one.\n */\n\n/**\n * The extension-point name stamped on these issues. Not a customization registry\n * like `'sidebar'`/`'fieldRenderers'` — the finding is about the project's own\n * declarations, so it locates the config, not an override list.\n */\nexport const PROJECT_CONFIG_POINT = 'project'\n\n/** The file a developer fixes these findings in — interpolated, never localized. */\nconst CONFIG_FILE = 'elytra.config.ts'\n\n/**\n * Catalog keys for the issues below (EC-478). Named here, next to the producer, so\n * the studio's i18n parity test asserts coverage against the producer rather than a\n * hand-copied list — the same shape as `default-modules.tsx`'s `KEYSPACE_KEYS`.\n */\nexport const PROJECT_CONFIG_ISSUE_KEYS = {\n noCollections: 'customization.issue.noCollections',\n} as const\n\n/**\n * Report what the project has NOT declared but the studio cannot work without.\n *\n * Today that is exactly one thing: collections. A studio with none has no content\n * model at all — the CMS rail expands to nothing, every list is empty, and before\n * EC-479 the store quietly substituted the engine's sample schema so none of that\n * was visible. The remedy is one line in `elytra.config.ts`, which is why the\n * message names the file.\n *\n * Deliberately NOT reported here: an absent locale config. A `Project` only exists\n * for a config-declared project and `resolveWorkspaceConfig` gives every one of\n * them a `locales` array, so \"no locales\" is unreachable from the rail's vantage\n * point; the CMS session guards it directly instead (`CmsProvider`), where it is\n * both reachable and actionable. Reporting an unreachable state would be copy\n * nobody can trigger — see the task file's found-but-left note on that default.\n */\nexport function projectConfigIssues(\n collections: readonly CollectionDef[],\n): CustomizationIssue[] {\n if (collections.length > 0) return []\n return [\n {\n code: 'missing-configuration',\n severity: 'error',\n message: `This project declares no content collections. Add them to \"${CONFIG_FILE}\" — the studio shows your schema or none, never sample content.`,\n messageRef: {\n key: PROJECT_CONFIG_ISSUE_KEYS.noCollections,\n vars: { file: CONFIG_FILE },\n },\n point: PROJECT_CONFIG_POINT,\n },\n ]\n}\n"]}
@@ -4,6 +4,7 @@ import type { SidebarNode } from '../../components/app-views/module.js';
4
4
  import type { CustomFieldRenderer, StudioConfig } from '../../components/app-views/studio-config.js';
5
5
  import type { GeneratedPreviewLookup } from '../../components/builder/blocks-model.js';
6
6
  import type { WorkspaceState } from './workspace-source.js';
7
+ export { PROJECT_CONFIG_ISSUE_KEYS, PROJECT_CONFIG_POINT, projectConfigIssues, } from './config-issues.js';
7
8
  export { resolveWorkspaceState } from './workspace-source.js';
8
9
  export type { WorkspaceSources, WorkspaceState } from './workspace-source.js';
9
10
  export { isSingleProjectWorkspace, launcherAutoForwardTarget, persistedProjects, selectSwitcherProjects, soleWorkspaceProject, unprovisionedProjects, } from './switcher-source.js';
@@ -145,6 +146,14 @@ export declare function resolveDeploymentSidebar(): SidebarNode[] | undefined;
145
146
  * body, kit `tokensCss` only). Studio-wide, like the rail and field renderers.
146
147
  */
147
148
  export declare function resolveDeploymentCanvasTheme(): StudioConfig['canvas'];
149
+ /**
150
+ * The reusable-elements declaration from the studio config (EC-467): WHICH
151
+ * component is the project's reuse embed. Studio-only (from `defineStudio`, never
152
+ * the delivery bundle); `undefined` when none — the studio then INFERS the embed
153
+ * from the manifests + collections exactly as it always has (absence means infer,
154
+ * not off). Studio-wide, like the rail and field renderers.
155
+ */
156
+ export declare function resolveDeploymentReuse(): StudioConfig['reuse'];
148
157
  /**
149
158
  * The resolved URL routes of the active config project (EC-207, "routes as
150
159
  * code"). Routes are config-sourced: the studio reads the materialized
@@ -1,6 +1,7 @@
1
1
  import { frontendUrlForEnvironment } from '@elytracms/core/studio-core';
2
2
  import { provideStudioEnv } from '../persistence/backend-mode.js';
3
3
  import { resolveWorkspaceState } from './workspace-source.js';
4
+ export { PROJECT_CONFIG_ISSUE_KEYS, PROJECT_CONFIG_POINT, projectConfigIssues, } from './config-issues.js';
4
5
  export { resolveWorkspaceState } from './workspace-source.js';
5
6
  export { isSingleProjectWorkspace, launcherAutoForwardTarget, persistedProjects, selectSwitcherProjects, soleWorkspaceProject, unprovisionedProjects, } from './switcher-source.js';
6
7
  let cached = null;
@@ -217,6 +218,16 @@ export function resolveDeploymentSidebar() {
217
218
  export function resolveDeploymentCanvasTheme() {
218
219
  return studioConfig?.canvas;
219
220
  }
221
+ /**
222
+ * The reusable-elements declaration from the studio config (EC-467): WHICH
223
+ * component is the project's reuse embed. Studio-only (from `defineStudio`, never
224
+ * the delivery bundle); `undefined` when none — the studio then INFERS the embed
225
+ * from the manifests + collections exactly as it always has (absence means infer,
226
+ * not off). Studio-wide, like the rail and field renderers.
227
+ */
228
+ export function resolveDeploymentReuse() {
229
+ return studioConfig?.reuse;
230
+ }
220
231
  /**
221
232
  * The resolved URL routes of the active config project (EC-207, "routes as
222
233
  * code"). Routes are config-sourced: the studio reads the materialized
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/workspace/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAUvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAG1B,IAAI,MAAM,GAA0B,IAAI,CAAA;AACxC,IAAI,YAAY,GAAwB,IAAI,CAAA;AA8B5C,MAAM,UAAU,YAAY,CAC1B,MAAyB,EACzB,MAAqB,EACrB,OAA4B;IAE5B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC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,OAAO,mBAAmB,EAAE,EAAE,UAAU,CAAA;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACvE,OAAO,yBAAyB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AAC1D,CAAC","sourcesContent":["import { frontendUrlForEnvironment } from '@elytracms/core/studio-core'\nimport type {\n BreakpointConfig,\n ElytraConfigInput,\n ResolvedWorkspaceProject,\n} from '@elytracms/core/studio-core'\nimport type { CollectionDef, LocaleConfig, RouteRecord } from '@elytracms/core/cms-core'\nimport type { SidebarNode } from '../../components/app-views/module'\nimport type { CustomFieldRenderer, StudioConfig } from '../../components/app-views/studio-config'\nimport type { GeneratedPreviewLookup } from '../../components/builder/blocks-model'\nimport { provideStudioEnv } from '../persistence/backend-mode'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport { resolveWorkspaceState } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport {\n isSingleProjectWorkspace,\n launcherAutoForwardTarget,\n persistedProjects,\n selectSwitcherProjects,\n soleWorkspaceProject,\n unprovisionedProjects,\n} from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\nlet studioConfig: StudioConfig | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract) and an\n * optional studio-only customization config (EC-236). The consumer's entry point\n * does `import config from './elytra.config'` + `import studio from\n * './studio.config'` and calls this — an explicit init, NOT an `import.meta.glob`\n * autoload that reaches into the consumer's filesystem (Oli, 2026-06-19: \"there's\n * always an entry point that can trigger a function call\").\n *\n * Two configs, deliberately: `config` (`elytra.config.ts`) is the project\n * definition, shared with the `frontend/` delivery bundle and projected to data;\n * `studio` (`studio.config.tsx` via `defineStudio`) is live builder UI code — the\n * section rail, custom field renderers, branding — that must NEVER reach delivery.\n * Keeping them separate is the customization boundary principle in the mount\n * signature. Seeds the workspace state + the studio-config holder every later\n * query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n *\n * EC-357 — `options.env`: the consumer's `import.meta.env`, captured HERE because\n * the entry module is code Vite always transforms live. The engine's own\n * `import.meta.env` reads are unreliable inside dep-optimized package code (Vite ≥8\n * omits custom `VITE_*` values there; Vite 7 froze them at optimize time), which\n * silently broke backend URL / mode / dev-login resolution in real consumers.\n * Always pass it: `createStudio(config, studioConfig, { env: import.meta.env })`.\n */\nexport interface StudioMountOptions {\n /** The consumer entry's `import.meta.env` (see `provideStudioEnv` for the contract). */\n env?: Record<string, unknown>\n}\n\nexport function createStudio(\n config: ElytraConfigInput,\n studio?: StudioConfig,\n options?: StudioMountOptions,\n): void {\n provideStudioEnv(options?.env)\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\n studioConfig = studio ?? null\n}\n\n/** Test seam: set/clear the studio customization config. Never used by app code. */\nexport function setStudioConfigForTests(next: StudioConfig | null): void {\n studioConfig = next\n}\n\n/**\n * The active project slug (EC-179, vision AD-8). One project per backend, so the\n * active project selects which Convex deployment the studio talks to. The root\n * layout sets this from the URL (`/<slug>`) — or, on the sign-in screen, from\n * the `redirect` target's slug — before the auth/persistence adapters are\n * selected, so the *initial* sign-in authenticates against the project the user\n * is heading for (Sanity-style: authenticate to one workspace, then the full\n * config-based switcher is available). `null` at the launcher → the default\n * (first) configured project's deployment.\n */\nlet activeProjectSlug: string | null = null\n\n/** Set the active project slug; returns whether the resolved deployment changed. */\nexport function setActiveProjectSlug(slug: string | null): boolean {\n const before = resolveDeploymentUrl('')\n activeProjectSlug = slug && slug.trim() !== '' ? slug : null\n return resolveDeploymentUrl('') !== before\n}\n\nexport function getActiveProjectSlug(): string | null {\n return activeProjectSlug\n}\n\n/** Test seam: reset the active project slug. Never used by app code. */\nexport function setActiveProjectSlugForTests(slug: string | null): void {\n activeProjectSlug = slug\n}\n\n/**\n * Reserved first-path segments that are NOT project slugs: the studio's own\n * root routes (EC-220). Project surfaces now live at `/<slug>/...` (no `/p/`\n * prefix), so the studio's root namespace is shared between project slugs and\n * these fixed routes — they must be excluded from slug extraction. Keep in\n * sync with the non-`$projectId` files in `src/routes/`; the launcher (`/`) is\n * the empty segment, excluded by the regex requiring one path char.\n */\nconst RESERVED_ROOT_SEGMENTS: ReadonlySet<string> = new Set(['sign-in', 'styleguide'])\n\n/** Extract a project slug from a studio path (`/<slug>/...`), else `null`. */\nexport function projectSlugFromPath(pathname: string): string | null {\n const match = /^\\/([^/?#]+)/.exec(pathname)\n if (!match) return null\n const segment = decodeURIComponent(match[1]!)\n return RESERVED_ROOT_SEGMENTS.has(segment) ? null : segment\n}\n\n/**\n * The project whose backend the studio should bind for a given location\n * (EC-179). A project path (`/<slug>`) binds that project; the sign-in screen\n * binds the project from its `redirect` target so the *initial* sign-in\n * authenticates against the backend the user is heading for (Sanity-style).\n * Anywhere else (the launcher) → `null`, i.e. the default/first project.\n */\nexport function activeSlugForLocation(pathname: string, redirect?: string): string | null {\n const direct = projectSlugFromPath(pathname)\n if (direct) return direct\n if (pathname === '/sign-in' && redirect) return projectSlugFromPath(redirect)\n return null\n}\n\n/** The active config project (by slug), or the first configured project. */\nfunction activeConfigProject() {\n const state = getWorkspaceState()\n if (state.kind !== 'config') return undefined\n if (activeProjectSlug) {\n const match = state.projects.find((p) => p.slug === activeProjectSlug)\n if (match) return match\n }\n return state.projects[0]\n}\n\n/**\n * The studio's resolved workspace state. Deterministic per boot: the config is\n * static input (bundled file or deployment env), so it is resolved once and\n * cached — every consumer (gate, switcher, launcher) sees the same state.\n */\nexport function getWorkspaceState(): WorkspaceState {\n // Seeded by `createStudio(config)` at the entry point. Until then — or when the\n // consumer wires no config — resolve to the empty `none` state (the single-project\n // golden path), rather than reaching for the filesystem.\n if (!cached) cached = resolveWorkspaceState({})\n return cached\n}\n\n/** Test seam: clear/replace the cached state. Never used by app code. */\nexport function setWorkspaceStateForTests(next: WorkspaceState | null): void {\n cached = next\n}\n\n/**\n * Resolve the Convex deployment URL the studio should connect to (vision AD-8:\n * the backend is wired in config). One project per backend, so the **active**\n * project (see {@link setActiveProjectSlug}) selects the deployment via its\n * `convex.deployment` (or its production environment's). At the launcher (no\n * active project) the first configured project is the default backend. Absent\n * config — or a project without a wired deployment — falls back to\n * `VITE_CONVEX_URL` (`fallbackUrl`) for local single-deployment development.\n */\nexport function resolveDeploymentUrl(fallbackUrl: string): string {\n return projectDeploymentUrl(activeConfigProject(), fallbackUrl)\n}\n\n/** The deployment URL for a specific project slug (per-backend auth checks). */\nexport function deploymentUrlForSlug(slug: string, fallbackUrl: string): string {\n const state = getWorkspaceState()\n const project = state.kind === 'config' ? state.projects.find((p) => p.slug === slug) : undefined\n return projectDeploymentUrl(project, fallbackUrl)\n}\n\n/** A project's wired deployment: per-environment ref → project ref → env fallback. */\nfunction projectDeploymentUrl(\n project: ResolvedWorkspaceProject | undefined,\n fallbackUrl: string,\n): string {\n if (!project) return fallbackUrl\n const envDeployment = project.environments.find((e) => e.convex?.deployment)?.convex?.deployment\n return envDeployment ?? project.convex?.deployment ?? fallbackUrl\n}\n\n/**\n * The slug of the project bound to the active deployment (EC-179). One project\n * per backend, so the active config project's slug identifies the deployment's\n * one project; the Convex adapter stamps it onto deployment-scoped records.\n * Absent config falls back to `fallbackId` (used only when wired by env alone).\n */\nexport function resolveDeploymentProjectId(fallbackId: string): string {\n return activeConfigProject()?.slug ?? fallbackId\n}\n\n/**\n * The CMS collections of the active config project (AD-11, EC-183). CMS\n * collection schemas are config-owned: the studio reads the model from\n * `elytra.config.ts` (served through the persistence port — the backend has no\n * `cmsSchemas` table). `[]` when the active project declares none, or when the\n * studio is wired by env alone with no config.\n */\nexport function resolveDeploymentCollections(): CollectionDef[] {\n return activeConfigProject()?.collections ?? []\n}\n\n/**\n * The canvas preview breakpoints of the active config project (EC-250).\n * Config-sourced (config-as-code, derived from the site's Tailwind `screens`);\n * `undefined` when the project declares none — the canvas then falls back to\n * Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.\n */\nexport function resolveDeploymentBreakpoints(): BreakpointConfig[] | undefined {\n return activeConfigProject()?.breakpoints\n}\n\n/**\n * The custom field renderers from the studio config (EC-238): control name →\n * component. Studio-only live code (from `defineStudio`, never the project schema\n * or the delivery bundle); `undefined` when none — the document editor then uses\n * its built-in control for every field. Studio-wide (not per-project): the rail and\n * renderers customize the studio, not one backend.\n */\nexport function resolveDeploymentFieldRenderers(): Record<string, CustomFieldRenderer> | undefined {\n return studioConfig?.fieldRenderers\n}\n\n/**\n * The studio-UI localization config from the studio config (EC-241): the default\n * locale + imported translation catalogs. Studio-only live code (from `defineStudio`,\n * never the project schema or the delivery bundle); `undefined` when none — the\n * studio then renders its built-in English chrome. Studio-wide, like the rail and\n * field renderers (localizes the studio, not one backend).\n */\nexport function resolveDeploymentI18n(): StudioConfig['i18n'] {\n return studioConfig?.i18n\n}\n\n/**\n * The AI platform config from the studio config (EC-331): provider, knowledge, and\n * limits. Studio-only live code (from `defineStudio`, never the delivery bundle);\n * `undefined` when no `ai` block is configured — the feature is then fully absent\n * (the AI subsystem never boots, so `@elytracms/studio/lib/ai`'s runtime — and the\n * `ai`/`@ai-sdk/*` SDK behind it — is never imported). Studio-wide, like the rail\n * and field renderers.\n */\nexport function resolveDeploymentAi(): StudioConfig['ai'] {\n return studioConfig?.ai\n}\n\n/**\n * The generated-preview lookup from the studio config (EC-439 AD-2, the seam\n * EC-440 fills): a pure `componentId + fixtureName → URL` function the blocks\n * panel threads into its tile model. Studio-only live code (from `defineStudio`,\n * never the delivery bundle); `undefined` when none — tiles then fall back from\n * a curated `manifest.previewImage` straight to the icon+name placeholder.\n * Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentGeneratedPreviews(): GeneratedPreviewLookup | undefined {\n return studioConfig?.previews?.generated\n}\n\n/**\n * The configurable section rail from the studio config (EC-237): an ordered list of\n * `nav.*` nodes (views / groups / separators). Studio-only live code (carries view\n * objects + icons); `undefined` when none — the studio then derives the default\n * rail from its built-in views. Invalid entries surface as visible issues at\n * resolution, never silent.\n */\nexport function resolveDeploymentSidebar(): SidebarNode[] | undefined {\n return studioConfig?.sidebar\n}\n\n/**\n * The canvas page-surface theme from the studio config (EC-389): body classes +\n * raw CSS for the preview iframe, so the canvas wears the SITE's chrome. Studio-only\n * (from `defineStudio`, never the delivery bundle); `undefined` when none — the\n * canvas keeps its built-in defaults (`bg-background text-foreground font-sans`\n * body, kit `tokensCss` only). Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentCanvasTheme(): StudioConfig['canvas'] {\n return studioConfig?.canvas\n}\n\n/**\n * The resolved URL routes of the active config project (EC-207, \"routes as\n * code\"). Routes are config-sourced: the studio reads the materialized\n * `RouteRecord[]` from the active `elytra.config.ts` project — never from the\n * backend (the `routes` system collection is retired). The Routes surface and\n * the per-page URL preview both read through here. `[]` when the active project\n * declares none, or when the studio is wired by env alone with no config.\n */\nexport function resolveDeploymentRoutes(): RouteRecord[] {\n return activeConfigProject()?.routes ?? []\n}\n\n// Redirects are editorial DATA now (EC-303), managed in the studio Redirects rail\n// and served dynamically — no longer resolved from config. `resolveDeploymentRedirects`\n// is retired; static/infra redirects are the dev's job via native next.config/vercel.\n\n/**\n * The configured locales of the active config project (AD-8). The same locale\n * set the host stamps onto its per-locale cache tags — used by the revalidation\n * webhook layer (EC-192) so a publish always invalidates EVERY configured locale\n * (e.g. `/de`, `/fr`), never just the default. `[]` when wired by env alone.\n */\nexport function resolveDeploymentLocales(): string[] {\n return activeConfigProject()?.locales ?? []\n}\n\n/**\n * The active config project's locales as a `LocaleConfig` (EC-357 finding #3).\n * Locales are structure and structure is code: when `elytra.config.ts` declares\n * them, they drive the studio's ambient locale switcher in EVERY mode — the CMS\n * surface must not fall back to the sample `en/de` fixture (playground, or a\n * connected first run with nothing persisted) when the config says otherwise.\n * `undefined` when no config project is active or it declares no locales (env-only\n * wiring keeps the existing kit/sample fallbacks). A missing/invalid explicit\n * default falls back to the first declared locale.\n */\nexport function resolveDeploymentLocaleConfig(): LocaleConfig | undefined {\n const project = activeConfigProject()\n if (!project || project.locales.length === 0) return undefined\n const fallback = project.locales[0]!\n const explicit = project.defaultLocale\n return {\n default: explicit && project.locales.includes(explicit) ? explicit : fallback,\n locales: [...project.locales],\n }\n}\n\n/**\n * The active project's components reference (EC-194, AD-11): where the consuming\n * repo's OWN real components live (`{ package }` or `{ dir }`). When set, the\n * studio registry composes with the repo's components instead of the built-in\n * demo fixtures — so the page builder edits the repo's actual component library.\n * `undefined` → the project ships no code components; the studio falls back to the\n * golden-path fixtures.\n */\nexport function resolveDeploymentComponents() {\n return activeConfigProject()?.components\n}\n\n/**\n * The active project's public site URL (EC-215): the live site's base URL the\n * studio links to (a document's live URL + open-live button, EC-216). Resolved\n * in lockstep with {@link resolveDeploymentUrl} — the environment bound to the\n * active deployment (the first with a wired deployment) provides the URL, falling\n * back to the project-level `frontendUrl`. No active-environment selector exists\n * yet, so the bound environment is the active one. `undefined` when the active\n * project (or env-only wiring) configures no frontend URL.\n */\nexport function resolveDeploymentFrontendUrl(): string | undefined {\n const project = activeConfigProject()\n if (!project) return undefined\n const boundEnv = project.environments.find((e) => e.convex?.deployment)\n return frontendUrlForEnvironment(project, boundEnv?.key)\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/workspace/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAUvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAG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A6B;IAC3C,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAE,CAAA;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAA;IACtC,OAAO;QACL,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;QAC7E,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;KAC9B,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,mBAAmB,EAAE,EAAE,UAAU,CAAA;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACvE,OAAO,yBAAyB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AAC1D,CAAC","sourcesContent":["import { frontendUrlForEnvironment } from '@elytracms/core/studio-core'\nimport type {\n BreakpointConfig,\n ElytraConfigInput,\n ResolvedWorkspaceProject,\n} from '@elytracms/core/studio-core'\nimport type { CollectionDef, LocaleConfig, RouteRecord } from '@elytracms/core/cms-core'\nimport type { SidebarNode } from '../../components/app-views/module'\nimport type { CustomFieldRenderer, StudioConfig } from '../../components/app-views/studio-config'\nimport type { GeneratedPreviewLookup } from '../../components/builder/blocks-model'\nimport { provideStudioEnv } from '../persistence/backend-mode'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport {\n PROJECT_CONFIG_ISSUE_KEYS,\n PROJECT_CONFIG_POINT,\n projectConfigIssues,\n} from './config-issues'\nexport { resolveWorkspaceState } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport {\n isSingleProjectWorkspace,\n launcherAutoForwardTarget,\n persistedProjects,\n selectSwitcherProjects,\n soleWorkspaceProject,\n unprovisionedProjects,\n} from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\nlet studioConfig: StudioConfig | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract) and an\n * optional studio-only customization config (EC-236). The consumer's entry point\n * does `import config from './elytra.config'` + `import studio from\n * './studio.config'` and calls this — an explicit init, NOT an `import.meta.glob`\n * autoload that reaches into the consumer's filesystem (Oli, 2026-06-19: \"there's\n * always an entry point that can trigger a function call\").\n *\n * Two configs, deliberately: `config` (`elytra.config.ts`) is the project\n * definition, shared with the `frontend/` delivery bundle and projected to data;\n * `studio` (`studio.config.tsx` via `defineStudio`) is live builder UI code — the\n * section rail, custom field renderers, branding — that must NEVER reach delivery.\n * Keeping them separate is the customization boundary principle in the mount\n * signature. Seeds the workspace state + the studio-config holder every later\n * query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n *\n * EC-357 — `options.env`: the consumer's `import.meta.env`, captured HERE because\n * the entry module is code Vite always transforms live. The engine's own\n * `import.meta.env` reads are unreliable inside dep-optimized package code (Vite ≥8\n * omits custom `VITE_*` values there; Vite 7 froze them at optimize time), which\n * silently broke backend URL / mode / dev-login resolution in real consumers.\n * Always pass it: `createStudio(config, studioConfig, { env: import.meta.env })`.\n */\nexport interface StudioMountOptions {\n /** The consumer entry's `import.meta.env` (see `provideStudioEnv` for the contract). */\n env?: Record<string, unknown>\n}\n\nexport function createStudio(\n config: ElytraConfigInput,\n studio?: StudioConfig,\n options?: StudioMountOptions,\n): void {\n provideStudioEnv(options?.env)\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\n studioConfig = studio ?? null\n}\n\n/** Test seam: set/clear the studio customization config. Never used by app code. */\nexport function setStudioConfigForTests(next: StudioConfig | null): void {\n studioConfig = next\n}\n\n/**\n * The active project slug (EC-179, vision AD-8). One project per backend, so the\n * active project selects which Convex deployment the studio talks to. The root\n * layout sets this from the URL (`/<slug>`) — or, on the sign-in screen, from\n * the `redirect` target's slug — before the auth/persistence adapters are\n * selected, so the *initial* sign-in authenticates against the project the user\n * is heading for (Sanity-style: authenticate to one workspace, then the full\n * config-based switcher is available). `null` at the launcher → the default\n * (first) configured project's deployment.\n */\nlet activeProjectSlug: string | null = null\n\n/** Set the active project slug; returns whether the resolved deployment changed. */\nexport function setActiveProjectSlug(slug: string | null): boolean {\n const before = resolveDeploymentUrl('')\n activeProjectSlug = slug && slug.trim() !== '' ? slug : null\n return resolveDeploymentUrl('') !== before\n}\n\nexport function getActiveProjectSlug(): string | null {\n return activeProjectSlug\n}\n\n/** Test seam: reset the active project slug. Never used by app code. */\nexport function setActiveProjectSlugForTests(slug: string | null): void {\n activeProjectSlug = slug\n}\n\n/**\n * Reserved first-path segments that are NOT project slugs: the studio's own\n * root routes (EC-220). Project surfaces now live at `/<slug>/...` (no `/p/`\n * prefix), so the studio's root namespace is shared between project slugs and\n * these fixed routes — they must be excluded from slug extraction. Keep in\n * sync with the non-`$projectId` files in `src/routes/`; the launcher (`/`) is\n * the empty segment, excluded by the regex requiring one path char.\n */\nconst RESERVED_ROOT_SEGMENTS: ReadonlySet<string> = new Set(['sign-in', 'styleguide'])\n\n/** Extract a project slug from a studio path (`/<slug>/...`), else `null`. */\nexport function projectSlugFromPath(pathname: string): string | null {\n const match = /^\\/([^/?#]+)/.exec(pathname)\n if (!match) return null\n const segment = decodeURIComponent(match[1]!)\n return RESERVED_ROOT_SEGMENTS.has(segment) ? null : segment\n}\n\n/**\n * The project whose backend the studio should bind for a given location\n * (EC-179). A project path (`/<slug>`) binds that project; the sign-in screen\n * binds the project from its `redirect` target so the *initial* sign-in\n * authenticates against the backend the user is heading for (Sanity-style).\n * Anywhere else (the launcher) → `null`, i.e. the default/first project.\n */\nexport function activeSlugForLocation(pathname: string, redirect?: string): string | null {\n const direct = projectSlugFromPath(pathname)\n if (direct) return direct\n if (pathname === '/sign-in' && redirect) return projectSlugFromPath(redirect)\n return null\n}\n\n/** The active config project (by slug), or the first configured project. */\nfunction activeConfigProject() {\n const state = getWorkspaceState()\n if (state.kind !== 'config') return undefined\n if (activeProjectSlug) {\n const match = state.projects.find((p) => p.slug === activeProjectSlug)\n if (match) return match\n }\n return state.projects[0]\n}\n\n/**\n * The studio's resolved workspace state. Deterministic per boot: the config is\n * static input (bundled file or deployment env), so it is resolved once and\n * cached — every consumer (gate, switcher, launcher) sees the same state.\n */\nexport function getWorkspaceState(): WorkspaceState {\n // Seeded by `createStudio(config)` at the entry point. Until then — or when the\n // consumer wires no config — resolve to the empty `none` state (the single-project\n // golden path), rather than reaching for the filesystem.\n if (!cached) cached = resolveWorkspaceState({})\n return cached\n}\n\n/** Test seam: clear/replace the cached state. Never used by app code. */\nexport function setWorkspaceStateForTests(next: WorkspaceState | null): void {\n cached = next\n}\n\n/**\n * Resolve the Convex deployment URL the studio should connect to (vision AD-8:\n * the backend is wired in config). One project per backend, so the **active**\n * project (see {@link setActiveProjectSlug}) selects the deployment via its\n * `convex.deployment` (or its production environment's). At the launcher (no\n * active project) the first configured project is the default backend. Absent\n * config — or a project without a wired deployment — falls back to\n * `VITE_CONVEX_URL` (`fallbackUrl`) for local single-deployment development.\n */\nexport function resolveDeploymentUrl(fallbackUrl: string): string {\n return projectDeploymentUrl(activeConfigProject(), fallbackUrl)\n}\n\n/** The deployment URL for a specific project slug (per-backend auth checks). */\nexport function deploymentUrlForSlug(slug: string, fallbackUrl: string): string {\n const state = getWorkspaceState()\n const project = state.kind === 'config' ? state.projects.find((p) => p.slug === slug) : undefined\n return projectDeploymentUrl(project, fallbackUrl)\n}\n\n/** A project's wired deployment: per-environment ref → project ref → env fallback. */\nfunction projectDeploymentUrl(\n project: ResolvedWorkspaceProject | undefined,\n fallbackUrl: string,\n): string {\n if (!project) return fallbackUrl\n const envDeployment = project.environments.find((e) => e.convex?.deployment)?.convex?.deployment\n return envDeployment ?? project.convex?.deployment ?? fallbackUrl\n}\n\n/**\n * The slug of the project bound to the active deployment (EC-179). One project\n * per backend, so the active config project's slug identifies the deployment's\n * one project; the Convex adapter stamps it onto deployment-scoped records.\n * Absent config falls back to `fallbackId` (used only when wired by env alone).\n */\nexport function resolveDeploymentProjectId(fallbackId: string): string {\n return activeConfigProject()?.slug ?? fallbackId\n}\n\n/**\n * The CMS collections of the active config project (AD-11, EC-183). CMS\n * collection schemas are config-owned: the studio reads the model from\n * `elytra.config.ts` (served through the persistence port — the backend has no\n * `cmsSchemas` table). `[]` when the active project declares none, or when the\n * studio is wired by env alone with no config.\n */\nexport function resolveDeploymentCollections(): CollectionDef[] {\n return activeConfigProject()?.collections ?? []\n}\n\n/**\n * The canvas preview breakpoints of the active config project (EC-250).\n * Config-sourced (config-as-code, derived from the site's Tailwind `screens`);\n * `undefined` when the project declares none — the canvas then falls back to\n * Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.\n */\nexport function resolveDeploymentBreakpoints(): BreakpointConfig[] | undefined {\n return activeConfigProject()?.breakpoints\n}\n\n/**\n * The custom field renderers from the studio config (EC-238): control name →\n * component. Studio-only live code (from `defineStudio`, never the project schema\n * or the delivery bundle); `undefined` when none — the document editor then uses\n * its built-in control for every field. Studio-wide (not per-project): the rail and\n * renderers customize the studio, not one backend.\n */\nexport function resolveDeploymentFieldRenderers(): Record<string, CustomFieldRenderer> | undefined {\n return studioConfig?.fieldRenderers\n}\n\n/**\n * The studio-UI localization config from the studio config (EC-241): the default\n * locale + imported translation catalogs. Studio-only live code (from `defineStudio`,\n * never the project schema or the delivery bundle); `undefined` when none — the\n * studio then renders its built-in English chrome. Studio-wide, like the rail and\n * field renderers (localizes the studio, not one backend).\n */\nexport function resolveDeploymentI18n(): StudioConfig['i18n'] {\n return studioConfig?.i18n\n}\n\n/**\n * The AI platform config from the studio config (EC-331): provider, knowledge, and\n * limits. Studio-only live code (from `defineStudio`, never the delivery bundle);\n * `undefined` when no `ai` block is configured — the feature is then fully absent\n * (the AI subsystem never boots, so `@elytracms/studio/lib/ai`'s runtime — and the\n * `ai`/`@ai-sdk/*` SDK behind it — is never imported). Studio-wide, like the rail\n * and field renderers.\n */\nexport function resolveDeploymentAi(): StudioConfig['ai'] {\n return studioConfig?.ai\n}\n\n/**\n * The generated-preview lookup from the studio config (EC-439 AD-2, the seam\n * EC-440 fills): a pure `componentId + fixtureName → URL` function the blocks\n * panel threads into its tile model. Studio-only live code (from `defineStudio`,\n * never the delivery bundle); `undefined` when none — tiles then fall back from\n * a curated `manifest.previewImage` straight to the icon+name placeholder.\n * Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentGeneratedPreviews(): GeneratedPreviewLookup | undefined {\n return studioConfig?.previews?.generated\n}\n\n/**\n * The configurable section rail from the studio config (EC-237): an ordered list of\n * `nav.*` nodes (views / groups / separators). Studio-only live code (carries view\n * objects + icons); `undefined` when none — the studio then derives the default\n * rail from its built-in views. Invalid entries surface as visible issues at\n * resolution, never silent.\n */\nexport function resolveDeploymentSidebar(): SidebarNode[] | undefined {\n return studioConfig?.sidebar\n}\n\n/**\n * The canvas page-surface theme from the studio config (EC-389): body classes +\n * raw CSS for the preview iframe, so the canvas wears the SITE's chrome. Studio-only\n * (from `defineStudio`, never the delivery bundle); `undefined` when none — the\n * canvas keeps its built-in defaults (`bg-background text-foreground font-sans`\n * body, kit `tokensCss` only). Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentCanvasTheme(): StudioConfig['canvas'] {\n return studioConfig?.canvas\n}\n\n/**\n * The reusable-elements declaration from the studio config (EC-467): WHICH\n * component is the project's reuse embed. Studio-only (from `defineStudio`, never\n * the delivery bundle); `undefined` when none — the studio then INFERS the embed\n * from the manifests + collections exactly as it always has (absence means infer,\n * not off). Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentReuse(): StudioConfig['reuse'] {\n return studioConfig?.reuse\n}\n\n/**\n * The resolved URL routes of the active config project (EC-207, \"routes as\n * code\"). Routes are config-sourced: the studio reads the materialized\n * `RouteRecord[]` from the active `elytra.config.ts` project — never from the\n * backend (the `routes` system collection is retired). The Routes surface and\n * the per-page URL preview both read through here. `[]` when the active project\n * declares none, or when the studio is wired by env alone with no config.\n */\nexport function resolveDeploymentRoutes(): RouteRecord[] {\n return activeConfigProject()?.routes ?? []\n}\n\n// Redirects are editorial DATA now (EC-303), managed in the studio Redirects rail\n// and served dynamically — no longer resolved from config. `resolveDeploymentRedirects`\n// is retired; static/infra redirects are the dev's job via native next.config/vercel.\n\n/**\n * The configured locales of the active config project (AD-8). The same locale\n * set the host stamps onto its per-locale cache tags — used by the revalidation\n * webhook layer (EC-192) so a publish always invalidates EVERY configured locale\n * (e.g. `/de`, `/fr`), never just the default. `[]` when wired by env alone.\n */\nexport function resolveDeploymentLocales(): string[] {\n return activeConfigProject()?.locales ?? []\n}\n\n/**\n * The active config project's locales as a `LocaleConfig` (EC-357 finding #3).\n * Locales are structure and structure is code: when `elytra.config.ts` declares\n * them, they drive the studio's ambient locale switcher in EVERY mode — the CMS\n * surface must not fall back to the sample `en/de` fixture (playground, or a\n * connected first run with nothing persisted) when the config says otherwise.\n * `undefined` when no config project is active or it declares no locales (env-only\n * wiring keeps the existing kit/sample fallbacks). A missing/invalid explicit\n * default falls back to the first declared locale.\n */\nexport function resolveDeploymentLocaleConfig(): LocaleConfig | undefined {\n const project = activeConfigProject()\n if (!project || project.locales.length === 0) return undefined\n const fallback = project.locales[0]!\n const explicit = project.defaultLocale\n return {\n default: explicit && project.locales.includes(explicit) ? explicit : fallback,\n locales: [...project.locales],\n }\n}\n\n/**\n * The active project's components reference (EC-194, AD-11): where the consuming\n * repo's OWN real components live (`{ package }` or `{ dir }`). When set, the\n * studio registry composes with the repo's components instead of the built-in\n * demo fixtures — so the page builder edits the repo's actual component library.\n * `undefined` → the project ships no code components; the studio falls back to the\n * golden-path fixtures.\n */\nexport function resolveDeploymentComponents() {\n return activeConfigProject()?.components\n}\n\n/**\n * The active project's public site URL (EC-215): the live site's base URL the\n * studio links to (a document's live URL + open-live button, EC-216). Resolved\n * in lockstep with {@link resolveDeploymentUrl} — the environment bound to the\n * active deployment (the first with a wired deployment) provides the URL, falling\n * back to the project-level `frontendUrl`. No active-environment selector exists\n * yet, so the bound environment is the active one. `undefined` when the active\n * project (or env-only wiring) configures no frontend URL.\n */\nexport function resolveDeploymentFrontendUrl(): string | undefined {\n const project = activeConfigProject()\n if (!project) return undefined\n const boundEnv = project.environments.find((e) => e.convex?.deployment)\n return frontendUrlForEnvironment(project, boundEnv?.key)\n}\n"]}
@@ -9,9 +9,26 @@ import type { WorkspaceState } from './workspace-source.js';
9
9
  * projects, untouched (single-project golden path).
10
10
  * - **Config present** → every configured project, in config order, as a
11
11
  * navigable entry; one that has no persisted counterpart yet is an explicit
12
- * `unprovisioned` state ("run `builder init --project <slug>`") rather than an
13
- * error. Persisted projects *not* in the config are not listed: the config is
14
- * the source of truth for what this workspace is.
12
+ * `unprovisioned` state ("run `elytra init`") rather than an error. Persisted
13
+ * projects *not* in the config are not listed: the config is the source of
14
+ * truth for what this workspace is.
15
+ *
16
+ * ## The `unprovisioned` branch is currently unreachable FROM THE STUDIO (EC-470)
17
+ *
18
+ * This function will happily produce `unprovisioned` — `switcher-source.test.ts`
19
+ * covers it directly. But the live studio can no longer feed it inputs that do:
20
+ * `studio-context.tsx`'s `configProjects()` derives `persisted` from the SAME
21
+ * `workspace.projects` array this function iterates (via `configProject`, which
22
+ * sets `slug` from the config entry), so the `bySlug` lookup below always hits.
23
+ * Under AD-8 project identity became config-owned, and "provisioned" stopped
24
+ * being a per-project row the studio could miss — it is now a property of the
25
+ * DEPLOYMENT (see `DeploymentSetupGate` / `elytra doctor`).
26
+ *
27
+ * Left in place deliberately rather than removed: the entry kind is load-bearing
28
+ * for the EC-401 single-project predicates below (`soleWorkspaceProject` treats a
29
+ * lone unprovisioned entry as "do not auto-forward"), so retiring it is a
30
+ * separate, owner-sized decision — not a docs sweep. Recorded so the next reader
31
+ * does not mistake it for live UI.
15
32
  *
16
33
  * Visibility is **not** filtered by membership. One project per backend (vision
17
34
  * AD-8): a configured project lives on its own deployment, so the *active*
@@ -1 +1 @@
1
- {"version":3,"file":"switcher-source.js","sourceRoot":"","sources":["../../../src/lib/workspace/switcher-source.ts"],"names":[],"mappings":"AAkCA,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,wEAAwE;QACxE,yEAAyE;QACzE,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACjF,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7C,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzC,OAAO,SAAS;YACd,CAAC,CAAC,EAAE,IAAI,EAAE,SAAkB,EAAE,OAAO,EAAE,SAAS,EAAE;YAClD,CAAC,CAAC,EAAE,IAAI,EAAE,eAAwB,EAAE,MAAM,EAAE,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACtF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAiC;IACpE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;IACtB,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAiC;IACxE,OAAO,oBAAoB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAMzC;IACC,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CACnC,OAAiC;IAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import type { Project } from '@elytracms/core/studio-core'\nimport type { ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport type { WorkspaceState } from './workspace-source'\n\n/**\n * Config-driven switcher source (EC-154, reframed for EC-179 per-backend\n * projects). Pure logic deciding what the project switcher and launcher list:\n *\n * - **No workspace config** → exactly today's behavior: the adapter-listed\n * projects, untouched (single-project golden path).\n * - **Config present** → every configured project, in config order, as a\n * navigable entry; one that has no persisted counterpart yet is an explicit\n * `unprovisioned` state (\"run `builder init --project <slug>`\") rather than an\n * error. Persisted projects *not* in the config are not listed: the config is\n * the source of truth for what this workspace is.\n *\n * Visibility is **not** filtered by membership. One project per backend (vision\n * AD-8): a configured project lives on its own deployment, so the *active*\n * backend's memberships cannot speak to another project's. Access is enforced\n * where it belongs — per-backend sign-in plus the EC-150 role hook on entry —\n * not by hiding projects you'd authenticate into. (Hiding them was the\n * single-backend assumption; cross-backend it just made projects unreachable.)\n */\n\nexport type SwitcherEntry =\n | { kind: 'project'; project: Project }\n | { kind: 'unprovisioned'; config: ResolvedWorkspaceProject }\n\nexport interface SwitcherSourceInput {\n workspace: WorkspaceState\n /** The studio store's read model (config-derived under a workspace config). */\n persisted: readonly Project[]\n}\n\nexport function selectSwitcherProjects(input: SwitcherSourceInput): SwitcherEntry[] {\n if (input.workspace.kind !== 'config') {\n // No-config golden path (an invalid config never reaches the switcher —\n // the DeploymentSetupGate blocks boot): today's adapter-listed behavior.\n return input.persisted.map((project) => ({ kind: 'project', project }))\n }\n\n const bySlug = new Map(input.persisted.map((project) => [project.slug, project]))\n return input.workspace.projects.map((config) => {\n const persisted = bySlug.get(config.slug)\n return persisted\n ? { kind: 'project' as const, project: persisted }\n : { kind: 'unprovisioned' as const, config }\n })\n}\n\n/** The persisted projects among the entries (for list surfaces filtering by status). */\nexport function persistedProjects(entries: readonly SwitcherEntry[]): Project[] {\n return entries.flatMap((entry) => (entry.kind === 'project' ? [entry.project] : []))\n}\n\n/**\n * The workspace's sole navigable project, or `null` (EC-401). Non-null exactly\n * when the workspace has ONE entry total and it is a real `project` — a single\n * *unprovisioned* entry keeps this `null` (the launcher's setup gate must stay\n * visible), and a second entry of any kind does too.\n */\nexport function soleWorkspaceProject(entries: readonly SwitcherEntry[]): Project | null {\n const [only] = entries\n return entries.length === 1 && only?.kind === 'project' ? only.project : null\n}\n\n/**\n * EC-401 — the ONE single-project predicate, shared by the launcher (skip the\n * dashboard hop) and the shell header (plain project name instead of the\n * switcher dropdown) so the two surfaces can never disagree.\n */\nexport function isSingleProjectWorkspace(entries: readonly SwitcherEntry[]): boolean {\n return soleWorkspaceProject(entries) !== null\n}\n\n/**\n * The launcher's auto-forward decision (EC-401), pure: the sole project to\n * redirect to, or `null` to render the launcher. A forced `?state=` verification\n * state and an explicit \"all projects\" navigation (see `launcherVisitState` in\n * the router seam) both keep the launcher visible; otherwise a single-project\n * workspace forwards straight into its project.\n */\nexport function launcherAutoForwardTarget(input: {\n entries: readonly SwitcherEntry[]\n /** Whether the launcher was opened with a forced `?state=` verification state. */\n forcedState: boolean\n /** Whether this location is an explicit \"all projects\" navigation. */\n explicitVisit: boolean\n}): Project | null {\n if (input.forcedState || input.explicitVisit) return null\n return soleWorkspaceProject(input.entries)\n}\n\n/** The not-yet-provisioned config entries (rendered as explicit CLI-hint states). */\nexport function unprovisionedProjects(\n entries: readonly SwitcherEntry[],\n): ResolvedWorkspaceProject[] {\n return entries.flatMap((entry) => (entry.kind === 'unprovisioned' ? [entry.config] : []))\n}\n"]}
1
+ {"version":3,"file":"switcher-source.js","sourceRoot":"","sources":["../../../src/lib/workspace/switcher-source.ts"],"names":[],"mappings":"AAmDA,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,wEAAwE;QACxE,yEAAyE;QACzE,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,MAAM,MAAM,GAA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AI,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CACnC,OAAiC;IAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import type { Project } from '@elytracms/core/studio-core'\nimport type { ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport type { WorkspaceState } from './workspace-source'\n\n/**\n * Config-driven switcher source (EC-154, reframed for EC-179 per-backend\n * projects). Pure logic deciding what the project switcher and launcher list:\n *\n * - **No workspace config** → exactly today's behavior: the adapter-listed\n * projects, untouched (single-project golden path).\n * - **Config present** → every configured project, in config order, as a\n * navigable entry; one that has no persisted counterpart yet is an explicit\n * `unprovisioned` state (\"run `elytra init`\") rather than an error. Persisted\n * projects *not* in the config are not listed: the config is the source of\n * truth for what this workspace is.\n *\n * ## The `unprovisioned` branch is currently unreachable FROM THE STUDIO (EC-470)\n *\n * This function will happily produce `unprovisioned` — `switcher-source.test.ts`\n * covers it directly. But the live studio can no longer feed it inputs that do:\n * `studio-context.tsx`'s `configProjects()` derives `persisted` from the SAME\n * `workspace.projects` array this function iterates (via `configProject`, which\n * sets `slug` from the config entry), so the `bySlug` lookup below always hits.\n * Under AD-8 project identity became config-owned, and \"provisioned\" stopped\n * being a per-project row the studio could miss — it is now a property of the\n * DEPLOYMENT (see `DeploymentSetupGate` / `elytra doctor`).\n *\n * Left in place deliberately rather than removed: the entry kind is load-bearing\n * for the EC-401 single-project predicates below (`soleWorkspaceProject` treats a\n * lone unprovisioned entry as \"do not auto-forward\"), so retiring it is a\n * separate, owner-sized decision — not a docs sweep. Recorded so the next reader\n * does not mistake it for live UI.\n *\n * Visibility is **not** filtered by membership. One project per backend (vision\n * AD-8): a configured project lives on its own deployment, so the *active*\n * backend's memberships cannot speak to another project's. Access is enforced\n * where it belongs — per-backend sign-in plus the EC-150 role hook on entry —\n * not by hiding projects you'd authenticate into. (Hiding them was the\n * single-backend assumption; cross-backend it just made projects unreachable.)\n */\n\nexport type SwitcherEntry =\n | { kind: 'project'; project: Project }\n | { kind: 'unprovisioned'; config: ResolvedWorkspaceProject }\n\nexport interface SwitcherSourceInput {\n workspace: WorkspaceState\n /** The studio store's read model (config-derived under a workspace config). */\n persisted: readonly Project[]\n}\n\nexport function selectSwitcherProjects(input: SwitcherSourceInput): SwitcherEntry[] {\n if (input.workspace.kind !== 'config') {\n // No-config golden path (an invalid config never reaches the switcher —\n // the DeploymentSetupGate blocks boot): today's adapter-listed behavior.\n return input.persisted.map((project) => ({ kind: 'project', project }))\n }\n\n const bySlug = new Map(input.persisted.map((project) => [project.slug, project]))\n return input.workspace.projects.map((config) => {\n const persisted = bySlug.get(config.slug)\n return persisted\n ? { kind: 'project' as const, project: persisted }\n : { kind: 'unprovisioned' as const, config }\n })\n}\n\n/** The persisted projects among the entries (for list surfaces filtering by status). */\nexport function persistedProjects(entries: readonly SwitcherEntry[]): Project[] {\n return entries.flatMap((entry) => (entry.kind === 'project' ? [entry.project] : []))\n}\n\n/**\n * The workspace's sole navigable project, or `null` (EC-401). Non-null exactly\n * when the workspace has ONE entry total and it is a real `project` — a single\n * *unprovisioned* entry keeps this `null` (the launcher's setup gate must stay\n * visible), and a second entry of any kind does too.\n */\nexport function soleWorkspaceProject(entries: readonly SwitcherEntry[]): Project | null {\n const [only] = entries\n return entries.length === 1 && only?.kind === 'project' ? only.project : null\n}\n\n/**\n * EC-401 — the ONE single-project predicate, shared by the launcher (skip the\n * dashboard hop) and the shell header (plain project name instead of the\n * switcher dropdown) so the two surfaces can never disagree.\n */\nexport function isSingleProjectWorkspace(entries: readonly SwitcherEntry[]): boolean {\n return soleWorkspaceProject(entries) !== null\n}\n\n/**\n * The launcher's auto-forward decision (EC-401), pure: the sole project to\n * redirect to, or `null` to render the launcher. A forced `?state=` verification\n * state and an explicit \"all projects\" navigation (see `launcherVisitState` in\n * the router seam) both keep the launcher visible; otherwise a single-project\n * workspace forwards straight into its project.\n */\nexport function launcherAutoForwardTarget(input: {\n entries: readonly SwitcherEntry[]\n /** Whether the launcher was opened with a forced `?state=` verification state. */\n forcedState: boolean\n /** Whether this location is an explicit \"all projects\" navigation. */\n explicitVisit: boolean\n}): Project | null {\n if (input.forcedState || input.explicitVisit) return null\n return soleWorkspaceProject(input.entries)\n}\n\n/** The not-yet-provisioned config entries (rendered as explicit CLI-hint states). */\nexport function unprovisionedProjects(\n entries: readonly SwitcherEntry[],\n): ResolvedWorkspaceProject[] {\n return entries.flatMap((entry) => (entry.kind === 'unprovisioned' ? [entry.config] : []))\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elytracms/studio",
3
3
  "author": "finaldream <hi@finaldream.de>",
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "private": false,
6
6
  "description": "The Elytra studio engine (UI + lib + routes + data-only Convex schema) as an importable package. Extraction staged in EXTRACTION.md (EC-223); Stages 1-2 = UI primitives + router-free lib leaves.",
7
7
  "license": "MIT",
@@ -150,7 +150,7 @@
150
150
  "lucide-react": "^1.23.0",
151
151
  "tailwind-merge": "^3.6.0",
152
152
  "zod": "^4.4.3",
153
- "@elytracms/core": "^0.0.79"
153
+ "@elytracms/core": "^0.0.81"
154
154
  },
155
155
  "peerDependencies": {
156
156
  "@tanstack/react-router": "^1.170.0",
@@ -1,63 +0,0 @@
1
- import { v } from 'convex/values'
2
- import { mutation, query } from './functions'
3
- import { requireCapability } from './guard'
4
-
5
- /**
6
- * CLI token persistence (EC-150). Only SHA-256 hashes are stored — hashing and
7
- * plaintext generation happen in `@elytracms/core/operations` (`tokens.issue`), and
8
- * verification goes through `verifyCliToken`, which calls `byHash` below via
9
- * the `ConvexCliTokenRepository`. All user-facing access is admin-only.
10
- */
11
-
12
- export const create = mutation({
13
- args: {
14
- tokenId: v.string(),
15
- label: v.string(),
16
- tokenHash: v.string(),
17
- createdAt: v.string(),
18
- },
19
- handler: async (ctx, args) => {
20
- await requireCapability(ctx, 'project.administer')
21
- const id = await ctx.db.insert('cliTokens', args)
22
- return ctx.db.get(id)
23
- },
24
- })
25
-
26
- export const list = query({
27
- args: {},
28
- handler: async (ctx) => {
29
- await requireCapability(ctx, 'project.administer')
30
- const rows = await ctx.db.query('cliTokens').collect()
31
- return rows.sort((a, b) => (a.tokenId < b.tokenId ? -1 : a.tokenId > b.tokenId ? 1 : 0))
32
- },
33
- })
34
-
35
- export const revoke = mutation({
36
- args: { tokenId: v.string(), revokedAt: v.string() },
37
- handler: async (ctx, { tokenId, revokedAt }) => {
38
- await requireCapability(ctx, 'project.administer')
39
- const existing = await ctx.db
40
- .query('cliTokens')
41
- .withIndex('by_token', (q) => q.eq('tokenId', tokenId))
42
- .first()
43
- if (!existing) throw new Error(`not-found: cli-token "${tokenId}"`)
44
- if (!existing.revokedAt) await ctx.db.patch(existing._id, { revokedAt })
45
- return ctx.db.get(existing._id)
46
- },
47
- })
48
-
49
- /**
50
- * Hash lookup for Bearer-token verification. Deliberately *unauthenticated*:
51
- * the future registry-sync HTTP endpoint (EC-156) calls it with the hash of a
52
- * presented token, and knowing a hash's preimage IS the credential. No token
53
- * material beyond what the caller already holds is revealed.
54
- */
55
- export const byHash = query({
56
- args: { tokenHash: v.string() },
57
- handler: async (ctx, { tokenHash }) => {
58
- return ctx.db
59
- .query('cliTokens')
60
- .withIndex('by_hash', (q) => q.eq('tokenHash', tokenHash))
61
- .first()
62
- },
63
- })