@gct-paas/api 0.1.0-dev.2 → 0.1.0-dev.3
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/gct-api.esm.min.js +25 -0
- package/dist/gct-api.system.min.js +25 -0
- package/es/apaas/service/api-config.mjs +676 -20
- package/es/apaas/service/apis/api.service.d.ts +10 -0
- package/es/apaas/service/apis/app-granted-user.service.d.ts +1 -0
- package/es/apaas/service/apis/audit-log.service.d.ts +2 -5
- package/es/apaas/service/apis/category.service.d.ts +0 -2
- package/es/apaas/service/apis/control-config.service.d.ts +4 -0
- package/es/apaas/service/apis/designer-common.service.d.ts +4 -0
- package/es/apaas/service/apis/dhr.service.d.ts +46 -0
- package/es/apaas/service/apis/doc-outline.service.d.ts +1 -1
- package/es/apaas/service/apis/document.service.d.ts +4 -0
- package/es/apaas/service/apis/edhr-category.service.d.ts +57 -0
- package/es/apaas/service/apis/edhr-circulationFormRelateModel.service.d.ts +60 -0
- package/es/apaas/service/apis/edhr-instance.service.d.ts +7 -0
- package/es/apaas/service/apis/edhr-tmpl.service.d.ts +5 -2
- package/es/apaas/service/apis/file-resource.service.d.ts +1 -0
- package/es/apaas/service/apis/file.service.d.ts +10 -0
- package/es/apaas/service/apis/form.service.d.ts +41 -0
- package/es/apaas/service/apis/label.service.d.ts +41 -1
- package/es/apaas/service/apis/message-record.service.d.ts +2 -0
- package/es/apaas/service/apis/model-meta.service.d.ts +25 -0
- package/es/apaas/service/apis/model-permission-relation.service.d.ts +50 -0
- package/es/apaas/service/apis/online-form-category.service.d.ts +57 -0
- package/es/apaas/service/apis/online-form-instance.service.d.ts +75 -6
- package/es/apaas/service/apis/online-form-tmpl.service.d.ts +6 -1
- package/es/apaas/service/apis/online-form.service.d.ts +0 -5
- package/es/apaas/service/apis/online-user-summary.service.d.ts +50 -0
- package/es/apaas/service/apis/online.service.d.ts +15 -1
- package/es/apaas/service/apis/pad-page.service.d.ts +70 -0
- package/es/apaas/service/apis/page-designer-log.service.d.ts +1 -1
- package/es/apaas/service/apis/pm-process-definition.service.d.ts +1 -0
- package/es/apaas/service/apis/print.service.d.ts +5 -0
- package/es/apaas/service/apis/process-definition-version.service.d.ts +8 -0
- package/es/apaas/service/apis/process-path.service.d.ts +8 -0
- package/es/apaas/service/apis/process-task-done.service.d.ts +10 -0
- package/es/apaas/service/apis/process-task-todo.service.d.ts +20 -0
- package/es/apaas/service/apis/product-release.service.d.ts +9 -0
- package/es/apaas/service/apis/report-data-set.service.d.ts +10 -0
- package/es/apaas/service/apis/sandbox-config.service.d.ts +74 -0
- package/es/apaas/service/apis/ss.service.d.ts +12 -0
- package/es/apaas/service/apis/trace-log.service.d.ts +1 -0
- package/es/apaas/service/entities.d.ts +9796 -6316
- package/es/apaas/service/index.d.ts +18 -0
- package/es/index.d.ts +1 -0
- package/es/index.mjs +1 -0
- package/es/ipaas/service/api-config.mjs +21 -0
- package/es/ipaas/service/apis/camel.service.d.ts +8 -0
- package/es/ipaas/service/apis/flow.service.d.ts +10 -1
- package/es/ipaas/service/entities.d.ts +27 -1
- package/es/platform/service/api-config.mjs +320 -16
- package/es/platform/service/apis/api.service.d.ts +63 -30
- package/es/platform/service/apis/app-member.service.d.ts +0 -4
- package/es/platform/service/apis/bi-app.service.d.ts +6 -0
- package/es/platform/service/apis/database.service.d.ts +24 -0
- package/es/platform/service/apis/dataset.service.d.ts +19 -0
- package/es/platform/service/apis/device-interconnection-param.service.d.ts +58 -0
- package/es/platform/service/apis/device-interconnection.service.d.ts +63 -0
- package/es/platform/service/apis/device-param-ref.service.d.ts +25 -0
- package/es/platform/service/apis/file-task.service.d.ts +1 -0
- package/es/platform/service/apis/file.service.d.ts +4 -0
- package/es/platform/service/apis/license.service.d.ts +8 -0
- package/es/platform/service/apis/login.service.d.ts +1 -0
- package/es/platform/service/apis/org.service.d.ts +1 -0
- package/es/platform/service/apis/plat.service.d.ts +17 -0
- package/es/platform/service/apis/seal-management.service.d.ts +1 -1
- package/es/platform/service/apis/tenant.service.d.ts +1 -0
- package/es/platform/service/entities.d.ts +768 -72
- package/es/platform/service/index.d.ts +8 -0
- package/es/service/api-manage.d.ts +26 -0
- package/es/service/api-manage.mjs +29 -0
- package/es/service/api-service.d.ts +96 -0
- package/es/service/api-service.interface.d.ts +159 -0
- package/es/service/api-service.interface.mjs +0 -0
- package/es/service/api-service.mjs +169 -0
- package/es/service/http.enum.d.ts +76 -0
- package/es/service/http.enum.mjs +60 -0
- package/es/service/http.util.d.ts +113 -0
- package/es/service/http.util.mjs +155 -0
- package/es/service/index.d.ts +8 -0
- package/es/service/index.mjs +14 -0
- package/es/types/index.d.ts +2 -0
- package/es/utils/index.d.ts +10 -0
- package/es/utils/index.mjs +14 -0
- package/lib/apaas/service/api-config.cjs +566 -14
- package/lib/apaas/service/apis/api.service.d.ts +10 -0
- package/lib/apaas/service/apis/app-granted-user.service.d.ts +1 -0
- package/lib/apaas/service/apis/audit-log.service.d.ts +2 -5
- package/lib/apaas/service/apis/category.service.d.ts +0 -2
- package/lib/apaas/service/apis/control-config.service.d.ts +4 -0
- package/lib/apaas/service/apis/designer-common.service.d.ts +4 -0
- package/lib/apaas/service/apis/dhr.service.d.ts +46 -0
- package/lib/apaas/service/apis/doc-outline.service.d.ts +1 -1
- package/lib/apaas/service/apis/document.service.d.ts +4 -0
- package/lib/apaas/service/apis/edhr-category.service.d.ts +57 -0
- package/lib/apaas/service/apis/edhr-circulationFormRelateModel.service.d.ts +60 -0
- package/lib/apaas/service/apis/edhr-instance.service.d.ts +7 -0
- package/lib/apaas/service/apis/edhr-tmpl.service.d.ts +5 -2
- package/lib/apaas/service/apis/file-resource.service.d.ts +1 -0
- package/lib/apaas/service/apis/file.service.d.ts +10 -0
- package/lib/apaas/service/apis/form.service.d.ts +41 -0
- package/lib/apaas/service/apis/label.service.d.ts +41 -1
- package/lib/apaas/service/apis/message-record.service.d.ts +2 -0
- package/lib/apaas/service/apis/model-meta.service.d.ts +25 -0
- package/lib/apaas/service/apis/model-permission-relation.service.d.ts +50 -0
- package/lib/apaas/service/apis/online-form-category.service.d.ts +57 -0
- package/lib/apaas/service/apis/online-form-instance.service.d.ts +75 -6
- package/lib/apaas/service/apis/online-form-tmpl.service.d.ts +6 -1
- package/lib/apaas/service/apis/online-form.service.d.ts +0 -5
- package/lib/apaas/service/apis/online-user-summary.service.d.ts +50 -0
- package/lib/apaas/service/apis/online.service.d.ts +15 -1
- package/lib/apaas/service/apis/pad-page.service.d.ts +70 -0
- package/lib/apaas/service/apis/page-designer-log.service.d.ts +1 -1
- package/lib/apaas/service/apis/pm-process-definition.service.d.ts +1 -0
- package/lib/apaas/service/apis/print.service.d.ts +5 -0
- package/lib/apaas/service/apis/process-definition-version.service.d.ts +8 -0
- package/lib/apaas/service/apis/process-path.service.d.ts +8 -0
- package/lib/apaas/service/apis/process-task-done.service.d.ts +10 -0
- package/lib/apaas/service/apis/process-task-todo.service.d.ts +20 -0
- package/lib/apaas/service/apis/product-release.service.d.ts +9 -0
- package/lib/apaas/service/apis/report-data-set.service.d.ts +10 -0
- package/lib/apaas/service/apis/sandbox-config.service.d.ts +74 -0
- package/lib/apaas/service/apis/ss.service.d.ts +12 -0
- package/lib/apaas/service/apis/trace-log.service.d.ts +1 -0
- package/lib/apaas/service/entities.d.ts +9796 -6316
- package/lib/apaas/service/index.d.ts +18 -0
- package/lib/index.cjs +16 -0
- package/lib/ipaas/service/api-config.cjs +18 -0
- package/lib/ipaas/service/apis/camel.service.d.ts +8 -0
- package/lib/ipaas/service/apis/flow.service.d.ts +10 -1
- package/lib/ipaas/service/entities.d.ts +27 -1
- package/lib/platform/service/api-config.cjs +271 -15
- package/lib/platform/service/apis/api.service.d.ts +63 -30
- package/lib/platform/service/apis/app-member.service.d.ts +0 -4
- package/lib/platform/service/apis/bi-app.service.d.ts +6 -0
- package/lib/platform/service/apis/database.service.d.ts +24 -0
- package/lib/platform/service/apis/dataset.service.d.ts +19 -0
- package/lib/platform/service/apis/device-interconnection-param.service.d.ts +58 -0
- package/lib/platform/service/apis/device-interconnection.service.d.ts +63 -0
- package/lib/platform/service/apis/device-param-ref.service.d.ts +25 -0
- package/lib/platform/service/apis/file-task.service.d.ts +1 -0
- package/lib/platform/service/apis/file.service.d.ts +4 -0
- package/lib/platform/service/apis/license.service.d.ts +8 -0
- package/lib/platform/service/apis/login.service.d.ts +1 -0
- package/lib/platform/service/apis/org.service.d.ts +1 -0
- package/lib/platform/service/apis/plat.service.d.ts +17 -0
- package/lib/platform/service/apis/seal-management.service.d.ts +1 -1
- package/lib/platform/service/apis/tenant.service.d.ts +1 -0
- package/lib/platform/service/entities.d.ts +768 -72
- package/lib/platform/service/index.d.ts +8 -0
- package/lib/service/api-manage.cjs +34 -0
- package/lib/service/api-service.cjs +142 -0
- package/lib/service/api-service.interface.cjs +1 -0
- package/lib/service/http.enum.cjs +66 -0
- package/lib/service/http.util.cjs +181 -0
- package/lib/service/index.cjs +45 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/utils/index.cjs +16 -0
- package/package.json +38 -38
- package/dist/api-apaas.esm.js +0 -1
- package/dist/api-apaas.system.js +0 -1
- package/dist/api-ipaas.esm.js +0 -1
- package/dist/api-ipaas.system.js +0 -1
- package/dist/api-platform.esm.js +0 -1
- package/dist/api-platform.system.js +0 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { IHttpResponse } from './api-service.interface';
|
|
3
|
+
/**
|
|
4
|
+
* 全局请求工具类
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class HttpUtil
|
|
8
|
+
*/
|
|
9
|
+
export declare class HttpUtil {
|
|
10
|
+
/**
|
|
11
|
+
* 挂载中间件
|
|
12
|
+
*
|
|
13
|
+
* @static
|
|
14
|
+
* @param {(_axios: AxiosInstance) => void} fn 中间件函数
|
|
15
|
+
*/
|
|
16
|
+
static use(fn: (_axios: AxiosInstance) => void): void;
|
|
17
|
+
/**
|
|
18
|
+
* GET 请求方法
|
|
19
|
+
*
|
|
20
|
+
* @static
|
|
21
|
+
* @template T
|
|
22
|
+
* @param {string} url 请求地址
|
|
23
|
+
* @param {IObject} [data={}] 请求数据
|
|
24
|
+
* @param {IParams} [query={}] 查询参数
|
|
25
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
26
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
27
|
+
*/
|
|
28
|
+
static get<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
29
|
+
/**
|
|
30
|
+
* POST 请求方法
|
|
31
|
+
*
|
|
32
|
+
* @static
|
|
33
|
+
* @template T
|
|
34
|
+
* @param {string} url 请求地址
|
|
35
|
+
* @param {IObject} [data={}] 请求数据
|
|
36
|
+
* @param {IParams} [query={}] 查询参数
|
|
37
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
38
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
39
|
+
*/
|
|
40
|
+
static post<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
41
|
+
/**
|
|
42
|
+
* PUT 请求方法
|
|
43
|
+
*
|
|
44
|
+
* @static
|
|
45
|
+
* @template T
|
|
46
|
+
* @param {string} url 请求地址
|
|
47
|
+
* @param {IObject} [data={}] 请求数据
|
|
48
|
+
* @param {IParams} [query={}] 查询参数
|
|
49
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
50
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
51
|
+
*/
|
|
52
|
+
static put<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
53
|
+
/**
|
|
54
|
+
* DELETE 请求方法
|
|
55
|
+
*
|
|
56
|
+
* @static
|
|
57
|
+
* @template T
|
|
58
|
+
* @param {string} url 请求地址
|
|
59
|
+
* @param {IObject} [data={}] 请求数据
|
|
60
|
+
* @param {IParams} [query={}] 查询参数
|
|
61
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
62
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
63
|
+
*/
|
|
64
|
+
static delete<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
65
|
+
/**
|
|
66
|
+
* OPTIONS 请求方法
|
|
67
|
+
*
|
|
68
|
+
* @static
|
|
69
|
+
* @template T
|
|
70
|
+
* @param {string} url 请求地址
|
|
71
|
+
* @param {IObject} [data={}] 请求数据
|
|
72
|
+
* @param {IParams} [query={}] 查询参数
|
|
73
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
74
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
75
|
+
*/
|
|
76
|
+
static options<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
77
|
+
/**
|
|
78
|
+
* PATCH 请求方法
|
|
79
|
+
*
|
|
80
|
+
* @static
|
|
81
|
+
* @template T
|
|
82
|
+
* @param {string} url 请求地址
|
|
83
|
+
* @param {IObject} [data={}] 请求数据
|
|
84
|
+
* @param {IParams} [query={}] 查询参数
|
|
85
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
86
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
87
|
+
*/
|
|
88
|
+
static patch<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
89
|
+
/**
|
|
90
|
+
* HEAD 请求方法
|
|
91
|
+
*
|
|
92
|
+
* @static
|
|
93
|
+
* @template T
|
|
94
|
+
* @param {string} url 请求地址
|
|
95
|
+
* @param {IObject} [data={}] 请求数据
|
|
96
|
+
* @param {IParams} [query={}] 查询参数
|
|
97
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
98
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
99
|
+
*/
|
|
100
|
+
static head<T = unknown>(url: string, data?: IObject, query?: IParams, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
101
|
+
/**
|
|
102
|
+
* 通用请求方法
|
|
103
|
+
*
|
|
104
|
+
* @static
|
|
105
|
+
* @template T
|
|
106
|
+
* @param {string} url 请求地址
|
|
107
|
+
* @param {(IObject | null)} data 请求数据
|
|
108
|
+
* @param {(IParams | null)} query 查询参数
|
|
109
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
110
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
111
|
+
*/
|
|
112
|
+
static request<T = unknown>(url: string, data: IObject | null, query: IParams | null, config?: AxiosRequestConfig): Promise<IHttpResponse<T>>;
|
|
113
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import qs from "qs";
|
|
3
|
+
import { ContentTypeEnum } from "./http.enum.mjs";
|
|
4
|
+
import { deepMerge } from "../utils/index.mjs";
|
|
5
|
+
const instance = axios.create();
|
|
6
|
+
export class HttpUtil {
|
|
7
|
+
/**
|
|
8
|
+
* 挂载中间件
|
|
9
|
+
*
|
|
10
|
+
* @static
|
|
11
|
+
* @param {(_axios: AxiosInstance) => void} fn 中间件函数
|
|
12
|
+
*/
|
|
13
|
+
static use(fn) {
|
|
14
|
+
fn(instance);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* GET 请求方法
|
|
18
|
+
*
|
|
19
|
+
* @static
|
|
20
|
+
* @template T
|
|
21
|
+
* @param {string} url 请求地址
|
|
22
|
+
* @param {IObject} [data={}] 请求数据
|
|
23
|
+
* @param {IParams} [query={}] 查询参数
|
|
24
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
25
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
26
|
+
*/
|
|
27
|
+
static get(url, data = {}, query = {}, config = {}) {
|
|
28
|
+
return this.request(url, data, query, { ...config, method: "GET" });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* POST 请求方法
|
|
32
|
+
*
|
|
33
|
+
* @static
|
|
34
|
+
* @template T
|
|
35
|
+
* @param {string} url 请求地址
|
|
36
|
+
* @param {IObject} [data={}] 请求数据
|
|
37
|
+
* @param {IParams} [query={}] 查询参数
|
|
38
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
39
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
40
|
+
*/
|
|
41
|
+
static post(url, data = {}, query = {}, config = {}) {
|
|
42
|
+
return this.request(url, data, query, { ...config, method: "POST" });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* PUT 请求方法
|
|
46
|
+
*
|
|
47
|
+
* @static
|
|
48
|
+
* @template T
|
|
49
|
+
* @param {string} url 请求地址
|
|
50
|
+
* @param {IObject} [data={}] 请求数据
|
|
51
|
+
* @param {IParams} [query={}] 查询参数
|
|
52
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
53
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
54
|
+
*/
|
|
55
|
+
static put(url, data = {}, query = {}, config = {}) {
|
|
56
|
+
return this.request(url, data, query, { ...config, method: "PUT" });
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* DELETE 请求方法
|
|
60
|
+
*
|
|
61
|
+
* @static
|
|
62
|
+
* @template T
|
|
63
|
+
* @param {string} url 请求地址
|
|
64
|
+
* @param {IObject} [data={}] 请求数据
|
|
65
|
+
* @param {IParams} [query={}] 查询参数
|
|
66
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
67
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
68
|
+
*/
|
|
69
|
+
static delete(url, data = {}, query = {}, config = {}) {
|
|
70
|
+
return this.request(url, data, query, { ...config, method: "DELETE" });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* OPTIONS 请求方法
|
|
74
|
+
*
|
|
75
|
+
* @static
|
|
76
|
+
* @template T
|
|
77
|
+
* @param {string} url 请求地址
|
|
78
|
+
* @param {IObject} [data={}] 请求数据
|
|
79
|
+
* @param {IParams} [query={}] 查询参数
|
|
80
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
81
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
82
|
+
*/
|
|
83
|
+
static options(url, data = {}, query = {}, config = {}) {
|
|
84
|
+
return this.request(url, data, query, { ...config, method: "OPTIONS" });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* PATCH 请求方法
|
|
88
|
+
*
|
|
89
|
+
* @static
|
|
90
|
+
* @template T
|
|
91
|
+
* @param {string} url 请求地址
|
|
92
|
+
* @param {IObject} [data={}] 请求数据
|
|
93
|
+
* @param {IParams} [query={}] 查询参数
|
|
94
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
95
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
96
|
+
*/
|
|
97
|
+
static patch(url, data = {}, query = {}, config = {}) {
|
|
98
|
+
return this.request(url, data, query, { ...config, method: "PATCH" });
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* HEAD 请求方法
|
|
102
|
+
*
|
|
103
|
+
* @static
|
|
104
|
+
* @template T
|
|
105
|
+
* @param {string} url 请求地址
|
|
106
|
+
* @param {IObject} [data={}] 请求数据
|
|
107
|
+
* @param {IParams} [query={}] 查询参数
|
|
108
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
109
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
110
|
+
*/
|
|
111
|
+
static head(url, data = {}, query = {}, config = {}) {
|
|
112
|
+
return this.request(url, data, query, { ...config, method: "HEAD" });
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 通用请求方法
|
|
116
|
+
*
|
|
117
|
+
* @static
|
|
118
|
+
* @template T
|
|
119
|
+
* @param {string} url 请求地址
|
|
120
|
+
* @param {(IObject | null)} data 请求数据
|
|
121
|
+
* @param {(IParams | null)} query 查询参数
|
|
122
|
+
* @param {AxiosRequestConfig} [config={}] 请求配置
|
|
123
|
+
* @returns {Promise<IHttpResponse<T>>} 请求结果
|
|
124
|
+
*/
|
|
125
|
+
static async request(url, data, query, config = {}) {
|
|
126
|
+
if (query) {
|
|
127
|
+
const queryStr = qs.stringify(query, { arrayFormat: "brackets" });
|
|
128
|
+
if (queryStr) {
|
|
129
|
+
if (url.includes("?")) {
|
|
130
|
+
url += `&${queryStr}`;
|
|
131
|
+
} else {
|
|
132
|
+
url += `?${queryStr}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const res = await instance.request(
|
|
137
|
+
deepMerge(
|
|
138
|
+
{
|
|
139
|
+
url,
|
|
140
|
+
data: JSON.stringify(data ? data : {}),
|
|
141
|
+
params: query,
|
|
142
|
+
timeout: 2 * 60 * 1e3,
|
|
143
|
+
headers: {
|
|
144
|
+
"Content-Type": ContentTypeEnum.JSON
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
config
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
if (res.status >= 200 && res.status < 300) {
|
|
151
|
+
return res.data;
|
|
152
|
+
}
|
|
153
|
+
throw res;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiMap } from './api-service.interface';
|
|
2
|
+
/**
|
|
3
|
+
* API 实例
|
|
4
|
+
*/
|
|
5
|
+
export declare const api: ApiMap;
|
|
6
|
+
export { ResultEnum, RequestEnum, ContentTypeEnum, BizServiceEnum, } from './http.enum';
|
|
7
|
+
export type { IHttpResponse, ApiConfigItem, ApiItem, ApiMap, } from './api-service.interface';
|
|
8
|
+
export { HttpUtil } from './http.util';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { apiConfig as aPaasConfig } from "../apaas/index.mjs";
|
|
2
|
+
import { apiConfig as platformConfig } from "../platform/index.mjs";
|
|
3
|
+
import { ApiManage } from "./api-manage.mjs";
|
|
4
|
+
export const api = {
|
|
5
|
+
apaas: new ApiManage("/gct-apaas/api", aPaasConfig),
|
|
6
|
+
platform: new ApiManage("/gct-platform/api", platformConfig)
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
ResultEnum,
|
|
10
|
+
RequestEnum,
|
|
11
|
+
ContentTypeEnum,
|
|
12
|
+
BizServiceEnum
|
|
13
|
+
} from "./http.enum.mjs";
|
|
14
|
+
export { HttpUtil } from "./http.util.mjs";
|
package/es/types/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 递归合并两个对象
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @template U
|
|
6
|
+
* @param {T} target 目标对象,合并后结果存放于此
|
|
7
|
+
* @param {U} source 要合并的源对象
|
|
8
|
+
* @returns {(T & U)} 合并后的对象
|
|
9
|
+
*/
|
|
10
|
+
export declare function deepMerge<T extends object | null | undefined, U extends object | null | undefined>(target: T, source: U): T & U;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cloneDeep, isEqual, mergeWith, unionWith } from "lodash-es";
|
|
2
|
+
export function deepMerge(target, source) {
|
|
3
|
+
return mergeWith(cloneDeep(target), source, (objValue, srcValue) => {
|
|
4
|
+
if (typeof objValue === "object" && typeof srcValue === "object") {
|
|
5
|
+
return mergeWith(
|
|
6
|
+
cloneDeep(objValue),
|
|
7
|
+
srcValue,
|
|
8
|
+
(prevValue, nextValue) => {
|
|
9
|
+
return Array.isArray(prevValue) ? unionWith(prevValue, nextValue, isEqual) : void 0;
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|