@lowdefy/engine 0.0.0-alpha.7 → 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.
- package/LICENSE +201 -0
- package/dist/Actions.js +231 -486
- package/dist/Blocks.js +563 -572
- package/dist/Events.js +126 -0
- package/dist/Requests.js +107 -134
- package/dist/State.js +56 -83
- package/dist/actions/createCallMethod.js +29 -0
- package/dist/actions/createDisplayMessage.js +20 -0
- package/dist/actions/createGetActions.js +27 -0
- package/dist/actions/createGetBlockId.js +20 -0
- package/dist/actions/createGetEvent.js +27 -0
- package/dist/actions/createGetGlobal.js +27 -0
- package/dist/actions/createGetInput.js +27 -0
- package/dist/actions/createGetPageId.js +20 -0
- package/dist/actions/createGetRequestDetails.js +27 -0
- package/dist/actions/createGetState.js +27 -0
- package/dist/actions/createGetUrlQuery.js +32 -0
- package/dist/actions/createGetUser.js +27 -0
- package/dist/actions/createLink.js +20 -0
- package/dist/actions/createLogin.js +20 -0
- package/dist/actions/createLogout.js +20 -0
- package/dist/actions/createRequest.js +26 -0
- package/dist/actions/createReset.js +22 -0
- package/dist/actions/createResetValidation.js +21 -0
- package/dist/actions/createSetGlobal.js +25 -0
- package/dist/actions/createSetState.js +25 -0
- package/dist/actions/createUpdateSession.js +20 -0
- package/dist/actions/createValidate.js +25 -0
- package/dist/actions/getActionMethods.js +63 -0
- package/dist/actions/getFromObject.js +42 -0
- package/dist/createLink.js +71 -0
- package/dist/getBlockMatcher.js +61 -0
- package/dist/getContext.js +106 -153
- package/dist/index.js +10 -63
- package/package.json +27 -26
- package/CHANGELOG.md +0 -38
- package/dist/BlockActions.js +0 -211
- package/dist/Mutations.js +0 -100
- package/dist/getFieldValues.js +0 -49
- package/dist/makeContextId.js +0 -44
package/dist/BlockActions.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
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
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
16
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
|
-
|
|
18
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
-
|
|
20
|
-
class BlockActions {
|
|
21
|
-
constructor(_ref) {
|
|
22
|
-
var {
|
|
23
|
-
arrayIndices,
|
|
24
|
-
block,
|
|
25
|
-
context
|
|
26
|
-
} = _ref;
|
|
27
|
-
this.actions = {};
|
|
28
|
-
this.arrayIndices = arrayIndices;
|
|
29
|
-
this.block = block;
|
|
30
|
-
this.context = context;
|
|
31
|
-
this.init = this.init.bind(this);
|
|
32
|
-
this.callAction = this.callAction.bind(this);
|
|
33
|
-
this.createCall = this.createCall.bind(this);
|
|
34
|
-
this.callRec = this.callRec.bind(this);
|
|
35
|
-
this.registerAction = this.registerAction.bind(this);
|
|
36
|
-
this.init();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
callRec(args, actions, results, resolve, reject) {
|
|
40
|
-
if (actions.length > 0) {
|
|
41
|
-
// eslint-disable-next-line no-unused-vars
|
|
42
|
-
var _actions$ = actions[0],
|
|
43
|
-
{
|
|
44
|
-
fn,
|
|
45
|
-
success,
|
|
46
|
-
error
|
|
47
|
-
} = _actions$,
|
|
48
|
-
action = _objectWithoutProperties(_actions$, ["fn", "success", "error"]);
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
var skip = this.context.parser.parse({
|
|
52
|
-
args,
|
|
53
|
-
arrayIndices: this.arrayIndices,
|
|
54
|
-
input: action.skip,
|
|
55
|
-
location: this.block.blockId
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (skip.output) {
|
|
59
|
-
results.unshift({
|
|
60
|
-
actionId: action.id,
|
|
61
|
-
actionType: action.type,
|
|
62
|
-
skipped: true
|
|
63
|
-
});
|
|
64
|
-
this.callRec(args, actions.slice(1), results, resolve, reject);
|
|
65
|
-
} else {
|
|
66
|
-
fn({
|
|
67
|
-
args,
|
|
68
|
-
arrayIndices: this.arrayIndices,
|
|
69
|
-
blockId: this.block.blockId
|
|
70
|
-
}).then(result => {
|
|
71
|
-
results.unshift(_objectSpread(_objectSpread(_objectSpread({}, result), {}, {
|
|
72
|
-
args
|
|
73
|
-
}, action), {}, {
|
|
74
|
-
skipped: false
|
|
75
|
-
}));
|
|
76
|
-
this.callRec(args, actions.slice(1), results, resolve, reject);
|
|
77
|
-
}).catch(e => {
|
|
78
|
-
results.unshift(_objectSpread(_objectSpread(_objectSpread({}, e), {}, {
|
|
79
|
-
args
|
|
80
|
-
}, action), {}, {
|
|
81
|
-
skipped: false
|
|
82
|
-
}));
|
|
83
|
-
reject(results);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
} catch (e) {
|
|
87
|
-
results.unshift(_objectSpread(_objectSpread({
|
|
88
|
-
args
|
|
89
|
-
}, action), {}, {
|
|
90
|
-
skipped: false,
|
|
91
|
-
error: e
|
|
92
|
-
}));
|
|
93
|
-
reject(results);
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
resolve(results);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
createCall(actions) {
|
|
101
|
-
var fnActions = this.context.Actions.build(actions);
|
|
102
|
-
return args => new Promise((resolve, reject) => {
|
|
103
|
-
this.callRec(args, fnActions, [], resolve, reject);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
init() {
|
|
108
|
-
Object.keys(this.block.actions).forEach(actionName => {
|
|
109
|
-
this.actions[actionName] = {
|
|
110
|
-
loading: false,
|
|
111
|
-
calls: [],
|
|
112
|
-
call: this.createCall(this.block.actions[actionName]),
|
|
113
|
-
actionName
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
callAction(_ref2) {
|
|
119
|
-
var {
|
|
120
|
-
action,
|
|
121
|
-
args,
|
|
122
|
-
hideLoading
|
|
123
|
-
} = _ref2;
|
|
124
|
-
var actionName = action;
|
|
125
|
-
|
|
126
|
-
if (_helpers.type.isUndefined(this.actions[actionName])) {
|
|
127
|
-
return Promise.resolve();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
this.actions[actionName].loading = true;
|
|
131
|
-
this.context.update(this.block.id);
|
|
132
|
-
|
|
133
|
-
var loader = () => true;
|
|
134
|
-
|
|
135
|
-
if (!hideLoading) {
|
|
136
|
-
loader = this.context.displayMessage.loading('Loading...', 0);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return this.actions[actionName] // return to promise to await in test
|
|
140
|
-
.call(args).then(results => {
|
|
141
|
-
this.actions[actionName].calls.unshift({
|
|
142
|
-
args,
|
|
143
|
-
ts: new Date(),
|
|
144
|
-
success: results.map(res => res.successMessage || null)
|
|
145
|
-
});
|
|
146
|
-
results.reverse().forEach(result => {
|
|
147
|
-
if (result.successMessage) {
|
|
148
|
-
this.context.displayMessage.success(result.successMessage);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
this.context.actionLog.push({
|
|
152
|
-
blockId: this.block.blockId,
|
|
153
|
-
actionName,
|
|
154
|
-
response: results,
|
|
155
|
-
ts: new Date(),
|
|
156
|
-
status: 'success'
|
|
157
|
-
});
|
|
158
|
-
this.actions[actionName].loading = false;
|
|
159
|
-
this.block.update = true;
|
|
160
|
-
this.context.update();
|
|
161
|
-
loader();
|
|
162
|
-
return results;
|
|
163
|
-
}).catch(results => {
|
|
164
|
-
this.actions[actionName].calls.unshift({
|
|
165
|
-
args,
|
|
166
|
-
ts: new Date(),
|
|
167
|
-
error: results.map(res => _objectSpread(_objectSpread({}, res), {}, {
|
|
168
|
-
error: _helpers.type.isError(res.error) ? {
|
|
169
|
-
error: res.error,
|
|
170
|
-
message: res.error.message,
|
|
171
|
-
name: res.error.name
|
|
172
|
-
} : null
|
|
173
|
-
}))
|
|
174
|
-
});
|
|
175
|
-
results.reverse().forEach(result => {
|
|
176
|
-
if (result.successMessage) {
|
|
177
|
-
this.context.displayMessage.success(result.successMessage);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (result.errorMessage) {
|
|
181
|
-
this.context.displayMessage.error(result.errorMessage, 6);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
this.context.actionLog.push({
|
|
185
|
-
blockId: this.block.blockId,
|
|
186
|
-
actionName,
|
|
187
|
-
response: results,
|
|
188
|
-
ts: new Date(),
|
|
189
|
-
status: 'error'
|
|
190
|
-
});
|
|
191
|
-
this.actions[actionName].loading = false;
|
|
192
|
-
this.block.update = true;
|
|
193
|
-
this.context.update();
|
|
194
|
-
loader();
|
|
195
|
-
return results;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
registerAction(actionName, actionDefinition) {
|
|
200
|
-
this.actions[actionName] = {
|
|
201
|
-
loading: false,
|
|
202
|
-
calls: [],
|
|
203
|
-
call: this.createCall(actionDefinition),
|
|
204
|
-
actionName
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
var _default = BlockActions;
|
|
211
|
-
exports.default = _default;
|
package/dist/Mutations.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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 mutation callMutation($requestMutationInput: RequestMutationInput!) {\n requestMutation(requestMutationInput: $requestMutationInput) {\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_MUTATION = (0, _graphqlTag.default)(_templateObject());
|
|
27
|
-
|
|
28
|
-
class Mutations {
|
|
29
|
-
constructor(context) {
|
|
30
|
-
this.context = context;
|
|
31
|
-
this.mutationList = this.context.rootBlock.mutations || [];
|
|
32
|
-
this.callMutation = this.callMutation.bind(this);
|
|
33
|
-
this.fetch = this.fetch.bind(this);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
callMutation(_ref) {
|
|
37
|
-
var {
|
|
38
|
-
mutationId,
|
|
39
|
-
args,
|
|
40
|
-
arrayIndices
|
|
41
|
-
} = _ref;
|
|
42
|
-
|
|
43
|
-
if (!this.context.mutations[mutationId]) {
|
|
44
|
-
var mutation = this.mutationList.find(mut => mut.mutationId === mutationId);
|
|
45
|
-
|
|
46
|
-
if (!mutation) {
|
|
47
|
-
this.context.mutations[mutationId] = {
|
|
48
|
-
loading: false,
|
|
49
|
-
response: null,
|
|
50
|
-
error: [new Error("Configuration Error: Mutation ".concat(mutationId, " not defined on context."))]
|
|
51
|
-
};
|
|
52
|
-
return Promise.reject(new Error("Configuration Error: Mutation ".concat(mutationId, " not defined on context.")));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.context.mutations[mutationId] = {
|
|
56
|
-
loading: true,
|
|
57
|
-
response: null,
|
|
58
|
-
error: []
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return this.fetch(mutationId, args, arrayIndices);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
fetch(mutationId, args, arrayIndices) {
|
|
66
|
-
this.context.mutations[mutationId].loading = true;
|
|
67
|
-
return this.context.client.mutate({
|
|
68
|
-
mutation: CALL_MUTATION,
|
|
69
|
-
variables: {
|
|
70
|
-
requestMutationInput: {
|
|
71
|
-
arrayIndices,
|
|
72
|
-
mutationId,
|
|
73
|
-
args: _helpers.serializer.serialize(args) || {},
|
|
74
|
-
blockId: this.context.blockId,
|
|
75
|
-
input: _helpers.serializer.serialize(this.context.input),
|
|
76
|
-
lowdefyGlobal: _helpers.serializer.serialize(this.context.lowdefyGlobal),
|
|
77
|
-
pageId: this.context.pageId,
|
|
78
|
-
state: _helpers.serializer.serialize(this.context.state),
|
|
79
|
-
urlQuery: _helpers.serializer.serialize(this.context.urlQuery)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}).then(result => {
|
|
83
|
-
this.context.mutations[mutationId].response = _helpers.serializer.deserialize((0, _helpers.get)(result, 'data.requestMutation.response', {
|
|
84
|
-
default: null
|
|
85
|
-
}));
|
|
86
|
-
this.context.mutations[mutationId].error.unshift(null);
|
|
87
|
-
return this.context.mutations[mutationId].response;
|
|
88
|
-
}).catch(error => {
|
|
89
|
-
this.context.mutations[mutationId].error.unshift(error);
|
|
90
|
-
throw error;
|
|
91
|
-
}).finally(() => {
|
|
92
|
-
this.context.mutations[mutationId].loading = false;
|
|
93
|
-
this.context.update();
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var _default = Mutations;
|
|
100
|
-
exports.default = _default;
|
package/dist/getFieldValues.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
/*
|
|
11
|
-
Copyright 2020 Lowdefy, Inc
|
|
12
|
-
|
|
13
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
you may not use this file except in compliance with the License.
|
|
15
|
-
You may obtain a copy of the License at
|
|
16
|
-
|
|
17
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
-
|
|
19
|
-
Unless required by applicable law or agreed to in writing, software
|
|
20
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
-
See the License for the specific language governing permissions and
|
|
23
|
-
limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
function getFieldValues(operatorName) {
|
|
26
|
-
var result = new Set();
|
|
27
|
-
|
|
28
|
-
function reviver(key, value) {
|
|
29
|
-
if (key === operatorName) {
|
|
30
|
-
result.add(value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
37
|
-
args[_key - 1] = arguments[_key];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[...args].forEach(element => {
|
|
41
|
-
_helpers.serializer.deserializeFromString(_helpers.serializer.serializeToString(element), {
|
|
42
|
-
reviver
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
return [...result];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var _default = getFieldValues;
|
|
49
|
-
exports.default = _default;
|
package/dist/makeContextId.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
/*
|
|
11
|
-
Copyright 2020 Lowdefy, Inc
|
|
12
|
-
|
|
13
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
you may not use this file except in compliance with the License.
|
|
15
|
-
You may obtain a copy of the License at
|
|
16
|
-
|
|
17
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
-
|
|
19
|
-
Unless required by applicable law or agreed to in writing, software
|
|
20
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
-
See the License for the specific language governing permissions and
|
|
23
|
-
limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
function makeContextId(_ref) {
|
|
26
|
-
var {
|
|
27
|
-
blockId,
|
|
28
|
-
pageId,
|
|
29
|
-
urlQuery = {}
|
|
30
|
-
} = _ref;
|
|
31
|
-
|
|
32
|
-
if (!_helpers.type.isString(blockId)) {
|
|
33
|
-
throw new Error("Expected string for parameter blockId, received ".concat(blockId));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!_helpers.type.isString(pageId)) {
|
|
37
|
-
throw new Error("Expected string for parameter pageId, received ".concat(pageId));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return "".concat(pageId, ":").concat(blockId, ":").concat(_helpers.serializer.serializeToString(urlQuery));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var _default = makeContextId;
|
|
44
|
-
exports.default = _default;
|