@openfn/language-common 2.0.0-rc2 → 2.0.0-rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +127 -111
  2. package/dist/index.js +128 -119
  3. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -1087,25 +1087,40 @@ __export(src_exports, {
1087
1087
  });
1088
1088
  module.exports = __toCommonJS(src_exports);
1089
1089
 
1090
- // node_modules/jsonpath-plus/dist/index-es.js
1090
+ // node_modules/jsonpath-plus/dist/index-browser-esm.js
1091
1091
  function _typeof(obj) {
1092
1092
  "@babel/helpers - typeof";
1093
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1094
- _typeof = function(obj2) {
1095
- return typeof obj2;
1096
- };
1097
- } else {
1098
- _typeof = function(obj2) {
1099
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
1100
- };
1101
- }
1102
- return _typeof(obj);
1093
+ return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
1094
+ return typeof obj2;
1095
+ } : function(obj2) {
1096
+ return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
1097
+ }, _typeof(obj);
1103
1098
  }
1104
1099
  function _classCallCheck(instance, Constructor) {
1105
1100
  if (!(instance instanceof Constructor)) {
1106
1101
  throw new TypeError("Cannot call a class as a function");
1107
1102
  }
1108
1103
  }
1104
+ function _defineProperties(target, props) {
1105
+ for (var i = 0; i < props.length; i++) {
1106
+ var descriptor = props[i];
1107
+ descriptor.enumerable = descriptor.enumerable || false;
1108
+ descriptor.configurable = true;
1109
+ if ("value" in descriptor)
1110
+ descriptor.writable = true;
1111
+ Object.defineProperty(target, descriptor.key, descriptor);
1112
+ }
1113
+ }
1114
+ function _createClass(Constructor, protoProps, staticProps) {
1115
+ if (protoProps)
1116
+ _defineProperties(Constructor.prototype, protoProps);
1117
+ if (staticProps)
1118
+ _defineProperties(Constructor, staticProps);
1119
+ Object.defineProperty(Constructor, "prototype", {
1120
+ writable: false
1121
+ });
1122
+ return Constructor;
1123
+ }
1109
1124
  function _inherits(subClass, superClass) {
1110
1125
  if (typeof superClass !== "function" && superClass !== null) {
1111
1126
  throw new TypeError("Super expression must either be null or a function");
@@ -1117,17 +1132,20 @@ function _inherits(subClass, superClass) {
1117
1132
  configurable: true
1118
1133
  }
1119
1134
  });
1135
+ Object.defineProperty(subClass, "prototype", {
1136
+ writable: false
1137
+ });
1120
1138
  if (superClass)
1121
1139
  _setPrototypeOf(subClass, superClass);
1122
1140
  }
1123
1141
  function _getPrototypeOf(o) {
1124
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
1142
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
1125
1143
  return o2.__proto__ || Object.getPrototypeOf(o2);
1126
1144
  };
1127
1145
  return _getPrototypeOf(o);
1128
1146
  }
1129
1147
  function _setPrototypeOf(o, p) {
1130
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
1148
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
1131
1149
  o2.__proto__ = p2;
1132
1150
  return o2;
1133
1151
  };
