@rebasepro/server 0.12.0 → 0.12.1-canary.g06f263c

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.
Files changed (60) hide show
  1. package/dist/GCSStorageController-BEmDYFKc.js +216 -0
  2. package/dist/GCSStorageController-BEmDYFKc.js.map +1 -0
  3. package/dist/S3StorageController-CK7r5yZb.js +243 -0
  4. package/dist/S3StorageController-CK7r5yZb.js.map +1 -0
  5. package/dist/admin_block-BGQFSAuV.js +123 -0
  6. package/dist/admin_block-BGQFSAuV.js.map +1 -0
  7. package/dist/auth-DQv2_Z3S.js +8923 -0
  8. package/dist/auth-DQv2_Z3S.js.map +1 -0
  9. package/dist/backend-CIxN4FVm.js +15 -0
  10. package/dist/backend-CIxN4FVm.js.map +1 -0
  11. package/dist/backup-CVggVhR2.js +163 -0
  12. package/dist/backup-CVggVhR2.js.map +1 -0
  13. package/dist/boot/boot.d.ts +53 -0
  14. package/dist/boot/driver.d.ts +35 -1
  15. package/dist/boot/fetch-bundle.d.ts +43 -0
  16. package/dist/boot/version-skew.d.ts +77 -0
  17. package/dist/contract-routes-Dj8i5AiM.js +264 -0
  18. package/dist/contract-routes-Dj8i5AiM.js.map +1 -0
  19. package/dist/cron/cron-scheduler.d.ts +34 -0
  20. package/dist/cron-loader-B1S2MCSl.js +63 -0
  21. package/dist/cron-loader-B1S2MCSl.js.map +1 -0
  22. package/dist/cron-routes-CrQ0tK-_.js +62 -0
  23. package/dist/cron-routes-CrQ0tK-_.js.map +1 -0
  24. package/dist/cron-scheduler-B3RFt0HS.js +647 -0
  25. package/dist/cron-scheduler-B3RFt0HS.js.map +1 -0
  26. package/dist/cron-store-BywZsyfZ.js +164 -0
  27. package/dist/cron-store-BywZsyfZ.js.map +1 -0
  28. package/dist/dynamic-import-Dvh-K5fl.js.map +1 -1
  29. package/dist/errors-CgkCzoj7.js +226 -0
  30. package/dist/errors-CgkCzoj7.js.map +1 -0
  31. package/dist/function-loader-B_1fYfUY.js +86 -0
  32. package/dist/function-loader-B_1fYfUY.js.map +1 -0
  33. package/dist/function-routes-C0cLIy3N.js +28 -0
  34. package/dist/function-routes-C0cLIy3N.js.map +1 -0
  35. package/dist/index.es.js +7943 -17923
  36. package/dist/index.es.js.map +1 -1
  37. package/dist/init.d.ts +20 -0
  38. package/dist/{jwt-D-eI6TTu.js → jwt-DD6EtpGj.js} +32 -13
  39. package/dist/{jwt-D-eI6TTu.js.map → jwt-DD6EtpGj.js.map} +1 -1
  40. package/dist/logger-BYU66ENZ.js.map +1 -1
  41. package/dist/logs-routes-BYA72C_C.js +100 -0
  42. package/dist/logs-routes-BYA72C_C.js.map +1 -0
  43. package/dist/{openapi-generator-Bjzmb5cn.js → openapi-generator-5re-77gM.js} +9 -3
  44. package/dist/openapi-generator-5re-77gM.js.map +1 -0
  45. package/dist/policy-B5d-asZT.js +115 -0
  46. package/dist/policy-B5d-asZT.js.map +1 -0
  47. package/dist/{schema-editor-routes-DDxfOIid.js → schema-editor-routes-Doil0rrr.js} +4 -3
  48. package/dist/{schema-editor-routes-DDxfOIid.js.map → schema-editor-routes-Doil0rrr.js.map} +1 -1
  49. package/dist/{src-CoOAMnBh.js → src-By2xYed6.js} +238 -66
  50. package/dist/src-By2xYed6.js.map +1 -0
  51. package/dist/src-_qQ3RNCK.js +279 -0
  52. package/dist/src-_qQ3RNCK.js.map +1 -0
  53. package/dist/types-DSnOC4mF.js +38 -0
  54. package/dist/types-DSnOC4mF.js.map +1 -0
  55. package/package.json +10 -10
  56. package/dist/openapi-generator-Bjzmb5cn.js.map +0 -1
  57. package/dist/src-CoOAMnBh.js.map +0 -1
  58. package/dist/src-Ivjud8jD.js +0 -957
  59. package/dist/src-Ivjud8jD.js.map +0 -1
  60. /package/dist/{chunk-DSJWtz9O.js → rolldown-runtime-DSJWtz9O.js} +0 -0
