@airtop/sdk 0.1.18 → 0.1.26

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.
Files changed (150) hide show
  1. package/api/resources/profiles/client/Client.js +2 -2
  2. package/api/resources/sessions/client/Client.js +14 -14
  3. package/api/resources/sessions/types/SessionsEventsResponse.d.ts +4 -4
  4. package/api/resources/sessions/types/index.d.ts +1 -1
  5. package/api/resources/sessions/types/index.js +1 -1
  6. package/api/resources/windows/client/Client.js +26 -26
  7. package/api/types/AirtopProxyConfiguration.d.ts +9 -0
  8. package/api/types/ExternalSessionWithConnectionInfo.d.ts +1 -1
  9. package/api/types/PageQueryConfig.d.ts +2 -0
  10. package/api/types/PaginatedExtractionConfig.d.ts +3 -0
  11. package/api/types/Proxy.d.ts +9 -6
  12. package/api/types/ProxyConfigurationKind.d.ts +9 -0
  13. package/api/types/ProxyCredentials.d.ts +11 -0
  14. package/api/types/ScrapeConfig.d.ts +7 -0
  15. package/api/types/SessionConfigV1.d.ts +1 -1
  16. package/api/types/SessionConfigV1Proxy.d.ts +4 -4
  17. package/api/types/VisualAnalysisConfig.d.ts +1 -1
  18. package/api/types/VisualAnalysisConfigResultSelectionStrategy.d.ts +3 -2
  19. package/api/types/VisualAnalysisConfigResultSelectionStrategy.js +1 -0
  20. package/api/types/Window.d.ts +2 -0
  21. package/api/types/index.d.ts +4 -2
  22. package/api/types/index.js +4 -2
  23. package/biome.json +66 -0
  24. package/config/tsconfig-nobase.json +16 -0
  25. package/dist/api/resources/profiles/client/Client.js +2 -2
  26. package/dist/api/resources/sessions/client/Client.js +14 -14
  27. package/dist/api/resources/sessions/types/SessionsEventsResponse.d.ts +4 -4
  28. package/dist/api/resources/sessions/types/index.d.ts +1 -1
  29. package/dist/api/resources/sessions/types/index.js +1 -1
  30. package/dist/api/resources/windows/client/Client.js +26 -26
  31. package/dist/api/types/AirtopProxyConfiguration.d.ts +9 -0
  32. package/dist/api/types/AirtopProxyConfiguration.js +5 -0
  33. package/dist/api/types/ExternalSessionWithConnectionInfo.d.ts +1 -1
  34. package/dist/api/types/PageQueryConfig.d.ts +2 -0
  35. package/dist/api/types/PaginatedExtractionConfig.d.ts +3 -0
  36. package/dist/api/types/Proxy.d.ts +9 -6
  37. package/dist/api/types/ProxyConfigurationKind.d.ts +9 -0
  38. package/dist/api/types/ProxyConfigurationKind.js +5 -0
  39. package/dist/api/types/ProxyCredentials.d.ts +11 -0
  40. package/dist/api/types/ProxyCredentials.js +5 -0
  41. package/dist/api/types/ScrapeConfig.d.ts +7 -0
  42. package/dist/api/types/ScrapeConfig.js +5 -0
  43. package/dist/api/types/SessionConfigV1.d.ts +1 -1
  44. package/dist/api/types/SessionConfigV1Proxy.d.ts +4 -4
  45. package/dist/api/types/VisualAnalysisConfig.d.ts +1 -1
  46. package/dist/api/types/VisualAnalysisConfigResultSelectionStrategy.d.ts +3 -2
  47. package/dist/api/types/VisualAnalysisConfigResultSelectionStrategy.js +1 -0
  48. package/dist/api/types/Window.d.ts +2 -0
  49. package/dist/api/types/index.d.ts +4 -2
  50. package/dist/api/types/index.js +4 -2
  51. package/dist/serialization/resources/sessions/types/SessionsEventsResponse.d.ts +5 -5
  52. package/dist/serialization/resources/sessions/types/SessionsEventsResponse.js +2 -2
  53. package/dist/serialization/resources/sessions/types/index.d.ts +1 -1
  54. package/dist/serialization/resources/sessions/types/index.js +1 -1
  55. package/dist/serialization/types/AirtopProxyConfiguration.d.ts +13 -0
  56. package/dist/serialization/types/{SessionConfigV1ProxyItem.js → AirtopProxyConfiguration.js} +4 -5
  57. package/dist/serialization/types/PageQueryConfig.d.ts +2 -0
  58. package/dist/serialization/types/PageQueryConfig.js +2 -0
  59. package/dist/serialization/types/PaginatedExtractionConfig.d.ts +2 -0
  60. package/dist/serialization/types/PaginatedExtractionConfig.js +2 -0
  61. package/dist/serialization/types/Proxy.d.ts +4 -6
  62. package/dist/serialization/types/Proxy.js +3 -5
  63. package/dist/serialization/types/ProxyConfigurationKind.d.ts +14 -0
  64. package/dist/serialization/types/{CustomProxy.js → ProxyConfigurationKind.js} +5 -2
  65. package/dist/serialization/types/ProxyCredentials.d.ts +14 -0
  66. package/{serialization/types/SessionConfigV1ProxyItem.js → dist/serialization/types/ProxyCredentials.js} +5 -5
  67. package/dist/serialization/types/ScrapeConfig.d.ts +12 -0
  68. package/dist/serialization/types/ScrapeConfig.js +33 -0
  69. package/dist/serialization/types/SessionConfigV1Proxy.d.ts +3 -3
  70. package/dist/serialization/types/SessionConfigV1Proxy.js +4 -4
  71. package/dist/serialization/types/VisualAnalysisConfigResultSelectionStrategy.d.ts +1 -1
  72. package/dist/serialization/types/VisualAnalysisConfigResultSelectionStrategy.js +1 -1
  73. package/dist/serialization/types/Window.d.ts +1 -0
  74. package/dist/serialization/types/Window.js +1 -0
  75. package/dist/serialization/types/index.d.ts +4 -2
  76. package/dist/serialization/types/index.js +4 -2
  77. package/dist/utils/batch-operate/SessionQueue.d.ts +4 -4
  78. package/dist/utils/batch-operate/SessionQueue.js +11 -12
  79. package/dist/utils/batch-operate/WindowQueue.d.ts +3 -3
  80. package/dist/utils/batch-operate/WindowQueue.js +23 -11
  81. package/dist/utils/batch-operate/batch-util.d.ts +2 -2
  82. package/dist/utils/batch-operate/batch-util.js +5 -5
  83. package/dist/utils/batch-operate/helpers.d.ts +1 -1
  84. package/dist/utils/batch-operate/types.d.ts +1 -1
  85. package/dist/utils/index.d.ts +3 -3
  86. package/dist/utils/process-screenshots.d.ts +1 -1
  87. package/dist/utils/process-screenshots.js +4 -4
  88. package/dist/wrapper/AirtopClient.d.ts +1 -1
  89. package/dist/wrapper/AirtopClient.js +3 -3
  90. package/dist/wrapper/AirtopSessions.d.ts +2 -2
  91. package/dist/wrapper/AirtopSessions.js +4 -4
  92. package/dist/wrapper/AirtopWindows.d.ts +9 -9
  93. package/dist/wrapper/AirtopWindows.js +11 -11
  94. package/lefthook.yml +23 -0
  95. package/package.json +9 -3
  96. package/serialization/resources/sessions/types/SessionsEventsResponse.d.ts +5 -5
  97. package/serialization/resources/sessions/types/SessionsEventsResponse.js +2 -2
  98. package/serialization/resources/sessions/types/index.d.ts +1 -1
  99. package/serialization/resources/sessions/types/index.js +1 -1
  100. package/serialization/types/AirtopProxyConfiguration.d.ts +13 -0
  101. package/serialization/types/AirtopProxyConfiguration.js +34 -0
  102. package/serialization/types/PageQueryConfig.d.ts +2 -0
  103. package/serialization/types/PageQueryConfig.js +2 -0
  104. package/serialization/types/PaginatedExtractionConfig.d.ts +2 -0
  105. package/serialization/types/PaginatedExtractionConfig.js +2 -0
  106. package/serialization/types/Proxy.d.ts +4 -6
  107. package/serialization/types/Proxy.js +3 -5
  108. package/serialization/types/ProxyConfigurationKind.d.ts +14 -0
  109. package/serialization/types/{CustomProxy.js → ProxyConfigurationKind.js} +5 -2
  110. package/serialization/types/ProxyCredentials.d.ts +14 -0
  111. package/serialization/types/ProxyCredentials.js +35 -0
  112. package/serialization/types/ScrapeConfig.d.ts +12 -0
  113. package/serialization/types/ScrapeConfig.js +33 -0
  114. package/serialization/types/SessionConfigV1Proxy.d.ts +3 -3
  115. package/serialization/types/SessionConfigV1Proxy.js +4 -4
  116. package/serialization/types/VisualAnalysisConfigResultSelectionStrategy.d.ts +1 -1
  117. package/serialization/types/VisualAnalysisConfigResultSelectionStrategy.js +1 -1
  118. package/serialization/types/Window.d.ts +1 -0
  119. package/serialization/types/Window.js +1 -0
  120. package/serialization/types/index.d.ts +4 -2
  121. package/serialization/types/index.js +4 -2
  122. package/utils/batch-operate/SessionQueue.d.ts +4 -4
  123. package/utils/batch-operate/SessionQueue.js +11 -12
  124. package/utils/batch-operate/WindowQueue.d.ts +3 -3
  125. package/utils/batch-operate/WindowQueue.js +23 -11
  126. package/utils/batch-operate/batch-util.d.ts +2 -2
  127. package/utils/batch-operate/batch-util.js +5 -5
  128. package/utils/batch-operate/helpers.d.ts +1 -1
  129. package/utils/batch-operate/types.d.ts +1 -1
  130. package/utils/index.d.ts +3 -3
  131. package/utils/process-screenshots.d.ts +1 -1
  132. package/utils/process-screenshots.js +4 -4
  133. package/wrapper/AirtopClient.d.ts +1 -1
  134. package/wrapper/AirtopClient.js +3 -3
  135. package/wrapper/AirtopSessions.d.ts +2 -2
  136. package/wrapper/AirtopSessions.js +4 -4
  137. package/wrapper/AirtopWindows.d.ts +9 -9
  138. package/wrapper/AirtopWindows.js +11 -11
  139. package/api/types/CustomProxy.d.ts +0 -14
  140. package/api/types/SessionConfigV1ProxyItem.d.ts +0 -12
  141. package/dist/api/types/CustomProxy.d.ts +0 -14
  142. package/dist/api/types/SessionConfigV1ProxyItem.d.ts +0 -12
  143. package/dist/serialization/types/CustomProxy.d.ts +0 -11
  144. package/dist/serialization/types/SessionConfigV1ProxyItem.d.ts +0 -14
  145. package/serialization/types/CustomProxy.d.ts +0 -11
  146. package/serialization/types/SessionConfigV1ProxyItem.d.ts +0 -14
  147. /package/api/types/{CustomProxy.js → AirtopProxyConfiguration.js} +0 -0
  148. /package/api/types/{SessionConfigV1ProxyItem.js → ProxyConfigurationKind.js} +0 -0
  149. /package/{dist/api/types/CustomProxy.js → api/types/ProxyCredentials.js} +0 -0
  150. /package/{dist/api/types/SessionConfigV1ProxyItem.js → api/types/ScrapeConfig.js} +0 -0
