@lowdefy/build 4.0.0-alpha.10 → 4.0.0-alpha.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 (32) hide show
  1. package/dist/build/buildAuth/buildAuth.js +9 -28
  2. package/dist/build/buildAuth/buildAuthPlugins.js +78 -0
  3. package/dist/build/buildAuth/buildPageAuth.js +50 -0
  4. package/dist/build/buildAuth/getPageRoles.js +1 -1
  5. package/dist/build/buildAuth/getProtectedPages.js +5 -5
  6. package/dist/build/buildAuth/validateAuthConfig.js +61 -0
  7. package/dist/build/{buildIcons.js → buildImports/buildIconImports.js} +9 -8
  8. package/dist/build/buildImports/buildImports.js +30 -0
  9. package/dist/build/buildImports/buildImportsDev.js +101 -0
  10. package/dist/build/buildImports/buildImportsProd.js +52 -0
  11. package/dist/build/{buildStyles.js → buildImports/buildStyleImports.js} +5 -6
  12. package/dist/build/buildTypes.js +23 -0
  13. package/dist/build/testSchema.js +2 -3
  14. package/dist/build/updateServerPackageJson.js +3 -0
  15. package/dist/build/validateConfig.js +0 -24
  16. package/dist/build/writeAuth.js +18 -0
  17. package/dist/build/writePluginImports/generateImportFile.js +1 -6
  18. package/dist/build/writePluginImports/writeActionImports.js +1 -1
  19. package/dist/build/writePluginImports/writeAuthImports.js +30 -0
  20. package/dist/build/writePluginImports/writeBlockImports.js +1 -1
  21. package/dist/build/writePluginImports/writeConnectionImports.js +1 -1
  22. package/dist/build/writePluginImports/writeIconImports.js +1 -1
  23. package/dist/build/writePluginImports/writeOperatorImports.js +4 -4
  24. package/dist/build/writePluginImports/writePluginImports.js +52 -0
  25. package/dist/build/writePluginImports/writeStyleImports.js +1 -1
  26. package/dist/defaultTypesMap.json +503 -227
  27. package/dist/index.js +17 -35
  28. package/dist/lowdefySchema.js +104 -58
  29. package/dist/scripts/generateDefaultTypes.js +7 -1
  30. package/dist/scripts/run.js +4 -3
  31. package/dist/utils/createPluginTypesMap.js +21 -0
  32. package/package.json +30 -29
package/dist/index.js CHANGED
@@ -12,7 +12,8 @@
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 { mergeObjects } from '@lowdefy/helpers';
15
+ */ import { fileURLToPath } from 'url';
16
+ import { mergeObjects } from '@lowdefy/helpers';
16
17
  import { readFile } from '@lowdefy/node-utils';
17
18
  import createCounter from './utils/createCounter.js';
18
19
  import createPluginTypesMap from './utils/createPluginTypesMap.js';
@@ -21,11 +22,10 @@ import createWriteBuildArtifact from './utils/writeBuildArtifact.js';
21
22
  import addDefaultPages from './build/addDefaultPages/addDefaultPages.js';
22
23
  import buildAuth from './build/buildAuth/buildAuth.js';
23
24
  import buildConnections from './build/buildConnections.js';
24
- import buildIcons from './build/buildIcons.js';
25
+ import buildImports from './build/buildImports/buildImports.js';
25
26
  import buildMenu from './build/buildMenu.js';
26
27
  import buildPages from './build/buildPages/buildPages.js';
27
28
  import buildRefs from './build/buildRefs/buildRefs.js';
28
- import buildStyles from './build/buildStyles.js';
29
29
  import buildTypes from './build/buildTypes.js';
30
30
  import cleanBuildDirectory from './build/cleanBuildDirectory.js';
31
31
  import copyPublicFolder from './build/copyPublicFolder.js';
@@ -34,21 +34,17 @@ import validateApp from './build/validateApp.js';
34
34
  import validateConfig from './build/validateConfig.js';
35
35
  import updateServerPackageJson from './build/updateServerPackageJson.js';
36
36
  import writeApp from './build/writeApp.js';
37
- import writeActionImports from './build/writePluginImports/writeActionImports.js';
38
- import writeBlockImports from './build/writePluginImports/writeBlockImports.js';
37
+ import writeAuth from './build/writeAuth.js';
38
+ import writePluginImports from './build/writePluginImports/writePluginImports.js';
39
39
  import writeConfig from './build/writeConfig.js';
40
- import writeConnectionImports from './build/writePluginImports/writeConnectionImports.js';
41
40
  import writeConnections from './build/writeConnections.js';
