@rebasepro/cms 0.28.2 → 0.29.0

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 (339) hide show
  1. package/README.md +3 -3
  2. package/dist/collection_editor/_cms_internals.d.ts +0 -1
  3. package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
  4. package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
  6. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  7. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
  8. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
  9. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
  10. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
  11. package/dist/components/AdditionalFieldValue.d.ts +9 -3
  12. package/dist/components/AdditionalFieldValue.js +7 -4
  13. package/dist/components/AdditionalFieldValue.js.map +1 -1
  14. package/dist/components/CollectionPanel.d.ts +117 -18
  15. package/dist/components/CollectionPanel.js +115 -37
  16. package/dist/components/CollectionPanel.js.map +1 -1
  17. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
  18. package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
  19. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  20. package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
  21. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  22. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
  23. package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
  24. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  25. package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
  26. package/dist/components/CollectionTableBinding/column_utils.js +6 -3
  27. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  28. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
  29. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  30. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  31. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  32. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
  33. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  34. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
  35. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
  36. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  37. package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
  38. package/dist/components/CollectionTableBinding/internal/common.js +88 -4
  39. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  40. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
  41. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  42. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
  43. package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
  44. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  45. package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
  46. package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
  47. package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
  48. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
  49. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
  50. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  51. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
  52. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
  53. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  54. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
  55. package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
  56. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
  57. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
  58. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
  59. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  60. package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
  61. package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
  62. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
  63. package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
  64. package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
  65. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  66. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
  67. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
  68. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  69. package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
  70. package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
  71. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
  72. package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
  73. package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
  74. package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
  75. package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
  76. package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
  77. package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
  78. package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
  79. package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
  80. package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
  81. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
  82. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
  83. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  84. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
  85. package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
  86. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
  87. package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
  88. package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
  89. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
  90. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
  91. package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
  92. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  93. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
  94. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
  95. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
  96. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
  97. package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
  98. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
  99. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
  100. package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
  101. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
  102. package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
  103. package/dist/components/CollectionViewBinding/RowActions.js +60 -0
  104. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
  105. package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
  106. package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
  107. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  108. package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
  109. package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
  110. package/dist/components/CollectionViewBinding/fields.js +47 -0
  111. package/dist/components/CollectionViewBinding/fields.js.map +1 -0
  112. package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
  113. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  114. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
  115. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
  116. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
  117. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
  118. package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
  119. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
  120. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
  121. package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
  122. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  123. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
  124. package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
  125. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  126. package/dist/components/CollectionsProvider.d.ts +3 -3
  127. package/dist/components/CollectionsProvider.js +4 -4
  128. package/dist/components/CollectionsProvider.js.map +1 -1
  129. package/dist/components/CollectionsScopeContext.d.ts +1 -1
  130. package/dist/components/CollectionsScopeContext.js +1 -1
  131. package/dist/components/CollectionsScopeContext.js.map +1 -1
  132. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  133. package/dist/components/DeleteEntityDialog.js +2 -2
  134. package/dist/components/DeleteEntityDialog.js.map +1 -1
  135. package/dist/components/DetailViewBinding.js +32 -68
  136. package/dist/components/DetailViewBinding.js.map +1 -1
  137. package/dist/components/EditFormActions.js +5 -4
  138. package/dist/components/EditFormActions.js.map +1 -1
  139. package/dist/components/EditViewBinding.d.ts +2 -2
  140. package/dist/components/EditViewBinding.js +25 -15
  141. package/dist/components/EditViewBinding.js.map +1 -1
  142. package/dist/components/EntityDisplayHeader.js +8 -5
  143. package/dist/components/EntityDisplayHeader.js.map +1 -1
  144. package/dist/components/EntityPreviewBinding.js +1 -1
  145. package/dist/components/EntityPreviewBinding.js.map +1 -1
  146. package/dist/components/EntityViewBinding.d.ts +8 -1
  147. package/dist/components/EntityViewBinding.js +43 -14
  148. package/dist/components/EntityViewBinding.js.map +1 -1
  149. package/dist/components/EntityViewBody.d.ts +40 -0
  150. package/dist/components/EntityViewBody.js +90 -0
  151. package/dist/components/EntityViewBody.js.map +1 -0
  152. package/dist/components/FieldValue.d.ts +50 -0
  153. package/dist/components/FieldValue.js +81 -0
  154. package/dist/components/FieldValue.js.map +1 -0
  155. package/dist/components/InlineEntityPreview.js +1 -1
  156. package/dist/components/InlineEntityPreview.js.map +1 -1
  157. package/dist/components/PanelNotFound.d.ts +5 -0
  158. package/dist/components/PanelNotFound.js +21 -0
  159. package/dist/components/PanelNotFound.js.map +1 -0
  160. package/dist/components/RebaseCMS.d.ts +1 -1
  161. package/dist/components/RebaseCMS.js +11 -3
  162. package/dist/components/RebaseCMS.js.map +1 -1
  163. package/dist/components/RebaseNavigation.js +9 -3
  164. package/dist/components/RebaseNavigation.js.map +1 -1
  165. package/dist/components/RebaseShell.js +10 -5
  166. package/dist/components/RebaseShell.js.map +1 -1
  167. package/dist/components/RecordDetail.d.ts +61 -0
  168. package/dist/components/RecordDetail.js +123 -0
  169. package/dist/components/RecordDetail.js.map +1 -0
  170. package/dist/components/RecordForm.d.ts +126 -0
  171. package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
  172. package/dist/components/RecordForm.js.map +1 -0
  173. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
  174. package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
  175. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  176. package/dist/components/ReferenceWidget.d.ts +5 -3
  177. package/dist/components/ReferenceWidget.js +10 -7
  178. package/dist/components/ReferenceWidget.js.map +1 -1
  179. package/dist/components/RelationSelector.js +4 -4
  180. package/dist/components/RelationSelector.js.map +1 -1
  181. package/dist/components/SelectableTable/SelectableTable.js +2 -3
  182. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  183. package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
  184. package/dist/components/SelectableTable/SelectionStore.js +1 -1
  185. package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
  186. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  187. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  188. package/dist/components/SidePanelBinding.js +13 -12
  189. package/dist/components/SidePanelBinding.js.map +1 -1
  190. package/dist/components/collection_prop.d.ts +18 -0
  191. package/dist/components/collection_prop.js +23 -0
  192. package/dist/components/collection_prop.js.map +1 -0
  193. package/dist/components/common/default_entity_actions.js +54 -54
  194. package/dist/components/common/default_entity_actions.js.map +1 -1
  195. package/dist/components/history/EntityHistoryView.d.ts +4 -1
  196. package/dist/components/history/EntityHistoryView.js +1 -1
  197. package/dist/components/history/EntityHistoryView.js.map +1 -1
  198. package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
  199. package/dist/components/index.d.ts +4 -2
  200. package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
  201. package/dist/data_export/export/ExportCollectionAction.js +4 -3
  202. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  203. package/dist/data_export/export/additional_fields.d.ts +6 -3
  204. package/dist/data_export/export/additional_fields.js +8 -4
  205. package/dist/data_export/export/additional_fields.js.map +1 -1
  206. package/dist/data_import/import/ImportCollectionAction.js +2 -2
  207. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  208. package/dist/form/EntityForm.d.ts +1 -1
  209. package/dist/form/EntityForm.js +255 -150
  210. package/dist/form/EntityForm.js.map +1 -1
  211. package/dist/form/EntityFormActions.js +3 -2
  212. package/dist/form/EntityFormActions.js.map +1 -1
  213. package/dist/form/EntityFormBinding.d.ts +1 -1
  214. package/dist/form/EntityFormBinding.js +22 -11
  215. package/dist/form/EntityFormBinding.js.map +1 -1
  216. package/dist/form/FormField.d.ts +36 -0
  217. package/dist/form/FormField.js +41 -0
  218. package/dist/form/FormField.js.map +1 -0
  219. package/dist/form/FormFieldsContext.d.ts +69 -0
  220. package/dist/form/FormFieldsContext.js +143 -0
  221. package/dist/form/FormFieldsContext.js.map +1 -0
  222. package/dist/form/PropertyFieldBinding.js +4 -4
  223. package/dist/form/PropertyFieldBinding.js.map +1 -1
  224. package/dist/form/collection_showing.d.ts +8 -0
  225. package/dist/form/collection_showing.js +29 -0
  226. package/dist/form/collection_showing.js.map +1 -0
  227. package/dist/form/components/ErrorFocus.js +2 -1
  228. package/dist/form/components/ErrorFocus.js.map +1 -1
  229. package/dist/form/components/FieldBlock.js +3 -1
  230. package/dist/form/components/FieldBlock.js.map +1 -1
  231. package/dist/form/components/FormRail.d.ts +5 -1
  232. package/dist/form/components/FormRail.js +5 -1
  233. package/dist/form/components/FormRail.js.map +1 -1
  234. package/dist/form/components/FormSections.d.ts +5 -1
  235. package/dist/form/components/FormSections.js +11 -4
  236. package/dist/form/components/FormSections.js.map +1 -1
  237. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  238. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  239. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  240. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  241. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  242. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  243. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  244. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  245. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  246. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  247. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  248. package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
  249. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  250. package/dist/form/form_dom_ids.d.ts +25 -0
  251. package/dist/form/form_dom_ids.js +42 -0
  252. package/dist/form/form_dom_ids.js.map +1 -0
  253. package/dist/form/index.d.ts +3 -1
  254. package/dist/form/resolve_cell_property.d.ts +5 -0
  255. package/dist/form/resolve_cell_property.js +22 -1
  256. package/dist/form/resolve_cell_property.js.map +1 -1
  257. package/dist/hooks/index.d.ts +1 -1
  258. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
  259. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  260. package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
  261. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  262. package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
  263. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  264. package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
  265. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  266. package/dist/hooks/useBuildSidePanel.js +9 -9
  267. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  268. package/dist/hooks/useEntityDisplay.js +6 -4
  269. package/dist/hooks/useEntityDisplay.js.map +1 -1
  270. package/dist/hooks/useRecordActions.js +2 -2
  271. package/dist/hooks/useRecordActions.js.map +1 -1
  272. package/dist/hooks/useSelectionDialog.d.ts +20 -7
  273. package/dist/hooks/useSelectionDialog.js +29 -8
  274. package/dist/hooks/useSelectionDialog.js.map +1 -1
  275. package/dist/index.d.ts +8 -3
  276. package/dist/index.js +15 -9
  277. package/dist/mcp-view.d.ts +9 -0
  278. package/dist/mcp-view.js +2 -0
  279. package/dist/mcp_view/app_modules.d.ts +29 -0
  280. package/dist/mcp_view/app_modules.js +163 -0
  281. package/dist/mcp_view/app_modules.js.map +1 -0
  282. package/dist/mcp_view/bridge.d.ts +90 -0
  283. package/dist/mcp_view/bridge.js +205 -0
  284. package/dist/mcp_view/bridge.js.map +1 -0
  285. package/dist/mcp_view/code_app.d.ts +65 -0
  286. package/dist/mcp_view/code_app.js +139 -0
  287. package/dist/mcp_view/code_app.js.map +1 -0
  288. package/dist/mcp_view/index.d.ts +54 -0
  289. package/dist/mcp_view/index.js +262 -0
  290. package/dist/mcp_view/index.js.map +1 -0
  291. package/dist/mcp_view/payload.d.ts +78 -0
  292. package/dist/mcp_view/payload.js +155 -0
  293. package/dist/mcp_view/payload.js.map +1 -0
  294. package/dist/mcp_view/screen.d.ts +30 -0
  295. package/dist/mcp_view/screen.js +245 -0
  296. package/dist/mcp_view/screen.js.map +1 -0
  297. package/dist/mcp_view/storage_source.d.ts +14 -0
  298. package/dist/mcp_view/storage_source.js +29 -0
  299. package/dist/mcp_view/storage_source.js.map +1 -0
  300. package/dist/mcp_view/store.d.ts +9 -0
  301. package/dist/mcp_view/store.js +27 -0
  302. package/dist/mcp_view/store.js.map +1 -0
  303. package/dist/mcp_view/tool_driver.d.ts +160 -0
  304. package/dist/mcp_view/tool_driver.js +575 -0
  305. package/dist/mcp_view/tool_driver.js.map +1 -0
  306. package/dist/preview/components/DatePreview.d.ts +34 -1
  307. package/dist/preview/components/DatePreview.js +72 -37
  308. package/dist/preview/components/DatePreview.js.map +1 -1
  309. package/dist/routes/RebaseRoute.js +1 -1
  310. package/dist/routes/RebaseRoute.js.map +1 -1
  311. package/dist/selection/SelectionMenu.d.ts +5 -3
  312. package/dist/selection/SelectionMenu.js +16 -9
  313. package/dist/selection/SelectionMenu.js.map +1 -1
  314. package/dist/selection/index.d.ts +2 -1
  315. package/dist/selection/resolve_selection.d.ts +61 -7
  316. package/dist/selection/resolve_selection.js +93 -11
  317. package/dist/selection/resolve_selection.js.map +1 -1
  318. package/dist/types/components/EntityFormProps.d.ts +60 -10
  319. package/dist/types/fields.d.ts +2 -65
  320. package/dist/util/dataControllerAdapter.d.ts +8 -0
  321. package/dist/util/dataControllerAdapter.js +11 -0
  322. package/dist/util/dataControllerAdapter.js.map +1 -1
  323. package/dist/util/navigation_utils.d.ts +5 -4
  324. package/dist/util/navigation_utils.js +6 -6
  325. package/dist/util/navigation_utils.js.map +1 -1
  326. package/dist/util/propertyConfigMapper.d.ts +8 -0
  327. package/dist/util/propertyConfigMapper.js +16 -2
  328. package/dist/util/propertyConfigMapper.js.map +1 -1
  329. package/package.json +15 -9
  330. package/recipes/README.md +79 -26
  331. package/recipes/approval-queue.tsx +79 -0
  332. package/recipes/bulk-set-status.tsx +23 -17
  333. package/recipes/calendar-view.tsx +28 -23
  334. package/recipes/master-detail.tsx +75 -0
  335. package/recipes/my-preferences.tsx +3 -3
  336. package/recipes/orders-dashboard.tsx +58 -84
  337. package/recipes/site-settings.tsx +4 -4
  338. package/dist/components/EntityFormPanel.d.ts +0 -63
  339. package/dist/components/EntityFormPanel.js.map +0 -1
