@bjornpagen/bumbledb 1.1.0 → 1.2.0
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/COOKBOOK.md +114 -11
- package/README.md +52 -9
- package/dist/capacity.d.ts +15 -55
- package/dist/capacity.d.ts.map +1 -1
- package/dist/capacity.js +63 -12
- package/dist/capacity.js.map +1 -1
- package/dist/changes.d.ts +26 -3
- package/dist/changes.d.ts.map +1 -1
- package/dist/changes.js +89 -44
- package/dist/changes.js.map +1 -1
- package/dist/closed.d.ts +23 -51
- package/dist/closed.d.ts.map +1 -1
- package/dist/closed.js +110 -168
- package/dist/closed.js.map +1 -1
- package/dist/codec.d.ts +4 -9
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +108 -183
- package/dist/codec.js.map +1 -1
- package/dist/compile.d.ts +16 -16
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +36 -15
- package/dist/compile.js.map +1 -1
- package/dist/db-native.d.ts +39 -0
- package/dist/db-native.d.ts.map +1 -1
- package/dist/db-native.js +8 -0
- package/dist/db-native.js.map +1 -1
- package/dist/db.d.ts +28 -8
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +91 -38
- package/dist/db.js.map +1 -1
- package/dist/errors.d.ts +11 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +13 -1
- package/dist/errors.js.map +1 -1
- package/dist/face.d.ts +19 -25
- package/dist/face.d.ts.map +1 -1
- package/dist/face.js +30 -24
- package/dist/face.js.map +1 -1
- package/dist/fields.d.ts +13 -26
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +89 -116
- package/dist/fields.js.map +1 -1
- package/dist/immutable.d.ts +10 -0
- package/dist/immutable.d.ts.map +1 -0
- package/dist/immutable.js +75 -0
- package/dist/immutable.js.map +1 -0
- package/dist/index.d.ts +14 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/log.d.ts +2 -0
- package/dist/internal/log.d.ts.map +1 -1
- package/dist/internal/log.js +2 -0
- package/dist/internal/log.js.map +1 -1
- package/dist/law.d.ts +10 -10
- package/dist/law.d.ts.map +1 -1
- package/dist/law.js +1 -1
- package/dist/law.js.map +1 -1
- package/dist/lower.d.ts.map +1 -1
- package/dist/lower.js +11 -6
- package/dist/lower.js.map +1 -1
- package/dist/native.d.ts +1 -1
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/query/atom.d.ts +1 -1
- package/dist/query/atom.d.ts.map +1 -1
- package/dist/query/atom.js.map +1 -1
- package/dist/query/description.d.ts +33 -0
- package/dist/query/description.d.ts.map +1 -0
- package/dist/query/description.js +302 -0
- package/dist/query/description.js.map +1 -0
- package/dist/query/lower.d.ts +60 -4
- package/dist/query/lower.d.ts.map +1 -1
- package/dist/query/lower.js +126 -161
- package/dist/query/lower.js.map +1 -1
- package/dist/query/parse-ir.d.ts +7 -2
- package/dist/query/parse-ir.d.ts.map +1 -1
- package/dist/query/parse-ir.js +240 -53
- package/dist/query/parse-ir.js.map +1 -1
- package/dist/query/run.d.ts.map +1 -1
- package/dist/query/run.js +8 -10
- package/dist/query/run.js.map +1 -1
- package/dist/query/scope.d.ts +3 -4
- package/dist/query/scope.d.ts.map +1 -1
- package/dist/query/scope.js +5 -10
- package/dist/query/scope.js.map +1 -1
- package/dist/relation.d.ts +22 -48
- package/dist/relation.d.ts.map +1 -1
- package/dist/relation.js +30 -82
- package/dist/relation.js.map +1 -1
- package/dist/rows.d.ts +7 -4
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +44 -198
- package/dist/rows.js.map +1 -1
- package/dist/runtime-errors.d.ts +26 -2
- package/dist/runtime-errors.d.ts.map +1 -1
- package/dist/runtime-errors.js +43 -3
- package/dist/runtime-errors.js.map +1 -1
- package/dist/schema.d.ts +9 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +85 -24
- package/dist/schema.js.map +1 -1
- package/dist/selection.d.ts +27 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +104 -0
- package/dist/selection.js.map +1 -0
- package/dist/shape.d.ts +6 -9
- package/dist/shape.d.ts.map +1 -1
- package/dist/statements.d.ts +17 -52
- package/dist/statements.d.ts.map +1 -1
- package/dist/statements.js +92 -111
- package/dist/statements.js.map +1 -1
- package/dist/values.d.ts +25 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +203 -0
- package/dist/values.js.map +1 -0
- package/pack-provenance.json +3 -3
- package/package.json +4 -4
- package/src/capacity.ts +86 -76
- package/src/changes.ts +183 -54
- package/src/closed.ts +161 -314
- package/src/codec.ts +116 -190
- package/src/compile.ts +56 -32
- package/src/db-native.ts +42 -0
- package/src/db.ts +134 -52
- package/src/errors.ts +16 -1
- package/src/face.ts +44 -74
- package/src/fields.ts +100 -146
- package/src/immutable.ts +76 -0
- package/src/index.ts +34 -28
- package/src/internal/log.ts +2 -0
- package/src/law.ts +13 -13
- package/src/lower.ts +13 -10
- package/src/native.ts +2 -0
- package/src/query/atom.ts +1 -0
- package/src/query/description.ts +394 -0
- package/src/query/lower.ts +139 -173
- package/src/query/parse-ir.ts +247 -54
- package/src/query/run.ts +15 -9
- package/src/query/scope.ts +10 -18
- package/src/relation.ts +58 -142
- package/src/rows.ts +62 -205
- package/src/runtime-errors.ts +47 -3
- package/src/schema.ts +99 -29
- package/src/selection.ts +124 -0
- package/src/shape.ts +9 -9
- package/src/statements.ts +138 -189
- package/src/values.ts +223 -0
package/dist/rows.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { AuthoringError, SdkInvariantError } from "#errors.ts";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { literalShapeError, rosterOf } from "#fields.ts";
|
|
3
|
+
import { relationFields } from "#relation.ts";
|
|
4
|
+
import { fieldValue, recordValue } from "#values.ts";
|
|
4
5
|
function recordOf(fact) {
|
|
5
|
-
if (typeof fact !== "object"
|
|
6
|
-
throw new AuthoringError({ message: "
|
|
6
|
+
if (typeof fact !== "object" || fact === null) {
|
|
7
|
+
throw new AuthoringError({ message: "expected a fact record" });
|
|
7
8
|
}
|
|
8
9
|
return fact;
|
|
9
10
|
}
|
|
10
|
-
function refuseShared(context, value) {
|
|
11
|
-
if (!(value.buffer instanceof ArrayBuffer)) {
|
|
12
|
-
throw new AuthoringError({
|
|
13
|
-
message: `${context}: SharedArrayBuffer-backed views are refused — make a synchronized stable copy into ordinary unshared input first`
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
11
|
/**
|
|
18
12
|
* Approximate payload size for host batching, not a memory allowance.
|
|
19
13
|
* Strings use two bytes per UTF-16 code unit, not their UTF-8 wire size.
|
|
@@ -36,25 +30,11 @@ function hostCellCharge(value) {
|
|
|
36
30
|
}
|
|
37
31
|
return 0n;
|
|
38
32
|
}
|
|
39
|
-
/**
|
|
40
|
-
* The write half of the closed bijection: one handle NAME to its u64 row
|
|
41
|
-
* id (declaration order = row ids). An unknown name is a pointed refusal
|
|
42
|
-
* naming the vocabulary and its roster.
|
|
43
|
-
*/
|
|
44
|
-
function closedCellOf(context, closed, name) {
|
|
45
|
-
const id = closed.handles.indexOf(name);
|
|
46
|
-
if (id === -1) {
|
|
47
|
-
throw new AuthoringError({
|
|
48
|
-
message: `${context}: "${name}" is not a handle of ${closed.name} — the roster is ${closed.handles.join(", ")}`
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return BigInt(id);
|
|
52
|
-
}
|
|
53
33
|
function handleOf(context, closed, cell) {
|
|
54
34
|
if (typeof cell !== "bigint") {
|
|
55
35
|
throw literalShapeError(context, `a ${closed.name} handle id (bigint)`, cell);
|
|
56
36
|
}
|
|
57
|
-
const handle = closed.handles[Number(cell)];
|
|
37
|
+
const handle = cell < 0n || cell >= BigInt(closed.handles.length) ? undefined : closed.handles[Number(cell)];
|
|
58
38
|
if (handle === undefined) {
|
|
59
39
|
throw new AuthoringError({
|
|
60
40
|
message: `${context}: id ${cell} is outside the ${closed.name} roster (${closed.handles.join(", ")})`
|
|
@@ -63,86 +43,14 @@ function handleOf(context, closed, cell) {
|
|
|
63
43
|
return handle;
|
|
64
44
|
}
|
|
65
45
|
function cellOf(context, field, value) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (typeof value !== "string") {
|
|
69
|
-
throw literalShapeError(context, `a ${roster.name} handle name (string)`, value);
|
|
70
|
-
}
|
|
71
|
-
return closedCellOf(context, roster, value);
|
|
72
|
-
}
|
|
73
|
-
switch (field.kind) {
|
|
74
|
-
case "bool": {
|
|
75
|
-
if (typeof value !== "boolean") {
|
|
76
|
-
throw literalShapeError(context, "boolean", value);
|
|
77
|
-
}
|
|
78
|
-
return value;
|
|
79
|
-
}
|
|
80
|
-
case "u64":
|
|
81
|
-
case "i64": {
|
|
82
|
-
if (typeof value !== "bigint") {
|
|
83
|
-
throw literalShapeError(context, "bigint", value);
|
|
84
|
-
}
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
case "str": {
|
|
88
|
-
if (typeof value !== "string") {
|
|
89
|
-
throw literalShapeError(context, "string", value);
|
|
90
|
-
}
|
|
91
|
-
if (!value.isWellFormed()) {
|
|
92
|
-
throw literalShapeError(context, "well-formed string", value);
|
|
93
|
-
}
|
|
94
|
-
return value;
|
|
95
|
-
}
|
|
96
|
-
case "f64": {
|
|
97
|
-
if (typeof value !== "number") {
|
|
98
|
-
throw literalShapeError(context, "number", value);
|
|
99
|
-
}
|
|
100
|
-
return value;
|
|
101
|
-
}
|
|
102
|
-
case "uuid": {
|
|
103
|
-
if (!Uuid.isUuid(value)) {
|
|
104
|
-
throw literalShapeError(context, "a UUID (canonical UUID text)", value);
|
|
105
|
-
}
|
|
106
|
-
// UUIDs cross as canonical hyphenated text, not raw bytes.
|
|
107
|
-
return value;
|
|
108
|
-
}
|
|
109
|
-
case "bytes": {
|
|
110
|
-
if (!(value instanceof Uint8Array)) {
|
|
111
|
-
throw literalShapeError(context, "Uint8Array", value);
|
|
112
|
-
}
|
|
113
|
-
refuseShared(context, value);
|
|
114
|
-
if (value.byteLength !== field.width) {
|
|
115
|
-
throw new AuthoringError({
|
|
116
|
-
message: `${context}: bytes<${field.width}> takes exactly ${field.width} bytes (got ${value.byteLength})`
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
// Owned copy at the ownership boundary: later caller mutation
|
|
120
|
-
// cannot change an accepted cell.
|
|
121
|
-
return Uint8Array.from(value);
|
|
122
|
-
}
|
|
123
|
-
case "interval": {
|
|
124
|
-
if (field.element === "f64") {
|
|
125
|
-
if (!isFloatIntervalValue(value)) {
|
|
126
|
-
throw literalShapeError(context, "float interval ({ start, end } numbers)", value);
|
|
127
|
-
}
|
|
128
|
-
if (Number.isNaN(value.start) || Number.isNaN(value.end)) {
|
|
129
|
-
throw new AuthoringError({ message: `${context}: a float interval endpoint cannot be NaN` });
|
|
130
|
-
}
|
|
131
|
-
const start = Object.is(value.start, -0) ? 0 : value.start;
|
|
132
|
-
const end = Object.is(value.end, -0) ? 0 : value.end;
|
|
133
|
-
if (!(start < end)) {
|
|
134
|
-
throw new AuthoringError({
|
|
135
|
-
message: `${context}: a float interval is half-open and nonempty (start < end strictly)`
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return { start, end };
|
|
139
|
-
}
|
|
140
|
-
if (!isIntervalValue(value)) {
|
|
141
|
-
throw literalShapeError(context, "interval ({ start, end } bigints)", value);
|
|
142
|
-
}
|
|
143
|
-
return { start: value.start, end: value.end };
|
|
144
|
-
}
|
|
46
|
+
if ("closed" in field) {
|
|
47
|
+
return BigInt(field.closed.handles.indexOf(fieldValue(context, field, value)));
|
|
145
48
|
}
|
|
49
|
+
return fieldValue(context, field, value);
|
|
50
|
+
}
|
|
51
|
+
function factCellsOf(data, fact) {
|
|
52
|
+
const record = recordValue(`relation ${data.name}`, fact, relationFields(data).map((declared) => declared.name));
|
|
53
|
+
return relationFields(data).map((declared) => cellOf(`relation ${data.name} field ${declared.name}`, declared.field, record[declared.name]));
|
|
146
54
|
}
|
|
147
55
|
/**
|
|
148
56
|
* The flat projector: every fact's cells land in ONE row-major cell array
|
|
@@ -154,109 +62,37 @@ function flatRowsOf(data, facts) {
|
|
|
154
62
|
const cells = [];
|
|
155
63
|
let rows = 0n;
|
|
156
64
|
for (const fact of facts) {
|
|
157
|
-
|
|
158
|
-
const record = recordOf(fact);
|
|
159
|
-
for (const declared of data.fields) {
|
|
160
|
-
const value = record[declared.name];
|
|
161
|
-
if (value === undefined) {
|
|
162
|
-
throw new AuthoringError({ message: `relation ${data.name}: fact is missing field ${declared.name}` });
|
|
163
|
-
}
|
|
164
|
-
const cell = cellOf(`relation ${data.name} field ${declared.name}`, declared.field, value);
|
|
65
|
+
for (const cell of factCellsOf(data, fact))
|
|
165
66
|
cells.push(cell);
|
|
166
|
-
|
|
67
|
+
rows += 1n;
|
|
167
68
|
}
|
|
168
69
|
return { rows, cells };
|
|
169
70
|
}
|
|
170
|
-
function keyCellsOf(data, projection,
|
|
171
|
-
|
|
172
|
-
if (key[supplied] !== undefined && !projection.includes(supplied)) {
|
|
173
|
-
throw new AuthoringError({
|
|
174
|
-
message: `relation ${data.name}: key object carries field ${supplied} outside the primary key projection (${projection.join(", ")})`
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
71
|
+
function keyCellsOf(data, projection, input) {
|
|
72
|
+
const key = recordValue(`relation ${data.name} key`, input, projection);
|
|
178
73
|
return projection.map(function marshalKeyCell(fieldName) {
|
|
179
|
-
const declared = data.
|
|
180
|
-
return candidate.name === fieldName;
|
|
181
|
-
});
|
|
74
|
+
const declared = relationFields(data).find((candidate) => candidate.name === fieldName);
|
|
182
75
|
if (declared === undefined) {
|
|
183
|
-
throw new AuthoringError({
|
|
184
|
-
message: `relation ${data.name}: key projection cites unknown field ${fieldName}`
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const value = key[fieldName];
|
|
188
|
-
if (value === undefined) {
|
|
189
|
-
throw new AuthoringError({
|
|
190
|
-
message: `relation ${data.name}: key object is missing field ${fieldName} — get reads through the primary (first-declared) key, whose projection is (${projection.join(", ")})`
|
|
191
|
-
});
|
|
76
|
+
throw new AuthoringError({ message: `relation ${data.name}: key projection cites unknown field ${fieldName}` });
|
|
192
77
|
}
|
|
193
|
-
return cellOf(`relation ${data.name} key field ${fieldName}`, declared.field,
|
|
78
|
+
return cellOf(`relation ${data.name} key field ${fieldName}`, declared.field, key[fieldName]);
|
|
194
79
|
});
|
|
195
80
|
}
|
|
196
81
|
function decodeCell(context, field, cell) {
|
|
197
82
|
const roster = rosterOf(field);
|
|
198
|
-
if (roster !== undefined)
|
|
83
|
+
if (roster !== undefined)
|
|
199
84
|
return handleOf(context, roster, cell);
|
|
85
|
+
try {
|
|
86
|
+
return fieldValue(context, field, cell);
|
|
200
87
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
return cell;
|
|
207
|
-
}
|
|
208
|
-
case "u64":
|
|
209
|
-
case "i64": {
|
|
210
|
-
if (typeof cell !== "bigint") {
|
|
211
|
-
throw new SdkInvariantError({ message: `${context}: expected bigint cell` });
|
|
212
|
-
}
|
|
213
|
-
return cell;
|
|
214
|
-
}
|
|
215
|
-
case "f64": {
|
|
216
|
-
if (typeof cell !== "number") {
|
|
217
|
-
throw new SdkInvariantError({ message: `${context}: expected number cell` });
|
|
218
|
-
}
|
|
219
|
-
return cell;
|
|
220
|
-
}
|
|
221
|
-
case "str": {
|
|
222
|
-
if (typeof cell !== "string") {
|
|
223
|
-
throw new SdkInvariantError({ message: `${context}: expected string cell` });
|
|
224
|
-
}
|
|
225
|
-
return cell;
|
|
226
|
-
}
|
|
227
|
-
case "uuid": {
|
|
228
|
-
// The native renderer spells uuid as the canonical
|
|
229
|
-
// canonical hyphenated UUID string (marshal.rs `uuid_hex`); the read
|
|
230
|
-
// side revalidates the spelling and keeps the string value.
|
|
231
|
-
if (!Uuid.isUuid(cell)) {
|
|
232
|
-
throw new SdkInvariantError({
|
|
233
|
-
message: `${context}: expected an uuid cell (canonical UUID text)`
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
return cell;
|
|
237
|
-
}
|
|
238
|
-
case "bytes": {
|
|
239
|
-
if (!(cell instanceof Uint8Array)) {
|
|
240
|
-
throw new SdkInvariantError({ message: `${context}: expected owned bytes` });
|
|
241
|
-
}
|
|
242
|
-
return cell;
|
|
243
|
-
}
|
|
244
|
-
case "interval": {
|
|
245
|
-
if (field.element === "f64") {
|
|
246
|
-
if (!isFloatIntervalValue(cell)) {
|
|
247
|
-
throw new SdkInvariantError({ message: `${context}: expected a float interval cell` });
|
|
248
|
-
}
|
|
249
|
-
return Object.freeze({ start: cell.start, end: cell.end });
|
|
250
|
-
}
|
|
251
|
-
if (!isIntervalValue(cell)) {
|
|
252
|
-
throw new SdkInvariantError({ message: `${context}: expected an integer interval cell` });
|
|
253
|
-
}
|
|
254
|
-
return Object.freeze({ start: cell.start, end: cell.end });
|
|
255
|
-
}
|
|
88
|
+
catch (cause) {
|
|
89
|
+
if (cause instanceof AuthoringError)
|
|
90
|
+
throw new SdkInvariantError({ message: cause.message });
|
|
91
|
+
throw cause;
|
|
256
92
|
}
|
|
257
93
|
}
|
|
258
94
|
function isCompleteFact(relation, decoded) {
|
|
259
|
-
return relation.
|
|
95
|
+
return relationFields(relation).every(function present(declared) {
|
|
260
96
|
return decoded[declared.name] !== undefined;
|
|
261
97
|
});
|
|
262
98
|
}
|
|
@@ -265,21 +101,22 @@ function isCompleteFact(relation, decoded) {
|
|
|
265
101
|
* declared field order: stable field names and shapes, no Proxy or per-cell closures.
|
|
266
102
|
*/
|
|
267
103
|
function factOfCells(relation, row) {
|
|
268
|
-
const data = relation
|
|
269
|
-
if (row.length !== data.
|
|
104
|
+
const data = relation;
|
|
105
|
+
if (row.length !== relationFields(data).length) {
|
|
270
106
|
throw new SdkInvariantError({
|
|
271
|
-
message: `relation ${data.name}: row arity ${row.length} does not match the ${data.
|
|
107
|
+
message: `relation ${data.name}: row arity ${row.length} does not match the ${relationFields(data).length} declared fields`
|
|
272
108
|
});
|
|
273
109
|
}
|
|
274
110
|
const decoded = {};
|
|
275
|
-
data.
|
|
111
|
+
relationFields(data).forEach(function decodeOne(declared, ordinal) {
|
|
276
112
|
const cell = row[ordinal];
|
|
277
113
|
if (cell === undefined) {
|
|
278
114
|
throw new SdkInvariantError({
|
|
279
115
|
message: `relation ${data.name}: row cell ${ordinal} (${declared.name}) is absent`
|
|
280
116
|
});
|
|
281
117
|
}
|
|
282
|
-
|
|
118
|
+
const value = decodeCell(`relation ${data.name} field ${declared.name}`, declared.field, cell);
|
|
119
|
+
setOwnField(decoded, declared.name, value);
|
|
283
120
|
});
|
|
284
121
|
Object.freeze(decoded);
|
|
285
122
|
if (!isCompleteFact(relation, decoded)) {
|
|
@@ -287,5 +124,14 @@ function factOfCells(relation, row) {
|
|
|
287
124
|
}
|
|
288
125
|
return decoded;
|
|
289
126
|
}
|
|
290
|
-
|
|
127
|
+
/** Preserve every declared name as data, including JavaScript's prototype setter. */
|
|
128
|
+
function setOwnField(record, name, value) {
|
|
129
|
+
if (name === "__proto__") {
|
|
130
|
+
Object.defineProperty(record, name, { value, enumerable: true, writable: true, configurable: true });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
record[name] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export { cellOf, decodeCell, factCellsOf, factOfCells, flatRowsOf, handleOf, hostCellCharge, keyCellsOf, recordOf, setOwnField };
|
|
291
137
|
//# sourceMappingURL=rows.js.map
|
package/dist/rows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.js","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAmB9D,OAAO,EAAE,
|
|
1
|
+
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X,WAAW,EACX,UAAU,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,QAAQ,EACR,WAAW,EACX,CAAA"}
|
package/dist/runtime-errors.d.ts
CHANGED
|
@@ -15,7 +15,17 @@ export declare const DbReason: Schema.Union<readonly [Schema.Struct<{
|
|
|
15
15
|
readonly kind: Schema.String;
|
|
16
16
|
readonly message: Schema.String;
|
|
17
17
|
}>, Schema.Struct<{
|
|
18
|
-
readonly _tag: Schema.
|
|
18
|
+
readonly _tag: Schema.Literal<"InvalidArgument">;
|
|
19
|
+
readonly detail: Schema.optional<Schema.Struct<{
|
|
20
|
+
readonly message: Schema.String;
|
|
21
|
+
readonly diagnostic: Schema.optional<Schema.Struct<{
|
|
22
|
+
readonly code: Schema.Literals<readonly ["InvalidValue", "InvalidRecord", "UnknownField", "MissingField", "InvalidDeclaration", "InvalidQuery"]>;
|
|
23
|
+
readonly context: Schema.String;
|
|
24
|
+
readonly expected: Schema.String;
|
|
25
|
+
}>>;
|
|
26
|
+
}>>;
|
|
27
|
+
}>, Schema.Struct<{
|
|
28
|
+
readonly _tag: Schema.Literals<("Cancelled" | "ClosedHandle" | "DirectoryBusy" | "ForeignRuntime" | "Internal" | "InvalidPath" | "QueueFull" | "RuntimeAlreadyLive" | "SpentHandle" | "WriterBusy")[]>;
|
|
19
29
|
}>]>;
|
|
20
30
|
declare const DbError_base: Schema.Class<DbError, Schema.TaggedStruct<"DbError", {
|
|
21
31
|
readonly operation: Schema.String;
|
|
@@ -34,13 +44,27 @@ declare const DbError_base: Schema.Class<DbError, Schema.TaggedStruct<"DbError",
|
|
|
34
44
|
readonly kind: Schema.String;
|
|
35
45
|
readonly message: Schema.String;
|
|
36
46
|
}>, Schema.Struct<{
|
|
37
|
-
readonly _tag: Schema.
|
|
47
|
+
readonly _tag: Schema.Literal<"InvalidArgument">;
|
|
48
|
+
readonly detail: Schema.optional<Schema.Struct<{
|
|
49
|
+
readonly message: Schema.String;
|
|
50
|
+
readonly diagnostic: Schema.optional<Schema.Struct<{
|
|
51
|
+
readonly code: Schema.Literals<readonly ["InvalidValue", "InvalidRecord", "UnknownField", "MissingField", "InvalidDeclaration", "InvalidQuery"]>;
|
|
52
|
+
readonly context: Schema.String;
|
|
53
|
+
readonly expected: Schema.String;
|
|
54
|
+
}>>;
|
|
55
|
+
}>>;
|
|
56
|
+
}>, Schema.Struct<{
|
|
57
|
+
readonly _tag: Schema.Literals<("Cancelled" | "ClosedHandle" | "DirectoryBusy" | "ForeignRuntime" | "Internal" | "InvalidPath" | "QueueFull" | "RuntimeAlreadyLive" | "SpentHandle" | "WriterBusy")[]>;
|
|
38
58
|
}>]>;
|
|
39
59
|
}>, import("effect/Cause").YieldableError>;
|
|
40
60
|
export declare class DbError extends DbError_base {
|
|
41
61
|
get code(): "Cancelled" | "ClosedHandle" | "DirectoryBusy" | "Engine" | "ForeignRuntime" | "Internal" | "InvalidArgument" | "InvalidPath" | "Io" | "QueueFull" | "ResourceLimit" | "RuntimeAlreadyLive" | "SpentHandle" | "WriterBusy";
|
|
62
|
+
/** Safe default display; callers explicitly inspect structured detail. */
|
|
63
|
+
get message(): string;
|
|
42
64
|
}
|
|
43
65
|
export declare function dbError(operation: string, cause: unknown): DbError;
|
|
66
|
+
/** Host input failures retain authoring details without displaying values. */
|
|
67
|
+
export declare function argumentError(operation: string, cause: unknown): DbError;
|
|
44
68
|
declare const Outstanding: Schema.Struct<{
|
|
45
69
|
readonly phase: Schema.Literals<readonly ["open", "closing", "closed"]>;
|
|
46
70
|
readonly queued: Schema.BigInt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-errors.d.ts","sourceRoot":"","sources":["../src/runtime-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime-errors.d.ts","sourceRoot":"","sources":["../src/runtime-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAoCrD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;IAA0E,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAC/F,qBAAa,OAAQ,SAAQ,YAG3B;IACD,IAAI,IAAI,+NAEP;IACD,0EAA0E;IAC1E,IAAa,OAAO,IAAI,MAAM,CAE7B;CACD;AAGD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAkBlE;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAUxE;AAED,QAAA,MAAM,WAAW;;;;;;;;EAQf,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AACrD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;IAIT,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;AAE3C,qBAAa,YAAa,SAAQ,iBAGhC;CAAG"}
|
package/dist/runtime-errors.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { AuthoringDiagnostic, AuthoringError } from "#errors.ts";
|
|
2
3
|
import { runtimeErrorCodes } from "#runtime-codes.ts";
|
|
3
4
|
export { runtimeErrorCodes } from "#runtime-codes.ts";
|
|
4
5
|
const ResourceLimit = Schema.Struct({
|
|
@@ -9,7 +10,14 @@ const ResourceLimit = Schema.Struct({
|
|
|
9
10
|
limit: Schema.BigInt
|
|
10
11
|
});
|
|
11
12
|
const PlainReason = Schema.Struct({
|
|
12
|
-
_tag: Schema.Literals(runtimeErrorCodes.filter((code) => code !== "ResourceLimit" && code !== "Io" && code !== "Engine"))
|
|
13
|
+
_tag: Schema.Literals(runtimeErrorCodes.filter((code) => code !== "ResourceLimit" && code !== "Io" && code !== "Engine" && code !== "InvalidArgument"))
|
|
14
|
+
});
|
|
15
|
+
const InvalidArgument = Schema.Struct({
|
|
16
|
+
_tag: Schema.Literal("InvalidArgument"),
|
|
17
|
+
detail: Schema.optional(Schema.Struct({
|
|
18
|
+
message: Schema.String,
|
|
19
|
+
diagnostic: Schema.optional(AuthoringDiagnostic)
|
|
20
|
+
}))
|
|
13
21
|
});
|
|
14
22
|
const Io = Schema.Struct({
|
|
15
23
|
_tag: Schema.Literal("Io"),
|
|
@@ -22,7 +30,7 @@ const Engine = Schema.Struct({
|
|
|
22
30
|
kind: Schema.String,
|
|
23
31
|
message: Schema.String
|
|
24
32
|
});
|
|
25
|
-
export const DbReason = Schema.Union([ResourceLimit, Io, Engine, PlainReason]);
|
|
33
|
+
export const DbReason = Schema.Union([ResourceLimit, Io, Engine, InvalidArgument, PlainReason]);
|
|
26
34
|
export class DbError extends Schema.TaggedError()("DbError", {
|
|
27
35
|
operation: Schema.String,
|
|
28
36
|
reason: DbReason
|
|
@@ -30,11 +38,43 @@ export class DbError extends Schema.TaggedError()("DbError", {
|
|
|
30
38
|
get code() {
|
|
31
39
|
return this.reason._tag;
|
|
32
40
|
}
|
|
41
|
+
/** Safe default display; callers explicitly inspect structured detail. */
|
|
42
|
+
get message() {
|
|
43
|
+
return `${this.operation}: ${this.code}`;
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
const decodeReason = Schema.decodeUnknownOption(DbReason);
|
|
35
47
|
export function dbError(operation, cause) {
|
|
48
|
+
if (cause instanceof DbError)
|
|
49
|
+
return cause;
|
|
50
|
+
if (cause instanceof AuthoringError)
|
|
51
|
+
return argumentError(operation, cause);
|
|
36
52
|
const decoded = decodeReason(cause);
|
|
37
|
-
|
|
53
|
+
if (decoded._tag === "Some")
|
|
54
|
+
return new DbError({ operation, reason: decoded.value });
|
|
55
|
+
// Synchronous native schema/marshalling refusals precede the executor's
|
|
56
|
+
// tagged error wire. Preserve their engine family instead of losing it.
|
|
57
|
+
if (typeof cause === "object" &&
|
|
58
|
+
cause !== null &&
|
|
59
|
+
"kind" in cause &&
|
|
60
|
+
typeof cause.kind === "string" &&
|
|
61
|
+
"message" in cause &&
|
|
62
|
+
typeof cause.message === "string") {
|
|
63
|
+
return new DbError({ operation, reason: { _tag: "Engine", kind: cause.kind, message: cause.message } });
|
|
64
|
+
}
|
|
65
|
+
return new DbError({ operation, reason: { _tag: "Internal" } });
|
|
66
|
+
}
|
|
67
|
+
/** Host input failures retain authoring details without displaying values. */
|
|
68
|
+
export function argumentError(operation, cause) {
|
|
69
|
+
if (cause instanceof DbError)
|
|
70
|
+
return cause;
|
|
71
|
+
if (cause instanceof AuthoringError) {
|
|
72
|
+
const detail = cause.diagnostic === undefined
|
|
73
|
+
? { message: cause.message }
|
|
74
|
+
: { message: cause.message, diagnostic: cause.diagnostic };
|
|
75
|
+
return new DbError({ operation, reason: { _tag: "InvalidArgument", detail } });
|
|
76
|
+
}
|
|
77
|
+
return new DbError({ operation, reason: { _tag: "InvalidArgument" } });
|
|
38
78
|
}
|
|
39
79
|
const Outstanding = Schema.Struct({
|
|
40
80
|
phase: Schema.Literals(["open", "closing", "closed"]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-errors.js","sourceRoot":"","sources":["../src/runtime-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,SAAS,EAAE,MAA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|
}
|
|
29
29
|
type AnySchema = Schema<SchemaRelations>;
|
|
30
|
+
/**
|
|
31
|
+
* Logical schema equivalence, including the ordered native ordinals and
|
|
32
|
+
* host decoding domains. Schema display names do not change the theory.
|
|
33
|
+
* A database/snapshot still has its own resource identity and lifetime.
|
|
34
|
+
*/
|
|
35
|
+
declare function schemasAgree(leftInput: AnySchema, rightInput: AnySchema): boolean;
|
|
36
|
+
declare function schemaDescriptor<S extends AnySchema>(input: S): S;
|
|
37
|
+
declare function schemaDescriptor(input: unknown): AnySchema;
|
|
30
38
|
type EvaluatedClasses<C extends SchemaClasses> = C extends SchemaClasses ? {
|
|
31
39
|
readonly [N in keyof C]: {
|
|
32
40
|
readonly [F in keyof C[N]]: C[N][F];
|
|
@@ -34,5 +42,5 @@ type EvaluatedClasses<C extends SchemaClasses> = C extends SchemaClasses ? {
|
|
|
34
42
|
} : never;
|
|
35
43
|
declare function schema<const Rels extends SchemaRelations, const Stmts extends readonly Statement[]>(name: string, relations: Rels, statements: Stmts & LawfulStatements<Rels, Stmts>): Schema<Rels, EvaluatedClasses<ClassesOf<Rels, Stmts>>>;
|
|
36
44
|
export type { AnySchema, Schema, SchemaRelation, SchemaRelations };
|
|
37
|
-
export { schema };
|
|
45
|
+
export { schema, schemaDescriptor, schemasAgree };
|
|
38
46
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAK3C,OAAO,EAAE,KAAK,SAAS,EAAmC,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AACpH,OAAO,KAAK,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