@lunora/do 1.0.0-alpha.2 → 1.0.0-alpha.21
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/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +1162 -114
- package/dist/index.d.ts +1162 -114
- package/dist/index.mjs +27 -22
- package/dist/packem_shared/{ADMIN_FUNCTION_PREFIX-Dzdqq5J2.mjs → ADMIN_FUNCTIONS-DSUQ5fX9.mjs} +49 -3
- package/dist/packem_shared/{applyCdcChanges-Ctdmxmrv.mjs → CDC_LOG_TABLE-DSycmnDf.mjs} +5 -1
- package/dist/packem_shared/{DATA_MIGRATION_STATE_TABLE-PTtTiQ7U.mjs → DATA_MIGRATION_STATE_TABLE-DfPxn8I0.mjs} +5 -1
- package/dist/packem_shared/{assertFlatPredicate-DyVYReuT.mjs → DEFAULT_MAX_RELATION_KEYS-DU-Y4-LJ.mjs} +51 -2
- package/dist/packem_shared/{assertValidClientId-CBZ1zC96.mjs → NotUniqueError-Do5h_jiW.mjs} +127 -37
- package/dist/packem_shared/{rank-CrkEIpF4.mjs → RANK_TIEBREAK-CXhdcA1o.mjs} +2 -13
- package/dist/packem_shared/{guardWriter-u3UlnCH5.mjs → RLS_UNWRAP_SYMBOL-EtGQdC9d.mjs} +6 -2
- package/dist/packem_shared/{ROOT_DO_SIZE_WARN_BYTES-DQkmGiCS.mjs → ROOT_DO_SIZE_WARN_BYTES-BfPNp3Jh.mjs} +2342 -200
- package/dist/packem_shared/{ReactiveCache-ByVzgH3d.mjs → ReactiveCache-BYlSGY0N.mjs} +1 -28
- package/dist/packem_shared/{applyOnDelete-CMif2RKw.mjs → applyOnDelete-BQ-8ZlZ1.mjs} +19 -9
- package/dist/packem_shared/{buildSeekWhere-lVsNXSLy.mjs → applySelect-BvZdFUBT.mjs} +18 -1
- package/dist/packem_shared/{backfillAggregateIndexes-BF5eL7kW.mjs → backfillAggregateIndexes-BZsOqDXP.mjs} +3 -2
- package/dist/packem_shared/{compileWhereSql-CXrhFA3G.mjs → compileWhereSql-MW_Lk8nJ.mjs} +3 -2
- package/dist/packem_shared/ctx-db-idempotency-BdcNpvY4.mjs +108 -0
- package/dist/packem_shared/ctx-db-shapes-0RaIOy7J.mjs +53 -0
- package/dist/packem_shared/diffExternalSource-Cx9HUPJj.mjs +44 -0
- package/dist/packem_shared/isSourceDue-9mJRJ9Ld.mjs +40 -0
- package/dist/packem_shared/materializeExternalRows-Bj6EXy50.mjs +23 -0
- package/dist/packem_shared/{runShardMigrations-C3bn5r93.mjs → runShardMigrations-nIwoQeOK.mjs} +6 -4
- package/dist/packem_shared/serialize-sql-BlRUoiQe.mjs +14 -0
- package/dist/packem_shared/{serveRelationFanout-Clr1a05L.mjs → serveRelationFanout-C5axmGDj.mjs} +1 -1
- package/dist/packem_shared/stableStringify-MydiuScU.mjs +40 -0
- package/dist/packem_shared/subscription-delivery-CK8qga-k.mjs +347 -0
- package/dist/packem_shared/subscriptionListDeltas-BxygQlXT.mjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/ctx-db-idempotency-DkC9rP91.mjs +0 -35
- package/dist/packem_shared/encodePartitionKey-C6blLR5K.mjs +0 -1
- /package/dist/packem_shared/{matchesStaticWhere-CFk6adSu.mjs → AGGREGATE_SQL_FUNCTION-CFk6adSu.mjs} +0 -0
- /package/dist/packem_shared/{AUTH_METRICS_BUCKET_MS-CiHHYeJi.mjs → AUTH_METRICS_BUCKETS_TABLE-CiHHYeJi.mjs} +0 -0
- /package/dist/packem_shared/{ensureFunctionMetricsTables-UDNVD7FS.mjs → FUNCTION_METRICS_BUCKETS_TABLE-UDNVD7FS.mjs} +0 -0
- /package/dist/packem_shared/{clearCapturedMail-CPpgl-dX.mjs → MAIL_RETENTION-CPpgl-dX.mjs} +0 -0
- /package/dist/packem_shared/{assertReadonly-dDcFE1YZ.mjs → MAX_SQL_ROWS-dDcFE1YZ.mjs} +0 -0
- /package/dist/packem_shared/{buildSecurityAudit-CCAvoFlr.mjs → MIN_ADMIN_TOKEN_LENGTH-CCAvoFlr.mjs} +0 -0
- /package/dist/packem_shared/{ftsTableName-BLEMawrp.mjs → buildFtsMatch-BLEMawrp.mjs} +0 -0
- /package/dist/packem_shared/{runTriggers-5N6_Fx0A.mjs → hasTrigger-5N6_Fx0A.mjs} +0 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
const TAG = "$lunora.wire$";
|
|
2
|
+
const MAX_DEPTH = 64;
|
|
3
|
+
const MAX_BIGINT_DIGITS = 1024;
|
|
4
|
+
const UNSAFE_KEY = "__proto__";
|
|
5
|
+
const TYPED_ARRAY_CTORS = {
|
|
6
|
+
BigInt64Array,
|
|
7
|
+
BigUint64Array,
|
|
8
|
+
Float32Array,
|
|
9
|
+
Float64Array,
|
|
10
|
+
Int8Array,
|
|
11
|
+
Int16Array,
|
|
12
|
+
Int32Array,
|
|
13
|
+
Uint8Array,
|
|
14
|
+
Uint8ClampedArray,
|
|
15
|
+
Uint16Array,
|
|
16
|
+
Uint32Array
|
|
17
|
+
};
|
|
18
|
+
const ERROR_CTORS = {
|
|
19
|
+
Error,
|
|
20
|
+
EvalError,
|
|
21
|
+
RangeError,
|
|
22
|
+
ReferenceError,
|
|
23
|
+
SyntaxError,
|
|
24
|
+
TypeError,
|
|
25
|
+
URIError
|
|
26
|
+
};
|
|
27
|
+
const toBase64 = (bytes) => {
|
|
28
|
+
let binary = "";
|
|
29
|
+
const chunk = 32768;
|
|
30
|
+
for (let index = 0; index < bytes.length; index += chunk) {
|
|
31
|
+
binary += String.fromCharCode(...bytes.subarray(index, index + chunk));
|
|
32
|
+
}
|
|
33
|
+
return btoa(binary);
|
|
34
|
+
};
|
|
35
|
+
const fromBase64 = (base64) => {
|
|
36
|
+
const binary = atob(base64);
|
|
37
|
+
const bytes = new Uint8Array(binary.length);
|
|
38
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
39
|
+
bytes[index] = binary.codePointAt(index) ?? 0;
|
|
40
|
+
}
|
|
41
|
+
return bytes;
|
|
42
|
+
};
|
|
43
|
+
const encodeWire = (value, depth = 0) => {
|
|
44
|
+
if (depth > MAX_DEPTH) {
|
|
45
|
+
throw new RangeError(`wire-codec: value nesting exceeds the ${MAX_DEPTH}-level limit`);
|
|
46
|
+
}
|
|
47
|
+
if (value === void 0) {
|
|
48
|
+
return [TAG, "undefined"];
|
|
49
|
+
}
|
|
50
|
+
if (value === null) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const kind = typeof value;
|
|
54
|
+
if (kind === "bigint") {
|
|
55
|
+
return [TAG, "bigint", value.toString()];
|
|
56
|
+
}
|
|
57
|
+
if (kind === "number") {
|
|
58
|
+
const numeric = value;
|
|
59
|
+
if (Number.isNaN(numeric)) {
|
|
60
|
+
return [TAG, "nan"];
|
|
61
|
+
}
|
|
62
|
+
if (numeric === Infinity) {
|
|
63
|
+
return [TAG, "inf"];
|
|
64
|
+
}
|
|
65
|
+
if (numeric === -Infinity) {
|
|
66
|
+
return [TAG, "-inf"];
|
|
67
|
+
}
|
|
68
|
+
return numeric;
|
|
69
|
+
}
|
|
70
|
+
if (kind !== "object") {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
if (value instanceof Date) {
|
|
74
|
+
return [TAG, "date", encodeWire(value.getTime(), depth + 1)];
|
|
75
|
+
}
|
|
76
|
+
if (value instanceof Error) {
|
|
77
|
+
const error = value;
|
|
78
|
+
const properties = {};
|
|
79
|
+
for (const key of Object.keys(error)) {
|
|
80
|
+
if (error[key] !== void 0) {
|
|
81
|
+
properties[key] = encodeWire(error[key], depth + 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const encodedError = [TAG, "error", error.name, error.message, properties];
|
|
85
|
+
if (error.cause !== void 0) {
|
|
86
|
+
encodedError.push(encodeWire(error.cause, depth + 1));
|
|
87
|
+
}
|
|
88
|
+
return encodedError;
|
|
89
|
+
}
|
|
90
|
+
if (value instanceof URL) {
|
|
91
|
+
return [TAG, "url", value.href];
|
|
92
|
+
}
|
|
93
|
+
if (value instanceof Map) {
|
|
94
|
+
return [TAG, "map", [...value.entries()].map(([k, v]) => [encodeWire(k, depth + 1), encodeWire(v, depth + 1)])];
|
|
95
|
+
}
|
|
96
|
+
if (value instanceof Set) {
|
|
97
|
+
return [TAG, "set", [...value].map((item) => encodeWire(item, depth + 1))];
|
|
98
|
+
}
|
|
99
|
+
if (value instanceof ArrayBuffer) {
|
|
100
|
+
return [TAG, "bytes", toBase64(new Uint8Array(value)), "ArrayBuffer"];
|
|
101
|
+
}
|
|
102
|
+
if (ArrayBuffer.isView(value)) {
|
|
103
|
+
const view = value;
|
|
104
|
+
const ctorName = view.constructor.name;
|
|
105
|
+
const bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
106
|
+
return ctorName === "Uint8Array" ? [TAG, "bytes", toBase64(bytes)] : [TAG, "bytes", toBase64(bytes), ctorName];
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
const encoded = value.map((item) => encodeWire(item, depth + 1));
|
|
110
|
+
return encoded.length > 0 && encoded[0] === TAG ? [TAG, "arr", encoded] : encoded;
|
|
111
|
+
}
|
|
112
|
+
const proto = Object.getPrototypeOf(value);
|
|
113
|
+
if (proto !== null && proto !== Object.prototype) {
|
|
114
|
+
const name = value.constructor?.name ?? "value";
|
|
115
|
+
throw new TypeError(
|
|
116
|
+
`wire-codec: cannot encode a ${name} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
const source = value;
|
|
120
|
+
const result = {};
|
|
121
|
+
for (const key of Object.keys(source)) {
|
|
122
|
+
const field = source[key];
|
|
123
|
+
if (field !== void 0) {
|
|
124
|
+
result[key] = encodeWire(field, depth + 1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
};
|
|
129
|
+
const decodeWire = (value, depth = 0) => {
|
|
130
|
+
if (depth > MAX_DEPTH) {
|
|
131
|
+
throw new RangeError(`wire-codec: value nesting exceeds the ${MAX_DEPTH}-level limit`);
|
|
132
|
+
}
|
|
133
|
+
if (value === null || typeof value !== "object") {
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
if (Array.isArray(value)) {
|
|
137
|
+
if (value[0] === TAG) {
|
|
138
|
+
const tag = value[1];
|
|
139
|
+
switch (tag) {
|
|
140
|
+
case "-inf": {
|
|
141
|
+
return -Infinity;
|
|
142
|
+
}
|
|
143
|
+
case "arr": {
|
|
144
|
+
return value[2].map((item) => decodeWire(item, depth + 1));
|
|
145
|
+
}
|
|
146
|
+
case "bigint": {
|
|
147
|
+
const raw = value[2];
|
|
148
|
+
if (typeof raw !== "string" || raw.length > MAX_BIGINT_DIGITS || !/^-?\d+$/.test(raw)) {
|
|
149
|
+
throw new RangeError(`wire-codec: invalid or over-long bigint (max ${MAX_BIGINT_DIGITS} digits)`);
|
|
150
|
+
}
|
|
151
|
+
return BigInt(raw);
|
|
152
|
+
}
|
|
153
|
+
case "date": {
|
|
154
|
+
return new Date(decodeWire(value[2], depth + 1));
|
|
155
|
+
}
|
|
156
|
+
case "map": {
|
|
157
|
+
return new Map(value[2].map(([k, v]) => [decodeWire(k, depth + 1), decodeWire(v, depth + 1)]));
|
|
158
|
+
}
|
|
159
|
+
case "set": {
|
|
160
|
+
return new Set(value[2].map((item) => decodeWire(item, depth + 1)));
|
|
161
|
+
}
|
|
162
|
+
case "url": {
|
|
163
|
+
return new URL(value[2]);
|
|
164
|
+
}
|
|
165
|
+
case "error": {
|
|
166
|
+
const name = value[2];
|
|
167
|
+
const message = value[3];
|
|
168
|
+
const Ctor = (Object.hasOwn(ERROR_CTORS, name) ? ERROR_CTORS[name] : void 0) ?? Error;
|
|
169
|
+
const error = new Ctor(message);
|
|
170
|
+
if (error.name !== name) {
|
|
171
|
+
Object.defineProperty(error, "name", { configurable: true, value: name, writable: true });
|
|
172
|
+
}
|
|
173
|
+
const props = decodeWire(value[4], depth + 1);
|
|
174
|
+
for (const key of Object.keys(props)) {
|
|
175
|
+
if (key === UNSAFE_KEY) {
|
|
176
|
+
Object.defineProperty(error, key, { configurable: true, enumerable: true, value: props[key], writable: true });
|
|
177
|
+
} else {
|
|
178
|
+
error[key] = props[key];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (value.length > 5) {
|
|
182
|
+
Object.defineProperty(error, "cause", { configurable: true, value: decodeWire(value[5], depth + 1), writable: true });
|
|
183
|
+
}
|
|
184
|
+
return error;
|
|
185
|
+
}
|
|
186
|
+
case "bytes": {
|
|
187
|
+
const bytes = fromBase64(value[2]);
|
|
188
|
+
const ctorName = value[3] ?? "Uint8Array";
|
|
189
|
+
if (ctorName === "ArrayBuffer") {
|
|
190
|
+
return bytes.buffer.byteLength === bytes.byteLength ? bytes.buffer : bytes.slice().buffer;
|
|
191
|
+
}
|
|
192
|
+
const Ctor = Object.hasOwn(TYPED_ARRAY_CTORS, ctorName) ? TYPED_ARRAY_CTORS[ctorName] : void 0;
|
|
193
|
+
return Ctor ? new Ctor(bytes.slice().buffer) : bytes;
|
|
194
|
+
}
|
|
195
|
+
case "inf": {
|
|
196
|
+
return Infinity;
|
|
197
|
+
}
|
|
198
|
+
case "nan": {
|
|
199
|
+
return Number.NaN;
|
|
200
|
+
}
|
|
201
|
+
case "undefined": {
|
|
202
|
+
return void 0;
|
|
203
|
+
}
|
|
204
|
+
default: {
|
|
205
|
+
return value.map((item) => decodeWire(item, depth + 1));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return value.map((item) => decodeWire(item, depth + 1));
|
|
210
|
+
}
|
|
211
|
+
const source = value;
|
|
212
|
+
const result = {};
|
|
213
|
+
for (const key of Object.keys(source)) {
|
|
214
|
+
const decoded = decodeWire(source[key], depth + 1);
|
|
215
|
+
if (key === UNSAFE_KEY) {
|
|
216
|
+
Object.defineProperty(result, key, { configurable: true, enumerable: true, value: decoded, writable: true });
|
|
217
|
+
} else {
|
|
218
|
+
result[key] = decoded;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return result;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const ROW_ID_FIELD = "_id";
|
|
225
|
+
const DELTA_FALLBACK_TABLE = "__lunora__";
|
|
226
|
+
const readRowId = (row) => {
|
|
227
|
+
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
228
|
+
return void 0;
|
|
229
|
+
}
|
|
230
|
+
const id = row[ROW_ID_FIELD];
|
|
231
|
+
return typeof id === "string" ? id : void 0;
|
|
232
|
+
};
|
|
233
|
+
const indexRowsById = (rows) => {
|
|
234
|
+
const byId = /* @__PURE__ */ new Map();
|
|
235
|
+
const order = [];
|
|
236
|
+
for (const row of rows) {
|
|
237
|
+
const id = readRowId(row);
|
|
238
|
+
if (id === void 0 || byId.has(id)) {
|
|
239
|
+
return void 0;
|
|
240
|
+
}
|
|
241
|
+
byId.set(id, row);
|
|
242
|
+
order.push(id);
|
|
243
|
+
}
|
|
244
|
+
return { byId, order };
|
|
245
|
+
};
|
|
246
|
+
const survivorsKeepOrder = (previous, next) => {
|
|
247
|
+
const survivingPrevious = previous.order.filter((id) => next.byId.has(id));
|
|
248
|
+
const survivingNext = next.order.filter((id) => previous.byId.has(id));
|
|
249
|
+
if (survivingPrevious.length !== survivingNext.length) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return survivingPrevious.every((id, index) => survivingNext[index] === id);
|
|
253
|
+
};
|
|
254
|
+
const collectDeleteDeltas = (previous, next, deltaTable, tableJson) => {
|
|
255
|
+
const out = [];
|
|
256
|
+
for (const id of previous.order) {
|
|
257
|
+
if (!next.byId.has(id)) {
|
|
258
|
+
out.push({
|
|
259
|
+
delta: { key: id, op: "delete", table: deltaTable },
|
|
260
|
+
frame: `{"key":${JSON.stringify(id)},"op":"delete","table":${tableJson}}`
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
};
|
|
266
|
+
const collectUpsertDeltas = (previous, next, deltaTable, tableJson) => {
|
|
267
|
+
const out = [];
|
|
268
|
+
for (const id of next.order) {
|
|
269
|
+
const nextRow = next.byId.get(id);
|
|
270
|
+
const previousRow = previous.byId.get(id);
|
|
271
|
+
const nextFingerprint = JSON.stringify(encodeWire(nextRow));
|
|
272
|
+
const previousFingerprint = previousRow === void 0 ? void 0 : JSON.stringify(previousRow);
|
|
273
|
+
if (previousFingerprint === nextFingerprint) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const op = previousFingerprint === void 0 ? "insert" : "update";
|
|
277
|
+
out.push({
|
|
278
|
+
delta: { key: id, op, row: nextRow, table: deltaTable },
|
|
279
|
+
frame: `{"key":${JSON.stringify(id)},"op":"${op}","row":${nextFingerprint},"table":${tableJson}}`
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return out;
|
|
283
|
+
};
|
|
284
|
+
const subscriptionListDeltas = (previousJson, nextResult, table, frames) => {
|
|
285
|
+
let parsed;
|
|
286
|
+
try {
|
|
287
|
+
parsed = JSON.parse(previousJson);
|
|
288
|
+
} catch {
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
if (!Array.isArray(parsed) || !Array.isArray(nextResult)) {
|
|
292
|
+
return void 0;
|
|
293
|
+
}
|
|
294
|
+
const previous = indexRowsById(parsed);
|
|
295
|
+
const next = indexRowsById(nextResult);
|
|
296
|
+
if (previous === void 0 || next === void 0) {
|
|
297
|
+
return void 0;
|
|
298
|
+
}
|
|
299
|
+
if (!survivorsKeepOrder(previous, next)) {
|
|
300
|
+
return void 0;
|
|
301
|
+
}
|
|
302
|
+
const deltaTable = table === "" ? DELTA_FALLBACK_TABLE : table;
|
|
303
|
+
const tableJson = JSON.stringify(deltaTable);
|
|
304
|
+
const framed = [...collectDeleteDeltas(previous, next, deltaTable, tableJson), ...collectUpsertDeltas(previous, next, deltaTable, tableJson)];
|
|
305
|
+
if (framed.length > next.order.length) {
|
|
306
|
+
return void 0;
|
|
307
|
+
}
|
|
308
|
+
if (frames !== void 0) {
|
|
309
|
+
for (const { frame } of framed) {
|
|
310
|
+
frames.push(frame);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return framed.map(({ delta }) => delta);
|
|
314
|
+
};
|
|
315
|
+
const trySendFrame = (ws, frame) => {
|
|
316
|
+
try {
|
|
317
|
+
ws.send(frame);
|
|
318
|
+
return true;
|
|
319
|
+
} catch {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const sendDeltaFrames = (ws, subId, deltaFrames, cursorSuffix) => {
|
|
324
|
+
const idJson = JSON.stringify(subId);
|
|
325
|
+
let delivered = true;
|
|
326
|
+
for (const deltaBody of deltaFrames) {
|
|
327
|
+
if (!trySendFrame(ws, `{"type":"delta","id":${idJson},"delta":${deltaBody}${cursorSuffix}}`)) {
|
|
328
|
+
delivered = false;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return delivered;
|
|
332
|
+
};
|
|
333
|
+
const awaitWsDrain = async (ws) => {
|
|
334
|
+
let attempts = 0;
|
|
335
|
+
while (attempts < 100) {
|
|
336
|
+
attempts += 1;
|
|
337
|
+
const buffered = ws.bufferedAmount;
|
|
338
|
+
if (typeof buffered !== "number" || buffered < 1048576) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
await new Promise((resolve) => {
|
|
342
|
+
setTimeout(resolve, 20);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export { awaitWsDrain as a, sendDeltaFrames as b, decodeWire as d, encodeWire as e, subscriptionListDeltas as s, trySendFrame as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { a as awaitWsDrain, b as sendDeltaFrames, s as subscriptionListDeltas, t as trySendFrame } from './subscription-delivery-CK8qga-k.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/do",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "Lunora Durable Objects: ShardDO (SQLite, OCC, hibernated WebSocket subscriptions) and SessionDO",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"directory": "packages/do"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist",
|
|
28
|
+
"./dist",
|
|
29
29
|
"README.md",
|
|
30
30
|
"LICENSE.md",
|
|
31
31
|
"__assets__"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
|
2
|
-
import { r as runDrizzle } from './do-exec-5eQy5cEi.mjs';
|
|
3
|
-
|
|
4
|
-
const IDEMPOTENCY_TABLE = "__idempotency";
|
|
5
|
-
const migrateIdempotency = (sql$1) => {
|
|
6
|
-
runDrizzle(
|
|
7
|
-
sql$1,
|
|
8
|
-
sql`CREATE TABLE IF NOT EXISTS ${sql.identifier(IDEMPOTENCY_TABLE)} (
|
|
9
|
-
identity TEXT NOT NULL,
|
|
10
|
-
mutation_id TEXT NOT NULL,
|
|
11
|
-
result_json TEXT NOT NULL,
|
|
12
|
-
ts REAL NOT NULL,
|
|
13
|
-
PRIMARY KEY (identity, mutation_id)
|
|
14
|
-
)`
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
const readIdempotent = (sql$1, identity, mutationId) => {
|
|
18
|
-
const rows = runDrizzle(
|
|
19
|
-
sql$1,
|
|
20
|
-
sql`SELECT result_json, ts FROM ${sql.identifier(IDEMPOTENCY_TABLE)} WHERE identity = ${identity} AND mutation_id = ${mutationId} LIMIT 1`
|
|
21
|
-
).toArray();
|
|
22
|
-
const row = rows[0];
|
|
23
|
-
return row === void 0 ? void 0 : { resultJson: row.result_json, ts: row.ts };
|
|
24
|
-
};
|
|
25
|
-
const writeIdempotent = (sql$1, identity, mutationId, resultJson, ts) => {
|
|
26
|
-
runDrizzle(
|
|
27
|
-
sql$1,
|
|
28
|
-
sql`INSERT OR IGNORE INTO ${sql.identifier(IDEMPOTENCY_TABLE)} (identity, mutation_id, result_json, ts) VALUES (${identity}, ${mutationId}, ${resultJson}, ${ts})`
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
const trimIdempotent = (sql$1, olderThanTs) => {
|
|
32
|
-
runDrizzle(sql$1, sql`DELETE FROM ${sql.identifier(IDEMPOTENCY_TABLE)} WHERE ts < ${olderThanTs}`);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { IDEMPOTENCY_TABLE as I, migrateIdempotency as m, readIdempotent as r, trimIdempotent as t, writeIdempotent as w };
|
|
@@ -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';
|
/package/dist/packem_shared/{matchesStaticWhere-CFk6adSu.mjs → AGGREGATE_SQL_FUNCTION-CFk6adSu.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/packem_shared/{buildSecurityAudit-CCAvoFlr.mjs → MIN_ADMIN_TOKEN_LENGTH-CCAvoFlr.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|