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
@@ -4,18 +4,17 @@ import { IsAccess, AccessInput, BaseAccess, PageSearch } from "@certd/pipeline";
name: "spaceship",
title: "Spaceship.com 授权",
icon: "clarity:plugin-line",
desc: "Spaceship.com API 授权插件"
desc: "Spaceship.com API 授权插件",
})
export class SpaceshipAccess extends BaseAccess {
@AccessInput({
title: "API Key",
component: {
placeholder: "请输入 API Key"
placeholder: "请输入 API Key",
},
required: true,
encrypt: true,
helper: "前往 [获取 API Key](https://www.spaceship.com/application/api-manager/)"
helper: "前往 [获取 API Key](https://www.spaceship.com/application/api-manager/)",
})
apiKey = "";
@@ -24,10 +23,10 @@ export class SpaceshipAccess extends BaseAccess {
component: {
name: "a-input-password",
vModel: "value",
placeholder: "请输入 API Secret"
placeholder: "请输入 API Secret",
},
required: true,
encrypt: true
encrypt: true,
})
apiSecret = "";
@@ -35,9 +34,9 @@ export class SpaceshipAccess extends BaseAccess {
title: "测试",
component: {
name: "api-test",
action: "TestRequest"
action: "TestRequest",
},
helper: "测试 API 连接是否正常,需要域名查询权限"
helper: "测试 API 连接是否正常,需要域名查询权限",
})
testRequest = true;
@@ -46,24 +45,19 @@ export class SpaceshipAccess extends BaseAccess {
return "ok";
}
async doRequest(options: {
url: string;
method: 'GET' | 'POST' | 'DELETE' | 'PUT';
params?: any;
data?: any;
}) {
async doRequest(options: { url: string; method: "GET" | "POST" | "DELETE" | "PUT"; params?: any; data?: any }) {
const headers = {
"X-Api-Key": this.apiKey,
"X-Api-Secret": this.apiSecret
"X-Api-Secret": this.apiSecret,
};
try {
const res = await this.ctx.http.request({
url: options.url,
method: options.method,
headers,
params: options.params,
data: options.data
data: options.data,
});
return res;
} catch (error: any) {
@@ -72,22 +66,22 @@ export class SpaceshipAccess extends BaseAccess {
if (error.response) {
const headers = error.response.headers;
const data = error.response.data;
errorMsg.push(`API 请求失败: ${status}`);
if (headers['spaceship-error-code']) {
errorMsg.push(`错误代码: ${headers['spaceship-error-code']}`);
if (headers["spaceship-error-code"]) {
errorMsg.push(`错误代码: ${headers["spaceship-error-code"]}`);
}
if (headers['spaceship-operation-id']) {
errorMsg.push(`操作ID: ${headers['spaceship-operation-id']}`);
if (headers["spaceship-operation-id"]) {
errorMsg.push(`操作ID: ${headers["spaceship-operation-id"]}`);
}
if (data && data.detail) {
errorMsg.push(`错误详情: ${data.detail}`);
}
this.ctx.logger.error(`Spaceship API 错误: ${errorMsg.join(' | ')}`);
this.ctx.logger.error(`Spaceship API 错误: ${errorMsg.join(" | ")}`);
} else if (error.request) {
errorMsg.push(`请求发送失败: ${error.message}`);
this.ctx.logger.error(`Spaceship API 请求发送失败: ${error.message}`);
@@ -95,8 +89,8 @@ export class SpaceshipAccess extends BaseAccess {
errorMsg.push(`请求配置错误: ${error.message}`);
this.ctx.logger.error(`Spaceship API 请求配置错误: ${error.message}`);
}
const error2 = new Error(errorMsg.join(' | '));
const error2 = new Error(errorMsg.join(" | "));
//@ts-ignore
error2.status = status;
throw error2;
@@ -106,19 +100,19 @@ export class SpaceshipAccess extends BaseAccess {
async GetDomainList(req: PageSearch) {
const take = req.pageSize || 100;
const skip = ((req.pageNo || 1) - 1) * take;
const res = await this.doRequest({
url: "https://spaceship.dev/api/v1/domains",
method: "GET",
params: {
take,
skip
}
skip,
},
});
return {
total: res.total || 0,
list: res.items || []
list: res.items || [],
};
}
@@ -126,7 +120,7 @@ export class SpaceshipAccess extends BaseAccess {
try {
const res = await this.doRequest({
url: `https://spaceship.dev/api/v1/domains/${domain}`,
method: "GET"
method: "GET",
});
return res;
} catch (error: any) {
@@ -142,7 +136,6 @@ export class SpaceshipAccess extends BaseAccess {
const hashCode = this.ctx.utils.hash.sha256(hashStr);
return `spaceship-${hashCode}`;
}
}
new SpaceshipAccess();
new SpaceshipAccess();
@@ -12,7 +12,7 @@ export type SpaceshipRecord = {
desc: "Spaceship 域名解析",
icon: "clarity:plugin-line",
accessType: "spaceship",
order: 99
order: 99,
})
export class SpaceshipProvider extends AbstractDnsProvider<SpaceshipRecord> {
access!: SpaceshipAccess;
@@ -38,10 +38,10 @@ export class SpaceshipProvider extends AbstractDnsProvider<SpaceshipRecord> {
type: type,
value: value,
name: hostRecord,
ttl: 60
}
]
}
ttl: 60,
},
],
},
});
return recordRes;
@@ -59,9 +59,9 @@ export class SpaceshipProvider extends AbstractDnsProvider<SpaceshipRecord> {
{
type: recordReq.type,
value: recordReq.value,
name: recordReq.hostRecord
}
]
name: recordReq.hostRecord,
},
],
});
this.logger.info("删除域名解析成功:", JSON.stringify(recordReq));
@@ -69,17 +69,17 @@ export class SpaceshipProvider extends AbstractDnsProvider<SpaceshipRecord> {
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
const res = await this.access.GetDomainList(req);
const list = res.list.map((item: any) => ({
domain: item.name,
id: item.name
id: item.name,
}));
return {
total: res.total || 0,
list: list || []
list: list || [],
};
}
}
new SpaceshipProvider();
new SpaceshipProvider();
@@ -1,2 +1,2 @@
import "./access.js";
import "./dns-provider.js";
import "./dns-provider.js";