@fern-api/fern-api-dev 5.74.0 → 5.74.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 +184 -19
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -153418,12 +153418,23 @@ function convertDiscriminatedOneOf({ nameOverride, generatedName, title: title2,
153418
153418
  const discriminantNameOverride = getExtension(discriminator, FernOpenAPIExtension.FERN_PROPERTY_NAME);
153419
153419
  const discriminatorContext = resolveDiscriminatorContext({ discriminator, context: context3 });
153420
153420
  const unionSubTypes = Object.fromEntries(Object.entries(discriminator.mapping ?? {}).map(([discriminantValue, schema]) => {
153421
- const subtypeReference = convertReferenceObject({
153422
- $ref: schema
153423
- }, false, false, context3, [schema], encoding, source2, namespace);
153424
- context3.markReferencedByDiscriminatedUnion({
153425
- $ref: schema
153426
- }, discriminant22, 1);
153421
+ const ref2 = { $ref: schema };
153422
+ const resolvedSchema = context3.resolveSchemaReference(ref2);
153423
+ const nestedVariants = resolvedSchema.oneOf ?? resolvedSchema.anyOf;
153424
+ if (nestedVariants != null && nestedVariants.length > 0 && resolvedSchema.discriminator == null && resolvedSchema.properties == null && resolvedSchema.allOf == null) {
153425
+ const mergedSchema = mergeOneOfVariantsIntoObject({
153426
+ variants: nestedVariants,
153427
+ context: context3,
153428
+ discriminant: discriminant22
153429
+ });
153430
+ if (mergedSchema != null) {
153431
+ const variantSchema = convertSchemaObject(mergedSchema, false, false, context3, [...breadcrumbs, discriminantValue], encoding, source2, namespace, /* @__PURE__ */ new Set([discriminant22]));
153432
+ context3.markReferencedByDiscriminatedUnion(ref2, discriminant22, 1);
153433
+ return [discriminantValue, variantSchema];
153434
+ }
153435
+ }
153436
+ const subtypeReference = convertReferenceObject(ref2, false, false, context3, [schema], encoding, source2, namespace);
153437
+ context3.markReferencedByDiscriminatedUnion(ref2, discriminant22, 1);
153427
153438
  return [discriminantValue, subtypeReference];
153428
153439
  }));
153429
153440
  const convertedProperties = Object.entries(properties7).filter(([propertyName]) => {
@@ -153638,6 +153649,74 @@ function getAllRequiredPropertyNames({ schema, context: context3, visited }) {
153638
153649
  }
153639
153650
  return result;
153640
153651
  }
153652
+ function collectAllRawProperties({ schema, context: context3, visited }) {
153653
+ const properties7 = {};
153654
+ const required6 = /* @__PURE__ */ new Set();
153655
+ let resolved;
153656
+ if (isReferenceObject(schema)) {
153657
+ if (visited.has(schema.$ref)) {
153658
+ return { properties: properties7, required: required6 };
153659
+ }
153660
+ visited.add(schema.$ref);
153661
+ resolved = context3.resolveSchemaReference(schema);
153662
+ } else {
153663
+ resolved = schema;
153664
+ }
153665
+ for (const allOfElement of resolved.allOf ?? []) {
153666
+ const child = collectAllRawProperties({ schema: allOfElement, context: context3, visited: new Set(visited) });
153667
+ for (const [name2, prop] of Object.entries(child.properties)) {
153668
+ if (!(name2 in properties7)) {
153669
+ properties7[name2] = prop;
153670
+ }
153671
+ }
153672
+ for (const name2 of child.required) {
153673
+ required6.add(name2);
153674
+ }
153675
+ }
153676
+ for (const [name2, prop] of Object.entries(resolved.properties ?? {})) {
153677
+ if (!(name2 in properties7)) {
153678
+ properties7[name2] = prop;
153679
+ }
153680
+ }
153681
+ for (const name2 of resolved.required ?? []) {
153682
+ required6.add(name2);
153683
+ }
153684
+ return { properties: properties7, required: required6 };
153685
+ }
153686
+ function mergeOneOfVariantsIntoObject({ variants, context: context3, discriminant: discriminant22 }) {
153687
+ const variantData = [];
153688
+ for (const variant of variants) {
153689
+ const resolved = isReferenceObject(variant) ? context3.resolveSchemaReference(variant) : variant;
153690
+ if (resolved.properties == null && resolved.allOf == null && resolved.type !== "object") {
153691
+ return void 0;
153692
+ }
153693
+ const collected = collectAllRawProperties({ schema: variant, context: context3, visited: /* @__PURE__ */ new Set() });
153694
+ variantData.push(collected);
153695
+ }
153696
+ const mergedProperties = {};
153697
+ const propertyPresenceCount = {};
153698
+ const requiredInAllCount = {};
153699
+ for (const { properties: properties7, required: required6 } of variantData) {
153700
+ for (const [name2, prop] of Object.entries(properties7)) {
153701
+ if (name2 === discriminant22) {
153702
+ continue;
153703
+ }
153704
+ if (!(name2 in mergedProperties)) {
153705
+ mergedProperties[name2] = prop;
153706
+ }
153707
+ propertyPresenceCount[name2] = (propertyPresenceCount[name2] ?? 0) + 1;
153708
+ if (required6.has(name2)) {
153709
+ requiredInAllCount[name2] = (requiredInAllCount[name2] ?? 0) + 1;
153710
+ }
153711
+ }
153712
+ }
153713
+ const mergedRequired = Object.keys(mergedProperties).filter((name2) => propertyPresenceCount[name2] === variants.length && requiredInAllCount[name2] === variants.length);
153714
+ return {
153715
+ type: "object",
153716
+ properties: mergedProperties,
153717
+ required: mergedRequired.length > 0 ? mergedRequired : void 0
153718
+ };
153719
+ }
153641
153720
  var init_convertDiscriminatedOneOf = __esm({
153642
153721
  "../api-importers/openapi/openapi-ir-parser/lib/schema/convertDiscriminatedOneOf.js"() {
153643
153722
  "use strict";
@@ -573335,9 +573414,9 @@ var require_diff3 = __commonJS({
573335
573414
  }
573336
573415
  });
573337
573416
 
573338
- // ../../../node_modules/.pnpm/@fern-api+replay@0.19.0/node_modules/@fern-api/replay/dist/index.cjs
573417
+ // ../../../node_modules/.pnpm/@fern-api+replay@0.19.1/node_modules/@fern-api/replay/dist/index.cjs
573339
573418
  var require_dist24 = __commonJS({
573340
- "../../../node_modules/.pnpm/@fern-api+replay@0.19.0/node_modules/@fern-api/replay/dist/index.cjs"(exports2, module4) {
573419
+ "../../../node_modules/.pnpm/@fern-api+replay@0.19.1/node_modules/@fern-api/replay/dist/index.cjs"(exports2, module4) {
573341
573420
  "use strict";
573342
573421
  var __defProp5 = Object.defineProperty;
573343
573422
  var __getOwnPropDesc4 = Object.getOwnPropertyDescriptor;
@@ -575379,6 +575458,47 @@ var require_dist24 = __commonJS({
575379
575458
  }
575380
575459
  var import_promises218 = require("fs/promises");
575381
575460
  var import_node_path45 = require("path");
575461
+ var AUTOVERSION_PLACEHOLDERS = [
575462
+ "v0.0.0-fern-placeholder",
575463
+ // Go -- a superstring of the default; check first
575464
+ "0.0.0-fern-placeholder",
575465
+ // TS/Java/C#/Ruby/PHP/Rust/default
575466
+ "0.0.0.dev0"
575467
+ // Python (PEP 440 -- Poetry rejects hyphens)
575468
+ ];
575469
+ var VERSION_TOKEN = /(?:v)?\d+\.\d+\.\d+[0-9A-Za-z.+-]*/g;
575470
+ var VERSION_MASK = "@@FERN_VERSION@@";
575471
+ function maskVersions(line) {
575472
+ return line.replace(VERSION_TOKEN, VERSION_MASK);
575473
+ }
575474
+ function containsPlaceholder(content5) {
575475
+ if (!content5) return false;
575476
+ return AUTOVERSION_PLACEHOLDERS.some((p6) => content5.includes(p6));
575477
+ }
575478
+ function remapManagedLines(genBase, target, theirs) {
575479
+ if (!containsPlaceholder(genBase)) return theirs;
575480
+ const managedMasks = /* @__PURE__ */ new Set();
575481
+ for (const line of genBase.split("\n")) {
575482
+ if (AUTOVERSION_PLACEHOLDERS.some((p6) => line.includes(p6))) managedMasks.add(maskVersions(line));
575483
+ }
575484
+ if (managedMasks.size === 0) return theirs;
575485
+ const targetByMask = /* @__PURE__ */ new Map();
575486
+ for (const line of target.split("\n")) {
575487
+ const mask2 = maskVersions(line);
575488
+ if (managedMasks.has(mask2) && !targetByMask.has(mask2)) targetByMask.set(mask2, line);
575489
+ }
575490
+ return theirs.split("\n").map((line) => {
575491
+ const mask2 = maskVersions(line);
575492
+ const replacement = managedMasks.has(mask2) ? targetByMask.get(mask2) : void 0;
575493
+ return replacement !== void 0 && replacement !== line ? replacement : line;
575494
+ }).join("\n");
575495
+ }
575496
+ function neutralizeAutoversionTheirs(genBase, theirs) {
575497
+ return remapManagedLines(genBase, genBase, theirs);
575498
+ }
575499
+ function alignAutoversionToOurs(genBase, ours, theirs) {
575500
+ return remapManagedLines(genBase, ours, theirs);
575501
+ }
575382
575502
  async function runMergeAndRecord(args) {
575383
575503
  const { plan, inputs, patch: patch5, accumulator } = args;
575384
575504
  const { resolvedPath, metadata, oursPath, ours } = inputs;
@@ -575409,11 +575529,13 @@ var require_dist24 = __commonJS({
575409
575529
  accumulator.recordMerge(resolvedPath, merged2.content, patch5.base_generation);
575410
575530
  return { file: resolvedPath, status: "merged", ...unreachableFlag };
575411
575531
  }
575412
- const merged = threeWayMerge(plan.mergeBase, ours, plan.theirs);
575532
+ const mergeBase = inputs.base != null ? alignAutoversionToOurs(inputs.base, ours, plan.mergeBase) : plan.mergeBase;
575533
+ const theirs = inputs.base != null ? alignAutoversionToOurs(inputs.base, ours, plan.theirs) : plan.theirs;
575534
+ const merged = threeWayMerge(mergeBase, ours, theirs);
575413
575535
  await (0, import_promises218.mkdir)((0, import_node_path45.dirname)(oursPath), { recursive: true });
575414
575536
  await (0, import_promises218.writeFile)(oursPath, merged.content);
575415
575537
  if (merged.hasConflicts) {
575416
- accumulator.recordConflict(resolvedPath, plan.theirs, patch5.base_generation);
575538
+ accumulator.recordConflict(resolvedPath, theirs, patch5.base_generation);
575417
575539
  return {
575418
575540
  file: resolvedPath,
575419
575541
  status: "conflict",
@@ -575422,7 +575544,7 @@ var require_dist24 = __commonJS({
575422
575544
  conflictMetadata: metadata
575423
575545
  };
575424
575546
  }
575425
- accumulator.recordMerge(resolvedPath, plan.theirs, patch5.base_generation);
575547
+ accumulator.recordMerge(resolvedPath, theirs, patch5.base_generation);
575426
575548
  return {
575427
575549
  file: resolvedPath,
575428
575550
  status: "merged",
@@ -577186,7 +577308,9 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
577186
577308
  if (baseChanged) repointed++;
577187
577309
  continue;
577188
577310
  }
577189
- const diff2 = await this.git.exec(["diff", currentGenSha, "--", ...patch5.files]).catch(() => null);
577311
+ const rawDiff = await this.git.exec(["diff", currentGenSha, "--", ...patch5.files]).catch(() => null);
577312
+ const neutralizedRebase = rawDiff != null && containsPlaceholder(rawDiff) ? await this.computeAutoversionNeutralizedRebase(patch5.files, currentGenSha) : null;
577313
+ const diff2 = neutralizedRebase ? neutralizedRebase.diff : rawDiff;
577190
577314
  if (diff2 === null) continue;
577191
577315
  if (!diff2.trim()) {
577192
577316
  if (hasProtectedFiles) {
@@ -577242,7 +577366,7 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
577242
577366
  patch5.base_generation = currentGenSha;
577243
577367
  patch5.patch_content = diff2;
577244
577368
  patch5.content_hash = newContentHash;
577245
- const snapshot = await this.readSnapshotFromDisk(patch5.files);
577369
+ const snapshot = neutralizedRebase ? neutralizedRebase.snapshot : await this.readSnapshotFromDisk(patch5.files);
577246
577370
  const snapshotIsNonEmpty = Object.keys(snapshot).length > 0;
577247
577371
  if (snapshotIsNonEmpty) {
577248
577372
  patch5.theirs_snapshot = snapshot;
@@ -577282,6 +577406,47 @@ Patches absorbed by generator (${buckets.absorbed.length}):`;
577282
577406
  }
577283
577407
  return snapshot;
577284
577408
  }
577409
+ /**
577410
+ * Autoversion-aware replacement for the naive `git diff currentGen -- files`
577411
+ * + on-disk snapshot used when rebasing a cleanly-applied patch.
577412
+ *
577413
+ * The generation tree (BASE) still carries the placeholder on version lines
577414
+ * (autoversion runs after `[fern-generated]`), but the working tree holds
577415
+ * autoversion's resolved semver. A raw diff/snapshot would fold the
577416
+ * placeholder->semver swap into the customer's patch_content/theirs_snapshot,
577417
+ * pinning a stale version. This re-derives both against a version-neutralized
577418
+ * THEIRS so the pipeline-owned version line never enters the patch.
577419
+ *
577420
+ * Returns null when no file is under autoversion (fixed `--version`, i.e. no
577421
+ * placeholder in the generation tree) — callers keep their existing behavior.
577422
+ */
577423
+ async computeAutoversionNeutralizedRebase(files, currentGenSha) {
577424
+ const genByFile = /* @__PURE__ */ new Map();
577425
+ let anyPlaceholder = false;
577426
+ for (const file4 of files) {
577427
+ const gen = await this.git.showFile(currentGenSha, file4).catch(() => null);
577428
+ genByFile.set(file4, gen);
577429
+ if (containsPlaceholder(gen)) anyPlaceholder = true;
577430
+ }
577431
+ if (!anyPlaceholder) return null;
577432
+ const snapshot = {};
577433
+ const fragments = [];
577434
+ for (const file4 of files) {
577435
+ if (isBinaryFile(file4)) continue;
577436
+ const disk = await (0, import_promises610.readFile)((0, import_node_path92.join)(this.outputDir, file4), "utf-8").catch(() => null);
577437
+ if (disk == null) continue;
577438
+ const gen = genByFile.get(file4) ?? null;
577439
+ const neutralized = gen != null ? neutralizeAutoversionTheirs(gen, disk) : disk;
577440
+ snapshot[file4] = neutralized;
577441
+ if (gen == null) {
577442
+ fragments.push(synthesizeNewFileDiff(file4, neutralized));
577443
+ } else if (gen !== neutralized) {
577444
+ const fileDiff = await unifiedDiff(gen, neutralized, file4);
577445
+ if (fileDiff.trim()) fragments.push(fileDiff);
577446
+ }
577447
+ }
577448
+ return { diff: fragments.join(""), snapshot };
577449
+ }
577285
577450
  /**
577286
577451
  * Detects autoversion contamination — returns true when a
577287
577452
  * `[fern-autoversion]` commit between `fromSha` and `toSha` touched any
@@ -690812,7 +690977,7 @@ var AccessTokenPosthogManager = class {
690812
690977
  properties: {
690813
690978
  ...event,
690814
690979
  ...event.properties,
690815
- version: "5.74.0",
690980
+ version: "5.74.2",
690816
690981
  usingAccessToken: true,
690817
690982
  ...getRunIdProperties()
690818
690983
  }
@@ -690878,7 +691043,7 @@ var UserPosthogManager = class {
690878
691043
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
690879
691044
  event: "CLI",
690880
691045
  properties: {
690881
- version: "5.74.0",
691046
+ version: "5.74.2",
690882
691047
  ...event,
690883
691048
  ...event.properties,
690884
691049
  usingAccessToken: false,
@@ -871979,7 +872144,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
871979
872144
  var LOGS_FOLDER_NAME = "logs";
871980
872145
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
871981
872146
  function getCliSource() {
871982
- const version7 = "5.74.0";
872147
+ const version7 = "5.74.2";
871983
872148
  return `cli@${version7}`;
871984
872149
  }
871985
872150
  var DebugLogger = class {
@@ -904562,7 +904727,7 @@ var LegacyDocsPublisher = class {
904562
904727
  previewId,
904563
904728
  disableTemplates: void 0,
904564
904729
  skipUpload,
904565
- cliVersion: "5.74.0",
904730
+ cliVersion: "5.74.2",
904566
904731
  loginCommand: "fern auth login"
904567
904732
  });
904568
904733
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -971088,7 +971253,7 @@ function getAutomationContextFromEnv() {
971088
971253
  config_branch: process.env.FERN_CONFIG_BRANCH,
971089
971254
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
971090
971255
  trigger: process.env.GITHUB_EVENT_NAME,
971091
- cli_version: "5.74.0"
971256
+ cli_version: "5.74.2"
971092
971257
  };
971093
971258
  }
971094
971259
  function isAutomationMode() {
@@ -971920,7 +972085,7 @@ var CliContext = class _CliContext {
971920
972085
  if (false) {
971921
972086
  this.logger.error("CLI_VERSION is not defined");
971922
972087
  }
971923
- return "5.74.0";
972088
+ return "5.74.2";
971924
972089
  }
971925
972090
  getCliName() {
971926
972091
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.74.0",
2
+ "version": "5.74.2",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",