chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -1,6 +1,6 @@
import {AccessInput, BaseAccess, IsAccess} from "@certd/pipeline";
import {HttpRequestConfig} from "@certd/basic";
import {CertInfo, CertReader} from "@certd/plugin-cert";
import { AccessInput, BaseAccess, IsAccess } from "@certd/pipeline";
import { HttpRequestConfig } from "@certd/basic";
import { CertInfo, CertReader } from "@certd/plugin-cert";
/**
*/
@@ -8,10 +8,9 @@ import {CertInfo, CertReader} from "@certd/plugin-cert";
name: "apisix",
title: "APISIX授权",
desc: "",
icon: "svg:icon-lucky"
icon: "svg:icon-lucky",
})
export class ApisixAccess extends BaseAccess {
@AccessInput({
title: "Apisix管理地址",
component: {
@@ -19,23 +18,23 @@ export class ApisixAccess extends BaseAccess {
},
required: true,
})
endpoint = '';
endpoint = "";
@AccessInput({
title: 'ApiKey',
title: "ApiKey",
component: {
placeholder: 'ApiKey',
placeholder: "ApiKey",
},
helper: "[参考文档](https://apisix.apache.org/docs/apisix/admin-api/#using-environment-variables)在config中配置admin apiKey",
required: true,
encrypt: true,
})
apiKey = '';
apiKey = "";
@AccessInput({
title: '版本',
title: "版本",
component: {
name:"a-select",
name: "a-select",
options: [
{
label: "v3.x",
@@ -45,78 +44,77 @@ export class ApisixAccess extends BaseAccess {
label: "v2.x",
value: "2",
},
]
],
},
helper: "apisix系统的版本",
value:"3",
value: "3",
required: true,
})
version = '3';
version = "3";
@AccessInput({
title: "测试",
component: {
name: "api-test",
action: "TestRequest"
action: "TestRequest",
},
helper: "点击测试接口是否正常"
helper: "点击测试接口是否正常",
})
testRequest = true;
async onTestRequest() {
await this.getCertList();
return "ok"
return "ok";
}
async getCertList(){
async getCertList() {
const sslPath = this.getSslPath();
const req = {
url :`/apisix/admin/${sslPath}`,
url: `/apisix/admin/${sslPath}`,
method: "get",
}
};
return await this.doRequest(req);
}
getSslPath(){
const sslPath = this.version === '3' ? 'ssls' : 'ssl';
getSslPath() {
const sslPath = this.version === "3" ? "ssls" : "ssl";
return sslPath;
}
async createCert(opts:{cert:CertInfo}){
const certReader = new CertReader(opts.cert)
async createCert(opts: { cert: CertInfo }) {
const certReader = new CertReader(opts.cert);
const sslPath = this.getSslPath();
const req = {
url :`/apisix/admin/${sslPath}`,
url: `/apisix/admin/${sslPath}`,
method: "post",
data:{
data: {
cert: opts.cert.crt,
key: opts.cert.key,
snis: certReader.getAllDomains()
}
}
snis: certReader.getAllDomains(),
},
};
return await this.doRequest(req);
}
async updateCert (opts:{cert:CertInfo,id:string}){
const certReader = new CertReader(opts.cert)
async updateCert(opts: { cert: CertInfo; id: string }) {
const certReader = new CertReader(opts.cert);
const sslPath = this.getSslPath();
const req = {
url :`/apisix/admin/${sslPath}/${opts.id}`,
url: `/apisix/admin/${sslPath}/${opts.id}`,
method: "put",
data:{
data: {
cert: opts.cert.crt,
key: opts.cert.key,
snis: certReader.getAllDomains()
}
}
snis: certReader.getAllDomains(),
},
};
return await this.doRequest(req);
}
async doRequest(req: HttpRequestConfig){
async doRequest(req: HttpRequestConfig) {
const headers = {
"X-API-KEY": this.apiKey,
...req.headers
...req.headers,
};
return await this.ctx.http.request({
headers,
@@ -125,9 +123,6 @@ export class ApisixAccess extends BaseAccess {
logRes: false,
});
}
}
new ApisixAccess();
@@ -1 +1 @@
import "./plugin-refresh-cert.js"
import "./plugin-refresh-cert.js";
@@ -1,7 +1,7 @@
import {IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput} from "@certd/pipeline";
import {CertApplyPluginNames, CertInfo} from "@certd/plugin-cert";
import {createCertDomainGetterInputDefine, createRemoteSelectInputDefine} from "@certd/plugin-lib";
import {ApisixAccess} from "../access.js";
import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
import { ApisixAccess } from "../access.js";
import { AbstractPlusTaskPlugin } from "@certd/plugin-plus";
@IsTaskPlugin({
//命名规范,插件类型+功能(就是目录plugin-demo中的demo),大写字母开头,驼峰命名
@@ -15,9 +15,9 @@ import { AbstractPlusTaskPlugin } from "@certd/plugin-plus";
default: {
//默认值配置照抄即可
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed
}
}
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
//类名规范,跟上面插件名称(name)一致
export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
@@ -27,8 +27,8 @@ export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
helper: "请选择前置任务输出的域名证书",
component: {
name: "output-selector",
from: [...CertApplyPluginNames]
}
from: [...CertApplyPluginNames],
},
// required: true, // 必填
})
cert!: CertInfo;
@@ -41,9 +41,9 @@ export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
title: "Apisix授权",
component: {
name: "access-selector",
type: "apisix" //固定授权类型
type: "apisix", //固定授权类型
},
required: true //必填
required: true, //必填
})
accessId!: string;
//
@@ -54,14 +54,13 @@ export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
helper: "要更新的证书id,如果这里没有,请先给手动绑定一次证书",
action: ApisixRefreshCDNCert.prototype.onGetCertList.name,
pager: false,
search: false
search: false,
})
)
certList!: string[];
//插件实例化时执行的方法
async onInstance() {
}
async onInstance() {}
//插件执行方法
async execute(): Promise<void> {
@@ -74,7 +73,7 @@ export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
await access.updateCert({
id: certId,
cert: this.cert
cert: this.cert,
});
this.logger.info(`----------- 更新证书${certId}成功`);
}
@@ -85,13 +84,12 @@ export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
async onGetCertList(data: PageSearch = {}) {
const access = await this.getAccess<ApisixAccess>(this.accessId);
const res = await access.getCertList()
const list = res.list
const res = await access.getCertList();
const list = res.list;
if (!list || list.length === 0) {
throw new Error("没有找到证书,你可以直接手动输入id,如果id不存在将自动创建");
}
/**
* certificate-id
* name
@@ -101,7 +99,7 @@ export class ApisixRefreshCDNCert extends AbstractPlusTaskPlugin {
return {
label: `${item.value.snis[0]}<${item.value.id}>`,
value: item.value.id,
domain: item.value.snis
domain: item.value.snis,
};
});
return {