@rebasepro/server-postgres 0.0.1-canary.4829d6e
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/LICENSE +22 -0
- package/README.md +86 -0
- package/dist/PostgresAdapter.d.ts +6 -0
- package/dist/PostgresBackendDriver.d.ts +150 -0
- package/dist/PostgresBootstrapper.d.ts +51 -0
- package/dist/auth/ensure-tables.d.ts +10 -0
- package/dist/auth/services.d.ts +250 -0
- package/dist/backup/backup-cli.d.ts +3 -0
- package/dist/backup/backup-cron.d.ts +53 -0
- package/dist/backup/backup-service.d.ts +85 -0
- package/dist/backup/index.d.ts +12 -0
- package/dist/backup/pg-tools.d.ts +110 -0
- package/dist/backup/retention.d.ts +35 -0
- package/dist/chunk-DSJWtz9O.js +40 -0
- package/dist/cli-errors.d.ts +42 -0
- package/dist/cli-helpers.d.ts +7 -0
- package/dist/cli.d.ts +1 -0
- package/dist/collections/PostgresCollectionRegistry.d.ts +47 -0
- package/dist/connection.d.ts +65 -0
- package/dist/data-transformer.d.ts +55 -0
- package/dist/databasePoolManager.d.ts +20 -0
- package/dist/history/HistoryService.d.ts +71 -0
- package/dist/history/ensure-history-table.d.ts +7 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.es.js +23535 -0
- package/dist/index.es.js.map +1 -0
- package/dist/interfaces.d.ts +18 -0
- package/dist/schema/auth-bootstrap-sql.d.ts +24 -0
- package/dist/schema/auth-default-policies.d.ts +10 -0
- package/dist/schema/auth-schema.d.ts +2376 -0
- package/dist/schema/doctor-cli.d.ts +2 -0
- package/dist/schema/doctor.d.ts +58 -0
- package/dist/schema/dynamic-tables.d.ts +31 -0
- package/dist/schema/generate-drizzle-schema-logic.d.ts +2 -0
- package/dist/schema/generate-drizzle-schema.d.ts +1 -0
- package/dist/schema/generate-postgres-ddl-logic.d.ts +5 -0
- package/dist/schema/generate-postgres-ddl.d.ts +1 -0
- package/dist/schema/introspect-db-inference.d.ts +5 -0
- package/dist/schema/introspect-db-logic.d.ts +118 -0
- package/dist/schema/introspect-db.d.ts +1 -0
- package/dist/schema/introspect-runtime.d.ts +57 -0
- package/dist/schema/test-schema.d.ts +24 -0
- package/dist/security/policy-drift.d.ts +57 -0
- package/dist/security/rls-enforcement.d.ts +122 -0
- package/dist/services/BranchService.d.ts +47 -0
- package/dist/services/FetchService.d.ts +214 -0
- package/dist/services/PersistService.d.ts +39 -0
- package/dist/services/RelationService.d.ts +109 -0
- package/dist/services/cdc/CdcListener.d.ts +54 -0
- package/dist/services/cdc/trigger-cdc.d.ts +64 -0
- package/dist/services/collection-helpers.d.ts +38 -0
- package/dist/services/dataService.d.ts +110 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/realtimeService.d.ts +298 -0
- package/dist/src-Eh-CZosp.js +595 -0
- package/dist/src-Eh-CZosp.js.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/utils/drizzle-conditions.d.ts +138 -0
- package/dist/utils/pg-array-null-patch.d.ts +16 -0
- package/dist/utils/pg-error-utils.d.ts +65 -0
- package/dist/utils/table-classification.d.ts +8 -0
- package/dist/websocket.d.ts +18 -0
- package/package.json +113 -0
- package/src/PostgresAdapter.ts +58 -0
- package/src/PostgresBackendDriver.ts +1387 -0
- package/src/PostgresBootstrapper.ts +581 -0
- package/src/auth/ensure-tables.ts +367 -0
- package/src/auth/services.ts +1321 -0
- package/src/backup/backup-cli.ts +383 -0
- package/src/backup/backup-cron.ts +189 -0
- package/src/backup/backup-service.ts +299 -0
- package/src/backup/index.ts +12 -0
- package/src/backup/pg-tools.ts +231 -0
- package/src/backup/retention.ts +75 -0
- package/src/cli-errors.ts +265 -0
- package/src/cli-helpers.ts +196 -0
- package/src/cli.ts +786 -0
- package/src/collections/PostgresCollectionRegistry.ts +103 -0
- package/src/connection.ts +166 -0
- package/src/data-transformer.ts +733 -0
- package/src/databasePoolManager.ts +87 -0
- package/src/history/HistoryService.ts +272 -0
- package/src/history/ensure-history-table.ts +46 -0
- package/src/index.ts +15 -0
- package/src/interfaces.ts +60 -0
- package/src/schema/auth-bootstrap-sql.ts +41 -0
- package/src/schema/auth-default-policies.ts +125 -0
- package/src/schema/auth-schema.ts +233 -0
- package/src/schema/doctor-cli.ts +113 -0
- package/src/schema/doctor.ts +733 -0
- package/src/schema/dynamic-tables.test.ts +302 -0
- package/src/schema/dynamic-tables.ts +293 -0
- package/src/schema/generate-drizzle-schema-logic.ts +850 -0
- package/src/schema/generate-drizzle-schema.ts +131 -0
- package/src/schema/generate-postgres-ddl-logic.ts +490 -0
- package/src/schema/generate-postgres-ddl.ts +92 -0
- package/src/schema/introspect-db-inference.ts +238 -0
- package/src/schema/introspect-db-logic.ts +910 -0
- package/src/schema/introspect-db.ts +266 -0
- package/src/schema/introspect-runtime.test.ts +212 -0
- package/src/schema/introspect-runtime.ts +293 -0
- package/src/schema/test-schema.ts +11 -0
- package/src/security/policy-drift.test.ts +122 -0
- package/src/security/policy-drift.ts +159 -0
- package/src/security/rls-enforcement.ts +295 -0
- package/src/services/BranchService.ts +251 -0
- package/src/services/FetchService.ts +1661 -0
- package/src/services/PersistService.ts +329 -0
- package/src/services/RelationService.ts +1306 -0
- package/src/services/cdc/CdcListener.ts +167 -0
- package/src/services/cdc/trigger-cdc.ts +169 -0
- package/src/services/collection-helpers.ts +151 -0
- package/src/services/dataService.ts +246 -0
- package/src/services/index.ts +13 -0
- package/src/services/realtimeService.ts +1502 -0
- package/src/types.ts +4 -0
- package/src/utils/drizzle-conditions.ts +1162 -0
- package/src/utils/pg-array-null-patch.ts +42 -0
- package/src/utils/pg-error-utils.ts +227 -0
- package/src/utils/table-classification.ts +16 -0
- package/src/websocket.ts +640 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
import "process";
|
|
3
|
+
__createRequire(import.meta.url);
|
|
4
|
+
import { n as __exportAll } from "./chunk-DSJWtz9O.js";
|
|
5
|
+
//#region ../types/src/errors.ts
|
|
6
|
+
/**
|
|
7
|
+
* The single error type thrown across the entire Rebase client surface —
|
|
8
|
+
* HTTP data/control-plane calls, realtime/WebSocket operations, and
|
|
9
|
+
* client-side logic errors (e.g. an unknown collection accessor). A `catch`
|
|
10
|
+
* block only ever needs to check for this one class:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { RebaseApiError } from "@rebasepro/client"; // re-exported
|
|
14
|
+
*
|
|
15
|
+
* try {
|
|
16
|
+
* await client.data.products.update(id, { price: 9 });
|
|
17
|
+
* } catch (e) {
|
|
18
|
+
* if (e instanceof RebaseApiError) {
|
|
19
|
+
* if (e.status === 404) { ... } // HTTP failures carry a status
|
|
20
|
+
* console.error(e.code, e.details);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `status` is present for HTTP failures and `undefined` otherwise, so its
|
|
26
|
+
* presence distinguishes transport-level errors from realtime/logic errors.
|
|
27
|
+
*
|
|
28
|
+
* @group Errors
|
|
29
|
+
*/
|
|
30
|
+
var RebaseApiError = class extends Error {
|
|
31
|
+
/** HTTP status code, or `undefined` for non-HTTP errors. */
|
|
32
|
+
status;
|
|
33
|
+
/** Stable machine-readable error code, when the server supplied one. */
|
|
34
|
+
code;
|
|
35
|
+
/** Structured error payload from the server, when present. */
|
|
36
|
+
details;
|
|
37
|
+
constructor(message, init = {}) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "RebaseApiError";
|
|
40
|
+
this.status = init.status;
|
|
41
|
+
this.code = init.code;
|
|
42
|
+
this.details = init.details;
|
|
43
|
+
if (init.cause !== void 0) this.cause = init.cause;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Client-side logic error — raised before any request is made (e.g. accessing
|
|
48
|
+
* an unknown collection accessor when a typed dictionary is configured).
|
|
49
|
+
*
|
|
50
|
+
* A subclass of {@link RebaseApiError} (with no `status`), so a single
|
|
51
|
+
* `catch (e) { if (e instanceof RebaseApiError) ... }` handles it too.
|
|
52
|
+
*
|
|
53
|
+
* @group Errors
|
|
54
|
+
*/
|
|
55
|
+
var RebaseClientError = class extends RebaseApiError {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = "RebaseClientError";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../types/src/types/entities.ts
|
|
63
|
+
/**
|
|
64
|
+
* Class used to create a reference to a entity in a different path.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Simple reference (most common case - single driver, single db)
|
|
68
|
+
* new EntityReference({ id: "123", path: "users" })
|
|
69
|
+
*
|
|
70
|
+
* // Reference to a different driver (e.g., Firestore)
|
|
71
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
72
|
+
*
|
|
73
|
+
* // Reference to a specific database within a driver
|
|
74
|
+
* new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
|
|
75
|
+
*/
|
|
76
|
+
var EntityReference = class {
|
|
77
|
+
__type = "reference";
|
|
78
|
+
/**
|
|
79
|
+
* ID of the entity
|
|
80
|
+
*/
|
|
81
|
+
id;
|
|
82
|
+
/**
|
|
83
|
+
* A string representing the path of the referenced document (relative
|
|
84
|
+
* to the root of the database).
|
|
85
|
+
*/
|
|
86
|
+
path;
|
|
87
|
+
/**
|
|
88
|
+
* Which driver (e.g., 'postgres', 'firestore').
|
|
89
|
+
* Defaults to "(default)" if not specified.
|
|
90
|
+
*/
|
|
91
|
+
driver;
|
|
92
|
+
/**
|
|
93
|
+
* Which database within the driver.
|
|
94
|
+
* Defaults to "(default)" if not specified.
|
|
95
|
+
*/
|
|
96
|
+
databaseId;
|
|
97
|
+
/**
|
|
98
|
+
* Create a reference to a entity.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* // Simple reference (most common case)
|
|
102
|
+
* new EntityReference({ id: "123", path: "users" })
|
|
103
|
+
*
|
|
104
|
+
* // With driver
|
|
105
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
106
|
+
*/
|
|
107
|
+
constructor(props) {
|
|
108
|
+
this.id = props.id;
|
|
109
|
+
this.path = props.path;
|
|
110
|
+
this.driver = props.driver;
|
|
111
|
+
this.databaseId = props.databaseId;
|
|
112
|
+
}
|
|
113
|
+
get pathWithId() {
|
|
114
|
+
return `${this.path}/${this.id}`;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get the full path including driver and database prefixes if specified.
|
|
118
|
+
* For the common case (single driver, single db), this just returns pathWithId.
|
|
119
|
+
*/
|
|
120
|
+
get fullPath() {
|
|
121
|
+
const parts = [];
|
|
122
|
+
if (this.driver && this.driver !== "(default)") parts.push(this.driver);
|
|
123
|
+
if (this.databaseId && this.databaseId !== "(default)") parts.push(this.databaseId);
|
|
124
|
+
if (parts.length > 0) return `${parts.join(":")}:::${this.path}/${this.id}`;
|
|
125
|
+
return this.pathWithId;
|
|
126
|
+
}
|
|
127
|
+
isEntityReference() {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Class used to create a reference to a entity in a different path
|
|
133
|
+
*/
|
|
134
|
+
var EntityRelation = class {
|
|
135
|
+
__type = "relation";
|
|
136
|
+
/**
|
|
137
|
+
* ID of the entity
|
|
138
|
+
*/
|
|
139
|
+
id;
|
|
140
|
+
/**
|
|
141
|
+
* A string representing the path of the referenced document (relative
|
|
142
|
+
* to the root of the database).
|
|
143
|
+
*/
|
|
144
|
+
path;
|
|
145
|
+
/**
|
|
146
|
+
* Pre-fetched data payload to eliminate N+1 queries.
|
|
147
|
+
* When present, clients can use this directly instead of fetching.
|
|
148
|
+
*/
|
|
149
|
+
data;
|
|
150
|
+
constructor(id, path, data) {
|
|
151
|
+
this.id = id;
|
|
152
|
+
this.path = path;
|
|
153
|
+
this.data = data;
|
|
154
|
+
}
|
|
155
|
+
get pathWithId() {
|
|
156
|
+
return `${this.path}/${this.id}`;
|
|
157
|
+
}
|
|
158
|
+
isEntityReference() {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
isEntityRelation() {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var GeoPoint = class {
|
|
166
|
+
/**
|
|
167
|
+
* The latitude of this GeoPoint instance.
|
|
168
|
+
*/
|
|
169
|
+
latitude;
|
|
170
|
+
/**
|
|
171
|
+
* The longitude of this GeoPoint instance.
|
|
172
|
+
*/
|
|
173
|
+
longitude;
|
|
174
|
+
constructor(latitude, longitude) {
|
|
175
|
+
this.latitude = latitude;
|
|
176
|
+
this.longitude = longitude;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var Vector = class {
|
|
180
|
+
value;
|
|
181
|
+
constructor(value) {
|
|
182
|
+
this.value = value;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region ../types/src/types/filter-operators.ts
|
|
187
|
+
/** Maps canonical operators to their REST short-code equivalents. */
|
|
188
|
+
var CANONICAL_TO_REST = {
|
|
189
|
+
"==": "eq",
|
|
190
|
+
"!=": "neq",
|
|
191
|
+
">": "gt",
|
|
192
|
+
">=": "gte",
|
|
193
|
+
"<": "lt",
|
|
194
|
+
"<=": "lte",
|
|
195
|
+
"in": "in",
|
|
196
|
+
"not-in": "nin",
|
|
197
|
+
"array-contains": "cs",
|
|
198
|
+
"array-contains-any": "csa",
|
|
199
|
+
"like": "like",
|
|
200
|
+
"ilike": "ilike",
|
|
201
|
+
"not-like": "nlike",
|
|
202
|
+
"not-ilike": "nilike",
|
|
203
|
+
"is-null": "isnull",
|
|
204
|
+
"is-not-null": "notnull"
|
|
205
|
+
};
|
|
206
|
+
/** Maps REST short-code operators to their canonical equivalents. */
|
|
207
|
+
var REST_TO_CANONICAL = {
|
|
208
|
+
"eq": "==",
|
|
209
|
+
"neq": "!=",
|
|
210
|
+
"gt": ">",
|
|
211
|
+
"gte": ">=",
|
|
212
|
+
"lt": "<",
|
|
213
|
+
"lte": "<=",
|
|
214
|
+
"in": "in",
|
|
215
|
+
"nin": "not-in",
|
|
216
|
+
"cs": "array-contains",
|
|
217
|
+
"csa": "array-contains-any",
|
|
218
|
+
"like": "like",
|
|
219
|
+
"ilike": "ilike",
|
|
220
|
+
"nlike": "not-like",
|
|
221
|
+
"nilike": "not-ilike",
|
|
222
|
+
"isnull": "is-null",
|
|
223
|
+
"notnull": "is-not-null"
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Operators that test for null/not-null and therefore ignore their value.
|
|
227
|
+
* Codecs normalize the value of these conditions to `null`.
|
|
228
|
+
*/
|
|
229
|
+
var NULL_OPS = new Set(["is-null", "is-not-null"]);
|
|
230
|
+
/**
|
|
231
|
+
* Every canonical operator, in a stable order. Useful for engine capability
|
|
232
|
+
* declarations ({@link DataSourceCapabilities.filterOperators}) and for
|
|
233
|
+
* building operator subsets.
|
|
234
|
+
* @group Models
|
|
235
|
+
*/
|
|
236
|
+
var ALL_WHERE_FILTER_OPS = [
|
|
237
|
+
"<",
|
|
238
|
+
"<=",
|
|
239
|
+
"==",
|
|
240
|
+
"!=",
|
|
241
|
+
">=",
|
|
242
|
+
">",
|
|
243
|
+
"in",
|
|
244
|
+
"not-in",
|
|
245
|
+
"array-contains",
|
|
246
|
+
"array-contains-any",
|
|
247
|
+
"like",
|
|
248
|
+
"ilike",
|
|
249
|
+
"not-like",
|
|
250
|
+
"not-ilike",
|
|
251
|
+
"is-null",
|
|
252
|
+
"is-not-null"
|
|
253
|
+
];
|
|
254
|
+
/** All canonical operator strings for runtime validation. */
|
|
255
|
+
var CANONICAL_OPS = new Set(ALL_WHERE_FILTER_OPS);
|
|
256
|
+
/**
|
|
257
|
+
* Resolve any operator string (canonical or REST short-code) to its
|
|
258
|
+
* canonical `WhereFilterOp` form. Returns `undefined` for unknown operators.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* toCanonicalOp("==") // "=="
|
|
262
|
+
* toCanonicalOp("eq") // "=="
|
|
263
|
+
* toCanonicalOp("cs") // "array-contains"
|
|
264
|
+
* toCanonicalOp("xyz") // undefined
|
|
265
|
+
*/
|
|
266
|
+
function toCanonicalOp(op) {
|
|
267
|
+
if (CANONICAL_OPS.has(op)) return op;
|
|
268
|
+
return REST_TO_CANONICAL[op];
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region ../types/src/types/collections.ts
|
|
272
|
+
/**
|
|
273
|
+
* Type guard for PostgreSQL collections.
|
|
274
|
+
* Returns true if the collection uses the Postgres engine (or the default engine).
|
|
275
|
+
* @group Models
|
|
276
|
+
*/
|
|
277
|
+
function isPostgresCollectionConfig(collection) {
|
|
278
|
+
return !collection.engine || collection.engine === "postgres";
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Type guard for Firebase / Firestore collections.
|
|
282
|
+
* @group Models
|
|
283
|
+
*/
|
|
284
|
+
function isFirebaseCollectionConfig(collection) {
|
|
285
|
+
return collection.engine === "firestore";
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Type guard for MongoDB collections.
|
|
289
|
+
* @group Models
|
|
290
|
+
*/
|
|
291
|
+
function isMongoDBCollectionConfig(collection) {
|
|
292
|
+
return collection.engine === "mongodb";
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Returns the data path for a collection.
|
|
296
|
+
* For Firestore or MongoDB collections with a `path`, returns that value;
|
|
297
|
+
* otherwise falls back to `slug`.
|
|
298
|
+
*/
|
|
299
|
+
function getCollectionDataPath(collection) {
|
|
300
|
+
if (isFirebaseCollectionConfig(collection) && collection.path) return collection.path;
|
|
301
|
+
if (isMongoDBCollectionConfig(collection) && collection.path) return collection.path;
|
|
302
|
+
return collection.slug;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Reads a collection's driver-declared subcollections thunk (the `subcollections`
|
|
306
|
+
* field) independent of engine identity, so engine-agnostic code doesn't have to
|
|
307
|
+
* type-guard against a specific driver. Returns `undefined` when the collection
|
|
308
|
+
* declares none.
|
|
309
|
+
*
|
|
310
|
+
* Pair with `getDataSourceCapabilities(engine).supportsSubcollections` to decide
|
|
311
|
+
* whether the engine honours subcollections at all before reading them.
|
|
312
|
+
* @group Models
|
|
313
|
+
*/
|
|
314
|
+
function getDeclaredSubcollections(collection) {
|
|
315
|
+
return collection.subcollections;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region ../types/src/types/policy.ts
|
|
319
|
+
/** @group Models */
|
|
320
|
+
var policy = {
|
|
321
|
+
true: () => ({ kind: "true" }),
|
|
322
|
+
false: () => ({ kind: "false" }),
|
|
323
|
+
and: (...operands) => ({
|
|
324
|
+
kind: "and",
|
|
325
|
+
operands
|
|
326
|
+
}),
|
|
327
|
+
or: (...operands) => ({
|
|
328
|
+
kind: "or",
|
|
329
|
+
operands
|
|
330
|
+
}),
|
|
331
|
+
not: (operand) => ({
|
|
332
|
+
kind: "not",
|
|
333
|
+
operand
|
|
334
|
+
}),
|
|
335
|
+
compare: (left, op, right) => ({
|
|
336
|
+
kind: "compare",
|
|
337
|
+
op,
|
|
338
|
+
left,
|
|
339
|
+
right
|
|
340
|
+
}),
|
|
341
|
+
rolesOverlap: (roles) => ({
|
|
342
|
+
kind: "rolesOverlap",
|
|
343
|
+
roles
|
|
344
|
+
}),
|
|
345
|
+
rolesContain: (roles) => ({
|
|
346
|
+
kind: "rolesContain",
|
|
347
|
+
roles
|
|
348
|
+
}),
|
|
349
|
+
authenticated: () => ({ kind: "authenticated" }),
|
|
350
|
+
existsIn: (args) => ({
|
|
351
|
+
kind: "existsIn",
|
|
352
|
+
collection: args.collection,
|
|
353
|
+
where: args.where
|
|
354
|
+
}),
|
|
355
|
+
raw: (sql) => ({
|
|
356
|
+
kind: "raw",
|
|
357
|
+
sql
|
|
358
|
+
}),
|
|
359
|
+
field: (name) => ({
|
|
360
|
+
kind: "field",
|
|
361
|
+
name
|
|
362
|
+
}),
|
|
363
|
+
outerField: (name) => ({
|
|
364
|
+
kind: "outerField",
|
|
365
|
+
name
|
|
366
|
+
}),
|
|
367
|
+
literal: (value) => ({
|
|
368
|
+
kind: "literal",
|
|
369
|
+
value
|
|
370
|
+
}),
|
|
371
|
+
authUid: () => ({ kind: "authUid" }),
|
|
372
|
+
authRoles: () => ({ kind: "authRoles" })
|
|
373
|
+
};
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region ../types/src/types/backend.ts
|
|
376
|
+
/**
|
|
377
|
+
* Type guard: does this admin support SQL operations?
|
|
378
|
+
* @group Admin
|
|
379
|
+
*/
|
|
380
|
+
function isSQLAdmin(admin) {
|
|
381
|
+
return !!admin && typeof admin.executeSql === "function";
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Type guard: does this admin support document operations?
|
|
385
|
+
* @group Admin
|
|
386
|
+
*/
|
|
387
|
+
function isDocumentAdmin(admin) {
|
|
388
|
+
return !!admin && (typeof admin.executeAggregate === "function" || typeof admin.fetchCollectionStats === "function");
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Type guard: does this admin support schema management?
|
|
392
|
+
* @group Admin
|
|
393
|
+
*/
|
|
394
|
+
function isSchemaAdmin(admin) {
|
|
395
|
+
return !!admin && (typeof admin.fetchUnmappedTables === "function" || typeof admin.fetchTableMetadata === "function");
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Type guard: does this admin support database branching?
|
|
399
|
+
* @group Admin
|
|
400
|
+
*/
|
|
401
|
+
function isBranchAdmin(admin) {
|
|
402
|
+
return !!admin && typeof admin.createBranch === "function";
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region ../types/src/types/data_source.ts
|
|
406
|
+
/**
|
|
407
|
+
* The default data-source key, used when a collection does not name a
|
|
408
|
+
* `dataSource`. Shared by the frontend router and the backend driver
|
|
409
|
+
* registry so both agree on "the default database".
|
|
410
|
+
* @group Models
|
|
411
|
+
*/
|
|
412
|
+
var DEFAULT_DATA_SOURCE_KEY = "(default)";
|
|
413
|
+
/** @group Models */
|
|
414
|
+
var POSTGRES_CAPABILITIES = {
|
|
415
|
+
key: "postgres",
|
|
416
|
+
label: "PostgreSQL",
|
|
417
|
+
supportsRelations: true,
|
|
418
|
+
supportsSubcollections: false,
|
|
419
|
+
supportsRLS: true,
|
|
420
|
+
supportsReferences: false,
|
|
421
|
+
supportsColumnTypes: true,
|
|
422
|
+
supportsRealtime: true,
|
|
423
|
+
filterOperators: ALL_WHERE_FILTER_OPS,
|
|
424
|
+
supportsSQLAdmin: true,
|
|
425
|
+
supportsDocumentAdmin: false,
|
|
426
|
+
supportsSchemaAdmin: true
|
|
427
|
+
};
|
|
428
|
+
/** @group Models */
|
|
429
|
+
var FIREBASE_CAPABILITIES = {
|
|
430
|
+
key: "firestore",
|
|
431
|
+
label: "Firebase / Firestore",
|
|
432
|
+
supportsRelations: false,
|
|
433
|
+
supportsSubcollections: true,
|
|
434
|
+
supportsRLS: false,
|
|
435
|
+
supportsReferences: true,
|
|
436
|
+
supportsColumnTypes: false,
|
|
437
|
+
supportsRealtime: true,
|
|
438
|
+
filterOperators: ALL_WHERE_FILTER_OPS.filter((op) => op !== "like" && op !== "ilike" && op !== "not-like" && op !== "not-ilike"),
|
|
439
|
+
supportsSQLAdmin: false,
|
|
440
|
+
supportsDocumentAdmin: false,
|
|
441
|
+
supportsSchemaAdmin: false
|
|
442
|
+
};
|
|
443
|
+
/** @group Models */
|
|
444
|
+
var MONGODB_CAPABILITIES = {
|
|
445
|
+
key: "mongodb",
|
|
446
|
+
label: "MongoDB",
|
|
447
|
+
supportsRelations: false,
|
|
448
|
+
supportsSubcollections: true,
|
|
449
|
+
supportsRLS: false,
|
|
450
|
+
supportsReferences: true,
|
|
451
|
+
supportsColumnTypes: false,
|
|
452
|
+
supportsRealtime: false,
|
|
453
|
+
filterOperators: ALL_WHERE_FILTER_OPS,
|
|
454
|
+
supportsSQLAdmin: false,
|
|
455
|
+
supportsDocumentAdmin: true,
|
|
456
|
+
supportsSchemaAdmin: true
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* Fallback capabilities when the driver is unknown.
|
|
460
|
+
* Enables everything so nothing is hidden unexpectedly.
|
|
461
|
+
* @group Models
|
|
462
|
+
*/
|
|
463
|
+
var DEFAULT_CAPABILITIES = {
|
|
464
|
+
key: "(default)",
|
|
465
|
+
label: "Default",
|
|
466
|
+
supportsRelations: true,
|
|
467
|
+
supportsSubcollections: true,
|
|
468
|
+
supportsRLS: true,
|
|
469
|
+
supportsReferences: true,
|
|
470
|
+
supportsColumnTypes: true,
|
|
471
|
+
supportsRealtime: true,
|
|
472
|
+
filterOperators: ALL_WHERE_FILTER_OPS,
|
|
473
|
+
supportsSQLAdmin: true,
|
|
474
|
+
supportsDocumentAdmin: true,
|
|
475
|
+
supportsSchemaAdmin: true
|
|
476
|
+
};
|
|
477
|
+
var CAPABILITIES_REGISTRY = {
|
|
478
|
+
postgres: POSTGRES_CAPABILITIES,
|
|
479
|
+
firestore: FIREBASE_CAPABILITIES,
|
|
480
|
+
mongodb: MONGODB_CAPABILITIES,
|
|
481
|
+
"(default)": DEFAULT_CAPABILITIES
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* Look up capabilities for a given engine key.
|
|
485
|
+
* If `engine` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
486
|
+
* @group Models
|
|
487
|
+
*/
|
|
488
|
+
function getDataSourceCapabilities(engine) {
|
|
489
|
+
if (!engine) return POSTGRES_CAPABILITIES;
|
|
490
|
+
return CAPABILITIES_REGISTRY[engine] ?? DEFAULT_CAPABILITIES;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Register custom capabilities for a third-party driver.
|
|
494
|
+
* @group Models
|
|
495
|
+
*/
|
|
496
|
+
function registerDataSourceCapabilities(capabilities) {
|
|
497
|
+
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region ../types/src/types/storage_source.ts
|
|
501
|
+
/**
|
|
502
|
+
* Describes a named storage backend — a place files live.
|
|
503
|
+
*
|
|
504
|
+
* Declared once and shared front + back: the frontend uses it to decide
|
|
505
|
+
* transport (HTTP proxy vs direct SDK), the backend uses the same `key`
|
|
506
|
+
* to resolve a StorageController, and collection properties reference
|
|
507
|
+
* a definition by its `key` via `StorageConfig.storageSource`.
|
|
508
|
+
*
|
|
509
|
+
* This mirrors the {@link DataSourceDefinition} pattern used for databases.
|
|
510
|
+
*
|
|
511
|
+
* @group Models
|
|
512
|
+
*/
|
|
513
|
+
/**
|
|
514
|
+
* The default storage source key, used when a property does not specify
|
|
515
|
+
* a `storageSource`. Shared by the frontend and backend registries so
|
|
516
|
+
* both agree on "the default storage backend".
|
|
517
|
+
* @group Models
|
|
518
|
+
*/
|
|
519
|
+
var DEFAULT_STORAGE_SOURCE_KEY = "(default)";
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region ../types/src/types/component_ref.ts
|
|
522
|
+
/**
|
|
523
|
+
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
524
|
+
* Vite transform plugin.
|
|
525
|
+
*/
|
|
526
|
+
function isLazyComponentRef(ref) {
|
|
527
|
+
return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
|
|
528
|
+
}
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region ../types/src/controllers/storage.ts
|
|
531
|
+
/**
|
|
532
|
+
* Path prefix that marks an object as **public**. Files stored under this
|
|
533
|
+
* prefix are served without any auth token via a stable, permanent,
|
|
534
|
+
* CDN-cacheable URL (see {@link StorageSource.getSignedUrl}). Shared by the
|
|
535
|
+
* client SDK and the backend so both agree on which objects are public.
|
|
536
|
+
*
|
|
537
|
+
* @group Models
|
|
538
|
+
*/
|
|
539
|
+
var PUBLIC_STORAGE_PREFIX = "public/";
|
|
540
|
+
/**
|
|
541
|
+
* True when a storage key/path points at a public object (lives under
|
|
542
|
+
* {@link PUBLIC_STORAGE_PREFIX}). The check is applied to the key *within the
|
|
543
|
+
* bucket* — strip any `bucket/` and `scheme://` prefixes first.
|
|
544
|
+
*
|
|
545
|
+
* @group Models
|
|
546
|
+
*/
|
|
547
|
+
function isPublicStoragePath(path) {
|
|
548
|
+
if (!path) return false;
|
|
549
|
+
let p = path;
|
|
550
|
+
const scheme = p.indexOf("://");
|
|
551
|
+
if (scheme !== -1) p = p.substring(scheme + 3);
|
|
552
|
+
p = p.replace(/^\/+/, "");
|
|
553
|
+
if (p.split("/").some((seg) => seg === "..")) return false;
|
|
554
|
+
return p.startsWith("public/") || p.startsWith(`default/public/`);
|
|
555
|
+
}
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region ../types/src/index.ts
|
|
558
|
+
var src_exports = /* @__PURE__ */ __exportAll({
|
|
559
|
+
ALL_WHERE_FILTER_OPS: () => ALL_WHERE_FILTER_OPS,
|
|
560
|
+
CANONICAL_TO_REST: () => CANONICAL_TO_REST,
|
|
561
|
+
DEFAULT_CAPABILITIES: () => DEFAULT_CAPABILITIES,
|
|
562
|
+
DEFAULT_DATA_SOURCE_KEY: () => DEFAULT_DATA_SOURCE_KEY,
|
|
563
|
+
DEFAULT_STORAGE_SOURCE_KEY: () => DEFAULT_STORAGE_SOURCE_KEY,
|
|
564
|
+
EntityReference: () => EntityReference,
|
|
565
|
+
EntityRelation: () => EntityRelation,
|
|
566
|
+
FIREBASE_CAPABILITIES: () => FIREBASE_CAPABILITIES,
|
|
567
|
+
GeoPoint: () => GeoPoint,
|
|
568
|
+
MONGODB_CAPABILITIES: () => MONGODB_CAPABILITIES,
|
|
569
|
+
NULL_OPS: () => NULL_OPS,
|
|
570
|
+
POSTGRES_CAPABILITIES: () => POSTGRES_CAPABILITIES,
|
|
571
|
+
PUBLIC_STORAGE_PREFIX: () => PUBLIC_STORAGE_PREFIX,
|
|
572
|
+
REST_TO_CANONICAL: () => REST_TO_CANONICAL,
|
|
573
|
+
RebaseApiError: () => RebaseApiError,
|
|
574
|
+
RebaseClientError: () => RebaseClientError,
|
|
575
|
+
Vector: () => Vector,
|
|
576
|
+
getCollectionDataPath: () => getCollectionDataPath,
|
|
577
|
+
getDataSourceCapabilities: () => getDataSourceCapabilities,
|
|
578
|
+
getDeclaredSubcollections: () => getDeclaredSubcollections,
|
|
579
|
+
isBranchAdmin: () => isBranchAdmin,
|
|
580
|
+
isDocumentAdmin: () => isDocumentAdmin,
|
|
581
|
+
isFirebaseCollectionConfig: () => isFirebaseCollectionConfig,
|
|
582
|
+
isLazyComponentRef: () => isLazyComponentRef,
|
|
583
|
+
isMongoDBCollectionConfig: () => isMongoDBCollectionConfig,
|
|
584
|
+
isPostgresCollectionConfig: () => isPostgresCollectionConfig,
|
|
585
|
+
isPublicStoragePath: () => isPublicStoragePath,
|
|
586
|
+
isSQLAdmin: () => isSQLAdmin,
|
|
587
|
+
isSchemaAdmin: () => isSchemaAdmin,
|
|
588
|
+
policy: () => policy,
|
|
589
|
+
registerDataSourceCapabilities: () => registerDataSourceCapabilities,
|
|
590
|
+
toCanonicalOp: () => toCanonicalOp
|
|
591
|
+
});
|
|
592
|
+
//#endregion
|
|
593
|
+
export { isSchemaAdmin as a, isPostgresCollectionConfig as c, NULL_OPS as d, REST_TO_CANONICAL as f, Vector as g, EntityRelation as h, isSQLAdmin as i, ALL_WHERE_FILTER_OPS as l, EntityReference as m, DEFAULT_DATA_SOURCE_KEY as n, policy as o, toCanonicalOp as p, getDataSourceCapabilities as r, getDeclaredSubcollections as s, src_exports as t, CANONICAL_TO_REST as u };
|
|
594
|
+
|
|
595
|
+
//# sourceMappingURL=src-Eh-CZosp.js.map
|