workflow data save
This commit is contained in:
@@ -22,12 +22,12 @@ export type NotifyChannels = {
|
||||
};
|
||||
|
||||
export type NotifyChannel =
|
||||
| NotifyChannelEmail
|
||||
| NotifyChannelWebhook
|
||||
| NotifyChannelDingTalk
|
||||
| NotifyChannelLark
|
||||
| NotifyChannelTelegram
|
||||
| NotifyChannelWebhook
|
||||
| NotifyChannelServerChan
|
||||
| NotifyChannelMail
|
||||
| NotifyChannelBark;
|
||||
|
||||
type ChannelLabel = {
|
||||
@@ -66,6 +66,21 @@ export const channels: ChannelLabel[] = [
|
||||
];
|
||||
|
||||
export const channelLabelMap: Map<string, ChannelLabel> = new Map(channels.map((item) => [item.name, item]));
|
||||
export type NotifyChannelEmail = {
|
||||
smtpHost: string;
|
||||
smtpPort: number;
|
||||
smtpTLS: boolean;
|
||||
username: string;
|
||||
password: string;
|
||||
senderAddress: string;
|
||||
receiverAddress: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export type NotifyChannelWebhook = {
|
||||
url: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export type NotifyChannelDingTalk = {
|
||||
accessToken: string;
|
||||
@@ -84,26 +99,11 @@ export type NotifyChannelTelegram = {
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export type NotifyChannelWebhook = {
|
||||
url: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export type NotifyChannelServerChan = {
|
||||
url: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export type NotifyChannelMail = {
|
||||
senderAddress: string;
|
||||
receiverAddresses: string;
|
||||
smtpHostAddr: string;
|
||||
smtpHostPort: string;
|
||||
username: string;
|
||||
password: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
export type NotifyChannelBark = {
|
||||
deviceKey: string;
|
||||
serverUrl: string;
|
||||
|
||||
@@ -3,6 +3,20 @@ import { nanoid } from "nanoid";
|
||||
import i18n from "@/i18n";
|
||||
import { deployTargets, KVType } from "./domain";
|
||||
|
||||
export type Workflow = {
|
||||
id?: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
type: string;
|
||||
crontab?: string;
|
||||
content?: WorkflowNode;
|
||||
draft?: WorkflowNode;
|
||||
enabled?: boolean;
|
||||
hasDraft?: boolean;
|
||||
created?: string;
|
||||
updated?: string;
|
||||
};
|
||||
|
||||
export enum WorkflowNodeType {
|
||||
Start = "start",
|
||||
End = "end",
|
||||
@@ -94,6 +108,31 @@ type NewWorkflowNodeOptions = {
|
||||
providerType?: string;
|
||||
};
|
||||
|
||||
export const initWorkflow = (): Workflow => {
|
||||
// 开始节点
|
||||
const rs = newWorkflowNode(WorkflowNodeType.Start, {});
|
||||
let root = rs;
|
||||
|
||||
// 申请节点
|
||||
root.next = newWorkflowNode(WorkflowNodeType.Apply, {});
|
||||
root = root.next;
|
||||
|
||||
// 部署节点
|
||||
root.next = newWorkflowNode(WorkflowNodeType.Deploy, {});
|
||||
root = root.next;
|
||||
|
||||
// 通知节点
|
||||
root.next = newWorkflowNode(WorkflowNodeType.Notify, {});
|
||||
|
||||
return {
|
||||
name: i18n.t("workflow.default.name"),
|
||||
type: "auto",
|
||||
crontab: "0 0 * * *",
|
||||
enabled: false,
|
||||
draft: rs,
|
||||
};
|
||||
};
|
||||
|
||||
export const newWorkflowNode = (type: WorkflowNodeType, options: NewWorkflowNodeOptions): WorkflowNode | WorkflowBranchNode => {
|
||||
const id = nanoid();
|
||||
const typeName = workflowNodeTypeDefaultName.get(type) || "";
|
||||
|
||||
Reference in New Issue
Block a user