Skip to content

Commit f273028

Browse files
Merge pull request #96 from contentstack/fix/dx-3566-fix-nested-references
fix dx-3566 | Refactor processOverlappingPaths to include all paths
2 parents dae32da + 663bbce commit f273028

File tree

4 files changed

+55
-54
lines changed

4 files changed

+55
-54
lines changed

package-lock.json

Lines changed: 46 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/datasync-filesystem-sdk",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "JavaScript filesystem SDK to query data synced via @contentstack/datasync-content-store-filesystem",
55
"main": "dist/index.js",
66
"scripts": {

src/stack.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,32 +1227,22 @@ export class Stack {
12271227
/**
12281228
* @private
12291229
* @method processOverlappingPaths
1230-
* @description Processes overlapping paths using a chained approach
1230+
* @description Processes overlapping paths by including all paths from each group
12311231
* @param {Object} pathAnalysis - Analysis result from analyzeReferencePaths
12321232
* @returns {this} - Returns stack instance
12331233
*/
12341234
private processOverlappingPaths(pathAnalysis: any): Stack {
12351235
// Start with independent paths (if any)
12361236
if (pathAnalysis.independentPaths.length > 0) {
1237-
this.q.includeSpecificReferences = pathAnalysis.independentPaths
1237+
this.q.includeSpecificReferences = [...pathAnalysis.independentPaths]
1238+
} else {
1239+
this.q.includeSpecificReferences = []
12381240
}
12391241

1240-
// Process each overlapping group by using the most specific path
1242+
// Process each overlapping group by including ALL paths from each group
12411243
pathAnalysis.overlappingGroups.forEach((group: string[]) => {
1242-
// Sort group by length (longest/most specific first)
1243-
const sortedGroup = group.sort((a, b) => b.length - a.length)
1244-
1245-
// Use the most specific path from each group
1246-
const mostSpecificPath = sortedGroup[0]
1247-
1248-
// If this is the first group and we have no independent paths,
1249-
// set the includeSpecificReferences
1250-
if (!this.q.includeSpecificReferences) {
1251-
this.q.includeSpecificReferences = [mostSpecificPath]
1252-
} else {
1253-
// Add the most specific path to existing references
1254-
this.q.includeSpecificReferences.push(mostSpecificPath)
1255-
}
1244+
// Add all paths from the group to includeSpecificReferences
1245+
this.q.includeSpecificReferences.push(...group)
12561246
})
12571247

12581248
return this

typings/stack.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ export declare class Stack {
513513
/**
514514
* @private
515515
* @method processOverlappingPaths
516-
* @description Processes overlapping paths using a chained approach
516+
* @description Processes overlapping paths by including all paths from each group
517517
* @param {Object} pathAnalysis - Analysis result from analyzeReferencePaths
518518
* @returns {this} - Returns stack instance
519519
*/

0 commit comments

Comments
 (0)