@rebasepro/cms 0.23.0 → 0.24.1-canary.g19596ef

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 (840) hide show
  1. package/README.md +3 -1
  2. package/dist/collection_editor/CollectionEditorDialogsContext.js +10 -0
  3. package/dist/collection_editor/CollectionEditorDialogsContext.js.map +1 -0
  4. package/dist/collection_editor/ConfigControllerProvider.js +274 -0
  5. package/dist/collection_editor/ConfigControllerProvider.js.map +1 -0
  6. package/dist/collection_editor/_cms_internals.d.ts +2 -1
  7. package/dist/collection_editor/api/generateCollectionApi.js +64 -0
  8. package/dist/collection_editor/api/generateCollectionApi.js.map +1 -0
  9. package/dist/collection_editor/collection_wire.d.ts +13 -0
  10. package/dist/collection_editor/collection_wire.js +49 -0
  11. package/dist/collection_editor/collection_wire.js.map +1 -0
  12. package/dist/collection_editor/liveSchemaClient.d.ts +38 -18
  13. package/dist/collection_editor/liveSchemaClient.js +130 -0
  14. package/dist/collection_editor/liveSchemaClient.js.map +1 -0
  15. package/dist/collection_editor/relation_kinds.js +74 -0
  16. package/dist/collection_editor/relation_kinds.js.map +1 -0
  17. package/dist/collection_editor/serializable_types.d.ts +6 -1
  18. package/dist/collection_editor/serializable_utils.js +504 -0
  19. package/dist/collection_editor/serializable_utils.js.map +1 -0
  20. package/dist/collection_editor/types/config_controller.d.ts +11 -0
  21. package/dist/collection_editor/ui/EditorCollectionAction.js +37 -0
  22. package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -0
  23. package/dist/collection_editor/ui/MissingReferenceWidget.js +39 -0
  24. package/dist/collection_editor/ui/MissingReferenceWidget.js.map +1 -0
  25. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +160 -0
  26. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -0
  27. package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js +61 -0
  28. package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js.map +1 -0
  29. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +731 -0
  30. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -0
  31. package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js +220 -0
  32. package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js.map +1 -0
  33. package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js +160 -0
  34. package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js.map +1 -0
  35. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +394 -0
  36. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -0
  37. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +616 -0
  38. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -0
  39. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js +68 -0
  40. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js.map +1 -0
  41. package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js +11 -0
  42. package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js.map +1 -0
  43. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js +148 -0
  44. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js.map +1 -0
  45. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js +244 -0
  46. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -0
  47. package/dist/collection_editor/ui/collection_editor/EnumForm.js +222 -0
  48. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -0
  49. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +204 -0
  50. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -0
  51. package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js +108 -0
  52. package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js.map +1 -0
  53. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js +163 -0
  54. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -0
  55. package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js +59 -0
  56. package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js.map +1 -0
  57. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +640 -0
  58. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -0
  59. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +141 -0
  60. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -0
  61. package/dist/collection_editor/ui/collection_editor/PropertyTree.js +210 -0
  62. package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -0
  63. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js +31 -0
  64. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js.map +1 -0
  65. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js +25 -0
  66. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js.map +1 -0
  67. package/dist/{SchemaChangeDialog-BeP0A4MJ.js → collection_editor/ui/collection_editor/SchemaChangeDialog.js} +73 -69
  68. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -0
  69. package/dist/collection_editor/ui/collection_editor/SwitchControl.js +24 -0
  70. package/dist/collection_editor/ui/collection_editor/SwitchControl.js.map +1 -0
  71. package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js +66 -0
  72. package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js.map +1 -0
  73. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +61 -0
  74. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -0
  75. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js +188 -0
  76. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -0
  77. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +12 -0
  78. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js +74 -0
  79. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -0
  80. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js +100 -0
  81. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -0
  82. package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js +34 -0
  83. package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js.map +1 -0
  84. package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js +75 -0
  85. package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js.map +1 -0
  86. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +338 -0
  87. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -0
  88. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +83 -0
  89. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -0
  90. package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js +15 -0
  91. package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js.map +1 -0
  92. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js +121 -0
  93. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -0
  94. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +127 -0
  95. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -0
  96. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +151 -0
  97. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -0
  98. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js +77 -0
  99. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -0
  100. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js +254 -0
  101. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -0
  102. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js +71 -0
  103. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -0
  104. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +356 -0
  105. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -0
  106. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +173 -0
  107. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -0
  108. package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js +79 -0
  109. package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js.map +1 -0
  110. package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js +34 -0
  111. package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js.map +1 -0
  112. package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js +47 -0
  113. package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js.map +1 -0
  114. package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js +47 -0
  115. package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js.map +1 -0
  116. package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js +62 -0
  117. package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js.map +1 -0
  118. package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js +119 -0
  119. package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js.map +1 -0
  120. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.d.ts +10 -0
  121. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js +178 -0
  122. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js.map +1 -0
  123. package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js +23 -0
  124. package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js.map +1 -0
  125. package/dist/collection_editor/ui/collection_editor/templates/blog_template.js +116 -0
  126. package/dist/collection_editor/ui/collection_editor/templates/blog_template.js.map +1 -0
  127. package/dist/collection_editor/ui/collection_editor/templates/pages_template.js +182 -0
  128. package/dist/collection_editor/ui/collection_editor/templates/pages_template.js.map +1 -0
  129. package/dist/collection_editor/ui/collection_editor/templates/products_template.js +87 -0
  130. package/dist/collection_editor/ui/collection_editor/templates/products_template.js.map +1 -0
  131. package/dist/collection_editor/ui/collection_editor/templates/users_template.js +46 -0
  132. package/dist/collection_editor/ui/collection_editor/templates/users_template.js.map +1 -0
  133. package/dist/collection_editor/ui/collection_editor/util.js +20 -0
  134. package/dist/collection_editor/ui/collection_editor/util.js.map +1 -0
  135. package/dist/collection_editor/ui/collection_editor/utils/strings.js +2 -0
  136. package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js +37 -0
  137. package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js.map +1 -0
  138. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js +192 -0
  139. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -0
  140. package/dist/collection_editor/useCollectionEditorController.js +12 -0
  141. package/dist/collection_editor/useCollectionEditorController.js.map +1 -0
  142. package/dist/collection_editor/useCollectionsConfigController.js +12 -0
  143. package/dist/collection_editor/useCollectionsConfigController.js.map +1 -0
  144. package/dist/collection_editor/useJsonCollectionsConfigController.js +191 -0
  145. package/dist/collection_editor/useJsonCollectionsConfigController.js.map +1 -0
  146. package/dist/collection_editor/useLiveSchemaEditing.d.ts +5 -5
  147. package/dist/collection_editor/useLiveSchemaEditing.js +214 -0
  148. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -0
  149. package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +7 -0
  150. package/dist/collection_editor/useLocalCollectionsConfigController.js +228 -0
  151. package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -0
  152. package/dist/collection_editor/useSafeSnackbarController.js +13 -0
  153. package/dist/collection_editor/useSafeSnackbarController.js.map +1 -0
  154. package/dist/collection_editor/validateCollectionJson.js +289 -0
  155. package/dist/collection_editor/validateCollectionJson.js.map +1 -0
  156. package/dist/collection_editor_ui.js +7 -33
  157. package/dist/components/AdditionalFieldValue.js +60 -0
  158. package/dist/components/AdditionalFieldValue.js.map +1 -0
  159. package/dist/components/AdminModeSyncer.js +41 -0
  160. package/dist/components/AdminModeSyncer.js.map +1 -0
  161. package/dist/components/ArrayContainer.d.ts +8 -2
  162. package/dist/components/ArrayContainer.js +363 -0
  163. package/dist/components/ArrayContainer.js.map +1 -0
  164. package/dist/components/ClearFilterSortButton.d.ts +7 -1
  165. package/dist/components/ClearFilterSortButton.js +33 -0
  166. package/dist/components/ClearFilterSortButton.js.map +1 -0
  167. package/dist/components/CollectionEditorDialogs.js +49 -0
  168. package/dist/components/CollectionEditorDialogs.js.map +1 -0
  169. package/dist/components/CollectionPanel.d.ts +26 -5
  170. package/dist/components/CollectionPanel.js +142 -0
  171. package/dist/components/CollectionPanel.js.map +1 -0
  172. package/dist/components/CollectionTableBinding/CollectionRowActions.js +165 -0
  173. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -0
  174. package/dist/components/CollectionTableBinding/CollectionTableBinding.js +329 -0
  175. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -0
  176. package/dist/components/CollectionTableBinding/PropertyTableCell.js +311 -0
  177. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -0
  178. package/dist/components/CollectionTableBinding/column_utils.js +85 -0
  179. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -0
  180. package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js +45 -0
  181. package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js.map +1 -0
  182. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +66 -0
  183. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -0
  184. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +86 -0
  185. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -0
  186. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +93 -0
  187. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -0
  188. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js +33 -0
  189. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -0
  190. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +171 -0
  191. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -0
  192. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +91 -0
  193. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -0
  194. package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js +36 -0
  195. package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js.map +1 -0
  196. package/dist/components/CollectionTableBinding/index.js +6 -0
  197. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +50 -0
  198. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -0
  199. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +2 -0
  200. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js +223 -0
  201. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -0
  202. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +58 -0
  203. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -0
  204. package/dist/components/CollectionTableBinding/internal/TableCellOpener.js +53 -0
  205. package/dist/components/CollectionTableBinding/internal/TableCellOpener.js.map +1 -0
  206. package/dist/components/CollectionTableBinding/internal/common.js +40 -0
  207. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -0
  208. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +270 -0
  209. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -0
  210. package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js +68 -0
  211. package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js.map +1 -0
  212. package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js +24 -0
  213. package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js.map +1 -0
  214. package/dist/components/CollectionTableBinding/table_bindings.js +306 -0
  215. package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -0
  216. package/dist/components/CollectionViewBinding/BoardCardBinding.js +160 -0
  217. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -0
  218. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +471 -0
  219. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -0
  220. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +108 -0
  221. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -0
  222. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +988 -0
  223. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -0
  224. package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +6 -1
  225. package/dist/components/CollectionViewBinding/CollectionViewActions.js +146 -0
  226. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -0
  227. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +5 -2
  228. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +1209 -0
  229. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -0
  230. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +133 -0
  231. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -0
  232. package/dist/components/CollectionViewBinding/EntityCardBinding.js +133 -0
  233. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -0
  234. package/dist/components/CollectionViewBinding/FilterPresetsButton.js +203 -0
  235. package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -0
  236. package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +5 -0
  237. package/dist/components/CollectionViewBinding/FiltersDialog.js +148 -0
  238. package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -0
  239. package/dist/components/CollectionViewBinding/SearchExplanation.js +86 -0
  240. package/dist/components/CollectionViewBinding/SearchExplanation.js.map +1 -0
  241. package/dist/components/CollectionViewBinding/SearchHighlight.js +262 -0
  242. package/dist/components/CollectionViewBinding/SearchHighlight.js.map +1 -0
  243. package/dist/components/CollectionViewBinding/SlotValue.js +117 -0
  244. package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -0
  245. package/dist/components/CollectionViewBinding/SortButton.js +214 -0
  246. package/dist/components/CollectionViewBinding/SortButton.js.map +1 -0
  247. package/dist/components/CollectionViewBinding/SplitListCloseButton.js +41 -0
  248. package/dist/components/CollectionViewBinding/SplitListCloseButton.js.map +1 -0
  249. package/dist/components/CollectionViewBinding/SplitListShowButton.js +29 -0
  250. package/dist/components/CollectionViewBinding/SplitListShowButton.js.map +1 -0
  251. package/dist/components/CollectionViewBinding/SplitListView.js +311 -0
  252. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -0
  253. package/dist/components/CollectionViewBinding/SplitViewContext.js +21 -0
  254. package/dist/components/CollectionViewBinding/SplitViewContext.js.map +1 -0
  255. package/dist/components/CollectionViewBinding/ViewModeToggle.js +150 -0
  256. package/dist/components/CollectionViewBinding/ViewModeToggle.js.map +1 -0
  257. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +49 -0
  258. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -0
  259. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js +122 -0
  260. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -0
  261. package/dist/components/CollectionViewBinding/useBoardDataController.js +530 -0
  262. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -0
  263. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +4 -1
  264. package/dist/components/CollectionViewBinding/usePreviewSlots.js +384 -0
  265. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -0
  266. package/dist/components/CollectionViewBinding/useSelectionController.js +104 -0
  267. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -0
  268. package/dist/components/CollectionViewBinding/utils.js +21 -0
  269. package/dist/components/CollectionViewBinding/utils.js.map +1 -0
  270. package/dist/components/CollectionsProvider.d.ts +44 -0
  271. package/dist/components/CollectionsProvider.js +137 -0
  272. package/dist/components/CollectionsProvider.js.map +1 -0
  273. package/dist/components/CollectionsScopeContext.d.ts +18 -0
  274. package/dist/components/CollectionsScopeContext.js +25 -0
  275. package/dist/components/CollectionsScopeContext.js.map +1 -0
  276. package/dist/components/DefaultAppBar.js +179 -0
  277. package/dist/components/DefaultAppBar.js.map +1 -0
  278. package/dist/components/DefaultDrawer.js +364 -0
  279. package/dist/components/DefaultDrawer.js.map +1 -0
  280. package/dist/components/DeleteEntityDialog.js +256 -0
  281. package/dist/components/DeleteEntityDialog.js.map +1 -0
  282. package/dist/components/DetailViewBinding.js +504 -0
  283. package/dist/components/DetailViewBinding.js.map +1 -0
  284. package/dist/components/DrawerNavigationGroup.js +74 -0
  285. package/dist/components/DrawerNavigationGroup.js.map +1 -0
  286. package/dist/components/DrawerNavigationItem.d.ts +8 -0
  287. package/dist/components/DrawerNavigationItem.js +45 -0
  288. package/dist/components/DrawerNavigationItem.js.map +1 -0
  289. package/dist/components/EditFormActions.js +210 -0
  290. package/dist/components/EditFormActions.js.map +1 -0
  291. package/dist/components/EditViewBinding.d.ts +7 -1
  292. package/dist/components/EditViewBinding.js +802 -0
  293. package/dist/components/EditViewBinding.js.map +1 -0
  294. package/dist/components/EntityDisplayHeader.js +139 -0
  295. package/dist/components/EntityDisplayHeader.js.map +1 -0
  296. package/dist/components/EntityFormPanel.d.ts +58 -0
  297. package/dist/components/EntityFormPanel.js +126 -0
  298. package/dist/components/EntityFormPanel.js.map +1 -0
  299. package/dist/components/EntityIdentityBar.d.ts +29 -4
  300. package/dist/components/EntityIdentityBar.js +364 -0
  301. package/dist/components/EntityIdentityBar.js.map +1 -0
  302. package/dist/components/EntityInspector.js +96 -0
  303. package/dist/components/EntityInspector.js.map +1 -0
  304. package/dist/components/EntityPreviewBinding.js +282 -0
  305. package/dist/components/EntityPreviewBinding.js.map +1 -0
  306. package/dist/components/EntityPreviewNesting.js +53 -0
  307. package/dist/components/EntityPreviewNesting.js.map +1 -0
  308. package/dist/components/EntityViewBinding.js +246 -0
  309. package/dist/components/EntityViewBinding.js.map +1 -0
  310. package/dist/components/FieldCaption.js +17 -0
  311. package/dist/components/FieldCaption.js.map +1 -0
  312. package/dist/components/HomePage/ContentHomePage.js +326 -0
  313. package/dist/components/HomePage/ContentHomePage.js.map +1 -0
  314. package/dist/components/HomePage/FavouritesView.js +44 -0
  315. package/dist/components/HomePage/FavouritesView.js.map +1 -0
  316. package/dist/components/HomePage/HomePageDnD.js +436 -0
  317. package/dist/components/HomePage/HomePageDnD.js.map +1 -0
  318. package/dist/components/HomePage/NavigationCard.js +59 -0
  319. package/dist/components/HomePage/NavigationCard.js.map +1 -0
  320. package/dist/components/HomePage/NavigationCardBinding.js +70 -0
  321. package/dist/components/HomePage/NavigationCardBinding.js.map +1 -0
  322. package/dist/components/HomePage/NavigationGroup.js +98 -0
  323. package/dist/components/HomePage/NavigationGroup.js.map +1 -0
  324. package/dist/components/HomePage/RenameGroupDialog.js +89 -0
  325. package/dist/components/HomePage/RenameGroupDialog.js.map +1 -0
  326. package/dist/components/InlineEntityPreview.js +116 -0
  327. package/dist/components/InlineEntityPreview.js.map +1 -0
  328. package/dist/{JsonPreviewBinding-v0w3H0fp.js → components/JsonPreviewBinding.js} +2 -2
  329. package/dist/components/JsonPreviewBinding.js.map +1 -0
  330. package/dist/components/NavigationLoadingErrorView.d.ts +16 -0
  331. package/dist/components/NavigationLoadingErrorView.js +27 -0
  332. package/dist/components/NavigationLoadingErrorView.js.map +1 -0
  333. package/dist/components/PickerTrigger.js +27 -0
  334. package/dist/components/PickerTrigger.js.map +1 -0
  335. package/dist/components/PropertyCollectionView.js +215 -0
  336. package/dist/components/PropertyCollectionView.js.map +1 -0
  337. package/dist/components/PropertyConfigBadge.js +19 -0
  338. package/dist/components/PropertyConfigBadge.js.map +1 -0
  339. package/dist/components/PropertyKeyHint.js +58 -0
  340. package/dist/components/PropertyKeyHint.js.map +1 -0
  341. package/dist/components/RebaseAuthGate.js +35 -0
  342. package/dist/components/RebaseAuthGate.js.map +1 -0
  343. package/dist/components/RebaseCMS.js +44 -0
  344. package/dist/components/RebaseCMS.js.map +1 -0
  345. package/dist/components/RebaseLayout.js +59 -0
  346. package/dist/components/RebaseLayout.js.map +1 -0
  347. package/dist/components/RebaseNavigation.js +215 -0
  348. package/dist/components/RebaseNavigation.js.map +1 -0
  349. package/dist/components/RebaseRouteDefs.js +96 -0
  350. package/dist/components/RebaseRouteDefs.js.map +1 -0
  351. package/dist/components/RebaseShell.js +50 -0
  352. package/dist/components/RebaseShell.js.map +1 -0
  353. package/dist/components/ReferenceTable/SelectionTableBinding.js +224 -0
  354. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -0
  355. package/dist/components/ReferenceWidget.js +100 -0
  356. package/dist/components/ReferenceWidget.js.map +1 -0
  357. package/dist/components/RelationSelector.js +625 -0
  358. package/dist/components/RelationSelector.js.map +1 -0
  359. package/dist/components/SearchIconsView.js +52 -0
  360. package/dist/components/SearchIconsView.js.map +1 -0
  361. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  362. package/dist/components/SelectableTable/SelectableTable.js +158 -0
  363. package/dist/components/SelectableTable/SelectableTable.js.map +1 -0
  364. package/dist/components/SelectableTable/SelectableTableContext.js +8 -0
  365. package/dist/components/SelectableTable/SelectableTableContext.js.map +1 -0
  366. package/dist/components/SelectableTable/SelectionStore.js +29 -0
  367. package/dist/components/SelectableTable/SelectionStore.js.map +1 -0
  368. package/dist/components/SelectableTable/filters/BooleanFilterField.js +28 -0
  369. package/dist/components/SelectableTable/filters/BooleanFilterField.js.map +1 -0
  370. package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
  371. package/dist/components/SelectableTable/filters/DateTimeFilterField.js +93 -0
  372. package/dist/components/SelectableTable/filters/DateTimeFilterField.js.map +1 -0
  373. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +132 -0
  374. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -0
  375. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +157 -0
  376. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -0
  377. package/dist/components/SelectableTable/filters/RelationFilterField.js +169 -0
  378. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -0
  379. package/dist/components/SelectableTable/filters/StringNumberFilterField.js +181 -0
  380. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -0
  381. package/dist/components/SelectableTable/filters/null_filter.js +36 -0
  382. package/dist/components/SelectableTable/filters/null_filter.js.map +1 -0
  383. package/dist/components/SideDialogs.js +149 -0
  384. package/dist/components/SideDialogs.js.map +1 -0
  385. package/dist/components/SidePanelBinding.js +287 -0
  386. package/dist/components/SidePanelBinding.js.map +1 -0
  387. package/dist/components/SidePanelProvider.js +69 -0
  388. package/dist/components/SidePanelProvider.js.map +1 -0
  389. package/dist/components/UserSelector.d.ts +2 -0
  390. package/dist/components/UserSelector.js +418 -0
  391. package/dist/components/UserSelector.js.map +1 -0
  392. package/dist/components/admin/CreationResultDialog.js +118 -0
  393. package/dist/components/admin/CreationResultDialog.js.map +1 -0
  394. package/dist/components/app/AppBar.js +14 -0
  395. package/dist/components/app/AppBar.js.map +1 -0
  396. package/dist/components/app/Drawer.js +26 -0
  397. package/dist/components/app/Drawer.js.map +1 -0
  398. package/dist/components/app/Scaffold.js +229 -0
  399. package/dist/components/app/Scaffold.js.map +1 -0
  400. package/dist/components/app/useApp.js +24 -0
  401. package/dist/components/app/useApp.js.map +1 -0
  402. package/dist/components/common/ActionMenuLabel.d.ts +15 -0
  403. package/dist/components/common/ActionMenuLabel.js +30 -0
  404. package/dist/components/common/ActionMenuLabel.js.map +1 -0
  405. package/dist/components/common/default_entity_actions.d.ts +37 -0
  406. package/dist/components/common/default_entity_actions.js +590 -0
  407. package/dist/components/common/default_entity_actions.js.map +1 -0
  408. package/dist/components/drawer_expansion.d.ts +25 -0
  409. package/dist/components/drawer_expansion.js +44 -0
  410. package/dist/components/drawer_expansion.js.map +1 -0
  411. package/dist/components/field_configs.d.ts +2 -2
  412. package/dist/components/field_configs.js +431 -0
  413. package/dist/components/field_configs.js.map +1 -0
  414. package/dist/components/field_ids.d.ts +11 -0
  415. package/dist/components/field_ids.js +58 -0
  416. package/dist/components/field_ids.js.map +1 -0
  417. package/dist/components/history/EntityHistoryEntry.js +151 -0
  418. package/dist/components/history/EntityHistoryEntry.js.map +1 -0
  419. package/dist/components/history/EntityHistoryView.js +157 -0
  420. package/dist/components/history/EntityHistoryView.js.map +1 -0
  421. package/dist/components/history/UserChip.js +21 -0
  422. package/dist/components/history/UserChip.js.map +1 -0
  423. package/dist/components/history/index.js +4 -0
  424. package/dist/components/index.d.ts +2 -0
  425. package/dist/components/lazy_record_views.d.ts +10 -0
  426. package/dist/components/lazy_record_views.js +57 -0
  427. package/dist/components/lazy_record_views.js.map +1 -0
  428. package/dist/contexts/BreacrumbsContext.js +28 -0
  429. package/dist/contexts/BreacrumbsContext.js.map +1 -0
  430. package/dist/contexts/EditorAIControllerContext.d.ts +18 -0
  431. package/dist/contexts/EditorAIControllerContext.js +29 -0
  432. package/dist/contexts/EditorAIControllerContext.js.map +1 -0
  433. package/dist/contexts/SideDialogsControllerContext.js +7 -0
  434. package/dist/contexts/SideDialogsControllerContext.js.map +1 -0
  435. package/dist/data_export/export/BasicExportAction.js +151 -0
  436. package/dist/data_export/export/BasicExportAction.js.map +1 -0
  437. package/dist/data_export/export/ExportCollectionAction.js +297 -0
  438. package/dist/data_export/export/ExportCollectionAction.js.map +1 -0
  439. package/dist/data_export/export/additional_fields.js +40 -0
  440. package/dist/data_export/export/additional_fields.js.map +1 -0
  441. package/dist/data_export/export/export.d.ts +35 -0
  442. package/dist/data_export/export/export.js +400 -0
  443. package/dist/data_export/export/export.js.map +1 -0
  444. package/dist/data_export/export/fetch_export_data.d.ts +17 -7
  445. package/dist/data_export/export/fetch_export_data.js +67 -0
  446. package/dist/data_export/export/fetch_export_data.js.map +1 -0
  447. package/dist/data_export/export/index.d.ts +4 -2
  448. package/dist/data_export/export/index.js +5 -0
  449. package/dist/data_import/components/DataNewPropertiesMapping.js +207 -0
  450. package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -0
  451. package/dist/data_import/components/ImportConversionProblems.d.ts +11 -0
  452. package/dist/data_import/components/ImportConversionProblems.js +89 -0
  453. package/dist/data_import/components/ImportConversionProblems.js.map +1 -0
  454. package/dist/data_import/components/ImportFileUpload.js +43 -0
  455. package/dist/data_import/components/ImportFileUpload.js.map +1 -0
  456. package/dist/data_import/components/ImportNewPropertyFieldPreview.js +42 -0
  457. package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -0
  458. package/dist/data_import/components/ImportSaveInProgress.js +105 -0
  459. package/dist/data_import/components/ImportSaveInProgress.js.map +1 -0
  460. package/dist/data_import/components/index.d.ts +1 -0
  461. package/dist/data_import/hooks/useImportConfig.js +34 -0
  462. package/dist/data_import/hooks/useImportConfig.js.map +1 -0
  463. package/dist/{import-TCgkTVlS.js → data_import/import/ImportCollectionAction.js} +84 -92
  464. package/dist/data_import/import/ImportCollectionAction.js.map +1 -0
  465. package/dist/data_import/import/index.js +2 -0
  466. package/dist/data_import/utils/csv.js +146 -0
  467. package/dist/data_import/utils/csv.js.map +1 -0
  468. package/dist/data_import/utils/data.d.ts +81 -4
  469. package/dist/data_import/utils/data.js +366 -0
  470. package/dist/data_import/utils/data.js.map +1 -0
  471. package/dist/data_import/utils/file_headers.js +32 -0
  472. package/dist/data_import/utils/file_headers.js.map +1 -0
  473. package/dist/data_import/utils/file_to_json.js +149 -0
  474. package/dist/data_import/utils/file_to_json.js.map +1 -0
  475. package/dist/data_import/utils/get_import_inference_type.js +14 -0
  476. package/dist/data_import/utils/get_import_inference_type.js.map +1 -0
  477. package/dist/data_import/utils/id_column.js +27 -0
  478. package/dist/data_import/utils/id_column.js.map +1 -0
  479. package/dist/data_import/utils/import_columns.d.ts +48 -0
  480. package/dist/data_import/utils/import_columns.js +92 -0
  481. package/dist/data_import/utils/import_columns.js.map +1 -0
  482. package/dist/data_import/utils/save_entities.d.ts +33 -4
  483. package/dist/data_import/utils/save_entities.js +244 -0
  484. package/dist/data_import/utils/save_entities.js.map +1 -0
  485. package/dist/data_import/utils/transforms.js +83 -0
  486. package/dist/data_import/utils/transforms.js.map +1 -0
  487. package/dist/editor/components/SlashCommandMenu.js +497 -0
  488. package/dist/editor/components/SlashCommandMenu.js.map +1 -0
  489. package/dist/editor/components/editor-bubble-item.js +24 -0
  490. package/dist/editor/components/editor-bubble-item.js.map +1 -0
  491. package/dist/editor/components/editor-bubble.js +97 -0
  492. package/dist/editor/components/editor-bubble.js.map +1 -0
  493. package/dist/editor/components/image-bubble.js +148 -0
  494. package/dist/editor/components/image-bubble.js.map +1 -0
  495. package/dist/editor/components/table-bubble.js +406 -0
  496. package/dist/editor/components/table-bubble.js.map +1 -0
  497. package/dist/editor/editor.d.ts +7 -1
  498. package/dist/editor/editor.js +423 -0
  499. package/dist/editor/editor.js.map +1 -0
  500. package/dist/editor/extensions/HighlightDecorationExtension.js +74 -0
  501. package/dist/editor/extensions/HighlightDecorationExtension.js.map +1 -0
  502. package/dist/editor/extensions/Image.d.ts +28 -1
  503. package/dist/editor/extensions/Image.js +160 -0
  504. package/dist/editor/extensions/Image.js.map +1 -0
  505. package/dist/editor/extensions/TextLoadingDecorationExtension.js +82 -0
  506. package/dist/editor/extensions/TextLoadingDecorationExtension.js.map +1 -0
  507. package/dist/editor/extensions/clipboard.js +63 -0
  508. package/dist/editor/extensions/clipboard.js.map +1 -0
  509. package/dist/editor/extensions/drag-and-drop.js +354 -0
  510. package/dist/editor/extensions/drag-and-drop.js.map +1 -0
  511. package/dist/editor/hooks/useProseMirror.d.ts +4 -1
  512. package/dist/editor/hooks/useProseMirror.js +101 -0
  513. package/dist/editor/hooks/useProseMirror.js.map +1 -0
  514. package/dist/editor/hooks/useProseMirrorContext.js +11 -0
  515. package/dist/editor/hooks/useProseMirrorContext.js.map +1 -0
  516. package/dist/editor/markdown.js +154 -0
  517. package/dist/editor/markdown.js.map +1 -0
  518. package/dist/editor/nodeViews/ImageComponent.js +35 -0
  519. package/dist/editor/nodeViews/ImageComponent.js.map +1 -0
  520. package/dist/editor/nodeViews/ReactNodeView.js +57 -0
  521. package/dist/editor/nodeViews/ReactNodeView.js.map +1 -0
  522. package/dist/editor/nodeViews/TaskItemComponent.js +29 -0
  523. package/dist/editor/nodeViews/TaskItemComponent.js.map +1 -0
  524. package/dist/editor/nodeViews/index.js +21 -0
  525. package/dist/editor/nodeViews/index.js.map +1 -0
  526. package/dist/editor/plugins/index.js +54 -0
  527. package/dist/editor/plugins/index.js.map +1 -0
  528. package/dist/editor/plugins/inputrules.js +54 -0
  529. package/dist/editor/plugins/inputrules.js.map +1 -0
  530. package/dist/editor/plugins/placeholderPlugin.js +38 -0
  531. package/dist/editor/plugins/placeholderPlugin.js.map +1 -0
  532. package/dist/editor/plugins/slashCommandPlugin.js +40 -0
  533. package/dist/editor/plugins/slashCommandPlugin.js.map +1 -0
  534. package/dist/editor/sanitize-html.js +190 -0
  535. package/dist/editor/sanitize-html.js.map +1 -0
  536. package/dist/{markdown-CCqp8ibf.js → editor/schema.js} +2 -159
  537. package/dist/editor/schema.js.map +1 -0
  538. package/dist/editor/selectors/link-selector.js +118 -0
  539. package/dist/editor/selectors/link-selector.js.map +1 -0
  540. package/dist/editor/selectors/node-selector.js +118 -0
  541. package/dist/editor/selectors/node-selector.js.map +1 -0
  542. package/dist/editor/selectors/text-buttons.js +71 -0
  543. package/dist/editor/selectors/text-buttons.js.map +1 -0
  544. package/dist/editor/utils/prosemirror-utils.js +92 -0
  545. package/dist/editor/utils/prosemirror-utils.js.map +1 -0
  546. package/dist/editor/utils/remove_classes.js +16 -0
  547. package/dist/editor/utils/remove_classes.js.map +1 -0
  548. package/dist/editor.js +1 -3085
  549. package/dist/form/EntityForm.js +734 -0
  550. package/dist/form/EntityForm.js.map +1 -0
  551. package/dist/form/EntityFormActions.js +101 -0
  552. package/dist/form/EntityFormActions.js.map +1 -0
  553. package/dist/form/EntityFormBinding.js +256 -0
  554. package/dist/form/EntityFormBinding.js.map +1 -0
  555. package/dist/form/PropertyFieldBinding.js +298 -0
  556. package/dist/form/PropertyFieldBinding.js.map +1 -0
  557. package/dist/form/components/ErrorFocus.js +33 -0
  558. package/dist/form/components/ErrorFocus.js.map +1 -0
  559. package/dist/form/components/FieldBlock.js +118 -0
  560. package/dist/form/components/FieldBlock.js.map +1 -0
  561. package/dist/form/components/FieldHelperText.js +56 -0
  562. package/dist/form/components/FieldHelperText.js.map +1 -0
  563. package/dist/form/components/FormRail.js +118 -0
  564. package/dist/form/components/FormRail.js.map +1 -0
  565. package/dist/form/components/FormSections.js +63 -0
  566. package/dist/form/components/FormSections.js.map +1 -0
  567. package/dist/form/components/LabelWithIcon.js +29 -0
  568. package/dist/form/components/LabelWithIcon.js.map +1 -0
  569. package/dist/form/components/LocalChangesMenu.js +127 -0
  570. package/dist/form/components/LocalChangesMenu.js.map +1 -0
  571. package/dist/form/components/StorageItemPreview.js +46 -0
  572. package/dist/form/components/StorageItemPreview.js.map +1 -0
  573. package/dist/form/components/StorageUploadProgress.js +84 -0
  574. package/dist/form/components/StorageUploadProgress.js.map +1 -0
  575. package/dist/form/components/useRailVisible.js +43 -0
  576. package/dist/form/components/useRailVisible.js.map +1 -0
  577. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +84 -0
  578. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -0
  579. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +125 -0
  580. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -0
  581. package/dist/form/field_bindings/BinaryFieldBinding.js +135 -0
  582. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -0
  583. package/dist/form/field_bindings/BlockFieldBinding.js +164 -0
  584. package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -0
  585. package/dist/form/field_bindings/DateTimeFieldBinding.js +47 -0
  586. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -0
  587. package/dist/form/field_bindings/GeopointFieldBinding.js +148 -0
  588. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -0
  589. package/dist/form/field_bindings/KeyValueFieldBinding.js +450 -0
  590. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -0
  591. package/dist/form/field_bindings/MapFieldBinding.js +77 -0
  592. package/dist/form/field_bindings/MapFieldBinding.js.map +1 -0
  593. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +215 -0
  594. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -0
  595. package/dist/form/field_bindings/MultiSelectFieldBinding.js +88 -0
  596. package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -0
  597. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +118 -0
  598. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -0
  599. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +52 -0
  600. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -0
  601. package/dist/form/field_bindings/ReferenceFieldBinding.js +99 -0
  602. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -0
  603. package/dist/form/field_bindings/RelationFieldBinding.js +135 -0
  604. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -0
  605. package/dist/form/field_bindings/RepeatFieldBinding.js +103 -0
  606. package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -0
  607. package/dist/form/field_bindings/SelectFieldBinding.js +80 -0
  608. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -0
  609. package/dist/form/field_bindings/StorageUploadFieldBinding.js +266 -0
  610. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -0
  611. package/dist/form/field_bindings/SwitchFieldBinding.js +41 -0
  612. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -0
  613. package/dist/form/field_bindings/TextFieldBinding.js +114 -0
  614. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -0
  615. package/dist/form/field_bindings/UserSelectFieldBinding.js +48 -0
  616. package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -0
  617. package/dist/form/field_bindings/VectorFieldBinding.js +147 -0
  618. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -0
  619. package/dist/form/form_keyboard_scope.d.ts +26 -0
  620. package/dist/form/form_keyboard_scope.js +39 -0
  621. package/dist/form/form_keyboard_scope.js.map +1 -0
  622. package/dist/form/form_uploads.d.ts +24 -0
  623. package/dist/form/form_uploads.js +31 -0
  624. package/dist/form/form_uploads.js.map +1 -0
  625. package/dist/form/form_utils.d.ts +48 -0
  626. package/dist/form/form_utils.js +280 -0
  627. package/dist/form/form_utils.js.map +1 -0
  628. package/dist/form/resolve_cell_property.d.ts +32 -0
  629. package/dist/form/resolve_cell_property.js +80 -0
  630. package/dist/form/resolve_cell_property.js.map +1 -0
  631. package/dist/form/resolve_form_properties.d.ts +27 -0
  632. package/dist/form/resolve_form_properties.js +78 -0
  633. package/dist/form/resolve_form_properties.js.map +1 -0
  634. package/dist/form/useClearRestoreValue.js +27 -0
  635. package/dist/form/useClearRestoreValue.js.map +1 -0
  636. package/dist/form/useUndoableDiscard.js +36 -0
  637. package/dist/form/useUndoableDiscard.js.map +1 -0
  638. package/dist/form/validation.d.ts +20 -0
  639. package/dist/form/validation.js +416 -0
  640. package/dist/form/validation.js.map +1 -0
  641. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js +22 -0
  642. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -0
  643. package/dist/hooks/navigation/contexts/NavigationStateContext.js +15 -0
  644. package/dist/hooks/navigation/contexts/NavigationStateContext.js.map +1 -0
  645. package/dist/hooks/navigation/contexts/UrlContext.js +22 -0
  646. package/dist/hooks/navigation/contexts/UrlContext.js.map +1 -0
  647. package/dist/hooks/navigation/useAsyncResolver.js +68 -0
  648. package/dist/hooks/navigation/useAsyncResolver.js.map +1 -0
  649. package/dist/hooks/navigation/useBuildCollectionRegistryController.js +141 -0
  650. package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -0
  651. package/dist/hooks/navigation/useBuildNavigationStateController.js +77 -0
  652. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -0
  653. package/dist/hooks/navigation/useBuildUrlController.js +57 -0
  654. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -0
  655. package/dist/hooks/navigation/useNavigationResolution.js +177 -0
  656. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -0
  657. package/dist/hooks/navigation/useResolvedCollections.js +56 -0
  658. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -0
  659. package/dist/hooks/navigation/useResolvedViews.js +94 -0
  660. package/dist/hooks/navigation/useResolvedViews.js.map +1 -0
  661. package/dist/hooks/navigation/useTopLevelNavigation.js +162 -0
  662. package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -0
  663. package/dist/hooks/navigation/utils.js +125 -0
  664. package/dist/hooks/navigation/utils.js.map +1 -0
  665. package/dist/hooks/useAdminContext.js +45 -0
  666. package/dist/hooks/useAdminContext.js.map +1 -0
  667. package/dist/hooks/useBreadcrumbsController.js +17 -0
  668. package/dist/hooks/useBreadcrumbsController.js.map +1 -0
  669. package/dist/hooks/useBuildSideDialogsController.js +96 -0
  670. package/dist/hooks/useBuildSideDialogsController.js.map +1 -0
  671. package/dist/hooks/useBuildSidePanel.js +221 -0
  672. package/dist/hooks/useBuildSidePanel.js.map +1 -0
  673. package/dist/hooks/useChildViewSource.js +41 -0
  674. package/dist/hooks/useChildViewSource.js.map +1 -0
  675. package/dist/hooks/useEntityDisplay.js +136 -0
  676. package/dist/hooks/useEntityDisplay.js.map +1 -0
  677. package/dist/hooks/useEntityDisplayTitle.js +34 -0
  678. package/dist/hooks/useEntityDisplayTitle.js.map +1 -0
  679. package/dist/hooks/useHistory.js +137 -0
  680. package/dist/hooks/useHistory.js.map +1 -0
  681. package/dist/hooks/useRecordActions.d.ts +28 -6
  682. package/dist/hooks/useRecordActions.js +108 -0
  683. package/dist/hooks/useRecordActions.js.map +1 -0
  684. package/dist/hooks/useReferencePaths.d.ts +21 -0
  685. package/dist/hooks/useReferencePaths.js +32 -0
  686. package/dist/hooks/useReferencePaths.js.map +1 -0
  687. package/dist/hooks/useResolvedNavigationFrom.js +83 -0
  688. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -0
  689. package/dist/hooks/useResolvedUsers.js +109 -0
  690. package/dist/hooks/useResolvedUsers.js.map +1 -0
  691. package/dist/hooks/useSelectionDialog.js +53 -0
  692. package/dist/hooks/useSelectionDialog.js.map +1 -0
  693. package/dist/hooks/useSideDialogsController.js +8 -0
  694. package/dist/hooks/useSideDialogsController.js.map +1 -0
  695. package/dist/hooks/useSidePanel.js +15 -0
  696. package/dist/hooks/useSidePanel.js.map +1 -0
  697. package/dist/hooks/useStorageReferenceResolver.d.ts +25 -0
  698. package/dist/hooks/useStorageReferenceResolver.js +49 -0
  699. package/dist/hooks/useStorageReferenceResolver.js.map +1 -0
  700. package/dist/index.d.ts +3 -2
  701. package/dist/index.js +151 -3793
  702. package/dist/preview/PropertyPreview.js +260 -0
  703. package/dist/preview/PropertyPreview.js.map +1 -0
  704. package/dist/preview/compact_text.js +52 -0
  705. package/dist/preview/compact_text.js.map +1 -0
  706. package/dist/preview/components/ArrayEnumPreview.js +24 -0
  707. package/dist/preview/components/ArrayEnumPreview.js.map +1 -0
  708. package/dist/preview/components/BooleanPreview.js +25 -0
  709. package/dist/preview/components/BooleanPreview.js.map +1 -0
  710. package/dist/preview/components/DatePreview.d.ts +3 -2
  711. package/dist/preview/components/DatePreview.js +87 -0
  712. package/dist/preview/components/DatePreview.js.map +1 -0
  713. package/dist/preview/components/EmptyValue.js +13 -0
  714. package/dist/preview/components/EmptyValue.js.map +1 -0
  715. package/dist/preview/components/EnumValuesChip.js +26 -0
  716. package/dist/preview/components/EnumValuesChip.js.map +1 -0
  717. package/dist/preview/components/ImagePreview.d.ts +7 -1
  718. package/dist/preview/components/ImagePreview.js +112 -0
  719. package/dist/preview/components/ImagePreview.js.map +1 -0
  720. package/dist/preview/components/InlineEntityListPreview.js +31 -0
  721. package/dist/preview/components/InlineEntityListPreview.js.map +1 -0
  722. package/dist/preview/components/ReferencePreview.js +162 -0
  723. package/dist/preview/components/ReferencePreview.js.map +1 -0
  724. package/dist/preview/components/RelationPreview.js +196 -0
  725. package/dist/preview/components/RelationPreview.js.map +1 -0
  726. package/dist/preview/components/StorageMarkdown.d.ts +11 -0
  727. package/dist/preview/components/StorageMarkdown.js +49 -0
  728. package/dist/preview/components/StorageMarkdown.js.map +1 -0
  729. package/dist/preview/components/StorageThumbnail.js +183 -0
  730. package/dist/preview/components/StorageThumbnail.js.map +1 -0
  731. package/dist/preview/components/UrlComponentPreview.d.ts +3 -1
  732. package/dist/preview/components/UrlComponentPreview.js +88 -0
  733. package/dist/preview/components/UrlComponentPreview.js.map +1 -0
  734. package/dist/preview/components/UserPreview.js +30 -0
  735. package/dist/preview/components/UserPreview.js.map +1 -0
  736. package/dist/preview/components/date_fns_locales.js +124 -0
  737. package/dist/preview/components/date_fns_locales.js.map +1 -0
  738. package/dist/preview/components/storageRenditions.d.ts +10 -0
  739. package/dist/preview/components/storageRenditions.js +95 -0
  740. package/dist/preview/components/storageRenditions.js.map +1 -0
  741. package/dist/preview/property_previews/ArrayOfMapsPreview.js +44 -0
  742. package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -0
  743. package/dist/preview/property_previews/ArrayOfReferencesPreview.js +48 -0
  744. package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -0
  745. package/dist/preview/property_previews/ArrayOfRelationsPreview.js +50 -0
  746. package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -0
  747. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js +30 -0
  748. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -0
  749. package/dist/preview/property_previews/ArrayOfStringsPreview.js +42 -0
  750. package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -0
  751. package/dist/preview/property_previews/ArrayOneOfPreview.js +47 -0
  752. package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -0
  753. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +25 -0
  754. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -0
  755. package/dist/preview/property_previews/ArrayPropertyPreview.js +48 -0
  756. package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -0
  757. package/dist/preview/property_previews/MapPropertyPreview.js +137 -0
  758. package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -0
  759. package/dist/preview/property_previews/NumberPropertyPreview.js +34 -0
  760. package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -0
  761. package/dist/preview/property_previews/SkeletonPropertyComponent.js +151 -0
  762. package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -0
  763. package/dist/preview/property_previews/StringPropertyPreview.js +49 -0
  764. package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -0
  765. package/dist/preview/util.d.ts +8 -3
  766. package/dist/{util-CC0ozHoD.js → preview/util.js} +13 -6
  767. package/dist/preview/util.js.map +1 -0
  768. package/dist/routes/CustomViewRoute.js +26 -0
  769. package/dist/routes/CustomViewRoute.js.map +1 -0
  770. package/dist/routes/RebaseRoute.js +311 -0
  771. package/dist/routes/RebaseRoute.js.map +1 -0
  772. package/dist/selection/SelectionMenu.js +90 -0
  773. package/dist/selection/SelectionMenu.js.map +1 -0
  774. package/dist/selection/resolve_selection.js +79 -0
  775. package/dist/selection/resolve_selection.js.map +1 -0
  776. package/dist/util/caller_scopes.d.ts +15 -0
  777. package/dist/util/caller_scopes.js +25 -0
  778. package/dist/util/caller_scopes.js.map +1 -0
  779. package/dist/util/collection_open_mode.d.ts +20 -0
  780. package/dist/util/collection_open_mode.js +32 -0
  781. package/dist/util/collection_open_mode.js.map +1 -0
  782. package/dist/util/dataControllerAdapter.js +65 -0
  783. package/dist/util/dataControllerAdapter.js.map +1 -0
  784. package/dist/util/entity_actions.d.ts +42 -1
  785. package/dist/util/entity_actions.js +77 -0
  786. package/dist/util/entity_actions.js.map +1 -0
  787. package/dist/util/entity_pages.d.ts +37 -3
  788. package/dist/util/entity_pages.js +71 -0
  789. package/dist/util/entity_pages.js.map +1 -0
  790. package/dist/util/find_entities_by_ids.d.ts +23 -0
  791. package/dist/util/find_entities_by_ids.js +55 -0
  792. package/dist/util/find_entities_by_ids.js.map +1 -0
  793. package/dist/util/fit_inline_actions.d.ts +20 -0
  794. package/dist/util/fit_inline_actions.js +40 -0
  795. package/dist/util/fit_inline_actions.js.map +1 -0
  796. package/dist/util/format_collection_date.d.ts +29 -0
  797. package/dist/util/format_collection_date.js +60 -0
  798. package/dist/util/format_collection_date.js.map +1 -0
  799. package/dist/util/map_with_concurrency.js +46 -0
  800. package/dist/util/map_with_concurrency.js.map +1 -0
  801. package/dist/util/navigation_utils.js +45 -0
  802. package/dist/util/navigation_utils.js.map +1 -0
  803. package/dist/util/number_format.js +33 -0
  804. package/dist/util/number_format.js.map +1 -0
  805. package/dist/util/previews.js +71 -0
  806. package/dist/util/previews.js.map +1 -0
  807. package/dist/util/propertyConfigMapper.js +83 -0
  808. package/dist/util/propertyConfigMapper.js.map +1 -0
  809. package/dist/util/property_utils.js +141 -0
  810. package/dist/util/property_utils.js.map +1 -0
  811. package/dist/util/resolutions.js +55 -0
  812. package/dist/util/resolutions.js.map +1 -0
  813. package/dist/util/view_constants.js +35 -0
  814. package/dist/util/view_constants.js.map +1 -0
  815. package/dist/util/view_mode.js +112 -0
  816. package/dist/util/view_mode.js.map +1 -0
  817. package/package.json +13 -9
  818. package/dist/CollectionEditorDialog-DLHCka00.js +0 -3630
  819. package/dist/CollectionEditorDialog-DLHCka00.js.map +0 -1
  820. package/dist/JsonPreviewBinding-v0w3H0fp.js.map +0 -1
  821. package/dist/PropertyEditView-_pu5hzZn.js +0 -3837
  822. package/dist/PropertyEditView-_pu5hzZn.js.map +0 -1
  823. package/dist/RouterCollectionsStudioView-ChPNl_uU.js +0 -212
  824. package/dist/RouterCollectionsStudioView-ChPNl_uU.js.map +0 -1
  825. package/dist/SchemaChangeDialog-BeP0A4MJ.js.map +0 -1
  826. package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +0 -13
  827. package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +0 -8
  828. package/dist/collection_editor_ui.js.map +0 -1
  829. package/dist/editor.js.map +0 -1
  830. package/dist/export-4bJWdlDK.js +0 -520
  831. package/dist/export-4bJWdlDK.js.map +0 -1
  832. package/dist/history-BElrZ5Rw.js +0 -313
  833. package/dist/history-BElrZ5Rw.js.map +0 -1
  834. package/dist/import-TCgkTVlS.js.map +0 -1
  835. package/dist/index.js.map +0 -1
  836. package/dist/markdown-CCqp8ibf.js.map +0 -1
  837. package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
  838. package/dist/util-CC0ozHoD.js.map +0 -1
  839. package/dist/util-DybQBkug.js +0 -26390
  840. package/dist/util-DybQBkug.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file_to_json.js","names":[],"sources":["../../../src/data_import/utils/file_to_json.ts"],"sourcesContent":["import { getWorksheetHeaders, type SheetCell } from \"./file_headers\";\nimport { mapJsonParse, unflattenObject } from \"./transforms\";\nimport { parseCsvToObjects } from \"./csv\";\nimport { isPrototypePollutingKey } from \"@rebasepro/utils\";\n\ntype ConversionResult = {\n data: object[];\n propertiesOrder: string[]\n}\n\n/**\n * The workbook reader, fetched the first time somebody actually opens one.\n *\n * Still lazy, and for the original reason: a top-level import put the whole\n * spreadsheet reader into the admin's entry chunk — preloaded on the login\n * screen, before anyone has authenticated, let alone clicked Import.\n * `CollectionViewActions` lazy-loads the import and export actions and says so\n * in a comment, but the package's own barrel (`src/index.ts` re-exports\n * `./data_import`) puts this module back in the entry's static graph, so the\n * `lazy()` bought nothing. A static import inside a module the barrel reaches\n * is eager no matter what the component above it does; the only thing that\n * makes a dependency lazy is importing it lazily, here.\n *\n * `read-excel-file` rather than `exceljs`, since 2026-09-09. exceljs is pinned\n * at its last release and carries six deprecated packages of its own —\n * `fstream`, `glob@7`, `inflight`, `lodash.isequal`, `rimraf@2`, `uuid@8` —\n * which every project that installed the admin inherited and pnpm warned about\n * on a first `init`. Nothing here ever *wrote* a workbook: this is the one\n * place that touched it, to read an uploaded file. A reader with no deprecated\n * tail does the same job.\n *\n * exceljs remains a devDependency, because the test writes real workbooks to\n * read back — a fixture built by the library under test proves nothing.\n */\n/**\n * The default export returns one entry per *sheet*, not the rows — `readSheet`\n * is the rows-only overload. Taking `[0].data` keeps the old behaviour exactly:\n * ExcelJS read `workbook.worksheets[0]` and errored when there was none.\n */\ntype SheetEntry = { sheet: string; data: SheetCell[][] };\ntype ReadXlsxFile = (input: File | Blob | ArrayBuffer) => Promise<SheetEntry[]>;\n\nlet xlsxReader: Promise<ReadXlsxFile> | undefined;\n\nfunction loadXlsxReader(): Promise<ReadXlsxFile> {\n // `/browser`, not the bare package name: `read-excel-file` publishes no\n // root export at all — its `exports` map has only `./browser`,\n // `./universal`, `./node` and `./web-worker`, so importing the package\n // itself is a resolution error rather than a default. The browser entry is\n // the one whose `Input` accepts an `ArrayBuffer`, which is what the\n // FileReader above produces.\n xlsxReader ??= import(\"read-excel-file/browser\").then(mod => {\n const candidate = (mod as { default?: unknown }).default ?? mod;\n // `default.default` under some interop paths — unwrap one more level\n // rather than calling a namespace object and failing at the moment a\n // user picks a file, which is the only moment this code runs.\n const fn = typeof candidate === \"function\"\n ? candidate\n : (candidate as { default?: unknown })?.default;\n if (typeof fn !== \"function\") throw new Error(\"read-excel-file did not resolve to a function\");\n return fn as ReadXlsxFile;\n });\n return xlsxReader;\n}\n\n/**\n * Put a date the reader left a millisecond short back on its second.\n *\n * `read-excel-file` turns Excel's date serials (fractional days) into\n * milliseconds with `Math.floor`, and the fraction is rarely exact in floating\n * point: a time of 12:30:00 arrives as 12:29:59.999, and a field that shows\n * minutes displays 12:29. A date within a millisecond of a whole second is put\n * back on it; a genuine sub-second value is left alone.\n */\nfunction snapToSecond(cell: SheetCell): SheetCell {\n if (!(cell instanceof Date)) return cell;\n const time = cell.getTime();\n const second = Math.round(time / 1000) * 1000;\n return Math.abs(time - second) <= 1 ? new Date(second) : cell;\n}\n\n/**\n * Whether this file is delimited text rather than a workbook.\n *\n * Browsers report `text/csv`, `application/csv` or nothing at all for the same\n * `.csv`, so the extension is the reliable half of the test.\n */\nfunction isCsvFile(file: File): boolean {\n const name = (file.name ?? \"\").toLowerCase();\n if (name.endsWith(\".csv\") || name.endsWith(\".tsv\")) return true;\n return file.type === \"text/csv\" || file.type === \"application/csv\";\n}\n\n/** Turn the parsed cells of one sheet/file into the entity-shaped rows the import maps. */\nfunction toImportRows(rows: Array<Record<string, unknown>>): object[] {\n return rows.map(mapJsonParse).map(unflattenObject);\n}\n\nexport function convertFileToJson(file: File): Promise<ConversionResult> {\n return new Promise((resolve, reject) => {\n if (isCsvFile(file)) {\n // Not the ExcelJS branch: `workbook.xlsx.load` is a zip reader, and\n // every CSV — the format this admin exports by default — died on it\n // with \"Can't find end of central directory : is this a zip file ?\".\n console.debug(\"Converting CSV file to JSON\", file.name);\n const reader = new FileReader();\n reader.onload = function (e) {\n try {\n const { headers, data } = parseCsvToObjects(e.target?.result as string);\n if (headers.length === 0) {\n reject(new Error(\"The CSV file is empty\"));\n return;\n }\n resolve({\n data: toImportRows(data),\n propertiesOrder: headers\n });\n } catch (err) {\n console.error(\"Error parsing CSV file\", err);\n reject(err);\n }\n };\n reader.onerror = () => reject(reader.error ?? new Error(\"Could not read the file\"));\n // Explicit UTF-8: the pre-ExcelJS implementation passed\n // `codepage: 65001` for the same reason, and the browser's default\n // guess mangles accented and CJK text.\n reader.readAsText(file, \"utf-8\");\n } else if (file.type === \"application/json\") {\n console.debug(\"Converting JSON file to JSON\", file.name);\n const reader = new FileReader();\n reader.onload = function (e) {\n try {\n const data = e.target?.result as string;\n const jsonData = JSON.parse(data);\n if (!Array.isArray(jsonData)) {\n reject(new Error(\"JSON file should contain an array of objects\"));\n } else {\n const propertiesOrder = jsonData.length > 0 ? Object.keys(jsonData[0]) : [];\n resolve({\n data: jsonData,\n propertiesOrder\n });\n }\n } catch (e) {\n console.error(\"Error parsing JSON file\", e);\n reject(e);\n }\n };\n reader.readAsText(file);\n } else {\n console.debug(\"Converting Excel file to JSON\", file.name);\n const reader = new FileReader();\n reader.onload = async function (e) {\n try {\n const buffer = e.target?.result as ArrayBuffer;\n const readXlsxFile = await loadXlsxReader();\n // Every .xlsx is a zip, and its first two bytes say so. A\n // file that is not one never reaches the reader, because\n // what the reader says about it is a stack trace from\n // inside its own unzipper — the shape of error the CSV\n // branch above exists to avoid.\n const magic = new Uint8Array(buffer, 0, Math.min(2, buffer.byteLength));\n if (magic[0] !== 0x50 || magic[1] !== 0x4b) {\n reject(new Error(\n `'${file.name}' is not a readable .xlsx workbook. `\n + \"Export it again as .xlsx, or save it as .csv.\"\n ));\n return;\n }\n\n let sheets: SheetEntry[];\n try {\n sheets = await readXlsxFile(buffer);\n } catch (readError) {\n // A workbook with zero sheets throws from inside the\n // reader (`readFiles(...).then is not a function`)\n // rather than returning an empty list, so the \"no\n // sheets\" case arrives here rather than below. The file\n // is a valid zip — checked above — so the honest reading\n // is that there is nothing in it to import.\n console.debug(\"Spreadsheet reader failed\", readError);\n reject(new Error(\n \"No worksheets found in file — it has no sheets, or none this reader can open.\"\n ));\n return;\n }\n\n const firstSheet = sheets[0];\n if (!firstSheet) {\n reject(new Error(\"No worksheets found in file\"));\n return;\n }\n\n const [headerRow, ...dataRows] = firstSheet.data;\n if (!headerRow) {\n reject(new Error(\"The spreadsheet is empty\"));\n return;\n }\n\n const headers = getWorksheetHeaders(headerRow);\n if (headers.order.length === 0) {\n reject(new Error(\"The spreadsheet has no column headers in its first row\"));\n return;\n }\n\n const parsedData: Array<Record<string, any>> = [];\n for (const row of dataRows) {\n // A wholly empty row is not a record. ExcelJS skipped\n // these with `includeEmpty: false`; here they arrive as\n // a row of nulls.\n if (row.every(cell => cell === null || cell === undefined)) continue;\n\n const obj: Record<string, any> = {};\n row.forEach((cell, index) => {\n // An empty cell contributes no key, as before — the\n // difference between \"blank\" and \"absent\" is what\n // the import's own defaults key off.\n if (cell === null || cell === undefined) return;\n const header = headers.byColumn.get(index);\n // A `__proto__` header would be the prototype setter\n // here rather than a column; refused, as in `csv.ts`.\n if (header && !isPrototypePollutingKey(header)) {\n obj[header] = snapToSecond(cell);\n }\n });\n parsedData.push(obj);\n }\n\n resolve({\n data: toImportRows(parsedData),\n propertiesOrder: headers.order\n });\n } catch (err) {\n console.error(\"Error parsing Excel file\", err);\n reject(err);\n }\n };\n reader.readAsArrayBuffer(file);\n }\n });\n}\n"],"mappings":";;;;;AA0CA,IAAI;AAEJ,SAAS,iBAAwC;CAO7C,eAAe,OAAO,0BAA0B,CAAC,MAAK,QAAO;EACzD,MAAM,YAAa,IAA8B,WAAW;EAI5D,MAAM,KAAK,OAAO,cAAc,aAC1B,YACC,WAAqC;EAC5C,IAAI,OAAO,OAAO,YAAY,MAAM,IAAI,MAAM,+CAA+C;EAC7F,OAAO;CACX,CAAC;CACD,OAAO;AACX;;;;;;;;;;AAWA,SAAS,aAAa,MAA4B;CAC9C,IAAI,EAAE,gBAAgB,OAAO,OAAO;CACpC,MAAM,OAAO,KAAK,QA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AAI,IAAI,OAAM,SAAQ,SAAS,QAAQ,SAAS,KAAA,CAAS,GAAG;MAE5D,MAAM,MAA2B,CAAC;MAClC,IAAI,SAAS,MAAM,UAAU;OAIzB,IAAI,SAAS,QAAQ,SAAS,KAAA,GAAW;OACzC,MAAM,SAAS,QAAQ,SAAS,IAAI,KAAK;OAGzC,IAAI,UAAU,CAAC,wBAAwB,MAAM,GACzC,IAAI,UAAU,aAAa,IAAI;MAEvC,CAAC;MACD,WAAW,KAAK,GAAG;KACvB;KAEA,QAAQ;MACJ,MAAM,aAAa,UAAU;MAC7B,iBAAiB,QAAQ;KAC7B,CAAC;IACL,SAAS,KAAK;KACV,QAAQ,MAAM,4BAA4B,GAAG;KAC7C,OAAO,GAAG;IACd;GACJ;GACA,OAAO,kBAAkB,IAAI;EACjC;CACJ,CAAC;AACL"}