@@ -1,8 +1,132 @@
1
1
  import { createRequire as __createRequire } from "module";
2
2
  import "process";
3
3
  __createRequire(import.meta.url);
4
- import { r as __require, t as __commonJSMin } from "./chunk-DSJWtz9O.js";
5
- import { S as toCanonicalOp, b as NULL_OPS, f as getDeclaredSubcollections, g as getDataSourceCapabilities, l as policy, m as isRelationalCollectionConfig, w as EntityRelation, x as REST_TO_CANONICAL, y as CANONICAL_TO_REST } from "./src-Ivjud8jD.js";
4
+ import { r as __require, t as __commonJSMin } from "./rolldown-runtime-DSJWtz9O.js";
5
+ import { c as NULL_OPS, i as isRelationalCollectionConfig, l as REST_TO_CANONICAL, n as getDeclaredSubcollections, o as getDataSourceCapabilities, r as isPostgresCollectionConfig, s as CANONICAL_TO_REST, u as toCanonicalOp } from "./src-_qQ3RNCK.js";
6
+ import { r as policy } from "./policy-B5d-asZT.js";
7
+ //#region ../types/src/types/entities.ts
8
+ /**
9
+ * Class used to create a reference to a entity in a different path.
10
+ *
11
+ * @example
12
+ * // Simple reference (most common case - single driver, single db)
13
+ * new EntityReference({ id: "123", path: "users" })
14
+ *
15
+ * // Reference to a different driver (e.g., Firestore)
16
+ * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
17
+ *
18
+ * // Reference to a specific database within a driver
19
+ * new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
20
+ */
21
+ var EntityReference = class {
22
+ __type = "reference";
23
+ /**
24
+ * ID of the entity
25
+ */
26
+ id;
27
+ /**
28
+ * A string representing the path of the referenced document (relative
29
+ * to the root of the database).
30
+ */
31
+ path;
32
+ /**
33
+ * Which driver (e.g., 'postgres', 'firestore').
34
+ * Defaults to "(default)" if not specified.
35
+ */
36
+ driver;
37
+ /**
38
+ * Which database within the driver.
39
+ * Defaults to "(default)" if not specified.
40
+ */
41
+ databaseId;
42
+ /**
43
+ * Create a reference to a entity.
44
+ *
45
+ * @example
46
+ * // Simple reference (most common case)
47
+ * new EntityReference({ id: "123", path: "users" })
48
+ *
49
+ * // With driver
50
+ * new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
51
+ */
52
+ constructor(props) {
53
+ this.id = props.id;
54
+ this.path = props.path;
55
+ this.driver = props.driver;
56
+ this.databaseId = props.databaseId;
57
+ }
58
+ get pathWithId() {
59
+ return `${this.path}/${this.id}`;
60
+ }
61
+ /**
62
+ * Get the full path including driver and database prefixes if specified.
63
+ * For the common case (single driver, single db), this just returns pathWithId.
64
+ */
65
+ get fullPath() {
66
+ const parts = [];
67
+ if (this.driver && this.driver !== "(default)") parts.push(this.driver);
68
+ if (this.databaseId && this.databaseId !== "(default)") parts.push(this.databaseId);
69
+ if (parts.length > 0) return `${parts.join(":")}:::${this.path}/${this.id}`;
70
+ return this.pathWithId;
71
+ }
72
+ isEntityReference() {
73
+ return true;
74
+ }
75
+ };
76
+ /**
77
+ * Class used to create a reference to a entity in a different path
78
+ */
79
+ var EntityRelation = class {
80
+ __type = "relation";
81
+ /**
82
+ * ID of the entity
83
+ */
84
+ id;
85
+ /**
86
+ * A string representing the path of the referenced document (relative
87
+ * to the root of the database).
88
+ */
89
+ path;
90
+ /**
91
+ * Pre-fetched data payload to eliminate N+1 queries.
92
+ * When present, clients can use this directly instead of fetching.
93
+ */
94
+ data;
95
+ constructor(id, path, data) {
96
+ this.id = id;
97
+ this.path = path;
98
+ this.data = data;
99
+ }
100
+ get pathWithId() {
101
+ return `${this.path}/${this.id}`;
102
+ }
103
+ isEntityReference() {
104
+ return false;
105
+ }
106
+ isEntityRelation() {
107
+ return true;
108
+ }
109
+ };
110
+ var GeoPoint = class {
111
+ /**
112
+ * The latitude of this GeoPoint instance.
113
+ */
114
+ latitude;
115
+ /**
116
+ * The longitude of this GeoPoint instance.
117
+ */
118
+ longitude;
119
+ constructor(latitude, longitude) {
120
+ this.latitude = latitude;
121
+ this.longitude = longitude;
122
+ }
123
+ };
124
+ var Vector = class {
125
+ value;
126
+ constructor(value) {
127
+ this.value = value;
128
+ }
129
+ };
6
130
  (/* @__PURE__ */ __commonJSMin(((exports, module) => {
7
131
  (function(e) {
8
132
  var t;
@@ -1381,7 +1505,105 @@ function getEntityChildViews(collection) {
1381
1505
  function getSubcollections(collection) {
1382
1506
  return getEntityChildViews(collection).map((view) => view.collection);
1383
1507
  }
1384
- policy.or(policy.serverContext(), policy.rolesOverlap(["admin"]));
1508
+ //#endregion
1509
+ //#region ../common/src/util/auth-default-policies.ts
1510
+ /**
1511
+ * Default RLS policies injected by the schema generator.
1512
+ *
1513
+ * Rebase's enforcement model is unified: authenticated (user-context) requests
1514
+ * run under the restricted `rebase_user` role, so Postgres RLS binds *every*
1515
+ * statement — reads and writes. A collection's `securityRules` are the whole
1516
+ * authorization model. The server context (auth flows, migrations,
1517
+ * `dataAsAdmin`) runs as the owner and bypasses RLS.
1518
+ *
1519
+ * Because RLS default-denies, every collection is **locked by default**: with
1520
+ * no rules, only the server context and admins can touch it. The generator
1521
+ * injects that safe baseline:
1522
+ *
1523
+ * **For every collection**
1524
+ * 1. A permissive **server-or-admin SELECT** grant.
1525
+ * 2. A permissive **server-or-admin write** grant (insert/update/delete).
1526
+ *
1527
+ * Author `securityRules` are permissive and OR together, so explicit rules only
1528
+ * *broaden* access from this locked baseline (e.g. "users read/write their own
1529
+ * rows").
1530
+ *
1531
+ * **For auth collections additionally**
1532
+ * 3. A permissive **self SELECT** grant (`id = auth.uid()`), so users can read
1533
+ * their own row (profile, session bootstrap) without every app re-declaring
1534
+ * it.
1535
+ * 4. A **restrictive** admin write gate. Restrictive policies are AND'd with
1536
+ * every other policy, so a write is rejected unless the caller is an admin
1537
+ * (or the server context) — even if the author also wrote a permissive rule
1538
+ * such as "a user may edit their own row". Without this, a permissive owner
1539
+ * rule would let a user change their own `roles`.
1540
+ *
1541
+ * The server context is recognised as `auth.uid() IS NULL` (`policy.serverContext()`)
1542
+ * — the built-in flows that run without a user (signup, migrations) set no user
1543
+ * GUC — which also lets the owner connection satisfy these policies even under
1544
+ * FORCE RLS. A *user* request never reaches that state: an anonymous one carries
1545
+ * `ANONYMOUS_USER_ID`, precisely so it cannot pass for the server here.
1546
+ *
1547
+ * Opt out with `disableDefaultPolicies: true` to take full responsibility for
1548
+ * the collection's RLS.
1549
+ */
1550
+ var SERVER_OR_ADMIN_EXPR$1 = policy.or(policy.serverContext(), policy.rolesOverlap(["admin"]));
1551
+ /** Write operations that must be admin-gated by default on auth collections. */
1552
+ var DEFAULT_GUARDED_OPS = [
1553
+ "insert",
1554
+ "update",
1555
+ "delete"
1556
+ ];
1557
+ /** Whether a collection is flagged as an authentication collection. */
1558
+ function isAuthCollection(collection) {
1559
+ const auth = collection.auth;
1560
+ return auth === true || typeof auth === "object" && auth?.enabled === true;
1561
+ }
1562
+ /** The property marked as the row id (falls back to `id`). */
1563
+ function getIdPropertyName(collection) {
1564
+ for (const [name, prop] of Object.entries(collection.properties ?? {})) if (prop && typeof prop === "object" && "isId" in prop && prop.isId) return name;
1565
+ return "id";
1566
+ }
1567
+ /**
1568
+ * Returns the security rules that should be applied to a collection: the
1569
+ * author's explicit `securityRules` plus the framework defaults described in
1570
+ * the module doc (baseline server/admin read for all collections; self-read
1571
+ * and the admin write gate for auth collections).
1572
+ *
1573
+ * Collections that opt out via `disableDefaultPolicies` are returned unchanged.
1574
+ */
1575
+ function getEffectiveSecurityRules(collection) {
1576
+ const explicit = [...collection.securityRules ?? []];
1577
+ if (isPostgresCollectionConfig(collection) && collection.disableDefaultPolicies) return explicit;
1578
+ const tableName = getTableName(collection);
1579
+ const injected = [];
1580
+ injected.push({
1581
+ name: `${tableName}_default_admin_read`,
1582
+ operations: ["select"],
1583
+ condition: SERVER_OR_ADMIN_EXPR$1
1584
+ });
1585
+ injected.push({
1586
+ name: `${tableName}_default_admin_write`,
1587
+ operations: [...DEFAULT_GUARDED_OPS],
1588
+ condition: SERVER_OR_ADMIN_EXPR$1,
1589
+ check: SERVER_OR_ADMIN_EXPR$1
1590
+ });
1591
+ if (isAuthCollection(collection)) {
1592
+ injected.push({
1593
+ name: `${tableName}_default_self_read`,
1594
+ operations: ["select"],
1595
+ condition: policy.compare(policy.field(getIdPropertyName(collection)), "eq", policy.authUid())
1596
+ });
1597
+ injected.push({
1598
+ name: `${tableName}_require_admin_write`,
1599
+ mode: "restrictive",
1600
+ operations: [...DEFAULT_GUARDED_OPS],
1601
+ condition: SERVER_OR_ADMIN_EXPR$1,
1602
+ check: SERVER_OR_ADMIN_EXPR$1
1603
+ });
1604
+ }
1605
+ return [...explicit, ...injected];
1606
+ }
1385
1607
  policy.or(policy.serverContext(), policy.rolesOverlap(["admin"]));
1386
1608
  (/* @__PURE__ */ __commonJSMin(((exports, module) => {
1387
1609
  (function(root, factory) {
@@ -1660,7 +1882,7 @@ policy.or(policy.serverContext(), policy.rolesOverlap(["admin"]));
1660
1882
  * Apply PropertyConditions to a resolved property, evaluating all JSON Logic rules.
1661
1883
  */
1662
1884
  //#endregion
1663
- //#region ../../node_modules/.pnpm/fast-equals@6.0.0/node_modules/fast-equals/dist/es/index.mjs
1885
+ //#region ../../node_modules/.pnpm/fast-equals@6.0.2/node_modules/fast-equals/dist/es/index.mjs
1664
1886
  var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1665
1887
  var { hasOwnProperty } = Object.prototype;
1666
1888
  /**
@@ -1696,7 +1918,8 @@ function createIsCircular(areItemsEqual) {
1696
1918
  * not enumerable and symbol properties.
1697
1919
  */
1698
1920
  function getStrictProperties(object) {
1699
- return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
1921
+ const symbols = getOwnPropertySymbols(object);
1922
+ return symbols.length ? getOwnPropertyNames(object).concat(symbols) : getOwnPropertyNames(object);
1700
1923
  }
1701
1924
  /**
1702
1925
  * Whether the object contains the property passed as an own property.
@@ -1769,7 +1992,7 @@ function areMapsEqual(a, b, state) {
1769
1992
  const size = a.size;
1770
1993
  if (size !== b.size) return false;
1771
1994
  if (!size) return true;
1772
- const matchedIndices = new Array(size);
1995
+ const matchedIndices = new Uint8Array(size);
1773
1996
  const aIterable = a.entries();
1774
1997
  let aResult;
1775
1998
  let bResult;
@@ -1777,7 +2000,7 @@ function areMapsEqual(a, b, state) {
1777
2000
  while (aResult = aIterable.next()) {
1778
2001
  if (aResult.done) break;
1779
2002
  const bIterable = b.entries();
1780
- let hasMatch = false;
2003
+ let hasMatch = 0;
1781
2004
  let matchIndex = 0;
1782
2005
  while (bResult = bIterable.next()) {
1783
2006
  if (bResult.done) break;
@@ -1788,7 +2011,7 @@ function areMapsEqual(a, b, state) {
1788
2011
  const aEntry = aResult.value;
1789
2012
  const bEntry = bResult.value;
1790
2013
  if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
1791
- hasMatch = matchedIndices[matchIndex] = true;
2014
+ hasMatch = matchedIndices[matchIndex] = 1;
1792
2015
  break;
1793
2016
  }
1794
2017
  matchIndex++;
@@ -1846,19 +2069,19 @@ function areSetsEqual(a, b, state) {
1846
2069
  const size = a.size;
1847
2070
  if (size !== b.size) return false;
1848
2071
  if (!size) return true;
1849
- const matchedIndices = new Array(size);
2072
+ const matchedIndices = new Uint8Array(size);
1850
2073
  const aIterable = a.values();
1851
2074
  let aResult;
1852
2075
  let bResult;
1853
2076
  while (aResult = aIterable.next()) {
1854
2077
  if (aResult.done) break;
1855
2078
  const bIterable = b.values();
1856
- let hasMatch = false;
2079
+ let hasMatch = 0;
1857
2080
  let matchIndex = 0;
1858
2081
  while (bResult = bIterable.next()) {
1859
2082
  if (bResult.done) break;
1860
2083
  if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
1861
- hasMatch = matchedIndices[matchIndex] = true;
2084
+ hasMatch = matchedIndices[matchIndex] = 1;
1862
2085
  break;
1863
2086
  }
1864
2087
  matchIndex++;
@@ -1871,8 +2094,8 @@ function areSetsEqual(a, b, state) {
1871
2094
  * Whether the TypedArray instances are equal in value.
1872
2095
  */
1873
2096
  function areTypedArraysEqual(a, b) {
1874
- let index = a.byteLength;
1875
- if (b.byteLength !== index || a.byteOffset !== b.byteOffset) return false;
2097
+ let index = a.length;
2098
+ if (b.length !== index || a.byteOffset !== b.byteOffset) return false;
1876
2099
  while (index-- > 0) if (a[index] !== b[index]) return false;
1877
2100
  return true;
1878
2101
  }
@@ -3306,57 +3529,6 @@ function buildRoutedRebaseData({ defaultData, sources, resolveKey }) {
3306
3529
  } });
3307
3530
  }
3308
3531
  //#endregion
3309
- //#region ../common/src/data/sort-dialect.ts
3310
- /**
3311
- * Sort-order wire codec.
3312
- *
3313
- * This is the ONLY module that knows about the colon-delimited wire format
3314
- * (`"field:direction"`) used in HTTP query parameters.
3315
- * Everything else speaks {@link OrderByTuple} exclusively.
3316
- *
3317
- * Mirrors the filter architecture in `filter-dialect.ts`.
3318
- *
3319
- * @module
3320
- */
3321
- /**
3322
- * Serialize an {@link OrderByTuple} to the wire format `"field:direction"`.
3323
- *
3324
- * **Runtime tolerance:** if the input is already a well-formed wire string
3325
- * (from an untyped JS caller), it is returned unchanged.
3326
- * This is undocumented tolerance, not public API — don't rely on it.
3327
- *
3328
- * @param orderBy - A canonical `[field, direction]` tuple, or at runtime
3329
- * possibly a pre-serialized string (undocumented tolerance).
3330
- * @returns The wire-format string, or `undefined` if the input is falsy.
3331
- *
3332
- * @remarks
3333
- * Field names containing `:` are representable in the tuple form but
3334
- * **not** on the wire — this is an inherent limitation of the colon-delimited
3335
- * encoding and is not resolved here.
3336
- */
3337
- function serializeOrderBy(orderBy) {
3338
- if (!orderBy) return void 0;
3339
- if (typeof orderBy === "string") return orderBy;
3340
- return `${orderBy[0]}:${orderBy[1]}`;
3341
- }
3342
- /**
3343
- * Deserialize a wire-format `"field:direction"` string into an {@link OrderByTuple}.
3344
- *
3345
- * Lenient parsing (matches existing server behaviour):
3346
- * - Bare field name (no colon): `"name"` → `["name", "asc"]`
3347
- * - Unknown direction: `"name:foo"` → `["name", "asc"]`
3348
- * - Empty / falsy input: → `undefined`
3349
- *
3350
- * @param raw - The wire-format string from an HTTP query parameter.
3351
- * @returns The canonical tuple, or `undefined` if the input is empty/falsy.
3352
- */
3353
- function deserializeOrderBy(raw) {
3354
- if (!raw) return void 0;
3355
- const idx = raw.indexOf(":");
3356
- if (idx === -1) return [raw, "asc"];
3357
- return [raw.slice(0, idx), raw.slice(idx + 1) === "desc" ? "desc" : "asc"];
3358
- }
3359
- //#endregion
3360
- export { toSnakeCase as _, deserializeFilter as a, serializeLogicalCondition as c, CollectionRegistry as d, createDataSourceRegistry as f, buildCompositeId as g, resolveCollectionRelations as h, buildSdkData as i, collectAllPages as l, findRelation as m, serializeOrderBy as n, deserializeLogicalCondition as o, resolveDataSource as p, buildRoutedRebaseData as r, serializeFilter as s, deserializeOrderBy as t, paginateFind as u };
3532
+ export { EntityReference as _, serializeFilter as a, Vector as b, paginateFind as c, resolveDataSource as d, getEffectiveSecurityRules as f, toSnakeCase as g, buildCompositeId as h, deserializeLogicalCondition as i, CollectionRegistry as l, resolveCollectionRelations as m, buildSdkData as n, serializeLogicalCondition as o, findRelation as p, deserializeFilter as r, collectAllPages as s, buildRoutedRebaseData as t, createDataSourceRegistry as u, EntityRelation as v, GeoPoint as y };
3361
3533
 
3362
- //# sourceMappingURL=src-CoOAMnBh.js.map
3534
+ //# sourceMappingURL=src-By2xYed6.js.map