@ceki/sdk 1.11.0 → 1.11.2

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.cjs CHANGED
@@ -623,6 +623,7 @@ function keymapForChar(char) {
623
623
  var Browser = class _Browser {
624
624
  sessionId;
625
625
  browserId;
626
+ scheduleId;
626
627
  chatTopicId;
627
628
  browserInfo;
628
629
  providerUserId;
@@ -668,7 +669,8 @@ var Browser = class _Browser {
668
669
  constructor(client, match, humanizer) {
669
670
  this._client = client;
670
671
  this.sessionId = match.session_id;
671
- this.browserId = match.browser_id;
672
+ this.browserId = match.schedule_id;
673
+ this.scheduleId = match.schedule_id;
672
674
  this.chatTopicId = match.chat_topic_id ?? null;
673
675
  this.browserInfo = match.browser_info ?? {};
674
676
  this.providerUserId = match.provider_user_id ?? null;
@@ -683,7 +685,7 @@ var Browser = class _Browser {
683
685
  saveSession(this.sessionId, {
684
686
  session_id: this.sessionId,
685
687
  chat_topic_id: this.chatTopicId,
686
- browser_id: this.browserId,
688
+ schedule_id: this.scheduleId,
687
689
  last_seen_ts: this._lastSeenTs
688
690
  });
689
691
  }
@@ -1452,7 +1454,7 @@ var Client = class _Client {
1452
1454
  _pongTimer = null;
1453
1455
  _lastPongAt = 0;
1454
1456
  _pendingRents = /* @__PURE__ */ new Map();
1455
- // keyed by `rent:<browserId>` or eventId
1457
+ // keyed by `rent:<scheduleId>` or eventId
1456
1458
  _pendingResumes = /* @__PURE__ */ new Map();
1457
1459
  // keyed by sessionId
1458
1460
  _connectResolve = null;
@@ -1543,18 +1545,18 @@ var Client = class _Client {
1543
1545
  const items = body.browsers ?? body.data ?? body;
1544
1546
  return Array.isArray(items) ? items : [];
1545
1547
  }
1546
- async rent(browserId, opts) {
1547
- const rentMsg = { type: "rent", browser_id: browserId };
1548
+ async rent(scheduleId, opts) {
1549
+ const rentMsg = { type: "rent", browser_id: scheduleId };
1548
1550
  if (opts?.mode) rentMsg.mode = opts.mode;
1549
1551
  this._wsSend(rentMsg);
1550
- const key = `rent:${browserId}`;
1552
+ const key = `rent:${scheduleId}`;
1551
1553
  return new Promise((resolve, reject) => {
1552
1554
  const timer = setTimeout(() => {
1553
1555
  this._pendingRents.delete(key);
1554
1556
  reject(new TimeoutError("Rent timed out after 90s"));
1555
1557
  }, 9e4);
1556
1558
  this._pendingRents.set(key, {
1557
- browserId,
1559
+ scheduleId,
1558
1560
  eventId: null,
1559
1561
  opts,
1560
1562
  resolve: (match) => {
@@ -1859,7 +1861,7 @@ var Client = class _Client {
1859
1861
  }
1860
1862
  _onMatch(msg) {
1861
1863
  const eventId = String(msg.event_id ?? "");
1862
- const browserId = Number(msg.browser_id ?? 0);
1864
+ const scheduleId = Number(msg.schedule_id ?? 0);
1863
1865
  const sessionId = String(msg.session_id ?? "");
1864
1866
  if (msg.requires_ack) {
1865
1867
  try {
@@ -1869,15 +1871,15 @@ var Client = class _Client {
1869
1871
  }
1870
1872
  let pending = this._pendingRents.get(`event:${eventId}`);
1871
1873
  if (!pending) {
1872
- pending = this._pendingRents.get(`rent:${browserId}`);
1874
+ pending = this._pendingRents.get(`rent:${scheduleId}`);
1873
1875
  }
1874
1876
  if (pending) {
1875
1877
  clearTimeout(pending.timer);
1876
- const key = pending.eventId ? `event:${pending.eventId}` : `rent:${pending.browserId}`;
1878
+ const key = pending.eventId ? `event:${pending.eventId}` : `rent:${pending.scheduleId}`;
1877
1879
  this._pendingRents.delete(key);
1878
1880
  const match = {
1879
1881
  session_id: sessionId,
1880
- browser_id: browserId,
1882
+ schedule_id: scheduleId,
1881
1883
  event_id: eventId || null,
1882
1884
  chat_topic_id: msg.chat_topic_id ? String(msg.chat_topic_id) : null,
1883
1885
  provider_user_id: msg.provider_user_id != null ? Number(msg.provider_user_id) : null,
@@ -1919,7 +1921,7 @@ var Client = class _Client {
1919
1921
  const match = {
1920
1922
  session_id: sessionId,
1921
1923
  event_id: msg.event_id != null ? String(msg.event_id) : null,
1922
- browser_id: Number(msg.browser_id ?? 0),
1924
+ schedule_id: Number(msg.schedule_id ?? 0),
1923
1925
  chat_topic_id: msg.chat_topic_id ? String(msg.chat_topic_id) : null,
1924
1926
  provider_user_id: msg.provider_user_id != null ? Number(msg.provider_user_id) : null,
1925
1927
  started_at: Date.now(),