n8n-nodes-github-copilot 1.0.9 → 1.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.
|
@@ -64,14 +64,43 @@ class GitHubCopilot {
|
|
|
64
64
|
name: 'gitHubApi',
|
|
65
65
|
displayName: 'GitHub API (OAuth2)',
|
|
66
66
|
required: false,
|
|
67
|
+
displayOptions: {
|
|
68
|
+
show: {
|
|
69
|
+
authType: ['oauth2'],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
67
72
|
},
|
|
68
73
|
{
|
|
69
74
|
name: 'gitHubApiManual',
|
|
70
75
|
displayName: 'GitHub API (Manual Token)',
|
|
71
76
|
required: false,
|
|
77
|
+
displayOptions: {
|
|
78
|
+
show: {
|
|
79
|
+
authType: ['manual'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
72
82
|
},
|
|
73
83
|
],
|
|
74
84
|
properties: [
|
|
85
|
+
{
|
|
86
|
+
displayName: 'Authentication Type',
|
|
87
|
+
name: 'authType',
|
|
88
|
+
type: 'options',
|
|
89
|
+
options: [
|
|
90
|
+
{
|
|
91
|
+
name: 'OAuth2 (Automatic)',
|
|
92
|
+
value: 'oauth2',
|
|
93
|
+
description: 'Use OAuth2 authentication configured in n8n',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'Manual Token',
|
|
97
|
+
value: 'manual',
|
|
98
|
+
description: 'Use manually entered GitHub token',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
default: 'manual',
|
|
102
|
+
description: 'Choose how to authenticate with GitHub',
|
|
103
|
+
},
|
|
75
104
|
{
|
|
76
105
|
displayName: 'Operation',
|
|
77
106
|
name: 'operation',
|
|
@@ -179,6 +208,7 @@ class GitHubCopilot {
|
|
|
179
208
|
};
|
|
180
209
|
}
|
|
181
210
|
async execute() {
|
|
211
|
+
var _a;
|
|
182
212
|
const items = this.getInputData();
|
|
183
213
|
const returnData = [];
|
|
184
214
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -186,23 +216,33 @@ class GitHubCopilot {
|
|
|
186
216
|
const operation = this.getNodeParameter('operation', i);
|
|
187
217
|
const prompt = this.getNodeParameter('prompt', i);
|
|
188
218
|
const context = this.getNodeParameter('context', i, '');
|
|
189
|
-
|
|
219
|
+
const authType = this.getNodeParameter('authType', i);
|
|
190
220
|
let accessToken;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
221
|
+
let credentialType = '';
|
|
222
|
+
if (authType === 'oauth2') {
|
|
223
|
+
const oauthCredentials = await this.getCredentials('gitHubApi');
|
|
224
|
+
console.log('OAuth2 credentials object:', JSON.stringify(oauthCredentials, null, 2));
|
|
225
|
+
const creds = oauthCredentials;
|
|
226
|
+
accessToken = (creds === null || creds === void 0 ? void 0 : creds.accessToken) ||
|
|
227
|
+
(creds === null || creds === void 0 ? void 0 : creds.access_token) ||
|
|
228
|
+
(creds === null || creds === void 0 ? void 0 : creds.token) ||
|
|
229
|
+
((_a = creds === null || creds === void 0 ? void 0 : creds.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token);
|
|
230
|
+
if (accessToken && typeof accessToken === 'string') {
|
|
231
|
+
credentialType = 'OAuth2';
|
|
199
232
|
}
|
|
200
|
-
|
|
201
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
233
|
+
else {
|
|
234
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `OAuth2 token not found. Available fields: ${Object.keys(oauthCredentials || {}).join(', ')}. Please switch to Manual Token.`);
|
|
202
235
|
}
|
|
203
236
|
}
|
|
204
|
-
|
|
205
|
-
|
|
237
|
+
else {
|
|
238
|
+
const manualCredentials = await this.getCredentials('gitHubApiManual');
|
|
239
|
+
if ((manualCredentials === null || manualCredentials === void 0 ? void 0 : manualCredentials.accessToken) && typeof manualCredentials.accessToken === 'string') {
|
|
240
|
+
accessToken = manualCredentials.accessToken;
|
|
241
|
+
credentialType = 'Manual Token';
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Manual token credentials not found or invalid. Please configure Manual Token authentication or switch to OAuth2.');
|
|
245
|
+
}
|
|
206
246
|
}
|
|
207
247
|
let command;
|
|
208
248
|
let fullPrompt = prompt;
|
|
@@ -248,6 +288,8 @@ class GitHubCopilot {
|
|
|
248
288
|
env: {
|
|
249
289
|
...process.env,
|
|
250
290
|
GH_TOKEN: accessToken,
|
|
291
|
+
GITHUB_TOKEN: accessToken,
|
|
292
|
+
GH_PAT: accessToken,
|
|
251
293
|
HOME: '/opt/n8n-source/packages/cli/bin',
|
|
252
294
|
},
|
|
253
295
|
timeout: 30000,
|
|
@@ -266,6 +308,9 @@ class GitHubCopilot {
|
|
|
266
308
|
operation,
|
|
267
309
|
prompt: prompt,
|
|
268
310
|
context: context || undefined,
|
|
311
|
+
authType: authType,
|
|
312
|
+
credentialType: credentialType,
|
|
313
|
+
tokenPrefix: accessToken ? accessToken.substring(0, 4) + '...' : 'none',
|
|
269
314
|
language: operation === 'suggest' ? this.getNodeParameter('language', i) : undefined,
|
|
270
315
|
commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
|
|
271
316
|
output: processedOutput,
|
package/package.json
CHANGED