mcp-server-esa 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +4 -0
- package/.prettierrc +3 -0
- package/abc.json +8 -0
- package/dist/721.js +305 -0
- package/dist/721.mjs +304 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7475 -0
- package/dist/index.js.LICENSE.txt +27 -0
- package/dist/index.mjs +7448 -0
- package/dist/index.mjs.LICENSE.txt +27 -0
- package/dist/tools/commit.d.ts +9 -0
- package/dist/tools/deploy.d.ts +17 -0
- package/dist/tools/deployments.d.ts +9 -0
- package/dist/tools/list-esa-function.d.ts +26 -0
- package/dist/tools/record.d.ts +25 -0
- package/dist/tools/route.d.ts +49 -0
- package/dist/tools/routine.d.ts +33 -0
- package/dist/tools/site.d.ts +17 -0
- package/dist/utils/helpers.d.ts +25 -0
- package/dist/utils/service.d.ts +39 -0
- package/dist/utils/types.d.ts +59 -0
- package/esa.toml +8 -0
- package/eslint.config.mjs +10 -0
- package/image/readme/1744114566511.png +0 -0
- package/image/readme/1744114625974.png +0 -0
- package/image/readme/1744165412296.png +0 -0
- package/image/readme/1744168230082.gif +0 -0
- package/image/readme/1744168440370.gif +0 -0
- package/image/readme/1744168966418.gif +0 -0
- package/package.json +46 -0
- package/readme.md +281 -0
- package/rslib.config.ts +15 -0
- package/src/index.ts +48 -0
- package/src/tools/commit.ts +90 -0
- package/src/tools/deploy.ts +103 -0
- package/src/tools/deployments.ts +37 -0
- package/src/tools/list-esa-function.ts +92 -0
- package/src/tools/record.ts +115 -0
- package/src/tools/route.ts +314 -0
- package/src/tools/routine.ts +130 -0
- package/src/tools/site.ts +61 -0
- package/src/utils/helpers.ts +181 -0
- package/src/utils/service.ts +337 -0
- package/src/utils/types.ts +71 -0
- package/test.js +0 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { GetRoutineStagingCodeUploadInfoResponse } from '@alicloud/esa20240910';
|
|
2
|
+
import { IOssConfig } from './types';
|
|
3
|
+
import FormData from 'form-data';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
|
|
6
|
+
export function log(...args: unknown[]) {
|
|
7
|
+
const msg = `[DEBUG ${new Date().toISOString()}] ${args.join(' ')}\n`;
|
|
8
|
+
process.stderr.write(msg);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const uploadCodeToOSS = async (
|
|
12
|
+
res: GetRoutineStagingCodeUploadInfoResponse,
|
|
13
|
+
code: string,
|
|
14
|
+
) => {
|
|
15
|
+
const ossConfig = res?.body?.ossPostConfig as IOssConfig;
|
|
16
|
+
|
|
17
|
+
if (res.statusCode !== 200 || !ossConfig) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { OSSAccessKeyId, Signature, callback, Url, key, policy }: IOssConfig =
|
|
22
|
+
ossConfig;
|
|
23
|
+
const formData = new FormData();
|
|
24
|
+
formData.append('OSSAccessKeyId', OSSAccessKeyId);
|
|
25
|
+
formData.append('Signature', Signature);
|
|
26
|
+
formData.append('callback', callback);
|
|
27
|
+
formData.append('x:codeDescription', ossConfig['x:codeDescription']);
|
|
28
|
+
formData.append('policy', policy);
|
|
29
|
+
formData.append('key', key);
|
|
30
|
+
formData.append('file', code);
|
|
31
|
+
|
|
32
|
+
const ossRes = await fetch(Url, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body: formData,
|
|
35
|
+
headers: formData.getHeaders(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return ossRes && ossRes.status === 200;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/* 操作符号枚举 */
|
|
42
|
+
export enum OPERATOR_ENUM {
|
|
43
|
+
Eq = 'eq',
|
|
44
|
+
Ne = 'ne',
|
|
45
|
+
Contains = 'contains',
|
|
46
|
+
Negate_Contains = 'negate_contains',
|
|
47
|
+
StartsWith = 'starts_with',
|
|
48
|
+
Negate_StartsWith = 'negate_starts_with',
|
|
49
|
+
EndsWith = 'ends_with',
|
|
50
|
+
Negate_EndsWith = 'negate_ends_with',
|
|
51
|
+
Matches = 'matches',
|
|
52
|
+
Negate_Matches = 'negate_matches',
|
|
53
|
+
In = 'in',
|
|
54
|
+
Negate_In = 'negate_in',
|
|
55
|
+
Gt = 'gt',
|
|
56
|
+
Lt = 'lt',
|
|
57
|
+
Ge = 'ge',
|
|
58
|
+
Le = 'le',
|
|
59
|
+
InList = 'in_list',
|
|
60
|
+
Negate_InList = 'negate_in_list',
|
|
61
|
+
}
|
|
62
|
+
const RuleMatchTypeHost = 'http.host';
|
|
63
|
+
const RuleMatchTypeUriPath = 'http.request.uri.path';
|
|
64
|
+
const RuleMatchOperatorEq = OPERATOR_ENUM.Eq;
|
|
65
|
+
const RuleMatchOperatorStartsWith = OPERATOR_ENUM.StartsWith;
|
|
66
|
+
const RuleMatchOperatorEndsWith = OPERATOR_ENUM.EndsWith;
|
|
67
|
+
|
|
68
|
+
export const transferRouteToRuleString = (routePath: string): string => {
|
|
69
|
+
if (!routePath) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const index = routePath.indexOf('/');
|
|
74
|
+
let host = '';
|
|
75
|
+
let uriPath = '';
|
|
76
|
+
|
|
77
|
+
if (index < 0) {
|
|
78
|
+
host = routePath;
|
|
79
|
+
uriPath = '/';
|
|
80
|
+
} else {
|
|
81
|
+
host = routePath.substring(0, index);
|
|
82
|
+
uriPath = routePath.substring(index);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let hostOperator = RuleMatchOperatorEq;
|
|
86
|
+
if (host.startsWith('*')) {
|
|
87
|
+
hostOperator = RuleMatchOperatorEndsWith;
|
|
88
|
+
host = host.replace(/\*/g, '');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let uriPathOperator = RuleMatchOperatorEq;
|
|
92
|
+
if (uriPath.endsWith('*')) {
|
|
93
|
+
uriPathOperator = RuleMatchOperatorStartsWith;
|
|
94
|
+
uriPath = uriPath.replace(/\*$/, '');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let ruleStr = '';
|
|
98
|
+
if (hostOperator === RuleMatchOperatorEq) {
|
|
99
|
+
if (uriPathOperator === RuleMatchOperatorEq) {
|
|
100
|
+
ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
|
|
101
|
+
} else if (uriPathOperator === RuleMatchOperatorStartsWith) {
|
|
102
|
+
ruleStr = `(${RuleMatchTypeHost} ${hostOperator} "${host}" and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
|
|
103
|
+
}
|
|
104
|
+
} else if (hostOperator === RuleMatchOperatorEndsWith) {
|
|
105
|
+
if (uriPathOperator === RuleMatchOperatorEq) {
|
|
106
|
+
ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchTypeUriPath} ${uriPathOperator} "${uriPath}")`;
|
|
107
|
+
} else if (uriPathOperator === RuleMatchOperatorStartsWith) {
|
|
108
|
+
ruleStr = `(${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost}, "${host}") and ${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath}, "${uriPath}"))`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return ruleStr;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const transferRuleStringToRoute = (ruleStr: string): string => {
|
|
115
|
+
if (!ruleStr) {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
// 去掉外层括号并按 " and " 分割
|
|
119
|
+
const cleanedRule = ruleStr.replace(/^\(|\)$/g, '');
|
|
120
|
+
const parts = cleanedRule.split(' and ');
|
|
121
|
+
if (parts.length !== 2) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let host = '';
|
|
126
|
+
let uriPath = '';
|
|
127
|
+
|
|
128
|
+
// 处理host部分
|
|
129
|
+
const hostPart = parts[0].trim();
|
|
130
|
+
if (
|
|
131
|
+
hostPart.startsWith(`${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost},`)
|
|
132
|
+
) {
|
|
133
|
+
// host匹配eq时的逻辑
|
|
134
|
+
// ends_with(http.host, "value")
|
|
135
|
+
const match = hostPart.match(/ends_with\(http\.host,\s*"([^"]+)"\)/);
|
|
136
|
+
if (match) {
|
|
137
|
+
host = `*${match[1]}`; // 加前缀 *
|
|
138
|
+
}
|
|
139
|
+
} else if (
|
|
140
|
+
hostPart.startsWith(`${RuleMatchTypeHost} ${RuleMatchOperatorEq}`)
|
|
141
|
+
) {
|
|
142
|
+
// host匹配eq时的逻辑
|
|
143
|
+
// http.host eq "value"
|
|
144
|
+
const match = hostPart.match(/http\.host eq "([^"]+)"/);
|
|
145
|
+
if (match) {
|
|
146
|
+
host = match[1];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 处理uriPath 部分
|
|
151
|
+
const uriPathPart = parts[1].trim();
|
|
152
|
+
if (
|
|
153
|
+
uriPathPart.startsWith(
|
|
154
|
+
`${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath},`,
|
|
155
|
+
)
|
|
156
|
+
) {
|
|
157
|
+
// uriPath匹配startsWith时的逻辑
|
|
158
|
+
// starts_with(http.request.uri.path, "value")
|
|
159
|
+
const match = uriPathPart.match(
|
|
160
|
+
/starts_with\(http\.request\.uri\.path,\s*"([^"]+)"\)/,
|
|
161
|
+
);
|
|
162
|
+
if (match) {
|
|
163
|
+
uriPath = `${match[1]}*`; // 加后缀 *
|
|
164
|
+
}
|
|
165
|
+
} else if (
|
|
166
|
+
uriPathPart.startsWith(`${RuleMatchTypeUriPath} ${RuleMatchOperatorEq}`)
|
|
167
|
+
) {
|
|
168
|
+
// uriPath匹配eq时的逻辑
|
|
169
|
+
// http.request.uri.path eq "value"
|
|
170
|
+
const match = uriPathPart.match(/http\.request\.uri\.path eq "([^"]+)"/);
|
|
171
|
+
if (match) {
|
|
172
|
+
uriPath = match[1];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!host || !uriPath) {
|
|
177
|
+
return '';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return `${host}${uriPath}`;
|
|
181
|
+
};
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import ESA, {
|
|
2
|
+
CommitRoutineStagingCodeRequest,
|
|
3
|
+
CommitRoutineStagingCodeResponse,
|
|
4
|
+
CreateRoutineRelatedRecordRequest,
|
|
5
|
+
CreateRoutineRelatedRecordResponse,
|
|
6
|
+
CreateRoutineRequest,
|
|
7
|
+
CreateRoutineResponse,
|
|
8
|
+
CreateRoutineRouteRequest,
|
|
9
|
+
CreateRoutineRouteResponse,
|
|
10
|
+
DeleteRoutineCodeVersionRequest,
|
|
11
|
+
DeleteRoutineCodeVersionResponse,
|
|
12
|
+
DeleteRoutineRelatedRecordRequest,
|
|
13
|
+
DeleteRoutineRelatedRecordResponse,
|
|
14
|
+
DeleteRoutineRequest,
|
|
15
|
+
DeleteRoutineResponse,
|
|
16
|
+
DeleteRoutineRouteRequest,
|
|
17
|
+
DeleteRoutineRouteResponse,
|
|
18
|
+
GetRoutineRequest,
|
|
19
|
+
GetRoutineResponse,
|
|
20
|
+
GetRoutineRouteRequest,
|
|
21
|
+
GetRoutineRouteResponse,
|
|
22
|
+
GetRoutineStagingCodeUploadInfoRequest,
|
|
23
|
+
GetRoutineStagingCodeUploadInfoResponse,
|
|
24
|
+
ListRoutineRoutesRequest,
|
|
25
|
+
ListRoutineRoutesResponse,
|
|
26
|
+
ListSiteRoutesRequest,
|
|
27
|
+
ListSiteRoutesResponse,
|
|
28
|
+
ListSitesRequest,
|
|
29
|
+
ListSitesResponse,
|
|
30
|
+
PublishRoutineCodeVersionRequest,
|
|
31
|
+
PublishRoutineCodeVersionResponse,
|
|
32
|
+
UpdateRoutineRouteRequest,
|
|
33
|
+
UpdateRoutineRouteResponse,
|
|
34
|
+
} from '@alicloud/esa20240910';
|
|
35
|
+
import * as $OpenApi from '@alicloud/openapi-client';
|
|
36
|
+
import * as $Util from '@alicloud/tea-util';
|
|
37
|
+
import { log } from './helpers';
|
|
38
|
+
import {
|
|
39
|
+
CliConfig,
|
|
40
|
+
GetMatchSiteRequest,
|
|
41
|
+
ListRoutineRelatedRecordsRequest,
|
|
42
|
+
} from './types';
|
|
43
|
+
|
|
44
|
+
export interface ApiMethod<RequestType, ResponseType> {
|
|
45
|
+
(runtime: $Util.RuntimeOptions): Promise<ResponseType>;
|
|
46
|
+
(request: RequestType, runtime: $Util.RuntimeOptions): Promise<ResponseType>;
|
|
47
|
+
}
|
|
48
|
+
class Client {
|
|
49
|
+
client: ESA;
|
|
50
|
+
|
|
51
|
+
constructor() {
|
|
52
|
+
const config = {
|
|
53
|
+
auth: {
|
|
54
|
+
accessKeyId: process.env.ESA_ACCESS_KEY_ID || '',
|
|
55
|
+
accessKeySecret: process.env.ESA_ACCESS_KEY_SECRET || '',
|
|
56
|
+
},
|
|
57
|
+
endpoint: 'esa.cn-hangzhou.aliyuncs.com',
|
|
58
|
+
};
|
|
59
|
+
this.client = Client.createClient(config);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static createClient(config: CliConfig) {
|
|
63
|
+
const apiConfig = new $OpenApi.Config({
|
|
64
|
+
accessKeyId: config.auth?.accessKeyId || '',
|
|
65
|
+
accessKeySecret: config.auth?.accessKeySecret || '',
|
|
66
|
+
endpoint: config.endpoint,
|
|
67
|
+
});
|
|
68
|
+
return new ESA(apiConfig);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
callApi = async <RequestType, ResponseType>(
|
|
72
|
+
action: ApiMethod<RequestType, ResponseType>,
|
|
73
|
+
request?: RequestType,
|
|
74
|
+
): Promise<ResponseType> => {
|
|
75
|
+
const runtime = new $Util.RuntimeOptions({
|
|
76
|
+
connectTimeout: 10000,
|
|
77
|
+
readTimeout: 10000,
|
|
78
|
+
autoretry: true,
|
|
79
|
+
maxAttempts: 3,
|
|
80
|
+
});
|
|
81
|
+
const response = request
|
|
82
|
+
? await action(request, runtime)
|
|
83
|
+
: await action(runtime);
|
|
84
|
+
return response;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
createRoutine(params: CreateRoutineRequest) {
|
|
88
|
+
const request = new CreateRoutineRequest(params);
|
|
89
|
+
log('Creating routine with parameters:', JSON.stringify(params));
|
|
90
|
+
return this.callApi(
|
|
91
|
+
this.client.createRoutine.bind(this.client) as ApiMethod<
|
|
92
|
+
CreateRoutineRequest,
|
|
93
|
+
CreateRoutineResponse
|
|
94
|
+
>,
|
|
95
|
+
request,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
deleteRoutine(params: DeleteRoutineRequest) {
|
|
100
|
+
const request = new DeleteRoutineRequest(params);
|
|
101
|
+
return this.callApi(
|
|
102
|
+
this.client.deleteRoutineWithOptions.bind(this.client) as ApiMethod<
|
|
103
|
+
DeleteRoutineRequest,
|
|
104
|
+
DeleteRoutineResponse
|
|
105
|
+
>,
|
|
106
|
+
request,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getRoutine(params: GetRoutineRequest) {
|
|
111
|
+
const request = new GetRoutineRequest(params);
|
|
112
|
+
return this.callApi(
|
|
113
|
+
this.client.getRoutineWithOptions.bind(this.client) as ApiMethod<
|
|
114
|
+
GetRoutineRequest,
|
|
115
|
+
GetRoutineResponse
|
|
116
|
+
>,
|
|
117
|
+
request,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getRoutineUserInfo() {
|
|
122
|
+
return this.callApi(this.client.getRoutineUserInfo.bind(this.client));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async getRoutineStagingCodeUploadInfo(
|
|
126
|
+
params: GetRoutineStagingCodeUploadInfoRequest,
|
|
127
|
+
) {
|
|
128
|
+
const request = new GetRoutineStagingCodeUploadInfoRequest(params);
|
|
129
|
+
|
|
130
|
+
return this.callApi(
|
|
131
|
+
this.client.getRoutineStagingCodeUploadInfo.bind(
|
|
132
|
+
this.client,
|
|
133
|
+
) as ApiMethod<
|
|
134
|
+
GetRoutineStagingCodeUploadInfoRequest,
|
|
135
|
+
GetRoutineStagingCodeUploadInfoResponse
|
|
136
|
+
>,
|
|
137
|
+
request,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
commitRoutineStagingCode(params: CommitRoutineStagingCodeRequest) {
|
|
142
|
+
const request = new CommitRoutineStagingCodeRequest(params);
|
|
143
|
+
return this.callApi(
|
|
144
|
+
this.client.commitRoutineStagingCode.bind(this.client) as ApiMethod<
|
|
145
|
+
CommitRoutineStagingCodeRequest,
|
|
146
|
+
CommitRoutineStagingCodeResponse
|
|
147
|
+
>,
|
|
148
|
+
request,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
publishRoutineCodeVersion(params: PublishRoutineCodeVersionRequest) {
|
|
153
|
+
const request = new PublishRoutineCodeVersionRequest(params);
|
|
154
|
+
return this.callApi(
|
|
155
|
+
this.client.publishRoutineCodeVersion.bind(this.client) as ApiMethod<
|
|
156
|
+
PublishRoutineCodeVersionRequest,
|
|
157
|
+
PublishRoutineCodeVersionResponse
|
|
158
|
+
>,
|
|
159
|
+
request,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
listRoutineCanaryAreas() {
|
|
164
|
+
return this.callApi(this.client.listRoutineCanaryAreas.bind(this.client));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
listSites(params: ListSitesRequest) {
|
|
168
|
+
const request = new ListSitesRequest(params);
|
|
169
|
+
return this.callApi(
|
|
170
|
+
this.client.listSites.bind(this.client) as ApiMethod<
|
|
171
|
+
ListSitesRequest,
|
|
172
|
+
ListSitesResponse
|
|
173
|
+
>,
|
|
174
|
+
request,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
deleteRoutineCodeVersion(params: DeleteRoutineCodeVersionRequest) {
|
|
179
|
+
const request = new DeleteRoutineCodeVersionRequest(params);
|
|
180
|
+
return this.callApi(
|
|
181
|
+
this.client.deleteRoutineCodeVersion.bind(this.client) as ApiMethod<
|
|
182
|
+
DeleteRoutineCodeVersionRequest,
|
|
183
|
+
DeleteRoutineCodeVersionResponse
|
|
184
|
+
>,
|
|
185
|
+
request,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
createRoutineRelatedRecord(params: CreateRoutineRelatedRecordRequest) {
|
|
190
|
+
const request = new CreateRoutineRelatedRecordRequest(params);
|
|
191
|
+
return this.callApi(
|
|
192
|
+
this.client.createRoutineRelatedRecord.bind(this.client) as ApiMethod<
|
|
193
|
+
CreateRoutineRelatedRecordRequest,
|
|
194
|
+
CreateRoutineRelatedRecordResponse
|
|
195
|
+
>,
|
|
196
|
+
request,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
createRoutineRoute(params: CreateRoutineRouteRequest) {
|
|
201
|
+
const request = new CreateRoutineRouteRequest(params);
|
|
202
|
+
return this.callApi(
|
|
203
|
+
this.client.createRoutineRoute.bind(this.client) as ApiMethod<
|
|
204
|
+
CreateRoutineRouteRequest,
|
|
205
|
+
CreateRoutineRouteResponse
|
|
206
|
+
>,
|
|
207
|
+
request,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
deleteRoutineRoute(params: DeleteRoutineRouteRequest) {
|
|
212
|
+
const request = new DeleteRoutineRouteRequest(params);
|
|
213
|
+
return this.callApi(
|
|
214
|
+
this.client.deleteRoutineRoute.bind(this.client) as ApiMethod<
|
|
215
|
+
DeleteRoutineRouteRequest,
|
|
216
|
+
DeleteRoutineRouteResponse
|
|
217
|
+
>,
|
|
218
|
+
request,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
getRoutineRoute(params: GetRoutineRouteRequest) {
|
|
223
|
+
const request = new GetRoutineRouteRequest(params);
|
|
224
|
+
return this.callApi(
|
|
225
|
+
this.client.getRoutineRoute.bind(this.client) as ApiMethod<
|
|
226
|
+
GetRoutineRouteRequest,
|
|
227
|
+
GetRoutineRouteResponse
|
|
228
|
+
>,
|
|
229
|
+
request,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
listSiteRoutes(params: ListSiteRoutesRequest) {
|
|
234
|
+
const request = new ListSiteRoutesRequest(params);
|
|
235
|
+
return this.callApi(
|
|
236
|
+
this.client.listSiteRoutes.bind(this.client) as ApiMethod<
|
|
237
|
+
ListSiteRoutesRequest,
|
|
238
|
+
ListSiteRoutesResponse
|
|
239
|
+
>,
|
|
240
|
+
request,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
listRoutineRoutes(params: ListRoutineRoutesRequest) {
|
|
245
|
+
const request = new ListRoutineRoutesRequest(params);
|
|
246
|
+
return this.callApi(
|
|
247
|
+
this.client.listRoutineRoutes.bind(this.client) as ApiMethod<
|
|
248
|
+
ListRoutineRoutesRequest,
|
|
249
|
+
ListRoutineRoutesResponse
|
|
250
|
+
>,
|
|
251
|
+
request,
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
updateRoutineRoute(params: UpdateRoutineRouteRequest) {
|
|
256
|
+
const request = new UpdateRoutineRouteRequest(params);
|
|
257
|
+
return this.callApi(
|
|
258
|
+
this.client.updateRoutineRoute.bind(this.client) as ApiMethod<
|
|
259
|
+
UpdateRoutineRouteRequest,
|
|
260
|
+
UpdateRoutineRouteResponse
|
|
261
|
+
>,
|
|
262
|
+
request,
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
deleteRoutineRelatedRecord(params: DeleteRoutineRelatedRecordRequest) {
|
|
267
|
+
const request = new DeleteRoutineRelatedRecordRequest(params);
|
|
268
|
+
return this.callApi(
|
|
269
|
+
this.client.deleteRoutineRelatedRecord.bind(this.client) as ApiMethod<
|
|
270
|
+
DeleteRoutineRelatedRecordRequest,
|
|
271
|
+
DeleteRoutineRelatedRecordResponse
|
|
272
|
+
>,
|
|
273
|
+
request,
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
getMatchSite(requestParams: GetMatchSiteRequest) {
|
|
278
|
+
const params = {
|
|
279
|
+
action: 'GetMatchSite',
|
|
280
|
+
version: '2024-09-10',
|
|
281
|
+
protocol: 'https',
|
|
282
|
+
method: 'GET',
|
|
283
|
+
authType: 'AK',
|
|
284
|
+
bodyType: 'json',
|
|
285
|
+
reqBodyType: 'json',
|
|
286
|
+
style: 'RPC',
|
|
287
|
+
pathname: '/',
|
|
288
|
+
toMap: function () {
|
|
289
|
+
return this;
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
const request = new $OpenApi.OpenApiRequest({
|
|
293
|
+
query: {
|
|
294
|
+
RecordName: requestParams.recordName,
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
const runtime = {
|
|
298
|
+
toMap: function () {
|
|
299
|
+
return this;
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
return this.client.callApi(params, request, runtime);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
listRoutineRelatedRecords(requestParams: ListRoutineRelatedRecordsRequest) {
|
|
306
|
+
const params = {
|
|
307
|
+
action: 'ListRoutineRelatedRecords',
|
|
308
|
+
version: '2024-09-10',
|
|
309
|
+
protocol: 'https',
|
|
310
|
+
method: 'GET',
|
|
311
|
+
authType: 'AK',
|
|
312
|
+
bodyType: 'json',
|
|
313
|
+
reqBodyType: 'json',
|
|
314
|
+
style: 'RPC',
|
|
315
|
+
pathname: '/',
|
|
316
|
+
toMap: function () {
|
|
317
|
+
return this;
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
const request = new $OpenApi.OpenApiRequest({
|
|
321
|
+
query: {
|
|
322
|
+
Name: requestParams.Name,
|
|
323
|
+
PageNumber: requestParams.PageNumber,
|
|
324
|
+
PageSize: requestParams.PageSize,
|
|
325
|
+
SearchKeyWord: requestParams.SearchKeyWord,
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
const runtime = {
|
|
329
|
+
toMap: function () {
|
|
330
|
+
return this;
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
return this.client.callApi(params, request, runtime);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export default new Client();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
Result,
|
|
4
|
+
CallToolRequestSchema,
|
|
5
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import { CreateRoutineRouteRequest } from '@alicloud/esa20240910';
|
|
7
|
+
|
|
8
|
+
export type ToolHandlers = Record<
|
|
9
|
+
string,
|
|
10
|
+
(request: z.infer<typeof CallToolRequestSchema>) => Promise<Result>
|
|
11
|
+
>;
|
|
12
|
+
export interface IOssConfig {
|
|
13
|
+
OSSAccessKeyId: string;
|
|
14
|
+
Signature: string;
|
|
15
|
+
Url: string;
|
|
16
|
+
callback: string;
|
|
17
|
+
key: string;
|
|
18
|
+
policy: string;
|
|
19
|
+
'x:codeDescription': string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class CreateRoutineRouteRequestExt extends CreateRoutineRouteRequest {
|
|
23
|
+
mode: 'simple' | 'custom';
|
|
24
|
+
constructor(params: CreateRoutineRouteRequest) {
|
|
25
|
+
super(params);
|
|
26
|
+
this.mode = params.mode;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AuthConfig {
|
|
31
|
+
accessKeyId: string;
|
|
32
|
+
accessKeySecret: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CliConfig {
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
auth?: AuthConfig;
|
|
38
|
+
endpoint?: string;
|
|
39
|
+
lang?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface GetMatchSiteRequest {
|
|
43
|
+
recordName: string;
|
|
44
|
+
}
|
|
45
|
+
export interface GetMatchSiteResponse {
|
|
46
|
+
code: string;
|
|
47
|
+
data: { SiteId: number; SiteName: string };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ListRoutineRelatedRecordsRequest {
|
|
51
|
+
Name: string;
|
|
52
|
+
PageNumber?: number;
|
|
53
|
+
PageSize?: number;
|
|
54
|
+
SearchKeyWord?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ListRoutineRelatedRecordsResponse {
|
|
57
|
+
code: string;
|
|
58
|
+
data: {
|
|
59
|
+
RequestId: string;
|
|
60
|
+
PageNumber: number;
|
|
61
|
+
PageSize: number;
|
|
62
|
+
TotalCount: number;
|
|
63
|
+
RelatedRecords: {
|
|
64
|
+
RecordName: string;
|
|
65
|
+
SiteId: number;
|
|
66
|
+
SiteName: string;
|
|
67
|
+
RecordId: number;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export type Map = Record<string, unknown>;
|
package/test.js
ADDED
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2021"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"noEmit": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"useDefineForClassFields": true,
|
|
13
|
+
"allowImportingTsExtensions": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src"]
|
|
16
|
+
}
|