@lowdefy/build 3.23.2 → 4.0.0-alpha.6

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.
Files changed (90) hide show
  1. package/dist/build/addDefaultPages/404.js +51 -0
  2. package/dist/build/addDefaultPages/addDefaultPages.js +40 -0
  3. package/dist/build/buildAuth/buildAuth.js +50 -0
  4. package/dist/build/buildAuth/getPageRoles.js +33 -0
  5. package/dist/build/buildAuth/getProtectedPages.js +30 -0
  6. package/dist/build/buildConnections.js +46 -0
  7. package/dist/build/buildIcons.js +91 -0
  8. package/dist/build/buildMenu.js +122 -0
  9. package/dist/build/buildPages/buildBlock/buildBlock.js +31 -0
  10. package/dist/build/buildPages/buildBlock/buildEvents.js +72 -0
  11. package/dist/build/buildPages/buildBlock/buildRequests.js +51 -0
  12. package/dist/build/buildPages/buildBlock/buildSubBlocks.js +35 -0
  13. package/dist/build/buildPages/buildBlock/countBlockOperators.js +31 -0
  14. package/dist/build/buildPages/buildBlock/moveSubBlocksToArea.js +25 -0
  15. package/dist/build/buildPages/buildBlock/setBlockId.js +20 -0
  16. package/dist/build/buildPages/buildBlock/validateBlock.js +39 -0
  17. package/dist/build/buildPages/buildPage.js +50 -0
  18. package/dist/build/buildPages/buildPages.js +33 -0
  19. package/dist/build/buildRefs/buildRefs.js +25 -0
  20. package/dist/build/buildRefs/getConfigFile.js +28 -0
  21. package/dist/build/buildRefs/getRefContent.js +44 -0
  22. package/dist/build/buildRefs/getRefPath.js +30 -0
  23. package/dist/build/buildRefs/getRefsFromFile.js +37 -0
  24. package/dist/build/buildRefs/getUserJavascriptFunction.js +21 -0
  25. package/dist/build/buildRefs/makeRefDefinition.js +30 -0
  26. package/dist/build/buildRefs/parseNunjucks.js +20 -0
  27. package/dist/build/buildRefs/parseRefContent.js +37 -0
  28. package/dist/build/buildRefs/populateRefs.js +43 -0
  29. package/dist/build/buildRefs/recursiveBuild.js +62 -0
  30. package/dist/build/buildRefs/runRefResolver.js +33 -0
  31. package/dist/build/buildRefs/runTransformer.js +26 -0
  32. package/dist/build/buildStyles.js +29 -0
  33. package/dist/build/buildTypes.js +77 -0
  34. package/dist/build/cleanBuildDirectory.js +19 -0
  35. package/dist/build/testSchema.js +34 -0
  36. package/dist/build/updateServerPackageJson.js +49 -0
  37. package/dist/build/validateApp.js +34 -0
  38. package/dist/build/validateConfig.js +52 -0
  39. package/dist/build/writeApp.js +21 -0
  40. package/dist/build/writeConfig.js +21 -0
  41. package/dist/build/writeConnections.js +29 -0
  42. package/dist/build/writeGlobal.js +28 -0
  43. package/dist/build/writeMenus.js +25 -0
  44. package/dist/build/writePages.js +37 -0
  45. package/dist/build/writePluginImports/generateImportFile.js +36 -0
  46. package/dist/build/writePluginImports/writeBlockImports.js +25 -0
  47. package/dist/build/writePluginImports/writeConnectionImports.js +25 -0
  48. package/dist/build/writePluginImports/writeIconImports.js +34 -0
  49. package/dist/build/writePluginImports/writeOperatorImports.js +33 -0
  50. package/dist/build/writePluginImports/writeStyleImports.js +30 -0
  51. package/dist/build/writeRequests.js +37 -0
  52. package/dist/build/writeTypes.js +21 -0
  53. package/dist/defaultTypes.json +1159 -0
  54. package/dist/index.js +189 -1
  55. package/dist/lowdefySchema.js +709 -0
  56. package/dist/scripts/generateDefaultTypes.js +111 -0
  57. package/dist/scripts/run.js +28 -0
  58. package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +22 -0
  59. package/dist/test/buildRefs/testBuildRefsErrorResolver.js +18 -0
  60. package/dist/test/buildRefs/testBuildRefsNullResolver.js +19 -0
  61. package/dist/test/buildRefs/testBuildRefsParsingResolver.js +39 -0
  62. package/dist/test/buildRefs/testBuildRefsResolver.js +23 -0
  63. package/dist/test/buildRefs/testBuildRefsTransform.js +25 -0
  64. package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +21 -0
  65. package/dist/test/testContext.js +48 -0
  66. package/dist/utils/countOperators.js +30 -0
  67. package/dist/utils/createCheckDuplicateId.js +31 -0
  68. package/dist/utils/createCounter.js +33 -0
  69. package/dist/utils/files/readConfigFile.js +24 -0
  70. package/dist/utils/files/writeBuildArtifact.js +26 -0
  71. package/dist/utils/formatErrorMessage.js +56 -0
  72. package/package.json +39 -21
  73. package/dist/138.index.js +0 -2
  74. package/dist/138.index.js.LICENSE.txt +0 -3
  75. package/dist/231.index.js +0 -1
  76. package/dist/319.index.js +0 -1
  77. package/dist/35.index.js +0 -1
  78. package/dist/422.index.js +0 -1
  79. package/dist/443.index.js +0 -1
  80. package/dist/449.index.js +0 -1
  81. package/dist/5.index.js +0 -2
  82. package/dist/5.index.js.LICENSE.txt +0 -1
  83. package/dist/564.index.js +0 -1
  84. package/dist/569.index.js +0 -1
  85. package/dist/625.index.js +0 -1
  86. package/dist/693.index.js +0 -2
  87. package/dist/693.index.js.LICENSE.txt +0 -1
  88. package/dist/734.index.js +0 -1
  89. package/dist/904.index.js +0 -1
  90. package/dist/remoteEntry.js +0 -1