@@ -39,6 +39,7 @@ __exportStar(require("./PageQueryConfig"), exports);
39
39
  __exportStar(require("./PageQueryExperimentalConfig"), exports);
40
40
  __exportStar(require("./PaginatedExtractionConfig"), exports);
41
41
  __exportStar(require("./Pagination"), exports);
42
+ __exportStar(require("./ScrapeConfig"), exports);
42
43
  __exportStar(require("./ScrapeResponse"), exports);
43
44
  __exportStar(require("./ScrapeResponseContent"), exports);
44
45
  __exportStar(require("./ScrapeResponseEnvelope"), exports);
@@ -46,9 +47,10 @@ __exportStar(require("./ScrapeResponseOutput"), exports);
46
47
  __exportStar(require("./ScreenshotConfig"), exports);
47
48
  __exportStar(require("./ScreenshotMetadata"), exports);
48
49
  __exportStar(require("./ScreenshotRequestConfig"), exports);
50
+ __exportStar(require("./AirtopProxyConfiguration"), exports);
51
+ __exportStar(require("./ProxyCredentials"), exports);
49
52
  __exportStar(require("./Proxy"), exports);
50
- __exportStar(require("./CustomProxy"), exports);
51
- __exportStar(require("./SessionConfigV1ProxyItem"), exports);
53
+ __exportStar(require("./ProxyConfigurationKind"), exports);
52
54
  __exportStar(require("./SessionConfigV1Proxy"), exports);
