cyrus-linear-event-transport 0.2.2 → 0.2.4
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/LinearEventTransport.d.ts +10 -4
- package/dist/LinearEventTransport.d.ts.map +1 -1
- package/dist/LinearEventTransport.js +28 -11
- package/dist/LinearEventTransport.js.map +1 -1
- package/dist/LinearIssueTrackerService.d.ts +175 -0
- package/dist/LinearIssueTrackerService.d.ts.map +1 -0
- package/dist/LinearIssueTrackerService.js +536 -0
- package/dist/LinearIssueTrackerService.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { IAgentEventTransport } from "cyrus-core";
|
|
2
3
|
import type { LinearEventTransportConfig, LinearEventTransportEvents } from "./types.js";
|
|
3
4
|
export declare interface LinearEventTransport {
|
|
4
5
|
on<K extends keyof LinearEventTransportEvents>(event: K, listener: LinearEventTransportEvents[K]): this;
|
|
@@ -7,12 +8,17 @@ export declare interface LinearEventTransport {
|
|
|
7
8
|
/**
|
|
8
9
|
* LinearEventTransport - Handles Linear webhook event delivery
|
|
9
10
|
*
|
|
10
|
-
* This class
|
|
11
|
+
* This class implements IAgentEventTransport to provide a platform-agnostic
|
|
12
|
+
* interface for handling Linear webhooks with Linear-specific verification.
|
|
13
|
+
*
|
|
14
|
+
* It registers a POST /webhook endpoint with a Fastify server
|
|
11
15
|
* and verifies incoming webhooks using either:
|
|
12
|
-
* 1.
|
|
13
|
-
* 2.
|
|
16
|
+
* 1. "direct" mode: Verifies Linear's webhook signature
|
|
17
|
+
* 2. "proxy" mode: Verifies Bearer token authentication
|
|
18
|
+
*
|
|
19
|
+
* The class emits "event" events with AgentEvent (LinearWebhookPayload) data.
|
|
14
20
|
*/
|
|
15
|
-
export declare class LinearEventTransport extends EventEmitter {
|
|
21
|
+
export declare class LinearEventTransport extends EventEmitter implements IAgentEventTransport {
|
|
16
22
|
private config;
|
|
17
23
|
private linearWebhookClient;
|
|
18
24
|
constructor(config: LinearEventTransportConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinearEventTransport.d.ts","sourceRoot":"","sources":["../src/LinearEventTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"LinearEventTransport.d.ts","sourceRoot":"","sources":["../src/LinearEventTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,KAAK,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,WAAW,oBAAoB;IAC5C,EAAE,CAAC,CAAC,SAAS,MAAM,0BAA0B,EAC5C,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACrC,IAAI,CAAC;IACR,IAAI,CAAC,CAAC,SAAS,MAAM,0BAA0B,EAC9C,KAAK,EAAE,CAAC,EACR,GAAG,IAAI,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,GAChD,OAAO,CAAC;CACX;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,oBACZ,SAAQ,YACR,YAAW,oBAAoB;IAE/B,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,mBAAmB,CAAoC;gBAEnD,MAAM,EAAE,0BAA0B;IAU9C;;OAEG;IACH,QAAQ,IAAI,IAAI;IA4BhB;;OAEG;YACW,mBAAmB;IA2CjC;;OAEG;YACW,kBAAkB;CAmChC"}
|
|
@@ -3,10 +3,15 @@ import { LinearWebhookClient, } from "@linear/sdk/webhooks";
|
|
|
3
3
|
/**
|
|
4
4
|
* LinearEventTransport - Handles Linear webhook event delivery
|
|
5
5
|
*
|
|
6
|
-
* This class
|
|
6
|
+
* This class implements IAgentEventTransport to provide a platform-agnostic
|
|
7
|
+
* interface for handling Linear webhooks with Linear-specific verification.
|
|
8
|
+
*
|
|
9
|
+
* It registers a POST /webhook endpoint with a Fastify server
|
|
7
10
|
* and verifies incoming webhooks using either:
|
|
8
|
-
* 1.
|
|
9
|
-
* 2.
|
|
11
|
+
* 1. "direct" mode: Verifies Linear's webhook signature
|
|
12
|
+
* 2. "proxy" mode: Verifies Bearer token authentication
|
|
13
|
+
*
|
|
14
|
+
* The class emits "event" events with AgentEvent (LinearWebhookPayload) data.
|
|
10
15
|
*/
|
|
11
16
|
export class LinearEventTransport extends EventEmitter {
|
|
12
17
|
config;
|
|
@@ -34,8 +39,12 @@ export class LinearEventTransport extends EventEmitter {
|
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
catch (error) {
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
const err = new Error("[LinearEventTransport] Webhook error");
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
err.cause = error;
|
|
45
|
+
}
|
|
46
|
+
console.error(err);
|
|
47
|
+
this.emit("error", err);
|
|
39
48
|
reply.code(500).send({ error: "Internal server error" });
|
|
40
49
|
}
|
|
41
50
|
});
|
|
@@ -63,13 +72,17 @@ export class LinearEventTransport extends EventEmitter {
|
|
|
63
72
|
reply.code(401).send({ error: "Invalid webhook signature" });
|
|
64
73
|
return;
|
|
65
74
|
}
|
|
66
|
-
// Emit
|
|
67
|
-
this.emit("
|
|
75
|
+
// Emit "event" for IAgentEventTransport compatibility
|
|
76
|
+
this.emit("event", request.body);
|
|
68
77
|
// Send success response
|
|
69
78
|
reply.code(200).send({ success: true });
|
|
70
79
|
}
|
|
71
80
|
catch (error) {
|
|
72
|
-
|
|
81
|
+
const err = new Error("[LinearEventTransport] Direct webhook verification failed");
|
|
82
|
+
if (error instanceof Error) {
|
|
83
|
+
err.cause = error;
|
|
84
|
+
}
|
|
85
|
+
console.error(err);
|
|
73
86
|
reply.code(401).send({ error: "Invalid webhook signature" });
|
|
74
87
|
}
|
|
75
88
|
}
|
|
@@ -90,13 +103,17 @@ export class LinearEventTransport extends EventEmitter {
|
|
|
90
103
|
return;
|
|
91
104
|
}
|
|
92
105
|
try {
|
|
93
|
-
// Emit
|
|
94
|
-
this.emit("
|
|
106
|
+
// Emit "event" for IAgentEventTransport compatibility
|
|
107
|
+
this.emit("event", request.body);
|
|
95
108
|
// Send success response
|
|
96
109
|
reply.code(200).send({ success: true });
|
|
97
110
|
}
|
|
98
111
|
catch (error) {
|
|
99
|
-
|
|
112
|
+
const err = new Error("[LinearEventTransport] Proxy webhook processing failed");
|
|
113
|
+
if (error instanceof Error) {
|
|
114
|
+
err.cause = error;
|
|
115
|
+
}
|
|
116
|
+
console.error(err);
|
|
100
117
|
reply.code(500).send({ error: "Failed to process webhook" });
|
|
101
118
|
}
|
|
102
119
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinearEventTransport.js","sourceRoot":"","sources":["../src/LinearEventTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACN,mBAAmB,GAEnB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"LinearEventTransport.js","sourceRoot":"","sources":["../src/LinearEventTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACN,mBAAmB,GAEnB,MAAM,sBAAsB,CAAC;AAmB9B;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,oBACZ,SAAQ,YAAY;IAGZ,MAAM,CAA6B;IACnC,mBAAmB,GAA+B,IAAI,CAAC;IAE/D,YAAY,MAAkC;QAC7C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K,CAAC,GAAG,CAAC,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear-specific implementation of IIssueTrackerService.
|
|
3
|
+
*
|
|
4
|
+
* This adapter wraps the @linear/sdk LinearClient to provide a platform-agnostic
|
|
5
|
+
* interface for issue tracking operations. It transforms Linear-specific types
|
|
6
|
+
* to the platform-agnostic types defined in ../types.ts.
|
|
7
|
+
*
|
|
8
|
+
* @module issue-tracker/adapters/LinearIssueTrackerService
|
|
9
|
+
*/
|
|
10
|
+
import type { LinearClient } from "@linear/sdk";
|
|
11
|
+
import type { AgentActivityCreateInput, AgentActivityPayload, AgentEventTransportConfig, AgentSessionCreateOnCommentInput, AgentSessionCreateOnIssueInput, Comment, CommentCreateInput, CommentWithAttachments, Connection, FetchChildrenOptions, FileUploadRequest, FileUploadResponse, IAgentEventTransport, IIssueTrackerService, Issue, IssueUpdateInput, IssueWithChildren, Label, PaginationOptions, Team, User, WorkflowState } from "cyrus-core";
|
|
12
|
+
/**
|
|
13
|
+
* Linear implementation of IIssueTrackerService.
|
|
14
|
+
*
|
|
15
|
+
* This class wraps the Linear SDK's LinearClient and provides a platform-agnostic
|
|
16
|
+
* interface for all issue tracking operations. It handles type conversions between
|
|
17
|
+
* Linear-specific types and platform-agnostic types.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const linearClient = new LinearClient({ accessToken: 'your-token' });
|
|
22
|
+
* const service = new LinearIssueTrackerService(linearClient);
|
|
23
|
+
*
|
|
24
|
+
* // Fetch an issue
|
|
25
|
+
* const issue = await service.fetchIssue('TEAM-123');
|
|
26
|
+
*
|
|
27
|
+
* // Create a comment
|
|
28
|
+
* const comment = await service.createComment(issue.id, {
|
|
29
|
+
* body: 'This is a comment'
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class LinearIssueTrackerService implements IIssueTrackerService {
|
|
34
|
+
private readonly linearClient;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new LinearIssueTrackerService.
|
|
37
|
+
*
|
|
38
|
+
* @param linearClient - Configured LinearClient instance
|
|
39
|
+
*/
|
|
40
|
+
constructor(linearClient: LinearClient);
|
|
41
|
+
/**
|
|
42
|
+
* Fetch a single issue by ID or identifier.
|
|
43
|
+
*/
|
|
44
|
+
fetchIssue(idOrIdentifier: string): Promise<Issue>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetch child issues (sub-issues) for a parent issue.
|
|
47
|
+
*/
|
|
48
|
+
fetchIssueChildren(issueId: string, options?: FetchChildrenOptions): Promise<IssueWithChildren>;
|
|
49
|
+
/**
|
|
50
|
+
* Update an issue's properties.
|
|
51
|
+
*/
|
|
52
|
+
updateIssue(issueId: string, updates: IssueUpdateInput): Promise<Issue>;
|
|
53
|
+
/**
|
|
54
|
+
* Fetch attachments for an issue.
|
|
55
|
+
*
|
|
56
|
+
* Uses the Linear SDK to fetch native attachments (typically external links
|
|
57
|
+
* to Sentry errors, Datadog reports, etc.)
|
|
58
|
+
*/
|
|
59
|
+
fetchIssueAttachments(issueId: string): Promise<Array<{
|
|
60
|
+
title: string;
|
|
61
|
+
url: string;
|
|
62
|
+
}>>;
|
|
63
|
+
/**
|
|
64
|
+
* Fetch comments for an issue with optional pagination.
|
|
65
|
+
*/
|
|
66
|
+
fetchComments(issueId: string, options?: PaginationOptions): Promise<Connection<Comment>>;
|
|
67
|
+
/**
|
|
68
|
+
* Fetch a single comment by ID.
|
|
69
|
+
*/
|
|
70
|
+
fetchComment(commentId: string): Promise<Comment>;
|
|
71
|
+
/**
|
|
72
|
+
* Fetch a comment with attachments.
|
|
73
|
+
*
|
|
74
|
+
* @param commentId - Comment ID to fetch
|
|
75
|
+
* @returns Promise resolving to comment with attachments
|
|
76
|
+
* @throws Error if comment not found or request fails
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* **LIMITATION**: This method currently returns an empty `attachments` array
|
|
80
|
+
* because Linear's GraphQL API does not expose comment attachment metadata
|
|
81
|
+
* through their SDK or documented API endpoints.
|
|
82
|
+
*
|
|
83
|
+
* This is expected behavior, not a bug. Issue attachments (via `fetchIssueAttachments`)
|
|
84
|
+
* work correctly - only comment attachments are unavailable from the Linear API.
|
|
85
|
+
*
|
|
86
|
+
* If you need comment attachments, consider:
|
|
87
|
+
* - Using issue attachments instead (`fetchIssueAttachments`)
|
|
88
|
+
* - Parsing attachment URLs from comment body markdown
|
|
89
|
+
* - Waiting for Linear to expose this data in their API
|
|
90
|
+
*
|
|
91
|
+
* Implementation detail: The returned comment object is a Linear SDK Comment
|
|
92
|
+
* with an empty `attachments` array property added.
|
|
93
|
+
*/
|
|
94
|
+
fetchCommentWithAttachments(commentId: string): Promise<CommentWithAttachments>;
|
|
95
|
+
/**
|
|
96
|
+
* Create a comment on an issue.
|
|
97
|
+
*/
|
|
98
|
+
createComment(issueId: string, input: CommentCreateInput): Promise<Comment>;
|
|
99
|
+
/**
|
|
100
|
+
* Fetch all teams in the workspace/organization.
|
|
101
|
+
*/
|
|
102
|
+
fetchTeams(options?: PaginationOptions): Promise<Connection<Team>>;
|
|
103
|
+
/**
|
|
104
|
+
* Fetch a single team by ID or key.
|
|
105
|
+
*/
|
|
106
|
+
fetchTeam(idOrKey: string): Promise<Team>;
|
|
107
|
+
/**
|
|
108
|
+
* Fetch all issue labels in the workspace/organization.
|
|
109
|
+
*/
|
|
110
|
+
fetchLabels(options?: PaginationOptions): Promise<Connection<Label>>;
|
|
111
|
+
/**
|
|
112
|
+
* Fetch a single label by ID or name.
|
|
113
|
+
*/
|
|
114
|
+
fetchLabel(idOrName: string): Promise<Label>;
|
|
115
|
+
/**
|
|
116
|
+
* Fetch label names for a specific issue.
|
|
117
|
+
*/
|
|
118
|
+
getIssueLabels(issueId: string): Promise<string[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Fetch workflow states for a team.
|
|
121
|
+
*/
|
|
122
|
+
fetchWorkflowStates(teamId: string, options?: PaginationOptions): Promise<Connection<WorkflowState>>;
|
|
123
|
+
/**
|
|
124
|
+
* Fetch a single workflow state by ID.
|
|
125
|
+
*/
|
|
126
|
+
fetchWorkflowState(stateId: string): Promise<WorkflowState>;
|
|
127
|
+
/**
|
|
128
|
+
* Fetch a user by ID.
|
|
129
|
+
*/
|
|
130
|
+
fetchUser(userId: string): Promise<User>;
|
|
131
|
+
/**
|
|
132
|
+
* Fetch the current authenticated user.
|
|
133
|
+
*/
|
|
134
|
+
fetchCurrentUser(): Promise<User>;
|
|
135
|
+
/**
|
|
136
|
+
* Create an agent session on an issue.
|
|
137
|
+
* Uses native SDK method - direct passthrough to Linear SDK.
|
|
138
|
+
*/
|
|
139
|
+
createAgentSessionOnIssue(input: AgentSessionCreateOnIssueInput): import("@linear/sdk").LinearFetch<import("@linear/sdk").AgentSessionPayload>;
|
|
140
|
+
/**
|
|
141
|
+
* Create an agent session on a comment thread.
|
|
142
|
+
* Uses native SDK method - direct passthrough to Linear SDK.
|
|
143
|
+
*/
|
|
144
|
+
createAgentSessionOnComment(input: AgentSessionCreateOnCommentInput): import("@linear/sdk").LinearFetch<import("@linear/sdk").AgentSessionPayload>;
|
|
145
|
+
/**
|
|
146
|
+
* Fetch an agent session by ID.
|
|
147
|
+
* Uses native SDK method - direct passthrough to Linear SDK.
|
|
148
|
+
*/
|
|
149
|
+
fetchAgentSession(sessionId: string): import("@linear/sdk").LinearFetch<import("@linear/sdk").AgentSession>;
|
|
150
|
+
/**
|
|
151
|
+
* Post an agent activity to an agent session.
|
|
152
|
+
* Signature matches Linear SDK's createAgentActivity exactly.
|
|
153
|
+
*/
|
|
154
|
+
createAgentActivity(input: AgentActivityCreateInput): Promise<AgentActivityPayload>;
|
|
155
|
+
/**
|
|
156
|
+
* Request a file upload URL from the platform.
|
|
157
|
+
*/
|
|
158
|
+
requestFileUpload(request: FileUploadRequest): Promise<FileUploadResponse>;
|
|
159
|
+
/**
|
|
160
|
+
* Get the platform type identifier.
|
|
161
|
+
*/
|
|
162
|
+
getPlatformType(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Get the platform's API version or other metadata.
|
|
165
|
+
*/
|
|
166
|
+
getPlatformMetadata(): Record<string, unknown>;
|
|
167
|
+
/**
|
|
168
|
+
* Create an event transport for receiving Linear webhook events.
|
|
169
|
+
*
|
|
170
|
+
* @param config - Transport configuration
|
|
171
|
+
* @returns Linear event transport implementation
|
|
172
|
+
*/
|
|
173
|
+
createEventTransport(config: AgentEventTransportConfig): IAgentEventTransport;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=LinearIssueTrackerService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearIssueTrackerService.d.ts","sourceRoot":"","sources":["../src/LinearIssueTrackerService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EACX,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,8BAA8B,EAC9B,OAAO,EACP,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,EACL,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,yBAA0B,YAAW,oBAAoB;IACrE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C;;;;OAIG;gBACS,YAAY,EAAE,YAAY;IAQtC;;OAEG;IACG,UAAU,CAAC,c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AC;IAIlD;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAoBxD;;OAEG;IACG,mBAAmB,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IA+BrC;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAQjE;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQvC;;;OAGG;IACH,yBAAyB,CAAC,KAAK,EAAE,8BAA8B;IAI/D;;;OAGG;IACH,2BAA2B,CAAC,KAAK,EAAE,gCAAgC;IAInE;;;OAGG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM;IAQnC;;;OAGG;IACG,mBAAmB,CACxB,KAAK,EAAE,wBAAwB,GAC7B,OAAO,CAAC,oBAAoB,CAAC;IAQhC;;OAEG;IACG,iBAAiB,CACtB,OAAO,EAAE,iBAAiB,GACxB,OAAO,CAAC,kBAAkB,CAAC;IAmD9B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAY9C;;;;;OAKG;IACH,oBAAoB,CACnB,MAAM,EAAE,yBAAyB,GAC/B,oBAAoB;CAWvB"}
|
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear-specific implementation of IIssueTrackerService.
|
|
3
|
+
*
|
|
4
|
+
* This adapter wraps the @linear/sdk LinearClient to provide a platform-agnostic
|
|
5
|
+
* interface for issue tracking operations. It transforms Linear-specific types
|
|
6
|
+
* to the platform-agnostic types defined in ../types.ts.
|
|
7
|
+
*
|
|
8
|
+
* @module issue-tracker/adapters/LinearIssueTrackerService
|
|
9
|
+
*/
|
|
10
|
+
import { LinearEventTransport } from "./LinearEventTransport.js";
|
|
11
|
+
/**
|
|
12
|
+
* Linear implementation of IIssueTrackerService.
|
|
13
|
+
*
|
|
14
|
+
* This class wraps the Linear SDK's LinearClient and provides a platform-agnostic
|
|
15
|
+
* interface for all issue tracking operations. It handles type conversions between
|
|
16
|
+
* Linear-specific types and platform-agnostic types.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const linearClient = new LinearClient({ accessToken: 'your-token' });
|
|
21
|
+
* const service = new LinearIssueTrackerService(linearClient);
|
|
22
|
+
*
|
|
23
|
+
* // Fetch an issue
|
|
24
|
+
* const issue = await service.fetchIssue('TEAM-123');
|
|
25
|
+
*
|
|
26
|
+
* // Create a comment
|
|
27
|
+
* const comment = await service.createComment(issue.id, {
|
|
28
|
+
* body: 'This is a comment'
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class LinearIssueTrackerService {
|
|
33
|
+
linearClient;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new LinearIssueTrackerService.
|
|
36
|
+
*
|
|
37
|
+
* @param linearClient - Configured LinearClient instance
|
|
38
|
+
*/
|
|
39
|
+
constructor(linearClient) {
|
|
40
|
+
this.linearClient = linearClient;
|
|
41
|
+
}
|
|
42
|
+
// ========================================================================
|
|
43
|
+
// ISSUE OPERATIONS
|
|
44
|
+
// ========================================================================
|
|
45
|
+
/**
|
|
46
|
+
* Fetch a single issue by ID or identifier.
|
|
47
|
+
*/
|
|
48
|
+
async fetchIssue(idOrIdentifier) {
|
|
49
|
+
return await this.linearClient.issue(idOrIdentifier);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Fetch child issues (sub-issues) for a parent issue.
|
|
53
|
+
*/
|
|
54
|
+
async fetchIssueChildren(issueId, options) {
|
|
55
|
+
try {
|
|
56
|
+
const parentIssue = await this.linearClient.issue(issueId);
|
|
57
|
+
// Build filter based on options
|
|
58
|
+
const filter = {};
|
|
59
|
+
if (options?.includeCompleted === false) {
|
|
60
|
+
filter.state = { type: { neq: "completed" } };
|
|
61
|
+
}
|
|
62
|
+
if (options?.includeArchived === false) {
|
|
63
|
+
filter.archivedAt = { null: true };
|
|
64
|
+
}
|
|
65
|
+
// Merge with additional filters
|
|
66
|
+
if (options?.filter) {
|
|
67
|
+
Object.assign(filter, options.filter);
|
|
68
|
+
}
|
|
69
|
+
// Fetch children with filter
|
|
70
|
+
const childrenConnection = await parentIssue.children({
|
|
71
|
+
first: options?.limit ?? 50,
|
|
72
|
+
filter,
|
|
73
|
+
});
|
|
74
|
+
const children = childrenConnection.nodes ?? [];
|
|
75
|
+
// Return issue with children array directly from Linear SDK
|
|
76
|
+
// Cast to IssueWithChildren since Linear SDK types are compatible
|
|
77
|
+
return Object.assign(parentIssue, {
|
|
78
|
+
children,
|
|
79
|
+
childCount: children.length,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const err = new Error(`Failed to fetch children for issue ${issueId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
84
|
+
if (error instanceof Error) {
|
|
85
|
+
err.cause = error;
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Update an issue's properties.
|
|
92
|
+
*/
|
|
93
|
+
async updateIssue(issueId, updates) {
|
|
94
|
+
try {
|
|
95
|
+
const updatePayload = await this.linearClient.updateIssue(issueId, updates);
|
|
96
|
+
if (!updatePayload.success) {
|
|
97
|
+
throw new Error("Linear API returned success=false");
|
|
98
|
+
}
|
|
99
|
+
// Fetch the updated issue
|
|
100
|
+
const updatedIssue = await updatePayload.issue;
|
|
101
|
+
if (!updatedIssue) {
|
|
102
|
+
throw new Error("Updated issue not returned from Linear API");
|
|
103
|
+
}
|
|
104
|
+
return updatedIssue;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const err = new Error(`Failed to update issue ${issueId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
108
|
+
if (error instanceof Error) {
|
|
109
|
+
err.cause = error;
|
|
110
|
+
}
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetch attachments for an issue.
|
|
116
|
+
*
|
|
117
|
+
* Uses the Linear SDK to fetch native attachments (typically external links
|
|
118
|
+
* to Sentry errors, Datadog reports, etc.)
|
|
119
|
+
*/
|
|
120
|
+
async fetchIssueAttachments(issueId) {
|
|
121
|
+
try {
|
|
122
|
+
const issue = await this.linearClient.issue(issueId);
|
|
123
|
+
if (!issue) {
|
|
124
|
+
throw new Error(`Issue ${issueId} not found`);
|
|
125
|
+
}
|
|
126
|
+
// Call the Linear SDK's attachments() method which returns a Connection
|
|
127
|
+
const attachmentsConnection = await issue.attachments();
|
|
128
|
+
// Extract title and url from each attachment node
|
|
129
|
+
return attachmentsConnection.nodes.map((attachment) => ({
|
|
130
|
+
title: attachment.title || "Untitled attachment",
|
|
131
|
+
url: attachment.url,
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const err = new Error(`Failed to fetch attachments for issue ${issueId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
136
|
+
if (error instanceof Error) {
|
|
137
|
+
err.cause = error;
|
|
138
|
+
}
|
|
139
|
+
throw err;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// ========================================================================
|
|
143
|
+
// COMMENT OPERATIONS
|
|
144
|
+
// ========================================================================
|
|
145
|
+
/**
|
|
146
|
+
* Fetch comments for an issue with optional pagination.
|
|
147
|
+
*/
|
|
148
|
+
async fetchComments(issueId, options) {
|
|
149
|
+
try {
|
|
150
|
+
const issue = await this.linearClient.issue(issueId);
|
|
151
|
+
const commentsConnection = await issue.comments({
|
|
152
|
+
first: options?.first ?? 50,
|
|
153
|
+
after: options?.after,
|
|
154
|
+
before: options?.before,
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
nodes: commentsConnection.nodes ?? [],
|
|
158
|
+
pageInfo: commentsConnection.pageInfo
|
|
159
|
+
? {
|
|
160
|
+
hasNextPage: commentsConnection.pageInfo.hasNextPage,
|
|
161
|
+
hasPreviousPage: commentsConnection.pageInfo.hasPreviousPage,
|
|
162
|
+
startCursor: commentsConnection.pageInfo.startCursor,
|
|
163
|
+
endCursor: commentsConnection.pageInfo.endCursor,
|
|
164
|
+
}
|
|
165
|
+
: undefined,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const err = new Error(`Failed to fetch comments for issue ${issueId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
+
if (error instanceof Error) {
|
|
171
|
+
err.cause = error;
|
|
172
|
+
}
|
|
173
|
+
throw err;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Fetch a single comment by ID.
|
|
178
|
+
*/
|
|
179
|
+
async fetchComment(commentId) {
|
|
180
|
+
return await this.linearClient.comment({ id: commentId });
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Fetch a comment with attachments.
|
|
184
|
+
*
|
|
185
|
+
* @param commentId - Comment ID to fetch
|
|
186
|
+
* @returns Promise resolving to comment with attachments
|
|
187
|
+
* @throws Error if comment not found or request fails
|
|
188
|
+
*
|
|
189
|
+
* @remarks
|
|
190
|
+
* **LIMITATION**: This method currently returns an empty `attachments` array
|
|
191
|
+
* because Linear's GraphQL API does not expose comment attachment metadata
|
|
192
|
+
* through their SDK or documented API endpoints.
|
|
193
|
+
*
|
|
194
|
+
* This is expected behavior, not a bug. Issue attachments (via `fetchIssueAttachments`)
|
|
195
|
+
* work correctly - only comment attachments are unavailable from the Linear API.
|
|
196
|
+
*
|
|
197
|
+
* If you need comment attachments, consider:
|
|
198
|
+
* - Using issue attachments instead (`fetchIssueAttachments`)
|
|
199
|
+
* - Parsing attachment URLs from comment body markdown
|
|
200
|
+
* - Waiting for Linear to expose this data in their API
|
|
201
|
+
*
|
|
202
|
+
* Implementation detail: The returned comment object is a Linear SDK Comment
|
|
203
|
+
* with an empty `attachments` array property added.
|
|
204
|
+
*/
|
|
205
|
+
async fetchCommentWithAttachments(commentId) {
|
|
206
|
+
try {
|
|
207
|
+
// Fetch the comment using the Linear SDK
|
|
208
|
+
const comment = await this.fetchComment(commentId);
|
|
209
|
+
// Return comment with empty attachments array (Linear API doesn't expose comment attachments)
|
|
210
|
+
// Cast to CommentWithAttachments since Linear SDK types are compatible
|
|
211
|
+
return Object.assign(comment, {
|
|
212
|
+
attachments: [],
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
const err = new Error(`Failed to fetch comment with attachments ${commentId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
217
|
+
if (error instanceof Error) {
|
|
218
|
+
err.cause = error;
|
|
219
|
+
}
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Create a comment on an issue.
|
|
225
|
+
*/
|
|
226
|
+
async createComment(issueId, input) {
|
|
227
|
+
try {
|
|
228
|
+
// Build the comment body, optionally appending attachment URLs
|
|
229
|
+
let finalBody = input.body;
|
|
230
|
+
// If attachment URLs are provided, append them to the comment body as markdown
|
|
231
|
+
if (input.attachmentUrls && input.attachmentUrls.length > 0) {
|
|
232
|
+
const attachmentMarkdown = input.attachmentUrls
|
|
233
|
+
.map((url) => {
|
|
234
|
+
// Detect if the URL is an image based on file extension
|
|
235
|
+
// Matches common image extensions followed by query params (?), fragments (#), or end of string ($)
|
|
236
|
+
// Examples: image.png, image.png?v=123, image.png#section, image.png?w=500&h=300
|
|
237
|
+
const isImage = /\.(png|jpg|jpeg|gif|svg|webp|bmp)(\?|#|$)/i.test(url);
|
|
238
|
+
if (isImage) {
|
|
239
|
+
// Embed as markdown image
|
|
240
|
+
return ``;
|
|
241
|
+
}
|
|
242
|
+
// Otherwise, embed as markdown link
|
|
243
|
+
return `[attachment](${url})`;
|
|
244
|
+
})
|
|
245
|
+
.join("\n");
|
|
246
|
+
// Append attachments to the body with a separator if body is not empty
|
|
247
|
+
finalBody = input.body
|
|
248
|
+
? `${input.body}\n\n${attachmentMarkdown}`
|
|
249
|
+
: attachmentMarkdown;
|
|
250
|
+
}
|
|
251
|
+
const createPayload = await this.linearClient.createComment({
|
|
252
|
+
issueId,
|
|
253
|
+
body: finalBody,
|
|
254
|
+
parentId: input.parentId,
|
|
255
|
+
});
|
|
256
|
+
if (!createPayload.success) {
|
|
257
|
+
throw new Error("Linear API returned success=false");
|
|
258
|
+
}
|
|
259
|
+
const createdComment = await createPayload.comment;
|
|
260
|
+
if (!createdComment) {
|
|
261
|
+
throw new Error("Created comment not returned from Linear API");
|
|
262
|
+
}
|
|
263
|
+
return createdComment;
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
const err = new Error(`Failed to create comment on issue ${issueId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
267
|
+
if (error instanceof Error) {
|
|
268
|
+
err.cause = error;
|
|
269
|
+
}
|
|
270
|
+
throw err;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// ========================================================================
|
|
274
|
+
// TEAM OPERATIONS
|
|
275
|
+
// ========================================================================
|
|
276
|
+
/**
|
|
277
|
+
* Fetch all teams in the workspace/organization.
|
|
278
|
+
*/
|
|
279
|
+
async fetchTeams(options) {
|
|
280
|
+
try {
|
|
281
|
+
const teamsConnection = await this.linearClient.teams({
|
|
282
|
+
first: options?.first ?? 50,
|
|
283
|
+
after: options?.after,
|
|
284
|
+
before: options?.before,
|
|
285
|
+
});
|
|
286
|
+
return {
|
|
287
|
+
nodes: teamsConnection.nodes ?? [],
|
|
288
|
+
pageInfo: teamsConnection.pageInfo
|
|
289
|
+
? {
|
|
290
|
+
hasNextPage: teamsConnection.pageInfo.hasNextPage,
|
|
291
|
+
hasPreviousPage: teamsConnection.pageInfo.hasPreviousPage,
|
|
292
|
+
startCursor: teamsConnection.pageInfo.startCursor,
|
|
293
|
+
endCursor: teamsConnection.pageInfo.endCursor,
|
|
294
|
+
}
|
|
295
|
+
: undefined,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
const err = new Error(`Failed to fetch teams: ${error instanceof Error ? error.message : String(error)}`);
|
|
300
|
+
if (error instanceof Error) {
|
|
301
|
+
err.cause = error;
|
|
302
|
+
}
|
|
303
|
+
throw err;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Fetch a single team by ID or key.
|
|
308
|
+
*/
|
|
309
|
+
async fetchTeam(idOrKey) {
|
|
310
|
+
return await this.linearClient.team(idOrKey);
|
|
311
|
+
}
|
|
312
|
+
// ========================================================================
|
|
313
|
+
// LABEL OPERATIONS
|
|
314
|
+
// ========================================================================
|
|
315
|
+
/**
|
|
316
|
+
* Fetch all issue labels in the workspace/organization.
|
|
317
|
+
*/
|
|
318
|
+
async fetchLabels(options) {
|
|
319
|
+
try {
|
|
320
|
+
const labelsConnection = await this.linearClient.issueLabels({
|
|
321
|
+
first: options?.first ?? 50,
|
|
322
|
+
after: options?.after,
|
|
323
|
+
before: options?.before,
|
|
324
|
+
});
|
|
325
|
+
return {
|
|
326
|
+
nodes: labelsConnection.nodes ?? [],
|
|
327
|
+
pageInfo: labelsConnection.pageInfo
|
|
328
|
+
? {
|
|
329
|
+
hasNextPage: labelsConnection.pageInfo.hasNextPage,
|
|
330
|
+
hasPreviousPage: labelsConnection.pageInfo.hasPreviousPage,
|
|
331
|
+
startCursor: labelsConnection.pageInfo.startCursor,
|
|
332
|
+
endCursor: labelsConnection.pageInfo.endCursor,
|
|
333
|
+
}
|
|
334
|
+
: undefined,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
const err = new Error(`Failed to fetch labels: ${error instanceof Error ? error.message : String(error)}`);
|
|
339
|
+
if (error instanceof Error) {
|
|
340
|
+
err.cause = error;
|
|
341
|
+
}
|
|
342
|
+
throw err;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Fetch a single label by ID or name.
|
|
347
|
+
*/
|
|
348
|
+
async fetchLabel(idOrName) {
|
|
349
|
+
return await this.linearClient.issueLabel(idOrName);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Fetch label names for a specific issue.
|
|
353
|
+
*/
|
|
354
|
+
async getIssueLabels(issueId) {
|
|
355
|
+
try {
|
|
356
|
+
const issue = await this.linearClient.issue(issueId);
|
|
357
|
+
const labels = await issue.labels();
|
|
358
|
+
return labels.nodes.map((label) => label.name);
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
const err = new Error(`Failed to fetch issue labels for ${issueId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
362
|
+
if (error instanceof Error) {
|
|
363
|
+
err.cause = error;
|
|
364
|
+
}
|
|
365
|
+
throw err;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
// ========================================================================
|
|
369
|
+
// WORKFLOW STATE OPERATIONS
|
|
370
|
+
// ========================================================================
|
|
371
|
+
/**
|
|
372
|
+
* Fetch workflow states for a team.
|
|
373
|
+
*/
|
|
374
|
+
async fetchWorkflowStates(teamId, options) {
|
|
375
|
+
try {
|
|
376
|
+
const team = await this.linearClient.team(teamId);
|
|
377
|
+
const statesConnection = await team.states({
|
|
378
|
+
first: options?.first ?? 50,
|
|
379
|
+
after: options?.after,
|
|
380
|
+
before: options?.before,
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
nodes: statesConnection.nodes ?? [],
|
|
384
|
+
pageInfo: statesConnection.pageInfo
|
|
385
|
+
? {
|
|
386
|
+
hasNextPage: statesConnection.pageInfo.hasNextPage,
|
|
387
|
+
hasPreviousPage: statesConnection.pageInfo.hasPreviousPage,
|
|
388
|
+
startCursor: statesConnection.pageInfo.startCursor,
|
|
389
|
+
endCursor: statesConnection.pageInfo.endCursor,
|
|
390
|
+
}
|
|
391
|
+
: undefined,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
const err = new Error(`Failed to fetch workflow states for team ${teamId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
396
|
+
if (error instanceof Error) {
|
|
397
|
+
err.cause = error;
|
|
398
|
+
}
|
|
399
|
+
throw err;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Fetch a single workflow state by ID.
|
|
404
|
+
*/
|
|
405
|
+
async fetchWorkflowState(stateId) {
|
|
406
|
+
return await this.linearClient.workflowState(stateId);
|
|
407
|
+
}
|
|
408
|
+
// ========================================================================
|
|
409
|
+
// USER OPERATIONS
|
|
410
|
+
// ========================================================================
|
|
411
|
+
/**
|
|
412
|
+
* Fetch a user by ID.
|
|
413
|
+
*/
|
|
414
|
+
async fetchUser(userId) {
|
|
415
|
+
return await this.linearClient.user(userId);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Fetch the current authenticated user.
|
|
419
|
+
*/
|
|
420
|
+
async fetchCurrentUser() {
|
|
421
|
+
return await this.linearClient.viewer;
|
|
422
|
+
}
|
|
423
|
+
// ========================================================================
|
|
424
|
+
// AGENT SESSION OPERATIONS
|
|
425
|
+
// ========================================================================
|
|
426
|
+
/**
|
|
427
|
+
* Create an agent session on an issue.
|
|
428
|
+
* Uses native SDK method - direct passthrough to Linear SDK.
|
|
429
|
+
*/
|
|
430
|
+
createAgentSessionOnIssue(input) {
|
|
431
|
+
return this.linearClient.agentSessionCreateOnIssue(input);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Create an agent session on a comment thread.
|
|
435
|
+
* Uses native SDK method - direct passthrough to Linear SDK.
|
|
436
|
+
*/
|
|
437
|
+
createAgentSessionOnComment(input) {
|
|
438
|
+
return this.linearClient.agentSessionCreateOnComment(input);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Fetch an agent session by ID.
|
|
442
|
+
* Uses native SDK method - direct passthrough to Linear SDK.
|
|
443
|
+
*/
|
|
444
|
+
fetchAgentSession(sessionId) {
|
|
445
|
+
return this.linearClient.agentSession(sessionId);
|
|
446
|
+
}
|
|
447
|
+
// ========================================================================
|
|
448
|
+
// AGENT ACTIVITY OPERATIONS
|
|
449
|
+
// ========================================================================
|
|
450
|
+
/**
|
|
451
|
+
* Post an agent activity to an agent session.
|
|
452
|
+
* Signature matches Linear SDK's createAgentActivity exactly.
|
|
453
|
+
*/
|
|
454
|
+
async createAgentActivity(input) {
|
|
455
|
+
return await this.linearClient.createAgentActivity(input);
|
|
456
|
+
}
|
|
457
|
+
// ========================================================================
|
|
458
|
+
// FILE OPERATIONS
|
|
459
|
+
// ========================================================================
|
|
460
|
+
/**
|
|
461
|
+
* Request a file upload URL from the platform.
|
|
462
|
+
*/
|
|
463
|
+
async requestFileUpload(request) {
|
|
464
|
+
try {
|
|
465
|
+
const uploadPayload = await this.linearClient.fileUpload(request.contentType, request.filename, request.size, {
|
|
466
|
+
makePublic: request.makePublic ?? false,
|
|
467
|
+
});
|
|
468
|
+
if (!uploadPayload.success) {
|
|
469
|
+
throw new Error("Linear API returned success=false");
|
|
470
|
+
}
|
|
471
|
+
// Access the upload file result
|
|
472
|
+
const uploadFile = await uploadPayload.uploadFile;
|
|
473
|
+
if (!uploadFile) {
|
|
474
|
+
throw new Error("Upload file not returned from Linear API");
|
|
475
|
+
}
|
|
476
|
+
// Convert headers array to record
|
|
477
|
+
const headersRecord = {};
|
|
478
|
+
if (uploadFile.headers) {
|
|
479
|
+
for (const header of uploadFile.headers) {
|
|
480
|
+
if (header.key && header.value) {
|
|
481
|
+
headersRecord[header.key] = header.value;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
uploadUrl: uploadFile.uploadUrl ?? "",
|
|
487
|
+
headers: headersRecord,
|
|
488
|
+
assetUrl: uploadFile.assetUrl ?? "",
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
const err = new Error(`Failed to request file upload for ${request.filename}: ${error instanceof Error ? error.message : String(error)}`);
|
|
493
|
+
if (error instanceof Error) {
|
|
494
|
+
err.cause = error;
|
|
495
|
+
}
|
|
496
|
+
throw err;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
// ========================================================================
|
|
500
|
+
// PLATFORM METADATA
|
|
501
|
+
// ========================================================================
|
|
502
|
+
/**
|
|
503
|
+
* Get the platform type identifier.
|
|
504
|
+
*/
|
|
505
|
+
getPlatformType() {
|
|
506
|
+
return "linear";
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Get the platform's API version or other metadata.
|
|
510
|
+
*/
|
|
511
|
+
getPlatformMetadata() {
|
|
512
|
+
return {
|
|
513
|
+
platform: "linear",
|
|
514
|
+
sdkVersion: "unknown", // LinearClient doesn't expose version
|
|
515
|
+
apiVersion: "graphql",
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
// ========================================================================
|
|
519
|
+
// EVENT TRANSPORT
|
|
520
|
+
// ========================================================================
|
|
521
|
+
/**
|
|
522
|
+
* Create an event transport for receiving Linear webhook events.
|
|
523
|
+
*
|
|
524
|
+
* @param config - Transport configuration
|
|
525
|
+
* @returns Linear event transport implementation
|
|
526
|
+
*/
|
|
527
|
+
createEventTransport(config) {
|
|
528
|
+
// Type narrow to Linear config
|
|
529
|
+
if (config.platform !== "linear") {
|
|
530
|
+
throw new Error(`Invalid platform "${config.platform}" for LinearIssueTrackerService. Expected "linear".`);
|
|
531
|
+
}
|
|
532
|
+
// Import from same package - no require() needed
|
|
533
|
+
return new LinearEventTransport(config);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
//# sourceMappingURL=LinearIssueTrackerService.js.map
|
|
@@ -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AAE;aACnC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG,IAAI,KAAK,CACpB,qCAAqC,OAAO,CAAC,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAClH,CAAC;YACF,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC5B,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,CAAC;YACD,MAAM,GAAG,CAAC;QACX,CAAC;IACF,CAAC;IAED,2EAA2E;IAC3E,oBAAoB;IACpB,2EAA2E;IAE3E;;OAEG;IACH,eAAe;QACd,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,mBAAmB;QAClB,OAAO;YACN,QAAQ,EAAE,QAAQ;YAClB,UAAU,EAAE,SAAS,EAAE,sCAAsC;YAC7D,UAAU,EAAE,SAAS;SACrB,CAAC;IACH,CAAC;IAED,2EAA2E;IAC3E,kBAAkB;IAClB,2EAA2E;IAE3E;;;;;OAKG;IACH,oBAAoB,CACnB,MAAiC;QAEjC,+BAA+B;QAC/B,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACd,qBAAqB,MAAM,CAAC,QAAQ,qDAAqD,CACzF,CAAC;QACH,CAAC;QAED,iDAAiD;QACjD,OAAO,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { LinearWebhookPayload } from "@linear/sdk/webhooks";
|
|
2
2
|
export { LinearEventTransport } from "./LinearEventTransport.js";
|
|
3
|
+
export { LinearIssueTrackerService } from "./LinearIssueTrackerService.js";
|
|
3
4
|
export type { LinearEventTransportConfig, LinearEventTransportEvents, VerificationMode, } from "./types.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,gBAAgB,GAChB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,YAAY,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,gBAAgB,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types for Linear event transport
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { AgentEvent } from "cyrus-core";
|
|
5
5
|
import type { FastifyInstance } from "fastify";
|
|
6
6
|
/**
|
|
7
7
|
* Verification mode for Linear webhooks
|
|
@@ -25,7 +25,7 @@ export interface LinearEventTransportConfig {
|
|
|
25
25
|
*/
|
|
26
26
|
export interface LinearEventTransportEvents {
|
|
27
27
|
/** Emitted when a webhook is received and verified */
|
|
28
|
-
|
|
28
|
+
event: (event: AgentEvent) => void;
|
|
29
29
|
/** Emitted when an error occurs */
|
|
30
30
|
error: (error: Error) => void;
|
|
31
31
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,iDAAiD;IACjD,aAAa,EAAE,eAAe,CAAC;IAC/B,6CAA6C;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,sDAAsD;IACtD,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACnC,mCAAmC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyrus-linear-event-transport",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Linear event transport for receiving and verifying Linear webhooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@linear/sdk": "^
|
|
13
|
-
"fastify": "^5.2.0"
|
|
12
|
+
"@linear/sdk": "^64.0.0",
|
|
13
|
+
"fastify": "^5.2.0",
|
|
14
|
+
"cyrus-core": "0.2.4"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/node": "^20.0.0",
|