@niscorp/prism 0.2.2 → 0.3.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/CHANGELOG.md +187 -0
- package/DESIGN.md +9 -8
- package/DOCS.md +68 -25
- package/README.md +35 -22
- package/dist/agent.cjs +4 -4
- package/dist/agent.js +2 -2
- package/dist/{chunk-26VYDHHC.cjs → chunk-66YSI4PX.cjs} +268 -97
- package/dist/chunk-66YSI4PX.cjs.map +1 -0
- package/dist/{chunk-O3OJAQWA.js → chunk-7VMFSXBM.js} +262 -98
- package/dist/chunk-7VMFSXBM.js.map +1 -0
- package/dist/{chunk-XRK55NPE.js → chunk-BKXCULZV.js} +5 -3
- package/dist/chunk-BKXCULZV.js.map +1 -0
- package/dist/{chunk-W32JXP33.cjs → chunk-OLZQK2ZF.cjs} +7 -5
- package/dist/chunk-OLZQK2ZF.cjs.map +1 -0
- package/dist/examples/index.cjs +25 -2
- package/dist/examples/index.cjs.map +1 -1
- package/dist/examples/index.d.cts +1 -1
- package/dist/examples/index.d.ts +1 -1
- package/dist/examples/index.js +25 -2
- package/dist/examples/index.js.map +1 -1
- package/dist/index.cjs +1224 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +1120 -26
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.cjs +15 -7
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/migrations/index.d.cts +0 -2
- package/dist/migrations/index.d.ts +0 -2
- package/dist/migrations/index.js +14 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/{profiles-C6r-x-Vj.d.cts → profiles-CPVfysxC.d.cts} +2 -1
- package/dist/{profiles-C6r-x-Vj.d.ts → profiles-CPVfysxC.d.ts} +2 -1
- package/package.json +4 -4
- package/dist/chunk-26VYDHHC.cjs.map +0 -1
- package/dist/chunk-O3OJAQWA.js.map +0 -1
- package/dist/chunk-V426VIRI.cjs +0 -1168
- package/dist/chunk-V426VIRI.cjs.map +0 -1
- package/dist/chunk-VC4PRB4H.js +0 -1086
- package/dist/chunk-VC4PRB4H.js.map +0 -1
- package/dist/chunk-W32JXP33.cjs.map +0 -1
- package/dist/chunk-XRK55NPE.js.map +0 -1
- package/dist/transform-DcVcOBzQ.d.cts +0 -3
- package/dist/transform-DcVcOBzQ.d.ts +0 -3
|
@@ -1,18 +1,200 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var ErrorCode = {
|
|
5
|
+
SCHEMA: "E_SCHEMA",
|
|
6
|
+
MISSING_PATH: "E_MISSING_PATH",
|
|
7
|
+
TYPE: "E_TYPE",
|
|
8
|
+
DIVISION_BY_ZERO: "E_DIVISION_BY_ZERO",
|
|
9
|
+
DATE_INVALID: "E_DATE_INVALID",
|
|
10
|
+
VAR_NOT_FOUND: "E_VAR_NOT_FOUND",
|
|
11
|
+
NODE_SHAPE: "E_NODE_SHAPE",
|
|
12
|
+
// A config's own `$assert` refused its input.
|
|
13
|
+
ASSERT: "E_ASSERT",
|
|
14
|
+
// An evaluation past its budget (engine/budget.ts).
|
|
15
|
+
BUDGET: "E_BUDGET"
|
|
16
|
+
};
|
|
17
|
+
var PrismError = class extends Error {
|
|
18
|
+
code;
|
|
19
|
+
context;
|
|
20
|
+
constructor(message, code, context) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "PrismError";
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.context = context;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
4
27
|
var JsonPrimitiveSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]).describe("JSON primitive: string | number | boolean | null");
|
|
5
28
|
var JsonValueSchema = z.lazy(
|
|
6
29
|
() => z.union([JsonPrimitiveSchema, z.array(JsonValueSchema), z.record(z.string(), JsonValueSchema)])
|
|
7
30
|
).describe("Any JSON value: primitive, array, or object");
|
|
8
31
|
z.record(z.string(), JsonValueSchema).describe("JSON object mapping string keys to JSON values");
|
|
32
|
+
|
|
33
|
+
// src/schemas/guards.ts
|
|
34
|
+
var hasKey = (value, key) => typeof value === "object" && value !== null && !Array.isArray(value) && key in value;
|
|
35
|
+
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
|
+
var isJsonArray = (value) => Array.isArray(value);
|
|
37
|
+
var isRefNode = (v) => hasKey(v, "$ref");
|
|
38
|
+
var isConstNode = (v) => hasKey(v, "$const");
|
|
39
|
+
var isVarNode = (v) => hasKey(v, "$var");
|
|
40
|
+
var isGetNode = (v) => hasKey(v, "$get");
|
|
41
|
+
var isWithNode = (v) => hasKey(v, "$with");
|
|
42
|
+
var isMapNode = (v) => hasKey(v, "$map");
|
|
43
|
+
var isFilterNode = (v) => hasKey(v, "$filter");
|
|
44
|
+
var isReduceNode = (v) => hasKey(v, "$reduce");
|
|
45
|
+
var isSliceNode = (v) => hasKey(v, "$slice");
|
|
46
|
+
var isFlattenNode = (v) => hasKey(v, "$flatten");
|
|
47
|
+
var isUniqueNode = (v) => hasKey(v, "$unique");
|
|
48
|
+
var isSortByNode = (v) => hasKey(v, "$sortBy");
|
|
49
|
+
var isAddNode = (v) => hasKey(v, "$add");
|
|
50
|
+
var isSubNode = (v) => hasKey(v, "$sub");
|
|
51
|
+
var isMulNode = (v) => hasKey(v, "$mul");
|
|
52
|
+
var isDivNode = (v) => hasKey(v, "$div");
|
|
53
|
+
var isRoundNode = (v) => hasKey(v, "$round");
|
|
54
|
+
var isModNode = (v) => hasKey(v, "$mod");
|
|
55
|
+
var isToNumberNode = (v) => hasKey(v, "$toNumber");
|
|
56
|
+
var isJoinNode = (v) => hasKey(v, "$join");
|
|
57
|
+
var isToStringNode = (v) => hasKey(v, "$toString");
|
|
58
|
+
var isInterpolateNode = (v) => hasKey(v, "$interpolate");
|
|
59
|
+
var isFillNode = (v) => hasKey(v, "$fill");
|
|
60
|
+
var isTrimNode = (v) => hasKey(v, "$trim");
|
|
61
|
+
var isLowerNode = (v) => hasKey(v, "$lower");
|
|
62
|
+
var isUpperNode = (v) => hasKey(v, "$upper");
|
|
63
|
+
var isSplitNode = (v) => hasKey(v, "$split");
|
|
64
|
+
var isReplaceNode = (v) => hasKey(v, "$replace");
|
|
65
|
+
var isEqNode = (v) => hasKey(v, "$eq");
|
|
66
|
+
var isNeqNode = (v) => hasKey(v, "$neq");
|
|
67
|
+
var isGtNode = (v) => hasKey(v, "$gt");
|
|
68
|
+
var isGteNode = (v) => hasKey(v, "$gte");
|
|
69
|
+
var isLtNode = (v) => hasKey(v, "$lt");
|
|
70
|
+
var isLteNode = (v) => hasKey(v, "$lte");
|
|
71
|
+
var isEmptyNode = (v) => hasKey(v, "$empty");
|
|
72
|
+
var isStartsWithNode = (v) => hasKey(v, "$startsWith");
|
|
73
|
+
var isEndsWithNode = (v) => hasKey(v, "$endsWith");
|
|
74
|
+
var isContainsNode = (v) => hasKey(v, "$contains");
|
|
75
|
+
var isNotNode = (v) => hasKey(v, "$not");
|
|
76
|
+
var isAndNode = (v) => hasKey(v, "$and");
|
|
77
|
+
var isOrNode = (v) => hasKey(v, "$or");
|
|
78
|
+
var isMergeNode = (v) => hasKey(v, "$merge");
|
|
79
|
+
var isCoalesceNode = (v) => hasKey(v, "$coalesce");
|
|
80
|
+
var isCaseNode = (v) => hasKey(v, "$case");
|
|
81
|
+
var isEntriesOfNode = (v) => hasKey(v, "$entriesOf");
|
|
82
|
+
var isKeyByNode = (v) => hasKey(v, "$keyBy");
|
|
83
|
+
var isGroupByNode = (v) => hasKey(v, "$groupBy");
|
|
84
|
+
var isKeysNode = (v) => hasKey(v, "$keys");
|
|
85
|
+
var isValuesNode = (v) => hasKey(v, "$values");
|
|
86
|
+
var isFromEntriesNode = (v) => hasKey(v, "$fromEntries");
|
|
87
|
+
var isPickNode = (v) => hasKey(v, "$pick");
|
|
88
|
+
var isOmitNode = (v) => hasKey(v, "$omit");
|
|
89
|
+
var isHasNode = (v) => hasKey(v, "$has");
|
|
90
|
+
var isRenameKeysNode = (v) => hasKey(v, "$renameKeys");
|
|
91
|
+
var isUpdateNode = (v) => hasKey(v, "$update");
|
|
92
|
+
var isAssertNode = (v) => hasKey(v, "$assert");
|
|
93
|
+
var isWalkNode = (v) => hasKey(v, "$walk");
|
|
94
|
+
var isTypeNode = (v) => hasKey(v, "$type");
|
|
95
|
+
var isLengthNode = (v) => hasKey(v, "$length");
|
|
96
|
+
var isDateNode = (v) => hasKey(v, "$date");
|
|
97
|
+
var isDateAddNode = (v) => hasKey(v, "$dateAdd");
|
|
98
|
+
var isDateDiffNode = (v) => hasKey(v, "$dateDiff");
|
|
99
|
+
var isLocaleDateNode = (v) => hasKey(v, "$localeDate");
|
|
100
|
+
var isLocaleMoneyNode = (v) => hasKey(v, "$localeMoney");
|
|
101
|
+
var isLocaleNumberNode = (v) => hasKey(v, "$localeNumber");
|
|
102
|
+
var isSumNode = (v) => hasKey(v, "$sum");
|
|
103
|
+
var isAvgNode = (v) => hasKey(v, "$avg");
|
|
104
|
+
var isCountNode = (v) => hasKey(v, "$count");
|
|
105
|
+
var isMinNode = (v) => hasKey(v, "$min");
|
|
106
|
+
var isMaxNode = (v) => hasKey(v, "$max");
|
|
107
|
+
var isPluckNode = (v) => hasKey(v, "$pluck");
|
|
108
|
+
var isTakeNode = (v) => hasKey(v, "$take");
|
|
109
|
+
var isDropNode = (v) => hasKey(v, "$drop");
|
|
110
|
+
var isMatchNode = (v) => hasKey(v, "$match");
|
|
111
|
+
var isFlatMapNode = (v) => hasKey(v, "$flatMap");
|
|
112
|
+
var isPlainObject = (value) => isJsonObject(value) && !Object.keys(value).some((k) => k.startsWith("$"));
|
|
113
|
+
|
|
114
|
+
// src/utils/jsonpath.ts
|
|
115
|
+
var pathRefusal = (path) => `Not a path Prism reads: "${path}". A path is keys and indexes only, as in $.rows[0].sku; for every item of a list use $map or $pluck.`;
|
|
116
|
+
var refuse = (path) => {
|
|
117
|
+
throw new PrismError(pathRefusal(path), ErrorCode.SCHEMA, { op: "$ref", path });
|
|
118
|
+
};
|
|
119
|
+
var isReadablePath = (path) => {
|
|
120
|
+
if (!path.includes("[") && !path.includes("..")) return true;
|
|
121
|
+
try {
|
|
122
|
+
parseJsonPath(path);
|
|
123
|
+
return true;
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var parseJsonPath = (path) => {
|
|
129
|
+
if (!path.startsWith("$.")) return [];
|
|
130
|
+
const segments = [];
|
|
131
|
+
let cursor = 2;
|
|
132
|
+
let currentKey = "";
|
|
133
|
+
const pushKey = () => {
|
|
134
|
+
if (currentKey.length > 0) {
|
|
135
|
+
segments.push({ type: "key", key: currentKey });
|
|
136
|
+
currentKey = "";
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
while (cursor < path.length) {
|
|
140
|
+
const char = path[cursor];
|
|
141
|
+
if (char === ".") {
|
|
142
|
+
if (path[cursor - 1] === ".") refuse(path);
|
|
143
|
+
pushKey();
|
|
144
|
+
cursor++;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (char === "[") {
|
|
148
|
+
pushKey();
|
|
149
|
+
cursor++;
|
|
150
|
+
let numBuf = "";
|
|
151
|
+
while (cursor < path.length && path[cursor] !== "]") {
|
|
152
|
+
numBuf += path[cursor];
|
|
153
|
+
cursor++;
|
|
154
|
+
}
|
|
155
|
+
if (path[cursor] !== "]") refuse(path);
|
|
156
|
+
cursor++;
|
|
157
|
+
const index = Number(numBuf);
|
|
158
|
+
if (numBuf.trim() === "" || !Number.isInteger(index) || index < 0) refuse(path);
|
|
159
|
+
segments.push({ type: "index", index });
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
currentKey += char;
|
|
163
|
+
cursor++;
|
|
164
|
+
}
|
|
165
|
+
pushKey();
|
|
166
|
+
return segments;
|
|
167
|
+
};
|
|
168
|
+
var cache = /* @__PURE__ */ new Map();
|
|
169
|
+
var parseJsonPathCached = (path) => {
|
|
170
|
+
const cached = cache.get(path);
|
|
171
|
+
if (cached) return cached;
|
|
172
|
+
const parsed = parseJsonPath(path);
|
|
173
|
+
cache.set(path, parsed);
|
|
174
|
+
return parsed;
|
|
175
|
+
};
|
|
176
|
+
var getByPath = (root, segments) => {
|
|
177
|
+
let current = root;
|
|
178
|
+
for (const segment of segments) {
|
|
179
|
+
if (segment.type === "key") {
|
|
180
|
+
if (!isJsonObject(current)) return void 0;
|
|
181
|
+
current = current[segment.key];
|
|
182
|
+
} else {
|
|
183
|
+
if (!isJsonArray(current)) return void 0;
|
|
184
|
+
current = current[segment.index];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return current;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/schemas/ops/core.schema.ts
|
|
9
191
|
var _NodeSchema = z.any();
|
|
10
192
|
var setNodeSchema = (schema) => {
|
|
11
193
|
_NodeSchema = schema;
|
|
12
194
|
};
|
|
13
195
|
var node = () => _NodeSchema;
|
|
14
196
|
var RefNodeSchema = z.object({
|
|
15
|
-
$ref: z.string().regex(/^\$(\..*)?$/).describe('JSONPath from the source root: "$" is the whole source; "$.user.name", "$.items[0].sku" reach into it. Only reads from source data, not variables. For variables use $var, for navigating into variables use $get.')
|
|
197
|
+
$ref: z.string().regex(/^\$(\..*)?$/).refine(isReadablePath, { error: (issue) => pathRefusal(String(issue.input)) }).describe('JSONPath from the source root: "$" is the whole source; "$.user.name", "$.items[0].sku" reach into it. Only reads from source data, not variables. For variables use $var, for navigating into variables use $get.')
|
|
16
198
|
}).strict().describe("Read a value from the source data by static JSONPath. Use $ref for source access, $var for variables, $get for navigating into variables or dynamic paths.");
|
|
17
199
|
var ConstNodeSchema = z.object({
|
|
18
200
|
$const: JsonValueSchema.describe("Any JSON value to return as-is.")
|
|
@@ -92,12 +274,20 @@ var AddNodeSchema = z.object({ $add: pairOf("Two numeric operands to add.") }).s
|
|
|
92
274
|
var SubNodeSchema = z.object({ $sub: pairOf("Two numeric operands to subtract (a - b).") }).strict().describe("Subtract second number from first.");
|
|
93
275
|
var MulNodeSchema = z.object({ $mul: pairOf("Two numeric operands to multiply.") }).strict().describe("Multiply two numbers.");
|
|
94
276
|
var DivNodeSchema = z.object({ $div: pairOf("Two numeric operands to divide (a / b). Throws on division by zero.") }).strict().describe("Divide first number by second. Throws E_DIVISION_BY_ZERO if divisor is 0.");
|
|
277
|
+
var ModNodeSchema = z.object({ $mod: pairOf("Two numeric operands: the remainder of a divided by b. Throws on division by zero.") }).strict().describe("The remainder of the first number divided by the second, with the sign of the second: for a positive divisor n it is always from 0 up to n, also for a negative first number. Throws E_DIVISION_BY_ZERO if divisor is 0.");
|
|
95
278
|
var RoundNodeSchema = z.object({
|
|
96
279
|
$round: z.object({
|
|
97
280
|
value: z.lazy(node3).describe("Numeric value to round."),
|
|
98
|
-
digits: z.number().int().nonnegative().optional().default(0).describe("Decimal places. Default: 0.")
|
|
281
|
+
digits: z.number().int().nonnegative().optional().default(0).describe("Decimal places. Default: 0."),
|
|
282
|
+
mode: z.enum(["nearest", "floor", "ceil"]).optional().describe('Which way to round: "nearest" (the default), "floor" (down, toward negative infinity) or "ceil" (up).')
|
|
99
283
|
}).strict()
|
|
100
|
-
}).strict().describe(
|
|
284
|
+
}).strict().describe('Round a number to N decimal places: to the nearest, or down ("floor") or up ("ceil") with `mode`.');
|
|
285
|
+
var ToNumberNodeSchema = z.object({
|
|
286
|
+
$toNumber: z.object({
|
|
287
|
+
value: z.lazy(node3).describe('A number, or text that is a number written in digits: "42", "-3.5", " 1e3 ".'),
|
|
288
|
+
fallback: z.lazy(node3).optional().describe("What to answer when the value is not a number and not such text. Without it that is an error.")
|
|
289
|
+
}).strict()
|
|
290
|
+
}).strict().describe("A number from a number or from numeric text, as data from a form, a CSV or an API often has it. Anything else (other text, true, null, an object) throws E_TYPE unless `fallback` is given.");
|
|
101
291
|
var _NodeSchema4 = z.any();
|
|
102
292
|
var setNodeSchema4 = (schema) => {
|
|
103
293
|
_NodeSchema4 = schema;
|
|
@@ -132,9 +322,10 @@ var ReplaceNodeSchema = z.object({
|
|
|
132
322
|
$replace: z.object({
|
|
133
323
|
value: z.lazy(node4).describe("String to search in."),
|
|
134
324
|
search: z.string().describe("Substring to find."),
|
|
135
|
-
replacement: z.string().describe("Replacement string.")
|
|
325
|
+
replacement: z.string().describe("Replacement string."),
|
|
326
|
+
all: z.boolean().optional().describe("true replaces every occurrence. Default: only the first.")
|
|
136
327
|
}).strict()
|
|
137
|
-
}).strict().describe("Replace the first occurrence of a substring
|
|
328
|
+
}).strict().describe("Replace the first occurrence of a substring, or every occurrence with `all: true`.");
|
|
138
329
|
var _NodeSchema5 = z.any();
|
|
139
330
|
var setNodeSchema5 = (schema) => {
|
|
140
331
|
_NodeSchema5 = schema;
|
|
@@ -434,7 +625,9 @@ var OP_KEYS = [
|
|
|
434
625
|
"$sub",
|
|
435
626
|
"$mul",
|
|
436
627
|
"$div",
|
|
628
|
+
"$mod",
|
|
437
629
|
"$round",
|
|
630
|
+
"$toNumber",
|
|
438
631
|
"$fill",
|
|
439
632
|
"$join",
|
|
440
633
|
"$toString",
|
|
@@ -502,8 +695,62 @@ var hasValidOptionalMeta = (obj) => {
|
|
|
502
695
|
if (!Array.isArray(meta)) return false;
|
|
503
696
|
return meta.every((f) => typeof f === "string" && f.length > 0);
|
|
504
697
|
};
|
|
698
|
+
var NodeArraySchema = z.array(z.lazy(() => NodeSchema));
|
|
699
|
+
var TemplateSchema = z.record(z.string().regex(TEMPLATE_KEY, { error: (issue) => templateKeyRefusal(issue.input) }), z.lazy(() => NodeSchema)).refine((o) => hasValidOptionalMeta(o), { message: "__optional must be an array of non-empty field name strings." });
|
|
700
|
+
var opMembersOf = (options) => {
|
|
701
|
+
const members = /* @__PURE__ */ new Map();
|
|
702
|
+
for (const option of options) {
|
|
703
|
+
const { def } = option._zod;
|
|
704
|
+
const keys = "shape" in def && typeof def.shape === "object" && def.shape !== null ? Object.keys(def.shape) : [];
|
|
705
|
+
const [key] = keys;
|
|
706
|
+
if (keys.length === 1 && key !== void 0 && isOpKey(key)) members.set(key, option);
|
|
707
|
+
}
|
|
708
|
+
return members;
|
|
709
|
+
};
|
|
710
|
+
var memberOf = (value, ops) => {
|
|
711
|
+
if (value === null || typeof value !== "object") return JsonPrimitiveSchema;
|
|
712
|
+
if (Array.isArray(value)) return NodeArraySchema;
|
|
713
|
+
const proto = Object.getPrototypeOf(value);
|
|
714
|
+
if (proto !== Object.prototype && proto !== null) return void 0;
|
|
715
|
+
let op;
|
|
716
|
+
let count = 0;
|
|
717
|
+
for (const key in value) {
|
|
718
|
+
count += 1;
|
|
719
|
+
if (key.startsWith("$")) op = key;
|
|
720
|
+
}
|
|
721
|
+
if (op === void 0) return TemplateSchema;
|
|
722
|
+
return count === 1 ? ops.get(op) : void 0;
|
|
723
|
+
};
|
|
724
|
+
var quick = /* @__PURE__ */ new WeakSet();
|
|
725
|
+
var walking = /* @__PURE__ */ new WeakSet();
|
|
726
|
+
var NodeUnion = z.core.$constructor("PrismNodeUnion", (inst, def) => {
|
|
727
|
+
z.ZodUnion.init(inst, def);
|
|
728
|
+
const ops = opMembersOf(def.options);
|
|
729
|
+
const walk = inst._zod.parse;
|
|
730
|
+
inst._zod.parse = (payload, ctx) => {
|
|
731
|
+
if (ctx.async !== false || walking.has(ctx)) return walk(payload, ctx);
|
|
732
|
+
const member = memberOf(payload.value, ops);
|
|
733
|
+
if (quick.has(ctx)) {
|
|
734
|
+
if (member !== void 0) return member._zod.run(payload, ctx);
|
|
735
|
+
payload.issues.push({ code: "custom", input: payload.value, inst });
|
|
736
|
+
return payload;
|
|
737
|
+
}
|
|
738
|
+
if (member !== void 0) {
|
|
739
|
+
const own = { async: false, ...ctx.jitless === void 0 ? {} : { jitless: ctx.jitless } };
|
|
740
|
+
quick.add(own);
|
|
741
|
+
const tried = member._zod.run({ value: payload.value, issues: [] }, own);
|
|
742
|
+
if (!(tried instanceof Promise) && tried.issues.length === 0) return tried;
|
|
743
|
+
}
|
|
744
|
+
walking.add(ctx);
|
|
745
|
+
try {
|
|
746
|
+
return walk(payload, ctx);
|
|
747
|
+
} finally {
|
|
748
|
+
walking.delete(ctx);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
});
|
|
505
752
|
var NodeSchema = z.lazy(
|
|
506
|
-
() =>
|
|
753
|
+
() => new NodeUnion({ type: "union", options: [
|
|
507
754
|
// Core
|
|
508
755
|
RefNodeSchema,
|
|
509
756
|
ConstNodeSchema,
|
|
@@ -523,7 +770,9 @@ var NodeSchema = z.lazy(
|
|
|
523
770
|
SubNodeSchema,
|
|
524
771
|
MulNodeSchema,
|
|
525
772
|
DivNodeSchema,
|
|
773
|
+
ModNodeSchema,
|
|
526
774
|
RoundNodeSchema,
|
|
775
|
+
ToNumberNodeSchema,
|
|
527
776
|
// String
|
|
528
777
|
FillNodeSchema,
|
|
529
778
|
JoinNodeSchema,
|
|
@@ -592,16 +841,10 @@ var NodeSchema = z.lazy(
|
|
|
592
841
|
// Primitives
|
|
593
842
|
JsonPrimitiveSchema,
|
|
594
843
|
// Arrays of nodes
|
|
595
|
-
|
|
844
|
+
NodeArraySchema,
|
|
596
845
|
// Plain objects (no `$` keys, recursive values)
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
// zod then reports its complaint instead of the union's — so a typo inside
|
|
600
|
-
// a real op (`{ $get: { pathh } }`) read as "plain object must not contain
|
|
601
|
-
// $ op keys" at the root. As a key pattern it is also plain JSON Schema
|
|
602
|
-
// (`propertyNames`), which the grammar snapshot and agent prompts read.
|
|
603
|
-
z.record(z.string().regex(TEMPLATE_KEY, { error: (issue) => templateKeyRefusal(issue.input) }), z.lazy(() => NodeSchema)).refine((o) => hasValidOptionalMeta(o), { message: "__optional must be an array of non-empty field name strings." })
|
|
604
|
-
]).describe("A Prism node: an op, a plain JSON value, an array of nodes, or a plain object template.")
|
|
846
|
+
TemplateSchema
|
|
847
|
+
] }).describe("A Prism node: an op, a plain JSON value, an array of nodes, or a plain object template.")
|
|
605
848
|
);
|
|
606
849
|
setNodeSchema(NodeSchema);
|
|
607
850
|
setNodeSchema2(NodeSchema);
|
|
@@ -619,85 +862,6 @@ var ConfigSchema = NodeSchema.describe(
|
|
|
619
862
|
"A Prism config: the top-level transformation definition. Can be any valid node."
|
|
620
863
|
);
|
|
621
864
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
var isJsonArray = (value) => Array.isArray(value);
|
|
626
|
-
var isRefNode = (v) => hasKey(v, "$ref");
|
|
627
|
-
var isConstNode = (v) => hasKey(v, "$const");
|
|
628
|
-
var isVarNode = (v) => hasKey(v, "$var");
|
|
629
|
-
var isGetNode = (v) => hasKey(v, "$get");
|
|
630
|
-
var isWithNode = (v) => hasKey(v, "$with");
|
|
631
|
-
var isMapNode = (v) => hasKey(v, "$map");
|
|
632
|
-
var isFilterNode = (v) => hasKey(v, "$filter");
|
|
633
|
-
var isReduceNode = (v) => hasKey(v, "$reduce");
|
|
634
|
-
var isSliceNode = (v) => hasKey(v, "$slice");
|
|
635
|
-
var isFlattenNode = (v) => hasKey(v, "$flatten");
|
|
636
|
-
var isUniqueNode = (v) => hasKey(v, "$unique");
|
|
637
|
-
var isSortByNode = (v) => hasKey(v, "$sortBy");
|
|
638
|
-
var isAddNode = (v) => hasKey(v, "$add");
|
|
639
|
-
var isSubNode = (v) => hasKey(v, "$sub");
|
|
640
|
-
var isMulNode = (v) => hasKey(v, "$mul");
|
|
641
|
-
var isDivNode = (v) => hasKey(v, "$div");
|
|
642
|
-
var isRoundNode = (v) => hasKey(v, "$round");
|
|
643
|
-
var isJoinNode = (v) => hasKey(v, "$join");
|
|
644
|
-
var isToStringNode = (v) => hasKey(v, "$toString");
|
|
645
|
-
var isInterpolateNode = (v) => hasKey(v, "$interpolate");
|
|
646
|
-
var isFillNode = (v) => hasKey(v, "$fill");
|
|
647
|
-
var isTrimNode = (v) => hasKey(v, "$trim");
|
|
648
|
-
var isLowerNode = (v) => hasKey(v, "$lower");
|
|
649
|
-
var isUpperNode = (v) => hasKey(v, "$upper");
|
|
650
|
-
var isSplitNode = (v) => hasKey(v, "$split");
|
|
651
|
-
var isReplaceNode = (v) => hasKey(v, "$replace");
|
|
652
|
-
var isEqNode = (v) => hasKey(v, "$eq");
|
|
653
|
-
var isNeqNode = (v) => hasKey(v, "$neq");
|
|
654
|
-
var isGtNode = (v) => hasKey(v, "$gt");
|
|
655
|
-
var isGteNode = (v) => hasKey(v, "$gte");
|
|
656
|
-
var isLtNode = (v) => hasKey(v, "$lt");
|
|
657
|
-
var isLteNode = (v) => hasKey(v, "$lte");
|
|
658
|
-
var isEmptyNode = (v) => hasKey(v, "$empty");
|
|
659
|
-
var isStartsWithNode = (v) => hasKey(v, "$startsWith");
|
|
660
|
-
var isEndsWithNode = (v) => hasKey(v, "$endsWith");
|
|
661
|
-
var isContainsNode = (v) => hasKey(v, "$contains");
|
|
662
|
-
var isNotNode = (v) => hasKey(v, "$not");
|
|
663
|
-
var isAndNode = (v) => hasKey(v, "$and");
|
|
664
|
-
var isOrNode = (v) => hasKey(v, "$or");
|
|
665
|
-
var isMergeNode = (v) => hasKey(v, "$merge");
|
|
666
|
-
var isCoalesceNode = (v) => hasKey(v, "$coalesce");
|
|
667
|
-
var isCaseNode = (v) => hasKey(v, "$case");
|
|
668
|
-
var isEntriesOfNode = (v) => hasKey(v, "$entriesOf");
|
|
669
|
-
var isKeyByNode = (v) => hasKey(v, "$keyBy");
|
|
670
|
-
var isGroupByNode = (v) => hasKey(v, "$groupBy");
|
|
671
|
-
var isKeysNode = (v) => hasKey(v, "$keys");
|
|
672
|
-
var isValuesNode = (v) => hasKey(v, "$values");
|
|
673
|
-
var isFromEntriesNode = (v) => hasKey(v, "$fromEntries");
|
|
674
|
-
var isPickNode = (v) => hasKey(v, "$pick");
|
|
675
|
-
var isOmitNode = (v) => hasKey(v, "$omit");
|
|
676
|
-
var isHasNode = (v) => hasKey(v, "$has");
|
|
677
|
-
var isRenameKeysNode = (v) => hasKey(v, "$renameKeys");
|
|
678
|
-
var isUpdateNode = (v) => hasKey(v, "$update");
|
|
679
|
-
var isAssertNode = (v) => hasKey(v, "$assert");
|
|
680
|
-
var isWalkNode = (v) => hasKey(v, "$walk");
|
|
681
|
-
var isTypeNode = (v) => hasKey(v, "$type");
|
|
682
|
-
var isLengthNode = (v) => hasKey(v, "$length");
|
|
683
|
-
var isDateNode = (v) => hasKey(v, "$date");
|
|
684
|
-
var isDateAddNode = (v) => hasKey(v, "$dateAdd");
|
|
685
|
-
var isDateDiffNode = (v) => hasKey(v, "$dateDiff");
|
|
686
|
-
var isLocaleDateNode = (v) => hasKey(v, "$localeDate");
|
|
687
|
-
var isLocaleMoneyNode = (v) => hasKey(v, "$localeMoney");
|
|
688
|
-
var isLocaleNumberNode = (v) => hasKey(v, "$localeNumber");
|
|
689
|
-
var isSumNode = (v) => hasKey(v, "$sum");
|
|
690
|
-
var isAvgNode = (v) => hasKey(v, "$avg");
|
|
691
|
-
var isCountNode = (v) => hasKey(v, "$count");
|
|
692
|
-
var isMinNode = (v) => hasKey(v, "$min");
|
|
693
|
-
var isMaxNode = (v) => hasKey(v, "$max");
|
|
694
|
-
var isPluckNode = (v) => hasKey(v, "$pluck");
|
|
695
|
-
var isTakeNode = (v) => hasKey(v, "$take");
|
|
696
|
-
var isDropNode = (v) => hasKey(v, "$drop");
|
|
697
|
-
var isMatchNode = (v) => hasKey(v, "$match");
|
|
698
|
-
var isFlatMapNode = (v) => hasKey(v, "$flatMap");
|
|
699
|
-
var isPlainObject = (value) => isJsonObject(value) && !Object.keys(value).some((k) => k.startsWith("$"));
|
|
700
|
-
|
|
701
|
-
export { ConfigSchema, NodeSchema, OPTIONAL_FIELDS_KEY, OP_KEYS, isAddNode, isAndNode, isAssertNode, isAvgNode, isCaseNode, isCoalesceNode, isConstNode, isContainsNode, isCountNode, isDateAddNode, isDateDiffNode, isDateNode, isDivNode, isDropNode, isEmptyNode, isEndsWithNode, isEntriesOfNode, isEqNode, isFillNode, isFilterNode, isFlatMapNode, isFlattenNode, isFromEntriesNode, isGetNode, isGroupByNode, isGtNode, isGteNode, isHasNode, isInterpolateNode, isJoinNode, isJsonArray, isJsonObject, isKeyByNode, isKeysNode, isLengthNode, isLocaleDateNode, isLocaleMoneyNode, isLocaleNumberNode, isLowerNode, isLtNode, isLteNode, isMapNode, isMatchNode, isMaxNode, isMergeNode, isMinNode, isMulNode, isNeqNode, isNotNode, isOmitNode, isOrNode, isPickNode, isPlainObject, isPluckNode, isReduceNode, isRefNode, isRenameKeysNode, isReplaceNode, isRoundNode, isSliceNode, isSortByNode, isSplitNode, isStartsWithNode, isSubNode, isSumNode, isTakeNode, isToStringNode, isTrimNode, isTypeNode, isUniqueNode, isUpdateNode, isUpperNode, isValuesNode, isVarNode, isWalkNode, isWithNode };
|
|
702
|
-
//# sourceMappingURL=chunk-O3OJAQWA.js.map
|
|
703
|
-
//# sourceMappingURL=chunk-O3OJAQWA.js.map
|
|
865
|
+
export { ConfigSchema, ErrorCode, NodeSchema, OPTIONAL_FIELDS_KEY, OP_KEYS, PrismError, getByPath, isAddNode, isAndNode, isAssertNode, isAvgNode, isCaseNode, isCoalesceNode, isConstNode, isContainsNode, isCountNode, isDateAddNode, isDateDiffNode, isDateNode, isDivNode, isDropNode, isEmptyNode, isEndsWithNode, isEntriesOfNode, isEqNode, isFillNode, isFilterNode, isFlatMapNode, isFlattenNode, isFromEntriesNode, isGetNode, isGroupByNode, isGtNode, isGteNode, isHasNode, isInterpolateNode, isJoinNode, isJsonArray, isJsonObject, isKeyByNode, isKeysNode, isLengthNode, isLocaleDateNode, isLocaleMoneyNode, isLocaleNumberNode, isLowerNode, isLtNode, isLteNode, isMapNode, isMatchNode, isMaxNode, isMergeNode, isMinNode, isModNode, isMulNode, isNeqNode, isNotNode, isOmitNode, isOrNode, isPickNode, isPlainObject, isPluckNode, isReduceNode, isRefNode, isRenameKeysNode, isReplaceNode, isRoundNode, isSliceNode, isSortByNode, isSplitNode, isStartsWithNode, isSubNode, isSumNode, isTakeNode, isToNumberNode, isToStringNode, isTrimNode, isTypeNode, isUniqueNode, isUpdateNode, isUpperNode, isValuesNode, isVarNode, isWalkNode, isWithNode, parseJsonPath, parseJsonPathCached };
|
|
866
|
+
//# sourceMappingURL=chunk-7VMFSXBM.js.map
|
|
867
|
+
//# sourceMappingURL=chunk-7VMFSXBM.js.map
|