UNPKG

nestjs-temporal-core

Version:

Complete NestJS integration for Temporal.io with auto-discovery, declarative scheduling, enhanced monitoring, and enterprise-ready features

50 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ActivityMethod = exports.Activity = void 0; const common_1 = require("@nestjs/common"); const constants_1 = require("../constants"); const Activity = (options) => { return (target) => { const metadata = { ...options, className: target.name, }; (0, common_1.SetMetadata)(constants_1.TEMPORAL_ACTIVITY, metadata)(target); Reflect.defineMetadata(constants_1.TEMPORAL_ACTIVITY, metadata, target); return target; }; }; exports.Activity = Activity; const ActivityMethod = (nameOrOptions) => { return (target, propertyKey, descriptor) => { let activityName; let methodOptions = {}; if (typeof nameOrOptions === 'string') { activityName = nameOrOptions; methodOptions = { name: nameOrOptions }; } else if (nameOrOptions?.name) { activityName = nameOrOptions.name; methodOptions = nameOrOptions; } else { activityName = propertyKey.toString(); methodOptions = { name: activityName }; } const metadata = { name: activityName, methodName: propertyKey.toString(), ...methodOptions, }; if (descriptor?.value) { (0, common_1.SetMetadata)(constants_1.TEMPORAL_ACTIVITY_METHOD, metadata)(descriptor.value); Reflect.defineMetadata(constants_1.TEMPORAL_ACTIVITY_METHOD, metadata, descriptor.value); return descriptor; } else { Reflect.defineMetadata(constants_1.TEMPORAL_ACTIVITY_METHOD, metadata, target, propertyKey); } }; }; exports.ActivityMethod = ActivityMethod; //# sourceMappingURL=activity.decorator.js.map