@hcmai/sdk 0.21.10 → 0.21.11
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/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -225,6 +225,8 @@ var CliError = class extends Error {
|
|
|
225
225
|
if (typeof serverCode === "string" && serverCode && serverCode !== this.code) {
|
|
226
226
|
parts.push(`[\u670D\u52A1\u7AEF\u9519\u8BEF\u7801: ${serverCode}]`);
|
|
227
227
|
}
|
|
228
|
+
const workspaceKey = this.context?.workspaceKey;
|
|
229
|
+
if (typeof workspaceKey === "string" && workspaceKey) parts.push(`[\u5DE5\u4F5C\u533A: ${workspaceKey}]`);
|
|
228
230
|
const field = this.context?.field;
|
|
229
231
|
if (typeof field === "string" && field) parts.push(`[\u5B57\u6BB5: ${field}]`);
|
|
230
232
|
const reasonCode = this.context?.reasonCode;
|
|
@@ -280,9 +282,10 @@ function fromAxiosError(err, profile) {
|
|
|
280
282
|
const respDetails = body?.details;
|
|
281
283
|
const respReason = nonBlankString(body?.reason);
|
|
282
284
|
const respNote = nonBlankString(body?.note);
|
|
283
|
-
const respNextStep = body?.next_step ?? body?.nextStep;
|
|
285
|
+
const respNextStep = nonBlankString(body?.next_step) ?? nonBlankString(body?.nextStep);
|
|
284
286
|
const respRetryable = body?.retryable;
|
|
285
|
-
const
|
|
287
|
+
const conflictDiagnosis = status === 409 ? diagnoseWorkspaceConflict(respCode) : void 0;
|
|
288
|
+
const localDiagnosis = respCode === REJECTED_BEFORE_ROUTING_CODE ? diagnoseRejectedBeforeRouting(err.config?.url, err.config?.baseURL) : conflictDiagnosis;
|
|
286
289
|
let code;
|
|
287
290
|
if (status === 401) code = "AUTH_FAILED" /* AUTH_FAILED */;
|
|
288
291
|
else if (status === 403) code = "SCOPE_FORBIDDEN" /* SCOPE_FORBIDDEN */;
|
|
@@ -304,7 +307,7 @@ function fromAxiosError(err, profile) {
|
|
|
304
307
|
...respDetails !== void 0 ? { details: respDetails } : {},
|
|
305
308
|
...respReason ? { reason: respReason } : {},
|
|
306
309
|
...respNote ? { note: respNote } : {},
|
|
307
|
-
...respNextStep ? { nextStep: respNextStep } : {},
|
|
310
|
+
...respNextStep || conflictDiagnosis ? { nextStep: respNextStep ?? conflictRecovery } : {},
|
|
308
311
|
...respRetryable !== void 0 ? { retryable: respRetryable } : {},
|
|
309
312
|
// 与后端的 nextStep 并存、不互相覆盖:一个是服务端的通用路标,一个是本地对症结论。
|
|
310
313
|
...localDiagnosis ? { localDiagnosis } : {}
|
|
@@ -314,6 +317,16 @@ function fromAxiosError(err, profile) {
|
|
|
314
317
|
cause: err
|
|
315
318
|
});
|
|
316
319
|
}
|
|
320
|
+
var conflictRecovery = "\u5148\u6838\u5BF9\u670D\u52A1\u7AEF\u8BE6\u60C5\u3002\u4EC5\u5728\u786E\u8BA4\u662F\u5176\u4ED6\u5199\u5165\u6216\u90E8\u7F72\u5360\u7528\u65F6\u7B49\u5F85\u540E\u56DE\u8BFB\u72B6\u6001\uFF1B\u5BA2\u6237\u7AEF\u5EFA\u8BAE\u95F4\u9694 30\u201360 \u79D2\uFF0C\u4E0D\u80FD\u4FDD\u8BC1\u5C4A\u65F6\u9501\u5DF2\u91CA\u653E\uFF0C\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u7684\u6301\u6709\u8005\u53CA\u5269\u4F59\u65F6\u95F4\u4E0D\u80FD\u63A8\u65AD\u3002\u771F\u5B9E\u4FEE\u8BA2\u51B2\u7A81\u6216\u6587\u4EF6\u89C4\u8303\u5316\u8981\u6C42\u5E94\u6309\u8BE6\u60C5\u5904\u7406\uFF0C\u4FDD\u7559\u672C\u5730\u6539\u52A8\u3001\u8BFB\u53D6\u6700\u65B0\u5185\u5BB9\u5E76\u6BD4\u5BF9\u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002";
|
|
321
|
+
function diagnoseWorkspaceConflict(responseCode) {
|
|
322
|
+
if (responseCode === "WORKSPACE_REVISION_CONFLICT") {
|
|
323
|
+
return "\u5DE5\u4F5C\u533A\u5199\u5165\u88AB\u62D2\u7EDD\uFF1A\u53EF\u80FD\u662F\u79DF\u6237\u5185\u5176\u4ED6\u5199\u5165\u6216\u90E8\u7F72\u6B63\u5728\u5360\u7528\uFF0C\u4E5F\u53EF\u80FD\u662F\u57FA\u7EBF\u4FEE\u8BA2\u51B2\u7A81\u6216\u6587\u4EF6\u89C4\u8303\u5316\u8981\u6C42\uFF1B\u4EC5\u51ED\u9519\u8BEF\u7801\u65E0\u6CD5\u5224\u65AD\u53EF\u5426\u91CD\u8BD5\uFF0C\u4EE5\u670D\u52A1\u7AEF\u8BE6\u60C5\u4E3A\u51C6\u3002";
|
|
324
|
+
}
|
|
325
|
+
if (responseCode === "DEPLOY_IN_PROGRESS") {
|
|
326
|
+
return "\u79DF\u6237\u6269\u5C55\u6B63\u5728\u90E8\u7F72\u6216\u5F52\u6863\uFF0C\u5F53\u524D\u64CD\u4F5C\u88AB\u5E76\u53D1\u4FDD\u62A4\u62D2\u7EDD\uFF1B\u8BF7\u5148\u786E\u8BA4\u73B0\u6709\u90E8\u7F72\u72B6\u6001\u3002";
|
|
327
|
+
}
|
|
328
|
+
return void 0;
|
|
329
|
+
}
|
|
317
330
|
var CODE_LIKE = /^(?:[A-Z][A-Z0-9_]*|[a-z][a-z0-9]*(?:_[a-z0-9]+)+)$/;
|
|
318
331
|
function isRecord(value) {
|
|
319
332
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|