notte-sdk 1.10.20 → 1.10.22

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
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = true ? "1.10.20" : "dev";
2
+ var SDK_VERSION = true ? "1.10.22" : "dev";
3
3
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
4
4
 
5
5
  // src/version-check.ts
@@ -1445,6 +1445,25 @@ var profileStateSet = (options) => (options.client ?? client).post({
1445
1445
  ...options.headers
1446
1446
  }
1447
1447
  });
1448
+ var profileSessionConfigDelete = (options) => (options.client ?? client).delete({
1449
+ security: [{ scheme: "bearer", type: "http" }],
1450
+ url: "/profiles/{profile_id}/session-config",
1451
+ ...options
1452
+ });
1453
+ var profileSessionConfigGet = (options) => (options.client ?? client).get({
1454
+ security: [{ scheme: "bearer", type: "http" }],
1455
+ url: "/profiles/{profile_id}/session-config",
1456
+ ...options
1457
+ });
1458
+ var profileSessionConfigSet = (options) => (options.client ?? client).put({
1459
+ security: [{ scheme: "bearer", type: "http" }],
1460
+ url: "/profiles/{profile_id}/session-config",
1461
+ ...options,
1462
+ headers: {
1463
+ "Content-Type": "application/json",
1464
+ ...options.headers
1465
+ }
1466
+ });
1448
1467
  var profileList = (options) => (options?.client ?? client).get({
1449
1468
  security: [{ scheme: "bearer", type: "http" }],
1450
1469
  url: "/profiles",
@@ -2651,6 +2670,21 @@ function createResources(client2, getApiKey) {
2651
2670
  const response = await profileList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2652
2671
  return response.data;
2653
2672
  },
2673
+ /** profileSessionConfigDelete: /profiles/{profile_id}/session-config. Returns the API response body. */
2674
+ sessionConfigDelete: async (profileId, requestOptions = {}) => {
2675
+ const response = await profileSessionConfigDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
2676
+ return response.data;
2677
+ },
2678
+ /** profileSessionConfigGet: /profiles/{profile_id}/session-config. Returns the API response body. */
2679
+ sessionConfigGet: async (profileId, requestOptions = {}) => {
2680
+ const response = await profileSessionConfigGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
2681
+ return response.data;
2682
+ },
2683
+ /** profileSessionConfigSet: /profiles/{profile_id}/session-config. Returns the API response body. */
2684
+ sessionConfigSet: async (profileId, body, requestOptions = {}) => {
2685
+ const response = await profileSessionConfigSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
2686
+ return response.data;
2687
+ },
2654
2688
  /** profileStateSet: /profiles/{profile_id}/state. Returns the API response body. */
2655
2689
  stateSet: async (profileId, body, requestOptions = {}) => {
2656
2690
  const response = await profileStateSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
@@ -3259,6 +3293,7 @@ var RETRY_AFTER_MAX_MS = 2e4;
3259
3293
  var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
3260
3294
  var REFUSED_STATUSES = /* @__PURE__ */ new Set([503, 529]);
3261
3295
  var GATEWAY_STATUSES = /* @__PURE__ */ new Set([502, 504]);
3296
+ var WORKER_TIMEOUT_ERROR_CLASS = "WorkerRequestTimeout";
3262
3297
  var NOT_SENT_ERROR_CODES = /* @__PURE__ */ new Set([
3263
3298
  "ECONNREFUSED",
3264
3299
  "EAI_AGAIN",
@@ -3276,7 +3311,8 @@ var BROKEN_CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
3276
3311
  function isIdempotentMethod(method) {
3277
3312
  return IDEMPOTENT_METHODS.has(method.toUpperCase());
3278
3313
  }
3279
- function isRetryableStatus(status, method) {
3314
+ function isRetryableStatus(status, method, errorClass) {
3315
+ if (status === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) return isIdempotentMethod(method);
3280
3316
  return REFUSED_STATUSES.has(status) || GATEWAY_STATUSES.has(status) && isIdempotentMethod(method);
3281
3317
  }
3282
3318
  function isRetryableNetworkError(error, method) {
@@ -3328,7 +3364,7 @@ function createRetryingFetch(options) {
3328
3364
  await wait2(delay4, signal);
3329
3365
  continue;
3330
3366
  }
3331
- if (last || !isRetryableStatus(response.status, method)) return response;
3367
+ if (last || !isRetryableStatus(response.status, method, response.headers.get("x-error-class"))) return response;
3332
3368
  const delay3 = retryDelayMs(attempt, response.headers.get("retry-after"), options.random);
3333
3369
  if (delay3 === void 0 || !fitsDeadline(delay3)) return response;
3334
3370
  await response.body?.cancel().catch(() => void 0);
@@ -3508,7 +3544,9 @@ var Session = class {
3508
3544
  * (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
3509
3545
  * errors are retried up to `SESSION_START_TRIES` times. With client
3510
3546
  * retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
3511
- * 4xx errors are never retried.
3547
+ * 4xx errors are never retried, nor is a 529 marked
3548
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
3549
+ * time and may already have created the session.
3512
3550
  *
3513
3551
  * Managed-auth sessions wait for readiness by default. Pass
3514
3552
  * `{ wait_for_authentication: false }` for an explicit nonblocking start,
@@ -3563,7 +3601,11 @@ var Session = class {
3563
3601
  sessionData = response.data;
3564
3602
  break;
3565
3603
  } catch (error) {
3566
- const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST") : isRetryableNetworkError(error, "POST");
3604
+ const errorClass = error instanceof NotteAPIError ? error.response?.headers.get("x-error-class") : void 0;
3605
+ if (error instanceof NotteAPIError && error.statusCode === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) {
3606
+ throw error;
3607
+ }
3608
+ const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST", errorClass) : isRetryableNetworkError(error, "POST");
3567
3609
  if (maxRetries > 0 && transient) {
3568
3610
  const wait2 = transientRetries >= maxRetries ? void 0 : error instanceof NotteAPIError ? retryDelayMs(transientRetries, error.response?.headers.get("retry-after")) : backoffDelayMs(transientRetries);
3569
3611
  if (wait2 === void 0 || !fitsDeadline(wait2)) throw error;
@@ -6650,6 +6692,9 @@ var wait = builder("wait");
6650
6692
  var pressKey = builder("press_key");
6651
6693
  var scrollUp = builder("scroll_up");
6652
6694
  var scrollDown = builder("scroll_down");
6695
+ var mouseClick = builder("mouse_click");
6696
+ var mouseMove = builder("mouse_move");
6697
+ var mouseDrag = builder("mouse_drag");
6653
6698
  var captchaSolve = builder("captcha_solve");
6654
6699
  var help = builder("help");
6655
6700
  var completion = builder("completion");
@@ -6679,6 +6724,9 @@ var actions = {
6679
6724
  pressKey,
6680
6725
  scrollUp,
6681
6726
  scrollDown,
6727
+ mouseClick,
6728
+ mouseMove,
6729
+ mouseDrag,
6682
6730
  captchaSolve,
6683
6731
  help,
6684
6732
  completion,
@@ -6887,6 +6935,9 @@ export {
6887
6935
  profileDuplicate,
6888
6936
  profileGet,
6889
6937
  profileList,
6938
+ profileSessionConfigDelete,
6939
+ profileSessionConfigGet,
6940
+ profileSessionConfigSet,
6890
6941
  profileStateSet,
6891
6942
  readCookiesFile,
6892
6943
  readyCheck,