@generacy-ai/generacy-plugin-github-issues 0.0.0-preview-20260304013206
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/LICENSE +191 -0
- package/dist/auth/auth-factory.d.ts +44 -0
- package/dist/auth/auth-factory.d.ts.map +1 -0
- package/dist/auth/auth-factory.js +85 -0
- package/dist/auth/auth-factory.js.map +1 -0
- package/dist/auth/env.d.ts +32 -0
- package/dist/auth/env.d.ts.map +1 -0
- package/dist/auth/env.js +88 -0
- package/dist/auth/env.js.map +1 -0
- package/dist/auth/github-app.d.ts +69 -0
- package/dist/auth/github-app.d.ts.map +1 -0
- package/dist/auth/github-app.js +191 -0
- package/dist/auth/github-app.js.map +1 -0
- package/dist/auth/index.d.ts +10 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/token-cache.d.ts +70 -0
- package/dist/auth/token-cache.d.ts.map +1 -0
- package/dist/auth/token-cache.js +112 -0
- package/dist/auth/token-cache.js.map +1 -0
- package/dist/auth/types.d.ts +119 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +27 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client.d.ts +101 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +197 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/operations/comments.d.ts +46 -0
- package/dist/operations/comments.d.ts.map +1 -0
- package/dist/operations/comments.js +127 -0
- package/dist/operations/comments.js.map +1 -0
- package/dist/operations/issues.d.ts +46 -0
- package/dist/operations/issues.d.ts.map +1 -0
- package/dist/operations/issues.js +188 -0
- package/dist/operations/issues.js.map +1 -0
- package/dist/operations/labels.d.ts +46 -0
- package/dist/operations/labels.d.ts.map +1 -0
- package/dist/operations/labels.js +132 -0
- package/dist/operations/labels.js.map +1 -0
- package/dist/operations/pull-requests.d.ts +41 -0
- package/dist/operations/pull-requests.d.ts.map +1 -0
- package/dist/operations/pull-requests.js +162 -0
- package/dist/operations/pull-requests.js.map +1 -0
- package/dist/plugin.d.ts +181 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +324 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types/config.d.ts +126 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +22 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/events.d.ts +72 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/issues.d.ts +178 -0
- package/dist/types/issues.d.ts.map +1 -0
- package/dist/types/issues.js +29 -0
- package/dist/types/issues.js.map +1 -0
- package/dist/types/responses.d.ts +61 -0
- package/dist/types/responses.d.ts.map +1 -0
- package/dist/types/responses.js +5 -0
- package/dist/types/responses.js.map +1 -0
- package/dist/utils/errors.d.ts +69 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +123 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/validation.d.ts +33 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +69 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/webhooks/handler.d.ts +66 -0
- package/dist/webhooks/handler.d.ts.map +1 -0
- package/dist/webhooks/handler.js +176 -0
- package/dist/webhooks/handler.js.map +1 -0
- package/dist/webhooks/parser.d.ts +36 -0
- package/dist/webhooks/parser.d.ts.map +1 -0
- package/dist/webhooks/parser.js +220 -0
- package/dist/webhooks/parser.js.map +1 -0
- package/dist/webhooks/triggers.d.ts +25 -0
- package/dist/webhooks/triggers.d.ts.map +1 -0
- package/dist/webhooks/triggers.js +119 -0
- package/dist/webhooks/triggers.js.map +1 -0
- package/package.json +62 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { Issue as LatencyIssue, IssueSpec as LatencyIssueSpec, IssueUpdate as LatencyIssueUpdate, IssueQuery as LatencyIssueQuery, Comment as LatencyComment, PaginatedResult } from '@generacy-ai/latency';
|
|
2
|
+
import { AbstractIssueTrackerPlugin } from '@generacy-ai/latency-plugin-issue-tracker';
|
|
3
|
+
import type { GitHubIssuesConfig, Issue, CreateIssueParams, UpdateIssueParams, IssueFilter, Label, Comment, PullRequest, WorkflowAction, TypedWebhookEvent } from './types/index.js';
|
|
4
|
+
import { IssueOperations } from './operations/issues.js';
|
|
5
|
+
import { LabelOperations } from './operations/labels.js';
|
|
6
|
+
import { CommentOperations } from './operations/comments.js';
|
|
7
|
+
import { PullRequestOperations } from './operations/pull-requests.js';
|
|
8
|
+
import { WebhookHandler } from './webhooks/handler.js';
|
|
9
|
+
/**
|
|
10
|
+
* GitHub Issues Plugin for Generacy
|
|
11
|
+
*
|
|
12
|
+
* Extends AbstractIssueTrackerPlugin to provide the standard IssueTracker interface
|
|
13
|
+
* while also exposing GitHub-specific functionality.
|
|
14
|
+
*
|
|
15
|
+
* Provides programmatic access to GitHub Issues functionality including:
|
|
16
|
+
* - Issue CRUD operations (via IssueTracker interface)
|
|
17
|
+
* - Label management
|
|
18
|
+
* - Comment handling
|
|
19
|
+
* - PR linking
|
|
20
|
+
* - Webhook event processing
|
|
21
|
+
*/
|
|
22
|
+
export declare class GitHubIssuesPlugin extends AbstractIssueTrackerPlugin {
|
|
23
|
+
private readonly client;
|
|
24
|
+
private readonly issueOps;
|
|
25
|
+
private readonly labelOps;
|
|
26
|
+
private readonly commentOps;
|
|
27
|
+
private readonly pullRequestOps;
|
|
28
|
+
private readonly webhookHandler;
|
|
29
|
+
constructor(config: GitHubIssuesConfig);
|
|
30
|
+
/**
|
|
31
|
+
* Fetch a single issue from GitHub (implements abstract method)
|
|
32
|
+
*/
|
|
33
|
+
protected fetchIssue(id: string): Promise<LatencyIssue>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new issue in GitHub (implements abstract method)
|
|
36
|
+
*/
|
|
37
|
+
protected doCreateIssue(spec: LatencyIssueSpec): Promise<LatencyIssue>;
|
|
38
|
+
/**
|
|
39
|
+
* Update an existing issue (implements abstract method)
|
|
40
|
+
*/
|
|
41
|
+
protected doUpdateIssue(id: string, update: LatencyIssueUpdate): Promise<LatencyIssue>;
|
|
42
|
+
/**
|
|
43
|
+
* List issues matching the query (implements abstract method)
|
|
44
|
+
*/
|
|
45
|
+
protected doListIssues(query: LatencyIssueQuery): Promise<PaginatedResult<LatencyIssue>>;
|
|
46
|
+
/**
|
|
47
|
+
* Add a comment to an issue (implements abstract method)
|
|
48
|
+
*/
|
|
49
|
+
protected doAddComment(issueId: string, comment: string): Promise<LatencyComment>;
|
|
50
|
+
/**
|
|
51
|
+
* List comments for an issue (implements abstract method)
|
|
52
|
+
*/
|
|
53
|
+
protected doListComments(issueId: string): Promise<LatencyComment[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new issue (GitHub-specific version with full return type)
|
|
56
|
+
*/
|
|
57
|
+
createGitHubIssue(params: CreateIssueParams): Promise<Issue>;
|
|
58
|
+
/**
|
|
59
|
+
* Get an issue by number (GitHub-specific version with full return type)
|
|
60
|
+
*/
|
|
61
|
+
getGitHubIssue(number: number): Promise<Issue>;
|
|
62
|
+
/**
|
|
63
|
+
* Update an issue (GitHub-specific version)
|
|
64
|
+
*/
|
|
65
|
+
updateGitHubIssue(number: number, params: UpdateIssueParams): Promise<Issue>;
|
|
66
|
+
/**
|
|
67
|
+
* Close an issue
|
|
68
|
+
*/
|
|
69
|
+
closeIssue(number: number): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Search issues using GitHub search syntax
|
|
72
|
+
*/
|
|
73
|
+
searchIssues(query: string): Promise<Issue[]>;
|
|
74
|
+
/**
|
|
75
|
+
* List issues with optional filtering (GitHub-specific version)
|
|
76
|
+
*/
|
|
77
|
+
listGitHubIssues(filter?: IssueFilter): Promise<Issue[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Add labels to an issue
|
|
80
|
+
*/
|
|
81
|
+
addLabels(issueNumber: number, labels: string[]): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Remove labels from an issue
|
|
84
|
+
*/
|
|
85
|
+
removeLabels(issueNumber: number, labels: string[]): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Set labels on an issue (replaces existing)
|
|
88
|
+
*/
|
|
89
|
+
setLabels(issueNumber: number, labels: string[]): Promise<Label[]>;
|
|
90
|
+
/**
|
|
91
|
+
* List labels on an issue
|
|
92
|
+
*/
|
|
93
|
+
listLabels(issueNumber: number): Promise<Label[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Add a comment to an issue (GitHub-specific version with full return type)
|
|
96
|
+
*/
|
|
97
|
+
addGitHubComment(issueNumber: number, body: string): Promise<Comment>;
|
|
98
|
+
/**
|
|
99
|
+
* List comments on an issue (GitHub-specific version with numeric issue number)
|
|
100
|
+
*/
|
|
101
|
+
listGitHubComments(issueNumber: number): Promise<Comment[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Update a comment
|
|
104
|
+
*/
|
|
105
|
+
updateComment(commentId: number, body: string): Promise<Comment>;
|
|
106
|
+
/**
|
|
107
|
+
* Delete a comment
|
|
108
|
+
*/
|
|
109
|
+
deleteComment(commentId: number): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Link a pull request to an issue
|
|
112
|
+
*/
|
|
113
|
+
linkPullRequest(issueNumber: number, prNumber: number): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Get pull requests linked to an issue
|
|
116
|
+
*/
|
|
117
|
+
getLinkedPRs(issueNumber: number): Promise<PullRequest[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Handle a webhook event
|
|
120
|
+
* Returns the workflow action to take based on the event
|
|
121
|
+
*/
|
|
122
|
+
handleWebhook(event: TypedWebhookEvent): Promise<WorkflowAction>;
|
|
123
|
+
/**
|
|
124
|
+
* Handle a raw webhook delivery
|
|
125
|
+
* Useful when receiving webhooks directly from GitHub
|
|
126
|
+
*/
|
|
127
|
+
handleRawWebhook(eventName: string, payload: unknown, deliveryId?: string): Promise<WorkflowAction>;
|
|
128
|
+
/**
|
|
129
|
+
* Verify authentication
|
|
130
|
+
*/
|
|
131
|
+
verifyAuth(): Promise<{
|
|
132
|
+
login: string;
|
|
133
|
+
id: number;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Get current rate limit status
|
|
137
|
+
*/
|
|
138
|
+
getRateLimit(): Promise<{
|
|
139
|
+
limit: number;
|
|
140
|
+
remaining: number;
|
|
141
|
+
reset: Date;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Get the repository owner
|
|
145
|
+
*/
|
|
146
|
+
get owner(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Get the repository name
|
|
149
|
+
*/
|
|
150
|
+
get repo(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Access to underlying operations for advanced usage
|
|
153
|
+
*/
|
|
154
|
+
get operations(): {
|
|
155
|
+
issues: IssueOperations;
|
|
156
|
+
labels: LabelOperations;
|
|
157
|
+
comments: CommentOperations;
|
|
158
|
+
pullRequests: PullRequestOperations;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Access to webhook handler for advanced usage
|
|
162
|
+
*/
|
|
163
|
+
get webhook(): WebhookHandler;
|
|
164
|
+
/**
|
|
165
|
+
* Parse an issue ID string to a number
|
|
166
|
+
*/
|
|
167
|
+
private parseIssueNumber;
|
|
168
|
+
/**
|
|
169
|
+
* Map a GitHub Issue to the Latency Issue type
|
|
170
|
+
*/
|
|
171
|
+
private mapToLatencyIssue;
|
|
172
|
+
/**
|
|
173
|
+
* Map a GitHub Comment to the Latency Comment type
|
|
174
|
+
*/
|
|
175
|
+
private mapToLatencyComment;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Create a new GitHub Issues plugin instance
|
|
179
|
+
*/
|
|
180
|
+
export declare function createPlugin(config: GitHubIssuesConfig): GitHubIssuesPlugin;
|
|
181
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,IAAI,YAAY,EACrB,SAAS,IAAI,gBAAgB,EAC7B,WAAW,IAAI,kBAAkB,EACjC,UAAU,IAAI,iBAAiB,EAC/B,OAAO,IAAI,cAAc,EACzB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,EACV,kBAAkB,EAClB,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,KAAK,EACL,OAAO,EACP,WAAW,EACX,cAAc,EACd,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAA+B,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,cAAc,EAAmD,MAAM,uBAAuB,CAAC;AAExG;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAmB,SAAQ,0BAA0B;IAChE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAC/C,OAAO,CAAC,QAAQ,CAAC,c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EAAE,MAAM,CAAA;KAAE,CAAC;IAI1D;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC;QAC5B,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,IAAI,CAAC;KACb,CAAC;IAIF;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI;QAChB,MAAM,EAAE,eAAe,CAAC;QACxB,MAAM,EAAE,eAAe,CAAC;QACxB,QAAQ,EAAE,iBAAiB,CAAC;QAC5B,YAAY,EAAE,qBAAqB,CAAC;KACrC,CAOA;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,cAAc,CAE5B;IAMD;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAQ5B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAE3E"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { AbstractIssueTrackerPlugin } from '@generacy-ai/latency-plugin-issue-tracker';
|
|
2
|
+
import { createClient } from './client.js';
|
|
3
|
+
import { createIssueOperations } from './operations/issues.js';
|
|
4
|
+
import { createLabelOperations } from './operations/labels.js';
|
|
5
|
+
import { createCommentOperations } from './operations/comments.js';
|
|
6
|
+
import { createPullRequestOperations } from './operations/pull-requests.js';
|
|
7
|
+
import { createWebhookHandler } from './webhooks/handler.js';
|
|
8
|
+
/**
|
|
9
|
+
* GitHub Issues Plugin for Generacy
|
|
10
|
+
*
|
|
11
|
+
* Extends AbstractIssueTrackerPlugin to provide the standard IssueTracker interface
|
|
12
|
+
* while also exposing GitHub-specific functionality.
|
|
13
|
+
*
|
|
14
|
+
* Provides programmatic access to GitHub Issues functionality including:
|
|
15
|
+
* - Issue CRUD operations (via IssueTracker interface)
|
|
16
|
+
* - Label management
|
|
17
|
+
* - Comment handling
|
|
18
|
+
* - PR linking
|
|
19
|
+
* - Webhook event processing
|
|
20
|
+
*/
|
|
21
|
+
export class GitHubIssuesPlugin extends AbstractIssueTrackerPlugin {
|
|
22
|
+
client;
|
|
23
|
+
issueOps;
|
|
24
|
+
labelOps;
|
|
25
|
+
commentOps;
|
|
26
|
+
pullRequestOps;
|
|
27
|
+
webhookHandler;
|
|
28
|
+
constructor(config) {
|
|
29
|
+
super({ cacheTimeout: config.cacheTimeout ?? 60000 });
|
|
30
|
+
this.client = createClient(config);
|
|
31
|
+
this.issueOps = createIssueOperations(this.client);
|
|
32
|
+
this.labelOps = createLabelOperations(this.client);
|
|
33
|
+
this.commentOps = createCommentOperations(this.client);
|
|
34
|
+
this.pullRequestOps = createPullRequestOperations(this.client);
|
|
35
|
+
const webhookConfig = {
|
|
36
|
+
webhookSecret: config.webhookSecret,
|
|
37
|
+
agentAccount: config.agentAccount,
|
|
38
|
+
triggerLabels: config.triggerLabels,
|
|
39
|
+
};
|
|
40
|
+
this.webhookHandler = createWebhookHandler(webhookConfig);
|
|
41
|
+
}
|
|
42
|
+
// ==========================================================================
|
|
43
|
+
// AbstractIssueTrackerPlugin abstract method implementations
|
|
44
|
+
// ==========================================================================
|
|
45
|
+
/**
|
|
46
|
+
* Fetch a single issue from GitHub (implements abstract method)
|
|
47
|
+
*/
|
|
48
|
+
async fetchIssue(id) {
|
|
49
|
+
const issueNumber = this.parseIssueNumber(id);
|
|
50
|
+
const issue = await this.issueOps.get(issueNumber);
|
|
51
|
+
return this.mapToLatencyIssue(issue);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create a new issue in GitHub (implements abstract method)
|
|
55
|
+
*/
|
|
56
|
+
async doCreateIssue(spec) {
|
|
57
|
+
const params = {
|
|
58
|
+
title: spec.title,
|
|
59
|
+
body: spec.body,
|
|
60
|
+
labels: spec.labels,
|
|
61
|
+
assignees: spec.assignees,
|
|
62
|
+
};
|
|
63
|
+
const issue = await this.issueOps.create(params);
|
|
64
|
+
return this.mapToLatencyIssue(issue);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Update an existing issue (implements abstract method)
|
|
68
|
+
*/
|
|
69
|
+
async doUpdateIssue(id, update) {
|
|
70
|
+
const issueNumber = this.parseIssueNumber(id);
|
|
71
|
+
const params = {
|
|
72
|
+
title: update.title,
|
|
73
|
+
body: update.body,
|
|
74
|
+
state: update.state,
|
|
75
|
+
labels: update.labels,
|
|
76
|
+
assignees: update.assignees,
|
|
77
|
+
};
|
|
78
|
+
const issue = await this.issueOps.update(issueNumber, params);
|
|
79
|
+
return this.mapToLatencyIssue(issue);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* List issues matching the query (implements abstract method)
|
|
83
|
+
*/
|
|
84
|
+
async doListIssues(query) {
|
|
85
|
+
const filter = {
|
|
86
|
+
state: query.state,
|
|
87
|
+
labels: query.labels,
|
|
88
|
+
assignee: query.assignee,
|
|
89
|
+
};
|
|
90
|
+
const issues = await this.issueOps.list(filter);
|
|
91
|
+
const latencyIssues = issues.map((issue) => this.mapToLatencyIssue(issue));
|
|
92
|
+
// Apply pagination manually since the underlying operation returns all
|
|
93
|
+
const offset = query.offset ?? 0;
|
|
94
|
+
const limit = query.limit ?? 30;
|
|
95
|
+
const paginatedItems = latencyIssues.slice(offset, offset + limit);
|
|
96
|
+
return {
|
|
97
|
+
items: paginatedItems,
|
|
98
|
+
total: latencyIssues.length,
|
|
99
|
+
hasMore: offset + limit < latencyIssues.length,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Add a comment to an issue (implements abstract method)
|
|
104
|
+
*/
|
|
105
|
+
async doAddComment(issueId, comment) {
|
|
106
|
+
const issueNumber = this.parseIssueNumber(issueId);
|
|
107
|
+
const ghComment = await this.commentOps.add(issueNumber, comment);
|
|
108
|
+
return this.mapToLatencyComment(ghComment);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List comments for an issue (implements abstract method)
|
|
112
|
+
*/
|
|
113
|
+
async doListComments(issueId) {
|
|
114
|
+
const issueNumber = this.parseIssueNumber(issueId);
|
|
115
|
+
const comments = await this.commentOps.list(issueNumber);
|
|
116
|
+
return comments.map((c) => this.mapToLatencyComment(c));
|
|
117
|
+
}
|
|
118
|
+
// ==========================================================================
|
|
119
|
+
// GitHub-specific public API (for backwards compatibility)
|
|
120
|
+
// ==========================================================================
|
|
121
|
+
/**
|
|
122
|
+
* Create a new issue (GitHub-specific version with full return type)
|
|
123
|
+
*/
|
|
124
|
+
async createGitHubIssue(params) {
|
|
125
|
+
return this.issueOps.create(params);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get an issue by number (GitHub-specific version with full return type)
|
|
129
|
+
*/
|
|
130
|
+
async getGitHubIssue(number) {
|
|
131
|
+
return this.issueOps.get(number);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Update an issue (GitHub-specific version)
|
|
135
|
+
*/
|
|
136
|
+
async updateGitHubIssue(number, params) {
|
|
137
|
+
return this.issueOps.update(number, params);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Close an issue
|
|
141
|
+
*/
|
|
142
|
+
async closeIssue(number) {
|
|
143
|
+
return this.issueOps.close(number);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Search issues using GitHub search syntax
|
|
147
|
+
*/
|
|
148
|
+
async searchIssues(query) {
|
|
149
|
+
return this.issueOps.search(query);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* List issues with optional filtering (GitHub-specific version)
|
|
153
|
+
*/
|
|
154
|
+
async listGitHubIssues(filter) {
|
|
155
|
+
return this.issueOps.list(filter);
|
|
156
|
+
}
|
|
157
|
+
// ==================== Label Operations ====================
|
|
158
|
+
/**
|
|
159
|
+
* Add labels to an issue
|
|
160
|
+
*/
|
|
161
|
+
async addLabels(issueNumber, labels) {
|
|
162
|
+
await this.labelOps.add(issueNumber, labels);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Remove labels from an issue
|
|
166
|
+
*/
|
|
167
|
+
async removeLabels(issueNumber, labels) {
|
|
168
|
+
await this.labelOps.removeMany(issueNumber, labels);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Set labels on an issue (replaces existing)
|
|
172
|
+
*/
|
|
173
|
+
async setLabels(issueNumber, labels) {
|
|
174
|
+
return this.labelOps.set(issueNumber, labels);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* List labels on an issue
|
|
178
|
+
*/
|
|
179
|
+
async listLabels(issueNumber) {
|
|
180
|
+
return this.labelOps.list(issueNumber);
|
|
181
|
+
}
|
|
182
|
+
// ==================== Comment Operations (GitHub-specific) ====================
|
|
183
|
+
/**
|
|
184
|
+
* Add a comment to an issue (GitHub-specific version with full return type)
|
|
185
|
+
*/
|
|
186
|
+
async addGitHubComment(issueNumber, body) {
|
|
187
|
+
return this.commentOps.add(issueNumber, body);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* List comments on an issue (GitHub-specific version with numeric issue number)
|
|
191
|
+
*/
|
|
192
|
+
async listGitHubComments(issueNumber) {
|
|
193
|
+
return this.commentOps.list(issueNumber);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Update a comment
|
|
197
|
+
*/
|
|
198
|
+
async updateComment(commentId, body) {
|
|
199
|
+
return this.commentOps.update(commentId, body);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Delete a comment
|
|
203
|
+
*/
|
|
204
|
+
async deleteComment(commentId) {
|
|
205
|
+
return this.commentOps.delete(commentId);
|
|
206
|
+
}
|
|
207
|
+
// ==================== Pull Request Operations ====================
|
|
208
|
+
/**
|
|
209
|
+
* Link a pull request to an issue
|
|
210
|
+
*/
|
|
211
|
+
async linkPullRequest(issueNumber, prNumber) {
|
|
212
|
+
return this.pullRequestOps.linkToIssue(prNumber, issueNumber);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get pull requests linked to an issue
|
|
216
|
+
*/
|
|
217
|
+
async getLinkedPRs(issueNumber) {
|
|
218
|
+
return this.pullRequestOps.getLinkedToIssue(issueNumber);
|
|
219
|
+
}
|
|
220
|
+
// ==================== Webhook Operations ====================
|
|
221
|
+
/**
|
|
222
|
+
* Handle a webhook event
|
|
223
|
+
* Returns the workflow action to take based on the event
|
|
224
|
+
*/
|
|
225
|
+
async handleWebhook(event) {
|
|
226
|
+
const result = await this.webhookHandler.processEvent(event);
|
|
227
|
+
return result.action;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Handle a raw webhook delivery
|
|
231
|
+
* Useful when receiving webhooks directly from GitHub
|
|
232
|
+
*/
|
|
233
|
+
async handleRawWebhook(eventName, payload, deliveryId) {
|
|
234
|
+
return this.webhookHandler.handle(eventName, payload, deliveryId);
|
|
235
|
+
}
|
|
236
|
+
// ==================== Utility Methods ====================
|
|
237
|
+
/**
|
|
238
|
+
* Verify authentication
|
|
239
|
+
*/
|
|
240
|
+
async verifyAuth() {
|
|
241
|
+
return this.client.verifyAuth();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get current rate limit status
|
|
245
|
+
*/
|
|
246
|
+
async getRateLimit() {
|
|
247
|
+
return this.client.getRateLimit();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Get the repository owner
|
|
251
|
+
*/
|
|
252
|
+
get owner() {
|
|
253
|
+
return this.client.owner;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get the repository name
|
|
257
|
+
*/
|
|
258
|
+
get repo() {
|
|
259
|
+
return this.client.repo;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Access to underlying operations for advanced usage
|
|
263
|
+
*/
|
|
264
|
+
get operations() {
|
|
265
|
+
return {
|
|
266
|
+
issues: this.issueOps,
|
|
267
|
+
labels: this.labelOps,
|
|
268
|
+
comments: this.commentOps,
|
|
269
|
+
pullRequests: this.pullRequestOps,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Access to webhook handler for advanced usage
|
|
274
|
+
*/
|
|
275
|
+
get webhook() {
|
|
276
|
+
return this.webhookHandler;
|
|
277
|
+
}
|
|
278
|
+
// ==========================================================================
|
|
279
|
+
// Private helper methods
|
|
280
|
+
// ==========================================================================
|
|
281
|
+
/**
|
|
282
|
+
* Parse an issue ID string to a number
|
|
283
|
+
*/
|
|
284
|
+
parseIssueNumber(id) {
|
|
285
|
+
const num = parseInt(id, 10);
|
|
286
|
+
if (isNaN(num) || num <= 0) {
|
|
287
|
+
throw new Error(`Invalid issue number: ${id}`);
|
|
288
|
+
}
|
|
289
|
+
return num;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Map a GitHub Issue to the Latency Issue type
|
|
293
|
+
*/
|
|
294
|
+
mapToLatencyIssue(issue) {
|
|
295
|
+
return {
|
|
296
|
+
id: String(issue.number),
|
|
297
|
+
title: issue.title,
|
|
298
|
+
body: issue.body ?? '',
|
|
299
|
+
state: issue.state,
|
|
300
|
+
labels: issue.labels.map((label) => label.name),
|
|
301
|
+
assignees: issue.assignees.map((user) => user.login),
|
|
302
|
+
createdAt: new Date(issue.createdAt),
|
|
303
|
+
updatedAt: new Date(issue.updatedAt),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Map a GitHub Comment to the Latency Comment type
|
|
308
|
+
*/
|
|
309
|
+
mapToLatencyComment(comment) {
|
|
310
|
+
return {
|
|
311
|
+
id: String(comment.id),
|
|
312
|
+
body: comment.body,
|
|
313
|
+
author: comment.author.login,
|
|
314
|
+
createdAt: new Date(comment.createdAt),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Create a new GitHub Issues plugin instance
|
|
320
|
+
*/
|
|
321
|
+
export function createPlugin(config) {
|
|
322
|
+
return new GitHubIssuesPlugin(config);
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAavF,OAAO,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAmB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAmB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAqB,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAyB,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAkB,oBAAoB,EAA6B,MAAM,uBAAuB,CAAC;AAExG;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,kBAAmB,SAAQ,0BAA0B;IAC/C,MAAM,CAAe;IACrB,QAAQ,CAAkB;IAC1B,QAAQ,CAAkB;IAC1B,UAAU,CAAoB;IAC9B,cAAc,CAAwB;IACtC,cAAc,CAAiB;IAEhD,YAAY,MAA0B;QACpC,KAAK,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,KAAK,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,CAAC,cAAc,GAAG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M,CAAC,KAAK;YAC5B,SAAS,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;SACvC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type GitHubAppConfig } from '../auth/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin configuration for GitHub Issues integration
|
|
5
|
+
*/
|
|
6
|
+
export interface GitHubIssuesConfig {
|
|
7
|
+
/** Repository owner (user or organization) */
|
|
8
|
+
owner: string;
|
|
9
|
+
/** Repository name */
|
|
10
|
+
repo: string;
|
|
11
|
+
/** GitHub authentication token (PAT or installation token) - optional if app is configured */
|
|
12
|
+
token?: string;
|
|
13
|
+
/** GitHub App authentication configuration */
|
|
14
|
+
app?: GitHubAppConfig;
|
|
15
|
+
/** Webhook secret for signature verification */
|
|
16
|
+
webhookSecret?: string;
|
|
17
|
+
/** Agent account username for assignment detection */
|
|
18
|
+
agentAccount?: string;
|
|
19
|
+
/** Labels that trigger workflow start */
|
|
20
|
+
triggerLabels?: string[];
|
|
21
|
+
/** GitHub Enterprise base URL */
|
|
22
|
+
baseUrl?: string;
|
|
23
|
+
/** Cache TTL in milliseconds for issue caching (default: 60000) */
|
|
24
|
+
cacheTimeout?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Zod schema for configuration validation
|
|
28
|
+
*/
|
|
29
|
+
export declare const GitHubIssuesConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
30
|
+
owner: z.ZodString;
|
|
31
|
+
repo: z.ZodString;
|
|
32
|
+
token: z.ZodOptional<z.ZodString>;
|
|
33
|
+
app: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
34
|
+
appId: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
35
|
+
privateKey: z.ZodOptional<z.ZodString>;
|
|
36
|
+
privateKeyPath: z.ZodOptional<z.ZodString>;
|
|
37
|
+
installationId: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
appId: string | number;
|
|
40
|
+
privateKey?: string | undefined;
|
|
41
|
+
privateKeyPath?: string | undefined;
|
|
42
|
+
installationId?: number | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
appId: string | number;
|
|
45
|
+
privateKey?: string | undefined;
|
|
46
|
+
privateKeyPath?: string | undefined;
|
|
47
|
+
installationId?: number | undefined;
|
|
48
|
+
}>, {
|
|
49
|
+
appId: string | number;
|
|
50
|
+
privateKey?: string | undefined;
|
|
51
|
+
privateKeyPath?: string | undefined;
|
|
52
|
+
installationId?: number | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
appId: string | number;
|
|
55
|
+
privateKey?: string | undefined;
|
|
56
|
+
privateKeyPath?: string | undefined;
|
|
57
|
+
installationId?: number | undefined;
|
|
58
|
+
}>>;
|
|
59
|
+
webhookSecret: z.ZodOptional<z.ZodString>;
|
|
60
|
+
agentAccount: z.ZodOptional<z.ZodString>;
|
|
61
|
+
triggerLabels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
62
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
63
|
+
cacheTimeout: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
owner: string;
|
|
66
|
+
repo: string;
|
|
67
|
+
token?: string | undefined;
|
|
68
|
+
app?: {
|
|
69
|
+
appId: string | number;
|
|
70
|
+
privateKey?: string | undefined;
|
|
71
|
+
privateKeyPath?: string | undefined;
|
|
72
|
+
installationId?: number | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
webhookSecret?: string | undefined;
|
|
75
|
+
agentAccount?: string | undefined;
|
|
76
|
+
triggerLabels?: string[] | undefined;
|
|
77
|
+
baseUrl?: string | undefined;
|
|
78
|
+
cacheTimeout?: number | undefined;
|
|
79
|
+
}, {
|
|
80
|
+
owner: string;
|
|
81
|
+
repo: string;
|
|
82
|
+
token?: string | undefined;
|
|
83
|
+
app?: {
|
|
84
|
+
appId: string | number;
|
|
85
|
+
privateKey?: string | undefined;
|
|
86
|
+
privateKeyPath?: string | undefined;
|
|
87
|
+
installationId?: number | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
webhookSecret?: string | undefined;
|
|
90
|
+
agentAccount?: string | undefined;
|
|
91
|
+
triggerLabels?: string[] | undefined;
|
|
92
|
+
baseUrl?: string | undefined;
|
|
93
|
+
cacheTimeout?: number | undefined;
|
|
94
|
+
}>, {
|
|
95
|
+
owner: string;
|
|
96
|
+
repo: string;
|
|
97
|
+
token?: string | undefined;
|
|
98
|
+
app?: {
|
|
99
|
+
appId: string | number;
|
|
100
|
+
privateKey?: string | undefined;
|
|
101
|
+
privateKeyPath?: string | undefined;
|
|
102
|
+
installationId?: number | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
webhookSecret?: string | undefined;
|
|
105
|
+
agentAccount?: string | undefined;
|
|
106
|
+
triggerLabels?: string[] | undefined;
|
|
107
|
+
baseUrl?: string | undefined;
|
|
108
|
+
cacheTimeout?: number | undefined;
|
|
109
|
+
}, {
|
|
110
|
+
owner: string;
|
|
111
|
+
repo: string;
|
|
112
|
+
token?: string | undefined;
|
|
113
|
+
app?: {
|
|
114
|
+
appId: string | number;
|
|
115
|
+
privateKey?: string | undefined;
|
|
116
|
+
privateKeyPath?: string | undefined;
|
|
117
|
+
installationId?: number | undefined;
|
|
118
|
+
} | undefined;
|
|
119
|
+
webhookSecret?: string | undefined;
|
|
120
|
+
agentAccount?: string | undefined;
|
|
121
|
+
triggerLabels?: string[] | undefined;
|
|
122
|
+
baseUrl?: string | undefined;
|
|
123
|
+
cacheTimeout?: number | undefined;
|
|
124
|
+
}>;
|
|
125
|
+
export type ValidatedConfig = z.infer<typeof GitHubIssuesConfigSchema>;
|
|
126
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IAEd,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IAEb,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8CAA8C;IAC9C,GAAG,CAAC,EAAE,eAAe,CAAC;IAEtB,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yCAAyC;IACzC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAejC,CAAC;AAEL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GitHubAppConfigSchema } from '../auth/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for configuration validation
|
|
5
|
+
*/
|
|
6
|
+
export const GitHubIssuesConfigSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
owner: z.string().min(1, 'Owner is required'),
|
|
9
|
+
repo: z.string().min(1, 'Repository name is required'),
|
|
10
|
+
token: z.string().optional(),
|
|
11
|
+
app: GitHubAppConfigSchema.optional(),
|
|
12
|
+
webhookSecret: z.string().optional(),
|
|
13
|
+
agentAccount: z.string().optional(),
|
|
14
|
+
triggerLabels: z.array(z.string()).optional(),
|
|
15
|
+
baseUrl: z.string().url('Invalid base URL').optional(),
|
|
16
|
+
cacheTimeout: z.number().positive().optional(),
|
|
17
|
+
})
|
|
18
|
+
.refine((data) => data.token !== undefined || data.app !== undefined, {
|
|
19
|
+
message: 'Either token or app configuration is required',
|
|
20
|
+
path: ['token'],
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,CAAC;AAkC/E;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACtD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,GAAG,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IACrC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC7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