@taole/deploy-helper 1.0.2 → 1.0.4

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.
Files changed (32) hide show
  1. package/README.md +1 -4
  2. package/index.mjs +2 -39
  3. package/lib/pipelineApi.mjs +17 -16
  4. package/lib/util.mjs +0 -40
  5. package/lib/yunxiaoFlowApi.mjs +115 -0
  6. package/package.json +4 -7
  7. package/lib/offlinePkg.mjs +0 -333
  8. package/lib/upload.js +0 -49
  9. package/modules/alibabacloud-devops-mcp-server/dist/common/errors.js +0 -69
  10. package/modules/alibabacloud-devops-mcp-server/dist/common/modularTemplates.js +0 -483
  11. package/modules/alibabacloud-devops-mcp-server/dist/common/pipelineTemplates.js +0 -19
  12. package/modules/alibabacloud-devops-mcp-server/dist/common/types.js +0 -1119
  13. package/modules/alibabacloud-devops-mcp-server/dist/common/utils.js +0 -353
  14. package/modules/alibabacloud-devops-mcp-server/dist/common/version.js +0 -1
  15. package/modules/alibabacloud-devops-mcp-server/dist/index.js +0 -1067
  16. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/branches.js +0 -144
  17. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequestComments.js +0 -89
  18. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequests.js +0 -203
  19. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/compare.js +0 -26
  20. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/files.js +0 -233
  21. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/repositories.js +0 -64
  22. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/hostGroup.js +0 -48
  23. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipeline.js +0 -514
  24. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipelineJob.js +0 -113
  25. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/serviceConnection.js +0 -23
  26. package/modules/alibabacloud-devops-mcp-server/dist/operations/organization/members.js +0 -94
  27. package/modules/alibabacloud-devops-mcp-server/dist/operations/organization/organization.js +0 -73
  28. package/modules/alibabacloud-devops-mcp-server/dist/operations/packages/artifacts.js +0 -64
  29. package/modules/alibabacloud-devops-mcp-server/dist/operations/packages/repositories.js +0 -35
  30. package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/project.js +0 -206
  31. package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/sprint.js +0 -30
  32. package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/workitem.js +0 -264
