@fern-api/fern-api-dev 4.81.0-3-gaa0d9a2b5d2 → 4.81.0-7-ge028c11454c

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 +113 -35
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -614356,7 +614356,7 @@ var AccessTokenPosthogManager = class {
614356
614356
  properties: {
614357
614357
  ...event,
614358
614358
  ...event.properties,
614359
- version: "4.81.0-3-gaa0d9a2b5d2",
614359
+ version: "4.81.0-7-ge028c11454c",
614360
614360
  usingAccessToken: true
614361
614361
  }
614362
614362
  });
@@ -614410,7 +614410,7 @@ var UserPosthogManager = class {
614410
614410
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
614411
614411
  event: "CLI",
614412
614412
  properties: {
614413
- version: "4.81.0-3-gaa0d9a2b5d2",
614413
+ version: "4.81.0-7-ge028c11454c",
614414
614414
  ...event,
614415
614415
  ...event.properties,
614416
614416
  usingAccessToken: false,
@@ -615614,7 +615614,10 @@ var PlatformKeyring = class {
615614
615614
  await this.setPasswordWindows(service, account, password);
615615
615615
  break;
615616
615616
  default:
615617
- throw new Error(`Unsupported platform: ${process.platform}`);
615617
+ throw new CliError({
615618
+ message: `Unsupported platform: ${process.platform}`,
615619
+ code: CliError.Code.EnvironmentError
615620
+ });
615618
615621
  }
615619
615622
  }
615620
615623
  async getPassword(service, account) {
@@ -615626,7 +615629,10 @@ var PlatformKeyring = class {
615626
615629
  case "win32":
615627
615630
  return this.getPasswordWindows(service, account);
615628
615631
  default:
615629
- throw new Error(`Unsupported platform: ${process.platform}`);
615632
+ throw new CliError({
615633
+ message: `Unsupported platform: ${process.platform}`,
615634
+ code: CliError.Code.EnvironmentError
615635
+ });
615630
615636
  }
615631
615637
  }
615632
615638
  async deletePassword(service, account) {
@@ -615638,7 +615644,10 @@ var PlatformKeyring = class {
615638
615644
  case "win32":
615639
615645
  return this.deletePasswordWindows(service, account);
615640
615646
  default:
615641
- throw new Error(`Unsupported platform: ${process.platform}`);
615647
+ throw new CliError({
615648
+ message: `Unsupported platform: ${process.platform}`,
615649
+ code: CliError.Code.EnvironmentError
615650
+ });
615642
615651
  }
615643
615652
  }
615644
615653
  async findCredentials(service) {
@@ -615650,7 +615659,10 @@ var PlatformKeyring = class {
615650
615659
  case "win32":
615651
615660
  return this.findCredentialsWindows(service);
615652
615661
  default:
615653
- throw new Error(`Unsupported platform: ${process.platform}`);
615662
+ throw new CliError({
615663
+ message: `Unsupported platform: ${process.platform}`,
615664
+ code: CliError.Code.EnvironmentError
615665
+ });
615654
615666
  }
615655
615667
  }
615656
615668
  async setPasswordDarwin(service, account, password) {
@@ -617763,7 +617775,10 @@ var FileFinder = class {
617763
617775
  async findOrThrow({ filename, remediationMessage }) {
617764
617776
  const filepath = await this.find({ filename });
617765
617777
  if (filepath == null) {
617766
- throw new Error(`${filename} file not found in any parent directory from ${this.from}`);
617778
+ throw new CliError({
617779
+ message: `${filename} file not found in any parent directory from ${this.from}`,
617780
+ code: CliError.Code.InternalError
617781
+ });
617767
617782
  }
617768
617783
  return filepath;
617769
617784
  }
@@ -617805,7 +617820,10 @@ var FernYmlSchemaLoader = class {
617805
617820
  async loadOrThrow() {
617806
617821
  const loadResult = await this.load();
617807
617822
  if (loadResult.type === "notFound") {
617808
- throw new Error(`${FILENAME2} file not found in any parent directory; did you forget to run \`fern init\`?`);
617823
+ throw new CliError({
617824
+ message: `${FILENAME2} file not found in any parent directory; did you forget to run \`fern init\`?`,
617825
+ code: CliError.Code.InternalError
617826
+ });
617809
617827
  }
617810
617828
  if (loadResult.type === "failure") {
617811
617829
  throw new SourcedValidationError(loadResult.issues);
@@ -617876,7 +617894,10 @@ var TelemetryClient = class _TelemetryClient {
617876
617894
  if (sentryDsn != null && sentryDsn.length > 0 && isTelemetryEnabled) {
617877
617895
  const sentryEnvironment = "development";
617878
617896
  if (sentryEnvironment == null || sentryEnvironment.length === 0) {
617879
- throw new Error("SENTRY_ENVIRONMENT must be set when SENTRY_DSN is configured");
617897
+ throw new CliError({
617898
+ message: "SENTRY_ENVIRONMENT must be set when SENTRY_DSN is configured",
617899
+ code: CliError.Code.ConfigError
617900
+ });
617880
617901
  }
617881
617902
  this.sentry = init2({
617882
617903
  dsn: sentryDsn,
@@ -618176,7 +618197,10 @@ var ApiDefinitionConverter = class {
618176
618197
  sourced
618177
618198
  });
618178
618199
  }
618179
- throw new Error(`Unknown spec type: ${JSON.stringify(spec)}`);
618200
+ throw new CliError({
618201
+ message: `Unknown spec type: ${JSON.stringify(spec)}`,
618202
+ code: CliError.Code.InternalError
618203
+ });
618180
618204
  }
618181
618205
  async convertOpenApiSpec({ absoluteFernYmlPath, spec, sourced }) {
618182
618206
  const result = {
@@ -619536,7 +619560,10 @@ var LegacyApiSpecAdapter = class {
619536
619560
  if (isOpenRpcSpec(spec)) {
619537
619561
  return this.adaptOpenRpcSpec(spec);
619538
619562
  }
619539
- throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
619563
+ throw new CliError({
619564
+ message: `Unsupported spec type: ${JSON.stringify(spec)}`,
619565
+ code: CliError.Code.InternalError
619566
+ });
619540
619567
  }
619541
619568
  convertAll(specs) {
619542
619569
  return specs.map((spec) => this.adapt(spec));
@@ -746685,7 +746712,10 @@ var LegacyFernWorkspaceAdapter = class {
746685
746712
  generatorsConfiguration: apiConfig != null ? this.buildGeneratorsConfiguration(apiConfig) : void 0
746686
746713
  });
746687
746714
  if (ossWorkspace == null) {
746688
- throw new Error("Internal error; failed to build API definitions");
746715
+ throw new CliError({
746716
+ message: "Internal error; failed to build API definitions",
746717
+ code: CliError.Code.InternalError
746718
+ });
746689
746719
  }
746690
746720
  return ossWorkspace.toFernWorkspace({ context: this.taskContext });
746691
746721
  }
@@ -747842,7 +747872,10 @@ function addSplitCommand(cli) {
747842
747872
  description: `Output format: '${OVERLAY_NAME}' (OpenAPI Overlay 1.0.0) or '${OVERRIDES_NAME}' (Fern deep-merge)`
747843
747873
  }).coerce("format", (value2) => {
747844
747874
  if (!ALL_FORMAT_NAMES.includes(value2)) {
747845
- throw new Error(`Invalid format '${value2}'. Expected one of: ${OVERLAY_NAME}, ${OVERRIDES_NAME}`);
747875
+ throw new CliError({
747876
+ message: `Invalid format '${value2}'. Expected one of: ${OVERLAY_NAME}, ${OVERRIDES_NAME}`,
747877
+ code: CliError.Code.ValidationError
747878
+ });
747846
747879
  }
747847
747880
  return value2;
747848
747881
  }));
@@ -827894,7 +827927,7 @@ var DocsWorkspaceValidator = class {
827894
827927
  const startTime = performance.now();
827895
827928
  if (workspace.config.settings?.substituteEnvVars) {
827896
827929
  workspace.config = replaceEnvVariables(workspace.config, {
827897
- onError: (error50) => this.taskContext.failAndThrow(error50)
827930
+ onError: (error50) => this.taskContext.failAndThrow(error50, void 0, { code: CliError.Code.ConfigError })
827898
827931
  });
827899
827932
  }
827900
827933
  const violations = await validateDocsWorkspace(workspace, this.taskContext, apiWorkspaces, ossWorkspaces, false, excludeRules);
@@ -831728,7 +831761,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
831728
831761
  var LOGS_FOLDER_NAME = "logs";
831729
831762
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
831730
831763
  function getCliSource() {
831731
- const version7 = "4.81.0-3-gaa0d9a2b5d2";
831764
+ const version7 = "4.81.0-7-ge028c11454c";
831732
831765
  return `cli@${version7}`;
831733
831766
  }
831734
831767
  var DebugLogger = class {
@@ -843295,7 +843328,7 @@ var LegacyDocsPublisher = class {
843295
843328
  previewId,
843296
843329
  disableTemplates: void 0,
843297
843330
  skipUpload,
843298
- cliVersion: "4.81.0-3-gaa0d9a2b5d2"
843331
+ cliVersion: "4.81.0-7-ge028c11454c"
843299
843332
  });
843300
843333
  if (taskContext.getResult() === TaskResult.Failure) {
843301
843334
  return { success: false };
@@ -843770,7 +843803,10 @@ var DocsTask = class {
843770
843803
  getTask() {
843771
843804
  const task = this.taskGroup.getTask(this.id);
843772
843805
  if (task == null) {
843773
- throw new Error(`Internal error; task '${this.id}' does not exist`);
843806
+ throw new CliError({
843807
+ message: `Internal error; task '${this.id}' does not exist`,
843808
+ code: CliError.Code.InternalError
843809
+ });
843774
843810
  }
843775
843811
  return task;
843776
843812
  }
@@ -845042,7 +845078,10 @@ var Wizard = class {
845042
845078
  async fetchApiFromUrl(url3, specFormat) {
845043
845079
  const response = await fetch(url3, { signal: AbortSignal.timeout(FETCH_API_SPEC_REQUEST_TIMEOUT_MS) });
845044
845080
  if (!response.ok) {
845045
- throw new Error(`HTTP ${response.status} ${response.statusText}`);
845081
+ throw new CliError({
845082
+ message: `HTTP ${response.status} ${response.statusText}`,
845083
+ code: CliError.Code.NetworkError
845084
+ });
845046
845085
  }
845047
845086
  const content5 = await response.text();
845048
845087
  const filename = this.resolveFilenameFromUrl({ url: url3, specFormat });
@@ -846572,20 +846611,29 @@ var ApiSpecDetector = class {
846572
846611
  async detect({ absoluteFilePath, reference: reference4, content: content5 }) {
846573
846612
  const parsed = this.parseOrThrow({ content: content5, reference: reference4 });
846574
846613
  if (typeof parsed !== "object" || parsed == null) {
846575
- throw new Error(`Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`);
846614
+ throw new CliError({
846615
+ message: `Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`,
846616
+ code: CliError.Code.InternalError
846617
+ });
846576
846618
  }
846577
846619
  for (const specType of DETECTABLE_SPEC_TYPES) {
846578
846620
  if (specType in parsed) {
846579
846621
  return specType;
846580
846622
  }
846581
846623
  }
846582
- throw new Error(`Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`);
846624
+ throw new CliError({
846625
+ message: `Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`,
846626
+ code: CliError.Code.InternalError
846627
+ });
846583
846628
  }
846584
846629
  parseOrThrow({ content: content5, reference: reference4 }) {
846585
846630
  try {
846586
846631
  return jsYaml.load(content5);
846587
846632
  } catch {
846588
- throw new Error(`Could not parse "${reference4}" as YAML or JSON. Ensure the file is a valid OpenAPI or AsyncAPI specification.`);
846633
+ throw new CliError({
846634
+ message: `Could not parse "${reference4}" as YAML or JSON. Ensure the file is a valid OpenAPI or AsyncAPI specification.`,
846635
+ code: CliError.Code.ParseError
846636
+ });
846589
846637
  }
846590
846638
  }
846591
846639
  };
@@ -846623,7 +846671,10 @@ var ApiSpecResolver = class {
846623
846671
  async resolveLocal({ reference: reference4 }) {
846624
846672
  const absoluteFilePath = resolve6(this.context.cwd, reference4);
846625
846673
  if (!await doesPathExist(absoluteFilePath)) {
846626
- throw new Error(`API spec file does not exist: ${reference4}`);
846674
+ throw new CliError({
846675
+ message: `API spec file does not exist: ${reference4}`,
846676
+ code: CliError.Code.ConfigError
846677
+ });
846627
846678
  }
846628
846679
  const content5 = await (0, import_promises92.readFile)(absoluteFilePath, "utf-8");
846629
846680
  const specType = await this.detector.detect({ absoluteFilePath, content: content5, reference: reference4 });
@@ -846636,11 +846687,17 @@ var ApiSpecResolver = class {
846636
846687
  async fetchContent({ url: url3 }) {
846637
846688
  const response = await fetch(url3, { signal: AbortSignal.timeout(FETCH_API_SPEC_REQUEST_TIMEOUT_MS) });
846638
846689
  if (!response.ok) {
846639
- throw new Error(`Failed to fetch "${url3}": HTTP ${response.status} ${response.statusText}`);
846690
+ throw new CliError({
846691
+ message: `Failed to fetch "${url3}": HTTP ${response.status} ${response.statusText}`,
846692
+ code: CliError.Code.NetworkError
846693
+ });
846640
846694
  }
846641
846695
  const contentType = response.headers.get("content-type") ?? "";
846642
846696
  if (contentType.includes("text/html")) {
846643
- throw new Error(`The URL "${url3}" returned HTML content. Ensure you're pointing to a raw spec URL, not a documentation page.`);
846697
+ throw new CliError({
846698
+ message: `The URL "${url3}" returned HTML content. Ensure you're pointing to a raw spec URL, not a documentation page.`,
846699
+ code: CliError.Code.ConfigError
846700
+ });
846644
846701
  }
846645
846702
  const content5 = await response.text();
846646
846703
  return { content: content5, contentType };
@@ -846665,7 +846722,10 @@ var ApiSpecResolver = class {
846665
846722
  case "asyncapi":
846666
846723
  return { asyncapi: absoluteFilePath, origin: origin2 };
846667
846724
  default:
846668
- throw new Error(`Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`);
846725
+ throw new CliError({
846726
+ message: `Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`,
846727
+ code: CliError.Code.ConfigError
846728
+ });
846669
846729
  }
846670
846730
  }
846671
846731
  isUrl(reference4) {
@@ -897467,7 +897527,10 @@ var LegacyGeneratorInvocationAdapter = class {
897467
897527
  }
897468
897528
  const absolutePath = join8(this.context.cwd, RelativeFilePath2.of(license));
897469
897529
  if (!await doesPathExist(absolutePath, "file")) {
897470
- throw new Error(`Custom license file "${absolutePath}" does not exist; did you mean to use either MIT or Apache-2.0?`);
897530
+ throw new CliError({
897531
+ message: `Custom license file "${absolutePath}" does not exist; did you mean to use either MIT or Apache-2.0?`,
897532
+ code: CliError.Code.InternalError
897533
+ });
897471
897534
  }
897472
897535
  const contents = await (0, import_promises106.readFile)(absolutePath, "utf-8");
897473
897536
  return api_exports4.GithubLicense.custom({ contents });
@@ -897975,7 +898038,10 @@ var SdkTask = class {
897975
898038
  getTask() {
897976
898039
  const task = this.taskGroup.getTask(this.id);
897977
898040
  if (task == null) {
897978
- throw new Error(`Internal error; task '${this.id}' does not exist`);
898041
+ throw new CliError({
898042
+ message: `Internal error; task '${this.id}' does not exist`,
898043
+ code: CliError.Code.InternalError
898044
+ });
897979
898045
  }
897980
898046
  return task;
897981
898047
  }
@@ -898207,7 +898273,7 @@ var GenerateCommand = class {
898207
898273
  }
898208
898274
  async runGeneration({ context: context3, workspace, targets: targets2, args, forceLocal }) {
898209
898275
  if (workspace.sdks == null) {
898210
- throw new Error("No SDKs configured");
898276
+ throw new CliError({ message: "No SDKs configured", code: CliError.Code.InternalError });
898211
898277
  }
898212
898278
  const apisToCheck = [...new Set(targets2.map((t3) => t3.api))];
898213
898279
  const apiChecker = new ApiChecker({
@@ -898889,7 +898955,10 @@ var GeneratorMigrator = class _GeneratorMigrator {
898889
898955
  const packageJsonContent = await (0, import_promises110.readFile)(packageJsonPath, "utf-8");
898890
898956
  const packageJson2 = JSON.parse(packageJsonContent);
898891
898957
  if (packageJson2.main == null) {
898892
- throw new Error(`No main field found in package.json for ${MIGRATION_PACKAGE_NAME}`);
898958
+ throw new CliError({
898959
+ message: `No main field found in package.json for ${MIGRATION_PACKAGE_NAME}`,
898960
+ code: CliError.Code.InternalError
898961
+ });
898893
898962
  }
898894
898963
  const packageEntryPoint = (0, import_path80.join)(packageDir, packageJson2.main);
898895
898964
  const { migrations } = await import((0, import_url8.pathToFileURL)(packageEntryPoint).href);
@@ -899004,11 +899073,14 @@ var GeneratorMigrator = class _GeneratorMigrator {
899004
899073
  this.logger.debug(`No migration package found for ${generatorName}.`);
899005
899074
  return void 0;
899006
899075
  }
899007
- throw new Error(`Failed to load generator migrations for ${generatorName}.
899076
+ throw new CliError({
899077
+ message: `Failed to load generator migrations for ${generatorName}.
899008
899078
 
899009
899079
  Reason: ${errorMessage}
899010
899080
 
899011
- Please check your internet connection and npm configuration, then try again.`);
899081
+ Please check your internet connection and npm configuration, then try again.`,
899082
+ code: CliError.Code.InternalError
899083
+ });
899012
899084
  }
899013
899085
  }
899014
899086
  /**
@@ -899037,7 +899109,10 @@ Please check your internet connection and npm configuration, then try again.`);
899037
899109
  const aVersion = import_semver14.default.parse(a4.version);
899038
899110
  const bVersion = import_semver14.default.parse(b7.version);
899039
899111
  if (aVersion == null || bVersion == null) {
899040
- throw new Error(`Internal error: Invalid migration version found during sort. Version A: ${a4.version}, Version B: ${b7.version}. This should not happen as invalid versions are filtered out.`);
899112
+ throw new CliError({
899113
+ message: `Internal error: Invalid migration version found during sort. Version A: ${a4.version}, Version B: ${b7.version}. This should not happen as invalid versions are filtered out.`,
899114
+ code: CliError.Code.InternalError
899115
+ });
899041
899116
  }
899042
899117
  return import_semver14.default.compare(aVersion, bVersion);
899043
899118
  });
@@ -899055,11 +899130,14 @@ Please check your internet connection and npm configuration, then try again.`);
899055
899130
  appliedVersions.push(migration23.version);
899056
899131
  } catch (error50) {
899057
899132
  const errorMessage = extractErrorMessage(error50);
899058
- throw new Error(`Failed to apply migration for version ${migration23.version}.
899133
+ throw new CliError({
899134
+ message: `Failed to apply migration for version ${migration23.version}.
899059
899135
 
899060
899136
  Reason: ${errorMessage}
899061
899137
 
899062
- Please report this issue at: https://github.com/fern-api/fern/issues`);
899138
+ Please report this issue at: https://github.com/fern-api/fern/issues`,
899139
+ code: CliError.Code.InternalError
899140
+ });
899063
899141
  }
899064
899142
  }
899065
899143
  return {
@@ -918415,7 +918493,7 @@ var CliContext = class _CliContext {
918415
918493
  if (false) {
918416
918494
  this.logger.error("CLI_VERSION is not defined");
918417
918495
  }
918418
- return "4.81.0-3-gaa0d9a2b5d2";
918496
+ return "4.81.0-7-ge028c11454c";
918419
918497
  }
918420
918498
  getCliName() {
918421
918499
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.81.0-3-gaa0d9a2b5d2",
2
+ "version": "4.81.0-7-ge028c11454c",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",