@fern-api/fern-api-dev 5.44.3 → 5.44.5
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 +615 -115
- 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;
|
|
@@ -589133,7 +589242,7 @@ var GeneratorName = {
|
|
|
589133
589242
|
STOPLIGHT: "fernapi/fern-stoplight",
|
|
589134
589243
|
POSTMAN: "fernapi/fern-postman",
|
|
589135
589244
|
OPENAPI_PYTHON_CLIENT: "fernapi/openapi-python-client",
|
|
589136
|
-
CLI: "fernapi/fern-cli"
|
|
589245
|
+
CLI: "fernapi/fern-cli-generator"
|
|
589137
589246
|
};
|
|
589138
589247
|
|
|
589139
589248
|
// ../configuration-loader/lib/generators-yml/addGenerator.js
|
|
@@ -589471,6 +589580,7 @@ function getGeneratorMetadataFromName(generatorName, context3) {
|
|
|
589471
589580
|
return "swift-model";
|
|
589472
589581
|
// CLI
|
|
589473
589582
|
case "fern-cli":
|
|
589583
|
+
case "fern-cli-generator":
|
|
589474
589584
|
return "cli";
|
|
589475
589585
|
default: {
|
|
589476
589586
|
context3?.logger.warn(`Unrecognized generator name found, attempting to parse manually: ${generatorName}`);
|
|
@@ -649734,8 +649844,8 @@ var OR_KEYS = ["deprecated", "readOnly", "writeOnly", "uniqueItems", "nullable"]
|
|
|
649734
649844
|
var MAX_OF_MINS_KEYS = ["minimum", "exclusiveMinimum", "minLength", "minItems", "minProperties"];
|
|
649735
649845
|
var MIN_OF_MAXS_KEYS = ["maximum", "exclusiveMaximum", "maxLength", "maxItems", "maxProperties"];
|
|
649736
649846
|
var SKIP_FROM_CHILDREN = ["allOf", "oneOf", "anyOf"];
|
|
649737
|
-
function mergeAllOfSchemas(outerSchema, elements) {
|
|
649738
|
-
const flatElements = flattenNestedAllOf(elements);
|
|
649847
|
+
function mergeAllOfSchemas(outerSchema, elements, resolveRef4) {
|
|
649848
|
+
const flatElements = flattenNestedAllOf(elements, resolveRef4);
|
|
649739
649849
|
let result = {};
|
|
649740
649850
|
for (const element4 of flatElements) {
|
|
649741
649851
|
result = mergeSchemaElement(result, element4);
|
|
@@ -649743,13 +649853,32 @@ function mergeAllOfSchemas(outerSchema, elements) {
|
|
|
649743
649853
|
applyOuterSchema(result, outerSchema);
|
|
649744
649854
|
return result;
|
|
649745
649855
|
}
|
|
649746
|
-
function flattenNestedAllOf(elements) {
|
|
649856
|
+
function flattenNestedAllOf(elements, resolveRef4, visitedRefs) {
|
|
649857
|
+
const visited = visitedRefs ?? /* @__PURE__ */ new Set();
|
|
649747
649858
|
const flat = [];
|
|
649748
649859
|
for (const element4 of elements) {
|
|
649749
649860
|
if (Array.isArray(element4.allOf) && element4.allOf.length > 0) {
|
|
649750
649861
|
const { allOf, ...sibling2 } = element4;
|
|
649751
|
-
const schemaChildren =
|
|
649752
|
-
|
|
649862
|
+
const schemaChildren = [];
|
|
649863
|
+
for (const child of allOf) {
|
|
649864
|
+
if ("$ref" in child) {
|
|
649865
|
+
if (resolveRef4 == null) {
|
|
649866
|
+
continue;
|
|
649867
|
+
}
|
|
649868
|
+
const refPath = child.$ref;
|
|
649869
|
+
if (visited.has(refPath)) {
|
|
649870
|
+
continue;
|
|
649871
|
+
}
|
|
649872
|
+
visited.add(refPath);
|
|
649873
|
+
const resolved = resolveRef4(child);
|
|
649874
|
+
if (resolved != null) {
|
|
649875
|
+
schemaChildren.push(resolved);
|
|
649876
|
+
}
|
|
649877
|
+
} else {
|
|
649878
|
+
schemaChildren.push(child);
|
|
649879
|
+
}
|
|
649880
|
+
}
|
|
649881
|
+
flat.push(...flattenNestedAllOf(schemaChildren, resolveRef4, visited));
|
|
649753
649882
|
if (Object.keys(sibling2).length > 0) {
|
|
649754
649883
|
flat.push(sibling2);
|
|
649755
649884
|
}
|
|
@@ -651147,7 +651276,16 @@ var SchemaConverter = class _SchemaConverter extends AbstractConverter {
|
|
|
651147
651276
|
if (hasCycle) {
|
|
651148
651277
|
return void 0;
|
|
651149
651278
|
}
|
|
651150
|
-
const mergedSchema = mergeAllOfSchemas(this.schema, resolvedElements)
|
|
651279
|
+
const mergedSchema = mergeAllOfSchemas(this.schema, resolvedElements, (ref2) => {
|
|
651280
|
+
const resolved = this.context.resolveMaybeReference({
|
|
651281
|
+
schemaOrReference: ref2,
|
|
651282
|
+
breadcrumbs: this.breadcrumbs
|
|
651283
|
+
});
|
|
651284
|
+
if (resolved != null && this.context.isReferenceObject(resolved)) {
|
|
651285
|
+
return void 0;
|
|
651286
|
+
}
|
|
651287
|
+
return resolved;
|
|
651288
|
+
});
|
|
651151
651289
|
const allResolvedRefs = /* @__PURE__ */ new Set([...this.visitedRefs, ...localResolvedRefs]);
|
|
651152
651290
|
const mergedConverter = new _SchemaConverter({
|
|
651153
651291
|
context: this.context,
|
|
@@ -669396,7 +669534,7 @@ var AccessTokenPosthogManager = class {
|
|
|
669396
669534
|
properties: {
|
|
669397
669535
|
...event,
|
|
669398
669536
|
...event.properties,
|
|
669399
|
-
version: "5.44.
|
|
669537
|
+
version: "5.44.5",
|
|
669400
669538
|
usingAccessToken: true,
|
|
669401
669539
|
...getRunIdProperties()
|
|
669402
669540
|
}
|
|
@@ -669460,7 +669598,7 @@ var UserPosthogManager = class {
|
|
|
669460
669598
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
669461
669599
|
event: "CLI",
|
|
669462
669600
|
properties: {
|
|
669463
|
-
version: "5.44.
|
|
669601
|
+
version: "5.44.5",
|
|
669464
669602
|
...event,
|
|
669465
669603
|
...event.properties,
|
|
669466
669604
|
usingAccessToken: false,
|
|
@@ -675020,7 +675158,7 @@ var DOCKER_IMAGE_TO_GENERATOR_ID = {
|
|
|
675020
675158
|
"fernapi/fern-swift-model": "swift-model",
|
|
675021
675159
|
"fernapi/fern-postman": "postman",
|
|
675022
675160
|
"fernapi/fern-openapi": "openapi",
|
|
675023
|
-
"fernapi/fern-cli": "cli"
|
|
675161
|
+
"fernapi/fern-cli-generator": "cli"
|
|
675024
675162
|
};
|
|
675025
675163
|
var DOCKER_IMAGE_TO_CHANGELOG_URL = {
|
|
675026
675164
|
"fernapi/fern-typescript-sdk": "https://buildwithfern.com/learn/sdks/generators/typescript/changelog",
|
|
@@ -676839,7 +676977,7 @@ var MINIMUM_SUPPORTED_IR_VERSION = 53;
|
|
|
676839
676977
|
|
|
676840
676978
|
// ../generation/ir-migrations/lib/generatorVersionMap.js
|
|
676841
676979
|
var GENERATOR_MINIMUM_VERSIONS = {
|
|
676842
|
-
"fernapi/fern-cli": "0.0.1",
|
|
676980
|
+
"fernapi/fern-cli-generator": "0.0.1",
|
|
676843
676981
|
"fernapi/fern-csharp-model": "0.0.2",
|
|
676844
676982
|
"fernapi/fern-csharp-sdk": "0.5.0",
|
|
676845
676983
|
"fernapi/fern-express": "0.17.3",
|
|
@@ -817663,6 +817801,106 @@ init_lib4();
|
|
|
817663
817801
|
// ../docs-resolver/lib/index.js
|
|
817664
817802
|
init_lib41();
|
|
817665
817803
|
|
|
817804
|
+
// ../docs-resolver/lib/applyTranslatedApiTitlesToNavTree.js
|
|
817805
|
+
init_lib4();
|
|
817806
|
+
init_js();
|
|
817807
|
+
function applyTranslatedApiTitlesToNavTree(root6, baseApis, translatedApis) {
|
|
817808
|
+
const mapsByApiId = /* @__PURE__ */ new Map();
|
|
817809
|
+
for (const [apiId, translatedApi] of Object.entries(translatedApis)) {
|
|
817810
|
+
const holder = navigation_exports.ApiDefinitionHolder.create(translatedApi);
|
|
817811
|
+
const endpoints = /* @__PURE__ */ new Map();
|
|
817812
|
+
for (const [id2, endpoint3] of holder.endpoints) {
|
|
817813
|
+
if (endpoint3.name != null && endpoint3.name.length > 0) {
|
|
817814
|
+
endpoints.set(id2, endpoint3.name);
|
|
817815
|
+
}
|
|
817816
|
+
}
|
|
817817
|
+
const webhooks2 = /* @__PURE__ */ new Map();
|
|
817818
|
+
for (const [id2, webhook] of holder.webhooks) {
|
|
817819
|
+
if (webhook.name != null && webhook.name.length > 0) {
|
|
817820
|
+
webhooks2.set(id2, webhook.name);
|
|
817821
|
+
}
|
|
817822
|
+
}
|
|
817823
|
+
const webSockets = /* @__PURE__ */ new Map();
|
|
817824
|
+
for (const [id2, webSocket] of holder.webSockets) {
|
|
817825
|
+
if (webSocket.name != null && webSocket.name.length > 0) {
|
|
817826
|
+
webSockets.set(id2, webSocket.name);
|
|
817827
|
+
}
|
|
817828
|
+
}
|
|
817829
|
+
const graphql4 = /* @__PURE__ */ new Map();
|
|
817830
|
+
for (const [id2, operation] of holder.graphqlOperations) {
|
|
817831
|
+
const name2 = operation.displayName ?? operation.name;
|
|
817832
|
+
if (name2 != null && name2.length > 0) {
|
|
817833
|
+
graphql4.set(id2, name2);
|
|
817834
|
+
}
|
|
817835
|
+
}
|
|
817836
|
+
const packagesByBaseTitle = /* @__PURE__ */ new Map();
|
|
817837
|
+
const baseApi = baseApis[apiId];
|
|
817838
|
+
if (baseApi != null) {
|
|
817839
|
+
for (const [subpackageId, translatedSubpackage] of Object.entries(translatedApi.subpackages)) {
|
|
817840
|
+
const baseSubpackage = baseApi.subpackages[subpackageId];
|
|
817841
|
+
if (baseSubpackage == null) {
|
|
817842
|
+
continue;
|
|
817843
|
+
}
|
|
817844
|
+
const baseTitle = baseSubpackage.displayName ?? titleCase(baseSubpackage.name);
|
|
817845
|
+
const translatedTitle = translatedSubpackage.displayName ?? titleCase(translatedSubpackage.name);
|
|
817846
|
+
if (baseTitle !== translatedTitle) {
|
|
817847
|
+
packagesByBaseTitle.set(baseTitle, translatedTitle);
|
|
817848
|
+
}
|
|
817849
|
+
}
|
|
817850
|
+
}
|
|
817851
|
+
mapsByApiId.set(apiId, { endpoints, webhooks: webhooks2, webSockets, graphql: graphql4, packagesByBaseTitle });
|
|
817852
|
+
}
|
|
817853
|
+
const clone5 = structuredClone(root6);
|
|
817854
|
+
const visit5 = (node4) => {
|
|
817855
|
+
if (node4 == null || typeof node4 !== "object") {
|
|
817856
|
+
return;
|
|
817857
|
+
}
|
|
817858
|
+
if (Array.isArray(node4)) {
|
|
817859
|
+
for (const item of node4) {
|
|
817860
|
+
visit5(item);
|
|
817861
|
+
}
|
|
817862
|
+
return;
|
|
817863
|
+
}
|
|
817864
|
+
const obj = node4;
|
|
817865
|
+
const apiDefinitionId = typeof obj.apiDefinitionId === "string" ? obj.apiDefinitionId : void 0;
|
|
817866
|
+
const maps = apiDefinitionId != null ? mapsByApiId.get(apiDefinitionId) : void 0;
|
|
817867
|
+
if (maps != null) {
|
|
817868
|
+
const type8 = obj.type;
|
|
817869
|
+
if (type8 === "endpoint" && typeof obj.endpointId === "string") {
|
|
817870
|
+
const translated = maps.endpoints.get(obj.endpointId);
|
|
817871
|
+
if (translated != null) {
|
|
817872
|
+
obj.title = translated;
|
|
817873
|
+
}
|
|
817874
|
+
} else if (type8 === "webhook" && typeof obj.webhookId === "string") {
|
|
817875
|
+
const translated = maps.webhooks.get(obj.webhookId);
|
|
817876
|
+
if (translated != null) {
|
|
817877
|
+
obj.title = translated;
|
|
817878
|
+
}
|
|
817879
|
+
} else if (type8 === "webSocket" && typeof obj.webSocketId === "string") {
|
|
817880
|
+
const translated = maps.webSockets.get(obj.webSocketId);
|
|
817881
|
+
if (translated != null) {
|
|
817882
|
+
obj.title = translated;
|
|
817883
|
+
}
|
|
817884
|
+
} else if (type8 === "graphql" && typeof obj.graphqlOperationId === "string") {
|
|
817885
|
+
const translated = maps.graphql.get(obj.graphqlOperationId);
|
|
817886
|
+
if (translated != null) {
|
|
817887
|
+
obj.title = translated;
|
|
817888
|
+
}
|
|
817889
|
+
} else if (type8 === "apiPackage" && typeof obj.title === "string") {
|
|
817890
|
+
const translated = maps.packagesByBaseTitle.get(obj.title);
|
|
817891
|
+
if (translated != null) {
|
|
817892
|
+
obj.title = translated;
|
|
817893
|
+
}
|
|
817894
|
+
}
|
|
817895
|
+
}
|
|
817896
|
+
for (const value2 of Object.values(obj)) {
|
|
817897
|
+
visit5(value2);
|
|
817898
|
+
}
|
|
817899
|
+
};
|
|
817900
|
+
visit5(clone5);
|
|
817901
|
+
return clone5;
|
|
817902
|
+
}
|
|
817903
|
+
|
|
817666
817904
|
// ../docs-resolver/lib/applyTranslatedFrontmatterToNavTree.js
|
|
817667
817905
|
var import_gray_matter5 = __toESM(require_gray_matter(), 1);
|
|
817668
817906
|
function parseFrontmatterOverrides(markdown) {
|
|
@@ -826203,7 +826441,8 @@ var DocsDefinitionResolver = class {
|
|
|
826203
826441
|
uploadFiles;
|
|
826204
826442
|
registerApi;
|
|
826205
826443
|
targetAudiences;
|
|
826206
|
-
|
|
826444
|
+
buildTranslatedApiDefinitions;
|
|
826445
|
+
constructor({ domain: domain3, docsWorkspace, ossWorkspaces, apiWorkspaces, taskContext, editThisPage, uploadFiles: uploadFiles2 = defaultUploadFiles, registerApi: registerApi2 = defaultRegisterApi, targetAudiences, buildTranslatedApiDefinitions = false }) {
|
|
826207
826446
|
this.domain = domain3;
|
|
826208
826447
|
this.docsWorkspace = docsWorkspace;
|
|
826209
826448
|
this.ossWorkspaces = ossWorkspaces;
|
|
@@ -826213,6 +826452,7 @@ var DocsDefinitionResolver = class {
|
|
|
826213
826452
|
this.uploadFiles = uploadFiles2;
|
|
826214
826453
|
this.registerApi = registerApi2;
|
|
826215
826454
|
this.targetAudiences = targetAudiences;
|
|
826455
|
+
this.buildTranslatedApiDefinitions = buildTranslatedApiDefinitions;
|
|
826216
826456
|
}
|
|
826217
826457
|
#idgen = NodeIdGenerator2.init();
|
|
826218
826458
|
/**
|
|
@@ -826322,6 +826562,13 @@ var DocsDefinitionResolver = class {
|
|
|
826322
826562
|
getDocsWorkspacePath() {
|
|
826323
826563
|
return this.docsWorkspace.absoluteFilePath;
|
|
826324
826564
|
}
|
|
826565
|
+
/**
|
|
826566
|
+
* Returns per-locale translated API definitions, keyed by locale then by the base
|
|
826567
|
+
* `apiDefinitionId`. Must be called after `resolve()`.
|
|
826568
|
+
*/
|
|
826569
|
+
getTranslatedApiSpecs() {
|
|
826570
|
+
return this.translatedApiSpecs;
|
|
826571
|
+
}
|
|
826325
826572
|
getDocsTranslationsConfig() {
|
|
826326
826573
|
const translations = this.parsedDocsConfig.translations;
|
|
826327
826574
|
if (translations == null || translations.length === 0) {
|
|
@@ -826347,6 +826594,12 @@ var DocsDefinitionResolver = class {
|
|
|
826347
826594
|
referencedMarkdownFiles = [];
|
|
826348
826595
|
pendingApiRegistrations = [];
|
|
826349
826596
|
pendingApiCounter = 0;
|
|
826597
|
+
/**
|
|
826598
|
+
* Per-locale translated API definitions, keyed by locale then by the base
|
|
826599
|
+
* `apiDefinitionId`. Populated during {@link resolve} when an API section has
|
|
826600
|
+
* a translated OpenAPI spec under `translations/<locale>/apis/<apiName>/`.
|
|
826601
|
+
*/
|
|
826602
|
+
translatedApiSpecs = /* @__PURE__ */ new Map();
|
|
826350
826603
|
async resolve() {
|
|
826351
826604
|
const resolveStartTime = performance.now();
|
|
826352
826605
|
const startMemory = process.memoryUsage();
|
|
@@ -826501,6 +826754,25 @@ var DocsDefinitionResolver = class {
|
|
|
826501
826754
|
graphqlTypes: pending.graphqlTypes
|
|
826502
826755
|
});
|
|
826503
826756
|
updateApiDefinitionIdInTree(pending.apiReferenceNode, pending.tempApiDefinitionId, realApiDefinitionId);
|
|
826757
|
+
if (pending.translatedIrsByLocale != null) {
|
|
826758
|
+
for (const [locale, translatedIr] of pending.translatedIrsByLocale) {
|
|
826759
|
+
this.resolveLinksInIrDocs(translatedIr, markdownFilesToPathName);
|
|
826760
|
+
let localeMap = this.translatedApiSpecs.get(locale);
|
|
826761
|
+
if (localeMap == null) {
|
|
826762
|
+
localeMap = /* @__PURE__ */ new Map();
|
|
826763
|
+
this.translatedApiSpecs.set(locale, localeMap);
|
|
826764
|
+
}
|
|
826765
|
+
localeMap.set(realApiDefinitionId, {
|
|
826766
|
+
ir: translatedIr,
|
|
826767
|
+
snippetsConfig: pending.snippetsConfig,
|
|
826768
|
+
playgroundConfig: pending.playgroundConfig,
|
|
826769
|
+
apiName: pending.apiName,
|
|
826770
|
+
graphqlOperations: pending.graphqlOperations,
|
|
826771
|
+
graphqlTypes: pending.graphqlTypes,
|
|
826772
|
+
workspace: pending.workspace
|
|
826773
|
+
});
|
|
826774
|
+
}
|
|
826775
|
+
}
|
|
826504
826776
|
}
|
|
826505
826777
|
const deferredTime = performance.now() - deferredStart;
|
|
826506
826778
|
this.taskContext.logger.debug(`Processed deferred API registrations in ${deferredTime.toFixed(0)}ms`);
|
|
@@ -826859,6 +827131,112 @@ Learn more about project structure:
|
|
|
826859
827131
|
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
827132
|
throw new CliError({ message: errorMessage, code: CliError.Code.ConfigError });
|
|
826861
827133
|
}
|
|
827134
|
+
/**
|
|
827135
|
+
* Builds a translated IR for each configured non-default locale whose
|
|
827136
|
+
* `translations/<locale>/apis/<apiName>/` directory contains a translated copy of
|
|
827137
|
+
* the API's OpenAPI spec. The translated spec must be structurally identical to the
|
|
827138
|
+
* base (same paths, operationIds, schema names) so the derived IR lines up 1:1 and
|
|
827139
|
+
* can be keyed by the same `apiDefinitionId`.
|
|
827140
|
+
*/
|
|
827141
|
+
async buildTranslatedApiIrs(item, baseOssWorkspace) {
|
|
827142
|
+
const translationsConfig = this.getDocsTranslationsConfig();
|
|
827143
|
+
if (translationsConfig?.translations == null || translationsConfig.translations.length === 0) {
|
|
827144
|
+
return void 0;
|
|
827145
|
+
}
|
|
827146
|
+
const { defaultLocale, translations } = translationsConfig;
|
|
827147
|
+
const fernFolder = this.docsWorkspace.absoluteFilePath;
|
|
827148
|
+
const result = /* @__PURE__ */ new Map();
|
|
827149
|
+
for (const locale of translations) {
|
|
827150
|
+
if (locale === defaultLocale) {
|
|
827151
|
+
continue;
|
|
827152
|
+
}
|
|
827153
|
+
const translatedWorkspace = this.createTranslatedOssWorkspace(baseOssWorkspace, locale, fernFolder);
|
|
827154
|
+
if (translatedWorkspace == null) {
|
|
827155
|
+
continue;
|
|
827156
|
+
}
|
|
827157
|
+
try {
|
|
827158
|
+
const translatedIr = await translatedWorkspace.getIntermediateRepresentation({
|
|
827159
|
+
context: this.taskContext,
|
|
827160
|
+
audiences: item.audiences,
|
|
827161
|
+
enableUniqueErrorsPerEndpoint: true,
|
|
827162
|
+
generateV1Examples: false,
|
|
827163
|
+
logWarnings: false
|
|
827164
|
+
});
|
|
827165
|
+
result.set(locale, translatedIr);
|
|
827166
|
+
this.taskContext.logger.debug(`Built translated API definition for locale "${locale}" (api: ${item.apiName ?? baseOssWorkspace.workspaceName ?? "<default>"})`);
|
|
827167
|
+
} catch (error50) {
|
|
827168
|
+
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.`);
|
|
827169
|
+
}
|
|
827170
|
+
}
|
|
827171
|
+
return result.size > 0 ? result : void 0;
|
|
827172
|
+
}
|
|
827173
|
+
/**
|
|
827174
|
+
* Clones an OSS (OpenAPI) workspace, remapping spec file paths from `apis/<...>` to
|
|
827175
|
+
* `translations/<locale>/apis/<...>` wherever a translated file exists. Returns
|
|
827176
|
+
* `undefined` when no primary spec has a translated counterpart. Override/overlay
|
|
827177
|
+
* files fall back to the base copy when untranslated, keeping structural metadata
|
|
827178
|
+
* (x-fern-* extensions, audiences, etc.) consistent with the base definition.
|
|
827179
|
+
*/
|
|
827180
|
+
createTranslatedOssWorkspace(base4, locale, fernFolder) {
|
|
827181
|
+
let hasTranslatedSpec = false;
|
|
827182
|
+
const toTranslatedPath = (absPath, countsAsTranslation) => {
|
|
827183
|
+
const rel2 = relative4(fernFolder, absPath);
|
|
827184
|
+
if (String(rel2).startsWith("..")) {
|
|
827185
|
+
return absPath;
|
|
827186
|
+
}
|
|
827187
|
+
const candidate = join8(fernFolder, RelativeFilePath2.of(`translations/${locale}`), rel2);
|
|
827188
|
+
if ((0, import_fs26.existsSync)(candidate)) {
|
|
827189
|
+
if (countsAsTranslation) {
|
|
827190
|
+
hasTranslatedSpec = true;
|
|
827191
|
+
}
|
|
827192
|
+
return candidate;
|
|
827193
|
+
}
|
|
827194
|
+
return absPath;
|
|
827195
|
+
};
|
|
827196
|
+
const remapOverrides = (overrides) => {
|
|
827197
|
+
if (overrides == null) {
|
|
827198
|
+
return overrides;
|
|
827199
|
+
}
|
|
827200
|
+
if (Array.isArray(overrides)) {
|
|
827201
|
+
return overrides.map((p14) => toTranslatedPath(p14, false));
|
|
827202
|
+
}
|
|
827203
|
+
return toTranslatedPath(overrides, false);
|
|
827204
|
+
};
|
|
827205
|
+
const remapSpec = (spec) => {
|
|
827206
|
+
switch (spec.type) {
|
|
827207
|
+
case "openapi":
|
|
827208
|
+
return {
|
|
827209
|
+
...spec,
|
|
827210
|
+
absoluteFilepath: toTranslatedPath(spec.absoluteFilepath, true),
|
|
827211
|
+
absoluteFilepathToOverrides: remapOverrides(spec.absoluteFilepathToOverrides),
|
|
827212
|
+
absoluteFilepathToOverlays: spec.absoluteFilepathToOverlays != null ? toTranslatedPath(spec.absoluteFilepathToOverlays, false) : void 0
|
|
827213
|
+
};
|
|
827214
|
+
case "openrpc":
|
|
827215
|
+
case "graphql":
|
|
827216
|
+
return {
|
|
827217
|
+
...spec,
|
|
827218
|
+
absoluteFilepath: toTranslatedPath(spec.absoluteFilepath, true),
|
|
827219
|
+
absoluteFilepathToOverrides: remapOverrides(spec.absoluteFilepathToOverrides)
|
|
827220
|
+
};
|
|
827221
|
+
default:
|
|
827222
|
+
return spec;
|
|
827223
|
+
}
|
|
827224
|
+
};
|
|
827225
|
+
const translatedSpecs = base4.specs.map((spec) => remapSpec(spec));
|
|
827226
|
+
const translatedAllSpecs = base4.allSpecs.map((spec) => remapSpec(spec));
|
|
827227
|
+
if (!hasTranslatedSpec) {
|
|
827228
|
+
return void 0;
|
|
827229
|
+
}
|
|
827230
|
+
return new OSSWorkspace({
|
|
827231
|
+
allSpecs: translatedAllSpecs,
|
|
827232
|
+
specs: translatedSpecs,
|
|
827233
|
+
generatorsConfiguration: base4.generatorsConfiguration,
|
|
827234
|
+
workspaceName: base4.workspaceName,
|
|
827235
|
+
cliVersion: base4.cliVersion,
|
|
827236
|
+
absoluteFilePath: base4.absoluteFilePath,
|
|
827237
|
+
changelog: base4.changelog
|
|
827238
|
+
});
|
|
827239
|
+
}
|
|
826862
827240
|
async toRootNode() {
|
|
826863
827241
|
const slug = navigation_exports.V1.SlugGenerator.init(navigation_exports.slugjoin(this.getDocsBasePath()));
|
|
826864
827242
|
const id2 = this.#idgen.get("root");
|
|
@@ -827277,6 +827655,10 @@ https://buildwithfern.com/learn/docs/getting-started/project-structure#api-defin
|
|
|
827277
827655
|
this.parsedDocsConfig.pages[relativePath] = processedContent;
|
|
827278
827656
|
}
|
|
827279
827657
|
const apiReferenceNode = node4.get();
|
|
827658
|
+
let translatedIrsByLocale;
|
|
827659
|
+
if (this.buildTranslatedApiDefinitions && openapiWorkspace != null) {
|
|
827660
|
+
translatedIrsByLocale = await this.buildTranslatedApiIrs(item, openapiWorkspace);
|
|
827661
|
+
}
|
|
827280
827662
|
this.pendingApiRegistrations.push({
|
|
827281
827663
|
ir: ir11,
|
|
827282
827664
|
snippetsConfig,
|
|
@@ -827286,7 +827668,8 @@ https://buildwithfern.com/learn/docs/getting-started/project-structure#api-defin
|
|
|
827286
827668
|
graphqlOperations: graphqlData.operations,
|
|
827287
827669
|
graphqlTypes: graphqlData.types,
|
|
827288
827670
|
tempApiDefinitionId,
|
|
827289
|
-
apiReferenceNode
|
|
827671
|
+
apiReferenceNode,
|
|
827672
|
+
translatedIrsByLocale
|
|
827290
827673
|
});
|
|
827291
827674
|
return apiReferenceNode;
|
|
827292
827675
|
}
|
|
@@ -860901,7 +861284,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
860901
861284
|
var LOGS_FOLDER_NAME = "logs";
|
|
860902
861285
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
860903
861286
|
function getCliSource() {
|
|
860904
|
-
const version7 = "5.44.
|
|
861287
|
+
const version7 = "5.44.5";
|
|
860905
861288
|
return `cli@${version7}`;
|
|
860906
861289
|
}
|
|
860907
861290
|
var DebugLogger = class {
|
|
@@ -863742,7 +864125,8 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
|
|
|
863742
864125
|
translationPages: previousPreviewResult.translationPages,
|
|
863743
864126
|
translationNavigationOverlays: previousPreviewResult.translationNavigationOverlays,
|
|
863744
864127
|
collectedFileIds: previousPreviewResult.collectedFileIds,
|
|
863745
|
-
docsWorkspacePath: previousPreviewResult.docsWorkspacePath
|
|
864128
|
+
docsWorkspacePath: previousPreviewResult.docsWorkspacePath,
|
|
864129
|
+
translatedApiDefinitions: previousPreviewResult.translatedApiDefinitions
|
|
863746
864130
|
};
|
|
863747
864131
|
}
|
|
863748
864132
|
}
|
|
@@ -863771,7 +864155,8 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
|
|
|
863771
864155
|
};
|
|
863772
864156
|
}),
|
|
863773
864157
|
registerApi: async (opts) => apiCollector.addReferencedAPI(opts),
|
|
863774
|
-
targetAudiences: void 0
|
|
864158
|
+
targetAudiences: void 0,
|
|
864159
|
+
buildTranslatedApiDefinitions: true
|
|
863775
864160
|
});
|
|
863776
864161
|
const writeDocsDefinition = await resolver2.resolve();
|
|
863777
864162
|
const dbDocsDefinition = convertDocsDefinitionToDb({
|
|
@@ -863814,14 +864199,54 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
|
|
|
863814
864199
|
const translationPages = resolver2.getTranslationPages();
|
|
863815
864200
|
const translationNavigationOverlays = resolver2.getTranslationNavigationOverlays();
|
|
863816
864201
|
const collectedFileIds = resolver2.getCollectedFileIds();
|
|
864202
|
+
const translatedApiSpecs = resolver2.getTranslatedApiSpecs();
|
|
864203
|
+
let translatedApiDefinitions;
|
|
864204
|
+
if (translatedApiSpecs.size > 0) {
|
|
864205
|
+
translatedApiDefinitions = {};
|
|
864206
|
+
for (const [locale, byApiId] of translatedApiSpecs) {
|
|
864207
|
+
const localeApis = {};
|
|
864208
|
+
for (const [apiDefinitionId, spec] of byApiId) {
|
|
864209
|
+
try {
|
|
864210
|
+
localeApis[apiDefinitionId] = convertTranslatedIrToReadApi(spec, apiDefinitionId, context3);
|
|
864211
|
+
} catch (error50) {
|
|
864212
|
+
context3.logger.warn(`Failed to convert translated API definition "${apiDefinitionId}" for locale "${locale}": ${extractErrorMessage(error50)}. Falling back to the default-locale API.`);
|
|
864213
|
+
}
|
|
864214
|
+
}
|
|
864215
|
+
if (Object.keys(localeApis).length > 0) {
|
|
864216
|
+
translatedApiDefinitions[locale] = localeApis;
|
|
864217
|
+
}
|
|
864218
|
+
}
|
|
864219
|
+
if (Object.keys(translatedApiDefinitions).length === 0) {
|
|
864220
|
+
translatedApiDefinitions = void 0;
|
|
864221
|
+
}
|
|
864222
|
+
}
|
|
863817
864223
|
return {
|
|
863818
864224
|
docsDefinition,
|
|
863819
864225
|
translationPages,
|
|
863820
864226
|
translationNavigationOverlays,
|
|
863821
864227
|
collectedFileIds,
|
|
863822
|
-
docsWorkspacePath: docsWorkspace.absoluteFilePath
|
|
864228
|
+
docsWorkspacePath: docsWorkspace.absoluteFilePath,
|
|
864229
|
+
translatedApiDefinitions
|
|
863823
864230
|
};
|
|
863824
864231
|
}
|
|
864232
|
+
function convertTranslatedIrToReadApi(spec, apiDefinitionId, context3) {
|
|
864233
|
+
const dbApiDefinition = convertAPIDefinitionToDb(convertIrToFdrApi({
|
|
864234
|
+
ir: spec.ir,
|
|
864235
|
+
snippetsConfig: spec.snippetsConfig,
|
|
864236
|
+
playgroundConfig: spec.playgroundConfig,
|
|
864237
|
+
graphqlOperations: spec.graphqlOperations ?? {},
|
|
864238
|
+
graphqlTypes: spec.graphqlTypes ?? {},
|
|
864239
|
+
context: context3,
|
|
864240
|
+
apiNameOverride: spec.apiName
|
|
864241
|
+
}), FdrAPI_exports.ApiDefinitionId(apiDefinitionId), new SDKSnippetHolder({
|
|
864242
|
+
snippetsConfigWithSdkId: {},
|
|
864243
|
+
snippetsBySdkId: {},
|
|
864244
|
+
snippetTemplatesByEndpoint: {},
|
|
864245
|
+
snippetTemplatesByEndpointId: {},
|
|
864246
|
+
snippetsBySdkIdAndEndpointId: {}
|
|
864247
|
+
}));
|
|
864248
|
+
return convertDbAPIDefinitionToRead(dbApiDefinition);
|
|
864249
|
+
}
|
|
863825
864250
|
async function applyGlobalThemeIfNeeded(docsWorkspace, organization, context3) {
|
|
863826
864251
|
const themeName = docsWorkspace.config.globalTheme;
|
|
863827
864252
|
if (themeName == null) {
|
|
@@ -864409,15 +864834,22 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
|
|
|
864409
864834
|
const RELOAD_DEBOUNCE_MS = 1e3;
|
|
864410
864835
|
async function computeTranslatedDefinitions(result) {
|
|
864411
864836
|
const translations = /* @__PURE__ */ new Map();
|
|
864412
|
-
const { docsDefinition, translationPages, translationNavigationOverlays, collectedFileIds, docsWorkspacePath } = result;
|
|
864413
|
-
|
|
864837
|
+
const { docsDefinition, translationPages, translationNavigationOverlays, translatedApiDefinitions, collectedFileIds, docsWorkspacePath } = result;
|
|
864838
|
+
const hasTranslatedPages = translationPages != null && Object.keys(translationPages).length > 0;
|
|
864839
|
+
const hasTranslatedApis = translatedApiDefinitions != null && Object.keys(translatedApiDefinitions).length > 0;
|
|
864840
|
+
if (!hasTranslatedPages && !hasTranslatedApis) {
|
|
864414
864841
|
return translations;
|
|
864415
864842
|
}
|
|
864416
864843
|
const defaultLocale = docsDefinition.config.translations?.defaultLocale;
|
|
864417
|
-
|
|
864844
|
+
const localesToBuild = /* @__PURE__ */ new Set([
|
|
864845
|
+
...Object.keys(translationPages ?? {}),
|
|
864846
|
+
...Object.keys(translatedApiDefinitions ?? {})
|
|
864847
|
+
]);
|
|
864848
|
+
for (const locale of localesToBuild) {
|
|
864418
864849
|
if (locale === defaultLocale) {
|
|
864419
864850
|
continue;
|
|
864420
864851
|
}
|
|
864852
|
+
const localePages = translationPages?.[locale] ?? {};
|
|
864421
864853
|
try {
|
|
864422
864854
|
const resolveLocalePath = async (filepath) => {
|
|
864423
864855
|
const relPath = relative4(docsWorkspacePath, filepath);
|
|
@@ -864496,8 +864928,14 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
|
|
|
864496
864928
|
translatedNavbarLinks = localeNavOverlay.navbarLinks;
|
|
864497
864929
|
}
|
|
864498
864930
|
}
|
|
864931
|
+
const localeApis = translatedApiDefinitions?.[locale];
|
|
864932
|
+
const translatedApis = localeApis != null ? { ...docsDefinition.apis, ...localeApis } : docsDefinition.apis;
|
|
864933
|
+
if (localeApis != null && updatedRoot != null) {
|
|
864934
|
+
updatedRoot = applyTranslatedApiTitlesToNavTree(updatedRoot, docsDefinition.apis, localeApis);
|
|
864935
|
+
}
|
|
864499
864936
|
const translatedDefinition = {
|
|
864500
864937
|
...docsDefinition,
|
|
864938
|
+
apis: translatedApis,
|
|
864501
864939
|
pages: translatedPages,
|
|
864502
864940
|
config: {
|
|
864503
864941
|
...docsDefinition.config,
|
|
@@ -864507,7 +864945,7 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
|
|
|
864507
864945
|
}
|
|
864508
864946
|
};
|
|
864509
864947
|
translations.set(locale, translatedDefinition);
|
|
864510
|
-
context3.logger.debug(`Computed translated definition for locale "${locale}"`);
|
|
864948
|
+
context3.logger.debug(`Computed translated definition for locale "${locale}"` + (localeApis != null ? ` (with ${Object.keys(localeApis).length} translated API(s))` : ""));
|
|
864511
864949
|
} catch (error50) {
|
|
864512
864950
|
context3.logger.warn(`Failed to compute translation for locale "${locale}": ${String(error50)}`);
|
|
864513
864951
|
}
|
|
@@ -890797,6 +891235,114 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain3
|
|
|
890797
891235
|
token: token.value,
|
|
890798
891236
|
taskContext: context3
|
|
890799
891237
|
});
|
|
891238
|
+
const buildTranslatedApiDefinitions = docsWorkspace.config.translations != null && docsWorkspace.config.translations.length > 1;
|
|
891239
|
+
const readApiDefinitionsById = /* @__PURE__ */ new Map();
|
|
891240
|
+
const captureReadApiDefinition = (definition3, apiDefinitionId) => {
|
|
891241
|
+
if (!buildTranslatedApiDefinitions) {
|
|
891242
|
+
return;
|
|
891243
|
+
}
|
|
891244
|
+
try {
|
|
891245
|
+
const dbApiDefinition = convertAPIDefinitionToDb(definition3, FdrAPI_exports.ApiDefinitionId(apiDefinitionId), new SDKSnippetHolder({
|
|
891246
|
+
snippetsConfigWithSdkId: {},
|
|
891247
|
+
snippetsBySdkId: {},
|
|
891248
|
+
snippetTemplatesByEndpoint: {},
|
|
891249
|
+
snippetTemplatesByEndpointId: {},
|
|
891250
|
+
snippetsBySdkIdAndEndpointId: {}
|
|
891251
|
+
}));
|
|
891252
|
+
readApiDefinitionsById.set(apiDefinitionId, convertDbAPIDefinitionToRead(dbApiDefinition));
|
|
891253
|
+
} catch (error50) {
|
|
891254
|
+
context3.logger.debug(`Failed to build read API definition for ${apiDefinitionId} (translated sidebar titles may stay in the default language): ${String(error50)}`);
|
|
891255
|
+
}
|
|
891256
|
+
};
|
|
891257
|
+
const registerApiToFdr = async ({ ir: ir11, snippetsConfig, playgroundConfig, apiName, workspace, graphqlOperations, graphqlTypes }) => {
|
|
891258
|
+
let apiDefinition = convertIrToFdrApi({
|
|
891259
|
+
ir: ir11,
|
|
891260
|
+
snippetsConfig,
|
|
891261
|
+
playgroundConfig,
|
|
891262
|
+
graphqlOperations,
|
|
891263
|
+
graphqlTypes,
|
|
891264
|
+
context: context3,
|
|
891265
|
+
apiNameOverride: apiName
|
|
891266
|
+
});
|
|
891267
|
+
const isSelfHosted = token.value === "dummy";
|
|
891268
|
+
const aiEnhancerConfig = getAIEnhancerConfig(withAiExamples && !isSelfHosted, docsWorkspace.config.aiExamples?.style ?? docsWorkspace.config.experimental?.aiExampleStyleInstructions);
|
|
891269
|
+
if (aiEnhancerConfig) {
|
|
891270
|
+
const sources = workspace?.getSources();
|
|
891271
|
+
const openApiSources = sources?.filter((source2) => source2.type === "openapi").map((source2) => ({
|
|
891272
|
+
absoluteFilePath: source2.absoluteFilePath,
|
|
891273
|
+
absoluteFilePathToOverrides: source2.absoluteFilePathToOverrides
|
|
891274
|
+
}));
|
|
891275
|
+
if (openApiSources == null || openApiSources.length === 0) {
|
|
891276
|
+
context3.logger.debug("Skipping AI example enhancement: no OpenAPI source file paths available");
|
|
891277
|
+
} else {
|
|
891278
|
+
apiDefinition = await enhanceExamplesWithAI(apiDefinition, aiEnhancerConfig, context3, token, organization, openApiSources);
|
|
891279
|
+
}
|
|
891280
|
+
}
|
|
891281
|
+
let dynamicIRsByLanguage;
|
|
891282
|
+
let languagesWithExistingSdkDynamicIr = /* @__PURE__ */ new Set();
|
|
891283
|
+
if (Object.keys(snippetsConfig).length === 0) {
|
|
891284
|
+
context3.logger.debug(`No snippets configuration defined, skipping snippet generation...`);
|
|
891285
|
+
} else if (!disableDynamicSnippets) {
|
|
891286
|
+
const existingSdkDynamicIrs = await checkAndDownloadExistingSdkDynamicIRs({
|
|
891287
|
+
fdr,
|
|
891288
|
+
workspace,
|
|
891289
|
+
organization,
|
|
891290
|
+
context: context3,
|
|
891291
|
+
snippetsConfig
|
|
891292
|
+
});
|
|
891293
|
+
if (existingSdkDynamicIrs && Object.keys(existingSdkDynamicIrs).length > 0) {
|
|
891294
|
+
dynamicIRsByLanguage = existingSdkDynamicIrs;
|
|
891295
|
+
languagesWithExistingSdkDynamicIr = new Set(Object.keys(existingSdkDynamicIrs));
|
|
891296
|
+
context3.logger.debug(`Using existing SDK dynamic IRs for: ${Object.keys(existingSdkDynamicIrs).join(", ")}`);
|
|
891297
|
+
}
|
|
891298
|
+
const generatedDynamicIRs = await generateLanguageSpecificDynamicIRs({
|
|
891299
|
+
workspace,
|
|
891300
|
+
organization,
|
|
891301
|
+
context: context3,
|
|
891302
|
+
snippetsConfig,
|
|
891303
|
+
skipLanguages: languagesWithExistingSdkDynamicIr
|
|
891304
|
+
});
|
|
891305
|
+
if (generatedDynamicIRs) {
|
|
891306
|
+
dynamicIRsByLanguage = {
|
|
891307
|
+
...dynamicIRsByLanguage,
|
|
891308
|
+
...generatedDynamicIRs
|
|
891309
|
+
};
|
|
891310
|
+
}
|
|
891311
|
+
}
|
|
891312
|
+
let response;
|
|
891313
|
+
try {
|
|
891314
|
+
response = await fdr.api.register.registerApiDefinition({
|
|
891315
|
+
orgId: FdrAPI_exports.OrgId(organization),
|
|
891316
|
+
apiId: FdrAPI_exports.ApiId(apiName ?? getOriginalName(ir11.apiName)),
|
|
891317
|
+
definition: apiDefinition,
|
|
891318
|
+
dynamicIRs: dynamicIRsByLanguage
|
|
891319
|
+
});
|
|
891320
|
+
} catch (error50) {
|
|
891321
|
+
const errorDetails = extractErrorDetails(error50);
|
|
891322
|
+
context3.logger.error(`FDR registerApiDefinition failed. Error details:
|
|
891323
|
+
${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
891324
|
+
if (apiName != null) {
|
|
891325
|
+
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 });
|
|
891326
|
+
} else {
|
|
891327
|
+
return context3.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
|
|
891328
|
+
}
|
|
891329
|
+
}
|
|
891330
|
+
context3.logger.debug(`Registered API Definition ${apiName}: ${response.apiDefinitionId}`);
|
|
891331
|
+
if (response.dynamicIRs && dynamicIRsByLanguage) {
|
|
891332
|
+
if (skipUpload) {
|
|
891333
|
+
context3.logger.debug("Skip-upload mode: skipping dynamic IR uploads");
|
|
891334
|
+
} else {
|
|
891335
|
+
await uploadDynamicIRs({
|
|
891336
|
+
dynamicIRs: dynamicIRsByLanguage,
|
|
891337
|
+
dynamicIRUploadUrls: response.dynamicIRs,
|
|
891338
|
+
context: context3,
|
|
891339
|
+
apiId: response.apiDefinitionId
|
|
891340
|
+
});
|
|
891341
|
+
}
|
|
891342
|
+
}
|
|
891343
|
+
captureReadApiDefinition(apiDefinition, response.apiDefinitionId);
|
|
891344
|
+
return response.apiDefinitionId;
|
|
891345
|
+
};
|
|
890800
891346
|
const resolver2 = new DocsDefinitionResolver({
|
|
890801
891347
|
domain: domain3,
|
|
890802
891348
|
docsWorkspace: effectiveWorkspace,
|
|
@@ -890920,94 +891466,8 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain3
|
|
|
890920
891466
|
return convertToFilePathPairs(startDocsRegisterResponse.uploadUrls, docsWorkspace.absoluteFilePath, sanitizedToAbsoluteMap);
|
|
890921
891467
|
}
|
|
890922
891468
|
},
|
|
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
|
-
},
|
|
891469
|
+
registerApi: registerApiToFdr,
|
|
891470
|
+
buildTranslatedApiDefinitions,
|
|
891011
891471
|
targetAudiences
|
|
891012
891472
|
});
|
|
891013
891473
|
context3.logger.info("Resolving docs definition...");
|
|
@@ -891047,6 +891507,27 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
|
891047
891507
|
}
|
|
891048
891508
|
const publishTime = performance.now() - publishStart;
|
|
891049
891509
|
context3.logger.debug(`Docs published to FDR in ${publishTime.toFixed(0)}ms`);
|
|
891510
|
+
const translatedApiSpecsByLocale = buildTranslatedApiDefinitions ? resolver2.getTranslatedApiSpecs() : /* @__PURE__ */ new Map();
|
|
891511
|
+
const translatedApiIdsByLocale = /* @__PURE__ */ new Map();
|
|
891512
|
+
if (translatedApiSpecsByLocale.size > 0) {
|
|
891513
|
+
context3.logger.info(`Registering translated API definitions for ${translatedApiSpecsByLocale.size} locale(s)...`);
|
|
891514
|
+
for (const [locale, specsByBaseApiId] of translatedApiSpecsByLocale) {
|
|
891515
|
+
const idMap = /* @__PURE__ */ new Map();
|
|
891516
|
+
for (const [baseApiId, spec] of specsByBaseApiId) {
|
|
891517
|
+
try {
|
|
891518
|
+
const translatedApiId = await registerApiToFdr(spec);
|
|
891519
|
+
if (translatedApiId !== baseApiId) {
|
|
891520
|
+
idMap.set(baseApiId, translatedApiId);
|
|
891521
|
+
}
|
|
891522
|
+
} catch (error50) {
|
|
891523
|
+
context3.logger.warn(`Failed to register translated API definition for locale "${locale}" (API reference will render in the default language): ${String(error50)}`);
|
|
891524
|
+
}
|
|
891525
|
+
}
|
|
891526
|
+
if (idMap.size > 0) {
|
|
891527
|
+
translatedApiIdsByLocale.set(locale, idMap);
|
|
891528
|
+
}
|
|
891529
|
+
}
|
|
891530
|
+
}
|
|
891050
891531
|
const translationPages = resolver2.getTranslationPages();
|
|
891051
891532
|
const translationNavigationOverlays = resolver2.getTranslationNavigationOverlays();
|
|
891052
891533
|
const translationDomain = preview ? urlToOutput : domain3;
|
|
@@ -891146,6 +891627,25 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
|
|
|
891146
891627
|
translatedNavbarLinks = localeNavOverlay.navbarLinks;
|
|
891147
891628
|
}
|
|
891148
891629
|
}
|
|
891630
|
+
const localeApiIdMap = translatedApiIdsByLocale.get(locale);
|
|
891631
|
+
if (localeApiIdMap != null && localeApiIdMap.size > 0 && updatedRoot != null) {
|
|
891632
|
+
const baseApisForTitles = {};
|
|
891633
|
+
const translatedApisForTitles = {};
|
|
891634
|
+
for (const [baseApiId, translatedApiId] of localeApiIdMap) {
|
|
891635
|
+
const baseRead = readApiDefinitionsById.get(baseApiId);
|
|
891636
|
+
const translatedRead = readApiDefinitionsById.get(translatedApiId);
|
|
891637
|
+
if (baseRead != null) {
|
|
891638
|
+
baseApisForTitles[baseApiId] = baseRead;
|
|
891639
|
+
}
|
|
891640
|
+
if (translatedRead != null) {
|
|
891641
|
+
translatedApisForTitles[baseApiId] = translatedRead;
|
|
891642
|
+
}
|
|
891643
|
+
}
|
|
891644
|
+
updatedRoot = Object.keys(translatedApisForTitles).length > 0 ? applyTranslatedApiTitlesToNavTree(updatedRoot, baseApisForTitles, translatedApisForTitles) : structuredClone(updatedRoot);
|
|
891645
|
+
for (const [baseApiId, translatedApiId] of localeApiIdMap) {
|
|
891646
|
+
updateApiDefinitionIdInTree(updatedRoot, baseApiId, translatedApiId);
|
|
891647
|
+
}
|
|
891648
|
+
}
|
|
891149
891649
|
const translatedDefinition = {
|
|
891150
891650
|
...docsDefinition,
|
|
891151
891651
|
pages: translatedPages,
|
|
@@ -891876,7 +892376,7 @@ var LegacyDocsPublisher = class {
|
|
|
891876
892376
|
previewId,
|
|
891877
892377
|
disableTemplates: void 0,
|
|
891878
892378
|
skipUpload,
|
|
891879
|
-
cliVersion: "5.44.
|
|
892379
|
+
cliVersion: "5.44.5",
|
|
891880
892380
|
loginCommand: "fern auth login"
|
|
891881
892381
|
});
|
|
891882
892382
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
@@ -895481,7 +895981,7 @@ var CONTAINER_SOURCES_DIRECTORY = DOCKER_SOURCES_DIRECTORY;
|
|
|
895481
895981
|
var DOCKER_SPECS_DIRECTORY = import_path84.default.join(DOCKER_FERN_DIRECTORY, SPECS_DIRECTORY_NAME);
|
|
895482
895982
|
var CONTAINER_SPECS_DIRECTORY = DOCKER_SPECS_DIRECTORY;
|
|
895483
895983
|
var DEFAULT_NODE_DEBUG_PORT = "9229";
|
|
895484
|
-
var GENERATORS_WANTING_SPECS = /* @__PURE__ */ new Set(["fernapi/fern-cli"]);
|
|
895984
|
+
var GENERATORS_WANTING_SPECS = /* @__PURE__ */ new Set(["fernapi/fern-cli-generator"]);
|
|
895485
895985
|
function generatorWantsSpecs(generatorName) {
|
|
895486
895986
|
return GENERATORS_WANTING_SPECS.has(generatorName);
|
|
895487
895987
|
}
|
|
@@ -956963,7 +957463,7 @@ function getAutomationContextFromEnv() {
|
|
|
956963
957463
|
config_branch: process.env.FERN_CONFIG_BRANCH,
|
|
956964
957464
|
config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
|
|
956965
957465
|
trigger: process.env.GITHUB_EVENT_NAME,
|
|
956966
|
-
cli_version: "5.44.
|
|
957466
|
+
cli_version: "5.44.5"
|
|
956967
957467
|
};
|
|
956968
957468
|
}
|
|
956969
957469
|
function isAutomationMode() {
|
|
@@ -957789,7 +958289,7 @@ var CliContext = class _CliContext {
|
|
|
957789
958289
|
if (false) {
|
|
957790
958290
|
this.logger.error("CLI_VERSION is not defined");
|
|
957791
958291
|
}
|
|
957792
|
-
return "5.44.
|
|
958292
|
+
return "5.44.5";
|
|
957793
958293
|
}
|
|
957794
958294
|
getCliName() {
|
|
957795
958295
|
if (false) {
|
package/package.json
CHANGED