@rebasepro/types 0.8.0 → 0.9.1-canary.09aaf62
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/README.md +13 -13
- package/dist/controllers/auth.d.ts +7 -1
- package/dist/controllers/client.d.ts +204 -6
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +309 -35
- package/dist/controllers/data_driver.d.ts +92 -37
- package/dist/controllers/email.d.ts +2 -2
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +2 -2
- package/dist/controllers/registry.d.ts +21 -8
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
- package/dist/controllers/storage.d.ts +39 -0
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +160 -15
- package/dist/index.es.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +29 -4
- package/dist/types/backend.d.ts +33 -26
- package/dist/types/backup.d.ts +20 -0
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +84 -75
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +11 -2
- package/dist/types/data_source.d.ts +15 -2
- package/dist/types/database_adapter.d.ts +21 -4
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +39 -39
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +62 -17
- package/dist/types/index.d.ts +1 -0
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +111 -11
- package/dist/types/properties.d.ts +54 -9
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/translations.d.ts +5 -1
- package/dist/types/user_management_delegate.d.ts +8 -2
- package/dist/types/websockets.d.ts +46 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +5 -6
- package/src/controllers/auth.tsx +7 -1
- package/src/controllers/client.ts +235 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +330 -39
- package/src/controllers/data_driver.ts +93 -40
- package/src/controllers/email.ts +2 -2
- package/src/controllers/index.ts +1 -1
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +2 -2
- package/src/controllers/registry.ts +22 -8
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
- package/src/controllers/storage.ts +60 -1
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -0
- package/src/rebase_context.tsx +8 -4
- package/src/types/auth_adapter.ts +29 -4
- package/src/types/backend.ts +44 -36
- package/src/types/backup.ts +26 -0
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +101 -91
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +11 -2
- package/src/types/data_source.ts +24 -2
- package/src/types/database_adapter.ts +19 -4
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +42 -42
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +96 -23
- package/src/types/index.ts +1 -0
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +114 -9
- package/src/types/properties.ts +58 -9
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/translations.ts +5 -1
- package/src/types/user_management_delegate.ts +8 -2
- package/src/types/websockets.ts +43 -14
- package/src/users/user.ts +22 -9
- package/dist/index.umd.js +0 -458
- package/dist/index.umd.js.map +0 -1
package/src/types/websockets.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Entity } from "./entities";
|
|
2
|
-
|
|
3
1
|
export interface WebSocketErrorPayload {
|
|
4
2
|
error?: string | { message: string; code?: string };
|
|
5
3
|
message?: string;
|
|
@@ -11,35 +9,66 @@ export interface WebSocketMessage {
|
|
|
11
9
|
payload?: unknown;
|
|
12
10
|
subscriptionId?: string;
|
|
13
11
|
requestId?: string;
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
rows?: Record<string, unknown>[];
|
|
13
|
+
row?: Record<string, unknown> | null;
|
|
16
14
|
error?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Channel name, on broadcast and presence frames.
|
|
17
|
+
*
|
|
18
|
+
* These are addressed by channel rather than by `requestId` or
|
|
19
|
+
* `subscriptionId`, so this is the only field that routes them.
|
|
20
|
+
*/
|
|
21
|
+
channel?: string;
|
|
17
22
|
}
|
|
18
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The key columns a collection's rows are addressed by.
|
|
26
|
+
*
|
|
27
|
+
* A row is exactly its columns and carries no address, so a subscriber that has
|
|
28
|
+
* to recognise one — to patch it, or to keep its reference across a refetch —
|
|
29
|
+
* derives the address from these. The SDK is usable with no collections
|
|
30
|
+
* declared at all, so the server is the only side that knows them.
|
|
31
|
+
*
|
|
32
|
+
* Undefined when the server cannot resolve them: a table with no primary key
|
|
33
|
+
* and no `id` column has no address, and rows of it cannot be recognised by
|
|
34
|
+
* anyone.
|
|
35
|
+
*/
|
|
36
|
+
export type WirePrimaryKeys = { fieldName: string; type: "string" | "number"; isUUID?: boolean }[];
|
|
37
|
+
|
|
19
38
|
export interface CollectionUpdateMessage extends WebSocketMessage {
|
|
20
39
|
type: "collection_update";
|
|
21
40
|
subscriptionId: string;
|
|
22
|
-
|
|
41
|
+
rows: Record<string, unknown>[];
|
|
42
|
+
/**
|
|
43
|
+
* See {@link WirePrimaryKeys}. Sent with the rows themselves — and not only
|
|
44
|
+
* with a patch — because a CDC-originated change sends no patch at all: it
|
|
45
|
+
* invalidates and goes straight to a refetch, and the merge that preserves
|
|
46
|
+
* unchanged rows' references needs an address to match them by.
|
|
47
|
+
*/
|
|
48
|
+
pks?: WirePrimaryKeys;
|
|
23
49
|
}
|
|
24
50
|
|
|
25
|
-
export interface
|
|
26
|
-
type: "
|
|
51
|
+
export interface SingleUpdateMessage extends WebSocketMessage {
|
|
52
|
+
type: "single_update";
|
|
27
53
|
subscriptionId: string;
|
|
28
|
-
|
|
54
|
+
row: Record<string, unknown> | null;
|
|
29
55
|
}
|
|
30
56
|
|
|
31
57
|
/**
|
|
32
58
|
* Lightweight patch message sent to collection subscribers when a single
|
|
33
|
-
*
|
|
59
|
+
* row is created, updated, or deleted. The client can merge this into
|
|
34
60
|
* its cached collection data for near-instant cross-tab updates without
|
|
35
61
|
* waiting for a full collection refetch.
|
|
36
62
|
*/
|
|
37
|
-
export interface
|
|
38
|
-
type: "
|
|
63
|
+
export interface CollectionPatchMessage extends WebSocketMessage {
|
|
64
|
+
type: "collection_patch";
|
|
39
65
|
subscriptionId: string;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
66
|
+
/** The address of the row this patch refers to — derived, never read off it. */
|
|
67
|
+
id: string;
|
|
68
|
+
/** The updated row, or null if deleted */
|
|
69
|
+
row: Record<string, unknown> | null;
|
|
70
|
+
/** See {@link WirePrimaryKeys}: how the subscriber finds {@link id} in its cache. */
|
|
71
|
+
pks?: WirePrimaryKeys;
|
|
43
72
|
}
|
|
44
73
|
|
|
45
74
|
/**
|
package/src/users/user.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
* The canonical representation of an authenticated user in the Rebase ecosystem.
|
|
4
|
+
*
|
|
5
|
+
* Used by {@link AuthController}, collections, callbacks, and both the
|
|
6
|
+
* `@rebasepro/client` and `@rebasepro/app` packages. All other user types
|
|
7
|
+
* (`RebaseUser`, `UserInfo`) are deprecated aliases of this type.
|
|
8
|
+
*
|
|
9
|
+
* **Backend-managed fields** (`uid`, `email`, `roles`, `metadata`, `createdAt`)
|
|
10
|
+
* are populated by the server. **Client-visible fields** (`displayName`,
|
|
11
|
+
* `photoURL`, `providerId`, `isAnonymous`, `emailVerified`) may be set during
|
|
12
|
+
* authentication or profile updates.
|
|
13
|
+
*
|
|
14
|
+
* @see AdminUser — the admin-API DTO, which adds audit fields (`createdAt`,
|
|
15
|
+
* `updatedAt`) and required `roles`.
|
|
9
16
|
*
|
|
10
17
|
* @group Models
|
|
11
18
|
*/
|
|
@@ -27,16 +34,22 @@ export type User = {
|
|
|
27
34
|
*/
|
|
28
35
|
readonly photoURL: string | null;
|
|
29
36
|
/**
|
|
30
|
-
* The provider used to authenticate the user.
|
|
37
|
+
* The provider used to authenticate the user (e.g. `"password"`,
|
|
38
|
+
* `"google"`, `"github"`).
|
|
31
39
|
*/
|
|
32
40
|
readonly providerId: string;
|
|
33
41
|
/**
|
|
34
|
-
*
|
|
42
|
+
* Whether the user is anonymous (created via anonymous sign-in).
|
|
35
43
|
*/
|
|
36
44
|
readonly isAnonymous: boolean;
|
|
37
45
|
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* Whether the user's email address has been verified.
|
|
48
|
+
*/
|
|
49
|
+
readonly emailVerified?: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Role IDs assigned to this user (e.g. `["admin", "editor"]`).
|
|
40
53
|
*/
|
|
41
54
|
roles?: string[];
|
|
42
55
|
|
package/dist/index.umd.js
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["Rebase Types"] = {}));
|
|
3
|
-
})(this, function(exports) {
|
|
4
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
|
-
//#region src/types/entities.ts
|
|
6
|
-
/**
|
|
7
|
-
* Class used to create a reference to an entity in a different path.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Simple reference (most common case - single driver, single db)
|
|
11
|
-
* new EntityReference({ id: "123", path: "users" })
|
|
12
|
-
*
|
|
13
|
-
* // Reference to a different driver (e.g., Firestore)
|
|
14
|
-
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
15
|
-
*
|
|
16
|
-
* // Reference to a specific database within a driver
|
|
17
|
-
* new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
|
|
18
|
-
*/
|
|
19
|
-
var EntityReference = class {
|
|
20
|
-
__type = "reference";
|
|
21
|
-
/**
|
|
22
|
-
* ID of the entity
|
|
23
|
-
*/
|
|
24
|
-
id;
|
|
25
|
-
/**
|
|
26
|
-
* A string representing the path of the referenced document (relative
|
|
27
|
-
* to the root of the database).
|
|
28
|
-
*/
|
|
29
|
-
path;
|
|
30
|
-
/**
|
|
31
|
-
* Which driver (e.g., 'postgres', 'firestore').
|
|
32
|
-
* Defaults to "(default)" if not specified.
|
|
33
|
-
*/
|
|
34
|
-
driver;
|
|
35
|
-
/**
|
|
36
|
-
* Which database within the driver.
|
|
37
|
-
* Defaults to "(default)" if not specified.
|
|
38
|
-
*/
|
|
39
|
-
databaseId;
|
|
40
|
-
/**
|
|
41
|
-
* Create a reference to an entity.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* // Simple reference (most common case)
|
|
45
|
-
* new EntityReference({ id: "123", path: "users" })
|
|
46
|
-
*
|
|
47
|
-
* // With driver
|
|
48
|
-
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
49
|
-
*/
|
|
50
|
-
constructor(props) {
|
|
51
|
-
this.id = props.id;
|
|
52
|
-
this.path = props.path;
|
|
53
|
-
this.driver = props.driver;
|
|
54
|
-
this.databaseId = props.databaseId;
|
|
55
|
-
}
|
|
56
|
-
get pathWithId() {
|
|
57
|
-
return `${this.path}/${this.id}`;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get the full path including driver and database prefixes if specified.
|
|
61
|
-
* For the common case (single driver, single db), this just returns pathWithId.
|
|
62
|
-
*/
|
|
63
|
-
get fullPath() {
|
|
64
|
-
const parts = [];
|
|
65
|
-
if (this.driver && this.driver !== "(default)") parts.push(this.driver);
|
|
66
|
-
if (this.databaseId && this.databaseId !== "(default)") parts.push(this.databaseId);
|
|
67
|
-
if (parts.length > 0) return `${parts.join(":")}:::${this.path}/${this.id}`;
|
|
68
|
-
return this.pathWithId;
|
|
69
|
-
}
|
|
70
|
-
isEntityReference() {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Class used to create a reference to an entity in a different path
|
|
76
|
-
*/
|
|
77
|
-
var EntityRelation = class {
|
|
78
|
-
__type = "relation";
|
|
79
|
-
/**
|
|
80
|
-
* ID of the entity
|
|
81
|
-
*/
|
|
82
|
-
id;
|
|
83
|
-
/**
|
|
84
|
-
* A string representing the path of the referenced document (relative
|
|
85
|
-
* to the root of the database).
|
|
86
|
-
*/
|
|
87
|
-
path;
|
|
88
|
-
/**
|
|
89
|
-
* Pre-fetched data payload to eliminate N+1 queries.
|
|
90
|
-
* When present, clients can use this directly instead of fetching.
|
|
91
|
-
*/
|
|
92
|
-
data;
|
|
93
|
-
constructor(id, path, data) {
|
|
94
|
-
this.id = id;
|
|
95
|
-
this.path = path;
|
|
96
|
-
this.data = data;
|
|
97
|
-
}
|
|
98
|
-
get pathWithId() {
|
|
99
|
-
return `${this.path}/${this.id}`;
|
|
100
|
-
}
|
|
101
|
-
isEntityReference() {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
isEntityRelation() {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var GeoPoint = class {
|
|
109
|
-
/**
|
|
110
|
-
* The latitude of this GeoPoint instance.
|
|
111
|
-
*/
|
|
112
|
-
latitude;
|
|
113
|
-
/**
|
|
114
|
-
* The longitude of this GeoPoint instance.
|
|
115
|
-
*/
|
|
116
|
-
longitude;
|
|
117
|
-
constructor(latitude, longitude) {
|
|
118
|
-
this.latitude = latitude;
|
|
119
|
-
this.longitude = longitude;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
var Vector = class {
|
|
123
|
-
value;
|
|
124
|
-
constructor(value) {
|
|
125
|
-
this.value = value;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
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
|
|
184
|
-
//#region src/types/collections.ts
|
|
185
|
-
/**
|
|
186
|
-
* Type guard for PostgreSQL collections.
|
|
187
|
-
* Returns true if the collection uses the Postgres engine (or the default engine).
|
|
188
|
-
* @group Models
|
|
189
|
-
*/
|
|
190
|
-
function isPostgresCollection(collection) {
|
|
191
|
-
return !collection.engine || collection.engine === "postgres";
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Type guard for Firebase / Firestore collections.
|
|
195
|
-
* @group Models
|
|
196
|
-
*/
|
|
197
|
-
function isFirebaseCollection(collection) {
|
|
198
|
-
return collection.engine === "firestore";
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Type guard for MongoDB collections.
|
|
202
|
-
* @group Models
|
|
203
|
-
*/
|
|
204
|
-
function isMongoDBCollection(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;
|
|
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
|
-
};
|
|
278
|
-
//#endregion
|
|
279
|
-
//#region src/types/backend.ts
|
|
280
|
-
/**
|
|
281
|
-
* Type guard: does this admin support SQL operations?
|
|
282
|
-
* @group Admin
|
|
283
|
-
*/
|
|
284
|
-
function isSQLAdmin(admin) {
|
|
285
|
-
return !!admin && typeof admin.executeSql === "function";
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Type guard: does this admin support document operations?
|
|
289
|
-
* @group Admin
|
|
290
|
-
*/
|
|
291
|
-
function isDocumentAdmin(admin) {
|
|
292
|
-
return !!admin && (typeof admin.executeAggregate === "function" || typeof admin.fetchCollectionStats === "function");
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Type guard: does this admin support schema management?
|
|
296
|
-
* @group Admin
|
|
297
|
-
*/
|
|
298
|
-
function isSchemaAdmin(admin) {
|
|
299
|
-
return !!admin && (typeof admin.fetchUnmappedTables === "function" || typeof admin.fetchTableMetadata === "function");
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Type guard: does this admin support database branching?
|
|
303
|
-
* @group Admin
|
|
304
|
-
*/
|
|
305
|
-
function isBranchAdmin(admin) {
|
|
306
|
-
return !!admin && typeof admin.createBranch === "function";
|
|
307
|
-
}
|
|
308
|
-
//#endregion
|
|
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)";
|
|
317
|
-
/** @group Models */
|
|
318
|
-
var POSTGRES_CAPABILITIES = {
|
|
319
|
-
key: "postgres",
|
|
320
|
-
label: "PostgreSQL",
|
|
321
|
-
supportsRelations: true,
|
|
322
|
-
supportsSubcollections: false,
|
|
323
|
-
supportsRLS: true,
|
|
324
|
-
supportsReferences: false,
|
|
325
|
-
supportsColumnTypes: true,
|
|
326
|
-
supportsRealtime: true,
|
|
327
|
-
supportsSQLAdmin: true,
|
|
328
|
-
supportsDocumentAdmin: false,
|
|
329
|
-
supportsSchemaAdmin: true
|
|
330
|
-
};
|
|
331
|
-
/** @group Models */
|
|
332
|
-
var FIREBASE_CAPABILITIES = {
|
|
333
|
-
key: "firestore",
|
|
334
|
-
label: "Firebase / Firestore",
|
|
335
|
-
supportsRelations: false,
|
|
336
|
-
supportsSubcollections: true,
|
|
337
|
-
supportsRLS: false,
|
|
338
|
-
supportsReferences: true,
|
|
339
|
-
supportsColumnTypes: false,
|
|
340
|
-
supportsRealtime: true,
|
|
341
|
-
supportsSQLAdmin: false,
|
|
342
|
-
supportsDocumentAdmin: false,
|
|
343
|
-
supportsSchemaAdmin: false
|
|
344
|
-
};
|
|
345
|
-
/** @group Models */
|
|
346
|
-
var MONGODB_CAPABILITIES = {
|
|
347
|
-
key: "mongodb",
|
|
348
|
-
label: "MongoDB",
|
|
349
|
-
supportsRelations: false,
|
|
350
|
-
supportsSubcollections: true,
|
|
351
|
-
supportsRLS: false,
|
|
352
|
-
supportsReferences: true,
|
|
353
|
-
supportsColumnTypes: false,
|
|
354
|
-
supportsRealtime: false,
|
|
355
|
-
supportsSQLAdmin: false,
|
|
356
|
-
supportsDocumentAdmin: true,
|
|
357
|
-
supportsSchemaAdmin: true
|
|
358
|
-
};
|
|
359
|
-
/**
|
|
360
|
-
* Fallback capabilities when the driver is unknown.
|
|
361
|
-
* Enables everything so nothing is hidden unexpectedly.
|
|
362
|
-
* @group Models
|
|
363
|
-
*/
|
|
364
|
-
var DEFAULT_CAPABILITIES = {
|
|
365
|
-
key: "(default)",
|
|
366
|
-
label: "Default",
|
|
367
|
-
supportsRelations: true,
|
|
368
|
-
supportsSubcollections: true,
|
|
369
|
-
supportsRLS: true,
|
|
370
|
-
supportsReferences: true,
|
|
371
|
-
supportsColumnTypes: true,
|
|
372
|
-
supportsRealtime: true,
|
|
373
|
-
supportsSQLAdmin: true,
|
|
374
|
-
supportsDocumentAdmin: true,
|
|
375
|
-
supportsSchemaAdmin: true
|
|
376
|
-
};
|
|
377
|
-
var CAPABILITIES_REGISTRY = {
|
|
378
|
-
postgres: POSTGRES_CAPABILITIES,
|
|
379
|
-
firestore: FIREBASE_CAPABILITIES,
|
|
380
|
-
mongodb: MONGODB_CAPABILITIES,
|
|
381
|
-
"(default)": DEFAULT_CAPABILITIES
|
|
382
|
-
};
|
|
383
|
-
/**
|
|
384
|
-
* Look up capabilities for a given engine key.
|
|
385
|
-
* If `engine` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
386
|
-
* @group Models
|
|
387
|
-
*/
|
|
388
|
-
function getDataSourceCapabilities(engine) {
|
|
389
|
-
if (!engine) return POSTGRES_CAPABILITIES;
|
|
390
|
-
return CAPABILITIES_REGISTRY[engine] ?? DEFAULT_CAPABILITIES;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Register custom capabilities for a third-party driver.
|
|
394
|
-
* @group Models
|
|
395
|
-
*/
|
|
396
|
-
function registerDataSourceCapabilities(capabilities) {
|
|
397
|
-
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
398
|
-
}
|
|
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
|
|
421
|
-
//#region src/types/component_ref.ts
|
|
422
|
-
/**
|
|
423
|
-
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
424
|
-
* Vite transform plugin.
|
|
425
|
-
*/
|
|
426
|
-
function isLazyComponentRef(ref) {
|
|
427
|
-
return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
|
|
428
|
-
}
|
|
429
|
-
//#endregion
|
|
430
|
-
exports.CANONICAL_TO_REST = CANONICAL_TO_REST;
|
|
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;
|
|
434
|
-
exports.EntityReference = EntityReference;
|
|
435
|
-
exports.EntityRelation = EntityRelation;
|
|
436
|
-
exports.FIREBASE_CAPABILITIES = FIREBASE_CAPABILITIES;
|
|
437
|
-
exports.GeoPoint = GeoPoint;
|
|
438
|
-
exports.MONGODB_CAPABILITIES = MONGODB_CAPABILITIES;
|
|
439
|
-
exports.POSTGRES_CAPABILITIES = POSTGRES_CAPABILITIES;
|
|
440
|
-
exports.REST_TO_CANONICAL = REST_TO_CANONICAL;
|
|
441
|
-
exports.Vector = Vector;
|
|
442
|
-
exports.getCollectionDataPath = getCollectionDataPath;
|
|
443
|
-
exports.getDataSourceCapabilities = getDataSourceCapabilities;
|
|
444
|
-
exports.getDeclaredSubcollections = getDeclaredSubcollections;
|
|
445
|
-
exports.isBranchAdmin = isBranchAdmin;
|
|
446
|
-
exports.isDocumentAdmin = isDocumentAdmin;
|
|
447
|
-
exports.isFirebaseCollection = isFirebaseCollection;
|
|
448
|
-
exports.isLazyComponentRef = isLazyComponentRef;
|
|
449
|
-
exports.isMongoDBCollection = isMongoDBCollection;
|
|
450
|
-
exports.isPostgresCollection = isPostgresCollection;
|
|
451
|
-
exports.isSQLAdmin = isSQLAdmin;
|
|
452
|
-
exports.isSchemaAdmin = isSchemaAdmin;
|
|
453
|
-
exports.policy = policy;
|
|
454
|
-
exports.registerDataSourceCapabilities = registerDataSourceCapabilities;
|
|
455
|
-
exports.toCanonicalOp = toCanonicalOp;
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
//# sourceMappingURL=index.umd.js.map
|