@rebasepro/server-core 0.0.1-canary.eae7889 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/app/frontend/node_modules/esbuild/LICENSE.md +21 -0
  2. package/app/frontend/node_modules/esbuild/README.md +3 -0
  3. package/app/frontend/node_modules/esbuild/bin/esbuild +220 -0
  4. package/app/frontend/node_modules/esbuild/install.js +285 -0
  5. package/app/frontend/node_modules/esbuild/lib/main.d.ts +705 -0
  6. package/app/frontend/node_modules/esbuild/lib/main.js +2239 -0
  7. package/app/frontend/node_modules/esbuild/package.json +46 -0
  8. package/dist/index.es.js +1186 -1673
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.umd.js +1185 -1672
  11. package/dist/index.umd.js.map +1 -1
  12. package/dist/server-core/src/api/rest/api-generator.d.ts +15 -3
  13. package/dist/server-core/src/auth/admin-routes.d.ts +5 -0
  14. package/dist/server-core/src/auth/google-oauth.d.ts +36 -3
  15. package/dist/server-core/src/auth/index.d.ts +1 -0
  16. package/dist/server-core/src/cron/cron-scheduler.d.ts +45 -0
  17. package/dist/server-core/src/cron/index.d.ts +1 -1
  18. package/dist/server-core/src/init.d.ts +11 -1
  19. package/dist/types/src/controllers/auth.d.ts +8 -2
  20. package/dist/types/src/controllers/client.d.ts +13 -0
  21. package/dist/types/src/controllers/collection_registry.d.ts +2 -1
  22. package/dist/types/src/controllers/data_driver.d.ts +36 -1
  23. package/dist/types/src/controllers/navigation.d.ts +18 -6
  24. package/dist/types/src/controllers/registry.d.ts +9 -1
  25. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  26. package/dist/types/src/rebase_context.d.ts +17 -0
  27. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  28. package/dist/types/src/types/collections.d.ts +31 -11
  29. package/dist/types/src/types/component_ref.d.ts +47 -0
  30. package/dist/types/src/types/cron.d.ts +1 -1
  31. package/dist/types/src/types/entity_views.d.ts +6 -7
  32. package/dist/types/src/types/formex.d.ts +40 -0
  33. package/dist/types/src/types/index.d.ts +3 -0
  34. package/dist/types/src/types/plugins.d.ts +6 -3
  35. package/dist/types/src/types/properties.d.ts +72 -88
  36. package/dist/types/src/types/slots.d.ts +20 -10
  37. package/dist/types/src/types/translations.d.ts +6 -0
  38. package/examples/firebase/node_modules/esbuild/LICENSE.md +21 -0
  39. package/examples/firebase/node_modules/esbuild/README.md +3 -0
  40. package/examples/firebase/node_modules/esbuild/bin/esbuild +220 -0
  41. package/examples/firebase/node_modules/esbuild/install.js +285 -0
  42. package/examples/firebase/node_modules/esbuild/lib/main.d.ts +705 -0
  43. package/examples/firebase/node_modules/esbuild/lib/main.js +2239 -0
  44. package/examples/firebase/node_modules/esbuild/package.json +46 -0
  45. package/examples/medmot-staging/frontend/node_modules/esbuild/LICENSE.md +21 -0
  46. package/examples/medmot-staging/frontend/node_modules/esbuild/README.md +3 -0
  47. package/examples/medmot-staging/frontend/node_modules/esbuild/bin/esbuild +220 -0
  48. package/examples/medmot-staging/frontend/node_modules/esbuild/install.js +285 -0
  49. package/examples/medmot-staging/frontend/node_modules/esbuild/lib/main.d.ts +705 -0
  50. package/examples/medmot-staging/frontend/node_modules/esbuild/lib/main.js +2239 -0
  51. package/examples/medmot-staging/frontend/node_modules/esbuild/package.json +46 -0
  52. package/examples/sdk-demo/node_modules/esbuild/LICENSE.md +21 -0
  53. package/examples/sdk-demo/node_modules/esbuild/README.md +3 -0
  54. package/examples/sdk-demo/node_modules/esbuild/bin/esbuild +223 -0
  55. package/examples/sdk-demo/node_modules/esbuild/install.js +289 -0
  56. package/examples/sdk-demo/node_modules/esbuild/lib/main.d.ts +716 -0
  57. package/examples/sdk-demo/node_modules/esbuild/lib/main.js +2242 -0
  58. package/examples/sdk-demo/node_modules/esbuild/package.json +49 -0
  59. package/package.json +9 -9
  60. package/packages/client/node_modules/esbuild/LICENSE.md +21 -0
  61. package/packages/client/node_modules/esbuild/README.md +3 -0
  62. package/packages/client/node_modules/esbuild/bin/esbuild +220 -0
  63. package/packages/client/node_modules/esbuild/install.js +285 -0
  64. package/packages/client/node_modules/esbuild/lib/main.d.ts +705 -0
  65. package/packages/client/node_modules/esbuild/lib/main.js +2239 -0
  66. package/packages/client/node_modules/esbuild/package.json +46 -0
  67. package/packages/client-postgresql/node_modules/esbuild/LICENSE.md +21 -0
  68. package/packages/client-postgresql/node_modules/esbuild/README.md +3 -0
  69. package/packages/client-postgresql/node_modules/esbuild/bin/esbuild +220 -0
  70. package/packages/client-postgresql/node_modules/esbuild/install.js +285 -0
  71. package/packages/client-postgresql/node_modules/esbuild/lib/main.d.ts +705 -0
  72. package/packages/client-postgresql/node_modules/esbuild/lib/main.js +2239 -0
  73. package/packages/client-postgresql/node_modules/esbuild/package.json +46 -0
  74. package/packages/common/node_modules/esbuild/LICENSE.md +21 -0
  75. package/packages/common/node_modules/esbuild/README.md +3 -0
  76. package/packages/common/node_modules/esbuild/bin/esbuild +220 -0
  77. package/packages/common/node_modules/esbuild/install.js +285 -0
  78. package/packages/common/node_modules/esbuild/lib/main.d.ts +705 -0
  79. package/packages/common/node_modules/esbuild/lib/main.js +2239 -0
  80. package/packages/common/node_modules/esbuild/package.json +46 -0
  81. package/packages/server-mongodb/node_modules/esbuild/LICENSE.md +21 -0
  82. package/packages/server-mongodb/node_modules/esbuild/README.md +3 -0
  83. package/packages/server-mongodb/node_modules/esbuild/bin/esbuild +220 -0
  84. package/packages/server-mongodb/node_modules/esbuild/install.js +285 -0
  85. package/packages/server-mongodb/node_modules/esbuild/lib/main.d.ts +705 -0
  86. package/packages/server-mongodb/node_modules/esbuild/lib/main.js +2239 -0
  87. package/packages/server-mongodb/node_modules/esbuild/package.json +46 -0
  88. package/packages/server-postgresql/node_modules/esbuild/LICENSE.md +21 -0
  89. package/packages/server-postgresql/node_modules/esbuild/README.md +3 -0
  90. package/packages/server-postgresql/node_modules/esbuild/bin/esbuild +220 -0
  91. package/packages/server-postgresql/node_modules/esbuild/install.js +285 -0
  92. package/packages/server-postgresql/node_modules/esbuild/lib/main.d.ts +705 -0
  93. package/packages/server-postgresql/node_modules/esbuild/lib/main.js +2239 -0
  94. package/packages/server-postgresql/node_modules/esbuild/package.json +46 -0
  95. package/packages/types/node_modules/esbuild/LICENSE.md +21 -0
  96. package/packages/types/node_modules/esbuild/README.md +3 -0
  97. package/packages/types/node_modules/esbuild/bin/esbuild +220 -0
  98. package/packages/types/node_modules/esbuild/install.js +285 -0
  99. package/packages/types/node_modules/esbuild/lib/main.d.ts +705 -0
  100. package/packages/types/node_modules/esbuild/lib/main.js +2239 -0
  101. package/packages/types/node_modules/esbuild/package.json +46 -0
  102. package/packages/utils/node_modules/esbuild/LICENSE.md +21 -0
  103. package/packages/utils/node_modules/esbuild/README.md +3 -0
  104. package/packages/utils/node_modules/esbuild/bin/esbuild +220 -0
  105. package/packages/utils/node_modules/esbuild/install.js +285 -0
  106. package/packages/utils/node_modules/esbuild/lib/main.d.ts +705 -0
  107. package/packages/utils/node_modules/esbuild/lib/main.js +2239 -0
  108. package/packages/utils/node_modules/esbuild/package.json +46 -0
  109. package/src/api/errors.ts +3 -2
  110. package/src/api/rest/api-generator-count.test.ts +113 -0
  111. package/src/api/rest/api-generator.ts +123 -22
  112. package/src/api/server.ts +8 -4
  113. package/src/auth/admin-routes.ts +133 -57
  114. package/src/auth/apple-oauth.ts +8 -18
  115. package/src/auth/google-oauth.ts +192 -22
  116. package/src/auth/index.ts +1 -0
  117. package/src/auth/rate-limiter.ts +9 -5
  118. package/src/auth/routes.ts +25 -5
  119. package/src/collections/loader.ts +3 -3
  120. package/src/cron/cron-scheduler.test.ts +301 -175
  121. package/src/cron/cron-scheduler.ts +220 -57
  122. package/src/cron/index.ts +1 -1
  123. package/src/init.ts +27 -5
  124. package/src/storage/LocalStorageController.ts +37 -13
  125. package/src/storage/S3StorageController.ts +4 -1
  126. package/src/storage/routes.ts +51 -5
  127. package/test/backend-hooks-admin.test.ts +394 -0
  128. package/test/backend-hooks-data.test.ts +408 -0
  129. package/history_diff.log +0 -385
  130. package/scratch.ts +0 -9
  131. package/test-ast.ts +0 -28
  132. package/test_output.txt +0 -1133
