@niscorp/prism 0.2.1 → 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.
Files changed (42) hide show
  1. package/CHANGELOG.md +200 -0
  2. package/DESIGN.md +9 -8
  3. package/DOCS.md +68 -25
  4. package/README.md +35 -22
  5. package/dist/agent.cjs +4 -756
  6. package/dist/agent.cjs.map +1 -1
  7. package/dist/agent.js +2 -2
  8. package/dist/chunk-66YSI4PX.cjs +955 -0
  9. package/dist/chunk-66YSI4PX.cjs.map +1 -0
  10. package/dist/{chunk-O3OJAQWA.js → chunk-7VMFSXBM.js} +262 -98
  11. package/dist/chunk-7VMFSXBM.js.map +1 -0
  12. package/dist/{chunk-XRK55NPE.js → chunk-BKXCULZV.js} +5 -3
  13. package/dist/chunk-BKXCULZV.js.map +1 -0
  14. package/dist/chunk-OLZQK2ZF.cjs +149 -0
  15. package/dist/chunk-OLZQK2ZF.cjs.map +1 -0
  16. package/dist/examples/index.cjs +25 -2
  17. package/dist/examples/index.cjs.map +1 -1
  18. package/dist/examples/index.d.cts +1 -1
  19. package/dist/examples/index.d.ts +1 -1
  20. package/dist/examples/index.js +25 -2
  21. package/dist/examples/index.js.map +1 -1
  22. package/dist/index.cjs +694 -1484
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +9 -6
  25. package/dist/index.d.ts +9 -6
  26. package/dist/index.js +1120 -26
  27. package/dist/index.js.map +1 -1
  28. package/dist/migrations/index.cjs +15 -1777
  29. package/dist/migrations/index.cjs.map +1 -1
  30. package/dist/migrations/index.d.cts +0 -2
  31. package/dist/migrations/index.d.ts +0 -2
  32. package/dist/migrations/index.js +14 -2
  33. package/dist/migrations/index.js.map +1 -1
  34. package/dist/{profiles-C6r-x-Vj.d.cts → profiles-CPVfysxC.d.cts} +2 -1
  35. package/dist/{profiles-C6r-x-Vj.d.ts → profiles-CPVfysxC.d.ts} +2 -1
  36. package/package.json +4 -4
  37. package/dist/chunk-O3OJAQWA.js.map +0 -1
  38. package/dist/chunk-VC4PRB4H.js +0 -1086
  39. package/dist/chunk-VC4PRB4H.js.map +0 -1
  40. package/dist/chunk-XRK55NPE.js.map +0 -1
  41. package/dist/transform-DcVcOBzQ.d.cts +0 -3
  42. package/dist/transform-DcVcOBzQ.d.ts +0 -3
