@posty5/n8n-nodes-posty5 3.0.1 → 4.2.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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Posty5SocialPublisherPost = void 0;
4
4
  const api_helpers_1 = require("../../utils/api.helpers");
5
5
  const constants_1 = require("../../utils/constants");
6
+ const resumable_upload_1 = require("../../utils/resumable-upload");
6
7
  class Posty5SocialPublisherPost {
7
8
  constructor() {
8
9
  this.description = {
@@ -12,7 +13,7 @@ class Posty5SocialPublisherPost {
12
13
  group: ['transform'],
13
14
  version: 1,
14
15
  subtitle: '={{$parameter["operation"]}}',
15
- description: 'Publish videos to social media platforms',
16
+ description: 'Publish videos to social media platforms. Supports an optional post-publish auto-comment (Pro plan, +1 credit) for YouTube, Facebook and Instagram — TikTok is not supported.',
16
17
  defaults: {
17
18
  name: 'Posty5 Social Publisher Post',
18
19
  },
@@ -43,6 +44,48 @@ class Posty5SocialPublisherPost {
43
44
  description: 'Publish a video to social media platforms via account',
44
45
  action: 'Publish a video to account',
45
46
  },
47
+ {
48
+ name: 'Publish Image to Workspace',
49
+ value: 'publishImage',
50
+ description: 'Publish an image to social media platforms via workspace (5 credits, +1 if comment is set)',
51
+ action: 'Publish an image to workspace',
52
+ },
53
+ {
54
+ name: 'Publish Image to Account',
55
+ value: 'publishImageToAccount',
56
+ description: 'Publish an image to a single connected account (5 credits, +1 if comment is set)',
57
+ action: 'Publish an image to account',
58
+ },
59
+ {
60
+ name: 'Publish Long Video to Workspace',
61
+ value: 'publishLongVideo',
62
+ description: 'Publish a video of up to 60 minutes via workspace. Charged by duration: 50 credits per started 5 minutes.',
63
+ action: 'Publish a long video to workspace',
64
+ },
65
+ {
66
+ name: 'Publish Long Video to Account',
67
+ value: 'publishLongVideoToAccount',
68
+ description: 'Publish a video of up to 60 minutes to a single connected account. Charged by duration: 50 credits per started 5 minutes.',
69
+ action: 'Publish a long video to account',
70
+ },
71
+ {
72
+ name: 'Quote Long Video',
73
+ value: 'getLongVideoQuote',
74
+ description: 'Measure a video and return its exact credit cost plus which platforms accept it. Creates nothing and charges nothing.',
75
+ action: 'Quote a long video',
76
+ },
77
+ {
78
+ name: 'Reschedule Post',
79
+ value: 'reschedulePost',
80
+ description: 'Move a not-yet-published post to another time, or publish it now. Costs no credits.',
81
+ action: 'Reschedule a post',
82
+ },
83
+ {
84
+ name: 'Delete Post',
85
+ value: 'deletePost',
86
+ description: 'Delete a post that has not published yet and release its uploaded media. Free — nothing was charged for a post that never went out.',
87
+ action: 'Delete a post',
88
+ },
46
89
  {
47
90
  name: 'Get Post Status',
48
91
  value: 'getPostStatus',
@@ -72,7 +115,7 @@ class Posty5SocialPublisherPost {
72
115
  required: true,
73
116
  displayOptions: {
74
117
  show: {
75
- operation: ['publishVideo'],
118
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
76
119
  },
77
120
  },
78
121
  default: '',
@@ -85,7 +128,7 @@ class Posty5SocialPublisherPost {
85
128
  required: true,
86
129
  displayOptions: {
87
130
  show: {
88
- operation: ['publishVideoToAccount'],
131
+ operation: ['publishVideoToAccount', 'publishLongVideoToAccount'],
89
132
  },
90
133
  },
91
134
  default: '',
@@ -97,7 +140,7 @@ class Posty5SocialPublisherPost {
97
140
  type: 'options',
98
141
  displayOptions: {
99
142
  show: {
100
- operation: ['publishVideo'],
143
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
101
144
  },
102
145
  },
103
146
  options: [
@@ -114,7 +157,7 @@ class Posty5SocialPublisherPost {
114
157
  required: true,
115
158
  displayOptions: {
116
159
  show: {
117
- operation: ['publishVideo'],
160
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
118
161
  videoSource: ['binary'],
119
162
  },
120
163
  },
@@ -128,39 +171,20 @@ class Posty5SocialPublisherPost {
128
171
  required: true,
129
172
  displayOptions: {
130
173
  show: {
131
- operation: ['publishVideo'],
174
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
132
175
  videoSource: ['url'],
133
176
  },
134
177
  },
135
178
  default: '',
136
179
  description: 'URL of the video to publish (can be direct URL, Facebook, TikTok, or YouTube Shorts)',
137
180
  },
138
- {
139
- displayName: 'Platforms',
140
- name: 'platforms',
141
- type: 'multiOptions',
142
- required: true,
143
- displayOptions: {
144
- show: {
145
- operation: ['publishVideo'],
146
- },
147
- },
148
- options: [
149
- { name: 'YouTube', value: 'youtube' },
150
- { name: 'TikTok', value: 'tiktok' },
151
- { name: 'Facebook', value: 'facebook' },
152
- { name: 'Instagram', value: 'instagram' },
153
- ],
154
- default: ['youtube'],
155
- description: 'Platforms to publish to',
156
- },
157
181
  {
158
182
  displayName: 'Thumbnail Source',
159
183
  name: 'thumbnailSource',
160
184
  type: 'options',
161
185
  displayOptions: {
162
186
  show: {
163
- operation: ['publishVideo'],
187
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
164
188
  },
165
189
  },
166
190
  options: [
@@ -177,7 +201,7 @@ class Posty5SocialPublisherPost {
177
201
  type: 'string',
178
202
  displayOptions: {
179
203
  show: {
180
- operation: ['publishVideo'],
204
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
181
205
  thumbnailSource: ['binary'],
182
206
  },
183
207
  },
@@ -190,7 +214,7 @@ class Posty5SocialPublisherPost {
190
214
  type: 'string',
191
215
  displayOptions: {
192
216
  show: {
193
- operation: ['publishVideo'],
217
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
194
218
  thumbnailSource: ['url'],
195
219
  },
196
220
  },
@@ -203,7 +227,7 @@ class Posty5SocialPublisherPost {
203
227
  type: 'options',
204
228
  displayOptions: {
205
229
  show: {
206
- operation: ['publishVideo'],
230
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
207
231
  },
208
232
  },
209
233
  options: [
@@ -219,7 +243,7 @@ class Posty5SocialPublisherPost {
219
243
  type: 'dateTime',
220
244
  displayOptions: {
221
245
  show: {
222
- operation: ['publishVideo'],
246
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
223
247
  scheduledPublishTime: ['later'],
224
248
  },
225
249
  },
@@ -227,6 +251,17 @@ class Posty5SocialPublisherPost {
227
251
  description: 'The date and time to publish',
228
252
  },
229
253
  // YouTube Settings
254
+ {
255
+ displayName: 'Only used if your workspace has a YouTube account connected — otherwise ignored.',
256
+ name: 'youtubeSettingsNotice',
257
+ type: 'notice',
258
+ default: '',
259
+ displayOptions: {
260
+ show: {
261
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
262
+ },
263
+ },
264
+ },
230
265
  {
231
266
  displayName: 'YouTube Settings',
232
267
  name: 'youtubeSettings',
@@ -235,8 +270,7 @@ class Posty5SocialPublisherPost {
235
270
  default: {},
236
271
  displayOptions: {
237
272
  show: {
238
- operation: ['publishVideo'],
239
- platforms: ['youtube'],
273
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
240
274
  },
241
275
  },
242
276
  options: [
@@ -271,6 +305,17 @@ class Posty5SocialPublisherPost {
271
305
  ],
272
306
  },
273
307
  // TikTok Settings
308
+ {
309
+ displayName: 'Only used if your workspace has a TikTok account connected — otherwise ignored.',
310
+ name: 'tiktokSettingsNotice',
311
+ type: 'notice',
312
+ default: '',
313
+ displayOptions: {
314
+ show: {
315
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
316
+ },
317
+ },
318
+ },
274
319
  {
275
320
  displayName: 'TikTok Settings',
276
321
  name: 'tiktokSettings',
@@ -279,8 +324,7 @@ class Posty5SocialPublisherPost {
279
324
  default: {},
280
325
  displayOptions: {
281
326
  show: {
282
- operation: ['publishVideo'],
283
- platforms: ['tiktok'],
327
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
284
328
  },
285
329
  },
286
330
  options: [
@@ -327,6 +371,17 @@ class Posty5SocialPublisherPost {
327
371
  ],
328
372
  },
329
373
  // Facebook Settings
374
+ {
375
+ displayName: 'Only used if your workspace has a Facebook Page connected — otherwise ignored.',
376
+ name: 'facebookSettingsNotice',
377
+ type: 'notice',
378
+ default: '',
379
+ displayOptions: {
380
+ show: {
381
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
382
+ },
383
+ },
384
+ },
330
385
  {
331
386
  displayName: 'Facebook Settings',
332
387
  name: 'facebookSettings',
@@ -335,8 +390,7 @@ class Posty5SocialPublisherPost {
335
390
  default: {},
336
391
  displayOptions: {
337
392
  show: {
338
- operation: ['publishVideo'],
339
- platforms: ['facebook'],
393
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
340
394
  },
341
395
  },
342
396
  options: [
@@ -357,6 +411,17 @@ class Posty5SocialPublisherPost {
357
411
  ],
358
412
  },
359
413
  // Instagram Settings
414
+ {
415
+ displayName: 'Only used if your workspace has an Instagram account connected — otherwise ignored.',
416
+ name: 'instagramSettingsNotice',
417
+ type: 'notice',
418
+ default: '',
419
+ displayOptions: {
420
+ show: {
421
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
422
+ },
423
+ },
424
+ },
360
425
  {
361
426
  displayName: 'Instagram Settings',
362
427
  name: 'instagramSettings',
@@ -365,8 +430,7 @@ class Posty5SocialPublisherPost {
365
430
  default: {},
366
431
  displayOptions: {
367
432
  show: {
368
- operation: ['publishVideo'],
369
- platforms: ['instagram'],
433
+ operation: ['publishVideo', 'publishLongVideo', 'publishLongVideoToAccount'],
370
434
  },
371
435
  },
372
436
  options: [
@@ -386,6 +450,155 @@ class Posty5SocialPublisherPost {
386
450
  },
387
451
  ],
388
452
  },
453
+ // Auto-Comment (post-publish comment, Pro plan, +1 credit)
454
+ {
455
+ displayName: 'Comment',
456
+ name: 'comment',
457
+ type: 'collection',
458
+ placeholder: 'Add Comment',
459
+ default: {},
460
+ displayOptions: {
461
+ show: {
462
+ operation: ['publishVideo', 'publishVideoToAccount', 'publishImage', 'publishImageToAccount'],
463
+ },
464
+ },
465
+ description: 'Optional post-publish comment (Pro plan, +1 credit). When Text is set, a comment is added under each enabled platform once the video/image is published.',
466
+ options: [
467
+ {
468
+ displayName: 'Text',
469
+ name: 'text',
470
+ type: 'string',
471
+ typeOptions: { rows: 3 },
472
+ default: '',
473
+ description: 'Comment text (1-2200 characters). Leave empty to skip auto-commenting.',
474
+ },
475
+ {
476
+ displayName: 'Post to Facebook',
477
+ name: 'postToFacebook',
478
+ type: 'boolean',
479
+ default: true,
480
+ description: 'Whether to add the comment under the Facebook post',
481
+ },
482
+ {
483
+ displayName: 'Post to Instagram',
484
+ name: 'postToInstagram',
485
+ type: 'boolean',
486
+ default: true,
487
+ description: 'Whether to add the comment under the Instagram post',
488
+ },
489
+ {
490
+ displayName: 'Post to YouTube',
491
+ name: 'postToYoutube',
492
+ type: 'boolean',
493
+ default: true,
494
+ description: 'Whether to add the comment under the YouTube post',
495
+ },
496
+ {
497
+ displayName: 'TikTok',
498
+ name: 'tiktokNotice',
499
+ type: 'notice',
500
+ default: '',
501
+ description: 'TikTok comments are not supported by the platform. TikTok will always report "notSupported" on the comment status response.',
502
+ },
503
+ ],
504
+ },
505
+ // ─── Image post fields (task 6) ───────────────────────────────────
506
+ // Image post shares the per-platform settings collections + the
507
+ // Comment block above with the video flow. The only new inputs are
508
+ // the image source + URL + shared caption + AI-enhance flag, plus
509
+ // the Workspace ID / Account ID and (for account-target) the
510
+ // platform selector.
511
+ {
512
+ displayName: 'Workspace ID',
513
+ name: 'imageWorkspaceId',
514
+ type: 'string',
515
+ required: true,
516
+ displayOptions: { show: { operation: ['publishImage'] } },
517
+ default: '',
518
+ description: 'The workspace ID to publish under',
519
+ },
520
+ {
521
+ displayName: 'Account ID',
522
+ name: 'imageAccountId',
523
+ type: 'string',
524
+ required: true,
525
+ displayOptions: { show: { operation: ['publishImageToAccount'] } },
526
+ default: '',
527
+ description: 'The account ID to publish under',
528
+ },
529
+ {
530
+ displayName: 'Image Source',
531
+ name: 'imageSource',
532
+ type: 'options',
533
+ displayOptions: {
534
+ show: { operation: ['publishImage', 'publishImageToAccount'] },
535
+ },
536
+ options: [
537
+ { name: 'External URL', value: 'image-url' },
538
+ { name: 'Uploaded Bucket File', value: 'image-file' },
539
+ ],
540
+ default: 'image-url',
541
+ description: 'Where the image lives. "External URL" sends the URL directly; "Uploaded Bucket File" requires uploading via /generate-upload-urls first.',
542
+ },
543
+ {
544
+ displayName: 'Image URL',
545
+ name: 'imageExternalUrl',
546
+ type: 'string',
547
+ required: true,
548
+ displayOptions: {
549
+ show: {
550
+ operation: ['publishImage', 'publishImageToAccount'],
551
+ imageSource: ['image-url'],
552
+ },
553
+ },
554
+ default: '',
555
+ description: 'Public URL of the image to publish',
556
+ },
557
+ {
558
+ displayName: 'Bucket File URL',
559
+ name: 'imageBucketKey',
560
+ type: 'string',
561
+ required: true,
562
+ displayOptions: {
563
+ show: {
564
+ operation: ['publishImage', 'publishImageToAccount'],
565
+ imageSource: ['image-file'],
566
+ },
567
+ },
568
+ default: '',
569
+ description: 'fileURL returned by /generate-upload-urls after you uploaded the image',
570
+ },
571
+ {
572
+ displayName: 'Caption',
573
+ name: 'imageCaption',
574
+ type: 'string',
575
+ typeOptions: { rows: 3 },
576
+ required: true,
577
+ displayOptions: {
578
+ show: { operation: ['publishImage', 'publishImageToAccount'] },
579
+ },
580
+ default: '',
581
+ description: 'Shared caption used as the default per-platform description (1-8000 characters). Per-platform overrides still apply.',
582
+ },
583
+ {
584
+ displayName: 'AI-Enhanced',
585
+ name: 'imageAiEnhanced',
586
+ type: 'boolean',
587
+ default: false,
588
+ displayOptions: {
589
+ show: { operation: ['publishImage', 'publishImageToAccount'] },
590
+ },
591
+ description: 'Marks the caption as AI-enhanced; surfaces on the status page only',
592
+ },
593
+ {
594
+ displayName: 'YouTube community image posts are not supported by the YouTube Data API and will be reported as "notSupported" on the status response.',
595
+ name: 'imageYoutubeNotice',
596
+ type: 'notice',
597
+ default: '',
598
+ displayOptions: {
599
+ show: { operation: ['publishImage', 'publishImageToAccount'] },
600
+ },
601
+ },
389
602
  // Get post status fields
390
603
  {
391
604
  displayName: 'Post ID',
@@ -443,6 +656,99 @@ class Posty5SocialPublisherPost {
443
656
  default: 50,
444
657
  description: 'Max number of results to return',
445
658
  },
659
+ {
660
+ displayName: 'Post ID',
661
+ name: 'deletePostId',
662
+ type: 'string',
663
+ required: true,
664
+ displayOptions: {
665
+ show: {
666
+ operation: ['deletePost'],
667
+ },
668
+ },
669
+ default: '',
670
+ description: 'The post to delete. Only posts that have not published yet are eligible; a published post must be taken down with Remove instead.',
671
+ },
672
+ // ─── Long video: quote + reschedule ──────────────────────────────
673
+ {
674
+ displayName: 'Video URL',
675
+ name: 'quoteVideoUrl',
676
+ type: 'string',
677
+ required: true,
678
+ displayOptions: {
679
+ show: {
680
+ operation: ['getLongVideoQuote'],
681
+ },
682
+ },
683
+ default: '',
684
+ description: 'URL of an uploaded or externally hosted video to measure and price. The duration is read server-side; nothing is created or charged.',
685
+ },
686
+ {
687
+ displayName: 'Post ID',
688
+ name: 'reschedulePostId',
689
+ type: 'string',
690
+ required: true,
691
+ displayOptions: {
692
+ show: {
693
+ operation: ['reschedulePost'],
694
+ },
695
+ },
696
+ default: '',
697
+ description: 'The post to move. Only posts still pending with a future publish time are eligible.',
698
+ },
699
+ {
700
+ displayName: 'New Publish Time',
701
+ name: 'rescheduleWhen',
702
+ type: 'options',
703
+ displayOptions: {
704
+ show: {
705
+ operation: ['reschedulePost'],
706
+ },
707
+ },
708
+ options: [
709
+ { name: 'Now', value: 'now' },
710
+ { name: 'Schedule for Later', value: 'later' },
711
+ ],
712
+ default: 'later',
713
+ description: 'Publish the post immediately, or move it to a new date',
714
+ },
715
+ {
716
+ displayName: 'New Schedule Date',
717
+ name: 'rescheduleDate',
718
+ type: 'dateTime',
719
+ required: true,
720
+ displayOptions: {
721
+ show: {
722
+ operation: ['reschedulePost'],
723
+ rescheduleWhen: ['later'],
724
+ },
725
+ },
726
+ default: '',
727
+ description: 'The new date and time to publish the post',
728
+ },
729
+ {
730
+ displayName: 'New Caption',
731
+ name: 'rescheduleCaption',
732
+ type: 'string',
733
+ displayOptions: {
734
+ show: {
735
+ operation: ['reschedulePost'],
736
+ },
737
+ },
738
+ default: '',
739
+ description: 'Optionally replace the caption at the same time. Leave empty to keep it.',
740
+ },
741
+ {
742
+ displayName: 'Long video is capped at 60 minutes and charged by duration — 50 credits for every started 5 minutes. Platform limits differ: YouTube and Facebook take an hour, Instagram Reels stop at 15 minutes, and TikTok depends on the connected creator. Targets that cannot take the video are reported in "refusedTargets" and the post still publishes to the rest.',
743
+ name: 'longVideoNotice',
744
+ type: 'notice',
745
+ displayOptions: {
746
+ show: {
747
+ operation: ['publishLongVideo', 'publishLongVideoToAccount'],
748
+ },
749
+ },
750
+ default: '',
751
+ },
446
752
  ],
447
753
  };
448
754
  }
@@ -463,7 +769,6 @@ class Posty5SocialPublisherPost {
463
769
  ? this.getNodeParameter('accountId', i)
464
770
  : undefined;
465
771
  const videoSource = this.getNodeParameter('videoSource', i);
466
- const platforms = this.getNodeParameter('platforms', i);
467
772
  const thumbnailSource = this.getNodeParameter('thumbnailSource', i, 'none');
468
773
  const scheduledPublishTime = this.getNodeParameter('scheduledPublishTime', i);
469
774
  let videoURL;
@@ -502,30 +807,21 @@ class Posty5SocialPublisherPost {
502
807
  else {
503
808
  // URL-based video
504
809
  videoURL = this.getNodeParameter('videoUrl', i);
505
- // Detect source type from URL pattern
506
- if (videoURL.includes('facebook.com') || videoURL.includes('fb.watch')) {
507
- source = 'facebook-video';
508
- }
509
- else if (videoURL.includes('tiktok.com')) {
510
- source = 'tiktok-video';
511
- }
512
- else if (videoURL.includes('youtube.com') || videoURL.includes('youtu.be')) {
513
- source = 'youtube-video';
514
- }
515
- else {
516
- source = 'video-url';
517
- }
810
+ source = 'video-url';
518
811
  if (thumbnailSource === 'url') {
519
812
  thumbURL = this.getNodeParameter('thumbnailUrl', i);
520
813
  }
521
814
  }
522
- // Prepare post body
815
+ // Prepare post body.
816
+ // The server derives which platforms a post lands on from the
817
+ // workspace's connected accounts (or the account's platform).
818
+ // We forward every settings collection the user filled in —
819
+ // the API ignores any block whose platform isn't connected.
523
820
  const postBody = {
524
821
  workspaceId,
525
822
  accountId,
526
823
  videoURL,
527
824
  source,
528
- platforms,
529
825
  };
530
826
  if (thumbURL) {
531
827
  postBody.thumbURL = thumbURL;
@@ -538,35 +834,41 @@ class Posty5SocialPublisherPost {
538
834
  else {
539
835
  postBody.scheduledPublishTime = 'now';
540
836
  }
541
- // Platform-specific settings
542
- if (platforms.includes('youtube')) {
543
- const youtubeSettings = this.getNodeParameter('youtubeSettings', i, {});
544
- if (Object.keys(youtubeSettings).length > 0) {
545
- postBody.youtubeConfig = { ...youtubeSettings };
546
- if (youtubeSettings.tags && typeof youtubeSettings.tags === 'string') {
547
- postBody.youtubeConfig.tags = youtubeSettings.tags
548
- .split(',')
549
- .map((t) => t.trim());
550
- }
837
+ // Platform-specific settings — forward every non-empty block.
838
+ // The user only fills the platforms relevant to their workspace;
839
+ // the API ignores configs for unconnected platforms.
840
+ const youtubeSettings = this.getNodeParameter('youtubeSettings', i, {});
841
+ if (Object.keys(youtubeSettings).length > 0) {
842
+ postBody.youtubeConfig = { ...youtubeSettings };
843
+ if (youtubeSettings.tags && typeof youtubeSettings.tags === 'string') {
844
+ postBody.youtubeConfig.tags = youtubeSettings.tags
845
+ .split(',')
846
+ .map((t) => t.trim());
551
847
  }
552
848
  }
553
- if (platforms.includes('tiktok')) {
554
- const tiktokSettings = this.getNodeParameter('tiktokSettings', i, {});
555
- if (Object.keys(tiktokSettings).length > 0) {
556
- postBody.tiktokConfig = tiktokSettings;
557
- }
849
+ const tiktokSettings = this.getNodeParameter('tiktokSettings', i, {});
850
+ if (Object.keys(tiktokSettings).length > 0) {
851
+ postBody.tiktokConfig = tiktokSettings;
558
852
  }
559
- if (platforms.includes('facebook')) {
560
- const facebookSettings = this.getNodeParameter('facebookSettings', i, {});
561
- if (Object.keys(facebookSettings).length > 0) {
562
- postBody.facebookPageConfig = facebookSettings;
563
- }
853
+ const facebookSettings = this.getNodeParameter('facebookSettings', i, {});
854
+ if (Object.keys(facebookSettings).length > 0) {
855
+ postBody.facebookPageConfig = facebookSettings;
564
856
  }
565
- if (platforms.includes('instagram')) {
566
- const instagramSettings = this.getNodeParameter('instagramSettings', i, {});
567
- if (Object.keys(instagramSettings).length > 0) {
568
- postBody.instagramConfig = instagramSettings;
569
- }
857
+ const instagramSettings = this.getNodeParameter('instagramSettings', i, {});
858
+ if (Object.keys(instagramSettings).length > 0) {
859
+ postBody.instagramConfig = instagramSettings;
860
+ }
861
+ // Optional post-publish auto-comment (Pro plan, +1 credit).
862
+ // TikTok comments are not supported and will report `notSupported` in the status response.
863
+ const commentSettings = this.getNodeParameter('comment', i, {});
864
+ if (commentSettings && typeof commentSettings.text === 'string' && commentSettings.text.trim().length > 0) {
865
+ postBody.comment = {
866
+ text: commentSettings.text,
867
+ postToFacebook: commentSettings.postToFacebook ?? true,
868
+ postToInstagram: commentSettings.postToInstagram ?? true,
869
+ postToYoutube: commentSettings.postToYoutube ?? true,
870
+ postToTiktok: false,
871
+ };
570
872
  }
571
873
  // Create post
572
874
  let endpoint = '';
@@ -583,6 +885,236 @@ class Posty5SocialPublisherPost {
583
885
  body: postBody,
584
886
  });
585
887
  }
888
+ else if (operation === 'publishImage' || operation === 'publishImageToAccount') {
889
+ // ─── Image post (task 6) ─────────────────────────────────
890
+ // Image posts share most plumbing with video posts. The
891
+ // API auto-synthesizes per-platform description blocks
892
+ // from `caption` if not provided, so the n8n form only
893
+ // needs source + URL/bucketKey + caption + optional comment.
894
+ const isWorkspace = operation === 'publishImage';
895
+ const workspaceId = isWorkspace
896
+ ? this.getNodeParameter('imageWorkspaceId', i)
897
+ : undefined;
898
+ const accountId = !isWorkspace
899
+ ? this.getNodeParameter('imageAccountId', i)
900
+ : undefined;
901
+ const imageSource = this.getNodeParameter('imageSource', i);
902
+ const caption = this.getNodeParameter('imageCaption', i);
903
+ const aiEnhanced = this.getNodeParameter('imageAiEnhanced', i, false);
904
+ const image = { source: imageSource };
905
+ if (imageSource === 'image-url') {
906
+ image.externalUrl = this.getNodeParameter('imageExternalUrl', i);
907
+ }
908
+ else {
909
+ image.bucketKey = this.getNodeParameter('imageBucketKey', i);
910
+ }
911
+ const imagePostBody = {
912
+ workspaceId,
913
+ accountId,
914
+ image,
915
+ caption,
916
+ aiEnhanced,
917
+ };
918
+ // Optional auto-comment — reuse the existing Comment collection.
919
+ const commentSettings = this.getNodeParameter('comment', i, {});
920
+ if (commentSettings && typeof commentSettings.text === 'string' && commentSettings.text.trim().length > 0) {
921
+ imagePostBody.comment = {
922
+ text: commentSettings.text,
923
+ postToFacebook: commentSettings.postToFacebook ?? true,
924
+ postToInstagram: commentSettings.postToInstagram ?? true,
925
+ postToYoutube: commentSettings.postToYoutube ?? true,
926
+ postToTiktok: false,
927
+ };
928
+ }
929
+ const endpoint = isWorkspace
930
+ ? `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/image/workspace`
931
+ : `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/image/account`;
932
+ responseData = await api_helpers_1.makeApiRequest.call(this, apiKey, {
933
+ method: 'POST',
934
+ endpoint,
935
+ body: imagePostBody,
936
+ });
937
+ }
938
+ else if (operation === 'publishLongVideo' ||
939
+ operation === 'publishLongVideoToAccount') {
940
+ // ─── Long video (up to 60 minutes) ───────────────────────
941
+ // The payload is the short-video payload. What differs is
942
+ // duration, which the server measures from the file — there
943
+ // is no duration field here, and one would be ignored,
944
+ // because the price is derived from it.
945
+ const isWorkspace = operation === 'publishLongVideo';
946
+ const workspaceId = isWorkspace
947
+ ? this.getNodeParameter('workspaceId', i)
948
+ : undefined;
949
+ const accountId = !isWorkspace
950
+ ? this.getNodeParameter('accountId', i)
951
+ : undefined;
952
+ const videoSource = this.getNodeParameter('videoSource', i);
953
+ const thumbnailSource = this.getNodeParameter('thumbnailSource', i, 'none');
954
+ const scheduledPublishTime = this.getNodeParameter('scheduledPublishTime', i);
955
+ let videoURL;
956
+ let thumbURL;
957
+ let source;
958
+ let uploadedPostId;
959
+ if (videoSource === 'binary') {
960
+ const videoBinaryProperty = this.getNodeParameter('videoBinaryProperty', i);
961
+ const videoBuffer = await this.helpers.getBinaryDataBuffer(i, videoBinaryProperty);
962
+ // Declaring the post type here is what buys the early
963
+ // refusal: the server checks plan gating and whether the
964
+ // balance covers even the shortest long video BEFORE an
965
+ // hour of footage is transferred.
966
+ const uploadUrlsResponse = await api_helpers_1.makeApiRequest.call(this, apiKey, {
967
+ method: 'POST',
968
+ endpoint: `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/generate-upload-urls`,
969
+ body: {
970
+ videoFileType: 'video/mp4',
971
+ thumbFileType: thumbnailSource === 'binary' ? 'image/jpeg' : undefined,
972
+ postType: 'longVideo',
973
+ },
974
+ });
975
+ // Prefer the resumable transfer for a long video — this is
976
+ // the case a single PUT handles worst, since a dropped
977
+ // connection at 90% of an hour of footage otherwise starts
978
+ // again from zero. Servers without the resumable service
979
+ // omit the tus fields and the signed PUT still works.
980
+ if ((0, resumable_upload_1.supportsResumableUpload)(uploadUrlsResponse.video)) {
981
+ await resumable_upload_1.uploadResumable.call(this, uploadUrlsResponse.video, videoBuffer, {
982
+ contentType: 'video/mp4',
983
+ fileName: items[i].binary?.[videoBinaryProperty]?.fileName || 'video.mp4',
984
+ });
985
+ }
986
+ else {
987
+ await api_helpers_1.uploadFile.call(this, uploadUrlsResponse.video.uploadFileURL, videoBuffer);
988
+ }
989
+ videoURL = uploadUrlsResponse.video.fileURL;
990
+ source = 'video-file';
991
+ uploadedPostId = uploadUrlsResponse.postId;
992
+ if (thumbnailSource === 'binary') {
993
+ const thumbnailBinaryProperty = this.getNodeParameter('thumbnailBinaryProperty', i);
994
+ if (items[i].binary?.[thumbnailBinaryProperty]) {
995
+ const thumbnailBuffer = await this.helpers.getBinaryDataBuffer(i, thumbnailBinaryProperty);
996
+ await api_helpers_1.uploadFile.call(this, uploadUrlsResponse.thumb.uploadFileURL, thumbnailBuffer);
997
+ thumbURL = uploadUrlsResponse.thumb.fileURL;
998
+ }
999
+ }
1000
+ else if (thumbnailSource === 'url') {
1001
+ thumbURL = this.getNodeParameter('thumbnailUrl', i);
1002
+ }
1003
+ }
1004
+ else {
1005
+ videoURL = this.getNodeParameter('videoUrl', i);
1006
+ source = 'video-url';
1007
+ if (thumbnailSource === 'url') {
1008
+ thumbURL = this.getNodeParameter('thumbnailUrl', i);
1009
+ }
1010
+ }
1011
+ const longVideoBody = {
1012
+ workspaceId,
1013
+ accountId,
1014
+ videoURL,
1015
+ source,
1016
+ };
1017
+ if (thumbURL) {
1018
+ longVideoBody.thumbURL = thumbURL;
1019
+ }
1020
+ if (scheduledPublishTime === 'later') {
1021
+ const scheduleDate = this.getNodeParameter('scheduleDate', i);
1022
+ longVideoBody.schedule = {
1023
+ type: 'schedule',
1024
+ scheduledAt: new Date(scheduleDate).toISOString(),
1025
+ };
1026
+ }
1027
+ else {
1028
+ longVideoBody.schedule = { type: 'now' };
1029
+ }
1030
+ const lvYoutube = this.getNodeParameter('youtubeSettings', i, {});
1031
+ if (Object.keys(lvYoutube).length > 0) {
1032
+ longVideoBody.youtube = { ...lvYoutube };
1033
+ if (lvYoutube.tags && typeof lvYoutube.tags === 'string') {
1034
+ longVideoBody.youtube.tags = lvYoutube.tags
1035
+ .split(',')
1036
+ .map((t) => t.trim());
1037
+ }
1038
+ }
1039
+ const lvTiktok = this.getNodeParameter('tiktokSettings', i, {});
1040
+ if (Object.keys(lvTiktok).length > 0) {
1041
+ longVideoBody.tiktok = lvTiktok;
1042
+ }
1043
+ const lvFacebook = this.getNodeParameter('facebookSettings', i, {});
1044
+ if (Object.keys(lvFacebook).length > 0) {
1045
+ longVideoBody.facebook = lvFacebook;
1046
+ }
1047
+ const lvInstagram = this.getNodeParameter('instagramSettings', i, {});
1048
+ if (Object.keys(lvInstagram).length > 0) {
1049
+ longVideoBody.instagram = lvInstagram;
1050
+ }
1051
+ const lvComment = this.getNodeParameter('comment', i, {});
1052
+ if (lvComment &&
1053
+ typeof lvComment.text === 'string' &&
1054
+ lvComment.text.trim().length > 0) {
1055
+ longVideoBody.comment = {
1056
+ text: lvComment.text,
1057
+ postToFacebook: lvComment.postToFacebook ?? true,
1058
+ postToInstagram: lvComment.postToInstagram ?? true,
1059
+ postToYoutube: lvComment.postToYoutube ?? true,
1060
+ postToTiktok: false,
1061
+ };
1062
+ }
1063
+ const target = isWorkspace ? 'workspace' : 'account';
1064
+ const bySegment = source === 'video-file' ? 'by-file' : 'by-url';
1065
+ const longVideoEndpoint = `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/long-video/${target}/${bySegment}` +
1066
+ (uploadedPostId ? `/${uploadedPostId}` : '');
1067
+ // The response carries the measured duration, the credits
1068
+ // charged and any target dropped for exceeding its own
1069
+ // limit — all of it lands in the item so a later node can
1070
+ // branch on cost or on a partial publish.
1071
+ responseData = await api_helpers_1.makeApiRequest.call(this, apiKey, {
1072
+ method: 'POST',
1073
+ endpoint: longVideoEndpoint,
1074
+ body: longVideoBody,
1075
+ });
1076
+ }
1077
+ else if (operation === 'getLongVideoQuote') {
1078
+ // Measures and prices a video without creating or charging
1079
+ // anything, so a workflow can branch on cost before it
1080
+ // commits to publishing.
1081
+ const quoteVideoUrl = this.getNodeParameter('quoteVideoUrl', i);
1082
+ responseData = await api_helpers_1.makeApiRequest.call(this, apiKey, {
1083
+ method: 'POST',
1084
+ endpoint: `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/long-video/quote`,
1085
+ body: { videoURL: quoteVideoUrl },
1086
+ });
1087
+ }
1088
+ else if (operation === 'reschedulePost') {
1089
+ const reschedulePostId = this.getNodeParameter('reschedulePostId', i);
1090
+ const rescheduleWhen = this.getNodeParameter('rescheduleWhen', i, 'later');
1091
+ const rescheduleCaption = this.getNodeParameter('rescheduleCaption', i, '');
1092
+ const rescheduleBody = {
1093
+ schedule: rescheduleWhen === 'later'
1094
+ ? {
1095
+ type: 'schedule',
1096
+ scheduledAt: new Date(this.getNodeParameter('rescheduleDate', i)).toISOString(),
1097
+ }
1098
+ : { type: 'now' },
1099
+ };
1100
+ if (rescheduleCaption.trim().length > 0) {
1101
+ rescheduleBody.caption = rescheduleCaption;
1102
+ }
1103
+ responseData = await api_helpers_1.makeApiRequest.call(this, apiKey, {
1104
+ method: 'PUT',
1105
+ endpoint: `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/${reschedulePostId}`,
1106
+ body: rescheduleBody,
1107
+ });
1108
+ }
1109
+ else if (operation === 'deletePost') {
1110
+ // Free, and irreversible for the caller: the post is gone and its
1111
+ // uploaded media is released in the same request.
1112
+ const deletePostId = this.getNodeParameter('deletePostId', i);
1113
+ responseData = await api_helpers_1.makeApiRequest.call(this, apiKey, {
1114
+ method: 'DELETE',
1115
+ endpoint: `${constants_1.API_ENDPOINTS.SOCIAL_PUBLISHER_POST}/${deletePostId}`,
1116
+ });
1117
+ }
586
1118
  else if (operation === 'getPostStatus') {
587
1119
  const postId = this.getNodeParameter('postId', i);
588
1120
  responseData = await api_helpers_1.makeApiRequest.call(this, apiKey, {