@rebasepro/server-mongodb 0.0.1-canary.09e5ec5

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