@aws-lambda-powertools/jmespath 2.5.0 → 2.7.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/README.md +24 -20
- package/lib/cjs/Functions.d.ts.map +1 -1
- package/lib/cjs/Functions.js +26 -39
- package/lib/cjs/Lexer.d.ts.map +1 -1
- package/lib/cjs/Lexer.js +10 -18
- package/lib/cjs/ParsedResult.d.ts +1 -1
- package/lib/cjs/ParsedResult.d.ts.map +1 -1
- package/lib/cjs/Parser.d.ts.map +1 -1
- package/lib/cjs/Parser.js +51 -74
- package/lib/cjs/TreeInterpreter.d.ts +1 -1
- package/lib/cjs/TreeInterpreter.d.ts.map +1 -1
- package/lib/cjs/TreeInterpreter.js +8 -15
- package/lib/cjs/constants.js +2 -2
- package/lib/cjs/envelopes.d.ts.map +1 -1
- package/lib/cjs/envelopes.js +2 -5
- package/lib/cjs/types.d.ts +2 -2
- package/lib/cjs/types.d.ts.map +1 -1
- package/lib/cjs/utils.d.ts.map +1 -1
- package/lib/cjs/utils.js +12 -11
- package/lib/esm/Functions.d.ts.map +1 -1
- package/lib/esm/Functions.js +26 -39
- package/lib/esm/Lexer.d.ts.map +1 -1
- package/lib/esm/Lexer.js +10 -18
- package/lib/esm/ParsedResult.d.ts +1 -1
- package/lib/esm/ParsedResult.d.ts.map +1 -1
- package/lib/esm/Parser.d.ts.map +1 -1
- package/lib/esm/Parser.js +52 -75
- package/lib/esm/TreeInterpreter.d.ts +1 -1
- package/lib/esm/TreeInterpreter.d.ts.map +1 -1
- package/lib/esm/TreeInterpreter.js +8 -15
- package/lib/esm/constants.js +2 -2
- package/lib/esm/envelopes.d.ts.map +1 -1
- package/lib/esm/envelopes.js +2 -5
- package/lib/esm/types.d.ts +2 -2
- package/lib/esm/types.d.ts.map +1 -1
- package/lib/esm/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +13 -12
- package/package.json +2 -2
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TreeInterpreter = void 0;
|
|
4
4
|
const typeutils_1 = require("@aws-lambda-powertools/commons/typeutils");
|
|
5
|
-
const errors_js_1 = require("./errors.js");
|
|
6
5
|
const Expression_js_1 = require("./Expression.js");
|
|
7
6
|
const Functions_js_1 = require("./Functions.js");
|
|
7
|
+
const errors_js_1 = require("./errors.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -67,9 +67,7 @@ class TreeInterpreter {
|
|
|
67
67
|
if (visitMethod) {
|
|
68
68
|
return visitMethod.call(this, node, value);
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
throw new errors_js_1.JMESPathError(`Not Implemented: Invalid node type: ${node.type}`);
|
|
72
|
-
}
|
|
70
|
+
throw new errors_js_1.JMESPathError(`Not Implemented: Invalid node type: ${node.type}`);
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* Visit a subexpression, index expression, or pipe node.
|
|
@@ -103,9 +101,7 @@ class TreeInterpreter {
|
|
|
103
101
|
node.value in value) {
|
|
104
102
|
return value[node.value];
|
|
105
103
|
}
|
|
106
|
-
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
104
|
+
return null;
|
|
109
105
|
}
|
|
110
106
|
/**
|
|
111
107
|
* Visit a comparator node.
|
|
@@ -123,24 +119,22 @@ class TreeInterpreter {
|
|
|
123
119
|
if (comparator === 'eq') {
|
|
124
120
|
return (0, typeutils_1.isStrictEqual)(left, right);
|
|
125
121
|
}
|
|
126
|
-
|
|
122
|
+
if (comparator === 'ne') {
|
|
127
123
|
return !(0, typeutils_1.isStrictEqual)(left, right);
|
|
128
124
|
}
|
|
129
|
-
|
|
125
|
+
if (typeof left === 'number' && typeof right === 'number') {
|
|
130
126
|
// Ordering operators only work on numbers. Evaluating them on other
|
|
131
127
|
// types will return null.
|
|
132
128
|
if (comparator === 'lt') {
|
|
133
129
|
return left < right;
|
|
134
130
|
}
|
|
135
|
-
|
|
131
|
+
if (comparator === 'lte') {
|
|
136
132
|
return left <= right;
|
|
137
133
|
}
|
|
138
|
-
|
|
134
|
+
if (comparator === 'gt') {
|
|
139
135
|
return left > right;
|
|
140
136
|
}
|
|
141
|
-
|
|
142
|
-
return left >= right;
|
|
143
|
-
}
|
|
137
|
+
return left >= right;
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
else {
|
|
@@ -193,7 +187,6 @@ class TreeInterpreter {
|
|
|
193
187
|
// doesn't know that, so we have to use @ts-ignore to tell it that it's
|
|
194
188
|
// okay. We could use a type assertion like `as keyof Functions`, but
|
|
195
189
|
// we also want to keep the args generic, so for now we'll just ignore it.
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
197
190
|
// @ts-ignore-next-line
|
|
198
191
|
return this.#functions[funcName](args);
|
|
199
192
|
}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -60,12 +60,12 @@ const DIGITS = '0123456789';
|
|
|
60
60
|
/**
|
|
61
61
|
* The set of ASCII letters and digits allowed in JMESPath identifiers.
|
|
62
62
|
*/
|
|
63
|
-
const START_IDENTIFIER = new Set(ASCII_LETTERS
|
|
63
|
+
const START_IDENTIFIER = new Set(`${ASCII_LETTERS}_`);
|
|
64
64
|
exports.START_IDENTIFIER = START_IDENTIFIER;
|
|
65
65
|
/**
|
|
66
66
|
* The set of ASCII letters and digits allowed in JMESPath identifiers.
|
|
67
67
|
*/
|
|
68
|
-
const VALID_IDENTIFIER = new Set(ASCII_LETTERS
|
|
68
|
+
const VALID_IDENTIFIER = new Set(`${ASCII_LETTERS}${DIGITS}_`);
|
|
69
69
|
exports.VALID_IDENTIFIER = VALID_IDENTIFIER;
|
|
70
70
|
/**
|
|
71
71
|
* The set of ASCII digits allowed in JMESPath identifiers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/envelopes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,QAAA,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/envelopes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,QAAA,MAAM,uBAAuB,GAAI,CAAC,QAC1B,UAAU,YACN,MAAM,YACN,sBAAsB,KAC/B,CAMF,CAAC;AAEF,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,GAAG,qCAAqC,CAAC;AAC/C,QAAA,MAAM,GAAG,gDAAgD,CAAC;AAC1D,QAAA,MAAM,WAAW,WAAW,CAAC;AAC7B,QAAA,MAAM,2BAA2B,WAAW,CAAC;AAC7C,QAAA,MAAM,mBAAmB,gEACsC,CAAC;AAChE,QAAA,MAAM,eAAe,2EACqD,CAAC;AAC3E,QAAA,MAAM,UAAU,yEACwD,CAAC;AACzE,QAAA,MAAM,MAAM,gDAAgD,CAAC;AAC7D,QAAA,MAAM,uBAAuB,4FAC8D,CAAC;AAC5F,QAAA,MAAM,mBAAmB,mEACyC,CAAC;AACnE,QAAA,MAAM,kBAAkB,4CAA4C,CAAC;AAErE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,GAAG,EACH,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,MAAM,EACN,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
|
package/lib/cjs/envelopes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.S3_EVENTBRIDGE_SQS = exports.S3_KINESIS_FIREHOSE = exports.S3_SNS_KINESIS_FIREHOSE = exports.S3_SQS = exports.S3_SNS_SQS = exports.CLOUDWATCH_LOGS = exports.KINESIS_DATA_STREAM = exports.CLOUDWATCH_EVENTS_SCHEDULED = exports.EVENTBRIDGE = exports.SNS = exports.SQS = exports.API_GATEWAY_HTTP = exports.API_GATEWAY_REST = exports.extractDataFromEnvelope = void 0;
|
|
4
|
-
const search_js_1 = require("./search.js");
|
|
5
4
|
const PowertoolsFunctions_js_1 = require("./PowertoolsFunctions.js");
|
|
5
|
+
const search_js_1 = require("./search.js");
|
|
6
6
|
/**
|
|
7
7
|
* Searches and extracts data using JMESPath
|
|
8
8
|
*
|
|
@@ -56,10 +56,7 @@ const PowertoolsFunctions_js_1 = require("./PowertoolsFunctions.js");
|
|
|
56
56
|
* @param options The parsing options to use
|
|
57
57
|
*/
|
|
58
58
|
const extractDataFromEnvelope = (data, envelope, options) => {
|
|
59
|
-
|
|
60
|
-
options = { customFunctions: new PowertoolsFunctions_js_1.PowertoolsFunctions() };
|
|
61
|
-
}
|
|
62
|
-
return (0, search_js_1.search)(envelope, data, options);
|
|
59
|
+
return (0, search_js_1.search)(envelope, data, options || { customFunctions: new PowertoolsFunctions_js_1.PowertoolsFunctions() });
|
|
63
60
|
};
|
|
64
61
|
exports.extractDataFromEnvelope = extractDataFromEnvelope;
|
|
65
62
|
const API_GATEWAY_REST = 'powertools_json(body)';
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JSONArray, JSONValue } from '@aws-lambda-powertools/commons/types';
|
|
2
2
|
import type { Functions } from './Functions.js';
|
|
3
|
-
import { BINDING_POWER } from './constants.js';
|
|
3
|
+
import type { BINDING_POWER } from './constants.js';
|
|
4
4
|
/**
|
|
5
5
|
* A token in the JMESPath AST.
|
|
6
6
|
*/
|
package/lib/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,OAAO,aAAa,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,KAAK,0BAA0B,GAAG,CAChC,MAAM,EAAE,SAAS,GAAG,OAAO,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,kBAAkB,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,KAAK,wBAAwB,GAAG;IAC9B,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjD,YAAY,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,IAAI,EACJ,sBAAsB,EACtB,KAAK,EACL,UAAU,GACX,CAAC"}
|
package/lib/cjs/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,QAAA,MAAM,QAAQ,UAAW,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,QAAA,MAAM,QAAQ,UAAW,OAAO,KAAG,OAKlC,CAAC;AA6BF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,UAAU,GAAI,CAAC,gCAKlB;IACD,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,KAAG,CAAC,EAAE,GAAG,IA0BT,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,SACR,OAAO,EAAE,kBACC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,aACzB,OAAO,KACjB,IAcF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,SAAS,SACP,OAAO,EAAE,kBACC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KACnC,IAKF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,iBAAiB,QAAS,OAAO,gBAAgB,KAAK,CAAC,MAAM,CAAC,KAAG,IAMtE,CAAC;AA+IF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC"}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -18,9 +18,7 @@ const isTruthy = (value) => {
|
|
|
18
18
|
if ((0, typeutils_1.isNumber)(value)) {
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
return (0, typeutils_1.isTruthy)(value);
|
|
23
|
-
}
|
|
21
|
+
return (0, typeutils_1.isTruthy)(value);
|
|
24
22
|
};
|
|
25
23
|
exports.isTruthy = isTruthy;
|
|
26
24
|
/**
|
|
@@ -33,16 +31,17 @@ exports.isTruthy = isTruthy;
|
|
|
33
31
|
* @param isStepNegative Whether the step is negative
|
|
34
32
|
*/
|
|
35
33
|
const capSliceRange = (arrayLength, value, isStepNegative) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
let capValue = value;
|
|
35
|
+
if (capValue < 0) {
|
|
36
|
+
capValue += arrayLength;
|
|
37
|
+
if (capValue < 0) {
|
|
38
|
+
capValue = isStepNegative ? -1 : 0;
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
else if (
|
|
43
|
-
|
|
41
|
+
else if (capValue >= arrayLength) {
|
|
42
|
+
capValue = isStepNegative ? arrayLength - 1 : arrayLength;
|
|
44
43
|
}
|
|
45
|
-
return
|
|
44
|
+
return capValue;
|
|
46
45
|
};
|
|
47
46
|
/**
|
|
48
47
|
* Given a start, stop, and step value, the sub elements in an array are extracted as follows:
|
|
@@ -196,8 +195,9 @@ const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
|
|
|
196
195
|
checkExpressionType(arg, argumentSpec, hasMoreTypesToCheck);
|
|
197
196
|
return true;
|
|
198
197
|
}
|
|
199
|
-
|
|
198
|
+
if (['string', 'number', 'boolean'].includes(type)) {
|
|
200
199
|
typeCheckType(arg, type, argumentSpec, hasMoreTypesToCheck);
|
|
200
|
+
// biome-ignore lint/suspicious/useValidTypeof: we know that `type` is one of 'string', 'number', or 'boolean' because we checked for that above
|
|
201
201
|
if (typeof arg === type)
|
|
202
202
|
return true;
|
|
203
203
|
}
|
|
@@ -216,6 +216,7 @@ const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
|
|
|
216
216
|
* @param hasMoreTypesToCheck Whether there are more types to check
|
|
217
217
|
*/
|
|
218
218
|
const typeCheckType = (arg, type, argumentSpec, hasMoreTypesToCheck) => {
|
|
219
|
+
// biome-ignore lint/suspicious/useValidTypeof: we know that `type` is one of 'string', 'number', or 'boolean' because we checked before calling this function
|
|
219
220
|
if (typeof arg !== type && !hasMoreTypesToCheck) {
|
|
220
221
|
throw new errors_js_1.JMESPathTypeError({
|
|
221
222
|
currentValue: arg,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../src/Functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,sCAAsC,CAAC;AAM9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAM,SAAS;IACb;;OAEG;IACI,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAExC;;;;OAIG;IAEI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIpC;;;;OAIG;IAII,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAI3C;;;;OAIG;IAE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B,GAChC,0BAA0B;CAiB9B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/lib/esm/Functions.js
CHANGED
|
@@ -118,9 +118,7 @@ class Functions {
|
|
|
118
118
|
if (isRecord(arg)) {
|
|
119
119
|
return Object.keys(arg).length;
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
return arg.length;
|
|
123
|
-
}
|
|
121
|
+
return arg.length;
|
|
124
122
|
}
|
|
125
123
|
/**
|
|
126
124
|
* Map the provided function over the provided array.
|
|
@@ -143,13 +141,11 @@ class Functions {
|
|
|
143
141
|
return null;
|
|
144
142
|
// The signature decorator already enforces that all elements are of the same type
|
|
145
143
|
}
|
|
146
|
-
|
|
144
|
+
if (isNumber(arg[0])) {
|
|
147
145
|
return Math.max(...arg);
|
|
148
146
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return arg.reduce((a, b) => (a > b ? a : b));
|
|
152
|
-
}
|
|
147
|
+
// local compare function to handle string comparison
|
|
148
|
+
return arg.reduce((a, b) => (a > b ? a : b));
|
|
153
149
|
}
|
|
154
150
|
/**
|
|
155
151
|
* Get the item in the provided array that has the maximum value when the provided expression is evaluated.
|
|
@@ -177,14 +173,12 @@ class Functions {
|
|
|
177
173
|
if (max.visited === current.visited) {
|
|
178
174
|
return max;
|
|
179
175
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
: current;
|
|
187
|
-
}
|
|
176
|
+
// We can safely cast visited to number | string here because we've already
|
|
177
|
+
// checked the type at runtime above and we know that it's either a number or a string
|
|
178
|
+
return max.visited >
|
|
179
|
+
current.visited
|
|
180
|
+
? max
|
|
181
|
+
: current;
|
|
188
182
|
}, visitedArgs[0]);
|
|
189
183
|
return max.arg;
|
|
190
184
|
}
|
|
@@ -196,6 +190,7 @@ class Functions {
|
|
|
196
190
|
* @param args The objects to merge
|
|
197
191
|
*/
|
|
198
192
|
funcMerge(...args) {
|
|
193
|
+
// biome-ignore lint/performance/noAccumulatingSpread: This is a shallow merge so the tradeoff is acceptable
|
|
199
194
|
return args.reduce((a, b) => ({ ...a, ...b }), {});
|
|
200
195
|
}
|
|
201
196
|
/**
|
|
@@ -208,12 +203,10 @@ class Functions {
|
|
|
208
203
|
return null;
|
|
209
204
|
// The signature decorator already enforces that all elements are of the same type
|
|
210
205
|
}
|
|
211
|
-
|
|
206
|
+
if (isNumber(arg[0])) {
|
|
212
207
|
return Math.min(...arg);
|
|
213
208
|
}
|
|
214
|
-
|
|
215
|
-
return arg.reduce((a, b) => (a < b ? a : b));
|
|
216
|
-
}
|
|
209
|
+
return arg.reduce((a, b) => (a < b ? a : b));
|
|
217
210
|
}
|
|
218
211
|
/**
|
|
219
212
|
* Get the item in the provided array that has the minimum value when the provided expression is evaluated.
|
|
@@ -241,14 +234,12 @@ class Functions {
|
|
|
241
234
|
if (min.visited === current.visited) {
|
|
242
235
|
return min;
|
|
243
236
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
: current;
|
|
251
|
-
}
|
|
237
|
+
// We can safely cast visited to number | string here because we've already
|
|
238
|
+
// checked the type at runtime above and we know that it's either a number or a string
|
|
239
|
+
return min.visited <
|
|
240
|
+
current.visited
|
|
241
|
+
? min
|
|
242
|
+
: current;
|
|
252
243
|
}, visitedArgs[0]);
|
|
253
244
|
return min.arg;
|
|
254
245
|
}
|
|
@@ -317,13 +308,11 @@ class Functions {
|
|
|
317
308
|
if (a.visited === b.visited) {
|
|
318
309
|
return a.index - b.index; // Make the sort stable
|
|
319
310
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
: -1;
|
|
326
|
-
}
|
|
311
|
+
// We can safely cast visited to number | string here because we've already
|
|
312
|
+
// checked the type at runtime above and we know that it's either a number or a string
|
|
313
|
+
return a.visited > b.visited
|
|
314
|
+
? 1
|
|
315
|
+
: -1;
|
|
327
316
|
})
|
|
328
317
|
.map(({ value }) => value); // Extract the original values
|
|
329
318
|
}
|
|
@@ -369,13 +358,11 @@ class Functions {
|
|
|
369
358
|
if (typeof arg === 'number') {
|
|
370
359
|
return arg;
|
|
371
360
|
}
|
|
372
|
-
|
|
361
|
+
if (typeof arg === 'string') {
|
|
373
362
|
const num = Number(arg);
|
|
374
363
|
return Number.isNaN(num) ? null : num;
|
|
375
364
|
}
|
|
376
|
-
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
365
|
+
return null;
|
|
379
366
|
}
|
|
380
367
|
/**
|
|
381
368
|
* Convert the provided value to a string.
|
package/lib/esm/Lexer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lexer.d.ts","sourceRoot":"","sources":["../../src/Lexer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;;IAOT;;;;;;OAMG;IACK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"Lexer.d.ts","sourceRoot":"","sources":["../../src/Lexer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;;IAOT;;;;;;OAMG;IACK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;CA4UvD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/lib/esm/Lexer.js
CHANGED
|
@@ -23,9 +23,7 @@ class Lexer {
|
|
|
23
23
|
while (this.#current !== '' && this.#current !== undefined) {
|
|
24
24
|
if (SIMPLE_TOKENS.has(this.#current)) {
|
|
25
25
|
yield {
|
|
26
|
-
// We know that SIMPLE_TOKENS has this.#current as a key because
|
|
27
|
-
// we checked for that above.
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
+
// biome-ignore lint/style/noNonNullAssertion: We know that SIMPLE_TOKENS has this.#current as a key because we checked for that above.
|
|
29
27
|
type: SIMPLE_TOKENS.get(this.#current),
|
|
30
28
|
value: this.#current,
|
|
31
29
|
start: this.#position,
|
|
@@ -53,7 +51,7 @@ class Lexer {
|
|
|
53
51
|
const buff = this.#consumeNumber();
|
|
54
52
|
yield {
|
|
55
53
|
type: 'number',
|
|
56
|
-
value: parseInt(buff),
|
|
54
|
+
value: Number.parseInt(buff),
|
|
57
55
|
start: start,
|
|
58
56
|
end: start + buff.length,
|
|
59
57
|
};
|
|
@@ -113,9 +111,7 @@ class Lexer {
|
|
|
113
111
|
end: this.#position,
|
|
114
112
|
};
|
|
115
113
|
}
|
|
116
|
-
|
|
117
|
-
throw new LexerError(this.#position - 1, '=');
|
|
118
|
-
}
|
|
114
|
+
throw new LexerError(this.#position - 1, '=');
|
|
119
115
|
}
|
|
120
116
|
/**
|
|
121
117
|
* Consume an unquoted identifier.
|
|
@@ -149,15 +145,13 @@ class Lexer {
|
|
|
149
145
|
if (buff.length > 1) {
|
|
150
146
|
return {
|
|
151
147
|
type: 'number',
|
|
152
|
-
value: parseInt(buff),
|
|
148
|
+
value: Number.parseInt(buff),
|
|
153
149
|
start: start,
|
|
154
150
|
end: start + buff.length,
|
|
155
151
|
};
|
|
156
152
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
throw new LexerError(start, 'Unknown token after "-"');
|
|
160
|
-
}
|
|
153
|
+
// If the negative sign is not followed by a number, it is an error.
|
|
154
|
+
throw new LexerError(start, 'Unknown token after "-"');
|
|
161
155
|
}
|
|
162
156
|
/**
|
|
163
157
|
* Consume a raw string that is a number.
|
|
@@ -183,17 +177,15 @@ class Lexer {
|
|
|
183
177
|
#consumeSquareBracket() {
|
|
184
178
|
const start = this.#position;
|
|
185
179
|
const nextChar = this.#next();
|
|
186
|
-
if (nextChar
|
|
180
|
+
if (nextChar === ']') {
|
|
187
181
|
this.#next();
|
|
188
182
|
return { type: 'flatten', value: '[]', start: start, end: start + 2 };
|
|
189
183
|
}
|
|
190
|
-
|
|
184
|
+
if (nextChar === '?') {
|
|
191
185
|
this.#next();
|
|
192
186
|
return { type: 'filter', value: '[?', start: start, end: start + 2 };
|
|
193
187
|
}
|
|
194
|
-
|
|
195
|
-
return { type: 'lbracket', value: '[', start: start, end: start + 1 };
|
|
196
|
-
}
|
|
188
|
+
return { type: 'lbracket', value: '[', start: start, end: start + 1 };
|
|
197
189
|
}
|
|
198
190
|
/**
|
|
199
191
|
* Initializes the lexer for the given expression.
|
|
@@ -283,7 +275,7 @@ class Lexer {
|
|
|
283
275
|
*/
|
|
284
276
|
#consumeQuotedIdentifier() {
|
|
285
277
|
const start = this.#position;
|
|
286
|
-
const lexeme =
|
|
278
|
+
const lexeme = `"${this.#consumeUntil('"')}"`;
|
|
287
279
|
const tokenLen = this.#position - start;
|
|
288
280
|
return {
|
|
289
281
|
type: 'quoted_identifier',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE3E,cAAM,YAAY;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,IAAI,CAAC;gBAED,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;IAKnD;;;;;OAKG;IACI,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO;CAiB5E;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/lib/esm/Parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6BjD;;;;;;;;;;;;;GAaG;AACH,cAAM,MAAM;;gBAkBS,SAAS,SAAI;IAIhC;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAc9C;;OAEG;IACI,UAAU,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6BjD;;;;;;;;;;;;;GAaG;AACH,cAAM,MAAM;;gBAkBS,SAAS,SAAI;IAIhC;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAc9C;;OAEG;IACI,UAAU,IAAI,IAAI;CAutB1B;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|