@fern-api/fern-api-dev 4.107.1 → 4.107.2-1-g488c64ae1ff

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 +109 -22
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -477450,7 +477450,8 @@ var USER_ENVIRONMENT_ERRNOS = /* @__PURE__ */ new Set([
477450
477450
  "EROFS",
477451
477451
  "EMFILE",
477452
477452
  "ENFILE",
477453
- "EBUSY"
477453
+ "EBUSY",
477454
+ "EADDRINUSE"
477454
477455
  ]);
477455
477456
  var NETWORK_ERRNOS = /* @__PURE__ */ new Set([
477456
477457
  "ENOTFOUND",
@@ -543610,6 +543611,7 @@ function parseVariantOverlays(variants) {
543610
543611
  }
543611
543612
 
543612
543613
  // ../configuration-loader/lib/fern-config-json/loadProjectConfig.js
543614
+ init_lib4();
543613
543615
  init_lib6();
543614
543616
  var import_promises15 = require("fs/promises");
543615
543617
 
@@ -543624,7 +543626,15 @@ var ProjectConfigSchema = external_exports2.strictObject({
543624
543626
  async function loadProjectConfig({ directory, context: context3 }) {
543625
543627
  const pathToConfig = join8(directory, RelativeFilePath2.of(PROJECT_CONFIG_FILENAME));
543626
543628
  const projectConfigStr = await (0, import_promises15.readFile)(pathToConfig);
543627
- const projectConfigParsed = JSON.parse(projectConfigStr.toString());
543629
+ let projectConfigParsed;
543630
+ try {
543631
+ projectConfigParsed = JSON.parse(projectConfigStr.toString());
543632
+ } catch (error50) {
543633
+ throw new CliError({
543634
+ message: `Failed to parse ${PROJECT_CONFIG_FILENAME}: ${extractErrorMessage(error50)}`,
543635
+ code: CliError.Code.ParseError
543636
+ });
543637
+ }
543628
543638
  const rawProjectConfig = await validateSchema({
543629
543639
  schema: ProjectConfigSchema,
543630
543640
  value: projectConfigParsed,
@@ -599508,6 +599518,9 @@ async function parseOpenAPI({ absolutePathToOpenAPI, absolutePathToOpenAPIOverri
599508
599518
  `Continuing without full reference resolution.`
599509
599519
  ].join("\n"));
599510
599520
  }
599521
+ if (circularRefs.length > 0) {
599522
+ breakCircularRefCycles(document4, circularRefs);
599523
+ }
599511
599524
  return document4;
599512
599525
  }
599513
599526
  throw error50;
@@ -599521,6 +599534,50 @@ async function readAndParseFile2(absoluteFilePath) {
599521
599534
  }
599522
599535
  return jsYaml.load(contents);
599523
599536
  }
599537
+ function breakCircularRefCycles(document4, circularRefs) {
599538
+ if (typeof document4 !== "object" || document4 == null) {
599539
+ return;
599540
+ }
599541
+ const backEdgeRefs = /* @__PURE__ */ new Set();
599542
+ for (const info of circularRefs) {
599543
+ if (info.ref.startsWith("#/")) {
599544
+ backEdgeRefs.add(info.ref);
599545
+ }
599546
+ }
599547
+ replaceCircularRefs(document4, backEdgeRefs);
599548
+ }
599549
+ function replaceCircularRefs(obj, targets2) {
599550
+ if (typeof obj !== "object" || obj == null) {
599551
+ return;
599552
+ }
599553
+ if (Array.isArray(obj)) {
599554
+ for (let i9 = 0; i9 < obj.length; i9++) {
599555
+ const item = obj[i9];
599556
+ if (isCircularRefObject(item, targets2)) {
599557
+ obj[i9] = { type: "object", "x-fern-circular-ref": true };
599558
+ } else {
599559
+ replaceCircularRefs(item, targets2);
599560
+ }
599561
+ }
599562
+ return;
599563
+ }
599564
+ const record22 = obj;
599565
+ for (const key2 of Object.keys(record22)) {
599566
+ const value2 = record22[key2];
599567
+ if (isCircularRefObject(value2, targets2)) {
599568
+ record22[key2] = { type: "object", "x-fern-circular-ref": true };
599569
+ } else {
599570
+ replaceCircularRefs(value2, targets2);
599571
+ }
599572
+ }
599573
+ }
599574
+ function isCircularRefObject(value2, targets2) {
599575
+ if (typeof value2 !== "object" || value2 == null || Array.isArray(value2)) {
599576
+ return false;
599577
+ }
599578
+ const record22 = value2;
599579
+ return typeof record22.$ref === "string" && targets2.has(record22.$ref);
599580
+ }
599524
599581
 
599525
599582
  // ../workspace/lazy-fern-workspace/lib/utils/resolveDescriptionMarkdownRefs.js
599526
599583
  init_lib4();
@@ -612723,6 +612780,16 @@ function collapseSpecBooleanSetting(specs, getter) {
612723
612780
  }
612724
612781
  return values2.every((v9) => v9 == null || v9 === true);
612725
612782
  }
612783
+ function toRelativePath(raw, field5) {
612784
+ try {
612785
+ return RelativeFilePath2.of(raw);
612786
+ } catch {
612787
+ throw new CliError({
612788
+ message: `"${field5}: ${raw}" must be a relative path, not an absolute one.`,
612789
+ code: CliError.Code.ConfigError
612790
+ });
612791
+ }
612792
+ }
612726
612793
  function convertRemoveDiscriminantsFromSchemas(specs) {
612727
612794
  if (specs.every((spec) => spec.settings?.removeDiscriminantsFromSchemas === generators_yml_exports.RemoveDiscriminantsFromSchemas.Never)) {
612728
612795
  return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
@@ -613118,20 +613185,20 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
613118
613185
  const specs = [];
613119
613186
  for (const spec of specsOverride) {
613120
613187
  if (generators_yml_exports.isOpenApiSpecSchema(spec)) {
613121
- const absoluteFilepath = join8(this.absoluteFilePath, RelativeFilePath2.of(spec.openapi));
613188
+ const absoluteFilepath = join8(this.absoluteFilePath, toRelativePath(spec.openapi, "openapi"));
613122
613189
  let absoluteFilepathToOverrides;
613123
613190
  const specOverridePaths = [];
613124
613191
  if (spec.overrides != null) {
613125
613192
  if (Array.isArray(spec.overrides)) {
613126
- specOverridePaths.push(...spec.overrides.map((override) => join8(this.absoluteFilePath, RelativeFilePath2.of(override))));
613193
+ specOverridePaths.push(...spec.overrides.map((override) => join8(this.absoluteFilePath, toRelativePath(override, "overrides"))));
613127
613194
  } else {
613128
- specOverridePaths.push(join8(this.absoluteFilePath, RelativeFilePath2.of(spec.overrides)));
613195
+ specOverridePaths.push(join8(this.absoluteFilePath, toRelativePath(spec.overrides, "overrides")));
613129
613196
  }
613130
613197
  }
613131
613198
  if (specOverridePaths.length > 0) {
613132
613199
  absoluteFilepathToOverrides = specOverridePaths.length === 1 ? specOverridePaths[0] : specOverridePaths;
613133
613200
  }
613134
- const absoluteFilepathToOverlays = spec.overlays ? join8(this.absoluteFilePath, RelativeFilePath2.of(spec.overlays)) : void 0;
613201
+ const absoluteFilepathToOverlays = spec.overlays ? join8(this.absoluteFilePath, toRelativePath(spec.overlays, "overlays")) : void 0;
613135
613202
  const openApiSpec = {
613136
613203
  type: "openapi",
613137
613204
  absoluteFilepath,
@@ -621305,7 +621372,7 @@ var AccessTokenPosthogManager = class {
621305
621372
  properties: {
621306
621373
  ...event,
621307
621374
  ...event.properties,
621308
- version: "4.107.1",
621375
+ version: "4.107.2-1-g488c64ae1ff",
621309
621376
  usingAccessToken: true
621310
621377
  }
621311
621378
  });
@@ -621359,7 +621426,7 @@ var UserPosthogManager = class {
621359
621426
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
621360
621427
  event: "CLI",
621361
621428
  properties: {
621362
- version: "4.107.1",
621429
+ version: "4.107.2-1-g488c64ae1ff",
621363
621430
  ...event,
621364
621431
  ...event.properties,
621365
621432
  usingAccessToken: false,
@@ -799353,7 +799420,10 @@ var DocsDefinitionResolver = class {
799353
799420
  }
799354
799421
  } catch (error50) {
799355
799422
  this.taskContext.logger.error(`Failed to parse ${relativePath}: ${extractErrorMessage(error50)}`);
799356
- throw error50;
799423
+ throw new CliError({
799424
+ message: `Failed to parse markdown file ${relativePath}: ${extractErrorMessage(error50)}`,
799425
+ code: CliError.Code.ParseError
799426
+ });
799357
799427
  }
799358
799428
  }
799359
799429
  const imageParseTime = performance.now() - imageParseStart;
@@ -833002,7 +833072,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
833002
833072
  var LOGS_FOLDER_NAME = "logs";
833003
833073
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
833004
833074
  function getCliSource() {
833005
- const version7 = "4.107.1";
833075
+ const version7 = "4.107.2-1-g488c64ae1ff";
833006
833076
  return `cli@${version7}`;
833007
833077
  }
833008
833078
  var DebugLogger = class {
@@ -834025,10 +834095,19 @@ async function getPreviewDocsDefinition({ domain: domain3, project, context: con
834025
834095
  absolutePathToFernFolder: docsWorkspace.absoluteFilePath,
834026
834096
  absolutePathToMarkdownFile: absoluteFilePath
834027
834097
  });
834028
- const { markdown: markdownWithAbsPaths, filepaths } = parseImagePaths(markdownReplacedMdAndCode, {
834029
- absolutePathToFernFolder: docsWorkspace.absoluteFilePath,
834030
- absolutePathToMarkdownFile: absoluteFilePath
834031
- });
834098
+ let markdownWithAbsPaths;
834099
+ let filepaths;
834100
+ try {
834101
+ ({ markdown: markdownWithAbsPaths, filepaths } = parseImagePaths(markdownReplacedMdAndCode, {
834102
+ absolutePathToFernFolder: docsWorkspace.absoluteFilePath,
834103
+ absolutePathToMarkdownFile: absoluteFilePath
834104
+ }));
834105
+ } catch (error50) {
834106
+ throw new CliError({
834107
+ message: `Failed to parse markdown in ${absoluteFilePath}: ${extractErrorMessage(error50)}`,
834108
+ code: CliError.Code.ParseError
834109
+ });
834110
+ }
834032
834111
  if (previousDocsDefinition.filesV2 == null) {
834033
834112
  previousDocsDefinition.filesV2 = {};
834034
834113
  }
@@ -845411,7 +845490,7 @@ var LegacyDocsPublisher = class {
845411
845490
  previewId,
845412
845491
  disableTemplates: void 0,
845413
845492
  skipUpload,
845414
- cliVersion: "4.107.1",
845493
+ cliVersion: "4.107.2-1-g488c64ae1ff",
845415
845494
  loginCommand: "fern auth login"
845416
845495
  });
845417
845496
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -881496,7 +881575,8 @@ var Comment6 = class extends AstNode6 {
881496
881575
  this.docs.split("\n").forEach((line) => {
881497
881576
  const wrappedLines = this.wrapLine(line, writer2);
881498
881577
  wrappedLines.forEach((wrappedLine) => {
881499
- writer2.writeLine(`# ${wrappedLine}`);
881578
+ const trimmed2 = wrappedLine.trimEnd();
881579
+ writer2.writeLine(trimmed2 === "" ? "#" : `# ${trimmed2}`);
881500
881580
  });
881501
881581
  });
881502
881582
  }
@@ -919528,10 +919608,15 @@ function processGeneratorGroups(groups2, maybeApiName, logger4) {
919528
919608
  for (const [groupName, group] of Object.entries(groups2)) {
919529
919609
  for (const [generatorName, generatorVersions] of Object.entries(group)) {
919530
919610
  logger4.debug(`Checking if ${generatorName} in group ${groupName} has an upgrade available...`);
919531
- const isUpgradeAvailable = isVersionAhead(
919532
- generatorVersions.latestVersion,
919533
- generatorVersions.previousVersion
919534
- );
919611
+ let isUpgradeAvailable;
919612
+ try {
919613
+ isUpgradeAvailable = isVersionAhead(generatorVersions.latestVersion, generatorVersions.previousVersion);
919614
+ } catch {
919615
+ throw new CliError({
919616
+ message: `Generator "${generatorName}" has an invalid version "${generatorVersions.previousVersion}" in generators.yml. Use an exact version like 1.2.3.`,
919617
+ code: CliError.Code.ConfigError
919618
+ });
919619
+ }
919535
919620
  logger4.debug(
919536
919621
  `Latest version: ${generatorVersions.latestVersion}. ` + (isUpgradeAvailable ? "Upgrade available." : "No upgrade available.")
919537
919622
  );
@@ -919640,7 +919725,7 @@ var CliContext = class _CliContext {
919640
919725
  if (false) {
919641
919726
  this.logger.error("CLI_VERSION is not defined");
919642
919727
  }
919643
- return "4.107.1";
919728
+ return "4.107.2-1-g488c64ae1ff";
919644
919729
  }
919645
919730
  getCliName() {
919646
919731
  if (false) {
@@ -928173,7 +928258,9 @@ async function resolvePreviewUrlFromId({
928173
928258
  const fernDirectory = await getFernDirectory();
928174
928259
  if (fernDirectory == null) {
928175
928260
  return cliContext.failAndThrow(
928176
- "No fern directory found. The --id flag requires a Fern project to resolve the organization.\nRun this command from within a Fern project directory, or use the URL argument instead."
928261
+ "No fern directory found. The --id flag requires a Fern project to resolve the organization.\nRun this command from within a Fern project directory, or use the URL argument instead.",
928262
+ void 0,
928263
+ { code: CliError.Code.ValidationError }
928177
928264
  );
928178
928265
  }
928179
928266
  const projectConfig = await cliContext.runTask(
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.107.1",
2
+ "version": "4.107.2-1-g488c64ae1ff",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",