@fern-api/fdr-sdk 1.2.41-f793e24db2 → 1.2.42-080b4f1d94
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/client/FdrClient.js +1 -0
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +1 -0
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/converters/index.js +9 -0
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +9 -0
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +10 -0
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +10 -0
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +9 -0
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +9 -0
- package/dist/js/navigation/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +212 -36
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +212 -36
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/js/orpc-client.js +1 -0
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +1 -0
- package/dist/js/orpc-client.mjs.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js +267 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js +306 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.metadataPreservation.test.js +167 -4
- package/dist/navigation/__test__/ledger-root-builder.metadataPreservation.test.js.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js +102 -0
- package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js +273 -0
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugApiReference.test.js +276 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugApiReference.test.js.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js +234 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js +360 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +1 -0
- package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/navigation/ledger-root-builder.js +312 -47
- package/dist/navigation/ledger-root-builder.js.map +1 -1
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.d.ts +2 -0
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.d.ts.map +1 -0
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.js +29 -0
- package/dist/navigation/utils/__test__/syntheticSectionPath.test.js.map +1 -0
- package/dist/navigation/utils/index.d.ts +1 -0
- package/dist/navigation/utils/index.d.ts.map +1 -1
- package/dist/navigation/utils/index.js +1 -0
- package/dist/navigation/utils/index.js.map +1 -1
- package/dist/navigation/utils/syntheticSectionPath.d.ts +13 -0
- package/dist/navigation/utils/syntheticSectionPath.d.ts.map +1 -0
- package/dist/navigation/utils/syntheticSectionPath.js +20 -0
- package/dist/navigation/utils/syntheticSectionPath.js.map +1 -0
- package/dist/orpc-client/docs-ledger/contract.d.ts +9 -0
- package/dist/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/dist/orpc-client/docs-ledger/contract.js +1 -0
- package/dist/orpc-client/docs-ledger/contract.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +1 -0
- package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/types/navigation/utils/__test__/syntheticSectionPath.test.d.ts +2 -0
- package/dist/types/navigation/utils/__test__/syntheticSectionPath.test.d.ts.map +1 -0
- package/dist/types/navigation/utils/index.d.ts +1 -0
- package/dist/types/navigation/utils/index.d.ts.map +1 -1
- package/dist/types/navigation/utils/syntheticSectionPath.d.ts +13 -0
- package/dist/types/navigation/utils/syntheticSectionPath.d.ts.map +1 -0
- package/dist/types/orpc-client/docs-ledger/contract.d.ts +9 -0
- package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -92,6 +92,17 @@ var VersionIdSchema = z.string();
|
|
|
92
92
|
function VersionId(value) {
|
|
93
93
|
return value;
|
|
94
94
|
}
|
|
95
|
+
var Availability = {
|
|
96
|
+
Alpha: "Alpha",
|
|
97
|
+
Stable: "Stable",
|
|
98
|
+
GenerallyAvailable: "GenerallyAvailable",
|
|
99
|
+
InDevelopment: "InDevelopment",
|
|
100
|
+
PreRelease: "PreRelease",
|
|
101
|
+
Deprecated: "Deprecated",
|
|
102
|
+
Beta: "Beta",
|
|
103
|
+
Preview: "Preview",
|
|
104
|
+
Legacy: "Legacy"
|
|
105
|
+
};
|
|
95
106
|
var SnippetsByEndpointMethodSchema = z.record(
|
|
96
107
|
HttpMethodSchema,
|
|
97
108
|
z.array(z.unknown())
|
|
@@ -845,6 +856,12 @@ function traverseDF(node, visit) {
|
|
|
845
856
|
return dfs(node, visit, getChildren);
|
|
846
857
|
}
|
|
847
858
|
|
|
859
|
+
// src/navigation/utils/syntheticSectionPath.ts
|
|
860
|
+
var SYNTHETIC_SEGMENT_RE = /^~\d+$/;
|
|
861
|
+
function stripSyntheticSegments(section) {
|
|
862
|
+
return section.split("/").filter((part) => !SYNTHETIC_SEGMENT_RE.test(part)).join("/");
|
|
863
|
+
}
|
|
864
|
+
|
|
848
865
|
// src/navigation/ledger-root-builder.ts
|
|
849
866
|
var STRUCTURAL_SEGMENT_TYPES = /* @__PURE__ */ new Set([
|
|
850
867
|
"section",
|
|
@@ -882,6 +899,35 @@ function metaStr(metadata, key) {
|
|
|
882
899
|
}
|
|
883
900
|
return void 0;
|
|
884
901
|
}
|
|
902
|
+
var AVAILABILITY_LOOKUP = {
|
|
903
|
+
// V1 lowercase values (stored by docsPublishTransform from V1 navigation tree)
|
|
904
|
+
alpha: Availability.Alpha,
|
|
905
|
+
stable: Availability.Stable,
|
|
906
|
+
"generally-available": Availability.GenerallyAvailable,
|
|
907
|
+
"in-development": Availability.InDevelopment,
|
|
908
|
+
"pre-release": Availability.PreRelease,
|
|
909
|
+
deprecated: Availability.Deprecated,
|
|
910
|
+
beta: Availability.Beta,
|
|
911
|
+
preview: Availability.Preview,
|
|
912
|
+
legacy: Availability.Legacy,
|
|
913
|
+
// Latest PascalCase values (pass-through)
|
|
914
|
+
Alpha: Availability.Alpha,
|
|
915
|
+
Stable: Availability.Stable,
|
|
916
|
+
GenerallyAvailable: Availability.GenerallyAvailable,
|
|
917
|
+
InDevelopment: Availability.InDevelopment,
|
|
918
|
+
PreRelease: Availability.PreRelease,
|
|
919
|
+
Deprecated: Availability.Deprecated,
|
|
920
|
+
Beta: Availability.Beta,
|
|
921
|
+
Preview: Availability.Preview,
|
|
922
|
+
Legacy: Availability.Legacy
|
|
923
|
+
};
|
|
924
|
+
function metaAvailability(metadata) {
|
|
925
|
+
const raw = metaStr(metadata, "availability");
|
|
926
|
+
if (raw == null) {
|
|
927
|
+
return void 0;
|
|
928
|
+
}
|
|
929
|
+
return AVAILABILITY_LOOKUP[raw];
|
|
930
|
+
}
|
|
885
931
|
function metaBool(metadata, key) {
|
|
886
932
|
if (metadata != null && typeof metadata === "object" && key in metadata) {
|
|
887
933
|
const v = metadata[key];
|
|
@@ -999,7 +1045,7 @@ function artifactToNode(ctx, route) {
|
|
|
999
1045
|
}),
|
|
1000
1046
|
pageId: PageId(pageId),
|
|
1001
1047
|
noindex: metaBool(md, "noindex"),
|
|
1002
|
-
availability:
|
|
1048
|
+
availability: metaAvailability(md)
|
|
1003
1049
|
};
|
|
1004
1050
|
return node;
|
|
1005
1051
|
}
|
|
@@ -1064,7 +1110,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
|
|
|
1064
1110
|
endpointId: EndpointId(endpointId),
|
|
1065
1111
|
apiDefinitionId,
|
|
1066
1112
|
isResponseStream: metaBool(md, "isResponseStream"),
|
|
1067
|
-
availability:
|
|
1113
|
+
availability: metaAvailability(md),
|
|
1068
1114
|
playground: void 0
|
|
1069
1115
|
};
|
|
1070
1116
|
}
|
|
@@ -1080,7 +1126,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
|
|
|
1080
1126
|
method,
|
|
1081
1127
|
webhookId: WebhookId(webhookId),
|
|
1082
1128
|
apiDefinitionId,
|
|
1083
|
-
availability:
|
|
1129
|
+
availability: metaAvailability(md)
|
|
1084
1130
|
};
|
|
1085
1131
|
}
|
|
1086
1132
|
if (route.type === "asyncapi") {
|
|
@@ -1093,7 +1139,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
|
|
|
1093
1139
|
...meta,
|
|
1094
1140
|
webSocketId: WebSocketId(webSocketId),
|
|
1095
1141
|
apiDefinitionId,
|
|
1096
|
-
availability:
|
|
1142
|
+
availability: metaAvailability(md),
|
|
1097
1143
|
playground: void 0
|
|
1098
1144
|
};
|
|
1099
1145
|
}
|
|
@@ -1109,7 +1155,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
|
|
|
1109
1155
|
method,
|
|
1110
1156
|
grpcId: GrpcId(grpcId),
|
|
1111
1157
|
apiDefinitionId,
|
|
1112
|
-
availability:
|
|
1158
|
+
availability: metaAvailability(md)
|
|
1113
1159
|
};
|
|
1114
1160
|
}
|
|
1115
1161
|
if (route.type === "graphql") {
|
|
@@ -1125,7 +1171,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
|
|
|
1125
1171
|
graphqlOperationId: GraphQlOperationId(graphqlOperationId),
|
|
1126
1172
|
graphqlOperationIds: void 0,
|
|
1127
1173
|
apiDefinitionId,
|
|
1128
|
-
availability:
|
|
1174
|
+
availability: metaAvailability(md),
|
|
1129
1175
|
playground: void 0
|
|
1130
1176
|
};
|
|
1131
1177
|
}
|
|
@@ -1238,7 +1284,8 @@ function structuralNodeSlug(ctx, overviewFullPath, section, scopePrefix) {
|
|
|
1238
1284
|
if (overviewFullPath != null) {
|
|
1239
1285
|
return ctx.contentSlug(overviewFullPath);
|
|
1240
1286
|
}
|
|
1241
|
-
|
|
1287
|
+
const cleanSection = stripSyntheticSegments(section);
|
|
1288
|
+
return cleanSection !== "" ? slugjoin(scopePrefix, cleanSection) : scopePrefix;
|
|
1242
1289
|
}
|
|
1243
1290
|
function stripLeadingScopePrefix(section, scopePrefix) {
|
|
1244
1291
|
const prefix = scopePrefix;
|
|
@@ -1253,6 +1300,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
|
|
|
1253
1300
|
}
|
|
1254
1301
|
return section;
|
|
1255
1302
|
}
|
|
1303
|
+
function computeDuplicateSiblingSortBoundaries(siblings) {
|
|
1304
|
+
const result = /* @__PURE__ */ new Map();
|
|
1305
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1306
|
+
for (const sibling of siblings) {
|
|
1307
|
+
if (metaStr(sibling.seg.metadata, "type") !== "section") {
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
const group = byPath.get(sibling.seg.section) ?? [];
|
|
1311
|
+
group.push(sibling);
|
|
1312
|
+
byPath.set(sibling.seg.section, group);
|
|
1313
|
+
}
|
|
1314
|
+
for (const [, group] of byPath) {
|
|
1315
|
+
if (group.length <= 1) {
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
for (let i = 0; i < group.length; i++) {
|
|
1319
|
+
result.set(group[i], {
|
|
1320
|
+
lo: group[i].seg.sortOrder,
|
|
1321
|
+
hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return result;
|
|
1326
|
+
}
|
|
1256
1327
|
function mergeChildrenByPosition(ctx, nav, sectionChildren) {
|
|
1257
1328
|
const leafNodes = [];
|
|
1258
1329
|
for (let i = 0; i < nav.length; i++) {
|
|
@@ -1302,17 +1373,20 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
1302
1373
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1303
1374
|
collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) === true ? true : void 0),
|
|
1304
1375
|
collapsedByDefault: metaBool(seg.metadata, "collapsedByDefault") ?? (metaCollapsed(seg.metadata) === true ? true : void 0),
|
|
1305
|
-
availability:
|
|
1376
|
+
availability: metaAvailability(seg.metadata),
|
|
1306
1377
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
1307
1378
|
children: mergeChildrenByPosition(ctx, nav, sectionChildren)
|
|
1308
1379
|
};
|
|
1309
1380
|
}
|
|
1310
|
-
function directChildApiPackages(parentSection, scopeSegs) {
|
|
1381
|
+
function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
|
|
1311
1382
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
1312
1383
|
return scopeSegs.filter((s) => {
|
|
1313
1384
|
if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
|
|
1314
1385
|
return false;
|
|
1315
1386
|
}
|
|
1387
|
+
if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1316
1390
|
const parent = parentSectionPath(s.seg.section);
|
|
1317
1391
|
if (parent === parentSection) {
|
|
1318
1392
|
return true;
|
|
@@ -1326,7 +1400,17 @@ function directChildApiPackages(parentSection, scopeSegs) {
|
|
|
1326
1400
|
function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
|
|
1327
1401
|
const { seg, nav } = scoped;
|
|
1328
1402
|
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
1329
|
-
|
|
1403
|
+
let childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
|
|
1404
|
+
const samePathApiSiblings = scopeSegs.filter(
|
|
1405
|
+
(s) => s.seg.section === seg.section && s.seg.sortOrder !== seg.sortOrder && API_NODE_SEGMENT_TYPES.has(metaStr(s.seg.metadata, "type") ?? "")
|
|
1406
|
+
);
|
|
1407
|
+
const hasCollapsedGroups = samePathApiSiblings.length > 0;
|
|
1408
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") !== "apiReference") {
|
|
1409
|
+
const nextSibling = samePathApiSiblings.filter((s) => s.seg.sortOrder > seg.sortOrder).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder)[0];
|
|
1410
|
+
const lo = seg.sortOrder;
|
|
1411
|
+
const hi = nextSibling?.seg.sortOrder ?? Number.MAX_SAFE_INTEGER;
|
|
1412
|
+
childPackages = childPackages.filter((c) => c.seg.sortOrder > lo && c.seg.sortOrder < hi);
|
|
1413
|
+
}
|
|
1330
1414
|
const packageNodes = childPackages.map((child) => ({
|
|
1331
1415
|
node: apiPackageChildNode(
|
|
1332
1416
|
ctx,
|
|
@@ -1337,6 +1421,9 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
1337
1421
|
),
|
|
1338
1422
|
childIndex: metaNum(child.seg.metadata, "childIndex")
|
|
1339
1423
|
}));
|
|
1424
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") === "apiReference") {
|
|
1425
|
+
return [...leafNodes, ...packageNodes.map((p, i) => ({ node: p.node, pos: leafNodes.length + i }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
1426
|
+
}
|
|
1340
1427
|
const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
|
|
1341
1428
|
if (!hasChildIndex) {
|
|
1342
1429
|
return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
@@ -1376,7 +1463,7 @@ function apiPackageChildNode(ctx, scoped, scopeSegs, parentApiDefinitionId, scop
|
|
|
1376
1463
|
featureFlags: metaFeatureFlags(seg.metadata)
|
|
1377
1464
|
}),
|
|
1378
1465
|
apiDefinitionId: ApiDefinitionId(apiDefinitionId),
|
|
1379
|
-
availability:
|
|
1466
|
+
availability: metaAvailability(seg.metadata),
|
|
1380
1467
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1381
1468
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1382
1469
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
@@ -1464,10 +1551,10 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
|
|
|
1464
1551
|
featureFlags: metaFeatureFlags(seg.metadata)
|
|
1465
1552
|
}),
|
|
1466
1553
|
apiDefinitionId: ApiDefinitionId(apiDefinitionId),
|
|
1467
|
-
availability:
|
|
1554
|
+
availability: metaAvailability(seg.metadata),
|
|
1468
1555
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1469
1556
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1470
|
-
paginated:
|
|
1557
|
+
paginated: metaBool(seg.metadata, "paginated"),
|
|
1471
1558
|
showErrors: metaBool(seg.metadata, "showErrors"),
|
|
1472
1559
|
hideTitle: metaBool(seg.metadata, "hideTitle"),
|
|
1473
1560
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
@@ -1485,7 +1572,10 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
|
|
|
1485
1572
|
}
|
|
1486
1573
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1487
1574
|
});
|
|
1488
|
-
const
|
|
1575
|
+
const apiReferenceCount = scopeSegs.filter((candidate) => {
|
|
1576
|
+
return metaStr(candidate.seg.metadata, "type") === "apiReference" && metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1577
|
+
}).length;
|
|
1578
|
+
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? (apiReferenceCount === 1 ? candidates[0] : void 0);
|
|
1489
1579
|
return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : void 0;
|
|
1490
1580
|
}
|
|
1491
1581
|
function hasOwningApiReference(scoped, scopeSegs) {
|
|
@@ -1493,12 +1583,51 @@ function hasOwningApiReference(scoped, scopeSegs) {
|
|
|
1493
1583
|
if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
|
|
1494
1584
|
return false;
|
|
1495
1585
|
}
|
|
1496
|
-
|
|
1586
|
+
const candidates = scopeSegs.filter((candidate) => {
|
|
1497
1587
|
if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
|
|
1498
1588
|
return false;
|
|
1499
1589
|
}
|
|
1500
1590
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1501
1591
|
});
|
|
1592
|
+
return candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) || candidates.length === 1;
|
|
1593
|
+
}
|
|
1594
|
+
function isNestedApiPackage(scoped, scopeSegs) {
|
|
1595
|
+
if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
|
|
1596
|
+
return false;
|
|
1597
|
+
}
|
|
1598
|
+
const apiDefinitionId = metaStr(scoped.seg.metadata, "apiDefinitionId");
|
|
1599
|
+
if (apiDefinitionId == null) {
|
|
1600
|
+
return false;
|
|
1601
|
+
}
|
|
1602
|
+
const apiReferenceSections = new Set(
|
|
1603
|
+
scopeSegs.filter(
|
|
1604
|
+
(s) => metaStr(s.seg.metadata, "type") === "apiReference" && metaStr(s.seg.metadata, "apiDefinitionId") === apiDefinitionId
|
|
1605
|
+
).map((s) => s.seg.section)
|
|
1606
|
+
);
|
|
1607
|
+
if (apiReferenceSections.size === 0) {
|
|
1608
|
+
return false;
|
|
1609
|
+
}
|
|
1610
|
+
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
1611
|
+
const resolveParent = (section) => {
|
|
1612
|
+
const parent = parentSectionPath(section);
|
|
1613
|
+
if (parent === "" || sectionPaths.has(parent)) {
|
|
1614
|
+
return parent;
|
|
1615
|
+
}
|
|
1616
|
+
return nearestExistingAncestor(section, sectionPaths);
|
|
1617
|
+
};
|
|
1618
|
+
let current = scoped.seg.section;
|
|
1619
|
+
const seen = /* @__PURE__ */ new Set([current]);
|
|
1620
|
+
for (; ; ) {
|
|
1621
|
+
const parent = resolveParent(current);
|
|
1622
|
+
if (apiReferenceSections.has(parent)) {
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
if (parent === "" || seen.has(parent)) {
|
|
1626
|
+
return false;
|
|
1627
|
+
}
|
|
1628
|
+
seen.add(parent);
|
|
1629
|
+
current = parent;
|
|
1630
|
+
}
|
|
1502
1631
|
}
|
|
1503
1632
|
function changelogNode(ctx, scoped, scopePrefix) {
|
|
1504
1633
|
const { seg, nav } = scoped;
|
|
@@ -1603,7 +1732,11 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1603
1732
|
if (sec === "" || type === "tabRoot") {
|
|
1604
1733
|
return false;
|
|
1605
1734
|
}
|
|
1606
|
-
if (hasOwningApiReference(s, scopeSegs)) {
|
|
1735
|
+
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1736
|
+
return false;
|
|
1737
|
+
}
|
|
1738
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1739
|
+
if (depth === 0) {
|
|
1607
1740
|
return false;
|
|
1608
1741
|
}
|
|
1609
1742
|
const parent = parentSectionPath(sec);
|
|
@@ -1615,6 +1748,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1615
1748
|
}
|
|
1616
1749
|
return false;
|
|
1617
1750
|
}).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1751
|
+
const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
|
|
1618
1752
|
return direct.map((s) => {
|
|
1619
1753
|
const type = metaStr(s.seg.metadata, "type");
|
|
1620
1754
|
const childIndex = metaNum(s.seg.metadata, "childIndex");
|
|
@@ -1624,10 +1758,14 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1624
1758
|
} else if (type === "changelog") {
|
|
1625
1759
|
node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
|
|
1626
1760
|
} else {
|
|
1761
|
+
const boundary = siblingBoundaries.get(s);
|
|
1762
|
+
const childScopeSegs = boundary != null ? scopeSegs.filter(
|
|
1763
|
+
(candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
|
|
1764
|
+
) : scopeSegs;
|
|
1627
1765
|
node = sectionNode(
|
|
1628
1766
|
ctx,
|
|
1629
1767
|
s,
|
|
1630
|
-
buildSectionTree(ctx,
|
|
1768
|
+
buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
|
|
1631
1769
|
scopePrefix
|
|
1632
1770
|
);
|
|
1633
1771
|
}
|
|
@@ -1641,11 +1779,16 @@ function computeSiblingSortBoundaries(ordered) {
|
|
|
1641
1779
|
for (const s of ordered) {
|
|
1642
1780
|
const type = metaStr(s.seg.metadata, "type");
|
|
1643
1781
|
const sec = s.seg.section;
|
|
1644
|
-
if (type !== "section"
|
|
1782
|
+
if (type !== "section") {
|
|
1783
|
+
continue;
|
|
1784
|
+
}
|
|
1785
|
+
if (sec === "") {
|
|
1786
|
+
rootSections.push(s);
|
|
1645
1787
|
continue;
|
|
1646
1788
|
}
|
|
1789
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1647
1790
|
const parent = parentSectionPath(sec);
|
|
1648
|
-
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1791
|
+
const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1649
1792
|
if (isRootLevel) {
|
|
1650
1793
|
rootSections.push(s);
|
|
1651
1794
|
}
|
|
@@ -1672,14 +1815,24 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1672
1815
|
const ordered = [...scopeSegs].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1673
1816
|
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1674
1817
|
const annotated = [];
|
|
1675
|
-
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
|
|
1676
1818
|
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1819
|
+
const hasRootSection = ordered.some(
|
|
1820
|
+
(s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && (metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s))
|
|
1821
|
+
);
|
|
1677
1822
|
for (const s of ordered) {
|
|
1678
1823
|
const type = metaStr(s.seg.metadata, "type");
|
|
1679
1824
|
const sec = s.seg.section;
|
|
1680
|
-
if (hasOwningApiReference(s, scopeSegs)) {
|
|
1825
|
+
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1681
1826
|
continue;
|
|
1682
1827
|
}
|
|
1828
|
+
if (type === "apiPackage") {
|
|
1829
|
+
const hasApiRefSibling = ordered.some(
|
|
1830
|
+
(sib) => sib.seg.section === sec && metaStr(sib.seg.metadata, "type") === "apiReference"
|
|
1831
|
+
);
|
|
1832
|
+
if (hasApiRefSibling) {
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1683
1836
|
if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
|
|
1684
1837
|
continue;
|
|
1685
1838
|
}
|
|
@@ -1692,15 +1845,18 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1692
1845
|
}
|
|
1693
1846
|
continue;
|
|
1694
1847
|
}
|
|
1695
|
-
if (type === "section" && sec === "") {
|
|
1696
|
-
const
|
|
1848
|
+
if (type === "section" && sec === "" && hasRootSection) {
|
|
1849
|
+
const bounds = siblingBoundaries.get(s);
|
|
1850
|
+
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1851
|
+
const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
|
|
1697
1852
|
const node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1698
1853
|
annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
|
|
1699
1854
|
continue;
|
|
1700
1855
|
}
|
|
1856
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1701
1857
|
const parent = parentSectionPath(sec);
|
|
1702
|
-
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1703
|
-
if (isRootLevel && hasRootSection && sec !== "") {
|
|
1858
|
+
const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1859
|
+
if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
|
|
1704
1860
|
continue;
|
|
1705
1861
|
}
|
|
1706
1862
|
if (isRootLevel) {
|
|
@@ -1712,12 +1868,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1712
1868
|
} else {
|
|
1713
1869
|
const bounds = siblingBoundaries.get(s);
|
|
1714
1870
|
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix),
|
|
1719
|
-
scopePrefix
|
|
1720
|
-
);
|
|
1871
|
+
const isUnboundedSkipSlugSibling = sec === "" && metaNum(s.seg.metadata, "childIndex") != null && bounds == null;
|
|
1872
|
+
const sectionChildren = isUnboundedSkipSlugSibling ? [] : buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix);
|
|
1873
|
+
node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1721
1874
|
}
|
|
1722
1875
|
const isSharedSection = siblingBoundaries.size > 0 && scopePrefix !== "" && sec !== "" && !sec.startsWith(scopePrefix);
|
|
1723
1876
|
annotated.push({
|
|
@@ -1755,10 +1908,6 @@ function groupSidebarRootChildren(ctx, children) {
|
|
|
1755
1908
|
} else if (child.type === "section" && !child.collapsible) {
|
|
1756
1909
|
flushRun();
|
|
1757
1910
|
out.push(child);
|
|
1758
|
-
} else if (child.type === "changelog") {
|
|
1759
|
-
flushRun();
|
|
1760
|
-
run.push(child);
|
|
1761
|
-
flushRun();
|
|
1762
1911
|
} else {
|
|
1763
1912
|
run.push(child);
|
|
1764
1913
|
}
|
|
@@ -1873,7 +2022,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
|
|
|
1873
2022
|
const variantIndividualSlug = detailSlug(variant);
|
|
1874
2023
|
const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
|
|
1875
2024
|
const metaPointsTo = metaStr(variant.metadata, "pointsTo");
|
|
1876
|
-
const children = buildSidebarRootChildren(ctx, variantSegs,
|
|
2025
|
+
const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
|
|
1877
2026
|
return {
|
|
1878
2027
|
type: "variant",
|
|
1879
2028
|
...withMetadataDefaults({
|
|
@@ -2275,6 +2424,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2275
2424
|
};
|
|
2276
2425
|
return node;
|
|
2277
2426
|
});
|
|
2427
|
+
markCrossProductCanonicalSlugs(children);
|
|
2278
2428
|
return {
|
|
2279
2429
|
type: "productgroup",
|
|
2280
2430
|
id: ctx.nodeId("productgroup"),
|
|
@@ -2286,6 +2436,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2286
2436
|
children
|
|
2287
2437
|
};
|
|
2288
2438
|
}
|
|
2439
|
+
function markCrossProductCanonicalSlugs(productNodes) {
|
|
2440
|
+
const pageIdToCanonical = /* @__PURE__ */ new Map();
|
|
2441
|
+
const sorted = [...productNodes].sort((a, b) => {
|
|
2442
|
+
if (a.default !== b.default) {
|
|
2443
|
+
return a.default ? -1 : 1;
|
|
2444
|
+
}
|
|
2445
|
+
return 0;
|
|
2446
|
+
});
|
|
2447
|
+
for (const product of sorted) {
|
|
2448
|
+
traverseDF(product, (child) => {
|
|
2449
|
+
if (hasMetadata(child) && isPage(child)) {
|
|
2450
|
+
const pid = getPageId(child);
|
|
2451
|
+
if (pid == null) {
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
const key = `pid:${pid}`;
|
|
2455
|
+
const canonical = pageIdToCanonical.get(key);
|
|
2456
|
+
if (canonical != null && !product.default) {
|
|
2457
|
+
child.canonicalSlug = canonical;
|
|
2458
|
+
} else if (canonical == null) {
|
|
2459
|
+
pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2289
2465
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2290
2466
|
0 && (module.exports = {
|
|
2291
2467
|
apiLeafNodeFromNavRoute,
|