@lowdefy/build 4.0.0-alpha.6 → 4.0.0-alpha.7

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 (40) hide show
  1. package/dist/build/addDefaultPages/addDefaultPages.js +6 -2
  2. package/dist/build/buildPages/buildBlock/buildEvents.js +4 -1
  3. package/dist/build/buildRefs/getUserJavascriptFunction.js +6 -3
  4. package/dist/build/buildRefs/parseRefContent.js +2 -2
  5. package/dist/build/buildRefs/runTransformer.js +5 -1
  6. package/dist/build/buildTypes.js +23 -14
  7. package/dist/build/cleanBuildDirectory.js +1 -1
  8. package/dist/build/copyPublicFolder.js +23 -0
  9. package/dist/build/updateServerPackageJson.js +1 -4
  10. package/dist/build/validateConfig.js +5 -0
  11. package/dist/build/writeApp.js +1 -4
  12. package/dist/build/writeConfig.js +1 -4
  13. package/dist/build/writeConnections.js +1 -4
  14. package/dist/build/writeGlobal.js +1 -4
  15. package/dist/build/writeMenus.js +1 -4
  16. package/dist/build/writePages.js +2 -13
  17. package/dist/build/writePluginImports/writeActionImports.js +22 -0
  18. package/dist/build/writePluginImports/writeBlockImports.js +4 -7
  19. package/dist/build/writePluginImports/writeConnectionImports.js +4 -7
  20. package/dist/build/writePluginImports/writeIconImports.js +3 -6
  21. package/dist/build/writePluginImports/writeOperatorImports.js +8 -15
  22. package/dist/build/writePluginImports/writeStyleImports.js +3 -6
  23. package/dist/build/writeRequests.js +2 -7
  24. package/dist/build/writeTypes.js +1 -4
  25. package/dist/defaultTypes.json +543 -243
  26. package/dist/index.js +118 -113
  27. package/dist/lowdefySchema.js +7 -0
  28. package/dist/scripts/generateDefaultTypes.js +11 -7
  29. package/dist/scripts/run.js +7 -3
  30. package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +1 -1
  31. package/dist/test/buildRefs/testBuildRefsErrorResolver.js +1 -1
  32. package/dist/test/buildRefs/testBuildRefsNullResolver.js +1 -1
  33. package/dist/test/buildRefs/testBuildRefsParsingResolver.js +1 -1
  34. package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
  35. package/dist/test/buildRefs/testBuildRefsTransform.js +1 -1
  36. package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +1 -1
  37. package/dist/utils/formatErrorMessage.js +1 -1
  38. package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +0 -0
  39. package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +2 -5
  40. package/package.json +36 -27
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@
14
14
  limitations under the License.
15
15
  */ import { readFile } from '@lowdefy/node-utils';
16
16
  import createCounter from './utils/createCounter.js';
17
- import createReadConfigFile from './utils/files/readConfigFile.js';
18
- import createWriteBuildArtifact from './utils/files/writeBuildArtifact.js';
17
+ import createReadConfigFile from './utils/readConfigFile.js';
18
+ import createWriteBuildArtifact from './utils/writeBuildArtifact.js';
19
19
  import addDefaultPages from './build/addDefaultPages/addDefaultPages.js';
20
20
  import buildAuth from './build/buildAuth/buildAuth.js';
21
21
  import buildConnections from './build/buildConnections.js';
@@ -26,11 +26,13 @@ import buildRefs from './build/buildRefs/buildRefs.js';
26
26
  import buildStyles from './build/buildStyles.js';
27
27
  import buildTypes from './build/buildTypes.js';
28
28
  import cleanBuildDirectory from './build/cleanBuildDirectory.js';
29
+ import copyPublicFolder from './build/copyPublicFolder.js';
29
30
  import testSchema from './build/testSchema.js';
30
31
  import validateApp from './build/validateApp.js';
31
32
  import validateConfig from './build/validateConfig.js';
32
33
  import updateServerPackageJson from './build/updateServerPackageJson.js';