@@ -9,6 +9,7 @@ import type { RebaseContext } from "../rebase_context";
9
9
  import type { Relation } from "./relations";
10
10
  import type { EntityCustomView } from "./entity_views";
11
11
  import type { EntityAction } from "./entity_actions";
12
+ import type { ComponentRef } from "./component_ref";
12
13
  /**
13
14
  * Base interface containing all driver-agnostic collection properties.
14
15
  * Use {@link PostgresCollection} or {@link FirebaseCollection} for
@@ -19,9 +20,8 @@ import type { EntityAction } from "./entity_actions";
19
20
  */
20
21
  export interface BaseEntityCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
21
22
  /**
22
- * You can set an alias that will be used internally instead of the `path`.
23
- * The `alias` value will be used to determine the URL of the collection,
24
- * while `path` will still be used in the driver.
23
+ * You can set an alias that will be used internally instead of the collection name.
24
+ * The `slug` value will be used to determine the URL of the collection.
25
25
  * Note that you can use this value in reference properties too.
26
26
  */
27
27
  slug: string;
@@ -87,6 +87,9 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
87
87
  icon?: string | React.ReactNode;
88
88
  /**
89
89
  * Navigation group for this collection.
90
+ * Collections sharing the same group name will be visually grouped
91
+ * together in the drawer and home page. If not set, the collection
92
+ * falls into the default "Views" group.
90
93
  */
