@fishjam-cloud/js-server-sdk 0.29.0 → 0.30.1

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-3EYSX4WM.mjs";
3
+ } from "./chunk-NEIJH3YA.mjs";
4
4
 
5
5
  // ../fishjam-openapi/dist/index.js
6
6
  var BASE_PATH = "https://fishjam.io/api/v1/connect".replace(/\/+$/, "");
@@ -323,7 +323,8 @@ function MoqAccessConfigToJSONTyped(value, ignoreDiscriminator = false) {
323
323
  }
324
324
  return {
325
325
  "publishPath": value["publishPath"],
326
- "subscribePath": value["subscribePath"]
326
+ "subscribePath": value["subscribePath"],
327
+ "ttl": value["ttl"]
327
328
  };
328
329
  }
329
330
  var MoQApi = class extends BaseAPI {
@@ -368,9 +369,336 @@ var MoQApi = class extends BaseAPI {
368
369
  return await response.value();
369
370
  }
370
371
  };
372
+ function RecordingSourceFromJSON(json) {
373
+ return RecordingSourceFromJSONTyped(json, false);
374
+ }
375
+ function RecordingSourceFromJSONTyped(json, ignoreDiscriminator) {
376
+ if (json == null) {
377
+ return json;
378
+ }
379
+ return {
380
+ "compositionURL": json["compositionURL"],
381
+ "outputId": json["outputId"],
382
+ "scaleRatio": json["scaleRatio"] == null ? void 0 : json["scaleRatio"]
383
+ };
384
+ }
385
+ function RecordingSourceToJSON(json) {
386
+ return RecordingSourceToJSONTyped(json, false);
387
+ }
388
+ function RecordingSourceToJSONTyped(value, ignoreDiscriminator = false) {
389
+ if (value == null) {
390
+ return value;
391
+ }
392
+ return {
393
+ "compositionURL": value["compositionURL"],
394
+ "outputId": value["outputId"],
395
+ "scaleRatio": value["scaleRatio"]
396
+ };
397
+ }
398
+ function RecordingConfigToJSON(json) {
399
+ return RecordingConfigToJSONTyped(json, false);
400
+ }
401
+ function RecordingConfigToJSONTyped(value, ignoreDiscriminator = false) {
402
+ if (value == null) {
403
+ return value;
404
+ }
405
+ return {
406
+ "metadata": value["metadata"],
407
+ "source": RecordingSourceToJSON(value["source"])
408
+ };
409
+ }
410
+ function RecordingStatusFromJSON(json) {
411
+ return RecordingStatusFromJSONTyped(json, false);
412
+ }
413
+ function RecordingStatusFromJSONTyped(json, ignoreDiscriminator) {
414
+ return json;
415
+ }
416
+ function RecordingFileFromJSON(json) {
417
+ return RecordingFileFromJSONTyped(json, false);
418
+ }
419
+ function RecordingFileFromJSONTyped(json, ignoreDiscriminator) {
420
+ if (json == null) {
421
+ return json;
422
+ }
423
+ return {
424
+ "url": json["url"]
425
+ };
426
+ }
427
+ function RecordingFromJSON(json) {
428
+ return RecordingFromJSONTyped(json, false);
429
+ }
430
+ function RecordingFromJSONTyped(json, ignoreDiscriminator) {
431
+ if (json == null) {
432
+ return json;
433
+ }
434
+ return {
435
+ "files": json["files"].map(RecordingFileFromJSON),
436
+ "id": json["id"],
437
+ "metadata": json["metadata"] == null ? void 0 : json["metadata"],
438
+ "source": RecordingSourceFromJSON(json["source"]),
439
+ "status": RecordingStatusFromJSON(json["status"])
440
+ };
441
+ }
442
+ function RecordingDetailsResponseFromJSON(json) {
443
+ return RecordingDetailsResponseFromJSONTyped(json, false);
444
+ }
445
+ function RecordingDetailsResponseFromJSONTyped(json, ignoreDiscriminator) {
446
+ if (json == null) {
447
+ return json;
448
+ }
449
+ return {
450
+ "data": RecordingFromJSON(json["data"])
451
+ };
452
+ }
453
+ function RecordingListResponseFromJSON(json) {
454
+ return RecordingListResponseFromJSONTyped(json, false);
455
+ }
456
+ function RecordingListResponseFromJSONTyped(json, ignoreDiscriminator) {
457
+ if (json == null) {
458
+ return json;
459
+ }
460
+ return {
461
+ "data": json["data"].map(RecordingFromJSON)
462
+ };
463
+ }
464
+ var RecordingsApi = class extends BaseAPI {
465
+ /**
466
+ * Creates request options for createRecording without sending the request
467
+ */
468
+ async createRecordingRequestOpts(requestParameters) {
469
+ if (requestParameters["recordingConfig"] == null) {
470
+ throw new RequiredError(
471
+ "recordingConfig",
472
+ 'Required parameter "recordingConfig" was null or undefined when calling createRecording().'
473
+ );
474
+ }
475
+ const queryParameters = {};
476
+ const headerParameters = {};
477
+ headerParameters["Content-Type"] = "application/json";
478
+ if (this.configuration && this.configuration.accessToken) {
479
+ const token = this.configuration.accessToken;
480
+ const tokenString = await token("management_token", []);
481
+ if (tokenString) {
482
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
483
+ }
484
+ }
485
+ let urlPath = `/recordings`;
486
+ return {
487
+ path: urlPath,
488
+ method: "POST",
489
+ headers: headerParameters,
490
+ query: queryParameters,
491
+ body: RecordingConfigToJSON(requestParameters["recordingConfig"])
492
+ };
493
+ }
494
+ /**
495
+ * Create a recording resource. Capturing starts synchronously, so it is returned with status `active`.
496
+ * Create a recording
497
+ */
498
+ async createRecordingRaw(requestParameters, initOverrides) {
499
+ const requestOptions = await this.createRecordingRequestOpts(requestParameters);
500
+ const response = await this.request(requestOptions, initOverrides);
501
+ return new JSONApiResponse(response, (jsonValue) => RecordingDetailsResponseFromJSON(jsonValue));
502
+ }
503
+ /**
504
+ * Create a recording resource. Capturing starts synchronously, so it is returned with status `active`.
505
+ * Create a recording
506
+ */
507
+ async createRecording(requestParameters, initOverrides) {
508
+ const response = await this.createRecordingRaw(requestParameters, initOverrides);
509
+ return await response.value();
510
+ }
511
+ /**
512
+ * Creates request options for deleteRecording without sending the request
513
+ */
514
+ async deleteRecordingRequestOpts(requestParameters) {
515
+ if (requestParameters["recordingId"] == null) {
516
+ throw new RequiredError(
517
+ "recordingId",
518
+ 'Required parameter "recordingId" was null or undefined when calling deleteRecording().'
519
+ );
520
+ }
521
+ const queryParameters = {};
522
+ const headerParameters = {};
523
+ if (this.configuration && this.configuration.accessToken) {
524
+ const token = this.configuration.accessToken;
525
+ const tokenString = await token("management_token", []);
526
+ if (tokenString) {
527
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
528
+ }
529
+ }
530
+ let urlPath = `/recordings/{recording_id}`;
531
+ urlPath = urlPath.replace("{recording_id}", encodeURIComponent(String(requestParameters["recordingId"])));
532
+ return {
533
+ path: urlPath,
534
+ method: "DELETE",
535
+ headers: headerParameters,
536
+ query: queryParameters
537
+ };
538
+ }
539
+ /**
540
+ * Delete a recording by id. The recording disappears from the API immediately; its stored media is removed asynchronously by a background job. A recording that is still `active` cannot be deleted — wait for it to finish or fail.
541
+ * Delete a recording
542
+ */
543
+ async deleteRecordingRaw(requestParameters, initOverrides) {
544
+ const requestOptions = await this.deleteRecordingRequestOpts(requestParameters);
545
+ const response = await this.request(requestOptions, initOverrides);
546
+ return new VoidApiResponse(response);
547
+ }
548
+ /**
549
+ * Delete a recording by id. The recording disappears from the API immediately; its stored media is removed asynchronously by a background job. A recording that is still `active` cannot be deleted — wait for it to finish or fail.
550
+ * Delete a recording
551
+ */
552
+ async deleteRecording(requestParameters, initOverrides) {
553
+ await this.deleteRecordingRaw(requestParameters, initOverrides);
554
+ }
555
+ /**
556
+ * Creates request options for getRecording without sending the request
557
+ */
558
+ async getRecordingRequestOpts(requestParameters) {
559
+ if (requestParameters["recordingId"] == null) {
560
+ throw new RequiredError(
561
+ "recordingId",
562
+ 'Required parameter "recordingId" was null or undefined when calling getRecording().'
563
+ );
564
+ }
565
+ const queryParameters = {};
566
+ const headerParameters = {};
567
+ if (this.configuration && this.configuration.accessToken) {
568
+ const token = this.configuration.accessToken;
569
+ const tokenString = await token("management_token", []);
570
+ if (tokenString) {
571
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
572
+ }
573
+ }
574
+ let urlPath = `/recordings/{recording_id}`;
575
+ urlPath = urlPath.replace("{recording_id}", encodeURIComponent(String(requestParameters["recordingId"])));
576
+ return {
577
+ path: urlPath,
578
+ method: "GET",
579
+ headers: headerParameters,
580
+ query: queryParameters
581
+ };
582
+ }
583
+ /**
584
+ * Get a recording by id.
585
+ * Get a recording
586
+ */
587
+ async getRecordingRaw(requestParameters, initOverrides) {
588
+ const requestOptions = await this.getRecordingRequestOpts(requestParameters);
589
+ const response = await this.request(requestOptions, initOverrides);
590
+ return new JSONApiResponse(response, (jsonValue) => RecordingDetailsResponseFromJSON(jsonValue));
591
+ }
592
+ /**
593
+ * Get a recording by id.
594
+ * Get a recording
595
+ */
596
+ async getRecording(requestParameters, initOverrides) {
597
+ const response = await this.getRecordingRaw(requestParameters, initOverrides);
598
+ return await response.value();
599
+ }
600
+ /**
601
+ * Creates request options for listRecordings without sending the request
602
+ */
603
+ async listRecordingsRequestOpts(requestParameters) {
604
+ const queryParameters = {};
605
+ if (requestParameters["metadata"] != null) {
606
+ for (let key of Object.keys(requestParameters["metadata"])) {
607
+ queryParameters[key] = requestParameters["metadata"][key];
608
+ }
609
+ }
610
+ if (requestParameters["status"] != null) {
611
+ queryParameters["status"] = requestParameters["status"];
612
+ }
613
+ const headerParameters = {};
614
+ if (this.configuration && this.configuration.accessToken) {
615
+ const token = this.configuration.accessToken;
616
+ const tokenString = await token("management_token", []);
617
+ if (tokenString) {
618
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
619
+ }
620
+ }
621
+ let urlPath = `/recordings`;
622
+ return {
623
+ path: urlPath,
624
+ method: "GET",
625
+ headers: headerParameters,
626
+ query: queryParameters
627
+ };
628
+ }
629
+ /**
630
+ * List recordings for the tenant, optionally filtered by metadata and status.
631
+ * List recordings
632
+ */
633
+ async listRecordingsRaw(requestParameters, initOverrides) {
634
+ const requestOptions = await this.listRecordingsRequestOpts(requestParameters);
635
+ const response = await this.request(requestOptions, initOverrides);
636
+ return new JSONApiResponse(response, (jsonValue) => RecordingListResponseFromJSON(jsonValue));
637
+ }
638
+ /**
639
+ * List recordings for the tenant, optionally filtered by metadata and status.
640
+ * List recordings
641
+ */
642
+ async listRecordings(requestParameters = {}, initOverrides) {
643
+ const response = await this.listRecordingsRaw(requestParameters, initOverrides);
644
+ return await response.value();
645
+ }
646
+ /**
647
+ * Creates request options for stopRecording without sending the request
648
+ */
649
+ async stopRecordingRequestOpts(requestParameters) {
650
+ if (requestParameters["recordingId"] == null) {
651
+ throw new RequiredError(
652
+ "recordingId",
653
+ 'Required parameter "recordingId" was null or undefined when calling stopRecording().'
654
+ );
655
+ }
656
+ const queryParameters = {};
657
+ const headerParameters = {};
658
+ if (this.configuration && this.configuration.accessToken) {
659
+ const token = this.configuration.accessToken;
660
+ const tokenString = await token("management_token", []);
661
+ if (tokenString) {
662
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
663
+ }
664
+ }
665
+ let urlPath = `/recordings/{recording_id}/stop`;
666
+ urlPath = urlPath.replace("{recording_id}", encodeURIComponent(String(requestParameters["recordingId"])));
667
+ return {
668
+ path: urlPath,
669
+ method: "POST",
670
+ headers: headerParameters,
671
+ query: queryParameters
672
+ };
673
+ }
674
+ /**
675
+ * Request the recorder to stop capturing. Finalization is asynchronous: the recording stays `active` until the capture is finalized, then becomes `finished`. Stopping a recording that is no longer active is a no-op.
676
+ * Stop a recording
677
+ */
678
+ async stopRecordingRaw(requestParameters, initOverrides) {
679
+ const requestOptions = await this.stopRecordingRequestOpts(requestParameters);
680
+ const response = await this.request(requestOptions, initOverrides);
681
+ return new JSONApiResponse(response, (jsonValue) => RecordingDetailsResponseFromJSON(jsonValue));
682
+ }
683
+ /**
684
+ * Request the recorder to stop capturing. Finalization is asynchronous: the recording stays `active` until the capture is finalized, then becomes `finished`. Stopping a recording that is no longer active is a no-op.
685
+ * Stop a recording
686
+ */
687
+ async stopRecording(requestParameters, initOverrides) {
688
+ const response = await this.stopRecordingRaw(requestParameters, initOverrides);
689
+ return await response.value();
690
+ }
691
+ };
692
+ var AudioSampleRate = {
693
+ NUMBER_16000: 16e3,
694
+ NUMBER_24000: 24e3
695
+ };
371
696
  function AudioSampleRateToJSON(value) {
372
697
  return value;
373
698
  }
699
+ var AudioFormat = {
700
+ Pcm16: "pcm16"
701
+ };
374
702
  function AudioFormatToJSON(value) {
375
703
  return value;
376
704
  }
@@ -386,6 +714,10 @@ function AgentOutputToJSONTyped(value, ignoreDiscriminator = false) {
386
714
  "audioSampleRate": AudioSampleRateToJSON(value["audioSampleRate"])
387
715
  };
388
716
  }
717
+ var SubscribeMode = {
718
+ Auto: "auto",
719
+ Manual: "manual"
720
+ };
389
721
  function SubscribeModeFromJSON(json) {
390
722
  return SubscribeModeFromJSONTyped(json, false);
391
723
  }
@@ -428,6 +760,7 @@ function PeerOptionsVapiToJSONTyped(value, ignoreDiscriminator = false) {
428
760
  }
429
761
  return {
430
762
  "apiKey": value["apiKey"],
763
+ "autoClose": value["autoClose"],
431
764
  "callId": value["callId"],
432
765
  "subscribeMode": SubscribeModeToJSON(value["subscribeMode"])
433
766
  };
@@ -1369,6 +1702,72 @@ function ViewerFromJSONTyped(json, ignoreDiscriminator) {
1369
1702
  "token": json["token"]
1370
1703
  };
1371
1704
  }
1705
+ function TrackForwardingToJSON(json) {
1706
+ return TrackForwardingToJSONTyped(json, false);
1707
+ }
1708
+ function TrackForwardingToJSONTyped(value, ignoreDiscriminator = false) {
1709
+ if (value == null) {
1710
+ return value;
1711
+ }
1712
+ return {
1713
+ "compositionURL": value["compositionURL"],
1714
+ "selector": value["selector"]
1715
+ };
1716
+ }
1717
+ var TrackForwardingsApi = class extends BaseAPI {
1718
+ /**
1719
+ * Creates request options for createTrackForwarding without sending the request
1720
+ */
1721
+ async createTrackForwardingRequestOpts(requestParameters) {
1722
+ if (requestParameters["roomId"] == null) {
1723
+ throw new RequiredError(
1724
+ "roomId",
1725
+ 'Required parameter "roomId" was null or undefined when calling createTrackForwarding().'
1726
+ );
1727
+ }
1728
+ if (requestParameters["trackForwarding"] == null) {
1729
+ throw new RequiredError(
1730
+ "trackForwarding",
1731
+ 'Required parameter "trackForwarding" was null or undefined when calling createTrackForwarding().'
1732
+ );
1733
+ }
1734
+ const queryParameters = {};
1735
+ const headerParameters = {};
1736
+ headerParameters["Content-Type"] = "application/json";
1737
+ if (this.configuration && this.configuration.accessToken) {
1738
+ const token = this.configuration.accessToken;
1739
+ const tokenString = await token("management_token", []);
1740
+ if (tokenString) {
1741
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
1742
+ }
1743
+ }
1744
+ let urlPath = `/room/{room_id}/track_forwardings`;
1745
+ urlPath = urlPath.replace("{room_id}", encodeURIComponent(String(requestParameters["roomId"])));
1746
+ return {
1747
+ path: urlPath,
1748
+ method: "POST",
1749
+ headers: headerParameters,
1750
+ query: queryParameters,
1751
+ body: TrackForwardingToJSON(requestParameters["trackForwarding"])
1752
+ };
1753
+ }
1754
+ /**
1755
+ * Forward a room\'s tracks into an external composition.
1756
+ * Create a track forwarding
1757
+ */
1758
+ async createTrackForwardingRaw(requestParameters, initOverrides) {
1759
+ const requestOptions = await this.createTrackForwardingRequestOpts(requestParameters);
1760
+ const response = await this.request(requestOptions, initOverrides);
1761
+ return new VoidApiResponse(response);
1762
+ }
1763
+ /**
1764
+ * Forward a room\'s tracks into an external composition.
1765
+ * Create a track forwarding
1766
+ */
1767
+ async createTrackForwarding(requestParameters, initOverrides) {
1768
+ await this.createTrackForwardingRaw(requestParameters, initOverrides);
1769
+ }
1770
+ };
1372
1771
  function ViewerDetailsResponseFromJSON(json) {
1373
1772
  return ViewerDetailsResponseFromJSONTyped(json, false);
1374
1773
  }
@@ -2515,13 +2914,62 @@ function serverMessage_VadNotification_StatusToJSON(object) {
2515
2914
  return "UNRECOGNIZED";
2516
2915
  }
2517
2916
  }