@@ -0,0 +1,14 @@
1
+ //#region src/data_import/utils/get_import_inference_type.ts
2
+ function getInferenceType(value) {
3
+ if (value === null || value === void 0) return "string";
4
+ if (typeof value === "number") return "number";
5
+ else if (typeof value === "string") return "string";
6
+ else if (typeof value === "boolean") return "boolean";
7
+ else if (value instanceof Date) return "date";
8
+ else if (Array.isArray(value)) return "array";
9
+ return "map";
10
+ }
11
+ //#endregion
12
+ export { getInferenceType };
13
+
14
+ //# sourceMappingURL=get_import_inference_type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_import_inference_type.js","names":[],"sources":["../../../src/data_import/utils/get_import_inference_type.ts"],"sourcesContent":["import { DataType } from \"@rebasepro/types\";\n\nexport function getInferenceType(value: any): DataType {\n // `typeof null === \"object\"`, so a null or empty CSV cell used to fall past\n // every check and land on \"map\" — an empty cell described as a nested object.\n // `inferTypeFromValue` in @rebasepro/inference already answers \"string\" here;\n // the two entry points into inference have to agree.\n if (value === null || value === undefined)\n return \"string\";\n if (typeof value === \"number\")\n return \"number\";\n else if (typeof value === \"string\")\n return \"string\";\n else if (typeof value === \"boolean\")\n return \"boolean\";\n else if (value instanceof Date)\n return \"date\";\n else if (Array.isArray(value))\n return \"array\";\n return \"map\";\n}\n\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAsB;CAKnD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC5B,OAAO;CACX,IAAI,OAAO,UAAU,UACjB,OAAO;MACN,IAAI,OAAO,UAAU,UACtB,OAAO;MACN,IAAI,OAAO,UAAU,WACtB,OAAO;MACN,IAAI,iBAAiB,MACtB,OAAO;MACN,IAAI,MAAM,QAAQ,KAAK,GACxB,OAAO;CACX,OAAO;AACX"}
@@ -0,0 +1,27 @@
1
+ //#region src/data_import/utils/id_column.ts
2
+ /**
3
+ * The column an import uses as the row id before the user touches the mapping.
4
+ *
5
+ * The guess decides something destructive: the chosen column is taken out of
6
+ * the values and sent as the id of an upsert, so every row overwrites the record
7
+ * that already has that id. A header that merely *contained* "id" or "key" used
8
+ * to qualify, so a file starting with `width`, `video` or `provider` wrote its
9
+ * widths over the records whose ids they happened to equal.
10
+ *
11
+ * Only the first column is a candidate — the one the export writes the id to —
12
+ * and only when its name says it is the id: the header is `id` (in any case),
13
+ * or it maps onto a property the collection declares with `isId`. Anything else
14
+ * is left for the user to choose in the mapping step.
15
+ */
16
+ function guessIdColumn(headers, headersMapping, properties) {
17
+ const firstKey = headers[0];
18
+ if (firstKey === void 0) return void 0;
19
+ if (firstKey.trim().toLowerCase() === "id") return firstKey;
20
+ const mappedKey = headersMapping[firstKey];
21
+ const mappedProperty = mappedKey ? properties?.[mappedKey] : void 0;
22
+ if (mappedProperty && "isId" in mappedProperty && mappedProperty.isId) return firstKey;
23
+ }
24
+ //#endregion
25
+ export { guessIdColumn };
26
+
27
+ //# sourceMappingURL=id_column.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id_column.js","names":[],"sources":["../../../src/data_import/utils/id_column.ts"],"sourcesContent":["import { Properties } from \"@rebasepro/types\";\n\n/**\n * The column an import uses as the row id before the user touches the mapping.\n *\n * The guess decides something destructive: the chosen column is taken out of\n * the values and sent as the id of an upsert, so every row overwrites the record\n * that already has that id. A header that merely *contained* \"id\" or \"key\" used\n * to qualify, so a file starting with `width`, `video` or `provider` wrote its\n * widths over the records whose ids they happened to equal.\n *\n * Only the first column is a candidate — the one the export writes the id to —\n * and only when its name says it is the id: the header is `id` (in any case),\n * or it maps onto a property the collection declares with `isId`. Anything else\n * is left for the user to choose in the mapping step.\n */\nexport function guessIdColumn(headers: string[],\n headersMapping: Record<string, string | null>,\n properties?: Properties): string | undefined {\n const firstKey = headers[0];\n if (firstKey === undefined) return undefined;\n\n if (firstKey.trim().toLowerCase() === \"id\") return firstKey;\n\n const mappedKey = headersMapping[firstKey];\n const mappedProperty = mappedKey ? properties?.[mappedKey] : undefined;\n if (mappedProperty && \"isId\" in mappedProperty && mappedProperty.isId) return firstKey;\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,cAAc,SAC1B,gBACA,YAA6C;CAC7C,MAAM,WAAW,QAAQ;CACzB,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CAEnC,IAAI,SAAS,KAAK,CAAC,CAAC,YAAY,MAAM,MAAM,OAAO;CAEnD,MAAM,YAAY,eAAe;CACjC,MAAM,iBAAiB,YAAY,aAAa,aAAa,KAAA;CAC7D,IAAI,kBAAkB,UAAU,kBAAkB,eAAe,MAAM,OAAO;AAGlF"}
@@ -0,0 +1,48 @@
1
+ import { Properties, Property } from "@rebasepro/types";
2
+ /**
3
+ * Whether a property's value is an object the import takes whole, from one
4
+ * column: a geopoint, a vector, or a map that declares no fields (a key-value
5
+ * map). These are the values the export writes as objects — in a JSON file
6
+ * as the object, in a CSV cell as its JSON — and splitting one into
7
+ * `location.latitude` columns left it in columns no property holds: it was
8
+ * dropped without a word.
9
+ *
10
+ * Any other object is read one column per key: a map with declared fields
11
+ * field by field, as the export writes it, and an object no property takes
12
+ * so that its keys can be mapped one by one.
13
+ */
14
+ export declare function takesObjectWhole(property: Property): boolean;
15
+ /** One column of an imported row, as the mapping step lists it. */
16
+ export type ImportColumn = {
17
+ /** The column's name: a key of the row, or `parent.key` below one. */
18
+ column: string;
19
+ value: unknown;
20
+ /** The property path it lands in, or `null` for none. */
21
+ target: string | null;
22
+ /** Its value is an object that is read as one column per key, listed after it. */
23
+ split: boolean;
24
+ };
25
+ /**
26
+ * Where a column lands: the property path for it, or `null` for none. A
27
+ * column below another is given that parent; a top-level one is not.
28
+ */
29
+ export type ColumnTarget = (column: string, key: string, parent?: Pick<ImportColumn, "column" | "target">) => string | null;
30
+ /**
31
+ * The columns of one imported row, parents before their children.
32
+ *
33
+ * Each key of the row is a column. A key whose value is an object is also
34
+ * read as one column per key of that object (`address.street`) — unless the
35
+ * property it lands in takes the object whole (see {@link takesObjectWhole}).
36
+ *
37
+ * The mapping step lists these columns and the conversion reads them, so both
38
+ * get them from here: a list built one way and rows read another is a mapping
39
+ * whose keys match nothing.
40
+ */
41
+ export declare function importColumns(row: Record<string, unknown>, properties: Properties | undefined, targetOf: ColumnTarget): ImportColumn[];
42
+ /**
43
+ * The mapping the import starts from: each column of the file onto the
44
+ * property with its name, or with its name slugged (`First Name` →
45
+ * `first_name`); a column below a map onto that map's field. A column that
46
+ * matches nothing keeps its own name, for the person importing to map.
47
+ */
48
+ export declare function buildHeadersMappingFromData(rows: object[], properties?: Properties): Record<string, string>;
@@ -0,0 +1,92 @@
1
+ import { getPropertyInPath } from "../../util/property_utils.js";
2
+ import { isPrototypePollutingKey, slugify } from "@rebasepro/utils";
3
+ //#region src/data_import/utils/import_columns.ts
4
+ /**
5
+ * Whether a property's value is an object the import takes whole, from one
6
+ * column: a geopoint, a vector, or a map that declares no fields (a key-value
7
+ * map). These are the values the export writes as objects — in a JSON file
8
+ * as the object, in a CSV cell as its JSON — and splitting one into
9
+ * `location.latitude` columns left it in columns no property holds: it was
10
+ * dropped without a word.
11
+ *
12
+ * Any other object is read one column per key: a map with declared fields
13
+ * field by field, as the export writes it, and an object no property takes
14
+ * so that its keys can be mapped one by one.
15
+ */
16
+ function takesObjectWhole(property) {
17
+ return property.type === "geopoint" || property.type === "vector" || property.type === "map" && property.properties === void 0;
18
+ }
19
+ function isObjectCell(value) {
20
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
21
+ }
22
+ /** The declared property at a path, and nothing inherited (`toString`). */
23
+ function propertyAt(properties, path) {
24
+ if (!properties || path === null) return void 0;
25
+ const property = getPropertyInPath(properties, path);
26
+ return property !== null && typeof property === "object" ? property : void 0;
27
+ }
28
+ /**
29
+ * The columns of one imported row, parents before their children.
30
+ *
31
+ * Each key of the row is a column. A key whose value is an object is also
32
+ * read as one column per key of that object (`address.street`) — unless the
33
+ * property it lands in takes the object whole (see {@link takesObjectWhole}).
34
+ *
35
+ * The mapping step lists these columns and the conversion reads them, so both
36
+ * get them from here: a list built one way and rows read another is a mapping
37
+ * whose keys match nothing.
38
+ */
39
+ function importColumns(row, properties, targetOf) {
40
+ const columns = [];
41
+ const walk = (object, parent) => {
42
+ for (const key of Object.keys(object)) {
43
+ if (isPrototypePollutingKey(key)) {
44
+ console.warn(`Skipping column "${key}": a header may not reach the prototype chain`);
45
+ continue;
46
+ }
47
+ const column = parent === void 0 ? key : `${parent.column}.${key}`;
48
+ const value = object[key];
49
+ const target = targetOf(column, key, parent);
50
+ const property = propertyAt(properties, target);
51
+ const splitValue = isObjectCell(value) && !(property && takesObjectWhole(property)) ? value : void 0;
52
+ columns.push({
53
+ column,
54
+ value,
55
+ target,
56
+ split: splitValue !== void 0
57
+ });
58
+ if (splitValue) walk(splitValue, {
59
+ column,
60
+ target
61
+ });
62
+ }
63
+ };
64
+ walk(row);
65
+ return columns;
66
+ }
67
+ /**
68
+ * The mapping the import starts from: each column of the file onto the
69
+ * property with its name, or with its name slugged (`First Name` →
70
+ * `first_name`); a column below a map onto that map's field. A column that
71
+ * matches nothing keeps its own name, for the person importing to map.
72
+ */
73
+ function buildHeadersMappingFromData(rows, properties) {
74
+ const headersMapping = {};
75
+ const targetOf = (column, key, parent) => {
76
+ if (Object.hasOwn(headersMapping, column)) return headersMapping[column];
77
+ const parentProperty = parent && propertyAt(properties, parent.target);
78
+ const siblings = parent === void 0 ? properties : parentProperty?.type === "map" ? parentProperty.properties : void 0;
79
+ const slug = slugify(key);
80
+ const name = siblings && !Object.hasOwn(siblings, key) && Object.hasOwn(siblings, slug) ? slug : key;
81
+ return parent === void 0 ? name : `${parent.target ?? parent.column}.${name}`;
82
+ };
83
+ for (const row of rows) {
84
+ if (!row) continue;
85
+ for (const { column, target } of importColumns(row, properties, targetOf)) headersMapping[column] ??= target ?? column;
86
+ }
87
+ return headersMapping;
88
+ }
89
+ //#endregion
90
+ export { buildHeadersMappingFromData, importColumns, takesObjectWhole };
91
+
92
+ //# sourceMappingURL=import_columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import_columns.js","names":[],"sources":["../../../src/data_import/utils/import_columns.ts"],"sourcesContent":["import { Properties, Property } from \"@rebasepro/types\";\nimport { isPrototypePollutingKey, slugify } from \"@rebasepro/utils\";\nimport { getPropertyInPath } from \"../../util\";\n\n/**\n * Whether a property's value is an object the import takes whole, from one\n * column: a geopoint, a vector, or a map that declares no fields (a key-value\n * map). These are the values the export writes as objects — in a JSON file\n * as the object, in a CSV cell as its JSON — and splitting one into\n * `location.latitude` columns left it in columns no property holds: it was\n * dropped without a word.\n *\n * Any other object is read one column per key: a map with declared fields\n * field by field, as the export writes it, and an object no property takes\n * so that its keys can be mapped one by one.\n */\nexport function takesObjectWhole(property: Property): boolean {\n return property.type === \"geopoint\"\n || property.type === \"vector\"\n || (property.type === \"map\" && property.properties === undefined);\n}\n\n/** One column of an imported row, as the mapping step lists it. */\nexport type ImportColumn = {\n /** The column's name: a key of the row, or `parent.key` below one. */\n column: string;\n value: unknown;\n /** The property path it lands in, or `null` for none. */\n target: string | null;\n /** Its value is an object that is read as one column per key, listed after it. */\n split: boolean;\n};\n\n/**\n * Where a column lands: the property path for it, or `null` for none. A\n * column below another is given that parent; a top-level one is not.\n */\nexport type ColumnTarget = (column: string, key: string, parent?: Pick<ImportColumn, \"column\" | \"target\">) => string | null;\n\nfunction isObjectCell(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) && !(value instanceof Date);\n}\n\n/** The declared property at a path, and nothing inherited (`toString`). */\nfunction propertyAt(properties: Properties | undefined, path: string | null): Property | undefined {\n if (!properties || path === null) return undefined;\n const property = getPropertyInPath(properties, path);\n return property !== null && typeof property === \"object\" ? property : undefined;\n}\n\n/**\n * The columns of one imported row, parents before their children.\n *\n * Each key of the row is a column. A key whose value is an object is also\n * read as one column per key of that object (`address.street`) — unless the\n * property it lands in takes the object whole (see {@link takesObjectWhole}).\n *\n * The mapping step lists these columns and the conversion reads them, so both\n * get them from here: a list built one way and rows read another is a mapping\n * whose keys match nothing.\n */\nexport function importColumns(row: Record<string, unknown>,\n properties: Properties | undefined,\n targetOf: ColumnTarget): ImportColumn[] {\n const columns: ImportColumn[] = [];\n const walk = (object: Record<string, unknown>, parent?: Pick<ImportColumn, \"column\" | \"target\">) => {\n for (const key of Object.keys(object)) {\n // Keys come from the uploaded file, so a `__proto__` key would be\n // the prototype setter wherever it is used as one (class 22).\n if (isPrototypePollutingKey(key)) {\n console.warn(`Skipping column \"${key}\": a header may not reach the prototype chain`);\n continue;\n }\n const column = parent === undefined ? key : `${parent.column}.${key}`;\n const value = object[key];\n const target = targetOf(column, key, parent);\n const property = propertyAt(properties, target);\n const splitValue = isObjectCell(value) && !(property && takesObjectWhole(property))\n ? value\n : undefined;\n columns.push({ column, value, target, split: splitValue !== undefined });\n if (splitValue) walk(splitValue, { column, target });\n }\n };\n walk(row);\n return columns;\n}\n\n/**\n * The mapping the import starts from: each column of the file onto the\n * property with its name, or with its name slugged (`First Name` →\n * `first_name`); a column below a map onto that map's field. A column that\n * matches nothing keeps its own name, for the person importing to map.\n */\nexport function buildHeadersMappingFromData(rows: object[], properties?: Properties): Record<string, string> {\n const headersMapping: Record<string, string> = {};\n const targetOf: ColumnTarget = (column, key, parent) => {\n if (Object.hasOwn(headersMapping, column)) return headersMapping[column];\n const parentProperty = parent && propertyAt(properties, parent.target);\n const siblings = parent === undefined\n ? properties\n : parentProperty?.type === \"map\" ? parentProperty.properties : undefined;\n const slug = slugify(key);\n const name = siblings && !Object.hasOwn(siblings, key) && Object.hasOwn(siblings, slug) ? slug : key;\n return parent === undefined ? name : `${parent.target ?? parent.column}.${name}`;\n };\n for (const row of rows) {\n if (!row) continue;\n for (const { column, target } of importColumns(row as Record<string, unknown>, properties, targetOf)) {\n headersMapping[column] ??= target ?? column;\n }\n }\n return headersMapping;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,iBAAiB,UAA6B;CAC1D,OAAO,SAAS,SAAS,cAClB,SAAS,SAAS,YACjB,SAAS,SAAS,SAAS,SAAS,eAAe,KAAA;AAC/D;AAmBA,SAAS,aAAa,OAAkD;CACpE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,KAAK,EAAE,iBAAiB;AACtG;;AAGA,SAAS,WAAW,YAAoC,MAA2C;CAC/F,IAAI,CAAC,cAAc,SAAS,MAAM,OAAO,KAAA;CACzC,MAAM,WAAW,kBAAkB,YAAY,IAAI;CACnD,OAAO,aAAa,QAAQ,OAAO,aAAa,WAAW,WAAW,KAAA;AAC1E;;;;;;;;;;;;AAaA,SAAgB,cAAc,KAC1B,YACA,UAAwC;CACxC,MAAM,UAA0B,CAAC;CACjC,MAAM,QAAQ,QAAiC,WAAqD;EAChG,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;GAGnC,IAAI,wBAAwB,GAAG,GAAG;IAC9B,QAAQ,KAAK,oBAAoB,IAAI,8CAA8C;IACnF;GACJ;GACA,MAAM,SAAS,WAAW,KAAA,IAAY,MAAM,GAAG,OAAO,OAAO,GAAG;GAChE,MAAM,QAAQ,OAAO;GACrB,MAAM,SAAS,SAAS,QAAQ,KAAK,MAAM;GAC3C,MAAM,WAAW,WAAW,YAAY,MAAM;GAC9C,MAAM,aAAa,aAAa,KAAK,KAAK,EAAE,YAAY,iBAAiB,QAAQ,KAC3E,QACA,KAAA;GACN,QAAQ,KAAK;IAAE;IAAQ;IAAO;IAAQ,OAAO,eAAe,KAAA;GAAU,CAAC;GACvE,IAAI,YAAY,KAAK,YAAY;IAAE;IAAQ;GAAO,CAAC;EACvD;CACJ;CACA,KAAK,GAAG;CACR,OAAO;AACX;;;;;;;AAQA,SAAgB,4BAA4B,MAAgB,YAAiD;CACzG,MAAM,iBAAyC,CAAC;CAChD,MAAM,YAA0B,QAAQ,KAAK,WAAW;EACpD,IAAI,OAAO,OAAO,gBAAgB,MAAM,GAAG,OAAO,eAAe;EACjE,MAAM,iBAAiB,UAAU,WAAW,YAAY,OAAO,MAAM;EACrE,MAAM,WAAW,WAAW,KAAA,IACtB,aACA,gBAAgB,SAAS,QAAQ,eAAe,aAAa,KAAA;EACnE,MAAM,OAAO,QAAQ,GAAG;EACxB,MAAM,OAAO,YAAY,CAAC,OAAO,OAAO,UAAU,GAAG,KAAK,OAAO,OAAO,UAAU,IAAI,IAAI,OAAO;EACjG,OAAO,WAAW,KAAA,IAAY,OAAO,GAAG,OAAO,UAAU,OAAO,OAAO,GAAG;CAC9E;CACA,KAAK,MAAM,OAAO,MAAM;EACpB,IAAI,CAAC,KAAK;EACV,KAAK,MAAM,EAAE,QAAQ,YAAY,cAAc,KAAgC,YAAY,QAAQ,GAC/F,eAAe,YAAY,UAAU;CAE7C;CACA,OAAO;AACX"}
@@ -1,6 +1,20 @@
1
- import { Entity, RebaseData } from "@rebasepro/types";
2
- /** Rows written per request, and per transaction where the data source has one. */
3
- export declare const IMPORT_BATCH_SIZE = 25;
1
+ import { CollectionConfig, Entity, RebaseData } from "@rebasepro/types";
2
+ /**
3
+ * Rows written per request, and per transaction where the data source has one.
4
+ *
5
+ * It was 25, which made a 10,000-row import 400 sequential round trips. The
6
+ * server takes up to 1,000 rows per `POST /bulk`; 500 keeps a failed batch's
7
+ * rollback small enough to retry, and the byte cap below bounds the body.
8
+ */
9
+ export declare const IMPORT_BATCH_SIZE = 500;
10
+ /**
11
+ * The most JSON one batch carries, in UTF-8 bytes. ~1 MB: a tenth of the
12
+ * server's default body limit (10 MB, `maxBodySize`), and under the 1 MiB a
13
+ * reverse proxy commonly allows by default (nginx's `client_max_body_size`),
14
+ * so wide rows shrink the batch instead of failing it with a 413. A row larger
15
+ * than this still goes, alone.
16
+ */
17
+ export declare const IMPORT_BATCH_MAX_BYTES = 1000000;
4
18
  /**
5
19
  * An import failure that says where it stopped.
6
20
  *
@@ -16,6 +30,13 @@ export interface ImportSaveError extends Error {
16
30
  failedFrom: number;
17
31
  /** Index after the last row of the batch that was not written. */
