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
52 lines (51 loc) • 2.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var inputValidation_1 = require("../ArvoOrchestrationUtils/inputValidation");
/**
* Represents an ArvoMachine object that can be consumed by an Arvo orchestrator.
* ArvoMachine encapsulates the logic and metadata required for an Arvo-compatible
* state machine. It combines XState's actor logic with Arvo-specific contracts
* and versioning information.
*
* It is strongly recommended to use `setupArvoMachine(...).createMachine(...)`
* instead of creating this object directly. The setup function provides additional
* type safety and validation that helps prevent runtime errors.
*/
var ArvoMachine = /** @class */ (function () {
function ArvoMachine(id, version, contracts, logic, requiresResourceLocking) {
if (requiresResourceLocking === void 0) { requiresResourceLocking = true; }
this.id = id;
this.version = version;
this.contracts = contracts;
this.logic = logic;
this.requiresResourceLocking = requiresResourceLocking;
}
Object.defineProperty(ArvoMachine.prototype, "source", {
/**
* Gets the event type that this machine accepts, as defined in its contract.
*/
get: function () {
return this.contracts.self.accepts.type;
},
enumerable: false,
configurable: true
});
/**
* Validates an event against the machine's contracts and data schemas.
* Performs validation for both self-contract events and service contract events.
*
* @param event - The event to validate
*
* See {@link validateInputEvent} for more infromation
*/
ArvoMachine.prototype.validateInput = function (event, span) {
return (0, inputValidation_1.validateInputEvent)({
event: event,
selfContract: this.contracts.self,
serviceContracts: this.contracts.services,
span: span,
});
};
return ArvoMachine;
}());
exports.default = ArvoMachine;