@generacy-ai/latency-plugin-github-issues 0.1.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/LICENSE +191 -0
- package/dist/client.d.ts +45 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +113 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +47 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/mappers.d.ts +16 -0
- package/dist/mappers.d.ts.map +1 -0
- package/dist/mappers.js +63 -0
- package/dist/mappers.js.map +1 -0
- package/dist/plugin.d.ts +44 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +95 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 The Generacy AI Authors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
/** Response type for Octokit issue operations. */
|
|
3
|
+
export type OctokitIssueResponse = Awaited<ReturnType<InstanceType<typeof Octokit>['issues']['get']>>['data'];
|
|
4
|
+
/** Response type for Octokit comment operations. */
|
|
5
|
+
export type OctokitCommentResponse = Awaited<ReturnType<InstanceType<typeof Octokit>['issues']['createComment']>>['data'];
|
|
6
|
+
/** Response type for Octokit list comments operations. */
|
|
7
|
+
export type OctokitListCommentsResponse = Awaited<ReturnType<InstanceType<typeof Octokit>['issues']['listComments']>>['data'];
|
|
8
|
+
/** Response type for Octokit list operations. */
|
|
9
|
+
export type OctokitListResponse = Awaited<ReturnType<InstanceType<typeof Octokit>['issues']['listForRepo']>>['data'];
|
|
10
|
+
/**
|
|
11
|
+
* Thin wrapper around Octokit scoped to a single repository.
|
|
12
|
+
* All methods wrap API calls with mapGitHubError for consistent error handling.
|
|
13
|
+
*/
|
|
14
|
+
export declare class GitHubClient {
|
|
15
|
+
private octokit;
|
|
16
|
+
private owner;
|
|
17
|
+
private repo;
|
|
18
|
+
constructor(token: string, owner: string, repo: string);
|
|
19
|
+
getIssue(issueNumber: number): Promise<OctokitIssueResponse>;
|
|
20
|
+
createIssue(params: {
|
|
21
|
+
title: string;
|
|
22
|
+
body?: string;
|
|
23
|
+
labels?: string[];
|
|
24
|
+
assignees?: string[];
|
|
25
|
+
milestone?: number;
|
|
26
|
+
}): Promise<OctokitIssueResponse>;
|
|
27
|
+
updateIssue(issueNumber: number, params: {
|
|
28
|
+
title?: string;
|
|
29
|
+
body?: string;
|
|
30
|
+
state?: 'open' | 'closed';
|
|
31
|
+
labels?: string[];
|
|
32
|
+
assignees?: string[];
|
|
33
|
+
}): Promise<OctokitIssueResponse>;
|
|
34
|
+
listIssues(params: {
|
|
35
|
+
state?: 'open' | 'closed' | 'all';
|
|
36
|
+
labels?: string;
|
|
37
|
+
assignee?: string;
|
|
38
|
+
per_page?: number;
|
|
39
|
+
page?: number;
|
|
40
|
+
}): Promise<OctokitListResponse>;
|
|
41
|
+
createComment(issueNumber: number, body: string): Promise<OctokitCommentResponse>;
|
|
42
|
+
listComments(issueNumber: number): Promise<OctokitListCommentsResponse>;
|
|
43
|
+
addLabels(issueNumber: number, labels: string[]): Promise<OctokitIssueResponse>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,kDAAkD;AAClD,MAAM,MAAM,oBAAoB,GAAG,OAAO,CACxC,UAAU,CAAC,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC,MAAM,CAAC,CAAC;AAEV,oDAAoD;AACpD,MAAM,MAAM,s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B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,GACA,OAAO,CAAC,oBAAoB,CAAC;IAc1B,UAAU,CAAC,MAAM,EAAE;QACvB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;QAClC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAa1B,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,sBAAsB,CAAC;IAc5B,YAAY,CAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,2BAA2B,CAAC;IAcjC,SAAS,CACb,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,oBAAoB,CAAC;CAcjC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
import { mapGitHubError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Thin wrapper around Octokit scoped to a single repository.
|
|
5
|
+
* All methods wrap API calls with mapGitHubError for consistent error handling.
|
|
6
|
+
*/
|
|
7
|
+
export class GitHubClient {
|
|
8
|
+
octokit;
|
|
9
|
+
owner;
|
|
10
|
+
repo;
|
|
11
|
+
constructor(token, owner, repo) {
|
|
12
|
+
this.octokit = new Octokit({ auth: token });
|
|
13
|
+
this.owner = owner;
|
|
14
|
+
this.repo = repo;
|
|
15
|
+
}
|
|
16
|
+
async getIssue(issueNumber) {
|
|
17
|
+
try {
|
|
18
|
+
const { data } = await this.octokit.issues.get({
|
|
19
|
+
owner: this.owner,
|
|
20
|
+
repo: this.repo,
|
|
21
|
+
issue_number: issueNumber,
|
|
22
|
+
});
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw mapGitHubError(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async createIssue(params) {
|
|
30
|
+
try {
|
|
31
|
+
const { data } = await this.octokit.issues.create({
|
|
32
|
+
owner: this.owner,
|
|
33
|
+
repo: this.repo,
|
|
34
|
+
...params,
|
|
35
|
+
});
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw mapGitHubError(error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async updateIssue(issueNumber, params) {
|
|
43
|
+
try {
|
|
44
|
+
const { data } = await this.octokit.issues.update({
|
|
45
|
+
owner: this.owner,
|
|
46
|
+
repo: this.repo,
|
|
47
|
+
issue_number: issueNumber,
|
|
48
|
+
...params,
|
|
49
|
+
});
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw mapGitHubError(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async listIssues(params) {
|
|
57
|
+
try {
|
|
58
|
+
const { data } = await this.octokit.issues.listForRepo({
|
|
59
|
+
owner: this.owner,
|
|
60
|
+
repo: this.repo,
|
|
61
|
+
...params,
|
|
62
|
+
});
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw mapGitHubError(error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async createComment(issueNumber, body) {
|
|
70
|
+
try {
|
|
71
|
+
const { data } = await this.octokit.issues.createComment({
|
|
72
|
+
owner: this.owner,
|
|
73
|
+
repo: this.repo,
|
|
74
|
+
issue_number: issueNumber,
|
|
75
|
+
body,
|
|
76
|
+
});
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
throw mapGitHubError(error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async listComments(issueNumber) {
|
|
84
|
+
try {
|
|
85
|
+
const { data } = await this.octokit.issues.listComments({
|
|
86
|
+
owner: this.owner,
|
|
87
|
+
repo: this.repo,
|
|
88
|
+
issue_number: issueNumber,
|
|
89
|
+
per_page: 100,
|
|
90
|
+
});
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw mapGitHubError(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async addLabels(issueNumber, labels) {
|
|
98
|
+
try {
|
|
99
|
+
await this.octokit.issues.addLabels({
|
|
100
|
+
owner: this.owner,
|
|
101
|
+
repo: this.repo,
|
|
102
|
+
issue_number: issueNumber,
|
|
103
|
+
labels,
|
|
104
|
+
});
|
|
105
|
+
// Return updated issue after adding labels
|
|
106
|
+
return this.getIssue(issueNumber);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw mapGitHubError(error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAsB7C;;;GAGG;AACH,MAAM,OAAO,YAAY;IACf,OAAO,CAAU;IACjB,KAAK,CAAS;IACd,IAAI,CAAS;IAErB,YAAY,KAAa,EAAE,KAAa,EAAE,IAAY;QACpD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB;QAChC,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAA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AI,CAAC,KAAK;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,YAAY,EAAE,WAAW;gBACzB,MAAM;aACP,CAAC,CAAC;YACH,2CAA2C;YAC3C,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FacetError } from '@generacy-ai/latency';
|
|
2
|
+
/**
|
|
3
|
+
* Map a GitHub API error (from Octokit) to a FacetError with a standard code.
|
|
4
|
+
*
|
|
5
|
+
* HTTP status mapping:
|
|
6
|
+
* - 404 → NOT_FOUND
|
|
7
|
+
* - 401, 403 → AUTH_ERROR
|
|
8
|
+
* - 429 → RATE_LIMIT
|
|
9
|
+
* - 422 → VALIDATION
|
|
10
|
+
* - Other → UNKNOWN
|
|
11
|
+
*/
|
|
12
|
+
export declare function mapGitHubError(error: unknown): FacetError;
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAsBzD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FacetError } from '@generacy-ai/latency';
|
|
2
|
+
/**
|
|
3
|
+
* Map a GitHub API error (from Octokit) to a FacetError with a standard code.
|
|
4
|
+
*
|
|
5
|
+
* HTTP status mapping:
|
|
6
|
+
* - 404 → NOT_FOUND
|
|
7
|
+
* - 401, 403 → AUTH_ERROR
|
|
8
|
+
* - 429 → RATE_LIMIT
|
|
9
|
+
* - 422 → VALIDATION
|
|
10
|
+
* - Other → UNKNOWN
|
|
11
|
+
*/
|
|
12
|
+
export function mapGitHubError(error) {
|
|
13
|
+
if (error instanceof FacetError) {
|
|
14
|
+
return error;
|
|
15
|
+
}
|
|
16
|
+
const status = getStatusCode(error);
|
|
17
|
+
const message = getErrorMessage(error);
|
|
18
|
+
if (status === 404) {
|
|
19
|
+
return new FacetError(message, 'NOT_FOUND', { cause: error });
|
|
20
|
+
}
|
|
21
|
+
if (status === 401 || status === 403) {
|
|
22
|
+
return new FacetError(message, 'AUTH_ERROR', { cause: error });
|
|
23
|
+
}
|
|
24
|
+
if (status === 429) {
|
|
25
|
+
return new FacetError(message, 'RATE_LIMIT', { cause: error });
|
|
26
|
+
}
|
|
27
|
+
if (status === 422) {
|
|
28
|
+
return new FacetError(message, 'VALIDATION', { cause: error });
|
|
29
|
+
}
|
|
30
|
+
return new FacetError(message, 'UNKNOWN', { cause: error });
|
|
31
|
+
}
|
|
32
|
+
function getStatusCode(error) {
|
|
33
|
+
if (typeof error === 'object' && error !== null && 'status' in error) {
|
|
34
|
+
return error.status;
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
function getErrorMessage(error) {
|
|
39
|
+
if (error instanceof Error) {
|
|
40
|
+
return error.message;
|
|
41
|
+
}
|
|
42
|
+
if (typeof error === 'string') {
|
|
43
|
+
return error;
|
|
44
|
+
}
|
|
45
|
+
return 'Unknown GitHub API error';
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,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AAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,0BAA0B,CAAC;AACpC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Comment, PaginatedResult, Issue } from '@generacy-ai/latency';
|
|
2
|
+
import type { GitHubIssue } from '@generacy-ai/github-issues-interface';
|
|
3
|
+
import type { OctokitIssueResponse, OctokitCommentResponse, OctokitListResponse } from './client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Map an Octokit issue response to a GitHubIssue domain object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapToGitHubIssue(data: OctokitIssueResponse, repository: string): GitHubIssue;
|
|
8
|
+
/**
|
|
9
|
+
* Map an Octokit comment response to a Comment domain object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mapToComment(data: OctokitCommentResponse): Comment;
|
|
12
|
+
/**
|
|
13
|
+
* Wrap a list of mapped issues into a PaginatedResult.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mapIssuesToPaginatedResult(data: OctokitListResponse, repository: string, limit: number): PaginatedResult<Issue>;
|
|
16
|
+
//# sourceMappingURL=mappers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,oBAAoB,EAC1B,UAAU,EAAE,MAAM,GACjB,WAAW,CAmBb;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAOlE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC,KAAK,CAAC,CAOxB"}
|
package/dist/mappers.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map an Octokit issue response to a GitHubIssue domain object.
|
|
3
|
+
*/
|
|
4
|
+
export function mapToGitHubIssue(data, repository) {
|
|
5
|
+
return {
|
|
6
|
+
id: String(data.number),
|
|
7
|
+
title: data.title,
|
|
8
|
+
body: data.body ?? '',
|
|
9
|
+
state: data.state,
|
|
10
|
+
labels: data.labels.map((label) => typeof label === 'string' ? label : label.name ?? ''),
|
|
11
|
+
assignees: (data.assignees ?? []).map((a) => a.login),
|
|
12
|
+
createdAt: new Date(data.created_at),
|
|
13
|
+
updatedAt: new Date(data.updated_at),
|
|
14
|
+
number: data.number,
|
|
15
|
+
repository,
|
|
16
|
+
htmlUrl: data.html_url,
|
|
17
|
+
linkedPRs: data.pull_request ? [data.number] : [],
|
|
18
|
+
milestone: data.milestone ? mapMilestone(data.milestone) : undefined,
|
|
19
|
+
reactions: data.reactions ? mapReactions(data.reactions) : undefined,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Map an Octokit comment response to a Comment domain object.
|
|
24
|
+
*/
|
|
25
|
+
export function mapToComment(data) {
|
|
26
|
+
return {
|
|
27
|
+
id: String(data.id),
|
|
28
|
+
body: data.body ?? '',
|
|
29
|
+
author: data.user?.login ?? 'unknown',
|
|
30
|
+
createdAt: new Date(data.created_at),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Wrap a list of mapped issues into a PaginatedResult.
|
|
35
|
+
*/
|
|
36
|
+
export function mapIssuesToPaginatedResult(data, repository, limit) {
|
|
37
|
+
const items = data.map((item) => mapToGitHubIssue(item, repository));
|
|
38
|
+
return {
|
|
39
|
+
items,
|
|
40
|
+
total: items.length,
|
|
41
|
+
hasMore: items.length === limit,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function mapMilestone(milestone) {
|
|
45
|
+
return {
|
|
46
|
+
number: milestone.number,
|
|
47
|
+
title: milestone.title,
|
|
48
|
+
dueOn: milestone.due_on ? new Date(milestone.due_on) : undefined,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function mapReactions(reactions) {
|
|
52
|
+
return {
|
|
53
|
+
'+1': reactions['+1'] ?? 0,
|
|
54
|
+
'-1': reactions['-1'] ?? 0,
|
|
55
|
+
laugh: reactions.laugh ?? 0,
|
|
56
|
+
hooray: reactions.hooray ?? 0,
|
|
57
|
+
confused: reactions.confused ?? 0,
|
|
58
|
+
heart: reactions.heart ?? 0,
|
|
59
|
+
rocket: reactions.rocket ?? 0,
|
|
60
|
+
eyes: reactions.eyes ?? 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=mappers.js.map
|
|
@@ -0,0 +1 @@
|
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3B,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC;QAC7B,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC;KAC1B,CAAC;AACJ,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Issue, IssueSpec, IssueUpdate, IssueQuery, Comment, PaginatedResult } from '@generacy-ai/latency';
|
|
2
|
+
import { AbstractIssueTrackerPlugin } from '@generacy-ai/latency-plugin-issue-tracker';
|
|
3
|
+
import type { GitHubIssue } from '@generacy-ai/github-issues-interface';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for the GitHub Issues plugin.
|
|
6
|
+
*/
|
|
7
|
+
export interface GitHubConfig {
|
|
8
|
+
/** GitHub personal access token. */
|
|
9
|
+
token: string;
|
|
10
|
+
/** Repository owner. */
|
|
11
|
+
owner: string;
|
|
12
|
+
/** Repository name. */
|
|
13
|
+
repo: string;
|
|
14
|
+
/** Cache TTL in milliseconds. Defaults to 60000 (1 minute). */
|
|
15
|
+
cacheTimeout?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* GitHub Issues plugin extending AbstractIssueTrackerPlugin.
|
|
19
|
+
*
|
|
20
|
+
* Implements all five abstract methods for the IssueTracker interface
|
|
21
|
+
* plus GitHub-specific methods: linkPullRequest and addLabels.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GitHubIssuesPlugin extends AbstractIssueTrackerPlugin {
|
|
24
|
+
private client;
|
|
25
|
+
private repository;
|
|
26
|
+
constructor(config: GitHubConfig);
|
|
27
|
+
protected fetchIssue(id: string): Promise<Issue>;
|
|
28
|
+
protected doCreateIssue(spec: IssueSpec): Promise<Issue>;
|
|
29
|
+
protected doUpdateIssue(id: string, update: IssueUpdate): Promise<Issue>;
|
|
30
|
+
protected doListIssues(query: IssueQuery): Promise<PaginatedResult<Issue>>;
|
|
31
|
+
protected doAddComment(issueId: string, comment: string): Promise<Comment>;
|
|
32
|
+
protected doListComments(issueId: string): Promise<Comment[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Link a pull request to an issue by adding a cross-reference comment.
|
|
35
|
+
* GitHub automatically renders bidirectional references.
|
|
36
|
+
*/
|
|
37
|
+
linkPullRequest(issueId: string, prNumber: number): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Add labels to an issue and return the updated issue.
|
|
40
|
+
*/
|
|
41
|
+
addLabels(issueId: string, labels: string[]): Promise<GitHubIssue>;
|
|
42
|
+
private parseIssueNumber;
|
|
43
|
+
}
|
|
44
|
+
//# 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,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,OAAO,EACP,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,sCAAsC,CAAC;AAIzF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,0BAA0B;IAChE,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAS;gBAEf,MAAM,EAAE,YAAY;cAMhB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;cAMtC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;cAY9C,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;cAY9D,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;cAgBhE,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;cAMhE,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMnE;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQvE;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAQxE,OAAO,CAAC,gBAAgB;CAOzB"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { FacetError } from '@generacy-ai/latency';
|
|
2
|
+
import { AbstractIssueTrackerPlugin } from '@generacy-ai/latency-plugin-issue-tracker';
|
|
3
|
+
import { GitHubClient } from './client.js';
|
|
4
|
+
import { mapToGitHubIssue, mapToComment, mapIssuesToPaginatedResult } from './mappers.js';
|
|
5
|
+
/**
|
|
6
|
+
* GitHub Issues plugin extending AbstractIssueTrackerPlugin.
|
|
7
|
+
*
|
|
8
|
+
* Implements all five abstract methods for the IssueTracker interface
|
|
9
|
+
* plus GitHub-specific methods: linkPullRequest and addLabels.
|
|
10
|
+
*/
|
|
11
|
+
export class GitHubIssuesPlugin extends AbstractIssueTrackerPlugin {
|
|
12
|
+
client;
|
|
13
|
+
repository;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super({ cacheTimeout: config.cacheTimeout });
|
|
16
|
+
this.client = new GitHubClient(config.token, config.owner, config.repo);
|
|
17
|
+
this.repository = `${config.owner}/${config.repo}`;
|
|
18
|
+
}
|
|
19
|
+
async fetchIssue(id) {
|
|
20
|
+
const number = this.parseIssueNumber(id);
|
|
21
|
+
const data = await this.client.getIssue(number);
|
|
22
|
+
return mapToGitHubIssue(data, this.repository);
|
|
23
|
+
}
|
|
24
|
+
async doCreateIssue(spec) {
|
|
25
|
+
const ghSpec = spec;
|
|
26
|
+
const data = await this.client.createIssue({
|
|
27
|
+
title: spec.title,
|
|
28
|
+
body: spec.body,
|
|
29
|
+
labels: spec.labels,
|
|
30
|
+
assignees: spec.assignees,
|
|
31
|
+
milestone: ghSpec.milestone,
|
|
32
|
+
});
|
|
33
|
+
return mapToGitHubIssue(data, this.repository);
|
|
34
|
+
}
|
|
35
|
+
async doUpdateIssue(id, update) {
|
|
36
|
+
const number = this.parseIssueNumber(id);
|
|
37
|
+
const data = await this.client.updateIssue(number, {
|
|
38
|
+
title: update.title,
|
|
39
|
+
body: update.body,
|
|
40
|
+
state: update.state,
|
|
41
|
+
labels: update.labels,
|
|
42
|
+
assignees: update.assignees,
|
|
43
|
+
});
|
|
44
|
+
return mapToGitHubIssue(data, this.repository);
|
|
45
|
+
}
|
|
46
|
+
async doListIssues(query) {
|
|
47
|
+
const limit = query.limit ?? 30;
|
|
48
|
+
const offset = query.offset ?? 0;
|
|
49
|
+
const page = Math.floor(offset / limit) + 1;
|
|
50
|
+
const data = await this.client.listIssues({
|
|
51
|
+
state: query.state,
|
|
52
|
+
labels: query.labels?.join(','),
|
|
53
|
+
assignee: query.assignee,
|
|
54
|
+
per_page: limit,
|
|
55
|
+
page,
|
|
56
|
+
});
|
|
57
|
+
return mapIssuesToPaginatedResult(data, this.repository, limit);
|
|
58
|
+
}
|
|
59
|
+
async doAddComment(issueId, comment) {
|
|
60
|
+
const number = this.parseIssueNumber(issueId);
|
|
61
|
+
const data = await this.client.createComment(number, comment);
|
|
62
|
+
return mapToComment(data);
|
|
63
|
+
}
|
|
64
|
+
async doListComments(issueId) {
|
|
65
|
+
const number = this.parseIssueNumber(issueId);
|
|
66
|
+
const data = await this.client.listComments(number);
|
|
67
|
+
return data.map(mapToComment);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Link a pull request to an issue by adding a cross-reference comment.
|
|
71
|
+
* GitHub automatically renders bidirectional references.
|
|
72
|
+
*/
|
|
73
|
+
async linkPullRequest(issueId, prNumber) {
|
|
74
|
+
const number = this.parseIssueNumber(issueId);
|
|
75
|
+
await this.client.createComment(number, `Linked to pull request #${prNumber}`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Add labels to an issue and return the updated issue.
|
|
79
|
+
*/
|
|
80
|
+
async addLabels(issueId, labels) {
|
|
81
|
+
const number = this.parseIssueNumber(issueId);
|
|
82
|
+
const data = await this.client.addLabels(number, labels);
|
|
83
|
+
const issue = mapToGitHubIssue(data, this.repository);
|
|
84
|
+
this.cache.set(issueId, { value: issue, cachedAt: Date.now() });
|
|
85
|
+
return issue;
|
|
86
|
+
}
|
|
87
|
+
parseIssueNumber(id) {
|
|
88
|
+
const num = parseInt(id, 10);
|
|
89
|
+
if (isNaN(num) || num <= 0) {
|
|
90
|
+
throw new FacetError(`Invalid issue number: ${id}`, 'VALIDATION');
|
|
91
|
+
}
|
|
92
|
+
return num;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAgB1F;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,0BAA0B;IACxD,MAAM,CAAe;IACrB,UAAU,CAAS;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
"name": "@generacy-ai/latency-plugin-github-issues",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "GitHub Issues plugin implementation for the Latency ecosystem",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/generacy-ai/latency.git",
|
|
9
|
+
"directory": "packages/latency-plugin-github-issues"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@octokit/rest": "^21.0.0",
|
|
22
|
+
"@generacy-ai/github-issues-interface": "0.1.0",
|
|
23
|
+
"@generacy-ai/latency": "0.1.0",
|
|
24
|
+
"@generacy-ai/latency-plugin-issue-tracker": "0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.14.0",
|
|
28
|
+
"typescript": "^5.4.5",
|
|
29
|
+
"vitest": "^3.2.4"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"lint": "tsc --noEmit",
|
|
35
|
+
"test": "vitest run"
|
|
36
|
+
}
|
|
37
|
+
}
|