n8n-nodes-pilot-status 1.0.10 → 1.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.
@@ -44,9 +44,8 @@ class PilotStatus {
44
44
  url: '/groups',
45
45
  json: true,
46
46
  }));
47
- const groups = Array.isArray(response === null || response === void 0 ? void 0 : response.groups) ? response.groups : [];
48
- return groups.map((g) => ({
49
- name: g.name ? `${g.name} (${g.id})` : g.id,
47
+ return (response || []).map((g) => ({
48
+ name: g.subject,
50
49
  value: g.id,
51
50
  }));
52
51
  },
@@ -57,9 +56,8 @@ class PilotStatus {
57
56
  url: '/newsletters',
58
57
  json: true,
59
58
  }));
60
- const newsletters = Array.isArray(response === null || response === void 0 ? void 0 : response.newsletters) ? response.newsletters : [];
61
- return newsletters.map((n) => ({
62
- name: n.name ? `${n.name} (${n.id})` : n.id,
59
+ return (response || []).map((n) => ({
60
+ name: n.name,
63
61
  value: n.id,
64
62
  }));
65
63
  },
@@ -102,6 +100,9 @@ class PilotStatus {
102
100
  { name: 'Project', value: 'project' },
103
101
  { name: 'API Key', value: 'apiKey' },
104
102
  { name: 'Number', value: 'number' },
103
+ { name: 'Template', value: 'template' },
104
+ { name: 'Group', value: 'group' },
105
+ { name: 'Newsletter', value: 'newsletter' },
105
106
  { name: 'Analytics', value: 'analytics' },
106
107
  ],
107
108
  default: 'message',
@@ -123,7 +124,6 @@ class PilotStatus {
123
124
  action: 'Send a message',
124
125
  routing: {
125
126
  request: { method: 'POST', url: '/messages/send' },
126
- // ✅ preSend hook: monta o campo "variables" como objeto antes de enviar
127
127
  send: {
128
128
  preSend: [
129
129
  async function (requestOptions) {
@@ -167,7 +167,6 @@ class PilotStatus {
167
167
  try {
168
168
  const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
169
169
  if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
170
- // ✅ API exige que todos os valores sejam strings
171
170
  for (const [k, v] of Object.entries(parsed)) {
172
171
  variables[k] = String(v !== null && v !== void 0 ? v : '');
173
172
  }
@@ -180,11 +179,9 @@ class PilotStatus {
180
179
  else {
181
180
  const ui = this.getNodeParameter('variablesUi');
182
181
  for (const entry of (_a = ui === null || ui === void 0 ? void 0 : ui.values) !== null && _a !== void 0 ? _a : []) {
183
- // ✅ API exige que todos os valores sejam strings
184
182
  variables[entry.name] = String((_b = entry.value) !== null && _b !== void 0 ? _b : '');
185
183
  }
186
184
  }
187
- // Garante que o body é um objeto e injeta "variables" como objeto
188
185
  if (!requestOptions.body || typeof requestOptions.body !== 'object') {
189
186
  requestOptions.body = {};
190
187
  }
@@ -275,27 +272,25 @@ class PilotStatus {
275
272
  {
276
273
  displayName: 'Group ID',
277
274
  name: 'groupId',
278
- type: 'options',
279
- typeOptions: { loadOptionsMethod: 'getGroups' },
275
+ type: 'string',
280
276
  displayOptions: {
281
277
  show: { resource: ['message'], operation: ['send'], sendDestinationType: ['group'] },
282
278
  },
283
279
  default: '',
284
280
  required: true,
285
- description: 'JID do grupo (@g.us). Lista via GET /v1/groups; também pode usar expressão n8n.',
281
+ description: 'ID do grupo (@g.us)',
286
282
  routing: { send: { type: 'body', property: 'groupId' } },
287
283
  },
288
284
  {
289
285
  displayName: 'Newsletter ID',
290
286
  name: 'newsletterId',
291
- type: 'options',
292
- typeOptions: { loadOptionsMethod: 'getNewsletters' },
287
+ type: 'string',
293
288
  displayOptions: {
294
289
  show: { resource: ['message'], operation: ['send'], sendDestinationType: ['newsletter'] },
295
290
  },
296
291
  default: '',
297
292
  required: true,
298
- description: 'JID do canal (@newsletter). Lista via GET /v1/newsletters; também pode usar expressão n8n.',
293
+ description: 'ID do canal (@newsletter)',
299
294
  routing: { send: { type: 'body', property: 'newsletterId' } },
300
295
  },
301
296
  {
@@ -319,7 +314,6 @@ class PilotStatus {
319
314
  show: { resource: ['message'], operation: ['send'], variablesMode: ['json'] },
320
315
  },
321
316
  description: 'A JSON object containing key-value pairs for variables',
322
- // ✅ Sem routing aqui — o preSend cuida do envio como objeto
323
317
  },
324
318
  {
325
319
  displayName: 'Variables',
@@ -357,7 +351,6 @@ class PilotStatus {
357
351
  ],
358
352
  },
359
353
  ],
360
- // ✅ Sem routing aqui — o preSend cuida do envio como objeto
361
354
  },
362
355
  {
363
356
  displayName: 'Additional Fields',
@@ -381,6 +374,46 @@ class PilotStatus {
381
374
  default: '',
382
375
  description: 'Optional expiration limit for the message delivery (ISO8601)',
383
376
  },
377
+ {
378
+ displayName: 'Labels',
379
+ name: 'labels',
380
+ type: 'string',
381
+ default: '',
382
+ description: 'Comma-separated label names (processed asynchronously)',
383
+ },
384
+ {
385
+ displayName: 'AI Rewrite Enabled',
386
+ name: 'aiRewriteEnabled',
387
+ type: 'boolean',
388
+ default: false,
389
+ description: 'Whether to enable AI rewriting for marketing messages',
390
+ },
391
+ {
392
+ displayName: 'Media URL',
393
+ name: 'media',
394
+ type: 'string',
395
+ default: '',
396
+ description: 'URL of the media to attach (image, video, or document)',
397
+ },
398
+ {
399
+ displayName: 'Media Type',
400
+ name: 'mediaType',
401
+ type: 'options',
402
+ options: [
403
+ { name: 'Image', value: 'image' },
404
+ { name: 'Video', value: 'video' },
405
+ { name: 'Document', value: 'document' },
406
+ ],
407
+ default: 'image',
408
+ description: 'Type of media being attached',
409
+ },
410
+ {
411
+ displayName: 'Buttons (JSON)',
412
+ name: 'buttons',
413
+ type: 'json',
414
+ default: '',
415
+ description: 'JSON array of button objects (reply, url, call, copy)',
416
+ },
384
417
  ],
385
418
  },
386
419
  // Hidden fields para deliverAt / deliverUntil normalizados
@@ -400,6 +433,46 @@ class PilotStatus {
400
433
  default: '={{ $parameter.additionalFields?.deliverUntil ? new Date($parameter.additionalFields.deliverUntil).toISOString() : undefined }}',
401
434
  routing: { send: { type: 'body', property: 'deliverUntil' } },
402
435
  },
436
+ {
437
+ displayName: 'Labels',
438
+ name: 'labelsNormalized',
439
+ type: 'hidden',
440
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
441
+ default: '={{ $parameter.additionalFields?.labels ? $parameter.additionalFields.labels.split(",").map(l => l.trim()).filter(l => l) : undefined }}',
442
+ routing: { send: { type: 'body', property: 'labels' } },
443
+ },
444
+ {
445
+ displayName: 'Marketing Options',
446
+ name: 'marketingOptionsNormalized',
447
+ type: 'hidden',
448
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
449
+ default: '={{ $parameter.additionalFields?.aiRewriteEnabled ? { aiRewriteEnabled: true } : undefined }}',
450
+ routing: { send: { type: 'body', property: 'marketingOptions' } },
451
+ },
452
+ {
453
+ displayName: 'Media URL',
454
+ name: 'mediaNormalized',
455
+ type: 'hidden',
456
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
457
+ default: '={{ $parameter.additionalFields?.media || undefined }}',
458
+ routing: { send: { type: 'body', property: 'media' } },
459
+ },
460
+ {
461
+ displayName: 'Media Type',
462
+ name: 'mediaTypeNormalized',
463
+ type: 'hidden',
464
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
465
+ default: '={{ $parameter.additionalFields?.media ? ($parameter.additionalFields.mediaType || "image") : undefined }}',
466
+ routing: { send: { type: 'body', property: 'mediaType' } },
467
+ },
468
+ {
469
+ displayName: 'Buttons',
470
+ name: 'buttonsNormalized',
471
+ type: 'hidden',
472
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
473
+ default: '={{ $parameter.additionalFields?.buttons ? (() => { try { return JSON.parse($parameter.additionalFields.buttons); } catch { return undefined; } })() : undefined }}',
474
+ routing: { send: { type: 'body', property: 'buttons' } },
475
+ },
403
476
  // Message: Get Status
404
477
  {
405
478
  displayName: 'Message ID',
@@ -529,6 +602,20 @@ class PilotStatus {
529
602
  action: 'Connect a number',
530
603
  routing: { request: { method: 'GET', url: '=/numbers/{{$parameter.numberId}}/connect' } },
531
604
  },
605
+ {
606
+ name: 'Delete',
607
+ value: 'delete',
608
+ description: 'Remove a WhatsApp number',
609
+ action: 'Delete a number',
610
+ routing: { request: { method: 'DELETE', url: '=/numbers/{{$parameter.numberId}}' } },
611
+ },
612
+ {
613
+ name: 'Remote Pairing',
614
+ value: 'remotePairing',
615
+ description: 'Connect a number via remote pairing',
616
+ action: 'Remote pairing a number',
617
+ routing: { request: { method: 'POST', url: '/numbers/remote-pairing' } },
618
+ },
532
619
  ],
533
620
  default: 'create',
534
621
  },
@@ -536,7 +623,7 @@ class PilotStatus {
536
623
  displayName: 'Name',
537
624
  name: 'name',
538
625
  type: 'string',
539
- displayOptions: { show: { resource: ['number'], operation: ['create'] } },
626
+ displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
540
627
  default: '',
541
628
  required: true,
542
629
  routing: { send: { type: 'body', property: 'name' } },
@@ -545,7 +632,7 @@ class PilotStatus {
545
632
  displayName: 'Number',
546
633
  name: 'number',
547
634
  type: 'string',
548
- displayOptions: { show: { resource: ['number'], operation: ['create'] } },
635
+ displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
549
636
  default: '',
550
637
  required: true,
551
638
  description: 'E.164 format (e.g. +5511999999999)',
@@ -555,19 +642,103 @@ class PilotStatus {
555
642
  displayName: 'Link to API Key',
556
643
  name: 'linkToApiKey',
557
644
  type: 'boolean',
558
- displayOptions: { show: { resource: ['number'], operation: ['create'] } },
645
+ displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
559
646
  default: true,
560
647
  routing: { send: { type: 'body', property: 'linkToApiKey' } },
561
648
  },
649
+ {
650
+ displayName: 'Send via WhatsApp',
651
+ name: 'sendViaWhatsApp',
652
+ type: 'boolean',
653
+ displayOptions: { show: { resource: ['number'], operation: ['remotePairing'] } },
654
+ default: false,
655
+ description: 'Whether to send the pairing code via WhatsApp message',
656
+ routing: { send: { type: 'body', property: 'sendViaWhatsApp' } },
657
+ },
562
658
  {
563
659
  displayName: 'Number Instance ID',
564
660
  name: 'numberId',
565
661
  type: 'string',
566
- displayOptions: { show: { resource: ['number'], operation: ['getStatus', 'connect'] } },
662
+ displayOptions: { show: { resource: ['number'], operation: ['getStatus', 'connect', 'delete'] } },
663
+ default: '',
664
+ required: true,
665
+ },
666
+ // ----------------------------------
667
+ // Template Operations
668
+ // ----------------------------------
669
+ {
670
+ displayName: 'Operation',
671
+ name: 'operation',
672
+ type: 'options',
673
+ noDataExpression: true,
674
+ displayOptions: { show: { resource: ['template'] } },
675
+ options: [
676
+ {
677
+ name: 'Get Many',
678
+ value: 'getAll',
679
+ description: 'List all message templates',
680
+ action: 'Get many templates',
681
+ routing: { request: { method: 'GET', url: '/templates' } },
682
+ },
683
+ {
684
+ name: 'Get',
685
+ value: 'get',
686
+ description: 'Get a single template by ID',
687
+ action: 'Get a template',
688
+ routing: { request: { method: 'GET', url: '=/templates/{{$parameter.templateIdForGet}}' } },
689
+ },
690
+ ],
691
+ default: 'getAll',
692
+ },
693
+ {
694
+ displayName: 'Template ID',
695
+ name: 'templateIdForGet',
696
+ type: 'string',
697
+ displayOptions: { show: { resource: ['template'], operation: ['get'] } },
567
698
  default: '',
568
699
  required: true,
569
700
  },
570
701
  // ----------------------------------
702
+ // Group Operations
703
+ // ----------------------------------
704
+ {
705
+ displayName: 'Operation',
706
+ name: 'operation',
707
+ type: 'options',
708
+ noDataExpression: true,
709
+ displayOptions: { show: { resource: ['group'] } },
710
+ options: [
711
+ {
712
+ name: 'Get Many',
713
+ value: 'getAll',
714
+ description: 'List WhatsApp groups',
715
+ action: 'Get many groups',
716
+ routing: { request: { method: 'GET', url: '/groups' } },
717
+ },
718
+ ],
719
+ default: 'getAll',
720
+ },
721
+ // ----------------------------------
722
+ // Newsletter Operations
723
+ // ----------------------------------
724
+ {
725
+ displayName: 'Operation',
726
+ name: 'operation',
727
+ type: 'options',
728
+ noDataExpression: true,
729
+ displayOptions: { show: { resource: ['newsletter'] } },
730
+ options: [
731
+ {
732
+ name: 'Get Many',
733
+ value: 'getAll',
734
+ description: 'List WhatsApp newsletters',
735
+ action: 'Get many newsletters',
736
+ routing: { request: { method: 'GET', url: '/newsletters' } },
737
+ },
738
+ ],
739
+ default: 'getAll',
740
+ },
741
+ // ----------------------------------
571
742
  // Analytics Operations
572
743
  // ----------------------------------
573
744
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "1.0.10",
3
+ "version": "1.1.0",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",