import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import Index from "@entity-access/entity-access/dist/decorators/Index.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import type Mailbox from "./Mailbox.js"; import type { Email } from "./Email.js"; import type EmailRecipient from "./EmailRecipient.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Domain from "./Domain.js"; import type MailboxContact from "./MailboxContact.js"; import type { ContactEmail } from "./Contact.js"; import type SubscriberActivity from "./SubscriberActivity.js"; import type EmailAddressName from "./EmailAddressName.js"; import type StoreAccountEmail from "./StoreAccountEmail.js"; import type ThreadParticipant from "./ThreadParticipant.js"; import type MailboxContactEmail from "./MailboxContactEmail.js"; import type DeliveryStatus from "./DeliveryActivity.js"; @Table("EmailAddresses") @Index({ name: "IX_Unique_EmailAddresses_V2", dropNames: [ "IX_Unique_EmailAddresses"], columns: [{ name: (x) => x.emailAddress, descending : false, operatorClass: "varchar_pattern" }], unique: true }) @Index({ name: "IX_EmailAddresses_Pending_Name_Index", columns: [ { name: (x) => x.emailAddressID, descending: false }], filter: (x) => x.nameIndexed === false }) @Index({ name: "IX_EmailAddresses_Large_Email_Hash", columns: [ { name: (x) => x.largeEmailHash, descending: false }], filter: (x) => x.largeEmailAddress !== null && x.largeEmailHash !== null }) export default class EmailAddress { @Column({ key: true, generated: "identity", dataType: "BigInt"}) public emailAddressID: number; @Column({ dataType: "Char", length: 400}) public emailAddress: string; @Column({ dataType: "Char", nullable: true}) public largeEmailAddress: string; @Column({ dataType: "Char", length: 200, nullable: true}) public largeEmailHash: string; @Column({ dataType: "BigInt" }) @RelateTo(Domain, { property: (ea) => ea.domain, inverseProperty: (d) => d.emailAddresses }) public domainID: number; @Column({ dataType: "Char", length: 400 }) public name: string; @Column({ dataType: "Boolean", default: () => false}) public nameIndexed: boolean; @Column({ dataType: "Boolean", default: () => false}) public blocked: boolean; public mailbox: Mailbox; public senders: Email[]; public recipients: EmailRecipient[]; public domain: Domain; public threads: MailboxContact[]; public contactEmails: ContactEmail[]; public subscriberActivities: SubscriberActivity[]; names: EmailAddressName[]; storeAccounts: StoreAccountEmail[]; threadParticipants: ThreadParticipant[]; mailboxContactEmails: MailboxContactEmail[]; deliveryStatuses: DeliveryStatus[]; }