@lowdefy/build 4.0.0-alpha.1 → 4.0.0-alpha.10
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/build/addDefaultPages/404.js +37 -42
- package/dist/build/addDefaultPages/addDefaultPages.js +7 -3
- package/dist/build/buildAuth/buildAuth.js +1 -1
- package/dist/build/buildAuth/getPageRoles.js +2 -3
- package/dist/build/buildAuth/getProtectedPages.js +1 -1
- package/dist/build/buildConnections.js +2 -3
- package/dist/build/buildIcons.js +91 -0
- package/dist/build/buildMenu.js +1 -1
- package/dist/build/buildPages/buildBlock/buildBlock.js +6 -2
- package/dist/build/buildPages/buildBlock/buildEvents.js +5 -2
- package/dist/build/buildPages/buildBlock/buildRequests.js +2 -3
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +1 -1
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +4 -6
- package/dist/build/buildPages/buildBlock/countBlockTypes.js +18 -0
- package/dist/build/buildPages/buildBlock/moveSkeletonBlocksToArea.js +35 -0
- package/dist/build/buildPages/buildBlock/moveSubBlocksToArea.js +1 -1
- package/dist/build/buildPages/buildBlock/setBlockId.js +1 -1
- package/dist/build/buildPages/buildBlock/validateBlock.js +2 -3
- package/dist/build/buildPages/buildPage.js +1 -1
- package/dist/build/buildPages/buildPages.js +1 -1
- package/dist/build/buildRefs/buildRefs.js +3 -3
- package/dist/build/buildRefs/evaluateBuildOperators.js +35 -0
- package/dist/build/buildRefs/getConfigFile.js +1 -1
- package/dist/build/buildRefs/getRefContent.js +2 -2
- package/dist/build/buildRefs/getRefPath.js +1 -1
- package/dist/build/buildRefs/getRefsFromFile.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +7 -4
- package/dist/build/buildRefs/makeRefDefinition.js +2 -3
- package/dist/build/buildRefs/parseNunjucks.js +1 -1
- package/dist/build/buildRefs/parseRefContent.js +3 -3
- package/dist/build/buildRefs/populateRefs.js +1 -1
- package/dist/build/buildRefs/recursiveBuild.js +10 -5
- package/dist/build/buildRefs/runRefResolver.js +1 -1
- package/dist/build/buildRefs/runTransformer.js +8 -4
- package/dist/build/buildStyles.js +29 -0
- package/dist/build/buildTypes.js +50 -44
- package/dist/build/cleanBuildDirectory.js +2 -2
- package/dist/build/copyPublicFolder.js +23 -0
- package/dist/build/testSchema.js +1 -1
- package/dist/build/updateServerPackageJson.js +46 -0
- package/dist/build/validateApp.js +3 -5
- package/dist/build/validateConfig.js +13 -9
- package/dist/build/writeApp.js +2 -6
- package/dist/build/writeConfig.js +2 -6
- package/dist/build/writeConnections.js +2 -5
- package/dist/build/writeGlobal.js +3 -7
- package/dist/build/writeMenus.js +2 -5
- package/dist/build/writePages.js +3 -14
- package/dist/build/writePluginImports/generateImportFile.js +36 -0
- package/dist/build/writePluginImports/writeActionImports.js +22 -0
- package/dist/build/writePluginImports/writeBlockImports.js +6 -23
- package/dist/build/writePluginImports/writeConnectionImports.js +6 -23
- package/dist/build/writePluginImports/writeIconImports.js +31 -0
- package/dist/build/writePluginImports/writeOperatorImports.js +26 -0
- package/dist/build/writePluginImports/writeStyleImports.js +28 -0
- package/dist/build/writeRequests.js +3 -8
- package/dist/build/writeTypes.js +2 -5
- package/dist/defaultTypesMap.json +1598 -0
- package/dist/index.js +143 -111
- package/dist/lowdefySchema.js +72 -24
- package/dist/scripts/generateDefaultTypes.js +42 -76
- package/dist/scripts/run.js +13 -12
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +3 -6
- package/dist/test/buildRefs/testBuildRefsErrorResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsNullResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsParsingResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsTransform.js +2 -2
- package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +2 -2
- package/dist/test/testContext.js +12 -19
- package/dist/utils/countOperators.js +1 -1
- package/dist/utils/createCheckDuplicateId.js +1 -1
- package/dist/utils/createCounter.js +1 -1
- package/dist/utils/createPluginTypesMap.js +85 -0
- package/dist/utils/formatErrorMessage.js +2 -2
- package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +3 -3
- package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +4 -7
- package/package.json +47 -16
- package/dist/defaultTypes.json +0 -60
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -12,45 +12,40 @@
|
|
|
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
|
-
*/
|
|
16
|
-
export default {
|
|
15
|
+
*/ export default {
|
|
17
16
|
id: '404',
|
|
18
|
-
type: '
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// ],
|
|
54
|
-
// },
|
|
55
|
-
// },
|
|
56
|
-
// };
|
|
17
|
+
type: 'Result',
|
|
18
|
+
style: {
|
|
19
|
+
minHeight: '100vh'
|
|
20
|
+
},
|
|
21
|
+
properties: {
|
|
22
|
+
status: 404,
|
|
23
|
+
title: '404',
|
|
24
|
+
subTitle: 'Sorry, the page you are visiting does not exist.'
|
|
25
|
+
},
|
|
26
|
+
areas: {
|
|
27
|
+
extra: {
|
|
28
|
+
blocks: [
|
|
29
|
+
{
|
|
30
|
+
id: 'home',
|
|
31
|
+
type: 'Button',
|
|
32
|
+
properties: {
|
|
33
|
+
title: 'Go to home page',
|
|
34
|
+
type: 'Link'
|
|
35
|
+
},
|
|
36
|
+
events: {
|
|
37
|
+
onClick: [
|
|
38
|
+
{
|
|
39
|
+
id: 'home',
|
|
40
|
+
type: 'Link',
|
|
41
|
+
params: {
|
|
42
|
+
home: true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -26,8 +26,12 @@ async function addDefaultPages({ components }) {
|
|
|
26
26
|
if (!type.isArray(components.pages)) {
|
|
27
27
|
throw new Error('lowdefy.pages is not an array.');
|
|
28
28
|
}
|
|
29
|
-
const pageIds = components.pages.map((page)=>
|
|
30
|
-
|
|
29
|
+
const pageIds = components.pages.map((page, index)=>{
|
|
30
|
+
if (!type.isObject(page)) {
|
|
31
|
+
throw new Error(`pages[${index}] is not an object. Received ${JSON.stringify(page)}`);
|
|
32
|
+
}
|
|
33
|
+
return page.id;
|
|
34
|
+
});
|
|
31
35
|
// deep copy to avoid mutating defaultConfig
|
|
32
36
|
const filteredDefaultPages = defaultPages.filter((defaultPage)=>!pageIds.includes(defaultPage.id)
|
|
33
37
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ function getPageRoles({ components }) {
|
|
16
16
|
const roles = components.config.auth.pages.roles;
|
|
17
|
-
const pageRoles = {
|
|
18
|
-
};
|
|
17
|
+
const pageRoles = {};
|
|
19
18
|
Object.keys(roles).forEach((roleName)=>{
|
|
20
19
|
roles[roleName].forEach((pageId)=>{
|
|
21
20
|
if (!pageRoles[pageId]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -36,8 +36,7 @@ async function buildConnections({ components , context }) {
|
|
|
36
36
|
context.typeCounters.connections.increment(connection.type);
|
|
37
37
|
connection.connectionId = connection.id;
|
|
38
38
|
connection.id = `connection:${connection.id}`;
|
|
39
|
-
countOperators(connection.properties || {
|
|
40
|
-
}, {
|
|
39
|
+
countOperators(connection.properties || {}, {
|
|
41
40
|
counter: context.typeCounters.operators.server
|
|
42
41
|
});
|
|
43
42
|
});
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
*/ const iconPackages = {
|
|
16
|
+
'react-icons/ai': /"(Ai[A-Z0-9]\w*)"/gm,
|
|
17
|
+
'react-icons/bs': /"(Bs[A-Z0-9]\w*)"/gm,
|
|
18
|
+
'react-icons/bi': /"(Bi[A-Z0-9]\w*)"/gm,
|
|
19
|
+
'react-icons/di': /"(Di[A-Z0-9]\w*)"/gm,
|
|
20
|
+
'react-icons/fi': /"(Fi[A-Z0-9]\w*)"/gm,
|
|
21
|
+
'react-icons/fc': /"(Fc[A-Z0-9]\w*)"/gm,
|
|
22
|
+
'react-icons/fa': /"(Fa[A-Z0-9]\w*)"/gm,
|
|
23
|
+
'react-icons/gi': /"(Gi[A-Z0-9]\w*)"/gm,
|
|
24
|
+
'react-icons/go': /"(Go[A-Z0-9]\w*)"/gm,
|
|
25
|
+
'react-icons/gr': /"(Gr[A-Z0-9]\w*)"/gm,
|
|
26
|
+
'react-icons/hi': /"(Hi[A-Z0-9]\w*)"/gm,
|
|
27
|
+
'react-icons/im': /"(Im[A-Z0-9]\w*)"/gm,
|
|
28
|
+
'react-icons/io': /"(IoIos[A-Z0-9]\w*)"/gm,
|
|
29
|
+
'react-icons/io5': /"(Io[A-Z0-9]\w*)"/gm,
|
|
30
|
+
'react-icons/md': /"(Md[A-Z0-9]\w*)"/gm,
|
|
31
|
+
'react-icons/ri': /"(Ri[A-Z0-9]\w*)"/gm,
|
|
32
|
+
'react-icons/si': /"(Si[A-Z0-9]\w*)"/gm,
|
|
33
|
+
'react-icons/ti': /"(Ti[A-Z0-9]\w*)"/gm,
|
|
34
|
+
'react-icons/vsc': /"(Vsc[A-Z0-9]\w*)"/gm,
|
|
35
|
+
'react-icons/wi': /"(Wi[A-Z0-9]\w*)"/gm,
|
|
36
|
+
'react-icons/cg': /"(Cg[A-Z0-9]\w*)"/gm
|
|
37
|
+
};
|
|
38
|
+
function getConfigIcons({ components , icons , regex }) {
|
|
39
|
+
[
|
|
40
|
+
...JSON.stringify(components.global || {}).matchAll(regex)
|
|
41
|
+
].map((match)=>icons.add(match[1])
|
|
42
|
+
);
|
|
43
|
+
[
|
|
44
|
+
...JSON.stringify(components.menus || []).matchAll(regex)
|
|
45
|
+
].map((match)=>icons.add(match[1])
|
|
46
|
+
);
|
|
47
|
+
[
|
|
48
|
+
...JSON.stringify(components.pages || []).matchAll(regex)
|
|
49
|
+
].map((match)=>icons.add(match[1])
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function getBlockDefaultIcons({ components , context , icons , regex }) {
|
|
53
|
+
Object.keys(components.types.blocks).forEach((blockName)=>{
|
|
54
|
+
(context.typesMap.icons[blockName] || []).forEach((icon)=>{
|
|
55
|
+
[
|
|
56
|
+
...JSON.stringify(icon).matchAll(regex)
|
|
57
|
+
].map((match)=>icons.add(match[1])
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function buildIcons({ components , context }) {
|
|
63
|
+
components.icons = [];
|
|
64
|
+
Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
|
|
65
|
+
const icons = new Set();
|
|
66
|
+
// TODO: Can we do better than this?
|
|
67
|
+
// Add default icons
|
|
68
|
+
if (iconPackage === 'react-icons/ai') {
|
|
69
|
+
icons.add('AiOutlineLoading3Quarters');
|
|
70
|
+
icons.add('AiOutlineExclamationCircle');
|
|
71
|
+
}
|
|
72
|
+
getConfigIcons({
|
|
73
|
+
components,
|
|
74
|
+
icons,
|
|
75
|
+
regex
|
|
76
|
+
});
|
|
77
|
+
getBlockDefaultIcons({
|
|
78
|
+
components,
|
|
79
|
+
context,
|
|
80
|
+
icons,
|
|
81
|
+
regex
|
|
82
|
+
});
|
|
83
|
+
components.icons.push({
|
|
84
|
+
icons: [
|
|
85
|
+
...icons
|
|
86
|
+
],
|
|
87
|
+
package: iconPackage
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export default buildIcons;
|
package/dist/build/buildMenu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -16,16 +16,20 @@
|
|
|
16
16
|
import buildRequests from './buildRequests.js';
|
|
17
17
|
import buildSubBlocks from './buildSubBlocks.js';
|
|
18
18
|
import countBlockOperators from './countBlockOperators.js';
|
|
19
|
+
import countBlockTypes from './countBlockTypes.js';
|
|
19
20
|
import moveSubBlocksToArea from './moveSubBlocksToArea.js';
|
|
21
|
+
import moveSkeletonBlocksToArea from './moveSkeletonBlocksToArea.js';
|
|
20
22
|
import setBlockId from './setBlockId.js';
|
|
21
23
|
import validateBlock from './validateBlock.js';
|
|
22
24
|
async function buildBlock(block, pageContext) {
|
|
23
25
|
validateBlock(block, pageContext);
|
|
24
|
-
countBlockOperators(block, pageContext);
|
|
25
26
|
setBlockId(block, pageContext);
|
|
27
|
+
countBlockOperators(block, pageContext);
|
|
26
28
|
buildEvents(block, pageContext);
|
|
27
29
|
buildRequests(block, pageContext);
|
|
28
30
|
moveSubBlocksToArea(block, pageContext);
|
|
31
|
+
moveSkeletonBlocksToArea(block, pageContext);
|
|
32
|
+
countBlockTypes(block, pageContext);
|
|
29
33
|
await buildSubBlocks(block, pageContext);
|
|
30
34
|
}
|
|
31
35
|
export default buildBlock;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -44,7 +44,10 @@ function buildEvents(block, pageContext) {
|
|
|
44
44
|
if (!type.isArray(block.events[key].try)) {
|
|
45
45
|
throw new Error(`Events must be an array of actions at "${block.blockId}" in event "${key}" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].try)}`);
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
47
|
+
if (type.isNone(block.events[key].catch)) {
|
|
48
|
+
block.events[key].catch = [];
|
|
49
|
+
}
|
|
50
|
+
if (!type.isArray(block.events[key].catch)) {
|
|
48
51
|
throw new Error(`Catch events must be an array of actions at "${block.blockId}" in event "${key}" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].catch)}`);
|
|
49
52
|
}
|
|
50
53
|
const checkDuplicateActionId = createCheckDuplicateId({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -32,8 +32,7 @@ function buildRequest(request, pageContext) {
|
|
|
32
32
|
throw new Error(`Request type is not a string at at request at "${request.id}" at page "${pageId}". Received ${JSON.stringify(request.type)}.`);
|
|
33
33
|
}
|
|
34
34
|
typeCounters.requests.increment(request.type);
|
|
35
|
-
if (type.isUndefined(request.payload)) request.payload = {
|
|
36
|
-
};
|
|
35
|
+
if (type.isUndefined(request.payload)) request.payload = {};
|
|
37
36
|
if (!type.isObject(request.payload)) {
|
|
38
37
|
throw new Error(`Request "${request.id}" at page "${pageId}" payload should be an object.`);
|
|
39
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -15,17 +15,15 @@
|
|
|
15
15
|
*/ import countOperators from '../../../utils/countOperators.js';
|
|
16
16
|
function countBlockOperators(block, { typeCounters }) {
|
|
17
17
|
// eslint-disable-next-line no-unused-vars
|
|
18
|
-
const { requests ,
|
|
18
|
+
const { requests , areas , blocks , ...webBlock } = block;
|
|
19
19
|
countOperators(webBlock, {
|
|
20
20
|
counter: typeCounters.operators.client
|
|
21
21
|
});
|
|
22
22
|
(requests || []).forEach((request)=>{
|
|
23
|
-
countOperators(request.payload || {
|
|
24
|
-
}, {
|
|
23
|
+
countOperators(request.payload || {}, {
|
|
25
24
|
counter: typeCounters.operators.client
|
|
26
25
|
});
|
|
27
|
-
countOperators(request.properties || {
|
|
28
|
-
}, {
|
|
26
|
+
countOperators(request.properties || {}, {
|
|
29
27
|
counter: typeCounters.operators.server
|
|
30
28
|
});
|
|
31
29
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
*/ function countBlockTypes(block, { typeCounters }) {
|
|
16
|
+
typeCounters.blocks.increment(block.type);
|
|
17
|
+
}
|
|
18
|
+
export default countBlockTypes;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { set, type } from '@lowdefy/helpers';
|
|
16
|
+
function recMoveSkeletonBlocksToArea(block1, blockId, pageId) {
|
|
17
|
+
if (!type.isNone(block1.blocks)) {
|
|
18
|
+
if (!type.isArray(block1.blocks)) {
|
|
19
|
+
throw new Error(`Skeleton blocks at ${blockId} on page ${pageId} is not an array. Received ${JSON.stringify(block1.blocks)}`);
|
|
20
|
+
}
|
|
21
|
+
set(block1, 'areas.content.blocks', block1.blocks);
|
|
22
|
+
delete block1.blocks;
|
|
23
|
+
}
|
|
24
|
+
Object.keys(block1.areas || {}).forEach((area)=>{
|
|
25
|
+
block1.areas[area].blocks.forEach((block, i)=>{
|
|
26
|
+
recMoveSkeletonBlocksToArea(block, `${blockId}.areas.${area}.${i}.blocks`, pageId);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function moveSkeletonBlocksToArea(block, pageContext) {
|
|
31
|
+
if (type.isObject(block.skeleton)) {
|
|
32
|
+
recMoveSkeletonBlocksToArea(block.skeleton, `${block.blockId}.skeleton`, pageContext.pageId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default moveSkeletonBlocksToArea;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,7 +13,7 @@
|
|
|
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 validateBlock(block, { pageId
|
|
16
|
+
function validateBlock(block, { pageId }) {
|
|
17
17
|
if (!type.isObject(block)) {
|
|
18
18
|
throw new Error(`Expected block to be an object on page "${pageId}". Received ${JSON.stringify(block)}.`);
|
|
19
19
|
}
|
|
@@ -29,7 +29,6 @@ function validateBlock(block, { pageId , typeCounters }) {
|
|
|
29
29
|
if (!type.isString(block.type)) {
|
|
30
30
|
throw new Error(`Block type is not a string at "${block.id}" on page "${pageId}". Received ${JSON.stringify(block.type)}.`);
|
|
31
31
|
}
|
|
32
|
-
typeCounters.blocks.increment(block.type);
|
|
33
32
|
if (!type.isNone(block.requests)) {
|
|
34
33
|
if (!type.isArray(block.requests)) {
|
|
35
34
|
throw new Error(`Requests is not an array at "${block.id}" on page "${pageId}". Received ${JSON.stringify(block.requests)}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import recursiveBuild from './recursiveBuild.js';
|
|
16
16
|
import makeRefDefinition from './makeRefDefinition.js';
|
|
17
|
+
// TODO: build operators aren't evaluated in lowdefy.yaml file. Move recursive call up a layer or something.
|
|
17
18
|
async function buildRefs({ context }) {
|
|
18
19
|
const components = await recursiveBuild({
|
|
19
20
|
context,
|
|
20
21
|
refDef: makeRefDefinition('lowdefy.yaml'),
|
|
21
22
|
count: 0
|
|
22
23
|
});
|
|
23
|
-
return components || {
|
|
24
|
-
};
|
|
24
|
+
return components || {};
|
|
25
25
|
}
|
|
26
26
|
export default buildRefs;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { NodeParser } from '@lowdefy/operators';
|
|
16
|
+
import operators from '@lowdefy/operators-js/operators/build';
|
|
17
|
+
async function evaluateBuildOperators({ context , input , refDef }) {
|
|
18
|
+
const operatorsParser = new NodeParser({
|
|
19
|
+
env: process.env,
|
|
20
|
+
operators
|
|
21
|
+
});
|
|
22
|
+
const { output , errors } = operatorsParser.parse({
|
|
23
|
+
input,
|
|
24
|
+
location: refDef.path,
|
|
25
|
+
operatorPrefix: '_build.'
|
|
26
|
+
});
|
|
27
|
+
if (errors.length > 0) {
|
|
28
|
+
await context.logger.warn('Build operator errors.');
|
|
29
|
+
const promises = errors.map((error)=>context.logger.warn(error.message)
|
|
30
|
+
);
|
|
31
|
+
await promises;
|
|
32
|
+
}
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
35
|
+
export default evaluateBuildOperators;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -17,7 +17,7 @@ import parseRefContent from './parseRefContent.js';
|
|
|
17
17
|
import runRefResolver from './runRefResolver.js';
|
|
18
18
|
async function getRefContent({ context , refDef , referencedFrom }) {
|
|
19
19
|
let content;
|
|
20
|
-
if (refDef.path === 'lowdefy.yaml') {
|
|
20
|
+
if (refDef.path === 'lowdefy.yaml' || refDef.path === 'lowdefy.yml') {
|
|
21
21
|
content = await getConfigFile({
|
|
22
22
|
context,
|
|
23
23
|
refDef,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,9 +13,12 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import path from 'path';
|
|
16
|
-
import { readFile } from '@lowdefy/node-utils';
|
|
17
16
|
async function getUserJavascriptFunction({ context , filePath }) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
try {
|
|
18
|
+
return (await import(path.resolve(context.directories.config, filePath))).default;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
context.logger.error(`Error importing ${filePath}.`);
|
|
21
|
+
throw Error(error);
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
export default getUserJavascriptFunction;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -23,8 +23,7 @@ function makeRefDefinition(refDefinition) {
|
|
|
23
23
|
resolver: get(refDefinition, 'resolver'),
|
|
24
24
|
transformer: get(refDefinition, 'transformer'),
|
|
25
25
|
vars: get(refDefinition, 'vars', {
|
|
26
|
-
default: {
|
|
27
|
-
}
|
|
26
|
+
default: {}
|
|
28
27
|
})
|
|
29
28
|
};
|
|
30
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
import { getFileExtension, getFileSubExtension } from '@lowdefy/node-utils';
|
|
17
17
|
import JSON5 from 'json5';
|
|
18
|
-
import YAML from '
|
|
18
|
+
import YAML from 'yaml';
|
|
19
19
|
import parseNunjucks from './parseNunjucks.js';
|
|
20
20
|
function parseRefContent({ content , refDef }) {
|
|
21
21
|
const { path , vars } = refDef;
|
|
@@ -26,7 +26,7 @@ function parseRefContent({ content , refDef }) {
|
|
|
26
26
|
ext = getFileSubExtension(path);
|
|
27
27
|
}
|
|
28
28
|
if (ext === 'yaml' || ext === 'yml') {
|
|
29
|
-
return YAML.
|
|
29
|
+
return YAML.parse(content);
|
|
30
30
|
}
|
|
31
31
|
if (ext === 'json') {
|
|
32
32
|
return JSON5.parse(content);
|