@lowdefy/engine 0.0.0-experimental-20240111121545 → 0.0.0-experimental-20241107140648

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/Actions.js +1 -1
  2. package/dist/Blocks.js +1 -1
  3. package/dist/Events.js +1 -1
  4. package/dist/Requests.js +7 -1
  5. package/dist/State.js +1 -1
  6. package/dist/actions/createCallAPI.js +24 -0
  7. package/dist/actions/createCallMethod.js +1 -1
  8. package/dist/actions/createDisplayMessage.js +1 -1
  9. package/dist/actions/createGetActions.js +1 -1
  10. package/dist/actions/createGetBlockId.js +1 -1
  11. package/dist/actions/createGetEvent.js +1 -1
  12. package/dist/actions/createGetGlobal.js +1 -1
  13. package/dist/actions/createGetInput.js +1 -1
  14. package/dist/actions/createGetPageId.js +1 -1
  15. package/dist/actions/createGetRequestDetails.js +1 -1
  16. package/dist/actions/createGetState.js +1 -1
  17. package/dist/actions/createGetUrlQuery.js +1 -1
  18. package/dist/actions/createGetUser.js +1 -1
  19. package/dist/actions/createLink.js +1 -1
  20. package/dist/actions/createLogin.js +1 -1
  21. package/dist/actions/createLogout.js +1 -1
  22. package/dist/actions/createRequest.js +1 -1
  23. package/dist/actions/createReset.js +1 -1
  24. package/dist/actions/createResetValidation.js +1 -1
  25. package/dist/actions/createSetGlobal.js +1 -1
  26. package/dist/actions/createSetState.js +1 -1
  27. package/dist/actions/createUpdateSession.js +1 -1
  28. package/dist/actions/createValidate.js +1 -1
  29. package/dist/actions/getActionMethods.js +3 -1
  30. package/dist/actions/getFromObject.js +1 -1
  31. package/dist/callAPIHandler.js +58 -0
  32. package/dist/createLink.js +1 -1
  33. package/dist/getBlockMatcher.js +1 -1
  34. package/dist/getContext.js +3 -2
  35. package/dist/index.js +3 -3
  36. package/package.json +7 -7
package/dist/Actions.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/Blocks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-param-reassign */ /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/Events.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/Requests.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@ let Requests = class Requests {
54
54
  });
55
55
  throw error;
56
56
  }