33
34
  import writeApp from './build/writeApp.js';
35
+ import writeActionImports from './build/writePluginImports/writeActionImports.js';
34
36
  import writeBlockImports from './build/writePluginImports/writeBlockImports.js';
35
37
  import writeConfig from './build/writeConfig.js';
36
38
  import writeConnectionImports from './build/writePluginImports/writeConnectionImports.js';
@@ -73,117 +75,120 @@ async function createContext(options) {
73
75
  }
74
76
  async function build(options) {
75
77
  const context = await createContext(options);
76
- try {
77
- const components = await buildRefs({
78
- context
79
- });
80
- await testSchema({
81
- components,
82
- context
83
- });
84
- await validateApp({
85
- components,
86
- context
87
- });
88
- await validateConfig({
89
- components,
90
- context
91
- });
92
- await addDefaultPages({
93
- components,
94
- context
95
- });
96
- await buildAuth({
97
- components,
98
- context
99
- });
100
- await buildConnections({
101
- components,
102
- context
103
- });
104
- await buildPages({
105
- components,
106
- context
107
- });
108
- await buildMenu({
109
- components,
110
- context
111
- });
112
- await buildTypes({
113
- components,
114
- context
115
- });
116
- await buildIcons({
117
- components,
118
- context
119
- });
120
- await buildStyles({
121
- components,
122
- context
123
- });
124
- await cleanBuildDirectory({
125
- context
126
- });
127
- await writeApp({
128
- components,
129
- context
130
- });
131
- await writeConnections({
132
- components,
133
- context
134
- });
135
- await writeRequests({
136
- components,
137
- context
138
- });
139
- await writePages({
140
- components,
141
- context
142
- });
143
- await writeConfig({
144
- components,
145
- context
146
- });
147
- await writeGlobal({
148
- components,
149
- context
150
- });
151
- await writeMenus({
152
- components,
153
- context
154
- });
155
- await writeTypes({
156
- components,
157
- context
158
- });
159
- await writeBlockImports({
160
- components,
161
- context
162
- });
163
- await writeConnectionImports({
164
- components,
165
- context
166
- });
167
- await writeOperatorImports({
168
- components,
169
- context
170
- });
171
- await writeStyleImports({
172
- components,
173
- context
174
- });
175
- await writeIconImports({
176
- components,
177
- context
178
- });
179
- await updateServerPackageJson({
180
- components,
181
- context
182
- });
183
- } catch (error) {
184
- context.logger.error(error);
185
- throw error;
186
- }
78
+ const components = await buildRefs({
79
+ context
80
+ });
81
+ await testSchema({
82
+ components,
83
+ context
84
+ });
85
+ await validateApp({
86
+ components,
87
+ context
88
+ });
89
+ await validateConfig({
90
+ components,
91
+ context
92
+ });
93
+ await addDefaultPages({
94
+ components,
95
+ context
96
+ });
97
+ await buildAuth({
98
+ components,
99
+ context
100
+ });
101
+ await buildConnections({
102
+ components,
103
+ context
104
+ });
105
+ await buildPages({
106
+ components,
107
+ context
108
+ });
109
+ await buildMenu({
110
+ components,
111
+ context
112
+ });
113
+ await buildTypes({
114
+ components,
115
+ context
116
+ });
117
+ await buildIcons({
118
+ components,
119
+ context
120
+ });
121
+ await buildStyles({
122
+ components,
123
+ context
124
+ });
125
+ await cleanBuildDirectory({
126
+ context
127
+ });
128
+ await writeActionImports({
129
+ components,
130
+ context
131
+ });
132
+ await writeApp({
133
+ components,
134
+ context
135
+ });
136
+ await writeConnections({
137
+ components,
138
+ context
139
+ });
140
+ await writeRequests({
141
+ components,
142
+ context
143
+ });
144
+ await writePages({
145
+ components,
146
+ context
147
+ });
148
+ await writeConfig({
149
+ components,
150
+ context
151
+ });
152
+ await writeGlobal({
153
+ components,
154
+ context
155
+ });
156
+ await writeMenus({
157
+ components,
158
+ context
159
+ });
160
+ await writeTypes({
161
+ components,
162
+ context
163
+ });
164
+ await writeBlockImports({
165
+ components,
166
+ context
167
+ });
168
+ await writeConnectionImports({
169
+ components,
170
+ context
171
+ });
172
+ await writeOperatorImports({
173
+ components,
174
+ context
175
+ });
176
+ await writeStyleImports({
177
+ components,
178
+ context
179
+ });
180
+ await writeIconImports({
181
+ components,
182
+ context
183
+ });
184
+ await updateServerPackageJson({
185
+ components,
186
+ context
187
+ });
188
+ await copyPublicFolder({
189
+ components,
190
+ context
191
+ });
187
192
  }
