"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationRuleHistory = 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 env_1 = require("@things-factory/env");
const shell_1 = require("@things-factory/shell");
const notification_rule_1 = require("./notification-rule");
const ORMCONFIG = env_1.config.get('ormconfig', {});
const DATABASE_TYPE = ORMCONFIG.type;
let NotificationRuleHistory = class NotificationRuleHistory {
    constructor() {
        this.version = 1;
    }
};
exports.NotificationRuleHistory = NotificationRuleHistory;
tslib_1.__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    (0, type_graphql_1.Field)(type => type_graphql_1.ID),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.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)
], NotificationRuleHistory.prototype, "version", void 0);
tslib_1.__decorate([
    (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
    (0, type_graphql_1.Field)(type => shell_1.Domain),
    tslib_1.__metadata("design:type", shell_1.Domain)
], NotificationRuleHistory.prototype, "domain", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((notificationRule) => notificationRule.domain),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "domainId", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)(),
    (0, type_graphql_1.Field)(),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.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)
], NotificationRuleHistory.prototype, "description", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "state", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "title", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "body", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "url", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "thumbnail", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "channels", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)('simple-json', { nullable: true }),
    (0, type_graphql_1.Field)(type => [notification_rule_1.RecipientItem], { nullable: true, description: 'notification recipients.' }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "recipients", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], NotificationRuleHistory.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)
], NotificationRuleHistory.prototype, "updatedAt", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], NotificationRuleHistory.prototype, "deletedAt", 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)
], NotificationRuleHistory.prototype, "creator", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((notificationRule) => notificationRule.creator),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.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)
], NotificationRuleHistory.prototype, "updater", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((notificationRule) => notificationRule.updater),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "updaterId", void 0);
tslib_1.__decorate([
    (0, typeorm_history_1.HistoryOriginalIdColumn)(),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.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'
                : DATABASE_TYPE == 'mssql'
                    ? 'nvarchar'
                    : 'varchar',
        enum: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
            ? typeorm_history_1.HistoryActionType
            : undefined,
        length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10
    }),
    tslib_1.__metadata("design:type", String)
], NotificationRuleHistory.prototype, "action", void 0);
exports.NotificationRuleHistory = NotificationRuleHistory = tslib_1.__decorate([
    (0, typeorm_1.Entity)(),
    (0, typeorm_1.Index)('ix_notification-rule_history_0', (notificationRuleHistory) => [
        notificationRuleHistory.originalId,
        notificationRuleHistory.version
    ], { unique: true }),
    (0, typeorm_1.Index)('ix_notification-rule_history_1', (notificationRuleHistory) => [
        notificationRuleHistory.domain,
        notificationRuleHistory.originalId,
        notificationRuleHistory.version
    ], { unique: true }),
    (0, type_graphql_1.ObjectType)({ description: 'History Entity of NotificationRule' })
], NotificationRuleHistory);
//# sourceMappingURL=notification-rule-history.js.map