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