@aliyun-obv/api 4.7.2 → 4.7.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.
- package/dist/api.d.ts +31 -1
- package/dist/api.es.js +87 -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
|
@@ -96,6 +96,16 @@ class BaseFetch {
|
|
|
96
96
|
params.region = re[1];
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
if (params.region == null) {
|
|
100
|
+
try {
|
|
101
|
+
const url2 = new URL(window.location.href);
|
|
102
|
+
const defaultRegion = url2.searchParams.get("__default_region__");
|
|
103
|
+
if (defaultRegion) {
|
|
104
|
+
params.region = defaultRegion;
|
|
105
|
+
}
|
|
106
|
+
} catch (_e) {
|
|
107
|
+
}
|
|
108
|
+
}
|
|
99
109
|
let url = api;
|
|
100
110
|
let newInit = init;
|
|
101
111
|
if (hasBaseURL && !(url.startsWith("http:") || url.startsWith("https:"))) {
|
|
@@ -340,7 +350,7 @@ function getConfig(key) {
|
|
|
340
350
|
window.ALIYUN_SLS_CONSOLE_CONFIG = window.ALIYUN_SLS_CONSOLE_CONFIG || {};
|
|
341
351
|
return window.ALIYUN_SLS_CONSOLE_CONFIG[key] !== void 0 ? window.ALIYUN_SLS_CONSOLE_CONFIG[key] : "";
|
|
342
352
|
}
|
|
343
|
-
function extraActionAndResource(message) {
|
|
353
|
+
function extraActionAndResource$1(message) {
|
|
344
354
|
var _a;
|
|
345
355
|
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
346
356
|
if (arr.length === 3) {
|
|
@@ -355,7 +365,7 @@ function extraActionAndResource(message) {
|
|
|
355
365
|
};
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
|
-
function convertErrorDetaisAuth(o) {
|
|
368
|
+
function convertErrorDetaisAuth$1(o) {
|
|
359
369
|
if (!o) {
|
|
360
370
|
return;
|
|
361
371
|
}
|
|
@@ -503,7 +513,7 @@ var __spreadValues$4 = (a, b) => {
|
|
|
503
513
|
return a;
|
|
504
514
|
};
|
|
505
515
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
506
|
-
const ERROR_TITLE = i18n.ERROR;
|
|
516
|
+
const ERROR_TITLE$1 = i18n.ERROR;
|
|
507
517
|
i18n.OK;
|
|
508
518
|
let isGlobalAlertShow = false;
|
|
509
519
|
function showConsoleBaseAlertDialog(response, config = {}, request, extra = {}) {
|
|
@@ -512,7 +522,7 @@ function showConsoleBaseAlertDialog(response, config = {}, request, extra = {})
|
|
|
512
522
|
return false;
|
|
513
523
|
}
|
|
514
524
|
const errorConfig = {
|
|
515
|
-
title: ERROR_TITLE,
|
|
525
|
+
title: ERROR_TITLE$1,
|
|
516
526
|
// 错误
|
|
517
527
|
message: response.message,
|
|
518
528
|
code: response.code,
|
|
@@ -525,12 +535,12 @@ function showConsoleBaseAlertDialog(response, config = {}, request, extra = {})
|
|
|
525
535
|
const responseCode = (_a = response.code) == null ? void 0 : _a.toLowerCase();
|
|
526
536
|
if (responseCode === "unauthorized" || responseCode === "nopermission") {
|
|
527
537
|
if ((_b = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _b.accessDeniedDetail) {
|
|
528
|
-
const detailsAuth = convertErrorDetaisAuth(response.rawResponseError.accessDeniedDetail);
|
|
538
|
+
const detailsAuth = convertErrorDetaisAuth$1(response.rawResponseError.accessDeniedDetail);
|
|
529
539
|
errorConfig.detailsAuth = detailsAuth;
|
|
530
540
|
errorConfig.code = ((_c = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _c.errorCode) || "Unauthorized";
|
|
531
541
|
errorPrompt(errorConfig);
|
|
532
542
|
} else {
|
|
533
|
-
const { action, resource } = extraActionAndResource(response.message);
|
|
543
|
+
const { action, resource } = extraActionAndResource$1(response.message);
|
|
534
544
|
if (errorConfig.details) {
|
|
535
545
|
errorConfig.details.ACTION = action;
|
|
536
546
|
errorConfig.details.RESOURCE = resource;
|
|
@@ -640,7 +650,7 @@ function showAlertDialog(response, config = {}, request, extra = {}) {
|
|
|
640
650
|
return true;
|
|
641
651
|
}
|
|
642
652
|
const _params = {
|
|
643
|
-
title: ERROR_TITLE,
|
|
653
|
+
title: ERROR_TITLE$1,
|
|
644
654
|
message: /* @__PURE__ */ React.createElement("div", null, config.content ? config.content : "")
|
|
645
655
|
};
|
|
646
656
|
showConsoleBaseAlertDialog(response, _params, request, extra);
|
|
@@ -1121,6 +1131,75 @@ const sseClient = (api, params, options) => {
|
|
|
1121
1131
|
return new SSEClient(api, params, __spreadProps$1(__spreadValues$1({}, options), { headers }));
|
|
1122
1132
|
};
|
|
1123
1133
|
|
|
1134
|
+
const ERROR_TITLE = i18n.ERROR;
|
|
1135
|
+
function extraActionAndResource(message) {
|
|
1136
|
+
var _a;
|
|
1137
|
+
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
1138
|
+
if (arr.length === 3) {
|
|
1139
|
+
return {
|
|
1140
|
+
action: arr[1],
|
|
1141
|
+
resource: arr[2]
|
|
1142
|
+
};
|
|
1143
|
+
} else {
|
|
1144
|
+
return {
|
|
1145
|
+
action: "",
|
|
1146
|
+
resource: ""
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function convertErrorDetaisAuth(o) {
|
|
1151
|
+
if (!o) {
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
return {
|
|
1155
|
+
type: o.NoPermissionType,
|
|
1156
|
+
action: o.AuthAction,
|
|
1157
|
+
resource: o.AuthResource,
|
|
1158
|
+
userType: o.AuthPrincipalType,
|
|
1159
|
+
userName: o.AuthPrincipalDisplayName,
|
|
1160
|
+
userId: o.AuthPrincipalOwnerId,
|
|
1161
|
+
policyType: o.PolicyType,
|
|
1162
|
+
diagnosisInfo: o.EncodedDiagnosticMessage
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
function extractErrorInfo(response) {
|
|
1166
|
+
var _a, _b, _c, _d;
|
|
1167
|
+
if (response == null || (response == null ? void 0 : response.code) === "200") {
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
if (response.code === "ConsoleNeedLogin") {
|
|
1171
|
+
return {
|
|
1172
|
+
title: getMsg("lb.login_time_out_title"),
|
|
1173
|
+
message: getMsg("lb.login_time_out_content"),
|
|
1174
|
+
code: response.code || "",
|
|
1175
|
+
requestId: response.requestId || "",
|
|
1176
|
+
needLogin: true
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
const errorInfo = {
|
|
1180
|
+
title: ERROR_TITLE,
|
|
1181
|
+
message: response.message || "",
|
|
1182
|
+
code: response.code || "",
|
|
1183
|
+
requestId: response.requestId || ""
|
|
1184
|
+
};
|
|
1185
|
+
const responseCode = (_a = response.code) == null ? void 0 : _a.toLowerCase();
|
|
1186
|
+
if (responseCode === "unauthorized" || responseCode === "nopermission") {
|
|
1187
|
+
if ((_b = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _b.accessDeniedDetail) {
|
|
1188
|
+
const detailsAuth = convertErrorDetaisAuth(response.rawResponseError.accessDeniedDetail);
|
|
1189
|
+
errorInfo.detailsAuth = detailsAuth;
|
|
1190
|
+
errorInfo.code = ((_c = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _c.errorCode) || "Unauthorized";
|
|
1191
|
+
} else {
|
|
1192
|
+
const { action, resource } = extraActionAndResource(response.message || "");
|
|
1193
|
+
errorInfo.details = {
|
|
1194
|
+
ACTION: action,
|
|
1195
|
+
RESOURCE: resource
|
|
1196
|
+
};
|
|
1197
|
+
errorInfo.code = ((_d = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _d.errorCode) || "Unauthorized";
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
return errorInfo;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1124
1203
|
var __defProp = Object.defineProperty;
|
|
1125
1204
|
var __defProps = Object.defineProperties;
|
|
1126
1205
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -1685,4 +1764,4 @@ var dashbordService;
|
|
|
1685
1764
|
dashbordService2.updateDashboard = updateDashboard;
|
|
1686
1765
|
})(dashbordService || (dashbordService = {}));
|
|
1687
1766
|
|
|
1688
|
-
export { commonEasyFetch, dashbordService, diamondService, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
|
1767
|
+
export { commonEasyFetch, dashbordService, diamondService, extractErrorInfo, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
package/package.json
CHANGED