@aliyun-obv/api 0.3.5 → 0.3.7
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.es.js +85 -36
- package/package.json +1 -1
package/dist/api.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import urijs from 'urijs';
|
|
2
3
|
import errorPrompt from '@alicloud/console-base-error-prompt-proxy';
|
|
3
4
|
import i18n, { getMsg } from '@aliyun-obv/i18n';
|
|
4
|
-
import urijs from 'urijs';
|
|
5
5
|
import { Dialog, Button, Message } from '@alifd/next';
|
|
6
6
|
import { slsConsoleRuntime, commonUtil, urlUtil, addStubForSearch, addRUMLog, slsConsoleUtil } from '@aliyun-obv/utils';
|
|
7
7
|
import React from 'react';
|
|
@@ -89,6 +89,10 @@ class BaseFetch {
|
|
|
89
89
|
}
|
|
90
90
|
beforeRequest(api, params, init, options) {
|
|
91
91
|
const hasBaseURL = typeof this.defaults.baseURL === "string" && this.defaults.baseURL.trim().length > 0;
|
|
92
|
+
const parseQuery = urijs(decodeURIComponent(location.search)).escapeQuerySpace(false).query(true);
|
|
93
|
+
if ((params == null ? void 0 : params.product) === "CMS" && (parseQuery == null ? void 0 : parseQuery.cmsRegion) && params.region == null) {
|
|
94
|
+
params.region = parseQuery.cmsRegion;
|
|
95
|
+
}
|
|
92
96
|
let url = api;
|
|
93
97
|
let newInit = init;
|
|
94
98
|
if (hasBaseURL && !(url.startsWith("http:") || url.startsWith("https:"))) {
|
|
@@ -203,34 +207,97 @@ class BaseFetch {
|
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
209
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
var _a$1, _b, _c;
|
|
211
|
+
const isLocal = (_a$1 = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _a$1.LOCAL;
|
|
212
|
+
const isPre = ((_b = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b.fEnv) === "pre" || ((_c = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _c.ENV) === "pre";
|
|
213
|
+
function is4Service(location2) {
|
|
214
|
+
return location2.hostname.match(
|
|
215
|
+
/(4service|4bjzwy|4finance)(\.console)?(\.aliyun|\.alibabacloud)\.com$/
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
function getSLSdomain() {
|
|
219
|
+
var _a2, _b2;
|
|
220
|
+
if ((_a2 = window == null ? void 0 : window.__CONSOLE_OBVIZ_DOMAIN__) == null ? void 0 : _a2.getSlsDomain) {
|
|
221
|
+
return window.__CONSOLE_OBVIZ_DOMAIN__.getSlsDomain();
|
|
222
|
+
}
|
|
223
|
+
if (isLocal) {
|
|
224
|
+
if (window.location.hostname.includes("stg")) {
|
|
225
|
+
return `http://sls-stg:${window.location.port}`;
|
|
212
226
|
}
|
|
213
|
-
|
|
227
|
+
if (location.hostname.includes("observability")) {
|
|
228
|
+
return `http://pre-sls:${window.location.port}`;
|
|
229
|
+
}
|
|
230
|
+
return window.location.origin;
|
|
214
231
|
}
|
|
215
232
|
const host = window.location.host;
|
|
216
|
-
if (((
|
|
233
|
+
if (((_b2 = window == null ? void 0 : window.ALIYUN_SLS_CONSOLE_CONFIG) == null ? void 0 : _b2.isSlsConsole) || host.includes("sls") && host.includes("console.aliyun.com")) {
|
|
217
234
|
return void 0;
|
|
218
235
|
}
|
|
219
|
-
if (
|
|
236
|
+
if (isPre) {
|
|
237
|
+
if (is4Service(window.location)) {
|
|
238
|
+
return `https://pre-sls4service.console.aliyun.com`;
|
|
239
|
+
}
|
|
240
|
+
if (window.location.hostname.includes("stg")) {
|
|
241
|
+
return `https://sls-stg.console.aliyun.com`;
|
|
242
|
+
}
|
|
243
|
+
return "https://pre-sls.console.aliyun.com";
|
|
244
|
+
}
|
|
245
|
+
if (is4Service(window.location)) {
|
|
246
|
+
return `https://sls4service.console.aliyun.com`;
|
|
247
|
+
}
|
|
248
|
+
return "https://sls.console.aliyun.com";
|
|
249
|
+
}
|
|
250
|
+
function getObvDomain() {
|
|
251
|
+
var _a2, _b2;
|
|
252
|
+
if ((_a2 = window == null ? void 0 : window.__CONSOLE_OBVIZ_DOMAIN__) == null ? void 0 : _a2.getObvDomain) {
|
|
253
|
+
return window.__CONSOLE_OBVIZ_DOMAIN__.getObvDomain();
|
|
254
|
+
}
|
|
255
|
+
const { slsHost } = urijs(window.location.search).escapeQuerySpace(false).query(true);
|
|
256
|
+
if ((_b2 = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b2.LOCAL) {
|
|
220
257
|
if (slsHost != null && slsHost != "") {
|
|
221
258
|
return slsHost;
|
|
222
259
|
}
|
|
223
|
-
|
|
260
|
+
if (location.hostname === "localhost") {
|
|
261
|
+
return `http://pre-observability:${window.location.port}`;
|
|
262
|
+
}
|
|
263
|
+
if (location.hostname.includes("observability")) {
|
|
264
|
+
return `http://${location.hostname}:${window.location.port}`;
|
|
265
|
+
}
|
|
266
|
+
if (window.location.hostname.includes("stg")) {
|
|
267
|
+
return `http://pre-stg-observability:${window.location.port}`;
|
|
268
|
+
}
|
|
269
|
+
return `http://pre-observability:${window.location.port}`;
|
|
224
270
|
}
|
|
225
|
-
|
|
271
|
+
if (isPre) {
|
|
272
|
+
if (slsHost != null && slsHost != "") {
|
|
273
|
+
return slsHost;
|
|
274
|
+
}
|
|
275
|
+
if (is4Service(window.location)) {
|
|
276
|
+
return `https://pre-observability4service.console.aliyun.com`;
|
|
277
|
+
}
|
|
278
|
+
if (location.hostname.includes("observability")) {
|
|
279
|
+
return location.origin;
|
|
280
|
+
}
|
|
281
|
+
if (window.location.hostname.includes("stg")) {
|
|
282
|
+
return `https://pre-stg-observability.console.aliyun.com`;
|
|
283
|
+
}
|
|
284
|
+
return `https://pre-observability.console.aliyun.com`;
|
|
285
|
+
}
|
|
286
|
+
if (is4Service(window.location)) {
|
|
287
|
+
return `https://observability4service.console.aliyun.com`;
|
|
288
|
+
}
|
|
289
|
+
if (location.hostname.includes("observability")) {
|
|
290
|
+
return location.origin;
|
|
291
|
+
}
|
|
292
|
+
return `https://observability.console.aliyun.com`;
|
|
226
293
|
}
|
|
227
294
|
function getConfig(key) {
|
|
228
295
|
window.ALIYUN_SLS_CONSOLE_CONFIG = window.ALIYUN_SLS_CONSOLE_CONFIG || {};
|
|
229
296
|
return window.ALIYUN_SLS_CONSOLE_CONFIG[key] !== void 0 ? window.ALIYUN_SLS_CONSOLE_CONFIG[key] : "";
|
|
230
297
|
}
|
|
231
298
|
function extraActionAndResource(message) {
|
|
232
|
-
var
|
|
233
|
-
const arr = (
|
|
299
|
+
var _a2;
|
|
300
|
+
const arr = (_a2 = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a2 : [];
|
|
234
301
|
if (arr.length === 3) {
|
|
235
302
|
return {
|
|
236
303
|
action: arr[1],
|
|
@@ -280,11 +347,6 @@ function getOauthCallbackUrl(url = window.location.href) {
|
|
|
280
347
|
function createNoPermissionContent() {
|
|
281
348
|
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "sls-custom-container" }, /* @__PURE__ */ React.createElement("div", { className: "sls-custom-title" }, i18n.UNAUTHORIZEDOPERMSG)));
|
|
282
349
|
}
|
|
283
|
-
function is4Service(location) {
|
|
284
|
-
return location.hostname.match(
|
|
285
|
-
/(4service|4bjzwy|4finance)(\.console)?(\.aliyun|\.alibabacloud)\.com$/
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
350
|
|
|
289
351
|
var __defProp$3 = Object.defineProperty;
|
|
290
352
|
var __defProps$3 = Object.defineProperties;
|
|
@@ -401,7 +463,7 @@ function showCSRFDialog(config) {
|
|
|
401
463
|
type: "primary",
|
|
402
464
|
onClick: () => {
|
|
403
465
|
var _a;
|
|
404
|
-
commonEasyFetch.get(`${(_a =
|
|
466
|
+
commonEasyFetch.get(`${(_a = getSLSdomain()) != null ? _a : ""}/console/ajax/getSecToken.json`).then((res) => {
|
|
405
467
|
if ((res == null ? void 0 : res.code) === "200") {
|
|
406
468
|
window.ALIYUN_SLS_CONSOLE_CONFIG.SEC_TOKEN = res.data;
|
|
407
469
|
dialog.hide();
|
|
@@ -477,7 +539,7 @@ function showNeedLoginDialog(config) {
|
|
|
477
539
|
spm_btn_type: "getSecToken",
|
|
478
540
|
spm_loginUrl: loginUrl
|
|
479
541
|
});
|
|
480
|
-
commonEasyFetch.get(`${(_a =
|
|
542
|
+
commonEasyFetch.get(`${(_a = getSLSdomain()) != null ? _a : ""}/console/ajax/getSecToken.json`).then((res) => {
|
|
481
543
|
if (res && res.code === "200") {
|
|
482
544
|
window.ALIYUN_SLS_CONSOLE_CONFIG.SEC_TOKEN = res.data;
|
|
483
545
|
dialog.hide();
|
|
@@ -762,7 +824,7 @@ var __async$6 = (__this, __arguments, generator) => {
|
|
|
762
824
|
const slsEasyFetch = new BaseFetch(finalFetch);
|
|
763
825
|
slsEasyFetch.defaults.postDefaultInit.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
764
826
|
slsEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
|
|
765
|
-
slsEasyFetch.defaults.baseURL =
|
|
827
|
+
slsEasyFetch.defaults.baseURL = getSLSdomain();
|
|
766
828
|
slsEasyFetch.defaults.errorHandler = errorHandler;
|
|
767
829
|
slsEasyFetch.defaults.beforeRequest = (url, params, init, options) => __async$6(void 0, null, function* () {
|
|
768
830
|
var _a;
|
|
@@ -823,23 +885,10 @@ slsEasyFetch.defaults.afterResponse = (r, options) => __async$6(void 0, null, fu
|
|
|
823
885
|
return composedData;
|
|
824
886
|
});
|
|
825
887
|
|
|
826
|
-
function getBaseUrl() {
|
|
827
|
-
var _a, _b, _c;
|
|
828
|
-
if ((_a = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _a.LOCAL) {
|
|
829
|
-
return `http://pre-observability:${window.location.port}`;
|
|
830
|
-
}
|
|
831
|
-
if (((_b = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b.ENV) === "pre" || ((_c = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _c.fEnv) === "pre") {
|
|
832
|
-
return `https://pre-observability.console.aliyun.com`;
|
|
833
|
-
}
|
|
834
|
-
if (is4Service(window.location)) {
|
|
835
|
-
return `https://observability4service.console.aliyun.com`;
|
|
836
|
-
}
|
|
837
|
-
return `https://observability.console.aliyun.com`;
|
|
838
|
-
}
|
|
839
888
|
const obsEasyFetch = new BaseFetch(finalFetch);
|
|
840
889
|
obsEasyFetch.defaults.postDefaultInit.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
841
890
|
obsEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
|
|
842
|
-
obsEasyFetch.defaults.baseURL =
|
|
891
|
+
obsEasyFetch.defaults.baseURL = getObvDomain();
|
|
843
892
|
obsEasyFetch.defaults.errorHandler = errorHandler;
|
|
844
893
|
obsEasyFetch.defaults.beforeRequest = slsEasyFetch.defaults.beforeRequest;
|
|
845
894
|
obsEasyFetch.defaults.afterResponse = slsEasyFetch.defaults.afterResponse;
|
package/package.json
CHANGED