@blitzreels/sdk 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -11,6 +11,15 @@ export class BlitzReelsError extends Error {
11
11
  this.body = options.body;
12
12
  }
13
13
  }
14
+ function buildCaptionTrackSelectorBody({ options, }) {
15
+ return {
16
+ all: options.all,
17
+ caption_id: options.captionId,
18
+ timeline_item_id: options.timelineItemId,
19
+ from_seconds: options.fromSeconds,
20
+ to_seconds: options.toSeconds,
21
+ };
22
+ }
14
23
  function normalizeBaseUrl({ baseUrl, }) {
15
24
  const value = String(baseUrl ?? DEFAULT_BASE_URL).trim();
16
25
  return value.replace(/\/+$/, "");
@@ -37,6 +46,27 @@ function extractErrorMessage({ body }) {
37
46
  const message = record.message ?? record.error;
38
47
  return typeof message === "string" ? message : null;
39
48
  }
49
+ function normalizeMediaPositionPreset({ value, }) {
50
+ if (value === "full-screen") {
51
+ return "fullscreen";
52
+ }
53
+ if (value === "top-left") {
54
+ return "pip-top-left";
55
+ }
56
+ if (value === "top-right") {
57
+ return "pip-top-right";
58
+ }
59
+ if (value === "bottom-left") {
60
+ return "pip-bottom-left";
61
+ }
62
+ if (value === "bottom-right") {
63
+ return "pip-bottom-right";
64
+ }
65
+ return value;
66
+ }
67
+ function normalizeMediaAnimationPreset({ value, }) {
68
+ return value === "slideIn" ? "slideUp" : value;
69
+ }
40
70
  function sleep({ ms }) {
41
71
  return new Promise((resolve) => setTimeout(resolve, ms));
42
72
  }
@@ -86,10 +116,16 @@ export class BlitzReelsClient {
86
116
  userAgent;
87
117
  auth;
88
118
  projects;
119
+ timeline;
120
+ effects;
89
121
  workspace;
90
122
  media;
123
+ clips;
91
124
  text;
92
125
  audio;
126
+ audioLibrary;
127
+ stockMedia;
128
+ library;
93
129
  silence;
94
130
  mistakes;
95
131
  captions;
@@ -187,6 +223,138 @@ export class BlitzReelsClient {
187
223
  },
188
224
  }),
189
225
  };
