@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.d.cts CHANGED
@@ -6,7 +6,7 @@ interface ConnectOptions {
6
6
  reconnect?: boolean;
7
7
  }
8
8
  interface BrowserOption {
9
- browser_id: number;
9
+ schedule_id: number;
10
10
  user_id?: number | null;
11
11
  geo?: string | null;
12
12
  language?: string | null;
@@ -23,7 +23,7 @@ interface BrowserOption {
23
23
  }
24
24
  interface Match {
25
25
  session_id: string;
26
- browser_id: number;
26
+ schedule_id: number;
27
27
  event_id?: string | null;
28
28
  chat_topic_id?: string | null;
29
29
  provider_user_id?: number | null;
@@ -91,7 +91,7 @@ interface ChatHistoryOptions {
91
91
  }
92
92
  interface SessionInfo {
93
93
  id: number;
94
- browser_id: number;
94
+ schedule_id: number;
95
95
  started_at: string | null;
96
96
  ended_at: string | null;
97
97
  status: string;
@@ -208,6 +208,7 @@ type UserEventHandler = (events: Record<string, unknown>[]) => void;
208
208
  declare class Browser {
209
209
  readonly sessionId: string;
210
210
  readonly browserId: number;
211
+ readonly scheduleId: number;
211
212
  readonly chatTopicId: string | null;
212
213
  readonly browserInfo: Record<string, unknown>;
213
214
  readonly providerUserId: number | null;
@@ -334,7 +335,7 @@ declare class Client {
334
335
  limit?: number;
335
336
  }): Promise<SessionInfo[]>;
336
337
  myBrowsers(): Promise<BrowserOption[]>;
337
- rent(browserId: number, opts?: RentOptions): Promise<Browser>;
338
+ rent(scheduleId: number, opts?: RentOptions): Promise<Browser>;
338
339
  resume(sessionId: string, opts?: RentOptions): Promise<Browser>;
339
340
  close(): Promise<void>;
340
341
  disconnect(): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ interface ConnectOptions {
6
6
  reconnect?: boolean;
7
7
  }
8
8
  interface BrowserOption {
9
- browser_id: number;
9
+ schedule_id: number;
10
10
  user_id?: number | null;
11
11
  geo?: string | null;
12
12
  language?: string | null;
@@ -23,7 +23,7 @@ interface BrowserOption {
23
23
  }
24
24
  interface Match {
25
25
  session_id: string;
26
- browser_id: number;
26
+ schedule_id: number;
27
27
  event_id?: string | null;
28
28
  chat_topic_id?: string | null;
29
29
  provider_user_id?: number | null;
@@ -91,7 +91,7 @@ interface ChatHistoryOptions {
91
91
  }
92
92
  interface SessionInfo {
93
93
  id: number;
94
- browser_id: number;
94
+ schedule_id: number;
95
95
  started_at: string | null;
96
96
  ended_at: string | null;
97
97
  status: string;
@@ -208,6 +208,7 @@ type UserEventHandler = (events: Record<string, unknown>[]) => void;
208
208
  declare class Browser {
209
209
  readonly sessionId: string;
210
210
  readonly browserId: number;
211
+ readonly scheduleId: number;
211
212
  readonly chatTopicId: string | null;
212
213
  readonly browserInfo: Record<string, unknown>;
213
214
  readonly providerUserId: number | null;
@@ -334,7 +335,7 @@ declare class Client {
334
335
  limit?: number;
335
336
  }): Promise<SessionInfo[]>;
336
337
  myBrowsers(): Promise<BrowserOption[]>;
337
- rent(browserId: number, opts?: RentOptions): Promise<Browser>;
338
+ rent(scheduleId: number, opts?: RentOptions): Promise<Browser>;
338
339
  resume(sessionId: string, opts?: RentOptions): Promise<Browser>;
339
340
  close(): Promise<void>;
340
341
  disconnect(): Promise<void>;
package/dist/index.js CHANGED
@@ -564,6 +564,7 @@ function keymapForChar(char) {
564
564
  var Browser = class _Browser {
565
565
  sessionId;
566
566
  browserId;
567
+ scheduleId;
567
568
  chatTopicId;
568
569
  browserInfo;
569
570
  providerUserId;
@@ -609,7 +610,8 @@ var Browser = class _Browser {
609
610
  constructor(client, match, humanizer) {
610
611
  this._client = client;
611
612
  this.sessionId = match.session_id;
612
- this.browserId = match.browser_id;
613
+ this.browserId = match.schedule_id;
614
+ this.scheduleId = match.schedule_id;
613
615
  this.chatTopicId = match.chat_topic_id ?? null;
614
616
  this.browserInfo = match.browser_info ?? {};
615
617
  this.providerUserId = match.provider_user_id ?? null;
@@ -624,7 +626,7 @@ var Browser = class _Browser {
624
626
  saveSession(this.sessionId, {
625
627
  session_id: this.sessionId,
626
628
  chat_topic_id: this.chatTopicId,
627
- browser_id: this.browserId,
629
+ schedule_id: this.scheduleId,
628
630
  last_seen_ts: this._lastSeenTs
629
631
  });
630
632
  }
@@ -1393,7 +1395,7 @@ var Client = class _Client {
1393
1395
  _pongTimer = null;
1394
1396
  _lastPongAt = 0;
1395
1397
  _pendingRents = /* @__PURE__ */ new Map();
1396
- // keyed by `rent:<browserId>` or eventId
1398
+ // keyed by `rent:<scheduleId>` or eventId
1397
1399
  _pendingResumes = /* @__PURE__ */ new Map();
1398
1400
  // keyed by sessionId
1399
1401
  _connectResolve = null;
@@ -1484,18 +1486,18 @@ var Client = class _Client {
1484
1486
  const items = body.browsers ?? body.data ?? body;
1485
1487
  return Array.isArray(items) ? items : [];
1486
1488
  }
1487
- async rent(browserId, opts) {
1488
- const rentMsg = { type: "rent", browser_id: browserId };
1489
+ async rent(scheduleId, opts) {
1490
+ const rentMsg = { type: "rent", browser_id: scheduleId };
1489
1491
  if (opts?.mode) rentMsg.mode = opts.mode;
1490
1492
  this._wsSend(rentMsg);
1491
- const key = `rent:${browserId}`;
1493
+ const key = `rent:${scheduleId}`;
1492
1494
  return new Promise((resolve, reject) => {
1493
1495
  const timer = setTimeout(() => {
1494
1496
  this._pendingRents.delete(key);
1495
1497
  reject(new TimeoutError("Rent timed out after 90s"));
1496
1498
  }, 9e4);
1497
1499
  this._pendingRents.set(key, {
1498
- browserId,
1500
+ scheduleId,
1499
1501
  eventId: null,
1500
1502
  opts,
1501
1503
  resolve: (match) => {
@@ -1800,7 +1802,7 @@ var Client = class _Client {
1800
1802
  }
1801
1803
  _onMatch(msg) {
1802
1804
  const eventId = String(msg.event_id ?? "");
1803
- const browserId = Number(msg.browser_id ?? 0);
1805
+ const scheduleId = Number(msg.schedule_id ?? 0);
1804
1806
  const sessionId = String(msg.session_id ?? "");
1805
1807
  if (msg.requires_ack) {
1806
1808
  try {
@@ -1810,15 +1812,15 @@ var Client = class _Client {
1810
1812
  }
1811
1813
  let pending = this._pendingRents.get(`event:${eventId}`);
1812
1814
  if (!pending) {
1813
- pending = this._pendingRents.get(`rent:${browserId}`);
1815
+ pending = this._pendingRents.get(`rent:${scheduleId}`);
1814
1816
  }
1815
1817
  if (pending) {
1816
1818
  clearTimeout(pending.timer);
1817
- const key = pending.eventId ? `event:${pending.eventId}` : `rent:${pending.browserId}`;
1819
+ const key = pending.eventId ? `event:${pending.eventId}` : `rent:${pending.scheduleId}`;
1818
1820
  this._pendingRents.delete(key);
1819
1821
  const match = {
1820
1822
  session_id: sessionId,
1821
- browser_id: browserId,
1823
+ schedule_id: scheduleId,
1822
1824
  event_id: eventId || null,
1823
1825
  chat_topic_id: msg.chat_topic_id ? String(msg.chat_topic_id) : null,
1824
1826
  provider_user_id: msg.provider_user_id != null ? Number(msg.provider_user_id) : null,
@@ -1860,7 +1862,7 @@ var Client = class _Client {
1860
1862
  const match = {
1861
1863
  session_id: sessionId,
1862
1864
  event_id: msg.event_id != null ? String(msg.event_id) : null,
1863
- browser_id: Number(msg.browser_id ?? 0),
1865
+ schedule_id: Number(msg.schedule_id ?? 0),
1864
1866
  chat_topic_id: msg.chat_topic_id ? String(msg.chat_topic_id) : null,
1865
1867
  provider_user_id: msg.provider_user_id != null ? Number(msg.provider_user_id) : null,
1866
1868
  started_at: Date.now(),