@gct-paas/api 0.1.4-test.0 → 0.1.5-dev.1

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 (58) hide show
  1. package/dist/index.esm.min.js +4 -1
  2. package/dist/index.system.min.js +4 -1
  3. package/es/apaas/service/api-config.mjs +111 -89
  4. package/es/apaas/service/apis/app-global-settings.service.d.ts +0 -4
  5. package/es/apaas/service/apis/audit-log.service.d.ts +1 -1
  6. package/es/apaas/service/apis/data-source.service.d.ts +4 -0
  7. package/es/apaas/service/apis/designer-common.service.d.ts +2 -2
  8. package/es/apaas/service/apis/edhr-instance.service.d.ts +12 -0
  9. package/es/apaas/service/apis/enum-model-field.service.d.ts +8 -0
  10. package/es/apaas/service/apis/file-resource.service.d.ts +1 -1
  11. package/es/apaas/service/apis/file.service.d.ts +5 -1
  12. package/es/apaas/service/apis/i18n-info.service.d.ts +1 -1
  13. package/es/apaas/service/apis/label.service.d.ts +1 -1
  14. package/es/apaas/service/apis/medPro.service.d.ts +45 -17
  15. package/es/apaas/service/apis/model-method.service.d.ts +19 -1
  16. package/es/apaas/service/apis/office.service.d.ts +1 -1
  17. package/es/apaas/service/apis/online-form-instance.service.d.ts +28 -0
  18. package/es/apaas/service/apis/online-form-tmpl-export.service.d.ts +1 -1
  19. package/es/apaas/service/apis/online-form-tmpl.service.d.ts +4 -0
  20. package/es/apaas/service/apis/process-task-done.service.d.ts +4 -0
  21. package/es/apaas/service/apis/process-task-todo.service.d.ts +8 -0
  22. package/es/apaas/service/entities.d.ts +189 -1
  23. package/es/apaas/service/index.d.ts +1 -1
  24. package/es/ipaas/service/api-config.mjs +6 -4
  25. package/es/ipaas/service/apis/connector-config.service.d.ts +1 -1
  26. package/es/ipaas/service/apis/flow.service.d.ts +1 -1
  27. package/es/platform/service/api-config.mjs +110 -59
  28. package/es/platform/service/apis/api.service.d.ts +32 -8
  29. package/es/platform/service/apis/apk.service.d.ts +1 -1
  30. package/es/platform/service/apis/app.service.d.ts +1 -1
  31. package/es/platform/service/apis/assets.service.d.ts +1 -1
  32. package/es/platform/service/apis/bi-file.service.d.ts +1 -1
  33. package/es/platform/service/apis/dashboard.service.d.ts +4 -0
  34. package/es/platform/service/apis/device-interconnection-param.service.d.ts +1 -1
  35. package/es/platform/service/apis/device-interconnection.service.d.ts +1 -1
  36. package/es/platform/service/apis/file-task.service.d.ts +13 -0
  37. package/es/platform/service/apis/file.service.d.ts +3 -3
  38. package/es/platform/service/apis/i18n-info.service.d.ts +1 -1
  39. package/es/platform/service/apis/ldap.service.d.ts +1 -1
  40. package/es/platform/service/apis/license.service.d.ts +1 -10
  41. package/es/platform/service/apis/login-log.service.d.ts +13 -0
  42. package/es/platform/service/apis/plat.service.d.ts +8 -1
  43. package/es/platform/service/apis/pn-project.service.d.ts +1 -1
  44. package/es/platform/service/apis/user.service.d.ts +6 -6
  45. package/es/platform/service/entities.d.ts +499 -62
  46. package/es/service/api-service.d.ts +13 -0
  47. package/es/service/api-service.interface.d.ts +6 -0
  48. package/es/service/api-service.mjs +26 -1
  49. package/es/service/http.util.d.ts +7 -0
  50. package/es/service/http.util.mjs +10 -2
  51. package/es/service/index.mjs +2 -0
  52. package/es/service/request.client.d.ts +6 -0
  53. package/es/service/request.client.mjs +35 -0
  54. package/es/utils/index.d.ts +1 -0
  55. package/es/utils/index.mjs +1 -0
  56. package/es/utils/native-http/native-http.d.ts +6 -0
  57. package/es/utils/native-http/native-http.mjs +63 -0
  58. package/package.json +4 -3