42
41
  import writeGlobal from './build/writeGlobal.js';
43
- import writeIconImports from './build/writePluginImports/writeIconImports.js';
44
42
  import writeMenus from './build/writeMenus.js';
45
- import writeOperatorImports from './build/writePluginImports/writeOperatorImports.js';
46
43
  import writePages from './build/writePages.js';
47
44
  import writeRequests from './build/writeRequests.js';
48
- import writeStyleImports from './build/writePluginImports/writeStyleImports.js';
49
45
  import writeTypes from './build/writeTypes.js';
50
- async function createContext({ customTypesMap , directories , logger , refResolver }) {
51
- const defaultTypesMap = JSON.parse(await readFile(new URL('./defaultTypesMap.json', import.meta.url).pathname));
46
+ async function createContext({ customTypesMap , directories , logger , refResolver , stage ='prod' }) {
47
+ const defaultTypesMap = JSON.parse(await readFile(fileURLToPath(new URL('./defaultTypesMap.json', import.meta.url))));
52
48
  const context = {
53
49
  directories,
54
50
  logger,
@@ -56,8 +52,14 @@ async function createContext({ customTypesMap , directories , logger , refResolv
56
52
  directories
57
53
  }),
58
54
  refResolver,
55
+ stage,
59
56
  typeCounters: {
60
57
  actions: createCounter(),
58
+ auth: {
59
+ callbacks: createCounter(),
60
+ events: createCounter(),
61
+ providers: createCounter()
62
+ },
61
63
  blocks: createCounter(),
62
64
  connections: createCounter(),
63
65
  requests: createCounter(),
@@ -117,22 +119,18 @@ async function build(options) {
117
119
  components,
118
120
  context
119
121
  });
120
- await buildIcons({
121
- components,
122
- context
123
- });
124
- await buildStyles({
122
+ await buildImports({
125
123
  components,
126
124
  context
127
125
  });
128
126
  await cleanBuildDirectory({
129
127
  context
130
128
  });
131
- await writeActionImports({
129
+ await writeApp({
132
130
  components,
133
131
  context
134
132
  });
135
- await writeApp({
133
+ await writeAuth({
136
134
  components,
137
135
  context
138
136
  });
@@ -164,23 +162,7 @@ async function build(options) {
164
162
  components,
165
163
  context
166
164
  });
167
- await writeBlockImports({
168
- components,
169
- context
170
- });
171
- await writeConnectionImports({
172
- components,
173
- context
174
- });
175
- await writeOperatorImports({
176
- components,
177
- context
178
- });
179
- await writeStyleImports({
180
- components,
181
- context
182
- });
183
- await writeIconImports({
165
+ await writePluginImports({
184
166
  components,
185
167
  context
186
168
  });
@@ -72,36 +72,73 @@ export default {
72
72
  type: 'object',
73
73
  additionalProperties: false,
74
74
  errorMessage: {
75
- type: 'App "config.auth" should be an object.'
75
+ type: 'App "auth" should be an object.'
76
76
  },
77
77
  properties: {
78
- openId: {
79
- type: 'object',
80
- additionalProperties: false,
81
- errorMessage: {
82
- type: 'App "config.auth.openId" should be an object.'
83
- },
84
- properties: {
85
- rolesField: {
86
- type: 'string',
87
- description: '.',
88
- errorMessage: {
89
- type: 'App "config.auth.openId.rolesField" should be a string.'
78
+ callbacks: {
79
+ type: 'array',
80
+ items: {
81
+ type: 'object',
82
+ required: [
83
+ 'id',
84
+ 'type'
85
+ ],
86
+ properties: {
87
+ id: {
88
+ type: 'string',
89
+ errorMessage: {
90
+ type: 'Auth callback "id" should be a string.'
91
+ }
92
+ },
93
+ type: {
94
+ type: 'string',
95
+ errorMessage: {
96
+ type: 'Auth callback "type" should be a string.'
97
+ }
98
+ },
99
+ properties: {
100
+ type: 'object'
90
101
  }
91
102
  },
92
- logoutRedirectUri: {
93
- type: 'string',
94
- description: 'The URI to redirect the user to after logout. Can be a Nunjucks template string with client_id, host, id_token_hint, and openid_domain as template data.',
95
- errorMessage: {
96
- type: 'App "config.auth.openId.logoutRedirectUri" should be a string.'
103
+ errorMessage: {
104
+ type: 'Auth callback should be an object.',
105
+ required: {
106
+ id: 'Auth callback should have required property "id".',
107
+ type: 'Auth callback should have required property "type".'
108
+ }
109
+ }
110
+ }
111
+ },
112
+ events: {
113
+ type: 'array',
114
+ items: {
115
+ type: 'object',
116
+ required: [
117
+ 'id',
118
+ 'type'
119
+ ],
120
+ properties: {
121
+ id: {
122
+ type: 'string',
123
+ errorMessage: {
124
+ type: 'Auth event "id" should be a string.'
125
+ }
126
+ },
127
+ type: {
128
+ type: 'string',
129
+ errorMessage: {
130
+ type: 'Auth event "type" should be a string.'
131
+ }
132
+ },
133
+ properties: {
134
+ type: 'object'
97
135
  }
98
136
  },
99
- scope: {
100
- type: 'string',
101
- description: 'The OpenID Connect scope to request.',
102
- default: 'openid profile email',
103
- errorMessage: {
104
- type: 'App "config.auth.openId.scope" should be a string.'
137
+ errorMessage: {
138
+ type: 'Auth event should be an object.',
139
+ required: {
140
+ id: 'Auth event should have required property "id".',
141
+ type: 'Auth event should have required property "type".'
105
142
  }
106
143
  }
107
144
  }
@@ -119,13 +156,13 @@ export default {
119
156
  'boolean'
120
157
  ],
121
158
  errorMessage: {
122
- type: 'App "config.auth.pages.protected.$" should be an array of strings.'
159
+ type: 'App "auth.pages.protected.$" should be an array of strings.'
123
160
  },
124
161
  items: {
125
162
  type: 'string',
126
163
  description: 'Page ids for which authentication is required. When specified, all unspecified pages will be public.',
127
164
  errorMessage: {
128
- type: 'App "config.auth.pages.protected.$" should be an array of strings.'
165
+ type: 'App "auth.pages.protected.$" should be an array of strings.'
129
166
  }
130
167
  }
131
168
  },
@@ -135,13 +172,13 @@ export default {
135
172
  'boolean'
136
173
  ],
137
174
  errorMessage: {
138
- type: 'App "config.auth.pages.public.$" should be an array of strings.'
175
+ type: 'App "auth.pages.public.$" should be an array of strings.'
139
176
  },
140
177
  items: {
141
178
  type: 'string',
142
179
  description: 'Page ids for which authentication is not required. When specified, all unspecified pages will be protected.',
143
180
  errorMessage: {
144
- type: 'App "config.auth.pages.public.$" should be an array of strings.'
181
+ type: 'App "auth.pages.public.$" should be an array of strings.'
145
182
  }
146
183
  }
147
184
  },
@@ -154,46 +191,55 @@ export default {
154
191
  type: 'string'
155
192
  },
156
193
  errorMessage: {
157
- type: 'App "config.auth.pages.roles.[role]" should be an array of strings.'
194
+ type: 'App "auth.pages.roles.[role]" should be an array of strings.'
158
195
  }
159
196
  }
160
197
  },
161
198
  errorMessage: {
162
- type: 'App "config.auth.pages.roles" should be an object.'
199
+ type: 'App "auth.pages.roles" should be an object.'
163
200
  }
164
201
  }
165
202
  }
166
203
  },
167
- jwt: {
168
- type: 'object',
169
- additionalProperties: false,
170
- errorMessage: {
171
- type: 'App "config.auth.jwt" should be an object.'
172
- },
173
- properties: {
174
- expiresIn: {
175
- type: [
176
- 'string',
177
- 'number'
178
- ],
179
- default: '4h',
180
- description: 'The length of time a user token should be valid. Can be expressed as a number in seconds, or a vercel/ms string (https://github.com/vercel/ms)',
181
- errorMessage: {
182
- type: 'App "config.auth.jwt.expiresIn" should be a string or number.'
204
+ providers: {
205
+ type: 'array',
206
+ items: {
207
+ type: 'object',
208
+ required: [
209
+ 'id',
210
+ 'type'
211
+ ],
212
+ properties: {
213
+ id: {
214
+ type: 'string',
215
+ errorMessage: {
216
+ type: 'Auth provider "id" should be a string.'
217
+ }
218
+ },
219
+ type: {
220
+ type: 'string',
221
+ errorMessage: {
222
+ type: 'Auth provider "type" should be a string.'
223
+ }
224
+ },
225
+ properties: {
226
+ type: 'object'
183
227
  }
184
228
  },
185
- loginStateExpiresIn: {
186
- type: [
187
- 'string',
188
- 'number'
189
- ],
190
- default: '5min',
191
- description: 'The length of time an authorization request token should be valid. Can be expressed as a number in seconds, or a vercel/ms string (https://github.com/vercel/ms)',
192
- errorMessage: {
193
- type: 'App "config.auth.jwt.loginStateExpiresIn" should be a string or number.'
229
+ errorMessage: {
230
+ type: 'Auth provider should be an object.',
231
+ required: {
232
+ id: 'Auth provider should have required property "id".',
233
+ type: 'Auth provider should have required property "type".'
194
234
  }
195
235
  }
196
236
  }
237
+ },
238
+ session: {
239
+ type: 'object'
240
+ },
241
+ theme: {
242
+ type: 'object'
197
243
  }
198
244
  }
199
245
  },
@@ -648,6 +694,9 @@ export default {
648
694
  app: {
649
695
  $ref: '#/definitions/app'
650
696
  },
697
+ auth: {
698
+ $ref: '#/definitions/authConfig'
699
+ },
651
700
  cli: {
652
701
  type: 'object',
653
702
  errorMessage: {
@@ -661,9 +710,6 @@ export default {
661
710
  },
662
711
  additionalProperties: false,
663
712
  properties: {
664
- auth: {
665
- $ref: '#/definitions/authConfig'
666
- },
667
713
  basePath: {
668
714
  type: 'string',
669
715
  description: 'App base path to apply to all routes. Base path must start with "/".',
@@ -38,12 +38,18 @@ const defaultPackages = [
38
38
  '@lowdefy/operators-mql',
39
39
  '@lowdefy/operators-nunjucks',
40
40
  '@lowdefy/operators-uuid',
41
- '@lowdefy/operators-yaml',
41
+ '@lowdefy/operators-yaml',
42
+ '@lowdefy/plugin-next-auth',
42
43
  ];
43
44
  async function generateDefaultTypesMap() {
44
45
  const packageFile = JSON.parse(await readFile(path.resolve(process.cwd(), './package.json')));
45
46
  const defaultTypesMap = {
46
47
  actions: {},
48
+ auth: {
49
+ callbacks: {},
50
+ events: {},
51
+ providers: {}
52
+ },
47
53
  blocks: {},
48
54
  connections: {},
49
55
  icons: {},
@@ -20,13 +20,14 @@ import build from '../index.js';
20
20
  const argv = yargs(hideBin(process.argv)).argv;
21
21
  async function run() {
22
22
  await build({
23
- logger: console,
24
- refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
25
23
  directories: {
26
24
  build: path.resolve(argv.buildDirectory || process.env.LOWDEFY_DIRECTORY_BUILD || path.join(process.cwd(), 'build')),
27
25
  config: path.resolve(argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
28
26
  server: path.resolve(argv.serverDirectory || process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd())
29
- }
27
+ },
28
+ logger: console,
29
+ refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
30
+ stage: argv.stage || process.env.LOWDEFY_BUILD_STAGE || 'prod'
30
31
  });
31
32
  }
32
33
  run();
@@ -32,6 +32,27 @@ function createPluginTypesMap({ packageName , packageTypes , typePrefix ='' , ty
32
32
  typePrefix,
33
33
  version
34
34
  });
35
+ createTypeDefinitions({
36
+ typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.callbacks : [],
37
+ store: typesMap.auth.callbacks,
38
+ packageName,
39
+ typePrefix,
40
+ version
41
+ });
42
+ createTypeDefinitions({
43
+ typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.events : [],
44
+ store: typesMap.auth.events,
45
+ packageName,
46
+ typePrefix,
47
+ version
48
+ });
49
+ createTypeDefinitions({
50
+ typeNames: type.isObject(packageTypes.auth) ? packageTypes.auth.providers : [],
51
+ store: typesMap.auth.providers,
52
+ packageName,
53
+ typePrefix,
54
+ version
55
+ });
35
56
  createTypeDefinitions({
36
57
  typeNames: packageTypes.blocks,
37
58
  store: typesMap.blocks,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/build",
3
- "version": "4.0.0-alpha.10",
3
+ "version": "4.0.0-alpha.11",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -49,14 +49,14 @@
49
49
  "test": "yarn node --experimental-vm-modules $(yarn bin jest)"
50
50
  },
51
51
  "dependencies": {
52
- "@lowdefy/ajv": "4.0.0-alpha.10",
53
- "@lowdefy/blocks-basic": "4.0.0-alpha.10",
54
- "@lowdefy/blocks-loaders": "4.0.0-alpha.10",
55
- "@lowdefy/helpers": "4.0.0-alpha.10",
56
- "@lowdefy/node-utils": "4.0.0-alpha.10",
57
- "@lowdefy/nunjucks": "4.0.0-alpha.10",
58
- "@lowdefy/operators": "4.0.0-alpha.10",
59
- "@lowdefy/operators-js": "4.0.0-alpha.10",
52
+ "@lowdefy/ajv": "4.0.0-alpha.11",
53
+ "@lowdefy/blocks-basic": "4.0.0-alpha.11",
54
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.11",
55
+ "@lowdefy/helpers": "4.0.0-alpha.11",
56
+ "@lowdefy/node-utils": "4.0.0-alpha.11",
57
+ "@lowdefy/nunjucks": "4.0.0-alpha.11",
58
+ "@lowdefy/operators": "4.0.0-alpha.11",
59
+ "@lowdefy/operators-js": "4.0.0-alpha.11",
60
60
  "ajv": "8.9.0",
61
61
  "json5": "2.2.0",
62
62
  "uuid": "8.3.2",
@@ -65,25 +65,26 @@
65
65
  },
66
66
  "devDependencies": {
67
67
  "@jest/globals": "27.5.1",
68
- "@lowdefy/actions-core": "4.0.0-alpha.10",
69
- "@lowdefy/blocks-antd": "4.0.0-alpha.10",
70
- "@lowdefy/blocks-color-selectors": "4.0.0-alpha.10",
71
- "@lowdefy/blocks-echarts": "4.0.0-alpha.10",
72
- "@lowdefy/blocks-markdown": "4.0.0-alpha.10",
73
- "@lowdefy/connection-axios-http": "4.0.0-alpha.10",
74
- "@lowdefy/connection-elasticsearch": "4.0.0-alpha.10",
75
- "@lowdefy/connection-google-sheets": "4.0.0-alpha.10",
76
- "@lowdefy/connection-knex": "4.0.0-alpha.10",
77
- "@lowdefy/connection-mongodb": "4.0.0-alpha.10",
78
- "@lowdefy/connection-redis": "4.0.0-alpha.10",
79
- "@lowdefy/connection-sendgrid": "4.0.0-alpha.10",
80
- "@lowdefy/connection-stripe": "4.0.0-alpha.10",
81
- "@lowdefy/operators-change-case": "4.0.0-alpha.10",
82
- "@lowdefy/operators-diff": "4.0.0-alpha.10",
83
- "@lowdefy/operators-mql": "4.0.0-alpha.10",
84
- "@lowdefy/operators-nunjucks": "4.0.0-alpha.10",
85
- "@lowdefy/operators-uuid": "4.0.0-alpha.10",
86
- "@lowdefy/operators-yaml": "4.0.0-alpha.10",
68
+ "@lowdefy/actions-core": "4.0.0-alpha.11",
69
+ "@lowdefy/blocks-antd": "4.0.0-alpha.11",
70
+ "@lowdefy/blocks-color-selectors": "4.0.0-alpha.11",
71
+ "@lowdefy/blocks-echarts": "4.0.0-alpha.11",
72
+ "@lowdefy/blocks-markdown": "4.0.0-alpha.11",
73
+ "@lowdefy/connection-axios-http": "4.0.0-alpha.11",
74
+ "@lowdefy/connection-elasticsearch": "4.0.0-alpha.11",
75
+ "@lowdefy/connection-google-sheets": "4.0.0-alpha.11",
76
+ "@lowdefy/connection-knex": "4.0.0-alpha.11",
77
+ "@lowdefy/connection-mongodb": "4.0.0-alpha.11",
78
+ "@lowdefy/connection-redis": "4.0.0-alpha.11",
79
+ "@lowdefy/connection-sendgrid": "4.0.0-alpha.11",
80
+ "@lowdefy/connection-stripe": "4.0.0-alpha.11",
81
+ "@lowdefy/operators-change-case": "4.0.0-alpha.11",
82
+ "@lowdefy/operators-diff": "4.0.0-alpha.11",
83
+ "@lowdefy/operators-mql": "4.0.0-alpha.11",
84
+ "@lowdefy/operators-nunjucks": "4.0.0-alpha.11",
85
+ "@lowdefy/operators-uuid": "4.0.0-alpha.11",
86
+ "@lowdefy/operators-yaml": "4.0.0-alpha.11",
87
+ "@lowdefy/plugin-next-auth": "4.0.0-alpha.11",
87
88
  "@swc/cli": "0.1.55",
88
89
  "@swc/core": "1.2.135",
89
90
  "@swc/jest": "0.2.17",
@@ -92,5 +93,5 @@
92
93
  "publishConfig": {
93
94
  "access": "public"
94
95
  },
95
- "gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
96
+ "gitHead": "810fb2d8cb9ee8b0586b55fbbf26a5a5a0da3b2a"
96
97
  }