@@ -0,0 +1,111 @@
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-antd',
21
+ '@lowdefy/blocks-basic',
22
+ // '@lowdefy/blocks-color-selectors',
23
+ '@lowdefy/blocks-echarts',
24
+ '@lowdefy/blocks-loaders',
25
+ '@lowdefy/blocks-markdown',
26
+ '@lowdefy/connection-axios-http',
27
+ '@lowdefy/connection-redis',
28
+ '@lowdefy/operators-change-case',
29
+ // '@lowdefy/operators-diff',
30
+ '@lowdefy/operators-js',
31
+ // '@lowdefy/operators-mql',
32
+ '@lowdefy/operators-nunjucks',
33
+ '@lowdefy/operators-uuid',
34
+ '@lowdefy/operators-yaml',
35
+ ];
36
+ function createTypeDefinitions({ typeNames , store , packageName , version }) {
37
+ if (type.isArray(typeNames)) {
38
+ typeNames.forEach((typeName)=>{
39
+ store[typeName] = {
40
+ package: packageName,
41
+ version
42
+ };
43
+ });
44
+ }
45
+ }
46
+ async function generateDefaultTypes() {
47
+ const packageFile = JSON.parse(await readFile(path.resolve(process.cwd(), './package.json')));
48
+ const defaultTypes = {
49
+ actions: {},
50
+ blocks: {},
51
+ connections: {},
52
+ requests: {},
53
+ operators: {
54
+ client: {},
55
+ server: {}
56
+ },
57
+ icons: {},
58
+ styles: {}
59
+ };
60
+ await Promise.all(defaultPackages.map(async (packageName)=>{
61
+ const { default: types } = await import(`${packageName}/types`);
62
+ const version = packageFile.devDependencies[packageName];
63
+ createTypeDefinitions({
64
+ typeNames: types.actions,
65
+ store: defaultTypes.actions,
66
+ packageName,
67
+ version
68
+ });
69
+ createTypeDefinitions({
70
+ typeNames: types.blocks,
71
+ store: defaultTypes.blocks,
72
+ packageName,
73
+ version
74
+ });
75
+ createTypeDefinitions({
76
+ typeNames: types.connections,
77
+ store: defaultTypes.connections,
78
+ packageName,
79
+ version
80
+ });
81
+ createTypeDefinitions({
82
+ typeNames: types.requests,
83
+ store: defaultTypes.requests,
84
+ packageName,
85
+ version
86
+ });
87
+ createTypeDefinitions({
88
+ typeNames: type.isObject(types.operators) ? types.operators.client : [],
89
+ store: defaultTypes.operators.client,
90
+ packageName,
91
+ version
92
+ });
93
+ createTypeDefinitions({
94
+ typeNames: type.isObject(types.operators) ? types.operators.server : [],
95
+ store: defaultTypes.operators.server,
96
+ packageName,
97
+ version
98
+ });
99
+ if (type.isObject(types.styles)) {
100
+ defaultTypes.styles[packageName] = types.styles;
101
+ }
102
+ if (type.isObject(types.icons)) {
103
+ defaultTypes.icons[packageName] = types.icons;
104
+ }
105
+ }));
106
+ await writeFile({
107
+ filePath: path.resolve(process.cwd(), './dist/defaultTypes.json'),
108
+ content: JSON.stringify(defaultTypes, null, 2)
109
+ });
110
+ }
111
+ generateDefaultTypes();
@@ -0,0 +1,28 @@
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
+ directories: {
22
+ build: path.resolve(process.env.LOWDEFY_DIRECTORY_BUILD || path.join(process.cwd(), 'build')),
23
+ config: path.resolve(process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
24
+ server: path.resolve(process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd())
25
+ }
26
+ });
27
+ }
28
+ run();
@@ -0,0 +1,22 @@
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 { wait } from '@lowdefy/helpers';
16
+ async function asyncFn() {
17
+ await wait(20);
18
+ return {
19
+ async: true
20
+ };
21
+ }
22
+ 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,48 @@
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
+ const defaultLogger = {
18
+ info: ()=>{},
19
+ log: ()=>{},
20
+ warn: ()=>{},
21
+ error: ()=>{},
22
+ succeed: ()=>{}
23
+ };
24
+ const context = {
25
+ id: 'test',
26
+ directories: {
27
+ config: configDirectory || ''
28
+ },
29
+ typeCounters: {
30
+ actions: createCounter(),
31
+ blocks: createCounter(),
32
+ connections: createCounter(),
33
+ requests: createCounter(),
34
+ operators: {
35
+ client: createCounter(),
36
+ server: createCounter()
37
+ }
38
+ },
39
+ writeBuildArtifact: writeBuildArtifact || (()=>{}),
40
+ readConfigFile: readConfigFile || (()=>{})
41
+ };
42
+ context.logger = {
43
+ ...defaultLogger,
44
+ ...logger
45
+ };
46
+ return context;
47
+ }
48
+ 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({ 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,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({ directories }) {
18
+ async function writeBuildArtifact({ filePath , content }) {
19
+ return writeFile({
20
+ filePath: path.resolve(directories.build, 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.23.2",
3
+ "version": "4.0.0-alpha.6",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -18,47 +18,65 @@
18
18
  {
19
19
  "name": "Gerrie van Wyk",
20
20
  "url": "https://github.com/Gervwyk"
21
+ },
22
+ {
23
+ "name": "Sandile Memela",
24
+ "url": "https://github.com/sah-memela"
21
25
  }
22
26
  ],
23
27
  "repository": {
24
28
  "type": "git",
25
29
  "url": "https://github.com/lowdefy/lowdefy.git"
26
30
  },
27
- "main": "dist/index.js",
31
+ "type": "module",
32
+ "bin": {
33
+ "lowdefy-build": "./dist/scripts/run.js"
34
+ },
35
+ "exports": "./dist/index.js",
28
36
  "files": [
29
37
  "dist/*"
30
38
  ],
31
39
  "scripts": {
32
- "build": "yarn webpack",
40
+ "build": "yarn swc && node dist/scripts/generateDefaultTypes.js",
33
41
  "clean": "rm -rf dist",
34
42
  "prepare": "yarn build",
35
- "test": "jest --coverage",
36
- "webpack": "webpack --config webpack.config.js"
43
+ "start": "node dist/scripts/run.js",
44
+ "swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
45
+ "test": "jest --coverage"
37
46
  },
38
47
  "dependencies": {
39
- "@lowdefy/ajv": "3.23.2",
40
- "@lowdefy/helpers": "3.23.2",
41
- "@lowdefy/node-utils": "3.23.2",
42
- "@lowdefy/nunjucks": "3.23.2",
43
- "ajv": "6.12.6",
44
- "axios": "0.21.4",
48
+ "@lowdefy/ajv": "4.0.0-alpha.6",
49
+ "@lowdefy/helpers": "4.0.0-alpha.6",
50
+ "@lowdefy/node-utils": "4.0.0-alpha.6",
51
+ "@lowdefy/nunjucks": "4.0.0-alpha.6",
52
+ "ajv": "8.8.2",
45
53
  "js-yaml": "4.1.0",
46
54
  "json5": "2.2.0",
47
55
  "uuid": "8.3.2"
48
56
  },
49
57
  "devDependencies": {
50
- "@babel/cli": "7.14.3",
51
- "@babel/core": "7.14.3",
52
- "@babel/preset-env": "7.14.4",
53
- "babel-jest": "26.6.3",
54
- "babel-loader": "8.2.2",
55
- "clean-webpack-plugin": "3.0.0",
56
- "jest": "26.6.3",
57
- "webpack": "5.38.1",
58
- "webpack-cli": "4.7.0"
58
+ "@lowdefy/blocks-antd": "4.0.0-alpha.6",
59
+ "@lowdefy/blocks-basic": "4.0.0-alpha.6",
60
+ "@lowdefy/blocks-color-selectors": "4.0.0-alpha.6",
61
+ "@lowdefy/blocks-echarts": "4.0.0-alpha.6",
62
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.6",
63
+ "@lowdefy/blocks-markdown": "4.0.0-alpha.6",
64
+ "@lowdefy/connection-axios-http": "4.0.0-alpha.6",
65
+ "@lowdefy/connection-redis": "4.0.0-alpha.6",
66
+ "@lowdefy/operators-change-case": "4.0.0-alpha.6",
67
+ "@lowdefy/operators-diff": "4.0.0-alpha.6",
68
+ "@lowdefy/operators-js": "4.0.0-alpha.6",
69
+ "@lowdefy/operators-mql": "4.0.0-alpha.6",
70
+ "@lowdefy/operators-nunjucks": "4.0.0-alpha.6",
71
+ "@lowdefy/operators-uuid": "4.0.0-alpha.6",
72
+ "@lowdefy/operators-yaml": "4.0.0-alpha.6",
73
+ "@swc/cli": "0.1.55",
74
+ "@swc/core": "1.2.130",
75
+ "@swc/jest": "0.2.17",
76
+ "jest": "27.3.1"
59
77
  },
60
78
  "publishConfig": {
61
79
  "access": "public"
62
80
  },
63
- "gitHead": "4c30d3cdfa99ae4e90fc891825938c28bad45760"
81
+ "gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
64
82
  }