@rebasepro/server-postgresql 0.5.0 → 0.6.1

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 (169) 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 +10207 -11145
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/{server-postgresql/src/services → services}/EntityPersistService.d.ts +0 -14
  8. package/dist/utils/pg-array-null-patch.d.ts +16 -0
  9. package/dist/utils/pg-error-utils.d.ts +55 -0
  10. package/package.json +24 -21
  11. package/src/PostgresAdapter.ts +9 -10
  12. package/src/PostgresBackendDriver.ts +134 -121
  13. package/src/PostgresBootstrapper.ts +100 -30
  14. package/src/auth/ensure-tables.ts +28 -5
  15. package/src/auth/services.ts +28 -18
  16. package/src/cli.ts +99 -96
  17. package/src/collections/PostgresCollectionRegistry.ts +7 -0
  18. package/src/connection.ts +11 -6
  19. package/src/data-transformer.ts +25 -15
  20. package/src/databasePoolManager.ts +3 -2
  21. package/src/history/HistoryService.ts +3 -2
  22. package/src/history/ensure-history-table.ts +5 -4
  23. package/src/schema/auth-schema.ts +1 -2
  24. package/src/schema/doctor-cli.ts +2 -1
  25. package/src/schema/doctor.ts +40 -37
  26. package/src/schema/generate-drizzle-schema-logic.ts +56 -18
  27. package/src/schema/generate-drizzle-schema.ts +11 -11
  28. package/src/schema/introspect-db-inference.ts +25 -25
  29. package/src/schema/introspect-db-logic.ts +38 -38
  30. package/src/schema/introspect-db.ts +28 -27
  31. package/src/services/BranchService.ts +14 -0
  32. package/src/services/EntityFetchService.ts +28 -25
  33. package/src/services/EntityPersistService.ts +19 -149
  34. package/src/services/RelationService.ts +57 -37
  35. package/src/services/entity-helpers.ts +6 -2
  36. package/src/services/realtimeService.ts +45 -32
  37. package/src/utils/drizzle-conditions.ts +31 -15
  38. package/src/utils/pg-array-null-patch.ts +42 -0
  39. package/src/utils/pg-error-utils.ts +211 -0
  40. package/src/websocket.ts +15 -12
  41. package/test/array-null-safety.test.ts +335 -0
  42. package/test/auth-services.test.ts +36 -19
  43. package/test/batch-many-to-many-regression.test.ts +119 -39
  44. package/test/data-transformer-hardening.test.ts +67 -33
  45. package/test/data-transformer.test.ts +57 -4
  46. package/test/doctor.test.ts +10 -5
  47. package/test/drizzle-conditions.test.ts +59 -6
  48. package/test/generate-drizzle-schema.test.ts +65 -40
  49. package/test/introspect-db-generation.test.ts +179 -81
  50. package/test/introspect-db-utils.test.ts +92 -37
  51. package/test/mocks/chalk.cjs +7 -0
  52. package/test/pg-array-null-patch.test.ts +65 -0
  53. package/test/pg-error-utils.test.ts +221 -0
  54. package/test/postgresDataDriver.test.ts +14 -5
  55. package/test/property-ordering.test.ts +126 -79
  56. package/test/realtimeService.test.ts +6 -2
  57. package/test/relation-pipeline-gaps.test.ts +84 -36
  58. package/test/relations.test.ts +247 -0
  59. package/test/unmapped-tables-safety.test.ts +14 -6
  60. package/test/websocket.test.ts +1 -1
  61. package/tsconfig.json +5 -0
  62. package/tsconfig.prod.json +3 -0
  63. package/vite.config.ts +12 -10
  64. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  65. package/dist/common/src/collections/default-collections.d.ts +0 -9
  66. package/dist/common/src/collections/index.d.ts +0 -2
  67. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  68. package/dist/common/src/data/query_builder.d.ts +0 -55
  69. package/dist/common/src/index.d.ts +0 -4
  70. package/dist/common/src/util/builders.d.ts +0 -57
  71. package/dist/common/src/util/callbacks.d.ts +0 -6
  72. package/dist/common/src/util/collections.d.ts +0 -11
  73. package/dist/common/src/util/common.d.ts +0 -2
  74. package/dist/common/src/util/conditions.d.ts +0 -26
  75. package/dist/common/src/util/entities.d.ts +0 -58
  76. package/dist/common/src/util/enums.d.ts +0 -3
  77. package/dist/common/src/util/index.d.ts +0 -16
  78. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  79. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  80. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  81. package/dist/common/src/util/paths.d.ts +0 -14
  82. package/dist/common/src/util/permissions.d.ts +0 -14
  83. package/dist/common/src/util/references.d.ts +0 -2
  84. package/dist/common/src/util/relations.d.ts +0 -22
  85. package/dist/common/src/util/resolutions.d.ts +0 -72
  86. package/dist/common/src/util/storage.d.ts +0 -24
  87. package/dist/index.umd.js +0 -11749
  88. package/dist/index.umd.js.map +0 -1
  89. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  90. package/dist/types/src/controllers/auth.d.ts +0 -104
  91. package/dist/types/src/controllers/client.d.ts +0 -168
  92. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  93. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  94. package/dist/types/src/controllers/data.d.ts +0 -207
  95. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  96. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  97. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  98. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  99. package/dist/types/src/controllers/email.d.ts +0 -36
  100. package/dist/types/src/controllers/index.d.ts +0 -18
  101. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  102. package/dist/types/src/controllers/navigation.d.ts +0 -225
  103. package/dist/types/src/controllers/registry.d.ts +0 -63
  104. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  105. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  106. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  107. package/dist/types/src/controllers/storage.d.ts +0 -171
  108. package/dist/types/src/index.d.ts +0 -4
  109. package/dist/types/src/rebase_context.d.ts +0 -122
  110. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  111. package/dist/types/src/types/backend.d.ts +0 -571
  112. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  113. package/dist/types/src/types/builders.d.ts +0 -15
  114. package/dist/types/src/types/chips.d.ts +0 -5
  115. package/dist/types/src/types/collections.d.ts +0 -961
  116. package/dist/types/src/types/component_ref.d.ts +0 -47
  117. package/dist/types/src/types/cron.d.ts +0 -102
  118. package/dist/types/src/types/data_source.d.ts +0 -64
  119. package/dist/types/src/types/database_adapter.d.ts +0 -94
  120. package/dist/types/src/types/entities.d.ts +0 -145
  121. package/dist/types/src/types/entity_actions.d.ts +0 -104
  122. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  123. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  124. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  125. package/dist/types/src/types/entity_views.d.ts +0 -87
  126. package/dist/types/src/types/export_import.d.ts +0 -21
  127. package/dist/types/src/types/formex.d.ts +0 -40
  128. package/dist/types/src/types/index.d.ts +0 -28
  129. package/dist/types/src/types/locales.d.ts +0 -4
  130. package/dist/types/src/types/modify_collections.d.ts +0 -5
  131. package/dist/types/src/types/plugins.d.ts +0 -282
  132. package/dist/types/src/types/properties.d.ts +0 -1173
  133. package/dist/types/src/types/property_config.d.ts +0 -74
  134. package/dist/types/src/types/relations.d.ts +0 -336
  135. package/dist/types/src/types/slots.d.ts +0 -262
  136. package/dist/types/src/types/translations.d.ts +0 -900
  137. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  138. package/dist/types/src/types/websockets.d.ts +0 -78
  139. package/dist/types/src/users/index.d.ts +0 -1
  140. package/dist/types/src/users/user.d.ts +0 -50
  141. /package/dist/{server-postgresql/src/auth → auth}/ensure-tables.d.ts +0 -0
  142. /package/dist/{server-postgresql/src/auth → auth}/services.d.ts +0 -0
  143. /package/dist/{server-postgresql/src/cli.d.ts → cli.d.ts} +0 -0
  144. /package/dist/{server-postgresql/src/connection.d.ts → connection.d.ts} +0 -0
  145. /package/dist/{server-postgresql/src/data-transformer.d.ts → data-transformer.d.ts} +0 -0
  146. /package/dist/{server-postgresql/src/databasePoolManager.d.ts → databasePoolManager.d.ts} +0 -0
  147. /package/dist/{server-postgresql/src/history → history}/HistoryService.d.ts +0 -0
  148. /package/dist/{server-postgresql/src/history → history}/ensure-history-table.d.ts +0 -0
  149. /package/dist/{server-postgresql/src/index.d.ts → index.d.ts} +0 -0
  150. /package/dist/{server-postgresql/src/interfaces.d.ts → interfaces.d.ts} +0 -0
  151. /package/dist/{server-postgresql/src/schema → schema}/auth-schema.d.ts +0 -0
  152. /package/dist/{server-postgresql/src/schema → schema}/doctor-cli.d.ts +0 -0
  153. /package/dist/{server-postgresql/src/schema → schema}/doctor.d.ts +0 -0
  154. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema-logic.d.ts +0 -0
  155. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema.d.ts +0 -0
  156. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-inference.d.ts +0 -0
  157. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-logic.d.ts +0 -0
  158. /package/dist/{server-postgresql/src/schema → schema}/introspect-db.d.ts +0 -0
  159. /package/dist/{server-postgresql/src/schema → schema}/test-schema.d.ts +0 -0
  160. /package/dist/{server-postgresql/src/services → services}/BranchService.d.ts +0 -0
  161. /package/dist/{server-postgresql/src/services → services}/EntityFetchService.d.ts +0 -0
  162. /package/dist/{server-postgresql/src/services → services}/RelationService.d.ts +0 -0
  163. /package/dist/{server-postgresql/src/services → services}/entity-helpers.d.ts +0 -0
  164. /package/dist/{server-postgresql/src/services → services}/entityService.d.ts +0 -0
  165. /package/dist/{server-postgresql/src/services → services}/index.d.ts +0 -0
  166. /package/dist/{server-postgresql/src/services → services}/realtimeService.d.ts +0 -0
  167. /package/dist/{server-postgresql/src/types.d.ts → types.d.ts} +0 -0
  168. /package/dist/{server-postgresql/src/utils → utils}/drizzle-conditions.d.ts +0 -0
  169. /package/dist/{server-postgresql/src/websocket.d.ts → websocket.d.ts} +0 -0
