@lowdefy/engine 0.0.0-alpha.6 → 0.0.0-experimental-20231123101256

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 (39) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Actions.js +231 -486
  3. package/dist/Blocks.js +563 -572
  4. package/dist/Events.js +126 -0
  5. package/dist/Requests.js +107 -134
  6. package/dist/State.js +56 -83
  7. package/dist/actions/createCallMethod.js +29 -0
  8. package/dist/actions/createDisplayMessage.js +20 -0
  9. package/dist/actions/createGetActions.js +27 -0
  10. package/dist/actions/createGetBlockId.js +20 -0
  11. package/dist/actions/createGetEvent.js +27 -0
  12. package/dist/actions/createGetGlobal.js +27 -0
  13. package/dist/actions/createGetInput.js +27 -0
  14. package/dist/actions/createGetPageId.js +20 -0
  15. package/dist/actions/createGetRequestDetails.js +27 -0
  16. package/dist/actions/createGetState.js +27 -0
  17. package/dist/actions/createGetUrlQuery.js +32 -0
  18. package/dist/actions/createGetUser.js +27 -0
  19. package/dist/actions/createLink.js +20 -0
  20. package/dist/actions/createLogin.js +20 -0
  21. package/dist/actions/createLogout.js +20 -0
  22. package/dist/actions/createRequest.js +26 -0
  23. package/dist/actions/createReset.js +22 -0
  24. package/dist/actions/createResetValidation.js +21 -0
  25. package/dist/actions/createSetGlobal.js +25 -0
  26. package/dist/actions/createSetState.js +25 -0
  27. package/dist/actions/createUpdateSession.js +20 -0
  28. package/dist/actions/createValidate.js +25 -0
  29. package/dist/actions/getActionMethods.js +63 -0
  30. package/dist/actions/getFromObject.js +42 -0
  31. package/dist/createLink.js +71 -0
  32. package/dist/getBlockMatcher.js +61 -0
  33. package/dist/getContext.js +106 -153
  34. package/dist/index.js +10 -63
  35. package/package.json +27 -26
  36. package/dist/BlockActions.js +0 -211
  37. package/dist/Mutations.js +0 -100
  38. package/dist/getFieldValues.js +0 -49
  39. package/dist/makeContextId.js +0 -44