@@ -101,4 +101,17 @@ export declare class ApiService {
101
101
  * @returns {Promise<T>} 请求结果
102
102
  */
103
103
  protected _head<T = unknown>(method: string, pathParams?: IParams, query?: IParams, data?: IObject, config?: Partial<AxiosRequestConfig>): Promise<T>;
104
+ /**
105
+ * 文件上传方法
106
+ *
107
+ * @protected
108
+ * @template T
109
+ * @param {string} method 请求方法路径
110
+ * @param {IObject} [pathParams] 路径参数
111
+ * @param {IParams} [query] 查询参数
112
+ * @param {Partial<UploadFileData>} [data] 上传数据
113
+ * @param {Partial<AxiosRequestConfig>} [config] 请求配置
114
+ * @return {*} {Promise<T>} 请求结果
115
+ */
116
+ protected _upload<T = unknown>(method: string, pathParams?: IObject, query?: IParams, data?: Partial<UploadFileData>, config?: Partial<AxiosRequestConfig>): Promise<T>;
104
117
  }
@@ -98,6 +98,12 @@ export interface ApiItem {
98
98
  * @type {boolean}
99
99
  */
100
100
  hasData?: boolean;
101
+ /**
102
+ * 是否为文件上传
103
+ *
104
+ * @type {boolean}
105
+ */
106
+ hasUpload?: boolean;
101
107
  }
102
108
  /**
103
109
  * 接口配置项
@@ -16,7 +16,7 @@ export class ApiService {
16
16
  if (!(property in api)) {
17
17
  const cfg = config.apis.find((item) => item.method === property);
18
18
  if (cfg) {
19
- const modeFn = `_${cfg.mode}`;
19
+ const modeFn = cfg.hasUpload ? "_upload" : `_${cfg.mode}`;
20
20
  if (cfg.hasPathParams && cfg.hasData && cfg.hasQuery) {
21
21
  api[property] = (path, query, data, config2) => {
22
22
  return api[modeFn](cfg.path, path, query, data, config2);
@@ -74,6 +74,10 @@ export class ApiService {
74
74
  );
75
75
  };
76
76
  }
77
+ } else {
78
+ console.warn(
79
+ `API method ${property} is not defined in the configuration.`
80
+ );
77
81
  }
78
82
  }
79
83
  return api[property];
@@ -220,4 +224,25 @@ export class ApiService {
220
224
  config
221
225
  );
222
226
  }
227
+ /**
228
+ * 文件上传方法
229
+ *
230
+ * @protected
231
+ * @template T
232
+ * @param {string} method 请求方法路径
233
+ * @param {IObject} [pathParams] 路径参数
234
+ * @param {IParams} [query] 查询参数
235
+ * @param {Partial<UploadFileData>} [data] 上传数据
236
+ * @param {Partial<AxiosRequestConfig>} [config] 请求配置
237
+ * @return {*} {Promise<T>} 请求结果
238
+ */
239
+ _upload(method, pathParams, query, data, config) {
240
+ return HttpUtil.upload(
241
+ joinPath(this.url, method),
242
+ pathParams,
243
+ data,
244
+ query,
245
+ config
246
+ );
247
+ }
223
248
  }
@@ -6,6 +6,13 @@ import type { AxiosInstance, AxiosRequestConfig } from 'axios';
6
6
  * @class HttpUtil
7
7
  */