18
32
  failedTo: number;
33
+ /**
34
+ * Index of the row the server named as the cause, 0-based, when it named
35
+ * one (`Row 37: …` — every server message about one row of a bulk write
36
+ * starts that way, counted within the batch). The message is rewritten to
37
+ * name it the way the file does: from 1, counted from the first row.
38
+ */
39
+ failedRow?: number;
19
40
  }
20
41
  /**
21
42
  * Write imported entities in batches, reporting what was committed.
@@ -28,11 +49,19 @@ export interface ImportSaveError extends Error {
28
49
  *
29
50
  * @throws {ImportSaveError} naming the rows that were not written.
30
51
  */
31
- export declare function saveImportedEntities(dataClient: RebaseData, path: string, data: Partial<Entity<any>>[], { offset, batchSize, onBatchCommitted, bulkUnsupported }?: {
52
+ export declare function saveImportedEntities(dataClient: RebaseData, path: string, data: Partial<Entity<any>>[], { offset, batchSize, maxBatchBytes, onBatchCommitted, bulkUnsupported, collection }?: {
32
53
  offset?: number;
33
54
  batchSize?: number;
55
+ /** See {@link IMPORT_BATCH_MAX_BYTES}. */
56
+ maxBatchBytes?: number;
34
57
  onBatchCommitted?: (rowsWritten: number) => void;
35
58
  bulkUnsupported?: {
36
59
  current: boolean;
37
60
  };
61
+ /**
62
+ * The collection written to. With it, a row that updates a stored
63
+ * record with some of its columns is written as an update rather
64
+ * than refused for the required columns it leaves out.
65
+ */
66
+ collection?: CollectionConfig;
38
67
  }): Promise<void>;
@@ -0,0 +1,244 @@
1
+ import { findEntitiesByIds } from "../../util/find_entities_by_ids.js";
2
+ //#region src/data_import/utils/save_entities.ts
3
+ /**
4
+ * Rows written per request, and per transaction where the data source has one.
5
+ *
6
+ * It was 25, which made a 10,000-row import 400 sequential round trips. The
7
+ * server takes up to 1,000 rows per `POST /bulk`; 500 keeps a failed batch's
8
+ * rollback small enough to retry, and the byte cap below bounds the body.
9
+ */
10
+ var IMPORT_BATCH_SIZE = 500;
11
+ /**
12
+ * The most JSON one batch carries, in UTF-8 bytes. ~1 MB: a tenth of the
13
+ * server's default body limit (10 MB, `maxBodySize`), and under the 1 MiB a
14
+ * reverse proxy commonly allows by default (nginx's `client_max_body_size`),
15
+ * so wide rows shrink the batch instead of failing it with a 413. A row larger
16
+ * than this still goes, alone.
17
+ */
18
+ var IMPORT_BATCH_MAX_BYTES = 1e6;
19
+ /** The row a bulk write takes: the values, with the chosen id as a column. */
20
+ function toBulkRow(entity) {
21
+ const values = { ...entity.values ?? {} };
22
+ if (entity.id !== void 0 && entity.id !== null && entity.id !== "") values.id = entity.id;
23
+ return values;
24
+ }
25
+ function isBulkUnsupported(error) {
26
+ if (error?.code === "BULK_UNSUPPORTED") return true;
27
+ const message = error?.message ?? "";
28
+ return /bulk writes are not supported|does not support bulk/i.test(message);
29
+ }
30
+ /** The body was refused for its size: a proxy's or the server's 413, or too many rows. */
31
+ function isTooLarge(error) {
32
+ if ((error?.status ?? error?.statusCode) === 413) return true;
33
+ const code = error?.code;
34
+ return code === "PAYLOAD_TOO_LARGE" || code === "BULK_TOO_LARGE";
35
+ }
36
+ /** The length of a string in UTF-8 bytes, which is what a body limit counts. */
37
+ function utf8Length(text) {
38
+ let bytes = 0;
39
+ for (let i = 0; i < text.length; i++) {
40
+ const code = text.charCodeAt(i);
41
+ if (code < 128) bytes += 1;
42
+ else if (code < 2048) bytes += 2;
43
+ else if (code >= 55296 && code <= 56319) {
44
+ bytes += 4;
45
+ i++;
46
+ } else bytes += 3;
47
+ }
48
+ return bytes;
49
+ }
50
+ /** `{"rows":[`, `],"upsert":true}` and some slack. */
51
+ var BULK_ENVELOPE_BYTES = 64;
52
+ /**
53
+ * Where the batch starting at `start` ends: at `maxRows` rows, or before the
54
+ * row that would take the body past `maxBytes` — never before one row.
55
+ */
56
+ function batchEnd(data, start, maxRows, maxBytes) {
57
+ let bytes = BULK_ENVELOPE_BYTES;
58
+ let end = start;
59
+ while (end < data.length && end - start < maxRows) {
60
+ const rowBytes = utf8Length(JSON.stringify(toBulkRow(data[end]))) + 1;
61
+ if (end > start && bytes + rowBytes > maxBytes) break;
62
+ bytes += rowBytes;
63
+ end++;
64
+ }
65
+ return end;
66
+ }
67
+ /**
68
+ * The row a server message names, counted within the batch, and the message
69
+ * with that row counted the way the user's file counts it.
70
+ */
71
+ function locateFailedRow(error, start) {
72
+ const message = error?.message;
73
+ if (typeof message !== "string") return void 0;
74
+ const match = /^Row (\d+)(?: of \d+)?/.exec(message);
75
+ if (!match) return void 0;
76
+ const row = start + Number(match[1]);
77
+ return {
78
+ row,
79
+ message: `Row ${row + 1}` + message.slice(match[0].length)
80
+ };
81
+ }
82
+ function isConflict(error) {
83
+ if ((error?.status ?? error?.statusCode) === 409) return true;
84
+ const code = error?.code;
85
+ return code === "CONFLICT" || code === "23505";
86
+ }
87
+ /**
88
+ * The server refused a row only for the required columns it leaves out.
89
+ *
90
+ * `POST /bulk` with `upsert: true` judges each row as a create, since it may
91
+ * insert, so a row meant to update a stored record with some of its columns
92
+ * (`id,price`) is refused as `'name' is required`.
93
+ */
94
+ function isMissingRequiredOnly(error) {
95
+ const violations = error?.details?.violations;
96
+ return Array.isArray(violations) && violations.length > 0 && violations.every((v) => v?.code === "required");
97
+ }
98
+ /**
99
+ * Whether the collection's rows are the users, read the way the server reads it
100
+ * (`collection.auth`, `true` or `{ enabled: true }`).
101
+ *
102
+ * The server refuses an upsert there: a create hashes the password and runs
103
+ * `onCreateUser`, an update may not demote the last administrator, and an
104
+ * upsert decides between the two too late to follow either rule.
105
+ */
106
+ function isAuthCollection(collection) {
107
+ const auth = collection?.auth;
108
+ return auth === true || !!auth && typeof auth === "object" && auth.enabled === true;
109
+ }
110
+ /**
111
+ * The row a user creation takes. A row that carries a `password` asks the
112
+ * server to waive its password policy (`skipPasswordPolicy`): the accounts in
113
+ * an import had their passwords set under another system's rules. The server
114
+ * honours it only for an administrator.
115
+ */
116
+ function toUserCreationRow(entity) {
117
+ const row = toBulkRow(entity);
118
+ return typeof row.password === "string" && row.password !== "" ? {
119
+ ...row,
120
+ skipPasswordPolicy: true
121
+ } : row;
122
+ }
123
+ /**
124
+ * A batch split by whether each row's id is stored: the rows whose id is
125
+ * stored are updates — the given columns are written, the rest keep their
126
+ * values, as the per-row path and the preview's "overwritten" say — and the
127
+ * others are created, where a new row still needs every required column. A
128
+ * refusal of one of those names its row in `batch`.
129
+ *
130
+ * Used when the bulk upsert refused a batch for missing required columns
131
+ * (the creates then go back as an upsert), and for every batch of the auth
132
+ * collection, which takes no upsert (the creates go as a plain bulk create,
133
+ * which the server runs through user creation).
134
+ */
135
+ async function writeUpdatesAndCreates(accessor, batch, collection, createMany, upsert) {
136
+ const stored = await findEntitiesByIds(accessor, collection, batch.map((entity) => entity.id).filter((id) => id !== void 0 && id !== null && id !== ""));
137
+ const isUpdate = (entity) => entity.id !== void 0 && entity.id !== null && stored.has(String(entity.id));
138
+ const updates = batch.filter(isUpdate);
139
+ if (updates.length > 0) if (accessor.updateMany) await accessor.updateMany(updates.map((entity) => ({
140
+ id: entity.id,
141
+ data: entity.values ?? {}
142
+ })));
143
+ else for (const entity of updates) await accessor.update(entity.id, entity.values ?? {});
144
+ const creates = batch.map((entity, index) => ({
145
+ entity,
146
+ index
147
+ })).filter(({ entity }) => !isUpdate(entity));
148
+ if (creates.length === 0) return;
149
+ try {
150
+ const rows = creates.map(({ entity }) => isAuthCollection(collection) ? toUserCreationRow(entity) : toBulkRow(entity));
151
+ await (upsert ? createMany(rows, { upsert: true }) : createMany(rows));
152
+ } catch (e) {
153
+ const message = e?.message;
154
+ const match = typeof message === "string" ? /^Row (\d+)/.exec(message) : null;
155
+ if (match && creates[Number(match[1])]) e.message = `Row ${creates[Number(match[1])].index}` + message.slice(match[0].length);
156
+ throw e;
157
+ }
158
+ }
159
+ /**
160
+ * Write one batch, all-or-nothing wherever the data source can.
161
+ *
162
+ * `POST /<collection>/bulk` validates every row before the transaction opens,
163
+ * names a failure by row index, and takes the `upsert` flag the preview screen
164
+ * promises — none of which one `create` per row inside a `Promise.all` could
165
+ * offer, since `Promise.all` does not cancel its siblings and every request was
166
+ * its own transaction.
167
+ */
168
+ async function writeBatch(accessor, batch, bulkUnsupported, written, collection) {
169
+ if (accessor.createMany && !bulkUnsupported.current) try {
170
+ if (collection && isAuthCollection(collection)) {
171
+ await writeUpdatesAndCreates(accessor, batch, collection, accessor.createMany.bind(accessor), false);
172
+ written.count = batch.length;
173
+ return;
174
+ }
175
+ await accessor.createMany(batch.map(toBulkRow), { upsert: true });
176
+ written.count = batch.length;
177
+ return;
178
+ } catch (e) {
179
+ if (collection && !isAuthCollection(collection) && isMissingRequiredOnly(e) && batch.some((entity) => entity.id !== void 0 && entity.id !== null && entity.id !== "")) {
180
+ await writeUpdatesAndCreates(accessor, batch, collection, accessor.createMany.bind(accessor), true);
181
+ written.count = batch.length;
182
+ return;
183
+ }
184
+ if (!isBulkUnsupported(e)) throw e;
185
+ bulkUnsupported.current = true;
186
+ }
187
+ const usersCollection = !!collection && isAuthCollection(collection);
188
+ for (const entity of batch) {
189
+ try {
190
+ const values = usersCollection ? toUserCreationRow({ values: entity.values }) : entity.values ?? {};
191
+ await accessor.create(values, entity.id);
192
+ } catch (e) {
193
+ if (entity.id === void 0 || !isConflict(e)) throw e;
194
+ await accessor.update(entity.id, entity.values ?? {});
195
+ }
196
+ written.count++;
197
+ }
198
+ }
199
+ /**
200
+ * Write imported entities in batches, reporting what was committed.
201
+ *
202
+ * Resumable on purpose: a failure at row 4 000 leaves rows 1–3 999 in the table
203
+ * whatever this does, so the only useful thing to report is where to carry on
204
+ * from. `offset` is that point — the Retry button passes back the `committed`
205
+ * count of the error it is retrying, instead of starting from zero and
206
+ * conflicting on every row that already exists.
207
+ *
208
+ * @throws {ImportSaveError} naming the rows that were not written.
209
+ */
210
+ async function saveImportedEntities(dataClient, path, data, { offset = 0, batchSize = 500, maxBatchBytes = IMPORT_BATCH_MAX_BYTES, onBatchCommitted = () => void 0, bulkUnsupported = { current: false }, collection } = {}) {
211
+ console.debug("Saving imported data", offset, batchSize);
212
+ const accessor = dataClient.collection(path);
213
+ let maxRows = Math.max(1, batchSize);
214
+ let start = offset;
215
+ while (start < data.length) {
216
+ const batch = data.slice(start, batchEnd(data, start, maxRows, maxBatchBytes));
217
+ const written = { count: 0 };
218
+ try {
219
+ await writeBatch(accessor, batch, bulkUnsupported, written, collection);
220
+ } catch (e) {
221
+ if (written.count === 0 && batch.length > 1 && isTooLarge(e)) {
222
+ maxRows = Math.max(1, Math.floor(batch.length / 2));
223
+ continue;
224
+ }
225
+ const located = locateFailedRow(e, start + written.count);
226
+ throw Object.assign(e, {
227
+ committed: start + written.count,
228
+ failedFrom: start + written.count,
229
+ failedTo: start + batch.length,
230
+ ...located ? {
231
+ failedRow: located.row,
232
+ message: located.message
233
+ } : {}
234
+ });
235
+ }
236
+ start += batch.length;
237
+ onBatchCommitted(start);
238
+ }
239
+ onBatchCommitted(data.length);
240
+ }
241
+ //#endregion
242
+ export { IMPORT_BATCH_MAX_BYTES, IMPORT_BATCH_SIZE, saveImportedEntities };
243
+
244
+ //# sourceMappingURL=save_entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save_entities.js","names":[],"sources":["../../../src/data_import/utils/save_entities.ts"],"sourcesContent":["import { CollectionAccessor, CollectionConfig, Entity, RebaseData } from \"@rebasepro/types\";\nimport { findEntitiesByIds } from \"../../util/find_entities_by_ids\";\n\n/**\n * Rows written per request, and per transaction where the data source has one.\n *\n * It was 25, which made a 10,000-row import 400 sequential round trips. The\n * server takes up to 1,000 rows per `POST /bulk`; 500 keeps a failed batch's\n * rollback small enough to retry, and the byte cap below bounds the body.\n */\nexport const IMPORT_BATCH_SIZE = 500;\n\n/**\n * The most JSON one batch carries, in UTF-8 bytes. ~1 MB: a tenth of the\n * server's default body limit (10 MB, `maxBodySize`), and under the 1 MiB a\n * reverse proxy commonly allows by default (nginx's `client_max_body_size`),\n * so wide rows shrink the batch instead of failing it with a 413. A row larger\n * than this still goes, alone.\n */\nexport const IMPORT_BATCH_MAX_BYTES = 1_000_000;\n\n/**\n * An import failure that says where it stopped.\n *\n * \"Error saving data / null value in column \"sku\" violates not-null constraint\"\n * on a ten-thousand-row import named no row, and the Retry button restarted at\n * zero — where the rows already written now conflicted, so it could never\n * succeed. Both halves of that are what this carries.\n */\nexport interface ImportSaveError extends Error {\n /** Rows written and confirmed before the failure. Where a retry resumes. */\n committed: number;\n /** Index of the first row that was not written, 0-based. */\n failedFrom: number;\n /** Index after the last row of the batch that was not written. */\n failedTo: number;\n /**\n * Index of the row the server named as the cause, 0-based, when it named\n * one (`Row 37: …` — every server message about one row of a bulk write\n * starts that way, counted within the batch). The message is rewritten to\n * name it the way the file does: from 1, counted from the first row.\n */\n failedRow?: number;\n}\n\n/** The row a bulk write takes: the values, with the chosen id as a column. */\nfunction toBulkRow(entity: Partial<Entity<any>>): Record<string, unknown> {\n const values = { ...(entity.values ?? {}) } as Record<string, unknown>;\n if (entity.id !== undefined && entity.id !== null && entity.id !== \"\") {\n // Exactly what single-row `create(values, id)` puts on the wire.\n values.id = entity.id;\n }\n return values;\n}\n\nfunction isBulkUnsupported(error: unknown): boolean {\n if ((error as { code?: string })?.code === \"BULK_UNSUPPORTED\") return true;\n const message = (error as Error)?.message ?? \"\";\n return /bulk writes are not supported|does not support bulk/i.test(message);\n}\n\n/** The body was refused for its size: a proxy's or the server's 413, or too many rows. */\nfunction isTooLarge(error: unknown): boolean {\n const status = (error as { status?: number; statusCode?: number })?.status\n ?? (error as { statusCode?: number })?.statusCode;\n if (status === 413) return true;\n const code = (error as { code?: string })?.code;\n return code === \"PAYLOAD_TOO_LARGE\" || code === \"BULK_TOO_LARGE\";\n}\n\n/** The length of a string in UTF-8 bytes, which is what a body limit counts. */\nfunction utf8Length(text: string): number {\n let bytes = 0;\n for (let i = 0; i < text.length; i++) {\n const code = text.charCodeAt(i);\n if (code < 0x80) bytes += 1;\n else if (code < 0x800) bytes += 2;\n else if (code >= 0xD800 && code <= 0xDBFF) {\n bytes += 4;\n i++;\n } else bytes += 3;\n }\n return bytes;\n}\n\n/** `{\"rows\":[`, `],\"upsert\":true}` and some slack. */\nconst BULK_ENVELOPE_BYTES = 64;\n\n/**\n * Where the batch starting at `start` ends: at `maxRows` rows, or before the\n * row that would take the body past `maxBytes` — never before one row.\n */\nfunction batchEnd(data: Partial<Entity<any>>[], start: number, maxRows: number, maxBytes: number): number {\n let bytes = BULK_ENVELOPE_BYTES;\n let end = start;\n while (end < data.length && end - start < maxRows) {\n const rowBytes = utf8Length(JSON.stringify(toBulkRow(data[end]))) + 1;\n if (end > start && bytes + rowBytes > maxBytes) break;\n bytes += rowBytes;\n end++;\n }\n return end;\n}\n\n/**\n * The row a server message names, counted within the batch, and the message\n * with that row counted the way the user's file counts it.\n */\nfunction locateFailedRow(error: unknown, start: number): { row: number, message: string } | undefined {\n const message = (error as Error)?.message;\n if (typeof message !== \"string\") return undefined;\n const match = /^Row (\\d+)(?: of \\d+)?/.exec(message);\n if (!match) return undefined;\n const row = start + Number(match[1]);\n return { row, message: `Row ${row + 1}` + message.slice(match[0].length) };\n}\n\nfunction isConflict(error: unknown): boolean {\n const status = (error as { status?: number; statusCode?: number })?.status\n ?? (error as { statusCode?: number })?.statusCode;\n if (status === 409) return true;\n const code = (error as { code?: string })?.code;\n return code === \"CONFLICT\" || code === \"23505\";\n}\n\n/**\n * The server refused a row only for the required columns it leaves out.\n *\n * `POST /bulk` with `upsert: true` judges each row as a create, since it may\n * insert, so a row meant to update a stored record with some of its columns\n * (`id,price`) is refused as `'name' is required`.\n */\nfunction isMissingRequiredOnly(error: unknown): boolean {\n const violations = (error as { details?: { violations?: unknown } })?.details?.violations;\n return Array.isArray(violations) && violations.length > 0\n && violations.every(v => (v as { code?: unknown })?.code === \"required\");\n}\n\n/**\n * Whether the collection's rows are the users, read the way the server reads it\n * (`collection.auth`, `true` or `{ enabled: true }`).\n *\n * The server refuses an upsert there: a create hashes the password and runs\n * `onCreateUser`, an update may not demote the last administrator, and an\n * upsert decides between the two too late to follow either rule.\n */\nfunction isAuthCollection(collection: CollectionConfig | undefined): boolean {\n const auth = collection?.auth;\n return auth === true || (!!auth && typeof auth === \"object\" && auth.enabled === true);\n}\n\n/**\n * The row a user creation takes. A row that carries a `password` asks the\n * server to waive its password policy (`skipPasswordPolicy`): the accounts in\n * an import had their passwords set under another system's rules. The server\n * honours it only for an administrator.\n */\nfunction toUserCreationRow(entity: Partial<Entity<any>>): Record<string, unknown> {\n const row = toBulkRow(entity);\n return typeof row.password === \"string\" && row.password !== \"\" ? { ...row, skipPasswordPolicy: true } : row;\n}\n\n/**\n * A batch split by whether each row's id is stored: the rows whose id is\n * stored are updates — the given columns are written, the rest keep their\n * values, as the per-row path and the preview's \"overwritten\" say — and the\n * others are created, where a new row still needs every required column. A\n * refusal of one of those names its row in `batch`.\n *\n * Used when the bulk upsert refused a batch for missing required columns\n * (the creates then go back as an upsert), and for every batch of the auth\n * collection, which takes no upsert (the creates go as a plain bulk create,\n * which the server runs through user creation).\n */\nasync function writeUpdatesAndCreates(accessor: CollectionAccessor,\n batch: Partial<Entity<any>>[],\n collection: CollectionConfig,\n createMany: NonNullable<CollectionAccessor[\"createMany\"]>,\n upsert: boolean): Promise<void> {\n\n const ids = batch.map(entity => entity.id).filter((id): id is string | number => id !== undefined && id !== null && id !== \"\");\n const stored = await findEntitiesByIds(accessor, collection, ids);\n const isUpdate = (entity: Partial<Entity<any>>) => entity.id !== undefined && entity.id !== null && stored.has(String(entity.id));\n\n const updates = batch.filter(isUpdate);\n if (updates.length > 0) {\n if (accessor.updateMany) {\n await accessor.updateMany(updates.map(entity => ({ id: entity.id as string | number, data: entity.values ?? {} })));\n } else {\n for (const entity of updates) await accessor.update(entity.id as string | number, entity.values ?? {});\n }\n }\n\n const creates = batch.map((entity, index) => ({ entity, index })).filter(({ entity }) => !isUpdate(entity));\n if (creates.length === 0) return;\n try {\n const rows = creates.map(({ entity }) => isAuthCollection(collection) ? toUserCreationRow(entity) : toBulkRow(entity));\n await (upsert ? createMany(rows, { upsert: true }) : createMany(rows));\n } catch (e) {\n // \"Row 1\" of the rows sent is \"Row <n>\" of the batch.\n const message = (e as Error)?.message;\n const match = typeof message === \"string\" ? /^Row (\\d+)/.exec(message) : null;\n if (match && creates[Number(match[1])]) {\n (e as Error).message = `Row ${creates[Number(match[1])].index}` + message.slice(match[0].length);\n }\n throw e;\n }\n}\n\n/**\n * Write one batch, all-or-nothing wherever the data source can.\n *\n * `POST /<collection>/bulk` validates every row before the transaction opens,\n * names a failure by row index, and takes the `upsert` flag the preview screen\n * promises — none of which one `create` per row inside a `Promise.all` could\n * offer, since `Promise.all` does not cancel its siblings and every request was\n * its own transaction.\n */\nasync function writeBatch(accessor: CollectionAccessor,\n batch: Partial<Entity<any>>[],\n bulkUnsupported: { current: boolean },\n written: { count: number },\n collection: CollectionConfig | undefined): Promise<void> {\n\n if (accessor.createMany && !bulkUnsupported.current) {\n try {\n if (collection && isAuthCollection(collection)) {\n // Not one transaction: the updates are written before the\n // creates, and a retry of the batch writes them again, to the\n // same values — while a stored id among the creates is a\n // conflict, never an overwrite of a user's password.\n await writeUpdatesAndCreates(accessor, batch, collection, accessor.createMany.bind(accessor), false);\n written.count = batch.length;\n return;\n }\n await accessor.createMany(batch.map(toBulkRow), { upsert: true });\n written.count = batch.length;\n return;\n } catch (e) {\n if (collection && !isAuthCollection(collection) && isMissingRequiredOnly(e) && batch.some(entity => entity.id !== undefined && entity.id !== null && entity.id !== \"\")) {\n // Not one transaction any more: a refused create leaves the\n // updates before it written, and a retry of the batch writes\n // them again, to the same values.\n await writeUpdatesAndCreates(accessor, batch, collection, accessor.createMany.bind(accessor), true);\n written.count = batch.length;\n return;\n }\n if (!isBulkUnsupported(e)) throw e;\n // A data source without bulk writes: remember it, so the failed\n // round trip is not paid again on every later batch.\n bulkUnsupported.current = true;\n }\n }\n\n // Sequential, not `Promise.all`: a rejected write does not cancel its\n // siblings, so a parallel batch commits an indeterminate subset of itself\n // and nobody can say which rows landed.\n const usersCollection = !!collection && isAuthCollection(collection);\n for (const entity of batch) {\n try {\n const values = usersCollection\n ? toUserCreationRow({ values: entity.values })\n : entity.values ?? {};\n await accessor.create(values, entity.id);\n } catch (e) {\n // Without `/bulk` there is no upsert, so the preview's promise is\n // honoured the only way left: a row that collided on an id the user\n // supplied is overwritten. A row with no id had nothing to collide\n // on, and every other failure is still a failure.\n if (entity.id === undefined || !isConflict(e)) throw e;\n await accessor.update(entity.id, entity.values ?? {});\n }\n written.count++;\n }\n}\n\n/**\n * Write imported entities in batches, reporting what was committed.\n *\n * Resumable on purpose: a failure at row 4 000 leaves rows 1–3 999 in the table\n * whatever this does, so the only useful thing to report is where to carry on\n * from. `offset` is that point — the Retry button passes back the `committed`\n * count of the error it is retrying, instead of starting from zero and\n * conflicting on every row that already exists.\n *\n * @throws {ImportSaveError} naming the rows that were not written.\n */\nexport async function saveImportedEntities(dataClient: RebaseData,\n path: string,\n data: Partial<Entity<any>>[],\n {\n offset = 0,\n batchSize = IMPORT_BATCH_SIZE,\n maxBatchBytes = IMPORT_BATCH_MAX_BYTES,\n onBatchCommitted = () => undefined,\n bulkUnsupported = { current: false },\n collection\n }: {\n offset?: number;\n batchSize?: number;\n /** See {@link IMPORT_BATCH_MAX_BYTES}. */\n maxBatchBytes?: number;\n onBatchCommitted?: (rowsWritten: number) => void;\n bulkUnsupported?: { current: boolean };\n /**\n * The collection written to. With it, a row that updates a stored\n * record with some of its columns is written as an update rather\n * than refused for the required columns it leaves out.\n */\n collection?: CollectionConfig;\n } = {}): Promise<void> {\n\n console.debug(\"Saving imported data\", offset, batchSize);\n\n const accessor = dataClient.collection(path);\n\n // Lowered for the rest of the import when a batch is refused for its\n // size — a server or proxy configured below the byte cap — so an import\n // that worked in small batches does not fail in large ones.\n let maxRows = Math.max(1, batchSize);\n let start = offset;\n while (start < data.length) {\n const batch = data.slice(start, batchEnd(data, start, maxRows, maxBatchBytes));\n const written = { count: 0 };\n try {\n await writeBatch(accessor, batch, bulkUnsupported, written, collection);\n } catch (e) {\n if (written.count === 0 && batch.length > 1 && isTooLarge(e)) {\n maxRows = Math.max(1, Math.floor(batch.length / 2));\n continue;\n }\n const located = locateFailedRow(e, start + written.count);\n throw Object.assign(e as Error, {\n committed: start + written.count,\n failedFrom: start + written.count,\n failedTo: start + batch.length,\n ...(located ? { failedRow: located.row, message: located.message } : {})\n }) as ImportSaveError;\n }\n start += batch.length;\n onBatchCommitted(start);\n }\n\n onBatchCommitted(data.length);\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,oBAAoB;;;;;;;;AASjC,IAAa,yBAAyB;;AA2BtC,SAAS,UAAU,QAAuD;CACtE,MAAM,SAAS,EAAE,GAAI,OAAO,UAAU,CAAC,EAAG;CAC1C,IAAI,OAAO,OAAO,KAAA,KAAa,OAAO,OAAO,QAAQ,OAAO,OAAO,IAE/D,OAAO,KAAK,OAAO;CAEvB,OAAO;AACX;AAEA,SAAS,kBAAkB,OAAyB;CAChD,IAAK,OAA6B,SAAS,oBAAoB,OAAO;CACtE,MAAM,UAAW,OAAiB,WAAW;CAC7C,OAAO,uDAAuD,KAAK,OAAO;AAC9E;;AAGA,SAAS,WAAW,OAAyB;CAGzC,KAFgB,OAAoD,UAC5D,OAAmC,gBAC5B,KAAK,OAAO;CAC3B,MAAM,OAAQ,OAA6B;CAC3C,OAAO,SAAS,uBAAuB,SAAS;AACpD;;AAGA,SAAS,WAAW,MAAsB;C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