增加新建订阅

This commit is contained in:
whyour
2022-05-10 14:38:06 +08:00
parent 85d8565241
commit ebb6290468
13 changed files with 489 additions and 31 deletions
+17 -3
View File
@@ -3,8 +3,10 @@ import { DataTypes, Model, ModelDefined } from 'sequelize';
import { SimpleIntervalSchedule } from 'toad-scheduler';
export class Subscription {
id?: number;
name?: string;
type?: 'public-repo' | 'private-repo' | 'file';
schedule_type?: 'crontab' | 'interval';
schedule?: string | SimpleIntervalSchedule;
url?: string;
whitelist?: string;
@@ -14,11 +16,15 @@ export class Subscription {
status?: SubscriptionStatus;
pull_type?: 'ssh-key' | 'user-pwd';
pull_option?:
| { private_key: string; key_alias: string }
| { private_key: string }
| { username: string; password: string };
pid?: string;
pid?: number;
isDisabled?: 1 | 0;
log_path?: string;
alias: string;
constructor(options: Subscription) {
this.id = options.id;
this.name = options.name;
this.type = options.type;
this.schedule = options.schedule;
@@ -31,6 +37,10 @@ export class Subscription {
this.pull_type = options.pull_type;
this.pull_option = options.pull_option;
this.pid = options.pid;
this.isDisabled = options.isDisabled;
this.log_path = options.log_path;
this.schedule_type = options.schedule_type;
this.alias = options.alias;
}
}
@@ -44,7 +54,7 @@ export enum SubscriptionStatus {
interface SubscriptionInstance
extends Model<Subscription, Subscription>,
Subscription {}
export const CrontabModel = sequelize.define<SubscriptionInstance>(
export const SubscriptionModel = sequelize.define<SubscriptionInstance>(
'Subscription',
{
name: {
@@ -67,5 +77,9 @@ export const CrontabModel = sequelize.define<SubscriptionInstance>(
pull_type: DataTypes.STRING,
pull_option: DataTypes.JSON,
pid: DataTypes.NUMBER,
isDisabled: DataTypes.NUMBER,
log_path: DataTypes.STRING,
schedule_type: DataTypes.STRING,
alias: DataTypes.STRING,
},
);