import vine from '@vinejs/vine';
import _ from 'lodash';
import { HandlerMetaData } from '../../lib/handler_metadata.js';
const _SYMBOLS = {
    requestQueryParameters: Symbol('Vine request query parameters schema & validator'),
    requestSchema: Symbol('Vine request schema & validator'),
    responseSchema: Symbol('Vine response schema & validator'),
    responseErrors: Symbol('Vine response possible errors'),
    responseStatusCode: Symbol('Vine response status code'),
};
export class AKVineHandlerMetaData {
    static getRequestQueryParameters(handler) {
        return this.#getMetaDataOfHandler(handler, 'requestQueryParameters');
    }
    static setRequestQueryParameters(target, propertyName, schema) {
        this.#setMetaDataOfHandler(target, propertyName, schema, 'requestQueryParameters', true);
    }
    static getRequestSchema(handler) {
        return this.#getMetaDataOfHandler(handler, 'requestSchema');
    }
    static setRequestSchema(target, propertyName, schema) {
        this.#setMetaDataOfHandler(target, propertyName, schema, 'requestSchema', true);
    }
    static getResponseSchema(handler) {
        return this.#getMetaDataOfHandler(handler, 'responseSchema');
    }
    static setResponseSchema(target, propertyName, schema) {
        this.#setMetaDataOfHandler(target, propertyName, schema, 'responseSchema', true);
    }
    static getResponseStatusCode(handler) {
        return this.#getMetaDataOfHandler(handler, 'responseStatusCode');
    }
    static setResponseStatusCode(target, propertyName, statusCode) {
        this.#setMetaDataOfHandler(target, propertyName, statusCode, 'responseStatusCode', false);
    }
    static getResponseErrors(handler) {
        return this.#getMetaDataOfHandler(handler, 'responseErrors');
    }
    static setResponseErrors(target, propertyName, errors) {
        this.#setMetaDataOfHandler(target, propertyName, errors, 'responseErrors', false);
    }
    static #setMetaDataOfHandler(target, propertyName, data, type, isSchema = true) {
        const handler = { reference: [target.constructor, propertyName] };
        return HandlerMetaData.setMetaDataOfHandler(handler, _SYMBOLS[type], isSchema
            ? {
                schema: data,
                validator: _.isEmpty(data) ? undefined : vine.compile(data),
            }
            : data);
    }
    static #getMetaDataOfHandler(handler, type) {
        return HandlerMetaData.getMetaDataOfHandler(handler, _SYMBOLS[type]);
    }
}
//# sourceMappingURL=vine_handler_metadata.js.map