57
+ // evaluate operators
57
58
  const { output: payload, errors: parserErrors } = this.context._internal.parser.parse({
58
59
  actions,
59
60
  event,
@@ -76,6 +77,7 @@ let Requests = class Requests {
76
77
  }
77
78
  async fetch(request) {
78
79
  request.loading = true;
80
+ const startTime = Date.now();
79
81
  try {
80
82
  const response = await this.context._internal.lowdefy._internal.callRequest({
81
83
  blockId: request.blockId,
@@ -88,11 +90,15 @@ let Requests = class Requests {
88
90
  }));
89
91
  request.response = deserializedResponse;
90
92
  request.loading = false;
93
+ const endTime = Date.now();
94
+ request.responseTime = endTime - startTime;
91
95
  this.context._internal.update();
92
96
  return deserializedResponse;
93
97
  } catch (error) {
94
98
  request.error = error;
95
99
  request.loading = false;
100
+ const endTime = Date.now();
101
+ request.responseTime = endTime - startTime;
96
102
  this.context._internal.update();
97
103
  throw error;
98
104
  }
package/dist/State.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -0,0 +1,24 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import callAPIHandler from '../callAPIHandler.js';
16
+ function createCallAPI({ blockId, context }) {
17
+ return function callAPI(params) {
18
+ return callAPIHandler(context, {
19
+ blockId,
20
+ params
21
+ });
22
+ };
23
+ }
24
+ export default createCallAPI;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import createCallMethod from './createCallMethod.js';
16
+ import createCallAPI from './createCallAPI.js';
16
17
  import createGetActions from './createGetActions.js';
17
18
  import createGetBlockId from './createGetBlockId.js';
18
19
  import createGetEvent from './createGetEvent.js';
@@ -36,6 +37,7 @@ import createUpdateSession from './createUpdateSession.js';
36
37
  import createValidate from './createValidate.js';
37
38
  function getActionMethods(props) {
38
39
  return {
40
+ callAPI: createCallAPI(props),
39
41
  callMethod: createCallMethod(props),
40
42
  displayMessage: createDisplayMessage(props),
41
43
  getActions: createGetActions(props),
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -0,0 +1,58 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function callAPIHandler(context, { blockId, params }) {
17
+ if (!context._internal.lowdefy.apiResponses[params.endpointId]) {
18
+ context._internal.lowdefy.apiResponses[params.endpointId] = [];
19
+ }
20
+ const api = {
21
+ ...params,
22
+ blockId,
23
+ loading: true,
24
+ success: null,
25
+ pageId: context.pageId,
26
+ startTimestamp: new Date(),
27
+ endTimestamp: null
28
+ };
29
+ context._internal.lowdefy.apiResponses[api.endpointId].unshift(api);
30
+ try {
31
+ const { error, response, status, success } = await context._internal.lowdefy._internal.callAPI({
32
+ blockId: api.blockId,
33
+ pageId: context.pageId,
34
+ payload: serializer.serialize(api.payload),
35
+ endpointId: api.endpointId
36
+ });
37
+ api.error = serializer.deserialize(error);
38
+ api.loading = false;
39
+ api.response = serializer.deserialize(response);
40
+ api.status = status;
41
+ api.success = success;
42
+ api.endTimestamp = new Date();
43
+ api.responseTime = api.endTimestamp - api.startTimestamp;
44
+ context._internal.update();
45
+ } catch (error) {
46
+ api.error = error;
47
+ api.loading = false;
48
+ api.response = null;
49
+ api.status = 'error';
50
+ api.success = false;
51
+ api.endTimestamp = new Date();
52
+ api.responseTime = api.endTimestamp - api.startTimestamp;
53
+ context._internal.update();
54
+ throw error;
55
+ }
56
+ return api;
57
+ }
58
+ export default callAPIHandler;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ const blockData = ({ areas, blockId, blocks, events, field, id, layout, pageId,
34
34
  validate,
35
35
  visible
36
36
  });
37
- function getContext({ config, lowdefy, resetContext = {
37
+ function getContext({ config, jsMap = {}, lowdefy, resetContext = {
38
38
  reset: false,
39
39
  setReset: ()=>undefined
40
40
  } }) {
@@ -55,6 +55,7 @@ function getContext({ config, lowdefy, resetContext = {
55
55
  id,
56
56
  pageId: config.pageId,
57
57
  eventLog: [],
58
+ jsMap,
58
59
  requests: {},
59
60
  state: {},
60
61
  _internal: {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,11 +13,11 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import Actions from './Actions.js';
16
- import Events from './Events.js';
17
16
  import Blocks from './Blocks.js';
18
17
  import createLink from './createLink.js';
18
+ import Events from './Events.js';
19
19
  import Requests from './Requests.js';
20
20
  import State from './State.js';
21
21
  import getContext from './getContext.js';
22
- export { Actions, Events, Blocks, createLink, Requests, State };
22
+ export { Actions, Blocks, createLink, Events, Requests, State };
23
23
  export default getContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/engine",
3
- "version": "0.0.0-experimental-20240111121545",
3
+ "version": "0.0.0-experimental-20241107140648",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -30,15 +30,15 @@
30
30
  "dist/*"
31
31
  ],
32
32
  "dependencies": {
33
- "@lowdefy/helpers": "0.0.0-experimental-20240111121545",
34
- "@lowdefy/operators": "0.0.0-experimental-20240111121545"
33
+ "@lowdefy/helpers": "0.0.0-experimental-20241107140648",
34
+ "@lowdefy/operators": "0.0.0-experimental-20241107140648"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jest/globals": "28.1.3",
38
- "@lowdefy/actions-core": "0.0.0-experimental-20240111121545",
39
- "@lowdefy/build": "0.0.0-experimental-20240111121545",
40
- "@lowdefy/operators-js": "0.0.0-experimental-20240111121545",
41
- "@lowdefy/operators-mql": "0.0.0-experimental-20240111121545",
38
+ "@lowdefy/actions-core": "0.0.0-experimental-20241107140648",
39
+ "@lowdefy/build": "0.0.0-experimental-20241107140648",
40
+ "@lowdefy/operators-js": "0.0.0-experimental-20241107140648",
41
+ "@lowdefy/operators-mql": "0.0.0-experimental-20241107140648",
42
42
  "@swc/cli": "0.1.63",
43
43
  "@swc/core": "1.3.99",
44
44
  "@swc/jest": "0.2.29",