@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.
- package/CHANGELOG.md +200 -0
- package/DESIGN.md +9 -8
- package/DOCS.md +68 -25
- package/README.md +35 -22
- package/dist/agent.cjs +4 -756
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.js +2 -2
- package/dist/chunk-66YSI4PX.cjs +955 -0
- 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-OLZQK2ZF.cjs +149 -0
- 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 +694 -1484
- 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 -1777
- 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-O3OJAQWA.js.map +0 -1
- package/dist/chunk-VC4PRB4H.js +0 -1086
- package/dist/chunk-VC4PRB4H.js.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
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOLZQK2ZF_cjs = require('./chunk-OLZQK2ZF.cjs');
|
|
4
|
+
var chunk66YSI4PX_cjs = require('./chunk-66YSI4PX.cjs');
|
|
4
5
|
var strata = require('@niscorp/strata');
|
|
5
6
|
var dayjs = require('dayjs');
|
|
6
7
|
var utc = require('dayjs/plugin/utc.js');
|
|
@@ -29,751 +30,28 @@ var explainOne = (issue, prefix) => {
|
|
|
29
30
|
return bestDepth <= here.length ? [{ path: here, message: "Not a Prism node: no op matches, and it is not a plain value." }] : best;
|
|
30
31
|
};
|
|
31
32
|
var explainIssues = (issues) => issues.flatMap((i) => explainOne(i, []));
|
|
32
|
-
var JsonPrimitiveSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean(), zod.z.null()]).describe("JSON primitive: string | number | boolean | null");
|
|
33
|
-
var JsonValueSchema = zod.z.lazy(
|
|
34
|
-
() => zod.z.union([JsonPrimitiveSchema, zod.z.array(JsonValueSchema), zod.z.record(zod.z.string(), JsonValueSchema)])
|
|
35
|
-
).describe("Any JSON value: primitive, array, or object");
|
|
36
|
-
zod.z.record(zod.z.string(), JsonValueSchema).describe("JSON object mapping string keys to JSON values");
|
|
37
|
-
var _NodeSchema = zod.z.any();
|
|
38
|
-
var setNodeSchema = (schema) => {
|
|
39
|
-
_NodeSchema = schema;
|
|
40
|
-
};
|
|
41
|
-
var node = () => _NodeSchema;
|
|
42
|
-
var RefNodeSchema = zod.z.object({
|
|
43
|
-
$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.')
|
|
44
|
-
}).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.");
|
|
45
|
-
var ConstNodeSchema = zod.z.object({
|
|
46
|
-
$const: JsonValueSchema.describe("Any JSON value to return as-is.")
|
|
47
|
-
}).strict().describe("Return a literal JSON value unchanged.");
|
|
48
|
-
var VarNodeSchema = zod.z.object({
|
|
49
|
-
$var: zod.z.string().min(1).describe("Variable name bound by $with, $map, $filter, $reduce, or $sortBy.")
|
|
50
|
-
}).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.");
|
|
51
|
-
var GetNodeSchema = zod.z.object({
|
|
52
|
-
$get: zod.z.object({
|
|
53
|
-
from: zod.z.lazy(node).describe("Source value to navigate into."),
|
|
54
|
-
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."),
|
|
55
|
-
fallback: zod.z.lazy(node).optional().describe("Fallback value when path is missing.")
|
|
56
|
-
}).strict()
|
|
57
|
-
}).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.');
|
|
58
|
-
var WithNodeSchema = zod.z.object({
|
|
59
|
-
$with: zod.z.object({
|
|
60
|
-
let: zod.z.record(zod.z.string(), zod.z.lazy(node)).describe("Variable bindings: name \u2192 expression evaluated in current scope."),
|
|
61
|
-
value: zod.z.lazy(node).describe("Expression evaluated with the declared variables in scope.")
|
|
62
|
-
}).strict()
|
|
63
|
-
}).strict().describe("Bind variables in a scoped block: { $with: { let: { x: ... }, value: ... } }");
|
|
64
|
-
var _NodeSchema2 = zod.z.any();
|
|
65
|
-
var setNodeSchema2 = (schema) => {
|
|
66
|
-
_NodeSchema2 = schema;
|
|
67
|
-
};
|
|
68
|
-
var node2 = () => _NodeSchema2;
|
|
69
|
-
var MapNodeSchema = zod.z.object({
|
|
70
|
-
$map: zod.z.object({
|
|
71
|
-
over: zod.z.lazy(node2).describe("Array to iterate over."),
|
|
72
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
73
|
-
body: zod.z.lazy(node2).describe("Expression evaluated for each element.")
|
|
74
|
-
}).strict()
|
|
75
|
-
}).strict().describe("Map over an array, transforming each element.");
|
|
76
|
-
var FilterNodeSchema = zod.z.object({
|
|
77
|
-
$filter: zod.z.object({
|
|
78
|
-
over: zod.z.lazy(node2).describe("Array to filter."),
|
|
79
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
80
|
-
when: zod.z.lazy(node2).describe("Condition \u2014 keeps element when truthy.")
|
|
81
|
-
}).strict()
|
|
82
|
-
}).strict().describe("Filter an array, keeping elements where condition is truthy.");
|
|
83
|
-
var ReduceNodeSchema = zod.z.object({
|
|
84
|
-
$reduce: zod.z.object({
|
|
85
|
-
over: zod.z.lazy(node2).describe("Array to reduce."),
|
|
86
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
87
|
-
acc: zod.z.string().min(1).optional().default("acc").describe('Accumulator variable name. Default: "acc".'),
|
|
88
|
-
init: zod.z.lazy(node2).describe("Initial accumulator value."),
|
|
89
|
-
body: zod.z.lazy(node2).describe("Expression evaluated for each element with both element and accumulator in scope.")
|
|
90
|
-
}).strict()
|
|
91
|
-
}).strict().describe("Reduce an array to a single value using an accumulator.");
|
|
92
|
-
var SliceNodeSchema = zod.z.object({
|
|
93
|
-
$slice: zod.z.object({
|
|
94
|
-
from: zod.z.lazy(node2).describe("Array or string to slice."),
|
|
95
|
-
start: zod.z.number().int().optional().describe("Start index (inclusive). Default: 0."),
|
|
96
|
-
end: zod.z.number().int().optional().describe("End index (exclusive). Default: length.")
|
|
97
|
-
}).strict()
|
|
98
|
-
}).strict().describe("Slice an array or string by start/end indices.");
|
|
99
|
-
var FlattenNodeSchema = zod.z.object({
|
|
100
|
-
$flatten: zod.z.lazy(node2).describe("Array of arrays to flatten one level.")
|
|
101
|
-
}).strict().describe("Flatten a nested array by one level.");
|
|
102
|
-
var UniqueNodeSchema = zod.z.object({
|
|
103
|
-
$unique: zod.z.lazy(node2).describe("Array to deduplicate.")
|
|
104
|
-
}).strict().describe("Remove duplicate values from an array (compared by JSON.stringify).");
|
|
105
|
-
var SortByNodeSchema = zod.z.object({
|
|
106
|
-
$sortBy: zod.z.object({
|
|
107
|
-
over: zod.z.lazy(node2).describe("Array to sort."),
|
|
108
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
109
|
-
by: zod.z.lazy(node2).describe("Expression to compute the sort key."),
|
|
110
|
-
dir: zod.z.enum(["asc", "desc"]).optional().default("asc").describe('Sort direction. Default: "asc".')
|
|
111
|
-
}).strict()
|
|
112
|
-
}).strict().describe("Sort an array by a computed key.");
|
|
113
|
-
var _NodeSchema3 = zod.z.any();
|
|
114
|
-
var setNodeSchema3 = (schema) => {
|
|
115
|
-
_NodeSchema3 = schema;
|
|
116
|
-
};
|
|
117
|
-
var node3 = () => _NodeSchema3;
|
|
118
|
-
var pairOf = (desc) => zod.z.tuple([zod.z.lazy(node3), zod.z.lazy(node3)]).describe(desc);
|
|
119
|
-
var AddNodeSchema = zod.z.object({ $add: pairOf("Two numeric operands to add.") }).strict().describe("Add two numbers.");
|
|
120
|
-
var SubNodeSchema = zod.z.object({ $sub: pairOf("Two numeric operands to subtract (a - b).") }).strict().describe("Subtract second number from first.");
|
|
121
|
-
var MulNodeSchema = zod.z.object({ $mul: pairOf("Two numeric operands to multiply.") }).strict().describe("Multiply two numbers.");
|
|
122
|
-
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.");
|
|
123
|
-
var RoundNodeSchema = zod.z.object({
|
|
124
|
-
$round: zod.z.object({
|
|
125
|
-
value: zod.z.lazy(node3).describe("Numeric value to round."),
|
|
126
|
-
digits: zod.z.number().int().nonnegative().optional().default(0).describe("Decimal places. Default: 0.")
|
|
127
|
-
}).strict()
|
|
128
|
-
}).strict().describe("Round a number to N decimal places.");
|
|
129
|
-
var _NodeSchema4 = zod.z.any();
|
|
130
|
-
var setNodeSchema4 = (schema) => {
|
|
131
|
-
_NodeSchema4 = schema;
|
|
132
|
-
};
|
|
133
|
-
var node4 = () => _NodeSchema4;
|
|
134
|
-
var JoinNodeSchema = zod.z.object({
|
|
135
|
-
$join: zod.z.object({
|
|
136
|
-
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."),
|
|
137
|
-
sep: zod.z.string().optional().default("").describe('Separator between parts. Default: "".')
|
|
138
|
-
}).strict()
|
|
139
|
-
}).strict().describe("Concatenate values into a string with an optional separator.");
|
|
140
|
-
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.");
|
|
141
|
-
var InterpolateNodeSchema = zod.z.object({
|
|
142
|
-
$interpolate: zod.z.object({
|
|
143
|
-
template: zod.z.string().describe("Template with {{key}} placeholders."),
|
|
144
|
-
values: zod.z.lazy(node4).describe("Object whose keys replace {{key}} placeholders.")
|
|
145
|
-
}).strict()
|
|
146
|
-
}).strict().describe("Replace {{key}} placeholders in a template with values from an object.");
|
|
147
|
-
var FillNodeSchema = zod.z.object({
|
|
148
|
-
$fill: zod.z.lazy(node4).describe("A pattern value `{ phrase, slots }` \u2014 filled with its own slots, source language. Non-patterns pass through.")
|
|
149
|
-
}).strict().describe('Fill a counted phrase: `{ phrase: "{n} of {total}", slots: { n: 1, total: 12 } }` \u2192 "1 of 12".');
|
|
150
|
-
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.");
|
|
151
|
-
var LowerNodeSchema = zod.z.object({ $lower: zod.z.lazy(node4).describe("String to lowercase.") }).strict().describe("Convert a string to lowercase.");
|
|
152
|
-
var UpperNodeSchema = zod.z.object({ $upper: zod.z.lazy(node4).describe("String to uppercase.") }).strict().describe("Convert a string to uppercase.");
|
|
153
|
-
var SplitNodeSchema = zod.z.object({
|
|
154
|
-
$split: zod.z.object({
|
|
155
|
-
value: zod.z.lazy(node4).describe("String to split."),
|
|
156
|
-
sep: zod.z.string().describe("Separator to split on.")
|
|
157
|
-
}).strict()
|
|
158
|
-
}).strict().describe("Split a string into an array by separator.");
|
|
159
|
-
var ReplaceNodeSchema = zod.z.object({
|
|
160
|
-
$replace: zod.z.object({
|
|
161
|
-
value: zod.z.lazy(node4).describe("String to search in."),
|
|
162
|
-
search: zod.z.string().describe("Substring to find."),
|
|
163
|
-
replacement: zod.z.string().describe("Replacement string.")
|
|
164
|
-
}).strict()
|
|
165
|
-
}).strict().describe("Replace the first occurrence of a substring.");
|
|
166
|
-
var _NodeSchema5 = zod.z.any();
|
|
167
|
-
var setNodeSchema5 = (schema) => {
|
|
168
|
-
_NodeSchema5 = schema;
|
|
169
|
-
};
|
|
170
|
-
var node5 = () => _NodeSchema5;
|
|
171
|
-
var pairOf2 = (desc) => zod.z.tuple([zod.z.lazy(node5), zod.z.lazy(node5)]).describe(desc);
|
|
172
|
-
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.");
|
|
173
|
-
var NeqNodeSchema = zod.z.object({ $neq: pairOf2("Two values to compare for inequality.") }).strict().describe("Deep inequality comparison. Returns true or false.");
|
|
174
|
-
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.");
|
|
175
|
-
var GteNodeSchema = zod.z.object({ $gte: pairOf2("Two values: returns true if first >= second.") }).strict().describe("Greater than or equal comparison.");
|
|
176
|
-
var LtNodeSchema = zod.z.object({ $lt: pairOf2("Two values: returns true if first < second.") }).strict().describe("Less than comparison.");
|
|
177
|
-
var LteNodeSchema = zod.z.object({ $lte: pairOf2("Two values: returns true if first <= second.") }).strict().describe("Less than or equal comparison.");
|
|
178
|
-
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.");
|
|
179
|
-
var StartsWithNodeSchema = zod.z.object({
|
|
180
|
-
$startsWith: zod.z.object({
|
|
181
|
-
value: zod.z.lazy(node5).describe("String to check."),
|
|
182
|
-
prefix: zod.z.lazy(node5).describe("Expected prefix.")
|
|
183
|
-
}).strict()
|
|
184
|
-
}).strict().describe("Returns true if string starts with prefix.");
|
|
185
|
-
var EndsWithNodeSchema = zod.z.object({
|
|
186
|
-
$endsWith: zod.z.object({
|
|
187
|
-
value: zod.z.lazy(node5).describe("String to check."),
|
|
188
|
-
suffix: zod.z.lazy(node5).describe("Expected suffix.")
|
|
189
|
-
}).strict()
|
|
190
|
-
}).strict().describe("Returns true if string ends with suffix.");
|
|
191
|
-
var ContainsNodeSchema = zod.z.object({
|
|
192
|
-
$contains: zod.z.object({
|
|
193
|
-
value: zod.z.lazy(node5).describe("String to search in."),
|
|
194
|
-
search: zod.z.lazy(node5).describe("Substring to find.")
|
|
195
|
-
}).strict()
|
|
196
|
-
}).strict().describe("Returns true if string contains the search substring.");
|
|
197
|
-
var _NodeSchema6 = zod.z.any();
|
|
198
|
-
var setNodeSchema6 = (schema) => {
|
|
199
|
-
_NodeSchema6 = schema;
|
|
200
|
-
};
|
|
201
|
-
var node6 = () => _NodeSchema6;
|
|
202
|
-
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.");
|
|
203
|
-
var AndNodeSchema = zod.z.object({
|
|
204
|
-
$and: zod.z.array(zod.z.lazy(node6)).min(1).describe("Values to AND. Short-circuits: returns last truthy or first falsy.")
|
|
205
|
-
}).strict().describe("Short-circuit logical AND.");
|
|
206
|
-
var OrNodeSchema = zod.z.object({
|
|
207
|
-
$or: zod.z.array(zod.z.lazy(node6)).min(1).describe("Values to OR. Short-circuits: returns first truthy or last falsy.")
|
|
208
|
-
}).strict().describe("Short-circuit logical OR.");
|
|
209
|
-
var _NodeSchema7 = zod.z.any();
|
|
210
|
-
var setNodeSchema7 = (schema) => {
|
|
211
|
-
_NodeSchema7 = schema;
|
|
212
|
-
};
|
|
213
|
-
var node7 = () => _NodeSchema7;
|
|
214
|
-
var MergeNodeSchema = zod.z.object({
|
|
215
|
-
$merge: zod.z.array(zod.z.lazy(node7)).min(1).describe("Objects to shallow-merge (left to right, later wins).")
|
|
216
|
-
}).strict().describe("Shallow merge multiple objects. Later values overwrite earlier ones.");
|
|
217
|
-
var CoalesceNodeSchema = zod.z.object({
|
|
218
|
-
$coalesce: zod.z.array(zod.z.lazy(node7)).min(1).describe("Values to try in order. Returns first non-null/non-undefined.")
|
|
219
|
-
}).strict().describe("Return the first non-null, non-undefined value.");
|
|
220
|
-
var CaseNodeSchema = zod.z.object({
|
|
221
|
-
$case: zod.z.object({
|
|
222
|
-
branches: zod.z.array(
|
|
223
|
-
zod.z.object({
|
|
224
|
-
when: zod.z.lazy(node7).describe("Condition to evaluate."),
|
|
225
|
-
then: zod.z.lazy(node7).describe("Value to return if condition is truthy.")
|
|
226
|
-
}).strict()
|
|
227
|
-
).min(1).describe("Ordered list of when/then branches."),
|
|
228
|
-
else: zod.z.lazy(node7).optional().describe("Fallback value if no branch matches. Default: null.")
|
|
229
|
-
}).strict()
|
|
230
|
-
}).strict().describe("Conditional branching: evaluates branches in order, returns first match or else.");
|
|
231
|
-
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.");
|
|
232
|
-
var KeyByNodeSchema = zod.z.object({
|
|
233
|
-
$keyBy: zod.z.object({
|
|
234
|
-
over: zod.z.lazy(node7).describe("Array to group."),
|
|
235
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
236
|
-
key: zod.z.lazy(node7).describe("Expression to compute the key (last wins on collision).")
|
|
237
|
-
}).strict()
|
|
238
|
-
}).strict().describe("Convert an array to an object keyed by a computed value. Last element wins on key collision.");
|
|
239
|
-
var GroupByNodeSchema = zod.z.object({
|
|
240
|
-
$groupBy: zod.z.object({
|
|
241
|
-
over: zod.z.lazy(node7).describe("Array to group."),
|
|
242
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
243
|
-
key: zod.z.lazy(node7).describe("Expression to compute the group key.")
|
|
244
|
-
}).strict()
|
|
245
|
-
}).strict().describe("Group array elements into an object of arrays by computed key.");
|
|
246
|
-
var _NodeSchema8 = zod.z.any();
|
|
247
|
-
var setNodeSchema8 = (schema) => {
|
|
248
|
-
_NodeSchema8 = schema;
|
|
249
|
-
};
|
|
250
|
-
var node8 = () => _NodeSchema8;
|
|
251
|
-
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.");
|
|
252
|
-
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.");
|
|
253
|
-
var FromEntriesNodeSchema = zod.z.object({
|
|
254
|
-
$fromEntries: zod.z.lazy(node8).describe("Array of [key, value] pairs to convert to an object.")
|
|
255
|
-
}).strict().describe("Convert [key, value][] entries into an object.");
|
|
256
|
-
var PickNodeSchema = zod.z.object({
|
|
257
|
-
$pick: zod.z.object({
|
|
258
|
-
from: zod.z.lazy(node8).describe("Source object."),
|
|
259
|
-
keys: zod.z.array(zod.z.string()).min(1).describe("Keys to keep.")
|
|
260
|
-
}).strict()
|
|
261
|
-
}).strict().describe("Pick specific keys from an object, discarding the rest.");
|
|
262
|
-
var OmitNodeSchema = zod.z.object({
|
|
263
|
-
$omit: zod.z.object({
|
|
264
|
-
from: zod.z.lazy(node8).describe("Source object."),
|
|
265
|
-
keys: zod.z.array(zod.z.string()).min(1).describe("Keys to remove.")
|
|
266
|
-
}).strict()
|
|
267
|
-
}).strict().describe("Remove specific keys from an object, keeping the rest.");
|
|
268
|
-
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".');
|
|
269
|
-
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.");
|
|
270
|
-
var _NodeSchema9 = zod.z.any();
|
|
271
|
-
var setNodeSchema9 = (schema) => {
|
|
272
|
-
_NodeSchema9 = schema;
|
|
273
|
-
};
|
|
274
|
-
var node9 = () => _NodeSchema9;
|
|
275
|
-
var TimeUnit = zod.z.enum(["year", "month", "day", "hour", "minute", "second"]).describe("Time unit for date arithmetic.");
|
|
276
|
-
var DateNodeSchema = zod.z.object({
|
|
277
|
-
$date: zod.z.object({
|
|
278
|
-
value: zod.z.lazy(node9).describe("Date value (ISO string or timestamp)."),
|
|
279
|
-
format: zod.z.string().optional().describe("Output format string (dayjs format). Default: ISO 8601."),
|
|
280
|
-
utc: zod.z.boolean().optional().default(false).describe("Format in UTC. Default: false.")
|
|
281
|
-
}).strict()
|
|
282
|
-
}).strict().describe("Format a date value.");
|
|
283
|
-
var DateAddNodeSchema = zod.z.object({
|
|
284
|
-
$dateAdd: zod.z.object({
|
|
285
|
-
date: zod.z.lazy(node9).describe("Base date (ISO string or timestamp)."),
|
|
286
|
-
amount: zod.z.number().describe("Amount to add (can be negative)."),
|
|
287
|
-
unit: TimeUnit
|
|
288
|
-
}).strict()
|
|
289
|
-
}).strict().describe("Add a duration to a date. Returns ISO string.");
|
|
290
|
-
var DateDiffNodeSchema = zod.z.object({
|
|
291
|
-
$dateDiff: zod.z.object({
|
|
292
|
-
from: zod.z.lazy(node9).describe("Start date."),
|
|
293
|
-
to: zod.z.lazy(node9).describe("End date."),
|
|
294
|
-
unit: TimeUnit
|
|
295
|
-
}).strict()
|
|
296
|
-
}).strict().describe("Calculate difference between two dates. Returns a number.");
|
|
297
|
-
var _NodeSchema10 = zod.z.any();
|
|
298
|
-
var setNodeSchema10 = (schema) => {
|
|
299
|
-
_NodeSchema10 = schema;
|
|
300
|
-
};
|
|
301
|
-
var node10 = () => _NodeSchema10;
|
|
302
|
-
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.');
|
|
303
|
-
var fallbackField = zod.z.lazy(node10).optional().describe('Rendered when the value is null/undefined/empty. Default: "".');
|
|
304
|
-
var DateStyle = zod.z.enum(["full", "long", "medium", "short"]);
|
|
305
|
-
var IntlDateOptionsSchema = zod.z.object({
|
|
306
|
-
dateStyle: DateStyle.optional().describe("Whole-date preset. Mutually exclusive with the field-by-field options below."),
|
|
307
|
-
timeStyle: DateStyle.optional().describe("Whole-time preset. Mutually exclusive with the field-by-field options below."),
|
|
308
|
-
weekday: zod.z.enum(["long", "short", "narrow"]).optional(),
|
|
309
|
-
year: zod.z.enum(["numeric", "2-digit"]).optional(),
|
|
310
|
-
month: zod.z.enum(["numeric", "2-digit", "long", "short", "narrow"]).optional(),
|
|
311
|
-
day: zod.z.enum(["numeric", "2-digit"]).optional(),
|
|
312
|
-
hour: zod.z.enum(["numeric", "2-digit"]).optional(),
|
|
313
|
-
minute: zod.z.enum(["numeric", "2-digit"]).optional(),
|
|
314
|
-
second: zod.z.enum(["numeric", "2-digit"]).optional(),
|
|
315
|
-
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."),
|
|
316
|
-
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.')
|
|
317
|
-
}).strict();
|
|
318
|
-
var LocaleDateNodeSchema = zod.z.object({
|
|
319
|
-
$localeDate: zod.z.object({
|
|
320
|
-
value: zod.z.lazy(node10).describe("ISO string, DATE-only string, or epoch milliseconds."),
|
|
321
|
-
locale: localeField,
|
|
322
|
-
options: IntlDateOptionsSchema.optional().describe('Defaults to { dateStyle: "medium" }.'),
|
|
323
|
-
fallback: fallbackField
|
|
324
|
-
}).strict()
|
|
325
|
-
}).strict().describe("Format a date for a human reading in a given locale (Intl.DateTimeFormat).");
|
|
326
|
-
var LocaleMoneyNodeSchema = zod.z.object({
|
|
327
|
-
$localeMoney: zod.z.object({
|
|
328
|
-
value: zod.z.lazy(node10).describe("The amount. Minor units (cents) unless `minorUnits` is false."),
|
|
329
|
-
currency: zod.z.lazy(node10).describe('ISO-4217 code \u2014 "EUR", "CHF". Required: an amount without one is a number, not money.'),
|
|
330
|
-
locale: localeField,
|
|
331
|
-
minorUnits: zod.z.boolean().optional().describe(
|
|
332
|
-
"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."
|
|
333
|
-
),
|
|
334
|
-
digits: zod.z.number().int().min(0).max(20).optional().describe("Fraction digits. Default: the currency's own (2 for EUR, 0 for JPY)."),
|
|
335
|
-
fallback: fallbackField
|
|
336
|
-
}).strict()
|
|
337
|
-
}).strict().describe("Format an amount as money in a given locale (Intl.NumberFormat, style currency).");
|
|
338
|
-
var LocaleNumberNodeSchema = zod.z.object({
|
|
339
|
-
$localeNumber: zod.z.object({
|
|
340
|
-
value: zod.z.lazy(node10).describe("The number to format."),
|
|
341
|
-
locale: localeField,
|
|
342
|
-
style: zod.z.enum(["decimal", "percent"]).optional().describe('Default "decimal". "percent" multiplies by 100 \u2014 pass 0.42, not 42.'),
|
|
343
|
-
digits: zod.z.number().int().min(0).max(20).optional().describe("Maximum fraction digits. Default: the locale's own."),
|
|
344
|
-
minDigits: zod.z.number().int().min(0).max(20).optional().describe("Minimum fraction digits \u2014 for a column that should not ragged-edge."),
|
|
345
|
-
compact: zod.z.boolean().optional().describe('Short form \u2014 "1.2K", "1,2 Tsd.". For a headline figure, never for money owed.'),
|
|
346
|
-
fallback: fallbackField
|
|
347
|
-
}).strict()
|
|
348
|
-
}).strict().describe("Format a number in a given locale (Intl.NumberFormat).");
|
|
349
|
-
var _NodeSchema11 = zod.z.any();
|
|
350
|
-
var setNodeSchema11 = (schema) => {
|
|
351
|
-
_NodeSchema11 = schema;
|
|
352
|
-
};
|
|
353
|
-
var node11 = () => _NodeSchema11;
|
|
354
|
-
var overOnly = (desc) => zod.z.object({ over: zod.z.lazy(node11).describe(desc) }).strict();
|
|
355
|
-
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.");
|
|
356
|
-
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).");
|
|
357
|
-
var CountNodeSchema = zod.z.object({ $count: overOnly("Array to count elements of.") }).strict().describe("Sugar: count elements in an array. Desugars to $reduce.");
|
|
358
|
-
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.");
|
|
359
|
-
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.");
|
|
360
|
-
var PluckNodeSchema = zod.z.object({
|
|
361
|
-
$pluck: zod.z.object({
|
|
362
|
-
over: zod.z.lazy(node11).describe("Array of objects to extract from."),
|
|
363
|
-
key: zod.z.string().min(1).describe("Key to extract from each object.")
|
|
364
|
-
}).strict()
|
|
365
|
-
}).strict().describe("Sugar: extract a single field from each element. Desugars to $map + $get.");
|
|
366
|
-
var TakeNodeSchema = zod.z.object({
|
|
367
|
-
$take: zod.z.object({
|
|
368
|
-
from: zod.z.lazy(node11).describe("Array to take from."),
|
|
369
|
-
count: zod.z.number().int().nonnegative().describe("Number of elements to take from the start.")
|
|
370
|
-
}).strict()
|
|
371
|
-
}).strict().describe("Sugar: take first N elements. Desugars to $slice.");
|
|
372
|
-
var DropNodeSchema = zod.z.object({
|
|
373
|
-
$drop: zod.z.object({
|
|
374
|
-
from: zod.z.lazy(node11).describe("Array to drop from."),
|
|
375
|
-
count: zod.z.number().int().nonnegative().describe("Number of elements to skip from the start.")
|
|
376
|
-
}).strict()
|
|
377
|
-
}).strict().describe("Sugar: skip first N elements. Desugars to $slice.");
|
|
378
|
-
var MatchNodeSchema = zod.z.object({
|
|
379
|
-
$match: zod.z.object({
|
|
380
|
-
over: zod.z.lazy(node11).describe("Array to search within."),
|
|
381
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
382
|
-
search: zod.z.lazy(node11).describe("String to search for (uses $contains).")
|
|
383
|
-
}).strict()
|
|
384
|
-
}).strict().describe("Sugar: filter array by string containment. Desugars to $filter + $contains.");
|
|
385
|
-
var FlatMapNodeSchema = zod.z.object({
|
|
386
|
-
$flatMap: zod.z.object({
|
|
387
|
-
over: zod.z.lazy(node11).describe("Array to flat-map over."),
|
|
388
|
-
as: zod.z.string().min(1).describe("Variable name for the current element."),
|
|
389
|
-
body: zod.z.lazy(node11).describe("Expression that returns an array for each element.")
|
|
390
|
-
}).strict()
|
|
391
|
-
}).strict().describe("Sugar: map then flatten one level. Desugars to $map + $flatten.");
|
|
392
|
-
var _NodeSchema12 = zod.z.any();
|
|
393
|
-
var setNodeSchema12 = (schema) => {
|
|
394
|
-
_NodeSchema12 = schema;
|
|
395
|
-
};
|
|
396
|
-
var node12 = () => _NodeSchema12;
|
|
397
|
-
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).");
|
|
398
|
-
var HasNodeSchema = zod.z.object({
|
|
399
|
-
$has: zod.z.object({
|
|
400
|
-
from: zod.z.lazy(node12).describe("The value to look into."),
|
|
401
|
-
path: PathSchema
|
|
402
|
-
}).strict()
|
|
403
|
-
}).strict().describe("True when the whole path exists \u2014 a key present with a null value counts; a missing one does not.");
|
|
404
|
-
var RenameKeysNodeSchema = zod.z.object({
|
|
405
|
-
$renameKeys: zod.z.object({
|
|
406
|
-
from: zod.z.lazy(node12).describe("The object whose keys to rename."),
|
|
407
|
-
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.")
|
|
408
|
-
}).strict()
|
|
409
|
-
}).strict().describe(
|
|
410
|
-
"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."
|
|
411
|
-
);
|
|
412
|
-
var UpdateNodeSchema = zod.z.object({
|
|
413
|
-
$update: zod.z.object({
|
|
414
|
-
from: zod.z.lazy(node12).describe("The value to copy with one path changed."),
|
|
415
|
-
path: PathSchema,
|
|
416
|
-
value: zod.z.lazy(node12).describe("The new value at `path`. The value currently there (null when absent) is bound as `$var` `as`."),
|
|
417
|
-
as: zod.z.string().min(1).optional().describe('The variable name the current value is bound to (default "current").')
|
|
418
|
-
}).strict()
|
|
419
|
-
}).strict().describe(
|
|
420
|
-
"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."
|
|
421
|
-
);
|
|
422
|
-
var AssertNodeSchema = zod.z.object({
|
|
423
|
-
$assert: zod.z.object({
|
|
424
|
-
when: zod.z.lazy(node12).describe("Must be truthy."),
|
|
425
|
-
message: zod.z.string().min(1).describe("What went wrong, for a person \u2014 the whole error text."),
|
|
426
|
-
value: zod.z.lazy(node12).describe("Returned when `when` holds.")
|
|
427
|
-
}).strict()
|
|
428
|
-
}).strict().describe("Fail with `message` (E_ASSERT) unless `when` is truthy; otherwise evaluate to `value`. How a migration refuses a shape it cannot handle.");
|
|
429
|
-
var WalkNodeSchema = zod.z.object({
|
|
430
|
-
$walk: zod.z.object({
|
|
431
|
-
over: zod.z.lazy(node12).describe("The tree to rewrite \u2014 any JSON value."),
|
|
432
|
-
as: zod.z.string().min(1).describe("The variable each visited node is bound to."),
|
|
433
|
-
rules: zod.z.array(
|
|
434
|
-
zod.z.object({
|
|
435
|
-
when: zod.z.lazy(node12).describe("Evaluated with the node bound to `as`; the first truthy rule wins."),
|
|
436
|
-
then: zod.z.lazy(node12).describe("The node's replacement.")
|
|
437
|
-
}).strict()
|
|
438
|
-
).min(1).describe("Tried in order at every node. No rule matches: the node is kept."),
|
|
439
|
-
order: zod.z.enum(["post", "pre"]).optional().describe(
|
|
440
|
-
"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."
|
|
441
|
-
)
|
|
442
|
-
}).strict()
|
|
443
|
-
}).strict().describe(
|
|
444
|
-
"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."
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
// src/schemas/node.schema.ts
|
|
448
|
-
var OP_KEYS = [
|
|
449
|
-
"$ref",
|
|
450
|
-
"$const",
|
|
451
|
-
"$var",
|
|
452
|
-
"$get",
|
|
453
|
-
"$with",
|
|
454
|
-
"$map",
|
|
455
|
-
"$filter",
|
|
456
|
-
"$reduce",
|
|
457
|
-
"$slice",
|
|
458
|
-
"$flatten",
|
|
459
|
-
"$unique",
|
|
460
|
-
"$sortBy",
|
|
461
|
-
"$add",
|
|
462
|
-
"$sub",
|
|
463
|
-
"$mul",
|
|
464
|
-
"$div",
|
|
465
|
-
"$round",
|
|
466
|
-
"$fill",
|
|
467
|
-
"$join",
|
|
468
|
-
"$toString",
|
|
469
|
-
"$interpolate",
|
|
470
|
-
"$trim",
|
|
471
|
-
"$lower",
|
|
472
|
-
"$upper",
|
|
473
|
-
"$split",
|
|
474
|
-
"$replace",
|
|
475
|
-
"$eq",
|
|
476
|
-
"$neq",
|
|
477
|
-
"$gt",
|
|
478
|
-
"$gte",
|
|
479
|
-
"$lt",
|
|
480
|
-
"$lte",
|
|
481
|
-
"$empty",
|
|
482
|
-
"$startsWith",
|
|
483
|
-
"$endsWith",
|
|
484
|
-
"$contains",
|
|
485
|
-
"$not",
|
|
486
|
-
"$and",
|
|
487
|
-
"$or",
|
|
488
|
-
"$merge",
|
|
489
|
-
"$coalesce",
|
|
490
|
-
"$case",
|
|
491
|
-
"$entriesOf",
|
|
492
|
-
"$keyBy",
|
|
493
|
-
"$groupBy",
|
|
494
|
-
"$keys",
|
|
495
|
-
"$values",
|
|
496
|
-
"$fromEntries",
|
|
497
|
-
"$pick",
|
|
498
|
-
"$omit",
|
|
499
|
-
"$type",
|
|
500
|
-
"$length",
|
|
501
|
-
"$date",
|
|
502
|
-
"$dateAdd",
|
|
503
|
-
"$dateDiff",
|
|
504
|
-
"$localeDate",
|
|
505
|
-
"$localeMoney",
|
|
506
|
-
"$localeNumber",
|
|
507
|
-
"$sum",
|
|
508
|
-
"$avg",
|
|
509
|
-
"$count",
|
|
510
|
-
"$min",
|
|
511
|
-
"$max",
|
|
512
|
-
"$pluck",
|
|
513
|
-
"$take",
|
|
514
|
-
"$drop",
|
|
515
|
-
"$match",
|
|
516
|
-
"$flatMap",
|
|
517
|
-
"$has",
|
|
518
|
-
"$renameKeys",
|
|
519
|
-
"$update",
|
|
520
|
-
"$assert",
|
|
521
|
-
"$walk"
|
|
522
|
-
];
|
|
523
|
-
var OPTIONAL_FIELDS_KEY = "__optional";
|
|
524
|
-
var TEMPLATE_KEY = /^(?!\$)/;
|
|
525
|
-
var isOpKey = (key) => OP_KEYS.some((op) => op === key);
|
|
526
|
-
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.';
|
|
527
|
-
var hasValidOptionalMeta = (obj) => {
|
|
528
|
-
const meta = obj[OPTIONAL_FIELDS_KEY];
|
|
529
|
-
if (meta === void 0) return true;
|
|
530
|
-
if (!Array.isArray(meta)) return false;
|
|
531
|
-
return meta.every((f) => typeof f === "string" && f.length > 0);
|
|
532
|
-
};
|
|
533
|
-
var NodeSchema = zod.z.lazy(
|
|
534
|
-
() => zod.z.union([
|
|
535
|
-
// Core
|
|
536
|
-
RefNodeSchema,
|
|
537
|
-
ConstNodeSchema,
|
|
538
|
-
VarNodeSchema,
|
|
539
|
-
GetNodeSchema,
|
|
540
|
-
WithNodeSchema,
|
|
541
|
-
// Array
|
|
542
|
-
MapNodeSchema,
|
|
543
|
-
FilterNodeSchema,
|
|
544
|
-
ReduceNodeSchema,
|
|
545
|
-
SliceNodeSchema,
|
|
546
|
-
FlattenNodeSchema,
|
|
547
|
-
UniqueNodeSchema,
|
|
548
|
-
SortByNodeSchema,
|
|
549
|
-
// Math
|
|
550
|
-
AddNodeSchema,
|
|
551
|
-
SubNodeSchema,
|
|
552
|
-
MulNodeSchema,
|
|
553
|
-
DivNodeSchema,
|
|
554
|
-
RoundNodeSchema,
|
|
555
|
-
// String
|
|
556
|
-
FillNodeSchema,
|
|
557
|
-
JoinNodeSchema,
|
|
558
|
-
ToStringNodeSchema,
|
|
559
|
-
InterpolateNodeSchema,
|
|
560
|
-
TrimNodeSchema,
|
|
561
|
-
LowerNodeSchema,
|
|
562
|
-
UpperNodeSchema,
|
|
563
|
-
SplitNodeSchema,
|
|
564
|
-
ReplaceNodeSchema,
|
|
565
|
-
// Predicates
|
|
566
|
-
EqNodeSchema,
|
|
567
|
-
NeqNodeSchema,
|
|
568
|
-
GtNodeSchema,
|
|
569
|
-
GteNodeSchema,
|
|
570
|
-
LtNodeSchema,
|
|
571
|
-
LteNodeSchema,
|
|
572
|
-
EmptyNodeSchema,
|
|
573
|
-
StartsWithNodeSchema,
|
|
574
|
-
EndsWithNodeSchema,
|
|
575
|
-
ContainsNodeSchema,
|
|
576
|
-
// Logic
|
|
577
|
-
NotNodeSchema,
|
|
578
|
-
AndNodeSchema,
|
|
579
|
-
OrNodeSchema,
|
|
580
|
-
// Structure
|
|
581
|
-
MergeNodeSchema,
|
|
582
|
-
CoalesceNodeSchema,
|
|
583
|
-
CaseNodeSchema,
|
|
584
|
-
EntriesOfNodeSchema,
|
|
585
|
-
KeyByNodeSchema,
|
|
586
|
-
GroupByNodeSchema,
|
|
587
|
-
// Object
|
|
588
|
-
KeysNodeSchema,
|
|
589
|
-
ValuesNodeSchema,
|
|
590
|
-
FromEntriesNodeSchema,
|
|
591
|
-
PickNodeSchema,
|
|
592
|
-
OmitNodeSchema,
|
|
593
|
-
TypeNodeSchema,
|
|
594
|
-
LengthNodeSchema,
|
|
595
|
-
// Time
|
|
596
|
-
DateNodeSchema,
|
|
597
|
-
DateAddNodeSchema,
|
|
598
|
-
DateDiffNodeSchema,
|
|
599
|
-
// Locale-aware formatting
|
|
600
|
-
LocaleDateNodeSchema,
|
|
601
|
-
LocaleMoneyNodeSchema,
|
|
602
|
-
LocaleNumberNodeSchema,
|
|
603
|
-
// Sugar
|
|
604
|
-
SumNodeSchema,
|
|
605
|
-
AvgNodeSchema,
|
|
606
|
-
CountNodeSchema,
|
|
607
|
-
MinNodeSchema,
|
|
608
|
-
MaxNodeSchema,
|
|
609
|
-
PluckNodeSchema,
|
|
610
|
-
TakeNodeSchema,
|
|
611
|
-
DropNodeSchema,
|
|
612
|
-
MatchNodeSchema,
|
|
613
|
-
FlatMapNodeSchema,
|
|
614
|
-
// Transform (rewriting a document)
|
|
615
|
-
HasNodeSchema,
|
|
616
|
-
RenameKeysNodeSchema,
|
|
617
|
-
UpdateNodeSchema,
|
|
618
|
-
AssertNodeSchema,
|
|
619
|
-
WalkNodeSchema,
|
|
620
|
-
// Primitives
|
|
621
|
-
JsonPrimitiveSchema,
|
|
622
|
-
// Arrays of nodes
|
|
623
|
-
zod.z.array(zod.z.lazy(() => NodeSchema)),
|
|
624
|
-
// Plain objects (no `$` keys, recursive values)
|
|
625
|
-
// A `$` key is not a template key. Said in the KEY schema, not a
|
|
626
|
-
// refinement: a refinement leaves this branch structurally matched, and
|
|
627
|
-
// zod then reports its complaint instead of the union's — so a typo inside
|
|
628
|
-
// a real op (`{ $get: { pathh } }`) read as "plain object must not contain
|
|
629
|
-
// $ op keys" at the root. As a key pattern it is also plain JSON Schema
|
|
630
|
-
// (`propertyNames`), which the grammar snapshot and agent prompts read.
|
|
631
|
-
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." })
|
|
632
|
-
]).describe("A Prism node: an op, a plain JSON value, an array of nodes, or a plain object template.")
|
|
633
|
-
);
|
|
634
|
-
setNodeSchema(NodeSchema);
|
|
635
|
-
setNodeSchema2(NodeSchema);
|
|
636
|
-
setNodeSchema3(NodeSchema);
|
|
637
|
-
setNodeSchema4(NodeSchema);
|
|
638
|
-
setNodeSchema5(NodeSchema);
|
|
639
|
-
setNodeSchema6(NodeSchema);
|
|
640
|
-
setNodeSchema7(NodeSchema);
|
|
641
|
-
setNodeSchema8(NodeSchema);
|
|
642
|
-
setNodeSchema9(NodeSchema);
|
|
643
|
-
setNodeSchema10(NodeSchema);
|
|
644
|
-
setNodeSchema11(NodeSchema);
|
|
645
|
-
setNodeSchema12(NodeSchema);
|
|
646
|
-
|
|
647
|
-
// src/schemas/config.schema.ts
|
|
648
|
-
var ConfigSchema = NodeSchema.describe(
|
|
649
|
-
"A Prism config: the top-level transformation definition. Can be any valid node."
|
|
650
|
-
);
|
|
651
|
-
|
|
652
|
-
// src/errors.ts
|
|
653
|
-
var ErrorCode = {
|
|
654
|
-
SCHEMA: "E_SCHEMA",
|
|
655
|
-
MISSING_PATH: "E_MISSING_PATH",
|
|
656
|
-
TYPE: "E_TYPE",
|
|
657
|
-
DIVISION_BY_ZERO: "E_DIVISION_BY_ZERO",
|
|
658
|
-
DATE_INVALID: "E_DATE_INVALID",
|
|
659
|
-
VAR_NOT_FOUND: "E_VAR_NOT_FOUND",
|
|
660
|
-
NODE_SHAPE: "E_NODE_SHAPE",
|
|
661
|
-
// A config's own `$assert` refused its input.
|
|
662
|
-
ASSERT: "E_ASSERT",
|
|
663
|
-
// An evaluation past its budget (engine/budget.ts).
|
|
664
|
-
BUDGET: "E_BUDGET"
|
|
665
|
-
};
|
|
666
|
-
var PrismError = class extends Error {
|
|
667
|
-
code;
|
|
668
|
-
context;
|
|
669
|
-
constructor(message, code, context) {
|
|
670
|
-
super(message);
|
|
671
|
-
this.name = "PrismError";
|
|
672
|
-
this.code = code;
|
|
673
|
-
this.context = context;
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
// src/schemas/guards.ts
|
|
678
|
-
var hasKey = (value, key) => typeof value === "object" && value !== null && !Array.isArray(value) && key in value;
|
|
679
|
-
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
680
|
-
var isJsonArray = (value) => Array.isArray(value);
|
|
681
|
-
var isRefNode = (v) => hasKey(v, "$ref");
|
|
682
|
-
var isConstNode = (v) => hasKey(v, "$const");
|
|
683
|
-
var isVarNode = (v) => hasKey(v, "$var");
|
|
684
|
-
var isGetNode = (v) => hasKey(v, "$get");
|
|
685
|
-
var isWithNode = (v) => hasKey(v, "$with");
|
|
686
|
-
var isMapNode = (v) => hasKey(v, "$map");
|
|
687
|
-
var isFilterNode = (v) => hasKey(v, "$filter");
|
|
688
|
-
var isReduceNode = (v) => hasKey(v, "$reduce");
|
|
689
|
-
var isSliceNode = (v) => hasKey(v, "$slice");
|
|
690
|
-
var isFlattenNode = (v) => hasKey(v, "$flatten");
|
|
691
|
-
var isUniqueNode = (v) => hasKey(v, "$unique");
|
|
692
|
-
var isSortByNode = (v) => hasKey(v, "$sortBy");
|
|
693
|
-
var isAddNode = (v) => hasKey(v, "$add");
|
|
694
|
-
var isSubNode = (v) => hasKey(v, "$sub");
|
|
695
|
-
var isMulNode = (v) => hasKey(v, "$mul");
|
|
696
|
-
var isDivNode = (v) => hasKey(v, "$div");
|
|
697
|
-
var isRoundNode = (v) => hasKey(v, "$round");
|
|
698
|
-
var isJoinNode = (v) => hasKey(v, "$join");
|
|
699
|
-
var isToStringNode = (v) => hasKey(v, "$toString");
|
|
700
|
-
var isInterpolateNode = (v) => hasKey(v, "$interpolate");
|
|
701
|
-
var isFillNode = (v) => hasKey(v, "$fill");
|
|
702
|
-
var isTrimNode = (v) => hasKey(v, "$trim");
|
|
703
|
-
var isLowerNode = (v) => hasKey(v, "$lower");
|
|
704
|
-
var isUpperNode = (v) => hasKey(v, "$upper");
|
|
705
|
-
var isSplitNode = (v) => hasKey(v, "$split");
|
|
706
|
-
var isReplaceNode = (v) => hasKey(v, "$replace");
|
|
707
|
-
var isEqNode = (v) => hasKey(v, "$eq");
|
|
708
|
-
var isNeqNode = (v) => hasKey(v, "$neq");
|
|
709
|
-
var isGtNode = (v) => hasKey(v, "$gt");
|
|
710
|
-
var isGteNode = (v) => hasKey(v, "$gte");
|
|
711
|
-
var isLtNode = (v) => hasKey(v, "$lt");
|
|
712
|
-
var isLteNode = (v) => hasKey(v, "$lte");
|
|
713
|
-
var isEmptyNode = (v) => hasKey(v, "$empty");
|
|
714
|
-
var isStartsWithNode = (v) => hasKey(v, "$startsWith");
|
|
715
|
-
var isEndsWithNode = (v) => hasKey(v, "$endsWith");
|
|
716
|
-
var isContainsNode = (v) => hasKey(v, "$contains");
|
|
717
|
-
var isNotNode = (v) => hasKey(v, "$not");
|
|
718
|
-
var isAndNode = (v) => hasKey(v, "$and");
|
|
719
|
-
var isOrNode = (v) => hasKey(v, "$or");
|
|
720
|
-
var isMergeNode = (v) => hasKey(v, "$merge");
|
|
721
|
-
var isCoalesceNode = (v) => hasKey(v, "$coalesce");
|
|
722
|
-
var isCaseNode = (v) => hasKey(v, "$case");
|
|
723
|
-
var isEntriesOfNode = (v) => hasKey(v, "$entriesOf");
|
|
724
|
-
var isKeyByNode = (v) => hasKey(v, "$keyBy");
|
|
725
|
-
var isGroupByNode = (v) => hasKey(v, "$groupBy");
|
|
726
|
-
var isKeysNode = (v) => hasKey(v, "$keys");
|
|
727
|
-
var isValuesNode = (v) => hasKey(v, "$values");
|
|
728
|
-
var isFromEntriesNode = (v) => hasKey(v, "$fromEntries");
|
|
729
|
-
var isPickNode = (v) => hasKey(v, "$pick");
|
|
730
|
-
var isOmitNode = (v) => hasKey(v, "$omit");
|
|
731
|
-
var isHasNode = (v) => hasKey(v, "$has");
|
|
732
|
-
var isRenameKeysNode = (v) => hasKey(v, "$renameKeys");
|
|
733
|
-
var isUpdateNode = (v) => hasKey(v, "$update");
|
|
734
|
-
var isAssertNode = (v) => hasKey(v, "$assert");
|
|
735
|
-
var isWalkNode = (v) => hasKey(v, "$walk");
|
|
736
|
-
var isTypeNode = (v) => hasKey(v, "$type");
|
|
737
|
-
var isLengthNode = (v) => hasKey(v, "$length");
|
|
738
|
-
var isDateNode = (v) => hasKey(v, "$date");
|
|
739
|
-
var isDateAddNode = (v) => hasKey(v, "$dateAdd");
|
|
740
|
-
var isDateDiffNode = (v) => hasKey(v, "$dateDiff");
|
|
741
|
-
var isLocaleDateNode = (v) => hasKey(v, "$localeDate");
|
|
742
|
-
var isLocaleMoneyNode = (v) => hasKey(v, "$localeMoney");
|
|
743
|
-
var isLocaleNumberNode = (v) => hasKey(v, "$localeNumber");
|
|
744
|
-
var isSumNode = (v) => hasKey(v, "$sum");
|
|
745
|
-
var isAvgNode = (v) => hasKey(v, "$avg");
|
|
746
|
-
var isCountNode = (v) => hasKey(v, "$count");
|
|
747
|
-
var isMinNode = (v) => hasKey(v, "$min");
|
|
748
|
-
var isMaxNode = (v) => hasKey(v, "$max");
|
|
749
|
-
var isPluckNode = (v) => hasKey(v, "$pluck");
|
|
750
|
-
var isTakeNode = (v) => hasKey(v, "$take");
|
|
751
|
-
var isDropNode = (v) => hasKey(v, "$drop");
|
|
752
|
-
var isMatchNode = (v) => hasKey(v, "$match");
|
|
753
|
-
var isFlatMapNode = (v) => hasKey(v, "$flatMap");
|
|
754
|
-
var isPlainObject = (value) => isJsonObject(value) && !Object.keys(value).some((k) => k.startsWith("$"));
|
|
755
33
|
|
|
756
34
|
// src/sugar/rewriters.ts
|
|
757
|
-
var rewriteSum = (
|
|
35
|
+
var rewriteSum = (node, recurse) => ({
|
|
758
36
|
$reduce: {
|
|
759
|
-
over: recurse(
|
|
37
|
+
over: recurse(node.$sum.over),
|
|
760
38
|
as: "__x",
|
|
761
39
|
acc: "__acc",
|
|
762
40
|
init: { $const: 0 },
|
|
763
41
|
body: { $add: [{ $var: "__acc" }, { $var: "__x" }] }
|
|
764
42
|
}
|
|
765
43
|
});
|
|
766
|
-
var rewriteCount = (
|
|
44
|
+
var rewriteCount = (node, recurse) => ({
|
|
767
45
|
$reduce: {
|
|
768
|
-
over: recurse(
|
|
46
|
+
over: recurse(node.$count.over),
|
|
769
47
|
as: "__x",
|
|
770
48
|
acc: "__acc",
|
|
771
49
|
init: { $const: 0 },
|
|
772
50
|
body: { $add: [{ $var: "__acc" }, { $const: 1 }] }
|
|
773
51
|
}
|
|
774
52
|
});
|
|
775
|
-
var rewriteAvg = (
|
|
776
|
-
const over = recurse(
|
|
53
|
+
var rewriteAvg = (node, recurse) => {
|
|
54
|
+
const over = recurse(node.$avg.over);
|
|
777
55
|
return {
|
|
778
56
|
$div: [
|
|
779
57
|
{
|
|
@@ -797,9 +75,9 @@ var rewriteAvg = (node13, recurse) => {
|
|
|
797
75
|
]
|
|
798
76
|
};
|
|
799
77
|
};
|
|
800
|
-
var rewriteMin = (
|
|
78
|
+
var rewriteMin = (node, recurse) => ({
|
|
801
79
|
$reduce: {
|
|
802
|
-
over: recurse(
|
|
80
|
+
over: recurse(node.$min.over),
|
|
803
81
|
as: "__x",
|
|
804
82
|
acc: "__acc",
|
|
805
83
|
init: { $const: null },
|
|
@@ -814,9 +92,9 @@ var rewriteMin = (node13, recurse) => ({
|
|
|
814
92
|
}
|
|
815
93
|
}
|
|
816
94
|
});
|
|
817
|
-
var rewriteMax = (
|
|
95
|
+
var rewriteMax = (node, recurse) => ({
|
|
818
96
|
$reduce: {
|
|
819
|
-
over: recurse(
|
|
97
|
+
over: recurse(node.$max.over),
|
|
820
98
|
as: "__x",
|
|
821
99
|
acc: "__acc",
|
|
822
100
|
init: { $const: null },
|
|
@@ -831,78 +109,85 @@ var rewriteMax = (node13, recurse) => ({
|
|
|
831
109
|
}
|
|
832
110
|
}
|
|
833
111
|
});
|
|
834
|
-
var rewritePluck = (
|
|
112
|
+
var rewritePluck = (node, recurse) => ({
|
|
835
113
|
$map: {
|
|
836
|
-
over: recurse(
|
|
114
|
+
over: recurse(node.$pluck.over),
|
|
837
115
|
as: "__item",
|
|
838
|
-
body: { $get: { from: { $var: "__item" }, path: [
|
|
116
|
+
body: { $get: { from: { $var: "__item" }, path: [node.$pluck.key] } }
|
|
839
117
|
}
|
|
840
118
|
});
|
|
841
|
-
var rewriteTake = (
|
|
119
|
+
var rewriteTake = (node, recurse) => ({
|
|
842
120
|
$slice: {
|
|
843
|
-
from: recurse(
|
|
121
|
+
from: recurse(node.$take.from),
|
|
844
122
|
start: 0,
|
|
845
|
-
end:
|
|
123
|
+
end: node.$take.count
|
|
846
124
|
}
|
|
847
125
|
});
|
|
848
|
-
var rewriteDrop = (
|
|
126
|
+
var rewriteDrop = (node, recurse) => ({
|
|
849
127
|
$slice: {
|
|
850
|
-
from: recurse(
|
|
851
|
-
start:
|
|
128
|
+
from: recurse(node.$drop.from),
|
|
129
|
+
start: node.$drop.count
|
|
852
130
|
}
|
|
853
131
|
});
|
|
854
|
-
var rewriteMatch = (
|
|
132
|
+
var rewriteMatch = (node, recurse) => ({
|
|
855
133
|
$filter: {
|
|
856
|
-
over: recurse(
|
|
857
|
-
as:
|
|
134
|
+
over: recurse(node.$match.over),
|
|
135
|
+
as: node.$match.as,
|
|
858
136
|
when: {
|
|
859
137
|
$contains: {
|
|
860
|
-
value: { $var:
|
|
861
|
-
search: recurse(
|
|
138
|
+
value: { $var: node.$match.as },
|
|
139
|
+
search: recurse(node.$match.search)
|
|
862
140
|
}
|
|
863
141
|
}
|
|
864
142
|
}
|
|
865
143
|
});
|
|
866
|
-
var rewriteFlatMap = (
|
|
144
|
+
var rewriteFlatMap = (node, recurse) => ({
|
|
867
145
|
$flatten: {
|
|
868
146
|
$map: {
|
|
869
|
-
over: recurse(
|
|
870
|
-
as:
|
|
871
|
-
body: recurse(
|
|
147
|
+
over: recurse(node.$flatMap.over),
|
|
148
|
+
as: node.$flatMap.as,
|
|
149
|
+
body: recurse(node.$flatMap.body)
|
|
872
150
|
}
|
|
873
151
|
}
|
|
874
152
|
});
|
|
875
153
|
|
|
876
154
|
// src/sugar/desugar.ts
|
|
877
|
-
var desugar = (
|
|
878
|
-
if (
|
|
879
|
-
if (typeof
|
|
880
|
-
if (Array.isArray(
|
|
881
|
-
if (
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (
|
|
887
|
-
if (
|
|
888
|
-
if (
|
|
889
|
-
if (
|
|
890
|
-
if (
|
|
891
|
-
if (
|
|
155
|
+
var desugar = (node) => {
|
|
156
|
+
if (node === null || node === void 0) return node;
|
|
157
|
+
if (typeof node !== "object") return node;
|
|
158
|
+
if (Array.isArray(node)) return node.map(desugar);
|
|
159
|
+
if (chunk66YSI4PX_cjs.isWithNode(node)) {
|
|
160
|
+
const bindings = {};
|
|
161
|
+
for (const [name, expr] of Object.entries(node.$with.let)) bindings[name] = desugar(expr);
|
|
162
|
+
return { $with: { let: bindings, value: desugar(node.$with.value) } };
|
|
163
|
+
}
|
|
164
|
+
if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) return { $renameKeys: { ...node.$renameKeys, from: desugar(node.$renameKeys.from) } };
|
|
165
|
+
if (chunk66YSI4PX_cjs.isConstNode(node)) return node;
|
|
166
|
+
if (chunk66YSI4PX_cjs.isSumNode(node)) return rewriteSum(node, desugar);
|
|
167
|
+
if (chunk66YSI4PX_cjs.isAvgNode(node)) return rewriteAvg(node, desugar);
|
|
168
|
+
if (chunk66YSI4PX_cjs.isCountNode(node)) return rewriteCount(node, desugar);
|
|
169
|
+
if (chunk66YSI4PX_cjs.isMinNode(node)) return rewriteMin(node, desugar);
|
|
170
|
+
if (chunk66YSI4PX_cjs.isMaxNode(node)) return rewriteMax(node, desugar);
|
|
171
|
+
if (chunk66YSI4PX_cjs.isPluckNode(node)) return rewritePluck(node, desugar);
|
|
172
|
+
if (chunk66YSI4PX_cjs.isTakeNode(node)) return rewriteTake(node, desugar);
|
|
173
|
+
if (chunk66YSI4PX_cjs.isDropNode(node)) return rewriteDrop(node, desugar);
|
|
174
|
+
if (chunk66YSI4PX_cjs.isMatchNode(node)) return rewriteMatch(node, desugar);
|
|
175
|
+
if (chunk66YSI4PX_cjs.isFlatMapNode(node)) return rewriteFlatMap(node, desugar);
|
|
176
|
+
if (chunk66YSI4PX_cjs.isJsonObject(node)) {
|
|
892
177
|
const result = {};
|
|
893
|
-
for (const [key, value] of Object.entries(
|
|
178
|
+
for (const [key, value] of Object.entries(node)) {
|
|
894
179
|
result[key] = desugar(value);
|
|
895
180
|
}
|
|
896
181
|
return result;
|
|
897
182
|
}
|
|
898
|
-
return
|
|
183
|
+
return node;
|
|
899
184
|
};
|
|
900
185
|
|
|
901
186
|
// src/engine/budget.ts
|
|
902
187
|
var DEFAULT_LIMITS = { maxSteps: 1e6, maxStringLength: 1e6, maxValues: 1e6 };
|
|
903
188
|
var createBudget = (limits) => ({ limits: { ...DEFAULT_LIMITS, ...limits }, steps: 0, sizes: /* @__PURE__ */ new WeakMap() });
|
|
904
189
|
var refuse = (what, limit) => {
|
|
905
|
-
throw new PrismError(`Evaluation stopped: ${what} (limit ${limit})`, ErrorCode.BUDGET, { details: { limit } });
|
|
190
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Evaluation stopped: ${what} (limit ${limit})`, chunk66YSI4PX_cjs.ErrorCode.BUDGET, { details: { limit } });
|
|
906
191
|
};
|
|
907
192
|
var spendStep = (budget) => {
|
|
908
193
|
budget.steps += 1;
|
|
@@ -931,119 +216,59 @@ var measure = (value, budget) => {
|
|
|
931
216
|
}
|
|
932
217
|
};
|
|
933
218
|
|
|
934
|
-
// src/utils/jsonpath.ts
|
|
935
|
-
var parseJsonPath = (path) => {
|
|
936
|
-
if (!path.startsWith("$.")) return [];
|
|
937
|
-
const segments = [];
|
|
938
|
-
let cursor = 2;
|
|
939
|
-
let currentKey = "";
|
|
940
|
-
const pushKey = () => {
|
|
941
|
-
if (currentKey.length > 0) {
|
|
942
|
-
segments.push({ type: "key", key: currentKey });
|
|
943
|
-
currentKey = "";
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
while (cursor < path.length) {
|
|
947
|
-
const char = path[cursor];
|
|
948
|
-
if (char === ".") {
|
|
949
|
-
pushKey();
|
|
950
|
-
cursor++;
|
|
951
|
-
continue;
|
|
952
|
-
}
|
|
953
|
-
if (char === "[") {
|
|
954
|
-
pushKey();
|
|
955
|
-
cursor++;
|
|
956
|
-
let numBuf = "";
|
|
957
|
-
while (cursor < path.length && path[cursor] !== "]") {
|
|
958
|
-
numBuf += path[cursor];
|
|
959
|
-
cursor++;
|
|
960
|
-
}
|
|
961
|
-
if (path[cursor] !== "]") return [];
|
|
962
|
-
cursor++;
|
|
963
|
-
const index = Number(numBuf);
|
|
964
|
-
if (!Number.isInteger(index) || index < 0) return [];
|
|
965
|
-
segments.push({ type: "index", index });
|
|
966
|
-
continue;
|
|
967
|
-
}
|
|
968
|
-
currentKey += char;
|
|
969
|
-
cursor++;
|
|
970
|
-
}
|
|
971
|
-
pushKey();
|
|
972
|
-
return segments;
|
|
973
|
-
};
|
|
974
|
-
var cache = /* @__PURE__ */ new Map();
|
|
975
|
-
var parseJsonPathCached = (path) => {
|
|
976
|
-
const cached = cache.get(path);
|
|
977
|
-
if (cached) return cached;
|
|
978
|
-
const parsed = parseJsonPath(path);
|
|
979
|
-
cache.set(path, parsed);
|
|
980
|
-
return parsed;
|
|
981
|
-
};
|
|
982
|
-
var primeJsonPathCache = (paths) => {
|
|
983
|
-
for (const p of paths) {
|
|
984
|
-
if (!cache.has(p)) cache.set(p, parseJsonPath(p));
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
var getByPath = (root, segments) => {
|
|
988
|
-
let current2 = root;
|
|
989
|
-
for (const segment of segments) {
|
|
990
|
-
if (segment.type === "key") {
|
|
991
|
-
if (!isJsonObject(current2)) return void 0;
|
|
992
|
-
current2 = current2[segment.key];
|
|
993
|
-
} else {
|
|
994
|
-
if (!isJsonArray(current2)) return void 0;
|
|
995
|
-
current2 = current2[segment.index];
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
return current2;
|
|
999
|
-
};
|
|
1000
|
-
|
|
1001
219
|
// src/ops/core.ops.ts
|
|
1002
220
|
var SEGMENTS_KEY = "__segments";
|
|
1003
221
|
var isSegmentsArray = (value) => Array.isArray(value);
|
|
1004
|
-
var opRef = (
|
|
1005
|
-
const attached = Reflect.get(
|
|
1006
|
-
const segments = isSegmentsArray(attached) ? attached : parseJsonPathCached(
|
|
1007
|
-
const resolved = getByPath(context.source, segments);
|
|
222
|
+
var opRef = (node, context, _evaluate) => {
|
|
223
|
+
const attached = Reflect.get(node, SEGMENTS_KEY);
|
|
224
|
+
const segments = isSegmentsArray(attached) ? attached : chunk66YSI4PX_cjs.parseJsonPathCached(node.$ref);
|
|
225
|
+
const resolved = chunk66YSI4PX_cjs.getByPath(context.source, segments);
|
|
1008
226
|
if (resolved === void 0)
|
|
1009
|
-
throw new PrismError("Path not found", ErrorCode.MISSING_PATH, { op: "$ref", path:
|
|
227
|
+
throw new chunk66YSI4PX_cjs.PrismError("Path not found", chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH, { op: "$ref", path: node.$ref });
|
|
1010
228
|
return resolved;
|
|
1011
229
|
};
|
|
1012
|
-
var
|
|
1013
|
-
|
|
1014
|
-
|
|
230
|
+
var copyOf = (value) => {
|
|
231
|
+
if (value === null || typeof value !== "object") return value;
|
|
232
|
+
if (Array.isArray(value)) return value.map(copyOf);
|
|
233
|
+
const copy = {};
|
|
234
|
+
for (const [key, inner] of Object.entries(value)) copy[key] = copyOf(inner);
|
|
235
|
+
return copy;
|
|
236
|
+
};
|
|
237
|
+
var opConst = (node, context, _evaluate) => context.kept === true ? copyOf(node.$const) : node.$const;
|
|
238
|
+
var opVar = (node, context, _evaluate) => {
|
|
239
|
+
const value = context.vars[node.$var];
|
|
1015
240
|
if (value === void 0)
|
|
1016
|
-
throw new PrismError(`Variable not found: ${
|
|
241
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Variable not found: ${node.$var}`, chunk66YSI4PX_cjs.ErrorCode.VAR_NOT_FOUND, { op: "$var", path: node.$var });
|
|
1017
242
|
return value;
|
|
1018
243
|
};
|
|
1019
|
-
var opGet = (
|
|
1020
|
-
const { from, path, fallback } =
|
|
244
|
+
var opGet = (node, context, evaluate2) => {
|
|
245
|
+
const { from, path, fallback } = node.$get;
|
|
1021
246
|
let current2 = evaluate2(from, context);
|
|
1022
247
|
for (const segment of path) {
|
|
1023
248
|
const evaluated = typeof segment === "object" && segment !== null ? evaluate2(segment, context) : segment;
|
|
1024
249
|
if (typeof evaluated === "number") {
|
|
1025
|
-
if (!isJsonArray(current2)) {
|
|
250
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(current2)) {
|
|
1026
251
|
if (fallback !== void 0) return evaluate2(fallback, context);
|
|
1027
|
-
throw new PrismError("Expected array for index access", ErrorCode.TYPE, { op: "$get" });
|
|
252
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected array for index access", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$get" });
|
|
1028
253
|
}
|
|
1029
254
|
current2 = current2[evaluated];
|
|
1030
255
|
} else {
|
|
1031
256
|
const key = String(evaluated);
|
|
1032
|
-
if (!isJsonObject(current2)) {
|
|
257
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(current2)) {
|
|
1033
258
|
if (fallback !== void 0) return evaluate2(fallback, context);
|
|
1034
|
-
throw new PrismError("Expected object for key access", ErrorCode.TYPE, { op: "$get" });
|
|
259
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for key access", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$get" });
|
|
1035
260
|
}
|
|
1036
261
|
current2 = current2[key];
|
|
1037
262
|
}
|
|
1038
263
|
}
|
|
1039
264
|
if (current2 === void 0) {
|
|
1040
265
|
if (fallback !== void 0) return evaluate2(fallback, context);
|
|
1041
|
-
throw new PrismError("Path not found", ErrorCode.MISSING_PATH, { op: "$get" });
|
|
266
|
+
throw new chunk66YSI4PX_cjs.PrismError("Path not found", chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH, { op: "$get" });
|
|
1042
267
|
}
|
|
1043
268
|
return current2;
|
|
1044
269
|
};
|
|
1045
|
-
var opWith = (
|
|
1046
|
-
const { let: declarations, value } =
|
|
270
|
+
var opWith = (node, context, evaluate2) => {
|
|
271
|
+
const { let: declarations, value } = node.$with;
|
|
1047
272
|
const extendedVars = { ...context.vars };
|
|
1048
273
|
for (const [name, expr] of Object.entries(declarations)) {
|
|
1049
274
|
extendedVars[name] = evaluate2(expr, context);
|
|
@@ -1053,69 +278,83 @@ var opWith = (node13, context, evaluate2) => {
|
|
|
1053
278
|
};
|
|
1054
279
|
|
|
1055
280
|
// src/utils/compare.ts
|
|
1056
|
-
var jsonEqual = (a, b) =>
|
|
281
|
+
var jsonEqual = (a, b) => {
|
|
282
|
+
if (a === b) return true;
|
|
283
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
284
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
285
|
+
};
|
|
1057
286
|
var compare = (a, b) => {
|
|
1058
287
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
1059
288
|
if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
|
|
1060
289
|
return void 0;
|
|
1061
290
|
};
|
|
1062
291
|
|
|
292
|
+
// src/ops/scope.ts
|
|
293
|
+
var loopScope = (context) => {
|
|
294
|
+
const vars = { ...context.vars };
|
|
295
|
+
return { scope: { ...context, vars }, vars };
|
|
296
|
+
};
|
|
297
|
+
|
|
1063
298
|
// src/ops/array.ops.ts
|
|
1064
299
|
var requireArray = (value, op) => {
|
|
1065
|
-
if (!isJsonArray(value))
|
|
1066
|
-
throw new PrismError(`Expected array for ${op}`, ErrorCode.TYPE, { op });
|
|
300
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(value))
|
|
301
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Expected array for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
|
|
1067
302
|
return value;
|
|
1068
303
|
};
|
|
1069
|
-
var opMap = (
|
|
1070
|
-
const { over, as, body } =
|
|
304
|
+
var opMap = (node, context, evaluate2) => {
|
|
305
|
+
const { over, as, body } = node.$map;
|
|
1071
306
|
const input = requireArray(evaluate2(over, context), "$map.over");
|
|
1072
307
|
const result = [];
|
|
308
|
+
const { scope, vars } = loopScope(context);
|
|
1073
309
|
for (const item of input) {
|
|
1074
|
-
|
|
310
|
+
vars[as] = item;
|
|
311
|
+
result.push(evaluate2(body, scope));
|
|
1075
312
|
}
|
|
1076
313
|
return result;
|
|
1077
314
|
};
|
|
1078
|
-
var opFilter = (
|
|
1079
|
-
const { over, as, when } =
|
|
315
|
+
var opFilter = (node, context, evaluate2) => {
|
|
316
|
+
const { over, as, when } = node.$filter;
|
|
1080
317
|
const input = requireArray(evaluate2(over, context), "$filter.over");
|
|
1081
318
|
const result = [];
|
|
319
|
+
const { scope, vars } = loopScope(context);
|
|
1082
320
|
for (const item of input) {
|
|
1083
|
-
|
|
321
|
+
vars[as] = item;
|
|
322
|
+
const condition = evaluate2(when, scope);
|
|
1084
323
|
if (condition) result.push(item);
|
|
1085
324
|
}
|
|
1086
325
|
return result;
|
|
1087
326
|
};
|
|
1088
|
-
var opReduce = (
|
|
1089
|
-
const { over, as, acc: accName = "acc", init, body } =
|
|
327
|
+
var opReduce = (node, context, evaluate2) => {
|
|
328
|
+
const { over, as, acc: accName = "acc", init, body } = node.$reduce;
|
|
1090
329
|
const input = requireArray(evaluate2(over, context), "$reduce.over");
|
|
1091
330
|
let accumulator = evaluate2(init, context);
|
|
331
|
+
const { scope, vars } = loopScope(context);
|
|
1092
332
|
for (const item of input) {
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
});
|
|
333
|
+
vars[as] = item;
|
|
334
|
+
vars[accName] = accumulator;
|
|
335
|
+
accumulator = evaluate2(body, scope);
|
|
1097
336
|
measure(accumulator, context.budget);
|
|
1098
337
|
}
|
|
1099
338
|
return accumulator;
|
|
1100
339
|
};
|
|
1101
|
-
var opSlice = (
|
|
1102
|
-
const { from, start, end } =
|
|
340
|
+
var opSlice = (node, context, evaluate2) => {
|
|
341
|
+
const { from, start, end } = node.$slice;
|
|
1103
342
|
const input = evaluate2(from, context);
|
|
1104
343
|
if (typeof input === "string") return input.slice(start, end);
|
|
1105
|
-
if (isJsonArray(input)) return input.slice(start, end);
|
|
1106
|
-
throw new PrismError("Expected array or string for $slice", ErrorCode.TYPE, { op: "$slice" });
|
|
344
|
+
if (chunk66YSI4PX_cjs.isJsonArray(input)) return input.slice(start, end);
|
|
345
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected array or string for $slice", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$slice" });
|
|
1107
346
|
};
|
|
1108
|
-
var opFlatten = (
|
|
1109
|
-
const input = requireArray(evaluate2(
|
|
347
|
+
var opFlatten = (node, context, evaluate2) => {
|
|
348
|
+
const input = requireArray(evaluate2(node.$flatten, context), "$flatten");
|
|
1110
349
|
const result = [];
|
|
1111
350
|
for (const item of input) {
|
|
1112
|
-
if (isJsonArray(item)) result.push(...item);
|
|
351
|
+
if (chunk66YSI4PX_cjs.isJsonArray(item)) result.push(...item);
|
|
1113
352
|
else result.push(item);
|
|
1114
353
|
}
|
|
1115
354
|
return result;
|
|
1116
355
|
};
|
|
1117
|
-
var opUnique = (
|
|
1118
|
-
const input = requireArray(evaluate2(
|
|
356
|
+
var opUnique = (node, context, evaluate2) => {
|
|
357
|
+
const input = requireArray(evaluate2(node.$unique, context), "$unique");
|
|
1119
358
|
const seen = /* @__PURE__ */ new Set();
|
|
1120
359
|
const result = [];
|
|
1121
360
|
for (const item of input) {
|
|
@@ -1127,73 +366,114 @@ var opUnique = (node13, context, evaluate2) => {
|
|
|
1127
366
|
}
|
|
1128
367
|
return result;
|
|
1129
368
|
};
|
|
1130
|
-
var
|
|
1131
|
-
|
|
369
|
+
var sortKey = (key) => {
|
|
370
|
+
if (key !== null && typeof key === "object") {
|
|
371
|
+
throw new chunk66YSI4PX_cjs.PrismError(
|
|
372
|
+
`$sortBy.by answered ${Array.isArray(key) ? "a list" : "an object"}; a sort key is a string or a number. To sort by two keys, sort by the second and then by the first: the sort keeps the order of equal items.`,
|
|
373
|
+
chunk66YSI4PX_cjs.ErrorCode.TYPE,
|
|
374
|
+
{ op: "$sortBy" }
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
return key;
|
|
378
|
+
};
|
|
379
|
+
var NULL_KIND = 3;
|
|
380
|
+
var kindOf = (key) => key === null ? NULL_KIND : typeof key === "number" ? 0 : typeof key === "string" ? 1 : 2;
|
|
381
|
+
var opSortBy = (node, context, evaluate2) => {
|
|
382
|
+
const { over, as, by, dir = "asc" } = node.$sortBy;
|
|
1132
383
|
const input = requireArray(evaluate2(over, context), "$sortBy.over");
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
384
|
+
const { scope, vars } = loopScope(context);
|
|
385
|
+
const keyed = input.map((item) => {
|
|
386
|
+
vars[as] = item;
|
|
387
|
+
return { item, key: sortKey(evaluate2(by, scope)) };
|
|
388
|
+
});
|
|
1137
389
|
keyed.sort((a, b) => {
|
|
1138
|
-
const
|
|
1139
|
-
|
|
390
|
+
const kindA = kindOf(a.key);
|
|
391
|
+
const kindB = kindOf(b.key);
|
|
392
|
+
if (kindA === NULL_KIND || kindB === NULL_KIND) return kindA - kindB;
|
|
393
|
+
const cmp = kindA !== kindB ? kindA - kindB : compare(a.key, b.key) ?? Number(a.key) - Number(b.key);
|
|
1140
394
|
return dir === "desc" ? -cmp : cmp;
|
|
1141
395
|
});
|
|
1142
396
|
return keyed.map((k) => k.item);
|
|
1143
397
|
};
|
|
1144
398
|
|
|
1145
399
|
// src/ops/math.ops.ts
|
|
1146
|
-
var requireNumbers = (
|
|
1147
|
-
const a = evaluate2(
|
|
1148
|
-
const b = evaluate2(
|
|
400
|
+
var requireNumbers = (node, context, evaluate2, op) => {
|
|
401
|
+
const a = evaluate2(node[0], context);
|
|
402
|
+
const b = evaluate2(node[1], context);
|
|
1149
403
|
if (typeof a !== "number" || typeof b !== "number")
|
|
1150
|
-
throw new PrismError(`Expected numbers for ${op}`, ErrorCode.TYPE, { op });
|
|
404
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Expected numbers for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
|
|
1151
405
|
return [a, b];
|
|
1152
406
|
};
|
|
1153
|
-
var opAdd = (
|
|
1154
|
-
const [a, b] = requireNumbers(
|
|
407
|
+
var opAdd = (node, context, evaluate2) => {
|
|
408
|
+
const [a, b] = requireNumbers(node.$add, context, evaluate2, "$add");
|
|
1155
409
|
return a + b;
|
|
1156
410
|
};
|
|
1157
|
-
var opSub = (
|
|
1158
|
-
const [a, b] = requireNumbers(
|
|
411
|
+
var opSub = (node, context, evaluate2) => {
|
|
412
|
+
const [a, b] = requireNumbers(node.$sub, context, evaluate2, "$sub");
|
|
1159
413
|
return a - b;
|
|
1160
414
|
};
|
|
1161
|
-
var opMul = (
|
|
1162
|
-
const [a, b] = requireNumbers(
|
|
415
|
+
var opMul = (node, context, evaluate2) => {
|
|
416
|
+
const [a, b] = requireNumbers(node.$mul, context, evaluate2, "$mul");
|
|
1163
417
|
return a * b;
|
|
1164
418
|
};
|
|
1165
|
-
var opDiv = (
|
|
1166
|
-
const [a, b] = requireNumbers(
|
|
1167
|
-
if (b === 0) throw new PrismError("Division by zero", ErrorCode.DIVISION_BY_ZERO, { op: "$div" });
|
|
419
|
+
var opDiv = (node, context, evaluate2) => {
|
|
420
|
+
const [a, b] = requireNumbers(node.$div, context, evaluate2, "$div");
|
|
421
|
+
if (b === 0) throw new chunk66YSI4PX_cjs.PrismError("Division by zero", chunk66YSI4PX_cjs.ErrorCode.DIVISION_BY_ZERO, { op: "$div" });
|
|
1168
422
|
return a / b;
|
|
1169
423
|
};
|
|
1170
|
-
var
|
|
1171
|
-
const
|
|
424
|
+
var opMod = (node, context, evaluate2) => {
|
|
425
|
+
const [a, b] = requireNumbers(node.$mod, context, evaluate2, "$mod");
|
|
426
|
+
if (b === 0) throw new chunk66YSI4PX_cjs.PrismError("Division by zero", chunk66YSI4PX_cjs.ErrorCode.DIVISION_BY_ZERO, { op: "$mod" });
|
|
427
|
+
const remainder = a % b;
|
|
428
|
+
if (remainder === 0) return 0;
|
|
429
|
+
return remainder < 0 !== b < 0 ? remainder + b : remainder;
|
|
430
|
+
};
|
|
431
|
+
var ROUNDING = { nearest: Math.round, floor: Math.floor, ceil: Math.ceil };
|
|
432
|
+
var opRound = (node, context, evaluate2) => {
|
|
433
|
+
const value = evaluate2(node.$round.value, context);
|
|
1172
434
|
if (typeof value !== "number")
|
|
1173
|
-
throw new PrismError("Expected number for $round", ErrorCode.TYPE, { op: "$round" });
|
|
1174
|
-
const digits =
|
|
435
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected number for $round", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$round" });
|
|
436
|
+
const digits = node.$round.digits ?? 0;
|
|
1175
437
|
const factor = Math.pow(10, digits);
|
|
1176
|
-
return
|
|
438
|
+
return ROUNDING[node.$round.mode ?? "nearest"](value * factor) / factor;
|
|
439
|
+
};
|
|
440
|
+
var NUMERIC_TEXT = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
441
|
+
var whatIs = (value) => {
|
|
442
|
+
if (typeof value === "string") return JSON.stringify(value.slice(0, 40));
|
|
443
|
+
if (value === null) return "null";
|
|
444
|
+
if (Array.isArray(value)) return "a list";
|
|
445
|
+
return typeof value === "object" ? "an object" : String(value);
|
|
446
|
+
};
|
|
447
|
+
var opToNumber = (node, context, evaluate2) => {
|
|
448
|
+
const value = evaluate2(node.$toNumber.value, context);
|
|
449
|
+
if (typeof value === "number") return value;
|
|
450
|
+
if (typeof value === "string") {
|
|
451
|
+
const text = value.trim();
|
|
452
|
+
const parsed = NUMERIC_TEXT.test(text) ? Number(text) : Number.NaN;
|
|
453
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
454
|
+
}
|
|
455
|
+
if (node.$toNumber.fallback !== void 0) return evaluate2(node.$toNumber.fallback, context);
|
|
456
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Expected a number or numeric text for $toNumber, got ${whatIs(value)}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$toNumber" });
|
|
1177
457
|
};
|
|
1178
458
|
|
|
1179
459
|
// src/ops/string.ops.ts
|
|
1180
|
-
var opJoin = (
|
|
1181
|
-
const { parts, sep = "" } =
|
|
460
|
+
var opJoin = (node, context, evaluate2) => {
|
|
461
|
+
const { parts, sep = "" } = node.$join;
|
|
1182
462
|
const list = evaluate2(parts, context);
|
|
1183
|
-
if (!Array.isArray(list)) throw new PrismError("Expected $join.parts to evaluate to an array", ErrorCode.TYPE, { op: "$join" });
|
|
463
|
+
if (!Array.isArray(list)) throw new chunk66YSI4PX_cjs.PrismError("Expected $join.parts to evaluate to an array", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$join" });
|
|
1184
464
|
return list.map((p) => String(p ?? "")).join(sep);
|
|
1185
465
|
};
|
|
1186
|
-
var opToString = (
|
|
1187
|
-
const value = evaluate2(
|
|
466
|
+
var opToString = (node, context, evaluate2) => {
|
|
467
|
+
const value = evaluate2(node.$toString, context);
|
|
1188
468
|
if (value === null) return "null";
|
|
1189
469
|
if (typeof value === "object") return JSON.stringify(value);
|
|
1190
470
|
return String(value);
|
|
1191
471
|
};
|
|
1192
|
-
var opInterpolate = (
|
|
1193
|
-
const { template, values: valuesNode } =
|
|
472
|
+
var opInterpolate = (node, context, evaluate2) => {
|
|
473
|
+
const { template, values: valuesNode } = node.$interpolate;
|
|
1194
474
|
const values = evaluate2(valuesNode, context);
|
|
1195
|
-
if (!isJsonObject(values))
|
|
1196
|
-
throw new PrismError("Expected object for $interpolate.values", ErrorCode.TYPE, { op: "$interpolate" });
|
|
475
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(values))
|
|
476
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $interpolate.values", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$interpolate" });
|
|
1197
477
|
return template.replace(
|
|
1198
478
|
/\{\{(\w+)\}\}/g,
|
|
1199
479
|
(_match, key) => String(values[key] ?? "")
|
|
@@ -1202,7 +482,7 @@ var opInterpolate = (node13, context, evaluate2) => {
|
|
|
1202
482
|
var fillOne = (value) => {
|
|
1203
483
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
|
|
1204
484
|
const { phrase, slots } = value;
|
|
1205
|
-
if (typeof phrase !== "string" || !isJsonObject(slots)) return value;
|
|
485
|
+
if (typeof phrase !== "string" || !chunk66YSI4PX_cjs.isJsonObject(slots)) return value;
|
|
1206
486
|
return phrase.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (hole, name) => {
|
|
1207
487
|
const slot = slots[name];
|
|
1208
488
|
if (slot === void 0 || slot === null) return hole;
|
|
@@ -1210,47 +490,48 @@ var fillOne = (value) => {
|
|
|
1210
490
|
return typeof filled === "object" ? hole : String(filled);
|
|
1211
491
|
});
|
|
1212
492
|
};
|
|
1213
|
-
var opFill = (
|
|
1214
|
-
var opTrim = (
|
|
1215
|
-
const value = evaluate2(
|
|
493
|
+
var opFill = (node, context, evaluate2) => fillOne(evaluate2(node.$fill, context));
|
|
494
|
+
var opTrim = (node, context, evaluate2) => {
|
|
495
|
+
const value = evaluate2(node.$trim, context);
|
|
1216
496
|
if (typeof value !== "string")
|
|
1217
|
-
throw new PrismError("Expected string for $trim", ErrorCode.TYPE, { op: "$trim" });
|
|
497
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected string for $trim", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$trim" });
|
|
1218
498
|
return value.trim();
|
|
1219
499
|
};
|
|
1220
|
-
var opLower = (
|
|
1221
|
-
const value = evaluate2(
|
|
500
|
+
var opLower = (node, context, evaluate2) => {
|
|
501
|
+
const value = evaluate2(node.$lower, context);
|
|
1222
502
|
if (typeof value !== "string")
|
|
1223
|
-
throw new PrismError("Expected string for $lower", ErrorCode.TYPE, { op: "$lower" });
|
|
503
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected string for $lower", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$lower" });
|
|
1224
504
|
return value.toLowerCase();
|
|
1225
505
|
};
|
|
1226
|
-
var opUpper = (
|
|
1227
|
-
const value = evaluate2(
|
|
506
|
+
var opUpper = (node, context, evaluate2) => {
|
|
507
|
+
const value = evaluate2(node.$upper, context);
|
|
1228
508
|
if (typeof value !== "string")
|
|
1229
|
-
throw new PrismError("Expected string for $upper", ErrorCode.TYPE, { op: "$upper" });
|
|
509
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected string for $upper", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$upper" });
|
|
1230
510
|
return value.toUpperCase();
|
|
1231
511
|
};
|
|
1232
|
-
var opSplit = (
|
|
1233
|
-
const value = evaluate2(
|
|
512
|
+
var opSplit = (node, context, evaluate2) => {
|
|
513
|
+
const value = evaluate2(node.$split.value, context);
|
|
1234
514
|
if (typeof value !== "string")
|
|
1235
|
-
throw new PrismError("Expected string for $split", ErrorCode.TYPE, { op: "$split" });
|
|
1236
|
-
return value.split(
|
|
515
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected string for $split", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$split" });
|
|
516
|
+
return value.split(node.$split.sep);
|
|
1237
517
|
};
|
|
1238
|
-
var opReplace = (
|
|
1239
|
-
const value = evaluate2(
|
|
518
|
+
var opReplace = (node, context, evaluate2) => {
|
|
519
|
+
const value = evaluate2(node.$replace.value, context);
|
|
1240
520
|
if (typeof value !== "string")
|
|
1241
|
-
throw new PrismError("Expected string for $replace", ErrorCode.TYPE, { op: "$replace" });
|
|
1242
|
-
|
|
521
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected string for $replace", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$replace" });
|
|
522
|
+
const { search, replacement, all } = node.$replace;
|
|
523
|
+
return all === true ? value.replaceAll(search, replacement) : value.replace(search, replacement);
|
|
1243
524
|
};
|
|
1244
525
|
|
|
1245
526
|
// src/ops/predicate.ops.ts
|
|
1246
|
-
var opEq = (
|
|
1247
|
-
const a = evaluate2(
|
|
1248
|
-
const b = evaluate2(
|
|
527
|
+
var opEq = (node, context, evaluate2) => {
|
|
528
|
+
const a = evaluate2(node.$eq[0], context);
|
|
529
|
+
const b = evaluate2(node.$eq[1], context);
|
|
1249
530
|
return jsonEqual(a, b);
|
|
1250
531
|
};
|
|
1251
|
-
var opNeq = (
|
|
1252
|
-
const a = evaluate2(
|
|
1253
|
-
const b = evaluate2(
|
|
532
|
+
var opNeq = (node, context, evaluate2) => {
|
|
533
|
+
const a = evaluate2(node.$neq[0], context);
|
|
534
|
+
const b = evaluate2(node.$neq[1], context);
|
|
1254
535
|
return !jsonEqual(a, b);
|
|
1255
536
|
};
|
|
1256
537
|
var compareOp = (pair, context, evaluate2, op, test) => {
|
|
@@ -1258,56 +539,56 @@ var compareOp = (pair, context, evaluate2, op, test) => {
|
|
|
1258
539
|
const b = evaluate2(pair[1], context);
|
|
1259
540
|
const cmp = compare(a, b);
|
|
1260
541
|
if (cmp === void 0)
|
|
1261
|
-
throw new PrismError(`Cannot compare values for ${op}`, ErrorCode.TYPE, { op });
|
|
542
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Cannot compare values for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
|
|
1262
543
|
return test(cmp);
|
|
1263
544
|
};
|
|
1264
|
-
var opGt = (
|
|
1265
|
-
var opGte = (
|
|
1266
|
-
var opLt = (
|
|
1267
|
-
var opLte = (
|
|
1268
|
-
var opEmpty = (
|
|
1269
|
-
const value = evaluate2(
|
|
545
|
+
var opGt = (node, ctx, ev) => compareOp(node.$gt, ctx, ev, "$gt", (c) => c > 0);
|
|
546
|
+
var opGte = (node, ctx, ev) => compareOp(node.$gte, ctx, ev, "$gte", (c) => c >= 0);
|
|
547
|
+
var opLt = (node, ctx, ev) => compareOp(node.$lt, ctx, ev, "$lt", (c) => c < 0);
|
|
548
|
+
var opLte = (node, ctx, ev) => compareOp(node.$lte, ctx, ev, "$lte", (c) => c <= 0);
|
|
549
|
+
var opEmpty = (node, context, evaluate2) => {
|
|
550
|
+
const value = evaluate2(node.$empty, context);
|
|
1270
551
|
if (value === null || value === void 0) return true;
|
|
1271
552
|
if (typeof value === "string") return value.length === 0;
|
|
1272
|
-
if (isJsonArray(value)) return value.length === 0;
|
|
1273
|
-
if (isJsonObject(value)) return Object.keys(value).length === 0;
|
|
553
|
+
if (chunk66YSI4PX_cjs.isJsonArray(value)) return value.length === 0;
|
|
554
|
+
if (chunk66YSI4PX_cjs.isJsonObject(value)) return Object.keys(value).length === 0;
|
|
1274
555
|
return false;
|
|
1275
556
|
};
|
|
1276
|
-
var opStartsWith = (
|
|
1277
|
-
const value = evaluate2(
|
|
1278
|
-
const prefix = evaluate2(
|
|
557
|
+
var opStartsWith = (node, context, evaluate2) => {
|
|
558
|
+
const value = evaluate2(node.$startsWith.value, context);
|
|
559
|
+
const prefix = evaluate2(node.$startsWith.prefix, context);
|
|
1279
560
|
if (typeof value !== "string" || typeof prefix !== "string")
|
|
1280
|
-
throw new PrismError("Expected strings for $startsWith", ErrorCode.TYPE, { op: "$startsWith" });
|
|
561
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected strings for $startsWith", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$startsWith" });
|
|
1281
562
|
return value.startsWith(prefix);
|
|
1282
563
|
};
|
|
1283
|
-
var opEndsWith = (
|
|
1284
|
-
const value = evaluate2(
|
|
1285
|
-
const suffix = evaluate2(
|
|
564
|
+
var opEndsWith = (node, context, evaluate2) => {
|
|
565
|
+
const value = evaluate2(node.$endsWith.value, context);
|
|
566
|
+
const suffix = evaluate2(node.$endsWith.suffix, context);
|
|
1286
567
|
if (typeof value !== "string" || typeof suffix !== "string")
|
|
1287
|
-
throw new PrismError("Expected strings for $endsWith", ErrorCode.TYPE, { op: "$endsWith" });
|
|
568
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected strings for $endsWith", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$endsWith" });
|
|
1288
569
|
return value.endsWith(suffix);
|
|
1289
570
|
};
|
|
1290
|
-
var opContains = (
|
|
1291
|
-
const value = evaluate2(
|
|
1292
|
-
const search = evaluate2(
|
|
571
|
+
var opContains = (node, context, evaluate2) => {
|
|
572
|
+
const value = evaluate2(node.$contains.value, context);
|
|
573
|
+
const search = evaluate2(node.$contains.search, context);
|
|
1293
574
|
if (typeof value !== "string" || typeof search !== "string")
|
|
1294
|
-
throw new PrismError("Expected strings for $contains", ErrorCode.TYPE, { op: "$contains" });
|
|
575
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected strings for $contains", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$contains" });
|
|
1295
576
|
return value.includes(search);
|
|
1296
577
|
};
|
|
1297
578
|
|
|
1298
579
|
// src/ops/logic.ops.ts
|
|
1299
|
-
var opNot = (
|
|
1300
|
-
var opAnd = (
|
|
580
|
+
var opNot = (node, context, evaluate2) => !evaluate2(node.$not, context);
|
|
581
|
+
var opAnd = (node, context, evaluate2) => {
|
|
1301
582
|
let last = true;
|
|
1302
|
-
for (const operand of
|
|
583
|
+
for (const operand of node.$and) {
|
|
1303
584
|
last = evaluate2(operand, context);
|
|
1304
585
|
if (!last) return last;
|
|
1305
586
|
}
|
|
1306
587
|
return last;
|
|
1307
588
|
};
|
|
1308
|
-
var opOr = (
|
|
589
|
+
var opOr = (node, context, evaluate2) => {
|
|
1309
590
|
let last = false;
|
|
1310
|
-
for (const operand of
|
|
591
|
+
for (const operand of node.$or) {
|
|
1311
592
|
last = evaluate2(operand, context);
|
|
1312
593
|
if (last) return last;
|
|
1313
594
|
}
|
|
@@ -1315,57 +596,61 @@ var opOr = (node13, context, evaluate2) => {
|
|
|
1315
596
|
};
|
|
1316
597
|
|
|
1317
598
|
// src/ops/structure.ops.ts
|
|
1318
|
-
var opMerge = (
|
|
599
|
+
var opMerge = (node, context, evaluate2) => {
|
|
1319
600
|
const result = {};
|
|
1320
|
-
for (const part of
|
|
601
|
+
for (const part of node.$merge) {
|
|
1321
602
|
const evaluated = evaluate2(part, context);
|
|
1322
|
-
if (!isJsonObject(evaluated))
|
|
1323
|
-
throw new PrismError("Expected object for $merge element", ErrorCode.TYPE, { op: "$merge" });
|
|
603
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(evaluated))
|
|
604
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $merge element", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$merge" });
|
|
1324
605
|
Object.assign(result, evaluated);
|
|
1325
606
|
}
|
|
1326
607
|
return result;
|
|
1327
608
|
};
|
|
1328
|
-
var opCoalesce = (
|
|
1329
|
-
for (const candidate of
|
|
609
|
+
var opCoalesce = (node, context, evaluate2) => {
|
|
610
|
+
for (const candidate of node.$coalesce) {
|
|
1330
611
|
const value = evaluate2(candidate, context);
|
|
1331
612
|
if (value !== null && value !== void 0) return value;
|
|
1332
613
|
}
|
|
1333
614
|
return null;
|
|
1334
615
|
};
|
|
1335
|
-
var opCase = (
|
|
1336
|
-
for (const branch of
|
|
616
|
+
var opCase = (node, context, evaluate2) => {
|
|
617
|
+
for (const branch of node.$case.branches) {
|
|
1337
618
|
const condition = evaluate2(branch.when, context);
|
|
1338
619
|
if (condition) return evaluate2(branch.then, context);
|
|
1339
620
|
}
|
|
1340
|
-
if (
|
|
621
|
+
if (node.$case.else !== void 0) return evaluate2(node.$case.else, context);
|
|
1341
622
|
return null;
|
|
1342
623
|
};
|
|
1343
|
-
var opEntriesOf = (
|
|
1344
|
-
const value = evaluate2(
|
|
1345
|
-
if (!isJsonObject(value))
|
|
1346
|
-
throw new PrismError("Expected object for $entriesOf", ErrorCode.TYPE, { op: "$entriesOf" });
|
|
624
|
+
var opEntriesOf = (node, context, evaluate2) => {
|
|
625
|
+
const value = evaluate2(node.$entriesOf, context);
|
|
626
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(value))
|
|
627
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $entriesOf", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$entriesOf" });
|
|
1347
628
|
return Object.entries(value).map(([k, v]) => [k, v]);
|
|
1348
629
|
};
|
|
1349
|
-
var opKeyBy = (
|
|
1350
|
-
const { over, as, key: keyExpr } =
|
|
630
|
+
var opKeyBy = (node, context, evaluate2) => {
|
|
631
|
+
const { over, as, key: keyExpr } = node.$keyBy;
|
|
1351
632
|
const input = evaluate2(over, context);
|
|
1352
|
-
if (!isJsonArray(input))
|
|
1353
|
-
throw new PrismError("Expected array for $keyBy.over", ErrorCode.TYPE, { op: "$keyBy" });
|
|
633
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(input))
|
|
634
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected array for $keyBy.over", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$keyBy" });
|
|
1354
635
|
const result = {};
|
|
636
|
+
const { scope, vars } = loopScope(context);
|
|
1355
637
|
for (const item of input) {
|
|
1356
|
-
|
|
638
|
+
vars[as] = item;
|
|
639
|
+
const key = evaluate2(keyExpr, scope);
|
|
1357
640
|
result[String(key)] = item;
|
|
1358
641
|
}
|
|
1359
642
|
return result;
|
|
1360
643
|
};
|
|
1361
|
-
var opGroupBy = (
|
|
1362
|
-
const { over, as, key: keyExpr } =
|
|
644
|
+
var opGroupBy = (node, context, evaluate2) => {
|
|
645
|
+
const { over, as, key: keyExpr } = node.$groupBy;
|
|
1363
646
|
const input = evaluate2(over, context);
|
|
1364
|
-
if (!isJsonArray(input))
|
|
1365
|
-
throw new PrismError("Expected array for $groupBy.over", ErrorCode.TYPE, { op: "$groupBy" });
|
|
647
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(input))
|
|
648
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected array for $groupBy.over", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$groupBy" });
|
|
1366
649
|
const result = {};
|
|
650
|
+
const { scope, vars } = loopScope(context);
|
|
1367
651
|
for (const item of input) {
|
|
1368
|
-
|
|
652
|
+
vars[as] = item;
|
|
653
|
+
const key = String(evaluate2(keyExpr, scope));
|
|
1369
654
|
if (!result[key]) result[key] = [];
|
|
1370
655
|
result[key].push(item);
|
|
1371
656
|
}
|
|
@@ -1373,62 +658,62 @@ var opGroupBy = (node13, context, evaluate2) => {
|
|
|
1373
658
|
};
|
|
1374
659
|
|
|
1375
660
|
// src/ops/object.ops.ts
|
|
1376
|
-
var opKeys = (
|
|
1377
|
-
const value = evaluate2(
|
|
1378
|
-
if (!isJsonObject(value))
|
|
1379
|
-
throw new PrismError("Expected object for $keys", ErrorCode.TYPE, { op: "$keys" });
|
|
661
|
+
var opKeys = (node, context, evaluate2) => {
|
|
662
|
+
const value = evaluate2(node.$keys, context);
|
|
663
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(value))
|
|
664
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $keys", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$keys" });
|
|
1380
665
|
return Object.keys(value);
|
|
1381
666
|
};
|
|
1382
|
-
var opValues = (
|
|
1383
|
-
const value = evaluate2(
|
|
1384
|
-
if (!isJsonObject(value))
|
|
1385
|
-
throw new PrismError("Expected object for $values", ErrorCode.TYPE, { op: "$values" });
|
|
667
|
+
var opValues = (node, context, evaluate2) => {
|
|
668
|
+
const value = evaluate2(node.$values, context);
|
|
669
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(value))
|
|
670
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $values", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$values" });
|
|
1386
671
|
return Object.values(value);
|
|
1387
672
|
};
|
|
1388
|
-
var opFromEntries = (
|
|
1389
|
-
const value = evaluate2(
|
|
1390
|
-
if (!isJsonArray(value))
|
|
1391
|
-
throw new PrismError("Expected array for $fromEntries", ErrorCode.TYPE, { op: "$fromEntries" });
|
|
673
|
+
var opFromEntries = (node, context, evaluate2) => {
|
|
674
|
+
const value = evaluate2(node.$fromEntries, context);
|
|
675
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(value))
|
|
676
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected array for $fromEntries", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$fromEntries" });
|
|
1392
677
|
const result = {};
|
|
1393
678
|
for (const entry of value) {
|
|
1394
|
-
if (!isJsonArray(entry) || entry.length < 2)
|
|
1395
|
-
throw new PrismError("Expected [key, value] pairs for $fromEntries", ErrorCode.TYPE, { op: "$fromEntries" });
|
|
679
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(entry) || entry.length < 2)
|
|
680
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected [key, value] pairs for $fromEntries", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$fromEntries" });
|
|
1396
681
|
result[String(entry[0])] = entry[1];
|
|
1397
682
|
}
|
|
1398
683
|
return result;
|
|
1399
684
|
};
|
|
1400
|
-
var opPick = (
|
|
1401
|
-
const value = evaluate2(
|
|
1402
|
-
if (!isJsonObject(value))
|
|
1403
|
-
throw new PrismError("Expected object for $pick", ErrorCode.TYPE, { op: "$pick" });
|
|
685
|
+
var opPick = (node, context, evaluate2) => {
|
|
686
|
+
const value = evaluate2(node.$pick.from, context);
|
|
687
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(value))
|
|
688
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $pick", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$pick" });
|
|
1404
689
|
const result = {};
|
|
1405
|
-
for (const key of
|
|
690
|
+
for (const key of node.$pick.keys) {
|
|
1406
691
|
if (key in value) result[key] = value[key];
|
|
1407
692
|
}
|
|
1408
693
|
return result;
|
|
1409
694
|
};
|
|
1410
|
-
var opOmit = (
|
|
1411
|
-
const value = evaluate2(
|
|
1412
|
-
if (!isJsonObject(value))
|
|
1413
|
-
throw new PrismError("Expected object for $omit", ErrorCode.TYPE, { op: "$omit" });
|
|
1414
|
-
const keysToOmit = new Set(
|
|
695
|
+
var opOmit = (node, context, evaluate2) => {
|
|
696
|
+
const value = evaluate2(node.$omit.from, context);
|
|
697
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(value))
|
|
698
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected object for $omit", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$omit" });
|
|
699
|
+
const keysToOmit = new Set(node.$omit.keys);
|
|
1415
700
|
const result = {};
|
|
1416
701
|
for (const [k, v] of Object.entries(value)) {
|
|
1417
702
|
if (!keysToOmit.has(k)) result[k] = v;
|
|
1418
703
|
}
|
|
1419
704
|
return result;
|
|
1420
705
|
};
|
|
1421
|
-
var opType = (
|
|
1422
|
-
const value = evaluate2(
|
|
706
|
+
var opType = (node, context, evaluate2) => {
|
|
707
|
+
const value = evaluate2(node.$type, context);
|
|
1423
708
|
if (value === null) return "null";
|
|
1424
|
-
if (isJsonArray(value)) return "array";
|
|
709
|
+
if (chunk66YSI4PX_cjs.isJsonArray(value)) return "array";
|
|
1425
710
|
return typeof value;
|
|
1426
711
|
};
|
|
1427
|
-
var opLength = (
|
|
1428
|
-
const value = evaluate2(
|
|
712
|
+
var opLength = (node, context, evaluate2) => {
|
|
713
|
+
const value = evaluate2(node.$length, context);
|
|
1429
714
|
if (typeof value === "string") return value.length;
|
|
1430
|
-
if (isJsonArray(value)) return value.length;
|
|
1431
|
-
throw new PrismError("Expected array or string for $length", ErrorCode.TYPE, { op: "$length" });
|
|
715
|
+
if (chunk66YSI4PX_cjs.isJsonArray(value)) return value.length;
|
|
716
|
+
throw new chunk66YSI4PX_cjs.PrismError("Expected array or string for $length", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$length" });
|
|
1432
717
|
};
|
|
1433
718
|
|
|
1434
719
|
// src/ops/transform.ops.ts
|
|
@@ -1436,20 +721,20 @@ var has = (value, path) => {
|
|
|
1436
721
|
let at = value;
|
|
1437
722
|
for (const segment of path) {
|
|
1438
723
|
if (typeof segment === "number") {
|
|
1439
|
-
if (!isJsonArray(at) || segment >= at.length) return false;
|
|
724
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(at) || segment >= at.length) return false;
|
|
1440
725
|
at = at[segment] ?? null;
|
|
1441
726
|
} else {
|
|
1442
|
-
if (!isJsonObject(at) || !Object.prototype.hasOwnProperty.call(at, segment)) return false;
|
|
727
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(at) || !Object.prototype.hasOwnProperty.call(at, segment)) return false;
|
|
1443
728
|
at = at[segment] ?? null;
|
|
1444
729
|
}
|
|
1445
730
|
}
|
|
1446
731
|
return true;
|
|
1447
732
|
};
|
|
1448
|
-
var opHas = (
|
|
1449
|
-
var opRenameKeys = (
|
|
1450
|
-
const value = evaluate2(
|
|
1451
|
-
if (!isJsonObject(value)) throw new PrismError("Expected object for $renameKeys", ErrorCode.TYPE, { op: "$renameKeys" });
|
|
1452
|
-
const { map } =
|
|
733
|
+
var opHas = (node, context, evaluate2) => has(evaluate2(node.$has.from, context), node.$has.path);
|
|
734
|
+
var opRenameKeys = (node, context, evaluate2) => {
|
|
735
|
+
const value = evaluate2(node.$renameKeys.from, context);
|
|
736
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(value)) throw new chunk66YSI4PX_cjs.PrismError("Expected object for $renameKeys", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$renameKeys" });
|
|
737
|
+
const { map } = node.$renameKeys;
|
|
1453
738
|
const renamedTo = new Set(Object.entries(map).filter(([from]) => Object.prototype.hasOwnProperty.call(value, from)).map(([, to]) => to));
|
|
1454
739
|
const result = {};
|
|
1455
740
|
for (const [key, v] of Object.entries(value)) {
|
|
@@ -1462,8 +747,8 @@ var opRenameKeys = (node13, context, evaluate2) => {
|
|
|
1462
747
|
var current = (value, path) => {
|
|
1463
748
|
let at = value;
|
|
1464
749
|
for (const segment of path) {
|
|
1465
|
-
if (typeof segment === "number") at = isJsonArray(at) ? at[segment] ?? null : null;
|
|
1466
|
-
else at = isJsonObject(at) ? at[segment] ?? null : null;
|
|
750
|
+
if (typeof segment === "number") at = chunk66YSI4PX_cjs.isJsonArray(at) ? at[segment] ?? null : null;
|
|
751
|
+
else at = chunk66YSI4PX_cjs.isJsonObject(at) ? at[segment] ?? null : null;
|
|
1467
752
|
}
|
|
1468
753
|
return at;
|
|
1469
754
|
};
|
|
@@ -1471,26 +756,26 @@ var setIn = (value, path, next, full) => {
|
|
|
1471
756
|
const [head, ...rest] = path;
|
|
1472
757
|
if (head === void 0) return next;
|
|
1473
758
|
if (typeof head === "number") {
|
|
1474
|
-
if (!isJsonArray(value) || head >= value.length) {
|
|
1475
|
-
throw new PrismError(`No array item at ${full.join(".")}`, ErrorCode.MISSING_PATH, { op: "$update", path: full.join(".") });
|
|
759
|
+
if (!chunk66YSI4PX_cjs.isJsonArray(value) || head >= value.length) {
|
|
760
|
+
throw new chunk66YSI4PX_cjs.PrismError(`No array item at ${full.join(".")}`, chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH, { op: "$update", path: full.join(".") });
|
|
1476
761
|
}
|
|
1477
762
|
return value.map((item, i) => i === head ? setIn(item, rest, next, full) : item);
|
|
1478
763
|
}
|
|
1479
|
-
const base = isJsonObject(value) ? value : {};
|
|
764
|
+
const base = chunk66YSI4PX_cjs.isJsonObject(value) ? value : {};
|
|
1480
765
|
return { ...base, [head]: setIn(base[head] ?? null, rest, next, full) };
|
|
1481
766
|
};
|
|
1482
|
-
var opUpdate = (
|
|
1483
|
-
const { from, path, value, as } =
|
|
767
|
+
var opUpdate = (node, context, evaluate2) => {
|
|
768
|
+
const { from, path, value, as } = node.$update;
|
|
1484
769
|
const source = evaluate2(from, context);
|
|
1485
770
|
const next = evaluate2(value, { ...context, vars: { ...context.vars, [as ?? "current"]: current(source, path) } });
|
|
1486
771
|
return setIn(source, path, next, path);
|
|
1487
772
|
};
|
|
1488
|
-
var opAssert = (
|
|
1489
|
-
if (!evaluate2(
|
|
1490
|
-
return evaluate2(
|
|
773
|
+
var opAssert = (node, context, evaluate2) => {
|
|
774
|
+
if (!evaluate2(node.$assert.when, context)) throw new chunk66YSI4PX_cjs.PrismError(node.$assert.message, chunk66YSI4PX_cjs.ErrorCode.ASSERT, { op: "$assert" });
|
|
775
|
+
return evaluate2(node.$assert.value, context);
|
|
1491
776
|
};
|
|
1492
|
-
var opWalk = (
|
|
1493
|
-
const { over, as, rules, order } =
|
|
777
|
+
var opWalk = (node, context, evaluate2) => {
|
|
778
|
+
const { over, as, rules, order } = node.$walk;
|
|
1494
779
|
const rewrite = (value) => {
|
|
1495
780
|
const scope = { ...context, vars: { ...context.vars, [as]: value } };
|
|
1496
781
|
for (const rule of rules) {
|
|
@@ -1499,8 +784,8 @@ var opWalk = (node13, context, evaluate2) => {
|
|
|
1499
784
|
return { matched: false, value };
|
|
1500
785
|
};
|
|
1501
786
|
const children = (value, visit) => {
|
|
1502
|
-
if (isJsonArray(value)) return value.map(visit);
|
|
1503
|
-
if (isJsonObject(value)) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, visit(v)]));
|
|
787
|
+
if (chunk66YSI4PX_cjs.isJsonArray(value)) return value.map(visit);
|
|
788
|
+
if (chunk66YSI4PX_cjs.isJsonObject(value)) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, visit(v)]));
|
|
1504
789
|
return value;
|
|
1505
790
|
};
|
|
1506
791
|
const post = (value) => rewrite(children(value, post)).value;
|
|
@@ -1512,31 +797,31 @@ var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
|
1512
797
|
var isDateOnly = (value) => typeof value === "string" && DATE_ONLY.test(value);
|
|
1513
798
|
var parseDate = (value, op) => {
|
|
1514
799
|
if (typeof value !== "string" && typeof value !== "number")
|
|
1515
|
-
throw new PrismError(`Expected string or number for ${op}`, ErrorCode.TYPE, { op });
|
|
800
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Expected string or number for ${op}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
|
|
1516
801
|
const d = isDateOnly(value) ? dayjs__default.default.utc(value) : dayjs__default.default(value);
|
|
1517
802
|
if (!d.isValid())
|
|
1518
|
-
throw new PrismError(`Invalid date for ${op}: ${String(value)}`, ErrorCode.DATE_INVALID, { op });
|
|
803
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Invalid date for ${op}: ${String(value)}`, chunk66YSI4PX_cjs.ErrorCode.DATE_INVALID, { op });
|
|
1519
804
|
return d;
|
|
1520
805
|
};
|
|
1521
|
-
var opDate = (
|
|
1522
|
-
const value = evaluate2(
|
|
806
|
+
var opDate = (node, context, evaluate2) => {
|
|
807
|
+
const value = evaluate2(node.$date.value, context);
|
|
1523
808
|
const d = parseDate(value, "$date");
|
|
1524
|
-
const instance =
|
|
1525
|
-
if (
|
|
809
|
+
const instance = node.$date.utc ? d.utc() : d;
|
|
810
|
+
if (node.$date.format) return instance.format(node.$date.format);
|
|
1526
811
|
return instance.toISOString();
|
|
1527
812
|
};
|
|
1528
|
-
var opDateAdd = (
|
|
1529
|
-
const value = evaluate2(
|
|
813
|
+
var opDateAdd = (node, context, evaluate2) => {
|
|
814
|
+
const value = evaluate2(node.$dateAdd.date, context);
|
|
1530
815
|
const d = parseDate(value, "$dateAdd");
|
|
1531
|
-
const moved = d.add(
|
|
816
|
+
const moved = d.add(node.$dateAdd.amount, node.$dateAdd.unit);
|
|
1532
817
|
return isDateOnly(value) ? moved.format("YYYY-MM-DD") : moved.toISOString();
|
|
1533
818
|
};
|
|
1534
|
-
var opDateDiff = (
|
|
1535
|
-
const from = evaluate2(
|
|
1536
|
-
const to = evaluate2(
|
|
819
|
+
var opDateDiff = (node, context, evaluate2) => {
|
|
820
|
+
const from = evaluate2(node.$dateDiff.from, context);
|
|
821
|
+
const to = evaluate2(node.$dateDiff.to, context);
|
|
1537
822
|
const fromDate = parseDate(from, "$dateDiff.from");
|
|
1538
823
|
const toDate = parseDate(to, "$dateDiff.to");
|
|
1539
|
-
return toDate.diff(fromDate,
|
|
824
|
+
return toDate.diff(fromDate, node.$dateDiff.unit);
|
|
1540
825
|
};
|
|
1541
826
|
|
|
1542
827
|
// src/ops/intl.ops.ts
|
|
@@ -1545,7 +830,7 @@ var NUMBER_FORMATTERS = /* @__PURE__ */ new Map();
|
|
|
1545
830
|
var DATE_ONLY2 = /^\d{4}-\d{2}-\d{2}$/;
|
|
1546
831
|
var localeOf = (value, op) => {
|
|
1547
832
|
if (typeof value !== "string" || value.trim() === "")
|
|
1548
|
-
throw new PrismError(`${op} needs a locale tag (e.g. "de-AT")`, ErrorCode.TYPE, { op });
|
|
833
|
+
throw new chunk66YSI4PX_cjs.PrismError(`${op} needs a locale tag (e.g. "de-AT")`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
|
|
1549
834
|
return value;
|
|
1550
835
|
};
|
|
1551
836
|
var isBlank = (value) => value === null || value === void 0 || value === "";
|
|
@@ -1556,11 +841,11 @@ var fallbackOf = (raw, context, evaluate2) => {
|
|
|
1556
841
|
};
|
|
1557
842
|
var numberOf = (value, op) => {
|
|
1558
843
|
const parsed = typeof value === "number" ? value : Number(value);
|
|
1559
|
-
if (!Number.isFinite(parsed)) throw new PrismError(`${op} expected a number, got ${JSON.stringify(value)}`, ErrorCode.TYPE, { op });
|
|
844
|
+
if (!Number.isFinite(parsed)) throw new chunk66YSI4PX_cjs.PrismError(`${op} expected a number, got ${JSON.stringify(value)}`, chunk66YSI4PX_cjs.ErrorCode.TYPE, { op });
|
|
1560
845
|
return parsed;
|
|
1561
846
|
};
|
|
1562
|
-
var opLocaleDate = (
|
|
1563
|
-
const spec =
|
|
847
|
+
var opLocaleDate = (node, context, evaluate2) => {
|
|
848
|
+
const spec = node.$localeDate;
|
|
1564
849
|
const value = evaluate2(spec.value, context);
|
|
1565
850
|
if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
|
|
1566
851
|
const locale = localeOf(evaluate2(spec.locale, context), "$localeDate");
|
|
@@ -1572,7 +857,7 @@ var opLocaleDate = (node13, context, evaluate2) => {
|
|
|
1572
857
|
};
|
|
1573
858
|
const parsed = typeof value === "number" ? new Date(value) : new Date(String(value));
|
|
1574
859
|
if (Number.isNaN(parsed.getTime()))
|
|
1575
|
-
throw new PrismError(`Invalid date for $localeDate: ${String(value)}`, ErrorCode.DATE_INVALID, { op: "$localeDate" });
|
|
860
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Invalid date for $localeDate: ${String(value)}`, chunk66YSI4PX_cjs.ErrorCode.DATE_INVALID, { op: "$localeDate" });
|
|
1576
861
|
const key = `${locale}\0${JSON.stringify(options)}`;
|
|
1577
862
|
let formatter = DATE_FORMATTERS.get(key);
|
|
1578
863
|
if (formatter === void 0) {
|
|
@@ -1594,14 +879,14 @@ var minorUnitDivisor = (locale, currency) => {
|
|
|
1594
879
|
}
|
|
1595
880
|
return 10 ** (formatter.resolvedOptions().maximumFractionDigits ?? 2);
|
|
1596
881
|
};
|
|
1597
|
-
var opLocaleMoney = (
|
|
1598
|
-
const spec =
|
|
882
|
+
var opLocaleMoney = (node, context, evaluate2) => {
|
|
883
|
+
const spec = node.$localeMoney;
|
|
1599
884
|
const value = evaluate2(spec.value, context);
|
|
1600
885
|
if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
|
|
1601
886
|
const locale = localeOf(evaluate2(spec.locale, context), "$localeMoney");
|
|
1602
887
|
const rawCurrency = evaluate2(spec.currency, context);
|
|
1603
888
|
if (typeof rawCurrency !== "string" || rawCurrency.trim() === "")
|
|
1604
|
-
throw new PrismError("$localeMoney needs an ISO-4217 currency code", ErrorCode.TYPE, { op: "$localeMoney" });
|
|
889
|
+
throw new chunk66YSI4PX_cjs.PrismError("$localeMoney needs an ISO-4217 currency code", chunk66YSI4PX_cjs.ErrorCode.TYPE, { op: "$localeMoney" });
|
|
1605
890
|
const currency = rawCurrency.toUpperCase();
|
|
1606
891
|
const amount = numberOf(value, "$localeMoney");
|
|
1607
892
|
const major = spec.minorUnits === false ? amount : amount / minorUnitDivisor(locale, currency);
|
|
@@ -1622,8 +907,8 @@ var opLocaleMoney = (node13, context, evaluate2) => {
|
|
|
1622
907
|
}
|
|
1623
908
|
return formatter.format(major);
|
|
1624
909
|
};
|
|
1625
|
-
var opLocaleNumber = (
|
|
1626
|
-
const spec =
|
|
910
|
+
var opLocaleNumber = (node, context, evaluate2) => {
|
|
911
|
+
const spec = node.$localeNumber;
|
|
1627
912
|
const value = evaluate2(spec.value, context);
|
|
1628
913
|
if (isBlank(value)) return fallbackOf(spec.fallback, context, evaluate2);
|
|
1629
914
|
const locale = localeOf(evaluate2(spec.locale, context), "$localeNumber");
|
|
@@ -1642,156 +927,10 @@ var opLocaleNumber = (node13, context, evaluate2) => {
|
|
|
1642
927
|
return formatter.format(numberOf(value, "$localeNumber"));
|
|
1643
928
|
};
|
|
1644
929
|
|
|
1645
|
-
// src/engine/evaluate.ts
|
|
1646
|
-
var HANDLER_KEY = "__op";
|
|
1647
|
-
var isAttachedFn = (value) => typeof value === "function";
|
|
1648
|
-
var evaluateNode = (node13, context) => {
|
|
1649
|
-
const { budget } = context;
|
|
1650
|
-
if (budget === void 0) return evaluateUnbudgeted(node13, context);
|
|
1651
|
-
spendStep(budget);
|
|
1652
|
-
const out = evaluateUnbudgeted(node13, context);
|
|
1653
|
-
measureString(out, budget);
|
|
1654
|
-
return out;
|
|
1655
|
-
};
|
|
1656
|
-
var evaluateUnbudgeted = (node13, context) => {
|
|
1657
|
-
if (node13 === null || node13 === void 0) return null;
|
|
1658
|
-
if (typeof node13 === "string" || typeof node13 === "number" || typeof node13 === "boolean") return node13;
|
|
1659
|
-
if (Array.isArray(node13)) return node13.map((n) => evaluateNode(n, context));
|
|
1660
|
-
if (typeof node13 !== "object") return null;
|
|
1661
|
-
const obj = node13;
|
|
1662
|
-
const attached = obj[HANDLER_KEY];
|
|
1663
|
-
if (isAttachedFn(attached)) return attached(obj, context, evaluateNode);
|
|
1664
|
-
if (isRefNode(obj)) return opRef(obj, context);
|
|
1665
|
-
if (isConstNode(obj)) return opConst(obj);
|
|
1666
|
-
if (isVarNode(obj)) return opVar(obj, context);
|
|
1667
|
-
if (isGetNode(obj)) return opGet(obj, context, evaluateNode);
|
|
1668
|
-
if (isWithNode(obj)) return opWith(obj, context, evaluateNode);
|
|
1669
|
-
if (isMapNode(obj)) return opMap(obj, context, evaluateNode);
|
|
1670
|
-
if (isFilterNode(obj)) return opFilter(obj, context, evaluateNode);
|
|
1671
|
-
if (isReduceNode(obj)) return opReduce(obj, context, evaluateNode);
|
|
1672
|
-
if (isSliceNode(obj)) return opSlice(obj, context, evaluateNode);
|
|
1673
|
-
if (isFlattenNode(obj)) return opFlatten(obj, context, evaluateNode);
|
|
1674
|
-
if (isUniqueNode(obj)) return opUnique(obj, context, evaluateNode);
|
|
1675
|
-
if (isSortByNode(obj)) return opSortBy(obj, context, evaluateNode);
|
|
1676
|
-
if (isAddNode(obj)) return opAdd(obj, context, evaluateNode);
|
|
1677
|
-
if (isSubNode(obj)) return opSub(obj, context, evaluateNode);
|
|
1678
|
-
if (isMulNode(obj)) return opMul(obj, context, evaluateNode);
|
|
1679
|
-
if (isDivNode(obj)) return opDiv(obj, context, evaluateNode);
|
|
1680
|
-
if (isRoundNode(obj)) return opRound(obj, context, evaluateNode);
|
|
1681
|
-
if (isJoinNode(obj)) return opJoin(obj, context, evaluateNode);
|
|
1682
|
-
if (isToStringNode(obj)) return opToString(obj, context, evaluateNode);
|
|
1683
|
-
if (isInterpolateNode(obj)) return opInterpolate(obj, context, evaluateNode);
|
|
1684
|
-
if (isFillNode(obj)) return opFill(obj, context, evaluateNode);
|
|
1685
|
-
if (isTrimNode(obj)) return opTrim(obj, context, evaluateNode);
|
|
1686
|
-
if (isLowerNode(obj)) return opLower(obj, context, evaluateNode);
|
|
1687
|
-
if (isUpperNode(obj)) return opUpper(obj, context, evaluateNode);
|
|
1688
|
-
if (isSplitNode(obj)) return opSplit(obj, context, evaluateNode);
|
|
1689
|
-
if (isReplaceNode(obj)) return opReplace(obj, context, evaluateNode);
|
|
1690
|
-
if (isEqNode(obj)) return opEq(obj, context, evaluateNode);
|
|
1691
|
-
if (isNeqNode(obj)) return opNeq(obj, context, evaluateNode);
|
|
1692
|
-
if (isGtNode(obj)) return opGt(obj, context, evaluateNode);
|
|
1693
|
-
if (isGteNode(obj)) return opGte(obj, context, evaluateNode);
|
|
1694
|
-
if (isLtNode(obj)) return opLt(obj, context, evaluateNode);
|
|
1695
|
-
if (isLteNode(obj)) return opLte(obj, context, evaluateNode);
|
|
1696
|
-
if (isEmptyNode(obj)) return opEmpty(obj, context, evaluateNode);
|
|
1697
|
-
if (isStartsWithNode(obj)) return opStartsWith(obj, context, evaluateNode);
|
|
1698
|
-
if (isEndsWithNode(obj)) return opEndsWith(obj, context, evaluateNode);
|
|
1699
|
-
if (isContainsNode(obj)) return opContains(obj, context, evaluateNode);
|
|
1700
|
-
if (isNotNode(obj)) return opNot(obj, context, evaluateNode);
|
|
1701
|
-
if (isAndNode(obj)) return opAnd(obj, context, evaluateNode);
|
|
1702
|
-
if (isOrNode(obj)) return opOr(obj, context, evaluateNode);
|
|
1703
|
-
if (isMergeNode(obj)) return opMerge(obj, context, evaluateNode);
|
|
1704
|
-
if (isCoalesceNode(obj)) return opCoalesce(obj, context, evaluateNode);
|
|
1705
|
-
if (isCaseNode(obj)) return opCase(obj, context, evaluateNode);
|
|
1706
|
-
if (isEntriesOfNode(obj)) return opEntriesOf(obj, context, evaluateNode);
|
|
1707
|
-
if (isKeyByNode(obj)) return opKeyBy(obj, context, evaluateNode);
|
|
1708
|
-
if (isGroupByNode(obj)) return opGroupBy(obj, context, evaluateNode);
|
|
1709
|
-
if (isKeysNode(obj)) return opKeys(obj, context, evaluateNode);
|
|
1710
|
-
if (isValuesNode(obj)) return opValues(obj, context, evaluateNode);
|
|
1711
|
-
if (isFromEntriesNode(obj)) return opFromEntries(obj, context, evaluateNode);
|
|
1712
|
-
if (isPickNode(obj)) return opPick(obj, context, evaluateNode);
|
|
1713
|
-
if (isOmitNode(obj)) return opOmit(obj, context, evaluateNode);
|
|
1714
|
-
if (isTypeNode(obj)) return opType(obj, context, evaluateNode);
|
|
1715
|
-
if (isLengthNode(obj)) return opLength(obj, context, evaluateNode);
|
|
1716
|
-
if (isHasNode(obj)) return opHas(obj, context, evaluateNode);
|
|
1717
|
-
if (isRenameKeysNode(obj)) return opRenameKeys(obj, context, evaluateNode);
|
|
1718
|
-
if (isUpdateNode(obj)) return opUpdate(obj, context, evaluateNode);
|
|
1719
|
-
if (isAssertNode(obj)) return opAssert(obj, context, evaluateNode);
|
|
1720
|
-
if (isWalkNode(obj)) return opWalk(obj, context, evaluateNode);
|
|
1721
|
-
if (isDateNode(obj)) return opDate(obj, context, evaluateNode);
|
|
1722
|
-
if (isDateAddNode(obj)) return opDateAdd(obj, context, evaluateNode);
|
|
1723
|
-
if (isDateDiffNode(obj)) return opDateDiff(obj, context, evaluateNode);
|
|
1724
|
-
if (isLocaleDateNode(obj)) return opLocaleDate(obj, context, evaluateNode);
|
|
1725
|
-
if (isLocaleMoneyNode(obj)) return opLocaleMoney(obj, context, evaluateNode);
|
|
1726
|
-
if (isLocaleNumberNode(obj)) return opLocaleNumber(obj, context, evaluateNode);
|
|
1727
|
-
if (isPlainObject(obj)) {
|
|
1728
|
-
const optionalFields = new Set(
|
|
1729
|
-
Array.isArray(obj[OPTIONAL_FIELDS_KEY]) ? obj[OPTIONAL_FIELDS_KEY] : []
|
|
1730
|
-
);
|
|
1731
|
-
const result = {};
|
|
1732
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
1733
|
-
if (key === OPTIONAL_FIELDS_KEY) continue;
|
|
1734
|
-
const isOptional = optionalFields.has(key);
|
|
1735
|
-
try {
|
|
1736
|
-
const evaluated = evaluateNode(value, context);
|
|
1737
|
-
if (isOptional && (evaluated === null || evaluated === void 0)) continue;
|
|
1738
|
-
result[key] = evaluated;
|
|
1739
|
-
} catch (error) {
|
|
1740
|
-
if (isOptional && error instanceof PrismError && error.code === ErrorCode.MISSING_PATH) continue;
|
|
1741
|
-
throw error;
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
return result;
|
|
1745
|
-
}
|
|
1746
|
-
const unknownKeys = Object.keys(obj).filter((k) => k.startsWith("$"));
|
|
1747
|
-
throw new PrismError("Unsupported node shape", ErrorCode.NODE_SHAPE, {
|
|
1748
|
-
details: { keys: unknownKeys, preview: JSON.stringify(obj).slice(0, 100) }
|
|
1749
|
-
});
|
|
1750
|
-
};
|
|
1751
|
-
var evaluate = (config, source, limits) => {
|
|
1752
|
-
if (strata.exceedsDepth(config)) throw new PrismError("Invalid config", ErrorCode.SCHEMA, { details: { issues: [{ path: "root", message: strata.depthRefusal() }] } });
|
|
1753
|
-
const parsed = ConfigSchema.safeParse(config);
|
|
1754
|
-
if (!parsed.success) {
|
|
1755
|
-
const issues = explainIssues(parsed.error.issues).map((i) => ({ path: i.path.join(".") || "root", message: i.message }));
|
|
1756
|
-
throw new PrismError("Invalid config", ErrorCode.SCHEMA, { details: { issues } });
|
|
1757
|
-
}
|
|
1758
|
-
const desugared = desugar(parsed.data);
|
|
1759
|
-
const budget = createBudget(limits);
|
|
1760
|
-
const result = evaluateNode(desugared, { source, vars: {}, budget });
|
|
1761
|
-
measure(result, budget);
|
|
1762
|
-
return result;
|
|
1763
|
-
};
|
|
1764
|
-
var evaluateSafe = (config, source, limits) => {
|
|
1765
|
-
try {
|
|
1766
|
-
return { ok: true, data: evaluate(config, source, limits) };
|
|
1767
|
-
} catch (error) {
|
|
1768
|
-
return { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
|
|
1769
|
-
}
|
|
1770
|
-
};
|
|
1771
|
-
|
|
1772
|
-
// src/engine/transform.ts
|
|
1773
|
-
var isJsonValue = (value) => {
|
|
1774
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
1775
|
-
if (typeof value === "number") return Number.isFinite(value);
|
|
1776
|
-
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
1777
|
-
if (typeof value === "object") return Object.values(value).every(isJsonValue);
|
|
1778
|
-
return false;
|
|
1779
|
-
};
|
|
1780
|
-
var parsedConfigs = /* @__PURE__ */ new WeakMap();
|
|
1781
|
-
var prismTransform = (config, source) => {
|
|
1782
|
-
if (!isJsonValue(source)) throw new Error("The source of a transform must be plain JSON.");
|
|
1783
|
-
const cached = typeof config === "object" && config !== null ? parsedConfigs.get(config) : void 0;
|
|
1784
|
-
const parsed = cached ?? ConfigSchema.parse(config);
|
|
1785
|
-
if (cached === void 0 && typeof config === "object" && config !== null) parsedConfigs.set(config, parsed);
|
|
1786
|
-
return evaluate(parsed, source);
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
930
|
// src/engine/optimize.ts
|
|
1790
|
-
var
|
|
931
|
+
var HANDLER_KEY = "__op";
|
|
1791
932
|
var SEGMENTS_KEY2 = "__segments";
|
|
1792
|
-
var eraseOp = (op) =>
|
|
1793
|
-
return op.call(void 0, node13, context, evaluate2);
|
|
1794
|
-
};
|
|
933
|
+
var eraseOp = (op) => op;
|
|
1795
934
|
var attachNonEnumerable = (target, key, value) => {
|
|
1796
935
|
Object.defineProperty(target, key, {
|
|
1797
936
|
value,
|
|
@@ -1800,105 +939,121 @@ var attachNonEnumerable = (target, key, value) => {
|
|
|
1800
939
|
configurable: true
|
|
1801
940
|
});
|
|
1802
941
|
};
|
|
1803
|
-
var isPlainObject2 = (value) => isJsonObject(value);
|
|
1804
|
-
var
|
|
1805
|
-
if (
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
if (
|
|
1811
|
-
if (
|
|
1812
|
-
if (
|
|
1813
|
-
if (
|
|
1814
|
-
if (
|
|
1815
|
-
if (
|
|
1816
|
-
if (
|
|
1817
|
-
if (
|
|
1818
|
-
if (
|
|
1819
|
-
if (
|
|
1820
|
-
if (
|
|
1821
|
-
if (
|
|
1822
|
-
if (
|
|
1823
|
-
if (
|
|
1824
|
-
if (
|
|
1825
|
-
if (
|
|
1826
|
-
if (
|
|
1827
|
-
if (
|
|
1828
|
-
if (
|
|
1829
|
-
if (
|
|
1830
|
-
if (
|
|
1831
|
-
if (
|
|
1832
|
-
if (
|
|
1833
|
-
if (
|
|
1834
|
-
if (
|
|
1835
|
-
if (
|
|
1836
|
-
if (
|
|
1837
|
-
if (
|
|
1838
|
-
if (
|
|
1839
|
-
if (
|
|
1840
|
-
if (
|
|
1841
|
-
if (
|
|
1842
|
-
if (
|
|
1843
|
-
if (
|
|
1844
|
-
if (
|
|
1845
|
-
if (
|
|
1846
|
-
if (
|
|
1847
|
-
if (
|
|
1848
|
-
if (
|
|
1849
|
-
if (
|
|
1850
|
-
if (
|
|
1851
|
-
if (
|
|
1852
|
-
if (
|
|
1853
|
-
if (
|
|
1854
|
-
if (
|
|
1855
|
-
if (
|
|
1856
|
-
if (
|
|
1857
|
-
if (
|
|
1858
|
-
if (
|
|
1859
|
-
if (
|
|
1860
|
-
if (
|
|
1861
|
-
if (
|
|
1862
|
-
if (
|
|
1863
|
-
if (
|
|
1864
|
-
if (
|
|
1865
|
-
if (
|
|
1866
|
-
if (
|
|
1867
|
-
if (
|
|
942
|
+
var isPlainObject2 = (value) => chunk66YSI4PX_cjs.isJsonObject(value);
|
|
943
|
+
var freezeConstant = (value) => {
|
|
944
|
+
if (value === null || typeof value !== "object" || Object.isFrozen(value)) return;
|
|
945
|
+
Object.freeze(value);
|
|
946
|
+
for (const inner of Object.values(value)) freezeConstant(inner);
|
|
947
|
+
};
|
|
948
|
+
var resolveHandler = (node) => {
|
|
949
|
+
if (chunk66YSI4PX_cjs.isRefNode(node)) return eraseOp(opRef);
|
|
950
|
+
if (chunk66YSI4PX_cjs.isConstNode(node)) return eraseOp(opConst);
|
|
951
|
+
if (chunk66YSI4PX_cjs.isVarNode(node)) return eraseOp(opVar);
|
|
952
|
+
if (chunk66YSI4PX_cjs.isGetNode(node)) return eraseOp(opGet);
|
|
953
|
+
if (chunk66YSI4PX_cjs.isWithNode(node)) return eraseOp(opWith);
|
|
954
|
+
if (chunk66YSI4PX_cjs.isMapNode(node)) return eraseOp(opMap);
|
|
955
|
+
if (chunk66YSI4PX_cjs.isFilterNode(node)) return eraseOp(opFilter);
|
|
956
|
+
if (chunk66YSI4PX_cjs.isReduceNode(node)) return eraseOp(opReduce);
|
|
957
|
+
if (chunk66YSI4PX_cjs.isSliceNode(node)) return eraseOp(opSlice);
|
|
958
|
+
if (chunk66YSI4PX_cjs.isFlattenNode(node)) return eraseOp(opFlatten);
|
|
959
|
+
if (chunk66YSI4PX_cjs.isUniqueNode(node)) return eraseOp(opUnique);
|
|
960
|
+
if (chunk66YSI4PX_cjs.isSortByNode(node)) return eraseOp(opSortBy);
|
|
961
|
+
if (chunk66YSI4PX_cjs.isAddNode(node)) return eraseOp(opAdd);
|
|
962
|
+
if (chunk66YSI4PX_cjs.isSubNode(node)) return eraseOp(opSub);
|
|
963
|
+
if (chunk66YSI4PX_cjs.isMulNode(node)) return eraseOp(opMul);
|
|
964
|
+
if (chunk66YSI4PX_cjs.isDivNode(node)) return eraseOp(opDiv);
|
|
965
|
+
if (chunk66YSI4PX_cjs.isRoundNode(node)) return eraseOp(opRound);
|
|
966
|
+
if (chunk66YSI4PX_cjs.isModNode(node)) return eraseOp(opMod);
|
|
967
|
+
if (chunk66YSI4PX_cjs.isToNumberNode(node)) return eraseOp(opToNumber);
|
|
968
|
+
if (chunk66YSI4PX_cjs.isJoinNode(node)) return eraseOp(opJoin);
|
|
969
|
+
if (chunk66YSI4PX_cjs.isToStringNode(node)) return eraseOp(opToString);
|
|
970
|
+
if (chunk66YSI4PX_cjs.isInterpolateNode(node)) return eraseOp(opInterpolate);
|
|
971
|
+
if (chunk66YSI4PX_cjs.isFillNode(node)) return eraseOp(opFill);
|
|
972
|
+
if (chunk66YSI4PX_cjs.isTrimNode(node)) return eraseOp(opTrim);
|
|
973
|
+
if (chunk66YSI4PX_cjs.isLowerNode(node)) return eraseOp(opLower);
|
|
974
|
+
if (chunk66YSI4PX_cjs.isUpperNode(node)) return eraseOp(opUpper);
|
|
975
|
+
if (chunk66YSI4PX_cjs.isSplitNode(node)) return eraseOp(opSplit);
|
|
976
|
+
if (chunk66YSI4PX_cjs.isReplaceNode(node)) return eraseOp(opReplace);
|
|
977
|
+
if (chunk66YSI4PX_cjs.isEqNode(node)) return eraseOp(opEq);
|
|
978
|
+
if (chunk66YSI4PX_cjs.isNeqNode(node)) return eraseOp(opNeq);
|
|
979
|
+
if (chunk66YSI4PX_cjs.isGtNode(node)) return eraseOp(opGt);
|
|
980
|
+
if (chunk66YSI4PX_cjs.isGteNode(node)) return eraseOp(opGte);
|
|
981
|
+
if (chunk66YSI4PX_cjs.isLtNode(node)) return eraseOp(opLt);
|
|
982
|
+
if (chunk66YSI4PX_cjs.isLteNode(node)) return eraseOp(opLte);
|
|
983
|
+
if (chunk66YSI4PX_cjs.isEmptyNode(node)) return eraseOp(opEmpty);
|
|
984
|
+
if (chunk66YSI4PX_cjs.isStartsWithNode(node)) return eraseOp(opStartsWith);
|
|
985
|
+
if (chunk66YSI4PX_cjs.isEndsWithNode(node)) return eraseOp(opEndsWith);
|
|
986
|
+
if (chunk66YSI4PX_cjs.isContainsNode(node)) return eraseOp(opContains);
|
|
987
|
+
if (chunk66YSI4PX_cjs.isNotNode(node)) return eraseOp(opNot);
|
|
988
|
+
if (chunk66YSI4PX_cjs.isAndNode(node)) return eraseOp(opAnd);
|
|
989
|
+
if (chunk66YSI4PX_cjs.isOrNode(node)) return eraseOp(opOr);
|
|
990
|
+
if (chunk66YSI4PX_cjs.isMergeNode(node)) return eraseOp(opMerge);
|
|
991
|
+
if (chunk66YSI4PX_cjs.isCoalesceNode(node)) return eraseOp(opCoalesce);
|
|
992
|
+
if (chunk66YSI4PX_cjs.isCaseNode(node)) return eraseOp(opCase);
|
|
993
|
+
if (chunk66YSI4PX_cjs.isEntriesOfNode(node)) return eraseOp(opEntriesOf);
|
|
994
|
+
if (chunk66YSI4PX_cjs.isKeyByNode(node)) return eraseOp(opKeyBy);
|
|
995
|
+
if (chunk66YSI4PX_cjs.isGroupByNode(node)) return eraseOp(opGroupBy);
|
|
996
|
+
if (chunk66YSI4PX_cjs.isKeysNode(node)) return eraseOp(opKeys);
|
|
997
|
+
if (chunk66YSI4PX_cjs.isValuesNode(node)) return eraseOp(opValues);
|
|
998
|
+
if (chunk66YSI4PX_cjs.isFromEntriesNode(node)) return eraseOp(opFromEntries);
|
|
999
|
+
if (chunk66YSI4PX_cjs.isPickNode(node)) return eraseOp(opPick);
|
|
1000
|
+
if (chunk66YSI4PX_cjs.isOmitNode(node)) return eraseOp(opOmit);
|
|
1001
|
+
if (chunk66YSI4PX_cjs.isTypeNode(node)) return eraseOp(opType);
|
|
1002
|
+
if (chunk66YSI4PX_cjs.isLengthNode(node)) return eraseOp(opLength);
|
|
1003
|
+
if (chunk66YSI4PX_cjs.isHasNode(node)) return eraseOp(opHas);
|
|
1004
|
+
if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) return eraseOp(opRenameKeys);
|
|
1005
|
+
if (chunk66YSI4PX_cjs.isUpdateNode(node)) return eraseOp(opUpdate);
|
|
1006
|
+
if (chunk66YSI4PX_cjs.isAssertNode(node)) return eraseOp(opAssert);
|
|
1007
|
+
if (chunk66YSI4PX_cjs.isWalkNode(node)) return eraseOp(opWalk);
|
|
1008
|
+
if (chunk66YSI4PX_cjs.isDateNode(node)) return eraseOp(opDate);
|
|
1009
|
+
if (chunk66YSI4PX_cjs.isDateAddNode(node)) return eraseOp(opDateAdd);
|
|
1010
|
+
if (chunk66YSI4PX_cjs.isDateDiffNode(node)) return eraseOp(opDateDiff);
|
|
1011
|
+
if (chunk66YSI4PX_cjs.isLocaleDateNode(node)) return eraseOp(opLocaleDate);
|
|
1012
|
+
if (chunk66YSI4PX_cjs.isLocaleMoneyNode(node)) return eraseOp(opLocaleMoney);
|
|
1013
|
+
if (chunk66YSI4PX_cjs.isLocaleNumberNode(node)) return eraseOp(opLocaleNumber);
|
|
1868
1014
|
return void 0;
|
|
1869
1015
|
};
|
|
1870
|
-
var isFoldableLiteral = (
|
|
1871
|
-
if (
|
|
1872
|
-
const t = typeof
|
|
1016
|
+
var isFoldableLiteral = (node) => {
|
|
1017
|
+
if (node === null || node === void 0) return true;
|
|
1018
|
+
const t = typeof node;
|
|
1873
1019
|
if (t === "string" || t === "number" || t === "boolean") return true;
|
|
1874
|
-
if (Array.isArray(
|
|
1875
|
-
if (!isPlainObject2(
|
|
1876
|
-
if (isConstNode(
|
|
1877
|
-
if (Object.keys(
|
|
1878
|
-
return Object.values(
|
|
1879
|
-
};
|
|
1880
|
-
var optimizeNode = (
|
|
1881
|
-
if (
|
|
1882
|
-
if (typeof
|
|
1883
|
-
if (Array.isArray(
|
|
1020
|
+
if (Array.isArray(node)) return node.every(isFoldableLiteral);
|
|
1021
|
+
if (!isPlainObject2(node)) return false;
|
|
1022
|
+
if (chunk66YSI4PX_cjs.isConstNode(node)) return isFoldableLiteral(node.$const);
|
|
1023
|
+
if (Object.keys(node).some((k) => k.startsWith("$"))) return false;
|
|
1024
|
+
return Object.values(node).every(isFoldableLiteral);
|
|
1025
|
+
};
|
|
1026
|
+
var optimizeNode = (node, stats, evaluate2) => {
|
|
1027
|
+
if (node === null || node === void 0) return node;
|
|
1028
|
+
if (typeof node !== "object") return node;
|
|
1029
|
+
if (Array.isArray(node)) {
|
|
1884
1030
|
const out = [];
|
|
1885
|
-
for (const child of
|
|
1031
|
+
for (const child of node) out.push(optimizeNode(child, stats, evaluate2));
|
|
1886
1032
|
return out;
|
|
1887
1033
|
}
|
|
1888
|
-
if (!isPlainObject2(
|
|
1889
|
-
if (isConstNode(
|
|
1890
|
-
const literal = { ...
|
|
1891
|
-
|
|
1034
|
+
if (!isPlainObject2(node)) return node;
|
|
1035
|
+
if (chunk66YSI4PX_cjs.isConstNode(node)) {
|
|
1036
|
+
const literal = { ...node };
|
|
1037
|
+
freezeConstant(literal["$const"]);
|
|
1038
|
+
attachNonEnumerable(literal, HANDLER_KEY, eraseOp(opConst));
|
|
1892
1039
|
stats.handlersAttached += 1;
|
|
1893
1040
|
return literal;
|
|
1894
1041
|
}
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1042
|
+
const optimizeValues = (record) => {
|
|
1043
|
+
const out = {};
|
|
1044
|
+
for (const key of Object.keys(record)) out[key] = optimizeNode(record[key], stats, evaluate2);
|
|
1045
|
+
return out;
|
|
1046
|
+
};
|
|
1047
|
+
let optimized;
|
|
1048
|
+
if (chunk66YSI4PX_cjs.isWithNode(node)) {
|
|
1049
|
+
optimized = { $with: { let: optimizeValues(node.$with.let), value: optimizeNode(node.$with.value, stats, evaluate2) } };
|
|
1050
|
+
} else if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) {
|
|
1051
|
+
optimized = { $renameKeys: { ...node.$renameKeys, from: optimizeNode(node.$renameKeys.from, stats, evaluate2) } };
|
|
1052
|
+
} else {
|
|
1053
|
+
optimized = optimizeValues(node);
|
|
1054
|
+
}
|
|
1055
|
+
if (chunk66YSI4PX_cjs.isRefNode(optimized)) {
|
|
1056
|
+
const segments = chunk66YSI4PX_cjs.parseJsonPath(optimized.$ref);
|
|
1902
1057
|
if (segments.length > 0) {
|
|
1903
1058
|
attachNonEnumerable(optimized, SEGMENTS_KEY2, segments);
|
|
1904
1059
|
stats.refsInlined += 1;
|
|
@@ -1906,12 +1061,12 @@ var optimizeNode = (node13, stats, evaluate2) => {
|
|
|
1906
1061
|
}
|
|
1907
1062
|
const handler = resolveHandler(optimized);
|
|
1908
1063
|
if (handler !== void 0) {
|
|
1909
|
-
attachNonEnumerable(optimized,
|
|
1064
|
+
attachNonEnumerable(optimized, HANDLER_KEY, handler);
|
|
1910
1065
|
stats.handlersAttached += 1;
|
|
1911
1066
|
}
|
|
1912
|
-
if (handler !== void 0 && !isConstNode(optimized) && !isRefNode(optimized) && !isVarNode(optimized)) {
|
|
1067
|
+
if (handler !== void 0 && !chunk66YSI4PX_cjs.isConstNode(optimized) && !chunk66YSI4PX_cjs.isRefNode(optimized) && !chunk66YSI4PX_cjs.isVarNode(optimized)) {
|
|
1913
1068
|
const allFoldable = Object.entries(optimized).every(([key, value]) => {
|
|
1914
|
-
if (key ===
|
|
1069
|
+
if (key === HANDLER_KEY || key === SEGMENTS_KEY2) return true;
|
|
1915
1070
|
return isFoldableLiteral(value);
|
|
1916
1071
|
});
|
|
1917
1072
|
if (allFoldable) {
|
|
@@ -1919,7 +1074,8 @@ var optimizeNode = (node13, stats, evaluate2) => {
|
|
|
1919
1074
|
try {
|
|
1920
1075
|
const folded = handler(optimized, emptyCtx, evaluate2);
|
|
1921
1076
|
const replacement = { $const: folded };
|
|
1922
|
-
|
|
1077
|
+
freezeConstant(folded);
|
|
1078
|
+
attachNonEnumerable(replacement, HANDLER_KEY, eraseOp(opConst));
|
|
1923
1079
|
stats.constantsFolded += 1;
|
|
1924
1080
|
return replacement;
|
|
1925
1081
|
} catch {
|
|
@@ -1928,54 +1084,220 @@ var optimizeNode = (node13, stats, evaluate2) => {
|
|
|
1928
1084
|
}
|
|
1929
1085
|
return optimized;
|
|
1930
1086
|
};
|
|
1931
|
-
var optimize = (
|
|
1087
|
+
var optimize = (node, evaluate2) => {
|
|
1932
1088
|
const stats = { refsInlined: 0, handlersAttached: 0, constantsFolded: 0 };
|
|
1933
|
-
const result = optimizeNode(
|
|
1089
|
+
const result = optimizeNode(node, stats, evaluate2);
|
|
1934
1090
|
return { node: result, stats };
|
|
1935
1091
|
};
|
|
1936
|
-
var annotateNode = (
|
|
1937
|
-
if (Array.isArray(
|
|
1938
|
-
for (const child of
|
|
1092
|
+
var annotateNode = (node) => {
|
|
1093
|
+
if (Array.isArray(node)) {
|
|
1094
|
+
for (const child of node) annotateNode(child);
|
|
1939
1095
|
return;
|
|
1940
1096
|
}
|
|
1941
|
-
if (!isPlainObject2(
|
|
1942
|
-
if (
|
|
1943
|
-
for (const value of Object.values(
|
|
1097
|
+
if (!isPlainObject2(node)) return;
|
|
1098
|
+
if (chunk66YSI4PX_cjs.isWithNode(node)) {
|
|
1099
|
+
for (const value of Object.values(node.$with.let)) annotateNode(value);
|
|
1100
|
+
annotateNode(node.$with.value);
|
|
1101
|
+
} else if (chunk66YSI4PX_cjs.isRenameKeysNode(node)) {
|
|
1102
|
+
annotateNode(node.$renameKeys.from);
|
|
1103
|
+
} else if (!chunk66YSI4PX_cjs.isConstNode(node)) {
|
|
1104
|
+
for (const value of Object.values(node)) annotateNode(value);
|
|
1105
|
+
} else {
|
|
1106
|
+
freezeConstant(node.$const);
|
|
1944
1107
|
}
|
|
1945
|
-
if (isRefNode(
|
|
1946
|
-
const segments = parseJsonPath(
|
|
1947
|
-
if (segments.length > 0) attachNonEnumerable(
|
|
1108
|
+
if (chunk66YSI4PX_cjs.isRefNode(node)) {
|
|
1109
|
+
const segments = chunk66YSI4PX_cjs.parseJsonPath(node.$ref);
|
|
1110
|
+
if (segments.length > 0) attachNonEnumerable(node, SEGMENTS_KEY2, segments);
|
|
1948
1111
|
}
|
|
1949
|
-
const handler = resolveHandler(
|
|
1950
|
-
if (handler !== void 0) attachNonEnumerable(
|
|
1112
|
+
const handler = resolveHandler(node);
|
|
1113
|
+
if (handler !== void 0) attachNonEnumerable(node, HANDLER_KEY, handler);
|
|
1951
1114
|
};
|
|
1952
1115
|
var rehydrate = (core) => annotateNode(core);
|
|
1953
1116
|
|
|
1954
|
-
// src/engine/
|
|
1955
|
-
var
|
|
1117
|
+
// src/engine/evaluate.ts
|
|
1118
|
+
var HANDLER_KEY2 = "__op";
|
|
1119
|
+
var isAttachedFn = (value) => typeof value === "function";
|
|
1120
|
+
var evaluateNode = (node, context) => {
|
|
1121
|
+
const { budget } = context;
|
|
1122
|
+
if (budget === void 0) return evaluateUnbudgeted(node, context);
|
|
1123
|
+
spendStep(budget);
|
|
1124
|
+
const out = evaluateUnbudgeted(node, context);
|
|
1125
|
+
measureString(out, budget);
|
|
1126
|
+
return out;
|
|
1127
|
+
};
|
|
1128
|
+
var evaluateUnbudgeted = (node, context) => {
|
|
1129
|
+
if (node === null || node === void 0) return null;
|
|
1130
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") return node;
|
|
1131
|
+
if (Array.isArray(node)) return node.map((n) => evaluateNode(n, context));
|
|
1132
|
+
if (typeof node !== "object") return null;
|
|
1133
|
+
const obj = node;
|
|
1134
|
+
const attached = obj[HANDLER_KEY2];
|
|
1135
|
+
if (isAttachedFn(attached)) return attached(obj, context, evaluateNode);
|
|
1136
|
+
if (chunk66YSI4PX_cjs.isPlainObject(obj)) {
|
|
1137
|
+
const result = {};
|
|
1138
|
+
if (!(chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY in obj)) {
|
|
1139
|
+
for (const key of Object.keys(obj)) result[key] = evaluateNode(obj[key], context);
|
|
1140
|
+
return result;
|
|
1141
|
+
}
|
|
1142
|
+
const optionalFields = new Set(
|
|
1143
|
+
Array.isArray(obj[chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY]) ? obj[chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY] : []
|
|
1144
|
+
);
|
|
1145
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1146
|
+
if (key === chunk66YSI4PX_cjs.OPTIONAL_FIELDS_KEY) continue;
|
|
1147
|
+
const isOptional = optionalFields.has(key);
|
|
1148
|
+
try {
|
|
1149
|
+
const evaluated = evaluateNode(value, context);
|
|
1150
|
+
if (isOptional && (evaluated === null || evaluated === void 0)) continue;
|
|
1151
|
+
result[key] = evaluated;
|
|
1152
|
+
} catch (error) {
|
|
1153
|
+
if (isOptional && error instanceof chunk66YSI4PX_cjs.PrismError && error.code === chunk66YSI4PX_cjs.ErrorCode.MISSING_PATH) continue;
|
|
1154
|
+
throw error;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
return result;
|
|
1158
|
+
}
|
|
1159
|
+
if (chunk66YSI4PX_cjs.isRefNode(obj)) return opRef(obj, context);
|
|
1160
|
+
if (chunk66YSI4PX_cjs.isConstNode(obj)) return opConst(obj, context);
|
|
1161
|
+
if (chunk66YSI4PX_cjs.isVarNode(obj)) return opVar(obj, context);
|
|
1162
|
+
if (chunk66YSI4PX_cjs.isGetNode(obj)) return opGet(obj, context, evaluateNode);
|
|
1163
|
+
if (chunk66YSI4PX_cjs.isWithNode(obj)) return opWith(obj, context, evaluateNode);
|
|
1164
|
+
if (chunk66YSI4PX_cjs.isMapNode(obj)) return opMap(obj, context, evaluateNode);
|
|
1165
|
+
if (chunk66YSI4PX_cjs.isFilterNode(obj)) return opFilter(obj, context, evaluateNode);
|
|
1166
|
+
if (chunk66YSI4PX_cjs.isReduceNode(obj)) return opReduce(obj, context, evaluateNode);
|
|
1167
|
+
if (chunk66YSI4PX_cjs.isSliceNode(obj)) return opSlice(obj, context, evaluateNode);
|
|
1168
|
+
if (chunk66YSI4PX_cjs.isFlattenNode(obj)) return opFlatten(obj, context, evaluateNode);
|
|
1169
|
+
if (chunk66YSI4PX_cjs.isUniqueNode(obj)) return opUnique(obj, context, evaluateNode);
|
|
1170
|
+
if (chunk66YSI4PX_cjs.isSortByNode(obj)) return opSortBy(obj, context, evaluateNode);
|
|
1171
|
+
if (chunk66YSI4PX_cjs.isAddNode(obj)) return opAdd(obj, context, evaluateNode);
|
|
1172
|
+
if (chunk66YSI4PX_cjs.isSubNode(obj)) return opSub(obj, context, evaluateNode);
|
|
1173
|
+
if (chunk66YSI4PX_cjs.isMulNode(obj)) return opMul(obj, context, evaluateNode);
|
|
1174
|
+
if (chunk66YSI4PX_cjs.isDivNode(obj)) return opDiv(obj, context, evaluateNode);
|
|
1175
|
+
if (chunk66YSI4PX_cjs.isRoundNode(obj)) return opRound(obj, context, evaluateNode);
|
|
1176
|
+
if (chunk66YSI4PX_cjs.isModNode(obj)) return opMod(obj, context, evaluateNode);
|
|
1177
|
+
if (chunk66YSI4PX_cjs.isToNumberNode(obj)) return opToNumber(obj, context, evaluateNode);
|
|
1178
|
+
if (chunk66YSI4PX_cjs.isJoinNode(obj)) return opJoin(obj, context, evaluateNode);
|
|
1179
|
+
if (chunk66YSI4PX_cjs.isToStringNode(obj)) return opToString(obj, context, evaluateNode);
|
|
1180
|
+
if (chunk66YSI4PX_cjs.isInterpolateNode(obj)) return opInterpolate(obj, context, evaluateNode);
|
|
1181
|
+
if (chunk66YSI4PX_cjs.isFillNode(obj)) return opFill(obj, context, evaluateNode);
|
|
1182
|
+
if (chunk66YSI4PX_cjs.isTrimNode(obj)) return opTrim(obj, context, evaluateNode);
|
|
1183
|
+
if (chunk66YSI4PX_cjs.isLowerNode(obj)) return opLower(obj, context, evaluateNode);
|
|
1184
|
+
if (chunk66YSI4PX_cjs.isUpperNode(obj)) return opUpper(obj, context, evaluateNode);
|
|
1185
|
+
if (chunk66YSI4PX_cjs.isSplitNode(obj)) return opSplit(obj, context, evaluateNode);
|
|
1186
|
+
if (chunk66YSI4PX_cjs.isReplaceNode(obj)) return opReplace(obj, context, evaluateNode);
|
|
1187
|
+
if (chunk66YSI4PX_cjs.isEqNode(obj)) return opEq(obj, context, evaluateNode);
|
|
1188
|
+
if (chunk66YSI4PX_cjs.isNeqNode(obj)) return opNeq(obj, context, evaluateNode);
|
|
1189
|
+
if (chunk66YSI4PX_cjs.isGtNode(obj)) return opGt(obj, context, evaluateNode);
|
|
1190
|
+
if (chunk66YSI4PX_cjs.isGteNode(obj)) return opGte(obj, context, evaluateNode);
|
|
1191
|
+
if (chunk66YSI4PX_cjs.isLtNode(obj)) return opLt(obj, context, evaluateNode);
|
|
1192
|
+
if (chunk66YSI4PX_cjs.isLteNode(obj)) return opLte(obj, context, evaluateNode);
|
|
1193
|
+
if (chunk66YSI4PX_cjs.isEmptyNode(obj)) return opEmpty(obj, context, evaluateNode);
|
|
1194
|
+
if (chunk66YSI4PX_cjs.isStartsWithNode(obj)) return opStartsWith(obj, context, evaluateNode);
|
|
1195
|
+
if (chunk66YSI4PX_cjs.isEndsWithNode(obj)) return opEndsWith(obj, context, evaluateNode);
|
|
1196
|
+
if (chunk66YSI4PX_cjs.isContainsNode(obj)) return opContains(obj, context, evaluateNode);
|
|
1197
|
+
if (chunk66YSI4PX_cjs.isNotNode(obj)) return opNot(obj, context, evaluateNode);
|
|
1198
|
+
if (chunk66YSI4PX_cjs.isAndNode(obj)) return opAnd(obj, context, evaluateNode);
|
|
1199
|
+
if (chunk66YSI4PX_cjs.isOrNode(obj)) return opOr(obj, context, evaluateNode);
|
|
1200
|
+
if (chunk66YSI4PX_cjs.isMergeNode(obj)) return opMerge(obj, context, evaluateNode);
|
|
1201
|
+
if (chunk66YSI4PX_cjs.isCoalesceNode(obj)) return opCoalesce(obj, context, evaluateNode);
|
|
1202
|
+
if (chunk66YSI4PX_cjs.isCaseNode(obj)) return opCase(obj, context, evaluateNode);
|
|
1203
|
+
if (chunk66YSI4PX_cjs.isEntriesOfNode(obj)) return opEntriesOf(obj, context, evaluateNode);
|
|
1204
|
+
if (chunk66YSI4PX_cjs.isKeyByNode(obj)) return opKeyBy(obj, context, evaluateNode);
|
|
1205
|
+
if (chunk66YSI4PX_cjs.isGroupByNode(obj)) return opGroupBy(obj, context, evaluateNode);
|
|
1206
|
+
if (chunk66YSI4PX_cjs.isKeysNode(obj)) return opKeys(obj, context, evaluateNode);
|
|
1207
|
+
if (chunk66YSI4PX_cjs.isValuesNode(obj)) return opValues(obj, context, evaluateNode);
|
|
1208
|
+
if (chunk66YSI4PX_cjs.isFromEntriesNode(obj)) return opFromEntries(obj, context, evaluateNode);
|
|
1209
|
+
if (chunk66YSI4PX_cjs.isPickNode(obj)) return opPick(obj, context, evaluateNode);
|
|
1210
|
+
if (chunk66YSI4PX_cjs.isOmitNode(obj)) return opOmit(obj, context, evaluateNode);
|
|
1211
|
+
if (chunk66YSI4PX_cjs.isTypeNode(obj)) return opType(obj, context, evaluateNode);
|
|
1212
|
+
if (chunk66YSI4PX_cjs.isLengthNode(obj)) return opLength(obj, context, evaluateNode);
|
|
1213
|
+
if (chunk66YSI4PX_cjs.isHasNode(obj)) return opHas(obj, context, evaluateNode);
|
|
1214
|
+
if (chunk66YSI4PX_cjs.isRenameKeysNode(obj)) return opRenameKeys(obj, context, evaluateNode);
|
|
1215
|
+
if (chunk66YSI4PX_cjs.isUpdateNode(obj)) return opUpdate(obj, context, evaluateNode);
|
|
1216
|
+
if (chunk66YSI4PX_cjs.isAssertNode(obj)) return opAssert(obj, context, evaluateNode);
|
|
1217
|
+
if (chunk66YSI4PX_cjs.isWalkNode(obj)) return opWalk(obj, context, evaluateNode);
|
|
1218
|
+
if (chunk66YSI4PX_cjs.isDateNode(obj)) return opDate(obj, context, evaluateNode);
|
|
1219
|
+
if (chunk66YSI4PX_cjs.isDateAddNode(obj)) return opDateAdd(obj, context, evaluateNode);
|
|
1220
|
+
if (chunk66YSI4PX_cjs.isDateDiffNode(obj)) return opDateDiff(obj, context, evaluateNode);
|
|
1221
|
+
if (chunk66YSI4PX_cjs.isLocaleDateNode(obj)) return opLocaleDate(obj, context, evaluateNode);
|
|
1222
|
+
if (chunk66YSI4PX_cjs.isLocaleMoneyNode(obj)) return opLocaleMoney(obj, context, evaluateNode);
|
|
1223
|
+
if (chunk66YSI4PX_cjs.isLocaleNumberNode(obj)) return opLocaleNumber(obj, context, evaluateNode);
|
|
1224
|
+
const unknownKeys = Object.keys(obj).filter((k) => k.startsWith("$"));
|
|
1225
|
+
throw new chunk66YSI4PX_cjs.PrismError("Unsupported node shape", chunk66YSI4PX_cjs.ErrorCode.NODE_SHAPE, {
|
|
1226
|
+
details: { keys: unknownKeys, preview: JSON.stringify(obj).slice(0, 100) }
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
var isJsonValue = (value) => {
|
|
1230
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
1231
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
1232
|
+
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
1233
|
+
if (typeof value !== "object") return false;
|
|
1234
|
+
const proto = Object.getPrototypeOf(value);
|
|
1235
|
+
return (proto === Object.prototype || proto === null) && Object.values(value).every(isJsonValue);
|
|
1236
|
+
};
|
|
1237
|
+
var checked = (config) => {
|
|
1238
|
+
if (strata.exceedsDepth(config)) throw new chunk66YSI4PX_cjs.PrismError("Invalid config", chunk66YSI4PX_cjs.ErrorCode.SCHEMA, { details: { issues: [{ path: "root", message: strata.depthRefusal() }] } });
|
|
1239
|
+
const parsed = chunk66YSI4PX_cjs.ConfigSchema.safeParse(config);
|
|
1240
|
+
if (!parsed.success) {
|
|
1241
|
+
const issues = explainIssues(parsed.error.issues).map((i) => ({ path: i.path.join(".") || "root", message: i.message }));
|
|
1242
|
+
throw new chunk66YSI4PX_cjs.PrismError("Invalid config", chunk66YSI4PX_cjs.ErrorCode.SCHEMA, { details: { issues } });
|
|
1243
|
+
}
|
|
1244
|
+
return desugar(parsed.data);
|
|
1245
|
+
};
|
|
1246
|
+
var run = (tree, source, limits, kept) => {
|
|
1247
|
+
const budget = createBudget(limits);
|
|
1248
|
+
const result = evaluateNode(tree, kept ? { source, vars: {}, budget, kept } : { source, vars: {}, budget });
|
|
1249
|
+
measure(result, budget);
|
|
1250
|
+
return result;
|
|
1251
|
+
};
|
|
1252
|
+
var keptTrees = /* @__PURE__ */ new WeakMap();
|
|
1253
|
+
var evaluate = (config, source, options) => {
|
|
1254
|
+
if (options?.check === "always") {
|
|
1255
|
+
if (!isJsonValue(source)) throw new chunk66YSI4PX_cjs.PrismError("The source must be plain JSON.", chunk66YSI4PX_cjs.ErrorCode.TYPE);
|
|
1256
|
+
return run(checked(config), source, options.limits, false);
|
|
1257
|
+
}
|
|
1258
|
+
const input = source;
|
|
1259
|
+
if (typeof config !== "object" || config === null) return run(checked(config), input, options?.limits, false);
|
|
1260
|
+
let kept = keptTrees.get(config);
|
|
1261
|
+
if (kept === void 0) {
|
|
1262
|
+
kept = { tree: checked(config), optimized: false };
|
|
1263
|
+
keptTrees.set(config, kept);
|
|
1264
|
+
} else if (!kept.optimized) {
|
|
1265
|
+
kept.tree = optimize(kept.tree, evaluateNode).node;
|
|
1266
|
+
kept.optimized = true;
|
|
1267
|
+
}
|
|
1268
|
+
return run(kept.tree, input, options?.limits, true);
|
|
1269
|
+
};
|
|
1270
|
+
var evaluateSafe = (config, source, options) => {
|
|
1271
|
+
try {
|
|
1272
|
+
return { ok: true, data: evaluate(config, source, options) };
|
|
1273
|
+
} catch (error) {
|
|
1274
|
+
return { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
var walk = (node, stats, depth) => {
|
|
1956
1278
|
stats.nodeCount++;
|
|
1957
1279
|
if (depth > stats.maxDepth) stats.maxDepth = depth;
|
|
1958
|
-
if (
|
|
1959
|
-
if (typeof
|
|
1960
|
-
stats.strings.add(
|
|
1280
|
+
if (node === null || node === void 0) return;
|
|
1281
|
+
if (typeof node === "string") {
|
|
1282
|
+
stats.strings.add(node);
|
|
1961
1283
|
return;
|
|
1962
1284
|
}
|
|
1963
|
-
if (typeof
|
|
1964
|
-
if (Array.isArray(
|
|
1965
|
-
for (const child of
|
|
1285
|
+
if (typeof node === "number" || typeof node === "boolean") return;
|
|
1286
|
+
if (Array.isArray(node)) {
|
|
1287
|
+
for (const child of node) walk(child, stats, depth + 1);
|
|
1966
1288
|
return;
|
|
1967
1289
|
}
|
|
1968
|
-
if (!isJsonObject(
|
|
1969
|
-
for (const key of Object.keys(
|
|
1290
|
+
if (!chunk66YSI4PX_cjs.isJsonObject(node)) return;
|
|
1291
|
+
for (const key of Object.keys(node)) {
|
|
1970
1292
|
if (key.startsWith("$")) {
|
|
1971
1293
|
stats.opCount[key] = (stats.opCount[key] ?? 0) + 1;
|
|
1972
1294
|
}
|
|
1973
1295
|
}
|
|
1974
|
-
if ("$ref" in
|
|
1975
|
-
stats.paths.add(
|
|
1976
|
-
stats.strings.add(
|
|
1296
|
+
if ("$ref" in node && typeof node["$ref"] === "string") {
|
|
1297
|
+
stats.paths.add(node["$ref"]);
|
|
1298
|
+
stats.strings.add(node["$ref"]);
|
|
1977
1299
|
}
|
|
1978
|
-
for (const value of Object.values(
|
|
1300
|
+
for (const value of Object.values(node)) {
|
|
1979
1301
|
walk(value, stats, depth + 1);
|
|
1980
1302
|
}
|
|
1981
1303
|
};
|
|
@@ -1985,11 +1307,11 @@ var hashSha256 = async (data) => {
|
|
|
1985
1307
|
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1986
1308
|
};
|
|
1987
1309
|
var compile = async (config, options) => {
|
|
1988
|
-
if (strata.exceedsDepth(config)) throw new PrismError(`Invalid config: ${strata.depthRefusal()}`, ErrorCode.SCHEMA);
|
|
1989
|
-
const parsed = ConfigSchema.safeParse(config);
|
|
1310
|
+
if (strata.exceedsDepth(config)) throw new chunk66YSI4PX_cjs.PrismError(`Invalid config: ${strata.depthRefusal()}`, chunk66YSI4PX_cjs.ErrorCode.SCHEMA);
|
|
1311
|
+
const parsed = chunk66YSI4PX_cjs.ConfigSchema.safeParse(config);
|
|
1990
1312
|
if (!parsed.success) {
|
|
1991
1313
|
const issues = explainIssues(parsed.error.issues).map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
1992
|
-
throw new PrismError(`Invalid config: ${issues}`, ErrorCode.SCHEMA);
|
|
1314
|
+
throw new chunk66YSI4PX_cjs.PrismError(`Invalid config: ${issues}`, chunk66YSI4PX_cjs.ErrorCode.SCHEMA);
|
|
1993
1315
|
}
|
|
1994
1316
|
const desugared = desugar(parsed.data);
|
|
1995
1317
|
const { node: core, stats: optimizations } = optimize(desugared, evaluateNode);
|
|
@@ -2030,9 +1352,6 @@ var compile = async (config, options) => {
|
|
|
2030
1352
|
// src/engine/execute.ts
|
|
2031
1353
|
var hydrated = /* @__PURE__ */ new WeakSet();
|
|
2032
1354
|
var execute = (ir, source, limits) => {
|
|
2033
|
-
if (ir.tables.paths.length > 0) {
|
|
2034
|
-
primeJsonPathCache(ir.tables.paths);
|
|
2035
|
-
}
|
|
2036
1355
|
const { core } = ir;
|
|
2037
1356
|
if (typeof core === "object" && core !== null && !hydrated.has(core)) {
|
|
2038
1357
|
rehydrate(core);
|
|
@@ -2045,7 +1364,7 @@ var execute = (ir, source, limits) => {
|
|
|
2045
1364
|
};
|
|
2046
1365
|
var validate = (config) => {
|
|
2047
1366
|
if (strata.exceedsDepth(config)) return { ok: false, issues: [{ path: [], message: strata.depthRefusal() }] };
|
|
2048
|
-
const parsed = ConfigSchema.safeParse(config);
|
|
1367
|
+
const parsed = chunk66YSI4PX_cjs.ConfigSchema.safeParse(config);
|
|
2049
1368
|
if (!parsed.success) {
|
|
2050
1369
|
return {
|
|
2051
1370
|
ok: false,
|
|
@@ -2056,157 +1375,48 @@ var validate = (config) => {
|
|
|
2056
1375
|
}
|
|
2057
1376
|
return { ok: true, data: parsed.data };
|
|
2058
1377
|
};
|
|
2059
|
-
var getNodeJsonSchema = (target = "draft-2020-12") => zod.z.toJSONSchema(NodeSchema, { target });
|
|
2060
|
-
var getConfigJsonSchema = (target = "draft-2020-12") => zod.z.toJSONSchema(ConfigSchema, { target });
|
|
2061
|
-
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2062
|
-
var unwrapRef = (value) => {
|
|
2063
|
-
const allOf = isObject(value) ? value["allOf"] : void 0;
|
|
2064
|
-
const only = Array.isArray(allOf) && allOf.length === 1 ? allOf[0] : void 0;
|
|
2065
|
-
return isObject(only) && "$ref" in only ? only : value;
|
|
2066
|
-
};
|
|
2067
|
-
var refTarget = (ref) => {
|
|
2068
|
-
if (typeof ref !== "string") return void 0;
|
|
2069
|
-
const match = /^#\/([^/]+)\/([^/]+)$/.exec(ref);
|
|
2070
|
-
return match?.[1] !== void 0 && match[2] !== void 0 ? [match[1], match[2]] : void 0;
|
|
2071
|
-
};
|
|
2072
|
-
var resolve = (root, ref) => {
|
|
2073
|
-
const target = refTarget(ref);
|
|
2074
|
-
if (target === void 0) return void 0;
|
|
2075
|
-
const container = root[target[0]];
|
|
2076
|
-
const def = isObject(container) ? container[target[1]] : void 0;
|
|
2077
|
-
return isObject(def) ? def : void 0;
|
|
2078
|
-
};
|
|
2079
|
-
var opOf = (root, written) => {
|
|
2080
|
-
const alternative = unwrapRef(written);
|
|
2081
|
-
const node13 = isObject(alternative) && "$ref" in alternative ? resolve(root, alternative["$ref"]) : alternative;
|
|
2082
|
-
const properties = isObject(node13) ? node13["properties"] : void 0;
|
|
2083
|
-
const key = isObject(properties) ? Object.keys(properties)[0] : void 0;
|
|
2084
|
-
return key !== void 0 && key.startsWith("$") ? key : void 0;
|
|
2085
|
-
};
|
|
2086
|
-
var refsIn = (value, found) => {
|
|
2087
|
-
if (Array.isArray(value)) {
|
|
2088
|
-
for (const item of value) refsIn(item, found);
|
|
2089
|
-
return;
|
|
2090
|
-
}
|
|
2091
|
-
if (!isObject(value)) return;
|
|
2092
|
-
for (const [key, child] of Object.entries(value)) {
|
|
2093
|
-
if (key === "$ref" && typeof child === "string") found.add(child);
|
|
2094
|
-
else refsIn(child, found);
|
|
2095
|
-
}
|
|
2096
|
-
};
|
|
2097
|
-
var getProfileJsonSchema = (ops, target = "draft-2020-12") => narrowConfigJsonSchema(getConfigJsonSchema(target), ops);
|
|
2098
|
-
var narrowConfigJsonSchema = (full, ops) => {
|
|
2099
|
-
if (!isObject(full)) throw new Error("prism: the config JSON Schema is not an object");
|
|
2100
|
-
const root = structuredClone(full);
|
|
2101
|
-
const top = unwrapRef(root);
|
|
2102
|
-
const node13 = resolve(root, isObject(top) ? top["$ref"] : void 0);
|
|
2103
|
-
const alternatives = node13?.["anyOf"];
|
|
2104
|
-
if (node13 === void 0 || !Array.isArray(alternatives)) throw new Error("prism: the config JSON Schema has no node union to narrow");
|
|
2105
|
-
const keep = new Set(ops);
|
|
2106
|
-
node13["anyOf"] = alternatives.filter((alternative) => {
|
|
2107
|
-
const op = opOf(root, alternative);
|
|
2108
|
-
return op === void 0 || keep.has(op);
|
|
2109
|
-
});
|
|
2110
|
-
const reached = /* @__PURE__ */ new Set();
|
|
2111
|
-
const pending = [];
|
|
2112
|
-
const visit = (value) => {
|
|
2113
|
-
const found = /* @__PURE__ */ new Set();
|
|
2114
|
-
refsIn(value, found);
|
|
2115
|
-
for (const ref of found) {
|
|
2116
|
-
if (reached.has(ref)) continue;
|
|
2117
|
-
reached.add(ref);
|
|
2118
|
-
pending.push(ref);
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
visit({ ...root, $defs: void 0, definitions: void 0 });
|
|
2122
|
-
for (let ref = pending.pop(); ref !== void 0; ref = pending.pop()) visit(resolve(root, ref));
|
|
2123
|
-
for (const container of ["$defs", "definitions"]) {
|
|
2124
|
-
const defs = root[container];
|
|
2125
|
-
if (!isObject(defs)) continue;
|
|
2126
|
-
for (const name of Object.keys(defs)) if (!reached.has(`#/${container}/${name}`)) delete defs[name];
|
|
2127
|
-
}
|
|
2128
|
-
return root;
|
|
2129
|
-
};
|
|
2130
|
-
|
|
2131
|
-
// src/schemas/profiles.ts
|
|
2132
|
-
var MAPPING_OPS = [
|
|
2133
|
-
// reading the source
|
|
2134
|
-
"$ref",
|
|
2135
|
-
"$const",
|
|
2136
|
-
"$var",
|
|
2137
|
-
"$get",
|
|
2138
|
-
"$with",
|
|
2139
|
-
// arrays
|
|
2140
|
-
"$map",
|
|
2141
|
-
"$filter",
|
|
2142
|
-
"$reduce",
|
|
2143
|
-
"$slice",
|
|
2144
|
-
"$unique",
|
|
2145
|
-
"$sortBy",
|
|
2146
|
-
"$take",
|
|
2147
|
-
"$pluck",
|
|
2148
|
-
// numbers and aggregates
|
|
2149
|
-
"$add",
|
|
2150
|
-
"$sub",
|
|
2151
|
-
"$mul",
|
|
2152
|
-
"$div",
|
|
2153
|
-
"$round",
|
|
2154
|
-
"$sum",
|
|
2155
|
-
"$avg",
|
|
2156
|
-
"$count",
|
|
2157
|
-
"$min",
|
|
2158
|
-
"$max",
|
|
2159
|
-
// strings
|
|
2160
|
-
"$join",
|
|
2161
|
-
"$toString",
|
|
2162
|
-
"$interpolate",
|
|
2163
|
-
"$trim",
|
|
2164
|
-
"$lower",
|
|
2165
|
-
"$upper",
|
|
2166
|
-
"$split",
|
|
2167
|
-
// conditions
|
|
2168
|
-
"$eq",
|
|
2169
|
-
"$neq",
|
|
2170
|
-
"$gt",
|
|
2171
|
-
"$gte",
|
|
2172
|
-
"$lt",
|
|
2173
|
-
"$lte",
|
|
2174
|
-
"$empty",
|
|
2175
|
-
"$contains",
|
|
2176
|
-
"$not",
|
|
2177
|
-
"$and",
|
|
2178
|
-
"$or",
|
|
2179
|
-
// structure
|
|
2180
|
-
"$merge",
|
|
2181
|
-
"$coalesce",
|
|
2182
|
-
"$case",
|
|
2183
|
-
"$groupBy",
|
|
2184
|
-
"$pick",
|
|
2185
|
-
"$omit",
|
|
2186
|
-
"$length",
|
|
2187
|
-
// dates and locale formatting
|
|
2188
|
-
"$date",
|
|
2189
|
-
"$dateDiff",
|
|
2190
|
-
"$localeDate",
|
|
2191
|
-
"$localeMoney",
|
|
2192
|
-
"$localeNumber"
|
|
2193
|
-
];
|
|
2194
1378
|
|
|
2195
|
-
exports
|
|
1379
|
+
Object.defineProperty(exports, "MAPPING_OPS", {
|
|
1380
|
+
enumerable: true,
|
|
1381
|
+
get: function () { return chunkOLZQK2ZF_cjs.MAPPING_OPS; }
|
|
1382
|
+
});
|
|
1383
|
+
Object.defineProperty(exports, "getConfigJsonSchema", {
|
|
1384
|
+
enumerable: true,
|
|
1385
|
+
get: function () { return chunkOLZQK2ZF_cjs.getConfigJsonSchema; }
|
|
1386
|
+
});
|
|
1387
|
+
Object.defineProperty(exports, "getNodeJsonSchema", {
|
|
1388
|
+
enumerable: true,
|
|
1389
|
+
get: function () { return chunkOLZQK2ZF_cjs.getNodeJsonSchema; }
|
|
1390
|
+
});
|
|
1391
|
+
Object.defineProperty(exports, "getProfileJsonSchema", {
|
|
1392
|
+
enumerable: true,
|
|
1393
|
+
get: function () { return chunkOLZQK2ZF_cjs.getProfileJsonSchema; }
|
|
1394
|
+
});
|
|
1395
|
+
Object.defineProperty(exports, "ConfigSchema", {
|
|
1396
|
+
enumerable: true,
|
|
1397
|
+
get: function () { return chunk66YSI4PX_cjs.ConfigSchema; }
|
|
1398
|
+
});
|
|
1399
|
+
Object.defineProperty(exports, "ErrorCode", {
|
|
1400
|
+
enumerable: true,
|
|
1401
|
+
get: function () { return chunk66YSI4PX_cjs.ErrorCode; }
|
|
1402
|
+
});
|
|
1403
|
+
Object.defineProperty(exports, "NodeSchema", {
|
|
1404
|
+
enumerable: true,
|
|
1405
|
+
get: function () { return chunk66YSI4PX_cjs.NodeSchema; }
|
|
1406
|
+
});
|
|
1407
|
+
Object.defineProperty(exports, "OP_KEYS", {
|
|
1408
|
+
enumerable: true,
|
|
1409
|
+
get: function () { return chunk66YSI4PX_cjs.OP_KEYS; }
|
|
1410
|
+
});
|
|
1411
|
+
Object.defineProperty(exports, "PrismError", {
|
|
1412
|
+
enumerable: true,
|
|
1413
|
+
get: function () { return chunk66YSI4PX_cjs.PrismError; }
|
|
1414
|
+
});
|
|
2196
1415
|
exports.DEFAULT_LIMITS = DEFAULT_LIMITS;
|
|
2197
|
-
exports.ErrorCode = ErrorCode;
|
|
2198
|
-
exports.MAPPING_OPS = MAPPING_OPS;
|
|
2199
|
-
exports.NodeSchema = NodeSchema;
|
|
2200
|
-
exports.OP_KEYS = OP_KEYS;
|
|
2201
|
-
exports.PrismError = PrismError;
|
|
2202
1416
|
exports.compile = compile;
|
|
2203
1417
|
exports.evaluate = evaluate;
|
|
2204
1418
|
exports.evaluateSafe = evaluateSafe;
|
|
2205
1419
|
exports.execute = execute;
|
|
2206
|
-
exports.getConfigJsonSchema = getConfigJsonSchema;
|
|
2207
|
-
exports.getNodeJsonSchema = getNodeJsonSchema;
|
|
2208
|
-
exports.getProfileJsonSchema = getProfileJsonSchema;
|
|
2209
|
-
exports.prismTransform = prismTransform;
|
|
2210
1420
|
exports.validate = validate;
|
|
2211
1421
|
//# sourceMappingURL=index.cjs.map
|
|
2212
1422
|
//# sourceMappingURL=index.cjs.map
|