lexmount 0.5.9 → 0.5.11

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
@@ -248,6 +248,9 @@ function withRequestedRegion(client, payload) {
248
248
  const regionId = client.selectedRegion ?? client.region;
249
249
  return regionId ? { ...payload, region_id: regionId } : payload;
250
250
  }
251
+ function projectHeaders(projectId) {
252
+ return projectId ? { headers: { "x-project-id": projectId } } : void 0;
253
+ }
251
254
  function getNumber(value) {
252
255
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
253
256
  }
@@ -392,10 +395,8 @@ var SessionDownloadsResource = class {
392
395
  async list(sessionId, projectId) {
393
396
  const response = await this.client._post(
394
397
  `${this.client.baseUrl}/instance/v1/sessions/${sessionId}/downloads/list`,
395
- {
396
- api_key: this.client.apiKey,
397
- project_id: projectId ?? this.client.projectId
398
- }
398
+ {},
399
+ projectHeaders(projectId)
399
400
  );
400
401
  if (response.status >= 400) {
401
402
  this.handleError("list session downloads", response, sessionId);
@@ -423,12 +424,10 @@ var SessionDownloadsResource = class {
423
424
  async get(sessionId, downloadId, projectId) {
424
425
  const response = await this.client._get(
425
426
  `${this.client.baseUrl}/instance/v1/sessions/${sessionId}/downloads/${downloadId}`,
427
+ void 0,
426
428
  {
427
- api_key: this.client.apiKey,
428
- project_id: projectId ?? this.client.projectId
429
- },
430
- {
431
- responseType: "arraybuffer"
429
+ responseType: "arraybuffer",
430
+ ...projectHeaders(projectId) ?? {}
432
431
  }
433
432
  );
434
433
  if (response.status >= 400) {
@@ -439,12 +438,10 @@ var SessionDownloadsResource = class {
439
438
  async archive(sessionId, projectId) {
440
439
  const response = await this.client._get(
441
440
  `${this.client.baseUrl}/instance/v1/sessions/${sessionId}/downloads/archive`,
441
+ void 0,
442
442
  {
443
- api_key: this.client.apiKey,
444
- project_id: projectId ?? this.client.projectId
445
- },
446
- {
447
- responseType: "arraybuffer"
443
+ responseType: "arraybuffer",
444
+ ...projectHeaders(projectId) ?? {}
448
445
  }
449
446
  );
450
447
  if (response.status >= 400) {
@@ -455,10 +452,8 @@ var SessionDownloadsResource = class {
455
452
  async delete(sessionId, projectId) {
456
453
  const response = await this.client._delete(
457
454
  `${this.client.baseUrl}/instance/v1/sessions/${sessionId}/downloads`,
458
- {
459
- api_key: this.client.apiKey,
460
- project_id: projectId ?? this.client.projectId
461
- }
455
+ {},
456
+ projectHeaders(projectId)
462
457
  );
463
458
  if (response.status >= 400) {
464
459
  this.handleError("delete session downloads", response, sessionId);
@@ -496,8 +491,6 @@ var SessionsResource = class {
496
491
  */
497
492
  async create(options = {}) {
498
493
  const payload = {
499
- api_key: this.client.apiKey,
500
- project_id: options.projectId ?? this.client.projectId,
501
494
  browser_mode: options.browserMode ?? "normal"
502
495
  };
503
496
  if (options.customImageId) {
@@ -525,6 +518,12 @@ var SessionsResource = class {
525
518
  if (options.proxy) {
526
519
  payload.proxy = this.normalizeProxy(options.proxy);
527
520
  }
521
+ if (options.officialProxy) {
522
+ if (options.proxy) {
523
+ throw new ValidationError("officialProxy cannot be used together with proxy");
524
+ }
525
+ payload.official_proxy = true;
526
+ }
528
527
  if (options.weakLock) {
529
528
  payload.weak_lock = true;
530
529
  }
@@ -532,7 +531,11 @@ var SessionsResource = class {
532
531
  return this.createAsync(withRequestedRegion(this.client, payload), options);
533
532
  }
534
533
  const url = `${this.client.baseUrl}/instance`;
535
- const response = await this.client._post(url, withRequestedRegion(this.client, payload));
534
+ const response = await this.client._post(
535
+ url,
536
+ withRequestedRegion(this.client, payload),
537
+ projectHeaders(options.projectId)
538
+ );
536
539
  if (response.status >= 400) {
537
540
  this.handleCreateError(response);
538
541
  }
@@ -564,7 +567,11 @@ var SessionsResource = class {
564
567
  });
565
568
  }
566
569
  async createAsync(payload, options) {
567
- const response = await this.client._post(`${this.client.baseUrl}/instance/v2`, payload);
570
+ const response = await this.client._post(
571
+ `${this.client.baseUrl}/instance/v2`,
572
+ payload,
573
+ projectHeaders(options.projectId)
574
+ );
568
575
  if (response.status >= 400) {
569
576
  this.handleCreateError(response);
570
577
  }
@@ -626,10 +633,8 @@ var SessionsResource = class {
626
633
  */
627
634
  async get(sessionId, projectId) {
628
635
  const response = await this.client._post(`${this.client.baseUrl}/instance/session`, withRequestedRegion(this.client, {
629
- api_key: this.client.apiKey,
630
- project_id: projectId ?? this.client.projectId,
631
636
  session_id: sessionId
632
- }));
637
+ }), projectHeaders(projectId));
633
638
  if (response.status >= 400) {
634
639
  this.handleGetError(response, sessionId);
635
640
  }
@@ -640,14 +645,15 @@ var SessionsResource = class {
640
645
  */
641
646
  async list(options = {}) {
642
647
  const url = `${this.client.baseUrl}/instance/v2/sessions`;
643
- const payload = {
644
- api_key: this.client.apiKey,
645
- project_id: options.projectId ?? this.client.projectId
646
- };
648
+ const payload = {};
647
649
  if (options.status) {
648
650
  payload.status = options.status;
649
651
  }
650
- const response = await this.client._post(url, withRequestedRegion(this.client, payload));
652
+ const response = await this.client._post(
653
+ url,
654
+ withRequestedRegion(this.client, payload),
655
+ projectHeaders(options.projectId)
656
+ );
651
657
  if (response.status >= 400) {
652
658
  this.handleListError(response);
653
659
  }
@@ -674,11 +680,9 @@ var SessionsResource = class {
674
680
  async delete(options) {
675
681
  const url = `${this.client.baseUrl}/instance`;
676
682
  const payload = withRequestedRegion(this.client, {
677
- api_key: this.client.apiKey,
678
- project_id: options.projectId ?? this.client.projectId,
679
683
  session_id: options.sessionId
680
684
  });
681
- const response = await this.client._delete(url, payload);
685
+ const response = await this.client._delete(url, payload, projectHeaders(options.projectId));
682
686
  if (response.status >= 400) {
683
687
  this.handleDeleteError(response, options.sessionId);
684
688
  }
@@ -1552,8 +1556,8 @@ var Lexmount = class {
1552
1556
  logger2.debug(`${method} request to ${requestUrl}`);
1553
1557
  try {
1554
1558
  const headers = {
1555
- api_key: this.apiKey,
1556
- project_id: this.projectId,
1559
+ "x-api-key": this.apiKey,
1560
+ "x-project-id": this.projectId,
1557
1561
  ...this.getDefaultHeaders(config2.data),
1558
1562
  ...config2.headers ?? {}
1559
1563
  };
@@ -1699,7 +1703,7 @@ var Lexmount = class {
1699
1703
  };
1700
1704
 
1701
1705
  // src/index.ts
1702
- var VERSION = "0.5.9";
1706
+ var VERSION = "0.5.10";
1703
1707
  export {
1704
1708
  APIError,
1705
1709
  AuthenticationError,