91
94
  group?: string;
92
95
  /**
@@ -158,17 +161,17 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
158
161
  /**
159
162
  * Force a filter in this view. If applied, the rest of the filters will
160
163
  * be disabled. Filters applied with this prop cannot be changed.
161
- * e.g. `forceFilter: { age: [">", 18] }`
162
- * e.g. `forceFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
164
+ * e.g. `fixedFilter: { age: [">", 18] }`
165
+ * e.g. `fixedFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
163
166
  */
164
- readonly forceFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
167
+ readonly fixedFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
165
168
  /**
166
169
  * Initial filters applied to the collection this collection is related to.
167
170
  * Defaults to none. Filters applied with this prop can be changed.
168
- * e.g. `filter: { age: [">", 18] }`
169
- * e.g. `filter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
171
+ * e.g. `defaultFilter: { age: [">", 18] }`
172
+ * e.g. `defaultFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
170
173
  */
171
- readonly filter?: FilterValues<Extract<keyof M, string> | (string & {})>;
174
+ readonly defaultFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
172
175
  /**
173
176
  * Default sort applied to this collection.
174
177
  * When setting this prop, entities will have a default order
@@ -302,7 +305,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
302
305
  /**
303
306
  * Builder for the collection actions rendered in the toolbar
304
307
  */
