@jdr-web-infra/xingyun-open-api-user 0.0.3 → 0.0.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.d.mts +3 -5
- package/dist/index.mjs +76 -66
- package/package.json +6 -9
- package/README.md +0 -43
package/dist/index.d.mts
CHANGED
|
@@ -87,9 +87,7 @@ interface UserVO {
|
|
|
87
87
|
positionName: string;
|
|
88
88
|
quited: number;
|
|
89
89
|
}
|
|
90
|
-
declare
|
|
91
|
-
private axiosInstance;
|
|
92
|
-
constructor(userToken?: string);
|
|
90
|
+
export declare function createApplication(userToken?: string): {
|
|
93
91
|
/**
|
|
94
92
|
* 按卡片ID查询卡片详情(含所属空间、迭代、阶段、扩展字段及关联附件)
|
|
95
93
|
*
|
|
@@ -118,5 +116,5 @@ declare class Application {
|
|
|
118
116
|
* @returns
|
|
119
117
|
*/
|
|
120
118
|
querySprintsBySpaceId(spaceId: string): Promise<Sprint[]>;
|
|
121
|
-
}
|
|
122
|
-
export {
|
|
119
|
+
};
|
|
120
|
+
export type { Card, Space, Sprint, SprintInfo, UserVO };
|
package/dist/index.mjs
CHANGED
|
@@ -1,74 +1,84 @@
|
|
|
1
1
|
import { create, isAxiosError } from "axios";
|
|
2
|
+
|
|
2
3
|
// src/config.ts
|
|
3
4
|
const BASE_URL = "http://api-gateway.jd.com/jacp";
|
|
4
5
|
const APP_ID = "joyclaw";
|
|
5
6
|
const CONTENT_TYPE = "application/json";
|
|
6
7
|
const API_SUCCESS_CODE = 200;
|
|
8
|
+
|
|
7
9
|
// src/index.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
10
|
+
function resolveCookie(userToken) {
|
|
11
|
+
if (userToken) return `sso.jd.com=${userToken}`;
|
|
12
|
+
if (process.env.SSO_JD_COM) return `sso.jd.com=${process.env.SSO_JD_COM}`;
|
|
13
|
+
throw new Error("用户凭据丢失");
|
|
14
|
+
}
|
|
15
|
+
function errorFromMessage(message, fallback = "请求失败") {
|
|
16
|
+
return new Error(typeof message === "string" && message ? message : fallback);
|
|
17
|
+
}
|
|
18
|
+
function readApiBody(value) {
|
|
19
|
+
if (typeof value === "object" && value !== null) return value;
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
function createClient(userToken) {
|
|
23
|
+
return create({
|
|
24
|
+
baseURL: BASE_URL,
|
|
25
|
+
headers: {
|
|
26
|
+
appId: APP_ID,
|
|
27
|
+
Cookie: resolveCookie(userToken),
|
|
28
|
+
"Content-Type": CONTENT_TYPE
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function getJson(axiosInstance, url) {
|
|
33
|
+
try {
|
|
34
|
+
const body = readApiBody((await axiosInstance.get(url)).data);
|
|
35
|
+
if (body.code !== 200) throw errorFromMessage(body.message);
|
|
36
|
+
return body.data;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (!isAxiosError(error)) throw error instanceof Error ? error : errorFromMessage();
|
|
39
|
+
throw errorFromMessage(readApiBody(error.response?.data).message, error.message);
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
41
|
+
}
|
|
42
|
+
function createApplication(userToken) {
|
|
43
|
+
const axiosInstance = createClient(userToken);
|
|
44
|
+
return {
|
|
45
|
+
/**
|
|
46
|
+
* 按卡片ID查询卡片详情(含所属空间、迭代、阶段、扩展字段及关联附件)
|
|
47
|
+
*
|
|
48
|
+
* @param cardId
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
getCardById(cardId) {
|
|
52
|
+
return getJson(axiosInstance, `/openapi/v3/cards/${cardId}`);
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* 按空间ID查询空间信息
|
|
56
|
+
*
|
|
57
|
+
* @param spaceId 空间ID
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
getSpaceById(spaceId) {
|
|
61
|
+
return getJson(axiosInstance, `/openapi/v3/spaces/${spaceId}`);
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* 按迭代ID查询迭代信息
|
|
65
|
+
*
|
|
66
|
+
* @param sprintId 迭代ID
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
getSprintById(sprintId) {
|
|
70
|
+
return getJson(axiosInstance, `/openapi/v3/sprints/${sprintId}`);
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* 查询指定空间下的迭代列表
|
|
74
|
+
*
|
|
75
|
+
* @param spaceId 空间 ID
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
querySprintsBySpaceId(spaceId) {
|
|
79
|
+
return getJson(axiosInstance, `/openapi/v3/spaces/${spaceId}/sprints`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { API_SUCCESS_CODE, APP_ID, BASE_URL, CONTENT_TYPE, createApplication };
|
package/package.json
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdr-web-infra/xingyun-open-api-user",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"repository": {
|
|
5
|
-
"type": "git",
|
|
6
|
-
"url": "git+https://github.com/jdr-web-infra/xingyun-open-api-user.git"
|
|
7
|
-
},
|
|
3
|
+
"version": "0.0.5",
|
|
8
4
|
"files": [
|
|
9
5
|
"dist"
|
|
10
6
|
],
|
|
@@ -20,8 +16,9 @@
|
|
|
20
16
|
"axios": "1.21.1"
|
|
21
17
|
},
|
|
22
18
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
19
|
+
"@liangmi/vp-config": "1.0.1",
|
|
20
|
+
"@types/node": "26.6.6",
|
|
21
|
+
"typescript": "7.0.2",
|
|
25
22
|
"vite-plus": "1.7.0"
|
|
26
23
|
},
|
|
27
24
|
"devEngines": {
|
|
@@ -33,8 +30,8 @@
|
|
|
33
30
|
},
|
|
34
31
|
"scripts": {
|
|
35
32
|
"build": "vp pack",
|
|
33
|
+
"check": "vp check",
|
|
36
34
|
"dev": "vp pack --watch",
|
|
37
|
-
"test": "vp test"
|
|
38
|
-
"check": "vp check"
|
|
35
|
+
"test": "vp test"
|
|
39
36
|
}
|
|
40
37
|
}
|
package/README.md
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# xingyun-open-api-user
|
|
2
|
-
|
|
3
|
-
<!-- automd:badges bundlephobia -->
|
|
4
|
-
|
|
5
|
-
[](https://npmjs.com/package/@jdr-web-infra/xingyun-open-api-user)
|
|
6
|
-
[](https://npm.chart.dev/@jdr-web-infra/xingyun-open-api-user)
|
|
7
|
-
[](https://bundlephobia.com/package/@jdr-web-infra/xingyun-open-api-user)
|
|
8
|
-
|
|
9
|
-
<!-- /automd -->
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
<!-- automd:pm-install -->
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
# ✨ Auto-detect
|
|
17
|
-
npx nypm install @jdr-web-infra/xingyun-open-api-user
|
|
18
|
-
|
|
19
|
-
# npm
|
|
20
|
-
npm install @jdr-web-infra/xingyun-open-api-user
|
|
21
|
-
|
|
22
|
-
# yarn
|
|
23
|
-
yarn add @jdr-web-infra/xingyun-open-api-user
|
|
24
|
-
|
|
25
|
-
# pnpm
|
|
26
|
-
pnpm add @jdr-web-infra/xingyun-open-api-user
|
|
27
|
-
|
|
28
|
-
# bun
|
|
29
|
-
bun install @jdr-web-infra/xingyun-open-api-user
|
|
30
|
-
|
|
31
|
-
# deno
|
|
32
|
-
deno install npm:@jdr-web-infra/xingyun-open-api-user
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
<!-- /automd -->
|
|
36
|
-
|
|
37
|
-
<!-- automd:with-automd -->
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
_🤖 auto updated with [automd](https://automd.unjs.io)_
|
|
42
|
-
|
|
43
|
-
<!-- /automd -->
|