lexmount 0.5.5 → 0.5.6

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.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
  }
@@ -518,10 +522,10 @@ var SessionsResource = class {
518
522
  payload.weak_lock = true;
519
523
  }
520
524
  if (options.asyncCreate !== false) {
521
- return this.createAsync(payload, options);
525
+ return this.createAsync(withRequestedRegion(this.client, payload), options);
522
526
  }
523
527
  const url = `${this.client.baseUrl}/instance`;
524
- const response = await this.client._post(url, payload);
528
+ const response = await this.client._post(url, withRequestedRegion(this.client, payload));
525
529
  if (response.status >= 400) {
526
530
  this.handleCreateError(response);
527
531
  }
@@ -543,6 +547,7 @@ var SessionsResource = class {
543
547
  status: createdSession?.status ?? "active",
544
548
  apiKey: this.client.apiKey,
545
549
  projectId,
550
+ regionId: createdSession?.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
546
551
  browserType: createdSession?.browserType ?? (options.browserMode ?? "normal"),
547
552
  createdAt: createdSession?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
548
553
  inspectUrl: createdSession?.inspectUrl ?? `${this.client.baseUrl}/inspect?session_id=${sessionId}`,
@@ -578,6 +583,7 @@ var SessionsResource = class {
578
583
  status: "active",
579
584
  apiKey: this.client.apiKey,
580
585
  projectId,
586
+ regionId: info.regionId ?? this.client.selectedRegion ?? this.client.region ?? null,
581
587
  browserType: info.browserType || (options.browserMode ?? "normal"),
582
588
  createdAt: info.createdAt,
583
589
  inspectUrl: info.inspectUrl,
@@ -612,11 +618,11 @@ var SessionsResource = class {
612
618
  * intentionally uses POST even though the operation is read-only.
613
619
  */
614
620
  async get(sessionId, projectId) {
615
- const response = await this.client._post(`${this.client.baseUrl}/instance/session`, {
621
+ const response = await this.client._post(`${this.client.baseUrl}/instance/session`, withRequestedRegion(this.client, {
616
622
  api_key: this.client.apiKey,
617
623
  project_id: projectId ?? this.client.projectId,
618
624
  session_id: sessionId
619
- });
625
+ }));
620
626
  if (response.status >= 400) {
621
627
  this.handleGetError(response, sessionId);
622
628
  }
@@ -634,7 +640,7 @@ var SessionsResource = class {
634
640
  if (options.status) {
635
641
  payload.status = options.status;
636
642
  }
637
- const response = await this.client._post(url, payload);
643
+ const response = await this.client._post(url, withRequestedRegion(this.client, payload));
638
644
  if (response.status >= 400) {
639
645
  this.handleListError(response);
640
646
  }
@@ -660,11 +666,11 @@ var SessionsResource = class {
660
666
  */
661
667
  async delete(options) {
662
668
  const url = `${this.client.baseUrl}/instance`;
663
- const payload = {
669
+ const payload = withRequestedRegion(this.client, {
664
670
  api_key: this.client.apiKey,
665
671
  project_id: options.projectId ?? this.client.projectId,
666
672
  session_id: options.sessionId
667
- };
673
+ });
668
674
  const response = await this.client._delete(url, payload);
669
675
  if (response.status >= 400) {
670
676
  this.handleDeleteError(response, options.sessionId);
@@ -1659,7 +1665,7 @@ var Lexmount = class {
1659
1665
  };
1660
1666
 
1661
1667
  // src/index.ts
1662
- var VERSION = "0.5.5";
1668
+ var VERSION = "0.5.6";
1663
1669
  export {
1664
1670
  APIError,
1665
1671
  AuthenticationError,