@fern-api/fern-api-dev 5.56.0 → 5.56.2

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.
Files changed (2) hide show
  1. package/cli.cjs +144 -138
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -454802,129 +454802,20 @@ var init_lib65 = __esm({
454802
454802
  }
454803
454803
  });
454804
454804
 
454805
- // ../register/lib/ai-example-enhancer/filterHelpers.js
454806
- function isFdrTypedValueWrapper(value2) {
454807
- if (value2 === null || value2 === void 0 || typeof value2 !== "object" || Array.isArray(value2)) {
454808
- return false;
454809
- }
454810
- const obj = value2;
454811
- const keys25 = Object.keys(obj);
454812
- if (keys25.length === 0 || keys25.length > 2) {
454813
- return false;
454814
- }
454815
- const hasType = "type" in obj && typeof obj.type === "string";
454816
- const hasValue = "value" in obj;
454817
- return hasType && keys25.length === 1 || hasType && hasValue && keys25.length === 2 || hasValue && keys25.length === 1;
454818
- }
454819
- function unwrapExampleValue(value2) {
454820
- if (value2 === null || value2 === void 0) {
454821
- return value2;
454822
- }
454823
- if (Array.isArray(value2)) {
454824
- return value2.map(unwrapExampleValue);
454825
- }
454826
- if (typeof value2 !== "object") {
454827
- return value2;
454828
- }
454829
- const obj = value2;
454830
- if (isFdrTypedValueWrapper(obj)) {
454831
- if ("value" in obj) {
454832
- return unwrapExampleValue(obj.value);
454833
- }
454834
- return void 0;
454835
- }
454836
- const result = {};
454837
- for (const [key2, val] of Object.entries(obj)) {
454838
- const unwrapped = unwrapExampleValue(val);
454839
- if (unwrapped !== void 0) {
454840
- result[key2] = unwrapped;
454841
- }
454842
- }
454843
- return result;
454844
- }
454845
- function isEmptyObject3(value2) {
454846
- if (value2 === null || value2 === void 0) {
454847
- return true;
454848
- }
454849
- if (typeof value2 !== "object") {
454850
- return false;
454851
- }
454852
- if (Array.isArray(value2)) {
454853
- return value2.length === 0;
454854
- }
454855
- return Object.keys(value2).length === 0;
454856
- }
454857
- function filterRequestBody(requestBody, pathParameters, queryParameters, headers2) {
454858
- const extractedPathParams = {};
454859
- const extractedQueryParams = {};
454860
- const extractedHeaders = {};
454861
- if (requestBody === null || requestBody === void 0 || typeof requestBody !== "object" || Array.isArray(requestBody)) {
454862
- return { filteredBody: requestBody, extractedPathParams, extractedQueryParams, extractedHeaders };
454863
- }
454864
- const bodyRecord = requestBody;
454865
- const filteredBody = {};
454866
- const pathParamKeys = new Set(Object.keys(pathParameters ?? {}));
454867
- const queryParamKeys = new Set(Object.keys(queryParameters ?? {}));
454868
- const headerKeys = new Set(Object.keys(headers2 ?? {}));
454869
- for (const [key2, value2] of Object.entries(bodyRecord)) {
454870
- const normalizedKey = key2.toLowerCase().replace(/[-_]/g, "");
454871
- let isPathParam = false;
454872
- let isQueryParam = false;
454873
- let isHeader = false;
454874
- for (const pathKey of pathParamKeys) {
454875
- const normalizedPathKey = pathKey.toLowerCase().replace(/[-_]/g, "");
454876
- if (normalizedKey === normalizedPathKey) {
454877
- isPathParam = true;
454878
- extractedPathParams[pathKey] = value2;
454879
- break;
454880
- }
454881
- }
454882
- if (!isPathParam) {
454883
- for (const queryKey of queryParamKeys) {
454884
- const normalizedQueryKey = queryKey.toLowerCase().replace(/[-_]/g, "");
454885
- if (normalizedKey === normalizedQueryKey) {
454886
- isQueryParam = true;
454887
- extractedQueryParams[queryKey] = value2;
454888
- break;
454889
- }
454890
- }
454891
- }
454892
- if (!isPathParam && !isQueryParam) {
454893
- for (const headerKey of headerKeys) {
454894
- const normalizedHeaderKey = headerKey.toLowerCase().replace(/[-_]/g, "");
454895
- if (normalizedKey === normalizedHeaderKey) {
454896
- isHeader = true;
454897
- extractedHeaders[headerKey] = value2;
454898
- break;
454899
- }
454900
- }
454901
- }
454902
- if (!isPathParam && !isQueryParam && !isHeader) {
454903
- filteredBody[key2] = value2;
454904
- }
454905
- }
454906
- return { filteredBody, extractedPathParams, extractedQueryParams, extractedHeaders };
454907
- }
454908
- var init_filterHelpers = __esm({
454909
- "../register/lib/ai-example-enhancer/filterHelpers.js"() {
454910
- "use strict";
454911
- }
454912
- });
454913
-
454914
- // ../register/lib/ai-example-enhancer/lambdaClient.js
454915
- var DEFAULT_AI_ENHANCEMENT_MAX_RETRIES, DEFAULT_AI_ENHANCEMENT_TIMEOUT_MS, LambdaExampleEnhancer;
454916
- var init_lambdaClient = __esm({
454917
- "../register/lib/ai-example-enhancer/lambdaClient.js"() {
454805
+ // ../register/lib/ai-example-enhancer/faiClient.js
454806
+ var DEFAULT_AI_ENHANCEMENT_MAX_RETRIES, DEFAULT_AI_ENHANCEMENT_TIMEOUT_MS, FaiExampleEnhancer;
454807
+ var init_faiClient = __esm({
454808
+ "../register/lib/ai-example-enhancer/faiClient.js"() {
454918
454809
  "use strict";
454919
454810
  init_lib4();
454920
454811
  init_lib35();
454921
454812
  init_lib6();
454922
454813
  DEFAULT_AI_ENHANCEMENT_MAX_RETRIES = 0;
454923
454814
  DEFAULT_AI_ENHANCEMENT_TIMEOUT_MS = 15e3;
454924
- LambdaExampleEnhancer = class {
454815
+ FaiExampleEnhancer = class {
454925
454816
  config;
454926
454817
  context;
454927
- lambdaOrigin;
454818
+ faiOrigin;
454928
454819
  venusOrigin;
454929
454820
  token;
454930
454821
  jwtPromise;
@@ -454940,14 +454831,14 @@ var init_lambdaClient = __esm({
454940
454831
  styleInstructions: config5.styleInstructions
454941
454832
  };
454942
454833
  this.context = context3;
454943
- const lambdaOrigin = "https://ykq45y6fvnszd35iv5yuuatkze0rpwuz.lambda-url.us-east-1.on.aws";
454944
- if (!lambdaOrigin) {
454834
+ const faiOrigin = "https://fai-dev2.buildwithfern.com";
454835
+ if (!faiOrigin) {
454945
454836
  throw new CliError({
454946
- message: "DEFAULT_FDR_LAMBDA_DOCS_ORIGIN environment variable is not set. AI example enhancement requires this to be configured.",
454837
+ message: "DEFAULT_FAI_ORIGIN environment variable is not set. AI example enhancement requires this to be configured.",
454947
454838
  code: CliError.Code.EnvironmentError
454948
454839
  });
454949
454840
  }
454950
- this.lambdaOrigin = lambdaOrigin;
454841
+ this.faiOrigin = faiOrigin;
454951
454842
  this.venusOrigin = "https://venus-dev2.buildwithfern.com";
454952
454843
  this.token = token;
454953
454844
  this.organizationId = organizationId;
@@ -455052,7 +454943,7 @@ var init_lambdaClient = __esm({
455052
454943
  const maxAttempts = this.config.maxRetries + 1;
455053
454944
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
455054
454945
  try {
455055
- this.context.logger.debug(`Enhancing example for ${request7.method} ${request7.endpointPath} via lambda (attempt ${attempt}/${maxAttempts})`);
454946
+ this.context.logger.debug(`Enhancing example for ${request7.method} ${request7.endpointPath} via FAI (attempt ${attempt}/${maxAttempts})`);
455056
454947
  const requestBody = {
455057
454948
  method: request7.method,
455058
454949
  endpointPath: request7.endpointPath,
@@ -455068,7 +454959,7 @@ var init_lambdaClient = __esm({
455068
454959
  ...requestBody,
455069
454960
  openApiSpec: request7.openApiSpec ? `[OpenAPI spec present: ${request7.openApiSpec.length} chars]` : "[No OpenAPI spec]"
455070
454961
  }, null, 2)}`);
455071
- const response = await fetch(`${this.lambdaOrigin}/v2/registry/ai/enhance-example`, {
454962
+ const response = await fetch(`${this.faiOrigin}/examples/enhance`, {
455072
454963
  method: "POST",
455073
454964
  headers: {
455074
454965
  "Content-Type": "application/json",
@@ -455080,7 +454971,7 @@ var init_lambdaClient = __esm({
455080
454971
  if (!response.ok) {
455081
454972
  const errorText = await response.text();
455082
454973
  throw new CliError({
455083
- message: `Lambda returned ${response.status}: ${errorText || response.statusText}`,
454974
+ message: `FAI returned ${response.status}: ${errorText || response.statusText}`,
455084
454975
  code: CliError.Code.NetworkError
455085
454976
  });
455086
454977
  }
@@ -455108,6 +454999,115 @@ var init_lambdaClient = __esm({
455108
454999
  }
455109
455000
  });
455110
455001
 
455002
+ // ../register/lib/ai-example-enhancer/filterHelpers.js
455003
+ function isFdrTypedValueWrapper(value2) {
455004
+ if (value2 === null || value2 === void 0 || typeof value2 !== "object" || Array.isArray(value2)) {
455005
+ return false;
455006
+ }
455007
+ const obj = value2;
455008
+ const keys25 = Object.keys(obj);
455009
+ if (keys25.length === 0 || keys25.length > 2) {
455010
+ return false;
455011
+ }
455012
+ const hasType = "type" in obj && typeof obj.type === "string";
455013
+ const hasValue = "value" in obj;
455014
+ return hasType && keys25.length === 1 || hasType && hasValue && keys25.length === 2 || hasValue && keys25.length === 1;
455015
+ }
455016
+ function unwrapExampleValue(value2) {
455017
+ if (value2 === null || value2 === void 0) {
455018
+ return value2;
455019
+ }
455020
+ if (Array.isArray(value2)) {
455021
+ return value2.map(unwrapExampleValue);
455022
+ }
455023
+ if (typeof value2 !== "object") {
455024
+ return value2;
455025
+ }
455026
+ const obj = value2;
455027
+ if (isFdrTypedValueWrapper(obj)) {
455028
+ if ("value" in obj) {
455029
+ return unwrapExampleValue(obj.value);
455030
+ }
455031
+ return void 0;
455032
+ }
455033
+ const result = {};
455034
+ for (const [key2, val] of Object.entries(obj)) {
455035
+ const unwrapped = unwrapExampleValue(val);
455036
+ if (unwrapped !== void 0) {
455037
+ result[key2] = unwrapped;
455038
+ }
455039
+ }
455040
+ return result;
455041
+ }
455042
+ function isEmptyObject3(value2) {
455043
+ if (value2 === null || value2 === void 0) {
455044
+ return true;
455045
+ }
455046
+ if (typeof value2 !== "object") {
455047
+ return false;
455048
+ }
455049
+ if (Array.isArray(value2)) {
455050
+ return value2.length === 0;
455051
+ }
455052
+ return Object.keys(value2).length === 0;
455053
+ }
455054
+ function filterRequestBody(requestBody, pathParameters, queryParameters, headers2) {
455055
+ const extractedPathParams = {};
455056
+ const extractedQueryParams = {};
455057
+ const extractedHeaders = {};
455058
+ if (requestBody === null || requestBody === void 0 || typeof requestBody !== "object" || Array.isArray(requestBody)) {
455059
+ return { filteredBody: requestBody, extractedPathParams, extractedQueryParams, extractedHeaders };
455060
+ }
455061
+ const bodyRecord = requestBody;
455062
+ const filteredBody = {};
455063
+ const pathParamKeys = new Set(Object.keys(pathParameters ?? {}));
455064
+ const queryParamKeys = new Set(Object.keys(queryParameters ?? {}));
455065
+ const headerKeys = new Set(Object.keys(headers2 ?? {}));
455066
+ for (const [key2, value2] of Object.entries(bodyRecord)) {
455067
+ const normalizedKey = key2.toLowerCase().replace(/[-_]/g, "");
455068
+ let isPathParam = false;
455069
+ let isQueryParam = false;
455070
+ let isHeader = false;
455071
+ for (const pathKey of pathParamKeys) {
455072
+ const normalizedPathKey = pathKey.toLowerCase().replace(/[-_]/g, "");
455073
+ if (normalizedKey === normalizedPathKey) {
455074
+ isPathParam = true;
455075
+ extractedPathParams[pathKey] = value2;
455076
+ break;
455077
+ }
455078
+ }
455079
+ if (!isPathParam) {
455080
+ for (const queryKey of queryParamKeys) {
455081
+ const normalizedQueryKey = queryKey.toLowerCase().replace(/[-_]/g, "");
455082
+ if (normalizedKey === normalizedQueryKey) {
455083
+ isQueryParam = true;
455084
+ extractedQueryParams[queryKey] = value2;
455085
+ break;
455086
+ }
455087
+ }
455088
+ }
455089
+ if (!isPathParam && !isQueryParam) {
455090
+ for (const headerKey of headerKeys) {
455091
+ const normalizedHeaderKey = headerKey.toLowerCase().replace(/[-_]/g, "");
455092
+ if (normalizedKey === normalizedHeaderKey) {
455093
+ isHeader = true;
455094
+ extractedHeaders[headerKey] = value2;
455095
+ break;
455096
+ }
455097
+ }
455098
+ }
455099
+ if (!isPathParam && !isQueryParam && !isHeader) {
455100
+ filteredBody[key2] = value2;
455101
+ }
455102
+ }
455103
+ return { filteredBody, extractedPathParams, extractedQueryParams, extractedHeaders };
455104
+ }
455105
+ var init_filterHelpers = __esm({
455106
+ "../register/lib/ai-example-enhancer/filterHelpers.js"() {
455107
+ "use strict";
455108
+ }
455109
+ });
455110
+
455111
455111
  // ../register/lib/ai-example-enhancer/spinnerStatusCoordinator.js
455112
455112
  var SpinnerStatusCoordinator;
455113
455113
  var init_spinnerStatusCoordinator = __esm({
@@ -455713,7 +455713,7 @@ async function enhanceExamplesWithAI(apiDefinition, config5, context3, token, or
455713
455713
  }
455714
455714
  }
455715
455715
  async function performAIEnhancement(apiDefinition, config5, context3, token, organizationId, sourceSpecs, apiName) {
455716
- const enhancer = new LambdaExampleEnhancer(config5, context3, token, organizationId);
455716
+ const enhancer = new FaiExampleEnhancer(config5, context3, token, organizationId);
455717
455717
  const circuitBreaker = new CircuitBreaker();
455718
455718
  let openApiSpec;
455719
455719
  let endpointsNeedingRegeneration = /* @__PURE__ */ new Set();
@@ -455926,7 +455926,7 @@ function collectWorkItems(pkg2, coveredEndpoints, endpointsNeedingRegeneration,
455926
455926
  }
455927
455927
  async function processEndpointsConcurrently(allWorkItems, enhancer, context3, organizationId, stats, enhancedExampleRecords, openApiSpec, sourceFilePath, statusId, apiStats, circuitBreaker) {
455928
455928
  const maxConcurrentRequests = parseInt(process.env.FERN_AI_MAX_CONCURRENT || "25", 10);
455929
- context3.logger.debug(`Processing ${allWorkItems.length} endpoints with max ${maxConcurrentRequests} concurrent Lambda calls using rolling window queue`);
455929
+ context3.logger.debug(`Processing ${allWorkItems.length} endpoints with max ${maxConcurrentRequests} concurrent FAI calls using rolling window queue`);
455930
455930
  if (circuitBreaker?.shouldSkip()) {
455931
455931
  context3.logger.debug(`Circuit breaker is open after ${circuitBreaker.getFailureCount()} failures (threshold: ${circuitBreaker.getThreshold()}). Skipping AI enhancement for remaining endpoints.`);
455932
455932
  return /* @__PURE__ */ new Map();
@@ -456043,7 +456043,7 @@ async function processEndpoint(workItem, enhancer, context3, organizationId, sta
456043
456043
  const result = await enhancer.enhanceExample(request7);
456044
456044
  circuitBreaker?.recordSuccess();
456045
456045
  if (result.enhancedRequestExample != null && request7.originalRequestExample != null) {
456046
- const unwrapped = unwrapLambdaBodyEnvelope(result.enhancedRequestExample);
456046
+ const unwrapped = unwrapBodyEnvelope(result.enhancedRequestExample);
456047
456047
  const originalHasBody = isObjectWithKey(request7.originalRequestExample, "body");
456048
456048
  if (unwrapped.wasWrapped && !originalHasBody) {
456049
456049
  result.enhancedRequestExample = backfillMissingFields(unwrapped.inner, request7.originalRequestExample);
@@ -456327,7 +456327,7 @@ function extractExampleValue(bodyV3) {
456327
456327
  function isObjectWithKey(value2, key2) {
456328
456328
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2) && key2 in value2;
456329
456329
  }
456330
- function unwrapLambdaBodyEnvelope(value2) {
456330
+ function unwrapBodyEnvelope(value2) {
456331
456331
  if (typeof value2 === "object" && value2 !== null && !Array.isArray(value2) && "body" in value2) {
456332
456332
  return { wasWrapped: true, inner: value2.body };
456333
456333
  }
@@ -456365,8 +456365,8 @@ var init_enhanceExamplesWithAI = __esm({
456365
456365
  init_lib65();
456366
456366
  import_promises72 = require("fs/promises");
456367
456367
  init_js_yaml();
456368
+ init_faiClient();
456368
456369
  init_filterHelpers();
456369
- init_lambdaClient();
456370
456370
  init_spinnerStatusCoordinator();
456371
456371
  init_validateAiExamples();
456372
456372
  init_writeAiExamplesOverride();
@@ -686971,7 +686971,7 @@ var AccessTokenPosthogManager = class {
686971
686971
  properties: {
686972
686972
  ...event,
686973
686973
  ...event.properties,
686974
- version: "5.56.0",
686974
+ version: "5.56.2",
686975
686975
  usingAccessToken: true,
686976
686976
  ...getRunIdProperties()
686977
686977
  }
@@ -687037,7 +687037,7 @@ var UserPosthogManager = class {
687037
687037
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
687038
687038
  event: "CLI",
687039
687039
  properties: {
687040
- version: "5.56.0",
687040
+ version: "5.56.2",
687041
687041
  ...event,
687042
687042
  ...event.properties,
687043
687043
  usingAccessToken: false,
@@ -868132,7 +868132,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
868132
868132
  var LOGS_FOLDER_NAME = "logs";
868133
868133
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
868134
868134
  function getCliSource() {
868135
- const version7 = "5.56.0";
868135
+ const version7 = "5.56.2";
868136
868136
  return `cli@${version7}`;
868137
868137
  }
868138
868138
  var DebugLogger = class {
@@ -870553,11 +870553,17 @@ async function downloadBundle({ bucketUrl, logger: logger4, preferCached, app =
870553
870553
  }
870554
870554
  const workspaceConfigPath = import_path69.default.join(absolutePathToBundleFolder, "pnpm-workspace.yaml");
870555
870555
  if (!(0, import_fs28.existsSync)(workspaceConfigPath)) {
870556
- await (0, import_promises97.writeFile)(workspaceConfigPath, "onlyBuiltDependencies:\n - esbuild\n");
870556
+ await (0, import_promises97.writeFile)(workspaceConfigPath, "packages: []\nonlyBuiltDependencies:\n - esbuild\n");
870557
+ } else {
870558
+ const existingWorkspaceConfig = await (0, import_promises97.readFile)(workspaceConfigPath, "utf-8");
870559
+ if (!existingWorkspaceConfig.includes("packages:")) {
870560
+ await (0, import_promises97.writeFile)(workspaceConfigPath, `packages: []
870561
+ ${existingWorkspaceConfig}`);
870562
+ }
870557
870563
  }
870558
870564
  try {
870559
870565
  logger4.debug("Installing esbuild");
870560
- await loggingExeca(logger4, "pnpm", ["i", "esbuild"], {
870566
+ await loggingExeca(logger4, "pnpm", ["i", "-w", "esbuild"], {
870561
870567
  cwd: absolutePathToBundleFolder,
870562
870568
  doNotPipeOutput: true
870563
870569
  });
@@ -870576,7 +870582,7 @@ async function downloadBundle({ bucketUrl, logger: logger4, preferCached, app =
870576
870582
  }
870577
870583
  try {
870578
870584
  logger4.debug("Installing esbuild after upgrading corepack");
870579
- await loggingExeca(logger4, "pnpm", ["i", "esbuild"], {
870585
+ await loggingExeca(logger4, "pnpm", ["i", "-w", "esbuild"], {
870580
870586
  cwd: absolutePathToBundleFolder,
870581
870587
  doNotPipeOutput: true
870582
870588
  });
@@ -887561,8 +887567,8 @@ init_lib68();
887561
887567
  init_lib6();
887562
887568
  var import_tmp_promise11 = __toESM(require_tmp_promise(), 1);
887563
887569
  var PARSER_IMAGES = {
887564
- PYTHON: "fernapi/fern-python-library-docs-parser",
887565
- CPP: "fernapi/fern-cpp-library-docs-parser"
887570
+ PYTHON: "fernenterprise/fern-python-library-docs-parser",
887571
+ CPP: "fernenterprise/fern-cpp-library-docs-parser"
887566
887572
  };
887567
887573
  var PARSER_IMAGE_TAG = "latest";
887568
887574
  var PARSER_IMAGE_ENV_VARS = {
@@ -900526,7 +900532,7 @@ var LegacyDocsPublisher = class {
900526
900532
  previewId,
900527
900533
  disableTemplates: void 0,
900528
900534
  skipUpload,
900529
- cliVersion: "5.56.0",
900535
+ cliVersion: "5.56.2",
900530
900536
  loginCommand: "fern auth login"
900531
900537
  });
900532
900538
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -966795,7 +966801,7 @@ function getAutomationContextFromEnv() {
966795
966801
  config_branch: process.env.FERN_CONFIG_BRANCH,
966796
966802
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
966797
966803
  trigger: process.env.GITHUB_EVENT_NAME,
966798
- cli_version: "5.56.0"
966804
+ cli_version: "5.56.2"
966799
966805
  };
966800
966806
  }
966801
966807
  function isAutomationMode() {
@@ -967627,7 +967633,7 @@ var CliContext = class _CliContext {
967627
967633
  if (false) {
967628
967634
  this.logger.error("CLI_VERSION is not defined");
967629
967635
  }
967630
- return "5.56.0";
967636
+ return "5.56.2";
967631
967637
  }
967632
967638
  getCliName() {
967633
967639
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.56.0",
2
+ "version": "5.56.2",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",