88 lines
1.7 KiB
TypeScript
88 lines
1.7 KiB
TypeScript
import { sequelize } from '../../../modules/sequelize.ts';
|
|
import { DataTypes, Model } from 'sequelize';
|
|
|
|
export interface ContainerData {}
|
|
export type ContainerPublish = {
|
|
rid?: string; // resource id
|
|
name?: string;
|
|
description?: string;
|
|
version?: string;
|
|
};
|
|
export type Container = Partial<InstanceType<typeof ContainerModel>>;
|
|
|
|
/**
|
|
* 用户代码容器
|
|
*/
|
|
export class ContainerModel extends Model {
|
|
declare id: string;
|
|
declare title: string;
|
|
declare description: string;
|
|
declare type: string;
|
|
declare tags: string[];
|
|
declare code: string;
|
|
declare source: string;
|
|
declare sourceType: string;
|
|
declare data: ContainerData;
|
|
declare publish: ContainerPublish;
|
|
declare uid: string;
|
|
}
|
|
ContainerModel.init(
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
primaryKey: true,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
comment: 'id',
|
|
},
|
|
title: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: '',
|
|
},
|
|
description: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: '',
|
|
},
|
|
tags: {
|
|
type: DataTypes.JSON,
|
|
defaultValue: [],
|
|
},
|
|
type: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: '',
|
|
},
|
|
code: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
source: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: '',
|
|
},
|
|
sourceType: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: '',
|
|
},
|
|
data: {
|
|
type: DataTypes.JSON,
|
|
defaultValue: {},
|
|
},
|
|
publish: {
|
|
type: DataTypes.JSON,
|
|
defaultValue: {},
|
|
},
|
|
|
|
uid: {
|
|
type: DataTypes.UUID,
|
|
allowNull: true,
|
|
},
|
|
},
|
|
{
|
|
sequelize,
|
|
tableName: 'kv_container',
|
|
},
|
|
);
|
|
|
|
ContainerModel.sync({ alter: true, logging: false }).catch((e) => {
|
|
console.error('ContainerModel sync', e);
|
|
});
|