@fern-api/fern-api-dev 4.68.2 → 4.68.3-1-g429be56b56f
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.
- package/cli.cjs +1454 -1250
- 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
|
|
38972
|
+
function reportError3(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 =
|
|
38982
|
+
exports2.reportError = reportError3;
|
|
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
|
|
54546
|
+
function createLogger2(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 createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
|
|
|
54552
54552
|
function sibling2(name2, initial) {
|
|
54553
54553
|
return append(
|
|
54554
54554
|
spawned,
|
|
54555
|
-
|
|
54555
|
+
createLogger2(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 =
|
|
56286
|
+
const logger4 = createLogger2(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 =
|
|
57569
|
+
this.logger = createLogger2("", "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
|
|
59889
|
+
function createLogger3(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 =
|
|
59985
|
+
this.log = createLogger3(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:
|
|
66346
|
+
log: createLogger4(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
|
|
66388
|
+
var createLogger4, 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
|
-
|
|
66394
|
+
createLogger4 = (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:
|
|
66749
|
+
log: createLogger4(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 =
|
|
80664
|
+
exports2.reportError = reportError3;
|
|
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
|
|
80677
|
+
function reportError3(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,6 +485174,222 @@ 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
|
+
};
|
|
485227
|
+
})(CliError || (CliError = {}));
|
|
485228
|
+
var SENTRY_REPORTABLE = {
|
|
485229
|
+
[CliError.Code.InternalError]: true,
|
|
485230
|
+
[CliError.Code.ResolutionError]: true,
|
|
485231
|
+
[CliError.Code.IrConversionError]: true,
|
|
485232
|
+
[CliError.Code.ContainerError]: true,
|
|
485233
|
+
[CliError.Code.VersionError]: true,
|
|
485234
|
+
[CliError.Code.ParseError]: false,
|
|
485235
|
+
[CliError.Code.EnvironmentError]: false,
|
|
485236
|
+
[CliError.Code.ReferenceError]: false,
|
|
485237
|
+
[CliError.Code.ValidationError]: false,
|
|
485238
|
+
[CliError.Code.NetworkError]: false,
|
|
485239
|
+
[CliError.Code.AuthError]: false,
|
|
485240
|
+
[CliError.Code.ConfigError]: false
|
|
485241
|
+
};
|
|
485242
|
+
function shouldReportToSentry(code5) {
|
|
485243
|
+
return SENTRY_REPORTABLE[code5];
|
|
485244
|
+
}
|
|
485245
|
+
function isSchemaValidationError(error50) {
|
|
485246
|
+
return error50 instanceof Error && (error50.constructor.name === "ParseError" || error50.constructor.name === "JsonError");
|
|
485247
|
+
}
|
|
485248
|
+
function isNodeVersionError(error50) {
|
|
485249
|
+
return error50 instanceof Error && error50.message.includes("globalThis");
|
|
485250
|
+
}
|
|
485251
|
+
function resolveErrorCode(error50, explicitCode) {
|
|
485252
|
+
if (explicitCode != null) {
|
|
485253
|
+
return explicitCode;
|
|
485254
|
+
}
|
|
485255
|
+
if (error50 instanceof CliError) {
|
|
485256
|
+
return error50.code;
|
|
485257
|
+
}
|
|
485258
|
+
if (isSchemaValidationError(error50)) {
|
|
485259
|
+
return CliError.Code.ParseError;
|
|
485260
|
+
}
|
|
485261
|
+
if (isNodeVersionError(error50)) {
|
|
485262
|
+
return CliError.Code.EnvironmentError;
|
|
485263
|
+
}
|
|
485264
|
+
return CliError.Code.InternalError;
|
|
485265
|
+
}
|
|
485266
|
+
|
|
485267
|
+
// ../logger/lib/LogLevel.js
|
|
485268
|
+
var LogLevel = {
|
|
485269
|
+
Trace: "trace",
|
|
485270
|
+
Debug: "debug",
|
|
485271
|
+
Info: "info",
|
|
485272
|
+
Warn: "warn",
|
|
485273
|
+
Error: "error"
|
|
485274
|
+
};
|
|
485275
|
+
var LOG_LEVELS = Object.values(LogLevel);
|
|
485276
|
+
|
|
485277
|
+
// ../logger/lib/createLogger.js
|
|
485278
|
+
var LoggerImpl = class {
|
|
485279
|
+
log;
|
|
485280
|
+
enabled;
|
|
485281
|
+
constructor(log4, enabled = true) {
|
|
485282
|
+
this.log = log4;
|
|
485283
|
+
this.enabled = enabled;
|
|
485284
|
+
}
|
|
485285
|
+
disable() {
|
|
485286
|
+
this.enabled = false;
|
|
485287
|
+
}
|
|
485288
|
+
enable() {
|
|
485289
|
+
this.enabled = true;
|
|
485290
|
+
}
|
|
485291
|
+
debug(...args) {
|
|
485292
|
+
if (this.enabled) {
|
|
485293
|
+
this.log(LogLevel.Debug, ...args);
|
|
485294
|
+
}
|
|
485295
|
+
}
|
|
485296
|
+
info(...args) {
|
|
485297
|
+
if (this.enabled) {
|
|
485298
|
+
this.log(LogLevel.Info, ...args);
|
|
485299
|
+
}
|
|
485300
|
+
}
|
|
485301
|
+
warn(...args) {
|
|
485302
|
+
if (this.enabled) {
|
|
485303
|
+
this.log(LogLevel.Warn, ...args);
|
|
485304
|
+
}
|
|
485305
|
+
}
|
|
485306
|
+
error(...args) {
|
|
485307
|
+
if (this.enabled) {
|
|
485308
|
+
this.log(LogLevel.Error, ...args);
|
|
485309
|
+
}
|
|
485310
|
+
}
|
|
485311
|
+
trace(...args) {
|
|
485312
|
+
if (this.enabled) {
|
|
485313
|
+
this.log(LogLevel.Trace, ...args);
|
|
485314
|
+
}
|
|
485315
|
+
}
|
|
485316
|
+
};
|
|
485317
|
+
function createLogger(log4) {
|
|
485318
|
+
return new LoggerImpl(log4);
|
|
485319
|
+
}
|
|
485320
|
+
|
|
485321
|
+
// ../logger/lib/console.js
|
|
485322
|
+
var CONSOLE_LOGGER = Object.freeze(createLogger(log3));
|
|
485323
|
+
function log3(level, ...args) {
|
|
485324
|
+
const consoleLogger = getConsoleLoggerForLevel(level);
|
|
485325
|
+
consoleLogger(...args);
|
|
485326
|
+
}
|
|
485327
|
+
function getConsoleLoggerForLevel(level) {
|
|
485328
|
+
switch (level) {
|
|
485329
|
+
case LogLevel.Trace:
|
|
485330
|
+
return console.trace;
|
|
485331
|
+
case LogLevel.Debug:
|
|
485332
|
+
return console.debug;
|
|
485333
|
+
case LogLevel.Info:
|
|
485334
|
+
return console.info;
|
|
485335
|
+
case LogLevel.Warn:
|
|
485336
|
+
return console.warn;
|
|
485337
|
+
case LogLevel.Error:
|
|
485338
|
+
return console.error;
|
|
485339
|
+
}
|
|
485340
|
+
}
|
|
485341
|
+
|
|
485342
|
+
// ../task-context/lib/TaskAbortSignal.js
|
|
485343
|
+
var TaskAbortSignal = class {
|
|
485344
|
+
__brand = "TaskAbortSignal";
|
|
485345
|
+
};
|
|
485346
|
+
|
|
485347
|
+
// ../task-context/lib/TaskContext.js
|
|
485348
|
+
var TaskResult;
|
|
485349
|
+
(function(TaskResult2) {
|
|
485350
|
+
TaskResult2[TaskResult2["Success"] = 0] = "Success";
|
|
485351
|
+
TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
|
|
485352
|
+
})(TaskResult || (TaskResult = {}));
|
|
485353
|
+
|
|
485354
|
+
// ../task-context/lib/MockTaskContext.js
|
|
485355
|
+
function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
485356
|
+
const context3 = {
|
|
485357
|
+
logger: logger4,
|
|
485358
|
+
takeOverTerminal: () => {
|
|
485359
|
+
throw new Error("Not implemented");
|
|
485360
|
+
},
|
|
485361
|
+
failAndThrow: (message, error50, _options) => {
|
|
485362
|
+
const parts = [];
|
|
485363
|
+
if (message != null) {
|
|
485364
|
+
parts.push(message);
|
|
485365
|
+
}
|
|
485366
|
+
if (error50 != null) {
|
|
485367
|
+
parts.push(JSON.stringify(error50));
|
|
485368
|
+
}
|
|
485369
|
+
if (parts.length > 0) {
|
|
485370
|
+
context3.logger.error(...parts);
|
|
485371
|
+
}
|
|
485372
|
+
throw new TaskAbortSignal();
|
|
485373
|
+
},
|
|
485374
|
+
failWithoutThrowing: (message, error50, _options) => {
|
|
485375
|
+
context3.failAndThrow(message, error50);
|
|
485376
|
+
},
|
|
485377
|
+
captureException: () => {
|
|
485378
|
+
},
|
|
485379
|
+
getResult: () => TaskResult.Success,
|
|
485380
|
+
addInteractiveTask: () => {
|
|
485381
|
+
throw new Error("Not implemented");
|
|
485382
|
+
},
|
|
485383
|
+
runInteractiveTask: () => {
|
|
485384
|
+
throw new Error("Not implemented");
|
|
485385
|
+
},
|
|
485386
|
+
instrumentPostHogEvent: () => {
|
|
485387
|
+
throw new Error("Not implemented");
|
|
485388
|
+
}
|
|
485389
|
+
};
|
|
485390
|
+
return context3;
|
|
485391
|
+
}
|
|
485392
|
+
|
|
485177
485393
|
// ../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
485178
485394
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
485179
485395
|
var wrapAnsi16 = (offset2 = 0) => (code5) => `\x1B[${code5 + offset2}m`;
|
|
@@ -518729,17 +518945,17 @@ var FernDocsConfigTimeoutError = class extends Error {
|
|
|
518729
518945
|
};
|
|
518730
518946
|
|
|
518731
518947
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/logger.js
|
|
518732
|
-
var
|
|
518948
|
+
var LogLevel2 = {
|
|
518733
518949
|
Debug: "debug",
|
|
518734
518950
|
Info: "info",
|
|
518735
518951
|
Warn: "warn",
|
|
518736
518952
|
Error: "error"
|
|
518737
518953
|
};
|
|
518738
518954
|
var logLevelMap2 = {
|
|
518739
|
-
[
|
|
518740
|
-
[
|
|
518741
|
-
[
|
|
518742
|
-
[
|
|
518955
|
+
[LogLevel2.Debug]: 1,
|
|
518956
|
+
[LogLevel2.Info]: 2,
|
|
518957
|
+
[LogLevel2.Warn]: 3,
|
|
518958
|
+
[LogLevel2.Error]: 4
|
|
518743
518959
|
};
|
|
518744
518960
|
var ConsoleLogger = class {
|
|
518745
518961
|
debug(message, ...args) {
|
|
@@ -518781,7 +518997,7 @@ var Logger = class {
|
|
|
518781
518997
|
* @returns True if debug logs should be output
|
|
518782
518998
|
*/
|
|
518783
518999
|
isDebug() {
|
|
518784
|
-
return this.shouldLog(
|
|
519000
|
+
return this.shouldLog(LogLevel2.Debug);
|
|
518785
519001
|
}
|
|
518786
519002
|
/**
|
|
518787
519003
|
* Logs a debug message if debug logging is enabled.
|
|
@@ -518798,7 +519014,7 @@ var Logger = class {
|
|
|
518798
519014
|
* @returns True if info logs should be output
|
|
518799
519015
|
*/
|
|
518800
519016
|
isInfo() {
|
|
518801
|
-
return this.shouldLog(
|
|
519017
|
+
return this.shouldLog(LogLevel2.Info);
|
|
518802
519018
|
}
|
|
518803
519019
|
/**
|
|
518804
519020
|
* Logs an info message if info logging is enabled.
|
|
@@ -518815,7 +519031,7 @@ var Logger = class {
|
|
|
518815
519031
|
* @returns True if warning logs should be output
|
|
518816
519032
|
*/
|
|
518817
519033
|
isWarn() {
|
|
518818
|
-
return this.shouldLog(
|
|
519034
|
+
return this.shouldLog(LogLevel2.Warn);
|
|
518819
519035
|
}
|
|
518820
519036
|
/**
|
|
518821
519037
|
* Logs a warning message if warning logging is enabled.
|
|
@@ -518832,7 +519048,7 @@ var Logger = class {
|
|
|
518832
519048
|
* @returns True if error logs should be output
|
|
518833
519049
|
*/
|
|
518834
519050
|
isError() {
|
|
518835
|
-
return this.shouldLog(
|
|
519051
|
+
return this.shouldLog(LogLevel2.Error);
|
|
518836
519052
|
}
|
|
518837
519053
|
/**
|
|
518838
519054
|
* Logs an error message if error logging is enabled.
|
|
@@ -518846,7 +519062,7 @@ var Logger = class {
|
|
|
518846
519062
|
}
|
|
518847
519063
|
};
|
|
518848
519064
|
var defaultLogger = new Logger({
|
|
518849
|
-
level:
|
|
519065
|
+
level: LogLevel2.Info,
|
|
518850
519066
|
logger: new ConsoleLogger(),
|
|
518851
519067
|
silent: true
|
|
518852
519068
|
});
|
|
@@ -518854,7 +519070,7 @@ var defaultLogger = new Logger({
|
|
|
518854
519070
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/exports.js
|
|
518855
519071
|
var logging;
|
|
518856
519072
|
(function(logging2) {
|
|
518857
|
-
logging2.LogLevel =
|
|
519073
|
+
logging2.LogLevel = LogLevel2;
|
|
518858
519074
|
logging2.ConsoleLogger = ConsoleLogger;
|
|
518859
519075
|
})(logging || (logging = {}));
|
|
518860
519076
|
|
|
@@ -555047,142 +555263,6 @@ function joinZodPath(arr) {
|
|
|
555047
555263
|
|
|
555048
555264
|
// ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
|
|
555049
555265
|
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
|
|
555186
555266
|
var import_path21 = __toESM(require("path"), 1);
|
|
555187
555267
|
var EMPTY_DEPENDENCIES_CONFIGURATION = {
|
|
555188
555268
|
dependencies: {}
|
|
@@ -571169,7 +571249,7 @@ function getInline2(typeDeclaration2) {
|
|
|
571169
571249
|
function getTypeDeclaration(typeId, types4) {
|
|
571170
571250
|
const maybeTypeDeclaration = types4[typeId];
|
|
571171
571251
|
if (maybeTypeDeclaration == null) {
|
|
571172
|
-
throw
|
|
571252
|
+
throw CliError.internalError(`Failed to load type declaration for type ${typeId}`);
|
|
571173
571253
|
}
|
|
571174
571254
|
return maybeTypeDeclaration;
|
|
571175
571255
|
}
|
|
@@ -571231,7 +571311,7 @@ function getObjectTypeDeclarationFromTypeId(typeId, ir15) {
|
|
|
571231
571311
|
}
|
|
571232
571312
|
}
|
|
571233
571313
|
}
|
|
571234
|
-
throw
|
|
571314
|
+
throw CliError.internalError(`Unexpected error: ${typeId} is extended but has shape ${typeDeclaration2.shape.type}`);
|
|
571235
571315
|
}
|
|
571236
571316
|
function getAllPropertiesForObject2({ objectTypeDeclaration, ir: ir15 }) {
|
|
571237
571317
|
const extendedProperties = objectTypeDeclaration.extends.flatMap((extended) => {
|
|
@@ -579493,7 +579573,8 @@ function formatLog({ breadcrumbs = [], title: title3, subtitle }) {
|
|
|
579493
579573
|
}
|
|
579494
579574
|
|
|
579495
579575
|
// ../cli-logger/lib/logErrorMessage.js
|
|
579496
|
-
|
|
579576
|
+
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
579577
|
+
function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel.Error }) {
|
|
579497
579578
|
if (message != null) {
|
|
579498
579579
|
logger4.log(logLevel, message);
|
|
579499
579580
|
} else if (error50 == null) {
|
|
@@ -579518,6 +579599,9 @@ function convertErrorToString(error50) {
|
|
|
579518
579599
|
return error50;
|
|
579519
579600
|
}
|
|
579520
579601
|
if (error50 instanceof Error) {
|
|
579602
|
+
if (error50?.message?.includes("globalThis")) {
|
|
579603
|
+
return USE_NODE_18_OR_ABOVE_MESSAGE;
|
|
579604
|
+
}
|
|
579521
579605
|
return error50.message;
|
|
579522
579606
|
}
|
|
579523
579607
|
return void 0;
|
|
@@ -580301,13 +580385,13 @@ function formatLog2(log4, { includeDebugInfo }) {
|
|
|
580301
580385
|
}
|
|
580302
580386
|
content5 += "\n";
|
|
580303
580387
|
switch (log4.level) {
|
|
580304
|
-
case
|
|
580388
|
+
case LogLevel.Error:
|
|
580305
580389
|
return source_default.red(content5);
|
|
580306
|
-
case
|
|
580390
|
+
case LogLevel.Warn:
|
|
580307
580391
|
return source_default.hex("FFA500")(content5);
|
|
580308
|
-
case
|
|
580309
|
-
case
|
|
580310
|
-
case
|
|
580392
|
+
case LogLevel.Trace:
|
|
580393
|
+
case LogLevel.Debug:
|
|
580394
|
+
case LogLevel.Info:
|
|
580311
580395
|
return content5;
|
|
580312
580396
|
}
|
|
580313
580397
|
}
|
|
@@ -580317,15 +580401,15 @@ function getDebugPrefix(log4) {
|
|
|
580317
580401
|
}
|
|
580318
580402
|
function getLogLevelAsString(logLevel) {
|
|
580319
580403
|
switch (logLevel) {
|
|
580320
|
-
case
|
|
580404
|
+
case LogLevel.Trace:
|
|
580321
580405
|
return "TRACE";
|
|
580322
|
-
case
|
|
580406
|
+
case LogLevel.Debug:
|
|
580323
580407
|
return "DEBUG";
|
|
580324
|
-
case
|
|
580408
|
+
case LogLevel.Info:
|
|
580325
580409
|
return "INFO";
|
|
580326
|
-
case
|
|
580410
|
+
case LogLevel.Warn:
|
|
580327
580411
|
return "WARN";
|
|
580328
|
-
case
|
|
580412
|
+
case LogLevel.Error:
|
|
580329
580413
|
return "ERROR";
|
|
580330
580414
|
default:
|
|
580331
580415
|
assertNever(logLevel);
|
|
@@ -606050,22 +606134,22 @@ var ErrorCollector2 = class {
|
|
|
606050
606134
|
}
|
|
606051
606135
|
switch (level) {
|
|
606052
606136
|
case APIErrorLevel.ERROR:
|
|
606053
|
-
this.logger.log(
|
|
606137
|
+
this.logger.log(LogLevel.Debug, error50.message);
|
|
606054
606138
|
if (error50.path && error50.path.length > 0) {
|
|
606055
606139
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606056
606140
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606057
|
-
this.logger.log(
|
|
606141
|
+
this.logger.log(LogLevel.Debug, ` - at location (${locationInfo})`);
|
|
606058
606142
|
}
|
|
606059
606143
|
break;
|
|
606060
606144
|
case APIErrorLevel.WARNING:
|
|
606061
|
-
this.logger.log(
|
|
606145
|
+
this.logger.log(LogLevel.Warn, error50.message);
|
|
606062
606146
|
if (error50.path && error50.path.length > 0) {
|
|
606063
606147
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606064
606148
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606065
|
-
this.logger.log(
|
|
606149
|
+
this.logger.log(LogLevel.Warn, ` - at location (${locationInfo})`);
|
|
606066
606150
|
}
|
|
606067
606151
|
if (error50.resolution) {
|
|
606068
|
-
this.logger.log(
|
|
606152
|
+
this.logger.log(LogLevel.Warn, ` - resolution: ${error50.resolution}`);
|
|
606069
606153
|
}
|
|
606070
606154
|
break;
|
|
606071
606155
|
}
|
|
@@ -606094,7 +606178,7 @@ var BreadcrumbToLineNumber = class {
|
|
|
606094
606178
|
jsYaml.load(fileContent, { listener: this.map.listen() });
|
|
606095
606179
|
this.initialized = true;
|
|
606096
606180
|
} catch (error50) {
|
|
606097
|
-
this.logger.log(
|
|
606181
|
+
this.logger.log(LogLevel.Warn, `Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(error50)}`);
|
|
606098
606182
|
}
|
|
606099
606183
|
}
|
|
606100
606184
|
/**
|
|
@@ -612978,7 +613062,7 @@ var FernGlobalHeadersExtension = class extends AbstractExtension {
|
|
|
612978
613062
|
}
|
|
612979
613063
|
};
|
|
612980
613064
|
|
|
612981
|
-
// ../api-importers/openapi-to-ir/lib/utils/
|
|
613065
|
+
// ../api-importers/openapi-to-ir/lib/utils/convertGlobalHeaderOverrides.js
|
|
612982
613066
|
function convertDefaultToLiteral2(defaultValue) {
|
|
612983
613067
|
if (defaultValue == null) {
|
|
612984
613068
|
return void 0;
|
|
@@ -612991,6 +613075,60 @@ function convertDefaultToLiteral2(defaultValue) {
|
|
|
612991
613075
|
}
|
|
612992
613076
|
return void 0;
|
|
612993
613077
|
}
|
|
613078
|
+
function convertGlobalHeaderOverrides({ globalHeaderOverrides, context: context3 }) {
|
|
613079
|
+
const headers2 = [];
|
|
613080
|
+
for (const [headerKey, headerSchema] of Object.entries(globalHeaderOverrides.headers ?? {})) {
|
|
613081
|
+
if (typeof headerSchema === "string") {
|
|
613082
|
+
headers2.push({
|
|
613083
|
+
name: context3.casingsGenerator.generateNameAndWireValue({
|
|
613084
|
+
name: headerKey,
|
|
613085
|
+
wireValue: headerKey
|
|
613086
|
+
}),
|
|
613087
|
+
valueType: AbstractConverter.STRING,
|
|
613088
|
+
env: void 0,
|
|
613089
|
+
v2Examples: {
|
|
613090
|
+
userSpecifiedExamples: {},
|
|
613091
|
+
autogeneratedExamples: {}
|
|
613092
|
+
},
|
|
613093
|
+
availability: void 0,
|
|
613094
|
+
docs: void 0,
|
|
613095
|
+
clientDefault: void 0
|
|
613096
|
+
});
|
|
613097
|
+
} else {
|
|
613098
|
+
const name2 = headerSchema.name ?? headerKey;
|
|
613099
|
+
headers2.push({
|
|
613100
|
+
name: context3.casingsGenerator.generateNameAndWireValue({
|
|
613101
|
+
name: name2,
|
|
613102
|
+
wireValue: headerKey
|
|
613103
|
+
}),
|
|
613104
|
+
valueType: AbstractConverter.STRING,
|
|
613105
|
+
env: headerSchema.env,
|
|
613106
|
+
v2Examples: {
|
|
613107
|
+
userSpecifiedExamples: {},
|
|
613108
|
+
autogeneratedExamples: {}
|
|
613109
|
+
},
|
|
613110
|
+
availability: void 0,
|
|
613111
|
+
docs: headerSchema.docs,
|
|
613112
|
+
clientDefault: convertDefaultToLiteral2(headerSchema.default)
|
|
613113
|
+
});
|
|
613114
|
+
}
|
|
613115
|
+
}
|
|
613116
|
+
return headers2;
|
|
613117
|
+
}
|
|
613118
|
+
|
|
613119
|
+
// ../api-importers/openapi-to-ir/lib/utils/convertGlobalHeadersExtension.js
|
|
613120
|
+
function convertDefaultToLiteral3(defaultValue) {
|
|
613121
|
+
if (defaultValue == null) {
|
|
613122
|
+
return void 0;
|
|
613123
|
+
}
|
|
613124
|
+
if (typeof defaultValue === "string") {
|
|
613125
|
+
return api_exports.Literal.string(defaultValue);
|
|
613126
|
+
}
|
|
613127
|
+
if (typeof defaultValue === "boolean") {
|
|
613128
|
+
return api_exports.Literal.boolean(defaultValue);
|
|
613129
|
+
}
|
|
613130
|
+
return void 0;
|
|
613131
|
+
}
|
|
612994
613132
|
function convertGlobalHeadersExtension({ globalHeaders, context: context3 }) {
|
|
612995
613133
|
return globalHeaders.map((header) => ({
|
|
612996
613134
|
name: context3.casingsGenerator.generateNameAndWireValue({
|
|
@@ -613002,7 +613140,7 @@ function convertGlobalHeadersExtension({ globalHeaders, context: context3 }) {
|
|
|
613002
613140
|
v2Examples: header.optional ? void 0 : constructGlobalHeaderExample({ header, context: context3 }),
|
|
613003
613141
|
availability: void 0,
|
|
613004
613142
|
docs: void 0,
|
|
613005
|
-
clientDefault:
|
|
613143
|
+
clientDefault: convertDefaultToLiteral3(header["x-fern-default"])
|
|
613006
613144
|
}));
|
|
613007
613145
|
}
|
|
613008
613146
|
function constructGlobalHeaderExample({ header, context: context3 }) {
|
|
@@ -616023,6 +616161,13 @@ var OpenAPIConverter = class extends AbstractSpecConverter {
|
|
|
616023
616161
|
}
|
|
616024
616162
|
convertGlobalHeaders() {
|
|
616025
616163
|
if (this.context.globalHeaderOverrides) {
|
|
616164
|
+
const globalHeaders = convertGlobalHeaderOverrides({
|
|
616165
|
+
globalHeaderOverrides: this.context.globalHeaderOverrides,
|
|
616166
|
+
context: this.context
|
|
616167
|
+
});
|
|
616168
|
+
this.addGlobalHeadersToIr(globalHeaders);
|
|
616169
|
+
this.context.setGlobalHeaders(globalHeaders);
|
|
616170
|
+
return;
|
|
616026
616171
|
}
|
|
616027
616172
|
const globalHeadersExtension = new FernGlobalHeadersExtension({
|
|
616028
616173
|
breadcrumbs: ["x-fern-global-headers"],
|
|
@@ -619302,851 +619447,16 @@ async function runRulesOnOSSWorkspace({ workspace, context: context3, rules }) {
|
|
|
619302
619447
|
return ruleResults.flat();
|
|
619303
619448
|
}
|
|
619304
619449
|
|
|
619305
|
-
// ../cli-v2/lib/context/adapter/TaskContextLogger.js
|
|
619306
|
-
var TaskContextLogger = class {
|
|
619307
|
-
context;
|
|
619308
|
-
task;
|
|
619309
|
-
logLevel;
|
|
619310
|
-
enabled = true;
|
|
619311
|
-
collectedErrors = [];
|
|
619312
|
-
constructor({ context: context3, task, logLevel = LogLevel2.Warn }) {
|
|
619313
|
-
this.context = context3;
|
|
619314
|
-
this.task = task;
|
|
619315
|
-
this.logLevel = logLevel;
|
|
619316
|
-
}
|
|
619317
|
-
disable() {
|
|
619318
|
-
this.enabled = false;
|
|
619319
|
-
}
|
|
619320
|
-
enable() {
|
|
619321
|
-
this.enabled = true;
|
|
619322
|
-
}
|
|
619323
|
-
trace(..._args) {
|
|
619324
|
-
}
|
|
619325
|
-
debug(...args) {
|
|
619326
|
-
const message = args.join(" ");
|
|
619327
|
-
this.writeLog({ level: LogLevel2.Debug, message });
|
|
619328
|
-
if (this.shouldLogToTask(LogLevel2.Debug)) {
|
|
619329
|
-
if (this.task.logs == null) {
|
|
619330
|
-
this.task.logs = [];
|
|
619331
|
-
}
|
|
619332
|
-
this.task.logs.push({ level: "debug", message });
|
|
619333
|
-
}
|
|
619334
|
-
}
|
|
619335
|
-
info(...args) {
|
|
619336
|
-
const message = args.join(" ");
|
|
619337
|
-
this.writeLog({ level: LogLevel2.Info, message });
|
|
619338
|
-
if (this.shouldLogToTask(LogLevel2.Info)) {
|
|
619339
|
-
if (this.task.logs == null) {
|
|
619340
|
-
this.task.logs = [];
|
|
619341
|
-
}
|
|
619342
|
-
this.task.logs.push({ level: "debug", message });
|
|
619343
|
-
}
|
|
619344
|
-
}
|
|
619345
|
-
warn(...args) {
|
|
619346
|
-
const message = args.join(" ");
|
|
619347
|
-
this.writeLog({ level: LogLevel2.Warn, message });
|
|
619348
|
-
if (this.shouldLogToTask(LogLevel2.Warn)) {
|
|
619349
|
-
if (this.task.logs == null) {
|
|
619350
|
-
this.task.logs = [];
|
|
619351
|
-
}
|
|
619352
|
-
this.task.logs.push({ level: "warn", message });
|
|
619353
|
-
}
|
|
619354
|
-
}
|
|
619355
|
-
error(...args) {
|
|
619356
|
-
const message = args.join(" ");
|
|
619357
|
-
this.writeLog({ level: LogLevel2.Error, message });
|
|
619358
|
-
if (this.shouldLogToTask(LogLevel2.Error)) {
|
|
619359
|
-
this.collectedErrors.push(message);
|
|
619360
|
-
if (this.task.logs == null) {
|
|
619361
|
-
this.task.logs = [];
|
|
619362
|
-
}
|
|
619363
|
-
this.task.logs.push({ level: "error", message });
|
|
619364
|
-
}
|
|
619365
|
-
}
|
|
619366
|
-
log(level, ...args) {
|
|
619367
|
-
switch (level) {
|
|
619368
|
-
case LogLevel2.Debug:
|
|
619369
|
-
this.debug(...args);
|
|
619370
|
-
break;
|
|
619371
|
-
case LogLevel2.Info:
|
|
619372
|
-
this.info(...args);
|
|
619373
|
-
break;
|
|
619374
|
-
case LogLevel2.Warn:
|
|
619375
|
-
this.warn(...args);
|
|
619376
|
-
break;
|
|
619377
|
-
case LogLevel2.Error:
|
|
619378
|
-
this.error(...args);
|
|
619379
|
-
break;
|
|
619380
|
-
}
|
|
619381
|
-
}
|
|
619382
|
-
/**
|
|
619383
|
-
* Write a log entry to the log file. In CI / non-TTY environments,
|
|
619384
|
-
* also write directly to stderr so logs are visible in CI runner output.
|
|
619385
|
-
*/
|
|
619386
|
-
writeLog({ level, message }) {
|
|
619387
|
-
this.context.logs.write({ taskName: this.task.name, level, message });
|
|
619388
|
-
if (this.context.isTTY) {
|
|
619389
|
-
return;
|
|
619390
|
-
}
|
|
619391
|
-
if (!this.enabled) {
|
|
619392
|
-
return;
|
|
619393
|
-
}
|
|
619394
|
-
const prefix2 = source_default.dim(`[${this.task.name}]`);
|
|
619395
|
-
switch (level) {
|
|
619396
|
-
case LogLevel2.Warn:
|
|
619397
|
-
process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
|
|
619398
|
-
`);
|
|
619399
|
-
break;
|
|
619400
|
-
case LogLevel2.Error:
|
|
619401
|
-
process.stderr.write(`${prefix2}: ${source_default.red(message)}
|
|
619402
|
-
`);
|
|
619403
|
-
break;
|
|
619404
|
-
default:
|
|
619405
|
-
process.stderr.write(`${prefix2}: ${message}
|
|
619406
|
-
`);
|
|
619407
|
-
break;
|
|
619408
|
-
}
|
|
619409
|
-
}
|
|
619410
|
-
/**
|
|
619411
|
-
* Check if a message at the given level should be logged to the task's UI.
|
|
619412
|
-
*/
|
|
619413
|
-
shouldLogToTask(level) {
|
|
619414
|
-
return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
|
|
619415
|
-
}
|
|
619416
|
-
};
|
|
619417
|
-
|
|
619418
|
-
// ../cli-v2/lib/context/adapter/TaskContextAdapter.js
|
|
619419
|
-
var TaskContextAdapter = class {
|
|
619420
|
-
result = TaskResult.Success;
|
|
619421
|
-
logger;
|
|
619422
|
-
constructor({ context: context3, task, logLevel = LogLevel2.Warn }) {
|
|
619423
|
-
if (task != null) {
|
|
619424
|
-
this.logger = new TaskContextLogger({ context: context3, task, logLevel });
|
|
619425
|
-
} else {
|
|
619426
|
-
this.logger = createLogger4((level, ...args) => {
|
|
619427
|
-
if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
|
|
619428
|
-
context3.stderr.log(level, ...args);
|
|
619429
|
-
}
|
|
619430
|
-
});
|
|
619431
|
-
}
|
|
619432
|
-
}
|
|
619433
|
-
async takeOverTerminal(run) {
|
|
619434
|
-
await run();
|
|
619435
|
-
}
|
|
619436
|
-
failAndThrow(message, error50) {
|
|
619437
|
-
this.failWithoutThrowing(message, error50);
|
|
619438
|
-
throw new TaskAbortSignal();
|
|
619439
|
-
}
|
|
619440
|
-
failWithoutThrowing(message, error50) {
|
|
619441
|
-
const fullMessage = this.getFullErrorMessage(message, error50);
|
|
619442
|
-
if (fullMessage != null) {
|
|
619443
|
-
this.logger.error(fullMessage);
|
|
619444
|
-
}
|
|
619445
|
-
this.result = TaskResult.Failure;
|
|
619446
|
-
}
|
|
619447
|
-
getFullErrorMessage(message, error50) {
|
|
619448
|
-
const errorDetails = this.formatError(error50);
|
|
619449
|
-
if (message != null && errorDetails != null) {
|
|
619450
|
-
return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
|
|
619451
|
-
}
|
|
619452
|
-
return message ?? errorDetails;
|
|
619453
|
-
}
|
|
619454
|
-
getResult() {
|
|
619455
|
-
return this.result;
|
|
619456
|
-
}
|
|
619457
|
-
addInteractiveTask(_params) {
|
|
619458
|
-
const subtask = {
|
|
619459
|
-
logger: this.logger,
|
|
619460
|
-
takeOverTerminal: this.takeOverTerminal.bind(this),
|
|
619461
|
-
failAndThrow: this.failAndThrow.bind(this),
|
|
619462
|
-
failWithoutThrowing: this.failWithoutThrowing.bind(this),
|
|
619463
|
-
getResult: () => this.result,
|
|
619464
|
-
addInteractiveTask: this.addInteractiveTask.bind(this),
|
|
619465
|
-
runInteractiveTask: this.runInteractiveTask.bind(this),
|
|
619466
|
-
instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
|
|
619467
|
-
setSubtitle: (_subtitle) => {
|
|
619468
|
-
},
|
|
619469
|
-
start: () => {
|
|
619470
|
-
return subtask;
|
|
619471
|
-
},
|
|
619472
|
-
isStarted: () => true,
|
|
619473
|
-
finish: () => {
|
|
619474
|
-
},
|
|
619475
|
-
isFinished: () => true
|
|
619476
|
-
};
|
|
619477
|
-
return subtask;
|
|
619478
|
-
}
|
|
619479
|
-
async runInteractiveTask(params2, run) {
|
|
619480
|
-
const subtask = this.addInteractiveTask(params2).start();
|
|
619481
|
-
try {
|
|
619482
|
-
await run(subtask);
|
|
619483
|
-
return true;
|
|
619484
|
-
} catch {
|
|
619485
|
-
return false;
|
|
619486
|
-
}
|
|
619487
|
-
}
|
|
619488
|
-
instrumentPostHogEvent(_event) {
|
|
619489
|
-
}
|
|
619490
|
-
formatError(error50) {
|
|
619491
|
-
if (error50 == null) {
|
|
619492
|
-
return void 0;
|
|
619493
|
-
}
|
|
619494
|
-
if (error50 instanceof Error) {
|
|
619495
|
-
return error50.message;
|
|
619496
|
-
}
|
|
619497
|
-
if (typeof error50 === "string") {
|
|
619498
|
-
return error50;
|
|
619499
|
-
}
|
|
619500
|
-
if (typeof error50 === "object") {
|
|
619501
|
-
const message = this.extractErrorMessage(error50);
|
|
619502
|
-
if (message != null) {
|
|
619503
|
-
return message;
|
|
619504
|
-
}
|
|
619505
|
-
}
|
|
619506
|
-
try {
|
|
619507
|
-
return JSON.stringify(error50);
|
|
619508
|
-
} catch {
|
|
619509
|
-
return String(error50);
|
|
619510
|
-
}
|
|
619511
|
-
}
|
|
619512
|
-
/**
|
|
619513
|
-
* Attempts to extract a human-readable message from a structured error object.
|
|
619514
|
-
*
|
|
619515
|
-
* Handles common shapes from the FDR SDK and other API clients, e.g.:
|
|
619516
|
-
* { content: { body: { message: "..." } } }
|
|
619517
|
-
* { body: { message: "..." } }
|
|
619518
|
-
* { message: "..." }
|
|
619519
|
-
*/
|
|
619520
|
-
extractErrorMessage(error50) {
|
|
619521
|
-
const record21 = error50;
|
|
619522
|
-
if (typeof record21.message === "string") {
|
|
619523
|
-
return record21.message;
|
|
619524
|
-
}
|
|
619525
|
-
if (record21.body != null && typeof record21.body === "object") {
|
|
619526
|
-
const body = record21.body;
|
|
619527
|
-
if (typeof body.message === "string") {
|
|
619528
|
-
return body.message;
|
|
619529
|
-
}
|
|
619530
|
-
}
|
|
619531
|
-
if (record21.content != null && typeof record21.content === "object") {
|
|
619532
|
-
return this.extractErrorMessage(record21.content);
|
|
619533
|
-
}
|
|
619534
|
-
return void 0;
|
|
619535
|
-
}
|
|
619536
|
-
};
|
|
619537
|
-
|
|
619538
|
-
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
619539
|
-
init_lib6();
|
|
619540
|
-
|
|
619541
|
-
// ../cli-v2/lib/api/config/OpenRpcSpec.js
|
|
619542
|
-
function isOpenRpcSpec(spec) {
|
|
619543
|
-
return "openrpc" in spec;
|
|
619544
|
-
}
|
|
619545
|
-
|
|
619546
|
-
// ../cli-v2/lib/api/config/ProtobufSpec.js
|
|
619547
|
-
function isProtobufSpec(spec) {
|
|
619548
|
-
return "proto" in spec;
|
|
619549
|
-
}
|
|
619550
|
-
|
|
619551
|
-
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
619552
|
-
var LegacyApiSpecAdapter = class {
|
|
619553
|
-
context;
|
|
619554
|
-
constructor(config5) {
|
|
619555
|
-
this.context = config5.context;
|
|
619556
|
-
}
|
|
619557
|
-
adapt(spec) {
|
|
619558
|
-
if (isOpenApiSpec(spec)) {
|
|
619559
|
-
return this.adaptOpenApiSpec(spec);
|
|
619560
|
-
}
|
|
619561
|
-
if (isAsyncApiSpec(spec)) {
|
|
619562
|
-
return this.adaptAsyncApiSpec(spec);
|
|
619563
|
-
}
|
|
619564
|
-
if (isProtobufSpec(spec)) {
|
|
619565
|
-
return this.adaptProtobufSpec(spec);
|
|
619566
|
-
}
|
|
619567
|
-
if (isOpenRpcSpec(spec)) {
|
|
619568
|
-
return this.adaptOpenRpcSpec(spec);
|
|
619569
|
-
}
|
|
619570
|
-
throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
|
|
619571
|
-
}
|
|
619572
|
-
convertAll(specs) {
|
|
619573
|
-
return specs.map((spec) => this.adapt(spec));
|
|
619574
|
-
}
|
|
619575
|
-
adaptOpenApiSpec(spec) {
|
|
619576
|
-
return {
|
|
619577
|
-
type: "openapi",
|
|
619578
|
-
absoluteFilepath: spec.openapi,
|
|
619579
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
619580
|
-
absoluteFilepathToOverlays: spec.overlays,
|
|
619581
|
-
namespace: spec.namespace,
|
|
619582
|
-
source: {
|
|
619583
|
-
type: "openapi",
|
|
619584
|
-
file: spec.openapi
|
|
619585
|
-
},
|
|
619586
|
-
settings: this.adaptOpenApiSettings(spec.settings)
|
|
619587
|
-
};
|
|
619588
|
-
}
|
|
619589
|
-
adaptAsyncApiSpec(spec) {
|
|
619590
|
-
return {
|
|
619591
|
-
type: "openapi",
|
|
619592
|
-
absoluteFilepath: spec.asyncapi,
|
|
619593
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
619594
|
-
absoluteFilepathToOverlays: void 0,
|
|
619595
|
-
namespace: spec.namespace,
|
|
619596
|
-
source: {
|
|
619597
|
-
type: "asyncapi",
|
|
619598
|
-
file: spec.asyncapi
|
|
619599
|
-
},
|
|
619600
|
-
settings: this.adaptAsyncApiSettings(spec.settings)
|
|
619601
|
-
};
|
|
619602
|
-
}
|
|
619603
|
-
adaptProtobufSpec(spec) {
|
|
619604
|
-
const proto3 = spec.proto;
|
|
619605
|
-
return {
|
|
619606
|
-
type: "protobuf",
|
|
619607
|
-
absoluteFilepathToProtobufRoot: proto3.root,
|
|
619608
|
-
absoluteFilepathToProtobufTarget: proto3.target,
|
|
619609
|
-
absoluteFilepathToOverrides: proto3.overrides,
|
|
619610
|
-
relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
|
|
619611
|
-
generateLocally: proto3.localGeneration ?? false,
|
|
619612
|
-
fromOpenAPI: proto3.fromOpenapi ?? false,
|
|
619613
|
-
dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
|
|
619614
|
-
settings: void 0
|
|
619615
|
-
};
|
|
619616
|
-
}
|
|
619617
|
-
adaptOpenRpcSpec(spec) {
|
|
619618
|
-
return {
|
|
619619
|
-
type: "openrpc",
|
|
619620
|
-
absoluteFilepath: spec.openrpc,
|
|
619621
|
-
absoluteFilepathToOverrides: spec.overrides,
|
|
619622
|
-
namespace: void 0
|
|
619623
|
-
};
|
|
619624
|
-
}
|
|
619625
|
-
adaptOpenApiSettings(settings) {
|
|
619626
|
-
if (settings == null) {
|
|
619627
|
-
return void 0;
|
|
619628
|
-
}
|
|
619629
|
-
const result = {
|
|
619630
|
-
// Base API settings
|
|
619631
|
-
respectNullableSchemas: settings.respectNullableSchemas,
|
|
619632
|
-
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
619633
|
-
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
619634
|
-
useTitlesAsName: settings.titleAsSchemaName,
|
|
619635
|
-
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
619636
|
-
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
619637
|
-
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
619638
|
-
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
619639
|
-
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
619640
|
-
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
619641
|
-
// OpenAPI-specific settings
|
|
619642
|
-
respectReadonlySchemas: settings.respectReadonlySchemas,
|
|
619643
|
-
onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
|
|
619644
|
-
inlinePathParameters: settings.inlinePathParameters,
|
|
619645
|
-
shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
|
|
619646
|
-
objectQueryParameters: settings.objectQueryParameters,
|
|
619647
|
-
respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
|
|
619648
|
-
useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
|
|
619649
|
-
defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
|
|
619650
|
-
filter: settings.filter,
|
|
619651
|
-
exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
|
|
619652
|
-
additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
|
|
619653
|
-
typeDatesAsStrings: settings.typeDatesAsStrings,
|
|
619654
|
-
preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
|
|
619655
|
-
inlineAllOfSchemas: settings.inlineAllOfSchemas,
|
|
619656
|
-
resolveAliases: settings.resolveAliases,
|
|
619657
|
-
groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
|
|
619658
|
-
defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
|
|
619659
|
-
coerceConstsTo: settings.coerceConstsTo
|
|
619660
|
-
};
|
|
619661
|
-
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
619662
|
-
return hasSettings ? result : void 0;
|
|
619663
|
-
}
|
|
619664
|
-
adaptAsyncApiSettings(settings) {
|
|
619665
|
-
if (settings == null) {
|
|
619666
|
-
return void 0;
|
|
619667
|
-
}
|
|
619668
|
-
const result = {
|
|
619669
|
-
// Base API settings (shared)
|
|
619670
|
-
respectNullableSchemas: settings.respectNullableSchemas,
|
|
619671
|
-
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
619672
|
-
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
619673
|
-
useTitlesAsName: settings.titleAsSchemaName,
|
|
619674
|
-
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
619675
|
-
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
619676
|
-
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
619677
|
-
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
619678
|
-
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
619679
|
-
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
619680
|
-
// AsyncAPI-specific settings
|
|
619681
|
-
asyncApiNaming: settings.messageNaming,
|
|
619682
|
-
coerceConstsTo: settings.coerceConstsTo
|
|
619683
|
-
};
|
|
619684
|
-
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
619685
|
-
return hasSettings ? result : void 0;
|
|
619686
|
-
}
|
|
619687
|
-
adaptRemoveDiscriminantsFromSchemas(value) {
|
|
619688
|
-
if (value == null) {
|
|
619689
|
-
return void 0;
|
|
619690
|
-
}
|
|
619691
|
-
switch (value) {
|
|
619692
|
-
case "always":
|
|
619693
|
-
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
|
|
619694
|
-
case "never":
|
|
619695
|
-
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
|
|
619696
|
-
default:
|
|
619697
|
-
return void 0;
|
|
619698
|
-
}
|
|
619699
|
-
}
|
|
619700
|
-
adaptPathParameterOrder(value) {
|
|
619701
|
-
if (value == null) {
|
|
619702
|
-
return void 0;
|
|
619703
|
-
}
|
|
619704
|
-
switch (value) {
|
|
619705
|
-
case "urlOrder":
|
|
619706
|
-
return generators_yml_exports.PathParameterOrder.UrlOrder;
|
|
619707
|
-
case "specOrder":
|
|
619708
|
-
return generators_yml_exports.PathParameterOrder.SpecOrder;
|
|
619709
|
-
default:
|
|
619710
|
-
return void 0;
|
|
619711
|
-
}
|
|
619712
|
-
}
|
|
619713
|
-
adaptDefaultIntegerFormat(value) {
|
|
619714
|
-
if (value == null) {
|
|
619715
|
-
return void 0;
|
|
619716
|
-
}
|
|
619717
|
-
switch (value) {
|
|
619718
|
-
case "int32":
|
|
619719
|
-
return generators_yml_exports.DefaultIntegerFormat.Int32;
|
|
619720
|
-
case "int64":
|
|
619721
|
-
return generators_yml_exports.DefaultIntegerFormat.Int64;
|
|
619722
|
-
case "uint32":
|
|
619723
|
-
return generators_yml_exports.DefaultIntegerFormat.Uint32;
|
|
619724
|
-
case "uint64":
|
|
619725
|
-
return generators_yml_exports.DefaultIntegerFormat.Uint64;
|
|
619726
|
-
default:
|
|
619727
|
-
return void 0;
|
|
619728
|
-
}
|
|
619729
|
-
}
|
|
619730
|
-
adaptExampleGeneration(value) {
|
|
619731
|
-
if (value == null) {
|
|
619732
|
-
return void 0;
|
|
619733
|
-
}
|
|
619734
|
-
const result = {};
|
|
619735
|
-
if (value.request != null) {
|
|
619736
|
-
result.request = { "max-depth": value.request.maxDepth };
|
|
619737
|
-
}
|
|
619738
|
-
if (value.response != null) {
|
|
619739
|
-
result.response = { "max-depth": value.response.maxDepth };
|
|
619740
|
-
}
|
|
619741
|
-
return result;
|
|
619742
|
-
}
|
|
619743
|
-
};
|
|
619744
|
-
|
|
619745
|
-
// ../cli-v2/lib/api/config/ConjureSpec.js
|
|
619746
|
-
function isConjureSpec(spec) {
|
|
619747
|
-
return "conjure" in spec;
|
|
619748
|
-
}
|
|
619749
|
-
|
|
619750
|
-
// ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
|
|
619751
|
-
var ApiDefinitionValidator = class {
|
|
619752
|
-
context;
|
|
619753
|
-
taskContext;
|
|
619754
|
-
cliVersion;
|
|
619755
|
-
constructor(config5) {
|
|
619756
|
-
this.context = config5.context;
|
|
619757
|
-
this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
|
|
619758
|
-
this.cliVersion = config5.cliVersion;
|
|
619759
|
-
}
|
|
619760
|
-
/**
|
|
619761
|
-
* Validate an ApiDefinition.
|
|
619762
|
-
*
|
|
619763
|
-
* Runs both Fern definition validation and OSS workspace validation
|
|
619764
|
-
* to ensure the API definition is valid before generation.
|
|
619765
|
-
*/
|
|
619766
|
-
async validate(definition3) {
|
|
619767
|
-
const startTime = performance.now();
|
|
619768
|
-
const violations = [];
|
|
619769
|
-
const fernSpec = definition3.specs.find(isFernSpec);
|
|
619770
|
-
if (fernSpec != null) {
|
|
619771
|
-
const fernViolations = await this.validateFernSpec(fernSpec);
|
|
619772
|
-
violations.push(...fernViolations);
|
|
619773
|
-
return {
|
|
619774
|
-
violations,
|
|
619775
|
-
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
619776
|
-
workspaceRoot: fernSpec.fern,
|
|
619777
|
-
elapsedMillis: performance.now() - startTime
|
|
619778
|
-
};
|
|
619779
|
-
}
|
|
619780
|
-
const conjureSpec = definition3.specs.find(isConjureSpec);
|
|
619781
|
-
if (conjureSpec != null) {
|
|
619782
|
-
return {
|
|
619783
|
-
violations: [],
|
|
619784
|
-
hasErrors: false,
|
|
619785
|
-
workspaceRoot: this.context.cwd,
|
|
619786
|
-
elapsedMillis: performance.now() - startTime
|
|
619787
|
-
};
|
|
619788
|
-
}
|
|
619789
|
-
const ossViolations = await this.validateOssSpecs(definition3.specs);
|
|
619790
|
-
violations.push(...ossViolations);
|
|
619791
|
-
return {
|
|
619792
|
-
violations,
|
|
619793
|
-
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
619794
|
-
workspaceRoot: this.context.cwd,
|
|
619795
|
-
elapsedMillis: performance.now() - startTime
|
|
619796
|
-
};
|
|
619797
|
-
}
|
|
619798
|
-
async validateFernSpec(spec) {
|
|
619799
|
-
const violations = [];
|
|
619800
|
-
const lazyWorkspace = new LazyFernWorkspace({
|
|
619801
|
-
absoluteFilePath: dirname6(spec.fern),
|
|
619802
|
-
context: this.taskContext,
|
|
619803
|
-
cliVersion: this.cliVersion,
|
|
619804
|
-
generatorsConfiguration: void 0,
|
|
619805
|
-
workspaceName: void 0,
|
|
619806
|
-
changelog: void 0
|
|
619807
|
-
});
|
|
619808
|
-
const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
619809
|
-
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
619810
|
-
violations.push(...fernViolations);
|
|
619811
|
-
return violations;
|
|
619812
|
-
}
|
|
619813
|
-
async validateOssSpecs(specs) {
|
|
619814
|
-
const violations = [];
|
|
619815
|
-
const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
|
|
619816
|
-
if (ossSpecs.length === 0) {
|
|
619817
|
-
return violations;
|
|
619818
|
-
}
|
|
619819
|
-
const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
|
|
619820
|
-
const v1Specs = specAdapter.convertAll(ossSpecs);
|
|
619821
|
-
const filteredSpecs = v1Specs.filter((spec) => {
|
|
619822
|
-
if (spec.type === "openrpc") {
|
|
619823
|
-
return false;
|
|
619824
|
-
}
|
|
619825
|
-
if (spec.type === "protobuf" && !spec.fromOpenAPI) {
|
|
619826
|
-
return false;
|
|
619827
|
-
}
|
|
619828
|
-
return true;
|
|
619829
|
-
});
|
|
619830
|
-
const allSpecs = v1Specs.filter((spec) => {
|
|
619831
|
-
if (spec.type === "protobuf" && spec.fromOpenAPI) {
|
|
619832
|
-
return false;
|
|
619833
|
-
}
|
|
619834
|
-
return true;
|
|
619835
|
-
});
|
|
619836
|
-
const ossWorkspace = new OSSWorkspace({
|
|
619837
|
-
specs: filteredSpecs,
|
|
619838
|
-
allSpecs,
|
|
619839
|
-
absoluteFilePath: this.context.cwd,
|
|
619840
|
-
cliVersion: this.cliVersion,
|
|
619841
|
-
changelog: void 0,
|
|
619842
|
-
generatorsConfiguration: void 0,
|
|
619843
|
-
workspaceName: void 0
|
|
619844
|
-
});
|
|
619845
|
-
const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
619846
|
-
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
619847
|
-
violations.push(...fernViolations);
|
|
619848
|
-
const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
|
|
619849
|
-
violations.push(...ossViolations);
|
|
619850
|
-
return violations;
|
|
619851
|
-
}
|
|
619852
|
-
};
|
|
619853
|
-
|
|
619854
|
-
// ../cli-v2/lib/api/checker/ApiChecker.js
|
|
619855
|
-
var ApiChecker = class {
|
|
619856
|
-
context;
|
|
619857
|
-
cliVersion;
|
|
619858
|
-
task;
|
|
619859
|
-
constructor(config5) {
|
|
619860
|
-
this.context = config5.context;
|
|
619861
|
-
this.cliVersion = config5.cliVersion;
|
|
619862
|
-
this.task = config5.task;
|
|
619863
|
-
}
|
|
619864
|
-
/**
|
|
619865
|
-
* Check APIs in the workspace and display results.
|
|
619866
|
-
*
|
|
619867
|
-
* @param strict - If true, display all warnings and treat them as errors. If false,
|
|
619868
|
-
* only show errors but still report warning count in summary.
|
|
619869
|
-
*/
|
|
619870
|
-
async check({ workspace, apiNames, strict = false }) {
|
|
619871
|
-
const startTime = performance.now();
|
|
619872
|
-
const validApis = /* @__PURE__ */ new Set();
|
|
619873
|
-
const invalidApis = /* @__PURE__ */ new Set();
|
|
619874
|
-
const apisToCheck = apiNames ?? Object.keys(workspace.apis);
|
|
619875
|
-
if (apisToCheck.length === 0) {
|
|
619876
|
-
return {
|
|
619877
|
-
validApis,
|
|
619878
|
-
invalidApis,
|
|
619879
|
-
violations: [],
|
|
619880
|
-
errorCount: 0,
|
|
619881
|
-
warningCount: 0,
|
|
619882
|
-
elapsedMillis: performance.now() - startTime
|
|
619883
|
-
};
|
|
619884
|
-
}
|
|
619885
|
-
const validator = new ApiDefinitionValidator({
|
|
619886
|
-
context: this.context,
|
|
619887
|
-
cliVersion: this.cliVersion,
|
|
619888
|
-
task: this.task
|
|
619889
|
-
});
|
|
619890
|
-
const allViolations = [];
|
|
619891
|
-
for (const apiName of apisToCheck) {
|
|
619892
|
-
const apiDefinition = workspace.apis[apiName];
|
|
619893
|
-
if (apiDefinition == null) {
|
|
619894
|
-
invalidApis.add(apiName);
|
|
619895
|
-
continue;
|
|
619896
|
-
}
|
|
619897
|
-
const result = await validator.validate(apiDefinition);
|
|
619898
|
-
if (result.hasErrors) {
|
|
619899
|
-
invalidApis.add(apiName);
|
|
619900
|
-
} else {
|
|
619901
|
-
validApis.add(apiName);
|
|
619902
|
-
}
|
|
619903
|
-
const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
|
|
619904
|
-
const resolvedViolations = this.resolveViolationPaths({
|
|
619905
|
-
workspaceRoot: result.workspaceRoot,
|
|
619906
|
-
apiName,
|
|
619907
|
-
apiSpecType,
|
|
619908
|
-
apiDefinition,
|
|
619909
|
-
violations: result.violations
|
|
619910
|
-
});
|
|
619911
|
-
allViolations.push(...resolvedViolations);
|
|
619912
|
-
}
|
|
619913
|
-
const dedupedViolations = this.deduplicateViolations(allViolations);
|
|
619914
|
-
return {
|
|
619915
|
-
...this.countViolations(dedupedViolations),
|
|
619916
|
-
validApis,
|
|
619917
|
-
invalidApis,
|
|
619918
|
-
violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
619919
|
-
elapsedMillis: performance.now() - startTime
|
|
619920
|
-
};
|
|
619921
|
-
}
|
|
619922
|
-
resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
|
|
619923
|
-
return violations.map((violation) => {
|
|
619924
|
-
const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
|
|
619925
|
-
return {
|
|
619926
|
-
...violation,
|
|
619927
|
-
message,
|
|
619928
|
-
displayRelativeFilepath: this.resolveDisplayPath({
|
|
619929
|
-
workspaceRoot,
|
|
619930
|
-
apiDefinition,
|
|
619931
|
-
apiSpecType,
|
|
619932
|
-
violation
|
|
619933
|
-
}),
|
|
619934
|
-
apiSpecType,
|
|
619935
|
-
apiName,
|
|
619936
|
-
// We don't actually surface valuable line/column information yet, but
|
|
619937
|
-
// this at least points to the correct file.
|
|
619938
|
-
line: 1,
|
|
619939
|
-
column: 1
|
|
619940
|
-
};
|
|
619941
|
-
});
|
|
619942
|
-
}
|
|
619943
|
-
/**
|
|
619944
|
-
* Format a violation message for non-Fern (OSS) specs.
|
|
619945
|
-
*
|
|
619946
|
-
* Prepends a human-readable node path so users can locate the endpoint,
|
|
619947
|
-
* then strips synthetic file paths from the body of the message.
|
|
619948
|
-
*/
|
|
619949
|
-
formatOssMessage(violation) {
|
|
619950
|
-
const strippedMessage = this.stripSyntheticFilePaths(violation.message);
|
|
619951
|
-
const nodePathPrefix = this.formatNodePath(violation.nodePath);
|
|
619952
|
-
if (nodePathPrefix.length === 0) {
|
|
619953
|
-
return strippedMessage;
|
|
619954
|
-
}
|
|
619955
|
-
return `${nodePathPrefix} - ${strippedMessage}`;
|
|
619956
|
-
}
|
|
619957
|
-
/**
|
|
619958
|
-
* Formats a NodePath into a readable string like "endpoints -> getUser".
|
|
619959
|
-
*
|
|
619960
|
-
* Skips the leading "service" segment since it's implicit.
|
|
619961
|
-
*/
|
|
619962
|
-
formatNodePath(nodePath) {
|
|
619963
|
-
const parts = [];
|
|
619964
|
-
for (const item of nodePath) {
|
|
619965
|
-
if (typeof item === "string") {
|
|
619966
|
-
parts.push(item);
|
|
619967
|
-
} else {
|
|
619968
|
-
parts.push(item.key);
|
|
619969
|
-
}
|
|
619970
|
-
}
|
|
619971
|
-
if (parts[0] === "service") {
|
|
619972
|
-
parts.shift();
|
|
619973
|
-
}
|
|
619974
|
-
return parts.join(" -> ");
|
|
619975
|
-
}
|
|
619976
|
-
resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
|
|
619977
|
-
if (apiSpecType === "fern") {
|
|
619978
|
-
const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
|
|
619979
|
-
return relativize(this.context.cwd, absolutePath);
|
|
619980
|
-
}
|
|
619981
|
-
return this.resolveOssDisplayPath(apiDefinition, violation);
|
|
619982
|
-
}
|
|
619983
|
-
resolveOssDisplayPath(apiDefinition, violation) {
|
|
619984
|
-
const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
|
|
619985
|
-
if (ossSpecs.length === 0) {
|
|
619986
|
-
return violation.relativeFilepath;
|
|
619987
|
-
}
|
|
619988
|
-
if (ossSpecs.length > 1) {
|
|
619989
|
-
for (const spec of ossSpecs) {
|
|
619990
|
-
const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
|
|
619991
|
-
if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
|
|
619992
|
-
const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
|
|
619993
|
-
return relativize(this.context.cwd, filePath2);
|
|
619994
|
-
}
|
|
619995
|
-
}
|
|
619996
|
-
}
|
|
619997
|
-
const firstSpec = ossSpecs[0];
|
|
619998
|
-
if (firstSpec == null) {
|
|
619999
|
-
return violation.relativeFilepath;
|
|
620000
|
-
}
|
|
620001
|
-
const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
|
|
620002
|
-
return relativize(this.context.cwd, filePath);
|
|
620003
|
-
}
|
|
620004
|
-
deduplicateViolations(violations) {
|
|
620005
|
-
const seen = /* @__PURE__ */ new Set();
|
|
620006
|
-
return violations.filter((v23) => {
|
|
620007
|
-
const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
|
|
620008
|
-
if (seen.has(key2)) {
|
|
620009
|
-
return false;
|
|
620010
|
-
}
|
|
620011
|
-
seen.add(key2);
|
|
620012
|
-
return true;
|
|
620013
|
-
});
|
|
620014
|
-
}
|
|
620015
|
-
/**
|
|
620016
|
-
* Strip synthetic file path references from violation messages for non-Fern specs.
|
|
620017
|
-
*
|
|
620018
|
-
* The validator produces messages like:
|
|
620019
|
-
* "- pet.yml -> getPetById /pet/{petId}"
|
|
620020
|
-
* For non-Fern specs these file names are synthetic (they don't exist on disk),
|
|
620021
|
-
* so we strip them to produce:
|
|
620022
|
-
* "- getPetById /pet/{petId}"
|
|
620023
|
-
*/
|
|
620024
|
-
stripSyntheticFilePaths(message) {
|
|
620025
|
-
return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
|
|
620026
|
-
}
|
|
620027
|
-
countViolations(violations) {
|
|
620028
|
-
let errorCount = 0;
|
|
620029
|
-
let warningCount = 0;
|
|
620030
|
-
for (const violation of violations) {
|
|
620031
|
-
switch (violation.severity) {
|
|
620032
|
-
case "fatal":
|
|
620033
|
-
case "error":
|
|
620034
|
-
errorCount++;
|
|
620035
|
-
break;
|
|
620036
|
-
case "warning":
|
|
620037
|
-
warningCount++;
|
|
620038
|
-
break;
|
|
620039
|
-
default:
|
|
620040
|
-
assertNever(violation.severity);
|
|
620041
|
-
}
|
|
620042
|
-
}
|
|
620043
|
-
return { errorCount, warningCount };
|
|
620044
|
-
}
|
|
620045
|
-
};
|
|
620046
|
-
|
|
620047
|
-
// ../cli-v2/lib/errors/CliError.js
|
|
620048
|
-
var CliError = class _CliError extends Error {
|
|
620049
|
-
code;
|
|
620050
|
-
docsLink;
|
|
620051
|
-
constructor({ message, code: code5, docsLink }) {
|
|
620052
|
-
super(message);
|
|
620053
|
-
this.code = code5;
|
|
620054
|
-
this.docsLink = docsLink;
|
|
620055
|
-
}
|
|
620056
|
-
static authRequired(message) {
|
|
620057
|
-
return new _CliError({
|
|
620058
|
-
message: message ?? "Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable.",
|
|
620059
|
-
code: "AUTH_REQUIRED"
|
|
620060
|
-
});
|
|
620061
|
-
}
|
|
620062
|
-
static generationFailed(message) {
|
|
620063
|
-
return new _CliError({
|
|
620064
|
-
message: message ?? "Generation failed. Please check the logs for more information.",
|
|
620065
|
-
code: "GENERATION_FAILED"
|
|
620066
|
-
});
|
|
620067
|
-
}
|
|
620068
|
-
static badRequest(message) {
|
|
620069
|
-
return new _CliError({ message, code: "BAD_REQUEST_ERROR" });
|
|
620070
|
-
}
|
|
620071
|
-
static notFound(message) {
|
|
620072
|
-
return new _CliError({ message, code: "NOT_FOUND_ERROR" });
|
|
620073
|
-
}
|
|
620074
|
-
static unauthorized(message) {
|
|
620075
|
-
return new _CliError({
|
|
620076
|
-
message: message ?? "Unauthorized. Please run 'fern auth login' or set the FERN_TOKEN environment variable.",
|
|
620077
|
-
code: "UNAUTHORIZED_ERROR"
|
|
620078
|
-
});
|
|
620079
|
-
}
|
|
620080
|
-
static validationError(message) {
|
|
620081
|
-
return new _CliError({ message, code: "VALIDATION_ERROR" });
|
|
620082
|
-
}
|
|
620083
|
-
static internalError(message) {
|
|
620084
|
-
return new _CliError({ message, code: "INTERNAL_ERROR" });
|
|
620085
|
-
}
|
|
620086
|
-
/**
|
|
620087
|
-
* A sentinel error that causes the CLI to exit with a non-zero exit code, but no message. This
|
|
620088
|
-
* is useful when a command handles the failure message itself.
|
|
620089
|
-
*/
|
|
620090
|
-
static exit() {
|
|
620091
|
-
return new _CliError({
|
|
620092
|
-
message: "",
|
|
620093
|
-
code: "EXIT"
|
|
620094
|
-
});
|
|
620095
|
-
}
|
|
620096
|
-
};
|
|
620097
|
-
|
|
620098
|
-
// ../cli-v2/lib/ui/format.js
|
|
620099
|
-
function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
|
|
620100
|
-
if (text9 == null) {
|
|
620101
|
-
return "";
|
|
620102
|
-
}
|
|
620103
|
-
const lines = text9.split("\n").filter((line) => line.trim().length > 0);
|
|
620104
|
-
if (lines.length === 0) {
|
|
620105
|
-
return "";
|
|
620106
|
-
}
|
|
620107
|
-
const baseIndentStr = " ".repeat(baseIndent);
|
|
620108
|
-
const contIndentStr = " ".repeat(continuationIndent);
|
|
620109
|
-
if (icon != null) {
|
|
620110
|
-
const [first3, ...rest] = lines;
|
|
620111
|
-
const firstLine = `
|
|
620112
|
-
${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
|
|
620113
|
-
const restLines = rest.map((line) => `
|
|
620114
|
-
${contIndentStr}${colorFn(line)}`).join("");
|
|
620115
|
-
return firstLine + restLines;
|
|
620116
|
-
}
|
|
620117
|
-
return lines.map((line) => `
|
|
620118
|
-
${baseIndentStr}${colorFn(line)}`).join("");
|
|
620119
|
-
}
|
|
620120
|
-
var Icons = {
|
|
620121
|
-
error: source_default.red("\u2717"),
|
|
620122
|
-
warning: source_default.yellow("\u26A0"),
|
|
620123
|
-
success: source_default.green("\u2713"),
|
|
620124
|
-
info: source_default.cyan("\u25C6")
|
|
620125
|
-
};
|
|
620126
|
-
var Colors = {
|
|
620127
|
-
error: source_default.red.bind(source_default),
|
|
620128
|
-
warning: source_default.yellow.bind(source_default),
|
|
620129
|
-
success: source_default.green.bind(source_default),
|
|
620130
|
-
info: source_default.cyan.bind(source_default),
|
|
620131
|
-
dim: source_default.dim.bind(source_default)
|
|
620132
|
-
};
|
|
620133
|
-
function formatBytes(bytes) {
|
|
620134
|
-
if (bytes === 0) {
|
|
620135
|
-
return "0 B";
|
|
620136
|
-
}
|
|
620137
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
620138
|
-
const base4 = 1024;
|
|
620139
|
-
const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
|
|
620140
|
-
const value = bytes / Math.pow(base4, index3);
|
|
620141
|
-
return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
|
|
620142
|
-
}
|
|
620143
|
-
|
|
620144
619450
|
// ../cli-v2/lib/auth/errors/KeyringUnavailableError.js
|
|
620145
|
-
var KeyringUnavailableError = class extends
|
|
619451
|
+
var KeyringUnavailableError = class _KeyringUnavailableError extends CliError {
|
|
620146
619452
|
platform;
|
|
620147
619453
|
cause;
|
|
620148
619454
|
constructor(platform3, cause) {
|
|
620149
|
-
super(
|
|
619455
|
+
super({
|
|
619456
|
+
message: getKeyringErrorMessage(platform3),
|
|
619457
|
+
code: CliError.Code.AuthError
|
|
619458
|
+
});
|
|
619459
|
+
Object.setPrototypeOf(this, _KeyringUnavailableError.prototype);
|
|
620150
619460
|
this.platform = platform3;
|
|
620151
619461
|
this.cause = cause;
|
|
620152
619462
|
}
|
|
@@ -620203,23 +619513,77 @@ If running in a headless environment, use FERN_TOKEN instead:
|
|
|
620203
619513
|
}
|
|
620204
619514
|
|
|
620205
619515
|
// ../cli-v2/lib/errors/SourcedValidationError.js
|
|
620206
|
-
var SourcedValidationError = class extends
|
|
619516
|
+
var SourcedValidationError = class _SourcedValidationError extends CliError {
|
|
620207
619517
|
issues;
|
|
620208
619518
|
constructor(issues) {
|
|
620209
|
-
super(
|
|
619519
|
+
super({
|
|
619520
|
+
message: issues.map((issue2) => issue2.toString()).join("\n"),
|
|
619521
|
+
code: CliError.Code.ValidationError
|
|
619522
|
+
});
|
|
619523
|
+
Object.setPrototypeOf(this, _SourcedValidationError.prototype);
|
|
620210
619524
|
this.issues = issues;
|
|
620211
619525
|
}
|
|
620212
619526
|
};
|
|
620213
619527
|
|
|
620214
619528
|
// ../cli-v2/lib/errors/ValidationError.js
|
|
620215
|
-
var ValidationError = class extends
|
|
619529
|
+
var ValidationError = class _ValidationError extends CliError {
|
|
620216
619530
|
violations;
|
|
620217
619531
|
constructor(violations) {
|
|
620218
|
-
super(
|
|
619532
|
+
super({
|
|
619533
|
+
message: violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"),
|
|
619534
|
+
code: CliError.Code.ValidationError
|
|
619535
|
+
});
|
|
619536
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
620219
619537
|
this.violations = violations;
|
|
620220
619538
|
}
|
|
620221
619539
|
};
|
|
620222
619540
|
|
|
619541
|
+
// ../cli-v2/lib/ui/format.js
|
|
619542
|
+
function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
|
|
619543
|
+
if (text9 == null) {
|
|
619544
|
+
return "";
|
|
619545
|
+
}
|
|
619546
|
+
const lines = text9.split("\n").filter((line) => line.trim().length > 0);
|
|
619547
|
+
if (lines.length === 0) {
|
|
619548
|
+
return "";
|
|
619549
|
+
}
|
|
619550
|
+
const baseIndentStr = " ".repeat(baseIndent);
|
|
619551
|
+
const contIndentStr = " ".repeat(continuationIndent);
|
|
619552
|
+
if (icon != null) {
|
|
619553
|
+
const [first3, ...rest] = lines;
|
|
619554
|
+
const firstLine = `
|
|
619555
|
+
${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
|
|
619556
|
+
const restLines = rest.map((line) => `
|
|
619557
|
+
${contIndentStr}${colorFn(line)}`).join("");
|
|
619558
|
+
return firstLine + restLines;
|
|
619559
|
+
}
|
|
619560
|
+
return lines.map((line) => `
|
|
619561
|
+
${baseIndentStr}${colorFn(line)}`).join("");
|
|
619562
|
+
}
|
|
619563
|
+
var Icons = {
|
|
619564
|
+
error: source_default.red("\u2717"),
|
|
619565
|
+
warning: source_default.yellow("\u26A0"),
|
|
619566
|
+
success: source_default.green("\u2713"),
|
|
619567
|
+
info: source_default.cyan("\u25C6")
|
|
619568
|
+
};
|
|
619569
|
+
var Colors = {
|
|
619570
|
+
error: source_default.red.bind(source_default),
|
|
619571
|
+
warning: source_default.yellow.bind(source_default),
|
|
619572
|
+
success: source_default.green.bind(source_default),
|
|
619573
|
+
info: source_default.cyan.bind(source_default),
|
|
619574
|
+
dim: source_default.dim.bind(source_default)
|
|
619575
|
+
};
|
|
619576
|
+
function formatBytes(bytes) {
|
|
619577
|
+
if (bytes === 0) {
|
|
619578
|
+
return "0 B";
|
|
619579
|
+
}
|
|
619580
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
619581
|
+
const base4 = 1024;
|
|
619582
|
+
const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
|
|
619583
|
+
const value = bytes / Math.pow(base4, index3);
|
|
619584
|
+
return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
|
|
619585
|
+
}
|
|
619586
|
+
|
|
620223
619587
|
// ../auth/lib/orgs/checkOrganizationMembership.js
|
|
620224
619588
|
async function checkOrganizationMembership({ organization, token }) {
|
|
620225
619589
|
const venus = createVenusService({ token: token.value });
|
|
@@ -627639,7 +627003,7 @@ var AccessTokenPosthogManager = class {
|
|
|
627639
627003
|
properties: {
|
|
627640
627004
|
...event,
|
|
627641
627005
|
...event.properties,
|
|
627642
|
-
version: "4.68.
|
|
627006
|
+
version: "4.68.3-1-g429be56b56f",
|
|
627643
627007
|
usingAccessToken: true
|
|
627644
627008
|
}
|
|
627645
627009
|
});
|
|
@@ -627693,7 +627057,7 @@ var UserPosthogManager = class {
|
|
|
627693
627057
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
627694
627058
|
event: "CLI",
|
|
627695
627059
|
properties: {
|
|
627696
|
-
version: "4.68.
|
|
627060
|
+
version: "4.68.3-1-g429be56b56f",
|
|
627697
627061
|
...event,
|
|
627698
627062
|
...event.properties,
|
|
627699
627063
|
usingAccessToken: false,
|
|
@@ -631205,7 +630569,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
631205
630569
|
* The caller is responsible for deciding which errors are worth reporting
|
|
631206
630570
|
* (see `shouldReportToSentry` in withContext.ts).
|
|
631207
630571
|
*/
|
|
631208
|
-
captureException(error50) {
|
|
630572
|
+
captureException(error50, { errorCode }) {
|
|
631209
630573
|
if (this.sentry === void 0) {
|
|
631210
630574
|
return;
|
|
631211
630575
|
}
|
|
@@ -631213,7 +630577,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
631213
630577
|
this.sentry.captureException(error50, {
|
|
631214
630578
|
captureContext: {
|
|
631215
630579
|
user: { id: this.distinctId },
|
|
631216
|
-
tags: { ...this.baseTags, ...this.accumulatedTags }
|
|
630580
|
+
tags: { ...this.baseTags, ...this.accumulatedTags, "error.code": errorCode }
|
|
631217
630581
|
}
|
|
631218
630582
|
});
|
|
631219
630583
|
} catch {
|
|
@@ -632113,6 +631477,7 @@ var Context = class _Context {
|
|
|
632113
631477
|
shutdownCallbacks = [];
|
|
632114
631478
|
isShuttingDown = false;
|
|
632115
631479
|
logFilePathPrinted = false;
|
|
631480
|
+
createdAt = Date.now();
|
|
632116
631481
|
cwd;
|
|
632117
631482
|
logLevel;
|
|
632118
631483
|
info;
|
|
@@ -632130,10 +631495,10 @@ var Context = class _Context {
|
|
|
632130
631495
|
}
|
|
632131
631496
|
constructor({ cwd: cwd2, logLevel, ttyAwareLogger, telemetry }) {
|
|
632132
631497
|
this.cwd = cwd2 ?? AbsoluteFilePath2.of(process.cwd());
|
|
632133
|
-
this.logLevel = logLevel ??
|
|
631498
|
+
this.logLevel = logLevel ?? LogLevel.Info;
|
|
632134
631499
|
this.info = parseCommandInfo(process.argv);
|
|
632135
|
-
this.stdout =
|
|
632136
|
-
this.stderr =
|
|
631500
|
+
this.stdout = createLogger((level, ...args) => this.log(level, ...args));
|
|
631501
|
+
this.stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
632137
631502
|
this.cache = new Cache({ logger: this.stderr });
|
|
632138
631503
|
this.logs = new LogFileWriter(this.cache.logs.absoluteFilePath);
|
|
632139
631504
|
this.ttyAwareLogger = ttyAwareLogger;
|
|
@@ -632191,7 +631556,7 @@ var Context = class _Context {
|
|
|
632191
631556
|
this.stderr.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
632192
631557
|
this.stderr.info("");
|
|
632193
631558
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
632194
|
-
throw CliError.
|
|
631559
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632195
631560
|
}
|
|
632196
631561
|
return await this.promptAndLogin();
|
|
632197
631562
|
}
|
|
@@ -632201,7 +631566,7 @@ var Context = class _Context {
|
|
|
632201
631566
|
this.stderr.error(`${Icons.error} Your access token has expired.`);
|
|
632202
631567
|
this.stderr.info("");
|
|
632203
631568
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
632204
|
-
throw CliError.
|
|
631569
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632205
631570
|
}
|
|
632206
631571
|
return await this.promptAndLogin();
|
|
632207
631572
|
}
|
|
@@ -632217,7 +631582,7 @@ var Context = class _Context {
|
|
|
632217
631582
|
}
|
|
632218
631583
|
]);
|
|
632219
631584
|
if (!confirm) {
|
|
632220
|
-
throw CliError.
|
|
631585
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632221
631586
|
}
|
|
632222
631587
|
this.stderr.info(`${Icons.info} Opening browser to log in to Fern...`);
|
|
632223
631588
|
this.stderr.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
@@ -632229,12 +631594,12 @@ var Context = class _Context {
|
|
|
632229
631594
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
632230
631595
|
if (payload == null) {
|
|
632231
631596
|
this.stderr.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
632232
|
-
throw CliError.
|
|
631597
|
+
throw new CliError({ code: CliError.Code.InternalError });
|
|
632233
631598
|
}
|
|
632234
631599
|
const email3 = payload.email;
|
|
632235
631600
|
if (email3 == null) {
|
|
632236
631601
|
this.stderr.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
632237
|
-
throw CliError.
|
|
631602
|
+
throw new CliError({ code: CliError.Code.InternalError });
|
|
632238
631603
|
}
|
|
632239
631604
|
await this.tokenService.login(email3, accessToken);
|
|
632240
631605
|
this.stderr.info(`${Icons.success} Logged in as ${source_default.bold(email3)}`);
|
|
@@ -632365,7 +631730,7 @@ ${source_default.dim(`Logs written to: ${this.logs.absoluteFilePath}`)}
|
|
|
632365
631730
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
632366
631731
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
632367
631732
|
this.ttyAwareLogger.log(filtered, {
|
|
632368
|
-
includeDebugInfo: this.logLevel ===
|
|
631733
|
+
includeDebugInfo: this.logLevel === LogLevel.Debug,
|
|
632369
631734
|
stderr
|
|
632370
631735
|
});
|
|
632371
631736
|
}
|
|
@@ -632378,28 +631743,19 @@ var SIGTERM_EXIT_CODE = SIGNAL_EXIT_CODE_BASE + 15;
|
|
|
632378
631743
|
function withContext(handler3) {
|
|
632379
631744
|
return async (args) => {
|
|
632380
631745
|
const context3 = await createContext(args);
|
|
632381
|
-
const startTime = Date.now();
|
|
632382
631746
|
setupSignalHandler(context3);
|
|
632383
631747
|
try {
|
|
632384
631748
|
await handler3(context3, args);
|
|
632385
631749
|
context3.telemetry.sendLifecycleEvent({
|
|
632386
631750
|
command: context3.info.command,
|
|
632387
631751
|
status: "success",
|
|
632388
|
-
durationMs: Date.now() -
|
|
631752
|
+
durationMs: Date.now() - context3.createdAt
|
|
632389
631753
|
});
|
|
632390
631754
|
await context3.telemetry.flush();
|
|
632391
631755
|
context3.finish();
|
|
632392
631756
|
await exitGracefully(0);
|
|
632393
631757
|
} catch (error50) {
|
|
632394
|
-
|
|
632395
|
-
context3.telemetry.captureException(error50);
|
|
632396
|
-
}
|
|
632397
|
-
context3.telemetry.sendLifecycleEvent({
|
|
632398
|
-
command: context3.info.command,
|
|
632399
|
-
status: "error",
|
|
632400
|
-
durationMs: Date.now() - startTime,
|
|
632401
|
-
errorCode: extractErrorCode(error50)
|
|
632402
|
-
});
|
|
631758
|
+
reportError(context3, error50);
|
|
632403
631759
|
await context3.telemetry.flush();
|
|
632404
631760
|
handleError(context3, error50);
|
|
632405
631761
|
context3.finish();
|
|
@@ -632439,7 +631795,7 @@ function handleError(context3, error50) {
|
|
|
632439
631795
|
return;
|
|
632440
631796
|
}
|
|
632441
631797
|
if (error50 instanceof CliError) {
|
|
632442
|
-
if (error50.message.length > 0) {
|
|
631798
|
+
if (error50.message && error50.message.length > 0) {
|
|
632443
631799
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
632444
631800
|
`);
|
|
632445
631801
|
}
|
|
@@ -632448,7 +631804,7 @@ function handleError(context3, error50) {
|
|
|
632448
631804
|
if (error50 instanceof Error) {
|
|
632449
631805
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
632450
631806
|
`);
|
|
632451
|
-
if (error50.stack != null && context3.logLevel ===
|
|
631807
|
+
if (error50.stack != null && context3.logLevel === LogLevel.Debug) {
|
|
632452
631808
|
process.stderr.write(`${source_default.dim(error50.stack)}
|
|
632453
631809
|
`);
|
|
632454
631810
|
}
|
|
@@ -632457,29 +631813,23 @@ function handleError(context3, error50) {
|
|
|
632457
631813
|
process.stderr.write(`${source_default.red(String(error50))}
|
|
632458
631814
|
`);
|
|
632459
631815
|
}
|
|
632460
|
-
function
|
|
631816
|
+
function reportError(context3, error50, options2) {
|
|
632461
631817
|
if (error50 instanceof TaskAbortSignal) {
|
|
632462
|
-
return
|
|
632463
|
-
}
|
|
632464
|
-
if (error50 instanceof CliError) {
|
|
632465
|
-
return error50.code === "INTERNAL_ERROR";
|
|
632466
|
-
}
|
|
632467
|
-
if (error50 instanceof ValidationError || error50 instanceof SourcedValidationError || error50 instanceof KeyringUnavailableError) {
|
|
632468
|
-
return false;
|
|
632469
|
-
}
|
|
632470
|
-
return true;
|
|
632471
|
-
}
|
|
632472
|
-
function extractErrorCode(error50) {
|
|
632473
|
-
if (error50 instanceof CliError && error50.code != null) {
|
|
632474
|
-
return error50.code;
|
|
632475
|
-
}
|
|
632476
|
-
if (error50 instanceof ValidationError || error50 instanceof SourcedValidationError) {
|
|
632477
|
-
return "VALIDATION_ERROR";
|
|
631818
|
+
return;
|
|
632478
631819
|
}
|
|
632479
|
-
|
|
632480
|
-
|
|
631820
|
+
const code5 = resolveErrorCode(error50, options2?.code);
|
|
631821
|
+
const capturable = error50 ?? new CliError({ message: options2?.message ?? "", code: code5 });
|
|
631822
|
+
if (shouldReportToSentry(code5)) {
|
|
631823
|
+
context3.telemetry.captureException(capturable, {
|
|
631824
|
+
errorCode: code5
|
|
631825
|
+
});
|
|
632481
631826
|
}
|
|
632482
|
-
|
|
631827
|
+
context3.telemetry.sendLifecycleEvent({
|
|
631828
|
+
status: "error",
|
|
631829
|
+
command: context3.info.command,
|
|
631830
|
+
durationMs: Date.now() - context3.createdAt,
|
|
631831
|
+
errorCode: code5
|
|
631832
|
+
});
|
|
632483
631833
|
}
|
|
632484
631834
|
function setupSignalHandler(context3) {
|
|
632485
631835
|
const onSignal = (exitCode) => {
|
|
@@ -632504,18 +631854,771 @@ function exitGracefully(code5) {
|
|
|
632504
631854
|
function parseLogLevel(level) {
|
|
632505
631855
|
switch (level.toLowerCase()) {
|
|
632506
631856
|
case "debug":
|
|
632507
|
-
return
|
|
631857
|
+
return LogLevel.Debug;
|
|
632508
631858
|
case "info":
|
|
632509
|
-
return
|
|
631859
|
+
return LogLevel.Info;
|
|
632510
631860
|
case "warn":
|
|
632511
|
-
return
|
|
631861
|
+
return LogLevel.Warn;
|
|
632512
631862
|
case "error":
|
|
632513
|
-
return
|
|
631863
|
+
return LogLevel.Error;
|
|
632514
631864
|
default:
|
|
632515
|
-
return
|
|
631865
|
+
return LogLevel.Info;
|
|
632516
631866
|
}
|
|
632517
631867
|
}
|
|
632518
631868
|
|
|
631869
|
+
// ../cli-v2/lib/context/adapter/TaskContextLogger.js
|
|
631870
|
+
var TaskContextLogger = class {
|
|
631871
|
+
context;
|
|
631872
|
+
task;
|
|
631873
|
+
logLevel;
|
|
631874
|
+
enabled = true;
|
|
631875
|
+
collectedErrors = [];
|
|
631876
|
+
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631877
|
+
this.context = context3;
|
|
631878
|
+
this.task = task;
|
|
631879
|
+
this.logLevel = logLevel;
|
|
631880
|
+
}
|
|
631881
|
+
disable() {
|
|
631882
|
+
this.enabled = false;
|
|
631883
|
+
}
|
|
631884
|
+
enable() {
|
|
631885
|
+
this.enabled = true;
|
|
631886
|
+
}
|
|
631887
|
+
trace(..._args) {
|
|
631888
|
+
}
|
|
631889
|
+
debug(...args) {
|
|
631890
|
+
const message = args.join(" ");
|
|
631891
|
+
this.writeLog({ level: LogLevel.Debug, message });
|
|
631892
|
+
if (this.shouldLogToTask(LogLevel.Debug)) {
|
|
631893
|
+
if (this.task.logs == null) {
|
|
631894
|
+
this.task.logs = [];
|
|
631895
|
+
}
|
|
631896
|
+
this.task.logs.push({ level: "debug", message });
|
|
631897
|
+
}
|
|
631898
|
+
}
|
|
631899
|
+
info(...args) {
|
|
631900
|
+
const message = args.join(" ");
|
|
631901
|
+
this.writeLog({ level: LogLevel.Info, message });
|
|
631902
|
+
if (this.shouldLogToTask(LogLevel.Info)) {
|
|
631903
|
+
if (this.task.logs == null) {
|
|
631904
|
+
this.task.logs = [];
|
|
631905
|
+
}
|
|
631906
|
+
this.task.logs.push({ level: "debug", message });
|
|
631907
|
+
}
|
|
631908
|
+
}
|
|
631909
|
+
warn(...args) {
|
|
631910
|
+
const message = args.join(" ");
|
|
631911
|
+
this.writeLog({ level: LogLevel.Warn, message });
|
|
631912
|
+
if (this.shouldLogToTask(LogLevel.Warn)) {
|
|
631913
|
+
if (this.task.logs == null) {
|
|
631914
|
+
this.task.logs = [];
|
|
631915
|
+
}
|
|
631916
|
+
this.task.logs.push({ level: "warn", message });
|
|
631917
|
+
}
|
|
631918
|
+
}
|
|
631919
|
+
error(...args) {
|
|
631920
|
+
const message = args.join(" ");
|
|
631921
|
+
this.writeLog({ level: LogLevel.Error, message });
|
|
631922
|
+
if (this.shouldLogToTask(LogLevel.Error)) {
|
|
631923
|
+
this.collectedErrors.push(message);
|
|
631924
|
+
if (this.task.logs == null) {
|
|
631925
|
+
this.task.logs = [];
|
|
631926
|
+
}
|
|
631927
|
+
this.task.logs.push({ level: "error", message });
|
|
631928
|
+
}
|
|
631929
|
+
}
|
|
631930
|
+
log(level, ...args) {
|
|
631931
|
+
switch (level) {
|
|
631932
|
+
case LogLevel.Debug:
|
|
631933
|
+
this.debug(...args);
|
|
631934
|
+
break;
|
|
631935
|
+
case LogLevel.Info:
|
|
631936
|
+
this.info(...args);
|
|
631937
|
+
break;
|
|
631938
|
+
case LogLevel.Warn:
|
|
631939
|
+
this.warn(...args);
|
|
631940
|
+
break;
|
|
631941
|
+
case LogLevel.Error:
|
|
631942
|
+
this.error(...args);
|
|
631943
|
+
break;
|
|
631944
|
+
}
|
|
631945
|
+
}
|
|
631946
|
+
/**
|
|
631947
|
+
* Write a log entry to the log file. In CI / non-TTY environments,
|
|
631948
|
+
* also write directly to stderr so logs are visible in CI runner output.
|
|
631949
|
+
*/
|
|
631950
|
+
writeLog({ level, message }) {
|
|
631951
|
+
this.context.logs.write({ taskName: this.task.name, level, message });
|
|
631952
|
+
if (this.context.isTTY) {
|
|
631953
|
+
return;
|
|
631954
|
+
}
|
|
631955
|
+
if (!this.enabled) {
|
|
631956
|
+
return;
|
|
631957
|
+
}
|
|
631958
|
+
const prefix2 = source_default.dim(`[${this.task.name}]`);
|
|
631959
|
+
switch (level) {
|
|
631960
|
+
case LogLevel.Warn:
|
|
631961
|
+
process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
|
|
631962
|
+
`);
|
|
631963
|
+
break;
|
|
631964
|
+
case LogLevel.Error:
|
|
631965
|
+
process.stderr.write(`${prefix2}: ${source_default.red(message)}
|
|
631966
|
+
`);
|
|
631967
|
+
break;
|
|
631968
|
+
default:
|
|
631969
|
+
process.stderr.write(`${prefix2}: ${message}
|
|
631970
|
+
`);
|
|
631971
|
+
break;
|
|
631972
|
+
}
|
|
631973
|
+
}
|
|
631974
|
+
/**
|
|
631975
|
+
* Check if a message at the given level should be logged to the task's UI.
|
|
631976
|
+
*/
|
|
631977
|
+
shouldLogToTask(level) {
|
|
631978
|
+
return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
|
|
631979
|
+
}
|
|
631980
|
+
};
|
|
631981
|
+
|
|
631982
|
+
// ../cli-v2/lib/context/adapter/TaskContextAdapter.js
|
|
631983
|
+
var TaskContextAdapter = class {
|
|
631984
|
+
result = TaskResult.Success;
|
|
631985
|
+
context;
|
|
631986
|
+
logger;
|
|
631987
|
+
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631988
|
+
this.context = context3;
|
|
631989
|
+
if (task != null) {
|
|
631990
|
+
this.logger = new TaskContextLogger({ context: context3, task, logLevel });
|
|
631991
|
+
} else {
|
|
631992
|
+
this.logger = createLogger((level, ...args) => {
|
|
631993
|
+
if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
|
|
631994
|
+
context3.stderr.log(level, ...args);
|
|
631995
|
+
}
|
|
631996
|
+
});
|
|
631997
|
+
}
|
|
631998
|
+
}
|
|
631999
|
+
async takeOverTerminal(run) {
|
|
632000
|
+
await run();
|
|
632001
|
+
}
|
|
632002
|
+
failAndThrow(message, error50, options2) {
|
|
632003
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
632004
|
+
throw new TaskAbortSignal();
|
|
632005
|
+
}
|
|
632006
|
+
failWithoutThrowing(message, error50, options2) {
|
|
632007
|
+
this.result = TaskResult.Failure;
|
|
632008
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
632009
|
+
return;
|
|
632010
|
+
}
|
|
632011
|
+
const fullMessage = this.getFullErrorMessage(message, error50);
|
|
632012
|
+
if (fullMessage != null) {
|
|
632013
|
+
this.logger.error(fullMessage);
|
|
632014
|
+
}
|
|
632015
|
+
reportError(this.context, error50, { ...options2, message });
|
|
632016
|
+
}
|
|
632017
|
+
captureException(error50, code5) {
|
|
632018
|
+
const errorCode = resolveErrorCode(error50, code5);
|
|
632019
|
+
this.context.telemetry.captureException(error50, { errorCode });
|
|
632020
|
+
}
|
|
632021
|
+
getFullErrorMessage(message, error50) {
|
|
632022
|
+
const errorDetails = this.formatError(error50);
|
|
632023
|
+
if (message != null && errorDetails != null) {
|
|
632024
|
+
return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
|
|
632025
|
+
}
|
|
632026
|
+
return message ?? errorDetails;
|
|
632027
|
+
}
|
|
632028
|
+
getResult() {
|
|
632029
|
+
return this.result;
|
|
632030
|
+
}
|
|
632031
|
+
addInteractiveTask(_params) {
|
|
632032
|
+
const subtask = {
|
|
632033
|
+
logger: this.logger,
|
|
632034
|
+
takeOverTerminal: this.takeOverTerminal.bind(this),
|
|
632035
|
+
failAndThrow: this.failAndThrow.bind(this),
|
|
632036
|
+
failWithoutThrowing: this.failWithoutThrowing.bind(this),
|
|
632037
|
+
captureException: this.captureException.bind(this),
|
|
632038
|
+
getResult: () => this.result,
|
|
632039
|
+
addInteractiveTask: this.addInteractiveTask.bind(this),
|
|
632040
|
+
runInteractiveTask: this.runInteractiveTask.bind(this),
|
|
632041
|
+
instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
|
|
632042
|
+
setSubtitle: (_subtitle) => {
|
|
632043
|
+
},
|
|
632044
|
+
start: () => {
|
|
632045
|
+
return subtask;
|
|
632046
|
+
},
|
|
632047
|
+
isStarted: () => true,
|
|
632048
|
+
finish: () => {
|
|
632049
|
+
},
|
|
632050
|
+
isFinished: () => true
|
|
632051
|
+
};
|
|
632052
|
+
return subtask;
|
|
632053
|
+
}
|
|
632054
|
+
async runInteractiveTask(params2, run) {
|
|
632055
|
+
const subtask = this.addInteractiveTask(params2).start();
|
|
632056
|
+
try {
|
|
632057
|
+
await run(subtask);
|
|
632058
|
+
return true;
|
|
632059
|
+
} catch {
|
|
632060
|
+
return false;
|
|
632061
|
+
}
|
|
632062
|
+
}
|
|
632063
|
+
instrumentPostHogEvent(_event) {
|
|
632064
|
+
}
|
|
632065
|
+
formatError(error50) {
|
|
632066
|
+
if (error50 == null) {
|
|
632067
|
+
return void 0;
|
|
632068
|
+
}
|
|
632069
|
+
if (error50 instanceof Error) {
|
|
632070
|
+
return error50.message;
|
|
632071
|
+
}
|
|
632072
|
+
if (typeof error50 === "string") {
|
|
632073
|
+
return error50;
|
|
632074
|
+
}
|
|
632075
|
+
if (typeof error50 === "object") {
|
|
632076
|
+
const message = this.extractErrorMessage(error50);
|
|
632077
|
+
if (message != null) {
|
|
632078
|
+
return message;
|
|
632079
|
+
}
|
|
632080
|
+
}
|
|
632081
|
+
try {
|
|
632082
|
+
return JSON.stringify(error50);
|
|
632083
|
+
} catch {
|
|
632084
|
+
return String(error50);
|
|
632085
|
+
}
|
|
632086
|
+
}
|
|
632087
|
+
/**
|
|
632088
|
+
* Attempts to extract a human-readable message from a structured error object.
|
|
632089
|
+
*
|
|
632090
|
+
* Handles common shapes from the FDR SDK and other API clients, e.g.:
|
|
632091
|
+
* { content: { body: { message: "..." } } }
|
|
632092
|
+
* { body: { message: "..." } }
|
|
632093
|
+
* { message: "..." }
|
|
632094
|
+
*/
|
|
632095
|
+
extractErrorMessage(error50) {
|
|
632096
|
+
const record21 = error50;
|
|
632097
|
+
if (typeof record21.message === "string") {
|
|
632098
|
+
return record21.message;
|
|
632099
|
+
}
|
|
632100
|
+
if (record21.body != null && typeof record21.body === "object") {
|
|
632101
|
+
const body = record21.body;
|
|
632102
|
+
if (typeof body.message === "string") {
|
|
632103
|
+
return body.message;
|
|
632104
|
+
}
|
|
632105
|
+
}
|
|
632106
|
+
if (record21.content != null && typeof record21.content === "object") {
|
|
632107
|
+
return this.extractErrorMessage(record21.content);
|
|
632108
|
+
}
|
|
632109
|
+
return void 0;
|
|
632110
|
+
}
|
|
632111
|
+
};
|
|
632112
|
+
|
|
632113
|
+
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632114
|
+
init_lib6();
|
|
632115
|
+
|
|
632116
|
+
// ../cli-v2/lib/api/config/OpenRpcSpec.js
|
|
632117
|
+
function isOpenRpcSpec(spec) {
|
|
632118
|
+
return "openrpc" in spec;
|
|
632119
|
+
}
|
|
632120
|
+
|
|
632121
|
+
// ../cli-v2/lib/api/config/ProtobufSpec.js
|
|
632122
|
+
function isProtobufSpec(spec) {
|
|
632123
|
+
return "proto" in spec;
|
|
632124
|
+
}
|
|
632125
|
+
|
|
632126
|
+
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632127
|
+
var LegacyApiSpecAdapter = class {
|
|
632128
|
+
context;
|
|
632129
|
+
constructor(config5) {
|
|
632130
|
+
this.context = config5.context;
|
|
632131
|
+
}
|
|
632132
|
+
adapt(spec) {
|
|
632133
|
+
if (isOpenApiSpec(spec)) {
|
|
632134
|
+
return this.adaptOpenApiSpec(spec);
|
|
632135
|
+
}
|
|
632136
|
+
if (isAsyncApiSpec(spec)) {
|
|
632137
|
+
return this.adaptAsyncApiSpec(spec);
|
|
632138
|
+
}
|
|
632139
|
+
if (isProtobufSpec(spec)) {
|
|
632140
|
+
return this.adaptProtobufSpec(spec);
|
|
632141
|
+
}
|
|
632142
|
+
if (isOpenRpcSpec(spec)) {
|
|
632143
|
+
return this.adaptOpenRpcSpec(spec);
|
|
632144
|
+
}
|
|
632145
|
+
throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
|
|
632146
|
+
}
|
|
632147
|
+
convertAll(specs) {
|
|
632148
|
+
return specs.map((spec) => this.adapt(spec));
|
|
632149
|
+
}
|
|
632150
|
+
adaptOpenApiSpec(spec) {
|
|
632151
|
+
return {
|
|
632152
|
+
type: "openapi",
|
|
632153
|
+
absoluteFilepath: spec.openapi,
|
|
632154
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632155
|
+
absoluteFilepathToOverlays: spec.overlays,
|
|
632156
|
+
namespace: spec.namespace,
|
|
632157
|
+
source: {
|
|
632158
|
+
type: "openapi",
|
|
632159
|
+
file: spec.openapi
|
|
632160
|
+
},
|
|
632161
|
+
settings: this.adaptOpenApiSettings(spec.settings)
|
|
632162
|
+
};
|
|
632163
|
+
}
|
|
632164
|
+
adaptAsyncApiSpec(spec) {
|
|
632165
|
+
return {
|
|
632166
|
+
type: "openapi",
|
|
632167
|
+
absoluteFilepath: spec.asyncapi,
|
|
632168
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632169
|
+
absoluteFilepathToOverlays: void 0,
|
|
632170
|
+
namespace: spec.namespace,
|
|
632171
|
+
source: {
|
|
632172
|
+
type: "asyncapi",
|
|
632173
|
+
file: spec.asyncapi
|
|
632174
|
+
},
|
|
632175
|
+
settings: this.adaptAsyncApiSettings(spec.settings)
|
|
632176
|
+
};
|
|
632177
|
+
}
|
|
632178
|
+
adaptProtobufSpec(spec) {
|
|
632179
|
+
const proto3 = spec.proto;
|
|
632180
|
+
return {
|
|
632181
|
+
type: "protobuf",
|
|
632182
|
+
absoluteFilepathToProtobufRoot: proto3.root,
|
|
632183
|
+
absoluteFilepathToProtobufTarget: proto3.target,
|
|
632184
|
+
absoluteFilepathToOverrides: proto3.overrides,
|
|
632185
|
+
relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
|
|
632186
|
+
generateLocally: proto3.localGeneration ?? false,
|
|
632187
|
+
fromOpenAPI: proto3.fromOpenapi ?? false,
|
|
632188
|
+
dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
|
|
632189
|
+
settings: void 0
|
|
632190
|
+
};
|
|
632191
|
+
}
|
|
632192
|
+
adaptOpenRpcSpec(spec) {
|
|
632193
|
+
return {
|
|
632194
|
+
type: "openrpc",
|
|
632195
|
+
absoluteFilepath: spec.openrpc,
|
|
632196
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632197
|
+
namespace: void 0
|
|
632198
|
+
};
|
|
632199
|
+
}
|
|
632200
|
+
adaptOpenApiSettings(settings) {
|
|
632201
|
+
if (settings == null) {
|
|
632202
|
+
return void 0;
|
|
632203
|
+
}
|
|
632204
|
+
const result = {
|
|
632205
|
+
// Base API settings
|
|
632206
|
+
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632207
|
+
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632208
|
+
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632209
|
+
useTitlesAsName: settings.titleAsSchemaName,
|
|
632210
|
+
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632211
|
+
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632212
|
+
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632213
|
+
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632214
|
+
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632215
|
+
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632216
|
+
// OpenAPI-specific settings
|
|
632217
|
+
respectReadonlySchemas: settings.respectReadonlySchemas,
|
|
632218
|
+
onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
|
|
632219
|
+
inlinePathParameters: settings.inlinePathParameters,
|
|
632220
|
+
shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
|
|
632221
|
+
objectQueryParameters: settings.objectQueryParameters,
|
|
632222
|
+
respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
|
|
632223
|
+
useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
|
|
632224
|
+
defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
|
|
632225
|
+
filter: settings.filter,
|
|
632226
|
+
exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
|
|
632227
|
+
additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
|
|
632228
|
+
typeDatesAsStrings: settings.typeDatesAsStrings,
|
|
632229
|
+
preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
|
|
632230
|
+
inlineAllOfSchemas: settings.inlineAllOfSchemas,
|
|
632231
|
+
resolveAliases: settings.resolveAliases,
|
|
632232
|
+
groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
|
|
632233
|
+
defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
|
|
632234
|
+
coerceConstsTo: settings.coerceConstsTo
|
|
632235
|
+
};
|
|
632236
|
+
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632237
|
+
return hasSettings ? result : void 0;
|
|
632238
|
+
}
|
|
632239
|
+
adaptAsyncApiSettings(settings) {
|
|
632240
|
+
if (settings == null) {
|
|
632241
|
+
return void 0;
|
|
632242
|
+
}
|
|
632243
|
+
const result = {
|
|
632244
|
+
// Base API settings (shared)
|
|
632245
|
+
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632246
|
+
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632247
|
+
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632248
|
+
useTitlesAsName: settings.titleAsSchemaName,
|
|
632249
|
+
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632250
|
+
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632251
|
+
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632252
|
+
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632253
|
+
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632254
|
+
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632255
|
+
// AsyncAPI-specific settings
|
|
632256
|
+
asyncApiNaming: settings.messageNaming,
|
|
632257
|
+
coerceConstsTo: settings.coerceConstsTo
|
|
632258
|
+
};
|
|
632259
|
+
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632260
|
+
return hasSettings ? result : void 0;
|
|
632261
|
+
}
|
|
632262
|
+
adaptRemoveDiscriminantsFromSchemas(value) {
|
|
632263
|
+
if (value == null) {
|
|
632264
|
+
return void 0;
|
|
632265
|
+
}
|
|
632266
|
+
switch (value) {
|
|
632267
|
+
case "always":
|
|
632268
|
+
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
|
|
632269
|
+
case "never":
|
|
632270
|
+
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
|
|
632271
|
+
default:
|
|
632272
|
+
return void 0;
|
|
632273
|
+
}
|
|
632274
|
+
}
|
|
632275
|
+
adaptPathParameterOrder(value) {
|
|
632276
|
+
if (value == null) {
|
|
632277
|
+
return void 0;
|
|
632278
|
+
}
|
|
632279
|
+
switch (value) {
|
|
632280
|
+
case "urlOrder":
|
|
632281
|
+
return generators_yml_exports.PathParameterOrder.UrlOrder;
|
|
632282
|
+
case "specOrder":
|
|
632283
|
+
return generators_yml_exports.PathParameterOrder.SpecOrder;
|
|
632284
|
+
default:
|
|
632285
|
+
return void 0;
|
|
632286
|
+
}
|
|
632287
|
+
}
|
|
632288
|
+
adaptDefaultIntegerFormat(value) {
|
|
632289
|
+
if (value == null) {
|
|
632290
|
+
return void 0;
|
|
632291
|
+
}
|
|
632292
|
+
switch (value) {
|
|
632293
|
+
case "int32":
|
|
632294
|
+
return generators_yml_exports.DefaultIntegerFormat.Int32;
|
|
632295
|
+
case "int64":
|
|
632296
|
+
return generators_yml_exports.DefaultIntegerFormat.Int64;
|
|
632297
|
+
case "uint32":
|
|
632298
|
+
return generators_yml_exports.DefaultIntegerFormat.Uint32;
|
|
632299
|
+
case "uint64":
|
|
632300
|
+
return generators_yml_exports.DefaultIntegerFormat.Uint64;
|
|
632301
|
+
default:
|
|
632302
|
+
return void 0;
|
|
632303
|
+
}
|
|
632304
|
+
}
|
|
632305
|
+
adaptExampleGeneration(value) {
|
|
632306
|
+
if (value == null) {
|
|
632307
|
+
return void 0;
|
|
632308
|
+
}
|
|
632309
|
+
const result = {};
|
|
632310
|
+
if (value.request != null) {
|
|
632311
|
+
result.request = { "max-depth": value.request.maxDepth };
|
|
632312
|
+
}
|
|
632313
|
+
if (value.response != null) {
|
|
632314
|
+
result.response = { "max-depth": value.response.maxDepth };
|
|
632315
|
+
}
|
|
632316
|
+
return result;
|
|
632317
|
+
}
|
|
632318
|
+
};
|
|
632319
|
+
|
|
632320
|
+
// ../cli-v2/lib/api/config/ConjureSpec.js
|
|
632321
|
+
function isConjureSpec(spec) {
|
|
632322
|
+
return "conjure" in spec;
|
|
632323
|
+
}
|
|
632324
|
+
|
|
632325
|
+
// ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
|
|
632326
|
+
var ApiDefinitionValidator = class {
|
|
632327
|
+
context;
|
|
632328
|
+
taskContext;
|
|
632329
|
+
cliVersion;
|
|
632330
|
+
constructor(config5) {
|
|
632331
|
+
this.context = config5.context;
|
|
632332
|
+
this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
|
|
632333
|
+
this.cliVersion = config5.cliVersion;
|
|
632334
|
+
}
|
|
632335
|
+
/**
|
|
632336
|
+
* Validate an ApiDefinition.
|
|
632337
|
+
*
|
|
632338
|
+
* Runs both Fern definition validation and OSS workspace validation
|
|
632339
|
+
* to ensure the API definition is valid before generation.
|
|
632340
|
+
*/
|
|
632341
|
+
async validate(definition3) {
|
|
632342
|
+
const startTime = performance.now();
|
|
632343
|
+
const violations = [];
|
|
632344
|
+
const fernSpec = definition3.specs.find(isFernSpec);
|
|
632345
|
+
if (fernSpec != null) {
|
|
632346
|
+
const fernViolations = await this.validateFernSpec(fernSpec);
|
|
632347
|
+
violations.push(...fernViolations);
|
|
632348
|
+
return {
|
|
632349
|
+
violations,
|
|
632350
|
+
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632351
|
+
workspaceRoot: fernSpec.fern,
|
|
632352
|
+
elapsedMillis: performance.now() - startTime
|
|
632353
|
+
};
|
|
632354
|
+
}
|
|
632355
|
+
const conjureSpec = definition3.specs.find(isConjureSpec);
|
|
632356
|
+
if (conjureSpec != null) {
|
|
632357
|
+
return {
|
|
632358
|
+
violations: [],
|
|
632359
|
+
hasErrors: false,
|
|
632360
|
+
workspaceRoot: this.context.cwd,
|
|
632361
|
+
elapsedMillis: performance.now() - startTime
|
|
632362
|
+
};
|
|
632363
|
+
}
|
|
632364
|
+
const ossViolations = await this.validateOssSpecs(definition3.specs);
|
|
632365
|
+
violations.push(...ossViolations);
|
|
632366
|
+
return {
|
|
632367
|
+
violations,
|
|
632368
|
+
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632369
|
+
workspaceRoot: this.context.cwd,
|
|
632370
|
+
elapsedMillis: performance.now() - startTime
|
|
632371
|
+
};
|
|
632372
|
+
}
|
|
632373
|
+
async validateFernSpec(spec) {
|
|
632374
|
+
const violations = [];
|
|
632375
|
+
const lazyWorkspace = new LazyFernWorkspace({
|
|
632376
|
+
absoluteFilePath: dirname6(spec.fern),
|
|
632377
|
+
context: this.taskContext,
|
|
632378
|
+
cliVersion: this.cliVersion,
|
|
632379
|
+
generatorsConfiguration: void 0,
|
|
632380
|
+
workspaceName: void 0,
|
|
632381
|
+
changelog: void 0
|
|
632382
|
+
});
|
|
632383
|
+
const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632384
|
+
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632385
|
+
violations.push(...fernViolations);
|
|
632386
|
+
return violations;
|
|
632387
|
+
}
|
|
632388
|
+
async validateOssSpecs(specs) {
|
|
632389
|
+
const violations = [];
|
|
632390
|
+
const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
|
|
632391
|
+
if (ossSpecs.length === 0) {
|
|
632392
|
+
return violations;
|
|
632393
|
+
}
|
|
632394
|
+
const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
|
|
632395
|
+
const v1Specs = specAdapter.convertAll(ossSpecs);
|
|
632396
|
+
const filteredSpecs = v1Specs.filter((spec) => {
|
|
632397
|
+
if (spec.type === "openrpc") {
|
|
632398
|
+
return false;
|
|
632399
|
+
}
|
|
632400
|
+
if (spec.type === "protobuf" && !spec.fromOpenAPI) {
|
|
632401
|
+
return false;
|
|
632402
|
+
}
|
|
632403
|
+
return true;
|
|
632404
|
+
});
|
|
632405
|
+
const allSpecs = v1Specs.filter((spec) => {
|
|
632406
|
+
if (spec.type === "protobuf" && spec.fromOpenAPI) {
|
|
632407
|
+
return false;
|
|
632408
|
+
}
|
|
632409
|
+
return true;
|
|
632410
|
+
});
|
|
632411
|
+
const ossWorkspace = new OSSWorkspace({
|
|
632412
|
+
specs: filteredSpecs,
|
|
632413
|
+
allSpecs,
|
|
632414
|
+
absoluteFilePath: this.context.cwd,
|
|
632415
|
+
cliVersion: this.cliVersion,
|
|
632416
|
+
changelog: void 0,
|
|
632417
|
+
generatorsConfiguration: void 0,
|
|
632418
|
+
workspaceName: void 0
|
|
632419
|
+
});
|
|
632420
|
+
const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632421
|
+
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632422
|
+
violations.push(...fernViolations);
|
|
632423
|
+
const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
|
|
632424
|
+
violations.push(...ossViolations);
|
|
632425
|
+
return violations;
|
|
632426
|
+
}
|
|
632427
|
+
};
|
|
632428
|
+
|
|
632429
|
+
// ../cli-v2/lib/api/checker/ApiChecker.js
|
|
632430
|
+
var ApiChecker = class {
|
|
632431
|
+
context;
|
|
632432
|
+
cliVersion;
|
|
632433
|
+
task;
|
|
632434
|
+
constructor(config5) {
|
|
632435
|
+
this.context = config5.context;
|
|
632436
|
+
this.cliVersion = config5.cliVersion;
|
|
632437
|
+
this.task = config5.task;
|
|
632438
|
+
}
|
|
632439
|
+
/**
|
|
632440
|
+
* Check APIs in the workspace and display results.
|
|
632441
|
+
*
|
|
632442
|
+
* @param strict - If true, display all warnings and treat them as errors. If false,
|
|
632443
|
+
* only show errors but still report warning count in summary.
|
|
632444
|
+
*/
|
|
632445
|
+
async check({ workspace, apiNames, strict = false }) {
|
|
632446
|
+
const startTime = performance.now();
|
|
632447
|
+
const validApis = /* @__PURE__ */ new Set();
|
|
632448
|
+
const invalidApis = /* @__PURE__ */ new Set();
|
|
632449
|
+
const apisToCheck = apiNames ?? Object.keys(workspace.apis);
|
|
632450
|
+
if (apisToCheck.length === 0) {
|
|
632451
|
+
return {
|
|
632452
|
+
validApis,
|
|
632453
|
+
invalidApis,
|
|
632454
|
+
violations: [],
|
|
632455
|
+
errorCount: 0,
|
|
632456
|
+
warningCount: 0,
|
|
632457
|
+
elapsedMillis: performance.now() - startTime
|
|
632458
|
+
};
|
|
632459
|
+
}
|
|
632460
|
+
const validator = new ApiDefinitionValidator({
|
|
632461
|
+
context: this.context,
|
|
632462
|
+
cliVersion: this.cliVersion,
|
|
632463
|
+
task: this.task
|
|
632464
|
+
});
|
|
632465
|
+
const allViolations = [];
|
|
632466
|
+
for (const apiName of apisToCheck) {
|
|
632467
|
+
const apiDefinition = workspace.apis[apiName];
|
|
632468
|
+
if (apiDefinition == null) {
|
|
632469
|
+
invalidApis.add(apiName);
|
|
632470
|
+
continue;
|
|
632471
|
+
}
|
|
632472
|
+
const result = await validator.validate(apiDefinition);
|
|
632473
|
+
if (result.hasErrors) {
|
|
632474
|
+
invalidApis.add(apiName);
|
|
632475
|
+
} else {
|
|
632476
|
+
validApis.add(apiName);
|
|
632477
|
+
}
|
|
632478
|
+
const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
|
|
632479
|
+
const resolvedViolations = this.resolveViolationPaths({
|
|
632480
|
+
workspaceRoot: result.workspaceRoot,
|
|
632481
|
+
apiName,
|
|
632482
|
+
apiSpecType,
|
|
632483
|
+
apiDefinition,
|
|
632484
|
+
violations: result.violations
|
|
632485
|
+
});
|
|
632486
|
+
allViolations.push(...resolvedViolations);
|
|
632487
|
+
}
|
|
632488
|
+
const dedupedViolations = this.deduplicateViolations(allViolations);
|
|
632489
|
+
return {
|
|
632490
|
+
...this.countViolations(dedupedViolations),
|
|
632491
|
+
validApis,
|
|
632492
|
+
invalidApis,
|
|
632493
|
+
violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632494
|
+
elapsedMillis: performance.now() - startTime
|
|
632495
|
+
};
|
|
632496
|
+
}
|
|
632497
|
+
resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
|
|
632498
|
+
return violations.map((violation) => {
|
|
632499
|
+
const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
|
|
632500
|
+
return {
|
|
632501
|
+
...violation,
|
|
632502
|
+
message,
|
|
632503
|
+
displayRelativeFilepath: this.resolveDisplayPath({
|
|
632504
|
+
workspaceRoot,
|
|
632505
|
+
apiDefinition,
|
|
632506
|
+
apiSpecType,
|
|
632507
|
+
violation
|
|
632508
|
+
}),
|
|
632509
|
+
apiSpecType,
|
|
632510
|
+
apiName,
|
|
632511
|
+
// We don't actually surface valuable line/column information yet, but
|
|
632512
|
+
// this at least points to the correct file.
|
|
632513
|
+
line: 1,
|
|
632514
|
+
column: 1
|
|
632515
|
+
};
|
|
632516
|
+
});
|
|
632517
|
+
}
|
|
632518
|
+
/**
|
|
632519
|
+
* Format a violation message for non-Fern (OSS) specs.
|
|
632520
|
+
*
|
|
632521
|
+
* Prepends a human-readable node path so users can locate the endpoint,
|
|
632522
|
+
* then strips synthetic file paths from the body of the message.
|
|
632523
|
+
*/
|
|
632524
|
+
formatOssMessage(violation) {
|
|
632525
|
+
const strippedMessage = this.stripSyntheticFilePaths(violation.message);
|
|
632526
|
+
const nodePathPrefix = this.formatNodePath(violation.nodePath);
|
|
632527
|
+
if (nodePathPrefix.length === 0) {
|
|
632528
|
+
return strippedMessage;
|
|
632529
|
+
}
|
|
632530
|
+
return `${nodePathPrefix} - ${strippedMessage}`;
|
|
632531
|
+
}
|
|
632532
|
+
/**
|
|
632533
|
+
* Formats a NodePath into a readable string like "endpoints -> getUser".
|
|
632534
|
+
*
|
|
632535
|
+
* Skips the leading "service" segment since it's implicit.
|
|
632536
|
+
*/
|
|
632537
|
+
formatNodePath(nodePath) {
|
|
632538
|
+
const parts = [];
|
|
632539
|
+
for (const item of nodePath) {
|
|
632540
|
+
if (typeof item === "string") {
|
|
632541
|
+
parts.push(item);
|
|
632542
|
+
} else {
|
|
632543
|
+
parts.push(item.key);
|
|
632544
|
+
}
|
|
632545
|
+
}
|
|
632546
|
+
if (parts[0] === "service") {
|
|
632547
|
+
parts.shift();
|
|
632548
|
+
}
|
|
632549
|
+
return parts.join(" -> ");
|
|
632550
|
+
}
|
|
632551
|
+
resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
|
|
632552
|
+
if (apiSpecType === "fern") {
|
|
632553
|
+
const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
|
|
632554
|
+
return relativize(this.context.cwd, absolutePath);
|
|
632555
|
+
}
|
|
632556
|
+
return this.resolveOssDisplayPath(apiDefinition, violation);
|
|
632557
|
+
}
|
|
632558
|
+
resolveOssDisplayPath(apiDefinition, violation) {
|
|
632559
|
+
const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
|
|
632560
|
+
if (ossSpecs.length === 0) {
|
|
632561
|
+
return violation.relativeFilepath;
|
|
632562
|
+
}
|
|
632563
|
+
if (ossSpecs.length > 1) {
|
|
632564
|
+
for (const spec of ossSpecs) {
|
|
632565
|
+
const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
|
|
632566
|
+
if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
|
|
632567
|
+
const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
|
|
632568
|
+
return relativize(this.context.cwd, filePath2);
|
|
632569
|
+
}
|
|
632570
|
+
}
|
|
632571
|
+
}
|
|
632572
|
+
const firstSpec = ossSpecs[0];
|
|
632573
|
+
if (firstSpec == null) {
|
|
632574
|
+
return violation.relativeFilepath;
|
|
632575
|
+
}
|
|
632576
|
+
const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
|
|
632577
|
+
return relativize(this.context.cwd, filePath);
|
|
632578
|
+
}
|
|
632579
|
+
deduplicateViolations(violations) {
|
|
632580
|
+
const seen = /* @__PURE__ */ new Set();
|
|
632581
|
+
return violations.filter((v23) => {
|
|
632582
|
+
const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
|
|
632583
|
+
if (seen.has(key2)) {
|
|
632584
|
+
return false;
|
|
632585
|
+
}
|
|
632586
|
+
seen.add(key2);
|
|
632587
|
+
return true;
|
|
632588
|
+
});
|
|
632589
|
+
}
|
|
632590
|
+
/**
|
|
632591
|
+
* Strip synthetic file path references from violation messages for non-Fern specs.
|
|
632592
|
+
*
|
|
632593
|
+
* The validator produces messages like:
|
|
632594
|
+
* "- pet.yml -> getPetById /pet/{petId}"
|
|
632595
|
+
* For non-Fern specs these file names are synthetic (they don't exist on disk),
|
|
632596
|
+
* so we strip them to produce:
|
|
632597
|
+
* "- getPetById /pet/{petId}"
|
|
632598
|
+
*/
|
|
632599
|
+
stripSyntheticFilePaths(message) {
|
|
632600
|
+
return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
|
|
632601
|
+
}
|
|
632602
|
+
countViolations(violations) {
|
|
632603
|
+
let errorCount = 0;
|
|
632604
|
+
let warningCount = 0;
|
|
632605
|
+
for (const violation of violations) {
|
|
632606
|
+
switch (violation.severity) {
|
|
632607
|
+
case "fatal":
|
|
632608
|
+
case "error":
|
|
632609
|
+
errorCount++;
|
|
632610
|
+
break;
|
|
632611
|
+
case "warning":
|
|
632612
|
+
warningCount++;
|
|
632613
|
+
break;
|
|
632614
|
+
default:
|
|
632615
|
+
assertNever(violation.severity);
|
|
632616
|
+
}
|
|
632617
|
+
}
|
|
632618
|
+
return { errorCount, warningCount };
|
|
632619
|
+
}
|
|
632620
|
+
};
|
|
632621
|
+
|
|
632519
632622
|
// ../cli-v2/lib/commands/_internal/command.js
|
|
632520
632623
|
function command2(cli, name2, description, handler3, builder) {
|
|
632521
632624
|
cli.command(name2, description, (yargs) => {
|
|
@@ -632559,7 +632662,8 @@ var CheckCommand = class {
|
|
|
632559
632662
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
632560
632663
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
632561
632664
|
throw new CliError({
|
|
632562
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
632665
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
|
|
632666
|
+
code: CliError.Code.ConfigError
|
|
632563
632667
|
});
|
|
632564
632668
|
}
|
|
632565
632669
|
const checker = new ApiChecker({ context: context3, cliVersion: workspace.cliVersion });
|
|
@@ -632573,7 +632677,7 @@ var CheckCommand = class {
|
|
|
632573
632677
|
const response = this.buildJsonResponse({ apiCheckResult: result, hasErrors });
|
|
632574
632678
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
632575
632679
|
if (hasErrors) {
|
|
632576
|
-
throw CliError.
|
|
632680
|
+
throw CliError.validationError();
|
|
632577
632681
|
}
|
|
632578
632682
|
return;
|
|
632579
632683
|
}
|
|
@@ -632585,7 +632689,7 @@ var CheckCommand = class {
|
|
|
632585
632689
|
}
|
|
632586
632690
|
}
|
|
632587
632691
|
if (hasErrors) {
|
|
632588
|
-
throw CliError.
|
|
632692
|
+
throw CliError.validationError();
|
|
632589
632693
|
}
|
|
632590
632694
|
if (result.warningCount > 0) {
|
|
632591
632695
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -759260,7 +759364,8 @@ var CompileCommand = class {
|
|
|
759260
759364
|
if (definition3 == null) {
|
|
759261
759365
|
const available2 = apiNames.join(", ");
|
|
759262
759366
|
throw new CliError({
|
|
759263
|
-
message: `API '${args.api}' not found. Available APIs: ${available2}
|
|
759367
|
+
message: `API '${args.api}' not found. Available APIs: ${available2}`,
|
|
759368
|
+
code: CliError.Code.ConfigError
|
|
759264
759369
|
});
|
|
759265
759370
|
}
|
|
759266
759371
|
return { apiName: args.api, definition: definition3 };
|
|
@@ -759269,20 +759374,23 @@ var CompileCommand = class {
|
|
|
759269
759374
|
const apiName = apiNames[0];
|
|
759270
759375
|
if (apiName == null) {
|
|
759271
759376
|
throw new CliError({
|
|
759272
|
-
message: "Internal error; no APIs found in workspace"
|
|
759377
|
+
message: "Internal error; no APIs found in workspace",
|
|
759378
|
+
code: CliError.Code.InternalError
|
|
759273
759379
|
});
|
|
759274
759380
|
}
|
|
759275
759381
|
const definition3 = workspace.apis[apiName];
|
|
759276
759382
|
if (definition3 == null) {
|
|
759277
759383
|
throw new CliError({
|
|
759278
|
-
message: `Internal error; API '${apiName}' not found in workspace
|
|
759384
|
+
message: `Internal error; API '${apiName}' not found in workspace`,
|
|
759385
|
+
code: CliError.Code.InternalError
|
|
759279
759386
|
});
|
|
759280
759387
|
}
|
|
759281
759388
|
return { apiName, definition: definition3 };
|
|
759282
759389
|
}
|
|
759283
759390
|
const available = apiNames.join(", ");
|
|
759284
759391
|
throw new CliError({
|
|
759285
|
-
message: `Multiple APIs found: ${available}. Use --api to select one
|
|
759392
|
+
message: `Multiple APIs found: ${available}. Use --api to select one.`,
|
|
759393
|
+
code: CliError.Code.ConfigError
|
|
759286
759394
|
});
|
|
759287
759395
|
}
|
|
759288
759396
|
async checkOrThrow({ context: context3, workspace, apiName }) {
|
|
@@ -759292,7 +759400,7 @@ var CompileCommand = class {
|
|
|
759292
759400
|
for (const violation of result.violations) {
|
|
759293
759401
|
context3.stderr.error(`${violation.displayRelativeFilepath}:${violation.line}:${violation.column}: ${violation.message}`);
|
|
759294
759402
|
}
|
|
759295
|
-
throw CliError.
|
|
759403
|
+
throw CliError.validationError(`API '${apiName}' has ${result.violations.length} validation errors`);
|
|
759296
759404
|
}
|
|
759297
759405
|
}
|
|
759298
759406
|
async writeOutput(context3, args, object21) {
|
|
@@ -759384,7 +759492,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759384
759492
|
const doc = document4.toJS();
|
|
759385
759493
|
if (doc == null || typeof doc !== "object") {
|
|
759386
759494
|
throw new CliError({
|
|
759387
|
-
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file
|
|
759495
|
+
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file.`,
|
|
759496
|
+
code: CliError.Code.ParseError
|
|
759388
759497
|
});
|
|
759389
759498
|
}
|
|
759390
759499
|
return new _FernYmlEditor(document4, config5.fernYmlPath);
|
|
@@ -759586,7 +759695,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759586
759695
|
const resolvedPath = join8(dirname6(this.rootFilePath), RelativeFilePath2.of(refPath));
|
|
759587
759696
|
if (!await doesPathExist(resolvedPath)) {
|
|
759588
759697
|
throw new CliError({
|
|
759589
|
-
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist
|
|
759698
|
+
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist.`,
|
|
759699
|
+
code: CliError.Code.ConfigError
|
|
759590
759700
|
});
|
|
759591
759701
|
}
|
|
759592
759702
|
const refContent = await (0, import_promises50.readFile)(resolvedPath, "utf-8");
|
|
@@ -759613,7 +759723,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759613
759723
|
const existing = section.document.getIn([...section.basePath, name2]);
|
|
759614
759724
|
if (existing == null) {
|
|
759615
759725
|
throw new CliError({
|
|
759616
|
-
message: `Target '${name2}' not found in SDK configuration
|
|
759726
|
+
message: `Target '${name2}' not found in SDK configuration.`,
|
|
759727
|
+
code: CliError.Code.ConfigError
|
|
759617
759728
|
});
|
|
759618
759729
|
}
|
|
759619
759730
|
}
|
|
@@ -759941,9 +760052,9 @@ async function loadSpec(filepath) {
|
|
|
759941
760052
|
contents = await (0, import_promises51.readFile)(filepath, "utf8");
|
|
759942
760053
|
} catch (error50) {
|
|
759943
760054
|
if (isEnoentError(error50)) {
|
|
759944
|
-
throw new CliError({ message: `File does not exist: ${filepath}
|
|
760055
|
+
throw new CliError({ message: `File does not exist: ${filepath}`, code: CliError.Code.ConfigError });
|
|
759945
760056
|
}
|
|
759946
|
-
throw new CliError({ message: `Failed to read file: ${filepath}
|
|
760057
|
+
throw new CliError({ message: `Failed to read file: ${filepath}`, code: CliError.Code.ParseError });
|
|
759947
760058
|
}
|
|
759948
760059
|
return parseSpec(contents, filepath);
|
|
759949
760060
|
}
|
|
@@ -759954,7 +760065,10 @@ function parseSpec(contents, filepath) {
|
|
|
759954
760065
|
try {
|
|
759955
760066
|
return jsYaml.load(contents);
|
|
759956
760067
|
} catch {
|
|
759957
|
-
throw new CliError({
|
|
760068
|
+
throw new CliError({
|
|
760069
|
+
message: `Failed to parse file as JSON or YAML: ${filepath}`,
|
|
760070
|
+
code: CliError.Code.ParseError
|
|
760071
|
+
});
|
|
759958
760072
|
}
|
|
759959
760073
|
}
|
|
759960
760074
|
}
|
|
@@ -759973,7 +760087,7 @@ var MergeCommand = class {
|
|
|
759973
760087
|
async handle(context3, args) {
|
|
759974
760088
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
759975
760089
|
if (Object.keys(workspace.apis).length === 0) {
|
|
759976
|
-
throw new CliError({ message: "No APIs found in workspace." });
|
|
760090
|
+
throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
|
|
759977
760091
|
}
|
|
759978
760092
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
759979
760093
|
if (entries22.length === 0) {
|
|
@@ -759985,7 +760099,8 @@ var MergeCommand = class {
|
|
|
759985
760099
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
759986
760100
|
if (fernYmlPath == null) {
|
|
759987
760101
|
throw new CliError({
|
|
759988
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760102
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
760103
|
+
code: CliError.Code.ConfigError
|
|
759989
760104
|
});
|
|
759990
760105
|
}
|
|
759991
760106
|
editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760120,7 +760235,7 @@ var SplitCommand = class {
|
|
|
760120
760235
|
async handle(context3, args) {
|
|
760121
760236
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
760122
760237
|
if (Object.keys(workspace.apis).length === 0) {
|
|
760123
|
-
throw new CliError({ message: "No APIs found in workspace." });
|
|
760238
|
+
throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
|
|
760124
760239
|
}
|
|
760125
760240
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
760126
760241
|
if (entries22.length === 0) {
|
|
@@ -760131,7 +760246,8 @@ var SplitCommand = class {
|
|
|
760131
760246
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
760132
760247
|
if (fernYmlPath == null) {
|
|
760133
760248
|
throw new CliError({
|
|
760134
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760249
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
760250
|
+
code: CliError.Code.ConfigError
|
|
760135
760251
|
});
|
|
760136
760252
|
}
|
|
760137
760253
|
const editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760252,7 +760368,8 @@ var SplitCommand = class {
|
|
|
760252
760368
|
const detail = extractErrorMessage(error50);
|
|
760253
760369
|
throw new CliError({
|
|
760254
760370
|
message: `Failed to get file from git HEAD: ${absolutePath}. Is the file tracked by git and has at least one commit?
|
|
760255
|
-
Cause: ${detail}
|
|
760371
|
+
Cause: ${detail}`,
|
|
760372
|
+
code: CliError.Code.ParseError
|
|
760256
760373
|
});
|
|
760257
760374
|
}
|
|
760258
760375
|
}
|
|
@@ -760267,7 +760384,10 @@ var SplitCommand = class {
|
|
|
760267
760384
|
function resolvePathOrThrow(context3, outputPath) {
|
|
760268
760385
|
const resolved = context3.resolveOutputFilePath(outputPath);
|
|
760269
760386
|
if (resolved == null) {
|
|
760270
|
-
throw new CliError({
|
|
760387
|
+
throw new CliError({
|
|
760388
|
+
message: `Could not resolve output path: ${outputPath}`,
|
|
760389
|
+
code: CliError.Code.ConfigError
|
|
760390
|
+
});
|
|
760271
760391
|
}
|
|
760272
760392
|
return resolved;
|
|
760273
760393
|
}
|
|
@@ -760311,7 +760431,7 @@ var LoginCommand = class {
|
|
|
760311
760431
|
context3.stdout.info("Opening browser to log in to Fern...");
|
|
760312
760432
|
context3.stdout.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
760313
760433
|
}
|
|
760314
|
-
const taskContext = new TaskContextAdapter({ context: context3, logLevel:
|
|
760434
|
+
const taskContext = new TaskContextAdapter({ context: context3, logLevel: LogLevel.Info });
|
|
760315
760435
|
const tokenResponse = await getTokenFromAuth0(taskContext, {
|
|
760316
760436
|
useDeviceCodeFlow,
|
|
760317
760437
|
forceReauth: true
|
|
@@ -760323,12 +760443,12 @@ var LoginCommand = class {
|
|
|
760323
760443
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
760324
760444
|
if (payload == null) {
|
|
760325
760445
|
context3.stdout.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
760326
|
-
throw CliError.
|
|
760446
|
+
throw CliError.internalError();
|
|
760327
760447
|
}
|
|
760328
760448
|
const email3 = payload.email;
|
|
760329
760449
|
if (email3 == null) {
|
|
760330
760450
|
context3.stdout.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
760331
|
-
throw CliError.
|
|
760451
|
+
throw CliError.internalError();
|
|
760332
760452
|
}
|
|
760333
760453
|
const { isNew, totalAccounts } = await context3.tokenService.login(email3, accessToken);
|
|
760334
760454
|
if (isNew) {
|
|
@@ -760394,7 +760514,7 @@ var LogoutCommand = class {
|
|
|
760394
760514
|
context3.stdout.info("");
|
|
760395
760515
|
if (!context3.isTTY) {
|
|
760396
760516
|
context3.stdout.error(`${Icons.error} Use --force to skip confirmation in non-interactive mode`);
|
|
760397
|
-
throw CliError.
|
|
760517
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
760398
760518
|
}
|
|
760399
760519
|
const { confirmed } = await lib_default4.prompt([
|
|
760400
760520
|
{
|
|
@@ -760415,7 +760535,9 @@ var LogoutCommand = class {
|
|
|
760415
760535
|
const { removed, newActive } = await context3.tokenService.logout(user);
|
|
760416
760536
|
if (!removed) {
|
|
760417
760537
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760418
|
-
throw CliError
|
|
760538
|
+
throw new CliError({
|
|
760539
|
+
code: CliError.Code.EnvironmentError
|
|
760540
|
+
});
|
|
760419
760541
|
}
|
|
760420
760542
|
context3.stdout.info(`${Icons.success} Logged out of ${source_default.bold(user)}`);
|
|
760421
760543
|
if (newActive != null) {
|
|
@@ -760425,7 +760547,9 @@ var LogoutCommand = class {
|
|
|
760425
760547
|
async handleLogoutInteractive(context3, accounts) {
|
|
760426
760548
|
if (!context3.isTTY) {
|
|
760427
760549
|
context3.stdout.error(`${Icons.error} Multiple accounts found. Use --user or --all in non-interactive mode.`);
|
|
760428
|
-
throw CliError
|
|
760550
|
+
throw new CliError({
|
|
760551
|
+
code: CliError.Code.EnvironmentError
|
|
760552
|
+
});
|
|
760429
760553
|
}
|
|
760430
760554
|
const choices = accounts.map((account) => ({
|
|
760431
760555
|
name: account.isActive ? `${account.user} ${source_default.dim("(active)")}` : account.user,
|
|
@@ -760581,13 +760705,15 @@ var SwitchCommand = class {
|
|
|
760581
760705
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760582
760706
|
context3.stdout.info("");
|
|
760583
760707
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760584
|
-
throw CliError
|
|
760708
|
+
throw new CliError({
|
|
760709
|
+
code: CliError.Code.ConfigError
|
|
760710
|
+
});
|
|
760585
760711
|
}
|
|
760586
760712
|
if (accounts.length === 1) {
|
|
760587
760713
|
const account = accounts[0];
|
|
760588
760714
|
if (account == null) {
|
|
760589
760715
|
context3.stdout.error(`${Icons.error} Internal error; no accounts found`);
|
|
760590
|
-
throw CliError.
|
|
760716
|
+
throw CliError.internalError();
|
|
760591
760717
|
}
|
|
760592
760718
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You only have one account logged in: ${source_default.bold(account.user)}`);
|
|
760593
760719
|
context3.stdout.info("");
|
|
@@ -760610,7 +760736,9 @@ var SwitchCommand = class {
|
|
|
760610
760736
|
async handleInteractiveSwitch(context3, accounts) {
|
|
760611
760737
|
if (!context3.isTTY) {
|
|
760612
760738
|
context3.stdout.error(`${Icons.error} Use --user to specify account in non-interactive mode`);
|
|
760613
|
-
throw CliError
|
|
760739
|
+
throw new CliError({
|
|
760740
|
+
code: CliError.Code.EnvironmentError
|
|
760741
|
+
});
|
|
760614
760742
|
}
|
|
760615
760743
|
const choices = accounts.map((account) => ({
|
|
760616
760744
|
name: account.isActive ? `${account.user} ${source_default.dim("(current)")}` : account.user,
|
|
@@ -760631,7 +760759,9 @@ var SwitchCommand = class {
|
|
|
760631
760759
|
const success2 = await context3.tokenService.switchAccount(user);
|
|
760632
760760
|
if (!success2) {
|
|
760633
760761
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760634
|
-
throw CliError
|
|
760762
|
+
throw new CliError({
|
|
760763
|
+
code: CliError.Code.EnvironmentError
|
|
760764
|
+
});
|
|
760635
760765
|
}
|
|
760636
760766
|
context3.stdout.info(`${Icons.success} Switched to ${source_default.bold(user)}`);
|
|
760637
760767
|
}
|
|
@@ -760668,24 +760798,32 @@ var TokenCommand = class {
|
|
|
760668
760798
|
organizationNotFoundError: () => {
|
|
760669
760799
|
process.stderr.write(`${Icons.error} Organization "${orgId}" was not found.
|
|
760670
760800
|
`);
|
|
760671
|
-
throw CliError
|
|
760801
|
+
throw new CliError({
|
|
760802
|
+
code: CliError.Code.ConfigError
|
|
760803
|
+
});
|
|
760672
760804
|
},
|
|
760673
760805
|
unauthorizedError: () => {
|
|
760674
760806
|
process.stderr.write(`${Icons.error} You do not have access to organization "${orgId}".
|
|
760675
760807
|
`);
|
|
760676
|
-
throw CliError
|
|
760808
|
+
throw new CliError({
|
|
760809
|
+
code: CliError.Code.AuthError
|
|
760810
|
+
});
|
|
760677
760811
|
},
|
|
760678
760812
|
missingOrgPermissionsError: () => {
|
|
760679
760813
|
process.stderr.write(`${Icons.error} You do not have the required permissions in organization "${orgId}".
|
|
760680
760814
|
`);
|
|
760681
|
-
throw CliError
|
|
760815
|
+
throw new CliError({
|
|
760816
|
+
code: CliError.Code.AuthError
|
|
760817
|
+
});
|
|
760682
760818
|
},
|
|
760683
760819
|
_other: () => {
|
|
760684
760820
|
process.stderr.write(`${Icons.error} Failed to generate token.
|
|
760685
760821
|
|
|
760686
760822
|
Please contact support@buildwithfern.com for assistance.
|
|
760687
760823
|
`);
|
|
760688
|
-
throw CliError
|
|
760824
|
+
throw new CliError({
|
|
760825
|
+
code: CliError.Code.InternalError
|
|
760826
|
+
});
|
|
760689
760827
|
}
|
|
760690
760828
|
});
|
|
760691
760829
|
}
|
|
@@ -760701,7 +760839,7 @@ var TokenCommand = class {
|
|
|
760701
760839
|
|
|
760702
760840
|
Run fern init or specify an organization with --org, then run this command again.
|
|
760703
760841
|
`);
|
|
760704
|
-
throw CliError.
|
|
760842
|
+
throw new CliError({ code: CliError.Code.ConfigError });
|
|
760705
760843
|
}
|
|
760706
760844
|
}
|
|
760707
760845
|
};
|
|
@@ -760721,7 +760859,7 @@ var WhoamiCommand = class {
|
|
|
760721
760859
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760722
760860
|
context3.stdout.info("");
|
|
760723
760861
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760724
|
-
throw CliError.
|
|
760862
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
760725
760863
|
}
|
|
760726
760864
|
if (args.json) {
|
|
760727
760865
|
context3.stdout.info(JSON.stringify({ email: activeAccount.user }, null, 2));
|
|
@@ -817707,7 +817845,7 @@ function checkMissingRedirects(removedSlugs, redirects, basePath) {
|
|
|
817707
817845
|
}
|
|
817708
817846
|
|
|
817709
817847
|
// ../yaml/docs-validator/lib/rules/missing-redirects/missing-redirects.js
|
|
817710
|
-
var NOOP_CONTEXT = createMockTaskContext({ logger:
|
|
817848
|
+
var NOOP_CONTEXT = createMockTaskContext({ logger: createLogger(noop2) });
|
|
817711
817849
|
async function fetchMarkdownEntries(fdrOrigin, domain3, basepath, authToken) {
|
|
817712
817850
|
try {
|
|
817713
817851
|
const response = await fetch(`${fdrOrigin}/slugs/markdowns`, {
|
|
@@ -839219,7 +839357,7 @@ function collectPathnamesToCheck(content5, { absoluteFilepath, instanceUrls }) {
|
|
|
839219
839357
|
}
|
|
839220
839358
|
|
|
839221
839359
|
// ../yaml/docs-validator/lib/rules/valid-markdown-link/valid-markdown-link.js
|
|
839222
|
-
var NOOP_CONTEXT2 = createMockTaskContext({ logger:
|
|
839360
|
+
var NOOP_CONTEXT2 = createMockTaskContext({ logger: createLogger(noop2) });
|
|
839223
839361
|
var ValidMarkdownLinks = {
|
|
839224
839362
|
name: "valid-markdown-links",
|
|
839225
839363
|
create: async ({ workspace, apiWorkspaces, ossWorkspaces }) => {
|
|
@@ -840288,7 +840426,8 @@ var DocsChecker = class {
|
|
|
840288
840426
|
const docsWorkspace = project.docsWorkspaces;
|
|
840289
840427
|
if (docsWorkspace == null) {
|
|
840290
840428
|
throw new CliError({
|
|
840291
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
840429
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
840430
|
+
code: CliError.Code.ConfigError
|
|
840292
840431
|
});
|
|
840293
840432
|
}
|
|
840294
840433
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -840559,12 +840698,12 @@ var CheckCommand2 = class {
|
|
|
840559
840698
|
const response = this.buildJsonResponse({ apiCheckResult, sdkCheckResult, docsCheckResult, hasErrors });
|
|
840560
840699
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
840561
840700
|
if (hasErrors) {
|
|
840562
|
-
throw CliError.
|
|
840701
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
840563
840702
|
}
|
|
840564
840703
|
return;
|
|
840565
840704
|
}
|
|
840566
840705
|
if (hasErrors) {
|
|
840567
|
-
throw CliError.
|
|
840706
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
840568
840707
|
}
|
|
840569
840708
|
if (totalWarnings > 0) {
|
|
840570
840709
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${totalWarnings} warnings`)}`);
|
|
@@ -840619,7 +840758,8 @@ var CheckCommand2 = class {
|
|
|
840619
840758
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
840620
840759
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
840621
840760
|
throw new CliError({
|
|
840622
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
840761
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
|
|
840762
|
+
code: CliError.Code.ConfigError
|
|
840623
840763
|
});
|
|
840624
840764
|
}
|
|
840625
840765
|
}
|
|
@@ -842082,7 +842222,7 @@ var MigrateCommand = class {
|
|
|
842082
842222
|
}
|
|
842083
842223
|
return;
|
|
842084
842224
|
}
|
|
842085
|
-
throw new CliError({ message: "Migration failed" });
|
|
842225
|
+
throw new CliError({ message: "Migration failed", code: CliError.Code.ConfigError });
|
|
842086
842226
|
}
|
|
842087
842227
|
};
|
|
842088
842228
|
function addMigrateCommand(cli) {
|
|
@@ -842105,7 +842245,8 @@ var CheckCommand3 = class {
|
|
|
842105
842245
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
842106
842246
|
if (workspace.docs == null) {
|
|
842107
842247
|
throw new CliError({
|
|
842108
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
842248
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
842249
|
+
code: CliError.Code.ConfigError
|
|
842109
842250
|
});
|
|
842110
842251
|
}
|
|
842111
842252
|
const checker = new DocsChecker({ context: context3 });
|
|
@@ -842115,7 +842256,7 @@ var CheckCommand3 = class {
|
|
|
842115
842256
|
const response = this.buildJsonResponse({ result, hasErrors });
|
|
842116
842257
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
842117
842258
|
if (hasErrors) {
|
|
842118
|
-
throw CliError.
|
|
842259
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
842119
842260
|
}
|
|
842120
842261
|
return;
|
|
842121
842262
|
}
|
|
@@ -842127,7 +842268,7 @@ var CheckCommand3 = class {
|
|
|
842127
842268
|
}
|
|
842128
842269
|
}
|
|
842129
842270
|
if (hasErrors) {
|
|
842130
|
-
throw CliError.
|
|
842271
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
842131
842272
|
}
|
|
842132
842273
|
if (result.warningCount > 0) {
|
|
842133
842274
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -843968,7 +844109,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
843968
844109
|
var LOGS_FOLDER_NAME = "logs";
|
|
843969
844110
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
843970
844111
|
function getCliSource() {
|
|
843971
|
-
const version7 = "4.68.
|
|
844112
|
+
const version7 = "4.68.3-1-g429be56b56f";
|
|
843972
844113
|
return `cli@${version7}`;
|
|
843973
844114
|
}
|
|
843974
844115
|
var DebugLogger = class {
|
|
@@ -845950,7 +846091,8 @@ var DevCommand = class {
|
|
|
845950
846091
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
845951
846092
|
if (workspace.docs == null) {
|
|
845952
846093
|
throw new CliError({
|
|
845953
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
846094
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
846095
|
+
code: CliError.Code.ConfigError
|
|
845954
846096
|
});
|
|
845955
846097
|
}
|
|
845956
846098
|
const backendPort = args["backend-port"] ?? await getPorts();
|
|
@@ -845960,7 +846102,7 @@ var DevCommand = class {
|
|
|
845960
846102
|
backendPort,
|
|
845961
846103
|
forceDownload: args["force-download"],
|
|
845962
846104
|
bundlePath: args["bundle-path"],
|
|
845963
|
-
logLevel:
|
|
846105
|
+
logLevel: LogLevel.Info
|
|
845964
846106
|
});
|
|
845965
846107
|
}
|
|
845966
846108
|
};
|
|
@@ -846271,11 +846413,11 @@ function getSeverityForViolations(violations) {
|
|
|
846271
846413
|
function getLogLevelForSeverity(severity) {
|
|
846272
846414
|
switch (severity) {
|
|
846273
846415
|
case "fatal":
|
|
846274
|
-
return
|
|
846416
|
+
return LogLevel.Error;
|
|
846275
846417
|
case "error":
|
|
846276
|
-
return
|
|
846418
|
+
return LogLevel.Error;
|
|
846277
846419
|
case "warning":
|
|
846278
|
-
return
|
|
846420
|
+
return LogLevel.Warn;
|
|
846279
846421
|
default:
|
|
846280
846422
|
assertNever(severity);
|
|
846281
846423
|
}
|
|
@@ -853561,15 +853703,15 @@ async function makeWritableRecursive(dirPath) {
|
|
|
853561
853703
|
function convertLogLevel(logLevel) {
|
|
853562
853704
|
switch (logLevel) {
|
|
853563
853705
|
case "DEBUG":
|
|
853564
|
-
return
|
|
853706
|
+
return LogLevel.Debug;
|
|
853565
853707
|
case "INFO":
|
|
853566
|
-
return
|
|
853708
|
+
return LogLevel.Info;
|
|
853567
853709
|
case "WARN":
|
|
853568
|
-
return
|
|
853710
|
+
return LogLevel.Warn;
|
|
853569
853711
|
case "ERROR":
|
|
853570
|
-
return
|
|
853712
|
+
return LogLevel.Error;
|
|
853571
853713
|
default:
|
|
853572
|
-
return
|
|
853714
|
+
return LogLevel.Info;
|
|
853573
853715
|
}
|
|
853574
853716
|
}
|
|
853575
853717
|
async function checkFernIgnorePresent(absolutePathToLocalOutput) {
|
|
@@ -855217,7 +855359,7 @@ var LegacyDocsPublisher = class {
|
|
|
855217
855359
|
previewId,
|
|
855218
855360
|
disableTemplates: void 0,
|
|
855219
855361
|
skipUpload,
|
|
855220
|
-
cliVersion: "4.68.
|
|
855362
|
+
cliVersion: "4.68.3-1-g429be56b56f"
|
|
855221
855363
|
});
|
|
855222
855364
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
855223
855365
|
return { success: false };
|
|
@@ -855810,7 +855952,8 @@ var PublishCommand = class {
|
|
|
855810
855952
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
855811
855953
|
if (workspace.docs == null) {
|
|
855812
855954
|
throw new CliError({
|
|
855813
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855955
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
855956
|
+
code: CliError.Code.ConfigError
|
|
855814
855957
|
});
|
|
855815
855958
|
}
|
|
855816
855959
|
const instanceUrl = this.resolveInstanceUrl({
|
|
@@ -855829,7 +855972,8 @@ var PublishCommand = class {
|
|
|
855829
855972
|
const docsWorkspace = project.docsWorkspaces;
|
|
855830
855973
|
if (docsWorkspace == null) {
|
|
855831
855974
|
throw new CliError({
|
|
855832
|
-
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started."
|
|
855975
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
855976
|
+
code: CliError.Code.ConfigError
|
|
855833
855977
|
});
|
|
855834
855978
|
}
|
|
855835
855979
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -855844,7 +855988,10 @@ var PublishCommand = class {
|
|
|
855844
855988
|
});
|
|
855845
855989
|
const docsTask = taskGroup.getTask("publish");
|
|
855846
855990
|
if (docsTask == null) {
|
|
855847
|
-
throw new CliError({
|
|
855991
|
+
throw new CliError({
|
|
855992
|
+
message: "Internal error; task 'publish' not found",
|
|
855993
|
+
code: CliError.Code.InternalError
|
|
855994
|
+
});
|
|
855848
855995
|
}
|
|
855849
855996
|
docsTask.start();
|
|
855850
855997
|
docsTask.stage.validation.start();
|
|
@@ -855888,13 +856035,14 @@ var PublishCommand = class {
|
|
|
855888
856035
|
errorMessage: labels.error
|
|
855889
856036
|
});
|
|
855890
856037
|
if (summary.failedCount > 0) {
|
|
855891
|
-
throw CliError.
|
|
856038
|
+
throw new CliError({ code: CliError.Code.ContainerError });
|
|
855892
856039
|
}
|
|
855893
856040
|
}
|
|
855894
856041
|
resolveInstanceUrl({ instances: instances2, instance }) {
|
|
855895
856042
|
if (instances2.length === 0) {
|
|
855896
856043
|
throw new CliError({
|
|
855897
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856044
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
|
|
856045
|
+
code: CliError.Code.ConfigError
|
|
855898
856046
|
});
|
|
855899
856047
|
}
|
|
855900
856048
|
if (instance != null) {
|
|
@@ -855907,7 +856055,8 @@ var PublishCommand = class {
|
|
|
855907
856055
|
Available instances:
|
|
855908
856056
|
${available}
|
|
855909
856057
|
|
|
855910
|
-
Use --instance <url> with one of the URLs above
|
|
856058
|
+
Use --instance <url> with one of the URLs above.`,
|
|
856059
|
+
code: CliError.Code.ConfigError
|
|
855911
856060
|
});
|
|
855912
856061
|
}
|
|
855913
856062
|
return match3.url;
|
|
@@ -855920,13 +856069,15 @@ ${available}
|
|
|
855920
856069
|
Available instances:
|
|
855921
856070
|
${available}
|
|
855922
856071
|
|
|
855923
|
-
Use --instance <url> to select one
|
|
856072
|
+
Use --instance <url> to select one.`,
|
|
856073
|
+
code: CliError.Code.ConfigError
|
|
855924
856074
|
});
|
|
855925
856075
|
}
|
|
855926
856076
|
const first3 = instances2[0];
|
|
855927
856077
|
if (first3 == null) {
|
|
855928
856078
|
throw new CliError({
|
|
855929
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856079
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
|
|
856080
|
+
code: CliError.Code.ConfigError
|
|
855930
856081
|
});
|
|
855931
856082
|
}
|
|
855932
856083
|
return first3.url;
|
|
@@ -855960,7 +856111,8 @@ ${available}
|
|
|
855960
856111
|
const fernToken = process.env["FERN_TOKEN"];
|
|
855961
856112
|
if (fernToken == null) {
|
|
855962
856113
|
throw new CliError({
|
|
855963
|
-
message: "No organization token found. Please set the FERN_TOKEN environment variable."
|
|
856114
|
+
message: "No organization token found. Please set the FERN_TOKEN environment variable.",
|
|
856115
|
+
code: CliError.Code.AuthError
|
|
855964
856116
|
});
|
|
855965
856117
|
}
|
|
855966
856118
|
return Promise.resolve({ type: "organization", value: fernToken });
|
|
@@ -855972,7 +856124,10 @@ function addPublishCommand(cli) {
|
|
|
855972
856124
|
const cmd = new PublishCommand();
|
|
855973
856125
|
command2(cli, "publish", "Publish your documentation site", async (context3, args) => {
|
|
855974
856126
|
const timeout4 = new Promise((_16, reject) => {
|
|
855975
|
-
setTimeout(() => reject(new CliError({
|
|
856127
|
+
setTimeout(() => reject(new CliError({
|
|
856128
|
+
message: "Docs publish timed out after 10 minutes.",
|
|
856129
|
+
code: CliError.Code.NetworkError
|
|
856130
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
855976
856131
|
});
|
|
855977
856132
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
855978
856133
|
}, (yargs) => yargs.option("force", {
|
|
@@ -856001,7 +856156,8 @@ var DeleteCommand = class {
|
|
|
856001
856156
|
if (!this.isPreviewUrl(args.url)) {
|
|
856002
856157
|
throw new CliError({
|
|
856003
856158
|
message: `Invalid preview URL: ${args.url}
|
|
856004
|
-
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com
|
|
856159
|
+
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com`,
|
|
856160
|
+
code: CliError.Code.ConfigError
|
|
856005
856161
|
});
|
|
856006
856162
|
}
|
|
856007
856163
|
const token = await context3.getTokenOrPrompt();
|
|
@@ -856018,7 +856174,8 @@ var DeleteCommand = class {
|
|
|
856018
856174
|
throw CliError.notFound(`Preview site not found: ${args.url}`);
|
|
856019
856175
|
default:
|
|
856020
856176
|
throw new CliError({
|
|
856021
|
-
message: `Failed to delete preview site: ${args.url}
|
|
856177
|
+
message: `Failed to delete preview site: ${args.url}`,
|
|
856178
|
+
code: CliError.Code.InternalError
|
|
856022
856179
|
});
|
|
856023
856180
|
}
|
|
856024
856181
|
}
|
|
@@ -856065,7 +856222,10 @@ function addPreviewCommand(cli) {
|
|
|
856065
856222
|
const cmd = new PreviewCommand();
|
|
856066
856223
|
commandWithSubcommands(cli, "preview", "Generate a preview of your documentation site", async (context3, args) => {
|
|
856067
856224
|
const timeout4 = new Promise((_16, reject) => {
|
|
856068
|
-
setTimeout(() => reject(new CliError({
|
|
856225
|
+
setTimeout(() => reject(new CliError({
|
|
856226
|
+
message: "Docs preview timed out after 10 minutes.",
|
|
856227
|
+
code: CliError.Code.NetworkError
|
|
856228
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856069
856229
|
});
|
|
856070
856230
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
856071
856231
|
}, (yargs) => yargs.option("instance", {
|
|
@@ -856452,7 +856612,7 @@ var Wizard = class {
|
|
|
856452
856612
|
return void 0;
|
|
856453
856613
|
}
|
|
856454
856614
|
this.context.stderr.info(` ${Icons.info} Opening browser to log in to Fern...`);
|
|
856455
|
-
const taskContext = new TaskContextAdapter({ context: this.context, logLevel:
|
|
856615
|
+
const taskContext = new TaskContextAdapter({ context: this.context, logLevel: LogLevel.Info });
|
|
856456
856616
|
const { accessToken, idToken } = await getTokenFromAuth0(taskContext, {
|
|
856457
856617
|
useDeviceCodeFlow: false,
|
|
856458
856618
|
forceReauth: false
|
|
@@ -857032,7 +857192,8 @@ var InitCommand = class {
|
|
|
857032
857192
|
async validateArgs({ context: context3, fernYmlPath, args }) {
|
|
857033
857193
|
if (await doesPathExist(fernYmlPath)) {
|
|
857034
857194
|
throw new CliError({
|
|
857035
|
-
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}
|
|
857195
|
+
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}`,
|
|
857196
|
+
code: CliError.Code.ConfigError
|
|
857036
857197
|
});
|
|
857037
857198
|
}
|
|
857038
857199
|
if (args.api != null) {
|
|
@@ -857040,13 +857201,14 @@ var InitCommand = class {
|
|
|
857040
857201
|
if (!api.startsWith("http://") && !api.startsWith("https://")) {
|
|
857041
857202
|
const resolved = import_path59.default.resolve(context3.cwd, api);
|
|
857042
857203
|
if (!await doesPathExist(AbsoluteFilePath2.of(resolved))) {
|
|
857043
|
-
throw new CliError({ message: `File not found: ${api}
|
|
857204
|
+
throw new CliError({ message: `File not found: ${api}`, code: CliError.Code.ConfigError });
|
|
857044
857205
|
}
|
|
857045
857206
|
}
|
|
857046
857207
|
}
|
|
857047
857208
|
if (!context3.isTTY && !args.yes) {
|
|
857048
857209
|
throw new CliError({
|
|
857049
|
-
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults."
|
|
857210
|
+
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults.",
|
|
857211
|
+
code: CliError.Code.ConfigError
|
|
857050
857212
|
});
|
|
857051
857213
|
}
|
|
857052
857214
|
}
|
|
@@ -857072,7 +857234,7 @@ var CreateCommand = class {
|
|
|
857072
857234
|
const token = await context3.getTokenOrPrompt();
|
|
857073
857235
|
if (token.type === "organization") {
|
|
857074
857236
|
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.`);
|
|
857075
|
-
throw CliError.
|
|
857237
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
857076
857238
|
}
|
|
857077
857239
|
const validationError = getOrganizationNameValidationError(args.name);
|
|
857078
857240
|
if (validationError != null) {
|
|
@@ -857109,7 +857271,7 @@ var ListCommand = class {
|
|
|
857109
857271
|
const token = await context3.getTokenOrPrompt();
|
|
857110
857272
|
if (token.type === "organization") {
|
|
857111
857273
|
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.`);
|
|
857112
|
-
throw CliError.
|
|
857274
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
857113
857275
|
}
|
|
857114
857276
|
const venus = createVenusService({ token: token.value });
|
|
857115
857277
|
const firstPage = await this.fetchPage({ venus, pageId: 1 });
|
|
@@ -857253,13 +857415,14 @@ var AddCommand = class {
|
|
|
857253
857415
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
857254
857416
|
if (fernYmlPath == null) {
|
|
857255
857417
|
throw new CliError({
|
|
857256
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
857418
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
857419
|
+
code: CliError.Code.ConfigError
|
|
857257
857420
|
});
|
|
857258
857421
|
}
|
|
857259
857422
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
857260
857423
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
857261
857424
|
if (sdkCheckResult.errorCount > 0) {
|
|
857262
|
-
throw CliError.
|
|
857425
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857263
857426
|
}
|
|
857264
857427
|
const existingTargets = workspace.sdks?.targets ?? [];
|
|
857265
857428
|
if (!context3.isTTY || args.yes) {
|
|
@@ -857272,7 +857435,8 @@ var AddCommand = class {
|
|
|
857272
857435
|
throw new CliError({
|
|
857273
857436
|
message: `Missing required flags:
|
|
857274
857437
|
|
|
857275
|
-
--target <language> SDK language (e.g. typescript, python, go)
|
|
857438
|
+
--target <language> SDK language (e.g. typescript, python, go)`,
|
|
857439
|
+
code: CliError.Code.ConfigError
|
|
857276
857440
|
});
|
|
857277
857441
|
}
|
|
857278
857442
|
const language = this.parseLanguage(args.target);
|
|
@@ -857318,7 +857482,8 @@ var AddCommand = class {
|
|
|
857318
857482
|
message: `"${value}" looks like a remote reference but is not a recognized git URL.
|
|
857319
857483
|
|
|
857320
857484
|
Please specify a local path (e.g. ./sdks/my-sdk) or a git URL:
|
|
857321
|
-
https://github.com/owner/repo
|
|
857485
|
+
https://github.com/owner/repo`,
|
|
857486
|
+
code: CliError.Code.ConfigError
|
|
857322
857487
|
});
|
|
857323
857488
|
}
|
|
857324
857489
|
return { path: value };
|
|
@@ -857340,7 +857505,8 @@ var AddCommand = class {
|
|
|
857340
857505
|
checkForDuplicate({ existingTargets, language }) {
|
|
857341
857506
|
if (existingTargets.some((t3) => t3.name === language)) {
|
|
857342
857507
|
throw new CliError({
|
|
857343
|
-
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}
|
|
857508
|
+
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}.`,
|
|
857509
|
+
code: CliError.Code.ConfigError
|
|
857344
857510
|
});
|
|
857345
857511
|
}
|
|
857346
857512
|
}
|
|
@@ -857392,7 +857558,8 @@ var AddCommand = class {
|
|
|
857392
857558
|
return lang;
|
|
857393
857559
|
}
|
|
857394
857560
|
throw new CliError({
|
|
857395
|
-
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}
|
|
857561
|
+
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}`,
|
|
857562
|
+
code: CliError.Code.ConfigError
|
|
857396
857563
|
});
|
|
857397
857564
|
}
|
|
857398
857565
|
};
|
|
@@ -857429,7 +857596,7 @@ var CheckCommand4 = class {
|
|
|
857429
857596
|
const response = this.buildJsonResponse({ sdkCheckResult: result, hasErrors });
|
|
857430
857597
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
857431
857598
|
if (hasErrors) {
|
|
857432
|
-
throw CliError.
|
|
857599
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857433
857600
|
}
|
|
857434
857601
|
return;
|
|
857435
857602
|
}
|
|
@@ -857441,7 +857608,7 @@ var CheckCommand4 = class {
|
|
|
857441
857608
|
}
|
|
857442
857609
|
}
|
|
857443
857610
|
if (hasErrors) {
|
|
857444
|
-
throw CliError.
|
|
857611
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857445
857612
|
}
|
|
857446
857613
|
if (result.warningCount > 0) {
|
|
857447
857614
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -904114,7 +904281,7 @@ function constructNpmPackage({ generatorConfig, isPackagePrivate }) {
|
|
|
904114
904281
|
registryUrl: outputMode.registriesV2.npm.registryUrl,
|
|
904115
904282
|
token: outputMode.registriesV2.npm.token
|
|
904116
904283
|
},
|
|
904117
|
-
license:
|
|
904284
|
+
license: licenseFromLicenseConfig(generatorConfig.license),
|
|
904118
904285
|
repoUrl: void 0
|
|
904119
904286
|
};
|
|
904120
904287
|
case "github":
|
|
@@ -904127,13 +904294,7 @@ function constructNpmPackage({ generatorConfig, isPackagePrivate }) {
|
|
|
904127
904294
|
private: isPackagePrivate,
|
|
904128
904295
|
publishInfo: void 0,
|
|
904129
904296
|
repoUrl: getRepoUrlFromUrl(outputMode.repoUrl),
|
|
904130
|
-
license: generatorConfig.license
|
|
904131
|
-
basic: (basic2) => basic2.id,
|
|
904132
|
-
custom: (custom3) => `See ${custom3.filename}`,
|
|
904133
|
-
_other: () => {
|
|
904134
|
-
return void 0;
|
|
904135
|
-
}
|
|
904136
|
-
})
|
|
904297
|
+
license: licenseFromLicenseConfig(generatorConfig.license)
|
|
904137
904298
|
};
|
|
904138
904299
|
default:
|
|
904139
904300
|
throw new Error(`Encountered unknown output mode: ${outputMode}`);
|
|
@@ -904175,6 +904336,13 @@ function removeGitSuffix(repoUrl) {
|
|
|
904175
904336
|
}
|
|
904176
904337
|
return repoUrl;
|
|
904177
904338
|
}
|
|
904339
|
+
function licenseFromLicenseConfig(licenseConfig) {
|
|
904340
|
+
return licenseConfig?._visit({
|
|
904341
|
+
basic: (basic2) => basic2.id,
|
|
904342
|
+
custom: (custom3) => `See ${custom3.filename}`,
|
|
904343
|
+
_other: () => void 0
|
|
904344
|
+
});
|
|
904345
|
+
}
|
|
904178
904346
|
|
|
904179
904347
|
// ../../../generators/typescript-v2/browser-compatible-base/lib/utils/getNamespaceExport.js
|
|
904180
904348
|
init_lodash();
|
|
@@ -907849,8 +908017,6 @@ var GenerationRunner = class {
|
|
|
907849
908017
|
}
|
|
907850
908018
|
} catch (error50) {
|
|
907851
908019
|
if (error50 instanceof TaskAbortSignal) {
|
|
907852
|
-
} else if (error50 instanceof LoggableFernCliError) {
|
|
907853
|
-
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50.log}`, error50);
|
|
907854
908020
|
} else {
|
|
907855
908021
|
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50);
|
|
907856
908022
|
}
|
|
@@ -908283,7 +908449,7 @@ var LegacyLocalGenerationRunner = class {
|
|
|
908283
908449
|
const taskContext = new TaskContextAdapter({
|
|
908284
908450
|
context: this.context,
|
|
908285
908451
|
task: args.task,
|
|
908286
|
-
logLevel:
|
|
908452
|
+
logLevel: LogLevel.Info
|
|
908287
908453
|
});
|
|
908288
908454
|
try {
|
|
908289
908455
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908422,7 +908588,7 @@ var LegacyRemoteGenerationRunner = class {
|
|
|
908422
908588
|
const taskContext = new TaskContextAdapter({
|
|
908423
908589
|
context: this.context,
|
|
908424
908590
|
task: args.task,
|
|
908425
|
-
logLevel:
|
|
908591
|
+
logLevel: LogLevel.Info
|
|
908426
908592
|
});
|
|
908427
908593
|
try {
|
|
908428
908594
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908562,7 +908728,8 @@ var GeneratorPipeline = class {
|
|
|
908562
908728
|
}
|
|
908563
908729
|
if (args.target.registry != null) {
|
|
908564
908730
|
throw new CliError({
|
|
908565
|
-
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry
|
|
908731
|
+
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry.`,
|
|
908732
|
+
code: CliError.Code.ConfigError
|
|
908566
908733
|
});
|
|
908567
908734
|
}
|
|
908568
908735
|
return await this.runRemoteGeneration(args);
|
|
@@ -908874,7 +909041,8 @@ var GenerateCommand = class {
|
|
|
908874
909041
|
throw new CliError({
|
|
908875
909042
|
message: `No fern.yml found, either run 'fern init' or specify all of the required flags:
|
|
908876
909043
|
|
|
908877
|
-
` + missingFlags.map((flag) => ` ${flag}`).join("\n")
|
|
909044
|
+
` + missingFlags.map((flag) => ` ${flag}`).join("\n"),
|
|
909045
|
+
code: CliError.Code.ConfigError
|
|
908878
909046
|
});
|
|
908879
909047
|
}
|
|
908880
909048
|
const api = args.api;
|
|
@@ -908925,12 +909093,12 @@ var GenerateCommand = class {
|
|
|
908925
909093
|
}
|
|
908926
909094
|
}
|
|
908927
909095
|
if (sdkCheckResult.errorCount > 0) {
|
|
908928
|
-
throw CliError.
|
|
909096
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
908929
909097
|
}
|
|
908930
909098
|
}
|
|
908931
909099
|
const validTargets = targets2.filter((t3) => checkResult.validApis.has(t3.api));
|
|
908932
909100
|
if (validTargets.length === 0) {
|
|
908933
|
-
throw CliError.
|
|
909101
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
908934
909102
|
}
|
|
908935
909103
|
const pipeline5 = new GeneratorPipeline({
|
|
908936
909104
|
context: context3,
|
|
@@ -908958,7 +909126,7 @@ var GenerateCommand = class {
|
|
|
908958
909126
|
if (outputPath != null) {
|
|
908959
909127
|
const { shouldProceed } = await this.checkOutputDirectory({ context: context3, args, outputPath });
|
|
908960
909128
|
if (!shouldProceed) {
|
|
908961
|
-
throw new CliError({ message: "Generation cancelled." });
|
|
909129
|
+
throw new CliError({ message: "Generation cancelled.", code: CliError.Code.ConfigError });
|
|
908962
909130
|
}
|
|
908963
909131
|
}
|
|
908964
909132
|
}
|
|
@@ -908976,7 +909144,10 @@ var GenerateCommand = class {
|
|
|
908976
909144
|
await Promise.all(targets2.map(async (target) => {
|
|
908977
909145
|
const task = taskGroup.getTask(target.name);
|
|
908978
909146
|
if (task == null) {
|
|
908979
|
-
throw new CliError({
|
|
909147
|
+
throw new CliError({
|
|
909148
|
+
message: `Internal error; task '${target.name}' not found`,
|
|
909149
|
+
code: CliError.Code.InternalError
|
|
909150
|
+
});
|
|
908980
909151
|
}
|
|
908981
909152
|
task.start();
|
|
908982
909153
|
task.stage.validation.start();
|
|
@@ -909022,22 +909193,32 @@ var GenerateCommand = class {
|
|
|
909022
909193
|
errorMessage: `Failed to generate ${sdkInitialism}`
|
|
909023
909194
|
});
|
|
909024
909195
|
if (summary.failedCount > 0) {
|
|
909025
|
-
throw CliError.
|
|
909196
|
+
throw new CliError({ code: CliError.Code.ContainerError });
|
|
909026
909197
|
}
|
|
909027
909198
|
}
|
|
909028
909199
|
validateArgs({ workspace, args, targets: targets2 }) {
|
|
909029
909200
|
if (args["container-engine"] != null && !args.local) {
|
|
909030
|
-
throw new CliError({
|
|
909201
|
+
throw new CliError({
|
|
909202
|
+
message: "The --container-engine flag can only be used with --local",
|
|
909203
|
+
code: CliError.Code.ConfigError
|
|
909204
|
+
});
|
|
909031
909205
|
}
|
|
909032
909206
|
if (args.group != null && args.target != null) {
|
|
909033
|
-
throw new CliError({
|
|
909207
|
+
throw new CliError({
|
|
909208
|
+
message: "The --group and --target flags cannot be used together",
|
|
909209
|
+
code: CliError.Code.ConfigError
|
|
909210
|
+
});
|
|
909034
909211
|
}
|
|
909035
909212
|
if (targets2.length > 1 && args.output != null) {
|
|
909036
|
-
throw new CliError({
|
|
909213
|
+
throw new CliError({
|
|
909214
|
+
message: "The --output flag can only be used when generating a single target",
|
|
909215
|
+
code: CliError.Code.ConfigError
|
|
909216
|
+
});
|
|
909037
909217
|
}
|
|
909038
909218
|
if (args["skip-fernignore"] && args.fernignore != null) {
|
|
909039
909219
|
throw new CliError({
|
|
909040
|
-
message: "The --skip-fernignore and --fernignore flags cannot be used together."
|
|
909220
|
+
message: "The --skip-fernignore and --fernignore flags cannot be used together.",
|
|
909221
|
+
code: CliError.Code.ConfigError
|
|
909041
909222
|
});
|
|
909042
909223
|
}
|
|
909043
909224
|
const issues = [];
|
|
@@ -909089,7 +909270,8 @@ Example:
|
|
|
909089
909270
|
throw new CliError({
|
|
909090
909271
|
message: `Remote generation is not supported with a git URL for --output
|
|
909091
909272
|
|
|
909092
|
-
Use --local or specify a local filesystem path for --output
|
|
909273
|
+
Use --local or specify a local filesystem path for --output`,
|
|
909274
|
+
code: CliError.Code.ConfigError
|
|
909093
909275
|
});
|
|
909094
909276
|
}
|
|
909095
909277
|
const token = process.env.GITHUB_TOKEN ?? process.env.GIT_TOKEN;
|
|
@@ -909101,7 +909283,8 @@ Example:
|
|
|
909101
909283
|
export GITHUB_TOKEN=ghp_xxx
|
|
909102
909284
|
|
|
909103
909285
|
Or use a local path:
|
|
909104
|
-
--output ./my-sdk
|
|
909286
|
+
--output ./my-sdk`,
|
|
909287
|
+
code: CliError.Code.AuthError
|
|
909105
909288
|
});
|
|
909106
909289
|
}
|
|
909107
909290
|
return {
|
|
@@ -909223,7 +909406,10 @@ function addGenerateCommand(cli) {
|
|
|
909223
909406
|
const cmd = new GenerateCommand();
|
|
909224
909407
|
command2(cli, "generate", "Generate SDKs from fern.yml or directly from an API spec", async (context3, args) => {
|
|
909225
909408
|
const timeout4 = new Promise((_16, reject) => {
|
|
909226
|
-
setTimeout(() => reject(new CliError({
|
|
909409
|
+
setTimeout(() => reject(new CliError({
|
|
909410
|
+
message: "Generation timed out after 10 minutes.",
|
|
909411
|
+
code: CliError.Code.NetworkError
|
|
909412
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909227
909413
|
});
|
|
909228
909414
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909229
909415
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909302,7 +909488,10 @@ function addPreviewCommand2(cli) {
|
|
|
909302
909488
|
const cmd = new PreviewCommand2();
|
|
909303
909489
|
command2(cli, "preview", "Generate a preview of an SDK", async (context3, args) => {
|
|
909304
909490
|
const timeout4 = new Promise((_16, reject) => {
|
|
909305
|
-
setTimeout(() => reject(new CliError({
|
|
909491
|
+
setTimeout(() => reject(new CliError({
|
|
909492
|
+
message: "Preview generation timed out after 10 minutes.",
|
|
909493
|
+
code: CliError.Code.NetworkError
|
|
909494
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909306
909495
|
});
|
|
909307
909496
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909308
909497
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909754,13 +909943,14 @@ var UpdateCommand = class {
|
|
|
909754
909943
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
909755
909944
|
if (fernYmlPath == null) {
|
|
909756
909945
|
throw new CliError({
|
|
909757
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
909946
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
909947
|
+
code: CliError.Code.ConfigError
|
|
909758
909948
|
});
|
|
909759
909949
|
}
|
|
909760
909950
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
909761
909951
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
909762
909952
|
if (sdkCheckResult.errorCount > 0) {
|
|
909763
|
-
throw CliError.
|
|
909953
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
909764
909954
|
}
|
|
909765
909955
|
const targets2 = workspace.sdks?.targets;
|
|
909766
909956
|
if (targets2 == null || targets2.length === 0) {
|
|
@@ -909776,7 +909966,8 @@ var UpdateCommand = class {
|
|
|
909776
909966
|
});
|
|
909777
909967
|
if (updates.length === 0 && upToDate.length === 0 && args.target != null) {
|
|
909778
909968
|
throw new CliError({
|
|
909779
|
-
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}
|
|
909969
|
+
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}.`,
|
|
909970
|
+
code: CliError.Code.ConfigError
|
|
909780
909971
|
});
|
|
909781
909972
|
}
|
|
909782
909973
|
if (updates.length === 0) {
|
|
@@ -924757,19 +924948,19 @@ var Logger4 = class {
|
|
|
924757
924948
|
this.enabled = true;
|
|
924758
924949
|
}
|
|
924759
924950
|
trace(...args) {
|
|
924760
|
-
this.write(
|
|
924951
|
+
this.write(LogLevel.Trace, ...args);
|
|
924761
924952
|
}
|
|
924762
924953
|
debug(...args) {
|
|
924763
|
-
this.write(
|
|
924954
|
+
this.write(LogLevel.Debug, ...args);
|
|
924764
924955
|
}
|
|
924765
924956
|
info(...args) {
|
|
924766
|
-
this.write(
|
|
924957
|
+
this.write(LogLevel.Info, ...args);
|
|
924767
924958
|
}
|
|
924768
924959
|
warn(...args) {
|
|
924769
|
-
this.write(
|
|
924960
|
+
this.write(LogLevel.Warn, ...args);
|
|
924770
924961
|
}
|
|
924771
924962
|
error(...args) {
|
|
924772
|
-
this.write(
|
|
924963
|
+
this.write(LogLevel.Error, ...args);
|
|
924773
924964
|
}
|
|
924774
924965
|
log(level, ...args) {
|
|
924775
924966
|
this.write(level, ...args);
|
|
@@ -928384,6 +928575,24 @@ var esm_default16 = createPrompt((config5, done) => {
|
|
|
928384
928575
|
// src/cli-context/CliContext.ts
|
|
928385
928576
|
init_lodash();
|
|
928386
928577
|
|
|
928578
|
+
// src/telemetry/reportError.ts
|
|
928579
|
+
function reportError2(reporter, error50, options2) {
|
|
928580
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
928581
|
+
return;
|
|
928582
|
+
}
|
|
928583
|
+
const code5 = resolveErrorCode(error50, options2?.code);
|
|
928584
|
+
reporter.instrumentPostHogEvent({
|
|
928585
|
+
command: process.argv.join(" "),
|
|
928586
|
+
properties: {
|
|
928587
|
+
failed: true,
|
|
928588
|
+
errorCode: code5
|
|
928589
|
+
}
|
|
928590
|
+
});
|
|
928591
|
+
if (shouldReportToSentry(code5)) {
|
|
928592
|
+
reporter.captureException(error50 ?? new CliError({ message: options2?.message ?? "", code: code5 }), code5);
|
|
928593
|
+
}
|
|
928594
|
+
}
|
|
928595
|
+
|
|
928387
928596
|
// src/telemetry/SentryClient.ts
|
|
928388
928597
|
var SentryClient = class {
|
|
928389
928598
|
sentry;
|
|
@@ -928406,12 +928615,15 @@ var SentryClient = class {
|
|
|
928406
928615
|
setSentryRunIdTags();
|
|
928407
928616
|
}
|
|
928408
928617
|
}
|
|
928409
|
-
|
|
928618
|
+
captureException(error50, code5) {
|
|
928410
928619
|
if (this.sentry == null) {
|
|
928411
928620
|
return;
|
|
928412
928621
|
}
|
|
928413
928622
|
try {
|
|
928414
|
-
this.sentry.captureException(
|
|
928623
|
+
this.sentry.captureException(
|
|
928624
|
+
error50,
|
|
928625
|
+
code5 != null ? { captureContext: { tags: { "error.code": code5 } } } : void 0
|
|
928626
|
+
);
|
|
928415
928627
|
} catch {
|
|
928416
928628
|
}
|
|
928417
928629
|
}
|
|
@@ -928469,13 +928681,15 @@ var TaskContextImpl = class {
|
|
|
928469
928681
|
status = "notStarted";
|
|
928470
928682
|
onResult;
|
|
928471
928683
|
instrumentPostHogEventImpl;
|
|
928684
|
+
captureExceptionImpl;
|
|
928472
928685
|
constructor({
|
|
928473
928686
|
logImmediately,
|
|
928474
928687
|
logPrefix,
|
|
928475
928688
|
takeOverTerminal,
|
|
928476
928689
|
onResult,
|
|
928477
928690
|
shouldBufferLogs,
|
|
928478
|
-
instrumentPostHogEvent
|
|
928691
|
+
instrumentPostHogEvent,
|
|
928692
|
+
captureException: captureException2
|
|
928479
928693
|
}) {
|
|
928480
928694
|
this.logImmediately = logImmediately;
|
|
928481
928695
|
this.logPrefix = logPrefix ?? "";
|
|
@@ -928483,6 +928697,7 @@ var TaskContextImpl = class {
|
|
|
928483
928697
|
this.onResult = onResult;
|
|
928484
928698
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
928485
928699
|
this.instrumentPostHogEventImpl = instrumentPostHogEvent;
|
|
928700
|
+
this.captureExceptionImpl = captureException2;
|
|
928486
928701
|
}
|
|
928487
928702
|
start() {
|
|
928488
928703
|
this.status = "running";
|
|
@@ -928500,14 +928715,21 @@ var TaskContextImpl = class {
|
|
|
928500
928715
|
return this.status === "finished";
|
|
928501
928716
|
}
|
|
928502
928717
|
takeOverTerminal;
|
|
928503
|
-
failAndThrow(message, error50) {
|
|
928504
|
-
this.failWithoutThrowing(message, error50);
|
|
928718
|
+
failAndThrow(message, error50, options2) {
|
|
928719
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
928505
928720
|
this.finish();
|
|
928506
928721
|
throw new TaskAbortSignal();
|
|
928507
928722
|
}
|
|
928508
|
-
failWithoutThrowing(message, error50) {
|
|
928509
|
-
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928723
|
+
failWithoutThrowing(message, error50, options2) {
|
|
928510
928724
|
this.result = TaskResult.Failure;
|
|
928725
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
928726
|
+
return;
|
|
928727
|
+
}
|
|
928728
|
+
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928729
|
+
reportError2(this, error50, { ...options2, message });
|
|
928730
|
+
}
|
|
928731
|
+
captureException(error50, code5) {
|
|
928732
|
+
this.captureExceptionImpl?.(error50, code5);
|
|
928511
928733
|
}
|
|
928512
928734
|
getResult() {
|
|
928513
928735
|
return this.result;
|
|
@@ -928539,7 +928761,7 @@ var TaskContextImpl = class {
|
|
|
928539
928761
|
this.logImmediately(this.bufferedLogs);
|
|
928540
928762
|
this.bufferedLogs = [];
|
|
928541
928763
|
}
|
|
928542
|
-
logger =
|
|
928764
|
+
logger = createLogger(this.logAtLevel.bind(this));
|
|
928543
928765
|
addInteractiveTask({ name: name2, subtitle }) {
|
|
928544
928766
|
const subtask = new InteractiveTaskContextImpl({
|
|
928545
928767
|
name: name2,
|
|
@@ -928549,7 +928771,8 @@ var TaskContextImpl = class {
|
|
|
928549
928771
|
takeOverTerminal: this.takeOverTerminal,
|
|
928550
928772
|
onResult: this.onResult,
|
|
928551
928773
|
shouldBufferLogs: this.shouldBufferLogs,
|
|
928552
|
-
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event)
|
|
928774
|
+
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event),
|
|
928775
|
+
captureException: this.captureExceptionImpl
|
|
928553
928776
|
});
|
|
928554
928777
|
this.subtasks.push(subtask);
|
|
928555
928778
|
return subtask;
|
|
@@ -928579,7 +928802,7 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928579
928802
|
}
|
|
928580
928803
|
start() {
|
|
928581
928804
|
super.start();
|
|
928582
|
-
this.logAtLevelWithOverrides(
|
|
928805
|
+
this.logAtLevelWithOverrides(LogLevel.Info, ["Started."], {
|
|
928583
928806
|
omitOnTTY: true
|
|
928584
928807
|
});
|
|
928585
928808
|
this.flushLogs();
|
|
@@ -928590,11 +928813,11 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928590
928813
|
}
|
|
928591
928814
|
finish() {
|
|
928592
928815
|
if (this.result === TaskResult.Success) {
|
|
928593
|
-
this.logAtLevelWithOverrides(
|
|
928816
|
+
this.logAtLevelWithOverrides(LogLevel.Info, ["Finished."], {
|
|
928594
928817
|
omitOnTTY: true
|
|
928595
928818
|
});
|
|
928596
928819
|
} else {
|
|
928597
|
-
this.logAtLevelWithOverrides(
|
|
928820
|
+
this.logAtLevelWithOverrides(LogLevel.Error, ["Failed."], {
|
|
928598
928821
|
omitOnTTY: true
|
|
928599
928822
|
});
|
|
928600
928823
|
}
|
|
@@ -928922,7 +929145,7 @@ var CliContext = class _CliContext {
|
|
|
928922
929145
|
didSucceed = true;
|
|
928923
929146
|
numTasks = 0;
|
|
928924
929147
|
ttyAwareLogger;
|
|
928925
|
-
logLevel =
|
|
929148
|
+
logLevel = LogLevel.Info;
|
|
928926
929149
|
isLocal;
|
|
928927
929150
|
stdoutRedirector = new StdoutRedirector();
|
|
928928
929151
|
jsonMode = false;
|
|
@@ -928957,7 +929180,7 @@ var CliContext = class _CliContext {
|
|
|
928957
929180
|
if (false) {
|
|
928958
929181
|
this.logger.error("CLI_VERSION is not defined");
|
|
928959
929182
|
}
|
|
928960
|
-
return "4.68.
|
|
929183
|
+
return "4.68.3-1-g429be56b56f";
|
|
928961
929184
|
}
|
|
928962
929185
|
getCliName() {
|
|
928963
929186
|
if (false) {
|
|
@@ -928973,13 +929196,17 @@ var CliContext = class _CliContext {
|
|
|
928973
929196
|
`Running ${source_default.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`
|
|
928974
929197
|
);
|
|
928975
929198
|
}
|
|
928976
|
-
failAndThrow(message, error50) {
|
|
928977
|
-
this.failWithoutThrowing(message, error50);
|
|
929199
|
+
failAndThrow(message, error50, options2) {
|
|
929200
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
928978
929201
|
throw new TaskAbortSignal();
|
|
928979
929202
|
}
|
|
928980
|
-
failWithoutThrowing(message, error50) {
|
|
929203
|
+
failWithoutThrowing(message, error50, options2) {
|
|
928981
929204
|
this.didSucceed = false;
|
|
929205
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
929206
|
+
return;
|
|
929207
|
+
}
|
|
928982
929208
|
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
929209
|
+
reportError2(this, error50, { ...options2, message });
|
|
928983
929210
|
}
|
|
928984
929211
|
/**
|
|
928985
929212
|
* Activate JSON-output mode: all logger output is forced to stderr
|
|
@@ -929082,15 +929309,7 @@ var CliContext = class _CliContext {
|
|
|
929082
929309
|
try {
|
|
929083
929310
|
result = await run(context3);
|
|
929084
929311
|
} catch (error50) {
|
|
929085
|
-
|
|
929086
|
-
throw error50;
|
|
929087
|
-
}
|
|
929088
|
-
if (error50.message.includes("globalThis")) {
|
|
929089
|
-
context3.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE);
|
|
929090
|
-
context3.failWithoutThrowing();
|
|
929091
|
-
} else {
|
|
929092
|
-
context3.failWithoutThrowing(void 0, error50);
|
|
929093
|
-
}
|
|
929312
|
+
context3.failWithoutThrowing(void 0, error50);
|
|
929094
929313
|
throw new TaskAbortSignal();
|
|
929095
929314
|
} finally {
|
|
929096
929315
|
context3.finish();
|
|
@@ -929102,11 +929321,11 @@ var CliContext = class _CliContext {
|
|
|
929102
929321
|
this.posthogManager.sendEvent(event);
|
|
929103
929322
|
}
|
|
929104
929323
|
}
|
|
929105
|
-
|
|
929106
|
-
|
|
929324
|
+
captureException(error50, code5) {
|
|
929325
|
+
this.sentryClient.captureException(error50, code5);
|
|
929107
929326
|
}
|
|
929108
|
-
logger =
|
|
929109
|
-
stderr =
|
|
929327
|
+
logger = createLogger((level, ...args) => this.log(level, ...args));
|
|
929328
|
+
stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
929110
929329
|
constructTaskInitForWorkspace(workspace) {
|
|
929111
929330
|
const prefixWithoutPadding = wrapWorkspaceNameForPrefix(
|
|
929112
929331
|
workspace.type === "docs" ? "docs" : workspace.workspaceName ?? "api"
|
|
@@ -929132,7 +929351,10 @@ var CliContext = class _CliContext {
|
|
|
929132
929351
|
instrumentPostHogEvent: (event) => {
|
|
929133
929352
|
this.instrumentPostHogEvent(event);
|
|
929134
929353
|
},
|
|
929135
|
-
shouldBufferLogs: false
|
|
929354
|
+
shouldBufferLogs: false,
|
|
929355
|
+
captureException: (error50, code5) => {
|
|
929356
|
+
this.sentryClient.captureException(error50, code5);
|
|
929357
|
+
}
|
|
929136
929358
|
};
|
|
929137
929359
|
}
|
|
929138
929360
|
log(level, ...parts) {
|
|
@@ -929159,7 +929381,7 @@ var CliContext = class _CliContext {
|
|
|
929159
929381
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
929160
929382
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
929161
929383
|
this.ttyAwareLogger.log(filtered, {
|
|
929162
|
-
includeDebugInfo: this.logLevel ===
|
|
929384
|
+
includeDebugInfo: this.logLevel === LogLevel.Debug,
|
|
929163
929385
|
stderr: stderr || this.jsonMode
|
|
929164
929386
|
});
|
|
929165
929387
|
}
|
|
@@ -947133,7 +947355,6 @@ function evaluateRuntime4() {
|
|
|
947133
947355
|
|
|
947134
947356
|
// src/cli.ts
|
|
947135
947357
|
void runCli();
|
|
947136
|
-
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
947137
947358
|
async function runCli() {
|
|
947138
947359
|
getOrCreateFernRunId();
|
|
947139
947360
|
const isLocal = process.argv.includes("--local");
|
|
@@ -947171,24 +947392,7 @@ async function runCli() {
|
|
|
947171
947392
|
});
|
|
947172
947393
|
}
|
|
947173
947394
|
} catch (error50) {
|
|
947174
|
-
cliContext.
|
|
947175
|
-
command: process.argv.join(" "),
|
|
947176
|
-
properties: {
|
|
947177
|
-
failed: true,
|
|
947178
|
-
error: error50
|
|
947179
|
-
}
|
|
947180
|
-
});
|
|
947181
|
-
if (error50 instanceof TaskAbortSignal) {
|
|
947182
|
-
cliContext.failWithoutThrowing();
|
|
947183
|
-
} else if (error50?.message.includes("globalThis")) {
|
|
947184
|
-
cliContext.logger.error(USE_NODE_18_OR_ABOVE_MESSAGE);
|
|
947185
|
-
cliContext.failWithoutThrowing();
|
|
947186
|
-
} else if (error50 instanceof LoggableFernCliError) {
|
|
947187
|
-
cliContext.logger.error(`Failed. ${error50.log}`);
|
|
947188
|
-
} else {
|
|
947189
|
-
await cliContext.captureException(error50);
|
|
947190
|
-
cliContext.failWithoutThrowing("Failed.", error50);
|
|
947191
|
-
}
|
|
947395
|
+
cliContext.failWithoutThrowing(void 0, error50);
|
|
947192
947396
|
}
|
|
947193
947397
|
await exit3();
|
|
947194
947398
|
}
|
|
@@ -947219,7 +947423,7 @@ async function tryRunCli(cliContext) {
|
|
|
947219
947423
|
}
|
|
947220
947424
|
}
|
|
947221
947425
|
).option("log-level", {
|
|
947222
|
-
default:
|
|
947426
|
+
default: LogLevel.Info,
|
|
947223
947427
|
choices: LOG_LEVELS
|
|
947224
947428
|
}).demandCommand().recommendCommands();
|
|
947225
947429
|
addDiffCommand(cli, cliContext);
|