@rebasepro/cms 0.30.0 → 0.31.0-canary.g59cd6fd

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 (583) hide show
  1. package/README.md +8 -8
  2. package/dist/collection_editor/ConfigControllerProvider.js +25 -22
  3. package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
  4. package/dist/collection_editor/firestore_callee.d.ts +10 -0
  5. package/dist/collection_editor/firestore_callee.js +15 -0
  6. package/dist/collection_editor/firestore_callee.js.map +1 -0
  7. package/dist/collection_editor/firestore_edit.d.ts +62 -0
  8. package/dist/collection_editor/firestore_edit.js +339 -0
  9. package/dist/collection_editor/firestore_edit.js.map +1 -0
  10. package/dist/collection_editor/index.d.ts +2 -3
  11. package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
  12. package/dist/collection_editor/liveSchemaClient.js +9 -3
  13. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  14. package/dist/collection_editor/property_column.d.ts +86 -0
  15. package/dist/collection_editor/property_column.js +719 -0
  16. package/dist/collection_editor/property_column.js.map +1 -0
  17. package/dist/collection_editor/serializable_types.d.ts +2 -24
  18. package/dist/collection_editor/serializable_utils.d.ts +1 -1
  19. package/dist/collection_editor/serializable_utils.js +2 -1
  20. package/dist/collection_editor/serializable_utils.js.map +1 -1
  21. package/dist/collection_editor/split_edit.d.ts +106 -0
  22. package/dist/collection_editor/split_edit.js +564 -0
  23. package/dist/collection_editor/split_edit.js.map +1 -0
  24. package/dist/collection_editor/split_edit_error.d.ts +25 -0
  25. package/dist/collection_editor/split_edit_error.js +35 -0
  26. package/dist/collection_editor/split_edit_error.js.map +1 -0
  27. package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
  28. package/dist/collection_editor/types/config_controller.d.ts +67 -1
  29. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
  30. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
  31. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
  32. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
  33. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
  34. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
  35. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
  36. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
  37. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
  38. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
  39. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  40. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
  41. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
  42. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
  43. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
  44. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
  45. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
  46. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
  47. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
  48. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
  49. package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
  50. package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
  51. package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
  52. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
  53. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  54. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
  55. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
  56. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
  57. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
  58. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  59. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
  60. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
  61. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
  62. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
  63. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  64. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
  65. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  66. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
  67. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
  68. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
  69. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
  70. package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
  71. package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
  72. package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
  73. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
  74. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
  75. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
  76. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
  77. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
  78. package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
  79. package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
  80. package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
  81. package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
  82. package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
  83. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  84. package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
  85. package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
  86. package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
  87. package/dist/collection_editor/validateCollectionJson.js.map +1 -1
  88. package/dist/components/CollectionPanel.d.ts +10 -9
  89. package/dist/components/CollectionPanel.js +5 -2
  90. package/dist/components/CollectionPanel.js.map +1 -1
  91. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
  92. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  93. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  94. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
  95. package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
  96. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  97. package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
  98. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  99. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
  100. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
  101. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  102. package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
  103. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  104. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  105. package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
  106. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
  107. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  108. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
  109. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
  110. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
  111. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  112. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
  113. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
  114. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
  115. package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
  116. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  117. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  118. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
  119. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  120. package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
  121. package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
  122. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
  123. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  124. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
  125. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
  126. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  127. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
  128. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  129. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
  130. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
  131. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
  132. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
  133. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  134. package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
  135. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
  136. package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
  137. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  138. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
  139. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  140. package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
  141. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  142. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
  143. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  144. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
  145. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
  146. package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
  147. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
  148. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
  149. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  150. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
  151. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
  152. package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
  153. package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
  154. package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
  155. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
  156. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
  157. package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
  158. package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
  159. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
  160. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
  161. package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
  162. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
  163. package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
  164. package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
  165. package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
  166. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  167. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
  168. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
  169. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
  170. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
  171. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
  172. package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
  173. package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
  174. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  175. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
  176. package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
  177. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
  178. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
  179. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  180. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
  181. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  182. package/dist/components/CollectionsProvider.d.ts +23 -8
  183. package/dist/components/CollectionsProvider.js +23 -7
  184. package/dist/components/CollectionsProvider.js.map +1 -1
  185. package/dist/components/DefaultDrawer.js +1 -1
  186. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  187. package/dist/components/DeleteEntityDialog.js +1 -1
  188. package/dist/components/DeleteEntityDialog.js.map +1 -1
  189. package/dist/components/DetailViewBinding.js +3 -3
  190. package/dist/components/DetailViewBinding.js.map +1 -1
  191. package/dist/components/EditFormActions.js.map +1 -1
  192. package/dist/components/EditViewBinding.d.ts +2 -1
  193. package/dist/components/EditViewBinding.js +6 -6
  194. package/dist/components/EditViewBinding.js.map +1 -1
  195. package/dist/components/EntityDisplayHeader.d.ts +1 -2
  196. package/dist/components/EntityDisplayHeader.js.map +1 -1
  197. package/dist/components/EntityInspector.d.ts +1 -2
  198. package/dist/components/EntityInspector.js.map +1 -1
  199. package/dist/components/EntityPreviewBinding.d.ts +1 -1
  200. package/dist/components/EntityPreviewBinding.js +1 -1
  201. package/dist/components/EntityPreviewBinding.js.map +1 -1
  202. package/dist/components/EntityViewBinding.d.ts +1 -1
  203. package/dist/components/EntityViewBinding.js.map +1 -1
  204. package/dist/components/EntityViewBody.d.ts +1 -1
  205. package/dist/components/EntityViewBody.js +3 -4
  206. package/dist/components/EntityViewBody.js.map +1 -1
  207. package/dist/components/FieldValue.js +2 -2
  208. package/dist/components/FieldValue.js.map +1 -1
  209. package/dist/components/HomePage/ContentHomePage.js +12 -3
  210. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  211. package/dist/components/InlineEntityPreview.d.ts +1 -1
  212. package/dist/components/InlineEntityPreview.js.map +1 -1
  213. package/dist/components/PropertyCollectionView.d.ts +2 -2
  214. package/dist/components/PropertyCollectionView.js.map +1 -1
  215. package/dist/components/PropertyConfigBadge.js.map +1 -1
  216. package/dist/components/RebaseCMS.d.ts +22 -3
  217. package/dist/components/RebaseCMS.js +32 -14
  218. package/dist/components/RebaseCMS.js.map +1 -1
  219. package/dist/components/RebaseNavigation.js +106 -31
  220. package/dist/components/RebaseNavigation.js.map +1 -1
  221. package/dist/components/RecordDetail.js +4 -1
  222. package/dist/components/RecordDetail.js.map +1 -1
  223. package/dist/components/RecordForm.d.ts +5 -5
  224. package/dist/components/RecordForm.js +5 -2
  225. package/dist/components/RecordForm.js.map +1 -1
  226. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
  227. package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
  228. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  229. package/dist/components/ReferenceWidget.d.ts +2 -1
  230. package/dist/components/ReferenceWidget.js +2 -2
  231. package/dist/components/ReferenceWidget.js.map +1 -1
  232. package/dist/components/RelationSelector.d.ts +2 -1
  233. package/dist/components/RelationSelector.js +2 -3
  234. package/dist/components/RelationSelector.js.map +1 -1
  235. package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
  236. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  237. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
  238. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
  239. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  240. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  241. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  242. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  243. package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
  244. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  245. package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
  246. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  247. package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
  248. package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
  249. package/dist/components/SidePanelBinding.js +1 -1
  250. package/dist/components/SidePanelBinding.js.map +1 -1
  251. package/dist/components/field_configs.d.ts +1 -2
  252. package/dist/components/field_configs.js.map +1 -1
  253. package/dist/components/field_ids.d.ts +1 -1
  254. package/dist/components/field_ids.js +1 -1
  255. package/dist/components/field_ids.js.map +1 -1
  256. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  257. package/dist/components/history/EntityHistoryView.d.ts +1 -2
  258. package/dist/components/history/EntityHistoryView.js +1 -1
  259. package/dist/components/history/EntityHistoryView.js.map +1 -1
  260. package/dist/data_export/export/BasicExportAction.d.ts +1 -1
  261. package/dist/data_export/export/BasicExportAction.js.map +1 -1
  262. package/dist/data_export/export/ExportCollectionAction.js +2 -2
  263. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  264. package/dist/data_export/export/additional_fields.d.ts +1 -1
  265. package/dist/data_export/export/additional_fields.js.map +1 -1
  266. package/dist/data_export/export/export.d.ts +1 -1
  267. package/dist/data_export/export/export.js +1 -1
  268. package/dist/data_export/export/export.js.map +1 -1
  269. package/dist/data_export/export/fetch_export_data.d.ts +3 -2
  270. package/dist/data_export/export/fetch_export_data.js.map +1 -1
  271. package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
  272. package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
  273. package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
  274. package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
  275. package/dist/data_import/hooks/useImportConfig.js.map +1 -1
  276. package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
  277. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  278. package/dist/data_import/types/column_mapping.d.ts +1 -1
  279. package/dist/data_import/utils/data.d.ts +1 -2
  280. package/dist/data_import/utils/data.js +1 -2
  281. package/dist/data_import/utils/data.js.map +1 -1
  282. package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
  283. package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
  284. package/dist/data_import/utils/id_column.d.ts +1 -1
  285. package/dist/data_import/utils/id_column.js.map +1 -1
  286. package/dist/data_import/utils/import_columns.d.ts +1 -1
  287. package/dist/data_import/utils/import_columns.js.map +1 -1
  288. package/dist/data_import/utils/save_entities.d.ts +3 -3
  289. package/dist/data_import/utils/save_entities.js +1 -1
  290. package/dist/data_import/utils/save_entities.js.map +1 -1
  291. package/dist/form/EntityForm.js +2 -1
  292. package/dist/form/EntityForm.js.map +1 -1
  293. package/dist/form/EntityFormActions.js.map +1 -1
  294. package/dist/form/EntityFormBinding.js +2 -2
  295. package/dist/form/EntityFormBinding.js.map +1 -1
  296. package/dist/form/FormFieldsContext.d.ts +1 -4
  297. package/dist/form/FormFieldsContext.js +1 -1
  298. package/dist/form/FormFieldsContext.js.map +1 -1
  299. package/dist/form/PropertyFieldBinding.js +6 -8
  300. package/dist/form/PropertyFieldBinding.js.map +1 -1
  301. package/dist/form/components/FieldBlock.d.ts +1 -2
  302. package/dist/form/components/FieldBlock.js.map +1 -1
  303. package/dist/form/components/FieldHelperText.d.ts +1 -1
  304. package/dist/form/components/FieldHelperText.js.map +1 -1
  305. package/dist/form/components/FormRail.d.ts +1 -1
  306. package/dist/form/components/FormRail.js.map +1 -1
  307. package/dist/form/components/LocalChangesMenu.d.ts +1 -1
  308. package/dist/form/components/LocalChangesMenu.js.map +1 -1
  309. package/dist/form/components/StorageItemPreview.d.ts +1 -1
  310. package/dist/form/components/StorageItemPreview.js.map +1 -1
  311. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  312. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
  313. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
  314. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
  315. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  316. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  317. package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
  318. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  319. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  320. package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
  321. package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
  322. package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
  323. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  324. package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
  325. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  326. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  327. package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
  328. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  329. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  330. package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
  331. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  332. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  333. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  334. package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
  335. package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
  336. package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
  337. package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
  338. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  339. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  340. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  341. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  342. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
  343. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  344. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  345. package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
  346. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  347. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  348. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  349. package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
  350. package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
  351. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  352. package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
  353. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  354. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
  355. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  356. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
  357. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  358. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  359. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  360. package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
  361. package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
  362. package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
  363. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
  364. package/dist/form/form_utils.d.ts +3 -3
  365. package/dist/form/form_utils.js +1 -2
  366. package/dist/form/form_utils.js.map +1 -1
  367. package/dist/form/label_placement.d.ts +1 -2
  368. package/dist/form/label_placement.js.map +1 -1
  369. package/dist/form/resolve_cell_property.d.ts +1 -2
  370. package/dist/form/resolve_cell_property.js +1 -1
  371. package/dist/form/resolve_cell_property.js.map +1 -1
  372. package/dist/form/resolve_form_properties.d.ts +2 -2
  373. package/dist/form/resolve_form_properties.js +1 -1
  374. package/dist/form/resolve_form_properties.js.map +1 -1
  375. package/dist/form/useClearRestoreValue.d.ts +1 -1
  376. package/dist/form/useClearRestoreValue.js.map +1 -1
  377. package/dist/form/validation.d.ts +2 -2
  378. package/dist/form/validation.js +1 -1
  379. package/dist/form/validation.js.map +1 -1
  380. package/dist/hooks/navigation/compose_collections.d.ts +59 -0
  381. package/dist/hooks/navigation/compose_collections.js +48 -0
  382. package/dist/hooks/navigation/compose_collections.js.map +1 -0
  383. package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
  384. package/dist/hooks/navigation/compose_collections_input.js +17 -0
  385. package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
  386. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
  387. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
  388. package/dist/hooks/navigation/registered_collection.d.ts +15 -0
  389. package/dist/hooks/navigation/registered_collection.js +20 -0
  390. package/dist/hooks/navigation/registered_collection.js.map +1 -0
  391. package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
  392. package/dist/hooks/navigation/ui_preferences.js +179 -0
  393. package/dist/hooks/navigation/ui_preferences.js.map +1 -0
  394. package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
  395. package/dist/hooks/navigation/useAsyncResolver.js +9 -3
  396. package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
  397. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
  398. package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
  399. package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
  400. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
  401. package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
  402. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  403. package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
  404. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  405. package/dist/hooks/navigation/useNavigationResolution.js +1 -2
  406. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  407. package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
  408. package/dist/hooks/navigation/usePanelTables.js +33 -0
  409. package/dist/hooks/navigation/usePanelTables.js.map +1 -0
  410. package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
  411. package/dist/hooks/navigation/useResolvedCollections.js +3 -2
  412. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  413. package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
  414. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  415. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
  416. package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
  417. package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
  418. package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
  419. package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
  420. package/dist/hooks/navigation/utils.js +1 -1
  421. package/dist/hooks/navigation/utils.js.map +1 -1
  422. package/dist/hooks/useAdminContext.d.ts +1 -2
  423. package/dist/hooks/useAdminContext.js.map +1 -1
  424. package/dist/hooks/useBuildSidePanel.d.ts +1 -2
  425. package/dist/hooks/useBuildSidePanel.js +2 -1
  426. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  427. package/dist/hooks/useChildViewSource.d.ts +1 -1
  428. package/dist/hooks/useChildViewSource.js +1 -1
  429. package/dist/hooks/useChildViewSource.js.map +1 -1
  430. package/dist/hooks/useEntityDisplay.d.ts +1 -2
  431. package/dist/hooks/useEntityDisplay.js +1 -1
  432. package/dist/hooks/useEntityDisplay.js.map +1 -1
  433. package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
  434. package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
  435. package/dist/hooks/useHistory.js +1 -1
  436. package/dist/hooks/useHistory.js.map +1 -1
  437. package/dist/hooks/useRecordActions.d.ts +1 -2
  438. package/dist/hooks/useRecordActions.js.map +1 -1
  439. package/dist/hooks/useReferencePaths.d.ts +21 -7
  440. package/dist/hooks/useReferencePaths.js +23 -6
  441. package/dist/hooks/useReferencePaths.js.map +1 -1
  442. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  443. package/dist/hooks/useResolvedNavigationFrom.js +1 -1
  444. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  445. package/dist/index.d.ts +11 -0
  446. package/dist/index.js +8 -2
  447. package/dist/mcp_view/app_modules.d.ts +2 -2
  448. package/dist/mcp_view/app_modules.js +4 -4
  449. package/dist/mcp_view/app_modules.js.map +1 -1
  450. package/dist/mcp_view/index.d.ts +16 -19
  451. package/dist/mcp_view/index.js +43 -62
  452. package/dist/mcp_view/index.js.map +1 -1
  453. package/dist/mcp_view/payload.d.ts +54 -18
  454. package/dist/mcp_view/payload.js +49 -24
  455. package/dist/mcp_view/payload.js.map +1 -1
  456. package/dist/mcp_view/screen.js +11 -11
  457. package/dist/mcp_view/screen.js.map +1 -1
  458. package/dist/mcp_view/tool_driver.d.ts +5 -34
  459. package/dist/mcp_view/tool_driver.js +17 -16
  460. package/dist/mcp_view/tool_driver.js.map +1 -1
  461. package/dist/mcp_view/write_review.d.ts +1 -2
  462. package/dist/mcp_view/write_review.js +1 -1
  463. package/dist/mcp_view/write_review.js.map +1 -1
  464. package/dist/preview/PropertyPreview.d.ts +1 -1
  465. package/dist/preview/PropertyPreview.js +4 -3
  466. package/dist/preview/PropertyPreview.js.map +1 -1
  467. package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
  468. package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
  469. package/dist/preview/components/BooleanPreview.d.ts +1 -1
  470. package/dist/preview/components/BooleanPreview.js.map +1 -1
  471. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  472. package/dist/preview/components/EnumValuesChip.js +1 -1
  473. package/dist/preview/components/EnumValuesChip.js.map +1 -1
  474. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  475. package/dist/preview/components/ReferencePreview.js.map +1 -1
  476. package/dist/preview/components/RelationPreview.d.ts +1 -1
  477. package/dist/preview/components/RelationPreview.js.map +1 -1
  478. package/dist/preview/components/StorageThumbnail.js +2 -1
  479. package/dist/preview/components/StorageThumbnail.js.map +1 -1
  480. package/dist/preview/components/UserPreview.d.ts +1 -1
  481. package/dist/preview/components/UserPreview.js.map +1 -1
  482. package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
  483. package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
  484. package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
  485. package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
  486. package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
  487. package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
  488. package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
  489. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
  490. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
  491. package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
  492. package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
  493. package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
  494. package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
  495. package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
  496. package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
  497. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
  498. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
  499. package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
  500. package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
  501. package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
  502. package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
  503. package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
  504. package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
  505. package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
  506. package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
  507. package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
  508. package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
  509. package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
  510. package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
  511. package/dist/preview/util.d.ts +1 -1
  512. package/dist/preview/util.js.map +1 -1
  513. package/dist/routes/RebaseRoute.js +2 -2
  514. package/dist/routes/RebaseRoute.js.map +1 -1
  515. package/dist/saved_apps/SavedAppsView.d.ts +1 -1
  516. package/dist/saved_apps/SavedAppsView.js +1 -1
  517. package/dist/saved_apps/SavedAppsView.js.map +1 -1
  518. package/dist/selection/SelectionMenu.d.ts +1 -1
  519. package/dist/selection/SelectionMenu.js.map +1 -1
  520. package/dist/selection/resolve_selection.d.ts +3 -3
  521. package/dist/selection/resolve_selection.js +3 -2
  522. package/dist/selection/resolve_selection.js.map +1 -1
  523. package/dist/tables/apply_customization.d.ts +65 -0
  524. package/dist/tables/apply_customization.js +644 -0
  525. package/dist/tables/apply_customization.js.map +1 -0
  526. package/dist/tables/column_property.d.ts +64 -0
  527. package/dist/tables/column_property.js +549 -0
  528. package/dist/tables/column_property.js.map +1 -0
  529. package/dist/tables/customize_table.d.ts +39 -0
  530. package/dist/tables/customize_table.js +247 -0
  531. package/dist/tables/customize_table.js.map +1 -0
  532. package/dist/tables/index.d.ts +12 -0
  533. package/dist/tables/labels.d.ts +18 -0
  534. package/dist/tables/labels.js +18 -0
  535. package/dist/tables/labels.js.map +1 -0
  536. package/dist/tables/project_table.d.ts +79 -0
  537. package/dist/tables/project_table.js +148 -0
  538. package/dist/tables/project_table.js.map +1 -0
  539. package/dist/tables/relations.d.ts +47 -0
  540. package/dist/tables/relations.js +112 -0
  541. package/dist/tables/relations.js.map +1 -0
  542. package/dist/tables/rls.d.ts +39 -0
  543. package/dist/tables/rls.js +111 -0
  544. package/dist/tables/rls.js.map +1 -0
  545. package/dist/tables/update_record.d.ts +32 -0
  546. package/dist/tables/update_record.js +40 -0
  547. package/dist/tables/update_record.js.map +1 -0
  548. package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
  549. package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
  550. package/dist/types/fields.d.ts +2 -2
  551. package/dist/util/dataControllerAdapter.js.map +1 -1
  552. package/dist/util/entity_pages.d.ts +2 -1
  553. package/dist/util/entity_pages.js.map +1 -1
  554. package/dist/util/find_entities_by_ids.d.ts +2 -2
  555. package/dist/util/find_entities_by_ids.js +1 -1
  556. package/dist/util/find_entities_by_ids.js.map +1 -1
  557. package/dist/util/format_collection_date.d.ts +1 -1
  558. package/dist/util/format_collection_date.js.map +1 -1
  559. package/dist/util/identity.d.ts +8 -0
  560. package/dist/util/identity.js +16 -0
  561. package/dist/util/identity.js.map +1 -0
  562. package/dist/util/navigation_utils.js +1 -1
  563. package/dist/util/navigation_utils.js.map +1 -1
  564. package/dist/util/previews.js +1 -1
  565. package/dist/util/previews.js.map +1 -1
  566. package/dist/util/propertyConfigMapper.d.ts +1 -1
  567. package/dist/util/propertyConfigMapper.js.map +1 -1
  568. package/dist/util/property_utils.d.ts +1 -3
  569. package/dist/util/property_utils.js +1 -1
  570. package/dist/util/property_utils.js.map +1 -1
  571. package/dist/util/relations.d.ts +18 -0
  572. package/dist/util/relations.js +32 -0
  573. package/dist/util/relations.js.map +1 -0
  574. package/package.json +12 -10
  575. package/recipes/README.md +4 -4
  576. package/recipes/my-preferences.tsx +34 -26
  577. package/recipes/site-settings.tsx +34 -27
  578. package/dist/collection_editor/collection_wire.d.ts +0 -13
  579. package/dist/collection_editor/collection_wire.js +0 -49
  580. package/dist/collection_editor/collection_wire.js.map +0 -1
  581. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
  582. package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
  583. package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import type { AuthState, Properties, Property } from "@rebasepro/types";
