@lowdefy/build 4.0.0-alpha.29 → 4.0.0-alpha.30
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 +51 -0
- package/dist/build/addDefaultPages/addDefaultPages.js +43 -0
- package/dist/build/buildAuth/buildAuth.js +34 -0
- package/dist/build/buildAuth/buildAuthPlugins.js +71 -0
- package/dist/build/buildAuth/buildPageAuth.js +50 -0
- package/dist/build/buildAuth/getPageRoles.js +33 -0
- package/dist/build/buildAuth/getProtectedPages.js +28 -0
- package/dist/build/buildAuth/validateAuthConfig.js +61 -0
- package/dist/build/buildConnections.js +46 -0
- package/dist/build/buildImports/buildIconImports.js +83 -0
- package/dist/build/buildImports/buildImports.js +30 -0
- package/dist/build/buildImports/buildImportsDev.js +106 -0
- package/dist/build/buildImports/buildImportsProd.js +54 -0
- package/dist/build/buildImports/buildStyleImports.js +25 -0
- package/dist/build/buildImports/defaultIconsDev.js +584 -0
- package/dist/build/buildImports/defaultIconsProd.js +21 -0
- package/dist/build/buildMenu.js +118 -0
- package/dist/build/buildPages/buildBlock/buildBlock.js +35 -0
- package/dist/build/buildPages/buildBlock/buildEvents.js +76 -0
- package/dist/build/buildPages/buildBlock/buildRequests.js +51 -0
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +30 -0
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +31 -0
- 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 +25 -0
- package/dist/build/buildPages/buildBlock/setBlockId.js +20 -0
- package/dist/build/buildPages/buildBlock/validateBlock.js +38 -0
- package/dist/build/buildPages/buildPage.js +50 -0
- package/dist/build/buildPages/buildPages.js +31 -0
- package/dist/build/buildPages/buildTestPage.js +46 -0
- package/dist/build/buildRefs/buildRefs.js +32 -0
- package/dist/build/buildRefs/evaluateBuildOperators.js +34 -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 +24 -0
- package/dist/build/buildRefs/makeRefDefinition.js +30 -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 +68 -0
- package/dist/build/buildRefs/runRefResolver.js +33 -0
- package/dist/build/buildRefs/runTransformer.js +30 -0
- package/dist/build/buildTypes.js +124 -0
- package/dist/build/cleanBuildDirectory.js +19 -0
- package/dist/build/copyPublicFolder.js +23 -0
- package/dist/build/testSchema.js +32 -0
- package/dist/build/updateServerPackageJson.js +50 -0
- package/dist/build/validateApp.js +34 -0
- package/dist/build/validateConfig.js +33 -0
- package/dist/build/writeApp.js +18 -0
- package/dist/build/writeAuth.js +18 -0
- package/dist/build/writeConfig.js +18 -0
- package/dist/build/writeConnections.js +26 -0
- package/dist/build/writeGlobal.js +25 -0
- package/dist/build/writeMenus.js +22 -0
- package/dist/build/writePages.js +25 -0
- package/dist/build/writePluginImports/generateImportFile.js +31 -0
- package/dist/build/writePluginImports/writeActionImports.js +22 -0
- package/dist/build/writePluginImports/writeAuthImports.js +34 -0
- package/dist/build/writePluginImports/writeBlockImports.js +22 -0
- package/dist/build/writePluginImports/writeConnectionImports.js +22 -0
- 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 +31 -0
- package/dist/build/writeTypes.js +18 -0
- package/dist/createContext.js +55 -0
- package/dist/defaultTypesMap.js +2046 -0
- package/dist/index.js +139 -0
- package/dist/lowdefySchema.js +841 -0
- package/dist/scripts/generateDefaultTypes.js +88 -0
- package/dist/scripts/run.js +33 -0
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +22 -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 +54 -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/createPluginTypesMap.js +113 -0
- package/dist/utils/formatErrorMessage.js +56 -0
- package/dist/utils/readConfigFile.js +24 -0
- package/dist/utils/writeBuildArtifact.js +23 -0
- package/package.json +36 -36
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 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 { readFile, writeFile } from '@lowdefy/node-utils';
|
|
18
|
+
import createPluginTypesMap from '../utils/createPluginTypesMap.js';
|
|
19
|
+
const defaultPackages = [
|
|
20
|
+
'@lowdefy/actions-core',
|
|
21
|
+
'@lowdefy/actions-pdf-make',
|
|
22
|
+
'@lowdefy/blocks-aggrid',
|
|
23
|
+
'@lowdefy/blocks-antd',
|
|
24
|
+
'@lowdefy/blocks-basic',
|
|
25
|
+
'@lowdefy/blocks-color-selectors',
|
|
26
|
+
'@lowdefy/blocks-echarts',
|
|
27
|
+
'@lowdefy/blocks-google-maps',
|
|
28
|
+
'@lowdefy/blocks-loaders',
|
|
29
|
+
'@lowdefy/blocks-markdown',
|
|
30
|
+
'@lowdefy/blocks-qr',
|
|
31
|
+
'@lowdefy/connection-axios-http',
|
|
32
|
+
'@lowdefy/connection-elasticsearch',
|
|
33
|
+
'@lowdefy/connection-google-sheets',
|
|
34
|
+
'@lowdefy/connection-knex',
|
|
35
|
+
'@lowdefy/connection-mongodb',
|
|
36
|
+
'@lowdefy/connection-redis',
|
|
37
|
+
'@lowdefy/connection-sendgrid',
|
|
38
|
+
'@lowdefy/connection-stripe',
|
|
39
|
+
'@lowdefy/operators-change-case',
|
|
40
|
+
'@lowdefy/operators-diff',
|
|
41
|
+
'@lowdefy/operators-js',
|
|
42
|
+
'@lowdefy/operators-mql',
|
|
43
|
+
'@lowdefy/operators-nunjucks',
|
|
44
|
+
'@lowdefy/operators-uuid',
|
|
45
|
+
'@lowdefy/operators-yaml',
|
|
46
|
+
'@lowdefy/plugin-auth0',
|
|
47
|
+
'@lowdefy/plugin-csv',
|
|
48
|
+
'@lowdefy/plugin-next-auth',
|
|
49
|
+
];
|
|
50
|
+
async function generateDefaultTypesMap() {
|
|
51
|
+
const packageFile = JSON.parse(await readFile(path.resolve(process.cwd(), './package.json')));
|
|
52
|
+
const defaultTypesMap = {
|
|
53
|
+
actions: {},
|
|
54
|
+
auth: {
|
|
55
|
+
adapters: {},
|
|
56
|
+
callbacks: {},
|
|
57
|
+
events: {},
|
|
58
|
+
providers: {}
|
|
59
|
+
},
|
|
60
|
+
blocks: {},
|
|
61
|
+
connections: {},
|
|
62
|
+
icons: {},
|
|
63
|
+
operators: {
|
|
64
|
+
client: {},
|
|
65
|
+
server: {}
|
|
66
|
+
},
|
|
67
|
+
requests: {},
|
|
68
|
+
styles: {
|
|
69
|
+
packages: {},
|
|
70
|
+
blocks: {}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
await Promise.all(defaultPackages.map(async (packageName)=>{
|
|
74
|
+
const { default: types } = await import(`${packageName}/types`);
|
|
75
|
+
const version = packageFile.devDependencies[packageName] || packageFile.dependencies[packageName];
|
|
76
|
+
createPluginTypesMap({
|
|
77
|
+
packageTypes: types,
|
|
78
|
+
typesMap: defaultTypesMap,
|
|
79
|
+
packageName,
|
|
80
|
+
version
|
|
81
|
+
});
|
|
82
|
+
}));
|
|
83
|
+
await writeFile(path.resolve(process.cwd(), './dist/defaultTypesMap.js'), `const defaultTypesMap = ${JSON.stringify(defaultTypesMap, null, 2)};
|
|
84
|
+
|
|
85
|
+
export default defaultTypesMap;
|
|
86
|
+
`);
|
|
87
|
+
}
|
|
88
|
+
generateDefaultTypesMap();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 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 yargs from 'yargs';
|
|
18
|
+
import { hideBin } from 'yargs/helpers';
|
|
19
|
+
import build from '../index.js';
|
|
20
|
+
const argv = yargs(hideBin(process.argv)).argv;
|
|
21
|
+
async function run() {
|
|
22
|
+
await build({
|
|
23
|
+
directories: {
|
|
24
|
+
build: path.resolve(argv.buildDirectory || process.env.LOWDEFY_DIRECTORY_BUILD || path.join(process.cwd(), 'build')),
|
|
25
|
+
config: path.resolve(argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
|
|
26
|
+
server: path.resolve(argv.serverDirectory || process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd())
|
|
27
|
+
},
|
|
28
|
+
logger: console,
|
|
29
|
+
refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
|
|
30
|
+
stage: argv.stage || process.env.LOWDEFY_BUILD_STAGE || 'prod'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
run();
|
|
@@ -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 { wait } from '@lowdefy/helpers';
|
|
16
|
+
async function asyncFn() {
|
|
17
|
+
await wait(20);
|
|
18
|
+
return {
|
|
19
|
+
async: true
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export default asyncFn;
|
|
@@ -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 resolver() {
|
|
16
|
+
throw new Error('Test error');
|
|
17
|
+
}
|
|
18
|
+
export default resolver;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 resolver(path) {
|
|
16
|
+
if (path === 'null') return null;
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export default resolver;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 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
|
+
export default resolver;
|
|
@@ -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
|
+
*/ function resolver(path, vars, context) {
|
|
16
|
+
return {
|
|
17
|
+
resolved: true,
|
|
18
|
+
path,
|
|
19
|
+
vars,
|
|
20
|
+
stage: context.stage
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export default resolver;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 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
|
+
export default transformer;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 transformer(obj, vars) {
|
|
16
|
+
return {
|
|
17
|
+
obj,
|
|
18
|
+
vars
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export default transformer;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 createCounter from '../utils/createCounter.js';
|
|
16
|
+
function testContext({ writeBuildArtifact , configDirectory , readConfigFile , logger ={} } = {}) {
|
|
17
|
+
const defaultLogger = {
|
|
18
|
+
info: ()=>{},
|
|
19
|
+
log: ()=>{},
|
|
20
|
+
warn: ()=>{},
|
|
21
|
+
error: ()=>{},
|
|
22
|
+
succeed: ()=>{}
|
|
23
|
+
};
|
|
24
|
+
const context = {
|
|
25
|
+
stage: 'test',
|
|
26
|
+
directories: {
|
|
27
|
+
config: configDirectory || ''
|
|
28
|
+
},
|
|
29
|
+
typeCounters: {
|
|
30
|
+
actions: createCounter(),
|
|
31
|
+
auth: {
|
|
32
|
+
adapters: createCounter(),
|
|
33
|
+
callbacks: createCounter(),
|
|
34
|
+
events: createCounter(),
|
|
35
|
+
providers: createCounter()
|
|
36
|
+
},
|
|
37
|
+
blocks: createCounter(),
|
|
38
|
+
connections: createCounter(),
|
|
39
|
+
requests: createCounter(),
|
|
40
|
+
operators: {
|
|
41
|
+
client: createCounter(),
|
|
42
|
+
server: createCounter()
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
writeBuildArtifact: writeBuildArtifact || (()=>{}),
|
|
46
|
+
readConfigFile: readConfigFile || (()=>{})
|
|
47
|
+
};
|
|
48
|
+
context.logger = {
|
|
49
|
+
...defaultLogger,
|
|
50
|
+
...logger
|
|
51
|
+
};
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
54
|
+
export default testContext;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { 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-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
|
+
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-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 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,113 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
function createTypeDefinitions({ packageName , store , typeNames , typePrefix , version }) {
|
|
17
|
+
if (type.isArray(typeNames)) {
|
|
18
|
+
typeNames.forEach((typeName)=>{
|
|
19
|
+
store[`${typePrefix}${typeName}`] = {
|
|
20
|
+
package: packageName,
|
|
21
|
+
originalTypeName: typeName,
|
|
22
|
+
version
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function createPluginTypesMap({ packageName , packageTypes , typePrefix ='' , typesMap , version }) {
|
|
28
|
+
createTypeDefinitions({
|
|
29
|
+
typeNames: packageTypes.actions,
|
|
30
|
+
store: typesMap.actions,
|
|
31
|
+
packageName,
|
|
32
|
+
typePrefix,
|
|
33
|
+
version
|
|
34
|
+
});
|
|
35
|
+
createTypeDefinitions({
|
|
36
|
+
typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.adapters : [],
|
|
37
|
+
store: typesMap.auth.adapters,
|
|
38
|
+
packageName,
|
|
39
|
+
typePrefix,
|
|
40
|
+
version
|
|
41
|
+
});
|
|
42
|
+
createTypeDefinitions({
|
|
43
|
+
typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.callbacks : [],
|
|
44
|
+
store: typesMap.auth.callbacks,
|
|
45
|
+
packageName,
|
|
46
|
+
typePrefix,
|
|
47
|
+
version
|
|
48
|
+
});
|
|
49
|
+
createTypeDefinitions({
|
|
50
|
+
typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.events : [],
|
|
51
|
+
store: typesMap.auth.events,
|
|
52
|
+
packageName,
|
|
53
|
+
typePrefix,
|
|
54
|
+
version
|
|
55
|
+
});
|
|
56
|
+
createTypeDefinitions({
|
|
57
|
+
typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.providers : [],
|
|
58
|
+
store: typesMap.auth.providers,
|
|
59
|
+
packageName,
|
|
60
|
+
typePrefix,
|
|
61
|
+
version
|
|
62
|
+
});
|
|
63
|
+
createTypeDefinitions({
|
|
64
|
+
typeNames: packageTypes.blocks,
|
|
65
|
+
store: typesMap.blocks,
|
|
66
|
+
packageName,
|
|
67
|
+
typePrefix,
|
|
68
|
+
version
|
|
69
|
+
});
|
|
70
|
+
createTypeDefinitions({
|
|
71
|
+
typeNames: packageTypes.connections,
|
|
72
|
+
store: typesMap.connections,
|
|
73
|
+
packageName,
|
|
74
|
+
typePrefix,
|
|
75
|
+
version
|
|
76
|
+
});
|
|
77
|
+
createTypeDefinitions({
|
|
78
|
+
typeNames: type.isObject(packageTypes.operators) ? packageTypes.operators.client : [],
|
|
79
|
+
store: typesMap.operators.client,
|
|
80
|
+
packageName,
|
|
81
|
+
typePrefix,
|
|
82
|
+
version
|
|
83
|
+
});
|
|
84
|
+
createTypeDefinitions({
|
|
85
|
+
typeNames: type.isObject(packageTypes.operators) ? packageTypes.operators.server : [],
|
|
86
|
+
store: typesMap.operators.server,
|
|
87
|
+
packageName,
|
|
88
|
+
typePrefix,
|
|
89
|
+
version
|
|
90
|
+
});
|
|
91
|
+
createTypeDefinitions({
|
|
92
|
+
typeNames: packageTypes.requests,
|
|
93
|
+
store: typesMap.requests,
|
|
94
|
+
packageName,
|
|
95
|
+
typePrefix,
|
|
96
|
+
version
|
|
97
|
+
});
|
|
98
|
+
if (type.isObject(packageTypes.styles)) {
|
|
99
|
+
Object.entries(packageTypes.styles).forEach(([blockType, styles])=>{
|
|
100
|
+
if (blockType === 'default') {
|
|
101
|
+
typesMap.styles.packages[packageName] = styles;
|
|
102
|
+
} else {
|
|
103
|
+
typesMap.styles.blocks[`${typePrefix}${blockType}`] = styles;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (type.isObject(packageTypes.icons)) {
|
|
108
|
+
Object.entries(packageTypes.icons).forEach(([blockType, icons])=>{
|
|
109
|
+
typesMap.icons[`${typePrefix}${blockType}`] = icons;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export default createPluginTypesMap;
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { get, type } from '@lowdefy/helpers';
|
|
16
|
+
function formatArrayKey({ index , object }) {
|
|
17
|
+
if (type.isObject(object) && (!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;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { cachedPromises } from '@lowdefy/helpers';
|
|
17
|
+
import { readFile } from '@lowdefy/node-utils';
|
|
18
|
+
function createReadConfigFile({ directories }) {
|
|
19
|
+
async function readConfigFile(filePath) {
|
|
20
|
+
return readFile(path.resolve(directories.config, filePath));
|
|
21
|
+
}
|
|
22
|
+
return cachedPromises(readConfigFile);
|
|
23
|
+
}
|
|
24
|
+
export default createReadConfigFile;
|
|
@@ -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 { writeFile } from '@lowdefy/node-utils';
|
|
17
|
+
function createWriteBuildArtifact({ directories }) {
|
|
18
|
+
async function writeBuildArtifact(filePath, content) {
|
|
19
|
+
await writeFile(path.join(directories.build, filePath), content);
|
|
20
|
+
}
|
|
21
|
+
return writeBuildArtifact;
|
|
22
|
+
}
|
|
23
|
+
export default createWriteBuildArtifact;
|