@jdr-web-infra/xingyun-open-api-user 0.0.0-stage → 0.0.2

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 CHANGED
@@ -1,3 +1,43 @@
1
- # Temporary Holding Version
1
+ # xingyun-open-api-user
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <!-- automd:badges bundlephobia -->
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@jdr-web-infra/xingyun-open-api-user)](https://npmjs.com/package/@jdr-web-infra/xingyun-open-api-user)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@jdr-web-infra/xingyun-open-api-user)](https://npm.chart.dev/@jdr-web-infra/xingyun-open-api-user)
7
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/@jdr-web-infra/xingyun-open-api-user)](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 -->
@@ -0,0 +1,112 @@
1
+ interface Card {
2
+ id: number;
3
+ code: string;
4
+ name: string;
5
+ space: {
6
+ id: number;
7
+ name: string;
8
+ };
9
+ workitemTypeCode: string;
10
+ workitemTypeName: string;
11
+ stageId: number;
12
+ stageName: string;
13
+ statusId: number;
14
+ statusName: string;
15
+ startDate: number;
16
+ deadline: number;
17
+ priority: number;
18
+ story: number;
19
+ sprint: {
20
+ id: number;
21
+ name: string;
22
+ };
23
+ desc: string;
24
+ demandId: number;
25
+ createTime: number;
26
+ updateTime: number;
27
+ }
28
+ interface Space {
29
+ id: number;
30
+ key: string;
31
+ name: string;
32
+ desc: string;
33
+ creator: UserVO;
34
+ operator: UserVO;
35
+ visibility: number;
36
+ createTime: number;
37
+ updateTime: number;
38
+ }
39
+ interface SprintInfo {
40
+ id: number;
41
+ spaceId: number;
42
+ name: string;
43
+ startDate: number;
44
+ endDate: number;
45
+ status: number;
46
+ desc: string;
47
+ creator: UserVO;
48
+ locked: number;
49
+ archived: number;
50
+ kickoffTime: number;
51
+ archivedTime: number;
52
+ createTime: number;
53
+ updateTime: number;
54
+ }
55
+ interface Sprint {
56
+ id: number;
57
+ spaceId: number;
58
+ name: string;
59
+ startDate: number;
60
+ endDate: number;
61
+ status: number;
62
+ statusName: string;
63
+ desc: string;
64
+ creator: UserVO;
65
+ locked: number;
66
+ archived: number;
67
+ createTime: number;
68
+ updateTime: number;
69
+ }
70
+ interface UserVO {
71
+ erp: string;
72
+ headImage: string;
73
+ name: string;
74
+ orgId: string;
75
+ orgName: string;
76
+ organization: {
77
+ code: string;
78
+ fullCode: string;
79
+ fullName: string;
80
+ id: string;
81
+ name: string;
82
+ };
83
+ positionName: string;
84
+ quited: number;
85
+ }
86
+ declare class Application {
87
+ private axiosInstance;
88
+ constructor(userToken?: string);
89
+ getCardById(cardId: number): Promise<Card>;
90
+ /**
91
+ * 按空间ID查询空间信息
92
+ *
93
+ * @param spaceId 空间ID
94
+ * @returns
95
+ */
96
+ getSpaceById(spaceId: string): Promise<Space>;
97
+ /**
98
+ * 按迭代ID查询迭代信息
99
+ *
100
+ * @param sprintId 迭代ID
101
+ * @returns
102
+ */
103
+ getSprintById(sprintId: string): Promise<SprintInfo>;
104
+ /**
105
+ * 查询指定空间下的迭代列表
106
+ *
107
+ * @param spaceId 空间 ID
108
+ * @returns
109
+ */
110
+ querySprintsBySpaceId(spaceId: string): Promise<Sprint[]>;
111
+ }
112
+ export { Application as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,67 @@
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
+ async getCardById(cardId) {
37
+ return (await this.axiosInstance.get(`/openapi/v3/cards/${cardId}`)).data;
38
+ }
39
+ /**
40
+ * 按空间ID查询空间信息
41
+ *
42
+ * @param spaceId 空间ID
43
+ * @returns
44
+ */
45
+ async getSpaceById(spaceId) {
46
+ return (await this.axiosInstance.get(`/openapi/v3/spaces/${spaceId}`)).data;
47
+ }
48
+ /**
49
+ * 按迭代ID查询迭代信息
50
+ *
51
+ * @param sprintId 迭代ID
52
+ * @returns
53
+ */
54
+ async getSprintById(sprintId) {
55
+ return (await this.axiosInstance.get(`/openapi/v3/sprints/${sprintId}`)).data;
56
+ }
57
+ /**
58
+ * 查询指定空间下的迭代列表
59
+ *
60
+ * @param spaceId 空间 ID
61
+ * @returns
62
+ */
63
+ async querySprintsBySpaceId(spaceId) {
64
+ return (await this.axiosInstance.get(`/openapi/v3/spaces/${spaceId}/sprints`)).data;
65
+ }
66
+ };
67
+ 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.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.2",
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
  }