@lowdefy/build 4.0.0-alpha.6 → 4.0.0-alpha.9
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 +1 -1
- package/dist/build/addDefaultPages/addDefaultPages.js +7 -3
- package/dist/build/buildAuth/buildAuth.js +1 -1
- package/dist/build/buildAuth/getPageRoles.js +1 -1
- package/dist/build/buildAuth/getProtectedPages.js +1 -1
- package/dist/build/buildConnections.js +1 -1
- package/dist/build/buildIcons.js +3 -3
- 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 +1 -1
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +1 -1
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +2 -2
- 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 +2 -1
- 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 +1 -1
- 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 +9 -3
- package/dist/build/buildRefs/runRefResolver.js +1 -1
- package/dist/build/buildRefs/runTransformer.js +8 -4
- package/dist/build/buildStyles.js +3 -3
- package/dist/build/buildTypes.js +39 -20
- package/dist/build/cleanBuildDirectory.js +2 -2
- package/dist/build/copyPublicFolder.js +23 -0
- package/dist/build/testSchema.js +1 -1
- package/dist/build/updateServerPackageJson.js +2 -5
- package/dist/build/validateApp.js +1 -1
- package/dist/build/validateConfig.js +6 -1
- package/dist/build/writeApp.js +2 -5
- package/dist/build/writeConfig.js +2 -5
- package/dist/build/writeConnections.js +2 -5
- package/dist/build/writeGlobal.js +2 -5
- package/dist/build/writeMenus.js +2 -5
- package/dist/build/writePages.js +3 -14
- package/dist/build/writePluginImports/generateImportFile.js +7 -7
- package/dist/build/writePluginImports/writeActionImports.js +22 -0
- package/dist/build/writePluginImports/writeBlockImports.js +5 -8
- package/dist/build/writePluginImports/writeConnectionImports.js +5 -8
- package/dist/build/writePluginImports/writeIconImports.js +4 -7
- package/dist/build/writePluginImports/writeOperatorImports.js +9 -16
- package/dist/build/writePluginImports/writeStyleImports.js +5 -7
- package/dist/build/writeRequests.js +3 -8
- package/dist/build/writeTypes.js +2 -5
- package/dist/defaultTypesMap.json +1598 -0
- package/dist/index.js +134 -126
- package/dist/lowdefySchema.js +50 -12
- package/dist/scripts/generateDefaultTypes.js +26 -65
- package/dist/scripts/run.js +8 -4
- package/dist/test/buildRefs/testBuildRefsAsyncFunction.js +2 -2
- 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 +1 -1
- 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 +85 -0
- package/dist/utils/formatErrorMessage.js +2 -2
- package/dist/utils/{files/readConfigFile.js → readConfigFile.js} +1 -1
- package/dist/utils/{files/writeBuildArtifact.js → writeBuildArtifact.js} +3 -6
- package/package.json +41 -27
- package/dist/defaultTypes.json +0 -1159
|
@@ -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
|
);
|
package/dist/build/buildIcons.js
CHANGED
|
@@ -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.
|
|
@@ -50,8 +50,8 @@ function getConfigIcons({ components , icons , regex }) {
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
function getBlockDefaultIcons({ components , context , icons , regex }) {
|
|
53
|
-
Object.
|
|
54
|
-
context.
|
|
53
|
+
Object.keys(components.types.blocks).forEach((blockName)=>{
|
|
54
|
+
(context.typesMap.icons[blockName] || []).forEach((icon)=>{
|
|
55
55
|
[
|
|
56
56
|
...JSON.stringify(icon).matchAll(regex)
|
|
57
57
|
].map((match)=>icons.add(match[1])
|
package/dist/build/buildMenu.js
CHANGED
|
@@ -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.
|
|
@@ -16,16 +16,20 @@
|
|
|
16
16
|
import buildRequests from './buildRequests.js';
|
|
17
17
|
import buildSubBlocks from './buildSubBlocks.js';
|
|
18
18
|
import countBlockOperators from './countBlockOperators.js';
|
|
19
|
+
import countBlockTypes from './countBlockTypes.js';
|
|
19
20
|
import moveSubBlocksToArea from './moveSubBlocksToArea.js';
|
|
21
|
+
import moveSkeletonBlocksToArea from './moveSkeletonBlocksToArea.js';
|
|
20
22
|
import setBlockId from './setBlockId.js';
|
|
21
23
|
import validateBlock from './validateBlock.js';
|
|
22
24
|
async function buildBlock(block, pageContext) {
|
|
23
25
|
validateBlock(block, pageContext);
|
|
24
|
-
countBlockOperators(block, pageContext);
|
|
25
26
|
setBlockId(block, pageContext);
|
|
27
|
+
countBlockOperators(block, pageContext);
|
|
26
28
|
buildEvents(block, pageContext);
|
|
27
29
|
buildRequests(block, pageContext);
|
|
28
30
|
moveSubBlocksToArea(block, pageContext);
|
|
31
|
+
moveSkeletonBlocksToArea(block, pageContext);
|
|
32
|
+
countBlockTypes(block, pageContext);
|
|
29
33
|
await buildSubBlocks(block, pageContext);
|
|
30
34
|
}
|
|
31
35
|
export default buildBlock;
|
|
@@ -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.
|
|
@@ -44,7 +44,10 @@ function buildEvents(block, pageContext) {
|
|
|
44
44
|
if (!type.isArray(block.events[key].try)) {
|
|
45
45
|
throw new Error(`Events must be an array of actions at "${block.blockId}" in event "${key}" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].try)}`);
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
47
|
+
if (type.isNone(block.events[key].catch)) {
|
|
48
|
+
block.events[key].catch = [];
|
|
49
|
+
}
|
|
50
|
+
if (!type.isArray(block.events[key].catch)) {
|
|
48
51
|
throw new Error(`Catch events must be an array of actions at "${block.blockId}" in event "${key}" on page "${pageContext.pageId}". Received ${JSON.stringify(block.events[key].catch)}`);
|
|
49
52
|
}
|
|
50
53
|
const checkDuplicateActionId = createCheckDuplicateId({
|
|
@@ -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.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import countOperators from '../../../utils/countOperators.js';
|
|
16
16
|
function countBlockOperators(block, { typeCounters }) {
|
|
17
17
|
// eslint-disable-next-line no-unused-vars
|
|
18
|
-
const { requests ,
|
|
18
|
+
const { requests , areas , blocks , ...webBlock } = block;
|
|
19
19
|
countOperators(webBlock, {
|
|
20
20
|
counter: typeCounters.operators.client
|
|
21
21
|
});
|
|
@@ -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
|
+
*/ function countBlockTypes(block, { typeCounters }) {
|
|
16
|
+
typeCounters.blocks.increment(block.type);
|
|
17
|
+
}
|
|
18
|
+
export default countBlockTypes;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { set, type } from '@lowdefy/helpers';
|
|
16
|
+
function recMoveSkeletonBlocksToArea(block1, blockId, pageId) {
|
|
17
|
+
if (!type.isNone(block1.blocks)) {
|
|
18
|
+
if (!type.isArray(block1.blocks)) {
|
|
19
|
+
throw new Error(`Skeleton blocks at ${blockId} on page ${pageId} is not an array. Received ${JSON.stringify(block1.blocks)}`);
|
|
20
|
+
}
|
|
21
|
+
set(block1, 'areas.content.blocks', block1.blocks);
|
|
22
|
+
delete block1.blocks;
|
|
23
|
+
}
|
|
24
|
+
Object.keys(block1.areas || {}).forEach((area)=>{
|
|
25
|
+
block1.areas[area].blocks.forEach((block, i)=>{
|
|
26
|
+
recMoveSkeletonBlocksToArea(block, `${blockId}.areas.${area}.${i}.blocks`, pageId);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function moveSkeletonBlocksToArea(block, pageContext) {
|
|
31
|
+
if (type.isObject(block.skeleton)) {
|
|
32
|
+
recMoveSkeletonBlocksToArea(block.skeleton, `${block.blockId}.skeleton`, pageContext.pageId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default moveSkeletonBlocksToArea;
|
|
@@ -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,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
|
-
function validateBlock(block, { pageId
|
|
16
|
+
function validateBlock(block, { pageId }) {
|
|
17
17
|
if (!type.isObject(block)) {
|
|
18
18
|
throw new Error(`Expected block to be an object on page "${pageId}". Received ${JSON.stringify(block)}.`);
|
|
19
19
|
}
|
|
@@ -29,7 +29,6 @@ function validateBlock(block, { pageId , typeCounters }) {
|
|
|
29
29
|
if (!type.isString(block.type)) {
|
|
30
30
|
throw new Error(`Block type is not a string at "${block.id}" on page "${pageId}". Received ${JSON.stringify(block.type)}.`);
|
|
31
31
|
}
|
|
32
|
-
typeCounters.blocks.increment(block.type);
|
|
33
32
|
if (!type.isNone(block.requests)) {
|
|
34
33
|
if (!type.isArray(block.requests)) {
|
|
35
34
|
throw new Error(`Requests is not an array at "${block.id}" on page "${pageId}". Received ${JSON.stringify(block.requests)}`);
|
|
@@ -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.
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import recursiveBuild from './recursiveBuild.js';
|
|
16
16
|
import makeRefDefinition from './makeRefDefinition.js';
|
|
17
|
+
// TODO: build operators aren't evaluated in lowdefy.yaml file. Move recursive call up a layer or something.
|
|
17
18
|
async function buildRefs({ context }) {
|
|
18
19
|
const components = await recursiveBuild({
|
|
19
20
|
context,
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { NodeParser } from '@lowdefy/operators';
|
|
16
|
+
import operators from '@lowdefy/operators-js/operators/build';
|
|
17
|
+
async function evaluateBuildOperators({ context , input , refDef }) {
|
|
18
|
+
const operatorsParser = new NodeParser({
|
|
19
|
+
env: process.env,
|
|
20
|
+
operators
|
|
21
|
+
});
|
|
22
|
+
const { output , errors } = operatorsParser.parse({
|
|
23
|
+
input,
|
|
24
|
+
location: refDef.path,
|
|
25
|
+
operatorPrefix: '_build.'
|
|
26
|
+
});
|
|
27
|
+
if (errors.length > 0) {
|
|
28
|
+
await context.logger.warn('Build operator errors.');
|
|
29
|
+
const promises = errors.map((error)=>context.logger.warn(error.message)
|
|
30
|
+
);
|
|
31
|
+
await promises;
|
|
32
|
+
}
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
35
|
+
export default evaluateBuildOperators;
|
|
@@ -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,7 +17,7 @@ import parseRefContent from './parseRefContent.js';
|
|
|
17
17
|
import runRefResolver from './runRefResolver.js';
|
|
18
18
|
async function getRefContent({ context , refDef , referencedFrom }) {
|
|
19
19
|
let content;
|
|
20
|
-
if (refDef.path === 'lowdefy.yaml') {
|
|
20
|
+
if (refDef.path === 'lowdefy.yaml' || refDef.path === 'lowdefy.yml') {
|
|
21
21
|
content = await getConfigFile({
|
|
22
22
|
context,
|
|
23
23
|
refDef,
|
|
@@ -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,12 @@
|
|
|
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 { readFile } from '@lowdefy/node-utils';
|
|
17
16
|
async function getUserJavascriptFunction({ context , filePath }) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
try {
|
|
18
|
+
return (await import(path.resolve(context.directories.config, filePath))).default;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
context.logger.error(`Error importing ${filePath}.`);
|
|
21
|
+
throw Error(error);
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
export default getUserJavascriptFunction;
|
|
@@ -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.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
import { getFileExtension, getFileSubExtension } from '@lowdefy/node-utils';
|
|
17
17
|
import JSON5 from 'json5';
|
|
18
|
-
import YAML from '
|
|
18
|
+
import YAML from 'yaml';
|
|
19
19
|
import parseNunjucks from './parseNunjucks.js';
|
|
20
20
|
function parseRefContent({ content , refDef }) {
|
|
21
21
|
const { path , vars } = refDef;
|
|
@@ -26,7 +26,7 @@ function parseRefContent({ content , refDef }) {
|
|
|
26
26
|
ext = getFileSubExtension(path);
|
|
27
27
|
}
|
|
28
28
|
if (ext === 'yaml' || ext === 'yml') {
|
|
29
|
-
return YAML.
|
|
29
|
+
return YAML.parse(content);
|
|
30
30
|
}
|
|
31
31
|
if (ext === 'json') {
|
|
32
32
|
return JSON5.parse(content);
|
|
@@ -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,7 +12,8 @@
|
|
|
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 evaluateBuildOperators from './evaluateBuildOperators.js';
|
|
16
|
+
import getRefContent from './getRefContent.js';
|
|
16
17
|
import getRefsFromFile from './getRefsFromFile.js';
|
|
17
18
|
import populateRefs from './populateRefs.js';
|
|
18
19
|
import runTransformer from './runTransformer.js';
|
|
@@ -46,9 +47,14 @@ async function recursiveParseFile({ context , refDef , count , referencedFrom }
|
|
|
46
47
|
count: count + 1,
|
|
47
48
|
referencedFrom: refDef.path
|
|
48
49
|
});
|
|
50
|
+
const evaluatedOperators = await evaluateBuildOperators({
|
|
51
|
+
context,
|
|
52
|
+
input: parsedFile,
|
|
53
|
+
refDef: parsedRefDef
|
|
54
|
+
});
|
|
49
55
|
const transformedFile = await runTransformer({
|
|
50
56
|
context,
|
|
51
|
-
|
|
57
|
+
input: evaluatedOperators,
|
|
52
58
|
refDef: parsedRefDef
|
|
53
59
|
});
|
|
54
60
|
parsedFiles[newRefDef.id] = transformedFile;
|
|
@@ -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,14 +13,18 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import getUserJavascriptFunction from './getUserJavascriptFunction.js';
|
|
16
|
-
async function runTransformer({ context ,
|
|
16
|
+
async function runTransformer({ context , input , refDef }) {
|
|
17
17
|
if (refDef.transformer) {
|
|
18
18
|
const transformerFn = await getUserJavascriptFunction({
|
|
19
19
|
context,
|
|
20
20
|
filePath: refDef.transformer
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
try {
|
|
23
|
+
return transformerFn(input, refDef.vars);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw Error(`Error calling transformer "${refDef.transformer}" from "${refDef.path}": ${error.message}`);
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
|
-
return
|
|
28
|
+
return input;
|
|
25
29
|
}
|
|
26
30
|
export default runTransformer;
|
|
@@ -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.
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
components.styles = [];
|
|
17
17
|
const styles = new Set();
|
|
18
18
|
Object.entries(components.types.blocks).forEach(([blockName, block])=>{
|
|
19
|
-
styles.add(...(context.
|
|
19
|
+
styles.add(...(context.typesMap.styles.packages[block.package] || []).map((style)=>`${block.package}/${style}`
|
|
20
20
|
));
|
|
21
|
-
styles.add(...(context.
|
|
21
|
+
styles.add(...(context.typesMap.styles.blocks[blockName] || []).map((style)=>`${block.package}/${style}`
|
|
22
22
|
));
|
|
23
23
|
});
|
|
24
24
|
components.styles = [
|
package/dist/build/buildTypes.js
CHANGED
|
@@ -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,13 +12,20 @@
|
|
|
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
|
-
*/
|
|
15
|
+
*/ import basicTypes from '@lowdefy/blocks-basic/types';
|
|
16
|
+
import loaderTypes from '@lowdefy/blocks-loaders/types';
|
|
17
|
+
function buildTypeClass(context, { counter , definitions , store , typeClass , warnIfMissing =false }) {
|
|
16
18
|
const counts = counter.getCounts();
|
|
17
19
|
Object.keys(counts).forEach((typeName)=>{
|
|
18
20
|
if (!definitions[typeName]) {
|
|
21
|
+
if (warnIfMissing) {
|
|
22
|
+
context.logger.warn(`${typeClass} type "${typeName}" was used but is not defined.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
19
25
|
throw new Error(`${typeClass} type "${typeName}" was used but is not defined.`);
|
|
20
26
|
}
|
|
21
27
|
store[typeName] = {
|
|
28
|
+
originalTypeName: definitions[typeName].originalTypeName,
|
|
22
29
|
package: definitions[typeName].package,
|
|
23
30
|
version: definitions[typeName].version,
|
|
24
31
|
count: counts[typeName]
|
|
@@ -27,6 +34,16 @@
|
|
|
27
34
|
}
|
|
28
35
|
function buildTypes({ components , context }) {
|
|
29
36
|
const { typeCounters } = context;
|
|
37
|
+
// Add Mandatory Types
|
|
38
|
+
// Add operators used by form validation
|
|
39
|
+
typeCounters.operators.client.increment('_not');
|
|
40
|
+
typeCounters.operators.client.increment('_type');
|
|
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
|
+
);
|
|
46
|
+
typeCounters.blocks.increment('Message'); // Used for DisplayMessage in @lowdefy/client
|
|
30
47
|
components.types = {
|
|
31
48
|
actions: {},
|
|
32
49
|
blocks: {},
|
|
@@ -37,41 +54,43 @@ function buildTypes({ components , context }) {
|
|
|
37
54
|
server: {}
|
|
38
55
|
}
|
|
39
56
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
buildTypeClass({
|
|
57
|
+
buildTypeClass(context, {
|
|
58
|
+
counter: typeCounters.actions,
|
|
59
|
+
definitions: context.typesMap.actions,
|
|
60
|
+
store: components.types.actions,
|
|
61
|
+
typeClass: 'Action'
|
|
62
|
+
});
|
|
63
|
+
buildTypeClass(context, {
|
|
47
64
|
counter: typeCounters.blocks,
|
|
48
|
-
definitions: context.
|
|
65
|
+
definitions: context.typesMap.blocks,
|
|
49
66
|
store: components.types.blocks,
|
|
50
67
|
typeClass: 'Block'
|
|
51
68
|
});
|
|
52
|
-
buildTypeClass({
|
|
69
|
+
buildTypeClass(context, {
|
|
53
70
|
counter: typeCounters.connections,
|
|
54
|
-
definitions: context.
|
|
71
|
+
definitions: context.typesMap.connections,
|
|
55
72
|
store: components.types.connections,
|
|
56
73
|
typeClass: 'Connection'
|
|
57
74
|
});
|
|
58
|
-
buildTypeClass({
|
|
75
|
+
buildTypeClass(context, {
|
|
59
76
|
counter: typeCounters.requests,
|
|
60
|
-
definitions: context.
|
|
77
|
+
definitions: context.typesMap.requests,
|
|
61
78
|
store: components.types.requests,
|
|
62
79
|
typeClass: 'Request'
|
|
63
80
|
});
|
|
64
|
-
buildTypeClass({
|
|
81
|
+
buildTypeClass(context, {
|
|
65
82
|
counter: typeCounters.operators.client,
|
|
66
|
-
definitions: context.
|
|
83
|
+
definitions: context.typesMap.operators.client,
|
|
67
84
|
store: components.types.operators.client,
|
|
68
|
-
typeClass: 'Operator'
|
|
85
|
+
typeClass: 'Operator',
|
|
86
|
+
warnIfMissing: true
|
|
69
87
|
});
|
|
70
|
-
buildTypeClass({
|
|
88
|
+
buildTypeClass(context, {
|
|
71
89
|
counter: typeCounters.operators.server,
|
|
72
|
-
definitions: context.
|
|
90
|
+
definitions: context.typesMap.operators.server,
|
|
73
91
|
store: components.types.operators.server,
|
|
74
|
-
typeClass: 'Operator'
|
|
92
|
+
typeClass: 'Operator',
|
|
93
|
+
warnIfMissing: true
|
|
75
94
|
});
|
|
76
95
|
}
|
|
77
96
|
export default buildTypes;
|