@rebasepro/plugin-data-enhancement 0.0.1-canary.000dc36

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 (318) hide show
  1. package/LICENSE +114 -0
  2. package/README.md +89 -0
  3. package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
  4. package/dist/common/src/collections/index.d.ts +1 -0
  5. package/dist/common/src/data/buildRebaseData.d.ts +14 -0
  6. package/dist/common/src/index.d.ts +3 -0
  7. package/dist/common/src/util/builders.d.ts +57 -0
  8. package/dist/common/src/util/callbacks.d.ts +6 -0
  9. package/dist/common/src/util/collections.d.ts +11 -0
  10. package/dist/common/src/util/common.d.ts +2 -0
  11. package/dist/common/src/util/conditions.d.ts +26 -0
  12. package/dist/common/src/util/entities.d.ts +58 -0
  13. package/dist/common/src/util/enums.d.ts +3 -0
  14. package/dist/common/src/util/index.d.ts +16 -0
  15. package/dist/common/src/util/navigation_from_path.d.ts +34 -0
  16. package/dist/common/src/util/navigation_utils.d.ts +20 -0
  17. package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
  18. package/dist/common/src/util/paths.d.ts +14 -0
  19. package/dist/common/src/util/permissions.d.ts +5 -0
  20. package/dist/common/src/util/references.d.ts +2 -0
  21. package/dist/common/src/util/relations.d.ts +22 -0
  22. package/dist/common/src/util/resolutions.d.ts +72 -0
  23. package/dist/common/src/util/storage.d.ts +24 -0
  24. package/dist/core/src/components/AIIcon.d.ts +16 -0
  25. package/dist/core/src/components/ConfirmationDialog.d.ts +9 -0
  26. package/dist/core/src/components/Debug/UIReferenceView.d.ts +1 -0
  27. package/dist/core/src/components/Debug/UIStyleGuide.d.ts +1 -0
  28. package/dist/core/src/components/ErrorTooltip.d.ts +2 -0
  29. package/dist/core/src/components/ErrorView.d.ts +21 -0
  30. package/dist/core/src/components/LanguageToggle.d.ts +1 -0
  31. package/dist/core/src/components/LoginView/LoginView.d.ts +68 -0
  32. package/dist/core/src/components/LoginView/index.d.ts +2 -0
  33. package/dist/core/src/components/NotFoundPage.d.ts +1 -0
  34. package/dist/core/src/components/RebaseAuth.d.ts +10 -0
  35. package/dist/core/src/components/RebaseLogo.d.ts +7 -0
  36. package/dist/core/src/components/UnsavedChangesDialog.d.ts +9 -0
  37. package/dist/core/src/components/UserDisplay.d.ts +7 -0
  38. package/dist/core/src/components/UserSelectPopover.d.ts +62 -0
  39. package/dist/core/src/components/UserSettingsView.d.ts +1 -0
  40. package/dist/core/src/components/common/index.d.ts +6 -0
  41. package/dist/core/src/components/common/table_height.d.ts +5 -0
  42. package/dist/core/src/components/common/types.d.ts +63 -0
  43. package/dist/core/src/components/common/useColumnsIds.d.ts +9 -0
  44. package/dist/core/src/components/common/useDataTableController.d.ts +45 -0
  45. package/dist/core/src/components/common/useDebouncedData.d.ts +9 -0
  46. package/dist/core/src/components/common/useScrollRestoration.d.ts +14 -0
  47. package/dist/core/src/components/index.d.ts +16 -0
  48. package/dist/core/src/contexts/AdminModeController.d.ts +4 -0
  49. package/dist/core/src/contexts/AnalyticsContext.d.ts +3 -0
  50. package/dist/core/src/contexts/AuthControllerContext.d.ts +3 -0
  51. package/dist/core/src/contexts/CustomizationControllerContext.d.ts +3 -0
  52. package/dist/core/src/contexts/DataDriverContext.d.ts +3 -0
  53. package/dist/core/src/contexts/DatabaseAdminContext.d.ts +3 -0
  54. package/dist/core/src/contexts/DialogsProvider.d.ts +4 -0
  55. package/dist/core/src/contexts/EffectiveRoleController.d.ts +4 -0
  56. package/dist/core/src/contexts/InternalUserManagementContext.d.ts +3 -0
  57. package/dist/core/src/contexts/ModeController.d.ts +4 -0
  58. package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +6 -0
  59. package/dist/core/src/contexts/RebaseDataContext.d.ts +3 -0
  60. package/dist/core/src/contexts/SnackbarProvider.d.ts +2 -0
  61. package/dist/core/src/contexts/StorageSourceContext.d.ts +3 -0
  62. package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
  63. package/dist/core/src/contexts/index.d.ts +13 -0
  64. package/dist/core/src/core/PluginLifecycleManager.d.ts +17 -0
  65. package/dist/core/src/core/PluginProviderStack.d.ts +21 -0
  66. package/dist/core/src/core/Rebase.d.ts +14 -0
  67. package/dist/core/src/core/RebaseProps.d.ts +136 -0
  68. package/dist/core/src/core/RebaseRouter.d.ts +4 -0
  69. package/dist/core/src/core/RebaseRoutes.d.ts +17 -0
  70. package/dist/core/src/core/index.d.ts +4 -0
  71. package/dist/core/src/hooks/ApiConfigContext.d.ts +24 -0
  72. package/dist/core/src/hooks/data/delete.d.ts +31 -0
  73. package/dist/core/src/hooks/data/save.d.ts +34 -0
  74. package/dist/core/src/hooks/data/useCollectionFetch.d.ts +51 -0
  75. package/dist/core/src/hooks/data/useData.d.ts +13 -0
  76. package/dist/core/src/hooks/data/useDataOrder.d.ts +12 -0
  77. package/dist/core/src/hooks/data/useEntityFetch.d.ts +38 -0
  78. package/dist/core/src/hooks/data/useRelationSelector.d.ts +52 -0
  79. package/dist/core/src/hooks/data/useUserSelector.d.ts +31 -0
  80. package/dist/core/src/hooks/index.d.ts +37 -0
  81. package/dist/core/src/hooks/useAdminModeController.d.ts +19 -0
  82. package/dist/core/src/hooks/useAnalyticsController.d.ts +5 -0
  83. package/dist/core/src/hooks/useAuthController.d.ts +11 -0
  84. package/dist/core/src/hooks/useAuthSubscription.d.ts +2 -0
  85. package/dist/core/src/hooks/useBackendStorageSource.d.ts +30 -0
  86. package/dist/core/src/hooks/useBridgeRegistration.d.ts +18 -0
  87. package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +6 -0
  88. package/dist/core/src/hooks/useBuildAdminModeController.d.ts +6 -0
  89. package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +8 -0
  90. package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
  91. package/dist/core/src/hooks/useBuildModeController.d.ts +6 -0
  92. package/dist/core/src/hooks/useClipboard.d.ts +57 -0
  93. package/dist/core/src/hooks/useCollapsedGroups.d.ts +12 -0
  94. package/dist/core/src/hooks/useCustomizationController.d.ts +11 -0
  95. package/dist/core/src/hooks/useDialogsController.d.ts +11 -0
  96. package/dist/core/src/hooks/useEffectiveRoleController.d.ts +7 -0
  97. package/dist/core/src/hooks/useInternalUserManagementController.d.ts +12 -0
  98. package/dist/core/src/hooks/useLargeLayout.d.ts +1 -0
  99. package/dist/core/src/hooks/useModeController.d.ts +19 -0
  100. package/dist/core/src/hooks/usePermissions.d.ts +12 -0
  101. package/dist/core/src/hooks/useRebaseClient.d.ts +5 -0
  102. package/dist/core/src/hooks/useRebaseContext.d.ts +11 -0
  103. package/dist/core/src/hooks/useRebaseRegistry.d.ts +34 -0
  104. package/dist/core/src/hooks/useSlot.d.ts +18 -0
  105. package/dist/core/src/hooks/useSnackbarController.d.ts +20 -0
  106. package/dist/core/src/hooks/useStorageSource.d.ts +7 -0
  107. package/dist/core/src/hooks/useStudioBridge.d.ts +91 -0
  108. package/dist/core/src/hooks/useTranslation.d.ts +17 -0
  109. package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +12 -0
  110. package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +8 -0
  111. package/dist/core/src/hooks/useValidateAuthenticator.d.ts +21 -0
  112. package/dist/core/src/i18n/RebaseI18nProvider.d.ts +33 -0
  113. package/dist/core/src/index.d.ts +15 -0
  114. package/dist/core/src/internal/common.d.ts +3 -0
  115. package/dist/core/src/internal/useRestoreScroll.d.ts +6 -0
  116. package/dist/core/src/locales/de.d.ts +2 -0
  117. package/dist/core/src/locales/en.d.ts +10 -0
  118. package/dist/core/src/locales/es.d.ts +10 -0
  119. package/dist/core/src/locales/fr.d.ts +2 -0
  120. package/dist/core/src/locales/hi.d.ts +2 -0
  121. package/dist/core/src/locales/it.d.ts +2 -0
  122. package/dist/core/src/locales/pt.d.ts +7 -0
  123. package/dist/core/src/util/constants.d.ts +1 -0
  124. package/dist/core/src/util/createFormexStub.d.ts +2 -0
  125. package/dist/core/src/util/entity_cache.d.ts +27 -0
  126. package/dist/core/src/util/enums.d.ts +5 -0
  127. package/dist/core/src/util/icon_list.d.ts +5 -0
  128. package/dist/core/src/util/icon_synonyms.d.ts +1 -0
  129. package/dist/core/src/util/icons.d.ts +20 -0
  130. package/dist/core/src/util/index.d.ts +10 -0
  131. package/dist/core/src/util/previews.d.ts +4 -0
  132. package/dist/core/src/util/useStorageUploadController.d.ts +38 -0
  133. package/dist/core/src/util/useTraceUpdate.d.ts +2 -0
  134. package/dist/formex/src/Field.d.ts +52 -0
  135. package/dist/formex/src/Formex.d.ts +7 -0
  136. package/dist/formex/src/index.d.ts +5 -0
  137. package/dist/formex/src/types.d.ts +40 -0
  138. package/dist/formex/src/useCreateFormex.d.ts +14 -0
  139. package/dist/formex/src/utils.d.ts +16 -0
  140. package/dist/index.es.js +751 -0
  141. package/dist/index.es.js.map +1 -0
  142. package/dist/index.umd.js +746 -0
  143. package/dist/index.umd.js.map +1 -0
  144. package/dist/plugin-data-enhancement/src/api.d.ts +34 -0
  145. package/dist/plugin-data-enhancement/src/components/DataEnhancementControllerProvider.d.ts +14 -0
  146. package/dist/plugin-data-enhancement/src/components/FormEnhanceAction.d.ts +10 -0
  147. package/dist/plugin-data-enhancement/src/editor/useEditorAIController.d.ts +4 -0
  148. package/dist/plugin-data-enhancement/src/index.d.ts +4 -0
  149. package/dist/plugin-data-enhancement/src/locales/de.d.ts +21 -0
  150. package/dist/plugin-data-enhancement/src/locales/en.d.ts +21 -0
  151. package/dist/plugin-data-enhancement/src/locales/es.d.ts +21 -0
  152. package/dist/plugin-data-enhancement/src/locales/fr.d.ts +21 -0
  153. package/dist/plugin-data-enhancement/src/locales/hi.d.ts +21 -0
  154. package/dist/plugin-data-enhancement/src/locales/it.d.ts +21 -0
  155. package/dist/plugin-data-enhancement/src/locales/pt.d.ts +21 -0
  156. package/dist/plugin-data-enhancement/src/types/data_enhancement_controller.d.ts +71 -0
  157. package/dist/plugin-data-enhancement/src/types/subscriptions_message_props.d.ts +3 -0
  158. package/dist/plugin-data-enhancement/src/useDataEnhancementPlugin.d.ts +29 -0
  159. package/dist/plugin-data-enhancement/src/utils/diffStrings.d.ts +7 -0
  160. package/dist/plugin-data-enhancement/src/utils/properties.d.ts +3 -0
  161. package/dist/plugin-data-enhancement/src/utils/strings_counter.d.ts +2 -0
  162. package/dist/plugin-data-enhancement/src/utils/suggestions.d.ts +1 -0
  163. package/dist/plugin-data-enhancement/src/utils/values.d.ts +1 -0
  164. package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
  165. package/dist/types/src/controllers/auth.d.ts +119 -0
  166. package/dist/types/src/controllers/client.d.ts +170 -0
  167. package/dist/types/src/controllers/collection_registry.d.ts +46 -0
  168. package/dist/types/src/controllers/customization_controller.d.ts +60 -0
  169. package/dist/types/src/controllers/data.d.ts +168 -0
  170. package/dist/types/src/controllers/data_driver.d.ts +195 -0
  171. package/dist/types/src/controllers/database_admin.d.ts +11 -0
  172. package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
  173. package/dist/types/src/controllers/effective_role.d.ts +4 -0
  174. package/dist/types/src/controllers/email.d.ts +34 -0
  175. package/dist/types/src/controllers/index.d.ts +18 -0
  176. package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
  177. package/dist/types/src/controllers/navigation.d.ts +213 -0
  178. package/dist/types/src/controllers/registry.d.ts +54 -0
  179. package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
  180. package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
  181. package/dist/types/src/controllers/snackbar.d.ts +24 -0
  182. package/dist/types/src/controllers/storage.d.ts +171 -0
  183. package/dist/types/src/index.d.ts +4 -0
  184. package/dist/types/src/rebase_context.d.ts +105 -0
  185. package/dist/types/src/types/backend.d.ts +536 -0
  186. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  187. package/dist/types/src/types/builders.d.ts +15 -0
  188. package/dist/types/src/types/chips.d.ts +5 -0
  189. package/dist/types/src/types/collections.d.ts +857 -0
  190. package/dist/types/src/types/cron.d.ts +102 -0
  191. package/dist/types/src/types/data_source.d.ts +64 -0
  192. package/dist/types/src/types/entities.d.ts +145 -0
  193. package/dist/types/src/types/entity_actions.d.ts +98 -0
  194. package/dist/types/src/types/entity_callbacks.d.ts +173 -0
  195. package/dist/types/src/types/entity_link_builder.d.ts +7 -0
  196. package/dist/types/src/types/entity_overrides.d.ts +10 -0
  197. package/dist/types/src/types/entity_views.d.ts +59 -0
  198. package/dist/types/src/types/export_import.d.ts +21 -0
  199. package/dist/types/src/types/formex.d.ts +40 -0
  200. package/dist/types/src/types/index.d.ts +25 -0
  201. package/dist/types/src/types/locales.d.ts +4 -0
  202. package/dist/types/src/types/modify_collections.d.ts +5 -0
  203. package/dist/types/src/types/plugins.d.ts +282 -0
  204. package/dist/types/src/types/properties.d.ts +1148 -0
  205. package/dist/types/src/types/property_config.d.ts +70 -0
  206. package/dist/types/src/types/relations.d.ts +336 -0
  207. package/dist/types/src/types/slots.d.ts +262 -0
  208. package/dist/types/src/types/translations.d.ts +874 -0
  209. package/dist/types/src/types/user_management_delegate.d.ts +121 -0
  210. package/dist/types/src/types/websockets.d.ts +78 -0
  211. package/dist/types/src/users/index.d.ts +2 -0
  212. package/dist/types/src/users/roles.d.ts +22 -0
  213. package/dist/types/src/users/user.d.ts +46 -0
  214. package/dist/ui/src/components/Alert.d.ts +12 -0
  215. package/dist/ui/src/components/Autocomplete.d.ts +21 -0
  216. package/dist/ui/src/components/Avatar.d.ts +11 -0
  217. package/dist/ui/src/components/Badge.d.ts +8 -0
  218. package/dist/ui/src/components/BooleanSwitch.d.ts +14 -0
  219. package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +17 -0
  220. package/dist/ui/src/components/Button.d.ts +14 -0
  221. package/dist/ui/src/components/Card.d.ts +9 -0
  222. package/dist/ui/src/components/CenteredView.d.ts +9 -0
  223. package/dist/ui/src/components/Checkbox.d.ts +13 -0
  224. package/dist/ui/src/components/Chip.d.ts +26 -0
  225. package/dist/ui/src/components/CircularProgress.d.ts +5 -0
  226. package/dist/ui/src/components/CircularProgressCenter.d.ts +11 -0
  227. package/dist/ui/src/components/Collapse.d.ts +9 -0
  228. package/dist/ui/src/components/ColorPicker.d.ts +30 -0
  229. package/dist/ui/src/components/Container.d.ts +8 -0
  230. package/dist/ui/src/components/DateTimeField.d.ts +24 -0
  231. package/dist/ui/src/components/DebouncedTextField.d.ts +2 -0
  232. package/dist/ui/src/components/Dialog.d.ts +39 -0
  233. package/dist/ui/src/components/DialogActions.d.ts +7 -0
  234. package/dist/ui/src/components/DialogContent.d.ts +7 -0
  235. package/dist/ui/src/components/DialogTitle.d.ts +10 -0
  236. package/dist/ui/src/components/ErrorBoundary.d.ts +11 -0
  237. package/dist/ui/src/components/ExpandablePanel.d.ts +12 -0
  238. package/dist/ui/src/components/FileUpload.d.ts +23 -0
  239. package/dist/ui/src/components/IconButton.d.ts +12 -0
  240. package/dist/ui/src/components/InfoLabel.d.ts +5 -0
  241. package/dist/ui/src/components/InputLabel.d.ts +11 -0
  242. package/dist/ui/src/components/Label.d.ts +7 -0
  243. package/dist/ui/src/components/LoadingButton.d.ts +7 -0
  244. package/dist/ui/src/components/Markdown.d.ts +10 -0
  245. package/dist/ui/src/components/Menu.d.ts +23 -0
  246. package/dist/ui/src/components/Menubar.d.ts +80 -0
  247. package/dist/ui/src/components/MultiSelect.d.ts +48 -0
  248. package/dist/ui/src/components/Paper.d.ts +6 -0
  249. package/dist/ui/src/components/Popover.d.ts +24 -0
  250. package/dist/ui/src/components/RadioGroup.d.ts +28 -0
  251. package/dist/ui/src/components/ResizablePanels.d.ts +18 -0
  252. package/dist/ui/src/components/SearchBar.d.ts +22 -0
  253. package/dist/ui/src/components/Select.d.ts +43 -0
  254. package/dist/ui/src/components/Separator.d.ts +5 -0
  255. package/dist/ui/src/components/Sheet.d.ts +22 -0
  256. package/dist/ui/src/components/Skeleton.d.ts +6 -0
  257. package/dist/ui/src/components/Slider.d.ts +21 -0
  258. package/dist/ui/src/components/Table.d.ts +34 -0
  259. package/dist/ui/src/components/Tabs.d.ts +19 -0
  260. package/dist/ui/src/components/TextField.d.ts +58 -0
  261. package/dist/ui/src/components/TextareaAutosize.d.ts +43 -0
  262. package/dist/ui/src/components/ToggleButtonGroup.d.ts +30 -0
  263. package/dist/ui/src/components/Tooltip.d.ts +19 -0
  264. package/dist/ui/src/components/Typography.d.ts +36 -0
  265. package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +11 -0
  266. package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +21 -0
  267. package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
  268. package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
  269. package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +243 -0
  270. package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +3 -0
  271. package/dist/ui/src/components/VirtualTable/index.d.ts +3 -0
  272. package/dist/ui/src/components/VirtualTable/types.d.ts +38 -0
  273. package/dist/ui/src/components/common/SelectInputLabel.d.ts +5 -0
  274. package/dist/ui/src/components/index.d.ts +53 -0
  275. package/dist/ui/src/hooks/PortalContainerContext.d.ts +31 -0
  276. package/dist/ui/src/hooks/index.d.ts +6 -0
  277. package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -0
  278. package/dist/ui/src/hooks/useDebounceValue.d.ts +1 -0
  279. package/dist/ui/src/hooks/useDebouncedCallback.d.ts +1 -0
  280. package/dist/ui/src/hooks/useInjectStyles.d.ts +7 -0
  281. package/dist/ui/src/hooks/useOutsideAlerter.d.ts +5 -0
  282. package/dist/ui/src/icons/GitHubIcon.d.ts +2 -0
  283. package/dist/ui/src/icons/HandleIcon.d.ts +1 -0
  284. package/dist/ui/src/icons/Icon.d.ts +20 -0
  285. package/dist/ui/src/icons/cool_icon_keys.d.ts +1 -0
  286. package/dist/ui/src/icons/icon_keys.d.ts +1 -0
  287. package/dist/ui/src/icons/index.d.ts +6 -0
  288. package/dist/ui/src/index.d.ts +5 -0
  289. package/dist/ui/src/styles.d.ts +12 -0
  290. package/dist/ui/src/util/chip_colors.d.ts +4 -0
  291. package/dist/ui/src/util/cls.d.ts +2 -0
  292. package/dist/ui/src/util/debounce.d.ts +10 -0
  293. package/dist/ui/src/util/hash.d.ts +1 -0
  294. package/dist/ui/src/util/index.d.ts +4 -0
  295. package/dist/ui/src/util/key_to_icon_component.d.ts +1 -0
  296. package/package.json +86 -0
  297. package/src/api.ts +198 -0
  298. package/src/components/DataEnhancementControllerProvider.tsx +339 -0
  299. package/src/components/FormEnhanceAction.tsx +273 -0
  300. package/src/editor/useEditorAIController.tsx +37 -0
  301. package/src/index.ts +10 -0
  302. package/src/locales/de.ts +21 -0
  303. package/src/locales/en.ts +21 -0
  304. package/src/locales/es.ts +21 -0
  305. package/src/locales/fr.ts +21 -0
  306. package/src/locales/hi.ts +21 -0
  307. package/src/locales/it.ts +21 -0
  308. package/src/locales/pt.ts +21 -0
  309. package/src/tests/diffStrings.test.ts +128 -0
  310. package/src/types/data_enhancement_controller.tsx +75 -0
  311. package/src/types/subscriptions_message_props.tsx +1 -0
  312. package/src/useDataEnhancementPlugin.tsx +66 -0
  313. package/src/utils/diffStrings.ts +70 -0
  314. package/src/utils/properties.ts +168 -0
  315. package/src/utils/strings_counter.ts +22 -0
  316. package/src/utils/suggestions.ts +6 -0
  317. package/src/utils/values.ts +12 -0
  318. package/src/vite-env.d.ts +1 -0
