@rebasepro/server-postgresql 0.4.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 (168) hide show
  1. package/README.md +69 -89
  2. package/dist/{server-postgresql/src/PostgresAdapter.d.ts → PostgresAdapter.d.ts} +1 -1
  3. package/dist/{server-postgresql/src/PostgresBackendDriver.d.ts → PostgresBackendDriver.d.ts} +2 -2
  4. package/dist/{server-postgresql/src/PostgresBootstrapper.d.ts → PostgresBootstrapper.d.ts} +11 -1
  5. package/dist/{server-postgresql/src/auth → auth}/services.d.ts +11 -11
  6. package/dist/{server-postgresql/src/collections → collections}/PostgresCollectionRegistry.d.ts +4 -0
  7. package/dist/{server-postgresql/src/data-transformer.d.ts → data-transformer.d.ts} +0 -3
  8. package/dist/{server-postgresql/src/databasePoolManager.d.ts → databasePoolManager.d.ts} +1 -1
  9. package/dist/index.es.js +10174 -11184
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +10735 -11462
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/{server-postgresql/src/services → services}/EntityPersistService.d.ts +0 -14
  14. package/dist/types.d.ts +3 -0
  15. package/dist/utils/pg-error-utils.d.ts +55 -0
  16. package/dist/{server-postgresql/src/websocket.d.ts → websocket.d.ts} +8 -3
  17. package/package.json +24 -21
  18. package/src/PostgresAdapter.ts +9 -10
  19. package/src/PostgresBackendDriver.ts +135 -122
  20. package/src/PostgresBootstrapper.ts +90 -16
  21. package/src/auth/ensure-tables.ts +28 -5
  22. package/src/auth/services.ts +56 -45
  23. package/src/cli.ts +140 -110
  24. package/src/collections/PostgresCollectionRegistry.ts +7 -0
  25. package/src/connection.ts +11 -6
  26. package/src/data-transformer.ts +73 -109
  27. package/src/databasePoolManager.ts +5 -3
  28. package/src/history/HistoryService.ts +3 -2
  29. package/src/history/ensure-history-table.ts +5 -4
  30. package/src/schema/auth-schema.ts +1 -2
  31. package/src/schema/doctor-cli.ts +2 -1
  32. package/src/schema/doctor.ts +40 -37
  33. package/src/schema/generate-drizzle-schema-logic.ts +56 -18
  34. package/src/schema/generate-drizzle-schema.ts +11 -11
  35. package/src/schema/introspect-db-inference.ts +25 -25
  36. package/src/schema/introspect-db-logic.ts +38 -38
  37. package/src/schema/introspect-db.ts +28 -27
  38. package/src/services/BranchService.ts +14 -0
  39. package/src/services/EntityFetchService.ts +28 -25
  40. package/src/services/EntityPersistService.ts +11 -124
  41. package/src/services/RelationService.ts +57 -37
  42. package/src/services/entity-helpers.ts +6 -2
  43. package/src/services/realtimeService.ts +45 -32
  44. package/src/types.ts +4 -0
  45. package/src/utils/drizzle-conditions.ts +31 -15
  46. package/src/utils/pg-error-utils.ts +211 -0
  47. package/src/websocket.ts +51 -33
  48. package/test/auth-services.test.ts +36 -19
  49. package/test/batch-many-to-many-regression.test.ts +119 -39
  50. package/test/data-transformer-hardening.test.ts +67 -33
  51. package/test/data-transformer.test.ts +4 -2
  52. package/test/doctor.test.ts +10 -5
  53. package/test/drizzle-conditions.test.ts +59 -6
  54. package/test/generate-drizzle-schema.test.ts +65 -40
  55. package/test/introspect-db-generation.test.ts +179 -81
  56. package/test/introspect-db-utils.test.ts +92 -37
  57. package/test/mocks/chalk.cjs +7 -0
  58. package/test/pg-error-utils.test.ts +221 -0
  59. package/test/postgresDataDriver.test.ts +14 -5
  60. package/test/property-ordering.test.ts +126 -79
  61. package/test/realtimeService.test.ts +6 -2
  62. package/test/relation-pipeline-gaps.test.ts +84 -36
  63. package/test/relations.test.ts +247 -0
  64. package/test/unmapped-tables-safety.test.ts +14 -6
  65. package/test/websocket.test.ts +1 -1
  66. package/tsconfig.json +5 -0
  67. package/tsconfig.prod.json +3 -0
  68. package/vite.config.ts +5 -5
  69. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  70. package/dist/common/src/collections/default-collections.d.ts +0 -9
  71. package/dist/common/src/collections/index.d.ts +0 -2
  72. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  73. package/dist/common/src/data/query_builder.d.ts +0 -55
  74. package/dist/common/src/index.d.ts +0 -4
  75. package/dist/common/src/util/builders.d.ts +0 -57
  76. package/dist/common/src/util/callbacks.d.ts +0 -6
  77. package/dist/common/src/util/collections.d.ts +0 -11
  78. package/dist/common/src/util/common.d.ts +0 -2
  79. package/dist/common/src/util/conditions.d.ts +0 -26
  80. package/dist/common/src/util/entities.d.ts +0 -58
  81. package/dist/common/src/util/enums.d.ts +0 -3
  82. package/dist/common/src/util/index.d.ts +0 -16
  83. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  84. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  85. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  86. package/dist/common/src/util/paths.d.ts +0 -14
  87. package/dist/common/src/util/permissions.d.ts +0 -6
  88. package/dist/common/src/util/references.d.ts +0 -2
  89. package/dist/common/src/util/relations.d.ts +0 -22
  90. package/dist/common/src/util/resolutions.d.ts +0 -72
  91. package/dist/common/src/util/storage.d.ts +0 -24
  92. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  93. package/dist/types/src/controllers/auth.d.ts +0 -104
  94. package/dist/types/src/controllers/client.d.ts +0 -168
  95. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  96. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  97. package/dist/types/src/controllers/data.d.ts +0 -207
  98. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  99. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  100. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  101. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  102. package/dist/types/src/controllers/email.d.ts +0 -36
  103. package/dist/types/src/controllers/index.d.ts +0 -18
  104. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  105. package/dist/types/src/controllers/navigation.d.ts +0 -225
  106. package/dist/types/src/controllers/registry.d.ts +0 -63
  107. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  108. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  109. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  110. package/dist/types/src/controllers/storage.d.ts +0 -171
  111. package/dist/types/src/index.d.ts +0 -4
  112. package/dist/types/src/rebase_context.d.ts +0 -122
  113. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  114. package/dist/types/src/types/backend.d.ts +0 -536
  115. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  116. package/dist/types/src/types/builders.d.ts +0 -15
  117. package/dist/types/src/types/chips.d.ts +0 -5
  118. package/dist/types/src/types/collections.d.ts +0 -941
  119. package/dist/types/src/types/component_ref.d.ts +0 -47
  120. package/dist/types/src/types/cron.d.ts +0 -102
  121. package/dist/types/src/types/data_source.d.ts +0 -64
  122. package/dist/types/src/types/database_adapter.d.ts +0 -94
  123. package/dist/types/src/types/entities.d.ts +0 -145
  124. package/dist/types/src/types/entity_actions.d.ts +0 -104
  125. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  126. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  127. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  128. package/dist/types/src/types/entity_views.d.ts +0 -87
  129. package/dist/types/src/types/export_import.d.ts +0 -21
  130. package/dist/types/src/types/formex.d.ts +0 -40
  131. package/dist/types/src/types/index.d.ts +0 -28
  132. package/dist/types/src/types/locales.d.ts +0 -4
  133. package/dist/types/src/types/modify_collections.d.ts +0 -5
  134. package/dist/types/src/types/plugins.d.ts +0 -282
  135. package/dist/types/src/types/properties.d.ts +0 -1181
  136. package/dist/types/src/types/property_config.d.ts +0 -74
  137. package/dist/types/src/types/relations.d.ts +0 -336
  138. package/dist/types/src/types/slots.d.ts +0 -262
  139. package/dist/types/src/types/translations.d.ts +0 -900
  140. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  141. package/dist/types/src/types/websockets.d.ts +0 -78
  142. package/dist/types/src/users/index.d.ts +0 -1
  143. package/dist/types/src/users/user.d.ts +0 -50
  144. package/drizzle.test.config.ts +0 -10
  145. /package/dist/{server-postgresql/src/auth → auth}/ensure-tables.d.ts +0 -0
  146. /package/dist/{server-postgresql/src/cli.d.ts → cli.d.ts} +0 -0
  147. /package/dist/{server-postgresql/src/connection.d.ts → connection.d.ts} +0 -0
  148. /package/dist/{server-postgresql/src/history → history}/HistoryService.d.ts +0 -0
  149. /package/dist/{server-postgresql/src/history → history}/ensure-history-table.d.ts +0 -0
  150. /package/dist/{server-postgresql/src/index.d.ts → index.d.ts} +0 -0
  151. /package/dist/{server-postgresql/src/interfaces.d.ts → interfaces.d.ts} +0 -0
  152. /package/dist/{server-postgresql/src/schema → schema}/auth-schema.d.ts +0 -0
  153. /package/dist/{server-postgresql/src/schema → schema}/doctor-cli.d.ts +0 -0
  154. /package/dist/{server-postgresql/src/schema → schema}/doctor.d.ts +0 -0
  155. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema-logic.d.ts +0 -0
  156. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema.d.ts +0 -0
  157. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-inference.d.ts +0 -0
  158. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-logic.d.ts +0 -0
  159. /package/dist/{server-postgresql/src/schema → schema}/introspect-db.d.ts +0 -0
  160. /package/dist/{server-postgresql/src/schema → schema}/test-schema.d.ts +0 -0
  161. /package/dist/{server-postgresql/src/services → services}/BranchService.d.ts +0 -0
  162. /package/dist/{server-postgresql/src/services → services}/EntityFetchService.d.ts +0 -0
  163. /package/dist/{server-postgresql/src/services → services}/RelationService.d.ts +0 -0
  164. /package/dist/{server-postgresql/src/services → services}/entity-helpers.d.ts +0 -0
  165. /package/dist/{server-postgresql/src/services → services}/entityService.d.ts +0 -0
  166. /package/dist/{server-postgresql/src/services → services}/index.d.ts +0 -0
  167. /package/dist/{server-postgresql/src/services → services}/realtimeService.d.ts +0 -0
  168. /package/dist/{server-postgresql/src/utils → utils}/drizzle-conditions.d.ts +0 -0
