digital-tools 2.0.2 → 2.1.1
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/CHANGELOG.md +17 -0
- package/package.json +3 -4
- package/src/define.js +267 -0
- package/src/entities/advertising.js +999 -0
- package/src/entities/ai.js +756 -0
- package/src/entities/analytics.js +1588 -0
- package/src/entities/automation.js +601 -0
- package/src/entities/communication.js +1150 -0
- package/src/entities/crm.js +1386 -0
- package/src/entities/design.js +546 -0
- package/src/entities/development.js +2212 -0
- package/src/entities/document.js +874 -0
- package/src/entities/ecommerce.js +1429 -0
- package/src/entities/experiment.js +1039 -0
- package/src/entities/finance.js +3478 -0
- package/src/entities/forms.js +1892 -0
- package/src/entities/hr.js +661 -0
- package/src/entities/identity.js +997 -0
- package/src/entities/index.js +282 -0
- package/src/entities/infrastructure.js +1153 -0
- package/src/entities/knowledge.js +1438 -0
- package/src/entities/marketing.js +1610 -0
- package/src/entities/media.js +1634 -0
- package/src/entities/notification.js +1199 -0
- package/src/entities/presentation.js +1274 -0
- package/src/entities/productivity.js +1317 -0
- package/src/entities/project-management.js +1136 -0
- package/src/entities/recruiting.js +736 -0
- package/src/entities/shipping.js +509 -0
- package/src/entities/signature.js +1102 -0
- package/src/entities/site.js +222 -0
- package/src/entities/spreadsheet.js +1341 -0
- package/src/entities/storage.js +1198 -0
- package/src/entities/support.js +1166 -0
- package/src/entities/video-conferencing.js +1750 -0
- package/src/entities/video.js +950 -0
- package/src/entities.js +1663 -0
- package/src/index.js +74 -0
- package/src/providers/analytics/index.js +17 -0
- package/src/providers/analytics/mixpanel.js +255 -0
- package/src/providers/calendar/cal-com.js +303 -0
- package/src/providers/calendar/google-calendar.js +335 -0
- package/src/providers/calendar/index.js +20 -0
- package/src/providers/crm/hubspot.js +566 -0
- package/src/providers/crm/index.js +17 -0
- package/src/providers/development/github.js +472 -0
- package/src/providers/development/index.js +17 -0
- package/src/providers/ecommerce/index.js +17 -0
- package/src/providers/ecommerce/shopify.js +378 -0
- package/src/providers/email/index.js +20 -0
- package/src/providers/email/resend.js +258 -0
- package/src/providers/email/sendgrid.js +161 -0
- package/src/providers/finance/index.js +17 -0
- package/src/providers/finance/stripe.js +549 -0
- package/src/providers/forms/index.js +17 -0
- package/src/providers/forms/typeform.js +500 -0
- package/src/providers/index.js +123 -0
- package/src/providers/knowledge/index.js +17 -0
- package/src/providers/knowledge/notion.js +389 -0
- package/src/providers/marketing/index.js +17 -0
- package/src/providers/marketing/mailchimp.js +443 -0
- package/src/providers/media/cloudinary.js +318 -0
- package/src/providers/media/index.js +17 -0
- package/src/providers/messaging/index.js +20 -0
- package/src/providers/messaging/slack.js +393 -0
- package/src/providers/messaging/twilio-sms.js +249 -0
- package/src/providers/project-management/index.js +17 -0
- package/src/providers/project-management/linear.js +575 -0
- package/src/providers/registry.js +86 -0
- package/src/providers/spreadsheet/google-sheets.js +375 -0
- package/src/providers/spreadsheet/index.js +20 -0
- package/src/providers/spreadsheet/xlsx.js +423 -0
- package/src/providers/storage/index.js +24 -0
- package/src/providers/storage/s3.js +419 -0
- package/src/providers/support/index.js +17 -0
- package/src/providers/support/zendesk.js +373 -0
- package/src/providers/tasks/index.js +17 -0
- package/src/providers/tasks/todoist.js +286 -0
- package/src/providers/types.js +9 -0
- package/src/providers/video-conferencing/google-meet.js +286 -0
- package/src/providers/video-conferencing/index.js +31 -0
- package/src/providers/video-conferencing/jitsi.js +254 -0
- package/src/providers/video-conferencing/teams.js +270 -0
- package/src/providers/video-conferencing/zoom.js +332 -0
- package/src/registry.js +128 -0
- package/src/tools/communication.js +184 -0
- package/src/tools/data.js +205 -0
- package/src/tools/index.js +11 -0
- package/src/tools/web.js +137 -0
- package/src/types.js +10 -0
- package/test/define.test.js +306 -0
- package/test/registry.test.js +357 -0
- package/test/tools.test.js +363 -0
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Development Provider
|
|
3
|
+
*
|
|
4
|
+
* Concrete implementation of DevelopmentProvider using GitHub REST API v3.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { defineProvider } from '../registry.js';
|
|
9
|
+
const GITHUB_API_URL = 'https://api.github.com';
|
|
10
|
+
/**
|
|
11
|
+
* GitHub provider info
|
|
12
|
+
*/
|
|
13
|
+
export const githubInfo = {
|
|
14
|
+
id: 'development.github',
|
|
15
|
+
name: 'GitHub',
|
|
16
|
+
description: 'GitHub development platform and version control service',
|
|
17
|
+
category: 'development',
|
|
18
|
+
website: 'https://github.com',
|
|
19
|
+
docsUrl: 'https://docs.github.com/rest',
|
|
20
|
+
requiredConfig: ['accessToken'],
|
|
21
|
+
optionalConfig: ['baseUrl'],
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Create GitHub development provider
|
|
25
|
+
*/
|
|
26
|
+
export function createGitHubProvider(config) {
|
|
27
|
+
let accessToken;
|
|
28
|
+
let baseUrl;
|
|
29
|
+
return {
|
|
30
|
+
info: githubInfo,
|
|
31
|
+
async initialize(cfg) {
|
|
32
|
+
accessToken = cfg.accessToken;
|
|
33
|
+
baseUrl = cfg.baseUrl || GITHUB_API_URL;
|
|
34
|
+
if (!accessToken) {
|
|
35
|
+
throw new Error('GitHub access token is required');
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async healthCheck() {
|
|
39
|
+
const start = Date.now();
|
|
40
|
+
try {
|
|
41
|
+
const response = await fetch(`${baseUrl}/user`, {
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: `Bearer ${accessToken}`,
|
|
44
|
+
Accept: 'application/vnd.github.v3+json',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
healthy: response.ok,
|
|
49
|
+
latencyMs: Date.now() - start,
|
|
50
|
+
message: response.ok ? 'Connected' : `HTTP ${response.status}`,
|
|
51
|
+
checkedAt: new Date(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return {
|
|
56
|
+
healthy: false,
|
|
57
|
+
latencyMs: Date.now() - start,
|
|
58
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
59
|
+
checkedAt: new Date(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
async dispose() {
|
|
64
|
+
// No cleanup needed
|
|
65
|
+
},
|
|
66
|
+
async listRepos(options) {
|
|
67
|
+
const params = new URLSearchParams();
|
|
68
|
+
if (options?.visibility) {
|
|
69
|
+
params.append('visibility', options.visibility);
|
|
70
|
+
}
|
|
71
|
+
if (options?.sort) {
|
|
72
|
+
params.append('sort', options.sort);
|
|
73
|
+
}
|
|
74
|
+
if (options?.limit) {
|
|
75
|
+
params.append('per_page', String(options.limit));
|
|
76
|
+
}
|
|
77
|
+
if (options?.cursor) {
|
|
78
|
+
params.append('page', options.cursor);
|
|
79
|
+
}
|
|
80
|
+
const response = await fetch(`${baseUrl}/user/repos?${params.toString()}`, {
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${accessToken}`,
|
|
83
|
+
Accept: 'application/vnd.github.v3+json',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
88
|
+
}
|
|
89
|
+
const data = await response.json();
|
|
90
|
+
const repos = data.map((repo) => ({
|
|
91
|
+
id: String(repo.id),
|
|
92
|
+
owner: repo.owner.login,
|
|
93
|
+
name: repo.name,
|
|
94
|
+
fullName: repo.full_name,
|
|
95
|
+
description: repo.description,
|
|
96
|
+
private: repo.private,
|
|
97
|
+
defaultBranch: repo.default_branch,
|
|
98
|
+
url: repo.html_url,
|
|
99
|
+
cloneUrl: repo.clone_url,
|
|
100
|
+
stars: repo.stargazers_count,
|
|
101
|
+
forks: repo.forks_count,
|
|
102
|
+
openIssues: repo.open_issues_count,
|
|
103
|
+
createdAt: new Date(repo.created_at),
|
|
104
|
+
updatedAt: new Date(repo.updated_at),
|
|
105
|
+
}));
|
|
106
|
+
const linkHeader = response.headers.get('Link');
|
|
107
|
+
const hasMore = linkHeader ? linkHeader.includes('rel="next"') : false;
|
|
108
|
+
const nextCursor = hasMore ? String(Number(options?.cursor || '1') + 1) : undefined;
|
|
109
|
+
return {
|
|
110
|
+
items: repos,
|
|
111
|
+
hasMore,
|
|
112
|
+
nextCursor,
|
|
113
|
+
total: undefined,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
async getRepo(owner, repo) {
|
|
117
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}`, {
|
|
118
|
+
headers: {
|
|
119
|
+
Authorization: `Bearer ${accessToken}`,
|
|
120
|
+
Accept: 'application/vnd.github.v3+json',
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
if (response.status === 404) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
128
|
+
}
|
|
129
|
+
const data = await response.json();
|
|
130
|
+
return {
|
|
131
|
+
id: String(data.id),
|
|
132
|
+
owner: data.owner.login,
|
|
133
|
+
name: data.name,
|
|
134
|
+
fullName: data.full_name,
|
|
135
|
+
description: data.description,
|
|
136
|
+
private: data.private,
|
|
137
|
+
defaultBranch: data.default_branch,
|
|
138
|
+
url: data.html_url,
|
|
139
|
+
cloneUrl: data.clone_url,
|
|
140
|
+
stars: data.stargazers_count,
|
|
141
|
+
forks: data.forks_count,
|
|
142
|
+
openIssues: data.open_issues_count,
|
|
143
|
+
createdAt: new Date(data.created_at),
|
|
144
|
+
updatedAt: new Date(data.updated_at),
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
async createIssue(owner, repo, issue) {
|
|
148
|
+
const body = {
|
|
149
|
+
title: issue.title,
|
|
150
|
+
body: issue.body,
|
|
151
|
+
labels: issue.labels,
|
|
152
|
+
assignees: issue.assignees,
|
|
153
|
+
milestone: issue.milestone,
|
|
154
|
+
};
|
|
155
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/issues`, {
|
|
156
|
+
method: 'POST',
|
|
157
|
+
headers: {
|
|
158
|
+
Authorization: `Bearer ${accessToken}`,
|
|
159
|
+
Accept: 'application/vnd.github.v3+json',
|
|
160
|
+
'Content-Type': 'application/json',
|
|
161
|
+
},
|
|
162
|
+
body: JSON.stringify(body),
|
|
163
|
+
});
|
|
164
|
+
if (!response.ok) {
|
|
165
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
166
|
+
}
|
|
167
|
+
const data = await response.json();
|
|
168
|
+
return {
|
|
169
|
+
id: String(data.id),
|
|
170
|
+
number: data.number,
|
|
171
|
+
title: data.title,
|
|
172
|
+
body: data.body,
|
|
173
|
+
state: data.state,
|
|
174
|
+
labels: data.labels.map((l) => l.name),
|
|
175
|
+
assignees: data.assignees.map((a) => a.login),
|
|
176
|
+
authorId: data.user.login,
|
|
177
|
+
url: data.html_url,
|
|
178
|
+
createdAt: new Date(data.created_at),
|
|
179
|
+
updatedAt: new Date(data.updated_at),
|
|
180
|
+
closedAt: data.closed_at ? new Date(data.closed_at) : undefined,
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
async getIssue(owner, repo, issueNumber) {
|
|
184
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/issues/${issueNumber}`, {
|
|
185
|
+
headers: {
|
|
186
|
+
Authorization: `Bearer ${accessToken}`,
|
|
187
|
+
Accept: 'application/vnd.github.v3+json',
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
if (response.status === 404) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
if (!response.ok) {
|
|
194
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
195
|
+
}
|
|
196
|
+
const data = await response.json();
|
|
197
|
+
return {
|
|
198
|
+
id: String(data.id),
|
|
199
|
+
number: data.number,
|
|
200
|
+
title: data.title,
|
|
201
|
+
body: data.body,
|
|
202
|
+
state: data.state,
|
|
203
|
+
labels: data.labels.map((l) => l.name),
|
|
204
|
+
assignees: data.assignees.map((a) => a.login),
|
|
205
|
+
authorId: data.user.login,
|
|
206
|
+
url: data.html_url,
|
|
207
|
+
createdAt: new Date(data.created_at),
|
|
208
|
+
updatedAt: new Date(data.updated_at),
|
|
209
|
+
closedAt: data.closed_at ? new Date(data.closed_at) : undefined,
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
async updateIssue(owner, repo, issueNumber, updates) {
|
|
213
|
+
const body = {};
|
|
214
|
+
if (updates.title !== undefined)
|
|
215
|
+
body.title = updates.title;
|
|
216
|
+
if (updates.body !== undefined)
|
|
217
|
+
body.body = updates.body;
|
|
218
|
+
if (updates.labels !== undefined)
|
|
219
|
+
body.labels = updates.labels;
|
|
220
|
+
if (updates.assignees !== undefined)
|
|
221
|
+
body.assignees = updates.assignees;
|
|
222
|
+
if (updates.milestone !== undefined)
|
|
223
|
+
body.milestone = updates.milestone;
|
|
224
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/issues/${issueNumber}`, {
|
|
225
|
+
method: 'PATCH',
|
|
226
|
+
headers: {
|
|
227
|
+
Authorization: `Bearer ${accessToken}`,
|
|
228
|
+
Accept: 'application/vnd.github.v3+json',
|
|
229
|
+
'Content-Type': 'application/json',
|
|
230
|
+
},
|
|
231
|
+
body: JSON.stringify(body),
|
|
232
|
+
});
|
|
233
|
+
if (!response.ok) {
|
|
234
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
235
|
+
}
|
|
236
|
+
const data = await response.json();
|
|
237
|
+
return {
|
|
238
|
+
id: String(data.id),
|
|
239
|
+
number: data.number,
|
|
240
|
+
title: data.title,
|
|
241
|
+
body: data.body,
|
|
242
|
+
state: data.state,
|
|
243
|
+
labels: data.labels.map((l) => l.name),
|
|
244
|
+
assignees: data.assignees.map((a) => a.login),
|
|
245
|
+
authorId: data.user.login,
|
|
246
|
+
url: data.html_url,
|
|
247
|
+
createdAt: new Date(data.created_at),
|
|
248
|
+
updatedAt: new Date(data.updated_at),
|
|
249
|
+
closedAt: data.closed_at ? new Date(data.closed_at) : undefined,
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
async listIssues(owner, repo, options) {
|
|
253
|
+
const params = new URLSearchParams();
|
|
254
|
+
if (options?.state) {
|
|
255
|
+
params.append('state', options.state);
|
|
256
|
+
}
|
|
257
|
+
if (options?.labels?.length) {
|
|
258
|
+
params.append('labels', options.labels.join(','));
|
|
259
|
+
}
|
|
260
|
+
if (options?.assignee) {
|
|
261
|
+
params.append('assignee', options.assignee);
|
|
262
|
+
}
|
|
263
|
+
if (options?.sort) {
|
|
264
|
+
params.append('sort', options.sort);
|
|
265
|
+
}
|
|
266
|
+
if (options?.limit) {
|
|
267
|
+
params.append('per_page', String(options.limit));
|
|
268
|
+
}
|
|
269
|
+
if (options?.cursor) {
|
|
270
|
+
params.append('page', options.cursor);
|
|
271
|
+
}
|
|
272
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/issues?${params.toString()}`, {
|
|
273
|
+
headers: {
|
|
274
|
+
Authorization: `Bearer ${accessToken}`,
|
|
275
|
+
Accept: 'application/vnd.github.v3+json',
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
if (!response.ok) {
|
|
279
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
280
|
+
}
|
|
281
|
+
const data = await response.json();
|
|
282
|
+
const issues = data
|
|
283
|
+
.filter((item) => !item.pull_request) // Filter out PRs
|
|
284
|
+
.map((issue) => ({
|
|
285
|
+
id: String(issue.id),
|
|
286
|
+
number: issue.number,
|
|
287
|
+
title: issue.title,
|
|
288
|
+
body: issue.body,
|
|
289
|
+
state: issue.state,
|
|
290
|
+
labels: issue.labels.map((l) => l.name),
|
|
291
|
+
assignees: issue.assignees.map((a) => a.login),
|
|
292
|
+
authorId: issue.user.login,
|
|
293
|
+
url: issue.html_url,
|
|
294
|
+
createdAt: new Date(issue.created_at),
|
|
295
|
+
updatedAt: new Date(issue.updated_at),
|
|
296
|
+
closedAt: issue.closed_at ? new Date(issue.closed_at) : undefined,
|
|
297
|
+
}));
|
|
298
|
+
const linkHeader = response.headers.get('Link');
|
|
299
|
+
const hasMore = linkHeader ? linkHeader.includes('rel="next"') : false;
|
|
300
|
+
const nextCursor = hasMore ? String(Number(options?.cursor || '1') + 1) : undefined;
|
|
301
|
+
return {
|
|
302
|
+
items: issues,
|
|
303
|
+
hasMore,
|
|
304
|
+
nextCursor,
|
|
305
|
+
total: undefined,
|
|
306
|
+
};
|
|
307
|
+
},
|
|
308
|
+
async createPullRequest(owner, repo, pr) {
|
|
309
|
+
const body = {
|
|
310
|
+
title: pr.title,
|
|
311
|
+
body: pr.body,
|
|
312
|
+
head: pr.head,
|
|
313
|
+
base: pr.base,
|
|
314
|
+
draft: pr.draft,
|
|
315
|
+
};
|
|
316
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/pulls`, {
|
|
317
|
+
method: 'POST',
|
|
318
|
+
headers: {
|
|
319
|
+
Authorization: `Bearer ${accessToken}`,
|
|
320
|
+
Accept: 'application/vnd.github.v3+json',
|
|
321
|
+
'Content-Type': 'application/json',
|
|
322
|
+
},
|
|
323
|
+
body: JSON.stringify(body),
|
|
324
|
+
});
|
|
325
|
+
if (!response.ok) {
|
|
326
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
327
|
+
}
|
|
328
|
+
const data = await response.json();
|
|
329
|
+
return {
|
|
330
|
+
id: String(data.id),
|
|
331
|
+
number: data.number,
|
|
332
|
+
title: data.title,
|
|
333
|
+
body: data.body,
|
|
334
|
+
state: data.merged_at ? 'merged' : data.state,
|
|
335
|
+
head: data.head.ref,
|
|
336
|
+
base: data.base.ref,
|
|
337
|
+
authorId: data.user.login,
|
|
338
|
+
draft: data.draft,
|
|
339
|
+
mergeable: data.mergeable,
|
|
340
|
+
url: data.html_url,
|
|
341
|
+
createdAt: new Date(data.created_at),
|
|
342
|
+
updatedAt: new Date(data.updated_at),
|
|
343
|
+
mergedAt: data.merged_at ? new Date(data.merged_at) : undefined,
|
|
344
|
+
closedAt: data.closed_at ? new Date(data.closed_at) : undefined,
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
async getPullRequest(owner, repo, prNumber) {
|
|
348
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/pulls/${prNumber}`, {
|
|
349
|
+
headers: {
|
|
350
|
+
Authorization: `Bearer ${accessToken}`,
|
|
351
|
+
Accept: 'application/vnd.github.v3+json',
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
if (response.status === 404) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
if (!response.ok) {
|
|
358
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
359
|
+
}
|
|
360
|
+
const data = await response.json();
|
|
361
|
+
return {
|
|
362
|
+
id: String(data.id),
|
|
363
|
+
number: data.number,
|
|
364
|
+
title: data.title,
|
|
365
|
+
body: data.body,
|
|
366
|
+
state: data.merged_at ? 'merged' : data.state,
|
|
367
|
+
head: data.head.ref,
|
|
368
|
+
base: data.base.ref,
|
|
369
|
+
authorId: data.user.login,
|
|
370
|
+
draft: data.draft,
|
|
371
|
+
mergeable: data.mergeable,
|
|
372
|
+
url: data.html_url,
|
|
373
|
+
createdAt: new Date(data.created_at),
|
|
374
|
+
updatedAt: new Date(data.updated_at),
|
|
375
|
+
mergedAt: data.merged_at ? new Date(data.merged_at) : undefined,
|
|
376
|
+
closedAt: data.closed_at ? new Date(data.closed_at) : undefined,
|
|
377
|
+
};
|
|
378
|
+
},
|
|
379
|
+
async listPullRequests(owner, repo, options) {
|
|
380
|
+
const params = new URLSearchParams();
|
|
381
|
+
if (options?.state) {
|
|
382
|
+
params.append('state', options.state);
|
|
383
|
+
}
|
|
384
|
+
if (options?.sort) {
|
|
385
|
+
params.append('sort', options.sort);
|
|
386
|
+
}
|
|
387
|
+
if (options?.direction) {
|
|
388
|
+
params.append('direction', options.direction);
|
|
389
|
+
}
|
|
390
|
+
if (options?.limit) {
|
|
391
|
+
params.append('per_page', String(options.limit));
|
|
392
|
+
}
|
|
393
|
+
if (options?.cursor) {
|
|
394
|
+
params.append('page', options.cursor);
|
|
395
|
+
}
|
|
396
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/pulls?${params.toString()}`, {
|
|
397
|
+
headers: {
|
|
398
|
+
Authorization: `Bearer ${accessToken}`,
|
|
399
|
+
Accept: 'application/vnd.github.v3+json',
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
if (!response.ok) {
|
|
403
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
404
|
+
}
|
|
405
|
+
const data = await response.json();
|
|
406
|
+
const prs = data.map((pr) => ({
|
|
407
|
+
id: String(pr.id),
|
|
408
|
+
number: pr.number,
|
|
409
|
+
title: pr.title,
|
|
410
|
+
body: pr.body,
|
|
411
|
+
state: pr.merged_at ? 'merged' : pr.state,
|
|
412
|
+
head: pr.head.ref,
|
|
413
|
+
base: pr.base.ref,
|
|
414
|
+
authorId: pr.user.login,
|
|
415
|
+
draft: pr.draft,
|
|
416
|
+
mergeable: pr.mergeable,
|
|
417
|
+
url: pr.html_url,
|
|
418
|
+
createdAt: new Date(pr.created_at),
|
|
419
|
+
updatedAt: new Date(pr.updated_at),
|
|
420
|
+
mergedAt: pr.merged_at ? new Date(pr.merged_at) : undefined,
|
|
421
|
+
closedAt: pr.closed_at ? new Date(pr.closed_at) : undefined,
|
|
422
|
+
}));
|
|
423
|
+
const linkHeader = response.headers.get('Link');
|
|
424
|
+
const hasMore = linkHeader ? linkHeader.includes('rel="next"') : false;
|
|
425
|
+
const nextCursor = hasMore ? String(Number(options?.cursor || '1') + 1) : undefined;
|
|
426
|
+
return {
|
|
427
|
+
items: prs,
|
|
428
|
+
hasMore,
|
|
429
|
+
nextCursor,
|
|
430
|
+
total: undefined,
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
async mergePullRequest(owner, repo, prNumber) {
|
|
434
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/pulls/${prNumber}/merge`, {
|
|
435
|
+
method: 'PUT',
|
|
436
|
+
headers: {
|
|
437
|
+
Authorization: `Bearer ${accessToken}`,
|
|
438
|
+
Accept: 'application/vnd.github.v3+json',
|
|
439
|
+
'Content-Type': 'application/json',
|
|
440
|
+
},
|
|
441
|
+
body: JSON.stringify({}),
|
|
442
|
+
});
|
|
443
|
+
return response.ok;
|
|
444
|
+
},
|
|
445
|
+
async addComment(owner, repo, issueNumber, body) {
|
|
446
|
+
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}/issues/${issueNumber}/comments`, {
|
|
447
|
+
method: 'POST',
|
|
448
|
+
headers: {
|
|
449
|
+
Authorization: `Bearer ${accessToken}`,
|
|
450
|
+
Accept: 'application/vnd.github.v3+json',
|
|
451
|
+
'Content-Type': 'application/json',
|
|
452
|
+
},
|
|
453
|
+
body: JSON.stringify({ body }),
|
|
454
|
+
});
|
|
455
|
+
if (!response.ok) {
|
|
456
|
+
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
|
457
|
+
}
|
|
458
|
+
const data = await response.json();
|
|
459
|
+
return {
|
|
460
|
+
id: String(data.id),
|
|
461
|
+
body: data.body,
|
|
462
|
+
authorId: data.user.login,
|
|
463
|
+
createdAt: new Date(data.created_at),
|
|
464
|
+
updatedAt: new Date(data.updated_at),
|
|
465
|
+
};
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* GitHub provider definition
|
|
471
|
+
*/
|
|
472
|
+
export const githubProvider = defineProvider(githubInfo, async (config) => createGitHubProvider(config));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development Providers
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { githubInfo, githubProvider, createGitHubProvider } from './github.js';
|
|
7
|
+
import { githubProvider } from './github.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register all development providers
|
|
10
|
+
*/
|
|
11
|
+
export function registerDevelopmentProviders() {
|
|
12
|
+
githubProvider.register();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* All development providers
|
|
16
|
+
*/
|
|
17
|
+
export const developmentProviders = [githubProvider];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E-commerce Providers
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { shopifyInfo, shopifyProvider, createShopifyProvider } from './shopify.js';
|
|
7
|
+
import { shopifyProvider } from './shopify.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register all e-commerce providers
|
|
10
|
+
*/
|
|
11
|
+
export function registerEcommerceProviders() {
|
|
12
|
+
shopifyProvider.register();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* All e-commerce providers
|
|
16
|
+
*/
|
|
17
|
+
export const ecommerceProviders = [shopifyProvider];
|