305
- Actions?: React.ComponentType<any>[];
308
+ Actions?: ComponentRef<CollectionActionsProps>[];
306
309
  }
307
310
  /**
308
311
  * A collection backed by PostgreSQL (or any SQL database).
@@ -314,6 +317,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
314
317
  * @group Models
315
318
  */
316
319
  export interface PostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
320
+ properties: Properties;
317
321
  /**
318
322
  * The driver for this collection. For Postgres collections this
319
323
  * can be omitted (Postgres is the default) or set to `"postgres"`.
@@ -457,7 +461,8 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
457
461
  /**
458
462
  * Array of the parent path segments like `['users']`
459
463
  */
460
- parentCollectionIds: string[];
464
+ parentCollectionSlugs: string[];
465
+ parentEntityIds: string[];
461
466
  /**
462
467
  * The collection configuration
463
468
  */
@@ -481,6 +486,21 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
481
486
  * undefined means the count is still loading.
482
487
  */
483
488
  collectionEntitiesCount?: number;
489
+ /**
490
+ * Programmatically open the new-document form for this collection,
491
+ * optionally pre-populating it with initial field values.
492
+ * The form opens in the same mode configured for the collection
493
+ * (side panel, full screen, or split).
494
+ *
495
+ * This is the primary hook for workflows that need to create a document
496
+ * from external data — e.g. fetching content from a URL, importing from
497
+ * a third-party API, or duplicating from another system.
498
+ *
499
+ * @example
500
+ * // Inside a custom CollectionAction component:
501
+ * openNewDocument({ title: "Fetched title", body: "..." });
502
+ */
503
+ openNewDocument: (defaultValues?: Record<string, unknown>) => void;
484
504
  }
485
505
  /**
486
506
  * Use this controller to retrieve the selected entities or modify them in
@@ -0,0 +1,47 @@
1
+ import type React from "react";
2
+ /**
3
+ * Internal marker for a lazily-loaded component reference.
4
+ * Created by the Vite transform plugin when converting string paths
5
+ * to deferred `import()` calls. Users should NOT create these manually.
6
+ *
7
+ * @internal
8
+ */
9
+ export interface LazyComponentRef<P = unknown> {
10
+ readonly __rebaseLazy: true;
11
+ readonly load: () => Promise<{
12
+ default: React.ComponentType<P>;
13
+ }>;
14
+ }
15
+ /**
16
+ * A reference to a React component that can be provided in three forms:
17
+ *
18
+ * 1. **String path** (recommended for collection configs):
19
+ * ```ts
20
+ * Field: "../../frontend/src/components/MyField"
21
+ * ```
22
+ * The Vite plugin transforms this into a `LazyComponentRef` at build time.
23
+ * On the backend, the string stays inert and is never evaluated.
24
+ *
25
+ * 2. **Lazy import function**:
26
+ * ```ts
27
+ * Field: () => import("../../frontend/src/components/MyField")
28
+ * ```
29
+ * Standard ES dynamic import. Backend never calls the function.
30
+ *
31
+ * 3. **Direct component reference** (use only in frontend-only code):
32
+ * ```ts
33
+ * Field: MyFieldComponent
34
+ * ```
35
+ * Importing a component at the top level will pull React into the
36
+ * backend runtime — only safe in code that the backend never imports.
37
+ *
38
+ * @group Types
39
+ */
40
+ export type ComponentRef<P = unknown> = React.ComponentType<P> | LazyComponentRef<P> | (() => Promise<{
41
+ default: React.ComponentType<P>;
42
+ }>) | string;
43
+ /**
44
+ * Type guard: checks if a value is a `LazyComponentRef` produced by the
45
+ * Vite transform plugin.
46
+ */
47
+ export declare function isLazyComponentRef<P = unknown>(ref: unknown): ref is LazyComponentRef<P>;
@@ -1,3 +1,4 @@
1
+ import type { RebaseClient } from "../controllers/client";
1
2
  /**
2
3
  * Cron Job type definitions for Rebase.
3
4
  *
@@ -32,7 +33,6 @@ export interface CronJobDefinition {
32
33
  */
