@n8n/expression-runtime 0.14.0 → 0.14.1
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/dist/cjs/build.tsbuildinfo +1 -1
- package/dist/cjs/runtime/jmespath.d.ts +22 -0
- package/dist/cjs/runtime/jmespath.d.ts.map +1 -0
- package/dist/cjs/runtime/jmespath.js +112 -0
- package/dist/cjs/runtime/jmespath.js.map +1 -0
- package/dist/esm/build.tsbuildinfo +1 -1
- package/dist/esm/runtime/jmespath.d.ts +22 -0
- package/dist/esm/runtime/jmespath.d.ts.map +1 -0
- package/dist/esm/runtime/jmespath.js +66 -0
- package/dist/esm/runtime/jmespath.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-isolate `$jmespath` / `$jmesPath` implementation.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the host-side wrapper in `packages/workflow/src/workflow-data-proxy.ts`
|
|
5
|
+
* so that expressions resolve `$jmespath` from the in-isolate runtime via
|
|
6
|
+
* Tournament's polyfill, instead of falling through to the bridge's
|
|
7
|
+
* `callFunctionAtPath` channel. This shrinks the host-callable surface
|
|
8
|
+
* exposed by the data object.
|
|
9
|
+
*
|
|
10
|
+
* Behavioural parity with the host wrapper:
|
|
11
|
+
* - Throws `ExpressionError` (same name) when args are wrong.
|
|
12
|
+
* - Rejects queries that contain unsafe property tokens.
|
|
13
|
+
* - Spreads non-array, non-null objects to drop proxies at the top level.
|
|
14
|
+
*
|
|
15
|
+
* Note on lazy proxies: when `data` is a lazy proxy (e.g. `$json`), each
|
|
16
|
+
* property access during `jmespath.search` triggers a synchronous host
|
|
17
|
+
* roundtrip via `getValueAtPath`. Functional but slow for deep traversals.
|
|
18
|
+
* Performance optimisation (e.g. bulk pre-fetch of the queried subtree) is
|
|
19
|
+
* a follow-up.
|
|
20
|
+
*/
|
|
21
|
+
export declare function jmesPath(data: unknown, query: string): unknown;
|
|
22
|
+
//# sourceMappingURL=jmespath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jmespath.d.ts","sourceRoot":"","sources":["../../../src/runtime/jmespath.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAoB9D"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
+
var ownKeys = function(o) {
|
|
19
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
+
var ar = [];
|
|
21
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
+
return ar;
|
|
23
|
+
};
|
|
24
|
+
return ownKeys(o);
|
|
25
|
+
};
|
|
26
|
+
return function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(function (factory) {
|
|
35
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
36
|
+
var v = factory(require, exports);
|
|
37
|
+
if (v !== undefined) module.exports = v;
|
|
38
|
+
}
|
|
39
|
+
else if (typeof define === "function" && define.amd) {
|
|
40
|
+
define(["require", "exports", "jmespath", "./safe-globals"], factory);
|
|
41
|
+
}
|
|
42
|
+
})(function (require, exports) {
|
|
43
|
+
"use strict";
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.jmesPath = jmesPath;
|
|
46
|
+
const jmespath = __importStar(require("jmespath"));
|
|
47
|
+
const safe_globals_1 = require("./safe-globals");
|
|
48
|
+
const unsafeJmespathProperties = [
|
|
49
|
+
'__proto__',
|
|
50
|
+
'prototype',
|
|
51
|
+
'constructor',
|
|
52
|
+
'getPrototypeOf',
|
|
53
|
+
'setPrototypeOf',
|
|
54
|
+
'getOwnPropertyDescriptor',
|
|
55
|
+
'getOwnPropertyDescriptors',
|
|
56
|
+
'defineProperty',
|
|
57
|
+
'defineProperties',
|
|
58
|
+
'mainModule',
|
|
59
|
+
'binding',
|
|
60
|
+
'_linkedBinding',
|
|
61
|
+
'_load',
|
|
62
|
+
'prepareStackTrace',
|
|
63
|
+
'__lookupGetter__',
|
|
64
|
+
'__lookupSetter__',
|
|
65
|
+
'__defineGetter__',
|
|
66
|
+
'__defineSetter__',
|
|
67
|
+
'caller',
|
|
68
|
+
'arguments',
|
|
69
|
+
'getBuiltinModule',
|
|
70
|
+
'dlopen',
|
|
71
|
+
'execve',
|
|
72
|
+
'loadEnvFile',
|
|
73
|
+
];
|
|
74
|
+
const unsafeJmespathPropertyPattern = new RegExp(`\\b(?:${unsafeJmespathProperties.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})\\b`);
|
|
75
|
+
/**
|
|
76
|
+
* In-isolate `$jmespath` / `$jmesPath` implementation.
|
|
77
|
+
*
|
|
78
|
+
* Mirrors the host-side wrapper in `packages/workflow/src/workflow-data-proxy.ts`
|
|
79
|
+
* so that expressions resolve `$jmespath` from the in-isolate runtime via
|
|
80
|
+
* Tournament's polyfill, instead of falling through to the bridge's
|
|
81
|
+
* `callFunctionAtPath` channel. This shrinks the host-callable surface
|
|
82
|
+
* exposed by the data object.
|
|
83
|
+
*
|
|
84
|
+
* Behavioural parity with the host wrapper:
|
|
85
|
+
* - Throws `ExpressionError` (same name) when args are wrong.
|
|
86
|
+
* - Rejects queries that contain unsafe property tokens.
|
|
87
|
+
* - Spreads non-array, non-null objects to drop proxies at the top level.
|
|
88
|
+
*
|
|
89
|
+
* Note on lazy proxies: when `data` is a lazy proxy (e.g. `$json`), each
|
|
90
|
+
* property access during `jmespath.search` triggers a synchronous host
|
|
91
|
+
* roundtrip via `getValueAtPath`. Functional but slow for deep traversals.
|
|
92
|
+
* Performance optimisation (e.g. bulk pre-fetch of the queried subtree) is
|
|
93
|
+
* a follow-up.
|
|
94
|
+
*/
|
|
95
|
+
function jmesPath(data, query) {
|
|
96
|
+
if (typeof data !== 'object' || typeof query !== 'string') {
|
|
97
|
+
throw new safe_globals_1.ExpressionError('expected two arguments (Object, string) for this function');
|
|
98
|
+
}
|
|
99
|
+
// jmespath decodes escape sequences inside quoted identifiers, so the
|
|
100
|
+
// token check must run against an unescaped query. Reject any backslash
|
|
101
|
+
// up front to keep the property-name match meaningful.
|
|
102
|
+
if (query.includes('\\') || unsafeJmespathPropertyPattern.test(query)) {
|
|
103
|
+
throw new safe_globals_1.ExpressionError('Cannot access this property in a jmespath query due to security concerns');
|
|
104
|
+
}
|
|
105
|
+
if (data !== null && !Array.isArray(data) && typeof data === 'object') {
|
|
106
|
+
return jmespath.search({ ...data }, query);
|
|
107
|
+
}
|
|
108
|
+
// Array or null — pass through to jmespath which accepts both
|
|
109
|
+
return jmespath.search(data, query);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=jmespath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jmespath.js","sourceRoot":"","sources":["../../../src/runtime/jmespath.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuDA,4BAoBC;IA3ED,mDAAqC;IAErC,iDAAiD;IAEjD,MAAM,wBAAwB,GAAG;QAChC,WAAW;QACX,WAAW;QACX,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QAChB,0BAA0B;QAC1B,2BAA2B;QAC3B,gBAAgB;QAChB,kBAAkB;QAClB,YAAY;QACZ,SAAS;QACT,gBAAgB;QAChB,OAAO;QACP,mBAAmB;QACnB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,QAAQ;QACR,WAAW;QACX,kBAAkB;QAClB,QAAQ;QACR,QAAQ;QACR,aAAa;KACb,CAAC;IAEF,MAAM,6BAA6B,GAAG,IAAI,MAAM,CAC/C,SAAS,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CACtG,CAAC;IAEF;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAgB,QAAQ,CAAC,IAAa,EAAE,KAAa;QACpD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC3D,MAAM,IAAI,8BAAe,CAAC,2DAA2D,CAAC,CAAC;QACxF,CAAC;QAED,sEAAsE;QACtE,wEAAwE;QACxE,uDAAuD;QACvD,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,8BAAe,CACxB,0EAA0E,CAC1E,CAAC;QACH,CAAC;QAED,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvE,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAI,IAAgC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;QAED,8DAA8D;QAC9D,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAa,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC"}
|