@lowdefy/build 4.5.2 → 4.7.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/404.js +1 -1
- package/dist/build/addDefaultPages/addDefaultPages.js +10 -4
- package/dist/build/addKeys.js +85 -29
- package/dist/build/buildApi/buildApi.js +27 -8
- package/dist/build/buildApi/buildEndpoint.js +7 -1
- package/dist/build/buildApi/buildRoutine/buildControl.js +1 -1
- package/dist/build/buildApi/buildRoutine/buildRoutine.js +1 -1
- package/dist/build/buildApi/buildRoutine/buildStep.js +1 -1
- package/dist/build/buildApi/buildRoutine/controlTypes.js +34 -11
- package/dist/build/buildApi/buildRoutine/countControl.js +1 -1
- package/dist/build/buildApi/buildRoutine/countStepTypes.js +2 -2
- package/dist/build/buildApi/buildRoutine/setStepId.js +1 -1
- package/dist/build/buildApi/buildRoutine/validateStep.js +30 -9
- package/dist/build/buildApi/validateEndpoint.js +36 -7
- package/dist/build/buildApi/validateStepReferences.js +65 -0
- package/dist/build/buildApp.js +1 -1
- package/dist/build/buildAuth/buildApiAuth.js +7 -3
- package/dist/build/buildAuth/buildAuth.js +7 -4
- package/dist/build/buildAuth/buildAuthPlugins.js +42 -13
- package/dist/build/buildAuth/buildPageAuth.js +14 -3
- package/dist/build/buildAuth/getApiRoles.js +1 -1
- package/dist/build/buildAuth/getPageRoles.js +1 -1
- package/dist/build/buildAuth/getProtectedApi.js +1 -1
- package/dist/build/buildAuth/getProtectedPages.js +1 -1
- package/dist/build/buildAuth/validateAuthConfig.js +39 -5
- package/dist/build/buildAuth/validateMutualExclusivity.js +13 -5
- package/dist/build/buildConnections.js +23 -24
- package/dist/build/buildImports/buildIconImports.js +1 -1
- package/dist/build/buildImports/buildImports.js +1 -1
- package/dist/build/buildImports/buildImportsDev.js +1 -1
- package/dist/build/buildImports/buildImportsProd.js +1 -1
- package/dist/build/buildImports/buildStyleImports.js +1 -1
- package/dist/build/buildImports/defaultIconsDev.js +1 -1
- package/dist/build/buildImports/defaultIconsProd.js +1 -1
- package/dist/build/buildJs/generateJsFile.js +1 -1
- package/dist/build/buildJs/jsMapParser.js +1 -1
- package/dist/build/buildJs/writeJs.js +1 -1
- package/dist/build/buildLogger.js +41 -0
- package/dist/build/buildMenu.js +36 -12
- package/dist/build/buildPages/buildBlock/buildBlock.js +1 -1
- package/dist/build/buildPages/buildBlock/buildEvents.js +79 -9
- package/dist/build/buildPages/buildBlock/buildRequests.js +38 -8
- package/dist/build/buildPages/buildBlock/buildSubBlocks.js +6 -2
- package/dist/build/buildPages/buildBlock/countBlockOperators.js +1 -1
- package/dist/build/buildPages/buildBlock/countBlockTypes.js +2 -2
- package/dist/build/buildPages/buildBlock/moveSkeletonBlocksToArea.js +6 -2
- package/dist/build/buildPages/buildBlock/moveSubBlocksToArea.js +6 -2
- package/dist/build/buildPages/buildBlock/setBlockId.js +1 -1
- package/dist/build/buildPages/buildBlock/validateBlock.js +25 -7
- package/dist/build/buildPages/buildPage.js +35 -6
- package/dist/build/buildPages/validateLinkReferences.js +33 -0
- package/dist/build/buildPages/validatePayloadReferences.js +59 -0
- package/dist/build/buildPages/validateRequestReferences.js +33 -0
- package/dist/build/buildPages/validateServerStateReferences.js +41 -0
- package/dist/build/buildPages/validateStateReferences.js +79 -0
- package/dist/build/buildRefs/buildRefs.js +40 -7
- package/dist/build/buildRefs/evaluateStaticOperators.js +52 -0
- package/dist/build/buildRefs/getConfigFile.js +25 -6
- package/dist/build/buildRefs/getKey.js +1 -1
- package/dist/build/buildRefs/getRefContent.js +1 -1
- package/dist/build/buildRefs/getRefPath.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +18 -4
- package/dist/build/buildRefs/makeRefDefinition.js +10 -5
- package/dist/build/buildRefs/parseNunjucks.js +1 -1
- package/dist/build/buildRefs/parseRefContent.js +108 -7
- package/dist/build/buildRefs/runRefResolver.js +11 -3
- package/dist/build/buildRefs/runTransformer.js +7 -3
- package/dist/build/buildRefs/walker.js +340 -0
- package/dist/build/buildTypes.js +22 -7
- package/dist/build/cleanBuildDirectory.js +1 -1
- package/dist/build/collectDynamicIdentifiers.js +35 -0
- package/dist/build/collectTypeNames.js +36 -0
- package/dist/build/copyPublicFolder.js +1 -1
- package/dist/build/{buildJs → full}/buildJs.js +3 -3
- package/dist/build/full/buildPages.js +87 -0
- package/dist/build/{buildPages → full}/buildTestPage.js +15 -3
- package/dist/build/{updateServerPackageJson.js → full/updateServerPackageJson.js} +1 -1
- package/dist/build/{writePages.js → full/writePages.js} +1 -1
- package/dist/build/{writeRequests.js → full/writeRequests.js} +11 -3
- package/dist/build/{writeTypes.js → full/writeTypes.js} +1 -1
- package/dist/build/jit/addInstalledTypes.js +51 -0
- package/dist/build/jit/buildJsShallow.js +41 -0
- package/dist/build/jit/buildPageJit.js +271 -0
- package/dist/build/jit/buildShallowPages.js +90 -0
- package/dist/build/jit/createPageRegistry.js +85 -0
- package/dist/build/jit/detectMissingPluginPackages.js +62 -0
- package/dist/build/jit/isPageContentPath.js +24 -0
- package/dist/build/jit/pageContentKeys.js +26 -0
- package/dist/build/jit/shallowBuild.js +242 -0
- package/dist/build/jit/updateServerPackageJsonJit.js +33 -0
- package/dist/build/jit/validatePageTypes.js +73 -0
- package/dist/build/jit/writePageJit.js +44 -0
- package/dist/build/jit/writePageRegistry.js +23 -0
- package/dist/build/jit/writeSourcelessPages.js +23 -0
- package/dist/build/testSchema.js +45 -7
- package/dist/build/validateConfig.js +2 -2
- package/dist/build/validateOperatorsDynamic.js +28 -0
- package/dist/build/writeApi.js +1 -1
- package/dist/build/writeApp.js +1 -1
- package/dist/build/writeAuth.js +1 -1
- package/dist/build/writeConfig.js +1 -1
- package/dist/build/writeConnections.js +1 -1
- package/dist/build/writeGlobal.js +1 -1
- package/dist/build/writeLogger.js +19 -0
- package/dist/build/writeMaps.js +1 -1
- package/dist/build/writeMenus.js +1 -1
- package/dist/build/writePluginImports/generateImportFile.js +1 -1
- package/dist/build/writePluginImports/writeActionImports.js +1 -1
- package/dist/build/writePluginImports/writeActionSchemaMap.js +42 -0
- package/dist/build/writePluginImports/writeAuthImports.js +1 -1
- package/dist/build/writePluginImports/writeBlockImports.js +1 -1
- package/dist/build/writePluginImports/writeBlockSchemaMap.js +42 -0
- package/dist/build/writePluginImports/writeConnectionImports.js +1 -1
- package/dist/build/writePluginImports/writeIconImports.js +1 -1
- package/dist/build/writePluginImports/writeOperatorImports.js +1 -1
- package/dist/build/writePluginImports/writeOperatorSchemaMap.js +49 -0
- package/dist/build/writePluginImports/writePluginImports.js +16 -1
- package/dist/build/writePluginImports/writeStyleImports.js +1 -1
- package/dist/createContext.js +16 -4
- package/dist/defaultTypesMap.js +479 -457
- package/dist/index.js +190 -127
- package/dist/indexDev.js +19 -0
- package/dist/lowdefySchema.js +588 -0
- package/dist/scripts/generateDefaultTypes.js +2 -1
- package/dist/scripts/run.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsAsyncFunction.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsErrorResolver.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsNullResolver.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsParsingResolver.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsResolver.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsTransform.js +1 -1
- package/dist/{test → test-utils}/buildRefs/testBuildRefsTransformIdentity.js +1 -1
- package/dist/test-utils/buildRefs/testJitPageResolver.js +24 -0
- package/dist/test-utils/createTestLogger.js +36 -0
- package/dist/test-utils/parseTestYaml.js +126 -0
- package/dist/test-utils/runBuild.js +228 -0
- package/dist/test-utils/runBuildForSnapshots.js +704 -0
- package/dist/{test → test-utils}/testContext.js +12 -2
- package/dist/utils/collectExceptions.js +34 -0
- package/dist/utils/countOperators.js +31 -12
- package/dist/utils/createBuildHandleError.js +38 -0
- package/dist/utils/createCheckDuplicateId.js +15 -9
- package/dist/utils/createCounter.js +16 -3
- package/dist/utils/createHandleWarning.js +41 -0
- package/dist/utils/createPluginTypesMap.js +1 -1
- package/dist/utils/extractOperatorKey.js +36 -0
- package/dist/utils/findConfigKey.js +37 -0
- package/dist/utils/findSimilarString.js +53 -0
- package/dist/utils/logCollectedErrors.js +30 -0
- package/dist/utils/makeId.js +16 -8
- package/dist/utils/preserveMetaProperties.js +27 -0
- package/dist/utils/readConfigFile.js +1 -1
- package/dist/utils/setNonEnumerableProperty.js +23 -0
- package/dist/utils/traverseConfig.js +43 -0
- package/dist/utils/tryBuildStep.js +46 -0
- package/dist/utils/writeBuildArtifact.js +1 -1
- package/package.json +46 -41
- package/dist/build/buildPages/buildPages.js +0 -31
- package/dist/build/buildRefs/evaluateBuildOperators.js +0 -34
- package/dist/build/buildRefs/getRefsFromFile.js +0 -37
- package/dist/build/buildRefs/populateRefs.js +0 -43
- package/dist/build/buildRefs/recursiveBuild.js +0 -85
- package/dist/utils/formatErrorMessage.js +0 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/build",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -38,20 +38,22 @@
|
|
|
38
38
|
},
|
|
39
39
|
"exports": {
|
|
40
40
|
".": "./dist/index.js",
|
|
41
|
-
"./
|
|
41
|
+
"./dev": "./dist/indexDev.js",
|
|
42
|
+
"./buildTestPage": "./dist/build/full/buildTestPage.js"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
44
45
|
"dist/*"
|
|
45
46
|
],
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@lowdefy/ajv": "4.
|
|
48
|
-
"@lowdefy/blocks-basic": "4.
|
|
49
|
-
"@lowdefy/blocks-loaders": "4.
|
|
50
|
-
"@lowdefy/
|
|
51
|
-
"@lowdefy/
|
|
52
|
-
"@lowdefy/
|
|
53
|
-
"@lowdefy/
|
|
54
|
-
"@lowdefy/operators
|
|
48
|
+
"@lowdefy/ajv": "4.7.0",
|
|
49
|
+
"@lowdefy/blocks-basic": "4.7.0",
|
|
50
|
+
"@lowdefy/blocks-loaders": "4.7.0",
|
|
51
|
+
"@lowdefy/errors": "4.7.0",
|
|
52
|
+
"@lowdefy/helpers": "4.7.0",
|
|
53
|
+
"@lowdefy/node-utils": "4.7.0",
|
|
54
|
+
"@lowdefy/nunjucks": "4.7.0",
|
|
55
|
+
"@lowdefy/operators": "4.7.0",
|
|
56
|
+
"@lowdefy/operators-js": "4.7.0",
|
|
55
57
|
"ajv": "8.12.0",
|
|
56
58
|
"json5": "2.2.3",
|
|
57
59
|
"yaml": "2.3.4",
|
|
@@ -59,40 +61,43 @@
|
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@jest/globals": "28.1.3",
|
|
62
|
-
"@lowdefy/actions-core": "4.
|
|
63
|
-
"@lowdefy/actions-pdf-make": "4.
|
|
64
|
-
"@lowdefy/blocks-aggrid": "4.
|
|
65
|
-
"@lowdefy/blocks-algolia": "4.
|
|
66
|
-
"@lowdefy/blocks-antd": "4.
|
|
67
|
-
"@lowdefy/blocks-color-selectors": "4.
|
|
68
|
-
"@lowdefy/blocks-echarts": "4.
|
|
69
|
-
"@lowdefy/blocks-google-maps": "4.
|
|
70
|
-
"@lowdefy/blocks-markdown": "4.
|
|
71
|
-
"@lowdefy/blocks-qr": "4.
|
|
72
|
-
"@lowdefy/connection-axios-http": "4.
|
|
73
|
-
"@lowdefy/connection-elasticsearch": "4.
|
|
74
|
-
"@lowdefy/connection-
|
|
75
|
-
"@lowdefy/connection-
|
|
76
|
-
"@lowdefy/connection-
|
|
77
|
-
"@lowdefy/connection-
|
|
78
|
-
"@lowdefy/connection-
|
|
79
|
-
"@lowdefy/connection-
|
|
80
|
-
"@lowdefy/
|
|
81
|
-
"@lowdefy/operators-
|
|
82
|
-
"@lowdefy/operators-
|
|
83
|
-
"@lowdefy/operators-
|
|
84
|
-
"@lowdefy/operators-
|
|
85
|
-
"@lowdefy/operators-
|
|
86
|
-
"@lowdefy/operators-
|
|
87
|
-
"@lowdefy/operators-
|
|
88
|
-
"@lowdefy/
|
|
89
|
-
"@lowdefy/plugin-
|
|
90
|
-
"@lowdefy/plugin-
|
|
91
|
-
"@lowdefy/plugin-
|
|
64
|
+
"@lowdefy/actions-core": "4.7.0",
|
|
65
|
+
"@lowdefy/actions-pdf-make": "4.7.0",
|
|
66
|
+
"@lowdefy/blocks-aggrid": "4.7.0",
|
|
67
|
+
"@lowdefy/blocks-algolia": "4.7.0",
|
|
68
|
+
"@lowdefy/blocks-antd": "4.7.0",
|
|
69
|
+
"@lowdefy/blocks-color-selectors": "4.7.0",
|
|
70
|
+
"@lowdefy/blocks-echarts": "4.7.0",
|
|
71
|
+
"@lowdefy/blocks-google-maps": "4.7.0",
|
|
72
|
+
"@lowdefy/blocks-markdown": "4.7.0",
|
|
73
|
+
"@lowdefy/blocks-qr": "4.7.0",
|
|
74
|
+
"@lowdefy/connection-axios-http": "4.7.0",
|
|
75
|
+
"@lowdefy/connection-elasticsearch": "4.7.0",
|
|
76
|
+
"@lowdefy/connection-test": "4.7.0",
|
|
77
|
+
"@lowdefy/connection-google-sheets": "4.7.0",
|
|
78
|
+
"@lowdefy/connection-knex": "4.7.0",
|
|
79
|
+
"@lowdefy/connection-mongodb": "4.7.0",
|
|
80
|
+
"@lowdefy/connection-redis": "4.7.0",
|
|
81
|
+
"@lowdefy/connection-sendgrid": "4.7.0",
|
|
82
|
+
"@lowdefy/connection-stripe": "4.7.0",
|
|
83
|
+
"@lowdefy/operators-change-case": "4.7.0",
|
|
84
|
+
"@lowdefy/operators-diff": "4.7.0",
|
|
85
|
+
"@lowdefy/operators-jsonata": "4.7.0",
|
|
86
|
+
"@lowdefy/operators-moment": "4.7.0",
|
|
87
|
+
"@lowdefy/operators-mql": "4.7.0",
|
|
88
|
+
"@lowdefy/operators-nunjucks": "4.7.0",
|
|
89
|
+
"@lowdefy/operators-uuid": "4.7.0",
|
|
90
|
+
"@lowdefy/operators-yaml": "4.7.0",
|
|
91
|
+
"@lowdefy/plugin-auth0": "4.7.0",
|
|
92
|
+
"@lowdefy/plugin-aws": "4.7.0",
|
|
93
|
+
"@lowdefy/plugin-csv": "4.7.0",
|
|
94
|
+
"@lowdefy/plugin-next-auth": "4.7.0",
|
|
92
95
|
"@swc/cli": "0.1.63",
|
|
93
96
|
"@swc/core": "1.3.99",
|
|
94
97
|
"@swc/jest": "0.2.29",
|
|
95
|
-
"
|
|
98
|
+
"@lowdefy/logger": "4.7.0",
|
|
99
|
+
"jest": "28.1.3",
|
|
100
|
+
"pino": "8.16.2"
|
|
96
101
|
},
|
|
97
102
|
"publishConfig": {
|
|
98
103
|
"access": "public"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-2024 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 buildPage from './buildPage.js';
|
|
17
|
-
import createCheckDuplicateId from '../../utils/createCheckDuplicateId.js';
|
|
18
|
-
function buildPages({ components, context }) {
|
|
19
|
-
const pages = type.isArray(components.pages) ? components.pages : [];
|
|
20
|
-
const checkDuplicatePageId = createCheckDuplicateId({
|
|
21
|
-
message: 'Duplicate pageId "{{ id }}".'
|
|
22
|
-
});
|
|
23
|
-
pages.map((page, index)=>buildPage({
|
|
24
|
-
page,
|
|
25
|
-
index,
|
|
26
|
-
context,
|
|
27
|
-
checkDuplicatePageId
|
|
28
|
-
}));
|
|
29
|
-
return components;
|
|
30
|
-
}
|
|
31
|
-
export default buildPages;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 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 { BuildParser } from '@lowdefy/operators';
|
|
16
|
-
import operators from '@lowdefy/operators-js/operators/build';
|
|
17
|
-
async function evaluateBuildOperators({ context, input, refDef }) {
|
|
18
|
-
const operatorsParser = new BuildParser({
|
|
19
|
-
env: process.env,
|
|
20
|
-
operators
|
|
21
|
-
});
|
|
22
|
-
const { output, errors } = operatorsParser.parse({
|
|
23
|
-
input,
|
|
24
|
-
location: refDef.path ?? refDef.resolver,
|
|
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
|
-
await promises;
|
|
31
|
-
}
|
|
32
|
-
return output;
|
|
33
|
-
}
|
|
34
|
-
export default evaluateBuildOperators;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 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 makeRefDefinition from './makeRefDefinition.js';
|
|
17
|
-
function getRefsFromFile(fileContent, parentRefDefId, refMap) {
|
|
18
|
-
const foundRefs = [];
|
|
19
|
-
const reviver = (key, value)=>{
|
|
20
|
-
if (type.isObject(value)) {
|
|
21
|
-
if (!type.isUndefined(value._ref)) {
|
|
22
|
-
const def = makeRefDefinition(value._ref, parentRefDefId, refMap);
|
|
23
|
-
foundRefs.push(def);
|
|
24
|
-
return {
|
|
25
|
-
_ref: def
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
};
|
|
31
|
-
const fileContentBuiltRefs = JSON.parse(JSON.stringify(fileContent), reviver);
|
|
32
|
-
return {
|
|
33
|
-
foundRefs,
|
|
34
|
-
fileContentBuiltRefs
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export default getRefsFromFile;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 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 { get, type } from '@lowdefy/helpers';
|
|
16
|
-
function refReviver(key, value) {
|
|
17
|
-
if (type.isObject(value)) {
|
|
18
|
-
if (!type.isUndefined(value._ref)) {
|
|
19
|
-
return this.parsedFiles[value._ref.id];
|
|
20
|
-
}
|
|
21
|
-
if (value._var) {
|
|
22
|
-
if (type.isString(value._var)) {
|
|
23
|
-
return JSON.parse(JSON.stringify(get(this.vars, value._var, {
|
|
24
|
-
default: null
|
|
25
|
-
})));
|
|
26
|
-
}
|
|
27
|
-
if (type.isObject(value._var) && type.isString(value._var.key)) {
|
|
28
|
-
return JSON.parse(JSON.stringify(get(this.vars, value._var.key, {
|
|
29
|
-
default: type.isNone(value._var.default) ? null : value._var.default
|
|
30
|
-
})));
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`"_var" operator takes a string or object with "key" field as arguments. Received "${JSON.stringify(value)}"`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
function populateRefs({ parsedFiles, refDef, toPopulate }) {
|
|
38
|
-
return JSON.parse(JSON.stringify(toPopulate), refReviver.bind({
|
|
39
|
-
parsedFiles,
|
|
40
|
-
vars: refDef.vars
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
export default populateRefs;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 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 evaluateBuildOperators from './evaluateBuildOperators.js';
|
|
17
|
-
import getKey from './getKey.js';
|
|
18
|
-
import getRefContent from './getRefContent.js';
|
|
19
|
-
import getRefsFromFile from './getRefsFromFile.js';
|
|
20
|
-
import populateRefs from './populateRefs.js';
|
|
21
|
-
import runTransformer from './runTransformer.js';
|
|
22
|
-
async function recursiveBuild({ context, refDef, count, referencedFrom }) {
|
|
23
|
-
// TODO: Maybe it would be better to detect a cycle, since this is the real issue here?
|
|
24
|
-
if (count > 10000) {
|
|
25
|
-
throw new Error(`Maximum recursion depth of references exceeded.`);
|
|
26
|
-
}
|
|
27
|
-
let fileContent = await getRefContent({
|
|
28
|
-
context,
|
|
29
|
-
refDef,
|
|
30
|
-
referencedFrom
|
|
31
|
-
});
|
|
32
|
-
const { foundRefs, fileContentBuiltRefs } = getRefsFromFile(fileContent, refDef.id, context.refMap);
|
|
33
|
-
const parsedFiles = {};
|
|
34
|
-
// Since we can have references in the variables of a reference, we need to first parse
|
|
35
|
-
// the deeper nodes, so we can use those parsed files in references higher in the tree.
|
|
36
|
-
// To do this, since foundRefs is an array of ref definitions that are in order of the
|
|
37
|
-
// deepest nodes first we for loop over over foundRefs one by one, awaiting each result.
|
|
38
|
-
for (const newRefDef of foundRefs.values()){
|
|
39
|
-
// Parse vars and path before passing down to parse new file
|
|
40
|
-
const parsedRefDef = populateRefs({
|
|
41
|
-
toPopulate: newRefDef,
|
|
42
|
-
parsedFiles,
|
|
43
|
-
refDef
|
|
44
|
-
});
|
|
45
|
-
context.refMap[parsedRefDef.id].path = parsedRefDef.path;
|
|
46
|
-
const parsedFile = await recursiveBuild({
|
|
47
|
-
context,
|
|
48
|
-
refDef: parsedRefDef,
|
|
49
|
-
count: count + 1,
|
|
50
|
-
referencedFrom: refDef.path
|
|
51
|
-
});
|
|
52
|
-
const transformedFile = await runTransformer({
|
|
53
|
-
context,
|
|
54
|
-
input: parsedFile,
|
|
55
|
-
refDef: parsedRefDef
|
|
56
|
-
});
|
|
57
|
-
// Evaluated in recursive loop for better error messages
|
|
58
|
-
const evaluatedOperators = await evaluateBuildOperators({
|
|
59
|
-
context,
|
|
60
|
-
input: transformedFile,
|
|
61
|
-
refDef: parsedRefDef
|
|
62
|
-
});
|
|
63
|
-
const withRefKey = getKey({
|
|
64
|
-
input: evaluatedOperators,
|
|
65
|
-
refDef: parsedRefDef
|
|
66
|
-
});
|
|
67
|
-
const reviver = (_, value)=>{
|
|
68
|
-
if (!type.isObject(value)) return value;
|
|
69
|
-
Object.defineProperty(value, '~r', {
|
|
70
|
-
value: refDef.id,
|
|
71
|
-
enumerable: false,
|
|
72
|
-
writable: true,
|
|
73
|
-
configurable: true
|
|
74
|
-
});
|
|
75
|
-
return value;
|
|
76
|
-
};
|
|
77
|
-
parsedFiles[newRefDef.id] = JSON.parse(JSON.stringify(withRefKey), reviver);
|
|
78
|
-
}
|
|
79
|
-
return populateRefs({
|
|
80
|
-
toPopulate: fileContentBuiltRefs,
|
|
81
|
-
parsedFiles,
|
|
82
|
-
refDef
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
export default recursiveBuild;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 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 { get, type } from '@lowdefy/helpers';
|
|
16
|
-
function formatArrayKey({ index, object }) {
|
|
17
|
-
if (type.isObject(object) && (!type.isNone(object.id) || !type.isNone(object.type))) {
|
|
18
|
-
const objectId = type.isNone(object.id) ? '_ERROR_MISSING_ID_' : object.id;
|
|
19
|
-
const objectType = type.isNone(object.type) ? '_ERROR_MISSING_TYPE_' : object.type;
|
|
20
|
-
return `[${index}:${objectId}:${objectType}]`;
|
|
21
|
-
}
|
|
22
|
-
return `[${index}]`;
|
|
23
|
-
}
|
|
24
|
-
function recursiveFormatPath({ data, instancePath, formattedPath = '', gap = '', root = false }) {
|
|
25
|
-
if (instancePath.length === 0) return formattedPath;
|
|
26
|
-
const key = instancePath.shift();
|
|
27
|
-
const newData = get(data, key);
|
|
28
|
-
let newPath;
|
|
29
|
-
if (type.isArray(data)) {
|
|
30
|
-
gap += ' ';
|
|
31
|
-
newPath = `${formattedPath}
|
|
32
|
-
${gap}- ${formatArrayKey({
|
|
33
|
-
index: key,
|
|
34
|
-
object: newData
|
|
35
|
-
})}`;
|
|
36
|
-
} else {
|
|
37
|
-
newPath = `${formattedPath}${root ? '- ' : '.'}${key}`;
|
|
38
|
-
}
|
|
39
|
-
return recursiveFormatPath({
|
|
40
|
-
data: newData,
|
|
41
|
-
instancePath,
|
|
42
|
-
formattedPath: newPath,
|
|
43
|
-
gap
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function formatErrorMessage({ error, components }) {
|
|
47
|
-
const formattedPath = recursiveFormatPath({
|
|
48
|
-
data: components,
|
|
49
|
-
instancePath: error.instancePath.split('/').slice(1),
|
|
50
|
-
root: true
|
|
51
|
-
});
|
|
52
|
-
return `Schema Error
|
|
53
|
-
${error.message}
|
|
54
|
-
${formattedPath}`;
|
|
55
|
-
}
|
|
56
|
-
export default formatErrorMessage;
|