33
34
  handler: (ctx: CronJobContext) => Promise<unknown> | unknown;
34
35
  }
35
- import type { RebaseClient } from "../controllers/client";
36
36
  /**
37
37
  * Context passed to each cron handler invocation.
38
38
  */
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import type { Entity, EntityValues } from "./entities";
3
3
  import type { EntityCollection } from "./collections";
4
+ import type { FormexController } from "./formex";
5
+ import type { ComponentRef } from "./component_ref";
4
6
  /**
5
7
  * Context passed to custom fields and entity views.
6
- * This is the base definition — `@rebasepro/admin` re-exports a
7
- * fully-typed version that narrows the `formex` field.
8
8
  * @group Form custom fields
9
9
  */
10
10
  export interface FormContext<M extends Record<string, unknown> = Record<string, unknown>> {
@@ -38,10 +38,8 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
38
38
  openEntityMode: "side_panel" | "full_screen" | "split";
39
39
  /**
40
40
  * The underlying formex controller that powers the form.
41
- * Prefer importing `FormContext` from `@rebasepro/admin` for the
42
- * fully-typed `FormexController<M>` version.
43
41
  */
44
- formex: Record<string, unknown>;
42
+ formex: FormexController<M>;
45
43
  disabled: boolean;
46
44
  }
47
45
  export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
@@ -49,7 +47,7 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
49
47
  name: string;
50
48
  tabComponent?: React.ReactNode;
51
49
  includeActions?: boolean | "bottom";
52
- Builder?: React.ComponentType<EntityCustomViewParams<M>>;
50
+ Builder?: ComponentRef<EntityCustomViewParams<M>>;
53
51
  position?: "start" | "end";
54
52
  };
55
53
  export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
@@ -57,5 +55,6 @@ export interface EntityCustomViewParams<M extends Record<string, unknown> = Reco
57
55
  entity?: Entity<M>;
58
56
  modifiedValues?: EntityValues<M>;
59
57
  formContext: FormContext<M>;
60
- parentCollectionIds?: string[];
58
+ parentCollectionSlugs?: string[];
59
+ parentEntityIds?: string[];
61
60
  }
