@rebasepro/types 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 (37) hide show
  1. package/README.md +83 -232
  2. package/dist/controllers/client.d.ts +79 -32
  3. package/dist/controllers/customization_controller.d.ts +10 -9
  4. package/dist/index.es.js +249 -197
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/index.umd.js +294 -224
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/rebase_context.d.ts +0 -16
  9. package/dist/types/auth_adapter.d.ts +59 -4
  10. package/dist/types/backend.d.ts +36 -1
  11. package/dist/types/backend_hooks.d.ts +0 -63
  12. package/dist/types/breadcrumbs.d.ts +26 -0
  13. package/dist/types/collections.d.ts +162 -1
  14. package/dist/types/component_overrides.d.ts +138 -0
  15. package/dist/types/entity_views.d.ts +9 -1
  16. package/dist/types/index.d.ts +2 -0
  17. package/dist/types/plugins.d.ts +0 -5
  18. package/dist/types/properties.d.ts +0 -8
  19. package/dist/types/translations.d.ts +3 -0
  20. package/dist/types/user_management_delegate.d.ts +0 -70
  21. package/package.json +10 -10
  22. package/src/controllers/client.ts +85 -33
  23. package/src/controllers/customization_controller.tsx +11 -11
  24. package/src/rebase_context.tsx +0 -16
  25. package/src/types/auth_adapter.ts +70 -4
  26. package/src/types/backend.ts +39 -1
  27. package/src/types/backend_hooks.ts +0 -55
  28. package/src/types/breadcrumbs.ts +27 -0
  29. package/src/types/collections.ts +172 -2
  30. package/src/types/component_overrides.ts +177 -0
  31. package/src/types/database_adapter.ts +1 -1
  32. package/src/types/entity_views.tsx +10 -1
  33. package/src/types/index.ts +2 -0
  34. package/src/types/plugins.tsx +1 -5
  35. package/src/types/properties.ts +0 -9
  36. package/src/types/translations.ts +3 -0
  37. package/src/types/user_management_delegate.ts +0 -77
