first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import type { Event } from '@sentry/node';
import type { ErrorTags, ErrorLevel, ReportingOptions } from '@n8n/errors';
export type BaseErrorOptions = {
description?: string | undefined | null;
} & ErrorOptions & ReportingOptions;
/**
* Base class for all errors
*/
export declare abstract class BaseError extends Error {
/**
* Error level. Defines which level the error should be logged/reported
* @default 'error'
*/
level: ErrorLevel;
/**
* Whether the error should be reported to Sentry.
* @default true
*/
readonly shouldReport: boolean;
readonly description: string | null | undefined;
readonly tags: ErrorTags;
readonly extra?: Event['extra'];
readonly packageName?: string;
constructor(message: string, { level, description, shouldReport, tags, extra, ...rest }?: BaseErrorOptions);
}
//# sourceMappingURL=base.error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base.error.d.ts","sourceRoot":"","sources":["../../../../src/errors/base/base.error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE3E,MAAM,MAAM,gBAAgB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CAAE,GAAG,YAAY,GACxF,gBAAgB,CAAC;AAClB;;GAEG;AACH,8BAAsB,SAAU,SAAQ,KAAK;IAC5C;;;OAGG;IACH,KAAK,EAAE,UAAU,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAE/B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAEhD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAEhC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACf,EACC,KAAe,EACf,WAAW,EACX,YAAY,EACZ,IAAS,EACT,KAAK,EACL,GAAG,IAAI,EACP,GAAE,gBAAqB;CAiBzB"}

View File

@@ -0,0 +1,53 @@
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "callsites"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseError = void 0;
const callsites_1 = __importDefault(require("callsites"));
/**
* Base class for all errors
*/
class BaseError extends Error {
/**
* Error level. Defines which level the error should be logged/reported
* @default 'error'
*/
level;
/**
* Whether the error should be reported to Sentry.
* @default true
*/
shouldReport;
description;
tags;
extra;
packageName;
constructor(message, { level = 'error', description, shouldReport, tags = {}, extra, ...rest } = {}) {
super(message, rest);
this.level = level;
this.shouldReport = shouldReport ?? (level === 'error' || level === 'fatal');
this.description = description;
this.tags = tags;
this.extra = extra;
try {
const filePath = (0, callsites_1.default)()[2].getFileName() ?? '';
const match = /packages\/([^\/]+)\//.exec(filePath)?.[1];
if (match)
this.tags.packageName = match;
}
catch { }
}
}
exports.BaseError = BaseError;
});
//# sourceMappingURL=base.error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base.error.js","sourceRoot":"","sources":["../../../../src/errors/base/base.error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;IACA,0DAAkC;IAMlC;;OAEG;IACH,MAAsB,SAAU,SAAQ,KAAK;QAC5C;;;WAGG;QACH,KAAK,CAAa;QAElB;;;WAGG;QACM,YAAY,CAAU;QAEtB,WAAW,CAA4B;QAEvC,IAAI,CAAY;QAEhB,KAAK,CAAkB;QAEvB,WAAW,CAAU;QAE9B,YACC,OAAe,EACf,EACC,KAAK,GAAG,OAAO,EACf,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,EAAE,EACT,KAAK,EACL,GAAG,IAAI,KACc,EAAE;YAExB,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAErB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC;YAC7E,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YAEnB,IAAI,CAAC;gBACJ,MAAM,QAAQ,GAAG,IAAA,mBAAS,GAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;gBACpD,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBAEzD,IAAI,KAAK;oBAAE,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACX,CAAC;KACD;IA/CD,8BA+CC"}

View File

@@ -0,0 +1,16 @@
import type { BaseErrorOptions } from './base.error';
import { BaseError } from './base.error';
export type OperationalErrorOptions = Omit<BaseErrorOptions, 'level'> & {
level?: 'info' | 'warning' | 'error';
};
/**
* Error that indicates a transient issue, like a network request failing,
* a database query timing out, etc. These are expected to happen, are
* transient by nature and should be handled gracefully.
*
* Default level: warning
*/
export declare class OperationalError extends BaseError {
constructor(message: string, opts?: OperationalErrorOptions);
}
//# sourceMappingURL=operational.error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operational.error.d.ts","sourceRoot":"","sources":["../../../../src/errors/base/operational.error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IACvE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBAClC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,uBAA4B;CAK/D"}

View File

