@rebasepro/server-postgresql 0.5.0 → 0.6.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 (165) hide show
  1. package/dist/{server-postgresql/src/PostgresAdapter.d.ts → PostgresAdapter.d.ts} +1 -1
  2. package/dist/{server-postgresql/src/PostgresBackendDriver.d.ts → PostgresBackendDriver.d.ts} +2 -2
  3. package/dist/{server-postgresql/src/PostgresBootstrapper.d.ts → PostgresBootstrapper.d.ts} +11 -1
  4. package/dist/{server-postgresql/src/collections → collections}/PostgresCollectionRegistry.d.ts +4 -0
  5. package/dist/index.es.js +10168 -11145
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/index.umd.js +10735 -11429
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/{server-postgresql/src/services → services}/EntityPersistService.d.ts +0 -14
  10. package/dist/utils/pg-error-utils.d.ts +55 -0
  11. package/package.json +24 -21
  12. package/src/PostgresAdapter.ts +9 -10
  13. package/src/PostgresBackendDriver.ts +134 -121
  14. package/src/PostgresBootstrapper.ts +86 -13
  15. package/src/auth/ensure-tables.ts +28 -5
  16. package/src/auth/services.ts +28 -18
  17. package/src/cli.ts +99 -96
  18. package/src/collections/PostgresCollectionRegistry.ts +7 -0
  19. package/src/connection.ts +11 -6
  20. package/src/data-transformer.ts +16 -14
  21. package/src/databasePoolManager.ts +3 -2
  22. package/src/history/HistoryService.ts +3 -2
  23. package/src/history/ensure-history-table.ts +5 -4
  24. package/src/schema/auth-schema.ts +1 -2
  25. package/src/schema/doctor-cli.ts +2 -1
  26. package/src/schema/doctor.ts +40 -37
  27. package/src/schema/generate-drizzle-schema-logic.ts +56 -18
  28. package/src/schema/generate-drizzle-schema.ts +11 -11
  29. package/src/schema/introspect-db-inference.ts +25 -25
  30. package/src/schema/introspect-db-logic.ts +38 -38
  31. package/src/schema/introspect-db.ts +28 -27
  32. package/src/services/BranchService.ts +14 -0
  33. package/src/services/EntityFetchService.ts +28 -25
  34. package/src/services/EntityPersistService.ts +11 -141
  35. package/src/services/RelationService.ts +57 -37
  36. package/src/services/entity-helpers.ts +6 -2
  37. package/src/services/realtimeService.ts +45 -32
  38. package/src/utils/drizzle-conditions.ts +31 -15
  39. package/src/utils/pg-error-utils.ts +211 -0
  40. package/src/websocket.ts +15 -12
  41. package/test/auth-services.test.ts +36 -19
  42. package/test/batch-many-to-many-regression.test.ts +119 -39
  43. package/test/data-transformer-hardening.test.ts +67 -33
  44. package/test/data-transformer.test.ts +4 -2
  45. package/test/doctor.test.ts +10 -5
  46. package/test/drizzle-conditions.test.ts +59 -6
  47. package/test/generate-drizzle-schema.test.ts +65 -40
  48. package/test/introspect-db-generation.test.ts +179 -81
  49. package/test/introspect-db-utils.test.ts +92 -37
  50. package/test/mocks/chalk.cjs +7 -0
  51. package/test/pg-error-utils.test.ts +221 -0
  52. package/test/postgresDataDriver.test.ts +14 -5
  53. package/test/property-ordering.test.ts +126 -79
  54. package/test/realtimeService.test.ts +6 -2
  55. package/test/relation-pipeline-gaps.test.ts +84 -36
  56. package/test/relations.test.ts +247 -0
  57. package/test/unmapped-tables-safety.test.ts +14 -6
  58. package/test/websocket.test.ts +1 -1
  59. package/tsconfig.json +5 -0
  60. package/tsconfig.prod.json +3 -0
  61. package/vite.config.ts +5 -5
  62. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  63. package/dist/common/src/collections/default-collections.d.ts +0 -9
  64. package/dist/common/src/collections/index.d.ts +0 -2
  65. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  66. package/dist/common/src/data/query_builder.d.ts +0 -55
  67. package/dist/common/src/index.d.ts +0 -4
  68. package/dist/common/src/util/builders.d.ts +0 -57
  69. package/dist/common/src/util/callbacks.d.ts +0 -6
  70. package/dist/common/src/util/collections.d.ts +0 -11
  71. package/dist/common/src/util/common.d.ts +0 -2
  72. package/dist/common/src/util/conditions.d.ts +0 -26
  73. package/dist/common/src/util/entities.d.ts +0 -58
  74. package/dist/common/src/util/enums.d.ts +0 -3
  75. package/dist/common/src/util/index.d.ts +0 -16
  76. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  77. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  78. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  79. package/dist/common/src/util/paths.d.ts +0 -14
  80. package/dist/common/src/util/permissions.d.ts +0 -14
  81. package/dist/common/src/util/references.d.ts +0 -2
  82. package/dist/common/src/util/relations.d.ts +0 -22
  83. package/dist/common/src/util/resolutions.d.ts +0 -72
  84. package/dist/common/src/util/storage.d.ts +0 -24
  85. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  86. package/dist/types/src/controllers/auth.d.ts +0 -104
  87. package/dist/types/src/controllers/client.d.ts +0 -168
  88. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  89. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  90. package/dist/types/src/controllers/data.d.ts +0 -207
  91. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  92. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  93. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  94. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  95. package/dist/types/src/controllers/email.d.ts +0 -36
  96. package/dist/types/src/controllers/index.d.ts +0 -18
  97. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  98. package/dist/types/src/controllers/navigation.d.ts +0 -225
  99. package/dist/types/src/controllers/registry.d.ts +0 -63
  100. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  101. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  102. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  103. package/dist/types/src/controllers/storage.d.ts +0 -171
  104. package/dist/types/src/index.d.ts +0 -4
  105. package/dist/types/src/rebase_context.d.ts +0 -122
  106. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  107. package/dist/types/src/types/backend.d.ts +0 -571
  108. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  109. package/dist/types/src/types/builders.d.ts +0 -15
  110. package/dist/types/src/types/chips.d.ts +0 -5
  111. package/dist/types/src/types/collections.d.ts +0 -961
  112. package/dist/types/src/types/component_ref.d.ts +0 -47
  113. package/dist/types/src/types/cron.d.ts +0 -102
  114. package/dist/types/src/types/data_source.d.ts +0 -64
  115. package/dist/types/src/types/database_adapter.d.ts +0 -94
  116. package/dist/types/src/types/entities.d.ts +0 -145
  117. package/dist/types/src/types/entity_actions.d.ts +0 -104
  118. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  119. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  120. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  121. package/dist/types/src/types/entity_views.d.ts +0 -87
  122. package/dist/types/src/types/export_import.d.ts +0 -21
  123. package/dist/types/src/types/formex.d.ts +0 -40
  124. package/dist/types/src/types/index.d.ts +0 -28
  125. package/dist/types/src/types/locales.d.ts +0 -4
  126. package/dist/types/src/types/modify_collections.d.ts +0 -5
  127. package/dist/types/src/types/plugins.d.ts +0 -282
  128. package/dist/types/src/types/properties.d.ts +0 -1173
  129. package/dist/types/src/types/property_config.d.ts +0 -74
  130. package/dist/types/src/types/relations.d.ts +0 -336
  131. package/dist/types/src/types/slots.d.ts +0 -262
  132. package/dist/types/src/types/translations.d.ts +0 -900
  133. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  134. package/dist/types/src/types/websockets.d.ts +0 -78
  135. package/dist/types/src/users/index.d.ts +0 -1
  136. package/dist/types/src/users/user.d.ts +0 -50
  137. /package/dist/{server-postgresql/src/auth → auth}/ensure-tables.d.ts +0 -0
  138. /package/dist/{server-postgresql/src/auth → auth}/services.d.ts +0 -0
  139. /package/dist/{server-postgresql/src/cli.d.ts → cli.d.ts} +0 -0
  140. /package/dist/{server-postgresql/src/connection.d.ts → connection.d.ts} +0 -0
  141. /package/dist/{server-postgresql/src/data-transformer.d.ts → data-transformer.d.ts} +0 -0
  142. /package/dist/{server-postgresql/src/databasePoolManager.d.ts → databasePoolManager.d.ts} +0 -0
  143. /package/dist/{server-postgresql/src/history → history}/HistoryService.d.ts +0 -0
  144. /package/dist/{server-postgresql/src/history → history}/ensure-history-table.d.ts +0 -0
  145. /package/dist/{server-postgresql/src/index.d.ts → index.d.ts} +0 -0
  146. /package/dist/{server-postgresql/src/interfaces.d.ts → interfaces.d.ts} +0 -0
  147. /package/dist/{server-postgresql/src/schema → schema}/auth-schema.d.ts +0 -0
  148. /package/dist/{server-postgresql/src/schema → schema}/doctor-cli.d.ts +0 -0
  149. /package/dist/{server-postgresql/src/schema → schema}/doctor.d.ts +0 -0
  150. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema-logic.d.ts +0 -0
  151. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema.d.ts +0 -0
  152. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-inference.d.ts +0 -0
  153. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-logic.d.ts +0 -0
  154. /package/dist/{server-postgresql/src/schema → schema}/introspect-db.d.ts +0 -0
  155. /package/dist/{server-postgresql/src/schema → schema}/test-schema.d.ts +0 -0
  156. /package/dist/{server-postgresql/src/services → services}/BranchService.d.ts +0 -0
  157. /package/dist/{server-postgresql/src/services → services}/EntityFetchService.d.ts +0 -0
  158. /package/dist/{server-postgresql/src/services → services}/RelationService.d.ts +0 -0
  159. /package/dist/{server-postgresql/src/services → services}/entity-helpers.d.ts +0 -0
  160. /package/dist/{server-postgresql/src/services → services}/entityService.d.ts +0 -0
  161. /package/dist/{server-postgresql/src/services → services}/index.d.ts +0 -0
  162. /package/dist/{server-postgresql/src/services → services}/realtimeService.d.ts +0 -0
  163. /package/dist/{server-postgresql/src/types.d.ts → types.d.ts} +0 -0
  164. /package/dist/{server-postgresql/src/utils → utils}/drizzle-conditions.d.ts +0 -0
  165. /package/dist/{server-postgresql/src/websocket.d.ts → websocket.d.ts} +0 -0
