@integromat/proto
Version:
Integromat Proto-Classes
480 lines • 17.8 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecutionInterruptedError = exports.DataSizeLimitExceededError = exports.OperationsLimitExceededError = exports.ScenarioTimeoutError = exports.ModuleTimeoutError = exports.DuplicateDataError = exports.IncompleteDataError = exports.MaxFileSizeExceededError = exports.MaxResultsExceededError = exports.UnexpectedError = exports.InvalidAccessTokenError = exports.InvalidConfigurationError = exports.ConnectionError = exports.OutOfSpaceError = exports.RateLimitError = exports.InconsistencyError = exports.DataError = exports.RuntimeError = exports.UnknownError = void 0;
/**
* Unknown Error. Used when non-instanceof-error error happens in program logic.
*
* @param {*} err Original error.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var UnknownError = /** @class */ (function (_super) {
__extends(UnknownError, _super);
function UnknownError(err) {
var _this = _super.call(this) || this;
if ('object' === typeof err) {
Object.assign(_this, err);
_this.message = err.message || '<no message>';
}
else if ('string' === typeof err) {
_this.message = err;
}
_this.name = 'UnknownError';
Object.setPrototypeOf(_this, UnknownError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
UnknownError.prototype.toJSON = function () {
return __assign(__assign({}, this), _super.prototype.toJSON.call(this));
};
return UnknownError;
}(Error));
exports.UnknownError = UnknownError;
/**
* Runtime Error. Used when error happens in program logic, not in invalid data. Flow will be rolled back.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var RuntimeError = /** @class */ (function (_super) {
__extends(RuntimeError, _super);
function RuntimeError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'RuntimeError';
Object.setPrototypeOf(_this, RuntimeError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return RuntimeError;
}(Error));
exports.RuntimeError = RuntimeError;
/**
* Data Error. Used on invalid data. Bundle will be moved to DLQ. Process flow will be commited normally.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var DataError = /** @class */ (function (_super) {
__extends(DataError, _super);
function DataError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'DataError';
Object.setPrototypeOf(_this, DataError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return DataError;
}(Error));
exports.DataError = DataError;
/**
* Inconsistency Error. Used when commit/rollback fails. Process flow stops immediately. Commited data remain commited.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var InconsistencyError = /** @class */ (function (_super) {
__extends(InconsistencyError, _super);
function InconsistencyError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'InconsistencyError';
Object.setPrototypeOf(_this, InconsistencyError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return InconsistencyError;
}(Error));
exports.InconsistencyError = InconsistencyError;
/**
* Rate Limit Error. Used when API rate limit is exceeded.
*
* **IMPORTANT**: Also freezes the scenario for some time.
*
* @param {String} message Error message.
* @param {Number} [delay] Delay in milliseconds. Optional, default is 20 minutes.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
* @property {Number} delay Delay in milliseconds.
*/
var RateLimitError = /** @class */ (function (_super) {
__extends(RateLimitError, _super);
function RateLimitError(message, delay) {
var _this = _super.call(this, message) || this;
_this.name = 'RateLimitError';
Object.setPrototypeOf(_this, RateLimitError.prototype);
_this.delay = delay;
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return RateLimitError;
}(Error));
exports.RateLimitError = RateLimitError;
/**
* Out Of Space Error. Used when service reports out of space.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var OutOfSpaceError = /** @class */ (function (_super) {
__extends(OutOfSpaceError, _super);
function OutOfSpaceError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'OutOfSpaceError';
Object.setPrototypeOf(_this, OutOfSpaceError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return OutOfSpaceError;
}(Error));
exports.OutOfSpaceError = OutOfSpaceError;
/**
* Connection Error. Used when there is a problem with connection to the service.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var ConnectionError = /** @class */ (function (_super) {
__extends(ConnectionError, _super);
function ConnectionError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'ConnectionError';
Object.setPrototypeOf(_this, ConnectionError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return ConnectionError;
}(Error));
exports.ConnectionError = ConnectionError;
/**
* Invalid Configuration Error. Used when configuration is broken and user interaction is required.
*
* **IMPORTANT**: Also disables the scenario.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var InvalidConfigurationError = /** @class */ (function (_super) {
__extends(InvalidConfigurationError, _super);
function InvalidConfigurationError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'InvalidConfigurationError';
Object.setPrototypeOf(_this, InvalidConfigurationError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return InvalidConfigurationError;
}(Error));
exports.InvalidConfigurationError = InvalidConfigurationError;
/**
* Invalid Access Token Error. Used when service access token is expired or invalid.
*
* **IMPORTANT**: Also disables the scenario.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var InvalidAccessTokenError = /** @class */ (function (_super) {
__extends(InvalidAccessTokenError, _super);
function InvalidAccessTokenError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'InvalidAccessTokenError';
Object.setPrototypeOf(_this, InvalidAccessTokenError.prototype);
return _this;
}
return InvalidAccessTokenError;
}(InvalidConfigurationError));
exports.InvalidAccessTokenError = InvalidAccessTokenError;
/**
* Invalid Access Token Error. Used when unexpected things occurs.
*
* **IMPORTANT**: Also disables and lock the scenario. Staff revision is required in order to unlock the scenario.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var UnexpectedError = /** @class */ (function (_super) {
__extends(UnexpectedError, _super);
function UnexpectedError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'UnexpectedError';
Object.setPrototypeOf(_this, UnexpectedError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return UnexpectedError;
}(Error));
exports.UnexpectedError = UnexpectedError;
/**
* Max Results Exceeded Error. Used when limit of results was exceeded.
*
* **IMPORTANT**: Also disables the scenario.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var MaxResultsExceededError = /** @class */ (function (_super) {
__extends(MaxResultsExceededError, _super);
function MaxResultsExceededError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MaxResultsExceededError';
Object.setPrototypeOf(_this, MaxResultsExceededError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return MaxResultsExceededError;
}(Error));
exports.MaxResultsExceededError = MaxResultsExceededError;
/**
* Max File Size Exceeded Error. Used when limit of file size was exceeded.
*
* **IMPORTANT**: Also disables the scenario.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var MaxFileSizeExceededError = /** @class */ (function (_super) {
__extends(MaxFileSizeExceededError, _super);
function MaxFileSizeExceededError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MaxFileSizeExceededError';
Object.setPrototypeOf(_this, MaxFileSizeExceededError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return MaxFileSizeExceededError;
}(Error));
exports.MaxFileSizeExceededError = MaxFileSizeExceededError;
/**
* Incomplete Data Error. Used when received data are incomplete.
*
* @param {String} message Error message.
* @param {Number} [delay] Delay in milliseconds. Optional.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
* @property {Number} delay Delay in milliseconds.
*/
var IncompleteDataError = /** @class */ (function (_super) {
__extends(IncompleteDataError, _super);
function IncompleteDataError(message, delay) {
var _this = _super.call(this, message) || this;
_this.name = 'IncompleteDataError';
Object.setPrototypeOf(_this, IncompleteDataError.prototype);
_this.delay = delay;
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return IncompleteDataError;
}(Error));
exports.IncompleteDataError = IncompleteDataError;
/**
* Duplicate Data Error. Used when service receives duplicate data.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var DuplicateDataError = /** @class */ (function (_super) {
__extends(DuplicateDataError, _super);
function DuplicateDataError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'DuplicateDataError';
Object.setPrototypeOf(_this, DuplicateDataError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return DuplicateDataError;
}(Error));
exports.DuplicateDataError = DuplicateDataError;
/**
* Module Timeout Error. Used when service module operation exceeds time limit.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var ModuleTimeoutError = /** @class */ (function (_super) {
__extends(ModuleTimeoutError, _super);
function ModuleTimeoutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'ModuleTimeoutError';
Object.setPrototypeOf(_this, ModuleTimeoutError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return ModuleTimeoutError;
}(Error));
exports.ModuleTimeoutError = ModuleTimeoutError;
/**
* Scenario Timeout Error. Used when service scenario execution exceeds time limit.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var ScenarioTimeoutError = /** @class */ (function (_super) {
__extends(ScenarioTimeoutError, _super);
function ScenarioTimeoutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'ScenarioTimeoutError';
Object.setPrototypeOf(_this, ScenarioTimeoutError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return ScenarioTimeoutError;
}(Error));
exports.ScenarioTimeoutError = ScenarioTimeoutError;
/**
* Used when processing of a scenario exceeds operations limit.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var OperationsLimitExceededError = /** @class */ (function (_super) {
__extends(OperationsLimitExceededError, _super);
function OperationsLimitExceededError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'OperationsLimitExceededError';
Object.setPrototypeOf(_this, OperationsLimitExceededError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return OperationsLimitExceededError;
}(Error));
exports.OperationsLimitExceededError = OperationsLimitExceededError;
/**
* Used when processing of a scenario exceeds data size limit.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var DataSizeLimitExceededError = /** @class */ (function (_super) {
__extends(DataSizeLimitExceededError, _super);
function DataSizeLimitExceededError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'DataSizeLimitExceededError';
Object.setPrototypeOf(_this, DataSizeLimitExceededError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return DataSizeLimitExceededError;
}(Error));
exports.DataSizeLimitExceededError = DataSizeLimitExceededError;
/**
* Used when execution is interrupted.
*
* @param {String} message Error message.
*
* @property {String} stack Call stack.
* @property {String} message Error message.
*/
var ExecutionInterruptedError = /** @class */ (function (_super) {
__extends(ExecutionInterruptedError, _super);
function ExecutionInterruptedError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'ExecutionInterruptedError';
Object.setPrototypeOf(_this, ExecutionInterruptedError.prototype);
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
return ExecutionInterruptedError;
}(Error));
exports.ExecutionInterruptedError = ExecutionInterruptedError;
/**
* Error JSON serialization.
*/
Object.defineProperty(Error.prototype, 'toJSON', {
enumerable: false,
writable: true,
value: function () {
var json = {
name: this.name,
message: this.message,
stack: this.stack,
};
if (this.hash != null)
json.hash = this.hash;
if (this.bundle != null)
json.bundle = this.bundle;
if (Array.isArray(this.suberrors))
json.suberrors = this.suberrors.map(function (item) { return item; });
if (this.external != null)
json.external = this.external;
if (this.imtInternalError)
json.imtInternalError = this.imtInternalError;
if (this.imtExceptionHash)
json.imtExceptionHash = this.imtExceptionHash;
return json;
},
});
/**
* Hash and imtExceptionHash are the same thing with different names - this keeps them synchronized to just 1 value
*/
Object.defineProperty(Error.prototype, 'imtExceptionHash', {
enumerable: true,
/**
* imt-bluperint does some crazy things and the proto get's loaded multiple times. Without this, it fails on redefinition of the same property
*/
configurable: true,
set: function (newValue) {
this.hash = newValue;
},
get: function () {
return this.hash;
},
});
//# sourceMappingURL=error.js.map