@dyrected/core 2.13.0 → 2.13.3

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.
@@ -1,1758 +0,0 @@
1
- import {
2
- __commonJS
3
- } from "./chunk-JSBRDJBE.js";
4
-
5
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/interopRequireDefault.js
6
- var require_interopRequireDefault = __commonJS({
7
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/interopRequireDefault.js"(exports, module) {
8
- "use strict";
9
- function _interopRequireDefault(e) {
10
- return e && e.__esModule ? e : {
11
- "default": e
12
- };
13
- }
14
- module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
15
- }
16
- });
17
-
18
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/typeof.js
19
- var require_typeof = __commonJS({
20
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/typeof.js"(exports, module) {
21
- "use strict";
22
- function _typeof(o) {
23
- "@babel/helpers - typeof";
24
- return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
25
- return typeof o2;
26
- } : function(o2) {
27
- return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
28
- }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
29
- }
30
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
31
- }
32
- });
33
-
34
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/toPrimitive.js
35
- var require_toPrimitive = __commonJS({
36
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/toPrimitive.js"(exports, module) {
37
- "use strict";
38
- var _typeof = require_typeof()["default"];
39
- function toPrimitive(t, r) {
40
- if ("object" != _typeof(t) || !t) return t;
41
- var e = t[Symbol.toPrimitive];
42
- if (void 0 !== e) {
43
- var i = e.call(t, r || "default");
44
- if ("object" != _typeof(i)) return i;
45
- throw new TypeError("@@toPrimitive must return a primitive value.");
46
- }
47
- return ("string" === r ? String : Number)(t);
48
- }
49
- module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
50
- }
51
- });
52
-
53
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/toPropertyKey.js
54
- var require_toPropertyKey = __commonJS({
55
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/toPropertyKey.js"(exports, module) {
56
- "use strict";
57
- var _typeof = require_typeof()["default"];
58
- var toPrimitive = require_toPrimitive();
59
- function toPropertyKey(t) {
60
- var i = toPrimitive(t, "string");
61
- return "symbol" == _typeof(i) ? i : i + "";
62
- }
63
- module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
64
- }
65
- });
66
-
67
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/defineProperty.js
68
- var require_defineProperty = __commonJS({
69
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/defineProperty.js"(exports, module) {
70
- "use strict";
71
- var toPropertyKey = require_toPropertyKey();
72
- function _defineProperty(e, r, t) {
73
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
74
- value: t,
75
- enumerable: true,
76
- configurable: true,
77
- writable: true
78
- }) : e[r] = t, e;
79
- }
80
- module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
81
- }
82
- });
83
-
84
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/classCallCheck.js
85
- var require_classCallCheck = __commonJS({
86
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/classCallCheck.js"(exports, module) {
87
- "use strict";
88
- function _classCallCheck(a, n) {
89
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
90
- }
91
- module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
92
- }
93
- });
94
-
95
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/createClass.js
96
- var require_createClass = __commonJS({
97
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/createClass.js"(exports, module) {
98
- "use strict";
99
- var toPropertyKey = require_toPropertyKey();
100
- function _defineProperties(e, r) {
101
- for (var t = 0; t < r.length; t++) {
102
- var o = r[t];
103
- o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, toPropertyKey(o.key), o);
104
- }
105
- }
106
- function _createClass(e, r, t) {
107
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
108
- writable: false
109
- }), e;
110
- }
111
- module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
112
- }
113
- });
114
-
115
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/arrayLikeToArray.js
116
- var require_arrayLikeToArray = __commonJS({
117
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/arrayLikeToArray.js"(exports, module) {
118
- "use strict";
119
- function _arrayLikeToArray(r, a) {
120
- (null == a || a > r.length) && (a = r.length);
121
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
122
- return n;
123
- }
124
- module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
125
- }
126
- });
127
-
128
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js
129
- var require_arrayWithoutHoles = __commonJS({
130
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js"(exports, module) {
131
- "use strict";
132
- var arrayLikeToArray = require_arrayLikeToArray();
133
- function _arrayWithoutHoles(r) {
134
- if (Array.isArray(r)) return arrayLikeToArray(r);
135
- }
136
- module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
137
- }
138
- });
139
-
140
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/iterableToArray.js
141
- var require_iterableToArray = __commonJS({
142
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/iterableToArray.js"(exports, module) {
143
- "use strict";
144
- function _iterableToArray(r) {
145
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
146
- }
147
- module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
148
- }
149
- });
150
-
151
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js
152
- var require_unsupportedIterableToArray = __commonJS({
153
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"(exports, module) {
154
- "use strict";
155
- var arrayLikeToArray = require_arrayLikeToArray();
156
- function _unsupportedIterableToArray(r, a) {
157
- if (r) {
158
- if ("string" == typeof r) return arrayLikeToArray(r, a);
159
- var t = {}.toString.call(r).slice(8, -1);
160
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;
161
- }
162
- }
163
- module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
164
- }
165
- });
166
-
167
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/nonIterableSpread.js
168
- var require_nonIterableSpread = __commonJS({
169
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/nonIterableSpread.js"(exports, module) {
170
- "use strict";
171
- function _nonIterableSpread() {
172
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
173
- }
174
- module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
175
- }
176
- });
177
-
178
- // ../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/toConsumableArray.js
179
- var require_toConsumableArray = __commonJS({
180
- "../../node_modules/.pnpm/@babel+runtime@7.29.7/node_modules/@babel/runtime/helpers/toConsumableArray.js"(exports, module) {
181
- "use strict";
182
- var arrayWithoutHoles = require_arrayWithoutHoles();
183
- var iterableToArray = require_iterableToArray();
184
- var unsupportedIterableToArray = require_unsupportedIterableToArray();
185
- var nonIterableSpread = require_nonIterableSpread();
186
- function _toConsumableArray(r) {
187
- return arrayWithoutHoles(r) || iterableToArray(r) || unsupportedIterableToArray(r) || nonIterableSpread();
188
- }
189
- module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
190
- }
191
- });
192
-
193
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/evaluator/handlers.js
194
- var require_handlers = __commonJS({
195
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/evaluator/handlers.js"(exports) {
196
- "use strict";
197
- var _interopRequireDefault = require_interopRequireDefault();
198
- var _toConsumableArray2 = _interopRequireDefault(require_toConsumableArray());
199
- var poolNames = {
200
- functions: "Jexl Function",
201
- transforms: "Transform"
202
- };
203
- exports.ArrayLiteral = function(ast) {
204
- return this.evalArray(ast.value);
205
- };
206
- exports.BinaryExpression = function(ast) {
207
- var _this = this;
208
- var grammarOp = this._grammar.elements[ast.operator];
209
- if (grammarOp.evalOnDemand) {
210
- var wrap = function wrap2(subAst) {
211
- return {
212
- eval: function _eval() {
213
- return _this.eval(subAst);
214
- }
215
- };
216
- };
217
- return grammarOp.evalOnDemand(wrap(ast.left), wrap(ast.right));
218
- }
219
- return this.Promise.all([this.eval(ast.left), this.eval(ast.right)]).then(function(arr) {
220
- return grammarOp.eval(arr[0], arr[1]);
221
- });
222
- };
223
- exports.ConditionalExpression = function(ast) {
224
- var _this2 = this;
225
- return this.eval(ast.test).then(function(res) {
226
- if (res) {
227
- if (ast.consequent) {
228
- return _this2.eval(ast.consequent);
229
- }
230
- return res;
231
- }
232
- return _this2.eval(ast.alternate);
233
- });
234
- };
235
- exports.FilterExpression = function(ast) {
236
- var _this3 = this;
237
- return this.eval(ast.subject).then(function(subject) {
238
- if (ast.relative) {
239
- return _this3._filterRelative(subject, ast.expr);
240
- }
241
- return _this3._filterStatic(subject, ast.expr);
242
- });
243
- };
244
- exports.Identifier = function(ast) {
245
- if (!ast.from) {
246
- return ast.relative ? this._relContext[ast.value] : this._context[ast.value];
247
- }
248
- return this.eval(ast.from).then(function(context) {
249
- if (context === void 0 || context === null) {
250
- return void 0;
251
- }
252
- if (Array.isArray(context)) {
253
- context = context[0];
254
- }
255
- return context[ast.value];
256
- });
257
- };
258
- exports.Literal = function(ast) {
259
- return ast.value;
260
- };
261
- exports.ObjectLiteral = function(ast) {
262
- return this.evalMap(ast.value);
263
- };
264
- exports.FunctionCall = function(ast) {
265
- var poolName = poolNames[ast.pool];
266
- if (!poolName) {
267
- throw new Error("Corrupt AST: Pool '".concat(ast.pool, "' not found"));
268
- }
269
- var pool = this._grammar[ast.pool];
270
- var func = pool[ast.name];
271
- if (!func) {
272
- throw new Error("".concat(poolName, " ").concat(ast.name, " is not defined."));
273
- }
274
- return this.evalArray(ast.args || []).then(function(args) {
275
- return func.apply(void 0, (0, _toConsumableArray2.default)(args));
276
- });
277
- };
278
- exports.UnaryExpression = function(ast) {
279
- var _this4 = this;
280
- return this.eval(ast.right).then(function(right) {
281
- return _this4._grammar.elements[ast.operator].eval(right);
282
- });
283
- };
284
- }
285
- });
286
-
287
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/evaluator/Evaluator.js
288
- var require_Evaluator = __commonJS({
289
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/evaluator/Evaluator.js"(exports, module) {
290
- "use strict";
291
- var _interopRequireDefault = require_interopRequireDefault();
292
- var _classCallCheck2 = _interopRequireDefault(require_classCallCheck());
293
- var _createClass2 = _interopRequireDefault(require_createClass());
294
- var handlers = require_handlers();
295
- var Evaluator = /* @__PURE__ */ (function() {
296
- function Evaluator2(grammar, context, relativeContext) {
297
- var promise = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : Promise;
298
- (0, _classCallCheck2.default)(this, Evaluator2);
299
- this._grammar = grammar;
300
- this._context = context || {};
301
- this._relContext = relativeContext || this._context;
302
- this.Promise = promise;
303
- }
304
- (0, _createClass2.default)(Evaluator2, [{
305
- key: "eval",
306
- value: function _eval(ast) {
307
- var _this = this;
308
- return this.Promise.resolve().then(function() {
309
- return handlers[ast.type].call(_this, ast);
310
- });
311
- }
312
- /**
313
- * Simultaneously evaluates each expression within an array, and delivers the
314
- * response as an array with the resulting values at the same indexes as their
315
- * originating expressions.
316
- * @param {Array<string>} arr An array of expression strings to be evaluated
317
- * @returns {Promise<Array<{}>>} resolves with the result array
318
- */
319
- }, {
320
- key: "evalArray",
321
- value: function evalArray(arr) {
322
- var _this2 = this;
323
- return this.Promise.all(arr.map(function(elem) {
324
- return _this2.eval(elem);
325
- }));
326
- }
327
- /**
328
- * Simultaneously evaluates each expression within a map, and delivers the
329
- * response as a map with the same keys, but with the evaluated result for each
330
- * as their value.
331
- * @param {{}} map A map of expression names to expression trees to be
332
- * evaluated
333
- * @returns {Promise<{}>} resolves with the result map.
334
- */
335
- }, {
336
- key: "evalMap",
337
- value: function evalMap(map) {
338
- var _this3 = this;
339
- var keys = Object.keys(map);
340
- var result = {};
341
- var asts = keys.map(function(key) {
342
- return _this3.eval(map[key]);
343
- });
344
- return this.Promise.all(asts).then(function(vals) {
345
- vals.forEach(function(val, idx) {
346
- result[keys[idx]] = val;
347
- });
348
- return result;
349
- });
350
- }
351
- /**
352
- * Applies a filter expression with relative identifier elements to a subject.
353
- * The intent is for the subject to be an array of subjects that will be
354
- * individually used as the relative context against the provided expression
355
- * tree. Only the elements whose expressions result in a truthy value will be
356
- * included in the resulting array.
357
- *
358
- * If the subject is not an array of values, it will be converted to a single-
359
- * element array before running the filter.
360
- * @param {*} subject The value to be filtered usually an array. If this value is
361
- * not an array, it will be converted to an array with this value as the
362
- * only element.
363
- * @param {{}} expr The expression tree to run against each subject. If the
364
- * tree evaluates to a truthy result, then the value will be included in
365
- * the returned array otherwise, it will be eliminated.
366
- * @returns {Promise<Array>} resolves with an array of values that passed the
367
- * expression filter.
368
- * @private
369
- */
370
- }, {
371
- key: "_filterRelative",
372
- value: function _filterRelative(subject, expr) {
373
- var _this4 = this;
374
- var promises = [];
375
- if (!Array.isArray(subject)) {
376
- subject = subject === void 0 ? [] : [subject];
377
- }
378
- subject.forEach(function(elem) {
379
- var evalInst = new Evaluator2(_this4._grammar, _this4._context, elem, _this4.Promise);
380
- promises.push(evalInst.eval(expr));
381
- });
382
- return this.Promise.all(promises).then(function(values) {
383
- var results = [];
384
- values.forEach(function(value, idx) {
385
- if (value) {
386
- results.push(subject[idx]);
387
- }
388
- });
389
- return results;
390
- });
391
- }
392
- /**
393
- * Applies a static filter expression to a subject value. If the filter
394
- * expression evaluates to boolean true, the subject is returned if false,
395
- * undefined.
396
- *
397
- * For any other resulting value of the expression, this function will attempt
398
- * to respond with the property at that name or index of the subject.
399
- * @param {*} subject The value to be filtered. Usually an Array (for which
400
- * the expression would generally resolve to a numeric index) or an
401
- * Object (for which the expression would generally resolve to a string
402
- * indicating a property name)
403
- * @param {{}} expr The expression tree to run against the subject
404
- * @returns {Promise<*>} resolves with the value of the drill-down.
405
- * @private
406
- */
407
- }, {
408
- key: "_filterStatic",
409
- value: function _filterStatic(subject, expr) {
410
- return this.eval(expr).then(function(res) {
411
- if (typeof res === "boolean") {
412
- return res ? subject : void 0;
413
- }
414
- return subject[res];
415
- });
416
- }
417
- }]);
418
- return Evaluator2;
419
- })();
420
- module.exports = Evaluator;
421
- }
422
- });
423
-
424
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/Lexer.js
425
- var require_Lexer = __commonJS({
426
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/Lexer.js"(exports, module) {
427
- "use strict";
428
- var _interopRequireDefault = require_interopRequireDefault();
429
- var _classCallCheck2 = _interopRequireDefault(require_classCallCheck());
430
- var _createClass2 = _interopRequireDefault(require_createClass());
431
- var numericRegex = /^-?(?:(?:[0-9]*\.[0-9]+)|[0-9]+)$/;
432
- var identRegex = /^[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*$/;
433
- var escEscRegex = /\\\\/;
434
- var whitespaceRegex = /^\s*$/;
435
- var preOpRegexElems = [
436
- // Strings
437
- "'(?:(?:\\\\')|[^'])*'",
438
- '"(?:(?:\\\\")|[^"])*"',
439
- // Whitespace
440
- "\\s+",
441
- // Booleans
442
- "\\btrue\\b",
443
- "\\bfalse\\b"
444
- ];
445
- var postOpRegexElems = [
446
- // Identifiers
447
- "[a-zA-Z\u0430-\u044F\u0410-\u042F_\xC0-\xD6\xD8-\xF6\xF8-\xFF\\$][a-zA-Z0-9\u0430-\u044F\u0410-\u042F_\xC0-\xD6\xD8-\xF6\xF8-\xFF\\$]*",
448
- // Numerics (without negative symbol)
449
- "(?:(?:[0-9]*\\.[0-9]+)|[0-9]+)"
450
- ];
451
- var minusNegatesAfter = ["binaryOp", "unaryOp", "openParen", "openBracket", "question", "colon"];
452
- var Lexer = /* @__PURE__ */ (function() {
453
- function Lexer2(grammar) {
454
- (0, _classCallCheck2.default)(this, Lexer2);
455
- this._grammar = grammar;
456
- }
457
- (0, _createClass2.default)(Lexer2, [{
458
- key: "getElements",
459
- value: function getElements(str) {
460
- var regex = this._getSplitRegex();
461
- return str.split(regex).filter(function(elem) {
462
- return elem;
463
- });
464
- }
465
- /**
466
- * Converts an array of expression elements into an array of tokens. Note that
467
- * the resulting array may not equal the element array in length, as any
468
- * elements that consist only of whitespace get appended to the previous
469
- * token's "raw" property. For the structure of a token object, please see
470
- * {@link Lexer#tokenize}.
471
- * @param {Array<string>} elements An array of Jexl expression elements to be
472
- * converted to tokens
473
- * @returns {Array<{type, value, raw}>} an array of token objects.
474
- */
475
- }, {
476
- key: "getTokens",
477
- value: function getTokens(elements) {
478
- var tokens = [];
479
- var negate = false;
480
- for (var i = 0; i < elements.length; i++) {
481
- if (this._isWhitespace(elements[i])) {
482
- if (tokens.length) {
483
- tokens[tokens.length - 1].raw += elements[i];
484
- }
485
- } else if (elements[i] === "-" && this._isNegative(tokens)) {
486
- negate = true;
487
- } else {
488
- if (negate) {
489
- elements[i] = "-" + elements[i];
490
- negate = false;
491
- }
492
- tokens.push(this._createToken(elements[i]));
493
- }
494
- }
495
- if (negate) {
496
- tokens.push(this._createToken("-"));
497
- }
498
- return tokens;
499
- }
500
- /**
501
- * Converts a Jexl string into an array of tokens. Each token is an object
502
- * in the following format:
503
- *
504
- * {
505
- * type: <string>,
506
- * [name]: <string>,
507
- * value: <boolean|number|string>,
508
- * raw: <string>
509
- * }
510
- *
511
- * Type is one of the following:
512
- *
513
- * literal, identifier, binaryOp, unaryOp
514
- *
515
- * OR, if the token is a control character its type is the name of the element
516
- * defined in the Grammar.
517
- *
518
- * Name appears only if the token is a control string found in
519
- * {@link grammar#elements}, and is set to the name of the element.
520
- *
521
- * Value is the value of the token in the correct type (boolean or numeric as
522
- * appropriate). Raw is the string representation of this value taken directly
523
- * from the expression string, including any trailing spaces.
524
- * @param {string} str The Jexl string to be tokenized
525
- * @returns {Array<{type, value, raw}>} an array of token objects.
526
- * @throws {Error} if the provided string contains an invalid token.
527
- */
528
- }, {
529
- key: "tokenize",
530
- value: function tokenize(str) {
531
- var elements = this.getElements(str);
532
- return this.getTokens(elements);
533
- }
534
- /**
535
- * Creates a new token object from an element of a Jexl string. See
536
- * {@link Lexer#tokenize} for a description of the token object.
537
- * @param {string} element The element from which a token should be made
538
- * @returns {{value: number|boolean|string, [name]: string, type: string,
539
- * raw: string}} a token object describing the provided element.
540
- * @throws {Error} if the provided string is not a valid expression element.
541
- * @private
542
- */
543
- }, {
544
- key: "_createToken",
545
- value: function _createToken(element) {
546
- var token = {
547
- type: "literal",
548
- value: element,
549
- raw: element
550
- };
551
- if (element[0] === '"' || element[0] === "'") {
552
- token.value = this._unquote(element);
553
- } else if (element.match(numericRegex)) {
554
- token.value = parseFloat(element);
555
- } else if (element === "true" || element === "false") {
556
- token.value = element === "true";
557
- } else if (this._grammar.elements[element]) {
558
- token.type = this._grammar.elements[element].type;
559
- } else if (element.match(identRegex)) {
560
- token.type = "identifier";
561
- } else {
562
- throw new Error("Invalid expression token: ".concat(element));
563
- }
564
- return token;
565
- }
566
- /**
567
- * Escapes a string so that it can be treated as a string literal within a
568
- * regular expression.
569
- * @param {string} str The string to be escaped
570
- * @returns {string} the RegExp-escaped string.
571
- * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
572
- * @private
573
- */
574
- }, {
575
- key: "_escapeRegExp",
576
- value: function _escapeRegExp(str) {
577
- str = str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
578
- if (str.match(identRegex)) {
579
- str = "\\b" + str + "\\b";
580
- }
581
- return str;
582
- }
583
- /**
584
- * Gets a RegEx object appropriate for splitting a Jexl string into its core
585
- * elements.
586
- * @returns {RegExp} An element-splitting RegExp object
587
- * @private
588
- */
589
- }, {
590
- key: "_getSplitRegex",
591
- value: function _getSplitRegex() {
592
- var _this = this;
593
- if (!this._splitRegex) {
594
- var elemArray = Object.keys(this._grammar.elements).sort(function(a, b) {
595
- return b.length - a.length;
596
- }).map(function(elem) {
597
- return _this._escapeRegExp(elem);
598
- }, this);
599
- this._splitRegex = new RegExp("(" + [preOpRegexElems.join("|"), elemArray.join("|"), postOpRegexElems.join("|")].join("|") + ")");
600
- }
601
- return this._splitRegex;
602
- }
603
- /**
604
- * Determines whether the addition of a '-' token should be interpreted as a
605
- * negative symbol for an upcoming number, given an array of tokens already
606
- * processed.
607
- * @param {Array<Object>} tokens An array of tokens already processed
608
- * @returns {boolean} true if adding a '-' should be considered a negative
609
- * symbol; false otherwise
610
- * @private
611
- */
612
- }, {
613
- key: "_isNegative",
614
- value: function _isNegative(tokens) {
615
- if (!tokens.length) return true;
616
- return minusNegatesAfter.some(function(type) {
617
- return type === tokens[tokens.length - 1].type;
618
- });
619
- }
620
- /**
621
- * A utility function to determine if a string consists of only space
622
- * characters.
623
- * @param {string} str A string to be tested
624
- * @returns {boolean} true if the string is empty or consists of only spaces;
625
- * false otherwise.
626
- * @private
627
- */
628
- }, {
629
- key: "_isWhitespace",
630
- value: function _isWhitespace(str) {
631
- return !!str.match(whitespaceRegex);
632
- }
633
- /**
634
- * Removes the beginning and trailing quotes from a string, unescapes any
635
- * escaped quotes on its interior, and unescapes any escaped escape
636
- * characters. Note that this function is not defensive; it assumes that the
637
- * provided string is not empty, and that its first and last characters are
638
- * actually quotes.
639
- * @param {string} str A string whose first and last characters are quotes
640
- * @returns {string} a string with the surrounding quotes stripped and escapes
641
- * properly processed.
642
- * @private
643
- */
644
- }, {
645
- key: "_unquote",
646
- value: function _unquote(str) {
647
- var quote = str[0];
648
- var escQuoteRegex = new RegExp("\\\\" + quote, "g");
649
- return str.substr(1, str.length - 2).replace(escQuoteRegex, quote).replace(escEscRegex, "\\");
650
- }
651
- }]);
652
- return Lexer2;
653
- })();
654
- module.exports = Lexer;
655
- }
656
- });
657
-
658
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/parser/handlers.js
659
- var require_handlers2 = __commonJS({
660
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/parser/handlers.js"(exports) {
661
- "use strict";
662
- exports.argVal = function(ast) {
663
- if (ast) this._cursor.args.push(ast);
664
- };
665
- exports.arrayStart = function() {
666
- this._placeAtCursor({
667
- type: "ArrayLiteral",
668
- value: []
669
- });
670
- };
671
- exports.arrayVal = function(ast) {
672
- if (ast) {
673
- this._cursor.value.push(ast);
674
- }
675
- };
676
- exports.binaryOp = function(token) {
677
- var precedence = this._grammar.elements[token.value].precedence || 0;
678
- var parent = this._cursor._parent;
679
- while (parent && parent.operator && this._grammar.elements[parent.operator].precedence >= precedence) {
680
- this._cursor = parent;
681
- parent = parent._parent;
682
- }
683
- var node = {
684
- type: "BinaryExpression",
685
- operator: token.value,
686
- left: this._cursor
687
- };
688
- this._setParent(this._cursor, node);
689
- this._cursor = parent;
690
- this._placeAtCursor(node);
691
- };
692
- exports.dot = function() {
693
- this._nextIdentEncapsulate = this._cursor && this._cursor.type !== "UnaryExpression" && (this._cursor.type !== "BinaryExpression" || this._cursor.type === "BinaryExpression" && this._cursor.right);
694
- this._nextIdentRelative = !this._cursor || this._cursor && !this._nextIdentEncapsulate;
695
- if (this._nextIdentRelative) {
696
- this._relative = true;
697
- }
698
- };
699
- exports.filter = function(ast) {
700
- this._placeBeforeCursor({
701
- type: "FilterExpression",
702
- expr: ast,
703
- relative: this._subParser.isRelative(),
704
- subject: this._cursor
705
- });
706
- };
707
- exports.functionCall = function() {
708
- this._placeBeforeCursor({
709
- type: "FunctionCall",
710
- name: this._cursor.value,
711
- args: [],
712
- pool: "functions"
713
- });
714
- };
715
- exports.identifier = function(token) {
716
- var node = {
717
- type: "Identifier",
718
- value: token.value
719
- };
720
- if (this._nextIdentEncapsulate) {
721
- node.from = this._cursor;
722
- this._placeBeforeCursor(node);
723
- this._nextIdentEncapsulate = false;
724
- } else {
725
- if (this._nextIdentRelative) {
726
- node.relative = true;
727
- this._nextIdentRelative = false;
728
- }
729
- this._placeAtCursor(node);
730
- }
731
- };
732
- exports.literal = function(token) {
733
- this._placeAtCursor({
734
- type: "Literal",
735
- value: token.value
736
- });
737
- };
738
- exports.objKey = function(token) {
739
- this._curObjKey = token.value;
740
- };
741
- exports.objStart = function() {
742
- this._placeAtCursor({
743
- type: "ObjectLiteral",
744
- value: {}
745
- });
746
- };
747
- exports.objVal = function(ast) {
748
- this._cursor.value[this._curObjKey] = ast;
749
- };
750
- exports.subExpression = function(ast) {
751
- this._placeAtCursor(ast);
752
- };
753
- exports.ternaryEnd = function(ast) {
754
- this._cursor.alternate = ast;
755
- };
756
- exports.ternaryMid = function(ast) {
757
- this._cursor.consequent = ast;
758
- };
759
- exports.ternaryStart = function() {
760
- this._tree = {
761
- type: "ConditionalExpression",
762
- test: this._tree
763
- };
764
- this._cursor = this._tree;
765
- };
766
- exports.transform = function(token) {
767
- this._placeBeforeCursor({
768
- type: "FunctionCall",
769
- name: token.value,
770
- args: [this._cursor],
771
- pool: "transforms"
772
- });
773
- };
774
- exports.unaryOp = function(token) {
775
- this._placeAtCursor({
776
- type: "UnaryExpression",
777
- operator: token.value
778
- });
779
- };
780
- }
781
- });
782
-
783
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/parser/states.js
784
- var require_states = __commonJS({
785
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/parser/states.js"(exports) {
786
- "use strict";
787
- var h = require_handlers2();
788
- exports.states = {
789
- expectOperand: {
790
- tokenTypes: {
791
- literal: {
792
- toState: "expectBinOp"
793
- },
794
- identifier: {
795
- toState: "identifier"
796
- },
797
- unaryOp: {},
798
- openParen: {
799
- toState: "subExpression"
800
- },
801
- openCurl: {
802
- toState: "expectObjKey",
803
- handler: h.objStart
804
- },
805
- dot: {
806
- toState: "traverse"
807
- },
808
- openBracket: {
809
- toState: "arrayVal",
810
- handler: h.arrayStart
811
- }
812
- }
813
- },
814
- expectBinOp: {
815
- tokenTypes: {
816
- binaryOp: {
817
- toState: "expectOperand"
818
- },
819
- pipe: {
820
- toState: "expectTransform"
821
- },
822
- dot: {
823
- toState: "traverse"
824
- },
825
- question: {
826
- toState: "ternaryMid",
827
- handler: h.ternaryStart
828
- }
829
- },
830
- completable: true
831
- },
832
- expectTransform: {
833
- tokenTypes: {
834
- identifier: {
835
- toState: "postTransform",
836
- handler: h.transform
837
- }
838
- }
839
- },
840
- expectObjKey: {
841
- tokenTypes: {
842
- identifier: {
843
- toState: "expectKeyValSep",
844
- handler: h.objKey
845
- },
846
- closeCurl: {
847
- toState: "expectBinOp"
848
- }
849
- }
850
- },
851
- expectKeyValSep: {
852
- tokenTypes: {
853
- colon: {
854
- toState: "objVal"
855
- }
856
- }
857
- },
858
- postTransform: {
859
- tokenTypes: {
860
- openParen: {
861
- toState: "argVal"
862
- },
863
- binaryOp: {
864
- toState: "expectOperand"
865
- },
866
- dot: {
867
- toState: "traverse"
868
- },
869
- openBracket: {
870
- toState: "filter"
871
- },
872
- pipe: {
873
- toState: "expectTransform"
874
- }
875
- },
876
- completable: true
877
- },
878
- postArgs: {
879
- tokenTypes: {
880
- binaryOp: {
881
- toState: "expectOperand"
882
- },
883
- dot: {
884
- toState: "traverse"
885
- },
886
- openBracket: {
887
- toState: "filter"
888
- },
889
- pipe: {
890
- toState: "expectTransform"
891
- }
892
- },
893
- completable: true
894
- },
895
- identifier: {
896
- tokenTypes: {
897
- binaryOp: {
898
- toState: "expectOperand"
899
- },
900
- dot: {
901
- toState: "traverse"
902
- },
903
- openBracket: {
904
- toState: "filter"
905
- },
906
- openParen: {
907
- toState: "argVal",
908
- handler: h.functionCall
909
- },
910
- pipe: {
911
- toState: "expectTransform"
912
- },
913
- question: {
914
- toState: "ternaryMid",
915
- handler: h.ternaryStart
916
- }
917
- },
918
- completable: true
919
- },
920
- traverse: {
921
- tokenTypes: {
922
- identifier: {
923
- toState: "identifier"
924
- }
925
- }
926
- },
927
- filter: {
928
- subHandler: h.filter,
929
- endStates: {
930
- closeBracket: "identifier"
931
- }
932
- },
933
- subExpression: {
934
- subHandler: h.subExpression,
935
- endStates: {
936
- closeParen: "expectBinOp"
937
- }
938
- },
939
- argVal: {
940
- subHandler: h.argVal,
941
- endStates: {
942
- comma: "argVal",
943
- closeParen: "postArgs"
944
- }
945
- },
946
- objVal: {
947
- subHandler: h.objVal,
948
- endStates: {
949
- comma: "expectObjKey",
950
- closeCurl: "expectBinOp"
951
- }
952
- },
953
- arrayVal: {
954
- subHandler: h.arrayVal,
955
- endStates: {
956
- comma: "arrayVal",
957
- closeBracket: "expectBinOp"
958
- }
959
- },
960
- ternaryMid: {
961
- subHandler: h.ternaryMid,
962
- endStates: {
963
- colon: "ternaryEnd"
964
- }
965
- },
966
- ternaryEnd: {
967
- subHandler: h.ternaryEnd,
968
- completable: true
969
- }
970
- };
971
- }
972
- });
973
-
974
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/parser/Parser.js
975
- var require_Parser = __commonJS({
976
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/parser/Parser.js"(exports, module) {
977
- "use strict";
978
- var _interopRequireDefault = require_interopRequireDefault();
979
- var _classCallCheck2 = _interopRequireDefault(require_classCallCheck());
980
- var _createClass2 = _interopRequireDefault(require_createClass());
981
- var handlers = require_handlers2();
982
- var states = require_states().states;
983
- var Parser = /* @__PURE__ */ (function() {
984
- function Parser2(grammar, prefix, stopMap) {
985
- (0, _classCallCheck2.default)(this, Parser2);
986
- this._grammar = grammar;
987
- this._state = "expectOperand";
988
- this._tree = null;
989
- this._exprStr = prefix || "";
990
- this._relative = false;
991
- this._stopMap = stopMap || {};
992
- }
993
- (0, _createClass2.default)(Parser2, [{
994
- key: "addToken",
995
- value: function addToken(token) {
996
- if (this._state === "complete") {
997
- throw new Error("Cannot add a new token to a completed Parser");
998
- }
999
- var state = states[this._state];
1000
- var startExpr = this._exprStr;
1001
- this._exprStr += token.raw;
1002
- if (state.subHandler) {
1003
- if (!this._subParser) {
1004
- this._startSubExpression(startExpr);
1005
- }
1006
- var stopState = this._subParser.addToken(token);
1007
- if (stopState) {
1008
- this._endSubExpression();
1009
- if (this._parentStop) return stopState;
1010
- this._state = stopState;
1011
- }
1012
- } else if (state.tokenTypes[token.type]) {
1013
- var typeOpts = state.tokenTypes[token.type];
1014
- var handleFunc = handlers[token.type];
1015
- if (typeOpts.handler) {
1016
- handleFunc = typeOpts.handler;
1017
- }
1018
- if (handleFunc) {
1019
- handleFunc.call(this, token);
1020
- }
1021
- if (typeOpts.toState) {
1022
- this._state = typeOpts.toState;
1023
- }
1024
- } else if (this._stopMap[token.type]) {
1025
- return this._stopMap[token.type];
1026
- } else {
1027
- throw new Error("Token ".concat(token.raw, " (").concat(token.type, ") unexpected in expression: ").concat(this._exprStr));
1028
- }
1029
- return false;
1030
- }
1031
- /**
1032
- * Processes an array of tokens iteratively through the {@link #addToken}
1033
- * function.
1034
- * @param {Array<{type: <string>}>} tokens An array of tokens, as provided by
1035
- * the {@link Lexer#tokenize} function.
1036
- */
1037
- }, {
1038
- key: "addTokens",
1039
- value: function addTokens(tokens) {
1040
- tokens.forEach(this.addToken, this);
1041
- }
1042
- /**
1043
- * Marks this Parser instance as completed and retrieves the full AST.
1044
- * @returns {{}|null} a full expression tree, ready for evaluation by the
1045
- * {@link Evaluator#eval} function, or null if no tokens were passed to
1046
- * the parser before complete was called
1047
- * @throws {Error} if the parser is not in a state where it's legal to end
1048
- * the expression, indicating that the expression is incomplete
1049
- */
1050
- }, {
1051
- key: "complete",
1052
- value: function complete() {
1053
- if (this._cursor && !states[this._state].completable) {
1054
- throw new Error("Unexpected end of expression: ".concat(this._exprStr));
1055
- }
1056
- if (this._subParser) {
1057
- this._endSubExpression();
1058
- }
1059
- this._state = "complete";
1060
- return this._cursor ? this._tree : null;
1061
- }
1062
- /**
1063
- * Indicates whether the expression tree contains a relative path identifier.
1064
- * @returns {boolean} true if a relative identifier exists false otherwise.
1065
- */
1066
- }, {
1067
- key: "isRelative",
1068
- value: function isRelative() {
1069
- return this._relative;
1070
- }
1071
- /**
1072
- * Ends a subexpression by completing the subParser and passing its result
1073
- * to the subHandler configured in the current state.
1074
- * @private
1075
- */
1076
- }, {
1077
- key: "_endSubExpression",
1078
- value: function _endSubExpression() {
1079
- states[this._state].subHandler.call(this, this._subParser.complete());
1080
- this._subParser = null;
1081
- }
1082
- /**
1083
- * Places a new tree node at the current position of the cursor (to the 'right'
1084
- * property) and then advances the cursor to the new node. This function also
1085
- * handles setting the parent of the new node.
1086
- * @param {{type: <string>}} node A node to be added to the AST
1087
- * @private
1088
- */
1089
- }, {
1090
- key: "_placeAtCursor",
1091
- value: function _placeAtCursor(node) {
1092
- if (!this._cursor) {
1093
- this._tree = node;
1094
- } else {
1095
- this._cursor.right = node;
1096
- this._setParent(node, this._cursor);
1097
- }
1098
- this._cursor = node;
1099
- }
1100
- /**
1101
- * Places a tree node before the current position of the cursor, replacing
1102
- * the node that the cursor currently points to. This should only be called in
1103
- * cases where the cursor is known to exist, and the provided node already
1104
- * contains a pointer to what's at the cursor currently.
1105
- * @param {{type: <string>}} node A node to be added to the AST
1106
- * @private
1107
- */
1108
- }, {
1109
- key: "_placeBeforeCursor",
1110
- value: function _placeBeforeCursor(node) {
1111
- this._cursor = this._cursor._parent;
1112
- this._placeAtCursor(node);
1113
- }
1114
- /**
1115
- * Sets the parent of a node by creating a non-enumerable _parent property
1116
- * that points to the supplied parent argument.
1117
- * @param {{type: <string>}} node A node of the AST on which to set a new
1118
- * parent
1119
- * @param {{type: <string>}} parent An existing node of the AST to serve as the
1120
- * parent of the new node
1121
- * @private
1122
- */
1123
- }, {
1124
- key: "_setParent",
1125
- value: function _setParent(node, parent) {
1126
- Object.defineProperty(node, "_parent", {
1127
- value: parent,
1128
- writable: true
1129
- });
1130
- }
1131
- /**
1132
- * Prepares the Parser to accept a subexpression by (re)instantiating the
1133
- * subParser.
1134
- * @param {string} [exprStr] The expression string to prefix to the new Parser
1135
- * @private
1136
- */
1137
- }, {
1138
- key: "_startSubExpression",
1139
- value: function _startSubExpression(exprStr) {
1140
- var endStates = states[this._state].endStates;
1141
- if (!endStates) {
1142
- this._parentStop = true;
1143
- endStates = this._stopMap;
1144
- }
1145
- this._subParser = new Parser2(this._grammar, exprStr, endStates);
1146
- }
1147
- }]);
1148
- return Parser2;
1149
- })();
1150
- module.exports = Parser;
1151
- }
1152
- });
1153
-
1154
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/PromiseSync.js
1155
- var require_PromiseSync = __commonJS({
1156
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/PromiseSync.js"(exports, module) {
1157
- "use strict";
1158
- var _interopRequireDefault = require_interopRequireDefault();
1159
- var _classCallCheck2 = _interopRequireDefault(require_classCallCheck());
1160
- var _createClass2 = _interopRequireDefault(require_createClass());
1161
- var PromiseSync = /* @__PURE__ */ (function() {
1162
- function PromiseSync2(fn) {
1163
- (0, _classCallCheck2.default)(this, PromiseSync2);
1164
- fn(this._resolve.bind(this), this._reject.bind(this));
1165
- }
1166
- (0, _createClass2.default)(PromiseSync2, [{
1167
- key: "catch",
1168
- value: function _catch(rejected) {
1169
- if (this.error) {
1170
- try {
1171
- this._resolve(rejected(this.error));
1172
- } catch (e) {
1173
- this._reject(e);
1174
- }
1175
- }
1176
- return this;
1177
- }
1178
- }, {
1179
- key: "then",
1180
- value: function then(resolved, rejected) {
1181
- if (!this.error) {
1182
- try {
1183
- this._resolve(resolved(this.value));
1184
- } catch (e) {
1185
- this._reject(e);
1186
- }
1187
- }
1188
- if (rejected) this.catch(rejected);
1189
- return this;
1190
- }
1191
- }, {
1192
- key: "_reject",
1193
- value: function _reject(error) {
1194
- this.value = void 0;
1195
- this.error = error;
1196
- }
1197
- }, {
1198
- key: "_resolve",
1199
- value: function _resolve(val) {
1200
- if (val instanceof PromiseSync2) {
1201
- if (val.error) {
1202
- this._reject(val.error);
1203
- } else {
1204
- this._resolve(val.value);
1205
- }
1206
- } else {
1207
- this.value = val;
1208
- this.error = void 0;
1209
- }
1210
- }
1211
- }]);
1212
- return PromiseSync2;
1213
- })();
1214
- PromiseSync.all = function(vals) {
1215
- return new PromiseSync(function(resolve) {
1216
- var resolved = vals.map(function(val) {
1217
- while (val instanceof PromiseSync) {
1218
- if (val.error) throw Error(val.error);
1219
- val = val.value;
1220
- }
1221
- return val;
1222
- });
1223
- resolve(resolved);
1224
- });
1225
- };
1226
- PromiseSync.resolve = function(val) {
1227
- return new PromiseSync(function(resolve) {
1228
- return resolve(val);
1229
- });
1230
- };
1231
- PromiseSync.reject = function(error) {
1232
- return new PromiseSync(function(resolve, reject) {
1233
- return reject(error);
1234
- });
1235
- };
1236
- module.exports = PromiseSync;
1237
- }
1238
- });
1239
-
1240
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/Expression.js
1241
- var require_Expression = __commonJS({
1242
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/Expression.js"(exports, module) {
1243
- "use strict";
1244
- var _interopRequireDefault = require_interopRequireDefault();
1245
- var _classCallCheck2 = _interopRequireDefault(require_classCallCheck());
1246
- var _createClass2 = _interopRequireDefault(require_createClass());
1247
- var Evaluator = require_Evaluator();
1248
- var Lexer = require_Lexer();
1249
- var Parser = require_Parser();
1250
- var PromiseSync = require_PromiseSync();
1251
- var Expression = /* @__PURE__ */ (function() {
1252
- function Expression2(grammar, exprStr) {
1253
- (0, _classCallCheck2.default)(this, Expression2);
1254
- this._grammar = grammar;
1255
- this._exprStr = exprStr;
1256
- this._ast = null;
1257
- }
1258
- (0, _createClass2.default)(Expression2, [{
1259
- key: "compile",
1260
- value: function compile() {
1261
- var lexer = new Lexer(this._grammar);
1262
- var parser = new Parser(this._grammar);
1263
- var tokens = lexer.tokenize(this._exprStr);
1264
- parser.addTokens(tokens);
1265
- this._ast = parser.complete();
1266
- return this;
1267
- }
1268
- /**
1269
- * Asynchronously evaluates the expression within an optional context.
1270
- * @param {Object} [context] A mapping of variables to values, which will be
1271
- * made accessible to the Jexl expression when evaluating it
1272
- * @returns {Promise<*>} resolves with the result of the evaluation.
1273
- */
1274
- }, {
1275
- key: "eval",
1276
- value: function _eval() {
1277
- var context = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1278
- return this._eval(context, Promise);
1279
- }
1280
- /**
1281
- * Synchronously evaluates the expression within an optional context.
1282
- * @param {Object} [context] A mapping of variables to values, which will be
1283
- * made accessible to the Jexl expression when evaluating it
1284
- * @returns {*} the result of the evaluation.
1285
- * @throws {*} on error
1286
- */
1287
- }, {
1288
- key: "evalSync",
1289
- value: function evalSync() {
1290
- var context = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1291
- var res = this._eval(context, PromiseSync);
1292
- if (res.error) throw res.error;
1293
- return res.value;
1294
- }
1295
- }, {
1296
- key: "_eval",
1297
- value: function _eval(context, promise) {
1298
- var _this = this;
1299
- return promise.resolve().then(function() {
1300
- var ast = _this._getAst();
1301
- var evaluator = new Evaluator(_this._grammar, context, void 0, promise);
1302
- return evaluator.eval(ast);
1303
- });
1304
- }
1305
- }, {
1306
- key: "_getAst",
1307
- value: function _getAst() {
1308
- if (!this._ast) this.compile();
1309
- return this._ast;
1310
- }
1311
- }]);
1312
- return Expression2;
1313
- })();
1314
- module.exports = Expression;
1315
- }
1316
- });
1317
-
1318
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/grammar.js
1319
- var require_grammar = __commonJS({
1320
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/grammar.js"(exports) {
1321
- "use strict";
1322
- exports.getGrammar = function() {
1323
- return {
1324
- /**
1325
- * A map of all expression elements to their properties. Note that changes
1326
- * here may require changes in the Lexer or Parser.
1327
- * @type {{}}
1328
- */
1329
- elements: {
1330
- ".": {
1331
- type: "dot"
1332
- },
1333
- "[": {
1334
- type: "openBracket"
1335
- },
1336
- "]": {
1337
- type: "closeBracket"
1338
- },
1339
- "|": {
1340
- type: "pipe"
1341
- },
1342
- "{": {
1343
- type: "openCurl"
1344
- },
1345
- "}": {
1346
- type: "closeCurl"
1347
- },
1348
- ":": {
1349
- type: "colon"
1350
- },
1351
- ",": {
1352
- type: "comma"
1353
- },
1354
- "(": {
1355
- type: "openParen"
1356
- },
1357
- ")": {
1358
- type: "closeParen"
1359
- },
1360
- "?": {
1361
- type: "question"
1362
- },
1363
- "+": {
1364
- type: "binaryOp",
1365
- precedence: 30,
1366
- eval: function _eval(left, right) {
1367
- return left + right;
1368
- }
1369
- },
1370
- "-": {
1371
- type: "binaryOp",
1372
- precedence: 30,
1373
- eval: function _eval(left, right) {
1374
- return left - right;
1375
- }
1376
- },
1377
- "*": {
1378
- type: "binaryOp",
1379
- precedence: 40,
1380
- eval: function _eval(left, right) {
1381
- return left * right;
1382
- }
1383
- },
1384
- "/": {
1385
- type: "binaryOp",
1386
- precedence: 40,
1387
- eval: function _eval(left, right) {
1388
- return left / right;
1389
- }
1390
- },
1391
- "//": {
1392
- type: "binaryOp",
1393
- precedence: 40,
1394
- eval: function _eval(left, right) {
1395
- return Math.floor(left / right);
1396
- }
1397
- },
1398
- "%": {
1399
- type: "binaryOp",
1400
- precedence: 50,
1401
- eval: function _eval(left, right) {
1402
- return left % right;
1403
- }
1404
- },
1405
- "^": {
1406
- type: "binaryOp",
1407
- precedence: 50,
1408
- eval: function _eval(left, right) {
1409
- return Math.pow(left, right);
1410
- }
1411
- },
1412
- "==": {
1413
- type: "binaryOp",
1414
- precedence: 20,
1415
- eval: function _eval(left, right) {
1416
- return left == right;
1417
- }
1418
- },
1419
- "!=": {
1420
- type: "binaryOp",
1421
- precedence: 20,
1422
- eval: function _eval(left, right) {
1423
- return left != right;
1424
- }
1425
- },
1426
- ">": {
1427
- type: "binaryOp",
1428
- precedence: 20,
1429
- eval: function _eval(left, right) {
1430
- return left > right;
1431
- }
1432
- },
1433
- ">=": {
1434
- type: "binaryOp",
1435
- precedence: 20,
1436
- eval: function _eval(left, right) {
1437
- return left >= right;
1438
- }
1439
- },
1440
- "<": {
1441
- type: "binaryOp",
1442
- precedence: 20,
1443
- eval: function _eval(left, right) {
1444
- return left < right;
1445
- }
1446
- },
1447
- "<=": {
1448
- type: "binaryOp",
1449
- precedence: 20,
1450
- eval: function _eval(left, right) {
1451
- return left <= right;
1452
- }
1453
- },
1454
- "&&": {
1455
- type: "binaryOp",
1456
- precedence: 10,
1457
- evalOnDemand: function evalOnDemand(left, right) {
1458
- return left.eval().then(function(leftVal) {
1459
- if (!leftVal) return leftVal;
1460
- return right.eval();
1461
- });
1462
- }
1463
- },
1464
- "||": {
1465
- type: "binaryOp",
1466
- precedence: 10,
1467
- evalOnDemand: function evalOnDemand(left, right) {
1468
- return left.eval().then(function(leftVal) {
1469
- if (leftVal) return leftVal;
1470
- return right.eval();
1471
- });
1472
- }
1473
- },
1474
- in: {
1475
- type: "binaryOp",
1476
- precedence: 20,
1477
- eval: function _eval(left, right) {
1478
- if (typeof right === "string") {
1479
- return right.indexOf(left) !== -1;
1480
- }
1481
- if (Array.isArray(right)) {
1482
- return right.some(function(elem) {
1483
- return elem === left;
1484
- });
1485
- }
1486
- return false;
1487
- }
1488
- },
1489
- "!": {
1490
- type: "unaryOp",
1491
- precedence: Infinity,
1492
- eval: function _eval(right) {
1493
- return !right;
1494
- }
1495
- }
1496
- },
1497
- /**
1498
- * A map of function names to javascript functions. A Jexl function
1499
- * takes zero ore more arguemnts:
1500
- *
1501
- * - {*} ...args: A variable number of arguments passed to this function.
1502
- * All of these are pre-evaluated to their actual values before calling
1503
- * the function.
1504
- *
1505
- * The Jexl function should return either the transformed value, or
1506
- * a Promises/A+ Promise object that resolves with the value and rejects
1507
- * or throws only when an unrecoverable error occurs. Functions should
1508
- * generally return undefined when they don't make sense to be used on the
1509
- * given value type, rather than throw/reject. An error is only
1510
- * appropriate when the function would normally return a value, but
1511
- * cannot due to some other failure.
1512
- */
1513
- functions: {},
1514
- /**
1515
- * A map of transform names to transform functions. A transform function
1516
- * takes one ore more arguemnts:
1517
- *
1518
- * - {*} val: A value to be transformed
1519
- * - {*} ...args: A variable number of arguments passed to this transform.
1520
- * All of these are pre-evaluated to their actual values before calling
1521
- * the function.
1522
- *
1523
- * The transform function should return either the transformed value, or
1524
- * a Promises/A+ Promise object that resolves with the value and rejects
1525
- * or throws only when an unrecoverable error occurs. Transforms should
1526
- * generally return undefined when they don't make sense to be used on the
1527
- * given value type, rather than throw/reject. An error is only
1528
- * appropriate when the transform would normally return a value, but
1529
- * cannot due to some other failure.
1530
- */
1531
- transforms: {}
1532
- };
1533
- };
1534
- }
1535
- });
1536
-
1537
- // ../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/Jexl.js
1538
- var require_Jexl = __commonJS({
1539
- "../../node_modules/.pnpm/jexl@2.3.0/node_modules/jexl/dist/Jexl.js"(exports, module) {
1540
- "use strict";
1541
- var _interopRequireDefault = require_interopRequireDefault();
1542
- var _defineProperty2 = _interopRequireDefault(require_defineProperty());
1543
- var _classCallCheck2 = _interopRequireDefault(require_classCallCheck());
1544
- var _createClass2 = _interopRequireDefault(require_createClass());
1545
- var Expression = require_Expression();
1546
- var _require = require_grammar();
1547
- var getGrammar = _require.getGrammar;
1548
- var Jexl = /* @__PURE__ */ (function() {
1549
- function Jexl2() {
1550
- (0, _classCallCheck2.default)(this, Jexl2);
1551
- this.expr = this.expr.bind(this);
1552
- this._grammar = getGrammar();
1553
- }
1554
- (0, _createClass2.default)(Jexl2, [{
1555
- key: "addBinaryOp",
1556
- value: function addBinaryOp(operator, precedence, fn, manualEval) {
1557
- this._addGrammarElement(operator, (0, _defineProperty2.default)({
1558
- type: "binaryOp",
1559
- precedence
1560
- }, manualEval ? "evalOnDemand" : "eval", fn));
1561
- }
1562
- /**
1563
- * Adds or replaces an expression function in this Jexl instance.
1564
- * @param {string} name The name of the expression function, as it will be
1565
- * used within Jexl expressions
1566
- * @param {function} fn The javascript function to be executed when this
1567
- * expression function is invoked. It will be provided with each argument
1568
- * supplied in the expression, in the same order.
1569
- */
1570
- }, {
1571
- key: "addFunction",
1572
- value: function addFunction(name, fn) {
1573
- this._grammar.functions[name] = fn;
1574
- }
1575
- /**
1576
- * Syntactic sugar for calling {@link #addFunction} repeatedly. This function
1577
- * accepts a map of one or more expression function names to their javascript
1578
- * function counterpart.
1579
- * @param {{}} map A map of expression function names to javascript functions
1580
- */
1581
- }, {
1582
- key: "addFunctions",
1583
- value: function addFunctions(map) {
1584
- for (var key in map) {
1585
- this._grammar.functions[key] = map[key];
1586
- }
1587
- }
1588
- /**
1589
- * Adds a unary operator to Jexl. Unary operators are currently only supported
1590
- * on the left side of the value on which it will operate.
1591
- * @param {string} operator The operator string to be added
1592
- * @param {function} fn A function to run to calculate the result. The function
1593
- * will be called with one argument: the literal value to the right of the
1594
- * operator. It should return either the resulting value, or a Promise
1595
- * that resolves with the resulting value.
1596
- */
1597
- }, {
1598
- key: "addUnaryOp",
1599
- value: function addUnaryOp(operator, fn) {
1600
- this._addGrammarElement(operator, {
1601
- type: "unaryOp",
1602
- weight: Infinity,
1603
- eval: fn
1604
- });
1605
- }
1606
- /**
1607
- * Adds or replaces a transform function in this Jexl instance.
1608
- * @param {string} name The name of the transform function, as it will be used
1609
- * within Jexl expressions
1610
- * @param {function} fn The function to be executed when this transform is
1611
- * invoked. It will be provided with at least one argument:
1612
- * - {*} value: The value to be transformed
1613
- * - {...*} args: The arguments for this transform
1614
- */
1615
- }, {
1616
- key: "addTransform",
1617
- value: function addTransform(name, fn) {
1618
- this._grammar.transforms[name] = fn;
1619
- }
1620
- /**
1621
- * Syntactic sugar for calling {@link #addTransform} repeatedly. This function
1622
- * accepts a map of one or more transform names to their transform function.
1623
- * @param {{}} map A map of transform names to transform functions
1624
- */
1625
- }, {
1626
- key: "addTransforms",
1627
- value: function addTransforms(map) {
1628
- for (var key in map) {
1629
- this._grammar.transforms[key] = map[key];
1630
- }
1631
- }
1632
- /**
1633
- * Creates an Expression object from the given Jexl expression string, and
1634
- * immediately compiles it. The returned Expression object can then be
1635
- * evaluated multiple times with new contexts, without generating any
1636
- * additional string processing overhead.
1637
- * @param {string} expression The Jexl expression to be compiled
1638
- * @returns {Expression} The compiled Expression object
1639
- */
1640
- }, {
1641
- key: "compile",
1642
- value: function compile(expression) {
1643
- var exprObj = this.createExpression(expression);
1644
- return exprObj.compile();
1645
- }
1646
- /**
1647
- * Constructs an Expression object from a Jexl expression string.
1648
- * @param {string} expression The Jexl expression to be wrapped in an
1649
- * Expression object
1650
- * @returns {Expression} The Expression object representing the given string
1651
- */
1652
- }, {
1653
- key: "createExpression",
1654
- value: function createExpression(expression) {
1655
- return new Expression(this._grammar, expression);
1656
- }
1657
- /**
1658
- * Retrieves a previously set expression function.
1659
- * @param {string} name The name of the expression function
1660
- * @returns {function} The expression function
1661
- */
1662
- }, {
1663
- key: "getFunction",
1664
- value: function getFunction(name) {
1665
- return this._grammar.functions[name];
1666
- }
1667
- /**
1668
- * Retrieves a previously set transform function.
1669
- * @param {string} name The name of the transform function
1670
- * @returns {function} The transform function
1671
- */
1672
- }, {
1673
- key: "getTransform",
1674
- value: function getTransform(name) {
1675
- return this._grammar.transforms[name];
1676
- }
1677
- /**
1678
- * Asynchronously evaluates a Jexl string within an optional context.
1679
- * @param {string} expression The Jexl expression to be evaluated
1680
- * @param {Object} [context] A mapping of variables to values, which will be
1681
- * made accessible to the Jexl expression when evaluating it
1682
- * @returns {Promise<*>} resolves with the result of the evaluation.
1683
- */
1684
- }, {
1685
- key: "eval",
1686
- value: function _eval(expression) {
1687
- var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1688
- var exprObj = this.createExpression(expression);
1689
- return exprObj.eval(context);
1690
- }
1691
- /**
1692
- * Synchronously evaluates a Jexl string within an optional context.
1693
- * @param {string} expression The Jexl expression to be evaluated
1694
- * @param {Object} [context] A mapping of variables to values, which will be
1695
- * made accessible to the Jexl expression when evaluating it
1696
- * @returns {*} the result of the evaluation.
1697
- * @throws {*} on error
1698
- */
1699
- }, {
1700
- key: "evalSync",
1701
- value: function evalSync(expression) {
1702
- var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1703
- var exprObj = this.createExpression(expression);
1704
- return exprObj.evalSync(context);
1705
- }
1706
- /**
1707
- * A JavaScript template literal to allow expressions to be defined by the
1708
- * syntax: expr`40 + 2`
1709
- * @param {Array<string>} strs
1710
- * @param {...any} args
1711
- */
1712
- }, {
1713
- key: "expr",
1714
- value: function expr(strs) {
1715
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1716
- args[_key - 1] = arguments[_key];
1717
- }
1718
- var exprStr = strs.reduce(function(acc, str, idx) {
1719
- var arg = idx < args.length ? args[idx] : "";
1720
- acc += str + arg;
1721
- return acc;
1722
- }, "");
1723
- return this.createExpression(exprStr);
1724
- }
1725
- /**
1726
- * Removes a binary or unary operator from the Jexl grammar.
1727
- * @param {string} operator The operator string to be removed
1728
- */
1729
- }, {
1730
- key: "removeOp",
1731
- value: function removeOp(operator) {
1732
- if (this._grammar.elements[operator] && (this._grammar.elements[operator].type === "binaryOp" || this._grammar.elements[operator].type === "unaryOp")) {
1733
- delete this._grammar.elements[operator];
1734
- }
1735
- }
1736
- /**
1737
- * Adds an element to the grammar map used by this Jexl instance.
1738
- * @param {string} str The key string to be added
1739
- * @param {{type: <string>}} obj A map of configuration options for this
1740
- * grammar element
1741
- * @private
1742
- */
1743
- }, {
1744
- key: "_addGrammarElement",
1745
- value: function _addGrammarElement(str, obj) {
1746
- this._grammar.elements[str] = obj;
1747
- }
1748
- }]);
1749
- return Jexl2;
1750
- })();
1751
- module.exports = new Jexl();
1752
- module.exports.Jexl = Jexl;
1753
- }
1754
- });
1755
-
1756
- export {
1757
- require_Jexl
1758
- };