package/dist/index.es.js CHANGED
@@ -1,222 +1,274 @@
1
- class EntityReference {
2
- __type = "reference";
3
- /**
4
- * ID of the entity
5
- */
6
- id;
7
- /**
8
- * A string representing the path of the referenced document (relative
9
- * to the root of the database).
10
- */
11
- path;
12
- /**
13
- * Which driver (e.g., 'postgres', 'firestore').
14
- * Defaults to "(default)" if not specified.
15
- */
16
- driver;
17
- /**
18
- * Which database within the driver.
19
- * Defaults to "(default)" if not specified.
20
- */
21
- databaseId;
22
- /**
23
- * Create a reference to an entity.
24
- *
25
- * @example
26
- * // Simple reference (most common case)
27
- * new EntityReference({ id: "123", path: "users" })
28
- *
29
- * // With driver
30
- * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
31
- */
32
- constructor(props) {
33
- this.id = props.id;
34
- this.path = props.path;
35
- this.driver = props.driver;
36
- this.databaseId = props.databaseId;
37
- }
38
- get pathWithId() {
39
- return `${this.path}/${this.id}`;
40
- }
41
- /**
42
- * Get the full path including driver and database prefixes if specified.
43
- * For the common case (single driver, single db), this just returns pathWithId.
44
- */
45
- get fullPath() {
46
- const parts = [];
47
- if (this.driver && this.driver !== "(default)") {
48
- parts.push(this.driver);
49
- }
50
- if (this.databaseId && this.databaseId !== "(default)") {
51
- parts.push(this.databaseId);
52
- }
53
- if (parts.length > 0) {
54
- return `${parts.join(":")}:::${this.path}/${this.id}`;
55
- }
56
- return this.pathWithId;
57
- }
58
- isEntityReference() {
59
- return true;
60
- }
61
- }
62
- class EntityRelation {
63
- __type = "relation";
64
- /**
65
- * ID of the entity
66
- */
67
- id;
68
- /**
69
- * A string representing the path of the referenced document (relative
70
- * to the root of the database).
71
- */
72
- path;
73
- /**
74
- * Pre-fetched data payload to eliminate N+1 queries.
75
- * When present, clients can use this directly instead of fetching.
76
- */
77
- data;
78
- constructor(id, path, data) {
79
- this.id = id;
80
- this.path = path;
81
- this.data = data;
82
- }
83
- get pathWithId() {
84
- return `${this.path}/${this.id}`;
85
- }
86
- isEntityReference() {
87
- return false;
88
- }
89
- isEntityRelation() {
90
- return true;
91
- }
92
- }
93
- class GeoPoint {
94
- /**
95
- * The latitude of this GeoPoint instance.
96
- */
97
- latitude;
98
- /**
99
- * The longitude of this GeoPoint instance.
100
- */
101
- longitude;
102
- constructor(latitude, longitude) {
103
- this.latitude = latitude;
104
- this.longitude = longitude;
105
- }
106
- }
107
- class Vector {
108
- value;
109
- constructor(value) {
110
- this.value = value;
111
- }
112
- }
1
+ //#region src/types/entities.ts
2
+ /**
3
+ * Class used to create a reference to an entity in a different path.
4
+ *
5
+ * @example
6
+ * // Simple reference (most common case - single driver, single db)
7
+ * new EntityReference({ id: "123", path: "users" })
8
+ *
9
+ * // Reference to a different driver (e.g., Firestore)
10
+ * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
11
+ *
12
+ * // Reference to a specific database within a driver
13
+ * new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
14
+ */
15
+ var EntityReference = class {
16
+ __type = "reference";
17
+ /**
18
+ * ID of the entity
19
+ */
20
+ id;
21
+ /**
22
+ * A string representing the path of the referenced document (relative
23
+ * to the root of the database).
24
+ */
25
+ path;
26
+ /**
27
+ * Which driver (e.g., 'postgres', 'firestore').
28
+ * Defaults to "(default)" if not specified.
29
+ */
30
+ driver;
31
+ /**
32
+ * Which database within the driver.
33
+ * Defaults to "(default)" if not specified.
34
+ */
35
+ databaseId;
36
+ /**
37
+ * Create a reference to an entity.
38
+ *
39
+ * @example
40
+ * // Simple reference (most common case)
41
+ * new EntityReference({ id: "123", path: "users" })
42
+ *
43
+ * // With driver
44
+ * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
45
+ */
46
+ constructor(props) {
47
+ this.id = props.id;
48
+ this.path = props.path;
49
+ this.driver = props.driver;
50
+ this.databaseId = props.databaseId;
51
+ }
52
+ get pathWithId() {
53
+ return `${this.path}/${this.id}`;
54
+ }
55
+ /**
56
+ * Get the full path including driver and database prefixes if specified.
57
+ * For the common case (single driver, single db), this just returns pathWithId.
58
+ */
59
+ get fullPath() {
60
+ const parts = [];
61
+ if (this.driver && this.driver !== "(default)") parts.push(this.driver);
62
+ if (this.databaseId && this.databaseId !== "(default)") parts.push(this.databaseId);
63
+ if (parts.length > 0) return `${parts.join(":")}:::${this.path}/${this.id}`;
64
+ return this.pathWithId;
65
+ }
66
+ isEntityReference() {
67
+ return true;
68
+ }
69
+ };
70
+ /**
71
+ * Class used to create a reference to an entity in a different path
72
+ */
73
+ var EntityRelation = class {
74
+ __type = "relation";
75
+ /**
76
+ * ID of the entity
77
+ */
78
+ id;
79
+ /**
80
+ * A string representing the path of the referenced document (relative
81
+ * to the root of the database).
82
+ */
83
+ path;
84
+ /**
85
+ * Pre-fetched data payload to eliminate N+1 queries.
86
+ * When present, clients can use this directly instead of fetching.
87
+ */
88
+ data;
89
+ constructor(id, path, data) {
90
+ this.id = id;
91
+ this.path = path;
92
+ this.data = data;
93
+ }
94
+ get pathWithId() {
95
+ return `${this.path}/${this.id}`;
96
+ }
97
+ isEntityReference() {
98
+ return false;
99
+ }
100
+ isEntityRelation() {
101
+ return true;
102
+ }
103
+ };
104
+ var GeoPoint = class {
105
+ /**
106
+ * The latitude of this GeoPoint instance.
107
+ */
108
+ latitude;
109
+ /**
110
+ * The longitude of this GeoPoint instance.
111
+ */
112
+ longitude;
113
+ constructor(latitude, longitude) {
114
+ this.latitude = latitude;
115
+ this.longitude = longitude;
116
+ }
117
+ };
118
+ var Vector = class {
119
+ value;
120
+ constructor(value) {
121
+ this.value = value;
122
+ }
123
+ };
124
+ //#endregion
125
+ //#region src/types/collections.ts
126
+ /**
127
+ * Type guard for PostgreSQL collections.
128
+ * Returns true if the collection uses the Postgres driver (or the default driver).
129
+ * @group Models
130
+ */
113
131
  function isPostgresCollection(collection) {
114
- return !collection.driver || collection.driver === "postgres";
132
+ return !collection.driver || collection.driver === "postgres";
115
133
  }
