fig-tree-evaluator 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,6 +53,7 @@ A range of built-in operators are available, from simple logic, arithmetic and s
53
53
  - [Fragments](#fragments)
54
54
  - [Shorthand syntax](#shorthand-syntax)
55
55
  - [Caching (Memoization)](#caching-memoization)
56
+ - [Error handling](#error-handling)
56
57
  - [Metadata](#metadata)
57
58
  - [More examples](#more-examples)
58
59
  - [Development environment](#development-environment)
@@ -156,7 +157,7 @@ The `options` parameter is an object with the following available properties (al
156
157
  - `sqlConnection` -- if you wish to make calls to an SQL database using the [`SQL` operator](#sql), pass a connection to the database here. See operator details below.
157
158
  - `baseEndpoint` -- A general http headers object that will be passed to *all* http-based operators (`GET`, `POST`, `GraphQL`). Useful if all http queries are to a common server -- then each individual node will only require a relative url. See specific operator for more details.
158
159
  - `headers` -- A general http headers object that will be passed to *all* http-based operators. Useful for authentication headers, for example. Each operator and instance can have its own headers, though, so see specific operator reference for details.
159
- - `returnErrorAsString` -- by default the evaluator will throw errors with invalid evaluation expressions (with helpful error messages indicating the node which threw the error and what the problem was). But if you have `returnErrorAsString: true` set, the evaluator will never throw, but instead return error messages as a valid string output. (See also the [`fallback`](#other-common-properties) parameter below)
160
+ - `returnErrorAsString` -- by default the evaluator will throw errors with invalid evaluation expressions (with helpful error messages indicating the node which threw the error and what the problem was). But if you have `returnErrorAsString: true` set, the evaluator will never throw, but instead return error messages as a valid string output. (See also the [`fallback`](#other-common-properties) parameter below). See [Error handling](#error-handling) section for more detail.
160
161
  - `allowJSONStringInput` -- the evaluator is expecting the input expression to be a javascript object. However, it will also accept JSON strings if this option is set to `true`. We have to perform additional logic on every evaluation input to determine if a string is a JSON expression or a standard string, so this is skipped by default for performance reasons. However, if you want to send (for example) user input directly to the evaluator without running it through your own `JSON.parse()`, then enable this option.
161
162
  - `skipRuntimeTypeCheck` -- we perform comprehensive type checking at runtime to ensure that each operator only performs its operation on valid inputs. If type checking fails, we throw an error detailing the explicit problem. However, if `skipRuntimeTypeCheck` is set to `true`, then all inputs are passed to the operator regardless, and any errors will come from whatever standard javascript errors might be encountered (e.g. trying to pass a primitive value when an array is expected => `.map is not a function`)
162
163
  - `caseInsensitive` -- this only affects the [`equal`/`notEqual` operators](#equal) (see there for more detail).
@@ -226,7 +227,8 @@ Most of the time named properties would be preferable; however there are occasio
226
227
 
227
228
  In each operator node, as well as the operator-specific properties, the following three optional properties can be provided:
228
229
 
229
- - `fallback`: if the operation throws an error, the `fallback` value will be returned instead. The `fallback` property can be provided at any level of the expression tree and bubbled up from where errors are caught to parent nodes. *Fallbacks are strongly recommended if there is any chance of an error (e.g. a network "GET" request that doesn't yet have its parameters defined).*
230
+ - `fallback`: if the operation throws an error, the `fallback` value will be returned instead. The `fallback` property can be provided at any level of the expression tree and bubbled up from where errors are caught to parent nodes. *Fallbacks are strongly recommended if there is any chance of an error (e.g. a network "GET" request that doesn't yet have its parameters defined).*
231
+ See [Error handling](#error-handling)
230
232
  - `outputType` (or `type`): will convert the result of the current node to the specified `outputType`. Valid values are `string`, `number`, `boolean` (or `bool`), and `array`. You can experiment in the [demo app](https://carlosnz.github.io/fig-tree-evaluator/) to see the outcome of applying different `outputType` values to various results.
231
233
  - `useCache`: Overrides the global `useCache` value (from [options](#available-options)) for this node only. See [Caching/Memoization](#caching-memoization) below for more info.
232
234
 
@@ -1070,7 +1072,7 @@ const fig = new FigTreeEvaluator({
1070
1072
 
1071
1073
  ```
1072
1074
 
1073
- See the implementation for `axios` and `node-fetch` [in the repo](https://github.com/CarlosNZ/fig-tree-evaluator/blob/91-exclude-axios-from-package/src/httpClients.ts) for specific details.
1075
+ See the implementation for `axios` and `node-fetch` [in the repo](https://github.com/CarlosNZ/fig-tree-evaluator/blob/main/src/httpClients.ts) for specific details.
1074
1076
 
1075
1077
 
1076
1078
  ### GET
@@ -1262,29 +1264,6 @@ Aliases: `sql`, `pgSql`, `postgres`, `pg`, `sqlLite`, `sqlite`, `mySql`
1262
1264
  - `single` (or `singleRecord`): (boolean) -- by default, results are returned as an array of objects. However, if your query is expected to just return a single record, you can set `single: true` and just the record object will be returned (i.e. not in an array). Note that if the query *does* fetch multiple records, only the first will be returned.
1263
1265
  - `flatten` (or `flat`): (boolean) -- Instead of returning an object, `flatten: true` will just return an array of values. e.g, instead of `{name: "Tom", age: 49}`, it will return `["Tom", 49]`. This would usually be used in conjunction with the `single` property -- if not, it will return an array of flattened arrays.
1264
1266
 
1265
- ##### SQLite
1266
-
1267
-
1268
- ```js
1269
- import sqlite3 from 'sqlite3'
1270
- import { open, Database } from 'sqlite'
1271
- import { FigTreeEvaluator, SQLite } from 'fig-tree-evaluator'
1272
-
1273
- open({
1274
- filename: '/path/to/sqlite.db',
1275
- driver: sqlite3.Database
1276
- }).then((db) => {
1277
- const fig = new FigTreeEvaluator({
1278
- sqlConnection: SQLite(db),
1279
- ...otherOptions
1280
- })
1281
-
1282
- fig.evaluate(...) // Continue app operations
1283
- })
1284
- ```
1285
-
1286
- To create additional abstractions for other database connections, check out `SQLNodePostgres` and `SQLite` [in the repo](https://github.com/CarlosNZ/fig-tree-evaluator/blob/108-generalise-SQL-operator/src/databaseConnections.ts).
1287
-
1288
1267
  #### Examples
1289
1268
 
1290
1269
  The following additional examples query a default installation of the [Northwind](https://github.com/pthom/northwind_psql) demo database.
@@ -1405,7 +1384,7 @@ interface QueryInput {
1405
1384
 
1406
1385
  You then implement in FigTree options the same way as the two described above.
1407
1386
 
1408
- Check out `SQLNodePostgres` and `SQLite` [in the repo](https://github.com/CarlosNZ/fig-tree-evaluator/blob/108-generalise-SQL-operator/src/databaseConnections.ts) for specific details.
1387
+ Check out `SQLNodePostgres` and `SQLite` [in the repo](https://github.com/CarlosNZ/fig-tree-evaluator/blob/main/src/databaseConnections.ts) for specific details.
1409
1388
 
1410
1389
  ----
1411
1390
  ### BUILD_OBJECT
@@ -1863,6 +1842,71 @@ fig.getCache() // returns key-value store
1863
1842
  fig.setCache(cache) // where "cache" is the object retrieved by .getCache()
1864
1843
  ```
1865
1844
 
1845
+ ## Error handling
1846
+
1847
+ By default, FigTree will throw errors that can be caught and handled by your application. The Error object is a `FigTreeError`, which extends the standard `Error` object (with `name` and `message` fields) with the following interface:
1848
+
1849
+ ```ts
1850
+ interface FigTreeError extends Error {
1851
+ errorData?: Record<string, unknown>
1852
+ operator?: Operator
1853
+ expression?: EvaluatorNode
1854
+ }
1855
+ ```
1856
+
1857
+ There are two alternatives to throwing:
1858
+
1859
+ 1. **Fallback**: If the `fallback` property is specified in the expression, this will be returned whenever an error occurs at that node (or below). See [Fallback option](#other-common-properties).
1860
+ 2. **Formatted string**: By using the `returnErrorAsString: true` option, FigTree will return a nicely formatted string describing the error. The formatted string will be structured like so:
1861
+
1862
+ ```
1863
+ Operator: <OPERATOR_NAME>: - <error.name (if specific)>
1864
+ <error.message>
1865
+ {
1866
+ ...errorData
1867
+ }
1868
+ ```
1869
+ `errorData` is specific data returned by the error thrown by an internal process (such as a network request using [fetch](#http-requests)).
1870
+
1871
+ For example, a 403 (forbidden) error thrown by the `GET` operator (with Axios HTTP client) would return a string like:
1872
+ ```
1873
+ Operator: GET - AxiosError
1874
+ Request failed with status code 403
1875
+ {
1876
+ "status": 403,
1877
+ "error": "Forbidden",
1878
+ "url": "http://httpstat.us/403",
1879
+ "response": {
1880
+ "success": false,
1881
+ "message": "jwt must be provided"
1882
+ }
1883
+ }
1884
+ ```
1885
+
1886
+ And, if thrown, the error object would contain:
1887
+ ```js
1888
+ {
1889
+ name: "AxiosError",
1890
+ message: "Request failed with status code 403"
1891
+ operator: "GET",
1892
+ errorData: {
1893
+ status: 403,
1894
+ error: 'Forbidden',
1895
+ url: 'http://httpstat.us/403',
1896
+ response: {
1897
+ success: false,
1898
+ message: "jwt must be provided"
1899
+ }
1900
+ }
1901
+ expression: {
1902
+ operator: 'API',
1903
+ url: 'http://httpstat.us/403',
1904
+ }
1905
+ ...otherProperties // all AxiosError and standard Error properties
1906
+ }
1907
+ ```
1908
+
1909
+ If extending FigTree with additional [HTTP Client](#http-requests) or [SQL Connection](#connecting-to-the-database) interfaces, please aim to adhere to this structure when throwing errors.
1866
1910
 
1867
1911
  ## Metadata
1868
1912
 
@@ -1870,9 +1914,9 @@ Evaluator expressions can be configured by hand, with [aliases](#alias-nodes), [
1870
1914
 
1871
1915
  However, you may wish to build an external UI for building FigTree expression. To this end, the FigTree instance provides three methods that could be useful for populating your configuration UI:
1872
1916
 
1873
- #### New FigTree instance
1917
+ #### A new FigTree instance:
1874
1918
 
1875
- Containing fragments and [custom functions](#custom_functions).
1919
+ - containing fragments and [custom functions](#custom_functions).
1876
1920
 
1877
1921
  ```js
1878
1922
  const fig = new FigTreeEvaluator({
@@ -2012,6 +2056,7 @@ Please open an issue: https://github.com/CarlosNZ/fig-tree-evaluator/issues
2012
2056
 
2013
2057
  *Trivial upgrades (e.g. documentation, small re-factors, types, etc.) not included*
2014
2058
 
2059
+ - **v2.16.0**: Standardise error response (see [Error handling](#error-handling))
2015
2060
  - **v2.15.0**:
2016
2061
  - Remove `axios` package dependency and create HTTP client abstraction (with built-in wrappers for `axios` and `fetch`). *Results in significantly smaller bundle size.*
2017
2062
  - Generalise `PG_SQL` operator to a client-agnostic `SQL` operator (with built-in abstractions for `node-postgres` and `SQLite`)
@@ -1 +1 @@
1
- "use strict";var e=require("change-case"),t=require("object-property-extractor"),r=require("dequal/lite");function a(e,t,r,a){return new(r||(r=Promise))((function(i,s){function n(e){try{l(a.next(e))}catch(e){s(e)}}function o(e){try{l(a.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,o)}l((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=e=>e instanceof Object&&"operator"in e,s=e=>e instanceof Object&&"fragment"in e,n=t=>{const r=e.camelCase(t);return r||t},o=(e,t)=>t[n(e)],l=(e,t,r)=>{const a=Object.assign({},e);return t.forEach((e=>{r[n(e)]||console.warn(`Invalid operator exclusion: ${e}`),delete a[r[n(e)]]})),a},u=(e,t=200)=>e.length<t?e:`${e.slice(0,t-2).trim()}...`,d=(e,t,r=!1)=>{if(void 0!==e)return e;if(r)return u(t);throw new Error(u(t))},c=(e,t)=>{const r=Object.entries(e).map((([e,r])=>[t(e),r]));return Object.fromEntries(r)},p=e=>/^\$.+/.test(e),h=(e,{resolvedAliasNodes:t})=>{var r;return"string"==typeof e&&p(e)&&null!==(r=null==t?void 0:t[e])&&void 0!==r?r:e},v=(e,t)=>{const r=Object.assign(Object.assign({},e),t);return(e.data||t.data)&&(r.data=Object.assign(Object.assign({},e.data),t.data)),(e.functions||t.functions)&&(r.functions=Object.assign(Object.assign({},e.functions),t.functions)),(e.fragments||t.fragments)&&(r.fragments=Object.assign(Object.assign({},e.fragments),t.fragments)),(e.headers||t.headers)&&(r.headers=Object.assign(Object.assign({},e.headers),t.headers)),r},y={number:e=>f(e),string:e=>String(e),array:e=>Array.isArray(e)?e:[e],boolean:e=>Boolean(e),bool:e=>Boolean(e)},m=e=>e.message,f=e=>{if("string"!=typeof e)return Number.isNaN(Number(e))?e:Number(e);const t=new RegExp(/-?\d*\.?\d+/gm),r=e.match(t);return r?Number(r[0]):0},g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b={and:"AND","&":"AND","&&":"AND",or:"OR","|":"OR","||":"OR","=":"EQUAL",eq:"EQUAL",equal:"EQUAL",equals:"EQUAL","!=":"NOT_EQUAL","!":"NOT_EQUAL",ne:"NOT_EQUAL",notEqual:"NOT_EQUAL","+":"PLUS",plus:"PLUS",add:"PLUS",concat:"PLUS",join:"PLUS",merge:"PLUS","-":"SUBTRACT",subtract:"SUBTRACT",minus:"SUBTRACT",takeaway:"SUBTRACT","*":"MULTIPLY",x:"MULTIPLY",multiply:"MULTIPLY",times:"MULTIPLY","/":"DIVIDE",divide:"DIVIDE","÷":"DIVIDE",">":"GREATER_THAN",greaterThan:"GREATER_THAN",higher:"GREATER_THAN",larger:"GREATER_THAN","<":"LESS_THAN",lessThan:"LESS_THAN",lower:"LESS_THAN",smaller:"LESS_THAN","?":"CONDITIONAL",conditional:"CONDITIONAL",ifThen:"CONDITIONAL",regex:"REGEX",patternMatch:"REGEX",regexp:"REGEX",matchPattern:"REGEX",dataProperties:"OBJECT_PROPERTIES",data:"OBJECT_PROPERTIES",getData:"OBJECT_PROPERTIES",objectProperties:"OBJECT_PROPERTIES",objProps:"OBJECT_PROPERTIES",getProperty:"OBJECT_PROPERTIES",getObjProp:"OBJECT_PROPERTIES",stringSubstitution:"STRING_SUBSTITUTION",substitute:"STRING_SUBSTITUTION",stringSub:"STRING_SUBSTITUTION",replace:"STRING_SUBSTITUTION",split:"SPLIT",arraySplit:"SPLIT",count:"COUNT",length:"COUNT",get:"GET",api:"GET",post:"POST",sql:"SQL",pgSql:"SQL",postgres:"SQL",pg:"SQL",sqLite:"SQL",sqlite:"SQL",mySql:"SQL",graphQl:"GRAPHQL",graphql:"GRAPHQL",gql:"GRAPHQL",buildObject:"BUILD_OBJECT",build:"BUILD_OBJECT",object:"BUILD_OBJECT",match:"MATCH",switch:"MATCH",customFunctions:"CUSTOM_FUNCTIONS",customFunction:"CUSTOM_FUNCTIONS",objectFunctions:"CUSTOM_FUNCTIONS",function:"CUSTOM_FUNCTIONS",functions:"CUSTOM_FUNCTIONS",runFunction:"CUSTOM_FUNCTIONS",_:"PASSTHRU",passThru:"PASSTHRU",passthru:"PASSTHRU",pass:"PASSTHRU",ignore:"PASSTHRU",coerce:"PASSTHRU",convert:"PASSTHRU"},T=b,O=/(\$[^()]+)\((.*)\)/,C=(e,t={},r=!0)=>r?"string"==typeof e?q(e,t):g(e)?j(e,t):e:e,q=(e,t)=>{const r=O.exec(e);if(!r)return e;const a=r[1].trim(),i=r[2].split(",").map((e=>C(e.trim(),t)));return S(a,i,t)},j=(e,t)=>{if(i(e)||s(e))return e;const r=Object.entries(e),a=r.filter((([e])=>p(e))),n=r.filter((([e])=>!p(e))),o=a.reduce(((e,[r,a])=>e=Object.assign(Object.assign({},e),S(r,a,t))),{});return Object.assign(Object.assign({},o),Object.fromEntries(n))},S=(e,t,r)=>{const a=e.slice(1),i=o(a,T);return i?Array.isArray(t)?{operator:i,children:t}:g(t)&&!Object.keys(t).some((e=>p(e)))?Object.assign({operator:i},t):{operator:i,children:[t]}:a in r?{fragment:a,parameters:Object.assign({},t)}:{[e]:t}},E=e=>g(e)&&"literal"in e,A=({value:e,name:t,expectedType:r})=>{if(E(r)){const{literal:a}=r;return!!a.includes(e)||x(t,e,`Literal(${a.map((e=>void 0===e?"undefined":`"${e}"`)).join(", ")})`)}if(Array.isArray(r))return!!r.some((r=>!0===A({value:e,name:t,expectedType:r})))||x(t,e,r.join("|"));return!!(0,w[r])(e)||x(t,e,r)},N=(...e)=>{const t=[];return e.forEach((e=>{const r=A(e);!0!==r&&t.push(r)})),!(t.length>0)||t.join("\n")},w={any:e=>void 0!==e,string:e=>"string"==typeof e,number:e=>"number"==typeof e,boolean:e=>"boolean"==typeof e,array:e=>Array.isArray(e),null:e=>null===e,object:e=>g(e),undefined:e=>void 0===e},x=(e,t,r)=>void 0===t&&e?`- Missing required property "${e}" (type: ${r})`:void 0!==e?`- Property "${e}" (value: ${P(t)}) is not of type: ${r}`:`- ${P(t)} is not of type: ${r}`,P=e=>{const t=void 0===e||Number.isNaN(e)?String(e):JSON.stringify(e);return u(t,50)},L=e=>{const t={};return e.forEach((e=>{e.aliases.forEach((r=>t[r]=e.name))})),t},I=(e,t)=>e.map((({name:e,required:r,type:a})=>{if(E(a)){const i=[...a.literal];return r||i.push(void 0),{name:e,value:t[e],expectedType:{literal:i}}}const i=Array.isArray(a)?a:[a];r||i.push("undefined");const s=1===i.length?i[0]:i;return{name:e,value:t[e],expectedType:s}})),U=(e,t)=>{const r=e.map(((e,r)=>[e,t[r]]));return Object.fromEntries(r)},R=e=>{if(e.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const t=e.filter(((e,t)=>t%2==0)),r=N(...t.map((e=>({value:e,expectedType:["string","number","boolean"]}))));if(!0!==r)throw new Error(r);const a=e.filter(((e,t)=>t%2==1)),i={};return t.forEach(((e,t)=>{i[e]=a[t]})),i},k=e=>g(e)&&1===Object.keys(e).length?Object.values(e)[0]:e,D=(e,r,a=void 0)=>{const i=r?t(e,r,a):e;return Array.isArray(i)?i.map((e=>k(e))):r?null===i?null:k(i):i},Q=e=>/^https?:\/\/.+/.test(e),_=(...e)=>e.reduce(((e,t,r)=>{const a="/"===t[0]?1:0,i="/"===t.slice(-1)?-1:void 0,s=t.slice(a,i);return""===s?e:e+(0===r?"":"/")+s}),""),$=(e,t)=>a(void 0,void 0,void 0,(function*(){const{url:r,params:a={},data:i={},headers:s={},method:n="get"}=t;try{return yield e[n]({url:r,headers:Object.assign({"Content-Type":"application/json",Accept:"application/json"},s),params:a,data:i})}catch(t){e.throwError(t)}})),H=(e,t)=>a(void 0,void 0,void 0,(function*(){var r,a,n,l;const{options:u,operators:p,operatorAliases:v}=t;let f=(null==u?void 0:u.allowJSONStringInput)?(e=>{if("string"!=typeof e)return e;try{const t=JSON.parse(e);return i(t)?t:e}catch(t){return e}})(e):e;f=C(f,null===(r=t.options)||void 0===r?void 0:r.fragments,!u.noShorthand),Array.isArray(f)&&(f=yield M(f,t));const b=i(f),T=s(f);if(u.evaluateFullObject&&!b&&!T)return h(yield B(f,t),t);if(!b&&!T)return u.supportDeprecatedValueNodes&&g(f)&&"value"in f?f.value:h(f,t);const{fallback:O}=f,q=null!==(a=null==u?void 0:u.returnErrorAsString)&&void 0!==a&&a;if(T){const[e,r]=yield M([f.fragment,f.parameters],t),a=C(null===(n=null==u?void 0:u.fragments)||void 0===n?void 0:n[e],u.fragments,!u.noShorthand);if(void 0===a)return d(yield H(O,t),`Fragment not defined: ${e}`,q);if(!i(a))return h(a,t);f=Object.assign(Object.assign(Object.assign({},f),a),r),delete f.fragment}try{const e=o(f.operator,v);if(!e)return d(yield H(O,t),`Invalid operator: ${f.operator}`,q);if(!t.operators[e])return d(yield H(O,t),`Excluded operator: ${f.operator}`,q);const{propertyAliases:r,evaluate:a,parseChildren:i}=p[e];f=((e,t)=>c(t,(t=>t in e?e[t]:t)))(r,f);const s=yield F(f,t);T||Object.entries(s).forEach((([e,r])=>t.resolvedAliasNodes[e]=r));const n=T?Object.assign(Object.assign({},t),{resolvedAliasNodes:Object.assign(Object.assign({},t.resolvedAliasNodes),s)}):t;if("children"in f){if(Array.isArray(f.children)||(f.children=yield H(f.children,n)),!Array.isArray(f.children))return d(yield H(O,t),`Operator: ${e}\n- Property "children" is not of type: array`,q);f=yield i(f,n),delete f.children}let u;try{u=yield a(f,n)}catch(r){return d(yield H(f.fallback,t),`Operator: ${e}\n${m(r)}`,q)}const h=null!==(l=null==f?void 0:f.outputType)&&void 0!==l?l:null==f?void 0:f.type;if(!h)return u;const g=yield H(h,t);return g in y?y[g](u):d(yield H(O,t),`Operator: ${e}\n- Invalid output type: ${g}`,q)}catch(e){return d(yield H(O,t),m(e),q)}})),M=(e,t)=>a(void 0,void 0,void 0,(function*(){return Array.isArray(e)?yield Promise.all(e.map((e=>H(e,t)))):yield H(e,t)})),F=(e,t)=>a(void 0,void 0,void 0,(function*(){const r=Object.keys(e).filter(p);if(0===r.length)return{};const a=[];return r.forEach((r=>a.push(H(e[r],t)))),U(r,yield Promise.all(a))})),B=(e,t)=>a(void 0,void 0,void 0,(function*(){if(!g(e))return e;const r=[],a=[];Object.entries(e).forEach((([r,i])=>{p(r)&&(a.push(r,H(i,t)),delete e[r])}));const i=yield Promise.all(a);t.resolvedAliasNodes=Object.assign(Object.assign({},t.resolvedAliasNodes),R(i)),Object.entries(e).forEach((([e,a])=>{r.push(e,H(a,t))}));const s=yield Promise.all(r);return h(R(s),t)})),G=[{name:"values",description:"Returns true if all values are true",aliases:[],required:!0,type:"array",default:[!0,!0]}],z=L(G),W={description:"Logical AND",aliases:["and","&","&&"],parameters:G},J=e=>{const t=e.children;return Object.assign(Object.assign({},e),{values:t})},V={propertyAliases:z,operatorData:W,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(W.parameters,{values:r})),r.reduce(((e,t)=>e&&!!t),!0)})),parseChildren:J},Y=[{name:"values",description:"Returns true if any values are true",aliases:[],required:!0,type:"array",default:[!0,!1]}],X=L(Y),K={description:"Logical OR",aliases:["or","|","||"],parameters:Y},Z={propertyAliases:X,operatorData:K,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(K.parameters,{values:r})),r.reduce(((e,t)=>e||!!t),!1)})),parseChildren:J},ee=[{name:"values",description:"Array of values to check for equality",aliases:[],required:!0,type:"array",default:["These are equal","These are equal"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],te=L(ee),re={description:"Test multiple values are equal",aliases:["=","eq","equal","equals"],parameters:ee},ae={propertyAliases:te,operatorData:re,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield M([e.values,e.caseInsensitive,e.nullEqualsUndefined],t);t.typeChecker(I(re.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=t.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=t.options)||void 0===s?void 0:s.nullEqualsUndefined)&&t.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.every((e=>r.dequal(e,u[0]))):u.every((e=>null==e))})),parseChildren:J},ie=[{name:"values",description:"Array of values to check for inequality",aliases:[],required:!0,type:"array",default:["These items","don't match"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],se=L(ie),ne={description:"Test if any values are different",aliases:["!=","!","ne","notEqual"],parameters:ie},oe={propertyAliases:se,operatorData:ne,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield M([e.values,e.caseInsensitive,e.nullEqualsUndefined],t);t.typeChecker(I(ne.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=t.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=t.options)||void 0===s?void 0:s.nullEqualsUndefined)&&t.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.some((e=>!r.dequal(e,u[0]))):u.some((e=>null===e&&void 0===e))})),parseChildren:J},le=[{name:"values",description:"Array of values to check to add together",aliases:[],required:!0,type:"array",default:[1,2,3]},{name:"type",description:"Data type to coerce input values to before addition",aliases:[],required:!1,type:{literal:["string","array","number","boolean","bool"]},default:"string"}],ue=L(le),de={description:"Add, concatenate or merge multiple values",aliases:["+","plus","add","concat","join","merge"],parameters:le},ce={propertyAliases:ue,operatorData:de,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(de.parameters,{values:r,type:e.type})),0===r.length?r:"string"===(null==e?void 0:e.type)?r.reduce(((e,t)=>e.concat(t)),""):"array"===(null==e?void 0:e.type)?r.reduce(((e,t)=>e.concat(t)),[]):r.every((e=>"string"==typeof e||Array.isArray(e)))?r.reduce(((e,t)=>e.concat(t))):r.every((e=>g(e)))?r.reduce(((e,t)=>Object.assign(Object.assign({},e),t)),{}):r.reduce(((e,t)=>e+t))})),parseChildren:J},pe=[{name:"values",description:"Array of values - 2nd element will be subtracted from the first",aliases:[],required:!1,type:"array",default:[10,5]},{name:"from",description:"Numerical value that will be subtracted from",aliases:["subtractFrom"],required:!1,type:"number",default:100},{name:"subtract",description:"Numerical value to subtract",aliases:[],required:!1,type:"number",default:50}],he=L(pe),ve={description:"Subtract one numerical value from another",aliases:["-","subtract","minus","takeaway"],parameters:pe},ye={propertyAliases:he,operatorData:ve,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a,i]=yield M([e.values,e.from,e.subtract],t);t.typeChecker(I(ve.parameters,{values:r,from:a,subtract:i}));const s=null!=r?r:[a,i].filter((e=>void 0!==e));if(s.length<2)throw new Error("- Not enough values provided");if(s.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return s[0]-s[1]})),parseChildren:J},me=[{name:"values",description:"Array of values whose product will be calculated",aliases:[],required:!0,type:"array",default:[5,5]}],fe=L(me),ge={description:"Multiply several numerical values together",aliases:["*","x","multiply","times"],parameters:me},be={propertyAliases:fe,operatorData:ge,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);if(t.typeChecker(I(ge.parameters,{values:r})),0===r.length)return 0;if(r.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return r.reduce(((e,t)=>e*t))})),parseChildren:J},Te=[{name:"values",description:"Array of values - 1st element will be divided by the first",aliases:[],required:!1,type:"array",default:[100,10]},{name:"dividend",description:"The number that will be divided",aliases:["divide"],required:!1,type:"number",default:99},{name:"divisor",description:"The number that dividend will be divided by",aliases:["by","divideBy"],required:!1,type:"number",default:3},{name:"output",description:"Whether to output a quotient, remainder or decimal",aliases:[],required:!1,type:{literal:["quotient","remainder"]},default:"quotient"}],Oe=L(Te),Ce={description:"Divide one numerical value by another",aliases:["/","divide","÷"],parameters:Te},qe={propertyAliases:Oe,operatorData:Ce,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a,i,s]=yield M([e.values,e.dividend,e.divisor,e.output],t);t.typeChecker(I(Ce.parameters,{values:r,dividend:a,divisor:i,output:s}));const n=null!=r?r:[a,i].filter((e=>void 0!==e));if(n.length<2)throw new Error("- Not enough values provided");if(n.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");if(0===n[1])throw new Error("Division by zero!");switch(s){case"quotient":return Math.floor(n[0]/n[1]);case"remainder":return n[0]%n[1];default:return n[0]/n[1]}})),parseChildren:J},je=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[10,9]},{name:"strict",description:"Whether value must be strictly greater than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Se=L(je),Ee={description:"Test if a value is greater than (or equal to) another value",aliases:[">","greaterThan","higher","larger"],parameters:je},Ae={propertyAliases:Se,operatorData:Ee,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a=!0]=yield M([e.values,e.strict],t);if(t.typeChecker(I(Ee.parameters,{values:r,strict:a})),r.length<2)throw new Error("- Not enough values provided");const[i,s]=r;return i===s&&!a||i>s})),parseChildren:J},Ne=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[9,10]},{name:"strict",description:"Whether value must be strictly smaller than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],we=L(Ne),xe={description:"Test if a value is smaller than (or equal to) another value",aliases:["<","lessThan","lower","smaller"],parameters:Ne},Pe={propertyAliases:we,operatorData:xe,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a=!0]=yield M([e.values,e.strict],t);if(t.typeChecker(I(xe.parameters,{values:r,strict:a})),r.length<2)throw new Error("- Not enough values provided");const[i,s]=r;return i===s&&!a||i<s})),parseChildren:J},Le=[{name:"condition",description:"The expression to check for truthiness",aliases:[],required:!0,type:"any",default:!0},{name:"valueIfTrue",description:"Value to return if condition is true",aliases:["ifTrue"],required:!0,type:"any",default:"The condition is true"},{name:"valueIfFalse",description:"Value to return if condition is false",aliases:["ifFalse","ifNot"],required:!0,type:"any",default:"The condition is false"}],Ie=L(Le),Ue={description:"Return a value based on a condition",aliases:["?","conditional","ifThen"],parameters:Le},Re={propertyAliases:Ie,operatorData:Ue,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){t.typeChecker(I(Ue.parameters,{condition:e.condition,valueIfTrue:e.valueIfTrue,valueIfFalse:e.valueIfFalse}));return(yield H(e.condition,t))?yield H(e.valueIfTrue,t):yield H(e.valueIfFalse,t)})),parseChildren:e=>{const[t,r,a]=e.children;return Object.assign(Object.assign({},e),{condition:t,valueIfTrue:r,valueIfFalse:a})}},ke=[{name:"testString",description:"The string to test",aliases:["string","value"],required:!0,type:"string",default:"test-this"},{name:"pattern",description:"The regular expression pattern",aliases:["regex","regexp","regExp","re"],required:!0,type:"string",default:"^[a-z]{4}-[a-z]{4}$"}],De=L(ke),Qe={description:"Compare a string against a regex pattern",aliases:["regex","patternMatch","regexp","matchPattern"],parameters:ke},_e={propertyAliases:De,operatorData:Qe,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a]=yield M([e.testString,e.pattern],t);t.typeChecker(I(Qe.parameters,{testString:r,pattern:a}));try{return new RegExp(a).test(r)}catch(e){throw new Error("Regex error:"+m(e))}})),parseChildren:e=>{const[t,r]=e.children;return Object.assign(Object.assign({},e),{testString:t,pattern:r})}},$e=[{name:"property",description:'The path to the required property (e.g. "user.firstName")',aliases:["path","propertyName"],required:!0,type:"string",default:"path.to[0].my.data"},{name:"additionalData",description:"Additional data objects to be considered",aliases:["additional","objects","data","additionalObjects"],required:!1,type:"object",default:{}}],He=L($e),Me={description:"Extract values from data objects",aliases:["dataProperties","data","getData","objectProperties","objProps","getProperty","getObjProp"],parameters:$e},Fe={propertyAliases:He,operatorData:Me,evaluate:(e,r)=>a(void 0,void 0,void 0,(function*(){var a,i;const[s,n={}]=yield M([e.property,e.additionalData],r);r.typeChecker(I(Me.parameters,{property:s,additionalData:n}));const o=Object.assign(Object.assign({},null!==(i=null===(a=r.options)||void 0===a?void 0:a.data)&&void 0!==i?i:{}),n);return t(o,s)})),parseChildren:e=>{const[t,r]=e.children,a=Object.assign(Object.assign({},e),{property:t});return void 0!==r&&(a.fallback=r),a}},Be=[{name:"string",description:"A parameterised (%1, %2) string where the parameters are to be replaced",aliases:[],required:!0,type:"string",default:"Hello, %1"},{name:"substitutions",description:"An array of substitution values for the parameterised string",aliases:["replacements","values"],required:!1,type:["array","object"],default:["friend"]},{name:"trimWhiteSpace",description:"Whether or not to trim white space from either end of the substituted strings (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"substitutionCharacter",description:'Which character to search for in original string for replacement -- can be "%" or "$" (default: "%")',aliases:["subCharacter","subChar"],required:!1,type:"string",default:"$"},{name:"numberMapping",description:"Rules for mapping number values to text strings, such as pluralisation.",aliases:["numMap","numberMap","pluralisation","pluralization","plurals"],required:!1,type:"object",default:{}}],Ge=L(Be),ze={description:"Replace values in a string using simple parameter substitution",aliases:["stringSubstitution","substitute","stringSub","replace"],parameters:Be},We={propertyAliases:Ge,operatorData:ze,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a={},i=!0,s="%",n={}]=yield M([e.string,e.substitutions,e.trimWhiteSpace,e.substitutionCharacter,e.numberMapping],t);if(t.typeChecker(I(ze.parameters,{string:r,substitutions:a,trimWhiteSpace:i,substitutionCharacter:s,numberMapping:n})),Array.isArray(a)){const e="$"===s?"$":"%",t=new RegExp(`(?<!\\\\)(${"%"===e?"%":"\\$"}[\\d]+)`,"g"),n=(r.match(t)||[]).sort(((e,t)=>Number(e.slice(1))-Number(t.slice(1)))),o=new Set(n),l=U(Array.from(o),a.map((e=>i?String(e).trim():e)));return r.split(t).map((e=>e in l?l[e]:e)).join("").replace(`\\${e}`,e)}return r.split(/(?<!\\)({{(?:[A-Za-z0-9_.]|\[[0-9]+\])+}})/g).map((e=>{if(!/(?<!\\){{(.+)}}/.exec(e))return e.replace("\\{{","{{");const r=Je(e,a,n,t.options.data);return i?String(r).trim():r})).join("")})),parseChildren:e=>{const[t,...r]=e.children;return Object.assign(Object.assign({},e),{string:t,substitutions:r})}},Je=(e,r,a,i={})=>{const s=e.replace(/{{(.+)}}/,"$1"),n=t(r,s,t(i,s,""));if("number"!=typeof n)return n;if(!(s in a))return n;const o=a[s];if(n in o)return o[n].replace("{}",String(n));const l=Object.keys(a[s]),u=l.find((e=>e.startsWith(">")));if(u){if(n>Number(u.slice(1)))return null==o?void 0:o[u]}const d=l.find((e=>e.startsWith("<")));if(d){if(n<Number(d.slice(1)))return null==o?void 0:o[d]}return o.other?o.other.replace("{}",String(n)):n},Ve=[{name:"values",description:"An array to count",aliases:[],required:!0,type:"array",default:[1,2,3,4,5]}],Ye=L(Ve),Xe={description:"Count elements in an array",aliases:["count","length"],parameters:Ve},Ke={propertyAliases:Ye,operatorData:Xe,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(Xe.parameters,{values:r})),r.length})),parseChildren:e=>{const[t]=e.children;return Object.assign(Object.assign({},e),{values:t})}},Ze=[{name:"value",description:"The string to be split",aliases:["string"],required:!0,type:"string",default:"Alpha, Bravo, Charlie"},{name:"delimiter",description:"The value to split the string on (default is white space)",aliases:["separator"],required:!1,type:"string",default:","},{name:"trimWhiteSpace",description:"Whether to trim white space from around the resulting elements (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"excludeTrailing",description:"If the input string ends in a delimiter, there will be an additional blank element if this value is false (default: true)",aliases:["removeTrailing","excludeTrailingDelimiter"],required:!1,type:"boolean",default:!0}],et=L(Ze),tt={description:"Split a string into an array",aliases:["split","arraySplit"],parameters:Ze},rt=" ",at={propertyAliases:et,operatorData:tt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,a,i;const[s,n,o,l]=yield M([e.value,null!==(r=e.delimiter)&&void 0!==r?r:rt,null===(a=e.trimWhiteSpace)||void 0===a||a,null===(i=e.excludeTrailing)||void 0===i||i],t);t.typeChecker(I(tt.parameters,{value:s,delimiter:n,trimWhiteSpace:o,excludeTrailing:l}));let u=s.split(n);return o&&(u=u.map((e=>e.trim()))),l&&""===u[u.length-1]&&u.pop(),u})),parseChildren:e=>{const[t,r=rt]=e.children;return Object.assign(Object.assign({},e),{value:t,delimiter:r})}},it=[{name:"query",description:"SQL query string, with parameterised replacements (e.g. $1, $2, etc)",aliases:["text"],required:!0,type:"string"},{name:"values",description:"An array/object of values to replace the SQL string parameters, as per SQL connection specifications ",aliases:["replacements"],required:!1,type:["array","object"]},{name:"single",description:"Specify if returning a single record",aliases:["singleRecord"],required:!1,type:"boolean"},{name:"flatten",description:"Specify whether to flatten resulting record objects to arrays of values",aliases:["flat","array"],required:!1,type:"boolean"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean"}],st=L(it),nt={description:"Query an SQL database",aliases:["sql","pgSql","postgres","pg","sqLite","sqlite","mySql"],parameters:it},ot={propertyAliases:st,operatorData:nt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s;const n=null===(r=t.options)||void 0===r?void 0:r.sqlConnection;if(!n)throw new Error("No SQL database connection provided");const[o,l,u,d,c,p]=yield M([e.query,e.values||[],e.single,e.flatten,e.useCache,e.type],t);t.typeChecker(I(nt.parameters,{query:o,single:u,flatten:d,values:l,useCache:c}));const h=null===(s=null!==(i=e.useCache)&&void 0!==i?i:t.options.useCache)||void 0===s||s;{const e=t.cache.useCache(h,((e,t,r,i,s)=>a(void 0,void 0,void 0,(function*(){const a=(yield n.query({query:e,values:t}))||[];["array","string","number"].includes(null!=s?s:"")&&(i=!0);const o=i?a.map((e=>{const t=Object.values(e);return t.length<=1?t[0]:t})):a;return r?o[0]:o}))),o,l,u,d,p);return e}})),parseChildren:e=>{const[t,...r]=e.children;return Object.assign(Object.assign({},e),{query:t,values:r})}},lt=[{name:"query",description:"GraphQL query string",aliases:[],required:!0,type:"string",default:'query getCountries {\n countries(filter: {continent: {eq: "OC"}}) {\n name\n }\n }'},{name:"url",description:"Endpoint for the GraphQL request (if not already provided in options)",aliases:["endpoint"],required:!1,type:["string","null"],default:"https://countries.trevorblades.com/"},{name:"headers",description:"HTTP Headers (if not already provided in options)",aliases:[],required:!1,type:"object",default:{}},{name:"variables",description:"Values for the variables used in query (key-value pairs)",aliases:[],required:!1,type:"object",default:{}},{name:"returnNode",description:"Property path to extract from the query response",aliases:["outputNode","returnProperty"],required:!1,type:"string",default:"data.countries[1].name"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],ut=L(lt),dt={description:"GraphQL request",aliases:["graphQl","graphql","gql"],parameters:lt},ct={propertyAliases:ut,operatorData:dt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s,n,o,l,u;const d=null!==(r=t.graphQLClient)&&void 0!==r?r:t.httpClient;if(!d)throw new Error("No HTTP client provided for GraphQL connection");const[c,p,h,v,y,m]=yield M([e.query,e.url,e.variables,e.returnNode,e.headers,e.useCache],t),{url:f,headers:g}=p instanceof Object?p:{url:p,headers:null};t.typeChecker([...I(dt.parameters,{url:f,query:c,variables:h,returnNode:v,headers:y,useCache:m}),{name:"headers",value:g,expectedType:["object","null"]}]);const b=f&&"graphqlendpoint"!==f.toLowerCase()?f:"",T=null!==(n=null!==(s=null===(i=t.options.graphQLConnection)||void 0===i?void 0:i.endpoint)&&void 0!==s?s:t.options.baseEndpoint)&&void 0!==n?n:"",O=Q(b)?b:_(T,b),C={query:c,variables:h},q=null===(o=null!=m?m:t.options.useCache)||void 0===o||o,j=yield t.cache.useCache(q,((e,t,r,i)=>a(void 0,void 0,void 0,(function*(){const a=yield $(d,{url:e,method:"post",data:t,headers:r});return D(null==a?void 0:a.data,i)}))),O,C,Object.assign(Object.assign(Object.assign(Object.assign({},null===(l=t.options.graphQLConnection)||void 0===l?void 0:l.headers),null===(u=t.options)||void 0===u?void 0:u.headers),g),y),v);return j})),parseChildren:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a="",i,...s]=yield M(e.children,t),n=Array.isArray(i)?i:[i],o=s.slice(0,n.length),l=U(n,o),u=Object.assign(Object.assign({},e),{query:r,url:a,variables:l});return s.length>n.length&&(u.returnNode=s.pop()),u}))},pt=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://restcountries.com/v3.1/name/zealand"},{name:"returnProperty",description:"Property from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"Query parameters (key-value)",aliases:["queryParams","queryParameters","urlQueries"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],ht=L(pt),vt={description:"HTTP GET Request",aliases:["get","api"],parameters:pt},yt=(e,t)=>a(void 0,void 0,void 0,(function*(){const[r="",a,...i]=yield M(e.children,t),s=Array.isArray(a)?a:[a],n=i.slice(0,s.length),o=U(s,n),l=Object.assign(Object.assign({},e),{url:r,parameters:o});return i.length>s.length&&(l.returnProperty=i.pop()),l})),mt=yt,ft={propertyAliases:ht,operatorData:vt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s;const n=t.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield M([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],t),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};t.typeChecker([...I(vt.parameters,{url:p,returnProperty:u,headers:d,parameters:l,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(r=t.options.baseEndpoint)&&void 0!==r?r:"",y=Object.assign(Object.assign(Object.assign({},null===(i=t.options)||void 0===i?void 0:i.headers),h),d),m=null===(s=null!=c?c:t.options.useCache)||void 0===s||s,f=yield t.cache.useCache(m,((e,t,r,i)=>a(void 0,void 0,void 0,(function*(){const a=yield $(n,{url:e,params:t,headers:r});return D(a,i)}))),Q(p)?p:_(v,p),l,y,u);return f})),parseChildren:yt},gt=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://jsonplaceholder.typicode.com/posts"},{name:"returnProperty",description:"Property path from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"JSON Body parameters (key-value)",aliases:["bodyJson","data"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],bt=L(gt),Tt={description:"HTTP POST Request",aliases:["post"],parameters:gt},Ot={propertyAliases:bt,operatorData:Tt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s;const n=t.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield M([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],t),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};t.typeChecker([...I(Tt.parameters,{url:p,headers:d,data:l,returnProperty:u,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(r=t.options.baseEndpoint)&&void 0!==r?r:"",y=Object.assign(Object.assign(Object.assign({},null===(i=t.options)||void 0===i?void 0:i.headers),h),d),m=null!==(s=null!=c?c:t.options.useCache)&&void 0!==s&&s,f=yield t.cache.useCache(m,((e,t,r,i)=>a(void 0,void 0,void 0,(function*(){const a=yield $(n,{url:e,data:t,headers:r,method:"post"});return D(a,i)}))),Q(p)?p:_(v,p),l,y,u);return f})),parseChildren:mt},Ct=[{name:"properties",description:'An array of objects, each with a "key" property and a "value" property',aliases:["values","keyValPairs","keyValuePairs"],required:!0,type:"array",default:["firstKey","firstValue","secondKey","secondValue"]}],qt=L(Ct),jt={description:"Construct an object using objects defining keys and values",aliases:["buildObject","build","object"],parameters:Ct},St={propertyAliases:qt,operatorData:jt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){t.typeChecker(I(jt.parameters,{properties:e.properties}));const r=e.properties.filter((e=>e instanceof Object&&"key"in e&&"value"in e)).map((({key:e,value:r})=>{return i=[e,r],a(void 0,void 0,void 0,(function*(){const[e,r]=yield M(i,t);return t.typeChecker({name:"key",value:e,expectedType:["string","number","boolean"]}),[e,r]}));var i}));return Object.fromEntries(yield Promise.all(r))})),parseChildren:e=>{const t=e.children;if(t.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const r=t.filter(((e,t)=>t%2==0)),a=t.filter(((e,t)=>t%2==1)),i=r.map(((e,t)=>({key:e,value:a[t]})));return Object.assign(Object.assign({},e),{properties:i})}},Et=[{name:"matchExpression",description:"Expression to match against",aliases:["match"],required:!0,type:["string","number","boolean"],default:"matchMe"},{name:"branches",description:"Object whose keys are compared against the match expression. The value of the matching key is returned",aliases:["arms","cases"],required:!1,type:["object","array"],default:{matchMe:"YES",nonMatch:"NO"}},{name:"[...branches]",description:"Branch properties can optionally be placed at the operator root",aliases:[],required:!1,type:["object","array"]}],At={propertyAliases:L(Et),operatorData:{description:"Return different values depending on a matching expression",aliases:["match","switch"],parameters:Et},evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r;const a=yield H(e.matchExpression,t);t.typeChecker({name:"matchExpression",value:a,expectedType:["string","number","boolean"]});const s=Array.isArray(e.branches)?R(e.branches):null!==(r=e.branches)&&void 0!==r?r:{},n=i(s)?yield H(s,t):s;if(!g(n))throw new Error("Branches don't evaluate to an object");if(a in n)return yield H(n[a],t);if("fallback"in n)return yield H(n.fallback,t);if(a in e)return yield H(e[a],t);throw new Error(`No match found for ${a}`)})),parseChildren:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,...a]=e.children,i=R(yield M(a,t));return Object.assign(Object.assign({},e),{matchExpression:r,branches:i})}))},Nt=[{name:"functionPath",description:"Path (in options.functions) to the required function",aliases:["functionsPath","functionName","funcName","path","name"],required:!0,type:"string",default:null},{name:"args",description:"Arguments for the function",aliases:["arguments","variables"],required:!1,type:"array",default:[]},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!1}],wt=L(Nt),xt={description:"Call a custom function (defined in options)",aliases:["customFunctions","customFunction","objectFunctions","function","functions","runFunction"],parameters:Nt},Pt={propertyAliases:wt,operatorData:xt,evaluate:(e,r)=>a(void 0,void 0,void 0,(function*(){var i,s,n;const[o,l=[],u]=yield M([e.functionPath,e.args,e.useCache],r);r.typeChecker(I(xt.parameters,{functionPath:o,args:l}));const{data:d,functions:c}=r.options,p=null!==(s=null!==(i=t(c,o,null))&&void 0!==i?i:t(d,o,null))&&void 0!==s?s:t(r.options,o,null);if(!p||"function"!=typeof p)throw new Error(`- No function found: "${o}"`);const h=null!==(n=null!=u?u:r.options.useCache)&&void 0!==n&&n;return yield r.cache.useCache(h,((e,...t)=>a(void 0,void 0,void 0,(function*(){return yield p(...t)}))),o,...l)})),parseChildren:e=>{const[t,...r]=e.children;return Object.assign(Object.assign({},e),{functionPath:t,args:r})}},Lt=[{name:"value",description:"Value to pass through",aliases:["_","data"],required:!0,type:"any",default:null}],It=L(Lt),Ut={description:"Pass through a value unchanged (or change its type)",aliases:["_","passThru","passthru","pass","ignore","coerce","convert"],parameters:Lt},Rt={propertyAliases:It,operatorData:Ut,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){return t.typeChecker(I(Ut.parameters,{value:e.value})),yield H(e.value,t)})),parseChildren:e=>{const[...t]=e.children,r=1===(null==t?void 0:t.length)?t[0]:t;return Object.assign(Object.assign({},e),{value:r})}};var kt=Object.freeze({__proto__:null,AND:V,BUILD_OBJECT:St,CONDITIONAL:Re,COUNT:Ke,CUSTOM_FUNCTIONS:Pt,DIVIDE:qe,EQUAL:ae,GET:ft,GRAPHQL:ct,GREATER_THAN:Ae,LESS_THAN:Pe,MATCH:At,MULTIPLY:be,NOT_EQUAL:oe,OBJECT_PROPERTIES:Fe,OR:Z,PASSTHRU:Rt,PLUS:ce,POST:Ot,REGEX:_e,SPLIT:at,SQL:ot,STRING_SUBSTITUTION:We,SUBTRACT:ye});class Dt{constructor(e){var t,r;this.useCache=(e,t,...r)=>a(this,void 0,void 0,(function*(){if(!e)return yield t(...r);const a=Qt(r),i=a in this.store,s=Date.now(),n=i&&s-this.store[a].timestamp>1e3*this.maxTime;if(i)return this.queue=this.queue.filter((e=>e!==a)),this.queue.unshift(a),this.store[a].timestamp=s,n&&(this.store[a].result=yield t(...r)),this.store[a].result;const o=yield t(...r);return this.store[a]={result:o,timestamp:s},this.queue.unshift(a),this.resizeCache(),o})),this.getMax=()=>this.maxSize,this.setMax=e=>{this.maxSize=e,this.resizeCache()},this.getMaxTime=()=>this.maxTime,this.setMaxTime=e=>{this.maxTime=e},this.getCache=()=>this.store,this.setCache=e=>this.store=e,this.resizeCache=()=>{if(this.queue.length>this.maxSize){this.queue.slice(this.maxSize).forEach((e=>delete this.store[e])),this.queue=this.queue.slice(0,this.maxSize)}},this.store={},this.queue=[],this.maxSize=null!==(t=null==e?void 0:e.maxSize)&&void 0!==t?t:50,this.maxTime=null!==(r=null==e?void 0:e.maxTime)&&void 0!==r?r:1800}}const Qt=e=>e.map((e=>"object"==typeof e?JSON.stringify(e):e)).join("_"),_t=e=>e?"name"in e&&"fetch"===e.name?Ht(e):"Axios"in e&&"Axios"===e.Axios.name?$t(e):e:"undefined"!=typeof window&&"document"in window&&"fetch"in window?Ht(window.fetch):void 0,$t=e=>({get:t=>a(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},t),{method:"get"}))).data})),post:t=>a(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},t),{method:"post"}))).data})),throwError:t=>{var r;if(e.isAxiosError(t)){if(!(null==t?void 0:t.response))throw new Error("Network Error");console.log(null===(r=t.response)||void 0===r?void 0:r.data)}throw t}}),Ht=e=>({get:t=>a(void 0,void 0,void 0,(function*(){const{url:r,headers:a,params:i}=t,s=new URLSearchParams(i),n=s.size>0?`?${s.toString()}`:"",o=yield e(r+n,{headers:a,method:"GET"}),l=yield o.json();if(!o.ok)throw console.log(l),new Error(`Request failed with status code ${o.status}`);return l})),post:t=>a(void 0,void 0,void 0,(function*(){const{url:r,headers:a,params:i,data:s}=t,n=new URLSearchParams(i),o=n.size>0?`?${n.toString()}`:"",l=yield e(r+o,{headers:a,body:JSON.stringify(s),method:"POST"}),u=yield l.json();if(!l.ok)throw console.log(u),new Error(`Request failed with status code ${l.status}`);return u})),throwError:e=>{throw new Error(`${m(e)}`)}});class Mt{constructor(e={}){var t,r,a;this.typeChecker=(...e)=>{const t=1===e.length&&Array.isArray(e[0])?e[0]:e,r=N(...t);if(!0!==r)throw new Error(r)},this.getCache=()=>this.cache.getCache(),this.setCache=e=>this.cache.setCache(e),this.getVersion=()=>"2.15.0",this.options=Ft(e),this.operators=l(kt,null!==(r=null===(t=this.options)||void 0===t?void 0:t.excludeOperators)&&void 0!==r?r:[],b),this.operatorAliases=b,this.cache=new Dt({maxSize:e.maxCacheSize,maxTime:e.maxCacheTime}),this.graphQLClient=_t(null===(a=e.graphQLConnection)||void 0===a?void 0:a.httpClient),this.httpClient=_t(e.httpClient)}evaluate(e,t={}){var r;return a(this,void 0,void 0,(function*(){const a=v(this.options,Ft(t));return t.httpClient&&(this.httpClient=_t(t.httpClient)),(null===(r=t.graphQLConnection)||void 0===r?void 0:r.httpClient)&&(this.graphQLClient=_t(t.graphQLConnection.httpClient)),a.maxCacheSize&&a.maxCacheSize!==this.cache.getMax()&&this.cache.setMax(a.maxCacheSize),a.maxCacheTime&&a.maxCacheTime!==this.cache.getMaxTime()&&this.cache.setMaxTime(a.maxCacheTime),yield H(e,{options:a,operators:t.excludeOperators?l(kt,t.excludeOperators,b):this.operators,operatorAliases:this.operatorAliases,typeChecker:a.skipRuntimeTypeCheck?()=>{}:this.typeChecker,resolvedAliasNodes:{},cache:this.cache,graphQLClient:this.graphQLClient,httpClient:this.httpClient})}))}getOptions(){return this.options}updateOptions(e){this.options=v(this.options,Ft(e)),this.options.excludeOperators&&(this.operators=l(kt,this.options.excludeOperators,b))}getOperators(){const e=this.options.excludeOperators?l(kt,this.options.excludeOperators,b):this.operators,t=Object.entries(e).map((([e,t])=>Object.assign({name:e},t.operatorData))),r=[...new Set(Object.values(b))];return t.sort(((e,t)=>r.indexOf(e.name)-r.indexOf(t.name)))}getFragments(){var e;return Object.entries(null!==(e=this.options.fragments)&&void 0!==e?e:{}).map((([e,t])=>Object.assign({name:e},null==t?void 0:t.metadata)))}getCustomFunctions(){var e;return Object.entries(null!==(e=this.options.functions)&&void 0!==e?e:{}).map((([e,t])=>({name:e,numRequiredArgs:t.length})))}}const Ft=e=>"objects"in e?Object.assign(Object.assign({},e),{data:e.objects}):e;exports.AxiosClient=$t,exports.FetchClient=Ht,exports.FigTreeEvaluator=Mt,exports.SQLNodePostgres=e=>({query:({query:t,values:r=[]})=>a(void 0,void 0,void 0,(function*(){const a={text:t,values:null!=r?r:[]},i=yield e.query(a);if(null==i?void 0:i.error)throw new Error(i.error);return i.rows}))}),exports.SQLite=e=>({query:({query:t,values:r=[]})=>a(void 0,void 0,void 0,(function*(){try{return yield e.all(t,r)}catch(e){throw`SQLite error: ${null==e?void 0:e.message}`}}))}),exports.evaluateExpression=(e,t)=>new Mt(t).evaluate(e),exports.isAliasString=p,exports.isFragmentNode=s,exports.isObject=g,exports.isOperatorNode=i,exports.preProcessShorthand=C,exports.standardiseOperatorName=n,exports.truncateString=u;
1
+ "use strict";var e=require("change-case"),r=require("object-property-extractor"),t=require("dequal/lite"),a=require("querystring");function i(e,r,t,a){return new(t||(t=Promise))((function(i,s){function n(e){try{l(a.next(e))}catch(e){s(e)}}function o(e){try{l(a.throw(e))}catch(e){s(e)}}function l(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(n,o)}l((a=a.apply(e,r||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s=e=>e instanceof Object&&"operator"in e,n=e=>e instanceof Object&&"fragment"in e,o=r=>{const t=e.camelCase(r);return t||r},l=(e,r)=>r[o(e)],u=(e,r,t)=>{const a=Object.assign({},e);return r.forEach((e=>{t[o(e)]||console.warn(`Invalid operator exclusion: ${e}`),delete a[t[o(e)]]})),a},d=(e,r=200)=>e.length<r?e:`${e.slice(0,r-2).trim()}...`,c=({fallback:e,operator:r,name:t,error:a,expression:i,returnErrorAsString:s=!1})=>{var n,o;if(void 0!==e)return e;const l="string"==typeof a?new Error(a):a;if(t&&(l.name=t),"Error"===l.name&&(l.name="FigTreeError"),l.expression=null!==(n=l.expression)&&void 0!==n?n:i,l.operator=null!==(o=l.operator)&&void 0!==o?o:r,!s)throw l;const u=(r?"Operator: "+r:"")+("FigTreeError"===l.name?"":` - ${l.name}`),c=l.errorData?"\n"+JSON.stringify(l.errorData,null,2):"";return`${""!==u?u+"\n":""}${d(l.message)}${"\n{}"===c?"":c}`},p=(e,r)=>{const t=Object.entries(e).map((([e,t])=>[r(e),t]));return Object.fromEntries(t)},h=e=>/^\$.+/.test(e),v=(e,{resolvedAliasNodes:r})=>{var t;return"string"==typeof e&&h(e)&&null!==(t=null==r?void 0:r[e])&&void 0!==t?t:e},y=(e,r)=>{const t=Object.assign(Object.assign({},e),r);return(e.data||r.data)&&(t.data=Object.assign(Object.assign({},e.data),r.data)),(e.functions||r.functions)&&(t.functions=Object.assign(Object.assign({},e.functions),r.functions)),(e.fragments||r.fragments)&&(t.fragments=Object.assign(Object.assign({},e.fragments),r.fragments)),(e.headers||r.headers)&&(t.headers=Object.assign(Object.assign({},e.headers),r.headers)),t},m={number:e=>f(e),string:e=>String(e),array:e=>Array.isArray(e)?e:[e],boolean:e=>Boolean(e),bool:e=>Boolean(e)},f=e=>{if("string"!=typeof e)return Number.isNaN(Number(e))?e:Number(e);const r=new RegExp(/-?\d*\.?\d+/gm),t=e.match(r);return t?Number(t[0]):0},g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b={and:"AND","&":"AND","&&":"AND",or:"OR","|":"OR","||":"OR","=":"EQUAL",eq:"EQUAL",equal:"EQUAL",equals:"EQUAL","!=":"NOT_EQUAL","!":"NOT_EQUAL",ne:"NOT_EQUAL",notEqual:"NOT_EQUAL","+":"PLUS",plus:"PLUS",add:"PLUS",concat:"PLUS",join:"PLUS",merge:"PLUS","-":"SUBTRACT",subtract:"SUBTRACT",minus:"SUBTRACT",takeaway:"SUBTRACT","*":"MULTIPLY",x:"MULTIPLY",multiply:"MULTIPLY",times:"MULTIPLY","/":"DIVIDE",divide:"DIVIDE","÷":"DIVIDE",">":"GREATER_THAN",greaterThan:"GREATER_THAN",higher:"GREATER_THAN",larger:"GREATER_THAN","<":"LESS_THAN",lessThan:"LESS_THAN",lower:"LESS_THAN",smaller:"LESS_THAN","?":"CONDITIONAL",conditional:"CONDITIONAL",ifThen:"CONDITIONAL",regex:"REGEX",patternMatch:"REGEX",regexp:"REGEX",matchPattern:"REGEX",dataProperties:"OBJECT_PROPERTIES",data:"OBJECT_PROPERTIES",getData:"OBJECT_PROPERTIES",objectProperties:"OBJECT_PROPERTIES",objProps:"OBJECT_PROPERTIES",getProperty:"OBJECT_PROPERTIES",getObjProp:"OBJECT_PROPERTIES",stringSubstitution:"STRING_SUBSTITUTION",substitute:"STRING_SUBSTITUTION",stringSub:"STRING_SUBSTITUTION",replace:"STRING_SUBSTITUTION",split:"SPLIT",arraySplit:"SPLIT",count:"COUNT",length:"COUNT",get:"GET",api:"GET",post:"POST",sql:"SQL",pgSql:"SQL",postgres:"SQL",pg:"SQL",sqLite:"SQL",sqlite:"SQL",mySql:"SQL",graphQl:"GRAPHQL",graphql:"GRAPHQL",gql:"GRAPHQL",buildObject:"BUILD_OBJECT",build:"BUILD_OBJECT",object:"BUILD_OBJECT",match:"MATCH",switch:"MATCH",customFunctions:"CUSTOM_FUNCTIONS",customFunction:"CUSTOM_FUNCTIONS",objectFunctions:"CUSTOM_FUNCTIONS",function:"CUSTOM_FUNCTIONS",functions:"CUSTOM_FUNCTIONS",runFunction:"CUSTOM_FUNCTIONS",_:"PASSTHRU",passThru:"PASSTHRU",passthru:"PASSTHRU",pass:"PASSTHRU",ignore:"PASSTHRU",coerce:"PASSTHRU",convert:"PASSTHRU"},T=b,O=/(\$[^()]+)\((.*)\)/,C=(e,r={},t=!0)=>t?"string"==typeof e?q(e,r):g(e)?S(e,r):e:e,q=(e,r)=>{const t=O.exec(e);if(!t)return e;const a=t[1].trim(),i=t[2].split(",").map((e=>C(e.trim(),r)));return E(a,i,r)},S=(e,r)=>{if(s(e)||n(e))return e;const t=Object.entries(e),a=t.filter((([e])=>h(e))),i=t.filter((([e])=>!h(e))),o=a.reduce(((e,[t,a])=>e=Object.assign(Object.assign({},e),E(t,a,r))),{});return Object.assign(Object.assign({},o),Object.fromEntries(i))},E=(e,r,t)=>{const a=e.slice(1),i=l(a,T);return i?Array.isArray(r)?{operator:i,children:r}:g(r)&&!Object.keys(r).some((e=>h(e)))?Object.assign({operator:i},r):{operator:i,children:[r]}:a in t?{fragment:a,parameters:Object.assign({},r)}:{[e]:r}},j=e=>g(e)&&"literal"in e,A=({value:e,name:r,expectedType:t})=>{if(j(t)){const{literal:a}=t;return!!a.includes(e)||w(r,e,`Literal(${a.map((e=>void 0===e?"undefined":`"${e}"`)).join(", ")})`)}if(Array.isArray(t))return!!t.some((t=>!0===A({value:e,name:r,expectedType:t})))||w(r,e,t.join("|"));return!!(0,N[t])(e)||w(r,e,t)},x=(...e)=>{const r=[];return e.forEach((e=>{const t=A(e);!0!==t&&r.push(t)})),!(r.length>0)||r.join("\n")},N={any:e=>void 0!==e,string:e=>"string"==typeof e,number:e=>"number"==typeof e,boolean:e=>"boolean"==typeof e,array:e=>Array.isArray(e),null:e=>null===e,object:e=>g(e),undefined:e=>void 0===e},w=(e,r,t)=>void 0===r&&e?`- Missing required property "${e}" (type: ${t})`:void 0!==e?`- Property "${e}" (value: ${P(r)}) is not of type: ${t}`:`- ${P(r)} is not of type: ${t}`,P=e=>{const r=void 0===e||Number.isNaN(e)?String(e):JSON.stringify(e);return d(r,50)},L=e=>{const r={};return e.forEach((e=>{e.aliases.forEach((t=>r[t]=e.name))})),r},I=(e,r)=>e.map((({name:e,required:t,type:a})=>{if(j(a)){const i=[...a.literal];return t||i.push(void 0),{name:e,value:r[e],expectedType:{literal:i}}}const i=Array.isArray(a)?a:[a];t||i.push("undefined");const s=1===i.length?i[0]:i;return{name:e,value:r[e],expectedType:s}})),U=(e,r)=>{const t=e.map(((e,t)=>[e,r[t]]));return Object.fromEntries(t)},k=e=>{if(e.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const r=e.filter(((e,r)=>r%2==0)),t=x(...r.map((e=>({value:e,expectedType:["string","number","boolean"]}))));if(!0!==t)throw new Error(t);const a=e.filter(((e,r)=>r%2==1)),i={};return r.forEach(((e,r)=>{i[e]=a[r]})),i},R=e=>g(e)&&1===Object.keys(e).length?Object.values(e)[0]:e,D=(e,t,a=void 0)=>{const i=t?r(e,t,a):e;return Array.isArray(i)?i.map((e=>R(e))):t?null===i?null:R(i):i},Q=e=>/^https?:\/\/.+/.test(e),_=(...e)=>e.reduce(((e,r,t)=>{const a="/"===r[0]?1:0,i="/"===r.slice(-1)?-1:void 0,s=r.slice(a,i);return""===s?e:e+(0===t?"":"/")+s}),""),F=(e,r)=>i(void 0,void 0,void 0,(function*(){const{url:t,params:a={},data:i={},headers:s={},method:n="get"}=r;if(!t||""===t)throw new Error("Invalid url");try{return yield e[n]({url:t,headers:Object.assign({"Content-Type":"application/json",Accept:"application/json"},s),params:a,data:i})}catch(r){e.throwError(r)}})),H=(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,i,o;const{options:u,operators:d,operatorAliases:h}=r;let y=(null==u?void 0:u.allowJSONStringInput)?(e=>{if("string"!=typeof e)return e;try{const r=JSON.parse(e);return s(r)?r:e}catch(r){return e}})(e):e;y=C(y,null===(t=r.options)||void 0===t?void 0:t.fragments,!u.noShorthand),Array.isArray(y)&&(y=yield M(y,r));const f=s(y),b=n(y);if(u.evaluateFullObject&&!f&&!b)return v(yield B(y,r),r);if(!f&&!b)return u.supportDeprecatedValueNodes&&g(y)&&"value"in y?y.value:v(y,r);const{fallback:T}=y,O=null!==(a=null==u?void 0:u.returnErrorAsString)&&void 0!==a&&a;if(b){const[e,t]=yield M([y.fragment,y.parameters],r),a=C(null===(i=null==u?void 0:u.fragments)||void 0===i?void 0:i[e],u.fragments,!u.noShorthand);if(void 0===a)return c({fallback:yield H(T,r),error:`Fragment not defined: ${e}`,expression:y,returnErrorAsString:O});if(!s(a))return v(a,r);y=Object.assign(Object.assign(Object.assign({},y),a),t),delete y.fragment}try{const e=l(y.operator,h);if(!e)return c({fallback:yield H(T,r),error:`Invalid operator: ${y.operator}`,expression:y,returnErrorAsString:O});if(!r.operators[e])return c({fallback:yield H(T,r),error:`Excluded operator: ${y.operator}`,expression:y,returnErrorAsString:O});const{propertyAliases:t,evaluate:a,parseChildren:i}=d[e];y=((e,r)=>p(r,(r=>r in e?e[r]:r)))(t,y);const s=yield $(y,r);b||Object.entries(s).forEach((([e,t])=>r.resolvedAliasNodes[e]=t));const n=b?Object.assign(Object.assign({},r),{resolvedAliasNodes:Object.assign(Object.assign({},r.resolvedAliasNodes),s)}):r;if("children"in y){if(Array.isArray(y.children)||(y.children=yield H(y.children,n)),!Array.isArray(y.children))return c({fallback:yield H(T,r),operator:e,name:"Type Error",error:'- Property "children" is not of type: array',expression:y,returnErrorAsString:O});y=yield i(y,n),delete y.children}let u;try{u=yield a(y,n)}catch(t){return c({fallback:yield H(y.fallback,r),operator:e,error:t,expression:y,returnErrorAsString:O})}const v=null!==(o=null==y?void 0:y.outputType)&&void 0!==o?o:null==y?void 0:y.type;if(!v)return u;const f=yield H(v,r);return f in m?m[f](u):c({fallback:yield H(T,r),operator:e,error:`- Invalid output type: ${f}`,expression:y,returnErrorAsString:O})}catch(e){return c({fallback:yield H(T,r),error:e,expression:y,returnErrorAsString:O})}})),M=(e,r)=>i(void 0,void 0,void 0,(function*(){return Array.isArray(e)?yield Promise.all(e.map((e=>H(e,r)))):yield H(e,r)})),$=(e,r)=>i(void 0,void 0,void 0,(function*(){const t=Object.keys(e).filter(h);if(0===t.length)return{};const a=[];return t.forEach((t=>a.push(H(e[t],r)))),U(t,yield Promise.all(a))})),B=(e,r)=>i(void 0,void 0,void 0,(function*(){if(!g(e))return e;const t=[],a=[];Object.entries(e).forEach((([t,i])=>{h(t)&&(a.push(t,H(i,r)),delete e[t])}));const i=yield Promise.all(a);r.resolvedAliasNodes=Object.assign(Object.assign({},r.resolvedAliasNodes),k(i)),Object.entries(e).forEach((([e,a])=>{t.push(e,H(a,r))}));const s=yield Promise.all(t);return v(k(s),r)})),G=[{name:"values",description:"Returns true if all values are true",aliases:[],required:!0,type:"array",default:[!0,!0]}],z=L(G),W={description:"Logical AND",aliases:["and","&","&&"],parameters:G},J=e=>{const r=e.children;return Object.assign(Object.assign({},e),{values:r})},V={propertyAliases:z,operatorData:W,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield M(e.values,r);return r.typeChecker(I(W.parameters,{values:t})),t.reduce(((e,r)=>e&&!!r),!0)})),parseChildren:J},Y=[{name:"values",description:"Returns true if any values are true",aliases:[],required:!0,type:"array",default:[!0,!1]}],X=L(Y),K={description:"Logical OR",aliases:["or","|","||"],parameters:Y},Z={propertyAliases:X,operatorData:K,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield M(e.values,r);return r.typeChecker(I(K.parameters,{values:t})),t.reduce(((e,r)=>e||!!r),!1)})),parseChildren:J},ee=[{name:"values",description:"Array of values to check for equality",aliases:[],required:!0,type:"array",default:["These are equal","These are equal"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],re=L(ee),te={description:"Test multiple values are equal",aliases:["=","eq","equal","equals"],parameters:ee},ae={propertyAliases:re,operatorData:te,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield M([e.values,e.caseInsensitive,e.nullEqualsUndefined],r);r.typeChecker(I(te.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=r.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=r.options)||void 0===s?void 0:s.nullEqualsUndefined)&&r.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.every((e=>t.dequal(e,u[0]))):u.every((e=>null==e))})),parseChildren:J},ie=[{name:"values",description:"Array of values to check for inequality",aliases:[],required:!0,type:"array",default:["These items","don't match"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],se=L(ie),ne={description:"Test if any values are different",aliases:["!=","!","ne","notEqual"],parameters:ie},oe={propertyAliases:se,operatorData:ne,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield M([e.values,e.caseInsensitive,e.nullEqualsUndefined],r);r.typeChecker(I(ne.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=r.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=r.options)||void 0===s?void 0:s.nullEqualsUndefined)&&r.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.some((e=>!t.dequal(e,u[0]))):u.some((e=>null===e&&void 0===e))})),parseChildren:J},le=[{name:"values",description:"Array of values to check to add together",aliases:[],required:!0,type:"array",default:[1,2,3]},{name:"type",description:"Data type to coerce input values to before addition",aliases:[],required:!1,type:{literal:["string","array","number","boolean","bool"]},default:"string"}],ue=L(le),de={description:"Add, concatenate or merge multiple values",aliases:["+","plus","add","concat","join","merge"],parameters:le},ce={propertyAliases:ue,operatorData:de,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield M(e.values,r);return r.typeChecker(I(de.parameters,{values:t,type:e.type})),0===t.length?t:"string"===(null==e?void 0:e.type)?t.reduce(((e,r)=>e.concat(r)),""):"array"===(null==e?void 0:e.type)?t.reduce(((e,r)=>e.concat(r)),[]):t.every((e=>"string"==typeof e||Array.isArray(e)))?t.reduce(((e,r)=>e.concat(r))):t.every((e=>g(e)))?t.reduce(((e,r)=>Object.assign(Object.assign({},e),r)),{}):t.reduce(((e,r)=>e+r))})),parseChildren:J},pe=[{name:"values",description:"Array of values - 2nd element will be subtracted from the first",aliases:[],required:!1,type:"array",default:[10,5]},{name:"from",description:"Numerical value that will be subtracted from",aliases:["subtractFrom"],required:!1,type:"number",default:100},{name:"subtract",description:"Numerical value to subtract",aliases:[],required:!1,type:"number",default:50}],he=L(pe),ve={description:"Subtract one numerical value from another",aliases:["-","subtract","minus","takeaway"],parameters:pe},ye={propertyAliases:he,operatorData:ve,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a,i]=yield M([e.values,e.from,e.subtract],r);r.typeChecker(I(ve.parameters,{values:t,from:a,subtract:i}));const s=null!=t?t:[a,i].filter((e=>void 0!==e));if(s.length<2)throw new Error("- Not enough values provided");if(s.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return s[0]-s[1]})),parseChildren:J},me=[{name:"values",description:"Array of values whose product will be calculated",aliases:[],required:!0,type:"array",default:[5,5]}],fe=L(me),ge={description:"Multiply several numerical values together",aliases:["*","x","multiply","times"],parameters:me},be={propertyAliases:fe,operatorData:ge,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield M(e.values,r);if(r.typeChecker(I(ge.parameters,{values:t})),0===t.length)return 0;if(t.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return t.reduce(((e,r)=>e*r))})),parseChildren:J},Te=[{name:"values",description:"Array of values - 1st element will be divided by the first",aliases:[],required:!1,type:"array",default:[100,10]},{name:"dividend",description:"The number that will be divided",aliases:["divide"],required:!1,type:"number",default:99},{name:"divisor",description:"The number that dividend will be divided by",aliases:["by","divideBy"],required:!1,type:"number",default:3},{name:"output",description:"Whether to output a quotient, remainder or decimal",aliases:[],required:!1,type:{literal:["quotient","remainder"]},default:"quotient"}],Oe=L(Te),Ce={description:"Divide one numerical value by another",aliases:["/","divide","÷"],parameters:Te},qe={propertyAliases:Oe,operatorData:Ce,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a,i,s]=yield M([e.values,e.dividend,e.divisor,e.output],r);r.typeChecker(I(Ce.parameters,{values:t,dividend:a,divisor:i,output:s}));const n=null!=t?t:[a,i].filter((e=>void 0!==e));if(n.length<2)throw new Error("- Not enough values provided");if(n.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");if(0===n[1])throw new Error("Division by zero!");switch(s){case"quotient":return Math.floor(n[0]/n[1]);case"remainder":return n[0]%n[1];default:return n[0]/n[1]}})),parseChildren:J},Se=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[10,9]},{name:"strict",description:"Whether value must be strictly greater than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Ee=L(Se),je={description:"Test if a value is greater than (or equal to) another value",aliases:[">","greaterThan","higher","larger"],parameters:Se},Ae={propertyAliases:Ee,operatorData:je,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a=!0]=yield M([e.values,e.strict],r);if(r.typeChecker(I(je.parameters,{values:t,strict:a})),t.length<2)throw new Error("- Not enough values provided");const[i,s]=t;return i===s&&!a||i>s})),parseChildren:J},xe=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[9,10]},{name:"strict",description:"Whether value must be strictly smaller than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Ne=L(xe),we={description:"Test if a value is smaller than (or equal to) another value",aliases:["<","lessThan","lower","smaller"],parameters:xe},Pe={propertyAliases:Ne,operatorData:we,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a=!0]=yield M([e.values,e.strict],r);if(r.typeChecker(I(we.parameters,{values:t,strict:a})),t.length<2)throw new Error("- Not enough values provided");const[i,s]=t;return i===s&&!a||i<s})),parseChildren:J},Le=[{name:"condition",description:"The expression to check for truthiness",aliases:[],required:!0,type:"any",default:!0},{name:"valueIfTrue",description:"Value to return if condition is true",aliases:["ifTrue"],required:!0,type:"any",default:"The condition is true"},{name:"valueIfFalse",description:"Value to return if condition is false",aliases:["ifFalse","ifNot"],required:!0,type:"any",default:"The condition is false"}],Ie=L(Le),Ue={description:"Return a value based on a condition",aliases:["?","conditional","ifThen"],parameters:Le},ke={propertyAliases:Ie,operatorData:Ue,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){r.typeChecker(I(Ue.parameters,{condition:e.condition,valueIfTrue:e.valueIfTrue,valueIfFalse:e.valueIfFalse}));return(yield H(e.condition,r))?yield H(e.valueIfTrue,r):yield H(e.valueIfFalse,r)})),parseChildren:e=>{const[r,t,a]=e.children;return Object.assign(Object.assign({},e),{condition:r,valueIfTrue:t,valueIfFalse:a})}},Re=[{name:"testString",description:"The string to test",aliases:["string","value"],required:!0,type:"string",default:"test-this"},{name:"pattern",description:"The regular expression pattern",aliases:["regex","regexp","regExp","re"],required:!0,type:"string",default:"^[a-z]{4}-[a-z]{4}$"}],De=L(Re),Qe={description:"Compare a string against a regex pattern",aliases:["regex","patternMatch","regexp","matchPattern"],parameters:Re},_e={propertyAliases:De,operatorData:Qe,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a]=yield M([e.testString,e.pattern],r);r.typeChecker(I(Qe.parameters,{testString:t,pattern:a}));return new RegExp(a).test(t)})),parseChildren:e=>{const[r,t]=e.children;return Object.assign(Object.assign({},e),{testString:r,pattern:t})}},Fe=[{name:"property",description:'The path to the required property (e.g. "user.firstName")',aliases:["path","propertyName"],required:!0,type:"string",default:"path.to[0].my.data"},{name:"additionalData",description:"Additional data objects to be considered",aliases:["additional","objects","data","additionalObjects"],required:!1,type:"object",default:{}}],He=L(Fe),Me={description:"Extract values from data objects",aliases:["dataProperties","data","getData","objectProperties","objProps","getProperty","getObjProp"],parameters:Fe},$e={propertyAliases:He,operatorData:Me,evaluate:(e,t)=>i(void 0,void 0,void 0,(function*(){var a,i;const[s,n={}]=yield M([e.property,e.additionalData],t);t.typeChecker(I(Me.parameters,{property:s,additionalData:n}));const o=Object.assign(Object.assign({},null!==(i=null===(a=t.options)||void 0===a?void 0:a.data)&&void 0!==i?i:{}),n);return r(o,s)})),parseChildren:e=>{const[r,t]=e.children,a=Object.assign(Object.assign({},e),{property:r});return void 0!==t&&(a.fallback=t),a}},Be=[{name:"string",description:"A parameterised (%1, %2) string where the parameters are to be replaced",aliases:[],required:!0,type:"string",default:"Hello, %1"},{name:"substitutions",description:"An array of substitution values for the parameterised string",aliases:["replacements","values"],required:!1,type:["array","object"],default:["friend"]},{name:"trimWhiteSpace",description:"Whether or not to trim white space from either end of the substituted strings (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"substitutionCharacter",description:'Which character to search for in original string for replacement -- can be "%" or "$" (default: "%")',aliases:["subCharacter","subChar"],required:!1,type:"string",default:"$"},{name:"numberMapping",description:"Rules for mapping number values to text strings, such as pluralisation.",aliases:["numMap","numberMap","pluralisation","pluralization","plurals"],required:!1,type:"object",default:{}}],Ge=L(Be),ze={description:"Replace values in a string using simple parameter substitution",aliases:["stringSubstitution","substitute","stringSub","replace"],parameters:Be},We={propertyAliases:Ge,operatorData:ze,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a={},i=!0,s="%",n={}]=yield M([e.string,e.substitutions,e.trimWhiteSpace,e.substitutionCharacter,e.numberMapping],r);if(r.typeChecker(I(ze.parameters,{string:t,substitutions:a,trimWhiteSpace:i,substitutionCharacter:s,numberMapping:n})),Array.isArray(a)){const e="$"===s?"$":"%",r=new RegExp(`(?<!\\\\)(${"%"===e?"%":"\\$"}[\\d]+)`,"g"),n=(t.match(r)||[]).sort(((e,r)=>Number(e.slice(1))-Number(r.slice(1)))),o=new Set(n),l=U(Array.from(o),a.map((e=>i?String(e).trim():e)));return t.split(r).map((e=>e in l?l[e]:e)).join("").replace(`\\${e}`,e)}return t.split(/(?<!\\)({{(?:[A-Za-z0-9_.]|\[[0-9]+\])+}})/g).map((e=>{if(!/(?<!\\){{(.+)}}/.exec(e))return e.replace("\\{{","{{");const t=Je(e,a,n,r.options.data);return i?String(t).trim():t})).join("")})),parseChildren:e=>{const[r,...t]=e.children;return Object.assign(Object.assign({},e),{string:r,substitutions:t})}},Je=(e,t,a,i={})=>{const s=e.replace(/{{(.+)}}/,"$1"),n=r(t,s,r(i,s,""));if("number"!=typeof n)return n;if(!(s in a))return n;const o=a[s];if(n in o)return o[n].replace("{}",String(n));const l=Object.keys(a[s]),u=l.find((e=>e.startsWith(">")));if(u){if(n>Number(u.slice(1)))return null==o?void 0:o[u]}const d=l.find((e=>e.startsWith("<")));if(d){if(n<Number(d.slice(1)))return null==o?void 0:o[d]}return o.other?o.other.replace("{}",String(n)):n},Ve=[{name:"values",description:"An array to count",aliases:[],required:!0,type:"array",default:[1,2,3,4,5]}],Ye=L(Ve),Xe={description:"Count elements in an array",aliases:["count","length"],parameters:Ve},Ke={propertyAliases:Ye,operatorData:Xe,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield M(e.values,r);return r.typeChecker(I(Xe.parameters,{values:t})),t.length})),parseChildren:e=>{const[r]=e.children;return Object.assign(Object.assign({},e),{values:r})}},Ze=[{name:"value",description:"The string to be split",aliases:["string"],required:!0,type:"string",default:"Alpha, Bravo, Charlie"},{name:"delimiter",description:"The value to split the string on (default is white space)",aliases:["separator"],required:!1,type:"string",default:","},{name:"trimWhiteSpace",description:"Whether to trim white space from around the resulting elements (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"excludeTrailing",description:"If the input string ends in a delimiter, there will be an additional blank element if this value is false (default: true)",aliases:["removeTrailing","excludeTrailingDelimiter"],required:!1,type:"boolean",default:!0}],er=L(Ze),rr={description:"Split a string into an array",aliases:["split","arraySplit"],parameters:Ze},tr=" ",ar={propertyAliases:er,operatorData:rr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,i;const[s,n,o,l]=yield M([e.value,null!==(t=e.delimiter)&&void 0!==t?t:tr,null===(a=e.trimWhiteSpace)||void 0===a||a,null===(i=e.excludeTrailing)||void 0===i||i],r);r.typeChecker(I(rr.parameters,{value:s,delimiter:n,trimWhiteSpace:o,excludeTrailing:l}));let u=s.split(n);return o&&(u=u.map((e=>e.trim()))),l&&""===u[u.length-1]&&u.pop(),u})),parseChildren:e=>{const[r,t=tr]=e.children;return Object.assign(Object.assign({},e),{value:r,delimiter:t})}},ir=[{name:"query",description:"SQL query string, with parameterised replacements (e.g. $1, $2, etc)",aliases:["text"],required:!0,type:"string"},{name:"values",description:"An array/object of values to replace the SQL string parameters, as per SQL connection specifications ",aliases:["replacements"],required:!1,type:["array","object"]},{name:"single",description:"Specify if returning a single record",aliases:["singleRecord"],required:!1,type:"boolean"},{name:"flatten",description:"Specify whether to flatten resulting record objects to arrays of values",aliases:["flat","array"],required:!1,type:"boolean"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean"}],sr=L(ir),nr={description:"Query an SQL database",aliases:["sql","pgSql","postgres","pg","sqLite","sqlite","mySql"],parameters:ir},or={propertyAliases:sr,operatorData:nr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s;const n=null===(t=r.options)||void 0===t?void 0:t.sqlConnection;if(!n)throw new Error("No SQL database connection provided");const[o,l,u,d,c,p]=yield M([e.query,e.values||[],e.single,e.flatten,e.useCache,e.type],r);r.typeChecker(I(nr.parameters,{query:o,single:u,flatten:d,values:l,useCache:c}));const h=null===(s=null!==(a=e.useCache)&&void 0!==a?a:r.options.useCache)||void 0===s||s;{const e=r.cache.useCache(h,((e,r,t,a,s)=>i(void 0,void 0,void 0,(function*(){const i=(yield n.query({query:e,values:r}))||[];["array","string","number"].includes(null!=s?s:"")&&(a=!0);const o=a?i.map((e=>{const r=Object.values(e);return r.length<=1?r[0]:r})):i;return t?o[0]:o}))),o,l,u,d,p);return e}})),parseChildren:e=>{const[r,...t]=e.children;return Object.assign(Object.assign({},e),{query:r,values:t})}},lr=[{name:"query",description:"GraphQL query string",aliases:[],required:!0,type:"string",default:'query getCountries {\n countries(filter: {continent: {eq: "OC"}}) {\n name\n }\n }'},{name:"url",description:"Endpoint for the GraphQL request (if not already provided in options)",aliases:["endpoint"],required:!1,type:["string","null"],default:"https://countries.trevorblades.com/"},{name:"headers",description:"HTTP Headers (if not already provided in options)",aliases:[],required:!1,type:"object",default:{}},{name:"variables",description:"Values for the variables used in query (key-value pairs)",aliases:[],required:!1,type:"object",default:{}},{name:"returnNode",description:"Property path to extract from the query response",aliases:["outputNode","returnProperty"],required:!1,type:"string",default:"data.countries[1].name"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],ur=L(lr),dr={description:"GraphQL request",aliases:["graphQl","graphql","gql"],parameters:lr},cr={propertyAliases:ur,operatorData:dr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s,n,o,l,u;const d=null!==(t=r.graphQLClient)&&void 0!==t?t:r.httpClient;if(!d)throw new Error("No HTTP client provided for GraphQL connection");const[c,p,h,v,y,m]=yield M([e.query,e.url,e.variables,e.returnNode,e.headers,e.useCache],r),{url:f,headers:g}=p instanceof Object?p:{url:p,headers:null};r.typeChecker([...I(dr.parameters,{url:f,query:c,variables:h,returnNode:v,headers:y,useCache:m}),{name:"headers",value:g,expectedType:["object","null"]}]);const b=f&&"graphqlendpoint"!==f.toLowerCase()?f:"",T=null!==(n=null!==(s=null===(a=r.options.graphQLConnection)||void 0===a?void 0:a.endpoint)&&void 0!==s?s:r.options.baseEndpoint)&&void 0!==n?n:"",O=Q(b)?b:_(T,b),C={query:c,variables:h},q=null===(o=null!=m?m:r.options.useCache)||void 0===o||o,S=yield r.cache.useCache(q,((e,r,t,a)=>i(void 0,void 0,void 0,(function*(){const i=yield F(d,{url:e,method:"post",data:r,headers:t});return D(null==i?void 0:i.data,a)}))),O,C,Object.assign(Object.assign(Object.assign(Object.assign({},null===(l=r.options.graphQLConnection)||void 0===l?void 0:l.headers),null===(u=r.options)||void 0===u?void 0:u.headers),g),y),v);return S})),parseChildren:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a="",i,...s]=yield M(e.children,r),n=Array.isArray(i)?i:[i],o=s.slice(0,n.length),l=U(n,o),u=Object.assign(Object.assign({},e),{query:t,url:a,variables:l});return s.length>n.length&&(u.returnNode=s.pop()),u}))},pr=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://restcountries.com/v3.1/name/zealand"},{name:"returnProperty",description:"Property from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"Query parameters (key-value)",aliases:["queryParams","queryParameters","urlQueries"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],hr=L(pr),vr={description:"HTTP GET Request",aliases:["get","api"],parameters:pr},yr=(e,r)=>i(void 0,void 0,void 0,(function*(){const[t="",a,...i]=yield M(e.children,r),s=Array.isArray(a)?a:[a],n=i.slice(0,s.length),o=U(s,n),l=Object.assign(Object.assign({},e),{url:t,parameters:o});return i.length>s.length&&(l.returnProperty=i.pop()),l})),mr=yr,fr={propertyAliases:hr,operatorData:vr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s;const n=r.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield M([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],r),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};r.typeChecker([...I(vr.parameters,{url:p,returnProperty:u,headers:d,parameters:l,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(t=r.options.baseEndpoint)&&void 0!==t?t:"",y=Object.assign(Object.assign(Object.assign({},null===(a=r.options)||void 0===a?void 0:a.headers),h),d),m=null===(s=null!=c?c:r.options.useCache)||void 0===s||s,f=yield r.cache.useCache(m,((e,r,t,a)=>i(void 0,void 0,void 0,(function*(){const i=yield F(n,{url:e,params:r,headers:t});return D(i,a)}))),Q(p)?p:_(v,p),l,y,u);return f})),parseChildren:yr},gr=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://jsonplaceholder.typicode.com/posts"},{name:"returnProperty",description:"Property path from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"JSON Body parameters (key-value)",aliases:["bodyJson","data"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],br=L(gr),Tr={description:"HTTP POST Request",aliases:["post"],parameters:gr},Or={propertyAliases:br,operatorData:Tr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s;const n=r.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield M([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],r),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};r.typeChecker([...I(Tr.parameters,{url:p,headers:d,data:l,returnProperty:u,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(t=r.options.baseEndpoint)&&void 0!==t?t:"",y=Object.assign(Object.assign(Object.assign({},null===(a=r.options)||void 0===a?void 0:a.headers),h),d),m=null!==(s=null!=c?c:r.options.useCache)&&void 0!==s&&s,f=yield r.cache.useCache(m,((e,r,t,a)=>i(void 0,void 0,void 0,(function*(){const i=yield F(n,{url:e,data:r,headers:t,method:"post"});return D(i,a)}))),Q(p)?p:_(v,p),l,y,u);return f})),parseChildren:mr},Cr=[{name:"properties",description:'An array of objects, each with a "key" property and a "value" property',aliases:["values","keyValPairs","keyValuePairs"],required:!0,type:"array",default:["firstKey","firstValue","secondKey","secondValue"]}],qr=L(Cr),Sr={description:"Construct an object using objects defining keys and values",aliases:["buildObject","build","object"],parameters:Cr},Er={propertyAliases:qr,operatorData:Sr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){r.typeChecker(I(Sr.parameters,{properties:e.properties}));const t=e.properties.filter((e=>e instanceof Object&&"key"in e&&"value"in e)).map((({key:e,value:t})=>{return a=[e,t],i(void 0,void 0,void 0,(function*(){const[e,t]=yield M(a,r);return r.typeChecker({name:"key",value:e,expectedType:["string","number","boolean"]}),[e,t]}));var a}));return Object.fromEntries(yield Promise.all(t))})),parseChildren:e=>{const r=e.children;if(r.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const t=r.filter(((e,r)=>r%2==0)),a=r.filter(((e,r)=>r%2==1)),i=t.map(((e,r)=>({key:e,value:a[r]})));return Object.assign(Object.assign({},e),{properties:i})}},jr=[{name:"matchExpression",description:"Expression to match against",aliases:["match"],required:!0,type:["string","number","boolean"],default:"matchMe"},{name:"branches",description:"Object whose keys are compared against the match expression. The value of the matching key is returned",aliases:["arms","cases"],required:!1,type:["object","array"],default:{matchMe:"YES",nonMatch:"NO"}},{name:"[...branches]",description:"Branch properties can optionally be placed at the operator root",aliases:[],required:!1,type:["object","array"]}],Ar={propertyAliases:L(jr),operatorData:{description:"Return different values depending on a matching expression",aliases:["match","switch"],parameters:jr},evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t;const a=yield H(e.matchExpression,r);r.typeChecker({name:"matchExpression",value:a,expectedType:["string","number","boolean"]});const i=Array.isArray(e.branches)?k(e.branches):null!==(t=e.branches)&&void 0!==t?t:{},n=s(i)?yield H(i,r):i;if(!g(n))throw new Error("Branches don't evaluate to an object");if(a in n)return yield H(n[a],r);if("fallback"in n)return yield H(n.fallback,r);if(a in e)return yield H(e[a],r);throw new Error(`No match found for ${a}`)})),parseChildren:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,...a]=e.children,i=k(yield M(a,r));return Object.assign(Object.assign({},e),{matchExpression:t,branches:i})}))},xr=[{name:"functionPath",description:"Path (in options.functions) to the required function",aliases:["functionsPath","functionName","funcName","path","name"],required:!0,type:"string",default:null},{name:"args",description:"Arguments for the function",aliases:["arguments","variables"],required:!1,type:"array",default:[]},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!1}],Nr=L(xr),wr={description:"Call a custom function (defined in options)",aliases:["customFunctions","customFunction","objectFunctions","function","functions","runFunction"],parameters:xr},Pr={propertyAliases:Nr,operatorData:wr,evaluate:(e,t)=>i(void 0,void 0,void 0,(function*(){var a,s,n;const[o,l=[],u]=yield M([e.functionPath,e.args,e.useCache],t);t.typeChecker(I(wr.parameters,{functionPath:o,args:l}));const{data:d,functions:c}=t.options,p=null!==(s=null!==(a=r(c,o,null))&&void 0!==a?a:r(d,o,null))&&void 0!==s?s:r(t.options,o,null);if(!p||"function"!=typeof p)throw new Error(`- No function found: "${o}"`);const h=null!==(n=null!=u?u:t.options.useCache)&&void 0!==n&&n;return yield t.cache.useCache(h,((e,...r)=>i(void 0,void 0,void 0,(function*(){return yield p(...r)}))),o,...l)})),parseChildren:e=>{const[r,...t]=e.children;return Object.assign(Object.assign({},e),{functionPath:r,args:t})}},Lr=[{name:"value",description:"Value to pass through",aliases:["_","data"],required:!0,type:"any",default:null}],Ir=L(Lr),Ur={description:"Pass through a value unchanged (or change its type)",aliases:["_","passThru","passthru","pass","ignore","coerce","convert"],parameters:Lr},kr={propertyAliases:Ir,operatorData:Ur,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){return r.typeChecker(I(Ur.parameters,{value:e.value})),yield H(e.value,r)})),parseChildren:e=>{const[...r]=e.children,t=1===(null==r?void 0:r.length)?r[0]:r;return Object.assign(Object.assign({},e),{value:t})}};var Rr=Object.freeze({__proto__:null,AND:V,BUILD_OBJECT:Er,CONDITIONAL:ke,COUNT:Ke,CUSTOM_FUNCTIONS:Pr,DIVIDE:qe,EQUAL:ae,GET:fr,GRAPHQL:cr,GREATER_THAN:Ae,LESS_THAN:Pe,MATCH:Ar,MULTIPLY:be,NOT_EQUAL:oe,OBJECT_PROPERTIES:$e,OR:Z,PASSTHRU:kr,PLUS:ce,POST:Or,REGEX:_e,SPLIT:ar,SQL:or,STRING_SUBSTITUTION:We,SUBTRACT:ye});class Dr{constructor(e){var r,t;this.useCache=(e,r,...t)=>i(this,void 0,void 0,(function*(){if(!e)return yield r(...t);const a=Qr(t),i=a in this.store,s=Date.now(),n=i&&s-this.store[a].timestamp>1e3*this.maxTime;if(i)return this.queue=this.queue.filter((e=>e!==a)),this.queue.unshift(a),this.store[a].timestamp=s,n&&(this.store[a].result=yield r(...t)),this.store[a].result;const o=yield r(...t);return this.store[a]={result:o,timestamp:s},this.queue.unshift(a),this.resizeCache(),o})),this.getMax=()=>this.maxSize,this.setMax=e=>{this.maxSize=e,this.resizeCache()},this.getMaxTime=()=>this.maxTime,this.setMaxTime=e=>{this.maxTime=e},this.getCache=()=>this.store,this.setCache=e=>this.store=e,this.resizeCache=()=>{if(this.queue.length>this.maxSize){this.queue.slice(this.maxSize).forEach((e=>delete this.store[e])),this.queue=this.queue.slice(0,this.maxSize)}},this.store={},this.queue=[],this.maxSize=null!==(r=null==e?void 0:e.maxSize)&&void 0!==r?r:50,this.maxTime=null!==(t=null==e?void 0:e.maxTime)&&void 0!==t?t:1800}}const Qr=e=>e.map((e=>"object"==typeof e?JSON.stringify(e):e)).join("_"),_r=e=>e?"name"in e&&"fetch"===e.name?Hr(e):"Axios"in e&&"Axios"===e.Axios.name?Fr(e):e:"undefined"!=typeof window&&"document"in window&&"fetch"in window?Hr(window.fetch):void 0,Fr=e=>({get:r=>i(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},r),{method:"get"}))).data})),post:r=>i(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},r),{method:"post"}))).data})),throwError:r=>{var t,a,i,s;if(e.isAxiosError(r)&&r.response)throw r.errorData={status:null===(t=r.response)||void 0===t?void 0:t.status,error:null===(a=r.response)||void 0===a?void 0:a.statusText,url:null===(i=r.config)||void 0===i?void 0:i.url,response:null===(s=r.response)||void 0===s?void 0:s.data},console.log(r.errorData),r;throw new Error("Network error: "+(null==r?void 0:r.message))}}),Hr=e=>({get:r=>i(void 0,void 0,void 0,(function*(){const{url:t,headers:i,params:s={}}=r,n=Object.keys(s).length>0?`?${a.stringify(s)}`:"",o=yield e(t+n,{headers:i,method:"GET"}),l=yield o.json();if(!o.ok){const e=new Error("Problem with GET request");throw e.name="FetchError",e.errorData={status:o.status,error:o.statusText,url:o.url,response:l},console.log(e.errorData),e}return l})),post:r=>i(void 0,void 0,void 0,(function*(){const{url:t,headers:a,params:i,data:s}=r,n=new URLSearchParams(i),o=n.size>0?`?${n.toString()}`:"",l=yield e(t+o,{headers:a,body:JSON.stringify(s),method:"POST"}),u=yield l.json();if(!l.ok){const e=new Error("Problem with POST request");throw e.name="FetchError",e.errorData={status:l.status,error:l.statusText,url:l.url,response:u},console.log(e.errorData),e}return u})),throwError:e=>{throw e}});class Mr{constructor(e={}){var r,t,a;this.typeChecker=(...e)=>{const r=1===e.length&&Array.isArray(e[0])?e[0]:e,t=x(...r);if(!0===t)return;const a=new Error(t);throw a.name="Type Error",a},this.getCache=()=>this.cache.getCache(),this.setCache=e=>this.cache.setCache(e),this.getVersion=()=>"2.16.0",this.options=$r(e),this.operators=u(Rr,null!==(t=null===(r=this.options)||void 0===r?void 0:r.excludeOperators)&&void 0!==t?t:[],b),this.operatorAliases=b,this.cache=new Dr({maxSize:e.maxCacheSize,maxTime:e.maxCacheTime}),this.graphQLClient=_r(null===(a=e.graphQLConnection)||void 0===a?void 0:a.httpClient),this.httpClient=_r(e.httpClient)}evaluate(e,r={}){var t;return i(this,void 0,void 0,(function*(){const a=y(this.options,$r(r));return r.httpClient&&(this.httpClient=_r(r.httpClient)),(null===(t=r.graphQLConnection)||void 0===t?void 0:t.httpClient)&&(this.graphQLClient=_r(r.graphQLConnection.httpClient)),a.maxCacheSize&&a.maxCacheSize!==this.cache.getMax()&&this.cache.setMax(a.maxCacheSize),a.maxCacheTime&&a.maxCacheTime!==this.cache.getMaxTime()&&this.cache.setMaxTime(a.maxCacheTime),yield H(e,{options:a,operators:r.excludeOperators?u(Rr,r.excludeOperators,b):this.operators,operatorAliases:this.operatorAliases,typeChecker:a.skipRuntimeTypeCheck?()=>{}:this.typeChecker,resolvedAliasNodes:{},cache:this.cache,graphQLClient:this.graphQLClient,httpClient:this.httpClient})}))}getOptions(){return this.options}updateOptions(e){this.options=y(this.options,$r(e)),this.options.excludeOperators&&(this.operators=u(Rr,this.options.excludeOperators,b))}getOperators(){const e=this.options.excludeOperators?u(Rr,this.options.excludeOperators,b):this.operators,r=Object.entries(e).map((([e,r])=>Object.assign({name:e},r.operatorData))),t=[...new Set(Object.values(b))];return r.sort(((e,r)=>t.indexOf(e.name)-t.indexOf(r.name)))}getFragments(){var e;return Object.entries(null!==(e=this.options.fragments)&&void 0!==e?e:{}).map((([e,r])=>Object.assign({name:e},null==r?void 0:r.metadata)))}getCustomFunctions(){var e;return Object.entries(null!==(e=this.options.functions)&&void 0!==e?e:{}).map((([e,r])=>({name:e,numRequiredArgs:r.length})))}}const $r=e=>"objects"in e?Object.assign(Object.assign({},e),{data:e.objects}):e;exports.AxiosClient=Fr,exports.FetchClient=Hr,exports.FigTreeEvaluator=Mr,exports.SQLNodePostgres=e=>({query:({query:r,values:t=[]})=>i(void 0,void 0,void 0,(function*(){const a={text:r,values:null!=t?t:[]};try{const r=yield e.query(a);if(null==r?void 0:r.error)throw new Error(r.error);return r.rows}catch(e){throw e.name="Node-Postgres error",e}}))}),exports.SQLite=e=>({query:({query:r,values:t=[]})=>i(void 0,void 0,void 0,(function*(){try{return yield e.all(r,t)}catch(e){throw e.name="SQLite error",e}}))}),exports.evaluateExpression=(e,r)=>new Mr(r).evaluate(e),exports.isAliasString=h,exports.isFragmentNode=n,exports.isObject=g,exports.isOperatorNode=s,exports.preProcessShorthand=C,exports.standardiseOperatorName=o,exports.truncateString=d;
@@ -1 +1 @@
1
- import{camelCase as e}from"change-case";import t from"object-property-extractor";import{dequal as r}from"dequal/lite";function a(e,t,r,a){return new(r||(r=Promise))((function(i,s){function n(e){try{l(a.next(e))}catch(e){s(e)}}function o(e){try{l(a.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,o)}l((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=e=>e instanceof Object&&"operator"in e,s=e=>e instanceof Object&&"fragment"in e,n=t=>{const r=e(t);return r||t},o=(e,t)=>t[n(e)],l=(e,t,r)=>{const a=Object.assign({},e);return t.forEach((e=>{r[n(e)]||console.warn(`Invalid operator exclusion: ${e}`),delete a[r[n(e)]]})),a},u=(e,t=200)=>e.length<t?e:`${e.slice(0,t-2).trim()}...`,d=(e,t,r=!1)=>{if(void 0!==e)return e;if(r)return u(t);throw new Error(u(t))},c=(e,t)=>{const r=Object.entries(e).map((([e,r])=>[t(e),r]));return Object.fromEntries(r)},p=e=>/^\$.+/.test(e),h=(e,{resolvedAliasNodes:t})=>{var r;return"string"==typeof e&&p(e)&&null!==(r=null==t?void 0:t[e])&&void 0!==r?r:e},v=(e,t)=>{const r=Object.assign(Object.assign({},e),t);return(e.data||t.data)&&(r.data=Object.assign(Object.assign({},e.data),t.data)),(e.functions||t.functions)&&(r.functions=Object.assign(Object.assign({},e.functions),t.functions)),(e.fragments||t.fragments)&&(r.fragments=Object.assign(Object.assign({},e.fragments),t.fragments)),(e.headers||t.headers)&&(r.headers=Object.assign(Object.assign({},e.headers),t.headers)),r},y={number:e=>f(e),string:e=>String(e),array:e=>Array.isArray(e)?e:[e],boolean:e=>Boolean(e),bool:e=>Boolean(e)},m=e=>e.message,f=e=>{if("string"!=typeof e)return Number.isNaN(Number(e))?e:Number(e);const t=new RegExp(/-?\d*\.?\d+/gm),r=e.match(t);return r?Number(r[0]):0},g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b={and:"AND","&":"AND","&&":"AND",or:"OR","|":"OR","||":"OR","=":"EQUAL",eq:"EQUAL",equal:"EQUAL",equals:"EQUAL","!=":"NOT_EQUAL","!":"NOT_EQUAL",ne:"NOT_EQUAL",notEqual:"NOT_EQUAL","+":"PLUS",plus:"PLUS",add:"PLUS",concat:"PLUS",join:"PLUS",merge:"PLUS","-":"SUBTRACT",subtract:"SUBTRACT",minus:"SUBTRACT",takeaway:"SUBTRACT","*":"MULTIPLY",x:"MULTIPLY",multiply:"MULTIPLY",times:"MULTIPLY","/":"DIVIDE",divide:"DIVIDE","÷":"DIVIDE",">":"GREATER_THAN",greaterThan:"GREATER_THAN",higher:"GREATER_THAN",larger:"GREATER_THAN","<":"LESS_THAN",lessThan:"LESS_THAN",lower:"LESS_THAN",smaller:"LESS_THAN","?":"CONDITIONAL",conditional:"CONDITIONAL",ifThen:"CONDITIONAL",regex:"REGEX",patternMatch:"REGEX",regexp:"REGEX",matchPattern:"REGEX",dataProperties:"OBJECT_PROPERTIES",data:"OBJECT_PROPERTIES",getData:"OBJECT_PROPERTIES",objectProperties:"OBJECT_PROPERTIES",objProps:"OBJECT_PROPERTIES",getProperty:"OBJECT_PROPERTIES",getObjProp:"OBJECT_PROPERTIES",stringSubstitution:"STRING_SUBSTITUTION",substitute:"STRING_SUBSTITUTION",stringSub:"STRING_SUBSTITUTION",replace:"STRING_SUBSTITUTION",split:"SPLIT",arraySplit:"SPLIT",count:"COUNT",length:"COUNT",get:"GET",api:"GET",post:"POST",sql:"SQL",pgSql:"SQL",postgres:"SQL",pg:"SQL",sqLite:"SQL",sqlite:"SQL",mySql:"SQL",graphQl:"GRAPHQL",graphql:"GRAPHQL",gql:"GRAPHQL",buildObject:"BUILD_OBJECT",build:"BUILD_OBJECT",object:"BUILD_OBJECT",match:"MATCH",switch:"MATCH",customFunctions:"CUSTOM_FUNCTIONS",customFunction:"CUSTOM_FUNCTIONS",objectFunctions:"CUSTOM_FUNCTIONS",function:"CUSTOM_FUNCTIONS",functions:"CUSTOM_FUNCTIONS",runFunction:"CUSTOM_FUNCTIONS",_:"PASSTHRU",passThru:"PASSTHRU",passthru:"PASSTHRU",pass:"PASSTHRU",ignore:"PASSTHRU",coerce:"PASSTHRU",convert:"PASSTHRU"},T=b,O=/(\$[^()]+)\((.*)\)/,C=(e,t={},r=!0)=>r?"string"==typeof e?q(e,t):g(e)?j(e,t):e:e,q=(e,t)=>{const r=O.exec(e);if(!r)return e;const a=r[1].trim(),i=r[2].split(",").map((e=>C(e.trim(),t)));return S(a,i,t)},j=(e,t)=>{if(i(e)||s(e))return e;const r=Object.entries(e),a=r.filter((([e])=>p(e))),n=r.filter((([e])=>!p(e))),o=a.reduce(((e,[r,a])=>e=Object.assign(Object.assign({},e),S(r,a,t))),{});return Object.assign(Object.assign({},o),Object.fromEntries(n))},S=(e,t,r)=>{const a=e.slice(1),i=o(a,T);return i?Array.isArray(t)?{operator:i,children:t}:g(t)&&!Object.keys(t).some((e=>p(e)))?Object.assign({operator:i},t):{operator:i,children:[t]}:a in r?{fragment:a,parameters:Object.assign({},t)}:{[e]:t}},E=e=>g(e)&&"literal"in e,A=({value:e,name:t,expectedType:r})=>{if(E(r)){const{literal:a}=r;return!!a.includes(e)||P(t,e,`Literal(${a.map((e=>void 0===e?"undefined":`"${e}"`)).join(", ")})`)}if(Array.isArray(r))return!!r.some((r=>!0===A({value:e,name:t,expectedType:r})))||P(t,e,r.join("|"));return!!(0,N[r])(e)||P(t,e,r)},w=(...e)=>{const t=[];return e.forEach((e=>{const r=A(e);!0!==r&&t.push(r)})),!(t.length>0)||t.join("\n")},N={any:e=>void 0!==e,string:e=>"string"==typeof e,number:e=>"number"==typeof e,boolean:e=>"boolean"==typeof e,array:e=>Array.isArray(e),null:e=>null===e,object:e=>g(e),undefined:e=>void 0===e},P=(e,t,r)=>void 0===t&&e?`- Missing required property "${e}" (type: ${r})`:void 0!==e?`- Property "${e}" (value: ${x(t)}) is not of type: ${r}`:`- ${x(t)} is not of type: ${r}`,x=e=>{const t=void 0===e||Number.isNaN(e)?String(e):JSON.stringify(e);return u(t,50)},L=e=>{const t={};return e.forEach((e=>{e.aliases.forEach((r=>t[r]=e.name))})),t},I=(e,t)=>e.map((({name:e,required:r,type:a})=>{if(E(a)){const i=[...a.literal];return r||i.push(void 0),{name:e,value:t[e],expectedType:{literal:i}}}const i=Array.isArray(a)?a:[a];r||i.push("undefined");const s=1===i.length?i[0]:i;return{name:e,value:t[e],expectedType:s}})),U=(e,t)=>{const r=e.map(((e,r)=>[e,t[r]]));return Object.fromEntries(r)},R=e=>{if(e.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const t=e.filter(((e,t)=>t%2==0)),r=w(...t.map((e=>({value:e,expectedType:["string","number","boolean"]}))));if(!0!==r)throw new Error(r);const a=e.filter(((e,t)=>t%2==1)),i={};return t.forEach(((e,t)=>{i[e]=a[t]})),i},k=e=>g(e)&&1===Object.keys(e).length?Object.values(e)[0]:e,D=(e,r,a=void 0)=>{const i=r?t(e,r,a):e;return Array.isArray(i)?i.map((e=>k(e))):r?null===i?null:k(i):i},_=e=>/^https?:\/\/.+/.test(e),Q=(...e)=>e.reduce(((e,t,r)=>{const a="/"===t[0]?1:0,i="/"===t.slice(-1)?-1:void 0,s=t.slice(a,i);return""===s?e:e+(0===r?"":"/")+s}),""),$=(e,t)=>a(void 0,void 0,void 0,(function*(){const{url:r,params:a={},data:i={},headers:s={},method:n="get"}=t;try{return yield e[n]({url:r,headers:Object.assign({"Content-Type":"application/json",Accept:"application/json"},s),params:a,data:i})}catch(t){e.throwError(t)}})),H=(e,t)=>a(void 0,void 0,void 0,(function*(){var r,a,n,l;const{options:u,operators:p,operatorAliases:v}=t;let f=(null==u?void 0:u.allowJSONStringInput)?(e=>{if("string"!=typeof e)return e;try{const t=JSON.parse(e);return i(t)?t:e}catch(t){return e}})(e):e;f=C(f,null===(r=t.options)||void 0===r?void 0:r.fragments,!u.noShorthand),Array.isArray(f)&&(f=yield M(f,t));const b=i(f),T=s(f);if(u.evaluateFullObject&&!b&&!T)return h(yield F(f,t),t);if(!b&&!T)return u.supportDeprecatedValueNodes&&g(f)&&"value"in f?f.value:h(f,t);const{fallback:O}=f,q=null!==(a=null==u?void 0:u.returnErrorAsString)&&void 0!==a&&a;if(T){const[e,r]=yield M([f.fragment,f.parameters],t),a=C(null===(n=null==u?void 0:u.fragments)||void 0===n?void 0:n[e],u.fragments,!u.noShorthand);if(void 0===a)return d(yield H(O,t),`Fragment not defined: ${e}`,q);if(!i(a))return h(a,t);f=Object.assign(Object.assign(Object.assign({},f),a),r),delete f.fragment}try{const e=o(f.operator,v);if(!e)return d(yield H(O,t),`Invalid operator: ${f.operator}`,q);if(!t.operators[e])return d(yield H(O,t),`Excluded operator: ${f.operator}`,q);const{propertyAliases:r,evaluate:a,parseChildren:i}=p[e];f=((e,t)=>c(t,(t=>t in e?e[t]:t)))(r,f);const s=yield B(f,t);T||Object.entries(s).forEach((([e,r])=>t.resolvedAliasNodes[e]=r));const n=T?Object.assign(Object.assign({},t),{resolvedAliasNodes:Object.assign(Object.assign({},t.resolvedAliasNodes),s)}):t;if("children"in f){if(Array.isArray(f.children)||(f.children=yield H(f.children,n)),!Array.isArray(f.children))return d(yield H(O,t),`Operator: ${e}\n- Property "children" is not of type: array`,q);f=yield i(f,n),delete f.children}let u;try{u=yield a(f,n)}catch(r){return d(yield H(f.fallback,t),`Operator: ${e}\n${m(r)}`,q)}const h=null!==(l=null==f?void 0:f.outputType)&&void 0!==l?l:null==f?void 0:f.type;if(!h)return u;const g=yield H(h,t);return g in y?y[g](u):d(yield H(O,t),`Operator: ${e}\n- Invalid output type: ${g}`,q)}catch(e){return d(yield H(O,t),m(e),q)}})),M=(e,t)=>a(void 0,void 0,void 0,(function*(){return Array.isArray(e)?yield Promise.all(e.map((e=>H(e,t)))):yield H(e,t)})),B=(e,t)=>a(void 0,void 0,void 0,(function*(){const r=Object.keys(e).filter(p);if(0===r.length)return{};const a=[];return r.forEach((r=>a.push(H(e[r],t)))),U(r,yield Promise.all(a))})),F=(e,t)=>a(void 0,void 0,void 0,(function*(){if(!g(e))return e;const r=[],a=[];Object.entries(e).forEach((([r,i])=>{p(r)&&(a.push(r,H(i,t)),delete e[r])}));const i=yield Promise.all(a);t.resolvedAliasNodes=Object.assign(Object.assign({},t.resolvedAliasNodes),R(i)),Object.entries(e).forEach((([e,a])=>{r.push(e,H(a,t))}));const s=yield Promise.all(r);return h(R(s),t)})),G=[{name:"values",description:"Returns true if all values are true",aliases:[],required:!0,type:"array",default:[!0,!0]}],z=L(G),W={description:"Logical AND",aliases:["and","&","&&"],parameters:G},J=e=>{const t=e.children;return Object.assign(Object.assign({},e),{values:t})},V={propertyAliases:z,operatorData:W,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(W.parameters,{values:r})),r.reduce(((e,t)=>e&&!!t),!0)})),parseChildren:J},Y=[{name:"values",description:"Returns true if any values are true",aliases:[],required:!0,type:"array",default:[!0,!1]}],X=L(Y),K={description:"Logical OR",aliases:["or","|","||"],parameters:Y},Z={propertyAliases:X,operatorData:K,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(K.parameters,{values:r})),r.reduce(((e,t)=>e||!!t),!1)})),parseChildren:J},ee=[{name:"values",description:"Array of values to check for equality",aliases:[],required:!0,type:"array",default:["These are equal","These are equal"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],te=L(ee),re={description:"Test multiple values are equal",aliases:["=","eq","equal","equals"],parameters:ee},ae={propertyAliases:te,operatorData:re,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield M([e.values,e.caseInsensitive,e.nullEqualsUndefined],t);t.typeChecker(I(re.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=t.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=t.options)||void 0===s?void 0:s.nullEqualsUndefined)&&t.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.every((e=>r(e,u[0]))):u.every((e=>null==e))})),parseChildren:J},ie=[{name:"values",description:"Array of values to check for inequality",aliases:[],required:!0,type:"array",default:["These items","don't match"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],se=L(ie),ne={description:"Test if any values are different",aliases:["!=","!","ne","notEqual"],parameters:ie},oe={propertyAliases:se,operatorData:ne,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield M([e.values,e.caseInsensitive,e.nullEqualsUndefined],t);t.typeChecker(I(ne.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=t.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=t.options)||void 0===s?void 0:s.nullEqualsUndefined)&&t.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.some((e=>!r(e,u[0]))):u.some((e=>null===e&&void 0===e))})),parseChildren:J},le=[{name:"values",description:"Array of values to check to add together",aliases:[],required:!0,type:"array",default:[1,2,3]},{name:"type",description:"Data type to coerce input values to before addition",aliases:[],required:!1,type:{literal:["string","array","number","boolean","bool"]},default:"string"}],ue=L(le),de={description:"Add, concatenate or merge multiple values",aliases:["+","plus","add","concat","join","merge"],parameters:le},ce={propertyAliases:ue,operatorData:de,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(de.parameters,{values:r,type:e.type})),0===r.length?r:"string"===(null==e?void 0:e.type)?r.reduce(((e,t)=>e.concat(t)),""):"array"===(null==e?void 0:e.type)?r.reduce(((e,t)=>e.concat(t)),[]):r.every((e=>"string"==typeof e||Array.isArray(e)))?r.reduce(((e,t)=>e.concat(t))):r.every((e=>g(e)))?r.reduce(((e,t)=>Object.assign(Object.assign({},e),t)),{}):r.reduce(((e,t)=>e+t))})),parseChildren:J},pe=[{name:"values",description:"Array of values - 2nd element will be subtracted from the first",aliases:[],required:!1,type:"array",default:[10,5]},{name:"from",description:"Numerical value that will be subtracted from",aliases:["subtractFrom"],required:!1,type:"number",default:100},{name:"subtract",description:"Numerical value to subtract",aliases:[],required:!1,type:"number",default:50}],he=L(pe),ve={description:"Subtract one numerical value from another",aliases:["-","subtract","minus","takeaway"],parameters:pe},ye={propertyAliases:he,operatorData:ve,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a,i]=yield M([e.values,e.from,e.subtract],t);t.typeChecker(I(ve.parameters,{values:r,from:a,subtract:i}));const s=null!=r?r:[a,i].filter((e=>void 0!==e));if(s.length<2)throw new Error("- Not enough values provided");if(s.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return s[0]-s[1]})),parseChildren:J},me=[{name:"values",description:"Array of values whose product will be calculated",aliases:[],required:!0,type:"array",default:[5,5]}],fe=L(me),ge={description:"Multiply several numerical values together",aliases:["*","x","multiply","times"],parameters:me},be={propertyAliases:fe,operatorData:ge,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);if(t.typeChecker(I(ge.parameters,{values:r})),0===r.length)return 0;if(r.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return r.reduce(((e,t)=>e*t))})),parseChildren:J},Te=[{name:"values",description:"Array of values - 1st element will be divided by the first",aliases:[],required:!1,type:"array",default:[100,10]},{name:"dividend",description:"The number that will be divided",aliases:["divide"],required:!1,type:"number",default:99},{name:"divisor",description:"The number that dividend will be divided by",aliases:["by","divideBy"],required:!1,type:"number",default:3},{name:"output",description:"Whether to output a quotient, remainder or decimal",aliases:[],required:!1,type:{literal:["quotient","remainder"]},default:"quotient"}],Oe=L(Te),Ce={description:"Divide one numerical value by another",aliases:["/","divide","÷"],parameters:Te},qe={propertyAliases:Oe,operatorData:Ce,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a,i,s]=yield M([e.values,e.dividend,e.divisor,e.output],t);t.typeChecker(I(Ce.parameters,{values:r,dividend:a,divisor:i,output:s}));const n=null!=r?r:[a,i].filter((e=>void 0!==e));if(n.length<2)throw new Error("- Not enough values provided");if(n.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");if(0===n[1])throw new Error("Division by zero!");switch(s){case"quotient":return Math.floor(n[0]/n[1]);case"remainder":return n[0]%n[1];default:return n[0]/n[1]}})),parseChildren:J},je=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[10,9]},{name:"strict",description:"Whether value must be strictly greater than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Se=L(je),Ee={description:"Test if a value is greater than (or equal to) another value",aliases:[">","greaterThan","higher","larger"],parameters:je},Ae={propertyAliases:Se,operatorData:Ee,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a=!0]=yield M([e.values,e.strict],t);if(t.typeChecker(I(Ee.parameters,{values:r,strict:a})),r.length<2)throw new Error("- Not enough values provided");const[i,s]=r;return i===s&&!a||i>s})),parseChildren:J},we=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[9,10]},{name:"strict",description:"Whether value must be strictly smaller than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Ne=L(we),Pe={description:"Test if a value is smaller than (or equal to) another value",aliases:["<","lessThan","lower","smaller"],parameters:we},xe={propertyAliases:Ne,operatorData:Pe,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a=!0]=yield M([e.values,e.strict],t);if(t.typeChecker(I(Pe.parameters,{values:r,strict:a})),r.length<2)throw new Error("- Not enough values provided");const[i,s]=r;return i===s&&!a||i<s})),parseChildren:J},Le=[{name:"condition",description:"The expression to check for truthiness",aliases:[],required:!0,type:"any",default:!0},{name:"valueIfTrue",description:"Value to return if condition is true",aliases:["ifTrue"],required:!0,type:"any",default:"The condition is true"},{name:"valueIfFalse",description:"Value to return if condition is false",aliases:["ifFalse","ifNot"],required:!0,type:"any",default:"The condition is false"}],Ie=L(Le),Ue={description:"Return a value based on a condition",aliases:["?","conditional","ifThen"],parameters:Le},Re={propertyAliases:Ie,operatorData:Ue,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){t.typeChecker(I(Ue.parameters,{condition:e.condition,valueIfTrue:e.valueIfTrue,valueIfFalse:e.valueIfFalse}));return(yield H(e.condition,t))?yield H(e.valueIfTrue,t):yield H(e.valueIfFalse,t)})),parseChildren:e=>{const[t,r,a]=e.children;return Object.assign(Object.assign({},e),{condition:t,valueIfTrue:r,valueIfFalse:a})}},ke=[{name:"testString",description:"The string to test",aliases:["string","value"],required:!0,type:"string",default:"test-this"},{name:"pattern",description:"The regular expression pattern",aliases:["regex","regexp","regExp","re"],required:!0,type:"string",default:"^[a-z]{4}-[a-z]{4}$"}],De=L(ke),_e={description:"Compare a string against a regex pattern",aliases:["regex","patternMatch","regexp","matchPattern"],parameters:ke},Qe={propertyAliases:De,operatorData:_e,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a]=yield M([e.testString,e.pattern],t);t.typeChecker(I(_e.parameters,{testString:r,pattern:a}));try{return new RegExp(a).test(r)}catch(e){throw new Error("Regex error:"+m(e))}})),parseChildren:e=>{const[t,r]=e.children;return Object.assign(Object.assign({},e),{testString:t,pattern:r})}},$e=[{name:"property",description:'The path to the required property (e.g. "user.firstName")',aliases:["path","propertyName"],required:!0,type:"string",default:"path.to[0].my.data"},{name:"additionalData",description:"Additional data objects to be considered",aliases:["additional","objects","data","additionalObjects"],required:!1,type:"object",default:{}}],He=L($e),Me={description:"Extract values from data objects",aliases:["dataProperties","data","getData","objectProperties","objProps","getProperty","getObjProp"],parameters:$e},Be={propertyAliases:He,operatorData:Me,evaluate:(e,r)=>a(void 0,void 0,void 0,(function*(){var a,i;const[s,n={}]=yield M([e.property,e.additionalData],r);r.typeChecker(I(Me.parameters,{property:s,additionalData:n}));const o=Object.assign(Object.assign({},null!==(i=null===(a=r.options)||void 0===a?void 0:a.data)&&void 0!==i?i:{}),n);return t(o,s)})),parseChildren:e=>{const[t,r]=e.children,a=Object.assign(Object.assign({},e),{property:t});return void 0!==r&&(a.fallback=r),a}},Fe=[{name:"string",description:"A parameterised (%1, %2) string where the parameters are to be replaced",aliases:[],required:!0,type:"string",default:"Hello, %1"},{name:"substitutions",description:"An array of substitution values for the parameterised string",aliases:["replacements","values"],required:!1,type:["array","object"],default:["friend"]},{name:"trimWhiteSpace",description:"Whether or not to trim white space from either end of the substituted strings (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"substitutionCharacter",description:'Which character to search for in original string for replacement -- can be "%" or "$" (default: "%")',aliases:["subCharacter","subChar"],required:!1,type:"string",default:"$"},{name:"numberMapping",description:"Rules for mapping number values to text strings, such as pluralisation.",aliases:["numMap","numberMap","pluralisation","pluralization","plurals"],required:!1,type:"object",default:{}}],Ge=L(Fe),ze={description:"Replace values in a string using simple parameter substitution",aliases:["stringSubstitution","substitute","stringSub","replace"],parameters:Fe},We={propertyAliases:Ge,operatorData:ze,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a={},i=!0,s="%",n={}]=yield M([e.string,e.substitutions,e.trimWhiteSpace,e.substitutionCharacter,e.numberMapping],t);if(t.typeChecker(I(ze.parameters,{string:r,substitutions:a,trimWhiteSpace:i,substitutionCharacter:s,numberMapping:n})),Array.isArray(a)){const e="$"===s?"$":"%",t=new RegExp(`(?<!\\\\)(${"%"===e?"%":"\\$"}[\\d]+)`,"g"),n=(r.match(t)||[]).sort(((e,t)=>Number(e.slice(1))-Number(t.slice(1)))),o=new Set(n),l=U(Array.from(o),a.map((e=>i?String(e).trim():e)));return r.split(t).map((e=>e in l?l[e]:e)).join("").replace(`\\${e}`,e)}return r.split(/(?<!\\)({{(?:[A-Za-z0-9_.]|\[[0-9]+\])+}})/g).map((e=>{if(!/(?<!\\){{(.+)}}/.exec(e))return e.replace("\\{{","{{");const r=Je(e,a,n,t.options.data);return i?String(r).trim():r})).join("")})),parseChildren:e=>{const[t,...r]=e.children;return Object.assign(Object.assign({},e),{string:t,substitutions:r})}},Je=(e,r,a,i={})=>{const s=e.replace(/{{(.+)}}/,"$1"),n=t(r,s,t(i,s,""));if("number"!=typeof n)return n;if(!(s in a))return n;const o=a[s];if(n in o)return o[n].replace("{}",String(n));const l=Object.keys(a[s]),u=l.find((e=>e.startsWith(">")));if(u){if(n>Number(u.slice(1)))return null==o?void 0:o[u]}const d=l.find((e=>e.startsWith("<")));if(d){if(n<Number(d.slice(1)))return null==o?void 0:o[d]}return o.other?o.other.replace("{}",String(n)):n},Ve=[{name:"values",description:"An array to count",aliases:[],required:!0,type:"array",default:[1,2,3,4,5]}],Ye=L(Ve),Xe={description:"Count elements in an array",aliases:["count","length"],parameters:Ve},Ke={propertyAliases:Ye,operatorData:Xe,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){const r=yield M(e.values,t);return t.typeChecker(I(Xe.parameters,{values:r})),r.length})),parseChildren:e=>{const[t]=e.children;return Object.assign(Object.assign({},e),{values:t})}},Ze=[{name:"value",description:"The string to be split",aliases:["string"],required:!0,type:"string",default:"Alpha, Bravo, Charlie"},{name:"delimiter",description:"The value to split the string on (default is white space)",aliases:["separator"],required:!1,type:"string",default:","},{name:"trimWhiteSpace",description:"Whether to trim white space from around the resulting elements (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"excludeTrailing",description:"If the input string ends in a delimiter, there will be an additional blank element if this value is false (default: true)",aliases:["removeTrailing","excludeTrailingDelimiter"],required:!1,type:"boolean",default:!0}],et=L(Ze),tt={description:"Split a string into an array",aliases:["split","arraySplit"],parameters:Ze},rt=" ",at={propertyAliases:et,operatorData:tt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,a,i;const[s,n,o,l]=yield M([e.value,null!==(r=e.delimiter)&&void 0!==r?r:rt,null===(a=e.trimWhiteSpace)||void 0===a||a,null===(i=e.excludeTrailing)||void 0===i||i],t);t.typeChecker(I(tt.parameters,{value:s,delimiter:n,trimWhiteSpace:o,excludeTrailing:l}));let u=s.split(n);return o&&(u=u.map((e=>e.trim()))),l&&""===u[u.length-1]&&u.pop(),u})),parseChildren:e=>{const[t,r=rt]=e.children;return Object.assign(Object.assign({},e),{value:t,delimiter:r})}},it=[{name:"query",description:"SQL query string, with parameterised replacements (e.g. $1, $2, etc)",aliases:["text"],required:!0,type:"string"},{name:"values",description:"An array/object of values to replace the SQL string parameters, as per SQL connection specifications ",aliases:["replacements"],required:!1,type:["array","object"]},{name:"single",description:"Specify if returning a single record",aliases:["singleRecord"],required:!1,type:"boolean"},{name:"flatten",description:"Specify whether to flatten resulting record objects to arrays of values",aliases:["flat","array"],required:!1,type:"boolean"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean"}],st=L(it),nt={description:"Query an SQL database",aliases:["sql","pgSql","postgres","pg","sqLite","sqlite","mySql"],parameters:it},ot={propertyAliases:st,operatorData:nt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s;const n=null===(r=t.options)||void 0===r?void 0:r.sqlConnection;if(!n)throw new Error("No SQL database connection provided");const[o,l,u,d,c,p]=yield M([e.query,e.values||[],e.single,e.flatten,e.useCache,e.type],t);t.typeChecker(I(nt.parameters,{query:o,single:u,flatten:d,values:l,useCache:c}));const h=null===(s=null!==(i=e.useCache)&&void 0!==i?i:t.options.useCache)||void 0===s||s;{const e=t.cache.useCache(h,((e,t,r,i,s)=>a(void 0,void 0,void 0,(function*(){const a=(yield n.query({query:e,values:t}))||[];["array","string","number"].includes(null!=s?s:"")&&(i=!0);const o=i?a.map((e=>{const t=Object.values(e);return t.length<=1?t[0]:t})):a;return r?o[0]:o}))),o,l,u,d,p);return e}})),parseChildren:e=>{const[t,...r]=e.children;return Object.assign(Object.assign({},e),{query:t,values:r})}},lt=[{name:"query",description:"GraphQL query string",aliases:[],required:!0,type:"string",default:'query getCountries {\n countries(filter: {continent: {eq: "OC"}}) {\n name\n }\n }'},{name:"url",description:"Endpoint for the GraphQL request (if not already provided in options)",aliases:["endpoint"],required:!1,type:["string","null"],default:"https://countries.trevorblades.com/"},{name:"headers",description:"HTTP Headers (if not already provided in options)",aliases:[],required:!1,type:"object",default:{}},{name:"variables",description:"Values for the variables used in query (key-value pairs)",aliases:[],required:!1,type:"object",default:{}},{name:"returnNode",description:"Property path to extract from the query response",aliases:["outputNode","returnProperty"],required:!1,type:"string",default:"data.countries[1].name"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],ut=L(lt),dt={description:"GraphQL request",aliases:["graphQl","graphql","gql"],parameters:lt},ct={propertyAliases:ut,operatorData:dt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s,n,o,l,u;const d=null!==(r=t.graphQLClient)&&void 0!==r?r:t.httpClient;if(!d)throw new Error("No HTTP client provided for GraphQL connection");const[c,p,h,v,y,m]=yield M([e.query,e.url,e.variables,e.returnNode,e.headers,e.useCache],t),{url:f,headers:g}=p instanceof Object?p:{url:p,headers:null};t.typeChecker([...I(dt.parameters,{url:f,query:c,variables:h,returnNode:v,headers:y,useCache:m}),{name:"headers",value:g,expectedType:["object","null"]}]);const b=f&&"graphqlendpoint"!==f.toLowerCase()?f:"",T=null!==(n=null!==(s=null===(i=t.options.graphQLConnection)||void 0===i?void 0:i.endpoint)&&void 0!==s?s:t.options.baseEndpoint)&&void 0!==n?n:"",O=_(b)?b:Q(T,b),C={query:c,variables:h},q=null===(o=null!=m?m:t.options.useCache)||void 0===o||o,j=yield t.cache.useCache(q,((e,t,r,i)=>a(void 0,void 0,void 0,(function*(){const a=yield $(d,{url:e,method:"post",data:t,headers:r});return D(null==a?void 0:a.data,i)}))),O,C,Object.assign(Object.assign(Object.assign(Object.assign({},null===(l=t.options.graphQLConnection)||void 0===l?void 0:l.headers),null===(u=t.options)||void 0===u?void 0:u.headers),g),y),v);return j})),parseChildren:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,a="",i,...s]=yield M(e.children,t),n=Array.isArray(i)?i:[i],o=s.slice(0,n.length),l=U(n,o),u=Object.assign(Object.assign({},e),{query:r,url:a,variables:l});return s.length>n.length&&(u.returnNode=s.pop()),u}))},pt=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://restcountries.com/v3.1/name/zealand"},{name:"returnProperty",description:"Property from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"Query parameters (key-value)",aliases:["queryParams","queryParameters","urlQueries"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],ht=L(pt),vt={description:"HTTP GET Request",aliases:["get","api"],parameters:pt},yt=(e,t)=>a(void 0,void 0,void 0,(function*(){const[r="",a,...i]=yield M(e.children,t),s=Array.isArray(a)?a:[a],n=i.slice(0,s.length),o=U(s,n),l=Object.assign(Object.assign({},e),{url:r,parameters:o});return i.length>s.length&&(l.returnProperty=i.pop()),l})),mt=yt,ft={propertyAliases:ht,operatorData:vt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s;const n=t.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield M([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],t),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};t.typeChecker([...I(vt.parameters,{url:p,returnProperty:u,headers:d,parameters:l,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(r=t.options.baseEndpoint)&&void 0!==r?r:"",y=Object.assign(Object.assign(Object.assign({},null===(i=t.options)||void 0===i?void 0:i.headers),h),d),m=null===(s=null!=c?c:t.options.useCache)||void 0===s||s,f=yield t.cache.useCache(m,((e,t,r,i)=>a(void 0,void 0,void 0,(function*(){const a=yield $(n,{url:e,params:t,headers:r});return D(a,i)}))),_(p)?p:Q(v,p),l,y,u);return f})),parseChildren:yt},gt=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://jsonplaceholder.typicode.com/posts"},{name:"returnProperty",description:"Property path from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"JSON Body parameters (key-value)",aliases:["bodyJson","data"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],bt=L(gt),Tt={description:"HTTP POST Request",aliases:["post"],parameters:gt},Ot={propertyAliases:bt,operatorData:Tt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r,i,s;const n=t.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield M([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],t),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};t.typeChecker([...I(Tt.parameters,{url:p,headers:d,data:l,returnProperty:u,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(r=t.options.baseEndpoint)&&void 0!==r?r:"",y=Object.assign(Object.assign(Object.assign({},null===(i=t.options)||void 0===i?void 0:i.headers),h),d),m=null!==(s=null!=c?c:t.options.useCache)&&void 0!==s&&s,f=yield t.cache.useCache(m,((e,t,r,i)=>a(void 0,void 0,void 0,(function*(){const a=yield $(n,{url:e,data:t,headers:r,method:"post"});return D(a,i)}))),_(p)?p:Q(v,p),l,y,u);return f})),parseChildren:mt},Ct=[{name:"properties",description:'An array of objects, each with a "key" property and a "value" property',aliases:["values","keyValPairs","keyValuePairs"],required:!0,type:"array",default:["firstKey","firstValue","secondKey","secondValue"]}],qt=L(Ct),jt={description:"Construct an object using objects defining keys and values",aliases:["buildObject","build","object"],parameters:Ct},St={propertyAliases:qt,operatorData:jt,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){t.typeChecker(I(jt.parameters,{properties:e.properties}));const r=e.properties.filter((e=>e instanceof Object&&"key"in e&&"value"in e)).map((({key:e,value:r})=>{return i=[e,r],a(void 0,void 0,void 0,(function*(){const[e,r]=yield M(i,t);return t.typeChecker({name:"key",value:e,expectedType:["string","number","boolean"]}),[e,r]}));var i}));return Object.fromEntries(yield Promise.all(r))})),parseChildren:e=>{const t=e.children;if(t.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const r=t.filter(((e,t)=>t%2==0)),a=t.filter(((e,t)=>t%2==1)),i=r.map(((e,t)=>({key:e,value:a[t]})));return Object.assign(Object.assign({},e),{properties:i})}},Et=[{name:"matchExpression",description:"Expression to match against",aliases:["match"],required:!0,type:["string","number","boolean"],default:"matchMe"},{name:"branches",description:"Object whose keys are compared against the match expression. The value of the matching key is returned",aliases:["arms","cases"],required:!1,type:["object","array"],default:{matchMe:"YES",nonMatch:"NO"}},{name:"[...branches]",description:"Branch properties can optionally be placed at the operator root",aliases:[],required:!1,type:["object","array"]}],At={propertyAliases:L(Et),operatorData:{description:"Return different values depending on a matching expression",aliases:["match","switch"],parameters:Et},evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){var r;const a=yield H(e.matchExpression,t);t.typeChecker({name:"matchExpression",value:a,expectedType:["string","number","boolean"]});const s=Array.isArray(e.branches)?R(e.branches):null!==(r=e.branches)&&void 0!==r?r:{},n=i(s)?yield H(s,t):s;if(!g(n))throw new Error("Branches don't evaluate to an object");if(a in n)return yield H(n[a],t);if("fallback"in n)return yield H(n.fallback,t);if(a in e)return yield H(e[a],t);throw new Error(`No match found for ${a}`)})),parseChildren:(e,t)=>a(void 0,void 0,void 0,(function*(){const[r,...a]=e.children,i=R(yield M(a,t));return Object.assign(Object.assign({},e),{matchExpression:r,branches:i})}))},wt=[{name:"functionPath",description:"Path (in options.functions) to the required function",aliases:["functionsPath","functionName","funcName","path","name"],required:!0,type:"string",default:null},{name:"args",description:"Arguments for the function",aliases:["arguments","variables"],required:!1,type:"array",default:[]},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!1}],Nt=L(wt),Pt={description:"Call a custom function (defined in options)",aliases:["customFunctions","customFunction","objectFunctions","function","functions","runFunction"],parameters:wt},xt={propertyAliases:Nt,operatorData:Pt,evaluate:(e,r)=>a(void 0,void 0,void 0,(function*(){var i,s,n;const[o,l=[],u]=yield M([e.functionPath,e.args,e.useCache],r);r.typeChecker(I(Pt.parameters,{functionPath:o,args:l}));const{data:d,functions:c}=r.options,p=null!==(s=null!==(i=t(c,o,null))&&void 0!==i?i:t(d,o,null))&&void 0!==s?s:t(r.options,o,null);if(!p||"function"!=typeof p)throw new Error(`- No function found: "${o}"`);const h=null!==(n=null!=u?u:r.options.useCache)&&void 0!==n&&n;return yield r.cache.useCache(h,((e,...t)=>a(void 0,void 0,void 0,(function*(){return yield p(...t)}))),o,...l)})),parseChildren:e=>{const[t,...r]=e.children;return Object.assign(Object.assign({},e),{functionPath:t,args:r})}},Lt=[{name:"value",description:"Value to pass through",aliases:["_","data"],required:!0,type:"any",default:null}],It=L(Lt),Ut={description:"Pass through a value unchanged (or change its type)",aliases:["_","passThru","passthru","pass","ignore","coerce","convert"],parameters:Lt},Rt={propertyAliases:It,operatorData:Ut,evaluate:(e,t)=>a(void 0,void 0,void 0,(function*(){return t.typeChecker(I(Ut.parameters,{value:e.value})),yield H(e.value,t)})),parseChildren:e=>{const[...t]=e.children,r=1===(null==t?void 0:t.length)?t[0]:t;return Object.assign(Object.assign({},e),{value:r})}};var kt=Object.freeze({__proto__:null,AND:V,BUILD_OBJECT:St,CONDITIONAL:Re,COUNT:Ke,CUSTOM_FUNCTIONS:xt,DIVIDE:qe,EQUAL:ae,GET:ft,GRAPHQL:ct,GREATER_THAN:Ae,LESS_THAN:xe,MATCH:At,MULTIPLY:be,NOT_EQUAL:oe,OBJECT_PROPERTIES:Be,OR:Z,PASSTHRU:Rt,PLUS:ce,POST:Ot,REGEX:Qe,SPLIT:at,SQL:ot,STRING_SUBSTITUTION:We,SUBTRACT:ye});class Dt{constructor(e){var t,r;this.useCache=(e,t,...r)=>a(this,void 0,void 0,(function*(){if(!e)return yield t(...r);const a=_t(r),i=a in this.store,s=Date.now(),n=i&&s-this.store[a].timestamp>1e3*this.maxTime;if(i)return this.queue=this.queue.filter((e=>e!==a)),this.queue.unshift(a),this.store[a].timestamp=s,n&&(this.store[a].result=yield t(...r)),this.store[a].result;const o=yield t(...r);return this.store[a]={result:o,timestamp:s},this.queue.unshift(a),this.resizeCache(),o})),this.getMax=()=>this.maxSize,this.setMax=e=>{this.maxSize=e,this.resizeCache()},this.getMaxTime=()=>this.maxTime,this.setMaxTime=e=>{this.maxTime=e},this.getCache=()=>this.store,this.setCache=e=>this.store=e,this.resizeCache=()=>{if(this.queue.length>this.maxSize){this.queue.slice(this.maxSize).forEach((e=>delete this.store[e])),this.queue=this.queue.slice(0,this.maxSize)}},this.store={},this.queue=[],this.maxSize=null!==(t=null==e?void 0:e.maxSize)&&void 0!==t?t:50,this.maxTime=null!==(r=null==e?void 0:e.maxTime)&&void 0!==r?r:1800}}const _t=e=>e.map((e=>"object"==typeof e?JSON.stringify(e):e)).join("_"),Qt=e=>e?"name"in e&&"fetch"===e.name?Ht(e):"Axios"in e&&"Axios"===e.Axios.name?$t(e):e:"undefined"!=typeof window&&"document"in window&&"fetch"in window?Ht(window.fetch):void 0,$t=e=>({get:t=>a(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},t),{method:"get"}))).data})),post:t=>a(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},t),{method:"post"}))).data})),throwError:t=>{var r;if(e.isAxiosError(t)){if(!(null==t?void 0:t.response))throw new Error("Network Error");console.log(null===(r=t.response)||void 0===r?void 0:r.data)}throw t}}),Ht=e=>({get:t=>a(void 0,void 0,void 0,(function*(){const{url:r,headers:a,params:i}=t,s=new URLSearchParams(i),n=s.size>0?`?${s.toString()}`:"",o=yield e(r+n,{headers:a,method:"GET"}),l=yield o.json();if(!o.ok)throw console.log(l),new Error(`Request failed with status code ${o.status}`);return l})),post:t=>a(void 0,void 0,void 0,(function*(){const{url:r,headers:a,params:i,data:s}=t,n=new URLSearchParams(i),o=n.size>0?`?${n.toString()}`:"",l=yield e(r+o,{headers:a,body:JSON.stringify(s),method:"POST"}),u=yield l.json();if(!l.ok)throw console.log(u),new Error(`Request failed with status code ${l.status}`);return u})),throwError:e=>{throw new Error(`${m(e)}`)}});class Mt{constructor(e={}){var t,r,a;this.typeChecker=(...e)=>{const t=1===e.length&&Array.isArray(e[0])?e[0]:e,r=w(...t);if(!0!==r)throw new Error(r)},this.getCache=()=>this.cache.getCache(),this.setCache=e=>this.cache.setCache(e),this.getVersion=()=>"2.15.0",this.options=Ft(e),this.operators=l(kt,null!==(r=null===(t=this.options)||void 0===t?void 0:t.excludeOperators)&&void 0!==r?r:[],b),this.operatorAliases=b,this.cache=new Dt({maxSize:e.maxCacheSize,maxTime:e.maxCacheTime}),this.graphQLClient=Qt(null===(a=e.graphQLConnection)||void 0===a?void 0:a.httpClient),this.httpClient=Qt(e.httpClient)}evaluate(e,t={}){var r;return a(this,void 0,void 0,(function*(){const a=v(this.options,Ft(t));return t.httpClient&&(this.httpClient=Qt(t.httpClient)),(null===(r=t.graphQLConnection)||void 0===r?void 0:r.httpClient)&&(this.graphQLClient=Qt(t.graphQLConnection.httpClient)),a.maxCacheSize&&a.maxCacheSize!==this.cache.getMax()&&this.cache.setMax(a.maxCacheSize),a.maxCacheTime&&a.maxCacheTime!==this.cache.getMaxTime()&&this.cache.setMaxTime(a.maxCacheTime),yield H(e,{options:a,operators:t.excludeOperators?l(kt,t.excludeOperators,b):this.operators,operatorAliases:this.operatorAliases,typeChecker:a.skipRuntimeTypeCheck?()=>{}:this.typeChecker,resolvedAliasNodes:{},cache:this.cache,graphQLClient:this.graphQLClient,httpClient:this.httpClient})}))}getOptions(){return this.options}updateOptions(e){this.options=v(this.options,Ft(e)),this.options.excludeOperators&&(this.operators=l(kt,this.options.excludeOperators,b))}getOperators(){const e=this.options.excludeOperators?l(kt,this.options.excludeOperators,b):this.operators,t=Object.entries(e).map((([e,t])=>Object.assign({name:e},t.operatorData))),r=[...new Set(Object.values(b))];return t.sort(((e,t)=>r.indexOf(e.name)-r.indexOf(t.name)))}getFragments(){var e;return Object.entries(null!==(e=this.options.fragments)&&void 0!==e?e:{}).map((([e,t])=>Object.assign({name:e},null==t?void 0:t.metadata)))}getCustomFunctions(){var e;return Object.entries(null!==(e=this.options.functions)&&void 0!==e?e:{}).map((([e,t])=>({name:e,numRequiredArgs:t.length})))}}const Bt=(e,t)=>new Mt(t).evaluate(e),Ft=e=>"objects"in e?Object.assign(Object.assign({},e),{data:e.objects}):e,Gt=e=>({query:({query:t,values:r=[]})=>a(void 0,void 0,void 0,(function*(){const a={text:t,values:null!=r?r:[]},i=yield e.query(a);if(null==i?void 0:i.error)throw new Error(i.error);return i.rows}))}),zt=e=>({query:({query:t,values:r=[]})=>a(void 0,void 0,void 0,(function*(){try{return yield e.all(t,r)}catch(e){throw`SQLite error: ${null==e?void 0:e.message}`}}))});export{$t as AxiosClient,Ht as FetchClient,Mt as FigTreeEvaluator,Gt as SQLNodePostgres,zt as SQLite,Bt as evaluateExpression,p as isAliasString,s as isFragmentNode,g as isObject,i as isOperatorNode,C as preProcessShorthand,n as standardiseOperatorName,u as truncateString};
1
+ import{camelCase as e}from"change-case";import r from"object-property-extractor";import{dequal as t}from"dequal/lite";import a from"querystring";function i(e,r,t,a){return new(t||(t=Promise))((function(i,s){function n(e){try{l(a.next(e))}catch(e){s(e)}}function o(e){try{l(a.throw(e))}catch(e){s(e)}}function l(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(n,o)}l((a=a.apply(e,r||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s=e=>e instanceof Object&&"operator"in e,n=e=>e instanceof Object&&"fragment"in e,o=r=>{const t=e(r);return t||r},l=(e,r)=>r[o(e)],u=(e,r,t)=>{const a=Object.assign({},e);return r.forEach((e=>{t[o(e)]||console.warn(`Invalid operator exclusion: ${e}`),delete a[t[o(e)]]})),a},d=(e,r=200)=>e.length<r?e:`${e.slice(0,r-2).trim()}...`,c=({fallback:e,operator:r,name:t,error:a,expression:i,returnErrorAsString:s=!1})=>{var n,o;if(void 0!==e)return e;const l="string"==typeof a?new Error(a):a;if(t&&(l.name=t),"Error"===l.name&&(l.name="FigTreeError"),l.expression=null!==(n=l.expression)&&void 0!==n?n:i,l.operator=null!==(o=l.operator)&&void 0!==o?o:r,!s)throw l;const u=(r?"Operator: "+r:"")+("FigTreeError"===l.name?"":` - ${l.name}`),c=l.errorData?"\n"+JSON.stringify(l.errorData,null,2):"";return`${""!==u?u+"\n":""}${d(l.message)}${"\n{}"===c?"":c}`},p=(e,r)=>{const t=Object.entries(e).map((([e,t])=>[r(e),t]));return Object.fromEntries(t)},h=e=>/^\$.+/.test(e),v=(e,{resolvedAliasNodes:r})=>{var t;return"string"==typeof e&&h(e)&&null!==(t=null==r?void 0:r[e])&&void 0!==t?t:e},m=(e,r)=>{const t=Object.assign(Object.assign({},e),r);return(e.data||r.data)&&(t.data=Object.assign(Object.assign({},e.data),r.data)),(e.functions||r.functions)&&(t.functions=Object.assign(Object.assign({},e.functions),r.functions)),(e.fragments||r.fragments)&&(t.fragments=Object.assign(Object.assign({},e.fragments),r.fragments)),(e.headers||r.headers)&&(t.headers=Object.assign(Object.assign({},e.headers),r.headers)),t},y={number:e=>f(e),string:e=>String(e),array:e=>Array.isArray(e)?e:[e],boolean:e=>Boolean(e),bool:e=>Boolean(e)},f=e=>{if("string"!=typeof e)return Number.isNaN(Number(e))?e:Number(e);const r=new RegExp(/-?\d*\.?\d+/gm),t=e.match(r);return t?Number(t[0]):0},g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b={and:"AND","&":"AND","&&":"AND",or:"OR","|":"OR","||":"OR","=":"EQUAL",eq:"EQUAL",equal:"EQUAL",equals:"EQUAL","!=":"NOT_EQUAL","!":"NOT_EQUAL",ne:"NOT_EQUAL",notEqual:"NOT_EQUAL","+":"PLUS",plus:"PLUS",add:"PLUS",concat:"PLUS",join:"PLUS",merge:"PLUS","-":"SUBTRACT",subtract:"SUBTRACT",minus:"SUBTRACT",takeaway:"SUBTRACT","*":"MULTIPLY",x:"MULTIPLY",multiply:"MULTIPLY",times:"MULTIPLY","/":"DIVIDE",divide:"DIVIDE","÷":"DIVIDE",">":"GREATER_THAN",greaterThan:"GREATER_THAN",higher:"GREATER_THAN",larger:"GREATER_THAN","<":"LESS_THAN",lessThan:"LESS_THAN",lower:"LESS_THAN",smaller:"LESS_THAN","?":"CONDITIONAL",conditional:"CONDITIONAL",ifThen:"CONDITIONAL",regex:"REGEX",patternMatch:"REGEX",regexp:"REGEX",matchPattern:"REGEX",dataProperties:"OBJECT_PROPERTIES",data:"OBJECT_PROPERTIES",getData:"OBJECT_PROPERTIES",objectProperties:"OBJECT_PROPERTIES",objProps:"OBJECT_PROPERTIES",getProperty:"OBJECT_PROPERTIES",getObjProp:"OBJECT_PROPERTIES",stringSubstitution:"STRING_SUBSTITUTION",substitute:"STRING_SUBSTITUTION",stringSub:"STRING_SUBSTITUTION",replace:"STRING_SUBSTITUTION",split:"SPLIT",arraySplit:"SPLIT",count:"COUNT",length:"COUNT",get:"GET",api:"GET",post:"POST",sql:"SQL",pgSql:"SQL",postgres:"SQL",pg:"SQL",sqLite:"SQL",sqlite:"SQL",mySql:"SQL",graphQl:"GRAPHQL",graphql:"GRAPHQL",gql:"GRAPHQL",buildObject:"BUILD_OBJECT",build:"BUILD_OBJECT",object:"BUILD_OBJECT",match:"MATCH",switch:"MATCH",customFunctions:"CUSTOM_FUNCTIONS",customFunction:"CUSTOM_FUNCTIONS",objectFunctions:"CUSTOM_FUNCTIONS",function:"CUSTOM_FUNCTIONS",functions:"CUSTOM_FUNCTIONS",runFunction:"CUSTOM_FUNCTIONS",_:"PASSTHRU",passThru:"PASSTHRU",passthru:"PASSTHRU",pass:"PASSTHRU",ignore:"PASSTHRU",coerce:"PASSTHRU",convert:"PASSTHRU"},T=b,O=/(\$[^()]+)\((.*)\)/,C=(e,r={},t=!0)=>t?"string"==typeof e?q(e,r):g(e)?E(e,r):e:e,q=(e,r)=>{const t=O.exec(e);if(!t)return e;const a=t[1].trim(),i=t[2].split(",").map((e=>C(e.trim(),r)));return S(a,i,r)},E=(e,r)=>{if(s(e)||n(e))return e;const t=Object.entries(e),a=t.filter((([e])=>h(e))),i=t.filter((([e])=>!h(e))),o=a.reduce(((e,[t,a])=>e=Object.assign(Object.assign({},e),S(t,a,r))),{});return Object.assign(Object.assign({},o),Object.fromEntries(i))},S=(e,r,t)=>{const a=e.slice(1),i=l(a,T);return i?Array.isArray(r)?{operator:i,children:r}:g(r)&&!Object.keys(r).some((e=>h(e)))?Object.assign({operator:i},r):{operator:i,children:[r]}:a in t?{fragment:a,parameters:Object.assign({},r)}:{[e]:r}},j=e=>g(e)&&"literal"in e,A=({value:e,name:r,expectedType:t})=>{if(j(t)){const{literal:a}=t;return!!a.includes(e)||x(r,e,`Literal(${a.map((e=>void 0===e?"undefined":`"${e}"`)).join(", ")})`)}if(Array.isArray(t))return!!t.some((t=>!0===A({value:e,name:r,expectedType:t})))||x(r,e,t.join("|"));return!!(0,N[t])(e)||x(r,e,t)},w=(...e)=>{const r=[];return e.forEach((e=>{const t=A(e);!0!==t&&r.push(t)})),!(r.length>0)||r.join("\n")},N={any:e=>void 0!==e,string:e=>"string"==typeof e,number:e=>"number"==typeof e,boolean:e=>"boolean"==typeof e,array:e=>Array.isArray(e),null:e=>null===e,object:e=>g(e),undefined:e=>void 0===e},x=(e,r,t)=>void 0===r&&e?`- Missing required property "${e}" (type: ${t})`:void 0!==e?`- Property "${e}" (value: ${P(r)}) is not of type: ${t}`:`- ${P(r)} is not of type: ${t}`,P=e=>{const r=void 0===e||Number.isNaN(e)?String(e):JSON.stringify(e);return d(r,50)},L=e=>{const r={};return e.forEach((e=>{e.aliases.forEach((t=>r[t]=e.name))})),r},I=(e,r)=>e.map((({name:e,required:t,type:a})=>{if(j(a)){const i=[...a.literal];return t||i.push(void 0),{name:e,value:r[e],expectedType:{literal:i}}}const i=Array.isArray(a)?a:[a];t||i.push("undefined");const s=1===i.length?i[0]:i;return{name:e,value:r[e],expectedType:s}})),U=(e,r)=>{const t=e.map(((e,t)=>[e,r[t]]));return Object.fromEntries(t)},k=e=>{if(e.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const r=e.filter(((e,r)=>r%2==0)),t=w(...r.map((e=>({value:e,expectedType:["string","number","boolean"]}))));if(!0!==t)throw new Error(t);const a=e.filter(((e,r)=>r%2==1)),i={};return r.forEach(((e,r)=>{i[e]=a[r]})),i},R=e=>g(e)&&1===Object.keys(e).length?Object.values(e)[0]:e,D=(e,t,a=void 0)=>{const i=t?r(e,t,a):e;return Array.isArray(i)?i.map((e=>R(e))):t?null===i?null:R(i):i},_=e=>/^https?:\/\/.+/.test(e),Q=(...e)=>e.reduce(((e,r,t)=>{const a="/"===r[0]?1:0,i="/"===r.slice(-1)?-1:void 0,s=r.slice(a,i);return""===s?e:e+(0===t?"":"/")+s}),""),H=(e,r)=>i(void 0,void 0,void 0,(function*(){const{url:t,params:a={},data:i={},headers:s={},method:n="get"}=r;if(!t||""===t)throw new Error("Invalid url");try{return yield e[n]({url:t,headers:Object.assign({"Content-Type":"application/json",Accept:"application/json"},s),params:a,data:i})}catch(r){e.throwError(r)}})),M=(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,i,o;const{options:u,operators:d,operatorAliases:h}=r;let m=(null==u?void 0:u.allowJSONStringInput)?(e=>{if("string"!=typeof e)return e;try{const r=JSON.parse(e);return s(r)?r:e}catch(r){return e}})(e):e;m=C(m,null===(t=r.options)||void 0===t?void 0:t.fragments,!u.noShorthand),Array.isArray(m)&&(m=yield $(m,r));const f=s(m),b=n(m);if(u.evaluateFullObject&&!f&&!b)return v(yield B(m,r),r);if(!f&&!b)return u.supportDeprecatedValueNodes&&g(m)&&"value"in m?m.value:v(m,r);const{fallback:T}=m,O=null!==(a=null==u?void 0:u.returnErrorAsString)&&void 0!==a&&a;if(b){const[e,t]=yield $([m.fragment,m.parameters],r),a=C(null===(i=null==u?void 0:u.fragments)||void 0===i?void 0:i[e],u.fragments,!u.noShorthand);if(void 0===a)return c({fallback:yield M(T,r),error:`Fragment not defined: ${e}`,expression:m,returnErrorAsString:O});if(!s(a))return v(a,r);m=Object.assign(Object.assign(Object.assign({},m),a),t),delete m.fragment}try{const e=l(m.operator,h);if(!e)return c({fallback:yield M(T,r),error:`Invalid operator: ${m.operator}`,expression:m,returnErrorAsString:O});if(!r.operators[e])return c({fallback:yield M(T,r),error:`Excluded operator: ${m.operator}`,expression:m,returnErrorAsString:O});const{propertyAliases:t,evaluate:a,parseChildren:i}=d[e];m=((e,r)=>p(r,(r=>r in e?e[r]:r)))(t,m);const s=yield F(m,r);b||Object.entries(s).forEach((([e,t])=>r.resolvedAliasNodes[e]=t));const n=b?Object.assign(Object.assign({},r),{resolvedAliasNodes:Object.assign(Object.assign({},r.resolvedAliasNodes),s)}):r;if("children"in m){if(Array.isArray(m.children)||(m.children=yield M(m.children,n)),!Array.isArray(m.children))return c({fallback:yield M(T,r),operator:e,name:"Type Error",error:'- Property "children" is not of type: array',expression:m,returnErrorAsString:O});m=yield i(m,n),delete m.children}let u;try{u=yield a(m,n)}catch(t){return c({fallback:yield M(m.fallback,r),operator:e,error:t,expression:m,returnErrorAsString:O})}const v=null!==(o=null==m?void 0:m.outputType)&&void 0!==o?o:null==m?void 0:m.type;if(!v)return u;const f=yield M(v,r);return f in y?y[f](u):c({fallback:yield M(T,r),operator:e,error:`- Invalid output type: ${f}`,expression:m,returnErrorAsString:O})}catch(e){return c({fallback:yield M(T,r),error:e,expression:m,returnErrorAsString:O})}})),$=(e,r)=>i(void 0,void 0,void 0,(function*(){return Array.isArray(e)?yield Promise.all(e.map((e=>M(e,r)))):yield M(e,r)})),F=(e,r)=>i(void 0,void 0,void 0,(function*(){const t=Object.keys(e).filter(h);if(0===t.length)return{};const a=[];return t.forEach((t=>a.push(M(e[t],r)))),U(t,yield Promise.all(a))})),B=(e,r)=>i(void 0,void 0,void 0,(function*(){if(!g(e))return e;const t=[],a=[];Object.entries(e).forEach((([t,i])=>{h(t)&&(a.push(t,M(i,r)),delete e[t])}));const i=yield Promise.all(a);r.resolvedAliasNodes=Object.assign(Object.assign({},r.resolvedAliasNodes),k(i)),Object.entries(e).forEach((([e,a])=>{t.push(e,M(a,r))}));const s=yield Promise.all(t);return v(k(s),r)})),G=[{name:"values",description:"Returns true if all values are true",aliases:[],required:!0,type:"array",default:[!0,!0]}],z=L(G),W={description:"Logical AND",aliases:["and","&","&&"],parameters:G},J=e=>{const r=e.children;return Object.assign(Object.assign({},e),{values:r})},V={propertyAliases:z,operatorData:W,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield $(e.values,r);return r.typeChecker(I(W.parameters,{values:t})),t.reduce(((e,r)=>e&&!!r),!0)})),parseChildren:J},Y=[{name:"values",description:"Returns true if any values are true",aliases:[],required:!0,type:"array",default:[!0,!1]}],X=L(Y),K={description:"Logical OR",aliases:["or","|","||"],parameters:Y},Z={propertyAliases:X,operatorData:K,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield $(e.values,r);return r.typeChecker(I(K.parameters,{values:t})),t.reduce(((e,r)=>e||!!r),!1)})),parseChildren:J},ee=[{name:"values",description:"Array of values to check for equality",aliases:[],required:!0,type:"array",default:["These are equal","These are equal"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],re=L(ee),te={description:"Test multiple values are equal",aliases:["=","eq","equal","equals"],parameters:ee},ae={propertyAliases:re,operatorData:te,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield $([e.values,e.caseInsensitive,e.nullEqualsUndefined],r);r.typeChecker(I(te.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=r.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=r.options)||void 0===s?void 0:s.nullEqualsUndefined)&&r.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.every((e=>t(e,u[0]))):u.every((e=>null==e))})),parseChildren:J},ie=[{name:"values",description:"Array of values to check for inequality",aliases:[],required:!0,type:"array",default:["These items","don't match"]},{name:"caseInsensitive",description:"If the values are strings, ignore the case (default: false)",aliases:[],required:!1,type:"boolean",default:!1},{name:"nullEqualsUndefined",description:"Whether a null value should be considered equal to an undefined value (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],se=L(ie),ne={description:"Test if any values are different",aliases:["!=","!","ne","notEqual"],parameters:ie},oe={propertyAliases:se,operatorData:ne,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var a,i,s;const[n,o,l]=yield $([e.values,e.caseInsensitive,e.nullEqualsUndefined],r);r.typeChecker(I(ne.parameters,{values:n,caseInsensitive:o,nullEqualsUndefined:l}));const u=(void 0!==o?o:null!==(i=null===(a=r.options)||void 0===a?void 0:a.caseInsensitive)&&void 0!==i&&i)&&n.every((e=>"string"==typeof e))?n.map((e=>e.toLowerCase())):n;return!(void 0!==l?l:void 0!==(null===(s=r.options)||void 0===s?void 0:s.nullEqualsUndefined)&&r.options.nullEqualsUndefined)||null!==u[0]&&void 0!==u[0]?u.some((e=>!t(e,u[0]))):u.some((e=>null===e&&void 0===e))})),parseChildren:J},le=[{name:"values",description:"Array of values to check to add together",aliases:[],required:!0,type:"array",default:[1,2,3]},{name:"type",description:"Data type to coerce input values to before addition",aliases:[],required:!1,type:{literal:["string","array","number","boolean","bool"]},default:"string"}],ue=L(le),de={description:"Add, concatenate or merge multiple values",aliases:["+","plus","add","concat","join","merge"],parameters:le},ce={propertyAliases:ue,operatorData:de,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield $(e.values,r);return r.typeChecker(I(de.parameters,{values:t,type:e.type})),0===t.length?t:"string"===(null==e?void 0:e.type)?t.reduce(((e,r)=>e.concat(r)),""):"array"===(null==e?void 0:e.type)?t.reduce(((e,r)=>e.concat(r)),[]):t.every((e=>"string"==typeof e||Array.isArray(e)))?t.reduce(((e,r)=>e.concat(r))):t.every((e=>g(e)))?t.reduce(((e,r)=>Object.assign(Object.assign({},e),r)),{}):t.reduce(((e,r)=>e+r))})),parseChildren:J},pe=[{name:"values",description:"Array of values - 2nd element will be subtracted from the first",aliases:[],required:!1,type:"array",default:[10,5]},{name:"from",description:"Numerical value that will be subtracted from",aliases:["subtractFrom"],required:!1,type:"number",default:100},{name:"subtract",description:"Numerical value to subtract",aliases:[],required:!1,type:"number",default:50}],he=L(pe),ve={description:"Subtract one numerical value from another",aliases:["-","subtract","minus","takeaway"],parameters:pe},me={propertyAliases:he,operatorData:ve,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a,i]=yield $([e.values,e.from,e.subtract],r);r.typeChecker(I(ve.parameters,{values:t,from:a,subtract:i}));const s=null!=t?t:[a,i].filter((e=>void 0!==e));if(s.length<2)throw new Error("- Not enough values provided");if(s.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return s[0]-s[1]})),parseChildren:J},ye=[{name:"values",description:"Array of values whose product will be calculated",aliases:[],required:!0,type:"array",default:[5,5]}],fe=L(ye),ge={description:"Multiply several numerical values together",aliases:["*","x","multiply","times"],parameters:ye},be={propertyAliases:fe,operatorData:ge,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield $(e.values,r);if(r.typeChecker(I(ge.parameters,{values:t})),0===t.length)return 0;if(t.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");return t.reduce(((e,r)=>e*r))})),parseChildren:J},Te=[{name:"values",description:"Array of values - 1st element will be divided by the first",aliases:[],required:!1,type:"array",default:[100,10]},{name:"dividend",description:"The number that will be divided",aliases:["divide"],required:!1,type:"number",default:99},{name:"divisor",description:"The number that dividend will be divided by",aliases:["by","divideBy"],required:!1,type:"number",default:3},{name:"output",description:"Whether to output a quotient, remainder or decimal",aliases:[],required:!1,type:{literal:["quotient","remainder"]},default:"quotient"}],Oe=L(Te),Ce={description:"Divide one numerical value by another",aliases:["/","divide","÷"],parameters:Te},qe={propertyAliases:Oe,operatorData:Ce,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a,i,s]=yield $([e.values,e.dividend,e.divisor,e.output],r);r.typeChecker(I(Ce.parameters,{values:t,dividend:a,divisor:i,output:s}));const n=null!=t?t:[a,i].filter((e=>void 0!==e));if(n.length<2)throw new Error("- Not enough values provided");if(n.some((e=>"number"!=typeof e)))throw new Error("- Not all values are numbers");if(0===n[1])throw new Error("Division by zero!");switch(s){case"quotient":return Math.floor(n[0]/n[1]);case"remainder":return n[0]%n[1];default:return n[0]/n[1]}})),parseChildren:J},Ee=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[10,9]},{name:"strict",description:"Whether value must be strictly greater than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Se=L(Ee),je={description:"Test if a value is greater than (or equal to) another value",aliases:[">","greaterThan","higher","larger"],parameters:Ee},Ae={propertyAliases:Se,operatorData:je,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a=!0]=yield $([e.values,e.strict],r);if(r.typeChecker(I(je.parameters,{values:t,strict:a})),t.length<2)throw new Error("- Not enough values provided");const[i,s]=t;return i===s&&!a||i>s})),parseChildren:J},we=[{name:"values",description:"Array of values - 1st element will be compared to the second",aliases:[],required:!0,type:"array",default:[9,10]},{name:"strict",description:"Whether value must be strictly smaller than (i.e. not equal) (default: false)",aliases:[],required:!1,type:"boolean",default:!1}],Ne=L(we),xe={description:"Test if a value is smaller than (or equal to) another value",aliases:["<","lessThan","lower","smaller"],parameters:we},Pe={propertyAliases:Ne,operatorData:xe,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a=!0]=yield $([e.values,e.strict],r);if(r.typeChecker(I(xe.parameters,{values:t,strict:a})),t.length<2)throw new Error("- Not enough values provided");const[i,s]=t;return i===s&&!a||i<s})),parseChildren:J},Le=[{name:"condition",description:"The expression to check for truthiness",aliases:[],required:!0,type:"any",default:!0},{name:"valueIfTrue",description:"Value to return if condition is true",aliases:["ifTrue"],required:!0,type:"any",default:"The condition is true"},{name:"valueIfFalse",description:"Value to return if condition is false",aliases:["ifFalse","ifNot"],required:!0,type:"any",default:"The condition is false"}],Ie=L(Le),Ue={description:"Return a value based on a condition",aliases:["?","conditional","ifThen"],parameters:Le},ke={propertyAliases:Ie,operatorData:Ue,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){r.typeChecker(I(Ue.parameters,{condition:e.condition,valueIfTrue:e.valueIfTrue,valueIfFalse:e.valueIfFalse}));return(yield M(e.condition,r))?yield M(e.valueIfTrue,r):yield M(e.valueIfFalse,r)})),parseChildren:e=>{const[r,t,a]=e.children;return Object.assign(Object.assign({},e),{condition:r,valueIfTrue:t,valueIfFalse:a})}},Re=[{name:"testString",description:"The string to test",aliases:["string","value"],required:!0,type:"string",default:"test-this"},{name:"pattern",description:"The regular expression pattern",aliases:["regex","regexp","regExp","re"],required:!0,type:"string",default:"^[a-z]{4}-[a-z]{4}$"}],De=L(Re),_e={description:"Compare a string against a regex pattern",aliases:["regex","patternMatch","regexp","matchPattern"],parameters:Re},Qe={propertyAliases:De,operatorData:_e,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a]=yield $([e.testString,e.pattern],r);r.typeChecker(I(_e.parameters,{testString:t,pattern:a}));return new RegExp(a).test(t)})),parseChildren:e=>{const[r,t]=e.children;return Object.assign(Object.assign({},e),{testString:r,pattern:t})}},He=[{name:"property",description:'The path to the required property (e.g. "user.firstName")',aliases:["path","propertyName"],required:!0,type:"string",default:"path.to[0].my.data"},{name:"additionalData",description:"Additional data objects to be considered",aliases:["additional","objects","data","additionalObjects"],required:!1,type:"object",default:{}}],Me=L(He),$e={description:"Extract values from data objects",aliases:["dataProperties","data","getData","objectProperties","objProps","getProperty","getObjProp"],parameters:He},Fe={propertyAliases:Me,operatorData:$e,evaluate:(e,t)=>i(void 0,void 0,void 0,(function*(){var a,i;const[s,n={}]=yield $([e.property,e.additionalData],t);t.typeChecker(I($e.parameters,{property:s,additionalData:n}));const o=Object.assign(Object.assign({},null!==(i=null===(a=t.options)||void 0===a?void 0:a.data)&&void 0!==i?i:{}),n);return r(o,s)})),parseChildren:e=>{const[r,t]=e.children,a=Object.assign(Object.assign({},e),{property:r});return void 0!==t&&(a.fallback=t),a}},Be=[{name:"string",description:"A parameterised (%1, %2) string where the parameters are to be replaced",aliases:[],required:!0,type:"string",default:"Hello, %1"},{name:"substitutions",description:"An array of substitution values for the parameterised string",aliases:["replacements","values"],required:!1,type:["array","object"],default:["friend"]},{name:"trimWhiteSpace",description:"Whether or not to trim white space from either end of the substituted strings (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"substitutionCharacter",description:'Which character to search for in original string for replacement -- can be "%" or "$" (default: "%")',aliases:["subCharacter","subChar"],required:!1,type:"string",default:"$"},{name:"numberMapping",description:"Rules for mapping number values to text strings, such as pluralisation.",aliases:["numMap","numberMap","pluralisation","pluralization","plurals"],required:!1,type:"object",default:{}}],Ge=L(Be),ze={description:"Replace values in a string using simple parameter substitution",aliases:["stringSubstitution","substitute","stringSub","replace"],parameters:Be},We={propertyAliases:Ge,operatorData:ze,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a={},i=!0,s="%",n={}]=yield $([e.string,e.substitutions,e.trimWhiteSpace,e.substitutionCharacter,e.numberMapping],r);if(r.typeChecker(I(ze.parameters,{string:t,substitutions:a,trimWhiteSpace:i,substitutionCharacter:s,numberMapping:n})),Array.isArray(a)){const e="$"===s?"$":"%",r=new RegExp(`(?<!\\\\)(${"%"===e?"%":"\\$"}[\\d]+)`,"g"),n=(t.match(r)||[]).sort(((e,r)=>Number(e.slice(1))-Number(r.slice(1)))),o=new Set(n),l=U(Array.from(o),a.map((e=>i?String(e).trim():e)));return t.split(r).map((e=>e in l?l[e]:e)).join("").replace(`\\${e}`,e)}return t.split(/(?<!\\)({{(?:[A-Za-z0-9_.]|\[[0-9]+\])+}})/g).map((e=>{if(!/(?<!\\){{(.+)}}/.exec(e))return e.replace("\\{{","{{");const t=Je(e,a,n,r.options.data);return i?String(t).trim():t})).join("")})),parseChildren:e=>{const[r,...t]=e.children;return Object.assign(Object.assign({},e),{string:r,substitutions:t})}},Je=(e,t,a,i={})=>{const s=e.replace(/{{(.+)}}/,"$1"),n=r(t,s,r(i,s,""));if("number"!=typeof n)return n;if(!(s in a))return n;const o=a[s];if(n in o)return o[n].replace("{}",String(n));const l=Object.keys(a[s]),u=l.find((e=>e.startsWith(">")));if(u){if(n>Number(u.slice(1)))return null==o?void 0:o[u]}const d=l.find((e=>e.startsWith("<")));if(d){if(n<Number(d.slice(1)))return null==o?void 0:o[d]}return o.other?o.other.replace("{}",String(n)):n},Ve=[{name:"values",description:"An array to count",aliases:[],required:!0,type:"array",default:[1,2,3,4,5]}],Ye=L(Ve),Xe={description:"Count elements in an array",aliases:["count","length"],parameters:Ve},Ke={propertyAliases:Ye,operatorData:Xe,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){const t=yield $(e.values,r);return r.typeChecker(I(Xe.parameters,{values:t})),t.length})),parseChildren:e=>{const[r]=e.children;return Object.assign(Object.assign({},e),{values:r})}},Ze=[{name:"value",description:"The string to be split",aliases:["string"],required:!0,type:"string",default:"Alpha, Bravo, Charlie"},{name:"delimiter",description:"The value to split the string on (default is white space)",aliases:["separator"],required:!1,type:"string",default:","},{name:"trimWhiteSpace",description:"Whether to trim white space from around the resulting elements (default: true)",aliases:["trim","trimWhitespace"],required:!1,type:"boolean",default:!0},{name:"excludeTrailing",description:"If the input string ends in a delimiter, there will be an additional blank element if this value is false (default: true)",aliases:["removeTrailing","excludeTrailingDelimiter"],required:!1,type:"boolean",default:!0}],er=L(Ze),rr={description:"Split a string into an array",aliases:["split","arraySplit"],parameters:Ze},tr=" ",ar={propertyAliases:er,operatorData:rr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,i;const[s,n,o,l]=yield $([e.value,null!==(t=e.delimiter)&&void 0!==t?t:tr,null===(a=e.trimWhiteSpace)||void 0===a||a,null===(i=e.excludeTrailing)||void 0===i||i],r);r.typeChecker(I(rr.parameters,{value:s,delimiter:n,trimWhiteSpace:o,excludeTrailing:l}));let u=s.split(n);return o&&(u=u.map((e=>e.trim()))),l&&""===u[u.length-1]&&u.pop(),u})),parseChildren:e=>{const[r,t=tr]=e.children;return Object.assign(Object.assign({},e),{value:r,delimiter:t})}},ir=[{name:"query",description:"SQL query string, with parameterised replacements (e.g. $1, $2, etc)",aliases:["text"],required:!0,type:"string"},{name:"values",description:"An array/object of values to replace the SQL string parameters, as per SQL connection specifications ",aliases:["replacements"],required:!1,type:["array","object"]},{name:"single",description:"Specify if returning a single record",aliases:["singleRecord"],required:!1,type:"boolean"},{name:"flatten",description:"Specify whether to flatten resulting record objects to arrays of values",aliases:["flat","array"],required:!1,type:"boolean"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean"}],sr=L(ir),nr={description:"Query an SQL database",aliases:["sql","pgSql","postgres","pg","sqLite","sqlite","mySql"],parameters:ir},or={propertyAliases:sr,operatorData:nr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s;const n=null===(t=r.options)||void 0===t?void 0:t.sqlConnection;if(!n)throw new Error("No SQL database connection provided");const[o,l,u,d,c,p]=yield $([e.query,e.values||[],e.single,e.flatten,e.useCache,e.type],r);r.typeChecker(I(nr.parameters,{query:o,single:u,flatten:d,values:l,useCache:c}));const h=null===(s=null!==(a=e.useCache)&&void 0!==a?a:r.options.useCache)||void 0===s||s;{const e=r.cache.useCache(h,((e,r,t,a,s)=>i(void 0,void 0,void 0,(function*(){const i=(yield n.query({query:e,values:r}))||[];["array","string","number"].includes(null!=s?s:"")&&(a=!0);const o=a?i.map((e=>{const r=Object.values(e);return r.length<=1?r[0]:r})):i;return t?o[0]:o}))),o,l,u,d,p);return e}})),parseChildren:e=>{const[r,...t]=e.children;return Object.assign(Object.assign({},e),{query:r,values:t})}},lr=[{name:"query",description:"GraphQL query string",aliases:[],required:!0,type:"string",default:'query getCountries {\n countries(filter: {continent: {eq: "OC"}}) {\n name\n }\n }'},{name:"url",description:"Endpoint for the GraphQL request (if not already provided in options)",aliases:["endpoint"],required:!1,type:["string","null"],default:"https://countries.trevorblades.com/"},{name:"headers",description:"HTTP Headers (if not already provided in options)",aliases:[],required:!1,type:"object",default:{}},{name:"variables",description:"Values for the variables used in query (key-value pairs)",aliases:[],required:!1,type:"object",default:{}},{name:"returnNode",description:"Property path to extract from the query response",aliases:["outputNode","returnProperty"],required:!1,type:"string",default:"data.countries[1].name"},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],ur=L(lr),dr={description:"GraphQL request",aliases:["graphQl","graphql","gql"],parameters:lr},cr={propertyAliases:ur,operatorData:dr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s,n,o,l,u;const d=null!==(t=r.graphQLClient)&&void 0!==t?t:r.httpClient;if(!d)throw new Error("No HTTP client provided for GraphQL connection");const[c,p,h,v,m,y]=yield $([e.query,e.url,e.variables,e.returnNode,e.headers,e.useCache],r),{url:f,headers:g}=p instanceof Object?p:{url:p,headers:null};r.typeChecker([...I(dr.parameters,{url:f,query:c,variables:h,returnNode:v,headers:m,useCache:y}),{name:"headers",value:g,expectedType:["object","null"]}]);const b=f&&"graphqlendpoint"!==f.toLowerCase()?f:"",T=null!==(n=null!==(s=null===(a=r.options.graphQLConnection)||void 0===a?void 0:a.endpoint)&&void 0!==s?s:r.options.baseEndpoint)&&void 0!==n?n:"",O=_(b)?b:Q(T,b),C={query:c,variables:h},q=null===(o=null!=y?y:r.options.useCache)||void 0===o||o,E=yield r.cache.useCache(q,((e,r,t,a)=>i(void 0,void 0,void 0,(function*(){const i=yield H(d,{url:e,method:"post",data:r,headers:t});return D(null==i?void 0:i.data,a)}))),O,C,Object.assign(Object.assign(Object.assign(Object.assign({},null===(l=r.options.graphQLConnection)||void 0===l?void 0:l.headers),null===(u=r.options)||void 0===u?void 0:u.headers),g),m),v);return E})),parseChildren:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,a="",i,...s]=yield $(e.children,r),n=Array.isArray(i)?i:[i],o=s.slice(0,n.length),l=U(n,o),u=Object.assign(Object.assign({},e),{query:t,url:a,variables:l});return s.length>n.length&&(u.returnNode=s.pop()),u}))},pr=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://restcountries.com/v3.1/name/zealand"},{name:"returnProperty",description:"Property from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"Query parameters (key-value)",aliases:["queryParams","queryParameters","urlQueries"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],hr=L(pr),vr={description:"HTTP GET Request",aliases:["get","api"],parameters:pr},mr=(e,r)=>i(void 0,void 0,void 0,(function*(){const[t="",a,...i]=yield $(e.children,r),s=Array.isArray(a)?a:[a],n=i.slice(0,s.length),o=U(s,n),l=Object.assign(Object.assign({},e),{url:t,parameters:o});return i.length>s.length&&(l.returnProperty=i.pop()),l})),yr=mr,fr={propertyAliases:hr,operatorData:vr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s;const n=r.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield $([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],r),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};r.typeChecker([...I(vr.parameters,{url:p,returnProperty:u,headers:d,parameters:l,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(t=r.options.baseEndpoint)&&void 0!==t?t:"",m=Object.assign(Object.assign(Object.assign({},null===(a=r.options)||void 0===a?void 0:a.headers),h),d),y=null===(s=null!=c?c:r.options.useCache)||void 0===s||s,f=yield r.cache.useCache(y,((e,r,t,a)=>i(void 0,void 0,void 0,(function*(){const i=yield H(n,{url:e,params:r,headers:t});return D(i,a)}))),_(p)?p:Q(v,p),l,m,u);return f})),parseChildren:mr},gr=[{name:"url",description:"Endpoint URL",aliases:["endpoint"],required:!0,type:"string",default:"https://jsonplaceholder.typicode.com/posts"},{name:"returnProperty",description:"Property path from request result",aliases:["outputProperty"],required:!1,type:"string",default:"result.path"},{name:"headers",description:"HTTP Headers",aliases:[],required:!1,type:"object",default:{}},{name:"parameters",description:"JSON Body parameters (key-value)",aliases:["bodyJson","data"],required:!1,type:"object",default:{}},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!0}],br=L(gr),Tr={description:"HTTP POST Request",aliases:["post"],parameters:gr},Or={propertyAliases:br,operatorData:Tr,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t,a,s;const n=r.httpClient;if(!n)throw new Error("No HTTP client provided");const[o,l,u,d,c]=yield $([e.url,e.parameters,e.returnProperty,e.headers,e.useCache],r),{url:p,headers:h}=o instanceof Object?o:{url:o,headers:null};r.typeChecker([...I(Tr.parameters,{url:p,headers:d,data:l,returnProperty:u,useCache:c}),{name:"headers",value:h,expectedType:["object","null"]}]);const v=null!==(t=r.options.baseEndpoint)&&void 0!==t?t:"",m=Object.assign(Object.assign(Object.assign({},null===(a=r.options)||void 0===a?void 0:a.headers),h),d),y=null!==(s=null!=c?c:r.options.useCache)&&void 0!==s&&s,f=yield r.cache.useCache(y,((e,r,t,a)=>i(void 0,void 0,void 0,(function*(){const i=yield H(n,{url:e,data:r,headers:t,method:"post"});return D(i,a)}))),_(p)?p:Q(v,p),l,m,u);return f})),parseChildren:yr},Cr=[{name:"properties",description:'An array of objects, each with a "key" property and a "value" property',aliases:["values","keyValPairs","keyValuePairs"],required:!0,type:"array",default:["firstKey","firstValue","secondKey","secondValue"]}],qr=L(Cr),Er={description:"Construct an object using objects defining keys and values",aliases:["buildObject","build","object"],parameters:Cr},Sr={propertyAliases:qr,operatorData:Er,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){r.typeChecker(I(Er.parameters,{properties:e.properties}));const t=e.properties.filter((e=>e instanceof Object&&"key"in e&&"value"in e)).map((({key:e,value:t})=>{return a=[e,t],i(void 0,void 0,void 0,(function*(){const[e,t]=yield $(a,r);return r.typeChecker({name:"key",value:e,expectedType:["string","number","boolean"]}),[e,t]}));var a}));return Object.fromEntries(yield Promise.all(t))})),parseChildren:e=>{const r=e.children;if(r.length%2!=0)throw new Error("Even number of children required to make key/value pairs");const t=r.filter(((e,r)=>r%2==0)),a=r.filter(((e,r)=>r%2==1)),i=t.map(((e,r)=>({key:e,value:a[r]})));return Object.assign(Object.assign({},e),{properties:i})}},jr=[{name:"matchExpression",description:"Expression to match against",aliases:["match"],required:!0,type:["string","number","boolean"],default:"matchMe"},{name:"branches",description:"Object whose keys are compared against the match expression. The value of the matching key is returned",aliases:["arms","cases"],required:!1,type:["object","array"],default:{matchMe:"YES",nonMatch:"NO"}},{name:"[...branches]",description:"Branch properties can optionally be placed at the operator root",aliases:[],required:!1,type:["object","array"]}],Ar={propertyAliases:L(jr),operatorData:{description:"Return different values depending on a matching expression",aliases:["match","switch"],parameters:jr},evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){var t;const a=yield M(e.matchExpression,r);r.typeChecker({name:"matchExpression",value:a,expectedType:["string","number","boolean"]});const i=Array.isArray(e.branches)?k(e.branches):null!==(t=e.branches)&&void 0!==t?t:{},n=s(i)?yield M(i,r):i;if(!g(n))throw new Error("Branches don't evaluate to an object");if(a in n)return yield M(n[a],r);if("fallback"in n)return yield M(n.fallback,r);if(a in e)return yield M(e[a],r);throw new Error(`No match found for ${a}`)})),parseChildren:(e,r)=>i(void 0,void 0,void 0,(function*(){const[t,...a]=e.children,i=k(yield $(a,r));return Object.assign(Object.assign({},e),{matchExpression:t,branches:i})}))},wr=[{name:"functionPath",description:"Path (in options.functions) to the required function",aliases:["functionsPath","functionName","funcName","path","name"],required:!0,type:"string",default:null},{name:"args",description:"Arguments for the function",aliases:["arguments","variables"],required:!1,type:"array",default:[]},{name:"useCache",description:"Whether or not the FigTree cache is used",aliases:[],required:!1,type:"boolean",default:!1}],Nr=L(wr),xr={description:"Call a custom function (defined in options)",aliases:["customFunctions","customFunction","objectFunctions","function","functions","runFunction"],parameters:wr},Pr={propertyAliases:Nr,operatorData:xr,evaluate:(e,t)=>i(void 0,void 0,void 0,(function*(){var a,s,n;const[o,l=[],u]=yield $([e.functionPath,e.args,e.useCache],t);t.typeChecker(I(xr.parameters,{functionPath:o,args:l}));const{data:d,functions:c}=t.options,p=null!==(s=null!==(a=r(c,o,null))&&void 0!==a?a:r(d,o,null))&&void 0!==s?s:r(t.options,o,null);if(!p||"function"!=typeof p)throw new Error(`- No function found: "${o}"`);const h=null!==(n=null!=u?u:t.options.useCache)&&void 0!==n&&n;return yield t.cache.useCache(h,((e,...r)=>i(void 0,void 0,void 0,(function*(){return yield p(...r)}))),o,...l)})),parseChildren:e=>{const[r,...t]=e.children;return Object.assign(Object.assign({},e),{functionPath:r,args:t})}},Lr=[{name:"value",description:"Value to pass through",aliases:["_","data"],required:!0,type:"any",default:null}],Ir=L(Lr),Ur={description:"Pass through a value unchanged (or change its type)",aliases:["_","passThru","passthru","pass","ignore","coerce","convert"],parameters:Lr},kr={propertyAliases:Ir,operatorData:Ur,evaluate:(e,r)=>i(void 0,void 0,void 0,(function*(){return r.typeChecker(I(Ur.parameters,{value:e.value})),yield M(e.value,r)})),parseChildren:e=>{const[...r]=e.children,t=1===(null==r?void 0:r.length)?r[0]:r;return Object.assign(Object.assign({},e),{value:t})}};var Rr=Object.freeze({__proto__:null,AND:V,BUILD_OBJECT:Sr,CONDITIONAL:ke,COUNT:Ke,CUSTOM_FUNCTIONS:Pr,DIVIDE:qe,EQUAL:ae,GET:fr,GRAPHQL:cr,GREATER_THAN:Ae,LESS_THAN:Pe,MATCH:Ar,MULTIPLY:be,NOT_EQUAL:oe,OBJECT_PROPERTIES:Fe,OR:Z,PASSTHRU:kr,PLUS:ce,POST:Or,REGEX:Qe,SPLIT:ar,SQL:or,STRING_SUBSTITUTION:We,SUBTRACT:me});class Dr{constructor(e){var r,t;this.useCache=(e,r,...t)=>i(this,void 0,void 0,(function*(){if(!e)return yield r(...t);const a=_r(t),i=a in this.store,s=Date.now(),n=i&&s-this.store[a].timestamp>1e3*this.maxTime;if(i)return this.queue=this.queue.filter((e=>e!==a)),this.queue.unshift(a),this.store[a].timestamp=s,n&&(this.store[a].result=yield r(...t)),this.store[a].result;const o=yield r(...t);return this.store[a]={result:o,timestamp:s},this.queue.unshift(a),this.resizeCache(),o})),this.getMax=()=>this.maxSize,this.setMax=e=>{this.maxSize=e,this.resizeCache()},this.getMaxTime=()=>this.maxTime,this.setMaxTime=e=>{this.maxTime=e},this.getCache=()=>this.store,this.setCache=e=>this.store=e,this.resizeCache=()=>{if(this.queue.length>this.maxSize){this.queue.slice(this.maxSize).forEach((e=>delete this.store[e])),this.queue=this.queue.slice(0,this.maxSize)}},this.store={},this.queue=[],this.maxSize=null!==(r=null==e?void 0:e.maxSize)&&void 0!==r?r:50,this.maxTime=null!==(t=null==e?void 0:e.maxTime)&&void 0!==t?t:1800}}const _r=e=>e.map((e=>"object"==typeof e?JSON.stringify(e):e)).join("_"),Qr=e=>e?"name"in e&&"fetch"===e.name?Mr(e):"Axios"in e&&"Axios"===e.Axios.name?Hr(e):e:"undefined"!=typeof window&&"document"in window&&"fetch"in window?Mr(window.fetch):void 0,Hr=e=>({get:r=>i(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},r),{method:"get"}))).data})),post:r=>i(void 0,void 0,void 0,(function*(){return(yield e(Object.assign(Object.assign({},r),{method:"post"}))).data})),throwError:r=>{var t,a,i,s;if(e.isAxiosError(r)&&r.response)throw r.errorData={status:null===(t=r.response)||void 0===t?void 0:t.status,error:null===(a=r.response)||void 0===a?void 0:a.statusText,url:null===(i=r.config)||void 0===i?void 0:i.url,response:null===(s=r.response)||void 0===s?void 0:s.data},console.log(r.errorData),r;throw new Error("Network error: "+(null==r?void 0:r.message))}}),Mr=e=>({get:r=>i(void 0,void 0,void 0,(function*(){const{url:t,headers:i,params:s={}}=r,n=Object.keys(s).length>0?`?${a.stringify(s)}`:"",o=yield e(t+n,{headers:i,method:"GET"}),l=yield o.json();if(!o.ok){const e=new Error("Problem with GET request");throw e.name="FetchError",e.errorData={status:o.status,error:o.statusText,url:o.url,response:l},console.log(e.errorData),e}return l})),post:r=>i(void 0,void 0,void 0,(function*(){const{url:t,headers:a,params:i,data:s}=r,n=new URLSearchParams(i),o=n.size>0?`?${n.toString()}`:"",l=yield e(t+o,{headers:a,body:JSON.stringify(s),method:"POST"}),u=yield l.json();if(!l.ok){const e=new Error("Problem with POST request");throw e.name="FetchError",e.errorData={status:l.status,error:l.statusText,url:l.url,response:u},console.log(e.errorData),e}return u})),throwError:e=>{throw e}});class $r{constructor(e={}){var r,t,a;this.typeChecker=(...e)=>{const r=1===e.length&&Array.isArray(e[0])?e[0]:e,t=w(...r);if(!0===t)return;const a=new Error(t);throw a.name="Type Error",a},this.getCache=()=>this.cache.getCache(),this.setCache=e=>this.cache.setCache(e),this.getVersion=()=>"2.16.0",this.options=Br(e),this.operators=u(Rr,null!==(t=null===(r=this.options)||void 0===r?void 0:r.excludeOperators)&&void 0!==t?t:[],b),this.operatorAliases=b,this.cache=new Dr({maxSize:e.maxCacheSize,maxTime:e.maxCacheTime}),this.graphQLClient=Qr(null===(a=e.graphQLConnection)||void 0===a?void 0:a.httpClient),this.httpClient=Qr(e.httpClient)}evaluate(e,r={}){var t;return i(this,void 0,void 0,(function*(){const a=m(this.options,Br(r));return r.httpClient&&(this.httpClient=Qr(r.httpClient)),(null===(t=r.graphQLConnection)||void 0===t?void 0:t.httpClient)&&(this.graphQLClient=Qr(r.graphQLConnection.httpClient)),a.maxCacheSize&&a.maxCacheSize!==this.cache.getMax()&&this.cache.setMax(a.maxCacheSize),a.maxCacheTime&&a.maxCacheTime!==this.cache.getMaxTime()&&this.cache.setMaxTime(a.maxCacheTime),yield M(e,{options:a,operators:r.excludeOperators?u(Rr,r.excludeOperators,b):this.operators,operatorAliases:this.operatorAliases,typeChecker:a.skipRuntimeTypeCheck?()=>{}:this.typeChecker,resolvedAliasNodes:{},cache:this.cache,graphQLClient:this.graphQLClient,httpClient:this.httpClient})}))}getOptions(){return this.options}updateOptions(e){this.options=m(this.options,Br(e)),this.options.excludeOperators&&(this.operators=u(Rr,this.options.excludeOperators,b))}getOperators(){const e=this.options.excludeOperators?u(Rr,this.options.excludeOperators,b):this.operators,r=Object.entries(e).map((([e,r])=>Object.assign({name:e},r.operatorData))),t=[...new Set(Object.values(b))];return r.sort(((e,r)=>t.indexOf(e.name)-t.indexOf(r.name)))}getFragments(){var e;return Object.entries(null!==(e=this.options.fragments)&&void 0!==e?e:{}).map((([e,r])=>Object.assign({name:e},null==r?void 0:r.metadata)))}getCustomFunctions(){var e;return Object.entries(null!==(e=this.options.functions)&&void 0!==e?e:{}).map((([e,r])=>({name:e,numRequiredArgs:r.length})))}}const Fr=(e,r)=>new $r(r).evaluate(e),Br=e=>"objects"in e?Object.assign(Object.assign({},e),{data:e.objects}):e,Gr=e=>({query:({query:r,values:t=[]})=>i(void 0,void 0,void 0,(function*(){const a={text:r,values:null!=t?t:[]};try{const r=yield e.query(a);if(null==r?void 0:r.error)throw new Error(r.error);return r.rows}catch(e){throw e.name="Node-Postgres error",e}}))}),zr=e=>({query:({query:r,values:t=[]})=>i(void 0,void 0,void 0,(function*(){try{return yield e.all(r,t)}catch(e){throw e.name="SQLite error",e}}))});export{Hr as AxiosClient,Mr as FetchClient,$r as FigTreeEvaluator,Gr as SQLNodePostgres,zr as SQLite,Fr as evaluateExpression,h as isAliasString,n as isFragmentNode,g as isObject,s as isOperatorNode,C as preProcessShorthand,o as standardiseOperatorName,d as truncateString};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fig-tree-evaluator",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "Module to evaluate JSON-structured expression trees",
5
5
  "main": "build/index.cjs.js",
6
6
  "module": "build/index.esm.js",
@@ -24,9 +24,9 @@
24
24
  "axios": "^1.7.2",
25
25
  "dotenv": "^16.0.1",
26
26
  "eslint": "^8.53.0",
27
- "fig-tree-evaluator": "^2.14.1",
27
+ "fig-tree-evaluator": "^2.15.0",
28
28
  "jest": "^29.7.0",
29
- "node-fetch": "^2.7.0",
29
+ "node-fetch": "2.7.0",
30
30
  "pg": "^8.11.3",
31
31
  "prettier": "^3.0.3",
32
32
  "rimraf": "^5.0.5",