@lowdefy/build 4.0.0-alpha.1 → 4.0.0-alpha.12

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 +37 -42
  2. package/dist/build/addDefaultPages/addDefaultPages.js +7 -3
  3. package/dist/build/buildAuth/buildAuth.js +10 -29
  4. package/dist/build/buildAuth/buildAuthPlugins.js +78 -0
  5. package/dist/build/buildAuth/buildPageAuth.js +50 -0
  6. package/dist/build/buildAuth/getPageRoles.js +3 -4
  7. package/dist/build/buildAuth/getProtectedPages.js +6 -6
  8. package/dist/build/buildAuth/validateAuthConfig.js +61 -0
  9. package/dist/build/buildConnections.js +2 -3
  10. package/dist/build/buildImports/buildIconImports.js +87 -0
  11. package/dist/build/buildImports/buildImports.js +30 -0
  12. package/dist/build/buildImports/buildImportsDev.js +103 -0
  13. package/dist/build/buildImports/buildImportsProd.js +54 -0
  14. package/dist/build/buildImports/buildStyleImports.js +28 -0
  15. package/dist/build/buildImports/defaultIconsDev.js +584 -0
  16. package/dist/build/buildImports/defaultIconsProd.js +21 -0
  17. package/dist/build/buildMenu.js +1 -1
  18. package/dist/build/buildPages/buildBlock/buildBlock.js +6 -2
  19. package/dist/build/buildPages/buildBlock/buildEvents.js +5 -2
  20. package/dist/build/buildPages/buildBlock/buildRequests.js +2 -3
  21. package/dist/build/buildPages/buildBlock/buildSubBlocks.js +1 -1
  22. package/dist/build/buildPages/buildBlock/countBlockOperators.js +4 -6
  23. package/dist/build/buildPages/buildBlock/countBlockTypes.js +18 -0
  24. package/dist/build/buildPages/buildBlock/moveSkeletonBlocksToArea.js +35 -0
  25. package/dist/build/buildPages/buildBlock/moveSubBlocksToArea.js +1 -1
  26. package/dist/build/buildPages/buildBlock/setBlockId.js +1 -1
  27. package/dist/build/buildPages/buildBlock/validateBlock.js +2 -3
  28. package/dist/build/buildPages/buildPage.js +1 -1
  29. package/dist/build/buildPages/buildPages.js +1 -1
  30. package/dist/build/buildRefs/buildRefs.js +3 -3
  31. package/dist/build/buildRefs/evaluateBuildOperators.js +35 -0
  32. package/dist/build/buildRefs/getConfigFile.js +1 -1
  33. package/dist/build/buildRefs/getRefContent.js +2 -2
  34. package/dist/build/buildRefs/getRefPath.js +1 -1
  35. package/dist/build/buildRefs/getRefsFromFile.js +1 -1
  36. package/dist/build/buildRefs/getUserJavascriptFunction.js +7 -4
  37. package/dist/build/buildRefs/makeRefDefinition.js +2 -3
  38. package/dist/build/buildRefs/parseNunjucks.js +1 -1
  39. package/dist/build/buildRefs/parseRefContent.js +3 -3
  40. package/dist/build/buildRefs/populateRefs.js +1 -1
  41. package/dist/build/buildRefs/recursiveBuild.js +10 -5
  42. package/dist/build/buildRefs/runRefResolver.js +1 -1
  43. package/dist/build/buildRefs/runTransformer.js +8 -4
  44. package/dist/build/buildTypes.js +72 -43
  45. package/dist/build/cleanBuildDirectory.js +2 -2
  46. package/dist/build/copyPublicFolder.js +23 -0
  47. package/dist/build/testSchema.js +3 -4
  48. package/dist/build/updateServerPackageJson.js +49 -0
  49. package/dist/build/validateApp.js +3 -5
  50. package/dist/build/validateConfig.js +8 -28
  51. package/dist/build/writeApp.js +2 -6
  52. package/dist/build/writeAuth.js +18 -0
  53. package/dist/build/writeConfig.js +2 -6
  54. package/dist/build/writeConnections.js +2 -5
  55. package/dist/build/writeGlobal.js +3 -7
  56. package/dist/build/writeMenus.js +2 -5
  57. package/dist/build/writePages.js +3 -14
  58. package/dist/build/writePluginImports/generateImportFile.js +31 -0
  59. package/dist/build/writePluginImports/writeActionImports.js +22 -0
  60. package/dist/build/writePluginImports/writeAuthImports.js +30 -0
  61. package/dist/build/writePluginImports/writeBlockImports.js +6 -23
  62. package/dist/build/writePluginImports/writeConnectionImports.js +6 -23
  63. package/dist/build/writePluginImports/writeIconImports.js +31 -0
  64. package/dist/build/writePluginImports/writeOperatorImports.js +26 -0
  65. package/dist/build/writePluginImports/writePluginImports.js +52 -0
  66. package/dist/build/writePluginImports/writeStyleImports.js +28 -0
  67. package/dist/build/writeRequests.js +3 -8
  68. package/dist/build/writeTypes.js +2 -5
  69. package/dist/defaultTypesMap.json +1874 -0
  70. package/dist/index.js +126 -112
  71. package/dist/lowdefySchema.js +173 -79
  72. package/dist/scripts/generateDefaultTypes.js +47 -75
  73. package/dist/scripts/run.js +14 -12
  74. package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +3 -6
  75. package/dist/test/buildRefs/testBuildRefsErrorResolver.js +2 -2
  76. package/dist/test/buildRefs/testBuildRefsNullResolver.js +2 -2
  77. package/dist/test/buildRefs/testBuildRefsParsingResolver.js +2 -2
  78. package/dist/test/buildRefs/testBuildRefsResolver.js +2 -2
  79. package/dist/test/buildRefs/testBuildRefsTransform.js +2 -2
  80. package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +2 -2
  81. package/dist/test/testContext.js +12 -19
  82. package/dist/utils/countOperators.js +1 -1
  83. package/dist/utils/createCheckDuplicateId.js +1 -1
  84. package/dist/utils/createCounter.js +1 -1
  85. package/dist/utils/createPluginTypesMap.js +106 -0
  86. package/dist/utils/formatErrorMessage.js +2 -2
  87. package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +3 -3
  88. package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +4 -7
  89. package/package.json +48 -16
  90. package/dist/defaultTypes.json +0 -60
