@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce

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
@@ -0,0 +1,112 @@
1
+ import { propertyFromColumn } from "./column_property.js";
2
+ import { labelFromIdentifier } from "@rebasepro/utils";
3
+ //#region src/tables/relations.ts
4
+ function pivotProperties(pivot) {
5
+ const properties = {};
6
+ for (const column of pivot) {
7
+ const property = propertyFromColumn(column, { primaryKey: [] });
8
+ if (property) properties[column.key] = property;
9
+ }
10
+ return properties;
11
+ }
12
+ function relationFrom(relation, target) {
13
+ const shared = {
14
+ relationName: relation.name,
15
+ target
16
+ };
17
+ switch (relation.kind) {
18
+ case "belongsTo": return {
19
+ ...shared,
20
+ kind: "belongsTo",
21
+ localKey: relation.localKey,
22
+ index: relation.index,
23
+ ...relation.onDelete ? { onDelete: relation.onDelete } : {},
24
+ ...relation.onUpdate ? { onUpdate: relation.onUpdate } : {}
25
+ };
26
+ case "hasOne": return {
27
+ ...shared,
28
+ kind: "hasOne",
29
+ foreignKeyOnTarget: relation.foreignKey,
30
+ ...relation.sourceKey ? { sourceKey: relation.sourceKey } : {}
31
+ };
32
+ case "hasMany": return {
33
+ ...shared,
34
+ kind: "hasMany",
35
+ foreignKeyOnTarget: relation.foreignKey,
36
+ ...relation.sourceKey ? { sourceKey: relation.sourceKey } : {}
37
+ };
38
+ case "manyToMany": return {
39
+ ...shared,
40
+ kind: "manyToMany",
41
+ through: {
42
+ table: relation.through.table,
43
+ sourceColumn: relation.through.sourceKey,
44
+ targetColumn: relation.through.targetKey,
45
+ properties: pivotProperties(relation.through.pivot)
46
+ },
47
+ ...relation.onDelete ? { onDelete: relation.onDelete } : {}
48
+ };
49
+ case "via": return {
50
+ ...shared,
51
+ kind: "via",
52
+ cardinality: relation.cardinality,
53
+ joinPath: relation.steps.map((step) => ({ ...step }))
54
+ };
55
+ }
56
+ }
57
+ /**
58
+ * The relations of a table the caller can follow, as properties.
59
+ *
60
+ * A relation whose target is not among the tables the caller was served is
61
+ * left out: the panel cannot open a table it does not have. A `belongsTo`
62
+ * then leaves its foreign-key column in place as a plain key field, so the
63
+ * value stays visible and editable. A `belongsTo` whose foreign-key column did
64
+ * not arrive (the caller may not read it) is left out too: there is nothing to
65
+ * pick a row into.
66
+ */
67
+ function projectRelations(table, resolveTarget) {
68
+ const columnsByKey = new Map(table.columns.filter((c) => !c.private).map((c) => [c.key, c]));
69
+ const out = [];
70
+ for (const relation of table.relations) {
71
+ if (!resolveTarget.has(relation.target)) continue;
72
+ const targetSlug = relation.target;
73
+ const target = () => {
74
+ const collection = resolveTarget.get(targetSlug);
75
+ if (!collection) throw new Error(`Relation "${relation.name}" on "${table.slug}" points at "${targetSlug}", which is not among the tables this panel was served.`);
76
+ return collection;
77
+ };
78
+ const property = {
79
+ type: "relation",
80
+ name: labelFromIdentifier(relation.name),
81
+ relation: relationFrom(relation, target)
82
+ };
83
+ if (relation.kind === "belongsTo") {
84
+ const foreignKey = columnsByKey.get(relation.localField);
85
+ if (!foreignKey) continue;
86
+ if (!foreignKey.nullable && !foreignKey.default && !foreignKey.readOnly && !foreignKey.generated) property.validation = { required: true };
87
+ if (foreignKey.description) property.description = foreignKey.description;
88
+ if (foreignKey.access) property.access = {
89
+ ...foreignKey.access.read ? { read: [...foreignKey.access.read] } : {},
90
+ ...foreignKey.access.write ? { write: [...foreignKey.access.write] } : {}
91
+ };
92
+ if (foreignKey.readOnly || foreignKey.generated || foreignKey.stamp) property.admin = { readOnly: true };
93
+ const inKey = table.primaryKey.includes(foreignKey.key);
94
+ out.push({
95
+ key: relation.name,
96
+ property,
97
+ ...inKey ? {} : { replacesColumn: foreignKey.key }
98
+ });
99
+ continue;
100
+ }
101
+ if (relation.kind === "via" && !relation.writable) property.admin = { readOnly: true };
102
+ out.push({
103
+ key: relation.name,
104
+ property
105
+ });
106
+ }
107
+ return out;
108
+ }
109
+ //#endregion
110
+ export { projectRelations };
111
+
112
+ //# sourceMappingURL=relations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations.js","names":[],"sources":["../../src/tables/relations.ts"],"sourcesContent":["/**\n * A table's relations as the panel's relation properties.\n *\n * Each relation becomes a `type: \"relation\"` property keyed by the relation's\n * name — the documented way an authored collection declares one, and the key\n * saved layouts, `include` and the entity tabs address it by. The panel then\n * does what it does for an authored collection: a to-one relation is a\n * reference picker, a to-many one is a tab in the entity view\n * (`getEntityChildViews`), with the redundant picker beside it hidden.\n */\nimport type {\n ColumnDescriptor,\n RelationDescriptor,\n TableDescriptor\n} from \"@rebasepro/types\";\nimport type {\n AnyCollectionConfig,\n Properties,\n Relation,\n RelationProperty\n} from \"@rebasepro/cms-types\";\nimport { labelFromIdentifier } from \"@rebasepro/utils\";\n\nimport { propertyFromColumn } from \"./column_property\";\n\n/**\n * The tables a relation may point at: whether one was served, and the\n * collection it projects to. `has` must not project anything, so a table can\n * point at itself.\n */\nexport interface TargetResolver {\n has(slug: string): boolean;\n get(slug: string): AnyCollectionConfig | undefined;\n}\n\n/**\n * A relation, projected: its property, and — for a `belongsTo` — the key of\n * the foreign-key column it stands in for.\n */\nexport interface ProjectedRelation {\n /** The relation's name: the property key. */\n key: string;\n property: RelationProperty;\n /**\n * The column the relation replaces in the form and the table. Set for a\n * `belongsTo` whose foreign key is not part of the primary key: the picker\n * edits that column, so the raw key is not rendered as a second field.\n */\n replacesColumn?: string;\n}\n\nfunction pivotProperties(pivot: readonly ColumnDescriptor[]): Properties {\n const properties: Properties = {};\n for (const column of pivot) {\n const property = propertyFromColumn(column, { primaryKey: [] });\n if (property) properties[column.key] = property;\n }\n return properties;\n}\n\nfunction relationFrom(relation: RelationDescriptor, target: () => AnyCollectionConfig): Relation {\n const shared = { relationName: relation.name, target };\n switch (relation.kind) {\n case \"belongsTo\":\n return {\n ...shared,\n kind: \"belongsTo\",\n localKey: relation.localKey,\n index: relation.index,\n ...(relation.onDelete ? { onDelete: relation.onDelete } : {}),\n ...(relation.onUpdate ? { onUpdate: relation.onUpdate } : {})\n };\n case \"hasOne\":\n return {\n ...shared,\n kind: \"hasOne\",\n foreignKeyOnTarget: relation.foreignKey,\n ...(relation.sourceKey ? { sourceKey: relation.sourceKey } : {})\n };\n case \"hasMany\":\n return {\n ...shared,\n kind: \"hasMany\",\n foreignKeyOnTarget: relation.foreignKey,\n ...(relation.sourceKey ? { sourceKey: relation.sourceKey } : {})\n };\n case \"manyToMany\":\n return {\n ...shared,\n kind: \"manyToMany\",\n through: {\n table: relation.through.table,\n sourceColumn: relation.through.sourceKey,\n targetColumn: relation.through.targetKey,\n properties: pivotProperties(relation.through.pivot)\n },\n ...(relation.onDelete ? { onDelete: relation.onDelete } : {})\n };\n case \"via\":\n return {\n ...shared,\n kind: \"via\",\n cardinality: relation.cardinality,\n joinPath: relation.steps.map(step => ({ ...step }))\n };\n }\n}\n\n/**\n * The relations of a table the caller can follow, as properties.\n *\n * A relation whose target is not among the tables the caller was served is\n * left out: the panel cannot open a table it does not have. A `belongsTo`\n * then leaves its foreign-key column in place as a plain key field, so the\n * value stays visible and editable. A `belongsTo` whose foreign-key column did\n * not arrive (the caller may not read it) is left out too: there is nothing to\n * pick a row into.\n */\nexport function projectRelations(table: TableDescriptor, resolveTarget: TargetResolver): ProjectedRelation[] {\n const columnsByKey = new Map(table.columns.filter(c => !c.private).map(c => [c.key, c]));\n const out: ProjectedRelation[] = [];\n\n for (const relation of table.relations) {\n if (!resolveTarget.has(relation.target)) continue;\n const targetSlug = relation.target;\n const target = (): AnyCollectionConfig => {\n const collection = resolveTarget.get(targetSlug);\n if (!collection) {\n throw new Error(`Relation \"${relation.name}\" on \"${table.slug}\" points at \"${targetSlug}\", which is not among the tables this panel was served.`);\n }\n return collection;\n };\n\n const property: RelationProperty = {\n type: \"relation\",\n name: labelFromIdentifier(relation.name),\n relation: relationFrom(relation, target)\n };\n\n if (relation.kind === \"belongsTo\") {\n const foreignKey = columnsByKey.get(relation.localField);\n if (!foreignKey) continue;\n const required = !foreignKey.nullable && !foreignKey.default && !foreignKey.readOnly && !foreignKey.generated;\n if (required) property.validation = { required: true };\n if (foreignKey.description) property.description = foreignKey.description;\n if (foreignKey.access) {\n property.access = {\n ...(foreignKey.access.read ? { read: [...foreignKey.access.read] } : {}),\n ...(foreignKey.access.write ? { write: [...foreignKey.access.write] } : {})\n };\n }\n if (foreignKey.readOnly || foreignKey.generated || foreignKey.stamp) property.admin = { readOnly: true };\n const inKey = table.primaryKey.includes(foreignKey.key);\n out.push({ key: relation.name, property, ...(inKey ? {} : { replacesColumn: foreignKey.key }) });\n continue;\n }\n\n if (relation.kind === \"via\" && !relation.writable) property.admin = { readOnly: true };\n out.push({ key: relation.name, property });\n }\n\n return out;\n}\n"],"mappings":";;;AAmDA,SAAS,gBAAgB,OAAgD;CACrE,MAAM,aAAyB,CAAC;CAChC,KAAK,MAAM,UAAU,OAAO;EACxB,MAAM,WAAW,mBAAmB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;EAC9D,IAAI,UAAU,WAAW,OAAO,OAAO;CAC3C;CACA,OAAO;AACX;AAEA,SAAS,aAAa,UAA8B,QAA6C;CAC7F,MAAM,SAAS;EAAE,cAAc,SAAS;EAAM;CAAO;CACrD,QAAQ,SAAS,MAAjB;EACI,KAAK,aACD,OAAO;GACH,GAAG;GACH,MAAM;GACN,UAAU,SAAS;GACnB,OAAO,SAAS;GAChB,GAAI,SAAS,WAAW,EAAE,UAAU,SAAS,SAAS,IAAI,CAAC;GAC3D,GAAI,SAAS,WAAW,EAAE,UAAU,SAAS,SAAS,IAAI,CAAC;EAC/D;EACJ,KAAK,UACD,OAAO;GACH,GAAG;GACH,MAAM;GACN,oBAAoB,SAAS;GAC7B,GAAI,SAAS,YAAY,EAAE,WAAW,SAAS,UAAU,IAAI,CAAC;EAClE;EACJ,KAAK,WACD,OAAO;GACH,GAAG;GACH,MAAM;GACN,oBAAoB,SAAS;GAC7B,GAAI,SAAS,YAAY,EAAE,WAAW,SAAS,UAAU,IAAI,CAAC;EAClE;EACJ,KAAK,cACD,OAAO;GACH,GAAG;GACH,MAAM;GACN,SAAS;IACL,OAAO,SAAS,QAAQ;IACxB,cAAc,SAAS,QAAQ;IAC/B,cAAc,SAAS,QAAQ;IAC/B,YAAY,gBAAgB,SAAS,QAAQ,KAAK;GACtD;GACA,GAAI,SAAS,WAAW,EAAE,UAAU,SAAS,SAAS,IAAI,CAAC;EAC/D;EACJ,KAAK,OACD,OAAO;GACH,GAAG;GACH,MAAM;GACN,aAAa,SAAS;GACtB,UAAU,SAAS,MAAM,KAAI,UAAS,EAAE,GAAG,KAAK,EAAE;EACtD;CACR;AACJ;;;;;;;;;;;AAYA,SAAgB,iBAAiB,OAAwB,eAAoD;CACzG,MAAM,eAAe,IAAI,IAAI,MAAM,QAAQ,QAAO,MAAK,CAAC,EAAE,OAAO,CAAC,CAAC,KAAI,MAAK,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CACvF,MAAM,MAA2B,CAAC;CAElC,KAAK,MAAM,YAAY,MAAM,WAAW;EACpC,IAAI,CAAC,cAAc,IAAI,SAAS,MAAM,GAAG;EACzC,MAAM,aAAa,SAAS;EAC5B,MAAM,eAAoC;GACtC,MAAM,aAAa,cAAc,IAAI,UAAU;GAC/C,IAAI,CAAC,YACD,MAAM,IAAI,MAAM,aAAa,SAAS,KAAK,QAAQ,MAAM,KAAK,eAAe,WAAW,wDAAwD;GAEpJ,OAAO;EACX;EAEA,MAAM,WAA6B;GAC/B,MAAM;GACN,MAAM,oBAAoB,SAAS,IAAI;GACvC,UAAU,aAAa,UAAU,MAAM;EAC3C;EAEA,IAAI,SAAS,SAAS,aAAa;GAC/B,MAAM,aAAa,aAAa,IAAI,SAAS,UAAU;GACvD,IAAI,CAAC,YAAY;GAEjB,IADiB,CAAC,WAAW,YAAY,CAAC,WAAW,WAAW,CAAC,WAAW,YAAY,CAAC,WAAW,WACtF,SAAS,aAAa,EAAE,UAAU,KAAK;GACrD,IAAI,WAAW,aAAa,SAAS,cAAc,WAAW;GAC9D,IAAI,WAAW,QACX,SAAS,SAAS;IACd,GAAI,WAAW,OAAO,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,OAAO,IAAI,EAAE,IAAI,CAAC;IACtE,GAAI,WAAW,OAAO,QAAQ,EAAE,OAAO,CAAC,GAAG,WAAW,OAAO,KAAK,EAAE,IAAI,CAAC;GAC7E;GAEJ,IAAI,WAAW,YAAY,WAAW,aAAa,WAAW,OAAO,SAAS,QAAQ,EAAE,UAAU,KAAK;GACvG,MAAM,QAAQ,MAAM,WAAW,SAAS,WAAW,GAAG;GACtD,IAAI,KAAK;IAAE,KAAK,SAAS;IAAM;IAAU,GAAI,QAAQ,CAAC,IAAI,EAAE,gBAAgB,WAAW,IAAI;GAAG,CAAC;GAC/F;EACJ;EAEA,IAAI,SAAS,SAAS,SAAS,CAAC,SAAS,UAAU,SAAS,QAAQ,EAAE,UAAU,KAAK;EACrF,IAAI,KAAK;GAAE,KAAK,SAAS;GAAM;EAAS,CAAC;CAC7C;CAEA,OAAO;AACX"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A table's row-level security as the rules the panel gates its controls by.
3
+ *
4
+ * The panel hides Create, Edit and Delete through `checkOperation`
5
+ * (`@rebasepro/common`), which reads `securityRules` — and which treats a
6
+ * collection with **no** rules as open to everyone. So the rules projected here
7
+ * are the *effective* ones: what the author declared plus what Rebase injects
8
+ * into Postgres beside them, computed by the same `getEffectiveSecurityRules`
9
+ * the policy generator uses. The panel then hides exactly what the database
10
+ * refuses, and a protected table never projects to an empty list.
11
+ */
12
+ import type { SecurityRule, TableDescriptor } from "@rebasepro/types";
13
+ import type { PostgresProperties } from "@rebasepro/cms-types";
14
+ /** The facts `getEffectiveSecurityRules` reads besides the rules themselves. */
15
+ export interface RlsProjectionBasis {
16
+ /** The projected properties: the auth self-read rule names the id column. */
17
+ properties: PostgresProperties;
18
+ }
19
+ /**
20
+ * The rules the panel evaluates for a table.
21
+ *
22
+ * - a view (`kind: "view"`, `posture: "view"`) → its own read rule, from
23
+ * `view` (see `viewRules`).
24
+ * - `posture: "view"` on a table, which the compiler never emits → one rule
25
+ * that grants nothing.
26
+ * - `posture: "admin-only"` → the injected admin baseline alone: admins may
27
+ * read and write, nobody else may do anything.
28
+ * - `posture: "rules"` → the declared rules, plus the admin baseline unless
29
+ * `defaultPolicies` is `false`.
30
+ * - On top of either, as in Postgres: the auth table's self-read and its
31
+ * restrictive admin write gate, and the tenant table's restrictive tenancy
32
+ * rule.
33
+ * - Rules the server withheld (`redacted: true`) evaluate as "unknown", like
34
+ * any raw rule.
35
+ * - Should all of that come to nothing (a posture the compiler refuses, such as
36
+ * `admin-only` without the baseline), the result is one rule that grants
37
+ * nothing — never an empty list, which the panel reads as open.
38
+ */
39
+ export declare function securityRulesFromRls(table: TableDescriptor, basis: RlsProjectionBasis): SecurityRule[];
@@ -0,0 +1,111 @@
1
+ import { getEffectiveSecurityRules } from "@rebasepro/cms-types";
2
+ import { isRedactedSecurityRule, policy } from "@rebasepro/types";
3
+ //#region src/tables/rls.ts
4
+ /**
5
+ * A rule as the evaluator should read it.
6
+ *
7
+ * The server sends a `RedactedSecurityRule` (`redacted: true`) in place of a
8
+ * rule whose SQL it does not show this caller; the evaluator answers it
9
+ * "unknown", as it answers any raw rule, so it is kept as it is. A rule whose
10
+ * `using` / `withCheck` arrived as something other than SQL text is malformed
11
+ * wire data, and is read as that same marker — its targeting kept, nothing
12
+ * else that could change its meaning — rather than trusted to mean anything.
13
+ */
14
+ function asEvaluated(rule) {
15
+ if (isRedactedSecurityRule(rule)) return rule;
16
+ const malformed = (key) => {
17
+ if (!Object.prototype.hasOwnProperty.call(rule, key)) return false;
18
+ const value = Reflect.get(rule, key);
19
+ return value !== void 0 && typeof value !== "string";
20
+ };
21
+ if (!malformed("using") && !malformed("withCheck")) return rule;
22
+ return {
23
+ redacted: true,
24
+ ...rule.name !== void 0 ? { name: rule.name } : {},
25
+ ...rule.operation !== void 0 ? { operation: rule.operation } : {},
26
+ ...rule.operations !== void 0 ? { operations: rule.operations } : {},
27
+ ...rule.mode !== void 0 ? { mode: rule.mode } : {},
28
+ ...rule.roles !== void 0 ? { roles: rule.roles } : {},
29
+ ...rule.pgRoles !== void 0 ? { pgRoles: rule.pgRoles } : {},
30
+ ...rule.access !== void 0 ? { access: rule.access } : {}
31
+ };
32
+ }
33
+ /**
34
+ * A view's rules. Its `rls` (`posture: "view"`) grants nothing by itself, so
35
+ * it is not read:
36
+ *
37
+ * - a plain view runs `security_invoker`, so the tables it reads decide every
38
+ * row. That cannot be decided here, and is projected as a read rule the
39
+ * evaluator answers "unknown" for — the view is listed, the server decides;
40
+ * - a materialized view is read by the roles it names (`["admin"]` when it
41
+ * names none), as `checkOperation` already enforces from `view.roles`.
42
+ *
43
+ * Writes are refused by `checkOperation` for every view.
44
+ */
45
+ function viewRules(table) {
46
+ if (table.view?.materialized) return [{
47
+ name: `${table.table}_view_read`,
48
+ operations: ["select"],
49
+ roles: table.view.roles ?? ["admin"]
50
+ }];
51
+ return [{
52
+ name: `${table.table}_view_read`,
53
+ operations: ["select"],
54
+ condition: policy.raw("/* security_invoker: decided by the tables the view reads */")
55
+ }];
56
+ }
57
+ /**
58
+ * The rules the panel evaluates for a table.
59
+ *
60
+ * - a view (`kind: "view"`, `posture: "view"`) → its own read rule, from
61
+ * `view` (see `viewRules`).
62
+ * - `posture: "view"` on a table, which the compiler never emits → one rule
63
+ * that grants nothing.
64
+ * - `posture: "admin-only"` → the injected admin baseline alone: admins may
65
+ * read and write, nobody else may do anything.
66
+ * - `posture: "rules"` → the declared rules, plus the admin baseline unless
67
+ * `defaultPolicies` is `false`.
68
+ * - On top of either, as in Postgres: the auth table's self-read and its
69
+ * restrictive admin write gate, and the tenant table's restrictive tenancy
70
+ * rule.
71
+ * - Rules the server withheld (`redacted: true`) evaluate as "unknown", like
72
+ * any raw rule.
73
+ * - Should all of that come to nothing (a posture the compiler refuses, such as
74
+ * `admin-only` without the baseline), the result is one rule that grants
75
+ * nothing — never an empty list, which the panel reads as open.
76
+ */
77
+ function securityRulesFromRls(table, basis) {
78
+ if (table.kind === "view") return viewRules(table);
79
+ if (table.rls.posture === "view") return [closedRule(table)];
80
+ const declared = table.rls.posture === "admin-only" ? [] : table.rls.rules.map(asEvaluated);
81
+ const tenant = table.tenant ? {
82
+ field: table.tenant.field,
83
+ from: table.tenant.from,
84
+ ...table.tenant.bypassRoles ? { bypassRoles: table.tenant.bypassRoles } : {}
85
+ } : void 0;
86
+ const effective = getEffectiveSecurityRules({
87
+ slug: table.slug,
88
+ name: table.name,
89
+ table: table.table,
90
+ schema: table.schema,
91
+ properties: basis.properties,
92
+ securityRules: declared,
93
+ disableDefaultPolicies: !table.rls.defaultPolicies,
94
+ ...table.auth ? { auth: { enabled: true } } : {},
95
+ ...tenant ? { tenant } : {}
96
+ });
97
+ if (effective.length > 0) return effective;
98
+ return [closedRule(table)];
99
+ }
100
+ /** One rule that grants nothing: never an empty list, which the panel reads as open. */
101
+ function closedRule(table) {
102
+ return {
103
+ name: `${table.table}_closed`,
104
+ operations: ["all"],
105
+ condition: policy.false()
106
+ };
107
+ }
108
+ //#endregion
109
+ export { securityRulesFromRls };
110
+
111
+ //# sourceMappingURL=rls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rls.js","names":[],"sources":["../../src/tables/rls.ts"],"sourcesContent":["/**\n * A table's row-level security as the rules the panel gates its controls by.\n *\n * The panel hides Create, Edit and Delete through `checkOperation`\n * (`@rebasepro/common`), which reads `securityRules` — and which treats a\n * collection with **no** rules as open to everyone. So the rules projected here\n * are the *effective* ones: what the author declared plus what Rebase injects\n * into Postgres beside them, computed by the same `getEffectiveSecurityRules`\n * the policy generator uses. The panel then hides exactly what the database\n * refuses, and a protected table never projects to an empty list.\n */\nimport type {\n CollectionTenantConfig,\n RedactedSecurityRule,\n SecurityRule,\n TableDescriptor\n} from \"@rebasepro/types\";\nimport type {\n PostgresCollectionConfig,\n PostgresProperties\n} from \"@rebasepro/cms-types\";\nimport { isRedactedSecurityRule, policy } from \"@rebasepro/types\";\nimport { getEffectiveSecurityRules } from \"@rebasepro/cms-types\";\n\n/**\n * A rule as the evaluator should read it.\n *\n * The server sends a `RedactedSecurityRule` (`redacted: true`) in place of a\n * rule whose SQL it does not show this caller; the evaluator answers it\n * \"unknown\", as it answers any raw rule, so it is kept as it is. A rule whose\n * `using` / `withCheck` arrived as something other than SQL text is malformed\n * wire data, and is read as that same marker — its targeting kept, nothing\n * else that could change its meaning — rather than trusted to mean anything.\n */\nfunction asEvaluated(rule: SecurityRule): SecurityRule {\n if (isRedactedSecurityRule(rule)) return rule;\n const malformed = (key: \"using\" | \"withCheck\"): boolean => {\n if (!Object.prototype.hasOwnProperty.call(rule, key)) return false;\n const value: unknown = Reflect.get(rule, key);\n return value !== undefined && typeof value !== \"string\";\n };\n if (!malformed(\"using\") && !malformed(\"withCheck\")) return rule;\n const marker: RedactedSecurityRule = {\n redacted: true,\n ...(rule.name !== undefined ? { name: rule.name } : {}),\n ...(rule.operation !== undefined ? { operation: rule.operation } : {}),\n ...(rule.operations !== undefined ? { operations: rule.operations } : {}),\n ...(rule.mode !== undefined ? { mode: rule.mode } : {}),\n ...(rule.roles !== undefined ? { roles: rule.roles } : {}),\n ...(rule.pgRoles !== undefined ? { pgRoles: rule.pgRoles } : {}),\n ...(rule.access !== undefined ? { access: rule.access } : {})\n };\n return marker;\n}\n\n/** The facts `getEffectiveSecurityRules` reads besides the rules themselves. */\nexport interface RlsProjectionBasis {\n /** The projected properties: the auth self-read rule names the id column. */\n properties: PostgresProperties;\n}\n\n/**\n * A view's rules. Its `rls` (`posture: \"view\"`) grants nothing by itself, so\n * it is not read:\n *\n * - a plain view runs `security_invoker`, so the tables it reads decide every\n * row. That cannot be decided here, and is projected as a read rule the\n * evaluator answers \"unknown\" for — the view is listed, the server decides;\n * - a materialized view is read by the roles it names (`[\"admin\"]` when it\n * names none), as `checkOperation` already enforces from `view.roles`.\n *\n * Writes are refused by `checkOperation` for every view.\n */\nfunction viewRules(table: TableDescriptor): SecurityRule[] {\n if (table.view?.materialized) {\n return [{ name: `${table.table}_view_read`, operations: [\"select\"], roles: table.view.roles ?? [\"admin\"] }];\n }\n return [{\n name: `${table.table}_view_read`,\n operations: [\"select\"],\n condition: policy.raw(\"/* security_invoker: decided by the tables the view reads */\")\n }];\n}\n\n/**\n * The rules the panel evaluates for a table.\n *\n * - a view (`kind: \"view\"`, `posture: \"view\"`) → its own read rule, from\n * `view` (see `viewRules`).\n * - `posture: \"view\"` on a table, which the compiler never emits → one rule\n * that grants nothing.\n * - `posture: \"admin-only\"` → the injected admin baseline alone: admins may\n * read and write, nobody else may do anything.\n * - `posture: \"rules\"` → the declared rules, plus the admin baseline unless\n * `defaultPolicies` is `false`.\n * - On top of either, as in Postgres: the auth table's self-read and its\n * restrictive admin write gate, and the tenant table's restrictive tenancy\n * rule.\n * - Rules the server withheld (`redacted: true`) evaluate as \"unknown\", like\n * any raw rule.\n * - Should all of that come to nothing (a posture the compiler refuses, such as\n * `admin-only` without the baseline), the result is one rule that grants\n * nothing — never an empty list, which the panel reads as open.\n */\nexport function securityRulesFromRls(table: TableDescriptor, basis: RlsProjectionBasis): SecurityRule[] {\n if (table.kind === \"view\") return viewRules(table);\n if (table.rls.posture === \"view\") return [closedRule(table)];\n\n const declared = table.rls.posture === \"admin-only\" ? [] : table.rls.rules.map(asEvaluated);\n const tenant: CollectionTenantConfig | undefined = table.tenant\n ? {\n field: table.tenant.field,\n from: table.tenant.from,\n ...(table.tenant.bypassRoles ? { bypassRoles: table.tenant.bypassRoles } : {})\n }\n : undefined;\n\n const collection: PostgresCollectionConfig = {\n slug: table.slug,\n name: table.name,\n table: table.table,\n schema: table.schema,\n properties: basis.properties,\n securityRules: declared,\n disableDefaultPolicies: !table.rls.defaultPolicies,\n ...(table.auth ? { auth: { enabled: true } } : {}),\n ...(tenant ? { tenant } : {})\n };\n\n const effective = getEffectiveSecurityRules(collection);\n if (effective.length > 0) return effective;\n return [closedRule(table)];\n}\n\n/** One rule that grants nothing: never an empty list, which the panel reads as open. */\nfunction closedRule(table: TableDescriptor): SecurityRule {\n return { name: `${table.table}_closed`, operations: [\"all\"], condition: policy.false() };\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,SAAS,YAAY,MAAkC;CACnD,IAAI,uBAAuB,IAAI,GAAG,OAAO;CACzC,MAAM,aAAa,QAAwC;EACvD,IAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,GAAG,GAAG,OAAO;EAC7D,MAAM,QAAiB,QAAQ,IAAI,MAAM,GAAG;EAC5C,OAAO,UAAU,KAAA,KAAa,OAAO,UAAU;CACnD;CACA,IAAI,CAAC,UAAU,OAAO,KAAK,CAAC,UAAU,WAAW,GAAG,OAAO;CAW3D,OAAO;EATH,UAAU;EACV,GAAI,KAAK,SAAS,KAAA,IAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;EACrD,GAAI,KAAK,cAAc,KAAA,IAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;EACpE,GAAI,KAAK,eAAe,KAAA,IAAY,EAAE,YAAY,KAAK,WAAW,IAAI,CAAC;EACvE,GAAI,KAAK,SAAS,KAAA,IAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;EACrD,GAAI,KAAK,UAAU,KAAA,IAAY,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;EACxD,GAAI,KAAK,YAAY,KAAA,IAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;EAC9D,GAAI,KAAK,WAAW,KAAA,IAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;CAExD;AACX;;;;;;;;;;;;;AAoBA,SAAS,UAAU,OAAwC;CACvD,IAAI,MAAM,MAAM,cACZ,OAAO,CAAC;EAAE,MAAM,GAAG,MAAM,MAAM;EAAa,YAAY,CAAC,QAAQ;EAAG,OAAO,MAAM,KAAK,SAAS,CAAC,OAAO;CAAE,CAAC;CAE9G,OAAO,CAAC;EACJ,MAAM,GAAG,MAAM,MAAM;EACrB,YAAY,CAAC,QAAQ;EACrB,WAAW,OAAO,IAAI,8DAA8D;CACxF,CAAC;AACL;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,qBAAqB,OAAwB,OAA2C;CACpG,IAAI,MAAM,SAAS,QAAQ,OAAO,UAAU,KAAK;CACjD,IAAI,MAAM,IAAI,YAAY,QAAQ,OAAO,CAAC,WAAW,KAAK,CAAC;CAE3D,MAAM,WAAW,MAAM,IAAI,YAAY,eAAe,CAAC,IAAI,MAAM,IAAI,MAAM,IAAI,WAAW;CAC1F,MAAM,SAA6C,MAAM,SACnD;EACE,OAAO,MAAM,OAAO;EACpB,MAAM,MAAM,OAAO;EACnB,GAAI,MAAM,OAAO,cAAc,EAAE,aAAa,MAAM,OAAO,YAAY,IAAI,CAAC;CAChF,IACE,KAAA;CAcN,MAAM,YAAY,0BAA0B;EAXxC,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,YAAY,MAAM;EAClB,eAAe;EACf,wBAAwB,CAAC,MAAM,IAAI;EACnC,GAAI,MAAM,OAAO,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,IAAI,CAAC;EAChD,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAGa,CAAU;CACtD,IAAI,UAAU,SAAS,GAAG,OAAO;CACjC,OAAO,CAAC,WAAW,KAAK,CAAC;AAC7B;;AAGA,SAAS,WAAW,OAAsC;CACtD,OAAO;EAAE,MAAM,GAAG,MAAM,MAAM;EAAU,YAAY,CAAC,KAAK;EAAG,WAAW,OAAO,MAAM;CAAE;AAC3F"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `updateRecord`: the write an entity action most often makes.
3
+ */
4
+ import type { CustomizableTable, RebaseContext, TableUpdate } from "@rebasepro/cms-types";
5
+ /**
6
+ * Writes `patch` onto one record through the panel's data layer, then says so.
7
+ *
8
+ * The write goes through `context.data`, so it is the same request the form
9
+ * would make — the server's hooks and row-level security apply — and every
10
+ * view of the table refreshes. `message`, when given, is shown as a success
11
+ * snackbar. A failed write throws, and the action that called it reports it.
12
+ *
13
+ * Takes what an entity action's `onClick` receives as-is, so a missing context
14
+ * or id (an action on a record that does not exist yet) writes nothing:
15
+ *
16
+ * ```ts
17
+ * onClick: ({ id, context }) =>
18
+ * updateRecord(context, "posts", id, { status: "published" }, "Published")
19
+ * ```
20
+ *
21
+ * With the table as a type argument the patch is checked against what an
22
+ * update of it accepts: `updateRecord<typeof posts>(context, "posts", id, { … })`.
23
+ *
24
+ * @param context the action's `context`
25
+ * @param slug the table's slug
26
+ * @param id the record's id
27
+ * @param patch the columns to write, as the server takes them (a date as its ISO string)
28
+ * @param message what the success snackbar says; none when omitted
29
+ *
30
+ * @group Tables
31
+ */
32
+ export declare function updateRecord<T extends CustomizableTable | undefined = undefined>(context: RebaseContext | undefined, slug: string | undefined, id: string | number | undefined, patch: TableUpdate<T>, message?: string): Promise<void>;
@@ -0,0 +1,40 @@
1
+ //#region src/tables/update_record.ts
2
+ /**
3
+ * Writes `patch` onto one record through the panel's data layer, then says so.
4
+ *
5
+ * The write goes through `context.data`, so it is the same request the form
6
+ * would make — the server's hooks and row-level security apply — and every
7
+ * view of the table refreshes. `message`, when given, is shown as a success
8
+ * snackbar. A failed write throws, and the action that called it reports it.
9
+ *
10
+ * Takes what an entity action's `onClick` receives as-is, so a missing context
11
+ * or id (an action on a record that does not exist yet) writes nothing:
12
+ *
13
+ * ```ts
14
+ * onClick: ({ id, context }) =>
15
+ * updateRecord(context, "posts", id, { status: "published" }, "Published")
16
+ * ```
17
+ *
18
+ * With the table as a type argument the patch is checked against what an
19
+ * update of it accepts: `updateRecord<typeof posts>(context, "posts", id, { … })`.
20
+ *
21
+ * @param context the action's `context`
22
+ * @param slug the table's slug
23
+ * @param id the record's id
24
+ * @param patch the columns to write, as the server takes them (a date as its ISO string)
25
+ * @param message what the success snackbar says; none when omitted
26
+ *
27
+ * @group Tables
28
+ */
29
+ async function updateRecord(context, slug, id, patch, message) {
30
+ if (!context || !slug || id === void 0) return;
31
+ await context.data.table(slug).update(id, patch);
32
+ if (message) context.snackbarController?.open({
33
+ type: "success",
34
+ message
35
+ });
36
+ }
37
+ //#endregion
38
+ export { updateRecord };
39
+
40
+ //# sourceMappingURL=update_record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update_record.js","names":[],"sources":["../../src/tables/update_record.ts"],"sourcesContent":["/**\n * `updateRecord`: the write an entity action most often makes.\n */\nimport type { CustomizableTable, RebaseContext, TableUpdate } from \"@rebasepro/cms-types\";\n\n/**\n * Writes `patch` onto one record through the panel's data layer, then says so.\n *\n * The write goes through `context.data`, so it is the same request the form\n * would make — the server's hooks and row-level security apply — and every\n * view of the table refreshes. `message`, when given, is shown as a success\n * snackbar. A failed write throws, and the action that called it reports it.\n *\n * Takes what an entity action's `onClick` receives as-is, so a missing context\n * or id (an action on a record that does not exist yet) writes nothing:\n *\n * ```ts\n * onClick: ({ id, context }) =>\n * updateRecord(context, \"posts\", id, { status: \"published\" }, \"Published\")\n * ```\n *\n * With the table as a type argument the patch is checked against what an\n * update of it accepts: `updateRecord<typeof posts>(context, \"posts\", id, { … })`.\n *\n * @param context the action's `context`\n * @param slug the table's slug\n * @param id the record's id\n * @param patch the columns to write, as the server takes them (a date as its ISO string)\n * @param message what the success snackbar says; none when omitted\n *\n * @group Tables\n */\nexport async function updateRecord<T extends CustomizableTable | undefined = undefined>(\n context: RebaseContext | undefined,\n slug: string | undefined,\n id: string | number | undefined,\n patch: TableUpdate<T>,\n message?: string\n): Promise<void> {\n if (!context || !slug || id === undefined) return;\n await context.data.table(slug).update(id, patch);\n if (message) context.snackbarController?.open({ type: \"success\", message });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,eAAsB,aAClB,SACA,MACA,IACA,OACA,SACa;CACb,IAAI,CAAC,WAAW,CAAC,QAAQ,OAAO,KAAA,GAAW;CAC3C,MAAM,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK;CAC/C,IAAI,SAAS,QAAQ,oBAAoB,KAAK;EAAE,MAAM;EAAW;CAAQ,CAAC;AAC9E"}
@@ -1,4 +1,4 @@
1
- import { Entity } from "@rebasepro/types";
1
+ import { Entity } from "@rebasepro/cms-types";
2
2
  import { FormContext } from "../fields.js";