@@ -0,0 +1,955 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
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
+ };
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");
30
+ var JsonValueSchema = zod.z.lazy(
31
+ () => zod.z.union([JsonPrimitiveSchema, zod.z.array(JsonValueSchema), zod.z.record(zod.z.string(), JsonValueSchema)])
32
+ ).describe("Any JSON value: primitive, array, or object");
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
193
+ var _NodeSchema = zod.z.any();
194
+ var setNodeSchema = (schema) => {
195
+ _NodeSchema = schema;
196
+ };
197
+ var node = () => _NodeSchema;
198
+ var RefNodeSchema = zod.z.object({
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.')
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.");
201
+ var ConstNodeSchema = zod.z.object({
202
+ $const: JsonValueSchema.describe("Any JSON value to return as-is.")
203
+ }).strict().describe("Return a literal JSON value unchanged.");
204
+ var VarNodeSchema = zod.z.object({
205
+ $var: zod.z.string().min(1).describe("Variable name bound by $with, $map, $filter, $reduce, or $sortBy.")
206
+ }).strict().describe("Read a scoped variable by name. Variables are created by $with (let bindings), $map/$filter/$reduce/$sortBy (loop element). Returns the whole variable \u2014 use $get to navigate into it.");
207
+ var GetNodeSchema = zod.z.object({
208
+ $get: zod.z.object({
209
+ from: zod.z.lazy(node).describe("Source value to navigate into."),
210
+ path: zod.z.array(zod.z.union([zod.z.string(), zod.z.number(), zod.z.lazy(node)])).min(1).describe("Path segments: string keys, numeric indices, or node expressions."),
211
+ fallback: zod.z.lazy(node).optional().describe("Fallback value when path is missing.")
212
+ }).strict()
213
+ }).strict().describe('Navigate into a value by path. Use to access fields on variables: {$get: {from: {$var: "item"}, path: ["name"]}}. Also supports dynamic path segments (nodes as segments) and fallback values. Prefer $ref for simple source access.');
214
+ var WithNodeSchema = zod.z.object({
215
+ $with: zod.z.object({
216
+ let: zod.z.record(zod.z.string(), zod.z.lazy(node)).describe("Variable bindings: name \u2192 expression evaluated in current scope."),
217
+ value: zod.z.lazy(node).describe("Expression evaluated with the declared variables in scope.")
218
+ }).strict()
219
+ }).strict().describe("Bind variables in a scoped block: { $with: { let: { x: ... }, value: ... } }");
220
+ var _NodeSchema2 = zod.z.any();
221
+ var setNodeSchema2 = (schema) => {
222
+ _NodeSchema2 = schema;
223
+ };
224
+ var node2 = () => _NodeSchema2;
225
+ var MapNodeSchema = zod.z.object({
226
+ $map: zod.z.object({
227
+ over: zod.z.lazy(node2).describe("Array to iterate over."),
228
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
229
+ body: zod.z.lazy(node2).describe("Expression evaluated for each element.")
230
+ }).strict()
231
+ }).strict().describe("Map over an array, transforming each element.");
232
+ var FilterNodeSchema = zod.z.object({
233
+ $filter: zod.z.object({
234
+ over: zod.z.lazy(node2).describe("Array to filter."),
235
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
236
+ when: zod.z.lazy(node2).describe("Condition \u2014 keeps element when truthy.")
237
+ }).strict()
238
+ }).strict().describe("Filter an array, keeping elements where condition is truthy.");
239
+ var ReduceNodeSchema = zod.z.object({
240
+ $reduce: zod.z.object({
241
+ over: zod.z.lazy(node2).describe("Array to reduce."),
242
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
243
+ acc: zod.z.string().min(1).optional().default("acc").describe('Accumulator variable name. Default: "acc".'),
244
+ init: zod.z.lazy(node2).describe("Initial accumulator value."),
245
+ body: zod.z.lazy(node2).describe("Expression evaluated for each element with both element and accumulator in scope.")
246
+ }).strict()
247
+ }).strict().describe("Reduce an array to a single value using an accumulator.");
248
+ var SliceNodeSchema = zod.z.object({
249
+ $slice: zod.z.object({
250
+ from: zod.z.lazy(node2).describe("Array or string to slice."),
251
+ start: zod.z.number().int().optional().describe("Start index (inclusive). Default: 0."),
252
+ end: zod.z.number().int().optional().describe("End index (exclusive). Default: length.")
253
+ }).strict()
254
+ }).strict().describe("Slice an array or string by start/end indices.");
255
+ var FlattenNodeSchema = zod.z.object({
256
+ $flatten: zod.z.lazy(node2).describe("Array of arrays to flatten one level.")
257
+ }).strict().describe("Flatten a nested array by one level.");
258
+ var UniqueNodeSchema = zod.z.object({
259
+ $unique: zod.z.lazy(node2).describe("Array to deduplicate.")
260
+ }).strict().describe("Remove duplicate values from an array (compared by JSON.stringify).");
261
+ var SortByNodeSchema = zod.z.object({
262
+ $sortBy: zod.z.object({
263
+ over: zod.z.lazy(node2).describe("Array to sort."),
264
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
265
+ by: zod.z.lazy(node2).describe("Expression to compute the sort key."),
266
+ dir: zod.z.enum(["asc", "desc"]).optional().default("asc").describe('Sort direction. Default: "asc".')
267
+ }).strict()
268
+ }).strict().describe("Sort an array by a computed key.");
269
+ var _NodeSchema3 = zod.z.any();
270
+ var setNodeSchema3 = (schema) => {
271
+ _NodeSchema3 = schema;
272
+ };
273
+ var node3 = () => _NodeSchema3;
274
+ var pairOf = (desc) => zod.z.tuple([zod.z.lazy(node3), zod.z.lazy(node3)]).describe(desc);
275
+ var AddNodeSchema = zod.z.object({ $add: pairOf("Two numeric operands to add.") }).strict().describe("Add two numbers.");
276
+ var SubNodeSchema = zod.z.object({ $sub: pairOf("Two numeric operands to subtract (a - b).") }).strict().describe("Subtract second number from first.");
277
+ var MulNodeSchema = zod.z.object({ $mul: pairOf("Two numeric operands to multiply.") }).strict().describe("Multiply two numbers.");
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.");
280
+ var RoundNodeSchema = zod.z.object({
281
+ $round: zod.z.object({
282
+ value: zod.z.lazy(node3).describe("Numeric value to round."),
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).')
285
+ }).strict()
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.");
293
+ var _NodeSchema4 = zod.z.any();
294
+ var setNodeSchema4 = (schema) => {
295
+ _NodeSchema4 = schema;
296
+ };
297
+ var node4 = () => _NodeSchema4;
298
+ var JoinNodeSchema = zod.z.object({
299
+ $join: zod.z.object({
300
+ parts: zod.z.lazy(node4).describe("Values to concatenate (coerced to string): a literal list of nodes, or any node that evaluates to an array \u2014 a mapped list, a $var."),
301
+ sep: zod.z.string().optional().default("").describe('Separator between parts. Default: "".')
302
+ }).strict()
303
+ }).strict().describe("Concatenate values into a string with an optional separator.");
304
+ var ToStringNodeSchema = zod.z.object({ $toString: zod.z.lazy(node4).describe("Value to stringify via String().") }).strict().describe("Convert a value to its string representation.");
305
+ var InterpolateNodeSchema = zod.z.object({
306
+ $interpolate: zod.z.object({
307
+ template: zod.z.string().describe("Template with {{key}} placeholders."),
308
+ values: zod.z.lazy(node4).describe("Object whose keys replace {{key}} placeholders.")
309
+ }).strict()
310
+ }).strict().describe("Replace {{key}} placeholders in a template with values from an object.");
311
+ var FillNodeSchema = zod.z.object({
312
+ $fill: zod.z.lazy(node4).describe("A pattern value `{ phrase, slots }` \u2014 filled with its own slots, source language. Non-patterns pass through.")
313
+ }).strict().describe('Fill a counted phrase: `{ phrase: "{n} of {total}", slots: { n: 1, total: 12 } }` \u2192 "1 of 12".');
314
+ var TrimNodeSchema = zod.z.object({ $trim: zod.z.lazy(node4).describe("String to trim whitespace from.") }).strict().describe("Trim leading and trailing whitespace from a string.");
315
+ var LowerNodeSchema = zod.z.object({ $lower: zod.z.lazy(node4).describe("String to lowercase.") }).strict().describe("Convert a string to lowercase.");
316
+ var UpperNodeSchema = zod.z.object({ $upper: zod.z.lazy(node4).describe("String to uppercase.") }).strict().describe("Convert a string to uppercase.");
317
+ var SplitNodeSchema = zod.z.object({
318
+ $split: zod.z.object({
319
+ value: zod.z.lazy(node4).describe("String to split."),
320
+ sep: zod.z.string().describe("Separator to split on.")
321
+ }).strict()
322
+ }).strict().describe("Split a string into an array by separator.");
323
+ var ReplaceNodeSchema = zod.z.object({
324
+ $replace: zod.z.object({
325
+ value: zod.z.lazy(node4).describe("String to search in."),
326
+ search: zod.z.string().describe("Substring to find."),
327
+ replacement: zod.z.string().describe("Replacement string."),
328
+ all: zod.z.boolean().optional().describe("true replaces every occurrence. Default: only the first.")
329
+ }).strict()
330
+ }).strict().describe("Replace the first occurrence of a substring, or every occurrence with `all: true`.");
331
+ var _NodeSchema5 = zod.z.any();
332
+ var setNodeSchema5 = (schema) => {
333
+ _NodeSchema5 = schema;
334
+ };
335
+ var node5 = () => _NodeSchema5;
336
+ var pairOf2 = (desc) => zod.z.tuple([zod.z.lazy(node5), zod.z.lazy(node5)]).describe(desc);
337
+ var EqNodeSchema = zod.z.object({ $eq: pairOf2("Two values to compare for deep equality.") }).strict().describe("Deep equality comparison (JSON.stringify-based). Returns true or false.");
338
+ var NeqNodeSchema = zod.z.object({ $neq: pairOf2("Two values to compare for inequality.") }).strict().describe("Deep inequality comparison. Returns true or false.");
339
+ var GtNodeSchema = zod.z.object({ $gt: pairOf2("Two values: returns true if first > second (numbers or strings).") }).strict().describe("Greater than comparison for numbers or strings.");
340
+ var GteNodeSchema = zod.z.object({ $gte: pairOf2("Two values: returns true if first >= second.") }).strict().describe("Greater than or equal comparison.");
341
+ var LtNodeSchema = zod.z.object({ $lt: pairOf2("Two values: returns true if first < second.") }).strict().describe("Less than comparison.");
342
+ var LteNodeSchema = zod.z.object({ $lte: pairOf2("Two values: returns true if first <= second.") }).strict().describe("Less than or equal comparison.");
343
+ var EmptyNodeSchema = zod.z.object({ $empty: zod.z.lazy(node5).describe('Value to check for emptiness (null, "", [], {}).') }).strict().describe("Returns true if value is null, empty string, empty array, or empty object.");
344
+ var StartsWithNodeSchema = zod.z.object({
345
+ $startsWith: zod.z.object({
346
+ value: zod.z.lazy(node5).describe("String to check."),
347
+ prefix: zod.z.lazy(node5).describe("Expected prefix.")
348
+ }).strict()
349
+ }).strict().describe("Returns true if string starts with prefix.");
350
+ var EndsWithNodeSchema = zod.z.object({
351
+ $endsWith: zod.z.object({
352
+ value: zod.z.lazy(node5).describe("String to check."),
353
+ suffix: zod.z.lazy(node5).describe("Expected suffix.")
354
+ }).strict()
355
+ }).strict().describe("Returns true if string ends with suffix.");
356
+ var ContainsNodeSchema = zod.z.object({
357
+ $contains: zod.z.object({
358
+ value: zod.z.lazy(node5).describe("String to search in."),
359
+ search: zod.z.lazy(node5).describe("Substring to find.")
360
+ }).strict()
361
+ }).strict().describe("Returns true if string contains the search substring.");
362
+ var _NodeSchema6 = zod.z.any();
363
+ var setNodeSchema6 = (schema) => {
364
+ _NodeSchema6 = schema;
365
+ };
366
+ var node6 = () => _NodeSchema6;
367
+ var NotNodeSchema = zod.z.object({ $not: zod.z.lazy(node6).describe("Value to negate (truthy \u2192 false, falsy \u2192 true).") }).strict().describe("Boolean negation of a truthy/falsy value.");
368
+ var AndNodeSchema = zod.z.object({
369
+ $and: zod.z.array(zod.z.lazy(node6)).min(1).describe("Values to AND. Short-circuits: returns last truthy or first falsy.")
370
+ }).strict().describe("Short-circuit logical AND.");
371
+ var OrNodeSchema = zod.z.object({
372
+ $or: zod.z.array(zod.z.lazy(node6)).min(1).describe("Values to OR. Short-circuits: returns first truthy or last falsy.")
373
+ }).strict().describe("Short-circuit logical OR.");
374
+ var _NodeSchema7 = zod.z.any();
375
+ var setNodeSchema7 = (schema) => {
376
+ _NodeSchema7 = schema;
377
+ };
378
+ var node7 = () => _NodeSchema7;
379
+ var MergeNodeSchema = zod.z.object({
380
+ $merge: zod.z.array(zod.z.lazy(node7)).min(1).describe("Objects to shallow-merge (left to right, later wins).")
381
+ }).strict().describe("Shallow merge multiple objects. Later values overwrite earlier ones.");
382
+ var CoalesceNodeSchema = zod.z.object({
383
+ $coalesce: zod.z.array(zod.z.lazy(node7)).min(1).describe("Values to try in order. Returns first non-null/non-undefined.")
384
+ }).strict().describe("Return the first non-null, non-undefined value.");
385
+ var CaseNodeSchema = zod.z.object({
386
+ $case: zod.z.object({
387
+ branches: zod.z.array(
388
+ zod.z.object({
389
+ when: zod.z.lazy(node7).describe("Condition to evaluate."),
390
+ then: zod.z.lazy(node7).describe("Value to return if condition is truthy.")
391
+ }).strict()
392
+ ).min(1).describe("Ordered list of when/then branches."),
393
+ else: zod.z.lazy(node7).optional().describe("Fallback value if no branch matches. Default: null.")
394
+ }).strict()
395
+ }).strict().describe("Conditional branching: evaluates branches in order, returns first match or else.");
396
+ var EntriesOfNodeSchema = zod.z.object({ $entriesOf: zod.z.lazy(node7).describe("Object to convert to [key, value][] entries.") }).strict().describe("Convert an object to an array of [key, value] pairs.");
397
+ var KeyByNodeSchema = zod.z.object({
398
+ $keyBy: zod.z.object({
399
+ over: zod.z.lazy(node7).describe("Array to group."),
400
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
401
+ key: zod.z.lazy(node7).describe("Expression to compute the key (last wins on collision).")
402
+ }).strict()
403
+ }).strict().describe("Convert an array to an object keyed by a computed value. Last element wins on key collision.");
404
+ var GroupByNodeSchema = zod.z.object({
405
+ $groupBy: zod.z.object({
406
+ over: zod.z.lazy(node7).describe("Array to group."),
407
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
408
+ key: zod.z.lazy(node7).describe("Expression to compute the group key.")
409
+ }).strict()
410
+ }).strict().describe("Group array elements into an object of arrays by computed key.");
411
+ var _NodeSchema8 = zod.z.any();
412
+ var setNodeSchema8 = (schema) => {
413
+ _NodeSchema8 = schema;
414
+ };
415
+ var node8 = () => _NodeSchema8;
416
+ var KeysNodeSchema = zod.z.object({ $keys: zod.z.lazy(node8).describe("Object to extract keys from.") }).strict().describe("Return the keys of an object as a string array.");
417
+ var ValuesNodeSchema = zod.z.object({ $values: zod.z.lazy(node8).describe("Object to extract values from.") }).strict().describe("Return the values of an object as an array.");
418
+ var FromEntriesNodeSchema = zod.z.object({
419
+ $fromEntries: zod.z.lazy(node8).describe("Array of [key, value] pairs to convert to an object.")
420
+ }).strict().describe("Convert [key, value][] entries into an object.");
421
+ var PickNodeSchema = zod.z.object({
422
+ $pick: zod.z.object({
423
+ from: zod.z.lazy(node8).describe("Source object."),
424
+ keys: zod.z.array(zod.z.string()).min(1).describe("Keys to keep.")
425
+ }).strict()
426
+ }).strict().describe("Pick specific keys from an object, discarding the rest.");
427
+ var OmitNodeSchema = zod.z.object({
428
+ $omit: zod.z.object({
429
+ from: zod.z.lazy(node8).describe("Source object."),
430
+ keys: zod.z.array(zod.z.string()).min(1).describe("Keys to remove.")
431
+ }).strict()
432
+ }).strict().describe("Remove specific keys from an object, keeping the rest.");
433
+ var TypeNodeSchema = zod.z.object({ $type: zod.z.lazy(node8).describe("Value to get the type of.") }).strict().describe('Returns the type as a string: "string", "number", "boolean", "null", "array", or "object".');
434
+ var LengthNodeSchema = zod.z.object({ $length: zod.z.lazy(node8).describe("Array or string to measure.") }).strict().describe("Return the length of an array or string.");
435
+ var _NodeSchema9 = zod.z.any();
436
+ var setNodeSchema9 = (schema) => {
437
+ _NodeSchema9 = schema;
438
+ };
439
+ var node9 = () => _NodeSchema9;
440
+ var TimeUnit = zod.z.enum(["year", "month", "day", "hour", "minute", "second"]).describe("Time unit for date arithmetic.");
441
+ var DateNodeSchema = zod.z.object({
442
+ $date: zod.z.object({
443
+ value: zod.z.lazy(node9).describe("Date value (ISO string or timestamp)."),
444
+ format: zod.z.string().optional().describe("Output format string (dayjs format). Default: ISO 8601."),
445
+ utc: zod.z.boolean().optional().default(false).describe("Format in UTC. Default: false.")
446
+ }).strict()
447
+ }).strict().describe("Format a date value.");
448
+ var DateAddNodeSchema = zod.z.object({
449
+ $dateAdd: zod.z.object({
450
+ date: zod.z.lazy(node9).describe("Base date (ISO string or timestamp)."),
451
+ amount: zod.z.number().describe("Amount to add (can be negative)."),
452
+ unit: TimeUnit
453
+ }).strict()
454
+ }).strict().describe("Add a duration to a date. Returns ISO string.");
455
+ var DateDiffNodeSchema = zod.z.object({
456
+ $dateDiff: zod.z.object({
457
+ from: zod.z.lazy(node9).describe("Start date."),
458
+ to: zod.z.lazy(node9).describe("End date."),
459
+ unit: TimeUnit
460
+ }).strict()
461
+ }).strict().describe("Calculate difference between two dates. Returns a number.");
462
+ var _NodeSchema10 = zod.z.any();
463
+ var setNodeSchema10 = (schema) => {
464
+ _NodeSchema10 = schema;
465
+ };
466
+ var node10 = () => _NodeSchema10;
467
+ var localeField = zod.z.lazy(node10).describe('BCP-47 locale tag ("de-AT", "en-GB"). Required \u2014 a default renders plausible nonsense for everybody it is wrong for.');
468
+ var fallbackField = zod.z.lazy(node10).optional().describe('Rendered when the value is null/undefined/empty. Default: "".');
469
+ var DateStyle = zod.z.enum(["full", "long", "medium", "short"]);
470
+ var IntlDateOptionsSchema = zod.z.object({
471
+ dateStyle: DateStyle.optional().describe("Whole-date preset. Mutually exclusive with the field-by-field options below."),
472
+ timeStyle: DateStyle.optional().describe("Whole-time preset. Mutually exclusive with the field-by-field options below."),
473
+ weekday: zod.z.enum(["long", "short", "narrow"]).optional(),
474
+ year: zod.z.enum(["numeric", "2-digit"]).optional(),
475
+ month: zod.z.enum(["numeric", "2-digit", "long", "short", "narrow"]).optional(),
476
+ day: zod.z.enum(["numeric", "2-digit"]).optional(),
477
+ hour: zod.z.enum(["numeric", "2-digit"]).optional(),
478
+ minute: zod.z.enum(["numeric", "2-digit"]).optional(),
479
+ second: zod.z.enum(["numeric", "2-digit"]).optional(),
480
+ hour12: zod.z.boolean().optional().describe("Force 12/24-hour. Omit to take the locale's own convention \u2014 which is the point of asking for a locale."),
481
+ timeZone: zod.z.string().optional().describe('IANA zone. Omit and a DATE-only value ("2026-03-14") is read as UTC, which is what stops it rendering as the 13th west of Greenwich.')
482
+ }).strict();
483
+ var LocaleDateNodeSchema = zod.z.object({
484
+ $localeDate: zod.z.object({
485
+ value: zod.z.lazy(node10).describe("ISO string, DATE-only string, or epoch milliseconds."),
486
+ locale: localeField,
487
+ options: IntlDateOptionsSchema.optional().describe('Defaults to { dateStyle: "medium" }.'),
488
+ fallback: fallbackField
489
+ }).strict()
490
+ }).strict().describe("Format a date for a human reading in a given locale (Intl.DateTimeFormat).");
491
+ var LocaleMoneyNodeSchema = zod.z.object({
492
+ $localeMoney: zod.z.object({
493
+ value: zod.z.lazy(node10).describe("The amount. Minor units (cents) unless `minorUnits` is false."),
494
+ currency: zod.z.lazy(node10).describe('ISO-4217 code \u2014 "EUR", "CHF". Required: an amount without one is a number, not money.'),
495
+ locale: localeField,
496
+ minorUnits: zod.z.boolean().optional().describe(
497
+ "Value is in the currency's minor unit. Default true. The divisor comes from the CURRENCY, not a hardcoded 100 \u2014 JPY has no minor unit and dividing it would be a hundredfold error."
498
+ ),
499
+ digits: zod.z.number().int().min(0).max(20).optional().describe("Fraction digits. Default: the currency's own (2 for EUR, 0 for JPY)."),
500
+ fallback: fallbackField
501
+ }).strict()
502
+ }).strict().describe("Format an amount as money in a given locale (Intl.NumberFormat, style currency).");
503
+ var LocaleNumberNodeSchema = zod.z.object({
504
+ $localeNumber: zod.z.object({
505
+ value: zod.z.lazy(node10).describe("The number to format."),
506
+ locale: localeField,
507
+ style: zod.z.enum(["decimal", "percent"]).optional().describe('Default "decimal". "percent" multiplies by 100 \u2014 pass 0.42, not 42.'),
508
+ digits: zod.z.number().int().min(0).max(20).optional().describe("Maximum fraction digits. Default: the locale's own."),
509
+ minDigits: zod.z.number().int().min(0).max(20).optional().describe("Minimum fraction digits \u2014 for a column that should not ragged-edge."),
510
+ compact: zod.z.boolean().optional().describe('Short form \u2014 "1.2K", "1,2 Tsd.". For a headline figure, never for money owed.'),
511
+ fallback: fallbackField
512
+ }).strict()
513
+ }).strict().describe("Format a number in a given locale (Intl.NumberFormat).");
514
+ var _NodeSchema11 = zod.z.any();
515
+ var setNodeSchema11 = (schema) => {
516
+ _NodeSchema11 = schema;
517
+ };
518
+ var node11 = () => _NodeSchema11;
519
+ var overOnly = (desc) => zod.z.object({ over: zod.z.lazy(node11).describe(desc) }).strict();
520
+ var SumNodeSchema = zod.z.object({ $sum: overOnly("Array of numbers to sum.") }).strict().describe("Sugar: sum all elements in an array. Desugars to $reduce + $add.");
521
+ var AvgNodeSchema = zod.z.object({ $avg: overOnly("Array of numbers to average.") }).strict().describe("Sugar: average all elements in an array. Desugars to $div($sum, $count).");
522
+ var CountNodeSchema = zod.z.object({ $count: overOnly("Array to count elements of.") }).strict().describe("Sugar: count elements in an array. Desugars to $reduce.");
523
+ var MinNodeSchema = zod.z.object({ $min: overOnly("Array of numbers to find minimum.") }).strict().describe("Sugar: find minimum value in an array. Desugars to $reduce + $lt.");
524
+ var MaxNodeSchema = zod.z.object({ $max: overOnly("Array of numbers to find maximum.") }).strict().describe("Sugar: find maximum value in an array. Desugars to $reduce + $gt.");
525
+ var PluckNodeSchema = zod.z.object({
526
+ $pluck: zod.z.object({
527
+ over: zod.z.lazy(node11).describe("Array of objects to extract from."),
528
+ key: zod.z.string().min(1).describe("Key to extract from each object.")
529
+ }).strict()
530
+ }).strict().describe("Sugar: extract a single field from each element. Desugars to $map + $get.");
531
+ var TakeNodeSchema = zod.z.object({
532
+ $take: zod.z.object({
533
+ from: zod.z.lazy(node11).describe("Array to take from."),
534
+ count: zod.z.number().int().nonnegative().describe("Number of elements to take from the start.")
535
+ }).strict()
536
+ }).strict().describe("Sugar: take first N elements. Desugars to $slice.");
537
+ var DropNodeSchema = zod.z.object({
538
+ $drop: zod.z.object({
539
+ from: zod.z.lazy(node11).describe("Array to drop from."),
540
+ count: zod.z.number().int().nonnegative().describe("Number of elements to skip from the start.")
541
+ }).strict()
542
+ }).strict().describe("Sugar: skip first N elements. Desugars to $slice.");
543
+ var MatchNodeSchema = zod.z.object({
544
+ $match: zod.z.object({
545
+ over: zod.z.lazy(node11).describe("Array to search within."),
546
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
547
+ search: zod.z.lazy(node11).describe("String to search for (uses $contains).")
548
+ }).strict()
549
+ }).strict().describe("Sugar: filter array by string containment. Desugars to $filter + $contains.");
550
+ var FlatMapNodeSchema = zod.z.object({
551
+ $flatMap: zod.z.object({
552
+ over: zod.z.lazy(node11).describe("Array to flat-map over."),
553
+ as: zod.z.string().min(1).describe("Variable name for the current element."),
554
+ body: zod.z.lazy(node11).describe("Expression that returns an array for each element.")
555
+ }).strict()
556
+ }).strict().describe("Sugar: map then flatten one level. Desugars to $map + $flatten.");
557
+ var _NodeSchema12 = zod.z.any();
558
+ var setNodeSchema12 = (schema) => {
559
+ _NodeSchema12 = schema;
560
+ };
561
+ var node12 = () => _NodeSchema12;
562
+ var PathSchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number().int().nonnegative()])).min(1).describe("Literal path segments: object keys (strings) and array indexes (numbers).");
563
+ var HasNodeSchema = zod.z.object({
564
+ $has: zod.z.object({
565
+ from: zod.z.lazy(node12).describe("The value to look into."),
566
+ path: PathSchema
567
+ }).strict()
568
+ }).strict().describe("True when the whole path exists \u2014 a key present with a null value counts; a missing one does not.");
569
+ var RenameKeysNodeSchema = zod.z.object({
570
+ $renameKeys: zod.z.object({
571
+ from: zod.z.lazy(node12).describe("The object whose keys to rename."),
572
+ map: zod.z.record(zod.z.string(), zod.z.string()).describe("Old key \u2192 new key. Keys not listed, and listed keys that are absent, are left alone.")
573
+ }).strict()
574
+ }).strict().describe(
575
+ "The object with keys renamed IN PLACE \u2014 each renamed key keeps its position. If a new name is already a key of the object, that entry is replaced by the renamed one."
576
+ );
577
+ var UpdateNodeSchema = zod.z.object({
578
+ $update: zod.z.object({
579
+ from: zod.z.lazy(node12).describe("The value to copy with one path changed."),
580
+ path: PathSchema,
581
+ value: zod.z.lazy(node12).describe("The new value at `path`. The value currently there (null when absent) is bound as `$var` `as`."),
582
+ as: zod.z.string().min(1).optional().describe('The variable name the current value is bound to (default "current").')
583
+ }).strict()
584
+ }).strict().describe(
585
+ "A copy of `from` with the value at `path` replaced and everything else identical. Missing objects along a string path are created; an index that does not exist is an error."
586
+ );
587
+ var AssertNodeSchema = zod.z.object({
588
+ $assert: zod.z.object({
589
+ when: zod.z.lazy(node12).describe("Must be truthy."),
590
+ message: zod.z.string().min(1).describe("What went wrong, for a person \u2014 the whole error text."),
591
+ value: zod.z.lazy(node12).describe("Returned when `when` holds.")
592
+ }).strict()
593
+ }).strict().describe("Fail with `message` (E_ASSERT) unless `when` is truthy; otherwise evaluate to `value`. How a migration refuses a shape it cannot handle.");
594
+ var WalkNodeSchema = zod.z.object({
595
+ $walk: zod.z.object({
596
+ over: zod.z.lazy(node12).describe("The tree to rewrite \u2014 any JSON value."),
597
+ as: zod.z.string().min(1).describe("The variable each visited node is bound to."),
598
+ rules: zod.z.array(
599
+ zod.z.object({
600
+ when: zod.z.lazy(node12).describe("Evaluated with the node bound to `as`; the first truthy rule wins."),
601
+ then: zod.z.lazy(node12).describe("The node's replacement.")
602
+ }).strict()
603
+ ).min(1).describe("Tried in order at every node. No rule matches: the node is kept."),
604
+ order: zod.z.enum(["post", "pre"]).optional().describe(
605
+ "post (default): a node's children are rewritten first, and its rules see the rewritten children. pre: rules see the node as it was, then the walk descends into whatever they returned."
606
+ )
607
+ }).strict()
608
+ }).strict().describe(
609
+ "Rewrite every node of a tree \u2014 objects, arrays and leaves, at any depth \u2014 by rules. Structural: it always terminates, and a replacement is never walked again at its own level."
610
+ );
611
+
612
+ // src/schemas/node.schema.ts
613
+ var OP_KEYS = [
614
+ "$ref",
615
+ "$const",
616
+ "$var",
617
+ "$get",
618
+ "$with",
619
+ "$map",
620
+ "$filter",
621
+ "$reduce",
622
+ "$slice",
623
+ "$flatten",
624
+ "$unique",
625
+ "$sortBy",
626
+ "$add",
627
+ "$sub",
628
+ "$mul",
629
+ "$div",
630
+ "$mod",
631
+ "$round",
632
+ "$toNumber",
633
+ "$fill",
634
+ "$join",
635
+ "$toString",
636
+ "$interpolate",
637
+ "$trim",
638
+ "$lower",
639
+ "$upper",
640
+ "$split",
641
+ "$replace",
642
+ "$eq",
643
+ "$neq",
644
+ "$gt",
645
+ "$gte",
646
+ "$lt",
647
+ "$lte",
648
+ "$empty",
649
+ "$startsWith",
650
+ "$endsWith",
651
+ "$contains",
652
+ "$not",
653
+ "$and",
654
+ "$or",
655
+ "$merge",
656
+ "$coalesce",
657
+ "$case",
658
+ "$entriesOf",
659
+ "$keyBy",
660
+ "$groupBy",
661
+ "$keys",
662
+ "$values",
663
+ "$fromEntries",
664
+ "$pick",
665
+ "$omit",
666
+ "$type",
667
+ "$length",
668
+ "$date",
669
+ "$dateAdd",
670
+ "$dateDiff",
671
+ "$localeDate",
672
+ "$localeMoney",
673
+ "$localeNumber",
674
+ "$sum",
675
+ "$avg",
676
+ "$count",
677
+ "$min",
678
+ "$max",
679
+ "$pluck",
680
+ "$take",
681
+ "$drop",
682
+ "$match",
683
+ "$flatMap",
684
+ "$has",
685
+ "$renameKeys",
686
+ "$update",
687
+ "$assert",
688
+ "$walk"
689
+ ];
690
+ var OPTIONAL_FIELDS_KEY = "__optional";
691
+ var TEMPLATE_KEY = /^(?!\$)/;
692
+ var isOpKey = (key) => OP_KEYS.some((op) => op === key);
693
+ var templateKeyRefusal = (key) => isOpKey(key) ? "An op name cannot be a plain object key. Use the op itself." : 'Not a Prism op. A key that starts with "$" names an op; data with such a key goes in $const.';
694
+ var hasValidOptionalMeta = (obj) => {
695
+ const meta = obj[OPTIONAL_FIELDS_KEY];
696
+ if (meta === void 0) return true;
697
+ if (!Array.isArray(meta)) return false;
698
+ return meta.every((f) => typeof f === "string" && f.length > 0);
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
+ });
754
+ var NodeSchema = zod.z.lazy(
755
+ () => new NodeUnion({ type: "union", options: [
756
+ // Core
757
+ RefNodeSchema,
758
+ ConstNodeSchema,
759
+ VarNodeSchema,
760
+ GetNodeSchema,
761
+ WithNodeSchema,
762
+ // Array
763
+ MapNodeSchema,
764
+ FilterNodeSchema,
765
+ ReduceNodeSchema,
766
+ SliceNodeSchema,
767
+ FlattenNodeSchema,
768
+ UniqueNodeSchema,
769
+ SortByNodeSchema,
770
+ // Math
771
+ AddNodeSchema,
772
+ SubNodeSchema,
773
+ MulNodeSchema,
774
+ DivNodeSchema,
775
+ ModNodeSchema,
776
+ RoundNodeSchema,
777
+ ToNumberNodeSchema,
778
+ // String
779
+ FillNodeSchema,
780
+ JoinNodeSchema,
781
+ ToStringNodeSchema,
782
+ InterpolateNodeSchema,
783
+ TrimNodeSchema,
784
+ LowerNodeSchema,
785
+ UpperNodeSchema,
786
+ SplitNodeSchema,
787
+ ReplaceNodeSchema,
788
+ // Predicates
789
+ EqNodeSchema,
790
+ NeqNodeSchema,
791
+ GtNodeSchema,
792
+ GteNodeSchema,
793
+ LtNodeSchema,
794
+ LteNodeSchema,
795
+ EmptyNodeSchema,
796
+ StartsWithNodeSchema,
797
+ EndsWithNodeSchema,
798
+ ContainsNodeSchema,
799
+ // Logic
800
+ NotNodeSchema,
801
+ AndNodeSchema,
802
+ OrNodeSchema,
803
+ // Structure
804
+ MergeNodeSchema,
805
+ CoalesceNodeSchema,
806
+ CaseNodeSchema,
807
+ EntriesOfNodeSchema,
808
+ KeyByNodeSchema,
809
+ GroupByNodeSchema,
810
+ // Object
811
+ KeysNodeSchema,
812
+ ValuesNodeSchema,
813
+ FromEntriesNodeSchema,
814
+ PickNodeSchema,
815
+ OmitNodeSchema,
816
+ TypeNodeSchema,
817
+ LengthNodeSchema,
818
+ // Time
819
+ DateNodeSchema,
820
+ DateAddNodeSchema,
821
+ DateDiffNodeSchema,
822
+ // Locale-aware formatting
823
+ LocaleDateNodeSchema,
824
+ LocaleMoneyNodeSchema,
825
+ LocaleNumberNodeSchema,
826
+ // Sugar
827
+ SumNodeSchema,
828
+ AvgNodeSchema,
829
+ CountNodeSchema,
830
+ MinNodeSchema,
831
+ MaxNodeSchema,
832
+ PluckNodeSchema,
833
+ TakeNodeSchema,
834
+ DropNodeSchema,
835
+ MatchNodeSchema,
836
+ FlatMapNodeSchema,
837
+ // Transform (rewriting a document)
838
+ HasNodeSchema,
839
+ RenameKeysNodeSchema,
840
+ UpdateNodeSchema,
841
+ AssertNodeSchema,
842
+ WalkNodeSchema,
843
+ // Primitives
844
+ JsonPrimitiveSchema,
845
+ // Arrays of nodes
846
+ NodeArraySchema,
847
+ // Plain objects (no `$` keys, recursive values)
848
+ TemplateSchema
849
+ ] }).describe("A Prism node: an op, a plain JSON value, an array of nodes, or a plain object template.")
850
+ );
851
+ setNodeSchema(NodeSchema);
852
+ setNodeSchema2(NodeSchema);
853
+ setNodeSchema3(NodeSchema);
854
+ setNodeSchema4(NodeSchema);
855
+ setNodeSchema5(NodeSchema);
856
+ setNodeSchema6(NodeSchema);
857
+ setNodeSchema7(NodeSchema);
858
+ setNodeSchema8(NodeSchema);
859
+ setNodeSchema9(NodeSchema);
860
+ setNodeSchema10(NodeSchema);
861
+ setNodeSchema11(NodeSchema);
862
+ setNodeSchema12(NodeSchema);
863
+ var ConfigSchema = NodeSchema.describe(
864
+ "A Prism config: the top-level transformation definition. Can be any valid node."
865
+ );
866
+
867
+ exports.ConfigSchema = ConfigSchema;
868
+ exports.ErrorCode = ErrorCode;
869
+ exports.NodeSchema = NodeSchema;
870
+ exports.OPTIONAL_FIELDS_KEY = OPTIONAL_FIELDS_KEY;
871
+ exports.OP_KEYS = OP_KEYS;
872
+ exports.PrismError = PrismError;
873
+ exports.getByPath = getByPath;
874
+ exports.isAddNode = isAddNode;
875
+ exports.isAndNode = isAndNode;
876
+ exports.isAssertNode = isAssertNode;
877
+ exports.isAvgNode = isAvgNode;
878
+ exports.isCaseNode = isCaseNode;
879
+ exports.isCoalesceNode = isCoalesceNode;
880
+ exports.isConstNode = isConstNode;
881
+ exports.isContainsNode = isContainsNode;
882
+ exports.isCountNode = isCountNode;
883
+ exports.isDateAddNode = isDateAddNode;
884
+ exports.isDateDiffNode = isDateDiffNode;
885
+ exports.isDateNode = isDateNode;
886
+ exports.isDivNode = isDivNode;
887
+ exports.isDropNode = isDropNode;
888
+ exports.isEmptyNode = isEmptyNode;
889
+ exports.isEndsWithNode = isEndsWithNode;
890
+ exports.isEntriesOfNode = isEntriesOfNode;
891
+ exports.isEqNode = isEqNode;
892
+ exports.isFillNode = isFillNode;
893
+ exports.isFilterNode = isFilterNode;
894
+ exports.isFlatMapNode = isFlatMapNode;
895
+ exports.isFlattenNode = isFlattenNode;
896
+ exports.isFromEntriesNode = isFromEntriesNode;
897
+ exports.isGetNode = isGetNode;
898
+ exports.isGroupByNode = isGroupByNode;
899
+ exports.isGtNode = isGtNode;
900
+ exports.isGteNode = isGteNode;
901
+ exports.isHasNode = isHasNode;
902
+ exports.isInterpolateNode = isInterpolateNode;
903
+ exports.isJoinNode = isJoinNode;
904
+ exports.isJsonArray = isJsonArray;
905
+ exports.isJsonObject = isJsonObject;
906
+ exports.isKeyByNode = isKeyByNode;
907
+ exports.isKeysNode = isKeysNode;
908
+ exports.isLengthNode = isLengthNode;
909
+ exports.isLocaleDateNode = isLocaleDateNode;
910
+ exports.isLocaleMoneyNode = isLocaleMoneyNode;
911
+ exports.isLocaleNumberNode = isLocaleNumberNode;
912
+ exports.isLowerNode = isLowerNode;
913
+ exports.isLtNode = isLtNode;
914
+ exports.isLteNode = isLteNode;
915
+ exports.isMapNode = isMapNode;
916
+ exports.isMatchNode = isMatchNode;
917
+ exports.isMaxNode = isMaxNode;
918
+ exports.isMergeNode = isMergeNode;
919
+ exports.isMinNode = isMinNode;
920
+ exports.isModNode = isModNode;
921
+ exports.isMulNode = isMulNode;
922
+ exports.isNeqNode = isNeqNode;
923
+ exports.isNotNode = isNotNode;
924
+ exports.isOmitNode = isOmitNode;
925
+ exports.isOrNode = isOrNode;
926
+ exports.isPickNode = isPickNode;
927
+ exports.isPlainObject = isPlainObject;
928
+ exports.isPluckNode = isPluckNode;
929
+ exports.isReduceNode = isReduceNode;
930
+ exports.isRefNode = isRefNode;
931
+ exports.isRenameKeysNode = isRenameKeysNode;
932
+ exports.isReplaceNode = isReplaceNode;
933
+ exports.isRoundNode = isRoundNode;
934
+ exports.isSliceNode = isSliceNode;
935
+ exports.isSortByNode = isSortByNode;
936
+ exports.isSplitNode = isSplitNode;
937
+ exports.isStartsWithNode = isStartsWithNode;
938
+ exports.isSubNode = isSubNode;
939
+ exports.isSumNode = isSumNode;
940
+ exports.isTakeNode = isTakeNode;
941
+ exports.isToNumberNode = isToNumberNode;
942
+ exports.isToStringNode = isToStringNode;
943
+ exports.isTrimNode = isTrimNode;
944
+ exports.isTypeNode = isTypeNode;
945
+ exports.isUniqueNode = isUniqueNode;
946
+ exports.isUpdateNode = isUpdateNode;
947
+ exports.isUpperNode = isUpperNode;
948
+ exports.isValuesNode = isValuesNode;
949
+ exports.isVarNode = isVarNode;
950
+ exports.isWalkNode = isWalkNode;
951
+ exports.isWithNode = isWithNode;
952
+ exports.parseJsonPath = parseJsonPath;
953
+ exports.parseJsonPathCached = parseJsonPathCached;
954
+ //# sourceMappingURL=chunk-66YSI4PX.cjs.map
955
+ //# sourceMappingURL=chunk-66YSI4PX.cjs.map