@aliyun-obv/api 0.3.56 → 0.4.0-beta.1
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 +3 -1
- package/dist/api.es.js +84 -63
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -351,4 +351,6 @@ declare namespace dashbordService {
|
|
|
351
351
|
}): Promise<IResponseData>;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
|
|
354
|
+
declare function getConsoleDomain(isObv?: boolean): any;
|
|
355
|
+
|
|
356
|
+
export { IResponseData, commonEasyFetch, dashbordService, diamondService, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
package/dist/api.es.js
CHANGED
|
@@ -3,7 +3,6 @@ import errorPrompt from '@alicloud/console-base-error-prompt-proxy';
|
|
|
3
3
|
import i18n, { getMsg } from '@aliyun-obv/i18n';
|
|
4
4
|
import urijs from 'urijs';
|
|
5
5
|
import { Dialog, Button, Message } from '@alifd/next';
|
|
6
|
-
import { slsConsoleRuntime } from '@aliyun-obv/utils';
|
|
7
6
|
import React from 'react';
|
|
8
7
|
import merge from 'lodash/merge';
|
|
9
8
|
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
@@ -211,9 +210,18 @@ class BaseFetch {
|
|
|
211
210
|
}
|
|
212
211
|
}
|
|
213
212
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
function isLocal() {
|
|
214
|
+
var _a;
|
|
215
|
+
return (_a = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _a.LOCAL;
|
|
216
|
+
}
|
|
217
|
+
function isPre() {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
return ((_a = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _a.fEnv) === "pre" || ((_b = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b.ENV) === "pre";
|
|
220
|
+
}
|
|
221
|
+
function getLinks(key) {
|
|
222
|
+
var _a, _b;
|
|
223
|
+
return ((_a = window == null ? void 0 : window.ALIYUN_SLS_CONSOLE_LINKS) == null ? void 0 : _a[key]) || ((_b = window == null ? void 0 : window.ALIYUN_OBSERVABILITY_CONSOLE_LINKS) == null ? void 0 : _b[key]) || key;
|
|
224
|
+
}
|
|
217
225
|
function is4Service(location2) {
|
|
218
226
|
return location2.hostname.match(
|
|
219
227
|
/(4service|4bjzwy|4finance)(\.console)?(\.aliyun|\.alibabacloud)\.com$/
|
|
@@ -222,13 +230,20 @@ function is4Service(location2) {
|
|
|
222
230
|
function is4Finance(location2) {
|
|
223
231
|
return location2.hostname.match(/(4finance)(\.console)?(\.aliyun|\.alibabacloud)\.com$/);
|
|
224
232
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
233
|
+
const { slsHost } = urijs(window.location.search).escapeQuerySpace(false).query(true);
|
|
234
|
+
function getLocalDomain(isObv) {
|
|
235
|
+
if (isObv) {
|
|
236
|
+
if (location.hostname === "localhost") {
|
|
237
|
+
return `http://pre-cmsnext:${window.location.port}`;
|
|
238
|
+
}
|
|
239
|
+
if (location.hostname.includes("cmsnext")) {
|
|
240
|
+
return `http://${location.hostname}:${window.location.port}`;
|
|
241
|
+
}
|
|
242
|
+
if (window.location.hostname.includes("stg")) {
|
|
243
|
+
return `http://pre-stg-cmsnext:${window.location.port}`;
|
|
244
|
+
}
|
|
245
|
+
return `http://pre-cmsnext:${window.location.port}`;
|
|
246
|
+
} else {
|
|
232
247
|
if (slsHost != null && slsHost != "") {
|
|
233
248
|
return slsHost;
|
|
234
249
|
}
|
|
@@ -240,77 +255,83 @@ function getSLSdomain() {
|
|
|
240
255
|
}
|
|
241
256
|
return window.location.origin;
|
|
242
257
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
258
|
+
}
|
|
259
|
+
function getPreConfig(isObv, suffix) {
|
|
260
|
+
if (isObv) {
|
|
261
|
+
if (is4Service(window.location)) {
|
|
262
|
+
return `https://pre-cmsnext4service.${suffix}`;
|
|
263
|
+
}
|
|
264
|
+
if (window.location.hostname.includes("stg")) {
|
|
265
|
+
return `https://pre-stg-cmsnext.${suffix}`;
|
|
266
|
+
}
|
|
267
|
+
return `https://pre-cmsnext.${suffix}`;
|
|
268
|
+
} else {
|
|
248
269
|
if (slsHost != null && slsHost != "") {
|
|
249
270
|
return slsHost;
|
|
250
271
|
}
|
|
251
272
|
if (is4Service(window.location)) {
|
|
252
|
-
return `https://pre-sls4service
|
|
273
|
+
return `https://pre-sls4service.${suffix}`;
|
|
253
274
|
}
|
|
254
275
|
if (window.location.hostname.includes("stg")) {
|
|
255
|
-
return `https://sls-stg
|
|
276
|
+
return `https://sls-stg.${suffix}`;
|
|
256
277
|
}
|
|
257
|
-
return
|
|
258
|
-
}
|
|
259
|
-
if (is4Finance(window.location)) {
|
|
260
|
-
return `https://log4finance.console.aliyun.com`;
|
|
278
|
+
return `https://pre-sls.${suffix}`;
|
|
261
279
|
}
|
|
262
|
-
if (is4Service(window.location)) {
|
|
263
|
-
return `https://sls4service.console.aliyun.com`;
|
|
264
|
-
}
|
|
265
|
-
return "https://sls.console.aliyun.com";
|
|
266
280
|
}
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
if ((_b2 = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b2.LOCAL) {
|
|
273
|
-
if (location.hostname === "localhost") {
|
|
274
|
-
return `http://pre-cmsnext:${window.location.port}`;
|
|
275
|
-
}
|
|
276
|
-
if (location.hostname.includes("observability") || location.hostname.includes("cmsnext")) {
|
|
277
|
-
return `http://${location.hostname}:${window.location.port}`;
|
|
281
|
+
function getProdConfig(isObv, suffix) {
|
|
282
|
+
if (isObv) {
|
|
283
|
+
if (is4Finance(window.location)) {
|
|
284
|
+
return `https://log4finance.${suffix}`;
|
|
278
285
|
}
|
|
279
|
-
if (window.location.hostname.includes("stg")) {
|
|
280
|
-
return `http://pre-stg-cmsnext:${window.location.port}`;
|
|
281
|
-
}
|
|
282
|
-
return `http://pre-cmsnext:${window.location.port}`;
|
|
283
|
-
}
|
|
284
|
-
if (isPre) {
|
|
285
286
|
if (is4Service(window.location)) {
|
|
286
|
-
return `https://
|
|
287
|
+
return `https://sls4service.${suffix}`;
|
|
287
288
|
}
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
return `https://sls.${suffix}`;
|
|
290
|
+
} else {
|
|
291
|
+
if (is4Finance(window.location)) {
|
|
292
|
+
return `https://cmsnext.${suffix}`;
|
|
290
293
|
}
|
|
291
|
-
if (window.location
|
|
292
|
-
return `https://
|
|
294
|
+
if (is4Service(window.location)) {
|
|
295
|
+
return `https://cmsnext4service.${suffix}`;
|
|
293
296
|
}
|
|
294
|
-
return `https://
|
|
297
|
+
return `https://cmsnext.${suffix}`;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function getConsoleDomain(isObv = true) {
|
|
301
|
+
var _a, _b, _c, _d, _e, _f;
|
|
302
|
+
if ((_a = window == null ? void 0 : window.__CONSOLE_OBVIZ_DOMAIN__) == null ? void 0 : _a.getConsoleDomain) {
|
|
303
|
+
return window.__CONSOLE_OBVIZ_DOMAIN__.getConsoleDomain();
|
|
295
304
|
}
|
|
296
|
-
if (
|
|
297
|
-
return
|
|
305
|
+
if (isLocal()) {
|
|
306
|
+
return getLocalDomain(isObv);
|
|
307
|
+
}
|
|
308
|
+
const host = window.location.host;
|
|
309
|
+
if (((_b = window == null ? void 0 : window.ALIYUN_SLS_CONSOLE_CONFIG) == null ? void 0 : _b.isSlsConsole) || ((_c = window == null ? void 0 : window.ALIYUN_OBSERVABILITY_CONSOLE_CONFIG) == null ? void 0 : _c.isCmsConsole) || host.includes("sls") && host.includes("console.aliyun.com")) {
|
|
310
|
+
return void 0;
|
|
298
311
|
}
|
|
299
|
-
|
|
300
|
-
|
|
312
|
+
const windowDomain = (_f = (_d = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _d.SLS_CONSOLE_DOMAIN) != null ? _f : (_e = window == null ? void 0 : window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _e.CMS_CONSOLE_DOMAIN;
|
|
313
|
+
if (windowDomain) {
|
|
314
|
+
return `https://${windowDomain}`;
|
|
301
315
|
}
|
|
302
|
-
|
|
303
|
-
|
|
316
|
+
const hostSuffix = window.location.hostname.includes("alibabacloud") ? "console.alibabacloud.com" : "console.aliyun.com";
|
|
317
|
+
if (isPre()) {
|
|
318
|
+
return getPreConfig(isObv, hostSuffix);
|
|
304
319
|
}
|
|
305
|
-
return
|
|
320
|
+
return getProdConfig(isObv, hostSuffix);
|
|
321
|
+
}
|
|
322
|
+
function getSLSdomain() {
|
|
323
|
+
return getConsoleDomain(false);
|
|
324
|
+
}
|
|
325
|
+
function getObvDomain() {
|
|
326
|
+
return getConsoleDomain(true);
|
|
306
327
|
}
|
|
307
328
|
function getConfig(key) {
|
|
308
329
|
window.ALIYUN_SLS_CONSOLE_CONFIG = window.ALIYUN_SLS_CONSOLE_CONFIG || {};
|
|
309
330
|
return window.ALIYUN_SLS_CONSOLE_CONFIG[key] !== void 0 ? window.ALIYUN_SLS_CONSOLE_CONFIG[key] : "";
|
|
310
331
|
}
|
|
311
332
|
function extraActionAndResource(message) {
|
|
312
|
-
var
|
|
313
|
-
const arr = (
|
|
333
|
+
var _a;
|
|
334
|
+
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
314
335
|
if (arr.length === 3) {
|
|
315
336
|
return {
|
|
316
337
|
action: arr[1],
|
|
@@ -355,7 +376,7 @@ const errorMsgHandler = (err) => {
|
|
|
355
376
|
return createNoXSS(msg || err.message || i18n.ERRMESSAGE3);
|
|
356
377
|
};
|
|
357
378
|
function getOauthCallbackUrl(url = window.location.href) {
|
|
358
|
-
return `https:${
|
|
379
|
+
return `https:${getLinks("sls.domain.account.url")}/login/login.htm?oauth_callback=${url}`;
|
|
359
380
|
}
|
|
360
381
|
function createNoPermissionContent() {
|
|
361
382
|
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "sls-custom-container" }, /* @__PURE__ */ React.createElement("div", { className: "sls-custom-title" }, i18n.UNAUTHORIZEDOPERMSG)));
|
|
@@ -378,11 +399,11 @@ function getParentUrl() {
|
|
|
378
399
|
}
|
|
379
400
|
const TOP_WINDOW = new Function("return window;")();
|
|
380
401
|
function addRUMLog(log) {
|
|
381
|
-
var
|
|
402
|
+
var _a;
|
|
382
403
|
if (TOP_WINDOW.SLS_CLIENT && TOP_WINDOW.SLS_CLIENT.addLog) {
|
|
383
404
|
TOP_WINDOW.SLS_CLIENT.addLog(log);
|
|
384
405
|
}
|
|
385
|
-
if ((
|
|
406
|
+
if ((_a = window == null ? void 0 : window.RUM_API) == null ? void 0 : _a.addRUMLog) {
|
|
386
407
|
window.RUM_API.addRUMLog(log);
|
|
387
408
|
}
|
|
388
409
|
}
|
|
@@ -872,7 +893,7 @@ slsEasyFetch.defaults.beforeRequest = (url, params, init, options) => __async$7(
|
|
|
872
893
|
const method = (_a = init.method) == null ? void 0 : _a.toLowerCase();
|
|
873
894
|
if (method === "post" || method === "put") {
|
|
874
895
|
let token = getConfig("SEC_TOKEN");
|
|
875
|
-
if (!token && !isLocal) {
|
|
896
|
+
if (!token && !isLocal()) {
|
|
876
897
|
const response = yield fetch(`${getSLSdomain()}/console/getConfigData.json`, {
|
|
877
898
|
method: "get",
|
|
878
899
|
credentials: "include"
|
|
@@ -1637,4 +1658,4 @@ var dashbordService;
|
|
|
1637
1658
|
dashbordService2.updateDashboard = updateDashboard;
|
|
1638
1659
|
})(dashbordService || (dashbordService = {}));
|
|
1639
1660
|
|
|
1640
|
-
export { commonEasyFetch, dashbordService, diamondService, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
|
1661
|
+
export { commonEasyFetch, dashbordService, diamondService, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
package/package.json
CHANGED