UNPKG

@nestjs-cls/transactional

Version:

A nestjs-cls plugin for transactional decorators

64 lines 2.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TransactionNotActiveError = exports.TransactionAlreadyActiveError = exports.TransactionPropagationError = exports.Propagation = void 0; /** * Sets the propagation mode for a transaction. */ var Propagation; (function (Propagation) { /** * (default) Reuse the existing transaction or create a new one if none exists. */ Propagation["Required"] = "REQUIRED"; /** * Create a new transaction even if one already exists. The new transaction is committed independently of the existing one. */ Propagation["RequiresNew"] = "REQUIRES_NEW"; /** * Run without a transaction even if one exists. The existing transaction is resumed once the callback completes. */ Propagation["NotSupported"] = "NOT_SUPPORTED"; /** * Reuse an existing transaction, throw an exception otherwise. */ Propagation["Mandatory"] = "MANDATORY"; /** * Run without a transaction, throw an exception if one already exists. */ Propagation["Never"] = "NEVER"; /** * Reuse the existing transaction or continue without a transaction if none exists. */ Propagation["Supports"] = "SUPPORTS"; })(Propagation || (exports.Propagation = Propagation = {})); /** * Base error for transaction propagation errors. */ class TransactionPropagationError extends Error { constructor() { super(...arguments); this.name = TransactionPropagationError.name; } } exports.TransactionPropagationError = TransactionPropagationError; /** * Error thrown when a attempting to start a transaction in mode NEVER, but an existing transaction is already active. */ class TransactionAlreadyActiveError extends TransactionPropagationError { constructor(methodName) { super(`Trying to start a transaction in mode ${Propagation.Never}, but an existing transaction is already active (for method ${methodName}).`); this.name = TransactionAlreadyActiveError.name; } } exports.TransactionAlreadyActiveError = TransactionAlreadyActiveError; /** * Error thrown when a attempting to start a transaction in mode MANDATORY, but no existing transaction is active. */ class TransactionNotActiveError extends TransactionPropagationError { constructor(methodName) { super(`Trying to start a transaction in mode ${Propagation.Mandatory}, but no existing transaction is active (for method ${methodName}).`); this.name = TransactionNotActiveError.name; } } exports.TransactionNotActiveError = TransactionNotActiveError; //# sourceMappingURL=propagation.js.map