import CheckConstraint from "@entity-access/entity-access/dist/decorators/CheckConstraint.js"; 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 { ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js"; import AppFile from "./AppFile.js"; import { StoreItem } from "./StoreItem.js"; @Table("StoreMediaFiles") @CheckConstraint({ name: "CX_StoreMediaFiles", filter: (x) => x.appFileID !== null || x.fileLink !== null }) export class StoreMediaFile { @Column({ dataType: "BigInt", key: true }) @RelateTo(StoreItem, { property: (x) => x.storeItem, inverseProperty: (x) => x.mediaFiles }) storeItemID: number; @Column({ dataType: "BigInt", key: true }) @RelateTo(AppFile, { property: (x) => x.appFile, inverseProperty: (x) => x.storeMediaFiles, foreignKeyConstraint: { name: "FK_StoreMediaFiles_AppFileID", onDelete: "restrict" } }) appFileID: number; @Column({ dataType: "BigInt", nullable: true }) fileContentID: number; @Column({ dataType: "Int", default: () => 0 }) sortOrder: number; @Column({ dataType: "Char", length: 400 }) title: string; @Column({ dataType: "Char", nullable: true }) description: string; @Column({ dataType: "Boolean", default: () => true }) isPreview: boolean; @Column({ dataType: "Boolean", default: () => false }) isDeleted: boolean; @Column({ dataType: "Char", nullable: true }) fileHtmlView: string; @Column({ dataType: "Char", nullable: true }) fileLink: string; @ReadOnlyJsonProperty signed: string; appFile: AppFile; storeItem: StoreItem; // [GraphService.init](sp) { // const ss = ServiceProvider.resolve(sp, SignerService); // const { signature, expiry } = ss.signer().sign({ appFileID: this.appFileID, fileContentID: this.fileContentID }, { till }); // this.signed = signature + "/" + expiry; // } }