48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import * as plugins from '../plugins.js';
|
|
import type { ImageManager } from './classes.imagemanager.js';
|
|
|
|
@plugins.smartdata.managed()
|
|
export class Image extends plugins.smartdata.SmartDataDbDoc<
|
|
Image,
|
|
plugins.servezoneInterfaces.data.IImage,
|
|
ImageManager
|
|
> {
|
|
public static async create(
|
|
imageDataArg: Partial<plugins.servezoneInterfaces.data.IImage['data']>,
|
|
) {
|
|
const image = new Image();
|
|
image.id = await this.getNewId();
|
|
console.log(imageDataArg);
|
|
Object.assign(image, {
|
|
data: {
|
|
name: imageDataArg.name,
|
|
description: imageDataArg.description,
|
|
versions: [],
|
|
},
|
|
});
|
|
console.log((Image as any).saveableProperties);
|
|
await image.save();
|
|
return image;
|
|
}
|
|
|
|
@plugins.smartdata.unI()
|
|
public id: string;
|
|
|
|
@plugins.smartdata.svDb()
|
|
public data: plugins.servezoneInterfaces.data.IImage['data'];
|
|
|
|
public async getVersions() {}
|
|
|
|
/**
|
|
* returns a storage path
|
|
* note: this is relative to the storage method defined by the imageManager
|
|
*/
|
|
public async getStoragePath(versionStringArg: string) {
|
|
return `${this.data.name}:${versionStringArg}`.replace('/', '__');
|
|
}
|
|
|
|
public async getWriteStream() {}
|
|
|
|
public async getReadStream() {}
|
|
}
|