orion-design 0.1.1 → 0.1.2
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/components/Flex/Col.d.ts +25 -0
- package/dist/components/Flex/Item.d.ts +25 -0
- package/dist/components/Flex/Row.d.ts +25 -0
- package/dist/components/Flex/index.d.ts +10 -0
- package/dist/components/Flex/index.js +151 -0
- package/dist/components/Modal/Modal.d.ts +2 -0
- package/dist/components/Space/index.d.ts +76 -0
- package/dist/components/_util/classNames.d.ts +2 -0
- package/dist/components/_util/classNames.js +31 -0
- package/dist/components/_util/isValid.d.ts +2 -0
- package/dist/components/_util/isValid.js +5 -0
- package/dist/components/_util/props-util/index.d.ts +6 -0
- package/dist/components/_util/props-util/index.js +53 -0
- package/dist/components/_util/props-util/initDefaultProps.d.ts +6 -0
- package/dist/components/_util/props-util/initDefaultProps.js +25 -0
- package/dist/components/_util/type.d.ts +62 -0
- package/dist/components/_util/type.js +66 -0
- package/dist/components/_util/util.d.ts +18 -0
- package/dist/components/_util/util.js +83 -0
- package/dist/components/_util/vue-types/index.d.ts +12 -0
- package/dist/components/_util/vue-types/index.js +473 -0
- package/dist/components/components.d.ts +4 -0
- package/dist/components/components.js +10 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +23 -0
- package/dist/components-O4L3qYfM.js +61 -0
- package/dist/error/OrionError.js +9 -7
- package/dist/index.css +44 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/print/LodopFuncs.js +109 -140
- package/dist/print/index.js +204 -199
- package/dist/request/ErrorHandlerChain.js +13 -13
- package/dist/request/RequestFilterChain.js +13 -13
- package/dist/request/ResponseParserChain.js +13 -13
- package/dist/request/disivion/DateSerializer.js +43 -51
- package/dist/request/disivion/DivisionErrorHandler.js +42 -42
- package/dist/request/disivion/DivisionResponseParser.js +22 -18
- package/dist/request/disivion/index.d.ts +21 -1
- package/dist/request/disivion/index.js +174 -153
- package/dist/request/error/BizExceptionResponseError.js +10 -10
- package/dist/request/error/ExceptionResponseError.js +10 -10
- package/dist/request/error/ResponseError.js +11 -9
- package/dist/request/error/SessionExceptionResponseError.js +10 -10
- package/dist/request/index.d.ts +3 -0
- package/dist/request/index.js +3 -2
- package/dist/style/index.d.ts +3 -0
- package/dist/style/index.js +1 -0
- package/dist/utils/DateUtil.js +46 -50
- package/dist/utils/NumberUtil.js +5 -5
- package/dist/utils/cloneDeep.js +1 -2255
- package/dist/utils/delay.js +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/md5.js +215 -271
- package/dist/version/index.d.ts +2 -0
- package/dist/version/index.js +6 -0
- package/dist/version/version.d.ts +2 -0
- package/dist/version/version.js +3 -0
- package/global.d.ts +9 -0
- package/package.json +25 -9
- package/dist/bignumber-upqAL281.js +0 -2907
- package/dist/request/disivion/request.d.ts +0 -21
- package/dist/request/disivion/request.js +0 -476
- package/dist/request/postByOpenNewWindow.d.ts +0 -1
- package/dist/request/postByOpenNewWindow.js +0 -41
@@ -7,53 +7,53 @@ import SessionExceptionResponseError from '../error/SessionExceptionResponseErro
|
|
7
7
|
// import SobekThrone from '../../throne/SobekThrone'
|
8
8
|
// import SobekMsgBox from '../../msgbox/SobekMsgBox'
|
9
9
|
function readBlob(blob) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
});
|
15
|
-
reader.readAsText(blob);
|
10
|
+
return new Promise(resolve => {
|
11
|
+
const reader = new FileReader();
|
12
|
+
reader.addEventListener('loadend', () => {
|
13
|
+
resolve(reader.result);
|
16
14
|
});
|
15
|
+
reader.readAsText(blob);
|
16
|
+
});
|
17
17
|
}
|
18
18
|
class DivisionErrorHandler {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
jsonData = rawData;
|
35
|
-
}
|
36
|
-
const { success, errorcode, data, errortext } = jsonData;
|
37
|
-
if (errorcode === '-1') {
|
38
|
-
throw new ExceptionResponseError(errortext, error, response, jsonData);
|
39
|
-
}
|
40
|
-
else if (errorcode === '-2') {
|
41
|
-
throw new BizExceptionResponseError(errortext, error, response, jsonData);
|
42
|
-
}
|
43
|
-
else if (errorcode === '-3') {
|
44
|
-
throw new SessionExceptionResponseError(errortext, error, response, jsonData);
|
45
|
-
}
|
46
|
-
else {
|
47
|
-
throw new ExceptionResponseError(errortext, error, response, jsonData);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
else {
|
51
|
-
let errortext = "'" + response.config.url + "' " + response.status + ' ' + response.statusText;
|
52
|
-
throw new ExceptionResponseError(errortext, error, response, null);
|
53
|
-
}
|
19
|
+
constructor() {}
|
20
|
+
async handle(error, chain) {
|
21
|
+
if (error instanceof ResponseError) {
|
22
|
+
const response = error.response;
|
23
|
+
if (response.status == 200) {
|
24
|
+
const rawData = response.data;
|
25
|
+
let jsonData;
|
26
|
+
if (rawData instanceof Blob) {
|
27
|
+
// 文件下载抛异常JSON,在Blob里面
|
28
|
+
jsonData = await readBlob(rawData);
|
29
|
+
jsonData = JSON.parse(jsonData);
|
30
|
+
jsonData = JSON.parse(jsonData);
|
31
|
+
} else {
|
32
|
+
// 普通请求的异常JSON
|
33
|
+
jsonData = rawData;
|
54
34
|
}
|
55
|
-
|
35
|
+
const {
|
36
|
+
success,
|
37
|
+
errorcode,
|
38
|
+
data,
|
39
|
+
errortext
|
40
|
+
} = jsonData;
|
41
|
+
if (errorcode === '-1') {
|
42
|
+
throw new ExceptionResponseError(errortext, error, response, jsonData);
|
43
|
+
} else if (errorcode === '-2') {
|
44
|
+
throw new BizExceptionResponseError(errortext, error, response, jsonData);
|
45
|
+
} else if (errorcode === '-3') {
|
46
|
+
throw new SessionExceptionResponseError(errortext, error, response, jsonData);
|
47
|
+
} else {
|
48
|
+
throw new ExceptionResponseError(errortext, error, response, jsonData);
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
let errortext = "'" + response.config.url + "' " + response.status + ' ' + response.statusText;
|
52
|
+
throw new ExceptionResponseError(errortext, error, response, null);
|
53
|
+
}
|
56
54
|
}
|
55
|
+
throw error;
|
56
|
+
}
|
57
57
|
}
|
58
58
|
|
59
59
|
export { DivisionErrorHandler as default, readBlob };
|
@@ -1,23 +1,27 @@
|
|
1
1
|
class DivisionResponseParser {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
}
|
8
|
-
// server 端响应的不是 application/json 协议
|
9
|
-
if (contentType.indexOf('application/json') === -1) {
|
10
|
-
return chain.doParse(response, chain);
|
11
|
-
}
|
12
|
-
// data为string时,兼容ie
|
13
|
-
const { success, errorcode, data, errortext } = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
|
14
|
-
if (success === true) {
|
15
|
-
return chain.doParse(data, chain);
|
16
|
-
}
|
17
|
-
else {
|
18
|
-
throw new Error(errortext);
|
19
|
-
}
|
2
|
+
parse(response, chain) {
|
3
|
+
// server 端不响应内容
|
4
|
+
const contentType = response.headers['content-type'];
|
5
|
+
if (!contentType) {
|
6
|
+
return chain.doParse(response, chain);
|
20
7
|
}
|
8
|
+
// server 端响应的不是 application/json 协议
|
9
|
+
if (contentType.indexOf('application/json') === -1) {
|
10
|
+
return chain.doParse(response, chain);
|
11
|
+
}
|
12
|
+
// data为string时,兼容ie
|
13
|
+
const {
|
14
|
+
success,
|
15
|
+
errorcode,
|
16
|
+
data,
|
17
|
+
errortext
|
18
|
+
} = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
|
19
|
+
if (success === true) {
|
20
|
+
return chain.doParse(data, chain);
|
21
|
+
} else {
|
22
|
+
throw new Error(errortext);
|
23
|
+
}
|
24
|
+
}
|
21
25
|
}
|
22
26
|
|
23
27
|
export { DivisionResponseParser as default };
|
@@ -1 +1,21 @@
|
|
1
|
-
|
1
|
+
import { type ResponseParser } from '../ResponseParserChain';
|
2
|
+
import { type ErrorHandler } from '../ErrorHandlerChain';
|
3
|
+
import { type RequestFilter } from '../RequestFilterChain';
|
4
|
+
export type RequestParams = Record<string, unknown>;
|
5
|
+
export interface RequestOptionsI {
|
6
|
+
loading?: boolean;
|
7
|
+
mask?: boolean;
|
8
|
+
timeout?: number;
|
9
|
+
}
|
10
|
+
declare function request<T>(url: string, data?: RequestParams | FormData, options?: RequestOptionsI): Promise<T>;
|
11
|
+
declare namespace request {
|
12
|
+
var download: (url: string, data?: RequestParams, options?: RequestOptionsI) => Promise<void>;
|
13
|
+
var upload: (url: string, params: RequestParams, options: RequestOptionsI) => Promise<unknown>;
|
14
|
+
var setBaseUrl: (pBaseUrl: string) => void;
|
15
|
+
var setRequestTimeout: (pTimeout: number) => void;
|
16
|
+
var setRequestHeaders: (pRequestHeaders: () => Record<string, string | null>) => void;
|
17
|
+
var setRequestFilters: (...filters: RequestFilter[]) => void;
|
18
|
+
var setResponseParsers: (...parsers: ResponseParser[]) => void;
|
19
|
+
var setErrorHandlers: (...handlers: ErrorHandler[]) => void;
|
20
|
+
}
|
21
|
+
export default request;
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import axios from 'axios';
|
2
|
+
import { cloneDeep } from 'lodash-es';
|
2
3
|
import 'dayjs';
|
3
4
|
import '../../utils/md5.js';
|
4
|
-
import '
|
5
|
+
import 'decimal.js';
|
5
6
|
import ResponseParserChain from '../ResponseParserChain.js';
|
6
7
|
import ErrorHandlerChain from '../ErrorHandlerChain.js';
|
7
8
|
import RequestFilterChain from '../RequestFilterChain.js';
|
8
9
|
import DateSerializer from './DateSerializer.js';
|
9
10
|
import DivisionResponseParser from './DivisionResponseParser.js';
|
10
11
|
import DivisionErrorHandler from './DivisionErrorHandler.js';
|
12
|
+
import { ElLoading } from 'element-plus';
|
11
13
|
import ResponseError from '../error/ResponseError.js';
|
12
|
-
import cloneDeep from '../../utils/cloneDeep.js';
|
13
14
|
import '../error/ExceptionResponseError.js';
|
14
15
|
import '../error/BizExceptionResponseError.js';
|
15
16
|
import '../error/SessionExceptionResponseError.js';
|
@@ -290,187 +291,207 @@ const gBase64 = {
|
|
290
291
|
let gRequestHeaders = () => ({});
|
291
292
|
let gResponseParsers = [new DivisionResponseParser()];
|
292
293
|
let gErrorHandlers = [new DivisionErrorHandler()];
|
293
|
-
let gRequestFilters = [
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
},
|
307
|
-
},
|
308
|
-
];
|
294
|
+
let gRequestFilters = [{
|
295
|
+
doFilter: (request, chain) => {
|
296
|
+
const headers = gRequestHeaders();
|
297
|
+
Object.keys(headers).forEach(function (key) {
|
298
|
+
request.headers[key] = headers[key];
|
299
|
+
});
|
300
|
+
chain.doFilter(request, chain);
|
301
|
+
}
|
302
|
+
}, {
|
303
|
+
doFilter: request => {
|
304
|
+
new DateSerializer('YYYYMMDDHHmmss').serialize(request.data);
|
305
|
+
}
|
306
|
+
}];
|
309
307
|
//////////////////////////////////// GLOBAL VARS
|
310
308
|
let BASE_URL = '/';
|
311
309
|
let REQUEST_TIMEOUT = 1000 * 30;
|
312
310
|
//////////////////////////////////// AXIOS
|
313
311
|
const g_AxiosInstance = axios.create();
|
314
312
|
g_AxiosInstance.interceptors.request.use(function (config) {
|
315
|
-
|
316
|
-
|
317
|
-
|
313
|
+
const chain = new RequestFilterChain(gRequestFilters);
|
314
|
+
chain.doFilter(config, chain);
|
315
|
+
return config;
|
318
316
|
});
|
319
317
|
g_AxiosInstance.interceptors.response.use(function (response) {
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
}
|
318
|
+
try {
|
319
|
+
const chain = new ResponseParserChain(gResponseParsers);
|
320
|
+
return chain.doParse(response, chain);
|
321
|
+
} catch (e) {
|
322
|
+
throw new ResponseError(e.message, {
|
323
|
+
cause: e
|
324
|
+
}, response);
|
325
|
+
}
|
327
326
|
});
|
328
|
-
function request(url, data = {}, options = {
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
...options,
|
344
|
-
})
|
345
|
-
.then((data) => {
|
346
|
-
return data;
|
347
|
-
})
|
348
|
-
.catch(function (error) {
|
349
|
-
const chain = new ErrorHandlerChain(gErrorHandlers);
|
350
|
-
return chain.handle(error, chain);
|
327
|
+
function request(url, data = {}, options = {
|
328
|
+
loading: true,
|
329
|
+
mask: false,
|
330
|
+
timeout: REQUEST_TIMEOUT
|
331
|
+
}) {
|
332
|
+
let newData = data;
|
333
|
+
if (!(data instanceof FormData)) {
|
334
|
+
newData = cloneDeep(data);
|
335
|
+
}
|
336
|
+
// loading
|
337
|
+
let loading;
|
338
|
+
if (options.loading === true) {
|
339
|
+
loading = ElLoading.service({
|
340
|
+
fullscreen: true,
|
341
|
+
background: 'transparent'
|
351
342
|
});
|
343
|
+
}
|
344
|
+
return g_AxiosInstance.request({
|
345
|
+
baseURL: BASE_URL,
|
346
|
+
method: 'POST',
|
347
|
+
timeout: REQUEST_TIMEOUT,
|
348
|
+
withCredentials: true,
|
349
|
+
url,
|
350
|
+
data: newData,
|
351
|
+
responseType: 'json',
|
352
|
+
...options
|
353
|
+
}).then(data => {
|
354
|
+
if (loading) {
|
355
|
+
loading.close();
|
356
|
+
}
|
357
|
+
return data;
|
358
|
+
}).catch(function (error) {
|
359
|
+
if (loading) {
|
360
|
+
loading.close();
|
361
|
+
}
|
362
|
+
const chain = new ErrorHandlerChain(gErrorHandlers);
|
363
|
+
return chain.handle(error, chain);
|
364
|
+
});
|
352
365
|
}
|
353
|
-
function download(url, data = {}, options = {
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
responseType: 'blob',
|
364
|
-
...options,
|
365
|
-
})
|
366
|
-
.then((data) => {
|
367
|
-
return data;
|
368
|
-
})
|
369
|
-
.then((response) => {
|
370
|
-
const contentDisposition = response.headers['content-disposition'];
|
371
|
-
const blob = response.data;
|
372
|
-
const base64FileName = contentDisposition.match(/attachment; filename=\"(.*?)\"/)[1];
|
373
|
-
const decodedFileName = gBase64.decode(base64FileName);
|
374
|
-
// for IE
|
375
|
-
//@ts-ignore
|
376
|
-
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
377
|
-
//@ts-ignore
|
378
|
-
window.navigator.msSaveOrOpenBlob(blob, decodedFileName);
|
379
|
-
}
|
380
|
-
else {
|
381
|
-
const a = document.createElement('a');
|
382
|
-
const url = URL.createObjectURL(blob);
|
383
|
-
a.href = url;
|
384
|
-
a.download = decodedFileName;
|
385
|
-
document.body.appendChild(a);
|
386
|
-
a.click();
|
387
|
-
document.body.removeChild(a);
|
388
|
-
URL.revokeObjectURL(url);
|
389
|
-
}
|
390
|
-
})
|
391
|
-
.catch(function (error) {
|
392
|
-
const chain = new ErrorHandlerChain(gErrorHandlers);
|
393
|
-
return chain.handle(error, chain);
|
366
|
+
function download(url, data = {}, options = {
|
367
|
+
loading: true,
|
368
|
+
mask: false,
|
369
|
+
timeout: REQUEST_TIMEOUT
|
370
|
+
}) {
|
371
|
+
let loading;
|
372
|
+
if (options.loading === true) {
|
373
|
+
loading = ElLoading.service({
|
374
|
+
fullscreen: true,
|
375
|
+
background: 'transparent'
|
394
376
|
});
|
377
|
+
}
|
378
|
+
return g_AxiosInstance.request({
|
379
|
+
baseURL: BASE_URL,
|
380
|
+
method: 'POST',
|
381
|
+
timeout: REQUEST_TIMEOUT,
|
382
|
+
withCredentials: true,
|
383
|
+
url,
|
384
|
+
data,
|
385
|
+
responseType: 'blob',
|
386
|
+
...options
|
387
|
+
}).then(data => {
|
388
|
+
if (loading) {
|
389
|
+
loading.close();
|
390
|
+
}
|
391
|
+
return data;
|
392
|
+
}).then(response => {
|
393
|
+
const contentDisposition = response.headers['content-disposition'];
|
394
|
+
const blob = response.data;
|
395
|
+
const base64FileName = contentDisposition.match(/attachment; filename=\"(.*?)\"/)[1];
|
396
|
+
const decodedFileName = gBase64.decode(base64FileName);
|
397
|
+
// for IE
|
398
|
+
//@ts-ignore
|
399
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
400
|
+
//@ts-ignore
|
401
|
+
window.navigator.msSaveOrOpenBlob(blob, decodedFileName);
|
402
|
+
} else {
|
403
|
+
const a = document.createElement('a');
|
404
|
+
const url = URL.createObjectURL(blob);
|
405
|
+
a.href = url;
|
406
|
+
a.download = decodedFileName;
|
407
|
+
document.body.appendChild(a);
|
408
|
+
a.click();
|
409
|
+
document.body.removeChild(a);
|
410
|
+
URL.revokeObjectURL(url);
|
411
|
+
}
|
412
|
+
}).catch(function (error) {
|
413
|
+
if (loading) {
|
414
|
+
loading.close();
|
415
|
+
}
|
416
|
+
const chain = new ErrorHandlerChain(gErrorHandlers);
|
417
|
+
return chain.handle(error, chain);
|
418
|
+
});
|
395
419
|
}
|
396
420
|
function upload(url, params, options) {
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
// formdata.append(key, JSON.stringify(itemValue));
|
422
|
-
normalParams[key] = itemValue;
|
423
|
-
}
|
424
|
-
}
|
425
|
-
else {
|
426
|
-
// formdata.append(key, itemValue);
|
427
|
-
normalParams[key] = itemValue;
|
428
|
-
}
|
421
|
+
const formdata = new FormData();
|
422
|
+
if (params) {
|
423
|
+
const keys = Object.keys(params);
|
424
|
+
const normalParams = {};
|
425
|
+
for (let i = 0; i < keys.length; i++) {
|
426
|
+
const key = keys[i];
|
427
|
+
const itemValue = params[key];
|
428
|
+
if (itemValue instanceof File) {
|
429
|
+
formdata.append(key, itemValue);
|
430
|
+
} else if (itemValue instanceof Array) {
|
431
|
+
let isFile = false;
|
432
|
+
for (let j = 0; j < itemValue.length; j++) {
|
433
|
+
if (itemValue[j] instanceof File) {
|
434
|
+
isFile = true;
|
435
|
+
break;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
if (isFile) {
|
439
|
+
for (let j = 0; j < itemValue.length; j++) {
|
440
|
+
formdata.append(key, itemValue[j]);
|
441
|
+
}
|
442
|
+
} else {
|
443
|
+
// formdata.append(key, JSON.stringify(itemValue));
|
444
|
+
normalParams[key] = itemValue;
|
429
445
|
}
|
430
|
-
|
446
|
+
} else {
|
447
|
+
// formdata.append(key, itemValue);
|
448
|
+
normalParams[key] = itemValue;
|
449
|
+
}
|
431
450
|
}
|
432
|
-
|
451
|
+
formdata.append('ibayJson', JSON.stringify(normalParams));
|
452
|
+
}
|
453
|
+
return request(url, formdata, options);
|
433
454
|
}
|
434
455
|
//////////////////////////////////// Exports
|
435
456
|
// api
|
436
457
|
request.download = download;
|
437
458
|
request.upload = upload;
|
438
459
|
// setters
|
439
|
-
request.setBaseUrl =
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
460
|
+
request.setBaseUrl = pBaseUrl => {
|
461
|
+
if (!pBaseUrl) {
|
462
|
+
throw new Error(`pBaseUrl is null!`);
|
463
|
+
}
|
464
|
+
BASE_URL = pBaseUrl;
|
444
465
|
};
|
445
|
-
request.setRequestTimeout =
|
446
|
-
|
466
|
+
request.setRequestTimeout = pTimeout => {
|
467
|
+
REQUEST_TIMEOUT = pTimeout;
|
447
468
|
};
|
448
|
-
request.setRequestHeaders =
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
469
|
+
request.setRequestHeaders = pRequestHeaders => {
|
470
|
+
if (!pRequestHeaders) {
|
471
|
+
throw new Error(`pRequestHeaders is null!`);
|
472
|
+
}
|
473
|
+
if (!(pRequestHeaders instanceof Function)) {
|
474
|
+
throw new Error(`pRequestHeaders is not a function!`);
|
475
|
+
}
|
476
|
+
gRequestHeaders = pRequestHeaders;
|
456
477
|
};
|
457
478
|
request.setRequestFilters = (...filters) => {
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
479
|
+
if (filters == null) {
|
480
|
+
throw new Error(`filters is null!`);
|
481
|
+
}
|
482
|
+
gRequestFilters = filters;
|
462
483
|
};
|
463
484
|
request.setResponseParsers = (...parsers) => {
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
485
|
+
if (parsers == null) {
|
486
|
+
throw new Error(`parsers is null!`);
|
487
|
+
}
|
488
|
+
gResponseParsers = parsers;
|
468
489
|
};
|
469
490
|
request.setErrorHandlers = (...handlers) => {
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
491
|
+
if (handlers == null) {
|
492
|
+
throw new Error(`handlers should not null!`);
|
493
|
+
}
|
494
|
+
gErrorHandlers = handlers;
|
474
495
|
};
|
475
496
|
|
476
497
|
export { request as default };
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import ResponseError from './ResponseError.js';
|
2
2
|
|
3
3
|
class BizExceptionResponseError extends ResponseError {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
this.name = 'BizExceptionResponseError';
|
11
|
-
// CustomData
|
12
|
-
this.response = response;
|
13
|
-
this.reponseData = reponseData;
|
4
|
+
constructor(message, cause, response, reponseData) {
|
5
|
+
super(message, cause, response);
|
6
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
7
|
+
if (Error.captureStackTrace) {
|
8
|
+
Error.captureStackTrace(this, BizExceptionResponseError);
|
14
9
|
}
|
10
|
+
this.name = 'BizExceptionResponseError';
|
11
|
+
// CustomData
|
12
|
+
this.response = response;
|
13
|
+
this.reponseData = reponseData;
|
14
|
+
}
|
15
15
|
}
|
16
16
|
|
17
17
|
export { BizExceptionResponseError as default };
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import ResponseError from './ResponseError.js';
|
2
2
|
|
3
3
|
class ExceptionResponseError extends ResponseError {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
this.name = 'ExceptionResponseError';
|
11
|
-
// CustomData
|
12
|
-
this.response = response;
|
13
|
-
this.reponseData = reponseData;
|
4
|
+
constructor(message, cause, response, reponseData) {
|
5
|
+
super(message, cause, response);
|
6
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
7
|
+
if (Error.captureStackTrace) {
|
8
|
+
Error.captureStackTrace(this, ExceptionResponseError);
|
14
9
|
}
|
10
|
+
this.name = 'ExceptionResponseError';
|
11
|
+
// CustomData
|
12
|
+
this.response = response;
|
13
|
+
this.reponseData = reponseData;
|
14
|
+
}
|
15
15
|
}
|
16
16
|
|
17
17
|
export { ExceptionResponseError as default };
|
@@ -1,14 +1,16 @@
|
|
1
1
|
class ResponseError extends Error {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
// CustomData
|
10
|
-
this.response = reponse;
|
2
|
+
constructor(message, options, reponse) {
|
3
|
+
super(message, {
|
4
|
+
cause: options.cause
|
5
|
+
});
|
6
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
7
|
+
if (Error.captureStackTrace) {
|
8
|
+
Error.captureStackTrace(this, ResponseError);
|
11
9
|
}
|
10
|
+
this.name = 'ResponseError';
|
11
|
+
// CustomData
|
12
|
+
this.response = reponse;
|
13
|
+
}
|
12
14
|
}
|
13
15
|
|
14
16
|
export { ResponseError as default };
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import ResponseError from './ResponseError.js';
|
2
2
|
|
3
3
|
class SessionExceptionResponseError extends ResponseError {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
this.name = 'SessionExceptionResponseError';
|
11
|
-
// CustomData
|
12
|
-
this.response = response;
|
13
|
-
this.reponseData = reponseData;
|
4
|
+
constructor(message, cause, response, reponseData) {
|
5
|
+
super(message, cause, response);
|
6
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
7
|
+
if (Error.captureStackTrace) {
|
8
|
+
Error.captureStackTrace(this, SessionExceptionResponseError);
|
14
9
|
}
|
10
|
+
this.name = 'SessionExceptionResponseError';
|
11
|
+
// CustomData
|
12
|
+
this.response = response;
|
13
|
+
this.reponseData = reponseData;
|
14
|
+
}
|
15
15
|
}
|
16
16
|
|
17
17
|
export { SessionExceptionResponseError as default };
|
package/dist/request/index.d.ts
CHANGED
@@ -1 +1,4 @@
|
|
1
1
|
export { default as divisionRequest } from './disivion';
|
2
|
+
export { default as BizExceptionResponseError } from './error/BizExceptionResponseError';
|
3
|
+
export { default as SessionExceptionResponseError } from './error/SessionExceptionResponseError';
|
4
|
+
export { default as ExceptionResponseError } from './error/ExceptionResponseError';
|