@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/client.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
import type { GitHubIssuesConfig } from './types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub API client wrapper with authentication and error handling
|
|
5
|
+
*
|
|
6
|
+
* Supports both PAT and GitHub App authentication.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitHubClient {
|
|
9
|
+
private readonly octokit;
|
|
10
|
+
private readonly config;
|
|
11
|
+
private authStrategy;
|
|
12
|
+
private authType;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new GitHubClient
|
|
15
|
+
*
|
|
16
|
+
* For synchronous construction (backward compatible), use token-based auth.
|
|
17
|
+
* For GitHub App auth, use the async createClient() function instead.
|
|
18
|
+
*/
|
|
19
|
+
constructor(config: GitHubIssuesConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize authentication strategy
|
|
22
|
+
* Called automatically by createClientAsync for GitHub App auth
|
|
23
|
+
*/
|
|
24
|
+
initializeAuth(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the authentication type being used
|
|
27
|
+
*/
|
|
28
|
+
get authenticationType(): 'pat' | 'github-app' | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get the owner from config
|
|
31
|
+
*/
|
|
32
|
+
get owner(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the repo from config
|
|
35
|
+
*/
|
|
36
|
+
get repo(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the agent account from config
|
|
39
|
+
*/
|
|
40
|
+
get agentAccount(): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get trigger labels from config
|
|
43
|
+
*/
|
|
44
|
+
get triggerLabels(): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Get webhook secret from config
|
|
47
|
+
*/
|
|
48
|
+
get webhookSecret(): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Access to the underlying Octokit instance for advanced usage
|
|
51
|
+
*/
|
|
52
|
+
get rest(): Octokit['rest'];
|
|
53
|
+
/**
|
|
54
|
+
* Get the current authentication token
|
|
55
|
+
* For GitHub App, this returns the installation access token
|
|
56
|
+
*/
|
|
57
|
+
getToken(): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Verify authentication by fetching the authenticated user
|
|
60
|
+
*/
|
|
61
|
+
verifyAuth(): Promise<{
|
|
62
|
+
login: string;
|
|
63
|
+
id: number;
|
|
64
|
+
type?: 'User' | 'Bot';
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Check the current rate limit status
|
|
68
|
+
*/
|
|
69
|
+
getRateLimit(): Promise<{
|
|
70
|
+
limit: number;
|
|
71
|
+
remaining: number;
|
|
72
|
+
reset: Date;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Execute a request with error handling
|
|
76
|
+
*/
|
|
77
|
+
request<T>(operation: () => Promise<T>, context?: string): Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Paginate through all results
|
|
80
|
+
*/
|
|
81
|
+
paginate<T>(method: (params: {
|
|
82
|
+
per_page: number;
|
|
83
|
+
page: number;
|
|
84
|
+
}) => Promise<{
|
|
85
|
+
data: T[];
|
|
86
|
+
}>, maxPages?: number): Promise<T[]>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a new GitHub client instance (synchronous, backward compatible)
|
|
90
|
+
*
|
|
91
|
+
* Note: For GitHub App authentication, use createClientAsync() instead.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createClient(config: GitHubIssuesConfig): GitHubClient;
|
|
94
|
+
/**
|
|
95
|
+
* Create a new GitHub client instance with full auth initialization
|
|
96
|
+
*
|
|
97
|
+
* This async version properly initializes GitHub App authentication
|
|
98
|
+
* and should be used when GitHub App auth is configured.
|
|
99
|
+
*/
|
|
100
|
+
export declare function createClientAsync(config: GitHubIssuesConfig): Promise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E,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,IAAI,CAAC;KACb,CAAC;IAaF;;OAEG;IACG,OAAO,CAAC,CAAC,EACb,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,CAAC,CAAC;IAyBb;;OAEG;IACG,QAAQ,CAAC,CAAC,EACd,MAAM,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,EAAE,CAAA;KAAE,CAAC,EAC9E,QAAQ,SAAK,GACZ,OAAO,CAAC,CAAC,EAAE,CAAC;CAgBhB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAErE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAIzF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
import { validateConfig } from './utils/validation.js';
|
|
3
|
+
import { createAuthStrategy } from './auth/auth-factory.js';
|
|
4
|
+
import { readGitHubAppConfigFromEnv } from './auth/env.js';
|
|
5
|
+
import { GitHubAuthError, GitHubRateLimitError, wrapGitHubError, } from './utils/errors.js';
|
|
6
|
+
/**
|
|
7
|
+
* GitHub API client wrapper with authentication and error handling
|
|
8
|
+
*
|
|
9
|
+
* Supports both PAT and GitHub App authentication.
|
|
10
|
+
*/
|
|
11
|
+
export class GitHubClient {
|
|
12
|
+
octokit;
|
|
13
|
+
config;
|
|
14
|
+
authStrategy = null;
|
|
15
|
+
authType;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new GitHubClient
|
|
18
|
+
*
|
|
19
|
+
* For synchronous construction (backward compatible), use token-based auth.
|
|
20
|
+
* For GitHub App auth, use the async createClient() function instead.
|
|
21
|
+
*/
|
|
22
|
+
constructor(config) {
|
|
23
|
+
this.config = validateConfig(config);
|
|
24
|
+
// For synchronous construction, use token if available
|
|
25
|
+
// GitHub App auth requires async initialization
|
|
26
|
+
this.octokit = new Octokit({
|
|
27
|
+
auth: this.config.token,
|
|
28
|
+
baseUrl: this.config.baseUrl,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Initialize authentication strategy
|
|
33
|
+
* Called automatically by createClientAsync for GitHub App auth
|
|
34
|
+
*/
|
|
35
|
+
async initializeAuth() {
|
|
36
|
+
// Merge env config with explicit config (explicit takes precedence)
|
|
37
|
+
const envAppConfig = readGitHubAppConfigFromEnv();
|
|
38
|
+
const appConfig = this.config.app ?? envAppConfig;
|
|
39
|
+
this.authStrategy = await createAuthStrategy({
|
|
40
|
+
owner: this.config.owner,
|
|
41
|
+
repo: this.config.repo,
|
|
42
|
+
token: this.config.token,
|
|
43
|
+
app: appConfig,
|
|
44
|
+
baseUrl: this.config.baseUrl,
|
|
45
|
+
});
|
|
46
|
+
this.authType = this.authStrategy.type;
|
|
47
|
+
// Log which auth method is active
|
|
48
|
+
if (this.authType === 'github-app') {
|
|
49
|
+
console.log(`[GitHubClient] Initialized with GitHub App authentication for ${this.config.owner}/${this.config.repo}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(`[GitHubClient] Initialized with PAT authentication for ${this.config.owner}/${this.config.repo}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the authentication type being used
|
|
57
|
+
*/
|
|
58
|
+
get authenticationType() {
|
|
59
|
+
return this.authType;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the owner from config
|
|
63
|
+
*/
|
|
64
|
+
get owner() {
|
|
65
|
+
return this.config.owner;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the repo from config
|
|
69
|
+
*/
|
|
70
|
+
get repo() {
|
|
71
|
+
return this.config.repo;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the agent account from config
|
|
75
|
+
*/
|
|
76
|
+
get agentAccount() {
|
|
77
|
+
return this.config.agentAccount;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get trigger labels from config
|
|
81
|
+
*/
|
|
82
|
+
get triggerLabels() {
|
|
83
|
+
return this.config.triggerLabels ?? [];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get webhook secret from config
|
|
87
|
+
*/
|
|
88
|
+
get webhookSecret() {
|
|
89
|
+
return this.config.webhookSecret;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Access to the underlying Octokit instance for advanced usage
|
|
93
|
+
*/
|
|
94
|
+
get rest() {
|
|
95
|
+
return this.octokit.rest;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the current authentication token
|
|
99
|
+
* For GitHub App, this returns the installation access token
|
|
100
|
+
*/
|
|
101
|
+
async getToken() {
|
|
102
|
+
if (this.authStrategy) {
|
|
103
|
+
return this.authStrategy.getToken();
|
|
104
|
+
}
|
|
105
|
+
// Fallback to configured token
|
|
106
|
+
return this.config.token ?? '';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Verify authentication by fetching the authenticated user
|
|
110
|
+
*/
|
|
111
|
+
async verifyAuth() {
|
|
112
|
+
try {
|
|
113
|
+
if (this.authStrategy) {
|
|
114
|
+
const verification = await this.authStrategy.verify();
|
|
115
|
+
return { login: verification.login, id: verification.id, type: verification.type };
|
|
116
|
+
}
|
|
117
|
+
const { data } = await this.octokit.rest.users.getAuthenticated();
|
|
118
|
+
return { login: data.login, id: data.id, type: data.type };
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
throw new GitHubAuthError('Failed to verify authentication', error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Check the current rate limit status
|
|
126
|
+
*/
|
|
127
|
+
async getRateLimit() {
|
|
128
|
+
try {
|
|
129
|
+
const { data } = await this.octokit.rest.rateLimit.get();
|
|
130
|
+
return {
|
|
131
|
+
limit: data.rate.limit,
|
|
132
|
+
remaining: data.rate.remaining,
|
|
133
|
+
reset: new Date(data.rate.reset * 1000),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
throw wrapGitHubError(error, 'Failed to get rate limit');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Execute a request with error handling
|
|
142
|
+
*/
|
|
143
|
+
async request(operation, context) {
|
|
144
|
+
try {
|
|
145
|
+
return await operation();
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
// Check for rate limit error
|
|
149
|
+
if (typeof error === 'object' &&
|
|
150
|
+
error !== null &&
|
|
151
|
+
'status' in error &&
|
|
152
|
+
error.status === 429) {
|
|
153
|
+
const headers = error.headers;
|
|
154
|
+
const resetTimestamp = headers?.['x-ratelimit-reset'];
|
|
155
|
+
const resetAt = resetTimestamp ? new Date(parseInt(resetTimestamp, 10) * 1000) : undefined;
|
|
156
|
+
throw new GitHubRateLimitError(`Rate limit exceeded${context ? ` for ${context}` : ''}`, resetAt, error);
|
|
157
|
+
}
|
|
158
|
+
throw wrapGitHubError(error, context);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Paginate through all results
|
|
163
|
+
*/
|
|
164
|
+
async paginate(method, maxPages = 10) {
|
|
165
|
+
const results = [];
|
|
166
|
+
let page = 1;
|
|
167
|
+
while (page <= maxPages) {
|
|
168
|
+
const response = await method({ per_page: 100, page });
|
|
169
|
+
results.push(...response.data);
|
|
170
|
+
if (response.data.length < 100) {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
page++;
|
|
174
|
+
}
|
|
175
|
+
return results;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create a new GitHub client instance (synchronous, backward compatible)
|
|
180
|
+
*
|
|
181
|
+
* Note: For GitHub App authentication, use createClientAsync() instead.
|
|
182
|
+
*/
|
|
183
|
+
export function createClient(config) {
|
|
184
|
+
return new GitHubClient(config);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Create a new GitHub client instance with full auth initialization
|
|
188
|
+
*
|
|
189
|
+
* This async version properly initializes GitHub App authentication
|
|
190
|
+
* and should be used when GitHub App auth is configured.
|
|
191
|
+
*/
|
|
192
|
+
export async function createClientAsync(config) {
|
|
193
|
+
const client = new GitHubClient(config);
|
|
194
|
+
await client.initializeAuth();
|
|
195
|
+
return client;
|
|
196
|
+
}
|
|
197
|
+
//# 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;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACN,OAAO,CAAU;IACjB,MAAM,CAAqB;IACpC,YAAY,GAAwB,IAAI,CAAC;IACzC,QAAQ,CAAmC;IAEnD;;;;;OAKG;IACH,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAErC,uDAAuD;QACvD,gDAAgD;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC;YACzB,IAAI,EAAE,IAAI,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C,EAAE,EAAE,EACxD,OAAO,EACP,KAAK,CACN,CAAC;YACJ,CAAC;YAED,MAAM,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CACZ,MAA8E,EAC9E,QAAQ,GAAG,EAAE;QAEb,MAAM,OAAO,GAAQ,EAAE,CAAC;QACxB,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,OAAO,IAAI,IAAI,QAAQ,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;YACvD,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAE/B,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;gBAC/B,MAAM;YACR,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAA0B;IAChE,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { GitHubIssuesPlugin, createPlugin } from './plugin.js';
|
|
2
|
+
export { GitHubClient, createClient, createClientAsync } from './client.js';
|
|
3
|
+
export { GitHubAppAuthStrategy, PATAuthStrategy, createAuthStrategy, createGitHubAppAuth, TokenCache, readGitHubAppConfigFromEnv, hasGitHubAppEnvConfig, GitHubAppConfigSchema, ENV_VARS, } from './auth/index.js';
|
|
4
|
+
export type { GitHubAppConfig, AuthStrategy, AuthVerification, CachedToken, AuthContext, AuthFactoryConfig, TokenCacheOptions, } from './auth/index.js';
|
|
5
|
+
export { IssueOperations, createIssueOperations } from './operations/issues.js';
|
|
6
|
+
export { LabelOperations, createLabelOperations } from './operations/labels.js';
|
|
7
|
+
export { CommentOperations, createCommentOperations } from './operations/comments.js';
|
|
8
|
+
export { PullRequestOperations, createPullRequestOperations } from './operations/pull-requests.js';
|
|
9
|
+
export { WebhookHandler, createWebhookHandler, parseWebhookEvent, isSupportedEvent, evaluateTriggers, requiresProcessing, getActionIssueNumber, } from './webhooks/handler.js';
|
|
10
|
+
export type { WebhookHandlerConfig, WebhookHeaders, WebhookResult, TriggerConfig, } from './webhooks/handler.js';
|
|
11
|
+
export type { GitHubIssuesConfig, ValidatedConfig, User, Label, Comment, Milestone, Issue, PullRequest, CreateIssueParams, UpdateIssueParams, IssueFilter, Repository, WebhookEvent, IssuesEventPayload, IssueCommentEventPayload, PullRequestEventPayload, WebhookEventName, TypedWebhookEvent, QueueForProcessingAction, StartWorkflowAction, ResumeWorkflowAction, NoAction, WorkflowAction, OperationResult, OperationError, OperationResponse, } from './types/index.js';
|
|
12
|
+
export { GitHubIssuesConfigSchema, CreateIssueParamsSchema, UpdateIssueParamsSchema, IssueFilterSchema, } from './types/index.js';
|
|
13
|
+
export { GitHubIssuesError, GitHubAuthError, GitHubAppAuthError, GitHubAppErrorCode, GitHubRateLimitError, GitHubNotFoundError, GitHubValidationError, WebhookVerificationError, wrapGitHubError, } from './utils/errors.js';
|
|
14
|
+
export { validate, validateConfig, validateCreateIssueParams, validateUpdateIssueParams, validateIssueFilter, isNonEmptyString, isPositiveInteger, } from './utils/validation.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],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,eAAe,EACf,cAAc,EACd,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Main plugin export
|
|
2
|
+
export { GitHubIssuesPlugin, createPlugin } from './plugin.js';
|
|
3
|
+
// Client export
|
|
4
|
+
export { GitHubClient, createClient, createClientAsync } from './client.js';
|
|
5
|
+
// Auth exports
|
|
6
|
+
export { GitHubAppAuthStrategy, PATAuthStrategy, createAuthStrategy, createGitHubAppAuth, TokenCache, readGitHubAppConfigFromEnv, hasGitHubAppEnvConfig, GitHubAppConfigSchema, ENV_VARS, } from './auth/index.js';
|
|
7
|
+
// Operations exports
|
|
8
|
+
export { IssueOperations, createIssueOperations } from './operations/issues.js';
|
|
9
|
+
export { LabelOperations, createLabelOperations } from './operations/labels.js';
|
|
10
|
+
export { CommentOperations, createCommentOperations } from './operations/comments.js';
|
|
11
|
+
export { PullRequestOperations, createPullRequestOperations } from './operations/pull-requests.js';
|
|
12
|
+
// Webhook exports
|
|
13
|
+
export { WebhookHandler, createWebhookHandler, parseWebhookEvent, isSupportedEvent, evaluateTriggers, requiresProcessing, getActionIssueNumber, } from './webhooks/handler.js';
|
|
14
|
+
// Schema exports
|
|
15
|
+
export { GitHubIssuesConfigSchema, CreateIssueParamsSchema, UpdateIssueParamsSchema, IssueFilterSchema, } from './types/index.js';
|
|
16
|
+
// Error exports
|
|
17
|
+
export { GitHubIssuesError, GitHubAuthError, GitHubAppAuthError, GitHubAppErrorCode, GitHubRateLimitError, GitHubNotFoundError, GitHubValidationError, WebhookVerificationError, wrapGitHubError, } from './utils/errors.js';
|
|
18
|
+
// Validation exports
|
|
19
|
+
export { validate, validateConfig, validateCreateIssueParams, validateUpdateIssueParams, validateIssueFilter, isNonEmptyString, isPositiveInteger, } from './utils/validation.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/D,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE5E,eAAe;AACf,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAYzB,qBAAqB;AACrB,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEnG,kBAAkB;AAClB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AA8C/B,iBAAiB;AACjB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,gBAAgB;AAChB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,qBAAqB;AACrB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GitHubClient } from '../client.js';
|
|
2
|
+
import type { Comment } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Comment operations using the GitHub client
|
|
5
|
+
*/
|
|
6
|
+
export declare class CommentOperations {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: GitHubClient);
|
|
9
|
+
/**
|
|
10
|
+
* Add a comment to an issue
|
|
11
|
+
*/
|
|
12
|
+
add(issueNumber: number, body: string): Promise<Comment>;
|
|
13
|
+
/**
|
|
14
|
+
* Update an existing comment
|
|
15
|
+
*/
|
|
16
|
+
update(commentId: number, body: string): Promise<Comment>;
|
|
17
|
+
/**
|
|
18
|
+
* Delete a comment
|
|
19
|
+
*/
|
|
20
|
+
delete(commentId: number): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a single comment by ID
|
|
23
|
+
*/
|
|
24
|
+
get(commentId: number): Promise<Comment>;
|
|
25
|
+
/**
|
|
26
|
+
* List all comments on an issue
|
|
27
|
+
*/
|
|
28
|
+
list(issueNumber: number): Promise<Comment[]>;
|
|
29
|
+
/**
|
|
30
|
+
* List comments on an issue since a specific date
|
|
31
|
+
*/
|
|
32
|
+
listSince(issueNumber: number, since: Date): Promise<Comment[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Find comments by author
|
|
35
|
+
*/
|
|
36
|
+
findByAuthor(issueNumber: number, authorLogin: string): Promise<Comment[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Find comments matching a pattern
|
|
39
|
+
*/
|
|
40
|
+
findByPattern(issueNumber: number, pattern: RegExp): Promise<Comment[]>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create comment operations instance
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCommentOperations(client: GitHubClient): CommentOperations;
|
|
46
|
+
//# sourceMappingURL=comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/operations/comments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AA+BvD;;GAEG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAEjD;;OAEG;IACG,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB9D;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB/D;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9C;;OAEG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAc9C;;OAEG;IACG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAenD;;OAEG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAgBrE;;OAEG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAKhF;;OAEG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAI9E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,iBAAiB,CAE/E"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { GitHubValidationError } from '../utils/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Transform GitHub API comment response to our Comment type
|
|
4
|
+
*/
|
|
5
|
+
function transformComment(apiComment) {
|
|
6
|
+
return {
|
|
7
|
+
id: apiComment.id,
|
|
8
|
+
body: apiComment.body ?? '',
|
|
9
|
+
author: apiComment.user
|
|
10
|
+
? {
|
|
11
|
+
id: apiComment.user.id,
|
|
12
|
+
login: apiComment.user.login,
|
|
13
|
+
avatarUrl: apiComment.user.avatar_url,
|
|
14
|
+
type: (apiComment.user.type ?? 'User'),
|
|
15
|
+
}
|
|
16
|
+
: { id: 0, login: 'unknown', avatarUrl: '', type: 'User' },
|
|
17
|
+
createdAt: apiComment.created_at,
|
|
18
|
+
updatedAt: apiComment.updated_at,
|
|
19
|
+
htmlUrl: apiComment.html_url,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Comment operations using the GitHub client
|
|
24
|
+
*/
|
|
25
|
+
export class CommentOperations {
|
|
26
|
+
client;
|
|
27
|
+
constructor(client) {
|
|
28
|
+
this.client = client;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Add a comment to an issue
|
|
32
|
+
*/
|
|
33
|
+
async add(issueNumber, body) {
|
|
34
|
+
if (!body.trim()) {
|
|
35
|
+
throw new GitHubValidationError('Comment body cannot be empty');
|
|
36
|
+
}
|
|
37
|
+
const { data } = await this.client.request(() => this.client.rest.issues.createComment({
|
|
38
|
+
owner: this.client.owner,
|
|
39
|
+
repo: this.client.repo,
|
|
40
|
+
issue_number: issueNumber,
|
|
41
|
+
body,
|
|
42
|
+
}), `add comment to issue #${issueNumber}`);
|
|
43
|
+
return transformComment(data);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Update an existing comment
|
|
47
|
+
*/
|
|
48
|
+
async update(commentId, body) {
|
|
49
|
+
if (!body.trim()) {
|
|
50
|
+
throw new GitHubValidationError('Comment body cannot be empty');
|
|
51
|
+
}
|
|
52
|
+
const { data } = await this.client.request(() => this.client.rest.issues.updateComment({
|
|
53
|
+
owner: this.client.owner,
|
|
54
|
+
repo: this.client.repo,
|
|
55
|
+
comment_id: commentId,
|
|
56
|
+
body,
|
|
57
|
+
}), `update comment #${commentId}`);
|
|
58
|
+
return transformComment(data);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Delete a comment
|
|
62
|
+
*/
|
|
63
|
+
async delete(commentId) {
|
|
64
|
+
await this.client.request(() => this.client.rest.issues.deleteComment({
|
|
65
|
+
owner: this.client.owner,
|
|
66
|
+
repo: this.client.repo,
|
|
67
|
+
comment_id: commentId,
|
|
68
|
+
}), `delete comment #${commentId}`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get a single comment by ID
|
|
72
|
+
*/
|
|
73
|
+
async get(commentId) {
|
|
74
|
+
const { data } = await this.client.request(() => this.client.rest.issues.getComment({
|
|
75
|
+
owner: this.client.owner,
|
|
76
|
+
repo: this.client.repo,
|
|
77
|
+
comment_id: commentId,
|
|
78
|
+
}), `get comment #${commentId}`);
|
|
79
|
+
return transformComment(data);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* List all comments on an issue
|
|
83
|
+
*/
|
|
84
|
+
async list(issueNumber) {
|
|
85
|
+
const results = await this.client.paginate((params) => this.client.rest.issues.listComments({
|
|
86
|
+
owner: this.client.owner,
|
|
87
|
+
repo: this.client.repo,
|
|
88
|
+
issue_number: issueNumber,
|
|
89
|
+
...params,
|
|
90
|
+
}), 10);
|
|
91
|
+
return results.map(transformComment);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* List comments on an issue since a specific date
|
|
95
|
+
*/
|
|
96
|
+
async listSince(issueNumber, since) {
|
|
97
|
+
const results = await this.client.paginate((params) => this.client.rest.issues.listComments({
|
|
98
|
+
owner: this.client.owner,
|
|
99
|
+
repo: this.client.repo,
|
|
100
|
+
issue_number: issueNumber,
|
|
101
|
+
since: since.toISOString(),
|
|
102
|
+
...params,
|
|
103
|
+
}), 10);
|
|
104
|
+
return results.map(transformComment);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Find comments by author
|
|
108
|
+
*/
|
|
109
|
+
async findByAuthor(issueNumber, authorLogin) {
|
|
110
|
+
const allComments = await this.list(issueNumber);
|
|
111
|
+
return allComments.filter((comment) => comment.author.login === authorLogin);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Find comments matching a pattern
|
|
115
|
+
*/
|
|
116
|
+
async findByPattern(issueNumber, pattern) {
|
|
117
|
+
const allComments = await this.list(issueNumber);
|
|
118
|
+
return allComments.filter((comment) => pattern.test(comment.body));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create comment operations instance
|
|
123
|
+
*/
|
|
124
|
+
export function createCommentOperations(client) {
|
|
125
|
+
return new CommentOperations(client);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/operations/comments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;GAEG;AACH,SAAS,gBAAgB,CAAC,UAOzB;IACC,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,IAAI,EAAE,UAAU,CAAC,IAAI,IAA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MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB,EAAE,OAAe;QACtD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAoB;IAC1D,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GitHubClient } from '../client.js';
|
|
2
|
+
import type { Issue, CreateIssueParams, UpdateIssueParams, IssueFilter } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Issue operations using the GitHub client
|
|
5
|
+
*/
|
|
6
|
+
export declare class IssueOperations {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: GitHubClient);
|
|
9
|
+
/**
|
|
10
|
+
* Create a new issue
|
|
11
|
+
*/
|
|
12
|
+
create(params: CreateIssueParams): Promise<Issue>;
|
|
13
|
+
/**
|
|
14
|
+
* Get an issue by number
|
|
15
|
+
*/
|
|
16
|
+
get(issueNumber: number): Promise<Issue>;
|
|
17
|
+
/**
|
|
18
|
+
* Update an issue
|
|
19
|
+
*/
|
|
20
|
+
update(issueNumber: number, params: UpdateIssueParams): Promise<Issue>;
|
|
21
|
+
/**
|
|
22
|
+
* Close an issue
|
|
23
|
+
*/
|
|
24
|
+
close(issueNumber: number): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Reopen an issue
|
|
27
|
+
*/
|
|
28
|
+
reopen(issueNumber: number): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Search issues using GitHub search syntax
|
|
31
|
+
*/
|
|
32
|
+
search(query: string): Promise<Issue[]>;
|
|
33
|
+
/**
|
|
34
|
+
* List issues with optional filtering
|
|
35
|
+
*/
|
|
36
|
+
list(filter?: IssueFilter): Promise<Issue[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if an issue exists
|
|
39
|
+
*/
|
|
40
|
+
exists(issueNumber: number): Promise<boolean>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create issue operations instance
|
|
44
|
+
*/
|
|
45
|
+
export declare function createIssueOperations(client: GitHubClient): IssueOperations;
|
|
46
|
+
//# sourceMappingURL=issues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/operations/issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAgF3B;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAEjD;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;IAoBvD;;OAEG;IACG,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAc9C;;OAEG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;IAsB5E;;OAEG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/C;;OAEG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAahD;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAkB7C;;OAEG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IA+BlD;;OAEG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAWpD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAE3E"}
|