@lowdefy/build 3.23.0 → 4.0.0-alpha.5

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 +56 -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 +34 -0
  5. package/dist/build/buildAuth/getProtectedPages.js +30 -0
  6. package/dist/build/buildConnections.js +47 -0
  7. package/dist/build/buildIcons.js +63 -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 +52 -0
  12. package/dist/build/buildPages/buildBlock/buildSubBlocks.js +35 -0
  13. package/dist/build/buildPages/buildBlock/countBlockOperators.js +33 -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 +26 -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 +31 -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 +63 -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 +83 -0
  34. package/dist/build/cleanBuildDirectory.js +19 -0
  35. package/dist/build/testSchema.js +34 -0
  36. package/dist/build/updateServerPackageJson.js +50 -0
  37. package/dist/build/validateApp.js +40 -0
  38. package/dist/build/validateConfig.js +53 -0
  39. package/dist/build/writeApp.js +22 -0
  40. package/dist/build/writeConfig.js +22 -0
  41. package/dist/build/writeConnections.js +29 -0
  42. package/dist/build/writeGlobal.js +29 -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 +37 -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 +896 -0
  54. package/dist/index.js +188 -1
  55. package/dist/lowdefySchema.js +705 -0
  56. package/dist/scripts/generateDefaultTypes.js +108 -0
  57. package/dist/scripts/run.js +28 -0
  58. package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +25 -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 +57 -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 +29 -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,83 @@
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 buildTypeClass({ counter , definitions , store , typeClass }) {
16
+ const counts = counter.getCounts();
17
+ Object.keys(counts).forEach((typeName)=>{
18
+ if (!definitions[typeName]) {
19
+ throw new Error(`${typeClass} type "${typeName}" was used but is not defined.`);
20
+ }
21
+ store[typeName] = {
22
+ package: definitions[typeName].package,
23
+ version: definitions[typeName].version,
24
+ count: counts[typeName]
25
+ };
26
+ });
27
+ }
28
+ function buildTypes({ components , context }) {
29
+ const { typeCounters } = context;
30
+ components.types = {
31
+ actions: {
32
+ },
33
+ blocks: {
34
+ },
35
+ connections: {
36
+ },
37
+ requests: {
38
+ },
39
+ operators: {
40
+ client: {
41
+ },
42
+ server: {
43
+ }
44
+ }
45
+ };
46
+ // buildTypeClass({
47
+ // counter: typeCounters.actions,
48
+ // definitions: context.types.actions,
49
+ // store: components.types.actions,
50
+ // typeClass: 'Action',
51
+ // });
52
+ buildTypeClass({
53
+ counter: typeCounters.blocks,
54
+ definitions: context.types.blocks,
55
+ store: components.types.blocks,
56
+ typeClass: 'Block'
57
+ });
58
+ buildTypeClass({
59
+ counter: typeCounters.connections,
60
+ definitions: context.types.connections,
61
+ store: components.types.connections,
62
+ typeClass: 'Connection'
63
+ });
64
+ buildTypeClass({
65
+ counter: typeCounters.requests,
66
+ definitions: context.types.requests,
67
+ store: components.types.requests,
68
+ typeClass: 'Request'
69
+ });
70
+ buildTypeClass({
71
+ counter: typeCounters.operators.client,
72
+ definitions: context.types.operators.client,
73
+ store: components.types.operators.client,
74
+ typeClass: 'Operator'
75
+ });
76
+ buildTypeClass({
77
+ counter: typeCounters.operators.server,
78
+ definitions: context.types.operators.server,
79
+ store: components.types.operators.server,
80
+ typeClass: 'Operator'
81
+ });
82
+ }
83
+ export default buildTypes;
@@ -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
+ */ import { cleanDirectory } from '@lowdefy/node-utils';
16
+ async function cleanBuildDirectory({ context }) {
17
+ return cleanDirectory(context.directories.build);
18
+ }
19
+ export default cleanBuildDirectory;
@@ -0,0 +1,34 @@
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 { validate } from '@lowdefy/ajv';
16
+ import lowdefySchema from '../lowdefySchema.js';
17
+ import formatErrorMessage from '../utils/formatErrorMessage.js';
18
+ async function testSchema({ components , context }) {
19
+ const { valid , errors } = validate({
20
+ schema: lowdefySchema,
21
+ data: components,
22
+ returnErrors: true
23
+ });
24
+ if (!valid) {
25
+ await context.logger.warn('Schema not valid.');
26
+ const promises = errors.map((error)=>context.logger.warn(formatErrorMessage({
27
+ error,
28
+ components
29
+ }))
30
+ );
31
+ await promises;
32
+ }
33
+ }
34
+ export default testSchema;
@@ -0,0 +1,50 @@
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 { readFile, writeFile } from '@lowdefy/node-utils';
17
+ async function updateServerPackageJson({ components , context }) {
18
+ const filePath = path.join(context.directories.server, 'package.json');
19
+ const packageJsonContent = await readFile(filePath);
20
+ const packageJson = JSON.parse(packageJsonContent);
21
+ const dependencies = packageJson.dependencies;
22
+ function getPackages(types) {
23
+ Object.values(types).forEach((type)=>{
24
+ dependencies[type.package] = type.version;
25
+ });
26
+ }
27
+ getPackages(components.types.actions);
28
+ getPackages(components.types.blocks);
29
+ getPackages(components.types.connections);
30
+ getPackages(components.types.requests);
31
+ getPackages(components.types.operators.client);
32
+ getPackages(components.types.operators.server);
33
+ // Sort dependencies
34
+ packageJson.dependencies = {
35
+ };
36
+ Object.keys(dependencies).sort().forEach((name)=>{
37
+ packageJson.dependencies[name] = dependencies[name];
38
+ });
39
+ const newPackageJsonContent = JSON.stringify(packageJson, null, 2).concat('\n');
40
+ // Only write package.json if it has changed since dev server will
41
+ // be watching the file to trigger reinstalls
42
+ if (newPackageJsonContent !== packageJsonContent) {
43
+ context.logger.warn('Plugin dependencies have changed. Updating "package.json".');
44
+ await writeFile({
45
+ filePath,
46
+ content: newPackageJsonContent
47
+ });
48
+ }
49
+ }
50
+ export default updateServerPackageJson;
@@ -0,0 +1,40 @@
1
+ /* eslint-disable no-param-reassign */ /*
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
+ async function validateApp({ components }) {
17
+ if (type.isNone(components.app)) {
18
+ components.app = {
19
+ };
20
+ }
21
+ if (!type.isObject(components.app)) {
22
+ throw new Error('lowdefy.app is not an object.');
23
+ }
24
+ if (type.isNone(components.app.html)) {
25
+ components.app.html = {
26
+ };
27
+ }
28
+ if (type.isNone(components.app.styles)) {
29
+ components.app.styles = {
30
+ };
31
+ }
32
+ if (type.isNone(components.app.html.appendBody)) {
33
+ components.app.html.appendBody = '';
34
+ }
35
+ if (type.isNone(components.app.html.appendHead)) {
36
+ components.app.html.appendHead = '';
37
+ }
38
+ return components;
39
+ }
40
+ export default validateApp;
@@ -0,0 +1,53 @@
1
+ /* eslint-disable no-param-reassign */ /*
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
+ import { validate } from '@lowdefy/ajv';
17
+ import lowdefySchema from '../lowdefySchema.js';
18
+ async function validateConfig({ components }) {
19
+ if (type.isNone(components.config)) {
20
+ components.config = {
21
+ };
22
+ }
23
+ if (!type.isObject(components.config)) {
24
+ throw new Error('lowdefy.config is not an object.');
25
+ }
26
+ if (type.isNone(components.config.auth)) {
27
+ components.config.auth = {
28
+ };
29
+ }
30
+ if (type.isNone(components.config.auth.pages)) {
31
+ components.config.auth.pages = {
32
+ };
33
+ }
34
+ if (type.isNone(components.config.auth.pages.roles)) {
35
+ components.config.auth.pages.roles = {
36
+ };
37
+ }
38
+ validate({
39
+ schema: lowdefySchema.definitions.authConfig,
40
+ data: components.config.auth
41
+ });
42
+ if (components.config.auth.pages.protected === true && components.config.auth.pages.public === true || type.isArray(components.config.auth.pages.protected) && type.isArray(components.config.auth.pages.public)) {
43
+ throw new Error('Protected and public pages are mutually exclusive. When protected pages are listed, all unlisted pages are public by default and visa versa.');
44
+ }
45
+ if (components.config.auth.pages.protected === false) {
46
+ throw new Error('Protected pages can not be set to false.');
47
+ }
48
+ if (components.config.auth.pages.public === false) {
49
+ throw new Error('Public pages can not be set to false.');
50
+ }
51
+ return components;
52
+ }
53
+ export default validateConfig;
@@ -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
+ */ async function writeApp({ components , context }) {
16
+ await context.writeBuildArtifact({
17
+ filePath: 'app.json',
18
+ content: JSON.stringify(components.app || {
19
+ }, null, 2)
20
+ });
21
+ }
22
+ export default writeApp;
@@ -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
+ */ async function writeConfig({ components , context }) {
16
+ await context.writeBuildArtifact({
17
+ filePath: 'config.json',
18
+ content: JSON.stringify(components.config || {
19
+ }, null, 2)
20
+ });
21
+ }
22
+ export default writeConfig;
@@ -0,0 +1,29 @@
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
+ async function writeConnections({ components , context }) {
17
+ if (type.isNone(components.connections)) return;
18
+ if (!type.isArray(components.connections)) {
19
+ throw new Error(`Connections is not an array.`);
20
+ }
21
+ const writePromises = components.connections.map(async (connection)=>{
22
+ await context.writeBuildArtifact({
23
+ filePath: `connections/${connection.connectionId}.json`,
24
+ content: JSON.stringify(connection, null, 2)
25
+ });
26
+ });
27
+ return Promise.all(writePromises);
28
+ }
29
+ export default writeConnections;
@@ -0,0 +1,29 @@
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
+ async function writeGlobal({ components , context }) {
17
+ if (type.isNone(components.global)) {
18
+ components.global = {
19
+ };
20
+ }
21
+ if (!type.isObject(components.global)) {
22
+ throw new Error('Global is not an object.');
23
+ }
24
+ await context.writeBuildArtifact({
25
+ filePath: 'global.json',
26
+ content: JSON.stringify(components.global, null, 2)
27
+ });
28
+ }
29
+ export default writeGlobal;
@@ -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
+ */ import { type } from '@lowdefy/helpers';
16
+ async function writeMenus({ components , context }) {
17
+ if (!type.isArray(components.menus)) {
18
+ throw new Error('Menus is not an array.');
19
+ }
20
+ await context.writeBuildArtifact({
21
+ filePath: 'menus.json',
22
+ content: JSON.stringify(components.menus, null, 2)
23
+ });
24
+ }
25
+ export default writeMenus;
@@ -0,0 +1,37 @@
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
+ async function writePage({ page , context }) {
17
+ if (!type.isObject(page)) {
18
+ throw new Error(`Page is not an object. Received ${JSON.stringify(page)}`);
19
+ }
20
+ await context.writeBuildArtifact({
21
+ filePath: `pages/${page.pageId}/${page.pageId}.json`,
22
+ content: JSON.stringify(page, null, 2)
23
+ });
24
+ }
25
+ async function writePages({ components , context }) {
26
+ if (type.isNone(components.pages)) return;
27
+ if (!type.isArray(components.pages)) {
28
+ throw new Error(`Pages is not an array.`);
29
+ }
30
+ const writePromises = components.pages.map((page)=>writePage({
31
+ page,
32
+ context
33
+ })
34
+ );
35
+ return Promise.all(writePromises);
36
+ }
37
+ export default writePages;
@@ -0,0 +1,36 @@
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
+ const template = `{%- for import in imports -%}
17
+ import { {{ import.type }} } from '{{ import.package }}/{{ importPath }}';
18
+ {% endfor -%}
19
+ export default {
20
+ {% for import in imports -%}
21
+ {{ import.type }},
22
+ {% endfor -%}
23
+ }`;
24
+ function generateImportFile({ types , importPath }) {
25
+ const templateFn = nunjucksFunction(template);
26
+ const imports = Object.keys(types).map((type)=>({
27
+ type,
28
+ ...types[type]
29
+ })
30
+ );
31
+ return templateFn({
32
+ imports,
33
+ importPath
34
+ });
35
+ }
36
+ export default generateImportFile;
@@ -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
+ */ import generateImportFile from './generateImportFile.js';
16
+ async function writeBlockImports({ components , context }) {
17
+ await context.writeBuildArtifact({
18
+ filePath: 'plugins/blocks.js',
19
+ content: generateImportFile({
20
+ types: components.types.blocks,
21
+ importPath: 'blocks'
22
+ })
23
+ });
24
+ }
25
+ export default writeBlockImports;
@@ -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
+ */ import generateImportFile from './generateImportFile.js';
16
+ async function writeConnectionImports({ components , context }) {
17
+ await context.writeBuildArtifact({
18
+ filePath: 'plugins/connections.js',
19
+ content: generateImportFile({
20
+ types: components.types.connections,
21
+ importPath: 'connections'
22
+ })
23
+ });
24
+ }
25
+ export default writeConnectionImports;
@@ -0,0 +1,37 @@
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
+ const template = `{%- for package in packages -%}
17
+ {%- for icon in package.icons -%}
18
+ import { {{ icon }} } from '{{ package.package }}';
19
+ {% endfor -%}
20
+ {% endfor -%}
21
+ export default {
22
+ {% for package in packages -%}
23
+ {%- for icon in package.icons -%}
24
+ {{ icon }},
25
+ {% endfor -%}{%- endfor -%}
26
+ };
27
+ `;
28
+ async function writeIconImports({ components , context }) {
29
+ const templateFn = nunjucksFunction(template);
30
+ await context.writeBuildArtifact({
31
+ filePath: 'plugins/icons.js',
32
+ content: templateFn({
33
+ packages: components.icons
34
+ })
35
+ });
36
+ }
37
+ export default writeIconImports;
@@ -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
+ */ import generateImportFile from './generateImportFile.js';
16
+ async function writeOperatorImports({ components , context }) {
17
+ // TODO: import _not and _type for validation.
18
+ await context.writeBuildArtifact({
19
+ filePath: 'plugins/operatorsClient.js',
20
+ content: generateImportFile({
21
+ types: components.types.operators.client,
22
+ importPath: 'operators/client'
23
+ })
24
+ });
25
+ await context.writeBuildArtifact({
26
+ filePath: 'plugins/operatorsServer.js',
27
+ content: generateImportFile({
28
+ types: components.types.operators.server,
29
+ importPath: 'operators/server'
30
+ })
31
+ });
32
+ }
33
+ export default writeOperatorImports;
@@ -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 { nunjucksFunction } from '@lowdefy/nunjucks';
16
+ const template = `@import '@lowdefy/layout/style.less';
17
+ {% for style in styles -%}
18
+ @import '{{ style }}';
19
+ {% endfor -%}
20
+ `;
21
+ async function writeStyleImports({ components , context }) {
22
+ const templateFn = nunjucksFunction(template);
23
+ await context.writeBuildArtifact({
24
+ filePath: 'plugins/styles.less',
25
+ content: templateFn({
26
+ styles: components.styles
27
+ })
28
+ });
29
+ }
30
+ export default writeStyleImports;