@theholocron/jira-client 1.32.0 → 1.32.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/dist/index.d.mts +159 -0
- package/dist/index.mjs +154 -0
- package/package.json +3 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { RestClient } from "@theholocron/http-client";
|
|
2
|
+
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
//#region ../../../../../src/types.d.ts
|
|
4
|
+
interface JiraClientOptions {
|
|
5
|
+
host: string;
|
|
6
|
+
token: string;
|
|
7
|
+
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
}
|
|
10
|
+
interface JiraIssueFields {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
interface JiraIssue {
|
|
14
|
+
id: string;
|
|
15
|
+
key: string;
|
|
16
|
+
fields: JiraIssueFields;
|
|
17
|
+
}
|
|
18
|
+
interface JiraVersion {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
project: string;
|
|
22
|
+
startDate?: string;
|
|
23
|
+
releaseDate?: string;
|
|
24
|
+
released?: boolean;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
interface JiraProject {
|
|
28
|
+
id: string;
|
|
29
|
+
key: string;
|
|
30
|
+
name: string;
|
|
31
|
+
issueTypes?: JiraIssueType[];
|
|
32
|
+
}
|
|
33
|
+
interface JiraIssueType {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
}
|
|
37
|
+
interface JiraTransition {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
to: {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
interface JiraResolution {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
interface JiraIssueLinkType {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
inward: string;
|
|
54
|
+
outward: string;
|
|
55
|
+
}
|
|
56
|
+
interface JiraSearchResponse {
|
|
57
|
+
issues: JiraIssue[];
|
|
58
|
+
total: number;
|
|
59
|
+
maxResults: number;
|
|
60
|
+
startAt: number;
|
|
61
|
+
}
|
|
62
|
+
interface JiraSearchQuery {
|
|
63
|
+
jql?: string;
|
|
64
|
+
startAt?: number;
|
|
65
|
+
maxResults?: number;
|
|
66
|
+
fields?: string[];
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region ../../../../../src/links.d.ts
|
|
70
|
+
interface IssueLinkResult {
|
|
71
|
+
ticket: string;
|
|
72
|
+
status: number;
|
|
73
|
+
}
|
|
74
|
+
declare function links(client: RestClient): {
|
|
75
|
+
create(ticket: string, link: string, type: string): Promise<number>;
|
|
76
|
+
createMany(tickets: string[], link: string, type: string): Promise<IssueLinkResult[]>;
|
|
77
|
+
getLinkTypes(params?: Record<string, string>): Promise<{
|
|
78
|
+
issueLinkTypes: JiraIssueLinkType[];
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region ../../../../../src/issues.d.ts
|
|
83
|
+
declare function issues(client: RestClient): {
|
|
84
|
+
create(title: string, type: string, project: string, fields?: JiraIssueFields): Promise<JiraIssue>;
|
|
85
|
+
get(ticket: string, params?: Record<string, string>): Promise<JiraIssue>;
|
|
86
|
+
getMany(tickets: string[], params?: Record<string, string>): Promise<JiraIssue[]>;
|
|
87
|
+
update(ticket: string, fields: JiraIssueFields): Promise<void>;
|
|
88
|
+
getProperty(ticket: string, property: string): Promise<unknown>;
|
|
89
|
+
search(query?: JiraSearchQuery): Promise<JiraSearchResponse>;
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../../../../../src/projects.d.ts
|
|
93
|
+
declare function projects(client: RestClient): {
|
|
94
|
+
get(id: string): Promise<JiraProject>;
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../../../../../src/transitions.d.ts
|
|
98
|
+
declare function transitions(client: RestClient): {
|
|
99
|
+
create(ticket: string, statusId: string, fields?: JiraIssueFields): Promise<void>;
|
|
100
|
+
get(ticket: string): Promise<{
|
|
101
|
+
transitions: JiraTransition[];
|
|
102
|
+
}>;
|
|
103
|
+
getResolutions(): Promise<JiraResolution[]>;
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../../../../../src/versions.d.ts
|
|
107
|
+
declare function versions(client: RestClient): {
|
|
108
|
+
create(name: string, project: string, fields?: Partial<JiraVersion>): Promise<JiraVersion>;
|
|
109
|
+
get(version: string, params?: Record<string, string>): Promise<JiraVersion>;
|
|
110
|
+
getMany(versionIds: string[], params?: Record<string, string>): Promise<JiraVersion[]>;
|
|
111
|
+
update(version: string, fields: Partial<JiraVersion>): Promise<JiraVersion>;
|
|
112
|
+
delete(version: string): Promise<void>;
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region ../../../../../src/index.d.ts
|
|
116
|
+
declare function createJiraClient(options: {
|
|
117
|
+
host: string;
|
|
118
|
+
token: string;
|
|
119
|
+
fetch?: typeof fetch;
|
|
120
|
+
/** Structured logger for request/response diagnostics. Defaults to a no-op. */
|
|
121
|
+
logger?: Logger;
|
|
122
|
+
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
123
|
+
errors?: ErrorSink;
|
|
124
|
+
}): {
|
|
125
|
+
issues: {
|
|
126
|
+
create(title: string, type: string, project: string, fields?: JiraIssueFields): Promise<JiraIssue>;
|
|
127
|
+
get(ticket: string, params?: Record<string, string>): Promise<JiraIssue>;
|
|
128
|
+
getMany(tickets: string[], params?: Record<string, string>): Promise<JiraIssue[]>;
|
|
129
|
+
update(ticket: string, fields: JiraIssueFields): Promise<void>;
|
|
130
|
+
getProperty(ticket: string, property: string): Promise<unknown>;
|
|
131
|
+
search(query?: JiraSearchQuery): Promise<JiraSearchResponse>;
|
|
132
|
+
};
|
|
133
|
+
links: {
|
|
134
|
+
create(ticket: string, link: string, type: string): Promise<number>;
|
|
135
|
+
createMany(tickets: string[], link: string, type: string): Promise<IssueLinkResult[]>;
|
|
136
|
+
getLinkTypes(params?: Record<string, string>): Promise<{
|
|
137
|
+
issueLinkTypes: JiraIssueLinkType[];
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
projects: {
|
|
141
|
+
get(id: string): Promise<JiraProject>;
|
|
142
|
+
};
|
|
143
|
+
transitions: {
|
|
144
|
+
create(ticket: string, statusId: string, fields?: JiraIssueFields): Promise<void>;
|
|
145
|
+
get(ticket: string): Promise<{
|
|
146
|
+
transitions: JiraTransition[];
|
|
147
|
+
}>;
|
|
148
|
+
getResolutions(): Promise<JiraResolution[]>;
|
|
149
|
+
};
|
|
150
|
+
versions: {
|
|
151
|
+
create(name: string, project: string, fields?: Partial<JiraVersion>): Promise<JiraVersion>;
|
|
152
|
+
get(version: string, params?: Record<string, string>): Promise<JiraVersion>;
|
|
153
|
+
getMany(versionIds: string[], params?: Record<string, string>): Promise<JiraVersion[]>;
|
|
154
|
+
update(version: string, fields: Partial<JiraVersion>): Promise<JiraVersion>;
|
|
155
|
+
delete(version: string): Promise<void>;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
//#endregion
|
|
159
|
+
export { type IssueLinkResult, type JiraClientOptions, type JiraIssue, type JiraIssueFields, type JiraIssueLinkType, type JiraIssueType, type JiraProject, type JiraResolution, type JiraSearchQuery, type JiraSearchResponse, type JiraTransition, type JiraVersion, createJiraClient, type issues, type links, type projects, type transitions, type versions };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { ProviderApiError, createRestClient } from "@theholocron/http-client";
|
|
2
|
+
//#region ../../../../../src/issues.ts
|
|
3
|
+
function issues(client) {
|
|
4
|
+
return {
|
|
5
|
+
create(title, type, project, fields = {}) {
|
|
6
|
+
return client.request("/issue/", {
|
|
7
|
+
method: "POST",
|
|
8
|
+
body: { fields: {
|
|
9
|
+
project: { key: project },
|
|
10
|
+
summary: title,
|
|
11
|
+
issuetype: { name: type },
|
|
12
|
+
...fields
|
|
13
|
+
} }
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
get(ticket, params) {
|
|
17
|
+
return client.request(`/issue/${ticket}`, { query: params });
|
|
18
|
+
},
|
|
19
|
+
getMany(tickets, params) {
|
|
20
|
+
return Promise.all(tickets.map((t) => this.get(t, params)));
|
|
21
|
+
},
|
|
22
|
+
update(ticket, fields) {
|
|
23
|
+
return client.request(`/issue/${ticket}`, {
|
|
24
|
+
method: "PUT",
|
|
25
|
+
body: { fields }
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
getProperty(ticket, property) {
|
|
29
|
+
return client.request(`/issue/${ticket}/properties/${property}`);
|
|
30
|
+
},
|
|
31
|
+
search(query = {}) {
|
|
32
|
+
const q = {};
|
|
33
|
+
if (query.jql !== void 0) q["jql"] = query.jql;
|
|
34
|
+
if (query.startAt !== void 0) q["startAt"] = String(query.startAt);
|
|
35
|
+
if (query.maxResults !== void 0) q["maxResults"] = String(query.maxResults);
|
|
36
|
+
if (query.fields !== void 0) q["fields"] = query.fields.join(",");
|
|
37
|
+
return client.request("/search", { query: q });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region ../../../../../src/links.ts
|
|
43
|
+
function links(client) {
|
|
44
|
+
return {
|
|
45
|
+
async create(ticket, link, type) {
|
|
46
|
+
try {
|
|
47
|
+
await client.request("/issueLink", {
|
|
48
|
+
method: "POST",
|
|
49
|
+
body: {
|
|
50
|
+
type: { name: type },
|
|
51
|
+
inwardIssue: { key: ticket },
|
|
52
|
+
outwardIssue: { key: link }
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return 201;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err instanceof ProviderApiError && err.status !== void 0 && err.status > 0) return err.status;
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
createMany(tickets, link, type) {
|
|
62
|
+
return Promise.all(tickets.map(async (ticket) => ({
|
|
63
|
+
ticket,
|
|
64
|
+
status: await this.create(ticket, link, type)
|
|
65
|
+
})));
|
|
66
|
+
},
|
|
67
|
+
getLinkTypes(params) {
|
|
68
|
+
return client.request("/issueLinkType", { query: params });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region ../../../../../src/projects.ts
|
|
74
|
+
function projects(client) {
|
|
75
|
+
return { get(id) {
|
|
76
|
+
return client.request(`/project/${id}`, { query: { expand: "issueTypes" } });
|
|
77
|
+
} };
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region ../../../../../src/transitions.ts
|
|
81
|
+
function transitions(client) {
|
|
82
|
+
return {
|
|
83
|
+
create(ticket, statusId, fields = {}) {
|
|
84
|
+
return client.request(`/issue/${ticket}/transitions`, {
|
|
85
|
+
method: "POST",
|
|
86
|
+
body: {
|
|
87
|
+
transition: { id: statusId },
|
|
88
|
+
fields
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
get(ticket) {
|
|
93
|
+
return client.request(`/issue/${ticket}/transitions`);
|
|
94
|
+
},
|
|
95
|
+
getResolutions() {
|
|
96
|
+
return client.request("/resolution");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../../../../../src/versions.ts
|
|
102
|
+
function versions(client) {
|
|
103
|
+
return {
|
|
104
|
+
create(name, project, fields = {}) {
|
|
105
|
+
return client.request("/version", {
|
|
106
|
+
method: "POST",
|
|
107
|
+
body: {
|
|
108
|
+
name,
|
|
109
|
+
project,
|
|
110
|
+
startDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111
|
+
...fields
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
get(version, params) {
|
|
116
|
+
return client.request(`/version/${version}`, { query: params });
|
|
117
|
+
},
|
|
118
|
+
getMany(versionIds, params) {
|
|
119
|
+
return Promise.all(versionIds.map((v) => this.get(v, params)));
|
|
120
|
+
},
|
|
121
|
+
update(version, fields) {
|
|
122
|
+
return client.request(`/version/${version}`, {
|
|
123
|
+
method: "PUT",
|
|
124
|
+
body: fields
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
delete(version) {
|
|
128
|
+
return client.request(`/version/${version}`, { method: "DELETE" });
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region ../../../../../src/index.ts
|
|
134
|
+
function createJiraClient(options) {
|
|
135
|
+
const client = createRestClient({
|
|
136
|
+
baseUrl: options.host,
|
|
137
|
+
token: `Basic ${options.token}`,
|
|
138
|
+
tokenScheme: "apikey",
|
|
139
|
+
apiKeyHeader: "authorization",
|
|
140
|
+
vendor: "Jira",
|
|
141
|
+
fetch: options.fetch,
|
|
142
|
+
logger: options.logger,
|
|
143
|
+
errors: options.errors
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
issues: issues(client),
|
|
147
|
+
links: links(client),
|
|
148
|
+
projects: projects(client),
|
|
149
|
+
transitions: transitions(client),
|
|
150
|
+
versions: versions(client)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { createJiraClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/jira-client",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.1",
|
|
4
4
|
"description": "A TypeScript client for the Jira REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jira",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@theholocron/observability": "^0.3.0",
|
|
36
|
-
"@theholocron/http-client": "^1.32.
|
|
36
|
+
"@theholocron/http-client": "^1.32.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@theholocron/cli": "5.0.0-alpha.79",
|
|
40
40
|
"@theholocron/eslint-config": "^8.4.3",
|
|
41
41
|
"@theholocron/tsconfig": "^8.2.0",
|
|
42
|
-
"@theholocron/tsdown-config": "^8.
|
|
42
|
+
"@theholocron/tsdown-config": "^8.6.1",
|
|
43
43
|
"@theholocron/vitest-config": "^8.2.0",
|
|
44
44
|
"@types/node": "^26.4.1",
|
|
45
45
|
"@vitest/coverage-v8": "^5.0.0",
|