package/dist/Events.js ADDED
@@ -0,0 +1,126 @@
1
+ /*
2
+ Copyright 2020-2023 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 { type } from '@lowdefy/helpers';
16
+ let Events = class Events {
17
+ initEvent(actions) {
18
+ return {
19
+ actions: (type.isObject(actions) ? actions.try : actions) || [],
20
+ catchActions: (type.isObject(actions) ? actions.catch : []) || [],
21
+ debounce: type.isObject(actions) ? actions.debounce : null,
22
+ history: [],
23
+ loading: false
24
+ };
25
+ }
26
+ init() {
27
+ Object.keys(this.block.events).forEach((eventName)=>{
28
+ this.events[eventName] = this.initEvent(this.block.events[eventName]);
29
+ });
30
+ }
31
+ registerEvent({ name, actions }) {
32
+ this.events[name] = this.initEvent(actions);
33
+ }
34
+ triggerEvent({ name, event, progress }) {
35
+ this.context._internal.lowdefy.eventCallback?.({
36
+ name,
37
+ blockId: this.block.blockId
38
+ });
39
+ const eventDescription = this.events[name];
40
+ const result = {
41
+ blockId: this.block.blockId,
42
+ event,
43
+ eventName: name,
44
+ responses: {},
45
+ endTimestamp: new Date(),
46
+ startTimestamp: new Date(),
47
+ success: true,
48
+ bounced: false
49
+ };
50
+ // no event
51
+ if (type.isUndefined(eventDescription)) {
52
+ return result;
53
+ }
54
+ eventDescription.loading = true;
55
+ this.block.update = true;
56
+ this.context._internal.update();
57
+ const actionHandle = async ()=>{
58
+ const res = await this.context._internal.Actions.callActions({
59
+ actions: eventDescription.actions,
60
+ arrayIndices: this.arrayIndices,
61
+ block: this.block,
62
+ catchActions: eventDescription.catchActions,
63
+ event,
64
+ eventName: name,
65
+ progress
66
+ });
67
+ eventDescription.history.unshift(res);
68
+ this.context.eventLog.unshift(res);
69
+ eventDescription.loading = false;
70
+ this.block.update = true;
71
+ this.context._internal.update();
72
+ return res;
73
+ };
74
+ // no debounce
75
+ if (type.isNone(eventDescription.debounce)) {
76
+ return actionHandle();
77
+ }
78
+ const delay = !type.isNone(eventDescription.debounce.ms) ? eventDescription.debounce.ms : this.defaultDebounceMs;
79
+ // leading edge: bounce
80
+ if (this.timeouts[name] && eventDescription.debounce.immediate === true) {
81
+ result.bounced = true;
82
+ eventDescription.history.unshift(result);
83
+ this.context.eventLog.unshift(result);
84
+ return result;
85
+ }
86
+ // leading edge: trigger
87
+ if (eventDescription.debounce.immediate === true) {
88
+ this.timeouts[name] = setTimeout(()=>{
89
+ this.timeouts[name] = null;
90
+ }, delay);
91
+ return actionHandle();
92
+ }
93
+ // trailing edge
94
+ if (eventDescription.bouncer) {
95
+ eventDescription.bouncer();
96
+ }
97
+ return new Promise((resolve)=>{
98
+ const timeout = setTimeout(async ()=>{
99
+ eventDescription.bouncer = null;
100
+ const res = await actionHandle();
101
+ resolve(res);
102
+ }, delay);
103
+ eventDescription.bouncer = ()=>{
104
+ clearTimeout(timeout);
105
+ result.bounced = true;
106
+ eventDescription.history.unshift(result);
107
+ this.context.eventLog.unshift(result);
108
+ resolve(result);
109
+ };
110
+ });
111
+ }
112
+ constructor({ arrayIndices, block, context }){
113
+ this.defaultDebounceMs = 300;
114
+ this.events = {};
115
+ this.timeouts = {};
116
+ this.arrayIndices = arrayIndices;
117
+ this.block = block;
118
+ this.context = context;
119
+ this.init = this.init.bind(this);
120
+ this.triggerEvent = this.triggerEvent.bind(this);
121
+ this.registerEvent = this.registerEvent.bind(this);
122
+ this.initEvent = this.initEvent.bind(this);
123
+ this.init();
124
+ }
125
+ };
126
+ export default Events;
package/dist/Requests.js CHANGED
@@ -1,138 +1,111 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
9
-
10
- var _helpers = require("@lowdefy/helpers");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _templateObject() {
15
- var data = _taggedTemplateLiteral(["\n query callRequest($input: RequestInput!) {\n request(input: $input) {\n id\n type\n success\n response\n }\n }\n"]);
16
-
17
- _templateObject = function _templateObject() {
18
- return data;
19
- };
20
-
21
- return data;
22
- }
23
-
24
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
25
-
26
- var CALL_REQUEST = (0, _graphqlTag.default)(_templateObject());
27
-
28
- class Requests {
29
- constructor(context) {
30
- this.context = context;
31
- this.requestList = this.context.rootBlock.requests || [];
32
- this.callRequests = this.callRequests.bind(this);
33
- this.callRequest = this.callRequest.bind(this);
34
- this.fetch = this.fetch.bind(this);
35
- }
36
-
37
- callRequests() {
38
- var {
39
- requestIds,
40
- args,
41
- arrayIndices
42
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
43
-
44
- if (!requestIds) {
45
- return Promise.all(this.requestList.map(request => this.callRequest({
46
- requestId: request.requestId,
47
- args,
48
- arrayIndices
49
- })));
1
+ /*
2
+ Copyright 2020-2023 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 { get, serializer, type } from '@lowdefy/helpers';
16
+ let Requests = class Requests {
17
+ callRequests({ actions, arrayIndices, blockId, event, params } = {}) {
18
+ if (type.isObject(params) && params.all === true) {
19
+ return Promise.all(Object.keys(this.requestConfig).map((requestId)=>this.callRequest({
20
+ arrayIndices,
21
+ blockId,
22
+ event,
23
+ requestId
24
+ })));
25
+ }
26
+ let requestIds = [];
27
+ if (type.isString(params)) requestIds = [
28
+ params
29
+ ];
30
+ if (type.isArray(params)) requestIds = params;
31
+ const requests = requestIds.map((requestId)=>this.callRequest({
32
+ actions,
33
+ requestId,
34
+ blockId,
35
+ event,
36
+ arrayIndices
37
+ }));
38
+ this.context._internal.update(); // update to render request reset
39
+ return Promise.all(requests);
50
40
  }
51
-
52
- return Promise.all(requestIds.map(requestId => this.callRequest({
53
- requestId,
54
- args,
55
- arrayIndices
56
- })));
57
- }
58
-
59
- callRequest(_ref) {
60
- var {
61
- requestId,
62
- args,
63
- arrayIndices
64
- } = _ref;
65
-
66
- if (!this.context.requests[requestId]) {
67
- var request = this.requestList.find(req => req.requestId === requestId);
68
-
69
- if (!request) {
70
- this.context.requests[requestId] = {
71
- loading: false,
72
- response: null,
73
- error: [new Error("Configuration Error: Request ".concat(requestId, " not defined on context."))]
41
+ async callRequest({ actions, arrayIndices, blockId, event, requestId }) {
42
+ const requestConfig = this.requestConfig[requestId];
43
+ if (!this.context.requests[requestId]) {
44
+ this.context.requests[requestId] = [];
45
+ }
46
+ if (!requestConfig) {
47
+ const error = new Error(`Configuration Error: Request ${requestId} not defined on page.`);
48
+ this.context.requests[requestId].unshift({
49
+ blockId: 'block_id',
50
+ error,
51
+ loading: false,
52
+ requestId,
53
+ response: null
54
+ });
55
+ throw error;
56
+ }
57
+ const { output: payload, errors: parserErrors } = this.context._internal.parser.parse({
58
+ actions,
59
+ event,
60
+ arrayIndices,
61
+ input: requestConfig.payload,
62
+ location: requestId
63
+ });
64
+ if (parserErrors.length > 0) {
65
+ throw parserErrors[0];
66
+ }
67
+ const request = {
68
+ blockId,
69
+ loading: true,
70
+ payload,
71
+ requestId,
72
+ response: null
74
73
  };
75
- return Promise.reject(new Error("Configuration Error: Request ".concat(requestId, " not defined on context.")));
76
- }
77
-
78
- this.context.requests[requestId] = {
79
- loading: true,
80
- response: null,
81
- error: []
82
- };
74
+ this.context.requests[requestId].unshift(request);
75
+ return this.fetch(request);
83
76
  }
84
-
85
- return this.fetch({
86
- requestId,
87
- args,
88
- arrayIndices
89
- });
90
- }
91
-
92
- fetch(_ref2) {
93
- var {
94
- requestId,
95
- args,
96
- arrayIndices
97
- } = _ref2;
98
- this.context.requests[requestId].loading = true;
99
-
100
- if (this.context.RootBlocks) {
101
- this.context.RootBlocks.setBlocksLoadingCache();
102
- }
103
-
104
- return this.context.client.query({
105
- query: CALL_REQUEST,
106
- fetchPolicy: 'network-only',
107
- variables: {
108
- input: {
109
- arrayIndices,
110
- requestId,
111
- blockId: this.context.blockId,
112
- args: _helpers.serializer.serialize(args) || {},
113
- input: _helpers.serializer.serialize(this.context.input),
114
- lowdefyGlobal: _helpers.serializer.serialize(this.context.lowdefyGlobal),
115
- pageId: this.context.pageId,
116
- state: _helpers.serializer.serialize(this.context.state),
117
- urlQuery: _helpers.serializer.serialize(this.context.urlQuery)
77
+ async fetch(request) {
78
+ request.loading = true;
79
+ try {
80
+ const response = await this.context._internal.lowdefy._internal.callRequest({
81
+ blockId: request.blockId,
82
+ pageId: this.context.pageId,
83
+ payload: serializer.serialize(request.payload),
84
+ requestId: request.requestId
85
+ });
86
+ const deserializedResponse = serializer.deserialize(get(response, 'response', {
87
+ default: null
88
+ }));
89
+ request.response = deserializedResponse;
90
+ request.loading = false;
91
+ this.context._internal.update();
92
+ return deserializedResponse;
93
+ } catch (error) {
94
+ request.error = error;
95
+ request.loading = false;
96
+ this.context._internal.update();
97
+ throw error;
118
98
  }
119
- }
120
- }).then(result => {
121
- this.context.requests[requestId].response = _helpers.serializer.deserialize((0, _helpers.get)(result, 'data.request.response', {
122
- default: null
123
- }));
124
- this.context.requests[requestId].error.unshift(null);
125
- return result;
126
- }).catch(error => {
127
- this.context.requests[requestId].error.unshift(error);
128
- throw error;
129
- }).finally(() => {
130
- this.context.requests[requestId].loading = false;
131
- this.context.update();
132
- });
133
- }
134
-
135
- }
136
-
137
- var _default = Requests;
138
- exports.default = _default;
99
+ }
100
+ constructor(context){
101
+ this.context = context;
102
+ this.callRequests = this.callRequests.bind(this);
103
+ this.callRequest = this.callRequest.bind(this);
104
+ this.fetch = this.fetch.bind(this);
105
+ this.requestConfig = {};
106
+ (this.context._internal.rootBlock.requests || []).forEach((request)=>{
107
+ this.requestConfig[request.requestId] = request;
108
+ });
109
+ }
110
+ };
111
+ export default Requests;
package/dist/State.js CHANGED
@@ -1,14 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
1
  /*
11
- Copyright 2020 Lowdefy, Inc
2
+ Copyright 2020-2023 Lowdefy, Inc
12
3
 
13
4
  Licensed under the Apache License, Version 2.0 (the "License");
14
5
  you may not use this file except in compliance with the License.
@@ -21,80 +12,62 @@ var _helpers = require("@lowdefy/helpers");
21
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
13
  See the License for the specific language governing permissions and
23
14
  limitations under the License.
24
- */
25
- class State {
26
- constructor(context) {
27
- this.context = context;
28
- this.frozenState = null;
29
- this.initialized = false;
30
- this.set = this.set.bind(this);
31
- this.del = this.del.bind(this);
32
- this.swapItems = this.swapItems.bind(this);
33
- this.removeItem = this.removeItem.bind(this);
34
- this.freezeState = this.freezeState.bind(this);
35
- this.resetState = this.resetState.bind(this);
36
- }
37
-
38
- resetState() {
39
- Object.keys(this.context.state).forEach(key => {
40
- delete this.context.state[key];
41
- });
42
-
43
- var frozenCopy = _helpers.serializer.deserializeFromString(this.frozenState);
44
-
45
- Object.keys(frozenCopy).forEach(key => {
46
- this.set(key, frozenCopy[key]);
47
- });
48
- this.context.showValidationErrors = false;
49
- }
50
-
51
- freezeState() {
52
- if (!this.initialized) {
53
- this.frozenState = _helpers.serializer.serializeToString(this.context.state);
54
- this.initialized = true;
15
+ */ import { unset, get, serializer, set, swap, type } from '@lowdefy/helpers';
16
+ let State = class State {
17
+ resetState() {
18
+ Object.keys(this.context.state).forEach((key)=>{
19
+ delete this.context.state[key];
20
+ });
21
+ const frozenCopy = serializer.deserializeFromString(this.frozenState);
22
+ Object.keys(frozenCopy).forEach((key)=>{
23
+ this.set(key, frozenCopy[key]);
24
+ });
55
25
  }
56
- }
57
-
58
- set(field, value) {
59
- (0, _helpers.set)(this.context.state, field, value);
60
- }
61
-
62
- del(field) {
63
- (0, _helpers.unset)(this.context.state, field); // remove all empty objects from state as an effect of deleted values
64
-
65
- var fields = field.split('.');
66
-
67
- if (fields.length > 1) {
68
- var parent = fields.slice(0, fields.length - 1).join('.');
69
- var parentValue = (0, _helpers.get)(this.context.state, parent);
70
-
71
- if (_helpers.type.isObject(parentValue) && Object.keys(parentValue).length === 0) {
72
- this.del(parent);
73
- }
26
+ freezeState() {
27
+ if (!this.initialized) {
28
+ this.frozenState = serializer.serializeToString(this.context.state);
29
+ this.initialized = true;
30
+ }
74
31
  }
75
- }
76
-
77
- swapItems(field, from, to) {
78
- var arr = (0, _helpers.get)(this.context.state, field);
79
-
80
- if (!_helpers.type.isArray(arr) || from < 0 || to < 0 || from >= arr.length || to >= arr.length) {
81
- return;
32
+ set(field, value) {
33
+ set(this.context.state, field, value);
82
34
  }
83
-
84
- (0, _helpers.swap)(arr, from, to);
85
- }
86
-
87
- removeItem(field, index) {
88
- var arr = (0, _helpers.get)(this.context.state, field);
89
-
90
- if (!_helpers.type.isArray(arr) || index < 0 || index >= arr.length) {
91
- return;
35
+ del(field) {
36
+ unset(this.context.state, field);
37
+ // remove all empty objects from state as an effect of deleted values
38
+ const fields = field.split('.');
39
+ if (fields.length > 1) {
40
+ const parent = fields.slice(0, fields.length - 1).join('.');
41
+ const parentValue = get(this.context.state, parent);
42
+ if (type.isObject(parentValue) && Object.keys(parentValue).length === 0) {
43
+ this.del(parent);
44
+ }
45
+ }
92
46
  }
93
-
94
- arr.splice(index, 1);
95
- }
96
-
97
- }
98
-
99
- var _default = State;
100
- exports.default = _default;
47
+ swapItems(field, from, to) {
48
+ const arr = get(this.context.state, field);
49
+ if (!type.isArray(arr) || from < 0 || to < 0 || from >= arr.length || to >= arr.length) {
50
+ return;
51
+ }
52
+ swap(arr, from, to);
53
+ }
54
+ removeItem(field, index) {
55
+ const arr = get(this.context.state, field);
56
+ if (!type.isArray(arr) || index < 0 || index >= arr.length) {
57
+ return;
58
+ }
59
+ arr.splice(index, 1);
60
+ }
61
+ constructor(context){
62
+ this.context = context;
63
+ this.frozenState = null;
64
+ this.initialized = false;
65
+ this.set = this.set.bind(this);
66
+ this.del = this.del.bind(this);
67
+ this.swapItems = this.swapItems.bind(this);
68
+ this.removeItem = this.removeItem.bind(this);
69
+ this.freezeState = this.freezeState.bind(this);
70
+ this.resetState = this.resetState.bind(this);
71
+ }
72
+ };
73
+ export default State;
@@ -0,0 +1,29 @@
1
+ /*
2
+ Copyright 2020-2023 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 { applyArrayIndices, type } from '@lowdefy/helpers';
16
+ function createCallMethod({ arrayIndices, context }) {
17
+ return function callMethod(params) {
18
+ const { blockId, method, args = [] } = params;
19
+ const blockMethod = context._internal.RootBlocks.map[applyArrayIndices(arrayIndices, blockId)].methods[method];
20
+ if (!type.isArray(args)) {
21
+ throw new Error(`Failed to call method "${method}" on block "${blockId}": "args" should be an array. Received "${JSON.stringify(params)}".`);
22
+ }
23
+ if (!type.isFunction(blockMethod)) {
24
+ throw new Error(`Failed to call method "${method}" on block "${blockId}". Check if "${method}" is a valid block method for block "${blockId}". Received "${JSON.stringify(params)}".`);
25
+ }
26
+ return blockMethod(...args);
27
+ };
28
+ }
29
+ export default createCallMethod;
@@ -0,0 +1,20 @@
1
+ /*
2
+ Copyright 2020-2023 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
+ */ function createDisplayMessage({ context }) {
16
+ return function displayMessage(params = {}) {
17
+ context._internal.lowdefy._internal.displayMessage(params);
18
+ };
19
+ }
20
+ export default createDisplayMessage;
@@ -0,0 +1,27 @@
1
+ /*
2
+ Copyright 2020-2023 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 getFromObject from './getFromObject.js';
16
+ function createGetActions({ actions, arrayIndices, blockId }) {
17
+ return function getActions(params) {
18
+ return getFromObject({
19
+ arrayIndices,
20
+ location: blockId,
21
+ object: actions,
22
+ method: 'getActions',
23
+ params
24
+ });
25
+ };
26
+ }
27
+ export default createGetActions;
@@ -0,0 +1,20 @@
1
+ /*
2
+ Copyright 2020-2023 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
+ */ function createGetBlockId({ blockId }) {
16
+ return function getBlockId() {
17
+ return blockId;
18
+ };
19
+ }
20
+ export default createGetBlockId;
@@ -0,0 +1,27 @@
1
+ /*
2
+ Copyright 2020-2023 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 getFromObject from './getFromObject.js';
16
+ function createGetEvent({ arrayIndices, blockId, event }) {
17
+ return function getEvent(params) {
18
+ return getFromObject({
19
+ arrayIndices,
20
+ location: blockId,
21
+ object: event,
22
+ method: 'getEvent',
23
+ params
24
+ });
25
+ };
26
+ }
27
+ export default createGetEvent;