@@ -0,0 +1,575 @@
1
+ import { isRecord } from "./bridge.js";
2
+ import { buildCompositeId, fieldKeyForColumn, getDeclaredPrimaryKeys, resolveCollectionRelations, resolvePrimaryKeys } from "@rebasepro/common";
3
+ import { toWireRow } from "@rebasepro/app";
4
+ import { DEFAULT_DATA_SOURCE_KEY } from "@rebasepro/types";
5
+ //#region src/mcp_view/tool_driver.ts
6
+ /**
7
+ * The admin panel's data layer, over the MCP tools of the server that served
8
+ * this view.
9
+ *
10
+ * `<Rebase>` reads and writes through a `DataDriver`; this one turns each read
11
+ * and write into a `tools/call` the host relays to the server — the same
12
+ * tools, the same person, the same RLS as the model's own calls. Rows go and
13
+ * come in the REST shape those tools speak (dates as ISO text, a belongsTo as
14
+ * its foreign key); `<Rebase>` turns them into the admin panel's view model
15
+ * and back, as it does for any driver.
16
+ *
17
+ * An app's row hooks (`useRows`, `useAggregate`, …) read the same driver
18
+ * through the flat data layer (`buildRebaseData`), which keeps the wire's
19
+ * rows and takes aggregates from `restFetchService`: here, the aggregate tool.
20
+ *
21
+ * A write the server answers with a plan (the hosted connector's two-step
22
+ * `write`) is held: the person is shown the plan and the write is sent again
23
+ * with its token only if they confirm. The row hooks write through
24
+ * `confirmingDriver`, which asks the person before any other write too: code
25
+ * can write without a click, while a save made with the admin's own controls
26
+ * was the person's click. Either way the admin panel sees one save that took
27
+ * a moment longer, or one that failed with "Not saved".
28
+ *
29
+ * The driver does not subscribe (no `listenCollection`/`listenOne`): every
30
+ * write it makes comes through `<Rebase>`'s data layers, which say so on the
31
+ * `<Rebase>`'s change signal, and each view of the collection reads again on
32
+ * it. It learns of no change it did not make — the host relays no other
33
+ * tool's calls — so it has nothing to announce either
34
+ * (`subscribeToExternalChanges`).
35
+ */
36
+ var DEFAULT_ACTIONS = {
37
+ page: {
38
+ tool: "query_collection",
39
+ arguments: {}
40
+ },
41
+ get: {
42
+ tool: "get_document",
43
+ arguments: {}
44
+ },
45
+ count: {
46
+ tool: "count_documents",
47
+ arguments: {}
48
+ },
49
+ create: {
50
+ tool: "create_document",
51
+ arguments: {}
52
+ },
53
+ update: {
54
+ tool: "update_document",
55
+ arguments: {}
56
+ },
57
+ delete: {
58
+ tool: "delete_document",
59
+ arguments: {}
60
+ },
61
+ aggregate: {
62
+ tool: "aggregate_documents",
63
+ arguments: {}
64
+ }
65
+ };
66
+ /** A save the person declined at the plan. The form shows it as the save's error. */
67
+ var SaveCancelledError = class extends Error {
68
+ constructor() {
69
+ super("Not saved: the change was not confirmed.");
70
+ this.name = "SaveCancelledError";
71
+ }
72
+ };
73
+ /** The ceiling every read tool takes for `limit` (`MAX_LIST_LIMIT`). */
74
+ var MAX_LIMIT = 1e3;
75
+ /**
76
+ * How long a row read, or the seeded page, answers in place of the server.
77
+ * Long enough for one render's relation previews and concurrent reads to
78
+ * share a call, and for a row the person picks off the page they are looking
79
+ * at to open with none; short enough that a row the model changed with its
80
+ * own tools — which takes the person's message and the model's turn — is
81
+ * read afresh when it is refreshed or opened again.
82
+ */
83
+ var READ_TTL_MS = 3e4;
84
+ function createToolDriver(options) {
85
+ const { callTool, actions, confirm, onChange } = options;
86
+ const configOf = options.collection ?? (() => void 0);
87
+ const canonical = (collection) => configOf(collection)?.slug ?? collection;
88
+ let seeds = [...options.seed ? [options.seed] : [], ...options.seeds ?? []].map((page) => ({
89
+ page,
90
+ pageTaken: false,
91
+ countTaken: page.total === void 0
92
+ }));
93
+ const seededAt = Date.now();
94
+ const changes = [];
95
+ const rows = /* @__PURE__ */ new Map();
96
+ const counting = /* @__PURE__ */ new Map();
97
+ const queued = /* @__PURE__ */ new Map();
98
+ let readsQueued = false;
99
+ const call = async (action, args) => {
100
+ const result = await callTool(action.tool, {
101
+ ...action.arguments,
102
+ ...args
103
+ });
104
+ if (result.isError) throw new Error(textOf(result) ?? "The server refused this call.");
105
+ return result.structuredContent ?? parseText(result);
106
+ };
107
+ /** A write, through its plan where the server asks for one. */
108
+ const write = async (action, args) => {
109
+ const first = await call(action, args);
110
+ const plan = planOf(first);
111
+ if (!plan) return first;
112
+ if (!await confirm(plan.plan)) throw new SaveCancelledError();
113
+ const second = await call(action, {
114
+ ...args,
115
+ confirm: plan.token
116
+ });
117
+ if (planOf(second)) throw new Error("The server asked for confirmation again; nothing was saved.");
118
+ return second;
119
+ };
120
+ /**
121
+ * What a write changed: what was read of its collection is dropped (the
122
+ * seeded page, the rows), and the model is told. The views read again on
123
+ * `<Rebase>`'s change signal, which the write's data layer emits.
124
+ */
125
+ const changed = (change) => {
126
+ seeds = [];
127
+ counting.clear();
128
+ const key = canonical(change.collection);
129
+ for (const row of rows.keys()) if (canonical(row.slice(0, row.lastIndexOf("/"))) === key) rows.delete(row);
130
+ changes.push(change);
131
+ onChange?.(changes);
132
+ };
133
+ /** A save's values as the write tools take them, by the collection's config where it is known. */
134
+ const wireValues = (props, collection) => {
135
+ return toWireRow(Object.fromEntries(Object.entries(props.values).filter(([, value]) => value !== void 0)), props.collection ?? configOf(collection) ?? NO_CONFIG, { included: false });
136
+ };
137
+ /**
138
+ * A page's rows into the row cache, keyed as {@link fetchOne} asks for
139
+ * them: the row a view lists is the row its record opens with, and a row
140
+ * an app was just shown opens with no call of its own. By the
141
+ * collection's key where its config is known, by `id` otherwise; a write
142
+ * to the collection drops them, as it drops every row read. Not a page
143
+ * that lists deleted rows: `get` answers none for those.
144
+ */
145
+ const remember = (collection, page, config) => {
146
+ const keys = config ? getDeclaredPrimaryKeys(config) : [];
147
+ for (const row of page) {
148
+ const id = keys.length > 1 ? buildCompositeId(row, keys) : row[keys[0]?.fieldName ?? "id"];
149
+ if (typeof id !== "string" && typeof id !== "number") continue;
150
+ rows.set(`${collection}/${String(id)}`, {
151
+ read: Promise.resolve(row),
152
+ at: Date.now()
153
+ });
154
+ }
155
+ };
156
+ for (const { page } of seeds) remember(page.collection, page.rows, configOf(page.collection));
157
+ /**
158
+ * The seeded page, once, to a read asking for exactly it — or for more
159
+ * of the same rows where the seed already holds every one: a view asks
160
+ * one row past its page to learn whether there are more, and a page
161
+ * shorter than its limit has answered that.
162
+ */
163
+ const takeSeed = (collection, args) => {
164
+ if (Date.now() - seededAt > READ_TTL_MS) seeds = [];
165
+ const seed = seeds.find((candidate) => !candidate.pageTaken && canonical(candidate.page.collection) === canonical(collection) && readKey(candidate.page.args) === readKey(args));
166
+ if (!seed) return void 0;
167
+ const seedLimit = limitOf(seed.page.args);
168
+ const readLimit = limitOf(args);
169
+ const complete = seedLimit === void 0 || seed.page.rows.length < seedLimit;
170
+ if (!(readLimit === seedLimit || complete && (readLimit === void 0 || seedLimit === void 0 || readLimit > seedLimit))) return void 0;
171
+ seed.pageTaken = true;
172
+ return seed.page.rows;
173
+ };
174
+ /** The count a seed's `total` answers — the collection's rows, unfiltered — once. */
175
+ const takeSeedCount = (collection, args) => {
176
+ if (Date.now() - seededAt > READ_TTL_MS) seeds = [];
177
+ if (args.where !== void 0 || args.searchString !== void 0 || args.deleted !== void 0) return void 0;
178
+ const seed = seeds.find((candidate) => !candidate.countTaken && canonical(candidate.page.collection) === canonical(collection) && candidate.page.args.where === void 0 && candidate.page.args.searchString === void 0);
179
+ if (!seed || seed.page.total === void 0) return void 0;
180
+ seed.countTaken = true;
181
+ return seed.page.total;
182
+ };
183
+ const fetchCollection = async (props) => {
184
+ const collection = collectionArg(props.path);
185
+ const args = readArgs(props);
186
+ let found = takeSeed(collection, args);
187
+ if (!found) {
188
+ const page = await call(actions.page, {
189
+ collection,
190
+ ...args
191
+ });
192
+ if (!isRecord(page) || !Array.isArray(page.data)) throw new Error("The read returned no rows.");
193
+ found = page.data.filter(isRecord);
194
+ }
195
+ if (!props.withDeleted) remember(collection, found, props.collection);
196
+ return found;
197
+ };
198
+ /**
199
+ * The rows asked for by key in one tick, read together: one page call per
200
+ * collection, `where <key> in [ids]`, however many relation previews a
201
+ * render draws — as the admin's `useBatchedFetch` reads them, chunked at
202
+ * the read tools' ceiling. A row the page does not carry is absent or not
203
+ * visible to the person: one answer for both, as the get tool gives.
204
+ */
205
+ const readQueued = () => {
206
+ readsQueued = false;
207
+ const batches = [...queued];
208
+ queued.clear();
209
+ for (const [collection, { key, reads }] of batches) {
210
+ const ids = [...reads.keys()];
211
+ for (let i = 0; i < ids.length; i += MAX_LIMIT) {
212
+ const chunk = ids.slice(i, i + MAX_LIMIT);
213
+ const values = chunk.map((id) => key.type === "number" && id.trim() !== "" && !Number.isNaN(Number(id)) ? Number(id) : id);
214
+ call(actions.page, {
215
+ collection,
216
+ where: { [key.fieldName]: ["in", values] },
217
+ limit: chunk.length
218
+ }).then((page) => {
219
+ if (!isRecord(page) || !Array.isArray(page.data)) throw new Error("The read returned no rows.");
220
+ const byId = new Map(page.data.filter(isRecord).map((row) => [String(row[key.fieldName]), row]));
221
+ for (const id of chunk) reads.get(id)?.resolve(byId.get(id));
222
+ }).catch((error) => {
223
+ for (const id of chunk) reads.get(id)?.reject(error);
224
+ });
225
+ }
226
+ }
227
+ };
228
+ const readByKey = (collection, id, key) => new Promise((resolve, reject) => {
229
+ let batch = queued.get(collection);
230
+ if (!batch) {
231
+ batch = {
232
+ key,
233
+ reads: /* @__PURE__ */ new Map()
234
+ };
235
+ queued.set(collection, batch);
236
+ }
237
+ batch.reads.set(id, {
238
+ resolve,
239
+ reject
240
+ });
241
+ if (!readsQueued) {
242
+ readsQueued = true;
243
+ queueMicrotask(readQueued);
244
+ }
245
+ });
246
+ /** A row of a collection with no single key column to put an `in` on, or none known: by the get tool. */
247
+ const readById = (collection, id) => call(actions.get, {
248
+ collection,
249
+ id
250
+ }).then((row) => isRecord(row) ? row : void 0).catch((error) => {
251
+ if (error instanceof Error && /^No row with id/.test(error.message)) return void 0;
252
+ throw error;
253
+ });
254
+ /**
255
+ * A row: by the page tool wherever its collection has one key column — a
256
+ * lone row as well as a crowd of previews. One rule, so a row is read the
257
+ * same way however many are drawn beside it; and the page tool is the one
258
+ * every server names (a hosted result may name no `get`), whose answer
259
+ * for an absent row is an empty page rather than an error told apart by
260
+ * its text.
261
+ */
262
+ const fetchOne = (props) => {
263
+ const collection = collectionArg(props.path);
264
+ const key = `${collection}/${String(props.id)}`;
265
+ const cached = rows.get(key);
266
+ if (cached && Date.now() - cached.at <= READ_TTL_MS) return cached.read;
267
+ const config = props.collection ?? configOf(collection);
268
+ const keys = config ? resolvePrimaryKeys(config) : [];
269
+ const read = (keys.length === 1 ? readByKey(collection, String(props.id), keys[0]) : readById(collection, String(props.id))).catch((error) => {
270
+ if (rows.get(key)?.read === read) rows.delete(key);
271
+ throw error;
272
+ });
273
+ rows.set(key, {
274
+ read,
275
+ at: Date.now()
276
+ });
277
+ return read;
278
+ };
279
+ const driver = {
280
+ key: DEFAULT_DATA_SOURCE_KEY,
281
+ initialised: true,
282
+ fetchCollection,
283
+ fetchOne,
284
+ restFetchService: {
285
+ fetchCollectionForRest(path, options = {}) {
286
+ refuseUnsupported(options);
287
+ return fetchCollection({
288
+ path,
289
+ ...options.filter && { filter: options.filter },
290
+ ...options.orderBy !== void 0 && { orderBy: options.orderBy },
291
+ ...options.order && { order: options.order },
292
+ ...options.limit !== void 0 && { limit: options.limit },
293
+ ...options.offset !== void 0 && { offset: options.offset },
294
+ ...options.searchString && { searchString: options.searchString },
295
+ ...options.withDeleted !== void 0 && { withDeleted: options.withDeleted }
296
+ });
297
+ },
298
+ async fetchOneForRest(path, id) {
299
+ return await fetchOne({
300
+ path,
301
+ id
302
+ }) ?? null;
303
+ },
304
+ async aggregate(path, options) {
305
+ refuseUnsupported(options);
306
+ const where = options.filter ? wireFilter(options.filter, void 0) : void 0;
307
+ const answer = await call(actions.aggregate, {
308
+ collection: collectionArg(path),
309
+ select: options.aggregates.map((aggregate) => aggregate.fn === "percentile" ? `${aggregate.fn}(${aggregate.field ?? ""},${aggregate.p})` : `${aggregate.fn}(${aggregate.field ?? ""})`),
310
+ ...options.groupBy && options.groupBy.length > 0 && { groupBy: options.groupBy.map((group) => typeof group === "string" ? group : `${group.transform}(${group.field})`) },
311
+ ...where && Object.keys(where).length > 0 && { where },
312
+ ...options.searchString && { searchString: options.searchString },
313
+ ...options.orderBy && options.orderBy.length > 0 && { orderBy: options.orderBy },
314
+ ...options.limit !== void 0 && { limit: Math.min(options.limit, MAX_LIMIT) },
315
+ ...options.offset && { offset: options.offset },
316
+ ...options.withDeleted && { deleted: options.withDeleted === "only" ? "only" : "include" }
317
+ });
318
+ if (!isRecord(answer) || !Array.isArray(answer.data)) throw new Error("The aggregate returned no rows.");
319
+ return answer.data.filter(isRecord);
320
+ }
321
+ },
322
+ async save(props) {
323
+ const collection = collectionArg(props.path);
324
+ const data = wireValues(props, collection);
325
+ const creating = props.status !== "existing";
326
+ const action = creating ? actions.create : actions.update;
327
+ const saved = creating ? await write(action, {
328
+ collection,
329
+ data,
330
+ ...props.id !== void 0 && { id: String(props.id) }
331
+ }) : await write(action, {
332
+ collection,
333
+ id: String(props.id),
334
+ data
335
+ });
336
+ const row = isRecord(saved) ? saved : { ...data };
337
+ const id = String(row.id ?? props.id ?? "");
338
+ const label = options.rowLabel?.(collection, id, row);
339
+ changed({
340
+ action: creating ? "created" : "updated",
341
+ collection,
342
+ id,
343
+ ...label && { label },
344
+ fields: Object.keys(data)
345
+ });
346
+ return row;
347
+ },
348
+ async delete(props) {
349
+ const collection = collectionArg(props.row.path);
350
+ const id = String(props.row.id);
351
+ const cached = await rows.get(`${collection}/${id}`)?.read.catch(() => void 0);
352
+ const label = options.rowLabel?.(collection, id, cached ?? void 0);
353
+ await write(actions.delete, {
354
+ collection,
355
+ id
356
+ });
357
+ changed({
358
+ action: "deleted",
359
+ collection,
360
+ id,
361
+ ...label && { label }
362
+ });
363
+ },
364
+ async count(props) {
365
+ const collection = collectionArg(props.path);
366
+ const args = pickRead(readArgs(props), [
367
+ "where",
368
+ "searchString",
369
+ "deleted"
370
+ ]);
371
+ const seeded = takeSeedCount(collection, args);
372
+ if (seeded !== void 0) return seeded;
373
+ const key = `${canonical(collection)}|${readKey(args)}`;
374
+ const inFlight = counting.get(key);
375
+ if (inFlight) return inFlight;
376
+ const counted = call(actions.count, {
377
+ collection,
378
+ ...args
379
+ }).then((answer) => {
380
+ if (isRecord(answer) && typeof answer.count === "number") return answer.count;
381
+ throw new Error("The count returned no number.");
382
+ }).finally(() => {
383
+ if (counting.get(key) === counted) counting.delete(key);
384
+ });
385
+ counting.set(key, counted);
386
+ return counted;
387
+ },
388
+ async checkUniqueField() {
389
+ return true;
390
+ }
391
+ };
392
+ /** The person's yes before a write the tool does not plan; their no rejects, and nothing is sent. */
393
+ const confirmFirst = async (action, plan) => {
394
+ if (!action.plans && !await confirm(plan)) throw new SaveCancelledError();
395
+ };
396
+ /** A row as the person knows it: its title where it has been read, else `row <id>`. */
397
+ const labelOf = async (collection, id) => {
398
+ const row = await rows.get(`${collection}/${id}`)?.read.catch(() => void 0);
399
+ return options.rowLabel?.(collection, id, row ?? void 0) || `row ${id}`;
400
+ };
401
+ /** A refused write, told; the rejection still reaches the caller. */
402
+ const reported = async (failure, write) => {
403
+ try {
404
+ return await write();
405
+ } catch (error) {
406
+ if (!(error instanceof SaveCancelledError)) options.onWriteFailed?.({
407
+ ...failure,
408
+ message: error instanceof Error ? error.message : String(error)
409
+ });
410
+ throw error;
411
+ }
412
+ };
413
+ return {
414
+ driver,
415
+ confirmingDriver: {
416
+ ...driver,
417
+ async save(props) {
418
+ const collection = collectionArg(props.path);
419
+ const creating = props.status !== "existing";
420
+ const row = creating ? void 0 : await labelOf(collection, String(props.id));
421
+ await confirmFirst(creating ? actions.create : actions.update, creating ? { summary: `Create a row in ${collection}.` } : { summary: `Change ${Object.keys(wireValues(props, collection)).join(", ")} on ${row} of ${collection}.` });
422
+ return reported({
423
+ action: creating ? "create" : "update",
424
+ collection,
425
+ ...row && { row }
426
+ }, () => driver.save(props));
427
+ },
428
+ async delete(props) {
429
+ const collection = collectionArg(props.row.path);
430
+ const row = await labelOf(collection, String(props.row.id));
431
+ await confirmFirst(actions.delete, { summary: `Delete ${row} of ${collection}.` });
432
+ return reported({
433
+ action: "delete",
434
+ collection,
435
+ row
436
+ }, () => driver.delete(props));
437
+ }
438
+ }
439
+ };
440
+ }
441
+ /**
442
+ * The collection a driver path names. The views open top-level collections
443
+ * only; a subcollection path has no tool to read it.
444
+ */
445
+ function collectionArg(path) {
446
+ if (path.includes("/")) throw new Error(`"${path}" is a subcollection, which this view cannot open.`);
447
+ return path;
448
+ }
449
+ /** A read's arguments, as the read tools take them. */
450
+ function readArgs(props) {
451
+ const where = props.filter ? wireFilter(props.filter, props.collection) : void 0;
452
+ const orderBy = wireOrderBy(props, props.collection);
453
+ return {
454
+ ...where && Object.keys(where).length > 0 && { where },
455
+ ...orderBy && { orderBy },
456
+ ...props.searchString && { searchString: props.searchString },
457
+ ...props.limit !== void 0 && { limit: Math.min(props.limit, MAX_LIMIT) },
458
+ ...props.offset && { offset: props.offset },
459
+ ...props.withDeleted !== void 0 && props.withDeleted !== false && { deleted: props.withDeleted === "only" ? "only" : "include" }
460
+ };
461
+ }
462
+ /** What the read tools cannot express, refused rather than read wider than asked. */
463
+ function refuseUnsupported(options) {
464
+ if (options.logical) throw new Error("This view's tools cannot filter by an or()/and() group.");
465
+ if (options.vectorSearch) throw new Error("This view's tools cannot run a vector search.");
466
+ }
467
+ /**
468
+ * Which rows a read asks for, as one comparable string: the same rows however
469
+ * the read was written — a sort as `"field:desc"` or `[["field", "desc"]]`, a
470
+ * filter's fields in any order, no offset or offset 0. How many is
471
+ * {@link limitOf}'s.
472
+ */
473
+ function readKey(args) {
474
+ const where = isRecord(args.where) ? args.where : {};
475
+ return JSON.stringify([
476
+ Object.keys(where).sort().map((key) => [key, where[key]]),
477
+ sortOf(args.orderBy),
478
+ typeof args.searchString === "string" ? args.searchString : "",
479
+ typeof args.offset === "number" ? args.offset : 0,
480
+ typeof args.deleted === "string" ? args.deleted : null
481
+ ]);
482
+ }
483
+ function limitOf(args) {
484
+ return typeof args.limit === "number" ? args.limit : void 0;
485
+ }
486
+ function sortOf(orderBy) {
487
+ if (typeof orderBy === "string" && orderBy !== "") {
488
+ const [field, direction] = orderBy.split(":");
489
+ return [[field, direction === "desc" ? "desc" : "asc"]];
490
+ }
491
+ if (!Array.isArray(orderBy) || orderBy.length === 0) return [];
492
+ return (Array.isArray(orderBy[0]) ? orderBy : [orderBy]).map((entry) => Array.isArray(entry) ? [entry[0], entry[1] === "desc" ? "desc" : "asc"] : entry);
493
+ }
494
+ function pickRead(args, names) {
495
+ return Object.fromEntries(Object.entries(args).filter(([name]) => names.includes(name)));
496
+ }
497
+ /**
498
+ * The admin panel's filter as the read tools' `where`: a belongsTo is
499
+ * filtered by its foreign key there, and a value is the wire's — a relation
500
+ * its id, a date its ISO text.
501
+ */
502
+ function wireFilter(filter, collection) {
503
+ const keys = foreignKeys(collection);
504
+ const where = {};
505
+ for (const [key, condition] of Object.entries(filter)) {
506
+ if (condition === void 0) continue;
507
+ where[keys.get(key) ?? key] = toWireRow({ condition }, NO_CONFIG).condition;
508
+ }
509
+ return where;
510
+ }
511
+ /** No properties, so {@link toWireRow} converts each value by what it is: a relation to its id, a date to ISO text. */
512
+ var NO_CONFIG = {
513
+ slug: "",
514
+ name: "",
515
+ properties: {}
516
+ };
517
+ function wireOrderBy(props, collection) {
518
+ const keys = foreignKeys(collection);
519
+ if (typeof props.orderBy === "string") {
520
+ const field = keys.get(props.orderBy) ?? props.orderBy;
521
+ return props.order ? `${field}:${props.order}` : field;
522
+ }
523
+ if (Array.isArray(props.orderBy) && props.orderBy.length > 0) return props.orderBy.map((entry) => Array.isArray(entry) && typeof entry[0] === "string" ? [keys.get(entry[0]) ?? entry[0], ...entry.slice(1)] : entry);
524
+ }
525
+ /** A collection's belongsTo relations, by name → the foreign key its rows carry. */
526
+ function foreignKeys(collection) {
527
+ const keys = /* @__PURE__ */ new Map();
528
+ if (!collection) return keys;
529
+ try {
530
+ for (const [name, relation] of Object.entries(resolveCollectionRelations(collection))) if (relation.kind === "belongsTo" && relation.localKey) keys.set(name, fieldKeyForColumn(collection, relation.localKey));
531
+ } catch {}
532
+ return keys;
533
+ }
534
+ /** A write's plan and token, where its first call answered one (the server's `confirmation.ts`). */
535
+ function planOf(answer) {
536
+ if (!isRecord(answer) || answer.status !== "confirmation_required" || typeof answer.confirm !== "string") return void 0;
537
+ const plan = isRecord(answer.plan) ? answer.plan : {};
538
+ return {
539
+ token: answer.confirm,
540
+ plan: {
541
+ summary: typeof plan.summary === "string" ? plan.summary : "Save this change?",
542
+ ...Array.isArray(plan.effects) && { effects: plan.effects.filter((line) => typeof line === "string") },
543
+ ...typeof plan.reversible === "string" && { reversible: plan.reversible }
544
+ }
545
+ };
546
+ }
547
+ /** A result with no `structuredContent`: its text, as JSON where it is JSON. */
548
+ function parseText(result) {
549
+ const text = textOf(result);
550
+ if (text === void 0) return void 0;
551
+ const start = text.indexOf("{");
552
+ const end = text.lastIndexOf("}");
553
+ if (start < 0 || end < start) return void 0;
554
+ try {
555
+ return JSON.parse(text.slice(start, end + 1));
556
+ } catch {
557
+ return;
558
+ }
559
+ }
560
+ function textOf(result) {
561
+ return result.content?.find((block) => typeof block.text === "string")?.text;
562
+ }
563
+ /** What the model is told the person changed here, sent with their next message. */
564
+ /** "update ORD-2026-0081 in orders", "create a row in orders". */
565
+ function describeFailedWrite(failure) {
566
+ return failure.action === "create" ? `create a row in ${failure.collection}` : `${failure.action} ${failure.row ?? "a row"} in ${failure.collection}`;
567
+ }
568
+ function describeChanges(changes) {
569
+ const rowOf = (change) => change.label ? `${change.label} (row ${change.id})` : `row ${change.id}`;
570
+ return `In the Rebase view, the user saved these changes: ${changes.map((change) => change.action === "updated" ? `updated ${change.fields?.join(", ") || "fields"} on ${rowOf(change)} of ${change.collection}` : `${change.action} ${rowOf(change)} of ${change.collection}`).join("; ")}. Rows you read before them may be out of date.`;
571
+ }
572
+ //#endregion
573
+ export { DEFAULT_ACTIONS, SaveCancelledError, createToolDriver, describeChanges, describeFailedWrite, textOf };
574
+
575
+ //# sourceMappingURL=tool_driver.js.map