@@ -1141,7 +1159,7 @@ function _isNativeReflectConstruct() {
1141
1159
  if (typeof Proxy === "function")
1142
1160
  return true;
1143
1161
  try {
1144
- Date.prototype.toString.call(Reflect.construct(Date, [], function() {
1162
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1145
1163
  }));
1146
1164
  return true;
1147
1165
  } catch (e) {
@@ -1150,7 +1168,7 @@ function _isNativeReflectConstruct() {
1150
1168
  }
1151
1169
  function _construct(Parent, args, Class) {
1152
1170
  if (_isNativeReflectConstruct()) {
1153
- _construct = Reflect.construct;
1171
+ _construct = Reflect.construct.bind();
1154
1172
  } else {
1155
1173
  _construct = function _construct2(Parent2, args2, Class2) {
1156
1174
  var a = [null];
@@ -1204,13 +1222,16 @@ function _assertThisInitialized(self) {
1204
1222
  function _possibleConstructorReturn(self, call) {
1205
1223
  if (call && (typeof call === "object" || typeof call === "function")) {
1206
1224
  return call;
1225
+ } else if (call !== void 0) {
1226
+ throw new TypeError("Derived constructors may only return object or undefined");
1207
1227
  }
1208
1228
  return _assertThisInitialized(self);
1209
1229
  }
1210
1230
  function _createSuper(Derived) {
1211
- return function() {
1231
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
1232
+ return function _createSuperInternal() {
1212
1233
  var Super = _getPrototypeOf(Derived), result;
1213
- if (_isNativeReflectConstruct()) {
1234
+ if (hasNativeReflectConstruct) {
1214
1235
  var NewTarget = _getPrototypeOf(this).constructor;
1215
1236
  result = Reflect.construct(Super, arguments, NewTarget);
1216
1237
  } else {
@@ -1227,7 +1248,7 @@ function _arrayWithoutHoles(arr) {
1227
1248
  return _arrayLikeToArray(arr);
1228
1249
  }
1229
1250
  function _iterableToArray(iter) {
1230
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter))
1251
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
1231
1252
  return Array.from(iter);
1232
1253
  }
1233
1254
  function _unsupportedIterableToArray(o, minLen) {
@@ -1239,7 +1260,7 @@ function _unsupportedIterableToArray(o, minLen) {
1239
1260
  if (n === "Object" && o.constructor)
1240
1261
  n = o.constructor.name;
1241
1262
  if (n === "Map" || n === "Set")
1242
- return Array.from(n);
1263
+ return Array.from(o);
1243
1264
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
1244
1265
  return _arrayLikeToArray(o, minLen);
1245
1266
  }
@@ -1253,9 +1274,12 @@ function _arrayLikeToArray(arr, len) {
1253
1274
  function _nonIterableSpread() {
1254
1275
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1255
1276
  }
1256
- function _createForOfIteratorHelper(o) {
1257
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
1258
- if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
1277
+ function _createForOfIteratorHelper(o, allowArrayLike) {
1278
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1279
+ if (!it) {
1280
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1281
+ if (it)
1282
+ o = it;
1259
1283
  var i = 0;
1260
1284
  var F = function() {
1261
1285
  };
@@ -1279,10 +1303,10 @@ function _createForOfIteratorHelper(o) {
1279
1303
  }
1280
1304
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1281
1305
  }
1282
- var it, normalCompletion = true, didErr = false, err;
1306
+ var normalCompletion = true, didErr = false, err;
1283
1307
  return {
1284
1308
  s: function() {
1285
- it = o[Symbol.iterator]();
1309
+ it = it.call(o);
1286
1310
  },
1287
1311
  n: function() {
1288
1312
  var step = it.next();
@@ -1304,51 +1328,7 @@ function _createForOfIteratorHelper(o) {
1304
1328
  }
1305
1329
  };
1306
1330
  }
1307
- var supportsNodeVM = function supportsNodeVM2() {
1308
- try {
1309
- return Object.prototype.toString.call(global.process) === "[object process]";
1310
- } catch (e) {
1311
- return false;
1312
- }
1313
- };
1314
1331
  var hasOwnProp = Object.prototype.hasOwnProperty;
1315
- var moveToAnotherArray = function moveToAnotherArray2(source2, target, conditionCb) {
1316
- var il = source2.length;
1317
- for (var i = 0; i < il; i++) {
1318
- var item = source2[i];
1319
- if (conditionCb(item)) {
1320
- target.push(source2.splice(i--, 1)[0]);
1321
- }
1322
- }
1323
- };
1324
- JSONPath.nodeVMSupported = supportsNodeVM();
1325
- var vm = JSONPath.nodeVMSupported ? require("vm") : {
1326
- runInNewContext: function runInNewContext(expr, context) {
1327
- var keys = Object.keys(context);
1328
- var funcs = [];
1329
- moveToAnotherArray(keys, funcs, function(key) {
1330
- return typeof context[key] === "function";
1331
- });
1332
- var values = keys.map(function(vr, i) {
1333
- return context[vr];
1334
- });
1335
- var funcString = funcs.reduce(function(s, func) {
1336
- var fString = context[func].toString();
1337
- if (!/function/.test(fString)) {
1338
- fString = "function " + fString;
1339
- }
1340
- return "var " + func + "=" + fString + ";" + s;
1341
- }, "");
1342
- expr = funcString + expr;
1343
- if (!expr.match(/(["'])use strict\1/) && !keys.includes("arguments")) {
1344
- expr = "var arguments = undefined;" + expr;
1345
- }
1346
- expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
1347
- var lastStatementEnd = expr.lastIndexOf(";");
1348
- var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
1349
- return _construct(Function, _toConsumableArray(keys).concat([code])).apply(void 0, _toConsumableArray(values));
1350
- }
1351
- };
1352
1332
  function push(arr, item) {
1353
1333
  arr = arr.slice();
1354
1334
  arr.push(item);
@@ -1371,7 +1351,7 @@ var NewError = /* @__PURE__ */ function(_Error) {
1371
1351
  _this.name = "NewError";
1372
1352
  return _this;
1373
1353
  }
1374
- return NewError2;
1354
+ return _createClass(NewError2);
1375
1355
  }(/* @__PURE__ */ _wrapNativeSuper(Error));
1376
1356
  function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
1377
1357
  if (!(this instanceof JSONPath)) {
@@ -1423,7 +1403,7 @@ function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
1423
1403
  }
1424
1404
  }
1425
1405
  JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
1426
- var that = this;
1406
+ var _this2 = this;
1427
1407
  var currParent = this.parent, currParentProperty = this.parentProperty;
1428
1408
  var flatten = this.flatten, wrap = this.wrap;
1429
1409
  this.currResultType = this.resultType;
@@ -1461,7 +1441,6 @@ JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback)
1461
1441
  if (!expr && expr !== "" || !json) {
1462
1442
  return void 0;
1463
1443
  }
1464
- this._obj = json;
1465
1444
  var exprList = JSONPath.toPathArray(expr);
1466
1445
  if (exprList[0] === "$" && exprList.length > 1) {
1467
1446
  exprList.shift();
@@ -1477,7 +1456,7 @@ JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback)
1477
1456
  return this._getPreferredOutput(result[0]);
1478
1457
  }
1479
1458
  return result.reduce(function(rslt, ea) {
1480
- var valOrPath = that._getPreferredOutput(ea);
1459
+ var valOrPath = _this2._getPreferredOutput(ea);
1481
1460
  if (flatten && Array.isArray(valOrPath)) {
1482
1461
  rslt = rslt.concat(valOrPath);
1483
1462
  } else {
@@ -1489,8 +1468,6 @@ JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback)
1489
1468
  JSONPath.prototype._getPreferredOutput = function(ea) {
1490
1469
  var resultType = this.currResultType;
1491
1470
  switch (resultType) {
1492
- default:
1493
- throw new TypeError("Unknown result type");
1494
1471
  case "all": {
1495
1472
  var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
1496
1473
  ea.pointer = JSONPath.toPointer(path);
@@ -1505,6 +1482,8 @@ JSONPath.prototype._getPreferredOutput = function(ea) {
1505
1482
  return JSONPath.toPathString(ea[resultType]);
1506
1483
  case "pointer":
1507
1484
  return JSONPath.toPointer(ea.path);
1485
+ default:
1486
+ throw new TypeError("Unknown result type");
1508
1487
  }
1509
1488
  };
1510
1489
  JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
@@ -1515,8 +1494,8 @@ JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
1515
1494
  }
1516
1495
  };
1517
1496
  JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
1497
+ var _this3 = this;
1518
1498
  var retObj;
1519
- var that = this;
1520
1499
  if (!expr.length) {
1521
1500
  retObj = {
1522
1501
  path,
@@ -1543,13 +1522,13 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1543
1522
  addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
1544
1523
  } else if (loc === "*") {
1545
1524
  this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
1546
- addRet(that._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
1525
+ addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
1547
1526
  });
1548
1527
  } else if (loc === "..") {
1549
1528
  addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
1550
1529
  this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
1551
1530
  if (_typeof(v[m]) === "object") {
1552
- addRet(that._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
1531
+ addRet(_this3._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
1553
1532
  }
1554
1533
  });
1555
1534
  } else if (loc === "^") {
@@ -1577,8 +1556,8 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1577
1556
  throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
1578
1557
  }
1579
1558
  this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
1580
- if (that._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
1581
- addRet(that._trace(unshift(m, _x), v, p, par, pr, cb, true));
1559
+ if (_this3._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
1560
+ addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true));
1582
1561
  }
1583
1562
  });
1584
1563
  } else if (loc[0] === "(") {
@@ -1590,8 +1569,6 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1590
1569
  var addType = false;
1591
1570
  var valueType = loc.slice(1, -2);
1592
1571
  switch (valueType) {
1593
- default:
1594
- throw new TypeError("Unknown value type " + valueType);
1595
1572
  case "scalar":
1596
1573
  if (!val || !["object", "function"].includes(_typeof(val))) {
1597
1574
  addType = true;
@@ -1638,6 +1615,8 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1638
1615
  addType = true;
1639
1616
  }
1640
1617
  break;
1618
+ default:
1619
+ throw new TypeError("Unknown value type " + valueType);
1641
1620
  }
1642
1621
  if (addType) {
1643
1622
  retObj = {
@@ -1672,7 +1651,7 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1672
1651
  for (var t = 0; t < ret.length; t++) {
1673
1652
  var rett = ret[t];
1674
1653
  if (rett && rett.isParentSelector) {
1675
- var tmp = that._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
1654
+ var tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
1676
1655
  if (Array.isArray(tmp)) {
1677
1656
  ret[t] = tmp[0];
1678
1657
  var tl = tmp.length;
@@ -1718,37 +1697,26 @@ JSONPath.prototype._slice = function(loc, expr, val, path, parent, parentPropNam
1718
1697
  return ret;
1719
1698
  };
1720
1699
  JSONPath.prototype._eval = function(code, _v, _vname, path, parent, parentPropName) {
1721
- if (!this._obj || !_v) {
1722
- return false;
1723
- }
1724
- if (code.includes("@parentProperty")) {
1725
- this.currSandbox._$_parentProperty = parentPropName;
1726
- code = code.replace(/@parentProperty/g, "_$_parentProperty");
1727
- }
1728
- if (code.includes("@parent")) {
1729
- this.currSandbox._$_parent = parent;
1730
- code = code.replace(/@parent/g, "_$_parent");
1731
- }
1732
- if (code.includes("@property")) {
1733
- this.currSandbox._$_property = _vname;
1734
- code = code.replace(/@property/g, "_$_property");
1735
- }
1736
- if (code.includes("@path")) {
1700
+ this.currSandbox._$_parentProperty = parentPropName;
1701
+ this.currSandbox._$_parent = parent;
1702
+ this.currSandbox._$_property = _vname;
1703
+ this.currSandbox._$_root = this.json;
1704
+ this.currSandbox._$_v = _v;
1705
+ var containsPath = code.includes("@path");
1706
+ if (containsPath) {
1737
1707
  this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
1738
- code = code.replace(/@path/g, "_$_path");
1739
- }
1740
- if (code.includes("@root")) {
1741
- this.currSandbox._$_root = this.json;
1742
- code = code.replace(/@root/g, "_$_root");
1743
1708
  }
1744
- if (code.match(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/)) {
1745
- this.currSandbox._$_v = _v;
1746
- code = code.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
1709
+ var scriptCacheKey = "script:" + code;
1710
+ if (!JSONPath.cache[scriptCacheKey]) {
1711
+ var script = code.replace(/@parentProperty/g, "_$_parentProperty").replace(/@parent/g, "_$_parent").replace(/@property/g, "_$_property").replace(/@root/g, "_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
1712
+ if (containsPath) {
1713
+ script = script.replace(/@path/g, "_$_path");
1714
+ }
1715
+ JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
1747
1716
  }
1748
1717
  try {
1749
- return vm.runInNewContext(code, this.currSandbox);
1718
+ return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
1750
1719
  } catch (e) {
1751
- /* @__PURE__ */ console.log(e);
1752
1720
  throw new Error("jsonPath: " + e.message + ": " + code);
1753
1721
  }
1754
1722
  };
@@ -1781,9 +1749,9 @@ JSONPath.toPathArray = function(expr) {
1781
1749
  var subx = [];
1782
1750
  var normalized = expr.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g, function($0, $1) {
1783
1751
  return "[#" + (subx.push($1) - 1) + "]";
1784
- }).replace(/\['((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'\]/g, function($0, prop) {
1752
+ }).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g, function($0, prop) {
1785
1753
  return "['" + prop.replace(/\./g, "%@%").replace(/~/g, "%%@@%%") + "']";
1786
- }).replace(/~/g, ";~;").replace(/'?\.'?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\['?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
1754
+ }).replace(/~/g, ";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
1787
1755
  return ";" + ups.split("").join(";") + ";";
1788
1756
  }).replace(/;;;|;;/g, ";..;").replace(/;$|'?\]|'$/g, "");
1789
1757
  var exprList = normalized.split(";").map(function(exp) {
@@ -1791,7 +1759,55 @@ JSONPath.toPathArray = function(expr) {
1791
1759
  return !match2 || !match2[1] ? exp : subx[match2[1]];
1792
1760
  });
1793
1761
  cache[expr] = exprList;
1794
- return cache[expr];
1762
+ return cache[expr].concat();
1763
+ };
1764
+ var moveToAnotherArray = function moveToAnotherArray2(source2, target, conditionCb) {
1765
+ var il = source2.length;
1766
+ for (var i = 0; i < il; i++) {
1767
+ var item = source2[i];
1768
+ if (conditionCb(item)) {
1769
+ target.push(source2.splice(i--, 1)[0]);
1770
+ }
1771
+ }
1772
+ };
1773
+ var Script = /* @__PURE__ */ function() {
1774
+ function Script2(expr) {
1775
+ _classCallCheck(this, Script2);
1776
+ this.code = expr;
1777
+ }
1778
+ _createClass(Script2, [{
1779
+ key: "runInNewContext",
1780
+ value: function runInNewContext(context) {
1781
+ var expr = this.code;
1782
+ var keys = Object.keys(context);
1783
+ var funcs = [];
1784
+ moveToAnotherArray(keys, funcs, function(key) {
1785
+ return typeof context[key] === "function";
1786
+ });
1787
+ var values = keys.map(function(vr, i) {
1788
+ return context[vr];
1789
+ });
1790
+ var funcString = funcs.reduce(function(s, func) {
1791
+ var fString = context[func].toString();
1792
+ if (!/function/.test(fString)) {
1793
+ fString = "function " + fString;
1794
+ }
1795
+ return "var " + func + "=" + fString + ";" + s;
1796
+ }, "");
1797
+ expr = funcString + expr;
1798
+ if (!/(["'])use strict\1/.test(expr) && !keys.includes("arguments")) {
1799
+ expr = "var arguments = undefined;" + expr;
1800
+ }
1801
+ expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
1802
+ var lastStatementEnd = expr.lastIndexOf(";");
1803
+ var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
1804
+ return _construct(Function, keys.concat([code])).apply(void 0, _toConsumableArray(values));
1805
+ }
1806
+ }]);
1807
+ return Script2;
1808
+ }();
1809
+ JSONPath.prototype.vm = {
1810
+ Script
1795
1811
  };
1796
1812
 
1797
1813
  // src/http.ts
package/dist/index.js CHANGED
@@ -4,14 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined")
11
- return require.apply(this, arguments);
12
- throw new Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
- var __commonJS = (cb, mod) => function __require2() {
7
+ var __commonJS = (cb, mod) => function __require() {
15
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
9
  };
17
10
  var __export = (target, all) => {
@@ -1058,25 +1051,40 @@ var require_axios2 = __commonJS({
1058
1051
  }
1059
1052
  });
1060
1053
 
1061
- // node_modules/jsonpath-plus/dist/index-es.js
1054
+ // node_modules/jsonpath-plus/dist/index-browser-esm.js
1062
1055
  function _typeof(obj) {
1063
1056
  "@babel/helpers - typeof";
1064
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1065
- _typeof = function(obj2) {
1066
- return typeof obj2;
1067
- };
1068
- } else {
1069
- _typeof = function(obj2) {
1070
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
1071
- };
1072
- }
1073
- return _typeof(obj);
1057
+ return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
1058
+ return typeof obj2;
1059
+ } : function(obj2) {
1060
+ return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
1061
+ }, _typeof(obj);
1074
1062
  }
1075
1063
  function _classCallCheck(instance, Constructor) {
1076
1064
  if (!(instance instanceof Constructor)) {
1077
1065
  throw new TypeError("Cannot call a class as a function");
1078
1066
  }
1079
1067
  }
1068
+ function _defineProperties(target, props) {
1069
+ for (var i = 0; i < props.length; i++) {
1070
+ var descriptor = props[i];
1071
+ descriptor.enumerable = descriptor.enumerable || false;
1072
+ descriptor.configurable = true;
1073
+ if ("value" in descriptor)
1074
+ descriptor.writable = true;
1075
+ Object.defineProperty(target, descriptor.key, descriptor);
1076
+ }
1077
+ }
1078
+ function _createClass(Constructor, protoProps, staticProps) {
1079
+ if (protoProps)
1080
+ _defineProperties(Constructor.prototype, protoProps);
1081
+ if (staticProps)
1082
+ _defineProperties(Constructor, staticProps);
1083
+ Object.defineProperty(Constructor, "prototype", {
1084
+ writable: false
1085
+ });
1086
+ return Constructor;
1087
+ }
1080
1088
  function _inherits(subClass, superClass) {
1081
1089
  if (typeof superClass !== "function" && superClass !== null) {
1082
1090
  throw new TypeError("Super expression must either be null or a function");
@@ -1088,17 +1096,20 @@ function _inherits(subClass, superClass) {
1088
1096
  configurable: true
1089
1097
  }
1090
1098
  });
1099
+ Object.defineProperty(subClass, "prototype", {
1100
+ writable: false
1101
+ });
1091
1102
  if (superClass)
1092
1103
  _setPrototypeOf(subClass, superClass);
1093
1104
  }
1094
1105
  function _getPrototypeOf(o) {
1095
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
1106
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
1096
1107
  return o2.__proto__ || Object.getPrototypeOf(o2);
1097
1108
  };
1098
1109
  return _getPrototypeOf(o);
1099
1110
  }
1100
1111
  function _setPrototypeOf(o, p) {
1101
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
1112
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
1102
1113
  o2.__proto__ = p2;
1103
1114
  return o2;
1104
1115
  };
@@ -1112,7 +1123,7 @@ function _isNativeReflectConstruct() {
1112
1123
  if (typeof Proxy === "function")
1113
1124
  return true;
1114
1125
  try {
1115
- Date.prototype.toString.call(Reflect.construct(Date, [], function() {
1126
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1116
1127
  }));
1117
1128
  return true;
1118
1129
  } catch (e) {
@@ -1121,7 +1132,7 @@ function _isNativeReflectConstruct() {
1121
1132
  }
1122
1133
  function _construct(Parent, args, Class) {
1123
1134
  if (_isNativeReflectConstruct()) {
1124
- _construct = Reflect.construct;
1135
+ _construct = Reflect.construct.bind();
1125
1136
  } else {
1126
1137
  _construct = function _construct2(Parent2, args2, Class2) {
1127
1138
  var a = [null];
@@ -1175,13 +1186,16 @@ function _assertThisInitialized(self) {
1175
1186
  function _possibleConstructorReturn(self, call) {
1176
1187
  if (call && (typeof call === "object" || typeof call === "function")) {
1177
1188
  return call;
1189
+ } else if (call !== void 0) {
1190
+ throw new TypeError("Derived constructors may only return object or undefined");
1178
1191
  }
1179
1192
  return _assertThisInitialized(self);
1180
1193
  }
1181
1194
  function _createSuper(Derived) {
1182
- return function() {
1195
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
1196
+ return function _createSuperInternal() {
1183
1197
  var Super = _getPrototypeOf(Derived), result;
1184
- if (_isNativeReflectConstruct()) {
1198
+ if (hasNativeReflectConstruct) {
1185
1199
  var NewTarget = _getPrototypeOf(this).constructor;
1186
1200
  result = Reflect.construct(Super, arguments, NewTarget);
1187
1201
  } else {
@@ -1198,7 +1212,7 @@ function _arrayWithoutHoles(arr) {
1198
1212
  return _arrayLikeToArray(arr);
1199
1213
  }
1200
1214
  function _iterableToArray(iter) {
1201
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter))
1215
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
1202
1216
  return Array.from(iter);
1203
1217
  }
1204
1218
  function _unsupportedIterableToArray(o, minLen) {
@@ -1210,7 +1224,7 @@ function _unsupportedIterableToArray(o, minLen) {
1210
1224
  if (n === "Object" && o.constructor)
1211
1225
  n = o.constructor.name;
1212
1226
  if (n === "Map" || n === "Set")
1213
- return Array.from(n);
1227
+ return Array.from(o);
1214
1228
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
1215
1229
  return _arrayLikeToArray(o, minLen);
1216
1230
  }
@@ -1224,9 +1238,12 @@ function _arrayLikeToArray(arr, len) {
1224
1238
  function _nonIterableSpread() {
1225
1239
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1226
1240
  }
1227
- function _createForOfIteratorHelper(o) {
1228
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
1229
- if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
1241
+ function _createForOfIteratorHelper(o, allowArrayLike) {
1242
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1243
+ if (!it) {
1244
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1245
+ if (it)
1246
+ o = it;
1230
1247
  var i = 0;
1231
1248
  var F = function() {
1232
1249
  };
@@ -1250,10 +1267,10 @@ function _createForOfIteratorHelper(o) {
1250
1267
  }
1251
1268
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1252
1269
  }
1253
- var it, normalCompletion = true, didErr = false, err;
1270
+ var normalCompletion = true, didErr = false, err;
1254
1271
  return {
1255
1272
  s: function() {
1256
- it = o[Symbol.iterator]();
1273
+ it = it.call(o);
1257
1274
  },
1258
1275
  n: function() {
1259
1276
  var step = it.next();
@@ -1275,51 +1292,7 @@ function _createForOfIteratorHelper(o) {
1275
1292
  }
1276
1293
  };
1277
1294
  }
1278
- var supportsNodeVM = function supportsNodeVM2() {
1279
- try {
1280
- return Object.prototype.toString.call(global.process) === "[object process]";
1281
- } catch (e) {
1282
- return false;
1283
- }
1284
- };
1285
1295
  var hasOwnProp = Object.prototype.hasOwnProperty;
1286
- var moveToAnotherArray = function moveToAnotherArray2(source2, target, conditionCb) {
1287
- var il = source2.length;
1288
- for (var i = 0; i < il; i++) {
1289
- var item = source2[i];
1290
- if (conditionCb(item)) {
1291
- target.push(source2.splice(i--, 1)[0]);
1292
- }
1293
- }
1294
- };
1295
- JSONPath.nodeVMSupported = supportsNodeVM();
1296
- var vm = JSONPath.nodeVMSupported ? __require("vm") : {
1297
- runInNewContext: function runInNewContext(expr, context) {
1298
- var keys = Object.keys(context);
1299
- var funcs = [];
1300
- moveToAnotherArray(keys, funcs, function(key) {
1301
- return typeof context[key] === "function";
1302
- });
1303
- var values = keys.map(function(vr, i) {
1304
- return context[vr];
1305
- });
1306
- var funcString = funcs.reduce(function(s, func) {
1307
- var fString = context[func].toString();
1308
- if (!/function/.test(fString)) {
1309
- fString = "function " + fString;
1310
- }
1311
- return "var " + func + "=" + fString + ";" + s;
1312
- }, "");
1313
- expr = funcString + expr;
1314
- if (!expr.match(/(["'])use strict\1/) && !keys.includes("arguments")) {
1315
- expr = "var arguments = undefined;" + expr;
1316
- }
1317
- expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
1318
- var lastStatementEnd = expr.lastIndexOf(";");
1319
- var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
1320
- return _construct(Function, _toConsumableArray(keys).concat([code])).apply(void 0, _toConsumableArray(values));
1321
- }
1322
- };
1323
1296
  function push(arr, item) {
1324
1297
  arr = arr.slice();
1325
1298
  arr.push(item);
@@ -1342,7 +1315,7 @@ var NewError = /* @__PURE__ */ function(_Error) {
1342
1315
  _this.name = "NewError";
1343
1316
  return _this;
1344
1317
  }
1345
- return NewError2;
1318
+ return _createClass(NewError2);
1346
1319
  }(/* @__PURE__ */ _wrapNativeSuper(Error));
1347
1320
  function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
1348
1321
  if (!(this instanceof JSONPath)) {
@@ -1394,7 +1367,7 @@ function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
1394
1367
  }
1395
1368
  }
1396
1369
  JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
1397
- var that = this;
1370
+ var _this2 = this;
1398
1371
  var currParent = this.parent, currParentProperty = this.parentProperty;
1399
1372
  var flatten = this.flatten, wrap = this.wrap;
1400
1373
  this.currResultType = this.resultType;
@@ -1432,7 +1405,6 @@ JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback)
1432
1405
  if (!expr && expr !== "" || !json) {
1433
1406
  return void 0;
1434
1407
  }
1435
- this._obj = json;
1436
1408
  var exprList = JSONPath.toPathArray(expr);
1437
1409
  if (exprList[0] === "$" && exprList.length > 1) {
1438
1410
  exprList.shift();
@@ -1448,7 +1420,7 @@ JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback)
1448
1420
  return this._getPreferredOutput(result[0]);
1449
1421
  }
1450
1422
  return result.reduce(function(rslt, ea) {
1451
- var valOrPath = that._getPreferredOutput(ea);
1423
+ var valOrPath = _this2._getPreferredOutput(ea);
1452
1424
  if (flatten && Array.isArray(valOrPath)) {
1453
1425
  rslt = rslt.concat(valOrPath);
1454
1426
  } else {
@@ -1460,8 +1432,6 @@ JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback)
1460
1432
  JSONPath.prototype._getPreferredOutput = function(ea) {
1461
1433
  var resultType = this.currResultType;
1462
1434
  switch (resultType) {
1463
- default:
1464
- throw new TypeError("Unknown result type");
1465
1435
  case "all": {
1466
1436
  var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
1467
1437
  ea.pointer = JSONPath.toPointer(path);
@@ -1476,6 +1446,8 @@ JSONPath.prototype._getPreferredOutput = function(ea) {
1476
1446
  return JSONPath.toPathString(ea[resultType]);
1477
1447
  case "pointer":
1478
1448
  return JSONPath.toPointer(ea.path);
1449
+ default:
1450
+ throw new TypeError("Unknown result type");
1479
1451
  }
1480
1452
  };
1481
1453
  JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
@@ -1486,8 +1458,8 @@ JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
1486
1458
  }
1487
1459
  };
1488
1460
  JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
1461
+ var _this3 = this;
1489
1462
  var retObj;
1490
- var that = this;
1491
1463
  if (!expr.length) {
1492
1464
  retObj = {
1493
1465
  path,
@@ -1514,13 +1486,13 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1514
1486
  addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
1515
1487
  } else if (loc === "*") {
1516
1488
  this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
1517
- addRet(that._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
1489
+ addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
1518
1490
  });
1519
1491
  } else if (loc === "..") {
1520
1492
  addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
1521
1493
  this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
1522
1494
  if (_typeof(v[m]) === "object") {
1523
- addRet(that._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
1495
+ addRet(_this3._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
1524
1496
  }
1525
1497
  });
1526
1498
  } else if (loc === "^") {
@@ -1548,8 +1520,8 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1548
1520
  throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
1549
1521
  }
1550
1522
  this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
1551
- if (that._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
1552
- addRet(that._trace(unshift(m, _x), v, p, par, pr, cb, true));
1523
+ if (_this3._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
1524
+ addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true));
1553
1525
  }
1554
1526
  });
1555
1527
  } else if (loc[0] === "(") {
@@ -1561,8 +1533,6 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1561
1533
  var addType = false;
1562
1534
  var valueType = loc.slice(1, -2);
1563
1535
  switch (valueType) {
1564
- default:
1565
- throw new TypeError("Unknown value type " + valueType);
1566
1536
  case "scalar":
1567
1537
  if (!val || !["object", "function"].includes(_typeof(val))) {
1568
1538
  addType = true;
@@ -1609,6 +1579,8 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1609
1579
  addType = true;
1610
1580
  }
1611
1581
  break;
1582
+ default:
1583
+ throw new TypeError("Unknown value type " + valueType);
1612
1584
  }
1613
1585
  if (addType) {
1614
1586
  retObj = {
@@ -1643,7 +1615,7 @@ JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, ca
1643
1615
  for (var t = 0; t < ret.length; t++) {
1644
1616
  var rett = ret[t];
1645
1617
  if (rett && rett.isParentSelector) {
1646
- var tmp = that._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
1618
+ var tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
1647
1619
  if (Array.isArray(tmp)) {
1648
1620
  ret[t] = tmp[0];
1649
1621
  var tl = tmp.length;
@@ -1689,37 +1661,26 @@ JSONPath.prototype._slice = function(loc, expr, val, path, parent, parentPropNam
1689
1661
  return ret;
1690
1662
  };
1691
1663
  JSONPath.prototype._eval = function(code, _v, _vname, path, parent, parentPropName) {
1692
- if (!this._obj || !_v) {
1693
- return false;
1694
- }
1695
- if (code.includes("@parentProperty")) {
1696
- this.currSandbox._$_parentProperty = parentPropName;
1697
- code = code.replace(/@parentProperty/g, "_$_parentProperty");
1698
- }
1699
- if (code.includes("@parent")) {
1700
- this.currSandbox._$_parent = parent;
1701
- code = code.replace(/@parent/g, "_$_parent");
1702
- }
1703
- if (code.includes("@property")) {
1704
- this.currSandbox._$_property = _vname;
1705
- code = code.replace(/@property/g, "_$_property");
1706
- }
1707
- if (code.includes("@path")) {
1664
+ this.currSandbox._$_parentProperty = parentPropName;
1665
+ this.currSandbox._$_parent = parent;
1666
+ this.currSandbox._$_property = _vname;
1667
+ this.currSandbox._$_root = this.json;
1668
+ this.currSandbox._$_v = _v;
1669
+ var containsPath = code.includes("@path");
1670
+ if (containsPath) {
1708
1671
  this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
1709
- code = code.replace(/@path/g, "_$_path");
1710
- }
1711
- if (code.includes("@root")) {
1712
- this.currSandbox._$_root = this.json;
1713
- code = code.replace(/@root/g, "_$_root");
1714
1672
  }
1715
- if (code.match(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/)) {
1716
- this.currSandbox._$_v = _v;
1717
- code = code.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
1673
+ var scriptCacheKey = "script:" + code;
1674
+ if (!JSONPath.cache[scriptCacheKey]) {
1675
+ var script = code.replace(/@parentProperty/g, "_$_parentProperty").replace(/@parent/g, "_$_parent").replace(/@property/g, "_$_property").replace(/@root/g, "_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
1676
+ if (containsPath) {
1677
+ script = script.replace(/@path/g, "_$_path");
1678
+ }
1679
+ JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
1718
1680
  }
1719
1681
  try {
1720
- return vm.runInNewContext(code, this.currSandbox);
1682
+ return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
1721
1683
  } catch (e) {
1722
- /* @__PURE__ */ console.log(e);
1723
1684
  throw new Error("jsonPath: " + e.message + ": " + code);
1724
1685
  }
1725
1686
  };
@@ -1752,9 +1713,9 @@ JSONPath.toPathArray = function(expr) {
1752
1713
  var subx = [];
1753
1714
  var normalized = expr.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g, function($0, $1) {
1754
1715
  return "[#" + (subx.push($1) - 1) + "]";
1755
- }).replace(/\['((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'\]/g, function($0, prop) {
1716
+ }).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g, function($0, prop) {
1756
1717
  return "['" + prop.replace(/\./g, "%@%").replace(/~/g, "%%@@%%") + "']";
1757
- }).replace(/~/g, ";~;").replace(/'?\.'?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\['?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
1718
+ }).replace(/~/g, ";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
1758
1719
  return ";" + ups.split("").join(";") + ";";
1759
1720
  }).replace(/;;;|;;/g, ";..;").replace(/;$|'?\]|'$/g, "");
1760
1721
  var exprList = normalized.split(";").map(function(exp) {
@@ -1762,7 +1723,55 @@ JSONPath.toPathArray = function(expr) {
1762
1723
  return !match2 || !match2[1] ? exp : subx[match2[1]];
1763
1724
  });
1764
1725
  cache[expr] = exprList;
1765
- return cache[expr];
1726
+ return cache[expr].concat();
1727
+ };
1728
+ var moveToAnotherArray = function moveToAnotherArray2(source2, target, conditionCb) {
1729
+ var il = source2.length;
1730
+ for (var i = 0; i < il; i++) {
1731
+ var item = source2[i];
1732
+ if (conditionCb(item)) {
1733
+ target.push(source2.splice(i--, 1)[0]);
1734
+ }
1735
+ }
1736
+ };
1737
+ var Script = /* @__PURE__ */ function() {
1738
+ function Script2(expr) {
1739
+ _classCallCheck(this, Script2);
1740
+ this.code = expr;
1741
+ }
1742
+ _createClass(Script2, [{
1743
+ key: "runInNewContext",
1744
+ value: function runInNewContext(context) {
1745
+ var expr = this.code;
1746
+ var keys = Object.keys(context);
1747
+ var funcs = [];
1748
+ moveToAnotherArray(keys, funcs, function(key) {
1749
+ return typeof context[key] === "function";
1750
+ });
1751
+ var values = keys.map(function(vr, i) {
1752
+ return context[vr];
1753
+ });
1754
+ var funcString = funcs.reduce(function(s, func) {
1755
+ var fString = context[func].toString();
1756
+ if (!/function/.test(fString)) {
1757
+ fString = "function " + fString;
1758
+ }
1759
+ return "var " + func + "=" + fString + ";" + s;
1760
+ }, "");
1761
+ expr = funcString + expr;
1762
+ if (!/(["'])use strict\1/.test(expr) && !keys.includes("arguments")) {
1763
+ expr = "var arguments = undefined;" + expr;
1764
+ }
1765
+ expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
1766
+ var lastStatementEnd = expr.lastIndexOf(";");
1767
+ var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
1768
+ return _construct(Function, keys.concat([code])).apply(void 0, _toConsumableArray(values));
1769
+ }
1770
+ }]);
1771
+ return Script2;
1772
+ }();
1773
+ JSONPath.prototype.vm = {
1774
+ Script
1766
1775
  };
1767
1776
 
1768
1777
  // src/http.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-common",
3
- "version": "2.0.0-rc2",
3
+ "version": "2.0.0-rc3",
4
4
  "description": "Common Expressions for OpenFn",
5
5
  "scripts": {
6
6
  "build": "npm exec tsm build.ts",
@@ -31,7 +31,7 @@
31
31
  "./package.json": "./package.json"
32
32
  },
33
33
  "devDependencies": {
34
- "@microsoft/api-extractor": "^7.28.3",
34
+ "@microsoft/api-extractor": "^7.29.0",
35
35
  "@openfn/simple-ast": "^0.3.2",
36
36
  "@types/mocha": "^8.2.3",
37
37
  "@types/node": "^18.0.0",
@@ -42,7 +42,7 @@
42
42
  "dts-bundle-generator": "^6.12.0",
43
43
  "esbuild": "^0.14.47",
44
44
  "execa": "^6.1.0",
45
- "jsonpath-plus": "^4.0.0",
45
+ "jsonpath-plus": "^7.0.0",
46
46
  "mocha": "^7.1.0",
47
47
  "nock": "^13.0.5",
48
48
  "rimraf": "^3.0.2",