@@ -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 fs from 'fs';
17
+ import { copyDirectory } from '@lowdefy/node-utils';
18
+ async function copyPublicFolder({ context }) {
19
+ if (context.directories.config === context.directories.server) return;
20
+ if (!fs.existsSync(path.resolve(context.directories.config, 'public'))) return;
21
+ await copyDirectory(path.resolve(context.directories.config, 'public'), path.resolve(context.directories.server, 'public'));
22
+ }
23
+ export default copyPublicFolder;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -23,12 +23,11 @@ async function testSchema({ components , context }) {
23
23
  });
24
24
  if (!valid) {
25
25
  await context.logger.warn('Schema not valid.');
26
- const promises = errors.map((error)=>context.logger.warn(formatErrorMessage({
26
+ await Promise.all(errors.map((error)=>context.logger.warn(formatErrorMessage({
27
27
  error,
28
28
  components
29
29
  }))
30
- );
31
- await promises;
30
+ ));
32
31
  }
33
32
  }
34
33
  export default testSchema;
@@ -0,0 +1,49 @@
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 { 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.auth.callbacks);
29
+ getPackages(components.types.auth.events);
30
+ getPackages(components.types.auth.providers);
31
+ getPackages(components.types.blocks);
32
+ getPackages(components.types.connections);
33
+ getPackages(components.types.requests);
34
+ getPackages(components.types.operators.client);
35
+ getPackages(components.types.operators.server);
36
+ // Sort dependencies
37
+ packageJson.dependencies = {};
38
+ Object.keys(dependencies).sort().forEach((name)=>{
39
+ packageJson.dependencies[name] = dependencies[name];
40
+ });
41
+ const newPackageJsonContent = JSON.stringify(packageJson, null, 2).concat('\n');
42
+ // Only write package.json if it has changed since dev server will
43
+ // be watching the file to trigger reinstalls
44
+ if (newPackageJsonContent !== packageJsonContent) {
45
+ context.logger.warn('Plugin dependencies have changed. Updating "package.json".');
46
+ await writeFile(filePath, newPackageJsonContent);
47
+ }
48
+ }
49
+ export default updateServerPackageJson;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-param-reassign */ /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,15 +15,13 @@
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  async function validateApp({ components }) {
17
17
  if (type.isNone(components.app)) {
18
- components.app = {
19
- };
18
+ components.app = {};
20
19
  }
21
20
  if (!type.isObject(components.app)) {
22
21
  throw new Error('lowdefy.app is not an object.');
23
22
  }
24
23
  if (type.isNone(components.app.html)) {
25
- components.app.html = {
26
- };
24
+ components.app.html = {};
27
25
  }
28
26
  if (type.isNone(components.app.html.appendBody)) {
29
27
  components.app.html.appendBody = '';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-param-reassign */ /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,40 +13,20 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { type } from '@lowdefy/helpers';
16
- import { validate } from '@lowdefy/ajv';
17
- import lowdefySchema from '../lowdefySchema.js';
18
16
  async function validateConfig({ components }) {
19
17
  if (type.isNone(components.config)) {
20
- components.config = {
21
- };
18
+ components.config = {};
22
19
  }
23
20
  if (!type.isObject(components.config)) {
24
21
  throw new Error('lowdefy.config is not an object.');
25
22
  }
26
- if (type.isNone(components.config.auth)) {
27
- components.config.auth = {
28
- };
23
+ if (type.isNone(components.config.theme)) {
24
+ components.config.theme = {};
29
25
  }
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.');
26
+ if (type.isString(components.config.basePath)) {
27
+ if (components.config.basePath[0] !== '/') {
28
+ throw Error('Base path must start with "/".');
29
+ }
50
30
  }
51
31
  return components;
52
32
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,10 +13,6 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ async function writeApp({ components , context }) {
16
- await context.writeBuildArtifact({
17
- filePath: 'app.json',
18
- content: JSON.stringify(components.app || {
19
- }, null, 2)
20
- });
16
+ await context.writeBuildArtifact('app.json', JSON.stringify(components.app || {}, null, 2));
21
17
  }
22
18
  export default writeApp;
@@ -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
+ */ async function writeAuth({ components , context }) {
16
+ await context.writeBuildArtifact('auth.json', JSON.stringify(components.auth || {}, null, 2));
17
+ }
18
+ export default writeAuth;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,10 +13,6 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ async function writeConfig({ components , context }) {
16
- await context.writeBuildArtifact({
17
- filePath: 'config.json',
18
- content: JSON.stringify(components.config || {
19
- }, null, 2)
20
- });
16
+ await context.writeBuildArtifact('config.json', JSON.stringify(components.config || {}, null, 2));
21
17
  }
22
18
  export default writeConfig;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -19,10 +19,7 @@ async function writeConnections({ components , context }) {
19
19
  throw new Error(`Connections is not an array.`);
20
20
  }
21
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
- });
22
+ await context.writeBuildArtifact(`connections/${connection.connectionId}.json`, JSON.stringify(connection, null, 2));
26
23
  });
27
24
  return Promise.all(writePromises);
28
25
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,15 +15,11 @@
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  async function writeGlobal({ components , context }) {
17
17
  if (type.isNone(components.global)) {
18
- components.global = {
19
- };
18
+ components.global = {};
20
19
  }
21
20
  if (!type.isObject(components.global)) {
22
21
  throw new Error('Global is not an object.');
23
22
  }
24
- await context.writeBuildArtifact({
25
- filePath: 'global.json',
26
- content: JSON.stringify(components.global, null, 2)
27
- });
23
+ await context.writeBuildArtifact('global.json', JSON.stringify(components.global, null, 2));
28
24
  }
29
25
  export default writeGlobal;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,9 +17,6 @@ async function writeMenus({ components , context }) {
17
17
  if (!type.isArray(components.menus)) {
18
18
  throw new Error('Menus is not an array.');
19
19
  }
20
- await context.writeBuildArtifact({
21
- filePath: 'menus.json',
22
- content: JSON.stringify(components.menus, null, 2)
23
- });
20
+ await context.writeBuildArtifact('menus.json', JSON.stringify(components.menus, null, 2));
24
21
  }
25
22
  export default writeMenus;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,21 +12,10 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { 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
- });
15
+ */ async function writePage({ page , context }) {
16
+ await context.writeBuildArtifact(`pages/${page.pageId}/${page.pageId}.json`, JSON.stringify(page, null, 2));
24
17
  }
