@elytracms/studio 0.0.93 → 0.0.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (481) hide show
  1. package/convex/analytics-cost.test.ts +817 -0
  2. package/convex/auth.ts +5 -2
  3. package/convex/authority.ts +35 -11
  4. package/convex/contract-parity.test.ts +7 -0
  5. package/convex/delivery.ts +12 -9
  6. package/convex/guard.ts +9 -7
  7. package/convex/http-routes.test.ts +18 -8
  8. package/convex/http.ts +23 -17
  9. package/convex/ingest.test.ts +326 -0
  10. package/convex/ingest.ts +281 -0
  11. package/convex/invites.ts +13 -5
  12. package/convex/members.ts +10 -4
  13. package/convex/record-functions.ts +325 -0
  14. package/convex/records.test.ts +156 -0
  15. package/convex/redirect-migration.test.ts +205 -0
  16. package/convex/redirect-revalidate.test.ts +5 -1
  17. package/convex/redirects.ts +120 -79
  18. package/convex/role-policy.test.ts +315 -0
  19. package/convex/roles.ts +83 -0
  20. package/convex/schema.ts +30 -0
  21. package/convex/triggers.ts +21 -1
  22. package/dist/addon.d.ts +71 -0
  23. package/dist/addon.js +67 -0
  24. package/dist/addon.js.map +1 -0
  25. package/dist/components/account/account-settings.js +2 -2
  26. package/dist/components/account/account-settings.js.map +1 -1
  27. package/dist/components/account/credential-panel.js +2 -2
  28. package/dist/components/account/credential-panel.js.map +1 -1
  29. package/dist/components/account/self-account-schema.d.ts +6 -15
  30. package/dist/components/account/self-account-schema.js +52 -34
  31. package/dist/components/account/self-account-schema.js.map +1 -1
  32. package/dist/components/account/self-account-view-source.d.ts +1 -1
  33. package/dist/components/account/self-account-view-source.js +6 -4
  34. package/dist/components/account/self-account-view-source.js.map +1 -1
  35. package/dist/components/ai/ai-chat-panel-lazy.js +1 -1
  36. package/dist/components/ai/ai-chat-panel-lazy.js.map +1 -1
  37. package/dist/components/ai/ai-chat-panel.js +6 -6
  38. package/dist/components/ai/ai-chat-panel.js.map +1 -1
  39. package/dist/components/ai/ai-cms-panel.js +2 -2
  40. package/dist/components/ai/ai-cms-panel.js.map +1 -1
  41. package/dist/components/ai/ai-panel-toggle.js +4 -4
  42. package/dist/components/ai/ai-panel-toggle.js.map +1 -1
  43. package/dist/components/ai/chat-ui.js +2 -2
  44. package/dist/components/ai/chat-ui.js.map +1 -1
  45. package/dist/components/ai/proposal-card.d.ts +2 -2
  46. package/dist/components/ai/proposal-card.js +2 -2
  47. package/dist/components/ai/proposal-card.js.map +1 -1
  48. package/dist/components/ai/proposal-issues.js +2 -2
  49. package/dist/components/ai/proposal-issues.js.map +1 -1
  50. package/dist/components/ai/translate-document-action.js +2 -2
  51. package/dist/components/ai/translate-document-action.js.map +1 -1
  52. package/dist/components/ai/translate-document-dialog.js +6 -6
  53. package/dist/components/ai/translate-document-dialog.js.map +1 -1
  54. package/dist/components/ai/translate-skipped.d.ts +1 -1
  55. package/dist/components/ai/translate-skipped.js +2 -2
  56. package/dist/components/ai/translate-skipped.js.map +1 -1
  57. package/dist/components/app-views/default-modules.d.ts +50 -2
  58. package/dist/components/app-views/default-modules.js +65 -20
  59. package/dist/components/app-views/default-modules.js.map +1 -1
  60. package/dist/components/app-views/module.d.ts +53 -3
  61. package/dist/components/app-views/module.js +14 -7
  62. package/dist/components/app-views/module.js.map +1 -1
  63. package/dist/components/app-views/sidebar.js +1 -1
  64. package/dist/components/app-views/sidebar.js.map +1 -1
  65. package/dist/components/app-views/studio-config.d.ts +11 -2
  66. package/dist/components/app-views/studio-config.js.map +1 -1
  67. package/dist/components/assets/asset-detail.js +2 -2
  68. package/dist/components/assets/asset-detail.js.map +1 -1
  69. package/dist/components/assets/asset-grid.js +2 -2
  70. package/dist/components/assets/asset-grid.js.map +1 -1
  71. package/dist/components/assets/asset-thumb.js +3 -3
  72. package/dist/components/assets/asset-thumb.js.map +1 -1
  73. package/dist/components/assets/assets-collection-view-source.d.ts +2 -2
  74. package/dist/components/assets/assets-collection-view-source.js.map +1 -1
  75. package/dist/components/assets/assets-module.js +1 -1
  76. package/dist/components/assets/assets-module.js.map +1 -1
  77. package/dist/components/assets/assets-store.d.ts +2 -2
  78. package/dist/components/assets/assets-store.js +6 -6
  79. package/dist/components/assets/assets-store.js.map +1 -1
  80. package/dist/components/assets/assets-view-preference.js +1 -1
  81. package/dist/components/assets/assets-view-preference.js.map +1 -1
  82. package/dist/components/assets/replace-file.js +1 -1
  83. package/dist/components/assets/replace-file.js.map +1 -1
  84. package/dist/components/auth-context.d.ts +1 -1
  85. package/dist/components/auth-context.js +6 -6
  86. package/dist/components/auth-context.js.map +1 -1
  87. package/dist/components/builder/blocks-model.d.ts +1 -1
  88. package/dist/components/builder/blocks-model.js +3 -3
  89. package/dist/components/builder/blocks-model.js.map +1 -1
  90. package/dist/components/builder/blocks-panel.d.ts +1 -1
  91. package/dist/components/builder/blocks-panel.js +4 -4
  92. package/dist/components/builder/blocks-panel.js.map +1 -1
  93. package/dist/components/builder/builder-store.js +2 -2
  94. package/dist/components/builder/builder-store.js.map +1 -1
  95. package/dist/components/builder/canvas-breakpoints.js +1 -1
  96. package/dist/components/builder/canvas-breakpoints.js.map +1 -1
  97. package/dist/components/builder/canvas-dnd.d.ts +2 -2
  98. package/dist/components/builder/canvas-dnd.js +1 -1
  99. package/dist/components/builder/canvas-dnd.js.map +1 -1
  100. package/dist/components/builder/canvas-inline-editing.d.ts +1 -1
  101. package/dist/components/builder/canvas-inline-editing.js.map +1 -1
  102. package/dist/components/builder/canvas-overlay-geometry.d.ts +1 -1
  103. package/dist/components/builder/canvas-overlay-geometry.js.map +1 -1
  104. package/dist/components/builder/canvas-render-context.d.ts +1 -1
  105. package/dist/components/builder/canvas-render-context.js +4 -4
  106. package/dist/components/builder/canvas-render-context.js.map +1 -1
  107. package/dist/components/builder/canvas-theme-notice.js +2 -2
  108. package/dist/components/builder/canvas-theme-notice.js.map +1 -1
  109. package/dist/components/builder/canvas.js +3 -3
  110. package/dist/components/builder/canvas.js.map +1 -1
  111. package/dist/components/builder/clipboard-actions.d.ts +2 -2
  112. package/dist/components/builder/clipboard-actions.js +4 -4
  113. package/dist/components/builder/clipboard-actions.js.map +1 -1
  114. package/dist/components/builder/composition-field-editor-lazy.js +1 -1
  115. package/dist/components/builder/composition-field-editor-lazy.js.map +1 -1
  116. package/dist/components/builder/composition-field-editor.d.ts +1 -1
  117. package/dist/components/builder/composition-field-editor.js +3 -3
  118. package/dist/components/builder/composition-field-editor.js.map +1 -1
  119. package/dist/components/builder/drag-session.d.ts +1 -1
  120. package/dist/components/builder/drag-session.js.map +1 -1
  121. package/dist/components/builder/fixture-thumbnail.js +1 -1
  122. package/dist/components/builder/fixture-thumbnail.js.map +1 -1
  123. package/dist/components/builder/insert-context.d.ts +1 -1
  124. package/dist/components/builder/insert-context.js +3 -3
  125. package/dist/components/builder/insert-context.js.map +1 -1
  126. package/dist/components/builder/layout-inspector.js +1 -1
  127. package/dist/components/builder/layout-inspector.js.map +1 -1
  128. package/dist/components/builder/node-title.js +1 -1
  129. package/dist/components/builder/node-title.js.map +1 -1
  130. package/dist/components/builder/page-tree.d.ts +1 -1
  131. package/dist/components/builder/page-tree.js +5 -5
  132. package/dist/components/builder/page-tree.js.map +1 -1
  133. package/dist/components/builder/placement-refusal.js +3 -3
  134. package/dist/components/builder/placement-refusal.js.map +1 -1
  135. package/dist/components/builder/property-inspector.js +4 -4
  136. package/dist/components/builder/property-inspector.js.map +1 -1
  137. package/dist/components/builder/reuse-context.js +4 -4
  138. package/dist/components/builder/reuse-context.js.map +1 -1
  139. package/dist/components/builder/reuse.js +1 -1
  140. package/dist/components/builder/reuse.js.map +1 -1
  141. package/dist/components/builder/rich-text-toolbar.js +1 -1
  142. package/dist/components/builder/rich-text-toolbar.js.map +1 -1
  143. package/dist/components/builder/run-inspector.js +1 -1
  144. package/dist/components/builder/run-inspector.js.map +1 -1
  145. package/dist/components/builder/selection-overlay.js +3 -3
  146. package/dist/components/builder/selection-overlay.js.map +1 -1
  147. package/dist/components/builder/spacing-handles.d.ts +2 -2
  148. package/dist/components/builder/spacing-handles.js +3 -3
  149. package/dist/components/builder/spacing-handles.js.map +1 -1
  150. package/dist/components/cms/asset-field.js +2 -2
  151. package/dist/components/cms/asset-field.js.map +1 -1
  152. package/dist/components/cms/asset-picker.js +2 -2
  153. package/dist/components/cms/asset-picker.js.map +1 -1
  154. package/dist/components/cms/bulk-actions.d.ts +1 -1
  155. package/dist/components/cms/bulk-actions.js +2 -2
  156. package/dist/components/cms/bulk-actions.js.map +1 -1
  157. package/dist/components/cms/bulk-bar.d.ts +2 -2
  158. package/dist/components/cms/bulk-bar.js +2 -2
  159. package/dist/components/cms/bulk-bar.js.map +1 -1
  160. package/dist/components/cms/cell-edit.d.ts +1 -1
  161. package/dist/components/cms/cell-edit.js +1 -1
  162. package/dist/components/cms/cell-edit.js.map +1 -1
  163. package/dist/components/cms/cell.d.ts +1 -1
  164. package/dist/components/cms/cell.js +3 -3
  165. package/dist/components/cms/cell.js.map +1 -1
  166. package/dist/components/cms/cms-index.js +2 -2
  167. package/dist/components/cms/cms-index.js.map +1 -1
  168. package/dist/components/cms/cms-labels.js +2 -2
  169. package/dist/components/cms/cms-labels.js.map +1 -1
  170. package/dist/components/cms/cms-store.d.ts +2 -2
  171. package/dist/components/cms/cms-store.js +10 -10
  172. package/dist/components/cms/cms-store.js.map +1 -1
  173. package/dist/components/cms/collection-table.js +7 -7
  174. package/dist/components/cms/collection-table.js.map +1 -1
  175. package/dist/components/cms/detail-editor.d.ts +5 -2
  176. package/dist/components/cms/detail-editor.js +20 -14
  177. package/dist/components/cms/detail-editor.js.map +1 -1
  178. package/dist/components/cms/details-pane.js +1 -1
  179. package/dist/components/cms/details-pane.js.map +1 -1
  180. package/dist/components/cms/doc-state.js +1 -1
  181. package/dist/components/cms/doc-state.js.map +1 -1
  182. package/dist/components/cms/document-diff-view.js +5 -5
  183. package/dist/components/cms/document-diff-view.js.map +1 -1
  184. package/dist/components/cms/document-editor-context.js +1 -1
  185. package/dist/components/cms/document-editor-context.js.map +1 -1
  186. package/dist/components/cms/document-staging.js +1 -1
  187. package/dist/components/cms/document-staging.js.map +1 -1
  188. package/dist/components/cms/document-url-path.js +2 -2
  189. package/dist/components/cms/document-url-path.js.map +1 -1
  190. package/dist/components/cms/duplicate-document.d.ts +1 -1
  191. package/dist/components/cms/duplicate-document.js.map +1 -1
  192. package/dist/components/cms/editable-cell.js +3 -3
  193. package/dist/components/cms/editable-cell.js.map +1 -1
  194. package/dist/components/cms/field-collaboration.d.ts +1 -1
  195. package/dist/components/cms/field-collaboration.js +1 -1
  196. package/dist/components/cms/field-collaboration.js.map +1 -1
  197. package/dist/components/cms/field-connection.d.ts +1 -1
  198. package/dist/components/cms/field-connection.js +2 -2
  199. package/dist/components/cms/field-connection.js.map +1 -1
  200. package/dist/components/cms/field-control-lib.js +1 -1
  201. package/dist/components/cms/field-control-lib.js.map +1 -1
  202. package/dist/components/cms/field-control.js +4 -4
  203. package/dist/components/cms/field-control.js.map +1 -1
  204. package/dist/components/cms/field-renderer.d.ts +1 -1
  205. package/dist/components/cms/field-renderer.js +2 -2
  206. package/dist/components/cms/field-renderer.js.map +1 -1
  207. package/dist/components/cms/filter-builder.d.ts +1 -1
  208. package/dist/components/cms/filter-builder.js +3 -3
  209. package/dist/components/cms/filter-builder.js.map +1 -1
  210. package/dist/components/cms/gate-validation.js +1 -1
  211. package/dist/components/cms/gate-validation.js.map +1 -1
  212. package/dist/components/cms/import-export.js +2 -2
  213. package/dist/components/cms/import-export.js.map +1 -1
  214. package/dist/components/cms/issue-copy.js +1 -1
  215. package/dist/components/cms/issue-copy.js.map +1 -1
  216. package/dist/components/cms/issues-pane.js +3 -3
  217. package/dist/components/cms/issues-pane.js.map +1 -1
  218. package/dist/components/cms/object-array-field.js +2 -2
  219. package/dist/components/cms/object-array-field.js.map +1 -1
  220. package/dist/components/cms/prop-fields.js +2 -2
  221. package/dist/components/cms/prop-fields.js.map +1 -1
  222. package/dist/components/cms/reference-confirm.d.ts +1 -1
  223. package/dist/components/cms/reference-confirm.js +2 -2
  224. package/dist/components/cms/reference-confirm.js.map +1 -1
  225. package/dist/components/cms/relation-picker.js +2 -2
  226. package/dist/components/cms/relation-picker.js.map +1 -1
  227. package/dist/components/cms/rich-text/block-style.js +1 -1
  228. package/dist/components/cms/rich-text/block-style.js.map +1 -1
  229. package/dist/components/cms/rich-text/component-embed.js +4 -4
  230. package/dist/components/cms/rich-text/component-embed.js.map +1 -1
  231. package/dist/components/cms/rich-text/editor.js +3 -3
  232. package/dist/components/cms/rich-text/editor.js.map +1 -1
  233. package/dist/components/cms/rich-text/embed-picker.js +3 -3
  234. package/dist/components/cms/rich-text/embed-picker.js.map +1 -1
  235. package/dist/components/cms/rich-text/embed-props.js +3 -3
  236. package/dist/components/cms/rich-text/embed-props.js.map +1 -1
  237. package/dist/components/cms/rich-text/extensions.js +1 -1
  238. package/dist/components/cms/rich-text/extensions.js.map +1 -1
  239. package/dist/components/cms/rich-text/font-size-control.d.ts +1 -1
  240. package/dist/components/cms/rich-text/font-size-control.js +2 -2
  241. package/dist/components/cms/rich-text/font-size-control.js.map +1 -1
  242. package/dist/components/cms/rich-text/lazy.js +1 -1
  243. package/dist/components/cms/rich-text/lazy.js.map +1 -1
  244. package/dist/components/cms/rich-text/link-control.js +2 -2
  245. package/dist/components/cms/rich-text/link-control.js.map +1 -1
  246. package/dist/components/cms/rich-text/slash-command.js +3 -3
  247. package/dist/components/cms/rich-text/slash-command.js.map +1 -1
  248. package/dist/components/cms/rich-text/toolbar.js +1 -1
  249. package/dist/components/cms/rich-text/toolbar.js.map +1 -1
  250. package/dist/components/cms/rich-text/unknown-node.js +2 -2
  251. package/dist/components/cms/rich-text/unknown-node.js.map +1 -1
  252. package/dist/components/cms/rich-text-preview.js +2 -2
  253. package/dist/components/cms/rich-text-preview.js.map +1 -1
  254. package/dist/components/cms/row-actions.d.ts +1 -1
  255. package/dist/components/cms/row-actions.js.map +1 -1
  256. package/dist/components/cms/scalar-value-editor.d.ts +1 -1
  257. package/dist/components/cms/scalar-value-editor.js +2 -2
  258. package/dist/components/cms/scalar-value-editor.js.map +1 -1
  259. package/dist/components/cms/use-discard-controller.d.ts +1 -1
  260. package/dist/components/cms/use-discard-controller.js +1 -1
  261. package/dist/components/cms/use-discard-controller.js.map +1 -1
  262. package/dist/components/cms/use-document-draft.d.ts +7 -1
  263. package/dist/components/cms/use-document-draft.js +16 -2
  264. package/dist/components/cms/use-document-draft.js.map +1 -1
  265. package/dist/components/cms/use-document-versions.js +1 -1
  266. package/dist/components/cms/use-document-versions.js.map +1 -1
  267. package/dist/components/cms/use-field-focus.d.ts +1 -1
  268. package/dist/components/cms/use-field-focus.js +2 -2
  269. package/dist/components/cms/use-field-focus.js.map +1 -1
  270. package/dist/components/cms/use-live-url.d.ts +1 -1
  271. package/dist/components/cms/use-live-url.js +3 -3
  272. package/dist/components/cms/use-live-url.js.map +1 -1
  273. package/dist/components/cms/use-publish-controller.d.ts +1 -1
  274. package/dist/components/cms/use-publish-controller.js +1 -1
  275. package/dist/components/cms/use-publish-controller.js.map +1 -1
  276. package/dist/components/cms/use-published-perspective.d.ts +1 -1
  277. package/dist/components/cms/use-published-perspective.js.map +1 -1
  278. package/dist/components/cms/use-restore-version.d.ts +1 -1
  279. package/dist/components/cms/use-restore-version.js +1 -1
  280. package/dist/components/cms/use-restore-version.js.map +1 -1
  281. package/dist/components/cms/version-compare-lazy.js +1 -1
  282. package/dist/components/cms/version-compare-lazy.js.map +1 -1
  283. package/dist/components/cms/version-compare.js +1 -1
  284. package/dist/components/cms/version-compare.js.map +1 -1
  285. package/dist/components/cms/versions-pane.js +3 -3
  286. package/dist/components/cms/versions-pane.js.map +1 -1
  287. package/dist/components/cms/view-bar.js +3 -3
  288. package/dist/components/cms/view-bar.js.map +1 -1
  289. package/dist/components/collection-view/cms-collection-view-source.d.ts +1 -1
  290. package/dist/components/collection-view/cms-collection-view-source.js +2 -2
  291. package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
  292. package/dist/components/collection-view/collection-view-context.d.ts +1 -1
  293. package/dist/components/collection-view/collection-view-context.js +1 -1
  294. package/dist/components/collection-view/collection-view-context.js.map +1 -1
  295. package/dist/components/collection-view/collection-view-surface.d.ts +13 -0
  296. package/dist/components/collection-view/collection-view-surface.js +18 -0
  297. package/dist/components/collection-view/collection-view-surface.js.map +1 -0
  298. package/dist/components/components/component-detail.js +10 -10
  299. package/dist/components/components/component-detail.js.map +1 -1
  300. package/dist/components/components/component-preview.d.ts +2 -2
  301. package/dist/components/components/component-preview.js +5 -5
  302. package/dist/components/components/component-preview.js.map +1 -1
  303. package/dist/components/components/component-status.d.ts +1 -1
  304. package/dist/components/components/component-status.js +1 -1
  305. package/dist/components/components/component-status.js.map +1 -1
  306. package/dist/components/components/components-index.js +2 -2
  307. package/dist/components/components/components-index.js.map +1 -1
  308. package/dist/components/components/field-inspector.js +1 -1
  309. package/dist/components/components/field-inspector.js.map +1 -1
  310. package/dist/components/components/registry-browser.js +3 -3
  311. package/dist/components/components/registry-browser.js.map +1 -1
  312. package/dist/components/components/taxonomy.d.ts +1 -1
  313. package/dist/components/components/taxonomy.js.map +1 -1
  314. package/dist/components/components/transfer-dialog.js +3 -3
  315. package/dist/components/components/transfer-dialog.js.map +1 -1
  316. package/dist/components/current-user-menu.js +1 -1
  317. package/dist/components/current-user-menu.js.map +1 -1
  318. package/dist/components/delivery-health-banner.js +2 -2
  319. package/dist/components/delivery-health-banner.js.map +1 -1
  320. package/dist/components/deployment-setup-gate.js +3 -3
  321. package/dist/components/deployment-setup-gate.js.map +1 -1
  322. package/dist/components/dev-login-badge.js +2 -2
  323. package/dist/components/dev-login-badge.js.map +1 -1
  324. package/dist/components/guards.js +1 -1
  325. package/dist/components/guards.js.map +1 -1
  326. package/dist/components/inspector/document-panes.d.ts +54 -0
  327. package/dist/components/inspector/document-panes.js +41 -0
  328. package/dist/components/inspector/document-panes.js.map +1 -0
  329. package/dist/components/inspector/inspector-sidebar.js +1 -1
  330. package/dist/components/inspector/inspector-sidebar.js.map +1 -1
  331. package/dist/components/nav-issues-registry.d.ts +53 -0
  332. package/dist/components/nav-issues-registry.js +69 -0
  333. package/dist/components/nav-issues-registry.js.map +1 -0
  334. package/dist/components/nav-issues.js +4 -4
  335. package/dist/components/nav-issues.js.map +1 -1
  336. package/dist/components/operation-error.d.ts +1 -1
  337. package/dist/components/operation-error.js +4 -4
  338. package/dist/components/operation-error.js.map +1 -1
  339. package/dist/components/playground-badge.js +2 -2
  340. package/dist/components/playground-badge.js.map +1 -1
  341. package/dist/components/project-list.js +3 -3
  342. package/dist/components/project-list.js.map +1 -1
  343. package/dist/components/project-session.d.ts +2 -2
  344. package/dist/components/project-session.js +5 -5
  345. package/dist/components/project-session.js.map +1 -1
  346. package/dist/components/project-switcher.js +2 -2
  347. package/dist/components/project-switcher.js.map +1 -1
  348. package/dist/components/rail-store-status.js +1 -1
  349. package/dist/components/rail-store-status.js.map +1 -1
  350. package/dist/components/rail-view-source.d.ts +6 -5
  351. package/dist/components/rail-view-source.js +4 -3
  352. package/dist/components/rail-view-source.js.map +1 -1
  353. package/dist/components/records/record-lens.d.ts +51 -0
  354. package/dist/components/records/record-lens.js +156 -0
  355. package/dist/components/records/record-lens.js.map +1 -0
  356. package/dist/components/records/record-rail.d.ts +86 -0
  357. package/dist/components/records/record-rail.js +241 -0
  358. package/dist/components/records/record-rail.js.map +1 -0
  359. package/dist/components/redirects/redirects-schema.js +1 -1
  360. package/dist/components/redirects/redirects-schema.js.map +1 -1
  361. package/dist/components/references/references-panel.js +2 -2
  362. package/dist/components/references/references-panel.js.map +1 -1
  363. package/dist/components/section-nav.js +27 -11
  364. package/dist/components/section-nav.js.map +1 -1
  365. package/dist/components/section-state.js +2 -2
  366. package/dist/components/section-state.js.map +1 -1
  367. package/dist/components/section-surface.js +2 -2
  368. package/dist/components/section-surface.js.map +1 -1
  369. package/dist/components/session-expired-overlay.js +3 -3
  370. package/dist/components/session-expired-overlay.js.map +1 -1
  371. package/dist/components/settings-form.js +1 -1
  372. package/dist/components/settings-form.js.map +1 -1
  373. package/dist/components/sign-in-needed-badge.js +1 -1
  374. package/dist/components/sign-in-needed-badge.js.map +1 -1
  375. package/dist/components/sign-in-view.d.ts +2 -2
  376. package/dist/components/sign-in-view.js +5 -5
  377. package/dist/components/sign-in-view.js.map +1 -1
  378. package/dist/components/studio-context.js +3 -3
  379. package/dist/components/studio-context.js.map +1 -1
  380. package/dist/components/studio-project-screen.js +30 -3
  381. package/dist/components/studio-project-screen.js.map +1 -1
  382. package/dist/components/studio-shell.js +6 -5
  383. package/dist/components/studio-shell.js.map +1 -1
  384. package/dist/components/theme-context.d.ts +1 -1
  385. package/dist/components/theme-context.js +2 -2
  386. package/dist/components/theme-context.js.map +1 -1
  387. package/dist/components/use-hydration-phase.d.ts +1 -1
  388. package/dist/components/use-hydration-phase.js +1 -1
  389. package/dist/components/use-hydration-phase.js.map +1 -1
  390. package/dist/components/users/invite-user-bar.d.ts +27 -0
  391. package/dist/components/users/invite-user-bar.js +25 -9
  392. package/dist/components/users/invite-user-bar.js.map +1 -1
  393. package/dist/components/users/role-policy-drift-issues.d.ts +38 -0
  394. package/dist/components/users/role-policy-drift-issues.js +71 -0
  395. package/dist/components/users/role-policy-drift-issues.js.map +1 -0
  396. package/dist/components/users/users-collection-view-source.d.ts +1 -1
  397. package/dist/components/users/users-collection-view-source.js +4 -2
  398. package/dist/components/users/users-collection-view-source.js.map +1 -1
  399. package/dist/components/users/users-module.js +1 -1
  400. package/dist/components/users/users-module.js.map +1 -1
  401. package/dist/components/users/users-schema.d.ts +10 -1
  402. package/dist/components/users/users-schema.js +45 -25
  403. package/dist/components/users/users-schema.js.map +1 -1
  404. package/dist/components/users/users-store.js +3 -3
  405. package/dist/components/users/users-store.js.map +1 -1
  406. package/dist/components/workspace-projects.d.ts +1 -1
  407. package/dist/components/workspace-projects.js +1 -1
  408. package/dist/components/workspace-projects.js.map +1 -1
  409. package/dist/lib/ai/index.d.ts +1 -1
  410. package/dist/lib/ai/index.js +1 -1
  411. package/dist/lib/ai/index.js.map +1 -1
  412. package/dist/lib/ai/node-handler.d.ts +1 -1
  413. package/dist/lib/ai/node-handler.js.map +1 -1
  414. package/dist/lib/ai/translate-document.js +1 -1
  415. package/dist/lib/ai/translate-document.js.map +1 -1
  416. package/dist/lib/clipboard/paste-issues.js +1 -1
  417. package/dist/lib/clipboard/paste-issues.js.map +1 -1
  418. package/dist/lib/clipboard/paste-target.js +2 -2
  419. package/dist/lib/clipboard/paste-target.js.map +1 -1
  420. package/dist/lib/cms/published-documents.js +1 -1
  421. package/dist/lib/cms/published-documents.js.map +1 -1
  422. package/dist/lib/cms-views/view-model.d.ts +12 -12
  423. package/dist/lib/cms-views/view-model.js +2 -2
  424. package/dist/lib/cms-views/view-model.js.map +1 -1
  425. package/dist/lib/collection-view/collection-view-source.d.ts +7 -2
  426. package/dist/lib/collection-view/collection-view-source.js.map +1 -1
  427. package/dist/lib/data/content-session-refresh.d.ts +1 -1
  428. package/dist/lib/data/content-session-refresh.js.map +1 -1
  429. package/dist/lib/data/playground-unload-guard.d.ts +1 -1
  430. package/dist/lib/data/playground-unload-guard.js +1 -1
  431. package/dist/lib/data/playground-unload-guard.js.map +1 -1
  432. package/dist/lib/engine-version.d.ts +1 -1
  433. package/dist/lib/engine-version.js +1 -1
  434. package/dist/lib/engine-version.js.map +1 -1
  435. package/dist/lib/i18n/i18n.js +1 -1
  436. package/dist/lib/i18n/i18n.js.map +1 -1
  437. package/dist/lib/i18n/messages.de.js +4 -0
  438. package/dist/lib/i18n/messages.de.js.map +1 -1
  439. package/dist/lib/i18n/messages.en.d.ts +4 -0
  440. package/dist/lib/i18n/messages.en.js +8 -0
  441. package/dist/lib/i18n/messages.en.js.map +1 -1
  442. package/dist/lib/operations/project-runtime-config.d.ts +9 -0
  443. package/dist/lib/operations/project-runtime-config.js +13 -0
  444. package/dist/lib/operations/project-runtime-config.js.map +1 -1
  445. package/dist/lib/operations/studio-operations.d.ts +9 -1
  446. package/dist/lib/operations/studio-operations.js +6 -1
  447. package/dist/lib/operations/studio-operations.js.map +1 -1
  448. package/dist/lib/persistence/convex-adapter.d.ts +16 -3
  449. package/dist/lib/persistence/convex-adapter.js +78 -47
  450. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  451. package/dist/lib/persistence/index.js +14 -1
  452. package/dist/lib/persistence/index.js.map +1 -1
  453. package/dist/lib/persona/labels.js +1 -1
  454. package/dist/lib/persona/labels.js.map +1 -1
  455. package/dist/lib/query/operations-query.d.ts +1 -1
  456. package/dist/lib/query/operations-query.js +1 -1
  457. package/dist/lib/query/operations-query.js.map +1 -1
  458. package/dist/lib/references/reference-model.js +1 -1
  459. package/dist/lib/references/reference-model.js.map +1 -1
  460. package/dist/lib/references/references-store.js +1 -1
  461. package/dist/lib/references/references-store.js.map +1 -1
  462. package/dist/lib/workspace/index.d.ts +6 -0
  463. package/dist/lib/workspace/index.js +8 -0
  464. package/dist/lib/workspace/index.js.map +1 -1
  465. package/dist/mount.d.ts +28 -0
  466. package/dist/mount.js +27 -0
  467. package/dist/mount.js.map +1 -0
  468. package/dist/router/root.js +10 -10
  469. package/dist/router/root.js.map +1 -1
  470. package/dist/ui/badge.d.ts +1 -1
  471. package/dist/ui/button.d.ts +2 -2
  472. package/package.json +15 -11
  473. package/dist/components/redirects/redirects-collection-view-source.d.ts +0 -53
  474. package/dist/components/redirects/redirects-collection-view-source.js +0 -146
  475. package/dist/components/redirects/redirects-collection-view-source.js.map +0 -1
  476. package/dist/components/redirects/redirects-module.d.ts +0 -21
  477. package/dist/components/redirects/redirects-module.js +0 -40
  478. package/dist/components/redirects/redirects-module.js.map +0 -1
  479. package/dist/components/redirects/redirects-store.d.ts +0 -68
  480. package/dist/components/redirects/redirects-store.js +0 -132
  481. package/dist/components/redirects/redirects-store.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"view-model.js","sourceRoot":"","sources":["../../../src/lib/cms-views/view-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAA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,SAA4B,EAAE;IAE9B,MAAM,IAAI,GAAG,iBAAiB,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACxC,MAAM,EAAE,GAAG,IAAI,GAAG,KAAK,CAAA;IACvB,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACjE,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;IACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACvB,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;IAC5B,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import { z } from 'zod'\nimport {\n canonicalDateValue,\n localizedStringSchema,\n resolveField,\n resolveLabel,\n titleFieldOf,\n} from '@elytracms/core/cms-core'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { contentQueryErrorMessage } from '@elytracms/studio/lib/persona/labels'\nimport type {\n CmsDocument,\n CollectionDef,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n} from '@elytracms/core/cms-core'\nimport {\n FILTER_OPERATORS,\n compareListEntries,\n sortScalarOf,\n filterableFields,\n matchesFieldValue,\n validateWhere,\n} from '@elytracms/core/content'\nimport type {\n FilterCondition,\n FilterOperator,\n FilterScalar,\n NormalizedCondition,\n WhereInput,\n} from '@elytracms/core/content'\n\n/**\n * The pure table-view model for the CMS collection table (EC-169).\n *\n * A view bundles three things: filters in the closed AD-3 vocabulary\n * (`eq`/`in`/`lt`/`lte`/`gt`/`gte`, AND-only — exactly `@elytracms/core/content`'s\n * query model, evaluated with the same matching/ordering primitives), a sort\n * (field + direction), and the visible/ordered columns. Everything here is\n * plain data + functions so filtering, dirtiness, and column edits are\n * testable without a DOM.\n *\n * Filters are offered ONLY on fields the schema declares `filterable: true`\n * (EC-143), plus one built-in option: the document's publication state. The\n * state is document metadata, not a schema field — it powers the\n * \"show me drafts → bulk publish\" working set and still speaks only the\n * closed vocabulary (`eq`/`in`).\n */\n\n// --- Schemas (single source of truth — persisted view records reuse these) ----\n\nexport const filterScalarSchema = z.union([z.string(), z.number(), z.boolean()])\n\nexport const filterClauseSchema = z.object({\n /** A schema field name, or {@link STATE_FIELD} for the publication state. */\n field: z.string().min(1),\n op: z.enum(FILTER_OPERATORS),\n /** `in` carries an array of scalars; every other operator one scalar. */\n value: z.union([filterScalarSchema, z.array(filterScalarSchema)]),\n})\nexport type FilterClause = z.infer<typeof filterClauseSchema>\n\nexport const viewSortSchema = z.object({\n field: z.string().min(1),\n dir: z.enum(['asc', 'desc']),\n})\nexport type ViewSort = z.infer<typeof viewSortSchema>\n\nexport const tableViewStateSchema = z.object({\n /** AND-only list of conditions (no OR, no nesting — vision AD-3). */\n filters: z.array(filterClauseSchema),\n sort: viewSortSchema.nullable(),\n /**\n * The canonical column order (field names) — EVERY column, visible or not\n * (EC-213). Order is independent of visibility: hiding then re-showing a\n * column keeps its place. Schema fields absent here resolve in at the end\n * (see {@link resolveColumns}).\n */\n columns: z.array(z.string().min(1)),\n /**\n * The subset of {@link TableViewState.columns} that is hidden. Defaults to\n * `[]` so views persisted before EC-213 (no `hidden` key) load unchanged.\n */\n hidden: z.array(z.string().min(1)).default([]),\n})\nexport type TableViewState = z.infer<typeof tableViewStateSchema>\n\n// --- The built-in publication-state filter column ------------------------------\n\n/**\n * Sentinel field key for the publication state. `$`-prefixed so it can never\n * collide with a schema field name (`fieldDefSchema` names are identifiers).\n */\nexport const STATE_FIELD = '$state'\n\nconst STATE_VALUES = ['draft', 'published'] as const\n\n// --- Reserved pseudo-COLUMNS (EC-445) ------------------------------------------\n\n/**\n * Reserved pseudo-COLUMN keys — the columns-axis siblings of the filter-axis\n * {@link STATE_FIELD}. `$`-prefixed so they can never collide with a schema field\n * name; they participate in a view's `columns` list AND the Display picker exactly\n * like a schema field (orderable / hideable / includable), but they are NOT drawn\n * from `collection.fields` — the column UNIVERSE is `[...schemaFields, ...pseudoColumns]`.\n *\n * - `$state` — publication status. A reserved `$`-key, but NO LONGER a reorderable\n * column: EC-448 promoted it to a FIXED structural leading column (checkbox →\n * status-dot → title), so it is NOT emitted by {@link pseudoColumns} and never\n * participates in the reorderable columns/hidden/order model. It stays a reserved\n * key (filter + sort) and {@link isPseudoColumn} still recognizes it, so an authored\n * view listing `$state` is a harmless no-op (see {@link resolveConfigColumns}).\n * - `$url` — the derived delivery URL (routable collections only; NON-sortable).\n * - `$updatedAt` — the record's last-write timestamp.\n * - `$publishedAt` — the record's FIRST-publish instant (EC-447; opt-in, HIDDEN by\n * default). Now materialized end-to-end (`cmsDocuments.publishedAt` → source\n * `timestamps.publishedAt`) and emitted by {@link pseudoColumns} when the source\n * both materializes timestamps and has a publish lifecycle.\n */\nexport const URL_FIELD = '$url'\nexport const PUBLISHED_AT_FIELD = '$publishedAt'\nexport const UPDATED_AT_FIELD = '$updatedAt'\n\n/**\n * Every reserved pseudo-column key. `$state` is included (it is still a reserved\n * `$`-key: the filter/sort axis + the FIXED structural status column, EC-448) so\n * {@link isPseudoColumn} never mistakes it for a schema field — but it is NOT a\n * reorderable column, so it is absent from the `pseudo` sets {@link pseudoColumns}\n * emits into the order/hide/picker model.\n */\nconst PSEUDO_COLUMN_FIELDS: readonly string[] = [\n STATE_FIELD,\n URL_FIELD,\n PUBLISHED_AT_FIELD,\n UPDATED_AT_FIELD,\n]\n\n/** Is `name` a reserved pseudo-column (a `$`-key, not a schema field)? */\nexport function isPseudoColumn(name: string): boolean {\n return PSEUDO_COLUMN_FIELDS.includes(name)\n}\n\n/**\n * Pseudo-columns HIDDEN by default (opt-in): the extra publish timestamp. Everything\n * else applicable (`$updatedAt`/`$state`/`$url`) is on by default (owner, 2026-07-17).\n */\nconst DEFAULT_HIDDEN_PSEUDO_COLUMNS: ReadonlySet<string> = new Set([PUBLISHED_AT_FIELD])\n\n/**\n * Capability signals that make a pseudo-column applicable to a collection/source\n * (EC-445). Supplied by the caller from the portable source — the model stays pure.\n */\nexport interface PseudoColumnOptions {\n /** The source materializes per-document timestamps → `$updatedAt` applies. */\n timestamps?: boolean\n /**\n * The collection has a publish lifecycle. Gates `$publishedAt` (with `timestamps`).\n * EC-448: it no longer gates a reorderable `$state` column — `$state` is the FIXED\n * structural status column, gated by the same signal at the render site, not here.\n */\n publishing?: boolean\n /** The collection resolves delivery URLs → `$url` applies (mirrors `urlByDocId`). */\n routable?: boolean\n}\n\n/**\n * The reserved REORDERABLE pseudo-columns that APPLY to a collection, in their default\n * appended order (EC-445/EC-447): `$updatedAt`, `$publishedAt`, then `$url`. `$url` is\n * gated on `routable` (a non-routable collection has no URL column, not an empty one),\n * `$updatedAt` on `timestamps`. `$publishedAt` (EC-447) needs BOTH `timestamps` (its\n * materialized value) AND `publishing` (a publish lifecycle to have a publish date) —\n * it is OPT-IN, HIDDEN by default (`DEFAULT_HIDDEN_PSEUDO_COLUMNS`), so it joins the\n * universe/picker without appearing in the baseline lens.\n *\n * NOTE (EC-448): `$state` is NO LONGER emitted here. It became a FIXED structural\n * leading column (checkbox → status-dot → title), rendered by `collection-table.tsx`\n * regardless of the reorderable model — so it is never in the order/hide/picker set,\n * even though `publishing` is what gates BOTH it and the status column's presence.\n * `opts.publishing` therefore only affects `$publishedAt` here. Pure — a caller\n * (`pseudoColumnsForSource`) supplies the signals from the source.\n */\nexport function pseudoColumns(collection: CollectionDef, opts: PseudoColumnOptions = {}): string[] {\n void collection // reserved for future per-collection gating; kept for API symmetry\n const cols: string[] = []\n if (opts.timestamps) cols.push(UPDATED_AT_FIELD)\n // EC-447: a publish date needs both a timestamps source (the value) AND a publish\n // lifecycle (the meaning). Hidden by default → surfaced via the Display picker / a\n // config view's `columns`, never a blank column on a rail that can't publish.\n if (opts.timestamps && opts.publishing) cols.push(PUBLISHED_AT_FIELD)\n // EC-448: $state is structural (fixed leading column), not a reorderable pseudo-column.\n if (opts.routable) cols.push(URL_FIELD)\n return cols\n}\n\n/**\n * The per-document metadata accessors the pseudo-DATE columns sort by (EC-445) — the\n * columns-axis analogue of {@link IsPublished}. Threaded into the sort machinery so a\n * `$updatedAt`/`$publishedAt` sort orders by the source's materialized timestamp; a\n * missing accessor (fixtures/tests) sorts those rows last. `$url` is derived → never sorted.\n */\nexport interface PseudoColumnMeta {\n updatedAt?(doc: CmsDocument): string | undefined\n publishedAt?(doc: CmsDocument): string | undefined\n}\n\n/** One field the filter builder may offer. */\nexport interface FilterableFieldOption {\n /** Clause field key: a schema field name, or {@link STATE_FIELD}. */\n field: string\n label: string\n /** The schema field def, or `null` for the built-in publication state. */\n def: FieldDef | null\n}\n\nexport const STATE_OPTION: FilterableFieldOption = {\n field: STATE_FIELD,\n label: 'State',\n def: null,\n}\n\n/**\n * The closed list of fields the filter builder offers: exactly the schema's\n * `filterable: true` fields (EC-143) plus the publication state. Nothing else\n * is ever offered — the UI builds queries, it does not invent a language.\n */\nexport function filterableFieldOptions(collection: CollectionDef): FilterableFieldOption[] {\n const schemaOptions = filterableFields(collection).map((field) => ({\n field: field.name,\n label: localizedLabel(field.form?.label, field.name),\n def: field,\n }))\n return [...schemaOptions, STATE_OPTION]\n}\n\nexport function filterOptionFor(\n collection: CollectionDef,\n field: string,\n): FilterableFieldOption | undefined {\n return filterableFieldOptions(collection).find((option) => option.field === field)\n}\n\n// --- Operators per field type (EC-345) ------------------------------------------\n\n/**\n * The per-type operator SET the builder offers (EC-345), always a subset of the\n * closed `FILTER_OPERATORS` — the UI narrows the vocabulary, it never extends it.\n * Ratified sets (Oli, 2026-07-08):\n *\n * - text: contains (default) · equals · starts with · ends with · empty\n * - number: equals · < · ≤ · > · ≥ · empty\n * - date: equals · before · … · after · empty (same ops as number, date labels)\n * - boolean: is\n * - select: is · is any of · empty\n * - relation / asset: is · is any of · empty (relation value = the relation picker;\n * `eq` on a `multiple` relation is membership — array-contains, EC-255 semantics)\n * - state pseudo-field: is · is any of (unchanged — a publication state is never empty)\n */\nexport function operatorsFor(option: FilterableFieldOption): FilterOperator[] {\n if (option.def === null) return ['eq', 'in'] // publication state\n switch (option.def.type) {\n case 'boolean':\n return ['eq']\n case 'number':\n case 'date':\n return ['eq', 'lt', 'lte', 'gt', 'gte', 'empty']\n case 'select':\n case 'relation':\n case 'asset':\n return ['eq', 'in', 'empty']\n default:\n // text (and any other string-shaped field)\n return ['contains', 'eq', 'startsWith', 'endsWith', 'empty']\n }\n}\n\n/**\n * A visual choice in the operator dropdown (EC-345). Usually one per operator,\n * but `empty` splits into two — \"is empty\" (`true`) and \"is not empty\" (`false`) —\n * so an editor never has to reason about a boolean value; the choice carries the\n * preset. `token` is the `<option value>`, `labelKey` a catalog key ({@link operatorLabelKey}).\n */\nexport interface OperatorChoice {\n token: string\n op: FilterOperator\n /** Value forced when this choice is picked (the `empty` true/false), else undefined. */\n presetValue?: FilterScalar\n labelKey: string\n}\n\n/**\n * The operator dropdown entries for a field (EC-345): {@link operatorsFor} expanded\n * for display, with `empty` shown as the two self-describing choices.\n */\nexport function operatorChoices(option: FilterableFieldOption): OperatorChoice[] {\n const choices: OperatorChoice[] = []\n for (const op of operatorsFor(option)) {\n if (op === 'empty') {\n choices.push({ token: 'empty:true', op, presetValue: true, labelKey: 'cms.filter.op.isEmpty' })\n choices.push({\n token: 'empty:false',\n op,\n presetValue: false,\n labelKey: 'cms.filter.op.isNotEmpty',\n })\n continue\n }\n choices.push({ token: op, op, labelKey: operatorLabelKey(op, option) })\n }\n return choices\n}\n\n/**\n * The catalog key for an operator's label (EC-241/EC-345), keyed by operator AND\n * field type — `eq` reads \"equals\" on text/number, \"on\" on a date, \"is\" on an\n * enum-like field; `lt` reads \"less than\" on a number, \"before\" on a date. `empty`\n * additionally depends on its VALUE (is empty / is not empty). Pure → unit-tested.\n */\nexport function operatorLabelKey(\n op: FilterOperator,\n option: FilterableFieldOption | undefined,\n value?: FilterScalar | readonly FilterScalar[],\n): string {\n const type = option?.def?.type\n switch (op) {\n case 'contains':\n return 'cms.filter.op.contains'\n case 'startsWith':\n return 'cms.filter.op.startsWith'\n case 'endsWith':\n return 'cms.filter.op.endsWith'\n case 'in':\n return 'cms.filter.op.isAnyOf'\n case 'empty':\n return value === false ? 'cms.filter.op.isNotEmpty' : 'cms.filter.op.isEmpty'\n case 'eq':\n // \"on\" for a date; \"is\" for enum-like refs; \"equals\" for text/number/unknown\n // (and the publication-state pseudo-field, whose `def` is null → unchanged).\n if (type === 'date') return 'cms.filter.op.on'\n if (type === 'boolean' || type === 'select' || type === 'relation' || type === 'asset') {\n return 'cms.filter.op.is'\n }\n return 'cms.filter.op.equals'\n case 'lt':\n return type === 'date' ? 'cms.filter.op.before' : 'cms.filter.op.lessThan'\n case 'lte':\n return type === 'date' ? 'cms.filter.op.onOrBefore' : 'cms.filter.op.atMost'\n case 'gt':\n return type === 'date' ? 'cms.filter.op.after' : 'cms.filter.op.greaterThan'\n case 'gte':\n return type === 'date' ? 'cms.filter.op.onOrAfter' : 'cms.filter.op.atLeast'\n }\n}\n\n/** A sensible starting clause when a field is added to the builder (EC-345). */\nexport function defaultClause(option: FilterableFieldOption): FilterClause {\n if (option.def === null) return { field: STATE_FIELD, op: 'eq', value: 'published' }\n switch (option.def.type) {\n case 'boolean':\n return { field: option.field, op: 'eq', value: true }\n case 'number':\n case 'date':\n return { field: option.field, op: 'eq', value: option.def.type === 'number' ? 0 : '' }\n case 'select':\n return { field: option.field, op: 'eq', value: option.def.options[0]?.value ?? '' }\n case 'relation':\n case 'asset':\n return { field: option.field, op: 'eq', value: '' }\n default:\n // text (and any other string-shaped field): `contains` is the natural default\n return { field: option.field, op: 'contains', value: '' }\n }\n}\n\n// --- Text ⇄ scalar coercion (the value inputs of the builder) -------------------\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/** Coerce one text input into the scalar a clause compares against. */\nexport function scalarFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar {\n const type = option?.def?.type\n if (type === 'number') {\n const trimmed = raw.trim()\n if (trimmed === '') return raw // an emptied input must not become eq 0\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? raw : parsed\n }\n if (type === 'boolean') return raw === 'true'\n // EC-586: a date operand goes through THE date canonicaliser — the same one every\n // write and the comparator use — so `2026-09-18` means midnight UTC on that day.\n if (type === 'date' && DATE_ONLY.test(raw)) return canonicalDateValue(raw) ?? raw\n return raw\n}\n\n/** Parse a comma-separated list for the `in` operator. */\nexport function scalarListFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar[] {\n return raw\n .split(',')\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .map((part) => scalarFromText(option, part))\n}\n\nexport function scalarListToText(value: FilterScalar | FilterScalar[]): string {\n const list = Array.isArray(value) ? value : [value]\n return list.map(String).join(', ')\n}\n\n// --- Clause validation -----------------------------------------------------------\n\n/** A structured problem with one clause (by index in the filter list). */\nexport interface ClauseIssue {\n index: number\n message: string\n}\n\n/**\n * Validate clauses against the collection schema. Schema-field clauses run\n * through the canonical `validateWhere` (EC-143: `filterable` enforcement +\n * operator/value shape); state clauses check the `eq`/`in` subset and the\n * draft/published value set. Invalid clauses (e.g. a persisted view whose\n * field is no longer filterable) are reported — never silently applied.\n *\n * EC-494 — the two `$state` sentences are authored HERE, studio-side, so they call\n * `translate` directly; the schema-field ones come from `core/content`, below the\n * catalog in the DAG, and are resolved from the `messageRef` that error now carries.\n * Both halves of one line therefore render in the same language.\n */\nexport function validateClauses(\n collection: CollectionDef,\n clauses: readonly FilterClause[],\n): ClauseIssue[] {\n const issues: ClauseIssue[] = []\n clauses.forEach((clause, index) => {\n if (clause.field === STATE_FIELD) {\n if (clause.op !== 'eq' && clause.op !== 'in') {\n issues.push({ index, message: translate('cms.filter.issue.stateOperator') })\n return\n }\n const values = Array.isArray(clause.value) ? clause.value : [clause.value]\n if (!values.every((value) => (STATE_VALUES as readonly unknown[]).includes(value))) {\n issues.push({ index, message: translate('cms.filter.issue.stateValue') })\n }\n return\n }\n const where: WhereInput = {\n [clause.field]: { [clause.op]: clause.value } as FilterCondition,\n }\n const errors = validateWhere(collection, where)\n if (errors.length > 0) issues.push({ index, message: contentQueryErrorMessage(errors[0]!) })\n })\n return issues\n}\n\n// --- Matching & sorting (delegates to @elytracms/core/content's primitives) -------------\n\n/**\n * Published-ness source for the `$state` pseudo-field (EC-224): the version\n * POINTER, supplied by the caller as `cms.isPublished`. Defaults to \"nothing\n * published\" — a bare row carries no publish signal now that the flat `state`\n * field is gone, so the table (which knows the pointer) passes the real\n * predicate; fixtures/tests that don't surface `$state` get the safe default.\n */\nexport type IsPublished = (doc: CmsDocument) => boolean\nconst defaultIsPublished: IsPublished = () => false\n\n/**\n * The RAW locale-resolved value a document exposes for a clause field — an array\n * for a `multiple` relation/asset, a ref object for a single one, a scalar\n * otherwise. Matching runs on this (via `matchesFieldValue`) so it agrees with the\n * delivery/listing path exactly: array-contains for `multiple` relations (EC-255)\n * and whole-value `empty` semantics (EC-345). Sorting keeps its own scalar reduction.\n *\n * EC-580: read in the DISPLAYED view of the table's active locale (`resolveField`,\n * the per-field form of `valuesInLocale`) — what the row shows is what it sorts and\n * filters by, as delivery does in the request locale. It used to read a\n * per-document default locale, so a `de` table sorted by English values.\n */\nfunction rawValueOf(\n collection: CollectionDef,\n doc: CmsDocument,\n field: string,\n localeConfig: LocaleConfig,\n locale: Locale,\n isPublished: IsPublished,\n): unknown {\n if (field === STATE_FIELD) return isPublished(doc) ? 'published' : 'draft'\n if (!collection.fields.some((f) => f.name === field)) return undefined\n return resolveField(collection, doc, field, locale, localeConfig).value\n}\n\n/** The scalar a document exposes for a SORT field, in the active locale's view. */\nfunction scalarOf(\n collection: CollectionDef,\n doc: CmsDocument,\n field: string,\n localeConfig: LocaleConfig,\n locale: Locale,\n isPublished: IsPublished,\n meta: PseudoColumnMeta = {},\n): FilterScalar | null {\n if (field === STATE_FIELD) return isPublished(doc) ? 'published' : 'draft'\n // EC-445: the pseudo-DATE columns sort by the source's materialized ISO timestamp\n // (ISO strings order lexicographically = chronologically); `$url` is derived → not sortable.\n if (field === UPDATED_AT_FIELD) return meta.updatedAt?.(doc) ?? null\n if (field === PUBLISHED_AT_FIELD) return meta.publishedAt?.(doc) ?? null\n if (field === URL_FIELD) return null\n const def = collection.fields.find((f) => f.name === field)\n if (!def) return null\n // EC-586: a `date` sorts as the instant it denotes (`sortScalarOf`), as delivery does.\n return sortScalarOf(resolveField(collection, doc, field, locale, localeConfig).value, def)\n}\n\n/**\n * Does a document satisfy one clause? Identical verdict to the content accessors'\n * delivery/listing path: both reduce to `@elytracms/core/content`'s\n * `matchesFieldValue` over the RAW field value (so `contains`/`empty`/multiple-\n * relation membership all behave the same on the table as on the live site).\n */\nexport function clauseMatches(\n collection: CollectionDef,\n doc: CmsDocument,\n localeConfig: LocaleConfig,\n locale: Locale,\n clause: FilterClause,\n isPublished: IsPublished = defaultIsPublished,\n): boolean {\n const value = rawValueOf(collection, doc, clause.field, localeConfig, locale, isPublished)\n const condition = { [clause.op]: clause.value } as NormalizedCondition\n // EC-586: the field def makes a `date` compare as an instant — delivery's exact rule.\n return matchesFieldValue(value, condition, collection.fields.find((f) => f.name === clause.field))\n}\n\n/**\n * Sort documents by one column in the canonical deterministic order\n * (`compareListEntries`: typed value order, id-ascending tiebreak). Unlike the\n * content accessors, the *table* may sort any rendered column — sorting is a\n * presentation concern here; the `filterable` flag governs filters.\n */\nexport function sortViewDocuments(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n locale: Locale,\n sort: ViewSort | null,\n isPublished: IsPublished = defaultIsPublished,\n meta: PseudoColumnMeta = {},\n): CmsDocument[] {\n if (sort === null) return [...docs]\n const positions = new Map(\n docs.map((doc) => [\n doc.id,\n scalarOf(collection, doc, sort.field, localeConfig, locale, isPublished, meta),\n ]),\n )\n return [...docs].sort((a, b) =>\n compareListEntries(\n { id: a.id, sortValue: positions.get(a.id) ?? null },\n { id: b.id, sortValue: positions.get(b.id) ?? null },\n sort.dir,\n ),\n )\n}\n\n/** The filtered + sorted documents of a view, plus any clause issues. */\nexport interface AppliedViewState {\n docs: CmsDocument[]\n /** Clauses that failed validation — reported AND excluded from matching. */\n issues: ClauseIssue[]\n}\n\n/**\n * Apply a view state to a document list: validate clauses, AND-match the valid\n * ones, sort. Invalid clauses never filter silently — they come back as\n * issues for the UI to surface.\n */\nexport function applyViewState(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n locale: Locale,\n state: TableViewState,\n isPublished: IsPublished = defaultIsPublished,\n meta: PseudoColumnMeta = {},\n): AppliedViewState {\n const issues = validateClauses(collection, state.filters)\n const invalid = new Set(issues.map((issue) => issue.index))\n const active = state.filters.filter((_, index) => !invalid.has(index))\n const matched = docs.filter((doc) =>\n active.every((clause) =>\n clauseMatches(collection, doc, localeConfig, locale, clause, isPublished),\n ),\n )\n return {\n docs: sortViewDocuments(collection, matched, localeConfig, locale, state.sort, isPublished, meta),\n issues,\n }\n}\n\n// --- View state construction, equality, columns ----------------------------------\n\n/** The id of the synthesized built-in \"All entries\" baseline view (EC-444). */\nexport const ALL_VIEW_ID = 'all'\n\n/** The default (unnamed) view: no filters, no sort, every field visible. */\n/**\n * Field types kept OFF the default table columns (EC-246b): the composite editing\n * surfaces — a blocks canvas, rich text, a structured object/repeater — read as\n * noise in a scalar list. `filterable` no longer forces (or governs) a column; the\n * default lens is \"all scalars\". These stay in the column picker one toggle away,\n * and any named view may list them in its `columns`; they're just off by default.\n */\nconst NON_DEFAULT_COLUMN_TYPES = new Set<FieldDef['type']>(['blocks', 'richText', 'object'])\n\n/**\n * Field names OFF the built-in baseline lens by default: exactly the composite\n * editing surfaces (blocks/richText/object) — always noise in a scalar list. The\n * default lens is \"all scalars\"; there is no per-field column opt-out any more\n * (EC-444 hard-removed `form.column`). A field stays in the picker one toggle away,\n * and a view curates columns by declaring an explicit `columns` list (or the\n * `id: 'default'` baseline override).\n */\nfunction defaultHiddenColumns(collection: CollectionDef, pseudo: readonly string[] = []): string[] {\n const composites = collection.fields\n .filter((f) => NON_DEFAULT_COLUMN_TYPES.has(f.type))\n .map((f) => f.name)\n // EC-445: applicable opt-in pseudo-columns ($publishedAt) start hidden; the rest\n // ($updatedAt/$state/$url) are visible by default (owner: keep them on).\n const hiddenPseudo = pseudo.filter((name) => DEFAULT_HIDDEN_PSEUDO_COLUMNS.has(name))\n return [...composites, ...hiddenPseudo]\n}\n\nexport function defaultViewState(\n collection: CollectionDef,\n pseudo: readonly string[] = [],\n): TableViewState {\n return {\n filters: [],\n sort: null,\n // Every field keeps a slot (order + picker), but the composite surfaces start\n // hidden so the default lens is the collection's scalar columns (EC-246b/EC-444).\n // EC-445: the applicable reserved pseudo-columns append after the data columns.\n columns: orderedColumnNames(collection, pseudo),\n hidden: defaultHiddenColumns(collection, pseudo),\n }\n}\n\n/**\n * Resolve an authored VISIBLE column list (EC-444) into the internal two-axis\n * `{columns, hidden}` table state. The authored list is exactly the columns shown,\n * in order; every OTHER schema field is appended (in schema order) and hidden — the\n * same shape {@link defaultViewState} produces, so {@link resolveColumns} renders\n * precisely the authored list, visible, in that order. An omitted (or empty) list\n * inherits the collection's default lens (all scalars visible, composites hidden).\n * Unknown names in the authored list (a field the schema no longer has) are dropped.\n */\nexport function resolveConfigColumns(\n collection: CollectionDef,\n visible: readonly string[] | undefined,\n pseudo: readonly string[] = [],\n): Pick<TableViewState, 'columns' | 'hidden'> {\n if (visible === undefined || visible.length === 0) {\n const base = defaultViewState(collection, pseudo)\n return { columns: base.columns, hidden: base.hidden }\n }\n const universe = orderedColumnNames(collection, pseudo)\n const inUniverse = new Set(universe)\n const seen = new Set<string>()\n const shown: string[] = []\n for (const name of visible) {\n if (inUniverse.has(name) && !seen.has(name)) {\n shown.push(name)\n seen.add(name)\n }\n }\n const rest = universe.filter((name) => !seen.has(name))\n // EC-445: a schema-ONLY authored list (mentioning no pseudo-column) keeps the\n // applicable pseudo-columns at their DEFAULT visibility — so a consumer's\n // pre-EC-445 `columns:[…schema…]` list still shows today's url (+ updatedAt).\n // Mentioning ANY reorderable pseudo-column switches them to the visible-list rule\n // (only listed shows). EC-448: `$state` is EXCLUDED here — it is a fixed structural\n // column, not a reorderable one, so an authored `$state` is an inert no-op: it must\n // not flip the visible-list rule (nor is it in the universe, so it is simply dropped).\n const mentionsPseudo = visible.some((name) => isPseudoColumn(name) && name !== STATE_FIELD)\n const keepVisible = mentionsPseudo\n ? new Set<string>()\n : new Set(pseudo.filter((name) => !DEFAULT_HIDDEN_PSEUDO_COLUMNS.has(name)))\n const hidden = rest.filter((name) => !keepVisible.has(name))\n return { columns: [...shown, ...rest], hidden }\n}\n\n/** The reserved `views[]` id whose entry OVERRIDES the synthesized baseline view (EC-444). */\nexport const DEFAULT_VIEW_OVERRIDE_ID = 'default'\n\n/**\n * A config-declared view (EC-246b/EC-444) — the flat authoring shape a collection\n * declares in `cms/` config: `{ name, initial?, filters?, sort?, columns? }`.\n * Filters/sort/columns sit at the top level (no nested `state` wrapper). The\n * studio validates + interprets these; `cms-core` stores them opaquely (it\n * can't reference the filter vocabulary without a layering cycle).\n */\nexport const configViewSchema = z.object({\n /**\n * Optional stable id; defaults to a slug of `name`. The reserved value\n * {@link DEFAULT_VIEW_OVERRIDE_ID} (`'default'`) marks the baseline-override entry.\n */\n id: z.string().min(1).optional(),\n /**\n * View label; localizable (EC-343): a plain string or a `{ locale }` map, resolved\n * at the render site via the same `resolveLabel` path as `form.label` (EC-241).\n */\n name: localizedStringSchema,\n /**\n * When true this view seeds the collection's INITIAL active view (EC-343/EC-444) —\n * the curated lens an editor lands on before picking one. At most one per collection;\n * a duplicate is a visible validation issue ({@link configViewIssues}), never silent.\n * The baseline lens stays available and stays the fallback.\n */\n initial: z.boolean().optional(),\n /**\n * @deprecated EC-444 — renamed to {@link ConfigView.initial}. Still read as an alias\n * for one release (`initial ?? default`) with a console warning; removed next release.\n * Distinct from a field's default VALUE and from the reserved `id: 'default'` override.\n */\n default: z.boolean().optional(),\n filters: z.array(filterClauseSchema).optional(),\n sort: viewSortSchema.nullable().optional(),\n /**\n * The single ordered list of VISIBLE columns (EC-444): what you list is what shows,\n * in that order. Omit to inherit the collection's default columns (all scalars). The\n * two-axis `{columns, hidden}` internal state is derived by {@link resolveConfigColumns}.\n */\n columns: z.array(z.string().min(1)).optional(),\n})\nexport type ConfigView = z.infer<typeof configViewSchema>\n\n/**\n * A resolved view: identity + the table state it restores (matches `SavedView`).\n * `name` stays a {@link LocalizedString} — resolved at the render site (EC-343), like\n * `form.label`. `initial` marks the first-load seed (see {@link defaultConfigViewId}),\n * resolved from the authored `initial ?? default` flag (EC-444).\n */\nexport interface ResolvedView {\n id: string\n name: LocalizedString\n state: TableViewState\n initial?: boolean\n}\n\n/**\n * Slug used to derive a config view's stable id from its name. A localized name\n * (EC-343) slugs its DEFAULT-locale text so the id is stable across the active UI\n * locale (an id must not shift when a German editor loads the same config).\n */\nfunction configViewId(name: LocalizedString, index: number): string {\n const text = resolveLabel(name) ?? ''\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n return `config:${slug || index}`\n}\n\n/**\n * Resolve a collection's config-declared `views` into full {@link ResolvedView}s\n * (EC-246b). Each is validated with {@link configViewSchema}; malformed entries\n * and duplicate ids are dropped (defensive). Columns fall back to the collection\n * default when a view doesn't pin them, so a filter-only view still renders every\n * column. Config views are shared and change only in\n * code — the runtime never mutates them.\n */\nexport function configViewsFor(\n collection: CollectionDef,\n pseudo: readonly string[] = [],\n): ResolvedView[] {\n const declared = collection.views\n if (!Array.isArray(declared)) return []\n const seen = new Set<string>()\n const resolved: ResolvedView[] = []\n declared.forEach((raw, index) => {\n const parsed = configViewSchema.safeParse(raw)\n if (!parsed.success) return\n const view = parsed.data\n const id = view.id ?? configViewId(view.name, index)\n if (seen.has(id)) return\n seen.add(id)\n // EC-444: `initial` supersedes the deprecated `default` alias (one-release window).\n const initial = view.initial ?? view.default\n const { columns, hidden } = resolveConfigColumns(collection, view.columns, pseudo)\n resolved.push({\n id,\n name: view.name,\n ...(initial ? { initial: true } : {}),\n state: normalizeViewState({\n filters: view.filters ?? [],\n sort: view.sort ?? null,\n columns,\n hidden,\n }),\n })\n })\n return resolved\n}\n\n/**\n * Does the collection declare a baseline-override view (a config view whose id is\n * {@link DEFAULT_VIEW_OVERRIDE_ID})? When true the synthesized \"All entries\" lens is\n * replaced by that entry verbatim (see {@link resolveCollectionViews}), EC-444.\n */\nexport function hasDefaultViewOverride(collection: CollectionDef): boolean {\n return configViewsFor(collection).some((view) => view.id === DEFAULT_VIEW_OVERRIDE_ID)\n}\n\n/**\n * The ordered view list a collection surfaces (EC-444): the baseline first, then the\n * config-declared views in declaration order. The baseline is either an authored\n * OVERRIDE (the config view whose id is {@link DEFAULT_VIEW_OVERRIDE_ID}, used\n * VERBATIM and NOT repeated among the trailing views) or, absent one, the\n * `synthesizedBaseline` the caller passes (the studio's translated \"All entries\"\n * lens). Pure — the store supplies the synthesized baseline (i18n-bound `name`).\n */\nexport function resolveCollectionViews(\n collection: CollectionDef,\n synthesizedBaseline: ResolvedView,\n pseudo: readonly string[] = [],\n): ResolvedView[] {\n const configViews = configViewsFor(collection, pseudo)\n const overrideIndex = configViews.findIndex((view) => view.id === DEFAULT_VIEW_OVERRIDE_ID)\n if (overrideIndex < 0) return [synthesizedBaseline, ...configViews]\n const override = configViews[overrideIndex]!\n const rest = configViews.filter((_, index) => index !== overrideIndex)\n return [override, ...rest]\n}\n\n/**\n * The ids of config views that still use the DEPRECATED `default` flag without the\n * new `initial` (EC-444). Drives the one-release deprecation warning (mirrors the\n * duplicate-default channel); empty once every view has migrated to `initial`.\n */\nexport function deprecatedDefaultFlagViewIds(collection: CollectionDef): string[] {\n const declared = collection.views\n if (!Array.isArray(declared)) return []\n const seen = new Set<string>()\n const ids: string[] = []\n declared.forEach((raw, index) => {\n const parsed = configViewSchema.safeParse(raw)\n if (!parsed.success) return\n const view = parsed.data\n const id = view.id ?? configViewId(view.name, index)\n if (seen.has(id)) return\n seen.add(id)\n if (view.default !== undefined && view.initial === undefined) ids.push(id)\n })\n return ids\n}\n\n/**\n * The id of the config view flagged `initial: true` (EC-343/EC-444; `default` read\n * as a deprecated alias) — the seed for a collection's INITIAL active view. When\n * several are flagged (a misconfiguration, reported by {@link configViewIssues}) the\n * FIRST in declaration order wins deterministically; when none is flagged the caller\n * falls back to the baseline lens. `undefined` when the collection flags none.\n */\nexport function defaultConfigViewId(collection: CollectionDef): string | undefined {\n return configViewsFor(collection).find((view) => view.initial)?.id\n}\n\n/** A config-level problem with a collection's declared views (EC-343/EC-444). */\nexport interface ConfigViewIssue {\n /** Stable code (kept from EC-343 to avoid catalog churn); reads \"duplicate initial\". */\n code: 'duplicate-default'\n message: string\n /** The offending view ids (all views flagged `initial`, in declaration order). */\n viewIds: string[]\n}\n\n/**\n * Validate a collection's config-declared views (EC-343/EC-444): at most one may set\n * `initial: true` (`default` counted as its deprecated alias). A duplicate is returned\n * as an explicit, structured issue — never silently swallowed — so the studio can\n * surface it (the first still wins deterministically for seeding, per\n * {@link defaultConfigViewId}). Pure and schema-only; the DOM-free counterpart of the\n * \"failures are first-class\" contract.\n */\nexport function configViewIssues(collection: CollectionDef): ConfigViewIssue[] {\n const initials = configViewsFor(collection).filter((view) => view.initial)\n if (initials.length <= 1) return []\n const viewIds = initials.map((view) => view.id)\n return [\n {\n code: 'duplicate-default',\n message: `Collection \"${collection.id}\" declares ${initials.length} initial views (${viewIds.join(', ')}); at most one view may set \\`initial: true\\`. Seeding \"${viewIds[0]}\".`,\n viewIds,\n },\n ]\n}\n\n/**\n * The default column order: the schema's title field first (it becomes the\n * default title/link column — EC-213 drops the separate primary-column\n * selector, treating the first visible column as the title), then the\n * remaining fields in schema order.\n */\nfunction orderedColumnNames(collection: CollectionDef, pseudo: readonly string[] = []): string[] {\n const names = collection.fields.map((field) => field.name)\n const title = titleFieldOf(collection)?.name\n const schemaOrdered =\n title === undefined || !names.includes(title)\n ? names\n : [title, ...names.filter((name) => name !== title)]\n // EC-445: the column UNIVERSE = schema fields, then the applicable reserved\n // pseudo-columns (they are NOT in `collection.fields`).\n return [...schemaOrdered, ...pseudo]\n}\n\n/** Deep-cloned canonical form (stable key order via the Zod shape). */\nexport function normalizeViewState(state: TableViewState): TableViewState {\n return tableViewStateSchema.parse(state)\n}\n\n/** Structural equality on normalized states — drives the \"unsaved changes\" affordance. */\nexport function viewStatesEqual(a: TableViewState, b: TableViewState): boolean {\n return JSON.stringify(normalizeViewState(a)) === JSON.stringify(normalizeViewState(b))\n}\n\n/** One column of a view resolved against the current schema (EC-213). */\nexport interface ResolvedColumn {\n /** The schema field name. */\n field: string\n /** Whether the column renders (`false` ⇒ in {@link TableViewState.hidden}). */\n visible: boolean\n}\n\n/**\n * Resolve a view's columns against the live schema (EC-213): every schema\n * field exactly once, in the view's saved order, with any fields the view\n * predates appended (visible) and any fields no longer in the schema dropped.\n * This is the single source of truth for \"which columns, in what order, shown\n * or hidden\" — order is preserved across hide/show because visibility lives in\n * `hidden`, never in the order.\n */\nexport function resolveColumns(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): ResolvedColumn[] {\n const schemaNames = collection.fields.map((field) => field.name)\n // EC-445: the valid universe to KEEP from the saved order is schema fields PLUS the\n // applicable pseudo-columns (which are not in `collection.fields`) — so a seeded\n // `$state`/`$url`/`$updatedAt` is preserved + ordered, never dropped as \"unknown\".\n const keep = new Set([...schemaNames, ...pseudo])\n const hidden = new Set(state.hidden)\n const inState = new Set(state.columns)\n // Keep the saved order, restricted to the live universe and de-duplicated (a\n // corrupted persisted state must never render one field as two columns).\n const ordered: string[] = []\n const seen = new Set<string>()\n for (const name of state.columns) {\n if (keep.has(name) && !seen.has(name)) {\n ordered.push(name)\n seen.add(name)\n }\n }\n // Append universe members the saved order predates: new schema fields (EC-213\n // discovery), then applicable pseudo-columns not yet placed (EC-445).\n const appended = [\n ...schemaNames.filter((name) => !seen.has(name)),\n ...pseudo.filter((name) => !seen.has(name)),\n ]\n return [...ordered, ...appended].map((field) => {\n // A freshly-appended opt-in pseudo-column ($publishedAt) starts hidden; once it\n // is in the saved order (an editor un-hid it) its visibility follows `hidden`.\n const defaultHiddenAppend = DEFAULT_HIDDEN_PSEUDO_COLUMNS.has(field) && !inState.has(field)\n return { field, visible: !hidden.has(field) && !defaultHiddenAppend }\n })\n}\n\n/** The visible columns of a view, in render order (EC-213). */\nexport function visibleColumns(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): string[] {\n return resolveColumns(collection, state, pseudo)\n .filter((column) => column.visible)\n .map((column) => column.field)\n}\n\n/**\n * The title/link column — the document IDENTITY column (EC-242): the schema title\n * field, shown as the leftmost linked cell whose content is `resolveDocumentTitle`\n * (a string `titleField` or a function pattern). Always present regardless of\n * column visibility — it is the document's identity, not a toggleable data column —\n * and excluded from the data columns so the title never shows twice. Falls back to\n * the first visible column, then the first field, then `id`, when no title field\n * is resolvable (e.g. a function title with no backing `title` field).\n */\nexport function primaryColumn(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): string {\n return (\n titleFieldOf(collection)?.name ??\n // EC-445: a pseudo-column is never the identity column (it has no title value) —\n // fall back to the first visible SCHEMA column.\n visibleColumns(collection, state, pseudo).find((name) => !isPseudoColumn(name)) ??\n collection.fields[0]?.name ??\n 'id'\n )\n}\n\n/**\n * Reconcile `columns` to the full resolved order so column edits operate on a\n * complete, stable order (drops removed fields, pins appended ones), and prune\n * `hidden` to fields the live schema still has (a column removed from the schema\n * must not leave dead `hidden` cruft that trips dirty-detection / persists).\n */\nfunction withResolvedOrder(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): TableViewState {\n const columns = resolveColumns(collection, state, pseudo).map((column) => column.field)\n const live = new Set(columns)\n const hidden = state.hidden.filter((name) => live.has(name))\n return { ...state, columns, hidden }\n}\n\n/**\n * The canonical, schema-resolved form of a view state — full column order with\n * `hidden` pruned to live fields (EC-213). Two states that render identically\n * share one canonical form, so dirty-detection never trips on a mere column\n * reconciliation or a stale `hidden` entry (only a real filter/sort/visibility/\n * order change counts as \"unsaved\").\n */\nexport function canonicalViewState(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): TableViewState {\n return normalizeViewState(withResolvedOrder(collection, state, pseudo))\n}\n\n/**\n * Toggle a column's visibility — position is preserved (EC-213): visibility\n * lives in `hidden`, the order in `columns` is untouched. Columns the saved\n * order predates are pinned into `columns` first so their place is stable.\n */\nexport function toggleColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n pseudo: readonly string[] = [],\n): TableViewState {\n const base = withResolvedOrder(collection, state, pseudo)\n const hidden = base.hidden.includes(field)\n ? base.hidden.filter((name) => name !== field)\n : [...base.hidden, field]\n return { ...base, hidden }\n}\n\n/** Move a column one position left (-1) or right (+1) in the full column order. */\nexport function moveColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n delta: -1 | 1,\n pseudo: readonly string[] = [],\n): TableViewState {\n const base = withResolvedOrder(collection, state, pseudo)\n const from = base.columns.indexOf(field)\n const to = from + delta\n if (from < 0 || to < 0 || to >= base.columns.length) return state\n const columns = [...base.columns]\n columns.splice(from, 1)\n columns.splice(to, 0, field)\n return { ...base, columns }\n}\n"]}
