@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,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;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 buildStyles({ components , context }) {
|
|
16
|
+
components.styles = [];
|
|
17
|
+
const styles = new Set();
|
|
18
|
+
Object.entries(components.types.blocks).forEach(([blockName, block])=>{
|
|
19
|
+
styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`
|
|
20
|
+
));
|
|
21
|
+
styles.add(...(context.typesMap.styles.blocks[blockName] || []).map((style)=>`${block.package}/${style}`
|
|
22
|
+
));
|
|
23
|
+
});
|
|
24
|
+
components.styles = [
|
|
25
|
+
...styles
|
|
26
|
+
].filter((style)=>!!style
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export default buildStyles;
|
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,63 @@
|
|
|
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
|
-
connections: {
|
|
36
|
-
},
|
|
37
|
-
requests: {
|
|
38
|
-
},
|
|
48
|
+
actions: {},
|
|
49
|
+
blocks: {},
|
|
50
|
+
connections: {},
|
|
51
|
+
requests: {},
|
|
39
52
|
operators: {
|
|
40
|
-
client: {
|
|
41
|
-
}
|
|
42
|
-
server: {
|
|
43
|
-
}
|
|
53
|
+
client: {},
|
|
54
|
+
server: {}
|
|
44
55
|
}
|
|
45
56
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
buildTypeClass({
|
|
57
|
+
buildTypeClass(context, {
|
|
58
|
+
counter: typeCounters.actions,
|
|
59
|
+
definitions: context.typesMap.actions,
|
|
60
|
+
store: components.types.actions,
|
|
61
|
+
typeClass: 'Action'
|
|
62
|
+
});
|
|
63
|
+
buildTypeClass(context, {
|
|
53
64
|
counter: typeCounters.blocks,
|
|
54
|
-
definitions: context.
|
|
65
|
+
definitions: context.typesMap.blocks,
|
|
55
66
|
store: components.types.blocks,
|
|
56
67
|
typeClass: 'Block'
|
|
57
68
|
});
|
|
58
|
-
buildTypeClass({
|
|
69
|
+
buildTypeClass(context, {
|
|
59
70
|
counter: typeCounters.connections,
|
|
60
|
-
definitions: context.
|
|
71
|
+
definitions: context.typesMap.connections,
|
|
61
72
|
store: components.types.connections,
|
|
62
73
|
typeClass: 'Connection'
|
|
63
74
|
});
|
|
64
|
-
buildTypeClass({
|
|
75
|
+
buildTypeClass(context, {
|
|
65
76
|
counter: typeCounters.requests,
|
|
66
|
-
definitions: context.
|
|
77
|
+
definitions: context.typesMap.requests,
|
|
67
78
|
store: components.types.requests,
|
|
68
79
|
typeClass: 'Request'
|
|
69
80
|
});
|
|
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);
|
|
81
|
+
buildTypeClass(context, {
|
|
82
|
+
counter: typeCounters.operators.client,
|
|
83
|
+
definitions: context.typesMap.operators.client,
|
|
84
|
+
store: components.types.operators.client,
|
|
85
|
+
typeClass: 'Operator',
|
|
86
|
+
warnIfMissing: true
|
|
87
|
+
});
|
|
88
|
+
buildTypeClass(context, {
|
|
89
|
+
counter: typeCounters.operators.server,
|
|
90
|
+
definitions: context.typesMap.operators.server,
|
|
91
|
+
store: components.types.operators.server,
|
|
92
|
+
typeClass: 'Operator',
|
|
93
|
+
warnIfMissing: true
|
|
86
94
|
});
|
|
87
|
-
components.styles = context.types.styles.filter((style)=>blocksPackages.has(style.package)
|
|
88
|
-
);
|
|
89
95
|
}
|
|
90
96
|
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;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 path from 'path';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import { copyDirectory } from '@lowdefy/node-utils';
|
|
18
|
+
async function copyPublicFolder({ context }) {
|
|
19
|
+
if (context.directories.config === context.directories.server) return;
|
|
20
|
+
if (!fs.existsSync(path.resolve(context.directories.config, 'public'))) return;
|
|
21
|
+
await copyDirectory(path.resolve(context.directories.config, 'public'), path.resolve(context.directories.server, 'public'));
|
|
22
|
+
}
|
|
23
|
+
export default copyPublicFolder;
|
package/dist/build/testSchema.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
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 path from 'path';
|
|
16
|
+
import { readFile, writeFile } from '@lowdefy/node-utils';
|
|
17
|
+
async function updateServerPackageJson({ components , context }) {
|
|
18
|
+
const filePath = path.join(context.directories.server, 'package.json');
|
|
19
|
+
const packageJsonContent = await readFile(filePath);
|
|
20
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
21
|
+
const dependencies = packageJson.dependencies;
|
|
22
|
+
function getPackages(types) {
|
|
23
|
+
Object.values(types).forEach((type)=>{
|
|
24
|
+
dependencies[type.package] = type.version;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getPackages(components.types.actions);
|
|
28
|
+
getPackages(components.types.blocks);
|
|
29
|
+
getPackages(components.types.connections);
|
|
30
|
+
getPackages(components.types.requests);
|
|
31
|
+
getPackages(components.types.operators.client);
|
|
32
|
+
getPackages(components.types.operators.server);
|
|
33
|
+
// Sort dependencies
|
|
34
|
+
packageJson.dependencies = {};
|
|
35
|
+
Object.keys(dependencies).sort().forEach((name)=>{
|
|
36
|
+
packageJson.dependencies[name] = dependencies[name];
|
|
37
|
+
});
|
|
38
|
+
const newPackageJsonContent = JSON.stringify(packageJson, null, 2).concat('\n');
|
|
39
|
+
// Only write package.json if it has changed since dev server will
|
|
40
|
+
// be watching the file to trigger reinstalls
|
|
41
|
+
if (newPackageJsonContent !== packageJsonContent) {
|
|
42
|
+
context.logger.warn('Plugin dependencies have changed. Updating "package.json".');
|
|
43
|
+
await writeFile(filePath, newPackageJsonContent);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export default updateServerPackageJson;
|
|
@@ -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.
|
|
@@ -15,15 +15,13 @@
|
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
async function validateApp({ components }) {
|
|
17
17
|
if (type.isNone(components.app)) {
|
|
18
|
-
components.app = {
|
|
19
|
-
};
|
|
18
|
+
components.app = {};
|
|
20
19
|
}
|
|
21
20
|
if (!type.isObject(components.app)) {
|
|
22
21
|
throw new Error('lowdefy.app is not an object.');
|
|
23
22
|
}
|
|
24
23
|
if (type.isNone(components.app.html)) {
|
|
25
|
-
components.app.html = {
|
|
26
|
-
};
|
|
24
|
+
components.app.html = {};
|
|
27
25
|
}
|
|
28
26
|
if (type.isNone(components.app.html.appendBody)) {
|
|
29
27
|
components.app.html.appendBody = '';
|
|
@@ -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.
|
|
@@ -17,23 +17,27 @@ import { validate } from '@lowdefy/ajv';
|
|
|
17
17
|
import lowdefySchema from '../lowdefySchema.js';
|
|
18
18
|
async function validateConfig({ components }) {
|
|
19
19
|
if (type.isNone(components.config)) {
|
|
20
|
-
components.config = {
|
|
21
|
-
};
|
|
20
|
+
components.config = {};
|
|
22
21
|
}
|
|
23
22
|
if (!type.isObject(components.config)) {
|
|
24
23
|
throw new Error('lowdefy.config is not an object.');
|
|
25
24
|
}
|
|
26
25
|
if (type.isNone(components.config.auth)) {
|
|
27
|
-
components.config.auth = {
|
|
28
|
-
};
|
|
26
|
+
components.config.auth = {};
|
|
29
27
|
}
|
|
30
28
|
if (type.isNone(components.config.auth.pages)) {
|
|
31
|
-
components.config.auth.pages = {
|
|
32
|
-
};
|
|
29
|
+
components.config.auth.pages = {};
|
|
33
30
|
}
|
|
34
31
|
if (type.isNone(components.config.auth.pages.roles)) {
|
|
35
|
-
components.config.auth.pages.roles = {
|
|
36
|
-
|
|
32
|
+
components.config.auth.pages.roles = {};
|
|
33
|
+
}
|
|
34
|
+
if (type.isNone(components.config.theme)) {
|
|
35
|
+
components.config.theme = {};
|
|
36
|
+
}
|
|
37
|
+
if (type.isString(components.config.basePath)) {
|
|
38
|
+
if (components.config.basePath[0] !== '/') {
|
|
39
|
+
throw Error('Base path must start with "/".');
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
validate({
|
|
39
43
|
schema: lowdefySchema.definitions.authConfig,
|
package/dist/build/writeApp.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.
|
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ async function writeApp({ components , context }) {
|
|
16
|
-
await context.writeBuildArtifact({
|
|
17
|
-
filePath: 'app.json',
|
|
18
|
-
content: JSON.stringify(components.app || {
|
|
19
|
-
}, null, 2)
|
|
20
|
-
});
|
|
16
|
+
await context.writeBuildArtifact('app.json', JSON.stringify(components.app || {}, null, 2));
|
|
21
17
|
}
|
|
22
18
|
export default writeApp;
|
|
@@ -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,10 +13,6 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ async function writeConfig({ components , context }) {
|
|
16
|
-
await context.writeBuildArtifact({
|
|
17
|
-
filePath: 'config.json',
|
|
18
|
-
content: JSON.stringify(components.config || {
|
|
19
|
-
}, null, 2)
|
|
20
|
-
});
|
|
16
|
+
await context.writeBuildArtifact('config.json', JSON.stringify(components.config || {}, null, 2));
|
|
21
17
|
}
|
|
22
18
|
export default writeConfig;
|
|
@@ -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.
|
|
@@ -19,10 +19,7 @@ async function writeConnections({ components , context }) {
|
|
|
19
19
|
throw new Error(`Connections is not an array.`);
|
|
20
20
|
}
|
|
21
21
|
const writePromises = components.connections.map(async (connection)=>{
|
|
22
|
-
await context.writeBuildArtifact({
|
|
23
|
-
filePath: `connections/${connection.connectionId}.json`,
|
|
24
|
-
content: JSON.stringify(connection, null, 2)
|
|
25
|
-
});
|
|
22
|
+
await context.writeBuildArtifact(`connections/${connection.connectionId}.json`, JSON.stringify(connection, null, 2));
|
|
26
23
|
});
|
|
27
24
|
return Promise.all(writePromises);
|
|
28
25
|
}
|
|
@@ -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,15 +15,11 @@
|
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
async function writeGlobal({ components , context }) {
|
|
17
17
|
if (type.isNone(components.global)) {
|
|
18
|
-
components.global = {
|
|
19
|
-
};
|
|
18
|
+
components.global = {};
|
|
20
19
|
}
|
|
21
20
|
if (!type.isObject(components.global)) {
|
|
22
21
|
throw new Error('Global is not an object.');
|
|
23
22
|
}
|
|
24
|
-
await context.writeBuildArtifact(
|
|
25
|
-
filePath: 'global.json',
|
|
26
|
-
content: JSON.stringify(components.global, null, 2)
|
|
27
|
-
});
|
|
23
|
+
await context.writeBuildArtifact('global.json', JSON.stringify(components.global, null, 2));
|
|
28
24
|
}
|
|
29
25
|
export default writeGlobal;
|
package/dist/build/writeMenus.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.
|
|
@@ -17,9 +17,6 @@ async function writeMenus({ components , context }) {
|
|
|
17
17
|
if (!type.isArray(components.menus)) {
|
|
18
18
|
throw new Error('Menus is not an array.');
|
|
19
19
|
}
|
|
20
|
-
await context.writeBuildArtifact(
|
|
21
|
-
filePath: 'menus.json',
|
|
22
|
-
content: JSON.stringify(components.menus, null, 2)
|
|
23
|
-
});
|
|
20
|
+
await context.writeBuildArtifact('menus.json', JSON.stringify(components.menus, null, 2));
|
|
24
21
|
}
|
|
25
22
|
export default writeMenus;
|
package/dist/build/writePages.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,21 +12,10 @@
|
|
|
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
|
-
|
|
17
|
-
if (!type.isObject(page)) {
|
|
18
|
-
throw new Error(`Page is not an object. Received ${JSON.stringify(page)}`);
|
|
19
|
-
}
|
|
20
|
-
await context.writeBuildArtifact({
|
|
21
|
-
filePath: `pages/${page.pageId}/${page.pageId}.json`,
|
|
22
|
-
content: JSON.stringify(page, null, 2)
|
|
23
|
-
});
|
|
15
|
+
*/ async function writePage({ page , context }) {
|
|
16
|
+
await context.writeBuildArtifact(`pages/${page.pageId}/${page.pageId}.json`, JSON.stringify(page, null, 2));
|
|
24
17
|
}
|
|
25
18
|
async function writePages({ components , context }) {
|
|
26
|
-
if (type.isNone(components.pages)) return;
|
|
27
|
-
if (!type.isArray(components.pages)) {
|
|
28
|
-
throw new Error(`Pages is not an array.`);
|
|
29
|
-
}
|
|
30
19
|
const writePromises = components.pages.map((page)=>writePage({
|
|
31
20
|
page,
|
|
32
21
|
context
|
|
@@ -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
|
+
*/ import { nunjucksFunction } from '@lowdefy/nunjucks';
|
|
16
|
+
const template = `{%- for import in imports -%}
|
|
17
|
+
import { {{ import.originalTypeName }} as {{ import.typeName }} } from '{{ import.package }}/{{ importPath }}';
|
|
18
|
+
{% endfor -%}
|
|
19
|
+
export default {
|
|
20
|
+
{% for import in imports -%}
|
|
21
|
+
{{ import.typeName }},
|
|
22
|
+
{% endfor -%}
|
|
23
|
+
};`;
|
|
24
|
+
function generateImportFile({ types , importPath }) {
|
|
25
|
+
const templateFn = nunjucksFunction(template);
|
|
26
|
+
const imports = Object.keys(types).map((typeName)=>({
|
|
27
|
+
typeName,
|
|
28
|
+
...types[typeName]
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
return templateFn({
|
|
32
|
+
imports,
|
|
33
|
+
importPath
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export default generateImportFile;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 generateImportFile from './generateImportFile.js';
|
|
16
|
+
async function writeActionImports({ components , context }) {
|
|
17
|
+
await context.writeBuildArtifact('plugins/actions.js', generateImportFile({
|
|
18
|
+
types: components.types.actions,
|
|
19
|
+
importPath: 'actions'
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
export default writeActionImports;
|
|
@@ -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,28 +12,11 @@
|
|
|
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
|
|
16
|
-
const template = `{%- for block in blocks -%}
|
|
17
|
-
import { {{ block.type }} } from '{{ block.package }}/blocks';
|
|
18
|
-
{% endfor -%}
|
|
19
|
-
export default {
|
|
20
|
-
{%- for block in blocks -%}
|
|
21
|
-
{{ block.type }},
|
|
22
|
-
{% endfor -%}
|
|
23
|
-
};
|
|
24
|
-
`;
|
|
15
|
+
*/ import generateImportFile from './generateImportFile.js';
|
|
25
16
|
async function writeBlockImports({ components , context }) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
await context.writeBuildArtifact({
|
|
33
|
-
filePath: 'plugins/blocks.js',
|
|
34
|
-
content: templateFn({
|
|
35
|
-
blocks
|
|
36
|
-
})
|
|
37
|
-
});
|
|
17
|
+
await context.writeBuildArtifact('plugins/blocks.js', generateImportFile({
|
|
18
|
+
types: components.types.blocks,
|
|
19
|
+
importPath: 'blocks'
|
|
20
|
+
}));
|
|
38
21
|
}
|
|
39
22
|
export default writeBlockImports;
|