@lowdefy/actions-core 4.0.0-alpha.9 → 4.0.0-rc.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/dist/actions/DisplayMessage.js +2 -12
- package/dist/actions/Fetch.js +24 -0
- package/dist/actions/GeolocationCurrentPosition.js +36 -0
- package/dist/actions/Logout.js +2 -2
- package/dist/actions/ScrollTo.js +2 -1
- package/dist/actions/Wait.js +1 -1
- package/dist/actions.js +2 -0
- package/package.json +17 -14
- package/dist/actions/testContext.js +0 -69
|
@@ -14,19 +14,9 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
function DisplayMessage({ methods: { displayMessage } , params }) {
|
|
17
|
-
if (!type.isObject(params)
|
|
17
|
+
if (!type.isObject(params)) {
|
|
18
18
|
throw new Error(`Invalid DisplayMessage, check action params. Params must be an object, received "${JSON.stringify(params)}".`);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
displayMessage({
|
|
22
|
-
content: 'Success'
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
if (type.isObject(params)) {
|
|
26
|
-
displayMessage({
|
|
27
|
-
...params,
|
|
28
|
-
content: type.isNone(params.content) ? 'Success' : params.content
|
|
29
|
-
});
|
|
30
|
-
}
|
|
20
|
+
displayMessage(params);
|
|
31
21
|
}
|
|
32
22
|
export default DisplayMessage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ async function Fetch({ globals , params }) {
|
|
16
|
+
const { fetch } = globals;
|
|
17
|
+
const { url , options , responseFunction } = params;
|
|
18
|
+
const res = await fetch(url, options);
|
|
19
|
+
if (responseFunction) {
|
|
20
|
+
return res[responseFunction]();
|
|
21
|
+
}
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
export default Fetch;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ async function GeolocationCurrentPosition({ globals , params }) {
|
|
16
|
+
try {
|
|
17
|
+
const position = await new Promise((resolve, reject)=>{
|
|
18
|
+
globals.window.navigator.geolocation.getCurrentPosition(resolve, reject, params);
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
coords: {
|
|
22
|
+
accuracy: position.coords.accuracy,
|
|
23
|
+
altitude: position.coords.altitude,
|
|
24
|
+
altitudeAccuracy: position.coords.altitudeAccuracy,
|
|
25
|
+
heading: position.coords.heading,
|
|
26
|
+
latitude: position.coords.latitude,
|
|
27
|
+
longitude: position.coords.longitude,
|
|
28
|
+
speed: position.coords.speed
|
|
29
|
+
},
|
|
30
|
+
timestamp: position.timestamp
|
|
31
|
+
};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export default GeolocationCurrentPosition;
|
package/dist/actions/Logout.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ function Logout({ methods: { logout } }) {
|
|
16
|
-
return logout();
|
|
15
|
+
*/ function Logout({ methods: { logout } , params }) {
|
|
16
|
+
return logout(params);
|
|
17
17
|
}
|
|
18
18
|
export default Logout;
|
package/dist/actions/ScrollTo.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
-
function ScrollTo({
|
|
16
|
+
function ScrollTo({ globals , params }) {
|
|
17
|
+
const { document , window } = globals;
|
|
17
18
|
if (!type.isObject(params)) {
|
|
18
19
|
throw new Error(`Invalid ScrollTo, check action params. Received "${JSON.stringify(params)}".`);
|
|
19
20
|
}
|
package/dist/actions/Wait.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type, wait } from '@lowdefy/helpers';
|
|
16
16
|
function Wait({ params }) {
|
|
17
|
-
if (!type.isInt(params.ms)) {
|
|
17
|
+
if (type.isNone(params) || !type.isInt(params.ms)) {
|
|
18
18
|
throw new Error(`Wait action "ms" param should be an integer.`);
|
|
19
19
|
}
|
|
20
20
|
return wait(params.ms);
|
package/dist/actions.js
CHANGED
|
@@ -17,6 +17,8 @@ export { default as Link } from './actions/Link.js';
|
|
|
17
17
|
export { default as Login } from './actions/Login.js';
|
|
18
18
|
export { default as Logout } from './actions/Logout.js';
|
|
19
19
|
export { default as DisplayMessage } from './actions/DisplayMessage.js';
|
|
20
|
+
export { default as Fetch } from './actions/Fetch.js';
|
|
21
|
+
export { default as GeolocationCurrentPosition } from './actions/GeolocationCurrentPosition.js';
|
|
20
22
|
export { default as Request } from './actions/Request.js';
|
|
21
23
|
export { default as Reset } from './actions/Reset.js';
|
|
22
24
|
export { default as ResetValidation } from './actions/ResetValidation.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/actions-core",
|
|
3
|
-
"version": "4.0.0-
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-rc.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
7
7
|
"keywords": [
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
{
|
|
25
25
|
"name": "Sandile Memela",
|
|
26
26
|
"url": "https://github.com/sah-memela"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Stephanie Smit",
|
|
30
|
+
"url": "https://github.com/StephanieJKS"
|
|
27
31
|
}
|
|
28
32
|
],
|
|
29
33
|
"repository": {
|
|
@@ -39,25 +43,24 @@
|
|
|
39
43
|
"dist/*"
|
|
40
44
|
],
|
|
41
45
|
"scripts": {
|
|
42
|
-
"build": "
|
|
46
|
+
"build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
|
|
43
47
|
"clean": "rm -rf dist",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"test": "jest --coverage"
|
|
48
|
+
"prepublishOnly": "pnpm build",
|
|
49
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
47
50
|
},
|
|
48
51
|
"dependencies": {
|
|
49
|
-
"@lowdefy/helpers": "4.0.0-
|
|
52
|
+
"@lowdefy/helpers": "4.0.0-rc.0"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@swc/
|
|
55
|
-
"@swc/
|
|
56
|
-
"
|
|
57
|
-
"jest": "
|
|
55
|
+
"@jest/globals": "28.1.0",
|
|
56
|
+
"@swc/cli": "0.1.57",
|
|
57
|
+
"@swc/core": "1.2.194",
|
|
58
|
+
"@swc/jest": "0.2.21",
|
|
59
|
+
"jest": "28.1.0",
|
|
60
|
+
"jest-environment-jsdom": "28.1.0"
|
|
58
61
|
},
|
|
59
62
|
"publishConfig": {
|
|
60
63
|
"access": "public"
|
|
61
64
|
},
|
|
62
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
|
|
63
66
|
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 { Actions, Blocks, Requests, State } from '@lowdefy/engine';
|
|
16
|
-
import { WebParser } from '@lowdefy/operators';
|
|
17
|
-
const testContext = ({ lowdefy , operators , rootBlock , initState ={} })=>{
|
|
18
|
-
const testLowdefy = {
|
|
19
|
-
inputs: {
|
|
20
|
-
test: {}
|
|
21
|
-
},
|
|
22
|
-
urlQuery: {},
|
|
23
|
-
...lowdefy,
|
|
24
|
-
_internal: {
|
|
25
|
-
displayMessage: ()=>()=>undefined
|
|
26
|
-
,
|
|
27
|
-
updateBlock: ()=>{},
|
|
28
|
-
...lowdefy._internal
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const ctx = {
|
|
32
|
-
id: 'test',
|
|
33
|
-
pageId: rootBlock.blockId,
|
|
34
|
-
eventLog: [],
|
|
35
|
-
requests: {},
|
|
36
|
-
state: {},
|
|
37
|
-
_internal: {
|
|
38
|
-
lowdefy: testLowdefy,
|
|
39
|
-
rootBlock
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const _internal = ctx._internal;
|
|
43
|
-
_internal.parser = new WebParser({
|
|
44
|
-
context: ctx,
|
|
45
|
-
contexts: {},
|
|
46
|
-
operators: operators || {}
|
|
47
|
-
});
|
|
48
|
-
_internal.State = new State(ctx);
|
|
49
|
-
_internal.Actions = new Actions(ctx);
|
|
50
|
-
_internal.Requests = new Requests(ctx);
|
|
51
|
-
_internal.RootBlocks = new Blocks({
|
|
52
|
-
areas: _internal.rootBlock.areas,
|
|
53
|
-
context: ctx
|
|
54
|
-
});
|
|
55
|
-
_internal.RootBlocks.init();
|
|
56
|
-
_internal.update = ()=>{
|
|
57
|
-
_internal.RootBlocks.update();
|
|
58
|
-
};
|
|
59
|
-
if (initState) {
|
|
60
|
-
Object.keys(initState).forEach((key)=>{
|
|
61
|
-
_internal.State.set(key, initState[key]);
|
|
62
|
-
});
|
|
63
|
-
_internal.RootBlocks.reset();
|
|
64
|
-
}
|
|
65
|
-
_internal.update();
|
|
66
|
-
_internal.State.freezeState();
|
|
67
|
-
return ctx;
|
|
68
|
-
};
|
|
69
|
-
export default testContext;
|