@@ -1,60 +0,0 @@
1
- import React from "react";
2
- import type { EntityLinkBuilder } from "../types/entity_link_builder";
3
- import type { Locale } from "../types/locales";
4
- import type { EntityAction } from "../types/entity_actions";
5
- import type { EntityCustomView } from "../types/entity_views";
6
- import type { RebasePlugin } from "../types/plugins";
7
- import type { PropertyConfig } from "../types/property_config";
8
- import type { SlotContribution } from "../types/slots";
9
- export type CustomizationController = {
10
- /**
11
- * Builder for generating utility links for entities
12
- */
13
- entityLinkBuilder?: EntityLinkBuilder;
14
- /**
15
- * Use plugins to modify the behaviour of the CMS.
16
- */
17
- plugins?: RebasePlugin[];
18
- /**
19
- * Pre-merged slots from plugins + direct slot contributions.
20
- */
21
- resolvedSlots: SlotContribution[];
22
- /**
23
- * List of additional custom views for entities.
24
- * You can use the key to reference the custom view in
25
- * the `entityViews` prop of a collection.
26
- *
27
- * You can also define an entity view from the UI.
28
- */
29
- entityViews?: EntityCustomView[];
30
- /**
31
- * List of actions that can be performed on entities.
32
- * These actions are displayed in the entity view and in the collection view.
33
- * You can later reuse these actions in the `entityActions` prop of a collection,
34
- * by specifying the `key` of the action.
35
- */
36
- entityActions?: EntityAction[];
37
- /**
38
- * Format of the dates in the CMS.
39
- * Defaults to 'MMMM dd, yyyy, HH:mm:ss'
40
- */
41
- dateTimeFormat?: string;
42
- /**
43
- * Locale of the CMS, currently only affecting dates
44
- */
45
- locale?: Locale;
46
- /**
47
- * Record of custom form fields to be used in the CMS.
48
- * You can use the key to reference the custom field in
49
- * the `propertyConfig` prop of a property in a collection.
50
- */
51
- propertyConfigs: Record<string, PropertyConfig>;
52
- components?: {
53
- /**
54
- * Component to render when a reference is missing
55
- */
56
- missingReference?: React.ComponentType<{
57
- path: string;
58
- }>;
59
- };
60
- };
@@ -1,207 +0,0 @@
1
- import { Entity, EntityValues } from "../types/entities";
2
- /**
3
- * Parameters for querying a collection.
4
- * Uses PostgREST-style filter syntax for consistency between
5
- * the SDK (HTTP) and framework (in-process) contexts.
6
- *
7
- * @group Data
8
- */
9
- /**
10
- * A where-clause value for a single field.
11
- *
12
- * Supports three syntaxes:
13
- * 1. **Equality shorthand**: raw JS values — `null`, `"active"`, `42`, `true`
14
- * 2. **Tuple syntax**: `[operator, value]` — `[">", 18]`, `["in", ["a","b"]]`
15
- * 3. **PostgREST string**: `"eq.published"`, `"gte.18"`, `"in.(a,b)"`
16
- *
17
- * @group Data
18
- */
19
- export type WhereFieldValue = string | number | boolean | null | [WhereFilterOpShort, any] | [WhereFilterOpShort, any][];
20
- export type WhereValue<T> = T | T[] | null;
21
- export interface LogicalCondition {
22
- type: "and" | "or";
23
- conditions: (FilterCondition | LogicalCondition)[];
24
- }
25
- export interface FilterCondition {
26
- column: string;
27
- operator: FilterOperator;
28
- value: unknown;
29
- }
30
- /** Short operator strings accepted in the tuple syntax. */
31
- export type WhereFilterOpShort = "==" | "!=" | ">" | ">=" | "<" | "<=" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "not-in" | "array-contains" | "array-contains-any" | "cs" | "csa";
32
- export interface FindParams {
33
- /** Maximum number of items to return (default: 20) */
34
- limit?: number;
35
- /** Number of items to skip */
36
- offset?: number;
37
- /** Page number (1-indexed), alternative to offset */
38
- page?: number;
39
- /**
40
- * Filter object. Supports multiple syntaxes per field:
41
- *
42
- * **Equality shorthand** — raw JS values (null, string, number, boolean):
43
- * ```ts
44
- * { company_profile_id: null }
45
- * { status: "active" }
46
- * { age: 18 }
47
- * ```
48
- *
49
- * **Tuple syntax** — `[operator, value]`:
50
- * ```ts
51
- * { age: [">=", 18] }
52
- * { role: ["in", ["admin", "editor"]] }
53
- * { deleted_at: ["!=", null] }
54
- * ```
55
- *
56
- * **PostgREST string syntax** (original format):
57
- * ```ts
58
- * { status: "eq.published" }
59
- * { age: "gte.18" }
60
- * { role: "in.(admin,editor)" }
61
- * ```
62
- */
63
- where?: Record<string, WhereFieldValue>;
64
- /** Logical grouping conditions (AND/OR) */
65
- logical?: LogicalCondition;
66
- /**
67
- * Sort order. Format: "field:direction".
68
- * @example "created_at:desc", "name:asc"
69
- */
70
- orderBy?: string;
71
- /** Relations to include in the response */
72
- include?: string[];
73
- /** Full-text search string */
74
- searchString?: string;
75
- }
76
- /**
77
- * Paginated response from a collection query.
78
- * @group Data
79
- */
80
- export interface FindResponse<M extends Record<string, unknown> = Record<string, unknown>> {
81
- /** Array of entities matching the query */
82
- data: Entity<M>[];
83
- /** Pagination metadata */
84
- meta: {
85
- total: number;
86
- limit: number;
87
- offset: number;
88
- hasMore: boolean;
89
- };
90
- }
91
- export type FilterOperator = WhereFilterOpShort;
92
- /**
93
- * Fluent Query Builder Interface supported on both client and server accessors.
94
- * @group Data
95
- */
96
- export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
97
- where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): this;
98
- where(logicalCondition: LogicalCondition): this;
99
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
100
- limit(count: number): this;
101
- offset(count: number): this;
102
- search(searchString: string): this;
103
- include(...relations: string[]): this;
104
- find(): Promise<FindResponse<M>>;
105
- listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
106
- }
107
- /**
108
- * A single collection's CRUD accessor.
109
- *
110
- * This is the unified API surface used in both:
111
- * - The generated SDK (`client.data.products.create(...)`)
112
- * - Framework callbacks (`context.data.products.create(...)`)
113
- *
114
- * @group Data
115
- */
116
- export interface CollectionAccessor<M extends Record<string, unknown> = Record<string, unknown>> {
117
- /**
118
- * Find multiple records with optional filtering, pagination, and sorting.
119
- */
120
- find(params?: FindParams): Promise<FindResponse<M>>;
121
- /**
122
- * Find a single record by its ID.
123
- */
124
- findById(id: string | number): Promise<Entity<M> | undefined>;
125
- /**
126
- * Create a new record.
127
- * @param data The entity data to create.
128
- * @param id Optional specific ID to use for the new record.
129
- * @returns The created entity
130
- */
131
- create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
132
- /**
133
- * Update an existing record by ID.
134
- * @returns The updated entity
135
- */
136
- update(id: string | number, data: Partial<EntityValues<M>>): Promise<Entity<M>>;
137
- /**
138
- * Delete a record by ID.
139
- */
140
- delete(id: string | number): Promise<void>;
141
- /**
142
- * Delete all records in this collection.
143
- */
144
- deleteAll?(): Promise<void>;
145
- /**
146
- * Subscribe to a collection for real-time updates.
147
- * Optional method, may not be supported by all implementations (like stateless HTTP clients).
148
- */
149
- listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
150
- /**
151
- * Subscribe to a single record for real-time updates.
152
- * Optional method.
153
- */
154
- listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
155
- /**
156
- * Count the number of records matching the given filter.
157
- */
158
- count?(params?: FindParams): Promise<number>;
159
- where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
160
- where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
161
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilderInterface<M>;
162
- limit(count: number): QueryBuilderInterface<M>;
163
- offset(count: number): QueryBuilderInterface<M>;
164
- search(searchString: string): QueryBuilderInterface<M>;
165
- include(...relations: string[]): QueryBuilderInterface<M>;
166
- }
167
- /**
168
- * The unified data access object.
169
- *
170
- * Access collections as dynamic properties: `data.products.find(...)`.
171
- * In the SDK this is backed by HTTP transport (typed, generated per-project).
172
- * In the framework this is backed by a Proxy + in-process database driver (dynamic).
173
- *
174
- * @example
175
- * // SDK
176
- * const client = createRebaseClient({ baseUrl: "..." });
177
- * await client.data.products.create({ name: "Camera", price: 299 });
178
- *
179
- * // Framework callback
180
- * callbacks: {
181
- * afterSave({ context }) {
182
- * await context.data.logs.create({ action: "saved", timestamp: new Date() });
183
- * }
184
- * }
185
- *
186
- * @group Data
187
- */
188
- export interface RebaseData {
189
- /**
190
- * Get a collection accessor by slug.
191
- * Alternative to dynamic property access for cases where
192
- * the collection name is a variable.
193
- *
194
- * @example
195
- * const accessor = data.collection("products");
196
- * await accessor.find({ limit: 10 });
197
- */
198
- collection(slug: string): CollectionAccessor;
199
- /**
200
- * Dynamic collection accessor.
201
- * Access any collection by its slug as a property.
202
- *
203
- * @example
204
- * data.products.find({ where: { status: "eq.published" } })
205
- */
206
- [collectionSlug: string]: CollectionAccessor | ((slug: string) => CollectionAccessor);
207
- }
@@ -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
- }