@@ -0,0 +1,29 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./base.error"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OperationalError = void 0;
const base_error_1 = require("./base.error");
/**
* Error that indicates a transient issue, like a network request failing,
* a database query timing out, etc. These are expected to happen, are
* transient by nature and should be handled gracefully.
*
* Default level: warning
*/
class OperationalError extends base_error_1.BaseError {
constructor(message, opts = {}) {
opts.level = opts.level ?? 'warning';
super(message, opts);
}
}
exports.OperationalError = OperationalError;
});
//# sourceMappingURL=operational.error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operational.error.js","sourceRoot":"","sources":["../../../../src/errors/base/operational.error.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,6CAAyC;IAMzC;;;;;;OAMG;IACH,MAAa,gBAAiB,SAAQ,sBAAS;QAC9C,YAAY,OAAe,EAAE,OAAgC,EAAE;YAC9D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC;YAErC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtB,CAAC;KACD;IAND,4CAMC"}

View File

@@ -0,0 +1,16 @@
import type { BaseErrorOptions } from './base.error';
import { BaseError } from './base.error';
export type UnexpectedErrorOptions = Omit<BaseErrorOptions, 'level'> & {
level?: 'error' | 'fatal';
};
/**
* Error that indicates something is wrong in the code: logic mistakes,
* unhandled cases, assertions that fail. These are not recoverable and
* should be brought to developers' attention.
*
* Default level: error
*/
export declare class UnexpectedError extends BaseError {
constructor(message: string, opts?: UnexpectedErrorOptions);
}
//# sourceMappingURL=unexpected.error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"unexpected.error.d.ts","sourceRoot":"","sources":["../../../../src/errors/base/unexpected.error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,sBAA2B;CAK9D"}

View File

@@ -0,0 +1,29 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./base.error"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnexpectedError = void 0;
const base_error_1 = require("./base.error");
/**
* Error that indicates something is wrong in the code: logic mistakes,
* unhandled cases, assertions that fail. These are not recoverable and
* should be brought to developers' attention.
*
* Default level: error
*/
class UnexpectedError extends base_error_1.BaseError {
constructor(message, opts = {}) {
opts.level = opts.level ?? 'error';
super(message, opts);
}
}
exports.UnexpectedError = UnexpectedError;
});
//# sourceMappingURL=unexpected.error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"unexpected.error.js","sourceRoot":"","sources":["../../../../src/errors/base/unexpected.error.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,6CAAyC;IAMzC;;;;;;OAMG;IACH,MAAa,eAAgB,SAAQ,sBAAS;QAC7C,YAAY,OAAe,EAAE,OAA+B,EAAE;YAC7D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;YAEnC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtB,CAAC;KACD;IAND,0CAMC"}

View File

@@ -0,0 +1,18 @@
import type { BaseErrorOptions } from './base.error';
import { BaseError } from './base.error';
export type UserErrorOptions = Omit<BaseErrorOptions, 'level'> & {
level?: 'info' | 'warning';
description?: string | null | undefined;
};
/**
* Error that indicates the user performed an action that caused an error.
* E.g. provided invalid input, tried to access a resource theyre not
* authorized to, or violates a business rule.
*
* Default level: info
*/
export declare class UserError extends BaseError {
readonly description: string | null | undefined;
constructor(message: string, opts?: UserErrorOptions);
}
//# sourceMappingURL=user.error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.error.d.ts","sourceRoot":"","sources":["../../../../src/errors/base/user.error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IAChE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACvC,SAAiB,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;gBAE5C,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB;CAKxD"}

View File

@@ -0,0 +1,29 @@
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./base.error"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserError = void 0;
const base_error_1 = require("./base.error");
/**
* Error that indicates the user performed an action that caused an error.
* E.g. provided invalid input, tried to access a resource theyre not
* authorized to, or violates a business rule.
*
* Default level: info
*/
class UserError extends base_error_1.BaseError {
constructor(message, opts = {}) {
opts.level = opts.level ?? 'info';
super(message, opts);
}
}
exports.UserError = UserError;
});
//# sourceMappingURL=user.error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.error.js","sourceRoot":"","sources":["../../../../src/errors/base/user.error.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,6CAAyC;IAOzC;;;;;;OAMG;IACH,MAAa,SAAU,SAAQ,sBAAS;QAGvC,YAAY,OAAe,EAAE,OAAyB,EAAE;YACvD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;YAElC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtB,CAAC;KACD;IARD,8BAQC"}