@fern-api/fern-api-dev 5.23.3-1306-g97e4764e29d → 5.23.3-1314-ge04cf20354b

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 +160 -11
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -67272,6 +67272,13 @@ var init_HeaderApiVersionScheme = __esm({
67272
67272
  }
67273
67273
  });
67274
67274
 
67275
+ // ../../ir-sdk/lib/sdk/api/resources/ir/types/IdempotencyKeyGeneration.js
67276
+ var init_IdempotencyKeyGeneration = __esm({
67277
+ "../../ir-sdk/lib/sdk/api/resources/ir/types/IdempotencyKeyGeneration.js"() {
67278
+ "use strict";
67279
+ }
67280
+ });
67281
+
67275
67282
  // ../../ir-sdk/lib/sdk/api/resources/ir/types/IntermediateRepresentation.js
67276
67283
  var init_IntermediateRepresentation = __esm({
67277
67284
  "../../ir-sdk/lib/sdk/api/resources/ir/types/IntermediateRepresentation.js"() {
@@ -67400,6 +67407,7 @@ var init_types63 = __esm({
67400
67407
  init_ExampleStyle();
67401
67408
  init_GenerationMetadata();
67402
67409
  init_HeaderApiVersionScheme();
67410
+ init_IdempotencyKeyGeneration();
67403
67411
  init_IntermediateRepresentation();
67404
67412
  init_InvocationSource();
67405
67413
  init_Package();
@@ -79542,6 +79550,20 @@ var init_GenerationMetadata2 = __esm({
79542
79550
  }
79543
79551
  });
79544
79552
 
79553
+ // ../../ir-sdk/lib/sdk/serialization/resources/ir/types/IdempotencyKeyGeneration.js
79554
+ var IdempotencyKeyGeneration;
79555
+ var init_IdempotencyKeyGeneration2 = __esm({
79556
+ "../../ir-sdk/lib/sdk/serialization/resources/ir/types/IdempotencyKeyGeneration.js"() {
79557
+ "use strict";
79558
+ init_core2();
79559
+ init_HttpMethod4();
79560
+ IdempotencyKeyGeneration = schemas_exports3.objectWithoutOptionalProperties({
79561
+ headerName: schemas_exports3.string(),
79562
+ methods: schemas_exports3.list(HttpMethod4)
79563
+ });
79564
+ }
79565
+ });
79566
+
79545
79567
  // ../../ir-sdk/lib/sdk/serialization/resources/publish/types/CratesPublishTarget.js
79546
79568
  var CratesPublishTarget;
79547
79569
  var init_CratesPublishTarget2 = __esm({
@@ -81375,13 +81397,15 @@ var init_SdkConfig2 = __esm({
81375
81397
  "../../ir-sdk/lib/sdk/serialization/resources/ir/types/SdkConfig.js"() {
81376
81398
  "use strict";
81377
81399
  init_core2();
81400
+ init_IdempotencyKeyGeneration2();
81378
81401
  init_PlatformHeaders2();
81379
81402
  SdkConfig = schemas_exports3.objectWithoutOptionalProperties({
81380
81403
  isAuthMandatory: schemas_exports3.boolean(),
81381
81404
  hasStreamingEndpoints: schemas_exports3.boolean(),
81382
81405
  hasPaginatedEndpoints: schemas_exports3.boolean(),
81383
81406
  hasFileDownloadEndpoints: schemas_exports3.boolean(),
81384
- platformHeaders: PlatformHeaders
81407
+ platformHeaders: PlatformHeaders,
81408
+ idempotencyKeyGeneration: IdempotencyKeyGeneration.optional()
81385
81409
  });
81386
81410
  }
81387
81411
  });
@@ -81521,6 +81545,7 @@ var init_types92 = __esm({
81521
81545
  init_ExampleStyle2();
81522
81546
  init_GenerationMetadata2();
81523
81547
  init_HeaderApiVersionScheme2();
81548
+ init_IdempotencyKeyGeneration2();
81524
81549
  init_IntermediateRepresentation2();
81525
81550
  init_InvocationSource2();
81526
81551
  init_Package2();
@@ -81549,6 +81574,7 @@ __export(ir_exports4, {
81549
81574
  ExampleStyle: () => ExampleStyle2,
81550
81575
  GenerationMetadata: () => GenerationMetadata,
81551
81576
  HeaderApiVersionScheme: () => HeaderApiVersionScheme,
81577
+ IdempotencyKeyGeneration: () => IdempotencyKeyGeneration,
81552
81578
  IntermediateRepresentation: () => IntermediateRepresentation,
81553
81579
  InvocationSource: () => InvocationSource2,
81554
81580
  Package: () => Package,
@@ -82851,6 +82877,7 @@ __export(serialization_exports2, {
82851
82877
  HttpResponse: () => HttpResponse,
82852
82878
  HttpResponseBody: () => HttpResponseBody2,
82853
82879
  HttpService: () => HttpService,
82880
+ IdempotencyKeyGeneration: () => IdempotencyKeyGeneration,
82854
82881
  InferredAuthScheme: () => InferredAuthScheme,
82855
82882
  InferredAuthSchemeTokenEndpoint: () => InferredAuthSchemeTokenEndpoint,
82856
82883
  InferredAuthenticatedRequestHeader: () => InferredAuthenticatedRequestHeader2,
@@ -83903,6 +83930,30 @@ function getUserAgentTemplateFromGeneratorConfig(generatorInvocation) {
83903
83930
  }
83904
83931
  return void 0;
83905
83932
  }
83933
+ function parseIdempotencyKeyMethods(value2) {
83934
+ if (!Array.isArray(value2)) {
83935
+ return DEFAULT_IDEMPOTENCY_KEY_METHODS;
83936
+ }
83937
+ const methods = value2.filter((entry) => typeof entry === "string").map((entry) => entry.toUpperCase()).filter((entry) => ALL_HTTP_METHODS.has(entry));
83938
+ return methods.length > 0 ? methods : DEFAULT_IDEMPOTENCY_KEY_METHODS;
83939
+ }
83940
+ function getIdempotencyKeyGenerationFromGeneratorConfig(generatorInvocation) {
83941
+ if (typeof generatorInvocation.raw?.config !== "object" || generatorInvocation.raw?.config === null) {
83942
+ return void 0;
83943
+ }
83944
+ const value2 = generatorInvocation.raw.config["auto-generate-idempotency-key"];
83945
+ if (value2 === true) {
83946
+ return { headerName: DEFAULT_IDEMPOTENCY_KEY_HEADER, methods: DEFAULT_IDEMPOTENCY_KEY_METHODS };
83947
+ }
83948
+ if (typeof value2 === "object" && value2 !== null) {
83949
+ const headerName = value2["header-name"];
83950
+ return {
83951
+ headerName: typeof headerName === "string" ? headerName : DEFAULT_IDEMPOTENCY_KEY_HEADER,
83952
+ methods: parseIdempotencyKeyMethods(value2["methods"])
83953
+ };
83954
+ }
83955
+ return void 0;
83956
+ }
83906
83957
  function stripCliConfigKeys(config5) {
83907
83958
  if (typeof config5 !== "object" || config5 === null) {
83908
83959
  return config5;
@@ -84068,13 +84119,16 @@ function getRegistryName(language) {
84068
84119
  return language;
84069
84120
  }
84070
84121
  }
84071
- var CLI_ONLY_CONFIG_KEYS, REGISTRY_TIMEOUT_MS;
84122
+ var DEFAULT_IDEMPOTENCY_KEY_HEADER, DEFAULT_IDEMPOTENCY_KEY_METHODS, ALL_HTTP_METHODS, CLI_ONLY_CONFIG_KEYS, REGISTRY_TIMEOUT_MS;
84072
84123
  var init_checkVersionExists = __esm({
84073
84124
  "../../commons/api-workspace-commons/lib/checkVersionExists.js"() {
84074
84125
  "use strict";
84075
84126
  init_lib4();
84076
84127
  init_lib6();
84077
- CLI_ONLY_CONFIG_KEYS = /* @__PURE__ */ new Set(["user-agent"]);
84128
+ DEFAULT_IDEMPOTENCY_KEY_HEADER = "Idempotency-Key";
84129
+ DEFAULT_IDEMPOTENCY_KEY_METHODS = ["POST", "PUT"];
84130
+ ALL_HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
84131
+ CLI_ONLY_CONFIG_KEYS = /* @__PURE__ */ new Set(["user-agent", "auto-generate-idempotency-key"]);
84078
84132
  REGISTRY_TIMEOUT_MS = 5e3;
84079
84133
  }
84080
84134
  });
@@ -276640,7 +276694,7 @@ var init_getIrGenerationSettings = __esm({
276640
276694
  });
276641
276695
 
276642
276696
  // ../generation/ir-generator/lib/generateIntermediateRepresentation.js
276643
- function generateIntermediateRepresentation({ workspace, generationLanguage, keywords: keywords3, smartCasing, exampleGeneration, audiences, readme, packageName, userAgentTemplate, organization, version: version7, context: context3, fdrApiDefinitionId, sourceResolver, disableDynamicExamples, dynamicGeneratorConfig, generationMetadata }) {
276697
+ function generateIntermediateRepresentation({ workspace, generationLanguage, keywords: keywords3, smartCasing, exampleGeneration, audiences, readme, packageName, userAgentTemplate, idempotencyKeyGeneration, organization, version: version7, context: context3, fdrApiDefinitionId, sourceResolver, disableDynamicExamples, dynamicGeneratorConfig, generationMetadata }) {
276644
276698
  const irSettings = getIrGenerationSettings({ workspace });
276645
276699
  const casingsGenerator = constructCasingsGenerator({ generationLanguage, keywords: keywords3, smartCasing });
276646
276700
  const irGraph = new IrGraph(audiences);
@@ -276978,6 +277032,7 @@ function generateIntermediateRepresentation({ workspace, generationLanguage, key
276978
277032
  hasStreamingEndpoints,
276979
277033
  hasPaginatedEndpoints,
276980
277034
  hasFileDownloadEndpoints,
277035
+ idempotencyKeyGeneration,
276981
277036
  platformHeaders: {
276982
277037
  language: "X-Fern-Language",
276983
277038
  sdkName: "X-Fern-SDK-Name",
@@ -342420,6 +342475,7 @@ var init_AbstractSpecConverter = __esm({
342420
342475
  hasPaginatedEndpoints: false,
342421
342476
  hasStreamingEndpoints: false,
342422
342477
  isAuthMandatory: true,
342478
+ idempotencyKeyGeneration: void 0,
342423
342479
  platformHeaders: {
342424
342480
  language: "",
342425
342481
  sdkName: "",
@@ -565816,7 +565872,8 @@ var require_AutoVersionStep = __commonJS({
565816
565872
  }
565817
565873
  async handleNormalFlow(params2) {
565818
565874
  const { prepared, service, language, mappedMagicVersion, previousGenerationSha } = params2;
565819
- const rawDiff = this.gitDiff(previousGenerationSha, prepared.currentGenerationSha);
565875
+ const diffBase = this.resolveReachableGenerationBase(previousGenerationSha, prepared.currentGenerationSha);
565876
+ const rawDiff = diffBase != null ? this.safeGitDiff(diffBase, prepared.currentGenerationSha) : "";
565820
565877
  const previousVersion = await this.resolvePreviousVersion({
565821
565878
  service,
565822
565879
  rawDiff,
@@ -566213,6 +566270,91 @@ var require_AutoVersionStep = __commonJS({
566213
566270
  maxBuffer: 256 * 1024 * 1024
566214
566271
  });
566215
566272
  }
566273
+ /**
566274
+ * Resolves a reachable base commit for the autoversion diff.
566275
+ *
566276
+ * `recordedSha` (the previous generation from replay.lock) is preferred when it exists
566277
+ * in this clone. When it doesn't — e.g. the signed-commit push recreated the
566278
+ * [fern-generated] commit under a new SHA, or the branch was squash-merged — we re-anchor
566279
+ * on the most recent reachable [fern-generated] commit in history. Returns null when no
566280
+ * generation baseline is reachable at all, in which case the caller resolves the previous
566281
+ * version from metadata/git-tags and still rewrites the placeholder.
566282
+ */
566283
+ resolveReachableGenerationBase(recordedSha, currentGenerationSha) {
566284
+ if (this.commitExists(recordedSha)) {
566285
+ return recordedSha;
566286
+ }
566287
+ this.logger.warn(`AutoVersionStep: recorded previous generation ${recordedSha.slice(0, 7)} is unreachable in this clone; deriving the baseline from history.`);
566288
+ const derived = this.findPreviousGenerationFromHistory(currentGenerationSha);
566289
+ if (derived != null) {
566290
+ this.logger.info(`AutoVersionStep: re-anchored autoversion baseline on ${derived.slice(0, 7)}.`);
566291
+ return derived;
566292
+ }
566293
+ this.logger.warn("AutoVersionStep: no reachable [fern-generated] baseline found; falling back to metadata/git-tags.");
566294
+ return null;
566295
+ }
566296
+ commitExists(sha) {
566297
+ if (!/^[0-9a-f]{7,40}$/.test(sha)) {
566298
+ return false;
566299
+ }
566300
+ try {
566301
+ (0, child_process_1.execFileSync)("git", ["cat-file", "-e", `${sha}^{commit}`], {
566302
+ cwd: this.outputDir,
566303
+ stdio: "pipe"
566304
+ });
566305
+ return true;
566306
+ } catch {
566307
+ return false;
566308
+ }
566309
+ }
566310
+ /**
566311
+ * Walks first-parent history from the current generation commit and returns the most
566312
+ * recent prior [fern-generated] commit — the reachable equivalent of replay.lock's
566313
+ * recorded baseline. Mirrors @fern-api/replay's `findPreviousGenerationFromHistory`.
566314
+ */
566315
+ findPreviousGenerationFromHistory(currentGenerationSha) {
566316
+ const start2 = this.commitExists(currentGenerationSha) ? currentGenerationSha : "HEAD";
566317
+ let log4;
566318
+ try {
566319
+ log4 = (0, child_process_1.execFileSync)("git", ["log", "--first-parent", "--format=%H%x00%s", start2], {
566320
+ cwd: this.outputDir,
566321
+ encoding: "utf-8",
566322
+ stdio: "pipe",
566323
+ maxBuffer: 64 * 1024 * 1024
566324
+ });
566325
+ } catch (error50) {
566326
+ this.logger.debug(`AutoVersionStep: git log history walk failed (${String(error50)}); no baseline derived.`);
566327
+ return null;
566328
+ }
566329
+ for (const line of log4.split("\n")) {
566330
+ if (line.trim().length === 0) {
566331
+ continue;
566332
+ }
566333
+ const [sha, subject = ""] = line.split("\0");
566334
+ if (sha == null || sha === currentGenerationSha) {
566335
+ continue;
566336
+ }
566337
+ if (subject.startsWith("[fern-generated]")) {
566338
+ return sha;
566339
+ }
566340
+ }
566341
+ return null;
566342
+ }
566343
+ /**
566344
+ * `gitDiff` that degrades to an empty diff instead of throwing. Both endpoints are
566345
+ * expected to be reachable (the base is resolved via resolveReachableGenerationBase and
566346
+ * `to` is this run's freshly-created HEAD), but we never want a `git diff` failure to
566347
+ * abort autoversion and leave the magic placeholder in the shipped SDK — the empty diff
566348
+ * routes version resolution to baseVersion/metadata/git-tags, which still rewrites it.
566349
+ */
566350
+ safeGitDiff(from4, to2) {
566351
+ try {
566352
+ return this.gitDiff(from4, to2);
566353
+ } catch (error50) {
566354
+ this.logger.warn(`AutoVersionStep: git diff ${from4.slice(0, 7)}..${to2.slice(0, 7)} failed (${error50 instanceof Error ? error50.message : String(error50)}); proceeding with an empty diff.`);
566355
+ return "";
566356
+ }
566357
+ }
566216
566358
  gitDiff(from4, to2) {
566217
566359
  return (0, child_process_1.execFileSync)("git", ["diff", from4, to2, "--", ".", ":(exclude).fern/metadata.json"], {
566218
566360
  cwd: this.outputDir,
@@ -689087,7 +689229,7 @@ var AccessTokenPosthogManager = class {
689087
689229
  properties: {
689088
689230
  ...event,
689089
689231
  ...event.properties,
689090
- version: "5.23.3-1306-g97e4764e29d",
689232
+ version: "5.23.3-1314-ge04cf20354b",
689091
689233
  usingAccessToken: true,
689092
689234
  ...getRunIdProperties()
689093
689235
  }
@@ -689153,7 +689295,7 @@ var UserPosthogManager = class {
689153
689295
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
689154
689296
  event: "CLI",
689155
689297
  properties: {
689156
- version: "5.23.3-1306-g97e4764e29d",
689298
+ version: "5.23.3-1314-ge04cf20354b",
689157
689299
  ...event,
689158
689300
  ...event.properties,
689159
689301
  usingAccessToken: false,
@@ -870254,7 +870396,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
870254
870396
  var LOGS_FOLDER_NAME = "logs";
870255
870397
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
870256
870398
  function getCliSource() {
870257
- const version7 = "5.23.3-1306-g97e4764e29d";
870399
+ const version7 = "5.23.3-1314-ge04cf20354b";
870258
870400
  return `cli@${version7}`;
870259
870401
  }
870260
870402
  var DebugLogger = class {
@@ -900060,6 +900202,7 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
900060
900202
  }
900061
900203
  const effectiveIrVersion = resolvedVersion != null && (0, import_autoversion.isAutoVersion)(resolvedVersion) ? import_autoversion.MAGIC_VERSION : resolvedVersion;
900062
900204
  const userAgentTemplate = getUserAgentTemplateFromGeneratorConfig(generatorInvocation);
900205
+ const idempotencyKeyGeneration = getIdempotencyKeyGenerationFromGeneratorConfig(generatorInvocation);
900063
900206
  const ir3 = generateIntermediateRepresentation({
900064
900207
  workspace,
900065
900208
  generationLanguage: generatorInvocation.language,
@@ -900074,6 +900217,7 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
900074
900217
  readme,
900075
900218
  packageName,
900076
900219
  userAgentTemplate,
900220
+ idempotencyKeyGeneration,
900077
900221
  organization,
900078
900222
  version: effectiveIrVersion,
900079
900223
  context: interactiveTaskContext,
@@ -902813,7 +902957,7 @@ var LegacyDocsPublisher = class {
902813
902957
  previewId,
902814
902958
  disableTemplates: void 0,
902815
902959
  skipUpload,
902816
- cliVersion: "5.23.3-1306-g97e4764e29d",
902960
+ cliVersion: "5.23.3-1314-ge04cf20354b",
902817
902961
  loginCommand: "fern auth login"
902818
902962
  });
902819
902963
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -955671,6 +955815,7 @@ init_lib26();
955671
955815
  init_lib22();
955672
955816
  async function getIntermediateRepresentation({ workspace, audiences, generatorInvocation, context: context3, irVersionOverride, version: version7, packageName, userAgentTemplate, organization, sourceConfig, includeOptionalRequestPropertyExamples, ir: ir3 }) {
955673
955817
  const resolvedUserAgentTemplate = userAgentTemplate ?? getUserAgentTemplateFromGeneratorConfig(generatorInvocation);
955818
+ const idempotencyKeyGeneration = getIdempotencyKeyGenerationFromGeneratorConfig(generatorInvocation);
955674
955819
  const intermediateRepresentation = ir3 ?? generateIntermediateRepresentation({
955675
955820
  workspace,
955676
955821
  audiences,
@@ -955685,6 +955830,7 @@ async function getIntermediateRepresentation({ workspace, audiences, generatorIn
955685
955830
  version: version7,
955686
955831
  packageName,
955687
955832
  userAgentTemplate: resolvedUserAgentTemplate,
955833
+ idempotencyKeyGeneration,
955688
955834
  organization,
955689
955835
  context: context3,
955690
955836
  sourceResolver: new SourceResolverImpl(context3, workspace),
@@ -957009,6 +957155,7 @@ async function runLocalGenerationForWorkspace({ token, projectConfig, workspace,
957009
957155
  });
957010
957156
  const packageName = getPackageNameFromGeneratorConfig(generatorInvocation);
957011
957157
  const userAgentTemplate = getUserAgentTemplateFromGeneratorConfig(generatorInvocation);
957158
+ const idempotencyKeyGeneration = getIdempotencyKeyGenerationFromGeneratorConfig(generatorInvocation);
957012
957159
  version7 = version7 ?? await computeSemanticVersion({ packageName, generatorInvocation });
957013
957160
  const irLanguage = generatorInvocation.language ?? (0, import_autoversion4.extractLanguageFromGeneratorName)(generatorInvocation.name);
957014
957161
  const effectiveIrVersion = version7 != null && (0, import_autoversion4.isAutoVersion)(version7) ? (0, import_autoversion4.mapMagicVersionForLanguage)(import_autoversion4.MAGIC_VERSION, irLanguage) : version7;
@@ -957026,6 +957173,7 @@ async function runLocalGenerationForWorkspace({ token, projectConfig, workspace,
957026
957173
  version: effectiveIrVersion,
957027
957174
  packageName,
957028
957175
  userAgentTemplate,
957176
+ idempotencyKeyGeneration,
957029
957177
  organization: projectConfig.organization,
957030
957178
  context: context3,
957031
957179
  sourceResolver: new SourceResolverImpl(context3, fernWorkspace),
@@ -957568,6 +957716,7 @@ var GenerationRunner = class {
957568
957716
  version: outputVersionOverride,
957569
957717
  packageName: generators_yml_exports.getPackageName({ generatorInvocation }),
957570
957718
  userAgentTemplate: getUserAgentTemplateFromGeneratorConfig(generatorInvocation),
957719
+ idempotencyKeyGeneration: getIdempotencyKeyGenerationFromGeneratorConfig(generatorInvocation),
957571
957720
  organization,
957572
957721
  context: context3,
957573
957722
  sourceResolver: new SourceResolverImpl(context3, workspace),
@@ -969156,7 +969305,7 @@ function getAutomationContextFromEnv() {
969156
969305
  config_branch: process.env.FERN_CONFIG_BRANCH,
969157
969306
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
969158
969307
  trigger: process.env.GITHUB_EVENT_NAME,
969159
- cli_version: "5.23.3-1306-g97e4764e29d"
969308
+ cli_version: "5.23.3-1314-ge04cf20354b"
969160
969309
  };
969161
969310
  }
969162
969311
  function isAutomationMode() {
@@ -969988,7 +970137,7 @@ var CliContext = class _CliContext {
969988
970137
  if (false) {
969989
970138
  this.logger.error("CLI_VERSION is not defined");
969990
970139
  }
969991
- return "5.23.3-1306-g97e4764e29d";
970140
+ return "5.23.3-1314-ge04cf20354b";
969992
970141
  }
969993
970142
  getCliName() {
969994
970143
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-1306-g97e4764e29d",
2
+ "version": "5.23.3-1314-ge04cf20354b",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",