@leitwerk-dev/jira 0.0.0-stage → 0.4.0

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/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
- "name": "@leitwerk-dev/jira",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@leitwerk-dev/jira",
3
+ "version": "0.4.0",
4
+ "type": "module",
5
+ "leitwerk": {
6
+ "extension": {
7
+ "source": "./src/index.ts",
8
+ "import": "./dist/index.js"
9
+ },
10
+ "discover": false
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "source": "./src/index.ts",
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ },
18
+ "./testing": {
19
+ "source": "./src/testing.ts",
20
+ "import": "./dist/testing.js",
21
+ "types": "./dist/testing.d.ts"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
26
+ },
27
+ "dependencies": {
28
+ "@leitwerk-dev/domain": "0.4.0",
29
+ "@leitwerk-dev/process-sdk": "0.4.0",
30
+ "@leitwerk-dev/test-support": "0.4.0",
31
+ "@leitwerk-dev/watcher-utils": "0.4.0",
32
+ "@leitwerk-dev/wiki": "0.4.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.5.1",
36
+ "@types/node": "^26.2.0",
37
+ "@types/markdown-it": "^14.1.2"
38
+ },
39
+ "license": "Apache-2.0",
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "engines": {
44
+ "node": ">=26 <27"
45
+ },
46
+ "files": [
47
+ "dist/**",
48
+ "src/**",
49
+ "!dist/**/*.test.*",
50
+ "!src/**/*.test.ts"
51
+ ],
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/leitwerk-dev/leitwerk.git",
55
+ "directory": "extensions/jira"
56
+ }
57
+ }
package/src/client.ts ADDED
@@ -0,0 +1,590 @@
1
+ import { asUnknownRecord } from "@leitwerk-dev/domain";
2
+
3
+ /** @public */
4
+ export interface JiraProject {
5
+ /** @internal */
6
+ id: string;
7
+
8
+ /** @internal */
9
+ key: string;
10
+
11
+ /** @internal */
12
+ name: string;
13
+ }
14
+
15
+ /** @public */
16
+ export interface JiraComponent {
17
+ /** @internal */
18
+ id: string;
19
+
20
+ /** @internal */
21
+ name: string;
22
+ }
23
+
24
+ /** @public */
25
+ export interface JiraIssue {
26
+ /** @internal */
27
+ id: string;
28
+
29
+ /** @internal */
30
+ key: string;
31
+
32
+ /** @internal */
33
+ fields: {
34
+ /** @internal */
35
+ issuetype?: {
36
+ /** @internal */
37
+ id: string;
38
+ /** @internal */
39
+ name: string;
40
+ /** @internal */
41
+ subtask?: boolean;
42
+ };
43
+ /** @internal */
44
+ parent?: JiraIssueReceipt;
45
+ /** @internal */
46
+ updated?: string;
47
+ /** @internal */
48
+ summary: string;
49
+
50
+ /** @internal */
51
+ description: string | null;
52
+
53
+ /** @internal */
54
+ labels: string[];
55
+
56
+ /** @internal */
57
+ project: JiraProject;
58
+
59
+ /** @internal */
60
+ components: JiraComponent[];
61
+
62
+ /** @internal */
63
+ status: {
64
+ /** @internal */
65
+ id?: string;
66
+ /** @internal */
67
+ name?: string;
68
+ /** @internal */
69
+ statusCategory: {
70
+ /** @internal */
71
+ key: string;
72
+ };
73
+ };
74
+ };
75
+ }
76
+
77
+ /** @public */
78
+ export interface JiraComment {
79
+ /** @internal */
80
+ id: string;
81
+
82
+ /** @internal */
83
+ body: string;
84
+ }
85
+
86
+ /** @internal */
87
+ export interface JiraRemoteLink {
88
+ /** @internal */ id: number;
89
+ /** @internal */ globalId: string;
90
+ /** @internal */ object: {
91
+ /** @internal */ url: string;
92
+ /** @internal */ title: string;
93
+ };
94
+ }
95
+
96
+ /** @internal */
97
+ export interface JiraTransition {
98
+ /** @internal */ id: string;
99
+ /** @internal */ name: string;
100
+ /** @internal */ to: JiraIssue["fields"]["status"];
101
+ }
102
+
103
+ /** @internal */
104
+ export interface JiraCreateField {
105
+ /** @internal */
106
+ name: string;
107
+ /** @internal */
108
+ required: boolean;
109
+ /** @internal */
110
+ hasDefaultValue?: boolean;
111
+ /** @internal */
112
+ schema?: Record<string, unknown>;
113
+ /** @internal */
114
+ allowedValues?: unknown[];
115
+ }
116
+
117
+ /** @internal */
118
+ export interface JiraCreateProject extends JiraProject {
119
+ /** @internal */
120
+ issuetypes: Array<{
121
+ /** @internal */
122
+ id: string;
123
+ /** @internal */
124
+ name: string;
125
+ /** @internal */
126
+ subtask: boolean;
127
+ /** @internal */
128
+ fields: Record<string, JiraCreateField>;
129
+ }>;
130
+ }
131
+
132
+ /** @public */
133
+ export interface JiraClientLike extends Pick<JiraClient, keyof JiraClient> {}
134
+
135
+ /** @internal */
136
+ export interface JiraCreateMetadata {
137
+ /** @internal */ epicLinkField: string | null;
138
+ /** @internal */
139
+ issueTypes: {
140
+ /** @internal */
141
+ id: string;
142
+ /** @internal */
143
+ name: string;
144
+ /** @internal */
145
+ subtask?: boolean;
146
+ /** @internal */
147
+ fields: Record<
148
+ string,
149
+ {
150
+ /** @internal */
151
+ required?: boolean;
152
+ /** @internal */
153
+ hasDefaultValue?: boolean;
154
+ }
155
+ >;
156
+ }[];
157
+ }
158
+
159
+ /** @internal */
160
+ export class JiraRequestError extends Error {
161
+ /** @internal */
162
+ readonly status: number;
163
+ /** @internal */
164
+ constructor(status: number) {
165
+ super(`Jira request failed (${status})`);
166
+ this.status = status;
167
+ }
168
+ }
169
+
170
+ /** @internal */
171
+ export interface JiraIssueReceipt {
172
+ /** @internal */ id: string;
173
+ /** @internal */ key: string;
174
+ }
175
+
176
+ /** @internal */
177
+ export function jiraBaseUrl(raw: string): string {
178
+ const url = new URL(raw);
179
+ if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash)
180
+ throw new Error("Jira base_url must be HTTPS, without credentials, query, or fragment");
181
+ return url.href.replace(/\/+$/, "");
182
+ }
183
+
184
+ /** @internal */
185
+ export function parseJiraProfiles(raw: unknown): Map<
186
+ string,
187
+ {
188
+ /** @internal */
189
+ baseUrl: string;
190
+ /** @internal */
191
+ token: string;
192
+ /** @internal */
193
+ epicLinkField?: string;
194
+ /** @internal */
195
+ project?: string;
196
+ }
197
+ > {
198
+ const profiles = asUnknownRecord(asUnknownRecord(raw)?.profiles) ?? {};
199
+ return new Map(
200
+ Object.entries(profiles).map(([id, value]) => {
201
+ const profile = asUnknownRecord(value);
202
+ if (
203
+ typeof profile?.base_url !== "string" ||
204
+ typeof profile.token !== "string" ||
205
+ !profile.token.trim()
206
+ )
207
+ throw new Error(`Jira profile '${id}' requires base_url and a PAT`);
208
+ const token = profile.token.startsWith("env:")
209
+ ? (process.env[profile.token.slice(4)] ?? "")
210
+ : profile.token;
211
+ if (!token || /[\r\n\0]/.test(token))
212
+ throw new Error(`Jira profile '${id}' requires a valid PAT`);
213
+ if (
214
+ profile.epic_link_field !== undefined &&
215
+ (typeof profile.epic_link_field !== "string" ||
216
+ !/^customfield_\d+$/.test(profile.epic_link_field))
217
+ )
218
+ throw new Error("epic_link_field must identify a Jira custom field");
219
+ if (
220
+ profile.project !== undefined &&
221
+ (typeof profile.project !== "string" || !profile.project.trim())
222
+ )
223
+ throw new Error("project must identify a Jira project by ID or key");
224
+ return [
225
+ id,
226
+ {
227
+ baseUrl: jiraBaseUrl(profile.base_url),
228
+ token,
229
+ ...(typeof profile.project === "string" ? { project: profile.project.trim() } : {}),
230
+ ...(typeof profile.epic_link_field === "string"
231
+ ? { epicLinkField: profile.epic_link_field }
232
+ : {}),
233
+ },
234
+ ];
235
+ }),
236
+ );
237
+ }
238
+ /** Jira Data Center REST v2. Credentials never appear in errors or public fields. @public */
239
+ export class JiraClient {
240
+ /** @internal */
241
+ readonly baseUrl: string;
242
+ #token: string;
243
+ #fetch: typeof fetch;
244
+ #epicLinkField: string | undefined;
245
+
246
+ /** @internal */
247
+ constructor(
248
+ profile: {
249
+ /** @internal */
250
+ baseUrl: string;
251
+ /** @internal */
252
+ token: string;
253
+ /** @internal */
254
+ epicLinkField?: string;
255
+ },
256
+ fetcher: typeof fetch = fetch,
257
+ ) {
258
+ this.#fetch = fetcher;
259
+ this.baseUrl = jiraBaseUrl(profile.baseUrl);
260
+ this.#token = profile.token;
261
+ this.#epicLinkField = profile.epicLinkField;
262
+ }
263
+ async #request<T>(path: string, init: RequestInit = {}): Promise<T> {
264
+ init.signal?.throwIfAborted();
265
+ let response: Response;
266
+ try {
267
+ response = await this.#fetch(`${this.baseUrl}/rest/api/2/${path}`, {
268
+ ...init,
269
+ redirect: "error",
270
+ signal: init.signal
271
+ ? AbortSignal.any([init.signal, AbortSignal.timeout(30_000)])
272
+ : AbortSignal.timeout(30_000),
273
+ headers: {
274
+ Authorization: `Bearer ${this.#token}`,
275
+ Accept: "application/json",
276
+ "Content-Type": "application/json",
277
+ },
278
+ });
279
+ } catch {
280
+ throw new Error("Jira request unavailable");
281
+ }
282
+ if (!response.ok) throw new JiraRequestError(response.status);
283
+ if (response.status === 204) return undefined as T;
284
+ try {
285
+ return (await response.json()) as T;
286
+ } catch {
287
+ throw new Error("Jira returned invalid JSON");
288
+ }
289
+ }
290
+ async #pages<T>(path: string, field: string, signal?: AbortSignal): Promise<T[]> {
291
+ const items: T[] = [];
292
+ let startAt = 0;
293
+ for (;;) {
294
+ const page = await this.#request<Record<string, unknown> | T[]>(
295
+ `${path}${path.includes("?") ? "&" : "?"}startAt=${startAt}&maxResults=100`,
296
+ { signal },
297
+ );
298
+ // Data Center's project and component endpoints may return the complete array.
299
+ if (Array.isArray(page)) return page;
300
+ const batch = page[field];
301
+ if (!Array.isArray(batch)) throw new Error("Jira returned an invalid page");
302
+ const pageStart = page.startAt ?? page.start;
303
+ if (typeof pageStart === "number" && pageStart !== startAt)
304
+ throw new Error("Jira pagination did not advance");
305
+ items.push(...(batch as T[]));
306
+ startAt += batch.length;
307
+ if (
308
+ page.isLast === true ||
309
+ page.last === true ||
310
+ (typeof page.total === "number" && startAt >= page.total)
311
+ )
312
+ return items;
313
+ if (!batch.length) {
314
+ if (typeof page.total === "number" && startAt < page.total)
315
+ throw new Error("Jira returned an incomplete page");
316
+ return items;
317
+ }
318
+ }
319
+ }
320
+
321
+ /** @internal */
322
+ listProjects(signal?: AbortSignal) {
323
+ return this.#pages<JiraProject>("project", "values", signal);
324
+ }
325
+
326
+ /** @internal */
327
+ async listCreateProjects(projectId?: string, signal?: AbortSignal): Promise<JiraCreateProject[]> {
328
+ const projects = projectId
329
+ ? [await this.#request<JiraProject>(`project/${encodeURIComponent(projectId)}`, { signal })]
330
+ : await this.listProjects(signal);
331
+ return Promise.all(
332
+ projects.map(async (project) => {
333
+ const path = `issue/createmeta/${encodeURIComponent(project.id)}/issuetypes`;
334
+ const issueTypes = await this.#pages<
335
+ Omit<JiraCreateProject["issuetypes"][number], "fields">
336
+ >(path, "values", signal);
337
+ return {
338
+ ...project,
339
+ issuetypes: await Promise.all(
340
+ issueTypes
341
+ .filter((issueType) => !issueType.subtask)
342
+ .map(async (issueType) => {
343
+ const fields = await this.#pages<
344
+ JiraCreateField & { /** @internal */ fieldId: string }
345
+ >(`${path}/${encodeURIComponent(issueType.id)}`, "values", signal);
346
+ return {
347
+ ...issueType,
348
+ fields: Object.fromEntries(
349
+ fields.map(({ fieldId, ...field }) => {
350
+ if (typeof fieldId !== "string" || !fieldId)
351
+ throw new Error("Jira returned invalid create field metadata");
352
+ return [fieldId, field];
353
+ }),
354
+ ),
355
+ };
356
+ }),
357
+ ),
358
+ };
359
+ }),
360
+ );
361
+ }
362
+
363
+ /** @internal */
364
+ listProjectIssues(projectId: string, signal?: AbortSignal): Promise<JiraIssue[]> {
365
+ if (!/^\d+$/.test(projectId)) throw new Error("Invalid Jira project ID");
366
+ return this.#pages<JiraIssue>(
367
+ `search?jql=${encodeURIComponent(`project = ${projectId} ORDER BY id ASC`)}&fields=summary,description,labels,project,components,status`,
368
+ "issues",
369
+ signal,
370
+ );
371
+ }
372
+
373
+ /** @internal */
374
+ async createIssue(fields: Record<string, unknown>, signal?: AbortSignal): Promise<JiraIssue> {
375
+ const result = await this.createIssueReceipt(fields, signal);
376
+ return this.getIssue(result.id, signal);
377
+ }
378
+
379
+ /** Return the write receipt without a follow-up read that could obscure a successful POST. @internal */
380
+ createIssueReceipt(
381
+ fields: Record<string, unknown>,
382
+ signal?: AbortSignal,
383
+ ): Promise<JiraIssueReceipt> {
384
+ return this.#request<JiraIssueReceipt>("issue", {
385
+ method: "POST",
386
+ body: JSON.stringify({ fields }),
387
+ signal,
388
+ });
389
+ }
390
+
391
+ /** @internal */
392
+ listComponents(projectId: string) {
393
+ return this.#pages<JiraComponent>(
394
+ `project/${encodeURIComponent(projectId)}/components`,
395
+ "values",
396
+ );
397
+ }
398
+
399
+ /** @internal */
400
+ searchIssues(projectIds: readonly string[], triggerLabel?: string) {
401
+ if (!projectIds.length || projectIds.some((id) => !/^\d+$/.test(id)))
402
+ throw new Error("Select explicit Jira project IDs");
403
+ const jql = `project in (${projectIds.join(",")}) AND labels = ${JSON.stringify(jiraTriggerLabel(triggerLabel))} AND (labels not in ("leitwerk-done")) AND statusCategory != Done ORDER BY id ASC`;
404
+ return this.#pages<JiraIssue>(
405
+ `search?jql=${encodeURIComponent(jql)}&fields=summary,description,labels,project,components,status`,
406
+ "issues",
407
+ );
408
+ }
409
+
410
+ /** @internal */
411
+ getIssue(id: string, signal?: AbortSignal) {
412
+ return this.#request<JiraIssue>(`issue/${encodeURIComponent(id)}?fields=*all`, { signal });
413
+ }
414
+
415
+ async #resolveEpicLinkField(): Promise<string | null> {
416
+ if (this.#epicLinkField) return this.#epicLinkField;
417
+ const fields = await this.#request<{ id: string; schema?: { custom?: string } }[]>("field");
418
+ const matches = fields.filter(
419
+ (field) => field.schema?.custom === "com.pyxis.greenhopper.jira:gh-epic-link",
420
+ );
421
+ if (!matches.length) return null;
422
+ if (matches.length !== 1)
423
+ throw new Error(
424
+ "Configure this Jira profile's epic_link_field; Epic Link discovery is ambiguous",
425
+ );
426
+ this.#epicLinkField = matches[0].id;
427
+ return this.#epicLinkField;
428
+ }
429
+
430
+ /** @internal */
431
+ async getEpic(issue: JiraIssue): Promise<JiraIssue | null> {
432
+ if (issue.fields.issuetype?.name.toLowerCase() === "epic") return issue;
433
+ const field = await this.#resolveEpicLinkField();
434
+ if (!field) return null;
435
+ const key = (issue.fields as unknown as Record<string, unknown>)[field];
436
+ return typeof key === "string" && key ? this.getIssue(key) : null;
437
+ }
438
+
439
+ /** @internal */
440
+ searchSplitIssues(projectIds: readonly string[]): Promise<JiraIssue[]> {
441
+ if (!projectIds.length || projectIds.some((id) => !/^\d+$/.test(id)))
442
+ throw new Error("Select explicit Jira project IDs");
443
+ const jql = `project in (${projectIds.join(",")}) AND labels in ("leitwerk-issue-split", "leitwerk-epic-split") AND issuetype not in subTaskIssueTypes() AND statusCategory != Done ORDER BY id ASC`;
444
+ return this.#pages(`search?jql=${encodeURIComponent(jql)}&fields=*all`, "issues");
445
+ }
446
+
447
+ /** @internal */
448
+ async createMetadata(projectId: string, includeEpicLink = true): Promise<JiraCreateMetadata> {
449
+ const metadata = await this.#request<{
450
+ projects: { id: string; issuetypes: JiraCreateMetadata["issueTypes"] }[];
451
+ }>(
452
+ `issue/createmeta?projectIds=${encodeURIComponent(projectId)}&expand=projects.issuetypes.fields`,
453
+ );
454
+ const project = metadata.projects.find((candidate) => candidate.id === projectId);
455
+ if (!project) throw new Error("Jira issue creation is unavailable for this project");
456
+ const epicLinkField = includeEpicLink ? await this.#resolveEpicLinkField() : null;
457
+ if (includeEpicLink && !epicLinkField)
458
+ throw new Error("Splitting a Jira epic requires an Epic Link field");
459
+ return { epicLinkField, issueTypes: project.issuetypes };
460
+ }
461
+
462
+ /** @internal */
463
+ async findSplitIssue(projectId: string, marker: string): Promise<JiraIssue | null> {
464
+ if (!/^\d+$/.test(projectId) || !/^leitwerk-split-[a-f0-9]{64}$/.test(marker))
465
+ throw new Error("Invalid split ticket identity");
466
+ const jql = `project = ${projectId} AND labels = "${marker}" ORDER BY id ASC`;
467
+ const matches = await this.#pages<JiraIssue>(
468
+ `search?jql=${encodeURIComponent(jql)}&fields=*all`,
469
+ "issues",
470
+ );
471
+ if (matches.length > 1)
472
+ throw new Error(
473
+ "Multiple Jira tickets share the split identity; operator reconciliation required",
474
+ );
475
+ return matches[0] ?? null;
476
+ }
477
+
478
+ /** @internal */
479
+ listComments(id: string) {
480
+ return this.#pages<JiraComment>(`issue/${encodeURIComponent(id)}/comment`, "comments");
481
+ }
482
+
483
+ /** @internal */
484
+ listRemoteLinks(id: string, signal?: AbortSignal) {
485
+ return this.#request<JiraRemoteLink[]>(`issue/${encodeURIComponent(id)}/remotelink`, {
486
+ signal,
487
+ });
488
+ }
489
+
490
+ /** @internal */
491
+ upsertRemoteLink(
492
+ id: string,
493
+ link: Omit<JiraRemoteLink, "id">,
494
+ signal?: AbortSignal,
495
+ ): Promise<Pick<JiraRemoteLink, "id">> {
496
+ return this.#request<Pick<JiraRemoteLink, "id">>(`issue/${encodeURIComponent(id)}/remotelink`, {
497
+ method: "POST",
498
+ body: JSON.stringify(link),
499
+ signal,
500
+ });
501
+ }
502
+
503
+ /** @internal */
504
+ async listTransitions(id: string, signal?: AbortSignal): Promise<JiraTransition[]> {
505
+ const result = await this.#request<{ transitions: JiraTransition[] }>(
506
+ `issue/${encodeURIComponent(id)}/transitions`,
507
+ { signal },
508
+ );
509
+ return result.transitions;
510
+ }
511
+
512
+ /** @internal */
513
+ transitionIssue(id: string, transitionId: string, signal?: AbortSignal) {
514
+ return this.#request<void>(`issue/${encodeURIComponent(id)}/transitions`, {
515
+ method: "POST",
516
+ body: JSON.stringify({ transition: { id: transitionId } }),
517
+ signal,
518
+ });
519
+ }
520
+
521
+ /** @internal */
522
+ addComment(id: string, body: string) {
523
+ return this.#request<JiraComment>(`issue/${encodeURIComponent(id)}/comment`, {
524
+ method: "POST",
525
+ body: JSON.stringify({ body }),
526
+ });
527
+ }
528
+
529
+ /** @internal */
530
+ updateLabels(id: string, remove: string[], add: string[]) {
531
+ return this.#request<void>(`issue/${encodeURIComponent(id)}`, {
532
+ method: "PUT",
533
+ body: JSON.stringify({
534
+ update: {
535
+ labels: [
536
+ ...remove.map((value) => ({ remove: value })),
537
+ ...add.map((value) => ({ add: value })),
538
+ ],
539
+ },
540
+ }),
541
+ });
542
+ }
543
+ }
544
+
545
+ /** Resolve and validate the change trigger; absent values preserve existing runs. @internal */
546
+ export function jiraTriggerLabel(value: unknown = undefined): string {
547
+ if (value === undefined) return "use-leitwerk";
548
+ if (typeof value !== "string" || !/^[A-Za-z0-9_.-]{1,255}$/.test(value))
549
+ throw new Error(
550
+ "Jira trigger label must contain only letters, digits, dots, underscores or hyphens",
551
+ );
552
+ return value;
553
+ }
554
+
555
+ /** @public */
556
+ export const jiraEligible = (issue: JiraIssue, triggerLabel?: string) =>
557
+ issue.fields.labels.includes(jiraTriggerLabel(triggerLabel)) &&
558
+ !issue.fields.labels.includes("leitwerk-done") &&
559
+ issue.fields.status.statusCategory.key !== "done";
560
+ /** Installation context paths and immutable issue IDs define launch identity. @public */
561
+ export const jiraIssueExternalId = (baseUrl: string, id: string) =>
562
+ `jira:${JSON.stringify([jiraBaseUrl(baseUrl), id])}`;
563
+
564
+ /** @internal */
565
+ export const jiraIsEpic = (issue: JiraIssue) =>
566
+ issue.fields.issuetype?.name.toLowerCase() === "epic";
567
+
568
+ /** @internal */
569
+ export const jiraSplitEligible = (issue: JiraIssue) =>
570
+ Boolean(issue.fields.issuetype?.id) &&
571
+ issue.fields.issuetype?.subtask !== true &&
572
+ issue.fields.status.statusCategory.key !== "done" &&
573
+ issue.fields.labels.some((label) =>
574
+ ["leitwerk-issue-split", "leitwerk-epic-split"].includes(label),
575
+ );
576
+
577
+ /** @internal */
578
+ export async function jiraSplitChildMatches(
579
+ client: JiraClientLike,
580
+ issue: JiraIssue,
581
+ sourceIssueId: string,
582
+ relationship: "epic" | "subtask",
583
+ ): Promise<boolean> {
584
+ if (relationship === "subtask")
585
+ return issue.fields.issuetype?.subtask === true && issue.fields.parent?.id === sourceIssueId;
586
+ return (
587
+ issue.fields.issuetype?.subtask !== true &&
588
+ (await client.getEpic?.(issue))?.id === sourceIssueId
589
+ );
590
+ }