@lowdefy/build 4.0.0-alpha.9 → 4.0.0-rc.0
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 +11 -27
- package/dist/build/buildAuth/buildAuthPlugins.js +71 -0
- package/dist/build/buildAuth/buildPageAuth.js +50 -0
- package/dist/build/buildAuth/getPageRoles.js +1 -1
- package/dist/build/buildAuth/getProtectedPages.js +6 -8
- package/dist/build/buildAuth/validateAuthConfig.js +64 -0
- package/dist/build/buildConnections.js +1 -1
- package/dist/build/{buildIcons.js → buildImports/buildIconImports.js} +15 -23
- 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} +7 -11
- package/dist/build/buildImports/defaultIconsDev.js +584 -0
- package/dist/build/buildImports/defaultIconsProd.js +21 -0
- package/dist/build/buildMenu.js +9 -13
- package/dist/build/buildPages/buildBlock/buildBlock.js +2 -2
- package/dist/build/buildPages/buildBlock/buildEvents.js +7 -6
- 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/buildRefs.js +10 -4
- package/dist/build/buildRefs/evaluateBuildOperators.js +2 -3
- package/dist/build/buildRefs/getConfigFile.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +2 -1
- package/dist/build/buildRefs/makeRefDefinition.js +1 -0
- package/dist/build/buildRefs/parseRefContent.js +8 -3
- package/dist/build/buildRefs/populateRefs.js +3 -3
- package/dist/build/buildRefs/recursiveBuild.js +5 -5
- package/dist/build/buildTypes.js +32 -4
- package/dist/build/testSchema.js +4 -6
- package/dist/build/updateServerPackageJson.js +4 -0
- package/dist/build/validateApp.js +1 -1
- package/dist/build/validateConfig.js +1 -28
- package/dist/build/writeAuth.js +18 -0
- package/dist/build/writePages.js +1 -2
- package/dist/build/writePluginImports/generateImportFile.js +1 -6
- package/dist/build/writePluginImports/writeActionImports.js +1 -1
- package/dist/build/writePluginImports/writeAuthImports.js +34 -0
- package/dist/build/writePluginImports/writeBlockImports.js +1 -1
- package/dist/build/writePluginImports/writeConnectionImports.js +1 -1
- package/dist/build/writePluginImports/writeIconImports.js +1 -1
- package/dist/build/writePluginImports/writeOperatorImports.js +4 -4
- package/dist/build/writePluginImports/writePluginImports.js +52 -0
- package/dist/build/writePluginImports/writeStyleImports.js +8 -2
- package/dist/build/writeRequests.js +1 -2
- package/dist/createContext.js +55 -0
- package/dist/{defaultTypesMap.json → defaultTypesMap.js} +901 -399
- package/dist/index.js +19 -77
- package/dist/lowdefySchema.js +174 -66
- package/dist/scripts/generateDefaultTypes.js +20 -2
- package/dist/scripts/run.js +4 -3
- package/dist/test/buildRefs/testBuildRefsResolver.js +1 -1
- package/dist/test/testContext.js +7 -1
- package/dist/utils/createPluginTypesMap.js +28 -0
- package/dist/utils/readConfigFile.js +4 -1
- package/package.json +55 -44
|
@@ -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,13 @@ function buildEvents(block, pageContext) {
|
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
if (!type.isArray(block.events[key].try)) {
|
|
45
|
-
throw new Error(`
|
|
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)}`);
|
|
46
49
|
}
|
|
47
50
|
if (type.isNone(block.events[key].catch)) {
|
|
48
51
|
block.events[key].catch = [];
|
|
49
52
|
}
|
|
50
53
|
if (!type.isArray(block.events[key].catch)) {
|
|
51
|
-
throw new Error(`Catch
|
|
54
|
+
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
55
|
}
|
|
53
56
|
const checkDuplicateActionId = createCheckDuplicateId({
|
|
54
57
|
message: 'Duplicate actionId "{{ id }}" on event "{{ eventId }}" on block "{{ blockId }}" on page "{{ pageId }}".'
|
|
@@ -59,16 +62,14 @@ function buildEvents(block, pageContext) {
|
|
|
59
62
|
typeCounters: pageContext.typeCounters,
|
|
60
63
|
pageId: pageContext.pageId,
|
|
61
64
|
checkDuplicateActionId
|
|
62
|
-
})
|
|
63
|
-
);
|
|
65
|
+
}));
|
|
64
66
|
block.events[key].catch.map((action)=>checkAction(action, {
|
|
65
67
|
eventId: key,
|
|
66
68
|
blockId: block.blockId,
|
|
67
69
|
typeCounters: pageContext.typeCounters,
|
|
68
70
|
pageId: pageContext.pageId,
|
|
69
71
|
checkDuplicateActionId
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
+
}));
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -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;
|
|
@@ -14,13 +14,19 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import recursiveBuild from './recursiveBuild.js';
|
|
16
16
|
import makeRefDefinition from './makeRefDefinition.js';
|
|
17
|
-
|
|
17
|
+
import evaluateBuildOperators from './evaluateBuildOperators.js';
|
|
18
18
|
async function buildRefs({ context }) {
|
|
19
|
-
const
|
|
19
|
+
const refDef = makeRefDefinition('lowdefy.yaml');
|
|
20
|
+
let components = await recursiveBuild({
|
|
20
21
|
context,
|
|
21
|
-
refDef
|
|
22
|
+
refDef,
|
|
22
23
|
count: 0
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
+
components = await evaluateBuildOperators({
|
|
26
|
+
context,
|
|
27
|
+
input: components,
|
|
28
|
+
refDef
|
|
29
|
+
});
|
|
30
|
+
return components ?? {};
|
|
25
31
|
}
|
|
26
32
|
export default buildRefs;
|
|
@@ -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;
|
|
@@ -19,7 +19,7 @@ async function getConfigFile({ context , refDef , referencedFrom }) {
|
|
|
19
19
|
_ref: refDef.original
|
|
20
20
|
})} in file ${referencedFrom}`);
|
|
21
21
|
}
|
|
22
|
-
const content = context.readConfigFile(refDef.path);
|
|
22
|
+
const content = await context.readConfigFile(refDef.path);
|
|
23
23
|
if (content === null) {
|
|
24
24
|
throw new Error(`Tried to reference file "${refDef.path}" from "${referencedFrom}", but file does not exist.`);
|
|
25
25
|
}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import path from 'path';
|
|
16
|
+
import { pathToFileURL } from 'url';
|
|
16
17
|
async function getUserJavascriptFunction({ context , filePath }) {
|
|
17
18
|
try {
|
|
18
|
-
return (await import(path.
|
|
19
|
+
return (await import(pathToFileURL(path.join(context.directories.config, filePath)))).default;
|
|
19
20
|
} catch (error) {
|
|
20
21
|
context.logger.error(`Error importing ${filePath}.`);
|
|
21
22
|
throw Error(error);
|
|
@@ -20,6 +20,7 @@ function makeRefDefinition(refDefinition) {
|
|
|
20
20
|
id: uuid(),
|
|
21
21
|
original: refDefinition,
|
|
22
22
|
path: getRefPath(refDefinition),
|
|
23
|
+
key: get(refDefinition, 'key'),
|
|
23
24
|
resolver: get(refDefinition, 'resolver'),
|
|
24
25
|
transformer: get(refDefinition, 'transformer'),
|
|
25
26
|
vars: get(refDefinition, 'vars', {
|
|
@@ -12,7 +12,7 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
15
|
+
*/ /* eslint-disable no-param-reassign */ import { get, type } from '@lowdefy/helpers';
|
|
16
16
|
import { getFileExtension, getFileSubExtension } from '@lowdefy/node-utils';
|
|
17
17
|
import JSON5 from 'json5';
|
|
18
18
|
import YAML from 'yaml';
|
|
@@ -26,12 +26,17 @@ function parseRefContent({ content , refDef }) {
|
|
|
26
26
|
ext = getFileSubExtension(path);
|
|
27
27
|
}
|
|
28
28
|
if (ext === 'yaml' || ext === 'yml') {
|
|
29
|
-
|
|
29
|
+
content = YAML.parse(content);
|
|
30
30
|
}
|
|
31
31
|
if (ext === 'json') {
|
|
32
|
-
|
|
32
|
+
content = JSON5.parse(content);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
if (refDef.key) {
|
|
36
|
+
content = get(content, refDef.key, {
|
|
37
|
+
default: null
|
|
38
|
+
});
|
|
39
|
+
}
|
|
35
40
|
return content;
|
|
36
41
|
}
|
|
37
42
|
export default parseRefContent;
|
|
@@ -24,12 +24,12 @@ function refReviver(key, value) {
|
|
|
24
24
|
default: null
|
|
25
25
|
})));
|
|
26
26
|
}
|
|
27
|
-
if (type.isObject(value._var) && type.isString(value._var.
|
|
28
|
-
return JSON.parse(JSON.stringify(get(this.vars, value._var.
|
|
27
|
+
if (type.isObject(value._var) && type.isString(value._var.key)) {
|
|
28
|
+
return JSON.parse(JSON.stringify(get(this.vars, value._var.key, {
|
|
29
29
|
default: type.isNone(value._var.default) ? null : value._var.default
|
|
30
30
|
})));
|
|
31
31
|
}
|
|
32
|
-
throw new Error(`"_var" operator takes a string or object with
|
|
32
|
+
throw new Error(`"_var" operator takes a string or object with "key" field as arguments. Received "${JSON.stringify(value)}"`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return value;
|
|
@@ -33,7 +33,6 @@ async function recursiveParseFile({ context , refDef , count , referencedFrom }
|
|
|
33
33
|
// the deeper nodes, so we can use those parsed files in references higher in the tree.
|
|
34
34
|
// To do this, since foundRefs is an array of ref definitions that are in order of the
|
|
35
35
|
// deepest nodes first we for loop over over foundRefs one by one, awaiting each result.
|
|
36
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
37
36
|
for (const newRefDef of foundRefs.values()){
|
|
38
37
|
// Parse vars and path before passing down to parse new file
|
|
39
38
|
const parsedRefDef = populateRefs({
|
|
@@ -47,17 +46,18 @@ async function recursiveParseFile({ context , refDef , count , referencedFrom }
|
|
|
47
46
|
count: count + 1,
|
|
48
47
|
referencedFrom: refDef.path
|
|
49
48
|
});
|
|
50
|
-
const
|
|
49
|
+
const transformedFile = await runTransformer({
|
|
51
50
|
context,
|
|
52
51
|
input: parsedFile,
|
|
53
52
|
refDef: parsedRefDef
|
|
54
53
|
});
|
|
55
|
-
|
|
54
|
+
// Evaluated in recursive loop for better error messages
|
|
55
|
+
const evaluatedOperators = await evaluateBuildOperators({
|
|
56
56
|
context,
|
|
57
|
-
input:
|
|
57
|
+
input: transformedFile,
|
|
58
58
|
refDef: parsedRefDef
|
|
59
59
|
});
|
|
60
|
-
parsedFiles[newRefDef.id] =
|
|
60
|
+
parsedFiles[newRefDef.id] = evaluatedOperators;
|
|
61
61
|
}
|
|
62
62
|
return populateRefs({
|
|
63
63
|
toPopulate: fileContentBuiltRefs,
|
package/dist/build/buildTypes.js
CHANGED
|
@@ -39,13 +39,17 @@ 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: {},
|
|
47
|
+
auth: {
|
|
48
|
+
adapters: {},
|
|
49
|
+
callbacks: {},
|
|
50
|
+
events: {},
|
|
51
|
+
providers: {}
|
|
52
|
+
},
|
|
49
53
|
blocks: {},
|
|
50
54
|
connections: {},
|
|
51
55
|
requests: {},
|
|
@@ -60,6 +64,30 @@ function buildTypes({ components , context }) {
|
|
|
60
64
|
store: components.types.actions,
|
|
61
65
|
typeClass: 'Action'
|
|
62
66
|
});
|
|
67
|
+
buildTypeClass(context, {
|
|
68
|
+
counter: typeCounters.auth.adapters,
|
|
69
|
+
definitions: context.typesMap.auth.adapters,
|
|
70
|
+
store: components.types.auth.adapters,
|
|
71
|
+
typeClass: 'Auth adapter'
|
|
72
|
+
});
|
|
73
|
+
buildTypeClass(context, {
|
|
74
|
+
counter: typeCounters.auth.callbacks,
|
|
75
|
+
definitions: context.typesMap.auth.callbacks,
|
|
76
|
+
store: components.types.auth.callbacks,
|
|
77
|
+
typeClass: 'Auth callback'
|
|
78
|
+
});
|
|
79
|
+
buildTypeClass(context, {
|
|
80
|
+
counter: typeCounters.auth.events,
|
|
81
|
+
definitions: context.typesMap.auth.events,
|
|
82
|
+
store: components.types.auth.events,
|
|
83
|
+
typeClass: 'Auth event'
|
|
84
|
+
});
|
|
85
|
+
buildTypeClass(context, {
|
|
86
|
+
counter: typeCounters.auth.providers,
|
|
87
|
+
definitions: context.typesMap.auth.providers,
|
|
88
|
+
store: components.types.auth.providers,
|
|
89
|
+
typeClass: 'Auth provider'
|
|
90
|
+
});
|
|
63
91
|
buildTypeClass(context, {
|
|
64
92
|
counter: typeCounters.blocks,
|
|
65
93
|
definitions: context.typesMap.blocks,
|
package/dist/build/testSchema.js
CHANGED
|
@@ -15,20 +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
|
-
);
|
|
31
|
-
await promises;
|
|
29
|
+
})));
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
export default testSchema;
|
|
@@ -25,6 +25,10 @@ async function updateServerPackageJson({ components , context }) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
getPackages(components.types.actions);
|
|
28
|
+
getPackages(components.types.auth.adapters);
|
|
29
|
+
getPackages(components.types.auth.callbacks);
|
|
30
|
+
getPackages(components.types.auth.events);
|
|
31
|
+
getPackages(components.types.auth.providers);
|
|
28
32
|
getPackages(components.types.blocks);
|
|
29
33
|
getPackages(components.types.connections);
|
|
30
34
|
getPackages(components.types.requests);
|
|
@@ -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,45 +13,18 @@
|
|
|
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
|
-
|
|
17
|
-
import lowdefySchema from '../lowdefySchema.js';
|
|
18
|
-
async function validateConfig({ components }) {
|
|
16
|
+
function validateConfig({ components }) {
|
|
19
17
|
if (type.isNone(components.config)) {
|
|
20
18
|
components.config = {};
|
|
21
19
|
}
|
|
22
20
|
if (!type.isObject(components.config)) {
|
|
23
21
|
throw new Error('lowdefy.config is not an object.');
|
|
24
22
|
}
|
|
25
|
-
if (type.isNone(components.config.auth)) {
|
|
26
|
-
components.config.auth = {};
|
|
27
|
-
}
|
|
28
|
-
if (type.isNone(components.config.auth.pages)) {
|
|
29
|
-
components.config.auth.pages = {};
|
|
30
|
-
}
|
|
31
|
-
if (type.isNone(components.config.auth.pages.roles)) {
|
|
32
|
-
components.config.auth.pages.roles = {};
|
|
33
|
-
}
|
|
34
|
-
if (type.isNone(components.config.theme)) {
|
|
35
|
-
components.config.theme = {};
|
|
36
|
-
}
|
|
37
23
|
if (type.isString(components.config.basePath)) {
|
|
38
24
|
if (components.config.basePath[0] !== '/') {
|
|
39
25
|
throw Error('Base path must start with "/".');
|
|
40
26
|
}
|
|
41
27
|
}
|
|
42
|
-
validate({
|
|
43
|
-
schema: lowdefySchema.definitions.authConfig,
|
|
44
|
-
data: components.config.auth
|
|
45
|
-
});
|
|
46
|
-
if (components.config.auth.pages.protected === true && components.config.auth.pages.public === true || type.isArray(components.config.auth.pages.protected) && type.isArray(components.config.auth.pages.public)) {
|
|
47
|
-
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.');
|
|
48
|
-
}
|
|
49
|
-
if (components.config.auth.pages.protected === false) {
|
|
50
|
-
throw new Error('Protected pages can not be set to false.');
|
|
51
|
-
}
|
|
52
|
-
if (components.config.auth.pages.public === false) {
|
|
53
|
-
throw new Error('Public pages can not be set to false.');
|
|
54
|
-
}
|
|
55
28
|
return components;
|
|
56
29
|
}
|
|
57
30
|
export default validateConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
*/ async function writeAuth({ components , context }) {
|
|
16
|
+
await context.writeBuildArtifact('auth.json', JSON.stringify(components.auth || {}, null, 2));
|
|
17
|
+
}
|
|
18
|
+
export default writeAuth;
|
package/dist/build/writePages.js
CHANGED
|
@@ -21,13 +21,8 @@ export default {
|
|
|
21
21
|
{{ import.typeName }},
|
|
22
22
|
{% endfor -%}
|
|
23
23
|
};`;
|
|
24
|
-
function generateImportFile({
|
|
24
|
+
function generateImportFile({ imports , importPath }) {
|
|
25
25
|
const templateFn = nunjucksFunction(template);
|
|
26
|
-
const imports = Object.keys(types).map((typeName)=>({
|
|
27
|
-
typeName,
|
|
28
|
-
...types[typeName]
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
26
|
return templateFn({
|
|
32
27
|
imports,
|
|
33
28
|
importPath
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import generateImportFile from './generateImportFile.js';
|
|
16
16
|
async function writeActionImports({ components , context }) {
|
|
17
17
|
await context.writeBuildArtifact('plugins/actions.js', generateImportFile({
|
|
18
|
-
|
|
18
|
+
imports: components.imports.actions,
|
|
19
19
|
importPath: 'actions'
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 generateImportFile from './generateImportFile.js';
|
|
16
|
+
async function writeAuthImports({ components , context }) {
|
|
17
|
+
await context.writeBuildArtifact('plugins/auth/adapters.js', generateImportFile({
|
|
18
|
+
imports: components.imports.auth.adapters,
|
|
19
|
+
importPath: 'auth/adapters'
|
|
20
|
+
}));
|
|
21
|
+
await context.writeBuildArtifact('plugins/auth/callbacks.js', generateImportFile({
|
|
22
|
+
imports: components.imports.auth.callbacks,
|
|
23
|
+
importPath: 'auth/callbacks'
|
|
24
|
+
}));
|
|
25
|
+
await context.writeBuildArtifact('plugins/auth/events.js', generateImportFile({
|
|
26
|
+
imports: components.imports.auth.events,
|
|
27
|
+
importPath: 'auth/events'
|
|
28
|
+
}));
|
|
29
|
+
await context.writeBuildArtifact('plugins/auth/providers.js', generateImportFile({
|
|
30
|
+
imports: components.imports.auth.providers,
|
|
31
|
+
importPath: 'auth/providers'
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
export default writeAuthImports;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import generateImportFile from './generateImportFile.js';
|
|
16
16
|
async function writeBlockImports({ components , context }) {
|
|
17
17
|
await context.writeBuildArtifact('plugins/blocks.js', generateImportFile({
|
|
18
|
-
|
|
18
|
+
imports: components.imports.blocks,
|
|
19
19
|
importPath: 'blocks'
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import generateImportFile from './generateImportFile.js';
|
|
16
16
|
async function writeConnectionImports({ components , context }) {
|
|
17
17
|
await context.writeBuildArtifact('plugins/connections.js', generateImportFile({
|
|
18
|
-
|
|
18
|
+
imports: components.imports.connections,
|
|
19
19
|
importPath: 'connections'
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
async function writeIconImports({ components , context }) {
|
|
26
26
|
const templateFn = nunjucksFunction(template);
|
|
27
27
|
await context.writeBuildArtifact('plugins/icons.js', templateFn({
|
|
28
|
-
packages: components.icons
|
|
28
|
+
packages: components.imports.icons
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
export default writeIconImports;
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import generateImportFile from './generateImportFile.js';
|
|
16
16
|
async function writeOperatorImports({ components , context }) {
|
|
17
|
-
await context.writeBuildArtifact('plugins/
|
|
18
|
-
|
|
17
|
+
await context.writeBuildArtifact('plugins/operators/client.js', generateImportFile({
|
|
18
|
+
imports: components.imports.operators.client,
|
|
19
19
|
importPath: 'operators/client'
|
|
20
20
|
}));
|
|
21
|
-
await context.writeBuildArtifact('plugins/
|
|
22
|
-
|
|
21
|
+
await context.writeBuildArtifact('plugins/operators/server.js', generateImportFile({
|
|
22
|
+
imports: components.imports.operators.server,
|
|
23
23
|
importPath: 'operators/server'
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 writeActionImports from './writeActionImports.js';
|
|
16
|
+
import writeAuthImports from './writeAuthImports.js';
|
|
17
|
+
import writeBlockImports from './writeBlockImports.js';
|
|
18
|
+
import writeConnectionImports from './writeConnectionImports.js';
|
|
19
|
+
import writeIconImports from './writeIconImports.js';
|
|
20
|
+
import writeOperatorImports from './writeOperatorImports.js';
|
|
21
|
+
import writeStyleImports from './writeStyleImports.js';
|
|
22
|
+
async function writePluginImports({ components , context }) {
|
|
23
|
+
await writeActionImports({
|
|
24
|
+
components,
|
|
25
|
+
context
|
|
26
|
+
});
|
|
27
|
+
await writeAuthImports({
|
|
28
|
+
components,
|
|
29
|
+
context
|
|
30
|
+
});
|
|
31
|
+
await writeBlockImports({
|
|
32
|
+
components,
|
|
33
|
+
context
|
|
34
|
+
});
|
|
35
|
+
await writeConnectionImports({
|
|
36
|
+
components,
|
|
37
|
+
context
|
|
38
|
+
});
|
|
39
|
+
await writeIconImports({
|
|
40
|
+
components,
|
|
41
|
+
context
|
|
42
|
+
});
|
|
43
|
+
await writeOperatorImports({
|
|
44
|
+
components,
|
|
45
|
+
context
|
|
46
|
+
});
|
|
47
|
+
await writeStyleImports({
|
|
48
|
+
components,
|
|
49
|
+
context
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export default writePluginImports;
|