@lowdefy/build 4.0.0-alpha.9 → 4.0.0-rc.1
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 +4 -4
- package/dist/build/addDefaultPages/addDefaultPages.js +3 -4
- package/dist/build/buildAuth/buildAuth.js +12 -28
- package/dist/build/buildAuth/buildAuthPlugins.js +71 -0
- package/dist/build/buildAuth/buildPageAuth.js +50 -0
- package/dist/build/buildAuth/getPageRoles.js +2 -2
- package/dist/build/buildAuth/getProtectedPages.js +7 -9
- package/dist/build/buildAuth/validateAuthConfig.js +64 -0
- package/dist/build/buildConnections.js +2 -2
- package/dist/build/{buildIcons.js → buildImports/buildIconImports.js} +26 -29
- package/dist/build/buildImports/buildImports.js +30 -0
- package/dist/build/buildImports/buildImportsDev.js +106 -0
- package/dist/build/buildImports/buildImportsProd.js +54 -0
- package/dist/build/{buildStyles.js → buildImports/buildStyleImports.js} +8 -12
- package/dist/build/buildImports/defaultIconsDev.js +584 -0
- package/dist/build/buildImports/defaultIconsProd.js +21 -0
- package/dist/build/buildMenu.js +11 -15
- package/dist/build/buildPages/buildBlock/buildBlock.js +3 -3
- package/dist/build/buildPages/buildBlock/buildEvents.js +8 -7
- package/dist/build/buildPages/buildBlock/buildRequests.js +1 -1
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +3 -8
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +1 -1
- package/dist/build/buildPages/buildBlock/countBlockTypes.js +1 -1
- package/dist/build/buildPages/buildBlock/moveSkeletonBlocksToArea.js +9 -9
- 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 +1 -1
- package/dist/build/buildPages/buildPage.js +3 -3
- package/dist/build/buildPages/buildPages.js +4 -6
- package/dist/build/buildPages/buildTestPage.js +46 -0
- package/dist/build/buildRefs/buildRefs.js +11 -5
- package/dist/build/buildRefs/evaluateBuildOperators.js +3 -4
- package/dist/build/buildRefs/getConfigFile.js +2 -2
- package/dist/build/buildRefs/getKey.js +24 -0
- package/dist/build/buildRefs/getRefContent.js +1 -1
- package/dist/build/buildRefs/getRefPath.js +1 -1
- package/dist/build/buildRefs/getRefsFromFile.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +3 -2
- package/dist/build/buildRefs/makeRefDefinition.js +2 -1
- package/dist/build/buildRefs/parseNunjucks.js +1 -1
- package/dist/build/buildRefs/parseRefContent.js +4 -4
- package/dist/build/buildRefs/populateRefs.js +4 -4
- package/dist/build/buildRefs/recursiveBuild.js +9 -5
- package/dist/build/buildRefs/runRefResolver.js +1 -1
- package/dist/build/buildRefs/runTransformer.js +1 -1
- package/dist/build/buildTypes.js +33 -5
- package/dist/build/cleanBuildDirectory.js +1 -1
- package/dist/build/copyPublicFolder.js +7 -4
- package/dist/build/testSchema.js +5 -7
- package/dist/build/updateServerPackageJson.js +5 -1
- package/dist/build/validateApp.js +2 -2
- package/dist/build/validateConfig.js +2 -29
- package/dist/build/writeApp.js +1 -1
- package/dist/build/writeAuth.js +18 -0
- package/dist/build/writeConfig.js +1 -1
- package/dist/build/writeConnections.js +1 -1
- package/dist/build/writeGlobal.js +1 -1
- package/dist/build/writeMenus.js +1 -1
- package/dist/build/writePages.js +2 -3
- package/dist/build/writePluginImports/generateImportFile.js +2 -7
- package/dist/build/writePluginImports/writeActionImports.js +2 -2
- package/dist/build/writePluginImports/writeAuthImports.js +34 -0
- package/dist/build/writePluginImports/writeBlockImports.js +2 -2
- package/dist/build/writePluginImports/writeConnectionImports.js +2 -2
- package/dist/build/writePluginImports/writeIconImports.js +2 -2
- package/dist/build/writePluginImports/writeOperatorImports.js +5 -5
- package/dist/build/writePluginImports/writePluginImports.js +52 -0
- package/dist/build/writePluginImports/writeStyleImports.js +9 -3
- package/dist/build/writeRequests.js +2 -3
- package/dist/build/writeTypes.js +1 -1
- package/dist/createContext.js +55 -0
- package/dist/{defaultTypesMap.json → defaultTypesMap.js} +922 -405
- package/dist/index.js +20 -78
- package/dist/lowdefySchema.js +176 -68
- package/dist/scripts/generateDefaultTypes.js +21 -3
- package/dist/scripts/run.js +5 -4
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +1 -1
- package/dist/test/buildRefs/testBuildRefsErrorResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsNullResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsParsingResolver.js +1 -1
- package/dist/test/buildRefs/testBuildRefsResolver.js +2 -2
- package/dist/test/buildRefs/testBuildRefsTransform.js +1 -1
- package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +1 -1
- package/dist/test/testContext.js +8 -2
- 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 +29 -1
- package/dist/utils/formatErrorMessage.js +1 -1
- package/dist/utils/readConfigFile.js +5 -2
- package/dist/utils/writeBuildArtifact.js +1 -1
- package/package.json +56 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
minHeight: '100vh'
|
|
20
20
|
},
|
|
21
21
|
properties: {
|
|
22
|
-
status:
|
|
22
|
+
status: 'info',
|
|
23
23
|
title: '404',
|
|
24
24
|
subTitle: 'Sorry, the page you are visiting does not exist.'
|
|
25
25
|
},
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
params: {
|
|
42
42
|
home: true
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
]
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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,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
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
24
|
+
components.auth.configured = configured;
|
|
25
|
+
buildPageAuth({
|
|
23
26
|
components
|
|
24
27
|
});
|
|
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
|
-
}
|
|
28
|
+
buildAuthPlugins({
|
|
29
|
+
components,
|
|
30
|
+
context
|
|
47
31
|
});
|
|
48
32
|
return components;
|
|
49
33
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2023 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 buildAuthPlugin({ counter , pluginConfig , typeClass }) {
|
|
17
|
+
if (type.isArray(pluginConfig)) {
|
|
18
|
+
pluginConfig.forEach((plugin)=>{
|
|
19
|
+
if (type.isUndefined(plugin.id)) {
|
|
20
|
+
throw new Error(`Auth ${typeClass} id missing.`);
|
|
21
|
+
}
|
|
22
|
+
if (!type.isString(plugin.id)) {
|
|
23
|
+
throw new Error(`Auth ${typeClass} id is not a string. Received ${JSON.stringify(plugin.id)}.`);
|
|
24
|
+
}
|
|
25
|
+
if (!type.isString(plugin.type)) {
|
|
26
|
+
throw new Error(`Auth ${typeClass} type is not a string at ${typeClass} "${plugin.id}". Received ${JSON.stringify(plugin.type)}.`);
|
|
27
|
+
}
|
|
28
|
+
counter.increment(plugin.type);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function buildAdapter({ components , context }) {
|
|
33
|
+
const { adapter } = components.auth;
|
|
34
|
+
if (type.isNone(adapter)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (type.isUndefined(adapter.id)) {
|
|
38
|
+
throw new Error(`Auth adapter id missing.`);
|
|
39
|
+
}
|
|
40
|
+
if (!type.isString(adapter.id)) {
|
|
41
|
+
throw new Error(`Auth adapter id is not a string. Received ${JSON.stringify(adapter.id)}.`);
|
|
42
|
+
}
|
|
43
|
+
if (!type.isString(adapter.type)) {
|
|
44
|
+
throw new Error(`Auth adapter type is not a string at adapter "${adapter.id}". Received ${JSON.stringify(adapter.type)}.`);
|
|
45
|
+
}
|
|
46
|
+
context.typeCounters.auth.adapters.increment(adapter.type);
|
|
47
|
+
}
|
|
48
|
+
function buildAuthPlugins({ components , context }) {
|
|
49
|
+
const counters = context.typeCounters.auth;
|
|
50
|
+
const authConfig = components.auth;
|
|
51
|
+
buildAdapter({
|
|
52
|
+
components,
|
|
53
|
+
context
|
|
54
|
+
});
|
|
55
|
+
buildAuthPlugin({
|
|
56
|
+
counter: counters.callbacks,
|
|
57
|
+
pluginConfig: authConfig.callbacks,
|
|
58
|
+
typeClass: 'callback'
|
|
59
|
+
});
|
|
60
|
+
buildAuthPlugin({
|
|
61
|
+
counter: counters.events,
|
|
62
|
+
pluginConfig: authConfig.events,
|
|
63
|
+
typeClass: 'event'
|
|
64
|
+
});
|
|
65
|
+
buildAuthPlugin({
|
|
66
|
+
counter: counters.providers,
|
|
67
|
+
pluginConfig: authConfig.providers,
|
|
68
|
+
typeClass: 'provider'
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export default buildAuthPlugins;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */ /*
|
|
2
|
+
Copyright 2020-2023 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-2023 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,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.
|
|
16
|
+
const roles = components.auth.pages.roles;
|
|
17
17
|
const pageRoles = {};
|
|
18
18
|
Object.keys(roles).forEach((roleName)=>{
|
|
19
19
|
roles[roleName].forEach((pageId)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -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.
|
|
21
|
-
protectedPages = pageIds.filter((pageId)=>!components.
|
|
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.
|
|
26
|
-
protectedPages = components.
|
|
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,64 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */ /*
|
|
2
|
+
Copyright 2020-2023 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.authPages)) {
|
|
26
|
+
components.auth.authPages = {};
|
|
27
|
+
}
|
|
28
|
+
if (type.isNone(components.auth.pages)) {
|
|
29
|
+
components.auth.pages = {};
|
|
30
|
+
}
|
|
31
|
+
if (type.isNone(components.auth.pages.roles)) {
|
|
32
|
+
components.auth.pages.roles = {};
|
|
33
|
+
}
|
|
34
|
+
if (type.isNone(components.auth.callbacks)) {
|
|
35
|
+
components.auth.callbacks = [];
|
|
36
|
+
}
|
|
37
|
+
if (type.isNone(components.auth.events)) {
|
|
38
|
+
components.auth.events = [];
|
|
39
|
+
}
|
|
40
|
+
if (type.isNone(components.auth.providers)) {
|
|
41
|
+
components.auth.providers = [];
|
|
42
|
+
}
|
|
43
|
+
if (type.isNone(components.auth.session)) {
|
|
44
|
+
components.auth.session = {};
|
|
45
|
+
}
|
|
46
|
+
if (type.isNone(components.auth.theme)) {
|
|
47
|
+
components.auth.theme = {};
|
|
48
|
+
}
|
|
49
|
+
validate({
|
|
50
|
+
schema: lowdefySchema.definitions.authConfig,
|
|
51
|
+
data: components.auth
|
|
52
|
+
});
|
|
53
|
+
if (components.auth.pages.protected === true && components.auth.pages.public === true || type.isArray(components.auth.pages.protected) && type.isArray(components.auth.pages.public)) {
|
|
54
|
+
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.');
|
|
55
|
+
}
|
|
56
|
+
if (components.auth.pages.protected === false) {
|
|
57
|
+
throw new Error('Protected pages can not be set to false.');
|
|
58
|
+
}
|
|
59
|
+
if (components.auth.pages.public === false) {
|
|
60
|
+
throw new Error('Public pages can not be set to false.');
|
|
61
|
+
}
|
|
62
|
+
return components;
|
|
63
|
+
}
|
|
64
|
+
export default validateAuthConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -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
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 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.
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ const iconPackages = {
|
|
16
16
|
'react-icons/ai': /"(Ai[A-Z0-9]\w*)"/gm,
|
|
17
|
-
'react-icons/bs': /"(Bs[A-Z0-9]\w*)"/gm,
|
|
18
17
|
'react-icons/bi': /"(Bi[A-Z0-9]\w*)"/gm,
|
|
18
|
+
'react-icons/bs': /"(Bs[A-Z0-9]\w*)"/gm,
|
|
19
|
+
'react-icons/cg': /"(Cg[A-Z0-9]\w*)"/gm,
|
|
20
|
+
'react-icons/ci': /"(Ci[A-Z0-9]\w*)"/gm,
|
|
19
21
|
'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
22
|
'react-icons/fa': /"(Fa[A-Z0-9]\w*)"/gm,
|
|
23
|
+
'react-icons/fc': /"(Fc[A-Z0-9]\w*)"/gm,
|
|
24
|
+
'react-icons/fi': /"(Fi[A-Z0-9]\w*)"/gm,
|
|
23
25
|
'react-icons/gi': /"(Gi[A-Z0-9]\w*)"/gm,
|
|
24
26
|
'react-icons/go': /"(Go[A-Z0-9]\w*)"/gm,
|
|
25
27
|
'react-icons/gr': /"(Gr[A-Z0-9]\w*)"/gm,
|
|
@@ -29,63 +31,58 @@
|
|
|
29
31
|
'react-icons/io5': /"(Io[A-Z0-9]\w*)"/gm,
|
|
30
32
|
'react-icons/md': /"(Md[A-Z0-9]\w*)"/gm,
|
|
31
33
|
'react-icons/ri': /"(Ri[A-Z0-9]\w*)"/gm,
|
|
34
|
+
'react-icons/rx': /"(Rx[A-Z0-9]\w*)"/gm,
|
|
32
35
|
'react-icons/si': /"(Si[A-Z0-9]\w*)"/gm,
|
|
36
|
+
'react-icons/sl': /"(Sl[A-Z0-9]\w*)"/gm,
|
|
37
|
+
'react-icons/tb': /"(Tb[A-Z0-9]\w*)"/gm,
|
|
38
|
+
'react-icons/tfi': /"(Tfi[A-Z0-9]\w*)"/gm,
|
|
33
39
|
'react-icons/ti': /"(Ti[A-Z0-9]\w*)"/gm,
|
|
34
40
|
'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
|
|
41
|
+
'react-icons/wi': /"(Wi[A-Z0-9]\w*)"/gm
|
|
37
42
|
};
|
|
38
43
|
function getConfigIcons({ components , icons , regex }) {
|
|
39
44
|
[
|
|
40
45
|
...JSON.stringify(components.global || {}).matchAll(regex)
|
|
41
|
-
].map((match)=>icons.add(match[1])
|
|
42
|
-
);
|
|
46
|
+
].map((match)=>icons.add(match[1]));
|
|
43
47
|
[
|
|
44
48
|
...JSON.stringify(components.menus || []).matchAll(regex)
|
|
45
|
-
].map((match)=>icons.add(match[1])
|
|
46
|
-
);
|
|
49
|
+
].map((match)=>icons.add(match[1]));
|
|
47
50
|
[
|
|
48
51
|
...JSON.stringify(components.pages || []).matchAll(regex)
|
|
49
|
-
].map((match)=>icons.add(match[1])
|
|
50
|
-
);
|
|
52
|
+
].map((match)=>icons.add(match[1]));
|
|
51
53
|
}
|
|
52
|
-
function getBlockDefaultIcons({
|
|
53
|
-
|
|
54
|
-
(context.typesMap.icons[
|
|
54
|
+
function getBlockDefaultIcons({ blocks , context , icons , regex }) {
|
|
55
|
+
blocks.forEach((block)=>{
|
|
56
|
+
(context.typesMap.icons[block.typeName] || []).forEach((icon)=>{
|
|
55
57
|
[
|
|
56
58
|
...JSON.stringify(icon).matchAll(regex)
|
|
57
|
-
].map((match)=>icons.add(match[1])
|
|
58
|
-
);
|
|
59
|
+
].map((match)=>icons.add(match[1]));
|
|
59
60
|
});
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
63
|
+
function buildIconImports({ blocks , components , context , defaults ={} }) {
|
|
64
|
+
const iconImports = [];
|
|
64
65
|
Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// Add default icons
|
|
68
|
-
if (iconPackage === 'react-icons/ai') {
|
|
69
|
-
icons.add('AiOutlineLoading3Quarters');
|
|
70
|
-
icons.add('AiOutlineExclamationCircle');
|
|
71
|
-
}
|
|
66
|
+
defaults;
|
|
67
|
+
const icons = new Set(defaults[iconPackage]);
|
|
72
68
|
getConfigIcons({
|
|
73
69
|
components,
|
|
74
70
|
icons,
|
|
75
71
|
regex
|
|
76
72
|
});
|
|
77
73
|
getBlockDefaultIcons({
|
|
78
|
-
|
|
74
|
+
blocks,
|
|
79
75
|
context,
|
|
80
76
|
icons,
|
|
81
77
|
regex
|
|
82
78
|
});
|
|
83
|
-
|
|
79
|
+
iconImports.push({
|
|
84
80
|
icons: [
|
|
85
81
|
...icons
|
|
86
82
|
],
|
|
87
83
|
package: iconPackage
|
|
88
84
|
});
|
|
89
85
|
});
|
|
86
|
+
return iconImports;
|
|
90
87
|
}
|
|
91
|
-
export default
|
|
88
|
+
export default buildIconImports;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2023 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,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2023 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.adapters);
|
|
27
|
+
getPackages(components.types.auth.callbacks);
|
|
28
|
+
getPackages(components.types.auth.events);
|
|
29
|
+
getPackages(components.types.auth.providers);
|
|
30
|
+
getPackages(components.types.blocks);
|
|
31
|
+
getPackages(components.types.connections);
|
|
32
|
+
getPackages(components.types.requests);
|
|
33
|
+
getPackages(components.types.operators.client);
|
|
34
|
+
getPackages(components.types.operators.server);
|
|
35
|
+
return pluginPackages;
|
|
36
|
+
}
|
|
37
|
+
function buildImportClassDev({ pluginPackages , map }) {
|
|
38
|
+
return Object.entries(map).map(([typeName, type])=>({
|
|
39
|
+
originalTypeName: type.originalTypeName,
|
|
40
|
+
package: type.package,
|
|
41
|
+
typeName
|
|
42
|
+
})).filter((type)=>pluginPackages.has(type.package));
|
|
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
|
+
adapters: buildImportClassDev({
|
|
59
|
+
pluginPackages,
|
|
60
|
+
map: context.typesMap.auth.adapters
|
|
61
|
+
}),
|
|
62
|
+
callbacks: buildImportClassDev({
|
|
63
|
+
pluginPackages,
|
|
64
|
+
map: context.typesMap.auth.callbacks
|
|
65
|
+
}),
|
|
66
|
+
events: buildImportClassDev({
|
|
67
|
+
pluginPackages,
|
|
68
|
+
map: context.typesMap.auth.events
|
|
69
|
+
}),
|
|
70
|
+
providers: buildImportClassDev({
|
|
71
|
+
pluginPackages,
|
|
72
|
+
map: context.typesMap.auth.providers
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
blocks,
|
|
76
|
+
connections: buildImportClassDev({
|
|
77
|
+
pluginPackages,
|
|
78
|
+
map: context.typesMap.connections
|
|
79
|
+
}),
|
|
80
|
+
icons: buildIconImports({
|
|
81
|
+
blocks,
|
|
82
|
+
components,
|
|
83
|
+
context,
|
|
84
|
+
defaults: defaultIconsDev
|
|
85
|
+
}),
|
|
86
|
+
requests: buildImportClassDev({
|
|
87
|
+
pluginPackages,
|
|
88
|
+
map: context.typesMap.requests
|
|
89
|
+
}),
|
|
90
|
+
operators: {
|
|
91
|
+
client: buildImportClassDev({
|
|
92
|
+
pluginPackages,
|
|
93
|
+
map: context.typesMap.operators.client
|
|
94
|
+
}),
|
|
95
|
+
server: buildImportClassDev({
|
|
96
|
+
pluginPackages,
|
|
97
|
+
map: context.typesMap.operators.server
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
styles: buildStyleImports({
|
|
101
|
+
blocks,
|
|
102
|
+
context
|
|
103
|
+
})
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export default buildImportsDev;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2023 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
|
+
adapters: buildImportClassProd(components.types.auth.adapters),
|
|
31
|
+
callbacks: buildImportClassProd(components.types.auth.callbacks),
|
|
32
|
+
events: buildImportClassProd(components.types.auth.events),
|
|
33
|
+
providers: buildImportClassProd(components.types.auth.providers)
|
|
34
|
+
},
|
|
35
|
+
blocks,
|
|
36
|
+
connections: buildImportClassProd(components.types.connections),
|
|
37
|
+
icons: buildIconImports({
|
|
38
|
+
blocks,
|
|
39
|
+
components,
|
|
40
|
+
context,
|
|
41
|
+
defaults: defaultIconsProd
|
|
42
|
+
}),
|
|
43
|
+
requests: buildImportClassProd(components.types.requests),
|
|
44
|
+
operators: {
|
|
45
|
+
client: buildImportClassProd(components.types.operators.client),
|
|
46
|
+
server: buildImportClassProd(components.types.operators.server)
|
|
47
|
+
},
|
|
48
|
+
styles: buildStyleImports({
|
|
49
|
+
blocks,
|
|
50
|
+
context
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export default buildImportsProd;
|