orion-design 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/dist/_commonjsHelpers-BFTU3MAI.js +7 -0
  2. package/dist/bignumber-upqAL281.js +2907 -0
  3. package/dist/dayjs.min-CYqA_arp.js +12 -0
  4. package/dist/error/OrionError.d.ts +3 -0
  5. package/dist/error/OrionError.js +12 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +3 -0
  8. package/dist/print/LodopFuncs.d.ts +1 -0
  9. package/dist/print/LodopFuncs.js +159 -0
  10. package/dist/print/index.d.ts +25 -0
  11. package/dist/print/index.js +230 -0
  12. package/dist/request/ErrorHandlerChain.d.ts +9 -0
  13. package/dist/request/ErrorHandlerChain.js +18 -0
  14. package/dist/request/RequestFilterChain.d.ts +10 -0
  15. package/dist/request/RequestFilterChain.js +18 -0
  16. package/dist/request/ResponseParserChain.d.ts +10 -0
  17. package/dist/request/ResponseParserChain.js +18 -0
  18. package/dist/request/disivion/DateSerializer.d.ts +5 -0
  19. package/dist/request/disivion/DateSerializer.js +61 -0
  20. package/dist/request/disivion/DivisionErrorHandler.d.ts +6 -0
  21. package/dist/request/disivion/DivisionErrorHandler.js +59 -0
  22. package/dist/request/disivion/DivisionResponseParser.d.ts +5 -0
  23. package/dist/request/disivion/DivisionResponseParser.js +23 -0
  24. package/dist/request/disivion/index.d.ts +1 -0
  25. package/dist/request/disivion/index.js +28 -0
  26. package/dist/request/disivion/request.d.ts +21 -0
  27. package/dist/request/disivion/request.js +19345 -0
  28. package/dist/request/error/BizExceptionResponseError.d.ts +7 -0
  29. package/dist/request/error/BizExceptionResponseError.js +17 -0
  30. package/dist/request/error/ExceptionResponseError.d.ts +7 -0
  31. package/dist/request/error/ExceptionResponseError.js +17 -0
  32. package/dist/request/error/ResponseError.d.ts +5 -0
  33. package/dist/request/error/ResponseError.js +14 -0
  34. package/dist/request/error/SessionExceptionResponseError.d.ts +7 -0
  35. package/dist/request/error/SessionExceptionResponseError.js +17 -0
  36. package/dist/request/index.d.ts +1 -0
  37. package/dist/request/index.js +28 -0
  38. package/dist/request/postByOpenNewWindow.d.ts +1 -0
  39. package/dist/request/postByOpenNewWindow.js +41 -0
  40. package/dist/utils/DateUtil.d.ts +10 -0
  41. package/dist/utils/DateUtil.js +58 -0
  42. package/dist/utils/NumberUtil.d.ts +4 -0
  43. package/dist/utils/NumberUtil.js +10 -0
  44. package/dist/utils/cloneDeep.d.ts +1 -0
  45. package/dist/utils/cloneDeep.js +2255 -0
  46. package/dist/utils/delay.d.ts +1 -0
  47. package/dist/utils/delay.js +5 -0
  48. package/dist/utils/index.d.ts +6 -0
  49. package/dist/utils/index.js +10 -0
  50. package/dist/utils/md5.d.ts +1 -0
  51. package/dist/utils/md5.js +326 -0
  52. package/dist/utils/uuid.d.ts +1 -0
  53. package/dist/utils/uuid.js +63 -0
  54. package/package.json +45 -0
@@ -0,0 +1,59 @@
1
+ import ResponseError from '../error/ResponseError.js';
2
+ import ExceptionResponseError from '../error/ExceptionResponseError.js';
3
+ import BizExceptionResponseError from '../error/BizExceptionResponseError.js';
4
+ import SessionExceptionResponseError from '../error/SessionExceptionResponseError.js';
5
+
6
+ // import { Modal } from 'dw-neit-antd'
7
+ // import SobekThrone from '../../throne/SobekThrone'
8
+ // import SobekMsgBox from '../../msgbox/SobekMsgBox'
9
+ function readBlob(blob) {
10
+ return new Promise((resolve) => {
11
+ const reader = new FileReader();
12
+ reader.addEventListener('loadend', () => {
13
+ resolve(reader.result);
14
+ });
15
+ reader.readAsText(blob);
16
+ });
17
+ }
18
+ class DivisionErrorHandler {
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
+ }
32
+ else {
33
+ // 普通请求的异常JSON
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
+ }
54
+ }
55
+ throw error;
56
+ }
57
+ }
58
+
59
+ export { DivisionErrorHandler as default, readBlob };
@@ -0,0 +1,5 @@
1
+ import type { AxiosResponse } from 'axios';
2
+ import type ResponseParserChain from '../ResponseParserChain';
3
+ export default class DivisionResponseParser {
4
+ parse(response: AxiosResponse, chain: ResponseParserChain): AxiosResponse<any, any>;
5
+ }
@@ -0,0 +1,23 @@
1
+ class DivisionResponseParser {
2
+ parse(response, chain) {
3
+ // server 端不响应内容
4
+ const contentType = response.headers['content-type'];
5
+ if (!contentType) {
6
+ return chain.doParse(response, chain);
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 } = window.ActiveXObject || 'ActiveXObject' in window ? (typeof response.data === 'string' ? JSON.parse(response.data) : response.data) : response.data;
14
+ if (success === true) {
15
+ return chain.doParse(data, chain);
16
+ }
17
+ else {
18
+ throw new Error(errortext);
19
+ }
20
+ }
21
+ }
22
+
23
+ export { DivisionResponseParser as default };
@@ -0,0 +1 @@
1
+ export { default } from './request';
@@ -0,0 +1,28 @@
1
+ export { default } from './request.js';
2
+ import '../../_commonjsHelpers-BFTU3MAI.js';
3
+ import 'util';
4
+ import 'stream';
5
+ import 'path';
6
+ import 'http';
7
+ import 'https';
8
+ import 'url';
9
+ import 'fs';
10
+ import 'assert';
11
+ import 'tty';
12
+ import 'os';
13
+ import 'zlib';
14
+ import 'events';
15
+ import '../../dayjs.min-CYqA_arp.js';
16
+ import '../../utils/md5.js';
17
+ import '../../bignumber-upqAL281.js';
18
+ import '../ResponseParserChain.js';
19
+ import '../ErrorHandlerChain.js';
20
+ import '../RequestFilterChain.js';
21
+ import './DateSerializer.js';
22
+ import './DivisionResponseParser.js';
23
+ import './DivisionErrorHandler.js';
24
+ import '../error/ResponseError.js';
25
+ import '../error/ExceptionResponseError.js';
26
+ import '../error/BizExceptionResponseError.js';
27
+ import '../error/SessionExceptionResponseError.js';
28
+ import '../../utils/cloneDeep.js';
@@ -0,0 +1,21 @@
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;