@rebasepro/types 0.10.1-canary.5cd561f → 0.10.1-canary.60301c3
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/data.d.ts +17 -11
- package/dist/index.es.js +27 -1
- package/dist/index.es.js.map +1 -1
- package/dist/types/admin_block.d.ts +8 -26
- package/dist/types/backend.d.ts +23 -0
- package/dist/types/collections.d.ts +56 -18
- package/dist/types/filter-operators.d.ts +18 -0
- package/dist/types/properties.d.ts +35 -228
- package/dist/types/relations.d.ts +231 -247
- package/package.json +1 -1
- package/src/controllers/data.ts +17 -11
- package/src/types/admin_block.ts +8 -26
- package/src/types/backend.ts +24 -0
- package/src/types/collections.ts +60 -18
- package/src/types/filter-operators.ts +21 -0
- package/src/types/properties.ts +34 -258
- package/src/types/relations.ts +264 -249
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Entity, EntityValues } from "../types/entities";
|
|
2
|
-
import { WhereFilterOp, FilterValues, OrderByTuple } from "../types/filter-operators";
|
|
2
|
+
import { WhereFilterOp, FieldPath, FilterValues, OrderByTuple } from "../types/filter-operators";
|
|
3
3
|
export type WhereValue<T> = T | T[] | null;
|
|
4
4
|
export interface LogicalCondition {
|
|
5
5
|
type: "and" | "or";
|
|
@@ -39,7 +39,7 @@ export interface FilterCondition {
|
|
|
39
39
|
*
|
|
40
40
|
* @group Data
|
|
41
41
|
*/
|
|
42
|
-
export interface FindParams {
|
|
42
|
+
export interface FindParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
43
43
|
/** Maximum number of items to return (default: 20). */
|
|
44
44
|
limit?: number;
|
|
45
45
|
/**
|
|
@@ -65,7 +65,7 @@ export interface FindParams {
|
|
|
65
65
|
* { role: ["in", ["admin", "editor"]] }
|
|
66
66
|
* { age: [[">=", 18], ["<", 65]] }
|
|
67
67
|
*/
|
|
68
|
-
where?: FilterValues<
|
|
68
|
+
where?: FilterValues<FieldPath<M>>;
|
|
69
69
|
/**
|
|
70
70
|
* Logical grouping conditions (AND/OR). Use this for anything `where`
|
|
71
71
|
* can't express — notably OR-ing conditions. AND-ed with `where` and
|
|
@@ -76,8 +76,14 @@ export interface FindParams {
|
|
|
76
76
|
* Sort order as a `[field, direction]` tuple.
|
|
77
77
|
* @example orderBy: ["created_at", "desc"]
|
|
78
78
|
*/
|
|
79
|
-
orderBy?: OrderByTuple
|
|
80
|
-
/**
|
|
79
|
+
orderBy?: OrderByTuple<FieldPath<M>>;
|
|
80
|
+
/**
|
|
81
|
+
* Relations to include in the response.
|
|
82
|
+
*
|
|
83
|
+
* Deliberately `string[]` and not checked against `M`: a relation name
|
|
84
|
+
* comes from the collection's `relations`, not from its columns, so nothing
|
|
85
|
+
* in a generated row type can validate one.
|
|
86
|
+
*/
|
|
81
87
|
include?: string[];
|
|
82
88
|
/**
|
|
83
89
|
* Full-text search string. Matched (OR-ed) across the collection's
|
|
@@ -137,7 +143,7 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
137
143
|
/**
|
|
138
144
|
* Find multiple records with optional filtering, pagination, and sorting.
|
|
139
145
|
*/
|
|
140
|
-
find(params?: FindParams): Promise<FindResponse<M>>;
|
|
146
|
+
find(params?: FindParams<M>): Promise<FindResponse<M>>;
|
|
141
147
|
/**
|
|
142
148
|
* Find a single record by its ID.
|
|
143
149
|
*/
|
|
@@ -171,7 +177,7 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
171
177
|
* Subscribe to a collection for real-time updates.
|
|
172
178
|
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
173
179
|
*/
|
|
174
|
-
listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
|
|
180
|
+
listen?(params: FindParams<M> | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
|
|
175
181
|
/**
|
|
176
182
|
* Subscribe to a single record for real-time updates.
|
|
177
183
|
* Optional method.
|
|
@@ -180,7 +186,7 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
180
186
|
/**
|
|
181
187
|
* Count the number of records matching the given filter.
|
|
182
188
|
*/
|
|
183
|
-
count?(params?: FindParams): Promise<number>;
|
|
189
|
+
count?(params?: FindParams<M>): Promise<number>;
|
|
184
190
|
where<K extends keyof M & string>(column: K, operator: WhereFilterOp, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
|
|
185
191
|
where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
|
|
186
192
|
orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilderInterface<M>;
|
|
@@ -263,7 +269,7 @@ export interface SDKCollectionClient<M extends Record<string, unknown> = Record<
|
|
|
263
269
|
/**
|
|
264
270
|
* Find multiple records with optional filtering, pagination, and sorting.
|
|
265
271
|
*/
|
|
266
|
-
find(params?: FindParams): Promise<FindResult<M>>;
|
|
272
|
+
find(params?: FindParams<M>): Promise<FindResult<M>>;
|
|
267
273
|
/**
|
|
268
274
|
* Find a single record by its ID.
|
|
269
275
|
*/
|
|
@@ -323,7 +329,7 @@ export interface SDKCollectionClient<M extends Record<string, unknown> = Record<
|
|
|
323
329
|
/**
|
|
324
330
|
* Subscribe to a collection for real-time updates.
|
|
325
331
|
*/
|
|
326
|
-
listen?(params: FindParams | undefined, onUpdate: (response: FindResult<M>) => void, onError?: (error: Error) => void): () => void;
|
|
332
|
+
listen?(params: FindParams<M> | undefined, onUpdate: (response: FindResult<M>) => void, onError?: (error: Error) => void): () => void;
|
|
327
333
|
/**
|
|
328
334
|
* Subscribe to a single record for real-time updates.
|
|
329
335
|
*/
|
|
@@ -331,7 +337,7 @@ export interface SDKCollectionClient<M extends Record<string, unknown> = Record<
|
|
|
331
337
|
/**
|
|
332
338
|
* Count the number of records matching the given filter.
|
|
333
339
|
*/
|
|
334
|
-
count?(params?: FindParams): Promise<number>;
|
|
340
|
+
count?(params?: FindParams<M>): Promise<number>;
|
|
335
341
|
where<K extends keyof M & string>(column: K, operator: WhereFilterOp, value: WhereValue<M[K]>): SDKQueryBuilderInterface<M>;
|
|
336
342
|
where(logicalCondition: LogicalCondition): SDKQueryBuilderInterface<M>;
|
|
337
343
|
orderBy(column: keyof M & string, direction?: "asc" | "desc"): SDKQueryBuilderInterface<M>;
|
package/dist/index.es.js
CHANGED
|
@@ -266,6 +266,18 @@ function toCanonicalOp(op) {
|
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/types/admin_block.ts
|
|
268
268
|
/**
|
|
269
|
+
* The keys of a collection's admin block, as data.
|
|
270
|
+
*
|
|
271
|
+
* There is no *type* for the block in this package any more, and that is the point:
|
|
272
|
+
* `admin` is not declared on `BaseCollectionConfig` or on any property here, so a
|
|
273
|
+
* BaaS install cannot even write one. `@rebasepro/admin-types` adds the field back by
|
|
274
|
+
* declaration merging, which is why installing it is what makes the admin surface
|
|
275
|
+
* appear.
|
|
276
|
+
*
|
|
277
|
+
* The *list* still has to live here, because three runtime consumers need it and two
|
|
278
|
+
* of them are core — see below.
|
|
279
|
+
*/
|
|
280
|
+
/**
|
|
269
281
|
* Every key that belongs inside a collection's `admin` block, as data.
|
|
270
282
|
*
|
|
271
283
|
* The type that describes these fields is `AdminCollectionOptions` in
|
|
@@ -379,6 +391,20 @@ function getDeclaredSubcollections(collection) {
|
|
|
379
391
|
return collection.subcollections;
|
|
380
392
|
}
|
|
381
393
|
//#endregion
|
|
394
|
+
//#region src/types/relations.ts
|
|
395
|
+
/** @group Models */
|
|
396
|
+
function hasForeignKeyOnTarget(relation) {
|
|
397
|
+
return relation.kind === "hasOne" || relation.kind === "hasMany";
|
|
398
|
+
}
|
|
399
|
+
/** @group Models */
|
|
400
|
+
function isManyToMany(relation) {
|
|
401
|
+
return relation.kind === "manyToMany";
|
|
402
|
+
}
|
|
403
|
+
/** @group Models */
|
|
404
|
+
function isToMany(relation) {
|
|
405
|
+
return relation.cardinality === "many";
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
382
408
|
//#region src/types/policy.ts
|
|
383
409
|
/**
|
|
384
410
|
* The id a request without a logged-in user reports as `auth.uid()`.
|
|
@@ -929,6 +955,6 @@ function isPublicStoragePath(path) {
|
|
|
929
955
|
return p.startsWith("public/") || p.startsWith(`default/public/`);
|
|
930
956
|
}
|
|
931
957
|
//#endregion
|
|
932
|
-
export { ADMIN_COLLECTION_KEYS, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_DATA_SOURCE_KEY, DEFAULT_LIST_LIMIT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_VECTOR_LIST_LIMIT, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REST_TO_CANONICAL, RUNTIME_CONTRACT_VERSION, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, Vector, canonicalSchemaPayload, computeSchemaVersion, deserializeCollections, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, isBranchAdmin, isChannelBusInstance, isDocumentAdmin, isFirebaseCollectionConfig, isLazyComponentRef, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isSQLAdmin, isSchemaAdmin, isSerializedCollectionRef, policy, registerDataSourceCapabilities, resolveClientListLimit, serializeCollections, toCanonicalOp };
|
|
958
|
+
export { ADMIN_COLLECTION_KEYS, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_DATA_SOURCE_KEY, DEFAULT_LIST_LIMIT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_VECTOR_LIST_LIMIT, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REST_TO_CANONICAL, RUNTIME_CONTRACT_VERSION, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, Vector, canonicalSchemaPayload, computeSchemaVersion, deserializeCollections, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasForeignKeyOnTarget, isBranchAdmin, isChannelBusInstance, isDocumentAdmin, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isSQLAdmin, isSchemaAdmin, isSerializedCollectionRef, isToMany, policy, registerDataSourceCapabilities, resolveClientListLimit, serializeCollections, toCanonicalOp };
|
|
933
959
|
|
|
934
960
|
//# sourceMappingURL=index.es.js.map
|