feat(datasource): 完成 M03 数据源配置与熔断巡检
交付三种引擎登记、草稿/已保存连接测试、可逆启用、每源熔断与 Cron 巡检,以及控制台页面;用户确认收尾后标 DONE_LOCAL。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f17bf19709
commit
e6d37d176d
98 files changed
+9097
-91
No files matched your search
@@ -0,0 +1,66 @@
|
||||
/** Calls to the /datasources routes. Each one returns the unwrapped envelope data. */
|
||||
|
||||
import { api } from "../api";
|
||||
import type { CreatePayload, DraftTestPayload, UpdatePayload } from "./payload";
|
||||
import type {
|
||||
ConnectionTestOutcome,
|
||||
Datasource,
|
||||
DatasourceList,
|
||||
DatasourceReferences,
|
||||
DraftTestOutcome,
|
||||
} from "./types";
|
||||
|
||||
const JSON_HEADERS = { "Content-Type": "application/json" };
|
||||
|
||||
export function listDatasources(): Promise<DatasourceList> {
|
||||
return api<DatasourceList>("/datasources");
|
||||
}
|
||||
|
||||
export function getDatasource(id: string): Promise<Datasource> {
|
||||
return api<Datasource>(`/datasources/${encodeURIComponent(id)}`);
|
||||
}
|
||||
|
||||
export function createDatasource(payload: CreatePayload): Promise<Datasource> {
|
||||
return api<Datasource>("/datasources", {
|
||||
method: "POST",
|
||||
headers: JSON_HEADERS,
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateDatasource(id: string, payload: UpdatePayload): Promise<Datasource> {
|
||||
return api<Datasource>(`/datasources/${encodeURIComponent(id)}`, {
|
||||
method: "PATCH",
|
||||
headers: JSON_HEADERS,
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function disableDatasource(id: string): Promise<Datasource> {
|
||||
return api<Datasource>(`/datasources/${encodeURIComponent(id)}/disable`, { method: "POST" });
|
||||
}
|
||||
|
||||
/** Enabling does not touch the circuit state and needs no prior test. */
|
||||
export function enableDatasource(id: string): Promise<Datasource> {
|
||||
return api<Datasource>(`/datasources/${encodeURIComponent(id)}/enable`, { method: "POST" });
|
||||
}
|
||||
|
||||
/** Probe the form's values without saving. A failed probe throws like the saved test. */
|
||||
export function testDraftDatasource(payload: DraftTestPayload): Promise<DraftTestOutcome> {
|
||||
return api<DraftTestOutcome>("/datasources/test-draft", {
|
||||
method: "POST",
|
||||
headers: JSON_HEADERS,
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
/** A failed probe is HTTP 400 code 40000 with details.category, so it throws BusinessError. */
|
||||
export function testDatasource(id: string): Promise<ConnectionTestOutcome> {
|
||||
return api<ConnectionTestOutcome>(`/datasources/${encodeURIComponent(id)}/test`, {
|
||||
method: "POST",
|
||||
});
|
||||
}
|
||||
|
||||
export function getReferences(id: string): Promise<DatasourceReferences> {
|
||||
return api<DatasourceReferences>(`/datasources/${encodeURIComponent(id)}/references`);
|
||||
}
|
||||
Reference in new issue
Block a user