@elytracms/studio 0.0.65 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/self-account-view-source.js +9 -2
- package/dist/components/account/self-account-view-source.js.map +1 -1
- package/dist/components/app-views/default-modules.d.ts +28 -1
- package/dist/components/app-views/default-modules.js +47 -2
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/auth-context.js +32 -1
- package/dist/components/auth-context.js.map +1 -1
- package/dist/components/builder/blocks-model.js +4 -2
- package/dist/components/builder/blocks-model.js.map +1 -1
- package/dist/components/builder/canvas-dnd.js +4 -2
- package/dist/components/builder/canvas-dnd.js.map +1 -1
- package/dist/components/builder/insert-context.js +15 -6
- package/dist/components/builder/insert-context.js.map +1 -1
- package/dist/components/builder/page-tree.js +4 -2
- package/dist/components/builder/page-tree.js.map +1 -1
- package/dist/components/builder/property-inspector.js +2 -1
- package/dist/components/builder/property-inspector.js.map +1 -1
- package/dist/components/cms/asset-field.js +21 -5
- package/dist/components/cms/asset-field.js.map +1 -1
- package/dist/components/cms/bulk-actions.d.ts +22 -3
- package/dist/components/cms/bulk-actions.js +27 -3
- package/dist/components/cms/bulk-actions.js.map +1 -1
- package/dist/components/cms/cms-store.js +19 -0
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/detail-editor.js +18 -19
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/prop-fields.js +23 -16
- package/dist/components/cms/prop-fields.js.map +1 -1
- package/dist/components/cms/publish-clean.d.ts +21 -0
- package/dist/components/cms/publish-clean.js +30 -0
- package/dist/components/cms/publish-clean.js.map +1 -0
- package/dist/components/cms/use-live-url.d.ts +24 -1
- package/dist/components/cms/use-live-url.js +26 -4
- package/dist/components/cms/use-live-url.js.map +1 -1
- package/dist/components/cms/use-publish-controller.js +8 -6
- package/dist/components/cms/use-publish-controller.js.map +1 -1
- package/dist/components/collection-view/cms-collection-view-source.js +15 -7
- package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
- package/dist/lib/auth/auth-adapter.d.ts +22 -0
- package/dist/lib/auth/auth-adapter.js.map +1 -1
- package/dist/lib/auth/convex-auth-adapter.d.ts +42 -1
- package/dist/lib/auth/convex-auth-adapter.js +69 -0
- package/dist/lib/auth/convex-auth-adapter.js.map +1 -1
- package/dist/lib/auth/dev-auto-login-adapter.d.ts +2 -1
- package/dist/lib/auth/dev-auto-login-adapter.js +6 -0
- package/dist/lib/auth/dev-auto-login-adapter.js.map +1 -1
- package/dist/lib/auth/index.d.ts +1 -1
- package/dist/lib/auth/index.js.map +1 -1
- package/dist/lib/auth/local-auth-adapter.d.ts +2 -1
- package/dist/lib/auth/local-auth-adapter.js +7 -0
- package/dist/lib/auth/local-auth-adapter.js.map +1 -1
- package/dist/lib/auth-errors.d.ts +45 -3
- package/dist/lib/auth-errors.js +46 -5
- package/dist/lib/auth-errors.js.map +1 -1
- package/dist/lib/clipboard/paste-target.js +5 -2
- package/dist/lib/clipboard/paste-target.js.map +1 -1
- package/dist/lib/dnd/drop-rules.d.ts +13 -0
- package/dist/lib/dnd/drop-rules.js +15 -0
- package/dist/lib/dnd/drop-rules.js.map +1 -1
- package/dist/lib/i18n/messages.de.js +3 -0
- package/dist/lib/i18n/messages.de.js.map +1 -1
- package/dist/lib/i18n/messages.en.d.ts +2 -0
- package/dist/lib/i18n/messages.en.js +8 -0
- package/dist/lib/i18n/messages.en.js.map +1 -1
- package/dist/lib/persistence/index.js +6 -3
- package/dist/lib/persistence/index.js.map +1 -1
- package/dist/lib/session-expiry.d.ts +19 -6
- package/dist/lib/session-expiry.js +13 -1
- package/dist/lib/session-expiry.js.map +1 -1
- package/dist/lib/session-revalidation.d.ts +81 -0
- package/dist/lib/session-revalidation.js +94 -0
- package/dist/lib/session-revalidation.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-store.js","sourceRoot":"","sources":["../../../src/components/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,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;QAC1F,gBAAgB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;KAC3E,CAAC,EACF;QACE,SAAS;QACT,WAAW;QACX,SAAS;QACT,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,WAAW;QACX,OAAO;QACP,YAAY;QACZ,eAAe;QACf,cAAc;QACd,uBAAuB;QACvB,cAAc;QACd,WAAW;QACX,eAAe;QACf,iBAAiB;QACjB,oBAAoB;QACpB,sBAAsB;QACtB,eAAe;QACf,QAAQ;QACR,eAAe;QACf,OAAO;QACP,WAAW;QACX,YAAY;QACZ,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,cAAc;QACd,OAAO;QACP,QAAQ;QACR,YAAY;KACb,CACF,CAAA;IAED,OAAO,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,QAAQ,GAAuB,CAAA;AAC7E,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,OAAO,EAAE,YAAY,EAAE,CAAA","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport {\n createCollectionRegistry,\n createDocumentStore,\n documentKey,\n documentSchema,\n resolveDocumentTitle,\n resolveField,\n sampleDocuments,\n seedDefaults,\n sampleFilterableCollections,\n sampleLocaleConfig,\n samplePublishedKeys,\n resolveSingletonDocument,\n titleFieldOf,\n validateDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CmsValidationIssue,\n CollectionDef,\n CollectionRegistry,\n DocumentRef,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n RestoreScope,\n} from '@elytracms/core/cms-core'\nimport type { DocumentVersionRecord } from '@elytracms/core/persistence'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { configureStudioLocales, useStudioLocale } from '@elytracms/studio/lib/locale'\nimport { studioManifestLookup } from '@elytracms/studio/lib/registry'\nimport { resolveDeploymentCollections } from '@elytracms/studio/lib/workspace'\nimport { validateComposition, validateRichTextEmbeds } from './cms-composition-validators'\nimport { matchesRef, removeDoc, replaceDoc, upsertDoc } from './document-ref-utils'\nimport { createRequiredContext } from '@elytracms/studio/lib/required-context'\nimport { createCmsPersister, getStudioOperations } from '@elytracms/studio/lib/operations'\nimport type {\n CmsPersister,\n OperationError,\n OperationResult,\n} from '@elytracms/studio/lib/operations'\nimport {\n ALL_VIEW_ID,\n canonicalViewState,\n configViewIssues,\n configViewsFor,\n defaultConfigViewId,\n defaultViewState,\n viewStatesEqual,\n} from '@elytracms/studio/lib/cms-views'\nimport type { TableViewState } from '@elytracms/studio/lib/cms-views'\nimport { useOptionalAssets } from '../assets/assets-store'\nimport { consumeStagedDocuments } from './document-staging'\nimport { applyCellValue, commitCellEdit } from './cell-edit'\nimport type { CellCommitInput, CellCommitOutcome } from './cell-edit'\nimport { runBulkAction } from './bulk-actions'\nimport type { BulkAction, BulkReport, BulkSetField } from './bulk-actions'\n\n/**\n * A resolved table view: a named bundle of filters (closed AD-3 vocabulary),\n * sort, and visible/ordered columns. EC-246b: named views are **config-as-code**\n * (declared in `cms/`, read live via `configViewsFor`) — the editor-owned DB\n * saved-view store (EC-169) is retired. The unnamed \"All documents\" default is\n * derived per collection; editors keep only transient in-session tweaks + Reset.\n */\nexport interface SavedView {\n id: string\n /**\n * The view label — a {@link LocalizedString} (EC-343): the built-in \"All\" default is\n * a plain translated string; a config view's name may be a `{ locale }` map, resolved\n * at the render site (`ViewTabs`) via the same `resolveLabel` path as `form.label`.\n */\n name: LocalizedString\n state: TableViewState\n}\n\nexport interface ImportReport {\n added: number\n rejected: { id: string; issues: CmsValidationIssue[] }[]\n}\n\n/**\n * A document's recorded version history plus its live pin (EC-224), as the\n * Versions inspector pane reads it. `versions` is newest-first; `publishedVersion`\n * is the recorded version currently pinned live, absent when unpublished.\n */\nexport interface DocumentVersionsView {\n versions: DocumentVersionRecord[]\n publishedVersion?: number\n}\n\nexport interface CmsStore {\n /** The project this CMS session edits (set when persistence is enabled); the asset picker scopes the real library by it (EC-152). */\n projectId?: string\n collections: readonly CollectionDef[]\n localeConfig: LocaleConfig\n /**\n * The studio's ambient active locale (EC-176): table cells, detail forms,\n * and inline edits all display and write THIS locale. Switched once via the\n * shared `LocaleSwitcher`, never per control.\n */\n activeLocale: Locale\n getCollection(id: string): CollectionDef | undefined\n documentsOf(collectionId: string): CmsDocument[]\n getDocument(ref: DocumentRef): CmsDocument | undefined\n /** Resolve a relation/asset target's display title. */\n titleOf(ref: DocumentRef): string\n saveDocument(doc: CmsDocument): void\n /**\n * Commit ONE field edit from the table (EC-168): optimistic session apply +\n * exactly one `documents.upsert` operations command, awaited. Validation\n * failures and operation rejections return a structured error (the caller\n * renders it on the cell) and leave the session rolled back.\n */\n commitFieldEdit(input: CellCommitInput): Promise<CellCommitOutcome>\n createDocument(collectionId: string): DocumentRef\n /**\n * Ensure a singleton collection's lone document exists and return its ref\n * (EC-274). Resolves the existing single document, or creates one with a normal\n * generated id (never the collection id). Idempotent. The singleton route opens\n * through this so the one document always exists to edit.\n */\n ensureSingletonDocument(collectionId: string): DocumentRef\n deleteDocument(ref: DocumentRef): void\n /**\n * Is this document currently published? Sourced from the version POINTER\n * (EC-224), not the flat `state` enum — seeded from hydration and updated by\n * {@link publishDocument}/{@link unpublishDocument}.\n */\n isPublished(ref: DocumentRef): boolean\n /**\n * Publish: snapshot the draft as a new version and pin it live (EC-224).\n * Flips published-ness optimistically, then reconciles against the backend\n * record (EC-225) so the badge can never claim a publish the backend refused\n * (e.g. blocked by publish-time field validation).\n */\n publishDocument(ref: DocumentRef): Promise<void>\n /**\n * Unpublish: clear the live version pin (EC-224). Blocked at the operations\n * layer while strict relation fields published-reference it (EC-173); the\n * optimistic flip reconciles against the backend on rejection (EC-225).\n */\n unpublishDocument(ref: DocumentRef): Promise<void>\n /**\n * Load this document's recorded version history + live pin (EC-224) for the\n * Versions inspector pane. Fixture/playground sessions (no project) have no\n * persisted history → an empty view. Failures surface as {@link persistError}.\n */\n loadDocumentVersions(ref: DocumentRef): Promise<DocumentVersionsView>\n /**\n * Restore a recorded version as the new working draft (EC-224): the operation\n * snapshots the current draft first (so the rollback is itself undoable), then\n * loads the chosen snapshot. An optional `scope` (EC-298) restores only one\n * field or block, laid over the current draft, instead of the whole document.\n * Returns the restored draft (or null on failure/fixture session) so the open\n * editor can adopt it.\n */\n restoreDocumentVersion(\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null>\n importDocuments(collectionId: string, docs: unknown[]): ImportReport\n validate(doc: CmsDocument): CmsValidationIssue[]\n isFieldReadOnly(field: FieldDef): boolean\n // Views (EC-246b): the built-in default + config-declared named views (from\n // `cms/`, read live). Shared views are code, not editor-owned DB data.\n viewsOf(collectionId: string): SavedView[]\n activeViewId(collectionId: string): string\n /** Switch views — resets the working table state to the view's state. */\n setActiveView(collectionId: string, viewId: string): void\n /** The live table state (the active view's state plus unsaved edits). */\n tableStateOf(collectionId: string): TableViewState\n /**\n * Update the working state. Always pass an updater when deriving from the\n * previous state — render-time snapshots go stale across rapid events.\n */\n setTableState(\n collectionId: string,\n update: TableViewState | ((prev: TableViewState) => TableViewState),\n ): void\n /** Does the working state diverge from the active view (\"unsaved changes\")? */\n isViewDirty(collectionId: string): boolean\n /** Discard working-state edits, back to the active view. */\n resetTableState(collectionId: string): void\n /**\n * Bulk publish/unpublish/delete (EC-169) + set-field (EC-247): one operations\n * command PER item, per-item outcomes in the report — partial failure is\n * enumerated, never silent. Only succeeded items mutate the session. A\n * `set-field` carries its `{ field, value }` payload.\n */\n runBulk(\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport>\n /**\n * Mirror a collection into the session (e.g. an accepted AI-generated\n * schema, EC-097). Replaces by id. Session-only: persistence happens through\n * the accept flow's changeset (`schema.upsertCollection`), not here.\n */\n addCollection(def: CollectionDef): void\n /**\n * Most recent failed/denied persisted mutation (structured, from the\n * operation result). Rendered by the CMS surface — never a silent failure.\n */\n persistError: OperationError | null\n clearPersistError(): void\n /** Seed the persisted baseline now (e.g. before applying an AI changeset). */\n ensurePersistedBaseline(): Promise<void>\n /** Await all queued persisted mutations (tests, publish flows). */\n flushPersistence(): Promise<void>\n}\n\nconst { Context: CmsContext, useRequired: useCms } = createRequiredContext<CmsStore>('Cms')\n\nfunction primaryField(collection: CollectionDef): string {\n return titleFieldOf(collection)?.name ?? collection.fields[0]?.name ?? 'id'\n}\n\n/**\n * EC-316 (bug fix) — mint a fresh, COLLISION-FREE document id for `+ New`.\n *\n * `seq` is an in-memory, per-session counter (reset to 0 on every reload). A\n * document minted `new-<collection>-<n>` in a PRIOR session can already occupy\n * whatever `n` this session's counter would next reissue — the pre-fix bug:\n * `+ New` on a `post` collection that already held a (possibly published)\n * `new-post-1` handed out that SAME id again, silently opening the existing\n * document for editing instead of creating a fresh draft. Walking the counter\n * past every id already in `existingIds` makes the mint collision-free\n * regardless of what a prior session left behind.\n */\nexport function mintDocumentId(\n collectionId: string,\n seq: { current: number },\n existingIds: ReadonlySet<string>,\n): string {\n let id: string\n do {\n seq.current += 1\n id = `new-${collectionId}-${seq.current}`\n } while (existingIds.has(id))\n return id\n}\n\n/**\n * Build a fresh document for `collectionId`: a collision-free id (EC-316, via\n * {@link mintDocumentId} against every id `existingDocs` already holds for\n * this collection) and the collection's declared field defaults (EC-297, via\n * `seedDefaults`). Pure — the sensitive part of the insert sequence shared by\n * `createDocument` and `ensureSingletonDocument`'s empty branch (via the\n * private `insertNewDocument` below), factored out so it's unit-testable\n * without a `CmsProvider`.\n */\nexport function buildNewDocument(\n collectionId: string,\n registry: CollectionRegistry,\n seq: { current: number },\n existingDocs: readonly CmsDocument[],\n): CmsDocument {\n const existingIds = new Set(\n existingDocs.filter((d) => d.collection === collectionId).map((d) => d.id),\n )\n const id = mintDocumentId(collectionId, seq, existingIds)\n const collection = registry.get(collectionId)\n return { collection: collectionId, id, values: collection ? seedDefaults(collection) : {} }\n}\n\n/**\n * Does `docs` already hold a document for `collectionId`? `ensureSingletonDocument`'s\n * empty branch re-checks this INSIDE the `setDocuments` updater (against the\n * latest `prev`, not a stale snapshot) so a concurrent invocation — StrictMode's\n * double-invoked effect, or a second caller racing the same synchronous guard —\n * can never materialize a second singleton document.\n */\nexport function hasDocumentFor(docs: readonly CmsDocument[], collectionId: string): boolean {\n return docs.some((d) => d.collection === collectionId)\n}\n\n/**\n * Surface a duplicate `default: true` across a collection's config views (EC-343) as\n * a visible, one-time console warning — never a silent swallow. This is a developer\n * config mistake (editors can't fix config-as-code), so it takes the same warn-once\n * console channel the i18n runtime uses for config problems, not an editor banner;\n * the first-declared default still seeds deterministically. Deduped per collection id.\n */\nconst warnedDuplicateDefaultCollections = new Set<string>()\nfunction warnDuplicateDefaultViews(collection: CollectionDef): void {\n if (warnedDuplicateDefaultCollections.has(collection.id)) return\n const issues = configViewIssues(collection)\n if (issues.length === 0) return\n warnedDuplicateDefaultCollections.add(collection.id)\n if (typeof console !== 'undefined') console.warn(`[views] ${issues[0]!.message}`)\n}\n\n/** The unnamed built-in view: no filters, no sort, every field visible. */\nfunction defaultView(collection: CollectionDef | undefined): SavedView {\n return {\n id: ALL_VIEW_ID,\n name: translate('cms.list.view.all'),\n state: collection\n ? defaultViewState(collection)\n : { filters: [], sort: null, columns: [], hidden: [] },\n }\n}\n\n/**\n * The CMS session store (EC-141): documents and collections are optimistic,\n * synchronous session state (live validation while typing); every mutation —\n * create/save/delete/state transitions — is mirrored onto the operations\n * layer (`documents.*` / `schema.*` commands) through {@link createCmsPersister}.\n * Failed/denied commands surface as {@link CmsStore.persistError}.\n */\nexport function CmsProvider({\n children,\n projectId,\n initialCollections,\n initialDocuments,\n initialPublishedKeys,\n initialLocaleConfig,\n}: {\n children: ReactNode\n /** Enables persistence through the shared operations client. */\n projectId?: string\n /** Seed collections (e.g. from an imported starter kit, EC-119); defaults to the samples. */\n initialCollections?: CollectionDef[]\n initialDocuments?: CmsDocument[]\n /**\n * Published document keys from hydration (EC-224): the version pointer\n * (`publishedVersion` set). Absent (kit / fixture sessions) → the sample\n * fixtures' published set (`samplePublishedKeys`).\n */\n initialPublishedKeys?: readonly string[]\n /** Locale config for the seeded content; defaults to the sample config. */\n initialLocaleConfig?: LocaleConfig\n}) {\n const [documents, setDocuments] = useState<CmsDocument[]>(() => {\n const seeded = (initialDocuments ?? sampleDocuments).map((d) => structuredClone(d))\n // EC-320 (0.0.44 follow-up): merge any documents STAGED by the\n // Components-view \"Use in document…\" transfer — a cross-mount handoff in\n // EVERY mode now (see document-staging.ts), not just the playground. The\n // merge rule itself stays mode-aware there: playground's seeded set is a\n // static baseline that never reflects a write (staged always wins);\n // Convex's is a fresh per-mount hydration query (staged fills gaps only,\n // dropped once the seeded set actually carries the key).\n return consumeStagedDocuments(projectId, seeded)\n })\n // Published-ness as the version POINTER (EC-224), decoupled from the flat\n // `state` enum: seeded from hydration's pointer set, or — when none is supplied\n // — the canonical sample published set for the playground. A kit's imported\n // content (`initialDocuments` without a pointer set) starts unpublished\n // (drafts) until an editor publishes it. The flat `state` is never consulted.\n const [publishedKeys, setPublishedKeys] = useState<Set<string>>(() => {\n if (initialPublishedKeys) return new Set(initialPublishedKeys)\n return new Set(initialDocuments ? [] : samplePublishedKeys)\n })\n const [activeViews, setActiveViews] = useState<Record<string, string>>({})\n // The live table state per collection where it diverges from the active\n // view; absent key = exactly the active view's state (not dirty).\n const [tableStates, setTableStates] = useState<Record<string, TableViewState>>({})\n // Collections are stateful so AI-generated schemas (EC-097) can be accepted\n // into the session. The session schema IS the source the sort/filter\n // offering follows (EC-177 gap 3): hydrated sessions receive the persisted\n // schema via `initialCollections`; the fixture fallback is the canonical\n // cms-core sample schema WITH its declared `filterable` flags — no\n // session-side widenings, so the studio never offers a field the backend's\n // delivery engine would reject.\n const [collections, setCollections] = useState<CollectionDef[]>(() => [\n ...(initialCollections ?? sampleFilterableCollections),\n ])\n const [persistError, setPersistError] = useState<OperationError | null>(null)\n const seq = useRef(0)\n // EC-274: collection ids whose lone singleton document this session has already\n // created — a synchronous guard so a re-invoked effect (or StrictMode's double\n // mount) never materializes a second document under a freshly generated id.\n const ensuredSingletons = useRef<Set<string>>(new Set())\n\n // Latest session state for the persister's lazy baseline (no re-subscribing).\n const collectionsRef = useRef(collections)\n collectionsRef.current = collections\n const documentsRef = useRef(documents)\n documentsRef.current = documents\n\n const persisterRef = useRef<CmsPersister | null>(null)\n if (persisterRef.current === null && projectId !== undefined) {\n persisterRef.current = createCmsPersister({\n projectId,\n getOperations: async () => (await getStudioOperations()).operations,\n getCollections: () => collectionsRef.current,\n getDocuments: () => documentsRef.current,\n // EC-277: self-type composition static props on write (the manifest half of\n // the lens), so extraction stays schema-free. Document fields self-type via\n // the schema alone (above); the registry adds blocks/embed prop coverage.\n lookupManifest: studioManifestLookup(),\n onError: setPersistError,\n })\n }\n\n const registry = useMemo(() => createCollectionRegistry(collections), [collections])\n const store = useMemo(() => createDocumentStore(documents), [documents])\n const localeConfig = initialLocaleConfig ?? sampleLocaleConfig\n\n // Asset existence is validated against the REAL asset library (assets live in\n // their own repository, not as CMS documents). With the ambient AssetsProvider\n // present, the oracle is the set of uploaded asset ids — but only once loaded;\n // while it loads we are optimistic so a valid upload is never transiently\n // flagged \"unknown\". With no provider (tests/fixtures), the oracle is absent\n // and asset existence falls back to the document store.\n const assetStore = useOptionalAssets()\n const assetExists = useMemo<((id: string) => boolean) | undefined>(() => {\n if (!assetStore) return undefined\n if (assetStore.status !== 'ready') return () => true\n const ids = new Set(assetStore.assets.map((asset) => asset.id))\n return (id) => ids.has(id)\n }, [assetStore])\n\n // The ambient studio locale (EC-176): this session's locale config drives\n // the switcher options; every CMS surface follows the one active locale.\n const { locale: activeLocale } = useStudioLocale()\n useEffect(() => {\n configureStudioLocales(localeConfig)\n }, [localeConfig])\n\n const getCollection = useCallback((id: string) => registry.get(id), [registry])\n\n const getDocument = useCallback(\n (ref: DocumentRef) => documents.find((d) => matchesRef(d, ref)),\n [documents],\n )\n\n const titleOf = useCallback(\n (ref: DocumentRef) => {\n const doc = documents.find((d) => matchesRef(d, ref))\n const collection = registry.get(ref.collection)\n if (!doc || !collection) return ref.id\n // EC-296/EC-242: a function `titleField` (title pattern) composes the title\n // from the document's resolved values (active locale). Only resolve the full\n // value set when a function is declared — the common string `titleField` case\n // still resolves the single title field below (primaryField === the title field).\n if (typeof collection.titleField === 'function') {\n const values: Record<string, unknown> = {}\n for (const field of collection.fields) {\n values[field.name] = resolveField(collection, doc, field.name, activeLocale, localeConfig).value\n }\n return resolveDocumentTitle(collection, values, ref.id)\n }\n // Resolve through the locale layer in the ambient active locale (EC-176)\n // with EC-018 fallback, so localized titles follow the switcher.\n const { value } = resolveField(\n collection,\n doc,\n primaryField(collection),\n activeLocale,\n localeConfig,\n )\n return typeof value === 'string' && value ? value : ref.id\n },\n [documents, registry, localeConfig, activeLocale],\n )\n\n const saveDocument = useCallback((doc: CmsDocument) => {\n // Replace-or-append (upsert): a brand-new document must still land even\n // though nothing in the session matches its ref yet.\n setDocuments((prev) => upsertDoc(prev, doc))\n persisterRef.current?.upsertDocument(doc)\n }, [])\n\n const commitFieldEdit = useCallback(\n (input: CellCommitInput): Promise<CellCommitOutcome> => {\n // Pure map-replace: an edit always targets a document already open in\n // the session, so a miss (already gone) is a no-op, never an append.\n const replaceWith = (doc: CmsDocument) => setDocuments((prev) => replaceDoc(prev, doc))\n const persister = persisterRef.current\n return commitCellEdit(\n {\n registry,\n documents: documentsRef.current,\n localeConfig,\n applySession: replaceWith,\n rollbackSession: replaceWith,\n ...(persister && projectId !== undefined\n ? {\n dispatch: async (next: CmsDocument) => {\n // Make sure the persisted baseline + every queued mutation\n // landed first, then issue the commit's single command.\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n return operations.documents.upsert({ projectId, document: next })\n },\n }\n : {}),\n },\n input,\n )\n },\n [registry, localeConfig, projectId],\n )\n\n // Shared insert sequence (EC-326): existingIds/mint/seedDefaults (via\n // `buildNewDocument`) + optimistic append + persist, consumed by both\n // `createDocument` (always inserts) and `ensureSingletonDocument`'s empty\n // branch (`guardExisting: true` — re-checks \"no document for this collection\n // yet\" against the LATEST `prev` inside the `setDocuments` updater, not the\n // `documentsRef.current` snapshot the caller already checked, so a\n // concurrent invocation — StrictMode's double-invoked effect — can never\n // materialize a second singleton document).\n const insertNewDocument = useCallback(\n (collectionId: string, options?: { guardExisting?: boolean }): CmsDocument => {\n const doc = buildNewDocument(collectionId, registry, seq, documentsRef.current)\n setDocuments((prev) =>\n options?.guardExisting && hasDocumentFor(prev, collectionId) ? prev : [...prev, doc],\n )\n persisterRef.current?.upsertDocument(doc)\n return doc\n },\n [registry],\n )\n\n const createDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const doc = insertNewDocument(collectionId)\n return { collection: collectionId, id: doc.id }\n },\n [insertNewDocument],\n )\n\n // EC-274 (re-scopes EC-217): a singleton is a UI lens, not a fixed id. Resolve\n // the collection's lone document and return its ref; if none exists yet, create\n // one with a NORMAL generated id (never the collection id — no code ever names a\n // literal doc id). Idempotent under React effects/StrictMode: the create guard\n // keys on \"any document in this collection\", so a re-invocation never adds a\n // second. On drift (>1 doc) the studio routes to the list, so this defensively\n // returns the first; the empty draft persists like any create.\n const ensureSingletonDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const collection = registry.get(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, documentsRef.current)\n : ({ kind: 'empty' } as const)\n if (resolution.kind === 'ready') {\n return { collection: collectionId, id: resolution.doc.id }\n }\n if (resolution.kind === 'drift') {\n return { collection: collectionId, id: resolution.docs[0]!.id }\n }\n // Empty: create the lone document once. The ref guard (synchronous) plus the\n // updater's \"any doc in collection\" check make this idempotent under a\n // re-invoked effect or StrictMode's double mount — never a second draft.\n const existing = documentsRef.current.find((d) => d.collection === collectionId)\n if (existing) return { collection: collectionId, id: existing.id }\n if (ensuredSingletons.current.has(collectionId)) {\n return { collection: collectionId, id: `new-${collectionId}-pending` }\n }\n ensuredSingletons.current.add(collectionId)\n // EC-316: same collision-free mint as `createDocument` (via the shared\n // `insertNewDocument` — defensive here, the singleton-empty branch only\n // runs when no document exists yet).\n const doc = insertNewDocument(collectionId, { guardExisting: true })\n return { collection: collectionId, id: doc.id }\n },\n [registry, insertNewDocument],\n )\n\n const deleteDocument = useCallback((ref: DocumentRef) => {\n setDocuments((prev) => removeDoc(prev, ref))\n persisterRef.current?.deleteDocument(ref)\n }, [])\n\n // EC-224: published-ness IS the version pointer (`publishedKeys`) — the SOLE\n // studio source of truth, read via `isPublished`. The live row stays a\n // continuous draft (Sanity model); no flat `state` mirror is maintained. Every\n // reader now consults the pointer (the table badge/$state via `isPublished`,\n // the preview engine via the pin), so the flat field is read by nothing here.\n const setPublished = useCallback((ref: DocumentRef, published: boolean) => {\n const key = documentKey(ref)\n setPublishedKeys((prev) => {\n if (prev.has(key) === published) return prev\n const next = new Set(prev)\n if (published) next.add(key)\n else next.delete(key)\n return next\n })\n }, [])\n\n const isPublished = useCallback(\n (ref: DocumentRef) => publishedKeys.has(documentKey(ref)),\n [publishedKeys],\n )\n\n // Reconcile published-ness for a ref against the AUTHORITATIVE backend record\n // (EC-225): the optimistic flip is a guess; once the queued op settles we read\n // the actual pin so the badge can never claim a state the backend refused\n // (a publish blocked by field rules, an unpublish blocked by a strict ref).\n const reconcilePublished = useCallback(\n async (ref: DocumentRef) => {\n if (projectId === undefined) return\n const { operations } = await getStudioOperations()\n const record = await operations.documents.get({ projectId, ref })\n if (record.ok) setPublished(ref, record.value.publishedVersion !== undefined)\n },\n [projectId, setPublished],\n )\n\n const publishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, true) // optimistic\n // EC-273: no clearing here — the draft is already free of conditionally-hidden\n // values (the editor clears them on write), so the snapshot the publish op\n // pins is clean by construction.\n persisterRef.current?.publishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const unpublishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, false) // optimistic\n persisterRef.current?.unpublishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const loadDocumentVersions = useCallback(\n async (ref: DocumentRef): Promise<DocumentVersionsView> => {\n // No persisted backend (fixture/playground): no recorded history.\n if (projectId === undefined) return { versions: [] }\n const { operations } = await getStudioOperations()\n const [versionsRes, recordRes] = await Promise.all([\n operations.documents.listVersions({ projectId, ref }),\n operations.documents.get({ projectId, ref }),\n ])\n if (!versionsRes.ok) {\n setPersistError(versionsRes.error)\n return { versions: [] }\n }\n // The pinned (live) version comes off the document record; a never-saved\n // doc simply has no record (and no versions) — not an error to surface.\n const publishedVersion = recordRes.ok ? recordRes.value.publishedVersion : undefined\n return {\n versions: versionsRes.value,\n ...(publishedVersion !== undefined ? { publishedVersion } : {}),\n }\n },\n [projectId],\n )\n\n const restoreDocumentVersion = useCallback(\n async (\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null> => {\n if (projectId === undefined) return null\n // Land any queued edits before the restore reads the current draft to\n // snapshot it (same ordering contract as commitFieldEdit/runBulk). This is\n // what makes a granular (field/block) restore merge over the LATEST draft.\n await persisterRef.current?.ensureBaseline()\n const { operations } = await getStudioOperations()\n const result = await operations.documents.restore({\n projectId,\n ref,\n version,\n ...(scope ? { scope } : {}),\n })\n if (!result.ok) {\n setPersistError(result.error)\n return null\n }\n const restored = result.value.document\n // Pure map-replace: a restore always targets a document already open in\n // the session.\n setDocuments((prev) => replaceDoc(prev, restored))\n return restored\n },\n [projectId],\n )\n\n const validate = useCallback(\n (doc: CmsDocument) =>\n validateDocument(registry, doc, {\n store,\n localeConfig,\n validateComposition,\n validateRichTextEmbeds,\n // EC-224: the EC-173 weak-reference warning sources published-ness from\n // the version pointer, so editing a published doc that references an\n // unpublished target surfaces the fallback warning again (it had gone\n // inert once the flat `state` mirror was dropped in B-3b).\n isPublished,\n assetExists,\n }),\n [registry, store, localeConfig, isPublished, assetExists],\n )\n\n const importDocuments = useCallback(\n (collectionId: string, raw: unknown[]): ImportReport => {\n const report: ImportReport = { added: 0, rejected: [] }\n // Pre-parse so intra-batch relation/asset targets resolve during validation.\n const parsedBatch: CmsDocument[] = []\n const schemaFails: { item: unknown; error: ReturnType<typeof documentSchema.safeParse> }[] =\n []\n for (const item of raw) {\n const parsed = documentSchema.safeParse({ ...(item as object), collection: collectionId })\n if (parsed.success) parsedBatch.push(parsed.data)\n else schemaFails.push({ item, error: parsed })\n }\n for (const { item, error } of schemaFails) {\n report.rejected.push({\n id: (item as { id?: string })?.id ?? translate('cms.list.import.noId'),\n issues: (error.success ? [] : error.error.issues).map((e) => ({\n code: 'invalid-field-value' as const,\n severity: 'error' as const,\n message: e.message,\n path: e.path.map((p) => (typeof p === 'symbol' ? String(p) : p)),\n })),\n })\n }\n // Validate each against existing docs PLUS the rest of the batch.\n const batchStore = createDocumentStore([...documents, ...parsedBatch])\n const accepted: CmsDocument[] = []\n for (const doc of parsedBatch) {\n const issues = validateDocument(registry, doc, { store: batchStore, localeConfig, assetExists })\n const errors = issues.filter((iss) => iss.severity === 'error')\n if (errors.length > 0) report.rejected.push({ id: doc.id, issues: errors })\n else accepted.push(doc)\n }\n if (accepted.length > 0) {\n // Replace-or-append (upsert): an imported row may be brand new to the\n // session, so each accepted document must land even with no prior\n // entry for its ref.\n setDocuments((prev) => accepted.reduce((acc, doc) => upsertDoc(acc, doc), prev))\n for (const doc of accepted) persisterRef.current?.upsertDocument(doc)\n // EC-224: imports land as the working DRAFT. Publish-ness is the version\n // pointer (`publishedKeys`), set by publishing — never carried in the\n // imported row — so an import never auto-publishes; the editor publishes\n // explicitly afterward.\n report.added = accepted.length\n }\n return report\n },\n [registry, documents, localeConfig, assetExists],\n )\n\n const isFieldReadOnly = useCallback((field: FieldDef) => field.form?.readOnly === true, [])\n\n // --- Views (EC-246b: config-as-code) --------------------------------------\n\n const viewsOf = useCallback(\n (collectionId: string): SavedView[] => {\n // The built-in default plus the collection's config-declared views (EC-246b).\n // Views are PRESENTATION, read live from elytra.config.ts (AD-11) — not the\n // persisted content schema the session booted from — so they reflect code\n // immediately without a re-seed (the persisted schema is only baselined on\n // first run). The EC-169 DB saved-view store is retired: shared views are\n // code, editors keep only transient in-session tweaks + Reset.\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n return [\n defaultView(registry.get(collectionId)),\n ...(configCollection ? configViewsFor(configCollection) : []),\n ]\n },\n [registry],\n )\n\n // The INITIAL active view for a collection (EC-343): a config view flagged\n // `default: true` seeds the first-load lens; else the built-in \"All\" default. Only\n // consulted before the editor has picked a view (`activeViews[id]` wins once set),\n // so transient switching + Reset are unaffected. A duplicate `default` is warned\n // once (never silent) and the first-declared default seeds deterministically.\n const initialViewId = useCallback((collectionId: string): string => {\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n if (!configCollection) return ALL_VIEW_ID\n warnDuplicateDefaultViews(configCollection)\n return defaultConfigViewId(configCollection) ?? ALL_VIEW_ID\n }, [])\n\n const activeViewOf = useCallback(\n (collectionId: string): SavedView => {\n const id = activeViews[collectionId] ?? initialViewId(collectionId)\n return (\n viewsOf(collectionId).find((view) => view.id === id) ??\n defaultView(registry.get(collectionId))\n )\n },\n [activeViews, initialViewId, viewsOf, registry],\n )\n\n const tableStateOf = useCallback(\n (collectionId: string): TableViewState =>\n tableStates[collectionId] ?? activeViewOf(collectionId).state,\n [tableStates, activeViewOf],\n )\n\n const dropTableState = useCallback((collectionId: string) => {\n setTableStates((prev) => {\n if (!(collectionId in prev)) return prev\n const next = { ...prev }\n delete next[collectionId]\n return next\n })\n }, [])\n\n const setActiveView = useCallback(\n (collectionId: string, viewId: string) => {\n setActiveViews((prev) => ({ ...prev, [collectionId]: viewId }))\n dropTableState(collectionId)\n },\n [dropTableState],\n )\n\n // --- Bulk actions (EC-169) ------------------------------------------------\n\n const runBulk = useCallback(\n async (\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport> => {\n const collection = registry.get(collectionId)\n // A set-field needs both the field payload AND the collection def to fold\n // the value the locale-aware way — guard so a misconfigured call fails\n // loud rather than silently no-opping each item.\n if (action === 'set-field' && (!setField || !collection)) {\n return {\n action,\n ...(setField ? { setField } : {}),\n results: ids.map((id) => ({\n ref: { collection: collectionId, id },\n title: titleOf({ collection: collectionId, id }),\n ok: false,\n reason: translate('cms.list.bulk.error.invalidSetField'),\n error: { code: 'unknown', message: 'Invalid set-field request.' },\n })),\n }\n }\n // The next document for a set-field item: fold the value into the active\n // locale's bag (localized) or the shared `values` (non-localized).\n const setFieldDoc = (doc: CmsDocument): CmsDocument =>\n applyCellValue(collection!, doc, setField!.field, activeLocale, setField!.value)\n\n let dispatch:\n | ((action: BulkAction, ref: DocumentRef) => Promise<OperationResult<unknown>>)\n | undefined\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n // Pending queued mutations + baseline land first, then one awaited\n // command per item (same ordering contract as commitFieldEdit).\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n dispatch = (bulkAction, ref) => {\n if (bulkAction === 'delete') return operations.documents.delete({ projectId, ref })\n if (bulkAction === 'publish') return operations.documents.publish({ projectId, ref })\n if (bulkAction === 'unpublish') return operations.documents.unpublish({ projectId, ref })\n // set-field: upsert the document carrying the new value. The write\n // path self-types it through the schema lens (EC-277); a scalar field\n // stores its scalar as-is.\n const current = documentsRef.current.find((d) => matchesRef(d, ref))\n if (!current) {\n return Promise.resolve<OperationResult<unknown>>({\n ok: false,\n error: {\n code: 'not-found',\n message: 'Document is no longer in the session.',\n entity: 'cms-document',\n key: `${ref.collection}:${ref.id}`,\n },\n })\n }\n return operations.documents.upsert({ projectId, document: setFieldDoc(current) })\n }\n }\n return runBulkAction(\n {\n documents: documentsRef.current,\n titleOf,\n validate: (doc) =>\n validateDocument(registry, doc, {\n store: createDocumentStore(documentsRef.current),\n localeConfig,\n // EC-225: include the composition validators so a bulk PUBLISH\n // gates blocks/richText validity the same way the detail editor\n // does — the operations-layer publish gate has no component\n // registry, so composition validity is a studio-validation invariant.\n validateComposition,\n validateRichTextEmbeds,\n assetExists,\n }),\n // EC-224: a succeeded publish/unpublish moves the version pointer\n // (`publishedKeys`) via setPublished — there is no separate flat\n // `state` mirror to keep in sync (published-ness is derived from the\n // pointer set).\n applyState: (ref, state) => setPublished(ref, state === 'published'),\n applyDelete: (ref) => setDocuments((prev) => removeDoc(prev, ref)),\n // EC-247: fold the new value into the session document (same\n // locale-aware path the dispatched upsert used). Not a plain\n // `replaceDoc` — the replacement is computed FROM each matched\n // document (`setFieldDoc(d)`), not a fixed value to swap in.\n applySetField: (ref) =>\n setDocuments((prev) => prev.map((d) => (matchesRef(d, ref) ? setFieldDoc(d) : d))),\n ...(dispatch ? { dispatch } : {}),\n },\n collectionId,\n ids,\n action,\n setField,\n )\n },\n [projectId, titleOf, registry, localeConfig, activeLocale, setPublished, assetExists],\n )\n\n const store$ = useMemo<CmsStore>(\n () => ({\n ...(projectId !== undefined ? { projectId } : {}),\n collections,\n localeConfig,\n activeLocale,\n getCollection,\n documentsOf: (collectionId) => documents.filter((d) => d.collection === collectionId),\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViewId: (collectionId) => activeViews[collectionId] ?? initialViewId(collectionId),\n setActiveView,\n tableStateOf,\n setTableState: (collectionId, update) =>\n setTableStates((prev) => {\n const current = prev[collectionId] ?? activeViewOf(collectionId).state\n const next = typeof update === 'function' ? update(current) : update\n return { ...prev, [collectionId]: next }\n }),\n isViewDirty: (collectionId) => {\n const working = tableStates[collectionId]\n if (working === undefined) return false\n const active = activeViewOf(collectionId).state\n const collection = registry.get(collectionId)\n if (collection === undefined) return !viewStatesEqual(working, active)\n // Compare schema-resolved forms (EC-213): a column-order reconciliation\n // or a stale `hidden` entry must not read as an unsaved edit.\n return !viewStatesEqual(\n canonicalViewState(collection, working),\n canonicalViewState(collection, active),\n )\n },\n resetTableState: dropTableState,\n runBulk,\n addCollection: (def) =>\n setCollections((prev) => [...prev.filter((c) => c.id !== def.id), def]),\n persistError,\n clearPersistError: () => setPersistError(null),\n ensurePersistedBaseline: () => persisterRef.current?.ensureBaseline() ?? Promise.resolve(),\n flushPersistence: () => persisterRef.current?.flush() ?? Promise.resolve(),\n }),\n [\n projectId,\n collections,\n documents,\n localeConfig,\n activeLocale,\n getCollection,\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViews,\n activeViewOf,\n initialViewId,\n tableStates,\n tableStateOf,\n setActiveView,\n dropTableState,\n runBulk,\n registry,\n persistError,\n ],\n )\n\n return <CmsContext.Provider value={store$}>{children}</CmsContext.Provider>\n}\n\nexport { useCms }\n\nexport { primaryField }\nexport type { Locale }\n"]}
|
|
1
|
+
{"version":3,"file":"cms-store.js","sourceRoot":"","sources":["../../../src/components/cms/cms-store.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,E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M,CAAC,CACvC,CAAA;QACH,CAAC;QACD,eAAe,EAAE,cAAc;QAC/B,OAAO;QACP,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CACrB,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACzE,YAAY;QACZ,iBAAiB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAC9C,uBAAuB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;QAC1F,gBAAgB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;KAC3E,CAAC,EACF;QACE,SAAS;QACT,WAAW;QACX,SAAS;QACT,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,WAAW;QACX,OAAO;QACP,YAAY;QACZ,eAAe;QACf,cAAc;QACd,uBAAuB;QACvB,cAAc;QACd,WAAW;QACX,eAAe;QACf,iBAAiB;QACjB,oBAAoB;QACpB,sBAAsB;QACtB,eAAe;QACf,QAAQ;QACR,eAAe;QACf,OAAO;QACP,WAAW;QACX,YAAY;QACZ,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,cAAc;QACd,OAAO;QACP,QAAQ;QACR,YAAY;KACb,CACF,CAAA;IAED,OAAO,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,QAAQ,GAAuB,CAAA;AAC7E,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,OAAO,EAAE,YAAY,EAAE,CAAA","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport {\n createCollectionRegistry,\n createDocumentStore,\n documentKey,\n documentSchema,\n resolveDocumentTitle,\n resolveField,\n sampleDocuments,\n seedDefaults,\n sampleFilterableCollections,\n sampleLocaleConfig,\n samplePublishedKeys,\n resolveSingletonDocument,\n titleFieldOf,\n validateDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CmsValidationIssue,\n CollectionDef,\n CollectionRegistry,\n DocumentRef,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n RestoreScope,\n} from '@elytracms/core/cms-core'\nimport type { DocumentVersionRecord } from '@elytracms/core/persistence'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { configureStudioLocales, useStudioLocale } from '@elytracms/studio/lib/locale'\nimport { studioManifestLookup } from '@elytracms/studio/lib/registry'\nimport { resolveDeploymentCollections } from '@elytracms/studio/lib/workspace'\nimport { validateComposition, validateRichTextEmbeds } from './cms-composition-validators'\nimport { matchesRef, removeDoc, replaceDoc, upsertDoc } from './document-ref-utils'\nimport { createRequiredContext } from '@elytracms/studio/lib/required-context'\nimport { createCmsPersister, getStudioOperations } from '@elytracms/studio/lib/operations'\nimport type {\n CmsPersister,\n OperationError,\n OperationResult,\n} from '@elytracms/studio/lib/operations'\nimport {\n ALL_VIEW_ID,\n canonicalViewState,\n configViewIssues,\n configViewsFor,\n defaultConfigViewId,\n defaultViewState,\n viewStatesEqual,\n} from '@elytracms/studio/lib/cms-views'\nimport type { TableViewState } from '@elytracms/studio/lib/cms-views'\nimport { useOptionalAssets } from '../assets/assets-store'\nimport { consumeStagedDocuments } from './document-staging'\nimport { applyCellValue, commitCellEdit } from './cell-edit'\nimport type { CellCommitInput, CellCommitOutcome } from './cell-edit'\nimport { runBulkAction } from './bulk-actions'\nimport type { BulkAction, BulkReport, BulkSetField } from './bulk-actions'\nimport { cleanHiddenForPublish } from './publish-clean'\n\n/**\n * A resolved table view: a named bundle of filters (closed AD-3 vocabulary),\n * sort, and visible/ordered columns. EC-246b: named views are **config-as-code**\n * (declared in `cms/`, read live via `configViewsFor`) — the editor-owned DB\n * saved-view store (EC-169) is retired. The unnamed \"All documents\" default is\n * derived per collection; editors keep only transient in-session tweaks + Reset.\n */\nexport interface SavedView {\n id: string\n /**\n * The view label — a {@link LocalizedString} (EC-343): the built-in \"All\" default is\n * a plain translated string; a config view's name may be a `{ locale }` map, resolved\n * at the render site (`ViewTabs`) via the same `resolveLabel` path as `form.label`.\n */\n name: LocalizedString\n state: TableViewState\n}\n\nexport interface ImportReport {\n added: number\n rejected: { id: string; issues: CmsValidationIssue[] }[]\n}\n\n/**\n * A document's recorded version history plus its live pin (EC-224), as the\n * Versions inspector pane reads it. `versions` is newest-first; `publishedVersion`\n * is the recorded version currently pinned live, absent when unpublished.\n */\nexport interface DocumentVersionsView {\n versions: DocumentVersionRecord[]\n publishedVersion?: number\n}\n\nexport interface CmsStore {\n /** The project this CMS session edits (set when persistence is enabled); the asset picker scopes the real library by it (EC-152). */\n projectId?: string\n collections: readonly CollectionDef[]\n localeConfig: LocaleConfig\n /**\n * The studio's ambient active locale (EC-176): table cells, detail forms,\n * and inline edits all display and write THIS locale. Switched once via the\n * shared `LocaleSwitcher`, never per control.\n */\n activeLocale: Locale\n getCollection(id: string): CollectionDef | undefined\n documentsOf(collectionId: string): CmsDocument[]\n getDocument(ref: DocumentRef): CmsDocument | undefined\n /** Resolve a relation/asset target's display title. */\n titleOf(ref: DocumentRef): string\n saveDocument(doc: CmsDocument): void\n /**\n * Commit ONE field edit from the table (EC-168): optimistic session apply +\n * exactly one `documents.upsert` operations command, awaited. Validation\n * failures and operation rejections return a structured error (the caller\n * renders it on the cell) and leave the session rolled back.\n */\n commitFieldEdit(input: CellCommitInput): Promise<CellCommitOutcome>\n createDocument(collectionId: string): DocumentRef\n /**\n * Ensure a singleton collection's lone document exists and return its ref\n * (EC-274). Resolves the existing single document, or creates one with a normal\n * generated id (never the collection id). Idempotent. The singleton route opens\n * through this so the one document always exists to edit.\n */\n ensureSingletonDocument(collectionId: string): DocumentRef\n deleteDocument(ref: DocumentRef): void\n /**\n * Is this document currently published? Sourced from the version POINTER\n * (EC-224), not the flat `state` enum — seeded from hydration and updated by\n * {@link publishDocument}/{@link unpublishDocument}.\n */\n isPublished(ref: DocumentRef): boolean\n /**\n * Publish: snapshot the draft as a new version and pin it live (EC-224).\n * Flips published-ness optimistically, then reconciles against the backend\n * record (EC-225) so the badge can never claim a publish the backend refused\n * (e.g. blocked by publish-time field validation).\n */\n publishDocument(ref: DocumentRef): Promise<void>\n /**\n * Unpublish: clear the live version pin (EC-224). Blocked at the operations\n * layer while strict relation fields published-reference it (EC-173); the\n * optimistic flip reconciles against the backend on rejection (EC-225).\n */\n unpublishDocument(ref: DocumentRef): Promise<void>\n /**\n * Load this document's recorded version history + live pin (EC-224) for the\n * Versions inspector pane. Fixture/playground sessions (no project) have no\n * persisted history → an empty view. Failures surface as {@link persistError}.\n */\n loadDocumentVersions(ref: DocumentRef): Promise<DocumentVersionsView>\n /**\n * Restore a recorded version as the new working draft (EC-224): the operation\n * snapshots the current draft first (so the rollback is itself undoable), then\n * loads the chosen snapshot. An optional `scope` (EC-298) restores only one\n * field or block, laid over the current draft, instead of the whole document.\n * Returns the restored draft (or null on failure/fixture session) so the open\n * editor can adopt it.\n */\n restoreDocumentVersion(\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null>\n importDocuments(collectionId: string, docs: unknown[]): ImportReport\n validate(doc: CmsDocument): CmsValidationIssue[]\n isFieldReadOnly(field: FieldDef): boolean\n // Views (EC-246b): the built-in default + config-declared named views (from\n // `cms/`, read live). Shared views are code, not editor-owned DB data.\n viewsOf(collectionId: string): SavedView[]\n activeViewId(collectionId: string): string\n /** Switch views — resets the working table state to the view's state. */\n setActiveView(collectionId: string, viewId: string): void\n /** The live table state (the active view's state plus unsaved edits). */\n tableStateOf(collectionId: string): TableViewState\n /**\n * Update the working state. Always pass an updater when deriving from the\n * previous state — render-time snapshots go stale across rapid events.\n */\n setTableState(\n collectionId: string,\n update: TableViewState | ((prev: TableViewState) => TableViewState),\n ): void\n /** Does the working state diverge from the active view (\"unsaved changes\")? */\n isViewDirty(collectionId: string): boolean\n /** Discard working-state edits, back to the active view. */\n resetTableState(collectionId: string): void\n /**\n * Bulk publish/unpublish/delete (EC-169) + set-field (EC-247): one operations\n * command PER item, per-item outcomes in the report — partial failure is\n * enumerated, never silent. Only succeeded items mutate the session. A\n * `set-field` carries its `{ field, value }` payload.\n */\n runBulk(\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport>\n /**\n * Mirror a collection into the session (e.g. an accepted AI-generated\n * schema, EC-097). Replaces by id. Session-only: persistence happens through\n * the accept flow's changeset (`schema.upsertCollection`), not here.\n */\n addCollection(def: CollectionDef): void\n /**\n * Most recent failed/denied persisted mutation (structured, from the\n * operation result). Rendered by the CMS surface — never a silent failure.\n */\n persistError: OperationError | null\n clearPersistError(): void\n /** Seed the persisted baseline now (e.g. before applying an AI changeset). */\n ensurePersistedBaseline(): Promise<void>\n /** Await all queued persisted mutations (tests, publish flows). */\n flushPersistence(): Promise<void>\n}\n\nconst { Context: CmsContext, useRequired: useCms } = createRequiredContext<CmsStore>('Cms')\n\nfunction primaryField(collection: CollectionDef): string {\n return titleFieldOf(collection)?.name ?? collection.fields[0]?.name ?? 'id'\n}\n\n/**\n * EC-316 (bug fix) — mint a fresh, COLLISION-FREE document id for `+ New`.\n *\n * `seq` is an in-memory, per-session counter (reset to 0 on every reload). A\n * document minted `new-<collection>-<n>` in a PRIOR session can already occupy\n * whatever `n` this session's counter would next reissue — the pre-fix bug:\n * `+ New` on a `post` collection that already held a (possibly published)\n * `new-post-1` handed out that SAME id again, silently opening the existing\n * document for editing instead of creating a fresh draft. Walking the counter\n * past every id already in `existingIds` makes the mint collision-free\n * regardless of what a prior session left behind.\n */\nexport function mintDocumentId(\n collectionId: string,\n seq: { current: number },\n existingIds: ReadonlySet<string>,\n): string {\n let id: string\n do {\n seq.current += 1\n id = `new-${collectionId}-${seq.current}`\n } while (existingIds.has(id))\n return id\n}\n\n/**\n * Build a fresh document for `collectionId`: a collision-free id (EC-316, via\n * {@link mintDocumentId} against every id `existingDocs` already holds for\n * this collection) and the collection's declared field defaults (EC-297, via\n * `seedDefaults`). Pure — the sensitive part of the insert sequence shared by\n * `createDocument` and `ensureSingletonDocument`'s empty branch (via the\n * private `insertNewDocument` below), factored out so it's unit-testable\n * without a `CmsProvider`.\n */\nexport function buildNewDocument(\n collectionId: string,\n registry: CollectionRegistry,\n seq: { current: number },\n existingDocs: readonly CmsDocument[],\n): CmsDocument {\n const existingIds = new Set(\n existingDocs.filter((d) => d.collection === collectionId).map((d) => d.id),\n )\n const id = mintDocumentId(collectionId, seq, existingIds)\n const collection = registry.get(collectionId)\n return { collection: collectionId, id, values: collection ? seedDefaults(collection) : {} }\n}\n\n/**\n * Does `docs` already hold a document for `collectionId`? `ensureSingletonDocument`'s\n * empty branch re-checks this INSIDE the `setDocuments` updater (against the\n * latest `prev`, not a stale snapshot) so a concurrent invocation — StrictMode's\n * double-invoked effect, or a second caller racing the same synchronous guard —\n * can never materialize a second singleton document.\n */\nexport function hasDocumentFor(docs: readonly CmsDocument[], collectionId: string): boolean {\n return docs.some((d) => d.collection === collectionId)\n}\n\n/**\n * Surface a duplicate `default: true` across a collection's config views (EC-343) as\n * a visible, one-time console warning — never a silent swallow. This is a developer\n * config mistake (editors can't fix config-as-code), so it takes the same warn-once\n * console channel the i18n runtime uses for config problems, not an editor banner;\n * the first-declared default still seeds deterministically. Deduped per collection id.\n */\nconst warnedDuplicateDefaultCollections = new Set<string>()\nfunction warnDuplicateDefaultViews(collection: CollectionDef): void {\n if (warnedDuplicateDefaultCollections.has(collection.id)) return\n const issues = configViewIssues(collection)\n if (issues.length === 0) return\n warnedDuplicateDefaultCollections.add(collection.id)\n if (typeof console !== 'undefined') console.warn(`[views] ${issues[0]!.message}`)\n}\n\n/** The unnamed built-in view: no filters, no sort, every field visible. */\nfunction defaultView(collection: CollectionDef | undefined): SavedView {\n return {\n id: ALL_VIEW_ID,\n name: translate('cms.list.view.all'),\n state: collection\n ? defaultViewState(collection)\n : { filters: [], sort: null, columns: [], hidden: [] },\n }\n}\n\n/**\n * The CMS session store (EC-141): documents and collections are optimistic,\n * synchronous session state (live validation while typing); every mutation —\n * create/save/delete/state transitions — is mirrored onto the operations\n * layer (`documents.*` / `schema.*` commands) through {@link createCmsPersister}.\n * Failed/denied commands surface as {@link CmsStore.persistError}.\n */\nexport function CmsProvider({\n children,\n projectId,\n initialCollections,\n initialDocuments,\n initialPublishedKeys,\n initialLocaleConfig,\n}: {\n children: ReactNode\n /** Enables persistence through the shared operations client. */\n projectId?: string\n /** Seed collections (e.g. from an imported starter kit, EC-119); defaults to the samples. */\n initialCollections?: CollectionDef[]\n initialDocuments?: CmsDocument[]\n /**\n * Published document keys from hydration (EC-224): the version pointer\n * (`publishedVersion` set). Absent (kit / fixture sessions) → the sample\n * fixtures' published set (`samplePublishedKeys`).\n */\n initialPublishedKeys?: readonly string[]\n /** Locale config for the seeded content; defaults to the sample config. */\n initialLocaleConfig?: LocaleConfig\n}) {\n const [documents, setDocuments] = useState<CmsDocument[]>(() => {\n const seeded = (initialDocuments ?? sampleDocuments).map((d) => structuredClone(d))\n // EC-320 (0.0.44 follow-up): merge any documents STAGED by the\n // Components-view \"Use in document…\" transfer — a cross-mount handoff in\n // EVERY mode now (see document-staging.ts), not just the playground. The\n // merge rule itself stays mode-aware there: playground's seeded set is a\n // static baseline that never reflects a write (staged always wins);\n // Convex's is a fresh per-mount hydration query (staged fills gaps only,\n // dropped once the seeded set actually carries the key).\n return consumeStagedDocuments(projectId, seeded)\n })\n // Published-ness as the version POINTER (EC-224), decoupled from the flat\n // `state` enum: seeded from hydration's pointer set, or — when none is supplied\n // — the canonical sample published set for the playground. A kit's imported\n // content (`initialDocuments` without a pointer set) starts unpublished\n // (drafts) until an editor publishes it. The flat `state` is never consulted.\n const [publishedKeys, setPublishedKeys] = useState<Set<string>>(() => {\n if (initialPublishedKeys) return new Set(initialPublishedKeys)\n return new Set(initialDocuments ? [] : samplePublishedKeys)\n })\n const [activeViews, setActiveViews] = useState<Record<string, string>>({})\n // The live table state per collection where it diverges from the active\n // view; absent key = exactly the active view's state (not dirty).\n const [tableStates, setTableStates] = useState<Record<string, TableViewState>>({})\n // Collections are stateful so AI-generated schemas (EC-097) can be accepted\n // into the session. The session schema IS the source the sort/filter\n // offering follows (EC-177 gap 3): hydrated sessions receive the persisted\n // schema via `initialCollections`; the fixture fallback is the canonical\n // cms-core sample schema WITH its declared `filterable` flags — no\n // session-side widenings, so the studio never offers a field the backend's\n // delivery engine would reject.\n const [collections, setCollections] = useState<CollectionDef[]>(() => [\n ...(initialCollections ?? sampleFilterableCollections),\n ])\n const [persistError, setPersistError] = useState<OperationError | null>(null)\n const seq = useRef(0)\n // EC-274: collection ids whose lone singleton document this session has already\n // created — a synchronous guard so a re-invoked effect (or StrictMode's double\n // mount) never materializes a second document under a freshly generated id.\n const ensuredSingletons = useRef<Set<string>>(new Set())\n\n // Latest session state for the persister's lazy baseline (no re-subscribing).\n const collectionsRef = useRef(collections)\n collectionsRef.current = collections\n const documentsRef = useRef(documents)\n documentsRef.current = documents\n\n const persisterRef = useRef<CmsPersister | null>(null)\n if (persisterRef.current === null && projectId !== undefined) {\n persisterRef.current = createCmsPersister({\n projectId,\n getOperations: async () => (await getStudioOperations()).operations,\n getCollections: () => collectionsRef.current,\n getDocuments: () => documentsRef.current,\n // EC-277: self-type composition static props on write (the manifest half of\n // the lens), so extraction stays schema-free. Document fields self-type via\n // the schema alone (above); the registry adds blocks/embed prop coverage.\n lookupManifest: studioManifestLookup(),\n onError: setPersistError,\n })\n }\n\n const registry = useMemo(() => createCollectionRegistry(collections), [collections])\n const store = useMemo(() => createDocumentStore(documents), [documents])\n const localeConfig = initialLocaleConfig ?? sampleLocaleConfig\n\n // Asset existence is validated against the REAL asset library (assets live in\n // their own repository, not as CMS documents). With the ambient AssetsProvider\n // present, the oracle is the set of uploaded asset ids — but only once loaded;\n // while it loads we are optimistic so a valid upload is never transiently\n // flagged \"unknown\". With no provider (tests/fixtures), the oracle is absent\n // and asset existence falls back to the document store.\n const assetStore = useOptionalAssets()\n const assetExists = useMemo<((id: string) => boolean) | undefined>(() => {\n if (!assetStore) return undefined\n if (assetStore.status !== 'ready') return () => true\n const ids = new Set(assetStore.assets.map((asset) => asset.id))\n return (id) => ids.has(id)\n }, [assetStore])\n\n // The ambient studio locale (EC-176): this session's locale config drives\n // the switcher options; every CMS surface follows the one active locale.\n const { locale: activeLocale } = useStudioLocale()\n useEffect(() => {\n configureStudioLocales(localeConfig)\n }, [localeConfig])\n\n const getCollection = useCallback((id: string) => registry.get(id), [registry])\n\n const getDocument = useCallback(\n (ref: DocumentRef) => documents.find((d) => matchesRef(d, ref)),\n [documents],\n )\n\n const titleOf = useCallback(\n (ref: DocumentRef) => {\n const doc = documents.find((d) => matchesRef(d, ref))\n const collection = registry.get(ref.collection)\n if (!doc || !collection) return ref.id\n // EC-296/EC-242: a function `titleField` (title pattern) composes the title\n // from the document's resolved values (active locale). Only resolve the full\n // value set when a function is declared — the common string `titleField` case\n // still resolves the single title field below (primaryField === the title field).\n if (typeof collection.titleField === 'function') {\n const values: Record<string, unknown> = {}\n for (const field of collection.fields) {\n values[field.name] = resolveField(collection, doc, field.name, activeLocale, localeConfig).value\n }\n return resolveDocumentTitle(collection, values, ref.id)\n }\n // Resolve through the locale layer in the ambient active locale (EC-176)\n // with EC-018 fallback, so localized titles follow the switcher.\n const { value } = resolveField(\n collection,\n doc,\n primaryField(collection),\n activeLocale,\n localeConfig,\n )\n return typeof value === 'string' && value ? value : ref.id\n },\n [documents, registry, localeConfig, activeLocale],\n )\n\n const saveDocument = useCallback((doc: CmsDocument) => {\n // Replace-or-append (upsert): a brand-new document must still land even\n // though nothing in the session matches its ref yet.\n setDocuments((prev) => upsertDoc(prev, doc))\n persisterRef.current?.upsertDocument(doc)\n }, [])\n\n const commitFieldEdit = useCallback(\n (input: CellCommitInput): Promise<CellCommitOutcome> => {\n // Pure map-replace: an edit always targets a document already open in\n // the session, so a miss (already gone) is a no-op, never an append.\n const replaceWith = (doc: CmsDocument) => setDocuments((prev) => replaceDoc(prev, doc))\n const persister = persisterRef.current\n return commitCellEdit(\n {\n registry,\n documents: documentsRef.current,\n localeConfig,\n applySession: replaceWith,\n rollbackSession: replaceWith,\n ...(persister && projectId !== undefined\n ? {\n dispatch: async (next: CmsDocument) => {\n // Make sure the persisted baseline + every queued mutation\n // landed first, then issue the commit's single command.\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n return operations.documents.upsert({ projectId, document: next })\n },\n }\n : {}),\n },\n input,\n )\n },\n [registry, localeConfig, projectId],\n )\n\n // Shared insert sequence (EC-326): existingIds/mint/seedDefaults (via\n // `buildNewDocument`) + optimistic append + persist, consumed by both\n // `createDocument` (always inserts) and `ensureSingletonDocument`'s empty\n // branch (`guardExisting: true` — re-checks \"no document for this collection\n // yet\" against the LATEST `prev` inside the `setDocuments` updater, not the\n // `documentsRef.current` snapshot the caller already checked, so a\n // concurrent invocation — StrictMode's double-invoked effect — can never\n // materialize a second singleton document).\n const insertNewDocument = useCallback(\n (collectionId: string, options?: { guardExisting?: boolean }): CmsDocument => {\n const doc = buildNewDocument(collectionId, registry, seq, documentsRef.current)\n setDocuments((prev) =>\n options?.guardExisting && hasDocumentFor(prev, collectionId) ? prev : [...prev, doc],\n )\n persisterRef.current?.upsertDocument(doc)\n return doc\n },\n [registry],\n )\n\n const createDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const doc = insertNewDocument(collectionId)\n return { collection: collectionId, id: doc.id }\n },\n [insertNewDocument],\n )\n\n // EC-274 (re-scopes EC-217): a singleton is a UI lens, not a fixed id. Resolve\n // the collection's lone document and return its ref; if none exists yet, create\n // one with a NORMAL generated id (never the collection id — no code ever names a\n // literal doc id). Idempotent under React effects/StrictMode: the create guard\n // keys on \"any document in this collection\", so a re-invocation never adds a\n // second. On drift (>1 doc) the studio routes to the list, so this defensively\n // returns the first; the empty draft persists like any create.\n const ensureSingletonDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const collection = registry.get(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, documentsRef.current)\n : ({ kind: 'empty' } as const)\n if (resolution.kind === 'ready') {\n return { collection: collectionId, id: resolution.doc.id }\n }\n if (resolution.kind === 'drift') {\n return { collection: collectionId, id: resolution.docs[0]!.id }\n }\n // Empty: create the lone document once. The ref guard (synchronous) plus the\n // updater's \"any doc in collection\" check make this idempotent under a\n // re-invoked effect or StrictMode's double mount — never a second draft.\n const existing = documentsRef.current.find((d) => d.collection === collectionId)\n if (existing) return { collection: collectionId, id: existing.id }\n if (ensuredSingletons.current.has(collectionId)) {\n return { collection: collectionId, id: `new-${collectionId}-pending` }\n }\n ensuredSingletons.current.add(collectionId)\n // EC-316: same collision-free mint as `createDocument` (via the shared\n // `insertNewDocument` — defensive here, the singleton-empty branch only\n // runs when no document exists yet).\n const doc = insertNewDocument(collectionId, { guardExisting: true })\n return { collection: collectionId, id: doc.id }\n },\n [registry, insertNewDocument],\n )\n\n const deleteDocument = useCallback((ref: DocumentRef) => {\n setDocuments((prev) => removeDoc(prev, ref))\n persisterRef.current?.deleteDocument(ref)\n }, [])\n\n // EC-224: published-ness IS the version pointer (`publishedKeys`) — the SOLE\n // studio source of truth, read via `isPublished`. The live row stays a\n // continuous draft (Sanity model); no flat `state` mirror is maintained. Every\n // reader now consults the pointer (the table badge/$state via `isPublished`,\n // the preview engine via the pin), so the flat field is read by nothing here.\n const setPublished = useCallback((ref: DocumentRef, published: boolean) => {\n const key = documentKey(ref)\n setPublishedKeys((prev) => {\n if (prev.has(key) === published) return prev\n const next = new Set(prev)\n if (published) next.add(key)\n else next.delete(key)\n return next\n })\n }, [])\n\n const isPublished = useCallback(\n (ref: DocumentRef) => publishedKeys.has(documentKey(ref)),\n [publishedKeys],\n )\n\n // Reconcile published-ness for a ref against the AUTHORITATIVE backend record\n // (EC-225): the optimistic flip is a guess; once the queued op settles we read\n // the actual pin so the badge can never claim a state the backend refused\n // (a publish blocked by field rules, an unpublish blocked by a strict ref).\n const reconcilePublished = useCallback(\n async (ref: DocumentRef) => {\n if (projectId === undefined) return\n const { operations } = await getStudioOperations()\n const record = await operations.documents.get({ projectId, ref })\n if (record.ok) setPublished(ref, record.value.publishedVersion !== undefined)\n },\n [projectId, setPublished],\n )\n\n const publishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, true) // optimistic\n // EC-273: no clearing here — the draft is already free of conditionally-hidden\n // values (the editor clears them on write), so the snapshot the publish op\n // pins is clean by construction.\n persisterRef.current?.publishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const unpublishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, false) // optimistic\n persisterRef.current?.unpublishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const loadDocumentVersions = useCallback(\n async (ref: DocumentRef): Promise<DocumentVersionsView> => {\n // No persisted backend (fixture/playground): no recorded history.\n if (projectId === undefined) return { versions: [] }\n const { operations } = await getStudioOperations()\n const [versionsRes, recordRes] = await Promise.all([\n operations.documents.listVersions({ projectId, ref }),\n operations.documents.get({ projectId, ref }),\n ])\n if (!versionsRes.ok) {\n setPersistError(versionsRes.error)\n return { versions: [] }\n }\n // The pinned (live) version comes off the document record; a never-saved\n // doc simply has no record (and no versions) — not an error to surface.\n const publishedVersion = recordRes.ok ? recordRes.value.publishedVersion : undefined\n return {\n versions: versionsRes.value,\n ...(publishedVersion !== undefined ? { publishedVersion } : {}),\n }\n },\n [projectId],\n )\n\n const restoreDocumentVersion = useCallback(\n async (\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null> => {\n if (projectId === undefined) return null\n // Land any queued edits before the restore reads the current draft to\n // snapshot it (same ordering contract as commitFieldEdit/runBulk). This is\n // what makes a granular (field/block) restore merge over the LATEST draft.\n await persisterRef.current?.ensureBaseline()\n const { operations } = await getStudioOperations()\n const result = await operations.documents.restore({\n projectId,\n ref,\n version,\n ...(scope ? { scope } : {}),\n })\n if (!result.ok) {\n setPersistError(result.error)\n return null\n }\n const restored = result.value.document\n // Pure map-replace: a restore always targets a document already open in\n // the session.\n setDocuments((prev) => replaceDoc(prev, restored))\n return restored\n },\n [projectId],\n )\n\n const validate = useCallback(\n (doc: CmsDocument) =>\n validateDocument(registry, doc, {\n store,\n localeConfig,\n validateComposition,\n validateRichTextEmbeds,\n // EC-224: the EC-173 weak-reference warning sources published-ness from\n // the version pointer, so editing a published doc that references an\n // unpublished target surfaces the fallback warning again (it had gone\n // inert once the flat `state` mirror was dropped in B-3b).\n isPublished,\n assetExists,\n }),\n [registry, store, localeConfig, isPublished, assetExists],\n )\n\n const importDocuments = useCallback(\n (collectionId: string, raw: unknown[]): ImportReport => {\n const report: ImportReport = { added: 0, rejected: [] }\n // Pre-parse so intra-batch relation/asset targets resolve during validation.\n const parsedBatch: CmsDocument[] = []\n const schemaFails: { item: unknown; error: ReturnType<typeof documentSchema.safeParse> }[] =\n []\n for (const item of raw) {\n const parsed = documentSchema.safeParse({ ...(item as object), collection: collectionId })\n if (parsed.success) parsedBatch.push(parsed.data)\n else schemaFails.push({ item, error: parsed })\n }\n for (const { item, error } of schemaFails) {\n report.rejected.push({\n id: (item as { id?: string })?.id ?? translate('cms.list.import.noId'),\n issues: (error.success ? [] : error.error.issues).map((e) => ({\n code: 'invalid-field-value' as const,\n severity: 'error' as const,\n message: e.message,\n path: e.path.map((p) => (typeof p === 'symbol' ? String(p) : p)),\n })),\n })\n }\n // Validate each against existing docs PLUS the rest of the batch.\n const batchStore = createDocumentStore([...documents, ...parsedBatch])\n const accepted: CmsDocument[] = []\n for (const doc of parsedBatch) {\n const issues = validateDocument(registry, doc, { store: batchStore, localeConfig, assetExists })\n const errors = issues.filter((iss) => iss.severity === 'error')\n if (errors.length > 0) report.rejected.push({ id: doc.id, issues: errors })\n else accepted.push(doc)\n }\n if (accepted.length > 0) {\n // Replace-or-append (upsert): an imported row may be brand new to the\n // session, so each accepted document must land even with no prior\n // entry for its ref.\n setDocuments((prev) => accepted.reduce((acc, doc) => upsertDoc(acc, doc), prev))\n for (const doc of accepted) persisterRef.current?.upsertDocument(doc)\n // EC-224: imports land as the working DRAFT. Publish-ness is the version\n // pointer (`publishedKeys`), set by publishing — never carried in the\n // imported row — so an import never auto-publishes; the editor publishes\n // explicitly afterward.\n report.added = accepted.length\n }\n return report\n },\n [registry, documents, localeConfig, assetExists],\n )\n\n const isFieldReadOnly = useCallback((field: FieldDef) => field.form?.readOnly === true, [])\n\n // --- Views (EC-246b: config-as-code) --------------------------------------\n\n const viewsOf = useCallback(\n (collectionId: string): SavedView[] => {\n // The built-in default plus the collection's config-declared views (EC-246b).\n // Views are PRESENTATION, read live from elytra.config.ts (AD-11) — not the\n // persisted content schema the session booted from — so they reflect code\n // immediately without a re-seed (the persisted schema is only baselined on\n // first run). The EC-169 DB saved-view store is retired: shared views are\n // code, editors keep only transient in-session tweaks + Reset.\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n return [\n defaultView(registry.get(collectionId)),\n ...(configCollection ? configViewsFor(configCollection) : []),\n ]\n },\n [registry],\n )\n\n // The INITIAL active view for a collection (EC-343): a config view flagged\n // `default: true` seeds the first-load lens; else the built-in \"All\" default. Only\n // consulted before the editor has picked a view (`activeViews[id]` wins once set),\n // so transient switching + Reset are unaffected. A duplicate `default` is warned\n // once (never silent) and the first-declared default seeds deterministically.\n const initialViewId = useCallback((collectionId: string): string => {\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n if (!configCollection) return ALL_VIEW_ID\n warnDuplicateDefaultViews(configCollection)\n return defaultConfigViewId(configCollection) ?? ALL_VIEW_ID\n }, [])\n\n const activeViewOf = useCallback(\n (collectionId: string): SavedView => {\n const id = activeViews[collectionId] ?? initialViewId(collectionId)\n return (\n viewsOf(collectionId).find((view) => view.id === id) ??\n defaultView(registry.get(collectionId))\n )\n },\n [activeViews, initialViewId, viewsOf, registry],\n )\n\n const tableStateOf = useCallback(\n (collectionId: string): TableViewState =>\n tableStates[collectionId] ?? activeViewOf(collectionId).state,\n [tableStates, activeViewOf],\n )\n\n const dropTableState = useCallback((collectionId: string) => {\n setTableStates((prev) => {\n if (!(collectionId in prev)) return prev\n const next = { ...prev }\n delete next[collectionId]\n return next\n })\n }, [])\n\n const setActiveView = useCallback(\n (collectionId: string, viewId: string) => {\n setActiveViews((prev) => ({ ...prev, [collectionId]: viewId }))\n dropTableState(collectionId)\n },\n [dropTableState],\n )\n\n // --- Bulk actions (EC-169) ------------------------------------------------\n\n const runBulk = useCallback(\n async (\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport> => {\n const collection = registry.get(collectionId)\n // A set-field needs both the field payload AND the collection def to fold\n // the value the locale-aware way — guard so a misconfigured call fails\n // loud rather than silently no-opping each item.\n if (action === 'set-field' && (!setField || !collection)) {\n return {\n action,\n ...(setField ? { setField } : {}),\n results: ids.map((id) => ({\n ref: { collection: collectionId, id },\n title: titleOf({ collection: collectionId, id }),\n ok: false,\n reason: translate('cms.list.bulk.error.invalidSetField'),\n error: { code: 'unknown', message: 'Invalid set-field request.' },\n })),\n }\n }\n // The next document for a set-field item: fold the value into the active\n // locale's bag (localized) or the shared `values` (non-localized).\n const setFieldDoc = (doc: CmsDocument): CmsDocument =>\n applyCellValue(collection!, doc, setField!.field, activeLocale, setField!.value)\n\n let dispatch:\n | ((action: BulkAction, ref: DocumentRef) => Promise<OperationResult<unknown>>)\n | undefined\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n // Pending queued mutations + baseline land first, then one awaited\n // command per item (same ordering contract as commitFieldEdit).\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n dispatch = (bulkAction, ref) => {\n if (bulkAction === 'delete') return operations.documents.delete({ projectId, ref })\n if (bulkAction === 'publish') return operations.documents.publish({ projectId, ref })\n if (bulkAction === 'unpublish') return operations.documents.unpublish({ projectId, ref })\n // set-field: upsert the document carrying the new value. The write\n // path self-types it through the schema lens (EC-277); a scalar field\n // stores its scalar as-is.\n const current = documentsRef.current.find((d) => matchesRef(d, ref))\n if (!current) {\n return Promise.resolve<OperationResult<unknown>>({\n ok: false,\n error: {\n code: 'not-found',\n message: 'Document is no longer in the session.',\n entity: 'cms-document',\n key: `${ref.collection}:${ref.id}`,\n },\n })\n }\n return operations.documents.upsert({ projectId, document: setFieldDoc(current) })\n }\n }\n return runBulkAction(\n {\n documents: documentsRef.current,\n titleOf,\n validate: (doc) =>\n validateDocument(registry, doc, {\n store: createDocumentStore(documentsRef.current),\n localeConfig,\n // EC-225: include the composition validators so a bulk PUBLISH\n // gates blocks/richText validity the same way the detail editor\n // does — the operations-layer publish gate has no component\n // registry, so composition validity is a studio-validation invariant.\n validateComposition,\n validateRichTextEmbeds,\n assetExists,\n }),\n // EC-425: bulk publish joins the single-document clean point — the\n // SAME shared hidden-strip `doPublish` runs (EC-273 field values +\n // EC-394 component props, session registry), per item.\n ...(collection\n ? { cleanForPublish: (doc: CmsDocument) => cleanHiddenForPublish(collection, doc) }\n : {}),\n // Land a cleaned draft exactly the way the editor's publish does:\n // session apply + the persister's self-typing upsert (EC-277 manifest\n // lens), flushed so the serial queue lands the upsert BEFORE the\n // awaited publish command snapshots the stored draft.\n applyCleaned: async (_ref, cleaned) => {\n setDocuments((prev) => replaceDoc(prev, cleaned))\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n persister.upsertDocument(cleaned)\n await persister.flush()\n }\n },\n // EC-224: a succeeded publish/unpublish moves the version pointer\n // (`publishedKeys`) via setPublished — there is no separate flat\n // `state` mirror to keep in sync (published-ness is derived from the\n // pointer set).\n applyState: (ref, state) => setPublished(ref, state === 'published'),\n applyDelete: (ref) => setDocuments((prev) => removeDoc(prev, ref)),\n // EC-247: fold the new value into the session document (same\n // locale-aware path the dispatched upsert used). Not a plain\n // `replaceDoc` — the replacement is computed FROM each matched\n // document (`setFieldDoc(d)`), not a fixed value to swap in.\n applySetField: (ref) =>\n setDocuments((prev) => prev.map((d) => (matchesRef(d, ref) ? setFieldDoc(d) : d))),\n ...(dispatch ? { dispatch } : {}),\n },\n collectionId,\n ids,\n action,\n setField,\n )\n },\n [projectId, titleOf, registry, localeConfig, activeLocale, setPublished, assetExists],\n )\n\n const store$ = useMemo<CmsStore>(\n () => ({\n ...(projectId !== undefined ? { projectId } : {}),\n collections,\n localeConfig,\n activeLocale,\n getCollection,\n documentsOf: (collectionId) => documents.filter((d) => d.collection === collectionId),\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViewId: (collectionId) => activeViews[collectionId] ?? initialViewId(collectionId),\n setActiveView,\n tableStateOf,\n setTableState: (collectionId, update) =>\n setTableStates((prev) => {\n const current = prev[collectionId] ?? activeViewOf(collectionId).state\n const next = typeof update === 'function' ? update(current) : update\n return { ...prev, [collectionId]: next }\n }),\n isViewDirty: (collectionId) => {\n const working = tableStates[collectionId]\n if (working === undefined) return false\n const active = activeViewOf(collectionId).state\n const collection = registry.get(collectionId)\n if (collection === undefined) return !viewStatesEqual(working, active)\n // Compare schema-resolved forms (EC-213): a column-order reconciliation\n // or a stale `hidden` entry must not read as an unsaved edit.\n return !viewStatesEqual(\n canonicalViewState(collection, working),\n canonicalViewState(collection, active),\n )\n },\n resetTableState: dropTableState,\n runBulk,\n addCollection: (def) =>\n setCollections((prev) => [...prev.filter((c) => c.id !== def.id), def]),\n persistError,\n clearPersistError: () => setPersistError(null),\n ensurePersistedBaseline: () => persisterRef.current?.ensureBaseline() ?? Promise.resolve(),\n flushPersistence: () => persisterRef.current?.flush() ?? Promise.resolve(),\n }),\n [\n projectId,\n collections,\n documents,\n localeConfig,\n activeLocale,\n getCollection,\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViews,\n activeViewOf,\n initialViewId,\n tableStates,\n tableStateOf,\n setActiveView,\n dropTableState,\n runBulk,\n registry,\n persistError,\n ],\n )\n\n return <CmsContext.Provider value={store$}>{children}</CmsContext.Provider>\n}\n\nexport { useCms }\n\nexport { primaryField }\nexport type { Locale }\n"]}
|
|
@@ -268,16 +268,15 @@ function EditorBody({ projectId, collection, doc, focusPath, formAppendix, }) {
|
|
|
268
268
|
function getValue(field) {
|
|
269
269
|
// EC-226: read from the active VIEW (the draft, or the pinned published
|
|
270
270
|
// snapshot when viewing Published) — never directly from `draft`.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return viewDoc.values[field.name];
|
|
271
|
+
// EC-390: ONE reader. The form reads through the SAME `resolveField` the
|
|
272
|
+
// canvas/delivery path uses, so the two surfaces can never disagree on which
|
|
273
|
+
// stored value a field shows. This subsumes the old explicit-variant short
|
|
274
|
+
// circuit (resolveField's first branch IS the explicit per-locale read) and
|
|
275
|
+
// the non-localized `values` read (its non-localized branch) — pinned by the
|
|
276
|
+
// reader-agreement matrix in core's `value-shape.test.ts`. A fallback value
|
|
277
|
+
// is still labeled by the field's fallback marker (EC-176), so a German view
|
|
278
|
+
// shows the English text visibly, never an unexplained blank.
|
|
279
|
+
return resolveField(collection, viewDoc, field.name, locale, source.localeConfig).value;
|
|
281
280
|
}
|
|
282
281
|
// EC-176/EC-318: the present/absent-key write is single-sourced in `setFieldValue`
|
|
283
282
|
// — a localized field writes `localized[locale]`, clearing (value === undefined)
|
|
@@ -493,15 +492,15 @@ function EditorBody({ projectId, collection, doc, focusPath, formAppendix, }) {
|
|
|
493
492
|
setCompareBase,
|
|
494
493
|
setCompareTarget,
|
|
495
494
|
exitCompare,
|
|
496
|
-
}, children: _jsx(EmbedInspectorProvider, { value: embedInspectorApi, children: _jsxs("div", { className: cn('flex h-full min-h-0 flex-col', viewReadOnly && 'bg-info/[0.04]'), children: [_jsxs("div", { className: "shrink-0 border-b border-border px-4 py-3 sm:px-6", children: [_jsxs(Row, { gap: "3", align: "start", children: [_jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsxs(Row, { gap: "2", align: "center", className: "min-w-0", children: [_jsx(Heading, { level: 1, size: "h2", className: "truncate", children: singleton ? localizedLabel(collection.form?.label, collection.id) : title || doc.id }), singleton ? null : _jsx(FallbackChip, { fallback: titleFallback, testId: "doc-title-fallback" })] }), routableCollection ? (_jsx(DocumentUrlPath, { projectId: projectId, collection: collection, doc: draft, siblings: source.documents(), routes: resolveDeploymentRoutes(), localeConfig: source.localeConfig, locale: locale, live: headerLive })) : null] }), _jsx(Spacer, {}), _jsx(Text, { size: "xs", tone: "muted", className: "whitespace-nowrap", "data-testid": "autosave-status", children: source.lastError
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
495
|
+
}, children: _jsx(EmbedInspectorProvider, { value: embedInspectorApi, children: _jsxs("div", { className: cn('flex h-full min-h-0 flex-col', viewReadOnly && 'bg-info/[0.04]'), children: [_jsxs("div", { className: "shrink-0 border-b border-border px-4 py-3 sm:px-6", children: [_jsxs(Row, { gap: "3", align: "start", children: [_jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsxs(Row, { gap: "2", align: "center", className: "min-w-0", children: [_jsx(Heading, { level: 1, size: "h2", className: "truncate", children: singleton ? localizedLabel(collection.form?.label, collection.id) : title || doc.id }), singleton ? null : _jsx(FallbackChip, { fallback: titleFallback, testId: "doc-title-fallback" })] }), routableCollection ? (_jsx(DocumentUrlPath, { projectId: projectId, collection: collection, doc: draft, siblings: source.documents(), routes: resolveDeploymentRoutes(), localeConfig: source.localeConfig, locale: locale, live: headerLive })) : null] }), _jsx(Spacer, {}), _jsxs(Stack, { gap: "none", align: "end", className: "min-w-0", children: [_jsx(Text, { size: "xs", tone: "muted", className: "whitespace-nowrap", "data-testid": "autosave-status", children: source.lastError
|
|
496
|
+
? translate('cms.editor.saveFailed')
|
|
497
|
+
: explicitSave
|
|
498
|
+
? dirty
|
|
499
|
+
? translate('cms.editor.unsavedChanges')
|
|
500
|
+
: translate('cms.editor.saved')
|
|
501
|
+
: dirty
|
|
502
|
+
? translate('cms.editor.saving')
|
|
503
|
+
: translate('cms.editor.saved') }), source.lastError?.message ? (_jsx(Text, { size: "xs", className: "max-w-64 truncate text-destructive", title: source.lastError.message, "data-testid": "save-error-message", children: source.lastError.message })) : null] }), canPublish ? _jsx(DocStateBadge, { published: published }) : null, canPublish ? (_jsxs(Row, { gap: "px", align: "center", children: [_jsx(Button, { size: "sm", onClick: handlePublish, disabled: publishDisabled, title: publishTitle, className: canPublishClose ? 'rounded-r-none' : undefined, "data-testid": "doc-publish", children: publishButtonLabel }), canPublishClose ? (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { size: "sm", disabled: publishDisabled, "aria-label": translate('cms.editor.publishActions'), "data-testid": "doc-publish-actions", className: "rounded-l-none border-l border-primary-foreground/25 px-1.5", children: _jsx(ChevronDown, { className: "size-3.5" }) }) }), _jsx(DropdownMenuContent, { align: "end", children: _jsxs(DropdownMenuItem, { onClick: handlePublishAndClose, "data-testid": "doc-publish-and-close", children: [_jsx(Save, {}), " ", translate('cms.editor.publishAndClose')] }) })] })) : null] })) : null, explicitSave ? (_jsxs(Button, { size: "sm", onClick: save, disabled: !dirty, "data-testid": "doc-save", children: [_jsx(Check, {}), " ", translate('common.save')] })) : null, !viewReadOnly ? (_jsx(TranslateDocumentAction, { projectId: projectId, collection: collection, docRef: ref, document: draft, localeConfig: source.localeConfig, localesEnabled: canLocales, onApplied: (next) => {
|
|
505
504
|
source.save(next);
|
|
506
505
|
replaceDraft(next);
|
|
507
506
|
} })) : null, published || !singleton ? (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": translate('cms.editor.moreActions'), children: _jsx(MoreHorizontal, {}) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [discardStatus !== 'hidden' ? (_jsxs(DropdownMenuItem, { "data-testid": "doc-discard-draft", disabled: discardStatus !== 'ready', title: discardDisabledReason, onClick: () => setDiscardConfirm(true), children: [_jsx(RotateCcw, {}), " ", translate('cms.editor.discardDraft')] })) : null, published ? (_jsxs(DropdownMenuItem, { onClick: () => setConfirmAction('unpublish'), children: [_jsx(EyeOff, {}), " ", translate('cms.editor.unpublish')] })) : null, singleton ? null : (_jsxs(DropdownMenuItem, { "data-testid": "doc-delete", className: "text-destructive", onClick: () => setConfirmAction('delete'), children: [_jsx(Trash2, {}), " ", translate('common.delete')] }))] })] })) : null] }), showLensRow ? (_jsxs(Row, { gap: "3", className: "mt-3", wrap: true, children: [_jsxs(Row, { gap: "1", align: "center", children: [showContentTabs ? tabs.map((tab) => renderContentTab(tab)) : null, showReferences ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": true }), renderContentTab(REFERENCES_TAB)] })) : null, compare ? (_jsxs("span", { className: cn('inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium transition-colors', activeTab === COMPARE_TAB
|