@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
@@ -12,38 +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
- */ import { type } from '@lowdefy/helpers';
16
- import getPageRoles from './getPageRoles.js';
17
- import getProtectedPages from './getProtectedPages.js';
18
- function buildAuth({ components }) {
19
- const protectedPages = getProtectedPages({
15
+ */ import buildAuthPlugins from './buildAuthPlugins.js';
16
+ import buildPageAuth from './buildPageAuth.js';
17
+ import validateAuthConfig from './validateAuthConfig.js';
18
+ function buildAuth({ components , context }) {
19
+ validateAuthConfig({
20
20
  components
21
21
  });
22
- const pageRoles = getPageRoles({
22
+ buildPageAuth({
23
23
  components
24
24
  });
25
- let configPublicPages = [];
26
- if (type.isArray(components.config.auth.pages.public)) {
27
- configPublicPages = components.config.auth.pages.public;
28
- }
29
- (components.pages || []).forEach((page)=>{
30
- if (pageRoles[page.id]) {
31
- if (configPublicPages.includes(page.id)) {
32
- throw new Error(`Page "${page.id}" is both protected by roles ${JSON.stringify(pageRoles[page.id])} and public.`);
33
- }
34
- page.auth = {
35
- public: false,
36
- roles: pageRoles[page.id]
37
- };
38
- } else if (protectedPages.includes(page.id)) {
39
- page.auth = {
40
- public: false
41
- };
42
- } else {
43
- page.auth = {
44
- public: true
45
- };
46
- }
25
+ buildAuthPlugins({
26
+ components,
27
+ context
47
28
  });
48
29
  return components;
49
30
  }
@@ -0,0 +1,78 @@
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 { type } from '@lowdefy/helpers';
16
+ function buildCallbacks({ components , context }) {
17
+ if (type.isArray(components.auth.callbacks)) {
18
+ components.auth.callbacks.forEach((callback)=>{
19
+ if (type.isUndefined(callback.id)) {
20
+ throw new Error(`Auth callback id missing.`);
21
+ }
22
+ if (!type.isString(callback.id)) {
23
+ throw new Error(`Auth callback id is not a string. Received ${JSON.stringify(callback.id)}.`);
24
+ }
25
+ if (!type.isString(callback.type)) {
26
+ throw new Error(`Auth callback type is not a string at callback "${callback.id}". Received ${JSON.stringify(callback.type)}.`);
27
+ }
28
+ context.typeCounters.auth.callbacks.increment(callback.type);
29
+ });
30
+ }
31
+ }
32
+ function buildEvents({ components , context }) {
33
+ if (type.isArray(components.auth.events)) {
34
+ components.auth.events.forEach((event)=>{
35
+ if (type.isUndefined(event.id)) {
36
+ throw new Error(`Auth event id missing.`);
37
+ }
38
+ if (!type.isString(event.id)) {
39
+ throw new Error(`Auth event id is not a string. Received ${JSON.stringify(event.id)}.`);
40
+ }
41
+ if (!type.isString(event.type)) {
42
+ throw new Error(`Auth event type is not a string at event "${event.id}". Received ${JSON.stringify(event.type)}.`);
43
+ }
44
+ context.typeCounters.auth.events.increment(event.type);
45
+ });
46
+ }
47
+ }
48
+ function buildProviders({ components , context }) {
49
+ if (type.isArray(components.auth.providers)) {
50
+ components.auth.providers.forEach((provider)=>{
51
+ if (type.isUndefined(provider.id)) {
52
+ throw new Error(`Auth provider id missing.`);
53
+ }
54
+ if (!type.isString(provider.id)) {
55
+ throw new Error(`Auth provider id is not a string. Received ${JSON.stringify(provider.id)}.`);
56
+ }
57
+ if (!type.isString(provider.type)) {
58
+ throw new Error(`Auth provider type is not a string at provider "${provider.id}". Received ${JSON.stringify(provider.type)}.`);
59
+ }
60
+ context.typeCounters.auth.providers.increment(provider.type);
61
+ });
62
+ }
63
+ }
64
+ function buildAuthPlugins({ components , context }) {
65
+ buildCallbacks({
66
+ components,
67
+ context
68
+ });
69
+ buildEvents({
70
+ components,
71
+ context
72
+ });
73
+ buildProviders({
74
+ components,
75
+ context
76
+ });
77
+ }
78
+ export default buildAuthPlugins;
@@ -0,0 +1,50 @@
1
+ /* eslint-disable no-param-reassign */ /*
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 { type } from '@lowdefy/helpers';
16
+ import getPageRoles from './getPageRoles.js';
17
+ import getProtectedPages from './getProtectedPages.js';
18
+ function buildPageAuth({ components }) {
19
+ const protectedPages = getProtectedPages({
20
+ components
21
+ });
22
+ const pageRoles = getPageRoles({
23
+ components
24
+ });
25
+ let configPublicPages = [];
26
+ if (type.isArray(components.auth.pages.public)) {
27
+ configPublicPages = components.auth.pages.public;
28
+ }
29
+ (components.pages || []).forEach((page)=>{
30
+ if (pageRoles[page.id]) {
31
+ if (configPublicPages.includes(page.id)) {
32
+ throw new Error(`Page "${page.id}" is both protected by roles ${JSON.stringify(pageRoles[page.id])} and public.`);
33
+ }
34
+ page.auth = {
35
+ public: false,
36
+ roles: pageRoles[page.id]
37
+ };
38
+ } else if (protectedPages.includes(page.id)) {
39
+ page.auth = {
40
+ public: false
41
+ };
42
+ } else {
43
+ page.auth = {
44
+ public: true
45
+ };
46
+ }
47
+ });
48
+ return components;
49
+ }
50
+ export default buildPageAuth;
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ function getPageRoles({ components }) {
16
- const roles = components.config.auth.pages.roles;
16
+ const roles = components.auth.pages.roles;
17
17
  const pageRoles = {};
18
18
  Object.keys(roles).forEach((roleName)=>{
19
19
  roles[roleName].forEach((pageId)=>{
@@ -17,13 +17,13 @@ function getProtectedPages({ components }) {
17
17
  const pageIds = (components.pages || []).map((page)=>page.id
18
18
  );
19
19
  let protectedPages = [];
20
- if (type.isArray(components.config.auth.pages.public)) {
21
- protectedPages = pageIds.filter((pageId)=>!components.config.auth.pages.public.includes(pageId)
20
+ if (type.isArray(components.auth.pages.public)) {
21
+ protectedPages = pageIds.filter((pageId)=>!components.auth.pages.public.includes(pageId)
22
22
  );
23
- } else if (components.config.auth.pages.protected === true) {
23
+ } else if (components.auth.pages.protected === true) {
24
24
  protectedPages = pageIds;
25
- } else if (type.isArray(components.config.auth.pages.protected)) {
26
- protectedPages = components.config.auth.pages.protected;
25
+ } else if (type.isArray(components.auth.pages.protected)) {
26
+ protectedPages = components.auth.pages.protected;
27
27
  }
28
28
  return protectedPages;
29
29
  }
@@ -0,0 +1,61 @@
1
+ /* eslint-disable no-param-reassign */ /*
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 { type } from '@lowdefy/helpers';
16
+ import { validate } from '@lowdefy/ajv';
17
+ import lowdefySchema from '../../lowdefySchema.js';
18
+ async function validateAuthConfig({ components }) {
19
+ if (type.isNone(components.auth)) {
20
+ components.auth = {};
21
+ }
22
+ if (!type.isObject(components.auth)) {
23
+ throw new Error('lowdefy.auth is not an object.');
24
+ }
25
+ if (type.isNone(components.auth.pages)) {
26
+ components.auth.pages = {};
27
+ }
28
+ if (type.isNone(components.auth.pages.roles)) {
29
+ components.auth.pages.roles = {};
30
+ }
31
+ if (type.isNone(components.auth.callbacks)) {
32
+ components.auth.callbacks = [];
33
+ }
34
+ if (type.isNone(components.auth.events)) {
35
+ components.auth.events = [];
36
+ }
37
+ if (type.isNone(components.auth.providers)) {
38
+ components.auth.providers = [];
39
+ }
40
+ if (type.isNone(components.auth.session)) {
41
+ components.auth.session = {};
42
+ }
43
+ if (type.isNone(components.auth.theme)) {
44
+ components.auth.theme = {};
45
+ }
46
+ validate({
47
+ schema: lowdefySchema.definitions.authConfig,
48
+ data: components.auth
49
+ });
50
+ if (components.auth.pages.protected === true && components.auth.pages.public === true || type.isArray(components.auth.pages.protected) && type.isArray(components.auth.pages.public)) {
51
+ 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.');
52
+ }
53
+ if (components.auth.pages.protected === false) {
54
+ throw new Error('Protected pages can not be set to false.');
55
+ }
56
+ if (components.auth.pages.public === false) {
57
+ throw new Error('Public pages can not be set to false.');
58
+ }
59
+ return components;
60
+ }
61
+ export default validateAuthConfig;
@@ -49,9 +49,9 @@ function getConfigIcons({ components , icons , regex }) {
49
49
  ].map((match)=>icons.add(match[1])
50
50
  );
51
51
  }
52
- function getBlockDefaultIcons({ components , context , icons , regex }) {
53
- Object.keys(components.types.blocks).forEach((blockName)=>{
54
- (context.typesMap.icons[blockName] || []).forEach((icon)=>{
52
+ function getBlockDefaultIcons({ blocks , context , icons , regex }) {
53
+ blocks.forEach((block)=>{
54
+ (context.typesMap.icons[block.typeName] || []).forEach((icon)=>{
55
55
  [
56
56
  ...JSON.stringify(icon).matchAll(regex)
57
57
  ].map((match)=>icons.add(match[1])
@@ -59,8 +59,8 @@ function getBlockDefaultIcons({ components , context , icons , regex }) {
59
59
  });
60
60
  });
61
61
  }
62
- function buildIcons({ components , context }) {
63
- components.icons = [];
62
+ function buildIconImports({ blocks , components , context }) {
63
+ const iconImports = [];
64
64
  Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
65
65
  const icons = new Set();
66
66
  // TODO: Can we do better than this?
@@ -75,17 +75,18 @@ function buildIcons({ components , context }) {
75
75
  regex
76
76
  });
77
77
  getBlockDefaultIcons({
78
- components,
78
+ blocks,
79
79
  context,
80
80
  icons,
81
81
  regex
82
82
  });
83
- components.icons.push({
83
+ iconImports.push({
84
84
  icons: [
85
85
  ...icons
86
86
  ],
87
87
  package: iconPackage
88
88
  });
89
89
  });
90
+ return iconImports;
90
91
  }
91
- export default buildIcons;
92
+ export default buildIconImports;
@@ -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 buildImportsDev from './buildImportsDev.js';
16
+ import buildImportsProd from './buildImportsProd.js';
17
+ function buildImports({ components , context }) {
18
+ if (context.stage === 'dev') {
19
+ components.imports = buildImportsDev({
20
+ components,
21
+ context
22
+ });
23
+ } else {
24
+ components.imports = buildImportsProd({
25
+ components,
26
+ context
27
+ });
28
+ }
29
+ }
30
+ export default buildImports;
@@ -0,0 +1,101 @@
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 buildIconImports from './buildIconImports.js';
16
+ import buildStyleImports from './buildStyleImports.js';
17
+ function getPluginPackages({ components }) {
18
+ const pluginPackages = new Set();
19
+ function getPackages(types) {
20
+ Object.values(types).forEach((type)=>{
21
+ pluginPackages.add(type.package);
22
+ });
23
+ }
24
+ getPackages(components.types.actions);
25
+ getPackages(components.types.auth.callbacks);
26
+ getPackages(components.types.auth.events);
27
+ getPackages(components.types.auth.providers);
28
+ getPackages(components.types.blocks);
29
+ getPackages(components.types.connections);
30
+ getPackages(components.types.requests);
31
+ getPackages(components.types.operators.client);
32
+ getPackages(components.types.operators.server);
33
+ return pluginPackages;
34
+ }
35
+ function buildImportClassDev({ pluginPackages , map }) {
36
+ return Object.entries(map).map(([typeName, type])=>({
37
+ originalTypeName: type.originalTypeName,
38
+ package: type.package,
39
+ typeName
40
+ })
41
+ ).filter((type)=>pluginPackages.has(type.package)
42
+ );
43
+ }
44
+ function buildImportsDev({ components , context }) {
45
+ const pluginPackages = getPluginPackages({
46
+ components
47
+ });
48
+ const blocks = buildImportClassDev({
49
+ pluginPackages,
50
+ map: context.typesMap.blocks
51
+ });
52
+ return {
53
+ actions: buildImportClassDev({
54
+ pluginPackages,
55
+ map: context.typesMap.actions
56
+ }),
57
+ auth: {
58
+ callbacks: buildImportClassDev({
59
+ pluginPackages,
60
+ map: context.typesMap.auth.callbacks
61
+ }),
62
+ events: buildImportClassDev({
63
+ pluginPackages,
64
+ map: context.typesMap.auth.events
65
+ }),
66
+ providers: buildImportClassDev({
67
+ pluginPackages,
68
+ map: context.typesMap.auth.providers
69
+ })
70
+ },
71
+ blocks,
72
+ connections: buildImportClassDev({
73
+ pluginPackages,
74
+ map: context.typesMap.connections
75
+ }),
76
+ icons: buildIconImports({
77
+ blocks,
78
+ components,
79
+ context
80
+ }),
81
+ requests: buildImportClassDev({
82
+ pluginPackages,
83
+ map: context.typesMap.requests
84
+ }),
85
+ operators: {
86
+ client: buildImportClassDev({
87
+ pluginPackages,
88
+ map: context.typesMap.operators.client
89
+ }),
90
+ server: buildImportClassDev({
91
+ pluginPackages,
92
+ map: context.typesMap.operators.server
93
+ })
94
+ },
95
+ styles: buildStyleImports({
96
+ blocks,
97
+ context
98
+ })
99
+ };
100
+ }
101
+ export default buildImportsDev;
@@ -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 buildIconImports from './buildIconImports.js';
16
+ import buildStyleImports from './buildStyleImports.js';
17
+ function buildImportClassProd(types) {
18
+ return Object.entries(types).map(([typeName, type])=>({
19
+ originalTypeName: type.originalTypeName,
20
+ package: type.package,
21
+ typeName
22
+ })
23
+ );
24
+ }
25
+ function buildImportsProd({ components , context }) {
26
+ const blocks = buildImportClassProd(components.types.blocks);
27
+ return {
28
+ actions: buildImportClassProd(components.types.actions),
29
+ auth: {
30
+ callbacks: buildImportClassProd(components.types.auth.callbacks),
31
+ events: buildImportClassProd(components.types.auth.events),
32
+ providers: buildImportClassProd(components.types.auth.providers)
33
+ },
34
+ blocks,
35
+ connections: buildImportClassProd(components.types.connections),
36
+ icons: buildIconImports({
37
+ blocks,
38
+ components,
39
+ context
40
+ }),
41
+ requests: buildImportClassProd(components.types.requests),
42
+ operators: {
43
+ client: buildImportClassProd(components.types.operators.client),
44
+ server: buildImportClassProd(components.types.operators.server)
45
+ },
46
+ styles: buildStyleImports({
47
+ blocks,
48
+ context
49
+ })
50
+ };
51
+ }
52
+ export default buildImportsProd;
@@ -12,18 +12,17 @@
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
- */ function buildStyles({ components , context }) {
16
- components.styles = [];
15
+ */ function buildStyleImports({ blocks , context }) {
17
16
  const styles = new Set();
18
- Object.entries(components.types.blocks).forEach(([blockName, block])=>{
17
+ blocks.forEach((block)=>{
19
18
  styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`
20
19
  ));
21
- styles.add(...(context.typesMap.styles.blocks[blockName] || []).map((style)=>`${block.package}/${style}`
20
+ styles.add(...(context.typesMap.styles.blocks[block.typeName] || []).map((style)=>`${block.package}/${style}`
22
21
  ));
23
22
  });
24
- components.styles = [
23
+ return [
25
24
  ...styles
26
25
  ].filter((style)=>!!style
27
26
  );
28
27
  }
29
- export default buildStyles;
28
+ export default buildStyleImports;
@@ -46,6 +46,11 @@ function buildTypes({ components , context }) {
46
46
  typeCounters.blocks.increment('Message'); // Used for DisplayMessage in @lowdefy/client
47
47
  components.types = {
48
48
  actions: {},
49
+ auth: {
50
+ callbacks: {},
51
+ events: {},
52
+ providers: {}
53
+ },
49
54
  blocks: {},
50
55
  connections: {},
51
56
  requests: {},
@@ -60,6 +65,24 @@ function buildTypes({ components , context }) {
60
65
  store: components.types.actions,
61
66
  typeClass: 'Action'
62
67
  });
68
+ buildTypeClass(context, {
69
+ counter: typeCounters.auth.callbacks,
70
+ definitions: context.typesMap.auth.callbacks,
71
+ store: components.types.auth.callbacks,
72
+ typeClass: 'Auth callback'
73
+ });
74
+ buildTypeClass(context, {
75
+ counter: typeCounters.auth.events,
76
+ definitions: context.typesMap.auth.events,
77
+ store: components.types.auth.events,
78
+ typeClass: 'Auth event'
79
+ });
80
+ buildTypeClass(context, {
81
+ counter: typeCounters.auth.providers,
82
+ definitions: context.typesMap.auth.providers,
83
+ store: components.types.auth.providers,
84
+ typeClass: 'Auth provider'
85
+ });
63
86
  buildTypeClass(context, {
64
87
  counter: typeCounters.blocks,
65
88
  definitions: context.typesMap.blocks,
@@ -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;
@@ -25,6 +25,9 @@ async function updateServerPackageJson({ components , context }) {
25
25
  });
26
26
  }
27
27
  getPackages(components.types.actions);
28
+ getPackages(components.types.auth.callbacks);
29
+ getPackages(components.types.auth.events);
30
+ getPackages(components.types.auth.providers);
28
31
  getPackages(components.types.blocks);
29
32
  getPackages(components.types.connections);
30
33
  getPackages(components.types.requests);
@@ -13,8 +13,6 @@
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
18
  components.config = {};
@@ -22,15 +20,6 @@ async function validateConfig({ components }) {
22
20
  if (!type.isObject(components.config)) {
23
21
  throw new Error('lowdefy.config is not an object.');
24
22
  }
25
- if (type.isNone(components.config.auth)) {
26
- components.config.auth = {};
27
- }
28
- if (type.isNone(components.config.auth.pages)) {
29
- components.config.auth.pages = {};
30
- }
31
- if (type.isNone(components.config.auth.pages.roles)) {
32
- components.config.auth.pages.roles = {};
33
- }
34
23
  if (type.isNone(components.config.theme)) {
35
24
  components.config.theme = {};
36
25
  }
@@ -39,19 +28,6 @@ async function validateConfig({ components }) {
39
28
  throw Error('Base path must start with "/".');
40
29
  }
41
30
  }
42
- validate({
43
- schema: lowdefySchema.definitions.authConfig,
44
- data: components.config.auth
45
- });
46
- 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)) {
47
- 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.');
48
- }
49
- if (components.config.auth.pages.protected === false) {
50
- throw new Error('Protected pages can not be set to false.');
51
- }
52
- if (components.config.auth.pages.public === false) {
53
- throw new Error('Public pages can not be set to false.');
54
- }
55
31
  return components;
56
32
  }
57
33
  export default validateConfig;
@@ -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;
@@ -21,13 +21,8 @@ export default {
21
21
  {{ import.typeName }},
22
22
  {% endfor -%}
23
23
  };`;
24
- function generateImportFile({ types , importPath }) {
24
+ function generateImportFile({ imports , importPath }) {
25
25
  const templateFn = nunjucksFunction(template);
26
- const imports = Object.keys(types).map((typeName)=>({
27
- typeName,
28
- ...types[typeName]
29
- })
30
- );
31
26
  return templateFn({
32
27
  imports,
33
28
  importPath