@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.
- package/dist/index.esm.min.js +4 -1
- package/dist/index.system.min.js +4 -1
- package/es/apaas/service/api-config.mjs +15 -2
- package/es/apaas/service/apis/audit-log.service.d.ts +1 -1
- package/es/apaas/service/apis/designer-common.service.d.ts +2 -2
- package/es/apaas/service/apis/enum-model-field.service.d.ts +8 -0
- package/es/apaas/service/apis/file-resource.service.d.ts +1 -1
- package/es/apaas/service/apis/file.service.d.ts +1 -1
- package/es/apaas/service/apis/i18n-info.service.d.ts +1 -1
- package/es/apaas/service/apis/label.service.d.ts +1 -1
- package/es/apaas/service/apis/model-method.service.d.ts +19 -1
- package/es/apaas/service/apis/office.service.d.ts +1 -1
- package/es/apaas/service/apis/online-form-tmpl-export.service.d.ts +1 -1
- package/es/apaas/service/apis/online-form-tmpl.service.d.ts +4 -0
- package/es/apaas/service/apis/process-task-done.service.d.ts +4 -0
- package/es/apaas/service/apis/process-task-todo.service.d.ts +8 -0
- package/es/apaas/service/entities.d.ts +105 -1
- package/es/ipaas/service/apis/connector-config.service.d.ts +1 -1
- package/es/ipaas/service/apis/flow.service.d.ts +1 -1
- package/es/platform/service/api-config.mjs +22 -0
- package/es/platform/service/apis/api.service.d.ts +21 -1
- package/es/platform/service/apis/apk.service.d.ts +1 -1
- package/es/platform/service/apis/app.service.d.ts +5 -1
- package/es/platform/service/apis/assets.service.d.ts +1 -1
- package/es/platform/service/apis/bi-file.service.d.ts +1 -1
- package/es/platform/service/apis/dashboard.service.d.ts +4 -0
- package/es/platform/service/apis/device-interconnection-param.service.d.ts +1 -1
- package/es/platform/service/apis/device-interconnection.service.d.ts +1 -1
- package/es/platform/service/apis/file.service.d.ts +3 -3
- package/es/platform/service/apis/i18n-info.service.d.ts +1 -1
- package/es/platform/service/apis/ldap.service.d.ts +1 -1
- package/es/platform/service/apis/login-log.service.d.ts +13 -0
- package/es/platform/service/apis/org.service.d.ts +4 -0
- package/es/platform/service/apis/plat.service.d.ts +8 -1
- package/es/platform/service/apis/pn-project.service.d.ts +1 -1
- package/es/platform/service/apis/tenant.service.d.ts +4 -0
- package/es/platform/service/apis/user.service.d.ts +6 -6
- package/es/platform/service/entities.d.ts +393 -4
- package/es/service/http.util.d.ts +7 -0
- package/es/service/http.util.mjs +8 -1
- package/es/service/index.mjs +2 -0
- package/es/service/request.client.d.ts +6 -0
- package/es/service/request.client.mjs +35 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +1 -0
- package/es/utils/native-http/native-http.d.ts +6 -0
- package/es/utils/native-http/native-http.mjs +63 -0
- package/package.json +4 -3
package/es/service/http.util.mjs
CHANGED
|
@@ -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(
|
|
20
|
+
fn(this._instance);
|
|
14
21
|
}
|
|
15
22
|
/**
|
|
16
23
|
* GET 请求方法
|
package/es/service/index.mjs
CHANGED
|
@@ -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,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
|
+
}
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.mjs
CHANGED
|
@@ -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
|
+
"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.
|
|
83
|
-
"@gct-paas/cli": "^0.1.
|
|
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",
|