@nocobase/plugin-workflow-json-query 1.9.0-beta.17
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/LICENSE.txt +172 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +23 -0
- package/dist/client/index.js +10 -0
- package/dist/client/instruction.d.ts +167 -0
- package/dist/externalVersion.js +19 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +42 -0
- package/dist/locale/en-US.json +13 -0
- package/dist/locale/index.d.ts +10 -0
- package/dist/locale/index.js +42 -0
- package/dist/locale/zh-CN.json +14 -0
- package/dist/node_modules/jmespath/LICENSE +13 -0
- package/dist/node_modules/jmespath/artifacts/jmespath.min.js +2 -0
- package/dist/node_modules/jmespath/bower.json +24 -0
- package/dist/node_modules/jmespath/jmespath.js +1 -0
- package/dist/node_modules/jmespath/jp.js +23 -0
- package/dist/node_modules/jmespath/package.json +1 -0
- package/dist/node_modules/jsonata/LICENSE +19 -0
- package/dist/node_modules/jsonata/jsonata-es5.js +9875 -0
- package/dist/node_modules/jsonata/jsonata-es5.min.js +1 -0
- package/dist/node_modules/jsonata/jsonata.d.ts +72 -0
- package/dist/node_modules/jsonata/jsonata.js +1 -0
- package/dist/node_modules/jsonata/jsonata.min.js +1 -0
- package/dist/node_modules/jsonata/package.json +1 -0
- package/dist/node_modules/jsonpath-plus/LICENSE +22 -0
- package/dist/node_modules/jsonpath-plus/bin/jsonpath-cli.js +36 -0
- package/dist/node_modules/jsonpath-plus/dist/index-browser-esm.js +2158 -0
- package/dist/node_modules/jsonpath-plus/dist/index-browser-esm.min.js +2 -0
- package/dist/node_modules/jsonpath-plus/dist/index-browser-umd.cjs +2166 -0
- package/dist/node_modules/jsonpath-plus/dist/index-browser-umd.min.cjs +2 -0
- package/dist/node_modules/jsonpath-plus/dist/index-node-cjs.cjs +1 -0
- package/dist/node_modules/jsonpath-plus/dist/index-node-esm.js +2068 -0
- package/dist/node_modules/jsonpath-plus/package.json +1 -0
- package/dist/node_modules/jsonpath-plus/src/Safe-Script.js +200 -0
- package/dist/node_modules/jsonpath-plus/src/jsonpath-browser.js +102 -0
- package/dist/node_modules/jsonpath-plus/src/jsonpath-node.js +8 -0
- package/dist/node_modules/jsonpath-plus/src/jsonpath.d.ts +226 -0
- package/dist/node_modules/jsonpath-plus/src/jsonpath.js +784 -0
- package/dist/server/JSONQueryInstruction.d.ts +42 -0
- package/dist/server/JSONQueryInstruction.js +99 -0
- package/dist/server/Plugin.d.ts +24 -0
- package/dist/server/Plugin.js +62 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.js +42 -0
- package/package.json +31 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";class t{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,s){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,s?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const s={context:this,node:r};return t.hooks.run(e,s),s.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,s,n=[];for(;this.index<this.expr.length;)if(r=this.code,r===t.SEMCOL_CODE||r===t.COMMA_CODE)this.index++;else if(s=this.gobbleExpression())n.push(s);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,t.max_binop_len),r=e.length;for(;r>0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=r,e;e=e.substr(0,--r)}return!1}gobbleBinaryExpression(){let e,r,s,n,i,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(i={value:r,prec:t.binaryPrecedence(r),right_a:t.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),n=[o,i,a];r=this.gobbleBinaryOp();){if(s=t.binaryPrecedence(r),0===s){this.index-=r.length;break}i={value:r,prec:s,right_a:t.right_associative.has(r)},l=r;const h=e=>i.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),n.push(i,e)}for(h=n.length-1,e=n[h];h>1;)e={type:t.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),s=r.length;s>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=s;const e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:t.UNARY_EXP,operator:r,argument:e,prefix:!0})}r=r.substr(0,--s)}t.isIdentifierStart(e)?(n=this.gobbleIdentifier(),t.literals.hasOwnProperty(n.name)?n={type:t.LITERAL,value:t.literals[n.name],raw:n.name}:n.name===t.this_str&&(n={type:t.THIS_EXP})):e===t.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let r=this.code;for(;r===t.PERIOD_CODE||r===t.OBRACK_CODE||r===t.OPAREN_CODE||r===t.QUMARK_CODE;){let s;if(r===t.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==t.PERIOD_CODE)break;s=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===t.OBRACK_CODE?((e={type:t.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==t.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===t.OPAREN_CODE?e={type:t.CALL_EXP,arguments:this.gobbleArguments(t.CPAREN_CODE),callee:e}:(r===t.PERIOD_CODE||s)&&(s&&this.index--,this.gobbleSpaces(),e={type:t.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),s&&(e.optional=!0),this.gobbleSpaces(),r=this.code}return e}gobbleNumericLiteral(){let e,r,s="";for(;t.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(this.code===t.PERIOD_CODE)for(s+=this.expr.charAt(this.index++);t.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(e=this.char,"e"===e||"E"===e){for(s+=this.expr.charAt(this.index++),e=this.char,"+"!==e&&"-"!==e||(s+=this.expr.charAt(this.index++));t.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);t.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+s+this.char+")")}return r=this.code,t.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+s+this.char+")"):(r===t.PERIOD_CODE||1===s.length&&s.charCodeAt(0)===t.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:t.LITERAL,value:parseFloat(s),raw:s}}gobbleStringLiteral(){let e="";const r=this.index,s=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===s){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++),t){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:t.LITERAL,value:e,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let e=this.code,r=this.index;for(t.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,t.isIdentifierPart(e));)this.index++;return{type:t.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(e){const r=[];let s=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===e){s=!0,this.index++,e===t.CPAREN_CODE&&n&&n>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===t.COMMA_CODE){if(this.index++,n++,n!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e<n;e++)r.push(null)}else if(r.length!==n&&0!==n)this.throwError("Expected comma");else{const e=this.gobbleExpression();e&&e.type!==t.COMPOUND||this.throwError("Expected comma"),r.push(e)}}return s||this.throwError("Expected "+String.fromCharCode(e)),r}gobbleGroup(){this.index++;let e=this.gobbleExpressions(t.CPAREN_CODE);if(this.code===t.CPAREN_CODE)return this.index++,1===e.length?e[0]:!!e.length&&{type:t.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:t.ARRAY_EXP,elements:this.gobbleArguments(t.CBRACK_CODE)}}}const r=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(t,{hooks:r,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const s=e=>new t(e).parse(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter((e=>!n.includes(e)&&void 0===s[e])).forEach((e=>{s[e]=t[e]})),s.Jsep=t;var i={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};s.plugins.register(i);var o={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index<this.expr.length;){if(47===this.code&&!s){const s=this.expr.slice(r,this.index);let n,i="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}a.assignmentOperators.forEach((t=>e.addBinaryOp(t,a.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};s.plugins.register(o,a),s.addUnaryOp("typeof"),s.addLiteral("null",null),s.addLiteral("undefined",void 0);const h=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),l={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return l.evalBinaryExpression(e,t);case"Compound":return l.evalCompound(e,t);case"ConditionalExpression":return l.evalConditionalExpression(e,t);case"Identifier":return l.evalIdentifier(e,t);case"Literal":return l.evalLiteral(e,t);case"MemberExpression":return l.evalMemberExpression(e,t);case"UnaryExpression":return l.evalUnaryExpression(e,t);case"ArrayExpression":return l.evalArrayExpression(e,t);case"CallExpression":return l.evalCallExpression(e,t);case"AssignmentExpression":return l.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](l.evalAst(e.left,t),(()=>l.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let s=0;s<e.body.length;s++){"Identifier"===e.body[s].type&&["var","let","const"].includes(e.body[s].name)&&e.body[s+1]&&"AssignmentExpression"===e.body[s+1].type&&(s+=1);const n=e.body[s];r=l.evalAst(n,t)}return r},evalConditionalExpression:(e,t)=>l.evalAst(e.test,t)?l.evalAst(e.consequent,t):l.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=String(e.computed?l.evalAst(e.property):e.property.name),s=l.evalAst(e.object,t);if(null==s)throw TypeError(`Cannot read properties of ${s} (reading '${r}')`);if(!Object.hasOwn(s,r)&&h.has(r))throw TypeError(`Cannot read properties of ${s} (reading '${r}')`);const n=s[r];return"function"==typeof n?n.bind(s):n},evalUnaryExpression:(e,t)=>({"-":e=>-l.evalAst(e,t),"!":e=>!l.evalAst(e,t),"~":e=>~l.evalAst(e,t),"+":e=>+l.evalAst(e,t),typeof:e=>typeof l.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>l.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>l.evalAst(e,t)));return l.evalAst(e.callee,t)(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=l.evalAst(e.right,t);return t[r]=s,t[r]}};function c(e,t){return(e=e.slice()).push(t),e}function p(e,t){return(t=t.slice()).unshift(e),t}class u extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function d(e,t,r,s,n){if(!(this instanceof d))try{return new d(e,t,r,s,n)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const s={path:i?e.path:t};i?"json"in e&&(s.json=e.json):s.json=r;const n=this.evaluate(s);if(!n||"object"!=typeof n)throw new u(n);return n}}d.prototype.evaluate=function(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(e,"parent")?e.parent:n,i=Object.hasOwn(e,"parentProperty")?e.parentProperty:i,e=e.path}if(n=n||null,i=i||null,Array.isArray(e)&&(e=d.toPathString(e)),!e&&""!==e||!t)return;const h=d.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],n,i,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},d.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:d.toPathArray(e.path);return e.pointer=d.toPointer(t),e.path="string"==typeof e.path?e.path:d.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return d.toPathString(e[t]);case"pointer":return d.toPointer(e.path);default:throw new TypeError("Unknown result type")}},d.prototype._handleCallback=function(e,t,r){if(t){const s=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:d.toPathString(e.path),t(s,r,e)}},d.prototype._trace=function(e,t,r,s,n,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const l=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof l||a)&&t&&Object.hasOwn(t,l))f(this._trace(u,t[l],c(r,l),t,l,i,o));else if("*"===l)this._walk(t,(e=>{f(this._trace(u,t[e],c(r,e),t,e,i,!0,!0))}));else if(".."===l)f(this._trace(u,t,r,s,n,i,o)),this._walk(t,(s=>{"object"==typeof t[s]&&f(this._trace(e.slice(),t[s],c(r,s),t,s,i,!0))}));else{if("^"===l)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===l)return h={path:c(r,l),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)f(this._trace(u,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))f(this._slice(l,u,t,r,s,n,i));else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],h=o[1]?t[e][o[1]]:t[e];this._trace(a,h,r,s,n,i,!0).length>0&&f(this._trace(u,t[e],c(r,e),t,e,i,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,s,n)&&f(this._trace(u,t[o],c(r,o),t,o,i,!0))}))}else if("("===l[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(p(this._eval(l,t,r.at(-1),r.slice(0,-1),s,n),u),t,r,s,n,i,o))}else if("@"===l[0]){let e=!1;const o=l.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,n);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if("`"===l[0]&&t&&Object.hasOwn(t,l.slice(1))){const e=l.slice(1);f(this._trace(u,t[e],c(r,e),t,e,i,o,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)f(this._trace(p(o,u),t,r,s,n,i,!0))}else!a&&t&&Object.hasOwn(t,l)&&f(this._trace(u,t[l],c(r,l),t,l,i,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,s,n,i,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},d.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},d.prototype._slice=function(e,t,r,s,n,i,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number.parseInt(h[2])||1;let c=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;c=c<0?Math.max(0,c+a):Math.min(a,c),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=c;e<u;e+=l){this._trace(p(e,t),r,s,n,i,o,!0).forEach((e=>{d.push(e)}))}return d},d.prototype._eval=function(e,t,r,s,n,i){this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=d.toPathString(s.concat([r])));const a=this.currEval+"Script:"+e;if(!d.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)d.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)d.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;d.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);d.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return d.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},d.cache={},d.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return s},d.toPointer=function(e){const t=e,r=t.length;let s="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return s},d.toPathArray=function(e){const{cache:t}=d;if(t[e])return t[e].concat();const r=[],s=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=s,t[e].concat()},d.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=s(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return l.evalAst(this.ast,t)}}};d.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),s=[];!function(e,t,r){const s=e.length;for(let n=0;n<s;n++)r(e[n])&&t.push(e.splice(n--,1)[0])}(r,s,(t=>"function"==typeof e[t]));const n=r.map((t=>e[t]));t=s.reduce(((t,r)=>{let s=e[r].toString();return/function/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...n)}}},e.JSONPath=d}));
|
|
2
|
+
//# sourceMappingURL=index-browser-umd.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";var e={144:function(e){e.exports=require("vm")}};var t={};function __nccwpck_require__(r){var s=t[r];if(s!==undefined){return s.exports}var i=t[r]={exports:{}};var n=true;try{e[r](i,i.exports,__nccwpck_require__);n=false}finally{if(n)delete t[r]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};!function(){var e=r;var t=__nccwpck_require__(144);class Hooks{add(e,t,r){if(typeof arguments[0]!="string"){for(let e in arguments[0]){this.add(e,arguments[0][e],arguments[1])}}else{(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[];if(t){this[e][r?"unshift":"push"](t)}}),this)}}run(e,t){this[e]=this[e]||[];this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}}class Plugins{constructor(e){this.jsep=e;this.registered={}}register(...e){e.forEach((e=>{if(typeof e!=="object"||!e.name||!e.init){throw new Error("Invalid JSEP plugin format")}if(this.registered[e.name]){return}e.init(this.jsep);this.registered[e.name]=e}))}}class Jsep{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Jsep.version}static addUnaryOp(e){Jsep.max_unop_len=Math.max(e.length,Jsep.max_unop_len);Jsep.unary_ops[e]=1;return Jsep}static addBinaryOp(e,t,r){Jsep.max_binop_len=Math.max(e.length,Jsep.max_binop_len);Jsep.binary_ops[e]=t;if(r){Jsep.right_associative.add(e)}else{Jsep.right_associative.delete(e)}return Jsep}static addIdentifierChar(e){Jsep.additional_identifier_chars.add(e);return Jsep}static addLiteral(e,t){Jsep.literals[e]=t;return Jsep}static removeUnaryOp(e){delete Jsep.unary_ops[e];if(e.length===Jsep.max_unop_len){Jsep.max_unop_len=Jsep.getMaxKeyLen(Jsep.unary_ops)}return Jsep}static removeAllUnaryOps(){Jsep.unary_ops={};Jsep.max_unop_len=0;return Jsep}static removeIdentifierChar(e){Jsep.additional_identifier_chars.delete(e);return Jsep}static removeBinaryOp(e){delete Jsep.binary_ops[e];if(e.length===Jsep.max_binop_len){Jsep.max_binop_len=Jsep.getMaxKeyLen(Jsep.binary_ops)}Jsep.right_associative.delete(e);return Jsep}static removeAllBinaryOps(){Jsep.binary_ops={};Jsep.max_binop_len=0;return Jsep}static removeLiteral(e){delete Jsep.literals[e];return Jsep}static removeAllLiterals(){Jsep.literals={};return Jsep}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e;this.index=0}static parse(e){return new Jsep(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return Jsep.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Jsep.binary_ops[String.fromCharCode(e)]||Jsep.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Jsep.isIdentifierStart(e)||Jsep.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);t.index=this.index;t.description=e;throw t}runHook(e,t){if(Jsep.hooks[e]){const r={context:this,node:t};Jsep.hooks.run(e,r);return r.node}return t}searchHook(e){if(Jsep.hooks[e]){const t={context:this};Jsep.hooks[e].find((function(e){e.call(t.context,t);return t.node}));return t.node}}gobbleSpaces(){let e=this.code;while(e===Jsep.SPACE_CODE||e===Jsep.TAB_CODE||e===Jsep.LF_CODE||e===Jsep.CR_CODE){e=this.expr.charCodeAt(++this.index)}this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions();const t=e.length===1?e[0]:{type:Jsep.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,s;while(this.index<this.expr.length){r=this.code;if(r===Jsep.SEMCOL_CODE||r===Jsep.COMMA_CODE){this.index++}else{if(s=this.gobbleExpression()){t.push(s)}else if(this.index<this.expr.length){if(r===e){break}this.throwError('Unexpected "'+this.char+'"')}}}return t}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();this.gobbleSpaces();return this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,Jsep.max_binop_len);let t=e.length;while(t>0){if(Jsep.binary_ops.hasOwnProperty(e)&&(!Jsep.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Jsep.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=t;return e}e=e.substr(0,--t)}return false}gobbleBinaryExpression(){let e,t,r,s,i,n,a,o,h;n=this.gobbleToken();if(!n){return n}t=this.gobbleBinaryOp();if(!t){return n}i={value:t,prec:Jsep.binaryPrecedence(t),right_a:Jsep.right_associative.has(t)};a=this.gobbleToken();if(!a){this.throwError("Expected expression after "+t)}s=[n,i,a];while(t=this.gobbleBinaryOp()){r=Jsep.binaryPrecedence(t);if(r===0){this.index-=t.length;break}i={value:t,prec:r,right_a:Jsep.right_associative.has(t)};h=t;const comparePrev=e=>i.right_a&&e.right_a?r>e.prec:r<=e.prec;while(s.length>2&&comparePrev(s[s.length-2])){a=s.pop();t=s.pop().value;n=s.pop();e={type:Jsep.BINARY_EXP,operator:t,left:n,right:a};s.push(e)}e=this.gobbleToken();if(!e){this.throwError("Expected expression after "+h)}s.push(i,e)}o=s.length-1;e=s[o];while(o>1){e={type:Jsep.BINARY_EXP,operator:s[o-1].value,left:s[o-2],right:e};o-=2}return e}gobbleToken(){let e,t,r,s;this.gobbleSpaces();s=this.searchHook("gobble-token");if(s){return this.runHook("after-token",s)}e=this.code;if(Jsep.isDecimalDigit(e)||e===Jsep.PERIOD_CODE){return this.gobbleNumericLiteral()}if(e===Jsep.SQUOTE_CODE||e===Jsep.DQUOTE_CODE){s=this.gobbleStringLiteral()}else if(e===Jsep.OBRACK_CODE){s=this.gobbleArray()}else{t=this.expr.substr(this.index,Jsep.max_unop_len);r=t.length;while(r>0){if(Jsep.unary_ops.hasOwnProperty(t)&&(!Jsep.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Jsep.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;const e=this.gobbleToken();if(!e){this.throwError("missing unaryOp argument")}return this.runHook("after-token",{type:Jsep.UNARY_EXP,operator:t,argument:e,prefix:true})}t=t.substr(0,--r)}if(Jsep.isIdentifierStart(e)){s=this.gobbleIdentifier();if(Jsep.literals.hasOwnProperty(s.name)){s={type:Jsep.LITERAL,value:Jsep.literals[s.name],raw:s.name}}else if(s.name===Jsep.this_str){s={type:Jsep.THIS_EXP}}}else if(e===Jsep.OPAREN_CODE){s=this.gobbleGroup()}}if(!s){return this.runHook("after-token",false)}s=this.gobbleTokenProperty(s);return this.runHook("after-token",s)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;while(t===Jsep.PERIOD_CODE||t===Jsep.OBRACK_CODE||t===Jsep.OPAREN_CODE||t===Jsep.QUMARK_CODE){let r;if(t===Jsep.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Jsep.PERIOD_CODE){break}r=true;this.index+=2;this.gobbleSpaces();t=this.code}this.index++;if(t===Jsep.OBRACK_CODE){e={type:Jsep.MEMBER_EXP,computed:true,object:e,property:this.gobbleExpression()};if(!e.property){this.throwError('Unexpected "'+this.char+'"')}this.gobbleSpaces();t=this.code;if(t!==Jsep.CBRACK_CODE){this.throwError("Unclosed [")}this.index++}else if(t===Jsep.OPAREN_CODE){e={type:Jsep.CALL_EXP,arguments:this.gobbleArguments(Jsep.CPAREN_CODE),callee:e}}else if(t===Jsep.PERIOD_CODE||r){if(r){this.index--}this.gobbleSpaces();e={type:Jsep.MEMBER_EXP,computed:false,object:e,property:this.gobbleIdentifier()}}if(r){e.optional=true}this.gobbleSpaces();t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;while(Jsep.isDecimalDigit(this.code)){e+=this.expr.charAt(this.index++)}if(this.code===Jsep.PERIOD_CODE){e+=this.expr.charAt(this.index++);while(Jsep.isDecimalDigit(this.code)){e+=this.expr.charAt(this.index++)}}t=this.char;if(t==="e"||t==="E"){e+=this.expr.charAt(this.index++);t=this.char;if(t==="+"||t==="-"){e+=this.expr.charAt(this.index++)}while(Jsep.isDecimalDigit(this.code)){e+=this.expr.charAt(this.index++)}if(!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index-1))){this.throwError("Expected exponent ("+e+this.char+")")}}r=this.code;if(Jsep.isIdentifierStart(r)){this.throwError("Variable names cannot start with a number ("+e+this.char+")")}else if(r===Jsep.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Jsep.PERIOD_CODE){this.throwError("Unexpected period")}return{type:Jsep.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="";const t=this.index;const r=this.expr.charAt(this.index++);let s=false;while(this.index<this.expr.length){let t=this.expr.charAt(this.index++);if(t===r){s=true;break}else if(t==="\\"){t=this.expr.charAt(this.index++);switch(t){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}}else{e+=t}}if(!s){this.throwError('Unclosed quote after "'+e+'"')}return{type:Jsep.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;if(Jsep.isIdentifierStart(e)){this.index++}else{this.throwError("Unexpected "+this.char)}while(this.index<this.expr.length){e=this.code;if(Jsep.isIdentifierPart(e)){this.index++}else{break}}return{type:Jsep.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){const t=[];let r=false;let s=0;while(this.index<this.expr.length){this.gobbleSpaces();let i=this.code;if(i===e){r=true;this.index++;if(e===Jsep.CPAREN_CODE&&s&&s>=t.length){this.throwError("Unexpected token "+String.fromCharCode(e))}break}else if(i===Jsep.COMMA_CODE){this.index++;s++;if(s!==t.length){if(e===Jsep.CPAREN_CODE){this.throwError("Unexpected token ,")}else if(e===Jsep.CBRACK_CODE){for(let e=t.length;e<s;e++){t.push(null)}}}}else if(t.length!==s&&s!==0){this.throwError("Expected comma")}else{const e=this.gobbleExpression();if(!e||e.type===Jsep.COMPOUND){this.throwError("Expected comma")}t.push(e)}}if(!r){this.throwError("Expected "+String.fromCharCode(e))}return t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(Jsep.CPAREN_CODE);if(this.code===Jsep.CPAREN_CODE){this.index++;if(e.length===1){return e[0]}else if(!e.length){return false}else{return{type:Jsep.SEQUENCE_EXP,expressions:e}}}else{this.throwError("Unclosed (")}}gobbleArray(){this.index++;return{type:Jsep.ARRAY_EXP,elements:this.gobbleArguments(Jsep.CBRACK_CODE)}}}const s=new Hooks;Object.assign(Jsep,{hooks:s,plugins:new Plugins(Jsep),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:true,false:false,null:null},this_str:"this"});Jsep.max_unop_len=Jsep.getMaxKeyLen(Jsep.unary_ops);Jsep.max_binop_len=Jsep.getMaxKeyLen(Jsep.binary_ops);const jsep=e=>new Jsep(e).parse();const i=Object.getOwnPropertyNames(class Test{});Object.getOwnPropertyNames(Jsep).filter((e=>!i.includes(e)&&jsep[e]===undefined)).forEach((e=>{jsep[e]=Jsep[e]}));jsep.Jsep=Jsep;const n="ConditionalExpression";var a={name:"ternary",init(e){e.hooks.add("after-expression",(function gobbleTernary(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node;const s=this.gobbleExpression();if(!s){this.throwError("Expected expression")}this.gobbleSpaces();if(this.code===e.COLON_CODE){this.index++;const i=this.gobbleExpression();if(!i){this.throwError("Expected expression")}t.node={type:n,test:r,consequent:s,alternate:i};if(r.operator&&e.binary_ops[r.operator]<=.9){let s=r;while(s.right.operator&&e.binary_ops[s.right.operator]<=.9){s=s.right}t.node.test=s.right;s.right=t.node;t.node=r}}else{this.throwError("Expected :")}}}))}};jsep.plugins.register(a);const o=47;const h=92;var p={name:"regex",init(e){e.hooks.add("gobble-token",(function gobbleRegexLiteral(t){if(this.code===o){const r=++this.index;let s=false;while(this.index<this.expr.length){if(this.code===o&&!s){const s=this.expr.slice(r,this.index);let i="";while(++this.index<this.expr.length){const e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57){i+=this.char}else{break}}let n;try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)};t.node=this.gobbleTokenProperty(t.node);return t.node}if(this.code===e.OBRACK_CODE){s=true}else if(s&&this.code===e.CBRACK_CODE){s=false}this.index+=this.code===h?2:1}this.throwError("Unclosed Regex")}}))}};const l=43;const c=45;const u={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[l,c],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];u.assignmentOperators.forEach((t=>e.addBinaryOp(t,u.assignmentPrecedence,true)));e.hooks.add("gobble-token",(function gobbleUpdatePrefix(e){const r=this.code;if(u.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))){this.index+=2;e.node={type:"UpdateExpression",operator:r===l?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:true};if(!e.node.argument||!t.includes(e.node.argument.type)){this.throwError(`Unexpected ${e.node.operator}`)}}}));e.hooks.add("after-token",(function gobbleUpdatePostfix(e){if(e.node){const r=this.code;if(u.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))){if(!t.includes(e.node.type)){this.throwError(`Unexpected ${e.node.operator}`)}this.index+=2;e.node={type:"UpdateExpression",operator:r===l?"++":"--",argument:e.node,prefix:false}}}}));e.hooks.add("after-expression",(function gobbleAssignment(e){if(e.node){updateBinariesToAssignments(e.node)}}));function updateBinariesToAssignments(e){if(u.assignmentOperators.has(e.operator)){e.type="AssignmentExpression";updateBinariesToAssignments(e.left);updateBinariesToAssignments(e.right)}else if(!e.operator){Object.values(e).forEach((e=>{if(e&&typeof e==="object"){updateBinariesToAssignments(e)}}))}}}};jsep.plugins.register(p,u);jsep.addUnaryOp("typeof");jsep.addLiteral("null",null);jsep.addLiteral("undefined",undefined);const d=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]);const f={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return f.evalBinaryExpression(e,t);case"Compound":return f.evalCompound(e,t);case"ConditionalExpression":return f.evalConditionalExpression(e,t);case"Identifier":return f.evalIdentifier(e,t);case"Literal":return f.evalLiteral(e,t);case"MemberExpression":return f.evalMemberExpression(e,t);case"UnaryExpression":return f.evalUnaryExpression(e,t);case"ArrayExpression":return f.evalArrayExpression(e,t);case"CallExpression":return f.evalCallExpression(e,t);case"AssignmentExpression":return f.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression(e,t){const r={"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](f.evalAst(e.left,t),(()=>f.evalAst(e.right,t)));return r},evalCompound(e,t){let r;for(let s=0;s<e.body.length;s++){if(e.body[s].type==="Identifier"&&["var","let","const"].includes(e.body[s].name)&&e.body[s+1]&&e.body[s+1].type==="AssignmentExpression"){s+=1}const i=e.body[s];r=f.evalAst(i,t)}return r},evalConditionalExpression(e,t){if(f.evalAst(e.test,t)){return f.evalAst(e.consequent,t)}return f.evalAst(e.alternate,t)},evalIdentifier(e,t){if(Object.hasOwn(t,e.name)){return t[e.name]}throw ReferenceError(`${e.name} is not defined`)},evalLiteral(e){return e.value},evalMemberExpression(e,t){const r=String(e.computed?f.evalAst(e.property):e.property.name);const s=f.evalAst(e.object,t);if(s===undefined||s===null){throw TypeError(`Cannot read properties of ${s} (reading '${r}')`)}if(!Object.hasOwn(s,r)&&d.has(r)){throw TypeError(`Cannot read properties of ${s} (reading '${r}')`)}const i=s[r];if(typeof i==="function"){return i.bind(s)}return i},evalUnaryExpression(e,t){const r={"-":e=>-f.evalAst(e,t),"!":e=>!f.evalAst(e,t),"~":e=>~f.evalAst(e,t),"+":e=>+f.evalAst(e,t),typeof:e=>typeof f.evalAst(e,t)}[e.operator](e.argument);return r},evalArrayExpression(e,t){return e.elements.map((e=>f.evalAst(e,t)))},evalCallExpression(e,t){const r=e.arguments.map((e=>f.evalAst(e,t)));const s=f.evalAst(e.callee,t);return s(...r)},evalAssignmentExpression(e,t){if(e.left.type!=="Identifier"){throw SyntaxError("Invalid left-hand side in assignment")}const r=e.left.name;const s=f.evalAst(e.right,t);t[r]=s;return t[r]}};class SafeScript{constructor(e){this.code=e;this.ast=jsep(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return f.evalAst(this.ast,t)}}function push(e,t){e=e.slice();e.push(t);return e}function unshift(e,t){t=t.slice();t.unshift(e);return t}class NewError extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return '+"of (unwrapped) scalar values)");this.avoidNew=true;this.value=e;this.name="NewError"}}function JSONPath(e,t,r,s,i){if(!(this instanceof JSONPath)){try{return new JSONPath(e,t,r,s,i)}catch(e){if(!e.avoidNew){throw e}return e.value}}if(typeof e==="string"){i=s;s=r;r=t;t=e;e=null}const n=e&&typeof e==="object";e=e||{};this.json=e.json||r;this.path=e.path||t;this.resultType=e.resultType||"value";this.flatten=e.flatten||false;this.wrap=Object.hasOwn(e,"wrap")?e.wrap:true;this.sandbox=e.sandbox||{};this.eval=e.eval===undefined?"safe":e.eval;this.ignoreEvalErrors=typeof e.ignoreEvalErrors==="undefined"?false:e.ignoreEvalErrors;this.parent=e.parent||null;this.parentProperty=e.parentProperty||null;this.callback=e.callback||s||null;this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option "+"with the @other() operator.")};if(e.autostart!==false){const s={path:n?e.path:t};if(!n){s.json=r}else if("json"in e){s.json=e.json}const i=this.evaluate(s);if(!i||typeof i!=="object"){throw new NewError(i)}return i}}JSONPath.prototype.evaluate=function(e,t,r,s){let i=this.parent,n=this.parentProperty;let{flatten:a,wrap:o}=this;this.currResultType=this.resultType;this.currEval=this.eval;this.currSandbox=this.sandbox;r=r||this.callback;this.currOtherTypeCallback=s||this.otherTypeCallback;t=t||this.json;e=e||this.path;if(e&&typeof e==="object"&&!Array.isArray(e)){if(!e.path&&e.path!==""){throw new TypeError('You must supply a "path" property when providing an object '+"argument to JSONPath.evaluate().")}if(!Object.hasOwn(e,"json")){throw new TypeError('You must supply a "json" property when providing an object '+"argument to JSONPath.evaluate().")}({json:t}=e);a=Object.hasOwn(e,"flatten")?e.flatten:a;this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType;this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox;o=Object.hasOwn(e,"wrap")?e.wrap:o;this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval;r=Object.hasOwn(e,"callback")?e.callback:r;this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback;i=Object.hasOwn(e,"parent")?e.parent:i;n=Object.hasOwn(e,"parentProperty")?e.parentProperty:n;e=e.path}i=i||null;n=n||null;if(Array.isArray(e)){e=JSONPath.toPathString(e)}if(!e&&e!==""||!t){return undefined}const h=JSONPath.toPathArray(e);if(h[0]==="$"&&h.length>1){h.shift()}this._hasParentSelector=null;const p=this._trace(h,t,["$"],i,n,r).filter((function(e){return e&&!e.isParentSelector}));if(!p.length){return o?[]:undefined}if(!o&&p.length===1&&!p[0].hasArrExpr){return this._getPreferredOutput(p[0])}return p.reduce(((e,t)=>{const r=this._getPreferredOutput(t);if(a&&Array.isArray(r)){e=e.concat(r)}else{e.push(r)}return e}),[])};JSONPath.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:JSONPath.toPathArray(e.path);e.pointer=JSONPath.toPointer(t);e.path=typeof e.path==="string"?e.path:JSONPath.toPathString(e.path);return e}case"value":case"parent":case"parentProperty":return e[t];case"path":return JSONPath.toPathString(e[t]);case"pointer":return JSONPath.toPointer(e.path);default:throw new TypeError("Unknown result type")}};JSONPath.prototype._handleCallback=function(e,t,r){if(t){const s=this._getPreferredOutput(e);e.path=typeof e.path==="string"?e.path:JSONPath.toPathString(e.path);t(s,r,e)}};JSONPath.prototype._trace=function(e,t,r,s,i,n,a,o){let h;if(!e.length){h={path:r,value:t,parent:s,parentProperty:i,hasArrExpr:a};this._handleCallback(h,n,"value");return h}const p=e[0],l=e.slice(1);const c=[];function addRet(e){if(Array.isArray(e)){e.forEach((e=>{c.push(e)}))}else{c.push(e)}}if((typeof p!=="string"||o)&&t&&Object.hasOwn(t,p)){addRet(this._trace(l,t[p],push(r,p),t,p,n,a))}else if(p==="*"){this._walk(t,(e=>{addRet(this._trace(l,t[e],push(r,e),t,e,n,true,true))}))}else if(p===".."){addRet(this._trace(l,t,r,s,i,n,a));this._walk(t,(s=>{if(typeof t[s]==="object"){addRet(this._trace(e.slice(),t[s],push(r,s),t,s,n,true))}}))}else if(p==="^"){this._hasParentSelector=true;return{path:r.slice(0,-1),expr:l,isParentSelector:true}}else if(p==="~"){h={path:push(r,p),value:i,parent:s,parentProperty:null};this._handleCallback(h,n,"property");return h}else if(p==="$"){addRet(this._trace(l,t,r,null,null,n,a))}else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p)){addRet(this._slice(p,l,t,r,s,i,n))}else if(p.indexOf("?(")===0){if(this.currEval===false){throw new Error("Eval [?(expr)] prevented in JSONPath expression.")}const e=p.replace(/^\?\((.*?)\)$/u,"$1");const a=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);if(a){this._walk(t,(e=>{const o=[a[2]];const h=a[1]?t[e][a[1]]:t[e];const p=this._trace(o,h,r,s,i,n,true);if(p.length>0){addRet(this._trace(l,t[e],push(r,e),t,e,n,true))}}))}else{this._walk(t,(a=>{if(this._eval(e,t[a],a,r,s,i)){addRet(this._trace(l,t[a],push(r,a),t,a,n,true))}}))}}else if(p[0]==="("){if(this.currEval===false){throw new Error("Eval [(expr)] prevented in JSONPath expression.")}addRet(this._trace(unshift(this._eval(p,t,r.at(-1),r.slice(0,-1),s,i),l),t,r,s,i,n,a))}else if(p[0]==="@"){let e=false;const a=p.slice(1,-2);switch(a){case"scalar":if(!t||!["object","function"].includes(typeof t)){e=true}break;case"boolean":case"string":case"undefined":case"function":if(typeof t===a){e=true}break;case"integer":if(Number.isFinite(t)&&!(t%1)){e=true}break;case"number":if(Number.isFinite(t)){e=true}break;case"nonFinite":if(typeof t==="number"&&!Number.isFinite(t)){e=true}break;case"object":if(t&&typeof t===a){e=true}break;case"array":if(Array.isArray(t)){e=true}break;case"other":e=this.currOtherTypeCallback(t,r,s,i);break;case"null":if(t===null){e=true}break;default:throw new TypeError("Unknown value type "+a)}if(e){h={path:r,value:t,parent:s,parentProperty:i};this._handleCallback(h,n,"value");return h}}else if(p[0]==="`"&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);addRet(this._trace(l,t[e],push(r,e),t,e,n,a,true))}else if(p.includes(",")){const e=p.split(",");for(const a of e){addRet(this._trace(unshift(a,l),t,r,s,i,n,true))}}else if(!o&&t&&Object.hasOwn(t,p)){addRet(this._trace(l,t[p],push(r,p),t,p,n,a,true))}if(this._hasParentSelector){for(let e=0;e<c.length;e++){const r=c[e];if(r&&r.isParentSelector){const o=this._trace(r.expr,t,r.path,s,i,n,a);if(Array.isArray(o)){c[e]=o[0];const t=o.length;for(let r=1;r<t;r++){e++;c.splice(e,0,o[r])}}else{c[e]=o}}}}return c};JSONPath.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++){t(e)}}else if(e&&typeof e==="object"){Object.keys(e).forEach((e=>{t(e)}))}};JSONPath.prototype._slice=function(e,t,r,s,i,n,a){if(!Array.isArray(r)){return undefined}const o=r.length,h=e.split(":"),p=h[2]&&Number.parseInt(h[2])||1;let l=h[0]&&Number.parseInt(h[0])||0,c=h[1]&&Number.parseInt(h[1])||o;l=l<0?Math.max(0,l+o):Math.min(o,l);c=c<0?Math.max(0,c+o):Math.min(o,c);const u=[];for(let e=l;e<c;e+=p){const o=this._trace(unshift(e,t),r,s,i,n,a,true);o.forEach((e=>{u.push(e)}))}return u};JSONPath.prototype._eval=function(e,t,r,s,i,n){this.currSandbox._$_parentProperty=n;this.currSandbox._$_parent=i;this.currSandbox._$_property=r;this.currSandbox._$_root=this.json;this.currSandbox._$_v=t;const a=e.includes("@path");if(a){this.currSandbox._$_path=JSONPath.toPathString(s.concat([r]))}const o=this.currEval+"Script:"+e;if(!JSONPath.cache[o]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(a){t=t.replaceAll("@path","_$_path")}if(this.currEval==="safe"||this.currEval===true||this.currEval===undefined){JSONPath.cache[o]=new this.safeVm.Script(t)}else if(this.currEval==="native"){JSONPath.cache[o]=new this.vm.Script(t)}else if(typeof this.currEval==="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;JSONPath.cache[o]=new e(t)}else if(typeof this.currEval==="function"){JSONPath.cache[o]={runInNewContext:e=>this.currEval(t,e)}}else{throw new TypeError(`Unknown "eval" property "${this.currEval}"`)}}try{return JSONPath.cache[o].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors){return false}throw new Error("jsonPath: "+t.message+": "+e)}};JSONPath.cache={};JSONPath.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e<r;e++){if(!/^(~|\^|@.*?\(\))$/u.test(t[e])){s+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']"}}return s};JSONPath.toPointer=function(e){const t=e,r=t.length;let s="";for(let e=1;e<r;e++){if(!/^(~|\^|@.*?\(\))$/u.test(t[e])){s+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1")}}return s};JSONPath.toPathArray=function(e){const{cache:t}=JSONPath;if(t[e]){return t[e].concat()}const r=[];const s=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"");const i=s.split(";").map((function(e){const t=e.match(/#(\d+)/u);return!t||!t[1]?e:r[t[1]]}));t[e]=i;return t[e].concat()};JSONPath.prototype.safeVm={Script:SafeScript};JSONPath.prototype.vm=t;e.JSONPath=JSONPath}();module.exports=r})();
|