n8n-nodes-n8nfront 2.0.0
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/N8nFrontApi.credentials.d.ts +9 -0
- package/dist/credentials/N8nFrontApi.credentials.d.ts.map +1 -0
- package/dist/credentials/N8nFrontApi.credentials.js +39 -0
- package/dist/credentials/N8nFrontApi.credentials.js.map +1 -0
- package/dist/nodes/N8nFront/N8nFront.node.d.ts +6 -0
- package/dist/nodes/N8nFront/N8nFront.node.d.ts.map +1 -0
- package/dist/nodes/N8nFront/N8nFront.node.js +367 -0
- package/dist/nodes/N8nFront/N8nFront.node.js.map +1 -0
- package/dist/nodes/N8nFront/N8nFrontTrigger.node.d.ts +13 -0
- package/dist/nodes/N8nFront/N8nFrontTrigger.node.d.ts.map +1 -0
- package/dist/nodes/N8nFront/N8nFrontTrigger.node.js +142 -0
- package/dist/nodes/N8nFront/N8nFrontTrigger.node.js.map +1 -0
- package/dist/nodes/N8nFront/n8nfront.svg +7 -0
- package/package.json +45 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class N8nFrontApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
test: ICredentialTestRequest;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=N8nFrontApi.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nFrontApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/N8nFrontApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,MAAM,cAAc,CAAC;AAEtB,qBAAa,WAAY,YAAW,eAAe;IAClD,IAAI,SAAiB;IACrB,WAAW,SAAsB;IACjC,gBAAgB,SAAM;IACtB,UAAU,EAAE,eAAe,EAAE,CAmB3B;IAEF,IAAI,EAAE,sBAAsB,CAM1B;CACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.N8nFrontApi = void 0;
|
|
4
|
+
class N8nFrontApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'n8nFrontApi';
|
|
7
|
+
this.displayName = 'N8nFront Bot API';
|
|
8
|
+
this.documentationUrl = '';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Base URL',
|
|
12
|
+
name: 'baseUrl',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: '',
|
|
15
|
+
placeholder: 'https://chat.example.com',
|
|
16
|
+
description: 'URL вашего N8nFront сервера (без /api/bot)',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Bot Token',
|
|
21
|
+
name: 'botToken',
|
|
22
|
+
type: 'string',
|
|
23
|
+
typeOptions: { password: true },
|
|
24
|
+
default: '',
|
|
25
|
+
description: 'API-токен бота (из админки N8nFront)',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
this.test = {
|
|
30
|
+
request: {
|
|
31
|
+
baseURL: '={{$credentials.baseUrl}}',
|
|
32
|
+
url: '/api/bot/{{$credentials.botToken}}/getMe',
|
|
33
|
+
method: 'GET',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.N8nFrontApi = N8nFrontApi;
|
|
39
|
+
//# sourceMappingURL=N8nFrontApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nFrontApi.credentials.js","sourceRoot":"","sources":["../../credentials/N8nFrontApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,WAAW;IAAxB;QACC,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,kBAAkB,CAAC;QACjC,qBAAgB,GAAG,EAAE,CAAC;QACtB,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,0BAA0B;gBACvC,WAAW,EAAE,4CAA4C;gBACzD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,sCAAsC;gBACnD,QAAQ,EAAE,IAAI;aACd;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,0CAA0C;gBAC/C,MAAM,EAAE,KAAK;aACb;SACD,CAAC;IACH,CAAC;CAAA;AAhCD,kCAgCC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class N8nFront implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=N8nFront.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nFront.node.d.ts","sourceRoot":"","sources":["../../../nodes/N8nFront/N8nFront.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EAEpB,MAAM,cAAc,CAAC;AAqKtB,qBAAa,QAAS,YAAW,SAAS;IACzC,WAAW,EAAE,oBAAoB,CAoB/B;IAEI,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAwMvE"}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.N8nFront = void 0;
|
|
4
|
+
const operationFields = [
|
|
5
|
+
{
|
|
6
|
+
displayName: 'Operation',
|
|
7
|
+
name: 'operation',
|
|
8
|
+
type: 'options',
|
|
9
|
+
noDataExpression: true,
|
|
10
|
+
default: 'sendMessage',
|
|
11
|
+
options: [
|
|
12
|
+
{
|
|
13
|
+
name: 'Отправить сообщение',
|
|
14
|
+
value: 'sendMessage',
|
|
15
|
+
action: 'Отправить текстовое сообщение',
|
|
16
|
+
description: 'Отправить текстовое сообщение в чат',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Редактировать сообщение',
|
|
20
|
+
value: 'editMessageText',
|
|
21
|
+
action: 'Редактировать текст сообщения',
|
|
22
|
+
description: 'Изменить текст ранее отправленного сообщения бота',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Удалить сообщение',
|
|
26
|
+
value: 'deleteMessage',
|
|
27
|
+
action: 'Удалить сообщение',
|
|
28
|
+
description: 'Удалить сообщение в чате (soft delete)',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'Отправить документ',
|
|
32
|
+
value: 'sendDocument',
|
|
33
|
+
action: 'Отправить файл',
|
|
34
|
+
description: 'Отправить файл-документ в чат',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'Отправить фото',
|
|
38
|
+
value: 'sendPhoto',
|
|
39
|
+
action: 'Отправить изображение',
|
|
40
|
+
description: 'Отправить изображение в чат',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Скачать файл',
|
|
44
|
+
value: 'downloadFile',
|
|
45
|
+
action: 'Скачать файл как binary',
|
|
46
|
+
description: 'Скачать файл по file_id как бинарные данные для обработки в n8n',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Получить файл (инфо)',
|
|
50
|
+
value: 'getFile',
|
|
51
|
+
action: 'Получить информацию о файле',
|
|
52
|
+
description: 'Получить метаданные файла и ссылку на скачивание',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'Индикатор набора',
|
|
56
|
+
value: 'sendChatAction',
|
|
57
|
+
action: 'Показать индикатор набора',
|
|
58
|
+
description: 'Показать индикатор «бот печатает...» в чате',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Информация о боте',
|
|
62
|
+
value: 'getMe',
|
|
63
|
+
action: 'Получить информацию о боте',
|
|
64
|
+
description: 'Возвращает информацию о текущем боте',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
// --- Chat ID (shared by most operations) ---
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Chat ID',
|
|
71
|
+
name: 'chatId',
|
|
72
|
+
type: 'string',
|
|
73
|
+
default: '',
|
|
74
|
+
required: true,
|
|
75
|
+
description: 'ID чата (conversation). Берётся из триггера: {{ $json.message.chat.id }}',
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
operation: [
|
|
79
|
+
'sendMessage', 'editMessageText', 'deleteMessage',
|
|
80
|
+
'sendDocument', 'sendPhoto', 'sendChatAction',
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
// --- Message ID (for edit / delete) ---
|
|
86
|
+
{
|
|
87
|
+
displayName: 'Message ID',
|
|
88
|
+
name: 'messageId',
|
|
89
|
+
type: 'number',
|
|
90
|
+
default: 0,
|
|
91
|
+
required: true,
|
|
92
|
+
description: 'ID сообщения для редактирования/удаления. Берётся из триггера: {{ $json.message.message_id }}',
|
|
93
|
+
displayOptions: { show: { operation: ['editMessageText', 'deleteMessage'] } },
|
|
94
|
+
},
|
|
95
|
+
// --- Text (sendMessage, editMessageText) ---
|
|
96
|
+
{
|
|
97
|
+
displayName: 'Текст',
|
|
98
|
+
name: 'text',
|
|
99
|
+
type: 'string',
|
|
100
|
+
typeOptions: { rows: 4 },
|
|
101
|
+
default: '',
|
|
102
|
+
required: true,
|
|
103
|
+
description: 'Текст сообщения',
|
|
104
|
+
displayOptions: { show: { operation: ['sendMessage', 'editMessageText'] } },
|
|
105
|
+
},
|
|
106
|
+
// --- Parse Mode ---
|
|
107
|
+
{
|
|
108
|
+
displayName: 'Parse Mode',
|
|
109
|
+
name: 'parseMode',
|
|
110
|
+
type: 'options',
|
|
111
|
+
default: '',
|
|
112
|
+
options: [
|
|
113
|
+
{ name: 'Без форматирования', value: '' },
|
|
114
|
+
{ name: 'Markdown', value: 'markdown' },
|
|
115
|
+
{ name: 'HTML', value: 'html' },
|
|
116
|
+
],
|
|
117
|
+
description: 'Режим форматирования текста',
|
|
118
|
+
displayOptions: { show: { operation: ['sendMessage', 'editMessageText'] } },
|
|
119
|
+
},
|
|
120
|
+
// --- Reply Markup (inline keyboard) ---
|
|
121
|
+
{
|
|
122
|
+
displayName: 'Reply Markup (JSON)',
|
|
123
|
+
name: 'replyMarkup',
|
|
124
|
+
type: 'json',
|
|
125
|
+
default: '',
|
|
126
|
+
description: 'JSON inline-клавиатуры (Telegram-формат). Пример: {"inline_keyboard":[[{"text":"Кнопка","callback_data":"btn1"}]]}',
|
|
127
|
+
displayOptions: { show: { operation: ['sendMessage', 'editMessageText'] } },
|
|
128
|
+
},
|
|
129
|
+
// --- sendDocument / sendPhoto ---
|
|
130
|
+
{
|
|
131
|
+
displayName: 'Binary Property',
|
|
132
|
+
name: 'binaryProperty',
|
|
133
|
+
type: 'string',
|
|
134
|
+
default: 'data',
|
|
135
|
+
required: true,
|
|
136
|
+
description: 'Имя бинарного свойства с файлом для отправки',
|
|
137
|
+
displayOptions: { show: { operation: ['sendDocument', 'sendPhoto'] } },
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
displayName: 'Подпись',
|
|
141
|
+
name: 'caption',
|
|
142
|
+
type: 'string',
|
|
143
|
+
default: '',
|
|
144
|
+
description: 'Подпись к файлу/фото (необязательно)',
|
|
145
|
+
displayOptions: { show: { operation: ['sendDocument', 'sendPhoto'] } },
|
|
146
|
+
},
|
|
147
|
+
// --- getFile / downloadFile ---
|
|
148
|
+
{
|
|
149
|
+
displayName: 'File ID',
|
|
150
|
+
name: 'fileId',
|
|
151
|
+
type: 'string',
|
|
152
|
+
default: '',
|
|
153
|
+
required: true,
|
|
154
|
+
description: 'Идентификатор файла (file_id). Берётся из данных сообщения с файлом',
|
|
155
|
+
displayOptions: { show: { operation: ['getFile', 'downloadFile'] } },
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
displayName: 'Binary Property',
|
|
159
|
+
name: 'downloadBinaryProperty',
|
|
160
|
+
type: 'string',
|
|
161
|
+
default: 'data',
|
|
162
|
+
description: 'Имя бинарного свойства, куда будет записан скачанный файл',
|
|
163
|
+
displayOptions: { show: { operation: ['downloadFile'] } },
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
class N8nFront {
|
|
167
|
+
constructor() {
|
|
168
|
+
this.description = {
|
|
169
|
+
displayName: 'N8nFront',
|
|
170
|
+
name: 'n8nFront',
|
|
171
|
+
icon: 'file:n8nfront.svg',
|
|
172
|
+
group: ['output'],
|
|
173
|
+
version: 1,
|
|
174
|
+
subtitle: '={{ $parameter["operation"] }}',
|
|
175
|
+
description: 'Отправка сообщений и файлов через N8nFront Bot API',
|
|
176
|
+
defaults: {
|
|
177
|
+
name: 'N8nFront',
|
|
178
|
+
},
|
|
179
|
+
inputs: ['main'],
|
|
180
|
+
outputs: ['main'],
|
|
181
|
+
credentials: [
|
|
182
|
+
{
|
|
183
|
+
name: 'n8nFrontApi',
|
|
184
|
+
required: true,
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
properties: operationFields,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
async execute() {
|
|
191
|
+
const items = this.getInputData();
|
|
192
|
+
const returnData = [];
|
|
193
|
+
const credentials = await this.getCredentials('n8nFrontApi');
|
|
194
|
+
const baseUrl = credentials.baseUrl.replace(/\/+$/, '');
|
|
195
|
+
const botToken = credentials.botToken;
|
|
196
|
+
const apiBase = `${baseUrl}/api/bot/${botToken}`;
|
|
197
|
+
for (let i = 0; i < items.length; i++) {
|
|
198
|
+
const operation = this.getNodeParameter('operation', i);
|
|
199
|
+
try {
|
|
200
|
+
if (operation === 'getMe') {
|
|
201
|
+
const response = await this.helpers.httpRequest({
|
|
202
|
+
method: 'GET',
|
|
203
|
+
url: `${apiBase}/getMe`,
|
|
204
|
+
});
|
|
205
|
+
returnData.push({ json: response });
|
|
206
|
+
}
|
|
207
|
+
else if (operation === 'sendMessage') {
|
|
208
|
+
const chatId = this.getNodeParameter('chatId', i);
|
|
209
|
+
const text = this.getNodeParameter('text', i);
|
|
210
|
+
const parseMode = this.getNodeParameter('parseMode', i);
|
|
211
|
+
const replyMarkup = this.getNodeParameter('replyMarkup', i, '');
|
|
212
|
+
const body = {
|
|
213
|
+
chat_id: chatId,
|
|
214
|
+
text,
|
|
215
|
+
parse_mode: parseMode,
|
|
216
|
+
};
|
|
217
|
+
if (replyMarkup) {
|
|
218
|
+
body.reply_markup = typeof replyMarkup === 'string'
|
|
219
|
+
? JSON.parse(replyMarkup) : replyMarkup;
|
|
220
|
+
}
|
|
221
|
+
const response = await this.helpers.httpRequest({
|
|
222
|
+
method: 'POST',
|
|
223
|
+
url: `${apiBase}/sendMessage`,
|
|
224
|
+
body,
|
|
225
|
+
headers: { 'Content-Type': 'application/json' },
|
|
226
|
+
});
|
|
227
|
+
returnData.push({ json: response });
|
|
228
|
+
}
|
|
229
|
+
else if (operation === 'editMessageText') {
|
|
230
|
+
const chatId = this.getNodeParameter('chatId', i);
|
|
231
|
+
const messageId = this.getNodeParameter('messageId', i);
|
|
232
|
+
const text = this.getNodeParameter('text', i);
|
|
233
|
+
const parseMode = this.getNodeParameter('parseMode', i);
|
|
234
|
+
const replyMarkup = this.getNodeParameter('replyMarkup', i, '');
|
|
235
|
+
const body = {
|
|
236
|
+
chat_id: chatId,
|
|
237
|
+
message_id: messageId,
|
|
238
|
+
text,
|
|
239
|
+
parse_mode: parseMode,
|
|
240
|
+
};
|
|
241
|
+
if (replyMarkup) {
|
|
242
|
+
body.reply_markup = typeof replyMarkup === 'string'
|
|
243
|
+
? JSON.parse(replyMarkup) : replyMarkup;
|
|
244
|
+
}
|
|
245
|
+
const response = await this.helpers.httpRequest({
|
|
246
|
+
method: 'POST',
|
|
247
|
+
url: `${apiBase}/editMessageText`,
|
|
248
|
+
body,
|
|
249
|
+
headers: { 'Content-Type': 'application/json' },
|
|
250
|
+
});
|
|
251
|
+
returnData.push({ json: response });
|
|
252
|
+
}
|
|
253
|
+
else if (operation === 'deleteMessage') {
|
|
254
|
+
const chatId = this.getNodeParameter('chatId', i);
|
|
255
|
+
const messageId = this.getNodeParameter('messageId', i);
|
|
256
|
+
const response = await this.helpers.httpRequest({
|
|
257
|
+
method: 'POST',
|
|
258
|
+
url: `${apiBase}/deleteMessage`,
|
|
259
|
+
body: {
|
|
260
|
+
chat_id: chatId,
|
|
261
|
+
message_id: messageId,
|
|
262
|
+
},
|
|
263
|
+
headers: { 'Content-Type': 'application/json' },
|
|
264
|
+
});
|
|
265
|
+
returnData.push({ json: response });
|
|
266
|
+
}
|
|
267
|
+
else if (operation === 'sendChatAction') {
|
|
268
|
+
const chatId = this.getNodeParameter('chatId', i);
|
|
269
|
+
const response = await this.helpers.httpRequest({
|
|
270
|
+
method: 'POST',
|
|
271
|
+
url: `${apiBase}/sendChatAction`,
|
|
272
|
+
body: {
|
|
273
|
+
chat_id: chatId,
|
|
274
|
+
action: 'typing',
|
|
275
|
+
},
|
|
276
|
+
headers: { 'Content-Type': 'application/json' },
|
|
277
|
+
});
|
|
278
|
+
returnData.push({ json: response });
|
|
279
|
+
}
|
|
280
|
+
else if (operation === 'sendDocument' || operation === 'sendPhoto') {
|
|
281
|
+
const chatId = this.getNodeParameter('chatId', i);
|
|
282
|
+
const caption = this.getNodeParameter('caption', i);
|
|
283
|
+
const binaryProperty = this.getNodeParameter('binaryProperty', i);
|
|
284
|
+
const binaryData = this.helpers.assertBinaryData(i, binaryProperty);
|
|
285
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
|
|
286
|
+
const fieldName = operation === 'sendPhoto' ? 'photo' : 'document';
|
|
287
|
+
const fileName = binaryData.fileName || 'file';
|
|
288
|
+
const mimeType = binaryData.mimeType || 'application/octet-stream';
|
|
289
|
+
const response = await this.helpers.request({
|
|
290
|
+
method: 'POST',
|
|
291
|
+
uri: `${apiBase}/${operation}`,
|
|
292
|
+
formData: {
|
|
293
|
+
chat_id: chatId,
|
|
294
|
+
caption,
|
|
295
|
+
[fieldName]: {
|
|
296
|
+
value: buffer,
|
|
297
|
+
options: {
|
|
298
|
+
filename: fileName,
|
|
299
|
+
contentType: mimeType,
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
json: true,
|
|
304
|
+
});
|
|
305
|
+
returnData.push({ json: response });
|
|
306
|
+
}
|
|
307
|
+
else if (operation === 'getFile') {
|
|
308
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
309
|
+
const response = await this.helpers.httpRequest({
|
|
310
|
+
method: 'GET',
|
|
311
|
+
url: `${apiBase}/getFile`,
|
|
312
|
+
qs: { file_id: fileId },
|
|
313
|
+
});
|
|
314
|
+
returnData.push({ json: response });
|
|
315
|
+
}
|
|
316
|
+
else if (operation === 'downloadFile') {
|
|
317
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
318
|
+
const binaryProperty = this.getNodeParameter('downloadBinaryProperty', i);
|
|
319
|
+
// Step 1: get file info
|
|
320
|
+
const fileInfo = await this.helpers.httpRequest({
|
|
321
|
+
method: 'GET',
|
|
322
|
+
url: `${apiBase}/getFile`,
|
|
323
|
+
qs: { file_id: fileId },
|
|
324
|
+
});
|
|
325
|
+
if (!fileInfo.ok || !fileInfo.result?.file_path) {
|
|
326
|
+
throw new Error(`File not found: ${fileId}`);
|
|
327
|
+
}
|
|
328
|
+
// Step 2: download binary
|
|
329
|
+
const filePath = fileInfo.result.file_path;
|
|
330
|
+
const downloadUrl = `${apiBase}/${filePath}`;
|
|
331
|
+
const response = await this.helpers.httpRequest({
|
|
332
|
+
method: 'GET',
|
|
333
|
+
url: downloadUrl,
|
|
334
|
+
encoding: 'arraybuffer',
|
|
335
|
+
returnFullResponse: true,
|
|
336
|
+
});
|
|
337
|
+
const contentType = response.headers?.['content-type'] || 'application/octet-stream';
|
|
338
|
+
const contentDisposition = response.headers?.['content-disposition'] || '';
|
|
339
|
+
let fileName = fileId;
|
|
340
|
+
// Extract filename from Content-Disposition header
|
|
341
|
+
const filenameMatch = contentDisposition.match(/filename[^;=\n]*=(?:UTF-8''|"?)([^";\n]*)/i);
|
|
342
|
+
if (filenameMatch) {
|
|
343
|
+
fileName = decodeURIComponent(filenameMatch[1]);
|
|
344
|
+
}
|
|
345
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.body), fileName, contentType);
|
|
346
|
+
returnData.push({
|
|
347
|
+
json: fileInfo,
|
|
348
|
+
binary: { [binaryProperty]: binaryData },
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
if (this.continueOnFail()) {
|
|
354
|
+
returnData.push({
|
|
355
|
+
json: { error: error.message },
|
|
356
|
+
pairedItem: { item: i },
|
|
357
|
+
});
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return [returnData];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
exports.N8nFront = N8nFront;
|
|
367
|
+
//# sourceMappingURL=N8nFront.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nFront.node.js","sourceRoot":"","sources":["../../../nodes/N8nFront/N8nFront.node.ts"],"names":[],"mappings":";;;AAQA,MAAM,eAAe,GAAsB;IAC1C;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,aAAa;QACtB,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,qBAAqB;gBAC3B,KAAK,EAAE,aAAa;gBACpB,MAAM,EAAE,+BAA+B;gBACvC,WAAW,EAAE,qCAAqC;aAClD;YACD;gBACC,IAAI,EAAE,yBAAyB;gBAC/B,KAAK,EAAE,iBAAiB;gBACxB,MAAM,EAAE,+BAA+B;gBACvC,WAAW,EAAE,mDAAmD;aAChE;YACD;gBACC,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,eAAe;gBACtB,MAAM,EAAE,mBAAmB;gBAC3B,WAAW,EAAE,wCAAwC;aACrD;YACD;gBACC,IAAI,EAAE,oBAAoB;gBAC1B,KAAK,EAAE,cAAc;gBACrB,MAAM,EAAE,gBAAgB;gBACxB,WAAW,EAAE,+BAA+B;aAC5C;YACD;gBACC,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,WAAW;gBAClB,MAAM,EAAE,uBAAuB;gBAC/B,WAAW,EAAE,6BAA6B;aAC1C;YACD;gBACC,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,cAAc;gBACrB,MAAM,EAAE,yBAAyB;gBACjC,WAAW,EAAE,iEAAiE;aAC9E;YACD;gBACC,IAAI,EAAE,sBAAsB;gBAC5B,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,6BAA6B;gBACrC,WAAW,EAAE,kDAAkD;aAC/D;YACD;gBACC,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,gBAAgB;gBACvB,MAAM,EAAE,2BAA2B;gB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|
+
export declare class N8nFrontTrigger implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
webhookMethods: {
|
|
5
|
+
default: {
|
|
6
|
+
checkExists(this: IHookFunctions): Promise<boolean>;
|
|
7
|
+
create(this: IHookFunctions): Promise<boolean>;
|
|
8
|
+
delete(this: IHookFunctions): Promise<boolean>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=N8nFrontTrigger.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nFrontTrigger.node.d.ts","sourceRoot":"","sources":["../../../nodes/N8nFront/N8nFrontTrigger.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,oBAAoB,EACpB,cAAc,EACd,MAAM,cAAc,CAAC;AAEtB,qBAAa,eAAgB,YAAW,SAAS;IAChD,WAAW,EAAE,oBAAoB,CA0D/B;IAEF,cAAc;;8BAEY,cAAc,GAAG,QAAQ,OAAO,CAAC;yBAetC,cAAc,GAAG,QAAQ,OAAO,CAAC;yBAcjC,cAAc,GAAG,QAAQ,OAAO,CAAC;;MAepD;IAEI,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuDrE"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.N8nFrontTrigger = void 0;
|
|
4
|
+
class N8nFrontTrigger {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.description = {
|
|
7
|
+
displayName: 'N8nFront Trigger',
|
|
8
|
+
name: 'n8nFrontTrigger',
|
|
9
|
+
icon: 'file:n8nfront.svg',
|
|
10
|
+
group: ['trigger'],
|
|
11
|
+
version: 1,
|
|
12
|
+
subtitle: 'Получает события из чата',
|
|
13
|
+
description: 'Срабатывает при получении сообщения или callback от пользователя в N8nFront',
|
|
14
|
+
defaults: {
|
|
15
|
+
name: 'N8nFront Trigger',
|
|
16
|
+
},
|
|
17
|
+
inputs: [],
|
|
18
|
+
outputs: ['main'],
|
|
19
|
+
credentials: [
|
|
20
|
+
{
|
|
21
|
+
name: 'n8nFrontApi',
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
webhooks: [
|
|
26
|
+
{
|
|
27
|
+
name: 'default',
|
|
28
|
+
httpMethod: 'POST',
|
|
29
|
+
responseMode: 'onReceived',
|
|
30
|
+
path: 'webhook',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
properties: [
|
|
34
|
+
{
|
|
35
|
+
displayName: 'Events',
|
|
36
|
+
name: 'events',
|
|
37
|
+
type: 'multiOptions',
|
|
38
|
+
default: ['message'],
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
name: 'Сообщение',
|
|
42
|
+
value: 'message',
|
|
43
|
+
description: 'Текстовое сообщение от пользователя',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Документ',
|
|
47
|
+
value: 'document',
|
|
48
|
+
description: 'Пользователь отправил файл',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'Фото',
|
|
52
|
+
value: 'photo',
|
|
53
|
+
description: 'Пользователь отправил изображение',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Callback (инлайн-кнопка)',
|
|
57
|
+
value: 'callback_query',
|
|
58
|
+
description: 'Пользователь нажал инлайн-кнопку',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
description: 'Типы событий для обработки',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
this.webhookMethods = {
|
|
66
|
+
default: {
|
|
67
|
+
async checkExists() {
|
|
68
|
+
const credentials = await this.getCredentials('n8nFrontApi');
|
|
69
|
+
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
70
|
+
try {
|
|
71
|
+
const response = await this.helpers.httpRequest({
|
|
72
|
+
method: 'GET',
|
|
73
|
+
url: `${credentials.baseUrl}/api/bot/${credentials.botToken}/getWebhookInfo`,
|
|
74
|
+
});
|
|
75
|
+
return response?.result?.url === webhookUrl;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async create() {
|
|
82
|
+
const credentials = await this.getCredentials('n8nFrontApi');
|
|
83
|
+
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
84
|
+
await this.helpers.httpRequest({
|
|
85
|
+
method: 'POST',
|
|
86
|
+
url: `${credentials.baseUrl}/api/bot/${credentials.botToken}/setWebhook`,
|
|
87
|
+
body: { url: webhookUrl },
|
|
88
|
+
headers: { 'Content-Type': 'application/json' },
|
|
89
|
+
});
|
|
90
|
+
return true;
|
|
91
|
+
},
|
|
92
|
+
async delete() {
|
|
93
|
+
const credentials = await this.getCredentials('n8nFrontApi');
|
|
94
|
+
try {
|
|
95
|
+
await this.helpers.httpRequest({
|
|
96
|
+
method: 'POST',
|
|
97
|
+
url: `${credentials.baseUrl}/api/bot/${credentials.botToken}/deleteWebhook`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Ignore errors on cleanup
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async webhook() {
|
|
109
|
+
const body = this.getBodyData();
|
|
110
|
+
const events = this.getNodeParameter('events', []);
|
|
111
|
+
// Handle callback_query
|
|
112
|
+
if (body.callback_query) {
|
|
113
|
+
if (!events.includes('callback_query')) {
|
|
114
|
+
return { noWebhookResponse: true };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
workflowData: [this.helpers.returnJsonArray(body)],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// Handle message
|
|
121
|
+
if (body.message) {
|
|
122
|
+
const msg = body.message;
|
|
123
|
+
const hasDocument = !!msg.document;
|
|
124
|
+
const hasPhoto = msg.photo && msg.photo.length > 0;
|
|
125
|
+
const isText = !hasDocument && !hasPhoto;
|
|
126
|
+
if (isText && !events.includes('message')) {
|
|
127
|
+
return { noWebhookResponse: true };
|
|
128
|
+
}
|
|
129
|
+
if (hasDocument && !events.includes('document')) {
|
|
130
|
+
return { noWebhookResponse: true };
|
|
131
|
+
}
|
|
132
|
+
if (hasPhoto && !events.includes('photo')) {
|
|
133
|
+
return { noWebhookResponse: true };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
workflowData: [this.helpers.returnJsonArray(body)],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.N8nFrontTrigger = N8nFrontTrigger;
|
|
142
|
+
//# sourceMappingURL=N8nFrontTrigger.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nFrontTrigger.node.js","sourceRoot":"","sources":["../../../nodes/N8nFront/N8nFrontTrigger.node.ts"],"names":[],"mappings":";;;AAQA,MAAa,eAAe;IAA5B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,kBAAkB;YAC/B,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,CAAC,SAAS,CAAC;YAClB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,0BAA0B;YACpC,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE;gBACT,IAAI,EAAE,kBAAkB;aACxB;YACD,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,CAAC,MAAM,CAAQ;YACxB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,aAAa;oBACnB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,QAAQ,EAAE;gBACT;oBACC,IA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 0 1-4 4H28l-8 8v-8h-4a4 4 0 0 1-4-4V20z" fill="white"/>
|
|
4
|
+
<circle cx="26" cy="28" r="2.5" fill="#6366f1"/>
|
|
5
|
+
<circle cx="32" cy="28" r="2.5" fill="#6366f1"/>
|
|
6
|
+
<circle cx="38" cy="28" r="2.5" fill="#6366f1"/>
|
|
7
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-n8nfront",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "n8n community nodes for N8nFront chat platform — Telegram-compatible Bot API",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "ITSS"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/nodes/N8nFront/N8nFront.node.js",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"n8n-community-node-package",
|
|
12
|
+
"n8n",
|
|
13
|
+
"n8nfront",
|
|
14
|
+
"chat",
|
|
15
|
+
"bot",
|
|
16
|
+
"telegram-compatible"
|
|
17
|
+
],
|
|
18
|
+
"n8n": {
|
|
19
|
+
"n8nNodesApiVersion": 1,
|
|
20
|
+
"credentials": [
|
|
21
|
+
"dist/credentials/N8nFrontApi.credentials.js"
|
|
22
|
+
],
|
|
23
|
+
"nodes": [
|
|
24
|
+
"dist/nodes/N8nFront/N8nFront.node.js",
|
|
25
|
+
"dist/nodes/N8nFront/N8nFrontTrigger.node.js"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"dev": "tsc --watch",
|
|
31
|
+
"postbuild": "cp nodes/N8nFront/n8nfront.svg dist/nodes/N8nFront/",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"n8n-workflow": "^1.0.0",
|
|
36
|
+
"typescript": "~5.4.0",
|
|
37
|
+
"@types/node": "^20.0.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"n8n-workflow": "*"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
]
|
|
45
|
+
}
|