@fern-api/fern-api-dev 4.68.3-2-g063113b6335 → 4.68.3

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 +1240 -1384
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -38969,7 +38969,7 @@ var require_errors = __commonJS({
38969
38969
  exports2.keyword$DataError = {
38970
38970
  message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
38971
38971
  };
38972
- function reportError3(cxt, error50 = exports2.keywordError, errorPaths, overrideAllErrors) {
38972
+ function reportError(cxt, error50 = exports2.keywordError, errorPaths, overrideAllErrors) {
38973
38973
  const { it: it13 } = cxt;
38974
38974
  const { gen, compositeRule, allErrors } = it13;
38975
38975
  const errObj = errorObjectCode(cxt, error50, errorPaths);
@@ -38979,7 +38979,7 @@ var require_errors = __commonJS({
38979
38979
  returnErrors(it13, (0, codegen_1._)`[${errObj}]`);
38980
38980
  }
38981
38981
  }
38982
- exports2.reportError = reportError3;
38982
+ exports2.reportError = reportError;
38983
38983
  function reportExtraError(cxt, error50 = exports2.keywordError, errorPaths) {
38984
38984
  const { it: it13 } = cxt;
38985
38985
  const { gen, compositeRule, allErrors } = it13;
@@ -54543,7 +54543,7 @@ function childLoggerName(name2, childDebugger, { namespace: parentNamespace }) {
54543
54543
  }
54544
54544
  return childNamespace || parentNamespace;
54545
54545
  }
54546
- function createLogger2(label, verbose, initialStep, infoDebugger = createLog()) {
54546
+ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
54547
54547
  const labelPrefix = label && `[${label}]` || "";
54548
54548
  const spawned = [];
54549
54549
  const debugDebugger = typeof verbose === "string" ? infoDebugger.extend(verbose) : verbose;
@@ -54552,7 +54552,7 @@ function createLogger2(label, verbose, initialStep, infoDebugger = createLog())
54552
54552
  function sibling2(name2, initial) {
54553
54553
  return append(
54554
54554
  spawned,
54555
- createLogger2(label, key2.replace(/^[^:]+/, name2), initial, infoDebugger)
54555
+ createLogger(label, key2.replace(/^[^:]+/, name2), initial, infoDebugger)
54556
54556
  );
54557
54557
  }
54558
54558
  function step(phase) {
@@ -56283,7 +56283,7 @@ var init_esm16 = __esm({
56283
56283
  }
56284
56284
  createProgress(task) {
56285
56285
  const name2 = _TasksPendingQueue.getName(task.commands[0]);
56286
- const logger4 = createLogger2(this.logLabel, name2);
56286
+ const logger4 = createLogger(this.logLabel, name2);
56287
56287
  return {
56288
56288
  task,
56289
56289
  logger: logger4,
@@ -57566,7 +57566,7 @@ var init_esm16 = __esm({
57566
57566
  Scheduler = class {
57567
57567
  constructor(concurrency = 2) {
57568
57568
  this.concurrency = concurrency;
57569
- this.logger = createLogger2("", "scheduler");
57569
+ this.logger = createLogger("", "scheduler");
57570
57570
  this.pending = [];
57571
57571
  this.running = [];
57572
57572
  this.logger(`Constructed, concurrency=%s`, concurrency);
@@ -59886,7 +59886,7 @@ var init_version4 = __esm({
59886
59886
  });
59887
59887
 
59888
59888
  // ../../../node_modules/.pnpm/@octokit+core@6.1.6/node_modules/@octokit/core/dist-src/index.js
59889
- function createLogger3(logger4 = {}) {
59889
+ function createLogger2(logger4 = {}) {
59890
59890
  if (typeof logger4.debug !== "function") {
59891
59891
  logger4.debug = noop3;
59892
59892
  }
@@ -59982,7 +59982,7 @@ var init_dist_src2 = __esm({
59982
59982
  }
59983
59983
  this.request = request2.defaults(requestDefaults);
59984
59984
  this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
59985
- this.log = createLogger3(options2.log);
59985
+ this.log = createLogger2(options2.log);
59986
59986
  this.hook = hook8;
59987
59987
  if (!options2.authStrategy) {
59988
59988
  if (!options2.auth) {
@@ -66343,7 +66343,7 @@ function removeListener(state, webhookNameOrNames, handler3) {
66343
66343
  function createEventHandler(options2) {
66344
66344
  const state = {
66345
66345
  hooks: {},
66346
- log: createLogger4(options2 && options2.log)
66346
+ log: createLogger3(options2 && options2.log)
66347
66347
  };
66348
66348
  if (options2 && options2.transform) {
66349
66349
  state.transform = options2.transform;
@@ -66385,13 +66385,13 @@ async function verifyAndReceive(state, event) {
66385
66385
  payload
66386
66386
  });
66387
66387
  }
66388
- var createLogger4, emitterEventNames, textDecoder, decode, Webhooks;
66388
+ var createLogger3, emitterEventNames, textDecoder, decode, Webhooks;
66389
66389
  var init_dist_bundle13 = __esm({
66390
66390
  "../../../node_modules/.pnpm/@octokit+webhooks@13.9.1/node_modules/@octokit/webhooks/dist-bundle/index.js"() {
66391
66391
  "use strict";
66392
66392
  init_dist_node4();
66393
66393
  init_dist_node4();
66394
- createLogger4 = (logger4 = {}) => {
66394
+ createLogger3 = (logger4 = {}) => {
66395
66395
  if (typeof logger4.debug !== "function") {
66396
66396
  logger4.debug = () => {
66397
66397
  };
@@ -66746,7 +66746,7 @@ var init_dist_bundle13 = __esm({
66746
66746
  secret: options2.secret,
66747
66747
  additionalSecrets: options2.additionalSecrets,
66748
66748
  hooks: {},
66749
- log: createLogger4(options2.log)
66749
+ log: createLogger3(options2.log)
66750
66750
  };
66751
66751
  this.sign = sign.bind(null, options2.secret);
66752
66752
  this.verify = verify.bind(null, options2.secret);
@@ -80661,7 +80661,7 @@ var require_errors2 = __commonJS({
80661
80661
  "use strict";
80662
80662
  Object.defineProperty(exports2, "__esModule", { value: true });
80663
80663
  exports2.keyword$DataError = exports2.keywordError = void 0;
80664
- exports2.reportError = reportError3;
80664
+ exports2.reportError = reportError;
80665
80665
  exports2.reportExtraError = reportExtraError;
80666
80666
  exports2.resetErrorsCount = resetErrorsCount;
80667
80667
  exports2.extendErrors = extendErrors;
@@ -80674,7 +80674,7 @@ var require_errors2 = __commonJS({
80674
80674
  exports2.keyword$DataError = {
80675
80675
  message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
80676
80676
  };
80677
- function reportError3(cxt, error50 = exports2.keywordError, errorPaths, overrideAllErrors) {
80677
+ function reportError(cxt, error50 = exports2.keywordError, errorPaths, overrideAllErrors) {
80678
80678
  const { it: it13 } = cxt;
80679
80679
  const { gen, compositeRule, allErrors } = it13;
80680
80680
  const errObj = errorObjectCode(cxt, error50, errorPaths);
@@ -485174,224 +485174,6 @@ function commandGroup(cli, name2, description, subcommands) {
485174
485174
  });
485175
485175
  }
485176
485176
 
485177
- // ../task-context/lib/CliError.js
485178
- var CliError = class _CliError extends Error {
485179
- code;
485180
- docsLink;
485181
- constructor({ message, code: code5, docsLink }) {
485182
- super(message);
485183
- Object.setPrototypeOf(this, _CliError.prototype);
485184
- this.code = code5;
485185
- this.docsLink = docsLink;
485186
- }
485187
- static authRequired(message) {
485188
- return new _CliError({
485189
- message: message ?? "Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable.",
485190
- code: _CliError.Code.AuthError
485191
- });
485192
- }
485193
- static unauthorized(message) {
485194
- return new _CliError({
485195
- message: message ?? "Unauthorized. Please run 'fern auth login' or set the FERN_TOKEN environment variable.",
485196
- code: _CliError.Code.AuthError
485197
- });
485198
- }
485199
- static notFound(message) {
485200
- return new _CliError({ message, code: _CliError.Code.ConfigError });
485201
- }
485202
- static badRequest(message) {
485203
- return new _CliError({ message, code: _CliError.Code.NetworkError });
485204
- }
485205
- static validationError(message) {
485206
- return new _CliError({ message, code: _CliError.Code.ValidationError });
485207
- }
485208
- static internalError(message) {
485209
- return new _CliError({ message, code: _CliError.Code.InternalError });
485210
- }
485211
- };
485212
- (function(CliError4) {
485213
- CliError4.Code = {
485214
- InternalError: "INTERNAL_ERROR",
485215
- ResolutionError: "RESOLUTION_ERROR",
485216
- IrConversionError: "IR_CONVERSION_ERROR",
485217
- ContainerError: "CONTAINER_ERROR",
485218
- VersionError: "VERSION_ERROR",
485219
- ParseError: "PARSE_ERROR",
485220
- EnvironmentError: "ENVIRONMENT_ERROR",
485221
- ReferenceError: "REFERENCE_ERROR",
485222
- ValidationError: "VALIDATION_ERROR",
485223
- NetworkError: "NETWORK_ERROR",
485224
- AuthError: "AUTH_ERROR",
485225
- ConfigError: "CONFIG_ERROR",
485226
- Unclassified: "UNCLASSIFIED"
485227
- };
485228
- })(CliError || (CliError = {}));
485229
- var SENTRY_REPORTABLE = {
485230
- [CliError.Code.InternalError]: true,
485231
- [CliError.Code.ResolutionError]: true,
485232
- [CliError.Code.IrConversionError]: true,
485233
- [CliError.Code.ContainerError]: true,
485234
- [CliError.Code.VersionError]: true,
485235
- [CliError.Code.ParseError]: false,
485236
- [CliError.Code.EnvironmentError]: false,
485237
- [CliError.Code.ReferenceError]: false,
485238
- [CliError.Code.ValidationError]: false,
485239
- [CliError.Code.NetworkError]: false,
485240
- [CliError.Code.AuthError]: false,
485241
- [CliError.Code.ConfigError]: false,
485242
- [CliError.Code.Unclassified]: false
485243
- };
485244
- function shouldReportToSentry(code5) {
485245
- return SENTRY_REPORTABLE[code5];
485246
- }
485247
- function isSchemaValidationError(error50) {
485248
- return error50 instanceof Error && (error50.constructor.name === "ParseError" || error50.constructor.name === "JsonError");
485249
- }
485250
- function isNodeVersionError(error50) {
485251
- return error50 instanceof Error && error50.message.includes("globalThis");
485252
- }
485253
- function resolveErrorCode(error50, explicitCode) {
485254
- if (explicitCode != null) {
485255
- return explicitCode;
485256
- }
485257
- if (error50 instanceof CliError) {
485258
- return error50.code;
485259
- }
485260
- if (isSchemaValidationError(error50)) {
485261
- return CliError.Code.ParseError;
485262
- }
485263
- if (isNodeVersionError(error50)) {
485264
- return CliError.Code.EnvironmentError;
485265
- }
485266
- return CliError.Code.Unclassified;
485267
- }
485268
-
485269
- // ../logger/lib/LogLevel.js
485270
- var LogLevel = {
485271
- Trace: "trace",
485272
- Debug: "debug",
485273
- Info: "info",
485274
- Warn: "warn",
485275
- Error: "error"
485276
- };
485277
- var LOG_LEVELS = Object.values(LogLevel);
485278
-
485279
- // ../logger/lib/createLogger.js
485280
- var LoggerImpl = class {
485281
- log;
485282
- enabled;
485283
- constructor(log4, enabled = true) {
485284
- this.log = log4;
485285
- this.enabled = enabled;
485286
- }
485287
- disable() {
485288
- this.enabled = false;
485289
- }
485290
- enable() {
485291
- this.enabled = true;
485292
- }
485293
- debug(...args) {
485294
- if (this.enabled) {
485295
- this.log(LogLevel.Debug, ...args);
485296
- }
485297
- }
485298
- info(...args) {
485299
- if (this.enabled) {
485300
- this.log(LogLevel.Info, ...args);
485301
- }
485302
- }
485303
- warn(...args) {
485304
- if (this.enabled) {
485305
- this.log(LogLevel.Warn, ...args);
485306
- }
485307
- }
485308
- error(...args) {
485309
- if (this.enabled) {
485310
- this.log(LogLevel.Error, ...args);
485311
- }
485312
- }
485313
- trace(...args) {
485314
- if (this.enabled) {
485315
- this.log(LogLevel.Trace, ...args);
485316
- }
485317
- }
485318
- };
485319
- function createLogger(log4) {
485320
- return new LoggerImpl(log4);
485321
- }
485322
-
485323
- // ../logger/lib/console.js
485324
- var CONSOLE_LOGGER = Object.freeze(createLogger(log3));
485325
- function log3(level, ...args) {
485326
- const consoleLogger = getConsoleLoggerForLevel(level);
485327
- consoleLogger(...args);
485328
- }
485329
- function getConsoleLoggerForLevel(level) {
485330
- switch (level) {
485331
- case LogLevel.Trace:
485332
- return console.trace;
485333
- case LogLevel.Debug:
485334
- return console.debug;
485335
- case LogLevel.Info:
485336
- return console.info;
485337
- case LogLevel.Warn:
485338
- return console.warn;
485339
- case LogLevel.Error:
485340
- return console.error;
485341
- }
485342
- }
485343
-
485344
- // ../task-context/lib/TaskAbortSignal.js
485345
- var TaskAbortSignal = class {
485346
- __brand = "TaskAbortSignal";
485347
- };
485348
-
485349
- // ../task-context/lib/TaskContext.js
485350
- var TaskResult;
485351
- (function(TaskResult2) {
485352
- TaskResult2[TaskResult2["Success"] = 0] = "Success";
485353
- TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
485354
- })(TaskResult || (TaskResult = {}));
485355
-
485356
- // ../task-context/lib/MockTaskContext.js
485357
- function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
485358
- const context3 = {
485359
- logger: logger4,
485360
- takeOverTerminal: () => {
485361
- throw new Error("Not implemented");
485362
- },
485363
- failAndThrow: (message, error50, _options) => {
485364
- const parts = [];
485365
- if (message != null) {
485366
- parts.push(message);
485367
- }
485368
- if (error50 != null) {
485369
- parts.push(JSON.stringify(error50));
485370
- }
485371
- if (parts.length > 0) {
485372
- context3.logger.error(...parts);
485373
- }
485374
- throw new TaskAbortSignal();
485375
- },
485376
- failWithoutThrowing: (message, error50, _options) => {
485377
- context3.failAndThrow(message, error50);
485378
- },
485379
- captureException: () => {
485380
- },
485381
- getResult: () => TaskResult.Success,
485382
- addInteractiveTask: () => {
485383
- throw new Error("Not implemented");
485384
- },
485385
- runInteractiveTask: () => {
485386
- throw new Error("Not implemented");
485387
- },
485388
- instrumentPostHogEvent: () => {
485389
- throw new Error("Not implemented");
485390
- }
485391
- };
485392
- return context3;
485393
- }
485394
-
485395
485177
  // ../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
485396
485178
  var ANSI_BACKGROUND_OFFSET = 10;
485397
485179
  var wrapAnsi16 = (offset2 = 0) => (code5) => `\x1B[${code5 + offset2}m`;
@@ -518947,17 +518729,17 @@ var FernDocsConfigTimeoutError = class extends Error {
518947
518729
  };
518948
518730
 
518949
518731
  // ../configuration/lib/docs-yml/schemas/sdk/core/logging/logger.js
518950
- var LogLevel2 = {
518732
+ var LogLevel = {
518951
518733
  Debug: "debug",
518952
518734
  Info: "info",
518953
518735
  Warn: "warn",
518954
518736
  Error: "error"
518955
518737
  };
518956
518738
  var logLevelMap2 = {
518957
- [LogLevel2.Debug]: 1,
518958
- [LogLevel2.Info]: 2,
518959
- [LogLevel2.Warn]: 3,
518960
- [LogLevel2.Error]: 4
518739
+ [LogLevel.Debug]: 1,
518740
+ [LogLevel.Info]: 2,
518741
+ [LogLevel.Warn]: 3,
518742
+ [LogLevel.Error]: 4
518961
518743
  };
518962
518744
  var ConsoleLogger = class {
518963
518745
  debug(message, ...args) {
@@ -518999,7 +518781,7 @@ var Logger = class {
518999
518781
  * @returns True if debug logs should be output
519000
518782
  */
519001
518783
  isDebug() {
519002
- return this.shouldLog(LogLevel2.Debug);
518784
+ return this.shouldLog(LogLevel.Debug);
519003
518785
  }
519004
518786
  /**
519005
518787
  * Logs a debug message if debug logging is enabled.
@@ -519016,7 +518798,7 @@ var Logger = class {
519016
518798
  * @returns True if info logs should be output
519017
518799
  */
519018
518800
  isInfo() {
519019
- return this.shouldLog(LogLevel2.Info);
518801
+ return this.shouldLog(LogLevel.Info);
519020
518802
  }
519021
518803
  /**
519022
518804
  * Logs an info message if info logging is enabled.
@@ -519033,7 +518815,7 @@ var Logger = class {
519033
518815
  * @returns True if warning logs should be output
519034
518816
  */
519035
518817
  isWarn() {
519036
- return this.shouldLog(LogLevel2.Warn);
518818
+ return this.shouldLog(LogLevel.Warn);
519037
518819
  }
519038
518820
  /**
519039
518821
  * Logs a warning message if warning logging is enabled.
@@ -519050,7 +518832,7 @@ var Logger = class {
519050
518832
  * @returns True if error logs should be output
519051
518833
  */
519052
518834
  isError() {
519053
- return this.shouldLog(LogLevel2.Error);
518835
+ return this.shouldLog(LogLevel.Error);
519054
518836
  }
519055
518837
  /**
519056
518838
  * Logs an error message if error logging is enabled.
@@ -519064,7 +518846,7 @@ var Logger = class {
519064
518846
  }
519065
518847
  };
519066
518848
  var defaultLogger = new Logger({
519067
- level: LogLevel2.Info,
518849
+ level: LogLevel.Info,
519068
518850
  logger: new ConsoleLogger(),
519069
518851
  silent: true
519070
518852
  });
@@ -519072,7 +518854,7 @@ var defaultLogger = new Logger({
519072
518854
  // ../configuration/lib/docs-yml/schemas/sdk/core/logging/exports.js
519073
518855
  var logging;
519074
518856
  (function(logging2) {
519075
- logging2.LogLevel = LogLevel2;
518857
+ logging2.LogLevel = LogLevel;
519076
518858
  logging2.ConsoleLogger = ConsoleLogger;
519077
518859
  })(logging || (logging = {}));
519078
518860
 
@@ -555265,6 +555047,142 @@ function joinZodPath(arr) {
555265
555047
 
555266
555048
  // ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
555267
555049
  init_lib6();
555050
+
555051
+ // ../task-context/lib/LoggableFernCliError.js
555052
+ var LoggableFernCliError = class _LoggableFernCliError extends Error {
555053
+ log;
555054
+ constructor(log4) {
555055
+ super();
555056
+ this.log = log4;
555057
+ Object.setPrototypeOf(this, _LoggableFernCliError.prototype);
555058
+ }
555059
+ };
555060
+
555061
+ // ../logger/lib/LogLevel.js
555062
+ var LogLevel2 = {
555063
+ Trace: "trace",
555064
+ Debug: "debug",
555065
+ Info: "info",
555066
+ Warn: "warn",
555067
+ Error: "error"
555068
+ };
555069
+ var LOG_LEVELS = Object.values(LogLevel2);
555070
+
555071
+ // ../logger/lib/createLogger.js
555072
+ var LoggerImpl = class {
555073
+ log;
555074
+ enabled;
555075
+ constructor(log4, enabled = true) {
555076
+ this.log = log4;
555077
+ this.enabled = enabled;
555078
+ }
555079
+ disable() {
555080
+ this.enabled = false;
555081
+ }
555082
+ enable() {
555083
+ this.enabled = true;
555084
+ }
555085
+ debug(...args) {
555086
+ if (this.enabled) {
555087
+ this.log(LogLevel2.Debug, ...args);
555088
+ }
555089
+ }
555090
+ info(...args) {
555091
+ if (this.enabled) {
555092
+ this.log(LogLevel2.Info, ...args);
555093
+ }
555094
+ }
555095
+ warn(...args) {
555096
+ if (this.enabled) {
555097
+ this.log(LogLevel2.Warn, ...args);
555098
+ }
555099
+ }
555100
+ error(...args) {
555101
+ if (this.enabled) {
555102
+ this.log(LogLevel2.Error, ...args);
555103
+ }
555104
+ }
555105
+ trace(...args) {
555106
+ if (this.enabled) {
555107
+ this.log(LogLevel2.Trace, ...args);
555108
+ }
555109
+ }
555110
+ };
555111
+ function createLogger4(log4) {
555112
+ return new LoggerImpl(log4);
555113
+ }
555114
+
555115
+ // ../logger/lib/console.js
555116
+ var CONSOLE_LOGGER = Object.freeze(createLogger4(log3));
555117
+ function log3(level, ...args) {
555118
+ const consoleLogger = getConsoleLoggerForLevel(level);
555119
+ consoleLogger(...args);
555120
+ }
555121
+ function getConsoleLoggerForLevel(level) {
555122
+ switch (level) {
555123
+ case LogLevel2.Trace:
555124
+ return console.trace;
555125
+ case LogLevel2.Debug:
555126
+ return console.debug;
555127
+ case LogLevel2.Info:
555128
+ return console.info;
555129
+ case LogLevel2.Warn:
555130
+ return console.warn;
555131
+ case LogLevel2.Error:
555132
+ return console.error;
555133
+ }
555134
+ }
555135
+
555136
+ // ../task-context/lib/TaskAbortSignal.js
555137
+ var TaskAbortSignal = class {
555138
+ __brand = "TaskAbortSignal";
555139
+ };
555140
+
555141
+ // ../task-context/lib/TaskContext.js
555142
+ var TaskResult;
555143
+ (function(TaskResult2) {
555144
+ TaskResult2[TaskResult2["Success"] = 0] = "Success";
555145
+ TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
555146
+ })(TaskResult || (TaskResult = {}));
555147
+
555148
+ // ../task-context/lib/MockTaskContext.js
555149
+ function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
555150
+ const context3 = {
555151
+ logger: logger4,
555152
+ takeOverTerminal: () => {
555153
+ throw new Error("Not implemented");
555154
+ },
555155
+ failAndThrow: (message, error50) => {
555156
+ const parts = [];
555157
+ if (message != null) {
555158
+ parts.push(message);
555159
+ }
555160
+ if (error50 != null) {
555161
+ parts.push(JSON.stringify(error50));
555162
+ }
555163
+ if (parts.length > 0) {
555164
+ context3.logger.error(...parts);
555165
+ }
555166
+ throw new TaskAbortSignal();
555167
+ },
555168
+ failWithoutThrowing: (message, error50) => {
555169
+ context3.failAndThrow(message, error50);
555170
+ },
555171
+ getResult: () => TaskResult.Success,
555172
+ addInteractiveTask: () => {
555173
+ throw new Error("Not implemented");
555174
+ },
555175
+ runInteractiveTask: () => {
555176
+ throw new Error("Not implemented");
555177
+ },
555178
+ instrumentPostHogEvent: () => {
555179
+ throw new Error("Not implemented");
555180
+ }
555181
+ };
555182
+ return context3;
555183
+ }
555184
+
555185
+ // ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
555268
555186
  var import_path21 = __toESM(require("path"), 1);
555269
555187
  var EMPTY_DEPENDENCIES_CONFIGURATION = {
555270
555188
  dependencies: {}
@@ -571251,7 +571169,7 @@ function getInline2(typeDeclaration2) {
571251
571169
  function getTypeDeclaration(typeId, types4) {
571252
571170
  const maybeTypeDeclaration = types4[typeId];
571253
571171
  if (maybeTypeDeclaration == null) {
571254
- throw CliError.internalError(`Failed to load type declaration for type ${typeId}`);
571172
+ throw new LoggableFernCliError(`Illegal Error: Failed to load type declaration for type ${typeId}`);
571255
571173
  }
571256
571174
  return maybeTypeDeclaration;
571257
571175
  }
@@ -571313,7 +571231,7 @@ function getObjectTypeDeclarationFromTypeId(typeId, ir15) {
571313
571231
  }
571314
571232
  }
571315
571233
  }
571316
- throw CliError.internalError(`Unexpected error: ${typeId} is extended but has shape ${typeDeclaration2.shape.type}`);
571234
+ throw new LoggableFernCliError(`Unexpected error: ${typeId} is extended but has shape ${typeDeclaration2.shape.type}`);
571317
571235
  }
571318
571236
  function getAllPropertiesForObject2({ objectTypeDeclaration, ir: ir15 }) {
571319
571237
  const extendedProperties = objectTypeDeclaration.extends.flatMap((extended) => {
@@ -579575,8 +579493,7 @@ function formatLog({ breadcrumbs = [], title: title3, subtitle }) {
579575
579493
  }
579576
579494
 
579577
579495
  // ../cli-logger/lib/logErrorMessage.js
579578
- var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
579579
- function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel.Error }) {
579496
+ function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel2.Error }) {
579580
579497
  if (message != null) {
579581
579498
  logger4.log(logLevel, message);
579582
579499
  } else if (error50 == null) {
@@ -579601,9 +579518,6 @@ function convertErrorToString(error50) {
579601
579518
  return error50;
579602
579519
  }
579603
579520
  if (error50 instanceof Error) {
579604
- if (error50?.message?.includes("globalThis")) {
579605
- return USE_NODE_18_OR_ABOVE_MESSAGE;
579606
- }
579607
579521
  return error50.message;
579608
579522
  }
579609
579523
  return void 0;
@@ -580387,13 +580301,13 @@ function formatLog2(log4, { includeDebugInfo }) {
580387
580301
  }
580388
580302
  content5 += "\n";
580389
580303
  switch (log4.level) {
580390
- case LogLevel.Error:
580304
+ case LogLevel2.Error:
580391
580305
  return source_default.red(content5);
580392
- case LogLevel.Warn:
580306
+ case LogLevel2.Warn:
580393
580307
  return source_default.hex("FFA500")(content5);
580394
- case LogLevel.Trace:
580395
- case LogLevel.Debug:
580396
- case LogLevel.Info:
580308
+ case LogLevel2.Trace:
580309
+ case LogLevel2.Debug:
580310
+ case LogLevel2.Info:
580397
580311
  return content5;
580398
580312
  }
580399
580313
  }
@@ -580403,15 +580317,15 @@ function getDebugPrefix(log4) {
580403
580317
  }
580404
580318
  function getLogLevelAsString(logLevel) {
580405
580319
  switch (logLevel) {
580406
- case LogLevel.Trace:
580320
+ case LogLevel2.Trace:
580407
580321
  return "TRACE";
580408
- case LogLevel.Debug:
580322
+ case LogLevel2.Debug:
580409
580323
  return "DEBUG";
580410
- case LogLevel.Info:
580324
+ case LogLevel2.Info:
580411
580325
  return "INFO";
580412
- case LogLevel.Warn:
580326
+ case LogLevel2.Warn:
580413
580327
  return "WARN";
580414
- case LogLevel.Error:
580328
+ case LogLevel2.Error:
580415
580329
  return "ERROR";
580416
580330
  default:
580417
580331
  assertNever(logLevel);
@@ -606136,22 +606050,22 @@ var ErrorCollector2 = class {
606136
606050
  }
606137
606051
  switch (level) {
606138
606052
  case APIErrorLevel.ERROR:
606139
- this.logger.log(LogLevel.Debug, error50.message);
606053
+ this.logger.log(LogLevel2.Debug, error50.message);
606140
606054
  if (error50.path && error50.path.length > 0) {
606141
606055
  const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
606142
606056
  const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
606143
- this.logger.log(LogLevel.Debug, ` - at location (${locationInfo})`);
606057
+ this.logger.log(LogLevel2.Debug, ` - at location (${locationInfo})`);
606144
606058
  }
606145
606059
  break;
606146
606060
  case APIErrorLevel.WARNING:
606147
- this.logger.log(LogLevel.Warn, error50.message);
606061
+ this.logger.log(LogLevel2.Warn, error50.message);
606148
606062
  if (error50.path && error50.path.length > 0) {
606149
606063
  const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
606150
606064
  const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
606151
- this.logger.log(LogLevel.Warn, ` - at location (${locationInfo})`);
606065
+ this.logger.log(LogLevel2.Warn, ` - at location (${locationInfo})`);
606152
606066
  }
606153
606067
  if (error50.resolution) {
606154
- this.logger.log(LogLevel.Warn, ` - resolution: ${error50.resolution}`);
606068
+ this.logger.log(LogLevel2.Warn, ` - resolution: ${error50.resolution}`);
606155
606069
  }
606156
606070
  break;
606157
606071
  }
@@ -606180,7 +606094,7 @@ var BreadcrumbToLineNumber = class {
606180
606094
  jsYaml.load(fileContent, { listener: this.map.listen() });
606181
606095
  this.initialized = true;
606182
606096
  } catch (error50) {
606183
- this.logger.log(LogLevel.Warn, `Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(error50)}`);
606097
+ this.logger.log(LogLevel2.Warn, `Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(error50)}`);
606184
606098
  }
606185
606099
  }
606186
606100
  /**
@@ -619449,16 +619363,851 @@ async function runRulesOnOSSWorkspace({ workspace, context: context3, rules }) {
619449
619363
  return ruleResults.flat();
619450
619364
  }
619451
619365
 
619366
+ // ../cli-v2/lib/context/adapter/TaskContextLogger.js
619367
+ var TaskContextLogger = class {
619368
+ context;
619369
+ task;
619370
+ logLevel;
619371
+ enabled = true;
619372
+ collectedErrors = [];
619373
+ constructor({ context: context3, task, logLevel = LogLevel2.Warn }) {
619374
+ this.context = context3;
619375
+ this.task = task;
619376
+ this.logLevel = logLevel;
619377
+ }
619378
+ disable() {
619379
+ this.enabled = false;
619380
+ }
619381
+ enable() {
619382
+ this.enabled = true;
619383
+ }
619384
+ trace(..._args) {
619385
+ }
619386
+ debug(...args) {
619387
+ const message = args.join(" ");
619388
+ this.writeLog({ level: LogLevel2.Debug, message });
619389
+ if (this.shouldLogToTask(LogLevel2.Debug)) {
619390
+ if (this.task.logs == null) {
619391
+ this.task.logs = [];
619392
+ }
619393
+ this.task.logs.push({ level: "debug", message });
619394
+ }
619395
+ }
619396
+ info(...args) {
619397
+ const message = args.join(" ");
619398
+ this.writeLog({ level: LogLevel2.Info, message });
619399
+ if (this.shouldLogToTask(LogLevel2.Info)) {
619400
+ if (this.task.logs == null) {
619401
+ this.task.logs = [];
619402
+ }
619403
+ this.task.logs.push({ level: "debug", message });
619404
+ }
619405
+ }
619406
+ warn(...args) {
619407
+ const message = args.join(" ");
619408
+ this.writeLog({ level: LogLevel2.Warn, message });
619409
+ if (this.shouldLogToTask(LogLevel2.Warn)) {
619410
+ if (this.task.logs == null) {
619411
+ this.task.logs = [];
619412
+ }
619413
+ this.task.logs.push({ level: "warn", message });
619414
+ }
619415
+ }
619416
+ error(...args) {
619417
+ const message = args.join(" ");
619418
+ this.writeLog({ level: LogLevel2.Error, message });
619419
+ if (this.shouldLogToTask(LogLevel2.Error)) {
619420
+ this.collectedErrors.push(message);
619421
+ if (this.task.logs == null) {
619422
+ this.task.logs = [];
619423
+ }
619424
+ this.task.logs.push({ level: "error", message });
619425
+ }
619426
+ }
619427
+ log(level, ...args) {
619428
+ switch (level) {
619429
+ case LogLevel2.Debug:
619430
+ this.debug(...args);
619431
+ break;
619432
+ case LogLevel2.Info:
619433
+ this.info(...args);
619434
+ break;
619435
+ case LogLevel2.Warn:
619436
+ this.warn(...args);
619437
+ break;
619438
+ case LogLevel2.Error:
619439
+ this.error(...args);
619440
+ break;
619441
+ }
619442
+ }
619443
+ /**
619444
+ * Write a log entry to the log file. In CI / non-TTY environments,
619445
+ * also write directly to stderr so logs are visible in CI runner output.
619446
+ */
619447
+ writeLog({ level, message }) {
619448
+ this.context.logs.write({ taskName: this.task.name, level, message });
619449
+ if (this.context.isTTY) {
619450
+ return;
619451
+ }
619452
+ if (!this.enabled) {
619453
+ return;
619454
+ }
619455
+ const prefix2 = source_default.dim(`[${this.task.name}]`);
619456
+ switch (level) {
619457
+ case LogLevel2.Warn:
619458
+ process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
619459
+ `);
619460
+ break;
619461
+ case LogLevel2.Error:
619462
+ process.stderr.write(`${prefix2}: ${source_default.red(message)}
619463
+ `);
619464
+ break;
619465
+ default:
619466
+ process.stderr.write(`${prefix2}: ${message}
619467
+ `);
619468
+ break;
619469
+ }
619470
+ }
619471
+ /**
619472
+ * Check if a message at the given level should be logged to the task's UI.
619473
+ */
619474
+ shouldLogToTask(level) {
619475
+ return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
619476
+ }
619477
+ };
619478
+
619479
+ // ../cli-v2/lib/context/adapter/TaskContextAdapter.js
619480
+ var TaskContextAdapter = class {
619481
+ result = TaskResult.Success;
619482
+ logger;
619483
+ constructor({ context: context3, task, logLevel = LogLevel2.Warn }) {
619484
+ if (task != null) {
619485
+ this.logger = new TaskContextLogger({ context: context3, task, logLevel });
619486
+ } else {
619487
+ this.logger = createLogger4((level, ...args) => {
619488
+ if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
619489
+ context3.stderr.log(level, ...args);
619490
+ }
619491
+ });
619492
+ }
619493
+ }
619494
+ async takeOverTerminal(run) {
619495
+ await run();
619496
+ }
619497
+ failAndThrow(message, error50) {
619498
+ this.failWithoutThrowing(message, error50);
619499
+ throw new TaskAbortSignal();
619500
+ }
619501
+ failWithoutThrowing(message, error50) {
619502
+ const fullMessage = this.getFullErrorMessage(message, error50);
619503
+ if (fullMessage != null) {
619504
+ this.logger.error(fullMessage);
619505
+ }
619506
+ this.result = TaskResult.Failure;
619507
+ }
619508
+ getFullErrorMessage(message, error50) {
619509
+ const errorDetails = this.formatError(error50);
619510
+ if (message != null && errorDetails != null) {
619511
+ return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
619512
+ }
619513
+ return message ?? errorDetails;
619514
+ }
619515
+ getResult() {
619516
+ return this.result;
619517
+ }
619518
+ addInteractiveTask(_params) {
619519
+ const subtask = {
619520
+ logger: this.logger,
619521
+ takeOverTerminal: this.takeOverTerminal.bind(this),
619522
+ failAndThrow: this.failAndThrow.bind(this),
619523
+ failWithoutThrowing: this.failWithoutThrowing.bind(this),
619524
+ getResult: () => this.result,
619525
+ addInteractiveTask: this.addInteractiveTask.bind(this),
619526
+ runInteractiveTask: this.runInteractiveTask.bind(this),
619527
+ instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
619528
+ setSubtitle: (_subtitle) => {
619529
+ },
619530
+ start: () => {
619531
+ return subtask;
619532
+ },
619533
+ isStarted: () => true,
619534
+ finish: () => {
619535
+ },
619536
+ isFinished: () => true
619537
+ };
619538
+ return subtask;
619539
+ }
619540
+ async runInteractiveTask(params2, run) {
619541
+ const subtask = this.addInteractiveTask(params2).start();
619542
+ try {
619543
+ await run(subtask);
619544
+ return true;
619545
+ } catch {
619546
+ return false;
619547
+ }
619548
+ }
619549
+ instrumentPostHogEvent(_event) {
619550
+ }
619551
+ formatError(error50) {
619552
+ if (error50 == null) {
619553
+ return void 0;
619554
+ }
619555
+ if (error50 instanceof Error) {
619556
+ return error50.message;
619557
+ }
619558
+ if (typeof error50 === "string") {
619559
+ return error50;
619560
+ }
619561
+ if (typeof error50 === "object") {
619562
+ const message = this.extractErrorMessage(error50);
619563
+ if (message != null) {
619564
+ return message;
619565
+ }
619566
+ }
619567
+ try {
619568
+ return JSON.stringify(error50);
619569
+ } catch {
619570
+ return String(error50);
619571
+ }
619572
+ }
619573
+ /**
619574
+ * Attempts to extract a human-readable message from a structured error object.
619575
+ *
619576
+ * Handles common shapes from the FDR SDK and other API clients, e.g.:
619577
+ * { content: { body: { message: "..." } } }
619578
+ * { body: { message: "..." } }
619579
+ * { message: "..." }
619580
+ */
619581
+ extractErrorMessage(error50) {
619582
+ const record21 = error50;
619583
+ if (typeof record21.message === "string") {
619584
+ return record21.message;
619585
+ }
619586
+ if (record21.body != null && typeof record21.body === "object") {
619587
+ const body = record21.body;
619588
+ if (typeof body.message === "string") {
619589
+ return body.message;
619590
+ }
619591
+ }
619592
+ if (record21.content != null && typeof record21.content === "object") {
619593
+ return this.extractErrorMessage(record21.content);
619594
+ }
619595
+ return void 0;
619596
+ }
619597
+ };
619598
+
619599
+ // ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
619600
+ init_lib6();
619601
+
619602
+ // ../cli-v2/lib/api/config/OpenRpcSpec.js
619603
+ function isOpenRpcSpec(spec) {
619604
+ return "openrpc" in spec;
619605
+ }
619606
+
619607
+ // ../cli-v2/lib/api/config/ProtobufSpec.js
619608
+ function isProtobufSpec(spec) {
619609
+ return "proto" in spec;
619610
+ }
619611
+
619612
+ // ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
619613
+ var LegacyApiSpecAdapter = class {
619614
+ context;
619615
+ constructor(config5) {
619616
+ this.context = config5.context;
619617
+ }
619618
+ adapt(spec) {
619619
+ if (isOpenApiSpec(spec)) {
619620
+ return this.adaptOpenApiSpec(spec);
619621
+ }
619622
+ if (isAsyncApiSpec(spec)) {
619623
+ return this.adaptAsyncApiSpec(spec);
619624
+ }
619625
+ if (isProtobufSpec(spec)) {
619626
+ return this.adaptProtobufSpec(spec);
619627
+ }
619628
+ if (isOpenRpcSpec(spec)) {
619629
+ return this.adaptOpenRpcSpec(spec);
619630
+ }
619631
+ throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
619632
+ }
619633
+ convertAll(specs) {
619634
+ return specs.map((spec) => this.adapt(spec));
619635
+ }
619636
+ adaptOpenApiSpec(spec) {
619637
+ return {
619638
+ type: "openapi",
619639
+ absoluteFilepath: spec.openapi,
619640
+ absoluteFilepathToOverrides: spec.overrides,
619641
+ absoluteFilepathToOverlays: spec.overlays,
619642
+ namespace: spec.namespace,
619643
+ source: {
619644
+ type: "openapi",
619645
+ file: spec.openapi
619646
+ },
619647
+ settings: this.adaptOpenApiSettings(spec.settings)
619648
+ };
619649
+ }
619650
+ adaptAsyncApiSpec(spec) {
619651
+ return {
619652
+ type: "openapi",
619653
+ absoluteFilepath: spec.asyncapi,
619654
+ absoluteFilepathToOverrides: spec.overrides,
619655
+ absoluteFilepathToOverlays: void 0,
619656
+ namespace: spec.namespace,
619657
+ source: {
619658
+ type: "asyncapi",
619659
+ file: spec.asyncapi
619660
+ },
619661
+ settings: this.adaptAsyncApiSettings(spec.settings)
619662
+ };
619663
+ }
619664
+ adaptProtobufSpec(spec) {
619665
+ const proto3 = spec.proto;
619666
+ return {
619667
+ type: "protobuf",
619668
+ absoluteFilepathToProtobufRoot: proto3.root,
619669
+ absoluteFilepathToProtobufTarget: proto3.target,
619670
+ absoluteFilepathToOverrides: proto3.overrides,
619671
+ relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
619672
+ generateLocally: proto3.localGeneration ?? false,
619673
+ fromOpenAPI: proto3.fromOpenapi ?? false,
619674
+ dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
619675
+ settings: void 0
619676
+ };
619677
+ }
619678
+ adaptOpenRpcSpec(spec) {
619679
+ return {
619680
+ type: "openrpc",
619681
+ absoluteFilepath: spec.openrpc,
619682
+ absoluteFilepathToOverrides: spec.overrides,
619683
+ namespace: void 0
619684
+ };
619685
+ }
619686
+ adaptOpenApiSettings(settings) {
619687
+ if (settings == null) {
619688
+ return void 0;
619689
+ }
619690
+ const result = {
619691
+ // Base API settings
619692
+ respectNullableSchemas: settings.respectNullableSchemas,
619693
+ wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
619694
+ coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
619695
+ useTitlesAsName: settings.titleAsSchemaName,
619696
+ coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
619697
+ optionalAdditionalProperties: settings.optionalAdditionalProperties,
619698
+ shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
619699
+ groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
619700
+ removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
619701
+ pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
619702
+ // OpenAPI-specific settings
619703
+ respectReadonlySchemas: settings.respectReadonlySchemas,
619704
+ onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
619705
+ inlinePathParameters: settings.inlinePathParameters,
619706
+ shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
619707
+ objectQueryParameters: settings.objectQueryParameters,
619708
+ respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
619709
+ useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
619710
+ defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
619711
+ filter: settings.filter,
619712
+ exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
619713
+ additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
619714
+ typeDatesAsStrings: settings.typeDatesAsStrings,
619715
+ preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
619716
+ inlineAllOfSchemas: settings.inlineAllOfSchemas,
619717
+ resolveAliases: settings.resolveAliases,
619718
+ groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
619719
+ defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
619720
+ coerceConstsTo: settings.coerceConstsTo
619721
+ };
619722
+ const hasSettings = Object.values(result).some((v23) => v23 != null);
619723
+ return hasSettings ? result : void 0;
619724
+ }
619725
+ adaptAsyncApiSettings(settings) {
619726
+ if (settings == null) {
619727
+ return void 0;
619728
+ }
619729
+ const result = {
619730
+ // Base API settings (shared)
619731
+ respectNullableSchemas: settings.respectNullableSchemas,
619732
+ wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
619733
+ coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
619734
+ useTitlesAsName: settings.titleAsSchemaName,
619735
+ coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
619736
+ optionalAdditionalProperties: settings.optionalAdditionalProperties,
619737
+ shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
619738
+ groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
619739
+ removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
619740
+ pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
619741
+ // AsyncAPI-specific settings
619742
+ asyncApiNaming: settings.messageNaming,
619743
+ coerceConstsTo: settings.coerceConstsTo
619744
+ };
619745
+ const hasSettings = Object.values(result).some((v23) => v23 != null);
619746
+ return hasSettings ? result : void 0;
619747
+ }
619748
+ adaptRemoveDiscriminantsFromSchemas(value) {
619749
+ if (value == null) {
619750
+ return void 0;
619751
+ }
619752
+ switch (value) {
619753
+ case "always":
619754
+ return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
619755
+ case "never":
619756
+ return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
619757
+ default:
619758
+ return void 0;
619759
+ }
619760
+ }
619761
+ adaptPathParameterOrder(value) {
619762
+ if (value == null) {
619763
+ return void 0;
619764
+ }
619765
+ switch (value) {
619766
+ case "urlOrder":
619767
+ return generators_yml_exports.PathParameterOrder.UrlOrder;
619768
+ case "specOrder":
619769
+ return generators_yml_exports.PathParameterOrder.SpecOrder;
619770
+ default:
619771
+ return void 0;
619772
+ }
619773
+ }
619774
+ adaptDefaultIntegerFormat(value) {
619775
+ if (value == null) {
619776
+ return void 0;
619777
+ }
619778
+ switch (value) {
619779
+ case "int32":
619780
+ return generators_yml_exports.DefaultIntegerFormat.Int32;
619781
+ case "int64":
619782
+ return generators_yml_exports.DefaultIntegerFormat.Int64;
619783
+ case "uint32":
619784
+ return generators_yml_exports.DefaultIntegerFormat.Uint32;
619785
+ case "uint64":
619786
+ return generators_yml_exports.DefaultIntegerFormat.Uint64;
619787
+ default:
619788
+ return void 0;
619789
+ }
619790
+ }
619791
+ adaptExampleGeneration(value) {
619792
+ if (value == null) {
619793
+ return void 0;
619794
+ }
619795
+ const result = {};
619796
+ if (value.request != null) {
619797
+ result.request = { "max-depth": value.request.maxDepth };
619798
+ }
619799
+ if (value.response != null) {
619800
+ result.response = { "max-depth": value.response.maxDepth };
619801
+ }
619802
+ return result;
619803
+ }
619804
+ };
619805
+
619806
+ // ../cli-v2/lib/api/config/ConjureSpec.js
619807
+ function isConjureSpec(spec) {
619808
+ return "conjure" in spec;
619809
+ }
619810
+
619811
+ // ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
619812
+ var ApiDefinitionValidator = class {
619813
+ context;
619814
+ taskContext;
619815
+ cliVersion;
619816
+ constructor(config5) {
619817
+ this.context = config5.context;
619818
+ this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
619819
+ this.cliVersion = config5.cliVersion;
619820
+ }
619821
+ /**
619822
+ * Validate an ApiDefinition.
619823
+ *
619824
+ * Runs both Fern definition validation and OSS workspace validation
619825
+ * to ensure the API definition is valid before generation.
619826
+ */
619827
+ async validate(definition3) {
619828
+ const startTime = performance.now();
619829
+ const violations = [];
619830
+ const fernSpec = definition3.specs.find(isFernSpec);
619831
+ if (fernSpec != null) {
619832
+ const fernViolations = await this.validateFernSpec(fernSpec);
619833
+ violations.push(...fernViolations);
619834
+ return {
619835
+ violations,
619836
+ hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
619837
+ workspaceRoot: fernSpec.fern,
619838
+ elapsedMillis: performance.now() - startTime
619839
+ };
619840
+ }
619841
+ const conjureSpec = definition3.specs.find(isConjureSpec);
619842
+ if (conjureSpec != null) {
619843
+ return {
619844
+ violations: [],
619845
+ hasErrors: false,
619846
+ workspaceRoot: this.context.cwd,
619847
+ elapsedMillis: performance.now() - startTime
619848
+ };
619849
+ }
619850
+ const ossViolations = await this.validateOssSpecs(definition3.specs);
619851
+ violations.push(...ossViolations);
619852
+ return {
619853
+ violations,
619854
+ hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
619855
+ workspaceRoot: this.context.cwd,
619856
+ elapsedMillis: performance.now() - startTime
619857
+ };
619858
+ }
619859
+ async validateFernSpec(spec) {
619860
+ const violations = [];
619861
+ const lazyWorkspace = new LazyFernWorkspace({
619862
+ absoluteFilePath: dirname6(spec.fern),
619863
+ context: this.taskContext,
619864
+ cliVersion: this.cliVersion,
619865
+ generatorsConfiguration: void 0,
619866
+ workspaceName: void 0,
619867
+ changelog: void 0
619868
+ });
619869
+ const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
619870
+ const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
619871
+ violations.push(...fernViolations);
619872
+ return violations;
619873
+ }
619874
+ async validateOssSpecs(specs) {
619875
+ const violations = [];
619876
+ const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
619877
+ if (ossSpecs.length === 0) {
619878
+ return violations;
619879
+ }
619880
+ const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
619881
+ const v1Specs = specAdapter.convertAll(ossSpecs);
619882
+ const filteredSpecs = v1Specs.filter((spec) => {
619883
+ if (spec.type === "openrpc") {
619884
+ return false;
619885
+ }
619886
+ if (spec.type === "protobuf" && !spec.fromOpenAPI) {
619887
+ return false;
619888
+ }
619889
+ return true;
619890
+ });
619891
+ const allSpecs = v1Specs.filter((spec) => {
619892
+ if (spec.type === "protobuf" && spec.fromOpenAPI) {
619893
+ return false;
619894
+ }
619895
+ return true;
619896
+ });
619897
+ const ossWorkspace = new OSSWorkspace({
619898
+ specs: filteredSpecs,
619899
+ allSpecs,
619900
+ absoluteFilePath: this.context.cwd,
619901
+ cliVersion: this.cliVersion,
619902
+ changelog: void 0,
619903
+ generatorsConfiguration: void 0,
619904
+ workspaceName: void 0
619905
+ });
619906
+ const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
619907
+ const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
619908
+ violations.push(...fernViolations);
619909
+ const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
619910
+ violations.push(...ossViolations);
619911
+ return violations;
619912
+ }
619913
+ };
619914
+
619915
+ // ../cli-v2/lib/api/checker/ApiChecker.js
619916
+ var ApiChecker = class {
619917
+ context;
619918
+ cliVersion;
619919
+ task;
619920
+ constructor(config5) {
619921
+ this.context = config5.context;
619922
+ this.cliVersion = config5.cliVersion;
619923
+ this.task = config5.task;
619924
+ }
619925
+ /**
619926
+ * Check APIs in the workspace and display results.
619927
+ *
619928
+ * @param strict - If true, display all warnings and treat them as errors. If false,
619929
+ * only show errors but still report warning count in summary.
619930
+ */
619931
+ async check({ workspace, apiNames, strict = false }) {
619932
+ const startTime = performance.now();
619933
+ const validApis = /* @__PURE__ */ new Set();
619934
+ const invalidApis = /* @__PURE__ */ new Set();
619935
+ const apisToCheck = apiNames ?? Object.keys(workspace.apis);
619936
+ if (apisToCheck.length === 0) {
619937
+ return {
619938
+ validApis,
619939
+ invalidApis,
619940
+ violations: [],
619941
+ errorCount: 0,
619942
+ warningCount: 0,
619943
+ elapsedMillis: performance.now() - startTime
619944
+ };
619945
+ }
619946
+ const validator = new ApiDefinitionValidator({
619947
+ context: this.context,
619948
+ cliVersion: this.cliVersion,
619949
+ task: this.task
619950
+ });
619951
+ const allViolations = [];
619952
+ for (const apiName of apisToCheck) {
619953
+ const apiDefinition = workspace.apis[apiName];
619954
+ if (apiDefinition == null) {
619955
+ invalidApis.add(apiName);
619956
+ continue;
619957
+ }
619958
+ const result = await validator.validate(apiDefinition);
619959
+ if (result.hasErrors) {
619960
+ invalidApis.add(apiName);
619961
+ } else {
619962
+ validApis.add(apiName);
619963
+ }
619964
+ const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
619965
+ const resolvedViolations = this.resolveViolationPaths({
619966
+ workspaceRoot: result.workspaceRoot,
619967
+ apiName,
619968
+ apiSpecType,
619969
+ apiDefinition,
619970
+ violations: result.violations
619971
+ });
619972
+ allViolations.push(...resolvedViolations);
619973
+ }
619974
+ const dedupedViolations = this.deduplicateViolations(allViolations);
619975
+ return {
619976
+ ...this.countViolations(dedupedViolations),
619977
+ validApis,
619978
+ invalidApis,
619979
+ violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
619980
+ elapsedMillis: performance.now() - startTime
619981
+ };
619982
+ }
619983
+ resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
619984
+ return violations.map((violation) => {
619985
+ const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
619986
+ return {
619987
+ ...violation,
619988
+ message,
619989
+ displayRelativeFilepath: this.resolveDisplayPath({
619990
+ workspaceRoot,
619991
+ apiDefinition,
619992
+ apiSpecType,
619993
+ violation
619994
+ }),
619995
+ apiSpecType,
619996
+ apiName,
619997
+ // We don't actually surface valuable line/column information yet, but
619998
+ // this at least points to the correct file.
619999
+ line: 1,
620000
+ column: 1
620001
+ };
620002
+ });
620003
+ }
620004
+ /**
620005
+ * Format a violation message for non-Fern (OSS) specs.
620006
+ *
620007
+ * Prepends a human-readable node path so users can locate the endpoint,
620008
+ * then strips synthetic file paths from the body of the message.
620009
+ */
620010
+ formatOssMessage(violation) {
620011
+ const strippedMessage = this.stripSyntheticFilePaths(violation.message);
620012
+ const nodePathPrefix = this.formatNodePath(violation.nodePath);
620013
+ if (nodePathPrefix.length === 0) {
620014
+ return strippedMessage;
620015
+ }
620016
+ return `${nodePathPrefix} - ${strippedMessage}`;
620017
+ }
620018
+ /**
620019
+ * Formats a NodePath into a readable string like "endpoints -> getUser".
620020
+ *
620021
+ * Skips the leading "service" segment since it's implicit.
620022
+ */
620023
+ formatNodePath(nodePath) {
620024
+ const parts = [];
620025
+ for (const item of nodePath) {
620026
+ if (typeof item === "string") {
620027
+ parts.push(item);
620028
+ } else {
620029
+ parts.push(item.key);
620030
+ }
620031
+ }
620032
+ if (parts[0] === "service") {
620033
+ parts.shift();
620034
+ }
620035
+ return parts.join(" -> ");
620036
+ }
620037
+ resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
620038
+ if (apiSpecType === "fern") {
620039
+ const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
620040
+ return relativize(this.context.cwd, absolutePath);
620041
+ }
620042
+ return this.resolveOssDisplayPath(apiDefinition, violation);
620043
+ }
620044
+ resolveOssDisplayPath(apiDefinition, violation) {
620045
+ const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
620046
+ if (ossSpecs.length === 0) {
620047
+ return violation.relativeFilepath;
620048
+ }
620049
+ if (ossSpecs.length > 1) {
620050
+ for (const spec of ossSpecs) {
620051
+ const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
620052
+ if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
620053
+ const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
620054
+ return relativize(this.context.cwd, filePath2);
620055
+ }
620056
+ }
620057
+ }
620058
+ const firstSpec = ossSpecs[0];
620059
+ if (firstSpec == null) {
620060
+ return violation.relativeFilepath;
620061
+ }
620062
+ const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
620063
+ return relativize(this.context.cwd, filePath);
620064
+ }
620065
+ deduplicateViolations(violations) {
620066
+ const seen = /* @__PURE__ */ new Set();
620067
+ return violations.filter((v23) => {
620068
+ const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
620069
+ if (seen.has(key2)) {
620070
+ return false;
620071
+ }
620072
+ seen.add(key2);
620073
+ return true;
620074
+ });
620075
+ }
620076
+ /**
620077
+ * Strip synthetic file path references from violation messages for non-Fern specs.
620078
+ *
620079
+ * The validator produces messages like:
620080
+ * "- pet.yml -> getPetById /pet/{petId}"
620081
+ * For non-Fern specs these file names are synthetic (they don't exist on disk),
620082
+ * so we strip them to produce:
620083
+ * "- getPetById /pet/{petId}"
620084
+ */
620085
+ stripSyntheticFilePaths(message) {
620086
+ return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
620087
+ }
620088
+ countViolations(violations) {
620089
+ let errorCount = 0;
620090
+ let warningCount = 0;
620091
+ for (const violation of violations) {
620092
+ switch (violation.severity) {
620093
+ case "fatal":
620094
+ case "error":
620095
+ errorCount++;
620096
+ break;
620097
+ case "warning":
620098
+ warningCount++;
620099
+ break;
620100
+ default:
620101
+ assertNever(violation.severity);
620102
+ }
620103
+ }
620104
+ return { errorCount, warningCount };
620105
+ }
620106
+ };
620107
+
620108
+ // ../cli-v2/lib/errors/CliError.js
620109
+ var CliError = class _CliError extends Error {
620110
+ code;
620111
+ docsLink;
620112
+ constructor({ message, code: code5, docsLink }) {
620113
+ super(message);
620114
+ this.code = code5;
620115
+ this.docsLink = docsLink;
620116
+ }
620117
+ static authRequired(message) {
620118
+ return new _CliError({
620119
+ message: message ?? "Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable.",
620120
+ code: "AUTH_REQUIRED"
620121
+ });
620122
+ }
620123
+ static generationFailed(message) {
620124
+ return new _CliError({
620125
+ message: message ?? "Generation failed. Please check the logs for more information.",
620126
+ code: "GENERATION_FAILED"
620127
+ });
620128
+ }
620129
+ static badRequest(message) {
620130
+ return new _CliError({ message, code: "BAD_REQUEST_ERROR" });
620131
+ }
620132
+ static notFound(message) {
620133
+ return new _CliError({ message, code: "NOT_FOUND_ERROR" });
620134
+ }
620135
+ static unauthorized(message) {
620136
+ return new _CliError({
620137
+ message: message ?? "Unauthorized. Please run 'fern auth login' or set the FERN_TOKEN environment variable.",
620138
+ code: "UNAUTHORIZED_ERROR"
620139
+ });
620140
+ }
620141
+ static validationError(message) {
620142
+ return new _CliError({ message, code: "VALIDATION_ERROR" });
620143
+ }
620144
+ static internalError(message) {
620145
+ return new _CliError({ message, code: "INTERNAL_ERROR" });
620146
+ }
620147
+ /**
620148
+ * A sentinel error that causes the CLI to exit with a non-zero exit code, but no message. This
620149
+ * is useful when a command handles the failure message itself.
620150
+ */
620151
+ static exit() {
620152
+ return new _CliError({
620153
+ message: "",
620154
+ code: "EXIT"
620155
+ });
620156
+ }
620157
+ };
620158
+
620159
+ // ../cli-v2/lib/ui/format.js
620160
+ function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
620161
+ if (text9 == null) {
620162
+ return "";
620163
+ }
620164
+ const lines = text9.split("\n").filter((line) => line.trim().length > 0);
620165
+ if (lines.length === 0) {
620166
+ return "";
620167
+ }
620168
+ const baseIndentStr = " ".repeat(baseIndent);
620169
+ const contIndentStr = " ".repeat(continuationIndent);
620170
+ if (icon != null) {
620171
+ const [first3, ...rest] = lines;
620172
+ const firstLine = `
620173
+ ${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
620174
+ const restLines = rest.map((line) => `
620175
+ ${contIndentStr}${colorFn(line)}`).join("");
620176
+ return firstLine + restLines;
620177
+ }
620178
+ return lines.map((line) => `
620179
+ ${baseIndentStr}${colorFn(line)}`).join("");
620180
+ }
620181
+ var Icons = {
620182
+ error: source_default.red("\u2717"),
620183
+ warning: source_default.yellow("\u26A0"),
620184
+ success: source_default.green("\u2713"),
620185
+ info: source_default.cyan("\u25C6")
620186
+ };
620187
+ var Colors = {
620188
+ error: source_default.red.bind(source_default),
620189
+ warning: source_default.yellow.bind(source_default),
620190
+ success: source_default.green.bind(source_default),
620191
+ info: source_default.cyan.bind(source_default),
620192
+ dim: source_default.dim.bind(source_default)
620193
+ };
620194
+ function formatBytes(bytes) {
620195
+ if (bytes === 0) {
620196
+ return "0 B";
620197
+ }
620198
+ const units = ["B", "KB", "MB", "GB"];
620199
+ const base4 = 1024;
620200
+ const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
620201
+ const value = bytes / Math.pow(base4, index3);
620202
+ return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
620203
+ }
620204
+
619452
620205
  // ../cli-v2/lib/auth/errors/KeyringUnavailableError.js
619453
- var KeyringUnavailableError = class _KeyringUnavailableError extends CliError {
620206
+ var KeyringUnavailableError = class extends Error {
619454
620207
  platform;
619455
620208
  cause;
619456
620209
  constructor(platform3, cause) {
619457
- super({
619458
- message: getKeyringErrorMessage(platform3),
619459
- code: CliError.Code.AuthError
619460
- });
619461
- Object.setPrototypeOf(this, _KeyringUnavailableError.prototype);
620210
+ super(getKeyringErrorMessage(platform3));
619462
620211
  this.platform = platform3;
619463
620212
  this.cause = cause;
619464
620213
  }
@@ -619515,77 +620264,23 @@ If running in a headless environment, use FERN_TOKEN instead:
619515
620264
  }
619516
620265
 
619517
620266
  // ../cli-v2/lib/errors/SourcedValidationError.js
619518
- var SourcedValidationError = class _SourcedValidationError extends CliError {
620267
+ var SourcedValidationError = class extends Error {
619519
620268
  issues;
619520
620269
  constructor(issues) {
619521
- super({
619522
- message: issues.map((issue2) => issue2.toString()).join("\n"),
619523
- code: CliError.Code.ValidationError
619524
- });
619525
- Object.setPrototypeOf(this, _SourcedValidationError.prototype);
620270
+ super(issues.map((issue2) => issue2.toString()).join("\n"));
619526
620271
  this.issues = issues;
619527
620272
  }
619528
620273
  };
619529
620274
 
619530
620275
  // ../cli-v2/lib/errors/ValidationError.js
619531
- var ValidationError = class _ValidationError extends CliError {
620276
+ var ValidationError = class extends Error {
619532
620277
  violations;
619533
620278
  constructor(violations) {
619534
- super({
619535
- message: violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"),
619536
- code: CliError.Code.ValidationError
619537
- });
619538
- Object.setPrototypeOf(this, _ValidationError.prototype);
620279
+ super(violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"));
619539
620280
  this.violations = violations;
619540
620281
  }
619541
620282
  };
619542
620283
 
619543
- // ../cli-v2/lib/ui/format.js
619544
- function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
619545
- if (text9 == null) {
619546
- return "";
619547
- }
619548
- const lines = text9.split("\n").filter((line) => line.trim().length > 0);
619549
- if (lines.length === 0) {
619550
- return "";
619551
- }
619552
- const baseIndentStr = " ".repeat(baseIndent);
619553
- const contIndentStr = " ".repeat(continuationIndent);
619554
- if (icon != null) {
619555
- const [first3, ...rest] = lines;
619556
- const firstLine = `
619557
- ${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
619558
- const restLines = rest.map((line) => `
619559
- ${contIndentStr}${colorFn(line)}`).join("");
619560
- return firstLine + restLines;
619561
- }
619562
- return lines.map((line) => `
619563
- ${baseIndentStr}${colorFn(line)}`).join("");
619564
- }
619565
- var Icons = {
619566
- error: source_default.red("\u2717"),
619567
- warning: source_default.yellow("\u26A0"),
619568
- success: source_default.green("\u2713"),
619569
- info: source_default.cyan("\u25C6")
619570
- };
619571
- var Colors = {
619572
- error: source_default.red.bind(source_default),
619573
- warning: source_default.yellow.bind(source_default),
619574
- success: source_default.green.bind(source_default),
619575
- info: source_default.cyan.bind(source_default),
619576
- dim: source_default.dim.bind(source_default)
619577
- };
619578
- function formatBytes(bytes) {
619579
- if (bytes === 0) {
619580
- return "0 B";
619581
- }
619582
- const units = ["B", "KB", "MB", "GB"];
619583
- const base4 = 1024;
619584
- const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
619585
- const value = bytes / Math.pow(base4, index3);
619586
- return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
619587
- }
619588
-
619589
620284
  // ../auth/lib/orgs/checkOrganizationMembership.js
619590
620285
  async function checkOrganizationMembership({ organization, token }) {
619591
620286
  const venus = createVenusService({ token: token.value });
@@ -627005,7 +627700,7 @@ var AccessTokenPosthogManager = class {
627005
627700
  properties: {
627006
627701
  ...event,
627007
627702
  ...event.properties,
627008
- version: "4.68.3-2-g063113b6335",
627703
+ version: "4.68.3",
627009
627704
  usingAccessToken: true
627010
627705
  }
627011
627706
  });
@@ -627059,7 +627754,7 @@ var UserPosthogManager = class {
627059
627754
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
627060
627755
  event: "CLI",
627061
627756
  properties: {
627062
- version: "4.68.3-2-g063113b6335",
627757
+ version: "4.68.3",
627063
627758
  ...event,
627064
627759
  ...event.properties,
627065
627760
  usingAccessToken: false,
@@ -630571,7 +631266,7 @@ var TelemetryClient = class _TelemetryClient {
630571
631266
  * The caller is responsible for deciding which errors are worth reporting
630572
631267
  * (see `shouldReportToSentry` in withContext.ts).
630573
631268
  */
630574
- captureException(error50, { errorCode }) {
631269
+ captureException(error50) {
630575
631270
  if (this.sentry === void 0) {
630576
631271
  return;
630577
631272
  }
@@ -630579,7 +631274,7 @@ var TelemetryClient = class _TelemetryClient {
630579
631274
  this.sentry.captureException(error50, {
630580
631275
  captureContext: {
630581
631276
  user: { id: this.distinctId },
630582
- tags: { ...this.baseTags, ...this.accumulatedTags, "error.code": errorCode }
631277
+ tags: { ...this.baseTags, ...this.accumulatedTags }
630583
631278
  }
630584
631279
  });
630585
631280
  } catch {
@@ -631479,7 +632174,6 @@ var Context = class _Context {
631479
632174
  shutdownCallbacks = [];
631480
632175
  isShuttingDown = false;
631481
632176
  logFilePathPrinted = false;
631482
- createdAt = Date.now();
631483
632177
  cwd;
631484
632178
  logLevel;
631485
632179
  info;
@@ -631497,10 +632191,10 @@ var Context = class _Context {
631497
632191
  }
631498
632192
  constructor({ cwd: cwd2, logLevel, ttyAwareLogger, telemetry }) {
631499
632193
  this.cwd = cwd2 ?? AbsoluteFilePath2.of(process.cwd());
631500
- this.logLevel = logLevel ?? LogLevel.Info;
632194
+ this.logLevel = logLevel ?? LogLevel2.Info;
631501
632195
  this.info = parseCommandInfo(process.argv);
631502
- this.stdout = createLogger((level, ...args) => this.log(level, ...args));
631503
- this.stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
632196
+ this.stdout = createLogger4((level, ...args) => this.log(level, ...args));
632197
+ this.stderr = createLogger4((level, ...args) => this.logStderr(level, ...args));
631504
632198
  this.cache = new Cache({ logger: this.stderr });
631505
632199
  this.logs = new LogFileWriter(this.cache.logs.absoluteFilePath);
631506
632200
  this.ttyAwareLogger = ttyAwareLogger;
@@ -631558,7 +632252,7 @@ var Context = class _Context {
631558
632252
  this.stderr.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
631559
632253
  this.stderr.info("");
631560
632254
  this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
631561
- throw new CliError({ code: CliError.Code.AuthError });
632255
+ throw CliError.exit();
631562
632256
  }
631563
632257
  return await this.promptAndLogin();
631564
632258
  }
@@ -631568,7 +632262,7 @@ var Context = class _Context {
631568
632262
  this.stderr.error(`${Icons.error} Your access token has expired.`);
631569
632263
  this.stderr.info("");
631570
632264
  this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
631571
- throw new CliError({ code: CliError.Code.AuthError });
632265
+ throw CliError.exit();
631572
632266
  }
631573
632267
  return await this.promptAndLogin();
631574
632268
  }
@@ -631584,7 +632278,7 @@ var Context = class _Context {
631584
632278
  }
631585
632279
  ]);
631586
632280
  if (!confirm) {
631587
- throw new CliError({ code: CliError.Code.AuthError });
632281
+ throw CliError.exit();
631588
632282
  }
631589
632283
  this.stderr.info(`${Icons.info} Opening browser to log in to Fern...`);
631590
632284
  this.stderr.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
@@ -631596,12 +632290,12 @@ var Context = class _Context {
631596
632290
  const payload = await verifyAndDecodeJwt(idToken);
631597
632291
  if (payload == null) {
631598
632292
  this.stderr.error(`${Icons.error} Internal error; could not verify ID token`);
631599
- throw new CliError({ code: CliError.Code.InternalError });
632293
+ throw CliError.exit();
631600
632294
  }
631601
632295
  const email3 = payload.email;
631602
632296
  if (email3 == null) {
631603
632297
  this.stderr.error(`${Icons.error} Internal error; ID token does not contain email claim`);
631604
- throw new CliError({ code: CliError.Code.InternalError });
632298
+ throw CliError.exit();
631605
632299
  }
631606
632300
  await this.tokenService.login(email3, accessToken);
631607
632301
  this.stderr.info(`${Icons.success} Logged in as ${source_default.bold(email3)}`);
@@ -631732,7 +632426,7 @@ ${source_default.dim(`Logs written to: ${this.logs.absoluteFilePath}`)}
631732
632426
  logImmediately(logs4, { stderr = false } = {}) {
631733
632427
  const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
631734
632428
  this.ttyAwareLogger.log(filtered, {
631735
- includeDebugInfo: this.logLevel === LogLevel.Debug,
632429
+ includeDebugInfo: this.logLevel === LogLevel2.Debug,
631736
632430
  stderr
631737
632431
  });
631738
632432
  }
@@ -631745,19 +632439,28 @@ var SIGTERM_EXIT_CODE = SIGNAL_EXIT_CODE_BASE + 15;
631745
632439
  function withContext(handler3) {
631746
632440
  return async (args) => {
631747
632441
  const context3 = await createContext(args);
632442
+ const startTime = Date.now();
631748
632443
  setupSignalHandler(context3);
631749
632444
  try {
631750
632445
  await handler3(context3, args);
631751
632446
  context3.telemetry.sendLifecycleEvent({
631752
632447
  command: context3.info.command,
631753
632448
  status: "success",
631754
- durationMs: Date.now() - context3.createdAt
632449
+ durationMs: Date.now() - startTime
631755
632450
  });
631756
632451
  await context3.telemetry.flush();
631757
632452
  context3.finish();
631758
632453
  await exitGracefully(0);
631759
632454
  } catch (error50) {
631760
- reportError(context3, error50);
632455
+ if (shouldReportToSentry(error50)) {
632456
+ context3.telemetry.captureException(error50);
632457
+ }
632458
+ context3.telemetry.sendLifecycleEvent({
632459
+ command: context3.info.command,
632460
+ status: "error",
632461
+ durationMs: Date.now() - startTime,
632462
+ errorCode: extractErrorCode(error50)
632463
+ });
631761
632464
  await context3.telemetry.flush();
631762
632465
  handleError(context3, error50);
631763
632466
  context3.finish();
@@ -631797,7 +632500,7 @@ function handleError(context3, error50) {
631797
632500
  return;
631798
632501
  }
631799
632502
  if (error50 instanceof CliError) {
631800
- if (error50.message && error50.message.length > 0) {
632503
+ if (error50.message.length > 0) {
631801
632504
  process.stderr.write(`${source_default.red(error50.message)}
631802
632505
  `);
631803
632506
  }
@@ -631806,7 +632509,7 @@ function handleError(context3, error50) {
631806
632509
  if (error50 instanceof Error) {
631807
632510
  process.stderr.write(`${source_default.red(error50.message)}
631808
632511
  `);
631809
- if (error50.stack != null && context3.logLevel === LogLevel.Debug) {
632512
+ if (error50.stack != null && context3.logLevel === LogLevel2.Debug) {
631810
632513
  process.stderr.write(`${source_default.dim(error50.stack)}
631811
632514
  `);
631812
632515
  }
@@ -631815,23 +632518,29 @@ function handleError(context3, error50) {
631815
632518
  process.stderr.write(`${source_default.red(String(error50))}
631816
632519
  `);
631817
632520
  }
631818
- function reportError(context3, error50, options2) {
632521
+ function shouldReportToSentry(error50) {
631819
632522
  if (error50 instanceof TaskAbortSignal) {
631820
- return;
632523
+ return false;
631821
632524
  }
631822
- const code5 = resolveErrorCode(error50, options2?.code);
631823
- const capturable = error50 ?? new CliError({ message: options2?.message ?? "", code: code5 });
631824
- if (shouldReportToSentry(code5)) {
631825
- context3.telemetry.captureException(capturable, {
631826
- errorCode: code5
631827
- });
632525
+ if (error50 instanceof CliError) {
632526
+ return error50.code === "INTERNAL_ERROR";
631828
632527
  }
631829
- context3.telemetry.sendLifecycleEvent({
631830
- status: "error",
631831
- command: context3.info.command,
631832
- durationMs: Date.now() - context3.createdAt,
631833
- errorCode: code5
631834
- });
632528
+ if (error50 instanceof ValidationError || error50 instanceof SourcedValidationError || error50 instanceof KeyringUnavailableError) {
632529
+ return false;
632530
+ }
632531
+ return true;
632532
+ }
632533
+ function extractErrorCode(error50) {
632534
+ if (error50 instanceof CliError && error50.code != null) {
632535
+ return error50.code;
632536
+ }
632537
+ if (error50 instanceof ValidationError || error50 instanceof SourcedValidationError) {
632538
+ return "VALIDATION_ERROR";
632539
+ }
632540
+ if (error50 instanceof KeyringUnavailableError) {
632541
+ return "UNAUTHORIZED_ERROR";
632542
+ }
632543
+ return "INTERNAL_ERROR";
631835
632544
  }
631836
632545
  function setupSignalHandler(context3) {
631837
632546
  const onSignal = (exitCode) => {
@@ -631856,771 +632565,18 @@ function exitGracefully(code5) {
631856
632565
  function parseLogLevel(level) {
631857
632566
  switch (level.toLowerCase()) {
631858
632567
  case "debug":
631859
- return LogLevel.Debug;
632568
+ return LogLevel2.Debug;
631860
632569
  case "info":
631861
- return LogLevel.Info;
632570
+ return LogLevel2.Info;
631862
632571
  case "warn":
631863
- return LogLevel.Warn;
632572
+ return LogLevel2.Warn;
631864
632573
  case "error":
631865
- return LogLevel.Error;
632574
+ return LogLevel2.Error;
631866
632575
  default:
631867
- return LogLevel.Info;
632576
+ return LogLevel2.Info;
631868
632577
  }
631869
632578
  }
631870
632579
 
631871
- // ../cli-v2/lib/context/adapter/TaskContextLogger.js
631872
- var TaskContextLogger = class {
631873
- context;
631874
- task;
631875
- logLevel;
631876
- enabled = true;
631877
- collectedErrors = [];
631878
- constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
631879
- this.context = context3;
631880
- this.task = task;
631881
- this.logLevel = logLevel;
631882
- }
631883
- disable() {
631884
- this.enabled = false;
631885
- }
631886
- enable() {
631887
- this.enabled = true;
631888
- }
631889
- trace(..._args) {
631890
- }
631891
- debug(...args) {
631892
- const message = args.join(" ");
631893
- this.writeLog({ level: LogLevel.Debug, message });
631894
- if (this.shouldLogToTask(LogLevel.Debug)) {
631895
- if (this.task.logs == null) {
631896
- this.task.logs = [];
631897
- }
631898
- this.task.logs.push({ level: "debug", message });
631899
- }
631900
- }
631901
- info(...args) {
631902
- const message = args.join(" ");
631903
- this.writeLog({ level: LogLevel.Info, message });
631904
- if (this.shouldLogToTask(LogLevel.Info)) {
631905
- if (this.task.logs == null) {
631906
- this.task.logs = [];
631907
- }
631908
- this.task.logs.push({ level: "debug", message });
631909
- }
631910
- }
631911
- warn(...args) {
631912
- const message = args.join(" ");
631913
- this.writeLog({ level: LogLevel.Warn, message });
631914
- if (this.shouldLogToTask(LogLevel.Warn)) {
631915
- if (this.task.logs == null) {
631916
- this.task.logs = [];
631917
- }
631918
- this.task.logs.push({ level: "warn", message });
631919
- }
631920
- }
631921
- error(...args) {
631922
- const message = args.join(" ");
631923
- this.writeLog({ level: LogLevel.Error, message });
631924
- if (this.shouldLogToTask(LogLevel.Error)) {
631925
- this.collectedErrors.push(message);
631926
- if (this.task.logs == null) {
631927
- this.task.logs = [];
631928
- }
631929
- this.task.logs.push({ level: "error", message });
631930
- }
631931
- }
631932
- log(level, ...args) {
631933
- switch (level) {
631934
- case LogLevel.Debug:
631935
- this.debug(...args);
631936
- break;
631937
- case LogLevel.Info:
631938
- this.info(...args);
631939
- break;
631940
- case LogLevel.Warn:
631941
- this.warn(...args);
631942
- break;
631943
- case LogLevel.Error:
631944
- this.error(...args);
631945
- break;
631946
- }
631947
- }
631948
- /**
631949
- * Write a log entry to the log file. In CI / non-TTY environments,
631950
- * also write directly to stderr so logs are visible in CI runner output.
631951
- */
631952
- writeLog({ level, message }) {
631953
- this.context.logs.write({ taskName: this.task.name, level, message });
631954
- if (this.context.isTTY) {
631955
- return;
631956
- }
631957
- if (!this.enabled) {
631958
- return;
631959
- }
631960
- const prefix2 = source_default.dim(`[${this.task.name}]`);
631961
- switch (level) {
631962
- case LogLevel.Warn:
631963
- process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
631964
- `);
631965
- break;
631966
- case LogLevel.Error:
631967
- process.stderr.write(`${prefix2}: ${source_default.red(message)}
631968
- `);
631969
- break;
631970
- default:
631971
- process.stderr.write(`${prefix2}: ${message}
631972
- `);
631973
- break;
631974
- }
631975
- }
631976
- /**
631977
- * Check if a message at the given level should be logged to the task's UI.
631978
- */
631979
- shouldLogToTask(level) {
631980
- return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
631981
- }
631982
- };
631983
-
631984
- // ../cli-v2/lib/context/adapter/TaskContextAdapter.js
631985
- var TaskContextAdapter = class {
631986
- result = TaskResult.Success;
631987
- context;
631988
- logger;
631989
- constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
631990
- this.context = context3;
631991
- if (task != null) {
631992
- this.logger = new TaskContextLogger({ context: context3, task, logLevel });
631993
- } else {
631994
- this.logger = createLogger((level, ...args) => {
631995
- if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
631996
- context3.stderr.log(level, ...args);
631997
- }
631998
- });
631999
- }
632000
- }
632001
- async takeOverTerminal(run) {
632002
- await run();
632003
- }
632004
- failAndThrow(message, error50, options2) {
632005
- this.failWithoutThrowing(message, error50, options2);
632006
- throw new TaskAbortSignal();
632007
- }
632008
- failWithoutThrowing(message, error50, options2) {
632009
- this.result = TaskResult.Failure;
632010
- if (error50 instanceof TaskAbortSignal) {
632011
- return;
632012
- }
632013
- const fullMessage = this.getFullErrorMessage(message, error50);
632014
- if (fullMessage != null) {
632015
- this.logger.error(fullMessage);
632016
- }
632017
- reportError(this.context, error50, { ...options2, message });
632018
- }
632019
- captureException(error50, code5) {
632020
- const errorCode = resolveErrorCode(error50, code5);
632021
- this.context.telemetry.captureException(error50, { errorCode });
632022
- }
632023
- getFullErrorMessage(message, error50) {
632024
- const errorDetails = this.formatError(error50);
632025
- if (message != null && errorDetails != null) {
632026
- return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
632027
- }
632028
- return message ?? errorDetails;
632029
- }
632030
- getResult() {
632031
- return this.result;
632032
- }
632033
- addInteractiveTask(_params) {
632034
- const subtask = {
632035
- logger: this.logger,
632036
- takeOverTerminal: this.takeOverTerminal.bind(this),
632037
- failAndThrow: this.failAndThrow.bind(this),
632038
- failWithoutThrowing: this.failWithoutThrowing.bind(this),
632039
- captureException: this.captureException.bind(this),
632040
- getResult: () => this.result,
632041
- addInteractiveTask: this.addInteractiveTask.bind(this),
632042
- runInteractiveTask: this.runInteractiveTask.bind(this),
632043
- instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
632044
- setSubtitle: (_subtitle) => {
632045
- },
632046
- start: () => {
632047
- return subtask;
632048
- },
632049
- isStarted: () => true,
632050
- finish: () => {
632051
- },
632052
- isFinished: () => true
632053
- };
632054
- return subtask;
632055
- }
632056
- async runInteractiveTask(params2, run) {
632057
- const subtask = this.addInteractiveTask(params2).start();
632058
- try {
632059
- await run(subtask);
632060
- return true;
632061
- } catch {
632062
- return false;
632063
- }
632064
- }
632065
- instrumentPostHogEvent(_event) {
632066
- }
632067
- formatError(error50) {
632068
- if (error50 == null) {
632069
- return void 0;
632070
- }
632071
- if (error50 instanceof Error) {
632072
- return error50.message;
632073
- }
632074
- if (typeof error50 === "string") {
632075
- return error50;
632076
- }
632077
- if (typeof error50 === "object") {
632078
- const message = this.extractErrorMessage(error50);
632079
- if (message != null) {
632080
- return message;
632081
- }
632082
- }
632083
- try {
632084
- return JSON.stringify(error50);
632085
- } catch {
632086
- return String(error50);
632087
- }
632088
- }
632089
- /**
632090
- * Attempts to extract a human-readable message from a structured error object.
632091
- *
632092
- * Handles common shapes from the FDR SDK and other API clients, e.g.:
632093
- * { content: { body: { message: "..." } } }
632094
- * { body: { message: "..." } }
632095
- * { message: "..." }
632096
- */
632097
- extractErrorMessage(error50) {
632098
- const record21 = error50;
632099
- if (typeof record21.message === "string") {
632100
- return record21.message;
632101
- }
632102
- if (record21.body != null && typeof record21.body === "object") {
632103
- const body = record21.body;
632104
- if (typeof body.message === "string") {
632105
- return body.message;
632106
- }
632107
- }
632108
- if (record21.content != null && typeof record21.content === "object") {
632109
- return this.extractErrorMessage(record21.content);
632110
- }
632111
- return void 0;
632112
- }
632113
- };
632114
-
632115
- // ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
632116
- init_lib6();
632117
-
632118
- // ../cli-v2/lib/api/config/OpenRpcSpec.js
632119
- function isOpenRpcSpec(spec) {
632120
- return "openrpc" in spec;
632121
- }
632122
-
632123
- // ../cli-v2/lib/api/config/ProtobufSpec.js
632124
- function isProtobufSpec(spec) {
632125
- return "proto" in spec;
632126
- }
632127
-
632128
- // ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
632129
- var LegacyApiSpecAdapter = class {
632130
- context;
632131
- constructor(config5) {
632132
- this.context = config5.context;
632133
- }
632134
- adapt(spec) {
632135
- if (isOpenApiSpec(spec)) {
632136
- return this.adaptOpenApiSpec(spec);
632137
- }
632138
- if (isAsyncApiSpec(spec)) {
632139
- return this.adaptAsyncApiSpec(spec);
632140
- }
632141
- if (isProtobufSpec(spec)) {
632142
- return this.adaptProtobufSpec(spec);
632143
- }
632144
- if (isOpenRpcSpec(spec)) {
632145
- return this.adaptOpenRpcSpec(spec);
632146
- }
632147
- throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
632148
- }
632149
- convertAll(specs) {
632150
- return specs.map((spec) => this.adapt(spec));
632151
- }
632152
- adaptOpenApiSpec(spec) {
632153
- return {
632154
- type: "openapi",
632155
- absoluteFilepath: spec.openapi,
632156
- absoluteFilepathToOverrides: spec.overrides,
632157
- absoluteFilepathToOverlays: spec.overlays,
632158
- namespace: spec.namespace,
632159
- source: {
632160
- type: "openapi",
632161
- file: spec.openapi
632162
- },
632163
- settings: this.adaptOpenApiSettings(spec.settings)
632164
- };
632165
- }
632166
- adaptAsyncApiSpec(spec) {
632167
- return {
632168
- type: "openapi",
632169
- absoluteFilepath: spec.asyncapi,
632170
- absoluteFilepathToOverrides: spec.overrides,
632171
- absoluteFilepathToOverlays: void 0,
632172
- namespace: spec.namespace,
632173
- source: {
632174
- type: "asyncapi",
632175
- file: spec.asyncapi
632176
- },
632177
- settings: this.adaptAsyncApiSettings(spec.settings)
632178
- };
632179
- }
632180
- adaptProtobufSpec(spec) {
632181
- const proto3 = spec.proto;
632182
- return {
632183
- type: "protobuf",
632184
- absoluteFilepathToProtobufRoot: proto3.root,
632185
- absoluteFilepathToProtobufTarget: proto3.target,
632186
- absoluteFilepathToOverrides: proto3.overrides,
632187
- relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
632188
- generateLocally: proto3.localGeneration ?? false,
632189
- fromOpenAPI: proto3.fromOpenapi ?? false,
632190
- dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
632191
- settings: void 0
632192
- };
632193
- }
632194
- adaptOpenRpcSpec(spec) {
632195
- return {
632196
- type: "openrpc",
632197
- absoluteFilepath: spec.openrpc,
632198
- absoluteFilepathToOverrides: spec.overrides,
632199
- namespace: void 0
632200
- };
632201
- }
632202
- adaptOpenApiSettings(settings) {
632203
- if (settings == null) {
632204
- return void 0;
632205
- }
632206
- const result = {
632207
- // Base API settings
632208
- respectNullableSchemas: settings.respectNullableSchemas,
632209
- wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
632210
- coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
632211
- useTitlesAsName: settings.titleAsSchemaName,
632212
- coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
632213
- optionalAdditionalProperties: settings.optionalAdditionalProperties,
632214
- shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
632215
- groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
632216
- removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
632217
- pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
632218
- // OpenAPI-specific settings
632219
- respectReadonlySchemas: settings.respectReadonlySchemas,
632220
- onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
632221
- inlinePathParameters: settings.inlinePathParameters,
632222
- shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
632223
- objectQueryParameters: settings.objectQueryParameters,
632224
- respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
632225
- useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
632226
- defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
632227
- filter: settings.filter,
632228
- exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
632229
- additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
632230
- typeDatesAsStrings: settings.typeDatesAsStrings,
632231
- preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
632232
- inlineAllOfSchemas: settings.inlineAllOfSchemas,
632233
- resolveAliases: settings.resolveAliases,
632234
- groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
632235
- defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
632236
- coerceConstsTo: settings.coerceConstsTo
632237
- };
632238
- const hasSettings = Object.values(result).some((v23) => v23 != null);
632239
- return hasSettings ? result : void 0;
632240
- }
632241
- adaptAsyncApiSettings(settings) {
632242
- if (settings == null) {
632243
- return void 0;
632244
- }
632245
- const result = {
632246
- // Base API settings (shared)
632247
- respectNullableSchemas: settings.respectNullableSchemas,
632248
- wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
632249
- coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
632250
- useTitlesAsName: settings.titleAsSchemaName,
632251
- coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
632252
- optionalAdditionalProperties: settings.optionalAdditionalProperties,
632253
- shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
632254
- groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
632255
- removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
632256
- pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
632257
- // AsyncAPI-specific settings
632258
- asyncApiNaming: settings.messageNaming,
632259
- coerceConstsTo: settings.coerceConstsTo
632260
- };
632261
- const hasSettings = Object.values(result).some((v23) => v23 != null);
632262
- return hasSettings ? result : void 0;
632263
- }
632264
- adaptRemoveDiscriminantsFromSchemas(value) {
632265
- if (value == null) {
632266
- return void 0;
632267
- }
632268
- switch (value) {
632269
- case "always":
632270
- return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
632271
- case "never":
632272
- return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
632273
- default:
632274
- return void 0;
632275
- }
632276
- }
632277
- adaptPathParameterOrder(value) {
632278
- if (value == null) {
632279
- return void 0;
632280
- }
632281
- switch (value) {
632282
- case "urlOrder":
632283
- return generators_yml_exports.PathParameterOrder.UrlOrder;
632284
- case "specOrder":
632285
- return generators_yml_exports.PathParameterOrder.SpecOrder;
632286
- default:
632287
- return void 0;
632288
- }
632289
- }
632290
- adaptDefaultIntegerFormat(value) {
632291
- if (value == null) {
632292
- return void 0;
632293
- }
632294
- switch (value) {
632295
- case "int32":
632296
- return generators_yml_exports.DefaultIntegerFormat.Int32;
632297
- case "int64":
632298
- return generators_yml_exports.DefaultIntegerFormat.Int64;
632299
- case "uint32":
632300
- return generators_yml_exports.DefaultIntegerFormat.Uint32;
632301
- case "uint64":
632302
- return generators_yml_exports.DefaultIntegerFormat.Uint64;
632303
- default:
632304
- return void 0;
632305
- }
632306
- }
632307
- adaptExampleGeneration(value) {
632308
- if (value == null) {
632309
- return void 0;
632310
- }
632311
- const result = {};
632312
- if (value.request != null) {
632313
- result.request = { "max-depth": value.request.maxDepth };
632314
- }
632315
- if (value.response != null) {
632316
- result.response = { "max-depth": value.response.maxDepth };
632317
- }
632318
- return result;
632319
- }
632320
- };
632321
-
632322
- // ../cli-v2/lib/api/config/ConjureSpec.js
632323
- function isConjureSpec(spec) {
632324
- return "conjure" in spec;
632325
- }
632326
-
632327
- // ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
632328
- var ApiDefinitionValidator = class {
632329
- context;
632330
- taskContext;
632331
- cliVersion;
632332
- constructor(config5) {
632333
- this.context = config5.context;
632334
- this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
632335
- this.cliVersion = config5.cliVersion;
632336
- }
632337
- /**
632338
- * Validate an ApiDefinition.
632339
- *
632340
- * Runs both Fern definition validation and OSS workspace validation
632341
- * to ensure the API definition is valid before generation.
632342
- */
632343
- async validate(definition3) {
632344
- const startTime = performance.now();
632345
- const violations = [];
632346
- const fernSpec = definition3.specs.find(isFernSpec);
632347
- if (fernSpec != null) {
632348
- const fernViolations = await this.validateFernSpec(fernSpec);
632349
- violations.push(...fernViolations);
632350
- return {
632351
- violations,
632352
- hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
632353
- workspaceRoot: fernSpec.fern,
632354
- elapsedMillis: performance.now() - startTime
632355
- };
632356
- }
632357
- const conjureSpec = definition3.specs.find(isConjureSpec);
632358
- if (conjureSpec != null) {
632359
- return {
632360
- violations: [],
632361
- hasErrors: false,
632362
- workspaceRoot: this.context.cwd,
632363
- elapsedMillis: performance.now() - startTime
632364
- };
632365
- }
632366
- const ossViolations = await this.validateOssSpecs(definition3.specs);
632367
- violations.push(...ossViolations);
632368
- return {
632369
- violations,
632370
- hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
632371
- workspaceRoot: this.context.cwd,
632372
- elapsedMillis: performance.now() - startTime
632373
- };
632374
- }
632375
- async validateFernSpec(spec) {
632376
- const violations = [];
632377
- const lazyWorkspace = new LazyFernWorkspace({
632378
- absoluteFilePath: dirname6(spec.fern),
632379
- context: this.taskContext,
632380
- cliVersion: this.cliVersion,
632381
- generatorsConfiguration: void 0,
632382
- workspaceName: void 0,
632383
- changelog: void 0
632384
- });
632385
- const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
632386
- const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
632387
- violations.push(...fernViolations);
632388
- return violations;
632389
- }
632390
- async validateOssSpecs(specs) {
632391
- const violations = [];
632392
- const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
632393
- if (ossSpecs.length === 0) {
632394
- return violations;
632395
- }
632396
- const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
632397
- const v1Specs = specAdapter.convertAll(ossSpecs);
632398
- const filteredSpecs = v1Specs.filter((spec) => {
632399
- if (spec.type === "openrpc") {
632400
- return false;
632401
- }
632402
- if (spec.type === "protobuf" && !spec.fromOpenAPI) {
632403
- return false;
632404
- }
632405
- return true;
632406
- });
632407
- const allSpecs = v1Specs.filter((spec) => {
632408
- if (spec.type === "protobuf" && spec.fromOpenAPI) {
632409
- return false;
632410
- }
632411
- return true;
632412
- });
632413
- const ossWorkspace = new OSSWorkspace({
632414
- specs: filteredSpecs,
632415
- allSpecs,
632416
- absoluteFilePath: this.context.cwd,
632417
- cliVersion: this.cliVersion,
632418
- changelog: void 0,
632419
- generatorsConfiguration: void 0,
632420
- workspaceName: void 0
632421
- });
632422
- const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
632423
- const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
632424
- violations.push(...fernViolations);
632425
- const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
632426
- violations.push(...ossViolations);
632427
- return violations;
632428
- }
632429
- };
632430
-
632431
- // ../cli-v2/lib/api/checker/ApiChecker.js
632432
- var ApiChecker = class {
632433
- context;
632434
- cliVersion;
632435
- task;
632436
- constructor(config5) {
632437
- this.context = config5.context;
632438
- this.cliVersion = config5.cliVersion;
632439
- this.task = config5.task;
632440
- }
632441
- /**
632442
- * Check APIs in the workspace and display results.
632443
- *
632444
- * @param strict - If true, display all warnings and treat them as errors. If false,
632445
- * only show errors but still report warning count in summary.
632446
- */
632447
- async check({ workspace, apiNames, strict = false }) {
632448
- const startTime = performance.now();
632449
- const validApis = /* @__PURE__ */ new Set();
632450
- const invalidApis = /* @__PURE__ */ new Set();
632451
- const apisToCheck = apiNames ?? Object.keys(workspace.apis);
632452
- if (apisToCheck.length === 0) {
632453
- return {
632454
- validApis,
632455
- invalidApis,
632456
- violations: [],
632457
- errorCount: 0,
632458
- warningCount: 0,
632459
- elapsedMillis: performance.now() - startTime
632460
- };
632461
- }
632462
- const validator = new ApiDefinitionValidator({
632463
- context: this.context,
632464
- cliVersion: this.cliVersion,
632465
- task: this.task
632466
- });
632467
- const allViolations = [];
632468
- for (const apiName of apisToCheck) {
632469
- const apiDefinition = workspace.apis[apiName];
632470
- if (apiDefinition == null) {
632471
- invalidApis.add(apiName);
632472
- continue;
632473
- }
632474
- const result = await validator.validate(apiDefinition);
632475
- if (result.hasErrors) {
632476
- invalidApis.add(apiName);
632477
- } else {
632478
- validApis.add(apiName);
632479
- }
632480
- const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
632481
- const resolvedViolations = this.resolveViolationPaths({
632482
- workspaceRoot: result.workspaceRoot,
632483
- apiName,
632484
- apiSpecType,
632485
- apiDefinition,
632486
- violations: result.violations
632487
- });
632488
- allViolations.push(...resolvedViolations);
632489
- }
632490
- const dedupedViolations = this.deduplicateViolations(allViolations);
632491
- return {
632492
- ...this.countViolations(dedupedViolations),
632493
- validApis,
632494
- invalidApis,
632495
- violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
632496
- elapsedMillis: performance.now() - startTime
632497
- };
632498
- }
632499
- resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
632500
- return violations.map((violation) => {
632501
- const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
632502
- return {
632503
- ...violation,
632504
- message,
632505
- displayRelativeFilepath: this.resolveDisplayPath({
632506
- workspaceRoot,
632507
- apiDefinition,
632508
- apiSpecType,
632509
- violation
632510
- }),
632511
- apiSpecType,
632512
- apiName,
632513
- // We don't actually surface valuable line/column information yet, but
632514
- // this at least points to the correct file.
632515
- line: 1,
632516
- column: 1
632517
- };
632518
- });
632519
- }
632520
- /**
632521
- * Format a violation message for non-Fern (OSS) specs.
632522
- *
632523
- * Prepends a human-readable node path so users can locate the endpoint,
632524
- * then strips synthetic file paths from the body of the message.
632525
- */
632526
- formatOssMessage(violation) {
632527
- const strippedMessage = this.stripSyntheticFilePaths(violation.message);
632528
- const nodePathPrefix = this.formatNodePath(violation.nodePath);
632529
- if (nodePathPrefix.length === 0) {
632530
- return strippedMessage;
632531
- }
632532
- return `${nodePathPrefix} - ${strippedMessage}`;
632533
- }
632534
- /**
632535
- * Formats a NodePath into a readable string like "endpoints -> getUser".
632536
- *
632537
- * Skips the leading "service" segment since it's implicit.
632538
- */
632539
- formatNodePath(nodePath) {
632540
- const parts = [];
632541
- for (const item of nodePath) {
632542
- if (typeof item === "string") {
632543
- parts.push(item);
632544
- } else {
632545
- parts.push(item.key);
632546
- }
632547
- }
632548
- if (parts[0] === "service") {
632549
- parts.shift();
632550
- }
632551
- return parts.join(" -> ");
632552
- }
632553
- resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
632554
- if (apiSpecType === "fern") {
632555
- const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
632556
- return relativize(this.context.cwd, absolutePath);
632557
- }
632558
- return this.resolveOssDisplayPath(apiDefinition, violation);
632559
- }
632560
- resolveOssDisplayPath(apiDefinition, violation) {
632561
- const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
632562
- if (ossSpecs.length === 0) {
632563
- return violation.relativeFilepath;
632564
- }
632565
- if (ossSpecs.length > 1) {
632566
- for (const spec of ossSpecs) {
632567
- const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
632568
- if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
632569
- const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
632570
- return relativize(this.context.cwd, filePath2);
632571
- }
632572
- }
632573
- }
632574
- const firstSpec = ossSpecs[0];
632575
- if (firstSpec == null) {
632576
- return violation.relativeFilepath;
632577
- }
632578
- const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
632579
- return relativize(this.context.cwd, filePath);
632580
- }
632581
- deduplicateViolations(violations) {
632582
- const seen = /* @__PURE__ */ new Set();
632583
- return violations.filter((v23) => {
632584
- const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
632585
- if (seen.has(key2)) {
632586
- return false;
632587
- }
632588
- seen.add(key2);
632589
- return true;
632590
- });
632591
- }
632592
- /**
632593
- * Strip synthetic file path references from violation messages for non-Fern specs.
632594
- *
632595
- * The validator produces messages like:
632596
- * "- pet.yml -> getPetById /pet/{petId}"
632597
- * For non-Fern specs these file names are synthetic (they don't exist on disk),
632598
- * so we strip them to produce:
632599
- * "- getPetById /pet/{petId}"
632600
- */
632601
- stripSyntheticFilePaths(message) {
632602
- return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
632603
- }
632604
- countViolations(violations) {
632605
- let errorCount = 0;
632606
- let warningCount = 0;
632607
- for (const violation of violations) {
632608
- switch (violation.severity) {
632609
- case "fatal":
632610
- case "error":
632611
- errorCount++;
632612
- break;
632613
- case "warning":
632614
- warningCount++;
632615
- break;
632616
- default:
632617
- assertNever(violation.severity);
632618
- }
632619
- }
632620
- return { errorCount, warningCount };
632621
- }
632622
- };
632623
-
632624
632580
  // ../cli-v2/lib/commands/_internal/command.js
632625
632581
  function command2(cli, name2, description, handler3, builder) {
632626
632582
  cli.command(name2, description, (yargs) => {
@@ -632664,8 +632620,7 @@ var CheckCommand = class {
632664
632620
  if (args.api != null && workspace.apis[args.api] == null) {
632665
632621
  const availableApis = Object.keys(workspace.apis).join(", ");
632666
632622
  throw new CliError({
632667
- message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
632668
- code: CliError.Code.ConfigError
632623
+ message: `API '${args.api}' not found. Available APIs: ${availableApis}`
632669
632624
  });
632670
632625
  }
632671
632626
  const checker = new ApiChecker({ context: context3, cliVersion: workspace.cliVersion });
@@ -632679,7 +632634,7 @@ var CheckCommand = class {
632679
632634
  const response = this.buildJsonResponse({ apiCheckResult: result, hasErrors });
632680
632635
  context3.stdout.info(JSON.stringify(response, null, 2));
632681
632636
  if (hasErrors) {
632682
- throw CliError.validationError();
632637
+ throw CliError.exit();
632683
632638
  }
632684
632639
  return;
632685
632640
  }
@@ -632691,7 +632646,7 @@ var CheckCommand = class {
632691
632646
  }
632692
632647
  }
632693
632648
  if (hasErrors) {
632694
- throw CliError.validationError();
632649
+ throw CliError.exit();
632695
632650
  }
632696
632651
  if (result.warningCount > 0) {
632697
632652
  context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
@@ -759366,8 +759321,7 @@ var CompileCommand = class {
759366
759321
  if (definition3 == null) {
759367
759322
  const available2 = apiNames.join(", ");
759368
759323
  throw new CliError({
759369
- message: `API '${args.api}' not found. Available APIs: ${available2}`,
759370
- code: CliError.Code.ConfigError
759324
+ message: `API '${args.api}' not found. Available APIs: ${available2}`
759371
759325
  });
759372
759326
  }
759373
759327
  return { apiName: args.api, definition: definition3 };
@@ -759376,23 +759330,20 @@ var CompileCommand = class {
759376
759330
  const apiName = apiNames[0];
759377
759331
  if (apiName == null) {
759378
759332
  throw new CliError({
759379
- message: "Internal error; no APIs found in workspace",
759380
- code: CliError.Code.InternalError
759333
+ message: "Internal error; no APIs found in workspace"
759381
759334
  });
759382
759335
  }
759383
759336
  const definition3 = workspace.apis[apiName];
759384
759337
  if (definition3 == null) {
759385
759338
  throw new CliError({
759386
- message: `Internal error; API '${apiName}' not found in workspace`,
759387
- code: CliError.Code.InternalError
759339
+ message: `Internal error; API '${apiName}' not found in workspace`
759388
759340
  });
759389
759341
  }
759390
759342
  return { apiName, definition: definition3 };
759391
759343
  }
759392
759344
  const available = apiNames.join(", ");
759393
759345
  throw new CliError({
759394
- message: `Multiple APIs found: ${available}. Use --api to select one.`,
759395
- code: CliError.Code.ConfigError
759346
+ message: `Multiple APIs found: ${available}. Use --api to select one.`
759396
759347
  });
759397
759348
  }
759398
759349
  async checkOrThrow({ context: context3, workspace, apiName }) {
@@ -759402,7 +759353,7 @@ var CompileCommand = class {
759402
759353
  for (const violation of result.violations) {
759403
759354
  context3.stderr.error(`${violation.displayRelativeFilepath}:${violation.line}:${violation.column}: ${violation.message}`);
759404
759355
  }
759405
- throw CliError.validationError(`API '${apiName}' has ${result.violations.length} validation errors`);
759356
+ throw CliError.exit();
759406
759357
  }
759407
759358
  }
759408
759359
  async writeOutput(context3, args, object21) {
@@ -759494,8 +759445,7 @@ var FernYmlEditor = class _FernYmlEditor {
759494
759445
  const doc = document4.toJS();
759495
759446
  if (doc == null || typeof doc !== "object") {
759496
759447
  throw new CliError({
759497
- message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file.`,
759498
- code: CliError.Code.ParseError
759448
+ message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file.`
759499
759449
  });
759500
759450
  }
759501
759451
  return new _FernYmlEditor(document4, config5.fernYmlPath);
@@ -759697,8 +759647,7 @@ var FernYmlEditor = class _FernYmlEditor {
759697
759647
  const resolvedPath = join8(dirname6(this.rootFilePath), RelativeFilePath2.of(refPath));
759698
759648
  if (!await doesPathExist(resolvedPath)) {
759699
759649
  throw new CliError({
759700
- message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist.`,
759701
- code: CliError.Code.ConfigError
759650
+ message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist.`
759702
759651
  });
759703
759652
  }
759704
759653
  const refContent = await (0, import_promises50.readFile)(resolvedPath, "utf-8");
@@ -759725,8 +759674,7 @@ var FernYmlEditor = class _FernYmlEditor {
759725
759674
  const existing = section.document.getIn([...section.basePath, name2]);
759726
759675
  if (existing == null) {
759727
759676
  throw new CliError({
759728
- message: `Target '${name2}' not found in SDK configuration.`,
759729
- code: CliError.Code.ConfigError
759677
+ message: `Target '${name2}' not found in SDK configuration.`
759730
759678
  });
759731
759679
  }
759732
759680
  }
@@ -760054,9 +760002,9 @@ async function loadSpec(filepath) {
760054
760002
  contents = await (0, import_promises51.readFile)(filepath, "utf8");
760055
760003
  } catch (error50) {
760056
760004
  if (isEnoentError(error50)) {
760057
- throw new CliError({ message: `File does not exist: ${filepath}`, code: CliError.Code.ConfigError });
760005
+ throw new CliError({ message: `File does not exist: ${filepath}` });
760058
760006
  }
760059
- throw new CliError({ message: `Failed to read file: ${filepath}`, code: CliError.Code.ParseError });
760007
+ throw new CliError({ message: `Failed to read file: ${filepath}` });
760060
760008
  }
760061
760009
  return parseSpec(contents, filepath);
760062
760010
  }
@@ -760067,10 +760015,7 @@ function parseSpec(contents, filepath) {
760067
760015
  try {
760068
760016
  return jsYaml.load(contents);
760069
760017
  } catch {
760070
- throw new CliError({
760071
- message: `Failed to parse file as JSON or YAML: ${filepath}`,
760072
- code: CliError.Code.ParseError
760073
- });
760018
+ throw new CliError({ message: `Failed to parse file as JSON or YAML: ${filepath}` });
760074
760019
  }
760075
760020
  }
760076
760021
  }
@@ -760089,7 +760034,7 @@ var MergeCommand = class {
760089
760034
  async handle(context3, args) {
760090
760035
  const workspace = await context3.loadWorkspaceOrThrow();
760091
760036
  if (Object.keys(workspace.apis).length === 0) {
760092
- throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
760037
+ throw new CliError({ message: "No APIs found in workspace." });
760093
760038
  }
760094
760039
  const entries22 = filterSpecs(workspace, { api: args.api });
760095
760040
  if (entries22.length === 0) {
@@ -760101,8 +760046,7 @@ var MergeCommand = class {
760101
760046
  const fernYmlPath = workspace.absoluteFilePath;
760102
760047
  if (fernYmlPath == null) {
760103
760048
  throw new CliError({
760104
- message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
760105
- code: CliError.Code.ConfigError
760049
+ message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
760106
760050
  });
760107
760051
  }
760108
760052
  editor = await FernYmlEditor.load({ fernYmlPath });
@@ -760237,7 +760181,7 @@ var SplitCommand = class {
760237
760181
  async handle(context3, args) {
760238
760182
  const workspace = await context3.loadWorkspaceOrThrow();
760239
760183
  if (Object.keys(workspace.apis).length === 0) {
760240
- throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
760184
+ throw new CliError({ message: "No APIs found in workspace." });
760241
760185
  }
760242
760186
  const entries22 = filterSpecs(workspace, { api: args.api });
760243
760187
  if (entries22.length === 0) {
@@ -760248,8 +760192,7 @@ var SplitCommand = class {
760248
760192
  const fernYmlPath = workspace.absoluteFilePath;
760249
760193
  if (fernYmlPath == null) {
760250
760194
  throw new CliError({
760251
- message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
760252
- code: CliError.Code.ConfigError
760195
+ message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
760253
760196
  });
760254
760197
  }
760255
760198
  const editor = await FernYmlEditor.load({ fernYmlPath });
@@ -760370,8 +760313,7 @@ var SplitCommand = class {
760370
760313
  const detail = extractErrorMessage(error50);
760371
760314
  throw new CliError({
760372
760315
  message: `Failed to get file from git HEAD: ${absolutePath}. Is the file tracked by git and has at least one commit?
760373
- Cause: ${detail}`,
760374
- code: CliError.Code.ParseError
760316
+ Cause: ${detail}`
760375
760317
  });
760376
760318
  }
760377
760319
  }
@@ -760386,10 +760328,7 @@ var SplitCommand = class {
760386
760328
  function resolvePathOrThrow(context3, outputPath) {
760387
760329
  const resolved = context3.resolveOutputFilePath(outputPath);
760388
760330
  if (resolved == null) {
760389
- throw new CliError({
760390
- message: `Could not resolve output path: ${outputPath}`,
760391
- code: CliError.Code.ConfigError
760392
- });
760331
+ throw new CliError({ message: `Could not resolve output path: ${outputPath}` });
760393
760332
  }
760394
760333
  return resolved;
760395
760334
  }
@@ -760433,7 +760372,7 @@ var LoginCommand = class {
760433
760372
  context3.stdout.info("Opening browser to log in to Fern...");
760434
760373
  context3.stdout.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
760435
760374
  }
760436
- const taskContext = new TaskContextAdapter({ context: context3, logLevel: LogLevel.Info });
760375
+ const taskContext = new TaskContextAdapter({ context: context3, logLevel: LogLevel2.Info });
760437
760376
  const tokenResponse = await getTokenFromAuth0(taskContext, {
760438
760377
  useDeviceCodeFlow,
760439
760378
  forceReauth: true
@@ -760445,12 +760384,12 @@ var LoginCommand = class {
760445
760384
  const payload = await verifyAndDecodeJwt(idToken);
760446
760385
  if (payload == null) {
760447
760386
  context3.stdout.error(`${Icons.error} Internal error; could not verify ID token`);
760448
- throw CliError.internalError();
760387
+ throw CliError.exit();
760449
760388
  }
760450
760389
  const email3 = payload.email;
760451
760390
  if (email3 == null) {
760452
760391
  context3.stdout.error(`${Icons.error} Internal error; ID token does not contain email claim`);
760453
- throw CliError.internalError();
760392
+ throw CliError.exit();
760454
760393
  }
760455
760394
  const { isNew, totalAccounts } = await context3.tokenService.login(email3, accessToken);
760456
760395
  if (isNew) {
@@ -760516,7 +760455,7 @@ var LogoutCommand = class {
760516
760455
  context3.stdout.info("");
760517
760456
  if (!context3.isTTY) {
760518
760457
  context3.stdout.error(`${Icons.error} Use --force to skip confirmation in non-interactive mode`);
760519
- throw new CliError({ code: CliError.Code.ValidationError });
760458
+ throw CliError.exit();
760520
760459
  }
760521
760460
  const { confirmed } = await lib_default4.prompt([
760522
760461
  {
@@ -760537,9 +760476,7 @@ var LogoutCommand = class {
760537
760476
  const { removed, newActive } = await context3.tokenService.logout(user);
760538
760477
  if (!removed) {
760539
760478
  context3.stdout.error(`${Icons.error} Account not found: ${user}`);
760540
- throw new CliError({
760541
- code: CliError.Code.EnvironmentError
760542
- });
760479
+ throw CliError.exit();
760543
760480
  }
760544
760481
  context3.stdout.info(`${Icons.success} Logged out of ${source_default.bold(user)}`);
760545
760482
  if (newActive != null) {
@@ -760549,9 +760486,7 @@ var LogoutCommand = class {
760549
760486
  async handleLogoutInteractive(context3, accounts) {
760550
760487
  if (!context3.isTTY) {
760551
760488
  context3.stdout.error(`${Icons.error} Multiple accounts found. Use --user or --all in non-interactive mode.`);
760552
- throw new CliError({
760553
- code: CliError.Code.EnvironmentError
760554
- });
760489
+ throw CliError.exit();
760555
760490
  }
760556
760491
  const choices = accounts.map((account) => ({
760557
760492
  name: account.isActive ? `${account.user} ${source_default.dim("(active)")}` : account.user,
@@ -760707,15 +760642,13 @@ var SwitchCommand = class {
760707
760642
  context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
760708
760643
  context3.stdout.info("");
760709
760644
  context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
760710
- throw new CliError({
760711
- code: CliError.Code.ConfigError
760712
- });
760645
+ throw CliError.exit();
760713
760646
  }
760714
760647
  if (accounts.length === 1) {
760715
760648
  const account = accounts[0];
760716
760649
  if (account == null) {
760717
760650
  context3.stdout.error(`${Icons.error} Internal error; no accounts found`);
760718
- throw CliError.internalError();
760651
+ throw CliError.exit();
760719
760652
  }
760720
760653
  context3.stdout.warn(`${source_default.yellow("\u26A0")} You only have one account logged in: ${source_default.bold(account.user)}`);
760721
760654
  context3.stdout.info("");
@@ -760738,9 +760671,7 @@ var SwitchCommand = class {
760738
760671
  async handleInteractiveSwitch(context3, accounts) {
760739
760672
  if (!context3.isTTY) {
760740
760673
  context3.stdout.error(`${Icons.error} Use --user to specify account in non-interactive mode`);
760741
- throw new CliError({
760742
- code: CliError.Code.EnvironmentError
760743
- });
760674
+ throw CliError.exit();
760744
760675
  }
760745
760676
  const choices = accounts.map((account) => ({
760746
760677
  name: account.isActive ? `${account.user} ${source_default.dim("(current)")}` : account.user,
@@ -760761,9 +760692,7 @@ var SwitchCommand = class {
760761
760692
  const success2 = await context3.tokenService.switchAccount(user);
760762
760693
  if (!success2) {
760763
760694
  context3.stdout.error(`${Icons.error} Account not found: ${user}`);
760764
- throw new CliError({
760765
- code: CliError.Code.EnvironmentError
760766
- });
760695
+ throw CliError.exit();
760767
760696
  }
760768
760697
  context3.stdout.info(`${Icons.success} Switched to ${source_default.bold(user)}`);
760769
760698
  }
@@ -760800,32 +760729,24 @@ var TokenCommand = class {
760800
760729
  organizationNotFoundError: () => {
760801
760730
  process.stderr.write(`${Icons.error} Organization "${orgId}" was not found.
760802
760731
  `);
760803
- throw new CliError({
760804
- code: CliError.Code.ConfigError
760805
- });
760732
+ throw CliError.exit();
760806
760733
  },
760807
760734
  unauthorizedError: () => {
760808
760735
  process.stderr.write(`${Icons.error} You do not have access to organization "${orgId}".
760809
760736
  `);
760810
- throw new CliError({
760811
- code: CliError.Code.AuthError
760812
- });
760737
+ throw CliError.exit();
760813
760738
  },
760814
760739
  missingOrgPermissionsError: () => {
760815
760740
  process.stderr.write(`${Icons.error} You do not have the required permissions in organization "${orgId}".
760816
760741
  `);
760817
- throw new CliError({
760818
- code: CliError.Code.AuthError
760819
- });
760742
+ throw CliError.exit();
760820
760743
  },
760821
760744
  _other: () => {
760822
760745
  process.stderr.write(`${Icons.error} Failed to generate token.
760823
760746
 
760824
760747
  Please contact support@buildwithfern.com for assistance.
760825
760748
  `);
760826
- throw new CliError({
760827
- code: CliError.Code.InternalError
760828
- });
760749
+ throw CliError.exit();
760829
760750
  }
760830
760751
  });
760831
760752
  }
@@ -760841,7 +760762,7 @@ var TokenCommand = class {
760841
760762
 
760842
760763
  Run fern init or specify an organization with --org, then run this command again.
760843
760764
  `);
760844
- throw new CliError({ code: CliError.Code.ConfigError });
760765
+ throw CliError.exit();
760845
760766
  }
760846
760767
  }
760847
760768
  };
@@ -760861,7 +760782,7 @@ var WhoamiCommand = class {
760861
760782
  context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
760862
760783
  context3.stdout.info("");
760863
760784
  context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
760864
- throw new CliError({ code: CliError.Code.AuthError });
760785
+ throw CliError.exit();
760865
760786
  }
760866
760787
  if (args.json) {
760867
760788
  context3.stdout.info(JSON.stringify({ email: activeAccount.user }, null, 2));
@@ -817847,7 +817768,7 @@ function checkMissingRedirects(removedSlugs, redirects, basePath) {
817847
817768
  }
817848
817769
 
817849
817770
  // ../yaml/docs-validator/lib/rules/missing-redirects/missing-redirects.js
817850
- var NOOP_CONTEXT = createMockTaskContext({ logger: createLogger(noop2) });
817771
+ var NOOP_CONTEXT = createMockTaskContext({ logger: createLogger4(noop2) });
817851
817772
  async function fetchMarkdownEntries(fdrOrigin, domain3, basepath, authToken) {
817852
817773
  try {
817853
817774
  const response = await fetch(`${fdrOrigin}/slugs/markdowns`, {
@@ -839359,7 +839280,7 @@ function collectPathnamesToCheck(content5, { absoluteFilepath, instanceUrls }) {
839359
839280
  }
839360
839281
 
839361
839282
  // ../yaml/docs-validator/lib/rules/valid-markdown-link/valid-markdown-link.js
839362
- var NOOP_CONTEXT2 = createMockTaskContext({ logger: createLogger(noop2) });
839283
+ var NOOP_CONTEXT2 = createMockTaskContext({ logger: createLogger4(noop2) });
839363
839284
  var ValidMarkdownLinks = {
839364
839285
  name: "valid-markdown-links",
839365
839286
  create: async ({ workspace, apiWorkspaces, ossWorkspaces }) => {
@@ -840428,8 +840349,7 @@ var DocsChecker = class {
840428
840349
  const docsWorkspace = project.docsWorkspaces;
840429
840350
  if (docsWorkspace == null) {
840430
840351
  throw new CliError({
840431
- message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
840432
- code: CliError.Code.ConfigError
840352
+ message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
840433
840353
  });
840434
840354
  }
840435
840355
  const ossWorkspaces = await filterOssWorkspaces(project);
@@ -840700,12 +840620,12 @@ var CheckCommand2 = class {
840700
840620
  const response = this.buildJsonResponse({ apiCheckResult, sdkCheckResult, docsCheckResult, hasErrors });
840701
840621
  context3.stdout.info(JSON.stringify(response, null, 2));
840702
840622
  if (hasErrors) {
840703
- throw new CliError({ code: CliError.Code.ValidationError });
840623
+ throw CliError.exit();
840704
840624
  }
840705
840625
  return;
840706
840626
  }
840707
840627
  if (hasErrors) {
840708
- throw new CliError({ code: CliError.Code.ValidationError });
840628
+ throw CliError.exit();
840709
840629
  }
840710
840630
  if (totalWarnings > 0) {
840711
840631
  context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${totalWarnings} warnings`)}`);
@@ -840760,8 +840680,7 @@ var CheckCommand2 = class {
840760
840680
  if (args.api != null && workspace.apis[args.api] == null) {
840761
840681
  const availableApis = Object.keys(workspace.apis).join(", ");
840762
840682
  throw new CliError({
840763
- message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
840764
- code: CliError.Code.ConfigError
840683
+ message: `API '${args.api}' not found. Available APIs: ${availableApis}`
840765
840684
  });
840766
840685
  }
840767
840686
  }
@@ -842224,7 +842143,7 @@ var MigrateCommand = class {
842224
842143
  }
842225
842144
  return;
842226
842145
  }
842227
- throw new CliError({ message: "Migration failed", code: CliError.Code.ConfigError });
842146
+ throw new CliError({ message: "Migration failed" });
842228
842147
  }
842229
842148
  };
842230
842149
  function addMigrateCommand(cli) {
@@ -842247,8 +842166,7 @@ var CheckCommand3 = class {
842247
842166
  const workspace = await context3.loadWorkspaceOrThrow();
842248
842167
  if (workspace.docs == null) {
842249
842168
  throw new CliError({
842250
- message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
842251
- code: CliError.Code.ConfigError
842169
+ message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
842252
842170
  });
842253
842171
  }
842254
842172
  const checker = new DocsChecker({ context: context3 });
@@ -842258,7 +842176,7 @@ var CheckCommand3 = class {
842258
842176
  const response = this.buildJsonResponse({ result, hasErrors });
842259
842177
  context3.stdout.info(JSON.stringify(response, null, 2));
842260
842178
  if (hasErrors) {
842261
- throw new CliError({ code: CliError.Code.ValidationError });
842179
+ throw CliError.exit();
842262
842180
  }
842263
842181
  return;
842264
842182
  }
@@ -842270,7 +842188,7 @@ var CheckCommand3 = class {
842270
842188
  }
842271
842189
  }
842272
842190
  if (hasErrors) {
842273
- throw new CliError({ code: CliError.Code.ValidationError });
842191
+ throw CliError.exit();
842274
842192
  }
842275
842193
  if (result.warningCount > 0) {
842276
842194
  context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
@@ -844111,7 +844029,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
844111
844029
  var LOGS_FOLDER_NAME = "logs";
844112
844030
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
844113
844031
  function getCliSource() {
844114
- const version7 = "4.68.3-2-g063113b6335";
844032
+ const version7 = "4.68.3";
844115
844033
  return `cli@${version7}`;
844116
844034
  }
844117
844035
  var DebugLogger = class {
@@ -846093,8 +846011,7 @@ var DevCommand = class {
846093
846011
  const workspace = await context3.loadWorkspaceOrThrow();
846094
846012
  if (workspace.docs == null) {
846095
846013
  throw new CliError({
846096
- message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
846097
- code: CliError.Code.ConfigError
846014
+ message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
846098
846015
  });
846099
846016
  }
846100
846017
  const backendPort = args["backend-port"] ?? await getPorts();
@@ -846104,7 +846021,7 @@ var DevCommand = class {
846104
846021
  backendPort,
846105
846022
  forceDownload: args["force-download"],
846106
846023
  bundlePath: args["bundle-path"],
846107
- logLevel: LogLevel.Info
846024
+ logLevel: LogLevel2.Info
846108
846025
  });
846109
846026
  }
846110
846027
  };
@@ -846415,11 +846332,11 @@ function getSeverityForViolations(violations) {
846415
846332
  function getLogLevelForSeverity(severity) {
846416
846333
  switch (severity) {
846417
846334
  case "fatal":
846418
- return LogLevel.Error;
846335
+ return LogLevel2.Error;
846419
846336
  case "error":
846420
- return LogLevel.Error;
846337
+ return LogLevel2.Error;
846421
846338
  case "warning":
846422
- return LogLevel.Warn;
846339
+ return LogLevel2.Warn;
846423
846340
  default:
846424
846341
  assertNever(severity);
846425
846342
  }
@@ -853705,15 +853622,15 @@ async function makeWritableRecursive(dirPath) {
853705
853622
  function convertLogLevel(logLevel) {
853706
853623
  switch (logLevel) {
853707
853624
  case "DEBUG":
853708
- return LogLevel.Debug;
853625
+ return LogLevel2.Debug;
853709
853626
  case "INFO":
853710
- return LogLevel.Info;
853627
+ return LogLevel2.Info;
853711
853628
  case "WARN":
853712
- return LogLevel.Warn;
853629
+ return LogLevel2.Warn;
853713
853630
  case "ERROR":
853714
- return LogLevel.Error;
853631
+ return LogLevel2.Error;
853715
853632
  default:
853716
- return LogLevel.Info;
853633
+ return LogLevel2.Info;
853717
853634
  }
853718
853635
  }
853719
853636
  async function checkFernIgnorePresent(absolutePathToLocalOutput) {
@@ -855361,7 +855278,7 @@ var LegacyDocsPublisher = class {
855361
855278
  previewId,
855362
855279
  disableTemplates: void 0,
855363
855280
  skipUpload,
855364
- cliVersion: "4.68.3-2-g063113b6335"
855281
+ cliVersion: "4.68.3"
855365
855282
  });
855366
855283
  if (taskContext.getResult() === TaskResult.Failure) {
855367
855284
  return { success: false };
@@ -855954,8 +855871,7 @@ var PublishCommand = class {
855954
855871
  const workspace = await context3.loadWorkspaceOrThrow();
855955
855872
  if (workspace.docs == null) {
855956
855873
  throw new CliError({
855957
- message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
855958
- code: CliError.Code.ConfigError
855874
+ message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
855959
855875
  });
855960
855876
  }
855961
855877
  const instanceUrl = this.resolveInstanceUrl({
@@ -855974,8 +855890,7 @@ var PublishCommand = class {
855974
855890
  const docsWorkspace = project.docsWorkspaces;
855975
855891
  if (docsWorkspace == null) {
855976
855892
  throw new CliError({
855977
- message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
855978
- code: CliError.Code.ConfigError
855893
+ message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
855979
855894
  });
855980
855895
  }
855981
855896
  const ossWorkspaces = await filterOssWorkspaces(project);
@@ -855990,10 +855905,7 @@ var PublishCommand = class {
855990
855905
  });
855991
855906
  const docsTask = taskGroup.getTask("publish");
855992
855907
  if (docsTask == null) {
855993
- throw new CliError({
855994
- message: "Internal error; task 'publish' not found",
855995
- code: CliError.Code.InternalError
855996
- });
855908
+ throw new CliError({ message: "Internal error; task 'publish' not found" });
855997
855909
  }
855998
855910
  docsTask.start();
855999
855911
  docsTask.stage.validation.start();
@@ -856037,14 +855949,13 @@ var PublishCommand = class {
856037
855949
  errorMessage: labels.error
856038
855950
  });
856039
855951
  if (summary.failedCount > 0) {
856040
- throw new CliError({ code: CliError.Code.ContainerError });
855952
+ throw CliError.exit();
856041
855953
  }
856042
855954
  }
856043
855955
  resolveInstanceUrl({ instances: instances2, instance }) {
856044
855956
  if (instances2.length === 0) {
856045
855957
  throw new CliError({
856046
- message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
856047
- code: CliError.Code.ConfigError
855958
+ message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
856048
855959
  });
856049
855960
  }
856050
855961
  if (instance != null) {
@@ -856057,8 +855968,7 @@ var PublishCommand = class {
856057
855968
  Available instances:
856058
855969
  ${available}
856059
855970
 
856060
- Use --instance <url> with one of the URLs above.`,
856061
- code: CliError.Code.ConfigError
855971
+ Use --instance <url> with one of the URLs above.`
856062
855972
  });
856063
855973
  }
856064
855974
  return match3.url;
@@ -856071,15 +855981,13 @@ ${available}
856071
855981
  Available instances:
856072
855982
  ${available}
856073
855983
 
856074
- Use --instance <url> to select one.`,
856075
- code: CliError.Code.ConfigError
855984
+ Use --instance <url> to select one.`
856076
855985
  });
856077
855986
  }
856078
855987
  const first3 = instances2[0];
856079
855988
  if (first3 == null) {
856080
855989
  throw new CliError({
856081
- message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
856082
- code: CliError.Code.ConfigError
855990
+ message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
856083
855991
  });
856084
855992
  }
856085
855993
  return first3.url;
@@ -856113,8 +856021,7 @@ ${available}
856113
856021
  const fernToken = process.env["FERN_TOKEN"];
856114
856022
  if (fernToken == null) {
856115
856023
  throw new CliError({
856116
- message: "No organization token found. Please set the FERN_TOKEN environment variable.",
856117
- code: CliError.Code.AuthError
856024
+ message: "No organization token found. Please set the FERN_TOKEN environment variable."
856118
856025
  });
856119
856026
  }
856120
856027
  return Promise.resolve({ type: "organization", value: fernToken });
@@ -856126,10 +856033,7 @@ function addPublishCommand(cli) {
856126
856033
  const cmd = new PublishCommand();
856127
856034
  command2(cli, "publish", "Publish your documentation site", async (context3, args) => {
856128
856035
  const timeout4 = new Promise((_16, reject) => {
856129
- setTimeout(() => reject(new CliError({
856130
- message: "Docs publish timed out after 10 minutes.",
856131
- code: CliError.Code.NetworkError
856132
- })), GENERATE_COMMAND_TIMEOUT_MS).unref();
856036
+ setTimeout(() => reject(new CliError({ message: "Docs publish timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
856133
856037
  });
856134
856038
  await Promise.race([cmd.handle(context3, args), timeout4]);
856135
856039
  }, (yargs) => yargs.option("force", {
@@ -856158,8 +856062,7 @@ var DeleteCommand = class {
856158
856062
  if (!this.isPreviewUrl(args.url)) {
856159
856063
  throw new CliError({
856160
856064
  message: `Invalid preview URL: ${args.url}
856161
- Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com`,
856162
- code: CliError.Code.ConfigError
856065
+ Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com`
856163
856066
  });
856164
856067
  }
856165
856068
  const token = await context3.getTokenOrPrompt();
@@ -856176,8 +856079,7 @@ var DeleteCommand = class {
856176
856079
  throw CliError.notFound(`Preview site not found: ${args.url}`);
856177
856080
  default:
856178
856081
  throw new CliError({
856179
- message: `Failed to delete preview site: ${args.url}`,
856180
- code: CliError.Code.InternalError
856082
+ message: `Failed to delete preview site: ${args.url}`
856181
856083
  });
856182
856084
  }
856183
856085
  }
@@ -856224,10 +856126,7 @@ function addPreviewCommand(cli) {
856224
856126
  const cmd = new PreviewCommand();
856225
856127
  commandWithSubcommands(cli, "preview", "Generate a preview of your documentation site", async (context3, args) => {
856226
856128
  const timeout4 = new Promise((_16, reject) => {
856227
- setTimeout(() => reject(new CliError({
856228
- message: "Docs preview timed out after 10 minutes.",
856229
- code: CliError.Code.NetworkError
856230
- })), GENERATE_COMMAND_TIMEOUT_MS).unref();
856129
+ setTimeout(() => reject(new CliError({ message: "Docs preview timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
856231
856130
  });
856232
856131
  await Promise.race([cmd.handle(context3, args), timeout4]);
856233
856132
  }, (yargs) => yargs.option("instance", {
@@ -856614,7 +856513,7 @@ var Wizard = class {
856614
856513
  return void 0;
856615
856514
  }
856616
856515
  this.context.stderr.info(` ${Icons.info} Opening browser to log in to Fern...`);
856617
- const taskContext = new TaskContextAdapter({ context: this.context, logLevel: LogLevel.Info });
856516
+ const taskContext = new TaskContextAdapter({ context: this.context, logLevel: LogLevel2.Info });
856618
856517
  const { accessToken, idToken } = await getTokenFromAuth0(taskContext, {
856619
856518
  useDeviceCodeFlow: false,
856620
856519
  forceReauth: false
@@ -857194,8 +857093,7 @@ var InitCommand = class {
857194
857093
  async validateArgs({ context: context3, fernYmlPath, args }) {
857195
857094
  if (await doesPathExist(fernYmlPath)) {
857196
857095
  throw new CliError({
857197
- message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}`,
857198
- code: CliError.Code.ConfigError
857096
+ message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}`
857199
857097
  });
857200
857098
  }
857201
857099
  if (args.api != null) {
@@ -857203,14 +857101,13 @@ var InitCommand = class {
857203
857101
  if (!api.startsWith("http://") && !api.startsWith("https://")) {
857204
857102
  const resolved = import_path59.default.resolve(context3.cwd, api);
857205
857103
  if (!await doesPathExist(AbsoluteFilePath2.of(resolved))) {
857206
- throw new CliError({ message: `File not found: ${api}`, code: CliError.Code.ConfigError });
857104
+ throw new CliError({ message: `File not found: ${api}` });
857207
857105
  }
857208
857106
  }
857209
857107
  }
857210
857108
  if (!context3.isTTY && !args.yes) {
857211
857109
  throw new CliError({
857212
- message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults.",
857213
- code: CliError.Code.ConfigError
857110
+ message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults."
857214
857111
  });
857215
857112
  }
857216
857113
  }
@@ -857236,7 +857133,7 @@ var CreateCommand = class {
857236
857133
  const token = await context3.getTokenOrPrompt();
857237
857134
  if (token.type === "organization") {
857238
857135
  context3.stderr.error(`${Icons.error} Organization tokens cannot create organizations. Unset the FERN_TOKEN environment variable and run 'fern auth login' to create an organization.`);
857239
- throw new CliError({ code: CliError.Code.AuthError });
857136
+ throw CliError.exit();
857240
857137
  }
857241
857138
  const validationError = getOrganizationNameValidationError(args.name);
857242
857139
  if (validationError != null) {
@@ -857273,7 +857170,7 @@ var ListCommand = class {
857273
857170
  const token = await context3.getTokenOrPrompt();
857274
857171
  if (token.type === "organization") {
857275
857172
  context3.stderr.error(`${Icons.error} Organization tokens cannot list organizations. Unset the FERN_TOKEN environment variable and run 'fern auth login' to list your organizations.`);
857276
- throw new CliError({ code: CliError.Code.AuthError });
857173
+ throw CliError.exit();
857277
857174
  }
857278
857175
  const venus = createVenusService({ token: token.value });
857279
857176
  const firstPage = await this.fetchPage({ venus, pageId: 1 });
@@ -857417,14 +857314,13 @@ var AddCommand = class {
857417
857314
  const fernYmlPath = workspace.absoluteFilePath;
857418
857315
  if (fernYmlPath == null) {
857419
857316
  throw new CliError({
857420
- message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
857421
- code: CliError.Code.ConfigError
857317
+ message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
857422
857318
  });
857423
857319
  }
857424
857320
  const sdkChecker = new SdkChecker({ context: context3 });
857425
857321
  const sdkCheckResult = await sdkChecker.check({ workspace });
857426
857322
  if (sdkCheckResult.errorCount > 0) {
857427
- throw new CliError({ code: CliError.Code.ValidationError });
857323
+ throw CliError.exit();
857428
857324
  }
857429
857325
  const existingTargets = workspace.sdks?.targets ?? [];
857430
857326
  if (!context3.isTTY || args.yes) {
@@ -857437,8 +857333,7 @@ var AddCommand = class {
857437
857333
  throw new CliError({
857438
857334
  message: `Missing required flags:
857439
857335
 
857440
- --target <language> SDK language (e.g. typescript, python, go)`,
857441
- code: CliError.Code.ConfigError
857336
+ --target <language> SDK language (e.g. typescript, python, go)`
857442
857337
  });
857443
857338
  }
857444
857339
  const language = this.parseLanguage(args.target);
@@ -857484,8 +857379,7 @@ var AddCommand = class {
857484
857379
  message: `"${value}" looks like a remote reference but is not a recognized git URL.
857485
857380
 
857486
857381
  Please specify a local path (e.g. ./sdks/my-sdk) or a git URL:
857487
- https://github.com/owner/repo`,
857488
- code: CliError.Code.ConfigError
857382
+ https://github.com/owner/repo`
857489
857383
  });
857490
857384
  }
857491
857385
  return { path: value };
@@ -857507,8 +857401,7 @@ var AddCommand = class {
857507
857401
  checkForDuplicate({ existingTargets, language }) {
857508
857402
  if (existingTargets.some((t3) => t3.name === language)) {
857509
857403
  throw new CliError({
857510
- message: `Target '${language}' already exists in ${FERN_YML_FILENAME}.`,
857511
- code: CliError.Code.ConfigError
857404
+ message: `Target '${language}' already exists in ${FERN_YML_FILENAME}.`
857512
857405
  });
857513
857406
  }
857514
857407
  }
@@ -857560,8 +857453,7 @@ var AddCommand = class {
857560
857453
  return lang;
857561
857454
  }
857562
857455
  throw new CliError({
857563
- message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}`,
857564
- code: CliError.Code.ConfigError
857456
+ message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}`
857565
857457
  });
857566
857458
  }
857567
857459
  };
@@ -857598,7 +857490,7 @@ var CheckCommand4 = class {
857598
857490
  const response = this.buildJsonResponse({ sdkCheckResult: result, hasErrors });
857599
857491
  context3.stdout.info(JSON.stringify(response, null, 2));
857600
857492
  if (hasErrors) {
857601
- throw new CliError({ code: CliError.Code.ValidationError });
857493
+ throw CliError.exit();
857602
857494
  }
857603
857495
  return;
857604
857496
  }
@@ -857610,7 +857502,7 @@ var CheckCommand4 = class {
857610
857502
  }
857611
857503
  }
857612
857504
  if (hasErrors) {
857613
- throw new CliError({ code: CliError.Code.ValidationError });
857505
+ throw CliError.exit();
857614
857506
  }
857615
857507
  if (result.warningCount > 0) {
857616
857508
  context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
@@ -908019,6 +907911,8 @@ var GenerationRunner = class {
908019
907911
  }
908020
907912
  } catch (error50) {
908021
907913
  if (error50 instanceof TaskAbortSignal) {
907914
+ } else if (error50 instanceof LoggableFernCliError) {
907915
+ interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50.log}`, error50);
908022
907916
  } else {
908023
907917
  interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50);
908024
907918
  }
@@ -908451,7 +908345,7 @@ var LegacyLocalGenerationRunner = class {
908451
908345
  const taskContext = new TaskContextAdapter({
908452
908346
  context: this.context,
908453
908347
  task: args.task,
908454
- logLevel: LogLevel.Info
908348
+ logLevel: LogLevel2.Info
908455
908349
  });
908456
908350
  try {
908457
908351
  const generatorInvocation = await this.invocationAdapter.adapt(args.target);
@@ -908590,7 +908484,7 @@ var LegacyRemoteGenerationRunner = class {
908590
908484
  const taskContext = new TaskContextAdapter({
908591
908485
  context: this.context,
908592
908486
  task: args.task,
908593
- logLevel: LogLevel.Info
908487
+ logLevel: LogLevel2.Info
908594
908488
  });
908595
908489
  try {
908596
908490
  const generatorInvocation = await this.invocationAdapter.adapt(args.target);
@@ -908730,8 +908624,7 @@ var GeneratorPipeline = class {
908730
908624
  }
908731
908625
  if (args.target.registry != null) {
908732
908626
  throw new CliError({
908733
- message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry.`,
908734
- code: CliError.Code.ConfigError
908627
+ message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry.`
908735
908628
  });
908736
908629
  }
908737
908630
  return await this.runRemoteGeneration(args);
@@ -909043,8 +908936,7 @@ var GenerateCommand = class {
909043
908936
  throw new CliError({
909044
908937
  message: `No fern.yml found, either run 'fern init' or specify all of the required flags:
909045
908938
 
909046
- ` + missingFlags.map((flag) => ` ${flag}`).join("\n"),
909047
- code: CliError.Code.ConfigError
908939
+ ` + missingFlags.map((flag) => ` ${flag}`).join("\n")
909048
908940
  });
909049
908941
  }
909050
908942
  const api = args.api;
@@ -909095,12 +908987,12 @@ var GenerateCommand = class {
909095
908987
  }
909096
908988
  }
909097
908989
  if (sdkCheckResult.errorCount > 0) {
909098
- throw new CliError({ code: CliError.Code.ValidationError });
908990
+ throw CliError.exit();
909099
908991
  }
909100
908992
  }
909101
908993
  const validTargets = targets2.filter((t3) => checkResult.validApis.has(t3.api));
909102
908994
  if (validTargets.length === 0) {
909103
- throw new CliError({ code: CliError.Code.ValidationError });
908995
+ throw CliError.exit();
909104
908996
  }
909105
908997
  const pipeline5 = new GeneratorPipeline({
909106
908998
  context: context3,
@@ -909128,7 +909020,7 @@ var GenerateCommand = class {
909128
909020
  if (outputPath != null) {
909129
909021
  const { shouldProceed } = await this.checkOutputDirectory({ context: context3, args, outputPath });
909130
909022
  if (!shouldProceed) {
909131
- throw new CliError({ message: "Generation cancelled.", code: CliError.Code.ConfigError });
909023
+ throw new CliError({ message: "Generation cancelled." });
909132
909024
  }
909133
909025
  }
909134
909026
  }
@@ -909146,10 +909038,7 @@ var GenerateCommand = class {
909146
909038
  await Promise.all(targets2.map(async (target) => {
909147
909039
  const task = taskGroup.getTask(target.name);
909148
909040
  if (task == null) {
909149
- throw new CliError({
909150
- message: `Internal error; task '${target.name}' not found`,
909151
- code: CliError.Code.InternalError
909152
- });
909041
+ throw new CliError({ message: `Internal error; task '${target.name}' not found` });
909153
909042
  }
909154
909043
  task.start();
909155
909044
  task.stage.validation.start();
@@ -909195,32 +909084,22 @@ var GenerateCommand = class {
909195
909084
  errorMessage: `Failed to generate ${sdkInitialism}`
909196
909085
  });
909197
909086
  if (summary.failedCount > 0) {
909198
- throw new CliError({ code: CliError.Code.ContainerError });
909087
+ throw CliError.exit();
909199
909088
  }
909200
909089
  }
909201
909090
  validateArgs({ workspace, args, targets: targets2 }) {
909202
909091
  if (args["container-engine"] != null && !args.local) {
909203
- throw new CliError({
909204
- message: "The --container-engine flag can only be used with --local",
909205
- code: CliError.Code.ConfigError
909206
- });
909092
+ throw new CliError({ message: "The --container-engine flag can only be used with --local" });
909207
909093
  }
909208
909094
  if (args.group != null && args.target != null) {
909209
- throw new CliError({
909210
- message: "The --group and --target flags cannot be used together",
909211
- code: CliError.Code.ConfigError
909212
- });
909095
+ throw new CliError({ message: "The --group and --target flags cannot be used together" });
909213
909096
  }
909214
909097
  if (targets2.length > 1 && args.output != null) {
909215
- throw new CliError({
909216
- message: "The --output flag can only be used when generating a single target",
909217
- code: CliError.Code.ConfigError
909218
- });
909098
+ throw new CliError({ message: "The --output flag can only be used when generating a single target" });
909219
909099
  }
909220
909100
  if (args["skip-fernignore"] && args.fernignore != null) {
909221
909101
  throw new CliError({
909222
- message: "The --skip-fernignore and --fernignore flags cannot be used together.",
909223
- code: CliError.Code.ConfigError
909102
+ message: "The --skip-fernignore and --fernignore flags cannot be used together."
909224
909103
  });
909225
909104
  }
909226
909105
  const issues = [];
@@ -909272,8 +909151,7 @@ Example:
909272
909151
  throw new CliError({
909273
909152
  message: `Remote generation is not supported with a git URL for --output
909274
909153
 
909275
- Use --local or specify a local filesystem path for --output`,
909276
- code: CliError.Code.ConfigError
909154
+ Use --local or specify a local filesystem path for --output`
909277
909155
  });
909278
909156
  }
909279
909157
  const token = process.env.GITHUB_TOKEN ?? process.env.GIT_TOKEN;
@@ -909285,8 +909163,7 @@ Example:
909285
909163
  export GITHUB_TOKEN=ghp_xxx
909286
909164
 
909287
909165
  Or use a local path:
909288
- --output ./my-sdk`,
909289
- code: CliError.Code.AuthError
909166
+ --output ./my-sdk`
909290
909167
  });
909291
909168
  }
909292
909169
  return {
@@ -909408,10 +909285,7 @@ function addGenerateCommand(cli) {
909408
909285
  const cmd = new GenerateCommand();
909409
909286
  command2(cli, "generate", "Generate SDKs from fern.yml or directly from an API spec", async (context3, args) => {
909410
909287
  const timeout4 = new Promise((_16, reject) => {
909411
- setTimeout(() => reject(new CliError({
909412
- message: "Generation timed out after 10 minutes.",
909413
- code: CliError.Code.NetworkError
909414
- })), GENERATE_COMMAND_TIMEOUT_MS).unref();
909288
+ setTimeout(() => reject(new CliError({ message: "Generation timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
909415
909289
  });
909416
909290
  await Promise.race([cmd.handle(context3, args), timeout4]);
909417
909291
  }, (yargs) => yargs.option("api", {
@@ -909490,10 +909364,7 @@ function addPreviewCommand2(cli) {
909490
909364
  const cmd = new PreviewCommand2();
909491
909365
  command2(cli, "preview", "Generate a preview of an SDK", async (context3, args) => {
909492
909366
  const timeout4 = new Promise((_16, reject) => {
909493
- setTimeout(() => reject(new CliError({
909494
- message: "Preview generation timed out after 10 minutes.",
909495
- code: CliError.Code.NetworkError
909496
- })), GENERATE_COMMAND_TIMEOUT_MS).unref();
909367
+ setTimeout(() => reject(new CliError({ message: "Preview generation timed out after 10 minutes." })), GENERATE_COMMAND_TIMEOUT_MS).unref();
909497
909368
  });
909498
909369
  await Promise.race([cmd.handle(context3, args), timeout4]);
909499
909370
  }, (yargs) => yargs.option("api", {
@@ -909945,14 +909816,13 @@ var UpdateCommand = class {
909945
909816
  const fernYmlPath = workspace.absoluteFilePath;
909946
909817
  if (fernYmlPath == null) {
909947
909818
  throw new CliError({
909948
- message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
909949
- code: CliError.Code.ConfigError
909819
+ message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`
909950
909820
  });
909951
909821
  }
909952
909822
  const sdkChecker = new SdkChecker({ context: context3 });
909953
909823
  const sdkCheckResult = await sdkChecker.check({ workspace });
909954
909824
  if (sdkCheckResult.errorCount > 0) {
909955
- throw new CliError({ code: CliError.Code.ValidationError });
909825
+ throw CliError.exit();
909956
909826
  }
909957
909827
  const targets2 = workspace.sdks?.targets;
909958
909828
  if (targets2 == null || targets2.length === 0) {
@@ -909968,8 +909838,7 @@ var UpdateCommand = class {
909968
909838
  });
909969
909839
  if (updates.length === 0 && upToDate.length === 0 && args.target != null) {
909970
909840
  throw new CliError({
909971
- message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}.`,
909972
- code: CliError.Code.ConfigError
909841
+ message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}.`
909973
909842
  });
909974
909843
  }
909975
909844
  if (updates.length === 0) {
@@ -924950,19 +924819,19 @@ var Logger4 = class {
924950
924819
  this.enabled = true;
924951
924820
  }
924952
924821
  trace(...args) {
924953
- this.write(LogLevel.Trace, ...args);
924822
+ this.write(LogLevel2.Trace, ...args);
924954
924823
  }
924955
924824
  debug(...args) {
924956
- this.write(LogLevel.Debug, ...args);
924825
+ this.write(LogLevel2.Debug, ...args);
924957
924826
  }
924958
924827
  info(...args) {
924959
- this.write(LogLevel.Info, ...args);
924828
+ this.write(LogLevel2.Info, ...args);
924960
924829
  }
924961
924830
  warn(...args) {
924962
- this.write(LogLevel.Warn, ...args);
924831
+ this.write(LogLevel2.Warn, ...args);
924963
924832
  }
924964
924833
  error(...args) {
924965
- this.write(LogLevel.Error, ...args);
924834
+ this.write(LogLevel2.Error, ...args);
924966
924835
  }
924967
924836
  log(level, ...args) {
924968
924837
  this.write(level, ...args);
@@ -928577,24 +928446,6 @@ var esm_default16 = createPrompt((config5, done) => {
928577
928446
  // src/cli-context/CliContext.ts
928578
928447
  init_lodash();
928579
928448
 
928580
- // src/telemetry/reportError.ts
928581
- function reportError2(reporter, error50, options2) {
928582
- if (error50 instanceof TaskAbortSignal) {
928583
- return;
928584
- }
928585
- const code5 = resolveErrorCode(error50, options2?.code);
928586
- reporter.instrumentPostHogEvent({
928587
- command: process.argv.join(" "),
928588
- properties: {
928589
- failed: true,
928590
- errorCode: code5
928591
- }
928592
- });
928593
- if (shouldReportToSentry(code5)) {
928594
- reporter.captureException(error50 ?? new CliError({ message: options2?.message ?? "", code: code5 }), code5);
928595
- }
928596
- }
928597
-
928598
928449
  // src/telemetry/SentryClient.ts
928599
928450
  var SentryClient = class {
928600
928451
  sentry;
@@ -928617,15 +928468,12 @@ var SentryClient = class {
928617
928468
  setSentryRunIdTags();
928618
928469
  }
928619
928470
  }
928620
- captureException(error50, code5) {
928471
+ async captureException(error50) {
928621
928472
  if (this.sentry == null) {
928622
928473
  return;
928623
928474
  }
928624
928475
  try {
928625
- this.sentry.captureException(
928626
- error50,
928627
- code5 != null ? { captureContext: { tags: { "error.code": code5 } } } : void 0
928628
- );
928476
+ this.sentry.captureException(error50);
928629
928477
  } catch {
928630
928478
  }
928631
928479
  }
@@ -928683,15 +928531,13 @@ var TaskContextImpl = class {
928683
928531
  status = "notStarted";
928684
928532
  onResult;
928685
928533
  instrumentPostHogEventImpl;
928686
- captureExceptionImpl;
928687
928534
  constructor({
928688
928535
  logImmediately,
928689
928536
  logPrefix,
928690
928537
  takeOverTerminal,
928691
928538
  onResult,
928692
928539
  shouldBufferLogs,
928693
- instrumentPostHogEvent,
928694
- captureException: captureException2
928540
+ instrumentPostHogEvent
928695
928541
  }) {
928696
928542
  this.logImmediately = logImmediately;
928697
928543
  this.logPrefix = logPrefix ?? "";
@@ -928699,7 +928545,6 @@ var TaskContextImpl = class {
928699
928545
  this.onResult = onResult;
928700
928546
  this.shouldBufferLogs = shouldBufferLogs;
928701
928547
  this.instrumentPostHogEventImpl = instrumentPostHogEvent;
928702
- this.captureExceptionImpl = captureException2;
928703
928548
  }
928704
928549
  start() {
928705
928550
  this.status = "running";
@@ -928717,21 +928562,14 @@ var TaskContextImpl = class {
928717
928562
  return this.status === "finished";
928718
928563
  }
928719
928564
  takeOverTerminal;
928720
- failAndThrow(message, error50, options2) {
928721
- this.failWithoutThrowing(message, error50, options2);
928565
+ failAndThrow(message, error50) {
928566
+ this.failWithoutThrowing(message, error50);
928722
928567
  this.finish();
928723
928568
  throw new TaskAbortSignal();
928724
928569
  }
928725
- failWithoutThrowing(message, error50, options2) {
928726
- this.result = TaskResult.Failure;
928727
- if (error50 instanceof TaskAbortSignal) {
928728
- return;
928729
- }
928570
+ failWithoutThrowing(message, error50) {
928730
928571
  logErrorMessage({ message, error: error50, logger: this.logger });
928731
- reportError2(this, error50, { ...options2, message });
928732
- }
928733
- captureException(error50, code5) {
928734
- this.captureExceptionImpl?.(error50, code5);
928572
+ this.result = TaskResult.Failure;
928735
928573
  }
928736
928574
  getResult() {
928737
928575
  return this.result;
@@ -928763,7 +928601,7 @@ var TaskContextImpl = class {
928763
928601
  this.logImmediately(this.bufferedLogs);
928764
928602
  this.bufferedLogs = [];
928765
928603
  }
928766
- logger = createLogger(this.logAtLevel.bind(this));
928604
+ logger = createLogger4(this.logAtLevel.bind(this));
928767
928605
  addInteractiveTask({ name: name2, subtitle }) {
928768
928606
  const subtask = new InteractiveTaskContextImpl({
928769
928607
  name: name2,
@@ -928773,8 +928611,7 @@ var TaskContextImpl = class {
928773
928611
  takeOverTerminal: this.takeOverTerminal,
928774
928612
  onResult: this.onResult,
928775
928613
  shouldBufferLogs: this.shouldBufferLogs,
928776
- instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event),
928777
- captureException: this.captureExceptionImpl
928614
+ instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event)
928778
928615
  });
928779
928616
  this.subtasks.push(subtask);
928780
928617
  return subtask;
@@ -928804,7 +928641,7 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
928804
928641
  }
928805
928642
  start() {
928806
928643
  super.start();
928807
- this.logAtLevelWithOverrides(LogLevel.Info, ["Started."], {
928644
+ this.logAtLevelWithOverrides(LogLevel2.Info, ["Started."], {
928808
928645
  omitOnTTY: true
928809
928646
  });
928810
928647
  this.flushLogs();
@@ -928815,11 +928652,11 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
928815
928652
  }
928816
928653
  finish() {
928817
928654
  if (this.result === TaskResult.Success) {
928818
- this.logAtLevelWithOverrides(LogLevel.Info, ["Finished."], {
928655
+ this.logAtLevelWithOverrides(LogLevel2.Info, ["Finished."], {
928819
928656
  omitOnTTY: true
928820
928657
  });
928821
928658
  } else {
928822
- this.logAtLevelWithOverrides(LogLevel.Error, ["Failed."], {
928659
+ this.logAtLevelWithOverrides(LogLevel2.Error, ["Failed."], {
928823
928660
  omitOnTTY: true
928824
928661
  });
928825
928662
  }
@@ -929147,7 +928984,7 @@ var CliContext = class _CliContext {
929147
928984
  didSucceed = true;
929148
928985
  numTasks = 0;
929149
928986
  ttyAwareLogger;
929150
- logLevel = LogLevel.Info;
928987
+ logLevel = LogLevel2.Info;
929151
928988
  isLocal;
929152
928989
  stdoutRedirector = new StdoutRedirector();
929153
928990
  jsonMode = false;
@@ -929182,7 +929019,7 @@ var CliContext = class _CliContext {
929182
929019
  if (false) {
929183
929020
  this.logger.error("CLI_VERSION is not defined");
929184
929021
  }
929185
- return "4.68.3-2-g063113b6335";
929022
+ return "4.68.3";
929186
929023
  }
929187
929024
  getCliName() {
929188
929025
  if (false) {
@@ -929198,17 +929035,13 @@ var CliContext = class _CliContext {
929198
929035
  `Running ${source_default.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`
929199
929036
  );
929200
929037
  }
929201
- failAndThrow(message, error50, options2) {
929202
- this.failWithoutThrowing(message, error50, options2);
929038
+ failAndThrow(message, error50) {
929039
+ this.failWithoutThrowing(message, error50);
929203
929040
  throw new TaskAbortSignal();
929204
929041
  }
929205
- failWithoutThrowing(message, error50, options2) {
929042
+ failWithoutThrowing(message, error50) {
929206
929043
  this.didSucceed = false;
929207
- if (error50 instanceof TaskAbortSignal) {
929208
- return;
929209
- }
929210
929044
  logErrorMessage({ message, error: error50, logger: this.logger });
929211
- reportError2(this, error50, { ...options2, message });
929212
929045
  }
929213
929046
  /**
929214
929047
  * Activate JSON-output mode: all logger output is forced to stderr
@@ -929311,7 +929144,15 @@ var CliContext = class _CliContext {
929311
929144
  try {
929312
929145
  result = await run(context3);
929313
929146
  } catch (error50) {
929314
- context3.failWithoutThrowing(void 0, error50);
929147
+ if (error50 instanceof TaskAbortSignal) {
929148
+ throw error50;
929149
+ }
929150
+ if (error50.message.includes("globalThis")) {
929151
+ context3.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE);
929152
+ context3.failWithoutThrowing();
929153
+ } else {
929154
+ context3.failWithoutThrowing(void 0, error50);
929155
+ }
929315
929156
  throw new TaskAbortSignal();
929316
929157
  } finally {
929317
929158
  context3.finish();
@@ -929323,11 +929164,11 @@ var CliContext = class _CliContext {
929323
929164
  this.posthogManager.sendEvent(event);
929324
929165
  }
929325
929166
  }
929326
- captureException(error50, code5) {
929327
- this.sentryClient.captureException(error50, code5);
929167
+ async captureException(error50) {
929168
+ await this.sentryClient.captureException(error50);
929328
929169
  }
929329
- logger = createLogger((level, ...args) => this.log(level, ...args));
929330
- stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
929170
+ logger = createLogger4((level, ...args) => this.log(level, ...args));
929171
+ stderr = createLogger4((level, ...args) => this.logStderr(level, ...args));
929331
929172
  constructTaskInitForWorkspace(workspace) {
929332
929173
  const prefixWithoutPadding = wrapWorkspaceNameForPrefix(
929333
929174
  workspace.type === "docs" ? "docs" : workspace.workspaceName ?? "api"
@@ -929353,10 +929194,7 @@ var CliContext = class _CliContext {
929353
929194
  instrumentPostHogEvent: (event) => {
929354
929195
  this.instrumentPostHogEvent(event);
929355
929196
  },
929356
- shouldBufferLogs: false,
929357
- captureException: (error50, code5) => {
929358
- this.sentryClient.captureException(error50, code5);
929359
- }
929197
+ shouldBufferLogs: false
929360
929198
  };
929361
929199
  }
929362
929200
  log(level, ...parts) {
@@ -929383,7 +929221,7 @@ var CliContext = class _CliContext {
929383
929221
  logImmediately(logs4, { stderr = false } = {}) {
929384
929222
  const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
929385
929223
  this.ttyAwareLogger.log(filtered, {
929386
- includeDebugInfo: this.logLevel === LogLevel.Debug,
929224
+ includeDebugInfo: this.logLevel === LogLevel2.Debug,
929387
929225
  stderr: stderr || this.jsonMode
929388
929226
  });
929389
929227
  }
@@ -947357,6 +947195,7 @@ function evaluateRuntime4() {
947357
947195
 
947358
947196
  // src/cli.ts
947359
947197
  void runCli();
947198
+ var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
947360
947199
  async function runCli() {
947361
947200
  getOrCreateFernRunId();
947362
947201
  const isLocal = process.argv.includes("--local");
@@ -947394,7 +947233,24 @@ async function runCli() {
947394
947233
  });
947395
947234
  }
947396
947235
  } catch (error50) {
947397
- cliContext.failWithoutThrowing(void 0, error50);
947236
+ cliContext.instrumentPostHogEvent({
947237
+ command: process.argv.join(" "),
947238
+ properties: {
947239
+ failed: true,
947240
+ error: error50
947241
+ }
947242
+ });
947243
+ if (error50 instanceof TaskAbortSignal) {
947244
+ cliContext.failWithoutThrowing();
947245
+ } else if (error50?.message.includes("globalThis")) {
947246
+ cliContext.logger.error(USE_NODE_18_OR_ABOVE_MESSAGE);
947247
+ cliContext.failWithoutThrowing();
947248
+ } else if (error50 instanceof LoggableFernCliError) {
947249
+ cliContext.logger.error(`Failed. ${error50.log}`);
947250
+ } else {
947251
+ await cliContext.captureException(error50);
947252
+ cliContext.failWithoutThrowing("Failed.", error50);
947253
+ }
947398
947254
  }
947399
947255
  await exit3();
947400
947256
  }
@@ -947425,7 +947281,7 @@ async function tryRunCli(cliContext) {
947425
947281
  }
947426
947282
  }
947427
947283
  ).option("log-level", {
947428
- default: LogLevel.Info,
947284
+ default: LogLevel2.Info,
947429
947285
  choices: LOG_LEVELS
947430
947286
  }).demandCommand().recommendCommands();
947431
947287
  addDiffCommand(cli, cliContext);