226
+ this.timeline = {
227
+ transform: (options) => this.request({
228
+ method: "POST",
229
+ path: `/projects/${encodeURIComponent(options.projectId)}/timeline/edits`,
230
+ query: undefined,
231
+ body: {
232
+ action: "transform",
233
+ timeline_item_id: options.timelineItemId,
234
+ position_x: options.positionX,
235
+ position_y: options.positionY,
236
+ width_px: options.widthPx,
237
+ height_px: options.heightPx,
238
+ keep_aspect_ratio: options.keepAspectRatio,
239
+ },
240
+ }),
241
+ move: (options) => this.request({
242
+ method: "POST",
243
+ path: `/projects/${encodeURIComponent(options.projectId)}/timeline/edits`,
244
+ query: undefined,
245
+ body: {
246
+ action: "move",
247
+ timeline_item_id: options.timelineItemId,
248
+ new_start_seconds: options.newStartSeconds,
249
+ new_layer_index: options.newLayerIndex,
250
+ },
251
+ }),
252
+ delete: (options) => this.request({
253
+ method: "POST",
254
+ path: `/projects/${encodeURIComponent(options.projectId)}/timeline/edits`,
255
+ query: undefined,
256
+ body: {
257
+ action: "delete",
258
+ timeline_item_ids: options.timelineItemIds,
259
+ auto_pack: options.autoPack,
260
+ },
261
+ }),
262
+ deleteItem: (options) => this.request({
263
+ method: "DELETE",
264
+ path: `/projects/${encodeURIComponent(options.projectId)}/timeline/items/${encodeURIComponent(options.timelineItemId)}`,
265
+ query: undefined,
266
+ body: undefined,
267
+ }),
268
+ };
269
+ this.effects = {
270
+ zoom: {
271
+ add: (options) => this.request({
272
+ method: "POST",
273
+ path: `/projects/${encodeURIComponent(options.projectId)}/effects/zoom`,
274
+ query: undefined,
275
+ body: {
276
+ timeline_item_id: options.timelineItemId,
277
+ content_item_id: options.contentItemId,
278
+ effect_id: options.effectId,
279
+ name: options.name,
280
+ start_time_seconds: options.startTimeSeconds,
281
+ duration_seconds: options.durationSeconds,
282
+ easing: options.easing,
283
+ layer_index: options.layerIndex,
284
+ order_index: options.orderIndex,
285
+ settings: options.settings,
286
+ },
287
+ }),
288
+ update: (options) => this.request({
289
+ method: "PATCH",
290
+ path: `/projects/${encodeURIComponent(options.projectId)}/effects/zoom/${encodeURIComponent(options.timelineItemId)}`,
291
+ query: undefined,
292
+ body: {
293
+ duration_seconds: options.durationSeconds,
294
+ easing: options.easing,
295
+ settings: options.settings,
296
+ },
297
+ }),
298
+ },
299
+ mask: {
300
+ add: (options) => this.request({
301
+ method: "POST",
302
+ path: `/projects/${encodeURIComponent(options.projectId)}/effects/mask`,
303
+ query: undefined,
304
+ body: {
305
+ timeline_item_id: options.timelineItemId,
306
+ content_item_id: options.contentItemId,
307
+ effect_id: options.effectId,
308
+ name: options.name,
309
+ start_time_seconds: options.startTimeSeconds,
310
+ duration_seconds: options.durationSeconds,
311
+ easing: options.easing,
312
+ layer_index: options.layerIndex,
313
+ order_index: options.orderIndex,
314
+ settings: options.settings,
315
+ },
316
+ }),
317
+ update: (options) => this.request({
318
+ method: "PATCH",
319
+ path: `/projects/${encodeURIComponent(options.projectId)}/effects/mask/${encodeURIComponent(options.timelineItemId)}`,
320
+ query: undefined,
321
+ body: {
322
+ duration_seconds: options.durationSeconds,
323
+ easing: options.easing,
324
+ settings: options.settings,
325
+ },
326
+ }),
327
+ },
328
+ colorgrade: {
329
+ add: (options) => this.request({
330
+ method: "POST",
331
+ path: `/projects/${encodeURIComponent(options.projectId)}/effects/colorgrade`,
332
+ query: undefined,
333
+ body: {
334
+ timeline_item_id: options.timelineItemId,
335
+ content_item_id: options.contentItemId,
336
+ effect_id: options.effectId,
337
+ name: options.name,
338
+ start_time_seconds: options.startTimeSeconds,
339
+ duration_seconds: options.durationSeconds,
340
+ easing: options.easing,
341
+ layer_index: options.layerIndex,
342
+ order_index: options.orderIndex,
343
+ settings: options.settings,
344
+ },
345
+ }),
346
+ update: (options) => this.request({
347
+ method: "PATCH",
348
+ path: `/projects/${encodeURIComponent(options.projectId)}/effects/colorgrade/${encodeURIComponent(options.timelineItemId)}`,
349
+ query: undefined,
350
+ body: {
351
+ duration_seconds: options.durationSeconds,
352
+ easing: options.easing,
353
+ settings: options.settings,
354
+ },
355
+ }),
356
+ },
357
+ };
190
358
  this.workspace = {
191
359
  getSettings: () => this.request({
192
360
  method: "GET",
@@ -235,6 +403,12 @@ export class BlitzReelsClient {
235
403
  query: undefined,
236
404
  body: undefined,
237
405
  }),
406
+ clippingStatus: (options) => this.request({
407
+ method: "GET",
408
+ path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/clipping-status`,
409
+ query: { project_id: options.projectId },
410
+ body: undefined,
411
+ }),
238
412
  delete: (options) => this.request({
239
413
  method: "POST",
240
414
  path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/delete`,
@@ -307,11 +481,73 @@ export class BlitzReelsClient {
307
481
  asset_id: options.assetId,
308
482
  start_seconds: options.startSeconds ?? 0,
309
483
  duration_seconds: options.durationSeconds,
484
+ position_preset: normalizeMediaPositionPreset({
485
+ value: options.positionPreset,
486
+ }),
487
+ position_x: options.positionX,
488
+ position_y: options.positionY,
489
+ width_px: options.widthPx,
490
+ height_px: options.heightPx,
491
+ scale: options.scale,
492
+ opacity: options.opacity,
493
+ animation_preset: normalizeMediaAnimationPreset({
494
+ value: options.animationPreset,
495
+ }),
496
+ layer_index: options.layerIndex,
310
497
  },
311
498
  ],
312
499
  allow_duplicate: options.allowDuplicate,
313
500
  },
314
501
  }),
