@rebasepro/common 0.23.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/data/buildRebaseData.d.ts +15 -0
- package/dist/data/cursor.d.ts +1 -1
- package/dist/index.es.js +410 -57
- 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 +1 -0
- package/dist/util/untrusted-envelope.d.ts +25 -0
- package/package.json +3 -3
|
@@ -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;
|
|
@@ -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