"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("root/services/util");
class Route {
    static parseFromText(text) {
        const route = new Route();
        const params = text
            .split('/')
            .filter(p => p !== '')
            .map(p => {
            if (p[0] === '{') {
                return '{' + util_1.camelCaseToDash(p
                    .replace('{', '')
                    .replace('}', '')) + '}';
            }
            return p;
        });
        route.params = params;
        return route;
    }
    get endpointRoute() {
        return '/' + this.functionPath;
    }
    get folderName() {
        const params = [
            ...this.params,
        ];
        const models = params
            .filter(p => p[0] !== '{');
        const variables = params
            .filter(p => p[0] === '{')
            .map(p => p.replace('{', '').replace('}', ''));
        return `${models.join('-')}${variables.length ? '-by-' : ''}${variables.join('-and-')}`;
    }
    get functionName() {
        const params = [
            ...this.params,
        ];
        const models = params
            .filter(p => p[0] !== '{')
            .map(p => p
            .split('-')
            .map(p => util_1.capitalize(p))
            .join(''));
        const variables = params
            .filter(p => p[0] === '{')
            .map(p => p
            .replace('{', '')
            .replace('}', '')
            .split('-')
            .map(p => util_1.capitalize(p))
            .join(''));
        return `${models.join('')}${variables.length ? 'By' : ''}${variables.join('And')}`;
    }
    get functionPath() {
        const params = [
            ...this.params,
        ];
        return params
            .map(p => {
            if (p[0] === '{') {
                return `{${p
                    .replace('{', '')
                    .replace('}', '')
                    .split('-')
                    .map((p2, index) => !index ? p2 : util_1.capitalize(p2))
                    .join('')}}`;
            }
            return p;
        })
            .join('/');
    }
    toString() {
        return this.endpointRoute;
    }
    toJSON() {
        return this.endpointRoute;
    }
}
exports.default = Route;
//# sourceMappingURL=index.js.map