@elytracms/studio 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/convex/cms.ts +8 -31
- package/convex/content.ts +3 -44
- package/convex/delivery.ts +8 -42
- package/convex/functions.ts +17 -2
- package/convex/members.ts +2 -2
- package/convex/referenceMaintenance.ts +4 -73
- package/convex/references.ts +4 -2
- package/convex/schema.ts +17 -37
- package/convex/sync.ts +10 -42
- package/convex/triggers.ts +57 -0
- package/convex/webhooks.ts +3 -2
- package/dist/components/app-views/default-modules.d.ts +41 -0
- package/dist/components/app-views/default-modules.js +201 -0
- package/dist/components/app-views/default-modules.js.map +1 -0
- package/dist/components/app-views/module.d.ts +93 -0
- package/dist/components/app-views/module.js +75 -0
- package/dist/components/app-views/module.js.map +1 -0
- package/dist/components/app-views/sidebar.d.ts +95 -0
- package/dist/components/app-views/sidebar.js +153 -0
- package/dist/components/app-views/sidebar.js.map +1 -0
- package/dist/components/builder/builder-store.d.ts +92 -40
- package/dist/components/builder/builder-store.js +30 -126
- package/dist/components/builder/builder-store.js.map +1 -1
- package/dist/components/builder/canvas-breakpoints.d.ts +53 -0
- package/dist/components/builder/canvas-breakpoints.js +55 -0
- package/dist/components/builder/canvas-breakpoints.js.map +1 -0
- package/dist/components/builder/canvas.js +35 -61
- package/dist/components/builder/canvas.js.map +1 -1
- package/dist/components/builder/clipboard-actions.js +3 -3
- package/dist/components/builder/clipboard-actions.js.map +1 -1
- package/dist/components/builder/composition-field-editor.js +31 -40
- package/dist/components/builder/composition-field-editor.js.map +1 -1
- package/dist/components/builder/insert-context.js +1 -1
- package/dist/components/builder/insert-context.js.map +1 -1
- package/dist/components/builder/page-tree.js +3 -4
- package/dist/components/builder/page-tree.js.map +1 -1
- package/dist/components/builder/property-inspector.js +4 -64
- package/dist/components/builder/property-inspector.js.map +1 -1
- package/dist/components/cms/bulk-actions.d.ts +23 -5
- package/dist/components/cms/bulk-actions.js +7 -3
- package/dist/components/cms/bulk-actions.js.map +1 -1
- package/dist/components/cms/bulk-bar.d.ts +22 -6
- package/dist/components/cms/bulk-bar.js +46 -9
- package/dist/components/cms/bulk-bar.js.map +1 -1
- package/dist/components/cms/cell.d.ts +0 -4
- package/dist/components/cms/cell.js +1 -5
- package/dist/components/cms/cell.js.map +1 -1
- package/dist/components/cms/cms-index.d.ts +4 -2
- package/dist/components/cms/cms-index.js +6 -4
- package/dist/components/cms/cms-index.js.map +1 -1
- package/dist/components/cms/cms-store.d.ts +7 -6
- package/dist/components/cms/cms-store.js +55 -18
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/collection-table.js +8 -4
- package/dist/components/cms/collection-table.js.map +1 -1
- package/dist/components/cms/collections-sidebar.d.ts +10 -1
- package/dist/components/cms/collections-sidebar.js +13 -2
- package/dist/components/cms/collections-sidebar.js.map +1 -1
- package/dist/components/cms/detail-editor.js +2 -2
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/doc-state.d.ts +0 -5
- package/dist/components/cms/doc-state.js +1 -7
- package/dist/components/cms/doc-state.js.map +1 -1
- package/dist/components/cms/editable-cell.js +1 -1
- package/dist/components/cms/editable-cell.js.map +1 -1
- package/dist/components/cms/field-control.d.ts +11 -2
- package/dist/components/cms/field-control.js +22 -1
- package/dist/components/cms/field-control.js.map +1 -1
- package/dist/components/cms/field-renderer.d.ts +71 -0
- package/dist/components/cms/field-renderer.js +67 -0
- package/dist/components/cms/field-renderer.js.map +1 -0
- package/dist/components/cms/filter-builder.js +6 -28
- package/dist/components/cms/filter-builder.js.map +1 -1
- package/dist/components/cms/scalar-value-editor.d.ts +35 -0
- package/dist/components/cms/scalar-value-editor.js +43 -0
- package/dist/components/cms/scalar-value-editor.js.map +1 -0
- package/dist/components/collab/collab-context.d.ts +6 -14
- package/dist/components/collab/collab-context.js +3 -12
- package/dist/components/collab/collab-context.js.map +1 -1
- package/dist/components/collab/collab-seed.d.ts +7 -19
- package/dist/components/collab/collab-seed.js +9 -31
- package/dist/components/collab/collab-seed.js.map +1 -1
- package/dist/components/components/registry-browser.js +6 -12
- package/dist/components/components/registry-browser.js.map +1 -1
- package/dist/components/guards.d.ts +0 -9
- package/dist/components/guards.js +0 -12
- package/dist/components/guards.js.map +1 -1
- package/dist/components/project-session.js +8 -3
- package/dist/components/project-session.js.map +1 -1
- package/dist/components/section-nav.d.ts +10 -10
- package/dist/components/section-nav.js +48 -25
- package/dist/components/section-nav.js.map +1 -1
- package/dist/components/section-state.d.ts +0 -2
- package/dist/components/section-state.js +0 -9
- package/dist/components/section-state.js.map +1 -1
- package/dist/components/section-surface.d.ts +3 -7
- package/dist/components/section-surface.js +6 -14
- package/dist/components/section-surface.js.map +1 -1
- package/dist/components/sections.d.ts +0 -1
- package/dist/components/sections.js +0 -10
- package/dist/components/sections.js.map +1 -1
- package/dist/components/studio-project-screen.d.ts +3 -4
- package/dist/components/studio-project-screen.js +41 -160
- package/dist/components/studio-project-screen.js.map +1 -1
- package/dist/components/studio-shell.d.ts +0 -4
- package/dist/components/studio-shell.js +14 -14
- package/dist/components/studio-shell.js.map +1 -1
- package/dist/lib/data/collection-content.d.ts +19 -1
- package/dist/lib/data/collection-content.js +16 -0
- package/dist/lib/data/collection-content.js.map +1 -1
- package/dist/lib/operations/graph-commands.d.ts +2 -6
- package/dist/lib/operations/graph-commands.js +1 -2
- package/dist/lib/operations/graph-commands.js.map +1 -1
- package/dist/lib/operations/index.d.ts +0 -2
- package/dist/lib/operations/index.js +0 -2
- package/dist/lib/operations/index.js.map +1 -1
- package/dist/lib/operations/session-hydration.d.ts +14 -24
- package/dist/lib/operations/session-hydration.js +15 -34
- package/dist/lib/operations/session-hydration.js.map +1 -1
- package/dist/lib/persistence/convex-adapter.d.ts +1 -3
- package/dist/lib/persistence/convex-adapter.js +1 -154
- package/dist/lib/persistence/convex-adapter.js.map +1 -1
- package/dist/lib/persona/labels.js +0 -2
- package/dist/lib/persona/labels.js.map +1 -1
- package/dist/lib/references/reference-model.d.ts +0 -16
- package/dist/lib/references/reference-model.js +2 -54
- package/dist/lib/references/reference-model.js.map +1 -1
- package/dist/lib/references/references-store.js +3 -4
- package/dist/lib/references/references-store.js.map +1 -1
- package/dist/lib/registry/index.d.ts +0 -16
- package/dist/lib/registry/index.js +0 -15
- package/dist/lib/registry/index.js.map +1 -1
- package/dist/lib/webhooks/tags.js +2 -16
- package/dist/lib/webhooks/tags.js.map +1 -1
- package/dist/lib/workspace/index.d.ts +27 -1
- package/dist/lib/workspace/index.js +34 -0
- package/dist/lib/workspace/index.js.map +1 -1
- package/dist/router/match.d.ts +22 -34
- package/dist/router/match.js +22 -40
- package/dist/router/match.js.map +1 -1
- package/package.json +3 -2
- package/convex/graphs.ts +0 -55
- package/convex/publishing.ts +0 -76
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/lib/webhooks/tags.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,SAAS,MAAM,CAAC,SAAiB,EAAE,GAAW;IAC5C,OAAO,KAAK,SAAS,IAAI,GAAG,EAAE,CAAA;AAChC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,UAAkB,EAAE,EAAU;IAC7E,OAAO,MAAM,CAAC,SAAS,EAAE,OAAO,UAAU,IAAI,EAAE,EAAE,CAAC,CAAA;AACrD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,UAAkB,EAClB,MAAc;IAEd,OAAO,MAAM,CAAC,SAAS,EAAE,cAAc,UAAU,IAAI,MAAM,EAAE,CAAC,CAAA;AAChE,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,OAAe;IAChE,OAAO,MAAM,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED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AC,QAAQ,CAAE,MAAM,EAAE,CAAC,OAAO,CAAkC,EAAE,EAAE,CAAC,CAAA;IACvE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAA;IAC3F,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,KAAK,eAAe;QACxC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,EAAE;QAClF,CAAC,CAAC,IAAI,CAAA;AACV,CAAC","sourcesContent":["import type { OperationEvent } from '@elytracms/core/operations'\n\n/**\n * Pure tag computation for the EC-146 revalidation webhooks: map a succeeded\n * publish-shaped operation event onto the Next cache tags it invalidates.\n *\n * ## Tag format (mirror of `packages/next/src/cache.ts`)\n *\n * The canonical tag format lives in `@elytracms/next` (`src/cache.ts`). The\n * builder cannot depend on that package — it would drag the `next` peer\n * dependency into the studio bundle — so the three formatters are mirrored\n * here. Both sides pin the exact literal strings in their tests\n * (`tags.test.ts` here, `cache.test.ts` there) to keep them in lock-step.\n *\n * Every emitted tag is scoped `p:<projectId>:…` — the dispatcher always knows\n * the project id, and the scope keeps multi-project hosts from\n * cross-invalidating. Hosts must configure the same id as `cache.scope`.\n *\n * ## Which events produce which tags\n *\n * - **Document publish/unpublish/delete/save** (`documents.publish`,\n * `documents.unpublish`, `documents.pinVersion`, `documents.upsert`,\n * `documents.delete`): the document's own\n * `doc:<collection>:<id>` tag — dropping its detail page *and every cached\n * list that actually contained it* (fetch-time tagging) — plus the coarse\n * `collection:<name>:<locale>` membership tag for **all** configured\n * locales, sweeping cached lists whose membership may have changed\n * (new/removed/newly-matching documents).\n * - **Graph publish/unpublish** (`publishing.*`): the whole-project sweep tag\n * `project` — a layout, route, or binding change can affect any page, so\n * the honest v1 fallback (a superset of the per-route + per-collection\n * sweep) is to drop every cached entry of the project. Unrelated projects\n * stay cached.\n * - **Asset edit** (`assets.upsert` of an existing asset, `assets.remove`,\n * EC-227): the `asset:<id>` tag, dropping exactly the pages that *baked* that\n * asset's delivery shape (alt/dimensions/url). An `assets.upsert` CREATE (no\n * id in the summary — minted server-side) fires nothing: a brand-new asset is\n * in no cached page yet.\n * - **Fallback**: when a `documents` (or `assets.remove`) event's input summary\n * was truncated past the identity (EC-139 caps summaries at 160 chars; only\n * very large upserts hit this), the project sweep tag is emitted — coarse,\n * always correct, mirroring the EC-155 reference-index fallback.\n */\n\nfunction scoped(projectId: string, tag: string): string {\n return `p:${projectId}:${tag}`\n}\n\n/** `p:<projectId>:doc:<collection>:<id>` — mirror of `docCacheTag`. */\nexport function docWebhookTag(projectId: string, collection: string, id: string): string {\n return scoped(projectId, `doc:${collection}:${id}`)\n}\n\n/** `p:<projectId>:collection:<name>:<locale>` — mirror of `collectionCacheTag`. */\nexport function collectionWebhookTag(\n projectId: string,\n collection: string,\n locale: string,\n): string {\n return scoped(projectId, `collection:${collection}:${locale}`)\n}\n\n/** `p:<projectId>:asset:<id>` — mirror of `assetCacheTag` (EC-227). */\nexport function assetWebhookTag(projectId: string, assetId: string): string {\n return scoped(projectId, `asset:${assetId}`)\n}\n\n/** `p:<projectId>:project` — mirror of `projectSweepTag`. */\nexport function projectSweepWebhookTag(projectId: string): string {\n return scoped(projectId, 'project')\n}\n\n/** The operations whose success must reach the host's revalidate endpoint. */\nconst DOCUMENT_OPERATIONS = new Set([\n 'documents.upsert',\n 'documents.delete',\n // EC-224: publish/unpublish/pinVersion move the version pointer; their\n // `{ projectId, ref }` input drives the same doc + per-locale collection tag\n // set (the flat `documents.setState` op is gone).\n 'documents.publish',\n 'documents.unpublish',\n 'documents.pinVersion',\n])\nconst PUBLISHING_OPERATIONS = new Set(['publishing.publish', 'publishing.unpublish'])\n/**\n * Asset-record mutations (EC-227): editing an asset (alt/dimensions/re-upload)\n * must drop the published pages that *baked* its delivery shape, which carry the\n * `asset:<id>` tag. `assets.remove` always carries `assetId`; `assets.upsert`\n * carries `asset.id` only on an EDIT (a CREATE mints the id server-side).\n */\nconst ASSET_OPERATIONS = new Set(['assets.upsert', 'assets.remove'])\n\n/** One computed webhook emission: which project, why, and which tags. */\nexport interface WebhookTagSet {\n projectId: string\n /** The operation name, carried verbatim as the webhook `event`. */\n event: string\n /** Sorted, deduplicated, fully scoped Next tag strings. */\n tags: string[]\n}\n\n/** Tolerant parse of an EC-139 input summary (may be truncated past 160 chars). */\nfunction parseSummary(summary: string): Record<string, unknown> | undefined {\n try {\n const parsed: unknown = JSON.parse(summary)\n return typeof parsed === 'object' && parsed !== null\n ? (parsed as Record<string, unknown>)\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Extract the projectId even from a truncated summary (it serializes first). */\nfunction projectIdOfSummary(summary: string): string | undefined {\n const match = /\"projectId\":\"([^\"]+)\"/.exec(summary)\n return match?.[1]\n}\n\nfunction documentRefOf(value: unknown): { collection: string; id: string } | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const candidate = value as { collection?: unknown; id?: unknown }\n return typeof candidate.collection === 'string' &&\n candidate.collection.length > 0 &&\n typeof candidate.id === 'string' &&\n candidate.id.length > 0\n ? { collection: candidate.collection, id: candidate.id }\n : undefined\n}\n\n/**\n * Compute the webhook tag set for one lifecycle event, or `null` when the\n * event is not a successful publish-shaped command (queries, failures, and\n * unrelated domains never fire webhooks).\n */\nexport function webhookTagsForEvent(\n event: Pick<OperationEvent, 'operation' | 'kind' | 'status' | 'inputSummary'>,\n options: { locales: readonly string[] },\n): WebhookTagSet | null {\n if (event.status !== 'succeeded' || event.kind !== 'command') return null\n\n const isDocument = DOCUMENT_OPERATIONS.has(event.operation)\n const isPublishing = PUBLISHING_OPERATIONS.has(event.operation)\n const isAsset = ASSET_OPERATIONS.has(event.operation)\n if (!isDocument && !isPublishing && !isAsset) return null\n\n const projectId = projectIdOfSummary(event.inputSummary)\n if (projectId === undefined) return null\n\n if (isPublishing) {\n return {\n projectId,\n event: event.operation,\n tags: [projectSweepWebhookTag(projectId)],\n }\n }\n\n if (isAsset) return assetTagsForEvent(projectId, event)\n\n const parsed = parseSummary(event.inputSummary)\n const ref = documentRefOf(parsed?.['ref']) ?? documentRefOf(parsed?.['document'])\n if (!ref) {\n // Truncated summary (large upsert payload): honest coarse fallback.\n return { projectId, event: event.operation, tags: [projectSweepWebhookTag(projectId)] }\n }\n\n const tags = new Set<string>([docWebhookTag(projectId, ref.collection, ref.id)])\n for (const locale of options.locales) {\n tags.add(collectionWebhookTag(projectId, ref.collection, locale))\n }\n // EC-207: routes/redirects are config-owned (a code deploy, which rebuilds the\n // host) — they are no longer DB documents, so there is no route-document event\n // to sweep the project for. Graph publishes still emit the project sweep above.\n return { projectId, event: event.operation, tags: [...tags].sort() }\n}\n\n/** A non-empty string, else `undefined` (the asset id out of a summary). */\nfunction stringOf(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\n/**\n * Tags for an asset mutation (EC-227). The edit cases — `assets.remove` (carries\n * `assetId`) and `assets.upsert` of an existing asset (carries `asset.id`) —\n * emit exactly `asset:<id>`, dropping the pages that baked that asset. An\n * `assets.upsert` with **no** id is a CREATE: the id is minted server-side and a\n * brand-new asset cannot be baked into any existing page, so it invalidates\n * nothing (`null`, no webhook). A `remove` missing its id means a truncated\n * summary — sweep the project (coarse, always correct — the document fallback).\n */\nfunction assetTagsForEvent(\n projectId: string,\n event: Pick<OperationEvent, 'operation' | 'inputSummary'>,\n): WebhookTagSet | null {\n const parsed = parseSummary(event.inputSummary)\n const assetId =\n event.operation === 'assets.remove'\n ? stringOf(parsed?.['assetId'])\n : stringOf((parsed?.['asset'] as { id?: unknown } | undefined)?.id)\n if (assetId) {\n return { projectId, event: event.operation, tags: [assetWebhookTag(projectId, assetId)] }\n }\n return event.operation === 'assets.remove'\n ? { projectId, event: event.operation, tags: [projectSweepWebhookTag(projectId)] }\n : null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/lib/webhooks/tags.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,SAAS,MAAM,CAAC,SAAiB,EAAE,GAAW;IAC5C,OAAO,KAAK,SAAS,IAAI,GAAG,EAAE,CAAA;AAChC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,UAAkB,EAAE,EAAU;IAC7E,OAAO,MAAM,CAAC,SAAS,EAAE,OAAO,UAAU,IAAI,EAAE,EAAE,CAAC,CAAA;AACrD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,UAAkB,EAClB,MAAc;IAEd,OAAO,MAAM,CAAC,SAAS,EAAE,cAAc,UAAU,IAAI,MAAM,EAAE,CAAC,CAAA;AAChE,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,OAAe;IAChE,OAAO,MAAM,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,sBAAsB,CAAC,SAAiB;IACtD,OAAO,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AACrC,CAAC;AAED,8EAA8E;AAC9E,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,kBAAkB;IAClB,kBAAkB;IAClB,uEAAuE;IACvE,6EAA6E;IAC7E,kDAAkD;IAClD,mBAAmB;IACnB,qBAAqB;IACrB,sBAAsB;CACvB,CAAC,CAAA;AACF;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,CAAA;AAWpE,mFAAmF;AACnF,SAAS,YAAY,CAAC,OAAe;IACnC,IAAI,CAAC;QACH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O,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1E,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,iBAAiB,CACxB,SAAiB,EACjB,KAAyD;IAEzD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAC/C,MAAM,OAAO,GACX,KAAK,CAAC,SAAS,KAAK,eAAe;QACjC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC,CAAC,QAAQ,CAAE,MAAM,EAAE,CAAC,OAAO,CAAkC,EAAE,EAAE,CAAC,CAAA;IACvE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAA;IAC3F,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,KAAK,eAAe;QACxC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,EAAE;QAClF,CAAC,CAAC,IAAI,CAAA;AACV,CAAC","sourcesContent":["import type { OperationEvent } from '@elytracms/core/operations'\n\n/**\n * Pure tag computation for the EC-146 revalidation webhooks: map a succeeded\n * publish-shaped operation event onto the Next cache tags it invalidates.\n *\n * ## Tag format (mirror of `packages/next/src/cache.ts`)\n *\n * The canonical tag format lives in `@elytracms/next` (`src/cache.ts`). The\n * builder cannot depend on that package — it would drag the `next` peer\n * dependency into the studio bundle — so the three formatters are mirrored\n * here. Both sides pin the exact literal strings in their tests\n * (`tags.test.ts` here, `cache.test.ts` there) to keep them in lock-step.\n *\n * Every emitted tag is scoped `p:<projectId>:…` — the dispatcher always knows\n * the project id, and the scope keeps multi-project hosts from\n * cross-invalidating. Hosts must configure the same id as `cache.scope`.\n *\n * ## Which events produce which tags\n *\n * - **Document publish/unpublish/delete/save** (`documents.publish`,\n * `documents.unpublish`, `documents.pinVersion`, `documents.upsert`,\n * `documents.delete`): the document's own\n * `doc:<collection>:<id>` tag — dropping its detail page *and every cached\n * list that actually contained it* (fetch-time tagging) — plus the coarse\n * `collection:<name>:<locale>` membership tag for **all** configured\n * locales, sweeping cached lists whose membership may have changed\n * (new/removed/newly-matching documents).\n * - **Asset edit** (`assets.upsert` of an existing asset, `assets.remove`,\n * EC-227): the `asset:<id>` tag, dropping exactly the pages that *baked* that\n * asset's delivery shape (alt/dimensions/url). An `assets.upsert` CREATE (no\n * id in the summary — minted server-side) fires nothing: a brand-new asset is\n * in no cached page yet.\n * - **Fallback**: when a `documents` (or `assets.remove`) event's input summary\n * was truncated past the identity (EC-139 caps summaries at 160 chars; only\n * very large upserts hit this), the project sweep tag is emitted — coarse,\n * always correct, mirroring the EC-155 reference-index fallback.\n */\n\nfunction scoped(projectId: string, tag: string): string {\n return `p:${projectId}:${tag}`\n}\n\n/** `p:<projectId>:doc:<collection>:<id>` — mirror of `docCacheTag`. */\nexport function docWebhookTag(projectId: string, collection: string, id: string): string {\n return scoped(projectId, `doc:${collection}:${id}`)\n}\n\n/** `p:<projectId>:collection:<name>:<locale>` — mirror of `collectionCacheTag`. */\nexport function collectionWebhookTag(\n projectId: string,\n collection: string,\n locale: string,\n): string {\n return scoped(projectId, `collection:${collection}:${locale}`)\n}\n\n/** `p:<projectId>:asset:<id>` — mirror of `assetCacheTag` (EC-227). */\nexport function assetWebhookTag(projectId: string, assetId: string): string {\n return scoped(projectId, `asset:${assetId}`)\n}\n\n/** `p:<projectId>:project` — mirror of `projectSweepTag`. */\nexport function projectSweepWebhookTag(projectId: string): string {\n return scoped(projectId, 'project')\n}\n\n/** The operations whose success must reach the host's revalidate endpoint. */\nconst DOCUMENT_OPERATIONS = new Set([\n 'documents.upsert',\n 'documents.delete',\n // EC-224: publish/unpublish/pinVersion move the version pointer; their\n // `{ projectId, ref }` input drives the same doc + per-locale collection tag\n // set (the flat `documents.setState` op is gone).\n 'documents.publish',\n 'documents.unpublish',\n 'documents.pinVersion',\n])\n/**\n * Asset-record mutations (EC-227): editing an asset (alt/dimensions/re-upload)\n * must drop the published pages that *baked* its delivery shape, which carry the\n * `asset:<id>` tag. `assets.remove` always carries `assetId`; `assets.upsert`\n * carries `asset.id` only on an EDIT (a CREATE mints the id server-side).\n */\nconst ASSET_OPERATIONS = new Set(['assets.upsert', 'assets.remove'])\n\n/** One computed webhook emission: which project, why, and which tags. */\nexport interface WebhookTagSet {\n projectId: string\n /** The operation name, carried verbatim as the webhook `event`. */\n event: string\n /** Sorted, deduplicated, fully scoped Next tag strings. */\n tags: string[]\n}\n\n/** Tolerant parse of an EC-139 input summary (may be truncated past 160 chars). */\nfunction parseSummary(summary: string): Record<string, unknown> | undefined {\n try {\n const parsed: unknown = JSON.parse(summary)\n return typeof parsed === 'object' && parsed !== null\n ? (parsed as Record<string, unknown>)\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Extract the projectId even from a truncated summary (it serializes first). */\nfunction projectIdOfSummary(summary: string): string | undefined {\n const match = /\"projectId\":\"([^\"]+)\"/.exec(summary)\n return match?.[1]\n}\n\nfunction documentRefOf(value: unknown): { collection: string; id: string } | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const candidate = value as { collection?: unknown; id?: unknown }\n return typeof candidate.collection === 'string' &&\n candidate.collection.length > 0 &&\n typeof candidate.id === 'string' &&\n candidate.id.length > 0\n ? { collection: candidate.collection, id: candidate.id }\n : undefined\n}\n\n/**\n * Compute the webhook tag set for one lifecycle event, or `null` when the\n * event is not a successful publish-shaped command (queries, failures, and\n * unrelated domains never fire webhooks).\n */\nexport function webhookTagsForEvent(\n event: Pick<OperationEvent, 'operation' | 'kind' | 'status' | 'inputSummary'>,\n options: { locales: readonly string[] },\n): WebhookTagSet | null {\n if (event.status !== 'succeeded' || event.kind !== 'command') return null\n\n const isDocument = DOCUMENT_OPERATIONS.has(event.operation)\n const isAsset = ASSET_OPERATIONS.has(event.operation)\n if (!isDocument && !isAsset) return null\n\n const projectId = projectIdOfSummary(event.inputSummary)\n if (projectId === undefined) return null\n\n if (isAsset) return assetTagsForEvent(projectId, event)\n\n const parsed = parseSummary(event.inputSummary)\n const ref = documentRefOf(parsed?.['ref']) ?? documentRefOf(parsed?.['document'])\n if (!ref) {\n // Truncated summary (large upsert payload): honest coarse fallback.\n return { projectId, event: event.operation, tags: [projectSweepWebhookTag(projectId)] }\n }\n\n const tags = new Set<string>([docWebhookTag(projectId, ref.collection, ref.id)])\n for (const locale of options.locales) {\n tags.add(collectionWebhookTag(projectId, ref.collection, locale))\n }\n // EC-207: routes/redirects are config-owned (a code deploy, which rebuilds the\n // host) — they are no longer DB documents, so there is no route-document event\n // to sweep the project for.\n return { projectId, event: event.operation, tags: [...tags].sort() }\n}\n\n/** A non-empty string, else `undefined` (the asset id out of a summary). */\nfunction stringOf(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\n/**\n * Tags for an asset mutation (EC-227). The edit cases — `assets.remove` (carries\n * `assetId`) and `assets.upsert` of an existing asset (carries `asset.id`) —\n * emit exactly `asset:<id>`, dropping the pages that baked that asset. An\n * `assets.upsert` with **no** id is a CREATE: the id is minted server-side and a\n * brand-new asset cannot be baked into any existing page, so it invalidates\n * nothing (`null`, no webhook). A `remove` missing its id means a truncated\n * summary — sweep the project (coarse, always correct — the document fallback).\n */\nfunction assetTagsForEvent(\n projectId: string,\n event: Pick<OperationEvent, 'operation' | 'inputSummary'>,\n): WebhookTagSet | null {\n const parsed = parseSummary(event.inputSummary)\n const assetId =\n event.operation === 'assets.remove'\n ? stringOf(parsed?.['assetId'])\n : stringOf((parsed?.['asset'] as { id?: unknown } | undefined)?.id)\n if (assetId) {\n return { projectId, event: event.operation, tags: [assetWebhookTag(projectId, assetId)] }\n }\n return event.operation === 'assets.remove'\n ? { projectId, event: event.operation, tags: [projectSweepWebhookTag(projectId)] }\n : null\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElytraConfigInput } from '@elytracms/core/studio-core';
|
|
1
|
+
import type { AppViewEntry, BreakpointConfig, ElytraConfigInput, FieldRendererEntry, SidebarEntry } from '@elytracms/core/studio-core';
|
|
2
2
|
import type { CollectionDef, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core';
|
|
3
3
|
import type { WorkspaceState } from './workspace-source';
|
|
4
4
|
export { resolveWorkspaceState, WORKSPACE_ENV_VAR } from './workspace-source';
|
|
@@ -65,6 +65,32 @@ export declare function resolveDeploymentProjectId(fallbackId: string): string;
|
|
|
65
65
|
* studio is wired by env alone with no config.
|
|
66
66
|
*/
|
|
67
67
|
export declare function resolveDeploymentCollections(): CollectionDef[];
|
|
68
|
+
/**
|
|
69
|
+
* The canvas preview breakpoints of the active config project (EC-250).
|
|
70
|
+
* Config-sourced (config-as-code, derived from the site's Tailwind `screens`);
|
|
71
|
+
* `undefined` when the project declares none — the canvas then falls back to
|
|
72
|
+
* Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveDeploymentBreakpoints(): BreakpointConfig[] | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The custom field renderers of the active config project (EC-238). Config-sourced
|
|
77
|
+
* live React code (omitted from the serializable projection); `[]` when none — the
|
|
78
|
+
* document editor then uses its built-in control for every field type.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveDeploymentFieldRenderers(): FieldRendererEntry[];
|
|
81
|
+
/**
|
|
82
|
+
* The custom app-view modules of the active config project (EC-239). Config-sourced
|
|
83
|
+
* live React modules (omitted from the serializable projection); `[]` when none —
|
|
84
|
+
* the studio then mounts only its default module registry (CMS/Routes/Assets/…).
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveDeploymentAppViews(): AppViewEntry[];
|
|
87
|
+
/**
|
|
88
|
+
* The configurable sidebar of the active config project (EC-237). Config-sourced
|
|
89
|
+
* live entries (carry icons; omitted from the projection); `undefined` when the
|
|
90
|
+
* project declares none — the studio then derives the default rail from its module
|
|
91
|
+
* registry (declared-but-invalid entries surface as visible issues, never silent).
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolveDeploymentSidebar(): SidebarEntry[] | undefined;
|
|
68
94
|
/**
|
|
69
95
|
* The resolved URL routes of the active config project (EC-207, "routes as
|
|
70
96
|
* code"). Routes are config-sourced: the studio reads the materialized
|
|
@@ -147,6 +147,40 @@ export function resolveDeploymentProjectId(fallbackId) {
|
|
|
147
147
|
export function resolveDeploymentCollections() {
|
|
148
148
|
return activeConfigProject()?.collections ?? [];
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* The canvas preview breakpoints of the active config project (EC-250).
|
|
152
|
+
* Config-sourced (config-as-code, derived from the site's Tailwind `screens`);
|
|
153
|
+
* `undefined` when the project declares none — the canvas then falls back to
|
|
154
|
+
* Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.
|
|
155
|
+
*/
|
|
156
|
+
export function resolveDeploymentBreakpoints() {
|
|
157
|
+
return activeConfigProject()?.breakpoints;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The custom field renderers of the active config project (EC-238). Config-sourced
|
|
161
|
+
* live React code (omitted from the serializable projection); `[]` when none — the
|
|
162
|
+
* document editor then uses its built-in control for every field type.
|
|
163
|
+
*/
|
|
164
|
+
export function resolveDeploymentFieldRenderers() {
|
|
165
|
+
return activeConfigProject()?.fieldRenderers ?? [];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The custom app-view modules of the active config project (EC-239). Config-sourced
|
|
169
|
+
* live React modules (omitted from the serializable projection); `[]` when none —
|
|
170
|
+
* the studio then mounts only its default module registry (CMS/Routes/Assets/…).
|
|
171
|
+
*/
|
|
172
|
+
export function resolveDeploymentAppViews() {
|
|
173
|
+
return activeConfigProject()?.appViews ?? [];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The configurable sidebar of the active config project (EC-237). Config-sourced
|
|
177
|
+
* live entries (carry icons; omitted from the projection); `undefined` when the
|
|
178
|
+
* project declares none — the studio then derives the default rail from its module
|
|
179
|
+
* registry (declared-but-invalid entries surface as visible issues, never silent).
|
|
180
|
+
*/
|
|
181
|
+
export function resolveDeploymentSidebar() {
|
|
182
|
+
return activeConfigProject()?.sidebar;
|
|
183
|
+
}
|
|
150
184
|
/**
|
|
151
185
|
* The resolved URL routes of the active config project (EC-207, "routes as
|
|
152
186
|
* 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;AAGvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE7E,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAGpG,IAAI,MAAM,GAA0B,IAAI,CAAA;AAExC;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyB;IACpD,MAAM,GAAG,qBAAqB,CAAC;QAC7B,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC/B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,IAAI,iBAAiB,GAAkB,IAAI,CAAA;AAE3C,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,IAAmB;IACtD,MAAM,MAAM,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAA;IACvC,iBAAiB,GAAG,IAAI,IAAI,IAAI,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CAAA;AAC1D,CAAC","sourcesContent":["import { frontendUrlForEnvironment } from '@elytracms/core/studio-core'\nimport type { ElytraConfigInput, ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport type { CollectionDef, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport { resolveWorkspaceState, WORKSPACE_ENV_VAR } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport { persistedProjects, selectSwitcherProjects, unprovisionedProjects } from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract). The\n * consumer's entry point does `import config from './elytra.config'` and calls\n * this — an explicit init, NOT an `import.meta.glob` autoload that reaches into\n * the consumer's filesystem (Oli, 2026-06-19: \"there's always an entry point that\n * can trigger a function call\"). This is the config-injection responsibility of\n * the eventual `createStudio(config)` package export; it seeds the workspace state\n * every later query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n */\nexport function createStudio(config: ElytraConfigInput): void {\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\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 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/**\n * The resolved redirects of the active config project (EC-207). Config-sourced\n * exactly like {@link resolveDeploymentRoutes}: the `redirects` system\n * collection is retired and nothing is read from the backend. `[]` when none\n * are declared.\n */\nexport function resolveDeploymentRedirects(): RedirectRecord[] {\n return activeConfigProject()?.redirects ?? []\n}\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 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 frontendUr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C,CAAA;AAC1D,CAAC","sourcesContent":["import { frontendUrlForEnvironment } from '@elytracms/core/studio-core'\nimport type {\n AppViewEntry,\n BreakpointConfig,\n ElytraConfigInput,\n FieldRendererEntry,\n ResolvedWorkspaceProject,\n SidebarEntry,\n} from '@elytracms/core/studio-core'\nimport type { CollectionDef, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport { resolveWorkspaceState, WORKSPACE_ENV_VAR } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport { persistedProjects, selectSwitcherProjects, unprovisionedProjects } from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract). The\n * consumer's entry point does `import config from './elytra.config'` and calls\n * this — an explicit init, NOT an `import.meta.glob` autoload that reaches into\n * the consumer's filesystem (Oli, 2026-06-19: \"there's always an entry point that\n * can trigger a function call\"). This is the config-injection responsibility of\n * the eventual `createStudio(config)` package export; it seeds the workspace state\n * every later query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n */\nexport function createStudio(config: ElytraConfigInput): void {\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\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 of the active config project (EC-238). Config-sourced\n * live React code (omitted from the serializable projection); `[]` when none — the\n * document editor then uses its built-in control for every field type.\n */\nexport function resolveDeploymentFieldRenderers(): FieldRendererEntry[] {\n return activeConfigProject()?.fieldRenderers ?? []\n}\n\n/**\n * The custom app-view modules of the active config project (EC-239). Config-sourced\n * live React modules (omitted from the serializable projection); `[]` when none —\n * the studio then mounts only its default module registry (CMS/Routes/Assets/…).\n */\nexport function resolveDeploymentAppViews(): AppViewEntry[] {\n return activeConfigProject()?.appViews ?? []\n}\n\n/**\n * The configurable sidebar of the active config project (EC-237). Config-sourced\n * live entries (carry icons; omitted from the projection); `undefined` when the\n * project declares none — the studio then derives the default rail from its module\n * registry (declared-but-invalid entries surface as visible issues, never silent).\n */\nexport function resolveDeploymentSidebar(): SidebarEntry[] | undefined {\n return activeConfigProject()?.sidebar\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/**\n * The resolved redirects of the active config project (EC-207). Config-sourced\n * exactly like {@link resolveDeploymentRoutes}: the `redirects` system\n * collection is retired and nothing is read from the backend. `[]` when none\n * are declared.\n */\nexport function resolveDeploymentRedirects(): RedirectRecord[] {\n return activeConfigProject()?.redirects ?? []\n}\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 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"]}
|
package/dist/router/match.d.ts
CHANGED
|
@@ -10,46 +10,34 @@
|
|
|
10
10
|
* pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility
|
|
11
11
|
* convention without needing a router instance.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* /$projectId
|
|
23
|
-
* /$projectId
|
|
24
|
-
* /$projectId/
|
|
25
|
-
*
|
|
13
|
+
* EC-239 (app-view modularization): the route table is no longer a hardcoded
|
|
14
|
+
* per-section switch — the studio's surfaces are a config-extendable module
|
|
15
|
+
* registry, so the matcher is now registry-AGNOSTIC. It splits the splat into a
|
|
16
|
+
* module id (the first segment) + that module's trailing segments; the screen
|
|
17
|
+
* resolver looks the id up in the registry and the module's own `parsePath`
|
|
18
|
+
* interprets the segments (CMS: collection/document; components: id; flat: none).
|
|
19
|
+
* Keeping the matcher free of the surface list is what lets a consuming repo add
|
|
20
|
+
* a routable custom module purely from config.
|
|
21
|
+
*
|
|
22
|
+
* /$projectId → { section: 'index' } (redirect to first module)
|
|
23
|
+
* /$projectId/<id> → { section: 'module', moduleId: '<id>', segments: [] }
|
|
24
|
+
* /$projectId/<id>/a/b → { section: 'module', moduleId: '<id>', segments: ['a','b'] }
|
|
25
|
+
*
|
|
26
|
+
* The module decides whether its segments resolve; an unknown id or an
|
|
27
|
+
* over-deep path becomes a not-found at the resolver, not here.
|
|
26
28
|
*/
|
|
27
29
|
export type StudioRouteMatch = {
|
|
28
30
|
section: 'index';
|
|
29
31
|
} | {
|
|
30
|
-
section: '
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} | {
|
|
34
|
-
section: 'routes';
|
|
35
|
-
} | {
|
|
36
|
-
section: 'extensions';
|
|
37
|
-
} | {
|
|
38
|
-
section: 'builder';
|
|
39
|
-
} | {
|
|
40
|
-
section: 'components';
|
|
41
|
-
componentId: string | null;
|
|
42
|
-
} | {
|
|
43
|
-
section: 'cms';
|
|
44
|
-
collectionId: string | null;
|
|
45
|
-
documentId: string | null;
|
|
46
|
-
} | {
|
|
47
|
-
section: 'not-found';
|
|
32
|
+
section: 'module';
|
|
33
|
+
moduleId: string;
|
|
34
|
+
segments: string[];
|
|
48
35
|
};
|
|
49
36
|
/**
|
|
50
|
-
* Match the trailing pathname of the project splat (`_splat`)
|
|
51
|
-
*
|
|
52
|
-
* for `/p1/cms/page/abc
|
|
37
|
+
* Match the trailing pathname of the project splat (`_splat`) into a module id +
|
|
38
|
+
* its segments. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`
|
|
39
|
+
* for `/p1/cms/page/abc` → `{ moduleId: 'cms', segments: ['page', 'abc'] }`. An
|
|
40
|
+
* empty splat is the bare project index (which redirects to the first module).
|
|
53
41
|
*/
|
|
54
42
|
export declare function matchStudioRoute(splat: string): StudioRouteMatch;
|
|
55
43
|
/**
|
package/dist/router/match.js
CHANGED
|
@@ -10,19 +10,21 @@
|
|
|
10
10
|
* pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility
|
|
11
11
|
* convention without needing a router instance.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* /$projectId
|
|
23
|
-
* /$projectId
|
|
24
|
-
* /$projectId/
|
|
25
|
-
*
|
|
13
|
+
* EC-239 (app-view modularization): the route table is no longer a hardcoded
|
|
14
|
+
* per-section switch — the studio's surfaces are a config-extendable module
|
|
15
|
+
* registry, so the matcher is now registry-AGNOSTIC. It splits the splat into a
|
|
16
|
+
* module id (the first segment) + that module's trailing segments; the screen
|
|
17
|
+
* resolver looks the id up in the registry and the module's own `parsePath`
|
|
18
|
+
* interprets the segments (CMS: collection/document; components: id; flat: none).
|
|
19
|
+
* Keeping the matcher free of the surface list is what lets a consuming repo add
|
|
20
|
+
* a routable custom module purely from config.
|
|
21
|
+
*
|
|
22
|
+
* /$projectId → { section: 'index' } (redirect to first module)
|
|
23
|
+
* /$projectId/<id> → { section: 'module', moduleId: '<id>', segments: [] }
|
|
24
|
+
* /$projectId/<id>/a/b → { section: 'module', moduleId: '<id>', segments: ['a','b'] }
|
|
25
|
+
*
|
|
26
|
+
* The module decides whether its segments resolve; an unknown id or an
|
|
27
|
+
* over-deep path becomes a not-found at the resolver, not here.
|
|
26
28
|
*/
|
|
27
29
|
/** Split a splat pathname into clean segments (drops empty/leading/trailing slashes). */
|
|
28
30
|
function segments(splat) {
|
|
@@ -32,36 +34,16 @@ function segments(splat) {
|
|
|
32
34
|
.filter(Boolean);
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
|
-
* Match the trailing pathname of the project splat (`_splat`)
|
|
36
|
-
*
|
|
37
|
-
* for `/p1/cms/page/abc
|
|
37
|
+
* Match the trailing pathname of the project splat (`_splat`) into a module id +
|
|
38
|
+
* its segments. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`
|
|
39
|
+
* for `/p1/cms/page/abc` → `{ moduleId: 'cms', segments: ['page', 'abc'] }`. An
|
|
40
|
+
* empty splat is the bare project index (which redirects to the first module).
|
|
38
41
|
*/
|
|
39
42
|
export function matchStudioRoute(splat) {
|
|
40
|
-
const [
|
|
41
|
-
|
|
42
|
-
if (head === undefined)
|
|
43
|
+
const [moduleId, ...rest] = segments(splat);
|
|
44
|
+
if (moduleId === undefined)
|
|
43
45
|
return { section: 'index' };
|
|
44
|
-
|
|
45
|
-
case 'settings':
|
|
46
|
-
case 'assets':
|
|
47
|
-
case 'routes':
|
|
48
|
-
case 'extensions':
|
|
49
|
-
case 'builder':
|
|
50
|
-
// Flat sections take no path params; any trailing segment is not a route.
|
|
51
|
-
return a === undefined ? { section: head } : { section: 'not-found' };
|
|
52
|
-
case 'components':
|
|
53
|
-
// `components` (index) or `components/:id` (detail); deeper is not a route.
|
|
54
|
-
if (b !== undefined)
|
|
55
|
-
return { section: 'not-found' };
|
|
56
|
-
return { section: 'components', componentId: a ?? null };
|
|
57
|
-
case 'cms':
|
|
58
|
-
// `cms` (index) | `cms/:c` (collection) | `cms/:c/:d` (document); deeper is not a route.
|
|
59
|
-
if (rest.length > 0)
|
|
60
|
-
return { section: 'not-found' };
|
|
61
|
-
return { section: 'cms', collectionId: a ?? null, documentId: b ?? null };
|
|
62
|
-
default:
|
|
63
|
-
return { section: 'not-found' };
|
|
64
|
-
}
|
|
46
|
+
return { section: 'module', moduleId, segments: rest };
|
|
65
47
|
}
|
|
66
48
|
/**
|
|
67
49
|
* The inverse of {@link matchStudioRoute}: build the `_splat` subpath for a
|
package/dist/router/match.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/router/match.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/router/match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,yFAAyF;AACzF,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC3C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IACvD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE;IACf,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU;IAC1B,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ;IACtB,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ;IACtB,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY;IAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;IACxB,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY;IAC9B,SAAS,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,cAAc,WAAW,EAAE;IAC/D,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK;IAChB,aAAa,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,OAAO,YAAY,EAAE;IAC9D,WAAW,EAAE,CAAC,YAAoB,EAAE,UAAkB,EAAE,EAAE,CACxD,OAAO,YAAY,IAAI,UAAU,EAAE;CAC7B,CAAA","sourcesContent":["/**\n * Studio route table (EC-223 Stage 6 — catch-all routing). The studio mounts as\n * a SINGLE splat route per project (`/$projectId/$`); this pure matcher turns the\n * splat's trailing pathname into a typed match that the screen resolver renders.\n * Keeping the URL→screen map inside the engine (instead of in per-consumer route\n * files) is what lets the package own its navigation with a near-empty consumer\n * route tree — the goal of Stage 6.\n *\n * Deterministic and dependency-free: every screen state is reproducible from a\n * pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility\n * convention without needing a router instance.\n *\n * EC-239 (app-view modularization): the route table is no longer a hardcoded\n * per-section switch — the studio's surfaces are a config-extendable module\n * registry, so the matcher is now registry-AGNOSTIC. It splits the splat into a\n * module id (the first segment) + that module's trailing segments; the screen\n * resolver looks the id up in the registry and the module's own `parsePath`\n * interprets the segments (CMS: collection/document; components: id; flat: none).\n * Keeping the matcher free of the surface list is what lets a consuming repo add\n * a routable custom module purely from config.\n *\n * /$projectId → { section: 'index' } (redirect to first module)\n * /$projectId/<id> → { section: 'module', moduleId: '<id>', segments: [] }\n * /$projectId/<id>/a/b → { section: 'module', moduleId: '<id>', segments: ['a','b'] }\n *\n * The module decides whether its segments resolve; an unknown id or an\n * over-deep path becomes a not-found at the resolver, not here.\n */\n\nexport type StudioRouteMatch =\n | { section: 'index' }\n | { section: 'module'; moduleId: string; segments: string[] }\n\n/** Split a splat pathname into clean segments (drops empty/leading/trailing slashes). */\nfunction segments(splat: string): string[] {\n return splat\n .split('/')\n .map((segment) => segment.trim())\n .filter(Boolean)\n}\n\n/**\n * Match the trailing pathname of the project splat (`_splat`) into a module id +\n * its segments. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`\n * for `/p1/cms/page/abc` → `{ moduleId: 'cms', segments: ['page', 'abc'] }`. An\n * empty splat is the bare project index (which redirects to the first module).\n */\nexport function matchStudioRoute(splat: string): StudioRouteMatch {\n const [moduleId, ...rest] = segments(splat)\n if (moduleId === undefined) return { section: 'index' }\n return { section: 'module', moduleId, segments: rest }\n}\n\n/**\n * The inverse of {@link matchStudioRoute}: build the `_splat` subpath for a\n * screen. Navigation addresses the single project splat as\n * `to={STUDIO_PROJECT_ROUTE} params={{ projectId, _splat: studioPath.X(...) }}`,\n * so the URL-construction lives in exactly one place — the same module that\n * parses it back. `matchStudioRoute(studioPath.cmsDocument(c, d))` round-trips\n * (pinned in `match.test.ts`), which is what keeps the two directions in sync.\n */\nexport const studioPath = {\n index: () => '',\n settings: () => 'settings',\n assets: () => 'assets',\n routes: () => 'routes',\n extensions: () => 'extensions',\n builder: () => 'builder',\n components: () => 'components',\n component: (componentId: string) => `components/${componentId}`,\n cms: () => 'cms',\n cmsCollection: (collectionId: string) => `cms/${collectionId}`,\n cmsDocument: (collectionId: string, documentId: string) =>\n `cms/${collectionId}/${documentId}`,\n} as const\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.
|
|
4
|
+
"version": "0.0.16",
|
|
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",
|
|
@@ -109,10 +109,11 @@
|
|
|
109
109
|
"class-variance-authority": "^0.7.1",
|
|
110
110
|
"clsx": "^2.1.1",
|
|
111
111
|
"convex": "^1.40.0",
|
|
112
|
+
"convex-helpers": "0.1.120",
|
|
112
113
|
"lucide-react": "^1.17.0",
|
|
113
114
|
"tailwind-merge": "^3.6.0",
|
|
114
115
|
"zod": "^4.0.0",
|
|
115
|
-
"@elytracms/core": "^0.0.
|
|
116
|
+
"@elytracms/core": "^0.0.16"
|
|
116
117
|
},
|
|
117
118
|
"peerDependencies": {
|
|
118
119
|
"@tanstack/react-router": "^1.170.0",
|
package/convex/graphs.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { v } from 'convex/values'
|
|
2
|
-
import { mutation, query } from './functions'
|
|
3
|
-
import { requireRole } from './guard'
|
|
4
|
-
import { maintainGraphDraftReferences } from './referenceMaintenance'
|
|
5
|
-
|
|
6
|
-
/** Project graph + revision persistence (EC-041). Revisions are append-only. */
|
|
7
|
-
|
|
8
|
-
export const saveRevision = mutation({
|
|
9
|
-
args: {
|
|
10
|
-
serializedGraph: v.string(),
|
|
11
|
-
schemaVersion: v.number(),
|
|
12
|
-
createdAt: v.string(),
|
|
13
|
-
label: v.optional(v.string()),
|
|
14
|
-
message: v.optional(v.string()),
|
|
15
|
-
},
|
|
16
|
-
handler: async (ctx, args) => {
|
|
17
|
-
await requireRole(ctx, 'editor') // EC-150
|
|
18
|
-
// Compute the next revision atomically inside the mutation.
|
|
19
|
-
const last = await ctx.db.query('graphRevisions').withIndex('by_revision').order('desc').first()
|
|
20
|
-
const revision = (last?.revision ?? 0) + 1
|
|
21
|
-
const id = await ctx.db.insert('graphRevisions', { ...args, revision })
|
|
22
|
-
const record = await ctx.db.get(id)
|
|
23
|
-
// EC-277: the latest revision IS the draft graph — reindex its component-usage
|
|
24
|
-
// and self-typed static-prop references in-transaction (AD-6 "at the source").
|
|
25
|
-
await maintainGraphDraftReferences(ctx, args.serializedGraph)
|
|
26
|
-
return record
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
export const latest = query({
|
|
31
|
-
args: {},
|
|
32
|
-
handler: async (ctx) => {
|
|
33
|
-
await requireRole(ctx, 'viewer') // EC-150
|
|
34
|
-
return ctx.db.query('graphRevisions').withIndex('by_revision').order('desc').first()
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
export const revision = query({
|
|
39
|
-
args: { revision: v.number() },
|
|
40
|
-
handler: async (ctx, args) => {
|
|
41
|
-
await requireRole(ctx, 'viewer') // EC-150
|
|
42
|
-
return ctx.db
|
|
43
|
-
.query('graphRevisions')
|
|
44
|
-
.withIndex('by_revision', (q) => q.eq('revision', args.revision))
|
|
45
|
-
.first()
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
export const listRevisions = query({
|
|
50
|
-
args: {},
|
|
51
|
-
handler: async (ctx) => {
|
|
52
|
-
await requireRole(ctx, 'viewer') // EC-150
|
|
53
|
-
return ctx.db.query('graphRevisions').withIndex('by_revision').order('desc').collect()
|
|
54
|
-
},
|
|
55
|
-
})
|
package/convex/publishing.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { v } from 'convex/values'
|
|
2
|
-
import { mutation, query } from './functions'
|
|
3
|
-
import { requireRole } from './guard'
|
|
4
|
-
import { maintainGraphPublishedReferences } from './referenceMaintenance'
|
|
5
|
-
import { scheduleRevalidate } from './revalidate'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Publishing state (EC-045). Single-environment (EC-179, vision AD-8): a
|
|
9
|
-
* deployment IS one environment, so there is exactly ONE publishingState row —
|
|
10
|
-
* see `env-is-deployment-boundary`.
|
|
11
|
-
*
|
|
12
|
-
* EC-180 / EC-146: a graph publish/unpublish fires the host revalidation webhook
|
|
13
|
-
* via `scheduleRevalidate` (`./revalidate`) — the SAME helper CMS document
|
|
14
|
-
* publish uses, so content-only sites invalidate too (see `cms.ts`).
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export const publish = mutation({
|
|
18
|
-
args: {
|
|
19
|
-
revisionId: v.string(),
|
|
20
|
-
revision: v.number(),
|
|
21
|
-
publishedAt: v.string(),
|
|
22
|
-
},
|
|
23
|
-
handler: async (ctx, args) => {
|
|
24
|
-
await requireRole(ctx, 'editor') // EC-150
|
|
25
|
-
const existing = await ctx.db.query('publishingState').first()
|
|
26
|
-
const record = {
|
|
27
|
-
status: 'published' as const,
|
|
28
|
-
publishedRevisionId: args.revisionId,
|
|
29
|
-
publishedRevision: args.revision,
|
|
30
|
-
publishedAt: args.publishedAt,
|
|
31
|
-
createdAt: existing?.createdAt ?? args.publishedAt,
|
|
32
|
-
updatedAt: args.publishedAt,
|
|
33
|
-
}
|
|
34
|
-
// EC-153 parity: republish preserves `createdAt`; return the stored record.
|
|
35
|
-
const id = existing ? existing._id : await ctx.db.insert('publishingState', record)
|
|
36
|
-
if (existing) await ctx.db.patch(existing._id, record)
|
|
37
|
-
// EC-277: the newly pinned revision becomes the published graph — reindex its
|
|
38
|
-
// published reference rows in-transaction (AD-6 "at the source").
|
|
39
|
-
await maintainGraphPublishedReferences(ctx)
|
|
40
|
-
// EC-180: drop the host's cached pages for this project (fire-and-forget).
|
|
41
|
-
await scheduleRevalidate(ctx, 'publishing.publish')
|
|
42
|
-
return ctx.db.get(id)
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
export const unpublish = mutation({
|
|
47
|
-
args: { updatedAt: v.string() },
|
|
48
|
-
handler: async (ctx, args) => {
|
|
49
|
-
await requireRole(ctx, 'editor') // EC-150
|
|
50
|
-
const existing = await ctx.db.query('publishingState').first()
|
|
51
|
-
if (!existing || existing.status !== 'published') {
|
|
52
|
-
throw new Error('invalid-transition: nothing is currently published')
|
|
53
|
-
}
|
|
54
|
-
await ctx.db.patch(existing._id, {
|
|
55
|
-
status: 'draft',
|
|
56
|
-
publishedRevisionId: undefined,
|
|
57
|
-
publishedRevision: undefined,
|
|
58
|
-
publishedAt: undefined,
|
|
59
|
-
updatedAt: args.updatedAt,
|
|
60
|
-
})
|
|
61
|
-
// EC-277: a graph going dark drops every published graph reference row.
|
|
62
|
-
await maintainGraphPublishedReferences(ctx)
|
|
63
|
-
// EC-180: a graph going dark must also drop the host's cached pages.
|
|
64
|
-
await scheduleRevalidate(ctx, 'publishing.unpublish')
|
|
65
|
-
// EC-153 parity: return the stored record (createdAt preserved).
|
|
66
|
-
return ctx.db.get(existing._id)
|
|
67
|
-
},
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
export const getState = query({
|
|
71
|
-
args: {},
|
|
72
|
-
handler: async (ctx) => {
|
|
73
|
-
await requireRole(ctx, 'viewer') // EC-150
|
|
74
|
-
return ctx.db.query('publishingState').first()
|
|
75
|
-
},
|
|
76
|
-
})
|