@stinkycomputing/sesame-api-client 1.4.1-beta.5 → 1.4.1-beta.7

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/README.md CHANGED
@@ -48,6 +48,8 @@ import { sesame } from '@stinkycomputing/sesame-api-client';
48
48
  | `sesame.v1.commands` | Command list items |
49
49
  | `sesame.v1.rpc` | RPC message envelope (Request/Response/Event) |
50
50
 
51
+ For the complete type reference with every enum value, message field, and property name, see **[Protocol Reference](docs/protocol-reference.md)**.
52
+
51
53
  ## Wire Protocol
52
54
 
53
55
  Every websocket message is framed as:
@@ -8574,7 +8574,7 @@ var sesame = $root.sesame = (() => {
8574
8574
  RecorderClip.prototype.endTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8575
8575
  RecorderClip.prototype.lockedStartUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8576
8576
  RecorderClip.prototype.lockedEndUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8577
- RecorderClip.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8577
+ RecorderClip.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
8578
8578
  RecorderClip.create = function create(properties) {
8579
8579
  return new RecorderClip(properties);
8580
8580
  };
@@ -8621,11 +8621,11 @@ var sesame = $root.sesame = (() => {
8621
8621
  /* id 8, wireType 0 =*/
8622
8622
  64
8623
8623
  ).int64(message.lockedEndUs);
8624
- if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
8624
+ if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
8625
8625
  writer.uint32(
8626
8626
  /* id 9, wireType 0 =*/
8627
8627
  72
8628
- ).int64(message.userTimeMs);
8628
+ ).int64(message.userTimeUs);
8629
8629
  return writer;
8630
8630
  };
8631
8631
  RecorderClip.encodeDelimited = function encodeDelimited(message, writer) {
@@ -8673,7 +8673,7 @@ var sesame = $root.sesame = (() => {
8673
8673
  break;
8674
8674
  }
8675
8675
  case 9: {
8676
- message.userTimeMs = reader.int64();
8676
+ message.userTimeUs = reader.int64();
8677
8677
  break;
8678
8678
  }
8679
8679
  default:
@@ -8723,9 +8723,9 @@ var sesame = $root.sesame = (() => {
8723
8723
  if (!$util.isInteger(message.lockedEndUs) && !(message.lockedEndUs && $util.isInteger(message.lockedEndUs.low) && $util.isInteger(message.lockedEndUs.high)))
8724
8724
  return "lockedEndUs: integer|Long expected";
8725
8725
  }
8726
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
8727
- if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
8728
- return "userTimeMs: integer|Long expected";
8726
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
8727
+ if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
8728
+ return "userTimeUs: integer|Long expected";
8729
8729
  }
8730
8730
  return null;
8731
8731
  };
@@ -8797,15 +8797,15 @@ var sesame = $root.sesame = (() => {
8797
8797
  else if (typeof object.lockedEndUs === "object")
8798
8798
  message.lockedEndUs = new $util.LongBits(object.lockedEndUs.low >>> 0, object.lockedEndUs.high >>> 0).toNumber();
8799
8799
  }
8800
- if (object.userTimeMs != null) {
8800
+ if (object.userTimeUs != null) {
8801
8801
  if ($util.Long)
8802
- (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
8803
- else if (typeof object.userTimeMs === "string")
8804
- message.userTimeMs = parseInt(object.userTimeMs, 10);
8805
- else if (typeof object.userTimeMs === "number")
8806
- message.userTimeMs = object.userTimeMs;
8807
- else if (typeof object.userTimeMs === "object")
8808
- message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
8802
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
8803
+ else if (typeof object.userTimeUs === "string")
8804
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
8805
+ else if (typeof object.userTimeUs === "number")
8806
+ message.userTimeUs = object.userTimeUs;
8807
+ else if (typeof object.userTimeUs === "object")
8808
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
8809
8809
  }
8810
8810
  return message;
8811
8811
  };
@@ -8848,9 +8848,9 @@ var sesame = $root.sesame = (() => {
8848
8848
  object.lockedEndUs = options.longs === String ? "0" : 0;
8849
8849
  if ($util.Long) {
8850
8850
  let long = new $util.Long(0, 0, false);
8851
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8851
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
8852
8852
  } else
8853
- object.userTimeMs = options.longs === String ? "0" : 0;
8853
+ object.userTimeUs = options.longs === String ? "0" : 0;
8854
8854
  }
8855
8855
  if (message.id != null && message.hasOwnProperty("id"))
8856
8856
  if (typeof message.id === "number")
@@ -8886,11 +8886,11 @@ var sesame = $root.sesame = (() => {
8886
8886
  object.lockedEndUs = options.longs === String ? String(message.lockedEndUs) : message.lockedEndUs;
8887
8887
  else
8888
8888
  object.lockedEndUs = options.longs === String ? $util.Long.prototype.toString.call(message.lockedEndUs) : options.longs === Number ? new $util.LongBits(message.lockedEndUs.low >>> 0, message.lockedEndUs.high >>> 0).toNumber() : message.lockedEndUs;
8889
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
8890
- if (typeof message.userTimeMs === "number")
8891
- object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
8889
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
8890
+ if (typeof message.userTimeUs === "number")
8891
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
8892
8892
  else
8893
- object.userTimeMs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeMs) : options.longs === Number ? new $util.LongBits(message.userTimeMs.low >>> 0, message.userTimeMs.high >>> 0).toNumber() : message.userTimeMs;
8893
+ object.userTimeUs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeUs) : options.longs === Number ? new $util.LongBits(message.userTimeUs.low >>> 0, message.userTimeUs.high >>> 0).toNumber() : message.userTimeUs;
8894
8894
  return object;
8895
8895
  };
8896
8896
  RecorderClip.prototype.toJSON = function toJSON() {
@@ -13703,7 +13703,7 @@ var sesame = $root.sesame = (() => {
13703
13703
  TransportEvent.prototype.durationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13704
13704
  TransportEvent.prototype.positionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13705
13705
  TransportEvent.prototype.materialPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13706
- TransportEvent.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13706
+ TransportEvent.prototype.userTimeUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13707
13707
  TransportEvent.prototype.speed = 0;
13708
13708
  TransportEvent.prototype.userPlaylistId = "";
13709
13709
  TransportEvent.prototype.playlistIndex = 0;
@@ -13755,11 +13755,11 @@ var sesame = $root.sesame = (() => {
13755
13755
  /* id 7, wireType 0 =*/
13756
13756
  56
13757
13757
  ).int64(message.materialPositionUs);
13758
- if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
13758
+ if (message.userTimeUs != null && Object.hasOwnProperty.call(message, "userTimeUs"))
13759
13759
  writer.uint32(
13760
13760
  /* id 8, wireType 0 =*/
13761
13761
  64
13762
- ).int64(message.userTimeMs);
13762
+ ).int64(message.userTimeUs);
13763
13763
  if (message.speed != null && Object.hasOwnProperty.call(message, "speed"))
13764
13764
  writer.uint32(
13765
13765
  /* id 9, wireType 5 =*/
@@ -13853,7 +13853,7 @@ var sesame = $root.sesame = (() => {
13853
13853
  break;
13854
13854
  }
13855
13855
  case 8: {
13856
- message.userTimeMs = reader.int64();
13856
+ message.userTimeUs = reader.int64();
13857
13857
  break;
13858
13858
  }
13859
13859
  case 9: {
@@ -13946,9 +13946,9 @@ var sesame = $root.sesame = (() => {
13946
13946
  if (!$util.isInteger(message.materialPositionUs) && !(message.materialPositionUs && $util.isInteger(message.materialPositionUs.low) && $util.isInteger(message.materialPositionUs.high)))
13947
13947
  return "materialPositionUs: integer|Long expected";
13948
13948
  }
13949
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
13950
- if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
13951
- return "userTimeMs: integer|Long expected";
13949
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs")) {
13950
+ if (!$util.isInteger(message.userTimeUs) && !(message.userTimeUs && $util.isInteger(message.userTimeUs.low) && $util.isInteger(message.userTimeUs.high)))
13951
+ return "userTimeUs: integer|Long expected";
13952
13952
  }
13953
13953
  if (message.speed != null && message.hasOwnProperty("speed")) {
13954
13954
  if (typeof message.speed !== "number")
@@ -14060,15 +14060,15 @@ var sesame = $root.sesame = (() => {
14060
14060
  else if (typeof object.materialPositionUs === "object")
14061
14061
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
14062
14062
  }
14063
- if (object.userTimeMs != null) {
14063
+ if (object.userTimeUs != null) {
14064
14064
  if ($util.Long)
14065
- (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
14066
- else if (typeof object.userTimeMs === "string")
14067
- message.userTimeMs = parseInt(object.userTimeMs, 10);
14068
- else if (typeof object.userTimeMs === "number")
14069
- message.userTimeMs = object.userTimeMs;
14070
- else if (typeof object.userTimeMs === "object")
14071
- message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
14065
+ (message.userTimeUs = $util.Long.fromValue(object.userTimeUs)).unsigned = false;
14066
+ else if (typeof object.userTimeUs === "string")
14067
+ message.userTimeUs = parseInt(object.userTimeUs, 10);
14068
+ else if (typeof object.userTimeUs === "number")
14069
+ message.userTimeUs = object.userTimeUs;
14070
+ else if (typeof object.userTimeUs === "object")
14071
+ message.userTimeUs = new $util.LongBits(object.userTimeUs.low >>> 0, object.userTimeUs.high >>> 0).toNumber();
14072
14072
  }
14073
14073
  if (object.speed != null)
14074
14074
  message.speed = Number(object.speed);
@@ -14142,9 +14142,9 @@ var sesame = $root.sesame = (() => {
14142
14142
  object.materialPositionUs = options.longs === String ? "0" : 0;
14143
14143
  if ($util.Long) {
14144
14144
  let long = new $util.Long(0, 0, false);
14145
- object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
14145
+ object.userTimeUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
14146
14146
  } else
14147
- object.userTimeMs = options.longs === String ? "0" : 0;
14147
+ object.userTimeUs = options.longs === String ? "0" : 0;
14148
14148
  object.speed = 0;
14149
14149
  object.userPlaylistId = "";
14150
14150
  object.playlistIndex = 0;
@@ -14191,11 +14191,11 @@ var sesame = $root.sesame = (() => {
14191
14191
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
14192
14192
  else
14193
14193
  object.materialPositionUs = options.longs === String ? $util.Long.prototype.toString.call(message.materialPositionUs) : options.longs === Number ? new $util.LongBits(message.materialPositionUs.low >>> 0, message.materialPositionUs.high >>> 0).toNumber() : message.materialPositionUs;
14194
- if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
14195
- if (typeof message.userTimeMs === "number")
14196
- object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
14194
+ if (message.userTimeUs != null && message.hasOwnProperty("userTimeUs"))
14195
+ if (typeof message.userTimeUs === "number")
14196
+ object.userTimeUs = options.longs === String ? String(message.userTimeUs) : message.userTimeUs;
14197
14197
  else
14198
- object.userTimeMs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeMs) : options.longs === Number ? new $util.LongBits(message.userTimeMs.low >>> 0, message.userTimeMs.high >>> 0).toNumber() : message.userTimeMs;
14198
+ object.userTimeUs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeUs) : options.longs === Number ? new $util.LongBits(message.userTimeUs.low >>> 0, message.userTimeUs.high >>> 0).toNumber() : message.userTimeUs;
14199
14199
  if (message.speed != null && message.hasOwnProperty("speed"))
14200
14200
  object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
14201
14201
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
@@ -22317,8 +22317,8 @@ var RPCClient = class extends import_events.EventEmitter {
22317
22317
  } else {
22318
22318
  throw new Error("Unsupported RPC message payload");
22319
22319
  }
22320
- } catch (cause) {
22321
- const error = new Error("got invalid message");
22320
+ } catch (err) {
22321
+ const error = new Error(`Got invalid message: ${err instanceof Error ? err.message : String(err)}`);
22322
22322
  this.errorHandler(error);
22323
22323
  }
22324
22324
  };
@@ -22393,8 +22393,8 @@ var RPCClient = class extends import_events.EventEmitter {
22393
22393
  try {
22394
22394
  payload = type.decode(event.payload);
22395
22395
  object = type.toObject(payload, { longs: Number });
22396
- } catch (cause) {
22397
- const error = new Error("could not decode event payload");
22396
+ } catch (err) {
22397
+ const error = new Error(`Could not decode event payload: ${err instanceof Error ? err.message : String(err)}`);
22398
22398
  this.errorHandler(error);
22399
22399
  return;
22400
22400
  }
@@ -22549,14 +22549,29 @@ var SesameConnection = class extends import_events2.EventEmitter {
22549
22549
  this.socket.addEventListener("close", this.boundCloseHandler);
22550
22550
  this.socket.addEventListener("error", this.boundErrorHandler);
22551
22551
  this.socket.binaryType = "arraybuffer";
22552
- await new Promise((resolve) => {
22553
- const done = () => {
22554
- this.removeListener("open", done);
22555
- this.removeListener("close", done);
22556
- resolve(null);
22552
+ await new Promise((resolve, reject) => {
22553
+ const cleanup = () => {
22554
+ this.removeListener("open", onOpen);
22555
+ this.removeListener("close", onClose);
22556
+ this.removeListener("error", onError);
22557
22557
  };
22558
- this.on("open", done);
22559
- this.on("close", done);
22558
+ const onOpen = () => {
22559
+ cleanup();
22560
+ resolve();
22561
+ };
22562
+ const onError = (err) => {
22563
+ cleanup();
22564
+ reject(err instanceof Error ? err : new Error("WebSocket connection error"));
22565
+ };
22566
+ const onClose = () => {
22567
+ if (!this.isConnected()) {
22568
+ cleanup();
22569
+ reject(new Error("WebSocket connection closed before opening"));
22570
+ }
22571
+ };
22572
+ this.on("open", onOpen);
22573
+ this.on("close", onClose);
22574
+ this.on("error", onError);
22560
22575
  });
22561
22576
  }
22562
22577
  /**
@@ -22700,7 +22715,6 @@ var JobsApi = class {
22700
22715
  if (!config.filename) throw new Error("Filename is required");
22701
22716
  exportReq.config = {
22702
22717
  ...config,
22703
- filename: config.filename,
22704
22718
  videoCodec: config.videoCodec ?? sesame.v1.common.CodecId.CODEC_ID_H264,
22705
22719
  videoBitrateKbps: config.videoBitrateKbps ?? 1024,
22706
22720
  audioCodec: config.audioCodec ?? sesame.v1.jobs.AudioCodecId.AUDIO_CODEC_ID_AAC,
@@ -22709,18 +22723,18 @@ var JobsApi = class {
22709
22723
  audioRouting: config.audioRouting ?? [0, 1, 2, 3]
22710
22724
  };
22711
22725
  exportReq.items = playlist.clips.map((clip) => ({
22712
- id: clip.id,
22713
- recorderId: clip.recorderId,
22726
+ ...clip,
22714
22727
  transitionTimeUs: clip.transitionTimeUs ?? 0,
22715
22728
  transitionType: clip.transitionType ?? sesame.v1.recorder.TransitionType.TRANSITION_TYPE_MIX,
22716
22729
  transitionFadeColor: clip.transitionFadeColor ?? { x: 0, y: 0, z: 0, w: 0 },
22717
- speed: clip.speed ?? 1,
22718
- audioRouting: clip.audioRouting,
22719
- startTimeUs: clip.startTimeUs,
22720
- endTimeUs: clip.endTimeUs
22730
+ speed: clip.speed ?? 1
22721
22731
  }));
22722
22732
  const msg = sesame.v1.jobs.JobStartRequest.create({ exportRequest: exportReq });
22723
- await this.rpc.service.startJob(msg);
22733
+ const job = await this.rpc.service.startJob(msg);
22734
+ if (job.error) {
22735
+ throw new Error(job.error);
22736
+ }
22737
+ return job;
22724
22738
  }
22725
22739
  async abortJob(jobId) {
22726
22740
  const msg = { jobId };