"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SanCertificateEntity = void 0;
const typeorm_1 = require("typeorm");
const cluster_entity_1 = require("../../infrastructure/clusters/entities/cluster.entity");
const cluster_dns_zone_entity_1 = require("./cluster-dns-zone.entity");
const certificate_provider_enum_1 = require("../../providers/enums/certificate-provider.enum");
const certificate_provider_interface_1 = require("../../providers/interfaces/certificate-provider.interface");
const reconciliation_status_enum_1 = require("../../infrastructure/shared/enums/reconciliation-status.enum");
const cert_challenge_enum_1 = require("../enums/cert-challenge.enum");
let SanCertificateEntity = class SanCertificateEntity {
};
exports.SanCertificateEntity = SanCertificateEntity;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'uuid' }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "clusterId", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => cluster_entity_1.ClusterEntity, { onDelete: 'CASCADE' }),
    (0, typeorm_1.JoinColumn)({ name: 'clusterId' }),
    __metadata("design:type", cluster_entity_1.ClusterEntity)
], SanCertificateEntity.prototype, "cluster", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "clusterDnsZoneId", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => cluster_dns_zone_entity_1.ClusterDnsZoneEntity, {
        nullable: true,
        eager: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'clusterDnsZoneId' }),
    __metadata("design:type", cluster_dns_zone_entity_1.ClusterDnsZoneEntity)
], SanCertificateEntity.prototype, "clusterDnsZone", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar' }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'simple-array' }),
    __metadata("design:type", Array)
], SanCertificateEntity.prototype, "dnsNames", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: cert_challenge_enum_1.CertChallenge,
        default: cert_challenge_enum_1.CertChallenge.HTTP_01,
    }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "certChallenge", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: certificate_provider_enum_1.CertificateProvider,
        default: certificate_provider_enum_1.CertificateProvider.LETS_ENCRYPT,
    }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "certificateProvider", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', default: 'flui-system' }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "masterNamespace", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar' }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "masterCertName", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar' }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "masterSecretName", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar' }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "issuerName", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: certificate_provider_interface_1.CertificateStatus,
        default: certificate_provider_interface_1.CertificateStatus.PENDING,
    }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: reconciliation_status_enum_1.ReconciliationStatus,
        default: reconciliation_status_enum_1.ReconciliationStatus.PENDING,
    }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "reconciliationStatus", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], SanCertificateEntity.prototype, "notAfter", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], SanCertificateEntity.prototype, "renewalTime", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], SanCertificateEntity.prototype, "lastReconciliationAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SanCertificateEntity.prototype, "errorMessage", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
    __metadata("design:type", Date)
], SanCertificateEntity.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ type: 'timestamptz' }),
    __metadata("design:type", Date)
], SanCertificateEntity.prototype, "updatedAt", void 0);
exports.SanCertificateEntity = SanCertificateEntity = __decorate([
    (0, typeorm_1.Entity)('san_certificates'),
    (0, typeorm_1.Index)(['clusterId', 'name'], { unique: true })
], SanCertificateEntity);
