@generacy-ai/latency-plugin-issue-tracker 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/abstract-plugin.d.ts +83 -0
- package/dist/abstract-plugin.d.ts.map +1 -0
- package/dist/abstract-plugin.js +111 -0
- package/dist/abstract-plugin.js.map +1 -0
- package/dist/caching.d.ts +29 -0
- package/dist/caching.d.ts.map +1 -0
- package/dist/caching.js +20 -0
- package/dist/caching.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +30 -0
- package/dist/validation.js.map +1 -0
- package/package.json +35 -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.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Issue, IssueSpec, IssueUpdate, IssueQuery, IssueTracker, Comment, PaginatedResult } from '@generacy-ai/latency';
|
|
2
|
+
import { type CacheEntry } from './caching.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for {@link AbstractIssueTrackerPlugin}.
|
|
5
|
+
*/
|
|
6
|
+
export interface AbstractIssueTrackerOptions {
|
|
7
|
+
/** Cache TTL in milliseconds. Defaults to 60000 (1 minute). */
|
|
8
|
+
cacheTimeout?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for issue tracker plugin implementations.
|
|
12
|
+
*
|
|
13
|
+
* Provides common caching, validation, and error handling logic using the
|
|
14
|
+
* Template Method pattern. Concrete implementations (e.g., GitHub, Jira, Linear)
|
|
15
|
+
* extend this class and implement only the protected `do*` methods.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* class GitHubIssueTracker extends AbstractIssueTrackerPlugin {
|
|
20
|
+
* protected async fetchIssue(id: string): Promise<Issue> {
|
|
21
|
+
* // GitHub API call
|
|
22
|
+
* }
|
|
23
|
+
* // ... other do* methods
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class AbstractIssueTrackerPlugin implements IssueTracker {
|
|
28
|
+
protected readonly cache: Map<string, CacheEntry<Issue>>;
|
|
29
|
+
protected readonly cacheTimeout: number;
|
|
30
|
+
constructor(options?: AbstractIssueTrackerOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve an issue by ID, returning a cached value if available and not expired.
|
|
33
|
+
*/
|
|
34
|
+
getIssue(id: string): Promise<Issue>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new issue after validating the spec.
|
|
37
|
+
*/
|
|
38
|
+
createIssue(spec: IssueSpec): Promise<Issue>;
|
|
39
|
+
/**
|
|
40
|
+
* Update an existing issue after validating the update payload.
|
|
41
|
+
*/
|
|
42
|
+
updateIssue(id: string, update: IssueUpdate): Promise<Issue>;
|
|
43
|
+
/**
|
|
44
|
+
* List issues matching the given query. Results are not cached.
|
|
45
|
+
*/
|
|
46
|
+
listIssues(query: IssueQuery): Promise<PaginatedResult<Issue>>;
|
|
47
|
+
/**
|
|
48
|
+
* Add a comment to an issue. Validates that the comment is non-empty.
|
|
49
|
+
*/
|
|
50
|
+
addComment(issueId: string, comment: string): Promise<Comment>;
|
|
51
|
+
/**
|
|
52
|
+
* List comments on an issue in chronological order.
|
|
53
|
+
*/
|
|
54
|
+
listComments(issueId: string): Promise<Comment[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Invalidate cached entries. Pass an ID to clear a single entry,
|
|
57
|
+
* or call with no arguments to clear the entire cache.
|
|
58
|
+
*/
|
|
59
|
+
invalidateCache(id?: string): void;
|
|
60
|
+
/** Fetch a single issue from the backend. */
|
|
61
|
+
protected abstract fetchIssue(id: string): Promise<Issue>;
|
|
62
|
+
/** Create an issue in the backend. */
|
|
63
|
+
protected abstract doCreateIssue(spec: IssueSpec): Promise<Issue>;
|
|
64
|
+
/** Update an issue in the backend. */
|
|
65
|
+
protected abstract doUpdateIssue(id: string, update: IssueUpdate): Promise<Issue>;
|
|
66
|
+
/** List issues from the backend. */
|
|
67
|
+
protected abstract doListIssues(query: IssueQuery): Promise<PaginatedResult<Issue>>;
|
|
68
|
+
/** Add a comment in the backend. */
|
|
69
|
+
protected abstract doAddComment(issueId: string, comment: string): Promise<Comment>;
|
|
70
|
+
/** List comments from the backend. */
|
|
71
|
+
protected abstract doListComments(issueId: string): Promise<Comment[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Validate an issue creation spec. Override to add additional validation.
|
|
74
|
+
* @throws {ValidationError} If the spec is invalid.
|
|
75
|
+
*/
|
|
76
|
+
protected validateIssueSpec(spec: IssueSpec): void;
|
|
77
|
+
/**
|
|
78
|
+
* Validate an issue update payload. Override to add additional validation.
|
|
79
|
+
* @throws {ValidationError} If the update is invalid.
|
|
80
|
+
*/
|
|
81
|
+
protected validateIssueUpdate(update: IssueUpdate): void;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=abstract-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-plugin.d.ts","sourceRoot":"","sources":["../src/abstract-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,OAAO,EACP,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,KAAK,UAAU,EAAoC,MAAM,cAAc,CAAC;AAGjF;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,8BAAsB,0BAA2B,YAAW,YAAY;IACtE,SAAS,CAAC,QAAQ,CAAC,KAAK,iCAAwC;IAChE,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;gBAE5B,OAAO,CAAC,EAAE,2BAA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sCAAsC;IACtC,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMtE;;;OAGG;IACH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAMlD;;;OAGG;IACH,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAKzD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createCacheEntry, isCacheExpired } from './caching.js';
|
|
2
|
+
import { ValidationError } from './validation.js';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for issue tracker plugin implementations.
|
|
5
|
+
*
|
|
6
|
+
* Provides common caching, validation, and error handling logic using the
|
|
7
|
+
* Template Method pattern. Concrete implementations (e.g., GitHub, Jira, Linear)
|
|
8
|
+
* extend this class and implement only the protected `do*` methods.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* class GitHubIssueTracker extends AbstractIssueTrackerPlugin {
|
|
13
|
+
* protected async fetchIssue(id: string): Promise<Issue> {
|
|
14
|
+
* // GitHub API call
|
|
15
|
+
* }
|
|
16
|
+
* // ... other do* methods
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class AbstractIssueTrackerPlugin {
|
|
21
|
+
cache = new Map();
|
|
22
|
+
cacheTimeout;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.cacheTimeout = options?.cacheTimeout ?? 60000;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve an issue by ID, returning a cached value if available and not expired.
|
|
28
|
+
*/
|
|
29
|
+
async getIssue(id) {
|
|
30
|
+
const cached = this.cache.get(id);
|
|
31
|
+
if (cached && !isCacheExpired(cached, this.cacheTimeout)) {
|
|
32
|
+
return cached.value;
|
|
33
|
+
}
|
|
34
|
+
const issue = await this.fetchIssue(id);
|
|
35
|
+
this.cache.set(id, createCacheEntry(issue));
|
|
36
|
+
return issue;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a new issue after validating the spec.
|
|
40
|
+
*/
|
|
41
|
+
async createIssue(spec) {
|
|
42
|
+
this.validateIssueSpec(spec);
|
|
43
|
+
const issue = await this.doCreateIssue(spec);
|
|
44
|
+
this.cache.set(issue.id, createCacheEntry(issue));
|
|
45
|
+
return issue;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Update an existing issue after validating the update payload.
|
|
49
|
+
*/
|
|
50
|
+
async updateIssue(id, update) {
|
|
51
|
+
this.validateIssueUpdate(update);
|
|
52
|
+
const issue = await this.doUpdateIssue(id, update);
|
|
53
|
+
this.cache.set(id, createCacheEntry(issue));
|
|
54
|
+
return issue;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* List issues matching the given query. Results are not cached.
|
|
58
|
+
*/
|
|
59
|
+
async listIssues(query) {
|
|
60
|
+
return this.doListIssues(query);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add a comment to an issue. Validates that the comment is non-empty.
|
|
64
|
+
*/
|
|
65
|
+
async addComment(issueId, comment) {
|
|
66
|
+
if (!comment?.trim()) {
|
|
67
|
+
throw new ValidationError('Comment cannot be empty');
|
|
68
|
+
}
|
|
69
|
+
return this.doAddComment(issueId, comment);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* List comments on an issue in chronological order.
|
|
73
|
+
*/
|
|
74
|
+
async listComments(issueId) {
|
|
75
|
+
return this.doListComments(issueId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Invalidate cached entries. Pass an ID to clear a single entry,
|
|
79
|
+
* or call with no arguments to clear the entire cache.
|
|
80
|
+
*/
|
|
81
|
+
invalidateCache(id) {
|
|
82
|
+
if (id) {
|
|
83
|
+
this.cache.delete(id);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.cache.clear();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// -------------------------------------------------------------------------
|
|
90
|
+
// Validation helpers (overridable by subclasses)
|
|
91
|
+
// -------------------------------------------------------------------------
|
|
92
|
+
/**
|
|
93
|
+
* Validate an issue creation spec. Override to add additional validation.
|
|
94
|
+
* @throws {ValidationError} If the spec is invalid.
|
|
95
|
+
*/
|
|
96
|
+
validateIssueSpec(spec) {
|
|
97
|
+
if (!spec.title?.trim()) {
|
|
98
|
+
throw new ValidationError('Issue title is required');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Validate an issue update payload. Override to add additional validation.
|
|
103
|
+
* @throws {ValidationError} If the update is invalid.
|
|
104
|
+
*/
|
|
105
|
+
validateIssueUpdate(update) {
|
|
106
|
+
if (update.title !== undefined && !update.title.trim()) {
|
|
107
|
+
throw new ValidationError('Issue title cannot be empty');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=abstract-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-plugin.js","sourceRoot":"","sources":["../src/abstract-plugin.ts"],"names":[],"mappings":"AAUA,OAAO,EAAmB,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAUlD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,0BAA0B;IAC3B,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC7C,YAAY,CAAS;IAExC,YAAY,OAAqC;QAC/C,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,KAAK,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,MAAM,IA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C;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,OAAe;QAChC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,EAAW;QACzB,IAAI,EAAE,EAAE,CAAC;YACP,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IAwBD,4EAA4E;IAC5E,iDAAiD;IACjD,4EAA4E;IAE5E;;;OAGG;IACO,iBAAiB,CAAC,IAAe;QACzC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,yBAAyB,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,mBAAmB,CAAC,MAAmB;QAC/C,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACvD,MAAM,IAAI,eAAe,CAAC,6BAA6B,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cache entry wrapping a value with its insertion timestamp.
|
|
3
|
+
*
|
|
4
|
+
* Used by {@link AbstractIssueTrackerPlugin} to implement TTL-based caching.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam T - The type of the cached value.
|
|
7
|
+
*/
|
|
8
|
+
export interface CacheEntry<T> {
|
|
9
|
+
/** The cached value. */
|
|
10
|
+
value: T;
|
|
11
|
+
/** Timestamp (from `Date.now()`) when the entry was cached. */
|
|
12
|
+
cachedAt: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a new cache entry for the given value using the current timestamp.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The value to cache.
|
|
18
|
+
* @returns A {@link CacheEntry} wrapping the value with the current time.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createCacheEntry<T>(value: T): CacheEntry<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Check whether a cache entry has exceeded the given TTL.
|
|
23
|
+
*
|
|
24
|
+
* @param entry - The cache entry to check.
|
|
25
|
+
* @param timeout - The TTL in milliseconds.
|
|
26
|
+
* @returns `true` if the entry is expired, `false` otherwise.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCacheExpired<T>(entry: CacheEntry<T>, timeout: number): boolean;
|
|
29
|
+
//# sourceMappingURL=caching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caching.d.ts","sourceRoot":"","sources":["../src/caching.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,wBAAwB;IACxB,KAAK,EAAE,CAAC,CAAC;IACT,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEhF"}
|
package/dist/caching.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new cache entry for the given value using the current timestamp.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to cache.
|
|
5
|
+
* @returns A {@link CacheEntry} wrapping the value with the current time.
|
|
6
|
+
*/
|
|
7
|
+
export function createCacheEntry(value) {
|
|
8
|
+
return { value, cachedAt: Date.now() };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check whether a cache entry has exceeded the given TTL.
|
|
12
|
+
*
|
|
13
|
+
* @param entry - The cache entry to check.
|
|
14
|
+
* @param timeout - The TTL in milliseconds.
|
|
15
|
+
* @returns `true` if the entry is expired, `false` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export function isCacheExpired(entry, timeout) {
|
|
18
|
+
return Date.now() - entry.cachedAt > timeout;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=caching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caching.js","sourceRoot":"","sources":["../src/caching.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAI,KAAQ;IAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAI,KAAoB,EAAE,OAAe;IACrE,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC;AAC/C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AbstractIssueTrackerPlugin } from './abstract-plugin.js';
|
|
2
|
+
export type { AbstractIssueTrackerOptions } from './abstract-plugin.js';
|
|
3
|
+
export { ValidationError } from './validation.js';
|
|
4
|
+
export type { CacheEntry } from './caching.js';
|
|
5
|
+
export { createCacheEntry, isCacheExpired } from './caching.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,YAAY,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,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,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FacetError } from '@generacy-ai/latency';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when input validation fails in issue tracker operations.
|
|
4
|
+
*
|
|
5
|
+
* Extends {@link FacetError} with a fixed code of `'VALIDATION'`, supporting
|
|
6
|
+
* both `instanceof ValidationError` and `error.code === 'VALIDATION'` checks.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new ValidationError('Issue title is required');
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* try {
|
|
16
|
+
* await tracker.createIssue({ title: '' });
|
|
17
|
+
* } catch (err) {
|
|
18
|
+
* if (err instanceof ValidationError) {
|
|
19
|
+
* console.error('Validation failed:', err.message);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class ValidationError extends FacetError {
|
|
25
|
+
constructor(message: string, options?: {
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FacetError } from '@generacy-ai/latency';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when input validation fails in issue tracker operations.
|
|
4
|
+
*
|
|
5
|
+
* Extends {@link FacetError} with a fixed code of `'VALIDATION'`, supporting
|
|
6
|
+
* both `instanceof ValidationError` and `error.code === 'VALIDATION'` checks.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new ValidationError('Issue title is required');
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* try {
|
|
16
|
+
* await tracker.createIssue({ title: '' });
|
|
17
|
+
* } catch (err) {
|
|
18
|
+
* if (err instanceof ValidationError) {
|
|
19
|
+
* console.error('Validation failed:', err.message);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class ValidationError extends FacetError {
|
|
25
|
+
constructor(message, options) {
|
|
26
|
+
super(message, 'VALIDATION', options);
|
|
27
|
+
this.name = 'ValidationError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@generacy-ai/latency-plugin-issue-tracker",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Abstract issue tracker plugin for the Latency ecosystem",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/generacy-ai/latency.git",
|
|
9
|
+
"directory": "packages/latency-plugin-issue-tracker"
|
|
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
|
+
"@generacy-ai/latency": "0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^5.4.5",
|
|
25
|
+
"@types/node": "^20.14.0",
|
|
26
|
+
"vitest": "^3.2.4"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"lint": "tsc --noEmit",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:coverage": "vitest run --coverage"
|
|
34
|
+
}
|
|
35
|
+
}
|