n8n-nodes-waappa 0.1.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/LICENSE.md +19 -0
- package/README.md +56 -0
- package/dist/credentials/WaappaApi.credentials.d.ts +8 -0
- package/dist/credentials/WaappaApi.credentials.js +33 -0
- package/dist/credentials/WaappaApi.credentials.js.map +1 -0
- package/dist/credentials/waappa.svg +366 -0
- package/dist/icons/github.dark.svg +3 -0
- package/dist/icons/github.svg +3 -0
- package/dist/nodes/Waappa/GenericFunctions.d.ts +2 -0
- package/dist/nodes/Waappa/GenericFunctions.js +23 -0
- package/dist/nodes/Waappa/GenericFunctions.js.map +1 -0
- package/dist/nodes/Waappa/Waappa.node.d.ts +5 -0
- package/dist/nodes/Waappa/Waappa.node.js +846 -0
- package/dist/nodes/Waappa/Waappa.node.js.map +1 -0
- package/dist/nodes/Waappa/WaappaTrigger.node.d.ts +5 -0
- package/dist/nodes/Waappa/WaappaTrigger.node.js +140 -0
- package/dist/nodes/Waappa/WaappaTrigger.node.js.map +1 -0
- package/dist/nodes/Waappa/waappa.svg +366 -0
- package/dist/package.json +54 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,846 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Waappa = void 0;
|
|
4
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
5
|
+
function parseCommaList(value) {
|
|
6
|
+
return value
|
|
7
|
+
.split(',')
|
|
8
|
+
.map((x) => x.trim())
|
|
9
|
+
.filter(Boolean);
|
|
10
|
+
}
|
|
11
|
+
class Waappa {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.description = {
|
|
14
|
+
displayName: 'Waappa',
|
|
15
|
+
name: 'waappa',
|
|
16
|
+
icon: 'file:waappa.svg',
|
|
17
|
+
group: ['transform'],
|
|
18
|
+
version: 1,
|
|
19
|
+
description: 'Waappa WhatsApp API',
|
|
20
|
+
defaults: {
|
|
21
|
+
name: 'Waappa',
|
|
22
|
+
},
|
|
23
|
+
usableAsTool: true,
|
|
24
|
+
inputs: ['main'],
|
|
25
|
+
outputs: ['main'],
|
|
26
|
+
credentials: [{ name: 'waappaApi', required: true }],
|
|
27
|
+
properties: [
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Resource',
|
|
30
|
+
name: 'resource',
|
|
31
|
+
type: 'options',
|
|
32
|
+
options: [
|
|
33
|
+
{ name: 'Messages', value: 'messages' },
|
|
34
|
+
{ name: 'Media', value: 'media' },
|
|
35
|
+
{ name: 'Groups', value: 'groups' },
|
|
36
|
+
{ name: 'Contacts', value: 'contacts' },
|
|
37
|
+
],
|
|
38
|
+
default: 'messages',
|
|
39
|
+
noDataExpression: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Operation',
|
|
43
|
+
name: 'operation',
|
|
44
|
+
type: 'options',
|
|
45
|
+
displayOptions: { show: { resource: ['messages'] } },
|
|
46
|
+
options: [
|
|
47
|
+
{
|
|
48
|
+
name: 'Delete Message',
|
|
49
|
+
value: 'deleteMessage',
|
|
50
|
+
action: 'Delete a message',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'Edit Message',
|
|
54
|
+
value: 'editMessage',
|
|
55
|
+
action: 'Edit a message',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'Send Audio',
|
|
59
|
+
value: 'sendAudio',
|
|
60
|
+
action: 'Send an audio file',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'Send Contact',
|
|
64
|
+
value: 'sendContactCard',
|
|
65
|
+
action: 'Send a contact card',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'Send Document',
|
|
69
|
+
value: 'sendDocument',
|
|
70
|
+
action: 'Send a document',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Send Image',
|
|
74
|
+
value: 'sendImage',
|
|
75
|
+
action: 'Send an image',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Send Location',
|
|
79
|
+
value: 'sendLocation',
|
|
80
|
+
action: 'Send a location',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'Send Poll',
|
|
84
|
+
value: 'sendPoll',
|
|
85
|
+
action: 'Send a poll',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'Send Reply',
|
|
89
|
+
value: 'sendReplyTo',
|
|
90
|
+
action: 'Send a reply',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Send Sticker',
|
|
94
|
+
value: 'sendSticker',
|
|
95
|
+
action: 'Send a sticker',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'Send Text',
|
|
99
|
+
value: 'sendText',
|
|
100
|
+
action: 'Send a text message',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'Send Video',
|
|
104
|
+
value: 'sendVideo',
|
|
105
|
+
action: 'Send a video',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'Send View Once',
|
|
109
|
+
value: 'sendViewOnce',
|
|
110
|
+
action: 'Send a view once message',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'Send with Mentions',
|
|
114
|
+
value: 'sendMentions',
|
|
115
|
+
action: 'Send a message with mentions',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
default: 'sendText',
|
|
119
|
+
noDataExpression: true,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
displayName: 'To (JID/Phone)',
|
|
123
|
+
name: 'to',
|
|
124
|
+
type: 'string',
|
|
125
|
+
default: '',
|
|
126
|
+
required: true,
|
|
127
|
+
placeholder: 'e.g. 1234567890 or 1234567890@s.whatsapp.net',
|
|
128
|
+
description: 'Recipient phone number or JID',
|
|
129
|
+
displayOptions: {
|
|
130
|
+
show: {
|
|
131
|
+
resource: ['messages'],
|
|
132
|
+
operation: [
|
|
133
|
+
'sendText',
|
|
134
|
+
'sendImage',
|
|
135
|
+
'sendVideo',
|
|
136
|
+
'sendDocument',
|
|
137
|
+
'sendAudio',
|
|
138
|
+
'sendSticker',
|
|
139
|
+
'sendContactCard',
|
|
140
|
+
'sendLocation',
|
|
141
|
+
'sendPoll',
|
|
142
|
+
'sendReplyTo',
|
|
143
|
+
'sendMentions',
|
|
144
|
+
'sendViewOnce',
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
displayName: 'Message',
|
|
151
|
+
name: 'text',
|
|
152
|
+
type: 'string',
|
|
153
|
+
typeOptions: { rows: 2 },
|
|
154
|
+
default: '',
|
|
155
|
+
required: true,
|
|
156
|
+
description: 'Content of the message',
|
|
157
|
+
displayOptions: {
|
|
158
|
+
show: {
|
|
159
|
+
resource: ['messages'],
|
|
160
|
+
operation: ['sendText', 'sendImage', 'sendVideo', 'sendDocument', 'sendReplyTo', 'sendMentions', 'sendLocation'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Image URL',
|
|
166
|
+
name: 'imageUrl',
|
|
167
|
+
type: 'string',
|
|
168
|
+
default: '',
|
|
169
|
+
required: true,
|
|
170
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendImage'] } },
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
displayName: 'Video URL',
|
|
174
|
+
name: 'videoUrl',
|
|
175
|
+
type: 'string',
|
|
176
|
+
default: '',
|
|
177
|
+
required: true,
|
|
178
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendVideo'] } },
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
displayName: 'Audio URL',
|
|
182
|
+
name: 'audioUrl',
|
|
183
|
+
type: 'string',
|
|
184
|
+
default: '',
|
|
185
|
+
required: true,
|
|
186
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendAudio'] } },
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
displayName: 'Document URL',
|
|
190
|
+
name: 'documentUrl',
|
|
191
|
+
type: 'string',
|
|
192
|
+
default: '',
|
|
193
|
+
required: true,
|
|
194
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendDocument'] } },
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
displayName: 'File Name',
|
|
198
|
+
name: 'fileName',
|
|
199
|
+
type: 'string',
|
|
200
|
+
default: '',
|
|
201
|
+
required: true,
|
|
202
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendDocument'] } },
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
displayName: 'Sticker URL (.webp)',
|
|
206
|
+
name: 'stickerUrl',
|
|
207
|
+
type: 'string',
|
|
208
|
+
default: '',
|
|
209
|
+
required: true,
|
|
210
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendSticker'] } },
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Contact Name',
|
|
214
|
+
name: 'contactName',
|
|
215
|
+
type: 'string',
|
|
216
|
+
default: '',
|
|
217
|
+
required: true,
|
|
218
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendContactCard'] } },
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
displayName: 'Contact Phone',
|
|
222
|
+
name: 'contactPhone',
|
|
223
|
+
type: 'string',
|
|
224
|
+
default: '',
|
|
225
|
+
required: true,
|
|
226
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendContactCard'] } },
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
displayName: 'Latitude',
|
|
230
|
+
name: 'latitude',
|
|
231
|
+
type: 'number',
|
|
232
|
+
default: 0,
|
|
233
|
+
required: true,
|
|
234
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendLocation'] } },
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
displayName: 'Longitude',
|
|
238
|
+
name: 'longitude',
|
|
239
|
+
type: 'number',
|
|
240
|
+
default: 0,
|
|
241
|
+
required: true,
|
|
242
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendLocation'] } },
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Location Name',
|
|
246
|
+
name: 'locationName',
|
|
247
|
+
type: 'string',
|
|
248
|
+
default: '',
|
|
249
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendLocation'] } },
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
displayName: 'Location Address',
|
|
253
|
+
name: 'locationAddress',
|
|
254
|
+
type: 'string',
|
|
255
|
+
default: '',
|
|
256
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendLocation'] } },
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
displayName: 'Poll Question',
|
|
260
|
+
name: 'pollQuestion',
|
|
261
|
+
type: 'string',
|
|
262
|
+
default: '',
|
|
263
|
+
required: true,
|
|
264
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendPoll'] } },
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
displayName: 'Poll Options (Comma separated)',
|
|
268
|
+
name: 'pollOptions',
|
|
269
|
+
type: 'string',
|
|
270
|
+
default: '',
|
|
271
|
+
required: true,
|
|
272
|
+
placeholder: 'Blue, Green, Red',
|
|
273
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendPoll'] } },
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
displayName: 'Multi Select',
|
|
277
|
+
name: 'multiSelect',
|
|
278
|
+
type: 'boolean',
|
|
279
|
+
default: false,
|
|
280
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendPoll'] } },
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
displayName: 'Reply To Message ID',
|
|
284
|
+
name: 'replyTo',
|
|
285
|
+
type: 'string',
|
|
286
|
+
default: '',
|
|
287
|
+
required: true,
|
|
288
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendReplyTo'] } },
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
displayName: 'Mentions (Comma separated JIDs)',
|
|
292
|
+
name: 'mentions',
|
|
293
|
+
type: 'string',
|
|
294
|
+
default: '',
|
|
295
|
+
placeholder: '1234567890@s.whatsapp.net, 1111111111@s.whatsapp.net',
|
|
296
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendMentions'] } },
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
displayName: 'View Once',
|
|
300
|
+
name: 'viewOnce',
|
|
301
|
+
type: 'boolean',
|
|
302
|
+
default: true,
|
|
303
|
+
required: true,
|
|
304
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendViewOnce'] } },
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
displayName: 'View Once Type',
|
|
308
|
+
name: 'viewOnceType',
|
|
309
|
+
type: 'options',
|
|
310
|
+
options: [
|
|
311
|
+
{ name: 'Image', value: 'imageUrl' },
|
|
312
|
+
{ name: 'Video', value: 'videoUrl' },
|
|
313
|
+
{ name: 'Audio', value: 'audioUrl' },
|
|
314
|
+
],
|
|
315
|
+
default: 'imageUrl',
|
|
316
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendViewOnce'] } },
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
displayName: 'View Once Media URL',
|
|
320
|
+
name: 'viewOnceUrl',
|
|
321
|
+
type: 'string',
|
|
322
|
+
default: '',
|
|
323
|
+
required: true,
|
|
324
|
+
displayOptions: { show: { resource: ['messages'], operation: ['sendViewOnce'] } },
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
displayName: 'Message ID',
|
|
328
|
+
name: 'msgId',
|
|
329
|
+
type: 'string',
|
|
330
|
+
default: '',
|
|
331
|
+
required: true,
|
|
332
|
+
displayOptions: {
|
|
333
|
+
show: {
|
|
334
|
+
resource: ['messages'],
|
|
335
|
+
operation: ['editMessage', 'deleteMessage'],
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
displayName: 'New Text',
|
|
341
|
+
name: 'newText',
|
|
342
|
+
type: 'string',
|
|
343
|
+
typeOptions: { rows: 2 },
|
|
344
|
+
default: '',
|
|
345
|
+
required: true,
|
|
346
|
+
displayOptions: { show: { resource: ['messages'], operation: ['editMessage'] } },
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
displayName: 'Operation',
|
|
350
|
+
name: 'operation',
|
|
351
|
+
type: 'options',
|
|
352
|
+
displayOptions: { show: { resource: ['media'] } },
|
|
353
|
+
options: [
|
|
354
|
+
{ name: 'Upload', value: 'upload' },
|
|
355
|
+
{ name: 'Decrypt', value: 'decrypt' },
|
|
356
|
+
],
|
|
357
|
+
default: 'upload',
|
|
358
|
+
noDataExpression: true,
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
displayName: 'Upload Mode',
|
|
362
|
+
name: 'uploadMode',
|
|
363
|
+
type: 'options',
|
|
364
|
+
options: [
|
|
365
|
+
{ name: 'Raw Binary (Recommended)', value: 'binary' },
|
|
366
|
+
{ name: 'JSON (Base64)', value: 'base64' },
|
|
367
|
+
],
|
|
368
|
+
default: 'binary',
|
|
369
|
+
displayOptions: { show: { resource: ['media'], operation: ['upload'] } },
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
displayName: 'Binary Property',
|
|
373
|
+
name: 'binaryPropertyName',
|
|
374
|
+
type: 'string',
|
|
375
|
+
default: 'data',
|
|
376
|
+
required: true,
|
|
377
|
+
description: 'Name of the binary property from previous node',
|
|
378
|
+
displayOptions: { show: { resource: ['media'], operation: ['upload'], uploadMode: ['binary'] } },
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
displayName: 'Base64',
|
|
382
|
+
name: 'base64',
|
|
383
|
+
type: 'string',
|
|
384
|
+
default: '',
|
|
385
|
+
required: true,
|
|
386
|
+
description: 'Base64 encoded file content',
|
|
387
|
+
displayOptions: { show: { resource: ['media'], operation: ['upload'], uploadMode: ['base64'] } },
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
displayName: 'Message ID',
|
|
391
|
+
name: 'decryptMsgId',
|
|
392
|
+
type: 'string',
|
|
393
|
+
default: '',
|
|
394
|
+
required: true,
|
|
395
|
+
displayOptions: { show: { resource: ['media'], operation: ['decrypt'] } },
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
displayName: 'Media URL (Encrypted)',
|
|
399
|
+
name: 'decryptUrl',
|
|
400
|
+
type: 'string',
|
|
401
|
+
default: '',
|
|
402
|
+
required: true,
|
|
403
|
+
displayOptions: { show: { resource: ['media'], operation: ['decrypt'] } },
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
displayName: 'MIME Type',
|
|
407
|
+
name: 'decryptMimeType',
|
|
408
|
+
type: 'string',
|
|
409
|
+
default: 'image/jpeg',
|
|
410
|
+
required: true,
|
|
411
|
+
displayOptions: { show: { resource: ['media'], operation: ['decrypt'] } },
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
displayName: 'Media Key',
|
|
415
|
+
name: 'decryptMediaKey',
|
|
416
|
+
type: 'string',
|
|
417
|
+
default: '',
|
|
418
|
+
required: true,
|
|
419
|
+
displayOptions: { show: { resource: ['media'], operation: ['decrypt'] } },
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
displayName: 'Message Type Key',
|
|
423
|
+
name: 'decryptMessageTypeKey',
|
|
424
|
+
type: 'options',
|
|
425
|
+
options: [
|
|
426
|
+
{ name: 'Image Message', value: 'imageMessage' },
|
|
427
|
+
{ name: 'Video Message', value: 'videoMessage' },
|
|
428
|
+
{ name: 'Audio Message', value: 'audioMessage' },
|
|
429
|
+
{ name: 'Document Message', value: 'documentMessage' },
|
|
430
|
+
],
|
|
431
|
+
default: 'imageMessage',
|
|
432
|
+
displayOptions: { show: { resource: ['media'], operation: ['decrypt'] } },
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
displayName: 'Operation',
|
|
436
|
+
name: 'operation',
|
|
437
|
+
type: 'options',
|
|
438
|
+
displayOptions: { show: { resource: ['groups'] } },
|
|
439
|
+
options: [
|
|
440
|
+
{ name: 'Create', value: 'createGroup' },
|
|
441
|
+
{ name: 'Update Settings', value: 'updateGroup' },
|
|
442
|
+
{ name: 'Get All', value: 'getAllGroups' },
|
|
443
|
+
{ name: 'Get Metadata', value: 'getGroupMetadata' },
|
|
444
|
+
{ name: 'Add Participants', value: 'addParticipants' },
|
|
445
|
+
{ name: 'Remove Participants', value: 'removeParticipants' },
|
|
446
|
+
],
|
|
447
|
+
default: 'getAllGroups',
|
|
448
|
+
noDataExpression: true,
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
displayName: 'Group Name',
|
|
452
|
+
name: 'groupName',
|
|
453
|
+
type: 'string',
|
|
454
|
+
default: '',
|
|
455
|
+
required: true,
|
|
456
|
+
displayOptions: { show: { resource: ['groups'], operation: ['createGroup'] } },
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
displayName: 'Group JID',
|
|
460
|
+
name: 'groupJid',
|
|
461
|
+
type: 'string',
|
|
462
|
+
default: '',
|
|
463
|
+
required: true,
|
|
464
|
+
displayOptions: {
|
|
465
|
+
show: {
|
|
466
|
+
resource: ['groups'],
|
|
467
|
+
operation: ['updateGroup', 'getGroupMetadata', 'addParticipants', 'removeParticipants'],
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
displayName: 'Subject',
|
|
473
|
+
name: 'groupSubject',
|
|
474
|
+
type: 'string',
|
|
475
|
+
default: '',
|
|
476
|
+
description: 'New name/title for the group',
|
|
477
|
+
displayOptions: { show: { resource: ['groups'], operation: ['updateGroup'] } },
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
displayName: 'Description',
|
|
481
|
+
name: 'groupDescription',
|
|
482
|
+
type: 'string',
|
|
483
|
+
default: '',
|
|
484
|
+
displayOptions: { show: { resource: ['groups'], operation: ['updateGroup'] } },
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
displayName: 'Participants Input Mode',
|
|
488
|
+
name: 'participantsMode',
|
|
489
|
+
type: 'options',
|
|
490
|
+
options: [
|
|
491
|
+
{ name: 'Comma separated', value: 'comma' },
|
|
492
|
+
{ name: 'List', value: 'list' },
|
|
493
|
+
],
|
|
494
|
+
default: 'comma',
|
|
495
|
+
displayOptions: {
|
|
496
|
+
show: {
|
|
497
|
+
resource: ['groups'],
|
|
498
|
+
operation: ['createGroup', 'addParticipants', 'removeParticipants'],
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
displayName: 'Participants (Comma separated)',
|
|
504
|
+
name: 'participantsComma',
|
|
505
|
+
type: 'string',
|
|
506
|
+
default: '',
|
|
507
|
+
required: true,
|
|
508
|
+
placeholder: '123@s.whatsapp.net, 456@s.whatsapp.net',
|
|
509
|
+
displayOptions: {
|
|
510
|
+
show: {
|
|
511
|
+
resource: ['groups'],
|
|
512
|
+
operation: ['createGroup', 'addParticipants', 'removeParticipants'],
|
|
513
|
+
participantsMode: ['comma'],
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
displayName: 'Participants (List)',
|
|
519
|
+
name: 'participantsList',
|
|
520
|
+
type: 'fixedCollection',
|
|
521
|
+
typeOptions: {
|
|
522
|
+
multipleValues: true,
|
|
523
|
+
},
|
|
524
|
+
default: {},
|
|
525
|
+
displayOptions: {
|
|
526
|
+
show: {
|
|
527
|
+
resource: ['groups'],
|
|
528
|
+
operation: ['createGroup', 'addParticipants', 'removeParticipants'],
|
|
529
|
+
participantsMode: ['list'],
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
options: [
|
|
533
|
+
{
|
|
534
|
+
name: 'participants',
|
|
535
|
+
displayName: 'Participants',
|
|
536
|
+
values: [
|
|
537
|
+
{
|
|
538
|
+
displayName: 'Participant JID',
|
|
539
|
+
name: 'jid',
|
|
540
|
+
type: 'string',
|
|
541
|
+
default: '',
|
|
542
|
+
placeholder: '1234567890@s.whatsapp.net',
|
|
543
|
+
},
|
|
544
|
+
],
|
|
545
|
+
},
|
|
546
|
+
],
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
displayName: 'Operation',
|
|
550
|
+
name: 'operation',
|
|
551
|
+
type: 'options',
|
|
552
|
+
displayOptions: { show: { resource: ['contacts'] } },
|
|
553
|
+
options: [
|
|
554
|
+
{ name: 'Get All', value: 'getAllContacts' },
|
|
555
|
+
{ name: 'Get Info', value: 'getContact' },
|
|
556
|
+
{ name: 'Block', value: 'blockContact' },
|
|
557
|
+
],
|
|
558
|
+
default: 'getAllContacts',
|
|
559
|
+
noDataExpression: true,
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
displayName: 'Contact Phone Number',
|
|
563
|
+
name: 'contactPhoneNumber',
|
|
564
|
+
type: 'string',
|
|
565
|
+
default: '',
|
|
566
|
+
required: true,
|
|
567
|
+
description: 'The JID of the contact (e.g. 1234567890)',
|
|
568
|
+
displayOptions: {
|
|
569
|
+
show: {
|
|
570
|
+
resource: ['contacts'],
|
|
571
|
+
operation: ['getContact', 'blockContact'],
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
displayName: 'Options',
|
|
577
|
+
name: 'options',
|
|
578
|
+
type: 'collection',
|
|
579
|
+
placeholder: 'Add Option',
|
|
580
|
+
default: {},
|
|
581
|
+
options: [
|
|
582
|
+
{
|
|
583
|
+
displayName: 'Delay (ms)',
|
|
584
|
+
name: 'wait',
|
|
585
|
+
type: 'number',
|
|
586
|
+
default: 1000,
|
|
587
|
+
description: 'Time to wait in milliseconds before execution',
|
|
588
|
+
},
|
|
589
|
+
],
|
|
590
|
+
},
|
|
591
|
+
],
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
async execute() {
|
|
595
|
+
const items = this.getInputData();
|
|
596
|
+
const returnData = [];
|
|
597
|
+
for (let i = 0; i < items.length; i++) {
|
|
598
|
+
const resource = this.getNodeParameter('resource', i);
|
|
599
|
+
const operation = this.getNodeParameter('operation', i);
|
|
600
|
+
const options = this.getNodeParameter('options', i, {});
|
|
601
|
+
if (options.wait) {
|
|
602
|
+
await new Promise((resolve) => {
|
|
603
|
+
global.setTimeout(resolve, options.wait);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
let response;
|
|
607
|
+
if (resource === 'messages') {
|
|
608
|
+
if (operation === 'sendText') {
|
|
609
|
+
const to = this.getNodeParameter('to', i);
|
|
610
|
+
const text = this.getNodeParameter('text', i);
|
|
611
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, text });
|
|
612
|
+
}
|
|
613
|
+
if (operation === 'sendImage') {
|
|
614
|
+
const to = this.getNodeParameter('to', i);
|
|
615
|
+
const text = this.getNodeParameter('text', i);
|
|
616
|
+
const imageUrl = this.getNodeParameter('imageUrl', i);
|
|
617
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, text, imageUrl });
|
|
618
|
+
}
|
|
619
|
+
if (operation === 'sendVideo') {
|
|
620
|
+
const to = this.getNodeParameter('to', i);
|
|
621
|
+
const text = this.getNodeParameter('text', i);
|
|
622
|
+
const videoUrl = this.getNodeParameter('videoUrl', i);
|
|
623
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, text, videoUrl });
|
|
624
|
+
}
|
|
625
|
+
if (operation === 'sendAudio') {
|
|
626
|
+
const to = this.getNodeParameter('to', i);
|
|
627
|
+
const audioUrl = this.getNodeParameter('audioUrl', i);
|
|
628
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, audioUrl });
|
|
629
|
+
}
|
|
630
|
+
if (operation === 'sendDocument') {
|
|
631
|
+
const to = this.getNodeParameter('to', i);
|
|
632
|
+
const text = this.getNodeParameter('text', i);
|
|
633
|
+
const documentUrl = this.getNodeParameter('documentUrl', i);
|
|
634
|
+
const fileName = this.getNodeParameter('fileName', i);
|
|
635
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', {
|
|
636
|
+
to,
|
|
637
|
+
text,
|
|
638
|
+
documentUrl,
|
|
639
|
+
fileName,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
if (operation === 'sendSticker') {
|
|
643
|
+
const to = this.getNodeParameter('to', i);
|
|
644
|
+
const stickerUrl = this.getNodeParameter('stickerUrl', i);
|
|
645
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, stickerUrl });
|
|
646
|
+
}
|
|
647
|
+
if (operation === 'sendContactCard') {
|
|
648
|
+
const to = this.getNodeParameter('to', i);
|
|
649
|
+
const contactName = this.getNodeParameter('contactName', i);
|
|
650
|
+
const contactPhone = this.getNodeParameter('contactPhone', i);
|
|
651
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', {
|
|
652
|
+
to,
|
|
653
|
+
contact: {
|
|
654
|
+
name: contactName,
|
|
655
|
+
phone: contactPhone,
|
|
656
|
+
},
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
if (operation === 'sendLocation') {
|
|
660
|
+
const to = this.getNodeParameter('to', i);
|
|
661
|
+
const text = this.getNodeParameter('text', i);
|
|
662
|
+
const latitude = this.getNodeParameter('latitude', i);
|
|
663
|
+
const longitude = this.getNodeParameter('longitude', i);
|
|
664
|
+
const locationName = this.getNodeParameter('locationName', i);
|
|
665
|
+
const locationAddress = this.getNodeParameter('locationAddress', i);
|
|
666
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', {
|
|
667
|
+
to,
|
|
668
|
+
text,
|
|
669
|
+
location: {
|
|
670
|
+
latitude,
|
|
671
|
+
longitude,
|
|
672
|
+
name: locationName || undefined,
|
|
673
|
+
address: locationAddress || undefined,
|
|
674
|
+
},
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
if (operation === 'sendPoll') {
|
|
678
|
+
const to = this.getNodeParameter('to', i);
|
|
679
|
+
const pollQuestion = this.getNodeParameter('pollQuestion', i);
|
|
680
|
+
const pollOptions = parseCommaList(this.getNodeParameter('pollOptions', i));
|
|
681
|
+
const multiSelect = this.getNodeParameter('multiSelect', i);
|
|
682
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', {
|
|
683
|
+
to,
|
|
684
|
+
poll: {
|
|
685
|
+
question: pollQuestion,
|
|
686
|
+
options: pollOptions,
|
|
687
|
+
multiSelect,
|
|
688
|
+
},
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
if (operation === 'sendReplyTo') {
|
|
692
|
+
const to = this.getNodeParameter('to', i);
|
|
693
|
+
const text = this.getNodeParameter('text', i);
|
|
694
|
+
const replyTo = this.getNodeParameter('replyTo', i);
|
|
695
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, text, replyTo });
|
|
696
|
+
}
|
|
697
|
+
if (operation === 'sendMentions') {
|
|
698
|
+
const to = this.getNodeParameter('to', i);
|
|
699
|
+
const text = this.getNodeParameter('text', i);
|
|
700
|
+
const mentionsRaw = this.getNodeParameter('mentions', i);
|
|
701
|
+
const mentions = mentionsRaw ? parseCommaList(mentionsRaw) : [];
|
|
702
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', { to, text, mentions });
|
|
703
|
+
}
|
|
704
|
+
if (operation === 'sendViewOnce') {
|
|
705
|
+
const to = this.getNodeParameter('to', i);
|
|
706
|
+
const viewOnce = this.getNodeParameter('viewOnce', i);
|
|
707
|
+
const viewOnceType = this.getNodeParameter('viewOnceType', i);
|
|
708
|
+
const viewOnceUrl = this.getNodeParameter('viewOnceUrl', i);
|
|
709
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/send-message', {
|
|
710
|
+
to,
|
|
711
|
+
viewOnce,
|
|
712
|
+
[viewOnceType]: viewOnceUrl,
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
if (operation === 'editMessage') {
|
|
716
|
+
const msgId = this.getNodeParameter('msgId', i);
|
|
717
|
+
const newText = this.getNodeParameter('newText', i);
|
|
718
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'PUT', `/ api / messages / ${msgId} `, {
|
|
719
|
+
text: newText,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
if (operation === 'deleteMessage') {
|
|
723
|
+
const msgId = this.getNodeParameter('msgId', i);
|
|
724
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'DELETE', `/ api / messages / ${msgId} `);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (resource === 'media') {
|
|
728
|
+
if (operation === 'upload') {
|
|
729
|
+
const uploadMode = this.getNodeParameter('uploadMode', i);
|
|
730
|
+
if (uploadMode === 'binary') {
|
|
731
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
732
|
+
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
733
|
+
response = await this.helpers.httpRequest({
|
|
734
|
+
method: 'POST',
|
|
735
|
+
url: `${(await this.getCredentials('waappaApi')).baseUrl} /api/upload`,
|
|
736
|
+
headers: {
|
|
737
|
+
Authorization: `Bearer ${(await this.getCredentials('waappaApi')).apiKey} `,
|
|
738
|
+
'Content-Type': binaryData.mimeType,
|
|
739
|
+
},
|
|
740
|
+
body: await this.helpers.getBinaryDataBuffer(i, binaryPropertyName),
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
if (uploadMode === 'base64') {
|
|
744
|
+
const base64 = this.getNodeParameter('base64', i);
|
|
745
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/upload', {
|
|
746
|
+
base64,
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (operation === 'decrypt') {
|
|
751
|
+
const decryptMsgId = this.getNodeParameter('decryptMsgId', i);
|
|
752
|
+
const decryptUrl = this.getNodeParameter('decryptUrl', i);
|
|
753
|
+
const decryptMimeType = this.getNodeParameter('decryptMimeType', i);
|
|
754
|
+
const decryptMediaKey = this.getNodeParameter('decryptMediaKey', i);
|
|
755
|
+
const decryptMessageTypeKey = this.getNodeParameter('decryptMessageTypeKey', i);
|
|
756
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/decrypt-media', {
|
|
757
|
+
data: {
|
|
758
|
+
messages: {
|
|
759
|
+
key: {
|
|
760
|
+
id: decryptMsgId,
|
|
761
|
+
},
|
|
762
|
+
message: {
|
|
763
|
+
[decryptMessageTypeKey]: {
|
|
764
|
+
url: decryptUrl,
|
|
765
|
+
mimetype: decryptMimeType,
|
|
766
|
+
mediaKey: decryptMediaKey,
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (resource === 'groups') {
|
|
775
|
+
if (operation === 'getAllGroups') {
|
|
776
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'GET', '/api/groups');
|
|
777
|
+
}
|
|
778
|
+
if (operation === 'getGroupMetadata') {
|
|
779
|
+
const groupJid = this.getNodeParameter('groupJid', i);
|
|
780
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'GET', `/ api / groups / ${groupJid}/metadata`);
|
|
781
|
+
}
|
|
782
|
+
const getParticipants = () => {
|
|
783
|
+
var _a;
|
|
784
|
+
const participantsMode = this.getNodeParameter('participantsMode', i);
|
|
785
|
+
if (participantsMode === 'comma') {
|
|
786
|
+
const participantsComma = this.getNodeParameter('participantsComma', i);
|
|
787
|
+
return parseCommaList(participantsComma);
|
|
788
|
+
}
|
|
789
|
+
const participantsList = this.getNodeParameter('participantsList', i);
|
|
790
|
+
const values = (_a = participantsList === null || participantsList === void 0 ? void 0 : participantsList.participants) !== null && _a !== void 0 ? _a : [];
|
|
791
|
+
return values.map((p) => p.jid).filter(Boolean);
|
|
792
|
+
};
|
|
793
|
+
if (operation === 'createGroup') {
|
|
794
|
+
const groupName = this.getNodeParameter('groupName', i);
|
|
795
|
+
const participants = getParticipants();
|
|
796
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', '/api/groups', {
|
|
797
|
+
name: groupName,
|
|
798
|
+
participants,
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
if (operation === 'updateGroup') {
|
|
802
|
+
const groupJid = this.getNodeParameter('groupJid', i);
|
|
803
|
+
const subject = this.getNodeParameter('groupSubject', i);
|
|
804
|
+
const description = this.getNodeParameter('groupDescription', i);
|
|
805
|
+
const body = {};
|
|
806
|
+
if (subject)
|
|
807
|
+
body.subject = subject;
|
|
808
|
+
if (description)
|
|
809
|
+
body.description = description;
|
|
810
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'PUT', `/api/groups/${groupJid}/settings`, body);
|
|
811
|
+
}
|
|
812
|
+
if (operation === 'addParticipants') {
|
|
813
|
+
const groupJid = this.getNodeParameter('groupJid', i);
|
|
814
|
+
const participants = getParticipants();
|
|
815
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', `/api/groups/${groupJid}/participants/add`, {
|
|
816
|
+
participants,
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
if (operation === 'removeParticipants') {
|
|
820
|
+
const groupJid = this.getNodeParameter('groupJid', i);
|
|
821
|
+
const participants = getParticipants();
|
|
822
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', `/api/groups/${groupJid}/participants/remove`, {
|
|
823
|
+
participants,
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
if (resource === 'contacts') {
|
|
828
|
+
if (operation === 'getAllContacts') {
|
|
829
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'GET', '/api/contacts');
|
|
830
|
+
}
|
|
831
|
+
if (operation === 'getContact') {
|
|
832
|
+
const contactPhoneNumber = this.getNodeParameter('contactPhoneNumber', i);
|
|
833
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'GET', `/api/contacts/${contactPhoneNumber}`);
|
|
834
|
+
}
|
|
835
|
+
if (operation === 'blockContact') {
|
|
836
|
+
const contactPhoneNumber = this.getNodeParameter('contactPhoneNumber', i);
|
|
837
|
+
response = await GenericFunctions_1.waappaApiRequest.call(this, 'POST', `/api/contacts/${contactPhoneNumber}/block`);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
returnData.push(response);
|
|
841
|
+
}
|
|
842
|
+
return [this.helpers.returnJsonArray(returnData)];
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
exports.Waappa = Waappa;
|
|
846
|
+
//# sourceMappingURL=Waappa.node.js.map
|