@fern-api/fern-api-dev 4.68.2 → 4.68.3-2-g063113b6335
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 +1456 -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,224 @@ function commandGroup(cli, name2, description, subcommands) {
|
|
|
485174
485174
|
});
|
|
485175
485175
|
}
|
|
485176
485176
|
|
|
485177
|
+
// ../task-context/lib/CliError.js
|
|
485178
|
+
var CliError = class _CliError extends Error {
|
|
485179
|
+
code;
|
|
485180
|
+
docsLink;
|
|
485181
|
+
constructor({ message, code: code5, docsLink }) {
|
|
485182
|
+
super(message);
|
|
485183
|
+
Object.setPrototypeOf(this, _CliError.prototype);
|
|
485184
|
+
this.code = code5;
|
|
485185
|
+
this.docsLink = docsLink;
|
|
485186
|
+
}
|
|
485187
|
+
static authRequired(message) {
|
|
485188
|
+
return new _CliError({
|
|
485189
|
+
message: message ?? "Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable.",
|
|
485190
|
+
code: _CliError.Code.AuthError
|
|
485191
|
+
});
|
|
485192
|
+
}
|
|
485193
|
+
static unauthorized(message) {
|
|
485194
|
+
return new _CliError({
|
|
485195
|
+
message: message ?? "Unauthorized. Please run 'fern auth login' or set the FERN_TOKEN environment variable.",
|
|
485196
|
+
code: _CliError.Code.AuthError
|
|
485197
|
+
});
|
|
485198
|
+
}
|
|
485199
|
+
static notFound(message) {
|
|
485200
|
+
return new _CliError({ message, code: _CliError.Code.ConfigError });
|
|
485201
|
+
}
|
|
485202
|
+
static badRequest(message) {
|
|
485203
|
+
return new _CliError({ message, code: _CliError.Code.NetworkError });
|
|
485204
|
+
}
|
|
485205
|
+
static validationError(message) {
|
|
485206
|
+
return new _CliError({ message, code: _CliError.Code.ValidationError });
|
|
485207
|
+
}
|
|
485208
|
+
static internalError(message) {
|
|
485209
|
+
return new _CliError({ message, code: _CliError.Code.InternalError });
|
|
485210
|
+
}
|
|
485211
|
+
};
|
|
485212
|
+
(function(CliError4) {
|
|
485213
|
+
CliError4.Code = {
|
|
485214
|
+
InternalError: "INTERNAL_ERROR",
|
|
485215
|
+
ResolutionError: "RESOLUTION_ERROR",
|
|
485216
|
+
IrConversionError: "IR_CONVERSION_ERROR",
|
|
485217
|
+
ContainerError: "CONTAINER_ERROR",
|
|
485218
|
+
VersionError: "VERSION_ERROR",
|
|
485219
|
+
ParseError: "PARSE_ERROR",
|
|
485220
|
+
EnvironmentError: "ENVIRONMENT_ERROR",
|
|
485221
|
+
ReferenceError: "REFERENCE_ERROR",
|
|
485222
|
+
ValidationError: "VALIDATION_ERROR",
|
|
485223
|
+
NetworkError: "NETWORK_ERROR",
|
|
485224
|
+
AuthError: "AUTH_ERROR",
|
|
485225
|
+
ConfigError: "CONFIG_ERROR",
|
|
485226
|
+
Unclassified: "UNCLASSIFIED"
|
|
485227
|
+
};
|
|
485228
|
+
})(CliError || (CliError = {}));
|
|
485229
|
+
var SENTRY_REPORTABLE = {
|
|
485230
|
+
[CliError.Code.InternalError]: true,
|
|
485231
|
+
[CliError.Code.ResolutionError]: true,
|
|
485232
|
+
[CliError.Code.IrConversionError]: true,
|
|
485233
|
+
[CliError.Code.ContainerError]: true,
|
|
485234
|
+
[CliError.Code.VersionError]: true,
|
|
485235
|
+
[CliError.Code.ParseError]: false,
|
|
485236
|
+
[CliError.Code.EnvironmentError]: false,
|
|
485237
|
+
[CliError.Code.ReferenceError]: false,
|
|
485238
|
+
[CliError.Code.ValidationError]: false,
|
|
485239
|
+
[CliError.Code.NetworkError]: false,
|
|
485240
|
+
[CliError.Code.AuthError]: false,
|
|
485241
|
+
[CliError.Code.ConfigError]: false,
|
|
485242
|
+
[CliError.Code.Unclassified]: false
|
|
485243
|
+
};
|
|
485244
|
+
function shouldReportToSentry(code5) {
|
|
485245
|
+
return SENTRY_REPORTABLE[code5];
|
|
485246
|
+
}
|
|
485247
|
+
function isSchemaValidationError(error50) {
|
|
485248
|
+
return error50 instanceof Error && (error50.constructor.name === "ParseError" || error50.constructor.name === "JsonError");
|
|
485249
|
+
}
|
|
485250
|
+
function isNodeVersionError(error50) {
|
|
485251
|
+
return error50 instanceof Error && error50.message.includes("globalThis");
|
|
485252
|
+
}
|
|
485253
|
+
function resolveErrorCode(error50, explicitCode) {
|
|
485254
|
+
if (explicitCode != null) {
|
|
485255
|
+
return explicitCode;
|
|
485256
|
+
}
|
|
485257
|
+
if (error50 instanceof CliError) {
|
|
485258
|
+
return error50.code;
|
|
485259
|
+
}
|
|
485260
|
+
if (isSchemaValidationError(error50)) {
|
|
485261
|
+
return CliError.Code.ParseError;
|
|
485262
|
+
}
|
|
485263
|
+
if (isNodeVersionError(error50)) {
|
|
485264
|
+
return CliError.Code.EnvironmentError;
|
|
485265
|
+
}
|
|
485266
|
+
return CliError.Code.Unclassified;
|
|
485267
|
+
}
|
|
485268
|
+
|
|
485269
|
+
// ../logger/lib/LogLevel.js
|
|
485270
|
+
var LogLevel = {
|
|
485271
|
+
Trace: "trace",
|
|
485272
|
+
Debug: "debug",
|
|
485273
|
+
Info: "info",
|
|
485274
|
+
Warn: "warn",
|
|
485275
|
+
Error: "error"
|
|
485276
|
+
};
|
|
485277
|
+
var LOG_LEVELS = Object.values(LogLevel);
|
|
485278
|
+
|
|
485279
|
+
// ../logger/lib/createLogger.js
|
|
485280
|
+
var LoggerImpl = class {
|
|
485281
|
+
log;
|
|
485282
|
+
enabled;
|
|
485283
|
+
constructor(log4, enabled = true) {
|
|
485284
|
+
this.log = log4;
|
|
485285
|
+
this.enabled = enabled;
|
|
485286
|
+
}
|
|
485287
|
+
disable() {
|
|
485288
|
+
this.enabled = false;
|
|
485289
|
+
}
|
|
485290
|
+
enable() {
|
|
485291
|
+
this.enabled = true;
|
|
485292
|
+
}
|
|
485293
|
+
debug(...args) {
|
|
485294
|
+
if (this.enabled) {
|
|
485295
|
+
this.log(LogLevel.Debug, ...args);
|
|
485296
|
+
}
|
|
485297
|
+
}
|
|
485298
|
+
info(...args) {
|
|
485299
|
+
if (this.enabled) {
|
|
485300
|
+
this.log(LogLevel.Info, ...args);
|
|
485301
|
+
}
|
|
485302
|
+
}
|
|
485303
|
+
warn(...args) {
|
|
485304
|
+
if (this.enabled) {
|
|
485305
|
+
this.log(LogLevel.Warn, ...args);
|
|
485306
|
+
}
|
|
485307
|
+
}
|
|
485308
|
+
error(...args) {
|
|
485309
|
+
if (this.enabled) {
|
|
485310
|
+
this.log(LogLevel.Error, ...args);
|
|
485311
|
+
}
|
|
485312
|
+
}
|
|
485313
|
+
trace(...args) {
|
|
485314
|
+
if (this.enabled) {
|
|
485315
|
+
this.log(LogLevel.Trace, ...args);
|
|
485316
|
+
}
|
|
485317
|
+
}
|
|
485318
|
+
};
|
|
485319
|
+
function createLogger(log4) {
|
|
485320
|
+
return new LoggerImpl(log4);
|
|
485321
|
+
}
|
|
485322
|
+
|
|
485323
|
+
// ../logger/lib/console.js
|
|
485324
|
+
var CONSOLE_LOGGER = Object.freeze(createLogger(log3));
|
|
485325
|
+
function log3(level, ...args) {
|
|
485326
|
+
const consoleLogger = getConsoleLoggerForLevel(level);
|
|
485327
|
+
consoleLogger(...args);
|
|
485328
|
+
}
|
|
485329
|
+
function getConsoleLoggerForLevel(level) {
|
|
485330
|
+
switch (level) {
|
|
485331
|
+
case LogLevel.Trace:
|
|
485332
|
+
return console.trace;
|
|
485333
|
+
case LogLevel.Debug:
|
|
485334
|
+
return console.debug;
|
|
485335
|
+
case LogLevel.Info:
|
|
485336
|
+
return console.info;
|
|
485337
|
+
case LogLevel.Warn:
|
|
485338
|
+
return console.warn;
|
|
485339
|
+
case LogLevel.Error:
|
|
485340
|
+
return console.error;
|
|
485341
|
+
}
|
|
485342
|
+
}
|
|
485343
|
+
|
|
485344
|
+
// ../task-context/lib/TaskAbortSignal.js
|
|
485345
|
+
var TaskAbortSignal = class {
|
|
485346
|
+
__brand = "TaskAbortSignal";
|
|
485347
|
+
};
|
|
485348
|
+
|
|
485349
|
+
// ../task-context/lib/TaskContext.js
|
|
485350
|
+
var TaskResult;
|
|
485351
|
+
(function(TaskResult2) {
|
|
485352
|
+
TaskResult2[TaskResult2["Success"] = 0] = "Success";
|
|
485353
|
+
TaskResult2[TaskResult2["Failure"] = 1] = "Failure";
|
|
485354
|
+
})(TaskResult || (TaskResult = {}));
|
|
485355
|
+
|
|
485356
|
+
// ../task-context/lib/MockTaskContext.js
|
|
485357
|
+
function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
485358
|
+
const context3 = {
|
|
485359
|
+
logger: logger4,
|
|
485360
|
+
takeOverTerminal: () => {
|
|
485361
|
+
throw new Error("Not implemented");
|
|
485362
|
+
},
|
|
485363
|
+
failAndThrow: (message, error50, _options) => {
|
|
485364
|
+
const parts = [];
|
|
485365
|
+
if (message != null) {
|
|
485366
|
+
parts.push(message);
|
|
485367
|
+
}
|
|
485368
|
+
if (error50 != null) {
|
|
485369
|
+
parts.push(JSON.stringify(error50));
|
|
485370
|
+
}
|
|
485371
|
+
if (parts.length > 0) {
|
|
485372
|
+
context3.logger.error(...parts);
|
|
485373
|
+
}
|
|
485374
|
+
throw new TaskAbortSignal();
|
|
485375
|
+
},
|
|
485376
|
+
failWithoutThrowing: (message, error50, _options) => {
|
|
485377
|
+
context3.failAndThrow(message, error50);
|
|
485378
|
+
},
|
|
485379
|
+
captureException: () => {
|
|
485380
|
+
},
|
|
485381
|
+
getResult: () => TaskResult.Success,
|
|
485382
|
+
addInteractiveTask: () => {
|
|
485383
|
+
throw new Error("Not implemented");
|
|
485384
|
+
},
|
|
485385
|
+
runInteractiveTask: () => {
|
|
485386
|
+
throw new Error("Not implemented");
|
|
485387
|
+
},
|
|
485388
|
+
instrumentPostHogEvent: () => {
|
|
485389
|
+
throw new Error("Not implemented");
|
|
485390
|
+
}
|
|
485391
|
+
};
|
|
485392
|
+
return context3;
|
|
485393
|
+
}
|
|
485394
|
+
|
|
485177
485395
|
// ../../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
485178
485396
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
485179
485397
|
var wrapAnsi16 = (offset2 = 0) => (code5) => `\x1B[${code5 + offset2}m`;
|
|
@@ -518729,17 +518947,17 @@ var FernDocsConfigTimeoutError = class extends Error {
|
|
|
518729
518947
|
};
|
|
518730
518948
|
|
|
518731
518949
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/logger.js
|
|
518732
|
-
var
|
|
518950
|
+
var LogLevel2 = {
|
|
518733
518951
|
Debug: "debug",
|
|
518734
518952
|
Info: "info",
|
|
518735
518953
|
Warn: "warn",
|
|
518736
518954
|
Error: "error"
|
|
518737
518955
|
};
|
|
518738
518956
|
var logLevelMap2 = {
|
|
518739
|
-
[
|
|
518740
|
-
[
|
|
518741
|
-
[
|
|
518742
|
-
[
|
|
518957
|
+
[LogLevel2.Debug]: 1,
|
|
518958
|
+
[LogLevel2.Info]: 2,
|
|
518959
|
+
[LogLevel2.Warn]: 3,
|
|
518960
|
+
[LogLevel2.Error]: 4
|
|
518743
518961
|
};
|
|
518744
518962
|
var ConsoleLogger = class {
|
|
518745
518963
|
debug(message, ...args) {
|
|
@@ -518781,7 +518999,7 @@ var Logger = class {
|
|
|
518781
518999
|
* @returns True if debug logs should be output
|
|
518782
519000
|
*/
|
|
518783
519001
|
isDebug() {
|
|
518784
|
-
return this.shouldLog(
|
|
519002
|
+
return this.shouldLog(LogLevel2.Debug);
|
|
518785
519003
|
}
|
|
518786
519004
|
/**
|
|
518787
519005
|
* Logs a debug message if debug logging is enabled.
|
|
@@ -518798,7 +519016,7 @@ var Logger = class {
|
|
|
518798
519016
|
* @returns True if info logs should be output
|
|
518799
519017
|
*/
|
|
518800
519018
|
isInfo() {
|
|
518801
|
-
return this.shouldLog(
|
|
519019
|
+
return this.shouldLog(LogLevel2.Info);
|
|
518802
519020
|
}
|
|
518803
519021
|
/**
|
|
518804
519022
|
* Logs an info message if info logging is enabled.
|
|
@@ -518815,7 +519033,7 @@ var Logger = class {
|
|
|
518815
519033
|
* @returns True if warning logs should be output
|
|
518816
519034
|
*/
|
|
518817
519035
|
isWarn() {
|
|
518818
|
-
return this.shouldLog(
|
|
519036
|
+
return this.shouldLog(LogLevel2.Warn);
|
|
518819
519037
|
}
|
|
518820
519038
|
/**
|
|
518821
519039
|
* Logs a warning message if warning logging is enabled.
|
|
@@ -518832,7 +519050,7 @@ var Logger = class {
|
|
|
518832
519050
|
* @returns True if error logs should be output
|
|
518833
519051
|
*/
|
|
518834
519052
|
isError() {
|
|
518835
|
-
return this.shouldLog(
|
|
519053
|
+
return this.shouldLog(LogLevel2.Error);
|
|
518836
519054
|
}
|
|
518837
519055
|
/**
|
|
518838
519056
|
* Logs an error message if error logging is enabled.
|
|
@@ -518846,7 +519064,7 @@ var Logger = class {
|
|
|
518846
519064
|
}
|
|
518847
519065
|
};
|
|
518848
519066
|
var defaultLogger = new Logger({
|
|
518849
|
-
level:
|
|
519067
|
+
level: LogLevel2.Info,
|
|
518850
519068
|
logger: new ConsoleLogger(),
|
|
518851
519069
|
silent: true
|
|
518852
519070
|
});
|
|
@@ -518854,7 +519072,7 @@ var defaultLogger = new Logger({
|
|
|
518854
519072
|
// ../configuration/lib/docs-yml/schemas/sdk/core/logging/exports.js
|
|
518855
519073
|
var logging;
|
|
518856
519074
|
(function(logging2) {
|
|
518857
|
-
logging2.LogLevel =
|
|
519075
|
+
logging2.LogLevel = LogLevel2;
|
|
518858
519076
|
logging2.ConsoleLogger = ConsoleLogger;
|
|
518859
519077
|
})(logging || (logging = {}));
|
|
518860
519078
|
|
|
@@ -555047,142 +555265,6 @@ function joinZodPath(arr) {
|
|
|
555047
555265
|
|
|
555048
555266
|
// ../configuration-loader/lib/dependencies-yml/convertDependenciesConfiguration.js
|
|
555049
555267
|
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
555268
|
var import_path21 = __toESM(require("path"), 1);
|
|
555187
555269
|
var EMPTY_DEPENDENCIES_CONFIGURATION = {
|
|
555188
555270
|
dependencies: {}
|
|
@@ -571169,7 +571251,7 @@ function getInline2(typeDeclaration2) {
|
|
|
571169
571251
|
function getTypeDeclaration(typeId, types4) {
|
|
571170
571252
|
const maybeTypeDeclaration = types4[typeId];
|
|
571171
571253
|
if (maybeTypeDeclaration == null) {
|
|
571172
|
-
throw
|
|
571254
|
+
throw CliError.internalError(`Failed to load type declaration for type ${typeId}`);
|
|
571173
571255
|
}
|
|
571174
571256
|
return maybeTypeDeclaration;
|
|
571175
571257
|
}
|
|
@@ -571231,7 +571313,7 @@ function getObjectTypeDeclarationFromTypeId(typeId, ir15) {
|
|
|
571231
571313
|
}
|
|
571232
571314
|
}
|
|
571233
571315
|
}
|
|
571234
|
-
throw
|
|
571316
|
+
throw CliError.internalError(`Unexpected error: ${typeId} is extended but has shape ${typeDeclaration2.shape.type}`);
|
|
571235
571317
|
}
|
|
571236
571318
|
function getAllPropertiesForObject2({ objectTypeDeclaration, ir: ir15 }) {
|
|
571237
571319
|
const extendedProperties = objectTypeDeclaration.extends.flatMap((extended) => {
|
|
@@ -579493,7 +579575,8 @@ function formatLog({ breadcrumbs = [], title: title3, subtitle }) {
|
|
|
579493
579575
|
}
|
|
579494
579576
|
|
|
579495
579577
|
// ../cli-logger/lib/logErrorMessage.js
|
|
579496
|
-
|
|
579578
|
+
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
579579
|
+
function logErrorMessage({ message, error: error50, logger: logger4, logLevel = LogLevel.Error }) {
|
|
579497
579580
|
if (message != null) {
|
|
579498
579581
|
logger4.log(logLevel, message);
|
|
579499
579582
|
} else if (error50 == null) {
|
|
@@ -579518,6 +579601,9 @@ function convertErrorToString(error50) {
|
|
|
579518
579601
|
return error50;
|
|
579519
579602
|
}
|
|
579520
579603
|
if (error50 instanceof Error) {
|
|
579604
|
+
if (error50?.message?.includes("globalThis")) {
|
|
579605
|
+
return USE_NODE_18_OR_ABOVE_MESSAGE;
|
|
579606
|
+
}
|
|
579521
579607
|
return error50.message;
|
|
579522
579608
|
}
|
|
579523
579609
|
return void 0;
|
|
@@ -580301,13 +580387,13 @@ function formatLog2(log4, { includeDebugInfo }) {
|
|
|
580301
580387
|
}
|
|
580302
580388
|
content5 += "\n";
|
|
580303
580389
|
switch (log4.level) {
|
|
580304
|
-
case
|
|
580390
|
+
case LogLevel.Error:
|
|
580305
580391
|
return source_default.red(content5);
|
|
580306
|
-
case
|
|
580392
|
+
case LogLevel.Warn:
|
|
580307
580393
|
return source_default.hex("FFA500")(content5);
|
|
580308
|
-
case
|
|
580309
|
-
case
|
|
580310
|
-
case
|
|
580394
|
+
case LogLevel.Trace:
|
|
580395
|
+
case LogLevel.Debug:
|
|
580396
|
+
case LogLevel.Info:
|
|
580311
580397
|
return content5;
|
|
580312
580398
|
}
|
|
580313
580399
|
}
|
|
@@ -580317,15 +580403,15 @@ function getDebugPrefix(log4) {
|
|
|
580317
580403
|
}
|
|
580318
580404
|
function getLogLevelAsString(logLevel) {
|
|
580319
580405
|
switch (logLevel) {
|
|
580320
|
-
case
|
|
580406
|
+
case LogLevel.Trace:
|
|
580321
580407
|
return "TRACE";
|
|
580322
|
-
case
|
|
580408
|
+
case LogLevel.Debug:
|
|
580323
580409
|
return "DEBUG";
|
|
580324
|
-
case
|
|
580410
|
+
case LogLevel.Info:
|
|
580325
580411
|
return "INFO";
|
|
580326
|
-
case
|
|
580412
|
+
case LogLevel.Warn:
|
|
580327
580413
|
return "WARN";
|
|
580328
|
-
case
|
|
580414
|
+
case LogLevel.Error:
|
|
580329
580415
|
return "ERROR";
|
|
580330
580416
|
default:
|
|
580331
580417
|
assertNever(logLevel);
|
|
@@ -606050,22 +606136,22 @@ var ErrorCollector2 = class {
|
|
|
606050
606136
|
}
|
|
606051
606137
|
switch (level) {
|
|
606052
606138
|
case APIErrorLevel.ERROR:
|
|
606053
|
-
this.logger.log(
|
|
606139
|
+
this.logger.log(LogLevel.Debug, error50.message);
|
|
606054
606140
|
if (error50.path && error50.path.length > 0) {
|
|
606055
606141
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606056
606142
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606057
|
-
this.logger.log(
|
|
606143
|
+
this.logger.log(LogLevel.Debug, ` - at location (${locationInfo})`);
|
|
606058
606144
|
}
|
|
606059
606145
|
break;
|
|
606060
606146
|
case APIErrorLevel.WARNING:
|
|
606061
|
-
this.logger.log(
|
|
606147
|
+
this.logger.log(LogLevel.Warn, error50.message);
|
|
606062
606148
|
if (error50.path && error50.path.length > 0) {
|
|
606063
606149
|
const sourceLocation = await this.breadcrumbToLineNumberMapper?.getSourceLocation(error50.path);
|
|
606064
606150
|
const locationInfo = sourceLocation ? `${this.relativeFilepathToSpec}:${sourceLocation.line}:${sourceLocation.column}` : error50.path.join(" -> ");
|
|
606065
|
-
this.logger.log(
|
|
606151
|
+
this.logger.log(LogLevel.Warn, ` - at location (${locationInfo})`);
|
|
606066
606152
|
}
|
|
606067
606153
|
if (error50.resolution) {
|
|
606068
|
-
this.logger.log(
|
|
606154
|
+
this.logger.log(LogLevel.Warn, ` - resolution: ${error50.resolution}`);
|
|
606069
606155
|
}
|
|
606070
606156
|
break;
|
|
606071
606157
|
}
|
|
@@ -606094,7 +606180,7 @@ var BreadcrumbToLineNumber = class {
|
|
|
606094
606180
|
jsYaml.load(fileContent, { listener: this.map.listen() });
|
|
606095
606181
|
this.initialized = true;
|
|
606096
606182
|
} catch (error50) {
|
|
606097
|
-
this.logger.log(
|
|
606183
|
+
this.logger.log(LogLevel.Warn, `Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(error50)}`);
|
|
606098
606184
|
}
|
|
606099
606185
|
}
|
|
606100
606186
|
/**
|
|
@@ -612978,7 +613064,7 @@ var FernGlobalHeadersExtension = class extends AbstractExtension {
|
|
|
612978
613064
|
}
|
|
612979
613065
|
};
|
|
612980
613066
|
|
|
612981
|
-
// ../api-importers/openapi-to-ir/lib/utils/
|
|
613067
|
+
// ../api-importers/openapi-to-ir/lib/utils/convertGlobalHeaderOverrides.js
|
|
612982
613068
|
function convertDefaultToLiteral2(defaultValue) {
|
|
612983
613069
|
if (defaultValue == null) {
|
|
612984
613070
|
return void 0;
|
|
@@ -612991,6 +613077,60 @@ function convertDefaultToLiteral2(defaultValue) {
|
|
|
612991
613077
|
}
|
|
612992
613078
|
return void 0;
|
|
612993
613079
|
}
|
|
613080
|
+
function convertGlobalHeaderOverrides({ globalHeaderOverrides, context: context3 }) {
|
|
613081
|
+
const headers2 = [];
|
|
613082
|
+
for (const [headerKey, headerSchema] of Object.entries(globalHeaderOverrides.headers ?? {})) {
|
|
613083
|
+
if (typeof headerSchema === "string") {
|
|
613084
|
+
headers2.push({
|
|
613085
|
+
name: context3.casingsGenerator.generateNameAndWireValue({
|
|
613086
|
+
name: headerKey,
|
|
613087
|
+
wireValue: headerKey
|
|
613088
|
+
}),
|
|
613089
|
+
valueType: AbstractConverter.STRING,
|
|
613090
|
+
env: void 0,
|
|
613091
|
+
v2Examples: {
|
|
613092
|
+
userSpecifiedExamples: {},
|
|
613093
|
+
autogeneratedExamples: {}
|
|
613094
|
+
},
|
|
613095
|
+
availability: void 0,
|
|
613096
|
+
docs: void 0,
|
|
613097
|
+
clientDefault: void 0
|
|
613098
|
+
});
|
|
613099
|
+
} else {
|
|
613100
|
+
const name2 = headerSchema.name ?? headerKey;
|
|
613101
|
+
headers2.push({
|
|
613102
|
+
name: context3.casingsGenerator.generateNameAndWireValue({
|
|
613103
|
+
name: name2,
|
|
613104
|
+
wireValue: headerKey
|
|
613105
|
+
}),
|
|
613106
|
+
valueType: AbstractConverter.STRING,
|
|
613107
|
+
env: headerSchema.env,
|
|
613108
|
+
v2Examples: {
|
|
613109
|
+
userSpecifiedExamples: {},
|
|
613110
|
+
autogeneratedExamples: {}
|
|
613111
|
+
},
|
|
613112
|
+
availability: void 0,
|
|
613113
|
+
docs: headerSchema.docs,
|
|
613114
|
+
clientDefault: convertDefaultToLiteral2(headerSchema.default)
|
|
613115
|
+
});
|
|
613116
|
+
}
|
|
613117
|
+
}
|
|
613118
|
+
return headers2;
|
|
613119
|
+
}
|
|
613120
|
+
|
|
613121
|
+
// ../api-importers/openapi-to-ir/lib/utils/convertGlobalHeadersExtension.js
|
|
613122
|
+
function convertDefaultToLiteral3(defaultValue) {
|
|
613123
|
+
if (defaultValue == null) {
|
|
613124
|
+
return void 0;
|
|
613125
|
+
}
|
|
613126
|
+
if (typeof defaultValue === "string") {
|
|
613127
|
+
return api_exports.Literal.string(defaultValue);
|
|
613128
|
+
}
|
|
613129
|
+
if (typeof defaultValue === "boolean") {
|
|
613130
|
+
return api_exports.Literal.boolean(defaultValue);
|
|
613131
|
+
}
|
|
613132
|
+
return void 0;
|
|
613133
|
+
}
|
|
612994
613134
|
function convertGlobalHeadersExtension({ globalHeaders, context: context3 }) {
|
|
612995
613135
|
return globalHeaders.map((header) => ({
|
|
612996
613136
|
name: context3.casingsGenerator.generateNameAndWireValue({
|
|
@@ -613002,7 +613142,7 @@ function convertGlobalHeadersExtension({ globalHeaders, context: context3 }) {
|
|
|
613002
613142
|
v2Examples: header.optional ? void 0 : constructGlobalHeaderExample({ header, context: context3 }),
|
|
613003
613143
|
availability: void 0,
|
|
613004
613144
|
docs: void 0,
|
|
613005
|
-
clientDefault:
|
|
613145
|
+
clientDefault: convertDefaultToLiteral3(header["x-fern-default"])
|
|
613006
613146
|
}));
|
|
613007
613147
|
}
|
|
613008
613148
|
function constructGlobalHeaderExample({ header, context: context3 }) {
|
|
@@ -616023,6 +616163,13 @@ var OpenAPIConverter = class extends AbstractSpecConverter {
|
|
|
616023
616163
|
}
|
|
616024
616164
|
convertGlobalHeaders() {
|
|
616025
616165
|
if (this.context.globalHeaderOverrides) {
|
|
616166
|
+
const globalHeaders = convertGlobalHeaderOverrides({
|
|
616167
|
+
globalHeaderOverrides: this.context.globalHeaderOverrides,
|
|
616168
|
+
context: this.context
|
|
616169
|
+
});
|
|
616170
|
+
this.addGlobalHeadersToIr(globalHeaders);
|
|
616171
|
+
this.context.setGlobalHeaders(globalHeaders);
|
|
616172
|
+
return;
|
|
616026
616173
|
}
|
|
616027
616174
|
const globalHeadersExtension = new FernGlobalHeadersExtension({
|
|
616028
616175
|
breadcrumbs: ["x-fern-global-headers"],
|
|
@@ -619302,851 +619449,16 @@ async function runRulesOnOSSWorkspace({ workspace, context: context3, rules }) {
|
|
|
619302
619449
|
return ruleResults.flat();
|
|
619303
619450
|
}
|
|
619304
619451
|
|
|
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
619452
|
// ../cli-v2/lib/auth/errors/KeyringUnavailableError.js
|
|
620145
|
-
var KeyringUnavailableError = class extends
|
|
619453
|
+
var KeyringUnavailableError = class _KeyringUnavailableError extends CliError {
|
|
620146
619454
|
platform;
|
|
620147
619455
|
cause;
|
|
620148
619456
|
constructor(platform3, cause) {
|
|
620149
|
-
super(
|
|
619457
|
+
super({
|
|
619458
|
+
message: getKeyringErrorMessage(platform3),
|
|
619459
|
+
code: CliError.Code.AuthError
|
|
619460
|
+
});
|
|
619461
|
+
Object.setPrototypeOf(this, _KeyringUnavailableError.prototype);
|
|
620150
619462
|
this.platform = platform3;
|
|
620151
619463
|
this.cause = cause;
|
|
620152
619464
|
}
|
|
@@ -620203,23 +619515,77 @@ If running in a headless environment, use FERN_TOKEN instead:
|
|
|
620203
619515
|
}
|
|
620204
619516
|
|
|
620205
619517
|
// ../cli-v2/lib/errors/SourcedValidationError.js
|
|
620206
|
-
var SourcedValidationError = class extends
|
|
619518
|
+
var SourcedValidationError = class _SourcedValidationError extends CliError {
|
|
620207
619519
|
issues;
|
|
620208
619520
|
constructor(issues) {
|
|
620209
|
-
super(
|
|
619521
|
+
super({
|
|
619522
|
+
message: issues.map((issue2) => issue2.toString()).join("\n"),
|
|
619523
|
+
code: CliError.Code.ValidationError
|
|
619524
|
+
});
|
|
619525
|
+
Object.setPrototypeOf(this, _SourcedValidationError.prototype);
|
|
620210
619526
|
this.issues = issues;
|
|
620211
619527
|
}
|
|
620212
619528
|
};
|
|
620213
619529
|
|
|
620214
619530
|
// ../cli-v2/lib/errors/ValidationError.js
|
|
620215
|
-
var ValidationError = class extends
|
|
619531
|
+
var ValidationError = class _ValidationError extends CliError {
|
|
620216
619532
|
violations;
|
|
620217
619533
|
constructor(violations) {
|
|
620218
|
-
super(
|
|
619534
|
+
super({
|
|
619535
|
+
message: violations.map((v23) => `${v23.relativeFilepath}: ${v23.message}`).join("\n"),
|
|
619536
|
+
code: CliError.Code.ValidationError
|
|
619537
|
+
});
|
|
619538
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
620219
619539
|
this.violations = violations;
|
|
620220
619540
|
}
|
|
620221
619541
|
};
|
|
620222
619542
|
|
|
619543
|
+
// ../cli-v2/lib/ui/format.js
|
|
619544
|
+
function formatMultilineText({ text: text9, colorFn, icon, baseIndent = 4, continuationIndent = 6 }) {
|
|
619545
|
+
if (text9 == null) {
|
|
619546
|
+
return "";
|
|
619547
|
+
}
|
|
619548
|
+
const lines = text9.split("\n").filter((line) => line.trim().length > 0);
|
|
619549
|
+
if (lines.length === 0) {
|
|
619550
|
+
return "";
|
|
619551
|
+
}
|
|
619552
|
+
const baseIndentStr = " ".repeat(baseIndent);
|
|
619553
|
+
const contIndentStr = " ".repeat(continuationIndent);
|
|
619554
|
+
if (icon != null) {
|
|
619555
|
+
const [first3, ...rest] = lines;
|
|
619556
|
+
const firstLine = `
|
|
619557
|
+
${baseIndentStr}${icon} ${colorFn(first3 ?? "")}`;
|
|
619558
|
+
const restLines = rest.map((line) => `
|
|
619559
|
+
${contIndentStr}${colorFn(line)}`).join("");
|
|
619560
|
+
return firstLine + restLines;
|
|
619561
|
+
}
|
|
619562
|
+
return lines.map((line) => `
|
|
619563
|
+
${baseIndentStr}${colorFn(line)}`).join("");
|
|
619564
|
+
}
|
|
619565
|
+
var Icons = {
|
|
619566
|
+
error: source_default.red("\u2717"),
|
|
619567
|
+
warning: source_default.yellow("\u26A0"),
|
|
619568
|
+
success: source_default.green("\u2713"),
|
|
619569
|
+
info: source_default.cyan("\u25C6")
|
|
619570
|
+
};
|
|
619571
|
+
var Colors = {
|
|
619572
|
+
error: source_default.red.bind(source_default),
|
|
619573
|
+
warning: source_default.yellow.bind(source_default),
|
|
619574
|
+
success: source_default.green.bind(source_default),
|
|
619575
|
+
info: source_default.cyan.bind(source_default),
|
|
619576
|
+
dim: source_default.dim.bind(source_default)
|
|
619577
|
+
};
|
|
619578
|
+
function formatBytes(bytes) {
|
|
619579
|
+
if (bytes === 0) {
|
|
619580
|
+
return "0 B";
|
|
619581
|
+
}
|
|
619582
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
619583
|
+
const base4 = 1024;
|
|
619584
|
+
const index3 = Math.min(Math.floor(Math.log(bytes) / Math.log(base4)), units.length - 1);
|
|
619585
|
+
const value = bytes / Math.pow(base4, index3);
|
|
619586
|
+
return `${value.toFixed(index3 === 0 ? 0 : 1)} ${units[index3]}`;
|
|
619587
|
+
}
|
|
619588
|
+
|
|
620223
619589
|
// ../auth/lib/orgs/checkOrganizationMembership.js
|
|
620224
619590
|
async function checkOrganizationMembership({ organization, token }) {
|
|
620225
619591
|
const venus = createVenusService({ token: token.value });
|
|
@@ -627639,7 +627005,7 @@ var AccessTokenPosthogManager = class {
|
|
|
627639
627005
|
properties: {
|
|
627640
627006
|
...event,
|
|
627641
627007
|
...event.properties,
|
|
627642
|
-
version: "4.68.2",
|
|
627008
|
+
version: "4.68.3-2-g063113b6335",
|
|
627643
627009
|
usingAccessToken: true
|
|
627644
627010
|
}
|
|
627645
627011
|
});
|
|
@@ -627693,7 +627059,7 @@ var UserPosthogManager = class {
|
|
|
627693
627059
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
627694
627060
|
event: "CLI",
|
|
627695
627061
|
properties: {
|
|
627696
|
-
version: "4.68.2",
|
|
627062
|
+
version: "4.68.3-2-g063113b6335",
|
|
627697
627063
|
...event,
|
|
627698
627064
|
...event.properties,
|
|
627699
627065
|
usingAccessToken: false,
|
|
@@ -631205,7 +630571,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
631205
630571
|
* The caller is responsible for deciding which errors are worth reporting
|
|
631206
630572
|
* (see `shouldReportToSentry` in withContext.ts).
|
|
631207
630573
|
*/
|
|
631208
|
-
captureException(error50) {
|
|
630574
|
+
captureException(error50, { errorCode }) {
|
|
631209
630575
|
if (this.sentry === void 0) {
|
|
631210
630576
|
return;
|
|
631211
630577
|
}
|
|
@@ -631213,7 +630579,7 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
631213
630579
|
this.sentry.captureException(error50, {
|
|
631214
630580
|
captureContext: {
|
|
631215
630581
|
user: { id: this.distinctId },
|
|
631216
|
-
tags: { ...this.baseTags, ...this.accumulatedTags }
|
|
630582
|
+
tags: { ...this.baseTags, ...this.accumulatedTags, "error.code": errorCode }
|
|
631217
630583
|
}
|
|
631218
630584
|
});
|
|
631219
630585
|
} catch {
|
|
@@ -632113,6 +631479,7 @@ var Context = class _Context {
|
|
|
632113
631479
|
shutdownCallbacks = [];
|
|
632114
631480
|
isShuttingDown = false;
|
|
632115
631481
|
logFilePathPrinted = false;
|
|
631482
|
+
createdAt = Date.now();
|
|
632116
631483
|
cwd;
|
|
632117
631484
|
logLevel;
|
|
632118
631485
|
info;
|
|
@@ -632130,10 +631497,10 @@ var Context = class _Context {
|
|
|
632130
631497
|
}
|
|
632131
631498
|
constructor({ cwd: cwd2, logLevel, ttyAwareLogger, telemetry }) {
|
|
632132
631499
|
this.cwd = cwd2 ?? AbsoluteFilePath2.of(process.cwd());
|
|
632133
|
-
this.logLevel = logLevel ??
|
|
631500
|
+
this.logLevel = logLevel ?? LogLevel.Info;
|
|
632134
631501
|
this.info = parseCommandInfo(process.argv);
|
|
632135
|
-
this.stdout =
|
|
632136
|
-
this.stderr =
|
|
631502
|
+
this.stdout = createLogger((level, ...args) => this.log(level, ...args));
|
|
631503
|
+
this.stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
632137
631504
|
this.cache = new Cache({ logger: this.stderr });
|
|
632138
631505
|
this.logs = new LogFileWriter(this.cache.logs.absoluteFilePath);
|
|
632139
631506
|
this.ttyAwareLogger = ttyAwareLogger;
|
|
@@ -632191,7 +631558,7 @@ var Context = class _Context {
|
|
|
632191
631558
|
this.stderr.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
632192
631559
|
this.stderr.info("");
|
|
632193
631560
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
632194
|
-
throw CliError.
|
|
631561
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632195
631562
|
}
|
|
632196
631563
|
return await this.promptAndLogin();
|
|
632197
631564
|
}
|
|
@@ -632201,7 +631568,7 @@ var Context = class _Context {
|
|
|
632201
631568
|
this.stderr.error(`${Icons.error} Your access token has expired.`);
|
|
632202
631569
|
this.stderr.info("");
|
|
632203
631570
|
this.stderr.info(source_default.dim(" To authenticate, run: 'fern auth login' or set the FERN_TOKEN environment variable"));
|
|
632204
|
-
throw CliError.
|
|
631571
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632205
631572
|
}
|
|
632206
631573
|
return await this.promptAndLogin();
|
|
632207
631574
|
}
|
|
@@ -632217,7 +631584,7 @@ var Context = class _Context {
|
|
|
632217
631584
|
}
|
|
632218
631585
|
]);
|
|
632219
631586
|
if (!confirm) {
|
|
632220
|
-
throw CliError.
|
|
631587
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
632221
631588
|
}
|
|
632222
631589
|
this.stderr.info(`${Icons.info} Opening browser to log in to Fern...`);
|
|
632223
631590
|
this.stderr.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
@@ -632229,12 +631596,12 @@ var Context = class _Context {
|
|
|
632229
631596
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
632230
631597
|
if (payload == null) {
|
|
632231
631598
|
this.stderr.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
632232
|
-
throw CliError.
|
|
631599
|
+
throw new CliError({ code: CliError.Code.InternalError });
|
|
632233
631600
|
}
|
|
632234
631601
|
const email3 = payload.email;
|
|
632235
631602
|
if (email3 == null) {
|
|
632236
631603
|
this.stderr.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
632237
|
-
throw CliError.
|
|
631604
|
+
throw new CliError({ code: CliError.Code.InternalError });
|
|
632238
631605
|
}
|
|
632239
631606
|
await this.tokenService.login(email3, accessToken);
|
|
632240
631607
|
this.stderr.info(`${Icons.success} Logged in as ${source_default.bold(email3)}`);
|
|
@@ -632365,7 +631732,7 @@ ${source_default.dim(`Logs written to: ${this.logs.absoluteFilePath}`)}
|
|
|
632365
631732
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
632366
631733
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
632367
631734
|
this.ttyAwareLogger.log(filtered, {
|
|
632368
|
-
includeDebugInfo: this.logLevel ===
|
|
631735
|
+
includeDebugInfo: this.logLevel === LogLevel.Debug,
|
|
632369
631736
|
stderr
|
|
632370
631737
|
});
|
|
632371
631738
|
}
|
|
@@ -632378,28 +631745,19 @@ var SIGTERM_EXIT_CODE = SIGNAL_EXIT_CODE_BASE + 15;
|
|
|
632378
631745
|
function withContext(handler3) {
|
|
632379
631746
|
return async (args) => {
|
|
632380
631747
|
const context3 = await createContext(args);
|
|
632381
|
-
const startTime = Date.now();
|
|
632382
631748
|
setupSignalHandler(context3);
|
|
632383
631749
|
try {
|
|
632384
631750
|
await handler3(context3, args);
|
|
632385
631751
|
context3.telemetry.sendLifecycleEvent({
|
|
632386
631752
|
command: context3.info.command,
|
|
632387
631753
|
status: "success",
|
|
632388
|
-
durationMs: Date.now() -
|
|
631754
|
+
durationMs: Date.now() - context3.createdAt
|
|
632389
631755
|
});
|
|
632390
631756
|
await context3.telemetry.flush();
|
|
632391
631757
|
context3.finish();
|
|
632392
631758
|
await exitGracefully(0);
|
|
632393
631759
|
} 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
|
-
});
|
|
631760
|
+
reportError(context3, error50);
|
|
632403
631761
|
await context3.telemetry.flush();
|
|
632404
631762
|
handleError(context3, error50);
|
|
632405
631763
|
context3.finish();
|
|
@@ -632439,7 +631797,7 @@ function handleError(context3, error50) {
|
|
|
632439
631797
|
return;
|
|
632440
631798
|
}
|
|
632441
631799
|
if (error50 instanceof CliError) {
|
|
632442
|
-
if (error50.message.length > 0) {
|
|
631800
|
+
if (error50.message && error50.message.length > 0) {
|
|
632443
631801
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
632444
631802
|
`);
|
|
632445
631803
|
}
|
|
@@ -632448,7 +631806,7 @@ function handleError(context3, error50) {
|
|
|
632448
631806
|
if (error50 instanceof Error) {
|
|
632449
631807
|
process.stderr.write(`${source_default.red(error50.message)}
|
|
632450
631808
|
`);
|
|
632451
|
-
if (error50.stack != null && context3.logLevel ===
|
|
631809
|
+
if (error50.stack != null && context3.logLevel === LogLevel.Debug) {
|
|
632452
631810
|
process.stderr.write(`${source_default.dim(error50.stack)}
|
|
632453
631811
|
`);
|
|
632454
631812
|
}
|
|
@@ -632457,29 +631815,23 @@ function handleError(context3, error50) {
|
|
|
632457
631815
|
process.stderr.write(`${source_default.red(String(error50))}
|
|
632458
631816
|
`);
|
|
632459
631817
|
}
|
|
632460
|
-
function
|
|
631818
|
+
function reportError(context3, error50, options2) {
|
|
632461
631819
|
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";
|
|
631820
|
+
return;
|
|
632478
631821
|
}
|
|
632479
|
-
|
|
632480
|
-
|
|
631822
|
+
const code5 = resolveErrorCode(error50, options2?.code);
|
|
631823
|
+
const capturable = error50 ?? new CliError({ message: options2?.message ?? "", code: code5 });
|
|
631824
|
+
if (shouldReportToSentry(code5)) {
|
|
631825
|
+
context3.telemetry.captureException(capturable, {
|
|
631826
|
+
errorCode: code5
|
|
631827
|
+
});
|
|
632481
631828
|
}
|
|
632482
|
-
|
|
631829
|
+
context3.telemetry.sendLifecycleEvent({
|
|
631830
|
+
status: "error",
|
|
631831
|
+
command: context3.info.command,
|
|
631832
|
+
durationMs: Date.now() - context3.createdAt,
|
|
631833
|
+
errorCode: code5
|
|
631834
|
+
});
|
|
632483
631835
|
}
|
|
632484
631836
|
function setupSignalHandler(context3) {
|
|
632485
631837
|
const onSignal = (exitCode) => {
|
|
@@ -632504,18 +631856,771 @@ function exitGracefully(code5) {
|
|
|
632504
631856
|
function parseLogLevel(level) {
|
|
632505
631857
|
switch (level.toLowerCase()) {
|
|
632506
631858
|
case "debug":
|
|
632507
|
-
return
|
|
631859
|
+
return LogLevel.Debug;
|
|
632508
631860
|
case "info":
|
|
632509
|
-
return
|
|
631861
|
+
return LogLevel.Info;
|
|
632510
631862
|
case "warn":
|
|
632511
|
-
return
|
|
631863
|
+
return LogLevel.Warn;
|
|
632512
631864
|
case "error":
|
|
632513
|
-
return
|
|
631865
|
+
return LogLevel.Error;
|
|
632514
631866
|
default:
|
|
632515
|
-
return
|
|
631867
|
+
return LogLevel.Info;
|
|
632516
631868
|
}
|
|
632517
631869
|
}
|
|
632518
631870
|
|
|
631871
|
+
// ../cli-v2/lib/context/adapter/TaskContextLogger.js
|
|
631872
|
+
var TaskContextLogger = class {
|
|
631873
|
+
context;
|
|
631874
|
+
task;
|
|
631875
|
+
logLevel;
|
|
631876
|
+
enabled = true;
|
|
631877
|
+
collectedErrors = [];
|
|
631878
|
+
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631879
|
+
this.context = context3;
|
|
631880
|
+
this.task = task;
|
|
631881
|
+
this.logLevel = logLevel;
|
|
631882
|
+
}
|
|
631883
|
+
disable() {
|
|
631884
|
+
this.enabled = false;
|
|
631885
|
+
}
|
|
631886
|
+
enable() {
|
|
631887
|
+
this.enabled = true;
|
|
631888
|
+
}
|
|
631889
|
+
trace(..._args) {
|
|
631890
|
+
}
|
|
631891
|
+
debug(...args) {
|
|
631892
|
+
const message = args.join(" ");
|
|
631893
|
+
this.writeLog({ level: LogLevel.Debug, message });
|
|
631894
|
+
if (this.shouldLogToTask(LogLevel.Debug)) {
|
|
631895
|
+
if (this.task.logs == null) {
|
|
631896
|
+
this.task.logs = [];
|
|
631897
|
+
}
|
|
631898
|
+
this.task.logs.push({ level: "debug", message });
|
|
631899
|
+
}
|
|
631900
|
+
}
|
|
631901
|
+
info(...args) {
|
|
631902
|
+
const message = args.join(" ");
|
|
631903
|
+
this.writeLog({ level: LogLevel.Info, message });
|
|
631904
|
+
if (this.shouldLogToTask(LogLevel.Info)) {
|
|
631905
|
+
if (this.task.logs == null) {
|
|
631906
|
+
this.task.logs = [];
|
|
631907
|
+
}
|
|
631908
|
+
this.task.logs.push({ level: "debug", message });
|
|
631909
|
+
}
|
|
631910
|
+
}
|
|
631911
|
+
warn(...args) {
|
|
631912
|
+
const message = args.join(" ");
|
|
631913
|
+
this.writeLog({ level: LogLevel.Warn, message });
|
|
631914
|
+
if (this.shouldLogToTask(LogLevel.Warn)) {
|
|
631915
|
+
if (this.task.logs == null) {
|
|
631916
|
+
this.task.logs = [];
|
|
631917
|
+
}
|
|
631918
|
+
this.task.logs.push({ level: "warn", message });
|
|
631919
|
+
}
|
|
631920
|
+
}
|
|
631921
|
+
error(...args) {
|
|
631922
|
+
const message = args.join(" ");
|
|
631923
|
+
this.writeLog({ level: LogLevel.Error, message });
|
|
631924
|
+
if (this.shouldLogToTask(LogLevel.Error)) {
|
|
631925
|
+
this.collectedErrors.push(message);
|
|
631926
|
+
if (this.task.logs == null) {
|
|
631927
|
+
this.task.logs = [];
|
|
631928
|
+
}
|
|
631929
|
+
this.task.logs.push({ level: "error", message });
|
|
631930
|
+
}
|
|
631931
|
+
}
|
|
631932
|
+
log(level, ...args) {
|
|
631933
|
+
switch (level) {
|
|
631934
|
+
case LogLevel.Debug:
|
|
631935
|
+
this.debug(...args);
|
|
631936
|
+
break;
|
|
631937
|
+
case LogLevel.Info:
|
|
631938
|
+
this.info(...args);
|
|
631939
|
+
break;
|
|
631940
|
+
case LogLevel.Warn:
|
|
631941
|
+
this.warn(...args);
|
|
631942
|
+
break;
|
|
631943
|
+
case LogLevel.Error:
|
|
631944
|
+
this.error(...args);
|
|
631945
|
+
break;
|
|
631946
|
+
}
|
|
631947
|
+
}
|
|
631948
|
+
/**
|
|
631949
|
+
* Write a log entry to the log file. In CI / non-TTY environments,
|
|
631950
|
+
* also write directly to stderr so logs are visible in CI runner output.
|
|
631951
|
+
*/
|
|
631952
|
+
writeLog({ level, message }) {
|
|
631953
|
+
this.context.logs.write({ taskName: this.task.name, level, message });
|
|
631954
|
+
if (this.context.isTTY) {
|
|
631955
|
+
return;
|
|
631956
|
+
}
|
|
631957
|
+
if (!this.enabled) {
|
|
631958
|
+
return;
|
|
631959
|
+
}
|
|
631960
|
+
const prefix2 = source_default.dim(`[${this.task.name}]`);
|
|
631961
|
+
switch (level) {
|
|
631962
|
+
case LogLevel.Warn:
|
|
631963
|
+
process.stderr.write(`${prefix2}: ${source_default.yellow(message)}
|
|
631964
|
+
`);
|
|
631965
|
+
break;
|
|
631966
|
+
case LogLevel.Error:
|
|
631967
|
+
process.stderr.write(`${prefix2}: ${source_default.red(message)}
|
|
631968
|
+
`);
|
|
631969
|
+
break;
|
|
631970
|
+
default:
|
|
631971
|
+
process.stderr.write(`${prefix2}: ${message}
|
|
631972
|
+
`);
|
|
631973
|
+
break;
|
|
631974
|
+
}
|
|
631975
|
+
}
|
|
631976
|
+
/**
|
|
631977
|
+
* Check if a message at the given level should be logged to the task's UI.
|
|
631978
|
+
*/
|
|
631979
|
+
shouldLogToTask(level) {
|
|
631980
|
+
return this.enabled && LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.logLevel);
|
|
631981
|
+
}
|
|
631982
|
+
};
|
|
631983
|
+
|
|
631984
|
+
// ../cli-v2/lib/context/adapter/TaskContextAdapter.js
|
|
631985
|
+
var TaskContextAdapter = class {
|
|
631986
|
+
result = TaskResult.Success;
|
|
631987
|
+
context;
|
|
631988
|
+
logger;
|
|
631989
|
+
constructor({ context: context3, task, logLevel = LogLevel.Warn }) {
|
|
631990
|
+
this.context = context3;
|
|
631991
|
+
if (task != null) {
|
|
631992
|
+
this.logger = new TaskContextLogger({ context: context3, task, logLevel });
|
|
631993
|
+
} else {
|
|
631994
|
+
this.logger = createLogger((level, ...args) => {
|
|
631995
|
+
if (LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(logLevel)) {
|
|
631996
|
+
context3.stderr.log(level, ...args);
|
|
631997
|
+
}
|
|
631998
|
+
});
|
|
631999
|
+
}
|
|
632000
|
+
}
|
|
632001
|
+
async takeOverTerminal(run) {
|
|
632002
|
+
await run();
|
|
632003
|
+
}
|
|
632004
|
+
failAndThrow(message, error50, options2) {
|
|
632005
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
632006
|
+
throw new TaskAbortSignal();
|
|
632007
|
+
}
|
|
632008
|
+
failWithoutThrowing(message, error50, options2) {
|
|
632009
|
+
this.result = TaskResult.Failure;
|
|
632010
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
632011
|
+
return;
|
|
632012
|
+
}
|
|
632013
|
+
const fullMessage = this.getFullErrorMessage(message, error50);
|
|
632014
|
+
if (fullMessage != null) {
|
|
632015
|
+
this.logger.error(fullMessage);
|
|
632016
|
+
}
|
|
632017
|
+
reportError(this.context, error50, { ...options2, message });
|
|
632018
|
+
}
|
|
632019
|
+
captureException(error50, code5) {
|
|
632020
|
+
const errorCode = resolveErrorCode(error50, code5);
|
|
632021
|
+
this.context.telemetry.captureException(error50, { errorCode });
|
|
632022
|
+
}
|
|
632023
|
+
getFullErrorMessage(message, error50) {
|
|
632024
|
+
const errorDetails = this.formatError(error50);
|
|
632025
|
+
if (message != null && errorDetails != null) {
|
|
632026
|
+
return message.includes(errorDetails) ? message : `${message}: ${errorDetails}`;
|
|
632027
|
+
}
|
|
632028
|
+
return message ?? errorDetails;
|
|
632029
|
+
}
|
|
632030
|
+
getResult() {
|
|
632031
|
+
return this.result;
|
|
632032
|
+
}
|
|
632033
|
+
addInteractiveTask(_params) {
|
|
632034
|
+
const subtask = {
|
|
632035
|
+
logger: this.logger,
|
|
632036
|
+
takeOverTerminal: this.takeOverTerminal.bind(this),
|
|
632037
|
+
failAndThrow: this.failAndThrow.bind(this),
|
|
632038
|
+
failWithoutThrowing: this.failWithoutThrowing.bind(this),
|
|
632039
|
+
captureException: this.captureException.bind(this),
|
|
632040
|
+
getResult: () => this.result,
|
|
632041
|
+
addInteractiveTask: this.addInteractiveTask.bind(this),
|
|
632042
|
+
runInteractiveTask: this.runInteractiveTask.bind(this),
|
|
632043
|
+
instrumentPostHogEvent: this.instrumentPostHogEvent.bind(this),
|
|
632044
|
+
setSubtitle: (_subtitle) => {
|
|
632045
|
+
},
|
|
632046
|
+
start: () => {
|
|
632047
|
+
return subtask;
|
|
632048
|
+
},
|
|
632049
|
+
isStarted: () => true,
|
|
632050
|
+
finish: () => {
|
|
632051
|
+
},
|
|
632052
|
+
isFinished: () => true
|
|
632053
|
+
};
|
|
632054
|
+
return subtask;
|
|
632055
|
+
}
|
|
632056
|
+
async runInteractiveTask(params2, run) {
|
|
632057
|
+
const subtask = this.addInteractiveTask(params2).start();
|
|
632058
|
+
try {
|
|
632059
|
+
await run(subtask);
|
|
632060
|
+
return true;
|
|
632061
|
+
} catch {
|
|
632062
|
+
return false;
|
|
632063
|
+
}
|
|
632064
|
+
}
|
|
632065
|
+
instrumentPostHogEvent(_event) {
|
|
632066
|
+
}
|
|
632067
|
+
formatError(error50) {
|
|
632068
|
+
if (error50 == null) {
|
|
632069
|
+
return void 0;
|
|
632070
|
+
}
|
|
632071
|
+
if (error50 instanceof Error) {
|
|
632072
|
+
return error50.message;
|
|
632073
|
+
}
|
|
632074
|
+
if (typeof error50 === "string") {
|
|
632075
|
+
return error50;
|
|
632076
|
+
}
|
|
632077
|
+
if (typeof error50 === "object") {
|
|
632078
|
+
const message = this.extractErrorMessage(error50);
|
|
632079
|
+
if (message != null) {
|
|
632080
|
+
return message;
|
|
632081
|
+
}
|
|
632082
|
+
}
|
|
632083
|
+
try {
|
|
632084
|
+
return JSON.stringify(error50);
|
|
632085
|
+
} catch {
|
|
632086
|
+
return String(error50);
|
|
632087
|
+
}
|
|
632088
|
+
}
|
|
632089
|
+
/**
|
|
632090
|
+
* Attempts to extract a human-readable message from a structured error object.
|
|
632091
|
+
*
|
|
632092
|
+
* Handles common shapes from the FDR SDK and other API clients, e.g.:
|
|
632093
|
+
* { content: { body: { message: "..." } } }
|
|
632094
|
+
* { body: { message: "..." } }
|
|
632095
|
+
* { message: "..." }
|
|
632096
|
+
*/
|
|
632097
|
+
extractErrorMessage(error50) {
|
|
632098
|
+
const record21 = error50;
|
|
632099
|
+
if (typeof record21.message === "string") {
|
|
632100
|
+
return record21.message;
|
|
632101
|
+
}
|
|
632102
|
+
if (record21.body != null && typeof record21.body === "object") {
|
|
632103
|
+
const body = record21.body;
|
|
632104
|
+
if (typeof body.message === "string") {
|
|
632105
|
+
return body.message;
|
|
632106
|
+
}
|
|
632107
|
+
}
|
|
632108
|
+
if (record21.content != null && typeof record21.content === "object") {
|
|
632109
|
+
return this.extractErrorMessage(record21.content);
|
|
632110
|
+
}
|
|
632111
|
+
return void 0;
|
|
632112
|
+
}
|
|
632113
|
+
};
|
|
632114
|
+
|
|
632115
|
+
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632116
|
+
init_lib6();
|
|
632117
|
+
|
|
632118
|
+
// ../cli-v2/lib/api/config/OpenRpcSpec.js
|
|
632119
|
+
function isOpenRpcSpec(spec) {
|
|
632120
|
+
return "openrpc" in spec;
|
|
632121
|
+
}
|
|
632122
|
+
|
|
632123
|
+
// ../cli-v2/lib/api/config/ProtobufSpec.js
|
|
632124
|
+
function isProtobufSpec(spec) {
|
|
632125
|
+
return "proto" in spec;
|
|
632126
|
+
}
|
|
632127
|
+
|
|
632128
|
+
// ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
|
|
632129
|
+
var LegacyApiSpecAdapter = class {
|
|
632130
|
+
context;
|
|
632131
|
+
constructor(config5) {
|
|
632132
|
+
this.context = config5.context;
|
|
632133
|
+
}
|
|
632134
|
+
adapt(spec) {
|
|
632135
|
+
if (isOpenApiSpec(spec)) {
|
|
632136
|
+
return this.adaptOpenApiSpec(spec);
|
|
632137
|
+
}
|
|
632138
|
+
if (isAsyncApiSpec(spec)) {
|
|
632139
|
+
return this.adaptAsyncApiSpec(spec);
|
|
632140
|
+
}
|
|
632141
|
+
if (isProtobufSpec(spec)) {
|
|
632142
|
+
return this.adaptProtobufSpec(spec);
|
|
632143
|
+
}
|
|
632144
|
+
if (isOpenRpcSpec(spec)) {
|
|
632145
|
+
return this.adaptOpenRpcSpec(spec);
|
|
632146
|
+
}
|
|
632147
|
+
throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
|
|
632148
|
+
}
|
|
632149
|
+
convertAll(specs) {
|
|
632150
|
+
return specs.map((spec) => this.adapt(spec));
|
|
632151
|
+
}
|
|
632152
|
+
adaptOpenApiSpec(spec) {
|
|
632153
|
+
return {
|
|
632154
|
+
type: "openapi",
|
|
632155
|
+
absoluteFilepath: spec.openapi,
|
|
632156
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632157
|
+
absoluteFilepathToOverlays: spec.overlays,
|
|
632158
|
+
namespace: spec.namespace,
|
|
632159
|
+
source: {
|
|
632160
|
+
type: "openapi",
|
|
632161
|
+
file: spec.openapi
|
|
632162
|
+
},
|
|
632163
|
+
settings: this.adaptOpenApiSettings(spec.settings)
|
|
632164
|
+
};
|
|
632165
|
+
}
|
|
632166
|
+
adaptAsyncApiSpec(spec) {
|
|
632167
|
+
return {
|
|
632168
|
+
type: "openapi",
|
|
632169
|
+
absoluteFilepath: spec.asyncapi,
|
|
632170
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632171
|
+
absoluteFilepathToOverlays: void 0,
|
|
632172
|
+
namespace: spec.namespace,
|
|
632173
|
+
source: {
|
|
632174
|
+
type: "asyncapi",
|
|
632175
|
+
file: spec.asyncapi
|
|
632176
|
+
},
|
|
632177
|
+
settings: this.adaptAsyncApiSettings(spec.settings)
|
|
632178
|
+
};
|
|
632179
|
+
}
|
|
632180
|
+
adaptProtobufSpec(spec) {
|
|
632181
|
+
const proto3 = spec.proto;
|
|
632182
|
+
return {
|
|
632183
|
+
type: "protobuf",
|
|
632184
|
+
absoluteFilepathToProtobufRoot: proto3.root,
|
|
632185
|
+
absoluteFilepathToProtobufTarget: proto3.target,
|
|
632186
|
+
absoluteFilepathToOverrides: proto3.overrides,
|
|
632187
|
+
relativeFilepathToProtobufRoot: relativize(this.context.cwd, proto3.root),
|
|
632188
|
+
generateLocally: proto3.localGeneration ?? false,
|
|
632189
|
+
fromOpenAPI: proto3.fromOpenapi ?? false,
|
|
632190
|
+
dependencies: proto3.dependencies?.map((dep) => dep.toString()) ?? [],
|
|
632191
|
+
settings: void 0
|
|
632192
|
+
};
|
|
632193
|
+
}
|
|
632194
|
+
adaptOpenRpcSpec(spec) {
|
|
632195
|
+
return {
|
|
632196
|
+
type: "openrpc",
|
|
632197
|
+
absoluteFilepath: spec.openrpc,
|
|
632198
|
+
absoluteFilepathToOverrides: spec.overrides,
|
|
632199
|
+
namespace: void 0
|
|
632200
|
+
};
|
|
632201
|
+
}
|
|
632202
|
+
adaptOpenApiSettings(settings) {
|
|
632203
|
+
if (settings == null) {
|
|
632204
|
+
return void 0;
|
|
632205
|
+
}
|
|
632206
|
+
const result = {
|
|
632207
|
+
// Base API settings
|
|
632208
|
+
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632209
|
+
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632210
|
+
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632211
|
+
useTitlesAsName: settings.titleAsSchemaName,
|
|
632212
|
+
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632213
|
+
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632214
|
+
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632215
|
+
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632216
|
+
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632217
|
+
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632218
|
+
// OpenAPI-specific settings
|
|
632219
|
+
respectReadonlySchemas: settings.respectReadonlySchemas,
|
|
632220
|
+
onlyIncludeReferencedSchemas: settings.onlyIncludeReferencedSchemas,
|
|
632221
|
+
inlinePathParameters: settings.inlinePathParameters,
|
|
632222
|
+
shouldUseUndiscriminatedUnionsWithLiterals: settings.preferUndiscriminatedUnionsWithLiterals,
|
|
632223
|
+
objectQueryParameters: settings.objectQueryParameters,
|
|
632224
|
+
respectForwardCompatibleEnums: settings.respectForwardCompatibleEnums,
|
|
632225
|
+
useBytesForBinaryResponse: settings.useBytesForBinaryResponse,
|
|
632226
|
+
defaultFormParameterEncoding: settings.defaultFormParameterEncoding,
|
|
632227
|
+
filter: settings.filter,
|
|
632228
|
+
exampleGeneration: this.adaptExampleGeneration(settings.exampleGeneration),
|
|
632229
|
+
additionalPropertiesDefaultsTo: settings.additionalPropertiesDefaultsTo,
|
|
632230
|
+
typeDatesAsStrings: settings.typeDatesAsStrings,
|
|
632231
|
+
preserveSingleSchemaOneOf: settings.preserveSingleSchemaOneof,
|
|
632232
|
+
inlineAllOfSchemas: settings.inlineAllOfSchemas,
|
|
632233
|
+
resolveAliases: settings.resolveAliases,
|
|
632234
|
+
groupMultiApiEnvironments: settings.groupMultiApiEnvironments,
|
|
632235
|
+
defaultIntegerFormat: this.adaptDefaultIntegerFormat(settings.defaultIntegerFormat),
|
|
632236
|
+
coerceConstsTo: settings.coerceConstsTo
|
|
632237
|
+
};
|
|
632238
|
+
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632239
|
+
return hasSettings ? result : void 0;
|
|
632240
|
+
}
|
|
632241
|
+
adaptAsyncApiSettings(settings) {
|
|
632242
|
+
if (settings == null) {
|
|
632243
|
+
return void 0;
|
|
632244
|
+
}
|
|
632245
|
+
const result = {
|
|
632246
|
+
// Base API settings (shared)
|
|
632247
|
+
respectNullableSchemas: settings.respectNullableSchemas,
|
|
632248
|
+
wrapReferencesToNullableInOptional: settings.wrapReferencesToNullableInOptional,
|
|
632249
|
+
coerceOptionalSchemasToNullable: settings.coerceOptionalSchemasToNullable,
|
|
632250
|
+
useTitlesAsName: settings.titleAsSchemaName,
|
|
632251
|
+
coerceEnumsToLiterals: settings.coerceEnumsToLiterals,
|
|
632252
|
+
optionalAdditionalProperties: settings.optionalAdditionalProperties,
|
|
632253
|
+
shouldUseIdiomaticRequestNames: settings.idiomaticRequestNames,
|
|
632254
|
+
groupEnvironmentsByHost: settings.groupEnvironmentsByHost,
|
|
632255
|
+
removeDiscriminantsFromSchemas: this.adaptRemoveDiscriminantsFromSchemas(settings.removeDiscriminantsFromSchemas),
|
|
632256
|
+
pathParameterOrder: this.adaptPathParameterOrder(settings.pathParameterOrder),
|
|
632257
|
+
// AsyncAPI-specific settings
|
|
632258
|
+
asyncApiNaming: settings.messageNaming,
|
|
632259
|
+
coerceConstsTo: settings.coerceConstsTo
|
|
632260
|
+
};
|
|
632261
|
+
const hasSettings = Object.values(result).some((v23) => v23 != null);
|
|
632262
|
+
return hasSettings ? result : void 0;
|
|
632263
|
+
}
|
|
632264
|
+
adaptRemoveDiscriminantsFromSchemas(value) {
|
|
632265
|
+
if (value == null) {
|
|
632266
|
+
return void 0;
|
|
632267
|
+
}
|
|
632268
|
+
switch (value) {
|
|
632269
|
+
case "always":
|
|
632270
|
+
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Always;
|
|
632271
|
+
case "never":
|
|
632272
|
+
return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
|
|
632273
|
+
default:
|
|
632274
|
+
return void 0;
|
|
632275
|
+
}
|
|
632276
|
+
}
|
|
632277
|
+
adaptPathParameterOrder(value) {
|
|
632278
|
+
if (value == null) {
|
|
632279
|
+
return void 0;
|
|
632280
|
+
}
|
|
632281
|
+
switch (value) {
|
|
632282
|
+
case "urlOrder":
|
|
632283
|
+
return generators_yml_exports.PathParameterOrder.UrlOrder;
|
|
632284
|
+
case "specOrder":
|
|
632285
|
+
return generators_yml_exports.PathParameterOrder.SpecOrder;
|
|
632286
|
+
default:
|
|
632287
|
+
return void 0;
|
|
632288
|
+
}
|
|
632289
|
+
}
|
|
632290
|
+
adaptDefaultIntegerFormat(value) {
|
|
632291
|
+
if (value == null) {
|
|
632292
|
+
return void 0;
|
|
632293
|
+
}
|
|
632294
|
+
switch (value) {
|
|
632295
|
+
case "int32":
|
|
632296
|
+
return generators_yml_exports.DefaultIntegerFormat.Int32;
|
|
632297
|
+
case "int64":
|
|
632298
|
+
return generators_yml_exports.DefaultIntegerFormat.Int64;
|
|
632299
|
+
case "uint32":
|
|
632300
|
+
return generators_yml_exports.DefaultIntegerFormat.Uint32;
|
|
632301
|
+
case "uint64":
|
|
632302
|
+
return generators_yml_exports.DefaultIntegerFormat.Uint64;
|
|
632303
|
+
default:
|
|
632304
|
+
return void 0;
|
|
632305
|
+
}
|
|
632306
|
+
}
|
|
632307
|
+
adaptExampleGeneration(value) {
|
|
632308
|
+
if (value == null) {
|
|
632309
|
+
return void 0;
|
|
632310
|
+
}
|
|
632311
|
+
const result = {};
|
|
632312
|
+
if (value.request != null) {
|
|
632313
|
+
result.request = { "max-depth": value.request.maxDepth };
|
|
632314
|
+
}
|
|
632315
|
+
if (value.response != null) {
|
|
632316
|
+
result.response = { "max-depth": value.response.maxDepth };
|
|
632317
|
+
}
|
|
632318
|
+
return result;
|
|
632319
|
+
}
|
|
632320
|
+
};
|
|
632321
|
+
|
|
632322
|
+
// ../cli-v2/lib/api/config/ConjureSpec.js
|
|
632323
|
+
function isConjureSpec(spec) {
|
|
632324
|
+
return "conjure" in spec;
|
|
632325
|
+
}
|
|
632326
|
+
|
|
632327
|
+
// ../cli-v2/lib/api/validator/ApiDefinitionValidator.js
|
|
632328
|
+
var ApiDefinitionValidator = class {
|
|
632329
|
+
context;
|
|
632330
|
+
taskContext;
|
|
632331
|
+
cliVersion;
|
|
632332
|
+
constructor(config5) {
|
|
632333
|
+
this.context = config5.context;
|
|
632334
|
+
this.taskContext = new TaskContextAdapter({ context: this.context, task: config5.task });
|
|
632335
|
+
this.cliVersion = config5.cliVersion;
|
|
632336
|
+
}
|
|
632337
|
+
/**
|
|
632338
|
+
* Validate an ApiDefinition.
|
|
632339
|
+
*
|
|
632340
|
+
* Runs both Fern definition validation and OSS workspace validation
|
|
632341
|
+
* to ensure the API definition is valid before generation.
|
|
632342
|
+
*/
|
|
632343
|
+
async validate(definition3) {
|
|
632344
|
+
const startTime = performance.now();
|
|
632345
|
+
const violations = [];
|
|
632346
|
+
const fernSpec = definition3.specs.find(isFernSpec);
|
|
632347
|
+
if (fernSpec != null) {
|
|
632348
|
+
const fernViolations = await this.validateFernSpec(fernSpec);
|
|
632349
|
+
violations.push(...fernViolations);
|
|
632350
|
+
return {
|
|
632351
|
+
violations,
|
|
632352
|
+
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632353
|
+
workspaceRoot: fernSpec.fern,
|
|
632354
|
+
elapsedMillis: performance.now() - startTime
|
|
632355
|
+
};
|
|
632356
|
+
}
|
|
632357
|
+
const conjureSpec = definition3.specs.find(isConjureSpec);
|
|
632358
|
+
if (conjureSpec != null) {
|
|
632359
|
+
return {
|
|
632360
|
+
violations: [],
|
|
632361
|
+
hasErrors: false,
|
|
632362
|
+
workspaceRoot: this.context.cwd,
|
|
632363
|
+
elapsedMillis: performance.now() - startTime
|
|
632364
|
+
};
|
|
632365
|
+
}
|
|
632366
|
+
const ossViolations = await this.validateOssSpecs(definition3.specs);
|
|
632367
|
+
violations.push(...ossViolations);
|
|
632368
|
+
return {
|
|
632369
|
+
violations,
|
|
632370
|
+
hasErrors: violations.some((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632371
|
+
workspaceRoot: this.context.cwd,
|
|
632372
|
+
elapsedMillis: performance.now() - startTime
|
|
632373
|
+
};
|
|
632374
|
+
}
|
|
632375
|
+
async validateFernSpec(spec) {
|
|
632376
|
+
const violations = [];
|
|
632377
|
+
const lazyWorkspace = new LazyFernWorkspace({
|
|
632378
|
+
absoluteFilePath: dirname6(spec.fern),
|
|
632379
|
+
context: this.taskContext,
|
|
632380
|
+
cliVersion: this.cliVersion,
|
|
632381
|
+
generatorsConfiguration: void 0,
|
|
632382
|
+
workspaceName: void 0,
|
|
632383
|
+
changelog: void 0
|
|
632384
|
+
});
|
|
632385
|
+
const fernWorkspace = await lazyWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632386
|
+
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632387
|
+
violations.push(...fernViolations);
|
|
632388
|
+
return violations;
|
|
632389
|
+
}
|
|
632390
|
+
async validateOssSpecs(specs) {
|
|
632391
|
+
const violations = [];
|
|
632392
|
+
const ossSpecs = specs.filter((spec) => !isFernSpec(spec) && !isConjureSpec(spec));
|
|
632393
|
+
if (ossSpecs.length === 0) {
|
|
632394
|
+
return violations;
|
|
632395
|
+
}
|
|
632396
|
+
const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
|
|
632397
|
+
const v1Specs = specAdapter.convertAll(ossSpecs);
|
|
632398
|
+
const filteredSpecs = v1Specs.filter((spec) => {
|
|
632399
|
+
if (spec.type === "openrpc") {
|
|
632400
|
+
return false;
|
|
632401
|
+
}
|
|
632402
|
+
if (spec.type === "protobuf" && !spec.fromOpenAPI) {
|
|
632403
|
+
return false;
|
|
632404
|
+
}
|
|
632405
|
+
return true;
|
|
632406
|
+
});
|
|
632407
|
+
const allSpecs = v1Specs.filter((spec) => {
|
|
632408
|
+
if (spec.type === "protobuf" && spec.fromOpenAPI) {
|
|
632409
|
+
return false;
|
|
632410
|
+
}
|
|
632411
|
+
return true;
|
|
632412
|
+
});
|
|
632413
|
+
const ossWorkspace = new OSSWorkspace({
|
|
632414
|
+
specs: filteredSpecs,
|
|
632415
|
+
allSpecs,
|
|
632416
|
+
absoluteFilePath: this.context.cwd,
|
|
632417
|
+
cliVersion: this.cliVersion,
|
|
632418
|
+
changelog: void 0,
|
|
632419
|
+
generatorsConfiguration: void 0,
|
|
632420
|
+
workspaceName: void 0
|
|
632421
|
+
});
|
|
632422
|
+
const fernWorkspace = await ossWorkspace.toFernWorkspace({ context: this.taskContext });
|
|
632423
|
+
const fernViolations = validateFernWorkspace(fernWorkspace, this.context.stderr);
|
|
632424
|
+
violations.push(...fernViolations);
|
|
632425
|
+
const ossViolations = await validateOSSWorkspace(ossWorkspace, this.taskContext);
|
|
632426
|
+
violations.push(...ossViolations);
|
|
632427
|
+
return violations;
|
|
632428
|
+
}
|
|
632429
|
+
};
|
|
632430
|
+
|
|
632431
|
+
// ../cli-v2/lib/api/checker/ApiChecker.js
|
|
632432
|
+
var ApiChecker = class {
|
|
632433
|
+
context;
|
|
632434
|
+
cliVersion;
|
|
632435
|
+
task;
|
|
632436
|
+
constructor(config5) {
|
|
632437
|
+
this.context = config5.context;
|
|
632438
|
+
this.cliVersion = config5.cliVersion;
|
|
632439
|
+
this.task = config5.task;
|
|
632440
|
+
}
|
|
632441
|
+
/**
|
|
632442
|
+
* Check APIs in the workspace and display results.
|
|
632443
|
+
*
|
|
632444
|
+
* @param strict - If true, display all warnings and treat them as errors. If false,
|
|
632445
|
+
* only show errors but still report warning count in summary.
|
|
632446
|
+
*/
|
|
632447
|
+
async check({ workspace, apiNames, strict = false }) {
|
|
632448
|
+
const startTime = performance.now();
|
|
632449
|
+
const validApis = /* @__PURE__ */ new Set();
|
|
632450
|
+
const invalidApis = /* @__PURE__ */ new Set();
|
|
632451
|
+
const apisToCheck = apiNames ?? Object.keys(workspace.apis);
|
|
632452
|
+
if (apisToCheck.length === 0) {
|
|
632453
|
+
return {
|
|
632454
|
+
validApis,
|
|
632455
|
+
invalidApis,
|
|
632456
|
+
violations: [],
|
|
632457
|
+
errorCount: 0,
|
|
632458
|
+
warningCount: 0,
|
|
632459
|
+
elapsedMillis: performance.now() - startTime
|
|
632460
|
+
};
|
|
632461
|
+
}
|
|
632462
|
+
const validator = new ApiDefinitionValidator({
|
|
632463
|
+
context: this.context,
|
|
632464
|
+
cliVersion: this.cliVersion,
|
|
632465
|
+
task: this.task
|
|
632466
|
+
});
|
|
632467
|
+
const allViolations = [];
|
|
632468
|
+
for (const apiName of apisToCheck) {
|
|
632469
|
+
const apiDefinition = workspace.apis[apiName];
|
|
632470
|
+
if (apiDefinition == null) {
|
|
632471
|
+
invalidApis.add(apiName);
|
|
632472
|
+
continue;
|
|
632473
|
+
}
|
|
632474
|
+
const result = await validator.validate(apiDefinition);
|
|
632475
|
+
if (result.hasErrors) {
|
|
632476
|
+
invalidApis.add(apiName);
|
|
632477
|
+
} else {
|
|
632478
|
+
validApis.add(apiName);
|
|
632479
|
+
}
|
|
632480
|
+
const apiSpecType = apiDefinition.specs.some(isFernSpec) ? "fern" : "openapi";
|
|
632481
|
+
const resolvedViolations = this.resolveViolationPaths({
|
|
632482
|
+
workspaceRoot: result.workspaceRoot,
|
|
632483
|
+
apiName,
|
|
632484
|
+
apiSpecType,
|
|
632485
|
+
apiDefinition,
|
|
632486
|
+
violations: result.violations
|
|
632487
|
+
});
|
|
632488
|
+
allViolations.push(...resolvedViolations);
|
|
632489
|
+
}
|
|
632490
|
+
const dedupedViolations = this.deduplicateViolations(allViolations);
|
|
632491
|
+
return {
|
|
632492
|
+
...this.countViolations(dedupedViolations),
|
|
632493
|
+
validApis,
|
|
632494
|
+
invalidApis,
|
|
632495
|
+
violations: strict ? dedupedViolations : dedupedViolations.filter((v23) => v23.severity === "fatal" || v23.severity === "error"),
|
|
632496
|
+
elapsedMillis: performance.now() - startTime
|
|
632497
|
+
};
|
|
632498
|
+
}
|
|
632499
|
+
resolveViolationPaths({ violations, workspaceRoot, apiName, apiSpecType, apiDefinition }) {
|
|
632500
|
+
return violations.map((violation) => {
|
|
632501
|
+
const message = apiSpecType === "fern" ? violation.message : this.formatOssMessage(violation);
|
|
632502
|
+
return {
|
|
632503
|
+
...violation,
|
|
632504
|
+
message,
|
|
632505
|
+
displayRelativeFilepath: this.resolveDisplayPath({
|
|
632506
|
+
workspaceRoot,
|
|
632507
|
+
apiDefinition,
|
|
632508
|
+
apiSpecType,
|
|
632509
|
+
violation
|
|
632510
|
+
}),
|
|
632511
|
+
apiSpecType,
|
|
632512
|
+
apiName,
|
|
632513
|
+
// We don't actually surface valuable line/column information yet, but
|
|
632514
|
+
// this at least points to the correct file.
|
|
632515
|
+
line: 1,
|
|
632516
|
+
column: 1
|
|
632517
|
+
};
|
|
632518
|
+
});
|
|
632519
|
+
}
|
|
632520
|
+
/**
|
|
632521
|
+
* Format a violation message for non-Fern (OSS) specs.
|
|
632522
|
+
*
|
|
632523
|
+
* Prepends a human-readable node path so users can locate the endpoint,
|
|
632524
|
+
* then strips synthetic file paths from the body of the message.
|
|
632525
|
+
*/
|
|
632526
|
+
formatOssMessage(violation) {
|
|
632527
|
+
const strippedMessage = this.stripSyntheticFilePaths(violation.message);
|
|
632528
|
+
const nodePathPrefix = this.formatNodePath(violation.nodePath);
|
|
632529
|
+
if (nodePathPrefix.length === 0) {
|
|
632530
|
+
return strippedMessage;
|
|
632531
|
+
}
|
|
632532
|
+
return `${nodePathPrefix} - ${strippedMessage}`;
|
|
632533
|
+
}
|
|
632534
|
+
/**
|
|
632535
|
+
* Formats a NodePath into a readable string like "endpoints -> getUser".
|
|
632536
|
+
*
|
|
632537
|
+
* Skips the leading "service" segment since it's implicit.
|
|
632538
|
+
*/
|
|
632539
|
+
formatNodePath(nodePath) {
|
|
632540
|
+
const parts = [];
|
|
632541
|
+
for (const item of nodePath) {
|
|
632542
|
+
if (typeof item === "string") {
|
|
632543
|
+
parts.push(item);
|
|
632544
|
+
} else {
|
|
632545
|
+
parts.push(item.key);
|
|
632546
|
+
}
|
|
632547
|
+
}
|
|
632548
|
+
if (parts[0] === "service") {
|
|
632549
|
+
parts.shift();
|
|
632550
|
+
}
|
|
632551
|
+
return parts.join(" -> ");
|
|
632552
|
+
}
|
|
632553
|
+
resolveDisplayPath({ workspaceRoot, apiDefinition, apiSpecType, violation }) {
|
|
632554
|
+
if (apiSpecType === "fern") {
|
|
632555
|
+
const absolutePath = join8(workspaceRoot, RelativeFilePath2.of(violation.relativeFilepath));
|
|
632556
|
+
return relativize(this.context.cwd, absolutePath);
|
|
632557
|
+
}
|
|
632558
|
+
return this.resolveOssDisplayPath(apiDefinition, violation);
|
|
632559
|
+
}
|
|
632560
|
+
resolveOssDisplayPath(apiDefinition, violation) {
|
|
632561
|
+
const ossSpecs = apiDefinition.specs.filter((s11) => isOpenApiSpec(s11) || isAsyncApiSpec(s11));
|
|
632562
|
+
if (ossSpecs.length === 0) {
|
|
632563
|
+
return violation.relativeFilepath;
|
|
632564
|
+
}
|
|
632565
|
+
if (ossSpecs.length > 1) {
|
|
632566
|
+
for (const spec of ossSpecs) {
|
|
632567
|
+
const namespace = isOpenApiSpec(spec) ? spec.namespace : spec.namespace;
|
|
632568
|
+
if (namespace != null && violation.relativeFilepath.startsWith(namespace)) {
|
|
632569
|
+
const filePath2 = isOpenApiSpec(spec) ? spec.openapi : spec.asyncapi;
|
|
632570
|
+
return relativize(this.context.cwd, filePath2);
|
|
632571
|
+
}
|
|
632572
|
+
}
|
|
632573
|
+
}
|
|
632574
|
+
const firstSpec = ossSpecs[0];
|
|
632575
|
+
if (firstSpec == null) {
|
|
632576
|
+
return violation.relativeFilepath;
|
|
632577
|
+
}
|
|
632578
|
+
const filePath = isOpenApiSpec(firstSpec) ? firstSpec.openapi : firstSpec.asyncapi;
|
|
632579
|
+
return relativize(this.context.cwd, filePath);
|
|
632580
|
+
}
|
|
632581
|
+
deduplicateViolations(violations) {
|
|
632582
|
+
const seen = /* @__PURE__ */ new Set();
|
|
632583
|
+
return violations.filter((v23) => {
|
|
632584
|
+
const key2 = `${v23.apiName}|${v23.displayRelativeFilepath}|${v23.severity}|${JSON.stringify(v23.nodePath)}|${v23.message}`;
|
|
632585
|
+
if (seen.has(key2)) {
|
|
632586
|
+
return false;
|
|
632587
|
+
}
|
|
632588
|
+
seen.add(key2);
|
|
632589
|
+
return true;
|
|
632590
|
+
});
|
|
632591
|
+
}
|
|
632592
|
+
/**
|
|
632593
|
+
* Strip synthetic file path references from violation messages for non-Fern specs.
|
|
632594
|
+
*
|
|
632595
|
+
* The validator produces messages like:
|
|
632596
|
+
* "- pet.yml -> getPetById /pet/{petId}"
|
|
632597
|
+
* For non-Fern specs these file names are synthetic (they don't exist on disk),
|
|
632598
|
+
* so we strip them to produce:
|
|
632599
|
+
* "- getPetById /pet/{petId}"
|
|
632600
|
+
*/
|
|
632601
|
+
stripSyntheticFilePaths(message) {
|
|
632602
|
+
return message.replace(/^(\s*- )\S+\.[a-zA-Z]+ -> /gm, "$1");
|
|
632603
|
+
}
|
|
632604
|
+
countViolations(violations) {
|
|
632605
|
+
let errorCount = 0;
|
|
632606
|
+
let warningCount = 0;
|
|
632607
|
+
for (const violation of violations) {
|
|
632608
|
+
switch (violation.severity) {
|
|
632609
|
+
case "fatal":
|
|
632610
|
+
case "error":
|
|
632611
|
+
errorCount++;
|
|
632612
|
+
break;
|
|
632613
|
+
case "warning":
|
|
632614
|
+
warningCount++;
|
|
632615
|
+
break;
|
|
632616
|
+
default:
|
|
632617
|
+
assertNever(violation.severity);
|
|
632618
|
+
}
|
|
632619
|
+
}
|
|
632620
|
+
return { errorCount, warningCount };
|
|
632621
|
+
}
|
|
632622
|
+
};
|
|
632623
|
+
|
|
632519
632624
|
// ../cli-v2/lib/commands/_internal/command.js
|
|
632520
632625
|
function command2(cli, name2, description, handler3, builder) {
|
|
632521
632626
|
cli.command(name2, description, (yargs) => {
|
|
@@ -632559,7 +632664,8 @@ var CheckCommand = class {
|
|
|
632559
632664
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
632560
632665
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
632561
632666
|
throw new CliError({
|
|
632562
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
632667
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
|
|
632668
|
+
code: CliError.Code.ConfigError
|
|
632563
632669
|
});
|
|
632564
632670
|
}
|
|
632565
632671
|
const checker = new ApiChecker({ context: context3, cliVersion: workspace.cliVersion });
|
|
@@ -632573,7 +632679,7 @@ var CheckCommand = class {
|
|
|
632573
632679
|
const response = this.buildJsonResponse({ apiCheckResult: result, hasErrors });
|
|
632574
632680
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
632575
632681
|
if (hasErrors) {
|
|
632576
|
-
throw CliError.
|
|
632682
|
+
throw CliError.validationError();
|
|
632577
632683
|
}
|
|
632578
632684
|
return;
|
|
632579
632685
|
}
|
|
@@ -632585,7 +632691,7 @@ var CheckCommand = class {
|
|
|
632585
632691
|
}
|
|
632586
632692
|
}
|
|
632587
632693
|
if (hasErrors) {
|
|
632588
|
-
throw CliError.
|
|
632694
|
+
throw CliError.validationError();
|
|
632589
632695
|
}
|
|
632590
632696
|
if (result.warningCount > 0) {
|
|
632591
632697
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -759260,7 +759366,8 @@ var CompileCommand = class {
|
|
|
759260
759366
|
if (definition3 == null) {
|
|
759261
759367
|
const available2 = apiNames.join(", ");
|
|
759262
759368
|
throw new CliError({
|
|
759263
|
-
message: `API '${args.api}' not found. Available APIs: ${available2}
|
|
759369
|
+
message: `API '${args.api}' not found. Available APIs: ${available2}`,
|
|
759370
|
+
code: CliError.Code.ConfigError
|
|
759264
759371
|
});
|
|
759265
759372
|
}
|
|
759266
759373
|
return { apiName: args.api, definition: definition3 };
|
|
@@ -759269,20 +759376,23 @@ var CompileCommand = class {
|
|
|
759269
759376
|
const apiName = apiNames[0];
|
|
759270
759377
|
if (apiName == null) {
|
|
759271
759378
|
throw new CliError({
|
|
759272
|
-
message: "Internal error; no APIs found in workspace"
|
|
759379
|
+
message: "Internal error; no APIs found in workspace",
|
|
759380
|
+
code: CliError.Code.InternalError
|
|
759273
759381
|
});
|
|
759274
759382
|
}
|
|
759275
759383
|
const definition3 = workspace.apis[apiName];
|
|
759276
759384
|
if (definition3 == null) {
|
|
759277
759385
|
throw new CliError({
|
|
759278
|
-
message: `Internal error; API '${apiName}' not found in workspace
|
|
759386
|
+
message: `Internal error; API '${apiName}' not found in workspace`,
|
|
759387
|
+
code: CliError.Code.InternalError
|
|
759279
759388
|
});
|
|
759280
759389
|
}
|
|
759281
759390
|
return { apiName, definition: definition3 };
|
|
759282
759391
|
}
|
|
759283
759392
|
const available = apiNames.join(", ");
|
|
759284
759393
|
throw new CliError({
|
|
759285
|
-
message: `Multiple APIs found: ${available}. Use --api to select one
|
|
759394
|
+
message: `Multiple APIs found: ${available}. Use --api to select one.`,
|
|
759395
|
+
code: CliError.Code.ConfigError
|
|
759286
759396
|
});
|
|
759287
759397
|
}
|
|
759288
759398
|
async checkOrThrow({ context: context3, workspace, apiName }) {
|
|
@@ -759292,7 +759402,7 @@ var CompileCommand = class {
|
|
|
759292
759402
|
for (const violation of result.violations) {
|
|
759293
759403
|
context3.stderr.error(`${violation.displayRelativeFilepath}:${violation.line}:${violation.column}: ${violation.message}`);
|
|
759294
759404
|
}
|
|
759295
|
-
throw CliError.
|
|
759405
|
+
throw CliError.validationError(`API '${apiName}' has ${result.violations.length} validation errors`);
|
|
759296
759406
|
}
|
|
759297
759407
|
}
|
|
759298
759408
|
async writeOutput(context3, args, object21) {
|
|
@@ -759384,7 +759494,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759384
759494
|
const doc = document4.toJS();
|
|
759385
759495
|
if (doc == null || typeof doc !== "object") {
|
|
759386
759496
|
throw new CliError({
|
|
759387
|
-
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file
|
|
759497
|
+
message: `Invalid ${FERN_YML_FILENAME}: expected a YAML object; run 'fern init' to initialize a new file.`,
|
|
759498
|
+
code: CliError.Code.ParseError
|
|
759388
759499
|
});
|
|
759389
759500
|
}
|
|
759390
759501
|
return new _FernYmlEditor(document4, config5.fernYmlPath);
|
|
@@ -759586,7 +759697,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759586
759697
|
const resolvedPath = join8(dirname6(this.rootFilePath), RelativeFilePath2.of(refPath));
|
|
759587
759698
|
if (!await doesPathExist(resolvedPath)) {
|
|
759588
759699
|
throw new CliError({
|
|
759589
|
-
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist
|
|
759700
|
+
message: `Referenced file '${refPath}' in ${FERN_YML_FILENAME} does not exist.`,
|
|
759701
|
+
code: CliError.Code.ConfigError
|
|
759590
759702
|
});
|
|
759591
759703
|
}
|
|
759592
759704
|
const refContent = await (0, import_promises50.readFile)(resolvedPath, "utf-8");
|
|
@@ -759613,7 +759725,8 @@ var FernYmlEditor = class _FernYmlEditor {
|
|
|
759613
759725
|
const existing = section.document.getIn([...section.basePath, name2]);
|
|
759614
759726
|
if (existing == null) {
|
|
759615
759727
|
throw new CliError({
|
|
759616
|
-
message: `Target '${name2}' not found in SDK configuration
|
|
759728
|
+
message: `Target '${name2}' not found in SDK configuration.`,
|
|
759729
|
+
code: CliError.Code.ConfigError
|
|
759617
759730
|
});
|
|
759618
759731
|
}
|
|
759619
759732
|
}
|
|
@@ -759941,9 +760054,9 @@ async function loadSpec(filepath) {
|
|
|
759941
760054
|
contents = await (0, import_promises51.readFile)(filepath, "utf8");
|
|
759942
760055
|
} catch (error50) {
|
|
759943
760056
|
if (isEnoentError(error50)) {
|
|
759944
|
-
throw new CliError({ message: `File does not exist: ${filepath}
|
|
760057
|
+
throw new CliError({ message: `File does not exist: ${filepath}`, code: CliError.Code.ConfigError });
|
|
759945
760058
|
}
|
|
759946
|
-
throw new CliError({ message: `Failed to read file: ${filepath}
|
|
760059
|
+
throw new CliError({ message: `Failed to read file: ${filepath}`, code: CliError.Code.ParseError });
|
|
759947
760060
|
}
|
|
759948
760061
|
return parseSpec(contents, filepath);
|
|
759949
760062
|
}
|
|
@@ -759954,7 +760067,10 @@ function parseSpec(contents, filepath) {
|
|
|
759954
760067
|
try {
|
|
759955
760068
|
return jsYaml.load(contents);
|
|
759956
760069
|
} catch {
|
|
759957
|
-
throw new CliError({
|
|
760070
|
+
throw new CliError({
|
|
760071
|
+
message: `Failed to parse file as JSON or YAML: ${filepath}`,
|
|
760072
|
+
code: CliError.Code.ParseError
|
|
760073
|
+
});
|
|
759958
760074
|
}
|
|
759959
760075
|
}
|
|
759960
760076
|
}
|
|
@@ -759973,7 +760089,7 @@ var MergeCommand = class {
|
|
|
759973
760089
|
async handle(context3, args) {
|
|
759974
760090
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
759975
760091
|
if (Object.keys(workspace.apis).length === 0) {
|
|
759976
|
-
throw new CliError({ message: "No APIs found in workspace." });
|
|
760092
|
+
throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
|
|
759977
760093
|
}
|
|
759978
760094
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
759979
760095
|
if (entries22.length === 0) {
|
|
@@ -759985,7 +760101,8 @@ var MergeCommand = class {
|
|
|
759985
760101
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
759986
760102
|
if (fernYmlPath == null) {
|
|
759987
760103
|
throw new CliError({
|
|
759988
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760104
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
760105
|
+
code: CliError.Code.ConfigError
|
|
759989
760106
|
});
|
|
759990
760107
|
}
|
|
759991
760108
|
editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760120,7 +760237,7 @@ var SplitCommand = class {
|
|
|
760120
760237
|
async handle(context3, args) {
|
|
760121
760238
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
760122
760239
|
if (Object.keys(workspace.apis).length === 0) {
|
|
760123
|
-
throw new CliError({ message: "No APIs found in workspace." });
|
|
760240
|
+
throw new CliError({ message: "No APIs found in workspace.", code: CliError.Code.ConfigError });
|
|
760124
760241
|
}
|
|
760125
760242
|
const entries22 = filterSpecs(workspace, { api: args.api });
|
|
760126
760243
|
if (entries22.length === 0) {
|
|
@@ -760131,7 +760248,8 @@ var SplitCommand = class {
|
|
|
760131
760248
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
760132
760249
|
if (fernYmlPath == null) {
|
|
760133
760250
|
throw new CliError({
|
|
760134
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
760251
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
760252
|
+
code: CliError.Code.ConfigError
|
|
760135
760253
|
});
|
|
760136
760254
|
}
|
|
760137
760255
|
const editor = await FernYmlEditor.load({ fernYmlPath });
|
|
@@ -760252,7 +760370,8 @@ var SplitCommand = class {
|
|
|
760252
760370
|
const detail = extractErrorMessage(error50);
|
|
760253
760371
|
throw new CliError({
|
|
760254
760372
|
message: `Failed to get file from git HEAD: ${absolutePath}. Is the file tracked by git and has at least one commit?
|
|
760255
|
-
Cause: ${detail}
|
|
760373
|
+
Cause: ${detail}`,
|
|
760374
|
+
code: CliError.Code.ParseError
|
|
760256
760375
|
});
|
|
760257
760376
|
}
|
|
760258
760377
|
}
|
|
@@ -760267,7 +760386,10 @@ var SplitCommand = class {
|
|
|
760267
760386
|
function resolvePathOrThrow(context3, outputPath) {
|
|
760268
760387
|
const resolved = context3.resolveOutputFilePath(outputPath);
|
|
760269
760388
|
if (resolved == null) {
|
|
760270
|
-
throw new CliError({
|
|
760389
|
+
throw new CliError({
|
|
760390
|
+
message: `Could not resolve output path: ${outputPath}`,
|
|
760391
|
+
code: CliError.Code.ConfigError
|
|
760392
|
+
});
|
|
760271
760393
|
}
|
|
760272
760394
|
return resolved;
|
|
760273
760395
|
}
|
|
@@ -760311,7 +760433,7 @@ var LoginCommand = class {
|
|
|
760311
760433
|
context3.stdout.info("Opening browser to log in to Fern...");
|
|
760312
760434
|
context3.stdout.info(source_default.dim(" If the browser doesn't open, try: fern auth login --device-code"));
|
|
760313
760435
|
}
|
|
760314
|
-
const taskContext = new TaskContextAdapter({ context: context3, logLevel:
|
|
760436
|
+
const taskContext = new TaskContextAdapter({ context: context3, logLevel: LogLevel.Info });
|
|
760315
760437
|
const tokenResponse = await getTokenFromAuth0(taskContext, {
|
|
760316
760438
|
useDeviceCodeFlow,
|
|
760317
760439
|
forceReauth: true
|
|
@@ -760323,12 +760445,12 @@ var LoginCommand = class {
|
|
|
760323
760445
|
const payload = await verifyAndDecodeJwt(idToken);
|
|
760324
760446
|
if (payload == null) {
|
|
760325
760447
|
context3.stdout.error(`${Icons.error} Internal error; could not verify ID token`);
|
|
760326
|
-
throw CliError.
|
|
760448
|
+
throw CliError.internalError();
|
|
760327
760449
|
}
|
|
760328
760450
|
const email3 = payload.email;
|
|
760329
760451
|
if (email3 == null) {
|
|
760330
760452
|
context3.stdout.error(`${Icons.error} Internal error; ID token does not contain email claim`);
|
|
760331
|
-
throw CliError.
|
|
760453
|
+
throw CliError.internalError();
|
|
760332
760454
|
}
|
|
760333
760455
|
const { isNew, totalAccounts } = await context3.tokenService.login(email3, accessToken);
|
|
760334
760456
|
if (isNew) {
|
|
@@ -760394,7 +760516,7 @@ var LogoutCommand = class {
|
|
|
760394
760516
|
context3.stdout.info("");
|
|
760395
760517
|
if (!context3.isTTY) {
|
|
760396
760518
|
context3.stdout.error(`${Icons.error} Use --force to skip confirmation in non-interactive mode`);
|
|
760397
|
-
throw CliError.
|
|
760519
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
760398
760520
|
}
|
|
760399
760521
|
const { confirmed } = await lib_default4.prompt([
|
|
760400
760522
|
{
|
|
@@ -760415,7 +760537,9 @@ var LogoutCommand = class {
|
|
|
760415
760537
|
const { removed, newActive } = await context3.tokenService.logout(user);
|
|
760416
760538
|
if (!removed) {
|
|
760417
760539
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760418
|
-
throw CliError
|
|
760540
|
+
throw new CliError({
|
|
760541
|
+
code: CliError.Code.EnvironmentError
|
|
760542
|
+
});
|
|
760419
760543
|
}
|
|
760420
760544
|
context3.stdout.info(`${Icons.success} Logged out of ${source_default.bold(user)}`);
|
|
760421
760545
|
if (newActive != null) {
|
|
@@ -760425,7 +760549,9 @@ var LogoutCommand = class {
|
|
|
760425
760549
|
async handleLogoutInteractive(context3, accounts) {
|
|
760426
760550
|
if (!context3.isTTY) {
|
|
760427
760551
|
context3.stdout.error(`${Icons.error} Multiple accounts found. Use --user or --all in non-interactive mode.`);
|
|
760428
|
-
throw CliError
|
|
760552
|
+
throw new CliError({
|
|
760553
|
+
code: CliError.Code.EnvironmentError
|
|
760554
|
+
});
|
|
760429
760555
|
}
|
|
760430
760556
|
const choices = accounts.map((account) => ({
|
|
760431
760557
|
name: account.isActive ? `${account.user} ${source_default.dim("(active)")}` : account.user,
|
|
@@ -760581,13 +760707,15 @@ var SwitchCommand = class {
|
|
|
760581
760707
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760582
760708
|
context3.stdout.info("");
|
|
760583
760709
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760584
|
-
throw CliError
|
|
760710
|
+
throw new CliError({
|
|
760711
|
+
code: CliError.Code.ConfigError
|
|
760712
|
+
});
|
|
760585
760713
|
}
|
|
760586
760714
|
if (accounts.length === 1) {
|
|
760587
760715
|
const account = accounts[0];
|
|
760588
760716
|
if (account == null) {
|
|
760589
760717
|
context3.stdout.error(`${Icons.error} Internal error; no accounts found`);
|
|
760590
|
-
throw CliError.
|
|
760718
|
+
throw CliError.internalError();
|
|
760591
760719
|
}
|
|
760592
760720
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You only have one account logged in: ${source_default.bold(account.user)}`);
|
|
760593
760721
|
context3.stdout.info("");
|
|
@@ -760610,7 +760738,9 @@ var SwitchCommand = class {
|
|
|
760610
760738
|
async handleInteractiveSwitch(context3, accounts) {
|
|
760611
760739
|
if (!context3.isTTY) {
|
|
760612
760740
|
context3.stdout.error(`${Icons.error} Use --user to specify account in non-interactive mode`);
|
|
760613
|
-
throw CliError
|
|
760741
|
+
throw new CliError({
|
|
760742
|
+
code: CliError.Code.EnvironmentError
|
|
760743
|
+
});
|
|
760614
760744
|
}
|
|
760615
760745
|
const choices = accounts.map((account) => ({
|
|
760616
760746
|
name: account.isActive ? `${account.user} ${source_default.dim("(current)")}` : account.user,
|
|
@@ -760631,7 +760761,9 @@ var SwitchCommand = class {
|
|
|
760631
760761
|
const success2 = await context3.tokenService.switchAccount(user);
|
|
760632
760762
|
if (!success2) {
|
|
760633
760763
|
context3.stdout.error(`${Icons.error} Account not found: ${user}`);
|
|
760634
|
-
throw CliError
|
|
760764
|
+
throw new CliError({
|
|
760765
|
+
code: CliError.Code.EnvironmentError
|
|
760766
|
+
});
|
|
760635
760767
|
}
|
|
760636
760768
|
context3.stdout.info(`${Icons.success} Switched to ${source_default.bold(user)}`);
|
|
760637
760769
|
}
|
|
@@ -760668,24 +760800,32 @@ var TokenCommand = class {
|
|
|
760668
760800
|
organizationNotFoundError: () => {
|
|
760669
760801
|
process.stderr.write(`${Icons.error} Organization "${orgId}" was not found.
|
|
760670
760802
|
`);
|
|
760671
|
-
throw CliError
|
|
760803
|
+
throw new CliError({
|
|
760804
|
+
code: CliError.Code.ConfigError
|
|
760805
|
+
});
|
|
760672
760806
|
},
|
|
760673
760807
|
unauthorizedError: () => {
|
|
760674
760808
|
process.stderr.write(`${Icons.error} You do not have access to organization "${orgId}".
|
|
760675
760809
|
`);
|
|
760676
|
-
throw CliError
|
|
760810
|
+
throw new CliError({
|
|
760811
|
+
code: CliError.Code.AuthError
|
|
760812
|
+
});
|
|
760677
760813
|
},
|
|
760678
760814
|
missingOrgPermissionsError: () => {
|
|
760679
760815
|
process.stderr.write(`${Icons.error} You do not have the required permissions in organization "${orgId}".
|
|
760680
760816
|
`);
|
|
760681
|
-
throw CliError
|
|
760817
|
+
throw new CliError({
|
|
760818
|
+
code: CliError.Code.AuthError
|
|
760819
|
+
});
|
|
760682
760820
|
},
|
|
760683
760821
|
_other: () => {
|
|
760684
760822
|
process.stderr.write(`${Icons.error} Failed to generate token.
|
|
760685
760823
|
|
|
760686
760824
|
Please contact support@buildwithfern.com for assistance.
|
|
760687
760825
|
`);
|
|
760688
|
-
throw CliError
|
|
760826
|
+
throw new CliError({
|
|
760827
|
+
code: CliError.Code.InternalError
|
|
760828
|
+
});
|
|
760689
760829
|
}
|
|
760690
760830
|
});
|
|
760691
760831
|
}
|
|
@@ -760701,7 +760841,7 @@ var TokenCommand = class {
|
|
|
760701
760841
|
|
|
760702
760842
|
Run fern init or specify an organization with --org, then run this command again.
|
|
760703
760843
|
`);
|
|
760704
|
-
throw CliError.
|
|
760844
|
+
throw new CliError({ code: CliError.Code.ConfigError });
|
|
760705
760845
|
}
|
|
760706
760846
|
}
|
|
760707
760847
|
};
|
|
@@ -760721,7 +760861,7 @@ var WhoamiCommand = class {
|
|
|
760721
760861
|
context3.stdout.warn(`${source_default.yellow("\u26A0")} You are not logged in to Fern.`);
|
|
760722
760862
|
context3.stdout.info("");
|
|
760723
760863
|
context3.stdout.info(source_default.dim(" To log in, run: fern auth login"));
|
|
760724
|
-
throw CliError.
|
|
760864
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
760725
760865
|
}
|
|
760726
760866
|
if (args.json) {
|
|
760727
760867
|
context3.stdout.info(JSON.stringify({ email: activeAccount.user }, null, 2));
|
|
@@ -817707,7 +817847,7 @@ function checkMissingRedirects(removedSlugs, redirects, basePath) {
|
|
|
817707
817847
|
}
|
|
817708
817848
|
|
|
817709
817849
|
// ../yaml/docs-validator/lib/rules/missing-redirects/missing-redirects.js
|
|
817710
|
-
var NOOP_CONTEXT = createMockTaskContext({ logger:
|
|
817850
|
+
var NOOP_CONTEXT = createMockTaskContext({ logger: createLogger(noop2) });
|
|
817711
817851
|
async function fetchMarkdownEntries(fdrOrigin, domain3, basepath, authToken) {
|
|
817712
817852
|
try {
|
|
817713
817853
|
const response = await fetch(`${fdrOrigin}/slugs/markdowns`, {
|
|
@@ -839219,7 +839359,7 @@ function collectPathnamesToCheck(content5, { absoluteFilepath, instanceUrls }) {
|
|
|
839219
839359
|
}
|
|
839220
839360
|
|
|
839221
839361
|
// ../yaml/docs-validator/lib/rules/valid-markdown-link/valid-markdown-link.js
|
|
839222
|
-
var NOOP_CONTEXT2 = createMockTaskContext({ logger:
|
|
839362
|
+
var NOOP_CONTEXT2 = createMockTaskContext({ logger: createLogger(noop2) });
|
|
839223
839363
|
var ValidMarkdownLinks = {
|
|
839224
839364
|
name: "valid-markdown-links",
|
|
839225
839365
|
create: async ({ workspace, apiWorkspaces, ossWorkspaces }) => {
|
|
@@ -840288,7 +840428,8 @@ var DocsChecker = class {
|
|
|
840288
840428
|
const docsWorkspace = project.docsWorkspaces;
|
|
840289
840429
|
if (docsWorkspace == null) {
|
|
840290
840430
|
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."
|
|
840431
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
840432
|
+
code: CliError.Code.ConfigError
|
|
840292
840433
|
});
|
|
840293
840434
|
}
|
|
840294
840435
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -840559,12 +840700,12 @@ var CheckCommand2 = class {
|
|
|
840559
840700
|
const response = this.buildJsonResponse({ apiCheckResult, sdkCheckResult, docsCheckResult, hasErrors });
|
|
840560
840701
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
840561
840702
|
if (hasErrors) {
|
|
840562
|
-
throw CliError.
|
|
840703
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
840563
840704
|
}
|
|
840564
840705
|
return;
|
|
840565
840706
|
}
|
|
840566
840707
|
if (hasErrors) {
|
|
840567
|
-
throw CliError.
|
|
840708
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
840568
840709
|
}
|
|
840569
840710
|
if (totalWarnings > 0) {
|
|
840570
840711
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${totalWarnings} warnings`)}`);
|
|
@@ -840619,7 +840760,8 @@ var CheckCommand2 = class {
|
|
|
840619
840760
|
if (args.api != null && workspace.apis[args.api] == null) {
|
|
840620
840761
|
const availableApis = Object.keys(workspace.apis).join(", ");
|
|
840621
840762
|
throw new CliError({
|
|
840622
|
-
message: `API '${args.api}' not found. Available APIs: ${availableApis}
|
|
840763
|
+
message: `API '${args.api}' not found. Available APIs: ${availableApis}`,
|
|
840764
|
+
code: CliError.Code.ConfigError
|
|
840623
840765
|
});
|
|
840624
840766
|
}
|
|
840625
840767
|
}
|
|
@@ -842082,7 +842224,7 @@ var MigrateCommand = class {
|
|
|
842082
842224
|
}
|
|
842083
842225
|
return;
|
|
842084
842226
|
}
|
|
842085
|
-
throw new CliError({ message: "Migration failed" });
|
|
842227
|
+
throw new CliError({ message: "Migration failed", code: CliError.Code.ConfigError });
|
|
842086
842228
|
}
|
|
842087
842229
|
};
|
|
842088
842230
|
function addMigrateCommand(cli) {
|
|
@@ -842105,7 +842247,8 @@ var CheckCommand3 = class {
|
|
|
842105
842247
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
842106
842248
|
if (workspace.docs == null) {
|
|
842107
842249
|
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."
|
|
842250
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
842251
|
+
code: CliError.Code.ConfigError
|
|
842109
842252
|
});
|
|
842110
842253
|
}
|
|
842111
842254
|
const checker = new DocsChecker({ context: context3 });
|
|
@@ -842115,7 +842258,7 @@ var CheckCommand3 = class {
|
|
|
842115
842258
|
const response = this.buildJsonResponse({ result, hasErrors });
|
|
842116
842259
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
842117
842260
|
if (hasErrors) {
|
|
842118
|
-
throw CliError.
|
|
842261
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
842119
842262
|
}
|
|
842120
842263
|
return;
|
|
842121
842264
|
}
|
|
@@ -842127,7 +842270,7 @@ var CheckCommand3 = class {
|
|
|
842127
842270
|
}
|
|
842128
842271
|
}
|
|
842129
842272
|
if (hasErrors) {
|
|
842130
|
-
throw CliError.
|
|
842273
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
842131
842274
|
}
|
|
842132
842275
|
if (result.warningCount > 0) {
|
|
842133
842276
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -843968,7 +844111,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
843968
844111
|
var LOGS_FOLDER_NAME = "logs";
|
|
843969
844112
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
843970
844113
|
function getCliSource() {
|
|
843971
|
-
const version7 = "4.68.2";
|
|
844114
|
+
const version7 = "4.68.3-2-g063113b6335";
|
|
843972
844115
|
return `cli@${version7}`;
|
|
843973
844116
|
}
|
|
843974
844117
|
var DebugLogger = class {
|
|
@@ -845950,7 +846093,8 @@ var DevCommand = class {
|
|
|
845950
846093
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
845951
846094
|
if (workspace.docs == null) {
|
|
845952
846095
|
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."
|
|
846096
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
846097
|
+
code: CliError.Code.ConfigError
|
|
845954
846098
|
});
|
|
845955
846099
|
}
|
|
845956
846100
|
const backendPort = args["backend-port"] ?? await getPorts();
|
|
@@ -845960,7 +846104,7 @@ var DevCommand = class {
|
|
|
845960
846104
|
backendPort,
|
|
845961
846105
|
forceDownload: args["force-download"],
|
|
845962
846106
|
bundlePath: args["bundle-path"],
|
|
845963
|
-
logLevel:
|
|
846107
|
+
logLevel: LogLevel.Info
|
|
845964
846108
|
});
|
|
845965
846109
|
}
|
|
845966
846110
|
};
|
|
@@ -846271,11 +846415,11 @@ function getSeverityForViolations(violations) {
|
|
|
846271
846415
|
function getLogLevelForSeverity(severity) {
|
|
846272
846416
|
switch (severity) {
|
|
846273
846417
|
case "fatal":
|
|
846274
|
-
return
|
|
846418
|
+
return LogLevel.Error;
|
|
846275
846419
|
case "error":
|
|
846276
|
-
return
|
|
846420
|
+
return LogLevel.Error;
|
|
846277
846421
|
case "warning":
|
|
846278
|
-
return
|
|
846422
|
+
return LogLevel.Warn;
|
|
846279
846423
|
default:
|
|
846280
846424
|
assertNever(severity);
|
|
846281
846425
|
}
|
|
@@ -853561,15 +853705,15 @@ async function makeWritableRecursive(dirPath) {
|
|
|
853561
853705
|
function convertLogLevel(logLevel) {
|
|
853562
853706
|
switch (logLevel) {
|
|
853563
853707
|
case "DEBUG":
|
|
853564
|
-
return
|
|
853708
|
+
return LogLevel.Debug;
|
|
853565
853709
|
case "INFO":
|
|
853566
|
-
return
|
|
853710
|
+
return LogLevel.Info;
|
|
853567
853711
|
case "WARN":
|
|
853568
|
-
return
|
|
853712
|
+
return LogLevel.Warn;
|
|
853569
853713
|
case "ERROR":
|
|
853570
|
-
return
|
|
853714
|
+
return LogLevel.Error;
|
|
853571
853715
|
default:
|
|
853572
|
-
return
|
|
853716
|
+
return LogLevel.Info;
|
|
853573
853717
|
}
|
|
853574
853718
|
}
|
|
853575
853719
|
async function checkFernIgnorePresent(absolutePathToLocalOutput) {
|
|
@@ -855217,7 +855361,7 @@ var LegacyDocsPublisher = class {
|
|
|
855217
855361
|
previewId,
|
|
855218
855362
|
disableTemplates: void 0,
|
|
855219
855363
|
skipUpload,
|
|
855220
|
-
cliVersion: "4.68.2"
|
|
855364
|
+
cliVersion: "4.68.3-2-g063113b6335"
|
|
855221
855365
|
});
|
|
855222
855366
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
855223
855367
|
return { success: false };
|
|
@@ -855810,7 +855954,8 @@ var PublishCommand = class {
|
|
|
855810
855954
|
const workspace = await context3.loadWorkspaceOrThrow();
|
|
855811
855955
|
if (workspace.docs == null) {
|
|
855812
855956
|
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."
|
|
855957
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
855958
|
+
code: CliError.Code.ConfigError
|
|
855814
855959
|
});
|
|
855815
855960
|
}
|
|
855816
855961
|
const instanceUrl = this.resolveInstanceUrl({
|
|
@@ -855829,7 +855974,8 @@ var PublishCommand = class {
|
|
|
855829
855974
|
const docsWorkspace = project.docsWorkspaces;
|
|
855830
855975
|
if (docsWorkspace == null) {
|
|
855831
855976
|
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."
|
|
855977
|
+
message: "No docs configuration found in fern.yml.\n\n Add a 'docs:' section to your fern.yml to get started.",
|
|
855978
|
+
code: CliError.Code.ConfigError
|
|
855833
855979
|
});
|
|
855834
855980
|
}
|
|
855835
855981
|
const ossWorkspaces = await filterOssWorkspaces(project);
|
|
@@ -855844,7 +855990,10 @@ var PublishCommand = class {
|
|
|
855844
855990
|
});
|
|
855845
855991
|
const docsTask = taskGroup.getTask("publish");
|
|
855846
855992
|
if (docsTask == null) {
|
|
855847
|
-
throw new CliError({
|
|
855993
|
+
throw new CliError({
|
|
855994
|
+
message: "Internal error; task 'publish' not found",
|
|
855995
|
+
code: CliError.Code.InternalError
|
|
855996
|
+
});
|
|
855848
855997
|
}
|
|
855849
855998
|
docsTask.start();
|
|
855850
855999
|
docsTask.stage.validation.start();
|
|
@@ -855888,13 +856037,14 @@ var PublishCommand = class {
|
|
|
855888
856037
|
errorMessage: labels.error
|
|
855889
856038
|
});
|
|
855890
856039
|
if (summary.failedCount > 0) {
|
|
855891
|
-
throw CliError.
|
|
856040
|
+
throw new CliError({ code: CliError.Code.ContainerError });
|
|
855892
856041
|
}
|
|
855893
856042
|
}
|
|
855894
856043
|
resolveInstanceUrl({ instances: instances2, instance }) {
|
|
855895
856044
|
if (instances2.length === 0) {
|
|
855896
856045
|
throw new CliError({
|
|
855897
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856046
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
|
|
856047
|
+
code: CliError.Code.ConfigError
|
|
855898
856048
|
});
|
|
855899
856049
|
}
|
|
855900
856050
|
if (instance != null) {
|
|
@@ -855907,7 +856057,8 @@ var PublishCommand = class {
|
|
|
855907
856057
|
Available instances:
|
|
855908
856058
|
${available}
|
|
855909
856059
|
|
|
855910
|
-
Use --instance <url> with one of the URLs above
|
|
856060
|
+
Use --instance <url> with one of the URLs above.`,
|
|
856061
|
+
code: CliError.Code.ConfigError
|
|
855911
856062
|
});
|
|
855912
856063
|
}
|
|
855913
856064
|
return match3.url;
|
|
@@ -855920,13 +856071,15 @@ ${available}
|
|
|
855920
856071
|
Available instances:
|
|
855921
856072
|
${available}
|
|
855922
856073
|
|
|
855923
|
-
Use --instance <url> to select one
|
|
856074
|
+
Use --instance <url> to select one.`,
|
|
856075
|
+
code: CliError.Code.ConfigError
|
|
855924
856076
|
});
|
|
855925
856077
|
}
|
|
855926
856078
|
const first3 = instances2[0];
|
|
855927
856079
|
if (first3 == null) {
|
|
855928
856080
|
throw new CliError({
|
|
855929
|
-
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml."
|
|
856081
|
+
message: "No docs instances configured.\n\n Add an instance to the 'docs:' section of your fern.yml.",
|
|
856082
|
+
code: CliError.Code.ConfigError
|
|
855930
856083
|
});
|
|
855931
856084
|
}
|
|
855932
856085
|
return first3.url;
|
|
@@ -855960,7 +856113,8 @@ ${available}
|
|
|
855960
856113
|
const fernToken = process.env["FERN_TOKEN"];
|
|
855961
856114
|
if (fernToken == null) {
|
|
855962
856115
|
throw new CliError({
|
|
855963
|
-
message: "No organization token found. Please set the FERN_TOKEN environment variable."
|
|
856116
|
+
message: "No organization token found. Please set the FERN_TOKEN environment variable.",
|
|
856117
|
+
code: CliError.Code.AuthError
|
|
855964
856118
|
});
|
|
855965
856119
|
}
|
|
855966
856120
|
return Promise.resolve({ type: "organization", value: fernToken });
|
|
@@ -855972,7 +856126,10 @@ function addPublishCommand(cli) {
|
|
|
855972
856126
|
const cmd = new PublishCommand();
|
|
855973
856127
|
command2(cli, "publish", "Publish your documentation site", async (context3, args) => {
|
|
855974
856128
|
const timeout4 = new Promise((_16, reject) => {
|
|
855975
|
-
setTimeout(() => reject(new CliError({
|
|
856129
|
+
setTimeout(() => reject(new CliError({
|
|
856130
|
+
message: "Docs publish timed out after 10 minutes.",
|
|
856131
|
+
code: CliError.Code.NetworkError
|
|
856132
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
855976
856133
|
});
|
|
855977
856134
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
855978
856135
|
}, (yargs) => yargs.option("force", {
|
|
@@ -856001,7 +856158,8 @@ var DeleteCommand = class {
|
|
|
856001
856158
|
if (!this.isPreviewUrl(args.url)) {
|
|
856002
856159
|
throw new CliError({
|
|
856003
856160
|
message: `Invalid preview URL: ${args.url}
|
|
856004
|
-
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com
|
|
856161
|
+
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com`,
|
|
856162
|
+
code: CliError.Code.ConfigError
|
|
856005
856163
|
});
|
|
856006
856164
|
}
|
|
856007
856165
|
const token = await context3.getTokenOrPrompt();
|
|
@@ -856018,7 +856176,8 @@ var DeleteCommand = class {
|
|
|
856018
856176
|
throw CliError.notFound(`Preview site not found: ${args.url}`);
|
|
856019
856177
|
default:
|
|
856020
856178
|
throw new CliError({
|
|
856021
|
-
message: `Failed to delete preview site: ${args.url}
|
|
856179
|
+
message: `Failed to delete preview site: ${args.url}`,
|
|
856180
|
+
code: CliError.Code.InternalError
|
|
856022
856181
|
});
|
|
856023
856182
|
}
|
|
856024
856183
|
}
|
|
@@ -856065,7 +856224,10 @@ function addPreviewCommand(cli) {
|
|
|
856065
856224
|
const cmd = new PreviewCommand();
|
|
856066
856225
|
commandWithSubcommands(cli, "preview", "Generate a preview of your documentation site", async (context3, args) => {
|
|
856067
856226
|
const timeout4 = new Promise((_16, reject) => {
|
|
856068
|
-
setTimeout(() => reject(new CliError({
|
|
856227
|
+
setTimeout(() => reject(new CliError({
|
|
856228
|
+
message: "Docs preview timed out after 10 minutes.",
|
|
856229
|
+
code: CliError.Code.NetworkError
|
|
856230
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
856069
856231
|
});
|
|
856070
856232
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
856071
856233
|
}, (yargs) => yargs.option("instance", {
|
|
@@ -856452,7 +856614,7 @@ var Wizard = class {
|
|
|
856452
856614
|
return void 0;
|
|
856453
856615
|
}
|
|
856454
856616
|
this.context.stderr.info(` ${Icons.info} Opening browser to log in to Fern...`);
|
|
856455
|
-
const taskContext = new TaskContextAdapter({ context: this.context, logLevel:
|
|
856617
|
+
const taskContext = new TaskContextAdapter({ context: this.context, logLevel: LogLevel.Info });
|
|
856456
856618
|
const { accessToken, idToken } = await getTokenFromAuth0(taskContext, {
|
|
856457
856619
|
useDeviceCodeFlow: false,
|
|
856458
856620
|
forceReauth: false
|
|
@@ -857032,7 +857194,8 @@ var InitCommand = class {
|
|
|
857032
857194
|
async validateArgs({ context: context3, fernYmlPath, args }) {
|
|
857033
857195
|
if (await doesPathExist(fernYmlPath)) {
|
|
857034
857196
|
throw new CliError({
|
|
857035
|
-
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}
|
|
857197
|
+
message: `A ${FERN_YML_FILENAME} file already exists at ${fernYmlPath}`,
|
|
857198
|
+
code: CliError.Code.ConfigError
|
|
857036
857199
|
});
|
|
857037
857200
|
}
|
|
857038
857201
|
if (args.api != null) {
|
|
@@ -857040,13 +857203,14 @@ var InitCommand = class {
|
|
|
857040
857203
|
if (!api.startsWith("http://") && !api.startsWith("https://")) {
|
|
857041
857204
|
const resolved = import_path59.default.resolve(context3.cwd, api);
|
|
857042
857205
|
if (!await doesPathExist(AbsoluteFilePath2.of(resolved))) {
|
|
857043
|
-
throw new CliError({ message: `File not found: ${api}
|
|
857206
|
+
throw new CliError({ message: `File not found: ${api}`, code: CliError.Code.ConfigError });
|
|
857044
857207
|
}
|
|
857045
857208
|
}
|
|
857046
857209
|
}
|
|
857047
857210
|
if (!context3.isTTY && !args.yes) {
|
|
857048
857211
|
throw new CliError({
|
|
857049
|
-
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults."
|
|
857212
|
+
message: "Cannot run interactive init in non-TTY environment. Use --yes for defaults.",
|
|
857213
|
+
code: CliError.Code.ConfigError
|
|
857050
857214
|
});
|
|
857051
857215
|
}
|
|
857052
857216
|
}
|
|
@@ -857072,7 +857236,7 @@ var CreateCommand = class {
|
|
|
857072
857236
|
const token = await context3.getTokenOrPrompt();
|
|
857073
857237
|
if (token.type === "organization") {
|
|
857074
857238
|
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.
|
|
857239
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
857076
857240
|
}
|
|
857077
857241
|
const validationError = getOrganizationNameValidationError(args.name);
|
|
857078
857242
|
if (validationError != null) {
|
|
@@ -857109,7 +857273,7 @@ var ListCommand = class {
|
|
|
857109
857273
|
const token = await context3.getTokenOrPrompt();
|
|
857110
857274
|
if (token.type === "organization") {
|
|
857111
857275
|
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.
|
|
857276
|
+
throw new CliError({ code: CliError.Code.AuthError });
|
|
857113
857277
|
}
|
|
857114
857278
|
const venus = createVenusService({ token: token.value });
|
|
857115
857279
|
const firstPage = await this.fetchPage({ venus, pageId: 1 });
|
|
@@ -857253,13 +857417,14 @@ var AddCommand = class {
|
|
|
857253
857417
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
857254
857418
|
if (fernYmlPath == null) {
|
|
857255
857419
|
throw new CliError({
|
|
857256
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
857420
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
857421
|
+
code: CliError.Code.ConfigError
|
|
857257
857422
|
});
|
|
857258
857423
|
}
|
|
857259
857424
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
857260
857425
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
857261
857426
|
if (sdkCheckResult.errorCount > 0) {
|
|
857262
|
-
throw CliError.
|
|
857427
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857263
857428
|
}
|
|
857264
857429
|
const existingTargets = workspace.sdks?.targets ?? [];
|
|
857265
857430
|
if (!context3.isTTY || args.yes) {
|
|
@@ -857272,7 +857437,8 @@ var AddCommand = class {
|
|
|
857272
857437
|
throw new CliError({
|
|
857273
857438
|
message: `Missing required flags:
|
|
857274
857439
|
|
|
857275
|
-
--target <language> SDK language (e.g. typescript, python, go)
|
|
857440
|
+
--target <language> SDK language (e.g. typescript, python, go)`,
|
|
857441
|
+
code: CliError.Code.ConfigError
|
|
857276
857442
|
});
|
|
857277
857443
|
}
|
|
857278
857444
|
const language = this.parseLanguage(args.target);
|
|
@@ -857318,7 +857484,8 @@ var AddCommand = class {
|
|
|
857318
857484
|
message: `"${value}" looks like a remote reference but is not a recognized git URL.
|
|
857319
857485
|
|
|
857320
857486
|
Please specify a local path (e.g. ./sdks/my-sdk) or a git URL:
|
|
857321
|
-
https://github.com/owner/repo
|
|
857487
|
+
https://github.com/owner/repo`,
|
|
857488
|
+
code: CliError.Code.ConfigError
|
|
857322
857489
|
});
|
|
857323
857490
|
}
|
|
857324
857491
|
return { path: value };
|
|
@@ -857340,7 +857507,8 @@ var AddCommand = class {
|
|
|
857340
857507
|
checkForDuplicate({ existingTargets, language }) {
|
|
857341
857508
|
if (existingTargets.some((t3) => t3.name === language)) {
|
|
857342
857509
|
throw new CliError({
|
|
857343
|
-
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}
|
|
857510
|
+
message: `Target '${language}' already exists in ${FERN_YML_FILENAME}.`,
|
|
857511
|
+
code: CliError.Code.ConfigError
|
|
857344
857512
|
});
|
|
857345
857513
|
}
|
|
857346
857514
|
}
|
|
@@ -857392,7 +857560,8 @@ var AddCommand = class {
|
|
|
857392
857560
|
return lang;
|
|
857393
857561
|
}
|
|
857394
857562
|
throw new CliError({
|
|
857395
|
-
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}
|
|
857563
|
+
message: `"${target}" is not a supported language. Supported: ${LANGUAGES.join(", ")}`,
|
|
857564
|
+
code: CliError.Code.ConfigError
|
|
857396
857565
|
});
|
|
857397
857566
|
}
|
|
857398
857567
|
};
|
|
@@ -857429,7 +857598,7 @@ var CheckCommand4 = class {
|
|
|
857429
857598
|
const response = this.buildJsonResponse({ sdkCheckResult: result, hasErrors });
|
|
857430
857599
|
context3.stdout.info(JSON.stringify(response, null, 2));
|
|
857431
857600
|
if (hasErrors) {
|
|
857432
|
-
throw CliError.
|
|
857601
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857433
857602
|
}
|
|
857434
857603
|
return;
|
|
857435
857604
|
}
|
|
@@ -857441,7 +857610,7 @@ var CheckCommand4 = class {
|
|
|
857441
857610
|
}
|
|
857442
857611
|
}
|
|
857443
857612
|
if (hasErrors) {
|
|
857444
|
-
throw CliError.
|
|
857613
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
857445
857614
|
}
|
|
857446
857615
|
if (result.warningCount > 0) {
|
|
857447
857616
|
context3.stderr.info(`${Icons.warning} ${source_default.yellow(`Found ${result.warningCount} warnings`)}`);
|
|
@@ -904114,7 +904283,7 @@ function constructNpmPackage({ generatorConfig, isPackagePrivate }) {
|
|
|
904114
904283
|
registryUrl: outputMode.registriesV2.npm.registryUrl,
|
|
904115
904284
|
token: outputMode.registriesV2.npm.token
|
|
904116
904285
|
},
|
|
904117
|
-
license:
|
|
904286
|
+
license: licenseFromLicenseConfig(generatorConfig.license),
|
|
904118
904287
|
repoUrl: void 0
|
|
904119
904288
|
};
|
|
904120
904289
|
case "github":
|
|
@@ -904127,13 +904296,7 @@ function constructNpmPackage({ generatorConfig, isPackagePrivate }) {
|
|
|
904127
904296
|
private: isPackagePrivate,
|
|
904128
904297
|
publishInfo: void 0,
|
|
904129
904298
|
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
|
-
})
|
|
904299
|
+
license: licenseFromLicenseConfig(generatorConfig.license)
|
|
904137
904300
|
};
|
|
904138
904301
|
default:
|
|
904139
904302
|
throw new Error(`Encountered unknown output mode: ${outputMode}`);
|
|
@@ -904175,6 +904338,13 @@ function removeGitSuffix(repoUrl) {
|
|
|
904175
904338
|
}
|
|
904176
904339
|
return repoUrl;
|
|
904177
904340
|
}
|
|
904341
|
+
function licenseFromLicenseConfig(licenseConfig) {
|
|
904342
|
+
return licenseConfig?._visit({
|
|
904343
|
+
basic: (basic2) => basic2.id,
|
|
904344
|
+
custom: (custom3) => `See ${custom3.filename}`,
|
|
904345
|
+
_other: () => void 0
|
|
904346
|
+
});
|
|
904347
|
+
}
|
|
904178
904348
|
|
|
904179
904349
|
// ../../../generators/typescript-v2/browser-compatible-base/lib/utils/getNamespaceExport.js
|
|
904180
904350
|
init_lodash();
|
|
@@ -907849,8 +908019,6 @@ var GenerationRunner = class {
|
|
|
907849
908019
|
}
|
|
907850
908020
|
} catch (error50) {
|
|
907851
908021
|
if (error50 instanceof TaskAbortSignal) {
|
|
907852
|
-
} else if (error50 instanceof LoggableFernCliError) {
|
|
907853
|
-
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50.log}`, error50);
|
|
907854
908022
|
} else {
|
|
907855
908023
|
interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50);
|
|
907856
908024
|
}
|
|
@@ -908283,7 +908451,7 @@ var LegacyLocalGenerationRunner = class {
|
|
|
908283
908451
|
const taskContext = new TaskContextAdapter({
|
|
908284
908452
|
context: this.context,
|
|
908285
908453
|
task: args.task,
|
|
908286
|
-
logLevel:
|
|
908454
|
+
logLevel: LogLevel.Info
|
|
908287
908455
|
});
|
|
908288
908456
|
try {
|
|
908289
908457
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908422,7 +908590,7 @@ var LegacyRemoteGenerationRunner = class {
|
|
|
908422
908590
|
const taskContext = new TaskContextAdapter({
|
|
908423
908591
|
context: this.context,
|
|
908424
908592
|
task: args.task,
|
|
908425
|
-
logLevel:
|
|
908593
|
+
logLevel: LogLevel.Info
|
|
908426
908594
|
});
|
|
908427
908595
|
try {
|
|
908428
908596
|
const generatorInvocation = await this.invocationAdapter.adapt(args.target);
|
|
@@ -908562,7 +908730,8 @@ var GeneratorPipeline = class {
|
|
|
908562
908730
|
}
|
|
908563
908731
|
if (args.target.registry != null) {
|
|
908564
908732
|
throw new CliError({
|
|
908565
|
-
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry
|
|
908733
|
+
message: `Custom image configurations are only supported with local generation (--local). Target "${args.target.name}" uses a custom image registry.`,
|
|
908734
|
+
code: CliError.Code.ConfigError
|
|
908566
908735
|
});
|
|
908567
908736
|
}
|
|
908568
908737
|
return await this.runRemoteGeneration(args);
|
|
@@ -908874,7 +909043,8 @@ var GenerateCommand = class {
|
|
|
908874
909043
|
throw new CliError({
|
|
908875
909044
|
message: `No fern.yml found, either run 'fern init' or specify all of the required flags:
|
|
908876
909045
|
|
|
908877
|
-
` + missingFlags.map((flag) => ` ${flag}`).join("\n")
|
|
909046
|
+
` + missingFlags.map((flag) => ` ${flag}`).join("\n"),
|
|
909047
|
+
code: CliError.Code.ConfigError
|
|
908878
909048
|
});
|
|
908879
909049
|
}
|
|
908880
909050
|
const api = args.api;
|
|
@@ -908925,12 +909095,12 @@ var GenerateCommand = class {
|
|
|
908925
909095
|
}
|
|
908926
909096
|
}
|
|
908927
909097
|
if (sdkCheckResult.errorCount > 0) {
|
|
908928
|
-
throw CliError.
|
|
909098
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
908929
909099
|
}
|
|
908930
909100
|
}
|
|
908931
909101
|
const validTargets = targets2.filter((t3) => checkResult.validApis.has(t3.api));
|
|
908932
909102
|
if (validTargets.length === 0) {
|
|
908933
|
-
throw CliError.
|
|
909103
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
908934
909104
|
}
|
|
908935
909105
|
const pipeline5 = new GeneratorPipeline({
|
|
908936
909106
|
context: context3,
|
|
@@ -908958,7 +909128,7 @@ var GenerateCommand = class {
|
|
|
908958
909128
|
if (outputPath != null) {
|
|
908959
909129
|
const { shouldProceed } = await this.checkOutputDirectory({ context: context3, args, outputPath });
|
|
908960
909130
|
if (!shouldProceed) {
|
|
908961
|
-
throw new CliError({ message: "Generation cancelled." });
|
|
909131
|
+
throw new CliError({ message: "Generation cancelled.", code: CliError.Code.ConfigError });
|
|
908962
909132
|
}
|
|
908963
909133
|
}
|
|
908964
909134
|
}
|
|
@@ -908976,7 +909146,10 @@ var GenerateCommand = class {
|
|
|
908976
909146
|
await Promise.all(targets2.map(async (target) => {
|
|
908977
909147
|
const task = taskGroup.getTask(target.name);
|
|
908978
909148
|
if (task == null) {
|
|
908979
|
-
throw new CliError({
|
|
909149
|
+
throw new CliError({
|
|
909150
|
+
message: `Internal error; task '${target.name}' not found`,
|
|
909151
|
+
code: CliError.Code.InternalError
|
|
909152
|
+
});
|
|
908980
909153
|
}
|
|
908981
909154
|
task.start();
|
|
908982
909155
|
task.stage.validation.start();
|
|
@@ -909022,22 +909195,32 @@ var GenerateCommand = class {
|
|
|
909022
909195
|
errorMessage: `Failed to generate ${sdkInitialism}`
|
|
909023
909196
|
});
|
|
909024
909197
|
if (summary.failedCount > 0) {
|
|
909025
|
-
throw CliError.
|
|
909198
|
+
throw new CliError({ code: CliError.Code.ContainerError });
|
|
909026
909199
|
}
|
|
909027
909200
|
}
|
|
909028
909201
|
validateArgs({ workspace, args, targets: targets2 }) {
|
|
909029
909202
|
if (args["container-engine"] != null && !args.local) {
|
|
909030
|
-
throw new CliError({
|
|
909203
|
+
throw new CliError({
|
|
909204
|
+
message: "The --container-engine flag can only be used with --local",
|
|
909205
|
+
code: CliError.Code.ConfigError
|
|
909206
|
+
});
|
|
909031
909207
|
}
|
|
909032
909208
|
if (args.group != null && args.target != null) {
|
|
909033
|
-
throw new CliError({
|
|
909209
|
+
throw new CliError({
|
|
909210
|
+
message: "The --group and --target flags cannot be used together",
|
|
909211
|
+
code: CliError.Code.ConfigError
|
|
909212
|
+
});
|
|
909034
909213
|
}
|
|
909035
909214
|
if (targets2.length > 1 && args.output != null) {
|
|
909036
|
-
throw new CliError({
|
|
909215
|
+
throw new CliError({
|
|
909216
|
+
message: "The --output flag can only be used when generating a single target",
|
|
909217
|
+
code: CliError.Code.ConfigError
|
|
909218
|
+
});
|
|
909037
909219
|
}
|
|
909038
909220
|
if (args["skip-fernignore"] && args.fernignore != null) {
|
|
909039
909221
|
throw new CliError({
|
|
909040
|
-
message: "The --skip-fernignore and --fernignore flags cannot be used together."
|
|
909222
|
+
message: "The --skip-fernignore and --fernignore flags cannot be used together.",
|
|
909223
|
+
code: CliError.Code.ConfigError
|
|
909041
909224
|
});
|
|
909042
909225
|
}
|
|
909043
909226
|
const issues = [];
|
|
@@ -909089,7 +909272,8 @@ Example:
|
|
|
909089
909272
|
throw new CliError({
|
|
909090
909273
|
message: `Remote generation is not supported with a git URL for --output
|
|
909091
909274
|
|
|
909092
|
-
Use --local or specify a local filesystem path for --output
|
|
909275
|
+
Use --local or specify a local filesystem path for --output`,
|
|
909276
|
+
code: CliError.Code.ConfigError
|
|
909093
909277
|
});
|
|
909094
909278
|
}
|
|
909095
909279
|
const token = process.env.GITHUB_TOKEN ?? process.env.GIT_TOKEN;
|
|
@@ -909101,7 +909285,8 @@ Example:
|
|
|
909101
909285
|
export GITHUB_TOKEN=ghp_xxx
|
|
909102
909286
|
|
|
909103
909287
|
Or use a local path:
|
|
909104
|
-
--output ./my-sdk
|
|
909288
|
+
--output ./my-sdk`,
|
|
909289
|
+
code: CliError.Code.AuthError
|
|
909105
909290
|
});
|
|
909106
909291
|
}
|
|
909107
909292
|
return {
|
|
@@ -909223,7 +909408,10 @@ function addGenerateCommand(cli) {
|
|
|
909223
909408
|
const cmd = new GenerateCommand();
|
|
909224
909409
|
command2(cli, "generate", "Generate SDKs from fern.yml or directly from an API spec", async (context3, args) => {
|
|
909225
909410
|
const timeout4 = new Promise((_16, reject) => {
|
|
909226
|
-
setTimeout(() => reject(new CliError({
|
|
909411
|
+
setTimeout(() => reject(new CliError({
|
|
909412
|
+
message: "Generation timed out after 10 minutes.",
|
|
909413
|
+
code: CliError.Code.NetworkError
|
|
909414
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909227
909415
|
});
|
|
909228
909416
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909229
909417
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909302,7 +909490,10 @@ function addPreviewCommand2(cli) {
|
|
|
909302
909490
|
const cmd = new PreviewCommand2();
|
|
909303
909491
|
command2(cli, "preview", "Generate a preview of an SDK", async (context3, args) => {
|
|
909304
909492
|
const timeout4 = new Promise((_16, reject) => {
|
|
909305
|
-
setTimeout(() => reject(new CliError({
|
|
909493
|
+
setTimeout(() => reject(new CliError({
|
|
909494
|
+
message: "Preview generation timed out after 10 minutes.",
|
|
909495
|
+
code: CliError.Code.NetworkError
|
|
909496
|
+
})), GENERATE_COMMAND_TIMEOUT_MS).unref();
|
|
909306
909497
|
});
|
|
909307
909498
|
await Promise.race([cmd.handle(context3, args), timeout4]);
|
|
909308
909499
|
}, (yargs) => yargs.option("api", {
|
|
@@ -909754,13 +909945,14 @@ var UpdateCommand = class {
|
|
|
909754
909945
|
const fernYmlPath = workspace.absoluteFilePath;
|
|
909755
909946
|
if (fernYmlPath == null) {
|
|
909756
909947
|
throw new CliError({
|
|
909757
|
-
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project
|
|
909948
|
+
message: `No ${FERN_YML_FILENAME} found. Run 'fern init' to initialize a project.`,
|
|
909949
|
+
code: CliError.Code.ConfigError
|
|
909758
909950
|
});
|
|
909759
909951
|
}
|
|
909760
909952
|
const sdkChecker = new SdkChecker({ context: context3 });
|
|
909761
909953
|
const sdkCheckResult = await sdkChecker.check({ workspace });
|
|
909762
909954
|
if (sdkCheckResult.errorCount > 0) {
|
|
909763
|
-
throw CliError.
|
|
909955
|
+
throw new CliError({ code: CliError.Code.ValidationError });
|
|
909764
909956
|
}
|
|
909765
909957
|
const targets2 = workspace.sdks?.targets;
|
|
909766
909958
|
if (targets2 == null || targets2.length === 0) {
|
|
@@ -909776,7 +909968,8 @@ var UpdateCommand = class {
|
|
|
909776
909968
|
});
|
|
909777
909969
|
if (updates.length === 0 && upToDate.length === 0 && args.target != null) {
|
|
909778
909970
|
throw new CliError({
|
|
909779
|
-
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}
|
|
909971
|
+
message: `Target '${args.target}' not found in ${FERN_YML_FILENAME}.`,
|
|
909972
|
+
code: CliError.Code.ConfigError
|
|
909780
909973
|
});
|
|
909781
909974
|
}
|
|
909782
909975
|
if (updates.length === 0) {
|
|
@@ -924757,19 +924950,19 @@ var Logger4 = class {
|
|
|
924757
924950
|
this.enabled = true;
|
|
924758
924951
|
}
|
|
924759
924952
|
trace(...args) {
|
|
924760
|
-
this.write(
|
|
924953
|
+
this.write(LogLevel.Trace, ...args);
|
|
924761
924954
|
}
|
|
924762
924955
|
debug(...args) {
|
|
924763
|
-
this.write(
|
|
924956
|
+
this.write(LogLevel.Debug, ...args);
|
|
924764
924957
|
}
|
|
924765
924958
|
info(...args) {
|
|
924766
|
-
this.write(
|
|
924959
|
+
this.write(LogLevel.Info, ...args);
|
|
924767
924960
|
}
|
|
924768
924961
|
warn(...args) {
|
|
924769
|
-
this.write(
|
|
924962
|
+
this.write(LogLevel.Warn, ...args);
|
|
924770
924963
|
}
|
|
924771
924964
|
error(...args) {
|
|
924772
|
-
this.write(
|
|
924965
|
+
this.write(LogLevel.Error, ...args);
|
|
924773
924966
|
}
|
|
924774
924967
|
log(level, ...args) {
|
|
924775
924968
|
this.write(level, ...args);
|
|
@@ -928384,6 +928577,24 @@ var esm_default16 = createPrompt((config5, done) => {
|
|
|
928384
928577
|
// src/cli-context/CliContext.ts
|
|
928385
928578
|
init_lodash();
|
|
928386
928579
|
|
|
928580
|
+
// src/telemetry/reportError.ts
|
|
928581
|
+
function reportError2(reporter, error50, options2) {
|
|
928582
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
928583
|
+
return;
|
|
928584
|
+
}
|
|
928585
|
+
const code5 = resolveErrorCode(error50, options2?.code);
|
|
928586
|
+
reporter.instrumentPostHogEvent({
|
|
928587
|
+
command: process.argv.join(" "),
|
|
928588
|
+
properties: {
|
|
928589
|
+
failed: true,
|
|
928590
|
+
errorCode: code5
|
|
928591
|
+
}
|
|
928592
|
+
});
|
|
928593
|
+
if (shouldReportToSentry(code5)) {
|
|
928594
|
+
reporter.captureException(error50 ?? new CliError({ message: options2?.message ?? "", code: code5 }), code5);
|
|
928595
|
+
}
|
|
928596
|
+
}
|
|
928597
|
+
|
|
928387
928598
|
// src/telemetry/SentryClient.ts
|
|
928388
928599
|
var SentryClient = class {
|
|
928389
928600
|
sentry;
|
|
@@ -928406,12 +928617,15 @@ var SentryClient = class {
|
|
|
928406
928617
|
setSentryRunIdTags();
|
|
928407
928618
|
}
|
|
928408
928619
|
}
|
|
928409
|
-
|
|
928620
|
+
captureException(error50, code5) {
|
|
928410
928621
|
if (this.sentry == null) {
|
|
928411
928622
|
return;
|
|
928412
928623
|
}
|
|
928413
928624
|
try {
|
|
928414
|
-
this.sentry.captureException(
|
|
928625
|
+
this.sentry.captureException(
|
|
928626
|
+
error50,
|
|
928627
|
+
code5 != null ? { captureContext: { tags: { "error.code": code5 } } } : void 0
|
|
928628
|
+
);
|
|
928415
928629
|
} catch {
|
|
928416
928630
|
}
|
|
928417
928631
|
}
|
|
@@ -928469,13 +928683,15 @@ var TaskContextImpl = class {
|
|
|
928469
928683
|
status = "notStarted";
|
|
928470
928684
|
onResult;
|
|
928471
928685
|
instrumentPostHogEventImpl;
|
|
928686
|
+
captureExceptionImpl;
|
|
928472
928687
|
constructor({
|
|
928473
928688
|
logImmediately,
|
|
928474
928689
|
logPrefix,
|
|
928475
928690
|
takeOverTerminal,
|
|
928476
928691
|
onResult,
|
|
928477
928692
|
shouldBufferLogs,
|
|
928478
|
-
instrumentPostHogEvent
|
|
928693
|
+
instrumentPostHogEvent,
|
|
928694
|
+
captureException: captureException2
|
|
928479
928695
|
}) {
|
|
928480
928696
|
this.logImmediately = logImmediately;
|
|
928481
928697
|
this.logPrefix = logPrefix ?? "";
|
|
@@ -928483,6 +928699,7 @@ var TaskContextImpl = class {
|
|
|
928483
928699
|
this.onResult = onResult;
|
|
928484
928700
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
928485
928701
|
this.instrumentPostHogEventImpl = instrumentPostHogEvent;
|
|
928702
|
+
this.captureExceptionImpl = captureException2;
|
|
928486
928703
|
}
|
|
928487
928704
|
start() {
|
|
928488
928705
|
this.status = "running";
|
|
@@ -928500,14 +928717,21 @@ var TaskContextImpl = class {
|
|
|
928500
928717
|
return this.status === "finished";
|
|
928501
928718
|
}
|
|
928502
928719
|
takeOverTerminal;
|
|
928503
|
-
failAndThrow(message, error50) {
|
|
928504
|
-
this.failWithoutThrowing(message, error50);
|
|
928720
|
+
failAndThrow(message, error50, options2) {
|
|
928721
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
928505
928722
|
this.finish();
|
|
928506
928723
|
throw new TaskAbortSignal();
|
|
928507
928724
|
}
|
|
928508
|
-
failWithoutThrowing(message, error50) {
|
|
928509
|
-
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928725
|
+
failWithoutThrowing(message, error50, options2) {
|
|
928510
928726
|
this.result = TaskResult.Failure;
|
|
928727
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
928728
|
+
return;
|
|
928729
|
+
}
|
|
928730
|
+
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
928731
|
+
reportError2(this, error50, { ...options2, message });
|
|
928732
|
+
}
|
|
928733
|
+
captureException(error50, code5) {
|
|
928734
|
+
this.captureExceptionImpl?.(error50, code5);
|
|
928511
928735
|
}
|
|
928512
928736
|
getResult() {
|
|
928513
928737
|
return this.result;
|
|
@@ -928539,7 +928763,7 @@ var TaskContextImpl = class {
|
|
|
928539
928763
|
this.logImmediately(this.bufferedLogs);
|
|
928540
928764
|
this.bufferedLogs = [];
|
|
928541
928765
|
}
|
|
928542
|
-
logger =
|
|
928766
|
+
logger = createLogger(this.logAtLevel.bind(this));
|
|
928543
928767
|
addInteractiveTask({ name: name2, subtitle }) {
|
|
928544
928768
|
const subtask = new InteractiveTaskContextImpl({
|
|
928545
928769
|
name: name2,
|
|
@@ -928549,7 +928773,8 @@ var TaskContextImpl = class {
|
|
|
928549
928773
|
takeOverTerminal: this.takeOverTerminal,
|
|
928550
928774
|
onResult: this.onResult,
|
|
928551
928775
|
shouldBufferLogs: this.shouldBufferLogs,
|
|
928552
|
-
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event)
|
|
928776
|
+
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event),
|
|
928777
|
+
captureException: this.captureExceptionImpl
|
|
928553
928778
|
});
|
|
928554
928779
|
this.subtasks.push(subtask);
|
|
928555
928780
|
return subtask;
|
|
@@ -928579,7 +928804,7 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928579
928804
|
}
|
|
928580
928805
|
start() {
|
|
928581
928806
|
super.start();
|
|
928582
|
-
this.logAtLevelWithOverrides(
|
|
928807
|
+
this.logAtLevelWithOverrides(LogLevel.Info, ["Started."], {
|
|
928583
928808
|
omitOnTTY: true
|
|
928584
928809
|
});
|
|
928585
928810
|
this.flushLogs();
|
|
@@ -928590,11 +928815,11 @@ var InteractiveTaskContextImpl = class extends TaskContextImpl {
|
|
|
928590
928815
|
}
|
|
928591
928816
|
finish() {
|
|
928592
928817
|
if (this.result === TaskResult.Success) {
|
|
928593
|
-
this.logAtLevelWithOverrides(
|
|
928818
|
+
this.logAtLevelWithOverrides(LogLevel.Info, ["Finished."], {
|
|
928594
928819
|
omitOnTTY: true
|
|
928595
928820
|
});
|
|
928596
928821
|
} else {
|
|
928597
|
-
this.logAtLevelWithOverrides(
|
|
928822
|
+
this.logAtLevelWithOverrides(LogLevel.Error, ["Failed."], {
|
|
928598
928823
|
omitOnTTY: true
|
|
928599
928824
|
});
|
|
928600
928825
|
}
|
|
@@ -928922,7 +929147,7 @@ var CliContext = class _CliContext {
|
|
|
928922
929147
|
didSucceed = true;
|
|
928923
929148
|
numTasks = 0;
|
|
928924
929149
|
ttyAwareLogger;
|
|
928925
|
-
logLevel =
|
|
929150
|
+
logLevel = LogLevel.Info;
|
|
928926
929151
|
isLocal;
|
|
928927
929152
|
stdoutRedirector = new StdoutRedirector();
|
|
928928
929153
|
jsonMode = false;
|
|
@@ -928957,7 +929182,7 @@ var CliContext = class _CliContext {
|
|
|
928957
929182
|
if (false) {
|
|
928958
929183
|
this.logger.error("CLI_VERSION is not defined");
|
|
928959
929184
|
}
|
|
928960
|
-
return "4.68.2";
|
|
929185
|
+
return "4.68.3-2-g063113b6335";
|
|
928961
929186
|
}
|
|
928962
929187
|
getCliName() {
|
|
928963
929188
|
if (false) {
|
|
@@ -928973,13 +929198,17 @@ var CliContext = class _CliContext {
|
|
|
928973
929198
|
`Running ${source_default.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`
|
|
928974
929199
|
);
|
|
928975
929200
|
}
|
|
928976
|
-
failAndThrow(message, error50) {
|
|
928977
|
-
this.failWithoutThrowing(message, error50);
|
|
929201
|
+
failAndThrow(message, error50, options2) {
|
|
929202
|
+
this.failWithoutThrowing(message, error50, options2);
|
|
928978
929203
|
throw new TaskAbortSignal();
|
|
928979
929204
|
}
|
|
928980
|
-
failWithoutThrowing(message, error50) {
|
|
929205
|
+
failWithoutThrowing(message, error50, options2) {
|
|
928981
929206
|
this.didSucceed = false;
|
|
929207
|
+
if (error50 instanceof TaskAbortSignal) {
|
|
929208
|
+
return;
|
|
929209
|
+
}
|
|
928982
929210
|
logErrorMessage({ message, error: error50, logger: this.logger });
|
|
929211
|
+
reportError2(this, error50, { ...options2, message });
|
|
928983
929212
|
}
|
|
928984
929213
|
/**
|
|
928985
929214
|
* Activate JSON-output mode: all logger output is forced to stderr
|
|
@@ -929082,15 +929311,7 @@ var CliContext = class _CliContext {
|
|
|
929082
929311
|
try {
|
|
929083
929312
|
result = await run(context3);
|
|
929084
929313
|
} 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
|
-
}
|
|
929314
|
+
context3.failWithoutThrowing(void 0, error50);
|
|
929094
929315
|
throw new TaskAbortSignal();
|
|
929095
929316
|
} finally {
|
|
929096
929317
|
context3.finish();
|
|
@@ -929102,11 +929323,11 @@ var CliContext = class _CliContext {
|
|
|
929102
929323
|
this.posthogManager.sendEvent(event);
|
|
929103
929324
|
}
|
|
929104
929325
|
}
|
|
929105
|
-
|
|
929106
|
-
|
|
929326
|
+
captureException(error50, code5) {
|
|
929327
|
+
this.sentryClient.captureException(error50, code5);
|
|
929107
929328
|
}
|
|
929108
|
-
logger =
|
|
929109
|
-
stderr =
|
|
929329
|
+
logger = createLogger((level, ...args) => this.log(level, ...args));
|
|
929330
|
+
stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
929110
929331
|
constructTaskInitForWorkspace(workspace) {
|
|
929111
929332
|
const prefixWithoutPadding = wrapWorkspaceNameForPrefix(
|
|
929112
929333
|
workspace.type === "docs" ? "docs" : workspace.workspaceName ?? "api"
|
|
@@ -929132,7 +929353,10 @@ var CliContext = class _CliContext {
|
|
|
929132
929353
|
instrumentPostHogEvent: (event) => {
|
|
929133
929354
|
this.instrumentPostHogEvent(event);
|
|
929134
929355
|
},
|
|
929135
|
-
shouldBufferLogs: false
|
|
929356
|
+
shouldBufferLogs: false,
|
|
929357
|
+
captureException: (error50, code5) => {
|
|
929358
|
+
this.sentryClient.captureException(error50, code5);
|
|
929359
|
+
}
|
|
929136
929360
|
};
|
|
929137
929361
|
}
|
|
929138
929362
|
log(level, ...parts) {
|
|
@@ -929159,7 +929383,7 @@ var CliContext = class _CliContext {
|
|
|
929159
929383
|
logImmediately(logs4, { stderr = false } = {}) {
|
|
929160
929384
|
const filtered = logs4.filter((log4) => LOG_LEVELS.indexOf(log4.level) >= LOG_LEVELS.indexOf(this.logLevel));
|
|
929161
929385
|
this.ttyAwareLogger.log(filtered, {
|
|
929162
|
-
includeDebugInfo: this.logLevel ===
|
|
929386
|
+
includeDebugInfo: this.logLevel === LogLevel.Debug,
|
|
929163
929387
|
stderr: stderr || this.jsonMode
|
|
929164
929388
|
});
|
|
929165
929389
|
}
|
|
@@ -947133,7 +947357,6 @@ function evaluateRuntime4() {
|
|
|
947133
947357
|
|
|
947134
947358
|
// src/cli.ts
|
|
947135
947359
|
void runCli();
|
|
947136
|
-
var USE_NODE_18_OR_ABOVE_MESSAGE = "The Fern CLI requires Node 18+ or above.";
|
|
947137
947360
|
async function runCli() {
|
|
947138
947361
|
getOrCreateFernRunId();
|
|
947139
947362
|
const isLocal = process.argv.includes("--local");
|
|
@@ -947171,24 +947394,7 @@ async function runCli() {
|
|
|
947171
947394
|
});
|
|
947172
947395
|
}
|
|
947173
947396
|
} 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
|
-
}
|
|
947397
|
+
cliContext.failWithoutThrowing(void 0, error50);
|
|
947192
947398
|
}
|
|
947193
947399
|
await exit3();
|
|
947194
947400
|
}
|
|
@@ -947219,7 +947425,7 @@ async function tryRunCli(cliContext) {
|
|
|
947219
947425
|
}
|
|
947220
947426
|
}
|
|
947221
947427
|
).option("log-level", {
|
|
947222
|
-
default:
|
|
947428
|
+
default: LogLevel.Info,
|
|
947223
947429
|
choices: LOG_LEVELS
|
|
947224
947430
|
}).demandCommand().recommendCommands();
|
|
947225
947431
|
addDiffCommand(cli, cliContext);
|