@rebasepro/types 0.6.1 → 0.8.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 +69 -1
- package/dist/controllers/data.d.ts +19 -47
- package/dist/controllers/navigation.d.ts +14 -14
- package/dist/controllers/registry.d.ts +8 -4
- package/dist/index.es.js +164 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +171 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/types/api_keys.d.ts +57 -0
- package/dist/types/auth_adapter.d.ts +66 -4
- package/dist/types/backend.d.ts +5 -0
- package/dist/types/collections.d.ts +200 -90
- package/dist/types/data_source.d.ts +79 -3
- package/dist/types/entity_actions.d.ts +2 -2
- package/dist/types/entity_callbacks.d.ts +18 -6
- package/dist/types/entity_views.d.ts +1 -1
- package/dist/types/filter-operators.d.ts +108 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/policy.d.ts +137 -0
- package/dist/types/properties.d.ts +122 -37
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/translations.d.ts +8 -0
- package/package.json +1 -1
- package/src/controllers/client.ts +69 -1
- package/src/controllers/data.ts +20 -59
- package/src/controllers/navigation.ts +17 -16
- package/src/controllers/registry.ts +10 -4
- package/src/types/api_keys.ts +52 -0
- package/src/types/auth_adapter.ts +80 -4
- package/src/types/backend.ts +6 -1
- package/src/types/collections.ts +235 -113
- package/src/types/data_source.ts +89 -5
- package/src/types/entity_actions.tsx +2 -2
- package/src/types/entity_callbacks.ts +18 -7
- package/src/types/entity_views.tsx +1 -1
- package/src/types/filter-operators.ts +167 -0
- package/src/types/index.ts +5 -2
- package/src/types/plugins.tsx +1 -1
- package/src/types/policy.ts +173 -0
- package/src/types/properties.ts +132 -39
- package/src/types/property_config.tsx +0 -1
- package/src/types/storage_source.ts +90 -0
- package/src/types/translations.ts +8 -0
- package/dist/types/backend_hooks.d.ts +0 -109
- package/dist/types/entity_overrides.d.ts +0 -10
- package/src/types/backend_hooks.ts +0 -114
- package/src/types/entity_overrides.tsx +0 -11
package/dist/index.umd.js
CHANGED
|
@@ -126,30 +126,156 @@
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
//#endregion
|
|
129
|
+
//#region src/types/filter-operators.ts
|
|
130
|
+
/** Maps canonical operators to their REST short-code equivalents. */
|
|
131
|
+
var CANONICAL_TO_REST = {
|
|
132
|
+
"==": "eq",
|
|
133
|
+
"!=": "neq",
|
|
134
|
+
">": "gt",
|
|
135
|
+
">=": "gte",
|
|
136
|
+
"<": "lt",
|
|
137
|
+
"<=": "lte",
|
|
138
|
+
"in": "in",
|
|
139
|
+
"not-in": "nin",
|
|
140
|
+
"array-contains": "cs",
|
|
141
|
+
"array-contains-any": "csa"
|
|
142
|
+
};
|
|
143
|
+
/** Maps REST short-code operators to their canonical equivalents. */
|
|
144
|
+
var REST_TO_CANONICAL = {
|
|
145
|
+
"eq": "==",
|
|
146
|
+
"neq": "!=",
|
|
147
|
+
"gt": ">",
|
|
148
|
+
"gte": ">=",
|
|
149
|
+
"lt": "<",
|
|
150
|
+
"lte": "<=",
|
|
151
|
+
"in": "in",
|
|
152
|
+
"nin": "not-in",
|
|
153
|
+
"cs": "array-contains",
|
|
154
|
+
"csa": "array-contains-any"
|
|
155
|
+
};
|
|
156
|
+
/** All canonical operator strings for runtime validation. */
|
|
157
|
+
var CANONICAL_OPS = new Set([
|
|
158
|
+
"<",
|
|
159
|
+
"<=",
|
|
160
|
+
"==",
|
|
161
|
+
"!=",
|
|
162
|
+
">=",
|
|
163
|
+
">",
|
|
164
|
+
"in",
|
|
165
|
+
"not-in",
|
|
166
|
+
"array-contains",
|
|
167
|
+
"array-contains-any"
|
|
168
|
+
]);
|
|
169
|
+
/**
|
|
170
|
+
* Resolve any operator string (canonical or REST short-code) to its
|
|
171
|
+
* canonical `WhereFilterOp` form. Returns `undefined` for unknown operators.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* toCanonicalOp("==") // "=="
|
|
175
|
+
* toCanonicalOp("eq") // "=="
|
|
176
|
+
* toCanonicalOp("cs") // "array-contains"
|
|
177
|
+
* toCanonicalOp("xyz") // undefined
|
|
178
|
+
*/
|
|
179
|
+
function toCanonicalOp(op) {
|
|
180
|
+
if (CANONICAL_OPS.has(op)) return op;
|
|
181
|
+
return REST_TO_CANONICAL[op];
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
129
184
|
//#region src/types/collections.ts
|
|
130
185
|
/**
|
|
131
186
|
* Type guard for PostgreSQL collections.
|
|
132
|
-
* Returns true if the collection uses the Postgres
|
|
187
|
+
* Returns true if the collection uses the Postgres engine (or the default engine).
|
|
133
188
|
* @group Models
|
|
134
189
|
*/
|
|
135
190
|
function isPostgresCollection(collection) {
|
|
136
|
-
return !collection.
|
|
191
|
+
return !collection.engine || collection.engine === "postgres";
|
|
137
192
|
}
|
|
138
193
|
/**
|
|
139
194
|
* Type guard for Firebase / Firestore collections.
|
|
140
195
|
* @group Models
|
|
141
196
|
*/
|
|
142
197
|
function isFirebaseCollection(collection) {
|
|
143
|
-
return collection.
|
|
198
|
+
return collection.engine === "firestore";
|
|
144
199
|
}
|
|
145
200
|
/**
|
|
146
201
|
* Type guard for MongoDB collections.
|
|
147
202
|
* @group Models
|
|
148
203
|
*/
|
|
149
204
|
function isMongoDBCollection(collection) {
|
|
150
|
-
return collection.
|
|
205
|
+
return collection.engine === "mongodb";
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns the data path for a collection.
|
|
209
|
+
* For Firestore or MongoDB collections with a `path`, returns that value;
|
|
210
|
+
* otherwise falls back to `slug`.
|
|
211
|
+
*/
|
|
212
|
+
function getCollectionDataPath(collection) {
|
|
213
|
+
if (isFirebaseCollection(collection) && collection.path) return collection.path;
|
|
214
|
+
if (isMongoDBCollection(collection) && collection.path) return collection.path;
|
|
215
|
+
return collection.slug;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Reads a collection's driver-declared subcollections thunk (the `subcollections`
|
|
219
|
+
* field) independent of engine identity, so engine-agnostic code doesn't have to
|
|
220
|
+
* type-guard against a specific driver. Returns `undefined` when the collection
|
|
221
|
+
* declares none.
|
|
222
|
+
*
|
|
223
|
+
* Pair with `getDataSourceCapabilities(engine).supportsSubcollections` to decide
|
|
224
|
+
* whether the engine honours subcollections at all before reading them.
|
|
225
|
+
* @group Models
|
|
226
|
+
*/
|
|
227
|
+
function getDeclaredSubcollections(collection) {
|
|
228
|
+
return collection.subcollections;
|
|
151
229
|
}
|
|
152
230
|
//#endregion
|
|
231
|
+
//#region src/types/policy.ts
|
|
232
|
+
/** @group Models */
|
|
233
|
+
var policy = {
|
|
234
|
+
true: () => ({ kind: "true" }),
|
|
235
|
+
false: () => ({ kind: "false" }),
|
|
236
|
+
and: (...operands) => ({
|
|
237
|
+
kind: "and",
|
|
238
|
+
operands
|
|
239
|
+
}),
|
|
240
|
+
or: (...operands) => ({
|
|
241
|
+
kind: "or",
|
|
242
|
+
operands
|
|
243
|
+
}),
|
|
244
|
+
not: (operand) => ({
|
|
245
|
+
kind: "not",
|
|
246
|
+
operand
|
|
247
|
+
}),
|
|
248
|
+
compare: (left, op, right) => ({
|
|
249
|
+
kind: "compare",
|
|
250
|
+
op,
|
|
251
|
+
left,
|
|
252
|
+
right
|
|
253
|
+
}),
|
|
254
|
+
rolesOverlap: (roles) => ({
|
|
255
|
+
kind: "rolesOverlap",
|
|
256
|
+
roles
|
|
257
|
+
}),
|
|
258
|
+
rolesContain: (roles) => ({
|
|
259
|
+
kind: "rolesContain",
|
|
260
|
+
roles
|
|
261
|
+
}),
|
|
262
|
+
authenticated: () => ({ kind: "authenticated" }),
|
|
263
|
+
raw: (sql) => ({
|
|
264
|
+
kind: "raw",
|
|
265
|
+
sql
|
|
266
|
+
}),
|
|
267
|
+
field: (name) => ({
|
|
268
|
+
kind: "field",
|
|
269
|
+
name
|
|
270
|
+
}),
|
|
271
|
+
literal: (value) => ({
|
|
272
|
+
kind: "literal",
|
|
273
|
+
value
|
|
274
|
+
}),
|
|
275
|
+
authUid: () => ({ kind: "authUid" }),
|
|
276
|
+
authRoles: () => ({ kind: "authRoles" })
|
|
277
|
+
};
|
|
278
|
+
//#endregion
|
|
153
279
|
//#region src/types/backend.ts
|
|
154
280
|
/**
|
|
155
281
|
* Type guard: does this admin support SQL operations?
|
|
@@ -181,6 +307,13 @@
|
|
|
181
307
|
}
|
|
182
308
|
//#endregion
|
|
183
309
|
//#region src/types/data_source.ts
|
|
310
|
+
/**
|
|
311
|
+
* The default data-source key, used when a collection does not name a
|
|
312
|
+
* `dataSource`. Shared by the frontend router and the backend driver
|
|
313
|
+
* registry so both agree on "the default database".
|
|
314
|
+
* @group Models
|
|
315
|
+
*/
|
|
316
|
+
var DEFAULT_DATA_SOURCE_KEY = "(default)";
|
|
184
317
|
/** @group Models */
|
|
185
318
|
var POSTGRES_CAPABILITIES = {
|
|
186
319
|
key: "postgres",
|
|
@@ -248,13 +381,13 @@
|
|
|
248
381
|
"(default)": DEFAULT_CAPABILITIES
|
|
249
382
|
};
|
|
250
383
|
/**
|
|
251
|
-
* Look up capabilities for a given
|
|
252
|
-
* If `
|
|
384
|
+
* Look up capabilities for a given engine key.
|
|
385
|
+
* If `engine` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
253
386
|
* @group Models
|
|
254
387
|
*/
|
|
255
|
-
function getDataSourceCapabilities(
|
|
256
|
-
if (!
|
|
257
|
-
return CAPABILITIES_REGISTRY[
|
|
388
|
+
function getDataSourceCapabilities(engine) {
|
|
389
|
+
if (!engine) return POSTGRES_CAPABILITIES;
|
|
390
|
+
return CAPABILITIES_REGISTRY[engine] ?? DEFAULT_CAPABILITIES;
|
|
258
391
|
}
|
|
259
392
|
/**
|
|
260
393
|
* Register custom capabilities for a third-party driver.
|
|
@@ -264,6 +397,27 @@
|
|
|
264
397
|
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
265
398
|
}
|
|
266
399
|
//#endregion
|
|
400
|
+
//#region src/types/storage_source.ts
|
|
401
|
+
/**
|
|
402
|
+
* Describes a named storage backend — a place files live.
|
|
403
|
+
*
|
|
404
|
+
* Declared once and shared front + back: the frontend uses it to decide
|
|
405
|
+
* transport (HTTP proxy vs direct SDK), the backend uses the same `key`
|
|
406
|
+
* to resolve a StorageController, and collection properties reference
|
|
407
|
+
* a definition by its `key` via `StorageConfig.storageSource`.
|
|
408
|
+
*
|
|
409
|
+
* This mirrors the {@link DataSourceDefinition} pattern used for databases.
|
|
410
|
+
*
|
|
411
|
+
* @group Models
|
|
412
|
+
*/
|
|
413
|
+
/**
|
|
414
|
+
* The default storage source key, used when a property does not specify
|
|
415
|
+
* a `storageSource`. Shared by the frontend and backend registries so
|
|
416
|
+
* both agree on "the default storage backend".
|
|
417
|
+
* @group Models
|
|
418
|
+
*/
|
|
419
|
+
var DEFAULT_STORAGE_SOURCE_KEY = "(default)";
|
|
420
|
+
//#endregion
|
|
267
421
|
//#region src/types/component_ref.ts
|
|
268
422
|
/**
|
|
269
423
|
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
@@ -273,15 +427,21 @@
|
|
|
273
427
|
return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
|
|
274
428
|
}
|
|
275
429
|
//#endregion
|
|
430
|
+
exports.CANONICAL_TO_REST = CANONICAL_TO_REST;
|
|
276
431
|
exports.DEFAULT_CAPABILITIES = DEFAULT_CAPABILITIES;
|
|
432
|
+
exports.DEFAULT_DATA_SOURCE_KEY = DEFAULT_DATA_SOURCE_KEY;
|
|
433
|
+
exports.DEFAULT_STORAGE_SOURCE_KEY = DEFAULT_STORAGE_SOURCE_KEY;
|
|
277
434
|
exports.EntityReference = EntityReference;
|
|
278
435
|
exports.EntityRelation = EntityRelation;
|
|
279
436
|
exports.FIREBASE_CAPABILITIES = FIREBASE_CAPABILITIES;
|
|
280
437
|
exports.GeoPoint = GeoPoint;
|
|
281
438
|
exports.MONGODB_CAPABILITIES = MONGODB_CAPABILITIES;
|
|
282
439
|
exports.POSTGRES_CAPABILITIES = POSTGRES_CAPABILITIES;
|
|
440
|
+
exports.REST_TO_CANONICAL = REST_TO_CANONICAL;
|
|
283
441
|
exports.Vector = Vector;
|
|
442
|
+
exports.getCollectionDataPath = getCollectionDataPath;
|
|
284
443
|
exports.getDataSourceCapabilities = getDataSourceCapabilities;
|
|
444
|
+
exports.getDeclaredSubcollections = getDeclaredSubcollections;
|
|
285
445
|
exports.isBranchAdmin = isBranchAdmin;
|
|
286
446
|
exports.isDocumentAdmin = isDocumentAdmin;
|
|
287
447
|
exports.isFirebaseCollection = isFirebaseCollection;
|
|
@@ -290,7 +450,9 @@
|
|
|
290
450
|
exports.isPostgresCollection = isPostgresCollection;
|
|
291
451
|
exports.isSQLAdmin = isSQLAdmin;
|
|
292
452
|
exports.isSchemaAdmin = isSchemaAdmin;
|
|
453
|
+
exports.policy = policy;
|
|
293
454
|
exports.registerDataSourceCapabilities = registerDataSourceCapabilities;
|
|
455
|
+
exports.toCanonicalOp = toCanonicalOp;
|
|
294
456
|
});
|
|
295
457
|
|
|
296
458
|
//# sourceMappingURL=index.umd.js.map
|