@@ -1,353 +0,0 @@
1
- import { getUserAgent } from "universal-user-agent";
2
- import { createYunxiaoError } from "./errors.js";
3
- import { VERSION } from "./version.js";
4
- const DEFAULT_YUNXIAO_API_BASE_URL = "https://openapi-rdc.aliyuncs.com";
5
- /**
6
- * Get the Yunxiao API base URL from environment variables or use the default
7
- * @returns The Yunxiao API base URL
8
- */
9
- export function getYunxiaoApiBaseUrl() {
10
- return process.env.YUNXIAO_API_BASE_URL || DEFAULT_YUNXIAO_API_BASE_URL;
11
- }
12
- let isDebug = false;
13
- export function enableDebug() {
14
- isDebug = true;
15
- }
16
- export function debug(message, data) {
17
- if(!isDebug){
18
- return;
19
- }
20
- if (data !== undefined) {
21
- console.error(`[DEBUG] ${message}`, typeof data === 'object' ? JSON.stringify(data, null, 2) : data);
22
- }
23
- else {
24
- console.error(`[DEBUG] ${message}`);
25
- }
26
- }
27
- async function parseResponseBody(response) {
28
- const contentType = response.headers.get("content-type");
29
- if (contentType?.includes("application/json")) {
30
- return response.json();
31
- }
32
- return response.text();
33
- }
34
- export function buildUrl(baseUrl, params) {
35
- // Handle baseUrl that doesn't have protocol
36
- const isAbsolute = baseUrl.startsWith("http://") || baseUrl.startsWith("https://");
37
- const fullBaseUrl = isAbsolute ? baseUrl : `${getYunxiaoApiBaseUrl()}${baseUrl.startsWith('/') ? baseUrl : `/${baseUrl}`}`;
38
- try {
39
- const url = new URL(fullBaseUrl);
40
- Object.entries(params).forEach(([key, value]) => {
41
- if (value !== undefined) {
42
- url.searchParams.append(key, value.toString());
43
- }
44
- });
45
- const result = url.toString();
46
- debug(`[DEBUG] Final URL: ${result}`);
47
- // If we started with a relative URL, return just the path portion
48
- if (!baseUrl.startsWith('http')) {
49
- // Extract the path and query string from the full URL
50
- const urlObj = new URL(result);
51
- return urlObj.pathname + urlObj.search;
52
- }
53
- return result;
54
- }
55
- catch (error) {
56
- console.error(`[ERROR] Failed to build URL: ${error}`);
57
- // Fallback: manually append query parameters
58
- let urlWithParams = baseUrl;
59
- const queryParts = [];
60
- Object.entries(params).forEach(([key, value]) => {
61
- if (value !== undefined) {
62
- queryParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`);
63
- }
64
- });
65
- if (queryParts.length > 0) {
66
- urlWithParams += (urlWithParams.includes('?') ? '&' : '?') + queryParts.join('&');
67
- }
68
- console.error(`[DEBUG] Fallback URL: ${urlWithParams}`);
69
- return urlWithParams;
70
- }
71
- }
72
- const USER_AGENT = `modelcontextprotocol/servers/alibabacloud-devops-mcp-server/v${VERSION} ${getUserAgent()}`;
73
- export async function yunxiaoRequest(urlPath, options = {}) {
74
- // Check if the URL is already a full URL or a path
75
- const isAbsolute = urlPath.startsWith("http://") || urlPath.startsWith("https://");
76
- let url = isAbsolute ? urlPath : `${getYunxiaoApiBaseUrl()}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`;
77
- const requestHeaders = {
78
- "Accept": "application/json",
79
- "Content-Type": "application/json",
80
- "User-Agent": USER_AGENT,
81
- ...options.headers,
82
- };
83
- if (process.env.YUNXIAO_ACCESS_TOKEN) {
84
- requestHeaders["x-yunxiao-token"] = process.env.YUNXIAO_ACCESS_TOKEN;
85
- }
86
- debug(`Request: ${options.method} ${url}`);
87
- debug(`Headers:`, requestHeaders);
88
- debug(`Body:`, options.body);
89
- const response = await fetch(url, {
90
- method: options.method || "GET",
91
- headers: requestHeaders,
92
- body: options.body ? JSON.stringify(options.body) : undefined,
93
- });
94
- const responseBody = await parseResponseBody(response);
95
- debug(`Response Body:`, responseBody);
96
- if (!response.ok) {
97
- throw createYunxiaoError(response.status, responseBody);
98
- }
99
- return responseBody;
100
- }
101
- export function pathEscape(filePath) {
102
- // 先使用encodeURIComponent进行编码
103
- let encoded = encodeURIComponent(filePath);
104
- // 将编码后的%2F(/的编码)替换回/
105
- encoded = encoded.replace(/%2F/gi, "/");
106
- return encoded;
107
- }
108
- /**
109
- * Handle repository ID encoding
110
- * @param repositoryId Repository ID which may contain unencoded slash
111
- * @returns Properly encoded repository ID
112
- */
113
- export function handleRepositoryIdEncoding(repositoryId) {
114
- let encodedRepoId = repositoryId;
115
- // Automatically handle unencoded slashes in repositoryId
116
- if (repositoryId.includes("/")) {
117
- // Found unencoded slash, automatically URL encode it
118
- const parts = repositoryId.split("/", 2);
119
- if (parts.length === 2) {
120
- const encodedRepoName = encodeURIComponent(parts[1]);
121
- // Remove + signs from encoding (spaces are encoded as +, but we need %20)
122
- const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
123
- encodedRepoId = `${parts[0]}%2F${formattedEncodedName}`;
124
- }
125
- }
126
- return encodedRepoId;
127
- }
128
- /**
129
- * Converts a floating point number to an integer string (removes decimal point and decimal part)
130
- * Used primarily for handling numeric IDs that might come as floats from JSON parsing
131
- * @param value Value to convert
132
- * @returns Integer string representation
133
- */
134
- export function floatToIntString(value) {
135
- // 如果传入的是字符串,先尝试转为浮点数
136
- if (typeof value === 'string') {
137
- const floatValue = parseFloat(value);
138
- if (!isNaN(floatValue)) {
139
- value = floatValue;
140
- }
141
- else {
142
- return value; // 如果转换失败,返回原字符串
143
- }
144
- }
145
- // 处理浮点数
146
- if (typeof value === 'number') {
147
- const intValue = Math.floor(value + 0.5); // 四舍五入转整数
148
- return intValue.toString();
149
- }
150
- // 处理其他情况,直接转字符串
151
- return String(value);
152
- }
153
- /**
154
- * 将各种时间格式转换为毫秒时间戳
155
- * 支持:
156
- * - 已有时间戳(number)直接返回
157
- * - Date对象转换为时间戳
158
- * - ISO格式日期字符串 (如: '2023-01-01T00:00:00Z')
159
- * - 日期字符串 (如: '2023-01-01')
160
- *
161
- * @param time 时间输入
162
- * @returns 毫秒时间戳
163
- */
164
- export function convertToTimestamp(time) {
165
- if (typeof time === 'number') {
166
- // 如果已经是数字,假设已是时间戳
167
- return time;
168
- }
169
- else if (time instanceof Date) {
170
- // 如果是Date对象,转换为时间戳
171
- return time.getTime();
172
- }
173
- else if (typeof time === 'string') {
174
- // 尝试解析日期字符串
175
- const date = new Date(time);
176
- if (!isNaN(date.getTime())) {
177
- return date.getTime();
178
- }
179
- }
180
- // 无法转换时返回原值(如果是数字)或当前时间戳
181
- return typeof time === 'number' ? time : Date.now();
182
- }
183
- /**
184
- * Get start of today timestamp
185
- * @returns Timestamp for start of the current day (00:00:00)
186
- */
187
- export function getStartOfTodayTimestamp() {
188
- const now = new Date();
189
- // Reset time to start of day (00:00:00.000)
190
- now.setHours(0, 0, 0, 0);
191
- return now.getTime();
192
- }
193
- /**
194
- * Get end of today timestamp
195
- * @returns Timestamp for end of the current day (23:59:59.999)
196
- */
197
- export function getEndOfTodayTimestamp() {
198
- const now = new Date();
199
- // Set time to end of day (23:59:59.999)
200
- now.setHours(23, 59, 59, 999);
201
- return now.getTime();
202
- }
203
- /**
204
- * Get timestamp for start of a specific day
205
- * @param date Date object or date string
206
- * @returns Timestamp for start of the specified day
207
- */
208
- export function getStartOfDayTimestamp(date) {
209
- const targetDate = typeof date === 'string' ? new Date(date) : new Date(date);
210
- targetDate.setHours(0, 0, 0, 0);
211
- return targetDate.getTime();
212
- }
213
- /**
214
- * Get timestamp for end of a specific day
215
- * @param date Date object or date string
216
- * @returns Timestamp for end of the specified day
217
- */
218
- export function getEndOfDayTimestamp(date) {
219
- const targetDate = typeof date === 'string' ? new Date(date) : new Date(date);
220
- targetDate.setHours(23, 59, 59, 999);
221
- return targetDate.getTime();
222
- }
223
- /**
224
- * Get timestamp for start of current week
225
- * @param startOnMonday Whether week should start on Monday (true) or Sunday (false)
226
- * @returns Timestamp for start of the current week
227
- */
228
- export function getStartOfWeekTimestamp(startOnMonday = true) {
229
- const now = new Date();
230
- const dayOfWeek = now.getDay(); // 0 is Sunday, 1 is Monday, etc.
231
- const diff = startOnMonday ?
232
- (dayOfWeek === 0 ? 6 : dayOfWeek - 1) : // If startOnMonday, set Sunday as day 7
233
- dayOfWeek;
234
- // Set to beginning of the week
235
- now.setDate(now.getDate() - diff);
236
- now.setHours(0, 0, 0, 0);
237
- return now.getTime();
238
- }
239
- /**
240
- * Get timestamp for end of current week
241
- * @param startOnMonday Whether week should start on Monday (true) or Sunday (false)
242
- * @returns Timestamp for end of the current week
243
- */
244
- export function getEndOfWeekTimestamp(startOnMonday = true) {
245
- const now = new Date();
246
- const dayOfWeek = now.getDay(); // 0 is Sunday, 1 is Monday, etc.
247
- const diff = startOnMonday ?
248
- (dayOfWeek === 0 ? 0 : 7 - dayOfWeek) : // If startOnMonday, set Sunday as day 7
249
- (6 - dayOfWeek);
250
- // Set to end of the week
251
- now.setDate(now.getDate() + diff);
252
- now.setHours(23, 59, 59, 999);
253
- return now.getTime();
254
- }
255
- /**
256
- * Get timestamp for start of current month
257
- * @returns Timestamp for start of the current month
258
- */
259
- export function getStartOfMonthTimestamp() {
260
- const now = new Date();
261
- now.setDate(1); // First day of current month
262
- now.setHours(0, 0, 0, 0);
263
- return now.getTime();
264
- }
265
- /**
266
- * Get timestamp for end of current month
267
- * @returns Timestamp for end of the current month
268
- */
269
- export function getEndOfMonthTimestamp() {
270
- const now = new Date();
271
- now.setMonth(now.getMonth() + 1); // Move to next month
272
- now.setDate(0); // Last day of previous month (i.e., current month)
273
- now.setHours(23, 59, 59, 999);
274
- return now.getTime();
275
- }
276
- /**
277
- * Analyzes natural language date reference and returns corresponding timestamp range
278
- * @param dateReference Natural language date reference (e.g., "today", "this week", "last month")
279
- * @returns Object containing start and end timestamps
280
- */
281
- export function parseDateReference(dateReference) {
282
- if (!dateReference) {
283
- // Default to all time
284
- return {
285
- startTime: 0,
286
- endTime: Date.now()
287
- };
288
- }
289
- const normalizedRef = dateReference.trim().toLowerCase();
290
- // Today/yesterday
291
- if (normalizedRef === 'today' || normalizedRef === '今天') {
292
- return {
293
- startTime: getStartOfTodayTimestamp(),
294
- endTime: getEndOfTodayTimestamp()
295
- };
296
- }
297
- if (normalizedRef === 'yesterday' || normalizedRef === '昨天') {
298
- const yesterday = new Date();
299
- yesterday.setDate(yesterday.getDate() - 1);
300
- return {
301
- startTime: getStartOfDayTimestamp(yesterday),
302
- endTime: getEndOfDayTimestamp(yesterday)
303
- };
304
- }
305
- // This week/last week
306
- if (normalizedRef === 'this week' || normalizedRef === '本周' ||
307
- normalizedRef === 'current week' || normalizedRef === '这周' ||
308
- normalizedRef === '这个星期') {
309
- return {
310
- startTime: getStartOfWeekTimestamp(),
311
- endTime: getEndOfWeekTimestamp()
312
- };
313
- }
314
- if (normalizedRef === 'last week' || normalizedRef === '上周' ||
315
- normalizedRef === '上個星期' || normalizedRef === '上个星期') {
316
- const lastWeekStart = new Date(getStartOfWeekTimestamp());
317
- lastWeekStart.setDate(lastWeekStart.getDate() - 7);
318
- const lastWeekEnd = new Date(getEndOfWeekTimestamp());
319
- lastWeekEnd.setDate(lastWeekEnd.getDate() - 7);
320
- return {
321
- startTime: lastWeekStart.getTime(),
322
- endTime: lastWeekEnd.getTime()
323
- };
324
- }
325
- // This month/last month
326
- if (normalizedRef === 'this month' || normalizedRef === '本月' ||
327
- normalizedRef === 'current month' || normalizedRef === '这个月') {
328
- return {
329
- startTime: getStartOfMonthTimestamp(),
330
- endTime: getEndOfMonthTimestamp()
331
- };
332
- }
333
- if (normalizedRef === 'last month' || normalizedRef === '上月' ||
334
- normalizedRef === '上个月') {
335
- const now = new Date();
336
- const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1);
337
- // Start of last month
338
- const startOfLastMonth = new Date(lastMonth.getFullYear(), lastMonth.getMonth(), 1);
339
- startOfLastMonth.setHours(0, 0, 0, 0);
340
- // End of last month
341
- const endOfLastMonth = new Date(now.getFullYear(), now.getMonth(), 0);
342
- endOfLastMonth.setHours(23, 59, 59, 999);
343
- return {
344
- startTime: startOfLastMonth.getTime(),
345
- endTime: endOfLastMonth.getTime()
346
- };
347
- }
348
- // Default to all time
349
- return {
350
- startTime: 0,
351
- endTime: Date.now()
352
- };
353
- }
@@ -1 +0,0 @@
1
- export const VERSION = "0.1.17";