188
193
  export { createContext };
189
194
  export default build;
@@ -628,6 +628,13 @@ export default {
628
628
  auth: {
629
629
  $ref: '#/definitions/authConfig'
630
630
  },
631
+ basePath: {
632
+ type: 'string',
633
+ description: 'App base path to apply to all routes. Base path must start with "/".',
634
+ errorMessage: {
635
+ type: 'App "config.basePath" should be a string.'
636
+ }
637
+ },
631
638
  homePageId: {
632
639
  type: 'string',
633
640
  description: 'Page id to use as homepage. When visiting home route "/", the router will redirect to this page. If not provided, the first page in default or first menu will be used as the homePageId.',
@@ -17,18 +17,25 @@
17
17
  import { type } from '@lowdefy/helpers';
18
18
  import { readFile, writeFile } from '@lowdefy/node-utils';
19
19
  const defaultPackages = [
20
+ '@lowdefy/actions-core',
20
21
  '@lowdefy/blocks-antd',
21
22
  '@lowdefy/blocks-basic',
22
- // '@lowdefy/blocks-color-selectors',
23
+ '@lowdefy/blocks-color-selectors',
23
24
  '@lowdefy/blocks-echarts',
24
25
  '@lowdefy/blocks-loaders',
25
26
  '@lowdefy/blocks-markdown',
26
27
  '@lowdefy/connection-axios-http',
28
+ '@lowdefy/connection-elasticsearch',
29
+ '@lowdefy/connection-google-sheets',
30
+ '@lowdefy/connection-knex',
31
+ '@lowdefy/connection-mongodb',
27
32
  '@lowdefy/connection-redis',
33
+ '@lowdefy/connection-sendgrid',
34
+ '@lowdefy/connection-stripe',
28
35
  '@lowdefy/operators-change-case',
29
- // '@lowdefy/operators-diff',
36
+ '@lowdefy/operators-diff',
30
37
  '@lowdefy/operators-js',
31
- // '@lowdefy/operators-mql',
38
+ '@lowdefy/operators-mql',
32
39
  '@lowdefy/operators-nunjucks',
33
40
  '@lowdefy/operators-uuid',
34
41
  '@lowdefy/operators-yaml',
@@ -103,9 +110,6 @@ async function generateDefaultTypes() {
103
110
  defaultTypes.icons[packageName] = types.icons;
104
111
  }
105
112
  }));
106
- await writeFile({
107
- filePath: path.resolve(process.cwd(), './dist/defaultTypes.json'),
108
- content: JSON.stringify(defaultTypes, null, 2)
109
- });
113
+ await writeFile(path.resolve(process.cwd(), './dist/defaultTypes.json'), JSON.stringify(defaultTypes, null, 2));
110
114
  }
111
115
  generateDefaultTypes();
@@ -14,14 +14,18 @@
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  */ import path from 'path';
17
+ import yargs from 'yargs';
18
+ import { hideBin } from 'yargs/helpers';
17
19
  import build from '../index.js';