3
3
  import { FormexController } from "./formex.js";
4
4
  import type { AdminCollection } from "@rebasepro/cms-types";
@@ -1,5 +1,5 @@
1
- import { InferPropertyType } from "@rebasepro/types";
2
- import { Property } from "@rebasepro/types";
1
+ import { InferPropertyType } from "@rebasepro/cms-types";
2
+ import { Property } from "@rebasepro/cms-types";
3
3
  /**
4
4
  * @group Preview components
5
5
  */
@@ -1,5 +1,5 @@
1
- import { InferPropertyType } from "@rebasepro/types";
2
- import { Property } from "@rebasepro/types";
1
+ import { InferPropertyType } from "@rebasepro/cms-types";
2
+ import { Property } from "@rebasepro/cms-types";
3
3
  import type { FormContext } from "@rebasepro/cms-types";
4
4
  export type { FormContext };
5
5
  export type DefaultFieldConfig = "text_field" | "multiline" | "markdown" | "url" | "email" | "switch" | "select" | "multi_select" | "user_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "reference" | "multi_references" | "relation" | "date_time" | "group" | "key_value" | "repeat" | "custom_array" | "block" | "vector_input" | "geopoint" | "binary";
@@ -1 +1 @@
1
- {"version":3,"file":"dataControllerAdapter.js","names":[],"sources":["../../src/util/dataControllerAdapter.ts"],"sourcesContent":["/**\n * Adapts an `EntityTableController<M>` (from @rebasepro/types) to a\n * `CollectionDataController<T>` (from @rebasepro/ui), bridging the\n * entity-aware data layer to the headless collection view.\n */\n\nimport { useMemo } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { EntityTableController } from \"@rebasepro/cms-types\";\nimport type { CollectionDataController } from \"@rebasepro/ui\";\nimport { warnDeprecated } from \"@rebasepro/common\";\n\n/**\n * Unwrap `Entity<M>` objects to flat rows for the headless view.\n * The entity system uses `{ id, path, values: M }`; `values` is already the\n * flat row `M` carrying its real primary key, so unwrapping is just `.values` —\n * no `id`/`path` merge (those are view-model metadata, not row columns).\n */\nfunction flattenEntities<M extends Record<string, unknown>>(\n entities: Entity<M>[]\n): M[] {\n return entities.map(entity => entity.values);\n}\n\n/**\n * React hook that adapts a EntityTableController to a CollectionDataController.\n *\n * Usage:\n * ```tsx\n * const tableController = useDataTableController({ path, collection });\n * const dataController = useCollectionDataController(tableController);\n *\n * <CollectionView dataController={dataController} ... />\n * ```\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function useCollectionDataController<M extends Record<string, unknown>>(\n tableController: EntityTableController<M>\n): CollectionDataController<M> {\n warnDeprecated(\n \"cms.useCollectionDataController\",\n \"`useCollectionDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n const flatData = useMemo(\n () => flattenEntities(tableController.data),\n [tableController.data]\n );\n\n return useMemo((): CollectionDataController<M> => ({\n data: flatData,\n loading: tableController.dataLoading,\n noMoreToLoad: tableController.noMoreToLoad,\n error: tableController.dataLoadingError,\n\n filterValues: tableController.filterValues as Record<string, [string, unknown]> | undefined,\n setFilterValues: tableController.setFilterValues as\n ((values: Record<string, [string, unknown]> | undefined) => void) | undefined,\n\n sortBy: tableController.sortBy,\n setSortBy: tableController.setSortBy,\n\n searchString: tableController.searchString,\n setSearchString: tableController.setSearchString,\n\n clearFilter: tableController.clearFilter,\n\n initialScroll: tableController.initialScroll,\n onScroll: tableController.onScroll,\n\n paginationEnabled: tableController.paginationEnabled,\n pageSize: tableController.pageSize,\n itemCount: tableController.itemCount,\n setItemCount: tableController.setItemCount,\n }), [flatData, tableController]);\n}\n\n/**\n * Non-hook version for cases where you already have the data\n * and just need to build a static controller.\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function createStaticDataController<T extends Record<string, unknown>>(\n data: T[],\n options?: {\n loading?: boolean;\n error?: Error;\n }\n): CollectionDataController<T> {\n warnDeprecated(\n \"cms.createStaticDataController\",\n \"`createStaticDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n return {\n data,\n loading: options?.loading ?? false,\n noMoreToLoad: true,\n error: options?.error,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAS,gBACL,UACG;CACH,OAAO,SAAS,KAAI,WAAU,OAAO,MAAM;AAC/C;;;;;;;;;;;;;;;;AAiBA,SAAgB,4BACZ,iBAC2B;CAC3B,eACI,mCACA,wIACJ;CACA,MAAM,WAAW,cACP,gBAAgB,gBAAgB,IAAI,GAC1C,CAAC,gBAAgB,IAAI,CACzB;CAEA,OAAO,eAA4C;EAC/C,MAAM;EACN,SAAS,gBAAgB;EACzB,cAAc,gBAAgB;EAC9B,OAAO,gBAAgB;EAEvB,cAAc,gBAAgB;EAC9B,iBAAiB,gBAAgB;EAGjC,QAAQ,gBAAgB;EACxB,WAAW,gBAAgB;EAE3B,cAAc,gBAAgB;EAC9B,iBAAiB,gBAAgB;EAEjC,aAAa,gBAAgB;EAE7B,eAAe,gBAAgB;EAC/B,UAAU,gBAAgB;EAE1B,mBAAmB,gBAAgB;EACnC,UAAU,gBAAgB;EAC1B,WAAW,gBAAgB;EAC3B,cAAc,gBAAgB;CAClC,IAAI,CAAC,UAAU,eAAe,CAAC;AACnC;;;;;;;;;AAUA,SAAgB,2BACZ,MACA,SAI2B;CAC3B,eACI,kCACA,uIACJ;CACA,OAAO;EACH;EACA,SAAS,SAAS,WAAW;EAC7B,cAAc;EACd,OAAO,SAAS;CACpB;AACJ"}
1
+ {"version":3,"file":"dataControllerAdapter.js","names":[],"sources":["../../src/util/dataControllerAdapter.ts"],"sourcesContent":["/**\n * Adapts an `EntityTableController<M>` (from @rebasepro/types) to a\n * `CollectionDataController<T>` (from @rebasepro/ui), bridging the\n * entity-aware data layer to the headless collection view.\n */\n\nimport { useMemo } from \"react\";\nimport type { EntityTableController, Entity } from \"@rebasepro/cms-types\";\nimport type { CollectionDataController } from \"@rebasepro/ui\";\nimport { warnDeprecated } from \"@rebasepro/common\";\n\n/**\n * Unwrap `Entity<M>` objects to flat rows for the headless view.\n * The entity system uses `{ id, path, values: M }`; `values` is already the\n * flat row `M` carrying its real primary key, so unwrapping is just `.values` —\n * no `id`/`path` merge (those are view-model metadata, not row columns).\n */\nfunction flattenEntities<M extends Record<string, unknown>>(\n entities: Entity<M>[]\n): M[] {\n return entities.map(entity => entity.values);\n}\n\n/**\n * React hook that adapts a EntityTableController to a CollectionDataController.\n *\n * Usage:\n * ```tsx\n * const tableController = useDataTableController({ path, collection });\n * const dataController = useCollectionDataController(tableController);\n *\n * <CollectionView dataController={dataController} ... />\n * ```\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function useCollectionDataController<M extends Record<string, unknown>>(\n tableController: EntityTableController<M>\n): CollectionDataController<M> {\n warnDeprecated(\n \"cms.useCollectionDataController\",\n \"`useCollectionDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n const flatData = useMemo(\n () => flattenEntities(tableController.data),\n [tableController.data]\n );\n\n return useMemo((): CollectionDataController<M> => ({\n data: flatData,\n loading: tableController.dataLoading,\n noMoreToLoad: tableController.noMoreToLoad,\n error: tableController.dataLoadingError,\n\n filterValues: tableController.filterValues as Record<string, [string, unknown]> | undefined,\n setFilterValues: tableController.setFilterValues as\n ((values: Record<string, [string, unknown]> | undefined) => void) | undefined,\n\n sortBy: tableController.sortBy,\n setSortBy: tableController.setSortBy,\n\n searchString: tableController.searchString,\n setSearchString: tableController.setSearchString,\n\n clearFilter: tableController.clearFilter,\n\n initialScroll: tableController.initialScroll,\n onScroll: tableController.onScroll,\n\n paginationEnabled: tableController.paginationEnabled,\n pageSize: tableController.pageSize,\n itemCount: tableController.itemCount,\n setItemCount: tableController.setItemCount,\n }), [flatData, tableController]);\n}\n\n/**\n * Non-hook version for cases where you already have the data\n * and just need to build a static controller.\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function createStaticDataController<T extends Record<string, unknown>>(\n data: T[],\n options?: {\n loading?: boolean;\n error?: Error;\n }\n): CollectionDataController<T> {\n warnDeprecated(\n \"cms.createStaticDataController\",\n \"`createStaticDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n return {\n data,\n loading: options?.loading ?? false,\n noMoreToLoad: true,\n error: options?.error,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAS,gBACL,UACG;CACH,OAAO,SAAS,KAAI,WAAU,OAAO,MAAM;AAC/C;;;;;;;;;;;;;;;;AAiBA,SAAgB,4BACZ,iBAC2B;CAC3B,eACI,mCACA,wIACJ;CACA,MAAM,WAAW,cACP,gBAAgB,gBAAgB,IAAI,GAC1C,CAAC,gBAAgB,IAAI,CACzB;CAEA,OAAO,eAA4C;EAC/C,MAAM;EACN,SAAS,gBAAgB;EACzB,cAAc,gBAAgB;EAC9B,OAAO,gBAAgB;EAEvB,cAAc,gBAAgB;EAC9B,iBAAiB,gBAAgB;EAGjC,QAAQ,gBAAgB;EACxB,WAAW,gBAAgB;EAE3B,cAAc,gBAAgB;EAC9B,iBAAiB,gBAAgB;EAEjC,aAAa,gBAAgB;EAE7B,eAAe,gBAAgB;EAC/B,UAAU,gBAAgB;EAE1B,mBAAmB,gBAAgB;EACnC,UAAU,gBAAgB;EAC1B,WAAW,gBAAgB;EAC3B,cAAc,gBAAgB;CAClC,IAAI,CAAC,UAAU,eAAe,CAAC;AACnC;;;;;;;;;AAUA,SAAgB,2BACZ,MACA,SAI2B;CAC3B,eACI,kCACA,uIACJ;CACA,OAAO;EACH;EACA,SAAS,SAAS,WAAW;EAC7B,cAAc;EACd,OAAO,SAAS;CACpB;AACJ"}
@@ -1,4 +1,5 @@
1
- import { Entity, FindParams } from "@rebasepro/types";
1
+ import { FindParams } from "@rebasepro/types";
2
+ import { Entity } from "@rebasepro/cms-types";
2
3
  /**
3
4
  * One page as a walk reads it. A collection accessor's `FindResponse` is one;
4
5
  * `nextCursor` is what the REST listing adds whenever another page follows
@@ -1 +1 @@
1
- {"version":3,"file":"entity_pages.js","names":[],"sources":["../../src/util/entity_pages.ts"],"sourcesContent":["import { Entity, FindParams } from \"@rebasepro/types\";\n\n/**\n * One page as a walk reads it. A collection accessor's `FindResponse` is one;\n * `nextCursor` is what the REST listing adds whenever another page follows\n * (`PaginationMeta.nextCursor`), and the admin's data client passes it through.\n */\nexport interface EntityPage<M extends Record<string, unknown>> {\n data: Entity<M>[];\n meta?: {\n total?: number;\n hasMore?: boolean;\n nextCursor?: string;\n };\n}\n\n/** The slice of a collection accessor a page walk needs. */\nexport interface EntityPageAccessor<M extends Record<string, unknown>> {\n find(params?: FindParams<M>): Promise<EntityPage<M>>;\n}\n\nexport interface WalkEntityPagesParams<M extends Record<string, unknown>> {\n accessor: EntityPageAccessor<M>;\n /** Query to walk. The window (`limit` / `offset` / `page`) is owned by the walk. */\n params?: Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\">;\n pageSize: number;\n /** Walking past this many rows throws, with `onCeiling`'s message. */\n maxRows: number;\n onCeiling: (maxRows: number) => string;\n /** Called after every page with the rows so far, and the total when the server reports one. */\n onProgress?: (loaded: number, total: number | undefined) => void;\n /** Checked between pages. When it aborts, what has been read so far is returned. */\n signal?: { aborted: boolean };\n}\n\n/**\n * Read **every** row matching a query, one page at a time.\n *\n * `find({})` sends no `limit`, and an absent limit is resolved server-side to\n * `DEFAULT_LIST_LIMIT` — 50 rows. Anything that means \"all of them\" and asks\n * once gets 50 back, with nothing to say that is what happened.\n *\n * Termination is driven by the server's `meta.hasMore` where it is reported and\n * by an empty page otherwise — never by comparing a page's length against the\n * requested limit, since a final page that happens to be exactly full is\n * indistinguishable that way and a walk that stops there drops rows.\n *\n * Each page after the first continues from the server's `meta.nextCursor`\n * (sent back as `after`) whenever the previous page carried one. Paging by\n * `offset` made the database skip every row already read on every request, so\n * a walk cost the square of the collection; a seek reads only the next page,\n * and rows written mid-walk no longer shift it. Where no cursor comes —\n * relevance ordering, a server that predates cursors — or one stops advancing,\n * it pages by `offset` from the rows it has read. `after` and `offset` are\n * never sent together (the server refuses that, `CURSOR_WITH_OFFSET`).\n *\n * @throws When more than `maxRows` rows match. A truncated answer is worse than\n * no answer: it is indistinguishable from a complete one.\n */\nexport async function walkEntityPages<M extends Record<string, unknown>>(\n params: WalkEntityPagesParams<M>\n): Promise<Entity<M>[]> {\n const rows: Entity<M>[] = [];\n await forEachEntityPage<M>({\n ...params,\n onPage: (page) => {\n rows.push(...page);\n }\n });\n return rows;\n}\n\n/**\n * {@link walkEntityPages}, handing each page to `onPage` as it arrives instead\n * of collecting them: the next page is read once `onPage` has settled, and\n * nothing here keeps a page after that. For a caller that can consume a page\n * and let it go — an export writing its file as it reads.\n *\n * @throws When more than `maxRows` rows match — after handing on the pages\n * before the one that crossed it.\n */\nexport async function forEachEntityPage<M extends Record<string, unknown>>({\n accessor,\n params,\n pageSize,\n maxRows,\n onCeiling,\n onProgress,\n signal,\n onPage\n}: WalkEntityPagesParams<M> & {\n onPage: (page: Entity<M>[]) => void | Promise<void>;\n}): Promise<void> {\n\n let loaded = 0;\n let offset = 0;\n let after: string | undefined;\n\n for (; ;) {\n if (signal?.aborted) break;\n\n const res = await accessor.find({\n ...params,\n limit: pageSize,\n ...(after ? { after } : { offset })\n } as FindParams<M>);\n\n const page = res?.data ?? [];\n loaded += page.length;\n onProgress?.(loaded, res?.meta?.total);\n\n if (loaded > maxRows)\n throw new Error(onCeiling(maxRows));\n\n if (page.length > 0) await onPage(page);\n\n // An empty page ends the walk whatever the metadata says, so a server\n // that keeps answering `hasMore` cannot spin forever.\n if (page.length === 0) break;\n if (res?.meta && !res.meta.hasMore) break;\n\n // By rows received, not by `pageSize`: a server whose ceiling is lower\n // than the page we asked for would otherwise skip everything it clamped.\n // Counted on seeked pages too, so a fall back to offset resumes where\n // the walk has got to.\n offset += page.length;\n // A cursor equal to the one just sent cannot advance the walk; offset\n // still can.\n const next = res?.meta?.nextCursor;\n after = next && next !== after ? next : undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,eAAsB,gBAClB,QACoB;CACpB,MAAM,OAAoB,CAAC;CAC3B,MAAM,kBAAqB;EACvB,GAAG;EACH,SAAS,SAAS;GACd,KAAK,KAAK,GAAG,IAAI;EACrB;CACJ,CAAC;CACD,OAAO;AACX;;;;;;;;;;AAWA,eAAsB,kBAAqD,EACvE,UACA,QACA,UACA,SACA,WACA,YACA,QACA,UAGc;CAEd,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI;CAEJ,SAAU;EACN,IAAI,QAAQ,SAAS;EAErB,MAAM,MAAM,MAAM,SAAS,KAAK;GAC5B,GAAG;GACH,OAAO;GACP,GAAI,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO;EACrC,CAAkB;EAElB,MAAM,OAAO,KAAK,QAAQ,CAAC;EAC3B,UAAU,KAAK;EACf,aAAa,QAAQ,KAAK,MAAM,KAAK;EAErC,IAAI,SAAS,SACT,MAAM,IAAI,MAAM,UAAU,OAAO,CAAC;EAEtC,IAAI,KAAK,SAAS,GAAG,MAAM,OAAO,IAAI;EAItC,IAAI,KAAK,WAAW,GAAG;EACvB,IAAI,KAAK,QAAQ,CAAC,IAAI,KAAK,SAAS;EAMpC,UAAU,KAAK;EAGf,MAAM,OAAO,KAAK,MAAM;EACxB,QAAQ,QAAQ,SAAS,QAAQ,OAAO,KAAA;CAC5C;AACJ"}
1
+ {"version":3,"file":"entity_pages.js","names":[],"sources":["../../src/util/entity_pages.ts"],"sourcesContent":["import { FindParams } from \"@rebasepro/types\";\nimport { Entity } from \"@rebasepro/cms-types\";\n\n/**\n * One page as a walk reads it. A collection accessor's `FindResponse` is one;\n * `nextCursor` is what the REST listing adds whenever another page follows\n * (`PaginationMeta.nextCursor`), and the admin's data client passes it through.\n */\nexport interface EntityPage<M extends Record<string, unknown>> {\n data: Entity<M>[];\n meta?: {\n total?: number;\n hasMore?: boolean;\n nextCursor?: string;\n };\n}\n\n/** The slice of a collection accessor a page walk needs. */\nexport interface EntityPageAccessor<M extends Record<string, unknown>> {\n find(params?: FindParams<M>): Promise<EntityPage<M>>;\n}\n\nexport interface WalkEntityPagesParams<M extends Record<string, unknown>> {\n accessor: EntityPageAccessor<M>;\n /** Query to walk. The window (`limit` / `offset` / `page`) is owned by the walk. */\n params?: Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\">;\n pageSize: number;\n /** Walking past this many rows throws, with `onCeiling`'s message. */\n maxRows: number;\n onCeiling: (maxRows: number) => string;\n /** Called after every page with the rows so far, and the total when the server reports one. */\n onProgress?: (loaded: number, total: number | undefined) => void;\n /** Checked between pages. When it aborts, what has been read so far is returned. */\n signal?: { aborted: boolean };\n}\n\n/**\n * Read **every** row matching a query, one page at a time.\n *\n * `find({})` sends no `limit`, and an absent limit is resolved server-side to\n * `DEFAULT_LIST_LIMIT` — 50 rows. Anything that means \"all of them\" and asks\n * once gets 50 back, with nothing to say that is what happened.\n *\n * Termination is driven by the server's `meta.hasMore` where it is reported and\n * by an empty page otherwise — never by comparing a page's length against the\n * requested limit, since a final page that happens to be exactly full is\n * indistinguishable that way and a walk that stops there drops rows.\n *\n * Each page after the first continues from the server's `meta.nextCursor`\n * (sent back as `after`) whenever the previous page carried one. Paging by\n * `offset` made the database skip every row already read on every request, so\n * a walk cost the square of the collection; a seek reads only the next page,\n * and rows written mid-walk no longer shift it. Where no cursor comes —\n * relevance ordering, a server that predates cursors — or one stops advancing,\n * it pages by `offset` from the rows it has read. `after` and `offset` are\n * never sent together (the server refuses that, `CURSOR_WITH_OFFSET`).\n *\n * @throws When more than `maxRows` rows match. A truncated answer is worse than\n * no answer: it is indistinguishable from a complete one.\n */\nexport async function walkEntityPages<M extends Record<string, unknown>>(\n params: WalkEntityPagesParams<M>\n): Promise<Entity<M>[]> {\n const rows: Entity<M>[] = [];\n await forEachEntityPage<M>({\n ...params,\n onPage: (page) => {\n rows.push(...page);\n }\n });\n return rows;\n}\n\n/**\n * {@link walkEntityPages}, handing each page to `onPage` as it arrives instead\n * of collecting them: the next page is read once `onPage` has settled, and\n * nothing here keeps a page after that. For a caller that can consume a page\n * and let it go — an export writing its file as it reads.\n *\n * @throws When more than `maxRows` rows match — after handing on the pages\n * before the one that crossed it.\n */\nexport async function forEachEntityPage<M extends Record<string, unknown>>({\n accessor,\n params,\n pageSize,\n maxRows,\n onCeiling,\n onProgress,\n signal,\n onPage\n}: WalkEntityPagesParams<M> & {\n onPage: (page: Entity<M>[]) => void | Promise<void>;\n}): Promise<void> {\n\n let loaded = 0;\n let offset = 0;\n let after: string | undefined;\n\n for (; ;) {\n if (signal?.aborted) break;\n\n const res = await accessor.find({\n ...params,\n limit: pageSize,\n ...(after ? { after } : { offset })\n } as FindParams<M>);\n\n const page = res?.data ?? [];\n loaded += page.length;\n onProgress?.(loaded, res?.meta?.total);\n\n if (loaded > maxRows)\n throw new Error(onCeiling(maxRows));\n\n if (page.length > 0) await onPage(page);\n\n // An empty page ends the walk whatever the metadata says, so a server\n // that keeps answering `hasMore` cannot spin forever.\n if (page.length === 0) break;\n if (res?.meta && !res.meta.hasMore) break;\n\n // By rows received, not by `pageSize`: a server whose ceiling is lower\n // than the page we asked for would otherwise skip everything it clamped.\n // Counted on seeked pages too, so a fall back to offset resumes where\n // the walk has got to.\n offset += page.length;\n // A cursor equal to the one just sent cannot advance the walk; offset\n // still can.\n const next = res?.meta?.nextCursor;\n after = next && next !== after ? next : undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,eAAsB,gBAClB,QACoB;CACpB,MAAM,OAAoB,CAAC;CAC3B,MAAM,kBAAqB;EACvB,GAAG;EACH,SAAS,SAAS;GACd,KAAK,KAAK,GAAG,IAAI;EACrB;CACJ,CAAC;CACD,OAAO;AACX;;;;;;;;;;AAWA,eAAsB,kBAAqD,EACvE,UACA,QACA,UACA,SACA,WACA,YACA,QACA,UAGc;CAEd,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI;CAEJ,SAAU;EACN,IAAI,QAAQ,SAAS;EAErB,MAAM,MAAM,MAAM,SAAS,KAAK;GAC5B,GAAG;GACH,OAAO;GACP,GAAI,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO;EACrC,CAAkB;EAElB,MAAM,OAAO,KAAK,QAAQ,CAAC;EAC3B,UAAU,KAAK;EACf,aAAa,QAAQ,KAAK,MAAM,KAAK;EAErC,IAAI,SAAS,SACT,MAAM,IAAI,MAAM,UAAU,OAAO,CAAC;EAEtC,IAAI,KAAK,SAAS,GAAG,MAAM,OAAO,IAAI;EAItC,IAAI,KAAK,WAAW,GAAG;EACvB,IAAI,KAAK,QAAQ,CAAC,IAAI,KAAK,SAAS;EAMpC,UAAU,KAAK;EAGf,MAAM,OAAO,KAAK,MAAM;EACxB,QAAQ,QAAQ,SAAS,QAAQ,OAAO,KAAA;CAC5C;AACJ"}
@@ -1,4 +1,4 @@
1
- import type { CollectionAccessor, CollectionConfig, Entity } from "@rebasepro/types";
1
+ import type { CollectionConfig, TableAccessor, Entity } from "@rebasepro/cms-types";
2
2
  /**
3
3
  * The rows of one collection with these ids, in as few requests as its key
4
4
  * allows.
@@ -20,4 +20,4 @@ import type { CollectionAccessor, CollectionConfig, Entity } from "@rebasepro/ty
20
20
  * not the caller's to read — is absent, as `findById`'s `undefined` was; a
21
21
  * per-id read that fails is absent too, and logged.
22
22
  */
23
- export declare function findEntitiesByIds<M extends Record<string, unknown>>(accessor: Pick<CollectionAccessor<M>, "find" | "findById">, collection: CollectionConfig<M>, ids: readonly (string | number)[]): Promise<Map<string, Entity<M>>>;
23
+ export declare function findEntitiesByIds<M extends Record<string, unknown>>(accessor: Pick<TableAccessor<M>, "find" | "findById">, collection: CollectionConfig<M>, ids: readonly (string | number)[]): Promise<Map<string, Entity<M>>>;
@@ -1,4 +1,4 @@
1
- import { getPrimaryKeys } from "@rebasepro/common";
1
+ import { getPrimaryKeys } from "@rebasepro/cms-types";
2
2
  import { MAX_LIST_LIMIT } from "@rebasepro/types";
3
3
  //#region src/util/find_entities_by_ids.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"find_entities_by_ids.js","names":[],"sources":["../../src/util/find_entities_by_ids.ts"],"sourcesContent":["import { MAX_LIST_LIMIT } from \"@rebasepro/types\";\nimport type { CollectionAccessor, CollectionConfig, Entity, WhereFor } from \"@rebasepro/types\";\nimport { getPrimaryKeys } from \"@rebasepro/common\";\n\n/**\n * The rows of one collection with these ids, in as few requests as its key\n * allows.\n *\n * A picker opens with the rows already linked to the record, and reading each\n * with its own `findById` made a post with 40 tags open the tag picker with 40\n * requests. Where one column is the key, the ids go into one\n * `find({ where: { <key>: [\"in\", ids] } })` per {@link MAX_LIST_LIMIT} of\n * them; a key over several columns has no one column to put them in, so each\n * row is still read by its id. A batch the source refuses — a key the admin\n * resolves differently from the server, a custom source without `in` — falls\n * back to the same per-id reads, so nothing that opened before fails now.\n *\n * Same rows as before, under the same identity: `find` and `findById` go\n * through the one accessor, and both leave out a row the caller may not read\n * and a soft-deleted one.\n *\n * @returns the rows found, by `String(id)`. An id with no row — deleted, or\n * not the caller's to read — is absent, as `findById`'s `undefined` was; a\n * per-id read that fails is absent too, and logged.\n */\nexport async function findEntitiesByIds<M extends Record<string, unknown>>(\n accessor: Pick<CollectionAccessor<M>, \"find\" | \"findById\">,\n collection: CollectionConfig<M>,\n ids: readonly (string | number)[]\n): Promise<Map<string, Entity<M>>> {\n const wanted = [...new Set(ids.map(String))];\n const found = new Map<string, Entity<M>>();\n if (wanted.length === 0) return found;\n\n const keys = getPrimaryKeys(collection);\n if (keys.length === 1) {\n try {\n for (let start = 0; start < wanted.length; start += MAX_LIST_LIMIT) {\n const chunk = wanted.slice(start, start + MAX_LIST_LIMIT);\n // SAFETY: `keys[0]` is M's primary-key column, read from the\n // collection at runtime — the compiler cannot tie a runtime key\n // to `keyof M`, and `in` with a list of ids is a condition the\n // object-form `where` admits on any column.\n const where = { [keys[0]]: [\"in\", chunk] } as WhereFor<M>;\n // Nothing here reads a total.\n const { data } = await accessor.find({ where, limit: chunk.length, count: \"none\" });\n for (const entity of data) found.set(String(entity.id), entity);\n }\n return found;\n } catch {\n found.clear();\n }\n }\n\n const entities = await Promise.all(wanted.map(id =>\n accessor.findById(id).catch((error: unknown) => {\n console.warn(`Could not read ${collection.slug ?? \"the collection\"} row ${id}`, error);\n return undefined;\n })));\n entities.forEach((entity, i) => {\n if (entity) found.set(wanted[i], entity);\n });\n return found;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,kBAClB,UACA,YACA,KAC+B;CAC/B,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC;CAC3C,MAAM,wBAAQ,IAAI,IAAuB;CACzC,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,MAAM,OAAO,eAAe,UAAU;CACtC,IAAI,KAAK,WAAW,GAChB,IAAI;EACA,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS,gBAAgB;GAChE,MAAM,QAAQ,OAAO,MAAM,OAAO,QAAQ,cAAc;GAKxD,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,MAAM,KAAK,EAAE;GAEzC,MAAM,EAAE,SAAS,MAAM,SAAS,KAAK;IAAE;IAAO,OAAO,MAAM;IAAQ,OAAO;GAAO,CAAC;GAClF,KAAK,MAAM,UAAU,MAAM,MAAM,IAAI,OAAO,OAAO,EAAE,GAAG,MAAM;EAClE;EACA,OAAO;CACX,QAAQ;EACJ,MAAM,MAAM;CAChB;CAQJ,CAAA,MALuB,QAAQ,IAAI,OAAO,KAAI,OAC1C,SAAS,SAAS,EAAE,CAAC,CAAC,OAAO,UAAmB;EAC5C,QAAQ,KAAK,kBAAkB,WAAW,QAAQ,iBAAiB,OAAO,MAAM,KAAK;CAEzF,CAAC,CAAC,CAAC,EAAA,CACE,SAAS,QAAQ,MAAM;EAC5B,IAAI,QAAQ,MAAM,IAAI,OAAO,IAAI,MAAM;CAC3C,CAAC;CACD,OAAO;AACX"}
1
+ {"version":3,"file":"find_entities_by_ids.js","names":[],"sources":["../../src/util/find_entities_by_ids.ts"],"sourcesContent":["import { MAX_LIST_LIMIT } from \"@rebasepro/types\";\nimport type { WhereFor } from \"@rebasepro/types\";\nimport type { CollectionConfig, TableAccessor, Entity } from \"@rebasepro/cms-types\";\nimport { getPrimaryKeys } from \"@rebasepro/cms-types\";\n\n/**\n * The rows of one collection with these ids, in as few requests as its key\n * allows.\n *\n * A picker opens with the rows already linked to the record, and reading each\n * with its own `findById` made a post with 40 tags open the tag picker with 40\n * requests. Where one column is the key, the ids go into one\n * `find({ where: { <key>: [\"in\", ids] } })` per {@link MAX_LIST_LIMIT} of\n * them; a key over several columns has no one column to put them in, so each\n * row is still read by its id. A batch the source refuses — a key the admin\n * resolves differently from the server, a custom source without `in` — falls\n * back to the same per-id reads, so nothing that opened before fails now.\n *\n * Same rows as before, under the same identity: `find` and `findById` go\n * through the one accessor, and both leave out a row the caller may not read\n * and a soft-deleted one.\n *\n * @returns the rows found, by `String(id)`. An id with no row — deleted, or\n * not the caller's to read — is absent, as `findById`'s `undefined` was; a\n * per-id read that fails is absent too, and logged.\n */\nexport async function findEntitiesByIds<M extends Record<string, unknown>>(\n accessor: Pick<TableAccessor<M>, \"find\" | \"findById\">,\n collection: CollectionConfig<M>,\n ids: readonly (string | number)[]\n): Promise<Map<string, Entity<M>>> {\n const wanted = [...new Set(ids.map(String))];\n const found = new Map<string, Entity<M>>();\n if (wanted.length === 0) return found;\n\n const keys = getPrimaryKeys(collection);\n if (keys.length === 1) {\n try {\n for (let start = 0; start < wanted.length; start += MAX_LIST_LIMIT) {\n const chunk = wanted.slice(start, start + MAX_LIST_LIMIT);\n // SAFETY: `keys[0]` is M's primary-key column, read from the\n // collection at runtime — the compiler cannot tie a runtime key\n // to `keyof M`, and `in` with a list of ids is a condition the\n // object-form `where` admits on any column.\n const where = { [keys[0]]: [\"in\", chunk] } as WhereFor<M>;\n // Nothing here reads a total.\n const { data } = await accessor.find({ where, limit: chunk.length, count: \"none\" });\n for (const entity of data) found.set(String(entity.id), entity);\n }\n return found;\n } catch {\n found.clear();\n }\n }\n\n const entities = await Promise.all(wanted.map(id =>\n accessor.findById(id).catch((error: unknown) => {\n console.warn(`Could not read ${collection.slug ?? \"the collection\"} row ${id}`, error);\n return undefined;\n })));\n entities.forEach((entity, i) => {\n if (entity) found.set(wanted[i], entity);\n });\n return found;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,eAAsB,kBAClB,UACA,YACA,KAC+B;CAC/B,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC;CAC3C,MAAM,wBAAQ,IAAI,IAAuB;CACzC,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,MAAM,OAAO,eAAe,UAAU;CACtC,IAAI,KAAK,WAAW,GAChB,IAAI;EACA,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS,gBAAgB;GAChE,MAAM,QAAQ,OAAO,MAAM,OAAO,QAAQ,cAAc;GAKxD,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,MAAM,KAAK,EAAE;GAEzC,MAAM,EAAE,SAAS,MAAM,SAAS,KAAK;IAAE;IAAO,OAAO,MAAM;IAAQ,OAAO;GAAO,CAAC;GAClF,KAAK,MAAM,UAAU,MAAM,MAAM,IAAI,OAAO,OAAO,EAAE,GAAG,MAAM;EAClE;EACA,OAAO;CACX,QAAQ;EACJ,MAAM,MAAM;CAChB;CAQJ,CAAA,MALuB,QAAQ,IAAI,OAAO,KAAI,OAC1C,SAAS,SAAS,EAAE,CAAC,CAAC,OAAO,UAAmB;EAC5C,QAAQ,KAAK,kBAAkB,WAAW,QAAQ,iBAAiB,OAAO,MAAM,KAAK;CAEzF,CAAC,CAAC,CAAC,EAAA,CACE,SAAS,QAAQ,MAAM;EAC5B,IAAI,QAAQ,MAAM,IAAI,OAAO,IAAI,MAAM;CAC3C,CAAC;CACD,OAAO;AACX"}
@@ -1,4 +1,4 @@
1
- import type { Property } from "@rebasepro/types";
1
+ import type { Property } from "@rebasepro/cms-types";
2
2
  import { type RelativeTimeLabels } from "@rebasepro/utils";
3
3
  export type FormatCollectionDateOptions = {
4
4
  /** The instant relative phrases are measured from. Defaults to now. */
@@ -1 +1 @@
1
- {"version":3,"file":"format_collection_date.js","names":[],"sources":["../../src/util/format_collection_date.ts"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport { formatRelativeTime, type RelativeTimeLabels } from \"@rebasepro/utils\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../preview/util\";\n\nexport type FormatCollectionDateOptions = {\n /** The instant relative phrases are measured from. Defaults to now. */\n now?: Date;\n /** BCP 47 locale. Defaults to the browser's. */\n locale?: string;\n /** The relative phrases, in the admin language (`useUiLabels().relativeTime`). English when absent. */\n relativeTimeLabels?: Partial<RelativeTimeLabels>;\n};\n\nfunction yearIn(date: Date, timeZone: string | undefined): string {\n return new Intl.DateTimeFormat(\"en-US\", { year: \"numeric\", timeZone }).format(date);\n}\n\n/**\n * The short date a collection's list, card and board views show: the date\n * slot, and the list view's date columns.\n *\n * It reads the property the way the table cell, the filter and the form do\n * (`getDatePropertyMode` / `getDatePropertyTimezone`):\n * - a `columnType: \"date\"` value is a calendar day stored as its UTC midnight,\n * so it is shown as that day in UTC, with no time and no relative phrase —\n * in the browser's zone a stored 15th read as the 14th west of Greenwich;\n * - a `columnType: \"time\"` value is a time of day, shown in UTC;\n * - any other date reads \"3h ago\" / \"in 2d\" within a week, else a short date\n * in the property's declared `timezone` (the browser's when none).\n *\n * A slot can also hold a non-date property or a computed value; with no date\n * property the browser's zone is used.\n *\n * Returns `null` for an empty or unreadable value.\n */\nexport function formatCollectionDate(\n value: unknown,\n property: Property | undefined,\n options: FormatCollectionDateOptions = {}\n): string | null {\n if (value === undefined || value === null || value === \"\") return null;\n let date: Date | null = null;\n if (value instanceof Date) date = value;\n else if (typeof value === \"string\" || typeof value === \"number\") date = new Date(value);\n if (!date || isNaN(date.getTime())) return null;\n\n const now = options.now ?? new Date();\n const dateProperty = property?.type === \"date\" ? property : undefined;\n const timeZone = dateProperty ? getDatePropertyTimezone(dateProperty) : undefined;\n\n if (dateProperty?.columnType === \"time\") {\n return new Intl.DateTimeFormat(options.locale, { hour: \"2-digit\", minute: \"2-digit\", timeZone }).format(date);\n }\n\n const dayOnly = dateProperty !== undefined && getDatePropertyMode(dateProperty) === \"date\";\n if (!dayOnly) {\n // A date slot holds whatever the collection points it at, as often a\n // due or publish date as an `updated_at`; `formatRelativeTime` reads\n // the sign, so a scheduled date says \"in 3d\".\n const relative = formatRelativeTime(date, { now, labels: options.relativeTimeLabels });\n if (relative) return relative;\n }\n\n // Comparing years rather than counting days: a date six weeks back across a\n // new year needs the year, and one 400 days ahead needs it just as much.\n const sameYear = yearIn(date, timeZone) === yearIn(now, timeZone);\n return new Intl.DateTimeFormat(options.locale, {\n month: \"short\",\n day: \"numeric\",\n year: sameYear ? undefined : \"numeric\",\n timeZone\n }).format(date);\n}\n"],"mappings":";;;AAaA,SAAS,OAAO,MAAY,UAAsC;CAC9D,OAAO,IAAI,KAAK,eAAe,SAAS;EAAE,MAAM;EAAW;CAAS,CAAC,CAAC,CAAC,OAAO,IAAI;AACtF;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,qBACZ,OACA,UACA,UAAuC,CAAC,GAC3B;CACb,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IAAI,OAAO;CAClE,IAAI,OAAoB;CACxB,IAAI,iBAAiB,MAAM,OAAO;MAC7B,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU,OAAO,IAAI,KAAK,KAAK;CACtF,IAAI,CAAC,QAAQ,MAAM,KAAK,QAAQ,CAAC,GAAG,OAAO;CAE3C,MAAM,MAAM,QAAQ,uBAAO,IAAI,KAAK;CACpC,MAAM,eAAe,UAAU,SAAS,SAAS,WAAW,KAAA;CAC5D,MAAM,WAAW,eAAe,wBAAwB,YAAY,IAAI,KAAA;CAExE,IAAI,cAAc,eAAe,QAC7B,OAAO,IAAI,KAAK,eAAe,QAAQ,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAW;CAAS,CAAC,CAAC,CAAC,OAAO,IAAI;CAIhH,IAAI,EADY,iBAAiB,KAAA,KAAa,oBAAoB,YAAY,MAAM,SACtE;EAIV,MAAM,WAAW,mBAAmB,MAAM;GAAE;GAAK,QAAQ,QAAQ;EAAmB,CAAC;EACrF,IAAI,UAAU,OAAO;CACzB;CAIA,MAAM,WAAW,OAAO,MAAM,QAAQ,MAAM,OAAO,KAAK,QAAQ;CAChE,OAAO,IAAI,KAAK,eAAe,QAAQ,QAAQ;EAC3C,OAAO;EACP,KAAK;EACL,MAAM,WAAW,KAAA,IAAY;EAC7B;CACJ,CAAC,CAAC,CAAC,OAAO,IAAI;AAClB"}
1
+ {"version":3,"file":"format_collection_date.js","names":[],"sources":["../../src/util/format_collection_date.ts"],"sourcesContent":["import type { Property } from \"@rebasepro/cms-types\";\nimport { formatRelativeTime, type RelativeTimeLabels } from \"@rebasepro/utils\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../preview/util\";\n\nexport type FormatCollectionDateOptions = {\n /** The instant relative phrases are measured from. Defaults to now. */\n now?: Date;\n /** BCP 47 locale. Defaults to the browser's. */\n locale?: string;\n /** The relative phrases, in the admin language (`useUiLabels().relativeTime`). English when absent. */\n relativeTimeLabels?: Partial<RelativeTimeLabels>;\n};\n\nfunction yearIn(date: Date, timeZone: string | undefined): string {\n return new Intl.DateTimeFormat(\"en-US\", { year: \"numeric\", timeZone }).format(date);\n}\n\n/**\n * The short date a collection's list, card and board views show: the date\n * slot, and the list view's date columns.\n *\n * It reads the property the way the table cell, the filter and the form do\n * (`getDatePropertyMode` / `getDatePropertyTimezone`):\n * - a `columnType: \"date\"` value is a calendar day stored as its UTC midnight,\n * so it is shown as that day in UTC, with no time and no relative phrase —\n * in the browser's zone a stored 15th read as the 14th west of Greenwich;\n * - a `columnType: \"time\"` value is a time of day, shown in UTC;\n * - any other date reads \"3h ago\" / \"in 2d\" within a week, else a short date\n * in the property's declared `timezone` (the browser's when none).\n *\n * A slot can also hold a non-date property or a computed value; with no date\n * property the browser's zone is used.\n *\n * Returns `null` for an empty or unreadable value.\n */\nexport function formatCollectionDate(\n value: unknown,\n property: Property | undefined,\n options: FormatCollectionDateOptions = {}\n): string | null {\n if (value === undefined || value === null || value === \"\") return null;\n let date: Date | null = null;\n if (value instanceof Date) date = value;\n else if (typeof value === \"string\" || typeof value === \"number\") date = new Date(value);\n if (!date || isNaN(date.getTime())) return null;\n\n const now = options.now ?? new Date();\n const dateProperty = property?.type === \"date\" ? property : undefined;\n const timeZone = dateProperty ? getDatePropertyTimezone(dateProperty) : undefined;\n\n if (dateProperty?.columnType === \"time\") {\n return new Intl.DateTimeFormat(options.locale, { hour: \"2-digit\", minute: \"2-digit\", timeZone }).format(date);\n }\n\n const dayOnly = dateProperty !== undefined && getDatePropertyMode(dateProperty) === \"date\";\n if (!dayOnly) {\n // A date slot holds whatever the collection points it at, as often a\n // due or publish date as an `updated_at`; `formatRelativeTime` reads\n // the sign, so a scheduled date says \"in 3d\".\n const relative = formatRelativeTime(date, { now, labels: options.relativeTimeLabels });\n if (relative) return relative;\n }\n\n // Comparing years rather than counting days: a date six weeks back across a\n // new year needs the year, and one 400 days ahead needs it just as much.\n const sameYear = yearIn(date, timeZone) === yearIn(now, timeZone);\n return new Intl.DateTimeFormat(options.locale, {\n month: \"short\",\n day: \"numeric\",\n year: sameYear ? undefined : \"numeric\",\n timeZone\n }).format(date);\n}\n"],"mappings":";;;AAaA,SAAS,OAAO,MAAY,UAAsC;CAC9D,OAAO,IAAI,KAAK,eAAe,SAAS;EAAE,MAAM;EAAW;CAAS,CAAC,CAAC,CAAC,OAAO,IAAI;AACtF;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,qBACZ,OACA,UACA,UAAuC,CAAC,GAC3B;CACb,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IAAI,OAAO;CAClE,IAAI,OAAoB;CACxB,IAAI,iBAAiB,MAAM,OAAO;MAC7B,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU,OAAO,IAAI,KAAK,KAAK;CACtF,IAAI,CAAC,QAAQ,MAAM,KAAK,QAAQ,CAAC,GAAG,OAAO;CAE3C,MAAM,MAAM,QAAQ,uBAAO,IAAI,KAAK;CACpC,MAAM,eAAe,UAAU,SAAS,SAAS,WAAW,KAAA;CAC5D,MAAM,WAAW,eAAe,wBAAwB,YAAY,IAAI,KAAA;CAExE,IAAI,cAAc,eAAe,QAC7B,OAAO,IAAI,KAAK,eAAe,QAAQ,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAW;CAAS,CAAC,CAAC,CAAC,OAAO,IAAI;CAIhH,IAAI,EADY,iBAAiB,KAAA,KAAa,oBAAoB,YAAY,MAAM,SACtE;EAIV,MAAM,WAAW,mBAAmB,MAAM;GAAE;GAAK,QAAQ,QAAQ;EAAmB,CAAC;EACrF,IAAI,UAAU,OAAO;CACzB;CAIA,MAAM,WAAW,OAAO,MAAM,QAAQ,MAAM,OAAO,KAAK,QAAQ;CAChE,OAAO,IAAI,KAAK,eAAe,QAAQ,QAAQ;EAC3C,OAAO;EACP,KAAK;EACL,MAAM,WAAW,KAAA,IAAY;EAC7B;CACJ,CAAC,CAAC,CAAC,OAAO,IAAI;AAClB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether `id` names a record.
3
+ *
4
+ * Any number does — `0` is a valid serial or integer key — and any non-empty
5
+ * string. A truthiness test read record `0` as "no record": the panel opened it
6
+ * as a new one, and saving created a row instead of editing it.
7
+ */
8
+ export declare function hasEntityId(id: string | number | null | undefined): id is string | number;
@@ -0,0 +1,16 @@
1
+ //#region src/util/identity.ts
2
+ /**
3
+ * Whether `id` names a record.
4
+ *
5
+ * Any number does — `0` is a valid serial or integer key — and any non-empty
6
+ * string. A truthiness test read record `0` as "no record": the panel opened it
7
+ * as a new one, and saving created a row instead of editing it.
8
+ */
9
+ function hasEntityId(id) {
10
+ if (typeof id === "number") return !Number.isNaN(id);
11
+ return typeof id === "string" && id !== "";
12
+ }
13
+ //#endregion
14
+ export { hasEntityId };
15
+
16
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","names":[],"sources":["../../src/util/identity.ts"],"sourcesContent":["\n/**\n * Whether `id` names a record.\n *\n * Any number does — `0` is a valid serial or integer key — and any non-empty\n * string. A truthiness test read record `0` as \"no record\": the panel opened it\n * as a new one, and saving created a row instead of editing it.\n */\nexport function hasEntityId(id: string | number | null | undefined): id is string | number {\n if (typeof id === \"number\") return !Number.isNaN(id);\n return typeof id === \"string\" && id !== \"\";\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,YAAY,IAA+D;CACvF,IAAI,OAAO,OAAO,UAAU,OAAO,CAAC,OAAO,MAAM,EAAE;CACnD,OAAO,OAAO,OAAO,YAAY,OAAO;AAC5C"}
@@ -1,5 +1,5 @@
1
+ import { hasEntityId } from "./identity.js";
1
2
  import { withListState } from "./view_mode.js";
2
- import { hasEntityId } from "@rebasepro/common";
3
3
  import { addInitialSlash, getCollectionBySlugWithin, getCollectionPathsCombinations, getLastSegment as getLastSegment$1, removeInitialAndTrailingSlashes as removeInitialAndTrailingSlashes$1, removeInitialSlash, removeTrailingSlash as removeTrailingSlash$1, resolveCollectionPathIds as resolveCollectionPathIds$1 } from "@rebasepro/app";
4
4
  //#region src/util/navigation_utils.ts
5
5
  /**