@lowdefy/build 4.0.0-alpha.12 → 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.
- package/dist/build/addDefaultPages/addDefaultPages.js +2 -3
- package/dist/build/buildAuth/buildAuth.js +4 -1
- package/dist/build/buildAuth/getProtectedPages.js +2 -4
- package/dist/build/buildConnections.js +1 -1
- package/dist/build/buildImports/buildIconImports.js +4 -8
- package/dist/build/buildImports/buildImportsDev.js +1 -3
- package/dist/build/buildImports/buildImportsProd.js +1 -2
- package/dist/build/buildImports/buildStyleImports.js +3 -6
- package/dist/build/buildMenu.js +9 -13
- package/dist/build/buildPages/buildBlock/buildBlock.js +2 -2
- package/dist/build/buildPages/buildBlock/buildEvents.js +7 -9
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +2 -7
- package/dist/build/buildPages/buildPage.js +2 -2
- package/dist/build/buildPages/buildPages.js +3 -5
- package/dist/build/buildPages/buildTestPage.js +46 -0
- package/dist/build/buildRefs/evaluateBuildOperators.js +2 -3
- package/dist/build/buildTypes.js +2 -4
- package/dist/build/testSchema.js +4 -5
- package/dist/build/validateApp.js +1 -1
- package/dist/build/validateConfig.js +1 -1
- package/dist/build/writePages.js +1 -2
- package/dist/build/writeRequests.js +1 -2
- package/dist/createContext.js +54 -0
- package/dist/{defaultTypesMap.json → defaultTypesMap.js} +285 -283
- package/dist/index.js +13 -53
- package/dist/lowdefySchema.js +6 -0
- package/dist/scripts/generateDefaultTypes.js +4 -1
- package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
- package/dist/test/testContext.js +6 -1
- 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
|
-
|
|
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
|
|
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
|
-
|
|
18
|
+
function buildConnections({ components , context }) {
|
|
19
19
|
const checkDuplicateConnectionId = createCheckDuplicateId({
|
|
20
20
|
message: 'Duplicate connectionId "{{ id }}".'
|
|
21
21
|
});
|
|
@@ -38,24 +38,20 @@
|
|
|
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
|
}
|
|
@@ -38,9 +38,7 @@ function buildImportClassDev({ pluginPackages , map }) {
|
|
|
38
38
|
originalTypeName: type.originalTypeName,
|
|
39
39
|
package: type.package,
|
|
40
40
|
typeName
|
|
41
|
-
})
|
|
42
|
-
).filter((type)=>pluginPackages.has(type.package)
|
|
43
|
-
);
|
|
41
|
+
})).filter((type)=>pluginPackages.has(type.package));
|
|
44
42
|
}
|
|
45
43
|
function buildImportsDev({ components , context }) {
|
|
46
44
|
const pluginPackages = getPluginPackages({
|
|
@@ -20,8 +20,7 @@ function buildImportClassProd(types) {
|
|
|
20
20
|
originalTypeName: type.originalTypeName,
|
|
21
21
|
package: type.package,
|
|
22
22
|
typeName
|
|
23
|
-
})
|
|
24
|
-
);
|
|
23
|
+
}));
|
|
25
24
|
}
|
|
26
25
|
function buildImportsProd({ components , context }) {
|
|
27
26
|
const blocks = buildImportClassProd(components.types.blocks);
|
|
@@ -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;
|
package/dist/build/buildMenu.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
import createCheckDuplicateId from '../utils/createCheckDuplicateId.js';
|
|
17
|
-
|
|
17
|
+
function buildDefaultMenu({ components , context }) {
|
|
18
18
|
context.logger.warn('No menus found. Building default menu.');
|
|
19
19
|
const pages = type.isArray(components.pages) ? components.pages : [];
|
|
20
20
|
const menus = [
|
|
@@ -25,9 +25,7 @@ async function buildDefaultMenu({ components , context }) {
|
|
|
25
25
|
type: 'MenuLink',
|
|
26
26
|
pageId: page.pageId,
|
|
27
27
|
auth: page.auth
|
|
28
|
-
})
|
|
29
|
-
).filter((page)=>page.pageId !== '404'
|
|
30
|
-
)
|
|
28
|
+
})).filter((page)=>page.pageId !== '404')
|
|
31
29
|
},
|
|
32
30
|
];
|
|
33
31
|
return menus;
|
|
@@ -37,8 +35,7 @@ function loopItems({ parent , menuId , pages , missingPageWarnings , checkDuplic
|
|
|
37
35
|
parent.links.forEach((menuItem)=>{
|
|
38
36
|
if (menuItem.type === 'MenuLink') {
|
|
39
37
|
if (type.isString(menuItem.pageId)) {
|
|
40
|
-
const page = pages.find((pg)=>pg.pageId === menuItem.pageId
|
|
41
|
-
);
|
|
38
|
+
const page = pages.find((pg)=>pg.pageId === menuItem.pageId);
|
|
42
39
|
if (!page) {
|
|
43
40
|
missingPageWarnings.push({
|
|
44
41
|
menuItemId: menuItem.id,
|
|
@@ -75,14 +72,13 @@ function loopItems({ parent , menuId , pages , missingPageWarnings , checkDuplic
|
|
|
75
72
|
checkDuplicateMenuItemId
|
|
76
73
|
});
|
|
77
74
|
});
|
|
78
|
-
parent.links = parent.links.filter((item)=>item.remove !== true
|
|
79
|
-
);
|
|
75
|
+
parent.links = parent.links.filter((item)=>item.remove !== true);
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
|
-
|
|
78
|
+
function buildMenu({ components , context }) {
|
|
83
79
|
const pages = type.isArray(components.pages) ? components.pages : [];
|
|
84
80
|
if (type.isUndefined(components.menus) || components.menus.length === 0) {
|
|
85
|
-
components.menus =
|
|
81
|
+
components.menus = buildDefaultMenu({
|
|
86
82
|
components,
|
|
87
83
|
context
|
|
88
84
|
});
|
|
@@ -114,9 +110,9 @@ async function buildMenu({ components , context }) {
|
|
|
114
110
|
checkDuplicateMenuItemId
|
|
115
111
|
});
|
|
116
112
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})
|
|
113
|
+
missingPageWarnings.map(async (warning)=>{
|
|
114
|
+
context.logger.warn(`Page "${warning.pageId}" referenced in menu link "${warning.menuItemId}" not found.`);
|
|
115
|
+
});
|
|
120
116
|
return components;
|
|
121
117
|
}
|
|
122
118
|
export default buildMenu;
|
|
@@ -21,7 +21,7 @@ import moveSubBlocksToArea from './moveSubBlocksToArea.js';
|
|
|
21
21
|
import moveSkeletonBlocksToArea from './moveSkeletonBlocksToArea.js';
|
|
22
22
|
import setBlockId from './setBlockId.js';
|
|
23
23
|
import validateBlock from './validateBlock.js';
|
|
24
|
-
|
|
24
|
+
function buildBlock(block, pageContext) {
|
|
25
25
|
validateBlock(block, pageContext);
|
|
26
26
|
setBlockId(block, pageContext);
|
|
27
27
|
countBlockOperators(block, pageContext);
|
|
@@ -30,6 +30,6 @@ async function buildBlock(block, pageContext) {
|
|
|
30
30
|
moveSubBlocksToArea(block, pageContext);
|
|
31
31
|
moveSkeletonBlocksToArea(block, pageContext);
|
|
32
32
|
countBlockTypes(block, pageContext);
|
|
33
|
-
|
|
33
|
+
buildSubBlocks(block, pageContext);
|
|
34
34
|
}
|
|
35
35
|
export default buildBlock;
|
|
@@ -35,6 +35,9 @@ function checkAction(action, { blockId , checkDuplicateActionId , eventId , page
|
|
|
35
35
|
function buildEvents(block, pageContext) {
|
|
36
36
|
if (block.events) {
|
|
37
37
|
Object.keys(block.events).map((key)=>{
|
|
38
|
+
if (!type.isArray(block.events[key]) && !type.isObject(block.events[key]) || type.isObject(block.events[key]) && type.isNone(block.events[key].try)) {
|
|
39
|
+
throw new Error(`Actions must be an array at "${block.blockId}" in event "${key}" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].try)}`);
|
|
40
|
+
}
|
|
38
41
|
if (type.isArray(block.events[key])) {
|
|
39
42
|
block.events[key] = {
|
|
40
43
|
try: block.events[key],
|
|
@@ -42,13 +45,10 @@ function buildEvents(block, pageContext) {
|
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
if (!type.isArray(block.events[key].try)) {
|
|
45
|
-
throw new Error(`
|
|
46
|
-
}
|
|
47
|
-
if (type.isNone(block.events[key].catch)) {
|
|
48
|
-
block.events[key].catch = [];
|
|
48
|
+
throw new Error(`Try actions must be an array at "${block.blockId}" in event "${key}.try" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].try)}`);
|
|
49
49
|
}
|
|
50
50
|
if (!type.isArray(block.events[key].catch)) {
|
|
51
|
-
throw new Error(`Catch
|
|
51
|
+
throw new Error(`Catch actions must be an array at "${block.blockId}" in event "${key}.catch" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].catch)}`);
|
|
52
52
|
}
|
|
53
53
|
const checkDuplicateActionId = createCheckDuplicateId({
|
|
54
54
|
message: 'Duplicate actionId "{{ id }}" on event "{{ eventId }}" on block "{{ blockId }}" on page "{{ pageId }}".'
|
|
@@ -59,16 +59,14 @@ function buildEvents(block, pageContext) {
|
|
|
59
59
|
typeCounters: pageContext.typeCounters,
|
|
60
60
|
pageId: pageContext.pageId,
|
|
61
61
|
checkDuplicateActionId
|
|
62
|
-
})
|
|
63
|
-
);
|
|
62
|
+
}));
|
|
64
63
|
block.events[key].catch.map((action)=>checkAction(action, {
|
|
65
64
|
eventId: key,
|
|
66
65
|
blockId: block.blockId,
|
|
67
66
|
typeCounters: pageContext.typeCounters,
|
|
68
67
|
pageId: pageContext.pageId,
|
|
69
68
|
checkDuplicateActionId
|
|
70
|
-
})
|
|
71
|
-
);
|
|
69
|
+
}));
|
|
72
70
|
});
|
|
73
71
|
}
|
|
74
72
|
}
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
import buildBlock from './buildBlock.js';
|
|
17
|
-
|
|
17
|
+
function buildSubBlocks(block, pageContext) {
|
|
18
18
|
if (type.isObject(block.areas)) {
|
|
19
|
-
let promises = [];
|
|
20
19
|
Object.keys(block.areas).forEach((key)=>{
|
|
21
20
|
if (type.isNone(block.areas[key].blocks)) {
|
|
22
21
|
block.areas[key].blocks = [];
|
|
@@ -24,12 +23,8 @@ async function buildSubBlocks(block, pageContext) {
|
|
|
24
23
|
if (!type.isArray(block.areas[key].blocks)) {
|
|
25
24
|
throw new Error(`Expected blocks to be an array at ${block.blockId} in area ${key} on page ${pageContext.pageId}. Received ${JSON.stringify(block.areas[key].blocks)}`);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
await buildBlock(blk, pageContext);
|
|
29
|
-
});
|
|
30
|
-
promises = promises.concat(blockPromises);
|
|
26
|
+
block.areas[key].blocks.map((blk)=>buildBlock(blk, pageContext));
|
|
31
27
|
});
|
|
32
|
-
await Promise.all(promises);
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
30
|
export default buildSubBlocks;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import buildBlock from './buildBlock/buildBlock.js';
|
|
17
17
|
import createCheckDuplicateId from '../../utils/createCheckDuplicateId.js';
|
|
18
18
|
import createCounter from '../../utils/createCounter.js';
|
|
19
|
-
|
|
19
|
+
function buildPage({ page , index , context , checkDuplicatePageId }) {
|
|
20
20
|
if (type.isUndefined(page.id)) {
|
|
21
21
|
throw new Error(`Page id missing at page ${index}.`);
|
|
22
22
|
}
|
|
@@ -29,7 +29,7 @@ async function buildPage({ page , index , context , checkDuplicatePageId }) {
|
|
|
29
29
|
page.pageId = page.id;
|
|
30
30
|
const requests = [];
|
|
31
31
|
const operators = new Set();
|
|
32
|
-
|
|
32
|
+
buildBlock(page, {
|
|
33
33
|
auth: page.auth,
|
|
34
34
|
blockIdCounter: createCounter(),
|
|
35
35
|
checkDuplicateRequestId: createCheckDuplicateId({
|
|
@@ -15,19 +15,17 @@
|
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
import buildPage from './buildPage.js';
|
|
17
17
|
import createCheckDuplicateId from '../../utils/createCheckDuplicateId.js';
|
|
18
|
-
|
|
18
|
+
function buildPages({ components , context }) {
|
|
19
19
|
const pages = type.isArray(components.pages) ? components.pages : [];
|
|
20
20
|
const checkDuplicatePageId = createCheckDuplicateId({
|
|
21
21
|
message: 'Duplicate pageId "{{ id }}".'
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
pages.map((page, index)=>buildPage({
|
|
24
24
|
page,
|
|
25
25
|
index,
|
|
26
26
|
context,
|
|
27
27
|
checkDuplicatePageId
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
await Promise.all(pageBuildPromises);
|
|
28
|
+
}));
|
|
31
29
|
return components;
|
|
32
30
|
}
|
|
33
31
|
export default buildPages;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
*/ // Used in @lowdefy/engine tests
|
|
16
|
+
import buildAuth from '../buildAuth/buildAuth.js';
|
|
17
|
+
import buildPages from './buildPages.js';
|
|
18
|
+
import createContext from '../../createContext.js';
|
|
19
|
+
function buildTestPage({ pageConfig }) {
|
|
20
|
+
const context = createContext({
|
|
21
|
+
customTypesMap: {},
|
|
22
|
+
directories: {},
|
|
23
|
+
logger: {
|
|
24
|
+
debug: ()=>{},
|
|
25
|
+
log: ()=>{},
|
|
26
|
+
warn: ()=>{},
|
|
27
|
+
error: ()=>{}
|
|
28
|
+
},
|
|
29
|
+
stage: 'test'
|
|
30
|
+
});
|
|
31
|
+
const components = {
|
|
32
|
+
pages: [
|
|
33
|
+
pageConfig
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
buildAuth({
|
|
37
|
+
components,
|
|
38
|
+
context
|
|
39
|
+
});
|
|
40
|
+
buildPages({
|
|
41
|
+
components,
|
|
42
|
+
context
|
|
43
|
+
});
|
|
44
|
+
return components.pages[0];
|
|
45
|
+
}
|
|
46
|
+
export default buildTestPage;
|
|
@@ -21,13 +21,12 @@ async function evaluateBuildOperators({ context , input , refDef }) {
|
|
|
21
21
|
});
|
|
22
22
|
const { output , errors } = operatorsParser.parse({
|
|
23
23
|
input,
|
|
24
|
-
location: refDef.path,
|
|
24
|
+
location: refDef.path ?? refDef.resolver,
|
|
25
25
|
operatorPrefix: '_build.'
|
|
26
26
|
});
|
|
27
27
|
if (errors.length > 0) {
|
|
28
28
|
await context.logger.warn('Build operator errors.');
|
|
29
|
-
const promises = errors.map((error)=>context.logger.warn(error.message)
|
|
30
|
-
);
|
|
29
|
+
const promises = errors.map((error)=>context.logger.warn(error.message));
|
|
31
30
|
await promises;
|
|
32
31
|
}
|
|
33
32
|
return output;
|
package/dist/build/buildTypes.js
CHANGED
|
@@ -39,10 +39,8 @@ function buildTypes({ components , context }) {
|
|
|
39
39
|
typeCounters.operators.client.increment('_not');
|
|
40
40
|
typeCounters.operators.client.increment('_type');
|
|
41
41
|
// Add loaders and basic
|
|
42
|
-
basicTypes.blocks.forEach((block)=>typeCounters.blocks.increment(block)
|
|
43
|
-
);
|
|
44
|
-
loaderTypes.blocks.forEach((block)=>typeCounters.blocks.increment(block)
|
|
45
|
-
);
|
|
42
|
+
basicTypes.blocks.forEach((block)=>typeCounters.blocks.increment(block));
|
|
43
|
+
loaderTypes.blocks.forEach((block)=>typeCounters.blocks.increment(block));
|
|
46
44
|
typeCounters.blocks.increment('Message'); // Used for DisplayMessage in @lowdefy/client
|
|
47
45
|
components.types = {
|
|
48
46
|
actions: {},
|
package/dist/build/testSchema.js
CHANGED
|
@@ -15,19 +15,18 @@
|
|
|
15
15
|
*/ import { validate } from '@lowdefy/ajv';
|
|
16
16
|
import lowdefySchema from '../lowdefySchema.js';
|
|
17
17
|
import formatErrorMessage from '../utils/formatErrorMessage.js';
|
|
18
|
-
|
|
18
|
+
function testSchema({ components , context }) {
|
|
19
19
|
const { valid , errors } = validate({
|
|
20
20
|
schema: lowdefySchema,
|
|
21
21
|
data: components,
|
|
22
22
|
returnErrors: true
|
|
23
23
|
});
|
|
24
24
|
if (!valid) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
context.logger.warn('Schema not valid.');
|
|
26
|
+
errors.map((error)=>context.logger.warn(formatErrorMessage({
|
|
27
27
|
error,
|
|
28
28
|
components
|
|
29
|
-
}))
|
|
30
|
-
));
|
|
29
|
+
})));
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
export default testSchema;
|
|
@@ -13,7 +13,7 @@
|
|
|
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
|
-
|
|
16
|
+
function validateApp({ components }) {
|
|
17
17
|
if (type.isNone(components.app)) {
|
|
18
18
|
components.app = {};
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
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
|
-
|
|
16
|
+
function validateConfig({ components }) {
|
|
17
17
|
if (type.isNone(components.config)) {
|
|
18
18
|
components.config = {};
|
|
19
19
|
}
|
package/dist/build/writePages.js
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* eslint-disable no-console */ /*
|
|
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 { mergeObjects } from '@lowdefy/helpers';
|
|
16
|
+
import createCounter from './utils/createCounter.js';
|
|
17
|
+
import createReadConfigFile from './utils/readConfigFile.js';
|
|
18
|
+
import createWriteBuildArtifact from './utils/writeBuildArtifact.js';
|
|
19
|
+
import defaultTypesMap from './defaultTypesMap.js';
|
|
20
|
+
function createContext({ customTypesMap , directories , logger , refResolver , stage ='prod' }) {
|
|
21
|
+
const context = {
|
|
22
|
+
directories,
|
|
23
|
+
logger,
|
|
24
|
+
readConfigFile: createReadConfigFile({
|
|
25
|
+
directories
|
|
26
|
+
}),
|
|
27
|
+
refResolver,
|
|
28
|
+
stage,
|
|
29
|
+
typeCounters: {
|
|
30
|
+
actions: createCounter(),
|
|
31
|
+
auth: {
|
|
32
|
+
callbacks: createCounter(),
|
|
33
|
+
events: createCounter(),
|
|
34
|
+
providers: createCounter()
|
|
35
|
+
},
|
|
36
|
+
blocks: createCounter(),
|
|
37
|
+
connections: createCounter(),
|
|
38
|
+
requests: createCounter(),
|
|
39
|
+
operators: {
|
|
40
|
+
client: createCounter(),
|
|
41
|
+
server: createCounter()
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
typesMap: mergeObjects([
|
|
45
|
+
defaultTypesMap,
|
|
46
|
+
customTypesMap
|
|
47
|
+
]),
|
|
48
|
+
writeBuildArtifact: createWriteBuildArtifact({
|
|
49
|
+
directories
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
54
|
+
export default createContext;
|