chore: remove unused code

This commit is contained in:
Fu Diwei 2024-12-20 21:45:07 +08:00
parent cb162e063d
commit 929250810f
8 changed files with 78 additions and 125 deletions

View File

@ -1,5 +1,5 @@
import { WorkflowRunLog } from "@/domain/workflow";
import { logs } from "@/repository/workflow";
import { list as logs } from "@/repository/workflowRunLog";
import { ColumnDef } from "@tanstack/react-table";
import { useState } from "react";
import { DataTable } from "./DataTable";

View File

@ -190,7 +190,7 @@ export type AccessProvider = {
export const accessProvidersMap: Map<AccessProvider["type"], AccessProvider> = new Map(
/*
NOTICE: The following order determines the order displayed at the frontend.
*/
[

View File

@ -1,35 +0,0 @@
import { Domain } from "./domain";
export type Deployment = {
id: string;
domain: string;
log: {
apply?: Log[];
check?: Log[];
deploy?: Log[];
};
phase: Pahse;
phaseSuccess: boolean;
wholeSuccess: boolean;
deployedAt: string;
created: string;
updated: string;
expand: {
domain?: Domain;
};
};
export type Pahse = "apply" | "check" | "deploy";
export type Log = {
time: string;
message: string;
error: string;
info?: string[];
};
export type DeploymentListReq = {
domain?: string;
page?: number;
perPage?: number;
};

View File

@ -1,35 +1,17 @@
import { Deployment, Pahse } from "./deployment";
export type Domain = {
id?: string;
domain: string;
email?: string;
crontab: string;
access: string;
targetAccess?: string;
targetType?: string;
expiredAt?: string;
phase?: Pahse;
phaseSuccess?: boolean;
lastDeployedAt?: string;
variables?: string;
nameservers?: string;
group?: string;
enabled?: boolean;
deployed?: boolean;
created?: string;
updated?: string;
deleted?: string;
rightnow?: boolean;
certificate?: string;
privateKey?: string;
expand?: {
lastDeployment?: Deployment;
};
applyConfig?: ApplyConfig;
deployConfig?: DeployConfig[];
};
import {
ACCESS_PROVIDER_TYPE_ALIYUN,
ACCESS_PROVIDER_TYPE_BAIDUCLOUD,
ACCESS_PROVIDER_TYPE_BYTEPLUS,
ACCESS_PROVIDER_TYPE_DOGECLOUD,
ACCESS_PROVIDER_TYPE_HUAWEICLOUD,
ACCESS_PROVIDER_TYPE_KUBERNETES,
ACCESS_PROVIDER_TYPE_LOCAL,
ACCESS_PROVIDER_TYPE_QINIU,
ACCESS_PROVIDER_TYPE_SSH,
ACCESS_PROVIDER_TYPE_TENCENTCLOUD,
ACCESS_PROVIDER_TYPE_VOLCENGINE,
ACCESS_PROVIDER_TYPE_WEBHOOK,
} from "./access";
export type KVType = {
key: string;
@ -64,29 +46,33 @@ export type DeployTarget = {
};
export const deployTargetList: string[][] = [
["aliyun-oss", "common.provider.aliyun.oss", "/imgs/providers/aliyun.svg"],
["aliyun-cdn", "common.provider.aliyun.cdn", "/imgs/providers/aliyun.svg"],
["aliyun-dcdn", "common.provider.aliyun.dcdn", "/imgs/providers/aliyun.svg"],
["aliyun-clb", "common.provider.aliyun.clb", "/imgs/providers/aliyun.svg"],
["aliyun-alb", "common.provider.aliyun.alb", "/imgs/providers/aliyun.svg"],
["aliyun-nlb", "common.provider.aliyun.nlb", "/imgs/providers/aliyun.svg"],
["tencentcloud-cdn", "common.provider.tencentcloud.cdn", "/imgs/providers/tencentcloud.svg"],
["tencentcloud-ecdn", "common.provider.tencentcloud.ecdn", "/imgs/providers/tencentcloud.svg"],
["tencentcloud-clb", "common.provider.tencentcloud.clb", "/imgs/providers/tencentcloud.svg"],
["tencentcloud-cos", "common.provider.tencentcloud.cos", "/imgs/providers/tencentcloud.svg"],
["tencentcloud-eo", "common.provider.tencentcloud.eo", "/imgs/providers/tencentcloud.svg"],
["huaweicloud-cdn", "common.provider.huaweicloud.cdn", "/imgs/providers/huaweicloud.svg"],
["huaweicloud-elb", "common.provider.huaweicloud.elb", "/imgs/providers/huaweicloud.svg"],
["baiducloud-cdn", "common.provider.baiducloud.cdn", "/imgs/providers/baiducloud.svg"],
["qiniu-cdn", "common.provider.qiniu.cdn", "/imgs/providers/qiniu.svg"],
["dogecloud-cdn", "common.provider.dogecloud.cdn", "/imgs/providers/dogecloud.svg"],
["local", "common.provider.local", "/imgs/providers/local.svg"],
["ssh", "common.provider.ssh", "/imgs/providers/ssh.svg"],
["webhook", "common.provider.webhook", "/imgs/providers/webhook.svg"],
["k8s-secret", "common.provider.kubernetes.secret", "/imgs/providers/kubernetes.svg"],
["volcengine-live", "common.provider.volcengine.live", "/imgs/providers/volcengine.svg"],
["volcengine-cdn", "common.provider.volcengine.cdn", "/imgs/providers/volcengine.svg"],
["byteplus-cdn", "common.provider.byteplus.cdn", "/imgs/providers/byteplus.svg"],
/*
NOTICE: The following order determines the order displayed at the frontend.
*/
[`${ACCESS_PROVIDER_TYPE_LOCAL}`, "common.provider.local", "/imgs/providers/local.svg"],
[`${ACCESS_PROVIDER_TYPE_SSH}`, "common.provider.ssh", "/imgs/providers/ssh.svg"],
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-oss`, "common.provider.aliyun.oss", "/imgs/providers/aliyun.svg"],
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-cdn`, "common.provider.aliyun.cdn", "/imgs/providers/aliyun.svg"],
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-dcdn`, "common.provider.aliyun.dcdn", "/imgs/providers/aliyun.svg"],
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-clb`, "common.provider.aliyun.clb", "/imgs/providers/aliyun.svg"],
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-alb`, "common.provider.aliyun.alb", "/imgs/providers/aliyun.svg"],
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-nlb`, "common.provider.aliyun.nlb", "/imgs/providers/aliyun.svg"],
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-cdn`, "common.provider.tencentcloud.cdn", "/imgs/providers/tencentcloud.svg"],
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-ecdn`, "common.provider.tencentcloud.ecdn", "/imgs/providers/tencentcloud.svg"],
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-clb`, "common.provider.tencentcloud.clb", "/imgs/providers/tencentcloud.svg"],
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-cos`, "common.provider.tencentcloud.cos", "/imgs/providers/tencentcloud.svg"],
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-eo`, "common.provider.tencentcloud.eo", "/imgs/providers/tencentcloud.svg"],
[`${ACCESS_PROVIDER_TYPE_HUAWEICLOUD}-cdn`, "common.provider.huaweicloud.cdn", "/imgs/providers/huaweicloud.svg"],
[`${ACCESS_PROVIDER_TYPE_HUAWEICLOUD}-elb`, "common.provider.huaweicloud.elb", "/imgs/providers/huaweicloud.svg"],
[`${ACCESS_PROVIDER_TYPE_BAIDUCLOUD}-cdn`, "common.provider.baiducloud.cdn", "/imgs/providers/baiducloud.svg"],
[`${ACCESS_PROVIDER_TYPE_VOLCENGINE}-cdn`, "common.provider.volcengine.cdn", "/imgs/providers/volcengine.svg"],
[`${ACCESS_PROVIDER_TYPE_VOLCENGINE}-live`, "common.provider.volcengine.live", "/imgs/providers/volcengine.svg"],
[`${ACCESS_PROVIDER_TYPE_QINIU}-cdn`, "common.provider.qiniu.cdn", "/imgs/providers/qiniu.svg"],
[`${ACCESS_PROVIDER_TYPE_DOGECLOUD}-cdn`, "common.provider.dogecloud.cdn", "/imgs/providers/dogecloud.svg"],
[`${ACCESS_PROVIDER_TYPE_BYTEPLUS}-cdn`, "common.provider.byteplus.cdn", "/imgs/providers/byteplus.svg"],
[`${ACCESS_PROVIDER_TYPE_KUBERNETES}-secret`, "common.provider.kubernetes.secret", "/imgs/providers/kubernetes.svg"],
[`${ACCESS_PROVIDER_TYPE_WEBHOOK}`, "common.provider.webhook", "/imgs/providers/webhook.svg"],
];
export const deployTargetsMap: Map<DeployTarget["type"], DeployTarget> = new Map(

View File

@ -10,7 +10,7 @@ import { ClientResponseError } from "pocketbase";
import CertificateDetailDrawer from "@/components/certificate/CertificateDetailDrawer";
import { CertificateModel } from "@/domain/certificate";
import { list as listCertificate, type CertificateListReq } from "@/repository/certificate";
import { list as listCertificate, type ListCertificateRequest } from "@/repository/certificate";
import { getErrMsg } from "@/utils/error";
const CertificateList = () => {
@ -183,7 +183,7 @@ const CertificateList = () => {
return listCertificate({
page: page,
perPage: pageSize,
state: filters["state"] as CertificateListReq["state"],
state: filters["state"] as ListCertificateRequest["state"],
});
},
{

View File

@ -6,17 +6,17 @@ import { getPocketBase } from "./pocketbase";
const COLLECTION_NAME = "certificate";
export type CertificateListReq = {
export type ListCertificateRequest = {
page?: number;
perPage?: number;
state?: "expireSoon" | "expired";
};
export const list = async (req: CertificateListReq) => {
export const list = async (request: ListCertificateRequest) => {
const pb = getPocketBase();
const page = req.page || 1;
const perPage = req.perPage || 10;
const page = request.page || 1;
const perPage = request.perPage || 10;
const options: RecordListOptions = {
sort: "-created",
@ -24,11 +24,11 @@ export const list = async (req: CertificateListReq) => {
requestKey: null,
};
if (req.state === "expireSoon") {
if (request.state === "expireSoon") {
options.filter = pb.filter("expireAt<{:expiredAt}", {
expiredAt: dayjs().add(15, "d").toDate(),
});
} else if (req.state === "expired") {
} else if (request.state === "expired") {
options.filter = pb.filter("expireAt<={:expiredAt}", {
expiredAt: new Date(),
});

View File

@ -1,25 +1,25 @@
import { type RecordListOptions } from "pocketbase";
import { type WorkflowModel, type WorkflowNode, type WorkflowRunLog } from "@/domain/workflow";
import { type WorkflowModel, type WorkflowNode } from "@/domain/workflow";
import { getPocketBase } from "./pocketbase";
const COLLECTION_NAME = "workflow";
export type WorkflowListReq = {
export type ListWorkflowRequest = {
page?: number;
perPage?: number;
enabled?: boolean;
};
export const list = async (req: WorkflowListReq) => {
export const list = async (request: ListWorkflowRequest) => {
const pb = getPocketBase();
const page = req.page || 1;
const perPage = req.perPage || 10;
const page = request.page || 1;
const perPage = request.perPage || 10;
const options: RecordListOptions = { sort: "-created" };
if (req.enabled != null) {
options.filter = pb.filter("enabled={:enabled}", { enabled: req.enabled });
if (request.enabled != null) {
options.filter = pb.filter("enabled={:enabled}", { enabled: request.enabled });
}
return await pb.collection(COLLECTION_NAME).getList<WorkflowModel>(page, perPage, options);
@ -42,21 +42,3 @@ export const save = async (record: Record<string, string | boolean | WorkflowNod
export const remove = async (record: MaybeModelRecordWithId<WorkflowModel>) => {
return await getPocketBase().collection(COLLECTION_NAME).delete(record.id);
};
type WorkflowLogsReq = {
id: string;
page?: number;
perPage?: number;
};
export const logs = async (req: WorkflowLogsReq) => {
const page = req.page || 1;
const perPage = req.perPage || 10;
return await getPocketBase()
.collection("workflow_run_log")
.getList<WorkflowRunLog>(page, perPage, {
sort: "-created",
filter: getPocketBase().filter("workflow={:workflowId}", { workflowId: req.id }),
});
};

View File

@ -0,0 +1,20 @@
import { type WorkflowRunLog } from "@/domain/workflow";
import { getPocketBase } from "./pocketbase";
export type ListWorkflowLogsRequest = {
id: string;
page?: number;
perPage?: number;
};
export const list = async (request: ListWorkflowLogsRequest) => {
const page = request.page || 1;
const perPage = request.perPage || 10;
return await getPocketBase()
.collection("workflow_run_log")
.getList<WorkflowRunLog>(page, perPage, {
filter: getPocketBase().filter("workflow={:workflowId}", { workflowId: request.id }),
sort: "-created",
});
};