@lunora/do 1.0.0-alpha.4 → 1.0.0-alpha.41
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.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +5236 -3449
- package/dist/index.d.ts +5236 -3449
- package/dist/index.mjs +34 -25
- package/dist/packem_shared/{ADMIN_FUNCTIONS-Dzdqq5J2.mjs → ADMIN_FUNCTIONS-CnZkbXH_.mjs} +69 -8
- package/dist/packem_shared/{AGGREGATE_SQL_FUNCTION-CFk6adSu.mjs → AGGREGATE_SQL_FUNCTION-CQsu2Xga.mjs} +5 -3
- package/dist/packem_shared/{CDC_LOG_TABLE-Ctdmxmrv.mjs → CDC_LOG_TABLE-uwOJxJJZ.mjs} +8 -4
- package/dist/packem_shared/{ConflictError-C0STs6bU.mjs → ConflictError-CLoq37xH.mjs} +4 -5
- package/dist/packem_shared/{CountRlsUnsupportedError-28ZvvwKS.mjs → CountRlsUnsupportedError-BGxj0pgS.mjs} +4 -4
- package/dist/packem_shared/{DATA_MIGRATION_STATE_TABLE-PTtTiQ7U.mjs → DATA_MIGRATION_STATE_TABLE-CYwBpyTr.mjs} +11 -3
- package/dist/packem_shared/{DEFAULT_MAX_RELATION_KEYS-DyVYReuT.mjs → DEFAULT_MAX_RELATION_KEYS-BEan1CRD.mjs} +58 -7
- package/dist/packem_shared/GEO_DEFAULT_PRECISION-BWnsNmpP.mjs +114 -0
- package/dist/packem_shared/{MAX_SQL_ROWS-dDcFE1YZ.mjs → MAX_SQL_ROWS-iFAA8FbD.mjs} +35 -3
- package/dist/packem_shared/NotFoundError-C70b9hLw.mjs +9 -0
- package/dist/packem_shared/{NotUniqueError-B6tzuDmM.mjs → NotUniqueError-DbtlWwcG.mjs} +400 -114
- package/dist/packem_shared/{rank-CrkEIpF4.mjs → RANK_TIEBREAK-CXhdcA1o.mjs} +2 -13
- package/dist/packem_shared/{RLS_UNWRAP_SYMBOL-u3UlnCH5.mjs → RLS_UNWRAP_SYMBOL-DTvHvRzY.mjs} +22 -9
- package/dist/packem_shared/ROOT_DO_SIZE_WARN_BYTES-B4Cpm7Qv.mjs +7653 -0
- package/dist/packem_shared/{ReactiveCache-ByVzgH3d.mjs → ReactiveCache-DnSvbjil.mjs} +4 -30
- package/dist/packem_shared/{SESSION_DO_TTL_DEFAULT-ilPZsVwu.mjs → SESSION_DO_TTL_DEFAULT-BnSKgVO4.mjs} +16 -27
- package/dist/packem_shared/{SHARD_REGISTRY_DO_NAME-BsAbi5Mn.mjs → SHARD_REGISTRY_DO_NAME-D99roc-r.mjs} +12 -14
- package/dist/packem_shared/{applyOnDelete-CMif2RKw.mjs → applyOnDelete-BXSq3S70.mjs} +23 -12
- package/dist/packem_shared/{buildSeekWhere-lVsNXSLy.mjs → applySelect-WQY8m62C.mjs} +21 -2
- package/dist/packem_shared/{armRestore-BJk53Ro8.mjs → armRestore-4Px61hHS.mjs} +4 -10
- package/dist/packem_shared/{backfillAggregateIndexes-BbVPvciS.mjs → backfillAggregateIndexes-BGTwynwh.mjs} +4 -3
- package/dist/packem_shared/{compileWhereSql-CXrhFA3G.mjs → compileWhereSql-DE6yfRcQ.mjs} +5 -3
- package/dist/packem_shared/constant-time-equal-BVRWZgES.mjs +12 -0
- package/dist/packem_shared/context-telemetry-CDpyil58.mjs +223 -0
- package/dist/packem_shared/createMetrics-C4I2Yanj.mjs +1 -0
- package/dist/packem_shared/{createSystemReader-8CzSZP9V.mjs → createSystemReader-D12eNH13.mjs} +4 -2
- package/dist/packem_shared/ctx-db-idempotency-BdcNpvY4.mjs +108 -0
- package/dist/packem_shared/ctx-db-shapes-DTeFiHYS.mjs +53 -0
- package/dist/packem_shared/diffExternalSource-CovHfdyo.mjs +44 -0
- package/dist/packem_shared/{do-sql-BCHCWtrD.mjs → do-sql-CGAgiQUz.mjs} +2 -1
- package/dist/packem_shared/{exportShardRows-DZEhUeyI.mjs → exportShardRows-Dy3oFZ26.mjs} +4 -3
- package/dist/packem_shared/isSoftDeleted-CFJmhjFP.mjs +217 -0
- package/dist/packem_shared/json-response-BdbtpOhm.mjs +3 -0
- package/dist/packem_shared/materializeExternalRows-BtEGs1Fv.mjs +45 -0
- package/dist/packem_shared/{runShardMigrations-PabobOjF.mjs → runShardMigrations-BVax6rYu.mjs} +21 -4
- package/dist/packem_shared/selectExpiredIds-C5W29Upb.mjs +18 -0
- package/dist/packem_shared/serialize-sql-BlRUoiQe.mjs +14 -0
- package/dist/packem_shared/{serveRelationFanout-CFBKWJ8Q.mjs → serveRelationFanout-k7HTh3CC.mjs} +4 -7
- package/dist/packem_shared/stableStringify-mC40mZts.mjs +40 -0
- package/dist/packem_shared/stableWireKey-DKuXO7T5.mjs +6 -0
- package/dist/packem_shared/subscriptionListDeltas-CT76bYny.mjs +126 -0
- package/dist/packem_shared/wire-codec-CzQc1pvf.mjs +225 -0
- package/package.json +5 -3
- package/dist/packem_shared/NotFoundError-CMuMZt81.mjs +0 -10
- package/dist/packem_shared/RANK_TIEBREAK-C6blLR5K.mjs +0 -1
- package/dist/packem_shared/ROOT_DO_SIZE_WARN_BYTES-3lZ2yigq.mjs +0 -4003
- package/dist/packem_shared/ctx-db-idempotency-DkC9rP91.mjs +0 -35
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const compareKeys = (a, b) => {
|
|
2
|
+
if (a < b) {
|
|
3
|
+
return -1;
|
|
4
|
+
}
|
|
5
|
+
return a > b ? 1 : 0;
|
|
6
|
+
};
|
|
7
|
+
const stableStringify = (value) => {
|
|
8
|
+
if (value === void 0) {
|
|
9
|
+
return "null";
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === "bigint") {
|
|
12
|
+
throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");
|
|
13
|
+
}
|
|
14
|
+
if (value === null || typeof value !== "object") {
|
|
15
|
+
return JSON.stringify(value);
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
19
|
+
}
|
|
20
|
+
const proto = Object.getPrototypeOf(value);
|
|
21
|
+
if (proto !== null && proto !== Object.prototype) {
|
|
22
|
+
const name = value.constructor?.name ?? "value";
|
|
23
|
+
throw new TypeError(
|
|
24
|
+
`stableStringify: cannot use a ${name} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const record = value;
|
|
28
|
+
const keys = Object.keys(record).toSorted(compareKeys);
|
|
29
|
+
const parts = [];
|
|
30
|
+
for (const key of keys) {
|
|
31
|
+
const raw = record[key];
|
|
32
|
+
if (raw === void 0) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
|
|
36
|
+
}
|
|
37
|
+
return `{${parts.join(",")}}`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { stableStringify };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { e as encodeWire } from './wire-codec-CzQc1pvf.mjs';
|
|
2
|
+
|
|
3
|
+
const ROW_ID_FIELD = "_id";
|
|
4
|
+
const DELTA_FALLBACK_TABLE = "__lunora__";
|
|
5
|
+
const readRowId = (row) => {
|
|
6
|
+
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const id = row[ROW_ID_FIELD];
|
|
10
|
+
return typeof id === "string" ? id : void 0;
|
|
11
|
+
};
|
|
12
|
+
const indexRowsById = (rows) => {
|
|
13
|
+
const byId = /* @__PURE__ */ new Map();
|
|
14
|
+
const order = [];
|
|
15
|
+
for (const row of rows) {
|
|
16
|
+
const id = readRowId(row);
|
|
17
|
+
if (id === void 0 || byId.has(id)) {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
byId.set(id, row);
|
|
21
|
+
order.push(id);
|
|
22
|
+
}
|
|
23
|
+
return { byId, order };
|
|
24
|
+
};
|
|
25
|
+
const survivorsKeepOrder = (previous, next) => {
|
|
26
|
+
const survivingPrevious = previous.order.filter((id) => next.byId.has(id));
|
|
27
|
+
const survivingNext = next.order.filter((id) => previous.byId.has(id));
|
|
28
|
+
if (survivingPrevious.length !== survivingNext.length) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return survivingPrevious.every((id, index) => survivingNext[index] === id);
|
|
32
|
+
};
|
|
33
|
+
const collectDeleteDeltas = (previous, next, deltaTable, tableJson) => {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const id of previous.order) {
|
|
36
|
+
if (!next.byId.has(id)) {
|
|
37
|
+
out.push({
|
|
38
|
+
delta: { key: id, op: "delete", table: deltaTable },
|
|
39
|
+
frame: `{"key":${JSON.stringify(id)},"op":"delete","table":${tableJson}}`
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
};
|
|
45
|
+
const collectUpsertDeltas = (previous, next, deltaTable, tableJson) => {
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const id of next.order) {
|
|
48
|
+
const nextRow = next.byId.get(id);
|
|
49
|
+
const previousRow = previous.byId.get(id);
|
|
50
|
+
const nextFingerprint = JSON.stringify(encodeWire(nextRow));
|
|
51
|
+
const previousFingerprint = previousRow === void 0 ? void 0 : JSON.stringify(previousRow);
|
|
52
|
+
if (previousFingerprint === nextFingerprint) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const op = previousFingerprint === void 0 ? "insert" : "update";
|
|
56
|
+
out.push({
|
|
57
|
+
delta: { key: id, op, row: nextRow, table: deltaTable },
|
|
58
|
+
frame: `{"key":${JSON.stringify(id)},"op":"${op}","row":${nextFingerprint},"table":${tableJson}}`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
};
|
|
63
|
+
const subscriptionListDeltas = (previousJson, nextResult, table, frames) => {
|
|
64
|
+
let parsed;
|
|
65
|
+
try {
|
|
66
|
+
parsed = JSON.parse(previousJson);
|
|
67
|
+
} catch {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
if (!Array.isArray(parsed) || !Array.isArray(nextResult)) {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
const previous = indexRowsById(parsed);
|
|
74
|
+
const next = indexRowsById(nextResult);
|
|
75
|
+
if (previous === void 0 || next === void 0) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
if (!survivorsKeepOrder(previous, next)) {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
const deltaTable = table === "" ? DELTA_FALLBACK_TABLE : table;
|
|
82
|
+
const tableJson = JSON.stringify(deltaTable);
|
|
83
|
+
const framed = [...collectDeleteDeltas(previous, next, deltaTable, tableJson), ...collectUpsertDeltas(previous, next, deltaTable, tableJson)];
|
|
84
|
+
if (framed.length > next.order.length) {
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
if (frames !== void 0) {
|
|
88
|
+
for (const { frame } of framed) {
|
|
89
|
+
frames.push(frame);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return framed.map(({ delta }) => delta);
|
|
93
|
+
};
|
|
94
|
+
const trySendFrame = (ws, frame) => {
|
|
95
|
+
try {
|
|
96
|
+
ws.send(frame);
|
|
97
|
+
return true;
|
|
98
|
+
} catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const sendDeltaFrames = (ws, subId, deltaFrames, cursorSuffix) => {
|
|
103
|
+
const idJson = JSON.stringify(subId);
|
|
104
|
+
let delivered = true;
|
|
105
|
+
for (const deltaBody of deltaFrames) {
|
|
106
|
+
if (!trySendFrame(ws, `{"type":"delta","id":${idJson},"delta":${deltaBody}${cursorSuffix}}`)) {
|
|
107
|
+
delivered = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return delivered;
|
|
111
|
+
};
|
|
112
|
+
const awaitWsDrain = async (ws) => {
|
|
113
|
+
let attempts = 0;
|
|
114
|
+
while (attempts < 100) {
|
|
115
|
+
attempts += 1;
|
|
116
|
+
const buffered = ws.bufferedAmount;
|
|
117
|
+
if (typeof buffered !== "number" || buffered < 1048576) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
await new Promise((resolve) => {
|
|
121
|
+
setTimeout(resolve, 20);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export { awaitWsDrain, sendDeltaFrames, subscriptionListDeltas, trySendFrame };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const toBase64 = (bytes) => {
|
|
2
|
+
let binary = "";
|
|
3
|
+
const chunk = 32768;
|
|
4
|
+
for (let index = 0; index < bytes.length; index += chunk) {
|
|
5
|
+
binary += String.fromCharCode(...bytes.subarray(index, index + chunk));
|
|
6
|
+
}
|
|
7
|
+
return btoa(binary);
|
|
8
|
+
};
|
|
9
|
+
const fromBase64 = (base64) => {
|
|
10
|
+
const binary = atob(base64);
|
|
11
|
+
const bytes = new Uint8Array(binary.length);
|
|
12
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
13
|
+
bytes[index] = binary.codePointAt(index) ?? 0;
|
|
14
|
+
}
|
|
15
|
+
return bytes;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const TAG = "$lunora.wire$";
|
|
19
|
+
const MAX_DEPTH = 64;
|
|
20
|
+
const MAX_BIGINT_DIGITS = 1024;
|
|
21
|
+
const UNSAFE_KEY = "__proto__";
|
|
22
|
+
const TYPED_ARRAY_CTORS = {
|
|
23
|
+
BigInt64Array,
|
|
24
|
+
BigUint64Array,
|
|
25
|
+
Float32Array,
|
|
26
|
+
Float64Array,
|
|
27
|
+
Int8Array,
|
|
28
|
+
Int16Array,
|
|
29
|
+
Int32Array,
|
|
30
|
+
Uint8Array,
|
|
31
|
+
Uint8ClampedArray,
|
|
32
|
+
Uint16Array,
|
|
33
|
+
Uint32Array
|
|
34
|
+
};
|
|
35
|
+
const ERROR_CTORS = {
|
|
36
|
+
Error,
|
|
37
|
+
EvalError,
|
|
38
|
+
RangeError,
|
|
39
|
+
ReferenceError,
|
|
40
|
+
SyntaxError,
|
|
41
|
+
TypeError,
|
|
42
|
+
URIError
|
|
43
|
+
};
|
|
44
|
+
const encodeWire = (value, depth = 0) => {
|
|
45
|
+
if (depth > MAX_DEPTH) {
|
|
46
|
+
throw new RangeError(`wire-codec: value nesting exceeds the ${MAX_DEPTH}-level limit`);
|
|
47
|
+
}
|
|
48
|
+
if (value === void 0) {
|
|
49
|
+
return [TAG, "undefined"];
|
|
50
|
+
}
|
|
51
|
+
if (value === null) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const kind = typeof value;
|
|
55
|
+
if (kind === "bigint") {
|
|
56
|
+
return [TAG, "bigint", value.toString()];
|
|
57
|
+
}
|
|
58
|
+
if (kind === "number") {
|
|
59
|
+
const numeric = value;
|
|
60
|
+
if (Number.isNaN(numeric)) {
|
|
61
|
+
return [TAG, "nan"];
|
|
62
|
+
}
|
|
63
|
+
if (numeric === Infinity) {
|
|
64
|
+
return [TAG, "inf"];
|
|
65
|
+
}
|
|
66
|
+
if (numeric === -Infinity) {
|
|
67
|
+
return [TAG, "-inf"];
|
|
68
|
+
}
|
|
69
|
+
return numeric;
|
|
70
|
+
}
|
|
71
|
+
if (kind !== "object") {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
if (value instanceof Date) {
|
|
75
|
+
return [TAG, "date", encodeWire(value.getTime(), depth + 1)];
|
|
76
|
+
}
|
|
77
|
+
if (value instanceof Error) {
|
|
78
|
+
const error = value;
|
|
79
|
+
const properties = {};
|
|
80
|
+
for (const key of Object.keys(error)) {
|
|
81
|
+
if (error[key] !== void 0) {
|
|
82
|
+
properties[key] = encodeWire(error[key], depth + 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const encodedError = [TAG, "error", error.name, error.message, properties];
|
|
86
|
+
if (error.cause !== void 0) {
|
|
87
|
+
encodedError.push(encodeWire(error.cause, depth + 1));
|
|
88
|
+
}
|
|
89
|
+
return encodedError;
|
|
90
|
+
}
|
|
91
|
+
if (value instanceof URL) {
|
|
92
|
+
return [TAG, "url", value.href];
|
|
93
|
+
}
|
|
94
|
+
if (value instanceof Map) {
|
|
95
|
+
return [TAG, "map", [...value.entries()].map(([k, v]) => [encodeWire(k, depth + 1), encodeWire(v, depth + 1)])];
|
|
96
|
+
}
|
|
97
|
+
if (value instanceof Set) {
|
|
98
|
+
return [TAG, "set", [...value].map((item) => encodeWire(item, depth + 1))];
|
|
99
|
+
}
|
|
100
|
+
if (value instanceof ArrayBuffer) {
|
|
101
|
+
return [TAG, "bytes", toBase64(new Uint8Array(value)), "ArrayBuffer"];
|
|
102
|
+
}
|
|
103
|
+
if (ArrayBuffer.isView(value)) {
|
|
104
|
+
const view = value;
|
|
105
|
+
const ctorName = view.constructor.name;
|
|
106
|
+
const bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
107
|
+
return ctorName === "Uint8Array" ? [TAG, "bytes", toBase64(bytes)] : [TAG, "bytes", toBase64(bytes), ctorName];
|
|
108
|
+
}
|
|
109
|
+
if (Array.isArray(value)) {
|
|
110
|
+
const encoded = value.map((item) => encodeWire(item, depth + 1));
|
|
111
|
+
return encoded.length > 0 && encoded[0] === TAG ? [TAG, "arr", encoded] : encoded;
|
|
112
|
+
}
|
|
113
|
+
const proto = Object.getPrototypeOf(value);
|
|
114
|
+
if (proto !== null && proto !== Object.prototype) {
|
|
115
|
+
const name = value.constructor?.name ?? "value";
|
|
116
|
+
throw new TypeError(
|
|
117
|
+
`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`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
const source = value;
|
|
121
|
+
const result = {};
|
|
122
|
+
for (const key of Object.keys(source)) {
|
|
123
|
+
const field = source[key];
|
|
124
|
+
if (field !== void 0) {
|
|
125
|
+
result[key] = encodeWire(field, depth + 1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
};
|
|
130
|
+
const decodeWire = (value, depth = 0) => {
|
|
131
|
+
if (depth > MAX_DEPTH) {
|
|
132
|
+
throw new RangeError(`wire-codec: value nesting exceeds the ${MAX_DEPTH}-level limit`);
|
|
133
|
+
}
|
|
134
|
+
if (value === null || typeof value !== "object") {
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
if (Array.isArray(value)) {
|
|
138
|
+
if (value[0] === TAG) {
|
|
139
|
+
const tag = value[1];
|
|
140
|
+
switch (tag) {
|
|
141
|
+
case "-inf": {
|
|
142
|
+
return -Infinity;
|
|
143
|
+
}
|
|
144
|
+
case "arr": {
|
|
145
|
+
return value[2].map((item) => decodeWire(item, depth + 1));
|
|
146
|
+
}
|
|
147
|
+
case "bigint": {
|
|
148
|
+
const raw = value[2];
|
|
149
|
+
if (typeof raw !== "string" || raw.length > MAX_BIGINT_DIGITS || !/^-?\d+$/.test(raw)) {
|
|
150
|
+
throw new RangeError(`wire-codec: invalid or over-long bigint (max ${MAX_BIGINT_DIGITS} digits)`);
|
|
151
|
+
}
|
|
152
|
+
return BigInt(raw);
|
|
153
|
+
}
|
|
154
|
+
case "date": {
|
|
155
|
+
return new Date(decodeWire(value[2], depth + 1));
|
|
156
|
+
}
|
|
157
|
+
case "map": {
|
|
158
|
+
return new Map(value[2].map(([k, v]) => [decodeWire(k, depth + 1), decodeWire(v, depth + 1)]));
|
|
159
|
+
}
|
|
160
|
+
case "set": {
|
|
161
|
+
return new Set(value[2].map((item) => decodeWire(item, depth + 1)));
|
|
162
|
+
}
|
|
163
|
+
case "url": {
|
|
164
|
+
return new URL(value[2]);
|
|
165
|
+
}
|
|
166
|
+
case "error": {
|
|
167
|
+
const name = value[2];
|
|
168
|
+
const message = value[3];
|
|
169
|
+
const Ctor = (Object.hasOwn(ERROR_CTORS, name) ? ERROR_CTORS[name] : void 0) ?? Error;
|
|
170
|
+
const error = new Ctor(message);
|
|
171
|
+
if (error.name !== name) {
|
|
172
|
+
Object.defineProperty(error, "name", { configurable: true, value: name, writable: true });
|
|
173
|
+
}
|
|
174
|
+
const props = decodeWire(value[4], depth + 1);
|
|
175
|
+
for (const key of Object.keys(props)) {
|
|
176
|
+
if (key === UNSAFE_KEY) {
|
|
177
|
+
Object.defineProperty(error, key, { configurable: true, enumerable: true, value: props[key], writable: true });
|
|
178
|
+
} else {
|
|
179
|
+
error[key] = props[key];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (value.length > 5) {
|
|
183
|
+
Object.defineProperty(error, "cause", { configurable: true, value: decodeWire(value[5], depth + 1), writable: true });
|
|
184
|
+
}
|
|
185
|
+
return error;
|
|
186
|
+
}
|
|
187
|
+
case "bytes": {
|
|
188
|
+
const bytes = fromBase64(value[2]);
|
|
189
|
+
const ctorName = value[3] ?? "Uint8Array";
|
|
190
|
+
if (ctorName === "ArrayBuffer") {
|
|
191
|
+
return bytes.buffer.byteLength === bytes.byteLength ? bytes.buffer : bytes.slice().buffer;
|
|
192
|
+
}
|
|
193
|
+
const Ctor = Object.hasOwn(TYPED_ARRAY_CTORS, ctorName) ? TYPED_ARRAY_CTORS[ctorName] : void 0;
|
|
194
|
+
return Ctor ? new Ctor(bytes.slice().buffer) : bytes;
|
|
195
|
+
}
|
|
196
|
+
case "inf": {
|
|
197
|
+
return Infinity;
|
|
198
|
+
}
|
|
199
|
+
case "nan": {
|
|
200
|
+
return Number.NaN;
|
|
201
|
+
}
|
|
202
|
+
case "undefined": {
|
|
203
|
+
return void 0;
|
|
204
|
+
}
|
|
205
|
+
default: {
|
|
206
|
+
return value.map((item) => decodeWire(item, depth + 1));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return value.map((item) => decodeWire(item, depth + 1));
|
|
211
|
+
}
|
|
212
|
+
const source = value;
|
|
213
|
+
const result = {};
|
|
214
|
+
for (const key of Object.keys(source)) {
|
|
215
|
+
const decoded = decodeWire(source[key], depth + 1);
|
|
216
|
+
if (key === UNSAFE_KEY) {
|
|
217
|
+
Object.defineProperty(result, key, { configurable: true, enumerable: true, value: decoded, writable: true });
|
|
218
|
+
} else {
|
|
219
|
+
result[key] = decoded;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export { decodeWire as d, encodeWire as e };
|
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.41",
|
|
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__"
|
|
@@ -46,7 +46,9 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@
|
|
49
|
+
"@lunora/errors": "1.0.0-alpha.7",
|
|
50
|
+
"@lunora/fingerprint": "1.0.0-alpha.3",
|
|
51
|
+
"@visulima/redact": "3.0.0",
|
|
50
52
|
"drizzle-orm": "^0.45.2"
|
|
51
53
|
},
|
|
52
54
|
"engines": {
|
|
@@ -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';
|