@lark-apaas/miaoda-core 0.0.1-alpha.7 → 0.0.1-alpha.8

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.
@@ -1,12 +1,3 @@
1
- /**
2
- * api panel
3
- * 获取open-api.json
4
- */
5
- declare function getOpenApiJson(): Promise<{}>;
6
- /**
7
- * 获取日志json
8
- */
9
- declare function getLogJson(): Promise<{}>;
10
1
  /**
11
2
  * GET 请求
12
3
  */
@@ -35,4 +26,4 @@ declare function api_head(url: any, config: any): Promise<import("../api-proxy/c
35
26
  * OPTIONS 请求
36
27
  */
37
28
  declare function api_options(url: any, config: any): Promise<import("../api-proxy/core").ApiResponse<any>>;
38
- export { getOpenApiJson, getLogJson, api_get, api_post, api_put, api_delete, api_patch, api_head, api_options, };
29
+ export { api_get, api_post, api_put, api_delete, api_patch, api_head, api_options, };
@@ -1,60 +1,66 @@
1
1
  import { normalizeBasePath } from "../../../utils/utils.js";
2
2
  import core from "../api-proxy/core.js";
3
- async function getOpenApiJson() {
4
- let apiJson = {};
3
+ async function api_get(url, config) {
5
4
  try {
6
5
  const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
7
- const res = await fetch(`${basePath}/openapi.json`);
8
- apiJson = await res.json();
6
+ const res = await core.get(`${basePath}${url}`, config);
7
+ return res;
9
8
  } catch (error) {
10
- console.warn('get openapi.json error', error);
9
+ throw new Error(JSON.stringify(error));
11
10
  }
12
- return apiJson;
13
11
  }
14
- async function getLogJson() {
15
- let logJson = {};
12
+ async function api_post(url, data, config) {
16
13
  try {
17
14
  const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
18
- const res = await fetch(`${basePath}/log.json`);
19
- logJson = await res.json();
15
+ const res = await core.post(`${basePath}${url}`, data, config);
16
+ return res;
20
17
  } catch (error) {
21
- console.warn('get log.json error', error);
18
+ throw new Error(JSON.stringify(error));
22
19
  }
23
- return logJson;
24
- }
25
- async function api_get(url, config) {
26
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
27
- const res = await core.get(`${basePath}${url}`, config);
28
- return res;
29
- }
30
- async function api_post(url, data, config) {
31
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
32
- const res = await core.post(`${basePath}${url}`, data, config);
33
- return res;
34
20
  }
35
21
  async function api_put(url, data, config) {
36
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
37
- const res = await core.put(`${basePath}${url}`, data, config);
38
- return res;
22
+ try {
23
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
24
+ const res = await core.put(`${basePath}${url}`, data, config);
25
+ return res;
26
+ } catch (error) {
27
+ throw new Error(JSON.stringify(error));
28
+ }
39
29
  }
40
30
  async function api_delete(url, config) {
41
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
42
- const res = await core["delete"](`${basePath}${url}`, config);
43
- return res;
31
+ try {
32
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
33
+ const res = await core["delete"](`${basePath}${url}`, config);
34
+ return res;
35
+ } catch (error) {
36
+ throw new Error(JSON.stringify(error));
37
+ }
44
38
  }
45
39
  async function api_patch(url, data, config) {
46
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
47
- const res = await core.patch(`${basePath}${url}`, data, config);
48
- return res;
40
+ try {
41
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
42
+ const res = await core.patch(`${basePath}${url}`, data, config);
43
+ return res;
44
+ } catch (error) {
45
+ throw new Error(JSON.stringify(error));
46
+ }
49
47
  }
50
48
  async function api_head(url, config) {
51
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
52
- const res = await core.head(`${basePath}${url}`, config);
53
- return res;
49
+ try {
50
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
51
+ const res = await core.head(`${basePath}${url}`, config);
52
+ return res;
53
+ } catch (error) {
54
+ throw new Error(JSON.stringify(error));
55
+ }
54
56
  }
55
57
  async function api_options(url, config) {
56
- const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
57
- const res = await core.options(`${basePath}${url}`, config);
58
- return res;
58
+ try {
59
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
60
+ const res = await core.options(`${basePath}${url}`, config);
61
+ return res;
62
+ } catch (error) {
63
+ throw new Error(JSON.stringify(error));
64
+ }
59
65
  }
60
- export { api_delete, api_get, api_head, api_options, api_patch, api_post, api_put, getLogJson, getOpenApiJson };
66
+ export { api_delete, api_get, api_head, api_options, api_patch, api_post, api_put };
@@ -1,5 +1,5 @@
1
1
  import { normalizeBasePath } from "../../../utils/utils.js";
2
- import { api_delete, api_get, api_head, api_options, api_patch, api_post, api_put, getLogJson, getOpenApiJson } from "./api-panel.js";
2
+ import { api_delete, api_get, api_head, api_options, api_patch, api_post, api_put } from "./api-panel.js";
3
3
  async function getRoutes() {
4
4
  let routes = [
5
5
  {
@@ -24,9 +24,7 @@ const childApi = {
24
24
  api_delete: api_delete,
25
25
  api_patch: api_patch,
26
26
  api_head: api_head,
27
- api_options: api_options,
28
- getOpenApiJson: getOpenApiJson,
29
- getLogJson: getLogJson
27
+ api_options: api_options
30
28
  }
31
29
  };
32
30
  export { childApi };
@@ -55,7 +55,5 @@ export interface ChildApi {
55
55
  api_patch: (url: string, data?: any, config?: any) => Promise<any>;
56
56
  api_head: (url: string, config?: any) => Promise<any>;
57
57
  api_options: (url: string, config?: any) => Promise<any>;
58
- getOpenApiJson: () => Promise<any>;
59
- getLogJson: () => Promise<any>;
60
58
  };
61
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-core",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.8",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -70,7 +70,7 @@
70
70
  "test": "echo 0",
71
71
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx",
72
72
  "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
73
- "prepublishOnly": "npm run build && node scripts/replace-workspace-alias.js"
73
+ "prepublishOnly": "npm run build"
74
74
  },
75
75
  "dependencies": {
76
76
  "@ant-design/colors": "^7.2.1",