@fern-api/fern-api-dev 5.44.2 → 5.44.4
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/cli.cjs +617 -112
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -576868,6 +576868,14 @@ function inferCommonPropertiesFromVariants({ variants, discriminant: discriminan
|
|
|
576868
576868
|
if (firstVariantProps == null) {
|
|
576869
576869
|
return [];
|
|
576870
576870
|
}
|
|
576871
|
+
const inheritedFromSharedParent = getPropertyNamesInheritedFromSharedAllOfRefParents({
|
|
576872
|
+
variants,
|
|
576873
|
+
context: context3,
|
|
576874
|
+
breadcrumbs,
|
|
576875
|
+
source: source2,
|
|
576876
|
+
namespace
|
|
576877
|
+
});
|
|
576878
|
+
const variantRequiredSets = variants.map((variant) => getAllRequiredPropertyNames({ schema: variant, context: context3, visited: /* @__PURE__ */ new Set() }));
|
|
576871
576879
|
const result = [];
|
|
576872
576880
|
for (const [propertyName, firstSchema] of Object.entries(firstVariantProps)) {
|
|
576873
576881
|
if (propertyName === discriminant22) {
|
|
@@ -576876,6 +576884,9 @@ function inferCommonPropertiesFromVariants({ variants, discriminant: discriminan
|
|
|
576876
576884
|
if (existingPropertyNames.has(propertyName)) {
|
|
576877
576885
|
continue;
|
|
576878
576886
|
}
|
|
576887
|
+
if (inheritedFromSharedParent.has(propertyName)) {
|
|
576888
|
+
continue;
|
|
576889
|
+
}
|
|
576879
576890
|
let presentInAll = true;
|
|
576880
576891
|
for (let i9 = 1; i9 < variantPropertyMaps.length; i9++) {
|
|
576881
576892
|
const map16 = variantPropertyMaps[i9];
|
|
@@ -576885,8 +576896,106 @@ function inferCommonPropertiesFromVariants({ variants, discriminant: discriminan
|
|
|
576885
576896
|
break;
|
|
576886
576897
|
}
|
|
576887
576898
|
}
|
|
576888
|
-
if (presentInAll) {
|
|
576889
|
-
|
|
576899
|
+
if (!presentInAll) {
|
|
576900
|
+
continue;
|
|
576901
|
+
}
|
|
576902
|
+
const requiredInEveryVariant = variantRequiredSets.every((set27) => set27.has(propertyName));
|
|
576903
|
+
const schemaToLift = requiredInEveryVariant || firstSchema.type === "optional" || firstSchema.type === "nullable" ? firstSchema : SchemaWithExample.optional({
|
|
576904
|
+
nameOverride: void 0,
|
|
576905
|
+
generatedName: "",
|
|
576906
|
+
title: void 0,
|
|
576907
|
+
value: firstSchema,
|
|
576908
|
+
description: void 0,
|
|
576909
|
+
availability: void 0,
|
|
576910
|
+
namespace: void 0,
|
|
576911
|
+
groupName: void 0,
|
|
576912
|
+
inline: void 0
|
|
576913
|
+
});
|
|
576914
|
+
result.push({ key: propertyName, schema: schemaToLift });
|
|
576915
|
+
}
|
|
576916
|
+
return result;
|
|
576917
|
+
}
|
|
576918
|
+
function getAllRequiredPropertyNames({ schema: schema2, context: context3, visited }) {
|
|
576919
|
+
const result = /* @__PURE__ */ new Set();
|
|
576920
|
+
let resolved;
|
|
576921
|
+
if (isReferenceObject(schema2)) {
|
|
576922
|
+
if (visited.has(schema2.$ref)) {
|
|
576923
|
+
return result;
|
|
576924
|
+
}
|
|
576925
|
+
visited.add(schema2.$ref);
|
|
576926
|
+
resolved = context3.resolveSchemaReference(schema2);
|
|
576927
|
+
} else {
|
|
576928
|
+
resolved = schema2;
|
|
576929
|
+
}
|
|
576930
|
+
for (const name2 of resolved.required ?? []) {
|
|
576931
|
+
result.add(name2);
|
|
576932
|
+
}
|
|
576933
|
+
for (const allOfElement of resolved.allOf ?? []) {
|
|
576934
|
+
const childRequired = getAllRequiredPropertyNames({ schema: allOfElement, context: context3, visited });
|
|
576935
|
+
for (const name2 of childRequired) {
|
|
576936
|
+
result.add(name2);
|
|
576937
|
+
}
|
|
576938
|
+
}
|
|
576939
|
+
return result;
|
|
576940
|
+
}
|
|
576941
|
+
function getPropertyNamesInheritedFromSharedAllOfRefParents({ variants, context: context3, breadcrumbs, source: source2, namespace }) {
|
|
576942
|
+
if (variants.length === 0) {
|
|
576943
|
+
return /* @__PURE__ */ new Set();
|
|
576944
|
+
}
|
|
576945
|
+
const refsPerVariant = variants.map((variant) => collectTransitiveAllOfRefs({ schema: variant, context: context3, visited: /* @__PURE__ */ new Set() }));
|
|
576946
|
+
const firstSet = refsPerVariant[0];
|
|
576947
|
+
if (firstSet == null || firstSet.size === 0) {
|
|
576948
|
+
return /* @__PURE__ */ new Set();
|
|
576949
|
+
}
|
|
576950
|
+
const inherited = /* @__PURE__ */ new Set();
|
|
576951
|
+
for (const [refKey, refObject] of firstSet) {
|
|
576952
|
+
const sharedAcrossAllVariants = refsPerVariant.every((s9) => s9.has(refKey));
|
|
576953
|
+
if (!sharedAcrossAllVariants) {
|
|
576954
|
+
continue;
|
|
576955
|
+
}
|
|
576956
|
+
const parentProperties = getAllProperties({
|
|
576957
|
+
schema: refObject,
|
|
576958
|
+
context: context3,
|
|
576959
|
+
breadcrumbs,
|
|
576960
|
+
source: source2,
|
|
576961
|
+
namespace
|
|
576962
|
+
});
|
|
576963
|
+
for (const propertyName of Object.keys(parentProperties)) {
|
|
576964
|
+
inherited.add(propertyName);
|
|
576965
|
+
}
|
|
576966
|
+
}
|
|
576967
|
+
return inherited;
|
|
576968
|
+
}
|
|
576969
|
+
function collectTransitiveAllOfRefs({ schema: schema2, context: context3, visited }) {
|
|
576970
|
+
const result = /* @__PURE__ */ new Map();
|
|
576971
|
+
let resolved;
|
|
576972
|
+
if (isReferenceObject(schema2)) {
|
|
576973
|
+
if (visited.has(schema2.$ref)) {
|
|
576974
|
+
return result;
|
|
576975
|
+
}
|
|
576976
|
+
visited.add(schema2.$ref);
|
|
576977
|
+
resolved = context3.resolveSchemaReference(schema2);
|
|
576978
|
+
} else {
|
|
576979
|
+
resolved = schema2;
|
|
576980
|
+
}
|
|
576981
|
+
for (const allOfElement of resolved.allOf ?? []) {
|
|
576982
|
+
if (isReferenceObject(allOfElement)) {
|
|
576983
|
+
if (!result.has(allOfElement.$ref)) {
|
|
576984
|
+
result.set(allOfElement.$ref, allOfElement);
|
|
576985
|
+
}
|
|
576986
|
+
const nested = collectTransitiveAllOfRefs({ schema: allOfElement, context: context3, visited });
|
|
576987
|
+
for (const [k5, v9] of nested) {
|
|
576988
|
+
if (!result.has(k5)) {
|
|
576989
|
+
result.set(k5, v9);
|
|
576990
|
+
}
|
|
576991
|
+
}
|
|
576992
|
+
} else {
|
|
576993
|
+
const nested = collectTransitiveAllOfRefs({ schema: allOfElement, context: context3, visited });
|
|
576994
|
+
for (const [k5, v9] of nested) {
|
|
576995
|
+
if (!result.has(k5)) {
|
|
576996
|
+
result.set(k5, v9);
|
|
576997
|
+
}
|
|
576998
|
+
}
|
|
576890
576999
|
}
|
|
576891
577000
|
}
|
|
576892
577001
|
return result;
|
|
@@ -649734,8 +649843,8 @@ var OR_KEYS = ["deprecated", "readOnly", "writeOnly", "uniqueItems", "nullable"]
|
|
|
649734
649843
|
var MAX_OF_MINS_KEYS = ["minimum", "exclusiveMinimum", "minLength", "minItems", "minProperties"];
|
|
649735
649844
|
var MIN_OF_MAXS_KEYS = ["maximum", "exclusiveMaximum", "maxLength", "maxItems", "maxProperties"];
|
|
649736
649845
|
var SKIP_FROM_CHILDREN = ["allOf", "oneOf", "anyOf"];
|
|
649737
|
-
function mergeAllOfSchemas(outerSchema, elements) {
|
|
649738
|
-
const flatElements = flattenNestedAllOf(elements);
|
|
649846
|
+
function mergeAllOfSchemas(outerSchema, elements, resolveRef4) {
|
|
649847
|
+
const flatElements = flattenNestedAllOf(elements, resolveRef4);
|
|
649739
649848
|
let result = {};
|
|
649740
649849
|
for (const element4 of flatElements) {
|
|
649741
649850
|
result = mergeSchemaElement(result, element4);
|
|
@@ -649743,13 +649852,32 @@ function mergeAllOfSchemas(outerSchema, elements) {
|
|
|
649743
649852
|
applyOuterSchema(result, outerSchema);
|
|
649744
649853
|
return result;
|
|
649745
649854
|
}
|
|
649746
|
-
function flattenNestedAllOf(elements) {
|
|
649855
|
+
function flattenNestedAllOf(elements, resolveRef4, visitedRefs) {
|
|
649856
|
+
const visited = visitedRefs ?? /* @__PURE__ */ new Set();
|
|
649747
649857
|
const flat = [];
|
|
649748
649858
|
for (const element4 of elements) {
|
|
649749
649859
|
if (Array.isArray(element4.allOf) && element4.allOf.length > 0) {
|
|
649750
649860
|
const { allOf, ...sibling2 } = element4;
|
|
649751
|
-
const schemaChildren =
|
|
649752
|
-
|
|
649861
|
+
const schemaChildren = [];
|
|
649862
|
+
for (const child of allOf) {
|
|
649863
|
+
if ("$ref" in child) {
|
|
649864
|
+
if (resolveRef4 == null) {
|
|
649865
|
+
continue;
|
|
649866
|
+
}
|
|
649867
|
+
const refPath = child.$ref;
|
|
649868
|
+
if (visited.has(refPath)) {
|
|
649869
|
+
continue;
|
|
649870
|
+
}
|
|
649871
|
+
visited.add(refPath);
|
|
649872
|
+
const resolved = resolveRef4(child);
|
|
649873
|
+
if (resolved != null) {
|
|
649874
|
+
schemaChildren.push(resolved);
|
|
649875
|
+
}
|
|
649876
|
+
} else {
|
|
649877
|
+
schemaChildren.push(child);
|
|
649878
|
+
}
|
|
649879
|
+
}
|
|
649880
|
+
flat.push(...flattenNestedAllOf(schemaChildren, resolveRef4, visited));
|
|
649753
649881
|
if (Object.keys(sibling2).length > 0) {
|
|
649754
649882
|
flat.push(sibling2);
|
|
649755
649883
|
}
|
|
@@ -651147,7 +651275,16 @@ var SchemaConverter = class _SchemaConverter extends AbstractConverter {
|
|
|
651147
651275
|
if (hasCycle) {
|
|
651148
651276
|
return void 0;
|
|
651149
651277
|
}
|
|
651150
|
-
const mergedSchema = mergeAllOfSchemas(this.schema, resolvedElements)
|
|
651278
|
+
const mergedSchema = mergeAllOfSchemas(this.schema, resolvedElements, (ref2) => {
|
|
651279
|
+
const resolved = this.context.resolveMaybeReference({
|
|
651280
|
+
schemaOrReference: ref2,
|
|
651281
|
+
breadcrumbs: this.breadcrumbs
|
|
651282
|
+
});
|
|
651283
|
+
if (resolved != null && this.context.isReferenceObject(resolved)) {
|
|
651284
|
+
return void 0;
|
|
651285
|
+
}
|
|
651286
|
+
return resolved;
|
|
651287
|
+
});
|
|
651151
651288
|
const allResolvedRefs = /* @__PURE__ */ new Set([...this.visitedRefs, ...localResolvedRefs]);
|
|
651152
651289
|
const mergedConverter = new _SchemaConverter({
|
|
651153
651290
|
context: this.context,
|
|
@@ -669396,7 +669533,7 @@ var AccessTokenPosthogManager = class {
|
|
|
669396
669533
|
properties: {
|
|
669397
669534
|
...event,
|
|
669398
669535
|
...event.properties,
|
|
669399
|
-
version: "5.44.
|
|
669536
|
+
version: "5.44.4",
|
|
669400
669537
|
usingAccessToken: true,
|
|
669401
669538
|
...getRunIdProperties()
|
|
669402
669539
|
}
|
|
@@ -669460,7 +669597,7 @@ var UserPosthogManager = class {
|
|
|
669460
669597
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
669461
669598
|
event: "CLI",
|
|
669462
669599
|
properties: {
|
|
669463
|
-
version: "5.44.
|
|
669600
|
+
version: "5.44.4",
|
|
669464
669601
|
...event,
|
|
669465
669602
|
...event.properties,
|
|
669466
669603
|
usingAccessToken: false,
|
|
@@ -817663,6 +817800,106 @@ init_lib4();
|
|
|
817663
817800
|
// ../docs-resolver/lib/index.js
|
|
817664
817801
|
init_lib41();
|
|
817665
817802
|
|
|
817803
|
+
// ../docs-resolver/lib/applyTranslatedApiTitlesToNavTree.js
|
|
817804
|
+
init_lib4();
|
|
817805
|
+
init_js();
|
|
817806
|
+
function applyTranslatedApiTitlesToNavTree(root6, baseApis, translatedApis) {
|
|
817807
|
+
const mapsByApiId = /* @__PURE__ */ new Map();
|
|
817808
|
+
for (const [apiId, translatedApi] of Object.entries(translatedApis)) {
|
|
817809
|
+
const holder = navigation_exports.ApiDefinitionHolder.create(translatedApi);
|
|
817810
|
+
const endpoints = /* @__PURE__ */ new Map();
|
|
817811
|
+
for (const [id2, endpoint3] of holder.endpoints) {
|
|
817812
|
+
if (endpoint3.name != null && endpoint3.name.length > 0) {
|
|
817813
|
+
endpoints.set(id2, endpoint3.name);
|
|
817814
|
+
}
|
|
817815
|
+
}
|
|
817816
|
+
const webhooks2 = /* @__PURE__ */ new Map();
|
|
817817
|
+
for (const [id2, webhook] of holder.webhooks) {
|
|
817818
|
+
if (webhook.name != null && webhook.name.length > 0) {
|
|
817819
|
+
webhooks2.set(id2, webhook.name);
|
|
817820
|
+
}
|
|
817821
|
+
}
|
|
817822
|
+
const webSockets = /* @__PURE__ */ new Map();
|
|
817823
|
+
for (const [id2, webSocket] of holder.webSockets) {
|
|
817824
|
+
if (webSocket.name != null && webSocket.name.length > 0) {
|
|
817825
|
+
webSockets.set(id2, webSocket.name);
|
|
817826
|
+
}
|
|
817827
|
+
}
|
|
817828
|
+
const graphql4 = /* @__PURE__ */ new Map();
|
|
817829
|
+
for (const [id2, operation] of holder.graphqlOperations) {
|
|
817830
|
+
const name2 = operation.displayName ?? operation.name;
|
|
817831
|
+
if (name2 != null && name2.length > 0) {
|
|
817832
|
+
graphql4.set(id2, name2);
|
|
817833
|
+
}
|
|
817834
|
+
}
|
|
817835
|
+
const packagesByBaseTitle = /* @__PURE__ */ new Map();
|
|
817836
|
+
const baseApi = baseApis[apiId];
|
|
817837
|
+
if (baseApi != null) {
|
|
817838
|
+
for (const [subpackageId, translatedSubpackage] of Object.entries(translatedApi.subpackages)) {
|
|
817839
|
+
const baseSubpackage = baseApi.subpackages[subpackageId];
|
|
817840
|
+
if (baseSubpackage == null) {
|
|
817841
|
+
continue;
|
|
817842
|
+
}
|
|
817843
|
+
const baseTitle = baseSubpackage.displayName ?? titleCase(baseSubpackage.name);
|
|
817844
|
+
const translatedTitle = translatedSubpackage.displayName ?? titleCase(translatedSubpackage.name);
|
|
817845
|
+
if (baseTitle !== translatedTitle) {
|
|
817846
|
+
packagesByBaseTitle.set(baseTitle, translatedTitle);
|
|
817847
|
+
}
|
|
817848
|
+
}
|
|
817849
|
+
}
|
|
817850
|
+
mapsByApiId.set(apiId, { endpoints, webhooks: webhooks2, webSockets, graphql: graphql4, packagesByBaseTitle });
|
|
817851
|
+
}
|
|
817852
|
+
const clone5 = structuredClone(root6);
|
|
817853
|
+
const visit5 = (node4) => {
|
|
817854
|
+
if (node4 == null || typeof node4 !== "object") {
|
|
817855
|
+
return;
|
|
817856
|
+
}
|
|
817857
|
+
if (Array.isArray(node4)) {
|
|
817858
|
+
for (const item of node4) {
|
|
817859
|
+
visit5(item);
|
|
817860
|
+
}
|
|
817861
|
+
return;
|
|
817862
|
+
}
|
|
817863
|
+
const obj = node4;
|
|
817864
|
+
const apiDefinitionId = typeof obj.apiDefinitionId === "string" ? obj.apiDefinitionId : void 0;
|
|
817865
|
+
const maps = apiDefinitionId != null ? mapsByApiId.get(apiDefinitionId) : void 0;
|
|
817866
|
+
if (maps != null) {
|
|
817867
|
+
const type8 = obj.type;
|
|
817868
|
+
if (type8 === "endpoint" && typeof obj.endpointId === "string") {
|
|
817869
|
+
const translated = maps.endpoints.get(obj.endpointId);
|
|
817870
|
+
if (translated != null) {
|
|
817871
|
+
obj.title = translated;
|
|
817872
|
+
}
|
|
817873
|
+
} else if (type8 === "webhook" && typeof obj.webhookId === "string") {
|
|
817874
|
+
const translated = maps.webhooks.get(obj.webhookId);
|
|
817875
|
+
if (translated != null) {
|
|
817876
|
+
obj.title = translated;
|
|
817877
|
+
}
|
|
817878
|
+
} else if (type8 === "webSocket" && typeof obj.webSocketId === "string") {
|
|
817879
|
+
const translated = maps.webSockets.get(obj.webSocketId);
|
|
817880
|
+
if (translated != null) {
|
|
817881
|
+
obj.title = translated;
|
|
817882
|
+
}
|
|
817883
|
+
} else if (type8 === "graphql" && typeof obj.graphqlOperationId === "string") {
|
|
817884
|
+
const translated = maps.graphql.get(obj.graphqlOperationId);
|
|
817885
|
+
if (translated != null) {
|
|
817886
|
+
obj.title = translated;
|
|
817887
|
+
}
|
|
817888
|
+
} else if (type8 === "apiPackage" && typeof obj.title === "string") {
|
|
817889
|
+
const translated = maps.packagesByBaseTitle.get(obj.title);
|
|
817890
|
+
if (translated != null) {
|
|
817891
|
+
obj.title = translated;
|
|
817892
|
+
}
|
|
817893
|
+
}
|
|
817894
|
+
}
|
|
817895
|
+
for (const value2 of Object.values(obj)) {
|
|
817896
|
+
visit5(value2);
|
|
817897
|
+
}
|
|
817898
|
+
};
|
|
817899
|
+
visit5(clone5);
|
|
817900
|
+
return clone5;
|
|
817901
|
+
}
|
|
817902
|
+
|
|
817666
817903
|
// ../docs-resolver/lib/applyTranslatedFrontmatterToNavTree.js
|
|
817667
817904
|
var import_gray_matter5 = __toESM(require_gray_matter(), 1);
|
|
817668
817905
|
function parseFrontmatterOverrides(markdown) {
|
|
@@ -826203,7 +826440,8 @@ var DocsDefinitionResolver = class {
|
|
|
826203
826440
|
uploadFiles;
|
|
826204
826441
|
registerApi;
|
|
826205
826442
|
targetAudiences;
|
|
826206
|
-
|
|
826443
|
+
buildTranslatedApiDefinitions;
|
|
826444
|
+
constructor({ domain: domain3, docsWorkspace, ossWorkspaces, apiWorkspaces, taskContext, editThisPage, uploadFiles: uploadFiles2 = defaultUploadFiles, registerApi: registerApi2 = defaultRegisterApi, targetAudiences, buildTranslatedApiDefinitions = false }) {
|
|
826207
826445
|
this.domain = domain3;
|
|
826208
826446
|
this.docsWorkspace = docsWorkspace;
|
|
826209
826447
|
this.ossWorkspaces = ossWorkspaces;
|
|
@@ -826213,6 +826451,7 @@ var DocsDefinitionResolver = class {
|
|
|
826213
826451
|
this.uploadFiles = uploadFiles2;
|
|
826214
826452
|
this.registerApi = registerApi2;
|
|
826215
826453
|
this.targetAudiences = targetAudiences;
|
|
826454
|
+
this.buildTranslatedApiDefinitions = buildTranslatedApiDefinitions;
|
|
826216
826455
|
}
|
|
826217
826456
|
#idgen = NodeIdGenerator2.init();
|
|
826218
826457
|
/**
|
|
@@ -826322,6 +826561,13 @@ var DocsDefinitionResolver = class {
|
|
|
826322
826561
|
getDocsWorkspacePath() {
|
|
826323
826562
|
return this.docsWorkspace.absoluteFilePath;
|
|
826324
826563
|
}
|
|
826564
|
+
/**
|
|
826565
|
+
* Returns per-locale translated API definitions, keyed by locale then by the base
|
|
826566
|
+
* `apiDefinitionId`. Must be called after `resolve()`.
|
|
826567
|
+
*/
|
|
826568
|
+
getTranslatedApiSpecs() {
|
|
826569
|
+
return this.translatedApiSpecs;
|
|
826570
|
+
}
|
|
826325
826571
|
getDocsTranslationsConfig() {
|
|
826326
826572
|
const translations = this.parsedDocsConfig.translations;
|
|
826327
826573
|
if (translations == null || translations.length === 0) {
|
|
@@ -826347,6 +826593,12 @@ var DocsDefinitionResolver = class {
|
|
|
826347
826593
|
referencedMarkdownFiles = [];
|
|
826348
826594
|
pendingApiRegistrations = [];
|
|
826349
826595
|
pendingApiCounter = 0;
|
|
826596
|
+
/**
|
|
826597
|
+
* Per-locale translated API definitions, keyed by locale then by the base
|
|
826598
|
+
* `apiDefinitionId`. Populated during {@link resolve} when an API section has
|
|
826599
|
+
* a translated OpenAPI spec under `translations/<locale>/apis/<apiName>/`.
|
|
826600
|
+
*/
|
|
826601
|
+
translatedApiSpecs = /* @__PURE__ */ new Map();
|
|
826350
826602
|
async resolve() {
|
|
826351
826603
|
const resolveStartTime = performance.now();
|
|
826352
826604
|
const startMemory = process.memoryUsage();
|
|
@@ -826501,6 +826753,25 @@ var DocsDefinitionResolver = class {
|
|
|
826501
826753
|
graphqlTypes: pending.graphqlTypes
|
|
826502
826754
|
});
|
|
826503
826755
|
updateApiDefinitionIdInTree(pending.apiReferenceNode, pending.tempApiDefinitionId, realApiDefinitionId);
|
|
826756
|
+
if (pending.translatedIrsByLocale != null) {
|
|
826757
|
+
for (const [locale, translatedIr] of pending.translatedIrsByLocale) {
|
|
826758
|
+
this.resolveLinksInIrDocs(translatedIr, markdownFilesToPathName);
|
|
826759
|
+
let localeMap = this.translatedApiSpecs.get(locale);
|
|
826760
|
+
if (localeMap == null) {
|
|
826761
|
+
localeMap = /* @__PURE__ */ new Map();
|
|
826762
|
+
this.translatedApiSpecs.set(locale, localeMap);
|
|
826763
|
+
}
|
|
826764
|
+
localeMap.set(realApiDefinitionId, {
|
|
826765
|
+
ir: translatedIr,
|
|
826766
|
+
snippetsConfig: pending.snippetsConfig,
|
|
826767
|
+
playgroundConfig: pending.playgroundConfig,
|
|
826768
|
+
apiName: pending.apiName,
|
|
826769
|
+
graphqlOperations: pending.graphqlOperations,
|
|
826770
|
+
graphqlTypes: pending.graphqlTypes,
|
|
826771
|
+
workspace: pending.workspace
|
|
826772
|
+
});
|
|
826773
|
+
}
|
|
826774
|
+
}
|
|
826504
826775
|
}
|
|
826505
826776
|
const deferredTime = performance.now() - deferredStart;
|
|
826506
826777
|
this.taskContext.logger.debug(`Processed deferred API registrations in ${deferredTime.toFixed(0)}ms`);
|
|
@@ -826859,6 +827130,112 @@ Learn more about project structure:
|
|
|
826859
827130
|
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions` : "Failed to load API Definition referenced in docs.\nLearn more about project structure:\nhttps://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions";
|
|
826860
827131
|
throw new CliError({ message: errorMessage, code: CliError.Code.ConfigError });
|
|
826861
827132
|
}
|
|
827133
|
+
/**
|
|
827134
|
+
* Builds a translated IR for each configured non-default locale whose
|
|
827135
|
+
* `translations/<locale>/apis/<apiName>/` directory contains a translated copy of
|
|
827136
|
+
* the API's OpenAPI spec. The translated spec must be structurally identical to the
|
|
827137
|
+
* base (same paths, operationIds, schema names) so the derived IR lines up 1:1 and
|
|
827138
|
+
* can be keyed by the same `apiDefinitionId`.
|
|
827139
|
+
*/
|
|
827140
|
+
async buildTranslatedApiIrs(item, baseOssWorkspace) {
|
|
827141
|
+
const translationsConfig = this.getDocsTranslationsConfig();
|
|
827142
|
+
if (translationsConfig?.translations == null || translationsConfig.translations.length === 0) {
|
|
827143
|
+
return void 0;
|
|
827144
|
+
}
|
|
827145
|
+
const { defaultLocale, translations } = translationsConfig;
|
|
827146
|
+
const fernFolder = this.docsWorkspace.absoluteFilePath;
|
|
827147
|
+
const result = /* @__PURE__ */ new Map();
|
|
827148
|
+
for (const locale of translations) {
|
|
827149
|
+
if (locale === defaultLocale) {
|
|
827150
|
+
continue;
|
|
827151
|
+
}
|
|
827152
|
+
const translatedWorkspace = this.createTranslatedOssWorkspace(baseOssWorkspace, locale, fernFolder);
|
|
827153
|
+
if (translatedWorkspace == null) {
|
|
827154
|
+
continue;
|
|
827155
|
+
}
|
|
827156
|
+
try {
|
|
827157
|
+
const translatedIr = await translatedWorkspace.getIntermediateRepresentation({
|
|
827158
|
+
context: this.taskContext,
|
|
827159
|
+
audiences: item.audiences,
|
|
827160
|
+
enableUniqueErrorsPerEndpoint: true,
|
|
827161
|
+
generateV1Examples: false,
|
|
827162
|
+
logWarnings: false
|
|
827163
|
+
});
|
|
827164
|
+
result.set(locale, translatedIr);
|
|
827165
|
+
this.taskContext.logger.debug(`Built translated API definition for locale "${locale}" (api: ${item.apiName ?? baseOssWorkspace.workspaceName ?? "<default>"})`);
|
|
827166
|
+
} catch (error50) {
|
|
827167
|
+
this.taskContext.logger.warn(`Failed to build translated API definition for locale "${locale}": ${extractErrorMessage(error50)}. Falling back to the default-locale API for this locale.`);
|
|
827168
|
+
}
|
|
827169
|
+
}
|
|
827170
|
+
return result.size > 0 ? result : void 0;
|
|
827171
|
+
}
|
|
827172
|
+
/**
|
|
827173
|
+
* Clones an OSS (OpenAPI) workspace, remapping spec file paths from `apis/<...>` to
|
|
827174
|
+
* `translations/<locale>/apis/<...>` wherever a translated file exists. Returns
|
|
827175
|
+
* `undefined` when no primary spec has a translated counterpart. Override/overlay
|
|
827176
|
+
* files fall back to the base copy when untranslated, keeping structural metadata
|
|
827177
|
+
* (x-fern-* extensions, audiences, etc.) consistent with the base definition.
|
|
827178
|
+
*/
|
|
827179
|
+
createTranslatedOssWorkspace(base4, locale, fernFolder) {
|
|
827180
|
+
let hasTranslatedSpec = false;
|
|
827181
|
+
const toTranslatedPath = (absPath, countsAsTranslation) => {
|
|
827182
|
+
const rel2 = relative4(fernFolder, absPath);
|
|
827183
|
+
if (String(rel2).startsWith("..")) {
|
|
827184
|
+
return absPath;
|
|
827185
|
+
}
|
|
827186
|
+
const candidate = join8(fernFolder, RelativeFilePath2.of(`translations/${locale}`), rel2);
|
|
827187
|
+
if ((0, import_fs26.existsSync)(candidate)) {
|
|
827188
|
+
if (countsAsTranslation) {
|
|
827189
|
+
hasTranslatedSpec = true;
|
|
827190
|
+
}
|
|
827191
|
+
return candidate;
|
|
827192
|
+
}
|
|
827193
|
+
return absPath;
|
|
827194
|
+
};
|
|
827195
|
+
const remapOverrides = (overrides) => {
|
|
827196
|
+
if (overrides == null) {
|
|
827197
|
+
return overrides;
|
|
827198
|
+
}
|
|
827199
|
+
if (Array.isArray(overrides)) {
|
|
827200
|
+
return overrides.map((p14) => toTranslatedPath(p14, false));
|
|
827201
|
+
}
|
|
827202
|
+
return toTranslatedPath(overrides, false);
|
|
827203
|
+
};
|
|
827204
|
+
const remapSpec = (spec) => {
|
|
827205
|
+
switch (spec.type) {
|
|
827206
|
+
case "openapi":
|
|
827207
|
+
return {
|
|
827208
|
+
...spec,
|
|
827209
|
+
absoluteFilepath: toTranslatedPath(spec.absoluteFilepath, true),
|
|
827210
|
+
absoluteFilepathToOverrides: remapOverrides(spec.absoluteFilepathToOverrides),
|
|
827211
|
+
absoluteFilepathToOverlays: spec.absoluteFilepathToOverlays != null ? toTranslatedPath(spec.absoluteFilepathToOverlays, false) : void 0
|
|
827212
|
+
};
|
|
827213
|
+
case "openrpc":
|
|
827214
|
+
case "graphql":
|
|
827215
|
+
return {
|
|
827216
|
+
...spec,
|
|
827217
|
+
absoluteFilepath: toTranslatedPath(spec.absoluteFilepath, true),
|
|
827218
|
+
absoluteFilepathToOverrides: remapOverrides(spec.absoluteFilepathToOverrides)
|
|
827219
|
+
};
|
|
827220
|
+
default:
|
|
827221
|
+
return spec;
|
|
827222
|
+
}
|
|
827223
|
+
};
|
|
827224
|
+
const translatedSpecs = base4.specs.map((spec) => remapSpec(spec));
|
|
827225
|
+
const translatedAllSpecs = base4.allSpecs.map((spec) => remapSpec(spec));
|
|
827226
|
+
if (!hasTranslatedSpec) {
|
|
827227
|
+
return void 0;
|
|
827228
|
+
}
|
|
827229
|
+
return new OSSWorkspace({
|
|
827230
|
+
allSpecs: translatedAllSpecs,
|
|
827231
|
+
specs: translatedSpecs,
|
|
827232
|
+
generatorsConfiguration: base4.generatorsConfiguration,
|
|
827233
|
+
workspaceName: base4.workspaceName,
|
|
827234
|
+
cliVersion: base4.cliVersion,
|
|
827235
|
+
absoluteFilePath: base4.absoluteFilePath,
|
|
827236
|
+
changelog: base4.changelog
|
|
827237
|
+
});
|
|
827238
|
+
}
|
|
826862
827239
|
async toRootNode() {
|
|
826863
827240
|
const slug = navigation_exports.V1.SlugGenerator.init(navigation_exports.slugjoin(this.getDocsBasePath()));
|
|
826864
827241
|
const id2 = this.#idgen.get("root");
|
|
@@ -827277,6 +827654,10 @@ https://buildwithfern.com/learn/docs/getting-started/project-structure#api-defin
|
|
|
827277
827654
|
this.parsedDocsConfig.pages[relativePath] = processedContent;
|
|
827278
827655
|
}
|
|
827279
827656
|
const apiReferenceNode = node4.get();
|
|
827657
|
+
let translatedIrsByLocale;
|
|
827658
|
+
if (this.buildTranslatedApiDefinitions && openapiWorkspace != null) {
|
|
827659
|
+
translatedIrsByLocale = await this.buildTranslatedApiIrs(item, openapiWorkspace);
|
|
827660
|
+
}
|
|
827280
827661
|
this.pendingApiRegistrations.push({
|
|
827281
827662
|
ir: ir11,
|
|
827282
827663
|
snippetsConfig,
|
|
@@ -827286,7 +827667,8 @@ https://buildwithfern.com/learn/docs/getting-started/project-structure#api-defin
|
|
|
827286
827667
|
graphqlOperations: graphqlData.operations,
|
|
827287
827668
|
graphqlTypes: graphqlData.types,
|
|
827288
827669
|
tempApiDefinitionId,
|
|
827289
|
-
apiReferenceNode
|
|
827670
|
+
apiReferenceNode,
|
|
827671
|
+
translatedIrsByLocale
|
|
827290
827672
|
});
|
|
827291
827673
|
return apiReferenceNode;
|
|
827292
827674
|
}
|
|
@@ -860901,7 +861283,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
860901
861283
|
var LOGS_FOLDER_NAME = "logs";
|
|
860902
861284
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
860903
861285
|
function getCliSource() {
|
|
860904
|
-
const version7 = "5.44.
|
|
861286
|
+
const version7 = "5.44.4";
|
|
860905
861287
|
return `cli@${version7}`;
|
|
860906
861288
|
}
|
|
860907
861289
|
var DebugLogger = class {
|
|
@@ -863742,7 +864124,8 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
|
|
|
863742
864124
|
translationPages: previousPreviewResult.translationPages,
|
|
863743
864125
|
translationNavigationOverlays: previousPreviewResult.translationNavigationOverlays,
|
|
863744
864126
|
collectedFileIds: previousPreviewResult.collectedFileIds,
|
|
863745
|
-
docsWorkspacePath: previousPreviewResult.docsWorkspacePath
|
|
864127
|
+
docsWorkspacePath: previousPreviewResult.docsWorkspacePath,
|
|
864128
|
+
translatedApiDefinitions: previousPreviewResult.translatedApiDefinitions
|
|
863746
864129
|
};
|
|
863747
864130
|
}
|
|
863748
864131
|
}
|
|
@@ -863771,7 +864154,8 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
|
|
|
863771
864154
|
};
|
|
863772
864155
|
}),
|
|
863773
864156
|
registerApi: async (opts) => apiCollector.addReferencedAPI(opts),
|
|
863774
|
-
targetAudiences: void 0
|
|
864157
|
+
targetAudiences: void 0,
|
|
864158
|
+
buildTranslatedApiDefinitions: true
|
|
863775
864159
|
});
|
|
863776
864160
|
const writeDocsDefinition = await resolver2.resolve();
|
|
863777
864161
|
const dbDocsDefinition = convertDocsDefinitionToDb({
|
|
@@ -863814,14 +864198,54 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
|
|
|
863814
864198
|
const translationPages = resolver2.getTranslationPages();
|
|
863815
864199
|
const translationNavigationOverlays = resolver2.getTranslationNavigationOverlays();
|
|
863816
864200
|
const collectedFileIds = resolver2.getCollectedFileIds();
|
|
864201
|
+
const translatedApiSpecs = resolver2.getTranslatedApiSpecs();
|
|
864202
|
+
let translatedApiDefinitions;
|
|
864203
|
+
if (translatedApiSpecs.size > 0) {
|
|
864204
|
+
translatedApiDefinitions = {};
|
|
864205
|
+
for (const [locale, byApiId] of translatedApiSpecs) {
|
|
864206
|
+
const localeApis = {};
|
|
864207
|
+
for (const [apiDefinitionId, spec] of byApiId) {
|
|
864208
|
+
try {
|
|
864209
|
+
localeApis[apiDefinitionId] = convertTranslatedIrToReadApi(spec, apiDefinitionId, context3);
|
|
864210
|
+
} catch (error50) {
|
|
864211
|
+
context3.logger.warn(`Failed to convert translated API definition "${apiDefinitionId}" for locale "${locale}": ${extractErrorMessage(error50)}. Falling back to the default-locale API.`);
|
|
864212
|
+
}
|
|
864213
|
+
}
|
|
864214
|
+
if (Object.keys(localeApis).length > 0) {
|
|
864215
|
+
translatedApiDefinitions[locale] = localeApis;
|
|
864216
|
+
}
|
|
864217
|
+
}
|
|
864218
|
+
if (Object.keys(translatedApiDefinitions).length === 0) {
|
|
864219
|
+
translatedApiDefinitions = void 0;
|
|
864220
|
+
}
|
|
864221
|
+
}
|
|
863817
864222
|
return {
|
|
863818
864223
|
docsDefinition,
|
|
863819
864224
|
translationPages,
|
|
863820
864225
|
translationNavigationOverlays,
|
|
863821
864226
|
collectedFileIds,
|
|
863822
|
-
docsWorkspacePath: docsWorkspace.absoluteFilePath
|
|
864227
|
+
docsWorkspacePath: docsWorkspace.absoluteFilePath,
|
|
864228
|
+
translatedApiDefinitions
|
|
863823
864229
|
};
|
|
863824
864230
|
}
|
|
864231
|
+
function convertTranslatedIrToReadApi(spec, apiDefinitionId, context3) {
|
|
864232
|
+
const dbApiDefinition = convertAPIDefinitionToDb(convertIrToFdrApi({
|
|
864233
|
+
ir: spec.ir,
|
|
864234
|
+
snippetsConfig: spec.snippetsConfig,
|
|
864235
|
+
playgroundConfig: spec.playgroundConfig,
|
|
864236
|
+
graphqlOperations: spec.graphqlOperations ?? {},
|
|
864237
|
+
graphqlTypes: spec.graphqlTypes ?? {},
|
|
864238
|
+
context: context3,
|
|
864239
|
+
apiNameOverride: spec.apiName
|
|
864240
|
+
}), FdrAPI_exports.ApiDefinitionId(apiDefinitionId), new SDKSnippetHolder({
|
|
864241
|
+
snippetsConfigWithSdkId: {},
|
|
864242
|
+
snippetsBySdkId: {},
|
|
864243
|
+
snippetTemplatesByEndpoint: {},
|
|
864244
|
+
snippetTemplatesByEndpointId: {},
|
|
864245
|
+
snippetsBySdkIdAndEndpointId: {}
|
|
864246
|
+
}));
|
|
864247
|
+
return convertDbAPIDefinitionToRead(dbApiDefinition);
|
|
864248
|
+
}
|
|
863825
864249
|
async function applyGlobalThemeIfNeeded(docsWorkspace, organization, context3) {
|
|
863826
864250
|
const themeName = docsWorkspace.config.globalTheme;
|
|
863827
864251
|
if (themeName == null) {
|
|
@@ -864409,15 +864833,22 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
|
|
|
864409
864833
|
const RELOAD_DEBOUNCE_MS = 1e3;
|
|
864410
864834
|
async function computeTranslatedDefinitions(result) {
|
|
864411
864835
|
const translations = /* @__PURE__ */ new Map();
|
|
864412
|
-
const { docsDefinition, translationPages, translationNavigationOverlays, collectedFileIds, docsWorkspacePath } = result;
|
|
864413
|
-
|
|
864836
|
+
const { docsDefinition, translationPages, translationNavigationOverlays, translatedApiDefinitions, collectedFileIds, docsWorkspacePath } = result;
|
|
864837
|
+
const hasTranslatedPages = translationPages != null && Object.keys(translationPages).length > 0;
|
|
864838
|
+
const hasTranslatedApis = translatedApiDefinitions != null && Object.keys(translatedApiDefinitions).length > 0;
|
|
864839
|
+
if (!hasTranslatedPages && !hasTranslatedApis) {
|
|
864414
864840
|
return translations;
|
|
864415
864841
|
}
|
|
864416
864842
|
const defaultLocale = docsDefinition.config.translations?.defaultLocale;
|
|
864417
|
-
|
|
864843
|
+
const localesToBuild = /* @__PURE__ */ new Set([
|
|
864844
|
+
...Object.keys(translationPages ?? {}),
|
|
864845
|
+
...Object.keys(translatedApiDefinitions ?? {})
|
|
864846
|
+
]);
|
|
864847
|
+
for (const locale of localesToBuild) {
|
|
864418
864848
|
if (locale === defaultLocale) {
|
|
864419
864849
|
continue;
|
|
864420
864850
|
}
|
|
864851
|
+
const localePages = translationPages?.[locale] ?? {};
|
|
864421
864852
|
try {
|
|
864422
864853
|
const resolveLocalePath = async (filepath) => {
|
|
864423
864854
|
const relPath = relative4(docsWorkspacePath, filepath);
|
|
@@ -864496,8 +864927,14 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
|
|
|
864496
864927
|
translatedNavbarLinks = localeNavOverlay.navbarLinks;
|
|
864497
864928
|
}
|
|
864498
864929
|
}
|
|
864930
|
+
const localeApis = translatedApiDefinitions?.[locale];
|
|
864931
|
+
const translatedApis = localeApis != null ? { ...docsDefinition.apis, ...localeApis } : docsDefinition.apis;
|
|
864932
|
+
if (localeApis != null && updatedRoot != null) {
|
|
864933
|
+
updatedRoot = applyTranslatedApiTitlesToNavTree(updatedRoot, docsDefinition.apis, localeApis);
|
|
864934
|
+
}
|
|
864499
864935
|
const translatedDefinition = {
|
|
864500
864936
|
...docsDefinition,
|
|
864937
|
+
apis: translatedApis,
|
|
864501
864938
|
pages: translatedPages,
|
|
864502
864939
|
config: {
|
|
864503
864940
|
...docsDefinition.config,
|
|
@@ -864507,7 +864944,7 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
|
|
|
864507
864944
|
}
|
|
864508
864945
|
};
|
|
864509
864946
|
translations.set(locale, translatedDefinition);
|
|
864510
|
-
context3.logger.debug(`Computed translated definition for locale "${locale}"`);
|
|
864947
|
+
context3.logger.debug(`Computed translated definition for locale "${locale}"` + (localeApis != null ? ` (with ${Object.keys(localeApis).length} translated API(s))` : ""));
|
|
864511
864948
|
} catch (error50) {
|
|
864512
864949
|
context3.logger.warn(`Failed to compute translation for locale "${locale}": ${String(error50)}`);
|
|
864513
864950
|
}
|
|
@@ -890797,6 +891234,114 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain3
|
|
|
890797
891234
|
token: token.value,
|
|
890798
891235
|
taskContext: context3
|
|
890799
891236
|
});
|
|
891237
|
+
const buildTranslatedApiDefinitions = docsWorkspace.config.translations != null && docsWorkspace.config.translations.length > 1;
|
|
891238
|
+
const readApiDefinitionsById = /* @__PURE__ */ new Map();
|
|
891239
|
+
const captureReadApiDefinition = (definition3, apiDefinitionId) => {
|
|
891240
|
+
if (!buildTranslatedApiDefinitions) {
|
|
891241
|
+
return;
|
|
891242
|
+
}
|
|
891243
|
+
try {
|
|
891244
|
+
const dbApiDefinition = convertAPIDefinitionToDb(definition3, FdrAPI_exports.ApiDefinitionId(apiDefinitionId), new SDKSnippetHolder({
|
|
891245
|
+
snippetsConfigWithSdkId: {},
|
|
891246
|
+
snippetsBySdkId: {},
|
|
891247
|
+
snippetTemplatesByEndpoint: {},
|
|
891248
|
+
snippetTemplatesByEndpointId: {},
|
|
891249
|
+
snippetsBySdkIdAndEndpointId: {}
|
|
891250
|
+
}));
|
|
891251
|
+
readApiDefinitionsById.set(apiDefinitionId, convertDbAPIDefinitionToRead(dbApiDefinition));
|
|
891252
|
+
} catch (error50) {
|
|
891253
|
+
context3.logger.debug(`Failed to build read API definition for ${apiDefinitionId} (translated sidebar titles may stay in the default language): ${String(error50)}`);
|
|
891254
|
+
}
|
|
891255
|
+
};
|
|
891256
|
+
const registerApiToFdr = async ({ ir: ir11, snippetsConfig, playgroundConfig, apiName, workspace, graphqlOperations, graphqlTypes }) => {
|
|
891257
|
+
let apiDefinition = convertIrToFdrApi({
|
|
891258
|
+
ir: ir11,
|
|
891259
|
+
snippetsConfig,
|
|
891260
|
+
playgroundConfig,
|
|
891261
|
+
graphqlOperations,
|
|
891262
|
+
graphqlTypes,
|
|
891263
|
+
context: context3,
|
|
891264
|
+
apiNameOverride: apiName
|
|
891265
|
+
});
|
|
891266
|
+
const isSelfHosted = token.value === "dummy";
|
|
891267
|
+
const aiEnhancerConfig = getAIEnhancerConfig(withAiExamples && !isSelfHosted, docsWorkspace.config.aiExamples?.style ?? docsWorkspace.config.experimental?.aiExampleStyleInstructions);
|
|
891268
|
+
if (aiEnhancerConfig) {
|
|
891269
|
+
const sources = workspace?.getSources();
|
|
891270
|
+
const openApiSources = sources?.filter((source2) => source2.type === "openapi").map((source2) => ({
|
|
891271
|
+
absoluteFilePath: source2.absoluteFilePath,
|
|
891272
|
+
absoluteFilePathToOverrides: source2.absoluteFilePathToOverrides
|
|
891273
|
+
}));
|
|
891274
|
+
if (openApiSources == null || openApiSources.length === 0) {
|
|
891275
|
+
context3.logger.debug("Skipping AI example enhancement: no OpenAPI source file paths available");
|
|
891276
|
+
} else {
|
|
891277
|
+
apiDefinition = await enhanceExamplesWithAI(apiDefinition, aiEnhancerConfig, context3, token, organization, openApiSources);
|
|
891278
|
+
}
|
|
891279
|
+
}
|
|
891280
|
+
let dynamicIRsByLanguage;
|
|
891281
|
+
let languagesWithExistingSdkDynamicIr = /* @__PURE__ */ new Set();
|
|
891282
|
+
if (Object.keys(snippetsConfig).length === 0) {
|
|
891283
|
+
context3.logger.debug(`No snippets configuration defined, skipping snippet generation...`);
|
|
891284
|
+
} else if (!disableDynamicSnippets) {
|
|
891285
|
+
const existingSdkDynamicIrs = await checkAndDownloadExistingSdkDynamicIRs({
|
|
891286
|
+
fdr,
|
|
891287
|
+
workspace,
|
|
891288
|
+
organization,
|
|
891289
|
+
context: context3,
|
|
891290
|
+
snippetsConfig
|
|
891291
|
+
});
|
|
891292
|
+
if (existingSdkDynamicIrs && Object.keys(existingSdkDynamicIrs).length > 0) {
|
|
891293
|
+
dynamicIRsByLanguage = existingSdkDynamicIrs;
|
|
891294
|
+
languagesWithExistingSdkDynamicIr = new Set(Object.keys(existingSdkDynamicIrs));
|
|
891295
|
+
context3.logger.debug(`Using existing SDK dynamic IRs for: ${Object.keys(existingSdkDynamicIrs).join(", ")}`);
|
|
891296
|
+
}
|
|
891297
|
+
const generatedDynamicIRs = await generateLanguageSpecificDynamicIRs({
|
|
891298
|
+
workspace,
|
|
891299
|
+
organization,
|
|
891300
|
+
context: context3,
|
|
891301
|
+
snippetsConfig,
|
|
891302
|
+
skipLanguages: languagesWithExistingSdkDynamicIr
|
|
891303
|
+
});
|
|
891304
|
+
if (generatedDynamicIRs) {
|
|
891305
|
+
dynamicIRsByLanguage = {
|
|
891306
|
+
...dynamicIRsByLanguage,
|
|
891307
|
+
...generatedDynamicIRs
|
|
891308
|
+
};
|
|
891309
|
+
}
|
|
891310
|
+
}
|
|
891311
|
+
let response;
|
|
891312
|
+
try {
|
|
891313
|
+
response = await fdr.api.register.registerApiDefinition({
|
|
891314
|
+
orgId: FdrAPI_exports.OrgId(organization),
|
|
891315
|
+
apiId: FdrAPI_exports.ApiId(apiName ?? getOriginalName(ir11.apiName)),
|
|
891316
|
+
definition: apiDefinition,
|
|
891317
|
+
dynamicIRs: dynamicIRsByLanguage
|
|
891318
|
+
});
|
|
891319
|
+
} catch (error50) {
|
|
891320
|
+
const errorDetails = extractErrorDetails(error50);
|
|
891321
|
+
context3.logger.error(`FDR registerApiDefinition failed. Error details:
|
|
891322
|
+
${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
891323
|
+
if (apiName != null) {
|
|
891324
|
+
return context3.failAndThrow(`Failed to publish docs because API definition (${apiName}) could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
|
|
891325
|
+
} else {
|
|
891326
|
+
return context3.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
|
|
891327
|
+
}
|
|
891328
|
+
}
|
|
891329
|
+
context3.logger.debug(`Registered API Definition ${apiName}: ${response.apiDefinitionId}`);
|
|
891330
|
+
if (response.dynamicIRs && dynamicIRsByLanguage) {
|
|
891331
|
+
if (skipUpload) {
|
|
891332
|
+
context3.logger.debug("Skip-upload mode: skipping dynamic IR uploads");
|
|
891333
|
+
} else {
|
|
891334
|
+
await uploadDynamicIRs({
|
|
891335
|
+
dynamicIRs: dynamicIRsByLanguage,
|
|
891336
|
+
dynamicIRUploadUrls: response.dynamicIRs,
|
|
891337
|
+
context: context3,
|
|
891338
|
+
apiId: response.apiDefinitionId
|
|
891339
|
+
});
|
|
891340
|
+
}
|
|
891341
|
+
}
|
|
891342
|
+
captureReadApiDefinition(apiDefinition, response.apiDefinitionId);
|
|
891343
|
+
return response.apiDefinitionId;
|
|
891344
|
+
};
|
|
890800
891345
|
const resolver2 = new DocsDefinitionResolver({
|
|
890801
891346
|
domain: domain3,
|
|
890802
891347
|
docsWorkspace: effectiveWorkspace,
|
|
@@ -890920,94 +891465,8 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain3
|
|
|
890920
891465
|
return convertToFilePathPairs(startDocsRegisterResponse.uploadUrls, docsWorkspace.absoluteFilePath, sanitizedToAbsoluteMap);
|
|
890921
891466
|
}
|
|
890922
891467
|
},
|
|
890923
|
-
registerApi:
|
|
890924
|
-
|
|
890925
|
-
ir: ir11,
|
|
890926
|
-
snippetsConfig,
|
|
890927
|
-
playgroundConfig,
|
|
890928
|
-
graphqlOperations,
|
|
890929
|
-
graphqlTypes,
|
|
890930
|
-
context: context3,
|
|
890931
|
-
apiNameOverride: apiName
|
|
890932
|
-
});
|
|
890933
|
-
const isSelfHosted = token.value === "dummy";
|
|
890934
|
-
const aiEnhancerConfig = getAIEnhancerConfig(withAiExamples && !isSelfHosted, docsWorkspace.config.aiExamples?.style ?? docsWorkspace.config.experimental?.aiExampleStyleInstructions);
|
|
890935
|
-
if (aiEnhancerConfig) {
|
|
890936
|
-
const sources = workspace?.getSources();
|
|
890937
|
-
const openApiSources = sources?.filter((source2) => source2.type === "openapi").map((source2) => ({
|
|
890938
|
-
absoluteFilePath: source2.absoluteFilePath,
|
|
890939
|
-
absoluteFilePathToOverrides: source2.absoluteFilePathToOverrides
|
|
890940
|
-
}));
|
|
890941
|
-
if (openApiSources == null || openApiSources.length === 0) {
|
|
890942
|
-
context3.logger.debug("Skipping AI example enhancement: no OpenAPI source file paths available");
|
|
890943
|
-
} else {
|
|
890944
|
-
apiDefinition = await enhanceExamplesWithAI(apiDefinition, aiEnhancerConfig, context3, token, organization, openApiSources);
|
|
890945
|
-
}
|
|
890946
|
-
}
|
|
890947
|
-
let dynamicIRsByLanguage;
|
|
890948
|
-
let languagesWithExistingSdkDynamicIr = /* @__PURE__ */ new Set();
|
|
890949
|
-
if (Object.keys(snippetsConfig).length === 0) {
|
|
890950
|
-
context3.logger.debug(`No snippets configuration defined, skipping snippet generation...`);
|
|
890951
|
-
} else if (!disableDynamicSnippets) {
|
|
890952
|
-
const existingSdkDynamicIrs = await checkAndDownloadExistingSdkDynamicIRs({
|
|
890953
|
-
fdr,
|
|
890954
|
-
workspace,
|
|
890955
|
-
organization,
|
|
890956
|
-
context: context3,
|
|
890957
|
-
snippetsConfig
|
|
890958
|
-
});
|
|
890959
|
-
if (existingSdkDynamicIrs && Object.keys(existingSdkDynamicIrs).length > 0) {
|
|
890960
|
-
dynamicIRsByLanguage = existingSdkDynamicIrs;
|
|
890961
|
-
languagesWithExistingSdkDynamicIr = new Set(Object.keys(existingSdkDynamicIrs));
|
|
890962
|
-
context3.logger.debug(`Using existing SDK dynamic IRs for: ${Object.keys(existingSdkDynamicIrs).join(", ")}`);
|
|
890963
|
-
}
|
|
890964
|
-
const generatedDynamicIRs = await generateLanguageSpecificDynamicIRs({
|
|
890965
|
-
workspace,
|
|
890966
|
-
organization,
|
|
890967
|
-
context: context3,
|
|
890968
|
-
snippetsConfig,
|
|
890969
|
-
skipLanguages: languagesWithExistingSdkDynamicIr
|
|
890970
|
-
});
|
|
890971
|
-
if (generatedDynamicIRs) {
|
|
890972
|
-
dynamicIRsByLanguage = {
|
|
890973
|
-
...dynamicIRsByLanguage,
|
|
890974
|
-
...generatedDynamicIRs
|
|
890975
|
-
};
|
|
890976
|
-
}
|
|
890977
|
-
}
|
|
890978
|
-
let response;
|
|
890979
|
-
try {
|
|
890980
|
-
response = await fdr.api.register.registerApiDefinition({
|
|
890981
|
-
orgId: FdrAPI_exports.OrgId(organization),
|
|
890982
|
-
apiId: FdrAPI_exports.ApiId(apiName ?? getOriginalName(ir11.apiName)),
|
|
890983
|
-
definition: apiDefinition,
|
|
890984
|
-
dynamicIRs: dynamicIRsByLanguage
|
|
890985
|
-
});
|
|
890986
|
-
} catch (error50) {
|
|
890987
|
-
const errorDetails = extractErrorDetails(error50);
|
|
890988
|
-
context3.logger.error(`FDR registerApiDefinition failed. Error details:
|
|
890989
|
-
${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
890990
|
-
if (apiName != null) {
|
|
890991
|
-
return context3.failAndThrow(`Failed to publish docs because API definition (${apiName}) could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
|
|
890992
|
-
} else {
|
|
890993
|
-
return context3.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
|
|
890994
|
-
}
|
|
890995
|
-
}
|
|
890996
|
-
context3.logger.debug(`Registered API Definition ${apiName}: ${response.apiDefinitionId}`);
|
|
890997
|
-
if (response.dynamicIRs && dynamicIRsByLanguage) {
|
|
890998
|
-
if (skipUpload) {
|
|
890999
|
-
context3.logger.debug("Skip-upload mode: skipping dynamic IR uploads");
|
|
891000
|
-
} else {
|
|
891001
|
-
await uploadDynamicIRs({
|
|
891002
|
-
dynamicIRs: dynamicIRsByLanguage,
|
|
891003
|
-
dynamicIRUploadUrls: response.dynamicIRs,
|
|
891004
|
-
context: context3,
|
|
891005
|
-
apiId: response.apiDefinitionId
|
|
891006
|
-
});
|
|
891007
|
-
}
|
|
891008
|
-
}
|
|
891009
|
-
return response.apiDefinitionId;
|
|
891010
|
-
},
|
|
891468
|
+
registerApi: registerApiToFdr,
|
|
891469
|
+
buildTranslatedApiDefinitions,
|
|
891011
891470
|
targetAudiences
|
|
891012
891471
|
});
|
|
891013
891472
|
context3.logger.info("Resolving docs definition...");
|
|
@@ -891047,6 +891506,27 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
|
891047
891506
|
}
|
|
891048
891507
|
const publishTime = performance.now() - publishStart;
|
|
891049
891508
|
context3.logger.debug(`Docs published to FDR in ${publishTime.toFixed(0)}ms`);
|
|
891509
|
+
const translatedApiSpecsByLocale = buildTranslatedApiDefinitions ? resolver2.getTranslatedApiSpecs() : /* @__PURE__ */ new Map();
|
|
891510
|
+
const translatedApiIdsByLocale = /* @__PURE__ */ new Map();
|
|
891511
|
+
if (translatedApiSpecsByLocale.size > 0) {
|
|
891512
|
+
context3.logger.info(`Registering translated API definitions for ${translatedApiSpecsByLocale.size} locale(s)...`);
|
|
891513
|
+
for (const [locale, specsByBaseApiId] of translatedApiSpecsByLocale) {
|
|
891514
|
+
const idMap = /* @__PURE__ */ new Map();
|
|
891515
|
+
for (const [baseApiId, spec] of specsByBaseApiId) {
|
|
891516
|
+
try {
|
|
891517
|
+
const translatedApiId = await registerApiToFdr(spec);
|
|
891518
|
+
if (translatedApiId !== baseApiId) {
|
|
891519
|
+
idMap.set(baseApiId, translatedApiId);
|
|
891520
|
+
}
|
|
891521
|
+
} catch (error50) {
|
|
891522
|
+
context3.logger.warn(`Failed to register translated API definition for locale "${locale}" (API reference will render in the default language): ${String(error50)}`);
|
|
891523
|
+
}
|
|
891524
|
+
}
|
|
891525
|
+
if (idMap.size > 0) {
|
|
891526
|
+
translatedApiIdsByLocale.set(locale, idMap);
|
|
891527
|
+
}
|
|
891528
|
+
}
|
|
891529
|
+
}
|
|
891050
891530
|
const translationPages = resolver2.getTranslationPages();
|
|
891051
891531
|
const translationNavigationOverlays = resolver2.getTranslationNavigationOverlays();
|
|
891052
891532
|
const translationDomain = preview ? urlToOutput : domain3;
|
|
@@ -891146,6 +891626,25 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
|
891146
891626
|
translatedNavbarLinks = localeNavOverlay.navbarLinks;
|
|
891147
891627
|
}
|
|
891148
891628
|
}
|
|
891629
|
+
const localeApiIdMap = translatedApiIdsByLocale.get(locale);
|
|
891630
|
+
if (localeApiIdMap != null && localeApiIdMap.size > 0 && updatedRoot != null) {
|
|
891631
|
+
const baseApisForTitles = {};
|
|
891632
|
+
const translatedApisForTitles = {};
|
|
891633
|
+
for (const [baseApiId, translatedApiId] of localeApiIdMap) {
|
|
891634
|
+
const baseRead = readApiDefinitionsById.get(baseApiId);
|
|
891635
|
+
const translatedRead = readApiDefinitionsById.get(translatedApiId);
|
|
891636
|
+
if (baseRead != null) {
|
|
891637
|
+
baseApisForTitles[baseApiId] = baseRead;
|
|
891638
|
+
}
|
|
891639
|
+
if (translatedRead != null) {
|
|
891640
|
+
translatedApisForTitles[baseApiId] = translatedRead;
|
|
891641
|
+
}
|
|
891642
|
+
}
|
|
891643
|
+
updatedRoot = Object.keys(translatedApisForTitles).length > 0 ? applyTranslatedApiTitlesToNavTree(updatedRoot, baseApisForTitles, translatedApisForTitles) : structuredClone(updatedRoot);
|
|
891644
|
+
for (const [baseApiId, translatedApiId] of localeApiIdMap) {
|
|
891645
|
+
updateApiDefinitionIdInTree(updatedRoot, baseApiId, translatedApiId);
|
|
891646
|
+
}
|
|
891647
|
+
}
|
|
891149
891648
|
const translatedDefinition = {
|
|
891150
891649
|
...docsDefinition,
|
|
891151
891650
|
pages: translatedPages,
|
|
@@ -891876,7 +892375,7 @@ var LegacyDocsPublisher = class {
|
|
|
891876
892375
|
previewId,
|
|
891877
892376
|
disableTemplates: void 0,
|
|
891878
892377
|
skipUpload,
|
|
891879
|
-
cliVersion: "5.44.
|
|
892378
|
+
cliVersion: "5.44.4",
|
|
891880
892379
|
loginCommand: "fern auth login"
|
|
891881
892380
|
});
|
|
891882
892381
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
@@ -944174,6 +944673,7 @@ var LocalTaskHandler = class {
|
|
|
944174
944673
|
const pathsToPreserve = await this.getPathsToPreserve(fernIgnorePaths);
|
|
944175
944674
|
await (0, import_promises129.cp)(this.absolutePathToLocalOutput, tmpOutputResolutionDir, { recursive: true });
|
|
944176
944675
|
await this.runThrowawayGitCommand(["init"], tmpOutputResolutionDir);
|
|
944676
|
+
await this.runThrowawayGitCommand(["config", "gc.auto", "0"], tmpOutputResolutionDir);
|
|
944177
944677
|
await this.runThrowawayGitCommand(["add", "."], tmpOutputResolutionDir);
|
|
944178
944678
|
await this.runThrowawayGitCommand([
|
|
944179
944679
|
"-c",
|
|
@@ -944192,7 +944692,12 @@ var LocalTaskHandler = class {
|
|
|
944192
944692
|
await this.runThrowawayGitCommand(["reset", "--", ...pathsToPreserve], tmpOutputResolutionDir);
|
|
944193
944693
|
await this.runThrowawayGitCommand(["clean", "-fd", "--", ...pathsToPreserve], tmpOutputResolutionDir);
|
|
944194
944694
|
await this.runThrowawayGitCommand(["restore", "."], tmpOutputResolutionDir);
|
|
944195
|
-
await (0, import_promises129.rm)(join8(tmpOutputResolutionDir, RelativeFilePath2.of(".git")), {
|
|
944695
|
+
await (0, import_promises129.rm)(join8(tmpOutputResolutionDir, RelativeFilePath2.of(".git")), {
|
|
944696
|
+
recursive: true,
|
|
944697
|
+
force: true,
|
|
944698
|
+
maxRetries: 3,
|
|
944699
|
+
retryDelay: 100
|
|
944700
|
+
});
|
|
944196
944701
|
await (0, import_promises129.rm)(this.absolutePathToLocalOutput, { recursive: true });
|
|
944197
944702
|
await (0, import_promises129.cp)(tmpOutputResolutionDir, this.absolutePathToLocalOutput, { recursive: true });
|
|
944198
944703
|
}
|
|
@@ -956957,7 +957462,7 @@ function getAutomationContextFromEnv() {
|
|
|
956957
957462
|
config_branch: process.env.FERN_CONFIG_BRANCH,
|
|
956958
957463
|
config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
|
|
956959
957464
|
trigger: process.env.GITHUB_EVENT_NAME,
|
|
956960
|
-
cli_version: "5.44.
|
|
957465
|
+
cli_version: "5.44.4"
|
|
956961
957466
|
};
|
|
956962
957467
|
}
|
|
956963
957468
|
function isAutomationMode() {
|
|
@@ -957783,7 +958288,7 @@ var CliContext = class _CliContext {
|
|
|
957783
958288
|
if (false) {
|
|
957784
958289
|
this.logger.error("CLI_VERSION is not defined");
|
|
957785
958290
|
}
|
|
957786
|
-
return "5.44.
|
|
958291
|
+
return "5.44.4";
|
|
957787
958292
|
}
|
|
957788
958293
|
getCliName() {
|
|
957789
958294
|
if (false) {
|
package/package.json
CHANGED