20
+ const argv = yargs(hideBin(process.argv)).argv;
18
21
  async function run() {
19
22
  await build({
20
23
  logger: console,
24
+ refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
21
25
  directories: {
22
- build: path.resolve(process.env.LOWDEFY_DIRECTORY_BUILD || path.join(process.cwd(), 'build')),
23
- config: path.resolve(process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
24
- server: path.resolve(process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd())
26
+ build: path.resolve(argv.buildDirectory || process.env.LOWDEFY_DIRECTORY_BUILD || path.join(process.cwd(), 'build')),
27
+ config: path.resolve(argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
28
+ server: path.resolve(argv.serverDirectory || process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd())
25
29
  }
26
30
  });
27
31
  }
@@ -19,4 +19,4 @@ async function asyncFn() {
19
19
  async: true
20
20
  };
21
21
  }
22
- module.exports = asyncFn;
22
+ export default asyncFn;
@@ -15,4 +15,4 @@
15
15
  */ function resolver() {
16
16
  throw new Error('Test error');
17
17
  }
18
- module.exports = resolver;
18
+ export default resolver;
@@ -16,4 +16,4 @@
16
16
  if (path === 'null') return null;
17
17
  return undefined;
18
18
  }
19
- module.exports = resolver;
19
+ export default resolver;
@@ -36,4 +36,4 @@ array:
36
36
  return null;
37
37
  }
38
38
  }
39
- module.exports = resolver;
39
+ export default resolver;
@@ -20,4 +20,4 @@
20
20
  contextId: context.id
21
21
  };
22
22
  }
23
- module.exports = resolver;
23
+ export default resolver;
@@ -22,4 +22,4 @@ function transformer(obj, vars) {
22
22
  var: vars.var1
23
23
  };
24
24
  }
25
- module.exports = transformer;
25
+ export default transformer;
@@ -18,4 +18,4 @@
18
18
  vars
19
19
  };
20
20
  }