134
+ /**
135
+ * Type guard for Firebase / Firestore collections.
136
+ * @group Models
137
+ */
116
138
  function isFirebaseCollection(collection) {
117
- return collection.driver === "firestore";
139
+ return collection.driver === "firestore";
118
140
  }
141
+ /**
142
+ * Type guard for MongoDB collections.
143
+ * @group Models
144
+ */
119
145
  function isMongoDBCollection(collection) {
120
- return collection.driver === "mongodb";
146
+ return collection.driver === "mongodb";
121
147
  }
148
+ //#endregion
149
+ //#region src/types/backend.ts
150
+ /**
151
+ * Type guard: does this admin support SQL operations?
152
+ * @group Admin
153
+ */
122
154
  function isSQLAdmin(admin) {
123
- return !!admin && typeof admin.executeSql === "function";
155
+ return !!admin && typeof admin.executeSql === "function";
124
156
  }
157
+ /**
158
+ * Type guard: does this admin support document operations?
159
+ * @group Admin
160
+ */
125
161
  function isDocumentAdmin(admin) {
126
- return !!admin && (typeof admin.executeAggregate === "function" || typeof admin.fetchCollectionStats === "function");
162
+ return !!admin && (typeof admin.executeAggregate === "function" || typeof admin.fetchCollectionStats === "function");
127
163
  }
164
+ /**
165
+ * Type guard: does this admin support schema management?
166
+ * @group Admin
167
+ */
128
168
  function isSchemaAdmin(admin) {
129
- return !!admin && (typeof admin.fetchUnmappedTables === "function" || typeof admin.fetchTableMetadata === "function");
169
+ return !!admin && (typeof admin.fetchUnmappedTables === "function" || typeof admin.fetchTableMetadata === "function");
130
170
  }
171
+ /**
172
+ * Type guard: does this admin support database branching?
173
+ * @group Admin
174
+ */
131
175
  function isBranchAdmin(admin) {
132
- return !!admin && typeof admin.createBranch === "function";
176
+ return !!admin && typeof admin.createBranch === "function";
133
177
  }