@@ -0,0 +1,1148 @@
1
+ import React from "react";
2
+ import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
3
+ import type { Relation, JoinStep, OnAction } from "./relations";
4
+ import type { EntityCollection, FilterValues } from "./collections";
5
+ import type { ColorKey, ColorScheme } from "./chips";
6
+ import type { AuthController } from "../controllers/auth";
7
+ import type { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
8
+ import type { User } from "../users";
9
+ /**
10
+ * Callbacks/Hooks for individual property fields
11
+ * @group Entity properties
12
+ */
13
+ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
14
+ /**
15
+ * Callback used after fetching data, to transform the value before rendering
16
+ */
17
+ afterRead?(props: Omit<EntityAfterReadProps<M, USER>, "entity"> & {
18
+ value: T;
19
+ entity: Entity<M> | undefined;
20
+ }): Promise<T> | T;
21
+ /**
22
+ * Callback used before saving, after validation.
23
+ * You can modify the value before it's saved.
24
+ */
25
+ beforeSave?(props: Omit<EntityBeforeSaveProps<M, USER>, "values"> & {
26
+ value: T;
27
+ previousValue: T | undefined;
28
+ values: Partial<M>;
29
+ }): Promise<T> | T;
30
+ };
31
+ /**
32
+ * @group Entity properties
33
+ */
34
+ export type DataType = "string" | "number" | "boolean" | "date" | "geopoint" | "reference" | "relation" | "array" | "map";
35
+ export type Property = StringProperty | NumberProperty | BooleanProperty | DateProperty | GeopointProperty | ReferenceProperty | RelationProperty | ArrayProperty | MapProperty;
36
+ export type Properties = {
37
+ [key: string]: Property;
38
+ };
39
+ export type PostgresProperty = Exclude<Property, ReferenceProperty>;
40
+ export type PostgresProperties = {
41
+ [key: string]: PostgresProperty;
42
+ };
43
+ export type FirebaseProperty = Exclude<Property, RelationProperty>;
44
+ export type FirebaseProperties = {
45
+ [key: string]: FirebaseProperty;
46
+ };
47
+ /**
48
+ * A helper type to infer the underlying data type from a Property definition.
49
+ * This is the core of the type inference system.
50
+ */
51
+ export type InferPropertyType<P extends Property> = P extends StringProperty ? string : P extends NumberProperty ? number : P extends BooleanProperty ? boolean : P extends DateProperty ? Date : P extends GeopointProperty ? GeoPoint : P extends ReferenceProperty ? EntityReference : P extends RelationProperty ? EntityRelation | EntityRelation[] : P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : unknown[]) : P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, unknown>) : never;
52
+ /**
53
+ * Helper type that determines whether a property is required.
54
+ * Uses direct structural matching against `{ validation: { required: true } }`
55
+ * (without the optional marker on `validation`), which correctly narrows
56
+ * literal `true` while treating widened `boolean` as not-required.
57
+ */
58
+ type IsRequired<P extends Property> = P extends {
59
+ validation: {
60
+ required: true;
61
+ };
62
+ } ? true : false;
63
+ /**
64
+ * Extract keys from Properties where the property is required.
65
+ */
66
+ type RequiredPropertyKeys<P extends Properties> = {
67
+ [K in keyof P]: IsRequired<P[K]> extends true ? K : never;
68
+ }[keyof P];
69
+ /**
70
+ * Extract keys from Properties where the property is optional.
71
+ */
72
+ type OptionalPropertyKeys<P extends Properties> = {
73
+ [K in keyof P]: IsRequired<P[K]> extends true ? never : K;
74
+ }[keyof P];
75
+ /**
76
+ * A generic type that converts a `Properties` schema definition into a corresponding
77
+ * TypeScript entity type. It correctly handles required and optional properties.
78
+ *
79
+ * A property is considered required when it has `validation: { required: true }`.
80
+ * The `true` must be a literal type — if `required` is typed as `boolean`,
81
+ * the property will be treated as optional (use `as const` for literal inference).
82
+ *
83
+ * @example
84
+ * const productSchema = {
85
+ * name: { type: 'string', validation: { required: true } },
86
+ * price: { type: 'number' }
87
+ * } as const satisfies Properties;
88
+ * type Product = InferEntityType<typeof productSchema>;
89
+ * // Result: { name: string; price?: number; }
90
+ */
91
+ export type InferEntityType<P extends Properties> = {
92
+ -readonly [K in RequiredPropertyKeys<P>]: InferPropertyType<P[K]>;
93
+ } & {
94
+ -readonly [K in OptionalPropertyKeys<P>]?: InferPropertyType<P[K]>;
95
+ };
96
+ /**
97
+ * Interface including all common properties of a CMS property.
98
+ * @group Entity properties
99
+ */
100
+ export interface BaseUIConfig<CustomProps = unknown> {
101
+ columnWidth?: number;
102
+ hideFromCollection?: boolean;
103
+ readOnly?: boolean;
104
+ disabled?: boolean | PropertyDisabledConfig;
105
+ widthPercentage?: number;
106
+ customProps?: CustomProps;
107
+ Field?: React.ComponentType<any>;
108
+ Preview?: React.ComponentType<any>;
109
+ }
110
+ export interface BaseProperty<CustomProps = unknown> {
111
+ ui?: BaseUIConfig<CustomProps>;
112
+ /**
113
+ * Property name (e.g. Product)
114
+ */
115
+ name: string;
116
+ /**
117
+ * Property description, always displayed under the field
118
+ */
119
+ description?: string;
120
+ /**
121
+ * You can use this prop to reuse a property that has been defined
122
+ * in the top level of the CMS in the prop `fields`.
123
+ * All the configuration will be taken from the inherited config, and
124
+ * overwritten by the current property config.
125
+ */
126
+ propertyConfig?: string;
127
+ /**
128
+ * Rules for validating this property
129
+ */
130
+ validation?: PropertyValidationSchema;
131
+ /**
132
+ * This value will be set by default for new entities.
133
+ */
134
+ defaultValue?: unknown;
135
+ /**
136
+ * Use this to define dynamic properties that change based on certain conditions
137
+ * or on the entity's values. For example, you can make a field read-only if
138
+ * another field has a certain value.
139
+ * This function receives the same props as a `PropertyBuilder` and should return a partial `Property` object.
140
+ */
141
+ dynamicProps?: (props: PropertyBuilderProps) => Partial<Property>;
142
+ /**
143
+ * Declarative conditions for dynamic property behavior using JSON Logic.
144
+ *
145
+ * An alternative to PropertyBuilder functions that can be:
146
+ * - Stored in the database as JSON
147
+ * - Edited via the collection editor UI
148
+ * - Evaluated at runtime like property builders
149
+ *
150
+ * @see PropertyConditions for available condition options
151
+ * @see https://jsonlogic.com/ for JSON Logic syntax
152
+ */
153
+ conditions?: PropertyConditions;
154
+ /**
155
+ * Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
156
+ */
157
+ callbacks?: PropertyCallbacks;
158
+ }
159
+ /**
160
+ * @group Entity properties
161
+ */
162
+ export interface StringUIConfig extends BaseUIConfig {
163
+ multiline?: boolean;
164
+ markdown?: boolean;
165
+ previewAsTag?: boolean;
166
+ clearable?: boolean;
167
+ url?: boolean | PreviewType;
168
+ }
169
+ export interface StringProperty extends BaseProperty {
170
+ ui?: StringUIConfig;
171
+ type: "string";
172
+ /**
173
+ * Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
174
+ * Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
175
+ */
176
+ columnType?: "varchar" | "text" | "char";
177
+ /**
178
+ * Rules for validating this property
179
+ */
180
+ validation?: StringPropertyValidationSchema;
181
+ /**
182
+ * Marks this field as a Primary Key / Unique Identifier.
183
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
184
+ * Drizzle append: `.primaryKey()`
185
+ * UI behavior: Field value cannot be changed after creation.
186
+ *
187
+ * You can set this to `"manual"` for a user-defined ID, or specify a generation strategy:
188
+ * 'uuid' -> Drizzle `.defaultRandom()` (Postgres gen_random_uuid())
189
+ * 'cuid' -> Drizzle `.default(sql\`cuid()\`)`
190
+ * Or any other random string to act as a raw SQL default expression: e.g. `nanoid()`
191
+ *
192
+ * On the UI side, the field automatically gets disabled on new entities if a string strategy is provided.
193
+ */
194
+ isId?: boolean | "manual" | "uuid" | "cuid" | string;
195
+ /**
196
+ * You can use the enum values providing a map of possible
197
+ * exclusive values the property can take, mapped to the label that it is
198
+ * displayed in the dropdown. You can use a simple object with the format
199
+ * `value` => `label`, or with the format `value` => `EnumValueConfig` if you
200
+ * need extra customization, (like disabling specific options or assigning
201
+ * colors). If you need to ensure the order of the elements, you can pass
202
+ * a `Map` instead of a plain object.
203
+ *
204
+ */
205
+ enum?: EnumValues;
206
+ /**
207
+ * Is this string property long enough so it should be displayed in
208
+ * a multiple line field. Defaults to false. If set to true,
209
+ * the number of lines adapts to the content
210
+ */
211
+ multiline?: boolean;
212
+ /**
213
+ * Should this string property be displayed as a markdown field. If true,
214
+ * the field is rendered as a text editors that supports markdown highlight
215
+ * syntax. It also includes a preview of the result.
216
+ */
217
+ markdown?: boolean;
218
+ /**
219
+ * You can specify a `Storage` configuration. It is used to
220
+ * indicate that this string refers to a path in your storage provider.
221
+ */
222
+ storage?: StorageConfig;
223
+ /**
224
+ * This property is used to indicate that the string is a user ID, and
225
+ * it will be rendered as a user picker.
226
+ * Note that the user ID needs to be the one used in your authentication
227
+ * provider, e.g. Firebase Auth.
228
+ * You can also use a property builder to specify the user path dynamically
229
+ * based on other values of the entity.
230
+ */
231
+ userSelect?: boolean;
232
+ /**
233
+ * If the value of this property is a URL, you can set this flag to true
234
+ * to add a link, or one of the supported media types to render a preview
235
+ */
236
+ url?: boolean | PreviewType;
237
+ /**
238
+ * Does this field include an email
239
+ */
240
+ email?: boolean;
241
+ /**
242
+ * Should this string be rendered as a tag instead of just text.
243
+ */
244
+ previewAsTag?: boolean;
245
+ /**
246
+ * You can use this property (a string) to behave as a reference to another
247
+ * collection. The stored value is the ID of the entity in the
248
+ * collection, and the `path` prop is used to
249
+ * define the collection this reference points to.
250
+ */
251
+ reference?: ReferenceProperty;
252
+ }
253
+ /**
254
+ * @group Entity properties
255
+ */
256
+ export interface NumberUIConfig extends BaseUIConfig {
257
+ clearable?: boolean;
258
+ }
259
+ export interface NumberProperty extends BaseProperty {
260
+ ui?: NumberUIConfig;
261
+ type: "number";
262
+ /**
263
+ * Optional database column type. Allows specifying exact database numeric types.
264
+ * If not provided, integer fields (where validation.integer is true or isId is true) default to `integer`, others to `numeric`.
265
+ */
266
+ columnType?: "integer" | "real" | "double precision" | "numeric" | "bigint" | "serial" | "bigserial";
267
+ /**
268
+ * Rules for validating this property
269
+ */
270
+ validation?: NumberPropertyValidationSchema;
271
+ /**
272
+ * Marks this field as a Primary Key / Unique Identifier.
273
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
274
+ * Drizzle append: `.primaryKey()`
275
+ * UI behavior: Field value cannot be changed after creation.
276
+ *
277
+ * You can set this to `"manual"` for a user-defined ID, or specify a generation strategy:
278
+ * 'increment' -> PostgreSQL `GENERATED BY DEFAULT AS IDENTITY` or auto-incrementing integer.
279
+ * Or any other random string to act as a raw SQL default expression.
280
+ */
281
+ isId?: boolean | "manual" | "increment" | string;
282
+ /**
283
+ * You can use the enum values providing a map of possible
284
+ * exclusive values the property can take, mapped to the label that it is
285
+ * displayed in the dropdown.
286
+ */
287
+ enum?: EnumValues;
288
+ }
289
+ /**
290
+ * @group Entity properties
291
+ */
292
+ export interface BooleanProperty extends BaseProperty {
293
+ ui?: BaseUIConfig;
294
+ type: "boolean";
295
+ /**
296
+ * Rules for validating this property
297
+ */
298
+ validation?: PropertyValidationSchema;
299
+ }
300
+ /**
301
+ * @group Entity properties
302
+ */
303
+ export interface DateUIConfig extends BaseUIConfig {
304
+ clearable?: boolean;
305
+ }
306
+ export interface DateProperty extends BaseProperty {
307
+ ui?: DateUIConfig;
308
+ type: "date";
309
+ /**
310
+ * Optional database column type. If not set, defaults to `timestamp` with timezone.
311
+ */
312
+ columnType?: "timestamp" | "date" | "time";
313
+ /**
314
+ * Rules for validating this property
315
+ */
316
+ validation?: DatePropertyValidationSchema;
317
+ /**
318
+ * Set the granularity of the field to a date or date + time.
319
+ * Defaults to `date_time`.
320
+ *
321
+ */
322
+ mode?: "date" | "date_time";
323
+ /**
324
+ * Timezone string to evaluate the date in.
325
+ */
326
+ timezone?: string;
327
+ /**
328
+ * If this flag is set to `on_create` or `on_update` this timestamp is
329
+ * updated automatically on creation of the entity only or on every
330
+ * update (including creation). Useful for creating `created_on` or
331
+ * `updated_on` fields
332
+ */
333
+ autoValue?: "on_create" | "on_update";
334
+ /**
335
+ * Add an icon to clear the value and set it to `null`. Defaults to `false`
336
+ */
337
+ clearable?: boolean;
338
+ }
339
+ /**
340
+ * @group Entity properties
341
+ */
342
+ export interface GeopointProperty extends BaseProperty {
343
+ ui?: BaseUIConfig;
344
+ type: "geopoint";
345
+ /**
346
+ * Rules for validating this property
347
+ */
348
+ validation?: PropertyValidationSchema;
349
+ }
350
+ /**
351
+ * @group Entity properties
352
+ */
353
+ export interface ReferenceUIConfig extends BaseUIConfig {
354
+ previewProperties?: string[];
355
+ }
356
+ export interface ReferenceProperty extends BaseProperty {
357
+ ui?: ReferenceUIConfig;
358
+ type: "reference";
359
+ /**
360
+ * Marks this field as a Primary Key / Unique Identifier.
361
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
362
+ * Drizzle append: `.primaryKey()`
363
+ * UI behavior: Field value cannot be changed after creation.
364
+ */
365
+ isId?: boolean;
366
+ /**
367
+ * Absolute collection path of the collection this reference points to.
368
+ * The collection of the entity is inferred based on the root navigation, so
369
+ * the filters and search delegate existing there are applied to this view
370
+ * as well.
371
+ * You can leave this prop undefined if the path is not yet know, e.g.
372
+ * you are using a property builder and the path depends on a different
373
+ * property.
374
+ */
375
+ path?: string;
376
+ /**
377
+ * Allow selection of entities that pass the given filter only.
378
+ * e.g. `fixedFilter: { age: [">=", 18] }`
379
+ */
380
+ fixedFilter?: FilterValues<string>;
381
+ /**
382
+ * Should the reference include the ID of the entity. Defaults to `true`
383
+ */
384
+ includeId?: boolean;
385
+ /**
386
+ * Should the reference include a link to the entity (open the entity details). Defaults to `true`
387
+ */
388
+ includeEntityLink?: boolean;
389
+ }
390
+ /**
391
+ * @group Entity properties
392
+ */
393
+ export interface RelationUIConfig extends BaseUIConfig {
394
+ previewProperties?: string[];
395
+ widget?: "select" | "dialog";
396
+ }
397
+ export interface RelationProperty extends BaseProperty {
398
+ ui?: RelationUIConfig;
399
+ type: "relation";
400
+ /**
401
+ * Marks this field as a Primary Key / Unique Identifier.
402
+ * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
403
+ * Drizzle append: `.primaryKey()`
404
+ * UI behavior: Field value cannot be changed after creation.
405
+ */
406
+ isId?: boolean;
407
+ /**
408
+ * The target collection this relation points to.
409
+ * When set, the framework treats this property as a self-contained relation
410
+ * definition and no separate `relations[]` entry is needed.
411
+ */
412
+ target?: () => EntityCollection;
413
+ /**
414
+ * Whether this property references one or many records.
415
+ * Defaults to `"one"`.
416
+ */
417
+ cardinality?: "one" | "many";
418
+ /**
419
+ * Which side owns the persistence for this relationship.
420
+ * - `"owning"`: The foreign key (for one-to-one) or junction table (for many-to-many) is on this collection.
421
+ * - `"inverse"`: The foreign key is on the target collection's table.
422
+ * Defaults to `"owning"`.
423
+ */
424
+ direction?: "owning" | "inverse";
425
+ /**
426
+ * The name of the corresponding relation on the target collection.
427
+ * Used for inverse relations to locate the owning side.
428
+ */
429
+ inverseRelationName?: string;
430
+ /**
431
+ * Column on THIS table that stores the foreign key to the target.
432
+ * Required when `direction` is `"owning"` and `cardinality` is `"one"`.
433
+ * Auto-inferred if not set.
434
+ * @example "author_id"
435
+ */
436
+ localKey?: string;
437
+ /**
438
+ * Column on the TARGET table that stores the foreign key back to this entity.
439
+ * Required when `direction` is `"inverse"`.
440
+ * Auto-inferred if not set.
441
+ * @example "post_id"
442
+ */
443
+ foreignKeyOnTarget?: string;
444
+ /**
445
+ * Junction table configuration for many-to-many relationships.
446
+ * Required when `cardinality` is `"many"` and `direction` is `"owning"`.
447
+ * Auto-inferred if not set.
448
+ */
449
+ through?: {
450
+ table: string;
451
+ sourceColumn: string;
452
+ targetColumn: string;
453
+ };
454
+ /**
455
+ * Explicit, ordered join path for advanced multi-hop relations.
456
+ * When set, overrides `localKey`, `foreignKeyOnTarget`, and `through`.
457
+ */
458
+ joinPath?: JoinStep[];
459
+ /**
460
+ * Cascade action on update.
461
+ */
462
+ onUpdate?: OnAction;
463
+ /**
464
+ * Cascade action on delete.
465
+ */
466
+ onDelete?: OnAction;
467
+ /**
468
+ * Overrides applied to the target collection when rendered as a subcollection tab.
469
+ */
470
+ overrides?: Partial<EntityCollection>;
471
+ /**
472
+ * Optional name for this relation. Defaults to the property key at runtime.
473
+ * Only needed when the relation name should differ from the property key,
474
+ * or for backward compatibility with existing `relations[]` entries.
475
+ */
476
+ relationName?: string;
477
+ /**
478
+ * The resolved relation object, populated by the framework at normalization time.
479
+ * **Do not set manually** — it is computed from the inline fields above
480
+ * or looked up from the collection's `relations[]` array.
481
+ */
482
+ relation?: Relation;
483
+ /**
484
+ * Allow selection of entities that pass the given filter only.
485
+ * e.g. `fixedFilter: { age: [">=", 18] }`
486
+ */
487
+ fixedFilter?: FilterValues<string>;
488
+ /**
489
+ * Should the reference include the ID of the entity. Defaults to `true`
490
+ */
491
+ includeId?: boolean;
492
+ /**
493
+ * Should the reference include a link to the entity (open the entity details). Defaults to `true`
494
+ */
495
+ includeEntityLink?: boolean;
496
+ /**
497
+ * Choose the widget to use for selecting the relation.
498
+ * Defaults to `select`.
499
+ */
500
+ widget?: "select" | "dialog";
501
+ }
502
+ /**
503
+ * @group Entity properties
504
+ */
505
+ export interface ArrayUIConfig extends BaseUIConfig {
506
+ expanded?: boolean;
507
+ minimalistView?: boolean;
508
+ }
509
+ export interface ArrayProperty extends BaseProperty {
510
+ ui?: ArrayUIConfig;
511
+ type: "array";
512
+ /**
513
+ * Optional database column type. Defaults to `jsonb`.
514
+ */
515
+ columnType?: "json" | "jsonb";
516
+ /**
517
+ * The property of this array.
518
+ * You can specify any property (except another Array property)
519
+ * You can leave this field empty only if you are providing a custom field,
520
+ * or using the `oneOf` prop, otherwise an error will be thrown.
521
+ */
522
+ of?: Property | Property[];
523
+ /**
524
+ * Use this field if you would like to have an array of typed objects.
525
+ * It is useful if you need to have values of different types in the same
526
+ * array.
527
+ * Each entry of the array is an object with the shape:
528
+ * ```
529
+ * { type: "YOUR_TYPE", value: "YOUR_VALUE"}
530
+ * ```
531
+ * Note that you can use any property so `value` can take any value (strings,
532
+ * numbers, array, objects...)
533
+ * You can customise the `type` and `value` fields to suit your needs.
534
+ *
535
+ * An example use case for this feature may be a blog entry, where you have
536
+ * images and text blocks using markdown.
537
+ */
538
+ oneOf?: {
539
+ /**
540
+ * Record of properties, where the key is the `type` and the value
541
+ * is the corresponding property
542
+ */
543
+ properties: Properties;
544
+ /**
545
+ * Order in which the properties are displayed.
546
+ * If you are specifying your collection as code, the order is the same as the
547
+ * one you define in `properties`, and you don't need to specify this prop.
548
+ */
549
+ propertiesOrder?: string[];
550
+ /**
551
+ * Name of the field to use as the discriminator for type
552
+ * Defaults to `type`
553
+ */
554
+ typeField?: string;
555
+ /**
556
+ * Name of the field to use as the value
557
+ * Defaults to `value`
558
+ */
559
+ valueField?: string;
560
+ };
561
+ /**
562
+ * Rules for validating this property
563
+ */
564
+ validation?: ArrayPropertyValidationSchema;
565
+ /**
566
+ * Can the elements in this array be reordered. Defaults to `true`.
567
+ * This prop has no effect if `disabled` is set to true.
568
+ */
569
+ sortable?: boolean;
570
+ /**
571
+ * Can the elements in this array be added. Defaults to `true`
572
+ * This prop has no effect if `disabled` is set to true.
573
+ */
574
+ canAddElements?: boolean;
575
+ }
576
+ /**
577
+ * @group Entity properties
578
+ */
579
+ export interface MapUIConfig extends BaseUIConfig {
580
+ expanded?: boolean;
581
+ minimalistView?: boolean;
582
+ spreadChildren?: boolean;
583
+ }
584
+ export interface MapProperty extends BaseProperty {
585
+ ui?: MapUIConfig;
586
+ type: "map";
587
+ /**
588
+ * Optional database column type. Defaults to `jsonb`.
589
+ */
590
+ columnType?: "json" | "jsonb";
591
+ /**
592
+ * Record of properties included in this map.
593
+ */
594
+ properties?: Properties;
595
+ /**
596
+ * Order in which the properties are displayed.
597
+ * If you are specifying your collection as code, the order is the same as the
598
+ * one you define in `properties`, and you don't need to specify this prop.
599
+ */
600
+ propertiesOrder?: string[];
601
+ /**
602
+ * Rules for validating this property.
603
+ * NOTE: If you don't set `required` in the map property, an empty object
604
+ * will be considered valid, even if you set `required` in the properties.
605
+ */
606
+ validation?: PropertyValidationSchema;
607
+ /**
608
+ * Properties that are displayed when rendered as a preview
609
+ */
610
+ previewProperties?: string[];
611
+ /**
612
+ * Allow the user to add only some keys in this map.
613
+ * By default, all properties of the map have the corresponding field in
614
+ * the form view. Setting this flag to true allows to pick only some.
615
+ * Useful for map that can have a lot of sub-properties that may not be
616
+ * needed
617
+ */
618
+ pickOnlySomeKeys?: boolean;
619
+ /**
620
+ * Render this map as a key-value table that allows to use
621
+ * arbitrary keys. You don't need to define the properties in this case.
622
+ */
623
+ keyValue?: boolean;
624
+ }
625
+ /**
626
+ * @group Entity properties
627
+ */
628
+ export type PropertyBuilderProps<M extends Record<string, unknown> = Record<string, unknown>> = {
629
+ values: Partial<M>;
630
+ previousValues?: Partial<M>;
631
+ propertyValue?: unknown;
632
+ index?: number;
633
+ path: string;
634
+ entityId?: string | number;
635
+ authController: AuthController;
636
+ };
637
+ /**
638
+ * @group Entity properties
639
+ */
640
+ export interface PropertyDisabledConfig {
641
+ /**
642
+ * Enable this flag if you would like to clear the value of the field
643
+ * when the corresponding property gets disabled.
644
+ *
645
+ * This is useful for keeping data consistency when you have conditional
646
+ * properties.
647
+ */
648
+ clearOnDisabled?: boolean;
649
+ /**
650
+ * Explanation of why this property is disabled (e.g. a different field
651
+ * needs to be enabled)
652
+ */
653
+ disabledMessage?: string;
654
+ /**
655
+ * Set this flag to true if you want to hide this field when disabled
656
+ */
657
+ hidden?: boolean;
658
+ }
659
+ /**
660
+ * We use this type to define mapping between string or number values in
661
+ * the data source to a label (such in a select dropdown).
662
+ * The key in this Record is the value saved in the driver, and the value in
663
+ * this record is the label displayed in the UI.
664
+ * You can add additional customization by assigning a {@link EnumValueConfig} for the
665
+ * label instead of a simple string (for enabling or disabling options and
666
+ * choosing colors).
667
+ * If you need to ensure the order of the elements use an array of {@link EnumValueConfig}
668
+ * @group Entity properties
669
+ */
670
+ export type EnumValues = EnumValueConfig[] | Record<string | number, string | EnumValueConfig>;
671
+ /**
672
+ * Configuration for a particular entry in an `EnumValues`
673
+ * @group Entity properties
674
+ */
675
+ export type EnumValueConfig = {
676
+ /**
677
+ * Value stored in the data source.
678
+ */
679
+ id: string | number;
680
+ /**
681
+ * Displayed label
682
+ */
683
+ label: string;
684
+ /**
685
+ * This value will not be selectable
686
+ */
687
+ disabled?: boolean;
688
+ /**
689
+ * You can pick from a list of predefined color combinations or define
690
+ * your own {@link ColorScheme}
691
+ */
692
+ color?: ColorKey | ColorScheme;
693
+ };
694
+ /**
695
+ * Rules to validate any property. Some properties have specific rules
696
+ * additionally to these.
697
+ * @group Entity properties
698
+ */
699
+ export interface PropertyValidationSchema {
700
+ /**
701
+ * Is this field required
702
+ */
703
+ required?: boolean;
704
+ /**
705
+ * Customize the required message when the property is not set
706
+ */
707
+ requiredMessage?: string;
708
+ /**
709
+ * If the unique flag is set to `true`, you can only have one entity in the
710
+ * collection with this value.
711
+ */
712
+ unique?: boolean;
713
+ /**
714
+ * If the uniqueInArray flag is set to `true`, you can only have this value
715
+ * once per entry in the parent `ArrayProperty`. It has no effect if this
716
+ * property is not a child of an `ArrayProperty`. It works on direct
717
+ * children of an `ArrayProperty` or first level children of `MapProperty`
718
+ */
719
+ uniqueInArray?: boolean;
720
+ }
721
+ /**
722
+ * Validation rules for numbers
723
+ * @group Entity properties
724
+ */
725
+ export interface NumberPropertyValidationSchema extends PropertyValidationSchema {
726
+ min?: number;
727
+ max?: number;
728
+ lessThan?: number;
729
+ moreThan?: number;
730
+ positive?: boolean;
731
+ negative?: boolean;
732
+ integer?: boolean;
733
+ }
734
+ /**
735
+ * Validation rules for strings
736
+ * @group Entity properties
737
+ */
738
+ export interface StringPropertyValidationSchema extends PropertyValidationSchema {
739
+ length?: number;
740
+ min?: number;
741
+ max?: number;
742
+ matches?: string | RegExp;
743
+ /**
744
+ * Message displayed when the input does not satisfy the regex in `matches`
745
+ */
746
+ matchesMessage?: string;
747
+ trim?: boolean;
748
+ lowercase?: boolean;
749
+ uppercase?: boolean;
750
+ }
751
+ /**
752
+ * Validation rules for dates
753
+ * @group Entity properties
754
+ */
755
+ export interface DatePropertyValidationSchema extends PropertyValidationSchema {
756
+ min?: Date;
757
+ max?: Date;
758
+ }
759
+ /**
760
+ * Validation rules for arrays
761
+ * @group Entity properties
762
+ */
763
+ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema {
764
+ min?: number;
765
+ max?: number;
766
+ }
767
+ /**
768
+ * Additional configuration related to Storage related fields
769
+ * @group Entity properties
770
+ */
771
+ export type StorageConfig = {
772
+ /**
773
+ * File MIME types that can be uploaded to this reference. Don't specify for
774
+ * all.
775
+ * Note that you can also use the asterisk notation, so `image/*`
776
+ * accepts any image file, and so on.
777
+ */
778
+ acceptedFiles?: FileType[];
779
+ /**
780
+ * Advanced image resizing and cropping configuration.
781
+ * Applied before upload to optimize storage and bandwidth.
782
+ * Only applies to image MIME types: image/jpeg, image/png, image/webp
783
+ */
784
+ imageResize?: ImageResize;
785
+ /**
786
+ * Specific metadata set in your uploaded file.
787
+ * For the default Firebase implementation, the values passed here are of type
788
+ * `firebase.storage.UploadMetadata`
789
+ */
790
+ metadata?: Record<string, unknown>;
791
+ /**
792
+ * You can use this prop to customize the uploaded filename.
793
+ * You can use a function as a callback or a string where you
794
+ * specify some placeholders that get replaced with the corresponding values.
795
+ * - `{file}` - Full file name
796
+ * - `{file.name}` - Name of the file without extension
797
+ * - `{file.ext}` - Extension of the file
798
+ * - `{rand}` - Random value used to avoid name collisions
799
+ * - `{entityId}` - ID of the entity
800
+ * - `{propertyKey}` - ID of this property
801
+ * - `{path}` - Path of this entity
802
+ *
803
+ * @param context
804
+ */
805
+ fileName?: string | ((context: UploadedFileContext) => string | Promise<string>);
806
+ /**
807
+ * Absolute path in your bucket.
808
+ *
809
+ * You can use a function as a callback or a string where you
810
+ * specify some placeholders that get replaced with the corresponding values.
811
+ * - `{file}` - Full file name
812
+ * - `{file.name}` - Name of the file without extension
813
+ * - `{file.ext}` - Extension of the file
814
+ * - `{rand}` - Random value used to avoid name collisions
815
+ * - `{entityId}` - ID of the entity
816
+ * - `{propertyKey}` - ID of this property
817
+ * - `{path}` - Path of this entity
818
+ */
819
+ storagePath: string | ((context: UploadedFileContext) => string);
820
+ /**
821
+ * When set to true, this flag indicates that the bucket name will be
822
+ * included in the saved storage path.
823
+ *
824
+ * E.g. `s3://my-bucket/path/to/file.png` instead of just `path/to/file.png`
825
+ *
826
+ * Defaults to false.
827
+ */
828
+ includeBucketUrl?: boolean;
829
+ /**
830
+ * When set to true, this flag indicates that the download URL of the file
831
+ * will be saved in the driver, instead of the storage path.
832
+ *
833
+ * Note that the generated URL may use a token that, if disabled, may
834
+ * make the URL unusable and lose the original reference to Cloud Storage,
835
+ * so it is not encouraged to use this flag.
836
+ *
837
+ * Defaults to false.
838
+ */
839
+ storeUrl?: boolean;
840
+ /**
841
+ * Define maximal file size in bytes
842
+ */
843
+ maxSize?: number;
844
+ /**
845
+ * Use this callback to process the file before uploading it to the storage.
846
+ * If nothing is returned, the file is uploaded as it is.
847
+ * @param file
848
+ */
849
+ processFile?: (file: File) => Promise<File> | undefined;
850
+ /**
851
+ * Postprocess the saved value (storage path or URL)
852
+ * after it has been resolved.
853
+ */
854
+ postProcess?: (pathOrUrl: string) => Promise<string>;
855
+ /**
856
+ * You can use this prop in order to provide a custom preview URL.
857
+ * Useful when the file's path is different from the original field value
858
+ */
859
+ previewUrl?: (fileName: string) => string;
860
+ };
861
+ /**
862
+ * @group Entity properties
863
+ */
864
+ export interface UploadedFileContext {
865
+ /**
866
+ * Uploaded file
867
+ */
868
+ file: File;
869
+ /**
870
+ * Property field name
871
+ */
872
+ propertyKey: string;
873
+ /**
874
+ * Property related to this upload
875
+ */
876
+ property: StringProperty | ArrayProperty;
877
+ /**
878
+ * Entity ID
879
+ */
880
+ entityId?: string | number;
881
+ /**
882
+ * Entity path. E.g. `products/PID/locales`
883
+ */
884
+ path?: string;
885
+ /**
886
+ * Values of the current entity
887
+ */
888
+ values: EntityValues<any>;
889
+ /**
890
+ * Storage meta specified by the developer
891
+ */
892
+ storage: StorageConfig;
893
+ }
894
+ /**
895
+ * Used for previewing urls if the download file is known
896
+ * @group Entity properties
897
+ */
898
+ export type PreviewType = "image" | "video" | "audio" | "file";
899
+ /**
900
+ * MIME types for storage fields
901
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
902
+ * @group Entity properties
903
+ */
904
+ export type FileType = "image/*" | "video/*" | "audio/*" | "application/*" | "text/*" | "font/*" | string;
905
+ export interface ImageResize {
906
+ /**
907
+ * Maximum width in pixels. Image will be scaled down proportionally if wider.
908
+ */
909
+ maxWidth?: number;
910
+ /**
911
+ * Maximum height in pixels. Image will be scaled down proportionally if taller.
912
+ */
913
+ maxHeight?: number;
914
+ /**
915
+ * Resize mode determines how the image fits within maxWidth/maxHeight bounds.
916
+ * - `contain`: Scale down to fit within bounds, preserving aspect ratio (default)
917
+ * - `cover`: Scale to fill bounds, preserving aspect ratio (may crop)
918
+ */
919
+ mode?: "contain" | "cover";
920
+ /**
921
+ * Output format for the resized image.
922
+ * - `original`: Keep the original format (default)
923
+ * - `jpeg`: Convert to JPEG
924
+ * - `png`: Convert to PNG
925
+ * - `webp`: Convert to WebP
926
+ */
927
+ format?: "original" | "jpeg" | "png" | "webp";
928
+ /**
929
+ * Quality for lossy formats (JPEG, WebP). Number between 0 and 100.
930
+ * Higher is better quality but larger file size. Defaults to 80.
931
+ */
932
+ quality?: number;
933
+ }
934
+ /**
935
+ * A JSON Logic rule that gets evaluated at runtime.
936
+ * @see https://jsonlogic.com/
937
+ *
938
+ * Common operators:
939
+ * - Comparison: ==, !=, ===, !==, >, <, >=, <=
940
+ * - Logic: and, or, !, !!
941
+ * - Data access: var, missing, missing_some
942
+ * - Array: in, map, filter, reduce, all, some, none, merge
943
+ * - String: substr, cat
944
+ * - Numeric: +, -, *, /, %, min, max
945
+ *
946
+ * Custom operators:
947
+ * - hasRole(roleId) - check if user has role by ID
948
+ * - hasAnyRole([roleIds]) - check if user has any of the roles
949
+ * - isToday(timestamp) - check if timestamp is today
950
+ * - isPast(timestamp) - check if timestamp is in the past
951
+ * - isFuture(timestamp) - check if timestamp is in the future
952
+ *
953
+ * @group Entity properties
954
+ */
955
+ export type JsonLogicRule = Record<string, any>;
956
+ /**
957
+ * Conditions for individual enum values within a property.
958
+ * @group Entity properties
959
+ */
960
+ export interface EnumValueConditions {
961
+ /**
962
+ * Disable this enum option when condition is true.
963
+ * The option appears grayed out and cannot be selected.
964
+ */
965
+ disabled?: JsonLogicRule;
966
+ /**
967
+ * Message explaining why this option is disabled.
968
+ */
969
+ disabledMessage?: string;
970
+ /**
971
+ * Completely hide this enum option when condition is true.
972
+ * The option is removed from the dropdown/list.
973
+ */
974
+ hidden?: JsonLogicRule;
975
+ }
976
+ /**
977
+ * Declarative conditions for dynamic property behavior.
978
+ * All conditions are JSON Logic rules evaluated against ConditionContext.
979
+ *
980
+ * An alternative to PropertyBuilder functions that can be:
981
+ * - Stored in the database as JSON
982
+ * - Edited via the collection editor UI
983
+ * - Evaluated at runtime like property builders
984
+ *
985
+ * @see https://jsonlogic.com/ for JSON Logic syntax
986
+ * @group Entity properties
987
+ */
988
+ export interface PropertyConditions {
989
+ /**
990
+ * Disable the field when this condition evaluates to true.
991
+ * The field becomes non-editable but still visible (unless also hidden).
992
+ *
993
+ * @example Disable when another field has a specific value
994
+ * \`\`\`json
995
+ * { "==": [{ "var": "values.status" }, "archived"] }
996
+ * \`\`\`
997
+ */
998
+ disabled?: JsonLogicRule;
999
+ /**
1000
+ * Message to display when the field is disabled by a condition.
1001
+ */
1002
+ disabledMessage?: string;
1003
+ /**
1004
+ * Clear the field's value when it becomes disabled.
1005
+ * @default false
1006
+ */
1007
+ clearOnDisabled?: boolean;
1008
+ /**
1009
+ * Hide the field completely when this condition evaluates to true.
1010
+ * The field is removed from the form (not just visually hidden).
1011
+ */
1012
+ hidden?: JsonLogicRule;
1013
+ /**
1014
+ * Make the field read-only when this condition evaluates to true.
1015
+ * Renders as a preview instead of an input.
1016
+ */
1017
+ readOnly?: JsonLogicRule;
1018
+ /**
1019
+ * Make the field required when this condition evaluates to true.
1020
+ * Overrides the static `validation.required` setting.
1021
+ */
1022
+ required?: JsonLogicRule;
1023
+ /**
1024
+ * Custom message when conditional required validation fails.
1025
+ */
1026
+ requiredMessage?: string;
1027
+ /**
1028
+ * Dynamic minimum value for number/string length.
1029
+ * Should evaluate to a number.
1030
+ */
1031
+ min?: JsonLogicRule;
1032
+ /**
1033
+ * Dynamic maximum value for number/string length.
1034
+ * Should evaluate to a number.
1035
+ */
1036
+ max?: JsonLogicRule;
1037
+ /**
1038
+ * Dynamic default value for new entities.
1039
+ * Should evaluate to a value of the appropriate type for the field.
1040
+ * Only applied when entityId is empty (new entity).
1041
+ */
1042
+ defaultValue?: JsonLogicRule;
1043
+ /**
1044
+ * Conditions for individual enum values.
1045
+ * Keys are the enum value IDs, values are condition configs.
1046
+ *
1047
+ * @example Disable certain enum options based on user role
1048
+ * \`\`\`json
1049
+ * {
1050
+ * "admin": {
1051
+ * "disabled": { "!": { "hasRole": "admin" } },
1052
+ * "disabledMessage": "Admin option requires admin role"
1053
+ * }
1054
+ * }
1055
+ * \`\`\`
1056
+ */
1057
+ enumConditions?: Record<string | number, EnumValueConditions>;
1058
+ /**
1059
+ * Filter which enum values are available.
1060
+ * Should evaluate to an array of allowed enum value IDs.
1061
+ */
1062
+ allowedEnumValues?: JsonLogicRule;
1063
+ /**
1064
+ * Exclude specific enum values.
1065
+ * Should evaluate to an array of enum value IDs to exclude.
1066
+ */
1067
+ excludedEnumValues?: JsonLogicRule;
1068
+ /**
1069
+ * Dynamic path for reference properties.
1070
+ * Should evaluate to a collection path string.
1071
+ */
1072
+ referencePath?: JsonLogicRule;
1073
+ /**
1074
+ * Dynamic filter for reference selection.
1075
+ * Should evaluate to a FilterValues object.
1076
+ */
1077
+ referenceFilter?: JsonLogicRule;
1078
+ /**
1079
+ * Can elements be added to the array?
1080
+ */
1081
+ canAddElements?: JsonLogicRule;
1082
+ /**
1083
+ * Can elements be reordered in the array?
1084
+ */
1085
+ sortable?: JsonLogicRule;
1086
+ /**
1087
+ * Dynamic accepted file types.
1088
+ * Should evaluate to an array of MIME types.
1089
+ */
1090
+ acceptedFiles?: JsonLogicRule;
1091
+ /**
1092
+ * Dynamic maximum file size in bytes.
1093
+ * Should evaluate to a number.
1094
+ */
1095
+ maxFileSize?: JsonLogicRule;
1096
+ }
1097
+ /**
1098
+ * Context available during JSON Logic condition evaluation.
1099
+ * Mirrors PropertyBuilderProps but adapted for JSON serialization.
1100
+ * @group Entity properties
1101
+ */
1102
+ export interface ConditionContext {
1103
+ /**
1104
+ * Current form/entity values.
1105
+ * Date values are converted to Unix timestamps (milliseconds).
1106
+ */
1107
+ values: Record<string, unknown>;
1108
+ /**
1109
+ * Previous values before the current edit session.
1110
+ */
1111
+ previousValues: Record<string, unknown>;
1112
+ /**
1113
+ * Current value of this property specifically.
1114
+ */
1115
+ propertyValue: unknown;
1116
+ /**
1117
+ * Collection path (e.g., "products", "users/uid123/orders")
1118
+ */
1119
+ path: string;
1120
+ /**
1121
+ * Entity ID. Undefined for new entities.
1122
+ */
1123
+ entityId?: string;
1124
+ /**
1125
+ * Whether this is a new entity being created.
1126
+ */
1127
+ isNew: boolean;
1128
+ /**
1129
+ * Index of this property (only for array items).
1130
+ */
1131
+ index?: number;
1132
+ /**
1133
+ * Current authenticated user information.
1134
+ */
1135
+ user: {
1136
+ uid: string;
1137
+ email: string | null;
1138
+ displayName: string | null;
1139
+ photoURL: string | null;
1140
+ /** Role IDs the user has (extracted from Role[].id) */
1141
+ roles: string[];
1142
+ };
1143
+ /**
1144
+ * Current timestamp as Unix milliseconds.
1145
+ */
1146
+ now: number;
1147
+ }
1148
+ export {};