53
55
  __exportStar(require("./SessionConfigV1"), exports);
54
56
  __exportStar(require("./SessionEventMessage"), exports);
@@ -1,7 +1,7 @@
1
- import type { AirtopClient } from "../../wrapper/AirtopClient";
2
- import type { BatchOperationError, BatchOperationInput, BatchOperationResponse, BatchOperationUrl } from "./types";
3
- import type { EventEmitter } from "eventemitter3";
4
- import type { AirtopSessionConfigV1 } from "wrapper/AirtopSessions";
1
+ import type { EventEmitter } from 'eventemitter3';
2
+ import type { AirtopClient } from '../../wrapper/AirtopClient';
3
+ import type { AirtopSessionConfigV1 } from '../../wrapper/AirtopSessions';
4
+ import type { BatchOperationError, BatchOperationInput, BatchOperationResponse, BatchOperationUrl } from './types';
5
5
  export declare class SessionQueue<T> {
6
6
  private activePromises;
7
7
  private activePromisesMutex;
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SessionQueue = void 0;
13
- const helpers_1 = require("./helpers");
14
- const WindowQueue_1 = require("./WindowQueue");
15
13
  const async_mutex_1 = require("async-mutex");
14
+ const WindowQueue_1 = require("./WindowQueue");
15
+ const helpers_1 = require("./helpers");
16
16
  class SessionQueue {
17
17
  constructor({ maxConcurrentSessions, runEmitter, maxWindowsPerSession, initialBatches, operation, client, sessionConfig, onError, }) {
18
18
  this.activePromises = [];
@@ -24,9 +24,8 @@ class SessionQueue {
24
24
  this.processingPromisesCount = 0;
25
25
  this.sessionPool = [];
26
26
  this.sessionPoolMutex = new async_mutex_1.Mutex();
27
- if (!Number.isInteger(maxConcurrentSessions) ||
28
- maxConcurrentSessions <= 0) {
29
- throw new Error("maxConcurrentSessions must be a positive integer");
27
+ if (!Number.isInteger(maxConcurrentSessions) || maxConcurrentSessions <= 0) {
28
+ throw new Error('maxConcurrentSessions must be a positive integer');
30
29
  }
31
30
  this.maxConcurrentSessions = maxConcurrentSessions;
32
31
  this.runEmitter = runEmitter;
@@ -41,7 +40,7 @@ class SessionQueue {
41
40
  this.isHalted = false;
42
41
  }
43
42
  handleHaltEvent() {
44
- this.client.log("Halt event received");
43
+ this.client.log('Halt event received');
45
44
  this.isHalted = true;
46
45
  }
47
46
  addUrlsToBatchQueue(newBatch) {
@@ -64,7 +63,7 @@ class SessionQueue {
64
63
  this.batchQueue = [...this.initialBatches];
65
64
  });
66
65
  this.processingPromisesCount++;
67
- this.runEmitter.on("halt", this.handleHaltEvent.bind(this));
66
+ this.runEmitter.on('halt', this.handleHaltEvent.bind(this));
68
67
  this.latestProcessingPromise = this.processPendingBatches();
69
68
  yield this.latestProcessingPromise;
70
69
  });
@@ -75,7 +74,7 @@ class SessionQueue {
75
74
  yield this.latestProcessingPromise;
76
75
  }
77
76
  yield this.terminateAllSessions();
78
- this.runEmitter.removeListener("halt", this.handleHaltEvent);
77
+ this.runEmitter.removeListener('halt', this.handleHaltEvent);
79
78
  return this.results;
80
79
  });
81
80
  }
