"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationRule = exports.RecipientItem = exports.NotificationRuleStatus = void 0;
const tslib_1 = require("tslib");
const typeorm_1 = require("typeorm");
const type_graphql_1 = require("type-graphql");
const shell_1 = require("@things-factory/shell");
const auth_base_1 = require("@things-factory/auth-base");
const organization_1 = require("@things-factory/organization");
var NotificationRuleStatus;
(function (NotificationRuleStatus) {
    NotificationRuleStatus["DRAFT"] = "DRAFT";
    NotificationRuleStatus["RELEASED"] = "RELEASED";
})(NotificationRuleStatus || (exports.NotificationRuleStatus = NotificationRuleStatus = {}));
(0, type_graphql_1.registerEnumType)(NotificationRuleStatus, {
    name: 'NotificationRuleStatus',
    description: 'state enumeration of a notificationRule'
});
let RecipientItem = class RecipientItem {
};
exports.RecipientItem = RecipientItem;
tslib_1.__decorate([
    (0, type_graphql_1.Field)(type => organization_1.OrgMemberTargetType, { nullable: true }),
    tslib_1.__metadata("design:type", String)
], RecipientItem.prototype, "type", void 0);
tslib_1.__decorate([
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], RecipientItem.prototype, "value", void 0);
tslib_1.__decorate([
    (0, type_graphql_1.Field)(type => organization_1.OrgMemberTarget, { nullable: true }),
    tslib_1.__metadata("design:type", organization_1.OrgMemberTarget)
], RecipientItem.prototype, "recipient", void 0);
exports.RecipientItem = RecipientItem = tslib_1.__decorate([
    (0, type_graphql_1.ObjectType)()
], RecipientItem);
let NotificationRule = class NotificationRule {
    constructor() {
        this.version = 1;
    }
};
exports.NotificationRule = NotificationRule;
tslib_1.__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    (0, type_graphql_1.Field)(type => type_graphql_1.ID),
    tslib_1.__metadata("design:type", String)
], NotificationRule.prototype, "id", void 0);
tslib_1.__decorate([
    (0, typeorm_1.VersionColumn)(),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Number)
], NotificationRule.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)
], NotificationRule.prototype, "domain", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((notificationRule) => notificationRule.domain),
    tslib_1.__metadata("design:type", String)
], NotificationRule.prototype, "domainId", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)(),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", String)
], NotificationRule.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)
], NotificationRule.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)
], NotificationRule.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)
], NotificationRule.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)
], NotificationRule.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)
], NotificationRule.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)
], NotificationRule.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)
], NotificationRule.prototype, "channels", void 0);
tslib_1.__decorate([
    (0, typeorm_1.Column)('simple-json', { nullable: true }),
    (0, type_graphql_1.Field)(type => [RecipientItem], { nullable: true, description: 'notification recipients.' }),
    tslib_1.__metadata("design:type", String)
], NotificationRule.prototype, "recipients", void 0);
tslib_1.__decorate([
    (0, typeorm_1.CreateDateColumn)(),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], NotificationRule.prototype, "createdAt", void 0);
tslib_1.__decorate([
    (0, typeorm_1.UpdateDateColumn)(),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], NotificationRule.prototype, "updatedAt", void 0);
tslib_1.__decorate([
    (0, typeorm_1.DeleteDateColumn)(),
    (0, type_graphql_1.Field)({ nullable: true }),
    tslib_1.__metadata("design:type", Date)
], NotificationRule.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)
], NotificationRule.prototype, "creator", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((notificationRule) => notificationRule.creator),
    tslib_1.__metadata("design:type", String)
], NotificationRule.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)
], NotificationRule.prototype, "updater", void 0);
tslib_1.__decorate([
    (0, typeorm_1.RelationId)((notificationRule) => notificationRule.updater),
    tslib_1.__metadata("design:type", String)
], NotificationRule.prototype, "updaterId", void 0);
exports.NotificationRule = NotificationRule = tslib_1.__decorate([
    (0, typeorm_1.Entity)(),
    (0, typeorm_1.Index)('ix_notification_rule_0', (notificationRule) => [notificationRule.domain, notificationRule.name, notificationRule.deletedAt], { unique: true }),
    (0, type_graphql_1.ObjectType)({ description: 'Entity for NotificationRule' })
], NotificationRule);
//# sourceMappingURL=notification-rule.js.map