2
- import type { FieldViewer, ResolvePropertyProps } from "@rebasepro/common";
1
+ import type { FieldViewer } from "@rebasepro/common";
2
+ import type { ResolvePropertyProps, Properties, Property, AuthState } from "@rebasepro/cms-types";
3
3
  /**
4
4
  * A property as the record form shows it and judges it, given the values the
5
5
  * form holds now: its `dynamicProps` applied, then its `conditions`, then the
@@ -1,5 +1,5 @@
1
1
  import { deepEqual } from "fast-equals";
2
- import { buildConditionContext, canReadField, canWriteField, resolveProperty } from "@rebasepro/common";
2
+ import { buildConditionContext, canReadField, canWriteField, resolveProperty } from "@rebasepro/cms-types";
3
3
  import { applyPropertyConditions, isDisabled, isHidden, isReadOnly } from "@rebasepro/app";
4
4
  //#region src/form/resolve_form_properties.ts
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolve_form_properties.js","names":[],"sources":["../../src/form/resolve_form_properties.ts"],"sourcesContent":["import type { AuthState, Properties, Property } from \"@rebasepro/types\";\nimport type { FieldViewer, ResolvePropertyProps } from \"@rebasepro/common\";\nimport { buildConditionContext, canReadField, canWriteField, resolveProperty } from \"@rebasepro/common\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { applyPropertyConditions, isDisabled, isHidden, isReadOnly } from \"@rebasepro/app\";\n\n/**\n * A property as the record form shows it and judges it, given the values the\n * form holds now: its `dynamicProps` applied, then its `conditions`, then the\n * signed-in user's field access (see {@link applyFieldAccess}).\n *\n * One function for both, so what a field looks like and what the save checks\n * cannot drift apart. They had: the field was resolved through `dynamicProps`\n * and nothing else, and the save was judged against the raw declaration — so a\n * `dynamicProps` validation was never checked, and a `conditions` rule written\n * by the collection editor (and taught by the docs) did nothing anywhere.\n */\nexport function resolveFormProperty<M extends Record<string, unknown> = Record<string, unknown>>(\n props: ResolvePropertyProps<M>\n): Property | null {\n const resolved = resolveProperty(props);\n if (!resolved) return resolved;\n const conditioned = resolved.conditions\n ? applyPropertyConditions(resolved, buildConditionContext({\n propertyKey: props.propertyKey,\n values: props.values,\n previousValues: props.previousValues,\n path: props.path ?? \"\",\n entityId: props.entityId === undefined ? undefined : String(props.entityId),\n index: props.index,\n authController: props.authController\n }))\n : resolved;\n return applyFieldAccess(conditioned, formViewer(props.authController));\n}\n\n/**\n * The signed-in user as a field rule judges them — the roles the condition\n * context reads too, so `hasRole` and `access` agree on who is asking.\n *\n * Always a viewer, never `undefined`: `undefined` is the trusted server plane,\n * which satisfies every non-empty rule. Nobody signed in is a viewer with no\n * roles.\n */\nexport function formViewer(authController: AuthState): FieldViewer {\n const roles: unknown[] = authController.user?.roles ?? [];\n return { roles: roles.map(r => typeof r === \"string\" ? r : (r as { id: string }).id) };\n}\n\n/**\n * `property.access` in the form, which is where the user meets it.\n *\n * The server enforces it either way — it strips a field the caller cannot\n * read and refuses a write naming one they cannot set. The form did not read\n * it, so a field the user could not write was an ordinary input whose edit\n * came back as a 400 on save, and a field they could not read was an empty\n * input inviting them to fill it. A field they cannot read is hidden; one they\n * can read but not write is shown read-only.\n */\nexport function applyFieldAccess(property: Property, viewer: FieldViewer): Property {\n if (!canReadField(property, viewer)) {\n return { ...property, conditions: { ...property.conditions, hidden: true } } as Property;\n }\n if (!canWriteField(property, viewer)) {\n return { ...property, admin: { ...property.admin, readOnly: true } } as Property;\n }\n return property;\n}\n\n/**\n * A new record's or a copy's values without the fields this user may not\n * write that still hold what the form opened with.\n *\n * The form shows such a field read-only, so its value there is a default or\n * the original record's — not an edit — and the server refuses a whole save\n * that names it. A value that did change (a callback or plugin set it) is\n * kept, and the server's refusal says why the save failed: dropping it would\n * report success for an edit that did not happen.\n */\nexport function withoutUnwritableDefaults<M extends Record<string, unknown>>(\n values: Partial<M>,\n openedWith: Partial<M>,\n properties: Properties,\n viewer: FieldViewer\n): Partial<M> {\n let result: Partial<M> | undefined;\n for (const key of Object.keys(values)) {\n const property = (properties as Record<string, Property | undefined>)[key];\n if (!property || canWriteField(property, viewer)) continue;\n if (!equal(values[key], openedWith[key])) continue;\n result ??= { ...values };\n delete result[key];\n }\n return result ?? values;\n}\n\n/**\n * Whether the user can change this field in the form at all. A field the form\n * keeps hidden, read-only or disabled cannot be fixed from it, so it is not the\n * form's to judge: holding the save against it left \"Please fix the\n * highlighted errors\" over a form with nothing highlighted. The server's own\n * checks — `required`, `NOT NULL` — still hold for it.\n */\nfunction isEditableInForm(property: Property): boolean {\n return !isHidden(property) && !isReadOnly(property) && !isDisabled(property);\n}\n\n/**\n * The properties the form validates on submit: each resolved against `values`\n * (see {@link resolveFormProperty}), inside maps too, and only those the user\n * can change.\n */\nexport function resolvePropertiesForValidation<M extends Record<string, unknown>>({\n properties,\n propertyKey,\n isNew,\n ...props\n}: Omit<ResolvePropertyProps<M>, \"property\"> & {\n properties: Properties;\n /**\n * Whether the record is being created. A field marked\n * `admin.filledByServer` or `databaseDefault` is not required then: the\n * server, or the database, fills it.\n */\n isNew?: boolean;\n}): Properties {\n const result: Record<string, Property> = {};\n for (const [key, raw] of Object.entries(properties as Record<string, Property>)) {\n if (!raw) continue;\n const childKey = propertyKey ? `${propertyKey}.${key}` : key;\n const formProperty = resolveFormProperty<M>({\n ...props,\n ignoreMissingFields: true,\n propertyKey: childKey,\n property: raw\n });\n if (!formProperty || !isEditableInForm(formProperty)) continue;\n const filledOnCreate = formProperty.admin?.filledByServer || formProperty.databaseDefault;\n const resolved = isNew && filledOnCreate && formProperty.validation?.required\n ? { ...formProperty, validation: { ...formProperty.validation, required: false } } as Property\n : formProperty;\n if (resolved.type === \"map\" && resolved.properties) {\n // `resolveProperty` walked the children for their `dynamicProps`\n // but not their conditions. Resolving them again applies both; a\n // builder is a function of the values, so applying it twice is\n // applying it once.\n result[key] = {\n ...resolved,\n properties: resolvePropertiesForValidation<M>({\n ...props,\n isNew,\n propertyKey: childKey,\n properties: resolved.properties as Properties\n })\n };\n } else {\n result[key] = resolved;\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,oBACZ,OACe;CACf,MAAM,WAAW,gBAAgB,KAAK;CACtC,IAAI,CAAC,UAAU,OAAO;CAYtB,OAAO,iBAXa,SAAS,aACvB,wBAAwB,UAAU,sBAAsB;EACtD,aAAa,MAAM;EACnB,QAAQ,MAAM;EACd,gBAAgB,MAAM;EACtB,MAAM,MAA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E,IAAI,CAAC,KAAK;EACV,MAAM,WAAW,cAAc,GAAG,YAAY,GAAG,QAAQ;EACzD,MAAM,eAAe,oBAAuB;GACxC,GAAG;GACH,qBAAqB;GACrB,aAAa;GACb,UAAU;EACd,CAAC;EACD,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,YAAY,GAAG;EACtD,MAAM,iBAAiB,aAAa,OAAO,kBAAkB,aAAa;EAC1E,MAAM,WAAW,SAAS,kBAAkB,aAAa,YAAY,WAC/D;GAAE,GAAG;GAAc,YAAY;IAAE,GAAG,aAAa;IAAY,UAAU;GAAM;EAAE,IAC/E;EACN,IAAI,SAAS,SAAS,SAAS,SAAS,YAKpC,OAAO,OAAO;GACV,GAAG;GACH,YAAY,+BAAkC;IAC1C,GAAG;IACH;IACA,aAAa;IACb,YAAY,SAAS;GACzB,CAAC;EACL;OAEA,OAAO,OAAO;CAEtB;CACA,OAAO;AACX"}
1
+ {"version":3,"file":"resolve_form_properties.js","names":[],"sources":["../../src/form/resolve_form_properties.ts"],"sourcesContent":["import type { FieldViewer } from \"@rebasepro/common\";\nimport type { ResolvePropertyProps, Properties, Property, AuthState } from \"@rebasepro/cms-types\";\nimport { buildConditionContext, resolveProperty, canReadField, canWriteField } from \"@rebasepro/cms-types\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { applyPropertyConditions, isDisabled, isHidden, isReadOnly } from \"@rebasepro/app\";\n\n/**\n * A property as the record form shows it and judges it, given the values the\n * form holds now: its `dynamicProps` applied, then its `conditions`, then the\n * signed-in user's field access (see {@link applyFieldAccess}).\n *\n * One function for both, so what a field looks like and what the save checks\n * cannot drift apart. They had: the field was resolved through `dynamicProps`\n * and nothing else, and the save was judged against the raw declaration — so a\n * `dynamicProps` validation was never checked, and a `conditions` rule written\n * by the collection editor (and taught by the docs) did nothing anywhere.\n */\nexport function resolveFormProperty<M extends Record<string, unknown> = Record<string, unknown>>(\n props: ResolvePropertyProps<M>\n): Property | null {\n const resolved = resolveProperty(props);\n if (!resolved) return resolved;\n const conditioned = resolved.conditions\n ? applyPropertyConditions(resolved, buildConditionContext({\n propertyKey: props.propertyKey,\n values: props.values,\n previousValues: props.previousValues,\n path: props.path ?? \"\",\n entityId: props.entityId === undefined ? undefined : String(props.entityId),\n index: props.index,\n authController: props.authController\n }))\n : resolved;\n return applyFieldAccess(conditioned, formViewer(props.authController));\n}\n\n/**\n * The signed-in user as a field rule judges them — the roles the condition\n * context reads too, so `hasRole` and `access` agree on who is asking.\n *\n * Always a viewer, never `undefined`: `undefined` is the trusted server plane,\n * which satisfies every non-empty rule. Nobody signed in is a viewer with no\n * roles.\n */\nexport function formViewer(authController: AuthState): FieldViewer {\n const roles: unknown[] = authController.user?.roles ?? [];\n return { roles: roles.map(r => typeof r === \"string\" ? r : (r as { id: string }).id) };\n}\n\n/**\n * `property.access` in the form, which is where the user meets it.\n *\n * The server enforces it either way — it strips a field the caller cannot\n * read and refuses a write naming one they cannot set. The form did not read\n * it, so a field the user could not write was an ordinary input whose edit\n * came back as a 400 on save, and a field they could not read was an empty\n * input inviting them to fill it. A field they cannot read is hidden; one they\n * can read but not write is shown read-only.\n */\nexport function applyFieldAccess(property: Property, viewer: FieldViewer): Property {\n if (!canReadField(property, viewer)) {\n return { ...property, conditions: { ...property.conditions, hidden: true } } as Property;\n }\n if (!canWriteField(property, viewer)) {\n return { ...property, admin: { ...property.admin, readOnly: true } } as Property;\n }\n return property;\n}\n\n/**\n * A new record's or a copy's values without the fields this user may not\n * write that still hold what the form opened with.\n *\n * The form shows such a field read-only, so its value there is a default or\n * the original record's — not an edit — and the server refuses a whole save\n * that names it. A value that did change (a callback or plugin set it) is\n * kept, and the server's refusal says why the save failed: dropping it would\n * report success for an edit that did not happen.\n */\nexport function withoutUnwritableDefaults<M extends Record<string, unknown>>(\n values: Partial<M>,\n openedWith: Partial<M>,\n properties: Properties,\n viewer: FieldViewer\n): Partial<M> {\n let result: Partial<M> | undefined;\n for (const key of Object.keys(values)) {\n const property = (properties as Record<string, Property | undefined>)[key];\n if (!property || canWriteField(property, viewer)) continue;\n if (!equal(values[key], openedWith[key])) continue;\n result ??= { ...values };\n delete result[key];\n }\n return result ?? values;\n}\n\n/**\n * Whether the user can change this field in the form at all. A field the form\n * keeps hidden, read-only or disabled cannot be fixed from it, so it is not the\n * form's to judge: holding the save against it left \"Please fix the\n * highlighted errors\" over a form with nothing highlighted. The server's own\n * checks — `required`, `NOT NULL` — still hold for it.\n */\nfunction isEditableInForm(property: Property): boolean {\n return !isHidden(property) && !isReadOnly(property) && !isDisabled(property);\n}\n\n/**\n * The properties the form validates on submit: each resolved against `values`\n * (see {@link resolveFormProperty}), inside maps too, and only those the user\n * can change.\n */\nexport function resolvePropertiesForValidation<M extends Record<string, unknown>>({\n properties,\n propertyKey,\n isNew,\n ...props\n}: Omit<ResolvePropertyProps<M>, \"property\"> & {\n properties: Properties;\n /**\n * Whether the record is being created. A field marked\n * `admin.filledByServer` or `databaseDefault` is not required then: the\n * server, or the database, fills it.\n */\n isNew?: boolean;\n}): Properties {\n const result: Record<string, Property> = {};\n for (const [key, raw] of Object.entries(properties as Record<string, Property>)) {\n if (!raw) continue;\n const childKey = propertyKey ? `${propertyKey}.${key}` : key;\n const formProperty = resolveFormProperty<M>({\n ...props,\n ignoreMissingFields: true,\n propertyKey: childKey,\n property: raw\n });\n if (!formProperty || !isEditableInForm(formProperty)) continue;\n const filledOnCreate = formProperty.admin?.filledByServer || formProperty.databaseDefault;\n const resolved = isNew && filledOnCreate && formProperty.validation?.required\n ? { ...formProperty, validation: { ...formProperty.validation, required: false } } as Property\n : formProperty;\n if (resolved.type === \"map\" && resolved.properties) {\n // `resolveProperty` walked the children for their `dynamicProps`\n // but not their conditions. Resolving them again applies both; a\n // builder is a function of the values, so applying it twice is\n // applying it once.\n result[key] = {\n ...resolved,\n properties: resolvePropertiesForValidation<M>({\n ...props,\n isNew,\n propertyKey: childKey,\n properties: resolved.properties as Properties\n })\n };\n } else {\n result[key] = resolved;\n }\n }\n return result;\n}\n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nD,OAAO,CAAC,SAAS,QAAQ,KAAK,CAAC,WAAW,QAAQ,KAAK,CAAC,WAAW,QAAQ;AAC/E;;;;;;AAOA,SAAgB,+BAAkE,EAC9E,YACA,aACA,OACA,GAAG,SASQ;CACX,MAAM,SAAmC,CAAC;CAC1C,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,UAAsC,GAAG;EAC7E,IAAI,CAAC,KAAK;EACV,MAAM,WAAW,cAAc,GAAG,YAAY,GAAG,QAAQ;EACzD,MAAM,eAAe,oBAAuB;GACxC,GAAG;GACH,qBAAqB;GACrB,aAAa;GACb,UAAU;EACd,CAAC;EACD,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,YAAY,GAAG;EACtD,MAAM,iBAAiB,aAAa,OAAO,kBAAkB,aAAa;EAC1E,MAAM,WAAW,SAAS,kBAAkB,aAAa,YAAY,WAC/D;GAAE,GAAG;GAAc,YAAY;IAAE,GAAG,aAAa;IAAY,UAAU;GAAM;EAAE,IAC/E;EACN,IAAI,SAAS,SAAS,SAAS,SAAS,YAKpC,OAAO,OAAO;GACV,GAAG;GACH,YAAY,+BAAkC;IAC1C,GAAG;IACH;IACA,aAAa;IACb,YAAY,SAAS;GACzB,CAAC;EACL;OAEA,OAAO,OAAO;CAEtB;CACA,OAAO;AACX"}
@@ -1,4 +1,4 @@
1
- import type { Property } from "@rebasepro/types";
1
+ import type { Property } from "@rebasepro/cms-types";
2
2
  /**
3
3
  * Hook we use to restore a value after it has been cleared
4
4
  * @param property
@@ -1 +1 @@
1
- {"version":3,"file":"useClearRestoreValue.js","names":[],"sources":["../../src/form/useClearRestoreValue.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport { useEffect, useRef } from \"react\";\n;\n\n/**\n * Hook we use to restore a value after it has been cleared\n * @param property\n * @param value\n * @param setValue\n * @ignore\n */\nexport function useClearRestoreValue<T>({\n property,\n value,\n setValue\n}:\n {\n property: Property,\n value: T | null,\n setValue: (value: T | null, shouldValidate?: boolean) => void\n }) {\n\n // Boxed, so \"nothing was cleared\" is not confused with a cleared 0,\n // `false` or \"\" — each of which the field would otherwise never get back.\n const clearedRef = useRef<{ value: T } | null>(null);\n useEffect(() => {\n const shouldClearValueIfDisabled = typeof property.admin?.disabled === \"object\" && Boolean(property.admin?.disabled.clearOnDisabled);\n if (shouldClearValueIfDisabled) {\n if (value != null) {\n clearedRef.current = { value };\n setValue(null);\n }\n } else if (clearedRef.current) {\n setValue(clearedRef.current.value);\n clearedRef.current = null;\n }\n }, [property]);\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,qBAAwB,EACpC,UACA,OACA,YAMG;CAIH,MAAM,aAAa,OAA4B,IAAI;CACnD,gBAAgB;EAEZ,IADmC,OAAO,SAAS,OAAO,aAAa,YAAY,QAAQ,SAAS,OAAO,SAAS,eAAe;OAE3H,SAAS,MAAM;IACf,WAAW,UAAU,EAAE,MAAM;IAC7B,SAAS,IAAI;GACjB;SACG,IAAI,WAAW,SAAS;GAC3B,SAAS,WAAW,QAAQ,KAAK;GACjC,WAAW,UAAU;EACzB;CACJ,GAAG,CAAC,QAAQ,CAAC;AACjB"}
1
+ {"version":3,"file":"useClearRestoreValue.js","names":[],"sources":["../../src/form/useClearRestoreValue.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/cms-types\";\nimport { useEffect, useRef } from \"react\";\n;\n\n/**\n * Hook we use to restore a value after it has been cleared\n * @param property\n * @param value\n * @param setValue\n * @ignore\n */\nexport function useClearRestoreValue<T>({\n property,\n value,\n setValue\n}:\n {\n property: Property,\n value: T | null,\n setValue: (value: T | null, shouldValidate?: boolean) => void\n }) {\n\n // Boxed, so \"nothing was cleared\" is not confused with a cleared 0,\n // `false` or \"\" — each of which the field would otherwise never get back.\n const clearedRef = useRef<{ value: T } | null>(null);\n useEffect(() => {\n const shouldClearValueIfDisabled = typeof property.admin?.disabled === \"object\" && Boolean(property.admin?.disabled.clearOnDisabled);\n if (shouldClearValueIfDisabled) {\n if (value != null) {\n clearedRef.current = { value };\n setValue(null);\n }\n } else if (clearedRef.current) {\n setValue(clearedRef.current.value);\n clearedRef.current = null;\n }\n }, [property]);\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,qBAAwB,EACpC,UACA,OACA,YAMG;CAIH,MAAM,aAAa,OAA4B,IAAI;CACnD,gBAAgB;EAEZ,IADmC,OAAO,SAAS,OAAO,aAAa,YAAY,QAAQ,SAAS,OAAO,SAAS,eAAe;OAE3H,SAAS,MAAM;IACf,WAAW,UAAU,EAAE,MAAM;IAC7B,SAAS,IAAI;GACjB;SACG,IAAI,WAAW,SAAS;GAC3B,SAAS,WAAW,QAAQ,KAAK;GACjC,WAAW,UAAU;EACzB;CACJ,GAAG,CAAC,QAAQ,CAAC;AACjB"}
@@ -1,5 +1,5 @@
1
- import type { Properties } from "@rebasepro/types";
2
- import type { ArrayProperty, MapProperty, Property } from "@rebasepro/types";
1
+ import type { Properties } from "@rebasepro/cms-types";
2
+ import type { ArrayProperty, MapProperty, Property } from "@rebasepro/cms-types";
3
3
  import { z, ZodTypeAny } from "zod";
4
4
  export type CustomFieldValidator = (props: {
5
5
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { deepEqual } from "fast-equals";
2
- import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE, enumToObjectEntries, isPropertyBuilder } from "@rebasepro/common";
2
+ import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE, enumToObjectEntries, isPropertyBuilder } from "@rebasepro/cms-types";
3
3
  import { hydrateRegExp, isPlainObject, prettifyIdentifier } from "@rebasepro/utils";
4
4
  import { z } from "zod";
5
5
  //#region src/form/validation.ts
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","names":[],"sources":["../../src/form/validation.ts"],"sourcesContent":["import type { Properties } from \"@rebasepro/types\";\nimport type { ArrayProperty, MapProperty, NumberProperty, Property, BooleanProperty, DateProperty, GeopointProperty, ReferenceProperty, RelationProperty, StringProperty, StringPropertyValidationSchema, VectorProperty, BinaryProperty } from \"@rebasepro/types\";\n;\nimport { z, ZodTypeAny } from \"zod\";\nimport { deepEqual as isDeepEqual } from \"fast-equals\";\nimport { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE, enumToObjectEntries, isPropertyBuilder } from \"@rebasepro/common\";\nimport { getValueInPath, hydrateRegExp, isPlainObject, prettifyIdentifier } from \"@rebasepro/utils\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\n/**\n * What to call this field in a validation message.\n *\n * `property.name` is the author's label and is optional — a headless project has\n * no panel and no reason to invent display names. Every message here\n * interpolated it directly, so an unnamed property produced\n * \"undefined must be min 3 characters long\" in front of a user.\n *\n * The fallback is the field's own key, prettified the same way the panel derives\n * a column header, so the message names the field the author would recognise.\n */\nfunction fieldLabel(property: Property, name?: string): string {\n return property.name ?? (name ? prettifyIdentifier(name) : \"This field\");\n}\n\nfunction relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\nexport type CustomFieldValidator = (props: {\n name: string,\n value: unknown,\n property: Property,\n entityId?: string | number,\n parentProperty?: MapProperty | ArrayProperty,\n}) => Promise<boolean>;\n\ninterface PropertyContext<P extends Property> {\n property: P,\n parentProperty?: MapProperty | ArrayProperty,\n entityId?: string | number,\n customFieldValidator?: CustomFieldValidator,\n name?: string\n}\n\n/**\n * `validation.unique`, for the top-level properties that declare it: whether\n * another record already holds the value, asked of the data source through\n * `validator`. One error per field that fails, keyed like the schema's.\n *\n * Asked only for a value worth asking about — set (not empty), changed from\n * `storedValues` when there are any (a value the edit left alone is the stored\n * record's business, and it may predate the rule), and without an error of its\n * own already in `errors` — so a save makes one lookup per unique field it\n * actually changes, and typing makes none: this runs where validation runs, on\n * submit.\n */\nexport async function uniqueValueErrors({\n properties,\n values,\n storedValues,\n entityId,\n errors,\n validator\n}: {\n properties: Properties,\n values: Record<string, unknown>,\n storedValues?: Record<string, unknown>,\n entityId?: string | number,\n errors?: Record<string, unknown>,\n validator: CustomFieldValidator\n}): Promise<Record<string, string>> {\n const found: Record<string, string> = {};\n await Promise.all(Object.entries(properties as Record<string, Property>).map(async ([name, property]) => {\n if (!property?.validation?.unique) return;\n if (errors && name in errors) return;\n const value = values[name];\n if (value === undefined || value === null || value === \"\") return;\n if (storedValues && isDeepEqual(value, storedValues[name])) return;\n const unique = await validator({ name, value, property, entityId });\n if (!unique) found[name] = `${fieldLabel(property, name)} must be unique: another record already has this value`;\n }));\n return found;\n}\n\nexport function getEntitySchema<M extends Record<string, unknown>>(\n entityId: string | number | undefined,\n properties: Properties,\n customFieldValidator?: CustomFieldValidator): z.ZodObject<Record<string, ZodTypeAny>> {\n const shape: Record<string, ZodTypeAny> = {};\n Object.entries(properties as Record<string, Property>)\n .forEach(([name, property]) => {\n const isStringOrNumber = property.type === \"string\" || property.type === \"number\";\n const isIdAndAuto = isStringOrNumber && \"isId\" in property && typeof property.isId === \"string\" && property.isId !== \"manual\";\n if (entityId === undefined && isIdAndAuto) {\n return; // Skip validation for auto-generated IDs on new entities\n }\n shape[name] = mapPropertyToZod({\n property: property as Property,\n customFieldValidator,\n name,\n entityId\n });\n });\n return z.object(shape).passthrough();\n}\n\n\nexport function mapPropertyToZod(propertyContext: PropertyContext<Property>): ZodTypeAny {\n\n const property = propertyContext.property;\n if (isPropertyBuilder(property) && !property.type) {\n console.error(\"Error in property\", propertyContext);\n // Return a schema that always fails\n return z.any().refine(\n () => false,\n { message: \"Invalid property configuration: property builder should be resolved\" }\n );\n }\n\n if (property.type === \"string\") {\n return getZodStringSchema(propertyContext as PropertyContext<StringProperty>);\n } else if (property.type === \"number\") {\n return getZodNumberSchema(propertyContext as PropertyContext<NumberProperty>);\n } else if (property.type === \"boolean\") {\n return getZodBooleanSchema(propertyContext as PropertyContext<BooleanProperty>);\n } else if (property.type === \"map\") {\n return getZodMapObjectSchema(propertyContext as PropertyContext<MapProperty>);\n } else if (property.type === \"array\") {\n return getZodArraySchema(propertyContext as PropertyContext<ArrayProperty>);\n } else if (property.type === \"date\") {\n return getZodDateSchema(propertyContext as PropertyContext<DateProperty>);\n } else if (property.type === \"geopoint\") {\n return getZodGeoPointSchema(propertyContext as PropertyContext<GeopointProperty>);\n } else if (property.type === \"reference\") {\n return getZodReferenceSchema(propertyContext as PropertyContext<ReferenceProperty>);\n } else if (property.type === \"relation\") {\n return getZodRelationSchema(propertyContext as PropertyContext<RelationProperty>);\n } else if (property.type === \"vector\") {\n return getZodVectorSchema(propertyContext as PropertyContext<VectorProperty>);\n } else if (property.type === \"binary\") {\n return getZodBinarySchema(propertyContext as PropertyContext<BinaryProperty>);\n }\n\n // Log the error but don't crash the form\n console.error(\"Unsupported data type in zod mapping\", property);\n const dataType = \"dataType\" in (property as Record<string, unknown>) ? String((property as Record<string, unknown>).dataType) : \"unknown\";\n return z.any().refine(\n () => false,\n { message: `Unsupported data type: ${dataType}` }\n );\n}\n\n\nexport function getZodMapObjectSchema({\n property,\n entityId,\n customFieldValidator,\n name\n}: PropertyContext<MapProperty>): ZodTypeAny {\n const shape: Record<string, ZodTypeAny> = {};\n const validation = property.validation;\n if (property.properties)\n Object.entries(property.properties).forEach(([childName, childProperty]) => {\n const typedChildProperty = childProperty as Readonly<Property>;\n try {\n shape[childName] = mapPropertyToZod({\n property: typedChildProperty,\n parentProperty: property as MapProperty,\n customFieldValidator,\n name: `${name}[${childName}]`,\n entityId\n });\n } catch (e: unknown) {\n console.error(`Error creating validation schema for property ${childName}:`, e);\n shape[childName] = z.any().refine(\n () => false,\n { message: `Validation error: ${e instanceof Error ? e.message : \"Unknown error\"}` }\n );\n }\n });\n\n let schema: ZodTypeAny = z.object(shape).passthrough();\n if (validation?.required) {\n schema = schema.nullable().optional().refine(\n (value) => value !== undefined,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n } else {\n schema = schema.nullable().optional();\n }\n return schema;\n}\n\nfunction getZodStringSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<StringProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.string().nullable().optional();\n const validation = property.validation;\n\n const isRequired = validation?.required || property.isId === true || property.isId === \"manual\";\n\n if (property.enum) {\n if (isRequired) {\n schema = z.string().nullable().optional().refine(\n (value) => value !== undefined && value !== null && value !== \"\",\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n const entries = enumToObjectEntries(property.enum);\n const allowedValues = (isRequired ? entries : [...entries, null])\n .map((enumValueConfig) => enumValueConfig?.id ?? null);\n schema = schema.refine(\n (value: unknown) => allowedValues.includes(value as string | null),\n { message: `Must be one of: ${allowedValues.filter(Boolean).join(\", \")}` }\n );\n }\n\n if (isRequired && !property.enum) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null && value !== \"\",\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n if (validation) {\n\n if (validation.min || validation.min === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && value.length >= validation.min!),\n { message: `${fieldLabel(property, name)} must be min ${validation.min} characters long` }\n );\n if (validation.max || validation.max === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && value.length <= validation.max!),\n { message: `${fieldLabel(property, name)} must be max ${validation.max} characters long` }\n );\n if (validation.matches) {\n const regExp = toMatchesPattern(validation.matches);\n if (regExp) {\n schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && regExp.test(value)),\n { message: validation.matchesMessage ?? \"Invalid format\" }\n );\n }\n }\n if (validation.length !== undefined) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && value.length === validation.length),\n { message: `${fieldLabel(property, name)} must be exactly ${validation.length} characters long` }\n );\n if (validation.trim || validation.lowercase || validation.uppercase) schema = z.preprocess(\n (v: unknown) => typeof v === \"string\" ? transformString(v, validation) : v,\n schema\n );\n }\n\n // Checked the way the server checks them: on every string that declares\n // them, `validation` block or not, and with the empty string let through —\n // it is what a cleared text field holds, and whether the field may be\n // empty is `required`'s question.\n if (property.email) schema = schema.refine(\n (value: unknown) => value == null || value === \"\" || (typeof value === \"string\" && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value)),\n { message: `${fieldLabel(property, name)} must be an email` }\n );\n if (property.url) {\n if (!property.storage || property.storage?.storeUrl) {\n schema = schema.refine(\n (value: unknown) => {\n if (value == null || value === \"\") return true;\n try {\n new URL(value as string);\n return true;\n } catch {\n return false;\n }\n },\n { message: `${fieldLabel(property, name)} must be a url` }\n );\n } else {\n console.warn(`Property ${fieldLabel(property, name)} has a url validation but its storage configuration is not set to store urls`);\n }\n }\n return schema;\n}\n\n/**\n * `validation.matches` as a regex that answers the same for the same value\n * every time. A `g` or `y` regex keeps `lastIndex` between `test` calls, so a\n * value it accepted once it refused on the next validation; the flags are\n * dropped, as the server's write validation drops them.\n */\nfunction toMatchesPattern(matches: string | RegExp): RegExp | undefined {\n const regExp = typeof matches === \"string\" ? hydrateRegExp(matches) : matches;\n if (!regExp) return undefined;\n return regExp.global || regExp.sticky ? new RegExp(regExp.source, regExp.flags.replace(/[gy]/g, \"\")) : regExp;\n}\n\n/**\n * A string's declared transforms — `trim`, `lowercase`, `uppercase` — applied.\n * The one definition of them: validation judges its result, and\n * {@link applyValueTransforms} writes it.\n */\nfunction transformString(value: string, validation: StringPropertyValidationSchema): string {\n let result = value;\n if (validation.trim) result = result.trim();\n if (validation.lowercase) result = result.toLowerCase();\n if (validation.uppercase) result = result.toUpperCase();\n return result;\n}\n\n/**\n * The values as they are to be written: every `trim`, `lowercase` and\n * `uppercase` a string property declares applied to its value, inside maps and\n * arrays too.\n *\n * They are documented as changing the value that is written, and only the\n * panel applies them — the server checks what it receives. Validation judges\n * the transformed value, so without this the form passed \"my-slug\" and sent\n * \" My-Slug \", which a `matches` on the server then refused.\n *\n * Returns `values` itself when nothing changes.\n */\nexport function applyValueTransforms<M extends Record<string, unknown>>(values: M, properties: Properties): M {\n let result: M = values;\n for (const [key, property] of Object.entries(properties)) {\n if (!(key in values)) continue;\n const transformed = transformValue(property, values[key]);\n if (transformed !== values[key]) {\n result = { ...result, [key]: transformed };\n }\n }\n return result;\n}\n\nfunction transformValue(property: Property, value: unknown): unknown {\n if (!property || typeof property !== \"object\") return value;\n if (property.type === \"string\") {\n return typeof value === \"string\" && property.validation\n ? transformString(value, property.validation)\n : value;\n }\n if (property.type === \"map\" && property.properties && isPlainObject(value)) {\n return applyValueTransforms(value, property.properties);\n }\n if (property.type === \"array\" && property.of && Array.isArray(value)) {\n const of = property.of;\n const items = value.map((item, index) => {\n const itemProperty = Array.isArray(of) ? of[index] : of;\n return itemProperty ? transformValue(itemProperty, item) : item;\n });\n return items.some((item, index) => item !== value[index]) ? items : value;\n }\n return value;\n}\n\nfunction getZodNumberSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<NumberProperty>): ZodTypeAny {\n const validation = property.validation;\n // Accept number or null, coerce non-numbers to fail\n let schema: ZodTypeAny = z.preprocess(\n (val) => {\n if (val === null || val === undefined) return null;\n if (typeof val === \"number\") return val;\n const n = Number(val);\n return isNaN(n) ? val : n; // pass through non-numeric to let refine catch it\n },\n z.number({ error: \"Must be a number\" }).nullable()\n );\n\n const isRequired = validation?.required || property.isId === true || property.isId === \"manual\";\n\n if (isRequired) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n if (validation) {\n\n if (validation.min || validation.min === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value >= validation.min!),\n { message: `${fieldLabel(property, name)} must be higher or equal to ${validation.min}` }\n );\n if (validation.max || validation.max === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value <= validation.max!),\n { message: `${fieldLabel(property, name)} must be lower or equal to ${validation.max}` }\n );\n if (validation.lessThan || validation.lessThan === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value < validation.lessThan!),\n { message: `${fieldLabel(property, name)} must be lower than ${validation.lessThan}` }\n );\n if (validation.moreThan || validation.moreThan === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value > validation.moreThan!),\n { message: `${fieldLabel(property, name)} must be higher than ${validation.moreThan}` }\n );\n if (validation.positive) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value > 0),\n { message: `${fieldLabel(property, name)} must be positive` }\n );\n if (validation.negative) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value < 0),\n { message: `${fieldLabel(property, name)} must be negative` }\n );\n }\n // An integer column takes a whole number whether or not the property says\n // `validation.integer`; without it, a fraction reached Postgres and came\n // back as `Invalid data format` naming no field.\n if (validation?.integer || isIntegerColumn(property.columnType)) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && Number.isInteger(value)),\n { message: `${fieldLabel(property, name)} must be an integer` }\n );\n return schema;\n}\n\nfunction getZodGeoPointSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<GeopointProperty>): ZodTypeAny {\n // The field marks a coordinate off the globe in red; the schema has to\n // refuse it too, or Save wrote latitude 200 under the red message.\n // A `GeoPoint` instance or a plain `{ latitude, longitude }`.\n const coordinate = (value: unknown, axis: \"latitude\" | \"longitude\"): number | undefined => {\n if (typeof value !== \"object\" || value === null) return undefined;\n const n = (value as Record<string, unknown>)[axis];\n return typeof n === \"number\" ? n : undefined;\n };\n let schema: ZodTypeAny = z.object({}).passthrough().nullable().optional()\n .refine(\n (value: unknown) => Math.abs(coordinate(value, \"latitude\") ?? 0) <= 90,\n { message: \"Latitude must be between -90 and 90\" }\n )\n .refine(\n (value: unknown) => Math.abs(coordinate(value, \"longitude\") ?? 0) <= 180,\n { message: \"Longitude must be between -180 and 180\" }\n );\n const validation = property.validation;\n\n if (validation?.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n return schema;\n}\n\nfunction getZodDateSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<DateProperty>): ZodTypeAny {\n if (property.autoValue) {\n return z.date().nullable().optional();\n }\n // Accept Date objects and null, reject everything else\n let schema: ZodTypeAny = z.custom<Date | null | undefined>(\n (v) => v === null || v === undefined || v instanceof Date,\n { message: \"Expected a Date\" }\n ).optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n // Both bounds are inclusive, and the message says so: it said \"after\"\n // the bound, which the bound itself is not, and printed the bound with\n // `Date.toString()` (\"Wed Jan 01 2020 01:00:00 GMT+0100 (…)\").\n if (validation.min) schema = schema.refine(\n (value: unknown) => value == null || (value instanceof Date && value >= validation.min!),\n { message: `${fieldLabel(property, name)} must not be before ${formatDateBound(validation.min, property.columnType)}` }\n );\n if (validation.max) schema = schema.refine(\n (value: unknown) => value == null || (value instanceof Date && value <= validation.max!),\n { message: `${fieldLabel(property, name)} must not be after ${formatDateBound(validation.max, property.columnType)}` }\n );\n }\n return schema;\n}\n\nfunction getZodReferenceSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<ReferenceProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.object({}).passthrough().nullable().optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n }\n return schema;\n}\n\nfunction getZodRelationSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<RelationProperty>): ZodTypeAny {\n const isMany = relationCardinality(property.relation) === \"many\";\n let schema: ZodTypeAny = isMany\n ? z.array(z.object({}).passthrough()).nullable().optional()\n : z.object({}).passthrough().nullable().optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => {\n if (isMany) {\n return value !== undefined && value !== null && Array.isArray(value) && value.length > 0;\n }\n return value !== undefined && value !== null;\n },\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n }\n return schema;\n}\n\nfunction getZodBooleanSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<BooleanProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.boolean().nullable().optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n }\n return schema;\n}\n\n/** The Postgres number column types that hold whole numbers only. */\nfunction isIntegerColumn(columnType: string | undefined): boolean {\n return columnType === \"integer\" || columnType === \"bigint\" || columnType === \"serial\" || columnType === \"bigserial\";\n}\n\n/** A date bound as a reader writes it: the day for a date column, else an ISO instant. */\nfunction formatDateBound(bound: Date, columnType: string | undefined): string {\n const date = bound instanceof Date ? bound : new Date(bound);\n if (Number.isNaN(date.getTime())) return String(bound);\n return columnType === \"date\" ? date.toISOString().slice(0, 10) : date.toISOString();\n}\n\n/**\n * What `uniqueInArray` compares an item by. Relations and references are\n * objects built per read, so comparing them by identity never found the same\n * row linked twice; they compare by the row they point at.\n */\nfunction uniqueInArrayKey(value: unknown): unknown {\n if (value instanceof Date) return `date:${value.getTime()}`;\n if (typeof value === \"object\" && value !== null && \"id\" in value) {\n const { id, path } = value as { id?: unknown; path?: unknown };\n if (typeof id === \"string\" || typeof id === \"number\") return `row:${typeof path === \"string\" ? path : \"\"}:${String(id)}`;\n }\n return value;\n}\n\nfunction hasUniqueInArrayModifier(property: Property): boolean | [string, Property][] {\n if (property.validation?.uniqueInArray) {\n return true;\n } else if (property.type === \"map\" && property.properties) {\n return Object.entries(property.properties)\n .filter(([key, childProperty]) => (childProperty as Readonly<Property>).validation?.uniqueInArray) as [string, Property][];\n }\n return false;\n}\n\nfunction getZodArraySchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<ArrayProperty>): ZodTypeAny {\n\n let arraySchema: ZodTypeAny = z.array(z.any()).nullable().optional();\n\n if (!property.of && property.oneOf?.properties) {\n // Blocks: each item is `{ [typeField]: key, [valueField]: value }`, and\n // its value answers to `oneOf.properties[key]`, as an `of` item answers\n // to `of`. The error lands on `blocks.<i>.<valueField>`, which is the\n // key the block's inner field is bound to.\n const typeField = property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE;\n const valueField = property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE;\n const blockProperties = property.oneOf.properties as Record<string, Property>;\n const blockSchemas = new Map<string, ZodTypeAny>();\n const schemaFor = (type: string): ZodTypeAny | undefined => {\n if (!Object.prototype.hasOwnProperty.call(blockProperties, type)) return undefined;\n const blockProperty = blockProperties[type];\n if (!blockProperty || isPropertyBuilder(blockProperty)) return undefined;\n let schema = blockSchemas.get(type);\n if (!schema) {\n schema = mapPropertyToZod({ property: blockProperty, parentProperty: property, entityId, name: type });\n blockSchemas.set(type, schema);\n }\n return schema;\n };\n arraySchema = z.array(z.any()).superRefine(async (items, ctx) => {\n for (let index = 0; index < items.length; index++) {\n const item: unknown = items[index];\n if (!isPlainObject(item)) continue;\n const type = (item as Record<string, unknown>)[typeField];\n if (typeof type !== \"string\") continue;\n const schema = schemaFor(type);\n if (!schema) continue;\n const result = await schema.safeParseAsync((item as Record<string, unknown>)[valueField]);\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n ctx.addIssue({\n code: \"custom\",\n message: issue.message,\n path: [index, valueField, ...issue.path]\n });\n });\n }\n }\n }).nullable().optional();\n }\n\n if (property.of) {\n if (Array.isArray(property.of)) {\n // One property per position: the value is a tuple, and item `i`\n // answers to `of[i]` alone. Checked against every position, a\n // mixed tuple failed its own declaration and could never be saved.\n const positionSchemas: ZodTypeAny[] = (property.of as Property[]).map((p, index) => {\n try {\n return mapPropertyToZod({\n property: p as Property,\n parentProperty: property,\n entityId\n });\n } catch (e: unknown) {\n console.error(`Error creating validation schema for array item ${index}:`, e);\n return z.any().refine(\n () => false,\n { message: `Validation error: ${e instanceof Error ? e.message : \"Unknown error\"}` }\n );\n }\n });\n arraySchema = z.array(z.any()).superRefine(async (items, ctx) => {\n for (let index = 0; index < items.length && index < positionSchemas.length; index++) {\n const result = await positionSchemas[index].safeParseAsync(items[index]);\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n ctx.addIssue({\n code: \"custom\",\n message: issue.message,\n path: [index, ...issue.path]\n });\n });\n }\n }\n }).nullable().optional();\n } else {\n try {\n const ofSchema = mapPropertyToZod({\n property: property.of,\n parentProperty: property,\n entityId\n });\n arraySchema = z.array(ofSchema).nullable().optional();\n } catch (e: unknown) {\n console.error(\"Error creating validation schema for array of property:\", e);\n arraySchema = z.array(z.any().refine(\n () => false,\n { message: `Validation error: ${e instanceof Error ? e.message : \"Unknown error\"}` }\n )).nullable().optional();\n }\n const arrayUniqueFields = hasUniqueInArrayModifier(property.of);\n if (arrayUniqueFields) {\n if (typeof arrayUniqueFields === \"boolean\") {\n arraySchema = arraySchema.refine(\n (values: unknown) => !values || !Array.isArray(values) || values.length === new Set(values.map(uniqueInArrayKey)).size,\n { message: `${fieldLabel(property, name)} should have unique values within the array` }\n );\n } else if (Array.isArray(arrayUniqueFields)) {\n arrayUniqueFields.forEach(([fieldName, childProperty]) => {\n arraySchema = arraySchema.refine(\n (values: unknown) => !values || !Array.isArray(values) || values.length === new Set(values.map((v: unknown) => uniqueInArrayKey(v && typeof v === \"object\" ? (v as Record<string, unknown>)[fieldName] : v))).size,\n { message: `${fieldLabel(property, name)} → ${childProperty.name ?? fieldName}: should have unique values within the array` }\n );\n });\n }\n }\n }\n }\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n arraySchema = arraySchema.refine(\n (value: unknown) => value !== undefined && value !== null && Array.isArray(value) && value.length > 0,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n if (validation.min || validation.min === 0) arraySchema = arraySchema.refine(\n (value: unknown) => !value || !Array.isArray(value) || value.length >= validation.min!,\n { message: `${fieldLabel(property, name)} should be min ${validation.min} entries long` }\n );\n if (validation.max) arraySchema = arraySchema.refine(\n (value: unknown) => !value || !Array.isArray(value) || value.length <= validation.max!,\n { message: `${fieldLabel(property, name)} should be max ${validation.max} entries long` }\n );\n // Handle uniqueInArray at the array level\n if (validation.uniqueInArray) {\n arraySchema = arraySchema.refine(\n (values: unknown) => !values || !Array.isArray(values) || values.length === new Set(values.map(uniqueInArrayKey)).size,\n { message: `${fieldLabel(property, name)} should have unique values within the array` }\n );\n }\n }\n return arraySchema;\n}\n\nfunction getZodVectorSchema({\n property\n}: PropertyContext<VectorProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.preprocess(\n (val: unknown) => {\n if (val && typeof val === \"object\" && \"__type\" in val && (val as Record<string, unknown>).__type === \"Vector\") {\n return (val as Record<string, unknown>).value;\n }\n if (val && typeof val === \"object\" && \"value\" in val && Array.isArray((val as Record<string, unknown>).value)) {\n return (val as Record<string, unknown>).value;\n }\n return val;\n },\n z.array(z.number()).nullable().optional()\n );\n\n if (property.dimensions) {\n schema = schema.refine(\n (val: unknown) => val === null || val === undefined || (Array.isArray(val) && val.length === property.dimensions),\n { message: `${property.name ?? \"Vector\"} must have exactly ${property.dimensions} dimensions` }\n );\n }\n\n if (property.validation?.required) {\n schema = schema.refine(\n (val: unknown) => val !== null && val !== undefined && Array.isArray(val) && val.length > 0,\n { message: property.validation?.requiredMessage ?? \"Required\" }\n );\n }\n\n return schema;\n}\n\nfunction getZodBinarySchema({\n property\n}: PropertyContext<BinaryProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.string().nullable().optional();\n const validation = property.validation;\n\n if (validation?.required) {\n schema = schema.nullable().optional().refine(\n (value: unknown) => value !== undefined && value !== null && value !== \"\",\n { message: validation.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n return schema;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,SAAS,WAAW,UAAoB,MAAuB;CAC3D,OAAO,SAAS,SAAS,OAAO,mBAAmB,IAAI,IAAI;AAC/D;AAEA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;;;;;;;;;;;;;AA+BA,eAAsB,kBAAkB,EACpC,YACA,QACA,cACA,UACA,QACA,aAQgC;CAChC,MAAM,QAAgC,CAAC;CACvC,MAAM,QAAQ,IAAI,OAAO,QAAQ,UAAsC,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,cAAc;EACrG,IAAI,CAAC,UAAU,YAAY,QAAQ;EACnC,IAAI,UAAU,QAAQ,QAAQ;EAC9B,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IAAI;EAC3D,IAAI,gBAAgB,UAAY,OAAO,aAAa,KAAK,GAAG;EAE5D,IAAI,CAAC,MADgB,UAAU;GAAE;GAAM;GAAO;GAAU;EAAS,CAAC,GACrD,MAAM,QAAQ,GAAG,WAAW,UAAU,IAAI,EAAE;CAC7D,CAAC,CAAC;CACF,OAAO;AACX;AAEA,SAAgB,gBACZ,UACA,YACA,sBAAsF;CACtF,MAAM,QAAoC,CAAC;CAC3C,OAAO,QAAQ,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AC4C;CAC5C,IAAI,SAAqB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACxD,MAAM,aAAa,SAAS;CAE5B,IAAI,YAAY,UACZ,SAAS,OAAO,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,QACjC,UAAmB,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IACvE,EAAE,SAAS,WAAW,kBAAkB,WAAW,kBAAkB,WAAW,CACpF;CAEJ,OAAO;AACX"}
1
+ {"version":3,"file":"validation.js","names":[],"sources":["../../src/form/validation.ts"],"sourcesContent":["import type { Properties } from \"@rebasepro/cms-types\";\nimport type { ArrayProperty, MapProperty, NumberProperty, Property, BooleanProperty, DateProperty, GeopointProperty, ReferenceProperty, RelationProperty, StringProperty, StringPropertyValidationSchema, VectorProperty, BinaryProperty } from \"@rebasepro/cms-types\";\n;\nimport { z, ZodTypeAny } from \"zod\";\nimport { deepEqual as isDeepEqual } from \"fast-equals\";\nimport { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE, isPropertyBuilder, enumToObjectEntries } from \"@rebasepro/cms-types\";\nimport { getValueInPath, hydrateRegExp, isPlainObject, prettifyIdentifier } from \"@rebasepro/utils\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\n/**\n * What to call this field in a validation message.\n *\n * `property.name` is the author's label and is optional — a headless project has\n * no panel and no reason to invent display names. Every message here\n * interpolated it directly, so an unnamed property produced\n * \"undefined must be min 3 characters long\" in front of a user.\n *\n * The fallback is the field's own key, prettified the same way the panel derives\n * a column header, so the message names the field the author would recognise.\n */\nfunction fieldLabel(property: Property, name?: string): string {\n return property.name ?? (name ? prettifyIdentifier(name) : \"This field\");\n}\n\nfunction relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\nexport type CustomFieldValidator = (props: {\n name: string,\n value: unknown,\n property: Property,\n entityId?: string | number,\n parentProperty?: MapProperty | ArrayProperty,\n}) => Promise<boolean>;\n\ninterface PropertyContext<P extends Property> {\n property: P,\n parentProperty?: MapProperty | ArrayProperty,\n entityId?: string | number,\n customFieldValidator?: CustomFieldValidator,\n name?: string\n}\n\n/**\n * `validation.unique`, for the top-level properties that declare it: whether\n * another record already holds the value, asked of the data source through\n * `validator`. One error per field that fails, keyed like the schema's.\n *\n * Asked only for a value worth asking about — set (not empty), changed from\n * `storedValues` when there are any (a value the edit left alone is the stored\n * record's business, and it may predate the rule), and without an error of its\n * own already in `errors` — so a save makes one lookup per unique field it\n * actually changes, and typing makes none: this runs where validation runs, on\n * submit.\n */\nexport async function uniqueValueErrors({\n properties,\n values,\n storedValues,\n entityId,\n errors,\n validator\n}: {\n properties: Properties,\n values: Record<string, unknown>,\n storedValues?: Record<string, unknown>,\n entityId?: string | number,\n errors?: Record<string, unknown>,\n validator: CustomFieldValidator\n}): Promise<Record<string, string>> {\n const found: Record<string, string> = {};\n await Promise.all(Object.entries(properties as Record<string, Property>).map(async ([name, property]) => {\n if (!property?.validation?.unique) return;\n if (errors && name in errors) return;\n const value = values[name];\n if (value === undefined || value === null || value === \"\") return;\n if (storedValues && isDeepEqual(value, storedValues[name])) return;\n const unique = await validator({ name, value, property, entityId });\n if (!unique) found[name] = `${fieldLabel(property, name)} must be unique: another record already has this value`;\n }));\n return found;\n}\n\nexport function getEntitySchema<M extends Record<string, unknown>>(\n entityId: string | number | undefined,\n properties: Properties,\n customFieldValidator?: CustomFieldValidator): z.ZodObject<Record<string, ZodTypeAny>> {\n const shape: Record<string, ZodTypeAny> = {};\n Object.entries(properties as Record<string, Property>)\n .forEach(([name, property]) => {\n const isStringOrNumber = property.type === \"string\" || property.type === \"number\";\n const isIdAndAuto = isStringOrNumber && \"isId\" in property && typeof property.isId === \"string\" && property.isId !== \"manual\";\n if (entityId === undefined && isIdAndAuto) {\n return; // Skip validation for auto-generated IDs on new entities\n }\n shape[name] = mapPropertyToZod({\n property: property as Property,\n customFieldValidator,\n name,\n entityId\n });\n });\n return z.object(shape).passthrough();\n}\n\n\nexport function mapPropertyToZod(propertyContext: PropertyContext<Property>): ZodTypeAny {\n\n const property = propertyContext.property;\n if (isPropertyBuilder(property) && !property.type) {\n console.error(\"Error in property\", propertyContext);\n // Return a schema that always fails\n return z.any().refine(\n () => false,\n { message: \"Invalid property configuration: property builder should be resolved\" }\n );\n }\n\n if (property.type === \"string\") {\n return getZodStringSchema(propertyContext as PropertyContext<StringProperty>);\n } else if (property.type === \"number\") {\n return getZodNumberSchema(propertyContext as PropertyContext<NumberProperty>);\n } else if (property.type === \"boolean\") {\n return getZodBooleanSchema(propertyContext as PropertyContext<BooleanProperty>);\n } else if (property.type === \"map\") {\n return getZodMapObjectSchema(propertyContext as PropertyContext<MapProperty>);\n } else if (property.type === \"array\") {\n return getZodArraySchema(propertyContext as PropertyContext<ArrayProperty>);\n } else if (property.type === \"date\") {\n return getZodDateSchema(propertyContext as PropertyContext<DateProperty>);\n } else if (property.type === \"geopoint\") {\n return getZodGeoPointSchema(propertyContext as PropertyContext<GeopointProperty>);\n } else if (property.type === \"reference\") {\n return getZodReferenceSchema(propertyContext as PropertyContext<ReferenceProperty>);\n } else if (property.type === \"relation\") {\n return getZodRelationSchema(propertyContext as PropertyContext<RelationProperty>);\n } else if (property.type === \"vector\") {\n return getZodVectorSchema(propertyContext as PropertyContext<VectorProperty>);\n } else if (property.type === \"binary\") {\n return getZodBinarySchema(propertyContext as PropertyContext<BinaryProperty>);\n }\n\n // Log the error but don't crash the form\n console.error(\"Unsupported data type in zod mapping\", property);\n const dataType = \"dataType\" in (property as Record<string, unknown>) ? String((property as Record<string, unknown>).dataType) : \"unknown\";\n return z.any().refine(\n () => false,\n { message: `Unsupported data type: ${dataType}` }\n );\n}\n\n\nexport function getZodMapObjectSchema({\n property,\n entityId,\n customFieldValidator,\n name\n}: PropertyContext<MapProperty>): ZodTypeAny {\n const shape: Record<string, ZodTypeAny> = {};\n const validation = property.validation;\n if (property.properties)\n Object.entries(property.properties).forEach(([childName, childProperty]) => {\n const typedChildProperty = childProperty as Readonly<Property>;\n try {\n shape[childName] = mapPropertyToZod({\n property: typedChildProperty,\n parentProperty: property as MapProperty,\n customFieldValidator,\n name: `${name}[${childName}]`,\n entityId\n });\n } catch (e: unknown) {\n console.error(`Error creating validation schema for property ${childName}:`, e);\n shape[childName] = z.any().refine(\n () => false,\n { message: `Validation error: ${e instanceof Error ? e.message : \"Unknown error\"}` }\n );\n }\n });\n\n let schema: ZodTypeAny = z.object(shape).passthrough();\n if (validation?.required) {\n schema = schema.nullable().optional().refine(\n (value) => value !== undefined,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n } else {\n schema = schema.nullable().optional();\n }\n return schema;\n}\n\nfunction getZodStringSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<StringProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.string().nullable().optional();\n const validation = property.validation;\n\n const isRequired = validation?.required || property.isId === true || property.isId === \"manual\";\n\n if (property.enum) {\n if (isRequired) {\n schema = z.string().nullable().optional().refine(\n (value) => value !== undefined && value !== null && value !== \"\",\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n const entries = enumToObjectEntries(property.enum);\n const allowedValues = (isRequired ? entries : [...entries, null])\n .map((enumValueConfig) => enumValueConfig?.id ?? null);\n schema = schema.refine(\n (value: unknown) => allowedValues.includes(value as string | null),\n { message: `Must be one of: ${allowedValues.filter(Boolean).join(\", \")}` }\n );\n }\n\n if (isRequired && !property.enum) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null && value !== \"\",\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n if (validation) {\n\n if (validation.min || validation.min === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && value.length >= validation.min!),\n { message: `${fieldLabel(property, name)} must be min ${validation.min} characters long` }\n );\n if (validation.max || validation.max === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && value.length <= validation.max!),\n { message: `${fieldLabel(property, name)} must be max ${validation.max} characters long` }\n );\n if (validation.matches) {\n const regExp = toMatchesPattern(validation.matches);\n if (regExp) {\n schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && regExp.test(value)),\n { message: validation.matchesMessage ?? \"Invalid format\" }\n );\n }\n }\n if (validation.length !== undefined) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"string\" && value.length === validation.length),\n { message: `${fieldLabel(property, name)} must be exactly ${validation.length} characters long` }\n );\n if (validation.trim || validation.lowercase || validation.uppercase) schema = z.preprocess(\n (v: unknown) => typeof v === \"string\" ? transformString(v, validation) : v,\n schema\n );\n }\n\n // Checked the way the server checks them: on every string that declares\n // them, `validation` block or not, and with the empty string let through —\n // it is what a cleared text field holds, and whether the field may be\n // empty is `required`'s question.\n if (property.email) schema = schema.refine(\n (value: unknown) => value == null || value === \"\" || (typeof value === \"string\" && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value)),\n { message: `${fieldLabel(property, name)} must be an email` }\n );\n if (property.url) {\n if (!property.storage || property.storage?.storeUrl) {\n schema = schema.refine(\n (value: unknown) => {\n if (value == null || value === \"\") return true;\n try {\n new URL(value as string);\n return true;\n } catch {\n return false;\n }\n },\n { message: `${fieldLabel(property, name)} must be a url` }\n );\n } else {\n console.warn(`Property ${fieldLabel(property, name)} has a url validation but its storage configuration is not set to store urls`);\n }\n }\n return schema;\n}\n\n/**\n * `validation.matches` as a regex that answers the same for the same value\n * every time. A `g` or `y` regex keeps `lastIndex` between `test` calls, so a\n * value it accepted once it refused on the next validation; the flags are\n * dropped, as the server's write validation drops them.\n */\nfunction toMatchesPattern(matches: string | RegExp): RegExp | undefined {\n const regExp = typeof matches === \"string\" ? hydrateRegExp(matches) : matches;\n if (!regExp) return undefined;\n return regExp.global || regExp.sticky ? new RegExp(regExp.source, regExp.flags.replace(/[gy]/g, \"\")) : regExp;\n}\n\n/**\n * A string's declared transforms — `trim`, `lowercase`, `uppercase` — applied.\n * The one definition of them: validation judges its result, and\n * {@link applyValueTransforms} writes it.\n */\nfunction transformString(value: string, validation: StringPropertyValidationSchema): string {\n let result = value;\n if (validation.trim) result = result.trim();\n if (validation.lowercase) result = result.toLowerCase();\n if (validation.uppercase) result = result.toUpperCase();\n return result;\n}\n\n/**\n * The values as they are to be written: every `trim`, `lowercase` and\n * `uppercase` a string property declares applied to its value, inside maps and\n * arrays too.\n *\n * They are documented as changing the value that is written, and only the\n * panel applies them — the server checks what it receives. Validation judges\n * the transformed value, so without this the form passed \"my-slug\" and sent\n * \" My-Slug \", which a `matches` on the server then refused.\n *\n * Returns `values` itself when nothing changes.\n */\nexport function applyValueTransforms<M extends Record<string, unknown>>(values: M, properties: Properties): M {\n let result: M = values;\n for (const [key, property] of Object.entries(properties)) {\n if (!(key in values)) continue;\n const transformed = transformValue(property, values[key]);\n if (transformed !== values[key]) {\n result = { ...result, [key]: transformed };\n }\n }\n return result;\n}\n\nfunction transformValue(property: Property, value: unknown): unknown {\n if (!property || typeof property !== \"object\") return value;\n if (property.type === \"string\") {\n return typeof value === \"string\" && property.validation\n ? transformString(value, property.validation)\n : value;\n }\n if (property.type === \"map\" && property.properties && isPlainObject(value)) {\n return applyValueTransforms(value, property.properties);\n }\n if (property.type === \"array\" && property.of && Array.isArray(value)) {\n const of = property.of;\n const items = value.map((item, index) => {\n const itemProperty = Array.isArray(of) ? of[index] : of;\n return itemProperty ? transformValue(itemProperty, item) : item;\n });\n return items.some((item, index) => item !== value[index]) ? items : value;\n }\n return value;\n}\n\nfunction getZodNumberSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<NumberProperty>): ZodTypeAny {\n const validation = property.validation;\n // Accept number or null, coerce non-numbers to fail\n let schema: ZodTypeAny = z.preprocess(\n (val) => {\n if (val === null || val === undefined) return null;\n if (typeof val === \"number\") return val;\n const n = Number(val);\n return isNaN(n) ? val : n; // pass through non-numeric to let refine catch it\n },\n z.number({ error: \"Must be a number\" }).nullable()\n );\n\n const isRequired = validation?.required || property.isId === true || property.isId === \"manual\";\n\n if (isRequired) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n if (validation) {\n\n if (validation.min || validation.min === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value >= validation.min!),\n { message: `${fieldLabel(property, name)} must be higher or equal to ${validation.min}` }\n );\n if (validation.max || validation.max === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value <= validation.max!),\n { message: `${fieldLabel(property, name)} must be lower or equal to ${validation.max}` }\n );\n if (validation.lessThan || validation.lessThan === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value < validation.lessThan!),\n { message: `${fieldLabel(property, name)} must be lower than ${validation.lessThan}` }\n );\n if (validation.moreThan || validation.moreThan === 0) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value > validation.moreThan!),\n { message: `${fieldLabel(property, name)} must be higher than ${validation.moreThan}` }\n );\n if (validation.positive) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value > 0),\n { message: `${fieldLabel(property, name)} must be positive` }\n );\n if (validation.negative) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && value < 0),\n { message: `${fieldLabel(property, name)} must be negative` }\n );\n }\n // An integer column takes a whole number whether or not the property says\n // `validation.integer`; without it, a fraction reached Postgres and came\n // back as `Invalid data format` naming no field.\n if (validation?.integer || isIntegerColumn(property.columnType)) schema = schema.refine(\n (value: unknown) => value == null || (typeof value === \"number\" && Number.isInteger(value)),\n { message: `${fieldLabel(property, name)} must be an integer` }\n );\n return schema;\n}\n\nfunction getZodGeoPointSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<GeopointProperty>): ZodTypeAny {\n // The field marks a coordinate off the globe in red; the schema has to\n // refuse it too, or Save wrote latitude 200 under the red message.\n // A `GeoPoint` instance or a plain `{ latitude, longitude }`.\n const coordinate = (value: unknown, axis: \"latitude\" | \"longitude\"): number | undefined => {\n if (typeof value !== \"object\" || value === null) return undefined;\n const n = (value as Record<string, unknown>)[axis];\n return typeof n === \"number\" ? n : undefined;\n };\n let schema: ZodTypeAny = z.object({}).passthrough().nullable().optional()\n .refine(\n (value: unknown) => Math.abs(coordinate(value, \"latitude\") ?? 0) <= 90,\n { message: \"Latitude must be between -90 and 90\" }\n )\n .refine(\n (value: unknown) => Math.abs(coordinate(value, \"longitude\") ?? 0) <= 180,\n { message: \"Longitude must be between -180 and 180\" }\n );\n const validation = property.validation;\n\n if (validation?.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n return schema;\n}\n\nfunction getZodDateSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<DateProperty>): ZodTypeAny {\n if (property.autoValue) {\n return z.date().nullable().optional();\n }\n // Accept Date objects and null, reject everything else\n let schema: ZodTypeAny = z.custom<Date | null | undefined>(\n (v) => v === null || v === undefined || v instanceof Date,\n { message: \"Expected a Date\" }\n ).optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n // Both bounds are inclusive, and the message says so: it said \"after\"\n // the bound, which the bound itself is not, and printed the bound with\n // `Date.toString()` (\"Wed Jan 01 2020 01:00:00 GMT+0100 (…)\").\n if (validation.min) schema = schema.refine(\n (value: unknown) => value == null || (value instanceof Date && value >= validation.min!),\n { message: `${fieldLabel(property, name)} must not be before ${formatDateBound(validation.min, property.columnType)}` }\n );\n if (validation.max) schema = schema.refine(\n (value: unknown) => value == null || (value instanceof Date && value <= validation.max!),\n { message: `${fieldLabel(property, name)} must not be after ${formatDateBound(validation.max, property.columnType)}` }\n );\n }\n return schema;\n}\n\nfunction getZodReferenceSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<ReferenceProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.object({}).passthrough().nullable().optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n }\n return schema;\n}\n\nfunction getZodRelationSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<RelationProperty>): ZodTypeAny {\n const isMany = relationCardinality(property.relation) === \"many\";\n let schema: ZodTypeAny = isMany\n ? z.array(z.object({}).passthrough()).nullable().optional()\n : z.object({}).passthrough().nullable().optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => {\n if (isMany) {\n return value !== undefined && value !== null && Array.isArray(value) && value.length > 0;\n }\n return value !== undefined && value !== null;\n },\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n }\n return schema;\n}\n\nfunction getZodBooleanSchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<BooleanProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.boolean().nullable().optional();\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n schema = schema.refine(\n (value: unknown) => value !== undefined && value !== null,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n\n }\n return schema;\n}\n\n/** The Postgres number column types that hold whole numbers only. */\nfunction isIntegerColumn(columnType: string | undefined): boolean {\n return columnType === \"integer\" || columnType === \"bigint\" || columnType === \"serial\" || columnType === \"bigserial\";\n}\n\n/** A date bound as a reader writes it: the day for a date column, else an ISO instant. */\nfunction formatDateBound(bound: Date, columnType: string | undefined): string {\n const date = bound instanceof Date ? bound : new Date(bound);\n if (Number.isNaN(date.getTime())) return String(bound);\n return columnType === \"date\" ? date.toISOString().slice(0, 10) : date.toISOString();\n}\n\n/**\n * What `uniqueInArray` compares an item by. Relations and references are\n * objects built per read, so comparing them by identity never found the same\n * row linked twice; they compare by the row they point at.\n */\nfunction uniqueInArrayKey(value: unknown): unknown {\n if (value instanceof Date) return `date:${value.getTime()}`;\n if (typeof value === \"object\" && value !== null && \"id\" in value) {\n const { id, path } = value as { id?: unknown; path?: unknown };\n if (typeof id === \"string\" || typeof id === \"number\") return `row:${typeof path === \"string\" ? path : \"\"}:${String(id)}`;\n }\n return value;\n}\n\nfunction hasUniqueInArrayModifier(property: Property): boolean | [string, Property][] {\n if (property.validation?.uniqueInArray) {\n return true;\n } else if (property.type === \"map\" && property.properties) {\n return Object.entries(property.properties)\n .filter(([key, childProperty]) => (childProperty as Readonly<Property>).validation?.uniqueInArray) as [string, Property][];\n }\n return false;\n}\n\nfunction getZodArraySchema({\n property,\n parentProperty,\n customFieldValidator,\n name,\n entityId\n}: PropertyContext<ArrayProperty>): ZodTypeAny {\n\n let arraySchema: ZodTypeAny = z.array(z.any()).nullable().optional();\n\n if (!property.of && property.oneOf?.properties) {\n // Blocks: each item is `{ [typeField]: key, [valueField]: value }`, and\n // its value answers to `oneOf.properties[key]`, as an `of` item answers\n // to `of`. The error lands on `blocks.<i>.<valueField>`, which is the\n // key the block's inner field is bound to.\n const typeField = property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE;\n const valueField = property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE;\n const blockProperties = property.oneOf.properties as Record<string, Property>;\n const blockSchemas = new Map<string, ZodTypeAny>();\n const schemaFor = (type: string): ZodTypeAny | undefined => {\n if (!Object.prototype.hasOwnProperty.call(blockProperties, type)) return undefined;\n const blockProperty = blockProperties[type];\n if (!blockProperty || isPropertyBuilder(blockProperty)) return undefined;\n let schema = blockSchemas.get(type);\n if (!schema) {\n schema = mapPropertyToZod({ property: blockProperty, parentProperty: property, entityId, name: type });\n blockSchemas.set(type, schema);\n }\n return schema;\n };\n arraySchema = z.array(z.any()).superRefine(async (items, ctx) => {\n for (let index = 0; index < items.length; index++) {\n const item: unknown = items[index];\n if (!isPlainObject(item)) continue;\n const type = (item as Record<string, unknown>)[typeField];\n if (typeof type !== \"string\") continue;\n const schema = schemaFor(type);\n if (!schema) continue;\n const result = await schema.safeParseAsync((item as Record<string, unknown>)[valueField]);\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n ctx.addIssue({\n code: \"custom\",\n message: issue.message,\n path: [index, valueField, ...issue.path]\n });\n });\n }\n }\n }).nullable().optional();\n }\n\n if (property.of) {\n if (Array.isArray(property.of)) {\n // One property per position: the value is a tuple, and item `i`\n // answers to `of[i]` alone. Checked against every position, a\n // mixed tuple failed its own declaration and could never be saved.\n const positionSchemas: ZodTypeAny[] = (property.of as Property[]).map((p, index) => {\n try {\n return mapPropertyToZod({\n property: p as Property,\n parentProperty: property,\n entityId\n });\n } catch (e: unknown) {\n console.error(`Error creating validation schema for array item ${index}:`, e);\n return z.any().refine(\n () => false,\n { message: `Validation error: ${e instanceof Error ? e.message : \"Unknown error\"}` }\n );\n }\n });\n arraySchema = z.array(z.any()).superRefine(async (items, ctx) => {\n for (let index = 0; index < items.length && index < positionSchemas.length; index++) {\n const result = await positionSchemas[index].safeParseAsync(items[index]);\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n ctx.addIssue({\n code: \"custom\",\n message: issue.message,\n path: [index, ...issue.path]\n });\n });\n }\n }\n }).nullable().optional();\n } else {\n try {\n const ofSchema = mapPropertyToZod({\n property: property.of,\n parentProperty: property,\n entityId\n });\n arraySchema = z.array(ofSchema).nullable().optional();\n } catch (e: unknown) {\n console.error(\"Error creating validation schema for array of property:\", e);\n arraySchema = z.array(z.any().refine(\n () => false,\n { message: `Validation error: ${e instanceof Error ? e.message : \"Unknown error\"}` }\n )).nullable().optional();\n }\n const arrayUniqueFields = hasUniqueInArrayModifier(property.of);\n if (arrayUniqueFields) {\n if (typeof arrayUniqueFields === \"boolean\") {\n arraySchema = arraySchema.refine(\n (values: unknown) => !values || !Array.isArray(values) || values.length === new Set(values.map(uniqueInArrayKey)).size,\n { message: `${fieldLabel(property, name)} should have unique values within the array` }\n );\n } else if (Array.isArray(arrayUniqueFields)) {\n arrayUniqueFields.forEach(([fieldName, childProperty]) => {\n arraySchema = arraySchema.refine(\n (values: unknown) => !values || !Array.isArray(values) || values.length === new Set(values.map((v: unknown) => uniqueInArrayKey(v && typeof v === \"object\" ? (v as Record<string, unknown>)[fieldName] : v))).size,\n { message: `${fieldLabel(property, name)} → ${childProperty.name ?? fieldName}: should have unique values within the array` }\n );\n });\n }\n }\n }\n }\n const validation = property.validation;\n\n if (validation) {\n if (validation.required) {\n arraySchema = arraySchema.refine(\n (value: unknown) => value !== undefined && value !== null && Array.isArray(value) && value.length > 0,\n { message: validation?.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n if (validation.min || validation.min === 0) arraySchema = arraySchema.refine(\n (value: unknown) => !value || !Array.isArray(value) || value.length >= validation.min!,\n { message: `${fieldLabel(property, name)} should be min ${validation.min} entries long` }\n );\n if (validation.max) arraySchema = arraySchema.refine(\n (value: unknown) => !value || !Array.isArray(value) || value.length <= validation.max!,\n { message: `${fieldLabel(property, name)} should be max ${validation.max} entries long` }\n );\n // Handle uniqueInArray at the array level\n if (validation.uniqueInArray) {\n arraySchema = arraySchema.refine(\n (values: unknown) => !values || !Array.isArray(values) || values.length === new Set(values.map(uniqueInArrayKey)).size,\n { message: `${fieldLabel(property, name)} should have unique values within the array` }\n );\n }\n }\n return arraySchema;\n}\n\nfunction getZodVectorSchema({\n property\n}: PropertyContext<VectorProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.preprocess(\n (val: unknown) => {\n if (val && typeof val === \"object\" && \"__type\" in val && (val as Record<string, unknown>).__type === \"Vector\") {\n return (val as Record<string, unknown>).value;\n }\n if (val && typeof val === \"object\" && \"value\" in val && Array.isArray((val as Record<string, unknown>).value)) {\n return (val as Record<string, unknown>).value;\n }\n return val;\n },\n z.array(z.number()).nullable().optional()\n );\n\n if (property.dimensions) {\n schema = schema.refine(\n (val: unknown) => val === null || val === undefined || (Array.isArray(val) && val.length === property.dimensions),\n { message: `${property.name ?? \"Vector\"} must have exactly ${property.dimensions} dimensions` }\n );\n }\n\n if (property.validation?.required) {\n schema = schema.refine(\n (val: unknown) => val !== null && val !== undefined && Array.isArray(val) && val.length > 0,\n { message: property.validation?.requiredMessage ?? \"Required\" }\n );\n }\n\n return schema;\n}\n\nfunction getZodBinarySchema({\n property\n}: PropertyContext<BinaryProperty>): ZodTypeAny {\n let schema: ZodTypeAny = z.string().nullable().optional();\n const validation = property.validation;\n\n if (validation?.required) {\n schema = schema.nullable().optional().refine(\n (value: unknown) => value !== undefined && value !== null && value !== \"\",\n { message: validation.requiredMessage ? validation.requiredMessage : \"Required\" }\n );\n }\n return schema;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,SAAS,WAAW,UAAoB,MAAuB;CAC3D,OAAO,SAAS,SAAS,OAAO,mBAAmB,IAAI,IAAI;AAC/D;AAEA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;;;;;;;;;;;;;AA+BA,eAAsB,kBAAkB,EACpC,YACA,QACA,cACA,UACA,QACA,aAQgC;CAChC,MAAM,QAAgC,CAAC;CACvC,MAAM,QAAQ,IAAI,OAAO,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AAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAC5C;CAEA,IAAI,SAAS,YACT,SAAS,OAAO,QACX,QAAiB,QAAQ,QAAQ,QAAQ,KAAA,KAAc,MAAM,QAAQ,GAAG,KAAK,IAAI,WAAW,SAAS,YACtG,EAAE,SAAS,GAAG,SAAS,QAAQ,SAAS,qBAAqB,SAAS,WAAW,aAAa,CAClG;CAGJ,IAAI,SAAS,YAAY,UACrB,SAAS,OAAO,QACX,QAAiB,QAAQ,QAAQ,QAAQ,KAAA,KAAa,MAAM,QAAQ,GAAG,KAAK,IAAI,SAAS,GAC1F,EAAE,SAAS,SAAS,YAAY,mBAAmB,WAAW,CAClE;CAGJ,OAAO;AACX;AAEA,SAAS,mBAAmB,EACxB,YAC4C;CAC5C,IAAI,SAAqB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACxD,MAAM,aAAa,SAAS;CAE5B,IAAI,YAAY,UACZ,SAAS,OAAO,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,QACjC,UAAmB,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IACvE,EAAE,SAAS,WAAW,kBAAkB,WAAW,kBAAkB,WAAW,CACpF;CAEJ,OAAO;AACX"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * What `<RebaseCMS>` registers: the tables the server serves, projected and
3
+ * customized, beside the collections whose rows live elsewhere (Firestore).
4
+ *
5
+ * ## The composition order
6
+ *
7
+ * A served table's collection is built in layers, each over the one before:
8
+ *
9
+ * 1. **the projected table** — `GET /api/schema/tables`, through the
10
+ * projector: every column, relation and rule, with zero configuration;
11
+ * 2. **code customizations** — `<RebaseCMS tableCustomizations>`, the
12
+ * `customizeTable(...)` results written in the frontend (components,
13
+ * actions, callbacks: everything that is code);
14
+ * 3. **workspace preferences** — what the collection editor saved for
15
+ * everybody: `<RebaseCMS uiConfig>` (`frontend/src/cms/ui-config.json`,
16
+ * shipped with the frontend), then the preferences the server stores for
17
+ * the workspace;
18
+ * 4. **user preferences** — what the views remember for the signed-in user
19
+ * (column widths, order, view mode), folded in by the collection registry
20
+ * when a view resolves its collection (`useBuildCollectionRegistryController`).
21
+ *
22
+ * Layers 3 and 4 are data (`UiTablePreferences`): never a schema fact, never
23
+ * code.
24
+ */
25
+ import type { AdminCollection, TableCustomization } from "@rebasepro/cms-types";
26
+ import type { TableDescriptor, UiPreferences } from "@rebasepro/types";
27
+ import { type TableCollection } from "../../tables/apply_customization.js";
28
+ /** What the composition produces: a served table's collection, or an external one. */
29
+ export type PanelCollection = TableCollection | AdminCollection;
30
+ /** What {@link composeCollections} combines. */
31
+ export interface CollectionSources {
32
+ /** The tables the server serves the caller. */
33
+ tables: readonly TableDescriptor[];
34
+ /** `<RebaseCMS tableCustomizations>`. */
35
+ tableCustomizations: readonly TableCustomization[];
36
+ /** `<RebaseCMS externalCollections>`. */
37
+ externalCollections: readonly AdminCollection[];
38
+ /** `<RebaseCMS uiConfig>`: the workspace's preferences shipped with the frontend, as imported (validated here). */
39
+ uiConfig?: {
40
+ tables?: {
41
+ [slug: string]: object;
42
+ };
43
+ };
44
+ /** The workspace's preferences the server stores. */
45
+ workspacePreferences?: UiPreferences;
46
+ }
47
+ /**
48
+ * The collections the panel registers, in navigation order: the served tables,
49
+ * then the external ones.
50
+ *
51
+ * - **Tables**: every served table projected (`collectionsFromTables`), with
52
+ * its `customizeTable` folded in (`applyTableCustomizations`), then the
53
+ * workspace's preferences (see "The composition order" above).
54
+ * - **External collections never share a slug.** One with the slug of a
55
+ * served table or of another external collection throws, naming both: a
56
+ * slug is a URL, a saved layout and a reference target, and two collections
57
+ * cannot answer to one.
58
+ */
59
+ export declare function composeCollections({ tables, tableCustomizations, externalCollections, uiConfig, workspacePreferences }: CollectionSources): PanelCollection[];
@@ -0,0 +1,48 @@
1
+ import { applyTableCustomizations } from "../../tables/apply_customization.js";
2
+ import { collectionsFromTables } from "../../tables/project_table.js";
3
+ import { applyUiPreferences, uiConfigPreferences } from "./ui_preferences.js";
4
+ import { registeredCollection } from "./registered_collection.js";
5
+ //#region src/hooks/navigation/compose_collections.ts
6
+ function describe(collection) {
7
+ const name = collection.name && collection.name !== collection.slug ? ` ("${collection.name}")` : "";
8
+ return `"${collection.slug}"${name}`;
9
+ }
10
+ /**
11
+ * The collections the panel registers, in navigation order: the served tables,
12
+ * then the external ones.
13
+ *
14
+ * - **Tables**: every served table projected (`collectionsFromTables`), with
15
+ * its `customizeTable` folded in (`applyTableCustomizations`), then the
16
+ * workspace's preferences (see "The composition order" above).
17
+ * - **External collections never share a slug.** One with the slug of a
18
+ * served table or of another external collection throws, naming both: a
19
+ * slug is a URL, a saved layout and a reference target, and two collections
20
+ * cannot answer to one.
21
+ */
22
+ function composeCollections({ tables, tableCustomizations, externalCollections, uiConfig, workspacePreferences }) {
23
+ const shipped = uiConfigPreferences(uiConfig);
24
+ const composedBySlug = /* @__PURE__ */ new Map();
25
+ const targetCollection = (slug) => {
26
+ const composed = composedBySlug.get(slug);
27
+ return composed ? registeredCollection(composed) : void 0;
28
+ };
29
+ const projected = tables.length > 0 || tableCustomizations.length > 0 ? applyTableCustomizations(collectionsFromTables(tables, { targetCollection }), tableCustomizations).map((collection) => applyUiPreferences(collection, shipped.tables[collection.slug])).map((collection) => applyUiPreferences(collection, workspacePreferences?.tables[collection.slug])).map((collection, index) => tables[index]?.kind === "table" && tables[index].rls.defaultPolicies === false ? {
30
+ ...collection,
31
+ disableDefaultPolicies: true
32
+ } : collection) : [];
33
+ for (const collection of projected) composedBySlug.set(collection.slug, collection);
34
+ const tableSlugs = new Map(projected.map((collection) => [collection.slug, collection]));
35
+ const external = /* @__PURE__ */ new Map();
36
+ for (const collection of externalCollections) {
37
+ const table = tableSlugs.get(collection.slug);
38
+ if (table) throw new Error(`externalCollections: ${describe(collection)} has the slug of the table ${describe(table)} the server serves. Give the external collection another slug: a slug names one collection only.`);
39
+ const twin = external.get(collection.slug);
40
+ if (twin) throw new Error(`externalCollections: ${describe(twin)} and ${describe(collection)} have the same slug. Give one of them another slug: a slug names one collection only.`);
41
+ external.set(collection.slug, collection);
42
+ }
43
+ return [...projected, ...external.values()];
44
+ }
45
+ //#endregion
46
+ export { composeCollections };
47
+
48
+ //# sourceMappingURL=compose_collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose_collections.js","names":[],"sources":["../../../src/hooks/navigation/compose_collections.ts"],"sourcesContent":["/**\n * What `<RebaseCMS>` registers: the tables the server serves, projected and\n * customized, beside the collections whose rows live elsewhere (Firestore).\n *\n * ## The composition order\n *\n * A served table's collection is built in layers, each over the one before:\n *\n * 1. **the projected table** — `GET /api/schema/tables`, through the\n * projector: every column, relation and rule, with zero configuration;\n * 2. **code customizations** — `<RebaseCMS tableCustomizations>`, the\n * `customizeTable(...)` results written in the frontend (components,\n * actions, callbacks: everything that is code);\n * 3. **workspace preferences** — what the collection editor saved for\n * everybody: `<RebaseCMS uiConfig>` (`frontend/src/cms/ui-config.json`,\n * shipped with the frontend), then the preferences the server stores for\n * the workspace;\n * 4. **user preferences** — what the views remember for the signed-in user\n * (column widths, order, view mode), folded in by the collection registry\n * when a view resolves its collection (`useBuildCollectionRegistryController`).\n *\n * Layers 3 and 4 are data (`UiTablePreferences`): never a schema fact, never\n * code.\n */\nimport type { AdminCollection, TableCustomization } from \"@rebasepro/cms-types\";\nimport type { TableDescriptor, UiPreferences } from \"@rebasepro/types\";\nimport { collectionsFromTables } from \"../../tables/project_table\";\nimport { applyTableCustomizations, type TableCollection } from \"../../tables/apply_customization\";\nimport { applyUiPreferences, uiConfigPreferences } from \"./ui_preferences\";\nimport { registeredCollection } from \"./registered_collection\";\n\n/** What the composition produces: a served table's collection, or an external one. */\nexport type PanelCollection = TableCollection | AdminCollection;\n\n/** What {@link composeCollections} combines. */\nexport interface CollectionSources {\n /** The tables the server serves the caller. */\n tables: readonly TableDescriptor[];\n /** `<RebaseCMS tableCustomizations>`. */\n tableCustomizations: readonly TableCustomization[];\n /** `<RebaseCMS externalCollections>`. */\n externalCollections: readonly AdminCollection[];\n /** `<RebaseCMS uiConfig>`: the workspace's preferences shipped with the frontend, as imported (validated here). */\n uiConfig?: { tables?: { [slug: string]: object } };\n /** The workspace's preferences the server stores. */\n workspacePreferences?: UiPreferences;\n}\n\nfunction describe(collection: PanelCollection): string {\n const name = collection.name && collection.name !== collection.slug ? ` (\"${collection.name}\")` : \"\";\n return `\"${collection.slug}\"${name}`;\n}\n\n/**\n * The collections the panel registers, in navigation order: the served tables,\n * then the external ones.\n *\n * - **Tables**: every served table projected (`collectionsFromTables`), with\n * its `customizeTable` folded in (`applyTableCustomizations`), then the\n * workspace's preferences (see \"The composition order\" above).\n * - **External collections never share a slug.** One with the slug of a\n * served table or of another external collection throws, naming both: a\n * slug is a URL, a saved layout and a reference target, and two collections\n * cannot answer to one.\n */\nexport function composeCollections({ tables, tableCustomizations, externalCollections, uiConfig, workspacePreferences }: CollectionSources): PanelCollection[] {\n const shipped = uiConfigPreferences(uiConfig);\n // A relation opens its target as the panel registers it, not as it was\n // projected: the target's `customizeTable` (`hideFromEntityViews`, its\n // display, its columns) is what a tab, a picker or a preview of it must\n // read, as they read an authored collection's `target: () => other`. The\n // thunks are called after the composition below has filled this map, and\n // hand out the collection as the registry holds it (`registeredCollection`).\n const composedBySlug = new Map<string, TableCollection>();\n const targetCollection = (slug: string): AdminCollection | undefined => {\n const composed = composedBySlug.get(slug);\n return composed ? registeredCollection(composed) : undefined;\n };\n const projected = tables.length > 0 || tableCustomizations.length > 0\n ? applyTableCustomizations(collectionsFromTables(tables, { targetCollection }), tableCustomizations)\n .map(collection => applyUiPreferences(collection, shipped.tables[collection.slug]))\n .map(collection => applyUiPreferences(collection, workspacePreferences?.tables[collection.slug]))\n .map((collection, index) =>\n // The projected rules are already the effective ones. A table that\n // switches the admin baseline off says so here too, so the editors\n // that list what Postgres holds (`getEffectiveSecurityRulesOnce`)\n // do not offer the baseline it does not have.\n tables[index]?.kind === \"table\" && tables[index].rls.defaultPolicies === false\n ? { ...collection, disableDefaultPolicies: true }\n : collection)\n : [];\n\n for (const collection of projected) composedBySlug.set(collection.slug, collection);\n const tableSlugs = new Map(projected.map(collection => [collection.slug, collection]));\n\n const external = new Map<string, AdminCollection>();\n for (const collection of externalCollections) {\n const table = tableSlugs.get(collection.slug);\n if (table) {\n throw new Error(\n `externalCollections: ${describe(collection)} has the slug of the table ${describe(table)} the server serves. ` +\n \"Give the external collection another slug: a slug names one collection only.\"\n );\n }\n const twin = external.get(collection.slug);\n if (twin) {\n throw new Error(\n `externalCollections: ${describe(twin)} and ${describe(collection)} have the same slug. ` +\n \"Give one of them another slug: a slug names one collection only.\"\n );\n }\n external.set(collection.slug, collection);\n }\n\n return [...projected, ...external.values()];\n}\n"],"mappings":";;;;;AAgDA,SAAS,SAAS,YAAqC;CACnD,MAAM,OAAO,WAAW,QAAQ,WAAW,SAAS,WAAW,OAAO,MAAM,WAAW,KAAK,MAAM;CAClG,OAAO,IAAI,WAAW,KAAK,GAAG;AAClC;;;;;;;;;;;;;AAcA,SAAgB,mBAAmB,EAAE,QAAQ,qBAAqB,qBAAqB,UAAU,wBAA8D;CAC3J,MAAM,UAAU,oBAAoB,QAAQ;CAO5C,MAAM,iCAAiB,IAAI,IAA6B;CACxD,MAAM,oBAAoB,SAA8C;EACpE,MAAM,WAAW,eAAe,IAAI,IAAI;EACxC,OAAO,WAAW,qBAAqB,QAAQ,IAAI,KAAA;CACvD;CACA,MAAM,YAAY,OAAO,SAAS,KAAK,oBAAoB,SAAS,IAC9D,yBAAyB,sBAAsB,QAAQ,EAAE,iBAAiB,CAAC,GAAG,mBAAmB,CAAC,CAC/F,KAAI,eAAc,mBAAmB,YAAY,QAAQ,OAAO,WAAW,KAAK,CAAC,CAAC,CAClF,KAAI,eAAc,mBAAmB,YAAY,sBAAsB,OAAO,WAAW,KAAK,CAAC,CAAC,CAChG,KAAK,YAAY,UAKlB,OAAO,MAAM,EAAE,SAAS,WAAW,OAAO,MAAM,CAAC,IAAI,oBAAoB,QACnE;EAAE,GAAG;EAAY,wBAAwB;CAAK,IAC9C,UAAU,IAClB,CAAC;CAEP,KAAK,MAAM,cAAc,WAAW,eAAe,IAAI,WAAW,MAAM,UAAU;CAClF,MAAM,aAAa,IAAI,IAAI,UAAU,KAAI,eAAc,CAAC,WAAW,MAAM,UAAU,CAAC,CAAC;CAErF,MAAM,2BAAW,IAAI,IAA6B;CAClD,KAAK,MAAM,cAAc,qBAAqB;EAC1C,MAAM,QAAQ,WAAW,IAAI,WAAW,IAAI;EAC5C,IAAI,OACA,MAAM,IAAI,MACN,wBAAwB,SAAS,UAAU,EAAE,6BAA6B,SAAS,KAAK,EAAE,iGAE9F;EAEJ,MAAM,OAAO,SAAS,IAAI,WAAW,IAAI;EACzC,IAAI,MACA,MAAM,IAAI,MACN,wBAAwB,SAAS,IAAI,EAAE,OAAO,SAAS,UAAU,EAAE,sFAEvE;EAEJ,SAAS,IAAI,WAAW,MAAM,UAAU;CAC5C;CAEA,OAAO,CAAC,GAAG,WAAW,GAAG,SAAS,OAAO,CAAC;AAC9C"}
@@ -0,0 +1,8 @@
1
+ import type { CollectionConfigsBuilder } from "@rebasepro/cms-types";
2
+ import type { CollectionSources } from "./compose_collections.js";
3
+ /**
4
+ * `composeCollections` as the builder the navigation resolves, so a slug
5
+ * collision becomes the navigation's loading error, shown with what collided,
6
+ * rather than a crash of the whole panel.
7
+ */
8
+ export declare function composeCollectionsInput(sources: CollectionSources): CollectionConfigsBuilder;
@@ -0,0 +1,17 @@
1
+ import { registeredCollection } from "./registered_collection.js";
2
+ //#region src/hooks/navigation/compose_collections_input.ts
3
+ /**
4
+ * `composeCollections` as the builder the navigation resolves, so a slug
5
+ * collision becomes the navigation's loading error, shown with what collided,
6
+ * rather than a crash of the whole panel.
7
+ */
8
+ function composeCollectionsInput(sources) {
9
+ return async () => {
10
+ const { composeCollections } = await import("./compose_collections.js");
11
+ return composeCollections(sources).map(registeredCollection);
12
+ };
13
+ }
14
+ //#endregion
15
+ export { composeCollectionsInput };
16
+
17
+ //# sourceMappingURL=compose_collections_input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose_collections_input.js","names":[],"sources":["../../../src/hooks/navigation/compose_collections_input.ts"],"sourcesContent":["import type { CollectionConfigsBuilder } from \"@rebasepro/cms-types\";\nimport type { CollectionSources } from \"./compose_collections\";\nimport { registeredCollection } from \"./registered_collection\";\n\n/**\n * `composeCollections` as the builder the navigation resolves, so a slug\n * collision becomes the navigation's loading error, shown with what collided,\n * rather than a crash of the whole panel.\n */\nexport function composeCollectionsInput(sources: CollectionSources): CollectionConfigsBuilder {\n return async () => {\n // Loaded with the first resolution rather than with the shell: the\n // projector and the customization merge are not needed to paint the\n // login screen.\n const { composeCollections } = await import(\"./compose_collections\");\n return composeCollections(sources).map(registeredCollection);\n };\n}\n"],"mappings":";;;;;;;AASA,SAAgB,wBAAwB,SAAsD;CAC1F,OAAO,YAAY;EAIf,MAAM,EAAE,uBAAuB,MAAM,OAAO;EAC5C,OAAO,mBAAmB,OAAO,CAAC,CAAC,IAAI,oBAAoB;CAC/D;AACJ"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { CollectionRegistryController } from "@rebasepro/types";
2
+ import { CollectionRegistryController } from "@rebasepro/cms-types";
3
3
  import type { AdminCollection } from "@rebasepro/cms-types";
4
4
  export declare const CollectionRegistryContext: React.Context<CollectionRegistryController>;
5
5
  export declare function useCollectionRegistryController<DB = Record<string, unknown>, EC extends AdminCollection = AdminCollection>(): CollectionRegistryController<DB, EC>;
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionRegistryContext.js","names":[],"sources":["../../../../src/hooks/navigation/contexts/CollectionRegistryContext.tsx"],"sourcesContent":["\nimport React, { createContext } from \"react\";\nimport { CollectionRegistryController } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport const CollectionRegistryContext = createContext<CollectionRegistryController>({\n getCollection: () => undefined,\n getRawCollection: () => undefined,\n resolveDataPath: (path) => path,\n resolveCollectionPath: (path) => path,\n getParentReferencesFromPath: () => [],\n getParentCollectionSlugs: () => [],\n getParentEntityIds: () => [],\n convertIdsToPaths: () => [],\n initialised: false\n});\n\nexport function useCollectionRegistryController<DB = Record<string, unknown>, EC extends AdminCollection = AdminCollection>(): CollectionRegistryController<DB, EC> {\n const context = React.useContext(CollectionRegistryContext);\n if (context === undefined) {\n throw new Error(\"useCollectionRegistryController must be used within a CollectionRegistryContext.Provider\");\n }\n return context as CollectionRegistryController<DB, EC>;\n}\n"],"mappings":";;AAKA,IAAa,4BAA4B,cAA4C;CACjF,qBAAqB,KAAA;CACrB,wBAAwB,KAAA;CACxB,kBAAkB,SAAS;CAC3B,wBAAwB,SAAS;CACjC,mCAAmC,CAAC;CACpC,gCAAgC,CAAC;CACjC,0BAA0B,CAAC;CAC3B,yBAAyB,CAAC;CAC1B,aAAa;AACjB,CAAC;AAED,SAAgB,kCAAoJ;CAChK,MAAM,UAAU,MAAM,WAAW,yBAAyB;CAC1D,IAAI,YAAY,KAAA,GACZ,MAAM,IAAI,MAAM,0FAA0F;CAE9G,OAAO;AACX"}
1
+ {"version":3,"file":"CollectionRegistryContext.js","names":[],"sources":["../../../../src/hooks/navigation/contexts/CollectionRegistryContext.tsx"],"sourcesContent":["\nimport React, { createContext } from \"react\";\nimport { CollectionRegistryController } from \"@rebasepro/cms-types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport const CollectionRegistryContext = createContext<CollectionRegistryController>({\n getCollection: () => undefined,\n getRawCollection: () => undefined,\n resolveDataPath: (path) => path,\n resolveCollectionPath: (path) => path,\n getParentReferencesFromPath: () => [],\n getParentCollectionSlugs: () => [],\n getParentEntityIds: () => [],\n convertIdsToPaths: () => [],\n initialised: false\n});\n\nexport function useCollectionRegistryController<DB = Record<string, unknown>, EC extends AdminCollection = AdminCollection>(): CollectionRegistryController<DB, EC> {\n const context = React.useContext(CollectionRegistryContext);\n if (context === undefined) {\n throw new Error(\"useCollectionRegistryController must be used within a CollectionRegistryContext.Provider\");\n }\n return context as CollectionRegistryController<DB, EC>;\n}\n"],"mappings":";;AAKA,IAAa,4BAA4B,cAA4C;CACjF,qBAAqB,KAAA;CACrB,wBAAwB,KAAA;CACxB,kBAAkB,SAAS;CAC3B,wBAAwB,SAAS;CACjC,mCAAmC,CAAC;CACpC,gCAAgC,CAAC;CACjC,0BAA0B,CAAC;CAC3B,yBAAyB,CAAC;CAC1B,aAAa;AACjB,CAAC;AAED,SAAgB,kCAAoJ;CAChK,MAAM,UAAU,MAAM,WAAW,yBAAyB;CAC1D,IAAI,YAAY,KAAA,GACZ,MAAM,IAAI,MAAM,0FAA0F;CAE9G,OAAO;AACX"}
@@ -0,0 +1,15 @@
1
+ import type { AdminCollection } from "@rebasepro/cms-types";
2
+ import type { PanelCollection } from "./compose_collections.js";
3
+ /**
4
+ * A collection as the registry holds it.
5
+ *
6
+ * The registry and the plugin hooks are typed by the panel's `AdminCollection`,
7
+ * whose Postgres member takes the backend's `PostgresProperties` — and those
8
+ * admit no top-level `reference`, on purpose, for collections a backend
9
+ * declares. A table's collection may carry one: what `customizeTable`'s
10
+ * `referenceTo` makes of a column holding another collection's ids. The
11
+ * registry, the row codec and every view already handle a reference on a
12
+ * Postgres collection; the type says otherwise until the view-model types move
13
+ * to `@rebasepro/cms-types`. This is the one place that is bridged.
14
+ */
15
+ export declare function registeredCollection(collection: PanelCollection): AdminCollection;
@@ -0,0 +1,20 @@
1
+ //#region src/hooks/navigation/registered_collection.ts
2
+ /**
3
+ * A collection as the registry holds it.
4
+ *
5
+ * The registry and the plugin hooks are typed by the panel's `AdminCollection`,
6
+ * whose Postgres member takes the backend's `PostgresProperties` — and those
7
+ * admit no top-level `reference`, on purpose, for collections a backend
8
+ * declares. A table's collection may carry one: what `customizeTable`'s
9
+ * `referenceTo` makes of a column holding another collection's ids. The
10
+ * registry, the row codec and every view already handle a reference on a
11
+ * Postgres collection; the type says otherwise until the view-model types move
12
+ * to `@rebasepro/cms-types`. This is the one place that is bridged.
13
+ */
14
+ function registeredCollection(collection) {
15
+ return collection;
16
+ }
17
+ //#endregion
18
+ export { registeredCollection };
19
+
20
+ //# sourceMappingURL=registered_collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registered_collection.js","names":[],"sources":["../../../src/hooks/navigation/registered_collection.ts"],"sourcesContent":["import type { AdminCollection } from \"@rebasepro/cms-types\";\nimport type { PanelCollection } from \"./compose_collections\";\n\n/**\n * A collection as the registry holds it.\n *\n * The registry and the plugin hooks are typed by the panel's `AdminCollection`,\n * whose Postgres member takes the backend's `PostgresProperties` — and those\n * admit no top-level `reference`, on purpose, for collections a backend\n * declares. A table's collection may carry one: what `customizeTable`'s\n * `referenceTo` makes of a column holding another collection's ids. The\n * registry, the row codec and every view already handle a reference on a\n * Postgres collection; the type says otherwise until the view-model types move\n * to `@rebasepro/cms-types`. This is the one place that is bridged.\n */\nexport function registeredCollection(collection: PanelCollection): AdminCollection {\n return collection as AdminCollection;\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,qBAAqB,YAA8C;CAC/E,OAAO;AACX"}