@aliyun-obv/api 4.7.1 → 4.7.3
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/api.d.ts +31 -1
- package/dist/api.es.js +77 -8
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -122,6 +122,36 @@ declare const sseClient: (api: string, params: Record<string, any>, options: Iss
|
|
|
122
122
|
declare function showAlertDialog(response: any, config?: ShowConfig, request?: any, extra?: any): boolean;
|
|
123
123
|
declare function showAlertDialogWhenNeedLogin(response: any, config?: {}): void;
|
|
124
124
|
|
|
125
|
+
interface IErrorDetailsAuth {
|
|
126
|
+
type?: string;
|
|
127
|
+
action?: string;
|
|
128
|
+
resource?: string;
|
|
129
|
+
userType?: string;
|
|
130
|
+
userName?: string;
|
|
131
|
+
userId?: string;
|
|
132
|
+
policyType?: string;
|
|
133
|
+
diagnosisInfo?: string;
|
|
134
|
+
}
|
|
135
|
+
interface IErrorInfo {
|
|
136
|
+
title: string;
|
|
137
|
+
message: string;
|
|
138
|
+
code: string;
|
|
139
|
+
requestId: string;
|
|
140
|
+
detailsAuth?: IErrorDetailsAuth;
|
|
141
|
+
details?: {
|
|
142
|
+
ACTION?: string;
|
|
143
|
+
RESOURCE?: string;
|
|
144
|
+
};
|
|
145
|
+
/** 是否需要登录 */
|
|
146
|
+
needLogin?: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 从 response 中提取错误信息,参考 showConsoleBaseAlertDialog 和 showNeedLoginDialog 的实现逻辑
|
|
150
|
+
* @param response easyFetch 返回体
|
|
151
|
+
* @returns 包含 title, message, code, requestId 等的错误信息对象,如果 response 为空或 code 为 200 则返回 null
|
|
152
|
+
*/
|
|
153
|
+
declare function extractErrorInfo(response: any): IErrorInfo | null;
|
|
154
|
+
|
|
125
155
|
declare namespace metaService {
|
|
126
156
|
export interface GetMetaRecordParameters {
|
|
127
157
|
name: string;
|
|
@@ -354,4 +384,4 @@ declare namespace dashbordService {
|
|
|
354
384
|
|
|
355
385
|
declare function getConsoleDomain(isObv?: boolean): any;
|
|
356
386
|
|
|
357
|
-
export { IResponseData, commonEasyFetch, dashbordService, diamondService, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
|
387
|
+
export { IResponseData, commonEasyFetch, dashbordService, diamondService, extractErrorInfo, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
package/dist/api.es.js
CHANGED
|
@@ -340,7 +340,7 @@ function getConfig(key) {
|
|
|
340
340
|
window.ALIYUN_SLS_CONSOLE_CONFIG = window.ALIYUN_SLS_CONSOLE_CONFIG || {};
|
|
341
341
|
return window.ALIYUN_SLS_CONSOLE_CONFIG[key] !== void 0 ? window.ALIYUN_SLS_CONSOLE_CONFIG[key] : "";
|
|
342
342
|
}
|
|
343
|
-
function extraActionAndResource(message) {
|
|
343
|
+
function extraActionAndResource$1(message) {
|
|
344
344
|
var _a;
|
|
345
345
|
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
346
346
|
if (arr.length === 3) {
|
|
@@ -355,7 +355,7 @@ function extraActionAndResource(message) {
|
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
function convertErrorDetaisAuth(o) {
|
|
358
|
+
function convertErrorDetaisAuth$1(o) {
|
|
359
359
|
if (!o) {
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
@@ -503,7 +503,7 @@ var __spreadValues$4 = (a, b) => {
|
|
|
503
503
|
return a;
|
|
504
504
|
};
|
|
505
505
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
506
|
-
const ERROR_TITLE = i18n.ERROR;
|
|
506
|
+
const ERROR_TITLE$1 = i18n.ERROR;
|
|
507
507
|
i18n.OK;
|
|
508
508
|
let isGlobalAlertShow = false;
|
|
509
509
|
function showConsoleBaseAlertDialog(response, config = {}, request, extra = {}) {
|
|
@@ -512,7 +512,7 @@ function showConsoleBaseAlertDialog(response, config = {}, request, extra = {})
|
|
|
512
512
|
return false;
|
|
513
513
|
}
|
|
514
514
|
const errorConfig = {
|
|
515
|
-
title: ERROR_TITLE,
|
|
515
|
+
title: ERROR_TITLE$1,
|
|
516
516
|
// 错误
|
|
517
517
|
message: response.message,
|
|
518
518
|
code: response.code,
|
|
@@ -525,12 +525,12 @@ function showConsoleBaseAlertDialog(response, config = {}, request, extra = {})
|
|
|
525
525
|
const responseCode = (_a = response.code) == null ? void 0 : _a.toLowerCase();
|
|
526
526
|
if (responseCode === "unauthorized" || responseCode === "nopermission") {
|
|
527
527
|
if ((_b = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _b.accessDeniedDetail) {
|
|
528
|
-
const detailsAuth = convertErrorDetaisAuth(response.rawResponseError.accessDeniedDetail);
|
|
528
|
+
const detailsAuth = convertErrorDetaisAuth$1(response.rawResponseError.accessDeniedDetail);
|
|
529
529
|
errorConfig.detailsAuth = detailsAuth;
|
|
530
530
|
errorConfig.code = ((_c = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _c.errorCode) || "Unauthorized";
|
|
531
531
|
errorPrompt(errorConfig);
|
|
532
532
|
} else {
|
|
533
|
-
const { action, resource } = extraActionAndResource(response.message);
|
|
533
|
+
const { action, resource } = extraActionAndResource$1(response.message);
|
|
534
534
|
if (errorConfig.details) {
|
|
535
535
|
errorConfig.details.ACTION = action;
|
|
536
536
|
errorConfig.details.RESOURCE = resource;
|
|
@@ -640,7 +640,7 @@ function showAlertDialog(response, config = {}, request, extra = {}) {
|
|
|
640
640
|
return true;
|
|
641
641
|
}
|
|
642
642
|
const _params = {
|
|
643
|
-
title: ERROR_TITLE,
|
|
643
|
+
title: ERROR_TITLE$1,
|
|
644
644
|
message: /* @__PURE__ */ React.createElement("div", null, config.content ? config.content : "")
|
|
645
645
|
};
|
|
646
646
|
showConsoleBaseAlertDialog(response, _params, request, extra);
|
|
@@ -1121,6 +1121,75 @@ const sseClient = (api, params, options) => {
|
|
|
1121
1121
|
return new SSEClient(api, params, __spreadProps$1(__spreadValues$1({}, options), { headers }));
|
|
1122
1122
|
};
|
|
1123
1123
|
|
|
1124
|
+
const ERROR_TITLE = i18n.ERROR;
|
|
1125
|
+
function extraActionAndResource(message) {
|
|
1126
|
+
var _a;
|
|
1127
|
+
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
1128
|
+
if (arr.length === 3) {
|
|
1129
|
+
return {
|
|
1130
|
+
action: arr[1],
|
|
1131
|
+
resource: arr[2]
|
|
1132
|
+
};
|
|
1133
|
+
} else {
|
|
1134
|
+
return {
|
|
1135
|
+
action: "",
|
|
1136
|
+
resource: ""
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
function convertErrorDetaisAuth(o) {
|
|
1141
|
+
if (!o) {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
return {
|
|
1145
|
+
type: o.NoPermissionType,
|
|
1146
|
+
action: o.AuthAction,
|
|
1147
|
+
resource: o.AuthResource,
|
|
1148
|
+
userType: o.AuthPrincipalType,
|
|
1149
|
+
userName: o.AuthPrincipalDisplayName,
|
|
1150
|
+
userId: o.AuthPrincipalOwnerId,
|
|
1151
|
+
policyType: o.PolicyType,
|
|
1152
|
+
diagnosisInfo: o.EncodedDiagnosticMessage
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
function extractErrorInfo(response) {
|
|
1156
|
+
var _a, _b, _c, _d;
|
|
1157
|
+
if (response == null || (response == null ? void 0 : response.code) === "200") {
|
|
1158
|
+
return null;
|
|
1159
|
+
}
|
|
1160
|
+
if (response.code === "ConsoleNeedLogin") {
|
|
1161
|
+
return {
|
|
1162
|
+
title: getMsg("lb.login_time_out_title"),
|
|
1163
|
+
message: getMsg("lb.login_time_out_content"),
|
|
1164
|
+
code: response.code || "",
|
|
1165
|
+
requestId: response.requestId || "",
|
|
1166
|
+
needLogin: true
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
const errorInfo = {
|
|
1170
|
+
title: ERROR_TITLE,
|
|
1171
|
+
message: response.message || "",
|
|
1172
|
+
code: response.code || "",
|
|
1173
|
+
requestId: response.requestId || ""
|
|
1174
|
+
};
|
|
1175
|
+
const responseCode = (_a = response.code) == null ? void 0 : _a.toLowerCase();
|
|
1176
|
+
if (responseCode === "unauthorized" || responseCode === "nopermission") {
|
|
1177
|
+
if ((_b = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _b.accessDeniedDetail) {
|
|
1178
|
+
const detailsAuth = convertErrorDetaisAuth(response.rawResponseError.accessDeniedDetail);
|
|
1179
|
+
errorInfo.detailsAuth = detailsAuth;
|
|
1180
|
+
errorInfo.code = ((_c = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _c.errorCode) || "Unauthorized";
|
|
1181
|
+
} else {
|
|
1182
|
+
const { action, resource } = extraActionAndResource(response.message || "");
|
|
1183
|
+
errorInfo.details = {
|
|
1184
|
+
ACTION: action,
|
|
1185
|
+
RESOURCE: resource
|
|
1186
|
+
};
|
|
1187
|
+
errorInfo.code = ((_d = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _d.errorCode) || "Unauthorized";
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
return errorInfo;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1124
1193
|
var __defProp = Object.defineProperty;
|
|
1125
1194
|
var __defProps = Object.defineProperties;
|
|
1126
1195
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -1685,4 +1754,4 @@ var dashbordService;
|
|
|
1685
1754
|
dashbordService2.updateDashboard = updateDashboard;
|
|
1686
1755
|
})(dashbordService || (dashbordService = {}));
|
|
1687
1756
|
|
|
1688
|
-
export { commonEasyFetch, dashbordService, diamondService, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
|
1757
|
+
export { commonEasyFetch, dashbordService, diamondService, extractErrorInfo, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
package/package.json
CHANGED