lexmount 0.5.5 → 0.5.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 +73 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -244,6 +244,10 @@ function asRecord(value) {
|
|
|
244
244
|
function getString(value) {
|
|
245
245
|
return typeof value === "string" ? value : void 0;
|
|
246
246
|
}
|
|
247
|
+
function withRequestedRegion(client, payload) {
|
|
248
|
+
const regionId = client.selectedRegion ?? client.region;
|
|
249
|
+
return regionId ? { ...payload, region_id: regionId } : payload;
|
|
250
|
+
}
|
|
247
251
|
function getNumber(value) {
|
|
248
252
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
249
253
|
}
|
|
@@ -496,6 +500,9 @@ var SessionsResource = class {
|
|
|
496
500
|
project_id: options.projectId ?? this.client.projectId,
|
|
497
501
|
browser_mode: options.browserMode ?? "normal"
|
|
498
502
|
};
|
|
503
|
+
if (options.customImageId) {
|
|
504
|
+
payload.custom_image_id = options.customImageId;
|
|
505
|
+
}
|
|
499
506
|
if (options.context) {
|
|
500
507
|
const contextPayload = {
|
|
501
508
|
id: options.context.id,
|
|
@@ -518,10 +525,10 @@ var SessionsResource = class {
|
|
|
518
525
|
payload.weak_lock = true;
|
|
519
526
|
}
|
|
520
527
|
if (options.asyncCreate !== false) {
|
|
521
|
-
return this.createAsync(payload, options);
|
|
528
|
+
return this.createAsync(withRequestedRegion(this.client, payload), options);
|
|
522
529
|
}
|
|
523
530
|
const url = `${this.client.baseUrl}/instance`;
|
|
524
|
-
const response = await this.client._post(url, payload);
|
|
531
|
+
const response = await this.client._post(url, withRequestedRegion(this.client, payload));
|
|
525
532
|
if (response.status >= 400) {
|
|
526
533
|
this.handleCreateError(response);
|
|
527
534
|
}
|
|
@@ -543,6 +550,7 @@ var SessionsResource = class {
|
|
|
543
550
|
status: createdSession?.status ?? "active",
|
|
544
551
|
apiKey: this.client.apiKey,
|
|
545
552
|
projectId,
|
|
553
|
+
regionId: createdSession?.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
|
|
546
554
|
browserType: createdSession?.browserType ?? (options.browserMode ?? "normal"),
|
|
547
555
|
createdAt: createdSession?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
548
556
|
inspectUrl: createdSession?.inspectUrl ?? `${this.client.baseUrl}/inspect?session_id=${sessionId}`,
|
|
@@ -578,6 +586,7 @@ var SessionsResource = class {
|
|
|
578
586
|
status: "active",
|
|
579
587
|
apiKey: this.client.apiKey,
|
|
580
588
|
projectId,
|
|
589
|
+
regionId: info.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
|
|
581
590
|
browserType: info.browserType || (options.browserMode ?? "normal"),
|
|
582
591
|
createdAt: info.createdAt,
|
|
583
592
|
inspectUrl: info.inspectUrl,
|
|
@@ -612,11 +621,11 @@ var SessionsResource = class {
|
|
|
612
621
|
* intentionally uses POST even though the operation is read-only.
|
|
613
622
|
*/
|
|
614
623
|
async get(sessionId, projectId) {
|
|
615
|
-
const response = await this.client._post(`${this.client.baseUrl}/instance/session`, {
|
|
624
|
+
const response = await this.client._post(`${this.client.baseUrl}/instance/session`, withRequestedRegion(this.client, {
|
|
616
625
|
api_key: this.client.apiKey,
|
|
617
626
|
project_id: projectId ?? this.client.projectId,
|
|
618
627
|
session_id: sessionId
|
|
619
|
-
});
|
|
628
|
+
}));
|
|
620
629
|
if (response.status >= 400) {
|
|
621
630
|
this.handleGetError(response, sessionId);
|
|
622
631
|
}
|
|
@@ -634,7 +643,7 @@ var SessionsResource = class {
|
|
|
634
643
|
if (options.status) {
|
|
635
644
|
payload.status = options.status;
|
|
636
645
|
}
|
|
637
|
-
const response = await this.client._post(url, payload);
|
|
646
|
+
const response = await this.client._post(url, withRequestedRegion(this.client, payload));
|
|
638
647
|
if (response.status >= 400) {
|
|
639
648
|
this.handleListError(response);
|
|
640
649
|
}
|
|
@@ -660,11 +669,11 @@ var SessionsResource = class {
|
|
|
660
669
|
*/
|
|
661
670
|
async delete(options) {
|
|
662
671
|
const url = `${this.client.baseUrl}/instance`;
|
|
663
|
-
const payload = {
|
|
672
|
+
const payload = withRequestedRegion(this.client, {
|
|
664
673
|
api_key: this.client.apiKey,
|
|
665
674
|
project_id: options.projectId ?? this.client.projectId,
|
|
666
675
|
session_id: options.sessionId
|
|
667
|
-
};
|
|
676
|
+
});
|
|
668
677
|
const response = await this.client._delete(url, payload);
|
|
669
678
|
if (response.status >= 400) {
|
|
670
679
|
this.handleDeleteError(response, options.sessionId);
|
|
@@ -1659,7 +1668,7 @@ var Lexmount = class {
|
|
|
1659
1668
|
};
|
|
1660
1669
|
|
|
1661
1670
|
// src/index.ts
|
|
1662
|
-
var VERSION = "0.5.
|
|
1671
|
+
var VERSION = "0.5.7";
|
|
1663
1672
|
export {
|
|
1664
1673
|
APIError,
|
|
1665
1674
|
AuthenticationError,
|