@niscorp/prism 0.3.2 → 0.3.4
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/CHANGELOG.md +22 -0
- package/DESIGN.md +12 -6
- package/DOCS.md +39 -3
- package/dist/agent.cjs +4 -4
- package/dist/agent.js +2 -2
- package/dist/{chunk-VNGBVDUM.js → chunk-BT3DLVGE.js} +3 -3
- package/dist/{chunk-VNGBVDUM.js.map → chunk-BT3DLVGE.js.map} +1 -1
- package/dist/{chunk-OL4CCYWX.js → chunk-C4IHL4MY.js} +6 -3
- package/dist/chunk-C4IHL4MY.js.map +1 -0
- package/dist/{chunk-ROYHYYIL.cjs → chunk-DOCK3CEK.cjs} +5 -5
- package/dist/{chunk-ROYHYYIL.cjs.map → chunk-DOCK3CEK.cjs.map} +1 -1
- package/dist/{chunk-QUI2X5JB.cjs → chunk-L23ZLSDQ.cjs} +6 -3
- package/dist/chunk-L23ZLSDQ.cjs.map +1 -0
- package/dist/examples/index.cjs +1 -1
- package/dist/examples/index.cjs.map +1 -1
- package/dist/examples/index.js +1 -1
- package/dist/examples/index.js.map +1 -1
- package/dist/index.cjs +298 -271
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.cjs +6 -2
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/migrations/index.js +5 -1
- package/dist/migrations/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-OL4CCYWX.js.map +0 -1
- package/dist/chunk-QUI2X5JB.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkDOCK3CEK_cjs = require('./chunk-DOCK3CEK.cjs');
|
|
4
|
+
var chunkL23ZLSDQ_cjs = require('./chunk-L23ZLSDQ.cjs');
|
|
5
5
|
var strata = require('@niscorp/strata');
|
|
6
6
|
var dayjs = require('dayjs');
|
|
7
7
|
var utc = require('dayjs/plugin/utc.js');
|
|
@@ -32,16 +32,16 @@ var explainOne = (issue, prefix) => {
|
|
|
32
32
|
var valueAt = (value, path) => path.reduce((at, key) => typeof at === "object" && at !== null ? Reflect.get(at, key) : void 0, value);
|
|
33
33
|
var opOf = (value, path) => {
|
|
34
34
|
const last = path[path.length - 1];
|
|
35
|
-
if (typeof last === "string" && last.startsWith("$") &&
|
|
35
|
+
if (typeof last === "string" && last.startsWith("$") && chunkL23ZLSDQ_cjs.formOf(last) === void 0) return void 0;
|
|
36
36
|
const here = valueAt(value, path);
|
|
37
37
|
if (typeof here === "object" && here !== null && !Array.isArray(here)) {
|
|
38
|
-
const ops = Object.keys(here).filter((key) =>
|
|
38
|
+
const ops = Object.keys(here).filter((key) => chunkL23ZLSDQ_cjs.formOf(key) !== void 0);
|
|
39
39
|
if (ops.length === 1) return ops[0];
|
|
40
40
|
}
|
|
41
41
|
for (const back of [1, 2]) {
|
|
42
42
|
const i = path.length - back;
|
|
43
43
|
const key = path[i];
|
|
44
|
-
if (typeof key !== "string" ||
|
|
44
|
+
if (typeof key !== "string" || chunkL23ZLSDQ_cjs.formOf(key) === void 0) continue;
|
|
45
45
|
const holder = valueAt(value, path.slice(0, i));
|
|
46
46
|
if (typeof holder === "object" && holder !== null && Object.keys(holder).length === 1) return key;
|
|
47
47
|
}
|
|
@@ -49,7 +49,7 @@ var opOf = (value, path) => {
|
|
|
49
49
|
};
|
|
50
50
|
var withForm = (explained, value) => {
|
|
51
51
|
const op = opOf(value, explained.path);
|
|
52
|
-
const form = op === void 0 ? void 0 :
|
|
52
|
+
const form = op === void 0 ? void 0 : chunkL23ZLSDQ_cjs.formOf(op);
|
|
53
53
|
return form === void 0 ? explained : { ...explained, message: `${explained.message.replace(/\.$/, "")}. Form: ${form}` };
|
|
54
54
|
};
|
|
55
55
|
var explainIssues = (issues, value) => issues.flatMap((i) => explainOne(i, [])).map((explained) => withForm(explained, value));
|
|
@@ -180,24 +180,24 @@ var desugar = (node) => {
|
|
|
180
180
|
if (node === null || node === void 0) return node;
|
|
181
181
|
if (typeof node !== "object") return node;
|
|
182
182
|
if (Array.isArray(node)) return node.map(desugar);
|
|
183
|
-
if (
|
|
183
|
+
if (chunkL23ZLSDQ_cjs.isWithNode(node)) {
|
|
184
184
|
const bindings = {};
|
|
185
185
|
for (const [name, expr] of Object.entries(node.$with.let)) bindings[name] = desugar(expr);
|
|
186
186
|
return { $with: { let: bindings, value: desugar(node.$with.value) } };
|
|
187
187
|
}
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
if (
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
if (
|
|
197
|
-
if (
|
|
198
|
-
if (
|
|
199
|
-
if (
|
|
200
|
-
if (
|
|
188
|
+
if (chunkL23ZLSDQ_cjs.isRenameKeysNode(node)) return { $renameKeys: { ...node.$renameKeys, from: desugar(node.$renameKeys.from) } };
|
|
189
|
+
if (chunkL23ZLSDQ_cjs.isConstNode(node)) return node;
|
|
190
|
+
if (chunkL23ZLSDQ_cjs.isSumNode(node)) return rewriteSum(node, desugar);
|
|
191
|
+
if (chunkL23ZLSDQ_cjs.isAvgNode(node)) return rewriteAvg(node, desugar);
|
|
192
|
+
if (chunkL23ZLSDQ_cjs.isCountNode(node)) return rewriteCount(node, desugar);
|
|
193
|
+
if (chunkL23ZLSDQ_cjs.isMinNode(node)) return rewriteMin(node, desugar);
|
|
194
|
+
if (chunkL23ZLSDQ_cjs.isMaxNode(node)) return rewriteMax(node, desugar);
|
|
195
|
+
if (chunkL23ZLSDQ_cjs.isPluckNode(node)) return rewritePluck(node, desugar);
|
|
196
|
+
if (chunkL23ZLSDQ_cjs.isTakeNode(node)) return rewriteTake(node, desugar);
|
|
197
|
+
if (chunkL23ZLSDQ_cjs.isDropNode(node)) return rewriteDrop(node, desugar);
|
|
198
|
+
if (chunkL23ZLSDQ_cjs.isMatchNode(node)) return rewriteMatch(node, desugar);
|
|
199
|
+
if (chunkL23ZLSDQ_cjs.isFlatMapNode(node)) return rewriteFlatMap(node, desugar);
|
|
200
|
+
if (chunkL23ZLSDQ_cjs.isJsonObject(node)) {
|
|
201
201
|
const result = {};
|
|
202
202
|
for (const [key, value] of Object.entries(node)) {
|
|
203
203
|
result[key] = desugar(value);
|
|
@@ -212,8 +212,8 @@ var DEFAULT_LIMITS = { maxSteps: 1e6, maxStringLength: 1e6, maxValues: 1e6 };
|
|
|
212
212
|
var createBudget = (limits) => ({ limits: { ...DEFAULT_LIMITS, ...limits }, steps: 0, sizes: /* @__PURE__ */ new WeakMap() });
|
|
213
213
|
var refuse = (what, limit, node) => {
|
|
214
214
|
const message = `Evaluation stopped: ${what} (limit ${limit}).`;
|
|
215
|
-
if (typeof node === "object" && node !== null) return
|
|
216
|
-
throw new
|
|
215
|
+
if (typeof node === "object" && node !== null) return chunkL23ZLSDQ_cjs.failAt(message, chunkL23ZLSDQ_cjs.ErrorCode.BUDGET, { details: { limit } }, { node, form: false });
|
|
216
|
+
throw new chunkL23ZLSDQ_cjs.PrismError(message, chunkL23ZLSDQ_cjs.ErrorCode.BUDGET, { details: { limit } });
|
|
217
217
|
};
|
|
218
218
|
var spendStep = (budget, node) => {
|
|
219
219
|
budget.steps += 1;
|
|
@@ -247,15 +247,15 @@ var SEGMENTS_KEY = "__segments";
|
|
|
247
247
|
var isSegmentsArray = (value) => Array.isArray(value);
|
|
248
248
|
var opRef = (node, context, _evaluate) => {
|
|
249
249
|
const attached = Reflect.get(node, SEGMENTS_KEY);
|
|
250
|
-
const segments = isSegmentsArray(attached) ? attached :
|
|
251
|
-
const resolved =
|
|
250
|
+
const segments = isSegmentsArray(attached) ? attached : chunkL23ZLSDQ_cjs.parseJsonPathCached(node.$ref);
|
|
251
|
+
const resolved = chunkL23ZLSDQ_cjs.getByPath(context.source, segments);
|
|
252
252
|
if (resolved === void 0) {
|
|
253
253
|
const steps = segments.map((s) => s.type === "key" ? s.key : s.index);
|
|
254
|
-
return
|
|
254
|
+
return chunkL23ZLSDQ_cjs.failAt("Path not found.", chunkL23ZLSDQ_cjs.ErrorCode.MISSING_PATH, { op: "$ref", path: node.$ref }, {
|
|
255
255
|
node,
|
|
256
256
|
op: "$ref",
|
|
257
257
|
form: false,
|
|
258
|
-
detail: () => `$ref ${JSON.stringify(node.$ref)} ${
|
|
258
|
+
detail: () => `$ref ${JSON.stringify(node.$ref)} ${chunkL23ZLSDQ_cjs.whereStopped(context.source, steps, (count) => chunkL23ZLSDQ_cjs.jsonPathUpTo(segments, count))}`
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
261
|
return resolved;
|
|
@@ -273,7 +273,7 @@ var opVar = (node, context, _evaluate) => {
|
|
|
273
273
|
if (value === void 0) {
|
|
274
274
|
const names = Object.keys(context.vars).filter((name) => !name.startsWith("__"));
|
|
275
275
|
const scope = names.length === 0 ? "No variable is in scope here." : `In scope: ${names.join(", ")}.`;
|
|
276
|
-
return
|
|
276
|
+
return chunkL23ZLSDQ_cjs.failAt(`Variable not found: ${node.$var}. ${scope}`, chunkL23ZLSDQ_cjs.ErrorCode.VAR_NOT_FOUND, { op: "$var", path: node.$var }, { node, op: "$var", form: false });
|
|
277
277
|
}
|
|
278
278
|
return value;
|
|
279
279
|
};
|
|
@@ -283,7 +283,7 @@ var getStopped = (node, root, count, context, evaluate2) => {
|
|
|
283
283
|
const evaluated = typeof segment === "object" && segment !== null ? evaluate2(segment, unbudgeted) : segment;
|
|
284
284
|
return typeof evaluated === "number" ? evaluated : String(evaluated);
|
|
285
285
|
});
|
|
286
|
-
return `$get.path ${JSON.stringify(steps)} ${
|
|
286
|
+
return `$get.path ${JSON.stringify(steps)} ${chunkL23ZLSDQ_cjs.whereStopped(root, steps, (upTo) => upTo === 0 ? "from" : JSON.stringify(steps.slice(0, upTo)), true)}`;
|
|
287
287
|
};
|
|
288
288
|
var opGet = (node, context, evaluate2) => {
|
|
289
289
|
const { from, path, fallback } = node.$get;
|
|
@@ -293,27 +293,27 @@ var opGet = (node, context, evaluate2) => {
|
|
|
293
293
|
const segment = path[i];
|
|
294
294
|
const evaluated = typeof segment === "object" && segment !== null ? evaluate2(segment, context) : segment;
|
|
295
295
|
if (typeof evaluated === "number") {
|
|
296
|
-
if (!
|
|
296
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(current2)) {
|
|
297
297
|
if (fallback !== void 0) return evaluate2(fallback, context);
|
|
298
|
-
return
|
|
298
|
+
return chunkL23ZLSDQ_cjs.failAt(getStopped(node, root, i + 1, context, evaluate2), chunkL23ZLSDQ_cjs.ErrorCode.TYPE, { op: "$get" }, { node, op: "$get", field: "path", form: true });
|
|
299
299
|
}
|
|
300
300
|
current2 = current2[evaluated];
|
|
301
301
|
} else {
|
|
302
302
|
const key = String(evaluated);
|
|
303
|
-
if (
|
|
303
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(current2) && chunkL23ZLSDQ_cjs.INDEX_TEXT.test(key)) {
|
|
304
304
|
current2 = current2[Number(key)];
|
|
305
305
|
continue;
|
|
306
306
|
}
|
|
307
|
-
if (!
|
|
307
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(current2)) {
|
|
308
308
|
if (fallback !== void 0) return evaluate2(fallback, context);
|
|
309
|
-
return
|
|
309
|
+
return chunkL23ZLSDQ_cjs.failAt(getStopped(node, root, i + 1, context, evaluate2), chunkL23ZLSDQ_cjs.ErrorCode.TYPE, { op: "$get" }, { node, op: "$get", field: "path", form: true });
|
|
310
310
|
}
|
|
311
311
|
current2 = current2[key];
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
if (current2 === void 0) {
|
|
315
315
|
if (fallback !== void 0) return evaluate2(fallback, context);
|
|
316
|
-
return
|
|
316
|
+
return chunkL23ZLSDQ_cjs.failAt("Path not found.", chunkL23ZLSDQ_cjs.ErrorCode.MISSING_PATH, { op: "$get" }, { node, op: "$get", field: "path", form: true, detail: () => getStopped(node, root, path.length, context, evaluate2) });
|
|
317
317
|
}
|
|
318
318
|
return current2;
|
|
319
319
|
};
|
|
@@ -346,19 +346,19 @@ var loopScope = (context) => {
|
|
|
346
346
|
};
|
|
347
347
|
|
|
348
348
|
// src/ops/refuse.ts
|
|
349
|
-
var writtenNote = (written) =>
|
|
349
|
+
var writtenNote = (written) => chunkL23ZLSDQ_cjs.isPlainObject(written) ? ` That object was written in the program as ${chunkL23ZLSDQ_cjs.clip(JSON.stringify(written), 60)}, and an object without a "$" key builds an object; put the node itself there.` : "";
|
|
350
350
|
var TEXT_LIKE = "text, a number, true, false or null";
|
|
351
351
|
var isTextLike = (value) => value === null || typeof value !== "object";
|
|
352
|
-
var refuseType = ({ node, op, field, needs, got, written, contextOp }) =>
|
|
353
|
-
`${field === void 0 ? op : `${op}.${field}`} needs ${needs}, but got ${
|
|
354
|
-
|
|
352
|
+
var refuseType = ({ node, op, field, needs, got, written, contextOp }) => chunkL23ZLSDQ_cjs.failAt(
|
|
353
|
+
`${field === void 0 ? op : `${op}.${field}`} needs ${needs}, but got ${chunkL23ZLSDQ_cjs.describeValue(got)}.${writtenNote(written)}`,
|
|
354
|
+
chunkL23ZLSDQ_cjs.ErrorCode.TYPE,
|
|
355
355
|
{ op: contextOp ?? op },
|
|
356
356
|
{ node, op, ...field === void 0 ? {} : { field }, form: true }
|
|
357
357
|
);
|
|
358
358
|
|
|
359
359
|
// src/ops/array.ops.ts
|
|
360
360
|
var requireArray = (value, node, op, field, written) => {
|
|
361
|
-
if (!
|
|
361
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(value))
|
|
362
362
|
return refuseType({ node, op, ...field === void 0 ? {} : { field }, needs: "a list", got: value, written, contextOp: field === void 0 ? op : `${op}.${field}` });
|
|
363
363
|
return value;
|
|
364
364
|
};
|
|
@@ -402,14 +402,14 @@ var opSlice = (node, context, evaluate2) => {
|
|
|
402
402
|
const { from, start, end } = node.$slice;
|
|
403
403
|
const input = evaluate2(from, context);
|
|
404
404
|
if (typeof input === "string") return input.slice(start, end);
|
|
405
|
-
if (
|
|
405
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(input)) return input.slice(start, end);
|
|
406
406
|
return refuseType({ node, op: "$slice", field: "from", needs: "a list or text", got: input, written: from, contextOp: "$slice" });
|
|
407
407
|
};
|
|
408
408
|
var opFlatten = (node, context, evaluate2) => {
|
|
409
409
|
const input = requireArray(evaluate2(node.$flatten, context), node, "$flatten", void 0, node.$flatten);
|
|
410
410
|
const result = [];
|
|
411
411
|
for (const item of input) {
|
|
412
|
-
if (
|
|
412
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(item)) result.push(...item);
|
|
413
413
|
else result.push(item);
|
|
414
414
|
}
|
|
415
415
|
return result;
|
|
@@ -429,9 +429,9 @@ var opUnique = (node, context, evaluate2) => {
|
|
|
429
429
|
};
|
|
430
430
|
var sortKey = (key, node) => {
|
|
431
431
|
if (key !== null && typeof key === "object") {
|
|
432
|
-
return
|
|
433
|
-
`$sortBy.by answered ${
|
|
434
|
-
|
|
432
|
+
return chunkL23ZLSDQ_cjs.failAt(
|
|
433
|
+
`$sortBy.by answered ${chunkL23ZLSDQ_cjs.describeValue(key)}; a sort key is a string or a number. To sort by two keys, sort by the second and then by the first: the sort keeps the order of equal items.`,
|
|
434
|
+
chunkL23ZLSDQ_cjs.ErrorCode.TYPE,
|
|
435
435
|
{ op: "$sortBy" },
|
|
436
436
|
{ node, op: "$sortBy", field: "by", form: true }
|
|
437
437
|
);
|
|
@@ -464,16 +464,16 @@ var requireNumbers = (node, pair, context, evaluate2, op) => {
|
|
|
464
464
|
const b = evaluate2(pair[1], context);
|
|
465
465
|
if (typeof a !== "number" || typeof b !== "number") {
|
|
466
466
|
const wrong = typeof a === "number" ? 1 : 0;
|
|
467
|
-
return
|
|
468
|
-
`${op} needs two numbers, but got ${
|
|
469
|
-
|
|
467
|
+
return chunkL23ZLSDQ_cjs.failAt(
|
|
468
|
+
`${op} needs two numbers, but got ${chunkL23ZLSDQ_cjs.describeValue(a)} and ${chunkL23ZLSDQ_cjs.describeValue(b)}.${writtenNote(pair[wrong])}`,
|
|
469
|
+
chunkL23ZLSDQ_cjs.ErrorCode.TYPE,
|
|
470
470
|
{ op },
|
|
471
471
|
{ node, op, field: String(wrong), form: true }
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
474
|
return [a, b];
|
|
475
475
|
};
|
|
476
|
-
var refuseZero = (node, op) =>
|
|
476
|
+
var refuseZero = (node, op) => chunkL23ZLSDQ_cjs.failAt(`Division by zero: the second value of ${op} is 0.`, chunkL23ZLSDQ_cjs.ErrorCode.DIVISION_BY_ZERO, { op }, { node, op, field: "1", form: false });
|
|
477
477
|
var opAdd = (node, context, evaluate2) => {
|
|
478
478
|
const [a, b] = requireNumbers(node, node.$add, context, evaluate2, "$add");
|
|
479
479
|
return a + b;
|
|
@@ -526,9 +526,9 @@ var opJoin = (node, context, evaluate2) => {
|
|
|
526
526
|
if (!Array.isArray(list)) return refuseType({ node, op: "$join", field: "parts", needs: "a list", got: list, written: parts });
|
|
527
527
|
const wrong = list.findIndex((part) => !isTextLike(part));
|
|
528
528
|
if (wrong !== -1)
|
|
529
|
-
return
|
|
530
|
-
`$join.parts needs items that are ${TEXT_LIKE}, but item ${wrong} is ${
|
|
531
|
-
|
|
529
|
+
return chunkL23ZLSDQ_cjs.failAt(
|
|
530
|
+
`$join.parts needs items that are ${TEXT_LIKE}, but item ${wrong} is ${chunkL23ZLSDQ_cjs.describeValue(list[wrong])}.${Array.isArray(parts) ? writtenNote(parts[wrong]) : ""}`,
|
|
531
|
+
chunkL23ZLSDQ_cjs.ErrorCode.TYPE,
|
|
532
532
|
{ op: "$join" },
|
|
533
533
|
{ node, op: "$join", field: "parts", form: true }
|
|
534
534
|
);
|
|
@@ -543,13 +543,13 @@ var opToString = (node, context, evaluate2) => {
|
|
|
543
543
|
var opInterpolate = (node, context, evaluate2) => {
|
|
544
544
|
const { template, values: valuesNode } = node.$interpolate;
|
|
545
545
|
const values = evaluate2(valuesNode, context);
|
|
546
|
-
if (!
|
|
546
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(values)) return refuseType({ node, op: "$interpolate", field: "values", needs: "an object", got: values, written: valuesNode });
|
|
547
547
|
return template.replace(/\{\{(\w+)\}\}/g, (_match, key) => {
|
|
548
548
|
const value = values[key] ?? "";
|
|
549
549
|
if (!isTextLike(value))
|
|
550
|
-
return
|
|
551
|
-
`$interpolate.values needs ${TEXT_LIKE} for {{${key}}}, but "${key}" is ${
|
|
552
|
-
|
|
550
|
+
return chunkL23ZLSDQ_cjs.failAt(
|
|
551
|
+
`$interpolate.values needs ${TEXT_LIKE} for {{${key}}}, but "${key}" is ${chunkL23ZLSDQ_cjs.describeValue(value)}.`,
|
|
552
|
+
chunkL23ZLSDQ_cjs.ErrorCode.TYPE,
|
|
553
553
|
{ op: "$interpolate" },
|
|
554
554
|
{ node, op: "$interpolate", field: "values", form: true }
|
|
555
555
|
);
|
|
@@ -559,7 +559,7 @@ var opInterpolate = (node, context, evaluate2) => {
|
|
|
559
559
|
var fillOne = (value) => {
|
|
560
560
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
|
|
561
561
|
const { phrase, slots } = value;
|
|
562
|
-
if (typeof phrase !== "string" || !
|
|
562
|
+
if (typeof phrase !== "string" || !chunkL23ZLSDQ_cjs.isJsonObject(slots)) return value;
|
|
563
563
|
return phrase.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (hole, name) => {
|
|
564
564
|
const slot = slots[name];
|
|
565
565
|
if (slot === void 0 || slot === null) return hole;
|
|
@@ -612,9 +612,9 @@ var compareOp = (node, pair, context, evaluate2, op, test) => {
|
|
|
612
612
|
const cmp = compare(a, b);
|
|
613
613
|
if (cmp === void 0) {
|
|
614
614
|
const wrong = typeof a === "number" || typeof a === "string" ? 1 : 0;
|
|
615
|
-
return
|
|
616
|
-
`${op} needs two numbers or two texts, but got ${
|
|
617
|
-
|
|
615
|
+
return chunkL23ZLSDQ_cjs.failAt(
|
|
616
|
+
`${op} needs two numbers or two texts, but got ${chunkL23ZLSDQ_cjs.describeValue(a)} and ${chunkL23ZLSDQ_cjs.describeValue(b)}.${writtenNote(pair[wrong])}`,
|
|
617
|
+
chunkL23ZLSDQ_cjs.ErrorCode.TYPE,
|
|
618
618
|
{ op },
|
|
619
619
|
{ node, op, field: String(wrong), form: true }
|
|
620
620
|
);
|
|
@@ -629,8 +629,8 @@ var opEmpty = (node, context, evaluate2) => {
|
|
|
629
629
|
const value = evaluate2(node.$empty, context);
|
|
630
630
|
if (value === null || value === void 0) return true;
|
|
631
631
|
if (typeof value === "string") return value.length === 0;
|
|
632
|
-
if (
|
|
633
|
-
if (
|
|
632
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(value)) return value.length === 0;
|
|
633
|
+
if (chunkL23ZLSDQ_cjs.isJsonObject(value)) return Object.keys(value).length === 0;
|
|
634
634
|
return false;
|
|
635
635
|
};
|
|
636
636
|
var opStartsWith = (node, context, evaluate2) => {
|
|
@@ -680,7 +680,7 @@ var opMerge = (node, context, evaluate2) => {
|
|
|
680
680
|
for (let index = 0; index < node.$merge.length; index++) {
|
|
681
681
|
const part = node.$merge[index];
|
|
682
682
|
const evaluated = evaluate2(part, context);
|
|
683
|
-
if (!
|
|
683
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(evaluated)) return refuseType({ node, op: "$merge", field: String(index), needs: "an object", got: evaluated, written: part, contextOp: "$merge" });
|
|
684
684
|
Object.assign(result, evaluated);
|
|
685
685
|
}
|
|
686
686
|
return result;
|
|
@@ -702,13 +702,13 @@ var opCase = (node, context, evaluate2) => {
|
|
|
702
702
|
};
|
|
703
703
|
var opEntriesOf = (node, context, evaluate2) => {
|
|
704
704
|
const value = evaluate2(node.$entriesOf, context);
|
|
705
|
-
if (!
|
|
705
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(value)) return refuseType({ node, op: "$entriesOf", needs: "an object", got: value, written: node.$entriesOf });
|
|
706
706
|
return Object.entries(value).map(([k, v]) => [k, v]);
|
|
707
707
|
};
|
|
708
708
|
var opKeyBy = (node, context, evaluate2) => {
|
|
709
709
|
const { over, as, key: keyExpr } = node.$keyBy;
|
|
710
710
|
const input = evaluate2(over, context);
|
|
711
|
-
if (!
|
|
711
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(input)) return refuseType({ node, op: "$keyBy", field: "over", needs: "a list", got: input, written: over, contextOp: "$keyBy" });
|
|
712
712
|
const result = {};
|
|
713
713
|
const { scope, vars } = loopScope(context);
|
|
714
714
|
for (const item of input) {
|
|
@@ -722,7 +722,7 @@ var opKeyBy = (node, context, evaluate2) => {
|
|
|
722
722
|
var opGroupBy = (node, context, evaluate2) => {
|
|
723
723
|
const { over, as, key: keyExpr } = node.$groupBy;
|
|
724
724
|
const input = evaluate2(over, context);
|
|
725
|
-
if (!
|
|
725
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(input)) return refuseType({ node, op: "$groupBy", field: "over", needs: "a list", got: input, written: over, contextOp: "$groupBy" });
|
|
726
726
|
const result = {};
|
|
727
727
|
const { scope, vars } = loopScope(context);
|
|
728
728
|
for (const item of input) {
|
|
@@ -739,29 +739,29 @@ var opGroupBy = (node, context, evaluate2) => {
|
|
|
739
739
|
// src/ops/object.ops.ts
|
|
740
740
|
var opKeys = (node, context, evaluate2) => {
|
|
741
741
|
const value = evaluate2(node.$keys, context);
|
|
742
|
-
if (!
|
|
742
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(value)) return refuseType({ node, op: "$keys", needs: "an object", got: value, written: node.$keys });
|
|
743
743
|
return Object.keys(value);
|
|
744
744
|
};
|
|
745
745
|
var opValues = (node, context, evaluate2) => {
|
|
746
746
|
const value = evaluate2(node.$values, context);
|
|
747
|
-
if (!
|
|
747
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(value)) return refuseType({ node, op: "$values", needs: "an object", got: value, written: node.$values });
|
|
748
748
|
return Object.values(value);
|
|
749
749
|
};
|
|
750
750
|
var opFromEntries = (node, context, evaluate2) => {
|
|
751
751
|
const value = evaluate2(node.$fromEntries, context);
|
|
752
|
-
if (!
|
|
752
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(value)) return refuseType({ node, op: "$fromEntries", needs: "a list of [key, value] pairs", got: value, written: node.$fromEntries });
|
|
753
753
|
const result = {};
|
|
754
754
|
for (let index = 0; index < value.length; index++) {
|
|
755
755
|
const entry = value[index];
|
|
756
|
-
if (!
|
|
757
|
-
return
|
|
756
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(entry) || entry.length < 2)
|
|
757
|
+
return chunkL23ZLSDQ_cjs.failAt(`$fromEntries needs a list of [key, value] pairs, but item ${index} is ${chunkL23ZLSDQ_cjs.describeValue(entry)}.`, chunkL23ZLSDQ_cjs.ErrorCode.TYPE, { op: "$fromEntries" }, { node, op: "$fromEntries", form: true });
|
|
758
758
|
result[String(entry[0])] = entry[1];
|
|
759
759
|
}
|
|
760
760
|
return result;
|
|
761
761
|
};
|
|
762
762
|
var opPick = (node, context, evaluate2) => {
|
|
763
763
|
const value = evaluate2(node.$pick.from, context);
|
|
764
|
-
if (!
|
|
764
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(value)) return refuseType({ node, op: "$pick", field: "from", needs: "an object", got: value, written: node.$pick.from, contextOp: "$pick" });
|
|
765
765
|
const result = {};
|
|
766
766
|
for (const key of node.$pick.keys) {
|
|
767
767
|
if (key in value) result[key] = value[key];
|
|
@@ -770,7 +770,7 @@ var opPick = (node, context, evaluate2) => {
|
|
|
770
770
|
};
|
|
771
771
|
var opOmit = (node, context, evaluate2) => {
|
|
772
772
|
const value = evaluate2(node.$omit.from, context);
|
|
773
|
-
if (!
|
|
773
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(value)) return refuseType({ node, op: "$omit", field: "from", needs: "an object", got: value, written: node.$omit.from, contextOp: "$omit" });
|
|
774
774
|
const keysToOmit = new Set(node.$omit.keys);
|
|
775
775
|
const result = {};
|
|
776
776
|
for (const [k, v] of Object.entries(value)) {
|
|
@@ -781,13 +781,13 @@ var opOmit = (node, context, evaluate2) => {
|
|
|
781
781
|
var opType = (node, context, evaluate2) => {
|
|
782
782
|
const value = evaluate2(node.$type, context);
|
|
783
783
|
if (value === null) return "null";
|
|
784
|
-
if (
|
|
784
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(value)) return "array";
|
|
785
785
|
return typeof value;
|
|
786
786
|
};
|
|
787
787
|
var opLength = (node, context, evaluate2) => {
|
|
788
788
|
const value = evaluate2(node.$length, context);
|
|
789
789
|
if (typeof value === "string") return value.length;
|
|
790
|
-
if (
|
|
790
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(value)) return value.length;
|
|
791
791
|
return refuseType({ node, op: "$length", needs: "a list or text", got: value, written: node.$length });
|
|
792
792
|
};
|
|
793
793
|
|
|
@@ -796,10 +796,10 @@ var has = (value, path) => {
|
|
|
796
796
|
let at = value;
|
|
797
797
|
for (const segment of path) {
|
|
798
798
|
if (typeof segment === "number") {
|
|
799
|
-
if (!
|
|
799
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(at) || segment >= at.length) return false;
|
|
800
800
|
at = at[segment] ?? null;
|
|
801
801
|
} else {
|
|
802
|
-
if (!
|
|
802
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(at) || !Object.prototype.hasOwnProperty.call(at, segment)) return false;
|
|
803
803
|
at = at[segment] ?? null;
|
|
804
804
|
}
|
|
805
805
|
}
|
|
@@ -808,7 +808,7 @@ var has = (value, path) => {
|
|
|
808
808
|
var opHas = (node, context, evaluate2) => has(evaluate2(node.$has.from, context), node.$has.path);
|
|
809
809
|
var opRenameKeys = (node, context, evaluate2) => {
|
|
810
810
|
const value = evaluate2(node.$renameKeys.from, context);
|
|
811
|
-
if (!
|
|
811
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(value)) return refuseType({ node, op: "$renameKeys", field: "from", needs: "an object", got: value, written: node.$renameKeys.from, contextOp: "$renameKeys" });
|
|
812
812
|
const { map } = node.$renameKeys;
|
|
813
813
|
const renamedTo = new Set(Object.entries(map).filter(([from]) => Object.prototype.hasOwnProperty.call(value, from)).map(([, to]) => to));
|
|
814
814
|
const result = {};
|
|
@@ -822,8 +822,8 @@ var opRenameKeys = (node, context, evaluate2) => {
|
|
|
822
822
|
var current = (value, path) => {
|
|
823
823
|
let at = value;
|
|
824
824
|
for (const segment of path) {
|
|
825
|
-
if (typeof segment === "number") at =
|
|
826
|
-
else at =
|
|
825
|
+
if (typeof segment === "number") at = chunkL23ZLSDQ_cjs.isJsonArray(at) ? at[segment] ?? null : null;
|
|
826
|
+
else at = chunkL23ZLSDQ_cjs.isJsonObject(at) ? at[segment] ?? null : null;
|
|
827
827
|
}
|
|
828
828
|
return at;
|
|
829
829
|
};
|
|
@@ -831,12 +831,12 @@ var setIn = (value, path, next, full, node) => {
|
|
|
831
831
|
const [head, ...rest] = path;
|
|
832
832
|
if (head === void 0) return next;
|
|
833
833
|
if (typeof head === "number") {
|
|
834
|
-
if (!
|
|
835
|
-
return
|
|
834
|
+
if (!chunkL23ZLSDQ_cjs.isJsonArray(value) || head >= value.length) {
|
|
835
|
+
return chunkL23ZLSDQ_cjs.failAt(`No array item at ${full.join(".")}: the value there is ${chunkL23ZLSDQ_cjs.describeValue(value)}.`, chunkL23ZLSDQ_cjs.ErrorCode.MISSING_PATH, { op: "$update", path: full.join(".") }, { node, op: "$update", field: "path", form: false });
|
|
836
836
|
}
|
|
837
837
|
return value.map((item, i) => i === head ? setIn(item, rest, next, full, node) : item);
|
|
838
838
|
}
|
|
839
|
-
const base =
|
|
839
|
+
const base = chunkL23ZLSDQ_cjs.isJsonObject(value) ? value : {};
|
|
840
840
|
return { ...base, [head]: setIn(base[head] ?? null, rest, next, full, node) };
|
|
841
841
|
};
|
|
842
842
|
var opUpdate = (node, context, evaluate2) => {
|
|
@@ -846,7 +846,7 @@ var opUpdate = (node, context, evaluate2) => {
|
|
|
846
846
|
return setIn(source, path, next, path, node);
|
|
847
847
|
};
|
|
848
848
|
var opAssert = (node, context, evaluate2) => {
|
|
849
|
-
if (!evaluate2(node.$assert.when, context)) throw new
|
|
849
|
+
if (!evaluate2(node.$assert.when, context)) throw new chunkL23ZLSDQ_cjs.PrismError(node.$assert.message, chunkL23ZLSDQ_cjs.ErrorCode.ASSERT, { op: "$assert" });
|
|
850
850
|
return evaluate2(node.$assert.value, context);
|
|
851
851
|
};
|
|
852
852
|
var opWalk = (node, context, evaluate2) => {
|
|
@@ -859,8 +859,8 @@ var opWalk = (node, context, evaluate2) => {
|
|
|
859
859
|
return { matched: false, value };
|
|
860
860
|
};
|
|
861
861
|
const children = (value, visit) => {
|
|
862
|
-
if (
|
|
863
|
-
if (
|
|
862
|
+
if (chunkL23ZLSDQ_cjs.isJsonArray(value)) return value.map(visit);
|
|
863
|
+
if (chunkL23ZLSDQ_cjs.isJsonObject(value)) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, visit(v)]));
|
|
864
864
|
return value;
|
|
865
865
|
};
|
|
866
866
|
const post = (value) => rewrite(children(value, post)).value;
|
|
@@ -875,7 +875,7 @@ var parseDate = (value, node, op, field, written, contextOp) => {
|
|
|
875
875
|
return refuseType({ node, op, field, needs: "a date, as text or a number", got: value, written, contextOp });
|
|
876
876
|
const d = isDateOnly(value) ? dayjs__default.default.utc(value) : dayjs__default.default(value);
|
|
877
877
|
if (!d.isValid())
|
|
878
|
-
return
|
|
878
|
+
return chunkL23ZLSDQ_cjs.failAt(`Invalid date for ${contextOp}: ${chunkL23ZLSDQ_cjs.clip(String(value), 60)}`, chunkL23ZLSDQ_cjs.ErrorCode.DATE_INVALID, { op: contextOp }, { node, op, field, form: false });
|
|
879
879
|
return d;
|
|
880
880
|
};
|
|
881
881
|
var opDate = (node, context, evaluate2) => {
|
|
@@ -908,6 +908,31 @@ var localeOf = (value, node, op, written) => {
|
|
|
908
908
|
return refuseType({ node, op, field: "locale", needs: 'a locale tag such as "de-AT"', got: value, written, contextOp: op });
|
|
909
909
|
return value;
|
|
910
910
|
};
|
|
911
|
+
var KNOWN_ZONES = /* @__PURE__ */ new Set();
|
|
912
|
+
var isKnownZone = (zone) => {
|
|
913
|
+
if (KNOWN_ZONES.has(zone)) return true;
|
|
914
|
+
try {
|
|
915
|
+
new Intl.DateTimeFormat("en-US", { timeZone: zone });
|
|
916
|
+
} catch {
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
919
|
+
KNOWN_ZONES.add(zone);
|
|
920
|
+
return true;
|
|
921
|
+
};
|
|
922
|
+
var zoneOf = (written, node, context, evaluate2) => {
|
|
923
|
+
if (written === void 0) return void 0;
|
|
924
|
+
const zone = typeof written === "string" ? written : evaluate2(written, context);
|
|
925
|
+
if (typeof zone === "string" && zone !== "" && isKnownZone(zone)) return zone;
|
|
926
|
+
return refuseType({ node, op: "$localeDate", field: "options.timeZone", needs: 'an IANA time zone that Intl knows, such as "Europe/Vienna"', got: zone, written, contextOp: "$localeDate" });
|
|
927
|
+
};
|
|
928
|
+
var readableLocale = (locale, node, op, written) => {
|
|
929
|
+
try {
|
|
930
|
+
Intl.getCanonicalLocales(locale);
|
|
931
|
+
} catch {
|
|
932
|
+
return refuseType({ node, op, field: "locale", needs: 'a locale tag Intl can read, such as "de-AT"', got: locale, written, contextOp: op });
|
|
933
|
+
}
|
|
934
|
+
return locale;
|
|
935
|
+
};
|
|
911
936
|
var isBlank = (value) => value === null || value === void 0 || value === "";
|
|
912
937
|
var fallbackOf = (raw, context, evaluate2) => {
|
|
913
938
|
if (raw === void 0) return "";
|
|
@@ -924,19 +949,21 @@ var opLocaleDate = (node, context, evaluate2) => {
|
|
|
924
949
|
const value = evaluate2(spec.value, context);
|
|
925
950
|
if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
|
|
926
951
|
const locale = localeOf(evaluate2(spec.locale, context), node, "$localeDate", spec.locale);
|
|
927
|
-
const authored = spec.options ?? { dateStyle: "medium" };
|
|
952
|
+
const { timeZone: writtenZone, ...authored } = spec.options ?? { dateStyle: "medium" };
|
|
928
953
|
const dateOnly = typeof value === "string" && DATE_ONLY2.test(value);
|
|
954
|
+
const parsed = typeof value === "number" ? new Date(value) : new Date(String(value));
|
|
955
|
+
if (Number.isNaN(parsed.getTime()))
|
|
956
|
+
return chunkL23ZLSDQ_cjs.failAt(`Invalid date for $localeDate: ${chunkL23ZLSDQ_cjs.clip(String(value), 60)}`, chunkL23ZLSDQ_cjs.ErrorCode.DATE_INVALID, { op: "$localeDate" }, { node, op: "$localeDate", field: "value", form: false });
|
|
957
|
+
const zone = zoneOf(writtenZone, node, context, evaluate2);
|
|
958
|
+
const timeZone = zone ?? (dateOnly ? "UTC" : void 0);
|
|
929
959
|
const options = {
|
|
930
960
|
...authored,
|
|
931
|
-
...
|
|
961
|
+
...timeZone === void 0 ? {} : { timeZone }
|
|
932
962
|
};
|
|
933
|
-
const parsed = typeof value === "number" ? new Date(value) : new Date(String(value));
|
|
934
|
-
if (Number.isNaN(parsed.getTime()))
|
|
935
|
-
return chunkQUI2X5JB_cjs.failAt(`Invalid date for $localeDate: ${chunkQUI2X5JB_cjs.clip(String(value), 60)}`, chunkQUI2X5JB_cjs.ErrorCode.DATE_INVALID, { op: "$localeDate" }, { node, op: "$localeDate", field: "value", form: false });
|
|
936
963
|
const key = `${locale}\0${JSON.stringify(options)}`;
|
|
937
964
|
let formatter = DATE_FORMATTERS.get(key);
|
|
938
965
|
if (formatter === void 0) {
|
|
939
|
-
formatter = new Intl.DateTimeFormat(locale, options);
|
|
966
|
+
formatter = new Intl.DateTimeFormat(readableLocale(locale, node, "$localeDate", spec.locale), options);
|
|
940
967
|
DATE_FORMATTERS.set(key, formatter);
|
|
941
968
|
}
|
|
942
969
|
return formatter.format(parsed);
|
|
@@ -996,7 +1023,7 @@ var opLocaleNumber = (node, context, evaluate2) => {
|
|
|
996
1023
|
const key = `${locale}\0${JSON.stringify(options)}`;
|
|
997
1024
|
let formatter = NUMBER_FORMATTERS.get(key);
|
|
998
1025
|
if (formatter === void 0) {
|
|
999
|
-
formatter = new Intl.NumberFormat(locale, options);
|
|
1026
|
+
formatter = new Intl.NumberFormat(readableLocale(locale, node, "$localeNumber", spec.locale), options);
|
|
1000
1027
|
NUMBER_FORMATTERS.set(key, formatter);
|
|
1001
1028
|
}
|
|
1002
1029
|
return formatter.format(numberOf(value, node, "$localeNumber", spec.value));
|
|
@@ -1020,71 +1047,71 @@ var freezeConstant = (value) => {
|
|
|
1020
1047
|
for (const inner of Object.values(value)) freezeConstant(inner);
|
|
1021
1048
|
};
|
|
1022
1049
|
var resolveHandler = (node) => {
|
|
1023
|
-
if (
|
|
1024
|
-
if (
|
|
1025
|
-
if (
|
|
1026
|
-
if (
|
|
1027
|
-
if (
|
|
1028
|
-
if (
|
|
1029
|
-
if (
|
|
1030
|
-
if (
|
|
1031
|
-
if (
|
|
1032
|
-
if (
|
|
1033
|
-
if (
|
|
1034
|
-
if (
|
|
1035
|
-
if (
|
|
1036
|
-
if (
|
|
1037
|
-
if (
|
|
1038
|
-
if (
|
|
1039
|
-
if (
|
|
1040
|
-
if (
|
|
1041
|
-
if (
|
|
1042
|
-
if (
|
|
1043
|
-
if (
|
|
1044
|
-
if (
|
|
1045
|
-
if (
|
|
1046
|
-
if (
|
|
1047
|
-
if (
|
|
1048
|
-
if (
|
|
1049
|
-
if (
|
|
1050
|
-
if (
|
|
1051
|
-
if (
|
|
1052
|
-
if (
|
|
1053
|
-
if (
|
|
1054
|
-
if (
|
|
1055
|
-
if (
|
|
1056
|
-
if (
|
|
1057
|
-
if (
|
|
1058
|
-
if (
|
|
1059
|
-
if (
|
|
1060
|
-
if (
|
|
1061
|
-
if (
|
|
1062
|
-
if (
|
|
1063
|
-
if (
|
|
1064
|
-
if (
|
|
1065
|
-
if (
|
|
1066
|
-
if (
|
|
1067
|
-
if (
|
|
1068
|
-
if (
|
|
1069
|
-
if (
|
|
1070
|
-
if (
|
|
1071
|
-
if (
|
|
1072
|
-
if (
|
|
1073
|
-
if (
|
|
1074
|
-
if (
|
|
1075
|
-
if (
|
|
1076
|
-
if (
|
|
1077
|
-
if (
|
|
1078
|
-
if (
|
|
1079
|
-
if (
|
|
1080
|
-
if (
|
|
1081
|
-
if (
|
|
1082
|
-
if (
|
|
1083
|
-
if (
|
|
1084
|
-
if (
|
|
1085
|
-
if (
|
|
1086
|
-
if (
|
|
1087
|
-
if (
|
|
1050
|
+
if (chunkL23ZLSDQ_cjs.isRefNode(node)) return eraseOp(opRef);
|
|
1051
|
+
if (chunkL23ZLSDQ_cjs.isConstNode(node)) return eraseOp(opConst);
|
|
1052
|
+
if (chunkL23ZLSDQ_cjs.isVarNode(node)) return eraseOp(opVar);
|
|
1053
|
+
if (chunkL23ZLSDQ_cjs.isGetNode(node)) return eraseOp(opGet);
|
|
1054
|
+
if (chunkL23ZLSDQ_cjs.isWithNode(node)) return eraseOp(opWith);
|
|
1055
|
+
if (chunkL23ZLSDQ_cjs.isMapNode(node)) return eraseOp(opMap);
|
|
1056
|
+
if (chunkL23ZLSDQ_cjs.isFilterNode(node)) return eraseOp(opFilter);
|
|
1057
|
+
if (chunkL23ZLSDQ_cjs.isReduceNode(node)) return eraseOp(opReduce);
|
|
1058
|
+
if (chunkL23ZLSDQ_cjs.isSliceNode(node)) return eraseOp(opSlice);
|
|
1059
|
+
if (chunkL23ZLSDQ_cjs.isFlattenNode(node)) return eraseOp(opFlatten);
|
|
1060
|
+
if (chunkL23ZLSDQ_cjs.isUniqueNode(node)) return eraseOp(opUnique);
|
|
1061
|
+
if (chunkL23ZLSDQ_cjs.isSortByNode(node)) return eraseOp(opSortBy);
|
|
1062
|
+
if (chunkL23ZLSDQ_cjs.isAddNode(node)) return eraseOp(opAdd);
|
|
1063
|
+
if (chunkL23ZLSDQ_cjs.isSubNode(node)) return eraseOp(opSub);
|
|
1064
|
+
if (chunkL23ZLSDQ_cjs.isMulNode(node)) return eraseOp(opMul);
|
|
1065
|
+
if (chunkL23ZLSDQ_cjs.isDivNode(node)) return eraseOp(opDiv);
|
|
1066
|
+
if (chunkL23ZLSDQ_cjs.isRoundNode(node)) return eraseOp(opRound);
|
|
1067
|
+
if (chunkL23ZLSDQ_cjs.isModNode(node)) return eraseOp(opMod);
|
|
1068
|
+
if (chunkL23ZLSDQ_cjs.isToNumberNode(node)) return eraseOp(opToNumber);
|
|
1069
|
+
if (chunkL23ZLSDQ_cjs.isJoinNode(node)) return eraseOp(opJoin);
|
|
1070
|
+
if (chunkL23ZLSDQ_cjs.isToStringNode(node)) return eraseOp(opToString);
|
|
1071
|
+
if (chunkL23ZLSDQ_cjs.isInterpolateNode(node)) return eraseOp(opInterpolate);
|
|
1072
|
+
if (chunkL23ZLSDQ_cjs.isFillNode(node)) return eraseOp(opFill);
|
|
1073
|
+
if (chunkL23ZLSDQ_cjs.isTrimNode(node)) return eraseOp(opTrim);
|
|
1074
|
+
if (chunkL23ZLSDQ_cjs.isLowerNode(node)) return eraseOp(opLower);
|
|
1075
|
+
if (chunkL23ZLSDQ_cjs.isUpperNode(node)) return eraseOp(opUpper);
|
|
1076
|
+
if (chunkL23ZLSDQ_cjs.isSplitNode(node)) return eraseOp(opSplit);
|
|
1077
|
+
if (chunkL23ZLSDQ_cjs.isReplaceNode(node)) return eraseOp(opReplace);
|
|
1078
|
+
if (chunkL23ZLSDQ_cjs.isEqNode(node)) return eraseOp(opEq);
|
|
1079
|
+
if (chunkL23ZLSDQ_cjs.isNeqNode(node)) return eraseOp(opNeq);
|
|
1080
|
+
if (chunkL23ZLSDQ_cjs.isGtNode(node)) return eraseOp(opGt);
|
|
1081
|
+
if (chunkL23ZLSDQ_cjs.isGteNode(node)) return eraseOp(opGte);
|
|
1082
|
+
if (chunkL23ZLSDQ_cjs.isLtNode(node)) return eraseOp(opLt);
|
|
1083
|
+
if (chunkL23ZLSDQ_cjs.isLteNode(node)) return eraseOp(opLte);
|
|
1084
|
+
if (chunkL23ZLSDQ_cjs.isEmptyNode(node)) return eraseOp(opEmpty);
|
|
1085
|
+
if (chunkL23ZLSDQ_cjs.isStartsWithNode(node)) return eraseOp(opStartsWith);
|
|
1086
|
+
if (chunkL23ZLSDQ_cjs.isEndsWithNode(node)) return eraseOp(opEndsWith);
|
|
1087
|
+
if (chunkL23ZLSDQ_cjs.isContainsNode(node)) return eraseOp(opContains);
|
|
1088
|
+
if (chunkL23ZLSDQ_cjs.isNotNode(node)) return eraseOp(opNot);
|
|
1089
|
+
if (chunkL23ZLSDQ_cjs.isAndNode(node)) return eraseOp(opAnd);
|
|
1090
|
+
if (chunkL23ZLSDQ_cjs.isOrNode(node)) return eraseOp(opOr);
|
|
1091
|
+
if (chunkL23ZLSDQ_cjs.isMergeNode(node)) return eraseOp(opMerge);
|
|
1092
|
+
if (chunkL23ZLSDQ_cjs.isCoalesceNode(node)) return eraseOp(opCoalesce);
|
|
1093
|
+
if (chunkL23ZLSDQ_cjs.isCaseNode(node)) return eraseOp(opCase);
|
|
1094
|
+
if (chunkL23ZLSDQ_cjs.isEntriesOfNode(node)) return eraseOp(opEntriesOf);
|
|
1095
|
+
if (chunkL23ZLSDQ_cjs.isKeyByNode(node)) return eraseOp(opKeyBy);
|
|
1096
|
+
if (chunkL23ZLSDQ_cjs.isGroupByNode(node)) return eraseOp(opGroupBy);
|
|
1097
|
+
if (chunkL23ZLSDQ_cjs.isKeysNode(node)) return eraseOp(opKeys);
|
|
1098
|
+
if (chunkL23ZLSDQ_cjs.isValuesNode(node)) return eraseOp(opValues);
|
|
1099
|
+
if (chunkL23ZLSDQ_cjs.isFromEntriesNode(node)) return eraseOp(opFromEntries);
|
|
1100
|
+
if (chunkL23ZLSDQ_cjs.isPickNode(node)) return eraseOp(opPick);
|
|
1101
|
+
if (chunkL23ZLSDQ_cjs.isOmitNode(node)) return eraseOp(opOmit);
|
|
1102
|
+
if (chunkL23ZLSDQ_cjs.isTypeNode(node)) return eraseOp(opType);
|
|
1103
|
+
if (chunkL23ZLSDQ_cjs.isLengthNode(node)) return eraseOp(opLength);
|
|
1104
|
+
if (chunkL23ZLSDQ_cjs.isHasNode(node)) return eraseOp(opHas);
|
|
1105
|
+
if (chunkL23ZLSDQ_cjs.isRenameKeysNode(node)) return eraseOp(opRenameKeys);
|
|
1106
|
+
if (chunkL23ZLSDQ_cjs.isUpdateNode(node)) return eraseOp(opUpdate);
|
|
1107
|
+
if (chunkL23ZLSDQ_cjs.isAssertNode(node)) return eraseOp(opAssert);
|
|
1108
|
+
if (chunkL23ZLSDQ_cjs.isWalkNode(node)) return eraseOp(opWalk);
|
|
1109
|
+
if (chunkL23ZLSDQ_cjs.isDateNode(node)) return eraseOp(opDate);
|
|
1110
|
+
if (chunkL23ZLSDQ_cjs.isDateAddNode(node)) return eraseOp(opDateAdd);
|
|
1111
|
+
if (chunkL23ZLSDQ_cjs.isDateDiffNode(node)) return eraseOp(opDateDiff);
|
|
1112
|
+
if (chunkL23ZLSDQ_cjs.isLocaleDateNode(node)) return eraseOp(opLocaleDate);
|
|
1113
|
+
if (chunkL23ZLSDQ_cjs.isLocaleMoneyNode(node)) return eraseOp(opLocaleMoney);
|
|
1114
|
+
if (chunkL23ZLSDQ_cjs.isLocaleNumberNode(node)) return eraseOp(opLocaleNumber);
|
|
1088
1115
|
return void 0;
|
|
1089
1116
|
};
|
|
1090
1117
|
var isFoldableLiteral = (node) => {
|
|
@@ -1092,8 +1119,8 @@ var isFoldableLiteral = (node) => {
|
|
|
1092
1119
|
const t = typeof node;
|
|
1093
1120
|
if (t === "string" || t === "number" || t === "boolean") return true;
|
|
1094
1121
|
if (Array.isArray(node)) return node.every(isFoldableLiteral);
|
|
1095
|
-
if (!
|
|
1096
|
-
if (
|
|
1122
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(node)) return false;
|
|
1123
|
+
if (chunkL23ZLSDQ_cjs.isConstNode(node)) return isFoldableLiteral(node.$const);
|
|
1097
1124
|
if (Object.keys(node).some((k) => k.startsWith("$"))) return false;
|
|
1098
1125
|
return Object.values(node).every(isFoldableLiteral);
|
|
1099
1126
|
};
|
|
@@ -1105,8 +1132,8 @@ var optimizeNode = (node, stats, evaluate2) => {
|
|
|
1105
1132
|
for (const child of node) out.push(optimizeNode(child, stats, evaluate2));
|
|
1106
1133
|
return out;
|
|
1107
1134
|
}
|
|
1108
|
-
if (!
|
|
1109
|
-
if (
|
|
1135
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(node)) return node;
|
|
1136
|
+
if (chunkL23ZLSDQ_cjs.isConstNode(node)) {
|
|
1110
1137
|
const literal = { ...node };
|
|
1111
1138
|
freezeConstant(literal["$const"]);
|
|
1112
1139
|
attachNonEnumerable(literal, HANDLER_KEY, eraseOp(opConst));
|
|
@@ -1119,15 +1146,15 @@ var optimizeNode = (node, stats, evaluate2) => {
|
|
|
1119
1146
|
return out;
|
|
1120
1147
|
};
|
|
1121
1148
|
let optimized;
|
|
1122
|
-
if (
|
|
1149
|
+
if (chunkL23ZLSDQ_cjs.isWithNode(node)) {
|
|
1123
1150
|
optimized = { $with: { let: optimizeValues(node.$with.let), value: optimizeNode(node.$with.value, stats, evaluate2) } };
|
|
1124
|
-
} else if (
|
|
1151
|
+
} else if (chunkL23ZLSDQ_cjs.isRenameKeysNode(node)) {
|
|
1125
1152
|
optimized = { $renameKeys: { ...node.$renameKeys, from: optimizeNode(node.$renameKeys.from, stats, evaluate2) } };
|
|
1126
1153
|
} else {
|
|
1127
1154
|
optimized = optimizeValues(node);
|
|
1128
1155
|
}
|
|
1129
|
-
if (
|
|
1130
|
-
const segments =
|
|
1156
|
+
if (chunkL23ZLSDQ_cjs.isRefNode(optimized)) {
|
|
1157
|
+
const segments = chunkL23ZLSDQ_cjs.parseJsonPath(optimized.$ref);
|
|
1131
1158
|
if (segments.length > 0) {
|
|
1132
1159
|
attachNonEnumerable(optimized, SEGMENTS_KEY2, segments);
|
|
1133
1160
|
stats.refsInlined += 1;
|
|
@@ -1138,7 +1165,7 @@ var optimizeNode = (node, stats, evaluate2) => {
|
|
|
1138
1165
|
attachNonEnumerable(optimized, HANDLER_KEY, handler);
|
|
1139
1166
|
stats.handlersAttached += 1;
|
|
1140
1167
|
}
|
|
1141
|
-
if (handler !== void 0 && !
|
|
1168
|
+
if (handler !== void 0 && !chunkL23ZLSDQ_cjs.isConstNode(optimized) && !chunkL23ZLSDQ_cjs.isRefNode(optimized) && !chunkL23ZLSDQ_cjs.isVarNode(optimized)) {
|
|
1142
1169
|
const allFoldable = Object.entries(optimized).every(([key, value]) => {
|
|
1143
1170
|
if (key === HANDLER_KEY || key === SEGMENTS_KEY2) return true;
|
|
1144
1171
|
return isFoldableLiteral(value);
|
|
@@ -1168,19 +1195,19 @@ var annotateNode = (node) => {
|
|
|
1168
1195
|
for (const child of node) annotateNode(child);
|
|
1169
1196
|
return;
|
|
1170
1197
|
}
|
|
1171
|
-
if (!
|
|
1172
|
-
if (
|
|
1198
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(node)) return;
|
|
1199
|
+
if (chunkL23ZLSDQ_cjs.isWithNode(node)) {
|
|
1173
1200
|
for (const value of Object.values(node.$with.let)) annotateNode(value);
|
|
1174
1201
|
annotateNode(node.$with.value);
|
|
1175
|
-
} else if (
|
|
1202
|
+
} else if (chunkL23ZLSDQ_cjs.isRenameKeysNode(node)) {
|
|
1176
1203
|
annotateNode(node.$renameKeys.from);
|
|
1177
|
-
} else if (!
|
|
1204
|
+
} else if (!chunkL23ZLSDQ_cjs.isConstNode(node)) {
|
|
1178
1205
|
for (const value of Object.values(node)) annotateNode(value);
|
|
1179
1206
|
} else {
|
|
1180
1207
|
freezeConstant(node.$const);
|
|
1181
1208
|
}
|
|
1182
|
-
if (
|
|
1183
|
-
const segments =
|
|
1209
|
+
if (chunkL23ZLSDQ_cjs.isRefNode(node)) {
|
|
1210
|
+
const segments = chunkL23ZLSDQ_cjs.parseJsonPath(node.$ref);
|
|
1184
1211
|
if (segments.length > 0) attachNonEnumerable(node, SEGMENTS_KEY2, segments);
|
|
1185
1212
|
}
|
|
1186
1213
|
const handler = resolveHandler(node);
|
|
@@ -1204,7 +1231,7 @@ var findPath = (tree, matches) => {
|
|
|
1204
1231
|
return walk2(tree) ? at : void 0;
|
|
1205
1232
|
};
|
|
1206
1233
|
var soleOpOf = (node) => {
|
|
1207
|
-
if (!
|
|
1234
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(node)) return void 0;
|
|
1208
1235
|
const keys = Object.keys(node);
|
|
1209
1236
|
return keys.length === 1 && keys[0] !== void 0 && keys[0].startsWith("$") ? keys[0] : void 0;
|
|
1210
1237
|
};
|
|
@@ -1224,12 +1251,12 @@ var authorPosition = (authored, treePath) => {
|
|
|
1224
1251
|
continue;
|
|
1225
1252
|
}
|
|
1226
1253
|
const op = soleOpOf(node);
|
|
1227
|
-
if (op === void 0 || !
|
|
1254
|
+
if (op === void 0 || !chunkL23ZLSDQ_cjs.isJsonObject(node)) return void 0;
|
|
1228
1255
|
const fields = node[op];
|
|
1229
|
-
const names =
|
|
1256
|
+
const names = chunkL23ZLSDQ_cjs.isJsonObject(fields) ? Object.keys(fields) : [];
|
|
1230
1257
|
const rewritten = desugar({ [op]: Object.fromEntries(names.map((name) => [name, `${MARK}${name}`])) });
|
|
1231
1258
|
const landed = names.map((name) => ({ name, at: findPath(rewritten, (value) => value === `${MARK}${name}`) })).find(({ at }) => at !== void 0 && at.every((segment, i) => rest[i] === segment));
|
|
1232
|
-
if (landed?.at === void 0 || !
|
|
1259
|
+
if (landed?.at === void 0 || !chunkL23ZLSDQ_cjs.isJsonObject(fields)) return { path: [...path, op], sugar: op };
|
|
1233
1260
|
path.push(op, landed.name);
|
|
1234
1261
|
node = fields[landed.name];
|
|
1235
1262
|
rest = rest.slice(landed.at.length);
|
|
@@ -1239,8 +1266,8 @@ var authorPosition = (authored, treePath) => {
|
|
|
1239
1266
|
};
|
|
1240
1267
|
var pathText = (path) => path.length === 0 ? "(root)" : path.join(".");
|
|
1241
1268
|
var placeError = (error, tree, authored) => {
|
|
1242
|
-
if (!(error instanceof
|
|
1243
|
-
const origin =
|
|
1269
|
+
if (!(error instanceof chunkL23ZLSDQ_cjs.PrismError)) return;
|
|
1270
|
+
const origin = chunkL23ZLSDQ_cjs.takeOrigin(error);
|
|
1244
1271
|
if (origin === void 0) return;
|
|
1245
1272
|
const parts = [error.message];
|
|
1246
1273
|
if (origin.detail !== void 0) parts.push(origin.detail());
|
|
@@ -1256,7 +1283,7 @@ var placeError = (error, tree, authored) => {
|
|
|
1256
1283
|
formOp = position.sugar;
|
|
1257
1284
|
}
|
|
1258
1285
|
}
|
|
1259
|
-
const form = origin.form && formOp !== void 0 ?
|
|
1286
|
+
const form = origin.form && formOp !== void 0 ? chunkL23ZLSDQ_cjs.formOf(formOp) : void 0;
|
|
1260
1287
|
if (form !== void 0) parts.push(`Form: ${form}`);
|
|
1261
1288
|
error.message = parts.join(" ");
|
|
1262
1289
|
};
|
|
@@ -1280,99 +1307,99 @@ var evaluateUnbudgeted = (node, context) => {
|
|
|
1280
1307
|
const obj = node;
|
|
1281
1308
|
const attached = obj[HANDLER_KEY2];
|
|
1282
1309
|
if (isAttachedFn(attached)) return attached(obj, context, evaluateNode);
|
|
1283
|
-
if (
|
|
1310
|
+
if (chunkL23ZLSDQ_cjs.isPlainObject(obj)) {
|
|
1284
1311
|
const result = {};
|
|
1285
|
-
if (!(
|
|
1312
|
+
if (!(chunkL23ZLSDQ_cjs.OPTIONAL_FIELDS_KEY in obj)) {
|
|
1286
1313
|
for (const key of Object.keys(obj)) result[key] = evaluateNode(obj[key], context);
|
|
1287
1314
|
return result;
|
|
1288
1315
|
}
|
|
1289
1316
|
const optionalFields = new Set(
|
|
1290
|
-
Array.isArray(obj[
|
|
1317
|
+
Array.isArray(obj[chunkL23ZLSDQ_cjs.OPTIONAL_FIELDS_KEY]) ? obj[chunkL23ZLSDQ_cjs.OPTIONAL_FIELDS_KEY] : []
|
|
1291
1318
|
);
|
|
1292
1319
|
for (const [key, value] of Object.entries(obj)) {
|
|
1293
|
-
if (key ===
|
|
1320
|
+
if (key === chunkL23ZLSDQ_cjs.OPTIONAL_FIELDS_KEY) continue;
|
|
1294
1321
|
const isOptional = optionalFields.has(key);
|
|
1295
1322
|
try {
|
|
1296
1323
|
const evaluated = evaluateNode(value, context);
|
|
1297
1324
|
if (isOptional && (evaluated === null || evaluated === void 0)) continue;
|
|
1298
1325
|
result[key] = evaluated;
|
|
1299
1326
|
} catch (error) {
|
|
1300
|
-
if (isOptional && error instanceof
|
|
1327
|
+
if (isOptional && error instanceof chunkL23ZLSDQ_cjs.PrismError && error.code === chunkL23ZLSDQ_cjs.ErrorCode.MISSING_PATH) continue;
|
|
1301
1328
|
throw error;
|
|
1302
1329
|
}
|
|
1303
1330
|
}
|
|
1304
1331
|
return result;
|
|
1305
1332
|
}
|
|
1306
|
-
if (
|
|
1307
|
-
if (
|
|
1308
|
-
if (
|
|
1309
|
-
if (
|
|
1310
|
-
if (
|
|
1311
|
-
if (
|
|
1312
|
-
if (
|
|
1313
|
-
if (
|
|
1314
|
-
if (
|
|
1315
|
-
if (
|
|
1316
|
-
if (
|
|
1317
|
-
if (
|
|
1318
|
-
if (
|
|
1319
|
-
if (
|
|
1320
|
-
if (
|
|
1321
|
-
if (
|
|
1322
|
-
if (
|
|
1323
|
-
if (
|
|
1324
|
-
if (
|
|
1325
|
-
if (
|
|
1326
|
-
if (
|
|
1327
|
-
if (
|
|
1328
|
-
if (
|
|
1329
|
-
if (
|
|
1330
|
-
if (
|
|
1331
|
-
if (
|
|
1332
|
-
if (
|
|
1333
|
-
if (
|
|
1334
|
-
if (
|
|
1335
|
-
if (
|
|
1336
|
-
if (
|
|
1337
|
-
if (
|
|
1338
|
-
if (
|
|
1339
|
-
if (
|
|
1340
|
-
if (
|
|
1341
|
-
if (
|
|
1342
|
-
if (
|
|
1343
|
-
if (
|
|
1344
|
-
if (
|
|
1345
|
-
if (
|
|
1346
|
-
if (
|
|
1347
|
-
if (
|
|
1348
|
-
if (
|
|
1349
|
-
if (
|
|
1350
|
-
if (
|
|
1351
|
-
if (
|
|
1352
|
-
if (
|
|
1353
|
-
if (
|
|
1354
|
-
if (
|
|
1355
|
-
if (
|
|
1356
|
-
if (
|
|
1357
|
-
if (
|
|
1358
|
-
if (
|
|
1359
|
-
if (
|
|
1360
|
-
if (
|
|
1361
|
-
if (
|
|
1362
|
-
if (
|
|
1363
|
-
if (
|
|
1364
|
-
if (
|
|
1365
|
-
if (
|
|
1366
|
-
if (
|
|
1367
|
-
if (
|
|
1368
|
-
if (
|
|
1369
|
-
if (
|
|
1370
|
-
if (
|
|
1333
|
+
if (chunkL23ZLSDQ_cjs.isRefNode(obj)) return opRef(obj, context);
|
|
1334
|
+
if (chunkL23ZLSDQ_cjs.isConstNode(obj)) return opConst(obj, context);
|
|
1335
|
+
if (chunkL23ZLSDQ_cjs.isVarNode(obj)) return opVar(obj, context);
|
|
1336
|
+
if (chunkL23ZLSDQ_cjs.isGetNode(obj)) return opGet(obj, context, evaluateNode);
|
|
1337
|
+
if (chunkL23ZLSDQ_cjs.isWithNode(obj)) return opWith(obj, context, evaluateNode);
|
|
1338
|
+
if (chunkL23ZLSDQ_cjs.isMapNode(obj)) return opMap(obj, context, evaluateNode);
|
|
1339
|
+
if (chunkL23ZLSDQ_cjs.isFilterNode(obj)) return opFilter(obj, context, evaluateNode);
|
|
1340
|
+
if (chunkL23ZLSDQ_cjs.isReduceNode(obj)) return opReduce(obj, context, evaluateNode);
|
|
1341
|
+
if (chunkL23ZLSDQ_cjs.isSliceNode(obj)) return opSlice(obj, context, evaluateNode);
|
|
1342
|
+
if (chunkL23ZLSDQ_cjs.isFlattenNode(obj)) return opFlatten(obj, context, evaluateNode);
|
|
1343
|
+
if (chunkL23ZLSDQ_cjs.isUniqueNode(obj)) return opUnique(obj, context, evaluateNode);
|
|
1344
|
+
if (chunkL23ZLSDQ_cjs.isSortByNode(obj)) return opSortBy(obj, context, evaluateNode);
|
|
1345
|
+
if (chunkL23ZLSDQ_cjs.isAddNode(obj)) return opAdd(obj, context, evaluateNode);
|
|
1346
|
+
if (chunkL23ZLSDQ_cjs.isSubNode(obj)) return opSub(obj, context, evaluateNode);
|
|
1347
|
+
if (chunkL23ZLSDQ_cjs.isMulNode(obj)) return opMul(obj, context, evaluateNode);
|
|
1348
|
+
if (chunkL23ZLSDQ_cjs.isDivNode(obj)) return opDiv(obj, context, evaluateNode);
|
|
1349
|
+
if (chunkL23ZLSDQ_cjs.isRoundNode(obj)) return opRound(obj, context, evaluateNode);
|
|
1350
|
+
if (chunkL23ZLSDQ_cjs.isModNode(obj)) return opMod(obj, context, evaluateNode);
|
|
1351
|
+
if (chunkL23ZLSDQ_cjs.isToNumberNode(obj)) return opToNumber(obj, context, evaluateNode);
|
|
1352
|
+
if (chunkL23ZLSDQ_cjs.isJoinNode(obj)) return opJoin(obj, context, evaluateNode);
|
|
1353
|
+
if (chunkL23ZLSDQ_cjs.isToStringNode(obj)) return opToString(obj, context, evaluateNode);
|
|
1354
|
+
if (chunkL23ZLSDQ_cjs.isInterpolateNode(obj)) return opInterpolate(obj, context, evaluateNode);
|
|
1355
|
+
if (chunkL23ZLSDQ_cjs.isFillNode(obj)) return opFill(obj, context, evaluateNode);
|
|
1356
|
+
if (chunkL23ZLSDQ_cjs.isTrimNode(obj)) return opTrim(obj, context, evaluateNode);
|
|
1357
|
+
if (chunkL23ZLSDQ_cjs.isLowerNode(obj)) return opLower(obj, context, evaluateNode);
|
|
1358
|
+
if (chunkL23ZLSDQ_cjs.isUpperNode(obj)) return opUpper(obj, context, evaluateNode);
|
|
1359
|
+
if (chunkL23ZLSDQ_cjs.isSplitNode(obj)) return opSplit(obj, context, evaluateNode);
|
|
1360
|
+
if (chunkL23ZLSDQ_cjs.isReplaceNode(obj)) return opReplace(obj, context, evaluateNode);
|
|
1361
|
+
if (chunkL23ZLSDQ_cjs.isEqNode(obj)) return opEq(obj, context, evaluateNode);
|
|
1362
|
+
if (chunkL23ZLSDQ_cjs.isNeqNode(obj)) return opNeq(obj, context, evaluateNode);
|
|
1363
|
+
if (chunkL23ZLSDQ_cjs.isGtNode(obj)) return opGt(obj, context, evaluateNode);
|
|
1364
|
+
if (chunkL23ZLSDQ_cjs.isGteNode(obj)) return opGte(obj, context, evaluateNode);
|
|
1365
|
+
if (chunkL23ZLSDQ_cjs.isLtNode(obj)) return opLt(obj, context, evaluateNode);
|
|
1366
|
+
if (chunkL23ZLSDQ_cjs.isLteNode(obj)) return opLte(obj, context, evaluateNode);
|
|
1367
|
+
if (chunkL23ZLSDQ_cjs.isEmptyNode(obj)) return opEmpty(obj, context, evaluateNode);
|
|
1368
|
+
if (chunkL23ZLSDQ_cjs.isStartsWithNode(obj)) return opStartsWith(obj, context, evaluateNode);
|
|
1369
|
+
if (chunkL23ZLSDQ_cjs.isEndsWithNode(obj)) return opEndsWith(obj, context, evaluateNode);
|
|
1370
|
+
if (chunkL23ZLSDQ_cjs.isContainsNode(obj)) return opContains(obj, context, evaluateNode);
|
|
1371
|
+
if (chunkL23ZLSDQ_cjs.isNotNode(obj)) return opNot(obj, context, evaluateNode);
|
|
1372
|
+
if (chunkL23ZLSDQ_cjs.isAndNode(obj)) return opAnd(obj, context, evaluateNode);
|
|
1373
|
+
if (chunkL23ZLSDQ_cjs.isOrNode(obj)) return opOr(obj, context, evaluateNode);
|
|
1374
|
+
if (chunkL23ZLSDQ_cjs.isMergeNode(obj)) return opMerge(obj, context, evaluateNode);
|
|
1375
|
+
if (chunkL23ZLSDQ_cjs.isCoalesceNode(obj)) return opCoalesce(obj, context, evaluateNode);
|
|
1376
|
+
if (chunkL23ZLSDQ_cjs.isCaseNode(obj)) return opCase(obj, context, evaluateNode);
|
|
1377
|
+
if (chunkL23ZLSDQ_cjs.isEntriesOfNode(obj)) return opEntriesOf(obj, context, evaluateNode);
|
|
1378
|
+
if (chunkL23ZLSDQ_cjs.isKeyByNode(obj)) return opKeyBy(obj, context, evaluateNode);
|
|
1379
|
+
if (chunkL23ZLSDQ_cjs.isGroupByNode(obj)) return opGroupBy(obj, context, evaluateNode);
|
|
1380
|
+
if (chunkL23ZLSDQ_cjs.isKeysNode(obj)) return opKeys(obj, context, evaluateNode);
|
|
1381
|
+
if (chunkL23ZLSDQ_cjs.isValuesNode(obj)) return opValues(obj, context, evaluateNode);
|
|
1382
|
+
if (chunkL23ZLSDQ_cjs.isFromEntriesNode(obj)) return opFromEntries(obj, context, evaluateNode);
|
|
1383
|
+
if (chunkL23ZLSDQ_cjs.isPickNode(obj)) return opPick(obj, context, evaluateNode);
|
|
1384
|
+
if (chunkL23ZLSDQ_cjs.isOmitNode(obj)) return opOmit(obj, context, evaluateNode);
|
|
1385
|
+
if (chunkL23ZLSDQ_cjs.isTypeNode(obj)) return opType(obj, context, evaluateNode);
|
|
1386
|
+
if (chunkL23ZLSDQ_cjs.isLengthNode(obj)) return opLength(obj, context, evaluateNode);
|
|
1387
|
+
if (chunkL23ZLSDQ_cjs.isHasNode(obj)) return opHas(obj, context, evaluateNode);
|
|
1388
|
+
if (chunkL23ZLSDQ_cjs.isRenameKeysNode(obj)) return opRenameKeys(obj, context, evaluateNode);
|
|
1389
|
+
if (chunkL23ZLSDQ_cjs.isUpdateNode(obj)) return opUpdate(obj, context, evaluateNode);
|
|
1390
|
+
if (chunkL23ZLSDQ_cjs.isAssertNode(obj)) return opAssert(obj, context, evaluateNode);
|
|
1391
|
+
if (chunkL23ZLSDQ_cjs.isWalkNode(obj)) return opWalk(obj, context, evaluateNode);
|
|
1392
|
+
if (chunkL23ZLSDQ_cjs.isDateNode(obj)) return opDate(obj, context, evaluateNode);
|
|
1393
|
+
if (chunkL23ZLSDQ_cjs.isDateAddNode(obj)) return opDateAdd(obj, context, evaluateNode);
|
|
1394
|
+
if (chunkL23ZLSDQ_cjs.isDateDiffNode(obj)) return opDateDiff(obj, context, evaluateNode);
|
|
1395
|
+
if (chunkL23ZLSDQ_cjs.isLocaleDateNode(obj)) return opLocaleDate(obj, context, evaluateNode);
|
|
1396
|
+
if (chunkL23ZLSDQ_cjs.isLocaleMoneyNode(obj)) return opLocaleMoney(obj, context, evaluateNode);
|
|
1397
|
+
if (chunkL23ZLSDQ_cjs.isLocaleNumberNode(obj)) return opLocaleNumber(obj, context, evaluateNode);
|
|
1371
1398
|
const unknownKeys = Object.keys(obj).filter((k) => k.startsWith("$"));
|
|
1372
1399
|
const preview = JSON.stringify(obj).slice(0, 100);
|
|
1373
|
-
return
|
|
1374
|
-
`No op answers this node: ${
|
|
1375
|
-
|
|
1400
|
+
return chunkL23ZLSDQ_cjs.failAt(
|
|
1401
|
+
`No op answers this node: ${chunkL23ZLSDQ_cjs.clip(JSON.stringify(obj), 100)} (keys: ${unknownKeys.join(", ")}). The tree did not go through the schema.`,
|
|
1402
|
+
chunkL23ZLSDQ_cjs.ErrorCode.NODE_SHAPE,
|
|
1376
1403
|
{ details: { keys: unknownKeys, preview } },
|
|
1377
1404
|
{ node: obj, form: false }
|
|
1378
1405
|
);
|
|
@@ -1400,12 +1427,12 @@ var notJson = (value, at) => {
|
|
|
1400
1427
|
return void 0;
|
|
1401
1428
|
};
|
|
1402
1429
|
var checked = (config) => {
|
|
1403
|
-
if (strata.exceedsDepth(config)) throw new
|
|
1404
|
-
const parsed =
|
|
1430
|
+
if (strata.exceedsDepth(config)) throw new chunkL23ZLSDQ_cjs.PrismError(`Invalid config: ${strata.depthRefusal()}`, chunkL23ZLSDQ_cjs.ErrorCode.SCHEMA, { details: { issues: [{ path: "root", message: strata.depthRefusal() }] } });
|
|
1431
|
+
const parsed = chunkL23ZLSDQ_cjs.ConfigSchema.safeParse(config);
|
|
1405
1432
|
if (!parsed.success) {
|
|
1406
1433
|
const explained = explainIssues(parsed.error.issues, config);
|
|
1407
1434
|
const issues = explained.map((i) => ({ path: i.path.join(".") || "root", message: i.message }));
|
|
1408
|
-
throw new
|
|
1435
|
+
throw new chunkL23ZLSDQ_cjs.PrismError(`Invalid config: ${issuesText(explained)}`, chunkL23ZLSDQ_cjs.ErrorCode.SCHEMA, { details: { issues } });
|
|
1409
1436
|
}
|
|
1410
1437
|
return desugar(parsed.data);
|
|
1411
1438
|
};
|
|
@@ -1424,7 +1451,7 @@ var keptTrees = /* @__PURE__ */ new WeakMap();
|
|
|
1424
1451
|
var evaluate = (config, source, options) => {
|
|
1425
1452
|
if (options?.check === "always") {
|
|
1426
1453
|
const wrong = notJson(source, "source");
|
|
1427
|
-
if (wrong !== void 0) throw new
|
|
1454
|
+
if (wrong !== void 0) throw new chunkL23ZLSDQ_cjs.PrismError(`The source must be plain JSON: ${wrong}.`, chunkL23ZLSDQ_cjs.ErrorCode.TYPE);
|
|
1428
1455
|
return run(checked(config), source, options.limits, false, config);
|
|
1429
1456
|
}
|
|
1430
1457
|
const input = source;
|
|
@@ -1459,7 +1486,7 @@ var walk = (node, stats, depth) => {
|
|
|
1459
1486
|
for (const child of node) walk(child, stats, depth + 1);
|
|
1460
1487
|
return;
|
|
1461
1488
|
}
|
|
1462
|
-
if (!
|
|
1489
|
+
if (!chunkL23ZLSDQ_cjs.isJsonObject(node)) return;
|
|
1463
1490
|
for (const key of Object.keys(node)) {
|
|
1464
1491
|
if (key.startsWith("$")) {
|
|
1465
1492
|
stats.opCount[key] = (stats.opCount[key] ?? 0) + 1;
|
|
@@ -1479,10 +1506,10 @@ var hashSha256 = async (data) => {
|
|
|
1479
1506
|
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1480
1507
|
};
|
|
1481
1508
|
var compile = async (config, options) => {
|
|
1482
|
-
if (strata.exceedsDepth(config)) throw new
|
|
1483
|
-
const parsed =
|
|
1509
|
+
if (strata.exceedsDepth(config)) throw new chunkL23ZLSDQ_cjs.PrismError(`Invalid config: ${strata.depthRefusal()}`, chunkL23ZLSDQ_cjs.ErrorCode.SCHEMA);
|
|
1510
|
+
const parsed = chunkL23ZLSDQ_cjs.ConfigSchema.safeParse(config);
|
|
1484
1511
|
if (!parsed.success) {
|
|
1485
|
-
throw new
|
|
1512
|
+
throw new chunkL23ZLSDQ_cjs.PrismError(`Invalid config: ${issuesText(explainIssues(parsed.error.issues, config))}`, chunkL23ZLSDQ_cjs.ErrorCode.SCHEMA);
|
|
1486
1513
|
}
|
|
1487
1514
|
const desugared = desugar(parsed.data);
|
|
1488
1515
|
const { node: core, stats: optimizations } = optimize(desugared, evaluateNode);
|
|
@@ -1540,7 +1567,7 @@ var execute = (ir, source, limits) => {
|
|
|
1540
1567
|
};
|
|
1541
1568
|
var validate = (config) => {
|
|
1542
1569
|
if (strata.exceedsDepth(config)) return { ok: false, issues: [{ path: [], message: strata.depthRefusal() }] };
|
|
1543
|
-
const parsed =
|
|
1570
|
+
const parsed = chunkL23ZLSDQ_cjs.ConfigSchema.safeParse(config);
|
|
1544
1571
|
if (!parsed.success) {
|
|
1545
1572
|
return {
|
|
1546
1573
|
ok: false,
|
|
@@ -1552,39 +1579,39 @@ var validate = (config) => {
|
|
|
1552
1579
|
|
|
1553
1580
|
Object.defineProperty(exports, "MAPPING_OPS", {
|
|
1554
1581
|
enumerable: true,
|
|
1555
|
-
get: function () { return
|
|
1582
|
+
get: function () { return chunkDOCK3CEK_cjs.MAPPING_OPS; }
|
|
1556
1583
|
});
|
|
1557
1584
|
Object.defineProperty(exports, "getConfigJsonSchema", {
|
|
1558
1585
|
enumerable: true,
|
|
1559
|
-
get: function () { return
|
|
1586
|
+
get: function () { return chunkDOCK3CEK_cjs.getConfigJsonSchema; }
|
|
1560
1587
|
});
|
|
1561
1588
|
Object.defineProperty(exports, "getNodeJsonSchema", {
|
|
1562
1589
|
enumerable: true,
|
|
1563
|
-
get: function () { return
|
|
1590
|
+
get: function () { return chunkDOCK3CEK_cjs.getNodeJsonSchema; }
|
|
1564
1591
|
});
|
|
1565
1592
|
Object.defineProperty(exports, "getProfileJsonSchema", {
|
|
1566
1593
|
enumerable: true,
|
|
1567
|
-
get: function () { return
|
|
1594
|
+
get: function () { return chunkDOCK3CEK_cjs.getProfileJsonSchema; }
|
|
1568
1595
|
});
|
|
1569
1596
|
Object.defineProperty(exports, "ConfigSchema", {
|
|
1570
1597
|
enumerable: true,
|
|
1571
|
-
get: function () { return
|
|
1598
|
+
get: function () { return chunkL23ZLSDQ_cjs.ConfigSchema; }
|
|
1572
1599
|
});
|
|
1573
1600
|
Object.defineProperty(exports, "ErrorCode", {
|
|
1574
1601
|
enumerable: true,
|
|
1575
|
-
get: function () { return
|
|
1602
|
+
get: function () { return chunkL23ZLSDQ_cjs.ErrorCode; }
|
|
1576
1603
|
});
|
|
1577
1604
|
Object.defineProperty(exports, "NodeSchema", {
|
|
1578
1605
|
enumerable: true,
|
|
1579
|
-
get: function () { return
|
|
1606
|
+
get: function () { return chunkL23ZLSDQ_cjs.NodeSchema; }
|
|
1580
1607
|
});
|
|
1581
1608
|
Object.defineProperty(exports, "OP_KEYS", {
|
|
1582
1609
|
enumerable: true,
|
|
1583
|
-
get: function () { return
|
|
1610
|
+
get: function () { return chunkL23ZLSDQ_cjs.OP_KEYS; }
|
|
1584
1611
|
});
|
|
1585
1612
|
Object.defineProperty(exports, "PrismError", {
|
|
1586
1613
|
enumerable: true,
|
|
1587
|
-
get: function () { return
|
|
1614
|
+
get: function () { return chunkL23ZLSDQ_cjs.PrismError; }
|
|
1588
1615
|
});
|
|
1589
1616
|
exports.DEFAULT_LIMITS = DEFAULT_LIMITS;
|
|
1590
1617
|
exports.compile = compile;
|