@lowdefy/build 4.0.0-alpha.10 → 4.0.0-alpha.13

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 (50) hide show
  1. package/dist/build/addDefaultPages/addDefaultPages.js +2 -3
  2. package/dist/build/buildAuth/buildAuth.js +11 -27
  3. package/dist/build/buildAuth/buildAuthPlugins.js +78 -0
  4. package/dist/build/buildAuth/buildPageAuth.js +50 -0
  5. package/dist/build/buildAuth/getPageRoles.js +1 -1
  6. package/dist/build/buildAuth/getProtectedPages.js +6 -8
  7. package/dist/build/buildAuth/validateAuthConfig.js +61 -0
  8. package/dist/build/buildConnections.js +1 -1
  9. package/dist/build/{buildIcons.js → buildImports/buildIconImports.js} +15 -23
  10. package/dist/build/buildImports/buildImports.js +30 -0
  11. package/dist/build/buildImports/buildImportsDev.js +101 -0
  12. package/dist/build/buildImports/buildImportsProd.js +53 -0
  13. package/dist/build/{buildStyles.js → buildImports/buildStyleImports.js} +7 -11
  14. package/dist/build/buildImports/defaultIconsDev.js +584 -0
  15. package/dist/build/buildImports/defaultIconsProd.js +21 -0
  16. package/dist/build/buildMenu.js +9 -13
  17. package/dist/build/buildPages/buildBlock/buildBlock.js +2 -2
  18. package/dist/build/buildPages/buildBlock/buildEvents.js +7 -9
  19. package/dist/build/buildPages/buildBlock/buildSubBlocks.js +2 -7
  20. package/dist/build/buildPages/buildPage.js +2 -2
  21. package/dist/build/buildPages/buildPages.js +3 -5
  22. package/dist/build/buildPages/buildTestPage.js +46 -0
  23. package/dist/build/buildRefs/evaluateBuildOperators.js +2 -3
  24. package/dist/build/buildTypes.js +25 -4
  25. package/dist/build/testSchema.js +4 -6
  26. package/dist/build/updateServerPackageJson.js +3 -0
  27. package/dist/build/validateApp.js +1 -1
  28. package/dist/build/validateConfig.js +1 -25
  29. package/dist/build/writeAuth.js +18 -0
  30. package/dist/build/writePages.js +1 -2
  31. package/dist/build/writePluginImports/generateImportFile.js +1 -6
  32. package/dist/build/writePluginImports/writeActionImports.js +1 -1
  33. package/dist/build/writePluginImports/writeAuthImports.js +30 -0
  34. package/dist/build/writePluginImports/writeBlockImports.js +1 -1
  35. package/dist/build/writePluginImports/writeConnectionImports.js +1 -1
  36. package/dist/build/writePluginImports/writeIconImports.js +1 -1
  37. package/dist/build/writePluginImports/writeOperatorImports.js +4 -4
  38. package/dist/build/writePluginImports/writePluginImports.js +52 -0
  39. package/dist/build/writePluginImports/writeStyleImports.js +1 -1
  40. package/dist/build/writeRequests.js +1 -2
  41. package/dist/createContext.js +54 -0
  42. package/dist/{defaultTypesMap.json → defaultTypesMap.js} +507 -229
  43. package/dist/index.js +19 -77
  44. package/dist/lowdefySchema.js +110 -58
  45. package/dist/scripts/generateDefaultTypes.js +11 -2
  46. package/dist/scripts/run.js +4 -3
  47. package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
  48. package/dist/test/testContext.js +6 -1
  49. package/dist/utils/createPluginTypesMap.js +21 -0
  50. package/package.json +44 -40
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  import page404 from './404.js';
17
- async function addDefaultPages({ components }) {
17
+ function addDefaultPages({ components }) {
18
18
  // If not copied, the same object is mutated by build every time
19
19
  // build runs for dev server. See #647
20
20
  const defaultPages = [
@@ -33,8 +33,7 @@ async function addDefaultPages({ components }) {
33
33
  return page.id;
34
34
  });
35
35
  // deep copy to avoid mutating defaultConfig
36
- const filteredDefaultPages = defaultPages.filter((defaultPage)=>!pageIds.includes(defaultPage.id)
37
- );
36
+ const filteredDefaultPages = defaultPages.filter((defaultPage)=>!pageIds.includes(defaultPage.id));
38
37
  components.pages = [
39
38
  ...components.pages,
40
39
  ...filteredDefaultPages
@@ -13,37 +13,21 @@
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 getPageRoles from './getPageRoles.js';
17
- import getProtectedPages from './getProtectedPages.js';
18
- function buildAuth({ components }) {
19
- const protectedPages = getProtectedPages({
16
+ import buildAuthPlugins from './buildAuthPlugins.js';
17
+ import buildPageAuth from './buildPageAuth.js';
18
+ import validateAuthConfig from './validateAuthConfig.js';
19
+ function buildAuth({ components , context }) {
20
+ const configured = !type.isNone(components.auth);
21
+ validateAuthConfig({
20
22
  components
21
23
  });
22
- const pageRoles = getPageRoles({
24
+ components.auth.configured = configured;
25
+ buildPageAuth({
23
26
  components
24
27
  });
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
- }
28
+ buildAuthPlugins({
29
+ components,
30
+ context
47
31
  });
48
32
  return components;
49
33
  }
@@ -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)=>{
@@ -14,16 +14,14 @@
14
14
  limitations under the License.
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  function getProtectedPages({ components }) {
17
- const pageIds = (components.pages || []).map((page)=>page.id
18
- );
17
+ const pageIds = (components.pages || []).map((page)=>page.id);
19
18
  let protectedPages = [];
20
- if (type.isArray(components.config.auth.pages.public)) {
21
- protectedPages = pageIds.filter((pageId)=>!components.config.auth.pages.public.includes(pageId)
22
- );
23
- } else if (components.config.auth.pages.protected === true) {
19
+ if (type.isArray(components.auth.pages.public)) {
20
+ protectedPages = pageIds.filter((pageId)=>!components.auth.pages.public.includes(pageId));
21
+ } else if (components.auth.pages.protected === true) {
24
22
  protectedPages = pageIds;
25
- } else if (type.isArray(components.config.auth.pages.protected)) {
26
- protectedPages = components.config.auth.pages.protected;
23
+ } else if (type.isArray(components.auth.pages.protected)) {
24
+ protectedPages = components.auth.pages.protected;
27
25
  }
28
26
  return protectedPages;
29
27
  }
@@ -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;
@@ -15,7 +15,7 @@
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  import countOperators from '../utils/countOperators.js';
17
17
  import createCheckDuplicateId from '../utils/createCheckDuplicateId.js';
18
- async function buildConnections({ components , context }) {
18
+ function buildConnections({ components , context }) {
19
19
  const checkDuplicateConnectionId = createCheckDuplicateId({
20
20
  message: 'Duplicate connectionId "{{ id }}".'
21
21
  });
@@ -38,54 +38,46 @@
38
38
  function getConfigIcons({ components , icons , regex }) {
39
39
  [
40
40
  ...JSON.stringify(components.global || {}).matchAll(regex)
41
- ].map((match)=>icons.add(match[1])
42
- );
41
+ ].map((match)=>icons.add(match[1]));
43
42
  [
44
43
  ...JSON.stringify(components.menus || []).matchAll(regex)
45
- ].map((match)=>icons.add(match[1])
46
- );
44
+ ].map((match)=>icons.add(match[1]));
47
45
  [
48
46
  ...JSON.stringify(components.pages || []).matchAll(regex)
49
- ].map((match)=>icons.add(match[1])
50
- );
47
+ ].map((match)=>icons.add(match[1]));
51
48
  }
52
- function getBlockDefaultIcons({ components , context , icons , regex }) {
53
- Object.keys(components.types.blocks).forEach((blockName)=>{
54
- (context.typesMap.icons[blockName] || []).forEach((icon)=>{
49
+ function getBlockDefaultIcons({ blocks , context , icons , regex }) {
50
+ blocks.forEach((block)=>{
51
+ (context.typesMap.icons[block.typeName] || []).forEach((icon)=>{
55
52
  [
56
53
  ...JSON.stringify(icon).matchAll(regex)
57
- ].map((match)=>icons.add(match[1])
58
- );
54
+ ].map((match)=>icons.add(match[1]));
59
55
  });
60
56
  });
61
57
  }
62
- function buildIcons({ components , context }) {
63
- components.icons = [];
58
+ function buildIconImports({ blocks , components , context , defaults ={} }) {
59
+ const iconImports = [];
64
60
  Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
65
- const icons = new Set();
66
- // TODO: Can we do better than this?
67
- // Add default icons
68
- if (iconPackage === 'react-icons/ai') {
69
- icons.add('AiOutlineLoading3Quarters');
70
- icons.add('AiOutlineExclamationCircle');
71
- }
61
+ defaults;
62
+ const icons = new Set(defaults[iconPackage]);
72
63
  getConfigIcons({
73
64
  components,
74
65
  icons,
75
66
  regex
76
67
  });
77
68
  getBlockDefaultIcons({
78
- components,
69
+ blocks,
79
70
  context,
80
71
  icons,
81
72
  regex
82
73
  });
83
- components.icons.push({
74
+ iconImports.push({
84
75
  icons: [
85
76
  ...icons
86
77
  ],
87
78
  package: iconPackage
88
79
  });
89
80
  });
81
+ return iconImports;
90
82
  }
91
- export default buildIcons;
83
+ 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
+ import defaultIconsDev from './defaultIconsDev.js';
18
+ function getPluginPackages({ components }) {
19
+ const pluginPackages = new Set();
20
+ function getPackages(types) {
21
+ Object.values(types).forEach((type)=>{
22
+ pluginPackages.add(type.package);
23
+ });
24
+ }
25
+ getPackages(components.types.actions);
26
+ getPackages(components.types.auth.callbacks);
27
+ getPackages(components.types.auth.events);
28
+ getPackages(components.types.auth.providers);
29
+ getPackages(components.types.blocks);
30
+ getPackages(components.types.connections);
31
+ getPackages(components.types.requests);
32
+ getPackages(components.types.operators.client);
33
+ getPackages(components.types.operators.server);
34
+ return pluginPackages;
35
+ }
36
+ function buildImportClassDev({ pluginPackages , map }) {
37
+ return Object.entries(map).map(([typeName, type])=>({
38
+ originalTypeName: type.originalTypeName,
39
+ package: type.package,
40
+ typeName
41
+ })).filter((type)=>pluginPackages.has(type.package));
42
+ }
43
+ function buildImportsDev({ components , context }) {
44
+ const pluginPackages = getPluginPackages({
45
+ components
46
+ });
47
+ const blocks = buildImportClassDev({
48
+ pluginPackages,
49
+ map: context.typesMap.blocks
50
+ });
51
+ return {
52
+ actions: buildImportClassDev({
53
+ pluginPackages,
54
+ map: context.typesMap.actions
55
+ }),
56
+ auth: {
57
+ callbacks: buildImportClassDev({
58
+ pluginPackages,
59
+ map: context.typesMap.auth.callbacks
60
+ }),
61
+ events: buildImportClassDev({
62
+ pluginPackages,
63
+ map: context.typesMap.auth.events
64
+ }),
65
+ providers: buildImportClassDev({
66
+ pluginPackages,
67
+ map: context.typesMap.auth.providers
68
+ })
69
+ },
70
+ blocks,
71
+ connections: buildImportClassDev({
72
+ pluginPackages,
73
+ map: context.typesMap.connections
74
+ }),
75
+ icons: buildIconImports({
76
+ blocks,
77
+ components,
78
+ context,
79
+ defaults: defaultIconsDev
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,53 @@
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
+ import defaultIconsProd from './defaultIconsProd.js';
18
+ function buildImportClassProd(types) {
19
+ return Object.entries(types).map(([typeName, type])=>({
20
+ originalTypeName: type.originalTypeName,
21
+ package: type.package,
22
+ typeName
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
+ defaults: defaultIconsProd
41
+ }),
42
+ requests: buildImportClassProd(components.types.requests),
43
+ operators: {
44
+ client: buildImportClassProd(components.types.operators.client),
45
+ server: buildImportClassProd(components.types.operators.server)
46
+ },
47
+ styles: buildStyleImports({
48
+ blocks,
49
+ context
50
+ })
51
+ };
52
+ }
53
+ export default buildImportsProd;
@@ -12,18 +12,14 @@
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])=>{
19
- styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`
20
- ));
21
- styles.add(...(context.typesMap.styles.blocks[blockName] || []).map((style)=>`${block.package}/${style}`
22
- ));
17
+ blocks.forEach((block)=>{
18
+ styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`));
19
+ styles.add(...(context.typesMap.styles.blocks[block.typeName] || []).map((style)=>`${block.package}/${style}`));
23
20
  });
24
- components.styles = [
21
+ return [
25
22
  ...styles
26
- ].filter((style)=>!!style
27
- );
23
+ ].filter((style)=>!!style);
28
24
  }
29
- export default buildStyles;
25
+ export default buildStyleImports;