@@ -108,7 +107,7 @@ class SessionQueue {
108
107
  break;
109
108
  const promise = (() => __awaiter(this, void 0, void 0, function* () {
110
109
  if (this.isHalted) {
111
- this.client.log("Halt event received, skipping batch");
110
+ this.client.log('Halt event received, skipping batch');
112
111
  return;
113
112
  }
114
113
  let sessionId;
@@ -121,7 +120,7 @@ class SessionQueue {
121
120
  });
122
121
  // Otherwise, create a new session
123
122
  if (!sessionId) {
124
- const { data: session, warnings, errors } = yield this.client.sessions.create({
123
+ const { data: session, warnings, errors, } = yield this.client.sessions.create({
125
124
  configuration: this.sessionConfig,
126
125
  });
127
126
  sessionId = session.id;
@@ -133,7 +132,7 @@ class SessionQueue {
133
132
  // Return the session to the pool
134
133
  yield this.sessionPoolMutex.runExclusive(() => {
135
134
  if (!sessionId) {
136
- throw new Error("Missing sessionId, cannot return to pool");
135
+ throw new Error('Missing sessionId, cannot return to pool');
137
136
  }
138
137
  this.sessionPool.push(sessionId);
139
138
  });
@@ -202,7 +201,7 @@ class SessionQueue {
202
201
  formatError(error) {
203
202
  return error instanceof Error ? error.message : String(error);
204
203
  }
205
- handleErrorAndWarningResponses({ warnings, errors, sessionId, batch }) {
204
+ handleErrorAndWarningResponses({ warnings, errors, sessionId, batch, }) {
206
205
  if (!warnings && !errors)
207
206
  return;
208
207
  const details = {
@@ -1,6 +1,6 @@
1
- import type { AirtopClient } from "../../wrapper/AirtopClient";
2
- import type { BatchOperationError, BatchOperationInput, BatchOperationResponse, BatchOperationUrl } from "./types";
3
- import type { EventEmitter } from "eventemitter3";
1
+ import type { EventEmitter } from 'eventemitter3';
2
+ import type { AirtopClient } from '../../wrapper/AirtopClient';
3
+ import type { BatchOperationError, BatchOperationInput, BatchOperationResponse, BatchOperationUrl } from './types';
4
4
  export declare class WindowQueue<T> {
5
5
  private activePromises;
6
6
  private urlQueue;
@@ -18,7 +18,7 @@ class WindowQueue {
18
18
  this.activePromisesMutex = new async_mutex_1.Mutex();
19
19
  this.urlQueueMutex = new async_mutex_1.Mutex();
20
20
  if (!Number.isInteger(maxWindowsPerSession) || maxWindowsPerSession <= 0) {
21
- throw new Error("maxWindowsPerSession must be a positive integer");
21
+ throw new Error('maxWindowsPerSession must be a positive integer');
22
22
  }
23
23
  this.maxWindowsPerSession = maxWindowsPerSession;
24
24
  this.runEmitter = runEmitter;
@@ -36,13 +36,13 @@ class WindowQueue {
36
36
  });
37
37
  }
38
38
  handleHaltEvent() {
39
- this.client.log("Halt event received");
39
+ this.client.log('Halt event received');
40
40
  this.isHalted = true;
41
41
  }
42
42
  processInBatches(urls) {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
44
  const results = [];
45
- this.runEmitter.on("halt", this.handleHaltEvent.bind(this));
45
+ this.runEmitter.on('halt', this.handleHaltEvent.bind(this));
46
46
  yield this.urlQueueMutex.runExclusive(() => {
47
47
  this.urlQueue = [...urls];
48
48
  });
@@ -80,13 +80,25 @@ class WindowQueue {
80
80
  url: urlData.url,
81
81
  });
82
82
  windowId = data.windowId;
83
- this.handleErrorAndWarningResponses({ warnings, errors, sessionId: this.sessionId, url: urlData, operation: "window creation" });
83
+ this.handleErrorAndWarningResponses({
84
+ warnings,
85
+ errors,
86
+ sessionId: this.sessionId,
87
+ url: urlData,
88
+ operation: 'window creation',
89
+ });
84
90
  if (!windowId) {
85
91
  throw new Error(`WindowId not found, errors: ${JSON.stringify(errors)}`);
86
92
  }
87
- const { data: windowInfo, warnings: windowWarnings, errors: windowErrors } = yield this.client.windows.getWindowInfo(this.sessionId, windowId);
93
+ const { data: windowInfo, warnings: windowWarnings, errors: windowErrors, } = yield this.client.windows.getWindowInfo(this.sessionId, windowId);
88
94
  liveViewUrl = windowInfo.liveViewUrl;
89
- this.handleErrorAndWarningResponses({ warnings: windowWarnings, errors: windowErrors, sessionId: this.sessionId, url: urlData, operation: "window info retrieval" });
95
+ this.handleErrorAndWarningResponses({
96
+ warnings: windowWarnings,
97
+ errors: windowErrors,
98
+ sessionId: this.sessionId,
99
+ url: urlData,
100
+ operation: 'window info retrieval',
101
+ });
90
102
  // Run the operation on the window
91
103
  const result = yield this.operation({
92
104
  windowId,
@@ -100,12 +112,12 @@ class WindowQueue {
100
112
  results.push(data);
101
113
  }
102
114
  if (shouldHaltBatch) {
103
- this.client.log("Emitting halt event");
104
- this.runEmitter.emit("halt");
115
+ this.client.log('Emitting halt event');
116
+ this.runEmitter.emit('halt');
105
117
  }
106
118
  if (additionalUrls && additionalUrls.length > 0) {
107
119
  this.client.log(`Emitting addUrls event with urls: ${JSON.stringify(additionalUrls)}`);
108
- this.runEmitter.emit("addUrls", additionalUrls);
120
+ this.runEmitter.emit('addUrls', additionalUrls);
109
121
  }
110
122
  }
111
123
  }
@@ -147,7 +159,7 @@ class WindowQueue {
147
159
  // Wait for all processes to complete
148
160
  yield Promise.allSettled(this.activePromises);
149
161
  // Remove the halt listener
150
- this.runEmitter.removeListener("halt", this.handleHaltEvent);
162
+ this.runEmitter.removeListener('halt', this.handleHaltEvent);
151
163
  return results;
152
164
  });
153
165
  }
@@ -181,7 +193,7 @@ class WindowQueue {
181
193
  formatError(error) {
182
194
  return error instanceof Error ? error.message : String(error);
183
195
  }
184
- handleErrorAndWarningResponses({ warnings, errors, sessionId, url, operation }) {
196
+ handleErrorAndWarningResponses({ warnings, errors, sessionId, url, operation, }) {
185
197
  if (!warnings && !errors)
186
198
  return;
187
199
  const details = {
@@ -1,3 +1,3 @@
1
- import type { AirtopClient } from "../../wrapper/AirtopClient";
2
- import type { BatchOperateConfig, BatchOperationInput, BatchOperationResponse, BatchOperationUrl } from "./types";
1
+ import type { AirtopClient } from '../../wrapper/AirtopClient';
2
+ import type { BatchOperateConfig, BatchOperationInput, BatchOperationResponse, BatchOperationUrl } from './types';
3
3
  export declare const batchOperate: <T>(urls: BatchOperationUrl[], operation: (input: BatchOperationInput) => Promise<BatchOperationResponse<T>>, client: AirtopClient, config?: BatchOperateConfig | undefined) => Promise<T[]>;
@@ -11,19 +11,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.batchOperate = void 0;
13
13
  const eventemitter3_1 = require("eventemitter3");
14
- const helpers_1 = require("./helpers");
15
14
  const SessionQueue_1 = require("./SessionQueue");
15
+ const helpers_1 = require("./helpers");
16
16
  const DEFAULT_MAX_WINDOWS_PER_SESSION = 1;
17
17
  const DEFAULT_MAX_CONCURRENT_SESSIONS = 30;
18
18
  const batchOperate = (urls, operation, // operation to invoke on each url
19
19
  client, config) => __awaiter(void 0, void 0, void 0, function* () {
20
20
  // Validate the urls before proceeding
21
21
  if (!Array.isArray(urls)) {
22
- throw new Error("Please provide a valid list of urls");
22
+ throw new Error('Please provide a valid list of urls');
23
23
  }
24
24
  for (const url of urls) {
25
- if (!url || typeof url !== "object" || !("url" in url)) {
26
- throw new Error("Please provide a valid list of urls");
25
+ if (!url || typeof url !== 'object' || !('url' in url)) {
26
+ throw new Error('Please provide a valid list of urls');
27
27
  }
28
28
  }
29
29
  const runEmitter = new eventemitter3_1.EventEmitter();
@@ -40,7 +40,7 @@ client, config) => __awaiter(void 0, void 0, void 0, function* () {
40
40
  sessionConfig,
41
41
  onError,
42
42
  });
43
- runEmitter.on("addUrls", (additionalUrls) => {
43
+ runEmitter.on('addUrls', (additionalUrls) => {
44
44
  sessionQueue.addUrlsToBatchQueue(additionalUrls);
45
45
  });
46
46
  yield sessionQueue.processInitialBatches();
@@ -1,2 +1,2 @@
1
- import type { BatchOperationUrl } from "./types";
1
+ import type { BatchOperationUrl } from './types';
2
2
  export declare const distributeUrlsToBatches: (urls: BatchOperationUrl[], maxConcurrentSessions: number) => BatchOperationUrl[][];
@@ -1,4 +1,4 @@
1
- import type { AirtopSessionConfigV1 } from "../../wrapper/AirtopSessions";
1
+ import type { AirtopSessionConfigV1 } from '../../wrapper/AirtopSessions';
2
2
  export declare type BatchOperateConfig = {
3
3
  maxConcurrentSessions?: number;
4
4
  maxWindowsPerSession?: number;
package/utils/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./batch-operate/batch-util";
2
- export * from "./batch-operate/types";
3
- export * from "./process-screenshots";
1
+ export * from './batch-operate/batch-util';
2
+ export * from './batch-operate/types';
3
+ export * from './process-screenshots';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { AiPromptResponse } from "api";
2
+ import type { AiPromptResponse } from '../api';
3
3
  export declare type ProcessScreenshotsResponse = {
4
4
  index: number;
5
5
  success: boolean;
@@ -16,8 +16,8 @@ function extractMimeAndBase64(dataUrl) {
16
16
  return { mimeType: match[1], base64Data: match[2] };
17
17
  }
18
18
  return {
19
- mimeType: "image/jpeg",
20
- base64Data: dataUrl.replace(/^data:image\/jpeg;base64,/, ""),
19
+ mimeType: 'image/jpeg',
20
+ base64Data: dataUrl.replace(/^data:image\/jpeg;base64,/, ''),
21
21
  };
22
22
  }
23
23
  function processScreenshots(response) {
@@ -30,13 +30,13 @@ function processScreenshots(response) {
30
30
  if (!screenshot.dataUrl) {
31
31
  return {
32
32
  index,
33
- error: new Error("Screenshot data URL not found"),
33
+ error: new Error('Screenshot data URL not found'),
34
34
  success: false,
35
35
  };
36
36
  }
37
37
  try {
38
38
  const { mimeType, base64Data } = extractMimeAndBase64(screenshot.dataUrl);
39
- const binaryData = Buffer.from(base64Data, "base64");
39
+ const binaryData = Buffer.from(base64Data, 'base64');
40
40
  return {
41
41
  index,
42
42
  binaryData,
@@ -1,7 +1,7 @@
1
1
  import { AirtopClient as FernClient } from '../Client';
2
+ import { type BatchOperateConfig, type BatchOperationInput, type BatchOperationResponse, type BatchOperationUrl } from '../utils';
2
3
  import { AirtopSessions } from './AirtopSessions';
3
4
  import { AirtopWindows } from './AirtopWindows';
4
- import { type BatchOperateConfig, type BatchOperationInput, type BatchOperationResponse, type BatchOperationUrl } from "../utils";
5
5
  declare type AugmentedOptions = FernClient.Options & {
6
6
  debug?: boolean;
7
7
  };
@@ -34,10 +34,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.AirtopClient = void 0;
36
36
  const Client_1 = require("../Client"); // alias the Fern generated client
37
+ const core = __importStar(require("../core"));
38
+ const utils_1 = require("../utils");
37
39
  const AirtopSessions_1 = require("./AirtopSessions");
38
40
  const AirtopWindows_1 = require("./AirtopWindows");
39
- const utils_1 = require("../utils");
40
- const core = __importStar(require("../core"));
41
41
  class AirtopClient {
42
42
  constructor(_options) {
43
43
  this._options = _options;
@@ -47,7 +47,7 @@ class AirtopClient {
47
47
  const version = require('../package.json').version; //we don't control tsconfig.json so we can't use resolveJsonModule
48
48
  if (!_options.fetcher) {
49
49
  _options.fetcher = (req) => {
50
- return core.fetcher(Object.assign(Object.assign({}, req), { headers: Object.assign(Object.assign({}, req.headers), { "x-airtop-sdk-source": "javascript", "x-airtop-sdk-version": version }) }));
50
+ return core.fetcher(Object.assign(Object.assign({}, req), { headers: Object.assign(Object.assign({}, req.headers), { 'x-airtop-sdk-source': 'javascript', 'x-airtop-sdk-version': version }) }));
51
51
  };
52
52
  }
53
53
  this._client = new Client_1.AirtopClient(_options);
@@ -1,5 +1,5 @@
1
- import * as Airtop from '../api';
2
- import { Sessions as SessionsClass, Sessions as SessionsNamespace } from '../api/resources/sessions/client/Client';
1
+ import type * as Airtop from '../api';
2
+ import { Sessions as SessionsClass, type Sessions as SessionsNamespace } from '../api/resources/sessions/client/Client';
3
3
  export interface AirtopSessionConfigV1 extends Airtop.SessionConfigV1 {
4
4
  skipWaitSessionReady?: boolean;
5
5
  }
@@ -44,17 +44,17 @@ class AirtopSessions extends Client_1.Sessions {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  const createSessionResponse = yield _super.create.call(this, request, requestOptions);
46
46
  if (!createSessionResponse.data) {
47
- throw new Error(`Error creating browser session`);
47
+ throw new Error('Error creating browser session');
48
48
  }
49
49
  if ((_a = request === null || request === void 0 ? void 0 : request.configuration) === null || _a === void 0 ? void 0 : _a.skipWaitSessionReady) {
50
50
  return createSessionResponse;
51
51
  }
52
- this.log('session created:\n' + JSON.stringify(createSessionResponse, null, 2));
52
+ this.log(`session created:\n${JSON.stringify(createSessionResponse, null, 2)}`);
53
53
  try {
54
54
  const event = yield this.waitForSessionReady(createSessionResponse.data.id, requestOptions);
55
55
  if (!event) {
56
56
  this.log('No browser created, timed out?');
57
- throw new Error(`Waiting for session ready timed out`);
57
+ throw new Error('Waiting for session ready timed out');
58
58
  }
59
59
  const getInfoResponse = yield this.getInfo(createSessionResponse.data.id, requestOptions);
60
60
  // Merge the createSessionResponse with any new data from getInfoResponse
@@ -73,7 +73,7 @@ class AirtopSessions extends Client_1.Sessions {
73
73
  try {
74
74
  for (var sessionEvents_1 = __asyncValues(sessionEvents), sessionEvents_1_1; sessionEvents_1_1 = yield sessionEvents_1.next(), !sessionEvents_1_1.done;) {
75
75
  const event = sessionEvents_1_1.value;
76
- this.log('status message received:\n' + JSON.stringify(event, null, 2));
76
+ this.log(`status message received:\n${JSON.stringify(event, null, 2)}`);
77
77
  const e = event;
78
78
  if (e.event === 'status' && e.status === 'running') {
79
79
  return event;
@@ -14,9 +14,9 @@ declare namespace seleniumWebdriver {
14
14
  createCDPConnection(domain: string): Promise<any>;
15
15
  }
16
16
  }
17
- import * as Airtop from "../api";
18
- import { Windows as WindowsClass, Windows as WindowsNamespace } from "../api/resources/windows/client/Client";
19
- import * as core from "../core";
17
+ import type * as Airtop from '../api';
18
+ import { Windows as WindowsClass, type Windows as WindowsNamespace } from '../api/resources/windows/client/Client';
19
+ import * as core from '../core';
20
20
  export declare class AirtopWindows extends WindowsClass {
21
21
  readonly _options: WindowsNamespace.Options;
22
22
  private apiKeySupplier;
@@ -33,8 +33,8 @@ export declare class AirtopWindows extends WindowsClass {
33
33
  * prompt: "What is the main idea of this page?"
34
34
  * })
35
35
  */
36
- promptContent(sessionId: string, windowId: string, request: Omit<Airtop.SessionPageQueryHandlerRequestBody, "configuration"> & {
37
- configuration?: Omit<Airtop.SessionPageQueryHandlerRequestBody["configuration"], "outputSchema"> & {
36
+ promptContent(sessionId: string, windowId: string, request: Omit<Airtop.SessionPageQueryHandlerRequestBody, 'configuration'> & {
37
+ configuration?: Omit<Airtop.SessionPageQueryHandlerRequestBody['configuration'], 'outputSchema'> & {
38
38
  outputSchema?: string | object;
39
39
  };
40
40
  }, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiPromptResponse>;
@@ -49,8 +49,8 @@ export declare class AirtopWindows extends WindowsClass {
49
49
  * prompt: "What is the main idea of this page?"
50
50
  * })
51
51
  */
52
- pageQuery(sessionId: string, windowId: string, request: Omit<Airtop.SessionPageQueryHandlerRequestBody, "configuration"> & {
53
- configuration?: Omit<Airtop.SessionPageQueryHandlerRequestBody["configuration"], "outputSchema"> & {
52
+ pageQuery(sessionId: string, windowId: string, request: Omit<Airtop.SessionPageQueryHandlerRequestBody, 'configuration'> & {
53
+ configuration?: Omit<Airtop.SessionPageQueryHandlerRequestBody['configuration'], 'outputSchema'> & {
54
54
  outputSchema?: string | object;
55
55
  };
56
56
  }, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiPromptResponse>;
@@ -73,8 +73,8 @@ export declare class AirtopWindows extends WindowsClass {
73
73
  * @example
74
74
  * await client.windows.summarizeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430")
75
75
  */
76
- summarizeContent(sessionId: string, windowId: string, request?: Omit<Airtop.SessionSummaryHandlerRequestBody, "configuration"> & {
77
- configuration?: Omit<Airtop.SessionSummaryHandlerRequestBody["configuration"], "outputSchema"> & {
76
+ summarizeContent(sessionId: string, windowId: string, request?: Omit<Airtop.SessionSummaryHandlerRequestBody, 'configuration'> & {
77
+ configuration?: Omit<Airtop.SessionSummaryHandlerRequestBody['configuration'], 'outputSchema'> & {
78
78
  outputSchema?: string | object;
79
79
  };
80
80
  }, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiPromptResponse>;
@@ -63,7 +63,7 @@ class AirtopWindows extends Client_1.Windows {
63
63
  });
64
64
  var _a, _b;
65
65
  return __awaiter(this, void 0, void 0, function* () {
66
- return _super.promptContent.call(this, sessionId, windowId, Object.assign(Object.assign({}, request), { configuration: Object.assign(Object.assign({}, request.configuration), { outputSchema: typeof ((_a = request.configuration) === null || _a === void 0 ? void 0 : _a.outputSchema) === "object"
66
+ return _super.promptContent.call(this, sessionId, windowId, Object.assign(Object.assign({}, request), { configuration: Object.assign(Object.assign({}, request.configuration), { outputSchema: typeof ((_a = request.configuration) === null || _a === void 0 ? void 0 : _a.outputSchema) === 'object'
67
67
  ? JSON.stringify(request.configuration.outputSchema)
68
68
  : (_b = request.configuration) === null || _b === void 0 ? void 0 : _b.outputSchema }) }), Object.assign(Object.assign({ timeoutInSeconds: 600 }, requestOptions), { maxRetries: 0 }));
69
69
  });
@@ -85,7 +85,7 @@ class AirtopWindows extends Client_1.Windows {
85
85
  });
86
86
  var _a, _b;
87
87
  return __awaiter(this, void 0, void 0, function* () {
88
- return _super.pageQuery.call(this, sessionId, windowId, Object.assign(Object.assign({}, request), { configuration: Object.assign(Object.assign({}, request.configuration), { outputSchema: typeof ((_a = request.configuration) === null || _a === void 0 ? void 0 : _a.outputSchema) === "object"
88
+ return _super.pageQuery.call(this, sessionId, windowId, Object.assign(Object.assign({}, request), { configuration: Object.assign(Object.assign({}, request.configuration), { outputSchema: typeof ((_a = request.configuration) === null || _a === void 0 ? void 0 : _a.outputSchema) === 'object'
89
89
  ? JSON.stringify(request.configuration.outputSchema)
90
90
  : (_b = request.configuration) === null || _b === void 0 ? void 0 : _b.outputSchema }) }), Object.assign(Object.assign({ timeoutInSeconds: 600 }, requestOptions), { maxRetries: 0 }));
91
91
  });
@@ -113,7 +113,7 @@ class AirtopWindows extends Client_1.Windows {
113
113
  */
114
114
  summarizeContent(sessionId, windowId, request, requestOptions) {
115
115
  var _a, _b, _c;
116
- return super.summarizeContent(sessionId, windowId, Object.assign(Object.assign({}, request), { configuration: Object.assign(Object.assign({}, request === null || request === void 0 ? void 0 : request.configuration), { outputSchema: typeof ((_a = request === null || request === void 0 ? void 0 : request.configuration) === null || _a === void 0 ? void 0 : _a.outputSchema) === "object"
116
+ return super.summarizeContent(sessionId, windowId, Object.assign(Object.assign({}, request), { configuration: Object.assign(Object.assign({}, request === null || request === void 0 ? void 0 : request.configuration), { outputSchema: typeof ((_a = request === null || request === void 0 ? void 0 : request.configuration) === null || _a === void 0 ? void 0 : _a.outputSchema) === 'object'
117
117
  ? JSON.stringify((_b = request === null || request === void 0 ? void 0 : request.configuration) === null || _b === void 0 ? void 0 : _b.outputSchema)
118
118
  : (_c = request === null || request === void 0 ? void 0 : request.configuration) === null || _c === void 0 ? void 0 : _c.outputSchema }) }), Object.assign(Object.assign({ timeoutInSeconds: 600 }, requestOptions), { maxRetries: 0 }));
119
119
  }
@@ -127,10 +127,10 @@ class AirtopWindows extends Client_1.Windows {
127
127
  return __awaiter(this, void 0, void 0, function* () {
128
128
  // Retrieve target information
129
129
  const cdpSession = yield page.context().newCDPSession(page);
130
- const { targetInfo } = yield cdpSession.send("Target.getTargetInfo");
130
+ const { targetInfo } = yield cdpSession.send('Target.getTargetInfo');
131
131
  const targetId = targetInfo.targetId;
132
132
  if (!targetId) {
133
- throw new Error("TargetId not found");
133
+ throw new Error('TargetId not found');
134
134
  }
135
135
  return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
136
136
  });
@@ -214,17 +214,17 @@ class AirtopWindows extends Client_1.Windows {
214
214
  // Get the current WebDriver session ID
215
215
  const webDriverSessionId = (yield driver.getSession()).getId();
216
216
  if (!webDriverSessionId) {
217
- throw new Error("No WebDriver session available");
217
+ throw new Error('No WebDriver session available');
218
218
  }
219
219
  const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;
220
220
  const response = yield (0, node_fetch_1.default)(chromedriverSessionUrl, {
221
- method: "POST",
221
+ method: 'POST',
222
222
  headers: {
223
- "Content-Type": "application/json",
223
+ 'Content-Type': 'application/json',
224
224
  Authorization: `Bearer ${apiKey}`,
225
225
  },
226
226
  body: JSON.stringify({
227
- cmd: "Target.getTargetInfo",
227
+ cmd: 'Target.getTargetInfo',
228
228
  params: {},
229
229
  }),
230
230
  });
@@ -235,10 +235,10 @@ class AirtopWindows extends Client_1.Windows {
235
235
  var _a, _b;
236
236
  return __awaiter(this, void 0, void 0, function* () {
237
237
  const apiKey = yield core.Supplier.get(this.apiKeySupplier);
238
- const result = yield this.executeSeleniumCDPCommand(driver, session, apiKey || "");
238
+ const result = yield this.executeSeleniumCDPCommand(driver, session, apiKey || '');
239
239
  const targetId = (_b = (_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.targetInfo) === null || _b === void 0 ? void 0 : _b.targetId;
240
240
  if (!targetId) {
241
- throw new Error("TargetId not found");
241
+ throw new Error('TargetId not found');
242
242
  }
243
243
  return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
244
244
  });
@@ -1,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Airtop from "../index";
5
- /**
6
- * Configuration for a single custom proxy.
7
- */
8
- export declare type CustomProxy =
9
- /**
10
- * url of the proxy. Or "default" to use airtop provided proxy. */
11
- string
12
- /**
13
- * Proxy object with url of the proxy as a parameter. Takes optional username and password. */
14
- | Airtop.Proxy;
@@ -1,12 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Airtop from "../index";
5
- /**
6
- * You can set multiple proxies. You associate each proxy with a domain pattern. If the domain matches the pattern, the proxy is used. Pattern can contain '?' to match any single character, and '*' to match any sequence of characters. For example, '*.example.com' will match 'www.example.com' and 'sub.example.com'
7
- */
8
- export interface SessionConfigV1ProxyItem {
9
- domainPattern: string;
10
- /** Configuration for a single custom proxy. */
11
- relay: Airtop.CustomProxy;
12
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Airtop from "../index";
5
- /**
6
- * Configuration for a single custom proxy.
7
- */
8
- export declare type CustomProxy =
9
- /**
10
- * url of the proxy. Or "default" to use airtop provided proxy. */
11
- string
12
- /**
13
- * Proxy object with url of the proxy as a parameter. Takes optional username and password. */
14
- | Airtop.Proxy;
@@ -1,12 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Airtop from "../index";
5
- /**
6
- * You can set multiple proxies. You associate each proxy with a domain pattern. If the domain matches the pattern, the proxy is used. Pattern can contain '?' to match any single character, and '*' to match any sequence of characters. For example, '*.example.com' will match 'www.example.com' and 'sub.example.com'
7
- */
8
- export interface SessionConfigV1ProxyItem {
9
- domainPattern: string;
10
- /** Configuration for a single custom proxy. */
11
- relay: Airtop.CustomProxy;
12
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../index";
5
- import * as Airtop from "../../api/index";
6
- import * as core from "../../core";
7
- import { Proxy } from "./Proxy";
8
- export declare const CustomProxy: core.serialization.Schema<serializers.CustomProxy.Raw, Airtop.CustomProxy>;
9
- export declare namespace CustomProxy {
10
- type Raw = string | Proxy.Raw;
11
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../index";
5
- import * as Airtop from "../../api/index";
6
- import * as core from "../../core";
7
- import { CustomProxy } from "./CustomProxy";
8
- export declare const SessionConfigV1ProxyItem: core.serialization.ObjectSchema<serializers.SessionConfigV1ProxyItem.Raw, Airtop.SessionConfigV1ProxyItem>;
9
- export declare namespace SessionConfigV1ProxyItem {
10
- interface Raw {
11
- domainPattern: string;
12
- relay: CustomProxy.Raw;
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../index";
5
- import * as Airtop from "../../api/index";
6
- import * as core from "../../core";
7
- import { Proxy } from "./Proxy";
8
- export declare const CustomProxy: core.serialization.Schema<serializers.CustomProxy.Raw, Airtop.CustomProxy>;
9
- export declare namespace CustomProxy {
10
- type Raw = string | Proxy.Raw;
11
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../index";
5
- import * as Airtop from "../../api/index";
6
- import * as core from "../../core";
7
- import { CustomProxy } from "./CustomProxy";
8
- export declare const SessionConfigV1ProxyItem: core.serialization.ObjectSchema<serializers.SessionConfigV1ProxyItem.Raw, Airtop.SessionConfigV1ProxyItem>;
9
- export declare namespace SessionConfigV1ProxyItem {
10
- interface Raw {
11
- domainPattern: string;
12
- relay: CustomProxy.Raw;
13
- }
14
- }