@@ -1,218 +0,0 @@
1
- import type { Entity, EntityStatus, EntityValues } from "../types/entities";
2
- import type { EntityCollection, FilterValues } from "../types/collections";
3
- import type { RebaseContext } from "../rebase_context";
4
- /**
5
- * @internal
6
- */
7
- export interface FetchEntityProps<M extends Record<string, unknown> = Record<string, unknown>> {
8
- path: string;
9
- entityId: string | number;
10
- databaseId?: string;
11
- collection?: EntityCollection<M>;
12
- }
13
- /**
14
- * @internal
15
- */
16
- export type ListenEntityProps<M extends Record<string, unknown> = Record<string, unknown>> = FetchEntityProps<M> & {
17
- onUpdate: (entity: Entity<M> | null) => void;
18
- onError?: (error: Error) => void;
19
- };
20
- /**
21
- * Configuration for vector similarity search queries.
22
- * Vector search applies an ORDER BY distance expression and optionally
23
- * filters results by a distance threshold.
24
- */
25
- export interface VectorSearchParams {
26
- /** Property name containing the vector column */
27
- property: string;
28
- /** Query vector to compare against */
29
- vector: number[];
30
- /** Distance function (default: "cosine") */
31
- distance?: "cosine" | "l2" | "inner_product";
32
- /** Only return results within this distance threshold */
33
- threshold?: number;
34
- }
35
- /**
36
- * @internal
37
- */
38
- export interface FetchCollectionProps<M extends Record<string, unknown> = Record<string, unknown>> {
39
- path: string;
40
- collection?: EntityCollection<M>;
41
- filter?: FilterValues<Extract<keyof M, string>>;
42
- limit?: number;
43
- offset?: number;
44
- startAfter?: unknown;
45
- orderBy?: string;
46
- searchString?: string;
47
- order?: "desc" | "asc";
48
- /** Vector similarity search configuration */
49
- vectorSearch?: VectorSearchParams;
50
- }
51
- /**
52
- * @internal
53
- */
54
- export type ListenCollectionProps<M extends Record<string, unknown> = Record<string, unknown>> = FetchCollectionProps<M> & {
55
- onUpdate: (entities: Entity<M>[]) => void;
56
- onError?: (error: Error) => void;
57
- };
58
- /**
59
- * @internal
60
- */
61
- export interface SaveEntityProps<M extends Record<string, unknown> = Record<string, unknown>> {
62
- path: string;
63
- values: Partial<EntityValues<M>>;
64
- entityId?: string | number;
65
- previousValues?: Partial<EntityValues<M>>;
66
- collection?: EntityCollection<M>;
67
- status: EntityStatus;
68
- }
69
- /**
70
- * @internal
71
- */
72
- export interface DeleteEntityProps<M extends Record<string, unknown> = Record<string, unknown>> {
73
- entity: Entity<M>;
74
- collection?: EntityCollection<M>;
75
- }
76
- export type FilterCombinationValidProps = {
77
- path: string;
78
- databaseId?: string;
79
- collection: EntityCollection;
80
- filterValues: FilterValues<string>;
81
- sortBy?: [string, "asc" | "desc"];
82
- };
83
- /**
84
- * Internal driver interface for communicating with the data layer.
85
- * This is NOT the public API — use `RebaseData` / `context.data` instead.
86
- * @internal
87
- */
88
- export interface DataDriver {
89
- /**
90
- * Key that identifies this driver
91
- */
92
- key?: string;
93
- /**
94
- * If the driver has been initialised
95
- */
96
- initialised?: boolean;
97
- /**
98
- * Fetch data from a collection
99
- * @param props
100
- * @return Promise of entities
101
- */
102
- fetchCollection<M extends Record<string, unknown> = Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
103
- /**
104
- * Listen to a collection in a given path. If you don't implement this method
105
- * `fetchCollection` will be used instead, with no real time updates.
106
- * @param props
107
- * @return Function to cancel subscription
108
- */
109
- listenCollection?<M extends Record<string, unknown> = Record<string, unknown>>(props: ListenCollectionProps<M>): () => void;
110
- /**
111
- * Retrieve an entity given a path and a collection
112
- * @param props
113
- */
114
- fetchEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
115
- /**
116
- * Get realtime updates on one entity.
117
- * @param props
118
- * @return Function to cancel subscription
119
- */
120
- listenEntity?<M extends Record<string, unknown> = Record<string, unknown>>(props: ListenEntityProps<M>): () => void;
121
- /**
122
- * Save entity to the specified path
123
- * @param props
124
- */
125
- saveEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: SaveEntityProps<M>): Promise<Entity<M>>;
126
- /**
127
- * Delete an entity
128
- * @param props
129
- * @return was the whole deletion flow successful
130
- */
131
- deleteEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: DeleteEntityProps<M>): Promise<void>;
132
- /**
133
- * Delete all entities from a collection.
134
- * @param path Collection path
135
- */
136
- deleteAll?(path: string): Promise<void>;
137
- /**
138
- * Check if the given property is unique in the given collection
139
- * @param path Collection path
140
- * @param name of the property
141
- * @param value
142
- * @param entityId
143
- * @param collection
144
- * @return `true` if there are no other fields besides the given entity
145
- */
146
- checkUniqueField(path: string, name: string, value: unknown, entityId?: string | number, collection?: EntityCollection): Promise<boolean>;
147
- /**
148
- * Count the number of entities in a collection
149
- */
150
- countEntities?<M extends Record<string, unknown> = Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<number>;
151
- /**
152
- * Check if the given filter combination is valid
153
- * @param props
154
- */
155
- isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection"> & {
156
- databaseId?: string;
157
- }): boolean;
158
- /**
159
- * Get the object to generate the current time in the driver
160
- */
161
- currentTime?: () => unknown;
162
- delegateToCMSModel?: (data: unknown) => unknown;
163
- cmsToDelegateModel?: (data: unknown) => unknown;
164
- initTextSearch?: (props: {
165
- context: RebaseContext;
166
- path: string;
167
- databaseId?: string;
168
- collection: EntityCollection;
169
- parentCollectionSlugs?: string[];
170
- parentEntityIds?: string[];
171
- }) => Promise<boolean>;
172
- /**
173
- * Flag to indicate if the driver has requested the initialization of the text search index
174
- */
175
- needsInitTextSearch?: boolean;
176
- /**
177
- * Optional REST-optimised fetch service. When present, the REST API
178
- * generator uses these methods instead of the generic `fetchEntity` /
179
- * `fetchCollection` pipeline, enabling include-aware eager-loading.
180
- */
181
- restFetchService?: RestFetchService;
182
- /**
183
- * Return the admin capabilities of this driver.
184
- * @see SQLAdmin
185
- * @see DocumentAdmin
186
- * @see SchemaAdmin
187
- */
188
- admin?: import("../types/backend").DatabaseAdmin;
189
- }
190
- /**
191
- * REST-optimised fetch service exposed by drivers that support
192
- * eager-loading of relations via `include`.
193
- *
194
- * The methods return flattened rows (`{ id, ...columns }`) rather
195
- * than the `Entity<M>` wrapper used by the generic DataDriver API.
196
- *
197
- * @group DataDriver
198
- */
199
- export interface RestFetchService {
200
- /**
201
- * Fetch a collection of flattened entities with optional relation includes.
202
- */
203
- fetchCollectionForRest(collectionPath: string, options?: {
204
- filter?: FilterValues<string>;
205
- orderBy?: string;
206
- order?: "desc" | "asc";
207
- limit?: number;
208
- offset?: number;
209
- startAfter?: Record<string, unknown>;
210
- searchString?: string;
211
- databaseId?: string;
212
- vectorSearch?: VectorSearchParams;
213
- }, include?: string[]): Promise<Record<string, unknown>[]>;
214
- /**
215
- * Fetch a single flattened entity with optional relation includes.
216
- */
217
- fetchEntityForRest(collectionPath: string, entityId: string | number, include?: string[], databaseId?: string): Promise<Record<string, unknown> | null>;
218
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * @module database_admin
3
- *
4
- * Re-exports the capability-specific admin interfaces from `@rebasepro/types/backend`.
5
- * This file is kept for backwards compatibility — new code should import from
6
- * `@rebasepro/types` directly.
7
- *
8
- * @group Admin
9
- */
10
- export type { SQLAdmin, DocumentAdmin, SchemaAdmin, DatabaseAdmin, HealthCheckResult } from "../types/backend";
11
- export { isSQLAdmin, isDocumentAdmin, isSchemaAdmin } from "../types/backend";
@@ -1,36 +0,0 @@
1
- import React from "react";
2
- /**
3
- * Controller to open the side dialog
4
- * @group Hooks and utilities
5
- */
6
- export interface DialogsController {
7
- /**
8
- * Close the last dialog
9
- */
10
- close: () => void;
11
- /**
12
- * Open a dialog
13
- * @param props
14
- */
15
- open: <T extends object = object>(props: DialogControllerEntryProps<T>) => {
16
- closeDialog: () => void;
17
- };
18
- }
19
- /**
20
- * Props used to open a side dialog
21
- * @group Hooks and utilities
22
- */
23
- export interface DialogControllerEntryProps<T extends object = object> {
24
- key: string;
25
- /**
26
- * The component type that will be rendered
27
- */
28
- Component: React.ComponentType<{
29
- open: boolean;
30
- closeDialog: () => void;
31
- } & T>;
32
- /**
33
- * Props to pass to the dialog component
34
- */
35
- props?: T;
36
- }
@@ -1,4 +0,0 @@
1
- export interface EffectiveRoleController {
2
- effectiveRole: string | null;
3
- setEffectiveRole: (role: string | null) => void;
4
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Email service types — portable interface shared by RebaseClient and server-core.
3
- *
4
- * The concrete SMTP implementation lives in `@rebasepro/server-core/email`.
5
- * This file provides only the consumer-facing contract so that it can be
6
- * referenced from `RebaseClient` without dragging in nodemailer.
7
- */
8
- /**
9
- * Options for sending an email via the Rebase email service.
10
- */
11
- export interface EmailSendOptions {
12
- /** Recipient email address(es). */
13
- to: string | string[];
14
- /** Email subject line. */
15
- subject: string;
16
- /** HTML body content. */
17
- html: string;
18
- /** Optional plain-text fallback. */
19
- text?: string;
20
- /** Optional reply-to address. */
21
- replyTo?: string;
22
- }
23
- /**
24
- * Abstraction over an email delivery backend.
25
- *
26
- * Implementations may use SMTP, AWS SES, Resend, Postmark, or any other
27
- * provider — consumers only interact through this interface.
28
- */
29
- export interface EmailService {
30
- /** Send a single email. */
31
- send(options: EmailSendOptions): Promise<void>;
32
- /** Returns `true` when the service has valid credentials / is ready to send. */
33
- isConfigured(): boolean;
34
- /** Verify connection/credentials with the email provider. */
35
- verifyConnection?(): Promise<boolean>;
36
- }
@@ -1,18 +0,0 @@
1
- export * from "./collection_registry";
2
- export * from "./analytics_controller";
3
- export * from "./auth";
4
- export * from "./data";
5
- export * from "./database_admin";
6
- export * from "./data_driver";
7
- export * from "./local_config_persistence";
8
- export * from "./navigation";
9
- export * from "./effective_role";
10
- export * from "./storage";
11
- export * from "./email";
12
- export * from "./client";
13
- export * from "./customization_controller";
14
- export * from "./side_entity_controller";
15
- export * from "./side_dialogs_controller";
16
- export * from "./dialogs_controller";
17
- export * from "./snackbar";
18
- export * from "./registry";
@@ -1,20 +0,0 @@
1
- import type { EntityCollection } from "../types/collections";
2
- /**
3
- * @group Models
4
- */
5
- export type PartialEntityCollection<M extends Record<string, unknown> = Record<string, unknown>> = Partial<EntityCollection<M>>;
6
- /**
7
- * This interface is in charge of defining the controller that persists
8
- * modifications to a collection or collection, and retrieves them back from
9
- * a data source, such as local storage or Firestore.
10
- */
11
- export interface UserConfigurationPersistence {
12
- onCollectionModified: <M extends Record<string, unknown> = Record<string, unknown>>(path: string, partialCollection: PartialEntityCollection<M>) => void;
13
- getCollectionConfig: <M extends Record<string, unknown> = Record<string, unknown>>(path: string) => PartialEntityCollection<M>;
14
- recentlyVisitedPaths: string[];
15
- setRecentlyVisitedPaths: (paths: string[]) => void;
16
- favouritePaths: string[];
17
- setFavouritePaths: (paths: string[]) => void;
18
- collapsedGroups: string[];
19
- setCollapsedGroups: (paths: string[]) => void;
20
- }
@@ -1,225 +0,0 @@
1
- import React from "react";
2
- import type { EntityCollection } from "../types/collections";
3
- import type { RebasePlugin } from "../types/plugins";
4
- /**
5
- * Controller that handles URL path building and resolution.
6
- * @group Models
7
- */
8
- export type UrlController = {
9
- /**
10
- * Default path under the navigation routes of the CMS will be created.
11
- * Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
12
- */
13
- basePath: string;
14
- /**
15
- * Default path under the collection routes of the CMS will be created.
16
- * It defaults to '/c'
17
- */
18
- baseCollectionPath: string;
19
- /**
20
- * Convert a URL path to a collection or entity path
21
- * `/c/products` => `products`
22
- * `/my_cms/c/products/B34SAP8Z` => `products/B34SAP8Z`
23
- * `/my_cms/my_view` => `my_view`
24
- * @param cmsPath
25
- */
26
- urlPathToDataPath: (cmsPath: string) => string;
27
- /**
28
- * Base url path for the home screen
29
- */
30
- homeUrl: string;
31
- /**
32
- * Check if a url path belongs to a collection
33
- * @param path
34
- */
35
- isUrlCollectionPath: (urlPath: string) => boolean;
36
- /**
37
- * Build a URL collection path from a data path
38
- * `products` => `/c/products`
39
- * `products/B34SAP8Z` => `/c/products/B34SAP8Z`
40
- * @param path
41
- */
42
- buildUrlCollectionPath: (path: string) => string;
43
- /**
44
- * Build a URL path for the CMS (e.g. for custom views)
45
- * @param path
46
- */
47
- buildAppUrlPath: (path: string) => string;
48
- /**
49
- * Turn a path with collection ids into a resolved path.
50
- * The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
51
- * @param path
52
- */
53
- resolveDatabasePathsFrom: (path: string) => string;
54
- /**
55
- * A function to navigate to a specified route or URL.
56
- *
57
- * @param {string} to - The target route or URL to navigate to.
58
- * @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
59
- */
60
- navigate: (to: string, options?: NavigateOptions) => void;
61
- };
62
- /**
63
- * Controller that manages the state of the navigation menu,
64
- * including resolved views and top-level grouping.
65
- * @group Models
66
- */
67
- export type NavigationStateController = {
68
- /**
69
- * Custom additional views created by the developer, added to the main
70
- * navigation
71
- */
72
- views?: AppView[];
73
- /**
74
- * Custom additional views created by the developer, added to the admin
75
- * navigation
76
- */
77
- adminViews?: AppView[];
78
- /**
79
- * Configuration for the views that should be displayed at the top
80
- * level of the navigation (e.g. in the home page or the navigation
81
- * drawer)
82
- */
83
- topLevelNavigation?: NavigationResult;
84
- /**
85
- * Is the navigation loading (the configuration persistence has not
86
- * loaded yet, or a specified navigation builder has not completed)
87
- */
88
- loading: boolean;
89
- /**
90
- * Was there an error while loading the navigation data
91
- */
92
- navigationLoadingError?: unknown;
93
- /**
94
- * Call this method to recalculate the navigation
95
- */
96
- refreshNavigation: () => void;
97
- /**
98
- * Plugin system allowing to extend the CMS functionality.
99
- */
100
- plugins?: RebasePlugin[];
101
- };
102
- export interface NavigateOptions {
103
- replace?: boolean;
104
- state?: unknown;
105
- preventScrollReset?: boolean;
106
- relative?: "route" | "path";
107
- flushSync?: boolean;
108
- viewTransition?: boolean;
109
- }
110
- export type NavigationBlocker = {
111
- updateBlockListener: (path: string, block: boolean, basePath?: string) => () => void;
112
- isBlocked: (path: string) => boolean;
113
- proceed?: () => void;
114
- reset?: () => void;
115
- };
116
- /**
117
- * Custom additional views created by the developer, added to the main
118
- * navigation.
119
- * @group Models
120
- */
121
- export interface AppView {
122
- /**
123
- * CMS Path you can reach this view from.
124
- */
125
- slug: string;
126
- /**
127
- * Name of this view
128
- */
129
- name: string;
130
- /**
131
- * Optional description of this view. You can use Markdown
132
- */
133
- description?: string;
134
- /**
135
- * Icon key to use in this view.
136
- * You can use any of the icons in the Lucide specs:
137
- * https://lucide.dev/icons/
138
- * e.g. 'ShoppingCart' or 'User'
139
- * Find all the icons in https://rebase.pro/docs/icons
140
- */
141
- icon?: string | React.ReactNode;
142
- /**
143
- * Should this view be hidden from the main navigation panel.
144
- * It will still be accessible if you reach the specified path
145
- */
146
- hideFromNavigation?: boolean;
147
- /**
148
- * Navigation group for this view.
149
- * Views sharing the same group name will be visually grouped
150
- * together in the drawer and home page. If not set, the view
151
- * falls into the default "Views" group.
152
- */
153
- group?: string;
154
- /**
155
- * Component to be rendered. This can be any React component, and can use
156
- * any of the provided hooks
157
- */
158
- view: React.ReactNode;
159
- /**
160
- * If true, a wildcard route (slug/*) is automatically registered
161
- * alongside the base route, enabling nested navigation within this view.
162
- */
163
- nestedRoutes?: boolean;
164
- }
165
- /**
166
- * A composable section that can be rendered on the home page.
167
- * Use this to add custom content alongside the auto-generated
168
- * navigation groups.
169
- * @group Models
170
- */
171
- export interface HomePageSection {
172
- /**
173
- * Unique key for this section.
174
- */
175
- key: string;
176
- /**
177
- * Title displayed as the section header.
178
- */
179
- title: string;
180
- /**
181
- * Arbitrary React content rendered inside the section.
182
- */
183
- children: React.ReactNode;
184
- }
185
- /**
186
- * Used to group navigation entries in the main navigation.
187
- */
188
- export interface NavigationGroupMapping {
189
- /**
190
- * Name of the group, used to display the group header in the UI
191
- */
192
- name: string;
193
- /**
194
- * List of collection ids or view paths that belong to this group.
195
- */
196
- entries: string[];
197
- /**
198
- * Configure which groups start collapsed.
199
- * Set to `true` to collapse in both drawer and home page,
200
- * or use an object to control each independently.
201
- *
202
- * @defaultValue false (expanded)
203
- */
204
- collapsedByDefault?: boolean | {
205
- drawer?: boolean;
206
- home?: boolean;
207
- };
208
- }
209
- export interface NavigationEntry {
210
- id: string;
211
- url: string;
212
- name: string;
213
- slug: string;
214
- type: "collection" | "view" | "admin";
215
- collection?: EntityCollection;
216
- view?: AppView;
217
- description?: string;
218
- group: string;
219
- }
220
- export type NavigationResult = {
221
- allowDragAndDrop: boolean;
222
- navigationEntries: NavigationEntry[];
223
- groups: string[];
224
- onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
225
- };
@@ -1,63 +0,0 @@
1
- import { ReactNode } from "react";
2
- import type { EntityCollection } from "../types/collections";
3
- import type { EntityCollectionsBuilder } from "../types/builders";
4
- import type { EntityCustomView } from "../types/entity_views";
5
- import type { EntityAction } from "../types/entity_actions";
6
- import type { AppView, NavigationGroupMapping } from "./navigation";
7
- import type { RebasePlugin } from "../types/plugins";
8
- /**
9
- * Options to enable the built-in collection editor.
10
- * When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
11
- */
12
- export interface CollectionEditorOptions {
13
- /**
14
- * Function that returns an auth token for schema-editor API calls.
15
- * Falls back to `authController.getAuthToken` when omitted.
16
- */
17
- getAuthToken?: () => Promise<string | null>;
18
- /** Mark the editor as read-only (disable mutations). */
19
- readOnly?: boolean;
20
- /** Suggested base paths shown when creating new collections. */
21
- pathSuggestions?: string[];
22
- }
23
- export interface RebaseCMSConfig<EC extends EntityCollection = EntityCollection> {
24
- collections?: EC[] | EntityCollectionsBuilder<EC>;
25
- homePage?: ReactNode;
26
- entityViews?: EntityCustomView[];
27
- entityActions?: EntityAction[];
28
- plugins?: RebasePlugin[];
29
- /**
30
- * Centralized configuration for how collections and views are grouped
31
- * in the navigation sidebar and home page.
32
- * Each mapping defines a named group and the collection/view slugs
33
- * that belong to it. The array order determines group display order.
34
- * Entry order within each group determines card order.
35
- */
36
- navigationGroupMappings?: NavigationGroupMapping[];
37
- /**
38
- * Enable the built-in visual collection/schema editor.
39
- * Pass `true` for zero-config, or an options object for fine-grained control.
40
- * When enabled, the editor slots, provider, and Studio schema view
41
- * are all auto-wired — no plugin or manual view injection needed.
42
- */
43
- collectionEditor?: boolean | CollectionEditorOptions;
44
- }
45
- export interface RebaseStudioConfig {
46
- tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron" | "schema-visualizer" | "branches" | "api" | "logs")[];
47
- homePage?: ReactNode;
48
- devViews?: AppView[];
49
- }
50
- export interface RebaseAuthConfig {
51
- loginView?: ReactNode;
52
- }
53
- export interface RebaseRegistryController {
54
- cmsConfig: RebaseCMSConfig | null;
55
- studioConfig: RebaseStudioConfig | null;
56
- authConfig: RebaseAuthConfig | null;
57
- registerCMS: (config: RebaseCMSConfig) => void;
58
- unregisterCMS: () => void;
59
- registerStudio: (config: RebaseStudioConfig) => void;
60
- unregisterStudio: () => void;
61
- registerAuth: (config: RebaseAuthConfig) => void;
62
- unregisterAuth: () => void;
63
- }