@lowdefy/build 4.0.0-alpha.1 → 4.0.0-alpha.12
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 +10 -29
- package/dist/build/buildAuth/buildAuthPlugins.js +78 -0
- package/dist/build/buildAuth/buildPageAuth.js +50 -0
- package/dist/build/buildAuth/getPageRoles.js +3 -4
- package/dist/build/buildAuth/getProtectedPages.js +6 -6
- package/dist/build/buildAuth/validateAuthConfig.js +61 -0
- package/dist/build/buildConnections.js +2 -3
- package/dist/build/buildImports/buildIconImports.js +87 -0
- package/dist/build/buildImports/buildImports.js +30 -0
- package/dist/build/buildImports/buildImportsDev.js +103 -0
- package/dist/build/buildImports/buildImportsProd.js +54 -0
- package/dist/build/buildImports/buildStyleImports.js +28 -0
- package/dist/build/buildImports/defaultIconsDev.js +584 -0
- package/dist/build/buildImports/defaultIconsProd.js +21 -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/buildTypes.js +72 -43
- package/dist/build/cleanBuildDirectory.js +2 -2
- package/dist/build/copyPublicFolder.js +23 -0
- package/dist/build/testSchema.js +3 -4
- package/dist/build/updateServerPackageJson.js +49 -0
- package/dist/build/validateApp.js +3 -5
- package/dist/build/validateConfig.js +8 -28
- package/dist/build/writeApp.js +2 -6
- package/dist/build/writeAuth.js +18 -0
- 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 +31 -0
- package/dist/build/writePluginImports/writeActionImports.js +22 -0
- package/dist/build/writePluginImports/writeAuthImports.js +30 -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/writePluginImports.js +52 -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 +1874 -0
- package/dist/index.js +126 -112
- package/dist/lowdefySchema.js +173 -79
- package/dist/scripts/generateDefaultTypes.js +47 -75
- package/dist/scripts/run.js +14 -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 +106 -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 +48 -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.
|
|
@@ -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);
|
|
@@ -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,7 +12,8 @@
|
|
|
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
|
-
*/ import
|
|
15
|
+
*/ import evaluateBuildOperators from './evaluateBuildOperators.js';
|
|
16
|
+
import getRefContent from './getRefContent.js';
|
|
16
17
|
import getRefsFromFile from './getRefsFromFile.js';
|
|
17
18
|
import populateRefs from './populateRefs.js';
|
|
18
19
|
import runTransformer from './runTransformer.js';
|
|
@@ -27,8 +28,7 @@ async function recursiveParseFile({ context , refDef , count , referencedFrom }
|
|
|
27
28
|
referencedFrom
|
|
28
29
|
});
|
|
29
30
|
const { foundRefs , fileContentBuiltRefs } = getRefsFromFile(fileContent);
|
|
30
|
-
const parsedFiles = {
|
|
31
|
-
};
|
|
31
|
+
const parsedFiles = {};
|
|
32
32
|
// Since we can have references in the variables of a reference, we need to first parse
|
|
33
33
|
// the deeper nodes, so we can use those parsed files in references higher in the tree.
|
|
34
34
|
// To do this, since foundRefs is an array of ref definitions that are in order of the
|
|
@@ -47,9 +47,14 @@ async function recursiveParseFile({ context , refDef , count , referencedFrom }
|
|
|
47
47
|
count: count + 1,
|
|
48
48
|
referencedFrom: refDef.path
|
|
49
49
|
});
|
|
50
|
+
const evaluatedOperators = await evaluateBuildOperators({
|
|
51
|
+
context,
|
|
52
|
+
input: parsedFile,
|
|
53
|
+
refDef: parsedRefDef
|
|
54
|
+
});
|
|
50
55
|
const transformedFile = await runTransformer({
|
|
51
56
|
context,
|
|
52
|
-
|
|
57
|
+
input: evaluatedOperators,
|
|
53
58
|
refDef: parsedRefDef
|
|
54
59
|
});
|
|
55
60
|
parsedFiles[newRefDef.id] = transformedFile;
|
|
@@ -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,14 +13,18 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import getUserJavascriptFunction from './getUserJavascriptFunction.js';
|
|
16
|
-
async function runTransformer({ context ,
|
|
16
|
+
async function runTransformer({ context , input , refDef }) {
|
|
17
17
|
if (refDef.transformer) {
|
|
18
18
|
const transformerFn = await getUserJavascriptFunction({
|
|
19
19
|
context,
|
|
20
20
|
filePath: refDef.transformer
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
try {
|
|
23
|
+
return transformerFn(input, refDef.vars);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw Error(`Error calling transformer "${refDef.transformer}" from "${refDef.path}": ${error.message}`);
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
|
-
return
|
|
28
|
+
return input;
|
|
25
29
|
}
|
|
26
30
|
export default runTransformer;
|
package/dist/build/buildTypes.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.
|
|
@@ -12,13 +12,20 @@
|
|
|
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
|
-
*/
|
|
15
|
+
*/ import basicTypes from '@lowdefy/blocks-basic/types';
|
|
16
|
+
import loaderTypes from '@lowdefy/blocks-loaders/types';
|
|
17
|
+
function buildTypeClass(context, { counter , definitions , store , typeClass , warnIfMissing =false }) {
|
|
16
18
|
const counts = counter.getCounts();
|
|
17
19
|
Object.keys(counts).forEach((typeName)=>{
|
|
18
20
|
if (!definitions[typeName]) {
|
|
21
|
+
if (warnIfMissing) {
|
|
22
|
+
context.logger.warn(`${typeClass} type "${typeName}" was used but is not defined.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
19
25
|
throw new Error(`${typeClass} type "${typeName}" was used but is not defined.`);
|
|
20
26
|
}
|
|
21
27
|
store[typeName] = {
|
|
28
|
+
originalTypeName: definitions[typeName].originalTypeName,
|
|
22
29
|
package: definitions[typeName].package,
|
|
23
30
|
version: definitions[typeName].version,
|
|
24
31
|
count: counts[typeName]
|
|
@@ -27,64 +34,86 @@
|
|
|
27
34
|
}
|
|
28
35
|
function buildTypes({ components , context }) {
|
|
29
36
|
const { typeCounters } = context;
|
|
37
|
+
// Add Mandatory Types
|
|
38
|
+
// Add operators used by form validation
|
|
39
|
+
typeCounters.operators.client.increment('_not');
|
|
40
|
+
typeCounters.operators.client.increment('_type');
|
|
41
|
+
// Add loaders and basic
|
|
42
|
+
basicTypes.blocks.forEach((block)=>typeCounters.blocks.increment(block)
|
|
43
|
+
);
|
|
44
|
+
loaderTypes.blocks.forEach((block)=>typeCounters.blocks.increment(block)
|
|
45
|
+
);
|
|
46
|
+
typeCounters.blocks.increment('Message'); // Used for DisplayMessage in @lowdefy/client
|
|
30
47
|
components.types = {
|
|
31
|
-
actions: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
requests: {
|
|
48
|
+
actions: {},
|
|
49
|
+
auth: {
|
|
50
|
+
callbacks: {},
|
|
51
|
+
events: {},
|
|
52
|
+
providers: {}
|
|
38
53
|
},
|
|
54
|
+
blocks: {},
|
|
55
|
+
connections: {},
|
|
56
|
+
requests: {},
|
|
39
57
|
operators: {
|
|
40
|
-
client: {
|
|
41
|
-
}
|
|
42
|
-
server: {
|
|
43
|
-
}
|
|
58
|
+
client: {},
|
|
59
|
+
server: {}
|
|
44
60
|
}
|
|
45
61
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
buildTypeClass({
|
|
62
|
+
buildTypeClass(context, {
|
|
63
|
+
counter: typeCounters.actions,
|
|
64
|
+
definitions: context.typesMap.actions,
|
|
65
|
+
store: components.types.actions,
|
|
66
|
+
typeClass: 'Action'
|
|
67
|
+
});
|
|
68
|
+
buildTypeClass(context, {
|
|
69
|
+
counter: typeCounters.auth.callbacks,
|
|
70
|
+
definitions: context.typesMap.auth.callbacks,
|
|
71
|
+
store: components.types.auth.callbacks,
|
|
72
|
+
typeClass: 'Auth callback'
|
|
73
|
+
});
|
|
74
|
+
buildTypeClass(context, {
|
|
75
|
+
counter: typeCounters.auth.events,
|
|
76
|
+
definitions: context.typesMap.auth.events,
|
|
77
|
+
store: components.types.auth.events,
|
|
78
|
+
typeClass: 'Auth event'
|
|
79
|
+
});
|
|
80
|
+
buildTypeClass(context, {
|
|
81
|
+
counter: typeCounters.auth.providers,
|
|
82
|
+
definitions: context.typesMap.auth.providers,
|
|
83
|
+
store: components.types.auth.providers,
|
|
84
|
+
typeClass: 'Auth provider'
|
|
85
|
+
});
|
|
86
|
+
buildTypeClass(context, {
|
|
53
87
|
counter: typeCounters.blocks,
|
|
54
|
-
definitions: context.
|
|
88
|
+
definitions: context.typesMap.blocks,
|
|
55
89
|
store: components.types.blocks,
|
|
56
90
|
typeClass: 'Block'
|
|
57
91
|
});
|
|
58
|
-
buildTypeClass({
|
|
92
|
+
buildTypeClass(context, {
|
|
59
93
|
counter: typeCounters.connections,
|
|
60
|
-
definitions: context.
|
|
94
|
+
definitions: context.typesMap.connections,
|
|
61
95
|
store: components.types.connections,
|
|
62
96
|
typeClass: 'Connection'
|
|
63
97
|
});
|
|
64
|
-
buildTypeClass({
|
|
98
|
+
buildTypeClass(context, {
|
|
65
99
|
counter: typeCounters.requests,
|
|
66
|
-
definitions: context.
|
|
100
|
+
definitions: context.typesMap.requests,
|
|
67
101
|
store: components.types.requests,
|
|
68
102
|
typeClass: 'Request'
|
|
69
103
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const blocksPackages = new Set();
|
|
84
|
-
Object.values(components.types.blocks).forEach((typeDef)=>{
|
|
85
|
-
blocksPackages.add(typeDef.package);
|
|
104
|
+
buildTypeClass(context, {
|
|
105
|
+
counter: typeCounters.operators.client,
|
|
106
|
+
definitions: context.typesMap.operators.client,
|
|
107
|
+
store: components.types.operators.client,
|
|
108
|
+
typeClass: 'Operator',
|
|
109
|
+
warnIfMissing: true
|
|
110
|
+
});
|
|
111
|
+
buildTypeClass(context, {
|
|
112
|
+
counter: typeCounters.operators.server,
|
|
113
|
+
definitions: context.typesMap.operators.server,
|
|
114
|
+
store: components.types.operators.server,
|
|
115
|
+
typeClass: 'Operator',
|
|
116
|
+
warnIfMissing: true
|
|
86
117
|
});
|
|
87
|
-
components.styles = context.types.styles.filter((style)=>blocksPackages.has(style.package)
|
|
88
|
-
);
|
|
89
118
|
}
|
|
90
119
|
export default buildTypes;
|
|
@@ -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,6 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { cleanDirectory } from '@lowdefy/node-utils';
|
|
16
16
|
async function cleanBuildDirectory({ context }) {
|
|
17
|
-
|
|
17
|
+
await cleanDirectory(context.directories.build);
|
|
18
18
|
}
|
|
19
19
|
export default cleanBuildDirectory;
|