1
+ {"version":3,"file":"view-model.js","sourceRoot":"","sources":["../../../src/lib/cms-views/view-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC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KAAK,CAAC,CAAA;IACxC,MAAM,EAAE,GAAG,IAAI,GAAG,KAAK,CAAA;IACvB,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACjE,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;IACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACvB,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;IAC5B,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import { z } from 'zod'\nimport {\n canonicalDateValue,\n localizedStringSchema,\n resolveField,\n resolveLabel,\n titleFieldOf,\n} from '@elytracms/core/cms-core'\nimport { localizedLabel, translate } from '../i18n'\nimport { contentQueryErrorMessage } from '../persona/labels'\nimport type {\n CmsDocument,\n CollectionDef,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n} from '@elytracms/core/cms-core'\nimport {\n FILTER_OPERATORS,\n compareListEntries,\n sortScalarOf,\n filterableFields,\n matchesFieldValue,\n validateWhere,\n} from '@elytracms/core/content'\nimport type {\n FilterCondition,\n FilterOperator,\n FilterScalar,\n NormalizedCondition,\n WhereInput,\n} from '@elytracms/core/content'\n\n/**\n * The pure table-view model for the CMS collection table (EC-169).\n *\n * A view bundles three things: filters in the closed AD-3 vocabulary\n * (`eq`/`in`/`lt`/`lte`/`gt`/`gte`, AND-only — exactly `@elytracms/core/content`'s\n * query model, evaluated with the same matching/ordering primitives), a sort\n * (field + direction), and the visible/ordered columns. Everything here is\n * plain data + functions so filtering, dirtiness, and column edits are\n * testable without a DOM.\n *\n * Filters are offered ONLY on fields the schema declares `filterable: true`\n * (EC-143), plus one built-in option: the document's publication state. The\n * state is document metadata, not a schema field — it powers the\n * \"show me drafts → bulk publish\" working set and still speaks only the\n * closed vocabulary (`eq`/`in`).\n */\n\n// --- Schemas (single source of truth — persisted view records reuse these) ----\n\nexport const filterScalarSchema = z.union([z.string(), z.number(), z.boolean()])\n\nexport const filterClauseSchema = z.object({\n /** A schema field name, or {@link STATE_FIELD} for the publication state. */\n field: z.string().min(1),\n op: z.enum(FILTER_OPERATORS),\n /** `in` carries an array of scalars; every other operator one scalar. */\n value: z.union([filterScalarSchema, z.array(filterScalarSchema)]),\n})\nexport type FilterClause = z.infer<typeof filterClauseSchema>\n\nexport const viewSortSchema = z.object({\n field: z.string().min(1),\n dir: z.enum(['asc', 'desc']),\n})\nexport type ViewSort = z.infer<typeof viewSortSchema>\n\nexport const tableViewStateSchema = z.object({\n /** AND-only list of conditions (no OR, no nesting — vision AD-3). */\n filters: z.array(filterClauseSchema),\n sort: viewSortSchema.nullable(),\n /**\n * The canonical column order (field names) — EVERY column, visible or not\n * (EC-213). Order is independent of visibility: hiding then re-showing a\n * column keeps its place. Schema fields absent here resolve in at the end\n * (see {@link resolveColumns}).\n */\n columns: z.array(z.string().min(1)),\n /**\n * The subset of {@link TableViewState.columns} that is hidden. Defaults to\n * `[]` so views persisted before EC-213 (no `hidden` key) load unchanged.\n */\n hidden: z.array(z.string().min(1)).default([]),\n})\nexport type TableViewState = z.infer<typeof tableViewStateSchema>\n\n// --- The built-in publication-state filter column ------------------------------\n\n/**\n * Sentinel field key for the publication state. `$`-prefixed so it can never\n * collide with a schema field name (`fieldDefSchema` names are identifiers).\n */\nexport const STATE_FIELD = '$state'\n\nconst STATE_VALUES = ['draft', 'published'] as const\n\n// --- Reserved pseudo-COLUMNS (EC-445) ------------------------------------------\n\n/**\n * Reserved pseudo-COLUMN keys — the columns-axis siblings of the filter-axis\n * {@link STATE_FIELD}. `$`-prefixed so they can never collide with a schema field\n * name; they participate in a view's `columns` list AND the Display picker exactly\n * like a schema field (orderable / hideable / includable), but they are NOT drawn\n * from `collection.fields` — the column UNIVERSE is `[...schemaFields, ...pseudoColumns]`.\n *\n * - `$state` — publication status. A reserved `$`-key, but NO LONGER a reorderable\n * column: EC-448 promoted it to a FIXED structural leading column (checkbox →\n * status-dot → title), so it is NOT emitted by {@link pseudoColumns} and never\n * participates in the reorderable columns/hidden/order model. It stays a reserved\n * key (filter + sort) and {@link isPseudoColumn} still recognizes it, so an authored\n * view listing `$state` is a harmless no-op (see {@link resolveConfigColumns}).\n * - `$url` — the derived delivery URL (routable collections only; NON-sortable).\n * - `$updatedAt` — the record's last-write timestamp.\n * - `$publishedAt` — the record's FIRST-publish instant (EC-447; opt-in, HIDDEN by\n * default). Now materialized end-to-end (`cmsDocuments.publishedAt` → source\n * `timestamps.publishedAt`) and emitted by {@link pseudoColumns} when the source\n * both materializes timestamps and has a publish lifecycle.\n */\nexport const URL_FIELD = '$url'\nexport const PUBLISHED_AT_FIELD = '$publishedAt'\nexport const UPDATED_AT_FIELD = '$updatedAt'\n\n/**\n * Every reserved pseudo-column key. `$state` is included (it is still a reserved\n * `$`-key: the filter/sort axis + the FIXED structural status column, EC-448) so\n * {@link isPseudoColumn} never mistakes it for a schema field — but it is NOT a\n * reorderable column, so it is absent from the `pseudo` sets {@link pseudoColumns}\n * emits into the order/hide/picker model.\n */\nconst PSEUDO_COLUMN_FIELDS: readonly string[] = [\n STATE_FIELD,\n URL_FIELD,\n PUBLISHED_AT_FIELD,\n UPDATED_AT_FIELD,\n]\n\n/** Is `name` a reserved pseudo-column (a `$`-key, not a schema field)? */\nexport function isPseudoColumn(name: string): boolean {\n return PSEUDO_COLUMN_FIELDS.includes(name)\n}\n\n/**\n * Pseudo-columns HIDDEN by default (opt-in): the extra publish timestamp. Everything\n * else applicable (`$updatedAt`/`$state`/`$url`) is on by default (owner, 2026-07-17).\n */\nconst DEFAULT_HIDDEN_PSEUDO_COLUMNS: ReadonlySet<string> = new Set([PUBLISHED_AT_FIELD])\n\n/**\n * Capability signals that make a pseudo-column applicable to a collection/source\n * (EC-445). Supplied by the caller from the portable source — the model stays pure.\n */\nexport interface PseudoColumnOptions {\n /** The source materializes per-document timestamps → `$updatedAt` applies. */\n timestamps?: boolean\n /**\n * The collection has a publish lifecycle. Gates `$publishedAt` (with `timestamps`).\n * EC-448: it no longer gates a reorderable `$state` column — `$state` is the FIXED\n * structural status column, gated by the same signal at the render site, not here.\n */\n publishing?: boolean\n /** The collection resolves delivery URLs → `$url` applies (mirrors `urlByDocId`). */\n routable?: boolean\n}\n\n/**\n * The reserved REORDERABLE pseudo-columns that APPLY to a collection, in their default\n * appended order (EC-445/EC-447): `$updatedAt`, `$publishedAt`, then `$url`. `$url` is\n * gated on `routable` (a non-routable collection has no URL column, not an empty one),\n * `$updatedAt` on `timestamps`. `$publishedAt` (EC-447) needs BOTH `timestamps` (its\n * materialized value) AND `publishing` (a publish lifecycle to have a publish date) —\n * it is OPT-IN, HIDDEN by default (`DEFAULT_HIDDEN_PSEUDO_COLUMNS`), so it joins the\n * universe/picker without appearing in the baseline lens.\n *\n * NOTE (EC-448): `$state` is NO LONGER emitted here. It became a FIXED structural\n * leading column (checkbox → status-dot → title), rendered by `collection-table.tsx`\n * regardless of the reorderable model — so it is never in the order/hide/picker set,\n * even though `publishing` is what gates BOTH it and the status column's presence.\n * `opts.publishing` therefore only affects `$publishedAt` here. Pure — a caller\n * (`pseudoColumnsForSource`) supplies the signals from the source.\n */\nexport function pseudoColumns(collection: CollectionDef, opts: PseudoColumnOptions = {}): string[] {\n void collection // reserved for future per-collection gating; kept for API symmetry\n const cols: string[] = []\n if (opts.timestamps) cols.push(UPDATED_AT_FIELD)\n // EC-447: a publish date needs both a timestamps source (the value) AND a publish\n // lifecycle (the meaning). Hidden by default → surfaced via the Display picker / a\n // config view's `columns`, never a blank column on a rail that can't publish.\n if (opts.timestamps && opts.publishing) cols.push(PUBLISHED_AT_FIELD)\n // EC-448: $state is structural (fixed leading column), not a reorderable pseudo-column.\n if (opts.routable) cols.push(URL_FIELD)\n return cols\n}\n\n/**\n * The per-document metadata accessors the pseudo-DATE columns sort by (EC-445) — the\n * columns-axis analogue of {@link IsPublished}. Threaded into the sort machinery so a\n * `$updatedAt`/`$publishedAt` sort orders by the source's materialized timestamp; a\n * missing accessor (fixtures/tests) sorts those rows last. `$url` is derived → never sorted.\n */\nexport interface PseudoColumnMeta {\n updatedAt?(doc: CmsDocument): string | undefined\n publishedAt?(doc: CmsDocument): string | undefined\n}\n\n/** One field the filter builder may offer. */\nexport interface FilterableFieldOption {\n /** Clause field key: a schema field name, or {@link STATE_FIELD}. */\n field: string\n label: string\n /** The schema field def, or `null` for the built-in publication state. */\n def: FieldDef | null\n}\n\nexport const STATE_OPTION: FilterableFieldOption = {\n field: STATE_FIELD,\n label: 'State',\n def: null,\n}\n\n/**\n * The closed list of fields the filter builder offers: exactly the schema's\n * `filterable: true` fields (EC-143) plus the publication state. Nothing else\n * is ever offered — the UI builds queries, it does not invent a language.\n */\nexport function filterableFieldOptions(collection: CollectionDef): FilterableFieldOption[] {\n const schemaOptions = filterableFields(collection).map((field) => ({\n field: field.name,\n label: localizedLabel(field.form?.label, field.name),\n def: field,\n }))\n return [...schemaOptions, STATE_OPTION]\n}\n\nexport function filterOptionFor(\n collection: CollectionDef,\n field: string,\n): FilterableFieldOption | undefined {\n return filterableFieldOptions(collection).find((option) => option.field === field)\n}\n\n// --- Operators per field type (EC-345) ------------------------------------------\n\n/**\n * The per-type operator SET the builder offers (EC-345), always a subset of the\n * closed `FILTER_OPERATORS` — the UI narrows the vocabulary, it never extends it.\n * Ratified sets (Oli, 2026-07-08):\n *\n * - text: contains (default) · equals · starts with · ends with · empty\n * - number: equals · < · ≤ · > · ≥ · empty\n * - date: equals · before · … · after · empty (same ops as number, date labels)\n * - boolean: is\n * - select: is · is any of · empty\n * - relation / asset: is · is any of · empty (relation value = the relation picker;\n * `eq` on a `multiple` relation is membership — array-contains, EC-255 semantics)\n * - state pseudo-field: is · is any of (unchanged — a publication state is never empty)\n */\nexport function operatorsFor(option: FilterableFieldOption): FilterOperator[] {\n if (option.def === null) return ['eq', 'in'] // publication state\n switch (option.def.type) {\n case 'boolean':\n return ['eq']\n case 'number':\n case 'date':\n return ['eq', 'lt', 'lte', 'gt', 'gte', 'empty']\n case 'select':\n case 'relation':\n case 'asset':\n return ['eq', 'in', 'empty']\n default:\n // text (and any other string-shaped field)\n return ['contains', 'eq', 'startsWith', 'endsWith', 'empty']\n }\n}\n\n/**\n * A visual choice in the operator dropdown (EC-345). Usually one per operator,\n * but `empty` splits into two — \"is empty\" (`true`) and \"is not empty\" (`false`) —\n * so an editor never has to reason about a boolean value; the choice carries the\n * preset. `token` is the `<option value>`, `labelKey` a catalog key ({@link operatorLabelKey}).\n */\nexport interface OperatorChoice {\n token: string\n op: FilterOperator\n /** Value forced when this choice is picked (the `empty` true/false), else undefined. */\n presetValue?: FilterScalar\n labelKey: string\n}\n\n/**\n * The operator dropdown entries for a field (EC-345): {@link operatorsFor} expanded\n * for display, with `empty` shown as the two self-describing choices.\n */\nexport function operatorChoices(option: FilterableFieldOption): OperatorChoice[] {\n const choices: OperatorChoice[] = []\n for (const op of operatorsFor(option)) {\n if (op === 'empty') {\n choices.push({ token: 'empty:true', op, presetValue: true, labelKey: 'cms.filter.op.isEmpty' })\n choices.push({\n token: 'empty:false',\n op,\n presetValue: false,\n labelKey: 'cms.filter.op.isNotEmpty',\n })\n continue\n }\n choices.push({ token: op, op, labelKey: operatorLabelKey(op, option) })\n }\n return choices\n}\n\n/**\n * The catalog key for an operator's label (EC-241/EC-345), keyed by operator AND\n * field type — `eq` reads \"equals\" on text/number, \"on\" on a date, \"is\" on an\n * enum-like field; `lt` reads \"less than\" on a number, \"before\" on a date. `empty`\n * additionally depends on its VALUE (is empty / is not empty). Pure → unit-tested.\n */\nexport function operatorLabelKey(\n op: FilterOperator,\n option: FilterableFieldOption | undefined,\n value?: FilterScalar | readonly FilterScalar[],\n): string {\n const type = option?.def?.type\n switch (op) {\n case 'contains':\n return 'cms.filter.op.contains'\n case 'startsWith':\n return 'cms.filter.op.startsWith'\n case 'endsWith':\n return 'cms.filter.op.endsWith'\n case 'in':\n return 'cms.filter.op.isAnyOf'\n case 'empty':\n return value === false ? 'cms.filter.op.isNotEmpty' : 'cms.filter.op.isEmpty'\n case 'eq':\n // \"on\" for a date; \"is\" for enum-like refs; \"equals\" for text/number/unknown\n // (and the publication-state pseudo-field, whose `def` is null → unchanged).\n if (type === 'date') return 'cms.filter.op.on'\n if (type === 'boolean' || type === 'select' || type === 'relation' || type === 'asset') {\n return 'cms.filter.op.is'\n }\n return 'cms.filter.op.equals'\n case 'lt':\n return type === 'date' ? 'cms.filter.op.before' : 'cms.filter.op.lessThan'\n case 'lte':\n return type === 'date' ? 'cms.filter.op.onOrBefore' : 'cms.filter.op.atMost'\n case 'gt':\n return type === 'date' ? 'cms.filter.op.after' : 'cms.filter.op.greaterThan'\n case 'gte':\n return type === 'date' ? 'cms.filter.op.onOrAfter' : 'cms.filter.op.atLeast'\n }\n}\n\n/** A sensible starting clause when a field is added to the builder (EC-345). */\nexport function defaultClause(option: FilterableFieldOption): FilterClause {\n if (option.def === null) return { field: STATE_FIELD, op: 'eq', value: 'published' }\n switch (option.def.type) {\n case 'boolean':\n return { field: option.field, op: 'eq', value: true }\n case 'number':\n case 'date':\n return { field: option.field, op: 'eq', value: option.def.type === 'number' ? 0 : '' }\n case 'select':\n return { field: option.field, op: 'eq', value: option.def.options[0]?.value ?? '' }\n case 'relation':\n case 'asset':\n return { field: option.field, op: 'eq', value: '' }\n default:\n // text (and any other string-shaped field): `contains` is the natural default\n return { field: option.field, op: 'contains', value: '' }\n }\n}\n\n// --- Text ⇄ scalar coercion (the value inputs of the builder) -------------------\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/** Coerce one text input into the scalar a clause compares against. */\nexport function scalarFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar {\n const type = option?.def?.type\n if (type === 'number') {\n const trimmed = raw.trim()\n if (trimmed === '') return raw // an emptied input must not become eq 0\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? raw : parsed\n }\n if (type === 'boolean') return raw === 'true'\n // EC-586: a date operand goes through THE date canonicaliser — the same one every\n // write and the comparator use — so `2026-09-18` means midnight UTC on that day.\n if (type === 'date' && DATE_ONLY.test(raw)) return canonicalDateValue(raw) ?? raw\n return raw\n}\n\n/** Parse a comma-separated list for the `in` operator. */\nexport function scalarListFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar[] {\n return raw\n .split(',')\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .map((part) => scalarFromText(option, part))\n}\n\nexport function scalarListToText(value: FilterScalar | FilterScalar[]): string {\n const list = Array.isArray(value) ? value : [value]\n return list.map(String).join(', ')\n}\n\n// --- Clause validation -----------------------------------------------------------\n\n/** A structured problem with one clause (by index in the filter list). */\nexport interface ClauseIssue {\n index: number\n message: string\n}\n\n/**\n * Validate clauses against the collection schema. Schema-field clauses run\n * through the canonical `validateWhere` (EC-143: `filterable` enforcement +\n * operator/value shape); state clauses check the `eq`/`in` subset and the\n * draft/published value set. Invalid clauses (e.g. a persisted view whose\n * field is no longer filterable) are reported — never silently applied.\n *\n * EC-494 — the two `$state` sentences are authored HERE, studio-side, so they call\n * `translate` directly; the schema-field ones come from `core/content`, below the\n * catalog in the DAG, and are resolved from the `messageRef` that error now carries.\n * Both halves of one line therefore render in the same language.\n */\nexport function validateClauses(\n collection: CollectionDef,\n clauses: readonly FilterClause[],\n): ClauseIssue[] {\n const issues: ClauseIssue[] = []\n clauses.forEach((clause, index) => {\n if (clause.field === STATE_FIELD) {\n if (clause.op !== 'eq' && clause.op !== 'in') {\n issues.push({ index, message: translate('cms.filter.issue.stateOperator') })\n return\n }\n const values = Array.isArray(clause.value) ? clause.value : [clause.value]\n if (!values.every((value) => (STATE_VALUES as readonly unknown[]).includes(value))) {\n issues.push({ index, message: translate('cms.filter.issue.stateValue') })\n }\n return\n }\n const where: WhereInput = {\n [clause.field]: { [clause.op]: clause.value } as FilterCondition,\n }\n const errors = validateWhere(collection, where)\n if (errors.length > 0) issues.push({ index, message: contentQueryErrorMessage(errors[0]!) })\n })\n return issues\n}\n\n// --- Matching & sorting (delegates to @elytracms/core/content's primitives) -------------\n\n/**\n * Published-ness source for the `$state` pseudo-field (EC-224): the version\n * POINTER, supplied by the caller as `cms.isPublished`. Defaults to \"nothing\n * published\" — a bare row carries no publish signal now that the flat `state`\n * field is gone, so the table (which knows the pointer) passes the real\n * predicate; fixtures/tests that don't surface `$state` get the safe default.\n */\nexport type IsPublished = (doc: CmsDocument) => boolean\nconst defaultIsPublished: IsPublished = () => false\n\n/**\n * The RAW locale-resolved value a document exposes for a clause field — an array\n * for a `multiple` relation/asset, a ref object for a single one, a scalar\n * otherwise. Matching runs on this (via `matchesFieldValue`) so it agrees with the\n * delivery/listing path exactly: array-contains for `multiple` relations (EC-255)\n * and whole-value `empty` semantics (EC-345). Sorting keeps its own scalar reduction.\n *\n * EC-580: read in the DISPLAYED view of the table's active locale (`resolveField`,\n * the per-field form of `valuesInLocale`) — what the row shows is what it sorts and\n * filters by, as delivery does in the request locale. It used to read a\n * per-document default locale, so a `de` table sorted by English values.\n */\nfunction rawValueOf(\n collection: CollectionDef,\n doc: CmsDocument,\n field: string,\n localeConfig: LocaleConfig,\n locale: Locale,\n isPublished: IsPublished,\n): unknown {\n if (field === STATE_FIELD) return isPublished(doc) ? 'published' : 'draft'\n if (!collection.fields.some((f) => f.name === field)) return undefined\n return resolveField(collection, doc, field, locale, localeConfig).value\n}\n\n/** The scalar a document exposes for a SORT field, in the active locale's view. */\nfunction scalarOf(\n collection: CollectionDef,\n doc: CmsDocument,\n field: string,\n localeConfig: LocaleConfig,\n locale: Locale,\n isPublished: IsPublished,\n meta: PseudoColumnMeta = {},\n): FilterScalar | null {\n if (field === STATE_FIELD) return isPublished(doc) ? 'published' : 'draft'\n // EC-445: the pseudo-DATE columns sort by the source's materialized ISO timestamp\n // (ISO strings order lexicographically = chronologically); `$url` is derived → not sortable.\n if (field === UPDATED_AT_FIELD) return meta.updatedAt?.(doc) ?? null\n if (field === PUBLISHED_AT_FIELD) return meta.publishedAt?.(doc) ?? null\n if (field === URL_FIELD) return null\n const def = collection.fields.find((f) => f.name === field)\n if (!def) return null\n // EC-586: a `date` sorts as the instant it denotes (`sortScalarOf`), as delivery does.\n return sortScalarOf(resolveField(collection, doc, field, locale, localeConfig).value, def)\n}\n\n/**\n * Does a document satisfy one clause? Identical verdict to the content accessors'\n * delivery/listing path: both reduce to `@elytracms/core/content`'s\n * `matchesFieldValue` over the RAW field value (so `contains`/`empty`/multiple-\n * relation membership all behave the same on the table as on the live site).\n */\nexport function clauseMatches(\n collection: CollectionDef,\n doc: CmsDocument,\n localeConfig: LocaleConfig,\n locale: Locale,\n clause: FilterClause,\n isPublished: IsPublished = defaultIsPublished,\n): boolean {\n const value = rawValueOf(collection, doc, clause.field, localeConfig, locale, isPublished)\n const condition = { [clause.op]: clause.value } as NormalizedCondition\n // EC-586: the field def makes a `date` compare as an instant — delivery's exact rule.\n return matchesFieldValue(value, condition, collection.fields.find((f) => f.name === clause.field))\n}\n\n/**\n * Sort documents by one column in the canonical deterministic order\n * (`compareListEntries`: typed value order, id-ascending tiebreak). Unlike the\n * content accessors, the *table* may sort any rendered column — sorting is a\n * presentation concern here; the `filterable` flag governs filters.\n */\nexport function sortViewDocuments(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n locale: Locale,\n sort: ViewSort | null,\n isPublished: IsPublished = defaultIsPublished,\n meta: PseudoColumnMeta = {},\n): CmsDocument[] {\n if (sort === null) return [...docs]\n const positions = new Map(\n docs.map((doc) => [\n doc.id,\n scalarOf(collection, doc, sort.field, localeConfig, locale, isPublished, meta),\n ]),\n )\n return [...docs].sort((a, b) =>\n compareListEntries(\n { id: a.id, sortValue: positions.get(a.id) ?? null },\n { id: b.id, sortValue: positions.get(b.id) ?? null },\n sort.dir,\n ),\n )\n}\n\n/** The filtered + sorted documents of a view, plus any clause issues. */\nexport interface AppliedViewState {\n docs: CmsDocument[]\n /** Clauses that failed validation — reported AND excluded from matching. */\n issues: ClauseIssue[]\n}\n\n/**\n * Apply a view state to a document list: validate clauses, AND-match the valid\n * ones, sort. Invalid clauses never filter silently — they come back as\n * issues for the UI to surface.\n */\nexport function applyViewState(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n locale: Locale,\n state: TableViewState,\n isPublished: IsPublished = defaultIsPublished,\n meta: PseudoColumnMeta = {},\n): AppliedViewState {\n const issues = validateClauses(collection, state.filters)\n const invalid = new Set(issues.map((issue) => issue.index))\n const active = state.filters.filter((_, index) => !invalid.has(index))\n const matched = docs.filter((doc) =>\n active.every((clause) =>\n clauseMatches(collection, doc, localeConfig, locale, clause, isPublished),\n ),\n )\n return {\n docs: sortViewDocuments(collection, matched, localeConfig, locale, state.sort, isPublished, meta),\n issues,\n }\n}\n\n// --- View state construction, equality, columns ----------------------------------\n\n/** The id of the synthesized built-in \"All entries\" baseline view (EC-444). */\nexport const ALL_VIEW_ID = 'all'\n\n/** The default (unnamed) view: no filters, no sort, every field visible. */\n/**\n * Field types kept OFF the default table columns (EC-246b): the composite editing\n * surfaces — a blocks canvas, rich text, a structured object/repeater — read as\n * noise in a scalar list. `filterable` no longer forces (or governs) a column; the\n * default lens is \"all scalars\". These stay in the column picker one toggle away,\n * and any named view may list them in its `columns`; they're just off by default.\n */\nconst NON_DEFAULT_COLUMN_TYPES = new Set<FieldDef['type']>(['blocks', 'richText', 'object'])\n\n/**\n * Field names OFF the built-in baseline lens by default: exactly the composite\n * editing surfaces (blocks/richText/object) — always noise in a scalar list. The\n * default lens is \"all scalars\"; there is no per-field column opt-out any more\n * (EC-444 hard-removed `form.column`). A field stays in the picker one toggle away,\n * and a view curates columns by declaring an explicit `columns` list (or the\n * `id: 'default'` baseline override).\n */\nfunction defaultHiddenColumns(collection: CollectionDef, pseudo: readonly string[] = []): string[] {\n const composites = collection.fields\n .filter((f) => NON_DEFAULT_COLUMN_TYPES.has(f.type))\n .map((f) => f.name)\n // EC-445: applicable opt-in pseudo-columns ($publishedAt) start hidden; the rest\n // ($updatedAt/$state/$url) are visible by default (owner: keep them on).\n const hiddenPseudo = pseudo.filter((name) => DEFAULT_HIDDEN_PSEUDO_COLUMNS.has(name))\n return [...composites, ...hiddenPseudo]\n}\n\nexport function defaultViewState(\n collection: CollectionDef,\n pseudo: readonly string[] = [],\n): TableViewState {\n return {\n filters: [],\n sort: null,\n // Every field keeps a slot (order + picker), but the composite surfaces start\n // hidden so the default lens is the collection's scalar columns (EC-246b/EC-444).\n // EC-445: the applicable reserved pseudo-columns append after the data columns.\n columns: orderedColumnNames(collection, pseudo),\n hidden: defaultHiddenColumns(collection, pseudo),\n }\n}\n\n/**\n * Resolve an authored VISIBLE column list (EC-444) into the internal two-axis\n * `{columns, hidden}` table state. The authored list is exactly the columns shown,\n * in order; every OTHER schema field is appended (in schema order) and hidden — the\n * same shape {@link defaultViewState} produces, so {@link resolveColumns} renders\n * precisely the authored list, visible, in that order. An omitted (or empty) list\n * inherits the collection's default lens (all scalars visible, composites hidden).\n * Unknown names in the authored list (a field the schema no longer has) are dropped.\n */\nexport function resolveConfigColumns(\n collection: CollectionDef,\n visible: readonly string[] | undefined,\n pseudo: readonly string[] = [],\n): Pick<TableViewState, 'columns' | 'hidden'> {\n if (visible === undefined || visible.length === 0) {\n const base = defaultViewState(collection, pseudo)\n return { columns: base.columns, hidden: base.hidden }\n }\n const universe = orderedColumnNames(collection, pseudo)\n const inUniverse = new Set(universe)\n const seen = new Set<string>()\n const shown: string[] = []\n for (const name of visible) {\n if (inUniverse.has(name) && !seen.has(name)) {\n shown.push(name)\n seen.add(name)\n }\n }\n const rest = universe.filter((name) => !seen.has(name))\n // EC-445: a schema-ONLY authored list (mentioning no pseudo-column) keeps the\n // applicable pseudo-columns at their DEFAULT visibility — so a consumer's\n // pre-EC-445 `columns:[…schema…]` list still shows today's url (+ updatedAt).\n // Mentioning ANY reorderable pseudo-column switches them to the visible-list rule\n // (only listed shows). EC-448: `$state` is EXCLUDED here — it is a fixed structural\n // column, not a reorderable one, so an authored `$state` is an inert no-op: it must\n // not flip the visible-list rule (nor is it in the universe, so it is simply dropped).\n const mentionsPseudo = visible.some((name) => isPseudoColumn(name) && name !== STATE_FIELD)\n const keepVisible = mentionsPseudo\n ? new Set<string>()\n : new Set(pseudo.filter((name) => !DEFAULT_HIDDEN_PSEUDO_COLUMNS.has(name)))\n const hidden = rest.filter((name) => !keepVisible.has(name))\n return { columns: [...shown, ...rest], hidden }\n}\n\n/** The reserved `views[]` id whose entry OVERRIDES the synthesized baseline view (EC-444). */\nexport const DEFAULT_VIEW_OVERRIDE_ID = 'default'\n\n/**\n * A config-declared view (EC-246b/EC-444) — the flat authoring shape a collection\n * declares in `cms/` config: `{ name, initial?, filters?, sort?, columns? }`.\n * Filters/sort/columns sit at the top level (no nested `state` wrapper). The\n * studio validates + interprets these; `cms-core` stores them opaquely (it\n * can't reference the filter vocabulary without a layering cycle).\n */\nexport const configViewSchema = z.object({\n /**\n * Optional stable id; defaults to a slug of `name`. The reserved value\n * {@link DEFAULT_VIEW_OVERRIDE_ID} (`'default'`) marks the baseline-override entry.\n */\n id: z.string().min(1).optional(),\n /**\n * View label; localizable (EC-343): a plain string or a `{ locale }` map, resolved\n * at the render site via the same `resolveLabel` path as `form.label` (EC-241).\n */\n name: localizedStringSchema,\n /**\n * When true this view seeds the collection's INITIAL active view (EC-343/EC-444) —\n * the curated lens an editor lands on before picking one. At most one per collection;\n * a duplicate is a visible validation issue ({@link configViewIssues}), never silent.\n * The baseline lens stays available and stays the fallback.\n */\n initial: z.boolean().optional(),\n /**\n * @deprecated EC-444 — renamed to {@link ConfigView.initial}. Still read as an alias\n * for one release (`initial ?? default`) with a console warning; removed next release.\n * Distinct from a field's default VALUE and from the reserved `id: 'default'` override.\n */\n default: z.boolean().optional(),\n filters: z.array(filterClauseSchema).optional(),\n sort: viewSortSchema.nullable().optional(),\n /**\n * The single ordered list of VISIBLE columns (EC-444): what you list is what shows,\n * in that order. Omit to inherit the collection's default columns (all scalars). The\n * two-axis `{columns, hidden}` internal state is derived by {@link resolveConfigColumns}.\n */\n columns: z.array(z.string().min(1)).optional(),\n})\nexport type ConfigView = z.infer<typeof configViewSchema>\n\n/**\n * A resolved view: identity + the table state it restores (matches `SavedView`).\n * `name` stays a {@link LocalizedString} — resolved at the render site (EC-343), like\n * `form.label`. `initial` marks the first-load seed (see {@link defaultConfigViewId}),\n * resolved from the authored `initial ?? default` flag (EC-444).\n */\nexport interface ResolvedView {\n id: string\n name: LocalizedString\n state: TableViewState\n initial?: boolean\n}\n\n/**\n * Slug used to derive a config view's stable id from its name. A localized name\n * (EC-343) slugs its DEFAULT-locale text so the id is stable across the active UI\n * locale (an id must not shift when a German editor loads the same config).\n */\nfunction configViewId(name: LocalizedString, index: number): string {\n const text = resolveLabel(name) ?? ''\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n return `config:${slug || index}`\n}\n\n/**\n * Resolve a collection's config-declared `views` into full {@link ResolvedView}s\n * (EC-246b). Each is validated with {@link configViewSchema}; malformed entries\n * and duplicate ids are dropped (defensive). Columns fall back to the collection\n * default when a view doesn't pin them, so a filter-only view still renders every\n * column. Config views are shared and change only in\n * code — the runtime never mutates them.\n */\nexport function configViewsFor(\n collection: CollectionDef,\n pseudo: readonly string[] = [],\n): ResolvedView[] {\n const declared = collection.views\n if (!Array.isArray(declared)) return []\n const seen = new Set<string>()\n const resolved: ResolvedView[] = []\n declared.forEach((raw, index) => {\n const parsed = configViewSchema.safeParse(raw)\n if (!parsed.success) return\n const view = parsed.data\n const id = view.id ?? configViewId(view.name, index)\n if (seen.has(id)) return\n seen.add(id)\n // EC-444: `initial` supersedes the deprecated `default` alias (one-release window).\n const initial = view.initial ?? view.default\n const { columns, hidden } = resolveConfigColumns(collection, view.columns, pseudo)\n resolved.push({\n id,\n name: view.name,\n ...(initial ? { initial: true } : {}),\n state: normalizeViewState({\n filters: view.filters ?? [],\n sort: view.sort ?? null,\n columns,\n hidden,\n }),\n })\n })\n return resolved\n}\n\n/**\n * Does the collection declare a baseline-override view (a config view whose id is\n * {@link DEFAULT_VIEW_OVERRIDE_ID})? When true the synthesized \"All entries\" lens is\n * replaced by that entry verbatim (see {@link resolveCollectionViews}), EC-444.\n */\nexport function hasDefaultViewOverride(collection: CollectionDef): boolean {\n return configViewsFor(collection).some((view) => view.id === DEFAULT_VIEW_OVERRIDE_ID)\n}\n\n/**\n * The ordered view list a collection surfaces (EC-444): the baseline first, then the\n * config-declared views in declaration order. The baseline is either an authored\n * OVERRIDE (the config view whose id is {@link DEFAULT_VIEW_OVERRIDE_ID}, used\n * VERBATIM and NOT repeated among the trailing views) or, absent one, the\n * `synthesizedBaseline` the caller passes (the studio's translated \"All entries\"\n * lens). Pure — the store supplies the synthesized baseline (i18n-bound `name`).\n */\nexport function resolveCollectionViews(\n collection: CollectionDef,\n synthesizedBaseline: ResolvedView,\n pseudo: readonly string[] = [],\n): ResolvedView[] {\n const configViews = configViewsFor(collection, pseudo)\n const overrideIndex = configViews.findIndex((view) => view.id === DEFAULT_VIEW_OVERRIDE_ID)\n if (overrideIndex < 0) return [synthesizedBaseline, ...configViews]\n const override = configViews[overrideIndex]!\n const rest = configViews.filter((_, index) => index !== overrideIndex)\n return [override, ...rest]\n}\n\n/**\n * The ids of config views that still use the DEPRECATED `default` flag without the\n * new `initial` (EC-444). Drives the one-release deprecation warning (mirrors the\n * duplicate-default channel); empty once every view has migrated to `initial`.\n */\nexport function deprecatedDefaultFlagViewIds(collection: CollectionDef): string[] {\n const declared = collection.views\n if (!Array.isArray(declared)) return []\n const seen = new Set<string>()\n const ids: string[] = []\n declared.forEach((raw, index) => {\n const parsed = configViewSchema.safeParse(raw)\n if (!parsed.success) return\n const view = parsed.data\n const id = view.id ?? configViewId(view.name, index)\n if (seen.has(id)) return\n seen.add(id)\n if (view.default !== undefined && view.initial === undefined) ids.push(id)\n })\n return ids\n}\n\n/**\n * The id of the config view flagged `initial: true` (EC-343/EC-444; `default` read\n * as a deprecated alias) — the seed for a collection's INITIAL active view. When\n * several are flagged (a misconfiguration, reported by {@link configViewIssues}) the\n * FIRST in declaration order wins deterministically; when none is flagged the caller\n * falls back to the baseline lens. `undefined` when the collection flags none.\n */\nexport function defaultConfigViewId(collection: CollectionDef): string | undefined {\n return configViewsFor(collection).find((view) => view.initial)?.id\n}\n\n/** A config-level problem with a collection's declared views (EC-343/EC-444). */\nexport interface ConfigViewIssue {\n /** Stable code (kept from EC-343 to avoid catalog churn); reads \"duplicate initial\". */\n code: 'duplicate-default'\n message: string\n /** The offending view ids (all views flagged `initial`, in declaration order). */\n viewIds: string[]\n}\n\n/**\n * Validate a collection's config-declared views (EC-343/EC-444): at most one may set\n * `initial: true` (`default` counted as its deprecated alias). A duplicate is returned\n * as an explicit, structured issue — never silently swallowed — so the studio can\n * surface it (the first still wins deterministically for seeding, per\n * {@link defaultConfigViewId}). Pure and schema-only; the DOM-free counterpart of the\n * \"failures are first-class\" contract.\n */\nexport function configViewIssues(collection: CollectionDef): ConfigViewIssue[] {\n const initials = configViewsFor(collection).filter((view) => view.initial)\n if (initials.length <= 1) return []\n const viewIds = initials.map((view) => view.id)\n return [\n {\n code: 'duplicate-default',\n message: `Collection \"${collection.id}\" declares ${initials.length} initial views (${viewIds.join(', ')}); at most one view may set \\`initial: true\\`. Seeding \"${viewIds[0]}\".`,\n viewIds,\n },\n ]\n}\n\n/**\n * The default column order: the schema's title field first (it becomes the\n * default title/link column — EC-213 drops the separate primary-column\n * selector, treating the first visible column as the title), then the\n * remaining fields in schema order.\n */\nfunction orderedColumnNames(collection: CollectionDef, pseudo: readonly string[] = []): string[] {\n const names = collection.fields.map((field) => field.name)\n const title = titleFieldOf(collection)?.name\n const schemaOrdered =\n title === undefined || !names.includes(title)\n ? names\n : [title, ...names.filter((name) => name !== title)]\n // EC-445: the column UNIVERSE = schema fields, then the applicable reserved\n // pseudo-columns (they are NOT in `collection.fields`).\n return [...schemaOrdered, ...pseudo]\n}\n\n/** Deep-cloned canonical form (stable key order via the Zod shape). */\nexport function normalizeViewState(state: TableViewState): TableViewState {\n return tableViewStateSchema.parse(state)\n}\n\n/** Structural equality on normalized states — drives the \"unsaved changes\" affordance. */\nexport function viewStatesEqual(a: TableViewState, b: TableViewState): boolean {\n return JSON.stringify(normalizeViewState(a)) === JSON.stringify(normalizeViewState(b))\n}\n\n/** One column of a view resolved against the current schema (EC-213). */\nexport interface ResolvedColumn {\n /** The schema field name. */\n field: string\n /** Whether the column renders (`false` ⇒ in {@link TableViewState.hidden}). */\n visible: boolean\n}\n\n/**\n * Resolve a view's columns against the live schema (EC-213): every schema\n * field exactly once, in the view's saved order, with any fields the view\n * predates appended (visible) and any fields no longer in the schema dropped.\n * This is the single source of truth for \"which columns, in what order, shown\n * or hidden\" — order is preserved across hide/show because visibility lives in\n * `hidden`, never in the order.\n */\nexport function resolveColumns(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): ResolvedColumn[] {\n const schemaNames = collection.fields.map((field) => field.name)\n // EC-445: the valid universe to KEEP from the saved order is schema fields PLUS the\n // applicable pseudo-columns (which are not in `collection.fields`) — so a seeded\n // `$state`/`$url`/`$updatedAt` is preserved + ordered, never dropped as \"unknown\".\n const keep = new Set([...schemaNames, ...pseudo])\n const hidden = new Set(state.hidden)\n const inState = new Set(state.columns)\n // Keep the saved order, restricted to the live universe and de-duplicated (a\n // corrupted persisted state must never render one field as two columns).\n const ordered: string[] = []\n const seen = new Set<string>()\n for (const name of state.columns) {\n if (keep.has(name) && !seen.has(name)) {\n ordered.push(name)\n seen.add(name)\n }\n }\n // Append universe members the saved order predates: new schema fields (EC-213\n // discovery), then applicable pseudo-columns not yet placed (EC-445).\n const appended = [\n ...schemaNames.filter((name) => !seen.has(name)),\n ...pseudo.filter((name) => !seen.has(name)),\n ]\n return [...ordered, ...appended].map((field) => {\n // A freshly-appended opt-in pseudo-column ($publishedAt) starts hidden; once it\n // is in the saved order (an editor un-hid it) its visibility follows `hidden`.\n const defaultHiddenAppend = DEFAULT_HIDDEN_PSEUDO_COLUMNS.has(field) && !inState.has(field)\n return { field, visible: !hidden.has(field) && !defaultHiddenAppend }\n })\n}\n\n/** The visible columns of a view, in render order (EC-213). */\nexport function visibleColumns(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): string[] {\n return resolveColumns(collection, state, pseudo)\n .filter((column) => column.visible)\n .map((column) => column.field)\n}\n\n/**\n * The title/link column — the document IDENTITY column (EC-242): the schema title\n * field, shown as the leftmost linked cell whose content is `resolveDocumentTitle`\n * (a string `titleField` or a function pattern). Always present regardless of\n * column visibility — it is the document's identity, not a toggleable data column —\n * and excluded from the data columns so the title never shows twice. Falls back to\n * the first visible column, then the first field, then `id`, when no title field\n * is resolvable (e.g. a function title with no backing `title` field).\n */\nexport function primaryColumn(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): string {\n return (\n titleFieldOf(collection)?.name ??\n // EC-445: a pseudo-column is never the identity column (it has no title value) —\n // fall back to the first visible SCHEMA column.\n visibleColumns(collection, state, pseudo).find((name) => !isPseudoColumn(name)) ??\n collection.fields[0]?.name ??\n 'id'\n )\n}\n\n/**\n * Reconcile `columns` to the full resolved order so column edits operate on a\n * complete, stable order (drops removed fields, pins appended ones), and prune\n * `hidden` to fields the live schema still has (a column removed from the schema\n * must not leave dead `hidden` cruft that trips dirty-detection / persists).\n */\nfunction withResolvedOrder(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): TableViewState {\n const columns = resolveColumns(collection, state, pseudo).map((column) => column.field)\n const live = new Set(columns)\n const hidden = state.hidden.filter((name) => live.has(name))\n return { ...state, columns, hidden }\n}\n\n/**\n * The canonical, schema-resolved form of a view state — full column order with\n * `hidden` pruned to live fields (EC-213). Two states that render identically\n * share one canonical form, so dirty-detection never trips on a mere column\n * reconciliation or a stale `hidden` entry (only a real filter/sort/visibility/\n * order change counts as \"unsaved\").\n */\nexport function canonicalViewState(\n collection: CollectionDef,\n state: TableViewState,\n pseudo: readonly string[] = [],\n): TableViewState {\n return normalizeViewState(withResolvedOrder(collection, state, pseudo))\n}\n\n/**\n * Toggle a column's visibility — position is preserved (EC-213): visibility\n * lives in `hidden`, the order in `columns` is untouched. Columns the saved\n * order predates are pinned into `columns` first so their place is stable.\n */\nexport function toggleColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n pseudo: readonly string[] = [],\n): TableViewState {\n const base = withResolvedOrder(collection, state, pseudo)\n const hidden = base.hidden.includes(field)\n ? base.hidden.filter((name) => name !== field)\n : [...base.hidden, field]\n return { ...base, hidden }\n}\n\n/** Move a column one position left (-1) or right (+1) in the full column order. */\nexport function moveColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n delta: -1 | 1,\n pseudo: readonly string[] = [],\n): TableViewState {\n const base = withResolvedOrder(collection, state, pseudo)\n const from = base.columns.indexOf(field)\n const to = from + delta\n if (from < 0 || to < 0 || to >= base.columns.length) return state\n const columns = [...base.columns]\n columns.splice(from, 1)\n columns.splice(to, 0, field)\n return { ...base, columns }\n}\n"]}
@@ -182,10 +182,15 @@ export interface CollectionViewSource {
182
182
  }
