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
31 lines (30 loc) • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateAndParseSubject = void 0;
var arvo_core_1 = require("arvo-core");
/**
* Validates and parses an orchestration event's subject.
*
* Ensures the event subject is valid and matches the expected orchestrator source.
* Returns null if validation fails, allowing graceful handling of mismatched events.
*
* @returns Parsed subject content or null if validation fails
*/
var validateAndParseSubject = function (event, expectedSource, syncEventResource, span, handlerType) {
var _a;
syncEventResource.validateEventSubject(event, span);
var parsedEventSubject = arvo_core_1.ArvoOrchestrationSubject.parse(event.subject);
span.setAttributes((_a = {},
_a["arvo.parsed.subject.".concat(handlerType, ".name")] = parsedEventSubject.orchestrator.name,
_a["arvo.parsed.subject.".concat(handlerType, ".version")] = parsedEventSubject.orchestrator.version,
_a));
if (parsedEventSubject.orchestrator.name !== expectedSource) {
(0, arvo_core_1.logToSpan)({
level: 'WARNING',
message: "Event subject mismatch - expected '".concat(expectedSource, "' but got '").concat(parsedEventSubject.orchestrator.name, "'"),
}, span);
return null;
}
return parsedEventSubject;
};
exports.validateAndParseSubject = validateAndParseSubject;