@slates-integrations/github 0.2.0-rc.2 → 0.2.0-rc.4
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/package.json +2 -2
- package/src/auth.ts +233 -143
- package/src/lib/client.ts +20 -3
- package/src/tools/comment-on-issue.ts +1 -1
- package/src/tools/create-commit-status.ts +1 -1
- package/src/tools/create-release.ts +1 -1
- package/src/tools/create-repository.ts +1 -1
- package/src/tools/get-issue.ts +1 -1
- package/src/tools/get-repository.ts +1 -1
- package/src/tools/get-user.ts +1 -1
- package/src/tools/list-branches.ts +1 -1
- package/src/tools/list-commits.ts +1 -1
- package/src/tools/list-issues.ts +1 -1
- package/src/tools/list-pull-requests.ts +1 -1
- package/src/tools/list-repositories.ts +1 -1
- package/src/tools/manage-collaborators.ts +1 -1
- package/src/tools/manage-file-content.ts +1 -1
- package/src/tools/manage-gist.ts +1 -1
- package/src/tools/manage-issue.ts +1 -1
- package/src/tools/manage-labels.ts +1 -1
- package/src/tools/manage-pull-request.ts +1 -1
- package/src/tools/manage-workflow.ts +1 -1
- package/src/tools/merge-pull-request.ts +1 -1
- package/src/tools/review-pull-request.ts +1 -1
- package/src/tools/search.ts +1 -1
- package/src/tools/star-repository.ts +3 -3
- package/src/tools/update-repository.ts +1 -1
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -1,127 +1,156 @@
|
|
|
1
1
|
import { SlateAuth, createAxios } from 'slates';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})
|
|
10
|
-
)
|
|
11
|
-
.addOauth({
|
|
12
|
-
type: 'auth.oauth',
|
|
13
|
-
name: 'OAuth',
|
|
14
|
-
key: 'oauth',
|
|
4
|
+
let outputSchema = z.object({
|
|
5
|
+
token: z.string(),
|
|
6
|
+
refreshToken: z.string().optional(),
|
|
7
|
+
instanceUrl: z.string()
|
|
8
|
+
});
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
10
|
+
type AuthOutput = z.infer<typeof outputSchema>;
|
|
11
|
+
|
|
12
|
+
let scopes = [
|
|
13
|
+
{
|
|
14
|
+
title: 'Repository',
|
|
15
|
+
description: 'Full access to public and private repositories',
|
|
16
|
+
scope: 'repo'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: 'Repository Status',
|
|
20
|
+
description: 'Read/write access to commit statuses',
|
|
21
|
+
scope: 'repo:status'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: 'Public Repository',
|
|
25
|
+
description: 'Access to public repositories only',
|
|
26
|
+
scope: 'public_repo'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: 'Admin: Organization',
|
|
30
|
+
description: 'Full management of organizations and teams',
|
|
31
|
+
scope: 'admin:org'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: 'Write Organization',
|
|
35
|
+
description: 'Write access to organization membership',
|
|
36
|
+
scope: 'write:org'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: 'Read Organization',
|
|
40
|
+
description: 'Read access to organization membership',
|
|
41
|
+
scope: 'read:org'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'Admin: Repo Hook',
|
|
45
|
+
description: 'Full access to repository webhooks',
|
|
46
|
+
scope: 'admin:repo_hook'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: 'Admin: Org Hook',
|
|
50
|
+
description: 'Full access to organization webhooks',
|
|
51
|
+
scope: 'admin:org_hook'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: 'User',
|
|
55
|
+
description: 'Read/write access to user profile, email, and follow',
|
|
56
|
+
scope: 'user'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
title: 'User Email',
|
|
60
|
+
description: 'Read access to email addresses',
|
|
61
|
+
scope: 'user:email'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: 'Gist',
|
|
65
|
+
description: 'Write access to gists',
|
|
66
|
+
scope: 'gist'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: 'Notifications',
|
|
70
|
+
description: 'Access to notifications',
|
|
71
|
+
scope: 'notifications'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'Workflow',
|
|
75
|
+
description: 'Manage GitHub Actions workflow files',
|
|
76
|
+
scope: 'workflow'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: 'Write Packages',
|
|
80
|
+
description: 'Upload packages to GitHub Packages',
|
|
81
|
+
scope: 'write:packages'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: 'Read Packages',
|
|
85
|
+
description: 'Download packages from GitHub Packages',
|
|
86
|
+
scope: 'read:packages'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
title: 'Delete Packages',
|
|
90
|
+
description: 'Delete packages from GitHub Packages',
|
|
91
|
+
scope: 'delete:packages'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: 'Project',
|
|
95
|
+
description: 'Full access to user and organization projects',
|
|
96
|
+
scope: 'project'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: 'Read Project',
|
|
100
|
+
description: 'Read-only access to user and organization projects',
|
|
101
|
+
scope: 'read:project'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
title: 'Delete Repository',
|
|
105
|
+
description: 'Delete repositories',
|
|
106
|
+
scope: 'delete_repo'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
title: 'Security Events',
|
|
110
|
+
description: 'Access to code scanning API',
|
|
111
|
+
scope: 'security_events'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
title: 'Read Audit Log',
|
|
115
|
+
description: 'Read audit log data',
|
|
116
|
+
scope: 'read:audit_log'
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
function normalizeBaseUrl(url: string) {
|
|
121
|
+
return url.replace(/\/+$/, '');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function getApiBaseUrl(instanceUrl: string) {
|
|
125
|
+
let baseUrl = normalizeBaseUrl(instanceUrl);
|
|
126
|
+
return baseUrl === 'https://github.com' ? 'https://api.github.com' : `${baseUrl}/api/v3`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function createGithubOauth(opts: {
|
|
130
|
+
name: string;
|
|
131
|
+
key: string;
|
|
132
|
+
hardcodedInstanceUrl: string | null;
|
|
133
|
+
}) {
|
|
134
|
+
let inputSchema = opts.hardcodedInstanceUrl
|
|
135
|
+
? z.object({})
|
|
136
|
+
: z.object({
|
|
137
|
+
instanceUrl: z
|
|
138
|
+
.string()
|
|
139
|
+
.describe('Your GitHub Enterprise URL (e.g. https://github.example.com).')
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
type: 'auth.oauth' as const,
|
|
144
|
+
name: opts.name,
|
|
145
|
+
key: opts.key,
|
|
146
|
+
scopes,
|
|
147
|
+
inputSchema,
|
|
148
|
+
|
|
149
|
+
getAuthorizationUrl: async (ctx: any) => {
|
|
150
|
+
let baseUrl = opts.hardcodedInstanceUrl
|
|
151
|
+
? opts.hardcodedInstanceUrl
|
|
152
|
+
: normalizeBaseUrl(ctx.input.instanceUrl);
|
|
123
153
|
|
|
124
|
-
getAuthorizationUrl: async ctx => {
|
|
125
154
|
let params = new URLSearchParams({
|
|
126
155
|
client_id: ctx.clientId,
|
|
127
156
|
redirect_uri: ctx.redirectUri,
|
|
@@ -130,15 +159,19 @@ export let auth = SlateAuth.create()
|
|
|
130
159
|
});
|
|
131
160
|
|
|
132
161
|
return {
|
|
133
|
-
url:
|
|
162
|
+
url: `${baseUrl}/login/oauth/authorize?${params.toString()}`,
|
|
163
|
+
input: opts.hardcodedInstanceUrl ? {} : { instanceUrl: ctx.input.instanceUrl }
|
|
134
164
|
};
|
|
135
165
|
},
|
|
136
166
|
|
|
137
|
-
handleCallback: async ctx => {
|
|
138
|
-
let
|
|
167
|
+
handleCallback: async (ctx: any) => {
|
|
168
|
+
let baseUrl = opts.hardcodedInstanceUrl
|
|
169
|
+
? opts.hardcodedInstanceUrl
|
|
170
|
+
: normalizeBaseUrl(ctx.input.instanceUrl);
|
|
139
171
|
|
|
172
|
+
let http = createAxios({ baseURL: baseUrl });
|
|
140
173
|
let response = await http.post(
|
|
141
|
-
'
|
|
174
|
+
'/login/oauth/access_token',
|
|
142
175
|
{
|
|
143
176
|
client_id: ctx.clientId,
|
|
144
177
|
client_secret: ctx.clientSecret,
|
|
@@ -157,20 +190,24 @@ export let auth = SlateAuth.create()
|
|
|
157
190
|
return {
|
|
158
191
|
output: {
|
|
159
192
|
token: data.access_token,
|
|
160
|
-
refreshToken: data.refresh_token
|
|
193
|
+
refreshToken: data.refresh_token,
|
|
194
|
+
instanceUrl: baseUrl
|
|
161
195
|
}
|
|
162
196
|
};
|
|
163
197
|
},
|
|
164
198
|
|
|
165
|
-
handleTokenRefresh: async ctx => {
|
|
199
|
+
handleTokenRefresh: async (ctx: any) => {
|
|
166
200
|
if (!ctx.output.refreshToken) {
|
|
167
201
|
return { output: ctx.output };
|
|
168
202
|
}
|
|
169
203
|
|
|
170
|
-
let
|
|
204
|
+
let baseUrl = ctx.output.instanceUrl
|
|
205
|
+
? normalizeBaseUrl(ctx.output.instanceUrl)
|
|
206
|
+
: opts.hardcodedInstanceUrl || 'https://github.com';
|
|
171
207
|
|
|
208
|
+
let http = createAxios({ baseURL: baseUrl });
|
|
172
209
|
let response = await http.post(
|
|
173
|
-
'
|
|
210
|
+
'/login/oauth/access_token',
|
|
174
211
|
{
|
|
175
212
|
client_id: ctx.clientId,
|
|
176
213
|
client_secret: ctx.clientSecret,
|
|
@@ -189,14 +226,15 @@ export let auth = SlateAuth.create()
|
|
|
189
226
|
return {
|
|
190
227
|
output: {
|
|
191
228
|
token: data.access_token,
|
|
192
|
-
refreshToken: data.refresh_token ?? ctx.output.refreshToken
|
|
229
|
+
refreshToken: data.refresh_token ?? ctx.output.refreshToken,
|
|
230
|
+
instanceUrl: baseUrl
|
|
193
231
|
}
|
|
194
232
|
};
|
|
195
233
|
},
|
|
196
234
|
|
|
197
|
-
getProfile: async (ctx:
|
|
235
|
+
getProfile: async (ctx: { output: AuthOutput }) => {
|
|
198
236
|
let http = createAxios({
|
|
199
|
-
baseURL:
|
|
237
|
+
baseURL: getApiBaseUrl(ctx.output.instanceUrl),
|
|
200
238
|
headers: {
|
|
201
239
|
Authorization: `Bearer ${ctx.output.token}`,
|
|
202
240
|
Accept: 'application/vnd.github+json'
|
|
@@ -215,27 +253,47 @@ export let auth = SlateAuth.create()
|
|
|
215
253
|
}
|
|
216
254
|
};
|
|
217
255
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
type: 'auth.token',
|
|
221
|
-
name: 'Personal Access Token',
|
|
222
|
-
key: 'personal_access_token',
|
|
256
|
+
} as any;
|
|
257
|
+
}
|
|
223
258
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
259
|
+
function createGithubPat(opts: {
|
|
260
|
+
name: string;
|
|
261
|
+
key: string;
|
|
262
|
+
hardcodedInstanceUrl: string | null;
|
|
263
|
+
}) {
|
|
264
|
+
let inputSchema = opts.hardcodedInstanceUrl
|
|
265
|
+
? z.object({
|
|
266
|
+
token: z.string().describe('GitHub Personal Access Token (classic or fine-grained)')
|
|
267
|
+
})
|
|
268
|
+
: z.object({
|
|
269
|
+
token: z.string().describe('GitHub Personal Access Token (classic or fine-grained)'),
|
|
270
|
+
instanceUrl: z
|
|
271
|
+
.string()
|
|
272
|
+
.describe('Your GitHub Enterprise URL (e.g. https://github.example.com).')
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
type: 'auth.token' as const,
|
|
277
|
+
name: opts.name,
|
|
278
|
+
key: opts.key,
|
|
279
|
+
inputSchema,
|
|
280
|
+
|
|
281
|
+
getOutput: async (ctx: any) => {
|
|
282
|
+
let instanceUrl = opts.hardcodedInstanceUrl
|
|
283
|
+
? opts.hardcodedInstanceUrl
|
|
284
|
+
: normalizeBaseUrl(ctx.input.instanceUrl);
|
|
227
285
|
|
|
228
|
-
getOutput: async ctx => {
|
|
229
286
|
return {
|
|
230
287
|
output: {
|
|
231
|
-
token: ctx.input.token
|
|
288
|
+
token: ctx.input.token,
|
|
289
|
+
instanceUrl
|
|
232
290
|
}
|
|
233
291
|
};
|
|
234
292
|
},
|
|
235
293
|
|
|
236
|
-
getProfile: async (ctx:
|
|
294
|
+
getProfile: async (ctx: { output: AuthOutput }) => {
|
|
237
295
|
let http = createAxios({
|
|
238
|
-
baseURL:
|
|
296
|
+
baseURL: getApiBaseUrl(ctx.output.instanceUrl),
|
|
239
297
|
headers: {
|
|
240
298
|
Authorization: `Bearer ${ctx.output.token}`,
|
|
241
299
|
Accept: 'application/vnd.github+json'
|
|
@@ -254,4 +312,36 @@ export let auth = SlateAuth.create()
|
|
|
254
312
|
}
|
|
255
313
|
};
|
|
256
314
|
}
|
|
257
|
-
}
|
|
315
|
+
} as any;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export let auth = SlateAuth.create()
|
|
319
|
+
.output(outputSchema)
|
|
320
|
+
.addOauth(
|
|
321
|
+
createGithubOauth({
|
|
322
|
+
name: 'GitHub.com',
|
|
323
|
+
key: 'oauth',
|
|
324
|
+
hardcodedInstanceUrl: 'https://github.com'
|
|
325
|
+
})
|
|
326
|
+
)
|
|
327
|
+
.addOauth(
|
|
328
|
+
createGithubOauth({
|
|
329
|
+
name: 'Enterprise',
|
|
330
|
+
key: 'oauth_enterprise',
|
|
331
|
+
hardcodedInstanceUrl: null
|
|
332
|
+
})
|
|
333
|
+
)
|
|
334
|
+
.addTokenAuth(
|
|
335
|
+
createGithubPat({
|
|
336
|
+
name: 'Personal Access Token (GitHub.com)',
|
|
337
|
+
key: 'personal_access_token',
|
|
338
|
+
hardcodedInstanceUrl: 'https://github.com'
|
|
339
|
+
})
|
|
340
|
+
)
|
|
341
|
+
.addTokenAuth(
|
|
342
|
+
createGithubPat({
|
|
343
|
+
name: 'Personal Access Token (Enterprise)',
|
|
344
|
+
key: 'pat_enterprise',
|
|
345
|
+
hardcodedInstanceUrl: null
|
|
346
|
+
})
|
|
347
|
+
);
|
package/src/lib/client.ts
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
import { createAxios } from 'slates';
|
|
2
2
|
|
|
3
|
+
export interface GitHubClientConfig {
|
|
4
|
+
token: string;
|
|
5
|
+
instanceUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
export class GitHubClient {
|
|
4
9
|
private http: ReturnType<typeof createAxios>;
|
|
10
|
+
private instanceUrl: string;
|
|
11
|
+
private apiBaseUrl: string;
|
|
12
|
+
|
|
13
|
+
constructor(private config: GitHubClientConfig) {
|
|
14
|
+
this.instanceUrl = config.instanceUrl?.replace(/\/+$/, '') || 'https://github.com';
|
|
15
|
+
this.apiBaseUrl =
|
|
16
|
+
this.instanceUrl === 'https://github.com'
|
|
17
|
+
? 'https://api.github.com'
|
|
18
|
+
: `${this.instanceUrl}/api/v3`;
|
|
5
19
|
|
|
6
|
-
constructor(token: string) {
|
|
7
20
|
this.http = createAxios({
|
|
8
|
-
baseURL:
|
|
21
|
+
baseURL: this.apiBaseUrl,
|
|
9
22
|
headers: {
|
|
10
|
-
Authorization: `Bearer ${token}`,
|
|
23
|
+
Authorization: `Bearer ${config.token}`,
|
|
11
24
|
Accept: 'application/vnd.github+json',
|
|
12
25
|
'X-GitHub-Api-Version': '2022-11-28'
|
|
13
26
|
}
|
|
14
27
|
});
|
|
15
28
|
}
|
|
16
29
|
|
|
30
|
+
getRepositoryHtmlUrl(owner: string, repo: string) {
|
|
31
|
+
return `${this.instanceUrl}/${owner}/${repo}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
// ─── Repositories ──────────────────────────────────────────────
|
|
18
35
|
|
|
19
36
|
async listRepositories(
|
|
@@ -25,7 +25,7 @@ export let commentOnIssue = SlateTool.create(spec, {
|
|
|
25
25
|
})
|
|
26
26
|
)
|
|
27
27
|
.handleInvocation(async ctx => {
|
|
28
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
28
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
29
29
|
let comment = await client.createIssueComment(
|
|
30
30
|
ctx.input.owner,
|
|
31
31
|
ctx.input.repo,
|
|
@@ -55,7 +55,7 @@ Also supports reading the combined status of all checks for a given ref.`,
|
|
|
55
55
|
})
|
|
56
56
|
)
|
|
57
57
|
.handleInvocation(async ctx => {
|
|
58
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
58
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
59
59
|
let { owner, repo, action, ref } = ctx.input;
|
|
60
60
|
|
|
61
61
|
if (action === 'get') {
|
|
@@ -41,7 +41,7 @@ Can automatically generate release notes from commits since the last release.`
|
|
|
41
41
|
})
|
|
42
42
|
)
|
|
43
43
|
.handleInvocation(async ctx => {
|
|
44
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
44
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
45
45
|
let release = await client.createRelease(ctx.input.owner, ctx.input.repo, {
|
|
46
46
|
tagName: ctx.input.tagName,
|
|
47
47
|
targetCommitish: ctx.input.targetCommitish,
|
|
@@ -50,7 +50,7 @@ Supports initializing with a README, gitignore template, and license.`,
|
|
|
50
50
|
})
|
|
51
51
|
)
|
|
52
52
|
.handleInvocation(async ctx => {
|
|
53
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
53
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
54
54
|
let repo = await client.createRepository(ctx.input);
|
|
55
55
|
|
|
56
56
|
return {
|
package/src/tools/get-issue.ts
CHANGED
|
@@ -39,7 +39,7 @@ export let getIssue = SlateTool.create(spec, {
|
|
|
39
39
|
})
|
|
40
40
|
)
|
|
41
41
|
.handleInvocation(async ctx => {
|
|
42
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
42
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
43
43
|
let issue = await client.getIssue(ctx.input.owner, ctx.input.repo, ctx.input.issueNumber);
|
|
44
44
|
|
|
45
45
|
return {
|
|
@@ -43,7 +43,7 @@ Use this to inspect a repository's configuration, check its visibility, default
|
|
|
43
43
|
})
|
|
44
44
|
)
|
|
45
45
|
.handleInvocation(async ctx => {
|
|
46
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
46
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
47
47
|
let repo = await client.getRepository(ctx.input.owner, ctx.input.repo);
|
|
48
48
|
|
|
49
49
|
return {
|
package/src/tools/get-user.ts
CHANGED
|
@@ -37,7 +37,7 @@ export let getUser = SlateTool.create(spec, {
|
|
|
37
37
|
})
|
|
38
38
|
)
|
|
39
39
|
.handleInvocation(async ctx => {
|
|
40
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
40
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
41
41
|
let user = ctx.input.username
|
|
42
42
|
? await client.getUser(ctx.input.username)
|
|
43
43
|
: await client.getAuthenticatedUser();
|
|
@@ -33,7 +33,7 @@ export let listBranches = SlateTool.create(spec, {
|
|
|
33
33
|
})
|
|
34
34
|
)
|
|
35
35
|
.handleInvocation(async ctx => {
|
|
36
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
36
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
37
37
|
let branches = await client.listBranches(ctx.input.owner, ctx.input.repo, {
|
|
38
38
|
perPage: ctx.input.perPage,
|
|
39
39
|
page: ctx.input.page,
|
|
@@ -41,7 +41,7 @@ export let listCommits = SlateTool.create(spec, {
|
|
|
41
41
|
})
|
|
42
42
|
)
|
|
43
43
|
.handleInvocation(async ctx => {
|
|
44
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
44
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
45
45
|
let commits = await client.listCommits(ctx.input.owner, ctx.input.repo, {
|
|
46
46
|
sha: ctx.input.sha,
|
|
47
47
|
path: ctx.input.path,
|
package/src/tools/list-issues.ts
CHANGED
|
@@ -55,7 +55,7 @@ Filter by state, labels, assignee, milestone, and since date. Note: GitHub's API
|
|
|
55
55
|
})
|
|
56
56
|
)
|
|
57
57
|
.handleInvocation(async ctx => {
|
|
58
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
58
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
59
59
|
let items = await client.listIssues(ctx.input.owner, ctx.input.repo, {
|
|
60
60
|
state: ctx.input.state,
|
|
61
61
|
labels: ctx.input.labels,
|
|
@@ -50,7 +50,7 @@ export let listPullRequests = SlateTool.create(spec, {
|
|
|
50
50
|
})
|
|
51
51
|
)
|
|
52
52
|
.handleInvocation(async ctx => {
|
|
53
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
53
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
54
54
|
let prs = await client.listPullRequests(ctx.input.owner, ctx.input.repo, {
|
|
55
55
|
state: ctx.input.state,
|
|
56
56
|
head: ctx.input.head,
|
|
@@ -55,7 +55,7 @@ Supports filtering by type, sorting, and pagination.`,
|
|
|
55
55
|
})
|
|
56
56
|
)
|
|
57
57
|
.handleInvocation(async ctx => {
|
|
58
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
58
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
59
59
|
|
|
60
60
|
let repos: any[];
|
|
61
61
|
if (ctx.input.org) {
|
|
@@ -45,7 +45,7 @@ export let manageCollaborators = SlateTool.create(spec, {
|
|
|
45
45
|
})
|
|
46
46
|
)
|
|
47
47
|
.handleInvocation(async ctx => {
|
|
48
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
48
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
49
49
|
let { owner, repo, action, username } = ctx.input;
|
|
50
50
|
|
|
51
51
|
if (action === 'list') {
|
|
@@ -46,7 +46,7 @@ export let manageFileContent = SlateTool.create(spec, {
|
|
|
46
46
|
})
|
|
47
47
|
)
|
|
48
48
|
.handleInvocation(async ctx => {
|
|
49
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
49
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
50
50
|
let { owner, repo, path, action } = ctx.input;
|
|
51
51
|
|
|
52
52
|
if (action === 'read') {
|
package/src/tools/manage-gist.ts
CHANGED
|
@@ -74,7 +74,7 @@ export let manageGist = SlateTool.create(spec, {
|
|
|
74
74
|
})
|
|
75
75
|
)
|
|
76
76
|
.handleInvocation(async ctx => {
|
|
77
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
77
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
78
78
|
let { action, gistId } = ctx.input;
|
|
79
79
|
|
|
80
80
|
if (action === 'list') {
|
|
@@ -54,7 +54,7 @@ When updating: provide the issue number along with fields to change (title, body
|
|
|
54
54
|
})
|
|
55
55
|
)
|
|
56
56
|
.handleInvocation(async ctx => {
|
|
57
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
57
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
58
58
|
let { owner, repo, issueNumber, ...data } = ctx.input;
|
|
59
59
|
let issue: any;
|
|
60
60
|
|
|
@@ -48,7 +48,7 @@ export let manageLabels = SlateTool.create(spec, {
|
|
|
48
48
|
})
|
|
49
49
|
)
|
|
50
50
|
.handleInvocation(async ctx => {
|
|
51
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
51
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
52
52
|
let { owner, repo, action } = ctx.input;
|
|
53
53
|
|
|
54
54
|
if (action === 'list') {
|
|
@@ -61,7 +61,7 @@ When updating: provide the pull request number along with fields to change.`,
|
|
|
61
61
|
})
|
|
62
62
|
)
|
|
63
63
|
.handleInvocation(async ctx => {
|
|
64
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
64
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
65
65
|
let { owner, repo, pullNumber, ...data } = ctx.input;
|
|
66
66
|
let pr: any;
|
|
67
67
|
|
|
@@ -119,7 +119,7 @@ export let manageWorkflow = SlateTool.create(spec, {
|
|
|
119
119
|
})
|
|
120
120
|
)
|
|
121
121
|
.handleInvocation(async ctx => {
|
|
122
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
122
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
123
123
|
let { owner, repo, action } = ctx.input;
|
|
124
124
|
|
|
125
125
|
if (action === 'list_workflows') {
|
|
@@ -36,7 +36,7 @@ export let mergePullRequest = SlateTool.create(spec, {
|
|
|
36
36
|
})
|
|
37
37
|
)
|
|
38
38
|
.handleInvocation(async ctx => {
|
|
39
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
39
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
40
40
|
let result = await client.mergePullRequest(
|
|
41
41
|
ctx.input.owner,
|
|
42
42
|
ctx.input.repo,
|
|
@@ -54,7 +54,7 @@ Optionally include inline comments on specific files and lines. Can also request
|
|
|
54
54
|
})
|
|
55
55
|
)
|
|
56
56
|
.handleInvocation(async ctx => {
|
|
57
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
57
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
58
58
|
let { owner, repo, pullNumber, action } = ctx.input;
|
|
59
59
|
|
|
60
60
|
if (action === 'request_reviewers') {
|
package/src/tools/search.ts
CHANGED
|
@@ -41,7 +41,7 @@ Supports qualifiers for filtering (e.g., "language:python stars:>100" for reposi
|
|
|
41
41
|
})
|
|
42
42
|
)
|
|
43
43
|
.handleInvocation(async ctx => {
|
|
44
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
44
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
45
45
|
let { type, query, ...params } = ctx.input;
|
|
46
46
|
let result: any;
|
|
47
47
|
|
|
@@ -25,7 +25,7 @@ export let starRepository = SlateTool.create(spec, {
|
|
|
25
25
|
})
|
|
26
26
|
)
|
|
27
27
|
.handleInvocation(async ctx => {
|
|
28
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
28
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
29
29
|
let { owner, repo, action } = ctx.input;
|
|
30
30
|
|
|
31
31
|
if (action === 'star') {
|
|
@@ -35,7 +35,7 @@ export let starRepository = SlateTool.create(spec, {
|
|
|
35
35
|
owner,
|
|
36
36
|
repo,
|
|
37
37
|
fullName: `${owner}/${repo}`,
|
|
38
|
-
htmlUrl:
|
|
38
|
+
htmlUrl: client.getRepositoryHtmlUrl(owner, repo),
|
|
39
39
|
starred: true
|
|
40
40
|
},
|
|
41
41
|
message: `Starred **${owner}/${repo}**.`
|
|
@@ -48,7 +48,7 @@ export let starRepository = SlateTool.create(spec, {
|
|
|
48
48
|
owner,
|
|
49
49
|
repo,
|
|
50
50
|
fullName: `${owner}/${repo}`,
|
|
51
|
-
htmlUrl:
|
|
51
|
+
htmlUrl: client.getRepositoryHtmlUrl(owner, repo),
|
|
52
52
|
starred: false
|
|
53
53
|
},
|
|
54
54
|
message: `Removed star from **${owner}/${repo}**.`
|
|
@@ -36,7 +36,7 @@ Modify name, description, visibility, feature toggles (issues, wiki, projects),
|
|
|
36
36
|
})
|
|
37
37
|
)
|
|
38
38
|
.handleInvocation(async ctx => {
|
|
39
|
-
let client = new GitHubClient(ctx.auth.token);
|
|
39
|
+
let client = new GitHubClient({ token: ctx.auth.token, instanceUrl: ctx.auth.instanceUrl });
|
|
40
40
|
let { owner, repo, ...updateData } = ctx.input;
|
|
41
41
|
let updated = await client.updateRepository(owner, repo, updateData);
|
|
42
42
|
|