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.js CHANGED
@@ -193,6 +193,9 @@ __export(index_exports, {
193
193
  profileDuplicate: () => profileDuplicate,
194
194
  profileGet: () => profileGet,
195
195
  profileList: () => profileList,
196
+ profileSessionConfigDelete: () => profileSessionConfigDelete,
197
+ profileSessionConfigGet: () => profileSessionConfigGet,
198
+ profileSessionConfigSet: () => profileSessionConfigSet,
196
199
  profileStateSet: () => profileStateSet,
197
200
  readCookiesFile: () => readCookiesFile,
198
201
  readyCheck: () => readyCheck,
@@ -252,7 +255,7 @@ __export(index_exports, {
252
255
  module.exports = __toCommonJS(index_exports);
253
256
 
254
257
  // src/version.ts
255
- var SDK_VERSION = true ? "1.10.20" : "dev";
258
+ var SDK_VERSION = true ? "1.10.22" : "dev";
256
259
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
257
260
 
258
261
  // src/version-check.ts
@@ -1698,6 +1701,25 @@ var profileStateSet = (options) => (options.client ?? client).post({
1698
1701
  ...options.headers
1699
1702
  }
1700
1703
  });
1704
+ var profileSessionConfigDelete = (options) => (options.client ?? client).delete({
1705
+ security: [{ scheme: "bearer", type: "http" }],
1706
+ url: "/profiles/{profile_id}/session-config",
1707
+ ...options
1708
+ });
1709
+ var profileSessionConfigGet = (options) => (options.client ?? client).get({
1710
+ security: [{ scheme: "bearer", type: "http" }],
1711
+ url: "/profiles/{profile_id}/session-config",
1712
+ ...options
1713
+ });
1714
+ var profileSessionConfigSet = (options) => (options.client ?? client).put({
1715
+ security: [{ scheme: "bearer", type: "http" }],
1716
+ url: "/profiles/{profile_id}/session-config",
1717
+ ...options,
1718
+ headers: {
1719
+ "Content-Type": "application/json",
1720
+ ...options.headers
1721
+ }
1722
+ });
1701
1723
  var profileList = (options) => (options?.client ?? client).get({
1702
1724
  security: [{ scheme: "bearer", type: "http" }],
1703
1725
  url: "/profiles",
@@ -2904,6 +2926,21 @@ function createResources(client2, getApiKey) {
2904
2926
  const response = await profileList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2905
2927
  return response.data;
2906
2928
  },
2929
+ /** profileSessionConfigDelete: /profiles/{profile_id}/session-config. Returns the API response body. */
2930
+ sessionConfigDelete: async (profileId, requestOptions = {}) => {
2931
+ const response = await profileSessionConfigDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
2932
+ return response.data;
2933
+ },
2934
+ /** profileSessionConfigGet: /profiles/{profile_id}/session-config. Returns the API response body. */
2935
+ sessionConfigGet: async (profileId, requestOptions = {}) => {
2936
+ const response = await profileSessionConfigGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId } });
2937
+ return response.data;
2938
+ },
2939
+ /** profileSessionConfigSet: /profiles/{profile_id}/session-config. Returns the API response body. */
2940
+ sessionConfigSet: async (profileId, body, requestOptions = {}) => {
2941
+ const response = await profileSessionConfigSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
2942
+ return response.data;
2943
+ },
2907
2944
  /** profileStateSet: /profiles/{profile_id}/state. Returns the API response body. */
2908
2945
  stateSet: async (profileId, body, requestOptions = {}) => {
2909
2946
  const response = await profileStateSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
@@ -3512,6 +3549,7 @@ var RETRY_AFTER_MAX_MS = 2e4;
3512
3549
  var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
3513
3550
  var REFUSED_STATUSES = /* @__PURE__ */ new Set([503, 529]);
3514
3551
  var GATEWAY_STATUSES = /* @__PURE__ */ new Set([502, 504]);
3552
+ var WORKER_TIMEOUT_ERROR_CLASS = "WorkerRequestTimeout";
3515
3553
  var NOT_SENT_ERROR_CODES = /* @__PURE__ */ new Set([
3516
3554
  "ECONNREFUSED",
3517
3555
  "EAI_AGAIN",
@@ -3529,7 +3567,8 @@ var BROKEN_CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
3529
3567
  function isIdempotentMethod(method) {
3530
3568
  return IDEMPOTENT_METHODS.has(method.toUpperCase());
3531
3569
  }
3532
- function isRetryableStatus(status, method) {
3570
+ function isRetryableStatus(status, method, errorClass) {
3571
+ if (status === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) return isIdempotentMethod(method);
3533
3572
  return REFUSED_STATUSES.has(status) || GATEWAY_STATUSES.has(status) && isIdempotentMethod(method);
3534
3573
  }
3535
3574
  function isRetryableNetworkError(error, method) {
@@ -3581,7 +3620,7 @@ function createRetryingFetch(options) {
3581
3620
  await wait2(delay4, signal);
3582
3621
  continue;
3583
3622
  }
3584
- if (last || !isRetryableStatus(response.status, method)) return response;
3623
+ if (last || !isRetryableStatus(response.status, method, response.headers.get("x-error-class"))) return response;
3585
3624
  const delay3 = retryDelayMs(attempt, response.headers.get("retry-after"), options.random);
3586
3625
  if (delay3 === void 0 || !fitsDeadline(delay3)) return response;
3587
3626
  await response.body?.cancel().catch(() => void 0);
@@ -3761,7 +3800,9 @@ var Session = class {
3761
3800
  * (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
3762
3801
  * errors are retried up to `SESSION_START_TRIES` times. With client
3763
3802
  * retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
3764
- * 4xx errors are never retried.
3803
+ * 4xx errors are never retried, nor is a 529 marked
3804
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
3805
+ * time and may already have created the session.
3765
3806
  *
3766
3807
  * Managed-auth sessions wait for readiness by default. Pass
3767
3808
  * `{ wait_for_authentication: false }` for an explicit nonblocking start,
@@ -3816,7 +3857,11 @@ var Session = class {
3816
3857
  sessionData = response.data;
3817
3858
  break;
3818
3859
  } catch (error) {
3819
- const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST") : isRetryableNetworkError(error, "POST");
3860
+ const errorClass = error instanceof NotteAPIError ? error.response?.headers.get("x-error-class") : void 0;
3861
+ if (error instanceof NotteAPIError && error.statusCode === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) {
3862
+ throw error;
3863
+ }
3864
+ const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST", errorClass) : isRetryableNetworkError(error, "POST");
3820
3865
  if (maxRetries > 0 && transient) {
3821
3866
  const wait2 = transientRetries >= maxRetries ? void 0 : error instanceof NotteAPIError ? retryDelayMs(transientRetries, error.response?.headers.get("retry-after")) : backoffDelayMs(transientRetries);
3822
3867
  if (wait2 === void 0 || !fitsDeadline(wait2)) throw error;
@@ -6903,6 +6948,9 @@ var wait = builder("wait");
6903
6948
  var pressKey = builder("press_key");
6904
6949
  var scrollUp = builder("scroll_up");
6905
6950
  var scrollDown = builder("scroll_down");
6951
+ var mouseClick = builder("mouse_click");
6952
+ var mouseMove = builder("mouse_move");
6953
+ var mouseDrag = builder("mouse_drag");
6906
6954
  var captchaSolve = builder("captcha_solve");
6907
6955
  var help = builder("help");
6908
6956
  var completion = builder("completion");
@@ -6932,6 +6980,9 @@ var actions = {
6932
6980
  pressKey,
6933
6981
  scrollUp,
6934
6982
  scrollDown,
6983
+ mouseClick,
6984
+ mouseMove,
6985
+ mouseDrag,
6935
6986
  captchaSolve,
6936
6987
  help,
6937
6988
  completion,
@@ -7140,6 +7191,9 @@ var createClient2 = (config) => {
7140
7191
  profileDuplicate,
7141
7192
  profileGet,
7142
7193
  profileList,
7194
+ profileSessionConfigDelete,
7195
+ profileSessionConfigGet,
7196
+ profileSessionConfigSet,
7143
7197
  profileStateSet,
7144
7198
  readCookiesFile,
7145
7199
  readyCheck,