@lowdefy/build 0.0.0-experimental-20260113090459 → 0.0.0-experimental-20260113102133
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/buildRefs/recursiveBuild.js +24 -11
- package/dist/defaultTypesMap.js +455 -455
- package/dist/index.js +5 -1
- package/package.json +39 -39
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { serializer, type } from '@lowdefy/helpers';
|
|
16
16
|
import evaluateBuildOperators from './evaluateBuildOperators.js';
|
|
17
|
+
import formatConfigError from '../../utils/formatConfigError.js';
|
|
17
18
|
import getKey from './getKey.js';
|
|
18
19
|
import getRefContent from './getRefContent.js';
|
|
19
20
|
import getRefsFromFile from './getRefsFromFile.js';
|
|
@@ -21,19 +22,28 @@ import populateRefs from './populateRefs.js';
|
|
|
21
22
|
import runTransformer from './runTransformer.js';
|
|
22
23
|
async function recursiveBuild({ context, refDef, count, referencedFrom, refChainSet = new Set(), refChainList = [] }) {
|
|
23
24
|
// Detect circular references by tracking the chain of files being resolved
|
|
25
|
+
// Skip circular reference checking for refs without paths (e.g., resolver refs)
|
|
24
26
|
const currentPath = refDef.path;
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (currentPath) {
|
|
28
|
+
if (refChainSet.has(currentPath)) {
|
|
29
|
+
const chainDisplay = [
|
|
30
|
+
...refChainList,
|
|
31
|
+
currentPath
|
|
32
|
+
].join('\n -> ');
|
|
33
|
+
throw new Error(formatConfigError({
|
|
34
|
+
message: `Circular reference detected.\nFile "${currentPath}" references itself through:\n -> ${chainDisplay}`,
|
|
35
|
+
context
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
refChainSet.add(currentPath);
|
|
39
|
+
refChainList.push(currentPath);
|
|
31
40
|
}
|
|
32
|
-
refChainSet.add(currentPath);
|
|
33
|
-
refChainList.push(currentPath);
|
|
34
41
|
// Keep count as a fallback safety limit
|
|
35
42
|
if (count > 10000) {
|
|
36
|
-
throw new Error(
|
|
43
|
+
throw new Error(formatConfigError({
|
|
44
|
+
message: `Maximum recursion depth of references exceeded (10000 levels). This likely indicates a circular reference.`,
|
|
45
|
+
context
|
|
46
|
+
}));
|
|
37
47
|
}
|
|
38
48
|
let fileContent = await getRefContent({
|
|
39
49
|
context,
|
|
@@ -97,8 +107,11 @@ async function recursiveBuild({ context, refDef, count, referencedFrom, refChain
|
|
|
97
107
|
});
|
|
98
108
|
}
|
|
99
109
|
// Backtrack: remove current file from chain so sibling refs can use it
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
// Only remove if it was added (i.e., if currentPath exists)
|
|
111
|
+
if (currentPath) {
|
|
112
|
+
refChainSet.delete(currentPath);
|
|
113
|
+
refChainList.pop();
|
|
114
|
+
}
|
|
102
115
|
return populateRefs({
|
|
103
116
|
toPopulate: fileContentBuiltRefs,
|
|
104
117
|
parsedFiles,
|