@lowdefy/build 4.0.0-rc.1 → 4.0.0-rc.11

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 (77) hide show
  1. package/dist/build/addDefaultPages/addDefaultPages.js +1 -1
  2. package/dist/build/addKeys.js +48 -0
  3. package/dist/build/buildAuth/buildAuth.js +1 -1
  4. package/dist/build/buildAuth/buildAuthPlugins.js +4 -4
  5. package/dist/build/buildAuth/buildPageAuth.js +1 -1
  6. package/dist/build/buildAuth/getPageRoles.js +1 -1
  7. package/dist/build/buildAuth/getProtectedPages.js +1 -1
  8. package/dist/build/buildAuth/validateAuthConfig.js +1 -1
  9. package/dist/build/buildConnections.js +1 -1
  10. package/dist/build/buildImports/buildIconImports.js +4 -3
  11. package/dist/build/buildImports/buildImports.js +1 -1
  12. package/dist/build/buildImports/buildImportsDev.js +3 -3
  13. package/dist/build/buildImports/buildImportsProd.js +1 -1
  14. package/dist/build/buildImports/buildStyleImports.js +1 -1
  15. package/dist/build/buildMenu.js +3 -3
  16. package/dist/build/buildPages/buildBlock/buildEvents.js +1 -1
  17. package/dist/build/buildPages/buildBlock/buildRequests.js +1 -1
  18. package/dist/build/buildPages/buildBlock/countBlockOperators.js +2 -2
  19. package/dist/build/buildPages/buildBlock/countBlockTypes.js +1 -1
  20. package/dist/build/buildPages/buildBlock/setBlockId.js +1 -1
  21. package/dist/build/buildPages/buildBlock/validateBlock.js +1 -1
  22. package/dist/build/buildPages/buildPage.js +1 -1
  23. package/dist/build/buildPages/buildPages.js +1 -1
  24. package/dist/build/buildPages/buildTestPage.js +1 -1
  25. package/dist/build/buildRefs/buildRefs.js +2 -2
  26. package/dist/build/buildRefs/evaluateBuildOperators.js +4 -4
  27. package/dist/build/buildRefs/getConfigFile.js +1 -1
  28. package/dist/build/buildRefs/getKey.js +1 -1
  29. package/dist/build/buildRefs/getRefContent.js +1 -1
  30. package/dist/build/buildRefs/getRefsFromFile.js +2 -2
  31. package/dist/build/buildRefs/getUserJavascriptFunction.js +1 -1
  32. package/dist/build/buildRefs/makeRefDefinition.js +10 -4
  33. package/dist/build/buildRefs/parseRefContent.js +2 -2
  34. package/dist/build/buildRefs/populateRefs.js +1 -1
  35. package/dist/build/buildRefs/recursiveBuild.js +20 -7
  36. package/dist/build/buildRefs/runRefResolver.js +1 -1
  37. package/dist/build/buildRefs/runTransformer.js +1 -1
  38. package/dist/build/buildTypes.js +3 -3
  39. package/dist/build/cleanBuildDirectory.js +1 -1
  40. package/dist/build/copyPublicFolder.js +1 -1
  41. package/dist/build/testSchema.js +2 -2
  42. package/dist/build/updateServerPackageJson.js +2 -7
  43. package/dist/build/validateApp.js +1 -1
  44. package/dist/build/validateConfig.js +1 -1
  45. package/dist/build/writeApp.js +5 -2
  46. package/dist/build/writeAuth.js +5 -2
  47. package/dist/build/writeConfig.js +5 -2
  48. package/dist/build/writeConnections.js +5 -3
  49. package/dist/build/writeGlobal.js +5 -3
  50. package/dist/build/writeMaps.js +30 -0
  51. package/dist/build/writeMenus.js +5 -3
  52. package/dist/build/writePages.js +6 -3
  53. package/dist/build/writePluginImports/generateImportFile.js +1 -1
  54. package/dist/build/writePluginImports/writeActionImports.js +1 -1
  55. package/dist/build/writePluginImports/writeAuthImports.js +1 -1
  56. package/dist/build/writePluginImports/writeBlockImports.js +1 -1
  57. package/dist/build/writePluginImports/writeConnectionImports.js +1 -1
  58. package/dist/build/writePluginImports/writeIconImports.js +1 -1
  59. package/dist/build/writePluginImports/writeOperatorImports.js +1 -1
  60. package/dist/build/writePluginImports/writePluginImports.js +1 -1
  61. package/dist/build/writePluginImports/writeStyleImports.js +1 -1
  62. package/dist/build/writeRequests.js +6 -3
  63. package/dist/build/writeTypes.js +5 -2
  64. package/dist/createContext.js +3 -1
  65. package/dist/defaultTypesMap.js +562 -552
  66. package/dist/index.js +10 -0
  67. package/dist/lowdefySchema.js +6 -0
  68. package/dist/scripts/generateDefaultTypes.js +2 -1
  69. package/dist/test/testContext.js +4 -2
  70. package/dist/utils/countOperators.js +1 -1
  71. package/dist/utils/createCheckDuplicateId.js +2 -2
  72. package/dist/utils/createPluginTypesMap.js +2 -2
  73. package/dist/utils/formatErrorMessage.js +3 -3
  74. package/dist/utils/makeId.js +20 -0
  75. package/dist/utils/readConfigFile.js +1 -1
  76. package/dist/utils/writeBuildArtifact.js +1 -1
  77. package/package.json +46 -46
