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