@lowdefy/build 4.0.0-alpha.5 → 4.0.0-alpha.8
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 +36 -41
- package/dist/build/addDefaultPages/addDefaultPages.js +6 -2
- package/dist/build/buildAuth/getPageRoles.js +1 -2
- package/dist/build/buildConnections.js +1 -2
- package/dist/build/buildIcons.js +42 -14
- package/dist/build/buildPages/buildBlock/buildEvents.js +4 -1
- package/dist/build/buildPages/buildBlock/buildRequests.js +1 -2
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +2 -4
- package/dist/build/buildRefs/buildRefs.js +2 -2
- package/dist/build/buildRefs/evaluateBuildOperators.js +35 -0
- package/dist/build/buildRefs/getRefContent.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +6 -3
- package/dist/build/buildRefs/makeRefDefinition.js +1 -2
- package/dist/build/buildRefs/parseRefContent.js +2 -2
- package/dist/build/buildRefs/recursiveBuild.js +9 -4
- package/dist/build/buildRefs/runTransformer.js +7 -3
- package/dist/build/buildStyles.js +2 -2
- package/dist/build/buildTypes.js +35 -31
- package/dist/build/cleanBuildDirectory.js +1 -1
- package/dist/build/copyPublicFolder.js +23 -0
- package/dist/build/updateServerPackageJson.js +2 -6
- package/dist/build/validateApp.js +2 -8
- package/dist/build/validateConfig.js +12 -8
- package/dist/build/writeApp.js +1 -5
- package/dist/build/writeConfig.js +1 -5
- package/dist/build/writeConnections.js +1 -4
- package/dist/build/writeGlobal.js +2 -6
- package/dist/build/writeMenus.js +1 -4
- package/dist/build/writePages.js +2 -13
- package/dist/build/writePluginImports/generateImportFile.js +6 -6
- package/dist/build/writePluginImports/writeActionImports.js +22 -0
- package/dist/build/writePluginImports/writeBlockImports.js +4 -7
- package/dist/build/writePluginImports/writeConnectionImports.js +4 -7
- package/dist/build/writePluginImports/writeIconImports.js +10 -16
- package/dist/build/writePluginImports/writeOperatorImports.js +8 -15
- package/dist/build/writePluginImports/writeStyleImports.js +3 -6
- package/dist/build/writeRequests.js +2 -7
- package/dist/build/writeTypes.js +1 -4
- package/dist/defaultTypesMap.json +1499 -0
- package/dist/index.js +133 -124
- package/dist/lowdefySchema.js +69 -28
- package/dist/scripts/generateDefaultTypes.js +34 -70
- package/dist/scripts/run.js +7 -3
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +2 -5
- package/dist/test/buildRefs/testBuildRefsErrorResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsNullResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsParsingResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsTransform.js +1 -1
- package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +1 -1
- package/dist/test/testContext.js +8 -17
- package/dist/utils/createPluginTypesMap.js +85 -0
- package/dist/utils/formatErrorMessage.js +1 -1
- package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +0 -0
- package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +2 -5
- package/package.json +47 -23
- package/dist/defaultTypes.json +0 -896
|
@@ -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
|
+
};
|
|
@@ -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
|
);
|
|
@@ -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]) {
|
|
@@ -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
|
});
|
package/dist/build/buildIcons.js
CHANGED
|
@@ -35,23 +35,51 @@
|
|
|
35
35
|
'react-icons/wi': /"(Wi[A-Z0-9]\w*)"/gm,
|
|
36
36
|
'react-icons/cg': /"(Cg[A-Z0-9]\w*)"/gm
|
|
37
37
|
};
|
|
38
|
-
function
|
|
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 }) {
|
|
39
63
|
components.icons = [];
|
|
40
64
|
Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
|
|
41
65
|
const icons = new Set();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
+
});
|
|
55
83
|
components.icons.push({
|
|
56
84
|
icons: [
|
|
57
85
|
...icons
|
|
@@ -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({
|
|
@@ -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
|
}
|
|
@@ -20,12 +20,10 @@ function countBlockOperators(block, { typeCounters }) {
|
|
|
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
|
});
|
|
@@ -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-2021 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;
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
components.styles = [];
|
|
17
17
|
const styles = new Set();
|
|
18
18
|
Object.entries(components.types.blocks).forEach(([blockName, block])=>{
|
|
19
|
-
styles.add(...(context.
|
|
19
|
+
styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`
|
|
20
20
|
));
|
|
21
|
-
styles.add(...(context.
|
|
21
|
+
styles.add(...(context.typesMap.styles.blocks[blockName] || []).map((style)=>`${block.package}/${style}`
|
|
22
22
|
));
|
|
23
23
|
});
|
|
24
24
|
components.styles = [
|
package/dist/build/buildTypes.js
CHANGED
|
@@ -12,13 +12,18 @@
|
|
|
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 buildTypeClass({ counter , definitions , store , typeClass }) {
|
|
15
|
+
*/ function buildTypeClass(context, { counter , definitions , store , typeClass , warnIfMissing =false }) {
|
|
16
16
|
const counts = counter.getCounts();
|
|
17
17
|
Object.keys(counts).forEach((typeName)=>{
|
|
18
18
|
if (!definitions[typeName]) {
|
|
19
|
+
if (warnIfMissing) {
|
|
20
|
+
context.logger.warn(`${typeClass} type "${typeName}" was used but is not defined.`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
throw new Error(`${typeClass} type "${typeName}" was used but is not defined.`);
|
|
20
24
|
}
|
|
21
25
|
store[typeName] = {
|
|
26
|
+
originalTypeName: definitions[typeName].originalTypeName,
|
|
22
27
|
package: definitions[typeName].package,
|
|
23
28
|
version: definitions[typeName].version,
|
|
24
29
|
count: counts[typeName]
|
|
@@ -27,57 +32,56 @@
|
|
|
27
32
|
}
|
|
28
33
|
function buildTypes({ components , context }) {
|
|
29
34
|
const { typeCounters } = context;
|
|
35
|
+
// Add operators used by form validation
|
|
36
|
+
typeCounters.operators.client.increment('_not');
|
|
37
|
+
typeCounters.operators.client.increment('_type');
|
|
30
38
|
components.types = {
|
|
31
|
-
actions: {
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
connections: {
|
|
36
|
-
},
|
|
37
|
-
requests: {
|
|
38
|
-
},
|
|
39
|
+
actions: {},
|
|
40
|
+
blocks: {},
|
|
41
|
+
connections: {},
|
|
42
|
+
requests: {},
|
|
39
43
|
operators: {
|
|
40
|
-
client: {
|
|
41
|
-
}
|
|
42
|
-
server: {
|
|
43
|
-
}
|
|
44
|
+
client: {},
|
|
45
|
+
server: {}
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
buildTypeClass({
|
|
48
|
+
buildTypeClass(context, {
|
|
49
|
+
counter: typeCounters.actions,
|
|
50
|
+
definitions: context.typesMap.actions,
|
|
51
|
+
store: components.types.actions,
|
|
52
|
+
typeClass: 'Action'
|
|
53
|
+
});
|
|
54
|
+
buildTypeClass(context, {
|
|
53
55
|
counter: typeCounters.blocks,
|
|
54
|
-
definitions: context.
|
|
56
|
+
definitions: context.typesMap.blocks,
|
|
55
57
|
store: components.types.blocks,
|
|
56
58
|
typeClass: 'Block'
|
|
57
59
|
});
|
|
58
|
-
buildTypeClass({
|
|
60
|
+
buildTypeClass(context, {
|
|
59
61
|
counter: typeCounters.connections,
|
|
60
|
-
definitions: context.
|
|
62
|
+
definitions: context.typesMap.connections,
|
|
61
63
|
store: components.types.connections,
|
|
62
64
|
typeClass: 'Connection'
|
|
63
65
|
});
|
|
64
|
-
buildTypeClass({
|
|
66
|
+
buildTypeClass(context, {
|
|
65
67
|
counter: typeCounters.requests,
|
|
66
|
-
definitions: context.
|
|
68
|
+
definitions: context.typesMap.requests,
|
|
67
69
|
store: components.types.requests,
|
|
68
70
|
typeClass: 'Request'
|
|
69
71
|
});
|
|
70
|
-
buildTypeClass({
|
|
72
|
+
buildTypeClass(context, {
|
|
71
73
|
counter: typeCounters.operators.client,
|
|
72
|
-
definitions: context.
|
|
74
|
+
definitions: context.typesMap.operators.client,
|
|
73
75
|
store: components.types.operators.client,
|
|
74
|
-
typeClass: 'Operator'
|
|
76
|
+
typeClass: 'Operator',
|
|
77
|
+
warnIfMissing: true
|
|
75
78
|
});
|
|
76
|
-
buildTypeClass({
|
|
79
|
+
buildTypeClass(context, {
|
|
77
80
|
counter: typeCounters.operators.server,
|
|
78
|
-
definitions: context.
|
|
81
|
+
definitions: context.typesMap.operators.server,
|
|
79
82
|
store: components.types.operators.server,
|
|
80
|
-
typeClass: 'Operator'
|
|
83
|
+
typeClass: 'Operator',
|
|
84
|
+
warnIfMissing: true
|
|
81
85
|
});
|
|
82
86
|
}
|
|
83
87
|
export default buildTypes;
|
|
@@ -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-2021 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;
|
|
@@ -31,8 +31,7 @@ async function updateServerPackageJson({ components , context }) {
|
|
|
31
31
|
getPackages(components.types.operators.client);
|
|
32
32
|
getPackages(components.types.operators.server);
|
|
33
33
|
// Sort dependencies
|
|
34
|
-
packageJson.dependencies = {
|
|
35
|
-
};
|
|
34
|
+
packageJson.dependencies = {};
|
|
36
35
|
Object.keys(dependencies).sort().forEach((name)=>{
|
|
37
36
|
packageJson.dependencies[name] = dependencies[name];
|
|
38
37
|
});
|
|
@@ -41,10 +40,7 @@ async function updateServerPackageJson({ components , context }) {
|
|
|
41
40
|
// be watching the file to trigger reinstalls
|
|
42
41
|
if (newPackageJsonContent !== packageJsonContent) {
|
|
43
42
|
context.logger.warn('Plugin dependencies have changed. Updating "package.json".');
|
|
44
|
-
await writeFile(
|
|
45
|
-
filePath,
|
|
46
|
-
content: newPackageJsonContent
|
|
47
|
-
});
|
|
43
|
+
await writeFile(filePath, newPackageJsonContent);
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
export default updateServerPackageJson;
|
|
@@ -15,19 +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
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (type.isNone(components.app.styles)) {
|
|
29
|
-
components.app.styles = {
|
|
30
|
-
};
|
|
24
|
+
components.app.html = {};
|
|
31
25
|
}
|
|
32
26
|
if (type.isNone(components.app.html.appendBody)) {
|
|
33
27
|
components.app.html.appendBody = '';
|
|
@@ -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
|
@@ -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;
|