@fern-api/fdr-sdk 1.2.42-5d054efb73 → 1.2.42-756f6ba5d7
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/js/converters/index.js +0 -9
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +0 -9
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +0 -9
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +0 -9
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +0 -9
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +0 -9
- package/dist/js/navigation/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +36 -191
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +36 -191
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.metadataPreservation.test.js +4 -167
- package/dist/navigation/__test__/ledger-root-builder.metadataPreservation.test.js.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js +0 -102
- package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.skipSlugApiReference.test.js +0 -276
- package/dist/navigation/__test__/ledger-root-builder.skipSlugApiReference.test.js.map +1 -1
- package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/navigation/ledger-root-builder.js +47 -275
- package/dist/navigation/ledger-root-builder.js.map +1 -1
- package/dist/navigation/utils/index.d.ts +0 -1
- package/dist/navigation/utils/index.d.ts.map +1 -1
- package/dist/navigation/utils/index.js +0 -1
- package/dist/navigation/utils/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/types/navigation/utils/index.d.ts +0 -1
- package/dist/types/navigation/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +0 -2
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js +0 -267
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +0 -2
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js +0 -306
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +0 -2
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js +0 -273
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +0 -2
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +0 -1
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js +0 -256
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +0 -1
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.d.ts +0 -2
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.d.ts.map +0 -1
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.js +0 -29
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.js.map +0 -1
- package/dist/navigation/utils/syntheticSectionPath.d.ts +0 -13
- package/dist/navigation/utils/syntheticSectionPath.d.ts.map +0 -1
- package/dist/navigation/utils/syntheticSectionPath.js +0 -20
- package/dist/navigation/utils/syntheticSectionPath.js.map +0 -1
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +0 -2
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +0 -1
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +0 -2
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +0 -1
- package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +0 -2
- package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +0 -1
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +0 -2
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +0 -1
- package/dist/types/navigation/utils/__test__/syntheticSectionPath.test.d.ts +0 -2
- package/dist/types/navigation/utils/__test__/syntheticSectionPath.test.d.ts.map +0 -1
- package/dist/types/navigation/utils/syntheticSectionPath.d.ts +0 -13
- package/dist/types/navigation/utils/syntheticSectionPath.d.ts.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as FernNavigation from "./index.js";
|
|
2
|
-
import { stripSyntheticSegments } from "./utils/syntheticSectionPath.js";
|
|
3
2
|
const STRUCTURAL_SEGMENT_TYPES = new Set([
|
|
4
3
|
"section",
|
|
5
4
|
"apiReference",
|
|
@@ -60,41 +59,6 @@ function metaStr(metadata, key) {
|
|
|
60
59
|
}
|
|
61
60
|
return undefined;
|
|
62
61
|
}
|
|
63
|
-
/**
|
|
64
|
-
* V1 availability values stored in ledger metadata are lowercase (e.g. "deprecated"),
|
|
65
|
-
* but the latest Availability type uses PascalCase (e.g. "Deprecated"). This map
|
|
66
|
-
* normalises both formats so the badge component can look up display names correctly.
|
|
67
|
-
*/
|
|
68
|
-
const AVAILABILITY_LOOKUP = {
|
|
69
|
-
// V1 lowercase values (stored by docsPublishTransform from V1 navigation tree)
|
|
70
|
-
alpha: FernNavigation.Availability.Alpha,
|
|
71
|
-
stable: FernNavigation.Availability.Stable,
|
|
72
|
-
"generally-available": FernNavigation.Availability.GenerallyAvailable,
|
|
73
|
-
"in-development": FernNavigation.Availability.InDevelopment,
|
|
74
|
-
"pre-release": FernNavigation.Availability.PreRelease,
|
|
75
|
-
deprecated: FernNavigation.Availability.Deprecated,
|
|
76
|
-
beta: FernNavigation.Availability.Beta,
|
|
77
|
-
preview: FernNavigation.Availability.Preview,
|
|
78
|
-
legacy: FernNavigation.Availability.Legacy,
|
|
79
|
-
// Latest PascalCase values (pass-through)
|
|
80
|
-
Alpha: FernNavigation.Availability.Alpha,
|
|
81
|
-
Stable: FernNavigation.Availability.Stable,
|
|
82
|
-
GenerallyAvailable: FernNavigation.Availability.GenerallyAvailable,
|
|
83
|
-
InDevelopment: FernNavigation.Availability.InDevelopment,
|
|
84
|
-
PreRelease: FernNavigation.Availability.PreRelease,
|
|
85
|
-
Deprecated: FernNavigation.Availability.Deprecated,
|
|
86
|
-
Beta: FernNavigation.Availability.Beta,
|
|
87
|
-
Preview: FernNavigation.Availability.Preview,
|
|
88
|
-
Legacy: FernNavigation.Availability.Legacy
|
|
89
|
-
};
|
|
90
|
-
/** Read an availability field from metadata, converting V1 lowercase to latest PascalCase. */
|
|
91
|
-
function metaAvailability(metadata) {
|
|
92
|
-
const raw = metaStr(metadata, "availability");
|
|
93
|
-
if (raw == null) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
return AVAILABILITY_LOOKUP[raw];
|
|
97
|
-
}
|
|
98
62
|
function metaBool(metadata, key) {
|
|
99
63
|
if (metadata != null && typeof metadata === "object" && key in metadata) {
|
|
100
64
|
const v = metadata[key];
|
|
@@ -233,7 +197,7 @@ function artifactToNode(ctx, route) {
|
|
|
233
197
|
}),
|
|
234
198
|
pageId: FernNavigation.PageId(pageId),
|
|
235
199
|
noindex: metaBool(md, "noindex"),
|
|
236
|
-
availability:
|
|
200
|
+
availability: undefined
|
|
237
201
|
};
|
|
238
202
|
return node;
|
|
239
203
|
}
|
|
@@ -304,7 +268,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
304
268
|
endpointId: FernNavigation.EndpointId(endpointId),
|
|
305
269
|
apiDefinitionId,
|
|
306
270
|
isResponseStream: metaBool(md, "isResponseStream"),
|
|
307
|
-
availability:
|
|
271
|
+
availability: metaStr(md, "availability"),
|
|
308
272
|
playground: undefined
|
|
309
273
|
};
|
|
310
274
|
}
|
|
@@ -320,7 +284,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
320
284
|
method: method,
|
|
321
285
|
webhookId: FernNavigation.WebhookId(webhookId),
|
|
322
286
|
apiDefinitionId,
|
|
323
|
-
availability:
|
|
287
|
+
availability: metaStr(md, "availability")
|
|
324
288
|
};
|
|
325
289
|
}
|
|
326
290
|
if (route.type === "asyncapi") {
|
|
@@ -333,7 +297,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
333
297
|
...meta,
|
|
334
298
|
webSocketId: FernNavigation.WebSocketId(webSocketId),
|
|
335
299
|
apiDefinitionId,
|
|
336
|
-
availability:
|
|
300
|
+
availability: metaStr(md, "availability"),
|
|
337
301
|
playground: undefined
|
|
338
302
|
};
|
|
339
303
|
}
|
|
@@ -349,7 +313,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
349
313
|
method: method,
|
|
350
314
|
grpcId: FernNavigation.GrpcId(grpcId),
|
|
351
315
|
apiDefinitionId,
|
|
352
|
-
availability:
|
|
316
|
+
availability: metaStr(md, "availability")
|
|
353
317
|
};
|
|
354
318
|
}
|
|
355
319
|
if (route.type === "graphql") {
|
|
@@ -365,7 +329,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
365
329
|
graphqlOperationId: FernNavigation.GraphQlOperationId(graphqlOperationId),
|
|
366
330
|
graphqlOperationIds: undefined,
|
|
367
331
|
apiDefinitionId,
|
|
368
|
-
availability:
|
|
332
|
+
availability: metaStr(md, "availability"),
|
|
369
333
|
playground: undefined
|
|
370
334
|
};
|
|
371
335
|
}
|
|
@@ -553,8 +517,7 @@ function structuralNodeSlug(ctx, overviewFullPath, section, scopePrefix) {
|
|
|
553
517
|
// basepath-absolute (it is the version/product/tab node's slug), so join it
|
|
554
518
|
// directly rather than going through `contentSlug` (which would re-prefix
|
|
555
519
|
// the basepath).
|
|
556
|
-
|
|
557
|
-
return cleanSection !== "" ? FernNavigation.slugjoin(scopePrefix, cleanSection) : scopePrefix;
|
|
520
|
+
return section !== "" ? FernNavigation.slugjoin(scopePrefix, section) : scopePrefix;
|
|
558
521
|
}
|
|
559
522
|
function stripLeadingScopePrefix(section, scopePrefix) {
|
|
560
523
|
const prefix = scopePrefix;
|
|
@@ -569,30 +532,6 @@ function stripLeadingScopePrefix(section, scopePrefix) {
|
|
|
569
532
|
}
|
|
570
533
|
return section;
|
|
571
534
|
}
|
|
572
|
-
function computeDuplicateSiblingSortBoundaries(siblings) {
|
|
573
|
-
const result = new Map();
|
|
574
|
-
const byPath = new Map();
|
|
575
|
-
for (const sibling of siblings) {
|
|
576
|
-
if (metaStr(sibling.seg.metadata, "type") !== "section") {
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
const group = byPath.get(sibling.seg.section) ?? [];
|
|
580
|
-
group.push(sibling);
|
|
581
|
-
byPath.set(sibling.seg.section, group);
|
|
582
|
-
}
|
|
583
|
-
for (const [, group] of byPath) {
|
|
584
|
-
if (group.length <= 1) {
|
|
585
|
-
continue;
|
|
586
|
-
}
|
|
587
|
-
for (let i = 0; i < group.length; i++) {
|
|
588
|
-
result.set(group[i], {
|
|
589
|
-
lo: group[i].seg.sortOrder,
|
|
590
|
-
hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return result;
|
|
595
|
-
}
|
|
596
535
|
/**
|
|
597
536
|
* Merge leaf children and section children by their original V1 tree position.
|
|
598
537
|
* Leaves carry position via `displaySortOrder` (stored in nav routes), sections
|
|
@@ -656,7 +595,7 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
656
595
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
657
596
|
collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) === true ? true : undefined),
|
|
658
597
|
collapsedByDefault: metaBool(seg.metadata, "collapsedByDefault") ?? (metaCollapsed(seg.metadata) === true ? true : undefined),
|
|
659
|
-
availability:
|
|
598
|
+
availability: metaStr(seg.metadata, "availability"),
|
|
660
599
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : undefined,
|
|
661
600
|
children: mergeChildrenByPosition(ctx, nav, sectionChildren)
|
|
662
601
|
};
|
|
@@ -666,16 +605,13 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
666
605
|
* `parentSectionPath(seg.section) === parentSection`, or is an orphaned segment
|
|
667
606
|
* whose nearest existing ancestor is `parentSection`.
|
|
668
607
|
*/
|
|
669
|
-
function directChildApiPackages(parentSection, scopeSegs
|
|
608
|
+
function directChildApiPackages(parentSection, scopeSegs) {
|
|
670
609
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
671
610
|
return scopeSegs
|
|
672
611
|
.filter((s) => {
|
|
673
612
|
if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
|
|
674
613
|
return false;
|
|
675
614
|
}
|
|
676
|
-
if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
|
|
677
|
-
return false;
|
|
678
|
-
}
|
|
679
615
|
const parent = parentSectionPath(s.seg.section);
|
|
680
616
|
if (parent === parentSection) {
|
|
681
617
|
return true;
|
|
@@ -700,7 +636,7 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
700
636
|
// API leaf types.
|
|
701
637
|
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
702
638
|
// Build nested ApiPackageNodes from direct child apiPackage segments.
|
|
703
|
-
const childPackages = directChildApiPackages(seg.section, scopeSegs
|
|
639
|
+
const childPackages = directChildApiPackages(seg.section, scopeSegs);
|
|
704
640
|
const packageNodes = childPackages.map((child) => ({
|
|
705
641
|
node: apiPackageChildNode(ctx, child, scopeSegs, apiDefinitionId, scopePrefix),
|
|
706
642
|
childIndex: metaNum(child.seg.metadata, "childIndex")
|
|
@@ -748,7 +684,7 @@ function apiPackageChildNode(ctx, scoped, scopeSegs, parentApiDefinitionId, scop
|
|
|
748
684
|
featureFlags: metaFeatureFlags(seg.metadata)
|
|
749
685
|
}),
|
|
750
686
|
apiDefinitionId: FernNavigation.ApiDefinitionId(apiDefinitionId),
|
|
751
|
-
availability:
|
|
687
|
+
availability: metaStr(seg.metadata, "availability"),
|
|
752
688
|
overviewPageId: overviewPageId != null ? FernNavigation.PageId(overviewPageId) : undefined,
|
|
753
689
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
754
690
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : undefined,
|
|
@@ -858,10 +794,10 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
|
|
|
858
794
|
featureFlags: metaFeatureFlags(seg.metadata)
|
|
859
795
|
}),
|
|
860
796
|
apiDefinitionId: FernNavigation.ApiDefinitionId(apiDefinitionId),
|
|
861
|
-
availability:
|
|
797
|
+
availability: metaStr(seg.metadata, "availability"),
|
|
862
798
|
overviewPageId: overviewPageId != null ? FernNavigation.PageId(overviewPageId) : undefined,
|
|
863
799
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
864
|
-
paginated:
|
|
800
|
+
paginated: true,
|
|
865
801
|
showErrors: metaBool(seg.metadata, "showErrors"),
|
|
866
802
|
hideTitle: metaBool(seg.metadata, "hideTitle"),
|
|
867
803
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : undefined,
|
|
@@ -879,12 +815,7 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
|
|
|
879
815
|
}
|
|
880
816
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
881
817
|
});
|
|
882
|
-
const
|
|
883
|
-
return (metaStr(candidate.seg.metadata, "type") === "apiReference" &&
|
|
884
|
-
metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId);
|
|
885
|
-
}).length;
|
|
886
|
-
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ??
|
|
887
|
-
(apiReferenceCount === 1 ? candidates[0] : undefined);
|
|
818
|
+
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? candidates[0];
|
|
888
819
|
return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : undefined;
|
|
889
820
|
}
|
|
890
821
|
function hasOwningApiReference(scoped, scopeSegs) {
|
|
@@ -892,68 +823,12 @@ function hasOwningApiReference(scoped, scopeSegs) {
|
|
|
892
823
|
if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
|
|
893
824
|
return false;
|
|
894
825
|
}
|
|
895
|
-
|
|
826
|
+
return scopeSegs.some((candidate) => {
|
|
896
827
|
if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
|
|
897
828
|
return false;
|
|
898
829
|
}
|
|
899
830
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
900
831
|
});
|
|
901
|
-
return (candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) ||
|
|
902
|
-
candidates.length === 1);
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* True when this segment is an `apiPackage` that will be nested under an in-scope
|
|
906
|
-
* `apiReference` for the same API by {@link buildApiChildren}, and therefore must
|
|
907
|
-
* NOT also be emitted as a standalone root/section node.
|
|
908
|
-
*
|
|
909
|
-
* Without this guard, a skip-slug apiReference (section "") leaves its resource
|
|
910
|
-
* subpackages with `parentSectionPath === ""`, so they look root-level and get
|
|
911
|
-
* emitted a second time as always-expanded top-level apiReference nodes —
|
|
912
|
-
* duplicating every resource and endpoint in the sidebar (the "67 apiReference
|
|
913
|
-
* nodes vs 1" API-reference regression).
|
|
914
|
-
*
|
|
915
|
-
* Reachability mirrors {@link directChildApiPackages}: walk up the section-path
|
|
916
|
-
* chain (hopping to nearestExistingAncestor when a parent section is absent)
|
|
917
|
-
* until we reach an apiReference's section. If no apiReference is an ancestor the
|
|
918
|
-
* package is left where it is, so it can never be dropped.
|
|
919
|
-
*/
|
|
920
|
-
function isNestedApiPackage(scoped, scopeSegs) {
|
|
921
|
-
if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
|
|
922
|
-
return false;
|
|
923
|
-
}
|
|
924
|
-
const apiDefinitionId = metaStr(scoped.seg.metadata, "apiDefinitionId");
|
|
925
|
-
if (apiDefinitionId == null) {
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
const apiReferenceSections = new Set(scopeSegs
|
|
929
|
-
.filter((s) => metaStr(s.seg.metadata, "type") === "apiReference" &&
|
|
930
|
-
metaStr(s.seg.metadata, "apiDefinitionId") === apiDefinitionId)
|
|
931
|
-
.map((s) => s.seg.section));
|
|
932
|
-
if (apiReferenceSections.size === 0) {
|
|
933
|
-
return false;
|
|
934
|
-
}
|
|
935
|
-
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
936
|
-
const resolveParent = (section) => {
|
|
937
|
-
const parent = parentSectionPath(section);
|
|
938
|
-
if (parent === "" || sectionPaths.has(parent)) {
|
|
939
|
-
return parent;
|
|
940
|
-
}
|
|
941
|
-
return nearestExistingAncestor(section, sectionPaths);
|
|
942
|
-
};
|
|
943
|
-
let current = scoped.seg.section;
|
|
944
|
-
const seen = new Set([current]);
|
|
945
|
-
// Walk up until we hit an owning apiReference (nested → true) or run out.
|
|
946
|
-
for (;;) {
|
|
947
|
-
const parent = resolveParent(current);
|
|
948
|
-
if (apiReferenceSections.has(parent)) {
|
|
949
|
-
return true;
|
|
950
|
-
}
|
|
951
|
-
if (parent === "" || seen.has(parent)) {
|
|
952
|
-
return false;
|
|
953
|
-
}
|
|
954
|
-
seen.add(parent);
|
|
955
|
-
current = parent;
|
|
956
|
-
}
|
|
957
832
|
}
|
|
958
833
|
function changelogNode(ctx, scoped, scopePrefix) {
|
|
959
834
|
const { seg, nav } = scoped;
|
|
@@ -1077,13 +952,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1077
952
|
if (sec === "" || type === "tabRoot") {
|
|
1078
953
|
return false;
|
|
1079
954
|
}
|
|
1080
|
-
if (hasOwningApiReference(s, scopeSegs)
|
|
1081
|
-
return false;
|
|
1082
|
-
}
|
|
1083
|
-
// Segments marked as sidebar depth 0 are V1 root-level peers and
|
|
1084
|
-
// must never be adopted as children of another section.
|
|
1085
|
-
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1086
|
-
if (depth === 0) {
|
|
955
|
+
if (hasOwningApiReference(s, scopeSegs)) {
|
|
1087
956
|
return false;
|
|
1088
957
|
}
|
|
1089
958
|
const parent = parentSectionPath(sec);
|
|
@@ -1098,7 +967,6 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1098
967
|
return false;
|
|
1099
968
|
})
|
|
1100
969
|
.sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1101
|
-
const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
|
|
1102
970
|
return direct.map((s) => {
|
|
1103
971
|
const type = metaStr(s.seg.metadata, "type");
|
|
1104
972
|
const childIndex = metaNum(s.seg.metadata, "childIndex");
|
|
@@ -1111,11 +979,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1111
979
|
}
|
|
1112
980
|
else {
|
|
1113
981
|
// section (or unrecognised) → recurse for nested sections.
|
|
1114
|
-
|
|
1115
|
-
const childScopeSegs = boundary != null
|
|
1116
|
-
? scopeSegs.filter((candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi)
|
|
1117
|
-
: scopeSegs;
|
|
1118
|
-
node = sectionNode(ctx, s, buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix), scopePrefix);
|
|
982
|
+
node = sectionNode(ctx, s, buildSectionTree(ctx, scopeSegs, s.seg.section, scopePrefix, changelogScopePrefix), scopePrefix);
|
|
1119
983
|
}
|
|
1120
984
|
return { node, childIndex };
|
|
1121
985
|
});
|
|
@@ -1135,26 +999,16 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1135
999
|
function computeSiblingSortBoundaries(ordered) {
|
|
1136
1000
|
const result = new Map();
|
|
1137
1001
|
// Collect root-level sections grouped by their section path.
|
|
1138
|
-
// Sections with sec==="" (skip-slug sections) are included: when multiple
|
|
1139
|
-
// skip-slug sections exist at the root, they share path "" and need
|
|
1140
|
-
// boundaries so each only adopts its own children.
|
|
1141
1002
|
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1142
1003
|
const rootSections = [];
|
|
1143
1004
|
for (const s of ordered) {
|
|
1144
1005
|
const type = metaStr(s.seg.metadata, "type");
|
|
1145
1006
|
const sec = s.seg.section;
|
|
1146
|
-
if (type !== "section") {
|
|
1147
|
-
continue;
|
|
1148
|
-
}
|
|
1149
|
-
if (sec === "") {
|
|
1150
|
-
rootSections.push(s);
|
|
1007
|
+
if (type !== "section" || sec === "") {
|
|
1151
1008
|
continue;
|
|
1152
1009
|
}
|
|
1153
|
-
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1154
1010
|
const parent = parentSectionPath(sec);
|
|
1155
|
-
const isRootLevel =
|
|
1156
|
-
parent === "" ||
|
|
1157
|
-
(!sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "");
|
|
1011
|
+
const isRootLevel = parent === "" || (!sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "");
|
|
1158
1012
|
if (isRootLevel) {
|
|
1159
1013
|
rootSections.push(s);
|
|
1160
1014
|
}
|
|
@@ -1199,17 +1053,6 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1199
1053
|
// segments. Both index into the SAME child list at write time, so they
|
|
1200
1054
|
// interleave directly (e.g. [page 0, page 1, section 2…15, page 16, 17]).
|
|
1201
1055
|
const annotated = [];
|
|
1202
|
-
// ── Sibling section ownership ────────────────────────────────────────
|
|
1203
|
-
//
|
|
1204
|
-
// Multiple root-level sections can share the same section path (e.g.
|
|
1205
|
-
// three sections all with path equal to the version slug). When this
|
|
1206
|
-
// happens, buildSectionTree would incorrectly give ALL child subsections
|
|
1207
|
-
// to each sibling. We resolve ownership via sortOrder: a section owns
|
|
1208
|
-
// segments whose sortOrder falls between its own and the next sibling's.
|
|
1209
|
-
//
|
|
1210
|
-
// Computed first because hasRootSection (below) uses it to decide
|
|
1211
|
-
// whether bounded skip-slug siblings should activate adoption.
|
|
1212
|
-
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1213
1056
|
// ── Root-section adoption flow ──────────────────────────────────────
|
|
1214
1057
|
//
|
|
1215
1058
|
// A scope may contain a "root section" — a segment with type "section"
|
|
@@ -1221,31 +1064,26 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1221
1064
|
// │ → emit pages/links inline at their displaySortOrder
|
|
1222
1065
|
// │
|
|
1223
1066
|
// ├─ (B) the root section itself (sec=="", type=="section")
|
|
1224
|
-
// │ → buildSectionTree adopts
|
|
1225
|
-
// │ → emit one sectionNode wrapping the subtree
|
|
1067
|
+
// │ → buildSectionTree adopts ALL depth-0 children as its own
|
|
1068
|
+
// │ → emit one sectionNode wrapping the whole subtree
|
|
1226
1069
|
// │
|
|
1227
|
-
// └─ (C) depth-0 sections (
|
|
1228
|
-
// →
|
|
1070
|
+
// └─ (C) depth-0 sections (parentSectionPath=="")
|
|
1071
|
+
// → SKIP — already adopted by (B) via buildSectionTree
|
|
1229
1072
|
//
|
|
1230
1073
|
// Without a root section, depth-0 sections are emitted directly.
|
|
1074
|
+
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
|
|
1075
|
+
// ── Sibling section ownership ────────────────────────────────────────
|
|
1231
1076
|
//
|
|
1232
|
-
//
|
|
1233
|
-
//
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
//
|
|
1237
|
-
|
|
1238
|
-
// boundaries (multiple sec="" sections sharing the same path), which
|
|
1239
|
-
// correctly scope each section's children. A *single* unbounded
|
|
1240
|
-
// skip-slug sibling (e.g. mangopay's "Introduction") must NOT adopt
|
|
1241
|
-
// its depth-0 peers — doing so produces spurious breadcrumb entries.
|
|
1242
|
-
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" &&
|
|
1243
|
-
s.seg.section === "" &&
|
|
1244
|
-
(metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s)));
|
|
1077
|
+
// Multiple root-level sections can share the same section path (e.g.
|
|
1078
|
+
// three sections all with path equal to the version slug). When this
|
|
1079
|
+
// happens, buildSectionTree would incorrectly give ALL child subsections
|
|
1080
|
+
// to each sibling. We resolve ownership via sortOrder: a section owns
|
|
1081
|
+
// segments whose sortOrder falls between its own and the next sibling's.
|
|
1082
|
+
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1245
1083
|
for (const s of ordered) {
|
|
1246
1084
|
const type = metaStr(s.seg.metadata, "type");
|
|
1247
1085
|
const sec = s.seg.section;
|
|
1248
|
-
if (hasOwningApiReference(s, scopeSegs)
|
|
1086
|
+
if (hasOwningApiReference(s, scopeSegs)) {
|
|
1249
1087
|
continue;
|
|
1250
1088
|
}
|
|
1251
1089
|
if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
|
|
@@ -1264,33 +1102,21 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1264
1102
|
continue;
|
|
1265
1103
|
}
|
|
1266
1104
|
// (B) Root section wrapper — adopts depth-0 children via buildSectionTree.
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
// When multiple sections share sec==="" (skip-slug), scope children
|
|
1270
|
-
// to each section's sortOrder range so subsections aren't duplicated.
|
|
1271
|
-
if (type === "section" && sec === "" && hasRootSection) {
|
|
1272
|
-
const bounds = siblingBoundaries.get(s);
|
|
1273
|
-
const ownedSegs = bounds != null
|
|
1274
|
-
? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi)
|
|
1275
|
-
: scopeSegs;
|
|
1276
|
-
const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
|
|
1105
|
+
if (type === "section" && sec === "") {
|
|
1106
|
+
const sectionChildren = buildSectionTree(ctx, scopeSegs, "", scopePrefix);
|
|
1277
1107
|
const node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1278
1108
|
annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
|
|
1279
1109
|
continue;
|
|
1280
1110
|
}
|
|
1281
1111
|
// (C) Depth-0 or orphaned sections — emit at root unless already
|
|
1282
1112
|
// adopted by a root section (B).
|
|
1283
|
-
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1284
1113
|
const parent = parentSectionPath(sec);
|
|
1285
|
-
const isRootLevel =
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
//
|
|
1289
|
-
//
|
|
1290
|
-
|
|
1291
|
-
// Only skip sections without sidebarDepth (old data) that would still
|
|
1292
|
-
// be adopted by path-based hierarchy in buildSectionTree.
|
|
1293
|
-
if (isRootLevel && hasRootSection && sec !== "" && depth == null) {
|
|
1114
|
+
const isRootLevel = parent === "" || (!sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "");
|
|
1115
|
+
// Skip depth-0 sections already adopted by the root section wrapper (B),
|
|
1116
|
+
// but NOT structural types with sec="" (skip-slug). buildSectionTree
|
|
1117
|
+
// filters out sec="" segments (line 1249), so they wouldn't be adopted
|
|
1118
|
+
// and must be emitted here directly.
|
|
1119
|
+
if (isRootLevel && hasRootSection && sec !== "") {
|
|
1294
1120
|
continue;
|
|
1295
1121
|
}
|
|
1296
1122
|
if (isRootLevel) {
|
|
@@ -1308,20 +1134,7 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1308
1134
|
const ownedSegs = bounds != null
|
|
1309
1135
|
? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi)
|
|
1310
1136
|
: scopeSegs;
|
|
1311
|
-
|
|
1312
|
-
// root wrapper in case B) is a skipUrlSlug sibling.
|
|
1313
|
-
// When sortOrder boundaries exist (multiple sec="" sections),
|
|
1314
|
-
// the scoped ownedSegs correctly limits which subsections
|
|
1315
|
-
// each section can adopt. When there are NO boundaries
|
|
1316
|
-
// (single sec="" section, e.g. mangopay's "Introduction"),
|
|
1317
|
-
// buildSectionTree("") would re-adopt all depth-0 peers;
|
|
1318
|
-
// pass an empty child list instead — its leaf artifacts are
|
|
1319
|
-
// already in its own segment nav.
|
|
1320
|
-
const isUnboundedSkipSlugSibling = sec === "" && metaNum(s.seg.metadata, "childIndex") != null && bounds == null;
|
|
1321
|
-
const sectionChildren = isUnboundedSkipSlugSibling
|
|
1322
|
-
? []
|
|
1323
|
-
: buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix);
|
|
1324
|
-
node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1137
|
+
node = sectionNode(ctx, s, buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix), scopePrefix);
|
|
1325
1138
|
}
|
|
1326
1139
|
// Shared/merged sections (paths not rooted in scopePrefix) must not
|
|
1327
1140
|
// carry childIndex — their source-version positions would sort them
|
|
@@ -1391,6 +1204,11 @@ function groupSidebarRootChildren(ctx, children) {
|
|
|
1391
1204
|
flushRun();
|
|
1392
1205
|
out.push(child);
|
|
1393
1206
|
}
|
|
1207
|
+
else if (child.type === "changelog") {
|
|
1208
|
+
flushRun();
|
|
1209
|
+
run.push(child);
|
|
1210
|
+
flushRun();
|
|
1211
|
+
}
|
|
1394
1212
|
else {
|
|
1395
1213
|
run.push(child);
|
|
1396
1214
|
}
|
|
@@ -1557,7 +1375,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
|
|
|
1557
1375
|
? asSlug(FernNavigation.slugjoin(scopePrefix, variantIndividualSlug))
|
|
1558
1376
|
: scopePrefix;
|
|
1559
1377
|
const metaPointsTo = metaStr(variant.metadata, "pointsTo");
|
|
1560
|
-
const children = buildSidebarRootChildren(ctx, variantSegs,
|
|
1378
|
+
const children = buildSidebarRootChildren(ctx, variantSegs, scopePrefix);
|
|
1561
1379
|
return {
|
|
1562
1380
|
type: "variant",
|
|
1563
1381
|
...withMetadataDefaults({
|
|
@@ -2093,14 +1911,6 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2093
1911
|
};
|
|
2094
1912
|
return node;
|
|
2095
1913
|
});
|
|
2096
|
-
// Cross-product canonical slug deduplication (V2 parity).
|
|
2097
|
-
// V2's migrator deduplicates pages across products via a global pageId map:
|
|
2098
|
-
// the first product to register a pageId wins, and subsequent products'
|
|
2099
|
-
// pages with the same pageId receive a canonicalSlug pointing to the
|
|
2100
|
-
// canonical (default-product) page. Without this, shared content that is
|
|
2101
|
-
// materialized under every product scope (e.g. merge-api-basics pages)
|
|
2102
|
-
// appears as separate sitemap entries per product.
|
|
2103
|
-
markCrossProductCanonicalSlugs(children);
|
|
2104
1914
|
return {
|
|
2105
1915
|
type: "productgroup",
|
|
2106
1916
|
id: ctx.nodeId("productgroup"),
|
|
@@ -2109,43 +1919,5 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2109
1919
|
children
|
|
2110
1920
|
};
|
|
2111
1921
|
}
|
|
2112
|
-
/**
|
|
2113
|
-
* Deduplicate pages across products using pageId as a content-identity key.
|
|
2114
|
-
* Pages with the same pageId in different products are the same content
|
|
2115
|
-
* materialized per-scope; the default product's slug becomes canonical and
|
|
2116
|
-
* non-default copies receive `canonicalSlug` so the sitemap collapses them.
|
|
2117
|
-
*
|
|
2118
|
-
* API leaf nodes (endpoints, websockets, etc.) are unaffected — `getPageId`
|
|
2119
|
-
* returns undefined for those types, so product-specific API surface is
|
|
2120
|
-
* never suppressed.
|
|
2121
|
-
*/
|
|
2122
|
-
function markCrossProductCanonicalSlugs(productNodes) {
|
|
2123
|
-
const pageIdToCanonical = new Map();
|
|
2124
|
-
// Process default product first so its slugs become the canonical targets.
|
|
2125
|
-
const sorted = [...productNodes].sort((a, b) => {
|
|
2126
|
-
if (a.default !== b.default) {
|
|
2127
|
-
return a.default ? -1 : 1;
|
|
2128
|
-
}
|
|
2129
|
-
return 0;
|
|
2130
|
-
});
|
|
2131
|
-
for (const product of sorted) {
|
|
2132
|
-
FernNavigation.traverseDF(product, (child) => {
|
|
2133
|
-
if (FernNavigation.hasMetadata(child) && FernNavigation.isPage(child)) {
|
|
2134
|
-
const pid = FernNavigation.getPageId(child);
|
|
2135
|
-
if (pid == null) {
|
|
2136
|
-
return;
|
|
2137
|
-
}
|
|
2138
|
-
const key = `pid:${pid}`;
|
|
2139
|
-
const canonical = pageIdToCanonical.get(key);
|
|
2140
|
-
if (canonical != null && !product.default) {
|
|
2141
|
-
child.canonicalSlug = canonical;
|
|
2142
|
-
}
|
|
2143
|
-
else if (canonical == null) {
|
|
2144
|
-
pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
});
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
1922
|
// (root keeps the bare "root" id; it is the single tree root.)
|
|
2151
1923
|
//# sourceMappingURL=ledger-root-builder.js.map
|