@lowdefy/build 3.23.0-alpha.0 → 4.0.0-alpha.4
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 +56 -0
- package/dist/build/addDefaultPages/addDefaultPages.js +40 -0
- package/dist/build/buildAuth/buildAuth.js +50 -0
- package/dist/build/buildAuth/getPageRoles.js +34 -0
- package/dist/build/buildAuth/getProtectedPages.js +30 -0
- package/dist/build/buildConnections.js +47 -0
- package/dist/build/buildIcons.js +63 -0
- package/dist/build/buildMenu.js +122 -0
- package/dist/build/buildPages/buildBlock/buildBlock.js +31 -0
- package/dist/build/buildPages/buildBlock/buildEvents.js +72 -0
- package/dist/build/buildPages/buildBlock/buildRequests.js +52 -0
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +35 -0
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +33 -0
- package/dist/build/buildPages/buildBlock/moveSubBlocksToArea.js +25 -0
- package/dist/build/buildPages/buildBlock/setBlockId.js +20 -0
- package/dist/build/buildPages/buildBlock/validateBlock.js +39 -0
- package/dist/build/buildPages/buildPage.js +50 -0
- package/dist/build/buildPages/buildPages.js +33 -0
- package/dist/build/buildRefs/buildRefs.js +26 -0
- package/dist/build/buildRefs/getConfigFile.js +28 -0
- package/dist/build/buildRefs/getRefContent.js +44 -0
- package/dist/build/buildRefs/getRefPath.js +30 -0
- package/dist/build/buildRefs/getRefsFromFile.js +37 -0
- package/dist/build/buildRefs/getUserJavascriptFunction.js +21 -0
- package/dist/build/buildRefs/makeRefDefinition.js +31 -0
- package/dist/build/buildRefs/parseNunjucks.js +20 -0
- package/dist/build/buildRefs/parseRefContent.js +37 -0
- package/dist/build/buildRefs/populateRefs.js +43 -0
- package/dist/build/buildRefs/recursiveBuild.js +63 -0
- package/dist/build/buildRefs/runRefResolver.js +33 -0
- package/dist/build/buildRefs/runTransformer.js +26 -0
- package/dist/build/buildStyles.js +29 -0
- package/dist/build/buildTypes.js +83 -0
- package/dist/build/cleanBuildDirectory.js +19 -0
- package/dist/build/testSchema.js +34 -0
- package/dist/build/validateApp.js +36 -0
- package/dist/build/validateConfig.js +53 -0
- package/dist/build/writeApp.js +22 -0
- package/dist/build/writeConfig.js +22 -0
- package/dist/build/writeConnections.js +29 -0
- package/dist/build/writeGlobal.js +29 -0
- package/dist/build/writeMenus.js +25 -0
- package/dist/build/writePages.js +37 -0
- package/dist/build/writePluginImports/writeBlockImports.js +39 -0
- package/dist/build/writePluginImports/writeConnectionImports.js +39 -0
- package/dist/build/writePluginImports/writeIconImports.js +37 -0
- package/dist/build/writePluginImports/writeStyleImports.js +30 -0
- package/dist/build/writeRequests.js +37 -0
- package/dist/build/writeTypes.js +21 -0
- package/dist/defaultTypes.json +66 -0
- package/dist/index.js +182 -1
- package/dist/lowdefySchema.js +699 -0
- package/dist/scripts/generateDefaultTypes.js +101 -0
- package/dist/scripts/run.js +25 -0
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +25 -0
- package/dist/test/buildRefs/testBuildRefsErrorResolver.js +18 -0
- package/dist/test/buildRefs/testBuildRefsNullResolver.js +19 -0
- package/dist/test/buildRefs/testBuildRefsParsingResolver.js +39 -0
- package/dist/test/buildRefs/testBuildRefsResolver.js +23 -0
- package/dist/test/buildRefs/testBuildRefsTransform.js +25 -0
- package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +21 -0
- package/dist/test/testContext.js +55 -0
- package/dist/utils/countOperators.js +30 -0
- package/dist/utils/createCheckDuplicateId.js +31 -0
- package/dist/utils/createCounter.js +33 -0
- package/dist/utils/files/readConfigFile.js +24 -0
- package/dist/utils/files/writeBuildArtifact.js +26 -0
- package/dist/utils/formatErrorMessage.js +56 -0
- package/package.json +22 -21
- package/dist/138.index.js +0 -2
- package/dist/138.index.js.LICENSE.txt +0 -3
- package/dist/231.index.js +0 -1
- package/dist/319.index.js +0 -1
- package/dist/35.index.js +0 -1
- package/dist/422.index.js +0 -1
- package/dist/443.index.js +0 -1
- package/dist/449.index.js +0 -1
- package/dist/5.index.js +0 -2
- package/dist/5.index.js.LICENSE.txt +0 -1
- package/dist/564.index.js +0 -1
- package/dist/569.index.js +0 -1
- package/dist/625.index.js +0 -1
- package/dist/693.index.js +0 -2
- package/dist/693.index.js.LICENSE.txt +0 -1
- package/dist/734.index.js +0 -1
- package/dist/904.index.js +0 -1
- package/dist/remoteEntry.js +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/ import path from 'path';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
import { readFile, writeFile } from '@lowdefy/node-utils';
|
|
19
|
+
const defaultPackages = [
|
|
20
|
+
'@lowdefy/blocks-basic',
|
|
21
|
+
'@lowdefy/connection-axios-http'
|
|
22
|
+
];
|
|
23
|
+
function createTypeDefinitions({ typeNames , store , packageName , version }) {
|
|
24
|
+
if (type.isArray(typeNames)) {
|
|
25
|
+
typeNames.forEach((typeName)=>{
|
|
26
|
+
store[typeName] = {
|
|
27
|
+
package: packageName,
|
|
28
|
+
version
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function generateDefaultTypes() {
|
|
34
|
+
const packageFile = JSON.parse(await readFile(path.resolve(process.cwd(), './package.json')));
|
|
35
|
+
const defaultTypes = {
|
|
36
|
+
actions: {
|
|
37
|
+
},
|
|
38
|
+
blocks: {
|
|
39
|
+
},
|
|
40
|
+
connections: {
|
|
41
|
+
},
|
|
42
|
+
requests: {
|
|
43
|
+
},
|
|
44
|
+
operators: {
|
|
45
|
+
client: {
|
|
46
|
+
},
|
|
47
|
+
server: {
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
styles: {
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
await Promise.all(defaultPackages.map(async (packageName)=>{
|
|
54
|
+
const { default: types } = await import(`${packageName}/types`);
|
|
55
|
+
const version = packageFile.devDependencies[packageName];
|
|
56
|
+
createTypeDefinitions({
|
|
57
|
+
typeNames: types.actions,
|
|
58
|
+
store: defaultTypes.actions,
|
|
59
|
+
packageName,
|
|
60
|
+
version
|
|
61
|
+
});
|
|
62
|
+
createTypeDefinitions({
|
|
63
|
+
typeNames: types.blocks,
|
|
64
|
+
store: defaultTypes.blocks,
|
|
65
|
+
packageName,
|
|
66
|
+
version
|
|
67
|
+
});
|
|
68
|
+
createTypeDefinitions({
|
|
69
|
+
typeNames: types.connections,
|
|
70
|
+
store: defaultTypes.connections,
|
|
71
|
+
packageName,
|
|
72
|
+
version
|
|
73
|
+
});
|
|
74
|
+
createTypeDefinitions({
|
|
75
|
+
typeNames: types.requests,
|
|
76
|
+
store: defaultTypes.requests,
|
|
77
|
+
packageName,
|
|
78
|
+
version
|
|
79
|
+
});
|
|
80
|
+
createTypeDefinitions({
|
|
81
|
+
typeNames: type.isObject(types.operators) ? types.operators.client : [],
|
|
82
|
+
store: defaultTypes.operators.client,
|
|
83
|
+
packageName,
|
|
84
|
+
version
|
|
85
|
+
});
|
|
86
|
+
createTypeDefinitions({
|
|
87
|
+
typeNames: type.isObject(types.operators) ? types.operators.server : [],
|
|
88
|
+
store: defaultTypes.operators.server,
|
|
89
|
+
packageName,
|
|
90
|
+
version
|
|
91
|
+
});
|
|
92
|
+
if (type.isObject(types.styles)) {
|
|
93
|
+
defaultTypes.styles[packageName] = types.styles;
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
await writeFile({
|
|
97
|
+
filePath: path.resolve(process.cwd(), './dist/defaultTypes.json'),
|
|
98
|
+
content: JSON.stringify(defaultTypes, null, 2)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
generateDefaultTypes();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/ import path from 'path';
|
|
17
|
+
import build from '../index.js';
|
|
18
|
+
async function run() {
|
|
19
|
+
await build({
|
|
20
|
+
logger: console,
|
|
21
|
+
buildDirectory: path.resolve(process.env.LOWDEFY_BUILD_DIRECTORY || path.join(process.cwd(), 'build')),
|
|
22
|
+
configDirectory: path.resolve(process.env.LOWDEFY_CONFIG_DIRECTORY || process.cwd())
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
run();
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
*/ const wait = (ms)=>{
|
|
16
|
+
return new Promise((resolve)=>setTimeout(resolve, ms)
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
async function asyncFn() {
|
|
20
|
+
await wait(20);
|
|
21
|
+
return {
|
|
22
|
+
async: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
module.exports = asyncFn;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
*/ function resolver() {
|
|
16
|
+
throw new Error('Test error');
|
|
17
|
+
}
|
|
18
|
+
module.exports = resolver;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
*/ function resolver(path) {
|
|
16
|
+
if (path === 'null') return null;
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
module.exports = resolver;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
*/ function resolver(path) {
|
|
16
|
+
switch(path){
|
|
17
|
+
case 'target.yaml':
|
|
18
|
+
return `
|
|
19
|
+
array:
|
|
20
|
+
- 1
|
|
21
|
+
- 2`;
|
|
22
|
+
case 'target.yml':
|
|
23
|
+
return `
|
|
24
|
+
array:
|
|
25
|
+
- 1
|
|
26
|
+
- 2`;
|
|
27
|
+
case 'target.json':
|
|
28
|
+
return `{"a": 42}`;
|
|
29
|
+
case 'target.yaml.njk':
|
|
30
|
+
return 'a: {{ var }}';
|
|
31
|
+
case 'target.yml.njk':
|
|
32
|
+
return 'a: {{ var }}';
|
|
33
|
+
case 'target.json.njk':
|
|
34
|
+
return `{ "a": "{{ var }}" }`;
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
module.exports = resolver;
|
|
@@ -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
|
+
*/ function resolver(path, vars, context) {
|
|
16
|
+
return {
|
|
17
|
+
resolved: true,
|
|
18
|
+
path,
|
|
19
|
+
vars,
|
|
20
|
+
contextId: context.id
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
module.exports = resolver;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
*/ function add(a, b) {
|
|
16
|
+
return a + b;
|
|
17
|
+
}
|
|
18
|
+
function transformer(obj, vars) {
|
|
19
|
+
return {
|
|
20
|
+
json: JSON.stringify(obj),
|
|
21
|
+
add: add(obj.a, 42),
|
|
22
|
+
var: vars.var1
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
module.exports = transformer;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
*/ function transformer(obj, vars) {
|
|
16
|
+
return {
|
|
17
|
+
obj,
|
|
18
|
+
vars
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
module.exports = transformer;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 createCounter from '../utils/createCounter.js';
|
|
16
|
+
function testContext({ writeBuildArtifact , configDirectory , readConfigFile , logger ={
|
|
17
|
+
} } = {
|
|
18
|
+
}) {
|
|
19
|
+
const defaultLogger = {
|
|
20
|
+
info: ()=>{
|
|
21
|
+
},
|
|
22
|
+
log: ()=>{
|
|
23
|
+
},
|
|
24
|
+
warn: ()=>{
|
|
25
|
+
},
|
|
26
|
+
error: ()=>{
|
|
27
|
+
},
|
|
28
|
+
succeed: ()=>{
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const context = {
|
|
32
|
+
id: 'test',
|
|
33
|
+
configDirectory: configDirectory || '',
|
|
34
|
+
typeCounters: {
|
|
35
|
+
actions: createCounter(),
|
|
36
|
+
blocks: createCounter(),
|
|
37
|
+
connections: createCounter(),
|
|
38
|
+
requests: createCounter(),
|
|
39
|
+
operators: {
|
|
40
|
+
client: createCounter(),
|
|
41
|
+
server: createCounter()
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
writeBuildArtifact: writeBuildArtifact || (()=>{
|
|
45
|
+
}),
|
|
46
|
+
readConfigFile: readConfigFile || (()=>{
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
context.logger = {
|
|
50
|
+
...defaultLogger,
|
|
51
|
+
...logger
|
|
52
|
+
};
|
|
53
|
+
return context;
|
|
54
|
+
}
|
|
55
|
+
export default testContext;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
function countOperators(obj, { counter }) {
|
|
17
|
+
function getOperatorsReviver(_, value) {
|
|
18
|
+
if (type.isObject(value) && Object.keys(value).length === 1) {
|
|
19
|
+
const key = Object.keys(value)[0];
|
|
20
|
+
const [op] = key.split('.');
|
|
21
|
+
const operator = op.replace(/^(_+)/gm, '_');
|
|
22
|
+
if (operator.length > 1 && operator[0] === '_') {
|
|
23
|
+
counter.increment(operator);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
JSON.parse(JSON.stringify(obj), getOperatorsReviver);
|
|
29
|
+
}
|
|
30
|
+
export default countOperators;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { nunjucksFunction } from '@lowdefy/nunjucks';
|
|
16
|
+
function createCheckDuplicateId({ message }) {
|
|
17
|
+
const template = nunjucksFunction(message);
|
|
18
|
+
const ids = new Set();
|
|
19
|
+
function checkDuplicateId({ id , blockId , eventId , menuId , pageId }) {
|
|
20
|
+
if (ids.has(id)) throw new Error(template({
|
|
21
|
+
id,
|
|
22
|
+
blockId,
|
|
23
|
+
eventId,
|
|
24
|
+
menuId,
|
|
25
|
+
pageId
|
|
26
|
+
}));
|
|
27
|
+
ids.add(id);
|
|
28
|
+
}
|
|
29
|
+
return checkDuplicateId;
|
|
30
|
+
}
|
|
31
|
+
export default createCheckDuplicateId;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
*/ function createCounter() {
|
|
16
|
+
const counts = new Map();
|
|
17
|
+
function increment(key) {
|
|
18
|
+
const count = counts.get(key) || 0;
|
|
19
|
+
counts.set(key, count + 1);
|
|
20
|
+
}
|
|
21
|
+
function getCount(key) {
|
|
22
|
+
return counts.get(key) || 0;
|
|
23
|
+
}
|
|
24
|
+
function getCounts() {
|
|
25
|
+
return Object.fromEntries(counts);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
increment,
|
|
29
|
+
getCount,
|
|
30
|
+
getCounts
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export default createCounter;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { cachedPromises } from '@lowdefy/helpers';
|
|
17
|
+
import { readFile } from '@lowdefy/node-utils';
|
|
18
|
+
function createReadConfigFile({ configDirectory }) {
|
|
19
|
+
async function readConfigFile(filePath) {
|
|
20
|
+
return readFile(path.resolve(configDirectory, filePath));
|
|
21
|
+
}
|
|
22
|
+
return cachedPromises(readConfigFile);
|
|
23
|
+
}
|
|
24
|
+
export default createReadConfigFile;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { writeFile } from '@lowdefy/node-utils';
|
|
17
|
+
function createWriteBuildArtifact({ buildDirectory }) {
|
|
18
|
+
async function writeBuildArtifact({ filePath , content }) {
|
|
19
|
+
return writeFile({
|
|
20
|
+
filePath: path.resolve(buildDirectory, filePath),
|
|
21
|
+
content
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return writeBuildArtifact;
|
|
25
|
+
}
|
|
26
|
+
export default createWriteBuildArtifact;
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { get, type } from '@lowdefy/helpers';
|
|
16
|
+
function formatArrayKey({ index , object }) {
|
|
17
|
+
if (!type.isNone(object.id) || !type.isNone(object.type)) {
|
|
18
|
+
const objectId = type.isNone(object.id) ? '_ERROR_MISSING_ID_' : object.id;
|
|
19
|
+
const objectType = type.isNone(object.type) ? '_ERROR_MISSING_TYPE_' : object.type;
|
|
20
|
+
return `[${index}:${objectId}:${objectType}]`;
|
|
21
|
+
}
|
|
22
|
+
return `[${index}]`;
|
|
23
|
+
}
|
|
24
|
+
function recursiveFormatPath({ data , instancePath , formattedPath ='' , gap ='' , root =false }) {
|
|
25
|
+
if (instancePath.length === 0) return formattedPath;
|
|
26
|
+
const key = instancePath.shift();
|
|
27
|
+
const newData = get(data, key);
|
|
28
|
+
let newPath;
|
|
29
|
+
if (type.isArray(data)) {
|
|
30
|
+
gap += ' ';
|
|
31
|
+
newPath = `${formattedPath}
|
|
32
|
+
${gap}- ${formatArrayKey({
|
|
33
|
+
index: key,
|
|
34
|
+
object: newData
|
|
35
|
+
})}`;
|
|
36
|
+
} else {
|
|
37
|
+
newPath = `${formattedPath}${root ? '- ' : '.'}${key}`;
|
|
38
|
+
}
|
|
39
|
+
return recursiveFormatPath({
|
|
40
|
+
data: newData,
|
|
41
|
+
instancePath,
|
|
42
|
+
formattedPath: newPath,
|
|
43
|
+
gap
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function formatErrorMessage({ error , components }) {
|
|
47
|
+
const formattedPath = recursiveFormatPath({
|
|
48
|
+
data: components,
|
|
49
|
+
instancePath: error.instancePath.split('/').slice(1),
|
|
50
|
+
root: true
|
|
51
|
+
});
|
|
52
|
+
return `Schema Error
|
|
53
|
+
${error.message}
|
|
54
|
+
${formattedPath}`;
|
|
55
|
+
}
|
|
56
|
+
export default formatErrorMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -24,41 +24,42 @@
|
|
|
24
24
|
"type": "git",
|
|
25
25
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
26
26
|
},
|
|
27
|
-
"
|
|
27
|
+
"type": "module",
|
|
28
|
+
"bin": {
|
|
29
|
+
"lowdefy-build": "./dist/scripts/run.js"
|
|
30
|
+
},
|
|
31
|
+
"exports": "./dist/index.js",
|
|
28
32
|
"files": [
|
|
29
33
|
"dist/*"
|
|
30
34
|
],
|
|
31
35
|
"scripts": {
|
|
32
|
-
"build": "yarn
|
|
36
|
+
"build": "yarn swc && node dist/scripts/generateDefaultTypes.js",
|
|
33
37
|
"clean": "rm -rf dist",
|
|
34
38
|
"prepare": "yarn build",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
39
|
+
"start": "node dist/scripts/run.js",
|
|
40
|
+
"swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
|
|
41
|
+
"test": "jest --coverage"
|
|
37
42
|
},
|
|
38
43
|
"dependencies": {
|
|
39
|
-
"@lowdefy/ajv": "
|
|
40
|
-
"@lowdefy/helpers": "
|
|
41
|
-
"@lowdefy/node-utils": "
|
|
42
|
-
"@lowdefy/nunjucks": "
|
|
43
|
-
"ajv": "
|
|
44
|
-
"axios": "0.21.4",
|
|
44
|
+
"@lowdefy/ajv": "4.0.0-alpha.4",
|
|
45
|
+
"@lowdefy/helpers": "4.0.0-alpha.4",
|
|
46
|
+
"@lowdefy/node-utils": "4.0.0-alpha.4",
|
|
47
|
+
"@lowdefy/nunjucks": "4.0.0-alpha.4",
|
|
48
|
+
"ajv": "8.8.2",
|
|
45
49
|
"js-yaml": "4.1.0",
|
|
46
50
|
"json5": "2.2.0",
|
|
47
51
|
"uuid": "8.3.2"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"jest": "26.6.3",
|
|
57
|
-
"webpack": "5.38.1",
|
|
58
|
-
"webpack-cli": "4.7.0"
|
|
54
|
+
"@lowdefy/blocks-basic": "4.0.0-alpha.4",
|
|
55
|
+
"@lowdefy/connection-axios-http": "4.0.0-alpha.4",
|
|
56
|
+
"@swc/cli": "0.1.52",
|
|
57
|
+
"@swc/core": "1.2.112",
|
|
58
|
+
"@swc/jest": "0.2.9",
|
|
59
|
+
"jest": "27.3.1"
|
|
59
60
|
},
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"access": "public"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "537d166ba3f6e017b8a61c2a7e5c12fd0a48bf67"
|
|
64
65
|
}
|