@lunora/do 1.0.0-alpha.7 → 1.0.0-alpha.71

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 (52) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/index.d.mts +3394 -5259
  3. package/dist/index.d.ts +3394 -5259
  4. package/dist/index.mjs +1 -36
  5. package/dist/packem_shared/ROOT_DO_SIZE_WARN_BYTES-Bze_kj6L.mjs +13 -0
  6. package/dist/packem_shared/SESSION_DO_TTL_DEFAULT-Dan63qLN.mjs +1 -0
  7. package/dist/packem_shared/SHARD_REGISTRY_DO_NAME-tOQVzDCB.mjs +1 -0
  8. package/dist/packem_shared/constant-time-equal-BVG05Guz.mjs +1 -0
  9. package/dist/packem_shared/json-response-wrh9TBPw.mjs +1 -0
  10. package/dist/packem_shared/serveRelationFanout-Cbmlso1k.mjs +1 -0
  11. package/package.json +6 -2
  12. package/dist/packem_shared/ADMIN_FUNCTIONS-CHcC8fKV.mjs +0 -314
  13. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-CFk6adSu.mjs +0 -54
  14. package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-CiHHYeJi.mjs +0 -84
  15. package/dist/packem_shared/CDC_LOG_TABLE-Ctdmxmrv.mjs +0 -103
  16. package/dist/packem_shared/ConflictError-C0STs6bU.mjs +0 -13
  17. package/dist/packem_shared/CountRlsUnsupportedError-28ZvvwKS.mjs +0 -133
  18. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-PTtTiQ7U.mjs +0 -237
  19. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-Dou2PWdO.mjs +0 -160
  20. package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-UDNVD7FS.mjs +0 -248
  21. package/dist/packem_shared/LogBuffer-B_Ezju_N.mjs +0 -37
  22. package/dist/packem_shared/MAIL_RETENTION-CPpgl-dX.mjs +0 -104
  23. package/dist/packem_shared/MAX_SQL_ROWS-dDcFE1YZ.mjs +0 -29
  24. package/dist/packem_shared/MIN_ADMIN_TOKEN_LENGTH-CCAvoFlr.mjs +0 -1
  25. package/dist/packem_shared/NotFoundError-CMuMZt81.mjs +0 -10
  26. package/dist/packem_shared/NotUniqueError-h_thNFSZ.mjs +0 -1809
  27. package/dist/packem_shared/RANK_TIEBREAK-C6blLR5K.mjs +0 -1
  28. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-EtGQdC9d.mjs +0 -132
  29. package/dist/packem_shared/ROOT_DO_SIZE_WARN_BYTES-2DxWrdla.mjs +0 -3958
  30. package/dist/packem_shared/ReactiveCache-ByVzgH3d.mjs +0 -259
  31. package/dist/packem_shared/SCAN_DEP-DLJF8dsj.mjs +0 -19
  32. package/dist/packem_shared/SESSION_DO_TTL_DEFAULT-ilPZsVwu.mjs +0 -180
  33. package/dist/packem_shared/SHARD_REGISTRY_DO_NAME-BsAbi5Mn.mjs +0 -146
  34. package/dist/packem_shared/aggregateTableName-CxNqY1Sl.mjs +0 -64
  35. package/dist/packem_shared/applyOnDelete-sA7o1CqD.mjs +0 -169
  36. package/dist/packem_shared/applySelect-BvZdFUBT.mjs +0 -101
  37. package/dist/packem_shared/armRestore-BJk53Ro8.mjs +0 -55
  38. package/dist/packem_shared/backfillAggregateIndexes-BbVPvciS.mjs +0 -80
  39. package/dist/packem_shared/buildFtsMatch-BLEMawrp.mjs +0 -38
  40. package/dist/packem_shared/compileWhereSql-CXrhFA3G.mjs +0 -127
  41. package/dist/packem_shared/createSystemReader-8CzSZP9V.mjs +0 -80
  42. package/dist/packem_shared/ctx-db-idempotency-DkC9rP91.mjs +0 -35
  43. package/dist/packem_shared/do-exec-5eQy5cEi.mjs +0 -12
  44. package/dist/packem_shared/do-sql-BCHCWtrD.mjs +0 -87
  45. package/dist/packem_shared/exportShardRows-DZEhUeyI.mjs +0 -156
  46. package/dist/packem_shared/hasTrigger-5N6_Fx0A.mjs +0 -20
  47. package/dist/packem_shared/rank-CrkEIpF4.mjs +0 -102
  48. package/dist/packem_shared/renderSql-D6eUcn2N.mjs +0 -16
  49. package/dist/packem_shared/runShardMigrations-PabobOjF.mjs +0 -103
  50. package/dist/packem_shared/security-audit-CucgBice.mjs +0 -158
  51. package/dist/packem_shared/serveRelationFanout-oxaM6_WL.mjs +0 -24
  52. package/dist/packem_shared/subscriptionListDeltas-ce84gpwL.mjs +0 -111
