@jdr-web-infra/xingyun-open-api-user 0.0.0-stage → 0.0.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.
- package/README.md +42 -2
- package/dist/index.d.mts +82 -0
- package/dist/index.mjs +64 -0
- package/package.json +37 -3
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# xingyun-open-api-user
|
|
2
2
|
|
|
3
|
-
|
|
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 -->
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
interface UserVO {
|
|
2
|
+
erp: string;
|
|
3
|
+
headImage: string;
|
|
4
|
+
name: string;
|
|
5
|
+
orgId: string;
|
|
6
|
+
orgName: string;
|
|
7
|
+
organization: {
|
|
8
|
+
code: string;
|
|
9
|
+
fullCode: string;
|
|
10
|
+
fullName: string;
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
positionName: string;
|
|
15
|
+
quited: number;
|
|
16
|
+
}
|
|
17
|
+
declare class Application {
|
|
18
|
+
private axiosInstance;
|
|
19
|
+
constructor(userToken?: string);
|
|
20
|
+
/**
|
|
21
|
+
* 按空间ID查询空间信息
|
|
22
|
+
*
|
|
23
|
+
* @param spaceId 空间ID
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
getSpaceById(spaceId: string): Promise<{
|
|
27
|
+
id: number;
|
|
28
|
+
key: string;
|
|
29
|
+
name: string;
|
|
30
|
+
desc: string;
|
|
31
|
+
creator: UserVO;
|
|
32
|
+
operator: UserVO;
|
|
33
|
+
visibility: number;
|
|
34
|
+
createTime: number;
|
|
35
|
+
updateTime: number;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* 按迭代ID查询迭代信息
|
|
39
|
+
*
|
|
40
|
+
* @param sprintId 迭代ID
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
getSprintById(sprintId: string): Promise<{
|
|
44
|
+
id: number;
|
|
45
|
+
spaceId: number;
|
|
46
|
+
name: string;
|
|
47
|
+
startDate: number;
|
|
48
|
+
endDate: number;
|
|
49
|
+
status: number;
|
|
50
|
+
desc: string;
|
|
51
|
+
creator: UserVO;
|
|
52
|
+
locked: number;
|
|
53
|
+
archived: number;
|
|
54
|
+
kickoffTime: number;
|
|
55
|
+
archivedTime: number;
|
|
56
|
+
createTime: number;
|
|
57
|
+
updateTime: number;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* 查询指定空间下的迭代列表
|
|
61
|
+
*
|
|
62
|
+
* @param spaceId 空间 ID
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
querySprintsBySpaceId(spaceId: string): Promise<{
|
|
66
|
+
id: number;
|
|
67
|
+
spaceId: number;
|
|
68
|
+
name: string;
|
|
69
|
+
owner: UserVO;
|
|
70
|
+
startDate: number;
|
|
71
|
+
endDate: number;
|
|
72
|
+
status: number;
|
|
73
|
+
desc: string;
|
|
74
|
+
locked: number;
|
|
75
|
+
archived: number;
|
|
76
|
+
kickoffTime: number;
|
|
77
|
+
archivedTime: number;
|
|
78
|
+
cTime: number;
|
|
79
|
+
uTime: number;
|
|
80
|
+
}[]>;
|
|
81
|
+
}
|
|
82
|
+
export { Application as default };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { create, isAxiosError } from "axios";
|
|
2
|
+
// src/config.ts
|
|
3
|
+
const BASE_URL = "http://api-gateway.jd.com/jacp";
|
|
4
|
+
const APP_ID = "joyclaw";
|
|
5
|
+
const CONTENT_TYPE = "application/json";
|
|
6
|
+
// src/index.ts
|
|
7
|
+
var Application = class {
|
|
8
|
+
axiosInstance;
|
|
9
|
+
constructor(userToken) {
|
|
10
|
+
let cookie = "sso.jd.com=";
|
|
11
|
+
if (userToken) cookie += userToken;
|
|
12
|
+
else if (process.env.SSO_JD_COM) cookie += process.env.SSO_JD_COM;
|
|
13
|
+
else throw new Error("用户凭据丢失");
|
|
14
|
+
const axiosInstance = create({
|
|
15
|
+
baseURL: BASE_URL,
|
|
16
|
+
headers: {
|
|
17
|
+
appId: APP_ID,
|
|
18
|
+
Cookie: cookie,
|
|
19
|
+
"Content-Type": CONTENT_TYPE
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const rejectByMessage = (message, fallback = "请求失败") => Promise.reject(new Error(typeof message === "string" && message ? message : fallback));
|
|
23
|
+
axiosInstance.interceptors.response.use((response) => {
|
|
24
|
+
const { code, message, data } = response.data ?? {};
|
|
25
|
+
if (code !== 200) return rejectByMessage(message);
|
|
26
|
+
response.data = data;
|
|
27
|
+
return response;
|
|
28
|
+
}, (error) => {
|
|
29
|
+
const data = isAxiosError(error) ? error.response?.data : void 0;
|
|
30
|
+
const message = data && typeof data === "object" ? data.message : void 0;
|
|
31
|
+
const fallback = error instanceof Error ? error.message : "请求失败";
|
|
32
|
+
return rejectByMessage(message, fallback);
|
|
33
|
+
});
|
|
34
|
+
this.axiosInstance = axiosInstance;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 按空间ID查询空间信息
|
|
38
|
+
*
|
|
39
|
+
* @param spaceId 空间ID
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
async getSpaceById(spaceId) {
|
|
43
|
+
return (await this.axiosInstance.get(`/openapi/v3/spaces/${spaceId}`)).data;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 按迭代ID查询迭代信息
|
|
47
|
+
*
|
|
48
|
+
* @param sprintId 迭代ID
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
async getSprintById(sprintId) {
|
|
52
|
+
return (await this.axiosInstance.get(`/openapi/v3/sprints/${sprintId}`)).data;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 查询指定空间下的迭代列表
|
|
56
|
+
*
|
|
57
|
+
* @param spaceId 空间 ID
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
async querySprintsBySpaceId(spaceId) {
|
|
61
|
+
return (await this.axiosInstance.get("/openapi/v3/sprints", { params: { spaceId } })).data;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export { Application as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdr-web-infra/xingyun-open-api-user",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/jdr-web-infra/xingyun-open-api-user.git"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/index.mjs",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"axios": "1.21.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^26.6.5",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite-plus": "1.7.0"
|
|
26
|
+
},
|
|
27
|
+
"devEngines": {
|
|
28
|
+
"packageManager": {
|
|
29
|
+
"name": "pnpm",
|
|
30
|
+
"version": "12.21.0",
|
|
31
|
+
"onFail": "download"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "vp pack",
|
|
36
|
+
"dev": "vp pack --watch",
|
|
37
|
+
"test": "vp test",
|
|
38
|
+
"check": "vp check"
|
|
39
|
+
}
|
|
6
40
|
}
|