"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Properties = void 0;
const types_1 = require("../types");
class Properties {
    constructor() {
        this.moduleName = '';
        this.properties = [];
        this.timestampFields = ['createdAt', 'updatedAt', 'deletedAt'];
        this.deletedAtField = ['deletedAt'];
    }
    *[Symbol.iterator]() {
        for (const property of this.properties)
            yield property;
    }
    get length() {
        return this.properties.length;
    }
    get hasI18n() {
        return this.properties.some(property => property.isI18n);
    }
    get hasEnum() {
        return this.properties.some(property => property.type === types_1.SqlType.ENUM);
    }
    get hasIndex() {
        return this.properties.some(property => property.index === types_1.SqlIndex.INDEX || property.index === types_1.SqlIndex.UNIQUE);
    }
    get withoutTimestamps() {
        return this.properties.filter(property => !this.timestampFields.includes(property.name));
    }
    get withoutDeletedAt() {
        return this.properties.filter(property => !this.deletedAtField.includes(property.name));
    }
    /***************************************************
     * get relationship for import to avoid duplicates *
     ***************************************************/
    get withImportRelationshipOneToOne() {
        return this.properties
            // avoid duplicate self relations
            .filter((value, index, self) => index === self.findIndex(t => (t.relationshipModulePath === value.relationshipModulePath && t.relationshipAggregate === value.relationshipAggregate)))
            .filter(property => property.relationship === types_1.SqlRelationship.ONE_TO_ONE);
    }
    get withImportRelationshipManyToOne() {
        return this.properties
            // avoid duplicate self relations
            .filter((value, index, self) => index === self.findIndex(t => (t.relationshipModulePath === value.relationshipModulePath && t.relationshipAggregate === value.relationshipAggregate)))
            .filter(property => property.relationship === types_1.SqlRelationship.MANY_TO_ONE);
    }
    get withImportRelationshipOneToMany() {
        return this.properties
            // avoid duplicate self relations
            .filter((value, index, self) => index === self.findIndex(t => (t.relationshipModulePath === value.relationshipModulePath && t.relationshipAggregate === value.relationshipAggregate)))
            .filter(property => property.relationship === types_1.SqlRelationship.ONE_TO_MANY);
    }
    get withImportRelationshipManyToMany() {
        return this.properties
            // avoid duplicate self relations
            .filter((value, index, self) => index === self.findIndex(t => (t.relationshipModulePath === value.relationshipModulePath && t.relationshipAggregate === value.relationshipAggregate)))
            .filter(property => property.relationship === types_1.SqlRelationship.MANY_TO_MANY);
    }
    /****************
     * RELATIONSHIP *
     ****************/
    get withRelationship() {
        return this.properties.filter(property => property.relationship);
    }
    get withRelationshipOneToOne() {
        return this.properties.filter(property => property.relationship === types_1.SqlRelationship.ONE_TO_ONE);
    }
    get withRelationshipOneToOneWithRelationshipField() {
        return this.withRelationshipOneToOne.filter(property => Boolean(property.relationshipField));
    }
    get withRelationshipOneToOneWithoutRelationshipField() {
        return this.withRelationshipOneToOne.filter(property => !property.relationshipField);
    }
    get withRelationshipManyToOne() {
        return this.properties
            .filter(property => property.relationship === types_1.SqlRelationship.MANY_TO_ONE);
    }
    get withRelationshipOneToMany() {
        return this.properties.filter(property => property.relationship === types_1.SqlRelationship.ONE_TO_MANY);
    }
    get withRelationshipManyToMany() {
        return this.properties.filter(property => property.relationship === types_1.SqlRelationship.MANY_TO_MANY);
    }
    get withRelationshipType() {
        return this.properties.filter(property => property.type === types_1.SqlType.RELATIONSHIP);
    }
    get withTimezone() {
        return this.properties.filter(property => property.hasTimezone);
    }
    get id() {
        return this.properties.find(property => property.type === types_1.SqlType.ID);
    }
    /*************
     * DASHBOARD *
     *************/
    get gridFields() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name))
            .filter(property => property.name !== 'id');
    }
    get formDetailFields() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name))
            .filter(property => property.name !== 'id');
    }
    get formGroupFields() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name));
    }
    /*************
     * AGGREGATE *
     *************/
    get aggregate() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    /************
     * COMMANDS *
     ************/
    get createCommand() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get updateCommand() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get upsertCommand() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    /********************
     * COMMAND HANDLERS *
     ********************/
    get createCommandHandler() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get updateCommandHandler() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get upsertCommandHandler() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    /********************
     * QUERY HANDLERS *
     ********************/
    get findQueryHandler() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY); // exclude one to many relations
    }
    get findByIdQueryHandler() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY); // exclude one to many relations
    }
    get getQueryHandler() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY); // exclude one to many relations
    }
    /************
     * SERVICES *
     ************/
    get createService() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get createItemsService() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')); // exclude relationship id of i18n table
    }
    get updateService() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get upsertService() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')); // exclude relationship id of i18n table
    }
    // events
    get createdEvent() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get updatedEvent() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get deletedEvent() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    /***************
     * CONTROLLERS *
     ***************/
    get createController() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get updateController() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    // resolvers
    get createResolver() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get updateResolver() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    /***********
     * GRAPHQL *
     ***********/
    get graphqlProperties() {
        return this.properties;
    }
    get graphqlInputProperties() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)); // exclude timestamps
    }
    /********
     * REST *
     ********/
    get dtoProperties() {
        return this.properties;
    }
    get dtoInputProperties() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)); // exclude timestamps
    }
    /**********
     * MODELS *
     **********/
    get modelColumns() {
        return this.properties; // exclude one to many relations
    }
    get schemaRelations() {
        return this.properties.filter(property => property.relationship); // only relationship
    }
    get columnsWithIndex() {
        return this.properties.filter(property => property.index); // only properties with index defined
    }
    /***********
     * POSTMAN *
     ***********/
    get postmanGraphQLCreateQuery() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get postmanGraphQLCreateVariables() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get postmanGraphQLGetQuery() {
        return this.properties
            .filter(property => !this.deletedAtField.includes(property.name)) // exclude deleteAt
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_ONE) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get postmanGraphQLFindQuery() {
        return this.properties
            .filter(property => !this.deletedAtField.includes(property.name)) // exclude deleteAt
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_ONE) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get postmanGraphQLFindByIdQuery() {
        return this.properties
            .filter(property => !this.deletedAtField.includes(property.name)) // exclude deleteAt
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_ONE) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get postmanGraphQLUpdateQuery() {
        return this.properties
            .filter(property => !this.deletedAtField.includes(property.name)) // exclude deleteAt
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_ONE) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get postmanGraphQLUpdateVariables() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to one relations without relationshipField, is relation one to one without xxxxId
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang'));
    }
    get postmanGraphQLDeleteQuery() {
        return this.properties
            .filter(property => !this.deletedAtField.includes(property.name)) // exclude deleteAt
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_ONE) // exclude one to many relations
            .filter(property => property.relationship !== types_1.SqlRelationship.MANY_TO_MANY) // exclude many to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get postmanRestCreate() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to many relations
    }
    get postmanRestUpdate() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to many relations
    }
    /***********
     * TESTING *
     ***********/
    get test() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)) // exclude one to many relations
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get isNotNullable() {
        return this.properties.filter(property => property.nullable === false)
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get hasLength() {
        return this.properties.filter(property => !!property.length)
            .filter(property => !property.isI18n || (property.isI18n && property.name !== 'id')) // exclude id of i18n table
            .filter(property => !property.isI18n || (property.isI18n && property.name !== this.moduleName.toCamelCase() + 'Id')) // exclude relationship id of i18n table
            .filter(property => !this.hasI18n || (this.hasI18n && property.name !== 'dataLang')); // exclude dataLang if has i18n table
    }
    get hasMaxLength() {
        return this.properties.filter(property => !!property.maxLength);
    }
    get hasMinLength() {
        return this.properties.filter(property => !!property.minLength);
    }
    get isDecimal() {
        return this.properties.filter(property => property.type === types_1.SqlType.DECIMAL);
    }
    get isInteger() {
        return this.properties.filter(property => property.type === types_1.SqlType.INT);
    }
    get isIntegerUnsigned() {
        return this.properties.filter(property => property.type === types_1.SqlType['INT.UNSIGNED']);
    }
    get isBoolean() {
        return this.properties.filter(property => property.type === types_1.SqlType.BOOLEAN);
    }
    get isEnum() {
        return this.properties.filter(property => property.type === types_1.SqlType.ENUM);
    }
    get isTimestamp() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.type === types_1.SqlType.TIMESTAMP);
    }
    /**********
     * OTHERS *
     **********/
    get valueObjects() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to many relations
    }
    get response() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to many relations
    }
    get seed() {
        return this.properties
            .filter(property => !this.timestampFields.includes(property.name)) // exclude timestamps
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get mapper() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    get mock() {
        return this.properties
            .filter(property => property.relationship !== types_1.SqlRelationship.ONE_TO_MANY) // exclude one to many relations
            .filter(property => !(property.relationship === types_1.SqlRelationship.ONE_TO_ONE && !property.relationshipField)); // exclude one to one relations without relationshipField, is relation one to one without xxxxId
    }
    getForeignRelationship(boundedContextName) {
        return this.withRelationship.filter(item => {
            if (!item.relationshipModulePath)
                return false;
            return item.relationshipModulePath.split('/')[0] !== boundedContextName;
        });
    }
    add(property) {
        this.properties.push(property);
    }
    filter(fn) {
        return this.properties.filter(fn);
    }
    toDto() {
        return this.properties.map(property => property.toDto());
    }
}
exports.Properties = Properties;