@@ -1 +0,0 @@
1
- export { R as RANK_TIEBREAK, e as encodePartitionKey, m as matchesRankStaticWhere, c as rankKeyFromDoc, r as rankTableName, a as resolveRankPartition, s as sortColumnName } from './rank-CrkEIpF4.mjs';
@@ -1,132 +0,0 @@
1
- const RLS_UNWRAP_SYMBOL = /* @__PURE__ */ Symbol.for("lunora.ctxdb.rls-unwrap");
2
- class RlsRequiredError extends Error {
3
- code = "RLS_REQUIRED";
4
- status = 403;
5
- table;
6
- constructor(table) {
7
- super(
8
- `ctx.db access to "${table}" is denied: the schema is marked .rls("required"), so this table is protected. Apply RLS with .use(rls(policies)) in the procedure, or mark the table .public() to opt it out.`
9
- );
10
- this.name = "RlsRequiredError";
11
- this.table = table;
12
- }
13
- }
14
- const guardWriter = (raw, schema, tableOfId) => {
15
- if (schema.rlsMode !== "required") {
16
- return raw;
17
- }
18
- const base = raw;
19
- const isProtected = (tableName) => {
20
- const definition = schema.tables[tableName];
21
- return definition !== void 0 && definition.isPublic !== true;
22
- };
23
- const guardTable = (tableName) => {
24
- if (isProtected(tableName)) {
25
- throw new RlsRequiredError(tableName);
26
- }
27
- };
28
- const guardById = async (id, expectedTable) => {
29
- if (expectedTable !== void 0) {
30
- guardTable(expectedTable);
31
- return;
32
- }
33
- const tableName = await tableOfId(id);
34
- if (tableName !== void 0) {
35
- guardTable(tableName);
36
- }
37
- };
38
- const baseRankBefore = base.rankBefore;
39
- const guarded = {
40
- ...raw,
41
- [RLS_UNWRAP_SYMBOL]: raw,
42
- aggregate: (tableName, options) => {
43
- guardTable(tableName);
44
- return base.aggregate(tableName, options);
45
- },
46
- count: (tableName, whereOrArgs) => {
47
- guardTable(tableName);
48
- return base.count(tableName, whereOrArgs);
49
- },
50
- delete: async (id, expectedTable, options) => {
51
- await guardById(id, expectedTable);
52
- return base.delete(id, expectedTable, options);
53
- },
54
- deleteMany: async (ids, options, expectedTable) => {
55
- for (const id of ids) {
56
- await guardById(id, expectedTable);
57
- }
58
- return base.deleteMany(ids, options, expectedTable);
59
- },
60
- findFirst: (tableName, args) => {
61
- guardTable(tableName);
62
- return base.findFirst(tableName, args);
63
- },
64
- findFirstOrThrow: (tableName, args) => {
65
- guardTable(tableName);
66
- return base.findFirstOrThrow(tableName, args);
67
- },
68
- findMany: (tableName, args) => {
69
- guardTable(tableName);
70
- return base.findMany(tableName, args);
71
- },
72
- get: async (id, expectedTable) => {
73
- await guardById(id, expectedTable);
74
- return base.get(id, expectedTable);
75
- },
76
- groupBy: (tableName, options) => {
77
- guardTable(tableName);
78
- return base.groupBy(tableName, options);
79
- },
80
- insert: (tableName, document, options) => {
81
- guardTable(tableName);
82
- return base.insert(tableName, document, options);
83
- },
84
- insertMany: (tableName, documents, options) => {
85
- guardTable(tableName);
86
- return base.insertMany(tableName, documents, options);
87
- },
88
- insertManyUnsafe: (tableName, documents, options) => {
89
- guardTable(tableName);
90
- return base.insertManyUnsafe(tableName, documents, options);
91
- },
92
- patch: async (id, patch, expectedTable) => {
93
- await guardById(id, expectedTable);
94
- return base.patch(id, patch, expectedTable);
95
- },
96
- patchMany: async (patches, options, expectedTable) => {
97
- for (const entry of patches) {
98
- await guardById(entry.id, expectedTable);
99
- }
100
- return base.patchMany(patches, options, expectedTable);
101
- },
102
- query: (tableName) => {
103
- guardTable(tableName);
104
- return base.query(tableName);
105
- },
106
- rank: (tableName, indexName, options) => {
107
- guardTable(tableName);
108
- return base.rank(tableName, indexName, options);
109
- },
110
- rankPage: (tableName, indexName, options) => {
111
- guardTable(tableName);
112
- return base.rankPage(tableName, indexName, options);
113
- },
114
- replace: async (id, document, expectedTable) => {
115
- await guardById(id, expectedTable);
116
- return base.replace(id, document, expectedTable);
117
- },
118
- restore: async (id, expectedTable) => {
119
- await guardById(id, expectedTable);
120
- return base.restore?.(id, expectedTable);
121
- }
122
- };
123
- if (baseRankBefore) {
124
- guarded["rankBefore"] = (tableName, indexName, options) => {
125
- guardTable(tableName);
126
- return baseRankBefore(tableName, indexName, options);
127
- };
128
- }
129
- return guarded;
130
- };
131
-
132
- export { RLS_UNWRAP_SYMBOL, RlsRequiredError, guardWriter };