"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProcessHistory = void 0;
const tslib_1 = require("tslib");
const type_graphql_1 = require("type-graphql");
const typeorm_1 = require("typeorm");
const typeorm_history_1 = require("@operato/typeorm-history");
const auth_base_1 = require("@things-factory/auth-base");
const shell_1 = require("@things-factory/shell");
const env_1 = require("@things-factory/env");
const process_group_1 = require("../process-group/process-group");
const ORMCONFIG = env_1.config.get('ormconfig', {});
const DATABASE_TYPE = ORMCONFIG.type;
let ProcessHistory = class ProcessHistory {
    constructor() {
        this.version = 1;
    }
};
exports.ProcessHistory = ProcessHistory;
tslib_1.__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    (0, type_graphql_1.Field)(type => type_graphql_1.ID),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "id", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true, default: 1 }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Number)
], ProcessHistory.prototype, "version", void 0);
tslib_1.__decorate([
    (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
    (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true }),
    tslib_1.__metadata("design:type", shell_1.Domain)
], ProcessHistory.prototype, "domain", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((process) => process.domain),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "domainId", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)(),
    (0, type_graphql_1.Field)(),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "name", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "description", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({
        nullable: true,
        type: DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
            ? 'longtext'
            : DATABASE_TYPE == 'oracle'
                ? 'clob'
                : 'varchar'
    }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "model", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({
        nullable: true,
        type: DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
            ? 'longtext'
            : DATABASE_TYPE == 'oracle'
                ? 'clob'
                : 'varchar'
    }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "thumbnail", void 0);
tslib_1.__decorate([
    (0, typeorm_1.ManyToOne)(type => process_group_1.ProcessGroup, group => group.processes),
    (0, type_graphql_1.Field)(type => process_group_1.ProcessGroup, { nullable: true }),
    tslib_1.__metadata("design:type", process_group_1.ProcessGroup)
], ProcessHistory.prototype, "group", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((process) => process.group),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "groupId", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], ProcessHistory.prototype, "createdAt", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], ProcessHistory.prototype, "updatedAt", void 0);
tslib_1.__decorate([
    (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
    (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
    tslib_1.__metadata("design:type", auth_base_1.User)
], ProcessHistory.prototype, "creator", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((process) => process.creator),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "creatorId", void 0);
tslib_1.__decorate([
    (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
    (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
    tslib_1.__metadata("design:type", auth_base_1.User)
], ProcessHistory.prototype, "updater", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((process) => process.updater),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "updaterId", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], ProcessHistory.prototype, "deletedAt", void 0);
tslib_1.__decorate([
    (0, typeorm_history_1.HistoryOriginalIdColumn)(),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "originalId", void 0);
tslib_1.__decorate([
    (0, typeorm_history_1.HistoryActionColumn)({
        nullable: false,
        type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
            ? 'enum'
            : DATABASE_TYPE == 'oracle'
                ? 'varchar2'
                : 'smallint',
        enum: typeorm_history_1.HistoryActionType
    }),
    tslib_1.__metadata("design:type", String)
], ProcessHistory.prototype, "action", void 0);
exports.ProcessHistory = ProcessHistory = tslib_1.__decorate([
    (0, typeorm_1.Entity)(),
    (0, typeorm_1.Index)('ix_process_history_0', (processHistory) => [processHistory.originalId, processHistory.version], {
        unique: true
    }),
    (0, type_graphql_1.ObjectType)({ description: 'History Entity of Process' })
], ProcessHistory);
//# sourceMappingURL=process-history.js.map