@lowdefy/operators 4.0.0-alpha.10 → 4.0.0-alpha.13

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.
@@ -16,16 +16,14 @@
16
16
  function getFromArray({ params , array , key , operator , location }) {
17
17
  if (params === true) return array;
18
18
  if (type.isString(params)) {
19
- return array.find((item)=>item[key] === params
20
- );
19
+ return array.find((item)=>item[key] === params);
21
20
  }
22
21
  if (type.isNumber(params)) {
23
22
  return array[params];
24
23
  }
25
24
  if (type.isObject(params)) {
26
25
  if (params.all === true) return array;
27
- if (type.isString(params.value)) return array.find((item)=>item[key] === params.value
28
- );
26
+ if (type.isString(params.value)) return array.find((item)=>item[key] === params.value);
29
27
  if (type.isNumber(params.index)) return array[params.index];
30
28
  if (!type.isNone(params.value) && !type.isString(params.value)) {
31
29
  throw new Error(`Operator Error: ${operator}.value must be of type string. Received: ${JSON.stringify(params)} at ${location}.`);
@@ -15,11 +15,6 @@
15
15
  */ import { serializer, type } from '@lowdefy/helpers';
16
16
  let NodeParser = class NodeParser {
17
17
  parse({ args , input , location , operatorPrefix ='_' }) {
18
- const env = this.env;
19
- const operators = this.operators;
20
- const secrets = this.secrets;
21
- const payload = this.payload;
22
- const user = this.user;
23
18
  if (type.isUndefined(input)) {
24
19
  return {
25
20
  output: input,
@@ -38,21 +33,21 @@ let NodeParser = class NodeParser {
38
33
  const key = Object.keys(value)[0];
39
34
  if (!key.startsWith(operatorPrefix)) return value;
40
35
  const [op, methodName] = `_${key.substring(operatorPrefix.length)}`.split('.');
41
- if (type.isUndefined(operators[op])) return value;
36
+ if (type.isUndefined(this.operators[op])) return value;
42
37
  try {
43
- const res = operators[op]({
38
+ const res = this.operators[op]({
44
39
  args,
45
40
  arrayIndices: [],
46
- env,
41
+ env: this.env,
47
42
  location,
48
43
  methodName,
49
- operators: operators,
44
+ operators: this.operators,
50
45
  params: value[key],
51
46
  operatorPrefix,
52
47
  parser: this,
53
- payload,
54
- secrets,
55
- user
48
+ payload: this.payload,
49
+ secrets: this.secrets,
50
+ user: this.user
56
51
  });
57
52
  return res;
58
53
  } catch (e) {
package/dist/runClass.js CHANGED
@@ -50,8 +50,7 @@ const runClass = ({ location , meta , methodName , operator , params , functions
50
50
  args = params;
51
51
  }
52
52
  if (type.isObject(params)) {
53
- args.push(...(meta[methodName].namedArgs || []).map((key)=>params[key]
54
- ));
53
+ args.push(...(meta[methodName].namedArgs || []).map((key)=>params[key]));
55
54
  if (!type.isNone(meta[methodName].spreadArgs) && !type.isArray(params[meta[methodName].spreadArgs])) {
56
55
  throw new Error(`Operator Error: ${operator}.${methodName} takes an array as input argument for ${meta[methodName].spreadArgs}.
57
56
  Received: {"${operator}.${methodName}":${JSON.stringify(params)}} at ${location}.`);
@@ -36,8 +36,7 @@ const runInstance = ({ location , meta , methodName , operator , params , instan
36
36
  // Instance must be listed first in named args.
37
37
  if (type.isObject(params)) {
38
38
  instance = params[meta[methodName].namedArgs[0]];
39
- args.push(...meta[methodName].namedArgs.slice(1).map((key)=>params[key]
40
- ));
39
+ args.push(...meta[methodName].namedArgs.slice(1).map((key)=>params[key]));
41
40
  if (!type.isNone(meta[methodName].spreadArgs) && !type.isArray(params[meta[methodName].spreadArgs])) {
42
41
  throw new Error(`Operator Error: ${operator}.${methodName} takes an array as input argument for ${meta[methodName].spreadArgs}.
43
42
  Received: {"${operator}.${methodName}":${JSON.stringify(params)}} at ${location}.`);
package/dist/webParser.js CHANGED
@@ -15,8 +15,6 @@
15
15
  */ import { applyArrayIndices, serializer, type } from '@lowdefy/helpers';
16
16
  let WebParser = class WebParser {
17
17
  parse({ actions , args , arrayIndices , event , input , location , operatorPrefix ='_' }) {
18
- const operators = this.operators;
19
- const context = this.context;
20
18
  if (type.isUndefined(input)) {
21
19
  return {
22
20
  output: input,
@@ -33,34 +31,37 @@ let WebParser = class WebParser {
33
31
  throw new Error('Operator parser location must be a string.');
34
32
  }
35
33
  const errors = [];
36
- const { inputs , lowdefyGlobal , menus , urlQuery , user } = context._internal.lowdefy;
34
+ const { basePath , home , inputs , lowdefyGlobal , menus , pageId , urlQuery , user , _internal } = this.context._internal.lowdefy;
37
35
  const reviver = (_, value)=>{
38
36
  if (!type.isObject(value) || Object.keys(value).length !== 1) return value;
39
37
  const key = Object.keys(value)[0];
40
38
  if (!key.startsWith(operatorPrefix)) return value;
41
39
  const [op, methodName] = `_${key.substring(operatorPrefix.length)}`.split('.');
42
- if (type.isUndefined(operators[op])) return value;
40
+ if (type.isUndefined(this.operators[op])) return value;
43
41
  try {
44
- const res = operators[op]({
45
- eventLog: context.eventLog,
42
+ const res = this.operators[op]({
46
43
  actions,
47
44
  args,
48
45
  arrayIndices,
49
- context,
46
+ basePath,
50
47
  event,
51
- input: inputs ? inputs[context.id] : {},
48
+ eventLog: this.context.eventLog,
49
+ home,
50
+ input: inputs ? inputs[this.context.id] : {},
52
51
  location: applyArrayIndices(arrayIndices, location),
53
- lowdefyGlobal: lowdefyGlobal || {},
54
- menus: menus || {},
52
+ lowdefyGlobal: lowdefyGlobal ?? {},
53
+ menus: menus ?? [],
55
54
  methodName,
56
- operators,
57
55
  operatorPrefix,
56
+ operators: this.operators,
57
+ pageId,
58
58
  params: value[key],
59
- requests: context.requests,
60
- state: context.state,
61
- urlQuery: urlQuery || {},
62
- user: user || {},
63
- parser: this
59
+ parser: this,
60
+ requests: this.context.requests,
61
+ state: this.context.state,
62
+ urlQuery: urlQuery ?? {},
63
+ user: user ?? {},
64
+ window: _internal.window
64
65
  });
65
66
  return res;
66
67
  } catch (e) {
@@ -78,8 +79,8 @@ let WebParser = class WebParser {
78
79
  }
79
80
  constructor({ context , operators }){
80
81
  this.context = context;
81
- this.parse = this.parse.bind(this);
82
82
  this.operators = operators;
83
+ this.parse = this.parse.bind(this);
83
84
  }
84
85
  };
85
86
  export default WebParser;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lowdefy/operators",
3
- "version": "4.0.0-alpha.10",
4
- "licence": "Apache-2.0",
3
+ "version": "4.0.0-alpha.13",
4
+ "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
7
7
  "keywords": [
@@ -34,24 +34,25 @@
34
34
  "dist/*"
35
35
  ],
36
36
  "scripts": {
37
- "build": "yarn clean && yarn swc",
37
+ "build": "yarn swc",
38
38
  "clean": "rm -rf dist",
39
39
  "prepare": "yarn build",
40
- "swc": "swc src --out-dir dist --config-file ../../.swcrc",
40
+ "swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
41
41
  "test": "jest --coverage --testTimeout=10000",
42
42
  "test:watch": "jest --coverage --watch"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-alpha.10"
45
+ "@lowdefy/helpers": "4.0.0-alpha.13"
46
46
  },
47
47
  "devDependencies": {
48
- "@swc/cli": "0.1.55",
49
- "@swc/core": "1.2.135",
50
- "@swc/jest": "0.2.17",
51
- "jest": "27.5.1"
48
+ "@swc/cli": "0.1.57",
49
+ "@swc/core": "1.2.194",
50
+ "@swc/jest": "0.2.21",
51
+ "jest": "28.1.0",
52
+ "jest-environment-jsdom": "28.1.0"
52
53
  },
53
54
  "publishConfig": {
54
55
  "access": "public"
55
56
  },
56
- "gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
57
+ "gitHead": "e99b4b6c1f59804982fc148c0fe39dcf13b35d77"
57
58
  }