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