@@ -0,0 +1,40 @@
1
+ import React, { FormEvent } from "react";
2
+ export type FormexController<T = any> = {
3
+ values: T;
4
+ initialValues: T;
5
+ setValues: (values: T) => void;
6
+ setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
7
+ touched: Record<string, boolean>;
8
+ setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
9
+ setTouched: (touched: Record<string, boolean>) => void;
10
+ dirty: boolean;
11
+ setDirty: (dirty: boolean) => void;
12
+ setSubmitCount: (submitCount: number) => void;
13
+ errors: Record<string, string>;
14
+ setFieldError: (key: string, error?: string) => void;
15
+ handleChange: (event: React.SyntheticEvent) => void;
16
+ handleBlur: (event: React.FocusEvent) => void;
17
+ handleSubmit: (event?: FormEvent<HTMLFormElement>) => void;
18
+ validate: () => void;
19
+ resetForm: (props?: FormexResetProps<T>) => void;
20
+ submitCount: number;
21
+ isSubmitting: boolean;
22
+ setSubmitting: (isSubmitting: boolean) => void;
23
+ isValidating: boolean;
24
+ /**
25
+ * The version of the form. This is incremented every time the form is reset
26
+ * or the form is submitted.
27
+ */
28
+ version: number;
29
+ debugId?: string;
30
+ undo: () => void;
31
+ redo: () => void;
32
+ canUndo: boolean;
33
+ canRedo: boolean;
34
+ };
35
+ export type FormexResetProps<T = any> = {
36
+ values?: T;
37
+ submitCount?: number;
38
+ errors?: Record<string, string>;
39
+ touched?: Record<string, boolean>;
40
+ };
@@ -10,6 +10,7 @@ export * from "./entity_callbacks";
10
10
  export * from "./entity_overrides";
11
11
  export * from "./export_import";
12
12
  export * from "./modify_collections";
13
+ export * from "./formex";
13
14
  export * from "./websockets";
14
15
  export * from "./backend";
15
16
  export * from "./translations";
@@ -21,3 +22,5 @@ export * from "./property_config";
21
22
  export * from "./entity_views";
22
23
  export * from "./data_source";
23
24
  export * from "./cron";
