@lowdefy/build 4.0.0-alpha.5 → 4.0.0-alpha.8

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 (57) hide show
  1. package/dist/build/addDefaultPages/404.js +36 -41
  2. package/dist/build/addDefaultPages/addDefaultPages.js +6 -2
  3. package/dist/build/buildAuth/getPageRoles.js +1 -2
  4. package/dist/build/buildConnections.js +1 -2
  5. package/dist/build/buildIcons.js +42 -14
  6. package/dist/build/buildPages/buildBlock/buildEvents.js +4 -1
  7. package/dist/build/buildPages/buildBlock/buildRequests.js +1 -2
  8. package/dist/build/buildPages/buildBlock/countBlockOperators.js +2 -4
  9. package/dist/build/buildRefs/buildRefs.js +2 -2
  10. package/dist/build/buildRefs/evaluateBuildOperators.js +35 -0
  11. package/dist/build/buildRefs/getRefContent.js +1 -1
  12. package/dist/build/buildRefs/getUserJavascriptFunction.js +6 -3
  13. package/dist/build/buildRefs/makeRefDefinition.js +1 -2
  14. package/dist/build/buildRefs/parseRefContent.js +2 -2
  15. package/dist/build/buildRefs/recursiveBuild.js +9 -4
  16. package/dist/build/buildRefs/runTransformer.js +7 -3
  17. package/dist/build/buildStyles.js +2 -2
  18. package/dist/build/buildTypes.js +35 -31
  19. package/dist/build/cleanBuildDirectory.js +1 -1
  20. package/dist/build/copyPublicFolder.js +23 -0
  21. package/dist/build/updateServerPackageJson.js +2 -6
  22. package/dist/build/validateApp.js +2 -8
  23. package/dist/build/validateConfig.js +12 -8
  24. package/dist/build/writeApp.js +1 -5
  25. package/dist/build/writeConfig.js +1 -5
  26. package/dist/build/writeConnections.js +1 -4
  27. package/dist/build/writeGlobal.js +2 -6
  28. package/dist/build/writeMenus.js +1 -4
  29. package/dist/build/writePages.js +2 -13
  30. package/dist/build/writePluginImports/generateImportFile.js +6 -6
  31. package/dist/build/writePluginImports/writeActionImports.js +22 -0
  32. package/dist/build/writePluginImports/writeBlockImports.js +4 -7
  33. package/dist/build/writePluginImports/writeConnectionImports.js +4 -7
  34. package/dist/build/writePluginImports/writeIconImports.js +10 -16
  35. package/dist/build/writePluginImports/writeOperatorImports.js +8 -15
  36. package/dist/build/writePluginImports/writeStyleImports.js +3 -6
  37. package/dist/build/writeRequests.js +2 -7
  38. package/dist/build/writeTypes.js +1 -4
  39. package/dist/defaultTypesMap.json +1499 -0
  40. package/dist/index.js +133 -124
  41. package/dist/lowdefySchema.js +69 -28
  42. package/dist/scripts/generateDefaultTypes.js +34 -70
  43. package/dist/scripts/run.js +7 -3
  44. package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +2 -5
  45. package/dist/test/buildRefs/testBuildRefsErrorResolver.js +1 -1
  46. package/dist/test/buildRefs/testBuildRefsNullResolver.js +1 -1
  47. package/dist/test/buildRefs/testBuildRefsParsingResolver.js +1 -1
  48. package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
  49. package/dist/test/buildRefs/testBuildRefsTransform.js +1 -1
  50. package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +1 -1
  51. package/dist/test/testContext.js +8 -17
  52. package/dist/utils/createPluginTypesMap.js +85 -0
  53. package/dist/utils/formatErrorMessage.js +1 -1
  54. package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +0 -0
  55. package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +2 -5
  56. package/package.json +47 -23
  57. package/dist/defaultTypes.json +0 -896
@@ -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;
@@ -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
  }
@@ -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;
@@ -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;
@@ -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
@@ -14,18 +14,18 @@
14
14
  limitations under the License.
15
15
  */ import { nunjucksFunction } from '@lowdefy/nunjucks';
