UNPKG

@dolittle/sdk.events.handling

Version:

Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.

28 lines 2.62 kB
"use strict"; // Copyright (c) Dolittle. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. Object.defineProperty(exports, "__esModule", { value: true }); exports.getHandlesDecoratedMethods = exports.handles = void 0; const sdk_common_1 = require("@dolittle/sdk.common"); const HandlesDecoratedMethod_1 = require("./HandlesDecoratedMethod"); const [decorator, getMetadata] = sdk_common_1.Decorators.createMetadataDecorator('event-handler-handles-methods', 'handles', sdk_common_1.Decorators.DecoratorTarget.Method); function handles(typeOrId, generation) { return decorator((target, type, propertyKey, descriptorOrIndex, handlesDecoratedMethods) => { const methods = handlesDecoratedMethods || []; const methodName = propertyKey; const method = descriptorOrIndex.value; methods.push(new HandlesDecoratedMethod_1.HandlesDecoratedMethod(type, typeOrId, generation, method, methodName)); return methods; }); } exports.handles = handles; /** * Gets the decorated event handler handles methods of the specified class. * @param {Constructor<any>} type - The class to get the decorated event handler handles methods for. * @returns {HandlesDecoratedMethod[]} The decorated event handler handles methods. */ function getHandlesDecoratedMethods(type) { return getMetadata(type) || []; } exports.getHandlesDecoratedMethods = getHandlesDecoratedMethods; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlc0RlY29yYXRvci5qcyIsInNvdXJjZVJvb3QiOiIuLi8iLCJzb3VyY2VzIjpbIkJ1aWxkZXJzL2hhbmRsZXNEZWNvcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLCtDQUErQztBQUMvQyxxR0FBcUc7OztBQUtyRyxxREFBa0Q7QUFJbEQscUVBQWtFO0FBRWxFLE1BQU0sQ0FBQyxTQUFTLEVBQUUsV0FBVyxDQUFDLEdBQUcsdUJBQVUsQ0FBQyx1QkFBdUIsQ0FBMkIsK0JBQStCLEVBQUUsU0FBUyxFQUFFLHVCQUFVLENBQUMsZUFBZSxDQU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