n8n-nodes-pilot-status 1.0.11 → 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.
@@ -4,6 +4,8 @@ export declare class PilotStatus implements INodeType {
4
4
  loadOptions: {
5
5
  getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
6
6
  getTemplateVariables(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
8
+ getNewsletters(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
9
  };
8
10
  };
9
11
  description: INodeTypeDescription;
@@ -37,6 +37,30 @@ class PilotStatus {
37
37
  const vars = (_b = (_a = response === null || response === void 0 ? void 0 : response.latestVersion) === null || _a === void 0 ? void 0 : _a.variables) !== null && _b !== void 0 ? _b : [];
38
38
  return Array.isArray(vars) ? vars.map((v) => ({ name: v, value: v })) : [];
39
39
  },
40
+ async getGroups() {
41
+ const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
42
+ method: 'GET',
43
+ baseURL: 'https://pilotstatus.online/v1',
44
+ url: '/groups',
45
+ json: true,
46
+ }));
47
+ return (response || []).map((g) => ({
48
+ name: g.subject,
49
+ value: g.id,
50
+ }));
51
+ },
52
+ async getNewsletters() {
53
+ const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
54
+ method: 'GET',
55
+ baseURL: 'https://pilotstatus.online/v1',
56
+ url: '/newsletters',
57
+ json: true,
58
+ }));
59
+ return (response || []).map((n) => ({
60
+ name: n.name,
61
+ value: n.id,
62
+ }));
63
+ },
40
64
  },
41
65
  };
42
66
  this.description = {
@@ -76,6 +100,9 @@ class PilotStatus {
76
100
  { name: 'Project', value: 'project' },
77
101
  { name: 'API Key', value: 'apiKey' },
78
102
  { name: 'Number', value: 'number' },
103
+ { name: 'Template', value: 'template' },
104
+ { name: 'Group', value: 'group' },
105
+ { name: 'Newsletter', value: 'newsletter' },
79
106
  { name: 'Analytics', value: 'analytics' },
80
107
  ],
81
108
  default: 'message',
@@ -97,7 +124,6 @@ class PilotStatus {
97
124
  action: 'Send a message',
98
125
  routing: {
99
126
  request: { method: 'POST', url: '/messages/send' },
100
- // ✅ preSend hook: monta o campo "variables" como objeto antes de enviar
101
127
  send: {
102
128
  preSend: [
103
129
  async function (requestOptions) {
@@ -141,7 +167,6 @@ class PilotStatus {
141
167
  try {
142
168
  const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
143
169
  if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
144
- // ✅ API exige que todos os valores sejam strings
145
170
  for (const [k, v] of Object.entries(parsed)) {
146
171
  variables[k] = String(v !== null && v !== void 0 ? v : '');
147
172
  }
@@ -154,11 +179,9 @@ class PilotStatus {
154
179
  else {
155
180
  const ui = this.getNodeParameter('variablesUi');
156
181
  for (const entry of (_a = ui === null || ui === void 0 ? void 0 : ui.values) !== null && _a !== void 0 ? _a : []) {
157
- // ✅ API exige que todos os valores sejam strings
158
182
  variables[entry.name] = String((_b = entry.value) !== null && _b !== void 0 ? _b : '');
159
183
  }
160
184
  }
161
- // Garante que o body é um objeto e injeta "variables" como objeto
162
185
  if (!requestOptions.body || typeof requestOptions.body !== 'object') {
163
186
  requestOptions.body = {};
164
187
  }
@@ -291,7 +314,6 @@ class PilotStatus {
291
314
  show: { resource: ['message'], operation: ['send'], variablesMode: ['json'] },
292
315
  },
293
316
  description: 'A JSON object containing key-value pairs for variables',
294
- // ✅ Sem routing aqui — o preSend cuida do envio como objeto
295
317
  },
296
318
  {
297
319
  displayName: 'Variables',
@@ -329,7 +351,6 @@ class PilotStatus {
329
351
  ],
330
352
  },
331
353
  ],
332
- // ✅ Sem routing aqui — o preSend cuida do envio como objeto
333
354
  },
334
355
  {
335
356
  displayName: 'Additional Fields',
@@ -353,6 +374,46 @@ class PilotStatus {
353
374
  default: '',
354
375
  description: 'Optional expiration limit for the message delivery (ISO8601)',
355
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
+ },
356
417
  ],
357
418
  },
358
419
  // Hidden fields para deliverAt / deliverUntil normalizados
@@ -372,6 +433,46 @@ class PilotStatus {
372
433
  default: '={{ $parameter.additionalFields?.deliverUntil ? new Date($parameter.additionalFields.deliverUntil).toISOString() : undefined }}',
373
434
  routing: { send: { type: 'body', property: 'deliverUntil' } },
374
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
+ },
375
476
  // Message: Get Status
376
477
  {
377
478
  displayName: 'Message ID',
@@ -501,6 +602,20 @@ class PilotStatus {
501
602
  action: 'Connect a number',
502
603
  routing: { request: { method: 'GET', url: '=/numbers/{{$parameter.numberId}}/connect' } },
503
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
+ },
504
619
  ],
505
620
  default: 'create',
506
621
  },
@@ -508,7 +623,7 @@ class PilotStatus {
508
623
  displayName: 'Name',
509
624
  name: 'name',
510
625
  type: 'string',
511
- displayOptions: { show: { resource: ['number'], operation: ['create'] } },
626
+ displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
512
627
  default: '',
513
628
  required: true,
514
629
  routing: { send: { type: 'body', property: 'name' } },
@@ -517,7 +632,7 @@ class PilotStatus {
517
632
  displayName: 'Number',
518
633
  name: 'number',
519
634
  type: 'string',
520
- displayOptions: { show: { resource: ['number'], operation: ['create'] } },
635
+ displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
521
636
  default: '',
522
637
  required: true,
523
638
  description: 'E.164 format (e.g. +5511999999999)',
@@ -527,19 +642,103 @@ class PilotStatus {
527
642
  displayName: 'Link to API Key',
528
643
  name: 'linkToApiKey',
529
644
  type: 'boolean',
530
- displayOptions: { show: { resource: ['number'], operation: ['create'] } },
645
+ displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
531
646
  default: true,
532
647
  routing: { send: { type: 'body', property: 'linkToApiKey' } },
533
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
+ },
534
658
  {
535
659
  displayName: 'Number Instance ID',
536
660
  name: 'numberId',
537
661
  type: 'string',
538
- displayOptions: { show: { resource: ['number'], operation: ['getStatus', 'connect'] } },
662
+ displayOptions: { show: { resource: ['number'], operation: ['getStatus', 'connect', 'delete'] } },
539
663
  default: '',
540
664
  required: true,
541
665
  },
542
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'] } },
698
+ default: '',
699
+ required: true,
700
+ },
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
+ // ----------------------------------
543
742
  // Analytics Operations
544
743
  // ----------------------------------
545
744
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",