import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import WebSite from "./WebSite.js"; import Index from "@entity-access/entity-access/dist/decorators/Index.js"; import { JsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js"; // we might transfer payment gateway table to integrations... export const integrationTypeArray = ["social-mail-server", "domain-registrar", "payment-gateway"] as const; export type integrationType = typeof integrationTypeArray[number]; @Table("Integrations") @Index({ name: "UX_Integrations_Name", columns: [ { name: (x) => x.storeID, descending: false }, { name: (x) => x.type, descending: false }, { name: (x) => x.name, descending: false } ], unique: true, }) export default class Integration { @Column({ dataType: "BigInt" , key: true, generated: "identity"}) integrationID: number; @Column({ dataType: "BigInt", nullable: true}) @RelateTo(WebSite, { property: (x) => x.store, inverseProperty: (x) => x.integrations }) storeID: number; @Column({ dataType: "Char", length: 50, enum: integrationTypeArray}) type: integrationType; @Column({ dataType: "Char", length: 50}) name: string; @Column({ dataType: "Boolean", default: () => false}) sandbox: boolean; @Column({ dataType: "Char", nullable: true}) description: string; @Column({ dataType: "Char", nullable: true}) clientID: string; @Column({ dataType: "Char", nullable: true}) username: string; @Column({ dataType: "Char", nullable: true}) url: string; @Column({ dataType: "Char", nullable: true}) encryptedSecret: string; /** * This is only an input property. */ @JsonProperty({}) secret: string; store: WebSite; }