import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import { RelateTo, RelateToOne } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import AppFile from "./AppFile.js"; import { JsonProperty, ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js"; import Index from "@entity-access/entity-access/dist/decorators/Index.js"; import type ServerActivity from "./ServerActivity.js"; import type { StoreTag } from "./StoreTag.js"; import type { StoreAccount } from "./StoreAccount.js"; import type { StoreInsight } from "./StoreInsight.js"; import type { StoreItem } from "./StoreItem.js"; import type { StoreItemFolder } from "./StoreItemFolder.js"; import type { StoreJournal } from "./StoreJournal.js"; import type { StoreConfig } from "./StoreConfig.js"; import type StoreCoupon from "./StoreCoupon.js"; import type WebHook from "./WebHook.js"; import type { WebSiteChannelDomain } from "./WebSiteChannelDomain.js"; import type { WebSiteChannel } from "./WebSiteChannel.js"; import type { WebSiteVersion } from "./WebSiteVersion.js"; import type { WebSiteHost } from "./WebSiteHost.js"; import type WebSiteTag from "./WebSiteTag.js"; import DateTime from "@entity-access/entity-access/dist/types/DateTime.js"; import type StoreSubscription from "./StoreSubscription.js"; import type SubscriptionWebSite from "./SubscriptionWebSite.js"; import type Integration from "./Integration.js"; // import type { User } from "./User.js"; /** * Index Designs... * * For most setups, designs and templates will be empty, so indexes will not take up any space. * * For Social Mail's main hosting (esocialmail.com), these indexes will be useful to serve tools and templates. */ @Table("WebSites") @Index({ name: "IX_WebSite_All_Templates", columns: [ { name: (x) => x.description, descending: true } ], filter: (x) => x.isTemplate === true }) @Index({ name: "IX_WebSite_All_Designs", columns: [ { name: (x) => x.description, descending: true } ], filter: (x) => x.isDesign === true }) @Index({ name: "IX_WebSite_Published_Designs_V2", columns: [ { name: (x) => x.templateSites, descending: true } ], include: [ (x) => x.folderID ], filter: (x) => x.isDesign === true && x.currentVersionID !== null }) @Index({ name: "IX_WebSite_Published_Templates_V2", columns: [ { name: (x) => x.templateSites, descending: true } ], include: [ (x) => x.folderID ], filter: (x) => x.isTemplate === true && x.currentVersionID !== null }) @Index({ name: "IX_WebSite_Published_Designs_V2", columns: [ { name: (x) => x.templateSites, descending: true } ], include: [ (x) => x.folderID ], filter: (x) => x.isDesign === true && x.currentVersionID !== null }) @Index({ name: "IX_WebSite_Pending_Preview_Generation", columns: [ { name: (x) => x.previewGenerated, descending: false } ], include: [ (x) => x.folderID ], filter: (x) => x.previewGenerated === false && x.currentVersionID !== null && x.isSuspended === false && x.remoteUrl === null }) export default class WebSite { @Column({ dataType: "BigInt", key: true }) @RelateToOne(AppFile, { property: (x) => x.folder, inverseProperty: (x) => x.websiteFolder, foreignKeyConstraint: { name: "FC_WebSite_FolderID", onDelete: "restrict" } }) public folderID: number; @Column({ dataType: "BigInt", nullable: true }) @RelateTo(AppFile, { property: (x) => x.currentVersion, inverseProperty: (x) => x.currentVersionWebSites, foreignKeyConstraint: { name: "FC_WebSite_CurrentVersionID", onDelete: "restrict" } }) public currentVersionID: number; /** * Icon path must be real path in website, that * will be injected in headers for favicon placements. */ @Column({ dataType: "Char", length: 500, nullable: true }) public icon: string; @Column({ dataType: "Boolean", default:() => true }) public isStatic: boolean; /** Is this website used as a template for other website? */ @Column({ dataType: "Boolean", default:() => false }) public isTemplate: boolean; @Column({ dataType: "Boolean", default:() => false }) public hasEmailTemplates?: boolean; @Column({ dataType: "Boolean", default:() => false }) public isDesign: boolean; @Column({ dataType: "Boolean", default: () => false}) public isSuspended: boolean; @Column({ dataType: "Int", default: () => 0 }) public templateSites: number; @Column({ dataType: "Int", default: () => 0 }) public templateRank: number; @Column({ dataType: "Char", length: 1024, nullable: true }) public remoteUrl: string; @Column({ dataType: "Char", length: 200, nullable: true }) public title: string; @Column({ dataType: "Boolean", default:() => false}) @ReadOnlyJsonProperty public storeEnabled: boolean; @Column({ dataType: "Double", nullable: true}) public pageReadyDelayMS: number; @Column({ dataType: "Char", length: 450, nullable: true }) public description: string; @JsonProperty({}) public templateID: number; /** * Will be set true when any file below listed folder id is modified */ @Column({ dataType: "Boolean", default: () => false }) public isModified: boolean; @Column({ dataType: "DateTime", nullable: true }) public lastModified: DateTime; @Column({ dataType: "BigInt", nullable: true}) public lastModifiedByUserID: number; @Column({ dataType:"BigInt", default: () => 0}) public snapshotStorage: number; @Column({ dataType:"Char", length: 200, nullable: true}) public supportEmail: string; @Column({ dataType:"Char", length: 200, nullable: true}) public fromEmail: string; @Column({ dataType: "Char", length: 200, nullable: true}) public emailBCC: string; @Column({ dataType:"Char", length: 10, default: () => "USD"}) public currency: string; @Column({ dataType:"Char", length: 10, default: () => "US"}) public countryCode: string; @Column({ dataType: "Char", length: 16, nullable: true}) public invoicePrefix: string; @Column({ dataType: "BigInt", default: () => 1}) public nextInvoiceID: number; @Column({ dataType: "Char", nullable: true}) storeDefaultNameServers: string; @Column({ dataType: "Char", nullable: true}) storeDomainProviders: string; @Column({ dataType: "Char", nullable: true }) cacheKey: string; @Column({ dataType: "Boolean", default: () => false }) previewGenerated: boolean; @Column({ dataType: "Char", nullable: true}) preview: string; @Column({ dataType: "Char", nullable: true}) previewMobile: string; @Column({ dataType: "Char", nullable: true}) previewAnimated: string; @Column({ dataType: "Char", nullable: true}) previewAnimatedMobile: string; public folder: AppFile; currentVersion: AppFile; hosts: WebSiteHost[]; versions: WebSiteVersion[]; channels: WebSiteChannel[]; activities: ServerActivity[]; tags: StoreTag[]; storeAccounts: StoreAccount[]; insights: StoreInsight[]; storeItems: StoreItem[]; itemFolders: StoreItemFolder[]; journals: StoreJournal[]; configs: StoreConfig[]; coupons: StoreCoupon[]; webHooks: WebHook[]; channelDomains: WebSiteChannelDomain[]; webSiteTags: WebSiteTag[]; subscriptions: StoreSubscription[]; subscriptionWebSites: SubscriptionWebSite[]; integrations: Integration[]; // storeUsers: User[]; }