21
- module.exports = transformer;
21
+ export default transformer;
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { get, type } from '@lowdefy/helpers';
16
16
  function formatArrayKey({ index , object }) {
17
- if (!type.isNone(object.id) || !type.isNone(object.type)) {
17
+ if (type.isObject(object) && (!type.isNone(object.id) || !type.isNone(object.type))) {
18
18
  const objectId = type.isNone(object.id) ? '_ERROR_MISSING_ID_' : object.id;
19
19
  const objectType = type.isNone(object.type) ? '_ERROR_MISSING_TYPE_' : object.type;
20
20
  return `[${index}:${objectId}:${objectType}]`;
@@ -15,11 +15,8 @@
15
15
  */ import path from 'path';
16
16
  import { writeFile } from '@lowdefy/node-utils';
17
17
  function createWriteBuildArtifact({ directories }) {
18
- async function writeBuildArtifact({ filePath , content }) {
19
- return writeFile({
20
- filePath: path.resolve(directories.build, filePath),
21
- content
22
- });
18
+ async function writeBuildArtifact(filePath, content) {
19
+ await writeFile(path.join(directories.build, filePath), content);
23
20
  }
24
21
  return writeBuildArtifact;
25
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/build",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.7",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,41 +42,50 @@
42
42
  "prepare": "yarn build",
43
43
  "start": "node dist/scripts/run.js",
44
44
  "swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
45
- "test": "jest --coverage"
45
+ "test": "yarn node --experimental-vm-modules $(yarn bin jest)"
46
46
  },
47
47
  "dependencies": {
48
- "@lowdefy/ajv": "4.0.0-alpha.6",
49
- "@lowdefy/helpers": "4.0.0-alpha.6",
50
- "@lowdefy/node-utils": "4.0.0-alpha.6",
51
- "@lowdefy/nunjucks": "4.0.0-alpha.6",
52
- "ajv": "8.8.2",
53
- "js-yaml": "4.1.0",
48
+ "@lowdefy/ajv": "4.0.0-alpha.7",
49
+ "@lowdefy/helpers": "4.0.0-alpha.7",
50
+ "@lowdefy/node-utils": "4.0.0-alpha.7",
51
+ "@lowdefy/nunjucks": "4.0.0-alpha.7",
52
+ "ajv": "8.9.0",
54
53
  "json5": "2.2.0",
55
- "uuid": "8.3.2"
54
+ "uuid": "8.3.2",
55
+ "yaml": "2.0.0-10",
56
+ "yargs": "17.3.1"
56
57
  },
57
58
  "devDependencies": {
58
- "@lowdefy/blocks-antd": "4.0.0-alpha.6",
59
- "@lowdefy/blocks-basic": "4.0.0-alpha.6",
60
- "@lowdefy/blocks-color-selectors": "4.0.0-alpha.6",
61
- "@lowdefy/blocks-echarts": "4.0.0-alpha.6",
62
- "@lowdefy/blocks-loaders": "4.0.0-alpha.6",
63
- "@lowdefy/blocks-markdown": "4.0.0-alpha.6",
64
- "@lowdefy/connection-axios-http": "4.0.0-alpha.6",
65
- "@lowdefy/connection-redis": "4.0.0-alpha.6",
66
- "@lowdefy/operators-change-case": "4.0.0-alpha.6",
67
- "@lowdefy/operators-diff": "4.0.0-alpha.6",
68
- "@lowdefy/operators-js": "4.0.0-alpha.6",
69
- "@lowdefy/operators-mql": "4.0.0-alpha.6",
70
- "@lowdefy/operators-nunjucks": "4.0.0-alpha.6",
71
- "@lowdefy/operators-uuid": "4.0.0-alpha.6",
72
- "@lowdefy/operators-yaml": "4.0.0-alpha.6",
59
+ "@jest/globals": "27.5.1",
60
+ "@lowdefy/actions-core": "4.0.0-alpha.7",
61
+ "@lowdefy/blocks-antd": "4.0.0-alpha.7",
62
+ "@lowdefy/blocks-basic": "4.0.0-alpha.7",
63
+ "@lowdefy/blocks-color-selectors": "4.0.0-alpha.7",
64
+ "@lowdefy/blocks-echarts": "4.0.0-alpha.7",
65
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.7",
66
+ "@lowdefy/blocks-markdown": "4.0.0-alpha.7",
67
+ "@lowdefy/connection-axios-http": "4.0.0-alpha.7",
68
+ "@lowdefy/connection-elasticsearch": "4.0.0-alpha.7",
69
+ "@lowdefy/connection-google-sheets": "4.0.0-alpha.7",
70
+ "@lowdefy/connection-knex": "4.0.0-alpha.7",
71
+ "@lowdefy/connection-mongodb": "4.0.0-alpha.7",
72
+ "@lowdefy/connection-redis": "4.0.0-alpha.7",
73
+ "@lowdefy/connection-sendgrid": "4.0.0-alpha.7",
74
+ "@lowdefy/connection-stripe": "4.0.0-alpha.7",
75
+ "@lowdefy/operators-change-case": "4.0.0-alpha.7",
76
+ "@lowdefy/operators-diff": "4.0.0-alpha.7",
77
+ "@lowdefy/operators-js": "4.0.0-alpha.7",
78
+ "@lowdefy/operators-mql": "4.0.0-alpha.7",
79
+ "@lowdefy/operators-nunjucks": "4.0.0-alpha.7",
80
+ "@lowdefy/operators-uuid": "4.0.0-alpha.7",
81
+ "@lowdefy/operators-yaml": "4.0.0-alpha.7",
73
82
  "@swc/cli": "0.1.55",
74
- "@swc/core": "1.2.130",
83
+ "@swc/core": "1.2.135",
75
84
  "@swc/jest": "0.2.17",
76
- "jest": "27.3.1"
85
+ "jest": "27.5.1"
77
86
  },
78
87
  "publishConfig": {
79
88
  "access": "public"
80
89
  },
81
- "gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
90
+ "gitHead": "52ec14639d00de910cf9b8ab25bf933ca891cff5"
82
91
  }