@rebasepro/common 0.22.0 → 0.24.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/collections/CollectionRegistry.d.ts +72 -3
- package/dist/collections/default-collections.d.ts +1 -1
- package/dist/collections/field-access.d.ts +5 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/soft-delete.d.ts +23 -0
- package/dist/data/buildRebaseData.d.ts +15 -0
- package/dist/data/cursor.d.ts +1 -1
- package/dist/data/filter-dialect.d.ts +13 -0
- package/dist/index.es.js +659 -102
- package/dist/index.es.js.map +1 -1
- package/dist/util/copy.d.ts +33 -0
- package/dist/util/entities.d.ts +9 -1
- package/dist/util/index.d.ts +2 -0
- package/dist/util/policy/compileRulePolicies.d.ts +32 -0
- package/dist/util/policy/index.d.ts +2 -0
- package/dist/util/policy/policyToSecurityRule.d.ts +27 -0
- package/dist/util/untrusted-envelope.d.ts +25 -0
- package/package.json +3 -3
- package/dist/util/callback-errors.test.d.ts +0 -1
- package/dist/util/internal-tables.test.d.ts +0 -1
- package/dist/util/permissions.test.d.ts +0 -1
- package/dist/util/table-name.test.d.ts +0 -1
|
@@ -24,6 +24,13 @@ export declare class CollectionRegistry {
|
|
|
24
24
|
getGlobalCallbacks(): CollectionCallbacks | undefined;
|
|
25
25
|
private collectionsByTableName;
|
|
26
26
|
private collectionsBySlug;
|
|
27
|
+
/**
|
|
28
|
+
* Root collections whose driver stores them under a `path` other than
|
|
29
|
+
* their slug, by that path. A list, because the path is only unique within
|
|
30
|
+
* a data source: two collections in different databases may both be stored
|
|
31
|
+
* at `customer`.
|
|
32
|
+
*/
|
|
33
|
+
private collectionsByDataPath;
|
|
27
34
|
private rootCollections;
|
|
28
35
|
private cachedCollectionsList;
|
|
29
36
|
private rawCollectionsByTableName;
|
|
@@ -49,11 +56,61 @@ export declare class CollectionRegistry {
|
|
|
49
56
|
*/
|
|
50
57
|
registerMultiple(collections: CollectionConfig[]): boolean;
|
|
51
58
|
register(collection: CollectionConfig, rawCollection?: CollectionConfig): void;
|
|
59
|
+
/**
|
|
60
|
+
* Index a root collection by the path its driver stores it under, when
|
|
61
|
+
* that is not its slug. Only roots: a subcollection's `path` is relative to
|
|
62
|
+
* the record it hangs off, so it names nothing on its own.
|
|
63
|
+
*/
|
|
64
|
+
private indexDataPath;
|
|
52
65
|
private _registerRecursively;
|
|
53
66
|
normalizeCollection(collection: CollectionConfig): CollectionConfig;
|
|
54
67
|
private normalizeProperties;
|
|
55
68
|
private normalizeProperty;
|
|
56
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The collection registered under `path`: by slug, by slug with hyphens
|
|
71
|
+
* for underscores, by table name, and last by the `path` a root Firestore
|
|
72
|
+
* or MongoDB collection declares for its driver.
|
|
73
|
+
*
|
|
74
|
+
* One string can name two collections. Declaring `slug: "fs_diagnosis",
|
|
75
|
+
* path: "diagnosis"` is how a Firestore collection sits beside a Postgres
|
|
76
|
+
* collection whose slug is `diagnosis` — and a reference read back from
|
|
77
|
+
* Firestore carries `diagnosis`. The order above settles it in favour of the
|
|
78
|
+
* slug unless `preferredDriver` is given: then the first collection whose
|
|
79
|
+
* data source or engine is `preferredDriver` wins. Pass a reference's
|
|
80
|
+
* `driver`, or the data source of the record the path was read from.
|
|
81
|
+
*/
|
|
82
|
+
get(path: string, preferredDriver?: string): CollectionConfig | undefined;
|
|
83
|
+
/** Every collection {@link get} could answer `path` with, in its order. */
|
|
84
|
+
private candidatesFor;
|
|
85
|
+
/**
|
|
86
|
+
* The path a collection's rows are stored under, for the path the admin
|
|
87
|
+
* addresses it by.
|
|
88
|
+
*
|
|
89
|
+
* The admin addresses a collection by its slug — in routes, in
|
|
90
|
+
* `data.collection(...)`, in the `path` of every entity it lists — because
|
|
91
|
+
* the slug is what is unique. A Firestore or MongoDB collection may declare
|
|
92
|
+
* a `path` of its own ({@link getCollectionDataPath}), and its driver has to
|
|
93
|
+
* be handed that one, under every record and subcollection too:
|
|
94
|
+
* `fs_diagnosis/abc/locales` is stored at `diagnosis/abc/locales`.
|
|
95
|
+
*
|
|
96
|
+
* A path that names no registered collection, or runs only through
|
|
97
|
+
* collections stored under their slugs, comes back unchanged.
|
|
98
|
+
*/
|
|
99
|
+
resolveDataPath(path: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* The path the admin addresses a collection by, for a path its rows are
|
|
102
|
+
* stored under: the inverse of {@link resolveDataPath}, for a reference
|
|
103
|
+
* read back from its driver.
|
|
104
|
+
*
|
|
105
|
+
* The root is the longest leading run of segments naming a collection, and
|
|
106
|
+
* becomes its slug when the run is where that collection is stored. Each
|
|
107
|
+
* subcollection after a record id is matched by where it is stored too. A
|
|
108
|
+
* path that already names its collections by slug comes back unchanged.
|
|
109
|
+
*
|
|
110
|
+
* `preferredDriver` decides between a collection stored at the path and one
|
|
111
|
+
* whose slug it is, as in {@link get}.
|
|
112
|
+
*/
|
|
113
|
+
resolveCollectionPath(path: string, preferredDriver?: string): string;
|
|
57
114
|
/**
|
|
58
115
|
* Gets the pristine, un-normalized collection exactly as it was provided.
|
|
59
116
|
* Useful for the AST editor so it doesn't accidentally serialize injected metadata back to disk.
|
|
@@ -68,9 +125,21 @@ export declare class CollectionRegistry {
|
|
|
68
125
|
getRawCollections(): CollectionConfig[];
|
|
69
126
|
/**
|
|
70
127
|
* Resolves a multi-segment path like "products/123/locales" and returns
|
|
71
|
-
* information about the collections and entity IDs along the path
|
|
128
|
+
* information about the collections and entity IDs along the path.
|
|
129
|
+
*
|
|
130
|
+
* A slug may contain slashes (`content/de-DE/podcasts`), so the root is
|
|
131
|
+
* the longest leading run of segments naming a registered collection, and
|
|
132
|
+
* each subcollection is matched the same way among its parent's.
|
|
133
|
+
*
|
|
134
|
+
* @param options.allowRecordPath accept a path that ends at a record
|
|
135
|
+
* (`…/{id}`) and resolve it to the collection holding that record, with the
|
|
136
|
+
* id last in `entityIds`. Without it such a path is an error. Only the
|
|
137
|
+
* registry can tell the two shapes apart, because only it knows where each
|
|
138
|
+
* slug ends.
|
|
72
139
|
*/
|
|
73
|
-
resolvePathToCollections(path: string
|
|
140
|
+
resolvePathToCollections(path: string, options?: {
|
|
141
|
+
allowRecordPath?: boolean;
|
|
142
|
+
}): {
|
|
74
143
|
collections: CollectionConfig[];
|
|
75
144
|
entityIds: (string | number)[];
|
|
76
145
|
finalCollection: CollectionConfig;
|
|
@@ -17,8 +17,8 @@ export declare const defaultUsersCollection: import("@rebasepro/types").Postgres
|
|
|
17
17
|
} & {
|
|
18
18
|
id?: string | undefined;
|
|
19
19
|
metadata?: import("@rebasepro/types").InferEntityType<{}> | undefined;
|
|
20
|
-
photoURL?: string | undefined;
|
|
21
20
|
roles?: string[] | undefined;
|
|
21
|
+
photoURL?: string | undefined;
|
|
22
22
|
passwordHash?: string | undefined;
|
|
23
23
|
emailVerified?: boolean | undefined;
|
|
24
24
|
emailVerificationToken?: string | undefined;
|
|
@@ -60,6 +60,11 @@ export declare function canWriteField(property: Property | undefined, viewer: Fi
|
|
|
60
60
|
* who knows the table can send `password_hash` as readily as `passwordHash`, and
|
|
61
61
|
* a rule that only knew the wire name would be one rename away from useless.
|
|
62
62
|
*
|
|
63
|
+
* A restricted to-one relation takes its foreign key with it. `bandId: 7` names
|
|
64
|
+
* the band exactly as `band: { id: 7 }` does, and the row carries the column
|
|
65
|
+
* beside the relation — so a rule on the relation that left the key alone
|
|
66
|
+
* withheld the value from the row and still let `?bandId=7` ask for it.
|
|
67
|
+
*
|
|
63
68
|
* `kind` picks which half of the rule is read; nothing else differs.
|
|
64
69
|
*/
|
|
65
70
|
export declare function restrictedFieldNames(collection: CollectionConfig, viewer: FieldViewer | undefined, kind: "read" | "write"): {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CollectionConfig } from "@rebasepro/types";
|
|
2
|
+
/** The field `softDelete: true` means, when the object form names none. */
|
|
3
|
+
export declare const DEFAULT_SOFT_DELETE_FIELD = "deletedAt";
|
|
4
|
+
/**
|
|
5
|
+
* The property a `softDelete` collection records a deletion in — its wire
|
|
6
|
+
* name, what a delete stamps and what a restore (an update to `null`) clears —
|
|
7
|
+
* or `undefined` for a collection without soft delete.
|
|
8
|
+
*
|
|
9
|
+
* One reading of the declaration for every layer that needs it: the driver
|
|
10
|
+
* that stamps and filters on it, and the REST route that has to recognise a
|
|
11
|
+
* restore before it looks the row up.
|
|
12
|
+
*/
|
|
13
|
+
export declare function softDeleteFieldOf(collection: CollectionConfig | undefined): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Whether an update's values restore a soft-deleted row: they set the
|
|
16
|
+
* soft-delete field back to `null`, the documented restore.
|
|
17
|
+
*
|
|
18
|
+
* A restore is an ordinary update of a row every default read hides, so a door
|
|
19
|
+
* that looks the row up before updating it has to include the trashed rows for
|
|
20
|
+
* this update — and only for this one: any other edit of a trashed row is a
|
|
21
|
+
* 404.
|
|
22
|
+
*/
|
|
23
|
+
export declare function restoresSoftDeletedRow(collection: CollectionConfig | undefined, values: Record<string, unknown> | undefined): boolean;
|
|
@@ -22,6 +22,21 @@ export interface EntityDataOptions {
|
|
|
22
22
|
relations?: unknown[];
|
|
23
23
|
slug?: string;
|
|
24
24
|
} | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Translate the path a collection is addressed by into the path its driver
|
|
27
|
+
* stores it under.
|
|
28
|
+
*
|
|
29
|
+
* The admin addresses every collection by its slug, and a Firestore or
|
|
30
|
+
* MongoDB collection may declare a `path` of its own: `fs_diagnosis` stored
|
|
31
|
+
* at `diagnosis`, and `fs_diagnosis/abc/locales` at `diagnosis/abc/locales`.
|
|
32
|
+
* Only the driver is handed the stored path. Rows keep the address they
|
|
33
|
+
* were asked for by, because that is what the admin resolves their
|
|
34
|
+
* collection, routes and deletes by.
|
|
35
|
+
*
|
|
36
|
+
* Late-bound, like `resolveCollection`. Absent, or answering `undefined`,
|
|
37
|
+
* the address is the stored path.
|
|
38
|
+
*/
|
|
39
|
+
resolveDataPath?: (path: string) => string | undefined;
|
|
25
40
|
}
|
|
26
41
|
export declare function buildRebaseData(driver: DataDriver, options?: EntityDataOptions): RebaseData;
|
|
27
42
|
/**
|
package/dist/data/cursor.d.ts
CHANGED
|
@@ -64,6 +64,19 @@ export declare class UnknownFilterOperatorError extends Error {
|
|
|
64
64
|
};
|
|
65
65
|
constructor(field: string, operator: string);
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The query-parameter names a REST listing reads as something other than a
|
|
69
|
+
* field filter: pagination, sorting, includes, projection, search, the logical
|
|
70
|
+
* groups, the JSON `where` dialect, an aggregate's `select`/`groupBy`, and the
|
|
71
|
+
* soft-delete switches.
|
|
72
|
+
*
|
|
73
|
+
* One list for both ends. The server skips these names when it collects
|
|
74
|
+
* `?<field>=<op>.<value>` filters, and the SDK sends a filter on a column with
|
|
75
|
+
* one of these names inside `?where=` instead — a collection is free to have a
|
|
76
|
+
* `page`, `select` or `hard` column, and a filter on it sent as its own
|
|
77
|
+
* parameter was read as the parameter and never applied.
|
|
78
|
+
*/
|
|
79
|
+
export declare const RESERVED_QUERY_KEYS: ReadonlySet<string>;
|
|
67
80
|
/**
|
|
68
81
|
* Convert `FilterValues` (or `WireFilterValues`) to a PostgREST-style
|
|
69
82
|
* querystring record.
|