@fern-api/fdr-sdk 0.138.0-5cf655fec → 0.138.0-9712a62f7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1ToV2.d.ts","sourceRoot":"","sources":["../../../src/navigation/migrators/v1ToV2.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;GAIG;AACH,qBAAa,wBAAwB;;IACnC,MAAM,CAAC,MAAM,IAAI,wBAAwB;IAIzC,OAAO;
|
|
1
|
+
{"version":3,"file":"v1ToV2.d.ts","sourceRoot":"","sources":["../../../src/navigation/migrators/v1ToV2.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;GAIG;AACH,qBAAa,wBAAwB;;IACnC,MAAM,CAAC,MAAM,IAAI,wBAAwB;IAIzC,OAAO;IAaA,IAAI,SAAU,cAAc,CAAC,EAAE,CAAC,QAAQ,KAAG,cAAc,CAAC,QAAQ,CA2BvE;IAEK,SAAS,SACR,cAAc,CAAC,EAAE,CAAC,aAAa,WAC5B,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,KAC1C,cAAc,CAAC,aAAa,CAgD7B;IAEK,OAAO,SACN,cAAc,CAAC,EAAE,CAAC,WAAW,WAC1B,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,KAC1C,cAAc,CAAC,WAAW,CA6B3B;IAEK,WAAW,SACV,cAAc,CAAC,EAAE,CAAC,eAAe,WAC9B,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,KAC1C,cAAc,CAAC,eAAe,CAsB/B;IAEK,MAAM,SACL,cAAc,CAAC,EAAE,CAAC,UAAU,WACzB,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,KAC1C,cAAc,CAAC,UAAU,CAa1B;IAEK,GAAG,SACF,cAAc,CAAC,EAAE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or() { }
|
|
14
|
+
// store the base slug
|
|
15
|
+
#baseUrl;
|
|
16
|
+
// this will store the product slug we are currently parsing
|
|
17
|
+
// to be used when setting the canonical URL
|
|
18
|
+
#currentProductSlug;
|
|
19
|
+
// this will store the product slug we are currently parsing
|
|
20
|
+
// to be used when setting the canonical URL
|
|
21
|
+
#currentDefaultVersionSlug;
|
|
14
22
|
root = (node) => {
|
|
23
|
+
this.#baseUrl = FernNavigation.Slug(node.slug);
|
|
15
24
|
const latest = {
|
|
16
25
|
type: "root",
|
|
17
26
|
child: visitDiscriminatedUnion(node.child)._visit({
|
|
@@ -54,6 +63,7 @@ export class FernNavigationV1ToLatest {
|
|
|
54
63
|
if (!defaultVersionV1) {
|
|
55
64
|
throw new Error("default version is undefined");
|
|
56
65
|
}
|
|
66
|
+
this.#currentDefaultVersionSlug = FernNavigation.Slug(defaultVersionV1.slug);
|
|
57
67
|
const defaultVersion = this.version(defaultVersionV1, [...parents, node]);
|
|
58
68
|
/**
|
|
59
69
|
* visit the rest of the children, but splice the default version in its original position
|
|
@@ -221,6 +231,7 @@ export class FernNavigationV1ToLatest {
|
|
|
221
231
|
return latest;
|
|
222
232
|
};
|
|
223
233
|
product = (node, parents) => {
|
|
234
|
+
this.#currentProductSlug = node.slug;
|
|
224
235
|
const latest = {
|
|
225
236
|
type: "product",
|
|
226
237
|
id: FernNavigation.NodeId(node.id),
|
|
@@ -594,25 +605,50 @@ export class FernNavigationV1ToLatest {
|
|
|
594
605
|
}
|
|
595
606
|
}
|
|
596
607
|
#canonicalSlugs = new Map();
|
|
608
|
+
// return a match found with any key
|
|
609
|
+
#getCanonicalSlug = (keyOrKeys) => {
|
|
610
|
+
if (typeof keyOrKeys === "string") {
|
|
611
|
+
return this.#canonicalSlugs.get(keyOrKeys);
|
|
612
|
+
}
|
|
613
|
+
for (const key of keyOrKeys) {
|
|
614
|
+
const existing = this.#canonicalSlugs.get(key);
|
|
615
|
+
// explicitly check for undefined because empty string is valid
|
|
616
|
+
if (existing !== undefined) {
|
|
617
|
+
return existing;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return undefined;
|
|
621
|
+
};
|
|
622
|
+
// set all keys to use the same canonical url
|
|
623
|
+
#setCanonicalSlug = (keyOrKeys, fullCanonical) => {
|
|
624
|
+
const baseSlug = this.#currentProductSlug ?? "" + this.#baseUrl;
|
|
625
|
+
// if the canonical slug includes the default version, prefer an unversioned slug
|
|
626
|
+
const normalizedCanonical = this.#currentDefaultVersionSlug
|
|
627
|
+
? fullCanonical.replace(new RegExp(`(^|/)${this.#currentDefaultVersionSlug}(/|$)`, "g"), `$1${baseSlug}$2`)
|
|
628
|
+
: fullCanonical;
|
|
629
|
+
// canonical slug should always begin without a slash
|
|
630
|
+
const canonicalSlug = FernNavigation.Slug(normalizedCanonical.replace(/^\//, ""));
|
|
631
|
+
if (typeof keyOrKeys === "string") {
|
|
632
|
+
this.#canonicalSlugs.set(keyOrKeys, canonicalSlug);
|
|
633
|
+
return canonicalSlug;
|
|
634
|
+
}
|
|
635
|
+
// canonical slug should apply to all keys of a given page
|
|
636
|
+
for (const key of keyOrKeys) {
|
|
637
|
+
this.#canonicalSlugs.set(key, canonicalSlug);
|
|
638
|
+
}
|
|
639
|
+
return canonicalSlug;
|
|
640
|
+
};
|
|
597
641
|
// TODO: canonical url logic should account for RBAC, since we should always prefer the publicly available url over the private one (for SEO)
|
|
598
642
|
#getAndSetCanonicalSlug = (keyOrKeys, slug) => {
|
|
599
643
|
if (keyOrKeys == null) {
|
|
600
644
|
return undefined;
|
|
601
645
|
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* This will set the canonical slug to each of the keys in the array, and return the first non-null slug
|
|
605
|
-
*/
|
|
606
|
-
return keyOrKeys
|
|
607
|
-
.map((key) => this.#getAndSetCanonicalSlug(key, slug))
|
|
608
|
-
.find((s) => s != null);
|
|
609
|
-
}
|
|
610
|
-
const existing = this.#canonicalSlugs.get(keyOrKeys);
|
|
646
|
+
const existing = this.#getCanonicalSlug(keyOrKeys);
|
|
611
647
|
if (existing != null) {
|
|
612
648
|
return existing;
|
|
613
649
|
}
|
|
614
|
-
this.#
|
|
615
|
-
return
|
|
650
|
+
const canonicalSlug = this.#setCanonicalSlug(keyOrKeys, slug);
|
|
651
|
+
return canonicalSlug;
|
|
616
652
|
};
|
|
617
653
|
#createTitleDisambiguationKey = (node, parents) => {
|
|
618
654
|
const unversionedParents = this.#findUnversionedParents(parents);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/fdr-sdk",
|
|
3
|
-
"version": "0.138.0-
|
|
3
|
+
"version": "0.138.0-9712a62f7",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"test:update": "vitest --run --passWithNoTests --globals -u"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@fern-api/ui-core-utils": "0.138.0-
|
|
52
|
+
"@fern-api/ui-core-utils": "0.138.0-9712a62f7*",
|
|
53
53
|
"@ungap/structured-clone": "^1.2.0",
|
|
54
54
|
"dayjs": "^1.11.11",
|
|
55
55
|
"es-toolkit": "^1.32.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@babel/core": "^7.26.9",
|
|
69
69
|
"@babel/preset-env": "^7.26.0",
|
|
70
70
|
"@babel/preset-typescript": "^7.26.0",
|
|
71
|
-
"@fern-platform/configs": "0.138.0-
|
|
71
|
+
"@fern-platform/configs": "0.138.0-9712a62f7*",
|
|
72
72
|
"@types/node-fetch": "2.6.9",
|
|
73
73
|
"@types/qs": "6.9.14",
|
|
74
74
|
"@types/tinycolor2": "^1.4.6",
|