@aliyun-obv/api 0.0.42 → 0.0.44
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 +195 -15
- package/dist/api.es.js +955 -35
- package/package.json +7 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
import { ShowConfig } from '@alifd/next/types/dialog';
|
|
2
|
+
|
|
3
|
+
interface IBaseFetchOptions {
|
|
4
|
+
forbidAlert?: boolean;
|
|
5
|
+
headers?: HeadersInit;
|
|
6
|
+
}
|
|
7
|
+
interface IErrorRequest {
|
|
8
|
+
method: string;
|
|
9
|
+
api: string;
|
|
10
|
+
params: string;
|
|
11
|
+
}
|
|
12
|
+
interface BaseFetchDefault<OP extends IBaseFetchOptions> {
|
|
2
13
|
baseURL?: string;
|
|
3
14
|
getDefaultInit: RequestInit;
|
|
4
15
|
postDefaultInit: RequestInit;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
putDefaultInit: RequestInit;
|
|
17
|
+
beforeRequest?: (url: string, params: Record<string, any>, init: RequestInit, options?: OP) => Promise<{
|
|
18
|
+
url: string;
|
|
19
|
+
init: RequestInit;
|
|
20
|
+
}>;
|
|
21
|
+
afterResponse?: (response: any, options?: OP) => Promise<any>;
|
|
22
|
+
errorHandler?: (request: IErrorRequest, error: any, options?: OP) => any;
|
|
11
23
|
}
|
|
12
|
-
type IFetchAPI = (input: string, init?: RequestInit, options?:
|
|
13
|
-
declare class BaseFetch<R> {
|
|
24
|
+
type IFetchAPI<OP extends IBaseFetchOptions> = (input: string, init?: RequestInit, options?: OP) => Promise<any>;
|
|
25
|
+
declare class BaseFetch<OP extends IBaseFetchOptions, R> {
|
|
14
26
|
private fetchApi;
|
|
15
|
-
defaults: BaseFetchDefault
|
|
16
|
-
constructor(fetchApi?: IFetchAPI);
|
|
27
|
+
defaults: BaseFetchDefault<IBaseFetchOptions>;
|
|
28
|
+
constructor(fetchApi?: IFetchAPI<OP>);
|
|
29
|
+
private beforeRequest;
|
|
17
30
|
private callFetch;
|
|
18
|
-
get(api: string, params?: Record<string, any>, options?:
|
|
19
|
-
|
|
31
|
+
get(api: string, params?: Record<string, any>, options?: OP): Promise<R>;
|
|
32
|
+
private _post;
|
|
33
|
+
post(api: string, params?: Record<string, any>, options?: OP): Promise<R>;
|
|
34
|
+
put(api: string, params?: Record<string, any>, options?: OP): Promise<R>;
|
|
20
35
|
}
|
|
21
36
|
|
|
37
|
+
interface ISLSFetchOptions extends IBaseFetchOptions {
|
|
38
|
+
/**
|
|
39
|
+
* 如果 url 上有 slsRegion 参数,默认会使用,如果 ingoreSlsRegion 为 true,此时不启用
|
|
40
|
+
*/
|
|
41
|
+
ingoreSlsRegion?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* project region, 配置后会在 header 中添加 sls-region,用于 console 直连该 region
|
|
44
|
+
*/
|
|
45
|
+
region?: string;
|
|
46
|
+
/**
|
|
47
|
+
* 'Content-Type': 'application/json'
|
|
48
|
+
*/
|
|
49
|
+
restful?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 隐藏错误弹窗
|
|
52
|
+
*/
|
|
53
|
+
hideErrorAlert?: boolean;
|
|
54
|
+
forbidAlert?: boolean;
|
|
55
|
+
}
|
|
22
56
|
interface IResponseData {
|
|
23
57
|
[x: string]: any;
|
|
24
58
|
res: any;
|
|
@@ -28,9 +62,155 @@ interface IResponseData {
|
|
|
28
62
|
message: any;
|
|
29
63
|
response: Response;
|
|
30
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* For Obs EndPoint
|
|
68
|
+
*/
|
|
69
|
+
declare const obsEasyFetch: BaseFetch<ISLSFetchOptions, IResponseData>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* For Common EndPoint
|
|
73
|
+
*/
|
|
74
|
+
declare const commonEasyFetch: BaseFetch<IBaseFetchOptions, IResponseData>;
|
|
75
|
+
|
|
31
76
|
/**
|
|
32
77
|
* For SLS EndPoint
|
|
33
78
|
*/
|
|
34
|
-
declare const
|
|
79
|
+
declare const slsEasyFetch: BaseFetch<ISLSFetchOptions, IResponseData>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 全局错误处理函数
|
|
83
|
+
* @param config
|
|
84
|
+
* content: 内容
|
|
85
|
+
* title: 标题
|
|
86
|
+
* @param response easyfeatch 返回体
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
declare function showAlertDialog(response: any, config?: ShowConfig, request?: any): boolean;
|
|
90
|
+
declare function showAlertDialogWhenNeedLogin(response: any, config?: {}): void;
|
|
91
|
+
|
|
92
|
+
declare namespace metaService {
|
|
93
|
+
export interface GetMetaRecordParameters {
|
|
94
|
+
name: string;
|
|
95
|
+
recordId: string;
|
|
96
|
+
}
|
|
97
|
+
export function getMetaRecord(params: GetMetaRecordParameters): Promise<IResponseData>;
|
|
98
|
+
export interface ListMetaRecordParameters {
|
|
99
|
+
name: string;
|
|
100
|
+
jsonPath?: string;
|
|
101
|
+
jsonPathValue?: string;
|
|
102
|
+
size?: number;
|
|
103
|
+
page?: number;
|
|
104
|
+
}
|
|
105
|
+
export function listMetaRecord(params: ListMetaRecordParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
106
|
+
export interface CreateMetaResourceParameters {
|
|
107
|
+
name: string;
|
|
108
|
+
type: string;
|
|
109
|
+
description: string;
|
|
110
|
+
schema?: any;
|
|
111
|
+
}
|
|
112
|
+
export function createMetaResource(params: CreateMetaResourceParameters): Promise<IResponseData>;
|
|
113
|
+
export interface CreateMetaRecordParameters {
|
|
114
|
+
name: string;
|
|
115
|
+
record: {
|
|
116
|
+
id?: string;
|
|
117
|
+
tag?: string;
|
|
118
|
+
value: any;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export function createMetaRecord({ name, record }: CreateMetaRecordParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
122
|
+
export function updataMetaRecord({ name, record }: CreateMetaRecordParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
123
|
+
export function listMetaRecordWithIdentity(params: ListMetaRecordParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
124
|
+
export function getMetaRecordWithIdentity(params: GetMetaRecordParameters): Promise<IResponseData>;
|
|
125
|
+
export function updataMetaRecordWithIdentity({ name, record }: CreateMetaRecordParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
126
|
+
export interface DeleteMetaRecordsParameters {
|
|
127
|
+
name: string;
|
|
128
|
+
recordIds: string;
|
|
129
|
+
}
|
|
130
|
+
export function deleteRecords(config?: DeleteMetaRecordsParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
131
|
+
export function deleteRecordsWithIdentity(config?: DeleteMetaRecordsParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
132
|
+
export interface DeleteMetaResource {
|
|
133
|
+
name: string;
|
|
134
|
+
}
|
|
135
|
+
export function deleteResource(params: DeleteMetaResource): Promise<IResponseData>;
|
|
136
|
+
interface Config {
|
|
137
|
+
order: number;
|
|
138
|
+
}
|
|
139
|
+
interface Value {
|
|
140
|
+
project: string;
|
|
141
|
+
dashboard: string;
|
|
142
|
+
value: string;
|
|
143
|
+
update: number;
|
|
144
|
+
version: string;
|
|
145
|
+
config: Config;
|
|
146
|
+
}
|
|
147
|
+
export interface Record {
|
|
148
|
+
value: Value;
|
|
149
|
+
}
|
|
150
|
+
export interface CreateSomeMetaRecordsParameters {
|
|
151
|
+
name: string;
|
|
152
|
+
records: Record[];
|
|
153
|
+
}
|
|
154
|
+
export function createSomeMetaRecordsWithIdentity({ name, records }: CreateSomeMetaRecordsParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
155
|
+
export function createSomeMetaRecords({ name, records }: CreateSomeMetaRecordsParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
156
|
+
export interface LogstoreIndexParameters {
|
|
157
|
+
project: string;
|
|
158
|
+
dashboard: string;
|
|
159
|
+
version?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface NewLogstoreIndexParameters {
|
|
162
|
+
name: string;
|
|
163
|
+
jsonPath?: string;
|
|
164
|
+
jsonPathValue?: string;
|
|
165
|
+
page?: number;
|
|
166
|
+
size?: number;
|
|
167
|
+
}
|
|
168
|
+
export function getNewDashboardList({ name, jsonPath, jsonPathValue, page, size }: NewLogstoreIndexParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
169
|
+
export function getNewDashboardListWithIdentity({ name, jsonPath, jsonPathValue, page, size }: NewLogstoreIndexParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
170
|
+
export interface DeleteRecordsParameters {
|
|
171
|
+
name: string;
|
|
172
|
+
recordIds: string;
|
|
173
|
+
}
|
|
174
|
+
export function deleteVersionRecords({ name, recordIds }: DeleteRecordsParameters, forbidAlert?: boolean): Promise<IResponseData>;
|
|
175
|
+
export const ckeckPermissionForList: (resourceName: string) => Promise<boolean>;
|
|
176
|
+
export {};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare namespace workSpaceService {
|
|
180
|
+
export interface GetWorkspaceRecordParameters {
|
|
181
|
+
workspaceId: string;
|
|
182
|
+
}
|
|
183
|
+
export function getWorkspaceRecord(params: GetWorkspaceRecordParameters): Promise<IResponseData>;
|
|
184
|
+
export interface GetWorkSpaceList {
|
|
185
|
+
type: string;
|
|
186
|
+
page: number;
|
|
187
|
+
pageSize: number;
|
|
188
|
+
}
|
|
189
|
+
export function getWorkspacelist(params: GetWorkSpaceList): Promise<IResponseData>;
|
|
190
|
+
export interface GetWorkspaceInforProps {
|
|
191
|
+
id: string;
|
|
192
|
+
}
|
|
193
|
+
export function getWorkspaceInfor(params: GetWorkspaceInforProps): Promise<IResponseData>;
|
|
194
|
+
export interface createItomInstance {
|
|
195
|
+
workspace: string;
|
|
196
|
+
project: string;
|
|
197
|
+
version: string;
|
|
198
|
+
appType: string;
|
|
199
|
+
}
|
|
200
|
+
export function createInstance(params: createItomInstance): Promise<IResponseData>;
|
|
201
|
+
export interface UpdataAppInstanceProps {
|
|
202
|
+
workspaceId: string;
|
|
203
|
+
app: any;
|
|
204
|
+
}
|
|
205
|
+
export function updataAppInstance(params: UpdataAppInstanceProps): Promise<IResponseData>;
|
|
206
|
+
type GetWorkspaceForITOMProps = {
|
|
207
|
+
instanceId: string;
|
|
208
|
+
project: string;
|
|
209
|
+
aliasId: string;
|
|
210
|
+
size?: number;
|
|
211
|
+
};
|
|
212
|
+
export function getWorkspaceForITOM(params: GetWorkspaceForITOMProps): Promise<IResponseData>;
|
|
213
|
+
export {};
|
|
214
|
+
}
|
|
35
215
|
|
|
36
|
-
export {
|
|
216
|
+
export { commonEasyFetch, metaService, obsEasyFetch, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, workSpaceService };
|
package/dist/api.es.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import errorPrompt from '@alicloud/console-base-error-prompt-proxy';
|
|
3
|
+
import i18n, { getMsg } from '@aliyun-obv/i18n';
|
|
4
|
+
import urijs from 'urijs';
|
|
5
|
+
import { Dialog, Button, Message } from '@alifd/next';
|
|
6
|
+
import { slsConsoleRuntime, commonUtil, urlUtil, addStubForSearch, addRUMLog } from '@aliyun-obv/utils';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import merge from 'lodash/merge';
|
|
2
9
|
|
|
3
10
|
function getParams(obj = {}) {
|
|
4
11
|
return Object.keys(obj).filter((k) => obj[k] || +obj[k] === 0).map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(obj[k])}`).join("&");
|
|
@@ -14,13 +21,27 @@ function getPostParam(obj = {}) {
|
|
|
14
21
|
}).join("&");
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
var __defProp$
|
|
18
|
-
var
|
|
24
|
+
var __defProp$4 = Object.defineProperty;
|
|
25
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
26
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
27
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
28
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
29
|
+
var __spreadValues$4 = (a, b) => {
|
|
30
|
+
for (var prop in b || (b = {}))
|
|
31
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
32
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
33
|
+
if (__getOwnPropSymbols$4)
|
|
34
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
35
|
+
if (__propIsEnum$4.call(b, prop))
|
|
36
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
};
|
|
19
40
|
var __publicField = (obj, key, value) => {
|
|
20
|
-
__defNormalProp$
|
|
41
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
42
|
return value;
|
|
22
43
|
};
|
|
23
|
-
var __async$
|
|
44
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
24
45
|
return new Promise((resolve, reject) => {
|
|
25
46
|
var fulfilled = (value) => {
|
|
26
47
|
try {
|
|
@@ -40,6 +61,7 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
40
61
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
62
|
});
|
|
42
63
|
};
|
|
64
|
+
const isTest = process.env.NODE_ENV === "test";
|
|
43
65
|
class BaseFetch {
|
|
44
66
|
constructor(fetchApi) {
|
|
45
67
|
__publicField(this, "fetchApi");
|
|
@@ -53,13 +75,35 @@ class BaseFetch {
|
|
|
53
75
|
postDefaultInit: {
|
|
54
76
|
method: "post",
|
|
55
77
|
credentials: "same-origin",
|
|
56
|
-
headers: {
|
|
78
|
+
headers: {
|
|
79
|
+
Accept: "application/json"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
putDefaultInit: {
|
|
83
|
+
method: "post",
|
|
84
|
+
credentials: "same-origin",
|
|
85
|
+
headers: {
|
|
86
|
+
Accept: "application/json"
|
|
87
|
+
}
|
|
57
88
|
}
|
|
58
89
|
});
|
|
59
90
|
this.fetchApi = fetchApi;
|
|
60
91
|
}
|
|
92
|
+
beforeRequest(api, params, init, options) {
|
|
93
|
+
const hasBaseURL = typeof this.defaults.baseURL === "string" && this.defaults.baseURL.trim().length > 0;
|
|
94
|
+
let url = api;
|
|
95
|
+
let newInit = init;
|
|
96
|
+
if (hasBaseURL) {
|
|
97
|
+
url = `${this.defaults.baseURL}${url}`;
|
|
98
|
+
newInit = __spreadValues$4({}, Object.assign({}, init, { credentials: "include" }));
|
|
99
|
+
}
|
|
100
|
+
if (this.defaults.beforeRequest) {
|
|
101
|
+
return this.defaults.beforeRequest(url, params, newInit, options);
|
|
102
|
+
}
|
|
103
|
+
return { url, init: newInit };
|
|
104
|
+
}
|
|
61
105
|
callFetch(_0, _1) {
|
|
62
|
-
return __async$
|
|
106
|
+
return __async$5(this, arguments, function* (api, init, options = {}) {
|
|
63
107
|
let headers = init == null ? void 0 : init.headers;
|
|
64
108
|
if (options.headers) {
|
|
65
109
|
headers = Object.assign({}, init == null ? void 0 : init.headers, options.headers);
|
|
@@ -71,31 +115,653 @@ class BaseFetch {
|
|
|
71
115
|
});
|
|
72
116
|
}
|
|
73
117
|
get(_0) {
|
|
74
|
-
return __async$
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
118
|
+
return __async$5(this, arguments, function* (api, params = {}, options = {}) {
|
|
119
|
+
if (isTest)
|
|
120
|
+
return Promise.resolve({ res: void 0 });
|
|
121
|
+
try {
|
|
122
|
+
const { url: newApi, init: newInit } = yield this.beforeRequest(
|
|
123
|
+
api,
|
|
124
|
+
params,
|
|
125
|
+
this.defaults.getDefaultInit,
|
|
126
|
+
options
|
|
127
|
+
);
|
|
128
|
+
const url = `${newApi}?${getParams(params)}`;
|
|
129
|
+
const res = yield this.callFetch(url, newInit, options);
|
|
130
|
+
if (this.defaults.afterResponse) {
|
|
131
|
+
return yield this.defaults.afterResponse(res, options);
|
|
132
|
+
}
|
|
133
|
+
return res;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (this.defaults.errorHandler) {
|
|
136
|
+
return this.defaults.errorHandler(
|
|
137
|
+
{ method: "GET", api, params: getParams(params) },
|
|
138
|
+
error,
|
|
139
|
+
options
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
80
143
|
}
|
|
81
|
-
return res;
|
|
82
144
|
});
|
|
83
145
|
}
|
|
84
|
-
|
|
85
|
-
return __async$
|
|
146
|
+
_post(_0) {
|
|
147
|
+
return __async$5(this, arguments, function* (api, params = {}, options = {}, defaultInit) {
|
|
86
148
|
var _a;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
149
|
+
if (isTest)
|
|
150
|
+
return Promise.resolve({ res: void 0 });
|
|
151
|
+
try {
|
|
152
|
+
const contentType = ((_a = options == null ? void 0 : options.headers) == null ? void 0 : _a["Content-Type"]) || "application/x-www-form-urlencoded";
|
|
153
|
+
const fetchInit = _.merge({}, defaultInit, {
|
|
154
|
+
body: contentType.includes("application/json") ? JSON.stringify(params) : getPostParam(params)
|
|
155
|
+
});
|
|
156
|
+
const { url: newApi, init: newInit } = yield this.beforeRequest(api, params, fetchInit, options);
|
|
157
|
+
const res = yield this.callFetch(newApi, newInit, options);
|
|
158
|
+
if (this.defaults.afterResponse) {
|
|
159
|
+
return yield this.defaults.afterResponse(res, options);
|
|
160
|
+
}
|
|
161
|
+
return res;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (this.defaults.errorHandler) {
|
|
164
|
+
return this.defaults.errorHandler(error, options);
|
|
165
|
+
}
|
|
166
|
+
throw error;
|
|
94
167
|
}
|
|
95
|
-
return res;
|
|
96
168
|
});
|
|
97
169
|
}
|
|
170
|
+
post(_0) {
|
|
171
|
+
return __async$5(this, arguments, function* (api, params = {}, options = {}) {
|
|
172
|
+
return this._post(api, params, options, this.defaults.postDefaultInit);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
put(_0) {
|
|
176
|
+
return __async$5(this, arguments, function* (api, params = {}, options = {}) {
|
|
177
|
+
return this._post(api, params, options, this.defaults.putDefaultInit);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getConfig(key) {
|
|
183
|
+
window.ALIYUN_SLS_CONSOLE_CONFIG = window.ALIYUN_SLS_CONSOLE_CONFIG || {};
|
|
184
|
+
return window.ALIYUN_SLS_CONSOLE_CONFIG[key] !== void 0 ? window.ALIYUN_SLS_CONSOLE_CONFIG[key] : "";
|
|
185
|
+
}
|
|
186
|
+
function extraActionAndResource(message) {
|
|
187
|
+
var _a;
|
|
188
|
+
const arr = (_a = message.match(/denied by sts or ram[\S\s]+action:\s(\S+:\S+),[\S\s]+resource:\s(\S+)/)) != null ? _a : [];
|
|
189
|
+
if (arr.length === 3) {
|
|
190
|
+
return {
|
|
191
|
+
action: arr[1],
|
|
192
|
+
resource: arr[2]
|
|
193
|
+
};
|
|
194
|
+
} else {
|
|
195
|
+
return {
|
|
196
|
+
action: "",
|
|
197
|
+
resource: ""
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function convertErrorDetaisAuth(o) {
|
|
202
|
+
if (!o) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
type: o.NoPermissionType,
|
|
207
|
+
action: o.AuthAction,
|
|
208
|
+
resource: o.AuthResource,
|
|
209
|
+
userType: o.AuthPrincipalType,
|
|
210
|
+
userName: o.AuthPrincipalDisplayName,
|
|
211
|
+
userId: o.AuthPrincipalOwnerId,
|
|
212
|
+
policyType: o.PolicyType,
|
|
213
|
+
diagnosisInfo: o.EncodedDiagnosticMessage
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function createNoXSS(htmlString) {
|
|
217
|
+
return htmlString.substr(0, 400);
|
|
218
|
+
}
|
|
219
|
+
const errorMsgHandler = (err) => {
|
|
220
|
+
let msg = window.ALIYUN_SLS_CONSOLE_MESSAGE && window.ALIYUN_SLS_CONSOLE_MESSAGE[err.code];
|
|
221
|
+
if (err.code === "OnlyInternalAccess") {
|
|
222
|
+
return err.message;
|
|
223
|
+
}
|
|
224
|
+
if (err.message === "Failed to fetch") {
|
|
225
|
+
msg = i18n.ERRMESSAGE4;
|
|
226
|
+
}
|
|
227
|
+
if (err.message && err.message.indexOf("Specified ArgValue is malformed") > -1) {
|
|
228
|
+
msg = i18n.ERRMESSAGE2;
|
|
229
|
+
}
|
|
230
|
+
return createNoXSS(msg || err.message || i18n.ERRMESSAGE3);
|
|
231
|
+
};
|
|
232
|
+
function getOauthCallbackUrl(url = window.location.href) {
|
|
233
|
+
return `https:${slsConsoleRuntime.links.ACCOUNT}/login/login.htm?oauth_callback=${url}`;
|
|
234
|
+
}
|
|
235
|
+
function createNoPermissionContent() {
|
|
236
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "sls-custom-container" }, /* @__PURE__ */ React.createElement("div", { className: "sls-custom-title" }, i18n.UNAUTHORIZEDOPERMSG)));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var __defProp$3 = Object.defineProperty;
|
|
240
|
+
var __defProps$3 = Object.defineProperties;
|
|
241
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
242
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
243
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
244
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
245
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
246
|
+
var __spreadValues$3 = (a, b) => {
|
|
247
|
+
for (var prop in b || (b = {}))
|
|
248
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
249
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
250
|
+
if (__getOwnPropSymbols$3)
|
|
251
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
252
|
+
if (__propIsEnum$3.call(b, prop))
|
|
253
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
254
|
+
}
|
|
255
|
+
return a;
|
|
256
|
+
};
|
|
257
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
258
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
259
|
+
return new Promise((resolve, reject) => {
|
|
260
|
+
var fulfilled = (value) => {
|
|
261
|
+
try {
|
|
262
|
+
step(generator.next(value));
|
|
263
|
+
} catch (e) {
|
|
264
|
+
reject(e);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var rejected = (value) => {
|
|
268
|
+
try {
|
|
269
|
+
step(generator.throw(value));
|
|
270
|
+
} catch (e) {
|
|
271
|
+
reject(e);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
275
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
const commonEasyFetch = new BaseFetch();
|
|
279
|
+
commonEasyFetch.defaults.postDefaultInit.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
280
|
+
commonEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
|
|
281
|
+
commonEasyFetch.defaults.afterResponse = (response) => __async$4(void 0, null, function* () {
|
|
282
|
+
if (response.status >= 200 && response.status < 300) {
|
|
283
|
+
const data = yield response.json();
|
|
284
|
+
return __spreadProps$3(__spreadValues$3({}, data != null ? data : {}), {
|
|
285
|
+
response
|
|
286
|
+
});
|
|
287
|
+
} else {
|
|
288
|
+
throw new Error(response.statusText);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const ERROR_TITLE = i18n.ERROR;
|
|
293
|
+
i18n.OK;
|
|
294
|
+
let isGlobalAlertShow = false;
|
|
295
|
+
function showConsoleBaseAlertDialog(response, config = {}, request) {
|
|
296
|
+
var _a, _b, _c;
|
|
297
|
+
if ((response == null ? void 0 : response.code) === "200") {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
const errorConfig = {
|
|
301
|
+
title: ERROR_TITLE,
|
|
302
|
+
// 错误
|
|
303
|
+
message: response.message,
|
|
304
|
+
code: response.code,
|
|
305
|
+
requestId: response.requestId,
|
|
306
|
+
details: {
|
|
307
|
+
url: request ? request.api : void 0,
|
|
308
|
+
method: request ? request.method : void 0
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
if (response.code === "ShowUnauthorized") {
|
|
312
|
+
if ((_a = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _a.accessDeniedDetail) {
|
|
313
|
+
const detailsAuth = convertErrorDetaisAuth(response.rawResponseError.accessDeniedDetail);
|
|
314
|
+
errorConfig.detailsAuth = detailsAuth;
|
|
315
|
+
errorConfig.code = ((_b = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _b.errorCode) || "Unauthorized";
|
|
316
|
+
errorPrompt(errorConfig);
|
|
317
|
+
} else {
|
|
318
|
+
const { action, resource } = extraActionAndResource(response.message);
|
|
319
|
+
if (errorConfig.details) {
|
|
320
|
+
errorConfig.details.ACTION = action;
|
|
321
|
+
errorConfig.details.RESOURCE = resource;
|
|
322
|
+
}
|
|
323
|
+
errorConfig.code = ((_c = response == null ? void 0 : response.rawResponseError) == null ? void 0 : _c.errorCode) || "Unauthorized";
|
|
324
|
+
errorPrompt(errorConfig, config, true);
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
errorPrompt(errorConfig, config, true);
|
|
328
|
+
}
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
function showCSRFDialog(config) {
|
|
332
|
+
const dialog = Dialog.alert({
|
|
333
|
+
content: i18n.ERRMESSAGE1,
|
|
334
|
+
title: ERROR_TITLE,
|
|
335
|
+
className: "cdnext-alert cdnext-error-alert",
|
|
336
|
+
afterClose: () => {
|
|
337
|
+
isGlobalAlertShow = false;
|
|
338
|
+
if (config.afterClose) {
|
|
339
|
+
config.afterClose();
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
footer: [
|
|
343
|
+
/* @__PURE__ */ React.createElement(
|
|
344
|
+
Button,
|
|
345
|
+
{
|
|
346
|
+
type: "primary",
|
|
347
|
+
onClick: () => {
|
|
348
|
+
commonEasyFetch.get("/console/ajax/getSecToken.json").then((res) => {
|
|
349
|
+
if ((res == null ? void 0 : res.code) === "200") {
|
|
350
|
+
window.ALIYUN_SLS_CONSOLE_CONFIG.SEC_TOKEN = res.data;
|
|
351
|
+
dialog.hide();
|
|
352
|
+
}
|
|
353
|
+
}).catch(() => {
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
i18n.REFRESH
|
|
358
|
+
)
|
|
359
|
+
]
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function showNeedLoginDialog(config) {
|
|
363
|
+
const parseQuery = urijs(location.search).escapeQuerySpace(false).query(true);
|
|
364
|
+
if (commonUtil.judgeIframe() && parseQuery.reloadParent === "true") {
|
|
365
|
+
try {
|
|
366
|
+
const mockWindow = parent.parent.window;
|
|
367
|
+
const mockLocation = mockWindow.location;
|
|
368
|
+
mockLocation.href = decodeURIComponent(urlUtil.getParentUrl());
|
|
369
|
+
return;
|
|
370
|
+
} catch (e) {
|
|
371
|
+
console.error(e);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
let loginUrl = getOauthCallbackUrl(
|
|
375
|
+
`${window.location.origin}/lognext/exit${addStubForSearch("", true)}`
|
|
376
|
+
);
|
|
377
|
+
if (parseQuery.customLoginUrl && parseQuery.customLoginUrl !== "") {
|
|
378
|
+
loginUrl = decodeURIComponent(parseQuery.customLoginUrl);
|
|
379
|
+
}
|
|
380
|
+
const dialog = Dialog.alert({
|
|
381
|
+
content: getMsg("lb.login_time_out_content"),
|
|
382
|
+
title: getMsg("lb.login_time_out_title"),
|
|
383
|
+
className: "cdnext-alert cdnext-error-alert",
|
|
384
|
+
afterClose: () => {
|
|
385
|
+
isGlobalAlertShow = false;
|
|
386
|
+
if (config.afterClose) {
|
|
387
|
+
config.afterClose();
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
footer: [
|
|
391
|
+
/* @__PURE__ */ React.createElement(
|
|
392
|
+
Button,
|
|
393
|
+
{
|
|
394
|
+
type: "primary",
|
|
395
|
+
style: { marginRight: "8px" },
|
|
396
|
+
onClick: () => {
|
|
397
|
+
addRUMLog({
|
|
398
|
+
spm_main: "login_dialog",
|
|
399
|
+
spm_btn_type: "login",
|
|
400
|
+
spm_loginUrl: loginUrl
|
|
401
|
+
});
|
|
402
|
+
window.open(loginUrl, "_blank");
|
|
403
|
+
},
|
|
404
|
+
key: "login"
|
|
405
|
+
},
|
|
406
|
+
getMsg("lb.login_time_out_new_window")
|
|
407
|
+
),
|
|
408
|
+
/* @__PURE__ */ React.createElement(
|
|
409
|
+
Button,
|
|
410
|
+
{
|
|
411
|
+
onClick: () => {
|
|
412
|
+
addRUMLog({
|
|
413
|
+
spm_main: "login_dialog",
|
|
414
|
+
spm_btn_type: "getSecToken",
|
|
415
|
+
spm_loginUrl: loginUrl
|
|
416
|
+
});
|
|
417
|
+
commonEasyFetch.get("/console/ajax/getSecToken.json").then((res) => {
|
|
418
|
+
if (res && res.code === "200") {
|
|
419
|
+
window.ALIYUN_SLS_CONSOLE_CONFIG.SEC_TOKEN = res.data;
|
|
420
|
+
dialog.hide();
|
|
421
|
+
} else {
|
|
422
|
+
Message.error(getMsg("lb.login_time_out"));
|
|
423
|
+
}
|
|
424
|
+
}).catch(() => {
|
|
425
|
+
});
|
|
426
|
+
},
|
|
427
|
+
key: "getSecToken"
|
|
428
|
+
},
|
|
429
|
+
getMsg("lb.login_time_out_finished")
|
|
430
|
+
)
|
|
431
|
+
]
|
|
432
|
+
});
|
|
98
433
|
}
|
|
434
|
+
function showAlertDialog(response, config = {}, request) {
|
|
435
|
+
if (isGlobalAlertShow || response == null) {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
if ((response == null ? void 0 : response.code) === "200") {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
if (config.content == null || config.content === "") {
|
|
442
|
+
config.content = errorMsgHandler(response);
|
|
443
|
+
}
|
|
444
|
+
if (response.code === "CsrfTokenError") {
|
|
445
|
+
isGlobalAlertShow = true;
|
|
446
|
+
showCSRFDialog(config);
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
if (response.code === "ConsoleNeedLogin") {
|
|
450
|
+
isGlobalAlertShow = true;
|
|
451
|
+
showNeedLoginDialog(response);
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
const _params = {
|
|
455
|
+
title: ERROR_TITLE,
|
|
456
|
+
message: /* @__PURE__ */ React.createElement("div", null, config.content ? config.content : "")
|
|
457
|
+
};
|
|
458
|
+
showConsoleBaseAlertDialog(response, _params, request);
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
function showAlertDialogWhenNeedLogin(response, config = {}) {
|
|
462
|
+
if (response != null && response.code === "ConsoleNeedLogin") {
|
|
463
|
+
showAlertDialog(response, config);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const errorHandler = (request, error, options) => {
|
|
467
|
+
var _a;
|
|
468
|
+
if (error.code === "IndexConfigNotExist" && error.message && (request.api === "/console/logstoreindex/getLogs.json" || request.api === "/console/logstoreindex/getHistograms.json")) {
|
|
469
|
+
if (options && "product" in options && options.product !== "") {
|
|
470
|
+
showAlertDialog(
|
|
471
|
+
error,
|
|
472
|
+
{
|
|
473
|
+
content: i18n.PRODUCTMESSAGE
|
|
474
|
+
},
|
|
475
|
+
request
|
|
476
|
+
);
|
|
477
|
+
} else {
|
|
478
|
+
showAlertDialog(
|
|
479
|
+
error,
|
|
480
|
+
{
|
|
481
|
+
content: errorMsgHandler(error)
|
|
482
|
+
},
|
|
483
|
+
request
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
} else {
|
|
487
|
+
if (error.code === "ShowUnauthorized") {
|
|
488
|
+
if ((_a = error == null ? void 0 : error.rawResponseError) == null ? void 0 : _a.accessDeniedDetail) {
|
|
489
|
+
showAlertDialog(
|
|
490
|
+
error,
|
|
491
|
+
{
|
|
492
|
+
content: errorMsgHandler(error)
|
|
493
|
+
},
|
|
494
|
+
request
|
|
495
|
+
);
|
|
496
|
+
} else {
|
|
497
|
+
showAlertDialog(
|
|
498
|
+
error,
|
|
499
|
+
{
|
|
500
|
+
content: createNoPermissionContent(),
|
|
501
|
+
className: "sls-custom-dialog"
|
|
502
|
+
},
|
|
503
|
+
request
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
} else {
|
|
507
|
+
showAlertDialog(
|
|
508
|
+
error,
|
|
509
|
+
{
|
|
510
|
+
content: errorMsgHandler(error)
|
|
511
|
+
},
|
|
512
|
+
request
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
return "";
|
|
516
|
+
}
|
|
517
|
+
let errorMessage = error.message;
|
|
518
|
+
throw errorMessage;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
var __defProp$2 = Object.defineProperty;
|
|
522
|
+
var __defProps$2 = Object.defineProperties;
|
|
523
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
524
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
525
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
526
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
527
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
528
|
+
var __spreadValues$2 = (a, b) => {
|
|
529
|
+
for (var prop in b || (b = {}))
|
|
530
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
531
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
532
|
+
if (__getOwnPropSymbols$2)
|
|
533
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
534
|
+
if (__propIsEnum$2.call(b, prop))
|
|
535
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
536
|
+
}
|
|
537
|
+
return a;
|
|
538
|
+
};
|
|
539
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
540
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
541
|
+
return new Promise((resolve, reject) => {
|
|
542
|
+
var fulfilled = (value) => {
|
|
543
|
+
try {
|
|
544
|
+
step(generator.next(value));
|
|
545
|
+
} catch (e) {
|
|
546
|
+
reject(e);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
var rejected = (value) => {
|
|
550
|
+
try {
|
|
551
|
+
step(generator.throw(value));
|
|
552
|
+
} catch (e) {
|
|
553
|
+
reject(e);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
557
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
let slsAccessToken = window.ALIYUN_SLS_CONSOLE_CONFIG.slsAccessToken;
|
|
561
|
+
let slsAccessTokenMode = false;
|
|
562
|
+
const urlQueryObj = urijs(location.search).escapeQuerySpace(false).query(true);
|
|
563
|
+
const supportRefreshToken = urlQueryObj.supportRefreshToken === "true" && window.top !== window.self && parent != null;
|
|
564
|
+
try {
|
|
565
|
+
if (window.ALIYUN_CONSOLE_CONFIG.ENV === "pre") {
|
|
566
|
+
if (urlQueryObj.slsAccessToken) {
|
|
567
|
+
slsAccessToken = urlQueryObj.slsAccessToken;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
} catch (error) {
|
|
571
|
+
}
|
|
572
|
+
if (Object.prototype.toString.call(slsAccessToken) === "[object String]" && slsAccessToken.length > 0) {
|
|
573
|
+
slsAccessTokenMode = true;
|
|
574
|
+
}
|
|
575
|
+
let tokenRefreshing = false;
|
|
576
|
+
let refreshPromisesQueue = [];
|
|
577
|
+
function waitRefreshToken() {
|
|
578
|
+
return new Promise((resolve) => {
|
|
579
|
+
refreshPromisesQueue.push(resolve);
|
|
580
|
+
if (!tokenRefreshing) {
|
|
581
|
+
tokenRefreshing = true;
|
|
582
|
+
parent.postMessage({ type: "refreshToken", ticket: urlQueryObj.sls_ticket }, "*");
|
|
583
|
+
window.addEventListener(
|
|
584
|
+
"message",
|
|
585
|
+
(event) => {
|
|
586
|
+
var _a, _b, _c;
|
|
587
|
+
try {
|
|
588
|
+
if (((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.type) === "applyAccessToken" && ((_b = event == null ? void 0 : event.data) == null ? void 0 : _b.ticket) === urlQueryObj.sls_ticket) {
|
|
589
|
+
slsAccessToken = (_c = event == null ? void 0 : event.data) == null ? void 0 : _c.accessToken;
|
|
590
|
+
tokenRefreshing = false;
|
|
591
|
+
const queue = refreshPromisesQueue;
|
|
592
|
+
refreshPromisesQueue = [];
|
|
593
|
+
queue.forEach((rl) => {
|
|
594
|
+
rl(void 0);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
} catch (error) {
|
|
598
|
+
console.error(error);
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
{ once: true }
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
function _finalFetch(api, fetchOptions, deep = 0) {
|
|
607
|
+
return __async$3(this, null, function* () {
|
|
608
|
+
const requestApi = api;
|
|
609
|
+
if (tokenRefreshing) {
|
|
610
|
+
yield waitRefreshToken();
|
|
611
|
+
}
|
|
612
|
+
if (slsAccessTokenMode) {
|
|
613
|
+
fetchOptions.headers = __spreadProps$2(__spreadValues$2({}, fetchOptions.headers || {}), {
|
|
614
|
+
slsAccessToken
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
const response = yield fetch(requestApi, fetchOptions);
|
|
618
|
+
if (response.status >= 200 && response.status < 300) {
|
|
619
|
+
const data = yield response.json();
|
|
620
|
+
if (slsAccessTokenMode && supportRefreshToken && deep < 3) {
|
|
621
|
+
if (data.code === "ExpiredToken") {
|
|
622
|
+
yield waitRefreshToken();
|
|
623
|
+
return _finalFetch(api, fetchOptions, deep + 1);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
response,
|
|
628
|
+
data
|
|
629
|
+
};
|
|
630
|
+
} else {
|
|
631
|
+
throw new Error(response.statusText);
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
function finalFetch(api, fetchOptions, options) {
|
|
636
|
+
return __async$3(this, null, function* () {
|
|
637
|
+
let finalOption = fetchOptions;
|
|
638
|
+
const parseQuery = urijs(decodeURIComponent(location.search)).escapeQuerySpace(false).query(true);
|
|
639
|
+
if (parseQuery.slsRegion && options.ingoreSlsRegion) {
|
|
640
|
+
finalOption = merge({}, finalOption, {
|
|
641
|
+
headers: {
|
|
642
|
+
"Sls-Region": parseQuery.slsRegion
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
if (options.region && options.region.trim() !== "") {
|
|
647
|
+
finalOption = merge({}, finalOption, {
|
|
648
|
+
headers: {
|
|
649
|
+
"Sls-Region": options.region
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
return _finalFetch(api, finalOption);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
var __defProp$1 = Object.defineProperty;
|
|
658
|
+
var __defProps$1 = Object.defineProperties;
|
|
659
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
660
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
661
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
662
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
663
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
664
|
+
var __spreadValues$1 = (a, b) => {
|
|
665
|
+
for (var prop in b || (b = {}))
|
|
666
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
667
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
668
|
+
if (__getOwnPropSymbols$1)
|
|
669
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
670
|
+
if (__propIsEnum$1.call(b, prop))
|
|
671
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
672
|
+
}
|
|
673
|
+
return a;
|
|
674
|
+
};
|
|
675
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
676
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
677
|
+
return new Promise((resolve, reject) => {
|
|
678
|
+
var fulfilled = (value) => {
|
|
679
|
+
try {
|
|
680
|
+
step(generator.next(value));
|
|
681
|
+
} catch (e) {
|
|
682
|
+
reject(e);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
var rejected = (value) => {
|
|
686
|
+
try {
|
|
687
|
+
step(generator.throw(value));
|
|
688
|
+
} catch (e) {
|
|
689
|
+
reject(e);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
693
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
const slsEasyFetch = new BaseFetch(finalFetch);
|
|
697
|
+
slsEasyFetch.defaults.postDefaultInit.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
698
|
+
slsEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
|
|
699
|
+
slsEasyFetch.defaults.errorHandler = errorHandler;
|
|
700
|
+
slsEasyFetch.defaults.beforeRequest = (url, params, init, options) => __async$2(void 0, null, function* () {
|
|
701
|
+
var _a;
|
|
702
|
+
const method = (_a = init.method) == null ? void 0 : _a.toLowerCase();
|
|
703
|
+
if (method === "post" || method === "put") {
|
|
704
|
+
let newInit = init;
|
|
705
|
+
if (options == null ? void 0 : options.restful) {
|
|
706
|
+
newInit = merge({}, init, {
|
|
707
|
+
headers: {
|
|
708
|
+
"X-CSRF-TOKEN": getConfig("SEC_TOKEN"),
|
|
709
|
+
"Content-Type": "application/json"
|
|
710
|
+
},
|
|
711
|
+
body: JSON.stringify(params)
|
|
712
|
+
});
|
|
713
|
+
} else {
|
|
714
|
+
newInit = merge({}, init, {
|
|
715
|
+
headers: {
|
|
716
|
+
"X-CSRF-TOKEN": getConfig("SEC_TOKEN")
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
return {
|
|
721
|
+
url,
|
|
722
|
+
init: newInit
|
|
723
|
+
};
|
|
724
|
+
} else {
|
|
725
|
+
return {
|
|
726
|
+
url,
|
|
727
|
+
init
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
slsEasyFetch.defaults.afterResponse = (r, options) => __async$2(void 0, null, function* () {
|
|
732
|
+
const { response, data } = r;
|
|
733
|
+
let composedData = typeof data === "string" ? data : __spreadProps$1(__spreadValues$1({}, data), {
|
|
734
|
+
response
|
|
735
|
+
});
|
|
736
|
+
let hasError = false;
|
|
737
|
+
if (response.url.indexOf("/console/logs/getLogs.json") !== -1) {
|
|
738
|
+
const newData = Object.assign({}, data, response.headers.get("x-log-requestid"));
|
|
739
|
+
composedData = __spreadProps$1(__spreadValues$1({}, newData), {
|
|
740
|
+
response
|
|
741
|
+
});
|
|
742
|
+
if (newData.code && newData.code.toString() !== "200") {
|
|
743
|
+
hasError = true;
|
|
744
|
+
}
|
|
745
|
+
} else {
|
|
746
|
+
if (data.code && data.code.toString() === "200") ; else {
|
|
747
|
+
hasError = true;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if ((options == null ? void 0 : options.forbidAlert) || (options == null ? void 0 : options.hideErrorAlert)) {
|
|
751
|
+
return composedData;
|
|
752
|
+
}
|
|
753
|
+
if (hasError) {
|
|
754
|
+
throw composedData;
|
|
755
|
+
}
|
|
756
|
+
return composedData;
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
const obsEasyFetch = new BaseFetch(finalFetch);
|
|
760
|
+
obsEasyFetch.defaults.postDefaultInit.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
761
|
+
obsEasyFetch.defaults.postDefaultInit.headers["Accept"] = "application/json";
|
|
762
|
+
obsEasyFetch.defaults.errorHandler = errorHandler;
|
|
763
|
+
obsEasyFetch.defaults.beforeRequest = slsEasyFetch.defaults.beforeRequest;
|
|
764
|
+
obsEasyFetch.defaults.afterResponse = slsEasyFetch.defaults.afterResponse;
|
|
99
765
|
|
|
100
766
|
var __defProp = Object.defineProperty;
|
|
101
767
|
var __defProps = Object.defineProperties;
|
|
@@ -116,6 +782,234 @@ var __spreadValues = (a, b) => {
|
|
|
116
782
|
return a;
|
|
117
783
|
};
|
|
118
784
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
785
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
786
|
+
return new Promise((resolve, reject) => {
|
|
787
|
+
var fulfilled = (value) => {
|
|
788
|
+
try {
|
|
789
|
+
step(generator.next(value));
|
|
790
|
+
} catch (e) {
|
|
791
|
+
reject(e);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
var rejected = (value) => {
|
|
795
|
+
try {
|
|
796
|
+
step(generator.throw(value));
|
|
797
|
+
} catch (e) {
|
|
798
|
+
reject(e);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
802
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
803
|
+
});
|
|
804
|
+
};
|
|
805
|
+
var metaService;
|
|
806
|
+
((metaService2) => {
|
|
807
|
+
function getMetaRecord(params) {
|
|
808
|
+
return __async$1(this, null, function* () {
|
|
809
|
+
return slsEasyFetch.get("/console/metaRecordAjax/get.json", params);
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
metaService2.getMetaRecord = getMetaRecord;
|
|
813
|
+
function listMetaRecord(params, forbidAlert = false) {
|
|
814
|
+
return __async$1(this, null, function* () {
|
|
815
|
+
return slsEasyFetch.get(
|
|
816
|
+
"/console/metaRecordAjax/list.json",
|
|
817
|
+
__spreadProps(__spreadValues({}, params), {
|
|
818
|
+
page: params.page || 1,
|
|
819
|
+
size: params.size || 100
|
|
820
|
+
}),
|
|
821
|
+
{ forbidAlert }
|
|
822
|
+
);
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
metaService2.listMetaRecord = listMetaRecord;
|
|
826
|
+
function createMetaResource(params) {
|
|
827
|
+
return __async$1(this, null, function* () {
|
|
828
|
+
return slsEasyFetch.post("/console/metaResourceAjax/create.json", params);
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
metaService2.createMetaResource = createMetaResource;
|
|
832
|
+
function createMetaRecord(_0) {
|
|
833
|
+
return __async$1(this, arguments, function* ({ name, record }, forbidAlert = false) {
|
|
834
|
+
const recordObj = __spreadProps(__spreadValues({}, record), {
|
|
835
|
+
value: JSON.stringify(record.value)
|
|
836
|
+
});
|
|
837
|
+
return slsEasyFetch.post(
|
|
838
|
+
"/console/metaRecordAjax/create.json",
|
|
839
|
+
{
|
|
840
|
+
name,
|
|
841
|
+
record: JSON.stringify(recordObj)
|
|
842
|
+
},
|
|
843
|
+
{ forbidAlert }
|
|
844
|
+
);
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
metaService2.createMetaRecord = createMetaRecord;
|
|
848
|
+
function updataMetaRecord(_0) {
|
|
849
|
+
return __async$1(this, arguments, function* ({ name, record }, forbidAlert = false) {
|
|
850
|
+
const recordObj = __spreadProps(__spreadValues({}, record), {
|
|
851
|
+
value: JSON.stringify(record.value)
|
|
852
|
+
});
|
|
853
|
+
return slsEasyFetch.post(
|
|
854
|
+
"/console/metaRecordAjax/update.json",
|
|
855
|
+
{
|
|
856
|
+
name,
|
|
857
|
+
record: JSON.stringify(recordObj)
|
|
858
|
+
},
|
|
859
|
+
{ forbidAlert }
|
|
860
|
+
);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
metaService2.updataMetaRecord = updataMetaRecord;
|
|
864
|
+
function listMetaRecordWithIdentity(params, forbidAlert = false) {
|
|
865
|
+
return __async$1(this, null, function* () {
|
|
866
|
+
return slsEasyFetch.get(
|
|
867
|
+
"/console/metaRecordAjax/listWithIdentity.json",
|
|
868
|
+
__spreadProps(__spreadValues({}, params), {
|
|
869
|
+
page: params.page || 1,
|
|
870
|
+
size: params.size || 100
|
|
871
|
+
}),
|
|
872
|
+
{ forbidAlert }
|
|
873
|
+
);
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
metaService2.listMetaRecordWithIdentity = listMetaRecordWithIdentity;
|
|
877
|
+
function getMetaRecordWithIdentity(params) {
|
|
878
|
+
return __async$1(this, null, function* () {
|
|
879
|
+
return slsEasyFetch.get("/console/metaRecordAjax/getWithIdentity.json", params);
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
metaService2.getMetaRecordWithIdentity = getMetaRecordWithIdentity;
|
|
883
|
+
function updataMetaRecordWithIdentity(_0) {
|
|
884
|
+
return __async$1(this, arguments, function* ({ name, record }, forbidAlert = false) {
|
|
885
|
+
const recordObj = __spreadProps(__spreadValues({}, record), {
|
|
886
|
+
value: JSON.stringify(record.value)
|
|
887
|
+
});
|
|
888
|
+
return slsEasyFetch.post(
|
|
889
|
+
"/console/metaRecordAjax/updateWithIdentity.json",
|
|
890
|
+
{
|
|
891
|
+
name,
|
|
892
|
+
record: JSON.stringify(recordObj)
|
|
893
|
+
},
|
|
894
|
+
{ forbidAlert }
|
|
895
|
+
);
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
metaService2.updataMetaRecordWithIdentity = updataMetaRecordWithIdentity;
|
|
899
|
+
function deleteRecords() {
|
|
900
|
+
return __async$1(this, arguments, function* (config = {
|
|
901
|
+
name: "",
|
|
902
|
+
recordIds: ""
|
|
903
|
+
// 1,2
|
|
904
|
+
}, forbidAlert = false) {
|
|
905
|
+
return slsEasyFetch.post("/console/metaRecordAjax/delete.json", config, { forbidAlert });
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
metaService2.deleteRecords = deleteRecords;
|
|
909
|
+
function deleteRecordsWithIdentity() {
|
|
910
|
+
return __async$1(this, arguments, function* (config = {
|
|
911
|
+
name: "",
|
|
912
|
+
recordIds: ""
|
|
913
|
+
// 1,2
|
|
914
|
+
}, forbidAlert = false) {
|
|
915
|
+
return slsEasyFetch.post("/console/metaRecordAjax/deleteWithIdentity.json", config, {
|
|
916
|
+
forbidAlert
|
|
917
|
+
});
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
metaService2.deleteRecordsWithIdentity = deleteRecordsWithIdentity;
|
|
921
|
+
function deleteResource(params) {
|
|
922
|
+
return __async$1(this, null, function* () {
|
|
923
|
+
return slsEasyFetch.post("/console/metaResourceAjax/delete.json", params);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
metaService2.deleteResource = deleteResource;
|
|
927
|
+
function createSomeMetaRecordsWithIdentity(_0) {
|
|
928
|
+
return __async$1(this, arguments, function* ({ name, records }, forbidAlert = false) {
|
|
929
|
+
return slsEasyFetch.post(
|
|
930
|
+
"/console/metaRecordAjax/batchUpsertWithIdentity.json",
|
|
931
|
+
{
|
|
932
|
+
name,
|
|
933
|
+
records: JSON.stringify(records)
|
|
934
|
+
},
|
|
935
|
+
{ forbidAlert }
|
|
936
|
+
);
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
metaService2.createSomeMetaRecordsWithIdentity = createSomeMetaRecordsWithIdentity;
|
|
940
|
+
function createSomeMetaRecords(_0) {
|
|
941
|
+
return __async$1(this, arguments, function* ({ name, records }, forbidAlert = false) {
|
|
942
|
+
return slsEasyFetch.post(
|
|
943
|
+
"/console/metaRecordAjax/batchUpsert.json",
|
|
944
|
+
{
|
|
945
|
+
name,
|
|
946
|
+
records: JSON.stringify(records)
|
|
947
|
+
},
|
|
948
|
+
{ forbidAlert }
|
|
949
|
+
);
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
metaService2.createSomeMetaRecords = createSomeMetaRecords;
|
|
953
|
+
function getNewDashboardList(_0) {
|
|
954
|
+
return __async$1(this, arguments, function* ({ name, jsonPath, jsonPathValue, page, size }, forbidAlert = false) {
|
|
955
|
+
return slsEasyFetch.post(
|
|
956
|
+
`/console/metaRecordAjax/list.json`,
|
|
957
|
+
{
|
|
958
|
+
name,
|
|
959
|
+
jsonPath,
|
|
960
|
+
jsonPathValue,
|
|
961
|
+
page,
|
|
962
|
+
size
|
|
963
|
+
},
|
|
964
|
+
{ forbidAlert }
|
|
965
|
+
);
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
metaService2.getNewDashboardList = getNewDashboardList;
|
|
969
|
+
function getNewDashboardListWithIdentity(_0) {
|
|
970
|
+
return __async$1(this, arguments, function* ({ name, jsonPath, jsonPathValue, page, size }, forbidAlert = false) {
|
|
971
|
+
return slsEasyFetch.post(
|
|
972
|
+
`/console/metaRecordAjax/listWithIdentity.json`,
|
|
973
|
+
{
|
|
974
|
+
name,
|
|
975
|
+
jsonPath,
|
|
976
|
+
jsonPathValue,
|
|
977
|
+
page,
|
|
978
|
+
size
|
|
979
|
+
},
|
|
980
|
+
{ forbidAlert }
|
|
981
|
+
);
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
metaService2.getNewDashboardListWithIdentity = getNewDashboardListWithIdentity;
|
|
985
|
+
function deleteVersionRecords(_0) {
|
|
986
|
+
return __async$1(this, arguments, function* ({ name, recordIds }, forbidAlert = false) {
|
|
987
|
+
return slsEasyFetch.post(
|
|
988
|
+
"/console/metaRecordAjax/delete.json",
|
|
989
|
+
{
|
|
990
|
+
name,
|
|
991
|
+
recordIds
|
|
992
|
+
},
|
|
993
|
+
{ forbidAlert }
|
|
994
|
+
);
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
metaService2.deleteVersionRecords = deleteVersionRecords;
|
|
998
|
+
metaService2.ckeckPermissionForList = (resourceName) => __async$1(void 0, null, function* () {
|
|
999
|
+
const res = yield slsEasyFetch.get(
|
|
1000
|
+
"/console/metaRecordAjax/checkList.json",
|
|
1001
|
+
{
|
|
1002
|
+
name: resourceName
|
|
1003
|
+
},
|
|
1004
|
+
{ forbidAlert: true }
|
|
1005
|
+
);
|
|
1006
|
+
if (!res.data) {
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
return true;
|
|
1010
|
+
});
|
|
1011
|
+
})(metaService || (metaService = {}));
|
|
1012
|
+
|
|
119
1013
|
var __async = (__this, __arguments, generator) => {
|
|
120
1014
|
return new Promise((resolve, reject) => {
|
|
121
1015
|
var fulfilled = (value) => {
|
|
@@ -136,19 +1030,45 @@ var __async = (__this, __arguments, generator) => {
|
|
|
136
1030
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
137
1031
|
});
|
|
138
1032
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const data = yield response.json();
|
|
145
|
-
return __spreadProps(__spreadValues({}, data != null ? data : {}), {
|
|
146
|
-
response
|
|
1033
|
+
var workSpaceService;
|
|
1034
|
+
((workSpaceService2) => {
|
|
1035
|
+
function getWorkspaceRecord(params) {
|
|
1036
|
+
return __async(this, null, function* () {
|
|
1037
|
+
return slsEasyFetch.get("/console/workspace/list_app.json", params);
|
|
147
1038
|
});
|
|
148
|
-
} else {
|
|
149
|
-
throw new Error(response.statusText);
|
|
150
1039
|
}
|
|
151
|
-
|
|
1040
|
+
workSpaceService2.getWorkspaceRecord = getWorkspaceRecord;
|
|
1041
|
+
function getWorkspacelist(params) {
|
|
1042
|
+
return __async(this, null, function* () {
|
|
1043
|
+
return slsEasyFetch.get("/console/workspace/list.json", params);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
workSpaceService2.getWorkspacelist = getWorkspacelist;
|
|
1047
|
+
function getWorkspaceInfor(params) {
|
|
1048
|
+
return __async(this, null, function* () {
|
|
1049
|
+
return slsEasyFetch.get("/console/workspace/get.json", params);
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
workSpaceService2.getWorkspaceInfor = getWorkspaceInfor;
|
|
1053
|
+
function createInstance(params) {
|
|
1054
|
+
return __async(this, null, function* () {
|
|
1055
|
+
return slsEasyFetch.post("/observability/createInstance.json", params);
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
workSpaceService2.createInstance = createInstance;
|
|
1059
|
+
function updataAppInstance(params) {
|
|
1060
|
+
return __async(this, null, function* () {
|
|
1061
|
+
return slsEasyFetch.post("/console/workspace/update_app.json", params);
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
workSpaceService2.updataAppInstance = updataAppInstance;
|
|
1065
|
+
function getWorkspaceForITOM(params) {
|
|
1066
|
+
return __async(this, null, function* () {
|
|
1067
|
+
return slsEasyFetch.get("/console/workspace/getWorkspaceForITOM.json", params);
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
workSpaceService2.getWorkspaceForITOM = getWorkspaceForITOM;
|
|
1071
|
+
})(workSpaceService || (workSpaceService = {}));
|
|
152
1072
|
|
|
153
|
-
export {
|
|
1073
|
+
export { commonEasyFetch, metaService, obsEasyFetch, showAlertDialog, showAlertDialogWhenNeedLogin, slsEasyFetch, workSpaceService };
|
|
154
1074
|
//# sourceMappingURL=api.es.js.map
|
package/package.json
CHANGED
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
"keywords": [],
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"urijs": "^1.19.1",
|
|
11
|
-
"lodash": "^4.17.21"
|
|
11
|
+
"lodash": "^4.17.21",
|
|
12
|
+
"@alicloud/console-base-error-prompt-proxy": "^1.9.12",
|
|
13
|
+
"@aliyun-obv/i18n": "0.0.44",
|
|
14
|
+
"@aliyun-obv/utils": "0.0.44",
|
|
15
|
+
"@alifd/next": "^1.27.11",
|
|
16
|
+
"styled-components": "^5.2.0"
|
|
12
17
|
},
|
|
13
18
|
"devDependencies": {},
|
|
14
|
-
"version": "0.0.
|
|
19
|
+
"version": "0.0.44"
|
|
15
20
|
}
|