@@ -15,8 +15,8 @@
15
15
  */ import { validate } from '@lowdefy/ajv';
16
16
  import lowdefySchema from '../lowdefySchema.js';
17
17
  import formatErrorMessage from '../utils/formatErrorMessage.js';
18
- function testSchema({ components , context }) {
19
- const { valid , errors } = validate({
18
+ function testSchema({ components, context }) {
19
+ const { valid, errors } = validate({
20
20
  schema: lowdefySchema,
21
21
  data: components,
22
22
  returnErrors: true
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  import { readFile, writeFile } from '@lowdefy/node-utils';
17
- async function updateServerPackageJson({ components , context }) {
17
+ async function updateServerPackageJson({ components, context }) {
18
18
  const filePath = path.join(context.directories.server, 'package.json');
19
19
  const packageJsonContent = await readFile(filePath);
20
20
  const packageJson = JSON.parse(packageJsonContent);
@@ -40,11 +40,6 @@ async function updateServerPackageJson({ components , context }) {
40
40
  packageJson.dependencies[name] = dependencies[name];
41
41
  });
42
42
  const newPackageJsonContent = JSON.stringify(packageJson, null, 2).concat('\n');
43
- // Only write package.json if it has changed since dev server will
44
- // be watching the file to trigger reinstalls
45
- if (newPackageJsonContent !== packageJsonContent) {
46
- context.logger.warn('Plugin dependencies have changed. Updating "package.json".');
47
- await writeFile(filePath, newPackageJsonContent);
48
- }
43
+ await writeFile(filePath, newPackageJsonContent);
49
44
  }
50
45
  export default updateServerPackageJson;
@@ -13,7 +13,7 @@
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
- function validateApp({ components }) {
16
+ function validateApp({ components }) {
17
17
  if (type.isNone(components.app)) {
18
18
  components.app = {};
19
19
  }
@@ -13,7 +13,7 @@
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
- function validateConfig({ components }) {
16
+ function validateConfig({ components }) {
17
17
  if (type.isNone(components.config)) {
18
18
  components.config = {};
19
19
  }
@@ -12,7 +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
- */ async function writeApp({ components , context }) {
16
- await context.writeBuildArtifact('app.json', JSON.stringify(components.app || {}, null, 2));
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function writeApp({ components, context }) {
17
+ await context.writeBuildArtifact('app.json', serializer.serializeToString(components.app ?? {}, {
18
+ space: 2
19
+ }));
17
20
  }
18
21
  export default writeApp;
@@ -12,7 +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
- */ async function writeAuth({ components , context }) {
16
- await context.writeBuildArtifact('auth.json', JSON.stringify(components.auth || {}, null, 2));
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function writeAuth({ components, context }) {
17
+ await context.writeBuildArtifact('auth.json', serializer.serializeToString(components.auth ?? {}, {
18
+ space: 2
19
+ }));
17
20
  }
18
21
  export default writeAuth;
@@ -12,7 +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
- */ async function writeConfig({ components , context }) {
16
- await context.writeBuildArtifact('config.json', JSON.stringify(components.config || {}, null, 2));
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function writeConfig({ components, context }) {
17
+ await context.writeBuildArtifact('config.json', serializer.serializeToString(components.config ?? {}, {
18
+ space: 2
19
+ }));
17
20
  }
18
21
  export default writeConfig;
@@ -12,14 +12,16 @@
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 writeConnections({ components , context }) {
15
+ */ import { type, serializer } from '@lowdefy/helpers';
16
+ async function writeConnections({ components, context }) {
17
17
  if (type.isNone(components.connections)) return;
18
18
  if (!type.isArray(components.connections)) {
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(`connections/${connection.connectionId}.json`, JSON.stringify(connection, null, 2));
22
+ await context.writeBuildArtifact(`connections/${connection.connectionId}.json`, serializer.serializeToString(connection, {
23
+ space: 2
24
+ }));
23
25
  });
24
26
  return Promise.all(writePromises);
25
27
  }
@@ -12,14 +12,16 @@
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 writeGlobal({ components , context }) {
15
+ */ import { type, serializer } from '@lowdefy/helpers';
16
+ async function writeGlobal({ components, context }) {
17
17
  if (type.isNone(components.global)) {
18
18
  components.global = {};
19
19
  }
20
20
  if (!type.isObject(components.global)) {
21
21
  throw new Error('Global is not an object.');
22
22
  }
23
- await context.writeBuildArtifact('global.json', JSON.stringify(components.global, null, 2));
23
+ await context.writeBuildArtifact('global.json', serializer.serializeToString(components.global, {
24
+ space: 2
25
+ }));
24
26
  }
25
27
  export default writeGlobal;
@@ -0,0 +1,30 @@
1
+ /*
2
+ Copyright 2020-2023 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 { serializer, type } from '@lowdefy/helpers';
16
+ async function writeMaps({ context }) {
17
+ if (!type.isObject(context.keyMap)) {
18
+ throw new Error('keyMap is not an object.');
19
+ }
20
+ if (!type.isObject(context.refMap)) {
21
+ throw new Error('refMap is not an object.');
22
+ }
23
+ await context.writeBuildArtifact('keyMap.json', serializer.serializeToString(context.keyMap, {
24
+ space: 0
25
+ }));
26
+ await context.writeBuildArtifact('refMap.json', serializer.serializeToString(context.refMap, {
27
+ space: 0
28
+ }));
29
+ }
30
+ export default writeMaps;
@@ -12,11 +12,13 @@
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 writeMenus({ components , context }) {
15
+ */ import { type, serializer } from '@lowdefy/helpers';
16
+ 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('menus.json', JSON.stringify(components.menus, null, 2));
20
+ await context.writeBuildArtifact('menus.json', serializer.serializeToString(components.menus, {
21
+ space: 2
22
+ }));
21
23
  }
22
24
  export default writeMenus;
@@ -12,10 +12,13 @@
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
- */ async function writePage({ page , context }) {
16
- await context.writeBuildArtifact(`pages/${page.pageId}/${page.pageId}.json`, JSON.stringify(page, null, 2));
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function writePage({ page, context }) {
17
+ await context.writeBuildArtifact(`pages/${page.pageId}/${page.pageId}.json`, serializer.serializeToString(page ?? {}, {
18
+ space: 2
19
+ }));
17
20
  }
18
- async function writePages({ components , context }) {
21
+ async function writePages({ components, context }) {
19
22
  const writePromises = components.pages.map((page)=>writePage({
20
23
  page,
21
24
  context
@@ -21,7 +21,7 @@ export default {
21
21
  {{ import.typeName }},
22
22
  {% endfor -%}
23
23
  };`;
24
- function generateImportFile({ imports , importPath }) {
24
+ function generateImportFile({ imports, importPath }) {
25
25
  const templateFn = nunjucksFunction(template);
26
26
  return templateFn({
27
27
  imports,
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
- async function writeActionImports({ components , context }) {
16
+ async function writeActionImports({ components, context }) {
17
17
  await context.writeBuildArtifact('plugins/actions.js', generateImportFile({
18
18
  imports: components.imports.actions,
19
19
  importPath: 'actions'
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
- async function writeAuthImports({ components , context }) {
16
+ async function writeAuthImports({ components, context }) {
17
17
  await context.writeBuildArtifact('plugins/auth/adapters.js', generateImportFile({
18
18
  imports: components.imports.auth.adapters,
19
19
  importPath: 'auth/adapters'
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
- async function writeBlockImports({ components , context }) {
16
+ async function writeBlockImports({ components, context }) {
17
17
  await context.writeBuildArtifact('plugins/blocks.js', generateImportFile({
18
18
  imports: components.imports.blocks,
19
19
  importPath: 'blocks'
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
- async function writeConnectionImports({ components , context }) {
16
+ async function writeConnectionImports({ components, context }) {
17
17
  await context.writeBuildArtifact('plugins/connections.js', generateImportFile({
18
18
  imports: components.imports.connections,
19
19
  importPath: 'connections'
@@ -22,7 +22,7 @@ export default {
22
22
  {{ icon }},{% endfor %}
23
23
  {%- endfor %}
24
24
  };`;
25
- async function writeIconImports({ components , context }) {
25
+ async function writeIconImports({ components, context }) {
26
26
  const templateFn = nunjucksFunction(template);
27
27
  await context.writeBuildArtifact('plugins/icons.js', templateFn({
28
28
  packages: components.imports.icons
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import generateImportFile from './generateImportFile.js';
16
- async function writeOperatorImports({ components , context }) {
16
+ async function writeOperatorImports({ components, context }) {
17
17
  await context.writeBuildArtifact('plugins/operators/client.js', generateImportFile({
18
18
  imports: components.imports.operators.client,
19
19
  importPath: 'operators/client'
@@ -19,7 +19,7 @@ import writeConnectionImports from './writeConnectionImports.js';
19
19
  import writeIconImports from './writeIconImports.js';
20
20
  import writeOperatorImports from './writeOperatorImports.js';
21
21
  import writeStyleImports from './writeStyleImports.js';
22
- async function writePluginImports({ components , context }) {
22
+ async function writePluginImports({ components, context }) {
23
23
  await writeActionImports({
24
24
  components,
25
25
  context
@@ -24,7 +24,7 @@ const template = `@import '@lowdefy/layout/style.less';
24
24
  @import '../../public/styles.less';
25
25
  {% endif %}
26
26
  `;
27
- async function writeStyleImports({ components , context }) {
27
+ async function writeStyleImports({ components, context }) {
28
28
  const templateFn = nunjucksFunction(template);
29
29
  await context.writeBuildArtifact('plugins/styles.less', templateFn({
30
30
  styles: components.imports.styles,
@@ -12,16 +12,19 @@
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
- */ async function writeRequestsOnPage({ page , context }) {
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function writeRequestsOnPage({ page, context }) {
16
17
  return Promise.all(page.requests.map(async (request)=>{
17
- await context.writeBuildArtifact(`pages/${page.pageId}/requests/${request.requestId}.json`, JSON.stringify(request, null, 2));
18
+ await context.writeBuildArtifact(`pages/${page.pageId}/requests/${request.requestId}.json`, serializer.serializeToString(request ?? {}, {
19
+ space: 2
20
+ }));
18
21
  delete request.properties;
19
22
  delete request.type;
20
23
  delete request.connectionId;
21
24
  delete request.auth;
22
25
  }));
23
26
  }
24
- async function writeRequests({ components , context }) {
27
+ async function writeRequests({ components, context }) {
25
28
  const writePromises = components.pages.map((page)=>writeRequestsOnPage({
26
29
  page,
27
30
  context
@@ -12,7 +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
- */ async function writeTypes({ components , context }) {
16
- await context.writeBuildArtifact('types.json', JSON.stringify(components.types, null, 2));
15
+ */ import { serializer } from '@lowdefy/helpers';
16
+ async function writeTypes({ components, context }) {
17
+ await context.writeBuildArtifact('types.json', serializer.serializeToString(components.types ?? {}, {
18
+ space: 2
19
+ }));
17
20
  }
18
21
  export default writeTypes;
@@ -17,13 +17,15 @@ import createCounter from './utils/createCounter.js';
17
17
  import createReadConfigFile from './utils/readConfigFile.js';
18
18
  import createWriteBuildArtifact from './utils/writeBuildArtifact.js';
19
19
  import defaultTypesMap from './defaultTypesMap.js';
20
- function createContext({ customTypesMap , directories , logger , refResolver , stage ='prod' }) {
20
+ function createContext({ customTypesMap, directories, logger, refResolver, stage = 'prod' }) {
21
21
  const context = {
22
22
  directories,
23
+ keyMap: {},
23
24
  logger,
24
25
  readConfigFile: createReadConfigFile({
25
26
  directories
26
27
  }),
28
+ refMap: {},
27
29
  refResolver,
28
30
  stage,
29
31
  typeCounters: {