16
16
  const template = `{%- for import in imports -%}
17
- import { {{ import.type }} } from '{{ import.package }}/{{ importPath }}';
17
+ import { {{ import.originalTypeName }} as {{ import.typeName }} } from '{{ import.package }}/{{ importPath }}';
18
18
  {% endfor -%}
19
19
  export default {
20
20
  {% for import in imports -%}
21
- {{ import.type }},
21
+ {{ import.typeName }},
22
22
  {% endfor -%}
23
- }`;
23
+ };`;
24
24
  function generateImportFile({ types , importPath }) {
25
25
  const templateFn = nunjucksFunction(template);
26
- const imports = Object.keys(types).map((type)=>({
27
- type,
28
- ...types[type]
26
+ const imports = Object.keys(types).map((typeName)=>({
27
+ typeName,
28
+ ...types[typeName]
29
29
  })
30
30
  );
31
31
  return templateFn({
@@ -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 generateImportFile from './generateImportFile.js';
16
+ async function writeActionImports({ components , context }) {
17
+ await context.writeBuildArtifact('plugins/actions.js', generateImportFile({
18
+ types: components.types.actions,
19
+ importPath: 'actions'
20
+ }));
21
+ }
22
+ export default writeActionImports;
@@ -14,12 +14,9 @@
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
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
- });
17
+ await context.writeBuildArtifact('plugins/blocks.js', generateImportFile({
18
+ types: components.types.blocks,
19
+ importPath: 'blocks'
20
+ }));
24
21
  }
25
22
  export default writeBlockImports;
@@ -14,12 +14,9 @@
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
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
- });
17
+ await context.writeBuildArtifact('plugins/connections.js', generateImportFile({
18
+ types: components.types.connections,
19
+ importPath: 'connections'
20
+ }));
24
21
  }
25
22
  export default writeConnectionImports;
@@ -14,24 +14,18 @@
14
14
  limitations under the License.
15
15
  */ import { nunjucksFunction } from '@lowdefy/nunjucks';
16
16
  const template = `{%- for package in packages -%}
17
- {%- for icon in package.icons -%}
18
- import { {{ icon }} } from '{{ package.package }}';
19
- {% endfor -%}
20
- {% endfor -%}
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 -%}
21
19
  export default {
22
- {% for package in packages -%}
23
- {%- for icon in package.icons -%}
24
- {{ icon }},
25
- {% endfor -%}{%- endfor -%}
26
- };
27
- `;
20
+ {%- for package in packages -%}
21
+ {%- for icon in package.icons %}
22
+ {{ icon }},{% endfor %}
23
+ {%- endfor %}
24
+ };`;
28
25
  async function writeIconImports({ components , context }) {
29
26
  const templateFn = nunjucksFunction(template);
30
- await context.writeBuildArtifact({
31
- filePath: 'plugins/icons.js',
32
- content: templateFn({
33
- packages: components.icons
34
- })
35
- });
27
+ await context.writeBuildArtifact('plugins/icons.js', templateFn({
28
+ packages: components.icons
29
+ }));
36
30
  }
37
31
  export default writeIconImports;
@@ -14,20 +14,13 @@
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
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
- });
17
+ await context.writeBuildArtifact('plugins/operatorsClient.js', generateImportFile({
18
+ types: components.types.operators.client,
19
+ importPath: 'operators/client'
20
+ }));
21
+ await context.writeBuildArtifact('plugins/operatorsServer.js', generateImportFile({
22
+ types: components.types.operators.server,
23
+ importPath: 'operators/server'
24
+ }));
32
25
  }
33
26
  export default writeOperatorImports;
@@ -20,11 +20,8 @@ const template = `@import '@lowdefy/layout/style.less';
20
20
  `;
21
21
  async function writeStyleImports({ components , context }) {
22
22
  const templateFn = nunjucksFunction(template);
23
- await context.writeBuildArtifact({
24
- filePath: 'plugins/styles.less',
25
- content: templateFn({
26
- styles: components.styles
27
- })
28
- });
23
+ await context.writeBuildArtifact('plugins/styles.less', templateFn({
24
+ styles: components.styles
25
+ }));
29
26
  }
30
27
  export default writeStyleImports;
@@ -12,13 +12,9 @@
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 writeRequestsOnPage({ page , context }) {
15
+ */ async function writeRequestsOnPage({ page , context }) {
17
16
  return Promise.all(page.requests.map(async (request)=>{
18
- await context.writeBuildArtifact({
19
- filePath: `pages/${page.pageId}/requests/${request.requestId}.json`,
20
- content: JSON.stringify(request, null, 2)
21
- });
17
+ await context.writeBuildArtifact(`pages/${page.pageId}/requests/${request.requestId}.json`, JSON.stringify(request, null, 2));
22
18
  delete request.properties;
23
19
  delete request.type;
24
20
  delete request.connectionId;
@@ -26,7 +22,6 @@ async function writeRequestsOnPage({ page , context }) {
26
22
  }));
27
23
  }
28
24
  async function writeRequests({ components , context }) {
29
- if (type.isNone(components.pages)) return;
30
25
  const writePromises = components.pages.map((page)=>writeRequestsOnPage({
31
26
  page,
32
27
  context
@@ -13,9 +13,6 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ async function writeTypes({ components , context }) {
16
- await context.writeBuildArtifact({
17
- filePath: 'types.json',
18
- content: JSON.stringify(components.types, null, 2)
19
- });
16
+ await context.writeBuildArtifact('types.json', JSON.stringify(components.types, null, 2));
20
17
  }
21
18
  export default writeTypes;