n8n-nodes-github-copilot 3.2.5 → 3.2.6
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.
|
@@ -2,39 +2,143 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.suggestImageConversion = exports.getFileExtensionFromMimeType = exports.validateImageFormat = exports.isAudioMimeType = exports.isImageMimeType = exports.processMediaFile = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
|
-
async function
|
|
5
|
+
async function detectMimeType(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty) {
|
|
6
|
+
var _a, _b;
|
|
6
7
|
try {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (source === 'binary') {
|
|
9
|
+
const binaryData = context.getInputData()[itemIndex].binary;
|
|
10
|
+
if (binaryData && binaryProperty && binaryData[binaryProperty]) {
|
|
11
|
+
return binaryData[binaryProperty].mimeType || 'application/octet-stream';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else if (source === 'url' && mediaUrl) {
|
|
15
|
+
const extension = (_a = mediaUrl.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
16
|
+
const extToMime = {
|
|
17
|
+
'png': 'image/png',
|
|
18
|
+
'jpg': 'image/jpeg',
|
|
19
|
+
'jpeg': 'image/jpeg',
|
|
20
|
+
'gif': 'image/gif',
|
|
21
|
+
'webp': 'image/webp',
|
|
22
|
+
'mp3': 'audio/mpeg',
|
|
23
|
+
'wav': 'audio/wav',
|
|
24
|
+
'm4a': 'audio/mp4',
|
|
25
|
+
'ogg': 'audio/ogg',
|
|
26
|
+
'mp4': 'video/mp4'
|
|
27
|
+
};
|
|
28
|
+
return extToMime[extension || ''] || 'application/octet-stream';
|
|
29
|
+
}
|
|
30
|
+
else if (source === 'manual' && mediaFile) {
|
|
31
|
+
if (mediaFile.startsWith('data:')) {
|
|
32
|
+
const mimeMatch = mediaFile.match(/data:([^;]+)/);
|
|
33
|
+
if (mimeMatch)
|
|
34
|
+
return mimeMatch[1];
|
|
12
35
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
const extension = (_b = mediaFile.split('.').pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
37
|
+
const extToMime = {
|
|
38
|
+
'png': 'image/png',
|
|
39
|
+
'jpg': 'image/jpeg',
|
|
40
|
+
'jpeg': 'image/jpeg',
|
|
41
|
+
'gif': 'image/gif',
|
|
42
|
+
'webp': 'image/webp',
|
|
43
|
+
'mp3': 'audio/mpeg',
|
|
44
|
+
'wav': 'audio/wav',
|
|
45
|
+
'm4a': 'audio/mp4',
|
|
46
|
+
'ogg': 'audio/ogg',
|
|
47
|
+
'mp4': 'video/mp4'
|
|
18
48
|
};
|
|
49
|
+
return extToMime[extension || ''] || 'application/octet-stream';
|
|
19
50
|
}
|
|
20
|
-
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
}
|
|
54
|
+
return 'application/octet-stream';
|
|
55
|
+
}
|
|
56
|
+
async function processMediaFile(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty) {
|
|
57
|
+
try {
|
|
58
|
+
const detectedMimeType = await detectMimeType(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty);
|
|
59
|
+
const isLikelyImage = isImageMimeType(detectedMimeType);
|
|
60
|
+
const isLikelyAudio = isAudioMimeType(detectedMimeType);
|
|
61
|
+
if (isLikelyAudio && !isLikelyImage) {
|
|
21
62
|
try {
|
|
22
63
|
const audioResult = await (0, index_1.processAudioFile)(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty);
|
|
23
64
|
return {
|
|
24
65
|
type: 'audio',
|
|
25
66
|
dataUrl: `data:${audioResult.mimeType};base64,${audioResult.data}`,
|
|
26
|
-
description: `Audio file: ${audioResult.filename} (${Math.round(audioResult.size / 1024)}KB)`,
|
|
67
|
+
description: `Audio file: ${audioResult.filename} (${Math.round(audioResult.size / 1024)}KB, ${audioResult.mimeType})`,
|
|
27
68
|
mimeType: audioResult.mimeType,
|
|
28
69
|
};
|
|
29
70
|
}
|
|
30
71
|
catch (audioError) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
throw new Error(`Audio processing failed: ${audioError instanceof Error ? audioError.message : 'Unknown error'}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (isLikelyImage && !isLikelyAudio) {
|
|
76
|
+
try {
|
|
77
|
+
const imageResult = await (0, index_1.processImageFile)(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty);
|
|
78
|
+
const formatValidation = validateImageFormat(imageResult.mimeType);
|
|
79
|
+
if (!formatValidation.isValid) {
|
|
80
|
+
throw new Error(suggestImageConversion(imageResult.mimeType));
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
type: 'image',
|
|
84
|
+
dataUrl: `data:${imageResult.mimeType};base64,${imageResult.data}`,
|
|
85
|
+
description: `Image file: ${imageResult.filename} (${Math.round(imageResult.size / 1024)}KB, ${imageResult.mimeType})`,
|
|
86
|
+
mimeType: imageResult.mimeType,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (imageError) {
|
|
90
|
+
throw new Error(`Image processing failed: ${imageError instanceof Error ? imageError.message : 'Unknown error'}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (detectedMimeType.includes('mpeg') || detectedMimeType.includes('mp3')) {
|
|
95
|
+
try {
|
|
96
|
+
const audioResult = await (0, index_1.processAudioFile)(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty);
|
|
97
|
+
return {
|
|
98
|
+
type: 'audio',
|
|
99
|
+
dataUrl: `data:${audioResult.mimeType};base64,${audioResult.data}`,
|
|
100
|
+
description: `Audio file: ${audioResult.filename} (${Math.round(audioResult.size / 1024)}KB, ${audioResult.mimeType})`,
|
|
101
|
+
mimeType: audioResult.mimeType,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (audioError) {
|
|
105
|
+
throw new Error(`MPEG audio processing failed: ${audioError instanceof Error ? audioError.message : 'Unknown error'}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
try {
|
|
110
|
+
const imageResult = await (0, index_1.processImageFile)(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty);
|
|
111
|
+
const formatValidation = validateImageFormat(imageResult.mimeType);
|
|
112
|
+
if (!formatValidation.isValid) {
|
|
113
|
+
throw new Error(suggestImageConversion(imageResult.mimeType));
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
type: 'image',
|
|
117
|
+
dataUrl: `data:${imageResult.mimeType};base64,${imageResult.data}`,
|
|
118
|
+
description: `Image file: ${imageResult.filename} (${Math.round(imageResult.size / 1024)}KB, ${imageResult.mimeType})`,
|
|
119
|
+
mimeType: imageResult.mimeType,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (imageError) {
|
|
123
|
+
try {
|
|
124
|
+
const audioResult = await (0, index_1.processAudioFile)(context, itemIndex, source, mediaFile, mediaUrl, binaryProperty);
|
|
125
|
+
return {
|
|
126
|
+
type: 'audio',
|
|
127
|
+
dataUrl: `data:${audioResult.mimeType};base64,${audioResult.data}`,
|
|
128
|
+
description: `Audio file: ${audioResult.filename} (${Math.round(audioResult.size / 1024)}KB, ${audioResult.mimeType})`,
|
|
129
|
+
mimeType: audioResult.mimeType,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (audioError) {
|
|
133
|
+
const supportedImageFormats = ['PNG', 'JPEG', 'GIF', 'WebP'];
|
|
134
|
+
const supportedAudioFormats = ['MP3', 'WAV', 'M4A', 'OGG'];
|
|
135
|
+
throw new Error(`File is neither a valid image nor audio file (detected MIME: ${detectedMimeType}).\n` +
|
|
136
|
+
`Supported image formats: ${supportedImageFormats.join(', ')}\n` +
|
|
137
|
+
`Supported audio formats: ${supportedAudioFormats.join(', ')}\n` +
|
|
138
|
+
`Image error: ${imageError instanceof Error ? imageError.message : 'Unknown'}\n` +
|
|
139
|
+
`Audio error: ${audioError instanceof Error ? audioError.message : 'Unknown'}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
38
142
|
}
|
|
39
143
|
}
|
|
40
144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-github-copilot",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"description": "n8n community node for GitHub Copilot with CLI integration and official Chat API access to GPT-5, Claude, Gemini and more using your existing Copilot credits",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
|