2518
- function createBaseServerMessage() {
2519
- return {
2520
- authenticated: void 0,
2521
- authRequest: void 0,
2522
- subscribeRequest: void 0,
2523
- subscribeResponse: void 0,
2524
- roomCreated: void 0,
2917
+ var ServerMessage_RecordingStatusChanged_Status = /* @__PURE__ */ ((ServerMessage_RecordingStatusChanged_Status2) => {
2918
+ ServerMessage_RecordingStatusChanged_Status2[ServerMessage_RecordingStatusChanged_Status2["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
2919
+ ServerMessage_RecordingStatusChanged_Status2[ServerMessage_RecordingStatusChanged_Status2["STATUS_ACTIVE"] = 1] = "STATUS_ACTIVE";
2920
+ ServerMessage_RecordingStatusChanged_Status2[ServerMessage_RecordingStatusChanged_Status2["STATUS_FINISHED"] = 2] = "STATUS_FINISHED";
2921
+ ServerMessage_RecordingStatusChanged_Status2[ServerMessage_RecordingStatusChanged_Status2["STATUS_AVAILABLE"] = 3] = "STATUS_AVAILABLE";
2922
+ ServerMessage_RecordingStatusChanged_Status2[ServerMessage_RecordingStatusChanged_Status2["STATUS_FAILED"] = 4] = "STATUS_FAILED";
2923
+ ServerMessage_RecordingStatusChanged_Status2[ServerMessage_RecordingStatusChanged_Status2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
2924
+ return ServerMessage_RecordingStatusChanged_Status2;
2925
+ })(ServerMessage_RecordingStatusChanged_Status || {});
2926
+ function serverMessage_RecordingStatusChanged_StatusFromJSON(object) {
2927
+ switch (object) {
2928
+ case 0:
2929
+ case "STATUS_UNSPECIFIED":
2930
+ return 0;
2931
+ case 1:
2932
+ case "STATUS_ACTIVE":
2933
+ return 1;
2934
+ case 2:
2935
+ case "STATUS_FINISHED":
2936
+ return 2;
2937
+ case 3:
2938
+ case "STATUS_AVAILABLE":
2939
+ return 3;
2940
+ case 4:
2941
+ case "STATUS_FAILED":
2942
+ return 4;
2943
+ case -1:
2944
+ case "UNRECOGNIZED":
2945
+ default:
2946
+ return -1;
2947
+ }
2948
+ }
2949
+ function serverMessage_RecordingStatusChanged_StatusToJSON(object) {
2950
+ switch (object) {
2951
+ case 0:
2952
+ return "STATUS_UNSPECIFIED";
2953
+ case 1:
2954
+ return "STATUS_ACTIVE";
2955
+ case 2:
2956
+ return "STATUS_FINISHED";
2957
+ case 3:
2958
+ return "STATUS_AVAILABLE";
2959
+ case 4:
2960
+ return "STATUS_FAILED";
2961
+ case -1:
2962
+ default:
2963
+ return "UNRECOGNIZED";
2964
+ }
2965
+ }
2966
+ function createBaseServerMessage() {
2967
+ return {
2968
+ authenticated: void 0,
2969
+ authRequest: void 0,
2970
+ subscribeRequest: void 0,
2971
+ subscribeResponse: void 0,
2972
+ roomCreated: void 0,
2525
2973
  roomDeleted: void 0,
2526
2974
  roomCrashed: void 0,
2527
2975
  peerConnected: void 0,
@@ -2542,6 +2990,7 @@ function createBaseServerMessage() {
2542
2990
  viewerDisconnected: void 0,
2543
2991
  streamerConnected: void 0,
2544
2992
  streamerDisconnected: void 0,
2993
+ recordingStatusChanged: void 0,
2545
2994
  notificationBatch: void 0,
2546
2995
  streamConnected: void 0,
2547
2996
  streamDisconnected: void 0,
@@ -2628,6 +3077,9 @@ var ServerMessage = {
2628
3077
  if (message.streamerDisconnected !== void 0) {
2629
3078
  ServerMessage_StreamerDisconnected.encode(message.streamerDisconnected, writer.uint32(218).fork()).join();
2630
3079
  }
3080
+ if (message.recordingStatusChanged !== void 0) {
3081
+ ServerMessage_RecordingStatusChanged.encode(message.recordingStatusChanged, writer.uint32(274).fork()).join();
3082
+ }
2631
3083
  if (message.notificationBatch !== void 0) {
2632
3084
  ServerMessage_NotificationBatch.encode(message.notificationBatch, writer.uint32(266).fork()).join();
2633
3085
  }
@@ -2833,6 +3285,13 @@ var ServerMessage = {
2833
3285
  message.streamerDisconnected = ServerMessage_StreamerDisconnected.decode(reader, reader.uint32());
2834
3286
  continue;
2835
3287
  }
3288
+ case 34: {
3289
+ if (tag !== 274) {
3290
+ break;
3291
+ }
3292
+ message.recordingStatusChanged = ServerMessage_RecordingStatusChanged.decode(reader, reader.uint32());
3293
+ continue;
3294
+ }
2836
3295
  case 33: {
2837
3296
  if (tag !== 266) {
2838
3297
  break;
@@ -2917,6 +3376,7 @@ var ServerMessage = {
2917
3376
  viewerDisconnected: isSet2(object.viewerDisconnected) ? ServerMessage_ViewerDisconnected.fromJSON(object.viewerDisconnected) : void 0,
2918
3377
  streamerConnected: isSet2(object.streamerConnected) ? ServerMessage_StreamerConnected.fromJSON(object.streamerConnected) : void 0,
2919
3378
  streamerDisconnected: isSet2(object.streamerDisconnected) ? ServerMessage_StreamerDisconnected.fromJSON(object.streamerDisconnected) : void 0,
3379
+ recordingStatusChanged: isSet2(object.recordingStatusChanged) ? ServerMessage_RecordingStatusChanged.fromJSON(object.recordingStatusChanged) : void 0,
2920
3380
  notificationBatch: isSet2(object.notificationBatch) ? ServerMessage_NotificationBatch.fromJSON(object.notificationBatch) : void 0,
2921
3381
  streamConnected: isSet2(object.streamConnected) ? ServerMessage_StreamConnected.fromJSON(object.streamConnected) : void 0,
2922
3382
  streamDisconnected: isSet2(object.streamDisconnected) ? ServerMessage_StreamDisconnected.fromJSON(object.streamDisconnected) : void 0,
@@ -3003,6 +3463,9 @@ var ServerMessage = {
3003
3463
  if (message.streamerDisconnected !== void 0) {
3004
3464
  obj.streamerDisconnected = ServerMessage_StreamerDisconnected.toJSON(message.streamerDisconnected);
3005
3465
  }
3466
+ if (message.recordingStatusChanged !== void 0) {
3467
+ obj.recordingStatusChanged = ServerMessage_RecordingStatusChanged.toJSON(message.recordingStatusChanged);
3468
+ }
3006
3469
  if (message.notificationBatch !== void 0) {
3007
3470
  obj.notificationBatch = ServerMessage_NotificationBatch.toJSON(message.notificationBatch);
3008
3471
  }
@@ -3056,6 +3519,7 @@ var ServerMessage = {
3056
3519
  message.viewerDisconnected = object.viewerDisconnected !== void 0 && object.viewerDisconnected !== null ? ServerMessage_ViewerDisconnected.fromPartial(object.viewerDisconnected) : void 0;
3057
3520
  message.streamerConnected = object.streamerConnected !== void 0 && object.streamerConnected !== null ? ServerMessage_StreamerConnected.fromPartial(object.streamerConnected) : void 0;
3058
3521
  message.streamerDisconnected = object.streamerDisconnected !== void 0 && object.streamerDisconnected !== null ? ServerMessage_StreamerDisconnected.fromPartial(object.streamerDisconnected) : void 0;
3522
+ message.recordingStatusChanged = object.recordingStatusChanged !== void 0 && object.recordingStatusChanged !== null ? ServerMessage_RecordingStatusChanged.fromPartial(object.recordingStatusChanged) : void 0;
3059
3523
  message.notificationBatch = object.notificationBatch !== void 0 && object.notificationBatch !== null ? ServerMessage_NotificationBatch.fromPartial(object.notificationBatch) : void 0;
3060
3524
  message.streamConnected = object.streamConnected !== void 0 && object.streamConnected !== null ? ServerMessage_StreamConnected.fromPartial(object.streamConnected) : void 0;
3061
3525
  message.streamDisconnected = object.streamDisconnected !== void 0 && object.streamDisconnected !== null ? ServerMessage_StreamDisconnected.fromPartial(object.streamDisconnected) : void 0;
@@ -5363,6 +5827,89 @@ var ServerMessage_StreamerDisconnected = {
5363
5827
  return message;
5364
5828
  }
5365
5829
  };
5830
+ function createBaseServerMessage_RecordingStatusChanged() {
5831
+ return { recordingId: "", status: 0, metadata: "" };
5832
+ }
5833
+ var ServerMessage_RecordingStatusChanged = {
5834
+ encode(message, writer = new BinaryWriter()) {
5835
+ if (message.recordingId !== "") {
5836
+ writer.uint32(10).string(message.recordingId);
5837
+ }
5838
+ if (message.status !== 0) {
5839
+ writer.uint32(16).int32(message.status);
5840
+ }
5841
+ if (message.metadata !== "") {
5842
+ writer.uint32(26).string(message.metadata);
5843
+ }
5844
+ return writer;
5845
+ },
5846
+ decode(input, length) {
5847
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
5848
+ let end = length === void 0 ? reader.len : reader.pos + length;
5849
+ const message = createBaseServerMessage_RecordingStatusChanged();
5850
+ while (reader.pos < end) {
5851
+ const tag = reader.uint32();
5852
+ switch (tag >>> 3) {
5853
+ case 1: {
5854
+ if (tag !== 10) {
5855
+ break;
5856
+ }
5857
+ message.recordingId = reader.string();
5858
+ continue;
5859
+ }
5860
+ case 2: {
5861
+ if (tag !== 16) {
5862
+ break;
5863
+ }
5864
+ message.status = reader.int32();
5865
+ continue;
5866
+ }
5867
+ case 3: {
5868
+ if (tag !== 26) {
5869
+ break;
5870
+ }
5871
+ message.metadata = reader.string();
5872
+ continue;
5873
+ }
5874
+ }
5875
+ if ((tag & 7) === 4 || tag === 0) {
5876
+ break;
5877
+ }
5878
+ reader.skip(tag & 7);
5879
+ }
5880
+ return message;
5881
+ },
5882
+ fromJSON(object) {
5883
+ return {
5884
+ recordingId: isSet2(object.recordingId) ? globalThis.String(object.recordingId) : "",
5885
+ status: isSet2(object.status) ? serverMessage_RecordingStatusChanged_StatusFromJSON(object.status) : 0,
5886
+ metadata: isSet2(object.metadata) ? globalThis.String(object.metadata) : ""
5887
+ };
5888
+ },
5889
+ toJSON(message) {
5890
+ const obj = {};
5891
+ if (message.recordingId !== "") {
5892
+ obj.recordingId = message.recordingId;
5893
+ }
5894
+ if (message.status !== 0) {
5895
+ obj.status = serverMessage_RecordingStatusChanged_StatusToJSON(message.status);
5896
+ }
5897
+ if (message.metadata !== "") {
5898
+ obj.metadata = message.metadata;
5899
+ }
5900
+ return obj;
5901
+ },
5902
+ create(base) {
5903
+ return ServerMessage_RecordingStatusChanged.fromPartial(base ?? {});
5904
+ },
5905
+ fromPartial(object) {
5906
+ const message = createBaseServerMessage_RecordingStatusChanged();
5907
+ message.recordingId = object.recordingId ?? "";
5908
+ message.status = object.status ?? 0;
5909
+ message.metadata = object.metadata ?? "";
5910
+ return message;
5911
+ }
5912
+ };
5366
5913
  function createBaseServerMessage_NotificationBatch() {
5367
5914
  return { notifications: [] };
5368
5915
  }
@@ -6293,12 +6840,25 @@ function isSet3(value) {
6293
6840
  // src/ws_notifier.ts
6294
6841
  import { EventEmitter } from "events";
6295
6842
 
6843
+ // src/utils.ts
6844
+ import { readFile } from "node:fs/promises";
6845
+
6296
6846
  // src/exceptions/index.ts
6297
6847
  var MissingFishjamIdException = class extends Error {
6298
6848
  constructor() {
6299
6849
  super("Fishjam ID is required");
6300
6850
  }
6301
6851
  };
6852
+ var StaleSdkException = class extends Error {
6853
+ /** Raw wire value received from the server. */
6854
+ status;
6855
+ constructor(status) {
6856
+ super(
6857
+ `Received a recording status this SDK cannot parse (${status}). You are probably using an outdated version of @fishjam-cloud/js-server-sdk \u2014 please update it.`
6858
+ );
6859
+ this.status = status;
6860
+ }
6861
+ };
6302
6862
  var FishjamBaseException = class extends Error {
6303
6863
  statusCode;
6304
6864
  details;
@@ -6322,6 +6882,16 @@ var InvalidFishjamCredentialsException = class extends FishjamBaseException {
6322
6882
  };
6323
6883
  var PeerNotFoundException = class extends FishjamBaseException {
6324
6884
  };
6885
+ var RecordingNotFoundException = class extends FishjamBaseException {
6886
+ };
6887
+ var CompositionNotFoundException = class extends FishjamBaseException {
6888
+ };
6889
+ var InputNotFoundException = class extends FishjamBaseException {
6890
+ };
6891
+ var OutputNotFoundException = class extends FishjamBaseException {
6892
+ };
6893
+ var RendererNotFoundException = class extends FishjamBaseException {
6894
+ };
6325
6895
  var ServiceUnavailableException = class extends FishjamBaseException {
6326
6896
  };
6327
6897
  var QuotaExceededException = class extends FishjamBaseException {
@@ -6330,6 +6900,7 @@ var UnknownException = class extends FishjamBaseException {
6330
6900
  };
6331
6901
 
6332
6902
  // src/utils.ts
6903
+ var FISHJAM_URL = "https://fishjam.io";
6333
6904
  var httpToWebsocket = (httpUrl) => {
6334
6905
  const url = new URL(httpUrl);
6335
6906
  url.protocol = url.protocol.replace("http", "ws");
@@ -6340,7 +6911,7 @@ var getFishjamUrl = (config) => {
6340
6911
  try {
6341
6912
  return new URL(config.fishjamId).href;
6342
6913
  } catch {
6343
- return `https://fishjam.io/api/v1/connect/${config.fishjamId}`;
6914
+ return `${FISHJAM_URL}/api/v1/connect/${config.fishjamId}`;
6344
6915
  }
6345
6916
  };
6346
6917
  var AGENT_SOCKET_PATH = "/socket/agent/websocket";
@@ -6353,6 +6924,10 @@ var getAgentWebsocketUrl = (config, peerWebsocketUrl) => {
6353
6924
  }
6354
6925
  return `${httpToWebsocket(getFishjamUrl(config))}${AGENT_SOCKET_PATH}`;
6355
6926
  };
6927
+ var COMPOSITION_URL = "https://rtc.fishjam.io";
6928
+ var getCompositionOrigin = (config) => new URL(config.compositionUrl ?? COMPOSITION_URL).origin;
6929
+ var toBlob = async (file) => typeof file === "string" ? new Blob([await readFile(file)]) : file;
6930
+ var getLivestreamWhipUrl = (config) => `${new URL(getFishjamUrl(config)).origin}/api/v1/live/api/whip`;
6356
6931
 
6357
6932
  // src/notifications.ts
6358
6933
  var peerTypeMap = {
@@ -6374,6 +6949,20 @@ var vadStatusMap = {
6374
6949
  [ServerMessage_VadNotification_Status.STATUS_SPEECH]: "speech",
6375
6950
  [ServerMessage_VadNotification_Status.UNRECOGNIZED]: "silence"
6376
6951
  };
6952
+ var mapRecordingStatus = (status) => {
6953
+ switch (status) {
6954
+ case ServerMessage_RecordingStatusChanged_Status.STATUS_ACTIVE:
6955
+ return "active";
6956
+ case ServerMessage_RecordingStatusChanged_Status.STATUS_FINISHED:
6957
+ return "finished";
6958
+ case ServerMessage_RecordingStatusChanged_Status.STATUS_AVAILABLE:
6959
+ return "available";
6960
+ case ServerMessage_RecordingStatusChanged_Status.STATUS_FAILED:
6961
+ return "failed";
6962
+ default:
6963
+ throw new StaleSdkException(status);
6964
+ }
6965
+ };
6377
6966
  var expectedEventsList = [
6378
6967
  "roomCreated",
6379
6968
  "roomDeleted",
@@ -6395,7 +6984,8 @@ var expectedEventsList = [
6395
6984
  "trackForwardingRemoved",
6396
6985
  "vadNotification",
6397
6986
  "channelAdded",
6398
- "channelRemoved"
6987
+ "channelRemoved",
6988
+ "recordingStatusChanged"
6399
6989
  ];
6400
6990
  var peerEventsWithPeerType = /* @__PURE__ */ new Set([
6401
6991
  "peerAdded",
@@ -6424,6 +7014,10 @@ var mapNotification = (event, msg) => {
6424
7014
  const vad = msg;
6425
7015
  return { ...vad, status: vadStatusMap[vad.status] };
6426
7016
  }
7017
+ if (event === "recordingStatusChanged") {
7018
+ const recording = msg;
7019
+ return { ...recording, status: mapRecordingStatus(recording.status) };
7020
+ }
6427
7021
  return msg;
6428
7022
  };
6429
7023
  var isExpectedEvent = (event) => expectedEventsList.includes(event);
@@ -6648,132 +7242,2283 @@ var toProtoEncoding = (encoding) => {
6648
7242
  return TrackEncoding.TRACK_ENCODING_OPUS;
6649
7243
  };
6650
7244
 
6651
- // src/exceptions/mapper.ts
6652
- var notFoundException = (info, entity) => {
6653
- switch (entity) {
6654
- case "credentials":
6655
- return new InvalidFishjamCredentialsException(info);
6656
- case "peer":
6657
- return new PeerNotFoundException(info);
6658
- case "room":
6659
- return new RoomNotFoundException(info);
6660
- default:
6661
- return new FishjamNotFoundException(info);
7245
+ // ../composition-openapi/dist/index.js
7246
+ var BASE_PATH2 = "https://rtc.fishjam.io".replace(/\/+$/, "");
7247
+ var Configuration2 = class {
7248
+ constructor(configuration = {}) {
7249
+ this.configuration = configuration;
6662
7250
  }
6663
- };
6664
- var mapException = async (error, entity) => {
6665
- if (error instanceof FetchError) {
6666
- return new UnknownException({ message: error.cause.message, statusCode: 500, details: error.cause.message });
7251
+ set config(configuration) {
7252
+ this.configuration = configuration;
6667
7253
  }
6668
- if (!(error instanceof ResponseError)) {
6669
- return error;
7254
+ get basePath() {
7255
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH2;
6670
7256
  }
6671
- const status = error.response.status;
6672
- const body = await error.response.json().catch(() => ({}));
6673
- const info = {
6674
- message: `Request failed with status code ${status}`,
6675
- statusCode: status,
6676
- details: body["detail"] ?? body["errors"] ?? "Unknown error"
6677
- };
6678
- switch (status) {
6679
- case 400:
6680
- return new BadRequestException(info);
6681
- case 402:
6682
- return new QuotaExceededException(info);
6683
- case 401:
6684
- return new UnauthorizedException(info);
6685
- case 404:
6686
- return notFoundException(info, entity);
6687
- case 503:
6688
- return new ServiceUnavailableException(info);
6689
- default:
6690
- return new UnknownException(info);
7257
+ get fetchApi() {
7258
+ return this.configuration.fetchApi;
6691
7259
  }
6692
- };
6693
-
6694
- // src/client.ts
6695
- var FishjamClient = class _FishjamClient {
6696
- moqApi;
6697
- roomApi;
6698
- viewerApi;
6699
- streamerApi;
6700
- credentialsApi;
6701
- fishjamConfig;
6702
- deprecationWarningShown = false;
6703
- /**
6704
- * Create new instance of Fishjam Client.
6705
- *
6706
- * Does not verify credentials against the backend — use
6707
- * {@link FishjamClient.create} or call
6708
- * {@link FishjamClient.checkCredentials} afterwards for that.
6709
- *
6710
- * Example usage:
6711
- * ```
6712
- * const fishjamClient = new FishjamClient({
6713
- * fishjamId: fastify.config.FISHJAM_ID,
6714
- * managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
6715
- * });
6716
- * ```
6717
- */
6718
- constructor(config) {
6719
- const deprecationMiddleware = {
6720
- post: async ({ response }) => {
6721
- this.handleDeprecationHeader(response.headers);
6722
- return response;
6723
- }
6724
- };
6725
- const apiConfig = new Configuration({
6726
- basePath: getFishjamUrl(config),
6727
- headers: {
6728
- Authorization: `Bearer ${config.managementToken}`,
6729
- "x-fishjam-api-client": `js-server/${package_default.version}`
6730
- },
6731
- middleware: [deprecationMiddleware]
6732
- });
6733
- this.moqApi = new MoQApi(apiConfig);
6734
- this.roomApi = new RoomsApi(apiConfig);
6735
- this.viewerApi = new ViewersApi(apiConfig);
6736
- this.streamerApi = new StreamersApi(apiConfig);
6737
- this.credentialsApi = new CredentialsApi(apiConfig);
6738
- this.fishjamConfig = config;
7260
+ get middleware() {
7261
+ return this.configuration.middleware || [];
6739
7262
  }
6740
- /**
6741
- * Async factory: constructs a client and verifies credentials against
6742
- * the backend.
6743
- *
6744
- * Throws {@link InvalidFishjamCredentialsException} when the
6745
- * `fishjamId` / `managementToken` pair is rejected by the backend.
6746
- *
6747
- * Example:
6748
- * ```
6749
- * const client = await FishjamClient.create({
6750
- * fishjamId: process.env.FISHJAM_ID!,
6751
- * managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
6752
- * });
6753
- * ```
6754
- */
6755
- static async create(config) {
6756
- const client = new _FishjamClient(config);
6757
- await client.checkCredentials();
6758
- return client;
7263
+ get queryParamsStringify() {
7264
+ return this.configuration.queryParamsStringify || querystring2;
6759
7265
  }
6760
- /**
6761
- * Verifies the configured credentials by making a single lightweight
6762
- * call to the Fishjam backend. Resolves on success, throws
6763
- * {@link InvalidFishjamCredentialsException} on 401/404 from the backend,
6764
- * otherwise rethrows the standard mapped exception.
6765
- */
6766
- async checkCredentials() {
6767
- try {
6768
- await this.credentialsApi.validateCredentials();
6769
- } catch (error) {
6770
- throw await mapException(error, "credentials");
7266
+ get username() {
7267
+ return this.configuration.username;
7268
+ }
7269
+ get password() {
7270
+ return this.configuration.password;
7271
+ }
7272
+ get apiKey() {
7273
+ const apiKey = this.configuration.apiKey;
7274
+ if (apiKey) {
7275
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
6771
7276
  }
7277
+ return void 0;
6772
7278
  }
6773
- handleDeprecationHeader(headers) {
6774
- try {
6775
- const deprecationHeader = headers.get("x-fishjam-api-deprecated");
6776
- if (!deprecationHeader || this.deprecationWarningShown) return;
7279
+ get accessToken() {
7280
+ const accessToken = this.configuration.accessToken;
7281
+ if (accessToken) {
7282
+ return typeof accessToken === "function" ? accessToken : async () => accessToken;
7283
+ }
7284
+ return void 0;
7285
+ }
7286
+ get headers() {
7287
+ return this.configuration.headers;
7288
+ }
7289
+ get credentials() {
7290
+ return this.configuration.credentials;
7291
+ }
7292
+ };
7293
+ var DefaultConfig2 = new Configuration2();
7294
+ var BaseAPI2 = class _BaseAPI2 {
7295
+ constructor(configuration = DefaultConfig2) {
7296
+ this.configuration = configuration;
7297
+ this.middleware = configuration.middleware;
7298
+ }
7299
+ static jsonRegex = /^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$/i;
7300
+ middleware;
7301
+ withMiddleware(...middlewares) {
7302
+ const next = this.clone();
7303
+ next.middleware = next.middleware.concat(...middlewares);
7304
+ return next;
7305
+ }
7306
+ withPreMiddleware(...preMiddlewares) {
7307
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
7308
+ return this.withMiddleware(...middlewares);
7309
+ }
7310
+ withPostMiddleware(...postMiddlewares) {
7311
+ const middlewares = postMiddlewares.map((post) => ({ post }));
7312
+ return this.withMiddleware(...middlewares);
7313
+ }
7314
+ /**
7315
+ * Check if the given MIME is a JSON MIME.
7316
+ * JSON MIME examples:
7317
+ * application/json
7318
+ * application/json; charset=UTF8
7319
+ * APPLICATION/JSON
7320
+ * application/vnd.company+json
7321
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
7322
+ * @return True if the given MIME is JSON, false otherwise.
7323
+ */
7324
+ isJsonMime(mime) {
7325
+ if (!mime) {
7326
+ return false;
7327
+ }
7328
+ return _BaseAPI2.jsonRegex.test(mime);
7329
+ }
7330
+ async request(context, initOverrides) {
7331
+ const { url, init } = await this.createFetchParams(context, initOverrides);
7332
+ const response = await this.fetchApi(url, init);
7333
+ if (response && response.status >= 200 && response.status < 300) {
7334
+ return response;
7335
+ }
7336
+ throw new ResponseError2(response, "Response returned an error code");
7337
+ }
7338
+ async createFetchParams(context, initOverrides) {
7339
+ let url = this.configuration.basePath + context.path;
7340
+ if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
7341
+ url += "?" + this.configuration.queryParamsStringify(context.query);
7342
+ }
7343
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
7344
+ Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
7345
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
7346
+ const initParams = {
7347
+ method: context.method,
7348
+ headers,
7349
+ body: context.body,
7350
+ credentials: this.configuration.credentials
7351
+ };
7352
+ const overriddenInit = {
7353
+ ...initParams,
7354
+ ...await initOverrideFn({
7355
+ init: initParams,
7356
+ context
7357
+ })
7358
+ };
7359
+ let body;
7360
+ if (isFormData2(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob2(overriddenInit.body)) {
7361
+ body = overriddenInit.body;
7362
+ } else if (this.isJsonMime(headers["Content-Type"])) {
7363
+ body = JSON.stringify(overriddenInit.body);
7364
+ } else {
7365
+ body = overriddenInit.body;
7366
+ }
7367
+ const init = {
7368
+ ...overriddenInit,
7369
+ body
7370
+ };
7371
+ return { url, init };
7372
+ }
7373
+ fetchApi = async (url, init) => {
7374
+ let fetchParams = { url, init };
7375
+ for (const middleware of this.middleware) {
7376
+ if (middleware.pre) {
7377
+ fetchParams = await middleware.pre({
7378
+ fetch: this.fetchApi,
7379
+ ...fetchParams
7380
+ }) || fetchParams;
7381
+ }
7382
+ }
7383
+ let response = void 0;
7384
+ try {
7385
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
7386
+ } catch (e) {
7387
+ for (const middleware of this.middleware) {
7388
+ if (middleware.onError) {
7389
+ response = await middleware.onError({
7390
+ fetch: this.fetchApi,
7391
+ url: fetchParams.url,
7392
+ init: fetchParams.init,
7393
+ error: e,
7394
+ response: response ? response.clone() : void 0
7395
+ }) || response;
7396
+ }
7397
+ }
7398
+ if (response === void 0) {
7399
+ if (e instanceof Error) {
7400
+ throw new FetchError2(e, "The request failed and the interceptors did not return an alternative response");
7401
+ } else {
7402
+ throw e;
7403
+ }
7404
+ }
7405
+ }
7406
+ for (const middleware of this.middleware) {
7407
+ if (middleware.post) {
7408
+ response = await middleware.post({
7409
+ fetch: this.fetchApi,
7410
+ url: fetchParams.url,
7411
+ init: fetchParams.init,
7412
+ response: response.clone()
7413
+ }) || response;
7414
+ }
7415
+ }
7416
+ return response;
7417
+ };
7418
+ /**
7419
+ * Create a shallow clone of `this` by constructing a new instance
7420
+ * and then shallow cloning data members.
7421
+ */
7422
+ clone() {
7423
+ const constructor = this.constructor;
7424
+ const next = new constructor(this.configuration);
7425
+ next.middleware = this.middleware.slice();
7426
+ return next;
7427
+ }
7428
+ };
7429
+ function isBlob2(value) {
7430
+ return typeof Blob !== "undefined" && value instanceof Blob;
7431
+ }
7432
+ function isFormData2(value) {
7433
+ return typeof FormData !== "undefined" && value instanceof FormData;
7434
+ }
7435
+ var ResponseError2 = class extends Error {
7436
+ constructor(response, msg) {
7437
+ super(msg);
7438
+ this.response = response;
7439
+ const actualProto = new.target.prototype;
7440
+ if (Object.setPrototypeOf) {
7441
+ Object.setPrototypeOf(this, actualProto);
7442
+ }
7443
+ }
7444
+ name = "ResponseError";
7445
+ };
7446
+ var FetchError2 = class extends Error {
7447
+ constructor(cause, msg) {
7448
+ super(msg);
7449
+ this.cause = cause;
7450
+ const actualProto = new.target.prototype;
7451
+ if (Object.setPrototypeOf) {
7452
+ Object.setPrototypeOf(this, actualProto);
7453
+ }
7454
+ }
7455
+ name = "FetchError";
7456
+ };
7457
+ var RequiredError2 = class extends Error {
7458
+ constructor(field, msg) {
7459
+ super(msg);
7460
+ this.field = field;
7461
+ const actualProto = new.target.prototype;
7462
+ if (Object.setPrototypeOf) {
7463
+ Object.setPrototypeOf(this, actualProto);
7464
+ }
7465
+ }
7466
+ name = "RequiredError";
7467
+ };
7468
+ function querystring2(params, prefix = "") {
7469
+ return Object.keys(params).map((key) => querystringSingleKey2(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
7470
+ }
7471
+ function querystringSingleKey2(key, value, keyPrefix = "") {
7472
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
7473
+ if (value instanceof Array) {
7474
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
7475
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
7476
+ }
7477
+ if (value instanceof Set) {
7478
+ const valueAsArray = Array.from(value);
7479
+ return querystringSingleKey2(key, valueAsArray, keyPrefix);
7480
+ }
7481
+ if (value instanceof Date) {
7482
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
7483
+ }
7484
+ if (value instanceof Object) {
7485
+ return querystring2(value, fullKey);
7486
+ }
7487
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
7488
+ }
7489
+ function canConsumeForm(consumes) {
7490
+ for (const consume of consumes) {
7491
+ if (consume.contentType?.startsWith("multipart/form-data") == true) {
7492
+ return true;
7493
+ }
7494
+ }
7495
+ return false;
7496
+ }
7497
+ var JSONApiResponse2 = class {
7498
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
7499
+ this.raw = raw;
7500
+ this.transformer = transformer;
7501
+ }
7502
+ async value() {
7503
+ return this.transformer(await this.raw.json());
7504
+ }
7505
+ };
7506
+ var VoidApiResponse2 = class {
7507
+ constructor(raw) {
7508
+ this.raw = raw;
7509
+ }
7510
+ async value() {
7511
+ return void 0;
7512
+ }
7513
+ };
7514
+ var TextApiResponse = class {
7515
+ constructor(raw) {
7516
+ this.raw = raw;
7517
+ }
7518
+ async value() {
7519
+ return await this.raw.text();
7520
+ }
7521
+ };
7522
+ function CompositionCreatedResponseFromJSON(json) {
7523
+ return CompositionCreatedResponseFromJSONTyped(json, false);
7524
+ }
7525
+ function CompositionCreatedResponseFromJSONTyped(json, ignoreDiscriminator) {
7526
+ if (json == null) {
7527
+ return json;
7528
+ }
7529
+ return {
7530
+ compositionId: json["composition_id"],
7531
+ apiUrl: json["api_url"]
7532
+ };
7533
+ }
7534
+ function CreateCompositionRequestToJSON(json) {
7535
+ return CreateCompositionRequestToJSONTyped(json, false);
7536
+ }
7537
+ function CreateCompositionRequestToJSONTyped(value, ignoreDiscriminator = false) {
7538
+ if (value == null) {
7539
+ return value;
7540
+ }
7541
+ return {
7542
+ autostart: value["autostart"],
7543
+ cleanup_without_inputs: value["cleanupWithoutInputs"]
7544
+ };
7545
+ }
7546
+ var CompositionsApi = class extends BaseAPI2 {
7547
+ /**
7548
+ * Creates request options for createComposition without sending the request
7549
+ */
7550
+ async createCompositionRequestOpts(requestParameters) {
7551
+ if (requestParameters["createCompositionRequest"] == null) {
7552
+ throw new RequiredError2(
7553
+ "createCompositionRequest",
7554
+ 'Required parameter "createCompositionRequest" was null or undefined when calling createComposition().'
7555
+ );
7556
+ }
7557
+ const queryParameters = {};
7558
+ const headerParameters = {};
7559
+ headerParameters["Content-Type"] = "application/json";
7560
+ if (this.configuration && this.configuration.accessToken) {
7561
+ const token = this.configuration.accessToken;
7562
+ const tokenString = await token("BearerAuth", []);
7563
+ if (tokenString) {
7564
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
7565
+ }
7566
+ }
7567
+ let urlPath = `/api/composition`;
7568
+ return {
7569
+ path: urlPath,
7570
+ method: "POST",
7571
+ headers: headerParameters,
7572
+ query: queryParameters,
7573
+ body: CreateCompositionRequestToJSON(requestParameters["createCompositionRequest"])
7574
+ };
7575
+ }
7576
+ /**
7577
+ * Create a composition
7578
+ */
7579
+ async createCompositionRaw(requestParameters, initOverrides) {
7580
+ const requestOptions = await this.createCompositionRequestOpts(requestParameters);
7581
+ const response = await this.request(requestOptions, initOverrides);
7582
+ return new JSONApiResponse2(response, (jsonValue) => CompositionCreatedResponseFromJSON(jsonValue));
7583
+ }
7584
+ /**
7585
+ * Create a composition
7586
+ */
7587
+ async createComposition(requestParameters, initOverrides) {
7588
+ const response = await this.createCompositionRaw(requestParameters, initOverrides);
7589
+ return await response.value();
7590
+ }
7591
+ /**
7592
+ * Creates request options for deleteComposition without sending the request
7593
+ */
7594
+ async deleteCompositionRequestOpts(requestParameters) {
7595
+ if (requestParameters["compositionId"] == null) {
7596
+ throw new RequiredError2(
7597
+ "compositionId",
7598
+ 'Required parameter "compositionId" was null or undefined when calling deleteComposition().'
7599
+ );
7600
+ }
7601
+ const queryParameters = {};
7602
+ const headerParameters = {};
7603
+ if (this.configuration && this.configuration.accessToken) {
7604
+ const token = this.configuration.accessToken;
7605
+ const tokenString = await token("BearerAuth", []);
7606
+ if (tokenString) {
7607
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
7608
+ }
7609
+ }
7610
+ let urlPath = `/api/composition/{composition_id}`;
7611
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
7612
+ return {
7613
+ path: urlPath,
7614
+ method: "DELETE",
7615
+ headers: headerParameters,
7616
+ query: queryParameters
7617
+ };
7618
+ }
7619
+ /**
7620
+ * Delete a composition
7621
+ */
7622
+ async deleteCompositionRaw(requestParameters, initOverrides) {
7623
+ const requestOptions = await this.deleteCompositionRequestOpts(requestParameters);
7624
+ const response = await this.request(requestOptions, initOverrides);
7625
+ return new VoidApiResponse2(response);
7626
+ }
7627
+ /**
7628
+ * Delete a composition
7629
+ */
7630
+ async deleteComposition(requestParameters, initOverrides) {
7631
+ await this.deleteCompositionRaw(requestParameters, initOverrides);
7632
+ }
7633
+ /**
7634
+ * Creates request options for reset without sending the request
7635
+ */
7636
+ async resetRequestOpts(requestParameters) {
7637
+ if (requestParameters["compositionId"] == null) {
7638
+ throw new RequiredError2(
7639
+ "compositionId",
7640
+ 'Required parameter "compositionId" was null or undefined when calling reset().'
7641
+ );
7642
+ }
7643
+ const queryParameters = {};
7644
+ const headerParameters = {};
7645
+ if (this.configuration && this.configuration.accessToken) {
7646
+ const token = this.configuration.accessToken;
7647
+ const tokenString = await token("BearerAuth", []);
7648
+ if (tokenString) {
7649
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
7650
+ }
7651
+ }
7652
+ let urlPath = `/api/composition/{composition_id}/reset`;
7653
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
7654
+ return {
7655
+ path: urlPath,
7656
+ method: "POST",
7657
+ headers: headerParameters,
7658
+ query: queryParameters
7659
+ };
7660
+ }
7661
+ /**
7662
+ * Reset a composition
7663
+ */
7664
+ async resetRaw(requestParameters, initOverrides) {
7665
+ const requestOptions = await this.resetRequestOpts(requestParameters);
7666
+ const response = await this.request(requestOptions, initOverrides);
7667
+ return new JSONApiResponse2(response);
7668
+ }
7669
+ /**
7670
+ * Reset a composition
7671
+ */
7672
+ async reset(requestParameters, initOverrides) {
7673
+ const response = await this.resetRaw(requestParameters, initOverrides);
7674
+ return await response.value();
7675
+ }
7676
+ /**
7677
+ * Creates request options for start without sending the request
7678
+ */
7679
+ async startRequestOpts(requestParameters) {
7680
+ if (requestParameters["compositionId"] == null) {
7681
+ throw new RequiredError2(
7682
+ "compositionId",
7683
+ 'Required parameter "compositionId" was null or undefined when calling start().'
7684
+ );
7685
+ }
7686
+ const queryParameters = {};
7687
+ const headerParameters = {};
7688
+ if (this.configuration && this.configuration.accessToken) {
7689
+ const token = this.configuration.accessToken;
7690
+ const tokenString = await token("BearerAuth", []);
7691
+ if (tokenString) {
7692
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
7693
+ }
7694
+ }
7695
+ let urlPath = `/api/composition/{composition_id}/start`;
7696
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
7697
+ return {
7698
+ path: urlPath,
7699
+ method: "POST",
7700
+ headers: headerParameters,
7701
+ query: queryParameters
7702
+ };
7703
+ }
7704
+ /**
7705
+ * Start a composition
7706
+ */
7707
+ async startRaw(requestParameters, initOverrides) {
7708
+ const requestOptions = await this.startRequestOpts(requestParameters);
7709
+ const response = await this.request(requestOptions, initOverrides);
7710
+ return new JSONApiResponse2(response);
7711
+ }
7712
+ /**
7713
+ * Start a composition
7714
+ */
7715
+ async start(requestParameters, initOverrides) {
7716
+ const response = await this.startRaw(requestParameters, initOverrides);
7717
+ return await response.value();
7718
+ }
7719
+ };
7720
+ function SendCompositionEventRequestToJSON(json) {
7721
+ return SendCompositionEventRequestToJSONTyped(json, false);
7722
+ }
7723
+ function SendCompositionEventRequestToJSONTyped(value, ignoreDiscriminator = false) {
7724
+ if (value == null) {
7725
+ return value;
7726
+ }
7727
+ return {
7728
+ event_name: value["eventName"],
7729
+ data: value["data"]
7730
+ };
7731
+ }
7732
+ var EventsApi = class extends BaseAPI2 {
7733
+ /**
7734
+ * Creates request options for sendCompositionEvent without sending the request
7735
+ */
7736
+ async sendCompositionEventRequestOpts(requestParameters) {
7737
+ if (requestParameters["compositionId"] == null) {
7738
+ throw new RequiredError2(
7739
+ "compositionId",
7740
+ 'Required parameter "compositionId" was null or undefined when calling sendCompositionEvent().'
7741
+ );
7742
+ }
7743
+ if (requestParameters["sendCompositionEventRequest"] == null) {
7744
+ throw new RequiredError2(
7745
+ "sendCompositionEventRequest",
7746
+ 'Required parameter "sendCompositionEventRequest" was null or undefined when calling sendCompositionEvent().'
7747
+ );
7748
+ }
7749
+ const queryParameters = {};
7750
+ const headerParameters = {};
7751
+ headerParameters["Content-Type"] = "application/json";
7752
+ if (this.configuration && this.configuration.accessToken) {
7753
+ const token = this.configuration.accessToken;
7754
+ const tokenString = await token("BearerAuth", []);
7755
+ if (tokenString) {
7756
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
7757
+ }
7758
+ }
7759
+ let urlPath = `/api/composition/{composition_id}/event`;
7760
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
7761
+ return {
7762
+ path: urlPath,
7763
+ method: "POST",
7764
+ headers: headerParameters,
7765
+ query: queryParameters,
7766
+ body: SendCompositionEventRequestToJSON(requestParameters["sendCompositionEventRequest"])
7767
+ };
7768
+ }
7769
+ /**
7770
+ * Send an event to templates
7771
+ */
7772
+ async sendCompositionEventRaw(requestParameters, initOverrides) {
7773
+ const requestOptions = await this.sendCompositionEventRequestOpts(requestParameters);
7774
+ const response = await this.request(requestOptions, initOverrides);
7775
+ return new JSONApiResponse2(response);
7776
+ }
7777
+ /**
7778
+ * Send an event to templates
7779
+ */
7780
+ async sendCompositionEvent(requestParameters, initOverrides) {
7781
+ const response = await this.sendCompositionEventRaw(requestParameters, initOverrides);
7782
+ return await response.value();
7783
+ }
7784
+ };
7785
+ function instanceOfMp4Input(value) {
7786
+ if (!("url" in value) || value["url"] === void 0) return false;
7787
+ if (!("type" in value) || value["type"] === void 0) return false;
7788
+ if (value["type"] !== "mp4") return false;
7789
+ return true;
7790
+ }
7791
+ function Mp4InputToJSON(json) {
7792
+ return Mp4InputToJSONTyped(json, false);
7793
+ }
7794
+ function Mp4InputToJSONTyped(value, ignoreDiscriminator = false) {
7795
+ if (value == null) {
7796
+ return value;
7797
+ }
7798
+ return {
7799
+ url: value["url"],
7800
+ loop: value["loop"],
7801
+ type: value["type"]
7802
+ };
7803
+ }
7804
+ function instanceOfRtmpInput(value) {
7805
+ if (!("streamKey" in value) && !("stream_key" in value) || value["streamKey"] === void 0 && value["stream_key"] === void 0)
7806
+ return false;
7807
+ if (!("type" in value) || value["type"] === void 0) return false;
7808
+ if (value["type"] !== "rtmp_server") return false;
7809
+ return true;
7810
+ }
7811
+ function RtmpInputToJSON(json) {
7812
+ return RtmpInputToJSONTyped(json, false);
7813
+ }
7814
+ function RtmpInputToJSONTyped(value, ignoreDiscriminator = false) {
7815
+ if (value == null) {
7816
+ return value;
7817
+ }
7818
+ return {
7819
+ stream_key: value["streamKey"],
7820
+ type: value["type"]
7821
+ };
7822
+ }
7823
+ function instanceOfWhepInput(value) {
7824
+ if (!("endpointUrl" in value) && !("endpoint_url" in value) || value["endpointUrl"] === void 0 && value["endpoint_url"] === void 0)
7825
+ return false;
7826
+ if (!("type" in value) || value["type"] === void 0) return false;
7827
+ if (value["type"] !== "whep_client") return false;
7828
+ return true;
7829
+ }
7830
+ function WhepInputToJSON(json) {
7831
+ return WhepInputToJSONTyped(json, false);
7832
+ }
7833
+ function WhepInputToJSONTyped(value, ignoreDiscriminator = false) {
7834
+ if (value == null) {
7835
+ return value;
7836
+ }
7837
+ return {
7838
+ endpoint_url: value["endpointUrl"],
7839
+ bearer_token: value["bearerToken"],
7840
+ video: value["video"],
7841
+ type: value["type"]
7842
+ };
7843
+ }
7844
+ function instanceOfWhipInput(value) {
7845
+ if (!("type" in value) || value["type"] === void 0) return false;
7846
+ if (value["type"] !== "whip_server") return false;
7847
+ return true;
7848
+ }
7849
+ function WhipInputToJSON(json) {
7850
+ return WhipInputToJSONTyped(json, false);
7851
+ }
7852
+ function WhipInputToJSONTyped(value, ignoreDiscriminator = false) {
7853
+ if (value == null) {
7854
+ return value;
7855
+ }
7856
+ return {
7857
+ bearer_token: value["bearerToken"],
7858
+ video: value["video"],
7859
+ type: value["type"]
7860
+ };
7861
+ }
7862
+ function RegisterInputToJSON(json) {
7863
+ return RegisterInputToJSONTyped(json, false);
7864
+ }
7865
+ function RegisterInputToJSONTyped(value, ignoreDiscriminator = false) {
7866
+ if (value == null) {
7867
+ return value;
7868
+ }
7869
+ if (typeof value !== "object") {
7870
+ return value;
7871
+ }
7872
+ if (instanceOfMp4Input(value)) {
7873
+ return Mp4InputToJSON(value);
7874
+ }
7875
+ if (instanceOfRtmpInput(value)) {
7876
+ return RtmpInputToJSON(value);
7877
+ }
7878
+ if (instanceOfWhepInput(value)) {
7879
+ return WhepInputToJSON(value);
7880
+ }
7881
+ if (instanceOfWhipInput(value)) {
7882
+ return WhipInputToJSON(value);
7883
+ }
7884
+ return {};
7885
+ }
7886
+ function RegisterInputResponseFromJSON(json) {
7887
+ return RegisterInputResponseFromJSONTyped(json, false);
7888
+ }
7889
+ function RegisterInputResponseFromJSONTyped(json, ignoreDiscriminator) {
7890
+ if (json == null) {
7891
+ return json;
7892
+ }
7893
+ return {
7894
+ bearerToken: json["bearer_token"] === void 0 ? void 0 : json["bearer_token"] === null ? null : json["bearer_token"],
7895
+ endpointRoute: json["endpoint_route"] === void 0 ? void 0 : json["endpoint_route"] === null ? null : json["endpoint_route"],
7896
+ videoDurationMs: json["video_duration_ms"] === void 0 ? void 0 : json["video_duration_ms"] === null ? null : json["video_duration_ms"],
7897
+ audioDurationMs: json["audio_duration_ms"] === void 0 ? void 0 : json["audio_duration_ms"] === null ? null : json["audio_duration_ms"],
7898
+ port: json["port"] === void 0 ? void 0 : json["port"] === null ? null : json["port"]
7899
+ };
7900
+ }
7901
+ function UnregisterInputToJSON(json) {
7902
+ return UnregisterInputToJSONTyped(json, false);
7903
+ }
7904
+ function UnregisterInputToJSONTyped(value, ignoreDiscriminator = false) {
7905
+ if (value == null) {
7906
+ return value;
7907
+ }
7908
+ return {
7909
+ schedule_time_ms: value["scheduleTimeMs"]
7910
+ };
7911
+ }
7912
+ var InputsApi = class extends BaseAPI2 {
7913
+ /**
7914
+ * Creates request options for registerInput without sending the request
7915
+ */
7916
+ async registerInputRequestOpts(requestParameters) {
7917
+ if (requestParameters["compositionId"] == null) {
7918
+ throw new RequiredError2(
7919
+ "compositionId",
7920
+ 'Required parameter "compositionId" was null or undefined when calling registerInput().'
7921
+ );
7922
+ }
7923
+ if (requestParameters["inputId"] == null) {
7924
+ throw new RequiredError2(
7925
+ "inputId",
7926
+ 'Required parameter "inputId" was null or undefined when calling registerInput().'
7927
+ );
7928
+ }
7929
+ if (requestParameters["registerInput"] == null) {
7930
+ throw new RequiredError2(
7931
+ "registerInput",
7932
+ 'Required parameter "registerInput" was null or undefined when calling registerInput().'
7933
+ );
7934
+ }
7935
+ const queryParameters = {};
7936
+ const headerParameters = {};
7937
+ headerParameters["Content-Type"] = "application/json";
7938
+ if (this.configuration && this.configuration.accessToken) {
7939
+ const token = this.configuration.accessToken;
7940
+ const tokenString = await token("BearerAuth", []);
7941
+ if (tokenString) {
7942
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
7943
+ }
7944
+ }
7945
+ let urlPath = `/api/composition/{composition_id}/input/{input_id}/register`;
7946
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
7947
+ urlPath = urlPath.replace("{input_id}", encodeURIComponent(String(requestParameters["inputId"])));
7948
+ return {
7949
+ path: urlPath,
7950
+ method: "POST",
7951
+ headers: headerParameters,
7952
+ query: queryParameters,
7953
+ body: RegisterInputToJSON(requestParameters["registerInput"])
7954
+ };
7955
+ }
7956
+ /**
7957
+ * Register an input
7958
+ */
7959
+ async registerInputRaw(requestParameters, initOverrides) {
7960
+ const requestOptions = await this.registerInputRequestOpts(requestParameters);
7961
+ const response = await this.request(requestOptions, initOverrides);
7962
+ return new JSONApiResponse2(response, (jsonValue) => RegisterInputResponseFromJSON(jsonValue));
7963
+ }
7964
+ /**
7965
+ * Register an input
7966
+ */
7967
+ async registerInput(requestParameters, initOverrides) {
7968
+ const response = await this.registerInputRaw(requestParameters, initOverrides);
7969
+ return await response.value();
7970
+ }
7971
+ /**
7972
+ * Creates request options for unregisterInput without sending the request
7973
+ */
7974
+ async unregisterInputRequestOpts(requestParameters) {
7975
+ if (requestParameters["compositionId"] == null) {
7976
+ throw new RequiredError2(
7977
+ "compositionId",
7978
+ 'Required parameter "compositionId" was null or undefined when calling unregisterInput().'
7979
+ );
7980
+ }
7981
+ if (requestParameters["inputId"] == null) {
7982
+ throw new RequiredError2(
7983
+ "inputId",
7984
+ 'Required parameter "inputId" was null or undefined when calling unregisterInput().'
7985
+ );
7986
+ }
7987
+ if (requestParameters["unregisterInput"] == null) {
7988
+ throw new RequiredError2(
7989
+ "unregisterInput",
7990
+ 'Required parameter "unregisterInput" was null or undefined when calling unregisterInput().'
7991
+ );
7992
+ }
7993
+ const queryParameters = {};
7994
+ const headerParameters = {};
7995
+ headerParameters["Content-Type"] = "application/json";
7996
+ if (this.configuration && this.configuration.accessToken) {
7997
+ const token = this.configuration.accessToken;
7998
+ const tokenString = await token("BearerAuth", []);
7999
+ if (tokenString) {
8000
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8001
+ }
8002
+ }
8003
+ let urlPath = `/api/composition/{composition_id}/input/{input_id}/unregister`;
8004
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8005
+ urlPath = urlPath.replace("{input_id}", encodeURIComponent(String(requestParameters["inputId"])));
8006
+ return {
8007
+ path: urlPath,
8008
+ method: "POST",
8009
+ headers: headerParameters,
8010
+ query: queryParameters,
8011
+ body: UnregisterInputToJSON(requestParameters["unregisterInput"])
8012
+ };
8013
+ }
8014
+ /**
8015
+ * Unregister an input
8016
+ */
8017
+ async unregisterInputRaw(requestParameters, initOverrides) {
8018
+ const requestOptions = await this.unregisterInputRequestOpts(requestParameters);
8019
+ const response = await this.request(requestOptions, initOverrides);
8020
+ return new JSONApiResponse2(response);
8021
+ }
8022
+ /**
8023
+ * Unregister an input
8024
+ */
8025
+ async unregisterInput(requestParameters, initOverrides) {
8026
+ const response = await this.unregisterInputRaw(requestParameters, initOverrides);
8027
+ return await response.value();
8028
+ }
8029
+ };
8030
+ var MediaTransportApi = class extends BaseAPI2 {
8031
+ /**
8032
+ * Creates request options for whepOffer without sending the request
8033
+ */
8034
+ async whepOfferRequestOpts(requestParameters) {
8035
+ if (requestParameters["compositionId"] == null) {
8036
+ throw new RequiredError2(
8037
+ "compositionId",
8038
+ 'Required parameter "compositionId" was null or undefined when calling whepOffer().'
8039
+ );
8040
+ }
8041
+ if (requestParameters["outputId"] == null) {
8042
+ throw new RequiredError2(
8043
+ "outputId",
8044
+ 'Required parameter "outputId" was null or undefined when calling whepOffer().'
8045
+ );
8046
+ }
8047
+ if (requestParameters["body"] == null) {
8048
+ throw new RequiredError2(
8049
+ "body",
8050
+ 'Required parameter "body" was null or undefined when calling whepOffer().'
8051
+ );
8052
+ }
8053
+ const queryParameters = {};
8054
+ const headerParameters = {};
8055
+ headerParameters["Content-Type"] = "application/sdp";
8056
+ if (this.configuration && this.configuration.accessToken) {
8057
+ const token = this.configuration.accessToken;
8058
+ const tokenString = await token("BearerAuth", []);
8059
+ if (tokenString) {
8060
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8061
+ }
8062
+ }
8063
+ let urlPath = `/api/composition/{composition_id}/whep/{output_id}`;
8064
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8065
+ urlPath = urlPath.replace("{output_id}", encodeURIComponent(String(requestParameters["outputId"])));
8066
+ return {
8067
+ path: urlPath,
8068
+ method: "POST",
8069
+ headers: headerParameters,
8070
+ query: queryParameters,
8071
+ body: requestParameters["body"]
8072
+ };
8073
+ }
8074
+ /**
8075
+ * Play an output over WHEP
8076
+ */
8077
+ async whepOfferRaw(requestParameters, initOverrides) {
8078
+ const requestOptions = await this.whepOfferRequestOpts(requestParameters);
8079
+ const response = await this.request(requestOptions, initOverrides);
8080
+ if (this.isJsonMime(response.headers.get("content-type"))) {
8081
+ return new JSONApiResponse2(response);
8082
+ } else {
8083
+ return new TextApiResponse(response);
8084
+ }
8085
+ }
8086
+ /**
8087
+ * Play an output over WHEP
8088
+ */
8089
+ async whepOffer(requestParameters, initOverrides) {
8090
+ const response = await this.whepOfferRaw(requestParameters, initOverrides);
8091
+ return await response.value();
8092
+ }
8093
+ /**
8094
+ * Creates request options for whipOffer without sending the request
8095
+ */
8096
+ async whipOfferRequestOpts(requestParameters) {
8097
+ if (requestParameters["compositionId"] == null) {
8098
+ throw new RequiredError2(
8099
+ "compositionId",
8100
+ 'Required parameter "compositionId" was null or undefined when calling whipOffer().'
8101
+ );
8102
+ }
8103
+ if (requestParameters["inputId"] == null) {
8104
+ throw new RequiredError2(
8105
+ "inputId",
8106
+ 'Required parameter "inputId" was null or undefined when calling whipOffer().'
8107
+ );
8108
+ }
8109
+ if (requestParameters["body"] == null) {
8110
+ throw new RequiredError2(
8111
+ "body",
8112
+ 'Required parameter "body" was null or undefined when calling whipOffer().'
8113
+ );
8114
+ }
8115
+ const queryParameters = {};
8116
+ const headerParameters = {};
8117
+ headerParameters["Content-Type"] = "application/sdp";
8118
+ if (this.configuration && this.configuration.accessToken) {
8119
+ const token = this.configuration.accessToken;
8120
+ const tokenString = await token("BearerAuth", []);
8121
+ if (tokenString) {
8122
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8123
+ }
8124
+ }
8125
+ let urlPath = `/api/composition/{composition_id}/whip/{input_id}`;
8126
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8127
+ urlPath = urlPath.replace("{input_id}", encodeURIComponent(String(requestParameters["inputId"])));
8128
+ return {
8129
+ path: urlPath,
8130
+ method: "POST",
8131
+ headers: headerParameters,
8132
+ query: queryParameters,
8133
+ body: requestParameters["body"]
8134
+ };
8135
+ }
8136
+ /**
8137
+ * Publish to an input over WHIP
8138
+ */
8139
+ async whipOfferRaw(requestParameters, initOverrides) {
8140
+ const requestOptions = await this.whipOfferRequestOpts(requestParameters);
8141
+ const response = await this.request(requestOptions, initOverrides);
8142
+ if (this.isJsonMime(response.headers.get("content-type"))) {
8143
+ return new JSONApiResponse2(response);
8144
+ } else {
8145
+ return new TextApiResponse(response);
8146
+ }
8147
+ }
8148
+ /**
8149
+ * Publish to an input over WHIP
8150
+ */
8151
+ async whipOffer(requestParameters, initOverrides) {
8152
+ const response = await this.whipOfferRaw(requestParameters, initOverrides);
8153
+ return await response.value();
8154
+ }
8155
+ };
8156
+ function instanceOfImage(value) {
8157
+ if (!("imageId" in value) && !("image_id" in value) || value["imageId"] === void 0 && value["image_id"] === void 0)
8158
+ return false;
8159
+ if (!("type" in value) || value["type"] === void 0) return false;
8160
+ if (value["type"] !== "image") return false;
8161
+ return true;
8162
+ }
8163
+ function ImageToJSON(json) {
8164
+ return ImageToJSONTyped(json, false);
8165
+ }
8166
+ function ImageToJSONTyped(value, ignoreDiscriminator = false) {
8167
+ if (value == null) {
8168
+ return value;
8169
+ }
8170
+ return {
8171
+ id: value["id"],
8172
+ image_id: value["imageId"],
8173
+ width: value["width"],
8174
+ height: value["height"],
8175
+ type: value["type"]
8176
+ };
8177
+ }
8178
+ function instanceOfInputStream(value) {
8179
+ if (!("inputId" in value) && !("input_id" in value) || value["inputId"] === void 0 && value["input_id"] === void 0)
8180
+ return false;
8181
+ if (!("type" in value) || value["type"] === void 0) return false;
8182
+ if (value["type"] !== "input_stream") return false;
8183
+ return true;
8184
+ }
8185
+ function InputStreamToJSON(json) {
8186
+ return InputStreamToJSONTyped(json, false);
8187
+ }
8188
+ function InputStreamToJSONTyped(value, ignoreDiscriminator = false) {
8189
+ if (value == null) {
8190
+ return value;
8191
+ }
8192
+ return {
8193
+ id: value["id"],
8194
+ input_id: value["inputId"],
8195
+ type: value["type"]
8196
+ };
8197
+ }
8198
+ function RescaleModeToJSON(value) {
8199
+ return value;
8200
+ }
8201
+ function VerticalAlignToJSON(value) {
8202
+ return value;
8203
+ }
8204
+ function BoxShadowToJSON(json) {
8205
+ return BoxShadowToJSONTyped(json, false);
8206
+ }
8207
+ function BoxShadowToJSONTyped(value, ignoreDiscriminator = false) {
8208
+ if (value == null) {
8209
+ return value;
8210
+ }
8211
+ return {
8212
+ offset_x: value["offsetX"],
8213
+ offset_y: value["offsetY"],
8214
+ color: value["color"],
8215
+ blur_radius: value["blurRadius"]
8216
+ };
8217
+ }
8218
+ function HorizontalAlignToJSON(value) {
8219
+ return value;
8220
+ }
8221
+ function instanceOfEasingFunctionBounce(value) {
8222
+ if (!("functionName" in value) && !("function_name" in value) || value["functionName"] === void 0 && value["function_name"] === void 0)
8223
+ return false;
8224
+ if (value["functionName"] !== "bounce" && value["function_name"] !== "bounce")
8225
+ return false;
8226
+ return true;
8227
+ }
8228
+ function EasingFunctionBounceToJSON(json) {
8229
+ return EasingFunctionBounceToJSONTyped(json, false);
8230
+ }
8231
+ function EasingFunctionBounceToJSONTyped(value, ignoreDiscriminator = false) {
8232
+ if (value == null) {
8233
+ return value;
8234
+ }
8235
+ return {
8236
+ function_name: value["functionName"]
8237
+ };
8238
+ }
8239
+ function instanceOfEasingFunctionCubicBezier(value) {
8240
+ if (!("points" in value) || value["points"] === void 0) return false;
8241
+ if (!("functionName" in value) && !("function_name" in value) || value["functionName"] === void 0 && value["function_name"] === void 0)
8242
+ return false;
8243
+ if (value["functionName"] !== "cubic_bezier" && value["function_name"] !== "cubic_bezier")
8244
+ return false;
8245
+ return true;
8246
+ }
8247
+ function EasingFunctionCubicBezierToJSON(json) {
8248
+ return EasingFunctionCubicBezierToJSONTyped(json, false);
8249
+ }
8250
+ function EasingFunctionCubicBezierToJSONTyped(value, ignoreDiscriminator = false) {
8251
+ if (value == null) {
8252
+ return value;
8253
+ }
8254
+ return {
8255
+ points: value["points"],
8256
+ function_name: value["functionName"]
8257
+ };
8258
+ }
8259
+ function instanceOfEasingFunctionLinear(value) {
8260
+ if (!("functionName" in value) && !("function_name" in value) || value["functionName"] === void 0 && value["function_name"] === void 0)
8261
+ return false;
8262
+ if (value["functionName"] !== "linear" && value["function_name"] !== "linear")
8263
+ return false;
8264
+ return true;
8265
+ }
8266
+ function EasingFunctionLinearToJSON(json) {
8267
+ return EasingFunctionLinearToJSONTyped(json, false);
8268
+ }
8269
+ function EasingFunctionLinearToJSONTyped(value, ignoreDiscriminator = false) {
8270
+ if (value == null) {
8271
+ return value;
8272
+ }
8273
+ return {
8274
+ function_name: value["functionName"]
8275
+ };
8276
+ }
8277
+ function EasingFunctionToJSON(json) {
8278
+ return EasingFunctionToJSONTyped(json, false);
8279
+ }
8280
+ function EasingFunctionToJSONTyped(value, ignoreDiscriminator = false) {
8281
+ if (value == null) {
8282
+ return value;
8283
+ }
8284
+ if (typeof value !== "object") {
8285
+ return value;
8286
+ }
8287
+ if (instanceOfEasingFunctionBounce(value)) {
8288
+ return EasingFunctionBounceToJSON(value);
8289
+ }
8290
+ if (instanceOfEasingFunctionCubicBezier(value)) {
8291
+ return EasingFunctionCubicBezierToJSON(value);
8292
+ }
8293
+ if (instanceOfEasingFunctionLinear(value)) {
8294
+ return EasingFunctionLinearToJSON(value);
8295
+ }
8296
+ return {};
8297
+ }
8298
+ function TransitionToJSON(json) {
8299
+ return TransitionToJSONTyped(json, false);
8300
+ }
8301
+ function TransitionToJSONTyped(value, ignoreDiscriminator = false) {
8302
+ if (value == null) {
8303
+ return value;
8304
+ }
8305
+ return {
8306
+ duration_ms: value["durationMs"],
8307
+ easing_function: EasingFunctionToJSON(value["easingFunction"]),
8308
+ should_interrupt: value["shouldInterrupt"]
8309
+ };
8310
+ }
8311
+ function instanceOfRescaler(value) {
8312
+ if (!("child" in value) || value["child"] === void 0) return false;
8313
+ if (!("type" in value) || value["type"] === void 0) return false;
8314
+ if (value["type"] !== "rescaler") return false;
8315
+ return true;
8316
+ }
8317
+ function RescalerToJSON(json) {
8318
+ return RescalerToJSONTyped(json, false);
8319
+ }
8320
+ function RescalerToJSONTyped(value, ignoreDiscriminator = false) {
8321
+ if (value == null) {
8322
+ return value;
8323
+ }
8324
+ return {
8325
+ id: value["id"],
8326
+ child: ComponentToJSON(value["child"]),
8327
+ mode: RescaleModeToJSON(value["mode"]),
8328
+ horizontal_align: HorizontalAlignToJSON(value["horizontalAlign"]),
8329
+ vertical_align: VerticalAlignToJSON(value["verticalAlign"]),
8330
+ width: value["width"],
8331
+ height: value["height"],
8332
+ top: value["top"],
8333
+ left: value["left"],
8334
+ bottom: value["bottom"],
8335
+ right: value["right"],
8336
+ rotation: value["rotation"],
8337
+ transition: TransitionToJSON(value["transition"]),
8338
+ border_radius: value["borderRadius"],
8339
+ border_width: value["borderWidth"],
8340
+ border_color: value["borderColor"],
8341
+ box_shadow: value["boxShadow"] == null ? void 0 : value["boxShadow"].map(BoxShadowToJSON),
8342
+ type: value["type"]
8343
+ };
8344
+ }
8345
+ function TextStyleToJSON(value) {
8346
+ return value;
8347
+ }
8348
+ function TextWeightToJSON(value) {
8349
+ return value;
8350
+ }
8351
+ function TextWrapModeToJSON(value) {
8352
+ return value;
8353
+ }
8354
+ function instanceOfText(value) {
8355
+ if (!("text" in value) || value["text"] === void 0) return false;
8356
+ if (!("fontSize" in value) && !("font_size" in value) || value["fontSize"] === void 0 && value["font_size"] === void 0)
8357
+ return false;
8358
+ if (!("type" in value) || value["type"] === void 0) return false;
8359
+ if (value["type"] !== "text") return false;
8360
+ return true;
8361
+ }
8362
+ function TextToJSON(json) {
8363
+ return TextToJSONTyped(json, false);
8364
+ }
8365
+ function TextToJSONTyped(value, ignoreDiscriminator = false) {
8366
+ if (value == null) {
8367
+ return value;
8368
+ }
8369
+ return {
8370
+ id: value["id"],
8371
+ text: value["text"],
8372
+ width: value["width"],
8373
+ height: value["height"],
8374
+ max_width: value["maxWidth"],
8375
+ max_height: value["maxHeight"],
8376
+ font_size: value["fontSize"],
8377
+ line_height: value["lineHeight"],
8378
+ color: value["color"],
8379
+ background_color: value["backgroundColor"],
8380
+ font_family: value["fontFamily"],
8381
+ style: TextStyleToJSON(value["style"]),
8382
+ align: HorizontalAlignToJSON(value["align"]),
8383
+ wrap: TextWrapModeToJSON(value["wrap"]),
8384
+ weight: TextWeightToJSON(value["weight"]),
8385
+ type: value["type"]
8386
+ };
8387
+ }
8388
+ function instanceOfTiles(value) {
8389
+ if (!("type" in value) || value["type"] === void 0) return false;
8390
+ if (value["type"] !== "tiles") return false;
8391
+ return true;
8392
+ }
8393
+ function TilesToJSON(json) {
8394
+ return TilesToJSONTyped(json, false);
8395
+ }
8396
+ function TilesToJSONTyped(value, ignoreDiscriminator = false) {
8397
+ if (value == null) {
8398
+ return value;
8399
+ }
8400
+ return {
8401
+ id: value["id"],
8402
+ children: value["children"] == null ? void 0 : value["children"].map(ComponentToJSON),
8403
+ width: value["width"],
8404
+ height: value["height"],
8405
+ background_color: value["backgroundColor"],
8406
+ tile_aspect_ratio: value["tileAspectRatio"],
8407
+ margin: value["margin"],
8408
+ padding: value["padding"],
8409
+ horizontal_align: HorizontalAlignToJSON(value["horizontalAlign"]),
8410
+ vertical_align: VerticalAlignToJSON(value["verticalAlign"]),
8411
+ transition: TransitionToJSON(value["transition"]),
8412
+ type: value["type"]
8413
+ };
8414
+ }
8415
+ function ViewDirectionToJSON(value) {
8416
+ return value;
8417
+ }
8418
+ function OverflowToJSON(value) {
8419
+ return value;
8420
+ }
8421
+ function instanceOfView(value) {
8422
+ if (!("type" in value) || value["type"] === void 0) return false;
8423
+ if (value["type"] !== "view") return false;
8424
+ return true;
8425
+ }
8426
+ function ViewToJSON(json) {
8427
+ return ViewToJSONTyped(json, false);
8428
+ }
8429
+ function ViewToJSONTyped(value, ignoreDiscriminator = false) {
8430
+ if (value == null) {
8431
+ return value;
8432
+ }
8433
+ return {
8434
+ id: value["id"],
8435
+ children: value["children"] == null ? void 0 : value["children"].map(ComponentToJSON),
8436
+ width: value["width"],
8437
+ height: value["height"],
8438
+ direction: ViewDirectionToJSON(value["direction"]),
8439
+ top: value["top"],
8440
+ left: value["left"],
8441
+ bottom: value["bottom"],
8442
+ right: value["right"],
8443
+ rotation: value["rotation"],
8444
+ transition: TransitionToJSON(value["transition"]),
8445
+ overflow: OverflowToJSON(value["overflow"]),
8446
+ background_color: value["backgroundColor"],
8447
+ border_radius: value["borderRadius"],
8448
+ border_width: value["borderWidth"],
8449
+ border_color: value["borderColor"],
8450
+ box_shadow: value["boxShadow"] == null ? void 0 : value["boxShadow"].map(BoxShadowToJSON),
8451
+ padding: value["padding"],
8452
+ padding_vertical: value["paddingVertical"],
8453
+ padding_horizontal: value["paddingHorizontal"],
8454
+ padding_top: value["paddingTop"],
8455
+ padding_right: value["paddingRight"],
8456
+ padding_bottom: value["paddingBottom"],
8457
+ padding_left: value["paddingLeft"],
8458
+ type: value["type"]
8459
+ };
8460
+ }
8461
+ function ComponentToJSON(json) {
8462
+ return ComponentToJSONTyped4(json, false);
8463
+ }
8464
+ function ComponentToJSONTyped4(value, ignoreDiscriminator = false) {
8465
+ if (value == null) {
8466
+ return value;
8467
+ }
8468
+ if (typeof value !== "object") {
8469
+ return value;
8470
+ }
8471
+ if (instanceOfImage(value)) {
8472
+ return ImageToJSON(value);
8473
+ }
8474
+ if (instanceOfInputStream(value)) {
8475
+ return InputStreamToJSON(value);
8476
+ }
8477
+ if (instanceOfRescaler(value)) {
8478
+ return RescalerToJSON(value);
8479
+ }
8480
+ if (instanceOfText(value)) {
8481
+ return TextToJSON(value);
8482
+ }
8483
+ if (instanceOfTiles(value)) {
8484
+ return TilesToJSON(value);
8485
+ }
8486
+ if (instanceOfView(value)) {
8487
+ return ViewToJSON(value);
8488
+ }
8489
+ return {};
8490
+ }
8491
+ function VideoSceneToJSON(json) {
8492
+ return VideoSceneToJSONTyped(json, false);
8493
+ }
8494
+ function VideoSceneToJSONTyped(value, ignoreDiscriminator = false) {
8495
+ if (value == null) {
8496
+ return value;
8497
+ }
8498
+ return {
8499
+ root: ComponentToJSON(value["root"])
8500
+ };
8501
+ }
8502
+ function OutputEndConditionToJSON(json) {
8503
+ return OutputEndConditionToJSONTyped(json, false);
8504
+ }
8505
+ function OutputEndConditionToJSONTyped(value, ignoreDiscriminator = false) {
8506
+ if (value == null) {
8507
+ return value;
8508
+ }
8509
+ return {
8510
+ any_of: value["anyOf"],
8511
+ all_of: value["allOf"],
8512
+ any_input: value["anyInput"],
8513
+ all_inputs: value["allInputs"]
8514
+ };
8515
+ }
8516
+ function ResolutionToJSON(json) {
8517
+ return ResolutionToJSONTyped(json, false);
8518
+ }
8519
+ function ResolutionToJSONTyped(value, ignoreDiscriminator = false) {
8520
+ if (value == null) {
8521
+ return value;
8522
+ }
8523
+ return {
8524
+ width: value["width"],
8525
+ height: value["height"]
8526
+ };
8527
+ }
8528
+ function OutputRtmpClientVideoOptionsToJSON(json) {
8529
+ return OutputRtmpClientVideoOptionsToJSONTyped(json, false);
8530
+ }
8531
+ function OutputRtmpClientVideoOptionsToJSONTyped(value, ignoreDiscriminator = false) {
8532
+ if (value == null) {
8533
+ return value;
8534
+ }
8535
+ return {
8536
+ resolution: ResolutionToJSON(value["resolution"]),
8537
+ send_eos_when: OutputEndConditionToJSON(value["sendEosWhen"]),
8538
+ initial: VideoSceneToJSON(value["initial"])
8539
+ };
8540
+ }
8541
+ function AudioChannelsToJSON(value) {
8542
+ return value;
8543
+ }
8544
+ function AudioMixingStrategyToJSON(value) {
8545
+ return value;
8546
+ }
8547
+ function AudioSceneInputToJSON(json) {
8548
+ return AudioSceneInputToJSONTyped(json, false);
8549
+ }
8550
+ function AudioSceneInputToJSONTyped(value, ignoreDiscriminator = false) {
8551
+ if (value == null) {
8552
+ return value;
8553
+ }
8554
+ return {
8555
+ input_id: value["inputId"],
8556
+ volume: value["volume"]
8557
+ };
8558
+ }
8559
+ function AudioSceneToJSON(json) {
8560
+ return AudioSceneToJSONTyped(json, false);
8561
+ }
8562
+ function AudioSceneToJSONTyped(value, ignoreDiscriminator = false) {
8563
+ if (value == null) {
8564
+ return value;
8565
+ }
8566
+ return {
8567
+ inputs: value["inputs"].map(AudioSceneInputToJSON)
8568
+ };
8569
+ }
8570
+ function OutputRtmpClientAudioOptionsToJSON(json) {
8571
+ return OutputRtmpClientAudioOptionsToJSONTyped(json, false);
8572
+ }
8573
+ function OutputRtmpClientAudioOptionsToJSONTyped(value, ignoreDiscriminator = false) {
8574
+ if (value == null) {
8575
+ return value;
8576
+ }
8577
+ return {
8578
+ mixing_strategy: AudioMixingStrategyToJSON(value["mixingStrategy"]),
8579
+ send_eos_when: OutputEndConditionToJSON(value["sendEosWhen"]),
8580
+ channels: AudioChannelsToJSON(value["channels"]),
8581
+ initial: AudioSceneToJSON(value["initial"])
8582
+ };
8583
+ }
8584
+ function instanceOfRtmpOutput(value) {
8585
+ if (!("url" in value) || value["url"] === void 0) return false;
8586
+ if (!("type" in value) || value["type"] === void 0) return false;
8587
+ if (value["type"] !== "rtmp_client") return false;
8588
+ return true;
8589
+ }
8590
+ function RtmpOutputToJSON(json) {
8591
+ return RtmpOutputToJSONTyped(json, false);
8592
+ }
8593
+ function RtmpOutputToJSONTyped(value, ignoreDiscriminator = false) {
8594
+ if (value == null) {
8595
+ return value;
8596
+ }
8597
+ return {
8598
+ url: value["url"],
8599
+ video: OutputRtmpClientVideoOptionsToJSON(value["video"]),
8600
+ audio: OutputRtmpClientAudioOptionsToJSON(value["audio"]),
8601
+ type: value["type"]
8602
+ };
8603
+ }
8604
+ function OutputWhipVideoOptionsToJSON(json) {
8605
+ return OutputWhipVideoOptionsToJSONTyped(json, false);
8606
+ }
8607
+ function OutputWhipVideoOptionsToJSONTyped(value, ignoreDiscriminator = false) {
8608
+ if (value == null) {
8609
+ return value;
8610
+ }
8611
+ return {
8612
+ resolution: ResolutionToJSON(value["resolution"]),
8613
+ send_eos_when: OutputEndConditionToJSON(value["sendEosWhen"]),
8614
+ initial: VideoSceneToJSON(value["initial"])
8615
+ };
8616
+ }
8617
+ function instanceOfWhipAudioEncoderOptionsAny(value) {
8618
+ if (!("type" in value) || value["type"] === void 0) return false;
8619
+ if (value["type"] !== "any") return false;
8620
+ return true;
8621
+ }
8622
+ function WhipAudioEncoderOptionsAnyToJSON(json) {
8623
+ return WhipAudioEncoderOptionsAnyToJSONTyped(json, false);
8624
+ }
8625
+ function WhipAudioEncoderOptionsAnyToJSONTyped(value, ignoreDiscriminator = false) {
8626
+ if (value == null) {
8627
+ return value;
8628
+ }
8629
+ return {
8630
+ type: value["type"]
8631
+ };
8632
+ }
8633
+ function OpusEncoderPresetToJSON(value) {
8634
+ return value;
8635
+ }
8636
+ function instanceOfWhipAudioEncoderOptionsOpus(value) {
8637
+ if (!("type" in value) || value["type"] === void 0) return false;
8638
+ if (value["type"] !== "opus") return false;
8639
+ return true;
8640
+ }
8641
+ function WhipAudioEncoderOptionsOpusToJSON(json) {
8642
+ return WhipAudioEncoderOptionsOpusToJSONTyped(json, false);
8643
+ }
8644
+ function WhipAudioEncoderOptionsOpusToJSONTyped(value, ignoreDiscriminator = false) {
8645
+ if (value == null) {
8646
+ return value;
8647
+ }
8648
+ return {
8649
+ preset: OpusEncoderPresetToJSON(value["preset"]),
8650
+ sample_rate: value["sampleRate"],
8651
+ forward_error_correction: value["forwardErrorCorrection"],
8652
+ type: value["type"]
8653
+ };
8654
+ }
8655
+ function WhipAudioEncoderOptionsToJSON(json) {
8656
+ return WhipAudioEncoderOptionsToJSONTyped(json, false);
8657
+ }
8658
+ function WhipAudioEncoderOptionsToJSONTyped(value, ignoreDiscriminator = false) {
8659
+ if (value == null) {
8660
+ return value;
8661
+ }
8662
+ if (typeof value !== "object") {
8663
+ return value;
8664
+ }
8665
+ if (instanceOfWhipAudioEncoderOptionsAny(value)) {
8666
+ return WhipAudioEncoderOptionsAnyToJSON(value);
8667
+ }
8668
+ if (instanceOfWhipAudioEncoderOptionsOpus(value)) {
8669
+ return WhipAudioEncoderOptionsOpusToJSON(value);
8670
+ }
8671
+ return {};
8672
+ }
8673
+ function OutputWhipAudioOptionsToJSON(json) {
8674
+ return OutputWhipAudioOptionsToJSONTyped(json, false);
8675
+ }
8676
+ function OutputWhipAudioOptionsToJSONTyped(value, ignoreDiscriminator = false) {
8677
+ if (value == null) {
8678
+ return value;
8679
+ }
8680
+ return {
8681
+ mixing_strategy: AudioMixingStrategyToJSON(value["mixingStrategy"]),
8682
+ send_eos_when: OutputEndConditionToJSON(value["sendEosWhen"]),
8683
+ channels: AudioChannelsToJSON(value["channels"]),
8684
+ encoder_preferences: value["encoderPreferences"] == null ? void 0 : value["encoderPreferences"].map(WhipAudioEncoderOptionsToJSON),
8685
+ initial: AudioSceneToJSON(value["initial"])
8686
+ };
8687
+ }
8688
+ function instanceOfWhipOutput(value) {
8689
+ if (!("endpointUrl" in value) && !("endpoint_url" in value) || value["endpointUrl"] === void 0 && value["endpoint_url"] === void 0)
8690
+ return false;
8691
+ if (!("type" in value) || value["type"] === void 0) return false;
8692
+ if (value["type"] !== "whip_client") return false;
8693
+ return true;
8694
+ }
8695
+ function WhipOutputToJSON(json) {
8696
+ return WhipOutputToJSONTyped(json, false);
8697
+ }
8698
+ function WhipOutputToJSONTyped(value, ignoreDiscriminator = false) {
8699
+ if (value == null) {
8700
+ return value;
8701
+ }
8702
+ return {
8703
+ endpoint_url: value["endpointUrl"],
8704
+ bearer_token: value["bearerToken"],
8705
+ video: OutputWhipVideoOptionsToJSON(value["video"]),
8706
+ audio: OutputWhipAudioOptionsToJSON(value["audio"]),
8707
+ type: value["type"]
8708
+ };
8709
+ }
8710
+ function RegisterOutputToJSON(json) {
8711
+ return RegisterOutputToJSONTyped(json, false);
8712
+ }
8713
+ function RegisterOutputToJSONTyped(value, ignoreDiscriminator = false) {
8714
+ if (value == null) {
8715
+ return value;
8716
+ }
8717
+ if (typeof value !== "object") {
8718
+ return value;
8719
+ }
8720
+ if (instanceOfRtmpOutput(value)) {
8721
+ return RtmpOutputToJSON(value);
8722
+ }
8723
+ if (instanceOfWhipOutput(value)) {
8724
+ return WhipOutputToJSON(value);
8725
+ }
8726
+ return {};
8727
+ }
8728
+ function UnregisterOutputToJSON(json) {
8729
+ return UnregisterOutputToJSONTyped(json, false);
8730
+ }
8731
+ function UnregisterOutputToJSONTyped(value, ignoreDiscriminator = false) {
8732
+ if (value == null) {
8733
+ return value;
8734
+ }
8735
+ return {
8736
+ schedule_time_ms: value["scheduleTimeMs"]
8737
+ };
8738
+ }
8739
+ function UpdateOutputRequestToJSON(json) {
8740
+ return UpdateOutputRequestToJSONTyped(json, false);
8741
+ }
8742
+ function UpdateOutputRequestToJSONTyped(value, ignoreDiscriminator = false) {
8743
+ if (value == null) {
8744
+ return value;
8745
+ }
8746
+ return {
8747
+ video: VideoSceneToJSON(value["video"]),
8748
+ audio: AudioSceneToJSON(value["audio"]),
8749
+ schedule_time_ms: value["scheduleTimeMs"]
8750
+ };
8751
+ }
8752
+ var OutputsApi = class extends BaseAPI2 {
8753
+ /**
8754
+ * Creates request options for registerOutput without sending the request
8755
+ */
8756
+ async registerOutputRequestOpts(requestParameters) {
8757
+ if (requestParameters["compositionId"] == null) {
8758
+ throw new RequiredError2(
8759
+ "compositionId",
8760
+ 'Required parameter "compositionId" was null or undefined when calling registerOutput().'
8761
+ );
8762
+ }
8763
+ if (requestParameters["outputId"] == null) {
8764
+ throw new RequiredError2(
8765
+ "outputId",
8766
+ 'Required parameter "outputId" was null or undefined when calling registerOutput().'
8767
+ );
8768
+ }
8769
+ if (requestParameters["registerOutput"] == null) {
8770
+ throw new RequiredError2(
8771
+ "registerOutput",
8772
+ 'Required parameter "registerOutput" was null or undefined when calling registerOutput().'
8773
+ );
8774
+ }
8775
+ const queryParameters = {};
8776
+ const headerParameters = {};
8777
+ headerParameters["Content-Type"] = "application/json";
8778
+ if (this.configuration && this.configuration.accessToken) {
8779
+ const token = this.configuration.accessToken;
8780
+ const tokenString = await token("BearerAuth", []);
8781
+ if (tokenString) {
8782
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8783
+ }
8784
+ }
8785
+ let urlPath = `/api/composition/{composition_id}/output/{output_id}/register`;
8786
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8787
+ urlPath = urlPath.replace("{output_id}", encodeURIComponent(String(requestParameters["outputId"])));
8788
+ return {
8789
+ path: urlPath,
8790
+ method: "POST",
8791
+ headers: headerParameters,
8792
+ query: queryParameters,
8793
+ body: RegisterOutputToJSON(requestParameters["registerOutput"])
8794
+ };
8795
+ }
8796
+ /**
8797
+ * Register an output
8798
+ */
8799
+ async registerOutputRaw(requestParameters, initOverrides) {
8800
+ const requestOptions = await this.registerOutputRequestOpts(requestParameters);
8801
+ const response = await this.request(requestOptions, initOverrides);
8802
+ return new JSONApiResponse2(response);
8803
+ }
8804
+ /**
8805
+ * Register an output
8806
+ */
8807
+ async registerOutput(requestParameters, initOverrides) {
8808
+ const response = await this.registerOutputRaw(requestParameters, initOverrides);
8809
+ return await response.value();
8810
+ }
8811
+ /**
8812
+ * Creates request options for registerTemplateOutput without sending the request
8813
+ */
8814
+ async registerTemplateOutputRequestOpts(requestParameters) {
8815
+ if (requestParameters["compositionId"] == null) {
8816
+ throw new RequiredError2(
8817
+ "compositionId",
8818
+ 'Required parameter "compositionId" was null or undefined when calling registerTemplateOutput().'
8819
+ );
8820
+ }
8821
+ if (requestParameters["outputId"] == null) {
8822
+ throw new RequiredError2(
8823
+ "outputId",
8824
+ 'Required parameter "outputId" was null or undefined when calling registerTemplateOutput().'
8825
+ );
8826
+ }
8827
+ if (requestParameters["config"] == null) {
8828
+ throw new RequiredError2(
8829
+ "config",
8830
+ 'Required parameter "config" was null or undefined when calling registerTemplateOutput().'
8831
+ );
8832
+ }
8833
+ if (requestParameters["template"] == null) {
8834
+ throw new RequiredError2(
8835
+ "template",
8836
+ 'Required parameter "template" was null or undefined when calling registerTemplateOutput().'
8837
+ );
8838
+ }
8839
+ const queryParameters = {};
8840
+ const headerParameters = {};
8841
+ if (this.configuration && this.configuration.accessToken) {
8842
+ const token = this.configuration.accessToken;
8843
+ const tokenString = await token("BearerAuth", []);
8844
+ if (tokenString) {
8845
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8846
+ }
8847
+ }
8848
+ const consumes = [{ contentType: "multipart/form-data" }];
8849
+ const canConsumeForm2 = canConsumeForm(consumes);
8850
+ let formParams;
8851
+ let useForm = false;
8852
+ useForm = canConsumeForm2;
8853
+ if (useForm) {
8854
+ formParams = new FormData();
8855
+ } else {
8856
+ formParams = new URLSearchParams();
8857
+ }
8858
+ if (requestParameters["config"] != null) {
8859
+ formParams.append(
8860
+ "config",
8861
+ new Blob([JSON.stringify(RegisterOutputToJSON(requestParameters["config"]))], { type: "application/json" })
8862
+ );
8863
+ }
8864
+ if (requestParameters["template"] != null) {
8865
+ formParams.append("template", requestParameters["template"]);
8866
+ }
8867
+ let urlPath = `/api/composition/{composition_id}/output/{output_id}/template`;
8868
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8869
+ urlPath = urlPath.replace("{output_id}", encodeURIComponent(String(requestParameters["outputId"])));
8870
+ return {
8871
+ path: urlPath,
8872
+ method: "POST",
8873
+ headers: headerParameters,
8874
+ query: queryParameters,
8875
+ body: formParams
8876
+ };
8877
+ }
8878
+ /**
8879
+ * Register a templated output
8880
+ */
8881
+ async registerTemplateOutputRaw(requestParameters, initOverrides) {
8882
+ const requestOptions = await this.registerTemplateOutputRequestOpts(requestParameters);
8883
+ const response = await this.request(requestOptions, initOverrides);
8884
+ return new JSONApiResponse2(response);
8885
+ }
8886
+ /**
8887
+ * Register a templated output
8888
+ */
8889
+ async registerTemplateOutput(requestParameters, initOverrides) {
8890
+ const response = await this.registerTemplateOutputRaw(requestParameters, initOverrides);
8891
+ return await response.value();
8892
+ }
8893
+ /**
8894
+ * Creates request options for requestKeyframe without sending the request
8895
+ */
8896
+ async requestKeyframeRequestOpts(requestParameters) {
8897
+ if (requestParameters["compositionId"] == null) {
8898
+ throw new RequiredError2(
8899
+ "compositionId",
8900
+ 'Required parameter "compositionId" was null or undefined when calling requestKeyframe().'
8901
+ );
8902
+ }
8903
+ if (requestParameters["outputId"] == null) {
8904
+ throw new RequiredError2(
8905
+ "outputId",
8906
+ 'Required parameter "outputId" was null or undefined when calling requestKeyframe().'
8907
+ );
8908
+ }
8909
+ const queryParameters = {};
8910
+ const headerParameters = {};
8911
+ if (this.configuration && this.configuration.accessToken) {
8912
+ const token = this.configuration.accessToken;
8913
+ const tokenString = await token("BearerAuth", []);
8914
+ if (tokenString) {
8915
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8916
+ }
8917
+ }
8918
+ let urlPath = `/api/composition/{composition_id}/output/{output_id}/request_keyframe`;
8919
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8920
+ urlPath = urlPath.replace("{output_id}", encodeURIComponent(String(requestParameters["outputId"])));
8921
+ return {
8922
+ path: urlPath,
8923
+ method: "POST",
8924
+ headers: headerParameters,
8925
+ query: queryParameters
8926
+ };
8927
+ }
8928
+ /**
8929
+ * Request a keyframe
8930
+ */
8931
+ async requestKeyframeRaw(requestParameters, initOverrides) {
8932
+ const requestOptions = await this.requestKeyframeRequestOpts(requestParameters);
8933
+ const response = await this.request(requestOptions, initOverrides);
8934
+ return new JSONApiResponse2(response);
8935
+ }
8936
+ /**
8937
+ * Request a keyframe
8938
+ */
8939
+ async requestKeyframe(requestParameters, initOverrides) {
8940
+ const response = await this.requestKeyframeRaw(requestParameters, initOverrides);
8941
+ return await response.value();
8942
+ }
8943
+ /**
8944
+ * Creates request options for unregisterOutput without sending the request
8945
+ */
8946
+ async unregisterOutputRequestOpts(requestParameters) {
8947
+ if (requestParameters["compositionId"] == null) {
8948
+ throw new RequiredError2(
8949
+ "compositionId",
8950
+ 'Required parameter "compositionId" was null or undefined when calling unregisterOutput().'
8951
+ );
8952
+ }
8953
+ if (requestParameters["outputId"] == null) {
8954
+ throw new RequiredError2(
8955
+ "outputId",
8956
+ 'Required parameter "outputId" was null or undefined when calling unregisterOutput().'
8957
+ );
8958
+ }
8959
+ if (requestParameters["unregisterOutput"] == null) {
8960
+ throw new RequiredError2(
8961
+ "unregisterOutput",
8962
+ 'Required parameter "unregisterOutput" was null or undefined when calling unregisterOutput().'
8963
+ );
8964
+ }
8965
+ const queryParameters = {};
8966
+ const headerParameters = {};
8967
+ headerParameters["Content-Type"] = "application/json";
8968
+ if (this.configuration && this.configuration.accessToken) {
8969
+ const token = this.configuration.accessToken;
8970
+ const tokenString = await token("BearerAuth", []);
8971
+ if (tokenString) {
8972
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
8973
+ }
8974
+ }
8975
+ let urlPath = `/api/composition/{composition_id}/output/{output_id}/unregister`;
8976
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
8977
+ urlPath = urlPath.replace("{output_id}", encodeURIComponent(String(requestParameters["outputId"])));
8978
+ return {
8979
+ path: urlPath,
8980
+ method: "POST",
8981
+ headers: headerParameters,
8982
+ query: queryParameters,
8983
+ body: UnregisterOutputToJSON(requestParameters["unregisterOutput"])
8984
+ };
8985
+ }
8986
+ /**
8987
+ * Unregister an output
8988
+ */
8989
+ async unregisterOutputRaw(requestParameters, initOverrides) {
8990
+ const requestOptions = await this.unregisterOutputRequestOpts(requestParameters);
8991
+ const response = await this.request(requestOptions, initOverrides);
8992
+ return new JSONApiResponse2(response);
8993
+ }
8994
+ /**
8995
+ * Unregister an output
8996
+ */
8997
+ async unregisterOutput(requestParameters, initOverrides) {
8998
+ const response = await this.unregisterOutputRaw(requestParameters, initOverrides);
8999
+ return await response.value();
9000
+ }
9001
+ /**
9002
+ * Creates request options for updateOutput without sending the request
9003
+ */
9004
+ async updateOutputRequestOpts(requestParameters) {
9005
+ if (requestParameters["compositionId"] == null) {
9006
+ throw new RequiredError2(
9007
+ "compositionId",
9008
+ 'Required parameter "compositionId" was null or undefined when calling updateOutput().'
9009
+ );
9010
+ }
9011
+ if (requestParameters["outputId"] == null) {
9012
+ throw new RequiredError2(
9013
+ "outputId",
9014
+ 'Required parameter "outputId" was null or undefined when calling updateOutput().'
9015
+ );
9016
+ }
9017
+ if (requestParameters["updateOutputRequest"] == null) {
9018
+ throw new RequiredError2(
9019
+ "updateOutputRequest",
9020
+ 'Required parameter "updateOutputRequest" was null or undefined when calling updateOutput().'
9021
+ );
9022
+ }
9023
+ const queryParameters = {};
9024
+ const headerParameters = {};
9025
+ headerParameters["Content-Type"] = "application/json";
9026
+ if (this.configuration && this.configuration.accessToken) {
9027
+ const token = this.configuration.accessToken;
9028
+ const tokenString = await token("BearerAuth", []);
9029
+ if (tokenString) {
9030
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
9031
+ }
9032
+ }
9033
+ let urlPath = `/api/composition/{composition_id}/output/{output_id}/update`;
9034
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
9035
+ urlPath = urlPath.replace("{output_id}", encodeURIComponent(String(requestParameters["outputId"])));
9036
+ return {
9037
+ path: urlPath,
9038
+ method: "POST",
9039
+ headers: headerParameters,
9040
+ query: queryParameters,
9041
+ body: UpdateOutputRequestToJSON(requestParameters["updateOutputRequest"])
9042
+ };
9043
+ }
9044
+ /**
9045
+ * Update an output\'s scene
9046
+ */
9047
+ async updateOutputRaw(requestParameters, initOverrides) {
9048
+ const requestOptions = await this.updateOutputRequestOpts(requestParameters);
9049
+ const response = await this.request(requestOptions, initOverrides);
9050
+ return new JSONApiResponse2(response);
9051
+ }
9052
+ /**
9053
+ * Update an output\'s scene
9054
+ */
9055
+ async updateOutput(requestParameters, initOverrides) {
9056
+ const response = await this.updateOutputRaw(requestParameters, initOverrides);
9057
+ return await response.value();
9058
+ }
9059
+ };
9060
+ function instanceOfImageSpecAuto(value) {
9061
+ if (!("url" in value) || value["url"] === void 0) return false;
9062
+ if (!("assetType" in value) && !("asset_type" in value) || value["assetType"] === void 0 && value["asset_type"] === void 0)
9063
+ return false;
9064
+ if (value["assetType"] !== "auto" && value["asset_type"] !== "auto")
9065
+ return false;
9066
+ return true;
9067
+ }
9068
+ function ImageSpecAutoToJSON(json) {
9069
+ return ImageSpecAutoToJSONTyped(json, false);
9070
+ }
9071
+ function ImageSpecAutoToJSONTyped(value, ignoreDiscriminator = false) {
9072
+ if (value == null) {
9073
+ return value;
9074
+ }
9075
+ return {
9076
+ url: value["url"],
9077
+ asset_type: value["assetType"]
9078
+ };
9079
+ }
9080
+ function instanceOfImageSpecGif(value) {
9081
+ if (!("url" in value) || value["url"] === void 0) return false;
9082
+ if (!("assetType" in value) && !("asset_type" in value) || value["assetType"] === void 0 && value["asset_type"] === void 0)
9083
+ return false;
9084
+ if (value["assetType"] !== "gif" && value["asset_type"] !== "gif")
9085
+ return false;
9086
+ return true;
9087
+ }
9088
+ function ImageSpecGifToJSON(json) {
9089
+ return ImageSpecGifToJSONTyped(json, false);
9090
+ }
9091
+ function ImageSpecGifToJSONTyped(value, ignoreDiscriminator = false) {
9092
+ if (value == null) {
9093
+ return value;
9094
+ }
9095
+ return {
9096
+ url: value["url"],
9097
+ asset_type: value["assetType"]
9098
+ };
9099
+ }
9100
+ function instanceOfImageSpecJpeg(value) {
9101
+ if (!("url" in value) || value["url"] === void 0) return false;
9102
+ if (!("assetType" in value) && !("asset_type" in value) || value["assetType"] === void 0 && value["asset_type"] === void 0)
9103
+ return false;
9104
+ if (value["assetType"] !== "jpeg" && value["asset_type"] !== "jpeg")
9105
+ return false;
9106
+ return true;
9107
+ }
9108
+ function ImageSpecJpegToJSON(json) {
9109
+ return ImageSpecJpegToJSONTyped(json, false);
9110
+ }
9111
+ function ImageSpecJpegToJSONTyped(value, ignoreDiscriminator = false) {
9112
+ if (value == null) {
9113
+ return value;
9114
+ }
9115
+ return {
9116
+ url: value["url"],
9117
+ asset_type: value["assetType"]
9118
+ };
9119
+ }
9120
+ function instanceOfImageSpecPng(value) {
9121
+ if (!("url" in value) || value["url"] === void 0) return false;
9122
+ if (!("assetType" in value) && !("asset_type" in value) || value["assetType"] === void 0 && value["asset_type"] === void 0)
9123
+ return false;
9124
+ if (value["assetType"] !== "png" && value["asset_type"] !== "png")
9125
+ return false;
9126
+ return true;
9127
+ }
9128
+ function ImageSpecPngToJSON(json) {
9129
+ return ImageSpecPngToJSONTyped(json, false);
9130
+ }
9131
+ function ImageSpecPngToJSONTyped(value, ignoreDiscriminator = false) {
9132
+ if (value == null) {
9133
+ return value;
9134
+ }
9135
+ return {
9136
+ url: value["url"],
9137
+ asset_type: value["assetType"]
9138
+ };
9139
+ }
9140
+ function instanceOfImageSpecSvg(value) {
9141
+ if (!("url" in value) || value["url"] === void 0) return false;
9142
+ if (!("assetType" in value) && !("asset_type" in value) || value["assetType"] === void 0 && value["asset_type"] === void 0)
9143
+ return false;
9144
+ if (value["assetType"] !== "svg" && value["asset_type"] !== "svg")
9145
+ return false;
9146
+ return true;
9147
+ }
9148
+ function ImageSpecSvgToJSON(json) {
9149
+ return ImageSpecSvgToJSONTyped(json, false);
9150
+ }
9151
+ function ImageSpecSvgToJSONTyped(value, ignoreDiscriminator = false) {
9152
+ if (value == null) {
9153
+ return value;
9154
+ }
9155
+ return {
9156
+ url: value["url"],
9157
+ resolution: ResolutionToJSON(value["resolution"]),
9158
+ asset_type: value["assetType"]
9159
+ };
9160
+ }
9161
+ function ImageSpecToJSON(json) {
9162
+ return ImageSpecToJSONTyped(json, false);
9163
+ }
9164
+ function ImageSpecToJSONTyped(value, ignoreDiscriminator = false) {
9165
+ if (value == null) {
9166
+ return value;
9167
+ }
9168
+ if (typeof value !== "object") {
9169
+ return value;
9170
+ }
9171
+ if (instanceOfImageSpecAuto(value)) {
9172
+ return ImageSpecAutoToJSON(value);
9173
+ }
9174
+ if (instanceOfImageSpecGif(value)) {
9175
+ return ImageSpecGifToJSON(value);
9176
+ }
9177
+ if (instanceOfImageSpecJpeg(value)) {
9178
+ return ImageSpecJpegToJSON(value);
9179
+ }
9180
+ if (instanceOfImageSpecPng(value)) {
9181
+ return ImageSpecPngToJSON(value);
9182
+ }
9183
+ if (instanceOfImageSpecSvg(value)) {
9184
+ return ImageSpecSvgToJSON(value);
9185
+ }
9186
+ return {};
9187
+ }
9188
+ function UnregisterRendererToJSON(json) {
9189
+ return UnregisterRendererToJSONTyped(json, false);
9190
+ }
9191
+ function UnregisterRendererToJSONTyped(value, ignoreDiscriminator = false) {
9192
+ if (value == null) {
9193
+ return value;
9194
+ }
9195
+ return {
9196
+ schedule_time_ms: value["scheduleTimeMs"]
9197
+ };
9198
+ }
9199
+ var RenderersApi = class extends BaseAPI2 {
9200
+ /**
9201
+ * Creates request options for registerFont without sending the request
9202
+ */
9203
+ async registerFontRequestOpts(requestParameters) {
9204
+ if (requestParameters["compositionId"] == null) {
9205
+ throw new RequiredError2(
9206
+ "compositionId",
9207
+ 'Required parameter "compositionId" was null or undefined when calling registerFont().'
9208
+ );
9209
+ }
9210
+ if (requestParameters["font"] == null) {
9211
+ throw new RequiredError2(
9212
+ "font",
9213
+ 'Required parameter "font" was null or undefined when calling registerFont().'
9214
+ );
9215
+ }
9216
+ const queryParameters = {};
9217
+ const headerParameters = {};
9218
+ if (this.configuration && this.configuration.accessToken) {
9219
+ const token = this.configuration.accessToken;
9220
+ const tokenString = await token("BearerAuth", []);
9221
+ if (tokenString) {
9222
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
9223
+ }
9224
+ }
9225
+ const consumes = [{ contentType: "multipart/form-data" }];
9226
+ const canConsumeForm2 = canConsumeForm(consumes);
9227
+ let formParams;
9228
+ let useForm = false;
9229
+ useForm = canConsumeForm2;
9230
+ if (useForm) {
9231
+ formParams = new FormData();
9232
+ } else {
9233
+ formParams = new URLSearchParams();
9234
+ }
9235
+ if (requestParameters["font"] != null) {
9236
+ formParams.append("font", requestParameters["font"]);
9237
+ }
9238
+ let urlPath = `/api/composition/{composition_id}/font/register`;
9239
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
9240
+ return {
9241
+ path: urlPath,
9242
+ method: "POST",
9243
+ headers: headerParameters,
9244
+ query: queryParameters,
9245
+ body: formParams
9246
+ };
9247
+ }
9248
+ /**
9249
+ * Register a font
9250
+ */
9251
+ async registerFontRaw(requestParameters, initOverrides) {
9252
+ const requestOptions = await this.registerFontRequestOpts(requestParameters);
9253
+ const response = await this.request(requestOptions, initOverrides);
9254
+ return new JSONApiResponse2(response);
9255
+ }
9256
+ /**
9257
+ * Register a font
9258
+ */
9259
+ async registerFont(requestParameters, initOverrides) {
9260
+ const response = await this.registerFontRaw(requestParameters, initOverrides);
9261
+ return await response.value();
9262
+ }
9263
+ /**
9264
+ * Creates request options for registerImage without sending the request
9265
+ */
9266
+ async registerImageRequestOpts(requestParameters) {
9267
+ if (requestParameters["compositionId"] == null) {
9268
+ throw new RequiredError2(
9269
+ "compositionId",
9270
+ 'Required parameter "compositionId" was null or undefined when calling registerImage().'
9271
+ );
9272
+ }
9273
+ if (requestParameters["imageId"] == null) {
9274
+ throw new RequiredError2(
9275
+ "imageId",
9276
+ 'Required parameter "imageId" was null or undefined when calling registerImage().'
9277
+ );
9278
+ }
9279
+ if (requestParameters["imageSpec"] == null) {
9280
+ throw new RequiredError2(
9281
+ "imageSpec",
9282
+ 'Required parameter "imageSpec" was null or undefined when calling registerImage().'
9283
+ );
9284
+ }
9285
+ const queryParameters = {};
9286
+ const headerParameters = {};
9287
+ headerParameters["Content-Type"] = "application/json";
9288
+ if (this.configuration && this.configuration.accessToken) {
9289
+ const token = this.configuration.accessToken;
9290
+ const tokenString = await token("BearerAuth", []);
9291
+ if (tokenString) {
9292
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
9293
+ }
9294
+ }
9295
+ let urlPath = `/api/composition/{composition_id}/image/{image_id}/register`;
9296
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
9297
+ urlPath = urlPath.replace("{image_id}", encodeURIComponent(String(requestParameters["imageId"])));
9298
+ return {
9299
+ path: urlPath,
9300
+ method: "POST",
9301
+ headers: headerParameters,
9302
+ query: queryParameters,
9303
+ body: ImageSpecToJSON(requestParameters["imageSpec"])
9304
+ };
9305
+ }
9306
+ /**
9307
+ * Register an image
9308
+ */
9309
+ async registerImageRaw(requestParameters, initOverrides) {
9310
+ const requestOptions = await this.registerImageRequestOpts(requestParameters);
9311
+ const response = await this.request(requestOptions, initOverrides);
9312
+ return new JSONApiResponse2(response);
9313
+ }
9314
+ /**
9315
+ * Register an image
9316
+ */
9317
+ async registerImage(requestParameters, initOverrides) {
9318
+ const response = await this.registerImageRaw(requestParameters, initOverrides);
9319
+ return await response.value();
9320
+ }
9321
+ /**
9322
+ * Creates request options for unregisterImage without sending the request
9323
+ */
9324
+ async unregisterImageRequestOpts(requestParameters) {
9325
+ if (requestParameters["compositionId"] == null) {
9326
+ throw new RequiredError2(
9327
+ "compositionId",
9328
+ 'Required parameter "compositionId" was null or undefined when calling unregisterImage().'
9329
+ );
9330
+ }
9331
+ if (requestParameters["imageId"] == null) {
9332
+ throw new RequiredError2(
9333
+ "imageId",
9334
+ 'Required parameter "imageId" was null or undefined when calling unregisterImage().'
9335
+ );
9336
+ }
9337
+ if (requestParameters["unregisterRenderer"] == null) {
9338
+ throw new RequiredError2(
9339
+ "unregisterRenderer",
9340
+ 'Required parameter "unregisterRenderer" was null or undefined when calling unregisterImage().'
9341
+ );
9342
+ }
9343
+ const queryParameters = {};
9344
+ const headerParameters = {};
9345
+ headerParameters["Content-Type"] = "application/json";
9346
+ if (this.configuration && this.configuration.accessToken) {
9347
+ const token = this.configuration.accessToken;
9348
+ const tokenString = await token("BearerAuth", []);
9349
+ if (tokenString) {
9350
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
9351
+ }
9352
+ }
9353
+ let urlPath = `/api/composition/{composition_id}/image/{image_id}/unregister`;
9354
+ urlPath = urlPath.replace("{composition_id}", encodeURIComponent(String(requestParameters["compositionId"])));
9355
+ urlPath = urlPath.replace("{image_id}", encodeURIComponent(String(requestParameters["imageId"])));
9356
+ return {
9357
+ path: urlPath,
9358
+ method: "POST",
9359
+ headers: headerParameters,
9360
+ query: queryParameters,
9361
+ body: UnregisterRendererToJSON(requestParameters["unregisterRenderer"])
9362
+ };
9363
+ }
9364
+ /**
9365
+ * Unregister an image
9366
+ */
9367
+ async unregisterImageRaw(requestParameters, initOverrides) {
9368
+ const requestOptions = await this.unregisterImageRequestOpts(requestParameters);
9369
+ const response = await this.request(requestOptions, initOverrides);
9370
+ return new JSONApiResponse2(response);
9371
+ }
9372
+ /**
9373
+ * Unregister an image
9374
+ */
9375
+ async unregisterImage(requestParameters, initOverrides) {
9376
+ const response = await this.unregisterImageRaw(requestParameters, initOverrides);
9377
+ return await response.value();
9378
+ }
9379
+ };
9380
+
9381
+ // src/exceptions/mapper.ts
9382
+ var notFoundException = (info, entity) => {
9383
+ switch (entity) {
9384
+ case "composition":
9385
+ return new CompositionNotFoundException(info);
9386
+ case "credentials":
9387
+ return new InvalidFishjamCredentialsException(info);
9388
+ case "input":
9389
+ return new InputNotFoundException(info);
9390
+ case "output":
9391
+ return new OutputNotFoundException(info);
9392
+ case "peer":
9393
+ return new PeerNotFoundException(info);
9394
+ case "recording":
9395
+ return new RecordingNotFoundException(info);
9396
+ case "renderer":
9397
+ return new RendererNotFoundException(info);
9398
+ case "room":
9399
+ return new RoomNotFoundException(info);
9400
+ default:
9401
+ return new FishjamNotFoundException(info);
9402
+ }
9403
+ };
9404
+ var mapException = async (error, entity) => {
9405
+ if (error instanceof FetchError || error instanceof FetchError2) {
9406
+ return new UnknownException({ message: error.cause.message, statusCode: 500, details: error.cause.message });
9407
+ }
9408
+ if (!(error instanceof ResponseError) && !(error instanceof ResponseError2)) {
9409
+ return error;
9410
+ }
9411
+ const status = error.response.status;
9412
+ const body = await error.response.json().catch(() => ({}));
9413
+ const info = {
9414
+ message: `Request failed with status code ${status}`,
9415
+ statusCode: status,
9416
+ details: body["detail"] ?? body["errors"] ?? body["message"] ?? "Unknown error"
9417
+ };
9418
+ switch (status) {
9419
+ case 400:
9420
+ case 422:
9421
+ return new BadRequestException(info);
9422
+ case 402:
9423
+ return new QuotaExceededException(info);
9424
+ case 401:
9425
+ return new UnauthorizedException(info);
9426
+ case 404:
9427
+ return notFoundException(info, entity);
9428
+ case 503:
9429
+ return new ServiceUnavailableException(info);
9430
+ default:
9431
+ return new UnknownException(info);
9432
+ }
9433
+ };
9434
+
9435
+ // src/client.ts
9436
+ var FishjamClient = class _FishjamClient {
9437
+ moqApi;
9438
+ roomApi;
9439
+ viewerApi;
9440
+ streamerApi;
9441
+ credentialsApi;
9442
+ recordingsApi;
9443
+ trackForwardingsApi;
9444
+ fishjamConfig;
9445
+ deprecationWarningShown = false;
9446
+ /**
9447
+ * Create new instance of Fishjam Client.
9448
+ *
9449
+ * Does not verify credentials against the backend — use
9450
+ * {@link FishjamClient.create} or call
9451
+ * {@link FishjamClient.checkCredentials} afterwards for that.
9452
+ *
9453
+ * Example usage:
9454
+ * ```
9455
+ * const fishjamClient = new FishjamClient({
9456
+ * fishjamId: fastify.config.FISHJAM_ID,
9457
+ * managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
9458
+ * });
9459
+ * ```
9460
+ */
9461
+ constructor(config) {
9462
+ const deprecationMiddleware = {
9463
+ post: async ({ response }) => {
9464
+ this.handleDeprecationHeader(response.headers);
9465
+ return response;
9466
+ }
9467
+ };
9468
+ const apiConfig = new Configuration({
9469
+ basePath: getFishjamUrl(config),
9470
+ headers: {
9471
+ Authorization: `Bearer ${config.managementToken}`,
9472
+ "x-fishjam-api-client": `js-server/${package_default.version}`
9473
+ },
9474
+ middleware: [deprecationMiddleware]
9475
+ });
9476
+ this.moqApi = new MoQApi(apiConfig);
9477
+ this.roomApi = new RoomsApi(apiConfig);
9478
+ this.viewerApi = new ViewersApi(apiConfig);
9479
+ this.streamerApi = new StreamersApi(apiConfig);
9480
+ this.credentialsApi = new CredentialsApi(apiConfig);
9481
+ this.recordingsApi = new RecordingsApi(apiConfig);
9482
+ this.trackForwardingsApi = new TrackForwardingsApi(apiConfig);
9483
+ this.fishjamConfig = config;
9484
+ }
9485
+ /**
9486
+ * Async factory: constructs a client and verifies credentials against
9487
+ * the backend.
9488
+ *
9489
+ * Throws {@link InvalidFishjamCredentialsException} when the
9490
+ * `fishjamId` / `managementToken` pair is rejected by the backend.
9491
+ *
9492
+ * Example:
9493
+ * ```
9494
+ * const client = await FishjamClient.create({
9495
+ * fishjamId: process.env.FISHJAM_ID!,
9496
+ * managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
9497
+ * });
9498
+ * ```
9499
+ */
9500
+ static async create(config) {
9501
+ const client = new _FishjamClient(config);
9502
+ await client.checkCredentials();
9503
+ return client;
9504
+ }
9505
+ /**
9506
+ * Verifies the configured credentials by making a single lightweight
9507
+ * call to the Fishjam backend. Resolves on success, throws
9508
+ * {@link InvalidFishjamCredentialsException} on 401/404 from the backend,
9509
+ * otherwise rethrows the standard mapped exception.
9510
+ */
9511
+ async checkCredentials() {
9512
+ try {
9513
+ await this.credentialsApi.validateCredentials();
9514
+ } catch (error) {
9515
+ throw await mapException(error, "credentials");
9516
+ }
9517
+ }
9518
+ handleDeprecationHeader(headers) {
9519
+ try {
9520
+ const deprecationHeader = headers.get("x-fishjam-api-deprecated");
9521
+ if (!deprecationHeader || this.deprecationWarningShown) return;
6777
9522
  const deprecationStatus = JSON.parse(deprecationHeader);
6778
9523
  if (deprecationStatus.status === "unsupported") {
6779
9524
  console.error(deprecationStatus.message);
@@ -6920,6 +9665,29 @@ var FishjamClient = class _FishjamClient {
6920
9665
  throw await mapException(error, "peer");
6921
9666
  }
6922
9667
  }
9668
+ /**
9669
+ * Forwards every track published in the room into a composition, which composes them into
9670
+ * its outputs. Pass the composition's address, as returned by
9671
+ * {@link CompositionClient.compositionUrl}.
9672
+ */
9673
+ async forwardRoomTracks(roomId, compositionUrl) {
9674
+ try {
9675
+ await this.trackForwardingsApi.createTrackForwarding({
9676
+ roomId,
9677
+ trackForwarding: { compositionURL: compositionUrl }
9678
+ });
9679
+ } catch (error) {
9680
+ throw await mapException(error, "room");
9681
+ }
9682
+ }
9683
+ /**
9684
+ * Where to publish a livestream, paired with a token from
9685
+ * {@link FishjamClient.createLivestreamStreamerToken}. A composition reaches viewers by
9686
+ * sending a WHIP output here.
9687
+ */
9688
+ livestreamWhipUrl() {
9689
+ return getLivestreamWhipUrl(this.fishjamConfig);
9690
+ }
6923
9691
  /**
6924
9692
  * Creates a livestream viewer token for the given room.
6925
9693
  * @returns a livestream viewer token
@@ -6953,24 +9721,342 @@ var FishjamClient = class _FishjamClient {
6953
9721
  throw await mapException(error);
6954
9722
  }
6955
9723
  }
9724
+ /**
9725
+ * Create a new recording. Capturing starts synchronously, so the returned recording is `active`.
9726
+ */
9727
+ async createRecording(config) {
9728
+ try {
9729
+ const { data } = await this.recordingsApi.createRecording({ recordingConfig: config });
9730
+ return data;
9731
+ } catch (error) {
9732
+ throw await mapException(error);
9733
+ }
9734
+ }
9735
+ /**
9736
+ * Get details about a given recording.
9737
+ */
9738
+ async getRecording(recordingId) {
9739
+ try {
9740
+ const { data } = await this.recordingsApi.getRecording({ recordingId });
9741
+ return data;
9742
+ } catch (error) {
9743
+ throw await mapException(error, "recording");
9744
+ }
9745
+ }
9746
+ /**
9747
+ * Get a list of all recordings, optionally filtered by metadata.
9748
+ * Returns recordings whose metadata contains all the given key-value pairs.
9749
+ */
9750
+ async getAllRecordings(metadata) {
9751
+ const metadataQuery = metadata ? Object.fromEntries(Object.entries(metadata).map(([key, value]) => [`metadata[${key}]`, value])) : void 0;
9752
+ try {
9753
+ const { data } = await this.recordingsApi.listRecordings({ metadata: metadataQuery });
9754
+ return data ?? [];
9755
+ } catch (error) {
9756
+ throw await mapException(error);
9757
+ }
9758
+ }
9759
+ /**
9760
+ * Stop an active recording. Finalization is asynchronous: the recording stays `active` until
9761
+ * the capture is finalized, then becomes `finished`. Stopping a recording that is no longer active is a no-op.
9762
+ */
9763
+ async stopRecording(recordingId) {
9764
+ try {
9765
+ const { data } = await this.recordingsApi.stopRecording({ recordingId });
9766
+ return data;
9767
+ } catch (error) {
9768
+ throw await mapException(error, "recording");
9769
+ }
9770
+ }
9771
+ /**
9772
+ * Delete a recording. Its stored media is removed asynchronously.
9773
+ * A recording that is still `active` cannot be deleted — stop it first or wait for it to finish.
9774
+ */
9775
+ async deleteRecording(recordingId) {
9776
+ try {
9777
+ await this.recordingsApi.deleteRecording({ recordingId });
9778
+ } catch (error) {
9779
+ throw await mapException(error, "recording");
9780
+ }
9781
+ }
9782
+ };
9783
+
9784
+ // src/composition.ts
9785
+ var CompositionClient = class {
9786
+ compositionsApi;
9787
+ eventsApi;
9788
+ inputsApi;
9789
+ mediaTransportApi;
9790
+ outputsApi;
9791
+ renderersApi;
9792
+ baseUrl;
9793
+ constructor(config) {
9794
+ this.baseUrl = getCompositionOrigin(config);
9795
+ const apiConfig = new Configuration2({
9796
+ basePath: this.baseUrl,
9797
+ headers: { Authorization: `Bearer ${config.managementToken}` }
9798
+ });
9799
+ this.compositionsApi = new CompositionsApi(apiConfig);
9800
+ this.eventsApi = new EventsApi(apiConfig);
9801
+ this.inputsApi = new InputsApi(apiConfig);
9802
+ this.mediaTransportApi = new MediaTransportApi(apiConfig);
9803
+ this.outputsApi = new OutputsApi(apiConfig);
9804
+ this.renderersApi = new RenderersApi(apiConfig);
9805
+ }
9806
+ /**
9807
+ * Create a new composition. Inputs registered on it are composed into the scenes its outputs render.
9808
+ */
9809
+ async createComposition(config = {}) {
9810
+ try {
9811
+ return await this.compositionsApi.createComposition({ createCompositionRequest: config });
9812
+ } catch (error) {
9813
+ throw await mapException(error);
9814
+ }
9815
+ }
9816
+ /**
9817
+ * The address of a composition, as other services refer to it. Fishjam needs it to forward a
9818
+ * room's tracks with {@link FishjamClient.forwardRoomTracks}.
9819
+ */
9820
+ compositionUrl(compositionId) {
9821
+ return new URL(`/api/composition/${compositionId}`, this.baseUrl).href;
9822
+ }
9823
+ /**
9824
+ * Start a composition created with `autostart` disabled. Its outputs begin producing audio and video.
9825
+ */
9826
+ async startComposition(compositionId) {
9827
+ try {
9828
+ await this.compositionsApi.start({ compositionId });
9829
+ } catch (error) {
9830
+ throw await mapException(error, "composition");
9831
+ }
9832
+ }
9833
+ /**
9834
+ * Reset a composition, tearing down its scene while keeping the composition itself alive.
9835
+ */
9836
+ async resetComposition(compositionId) {
9837
+ try {
9838
+ await this.compositionsApi.reset({ compositionId });
9839
+ } catch (error) {
9840
+ throw await mapException(error, "composition");
9841
+ }
9842
+ }
9843
+ /**
9844
+ * Delete an existing composition. Its inputs and outputs are torn down with it.
9845
+ */
9846
+ async deleteComposition(compositionId) {
9847
+ try {
9848
+ await this.compositionsApi.deleteComposition({ compositionId });
9849
+ } catch (error) {
9850
+ throw await mapException(error, "composition");
9851
+ }
9852
+ }
9853
+ /**
9854
+ * Register a media source on a composition. Prefer the variant methods, such as
9855
+ * {@link CompositionClient.registerWhipInput}, which return what that input type produces.
9856
+ */
9857
+ async registerInput(compositionId, inputId, input) {
9858
+ try {
9859
+ return await this.inputsApi.registerInput({ compositionId, inputId, registerInput: input });
9860
+ } catch (error) {
9861
+ throw await mapException(error, "composition");
9862
+ }
9863
+ }
9864
+ /**
9865
+ * Register an input that a WHIP publisher pushes media into.
9866
+ * @returns the address and token to publish with, see {@link WhipInputTarget}
9867
+ */
9868
+ async registerWhipInput(compositionId, inputId, options = {}) {
9869
+ const { bearerToken, endpointRoute } = await this.registerInput(compositionId, inputId, {
9870
+ ...options,
9871
+ type: "whip_server"
9872
+ });
9873
+ if (!bearerToken) {
9874
+ throw new UnknownException({
9875
+ message: `Could not obtain a publishing token for input "${inputId}", retry or report it`
9876
+ });
9877
+ }
9878
+ const url = endpointRoute ? `${this.compositionUrl(compositionId)}/${endpointRoute.replace(/^\//, "")}` : await this.whipPath(compositionId, inputId);
9879
+ return { url, bearerToken };
9880
+ }
9881
+ /**
9882
+ * Where WHIP publishing is served, for servers that do not report the route themselves.
9883
+ */
9884
+ async whipPath(compositionId, inputId) {
9885
+ const { path } = await this.mediaTransportApi.whipOfferRequestOpts({ compositionId, inputId, body: "" });
9886
+ return new URL(path, this.baseUrl).href;
9887
+ }
9888
+ /**
9889
+ * Register an input that pulls media from a WHEP endpoint.
9890
+ */
9891
+ async registerWhepInput(compositionId, inputId, options) {
9892
+ await this.registerInput(compositionId, inputId, { ...options, type: "whep_client" });
9893
+ }
9894
+ /**
9895
+ * Register an input that plays an MP4 file.
9896
+ * @returns how much media the file holds, see {@link Mp4InputDurations}
9897
+ */
9898
+ async registerMp4Input(compositionId, inputId, options) {
9899
+ const { videoDurationMs, audioDurationMs } = await this.registerInput(compositionId, inputId, {
9900
+ ...options,
9901
+ type: "mp4"
9902
+ });
9903
+ return { videoDurationMs: videoDurationMs ?? void 0, audioDurationMs: audioDurationMs ?? void 0 };
9904
+ }
9905
+ /**
9906
+ * Register an input that an RTMP publisher pushes media into. The stream key identifies the
9907
+ * input; the address to publish to belongs to the composition, not to this call.
9908
+ */
9909
+ async registerRtmpInput(compositionId, inputId, options) {
9910
+ await this.registerInput(compositionId, inputId, { ...options, type: "rtmp_server" });
9911
+ }
9912
+ /**
9913
+ * Unregister an input. Scenes referencing it stop receiving its media.
9914
+ */
9915
+ async unregisterInput(compositionId, inputId, options = {}) {
9916
+ try {
9917
+ await this.inputsApi.unregisterInput({ compositionId, inputId, unregisterInput: options });
9918
+ } catch (error) {
9919
+ throw await mapException(error, "input");
9920
+ }
9921
+ }
9922
+ /**
9923
+ * Register an output, the destination the composed result is sent to, carrying the scene to render.
9924
+ */
9925
+ async registerOutput(compositionId, outputId, output) {
9926
+ try {
9927
+ await this.outputsApi.registerOutput({ compositionId, outputId, registerOutput: output });
9928
+ } catch (error) {
9929
+ throw await mapException(error, "composition");
9930
+ }
9931
+ }
9932
+ /**
9933
+ * Register an output rendering a template bundle, as built by `@fishjam-cloud/composition-cli`.
9934
+ * The bundle is either a `Blob` or a path to read it from; never pass a path taken from
9935
+ * untrusted input, since its contents are uploaded.
9936
+ */
9937
+ async registerTemplateOutput(compositionId, outputId, config, template) {
9938
+ try {
9939
+ await this.outputsApi.registerTemplateOutput({
9940
+ compositionId,
9941
+ outputId,
9942
+ config,
9943
+ template: await toBlob(template)
9944
+ });
9945
+ } catch (error) {
9946
+ throw await mapException(error, "composition");
9947
+ }
9948
+ }
9949
+ /**
9950
+ * Register an output sending the composed result to a WHIP endpoint.
9951
+ */
9952
+ async registerWhipOutput(compositionId, outputId, options) {
9953
+ await this.registerOutput(compositionId, outputId, { ...options, type: "whip_client" });
9954
+ }
9955
+ /**
9956
+ * Register an output sending the composed result to an RTMP endpoint.
9957
+ */
9958
+ async registerRtmpOutput(compositionId, outputId, options) {
9959
+ await this.registerOutput(compositionId, outputId, { ...options, type: "rtmp_client" });
9960
+ }
9961
+ /**
9962
+ * Unregister an output. It stops producing audio and video.
9963
+ */
9964
+ async unregisterOutput(compositionId, outputId, options = {}) {
9965
+ try {
9966
+ await this.outputsApi.unregisterOutput({ compositionId, outputId, unregisterOutput: options });
9967
+ } catch (error) {
9968
+ throw await mapException(error, "output");
9969
+ }
9970
+ }
9971
+ /**
9972
+ * Replace the scene an output renders.
9973
+ */
9974
+ async updateOutput(compositionId, outputId, update) {
9975
+ try {
9976
+ await this.outputsApi.updateOutput({ compositionId, outputId, updateOutputRequest: update });
9977
+ } catch (error) {
9978
+ throw await mapException(error, "composition");
9979
+ }
9980
+ }
9981
+ /**
9982
+ * Ask an output to emit a keyframe, so a viewer joining mid-stream renders a full picture sooner.
9983
+ */
9984
+ async requestKeyframe(compositionId, outputId) {
9985
+ try {
9986
+ await this.outputsApi.requestKeyframe({ compositionId, outputId });
9987
+ } catch (error) {
9988
+ throw await mapException(error, "composition");
9989
+ }
9990
+ }
9991
+ /**
9992
+ * Register an image that scenes can reference by its renderer ID.
9993
+ */
9994
+ async registerImage(compositionId, imageId, image) {
9995
+ try {
9996
+ await this.renderersApi.registerImage({ compositionId, imageId, imageSpec: image });
9997
+ } catch (error) {
9998
+ throw await mapException(error, "composition");
9999
+ }
10000
+ }
10001
+ /**
10002
+ * Register a font that scenes can render text with. The font is either a `Blob` or a path
10003
+ * to read it from; never pass a path taken from untrusted input, since its contents are uploaded.
10004
+ */
10005
+ async registerFont(compositionId, font) {
10006
+ try {
10007
+ await this.renderersApi.registerFont({ compositionId, font: await toBlob(font) });
10008
+ } catch (error) {
10009
+ throw await mapException(error, "composition");
10010
+ }
10011
+ }
10012
+ /**
10013
+ * Unregister a previously registered image.
10014
+ */
10015
+ async unregisterImage(compositionId, imageId, options = {}) {
10016
+ try {
10017
+ await this.renderersApi.unregisterImage({ compositionId, imageId, unregisterRenderer: options });
10018
+ } catch (error) {
10019
+ throw await mapException(error, "renderer");
10020
+ }
10021
+ }
10022
+ /**
10023
+ * Deliver an event to the templates rendered by the composition's outputs.
10024
+ */
10025
+ async sendEvent(compositionId, event) {
10026
+ try {
10027
+ await this.eventsApi.sendCompositionEvent({ compositionId, sendCompositionEventRequest: event });
10028
+ } catch (error) {
10029
+ throw await mapException(error, "composition");
10030
+ }
10031
+ }
6956
10032
  };
6957
10033
  export {
10034
+ AudioFormat,
10035
+ AudioSampleRate,
6958
10036
  BadRequestException,
10037
+ CompositionClient,
10038
+ CompositionNotFoundException,
6959
10039
  FishjamAgent,
6960
10040
  FishjamBaseException,
6961
10041
  FishjamClient,
6962
10042
  FishjamNotFoundException,
6963
10043
  FishjamWSNotifier,
6964
10044
  ForbiddenException,
10045
+ InputNotFoundException,
6965
10046
  InvalidFishjamCredentialsException,
6966
10047
  MissingFishjamIdException,
10048
+ OutputNotFoundException,
6967
10049
  PeerNotFoundException,
6968
10050
  PeerStatus,
6969
10051
  QuotaExceededException,
10052
+ RecordingNotFoundException,
10053
+ RendererNotFoundException,
6970
10054
  RoomNotFoundException,
6971
10055
  RoomType,
6972
10056
  ServerMessage,
6973
10057
  ServiceUnavailableException,
10058
+ StaleSdkException,
10059
+ SubscribeMode,
6974
10060
  UnauthorizedException,
6975
10061
  UnknownException,
6976
10062
  VideoCodec,