@lowdefy/build 4.0.0-alpha.11 → 4.0.0-alpha.14

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/addDefaultPages/addDefaultPages.js +2 -3
  2. package/dist/build/buildAuth/buildAuth.js +4 -1
  3. package/dist/build/buildAuth/getProtectedPages.js +2 -4
  4. package/dist/build/buildConnections.js +1 -1
  5. package/dist/build/buildImports/buildIconImports.js +7 -16
  6. package/dist/build/buildImports/buildImportsDev.js +4 -4
  7. package/dist/build/buildImports/buildImportsProd.js +4 -3
  8. package/dist/build/buildImports/buildStyleImports.js +3 -6
  9. package/dist/build/buildImports/defaultIconsDev.js +584 -0
  10. package/dist/build/buildImports/defaultIconsProd.js +21 -0
  11. package/dist/build/buildMenu.js +9 -13
  12. package/dist/build/buildPages/buildBlock/buildBlock.js +2 -2
  13. package/dist/build/buildPages/buildBlock/buildEvents.js +7 -9
  14. package/dist/build/buildPages/buildBlock/buildSubBlocks.js +2 -7
  15. package/dist/build/buildPages/buildPage.js +2 -2
  16. package/dist/build/buildPages/buildPages.js +3 -5
  17. package/dist/build/buildPages/buildTestPage.js +46 -0
  18. package/dist/build/buildRefs/evaluateBuildOperators.js +2 -3
  19. package/dist/build/buildTypes.js +2 -4
  20. package/dist/build/testSchema.js +4 -5
  21. package/dist/build/validateApp.js +1 -1
  22. package/dist/build/validateConfig.js +1 -1
  23. package/dist/build/writePages.js +1 -2
  24. package/dist/build/writeRequests.js +1 -2
  25. package/dist/createContext.js +54 -0
  26. package/dist/{defaultTypesMap.json → defaultTypesMap.js} +285 -283
  27. package/dist/index.js +13 -53
  28. package/dist/lowdefySchema.js +6 -0
  29. package/dist/scripts/generateDefaultTypes.js +4 -1
  30. package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
  31. package/dist/test/testContext.js +6 -1
  32. package/package.json +44 -41
@@ -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
@@ -12,13 +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 buildAuthPlugins from './buildAuthPlugins.js';
15
+ */ import { type } from '@lowdefy/helpers';
16
+ import buildAuthPlugins from './buildAuthPlugins.js';
16
17
  import buildPageAuth from './buildPageAuth.js';
17
18
  import validateAuthConfig from './validateAuthConfig.js';
18
19
  function buildAuth({ components , context }) {
20
+ const configured = !type.isNone(components.auth);
19
21
  validateAuthConfig({
20
22
  components
21
23
  });
24
+ components.auth.configured = configured;
22
25
  buildPageAuth({
23
26
  components
24
27
  });
@@ -14,12 +14,10 @@
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
19
  if (type.isArray(components.auth.pages.public)) {
21
- protectedPages = pageIds.filter((pageId)=>!components.auth.pages.public.includes(pageId)
22
- );
20
+ protectedPages = pageIds.filter((pageId)=>!components.auth.pages.public.includes(pageId));
23
21
  } else if (components.auth.pages.protected === true) {
24
22
  protectedPages = pageIds;
25
23
  } else if (type.isArray(components.auth.pages.protected)) {
@@ -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,37 +38,28 @@
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
49
  function getBlockDefaultIcons({ blocks , context , icons , regex }) {
53
50
  blocks.forEach((block)=>{
54
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 buildIconImports({ blocks , components , context }) {
58
+ function buildIconImports({ blocks , components , context , defaults ={} }) {
63
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,
@@ -14,6 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import buildIconImports from './buildIconImports.js';
16
16
  import buildStyleImports from './buildStyleImports.js';
17
+ import defaultIconsDev from './defaultIconsDev.js';
17
18
  function getPluginPackages({ components }) {
18
19
  const pluginPackages = new Set();
19
20
  function getPackages(types) {
@@ -37,9 +38,7 @@ function buildImportClassDev({ pluginPackages , map }) {
37
38
  originalTypeName: type.originalTypeName,
38
39
  package: type.package,
39
40
  typeName
40
- })
41
- ).filter((type)=>pluginPackages.has(type.package)
42
- );
41
+ })).filter((type)=>pluginPackages.has(type.package));
43
42
  }
44
43
  function buildImportsDev({ components , context }) {
45
44
  const pluginPackages = getPluginPackages({
@@ -76,7 +75,8 @@ function buildImportsDev({ components , context }) {
76
75
  icons: buildIconImports({
77
76
  blocks,
78
77
  components,
79
- context
78
+ context,
79
+ defaults: defaultIconsDev
80
80
  }),
81
81
  requests: buildImportClassDev({
82
82
  pluginPackages,
@@ -14,13 +14,13 @@
14
14
  limitations under the License.
15
15
  */ import buildIconImports from './buildIconImports.js';
16
16
  import buildStyleImports from './buildStyleImports.js';
17
+ import defaultIconsProd from './defaultIconsProd.js';
17
18
  function buildImportClassProd(types) {
18
19
  return Object.entries(types).map(([typeName, type])=>({
19
20
  originalTypeName: type.originalTypeName,
20
21
  package: type.package,
21
22
  typeName
22
- })
23
- );
23
+ }));
24
24
  }
25
25
  function buildImportsProd({ components , context }) {
26
26
  const blocks = buildImportClassProd(components.types.blocks);
@@ -36,7 +36,8 @@ function buildImportsProd({ components , context }) {
36
36
  icons: buildIconImports({
37
37
  blocks,
38
38
  components,
39
- context
39
+ context,
40
+ defaults: defaultIconsProd
40
41
  }),
41
42
  requests: buildImportClassProd(components.types.requests),
42
43
  operators: {
@@ -15,14 +15,11 @@
15
15
  */ function buildStyleImports({ blocks , context }) {
16
16
  const styles = new Set();
17
17
  blocks.forEach((block)=>{
18
- styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`
19
- ));
20
- styles.add(...(context.typesMap.styles.blocks[block.typeName] || []).map((style)=>`${block.package}/${style}`
21
- ));
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}`));
22
20
  });
23
21
  return [
24
22
  ...styles
25
- ].filter((style)=>!!style
26
- );
23
+ ].filter((style)=>!!style);
27
24
  }
28
25
  export default buildStyleImports;