25
18
  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
19
  const writePromises = components.pages.map((page)=>writePage({
31
20
  page,
32
21
  context
@@ -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
+ const template = `{%- for import in imports -%}
17
+ import { {{ import.originalTypeName }} as {{ import.typeName }} } from '{{ import.package }}/{{ importPath }}';
18
+ {% endfor -%}
19
+ export default {
20
+ {% for import in imports -%}
21
+ {{ import.typeName }},
22
+ {% endfor -%}
23
+ };`;
24
+ function generateImportFile({ imports , importPath }) {
25
+ const templateFn = nunjucksFunction(template);
26
+ return templateFn({
27
+ imports,
28
+ importPath
29
+ });
30
+ }
31
+ export default generateImportFile;
@@ -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 generateImportFile from './generateImportFile.js';
16
+ async function writeActionImports({ components , context }) {
17
+ await context.writeBuildArtifact('plugins/actions.js', generateImportFile({
18
+ imports: components.imports.actions,
19
+ importPath: 'actions'
20
+ }));
21
+ }
22
+ export default writeActionImports;
@@ -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 generateImportFile from './generateImportFile.js';
16
+ async function writeAuthImports({ components , context }) {
17
+ await context.writeBuildArtifact('plugins/auth/callbacks.js', generateImportFile({
18
+ imports: components.imports.auth.callbacks,
19
+ importPath: 'auth/callbacks'
20
+ }));
21
+ await context.writeBuildArtifact('plugins/auth/events.js', generateImportFile({
22
+ imports: components.imports.auth.events,
23
+ importPath: 'auth/events'
24
+ }));
25
+ await context.writeBuildArtifact('plugins/auth/providers.js', generateImportFile({
26
+ imports: components.imports.auth.providers,
27
+ importPath: 'auth/providers'
28
+ }));
29
+ }
30
+ export default writeAuthImports;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,28 +12,11 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { nunjucksFunction } from '@lowdefy/nunjucks';
16
- const template = `{%- for block in blocks -%}
17
- import { {{ block.type }} } from '{{ block.package }}/blocks';
18
- {% endfor -%}
19
- export default {
20
- {%- for block in blocks -%}
21
- {{ block.type }},
22
- {% endfor -%}
23
- };
24
- `;
15
+ */ import generateImportFile from './generateImportFile.js';
25
16
  async function writeBlockImports({ components , context }) {
26
- const templateFn = nunjucksFunction(template);
27
- const blocks = Object.keys(components.types.blocks).map((type)=>({
28
- type,
29
- ...components.types.blocks[type]
30
- })
31
- );
32
- await context.writeBuildArtifact({
33
- filePath: 'plugins/blocks.js',
34
- content: templateFn({
35
- blocks
36
- })
37
- });
17
+ await context.writeBuildArtifact('plugins/blocks.js', generateImportFile({
18
+ imports: components.imports.blocks,
19
+ importPath: 'blocks'
20
+ }));
38
21
  }
39
22
  export default writeBlockImports;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,28 +12,11 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { nunjucksFunction } from '@lowdefy/nunjucks';
16
- const template = `{%- for connection in connections -%}
17
- import { {{ connection.type }} } from '{{ connection.package }}/connections';
18
- {% endfor -%}
19
- export default {
20
- {%- for connection in connections -%}
21
- {{ connection.type }},
22
- {% endfor -%}
23
- };
24
- `;
15
+ */ import generateImportFile from './generateImportFile.js';
25
16
  async function writeConnectionImports({ components , context }) {
26
- const templateFn = nunjucksFunction(template);
27
- const connections = Object.keys(components.types.connections).map((type)=>({
28
- type,
29
- ...components.types.connections[type]
30
- })
31
- );
32
- await context.writeBuildArtifact({
33
- filePath: 'plugins/connections.js',
34
- content: templateFn({
35
- connections
36
- })
37
- });
17
+ await context.writeBuildArtifact('plugins/connections.js', generateImportFile({
18
+ imports: components.imports.connections,
19
+ importPath: 'connections'
20
+ }));
38
21
  }
39
22
  export default writeConnectionImports;
@@ -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
+ const template = `{%- for package in packages -%}
17
+ {% if package.icons.length %}import { {% for icon in package.icons -%}{% if not loop.last -%} {{ icon }}, {% else -%} {{ icon }} } from '{{ package.package }}';
18
+ {% endif -%}{% endfor %}{% endif %}{% endfor -%}
19
+ export default {
20
+ {%- for package in packages -%}
21
+ {%- for icon in package.icons %}
22
+ {{ icon }},{% endfor %}
23
+ {%- endfor %}
24
+ };`;
25
+ async function writeIconImports({ components , context }) {
26
+ const templateFn = nunjucksFunction(template);
27
+ await context.writeBuildArtifact('plugins/icons.js', templateFn({
28
+ packages: components.imports.icons
29
+ }));
30
+ }
31
+ export default writeIconImports;
@@ -0,0 +1,26 @@
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 generateImportFile from './generateImportFile.js';
16
+ async function writeOperatorImports({ components , context }) {
17
+ await context.writeBuildArtifact('plugins/operators/client.js', generateImportFile({
18
+ imports: components.imports.operators.client,
19
+ importPath: 'operators/client'
20
+ }));
21
+ await context.writeBuildArtifact('plugins/operators/server.js', generateImportFile({
22
+ imports: components.imports.operators.server,
23
+ importPath: 'operators/server'
24
+ }));
25
+ }
26
+ export default writeOperatorImports;
@@ -0,0 +1,52 @@
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 writeActionImports from './writeActionImports.js';
16
+ import writeAuthImports from './writeAuthImports.js';
17
+ import writeBlockImports from './writeBlockImports.js';
18
+ import writeConnectionImports from './writeConnectionImports.js';
19
+ import writeIconImports from './writeIconImports.js';
20
+ import writeOperatorImports from './writeOperatorImports.js';
21
+ import writeStyleImports from './writeStyleImports.js';
22
+ async function writePluginImports({ components , context }) {
23
+ await writeActionImports({
24
+ components,
25
+ context
26
+ });
27
+ await writeAuthImports({
28
+ components,
29
+ context
30
+ });
31
+ await writeBlockImports({
32
+ components,
33
+ context
34
+ });
35
+ await writeConnectionImports({
36
+ components,
37
+ context
38
+ });
39
+ await writeIconImports({
40
+ components,
41
+ context
42
+ });
43
+ await writeOperatorImports({
44
+ components,
45
+ context
46
+ });
47
+ await writeStyleImports({
48
+ components,
49
+ context
50
+ });
51
+ }
52
+ export default writePluginImports;
@@ -0,0 +1,28 @@
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
+ const template = `@import '@lowdefy/layout/style.less';
17
+ @import '@lowdefy/client/style.less';
18
+ {% for style in styles -%}
19
+ @import '{{ style }}';
20
+ {% endfor -%}
21
+ `;
22
+ async function writeStyleImports({ components , context }) {
23
+ const templateFn = nunjucksFunction(template);
24
+ await context.writeBuildArtifact('plugins/styles.less', templateFn({
25
+ styles: components.imports.styles
26
+ }));
27
+ }
28
+ export default writeStyleImports;