@lunora/do 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (99) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/index.d.mts +5722 -3497
  3. package/dist/index.d.ts +5722 -3497
  4. package/dist/index.mjs +1 -35
  5. package/dist/packem_shared/ADMIN_FUNCTIONS-PxZ8Lr9e.mjs +1 -0
  6. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-QYaiuty4.mjs +1 -0
  7. package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-D0wNaez7.mjs +22 -0
  8. package/dist/packem_shared/CDC_LOG_TABLE-E_J5LPoK.mjs +8 -0
  9. package/dist/packem_shared/ConflictError-C8GtJmjS.mjs +1 -0
  10. package/dist/packem_shared/CountRlsUnsupportedError-Cl8XpYDL.mjs +1 -0
  11. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-CaO6L0Ee.mjs +31 -0
  12. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-BRdmX7WW.mjs +1 -0
  13. package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-BPPeqM11.mjs +56 -0
  14. package/dist/packem_shared/GEO_DEFAULT_PRECISION-okRCkZ6r.mjs +1 -0
  15. package/dist/packem_shared/LogBuffer-bIvCelI-.mjs +1 -0
  16. package/dist/packem_shared/MAIL_RETENTION-KmozO2NQ.mjs +18 -0
  17. package/dist/packem_shared/MAX_SQL_ROWS-Bdu25ASB.mjs +2 -0
  18. package/dist/packem_shared/MIN_ADMIN_TOKEN_LENGTH-Ch6OW6_3.mjs +1 -0
  19. package/dist/packem_shared/NotFoundError-J3tjf4Uo.mjs +1 -0
  20. package/dist/packem_shared/NotUniqueError-GI79LNJB.mjs +1 -0
  21. package/dist/packem_shared/RANK_TIEBREAK-DtX8zQyc.mjs +1 -0
  22. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-C6_WX3dG.mjs +1 -0
  23. package/dist/packem_shared/ROOT_DO_SIZE_WARN_BYTES-oZjI_5uF.mjs +101 -0
  24. package/dist/packem_shared/ReactiveCache-1_9Rs7J_.mjs +1 -0
  25. package/dist/packem_shared/SCAN_DEP-D_yR9EeV.mjs +1 -0
  26. package/dist/packem_shared/SESSION_DO_TTL_DEFAULT-GvBy_DBz.mjs +1 -0
  27. package/dist/packem_shared/SHARD_REGISTRY_DO_NAME-Caa0fR4N.mjs +1 -0
  28. package/dist/packem_shared/aggregateTableName-G-eXyjcz.mjs +1 -0
  29. package/dist/packem_shared/applyOnDelete-BvQN7pDL.mjs +1 -0
  30. package/dist/packem_shared/applySelect-Bq2KOrkL.mjs +1 -0
  31. package/dist/packem_shared/armRestore-BNzdvQ_o.mjs +1 -0
  32. package/dist/packem_shared/backfillAggregateIndexes-BAQ3Fwwh.mjs +1 -0
  33. package/dist/packem_shared/buildFtsMatch-CV0Z7PWv.mjs +1 -0
  34. package/dist/packem_shared/compileWhereSql-BLcfs4QW.mjs +1 -0
  35. package/dist/packem_shared/constant-time-equal-BVG05Guz.mjs +1 -0
  36. package/dist/packem_shared/context-telemetry-BFO0N_e4.mjs +1 -0
  37. package/dist/packem_shared/createMetrics-B5oH1Xgn.mjs +1 -0
  38. package/dist/packem_shared/createSystemReader-DcDcrtM3.mjs +1 -0
  39. package/dist/packem_shared/ctx-db-idempotency-wiVoGnpQ.mjs +19 -0
  40. package/dist/packem_shared/ctx-db-shapes-DzX_H5q8.mjs +1 -0
  41. package/dist/packem_shared/diffExternalSource-DMpkJta1.mjs +1 -0
  42. package/dist/packem_shared/do-exec-BLe9lLrN.mjs +1 -0
  43. package/dist/packem_shared/do-sql-BYIQTG3z.mjs +1 -0
  44. package/dist/packem_shared/exportShardRows-kt42wijd.mjs +1 -0
  45. package/dist/packem_shared/hasTrigger-_rexbWMO.mjs +1 -0
  46. package/dist/packem_shared/isSoftDeleted-BvhQov04.mjs +9 -0
  47. package/dist/packem_shared/json-response-wrh9TBPw.mjs +1 -0
  48. package/dist/packem_shared/materializeExternalRows-BFmT9gsw.mjs +1 -0
  49. package/dist/packem_shared/renderSql-B5lF5Jd9.mjs +1 -0
  50. package/dist/packem_shared/runShardMigrations-bxOHpfID.mjs +5 -0
  51. package/dist/packem_shared/security-audit-BKUOgE0x.mjs +1 -0
  52. package/dist/packem_shared/selectExpiredIds-BGVP3d8-.mjs +1 -0
  53. package/dist/packem_shared/serialize-sql-DiRzL7A4.mjs +1 -0
  54. package/dist/packem_shared/serveRelationFanout-Ct5D2Tbk.mjs +1 -0
  55. package/dist/packem_shared/stableStringify-BjLh4gvA.mjs +1 -0
  56. package/dist/packem_shared/stableWireKey-YEHLaX6X.mjs +1 -0
  57. package/dist/packem_shared/subscriptionListDeltas-Bs69JbA8.mjs +1 -0
  58. package/dist/packem_shared/wire-codec-Ctnni0h6.mjs +1 -0
  59. package/package.json +5 -3
  60. package/dist/packem_shared/ADMIN_FUNCTIONS-Dzdqq5J2.mjs +0 -313
  61. package/dist/packem_shared/AGGREGATE_SQL_FUNCTION-CFk6adSu.mjs +0 -54
  62. package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-CiHHYeJi.mjs +0 -84
  63. package/dist/packem_shared/CDC_LOG_TABLE-Ctdmxmrv.mjs +0 -103
  64. package/dist/packem_shared/ConflictError-C0STs6bU.mjs +0 -13
  65. package/dist/packem_shared/CountRlsUnsupportedError-28ZvvwKS.mjs +0 -133
  66. package/dist/packem_shared/DATA_MIGRATION_STATE_TABLE-PTtTiQ7U.mjs +0 -237
  67. package/dist/packem_shared/DEFAULT_MAX_RELATION_KEYS-Dou2PWdO.mjs +0 -160
  68. package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-UDNVD7FS.mjs +0 -248
  69. package/dist/packem_shared/LogBuffer-B_Ezju_N.mjs +0 -37
  70. package/dist/packem_shared/MAIL_RETENTION-CPpgl-dX.mjs +0 -104
  71. package/dist/packem_shared/MAX_SQL_ROWS-dDcFE1YZ.mjs +0 -29
  72. package/dist/packem_shared/MIN_ADMIN_TOKEN_LENGTH-CCAvoFlr.mjs +0 -1
  73. package/dist/packem_shared/NotFoundError-CMuMZt81.mjs +0 -10
  74. package/dist/packem_shared/NotUniqueError-h_thNFSZ.mjs +0 -1809
  75. package/dist/packem_shared/RANK_TIEBREAK-C6blLR5K.mjs +0 -1
  76. package/dist/packem_shared/RLS_UNWRAP_SYMBOL-EtGQdC9d.mjs +0 -132
  77. package/dist/packem_shared/ROOT_DO_SIZE_WARN_BYTES-3lZ2yigq.mjs +0 -4003
  78. package/dist/packem_shared/ReactiveCache-ByVzgH3d.mjs +0 -259
  79. package/dist/packem_shared/SCAN_DEP-DLJF8dsj.mjs +0 -19
  80. package/dist/packem_shared/SESSION_DO_TTL_DEFAULT-ilPZsVwu.mjs +0 -180
  81. package/dist/packem_shared/SHARD_REGISTRY_DO_NAME-BsAbi5Mn.mjs +0 -146
  82. package/dist/packem_shared/aggregateTableName-CxNqY1Sl.mjs +0 -64
  83. package/dist/packem_shared/applyOnDelete-sA7o1CqD.mjs +0 -169
  84. package/dist/packem_shared/applySelect-BvZdFUBT.mjs +0 -101
  85. package/dist/packem_shared/armRestore-BJk53Ro8.mjs +0 -55
  86. package/dist/packem_shared/backfillAggregateIndexes-BbVPvciS.mjs +0 -80
  87. package/dist/packem_shared/buildFtsMatch-BLEMawrp.mjs +0 -38
  88. package/dist/packem_shared/compileWhereSql-CXrhFA3G.mjs +0 -127
  89. package/dist/packem_shared/createSystemReader-8CzSZP9V.mjs +0 -80
  90. package/dist/packem_shared/ctx-db-idempotency-DkC9rP91.mjs +0 -35
  91. package/dist/packem_shared/do-exec-5eQy5cEi.mjs +0 -12
  92. package/dist/packem_shared/do-sql-BCHCWtrD.mjs +0 -87
  93. package/dist/packem_shared/exportShardRows-DZEhUeyI.mjs +0 -156
  94. package/dist/packem_shared/hasTrigger-5N6_Fx0A.mjs +0 -20
  95. package/dist/packem_shared/rank-CrkEIpF4.mjs +0 -102
  96. package/dist/packem_shared/renderSql-D6eUcn2N.mjs +0 -16
  97. package/dist/packem_shared/runShardMigrations-PabobOjF.mjs +0 -103
  98. package/dist/packem_shared/security-audit-CucgBice.mjs +0 -158
  99. package/dist/packem_shared/serveRelationFanout-CFBKWJ8Q.mjs +0 -24
@@ -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 };