@lowdefy/build 0.0.0-experimental-20240115131502 → 0.0.0-experimental-20241107144205
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 +1 -1
- package/dist/build/addKeys.js +1 -1
- package/dist/build/buildApi/buildApi.js +34 -0
- package/dist/build/buildApi/buildEndpoint.js +34 -0
- package/dist/build/buildApi/buildRoutine/buildControl.js +33 -0
- package/dist/build/buildApi/buildRoutine/buildRoutine.js +35 -0
- package/dist/build/buildApi/buildRoutine/buildStep.js +27 -0
- package/dist/build/buildApi/buildRoutine/controlTypes.js +208 -0
- package/dist/build/buildApi/buildRoutine/countControl.js +18 -0
- package/dist/build/buildApi/buildRoutine/countOperators.js +0 -0
- package/dist/build/buildApi/buildRoutine/countStepTypes.js +18 -0
- package/dist/build/buildApi/buildRoutine/setStepId.js +20 -0
- package/dist/build/buildApi/buildRoutine/validateStep.js +46 -0
- package/dist/build/buildApi/validateEndpoint.js +22 -0
- package/dist/build/buildApp.js +1 -1
- package/dist/build/buildAuth/buildAuth.js +1 -1
- package/dist/build/buildAuth/buildAuthPlugins.js +1 -1
- package/dist/build/buildAuth/buildPageAuth.js +1 -1
- package/dist/build/buildAuth/getPageRoles.js +1 -1
- package/dist/build/buildAuth/getProtectedPages.js +1 -1
- package/dist/build/buildAuth/validateAuthConfig.js +1 -1
- package/dist/build/buildConnections.js +1 -1
- 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/buildJs.js +43 -0
- package/dist/build/buildJs/generateJsFile.js +30 -0
- package/dist/build/buildJs/jsMapParser.js +46 -0
- package/dist/build/buildJs/writeJs.js +26 -0
- package/dist/build/buildMenu.js +1 -1
- package/dist/build/buildPages/buildBlock/buildBlock.js +1 -1
- package/dist/build/buildPages/buildBlock/buildEvents.js +1 -1
- 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 +1 -1
- package/dist/build/buildPages/buildBlock/countBlockTypes.js +1 -1
- package/dist/build/buildPages/buildBlock/moveSkeletonBlocksToArea.js +1 -1
- 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 +1 -1
- package/dist/build/buildPages/buildPages.js +1 -1
- package/dist/build/buildPages/buildTestPage.js +1 -1
- package/dist/build/buildRefs/buildRefs.js +1 -1
- package/dist/build/buildRefs/evaluateBuildOperators.js +1 -1
- package/dist/build/buildRefs/getConfigFile.js +1 -1
- 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/getRefsFromFile.js +1 -1
- package/dist/build/buildRefs/getUserJavascriptFunction.js +1 -1
- package/dist/build/buildRefs/makeRefDefinition.js +1 -1
- package/dist/build/buildRefs/parseNunjucks.js +1 -1
- package/dist/build/buildRefs/parseRefContent.js +1 -1
- package/dist/build/buildRefs/populateRefs.js +1 -1
- package/dist/build/buildRefs/recursiveBuild.js +1 -1
- package/dist/build/buildRefs/runRefResolver.js +1 -1
- package/dist/build/buildRefs/runTransformer.js +1 -1
- package/dist/build/buildTypes.js +2 -1
- package/dist/build/cleanBuildDirectory.js +1 -1
- package/dist/build/copyPublicFolder.js +1 -1
- package/dist/build/testSchema.js +1 -1
- package/dist/build/updateServerPackageJson.js +1 -1
- package/dist/build/validateConfig.js +1 -1
- package/dist/build/writeApi.js +30 -0
- 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/writeMaps.js +1 -1
- package/dist/build/writeMenus.js +1 -1
- package/dist/build/writePages.js +1 -1
- package/dist/build/writePluginImports/generateImportFile.js +1 -1
- package/dist/build/writePluginImports/writeActionImports.js +1 -1
- package/dist/build/writePluginImports/writeAuthImports.js +1 -1
- 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 +1 -1
- package/dist/build/writePluginImports/writePluginImports.js +1 -1
- package/dist/build/writePluginImports/writeStyleImports.js +1 -1
- package/dist/build/writeRequests.js +1 -1
- package/dist/build/writeTypes.js +1 -1
- package/dist/createContext.js +3 -1
- package/dist/defaultTypesMap.js +459 -378
- package/dist/index.js +23 -3
- package/dist/lowdefySchema.js +47 -0
- package/dist/scripts/generateDefaultTypes.js +1 -1
- package/dist/scripts/run.js +1 -1
- 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 +1 -1
- package/dist/test/buildRefs/testBuildRefsTransform.js +1 -1
- package/dist/test/buildRefs/testBuildRefsTransformIdentity.js +1 -1
- package/dist/test/testContext.js +4 -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 +1 -1
- package/dist/utils/formatErrorMessage.js +1 -1
- package/dist/utils/makeId.js +1 -1
- package/dist/utils/readConfigFile.js +1 -1
- package/dist/utils/writeBuildArtifact.js +1 -1
- package/package.json +38 -38
package/dist/build/addKeys.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
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 createCheckDuplicateId from '../../utils/createCheckDuplicateId.js';
|
|
17
|
+
import buildEndpoint from './buildEndpoint.js';
|
|
18
|
+
function buildApi({ components, context }) {
|
|
19
|
+
if (components.api && !type.isArray(components.api)) {
|
|
20
|
+
throw new Error(`Api is not an array. Received ${JSON.stringify(components.api)}.`);
|
|
21
|
+
}
|
|
22
|
+
const api = type.isArray(components.api) ? components.api : [];
|
|
23
|
+
const checkDuplicateEndpointId = createCheckDuplicateId({
|
|
24
|
+
message: 'Duplicate endpointId "{{ id }}".'
|
|
25
|
+
});
|
|
26
|
+
api.map((endpoint, index)=>buildEndpoint({
|
|
27
|
+
endpoint,
|
|
28
|
+
index,
|
|
29
|
+
context,
|
|
30
|
+
checkDuplicateEndpointId
|
|
31
|
+
}));
|
|
32
|
+
return components;
|
|
33
|
+
}
|
|
34
|
+
export default buildApi;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 buildRoutine from './buildRoutine/buildRoutine.js';
|
|
16
|
+
import validateEndpoint from './validateEndpoint.js';
|
|
17
|
+
import createCheckDuplicateId from '../../utils/createCheckDuplicateId.js';
|
|
18
|
+
function buildEndpoint({ endpoint, index, context, checkDuplicateEndpointId }) {
|
|
19
|
+
validateEndpoint({
|
|
20
|
+
endpoint,
|
|
21
|
+
index,
|
|
22
|
+
checkDuplicateEndpointId
|
|
23
|
+
});
|
|
24
|
+
endpoint.endpointId = endpoint.id;
|
|
25
|
+
buildRoutine(endpoint.routine, {
|
|
26
|
+
checkDuplicateStepId: createCheckDuplicateId({
|
|
27
|
+
message: 'Duplicate stepId "{{ id }}" on endpoint "{{ eventId }}"'
|
|
28
|
+
}),
|
|
29
|
+
endpointId: endpoint.endpointId,
|
|
30
|
+
typeCounters: context.typeCounters
|
|
31
|
+
});
|
|
32
|
+
endpoint.id = `endpoint:${endpoint.endpointId}`;
|
|
33
|
+
}
|
|
34
|
+
export default buildEndpoint;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 buildRoutine from './buildRoutine.js';
|
|
16
|
+
import countControl from './countControl.js';
|
|
17
|
+
import { validateControl, routineKey } from './controlTypes.js';
|
|
18
|
+
import countOperators from '../../../utils/countOperators.js';
|
|
19
|
+
function buildControl(control, endpointContext) {
|
|
20
|
+
const controlType = validateControl(control, endpointContext);
|
|
21
|
+
Object.keys(control).forEach((key)=>{
|
|
22
|
+
if (routineKey(controlType, key)) {
|
|
23
|
+
countControl(key, endpointContext);
|
|
24
|
+
buildRoutine(control[key], endpointContext);
|
|
25
|
+
} else {
|
|
26
|
+
countOperators(control[key], {
|
|
27
|
+
counter: endpointContext.typeCounters.operators.server
|
|
28
|
+
});
|
|
29
|
+
countControl(key, endpointContext);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export default buildControl;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 buildStep from './buildStep.js';
|
|
17
|
+
import buildControl from './buildControl.js';
|
|
18
|
+
function buildRoutine(routine, endpointContext) {
|
|
19
|
+
if (type.isArray(routine)) {
|
|
20
|
+
routine.forEach((item)=>{
|
|
21
|
+
buildRoutine(item, endpointContext);
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (type.isObject(routine)) {
|
|
26
|
+
if (Object.keys(routine)[0]?.startsWith(':')) {
|
|
27
|
+
buildControl(routine, endpointContext);
|
|
28
|
+
} else {
|
|
29
|
+
buildStep(routine, endpointContext);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Routine at ${endpointContext.endpointId} on endpoint ${endpointContext.endpointId} is not an array or object. Received "${type.isString(routine) ? routine : JSON.stringify(routine)}"`);
|
|
34
|
+
}
|
|
35
|
+
export default buildRoutine;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 validateStep from './validateStep.js';
|
|
16
|
+
import setStepId from './setStepId.js';
|
|
17
|
+
import countStepTypes from './countStepTypes.js';
|
|
18
|
+
import countOperators from '../../../utils/countOperators.js';
|
|
19
|
+
function buildStep(step, endpointContext) {
|
|
20
|
+
validateStep(step, endpointContext);
|
|
21
|
+
countOperators(step.properties ?? {}, {
|
|
22
|
+
counter: endpointContext.typeCounters.operators.server
|
|
23
|
+
});
|
|
24
|
+
setStepId(step, endpointContext);
|
|
25
|
+
countStepTypes(step, endpointContext);
|
|
26
|
+
}
|
|
27
|
+
export default buildStep;
|
|
@@ -0,0 +1,208 @@
|
|
|
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 buildRoutine from './buildRoutine.js';
|
|
17
|
+
import countControl from './countControl.js';
|
|
18
|
+
import countOperators from '../../../utils/countOperators.js';
|
|
19
|
+
const controlTypes = {
|
|
20
|
+
':for': {
|
|
21
|
+
required: [
|
|
22
|
+
':for',
|
|
23
|
+
':in',
|
|
24
|
+
':do'
|
|
25
|
+
],
|
|
26
|
+
routine: [
|
|
27
|
+
':do'
|
|
28
|
+
],
|
|
29
|
+
optional: []
|
|
30
|
+
},
|
|
31
|
+
':if': {
|
|
32
|
+
required: [
|
|
33
|
+
':if',
|
|
34
|
+
':then'
|
|
35
|
+
],
|
|
36
|
+
routine: [
|
|
37
|
+
':then',
|
|
38
|
+
':else'
|
|
39
|
+
],
|
|
40
|
+
optional: [
|
|
41
|
+
':else'
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
':log': {
|
|
45
|
+
required: [
|
|
46
|
+
':log'
|
|
47
|
+
],
|
|
48
|
+
routine: [],
|
|
49
|
+
optional: []
|
|
50
|
+
},
|
|
51
|
+
':parallel': {
|
|
52
|
+
required: [
|
|
53
|
+
':parallel'
|
|
54
|
+
],
|
|
55
|
+
routine: [
|
|
56
|
+
':parallel'
|
|
57
|
+
],
|
|
58
|
+
optional: []
|
|
59
|
+
},
|
|
60
|
+
':parallel_for': {
|
|
61
|
+
required: [
|
|
62
|
+
':parallel_for',
|
|
63
|
+
':in',
|
|
64
|
+
':do'
|
|
65
|
+
],
|
|
66
|
+
routine: [
|
|
67
|
+
':do'
|
|
68
|
+
],
|
|
69
|
+
optional: []
|
|
70
|
+
},
|
|
71
|
+
':reject': {
|
|
72
|
+
required: [
|
|
73
|
+
':reject'
|
|
74
|
+
],
|
|
75
|
+
routine: [],
|
|
76
|
+
optional: []
|
|
77
|
+
},
|
|
78
|
+
':return': {
|
|
79
|
+
required: [
|
|
80
|
+
':return'
|
|
81
|
+
],
|
|
82
|
+
routine: [],
|
|
83
|
+
optional: []
|
|
84
|
+
},
|
|
85
|
+
':set_state': {
|
|
86
|
+
required: [
|
|
87
|
+
':set_state'
|
|
88
|
+
],
|
|
89
|
+
routine: [],
|
|
90
|
+
optional: []
|
|
91
|
+
},
|
|
92
|
+
':switch': {
|
|
93
|
+
required: [
|
|
94
|
+
':switch',
|
|
95
|
+
':case',
|
|
96
|
+
':then'
|
|
97
|
+
],
|
|
98
|
+
routine: [
|
|
99
|
+
':default',
|
|
100
|
+
':then'
|
|
101
|
+
],
|
|
102
|
+
optional: [
|
|
103
|
+
':default'
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
':throw': {
|
|
107
|
+
required: [
|
|
108
|
+
':throw'
|
|
109
|
+
],
|
|
110
|
+
routine: [],
|
|
111
|
+
optional: []
|
|
112
|
+
},
|
|
113
|
+
':try': {
|
|
114
|
+
required: [
|
|
115
|
+
':try'
|
|
116
|
+
],
|
|
117
|
+
routine: [
|
|
118
|
+
':try',
|
|
119
|
+
':catch',
|
|
120
|
+
':finally'
|
|
121
|
+
],
|
|
122
|
+
optional: [
|
|
123
|
+
':catch',
|
|
124
|
+
':finally'
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
':while': {
|
|
128
|
+
required: [
|
|
129
|
+
':while',
|
|
130
|
+
':do'
|
|
131
|
+
],
|
|
132
|
+
routine: [
|
|
133
|
+
':do'
|
|
134
|
+
],
|
|
135
|
+
optional: []
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
function getAdditionalKeys(controlType, keys) {
|
|
139
|
+
return keys.filter((item)=>!controlTypes[controlType].required.includes(item));
|
|
140
|
+
}
|
|
141
|
+
function checkMissingRequiredControls({ controlType, keys }, { endpointId }) {
|
|
142
|
+
const missingControls = controlTypes[controlType].required.filter((item)=>!keys.includes(item));
|
|
143
|
+
if (missingControls.length > 0) {
|
|
144
|
+
throw new Error(`Missing required control type(s) for endpoint ${endpointId}. Missing ${JSON.stringify(missingControls)}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function checkInvalidControls({ controlType, keys }, { endpointId }) {
|
|
148
|
+
const additionalControls = getAdditionalKeys(controlType, keys);
|
|
149
|
+
const invalidControls = additionalControls.filter((item)=>!controlTypes[controlType].optional.includes(item));
|
|
150
|
+
if (invalidControls.length > 0) {
|
|
151
|
+
throw new Error(`Invalid control type(s) for endpoint ${endpointId}. Received ${JSON.stringify(invalidControls)}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function handleSwitch(control, endpointContext) {
|
|
155
|
+
const switchArray = control[':switch'];
|
|
156
|
+
if (!type.isArray(control[':switch'])) {
|
|
157
|
+
throw new Error(`Type given for :switch control is invalid at endpoint ${endpointContext.endpointId}. Received ${JSON.stringify(control[':switch'])}`);
|
|
158
|
+
}
|
|
159
|
+
switchArray.forEach((caseObj)=>{
|
|
160
|
+
const input = {
|
|
161
|
+
controlType: ':switch',
|
|
162
|
+
keys: [
|
|
163
|
+
':switch',
|
|
164
|
+
...Object.keys(caseObj)
|
|
165
|
+
]
|
|
166
|
+
};
|
|
167
|
+
checkMissingRequiredControls(input, endpointContext);
|
|
168
|
+
checkInvalidControls(input, endpointContext);
|
|
169
|
+
Object.keys(caseObj).forEach((key)=>{
|
|
170
|
+
if (routineKey(':switch', key)) {
|
|
171
|
+
buildRoutine(caseObj[key], endpointContext);
|
|
172
|
+
} else {
|
|
173
|
+
countOperators(caseObj[key], {
|
|
174
|
+
counter: endpointContext.typeCounters.operators.server
|
|
175
|
+
});
|
|
176
|
+
countControl(key, endpointContext);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function validateControl(control, endpointContext) {
|
|
182
|
+
const keys = Object.keys(control);
|
|
183
|
+
const intersection = keys.filter((item)=>Object.keys(controlTypes).includes(item));
|
|
184
|
+
if (intersection.length === 0) {
|
|
185
|
+
throw new Error(`Invalid control type(s) for endpoint ${endpointContext.endpointId}. Received "${JSON.stringify(keys)}"`);
|
|
186
|
+
}
|
|
187
|
+
if (intersection.length > 1) {
|
|
188
|
+
throw new Error(`More than one control type found for endpoint ${endpointContext.endpointId}. Received ${JSON.stringify(intersection)}`);
|
|
189
|
+
}
|
|
190
|
+
const controlType = intersection[0];
|
|
191
|
+
if (controlType === ':switch') {
|
|
192
|
+
handleSwitch(control, endpointContext);
|
|
193
|
+
return controlType;
|
|
194
|
+
}
|
|
195
|
+
checkMissingRequiredControls({
|
|
196
|
+
controlType,
|
|
197
|
+
keys
|
|
198
|
+
}, endpointContext);
|
|
199
|
+
checkInvalidControls({
|
|
200
|
+
controlType,
|
|
201
|
+
keys
|
|
202
|
+
}, endpointContext);
|
|
203
|
+
return controlType;
|
|
204
|
+
}
|
|
205
|
+
function routineKey(controlType, key) {
|
|
206
|
+
return controlTypes[controlType]?.routine.includes(key);
|
|
207
|
+
}
|
|
208
|
+
export { routineKey, validateControl };
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
*/ function countControl(control, { typeCounters }) {
|
|
16
|
+
typeCounters.controls.increment(control);
|
|
17
|
+
}
|
|
18
|
+
export default countControl;
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
*/ function countStepTypes(step, { typeCounters }) {
|
|
16
|
+
typeCounters.requests.increment(step.type);
|
|
17
|
+
}
|
|
18
|
+
export default countStepTypes;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/ function setStepId(step, { endpointId }) {
|
|
16
|
+
step.requestId = step.id;
|
|
17
|
+
step.endpointId = endpointId;
|
|
18
|
+
step.id = `request:${endpointId}:${step.requestId}`;
|
|
19
|
+
}
|
|
20
|
+
export default setStepId;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
function validateStep(step, { endpointId, checkDuplicateStepId }) {
|
|
17
|
+
if (Object.keys(step).length === 0) {
|
|
18
|
+
throw new Error(`Step is not defined at endpoint "${endpointId}"`);
|
|
19
|
+
}
|
|
20
|
+
if (type.isUndefined(step.id)) {
|
|
21
|
+
throw new Error(`Step id missing at endpoint "${endpointId}".`);
|
|
22
|
+
}
|
|
23
|
+
if (!type.isString(step.id)) {
|
|
24
|
+
throw new Error(`Step id is not a string at endpoint "${endpointId}". Received ${JSON.stringify(step.id)}.`);
|
|
25
|
+
}
|
|
26
|
+
if (step.id.includes('.')) {
|
|
27
|
+
throw new Error(`Step id "${step.id}" at api "${endpointId}" should not include a period (".").`);
|
|
28
|
+
}
|
|
29
|
+
if (type.isNone(step.type)) {
|
|
30
|
+
throw new Error(`Step type is not defined at "${step.id}" on endpoint "${endpointId}".`);
|
|
31
|
+
}
|
|
32
|
+
if (!type.isString(step.type)) {
|
|
33
|
+
throw new Error(`Step type is not a string at "${step.id}" on endpoint "${endpointId}". Received ${JSON.stringify(step.type)}.`);
|
|
34
|
+
}
|
|
35
|
+
if (type.isUndefined(step.connectionId)) {
|
|
36
|
+
throw new Error(`Step connectionId missing at endpoint "${endpointId}".`);
|
|
37
|
+
}
|
|
38
|
+
if (!type.isString(step.connectionId)) {
|
|
39
|
+
throw new Error(`Step connectionId is not a string at endpoint "${endpointId}". Received ${JSON.stringify(step.connectionId)}.`);
|
|
40
|
+
}
|
|
41
|
+
checkDuplicateStepId({
|
|
42
|
+
id: step.id,
|
|
43
|
+
eventId: endpointId
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export default validateStep;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type } from '@lowdefy/helpers';
|
|
2
|
+
function validateEndpoint({ endpoint, index, checkDuplicateEndpointId }) {
|
|
3
|
+
if (type.isUndefined(endpoint.id)) {
|
|
4
|
+
throw new Error(`Endpoint id missing at endpoint ${index}.`);
|
|
5
|
+
}
|
|
6
|
+
if (!type.isString(endpoint.id)) {
|
|
7
|
+
throw new Error(`Endpoint id is not a string at endpoint ${index}. Received ${JSON.stringify(endpoint.id)}.`);
|
|
8
|
+
}
|
|
9
|
+
if (endpoint.id.includes('.')) {
|
|
10
|
+
throw new Error(`Endpoint id "${endpoint.id}" at endpoint "${endpoint.id}" should not include a period (".").`);
|
|
11
|
+
}
|
|
12
|
+
if (type.isUndefined(endpoint.type)) {
|
|
13
|
+
throw new Error(`Endpoint type is not defined at "${endpoint.id}" on endpoint "${endpoint.id}".`);
|
|
14
|
+
}
|
|
15
|
+
if (!type.isString(endpoint.type)) {
|
|
16
|
+
throw new Error(`Endpoint type is not a string at "${endpoint.id}" on endpoint "${endpoint.id}". Received ${JSON.stringify(endpoint.type)}.`);
|
|
17
|
+
}
|
|
18
|
+
checkDuplicateEndpointId({
|
|
19
|
+
id: endpoint.id
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export default validateEndpoint;
|
package/dist/build/buildApp.js
CHANGED