@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.
Files changed (165) hide show
  1. package/dist/gct-api.esm.min.js +25 -0
  2. package/dist/gct-api.system.min.js +25 -0
  3. package/es/apaas/service/api-config.mjs +676 -20
  4. package/es/apaas/service/apis/api.service.d.ts +10 -0
  5. package/es/apaas/service/apis/app-granted-user.service.d.ts +1 -0
  6. package/es/apaas/service/apis/audit-log.service.d.ts +2 -5
  7. package/es/apaas/service/apis/category.service.d.ts +0 -2
  8. package/es/apaas/service/apis/control-config.service.d.ts +4 -0
  9. package/es/apaas/service/apis/designer-common.service.d.ts +4 -0
  10. package/es/apaas/service/apis/dhr.service.d.ts +46 -0
  11. package/es/apaas/service/apis/doc-outline.service.d.ts +1 -1
  12. package/es/apaas/service/apis/document.service.d.ts +4 -0
  13. package/es/apaas/service/apis/edhr-category.service.d.ts +57 -0
  14. package/es/apaas/service/apis/edhr-circulationFormRelateModel.service.d.ts +60 -0
  15. package/es/apaas/service/apis/edhr-instance.service.d.ts +7 -0
  16. package/es/apaas/service/apis/edhr-tmpl.service.d.ts +5 -2
  17. package/es/apaas/service/apis/file-resource.service.d.ts +1 -0
  18. package/es/apaas/service/apis/file.service.d.ts +10 -0
  19. package/es/apaas/service/apis/form.service.d.ts +41 -0
  20. package/es/apaas/service/apis/label.service.d.ts +41 -1
  21. package/es/apaas/service/apis/message-record.service.d.ts +2 -0
  22. package/es/apaas/service/apis/model-meta.service.d.ts +25 -0
  23. package/es/apaas/service/apis/model-permission-relation.service.d.ts +50 -0
  24. package/es/apaas/service/apis/online-form-category.service.d.ts +57 -0
  25. package/es/apaas/service/apis/online-form-instance.service.d.ts +75 -6
  26. package/es/apaas/service/apis/online-form-tmpl.service.d.ts +6 -1
  27. package/es/apaas/service/apis/online-form.service.d.ts +0 -5
  28. package/es/apaas/service/apis/online-user-summary.service.d.ts +50 -0
  29. package/es/apaas/service/apis/online.service.d.ts +15 -1
  30. package/es/apaas/service/apis/pad-page.service.d.ts +70 -0
  31. package/es/apaas/service/apis/page-designer-log.service.d.ts +1 -1
  32. package/es/apaas/service/apis/pm-process-definition.service.d.ts +1 -0
  33. package/es/apaas/service/apis/print.service.d.ts +5 -0
  34. package/es/apaas/service/apis/process-definition-version.service.d.ts +8 -0
  35. package/es/apaas/service/apis/process-path.service.d.ts +8 -0
  36. package/es/apaas/service/apis/process-task-done.service.d.ts +10 -0
  37. package/es/apaas/service/apis/process-task-todo.service.d.ts +20 -0
  38. package/es/apaas/service/apis/product-release.service.d.ts +9 -0
  39. package/es/apaas/service/apis/report-data-set.service.d.ts +10 -0
  40. package/es/apaas/service/apis/sandbox-config.service.d.ts +74 -0
  41. package/es/apaas/service/apis/ss.service.d.ts +12 -0
  42. package/es/apaas/service/apis/trace-log.service.d.ts +1 -0
  43. package/es/apaas/service/entities.d.ts +9796 -6316
  44. package/es/apaas/service/index.d.ts +18 -0
  45. package/es/index.d.ts +1 -0
  46. package/es/index.mjs +1 -0
  47. package/es/ipaas/service/api-config.mjs +21 -0
  48. package/es/ipaas/service/apis/camel.service.d.ts +8 -0
  49. package/es/ipaas/service/apis/flow.service.d.ts +10 -1
  50. package/es/ipaas/service/entities.d.ts +27 -1
  51. package/es/platform/service/api-config.mjs +320 -16
  52. package/es/platform/service/apis/api.service.d.ts +63 -30
  53. package/es/platform/service/apis/app-member.service.d.ts +0 -4
  54. package/es/platform/service/apis/bi-app.service.d.ts +6 -0
  55. package/es/platform/service/apis/database.service.d.ts +24 -0
  56. package/es/platform/service/apis/dataset.service.d.ts +19 -0
  57. package/es/platform/service/apis/device-interconnection-param.service.d.ts +58 -0
  58. package/es/platform/service/apis/device-interconnection.service.d.ts +63 -0
  59. package/es/platform/service/apis/device-param-ref.service.d.ts +25 -0
  60. package/es/platform/service/apis/file-task.service.d.ts +1 -0
  61. package/es/platform/service/apis/file.service.d.ts +4 -0
  62. package/es/platform/service/apis/license.service.d.ts +8 -0
  63. package/es/platform/service/apis/login.service.d.ts +1 -0
  64. package/es/platform/service/apis/org.service.d.ts +1 -0
  65. package/es/platform/service/apis/plat.service.d.ts +17 -0
  66. package/es/platform/service/apis/seal-management.service.d.ts +1 -1
  67. package/es/platform/service/apis/tenant.service.d.ts +1 -0
  68. package/es/platform/service/entities.d.ts +768 -72
  69. package/es/platform/service/index.d.ts +8 -0
  70. package/es/service/api-manage.d.ts +26 -0
  71. package/es/service/api-manage.mjs +29 -0
  72. package/es/service/api-service.d.ts +96 -0
  73. package/es/service/api-service.interface.d.ts +159 -0
  74. package/es/service/api-service.interface.mjs +0 -0
  75. package/es/service/api-service.mjs +169 -0
  76. package/es/service/http.enum.d.ts +76 -0
  77. package/es/service/http.enum.mjs +60 -0
  78. package/es/service/http.util.d.ts +113 -0
  79. package/es/service/http.util.mjs +155 -0
  80. package/es/service/index.d.ts +8 -0
  81. package/es/service/index.mjs +14 -0
  82. package/es/types/index.d.ts +2 -0
  83. package/es/utils/index.d.ts +10 -0
  84. package/es/utils/index.mjs +14 -0
  85. package/lib/apaas/service/api-config.cjs +566 -14
  86. package/lib/apaas/service/apis/api.service.d.ts +10 -0
  87. package/lib/apaas/service/apis/app-granted-user.service.d.ts +1 -0
  88. package/lib/apaas/service/apis/audit-log.service.d.ts +2 -5
  89. package/lib/apaas/service/apis/category.service.d.ts +0 -2
  90. package/lib/apaas/service/apis/control-config.service.d.ts +4 -0
  91. package/lib/apaas/service/apis/designer-common.service.d.ts +4 -0
  92. package/lib/apaas/service/apis/dhr.service.d.ts +46 -0
  93. package/lib/apaas/service/apis/doc-outline.service.d.ts +1 -1
  94. package/lib/apaas/service/apis/document.service.d.ts +4 -0
  95. package/lib/apaas/service/apis/edhr-category.service.d.ts +57 -0
  96. package/lib/apaas/service/apis/edhr-circulationFormRelateModel.service.d.ts +60 -0
  97. package/lib/apaas/service/apis/edhr-instance.service.d.ts +7 -0
  98. package/lib/apaas/service/apis/edhr-tmpl.service.d.ts +5 -2
  99. package/lib/apaas/service/apis/file-resource.service.d.ts +1 -0
  100. package/lib/apaas/service/apis/file.service.d.ts +10 -0
  101. package/lib/apaas/service/apis/form.service.d.ts +41 -0
  102. package/lib/apaas/service/apis/label.service.d.ts +41 -1
  103. package/lib/apaas/service/apis/message-record.service.d.ts +2 -0
  104. package/lib/apaas/service/apis/model-meta.service.d.ts +25 -0
  105. package/lib/apaas/service/apis/model-permission-relation.service.d.ts +50 -0
  106. package/lib/apaas/service/apis/online-form-category.service.d.ts +57 -0
  107. package/lib/apaas/service/apis/online-form-instance.service.d.ts +75 -6
  108. package/lib/apaas/service/apis/online-form-tmpl.service.d.ts +6 -1
  109. package/lib/apaas/service/apis/online-form.service.d.ts +0 -5
  110. package/lib/apaas/service/apis/online-user-summary.service.d.ts +50 -0
  111. package/lib/apaas/service/apis/online.service.d.ts +15 -1
  112. package/lib/apaas/service/apis/pad-page.service.d.ts +70 -0
  113. package/lib/apaas/service/apis/page-designer-log.service.d.ts +1 -1
  114. package/lib/apaas/service/apis/pm-process-definition.service.d.ts +1 -0
  115. package/lib/apaas/service/apis/print.service.d.ts +5 -0
  116. package/lib/apaas/service/apis/process-definition-version.service.d.ts +8 -0
  117. package/lib/apaas/service/apis/process-path.service.d.ts +8 -0
  118. package/lib/apaas/service/apis/process-task-done.service.d.ts +10 -0
  119. package/lib/apaas/service/apis/process-task-todo.service.d.ts +20 -0
  120. package/lib/apaas/service/apis/product-release.service.d.ts +9 -0
  121. package/lib/apaas/service/apis/report-data-set.service.d.ts +10 -0
  122. package/lib/apaas/service/apis/sandbox-config.service.d.ts +74 -0
  123. package/lib/apaas/service/apis/ss.service.d.ts +12 -0
  124. package/lib/apaas/service/apis/trace-log.service.d.ts +1 -0
  125. package/lib/apaas/service/entities.d.ts +9796 -6316
  126. package/lib/apaas/service/index.d.ts +18 -0
  127. package/lib/index.cjs +16 -0
  128. package/lib/ipaas/service/api-config.cjs +18 -0
  129. package/lib/ipaas/service/apis/camel.service.d.ts +8 -0
  130. package/lib/ipaas/service/apis/flow.service.d.ts +10 -1
  131. package/lib/ipaas/service/entities.d.ts +27 -1
  132. package/lib/platform/service/api-config.cjs +271 -15
  133. package/lib/platform/service/apis/api.service.d.ts +63 -30
  134. package/lib/platform/service/apis/app-member.service.d.ts +0 -4
  135. package/lib/platform/service/apis/bi-app.service.d.ts +6 -0
  136. package/lib/platform/service/apis/database.service.d.ts +24 -0
  137. package/lib/platform/service/apis/dataset.service.d.ts +19 -0
  138. package/lib/platform/service/apis/device-interconnection-param.service.d.ts +58 -0
  139. package/lib/platform/service/apis/device-interconnection.service.d.ts +63 -0
  140. package/lib/platform/service/apis/device-param-ref.service.d.ts +25 -0
  141. package/lib/platform/service/apis/file-task.service.d.ts +1 -0
  142. package/lib/platform/service/apis/file.service.d.ts +4 -0
  143. package/lib/platform/service/apis/license.service.d.ts +8 -0
  144. package/lib/platform/service/apis/login.service.d.ts +1 -0
  145. package/lib/platform/service/apis/org.service.d.ts +1 -0
  146. package/lib/platform/service/apis/plat.service.d.ts +17 -0
  147. package/lib/platform/service/apis/seal-management.service.d.ts +1 -1
  148. package/lib/platform/service/apis/tenant.service.d.ts +1 -0
  149. package/lib/platform/service/entities.d.ts +768 -72
  150. package/lib/platform/service/index.d.ts +8 -0
  151. package/lib/service/api-manage.cjs +34 -0
  152. package/lib/service/api-service.cjs +142 -0
  153. package/lib/service/api-service.interface.cjs +1 -0
  154. package/lib/service/http.enum.cjs +66 -0
  155. package/lib/service/http.util.cjs +181 -0
  156. package/lib/service/index.cjs +45 -0
  157. package/lib/types/index.d.ts +2 -0
  158. package/lib/utils/index.cjs +16 -0
  159. package/package.json +38 -38
  160. package/dist/api-apaas.esm.js +0 -1
  161. package/dist/api-apaas.system.js +0 -1
  162. package/dist/api-ipaas.esm.js +0 -1
  163. package/dist/api-ipaas.system.js +0 -1
  164. package/dist/api-platform.esm.js +0 -1
  165. 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";
@@ -1,3 +1,5 @@
1
+ export {};
2
+
1
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
4
  declare global {
3
5
  /**
@@ -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
+ }