183
183
  /** EC-595 A2 — the write model of a source (see {@link CollectionViewSource.writes}). */
184
184
  export type CollectionWrites = RecordWrites | DocumentWrites;
185
- /** An explicit-save rail: the editor's Save button writes the whole record. */
185
+ /**
186
+ * An explicit-save rail: the editor's Save button writes the record. `base` (EC-616) is the
187
+ * record as the editor OPENED it (or as of their last successful save) — a rail that can
188
+ * write per column sends only what differs from it, so a column another writer changed
189
+ * meanwhile is kept; absent for a record being created.
190
+ */
186
191
  export interface RecordWrites {
187
192
  readonly kind: 'record';
188
- save(doc: CmsDocument): void;
193
+ save(doc: CmsDocument, base?: CmsDocument): void;
189
194
  }
190
195
  /**
191
196
  * The revisioned-document write model (EC-595, ratified 2026-10-24): patches at the
@@ -1 +1 @@
1
- {"version":3,"file":"collection-view-source.js","sourceRoot":"","sources":["../../../src/lib/collection-view/collection-view-source.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAmSvD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA4B,EAC5B,KAAe,EACf,MAAoB;IAEpB,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AACjG,CAAC;AAqDD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAA4B;IACjE,OAAO,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE;QAClC,UAAU,EAAE,MAAM,CAAC,UAAU,KAAK,SAAS;QAC3C,UAAU,EAAE,MAAM,CAAC,UAAU,KAAK,SAAS;QAC3C,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO;KACtC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type {\n CmsDocument,\n CollectionDef,\n DocumentPatch,\n DocumentRef,\n ValuePath,\n DocumentUrl,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n RestoreScope,\n} from '@elytracms/core/cms-core'\nimport type { CmsValidationIssue } from '@elytracms/core/cms-core'\nimport type { OperationError } from '@elytracms/core/operations'\nimport type { CmsDocumentRecord, PresenceEntry, ReferenceTarget } from '@elytracms/core/persistence'\nimport type { CommitOutcome, DocumentConflict } from '../operations/cms-persistence'\nimport type { TableViewState } from '../cms-views/view-model'\nimport { pseudoColumns } from '../cms-views/view-model'\n// The concrete inline-edit + bulk vocabulary (Stream A relocates it into `lib` as it settles).\nimport type { CellCommitInput, CellCommitOutcome } from '../../components/cms/cell-edit'\nimport type { BulkAction, BulkReport, BulkSetField } from '../../components/cms/bulk-actions'\nimport type { DocumentVersionsView, ImportReport } from '../../components/cms/cms-store'\n\n/**\n * `CollectionViewSource` — the studio's UNIVERSAL interaction seam (EC-240,\n * vision AD-19).\n *\n * The list surface (`CollectionTable`) and the edit-shell (`DetailEditor`) are\n * the studio's universal interaction surfaces. Historically they read the\n * concrete `CmsStore` through `useCms()`, so they only served `cmsDocuments`.\n * This interface is the data-agnostic seam they render over instead, so the SAME\n * surfaces drive the users rail (EC-240), redirects (EC-303), the Components app\n * edit-shell, and any future rail — no hand-rolled UI per rail.\n *\n * **Shape:** the source is scoped to ONE collection (it carries `schema` +\n * `collectionId`), and its methods mirror the subset of `CmsStore` the surfaces\n * actually use — dropping the `collectionId` argument (the source already knows\n * it). Keeping the names/signatures aligned makes the CMS adapter a\n * behaviour-preserving pass-through and the migration near-mechanical.\n *\n * **Referential stability:** the surfaces put `documents`, `isPublished`,\n * `localeConfig`, etc. in `useMemo` dependency arrays. An implementation MUST\n * return stable references across renders (delegate to the underlying store's\n * already-stable methods; never wrap in a fresh closure each render) or memos\n * bust and the inline-edit order snapshot / perf regress.\n *\n * **Capabilities:** flags gate whole shell regions AND method presence — a source\n * with `capabilities.versions === false` (the users rail) never mounts the\n * Versions pane, so no `listVersions` read fires on credential records. Optional\n * method groups are present iff the flag is set.\n */\nexport interface CollectionViewSource {\n /** The rail/collection this source serves. */\n readonly collectionId: string\n /** The schema lens: fields, form tabs/groups, `titleField`, display nouns. */\n readonly schema: CollectionDef\n /** Which regions/methods this source supports. */\n readonly capabilities: CollectionViewCapabilities\n\n /** The project scope (asset picker, published-pool queries). Absent in fixture sessions. */\n readonly projectId?: string\n /**\n * The collection id assets live in (for a cell/field's `titleOf` label fallback\n * when {@link resolveAsset} finds no record). Present only for sources that\n * reference assets — a rail without assets (users) omits it.\n */\n readonly assetCollectionId?: string\n /** The ambient locale lens (only meaningful when `capabilities.locales`). */\n readonly localeConfig: LocaleConfig\n readonly activeLocale: Locale\n\n // --- Reads -----------------------------------------------------------------\n /** The full row set (view mechanics filter/sort this client-side). */\n documents(): CmsDocument[]\n get(ref: DocumentRef): CmsDocument | undefined\n /** A relation/asset target's display title (hides the string-vs-function `titleField`). */\n titleOf(ref: DocumentRef): string\n /**\n * List the candidate records of a relation field's declared `target` collection\n * — the pick-list for a relation picker (EC-072). References are first-class and\n * collection-based: the field's schema declares which collection(s) it targets,\n * and this resolves those rows for ANY target (cross-collection), not just this\n * source's own collection. The caller passes `field.target`; a multi-target field\n * (future) merges one call per declared target. An unknown/empty target yields `[]`.\n */\n referenceCandidates(collectionId: string): CmsDocument[]\n /**\n * The workspace schema a reference/asset can point at — the schema counterpart to\n * {@link referenceCandidates}. Needed for the cases that read a TARGET collection's\n * fields (an asset field editing the asset collection's own metadata; the reuse\n * capability correlating embed manifests against their target collection). A\n * reference is collection-based, so resolving one sometimes needs the target's\n * schema, not just its rows.\n */\n readonly collections: readonly CollectionDef[]\n isFieldReadOnly(field: FieldDef): boolean\n /**\n * Principal-based field access (EC-240, vision AD-18): `edit` (writable), `read`\n * (visible but read-only), or `hidden` (not rendered for this principal). This is\n * IDENTITY-driven and distinct from a field's content-conditional `hidden(values)`\n * — e.g. an editor's own `role` resolves to `read`, a viewer never SEES a\n * sensitive field (`hidden`). A single tri-state (never two independent flags) so\n * the nonsensical writable-but-invisible state can't be expressed. Optional:\n * absent ⇒ derived from {@link isFieldReadOnly} (`read`|`edit`), i.e. default-open\n * (permissions RESTRICT, never grant a baseline). Per-rail policy lives on the\n * source; the starter's policy flows into its construction (engine = mechanism).\n * Prefer {@link resolveFieldAccess} over calling this directly (it applies the\n * default-open fallback).\n */\n fieldAccess?(field: FieldDef, record?: CmsDocument): FieldAccess\n validate(doc: CmsDocument): CmsValidationIssue[]\n /**\n * Resolve an asset id to its display metadata for a cell/field, or `undefined`\n * when there is no asset backend (a source without assets degrades to a label\n * via {@link titleOf}, matching today's \"no AssetsProvider\" behaviour).\n */\n resolveAsset?(id: string): AssetDisplay | undefined\n /**\n * How this rail's records are addressed in the EC-155 reference index — the\n * target shape the delete/unpublish confirmation's inbound pre-flight queries\n * (EC-433). Absent ⇒ the document shape (`{ type: 'document', id: 'collection:id' }`),\n * which every `cmsDocuments` collection uses. The assets rail supplies\n * `{ type: 'asset' }` so its list/bulk delete confirmation enumerates the SAME\n * inbound references its detail surface does — a document-shaped lookup would\n * report a referenced asset as \"not referenced\" (the EC-319 objection that\n * originally kept `remove` off the assets rail).\n */\n referenceTarget?(ref: DocumentRef): ReferenceTarget\n /** The last failed/denied mutation, surfaced by the shell (never a silent failure). */\n readonly lastError: OperationError | null\n clearLastError(): void\n /**\n * Land any queued/optimistic writes so a subsequent pre-flight READ sees them\n * (the reference index is maintained on write). A source with no async\n * persistence omits it — its reads are already authoritative.\n */\n flush?(): Promise<void>\n\n /**\n * The studio route splat for a record's detail surface (the row link + the\n * post-create navigation target), e.g. `studioPath.cmsDocument(collectionId, id)`.\n * Rail-owned so the list never hard-codes the CMS route. `undefined` ⇒ the rail\n * has no detail surface, so rows render as plain text (no navigation).\n */\n detailPath?(id: string): string\n /**\n * The studio route splat for this rail's LIST surface — the edit shell's\n * \"back to list\" breadcrumb crumb and its post-delete navigation target, e.g.\n * `studioPath.cmsCollection(collectionId)`. Rail-owned so the edit shell never\n * hard-codes the CMS route (the counterpart to {@link detailPath}). `undefined`\n * ⇒ the crumb is unlinked and delete falls back to the project index.\n */\n readonly listPath?: string\n\n // --- View state (list) -----------------------------------------------------\n viewState(): TableViewState\n setViewState(update: TableViewState | ((prev: TableViewState) => TableViewState)): void\n\n // --- Writes ----------------------------------------------------------------\n create(): DocumentRef\n /**\n * EC-595 A2 — HOW this source's records are written: exactly one model per source,\n * so a surface can never write a revisioned document the record way or vice versa.\n * `record` — the explicit-save rails (users, redirects, assets, the account): the\n * editor's Save button hands the whole record over. `document` — the CMS: every\n * writer emits patches at its source, committed on quiescence and merged per path\n * at the store; the editor shows per-field conflicts and follows the subscription.\n */\n readonly writes: CollectionWrites\n remove(ref: DocumentRef): void\n /**\n * Bulk publish/unpublish/delete/set-field (only when `capabilities.bulk`): one\n * command PER item, per-item outcomes enumerated in the report (partial failure\n * is never silent).\n */\n bulk?(ids: readonly string[], action: BulkAction, setField?: BulkSetField): Promise<BulkReport>\n\n // --- Capability method groups (present iff the matching flag is set) --------\n /** `publish` — published-pool predicate + publish/unpublish. */\n readonly publishing?: PublishingCapability\n /**\n * Per-document timestamps (EC-445) — the data behind the `$updatedAt`\n * pseudo-column (and, once its data path lands, `$publishedAt`). Present iff the\n * source materializes them (the CMS source, sourced through session-hydration);\n * a rail that carries no timestamps omits it, so those pseudo-columns simply don't\n * apply (see {@link pseudoColumnsForSource}). The accessor shape mirrors\n * {@link PublishingCapability.isPublished} — a per-ref lookup, referentially stable.\n */\n readonly timestamps?: DocumentTimestampsCapability\n /** `versions` — version history + restore. */\n readonly versioning?: VersioningCapability\n /** `inlineEdit` — the list's single-command optimistic cell write. */\n readonly inlineEditing?: InlineEditCapability\n /**\n * Config-as-code named lenses (EC-246b) the header view selector switches\n * between. Optional: a source that declares no named views (a non-CMS rail\n * like users) omits it, and the selector renders nothing (single default).\n */\n readonly views?: NamedViewsCapability\n /**\n * `importExport` — JSON round-trip of the collection's records. CMS-specific;\n * a rail whose records are credential-bearing (users) omits it, so neither the\n * import dialog nor the export action mounts (identities aren't dumped to JSON).\n */\n readonly imports?: ImportCapability\n}\n\n/** EC-595 A2 — the write model of a source (see {@link CollectionViewSource.writes}). */\nexport type CollectionWrites = RecordWrites | DocumentWrites\n\n/** An explicit-save rail: the editor's Save button writes the whole record. */\nexport interface RecordWrites {\n readonly kind: 'record'\n save(doc: CmsDocument): void\n}\n\n/**\n * The revisioned-document write model (EC-595, ratified 2026-10-24): patches at the\n * source, the persister's queue, per-field conflicts, the document subscription.\n */\nexport interface DocumentWrites {\n readonly kind: 'document'\n /**\n * Commit the patches a writer made; resolves once acknowledged (`undefined` in a\n * fixture session). `bases` — per patch, the revision the edit was started at.\n */\n commit(\n ref: DocumentRef,\n patches: readonly DocumentPatch[],\n bases?: readonly (number | undefined)[],\n ): Promise<CommitOutcome | undefined>\n /** The revision the session's view of a document is at. */\n revisionOf(ref: DocumentRef): number | undefined\n /** Create a document from a whole value (insert-if-absent): duplicate. */\n insert(doc: CmsDocument): void\n /** A fresh document id from the session's injected factory (EC-578). */\n newId(): string\n /** The open per-field conflicts on a document. */\n conflicts(ref: DocumentRef): readonly DocumentConflict[]\n resolveConflict(ref: DocumentRef, conflictId: string, choice: 'theirs' | 'mine'): void\n /** Adopt a row the document subscription pushed (local edits win on their paths until flushed). */\n adoptSnapshot(ref: DocumentRef, record: CmsDocumentRecord | undefined): void\n /** The forced flush's persistence half: await every queued write of the document. */\n flush(ref: DocumentRef): Promise<void>\n /**\n * Write the whole document at the revision the session holds (a document-level key\n * the value-position grammar has no position for — the slot `alias`). A move since\n * is refused, never overwritten.\n */\n replace(doc: CmsDocument): void\n /**\n * EC-595 point 7 — follow ONE document while it is open: every pushed row is adopted\n * under the local edits (the editor rebases), and the presence on it is delivered to\n * `onPresence`. Returns the unsubscribe function.\n */\n subscribe(ref: DocumentRef, onPresence: (presence: readonly PresenceEntry[]) => void): () => void\n /** Thin presence (Stage A): this session is on the document, in `path`'s field (or on no field). */\n reportPresence(ref: DocumentRef, path: ValuePath | undefined): void\n /** This session left the document. */\n clearPresence(ref: DocumentRef): void\n /** This session's presence id (one per tab), so the editor can leave itself out. */\n readonly presenceSessionId: string\n}\n\n/**\n * The capability matrix. Each flag gates a shell region AND the presence of its\n * method group. The **users rail** (EC-240) sets `publish:false`, `versions:false`\n * (credential caution), `create:false` (identity minted by sign-up), and no\n * `liveUrl`/`hierarchy`.\n */\nexport interface CollectionViewCapabilities {\n readonly publish: boolean\n readonly versions: boolean\n readonly locales: boolean\n readonly inlineEdit: boolean\n readonly create: boolean\n /**\n * Duplicate-document action (EC-442, amended same day). Deliberately its own\n * flag, never derived from `create`: the owner call (2026-07-17) is CMS\n * collections ONLY — no primitive rail offers Duplicate for now (identities\n * and uploads aren't copyable content; redirects deferred until requested as\n * a product feature).\n */\n readonly duplicate: boolean\n readonly remove: boolean\n readonly bulk: boolean\n /** The derived live-URL column (published pool × deployment routes). */\n readonly liveUrl: boolean\n /** Parent-self-relation tree mode (hierarchical collections only). */\n readonly hierarchy: boolean\n /** JSON import/export of the collection's records (off for credential rails). */\n readonly importExport: boolean\n /**\n * The rail is administration-scoped (mirrors `ADMIN_ONLY_OPERATIONS`). The\n * nav-permission layer reads this to gate the rail item. Absent ⇒ not admin-only.\n */\n readonly adminOnly?: boolean\n}\n\n/**\n * Principal-based field access (EC-240, AD-18). One tri-state drives BOTH visibility\n * and writability: `edit` (writable), `read` (visible, read-only), `hidden` (not\n * rendered). Default `edit` (default-open). Distinct from content-`hidden(values)`;\n * they compose — a field shows iff *not content-hidden AND access ≠ hidden*, and is\n * editable iff *access = edit AND not otherwise read-only* (published view, `form.readOnly`).\n */\nexport type FieldAccess = 'edit' | 'read' | 'hidden'\n\n/**\n * Resolve a field's effective principal access for a source — its {@link\n * CollectionViewSource.fieldAccess} policy when present, else derived from the\n * boolean `isFieldReadOnly` (default-open). The one place the shell asks \"may this\n * principal edit / see this field?\", so the default-open fallback lives in one spot.\n */\nexport function resolveFieldAccess(\n source: CollectionViewSource,\n field: FieldDef,\n record?: CmsDocument,\n): FieldAccess {\n return source.fieldAccess?.(field, record) ?? (source.isFieldReadOnly(field) ? 'read' : 'edit')\n}\n\n/**\n * Asset display metadata a cell/field renders (thumbnail or labelled badge). EC-587:\n * named apart from core's `ResolvedAsset` (the delivery shape) — this is the studio's\n * label/thumbnail slice; its `alt` is the one reader's (`assetAlt`).\n */\nexport interface AssetDisplay {\n readonly url?: string\n readonly contentType?: string\n readonly title?: string\n readonly filename?: string\n readonly alt?: string\n}\n\n/** `publish` capability. */\nexport interface PublishingCapability {\n /** Published-ness from the version pointer (NOT a row field). */\n isPublished(ref: DocumentRef): boolean\n /**\n * Does this PUBLISHED document's working draft carry unpublished changes\n * (EC-449)? The cheap per-row signal behind the amber \"changed\" `$state` dot —\n * sourced from the MATERIALIZED `hasUnpublishedChanges` record flag (computed\n * once at the write chokepoint), never a per-row snapshot compare. Optional: a\n * source without the signal omits it, and the list derives only\n * published/draft (exactly the pre-EC-449 rendering). Same referentially-stable\n * per-ref accessor shape as {@link isPublished}.\n */\n hasUnpublishedChanges?(ref: DocumentRef): boolean\n publish(ref: DocumentRef): Promise<void>\n unpublish(ref: DocumentRef): Promise<void>\n /**\n * Live URLs for the routable documents, keyed by id — derived from the\n * PUBLISHED pool (never draft rows) so an unpublished slug/parent edit can't\n * leak into a live link (EC-205/EC-216). `null` when the collection is not\n * routable → the live-URL column is hidden. Only present when `capabilities.liveUrl`.\n */\n liveUrls?(): Map<string, DocumentUrl> | null\n}\n\n/**\n * `timestamps` capability (EC-445/EC-447): per-document record timestamps as ISO\n * strings, or `undefined` when a document carries none. The `$updatedAt`/`$publishedAt`\n * pseudo-columns read + sort by these. `updatedAt` is the last-write instant;\n * `publishedAt` (EC-447) is the FIRST-publish instant — set-once on publish, cleared on\n * unpublish, so it is `undefined` for a draft / never-published / currently-unpublished\n * document (the column shows EmDash).\n */\nexport interface DocumentTimestampsCapability {\n updatedAt(ref: DocumentRef): string | undefined\n publishedAt(ref: DocumentRef): string | undefined\n}\n\n/**\n * The reserved pseudo-columns applicable to a source's list (EC-445), derived from\n * its capabilities: `$updatedAt` iff it materializes timestamps, `$state` iff it has a\n * publish lifecycle, `$url` iff it resolves delivery URLs. The one place the list\n * surface + the Display picker agree on which pseudo-columns exist for a source, so\n * the column universe never drifts between where columns render and where they toggle.\n */\nexport function pseudoColumnsForSource(source: CollectionViewSource): string[] {\n return pseudoColumns(source.schema, {\n timestamps: source.timestamps !== undefined,\n publishing: source.publishing !== undefined,\n routable: source.capabilities.liveUrl,\n })\n}\n\n/** `versions` capability. */\nexport interface VersioningCapability {\n restore(ref: DocumentRef, version: number, scope?: RestoreScope): Promise<CmsDocument | null>\n /**\n * The document's recorded version history + live pin. Folds the flush-before-read\n * ordering INTO the loader (the adapter's concern), so every fetch lists an\n * authoritative history regardless of which surface triggered the change (EC-224).\n */\n load(ref: DocumentRef): Promise<DocumentVersionsView>\n}\n\n/** `inlineEdit` capability: the list's single-command optimistic cell write (EC-168). */\nexport interface InlineEditCapability {\n commitField(input: CellCommitInput): Promise<CellCommitOutcome>\n}\n\n/** A named lens the header selector offers — id + display name only (the header never needs its state). */\nexport interface NamedView {\n readonly id: string\n /** Display name; a {@link LocalizedString} (EC-343), resolved at the render site like `form.label`. */\n readonly name: LocalizedString\n}\n\n/** `importExport` capability: validate + fold external JSON records into the collection (EC-079). */\nexport interface ImportCapability {\n importDocuments(items: unknown[]): ImportReport\n}\n\n/**\n * `views` capability: config-as-code named lenses (EC-246b). The header selector\n * only *picks* a lens — it never creates/edits/deletes one (shared views are code).\n */\nexport interface NamedViewsCapability {\n /** The built-in default + config-declared named views. */\n list(): readonly NamedView[]\n /** The currently-selected view id. */\n activeId(): string\n /** Switch views (resets the working table state to the view's baseline). */\n setActive(id: string): void\n}\n\nexport type { CellCommitInput, CellCommitOutcome, ImportReport }\n"]}
1
+ {"version":3,"file":"collection-view-source.js","sourceRoot":"","sources":["../../../src/lib/collection-view/collection-view-source.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAwSvD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA4B,EAC5B,KAAe,EACf,MAAoB;IAEpB,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AACjG,CAAC;AAqDD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAA4B;IACjE,OAAO,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE;QAClC,UAAU,EAAE,MAAM,CAAC,UAAU,KAAK,SAAS;QAC3C,UAAU,EAAE,MAAM,CAAC,UAAU,KAAK,SAAS;QAC3C,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO;KACtC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type {\n CmsDocument,\n CollectionDef,\n DocumentPatch,\n DocumentRef,\n ValuePath,\n DocumentUrl,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n RestoreScope,\n} from '@elytracms/core/cms-core'\nimport type { CmsValidationIssue } from '@elytracms/core/cms-core'\nimport type { OperationError } from '@elytracms/core/operations'\nimport type { CmsDocumentRecord, PresenceEntry, ReferenceTarget } from '@elytracms/core/persistence'\nimport type { CommitOutcome, DocumentConflict } from '../operations/cms-persistence'\nimport type { TableViewState } from '../cms-views/view-model'\nimport { pseudoColumns } from '../cms-views/view-model'\n// The concrete inline-edit + bulk vocabulary (Stream A relocates it into `lib` as it settles).\nimport type { CellCommitInput, CellCommitOutcome } from '../../components/cms/cell-edit'\nimport type { BulkAction, BulkReport, BulkSetField } from '../../components/cms/bulk-actions'\nimport type { DocumentVersionsView, ImportReport } from '../../components/cms/cms-store'\n\n/**\n * `CollectionViewSource` — the studio's UNIVERSAL interaction seam (EC-240,\n * vision AD-19).\n *\n * The list surface (`CollectionTable`) and the edit-shell (`DetailEditor`) are\n * the studio's universal interaction surfaces. Historically they read the\n * concrete `CmsStore` through `useCms()`, so they only served `cmsDocuments`.\n * This interface is the data-agnostic seam they render over instead, so the SAME\n * surfaces drive the users rail (EC-240), redirects (EC-303), the Components app\n * edit-shell, and any future rail — no hand-rolled UI per rail.\n *\n * **Shape:** the source is scoped to ONE collection (it carries `schema` +\n * `collectionId`), and its methods mirror the subset of `CmsStore` the surfaces\n * actually use — dropping the `collectionId` argument (the source already knows\n * it). Keeping the names/signatures aligned makes the CMS adapter a\n * behaviour-preserving pass-through and the migration near-mechanical.\n *\n * **Referential stability:** the surfaces put `documents`, `isPublished`,\n * `localeConfig`, etc. in `useMemo` dependency arrays. An implementation MUST\n * return stable references across renders (delegate to the underlying store's\n * already-stable methods; never wrap in a fresh closure each render) or memos\n * bust and the inline-edit order snapshot / perf regress.\n *\n * **Capabilities:** flags gate whole shell regions AND method presence — a source\n * with `capabilities.versions === false` (the users rail) never mounts the\n * Versions pane, so no `listVersions` read fires on credential records. Optional\n * method groups are present iff the flag is set.\n */\nexport interface CollectionViewSource {\n /** The rail/collection this source serves. */\n readonly collectionId: string\n /** The schema lens: fields, form tabs/groups, `titleField`, display nouns. */\n readonly schema: CollectionDef\n /** Which regions/methods this source supports. */\n readonly capabilities: CollectionViewCapabilities\n\n /** The project scope (asset picker, published-pool queries). Absent in fixture sessions. */\n readonly projectId?: string\n /**\n * The collection id assets live in (for a cell/field's `titleOf` label fallback\n * when {@link resolveAsset} finds no record). Present only for sources that\n * reference assets — a rail without assets (users) omits it.\n */\n readonly assetCollectionId?: string\n /** The ambient locale lens (only meaningful when `capabilities.locales`). */\n readonly localeConfig: LocaleConfig\n readonly activeLocale: Locale\n\n // --- Reads -----------------------------------------------------------------\n /** The full row set (view mechanics filter/sort this client-side). */\n documents(): CmsDocument[]\n get(ref: DocumentRef): CmsDocument | undefined\n /** A relation/asset target's display title (hides the string-vs-function `titleField`). */\n titleOf(ref: DocumentRef): string\n /**\n * List the candidate records of a relation field's declared `target` collection\n * — the pick-list for a relation picker (EC-072). References are first-class and\n * collection-based: the field's schema declares which collection(s) it targets,\n * and this resolves those rows for ANY target (cross-collection), not just this\n * source's own collection. The caller passes `field.target`; a multi-target field\n * (future) merges one call per declared target. An unknown/empty target yields `[]`.\n */\n referenceCandidates(collectionId: string): CmsDocument[]\n /**\n * The workspace schema a reference/asset can point at — the schema counterpart to\n * {@link referenceCandidates}. Needed for the cases that read a TARGET collection's\n * fields (an asset field editing the asset collection's own metadata; the reuse\n * capability correlating embed manifests against their target collection). A\n * reference is collection-based, so resolving one sometimes needs the target's\n * schema, not just its rows.\n */\n readonly collections: readonly CollectionDef[]\n isFieldReadOnly(field: FieldDef): boolean\n /**\n * Principal-based field access (EC-240, vision AD-18): `edit` (writable), `read`\n * (visible but read-only), or `hidden` (not rendered for this principal). This is\n * IDENTITY-driven and distinct from a field's content-conditional `hidden(values)`\n * — e.g. an editor's own `role` resolves to `read`, a viewer never SEES a\n * sensitive field (`hidden`). A single tri-state (never two independent flags) so\n * the nonsensical writable-but-invisible state can't be expressed. Optional:\n * absent ⇒ derived from {@link isFieldReadOnly} (`read`|`edit`), i.e. default-open\n * (permissions RESTRICT, never grant a baseline). Per-rail policy lives on the\n * source; the starter's policy flows into its construction (engine = mechanism).\n * Prefer {@link resolveFieldAccess} over calling this directly (it applies the\n * default-open fallback).\n */\n fieldAccess?(field: FieldDef, record?: CmsDocument): FieldAccess\n validate(doc: CmsDocument): CmsValidationIssue[]\n /**\n * Resolve an asset id to its display metadata for a cell/field, or `undefined`\n * when there is no asset backend (a source without assets degrades to a label\n * via {@link titleOf}, matching today's \"no AssetsProvider\" behaviour).\n */\n resolveAsset?(id: string): AssetDisplay | undefined\n /**\n * How this rail's records are addressed in the EC-155 reference index — the\n * target shape the delete/unpublish confirmation's inbound pre-flight queries\n * (EC-433). Absent ⇒ the document shape (`{ type: 'document', id: 'collection:id' }`),\n * which every `cmsDocuments` collection uses. The assets rail supplies\n * `{ type: 'asset' }` so its list/bulk delete confirmation enumerates the SAME\n * inbound references its detail surface does — a document-shaped lookup would\n * report a referenced asset as \"not referenced\" (the EC-319 objection that\n * originally kept `remove` off the assets rail).\n */\n referenceTarget?(ref: DocumentRef): ReferenceTarget\n /** The last failed/denied mutation, surfaced by the shell (never a silent failure). */\n readonly lastError: OperationError | null\n clearLastError(): void\n /**\n * Land any queued/optimistic writes so a subsequent pre-flight READ sees them\n * (the reference index is maintained on write). A source with no async\n * persistence omits it — its reads are already authoritative.\n */\n flush?(): Promise<void>\n\n /**\n * The studio route splat for a record's detail surface (the row link + the\n * post-create navigation target), e.g. `studioPath.cmsDocument(collectionId, id)`.\n * Rail-owned so the list never hard-codes the CMS route. `undefined` ⇒ the rail\n * has no detail surface, so rows render as plain text (no navigation).\n */\n detailPath?(id: string): string\n /**\n * The studio route splat for this rail's LIST surface — the edit shell's\n * \"back to list\" breadcrumb crumb and its post-delete navigation target, e.g.\n * `studioPath.cmsCollection(collectionId)`. Rail-owned so the edit shell never\n * hard-codes the CMS route (the counterpart to {@link detailPath}). `undefined`\n * ⇒ the crumb is unlinked and delete falls back to the project index.\n */\n readonly listPath?: string\n\n // --- View state (list) -----------------------------------------------------\n viewState(): TableViewState\n setViewState(update: TableViewState | ((prev: TableViewState) => TableViewState)): void\n\n // --- Writes ----------------------------------------------------------------\n create(): DocumentRef\n /**\n * EC-595 A2 — HOW this source's records are written: exactly one model per source,\n * so a surface can never write a revisioned document the record way or vice versa.\n * `record` — the explicit-save rails (users, redirects, assets, the account): the\n * editor's Save button hands the whole record over. `document` — the CMS: every\n * writer emits patches at its source, committed on quiescence and merged per path\n * at the store; the editor shows per-field conflicts and follows the subscription.\n */\n readonly writes: CollectionWrites\n remove(ref: DocumentRef): void\n /**\n * Bulk publish/unpublish/delete/set-field (only when `capabilities.bulk`): one\n * command PER item, per-item outcomes enumerated in the report (partial failure\n * is never silent).\n */\n bulk?(ids: readonly string[], action: BulkAction, setField?: BulkSetField): Promise<BulkReport>\n\n // --- Capability method groups (present iff the matching flag is set) --------\n /** `publish` — published-pool predicate + publish/unpublish. */\n readonly publishing?: PublishingCapability\n /**\n * Per-document timestamps (EC-445) — the data behind the `$updatedAt`\n * pseudo-column (and, once its data path lands, `$publishedAt`). Present iff the\n * source materializes them (the CMS source, sourced through session-hydration);\n * a rail that carries no timestamps omits it, so those pseudo-columns simply don't\n * apply (see {@link pseudoColumnsForSource}). The accessor shape mirrors\n * {@link PublishingCapability.isPublished} — a per-ref lookup, referentially stable.\n */\n readonly timestamps?: DocumentTimestampsCapability\n /** `versions` — version history + restore. */\n readonly versioning?: VersioningCapability\n /** `inlineEdit` — the list's single-command optimistic cell write. */\n readonly inlineEditing?: InlineEditCapability\n /**\n * Config-as-code named lenses (EC-246b) the header view selector switches\n * between. Optional: a source that declares no named views (a non-CMS rail\n * like users) omits it, and the selector renders nothing (single default).\n */\n readonly views?: NamedViewsCapability\n /**\n * `importExport` — JSON round-trip of the collection's records. CMS-specific;\n * a rail whose records are credential-bearing (users) omits it, so neither the\n * import dialog nor the export action mounts (identities aren't dumped to JSON).\n */\n readonly imports?: ImportCapability\n}\n\n/** EC-595 A2 — the write model of a source (see {@link CollectionViewSource.writes}). */\nexport type CollectionWrites = RecordWrites | DocumentWrites\n\n/**\n * An explicit-save rail: the editor's Save button writes the record. `base` (EC-616) is the\n * record as the editor OPENED it (or as of their last successful save) — a rail that can\n * write per column sends only what differs from it, so a column another writer changed\n * meanwhile is kept; absent for a record being created.\n */\nexport interface RecordWrites {\n readonly kind: 'record'\n save(doc: CmsDocument, base?: CmsDocument): void\n}\n\n/**\n * The revisioned-document write model (EC-595, ratified 2026-10-24): patches at the\n * source, the persister's queue, per-field conflicts, the document subscription.\n */\nexport interface DocumentWrites {\n readonly kind: 'document'\n /**\n * Commit the patches a writer made; resolves once acknowledged (`undefined` in a\n * fixture session). `bases` — per patch, the revision the edit was started at.\n */\n commit(\n ref: DocumentRef,\n patches: readonly DocumentPatch[],\n bases?: readonly (number | undefined)[],\n ): Promise<CommitOutcome | undefined>\n /** The revision the session's view of a document is at. */\n revisionOf(ref: DocumentRef): number | undefined\n /** Create a document from a whole value (insert-if-absent): duplicate. */\n insert(doc: CmsDocument): void\n /** A fresh document id from the session's injected factory (EC-578). */\n newId(): string\n /** The open per-field conflicts on a document. */\n conflicts(ref: DocumentRef): readonly DocumentConflict[]\n resolveConflict(ref: DocumentRef, conflictId: string, choice: 'theirs' | 'mine'): void\n /** Adopt a row the document subscription pushed (local edits win on their paths until flushed). */\n adoptSnapshot(ref: DocumentRef, record: CmsDocumentRecord | undefined): void\n /** The forced flush's persistence half: await every queued write of the document. */\n flush(ref: DocumentRef): Promise<void>\n /**\n * Write the whole document at the revision the session holds (a document-level key\n * the value-position grammar has no position for — the slot `alias`). A move since\n * is refused, never overwritten.\n */\n replace(doc: CmsDocument): void\n /**\n * EC-595 point 7 — follow ONE document while it is open: every pushed row is adopted\n * under the local edits (the editor rebases), and the presence on it is delivered to\n * `onPresence`. Returns the unsubscribe function.\n */\n subscribe(ref: DocumentRef, onPresence: (presence: readonly PresenceEntry[]) => void): () => void\n /** Thin presence (Stage A): this session is on the document, in `path`'s field (or on no field). */\n reportPresence(ref: DocumentRef, path: ValuePath | undefined): void\n /** This session left the document. */\n clearPresence(ref: DocumentRef): void\n /** This session's presence id (one per tab), so the editor can leave itself out. */\n readonly presenceSessionId: string\n}\n\n/**\n * The capability matrix. Each flag gates a shell region AND the presence of its\n * method group. The **users rail** (EC-240) sets `publish:false`, `versions:false`\n * (credential caution), `create:false` (identity minted by sign-up), and no\n * `liveUrl`/`hierarchy`.\n */\nexport interface CollectionViewCapabilities {\n readonly publish: boolean\n readonly versions: boolean\n readonly locales: boolean\n readonly inlineEdit: boolean\n readonly create: boolean\n /**\n * Duplicate-document action (EC-442, amended same day). Deliberately its own\n * flag, never derived from `create`: the owner call (2026-07-17) is CMS\n * collections ONLY — no primitive rail offers Duplicate for now (identities\n * and uploads aren't copyable content; redirects deferred until requested as\n * a product feature).\n */\n readonly duplicate: boolean\n readonly remove: boolean\n readonly bulk: boolean\n /** The derived live-URL column (published pool × deployment routes). */\n readonly liveUrl: boolean\n /** Parent-self-relation tree mode (hierarchical collections only). */\n readonly hierarchy: boolean\n /** JSON import/export of the collection's records (off for credential rails). */\n readonly importExport: boolean\n /**\n * The rail is administration-scoped (mirrors `ADMIN_ONLY_OPERATIONS`). The\n * nav-permission layer reads this to gate the rail item. Absent ⇒ not admin-only.\n */\n readonly adminOnly?: boolean\n}\n\n/**\n * Principal-based field access (EC-240, AD-18). One tri-state drives BOTH visibility\n * and writability: `edit` (writable), `read` (visible, read-only), `hidden` (not\n * rendered). Default `edit` (default-open). Distinct from content-`hidden(values)`;\n * they compose — a field shows iff *not content-hidden AND access ≠ hidden*, and is\n * editable iff *access = edit AND not otherwise read-only* (published view, `form.readOnly`).\n */\nexport type FieldAccess = 'edit' | 'read' | 'hidden'\n\n/**\n * Resolve a field's effective principal access for a source — its {@link\n * CollectionViewSource.fieldAccess} policy when present, else derived from the\n * boolean `isFieldReadOnly` (default-open). The one place the shell asks \"may this\n * principal edit / see this field?\", so the default-open fallback lives in one spot.\n */\nexport function resolveFieldAccess(\n source: CollectionViewSource,\n field: FieldDef,\n record?: CmsDocument,\n): FieldAccess {\n return source.fieldAccess?.(field, record) ?? (source.isFieldReadOnly(field) ? 'read' : 'edit')\n}\n\n/**\n * Asset display metadata a cell/field renders (thumbnail or labelled badge). EC-587:\n * named apart from core's `ResolvedAsset` (the delivery shape) — this is the studio's\n * label/thumbnail slice; its `alt` is the one reader's (`assetAlt`).\n */\nexport interface AssetDisplay {\n readonly url?: string\n readonly contentType?: string\n readonly title?: string\n readonly filename?: string\n readonly alt?: string\n}\n\n/** `publish` capability. */\nexport interface PublishingCapability {\n /** Published-ness from the version pointer (NOT a row field). */\n isPublished(ref: DocumentRef): boolean\n /**\n * Does this PUBLISHED document's working draft carry unpublished changes\n * (EC-449)? The cheap per-row signal behind the amber \"changed\" `$state` dot —\n * sourced from the MATERIALIZED `hasUnpublishedChanges` record flag (computed\n * once at the write chokepoint), never a per-row snapshot compare. Optional: a\n * source without the signal omits it, and the list derives only\n * published/draft (exactly the pre-EC-449 rendering). Same referentially-stable\n * per-ref accessor shape as {@link isPublished}.\n */\n hasUnpublishedChanges?(ref: DocumentRef): boolean\n publish(ref: DocumentRef): Promise<void>\n unpublish(ref: DocumentRef): Promise<void>\n /**\n * Live URLs for the routable documents, keyed by id — derived from the\n * PUBLISHED pool (never draft rows) so an unpublished slug/parent edit can't\n * leak into a live link (EC-205/EC-216). `null` when the collection is not\n * routable → the live-URL column is hidden. Only present when `capabilities.liveUrl`.\n */\n liveUrls?(): Map<string, DocumentUrl> | null\n}\n\n/**\n * `timestamps` capability (EC-445/EC-447): per-document record timestamps as ISO\n * strings, or `undefined` when a document carries none. The `$updatedAt`/`$publishedAt`\n * pseudo-columns read + sort by these. `updatedAt` is the last-write instant;\n * `publishedAt` (EC-447) is the FIRST-publish instant — set-once on publish, cleared on\n * unpublish, so it is `undefined` for a draft / never-published / currently-unpublished\n * document (the column shows EmDash).\n */\nexport interface DocumentTimestampsCapability {\n updatedAt(ref: DocumentRef): string | undefined\n publishedAt(ref: DocumentRef): string | undefined\n}\n\n/**\n * The reserved pseudo-columns applicable to a source's list (EC-445), derived from\n * its capabilities: `$updatedAt` iff it materializes timestamps, `$state` iff it has a\n * publish lifecycle, `$url` iff it resolves delivery URLs. The one place the list\n * surface + the Display picker agree on which pseudo-columns exist for a source, so\n * the column universe never drifts between where columns render and where they toggle.\n */\nexport function pseudoColumnsForSource(source: CollectionViewSource): string[] {\n return pseudoColumns(source.schema, {\n timestamps: source.timestamps !== undefined,\n publishing: source.publishing !== undefined,\n routable: source.capabilities.liveUrl,\n })\n}\n\n/** `versions` capability. */\nexport interface VersioningCapability {\n restore(ref: DocumentRef, version: number, scope?: RestoreScope): Promise<CmsDocument | null>\n /**\n * The document's recorded version history + live pin. Folds the flush-before-read\n * ordering INTO the loader (the adapter's concern), so every fetch lists an\n * authoritative history regardless of which surface triggered the change (EC-224).\n */\n load(ref: DocumentRef): Promise<DocumentVersionsView>\n}\n\n/** `inlineEdit` capability: the list's single-command optimistic cell write (EC-168). */\nexport interface InlineEditCapability {\n commitField(input: CellCommitInput): Promise<CellCommitOutcome>\n}\n\n/** A named lens the header selector offers — id + display name only (the header never needs its state). */\nexport interface NamedView {\n readonly id: string\n /** Display name; a {@link LocalizedString} (EC-343), resolved at the render site like `form.label`. */\n readonly name: LocalizedString\n}\n\n/** `importExport` capability: validate + fold external JSON records into the collection (EC-079). */\nexport interface ImportCapability {\n importDocuments(items: unknown[]): ImportReport\n}\n\n/**\n * `views` capability: config-as-code named lenses (EC-246b). The header selector\n * only *picks* a lens — it never creates/edits/deletes one (shared views are code).\n */\nexport interface NamedViewsCapability {\n /** The built-in default + config-declared named views. */\n list(): readonly NamedView[]\n /** The currently-selected view id. */\n activeId(): string\n /** Switch views (resets the working table state to the view's baseline). */\n setActive(id: string): void\n}\n\nexport type { CellCommitInput, CellCommitOutcome, ImportReport }\n"]}
@@ -1,4 +1,4 @@
1
- import type { OperationEvent } from '@elytracms/studio/lib/operations';
1
+ import type { OperationEvent } from '../operations/index.js';
2
2
  /**
3
3
  * Content-session write-sync (EC-460) — the root-cause fix for the playground
4
4
  * population family.
@@ -1 +1 @@
1
- {"version":3,"file":"content-session-refresh.js","sourceRoot":"","sources":["../../../src/lib/data/content-session-refresh.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACxE,WAAW;IACX,QAAQ;IACR,QAAQ;CACT,CAAC,CAAA;AAEF,0EAA0E;AAC1E,MAAM,UAAU,qBAAqB,CAAC,KAAqB;IACzD,OAAO,CACL,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,KAAK,CAAC,MAAM,KAAK,WAAW;QAC5B,6BAA6B,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAChD,CAAA;AACH,CAAC;AAqBD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAA4B;IACnE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAc,EAAE,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACtF,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,MAAe,EAAE,EAAE,CAAC,YAAY,CAAC,MAAgB,CAAC,CAAC,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;YACpB,OAAO,GAAG,EAAE;gBACV,IAAI,QAAQ;oBAAE,OAAM;gBACpB,QAAQ,GAAG,IAAI,CAAA;gBACf,SAAS,IAAI,CAAC,CAAA;YAChB,CAAC,CAAA;QACH,CAAC;QACD,OAAO;YACL,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAMD,IAAI,gBAAgB,GAAqB,IAAI,CAAA;AAE7C,MAAM,IAAI,GAAG,wBAAwB,CAAC;IACpC,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;CACzD,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,SAAoB;IAClE,gBAAgB,GAAG,SAAS,CAAA;IAC5B,OAAO,GAAG,EAAE;QACV,IAAI,gBAAgB,KAAK,SAAS;YAAE,gBAAgB,GAAG,IAAI,CAAA;IAC7D,CAAC,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,SAAS,EAAE,CAAA;AAClB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import type { OperationEvent } from '@elytracms/studio/lib/operations'\n\n/**\n * Content-session write-sync (EC-460) — the root-cause fix for the playground\n * population family.\n *\n * The canvas preview engine (`collection-content.ts`) resolves listings,\n * relation picks, and rich-text links against a module-global content session\n * that used to refresh ONLY at project boot and per CMS-surface mount\n * (`project-session.tsx`). A document authored or published after the last of\n * those hydrations was invisible to every canvas resolver while the picker UIs\n * (which read the live CMS store) showed it — the listing rendered its empty\n * state against real published same-session content, and a `multiple` relation\n * resolved 1-of-3 / 0-of-3 picked chips, all silently.\n *\n * This module closes the loop at the ONE write chokepoint the studio already\n * has: the operations lifecycle event bus (\"validate → authorize → mutate →\n * emit\"; its documented consumers include cache invalidation, vision AD-7 —\n * the reference index and revalidation webhooks attach the same way). Every\n * SUCCEEDED command in a content-bearing domain marks the session stale; a\n * registered refresher (the project session's own `loadCms`, so both modes run\n * the identical `loadHydratedCms` → `configureContentSession` path — no new\n * loader, no transport bypass, no second cache) re-hydrates it, debounced so a\n * persister burst coalesces into one load.\n *\n * Refreshes only run while a CONSUMER (a mounted canvas) is registered — a\n * session with no preview surface just keeps the stale flag and re-hydrates\n * when the next consumer arrives, so connected mode never pays a per-autosave\n * query while nobody is previewing. The pure orchestrator\n * ({@link createContentSessionSync}) takes its timer + refresh injected, so the\n * coalescing/latch behaviour is unit-tested in node (house pattern); the\n * module-level singleton below is the app wiring.\n */\n\n/** Domains whose succeeded commands change what the preview engine serves. */\nexport const CONTENT_SESSION_WRITE_DOMAINS: ReadonlySet<string> = new Set([\n 'documents',\n 'schema',\n 'assets',\n])\n\n/** Whether an operation event invalidates the preview content session. */\nexport function isContentSessionWrite(event: OperationEvent): boolean {\n return (\n event.kind === 'command' &&\n event.status === 'succeeded' &&\n CONTENT_SESSION_WRITE_DOMAINS.has(event.domain)\n )\n}\n\nexport interface ContentSessionSyncDeps {\n /** Re-hydrate the session (the project session's `loadCms`). Never throws upward. */\n refresh: () => Promise<unknown>\n /** Trailing debounce for write bursts (ms). */\n delayMs?: number\n /** Injectable timer pair (tests drive time manually). */\n setTimer?: (fn: () => void, ms: number) => unknown\n clearTimer?: (handle: unknown) => void\n}\n\nexport interface ContentSessionSync {\n /** A content-bearing write succeeded — refresh (debounced) if anyone previews. */\n markStale(): void\n /** A preview surface mounted; returns its release. A stale session refreshes now. */\n addConsumer(): () => void\n /** Whether a refresh is currently owed (test/introspection seam). */\n isStale(): boolean\n}\n\n/**\n * The pure orchestrator: stale flag + consumer count + one coalesced refresh.\n *\n * - `markStale` with no consumers only flags; the next `addConsumer` refreshes.\n * - `markStale` with consumers schedules a trailing debounce (bursts coalesce).\n * - A `markStale` DURING an in-flight refresh re-runs once after it settles —\n * the refresh that was already reading may have missed that write.\n */\nexport function createContentSessionSync(deps: ContentSessionSyncDeps): ContentSessionSync {\n const delayMs = deps.delayMs ?? 150\n const setTimer = deps.setTimer ?? ((fn: () => void, ms: number) => setTimeout(fn, ms))\n const clearTimer = deps.clearTimer ?? ((handle: unknown) => clearTimeout(handle as number))\n\n let stale = false\n let consumers = 0\n let timer: unknown = null\n let running = false\n let rerun = false\n\n function run(): void {\n if (running) {\n rerun = true\n return\n }\n running = true\n stale = false\n void deps\n .refresh()\n .catch(() => {\n // A failed hydration keeps the session stale so the next trigger retries;\n // the loader itself already reports the failure loudly (loadCmsIntoSession).\n stale = true\n })\n .finally(() => {\n running = false\n if (rerun || (stale && consumers > 0)) {\n rerun = false\n schedule()\n }\n })\n }\n\n function schedule(): void {\n if (timer !== null) clearTimer(timer)\n timer = setTimer(() => {\n timer = null\n run()\n }, delayMs)\n }\n\n return {\n markStale() {\n stale = true\n if (consumers > 0) schedule()\n },\n addConsumer() {\n consumers += 1\n if (stale && timer === null && !running) schedule()\n let released = false\n return () => {\n if (released) return\n released = true\n consumers -= 1\n }\n },\n isStale() {\n return stale\n },\n }\n}\n\n// --- App wiring (module singleton) -------------------------------------------------\n\ntype Refresher = () => Promise<unknown>\n\nlet currentRefresher: Refresher | null = null\n\nconst sync = createContentSessionSync({\n refresh: () => currentRefresher?.() ?? Promise.resolve(),\n})\n\n/**\n * Register the active project's session refresher (`ProjectSessionProvider`\n * mounts it with its `loadCms`; leaving the project unregisters). Only one is\n * active at a time — the studio shows one project per session.\n */\nexport function registerContentSessionRefresher(refresher: Refresher): () => void {\n currentRefresher = refresher\n return () => {\n if (currentRefresher === refresher) currentRefresher = null\n }\n}\n\n/** Mark the shared session stale (the event-bus listener calls this). */\nexport function markContentSessionStale(): void {\n sync.markStale()\n}\n\n/** Register a mounted preview consumer (the canvas); returns the release. */\nexport function acquireContentSessionConsumer(): () => void {\n return sync.addConsumer()\n}\n"]}
1
+ {"version":3,"file":"content-session-refresh.js","sourceRoot":"","sources":["../../../src/l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,UAAU,+BAA+B,CAAC,SAAoB;IAClE,gBAAgB,GAAG,SAAS,CAAA;IAC5B,OAAO,GAAG,EAAE;QACV,IAAI,gBAAgB,KAAK,SAAS;YAAE,gBAAgB,GAAG,IAAI,CAAA;IAC7D,CAAC,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,SAAS,EAAE,CAAA;AAClB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import type { OperationEvent } from '../operations'\n\n/**\n * Content-session write-sync (EC-460) — the root-cause fix for the playground\n * population family.\n *\n * The canvas preview engine (`collection-content.ts`) resolves listings,\n * relation picks, and rich-text links against a module-global content session\n * that used to refresh ONLY at project boot and per CMS-surface mount\n * (`project-session.tsx`). A document authored or published after the last of\n * those hydrations was invisible to every canvas resolver while the picker UIs\n * (which read the live CMS store) showed it — the listing rendered its empty\n * state against real published same-session content, and a `multiple` relation\n * resolved 1-of-3 / 0-of-3 picked chips, all silently.\n *\n * This module closes the loop at the ONE write chokepoint the studio already\n * has: the operations lifecycle event bus (\"validate → authorize → mutate →\n * emit\"; its documented consumers include cache invalidation, vision AD-7 —\n * the reference index and revalidation webhooks attach the same way). Every\n * SUCCEEDED command in a content-bearing domain marks the session stale; a\n * registered refresher (the project session's own `loadCms`, so both modes run\n * the identical `loadHydratedCms` → `configureContentSession` path — no new\n * loader, no transport bypass, no second cache) re-hydrates it, debounced so a\n * persister burst coalesces into one load.\n *\n * Refreshes only run while a CONSUMER (a mounted canvas) is registered — a\n * session with no preview surface just keeps the stale flag and re-hydrates\n * when the next consumer arrives, so connected mode never pays a per-autosave\n * query while nobody is previewing. The pure orchestrator\n * ({@link createContentSessionSync}) takes its timer + refresh injected, so the\n * coalescing/latch behaviour is unit-tested in node (house pattern); the\n * module-level singleton below is the app wiring.\n */\n\n/** Domains whose succeeded commands change what the preview engine serves. */\nexport const CONTENT_SESSION_WRITE_DOMAINS: ReadonlySet<string> = new Set([\n 'documents',\n 'schema',\n 'assets',\n])\n\n/** Whether an operation event invalidates the preview content session. */\nexport function isContentSessionWrite(event: OperationEvent): boolean {\n return (\n event.kind === 'command' &&\n event.status === 'succeeded' &&\n CONTENT_SESSION_WRITE_DOMAINS.has(event.domain)\n )\n}\n\nexport interface ContentSessionSyncDeps {\n /** Re-hydrate the session (the project session's `loadCms`). Never throws upward. */\n refresh: () => Promise<unknown>\n /** Trailing debounce for write bursts (ms). */\n delayMs?: number\n /** Injectable timer pair (tests drive time manually). */\n setTimer?: (fn: () => void, ms: number) => unknown\n clearTimer?: (handle: unknown) => void\n}\n\nexport interface ContentSessionSync {\n /** A content-bearing write succeeded — refresh (debounced) if anyone previews. */\n markStale(): void\n /** A preview surface mounted; returns its release. A stale session refreshes now. */\n addConsumer(): () => void\n /** Whether a refresh is currently owed (test/introspection seam). */\n isStale(): boolean\n}\n\n/**\n * The pure orchestrator: stale flag + consumer count + one coalesced refresh.\n *\n * - `markStale` with no consumers only flags; the next `addConsumer` refreshes.\n * - `markStale` with consumers schedules a trailing debounce (bursts coalesce).\n * - A `markStale` DURING an in-flight refresh re-runs once after it settles —\n * the refresh that was already reading may have missed that write.\n */\nexport function createContentSessionSync(deps: ContentSessionSyncDeps): ContentSessionSync {\n const delayMs = deps.delayMs ?? 150\n const setTimer = deps.setTimer ?? ((fn: () => void, ms: number) => setTimeout(fn, ms))\n const clearTimer = deps.clearTimer ?? ((handle: unknown) => clearTimeout(handle as number))\n\n let stale = false\n let consumers = 0\n let timer: unknown = null\n let running = false\n let rerun = false\n\n function run(): void {\n if (running) {\n rerun = true\n return\n }\n running = true\n stale = false\n void deps\n .refresh()\n .catch(() => {\n // A failed hydration keeps the session stale so the next trigger retries;\n // the loader itself already reports the failure loudly (loadCmsIntoSession).\n stale = true\n })\n .finally(() => {\n running = false\n if (rerun || (stale && consumers > 0)) {\n rerun = false\n schedule()\n }\n })\n }\n\n function schedule(): void {\n if (timer !== null) clearTimer(timer)\n timer = setTimer(() => {\n timer = null\n run()\n }, delayMs)\n }\n\n return {\n markStale() {\n stale = true\n if (consumers > 0) schedule()\n },\n addConsumer() {\n consumers += 1\n if (stale && timer === null && !running) schedule()\n let released = false\n return () => {\n if (released) return\n released = true\n consumers -= 1\n }\n },\n isStale() {\n return stale\n },\n }\n}\n\n// --- App wiring (module singleton) -------------------------------------------------\n\ntype Refresher = () => Promise<unknown>\n\nlet currentRefresher: Refresher | null = null\n\nconst sync = createContentSessionSync({\n refresh: () => currentRefresher?.() ?? Promise.resolve(),\n})\n\n/**\n * Register the active project's session refresher (`ProjectSessionProvider`\n * mounts it with its `loadCms`; leaving the project unregisters). Only one is\n * active at a time — the studio shows one project per session.\n */\nexport function registerContentSessionRefresher(refresher: Refresher): () => void {\n currentRefresher = refresher\n return () => {\n if (currentRefresher === refresher) currentRefresher = null\n }\n}\n\n/** Mark the shared session stale (the event-bus listener calls this). */\nexport function markContentSessionStale(): void {\n sync.markStale()\n}\n\n/** Register a mounted preview consumer (the canvas); returns the release. */\nexport function acquireContentSessionConsumer(): () => void {\n return sync.addConsumer()\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { OperationEvent } from '@elytracms/studio/lib/operations';
1
+ import type { OperationEvent } from '../operations/index.js';
2
2
  /** Should this operation event arm the playground unload guard? */
3
3
  export declare function shouldArmUnloadGuard(event: OperationEvent, playground?: boolean): boolean;
4
4
  export interface UnloadGuardState {
@@ -24,7 +24,7 @@
24
24
  * un-interacted-with tab reloads silently regardless, which is fine: any
25
25
  * authored write implies interaction.
26
26
  */
27
- import { isPlaygroundMode } from '@elytracms/studio/lib/persistence';
27
+ import { isPlaygroundMode } from '../persistence/index.js';
28
28
  import { isContentSessionWrite } from './content-session-refresh.js';
29
29
  /** Should this operation event arm the playground unload guard? */
30
30
  export function shouldArmUnloadGuard(event, playground = isPlaygroundMode()) {
@@ -1 +1 @@
1
- {"version":3,"file":"playground-unload-guard.js","sourceRoot":"","sources":["../../../src/lib/data/playground-unload-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAEjE,mEAAmE;AACnE,MAAM,UAAU,oBAAoB,CAClC,KAAqB,EACrB,aAAsB,gBAAgB,EAAE;IAExC,OAAO,UAAU,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAA;AACnD,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAA+D;IAE/D,IAAI,KAAK,GAAG,KAAK,CAAA;IACjB,OAAO;QACL,GAAG;YACD,IAAI,KAAK;gBAAE,OAAM;YACjB,KAAK,GAAG,IAAI,CAAA;YACZ,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;gBACjB,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,qEAAqE;gBACrE,KAAK,CAAC,WAAW,GAAG,EAAE,CAAA;YACxB,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO;YACL,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAED,sFAAsF;AAEtF,MAAM,KAAK,GAAG,sBAAsB,CAAC,CAAC,OAAO,EAAE,EAAE;IAC/C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACrF,CAAC,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAAqB;IACrE,IAAI,oBAAoB,CAAC,KAAK,CAAC;QAAE,KAAK,CAAC,GAAG,EAAE,CAAA;AAC9C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B;IAC1C,OAAO,KAAK,CAAC,OAAO,EAAE,CAAA;AACxB,CAAC","sourcesContent":["/**\n * EC-461 — the playground `beforeunload` guard.\n *\n * The playground's world is one in-memory adapter: a full page unload — a\n * reload, a Vite full-reload after a source edit (HMR), a hard top-level\n * navigation, a closed tab — destroys every authored document, schema change,\n * asset and publish irrecoverably. That is documented semantics, but losing it\n * SILENTLY is not acceptable once the session actually holds authored state.\n *\n * The rule (stated once, applied everywhere): the guard arms in PLAYGROUND\n * mode only, the first time a content-bearing write command succeeds on the\n * operations event bus (the same `isContentSessionWrite` predicate the EC-460\n * content-session sync uses — documents/schema/assets), and never disarms for\n * the rest of the page's life: any such write means the world has diverged\n * from its deterministic seed, and nothing short of the unload itself brings\n * it back. Connected mode never arms — writes persist to the backend within\n * the autosave rhythm, in-app navigation flushes pending autosaves on unmount,\n * and explicit-save rails carry their own `UnsavedChangesGuard`; a blanket\n * unload prompt there would cry wolf on every visit.\n *\n * The decision core ({@link createUnloadGuardState}) is pure (house pattern);\n * the module singleton below injects the real `window` listener registration.\n * Browsers require sticky user activation to actually show the dialog — an\n * un-interacted-with tab reloads silently regardless, which is fine: any\n * authored write implies interaction.\n */\nimport { isPlaygroundMode } from '@elytracms/studio/lib/persistence'\nimport type { OperationEvent } from '@elytracms/studio/lib/operations'\nimport { isContentSessionWrite } from './content-session-refresh'\n\n/** Should this operation event arm the playground unload guard? */\nexport function shouldArmUnloadGuard(\n event: OperationEvent,\n playground: boolean = isPlaygroundMode(),\n): boolean {\n return playground && isContentSessionWrite(event)\n}\n\nexport interface UnloadGuardState {\n /** A qualifying write happened — register the listener once. */\n arm(): void\n /** Is the guard live (listener registered)? */\n isArmed(): boolean\n}\n\n/**\n * The arm-once state machine. `register` is the injected DOM seam — it is\n * called exactly once, on the first arm, with the handler that flags the\n * unload prompt (`event.preventDefault()` + legacy `returnValue`).\n */\nexport function createUnloadGuardState(\n register: (handler: (event: BeforeUnloadEvent) => void) => void,\n): UnloadGuardState {\n let armed = false\n return {\n arm() {\n if (armed) return\n armed = true\n register((event) => {\n event.preventDefault()\n // Legacy channel — some browsers still require a truthy returnValue.\n event.returnValue = ''\n })\n },\n isArmed() {\n return armed\n },\n }\n}\n\n// --- App wiring (module singleton) -------------------------------------------------\n\nconst guard = createUnloadGuardState((handler) => {\n if (typeof window !== 'undefined') window.addEventListener('beforeunload', handler)\n})\n\n/**\n * Feed an operation event to the guard (the project session's event-bus\n * subscription calls this alongside the content-session staleness mark).\n */\nexport function notePlaygroundWriteForUnloadGuard(event: OperationEvent): void {\n if (shouldArmUnloadGuard(event)) guard.arm()\n}\n\n/** Introspection seam (live verification + tests): is the page-level guard armed? */\nexport function isPlaygroundUnloadGuardArmed(): boolean {\n return guard.isArmed()\n}\n"]}
1
+ {"version":3,"file":"playground-unload-guard.js","sourceRoot":"","sources":["../../../src/lib/data/playground-unload-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAEjE,mEAAmE;AACnE,MAAM,UAAU,oBAAoB,CAClC,KAAqB,EACrB,aAAsB,gBAAgB,EAAE;IAExC,OAAO,UAAU,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAA;AACnD,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAA+D;IAE/D,IAAI,KAAK,GAAG,KAAK,CAAA;IACjB,OAAO;QACL,GAAG;YACD,IAAI,KAAK;gBAAE,OAAM;YACjB,KAAK,GAAG,IAAI,CAAA;YACZ,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;gBACjB,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,qEAAqE;gBACrE,KAAK,CAAC,WAAW,GAAG,EAAE,CAAA;YACxB,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO;YACL,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAED,sFAAsF;AAEtF,MAAM,KAAK,GAAG,sBAAsB,CAAC,CAAC,OAAO,EAAE,EAAE;IAC/C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACrF,CAAC,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAAqB;IACrE,IAAI,oBAAoB,CAAC,KAAK,CAAC;QAAE,KAAK,CAAC,GAAG,EAAE,CAAA;AAC9C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B;IAC1C,OAAO,KAAK,CAAC,OAAO,EAAE,CAAA;AACxB,CAAC","sourcesContent":["/**\n * EC-461 — the playground `beforeunload` guard.\n *\n * The playground's world is one in-memory adapter: a full page unload — a\n * reload, a Vite full-reload after a source edit (HMR), a hard top-level\n * navigation, a closed tab — destroys every authored document, schema change,\n * asset and publish irrecoverably. That is documented semantics, but losing it\n * SILENTLY is not acceptable once the session actually holds authored state.\n *\n * The rule (stated once, applied everywhere): the guard arms in PLAYGROUND\n * mode only, the first time a content-bearing write command succeeds on the\n * operations event bus (the same `isContentSessionWrite` predicate the EC-460\n * content-session sync uses — documents/schema/assets), and never disarms for\n * the rest of the page's life: any such write means the world has diverged\n * from its deterministic seed, and nothing short of the unload itself brings\n * it back. Connected mode never arms — writes persist to the backend within\n * the autosave rhythm, in-app navigation flushes pending autosaves on unmount,\n * and explicit-save rails carry their own `UnsavedChangesGuard`; a blanket\n * unload prompt there would cry wolf on every visit.\n *\n * The decision core ({@link createUnloadGuardState}) is pure (house pattern);\n * the module singleton below injects the real `window` listener registration.\n * Browsers require sticky user activation to actually show the dialog — an\n * un-interacted-with tab reloads silently regardless, which is fine: any\n * authored write implies interaction.\n */\nimport { isPlaygroundMode } from '../persistence'\nimport type { OperationEvent } from '../operations'\nimport { isContentSessionWrite } from './content-session-refresh'\n\n/** Should this operation event arm the playground unload guard? */\nexport function shouldArmUnloadGuard(\n event: OperationEvent,\n playground: boolean = isPlaygroundMode(),\n): boolean {\n return playground && isContentSessionWrite(event)\n}\n\nexport interface UnloadGuardState {\n /** A qualifying write happened — register the listener once. */\n arm(): void\n /** Is the guard live (listener registered)? */\n isArmed(): boolean\n}\n\n/**\n * The arm-once state machine. `register` is the injected DOM seam — it is\n * called exactly once, on the first arm, with the handler that flags the\n * unload prompt (`event.preventDefault()` + legacy `returnValue`).\n */\nexport function createUnloadGuardState(\n register: (handler: (event: BeforeUnloadEvent) => void) => void,\n): UnloadGuardState {\n let armed = false\n return {\n arm() {\n if (armed) return\n armed = true\n register((event) => {\n event.preventDefault()\n // Legacy channel — some browsers still require a truthy returnValue.\n event.returnValue = ''\n })\n },\n isArmed() {\n return armed\n },\n }\n}\n\n// --- App wiring (module singleton) -------------------------------------------------\n\nconst guard = createUnloadGuardState((handler) => {\n if (typeof window !== 'undefined') window.addEventListener('beforeunload', handler)\n})\n\n/**\n * Feed an operation event to the guard (the project session's event-bus\n * subscription calls this alongside the content-session staleness mark).\n */\nexport function notePlaygroundWriteForUnloadGuard(event: OperationEvent): void {\n if (shouldArmUnloadGuard(event)) guard.arm()\n}\n\n/** Introspection seam (live verification + tests): is the page-level guard armed? */\nexport function isPlaygroundUnloadGuardArmed(): boolean {\n return guard.isArmed()\n}\n"]}
@@ -13,4 +13,4 @@
13
13
  * (The convex-side stamp does NOT read this mirror — `convex/delivery.ts` imports the
14
14
  * package.json declaration directly; its bundler allows what tsc's rootDir forbids.)
15
15
  */
16
- export declare const ENGINE_VERSION = "0.0.93";
16
+ export declare const ENGINE_VERSION = "0.0.94";
@@ -13,5 +13,5 @@
13
13
  * (The convex-side stamp does NOT read this mirror — `convex/delivery.ts` imports the
14
14
  * package.json declaration directly; its bundler allows what tsc's rootDir forbids.)
15
15
  */
16
- export const ENGINE_VERSION = '0.0.93';
16
+ export const ENGINE_VERSION = '0.0.94';
17
17
  //# sourceMappingURL=engine-version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-version.js","sourceRoot":"","sources":["../../src/lib/engine-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAA","sourcesContent":["/**\n * The engine version this studio build was compiled from (EC-552) — the client-side\n * half of the deployed-functions version handshake: the boot gate compares it against\n * what `delivery:engineVersion` answers from the deployment.\n *\n * A MIRROR of `package.json`'s `version`, not the declaration itself: client source\n * cannot import `../../package.json` (outside the tsc build's `rootDir`; moving the\n * root would reshape `dist` and every export path). The parity test beside this file\n * fs-reads the real declaration and fails `pnpm verify` the moment the two diverge,\n * so a release cannot ship with a stale mirror. `pnpm release:bump` writes this\n * alongside the five `package.json` versions (EC-608).\n *\n * (The convex-side stamp does NOT read this mirror — `convex/delivery.ts` imports the\n * package.json declaration directly; its bundler allows what tsc's rootDir forbids.)\n */\nexport const ENGINE_VERSION = '0.0.93'\n"]}
1
+ {"version":3,"file":"engine-version.js","sourceRoot":"","sources":["../../src/lib/engine-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAA","sourcesContent":["/**\n * The engine version this studio build was compiled from (EC-552) — the client-side\n * half of the deployed-functions version handshake: the boot gate compares it against\n * what `delivery:engineVersion` answers from the deployment.\n *\n * A MIRROR of `package.json`'s `version`, not the declaration itself: client source\n * cannot import `../../package.json` (outside the tsc build's `rootDir`; moving the\n * root would reshape `dist` and every export path). The parity test beside this file\n * fs-reads the real declaration and fails `pnpm verify` the moment the two diverge,\n * so a release cannot ship with a stale mirror. `pnpm release:bump` writes this\n * alongside the five `package.json` versions (EC-608).\n *\n * (The convex-side stamp does NOT read this mirror — `convex/delivery.ts` imports the\n * package.json declaration directly; its bundler allows what tsc's rootDir forbids.)\n */\nexport const ENGINE_VERSION = '0.0.94'\n"]}