8
8
  export declare class HttpUtil {
9
+ /**
10
+ * Axios 实例,供外部使用和挂载中间件
11
+ *
12
+ * @static
13
+ * @type {AxiosInstance}
14
+ */
15
+ static _instance: AxiosInstance;
9
16
  /**
10
17
  * 挂载中间件
11
18
  *
@@ -3,6 +3,13 @@ import { ContentTypeEnum } from "./http.enum.mjs";
3
3
  import { BackendError } from "./http.error.mjs";
4
4
  const instance = axios.create();
5
5
  export class HttpUtil {
6
+ /**
7
+ * Axios 实例,供外部使用和挂载中间件
8
+ *
9
+ * @static
10
+ * @type {AxiosInstance}
11
+ */
12
+ static _instance = instance;
6
13
  /**
7
14
  * 挂载中间件
8
15
  *
@@ -10,7 +17,7 @@ export class HttpUtil {
10
17
  * @param {(_axios: AxiosInstance) => void} fn 中间件函数
11
18
  */
12
19
  static use(fn) {
13
- fn(instance);
20
+ fn(this._instance);
14
21
  }
15
22
  /**
16
23
  * GET 请求方法
@@ -164,7 +171,8 @@ export class HttpUtil {
164
171
  headers: {
165
172
  "Content-Type": ContentTypeEnum.FORM_DATA,
166
173
  ...config.headers
167
- }
174
+ },
175
+ nativeData: true
168
176
  });
169
177
  }
170
178
  /**
@@ -1,10 +1,12 @@
1
1
  import { apiConfig as aPaasConfig } from "../apaas/index.mjs";
2
2
  import { apiConfig as platformConfig } from "../platform/index.mjs";
3
3
  import { ApiManage } from "./api-manage.mjs";
4
+ import { installHttpUtil } from "./request.client.mjs";
4
5
  export const api = {
5
6
  apaas: new ApiManage("/gct-apaas/api", aPaasConfig),
6
7
  platform: new ApiManage("/gct-platform/api", platformConfig)
7
8
  };
9
+ installHttpUtil();
8
10
  export {
9
11
  ResultEnum,
10
12
  RequestEnum,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 安装 HTTP 工具类,配置 android 原生适配器和拦截器
3
+ *
4
+ * @export
5
+ */
6
+ export declare function installHttpUtil(): void;
@@ -0,0 +1,35 @@
1
+ import { NativeHTTP } from "../utils/index.mjs";
2
+ import { HttpUtil } from "./http.util.mjs";
3
+ export function installHttpUtil() {
4
+ if (window.location.host !== "appassets.androidplatform.net") {
5
+ console.debug("\u5F53\u524D\u73AF\u5883\u975E Android\uFF0C\u5DF2\u8DF3\u8FC7 HTTP \u5DE5\u5177\u7C7B\u5B89\u88C5");
6
+ return;
7
+ }
8
+ const nativeAdapter = async (config) => {
9
+ const response = await NativeHTTP.request(config);
10
+ return response;
11
+ };
12
+ HttpUtil._instance.defaults.adapter = nativeAdapter;
13
+ const errorHandler = (error) => {
14
+ if (error?.response?.status === 401) {
15
+ console.log("\u767B\u5F55\u4FE1\u606F\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
16
+ } else {
17
+ console.log("\u7F51\u7EDC\u5F02\u5E38\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
18
+ }
19
+ return Promise.reject(error);
20
+ };
21
+ HttpUtil._instance.interceptors.request.use((config) => {
22
+ config.headers["App-Tag"] = "__platform__";
23
+ return config;
24
+ }, errorHandler);
25
+ HttpUtil._instance.interceptors.response.use((response) => {
26
+ if (response.data.code === 200) {
27
+ return response.data.data;
28
+ }
29
+ const errorMessageMode = response.config?.errorMessageMode;
30
+ if (errorMessageMode !== "none") {
31
+ console.log(response.data.message);
32
+ }
33
+ return Promise.reject(response.data);
34
+ }, errorHandler);
35
+ }
@@ -1,3 +1,4 @@
1
+ export { NativeHTTP } from './native-http/native-http';
1
2
  /**
2
3
  * 拼接 URL 路径片段,处理多余的斜杠
3
4
  *
@@ -1,3 +1,4 @@
1
+ export { NativeHTTP } from "./native-http/native-http.mjs";
1
2
  import { cloneDeep, isEqual, mergeWith, unionWith } from "lodash-es";
2
3
  export function joinPath(...segments) {
3
4
  return segments.map((seg, i) => {
@@ -0,0 +1,6 @@
1
+ import type { InternalAxiosRequestConfig } from 'axios';
2
+ export declare const NativeHTTP: {
3
+ request(querydata: InternalAxiosRequestConfig): Promise<unknown>;
4
+ urlDecode(arg: string): Promise<string>;
5
+ urlDecodeSync(arg: string): string;
6
+ };
@@ -0,0 +1,63 @@
1
+ import dsBridge from "dsbridge";
2
+ import qs from "qs";
3
+ export const NativeHTTP = {
4
+ request(querydata) {
5
+ const { method, url, timeout, params, headers, data, baseURL } = querydata;
6
+ const pathparam = "?" + qs.stringify(params);
7
+ const allurl = (baseURL + url).replace(/([^:])\/\//g, "$1/") + pathparam;
8
+ console.info(allurl + ">>HTTP", querydata);
9
+ const startTime = performance.now();
10
+ return new Promise((resolve, reject) => {
11
+ dsBridge.call(
12
+ "HTTP." + method,
13
+ {
14
+ url: allurl,
15
+ timeout,
16
+ headers,
17
+ data: data && typeof data === "string" ? JSON.parse(data) : data
18
+ },
19
+ function(res) {
20
+ const nativeData = JSON.parse(res);
21
+ console.info(
22
+ allurl + `>>HTTP.response-\u8017\u65F6\uFF1A${performance.now() - startTime}`,
23
+ nativeData
24
+ );
25
+ if (nativeData.code === 0 && nativeData.http_code === 200) {
26
+ resolve({ ...nativeData, config: querydata });
27
+ } else {
28
+ const response = {
29
+ message: nativeData.message,
30
+ status: nativeData.http_code
31
+ };
32
+ reject({ response, config: querydata });
33
+ }
34
+ }
35
+ );
36
+ });
37
+ },
38
+ urlDecode(arg) {
39
+ return new Promise((resolve, reject) => {
40
+ return dsBridge.call("HTTP.urlDecode", arg, function(res) {
41
+ if (res) {
42
+ const data = JSON.parse(res);
43
+ if (data.code === 0) {
44
+ resolve(data.data);
45
+ return;
46
+ }
47
+ }
48
+ reject();
49
+ });
50
+ });
51
+ },
52
+ urlDecodeSync(arg) {
53
+ if (!arg) return "";
54
+ const res = dsBridge.call("HTTP.urlDecodeSync", arg);
55
+ if (res) {
56
+ const data = JSON.parse(res);
57
+ if (data.code === 0) {
58
+ return data.data;
59
+ }
60
+ }
61
+ return "";
62
+ }
63
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/api",
3
- "version": "0.1.4-test.0",
3
+ "version": "0.1.5-dev.1",
4
4
  "description": "paas 平台底包",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -70,6 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "axios": "^1.13.2",
73
+ "dsbridge": "^3.1.4",
73
74
  "lodash-es": "^4.17.23",
74
75
  "qs": "^6.14.1"
75
76
  },
@@ -79,8 +80,8 @@
79
80
  "devDependencies": {
80
81
  "@babel/preset-env": "^7.28.6",
81
82
  "@commitlint/cli": "^20.3.1",
82
- "@gct-paas/build": "^0.1.6-dev.6",
83
- "@gct-paas/cli": "^0.1.6-dev.6",
83
+ "@gct-paas/build": "^0.1.8",
84
+ "@gct-paas/cli": "^0.1.16",
84
85
  "@rollup/plugin-commonjs": "^29.0.0",
85
86
  "@rollup/plugin-json": "^6.1.0",
86
87
  "@rollup/plugin-node-resolve": "^16.0.3",