@lowdefy/build 4.0.0-alpha.1 → 4.0.0-alpha.12
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/404.js +37 -42
- package/dist/build/addDefaultPages/addDefaultPages.js +7 -3
- package/dist/build/buildAuth/buildAuth.js +10 -29
- package/dist/build/buildAuth/buildAuthPlugins.js +78 -0
- package/dist/build/buildAuth/buildPageAuth.js +50 -0
- package/dist/build/buildAuth/getPageRoles.js +3 -4
- package/dist/build/buildAuth/getProtectedPages.js +6 -6
- package/dist/build/buildAuth/validateAuthConfig.js +61 -0
- package/dist/build/buildConnections.js +2 -3
- package/dist/build/buildImports/buildIconImports.js +87 -0
- package/dist/build/buildImports/buildImports.js +30 -0
- package/dist/build/buildImports/buildImportsDev.js +103 -0
- package/dist/build/buildImports/buildImportsProd.js +54 -0
- package/dist/build/buildImports/buildStyleImports.js +28 -0
- package/dist/build/buildImports/defaultIconsDev.js +584 -0
- package/dist/build/buildImports/defaultIconsProd.js +21 -0
- package/dist/build/buildMenu.js +1 -1
- package/dist/build/buildPages/buildBlock/buildBlock.js +6 -2
- package/dist/build/buildPages/buildBlock/buildEvents.js +5 -2
- package/dist/build/buildPages/buildBlock/buildRequests.js +2 -3
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +1 -1
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +4 -6
- package/dist/build/buildPages/buildBlock/countBlockTypes.js +18 -0
- package/dist/build/buildPages/buildBlock/moveSkeletonBlocksToArea.js +35 -0
- package/dist/build/buildPages/buildBlock/moveSubBlocksToArea.js +1 -1
- package/dist/build/buildPages/buildBlock/setBlockId.js +1 -1
- package/dist/build/buildPages/buildBlock/validateBlock.js +2 -3
- package/dist/build/buildPages/buildPage.js +1 -1
- package/dist/build/buildPages/buildPages.js +1 -1
- package/dist/build/buildRefs/buildRefs.js +3 -3
- package/dist/build/buildRefs/evaluateBuildOperators.js +35 -0
- package/dist/build/buildRefs/getConfigFile.js +1 -1
- package/dist/build/buildRefs/getRefContent.js +2 -2
- package/dist/build/buildRefs/getRefPath.js +1 -1
- package/dist/build/buildRefs/getRefsFromFile.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +7 -4
- package/dist/build/buildRefs/makeRefDefinition.js +2 -3
- package/dist/build/buildRefs/parseNunjucks.js +1 -1
- package/dist/build/buildRefs/parseRefContent.js +3 -3
- package/dist/build/buildRefs/populateRefs.js +1 -1
- package/dist/build/buildRefs/recursiveBuild.js +10 -5
- package/dist/build/buildRefs/runRefResolver.js +1 -1
- package/dist/build/buildRefs/runTransformer.js +8 -4
- package/dist/build/buildTypes.js +72 -43
- package/dist/build/cleanBuildDirectory.js +2 -2
- package/dist/build/copyPublicFolder.js +23 -0
- package/dist/build/testSchema.js +3 -4
- package/dist/build/updateServerPackageJson.js +49 -0
- package/dist/build/validateApp.js +3 -5
- package/dist/build/validateConfig.js +8 -28
- package/dist/build/writeApp.js +2 -6
- package/dist/build/writeAuth.js +18 -0
- package/dist/build/writeConfig.js +2 -6
- package/dist/build/writeConnections.js +2 -5
- package/dist/build/writeGlobal.js +3 -7
- package/dist/build/writeMenus.js +2 -5
- package/dist/build/writePages.js +3 -14
- package/dist/build/writePluginImports/generateImportFile.js +31 -0
- package/dist/build/writePluginImports/writeActionImports.js +22 -0
- package/dist/build/writePluginImports/writeAuthImports.js +30 -0
- package/dist/build/writePluginImports/writeBlockImports.js +6 -23
- package/dist/build/writePluginImports/writeConnectionImports.js +6 -23
- package/dist/build/writePluginImports/writeIconImports.js +31 -0
- package/dist/build/writePluginImports/writeOperatorImports.js +26 -0
- package/dist/build/writePluginImports/writePluginImports.js +52 -0
- package/dist/build/writePluginImports/writeStyleImports.js +28 -0
- package/dist/build/writeRequests.js +3 -8
- package/dist/build/writeTypes.js +2 -5
- package/dist/defaultTypesMap.json +1874 -0
- package/dist/index.js +126 -112
- package/dist/lowdefySchema.js +173 -79
- package/dist/scripts/generateDefaultTypes.js +47 -75
- package/dist/scripts/run.js +14 -12
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +3 -6
- package/dist/test/buildRefs/testBuildRefsErrorResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsNullResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsParsingResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsTransform.js +2 -2
- package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +2 -2
- package/dist/test/testContext.js +12 -19
- package/dist/utils/countOperators.js +1 -1
- package/dist/utils/createCheckDuplicateId.js +1 -1
- package/dist/utils/createCounter.js +1 -1
- package/dist/utils/createPluginTypesMap.js +106 -0
- package/dist/utils/formatErrorMessage.js +2 -2
- package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +3 -3
- package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +4 -7
- package/package.json +48 -16
- package/dist/defaultTypes.json +0 -60
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,45 +12,40 @@
|
|
|
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
|
-
*/
|
|
16
|
-
export default {
|
|
15
|
+
*/ export default {
|
|
17
16
|
id: '404',
|
|
18
|
-
type: '
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// ],
|
|
54
|
-
// },
|
|
55
|
-
// },
|
|
56
|
-
// };
|
|
17
|
+
type: 'Result',
|
|
18
|
+
style: {
|
|
19
|
+
minHeight: '100vh'
|
|
20
|
+
},
|
|
21
|
+
properties: {
|
|
22
|
+
status: 404,
|
|
23
|
+
title: '404',
|
|
24
|
+
subTitle: 'Sorry, the page you are visiting does not exist.'
|
|
25
|
+
},
|
|
26
|
+
areas: {
|
|
27
|
+
extra: {
|
|
28
|
+
blocks: [
|
|
29
|
+
{
|
|
30
|
+
id: 'home',
|
|
31
|
+
type: 'Button',
|
|
32
|
+
properties: {
|
|
33
|
+
title: 'Go to home page',
|
|
34
|
+
type: 'Link'
|
|
35
|
+
},
|
|
36
|
+
events: {
|
|
37
|
+
onClick: [
|
|
38
|
+
{
|
|
39
|
+
id: 'home',
|
|
40
|
+
type: 'Link',
|
|
41
|
+
params: {
|
|
42
|
+
home: true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -26,8 +26,12 @@ async function addDefaultPages({ components }) {
|
|
|
26
26
|
if (!type.isArray(components.pages)) {
|
|
27
27
|
throw new Error('lowdefy.pages is not an array.');
|
|
28
28
|
}
|
|
29
|
-
const pageIds = components.pages.map((page)=>
|
|
30
|
-
|
|
29
|
+
const pageIds = components.pages.map((page, index)=>{
|
|
30
|
+
if (!type.isObject(page)) {
|
|
31
|
+
throw new Error(`pages[${index}] is not an object. Received ${JSON.stringify(page)}`);
|
|
32
|
+
}
|
|
33
|
+
return page.id;
|
|
34
|
+
});
|
|
31
35
|
// deep copy to avoid mutating defaultConfig
|
|
32
36
|
const filteredDefaultPages = defaultPages.filter((defaultPage)=>!pageIds.includes(defaultPage.id)
|
|
33
37
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -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
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
function buildAuth({ components }) {
|
|
19
|
-
|
|
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
|
-
|
|
22
|
+
buildPageAuth({
|
|
23
23
|
components
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,9 +13,8 @@
|
|
|
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.
|
|
17
|
-
const pageRoles = {
|
|
18
|
-
};
|
|
16
|
+
const roles = components.auth.pages.roles;
|
|
17
|
+
const pageRoles = {};
|
|
19
18
|
Object.keys(roles).forEach((roleName)=>{
|
|
20
19
|
roles[roleName].forEach((pageId)=>{
|
|
21
20
|
if (!pageRoles[pageId]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -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.
|
|
21
|
-
protectedPages = pageIds.filter((pageId)=>!components.
|
|
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.
|
|
23
|
+
} else if (components.auth.pages.protected === true) {
|
|
24
24
|
protectedPages = pageIds;
|
|
25
|
-
} else if (type.isArray(components.
|
|
26
|
-
protectedPages = components.
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -36,8 +36,7 @@ async function buildConnections({ components , context }) {
|
|
|
36
36
|
context.typeCounters.connections.increment(connection.type);
|
|
37
37
|
connection.connectionId = connection.id;
|
|
38
38
|
connection.id = `connection:${connection.id}`;
|
|
39
|
-
countOperators(connection.properties || {
|
|
40
|
-
}, {
|
|
39
|
+
countOperators(connection.properties || {}, {
|
|
41
40
|
counter: context.typeCounters.operators.server
|
|
42
41
|
});
|
|
43
42
|
});
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
*/ const iconPackages = {
|
|
16
|
+
'react-icons/ai': /"(Ai[A-Z0-9]\w*)"/gm,
|
|
17
|
+
'react-icons/bs': /"(Bs[A-Z0-9]\w*)"/gm,
|
|
18
|
+
'react-icons/bi': /"(Bi[A-Z0-9]\w*)"/gm,
|
|
19
|
+
'react-icons/di': /"(Di[A-Z0-9]\w*)"/gm,
|
|
20
|
+
'react-icons/fi': /"(Fi[A-Z0-9]\w*)"/gm,
|
|
21
|
+
'react-icons/fc': /"(Fc[A-Z0-9]\w*)"/gm,
|
|
22
|
+
'react-icons/fa': /"(Fa[A-Z0-9]\w*)"/gm,
|
|
23
|
+
'react-icons/gi': /"(Gi[A-Z0-9]\w*)"/gm,
|
|
24
|
+
'react-icons/go': /"(Go[A-Z0-9]\w*)"/gm,
|
|
25
|
+
'react-icons/gr': /"(Gr[A-Z0-9]\w*)"/gm,
|
|
26
|
+
'react-icons/hi': /"(Hi[A-Z0-9]\w*)"/gm,
|
|
27
|
+
'react-icons/im': /"(Im[A-Z0-9]\w*)"/gm,
|
|
28
|
+
'react-icons/io': /"(IoIos[A-Z0-9]\w*)"/gm,
|
|
29
|
+
'react-icons/io5': /"(Io[A-Z0-9]\w*)"/gm,
|
|
30
|
+
'react-icons/md': /"(Md[A-Z0-9]\w*)"/gm,
|
|
31
|
+
'react-icons/ri': /"(Ri[A-Z0-9]\w*)"/gm,
|
|
32
|
+
'react-icons/si': /"(Si[A-Z0-9]\w*)"/gm,
|
|
33
|
+
'react-icons/ti': /"(Ti[A-Z0-9]\w*)"/gm,
|
|
34
|
+
'react-icons/vsc': /"(Vsc[A-Z0-9]\w*)"/gm,
|
|
35
|
+
'react-icons/wi': /"(Wi[A-Z0-9]\w*)"/gm,
|
|
36
|
+
'react-icons/cg': /"(Cg[A-Z0-9]\w*)"/gm
|
|
37
|
+
};
|
|
38
|
+
function getConfigIcons({ components , icons , regex }) {
|
|
39
|
+
[
|
|
40
|
+
...JSON.stringify(components.global || {}).matchAll(regex)
|
|
41
|
+
].map((match)=>icons.add(match[1])
|
|
42
|
+
);
|
|
43
|
+
[
|
|
44
|
+
...JSON.stringify(components.menus || []).matchAll(regex)
|
|
45
|
+
].map((match)=>icons.add(match[1])
|
|
46
|
+
);
|
|
47
|
+
[
|
|
48
|
+
...JSON.stringify(components.pages || []).matchAll(regex)
|
|
49
|
+
].map((match)=>icons.add(match[1])
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function getBlockDefaultIcons({ blocks , context , icons , regex }) {
|
|
53
|
+
blocks.forEach((block)=>{
|
|
54
|
+
(context.typesMap.icons[block.typeName] || []).forEach((icon)=>{
|
|
55
|
+
[
|
|
56
|
+
...JSON.stringify(icon).matchAll(regex)
|
|
57
|
+
].map((match)=>icons.add(match[1])
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function buildIconImports({ blocks , components , context , defaults ={} }) {
|
|
63
|
+
const iconImports = [];
|
|
64
|
+
Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
|
|
65
|
+
defaults;
|
|
66
|
+
const icons = new Set(defaults[iconPackage]);
|
|
67
|
+
getConfigIcons({
|
|
68
|
+
components,
|
|
69
|
+
icons,
|
|
70
|
+
regex
|
|
71
|
+
});
|
|
72
|
+
getBlockDefaultIcons({
|
|
73
|
+
blocks,
|
|
74
|
+
context,
|
|
75
|
+
icons,
|
|
76
|
+
regex
|
|
77
|
+
});
|
|
78
|
+
iconImports.push({
|
|
79
|
+
icons: [
|
|
80
|
+
...icons
|
|
81
|
+
],
|
|
82
|
+
package: iconPackage
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return iconImports;
|
|
86
|
+
}
|
|
87
|
+
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,103 @@
|
|
|
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
|
+
})
|
|
42
|
+
).filter((type)=>pluginPackages.has(type.package)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function buildImportsDev({ components , context }) {
|
|
46
|
+
const pluginPackages = getPluginPackages({
|
|
47
|
+
components
|
|
48
|
+
});
|
|
49
|
+
const blocks = buildImportClassDev({
|
|
50
|
+
pluginPackages,
|
|
51
|
+
map: context.typesMap.blocks
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
actions: buildImportClassDev({
|
|
55
|
+
pluginPackages,
|
|
56
|
+
map: context.typesMap.actions
|
|
57
|
+
}),
|
|
58
|
+
auth: {
|
|
59
|
+
callbacks: buildImportClassDev({
|
|
60
|
+
pluginPackages,
|
|
61
|
+
map: context.typesMap.auth.callbacks
|
|
62
|
+
}),
|
|
63
|
+
events: buildImportClassDev({
|
|
64
|
+
pluginPackages,
|
|
65
|
+
map: context.typesMap.auth.events
|
|
66
|
+
}),
|
|
67
|
+
providers: buildImportClassDev({
|
|
68
|
+
pluginPackages,
|
|
69
|
+
map: context.typesMap.auth.providers
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
blocks,
|
|
73
|
+
connections: buildImportClassDev({
|
|
74
|
+
pluginPackages,
|
|
75
|
+
map: context.typesMap.connections
|
|
76
|
+
}),
|
|
77
|
+
icons: buildIconImports({
|
|
78
|
+
blocks,
|
|
79
|
+
components,
|
|
80
|
+
context,
|
|
81
|
+
defaults: defaultIconsDev
|
|
82
|
+
}),
|
|
83
|
+
requests: buildImportClassDev({
|
|
84
|
+
pluginPackages,
|
|
85
|
+
map: context.typesMap.requests
|
|
86
|
+
}),
|
|
87
|
+
operators: {
|
|
88
|
+
client: buildImportClassDev({
|
|
89
|
+
pluginPackages,
|
|
90
|
+
map: context.typesMap.operators.client
|
|
91
|
+
}),
|
|
92
|
+
server: buildImportClassDev({
|
|
93
|
+
pluginPackages,
|
|
94
|
+
map: context.typesMap.operators.server
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
styles: buildStyleImports({
|
|
98
|
+
blocks,
|
|
99
|
+
context
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export default buildImportsDev;
|