25
+ export * from "./backend_hooks";
26
+ export * from "./component_ref";
@@ -157,7 +157,8 @@ export interface PluginHooks {
157
157
  */
158
158
  onColumnsReorder?: (props: {
159
159
  fullPath: string;
160
- parentCollectionIds: string[];
160
+ parentCollectionSlugs: string[];
161
+ parentEntityIds: string[];
161
162
  collection: EntityCollection;
162
163
  newPropertiesOrder: string[];
163
164
  }) => void;
@@ -166,7 +167,8 @@ export interface PluginHooks {
166
167
  */
167
168
  onKanbanColumnsReorder?: (props: {
168
169
  fullPath: string;
169
- parentCollectionIds: string[];
170
+ parentCollectionSlugs: string[];
171
+ parentEntityIds: string[];
170
172
  collection: EntityCollection;
171
173
  kanbanColumnProperty: string;
172
174
  newColumnsOrder: string[];
@@ -241,7 +243,8 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
241
243
  export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
242
244
  entityId?: string | number;
243
245
  path: string;
244
- parentCollectionIds: string[];
246
+ parentCollectionSlugs: string[];
247
+ parentEntityIds: string[];
245
248
  status: EntityStatus;
246
249
  collection: EC;
247
250
  disabled: boolean;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import type { ComponentRef } from "./component_ref";
2
2
  import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
3
3
  import type { Relation, JoinStep, OnAction } from "./relations";
4
4
  import type { EntityCollection, FilterValues } from "./collections";
@@ -36,6 +36,14 @@ export type Property = StringProperty | NumberProperty | BooleanProperty | DateP
36
36
  export type Properties = {
37
37
  [key: string]: Property;
38
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
+ };
39
47
  /**
40
48
  * A helper type to infer the underlying data type from a Property definition.
41
49
  * This is the core of the type inference system.
@@ -89,7 +97,18 @@ export type InferEntityType<P extends Properties> = {
89
97
  * Interface including all common properties of a CMS property.
90
98
  * @group Entity properties
91
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?: ComponentRef<any>;
108
+ Preview?: ComponentRef<any>;
109
+ }
92
110
  export interface BaseProperty<CustomProps = unknown> {
111
+ ui?: BaseUIConfig<CustomProps>;
93
112
  /**
94
113
  * Property name (e.g. Product)
95
114
  */
@@ -106,27 +125,17 @@ export interface BaseProperty<CustomProps = unknown> {
106
125
  */
107
126
  propertyConfig?: string;
108
127
  /**
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
+ * Explicit database column name. When set, this value is used as-is
129
+ * for the SQL column name, bypassing any snake_case conversion of
130
+ * the property key.
131
+ *
132
+ * This is automatically populated by `rebase schema introspect`
133
+ * to guarantee an exact match with the live database schema.
134
+ *
135
+ * For manually-authored collections you can omit this — the framework
136
+ * will derive the column name from the property key via `toSnakeCase()`.
128
137
  */
129
- disabled?: boolean | PropertyDisabledConfig;
138
+ columnName?: string;
130
139
  /**
131
140
  * Rules for validating this property
132
141
  */
@@ -135,16 +144,6 @@ export interface BaseProperty<CustomProps = unknown> {
135
144
  * This value will be set by default for new entities.
136
145
  */
137
146
  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
147
  /**
149
148
  * Use this to define dynamic properties that change based on certain conditions
150
149
  * or on the entity's values. For example, you can make a field read-only if
@@ -168,21 +167,19 @@ export interface BaseProperty<CustomProps = unknown> {
168
167
  * Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
169
168
  */
170
169
  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
170
  }
182
171
  /**
183
172
  * @group Entity properties
184
173
  */
174
+ export interface StringUIConfig extends BaseUIConfig {
175
+ multiline?: boolean;
176
+ markdown?: boolean;
177
+ previewAsTag?: boolean;
178
+ clearable?: boolean;
179
+ url?: boolean | PreviewType;
180
+ }
185
181
  export interface StringProperty extends BaseProperty {
182
+ ui?: StringUIConfig;
186
183
  type: "string";
187
184
  /**
188
185
  * Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
@@ -257,10 +254,6 @@ export interface StringProperty extends BaseProperty {
257
254
  * Should this string be rendered as a tag instead of just text.
258
255
  */
259
256
  previewAsTag?: boolean;
260
- /**
261
- * Add an icon to clear the value and set it to `null`. Defaults to `false`
262
- */
263
- clearable?: boolean;
264
257
  /**
265
258
  * You can use this property (a string) to behave as a reference to another
266
259
  * collection. The stored value is the ID of the entity in the
@@ -272,7 +265,11 @@ export interface StringProperty extends BaseProperty {
272
265
  /**
273
266
  * @group Entity properties
274
267
  */
268
+ export interface NumberUIConfig extends BaseUIConfig {
269
+ clearable?: boolean;
270
+ }
275
271
  export interface NumberProperty extends BaseProperty {
272
+ ui?: NumberUIConfig;
276
273
  type: "number";
277
274
  /**
278
275
  * Optional database column type. Allows specifying exact database numeric types.
@@ -300,15 +297,12 @@ export interface NumberProperty extends BaseProperty {
300
297
  * displayed in the dropdown.
301
298
  */
302
299
  enum?: EnumValues;
303
- /**
304
- * Add an icon to clear the value and set it to `null`. Defaults to `false`
305
- */
306
- clearable?: boolean;
307
300
  }
308
301
  /**
309
302
  * @group Entity properties
310
303
  */
311
304
  export interface BooleanProperty extends BaseProperty {
305
+ ui?: BaseUIConfig;
312
306
  type: "boolean";
313
307
  /**
314
308
  * Rules for validating this property
@@ -318,7 +312,11 @@ export interface BooleanProperty extends BaseProperty {
318
312
  /**
319
313
  * @group Entity properties
320
314
  */
315
+ export interface DateUIConfig extends BaseUIConfig {
316
+ clearable?: boolean;
317
+ }
321
318
  export interface DateProperty extends BaseProperty {
319
+ ui?: DateUIConfig;
322
320
  type: "date";
323
321
  /**
324
322
  * Optional database column type. If not set, defaults to `timestamp` with timezone.
@@ -354,6 +352,7 @@ export interface DateProperty extends BaseProperty {
354
352
  * @group Entity properties
355
353
  */
356
354
  export interface GeopointProperty extends BaseProperty {
355
+ ui?: BaseUIConfig;
357
356
  type: "geopoint";
358
357
  /**
359
358
  * Rules for validating this property
@@ -363,7 +362,11 @@ export interface GeopointProperty extends BaseProperty {
363
362
  /**
364
363
  * @group Entity properties
365
364
  */
365
+ export interface ReferenceUIConfig extends BaseUIConfig {
366
+ previewProperties?: string[];
367
+ }
366
368
  export interface ReferenceProperty extends BaseProperty {
369
+ ui?: ReferenceUIConfig;
367
370
  type: "reference";
368
371
  /**
369
372
  * Marks this field as a Primary Key / Unique Identifier.
@@ -384,15 +387,9 @@ export interface ReferenceProperty extends BaseProperty {
384
387
  path?: string;
385
388
  /**
386
389
  * Allow selection of entities that pass the given filter only.
387
- * e.g. `forceFilter: { age: [">=", 18] }`
390
+ * e.g. `fixedFilter: { age: [">=", 18] }`
388
391
  */
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[];
392
+ fixedFilter?: FilterValues<string>;
396
393
  /**
397
394
  * Should the reference include the ID of the entity. Defaults to `true`
398
395
  */
@@ -405,7 +402,12 @@ export interface ReferenceProperty extends BaseProperty {
405
402
  /**
406
403
  * @group Entity properties
407
404
  */
405
+ export interface RelationUIConfig extends BaseUIConfig {
406
+ previewProperties?: string[];
407
+ widget?: "select" | "dialog";
408
+ }
408
409
  export interface RelationProperty extends BaseProperty {
410
+ ui?: RelationUIConfig;
409
411
  type: "relation";
410
412
  /**
411
413
  * Marks this field as a Primary Key / Unique Identifier.
@@ -492,15 +494,9 @@ export interface RelationProperty extends BaseProperty {
492
494
  relation?: Relation;
493
495
  /**
494
496
  * Allow selection of entities that pass the given filter only.
495
- * e.g. `forceFilter: { age: [">=", 18] }`
497
+ * e.g. `fixedFilter: { age: [">=", 18] }`
496
498
  */
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[];
499
+ fixedFilter?: FilterValues<string>;
504
500
  /**
505
501
  * Should the reference include the ID of the entity. Defaults to `true`
506
502
  */
@@ -518,7 +514,12 @@ export interface RelationProperty extends BaseProperty {
518
514
  /**
519
515
  * @group Entity properties
520
516
  */
517
+ export interface ArrayUIConfig extends BaseUIConfig {
518
+ expanded?: boolean;
519
+ minimalistView?: boolean;
520
+ }
521
521
  export interface ArrayProperty extends BaseProperty {
522
+ ui?: ArrayUIConfig;
522
523
  type: "array";
523
524
  /**
524
525
  * Optional database column type. Defaults to `jsonb`.
@@ -573,15 +574,6 @@ export interface ArrayProperty extends BaseProperty {
573
574
  * Rules for validating this property
574
575
  */
575
576
  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
577
  /**
586
578
  * Can the elements in this array be reordered. Defaults to `true`.
587
579
  * This prop has no effect if `disabled` is set to true.
@@ -596,7 +588,13 @@ export interface ArrayProperty extends BaseProperty {
596
588
  /**
597
589
  * @group Entity properties
598
590
  */
591
+ export interface MapUIConfig extends BaseUIConfig {
592
+ expanded?: boolean;
593
+ minimalistView?: boolean;
594
+ spreadChildren?: boolean;
595
+ }
599
596
  export interface MapProperty extends BaseProperty {
597
+ ui?: MapUIConfig;
600
598
  type: "map";
601
599
  /**
602
600
  * Optional database column type. Defaults to `jsonb`.
@@ -630,20 +628,6 @@ export interface MapProperty extends BaseProperty {
630
628
  * needed
631
629
  */
632
630
  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
631
  /**
648
632
  * Render this map as a key-value table that allows to use
649
633
  * arbitrary keys. You don't need to define the properties in this case.