@@ -1,173 +0,0 @@
1
- import type { EntityCollection } from "./collections";
2
- import type { Entity, EntityStatus, EntityValues } from "./entities";
3
- import type { User } from "../users";
4
- import type { RebaseCallContext } from "../rebase_context";
5
- /**
6
- * This interface defines all the callbacks that can be used when an entity
7
- * is being created, updated or deleted.
8
- * Useful for adding your own logic or blocking the execution of the operation.
9
- * @group Models
10
- */
11
- export type EntityCallbacks<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
12
- /**
13
- * Callback used after fetching data
14
- * @param props
15
- */
16
- afterRead?(props: EntityAfterReadProps<M, USER>): Promise<Entity<M>> | Entity<M>;
17
- /**
18
- * Callback used before saving, you need to return the values that will get
19
- * saved. If you throw an error in this method the process stops, and an
20
- * error snackbar gets displayed.
21
- * This runs after schema validation.
22
- * @param props
23
- */
24
- beforeSave?(props: EntityBeforeSaveProps<M, USER>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
25
- /**
26
- * Callback used when save is successful
27
- * @param props
28
- */
29
- afterSave?(props: EntityAfterSaveProps<M, USER>): Promise<void> | void;
30
- /**
31
- * Callback used when saving fails
32
- * @param props
33
- */
34
- afterSaveError?(props: EntityAfterSaveErrorProps<M, USER>): Promise<void> | void;
35
- /**
36
- * Callback used before the entity is deleted.
37
- * If you throw an error in this method the process stops, and an
38
- * error snackbar gets displayed.
39
- *
40
- * @param props
41
- */
42
- beforeDelete?(props: EntityBeforeDeleteProps<M, USER>): Promise<boolean | void> | boolean | void;
43
- /**
44
- * Callback used after the entity is deleted.
45
- *
46
- * @param props
47
- */
48
- afterDelete?(props: EntityAfterDeleteProps<M, USER>): void;
49
- };
50
- /**
51
- * Parameters passed to hooks when an entity is fetched
52
- * @group Models
53
- */
54
- export interface EntityAfterReadProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
55
- /**
56
- * Collection of the entity
57
- */
58
- collection: EntityCollection<M>;
59
- /**
60
- * Full path of the CMS where this collection is being fetched.
61
- * Might contain unresolved aliases.
62
- */
63
- path: string;
64
- /**
65
- * Fetched entity
66
- */
67
- entity: Entity<M>;
68
- /**
69
- * Context of the app status
70
- */
71
- context: RebaseCallContext<USER>;
72
- }
73
- /**
74
- * Parameters passed to hooks before an entity is saved
75
- * @group Models
76
- */
77
- export type EntityBeforeSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
78
- entityId?: string | number;
79
- };
80
- /**
81
- * Parameters passed to hooks before an entity is saved
82
- * @group Models
83
- */
84
- export type EntityAfterSaveErrorProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
85
- entityId?: string | number;
86
- };
87
- /**
88
- * Parameters passed to hooks when an entity is saved
89
- * @group Models
90
- */
91
- export interface EntityAfterSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
92
- /**
93
- * Resolved collection of the entity
94
- */
95
- collection: EntityCollection<M>;
96
- /**
97
- * Full path of the CMS where this entity is being saved.
98
- * Might contain unresolved aliases.
99
- */
100
- path: string;
101
- /**
102
- * ID of the entity
103
- */
104
- entityId: string | number;
105
- /**
106
- * Values being saved
107
- */
108
- values: Partial<EntityValues<M>>;
109
- /**
110
- * Previous values
111
- */
112
- previousValues?: Partial<EntityValues<M>>;
113
- /**
114
- * New or existing entity
115
- */
116
- status: EntityStatus;
117
- /**
118
- * Context of the app status
119
- */
120
- context: RebaseCallContext<USER>;
121
- }
122
- /**
123
- * Parameters passed to hooks when an entity is deleted
124
- * @group Models
125
- */
126
- export interface EntityBeforeDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
127
- /**
128
- * collection of the entity being deleted
129
- */
130
- collection: EntityCollection<M>;
131
- /**
132
- * Path of the parent collection
133
- */
134
- path: string;
135
- /**
136
- * Deleted entity id
137
- */
138
- entityId: string | number;
139
- /**
140
- * Deleted entity
141
- */
142
- entity: Entity<M>;
143
- /**
144
- * Context of the app status
145
- */
146
- context: RebaseCallContext<USER>;
147
- }
148
- /**
149
- * Parameters passed to hooks after an entity is deleted
150
- * @group Models
151
- */
152
- export interface EntityAfterDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
153
- /**
154
- * collection of the entity being deleted
155
- */
156
- collection: EntityCollection<M>;
157
- /**
158
- * Path of the parent collection
159
- */
160
- path: string;
161
- /**
162
- * Deleted entity id
163
- */
164
- entityId: string | number;
165
- /**
166
- * Deleted entity
167
- */
168
- entity: Entity<M>;
169
- /**
170
- * Context of the app status
171
- */
172
- context: RebaseCallContext<USER>;
173
- }
@@ -1,7 +0,0 @@
1
- import { Entity } from "./entities";
2
- /**
3
- * @group Models
4
- */
5
- export type EntityLinkBuilder<M extends Record<string, unknown> = Record<string, unknown>> = ({ entity }: {
6
- entity: Entity<M>;
7
- }) => string;
@@ -1,10 +0,0 @@
1
- import type { DataDriver } from "../controllers/data_driver";
2
- import type { StorageSource } from "../controllers/storage";
3
- export type EntityOverrides = {
4
- /**
5
- * Internal driver override for this collection.
6
- * Used by the CMS engine to route data operations.
7
- */
8
- driver?: DataDriver;
9
- storageSource?: StorageSource;
10
- };
@@ -1,87 +0,0 @@
1
- import React from "react";
2
- import type { Entity, EntityValues } from "./entities";
3
- import type { EntityCollection } from "./collections";
4
- import type { FormexController } from "./formex";
5
- import type { ComponentRef } from "./component_ref";
6
- /**
7
- * Context passed to custom fields and entity views.
8
- * @group Form custom fields
9
- */
10
- export interface FormContext<M extends Record<string, unknown> = Record<string, unknown>> {
11
- /**
12
- * Current values of the entity
13
- */
14
- values: M;
15
- /**
16
- * Update the value of a field
17
- */
18
- setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
19
- /**
20
- * Save the entity.
21
- */
22
- save: (values: M) => void;
23
- /**
24
- * Collection of the entity being modified
25
- */
26
- collection?: EntityCollection<M>;
27
- /**
28
- * Entity id, it can be undefined if it's a new entity
29
- */
30
- entityId?: string | number;
31
- /**
32
- * Path this entity is located at
33
- */
34
- path?: string;
35
- status: "new" | "existing" | "copy";
36
- entity?: Entity<M>;
37
- savingError?: Error;
38
- openEntityMode: "side_panel" | "full_screen" | "split" | "dialog";
39
- /**
40
- * The underlying formex controller that powers the form.
41
- */
42
- formex: FormexController<M>;
43
- disabled: boolean;
44
- /**
45
- * Whether the form context is in read-only detail view mode.
46
- * Custom entity views can use this to adjust their rendering.
47
- */
48
- readOnly?: boolean;
49
- }
50
- export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
51
- key: string;
52
- name: string;
53
- icon?: string | React.ReactNode;
54
- tabComponent?: React.ReactNode;
55
- includeActions?: boolean | "bottom";
56
- Builder?: ComponentRef<EntityCustomViewParams<M>>;
57
- position?: "start" | "end";
58
- };
59
- /**
60
- * Configuration to replace the default entity form with a custom component.
61
- * The Builder receives the same props as entity view tabs (entity, formContext, etc.)
62
- * and has full control over the UI.
63
- *
64
- * The form tab still appears in the tab bar but renders your Builder
65
- * instead of the auto-generated field form.
66
- *
67
- * @group Models
68
- */
69
- export type FormViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
70
- /**
71
- * Custom component that replaces the default form.
72
- */
73
- Builder: ComponentRef<EntityCustomViewParams<M>>;
74
- /**
75
- * If true, the save/delete action bar is rendered alongside the custom view.
76
- * Defaults to true.
77
- */
78
- includeActions?: boolean;
79
- };
80
- export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
81
- collection: EntityCollection<M>;
82
- entity?: Entity<M>;
83
- modifiedValues?: EntityValues<M>;
84
- formContext: FormContext<M>;
85
- parentCollectionSlugs?: string[];
86
- parentEntityIds?: string[];
87
- }
@@ -1,21 +0,0 @@
1
- import type { Entity } from "./entities";
2
- import type { User } from "../users";
3
- import type { RebaseContext } from "../rebase_context";
4
- /**
5
- * You can use this configuration to add additional fields to the data
6
- * exports
7
- * @group Models
8
- */
9
- export interface ExportConfig<USER extends User = User> {
10
- additionalFields: ExportMappingFunction<USER>[];
11
- }
12
- /**
13
- * @group Models
14
- */
15
- export interface ExportMappingFunction<USER extends User = User> {
16
- key: string;
17
- builder: ({ entity, context }: {
18
- entity: Entity;
19
- context: RebaseContext<USER>;
20
- }) => Promise<string> | string;
21
- }
@@ -1,40 +0,0 @@
1
- import React, { FormEvent } from "react";
2
- export type FormexController<T = unknown> = {
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 = unknown> = {
36
- values?: T;
37
- submitCount?: number;
38
- errors?: Record<string, string>;
39
- touched?: Record<string, boolean>;
40
- };
@@ -1,28 +0,0 @@
1
- export * from "./entities";
2
- export * from "./chips";
3
- export * from "./properties";
4
- export * from "./collections";
5
- export * from "./relations";
6
- export * from "./locales";
7
- export * from "./entity_link_builder";
8
- export * from "./user_management_delegate";
9
- export * from "./entity_callbacks";
10
- export * from "./entity_overrides";
11
- export * from "./export_import";
12
- export * from "./modify_collections";
13
- export * from "./formex";
14
- export * from "./websockets";
15
- export * from "./backend";
16
- export * from "./translations";
17
- export * from "./plugins";
18
- export * from "./builders";
19
- export * from "./slots";
20
- export * from "./entity_actions";
21
- export * from "./property_config";
22
- export * from "./entity_views";
23
- export * from "./data_source";
24
- export * from "./cron";
25
- export * from "./backend_hooks";
26
- export * from "./component_ref";
27
- export * from "./auth_adapter";
28
- export * from "./database_adapter";
@@ -1,4 +0,0 @@
1
- /**
2
- * @group Models
3
- */
4
- export type Locale = "af" | "ar" | "arDZ" | "arMA" | "arSA" | "az" | "be" | "bg" | "bn" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "enAU" | "enCA" | "enGB" | "enIN" | "enNZ" | "enUS" | "eo" | "es" | "et" | "eu" | "faIR" | "fi" | "fil" | "fr" | "frCA" | "frCH" | "gd" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "kn" | "ko" | "lb" | "lt" | "lv" | "mk" | "ms" | "mt" | "nb" | "nl" | "nlBE" | "nn" | "pl" | "pt" | "ptBR" | "ro" | "ru" | "sk" | "sl" | "sr" | "srLatn" | "sv" | "ta" | "te" | "th" | "tr" | "ug" | "uk" | "uz" | "vi" | "zhCN" | "zhTW";
@@ -1,5 +0,0 @@
1
- import { EntityCollection } from "./collections";
2
- export type ModifyCollectionProps = {
3
- collection: EntityCollection;
4
- parentPaths: string[];
5
- };
@@ -1,282 +0,0 @@
1
- import React, { PropsWithChildren } from "react";
2
- import type { EntityCollection } from "./collections";
3
- import type { EntityStatus } from "./entities";
4
- import type { InferPropertyType, Property } from "./properties";
5
- import type { FormContext } from "./entity_views";
6
- import type { RebaseContext } from "../rebase_context";
7
- import type { NavigationGroupMapping, AppView } from "../controllers/navigation";
8
- import type { UserManagementDelegate } from "./user_management_delegate";
9
- import type { User } from "../users";
10
- import type { SlotContribution } from "./slots";
11
- /**
12
- * Props interface for custom field components.
13
- *
14
- * The `@rebasepro/admin` package re-exports a narrower version of this
15
- * interface that adds `formex` and layout-specific fields. This base
16
- * definition captures the core contract that every field renderer must
17
- * satisfy, regardless of where it is rendered.
18
- *
19
- * @typeParam P - The property type this field is bound to
20
- * @typeParam CustomProps - Extra props injected via the property's `customProps`
21
- * @typeParam M - The entity model type
22
- * @group Form custom fields
23
- */
24
- export interface FieldProps<P extends Property = Property, CustomProps = unknown, M extends Record<string, unknown> = Record<string, unknown>> {
25
- /** Key of the property (e.g. "user.name" for a nested path) */
26
- propertyKey: string;
27
- /** Current value of this field */
28
- value: InferPropertyType<P> | null;
29
- /** Set value of field directly */
30
- setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
31
- /** Set value of a different field directly */
32
- setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
33
- /** Is the form currently submitting */
34
- isSubmitting?: boolean;
35
- /** Should this field show the error indicator */
36
- showError?: boolean;
37
- /** Error message for this field, or undefined if valid */
38
- error?: string;
39
- /** Has this field been touched */
40
- touched?: boolean;
41
- /** Property related to this field */
42
- property: P;
43
- /** Should this field include a description */
44
- includeDescription?: boolean;
45
- /** Flag to indicate that the underlying value has been updated in the driver */
46
- underlyingValueHasChanged?: boolean;
47
- /** Is this field part of an array */
48
- partOfArray?: boolean;
49
- /** Is this field part of a block */
50
- partOfBlock?: boolean;
51
- /** Display the child properties directly, without being wrapped in an extendable panel */
52
- minimalistView?: boolean;
53
- /** Should this field autofocus on mount */
54
- autoFocus?: boolean;
55
- /** Additional properties set by the developer */
56
- customProps?: CustomProps;
57
- /** Additional values related to the state of the form or the entity */
58
- context: FormContext<M>;
59
- /** Flag to indicate if this field should be disabled */
60
- disabled?: boolean;
61
- /** Size of the field */
62
- size?: "small" | "medium" | "large";
63
- /** Callback when internal property state changes (e.g. panel expansion) */
64
- onPropertyChange?: (property: Partial<Property>) => void;
65
- }
66
- /**
67
- * Interface used to define plugins for Rebase.
68
- * Plugins contribute UI via **slots**, wrap subtrees with **providers**,
69
- * and inject behavioral logic via **hooks**.
70
- * @group Core
71
- */
72
- export interface RebasePlugin {
73
- /**
74
- * Unique key identifying this plugin.
75
- */
76
- key: string;
77
- /**
78
- * If true, no CMS content is shown until this plugin finishes loading.
79
- */
80
- loading?: boolean;
81
- /**
82
- * UI slot contributions rendered at the matching extension points.
83
- */
84
- slots?: SlotContribution[];
85
- /**
86
- * HOC providers wrapping root or form content.
87
- * Providers with `scope: "root"` wrap the entire CMS below RebaseContext.
88
- * Providers with `scope: "form"` wrap each entity form/edit view.
89
- */
90
- providers?: PluginProvider[];
91
- /**
92
- * Behavioral hooks (non-UI) — collection modification, search blocking,
93
- * column reordering, navigation entries, etc.
94
- */
95
- hooks?: PluginHooks;
96
- /**
97
- * Field wrapping for custom field rendering (e.g. data enhancement).
98
- */
99
- fieldBuilder?: FieldBuilderConfig;
100
- /**
101
- * Views to be automatically added to the navigation.
102
- */
103
- views?: AppView[];
104
- /**
105
- * User management delegate from this plugin.
106
- */
107
- userManagement?: UserManagementDelegate;
108
- /**
109
- * Optional lifecycle hooks. Called by the Rebase runtime
110
- * at appropriate points in the app lifecycle.
111
- */
112
- lifecycle?: PluginLifecycle;
113
- }
114
- /**
115
- * A HOC provider that wraps a subtree of the CMS.
116
- * @group Plugins
117
- */
118
- export interface PluginProvider {
119
- /**
120
- * `"root"` — wraps the entire CMS below RebaseContext.
121
- * `"form"` — wraps each entity form / edit view.
122
- */
123
- scope: "root" | "form";
124
- /**
125
- * The provider component. Must accept `children`.
126
- * Typed loosely because extra props are passed via the `props` field;
127
- * strict signatures cause contravariance issues.
128
- */
129
- Component: React.ComponentType<PropsWithChildren<Record<string, unknown>>>;
130
- /**
131
- * Additional props passed to the Component.
132
- */
133
- props?: Record<string, unknown>;
134
- }
135
- /**
136
- * Behavioral hooks that a plugin can provide.
137
- * These are non-UI extension points for modifying CMS behavior.
138
- * @group Plugins
139
- */
140
- export interface PluginHooks {
141
- /**
142
- * Modify a single collection before it is rendered (synchronous).
143
- */
144
- modifyCollection?: (collection: EntityCollection) => EntityCollection;
145
- /**
146
- * Async version of modifyCollection — supports fetching remote config.
147
- * Runs during navigation resolution. If provided alongside `modifyCollection`,
148
- * the sync version runs first, then the async version.
149
- */
150
- modifyCollectionAsync?: (collection: EntityCollection) => Promise<EntityCollection>;
151
- /**
152
- * Modify, add or remove collections.
153
- */
154
- injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
155
- /**
156
- * Callback called when columns are reordered via drag and drop.
157
- */
158
- onColumnsReorder?: (props: {
159
- fullPath: string;
160
- parentCollectionSlugs: string[];
161
- parentEntityIds: string[];
162
- collection: EntityCollection;
163
- newPropertiesOrder: string[];
164
- }) => void;
165
- /**
166
- * Callback called when Kanban board columns are reordered.
167
- */
168
- onKanbanColumnsReorder?: (props: {
169
- fullPath: string;
170
- parentCollectionSlugs: string[];
171
- parentEntityIds: string[];
172
- collection: EntityCollection;
173
- kanbanColumnProperty: string;
174
- newColumnsOrder: string[];
175
- }) => void;
176
- /**
177
- * Navigation entries contributed by this plugin.
178
- */
179
- navigationEntries?: NavigationGroupMapping[];
180
- /**
181
- * Callback when navigation entry order changes (e.g. drag-and-drop).
182
- */
183
- onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
184
- /**
185
- * Allow reordering collections in the home page via drag and drop.
186
- */
187
- allowDragAndDrop?: boolean;
188
- }
189
- /**
190
- * Lifecycle hooks for plugins. Called by the Rebase runtime
191
- * at appropriate points in the app lifecycle.
192
- * @group Plugins
193
- */
194
- export interface PluginLifecycle {
195
- /**
196
- * Called once when the plugin is mounted in the Rebase tree.
197
- * Can return a Promise for async initialization.
198
- */
199
- onMount?: (context: RebaseContext) => void | Promise<void>;
200
- /**
201
- * Called when the plugin is unmounted from the Rebase tree.
202
- * Use this for cleanup (subscriptions, timers, etc.).
203
- */
204
- onUnmount?: () => void;
205
- /**
206
- * Called whenever the authentication state changes.
207
- * Receives the new user (or null on sign-out).
208
- */
209
- onAuthStateChange?: (user: User | null) => void;
210
- /**
211
- * Called when a collection's visible entities change.
212
- * Useful for analytics, caching, or cross-plugin coordination.
213
- */
214
- onCollectionChange?: (slug: string, entities: unknown[]) => void;
215
- }
216
- /**
217
- * Configuration for wrapping form field components.
218
- * @group Plugins
219
- */
220
- export interface FieldBuilderConfig {
221
- /**
222
- * Returns a wrapped field component, or null to skip wrapping.
223
- */
224
- wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<Property>> | null;
225
- /**
226
- * Optional guard — return false to skip wrapping for this field.
227
- */
228
- enabled?: (params: PluginFieldBuilderParams) => boolean;
229
- }
230
- /**
231
- * Props passed to home page collection card action components.
232
- * @group Models
233
- */
234
- export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
235
- slug: string;
236
- collection: EC;
237
- context: RebaseContext<USER>;
238
- }
239
- /**
240
- * Props passed to form action components in entity edit/form views.
241
- * @group Models
242
- */
243
- export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
244
- entityId?: string | number;
245
- path: string;
246
- parentCollectionSlugs: string[];
247
- parentEntityIds: string[];
248
- status: EntityStatus;
249
- collection: EC;
250
- disabled: boolean;
251
- formContext?: FormContext;
252
- context: RebaseContext<USER>;
253
- openEntityMode: "side_panel" | "full_screen" | "split" | "dialog";
254
- }
255
- /**
256
- * Parameters passed to the field builder wrap function.
257
- * @group Models
258
- */
259
- export type PluginFieldBuilderParams<M extends Record<string, unknown> = Record<string, unknown>, EC extends EntityCollection<M> = EntityCollection<M>> = {
260
- fieldConfigId: string;
261
- propertyKey: string;
262
- property: Property;
263
- Field: React.ComponentType<FieldProps<Property, unknown, M>>;
264
- plugin: RebasePlugin;
265
- path?: string;
266
- collection?: EC;
267
- };
268
- /**
269
- * Generic props passed to plugin components that just need CMS context.
270
- * @group Models
271
- */
272
- export interface PluginGenericProps<USER extends User = User> {
273
- context: RebaseContext<USER>;
274
- }
275
- /**
276
- * Props for additional card components in the home page.
277
- * @group Models
278
- */
279
- export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
280
- group?: string;
281
- context: RebaseContext<USER>;
282
- }