arvo-event-handler
Version:
A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-me
70 lines (69 loc) • 2.95 kB
JavaScript
;
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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTransactionViolationError = exports.TransactionViolation = exports.TransactionViolationCause = void 0;
var arvo_core_1 = require("arvo-core");
/**
* Enumeration of transaction violation causes for state management operations.
*/
exports.TransactionViolationCause = {
/** Failed to read from machine memory */
READ_FAILURE: 'READ_MACHINE_MEMORY_FAILURE',
/** Failed to acquire lock on machine memory */
LOCK_FAILURE: 'LOCK_MACHINE_MEMORY_FAILURE',
/** Failed to write to machine memory */
WRITE_FAILURE: 'WRITE_MACHINE_MEMORY_FAILURE',
/** Lock acquisition was denied */
LOCK_UNACQUIRED: 'LOCK_UNACQUIRED',
/** Event subject format is invalid */
INVALID_SUBJECT: 'INVALID_SUBJECT',
};
/**
* Error representing failures in orchestrator state transaction operations.
*
* Indicates issues with lock acquisition, state persistence, or memory access
* during orchestration execution. These errors typically trigger retries.
*/
var TransactionViolation = /** @class */ (function (_super) {
__extends(TransactionViolation, _super);
function TransactionViolation(param) {
var _this = _super.call(this, {
type: 'OrchestratorTransaction',
message: "[".concat(param.cause, "] ").concat(param.message),
metadata: {
initiatingEvent: param.initiatingEvent,
},
}) || this;
_this.cause = param.cause;
return _this;
}
return TransactionViolation;
}(arvo_core_1.ViolationError));
exports.TransactionViolation = TransactionViolation;
/**
* Type guard checking if an error is a TransactionViolation.
*
* @param error - Error to check
* @param cause - Optional specific cause to match
* @returns True if error is TransactionViolation with optional matching cause
*/
var isTransactionViolationError = function (error, cause) {
return ((0, arvo_core_1.isViolationError)(error) &&
error.type === 'OrchestratorTransaction' &&
(cause ? error.cause === cause : true));
};
exports.isTransactionViolationError = isTransactionViolationError;