@aliyun-obv/api 0.3.55 → 0.4.0-beta.0
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 +81 -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,80 @@ 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, _g;
|
|
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);
|
|
298
307
|
}
|
|
299
|
-
|
|
300
|
-
|
|
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;
|
|
301
311
|
}
|
|
302
|
-
|
|
303
|
-
|
|
312
|
+
const hostSuffix = window.location.hostname.includes("alibabacloud") ? "console.alibabacloud.com" : "console.aliyun.com";
|
|
313
|
+
const suffix = (_g = (_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) != null ? _g : hostSuffix;
|
|
314
|
+
if (isPre()) {
|
|
315
|
+
return getPreConfig(isObv, suffix);
|
|
304
316
|
}
|
|
305
|
-
return
|
|
317
|
+
return getProdConfig(isObv, suffix);
|
|
318
|
+
}
|
|
319
|
+
function getSLSdomain() {
|
|
320
|
+
return getConsoleDomain(false);
|
|
321
|
+
}
|
|
322
|
+
function getObvDomain() {
|
|
323
|
+
return getConsoleDomain(true);
|
|
306
324
|
}
|
|
307
325
|
function getConfig(key) {
|
|
308
326
|
window.ALIYUN_SLS_CONSOLE_CONFIG = window.ALIYUN_SLS_CONSOLE_CONFIG || {};
|
|
309
327
|
return window.ALIYUN_SLS_CONSOLE_CONFIG[key] !== void 0 ? window.ALIYUN_SLS_CONSOLE_CONFIG[key] : "";
|
|
310
328
|
}
|
|
311
329
|
function extraActionAndResource(message) {
|
|
312
|
-
var
|
|
313
|
-
const arr = (
|
|
330
|
+
var _a;
|
|
331
|
+
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
314
332
|
if (arr.length === 3) {
|
|
315
333
|
return {
|
|
316
334
|
action: arr[1],
|
|
@@ -355,7 +373,7 @@ const errorMsgHandler = (err) => {
|
|
|
355
373
|
return createNoXSS(msg || err.message || i18n.ERRMESSAGE3);
|
|
356
374
|
};
|
|
357
375
|
function getOauthCallbackUrl(url = window.location.href) {
|
|
358
|
-
return `https:${
|
|
376
|
+
return `https:${getLinks("sls.domain.account.url")}/login/login.htm?oauth_callback=${url}`;
|
|
359
377
|
}
|
|
360
378
|
function createNoPermissionContent() {
|
|
361
379
|
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 +396,11 @@ function getParentUrl() {
|
|
|
378
396
|
}
|
|
379
397
|
const TOP_WINDOW = new Function("return window;")();
|
|
380
398
|
function addRUMLog(log) {
|
|
381
|
-
var
|
|
399
|
+
var _a;
|
|
382
400
|
if (TOP_WINDOW.SLS_CLIENT && TOP_WINDOW.SLS_CLIENT.addLog) {
|
|
383
401
|
TOP_WINDOW.SLS_CLIENT.addLog(log);
|
|
384
402
|
}
|
|
385
|
-
if ((
|
|
403
|
+
if ((_a = window == null ? void 0 : window.RUM_API) == null ? void 0 : _a.addRUMLog) {
|
|
386
404
|
window.RUM_API.addRUMLog(log);
|
|
387
405
|
}
|
|
388
406
|
}
|
|
@@ -872,7 +890,7 @@ slsEasyFetch.defaults.beforeRequest = (url, params, init, options) => __async$7(
|
|
|
872
890
|
const method = (_a = init.method) == null ? void 0 : _a.toLowerCase();
|
|
873
891
|
if (method === "post" || method === "put") {
|
|
874
892
|
let token = getConfig("SEC_TOKEN");
|
|
875
|
-
if (!token && !isLocal) {
|
|
893
|
+
if (!token && !isLocal()) {
|
|
876
894
|
const response = yield fetch(`${getSLSdomain()}/console/getConfigData.json`, {
|
|
877
895
|
method: "get",
|
|
878
896
|
credentials: "include"
|
|
@@ -1637,4 +1655,4 @@ var dashbordService;
|
|
|
1637
1655
|
dashbordService2.updateDashboard = updateDashboard;
|
|
1638
1656
|
})(dashbordService || (dashbordService = {}));
|
|
1639
1657
|
|
|
1640
|
-
export { commonEasyFetch, dashbordService, diamondService, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
|
1658
|
+
export { commonEasyFetch, dashbordService, diamondService, getConsoleDomain, indexService, metaService, obsEasyFetch, projectService, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, sseClient, workSpaceService };
|
package/package.json
CHANGED