134
- const POSTGRES_CAPABILITIES = {
135
- key: "postgres",
136
- label: "PostgreSQL",
137
- supportsRelations: true,
138
- supportsSubcollections: false,
139
- supportsRLS: true,
140
- supportsReferences: false,
141
- supportsColumnTypes: true,
142
- supportsRealtime: true,
143
- supportsSQLAdmin: true,
144
- supportsDocumentAdmin: false,
145
- supportsSchemaAdmin: true
178
+ //#endregion
179
+ //#region src/types/data_source.ts
180
+ /** @group Models */
181
+ var POSTGRES_CAPABILITIES = {
182
+ key: "postgres",
183
+ label: "PostgreSQL",
184
+ supportsRelations: true,
185
+ supportsSubcollections: false,
186
+ supportsRLS: true,
187
+ supportsReferences: false,
188
+ supportsColumnTypes: true,
189
+ supportsRealtime: true,
190
+ supportsSQLAdmin: true,
191
+ supportsDocumentAdmin: false,
192
+ supportsSchemaAdmin: true
146
193
  };
147
- const FIREBASE_CAPABILITIES = {
148
- key: "firestore",
149
- label: "Firebase / Firestore",
150
- supportsRelations: false,
151
- supportsSubcollections: true,
152
- supportsRLS: false,
153
- supportsReferences: true,
154
- supportsColumnTypes: false,
155
- supportsRealtime: true,
156
- supportsSQLAdmin: false,
157
- supportsDocumentAdmin: false,
158
- supportsSchemaAdmin: false
194
+ /** @group Models */
195
+ var FIREBASE_CAPABILITIES = {
196
+ key: "firestore",
197
+ label: "Firebase / Firestore",
198
+ supportsRelations: false,
199
+ supportsSubcollections: true,
200
+ supportsRLS: false,
201
+ supportsReferences: true,
202
+ supportsColumnTypes: false,
203
+ supportsRealtime: true,
204
+ supportsSQLAdmin: false,
205
+ supportsDocumentAdmin: false,
206
+ supportsSchemaAdmin: false
159
207
  };
160
- const MONGODB_CAPABILITIES = {
161
- key: "mongodb",
162
- label: "MongoDB",
163
- supportsRelations: false,
164
- supportsSubcollections: true,
165
- supportsRLS: false,
166
- supportsReferences: true,
167
- supportsColumnTypes: false,
168
- supportsRealtime: false,
169
- supportsSQLAdmin: false,
170
- supportsDocumentAdmin: true,
171
- supportsSchemaAdmin: true
208
+ /** @group Models */
209
+ var MONGODB_CAPABILITIES = {
210
+ key: "mongodb",
211
+ label: "MongoDB",
212
+ supportsRelations: false,
213
+ supportsSubcollections: true,
214
+ supportsRLS: false,
215
+ supportsReferences: true,
216
+ supportsColumnTypes: false,
217
+ supportsRealtime: false,
218
+ supportsSQLAdmin: false,
219
+ supportsDocumentAdmin: true,
220
+ supportsSchemaAdmin: true
172
221
  };
173
- const DEFAULT_CAPABILITIES = {
174
- key: "(default)",
175
- label: "Default",
176
- supportsRelations: true,
177
- supportsSubcollections: true,
178
- supportsRLS: true,
179
- supportsReferences: true,
180
- supportsColumnTypes: true,
181
- supportsRealtime: true,
182
- supportsSQLAdmin: true,
183
- supportsDocumentAdmin: true,
184
- supportsSchemaAdmin: true
222
+ /**
223
+ * Fallback capabilities when the driver is unknown.
224
+ * Enables everything so nothing is hidden unexpectedly.
225
+ * @group Models
226
+ */
227
+ var DEFAULT_CAPABILITIES = {
228
+ key: "(default)",
229
+ label: "Default",
230
+ supportsRelations: true,
231
+ supportsSubcollections: true,
232
+ supportsRLS: true,
233
+ supportsReferences: true,
234
+ supportsColumnTypes: true,
235
+ supportsRealtime: true,
236
+ supportsSQLAdmin: true,
237
+ supportsDocumentAdmin: true,
238
+ supportsSchemaAdmin: true
185
239
  };
186
- const CAPABILITIES_REGISTRY = {
187
- postgres: POSTGRES_CAPABILITIES,
188
- firestore: FIREBASE_CAPABILITIES,
189
- mongodb: MONGODB_CAPABILITIES,
190
- "(default)": DEFAULT_CAPABILITIES
240
+ var CAPABILITIES_REGISTRY = {
241
+ postgres: POSTGRES_CAPABILITIES,
242
+ firestore: FIREBASE_CAPABILITIES,
243
+ mongodb: MONGODB_CAPABILITIES,
244
+ "(default)": DEFAULT_CAPABILITIES
191
245
  };
246
+ /**
247
+ * Look up capabilities for a given driver key.
248
+ * If `driver` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
249
+ * @group Models
250
+ */
192
251
  function getDataSourceCapabilities(driver) {
193
- if (!driver) return POSTGRES_CAPABILITIES;
194
- return CAPABILITIES_REGISTRY[driver] ?? DEFAULT_CAPABILITIES;
252
+ if (!driver) return POSTGRES_CAPABILITIES;
253
+ return CAPABILITIES_REGISTRY[driver] ?? DEFAULT_CAPABILITIES;
195
254
  }
255
+ /**
256
+ * Register custom capabilities for a third-party driver.
257
+ * @group Models
258
+ */
196
259
  function registerDataSourceCapabilities(capabilities) {
197
- CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
260
+ CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
198
261
  }
262
+ //#endregion
263
+ //#region src/types/component_ref.ts
264
+ /**
265
+ * Type guard: checks if a value is a `LazyComponentRef` produced by the
266
+ * Vite transform plugin.
267
+ */
199
268
  function isLazyComponentRef(ref) {
200
- return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
269
+ return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
201
270
  }
202
- export {
203
- DEFAULT_CAPABILITIES,
204
- EntityReference,
205
- EntityRelation,
206
- FIREBASE_CAPABILITIES,
207
- GeoPoint,
208
- MONGODB_CAPABILITIES,
209
- POSTGRES_CAPABILITIES,
210
- Vector,
211
- getDataSourceCapabilities,
212
- isBranchAdmin,
213
- isDocumentAdmin,
214
- isFirebaseCollection,
215
- isLazyComponentRef,
216
- isMongoDBCollection,
217
- isPostgresCollection,
218
- isSQLAdmin,
219
- isSchemaAdmin,
220
- registerDataSourceCapabilities
221
- };
222
- //# sourceMappingURL=index.es.js.map
271
+ //#endregion
272
+ export { DEFAULT_CAPABILITIES, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MONGODB_CAPABILITIES, POSTGRES_CAPABILITIES, Vector, getDataSourceCapabilities, isBranchAdmin, isDocumentAdmin, isFirebaseCollection, isLazyComponentRef, isMongoDBCollection, isPostgresCollection, isSQLAdmin, isSchemaAdmin, registerDataSourceCapabilities };
273
+
274
+ //# sourceMappingURL=index.es.js.map