refactor: clean code
This commit is contained in:
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input, Select } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type ACMEHttpReqAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForACMEHttpReq } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormACMEHttpReqConfigFieldValues = Partial<ACMEHttpReqAccessConfig>;
|
||||
type AccessEditFormACMEHttpReqConfigFieldValues = Partial<AccessConfigForACMEHttpReq>;
|
||||
|
||||
export type AccessEditFormACMEHttpReqConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AWSAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForAWS } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormAWSConfigFieldValues = Partial<AWSAccessConfig>;
|
||||
type AccessEditFormAWSConfigFieldValues = Partial<AccessConfigForAWS>;
|
||||
|
||||
export type AccessEditFormAWSConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AliyunAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForAliyun } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormAliyunConfigFieldValues = Partial<AliyunAccessConfig>;
|
||||
type AccessEditFormAliyunConfigFieldValues = Partial<AccessConfigForAliyun>;
|
||||
|
||||
export type AccessEditFormAliyunConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type BaiduCloudAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForBaiduCloud } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormBaiduCloudConfigFieldValues = Partial<BaiduCloudAccessConfig>;
|
||||
type AccessEditFormBaiduCloudConfigFieldValues = Partial<AccessConfigForBaiduCloud>;
|
||||
|
||||
export type AccessEditFormBaiduCloudConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type BytePlusAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForBytePlus } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormBytePlusConfigFieldValues = Partial<BytePlusAccessConfig>;
|
||||
type AccessEditFormBytePlusConfigFieldValues = Partial<AccessConfigForBytePlus>;
|
||||
|
||||
export type AccessEditFormBytePlusConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type CloudflareAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForCloudflare } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormCloudflareConfigFieldValues = Partial<CloudflareAccessConfig>;
|
||||
type AccessEditFormCloudflareConfigFieldValues = Partial<AccessConfigForCloudflare>;
|
||||
|
||||
export type AccessEditFormCloudflareConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type DogeCloudAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForDogeCloud } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormDogeCloudConfigFieldValues = Partial<DogeCloudAccessConfig>;
|
||||
type AccessEditFormDogeCloudConfigFieldValues = Partial<AccessConfigForDogeCloud>;
|
||||
|
||||
export type AccessEditFormDogeCloudConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type GoDaddyAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForGoDaddy } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormGoDaddyConfigFieldValues = Partial<GoDaddyAccessConfig>;
|
||||
type AccessEditFormGoDaddyConfigFieldValues = Partial<AccessConfigForGoDaddy>;
|
||||
|
||||
export type AccessEditFormGoDaddyConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type HuaweiCloudAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForHuaweiCloud } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormHuaweiCloudConfigFieldValues = Partial<HuaweiCloudAccessConfig>;
|
||||
type AccessEditFormHuaweiCloudConfigFieldValues = Partial<AccessConfigForHuaweiCloud>;
|
||||
|
||||
export type AccessEditFormHuaweiCloudConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -7,11 +7,11 @@ import { Button, Form, type FormInstance, Input, Upload, type UploadFile, type U
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type KubernetesAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForKubernetes } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
import { readFileContent } from "@/utils/file";
|
||||
|
||||
type AccessEditFormKubernetesConfigFieldValues = Partial<KubernetesAccessConfig>;
|
||||
type AccessEditFormKubernetesConfigFieldValues = Partial<AccessConfigForKubernetes>;
|
||||
|
||||
export type AccessEditFormKubernetesConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Form, type FormInstance } from "antd";
|
||||
|
||||
import { type LocalAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForLocal } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormLocalConfigFieldValues = Partial<LocalAccessConfig>;
|
||||
type AccessEditFormLocalConfigFieldValues = Partial<AccessConfigForLocal>;
|
||||
|
||||
export type AccessEditFormLocalConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type NameDotComAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForNameDotCom } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormNameDotComConfigFieldValues = Partial<NameDotComAccessConfig>;
|
||||
type AccessEditFormNameDotComConfigFieldValues = Partial<AccessConfigForNameDotCom>;
|
||||
|
||||
export type AccessEditFormNameDotComConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type NameSiloAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForNameSilo } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormNameSiloConfigFieldValues = Partial<NameSiloAccessConfig>;
|
||||
type AccessEditFormNameSiloConfigFieldValues = Partial<AccessConfigForNameSilo>;
|
||||
|
||||
export type AccessEditFormNameSiloConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type PowerDNSAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForPowerDNS } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormPowerDNSConfigFieldValues = Partial<PowerDNSAccessConfig>;
|
||||
type AccessEditFormPowerDNSConfigFieldValues = Partial<AccessConfigForPowerDNS>;
|
||||
|
||||
export type AccessEditFormPowerDNSConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type QiniuAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForQiniu } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormQiniuConfigFieldValues = Partial<QiniuAccessConfig>;
|
||||
type AccessEditFormQiniuConfigFieldValues = Partial<AccessConfigForQiniu>;
|
||||
|
||||
export type AccessEditFormQiniuConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -7,12 +7,12 @@ import { Button, Form, type FormInstance, Input, InputNumber, Upload, type Uploa
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type SSHAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForSSH } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
import { readFileContent } from "@/utils/file";
|
||||
import { validDomainName, validIPv4Address, validIPv6Address } from "@/utils/validators";
|
||||
|
||||
type AccessEditFormSSHConfigFieldValues = Partial<SSHAccessConfig>;
|
||||
type AccessEditFormSSHConfigFieldValues = Partial<AccessConfigForSSH>;
|
||||
|
||||
export type AccessEditFormSSHConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type TencentCloudAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForTencentCloud } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormTencentCloudConfigFieldValues = Partial<TencentCloudAccessConfig>;
|
||||
type AccessEditFormTencentCloudConfigFieldValues = Partial<AccessConfigForTencentCloud>;
|
||||
|
||||
export type AccessEditFormTencentCloudConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type VolcEngineAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForVolcEngine } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormVolcEngineConfigFieldValues = Partial<VolcEngineAccessConfig>;
|
||||
type AccessEditFormVolcEngineConfigFieldValues = Partial<AccessConfigForVolcEngine>;
|
||||
|
||||
export type AccessEditFormVolcEngineConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type WebhookAccessConfig } from "@/domain/access";
|
||||
import { type AccessConfigForWebhook } from "@/domain/access";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
type AccessEditFormWebhookConfigFieldValues = Partial<WebhookAccessConfig>;
|
||||
type AccessEditFormWebhookConfigFieldValues = Partial<AccessConfigForWebhook>;
|
||||
|
||||
export type AccessEditFormWebhookConfigProps = {
|
||||
form: FormInstance;
|
||||
|
||||
@@ -96,16 +96,14 @@ const CertificateDetail = ({ data, ...props }: CertificateDetailProps) => {
|
||||
key: "PFX",
|
||||
label: "PFX",
|
||||
onClick: () => {
|
||||
// TODO: 下载 PFX 格式证书
|
||||
alert("TODO");
|
||||
alert("TODO: 暂时不支持下载 PFX 证书");
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "JKS",
|
||||
label: "JKS",
|
||||
onClick: () => {
|
||||
// TODO: 下载 JKS 格式证书
|
||||
alert("TODO");
|
||||
alert("TODO: 暂时不支持下载 JKS 证书");
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -9,10 +9,10 @@ import { notifyChannelsMap } from "@/domain/settings";
|
||||
import {
|
||||
WORKFLOW_TRIGGERS,
|
||||
type WorkflowNode,
|
||||
type WorkflowNodeConfigAsApply,
|
||||
type WorkflowNodeConfigAsDeploy,
|
||||
type WorkflowNodeConfigAsNotify,
|
||||
type WorkflowNodeConfigAsStart,
|
||||
type WorkflowNodeConfigForApply,
|
||||
type WorkflowNodeConfigForDeploy,
|
||||
type WorkflowNodeConfigForNotify,
|
||||
type WorkflowNodeConfigForStart,
|
||||
WorkflowNodeType,
|
||||
} from "@/domain/workflow";
|
||||
import { useZustandShallowSelector } from "@/hooks";
|
||||
@@ -40,7 +40,7 @@ const WorkflowElement = ({ node, disabled }: NodeProps) => {
|
||||
|
||||
switch (node.type) {
|
||||
case WorkflowNodeType.Start: {
|
||||
const config = (node.config as WorkflowNodeConfigAsStart) ?? {};
|
||||
const config = (node.config as WorkflowNodeConfigForStart) ?? {};
|
||||
return (
|
||||
<div className="flex items-center justify-between space-x-2">
|
||||
<Typography.Text className="truncate">
|
||||
@@ -58,12 +58,12 @@ const WorkflowElement = ({ node, disabled }: NodeProps) => {
|
||||
}
|
||||
|
||||
case WorkflowNodeType.Apply: {
|
||||
const config = (node.config as WorkflowNodeConfigAsApply) ?? {};
|
||||
const config = (node.config as WorkflowNodeConfigForApply) ?? {};
|
||||
return <Typography.Text className="truncate">{config.domains || " "}</Typography.Text>;
|
||||
}
|
||||
|
||||
case WorkflowNodeType.Deploy: {
|
||||
const config = (node.config as WorkflowNodeConfigAsDeploy) ?? {};
|
||||
const config = (node.config as WorkflowNodeConfigForDeploy) ?? {};
|
||||
const provider = deployProvidersMap.get(config.provider);
|
||||
return (
|
||||
<Space>
|
||||
@@ -74,7 +74,7 @@ const WorkflowElement = ({ node, disabled }: NodeProps) => {
|
||||
}
|
||||
|
||||
case WorkflowNodeType.Notify: {
|
||||
const config = (node.config as WorkflowNodeConfigAsNotify) ?? {};
|
||||
const config = (node.config as WorkflowNodeConfigForNotify) ?? {};
|
||||
const channel = notifyChannelsMap.get(config.channel as string);
|
||||
return (
|
||||
<div className="flex items-center justify-between space-x-2">
|
||||
|
||||
@@ -12,7 +12,7 @@ import MultipleInput from "@/components/MultipleInput";
|
||||
import AccessEditModal from "@/components/access/AccessEditModal";
|
||||
import AccessSelect from "@/components/access/AccessSelect";
|
||||
import { ACCESS_USAGES, accessProvidersMap } from "@/domain/provider";
|
||||
import { type WorkflowNode, type WorkflowNodeConfigAsApply } from "@/domain/workflow";
|
||||
import { type WorkflowNode, type WorkflowNodeConfigForApply } from "@/domain/workflow";
|
||||
import { useAntdForm, useZustandShallowSelector } from "@/hooks";
|
||||
import { useAccessesStore } from "@/stores/access";
|
||||
import { useContactEmailsStore } from "@/stores/contact";
|
||||
@@ -26,7 +26,7 @@ export type ApplyNodeFormProps = {
|
||||
|
||||
const MULTIPLE_INPUT_DELIMITER = ";";
|
||||
|
||||
const initFormModel = (): Partial<WorkflowNodeConfigAsApply> => {
|
||||
const initFormModel = (): Partial<WorkflowNodeConfigForApply> => {
|
||||
return {
|
||||
keyAlgorithm: "RSA2048",
|
||||
propagationTimeout: 60,
|
||||
@@ -76,7 +76,7 @@ const ApplyNodeForm = ({ node }: ApplyNodeFormProps) => {
|
||||
formPending,
|
||||
formProps,
|
||||
} = useAntdForm<z.infer<typeof formSchema>>({
|
||||
initialValues: (node?.config as WorkflowNodeConfigAsApply) ?? initFormModel(),
|
||||
initialValues: (node?.config as WorkflowNodeConfigForApply) ?? initFormModel(),
|
||||
onSubmit: async (values) => {
|
||||
await formInst.validateFields();
|
||||
await addEmail(values.contactEmail);
|
||||
@@ -85,7 +85,7 @@ const ApplyNodeForm = ({ node }: ApplyNodeFormProps) => {
|
||||
draft.config = {
|
||||
provider: accesses.find((e) => e.id === values.providerAccessId)?.provider,
|
||||
...values,
|
||||
} as WorkflowNodeConfigAsApply;
|
||||
} as WorkflowNodeConfigForApply;
|
||||
draft.validated = true;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ import AccessSelect from "@/components/access/AccessSelect";
|
||||
import DeployProviderPicker from "@/components/provider/DeployProviderPicker";
|
||||
import DeployProviderSelect from "@/components/provider/DeployProviderSelect";
|
||||
import { ACCESS_USAGES, DEPLOY_PROVIDERS, accessProvidersMap, deployProvidersMap } from "@/domain/provider";
|
||||
import { type WorkflowNode, type WorkflowNodeConfigAsDeploy } from "@/domain/workflow";
|
||||
import { type WorkflowNode, type WorkflowNodeConfigForDeploy } from "@/domain/workflow";
|
||||
import { useAntdForm, useZustandShallowSelector } from "@/hooks";
|
||||
import { useWorkflowStore } from "@/stores/workflow";
|
||||
import { usePanel } from "../PanelProvider";
|
||||
@@ -44,7 +44,7 @@ export type DeployFormProps = {
|
||||
node: WorkflowNode;
|
||||
};
|
||||
|
||||
const initFormModel = (): Partial<WorkflowNodeConfigAsDeploy> => {
|
||||
const initFormModel = (): Partial<WorkflowNodeConfigForDeploy> => {
|
||||
return {};
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ const DeployNodeForm = ({ node }: DeployFormProps) => {
|
||||
formPending,
|
||||
formProps,
|
||||
} = useAntdForm<z.infer<typeof formSchema>>({
|
||||
initialValues: (node?.config as WorkflowNodeConfigAsDeploy) ?? initFormModel(),
|
||||
initialValues: (node?.config as WorkflowNodeConfigForDeploy) ?? initFormModel(),
|
||||
onSubmit: async (values) => {
|
||||
await formInst.validateFields();
|
||||
await updateNode(
|
||||
|
||||
@@ -8,7 +8,7 @@ import { produce } from "immer";
|
||||
import { z } from "zod";
|
||||
|
||||
import { notifyChannelsMap } from "@/domain/settings";
|
||||
import { type WorkflowNode, type WorkflowNodeConfigAsNotify } from "@/domain/workflow";
|
||||
import { type WorkflowNode, type WorkflowNodeConfigForNotify } from "@/domain/workflow";
|
||||
import { useAntdForm, useZustandShallowSelector } from "@/hooks";
|
||||
import { useNotifyChannelsStore } from "@/stores/notify";
|
||||
import { useWorkflowStore } from "@/stores/workflow";
|
||||
@@ -18,7 +18,7 @@ export type NotifyNodeFormProps = {
|
||||
node: WorkflowNode;
|
||||
};
|
||||
|
||||
const initFormModel = (): Partial<WorkflowNodeConfigAsNotify> => {
|
||||
const initFormModel = (): Partial<WorkflowNodeConfigForNotify> => {
|
||||
return {
|
||||
subject: "Completed!",
|
||||
message: "Your workflow has been completed on Certimate.",
|
||||
@@ -57,7 +57,7 @@ const NotifyNodeForm = ({ node }: NotifyNodeFormProps) => {
|
||||
formPending,
|
||||
formProps,
|
||||
} = useAntdForm<z.infer<typeof formSchema>>({
|
||||
initialValues: (node?.config as WorkflowNodeConfigAsNotify) ?? initFormModel(),
|
||||
initialValues: (node?.config as WorkflowNodeConfigForNotify) ?? initFormModel(),
|
||||
onSubmit: async (values) => {
|
||||
await formInst.validateFields();
|
||||
await updateNode(
|
||||
|
||||
@@ -7,7 +7,7 @@ import { produce } from "immer";
|
||||
import { z } from "zod";
|
||||
|
||||
import Show from "@/components/Show";
|
||||
import { WORKFLOW_TRIGGERS, type WorkflowNode, type WorkflowNodeConfigAsStart } from "@/domain/workflow";
|
||||
import { WORKFLOW_TRIGGERS, type WorkflowNode, type WorkflowNodeConfigForStart } from "@/domain/workflow";
|
||||
import { useAntdForm, useZustandShallowSelector } from "@/hooks";
|
||||
import { useWorkflowStore } from "@/stores/workflow";
|
||||
import { getNextCronExecutions, validCronExpression } from "@/utils/cron";
|
||||
@@ -17,7 +17,7 @@ export type StartNodeFormProps = {
|
||||
node: WorkflowNode;
|
||||
};
|
||||
|
||||
const initFormModel = (): WorkflowNodeConfigAsStart => {
|
||||
const initFormModel = (): WorkflowNodeConfigForStart => {
|
||||
return {
|
||||
trigger: WORKFLOW_TRIGGERS.AUTO,
|
||||
triggerCron: "0 0 * * *",
|
||||
@@ -54,7 +54,7 @@ const StartNodeForm = ({ node }: StartNodeFormProps) => {
|
||||
formPending,
|
||||
formProps,
|
||||
} = useAntdForm<z.infer<typeof formSchema>>({
|
||||
initialValues: (node?.config as WorkflowNodeConfigAsStart) ?? initFormModel(),
|
||||
initialValues: (node?.config as WorkflowNodeConfigForStart) ?? initFormModel(),
|
||||
onSubmit: async (values) => {
|
||||
await formInst.validateFields();
|
||||
await updateNode(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { type AccessUsageType } from "./provider";
|
||||
|
||||
// #region AccessModel
|
||||
export interface AccessModel extends BaseModel {
|
||||
name: string;
|
||||
provider: string;
|
||||
@@ -9,106 +8,105 @@ export interface AccessModel extends BaseModel {
|
||||
NOTICE: If you add new type, please keep ASCII order.
|
||||
*/ Record<string, unknown> &
|
||||
(
|
||||
| ACMEHttpReqAccessConfig
|
||||
| AliyunAccessConfig
|
||||
| AWSAccessConfig
|
||||
| BaiduCloudAccessConfig
|
||||
| BytePlusAccessConfig
|
||||
| CloudflareAccessConfig
|
||||
| DogeCloudAccessConfig
|
||||
| GoDaddyAccessConfig
|
||||
| HuaweiCloudAccessConfig
|
||||
| KubernetesAccessConfig
|
||||
| LocalAccessConfig
|
||||
| NameDotComAccessConfig
|
||||
| NameSiloAccessConfig
|
||||
| PowerDNSAccessConfig
|
||||
| QiniuAccessConfig
|
||||
| SSHAccessConfig
|
||||
| TencentCloudAccessConfig
|
||||
| VolcEngineAccessConfig
|
||||
| WebhookAccessConfig
|
||||
| AccessConfigForACMEHttpReq
|
||||
| AccessConfigForAliyun
|
||||
| AccessConfigForAWS
|
||||
| AccessConfigForBaiduCloud
|
||||
| AccessConfigForBytePlus
|
||||
| AccessConfigForCloudflare
|
||||
| AccessConfigForDogeCloud
|
||||
| AccessConfigForGoDaddy
|
||||
| AccessConfigForHuaweiCloud
|
||||
| AccessConfigForKubernetes
|
||||
| AccessConfigForLocal
|
||||
| AccessConfigForNameDotCom
|
||||
| AccessConfigForNameSilo
|
||||
| AccessConfigForPowerDNS
|
||||
| AccessConfigForQiniu
|
||||
| AccessConfigForSSH
|
||||
| AccessConfigForTencentCloud
|
||||
| AccessConfigForVolcEngine
|
||||
| AccessConfigForWebhook
|
||||
);
|
||||
usage: AccessUsageType;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region AccessConfig
|
||||
export type ACMEHttpReqAccessConfig = {
|
||||
export type AccessConfigForACMEHttpReq = {
|
||||
endpoint: string;
|
||||
mode?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
|
||||
export type AliyunAccessConfig = {
|
||||
export type AccessConfigForAliyun = {
|
||||
accessKeyId: string;
|
||||
accessKeySecret: string;
|
||||
};
|
||||
|
||||
export type AWSAccessConfig = {
|
||||
export type AccessConfigForAWS = {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
region?: string;
|
||||
hostedZoneId?: string;
|
||||
};
|
||||
|
||||
export type BaiduCloudAccessConfig = {
|
||||
export type AccessConfigForBaiduCloud = {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
};
|
||||
|
||||
export type BytePlusAccessConfig = {
|
||||
export type AccessConfigForBytePlus = {
|
||||
accessKey: string;
|
||||
secretKey: string;
|
||||
};
|
||||
|
||||
export type CloudflareAccessConfig = {
|
||||
export type AccessConfigForCloudflare = {
|
||||
dnsApiToken: string;
|
||||
};
|
||||
|
||||
export type DogeCloudAccessConfig = {
|
||||
export type AccessConfigForDogeCloud = {
|
||||
accessKey: string;
|
||||
secretKey: string;
|
||||
};
|
||||
|
||||
export type GoDaddyAccessConfig = {
|
||||
export type AccessConfigForGoDaddy = {
|
||||
apiKey: string;
|
||||
apiSecret: string;
|
||||
};
|
||||
|
||||
export type HuaweiCloudAccessConfig = {
|
||||
export type AccessConfigForHuaweiCloud = {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
region?: string;
|
||||
};
|
||||
|
||||
export type KubernetesAccessConfig = {
|
||||
export type AccessConfigForKubernetes = {
|
||||
kubeConfig?: string;
|
||||
};
|
||||
|
||||
export type LocalAccessConfig = NonNullable<unknown>;
|
||||
export type AccessConfigForLocal = NonNullable<unknown>;
|
||||
|
||||
export type NameDotComAccessConfig = {
|
||||
export type AccessConfigForNameDotCom = {
|
||||
username: string;
|
||||
apiToken: string;
|
||||
};
|
||||
|
||||
export type NameSiloAccessConfig = {
|
||||
export type AccessConfigForNameSilo = {
|
||||
apiKey: string;
|
||||
};
|
||||
|
||||
export type PowerDNSAccessConfig = {
|
||||
export type AccessConfigForPowerDNS = {
|
||||
apiUrl: string;
|
||||
apiKey: string;
|
||||
};
|
||||
|
||||
export type QiniuAccessConfig = {
|
||||
export type AccessConfigForQiniu = {
|
||||
accessKey: string;
|
||||
secretKey: string;
|
||||
};
|
||||
|
||||
export type SSHAccessConfig = {
|
||||
export type AccessConfigForSSH = {
|
||||
host: string;
|
||||
port: number;
|
||||
username: string;
|
||||
@@ -117,17 +115,17 @@ export type SSHAccessConfig = {
|
||||
keyPassphrase?: string;
|
||||
};
|
||||
|
||||
export type TencentCloudAccessConfig = {
|
||||
export type AccessConfigForTencentCloud = {
|
||||
secretId: string;
|
||||
secretKey: string;
|
||||
};
|
||||
|
||||
export type VolcEngineAccessConfig = {
|
||||
export type AccessConfigForVolcEngine = {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
};
|
||||
|
||||
export type WebhookAccessConfig = {
|
||||
export type AccessConfigForWebhook = {
|
||||
url: string;
|
||||
};
|
||||
// #endregion
|
||||
|
||||
@@ -95,12 +95,12 @@ export type WorkflowNode = {
|
||||
validated?: boolean;
|
||||
};
|
||||
|
||||
export type WorkflowNodeConfigAsStart = {
|
||||
export type WorkflowNodeConfigForStart = {
|
||||
trigger: string;
|
||||
triggerCron?: string;
|
||||
};
|
||||
|
||||
export type WorkflowNodeConfigAsApply = {
|
||||
export type WorkflowNodeConfigForApply = {
|
||||
domains: string;
|
||||
contactEmail: string;
|
||||
provider: string;
|
||||
@@ -111,22 +111,22 @@ export type WorkflowNodeConfigAsApply = {
|
||||
disableFollowCNAME?: boolean;
|
||||
};
|
||||
|
||||
export type WorkflowNodeConfigAsDeploy = {
|
||||
export type WorkflowNodeConfigForDeploy = {
|
||||
provider: string;
|
||||
providerAccessId: string;
|
||||
certificate: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export type WorkflowNodeConfigAsNotify = {
|
||||
export type WorkflowNodeConfigForNotify = {
|
||||
channel: string;
|
||||
subject: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export type WorkflowNodeConfigAsBranch = never;
|
||||
export type WorkflowNodeConfigForBranch = never;
|
||||
|
||||
export type WorkflowNodeConfigAsEnd = never;
|
||||
export type WorkflowNodeConfigForEnd = never;
|
||||
|
||||
export type WorkflowNodeIO = {
|
||||
name: string;
|
||||
@@ -403,7 +403,7 @@ export const isAllNodesValidated = (node: WorkflowNode): boolean => {
|
||||
*/
|
||||
export const getExecuteMethod = (node: WorkflowNode): { trigger: string; triggerCron: string } => {
|
||||
if (node.type === WorkflowNodeType.Start) {
|
||||
const config = node.config as WorkflowNodeConfigAsStart;
|
||||
const config = node.config as WorkflowNodeConfigForStart;
|
||||
return {
|
||||
trigger: config.trigger ?? "",
|
||||
triggerCron: config.triggerCron ?? "",
|
||||
|
||||
Reference in New Issue
Block a user