"use strict";
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryHandler = void 0;
const Constants_1 = require("../Constants");
const tsyringe_1 = require("tsyringe");
/**
 * This decorator determines that a class is a query handler
 *
 * The decorated class must implement the `QueryHandler` interface.
 *
 * @param query query *type* to be handled by this handler.
 */
const QueryHandler = (query) => {
    return (target) => {
        (0, tsyringe_1.injectable)()(target);
        if (!Reflect.hasMetadata(Constants_1.QUERY_METADATA, query)) {
            Reflect.defineMetadata(Constants_1.QUERY_METADATA, { id: crypto.randomUUID() }, query);
        }
        Reflect.defineMetadata(Constants_1.QUERY_HANDLER_METADATA, query, target);
    };
};
exports.QueryHandler = QueryHandler;
