n8n-nodes-github-copilot 3.4.0 → 3.5.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/dist/credentials/GitHubApi.credentials.d.ts +8 -8
- package/dist/credentials/GitHubApi.credentials.js +50 -50
- package/dist/credentials/GitHubApiManual.credentials.d.ts +7 -7
- package/dist/credentials/GitHubApiManual.credentials.js +33 -33
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.d.ts +5 -5
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +324 -324
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.d.ts +5 -5
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +141 -146
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.d.ts +2 -2
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.js +172 -202
- package/dist/nodes/GitHubCopilotChatAPI/utils/helpers.d.ts +19 -21
- package/dist/nodes/GitHubCopilotChatAPI/utils/helpers.js +130 -131
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.d.ts +8 -8
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.js +100 -101
- package/dist/nodes/GitHubCopilotChatAPI/utils/index.d.ts +3 -3
- package/dist/nodes/GitHubCopilotChatAPI/utils/index.js +19 -19
- package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.d.ts +14 -14
- package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.js +70 -71
- package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.d.ts +5 -5
- package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.js +113 -113
- package/dist/nodes/GitHubCopilotChatAPI/utils/types.d.ts +57 -57
- package/dist/nodes/GitHubCopilotChatAPI/utils/types.js +2 -2
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.d.ts +5 -5
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +141 -211
- package/dist/shared/models/GitHubCopilotModels.d.ts +43 -0
- package/dist/shared/models/GitHubCopilotModels.js +218 -0
- package/package.json +5 -4
- package/dist/credentials/N8nApi.credentials.d.ts +0 -7
- package/dist/credentials/N8nApi.credentials.js +0 -31
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.backup.d.ts +0 -5
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.backup.js +0 -651
- package/dist/nodes/GitHubCopilotChatAPI/utils/audioProcessor.d.ts +0 -11
- package/dist/nodes/GitHubCopilotChatAPI/utils/audioProcessor.js +0 -86
- package/dist/nodes/N8nAiAgent/N8nAiAgent.node.d.ts +0 -5
- package/dist/nodes/N8nAiAgent/N8nAiAgent.node.js +0 -152
|
@@ -1,131 +1,130 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new Error(`
|
|
32
|
-
}
|
|
33
|
-
return
|
|
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
|
-
case '
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
case '
|
|
79
|
-
return 'audio/
|
|
80
|
-
case '
|
|
81
|
-
return 'audio/
|
|
82
|
-
case '
|
|
83
|
-
return 'audio/
|
|
84
|
-
case '
|
|
85
|
-
return 'audio/
|
|
86
|
-
|
|
87
|
-
return 'audio/
|
|
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
|
-
function truncateToTokenLimit(content, maxTokens = 100000) {
|
|
113
|
-
const originalTokens = Math.ceil(content.length / 4);
|
|
114
|
-
if (originalTokens <= maxTokens) {
|
|
115
|
-
return {
|
|
116
|
-
content,
|
|
117
|
-
truncated: false,
|
|
118
|
-
originalTokens,
|
|
119
|
-
finalTokens: originalTokens
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const targetLength = Math.floor(content.length * (maxTokens / originalTokens));
|
|
123
|
-
const truncatedContent = content.slice(0, targetLength) + '...[truncated]';
|
|
124
|
-
return {
|
|
125
|
-
content: truncatedContent,
|
|
126
|
-
truncated: true,
|
|
127
|
-
originalTokens,
|
|
128
|
-
finalTokens: Math.ceil(truncatedContent.length / 4)
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
exports.truncateToTokenLimit = truncateToTokenLimit;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeApiRequest = makeApiRequest;
|
|
4
|
+
exports.downloadFileFromUrl = downloadFileFromUrl;
|
|
5
|
+
exports.getFileFromBinary = getFileFromBinary;
|
|
6
|
+
exports.getImageMimeType = getImageMimeType;
|
|
7
|
+
exports.getAudioMimeType = getAudioMimeType;
|
|
8
|
+
exports.validateFileSize = validateFileSize;
|
|
9
|
+
exports.estimateTokens = estimateTokens;
|
|
10
|
+
exports.validateTokenLimit = validateTokenLimit;
|
|
11
|
+
exports.truncateToTokenLimit = truncateToTokenLimit;
|
|
12
|
+
async function makeApiRequest(context, endpoint, body, hasMedia = false) {
|
|
13
|
+
const credentials = await context.getCredentials('githubApi');
|
|
14
|
+
const headers = {
|
|
15
|
+
'Authorization': `Bearer ${credentials.accessToken}`,
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
'User-Agent': 'n8n-github-copilot-chat-api-node',
|
|
18
|
+
};
|
|
19
|
+
if (hasMedia) {
|
|
20
|
+
headers['Copilot-Vision-Request'] = 'true';
|
|
21
|
+
headers['Copilot-Media-Request'] = 'true';
|
|
22
|
+
}
|
|
23
|
+
const options = {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers,
|
|
26
|
+
body: JSON.stringify(body),
|
|
27
|
+
};
|
|
28
|
+
const response = await fetch(`https://api.githubcopilot.com${endpoint}`, options);
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
const errorText = await response.text();
|
|
31
|
+
throw new Error(`GitHub Copilot API error: ${response.status} ${response.statusText}. ${errorText}`);
|
|
32
|
+
}
|
|
33
|
+
return await response.json();
|
|
34
|
+
}
|
|
35
|
+
async function downloadFileFromUrl(url) {
|
|
36
|
+
const response = await fetch(url);
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`Failed to download file from URL: ${response.status} ${response.statusText}`);
|
|
39
|
+
}
|
|
40
|
+
return Buffer.from(await response.arrayBuffer());
|
|
41
|
+
}
|
|
42
|
+
async function getFileFromBinary(context, itemIndex, propertyName) {
|
|
43
|
+
const items = context.getInputData();
|
|
44
|
+
const item = items[itemIndex];
|
|
45
|
+
if (!item.binary || !item.binary[propertyName]) {
|
|
46
|
+
throw new Error(`No binary data found in property "${propertyName}"`);
|
|
47
|
+
}
|
|
48
|
+
const binaryData = item.binary[propertyName];
|
|
49
|
+
if (binaryData.data) {
|
|
50
|
+
return Buffer.from(binaryData.data, 'base64');
|
|
51
|
+
}
|
|
52
|
+
else if (binaryData.id) {
|
|
53
|
+
return await context.helpers.getBinaryDataBuffer(itemIndex, propertyName);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error(`Invalid binary data format in property "${propertyName}"`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function getImageMimeType(filename) {
|
|
60
|
+
const ext = filename.toLowerCase().split('.').pop();
|
|
61
|
+
switch (ext) {
|
|
62
|
+
case 'jpg':
|
|
63
|
+
case 'jpeg':
|
|
64
|
+
return 'image/jpeg';
|
|
65
|
+
case 'png':
|
|
66
|
+
return 'image/png';
|
|
67
|
+
case 'webp':
|
|
68
|
+
return 'image/webp';
|
|
69
|
+
case 'gif':
|
|
70
|
+
return 'image/gif';
|
|
71
|
+
default:
|
|
72
|
+
return 'image/jpeg';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getAudioMimeType(filename) {
|
|
76
|
+
const ext = filename.toLowerCase().split('.').pop();
|
|
77
|
+
switch (ext) {
|
|
78
|
+
case 'mp3':
|
|
79
|
+
return 'audio/mpeg';
|
|
80
|
+
case 'wav':
|
|
81
|
+
return 'audio/wav';
|
|
82
|
+
case 'm4a':
|
|
83
|
+
return 'audio/mp4';
|
|
84
|
+
case 'flac':
|
|
85
|
+
return 'audio/flac';
|
|
86
|
+
case 'ogg':
|
|
87
|
+
return 'audio/ogg';
|
|
88
|
+
case 'aac':
|
|
89
|
+
return 'audio/aac';
|
|
90
|
+
default:
|
|
91
|
+
return 'audio/mpeg';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function validateFileSize(buffer, maxSizeKB = 1024) {
|
|
95
|
+
const sizeKB = buffer.length / 1024;
|
|
96
|
+
if (sizeKB > maxSizeKB) {
|
|
97
|
+
throw new Error(`File size ${sizeKB.toFixed(2)}KB exceeds limit of ${maxSizeKB}KB`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function estimateTokens(base64String) {
|
|
101
|
+
return Math.ceil((base64String.length / 4 * 3) / 4);
|
|
102
|
+
}
|
|
103
|
+
function validateTokenLimit(estimatedTokens, maxTokens = 128000) {
|
|
104
|
+
if (estimatedTokens <= maxTokens) {
|
|
105
|
+
return { valid: true };
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
valid: false,
|
|
109
|
+
message: `Content too large: ${estimatedTokens} tokens exceeds limit of ${maxTokens}. Consider using smaller files or text.`
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function truncateToTokenLimit(content, maxTokens = 100000) {
|
|
113
|
+
const originalTokens = Math.ceil(content.length / 4);
|
|
114
|
+
if (originalTokens <= maxTokens) {
|
|
115
|
+
return {
|
|
116
|
+
content,
|
|
117
|
+
truncated: false,
|
|
118
|
+
originalTokens,
|
|
119
|
+
finalTokens: originalTokens
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const targetLength = Math.floor(content.length * (maxTokens / originalTokens));
|
|
123
|
+
const truncatedContent = content.slice(0, targetLength) + '...[truncated]';
|
|
124
|
+
return {
|
|
125
|
+
content: truncatedContent,
|
|
126
|
+
truncated: true,
|
|
127
|
+
originalTokens,
|
|
128
|
+
finalTokens: Math.ceil(truncatedContent.length / 4)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
-
import { ProcessedFileResult, OptimizationOptions } from './types';
|
|
3
|
-
export declare function processImageFile(context: IExecuteFunctions, itemIndex: number, imageSource: string, imageFile?: string, imageUrl?: string, imageProperty?: string, optimization?: OptimizationOptions): Promise<ProcessedFileResult>;
|
|
4
|
-
export declare function compressImageToTokenLimit(base64Data: string, maxTokens?: number): string;
|
|
5
|
-
export declare function resizeImageDimensions(originalWidth: number, originalHeight: number, maxWidth?: number, maxHeight?: number): {
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
};
|
|
1
|
+
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
import { ProcessedFileResult, OptimizationOptions } from './types';
|
|
3
|
+
export declare function processImageFile(context: IExecuteFunctions, itemIndex: number, imageSource: string, imageFile?: string, imageUrl?: string, imageProperty?: string, optimization?: OptimizationOptions): Promise<ProcessedFileResult>;
|
|
4
|
+
export declare function compressImageToTokenLimit(base64Data: string, maxTokens?: number): string;
|
|
5
|
+
export declare function resizeImageDimensions(originalWidth: number, originalHeight: number, maxWidth?: number, maxHeight?: number): {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
@@ -1,101 +1,100 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
function resizeImageDimensions(originalWidth, originalHeight, maxWidth = 1024, maxHeight = 1024) {
|
|
90
|
-
let { width, height } = { width: originalWidth, height: originalHeight };
|
|
91
|
-
if (width > maxWidth) {
|
|
92
|
-
height = (height * maxWidth) / width;
|
|
93
|
-
width = maxWidth;
|
|
94
|
-
}
|
|
95
|
-
if (height > maxHeight) {
|
|
96
|
-
width = (width * maxHeight) / height;
|
|
97
|
-
height = maxHeight;
|
|
98
|
-
}
|
|
99
|
-
return { width: Math.round(width), height: Math.round(height) };
|
|
100
|
-
}
|
|
101
|
-
exports.resizeImageDimensions = resizeImageDimensions;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processImageFile = processImageFile;
|
|
4
|
+
exports.compressImageToTokenLimit = compressImageToTokenLimit;
|
|
5
|
+
exports.resizeImageDimensions = resizeImageDimensions;
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
async function processImageFile(context, itemIndex, imageSource, imageFile, imageUrl, imageProperty, optimization) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
let imageBuffer;
|
|
10
|
+
let filename;
|
|
11
|
+
switch (imageSource) {
|
|
12
|
+
case 'file':
|
|
13
|
+
if (!imageFile) {
|
|
14
|
+
throw new Error('Image file content is required when source is "file"');
|
|
15
|
+
}
|
|
16
|
+
imageBuffer = Buffer.from(imageFile, 'base64');
|
|
17
|
+
filename = 'uploaded_image.jpg';
|
|
18
|
+
break;
|
|
19
|
+
case 'url':
|
|
20
|
+
if (!imageUrl) {
|
|
21
|
+
throw new Error('Image URL is required when source is "url"');
|
|
22
|
+
}
|
|
23
|
+
imageBuffer = await (0, helpers_1.downloadFileFromUrl)(imageUrl);
|
|
24
|
+
filename = imageUrl.split('/').pop() || 'downloaded_image.jpg';
|
|
25
|
+
break;
|
|
26
|
+
case 'binary':
|
|
27
|
+
if (!imageProperty) {
|
|
28
|
+
throw new Error('Image property name is required when source is "binary"');
|
|
29
|
+
}
|
|
30
|
+
imageBuffer = await (0, helpers_1.getFileFromBinary)(context, itemIndex, imageProperty);
|
|
31
|
+
const items = context.getInputData();
|
|
32
|
+
const item = items[itemIndex];
|
|
33
|
+
filename = ((_b = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[imageProperty]) === null || _b === void 0 ? void 0 : _b.fileName) || 'binary_image.jpg';
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Invalid image source: ${imageSource}`);
|
|
37
|
+
}
|
|
38
|
+
if (optimization) {
|
|
39
|
+
imageBuffer = await optimizeImage(imageBuffer, optimization);
|
|
40
|
+
}
|
|
41
|
+
(0, helpers_1.validateFileSize)(imageBuffer, 20480);
|
|
42
|
+
const base64Image = imageBuffer.toString('base64');
|
|
43
|
+
const estimatedTokens = (0, helpers_1.estimateTokens)(base64Image);
|
|
44
|
+
if (estimatedTokens > 50000) {
|
|
45
|
+
const compressedBuffer = await optimizeImage(imageBuffer, {
|
|
46
|
+
quality: 70,
|
|
47
|
+
maxSizeKB: (optimization === null || optimization === void 0 ? void 0 : optimization.maxSizeKB) || 1024
|
|
48
|
+
});
|
|
49
|
+
const compressedBase64 = compressedBuffer.toString('base64');
|
|
50
|
+
const compressedTokens = (0, helpers_1.estimateTokens)(compressedBase64);
|
|
51
|
+
if (compressedTokens < estimatedTokens) {
|
|
52
|
+
return {
|
|
53
|
+
data: compressedBase64,
|
|
54
|
+
mimeType: (0, helpers_1.getImageMimeType)(filename),
|
|
55
|
+
filename,
|
|
56
|
+
size: compressedBuffer.length,
|
|
57
|
+
estimatedTokens: compressedTokens
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const mimeType = (0, helpers_1.getImageMimeType)(filename);
|
|
62
|
+
return {
|
|
63
|
+
data: base64Image,
|
|
64
|
+
mimeType,
|
|
65
|
+
filename,
|
|
66
|
+
size: imageBuffer.length,
|
|
67
|
+
estimatedTokens
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function optimizeImage(buffer, options) {
|
|
71
|
+
if (options.maxSizeKB && buffer.length / 1024 > options.maxSizeKB) {
|
|
72
|
+
const compressionRatio = Math.min(0.8, options.maxSizeKB / (buffer.length / 1024));
|
|
73
|
+
const targetSize = Math.floor(buffer.length * compressionRatio);
|
|
74
|
+
if (targetSize < buffer.length) {
|
|
75
|
+
return buffer.slice(0, Math.max(targetSize, 1024));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return buffer;
|
|
79
|
+
}
|
|
80
|
+
function compressImageToTokenLimit(base64Data, maxTokens = 50000) {
|
|
81
|
+
const estimatedTokens = (0, helpers_1.estimateTokens)(base64Data);
|
|
82
|
+
if (estimatedTokens <= maxTokens) {
|
|
83
|
+
return base64Data;
|
|
84
|
+
}
|
|
85
|
+
const compressionRatio = maxTokens / estimatedTokens;
|
|
86
|
+
const targetLength = Math.floor(base64Data.length * compressionRatio);
|
|
87
|
+
return base64Data.slice(0, Math.max(targetLength, 1000));
|
|
88
|
+
}
|
|
89
|
+
function resizeImageDimensions(originalWidth, originalHeight, maxWidth = 1024, maxHeight = 1024) {
|
|
90
|
+
let { width, height } = { width: originalWidth, height: originalHeight };
|
|
91
|
+
if (width > maxWidth) {
|
|
92
|
+
height = (height * maxWidth) / width;
|
|
93
|
+
width = maxWidth;
|
|
94
|
+
}
|
|
95
|
+
if (height > maxHeight) {
|
|
96
|
+
width = (width * maxHeight) / height;
|
|
97
|
+
height = maxHeight;
|
|
98
|
+
}
|
|
99
|
+
return { width: Math.round(width), height: Math.round(height) };
|
|
100
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './helpers';
|
|
3
|
-
export * from './imageProcessor';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './helpers';
|
|
3
|
+
export * from './imageProcessor';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./helpers"), exports);
|
|
19
|
-
__exportStar(require("./imageProcessor"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./helpers"), exports);
|
|
19
|
+
__exportStar(require("./imageProcessor"), exports);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
-
export declare function processMediaFile(context: IExecuteFunctions, itemIndex: number, source: 'manual' | 'url' | 'binary', mediaFile?: string, mediaUrl?: string, binaryProperty?: string): Promise<{
|
|
3
|
-
type: 'image' | 'unknown';
|
|
4
|
-
dataUrl?: string;
|
|
5
|
-
description: string;
|
|
6
|
-
mimeType: string;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function isImageMimeType(mimeType: string): boolean;
|
|
9
|
-
export declare function validateImageFormat(mimeType: string): {
|
|
10
|
-
isValid: boolean;
|
|
11
|
-
error?: string;
|
|
12
|
-
};
|
|
13
|
-
export declare function getFileExtensionFromMimeType(mimeType: string): string;
|
|
14
|
-
export declare function suggestImageConversion(mimeType: string): string;
|
|
1
|
+
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare function processMediaFile(context: IExecuteFunctions, itemIndex: number, source: 'manual' | 'url' | 'binary', mediaFile?: string, mediaUrl?: string, binaryProperty?: string): Promise<{
|
|
3
|
+
type: 'image' | 'unknown';
|
|
4
|
+
dataUrl?: string;
|
|
5
|
+
description: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function isImageMimeType(mimeType: string): boolean;
|
|
9
|
+
export declare function validateImageFormat(mimeType: string): {
|
|
10
|
+
isValid: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getFileExtensionFromMimeType(mimeType: string): string;
|
|
14
|
+
export declare function suggestImageConversion(mimeType: string): string;
|