@gct-paas/api 0.1.4-dev.3 → 0.1.4-dev.5

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 (48) 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 +15 -2
  4. package/es/apaas/service/apis/audit-log.service.d.ts +1 -1
  5. package/es/apaas/service/apis/designer-common.service.d.ts +2 -2
  6. package/es/apaas/service/apis/enum-model-field.service.d.ts +8 -0
  7. package/es/apaas/service/apis/file-resource.service.d.ts +1 -1
  8. package/es/apaas/service/apis/file.service.d.ts +1 -1
  9. package/es/apaas/service/apis/i18n-info.service.d.ts +1 -1
  10. package/es/apaas/service/apis/label.service.d.ts +1 -1
  11. package/es/apaas/service/apis/model-method.service.d.ts +19 -1
  12. package/es/apaas/service/apis/office.service.d.ts +1 -1
  13. package/es/apaas/service/apis/online-form-tmpl-export.service.d.ts +1 -1
  14. package/es/apaas/service/apis/online-form-tmpl.service.d.ts +4 -0
  15. package/es/apaas/service/apis/process-task-done.service.d.ts +4 -0
  16. package/es/apaas/service/apis/process-task-todo.service.d.ts +8 -0
  17. package/es/apaas/service/entities.d.ts +105 -1
  18. package/es/ipaas/service/apis/connector-config.service.d.ts +1 -1
  19. package/es/ipaas/service/apis/flow.service.d.ts +1 -1
  20. package/es/platform/service/api-config.mjs +22 -0
  21. package/es/platform/service/apis/api.service.d.ts +21 -1
  22. package/es/platform/service/apis/apk.service.d.ts +1 -1
  23. package/es/platform/service/apis/app.service.d.ts +5 -1
  24. package/es/platform/service/apis/assets.service.d.ts +1 -1
  25. package/es/platform/service/apis/bi-file.service.d.ts +1 -1
  26. package/es/platform/service/apis/dashboard.service.d.ts +4 -0
  27. package/es/platform/service/apis/device-interconnection-param.service.d.ts +1 -1
  28. package/es/platform/service/apis/device-interconnection.service.d.ts +1 -1
  29. package/es/platform/service/apis/file.service.d.ts +3 -3
  30. package/es/platform/service/apis/i18n-info.service.d.ts +1 -1
  31. package/es/platform/service/apis/ldap.service.d.ts +1 -1
  32. package/es/platform/service/apis/login-log.service.d.ts +13 -0
  33. package/es/platform/service/apis/org.service.d.ts +4 -0
  34. package/es/platform/service/apis/plat.service.d.ts +8 -1
  35. package/es/platform/service/apis/pn-project.service.d.ts +1 -1
  36. package/es/platform/service/apis/tenant.service.d.ts +4 -0
  37. package/es/platform/service/apis/user.service.d.ts +6 -6
  38. package/es/platform/service/entities.d.ts +393 -4
  39. package/es/service/http.util.d.ts +7 -0
  40. package/es/service/http.util.mjs +8 -1
  41. package/es/service/index.mjs +2 -0
  42. package/es/service/request.client.d.ts +6 -0
  43. package/es/service/request.client.mjs +35 -0
  44. package/es/utils/index.d.ts +1 -0
  45. package/es/utils/index.mjs +1 -0
  46. package/es/utils/native-http/native-http.d.ts +6 -0
  47. package/es/utils/native-http/native-http.mjs +63 -0
  48. package/package.json +4 -3
@@ -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 请求方法
@@ -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-dev.3",
3
+ "version": "0.1.4-dev.5",
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.7",
83
- "@gct-paas/cli": "^0.1.13",
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",