502
+ updateOverlay: (options) => this.request({
503
+ method: "PATCH",
504
+ path: `/projects/${encodeURIComponent(options.projectId)}/timeline/media/${encodeURIComponent(options.timelineItemId)}`,
505
+ query: undefined,
506
+ body: {
507
+ position_preset: normalizeMediaPositionPreset({
508
+ value: options.positionPreset,
509
+ }),
510
+ position_x: options.positionX,
511
+ position_y: options.positionY,
512
+ width_px: options.widthPx,
513
+ height_px: options.heightPx,
514
+ scale: options.scale,
515
+ animation_preset: normalizeMediaAnimationPreset({
516
+ value: options.animationPreset,
517
+ }),
518
+ remove_animations: options.removeAnimations,
519
+ blurred_background: options.blurredBackground,
520
+ },
521
+ }),
522
+ shorts: {
523
+ list: (options) => this.request({
524
+ method: "GET",
525
+ path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/short-suggestions`,
526
+ query: undefined,
527
+ body: undefined,
528
+ }),
529
+ generate: (options) => this.request({
530
+ method: "POST",
531
+ path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/short-suggestions`,
532
+ query: undefined,
533
+ body: {
534
+ content_profile: options.contentProfile,
535
+ auto_trim_silence: options.autoTrimSilence,
536
+ },
537
+ }),
538
+ apply: (options) => this.request({
539
+ method: "POST",
540
+ path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/short-suggestions/${encodeURIComponent(options.suggestionId)}/apply`,
541
+ query: undefined,
542
+ body: {
543
+ project_id: options.projectId,
544
+ caption_style_id: options.captionStyleId,
545
+ mark_saved: options.markSaved,
546
+ allow_unverified_export: options.allowUnverifiedExport,
547
+ automatic_layout: options.automaticLayout,
548
+ },
549
+ }),
550
+ },
315
551
  folders: {
316
552
  list: (options) => this.request({
317
553
  method: "GET",
@@ -349,6 +585,89 @@ export class BlitzReelsClient {
349
585
  }),
350
586
  },
351
587
  };
588
+ this.clips = {
589
+ create: (options) => this.request({
590
+ method: "POST",
591
+ path: "/clips",
592
+ query: undefined,
593
+ body: {
594
+ project_name: options.projectName,
595
+ source: {
596
+ source_type: options.source.sourceType,
597
+ asset_id: options.source.assetId,
598
+ youtube_url: options.source.youtubeUrl,
599
+ },
600
+ selection: {
601
+ selection_mode: options.selection.mode,
602
+ suggestion_id: options.selection.suggestionId,
603
+ start_seconds: options.selection.startSeconds,
604
+ end_seconds: options.selection.endSeconds,
605
+ },
606
+ target: {
607
+ aspect_ratio: options.target.aspectRatio,
608
+ min_duration_seconds: options.target.minDurationSeconds,
609
+ max_duration_seconds: options.target.maxDurationSeconds,
610
+ },
611
+ layout: {
612
+ layout_mode: options.layout.mode,
613
+ content_type_hint: options.layout.contentTypeHint,
614
+ },
615
+ captions: {
616
+ enabled: options.captions.enabled,
617
+ style_id: options.captions.styleId,
618
+ },
619
+ qa: {
620
+ qa_mode: options.qa.mode,
621
+ },
622
+ export: {
623
+ auto_export: options.export.autoExport,
624
+ },
625
+ },
626
+ }),
627
+ get: (options) => this.request({
628
+ method: "GET",
629
+ path: `/clips/${encodeURIComponent(options.clipId)}`,
630
+ query: undefined,
631
+ body: undefined,
632
+ }),
633
+ reselect: (options) => this.request({
634
+ method: "POST",
635
+ path: `/clips/${encodeURIComponent(options.clipId)}/reselect`,
636
+ query: undefined,
637
+ body: {
638
+ selection: {
639
+ selection_mode: options.selection.mode,
640
+ suggestion_id: options.selection.suggestionId,
641
+ start_seconds: options.selection.startSeconds,
642
+ end_seconds: options.selection.endSeconds,
643
+ },
644
+ target: options.target === null || options.target === undefined
645
+ ? null
646
+ : {
647
+ min_duration_seconds: options.target.minDurationSeconds,
648
+ max_duration_seconds: options.target.maxDurationSeconds,
649
+ },
650
+ },
651
+ }),
652
+ repair: (options) => this.request({
653
+ method: "POST",
654
+ path: `/clips/${encodeURIComponent(options.clipId)}/repair`,
655
+ query: undefined,
656
+ body: {
657
+ repair_mode: options.repairMode,
658
+ },
659
+ }),
660
+ export: (options) => this.request({
661
+ method: "POST",
662
+ path: `/clips/${encodeURIComponent(options.clipId)}/export`,
663
+ query: undefined,
664
+ body: {
665
+ resolution: options.resolution,
666
+ format: options.format,
667
+ allow_blocking_qa_bypass: options.allowBlockingQaBypass,
668
+ },
669
+ }),
670
+ };
352
671
  this.text = {
353
672
  add: (options) => this.request({
354
673
  method: "POST",
@@ -358,6 +677,7 @@ export class BlitzReelsClient {
358
677
  kind: "overlay",
359
678
  text: options.text,
360
679
  name: options.name,
680
+ spec: options.spec,
361
681
  start_seconds: options.startSeconds,
362
682
  duration_seconds: options.durationSeconds,
363
683
  layer_index: options.layerIndex,
@@ -375,6 +695,7 @@ export class BlitzReelsClient {
375
695
  text: options.text,
376
696
  name: options.name,
377
697
  spec: options.spec,
698
+ durationSeconds: options.durationSeconds,
378
699
  }),
379
700
  remove: (options) => this.request({
380
701
  method: "DELETE",
@@ -402,6 +723,102 @@ export class BlitzReelsClient {
402
723
  ],
403
724
  },
404
725
  }),
726
+ update: (options) => this.request({
727
+ method: "PATCH",
728
+ path: `/projects/${encodeURIComponent(options.projectId)}/timeline/audio/${encodeURIComponent(options.timelineItemId)}`,
729
+ query: undefined,
730
+ body: {
731
+ duration_seconds: options.durationSeconds,
732
+ volume: options.volume,
733
+ fade_in_seconds: options.fadeInSeconds,
734
+ fade_out_seconds: options.fadeOutSeconds,
735
+ },
736
+ }),
737
+ };
738
+ this.audioLibrary = {
739
+ search: (options) => this.request({
740
+ method: "GET",
741
+ path: "/audio-library/search",
742
+ query: {
743
+ query: options.query,
744
+ provider: options.provider,
745
+ license: options.license,
746
+ audio_type: options.audioType,
747
+ min_duration_seconds: options.minDurationSeconds,
748
+ max_duration_seconds: options.maxDurationSeconds,
749
+ limit: options.limit,
750
+ page: options.page,
751
+ },
752
+ body: undefined,
753
+ }),
754
+ importAsset: (options) => this.request({
755
+ method: "POST",
756
+ path: "/audio-library/import",
757
+ query: undefined,
758
+ body: {
759
+ provider: options.provider,
760
+ external_id: options.externalId,
761
+ folder_id: options.folderId,
762
+ project_id: options.projectId,
763
+ start_seconds: options.startSeconds,
764
+ duration_seconds: options.durationSeconds,
765
+ volume: options.volume,
766
+ fade_in_seconds: options.fadeInSeconds,
767
+ fade_out_seconds: options.fadeOutSeconds,
768
+ loop: options.loop,
769
+ audio_type: options.audioType,
770
+ },
771
+ }),
772
+ };
773
+ this.stockMedia = {
774
+ search: (options) => this.request({
775
+ method: "GET",
776
+ path: "/workspace/stock-media/search",
777
+ query: {
778
+ query: options.query,
779
+ asset_type: options.assetType,
780
+ provider: options.provider,
781
+ orientation: options.orientation,
782
+ page: options.page,
783
+ limit: options.limit,
784
+ },
785
+ body: undefined,
786
+ }),
787
+ importAsset: (options) => this.request({
788
+ method: "POST",
789
+ path: "/workspace/stock-media/import",
790
+ query: undefined,
791
+ body: {
792
+ provider: options.provider,
793
+ provider_asset_id: options.providerAssetId,
794
+ asset_type: options.assetType,
795
+ variant_id: options.variantId,
796
+ folder_id: options.folderId,
797
+ audio_type: options.audioType,
798
+ },
799
+ }),
800
+ };
801
+ this.library = {
802
+ search: (options) => this.request({
803
+ method: "GET",
804
+ path: "/library/broll/search",
805
+ query: {
806
+ query: options.query,
807
+ asset_type: options.assetType,
808
+ audio_type: options.audioType,
809
+ limit: options.limit,
810
+ offset: options.offset,
811
+ },
812
+ body: undefined,
813
+ }),
814
+ importAsset: (options) => this.request({
815
+ method: "POST",
816
+ path: `/library/broll/${encodeURIComponent(options.libraryAssetId)}/import`,
817
+ query: undefined,
818
+ body: {
819
+ folder_id: options.folderId,
820
+ },
821
+ }),
405
822
  };
406
823
  this.silence = {
407
824
  plan: (options) => this.request({
@@ -410,6 +827,7 @@ export class BlitzReelsClient {
410
827
  query: undefined,
411
828
  body: {
412
829
  timeline_item_id: options.timelineItemId,
830
+ all_media_items: options.allMediaItems,
413
831
  padding_ms: options.paddingMs,
414
832
  silence_threshold_db: options.silenceThresholdDb,
415
833
  min_silence_duration_seconds: options.minSilenceDurationSeconds,
@@ -423,6 +841,7 @@ export class BlitzReelsClient {
423
841
  query: undefined,
424
842
  body: {
425
843
  timeline_item_id: options.timelineItemId,
844
+ all_media_items: options.allMediaItems,
426
845
  padding_ms: options.paddingMs,
427
846
  silence_threshold_db: options.silenceThresholdDb,
428
847
  min_silence_duration_seconds: options.minSilenceDurationSeconds,
@@ -457,12 +876,117 @@ export class BlitzReelsClient {
457
876
  }),
458
877
  };
459
878
  this.captions = {
879
+ listWords: (options) => this.request({
880
+ method: "GET",
881
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words`,
882
+ query: {
883
+ timeline_item_id: options.timelineItemId,
884
+ match_text: options.matchText,
885
+ limit: options.limit,
886
+ offset: options.offset,
887
+ },
888
+ body: undefined,
889
+ }),
890
+ updateWordText: (options) => this.request({
891
+ method: "POST",
892
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/text`,
893
+ query: undefined,
894
+ body: {
895
+ word_id: options.wordId,
896
+ new_text: options.newText,
897
+ },
898
+ }),
899
+ batchUpdateWordText: (options) => this.request({
900
+ method: "POST",
901
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/batch-text`,
902
+ query: undefined,
903
+ body: {
904
+ updates: options.updates,
905
+ },
906
+ }),
907
+ setWordStyle: (options) => this.request({
908
+ method: "POST",
909
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/style`,
910
+ query: undefined,
911
+ body: {
912
+ style: options.style,
913
+ clear_existing: options.clearExisting,
914
+ word_ids: options.wordIds,
915
+ match_text: options.matchText,
916
+ match_pattern: options.matchPattern,
917
+ timeline_item_id: options.timelineItemId,
918
+ all: options.all,
919
+ from_seconds: options.fromSeconds,
920
+ to_seconds: options.toSeconds,
921
+ },
922
+ }),
923
+ setWordEmphasis: (options) => this.request({
924
+ method: "POST",
925
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/emphasis`,
926
+ query: undefined,
927
+ body: {
928
+ emphasis: options.emphasis,
929
+ word_ids: options.wordIds,
930
+ match_text: options.matchText,
931
+ match_pattern: options.matchPattern,
932
+ timeline_item_id: options.timelineItemId,
933
+ all: options.all,
934
+ from_seconds: options.fromSeconds,
935
+ to_seconds: options.toSeconds,
936
+ },
937
+ }),
938
+ deleteWords: (options) => this.request({
939
+ method: "POST",
940
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/delete`,
941
+ query: undefined,
942
+ body: { word_ids: options.wordIds },
943
+ }),
944
+ delete: (options) => this.request({
945
+ method: "POST",
946
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/delete`,
947
+ query: undefined,
948
+ body: buildCaptionTrackSelectorBody({ options }),
949
+ }),
950
+ hide: (options) => this.request({
951
+ method: "POST",
952
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/hide`,
953
+ query: undefined,
954
+ body: buildCaptionTrackSelectorBody({ options }),
955
+ }),
956
+ show: (options) => this.request({
957
+ method: "POST",
958
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/show`,
959
+ query: undefined,
960
+ body: buildCaptionTrackSelectorBody({ options }),
961
+ }),
962
+ mergeWords: (options) => this.request({
963
+ method: "POST",
964
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/merge`,
965
+ query: undefined,
966
+ body: { word_ids: options.wordIds, text: options.text },
967
+ }),
968
+ splitWord: (options) => this.request({
969
+ method: "POST",
970
+ path: `/projects/${encodeURIComponent(options.projectId)}/captions/words/split`,
971
+ query: undefined,
972
+ body: { word_id: options.wordId, words: options.words },
973
+ }),
460
974
  listThemes: () => this.request({
461
975
  method: "GET",
462
976
  path: "/caption-themes",
463
977
  query: undefined,
464
978
  body: undefined,
465
979
  }),
980
+ updateTheme: (options) => this.request({
981
+ method: "PATCH",
982
+ path: `/caption-themes/${encodeURIComponent(options.themeId)}`,
983
+ query: undefined,
984
+ body: {
985
+ name: options.name,
986
+ description: options.description,
987
+ settings: options.settings,
988
+ },
989
+ }),
466
990
  setDefaultTheme: (options) => this.request({
467
991
  method: "POST",
468
992
  path: `/caption-themes/${encodeURIComponent(options.themeId)}/set-default`,
@@ -498,7 +1022,6 @@ export class BlitzReelsClient {
498
1022
  body: {
499
1023
  resolution: options.resolution,
500
1024
  format: options.format,
501
- include_captions: options.includeCaptions,
502
1025
  },
503
1026
  }),
504
1027
  get: (options) => this.request({
@@ -602,6 +1125,7 @@ export class BlitzReelsClient {
602
1125
  body: {
603
1126
  name: options.name,
604
1127
  spec,
1128
+ duration_seconds: options.durationSeconds,
605
1129
  },
606
1130
  });
607
1131
  }