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 AppFileTag from "./AppFileTag.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Sql from "@entity-access/entity-access/dist/sql/Sql.js"; import type { ContactTag } from "./Contact.js"; import { ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js"; import type MailboxContactTag from "./MailboxContactTag.js"; import type EmailTag from "./EmailTag.js"; import type { StoreItemTag } from "./StoreItemTag.js"; import type { StoreItemFolderTag } from "./StoreItemFolderTag.js"; import type { StoreTag } from "./StoreTag.js"; import type MailboxFolder from "./MailboxFolder.js"; import type MailboxTag from "./MailboxTag.js"; import type WebSiteTag from "./WebSiteTag.js"; import type MailboxContact from "./MailboxContact.js"; /** * The reason tags table exists in form of string,bigint pair is, we need * to reduce the storage. Storing individual tag with string in file/email * will be very expensive, and tags are expected to be case insensitive. */ @Table("Tags") @Index({ name: "IX_Unique_Tags", columns: [{ name: (x) => x.lowerCaseName, descending: false }, { name: (x) => x.parentID, descending: false }], unique: true }) @Index({ name: "IX_Tag_Path", columns: [{ name: (x) => x.path, descending: false }], filter: (x) => x.path !== null }) export default class Tag { @Column({ key: true, dataType: "BigInt", generated: "identity" }) public tagID: number; @Column({ dataType: "Char", length: 200}) public name: string; @Column({ dataType: "Char", length: 200}) public label: string; @Column({ dataType: "Char", length: 200, computed: (x) => Sql.text.lower(x.name)}) @ReadOnlyJsonProperty public lowerCaseName: string; @Column({ dataType: "AsciiChar", length: 400, nullable: true }) public path: string; @Column({ dataType: "Boolean", default: () => false }) public isSystemTag: boolean; @Column({ dataType:"Char", nullable: true}) public contentTypes: string; @Column({ dataType: "BigInt", nullable: true }) @RelateTo(Tag, { property: (t) => t.parent, inverseProperty: (t) => t.children }) public parentID: number; public emailTags: EmailTag[]; public mailboxContactTags: MailboxContactTag[]; public fileTags: AppFileTag[]; public parent: Tag; public children: Tag[]; public contactTags: ContactTag[]; public storeItemTags: StoreItemTag[]; storeTags: StoreTag[]; storeItemFolderTags: StoreItemFolderTag[]; mailboxFolders: MailboxFolder[]; mailboxTags: MailboxTag[]; webSiteTags: WebSiteTag[]; mailboxContacts: MailboxContact[]; }