@rebasepro/types 0.7.0 → 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 +53 -1
- package/dist/controllers/data.d.ts +19 -47
- package/dist/controllers/registry.d.ts +0 -2
- package/dist/index.es.js +157 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +163 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +5 -5
- package/dist/types/backend.d.ts +4 -0
- package/dist/types/collections.d.ts +158 -82
- package/dist/types/data_source.d.ts +3 -3
- package/dist/types/entity_callbacks.d.ts +18 -6
- package/dist/types/filter-operators.d.ts +108 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/policy.d.ts +137 -0
- package/dist/types/properties.d.ts +115 -37
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/storage_source.d.ts +83 -0
- package/package.json +1 -1
- package/src/controllers/client.ts +61 -1
- package/src/controllers/data.ts +20 -59
- package/src/controllers/registry.ts +0 -2
- package/src/types/auth_adapter.ts +5 -5
- package/src/types/backend.ts +5 -0
- package/src/types/collections.ts +191 -106
- package/src/types/data_source.ts +5 -5
- package/src/types/entity_callbacks.ts +18 -7
- package/src/types/filter-operators.ts +167 -0
- package/src/types/index.ts +3 -2
- package/src/types/policy.ts +173 -0
- package/src/types/properties.ts +123 -38
- package/src/types/property_config.tsx +0 -1
- package/src/types/storage_source.ts +90 -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,29 +126,155 @@
|
|
|
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";
|
|
151
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;
|
|
229
|
+
}
|
|
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
|
+
};
|
|
152
278
|
//#endregion
|
|
153
279
|
//#region src/types/backend.ts
|
|
154
280
|
/**
|
|
@@ -255,13 +381,13 @@
|
|
|
255
381
|
"(default)": DEFAULT_CAPABILITIES
|
|
256
382
|
};
|
|
257
383
|
/**
|
|
258
|
-
* Look up capabilities for a given
|
|
259
|
-
* If `
|
|
384
|
+
* Look up capabilities for a given engine key.
|
|
385
|
+
* If `engine` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
260
386
|
* @group Models
|
|
261
387
|
*/
|
|
262
|
-
function getDataSourceCapabilities(
|
|
263
|
-
if (!
|
|
264
|
-
return CAPABILITIES_REGISTRY[
|
|
388
|
+
function getDataSourceCapabilities(engine) {
|
|
389
|
+
if (!engine) return POSTGRES_CAPABILITIES;
|
|
390
|
+
return CAPABILITIES_REGISTRY[engine] ?? DEFAULT_CAPABILITIES;
|
|
265
391
|
}
|
|
266
392
|
/**
|
|
267
393
|
* Register custom capabilities for a third-party driver.
|
|
@@ -271,6 +397,27 @@
|
|
|
271
397
|
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
272
398
|
}
|
|
273
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
|
|
274
421
|
//#region src/types/component_ref.ts
|
|
275
422
|
/**
|
|
276
423
|
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
@@ -280,16 +427,21 @@
|
|
|
280
427
|
return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
|
|
281
428
|
}
|
|
282
429
|
//#endregion
|
|
430
|
+
exports.CANONICAL_TO_REST = CANONICAL_TO_REST;
|
|
283
431
|
exports.DEFAULT_CAPABILITIES = DEFAULT_CAPABILITIES;
|
|
284
432
|
exports.DEFAULT_DATA_SOURCE_KEY = DEFAULT_DATA_SOURCE_KEY;
|
|
433
|
+
exports.DEFAULT_STORAGE_SOURCE_KEY = DEFAULT_STORAGE_SOURCE_KEY;
|
|
285
434
|
exports.EntityReference = EntityReference;
|
|
286
435
|
exports.EntityRelation = EntityRelation;
|
|
287
436
|
exports.FIREBASE_CAPABILITIES = FIREBASE_CAPABILITIES;
|
|
288
437
|
exports.GeoPoint = GeoPoint;
|
|
289
438
|
exports.MONGODB_CAPABILITIES = MONGODB_CAPABILITIES;
|
|
290
439
|
exports.POSTGRES_CAPABILITIES = POSTGRES_CAPABILITIES;
|
|
440
|
+
exports.REST_TO_CANONICAL = REST_TO_CANONICAL;
|
|
291
441
|
exports.Vector = Vector;
|
|
442
|
+
exports.getCollectionDataPath = getCollectionDataPath;
|
|
292
443
|
exports.getDataSourceCapabilities = getDataSourceCapabilities;
|
|
444
|
+
exports.getDeclaredSubcollections = getDeclaredSubcollections;
|
|
293
445
|
exports.isBranchAdmin = isBranchAdmin;
|
|
294
446
|
exports.isDocumentAdmin = isDocumentAdmin;
|
|
295
447
|
exports.isFirebaseCollection = isFirebaseCollection;
|
|
@@ -298,7 +450,9 @@
|
|
|
298
450
|
exports.isPostgresCollection = isPostgresCollection;
|
|
299
451
|
exports.isSQLAdmin = isSQLAdmin;
|
|
300
452
|
exports.isSchemaAdmin = isSchemaAdmin;
|
|
453
|
+
exports.policy = policy;
|
|
301
454
|
exports.registerDataSourceCapabilities = registerDataSourceCapabilities;
|
|
455
|
+
exports.toCanonicalOp = toCanonicalOp;
|
|
302
456
|
});
|
|
303
457
|
|
|
304
458
|
//# sourceMappingURL=index.umd.js.map
|