@airtop/sdk 0.1.36-beta0 → 0.1.37-beta0
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/api/resources/automations/client/Client.js +4 -4
- package/api/resources/files/client/Client.js +4 -4
- package/api/resources/files/client/requests/CreateFileRestInputV1.d.ts +0 -2
- package/api/resources/profiles/client/Client.js +1 -1
- package/api/resources/requests/client/Client.js +1 -1
- package/api/resources/sessions/client/Client.js +6 -6
- package/api/resources/sessions/types/SessionsEventsResponse.d.ts +4 -1
- package/api/resources/sessions/types/SessionsEventsResponseFileEvent.d.ts +11 -0
- package/api/resources/sessions/types/SessionsEventsResponseFileEvent.js +5 -0
- package/api/resources/sessions/types/index.d.ts +1 -0
- package/api/resources/sessions/types/index.js +1 -0
- package/api/resources/windows/client/Client.d.ts +14 -0
- package/api/resources/windows/client/Client.js +87 -30
- package/api/resources/windows/client/requests/OperatorPromptV1Body.d.ts +25 -0
- package/api/resources/windows/client/requests/OperatorPromptV1Body.js +5 -0
- package/api/resources/windows/client/requests/index.d.ts +1 -0
- package/api/types/AsyncOperatorPromptResponseEnvelope.d.ts +9 -0
- package/api/types/AsyncOperatorPromptResponseEnvelope.js +5 -0
- package/api/types/CreateFileV1.d.ts +2 -2
- package/api/types/CreateFileV1Status.d.ts +13 -0
- package/api/types/CreateFileV1Status.js +12 -0
- package/api/types/ExternalFile.d.ts +2 -0
- package/api/types/FileEventMessage.d.ts +14 -0
- package/api/types/FileEventMessage.js +5 -0
- package/api/types/FileEventMessageStatus.d.ts +13 -0
- package/api/types/FileEventMessageStatus.js +12 -0
- package/api/types/GetFileV1.d.ts +4 -2
- package/api/types/GetFileV1Status.d.ts +13 -0
- package/api/types/GetFileV1Status.js +12 -0
- package/api/types/index.d.ts +5 -0
- package/api/types/index.js +5 -0
- package/dist/api/resources/automations/client/Client.js +4 -4
- package/dist/api/resources/files/client/Client.js +4 -4
- package/dist/api/resources/files/client/requests/CreateFileRestInputV1.d.ts +0 -2
- package/dist/api/resources/profiles/client/Client.js +1 -1
- package/dist/api/resources/requests/client/Client.js +1 -1
- package/dist/api/resources/sessions/client/Client.js +6 -6
- package/dist/api/resources/sessions/types/SessionsEventsResponse.d.ts +4 -1
- package/dist/api/resources/sessions/types/SessionsEventsResponseFileEvent.d.ts +11 -0
- package/dist/api/resources/sessions/types/SessionsEventsResponseFileEvent.js +5 -0
- package/dist/api/resources/sessions/types/index.d.ts +1 -0
- package/dist/api/resources/sessions/types/index.js +1 -0
- package/dist/api/resources/windows/client/Client.d.ts +14 -0
- package/dist/api/resources/windows/client/Client.js +87 -30
- package/dist/api/resources/windows/client/requests/OperatorPromptV1Body.d.ts +25 -0
- package/dist/api/resources/windows/client/requests/OperatorPromptV1Body.js +5 -0
- package/dist/api/resources/windows/client/requests/index.d.ts +1 -0
- package/dist/api/types/AsyncOperatorPromptResponseEnvelope.d.ts +9 -0
- package/dist/api/types/AsyncOperatorPromptResponseEnvelope.js +5 -0
- package/dist/api/types/CreateFileV1.d.ts +2 -2
- package/dist/api/types/CreateFileV1Status.d.ts +13 -0
- package/dist/api/types/CreateFileV1Status.js +12 -0
- package/dist/api/types/ExternalFile.d.ts +2 -0
- package/dist/api/types/FileEventMessage.d.ts +14 -0
- package/dist/api/types/FileEventMessage.js +5 -0
- package/dist/api/types/FileEventMessageStatus.d.ts +13 -0
- package/dist/api/types/FileEventMessageStatus.js +12 -0
- package/dist/api/types/GetFileV1.d.ts +4 -2
- package/dist/api/types/GetFileV1Status.d.ts +13 -0
- package/dist/api/types/GetFileV1Status.js +12 -0
- package/dist/api/types/index.d.ts +5 -0
- package/dist/api/types/index.js +5 -0
- package/dist/serialization/resources/files/client/requests/CreateFileRestInputV1.d.ts +0 -1
- package/dist/serialization/resources/files/client/requests/CreateFileRestInputV1.js +0 -1
- package/dist/serialization/resources/sessions/types/SessionsEventsResponse.d.ts +5 -1
- package/dist/serialization/resources/sessions/types/SessionsEventsResponse.js +2 -0
- package/dist/serialization/resources/sessions/types/SessionsEventsResponseFileEvent.d.ts +15 -0
- package/dist/serialization/resources/sessions/types/SessionsEventsResponseFileEvent.js +46 -0
- package/dist/serialization/resources/sessions/types/index.d.ts +1 -0
- package/dist/serialization/resources/sessions/types/index.js +1 -0
- package/dist/serialization/resources/windows/client/requests/OperatorPromptV1Body.d.ts +17 -0
- package/dist/serialization/resources/windows/client/requests/OperatorPromptV1Body.js +48 -0
- package/dist/serialization/resources/windows/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/windows/client/requests/index.js +3 -1
- package/dist/serialization/types/AsyncOperatorPromptResponseEnvelope.d.ts +15 -0
- package/dist/serialization/types/AsyncOperatorPromptResponseEnvelope.js +46 -0
- package/dist/serialization/types/CreateFileV1.d.ts +2 -1
- package/dist/serialization/types/CreateFileV1.js +2 -1
- package/dist/serialization/types/CreateFileV1Status.d.ts +10 -0
- package/dist/serialization/types/CreateFileV1Status.js +41 -0
- package/dist/serialization/types/ExternalFile.d.ts +1 -0
- package/dist/serialization/types/ExternalFile.js +1 -0
- package/dist/serialization/types/FileEventMessage.d.ts +16 -0
- package/dist/serialization/types/FileEventMessage.js +47 -0
- package/dist/serialization/types/FileEventMessageStatus.d.ts +10 -0
- package/dist/serialization/types/FileEventMessageStatus.js +41 -0
- package/dist/serialization/types/GetFileV1.d.ts +3 -1
- package/dist/serialization/types/GetFileV1.js +3 -1
- package/dist/serialization/types/GetFileV1Status.d.ts +10 -0
- package/dist/serialization/types/GetFileV1Status.js +41 -0
- package/dist/serialization/types/index.d.ts +5 -0
- package/dist/serialization/types/index.js +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wrapper/AirtopFiles.d.ts +12 -0
- package/dist/wrapper/AirtopFiles.js +31 -2
- package/dist/wrapper/AirtopRequests.js +1 -1
- package/dist/wrapper/AirtopSessions.d.ts +39 -0
- package/dist/wrapper/AirtopSessions.js +219 -17
- package/dist/wrapper/AirtopWindows.d.ts +26 -0
- package/dist/wrapper/AirtopWindows.js +40 -0
- package/package.json +1 -1
- package/reference.md +81 -0
- package/serialization/resources/files/client/requests/CreateFileRestInputV1.d.ts +0 -1
- package/serialization/resources/files/client/requests/CreateFileRestInputV1.js +0 -1
- package/serialization/resources/sessions/types/SessionsEventsResponse.d.ts +5 -1
- package/serialization/resources/sessions/types/SessionsEventsResponse.js +2 -0
- package/serialization/resources/sessions/types/SessionsEventsResponseFileEvent.d.ts +15 -0
- package/serialization/resources/sessions/types/SessionsEventsResponseFileEvent.js +46 -0
- package/serialization/resources/sessions/types/index.d.ts +1 -0
- package/serialization/resources/sessions/types/index.js +1 -0
- package/serialization/resources/windows/client/requests/OperatorPromptV1Body.d.ts +17 -0
- package/serialization/resources/windows/client/requests/OperatorPromptV1Body.js +48 -0
- package/serialization/resources/windows/client/requests/index.d.ts +1 -0
- package/serialization/resources/windows/client/requests/index.js +3 -1
- package/serialization/types/AsyncOperatorPromptResponseEnvelope.d.ts +15 -0
- package/serialization/types/AsyncOperatorPromptResponseEnvelope.js +46 -0
- package/serialization/types/CreateFileV1.d.ts +2 -1
- package/serialization/types/CreateFileV1.js +2 -1
- package/serialization/types/CreateFileV1Status.d.ts +10 -0
- package/serialization/types/CreateFileV1Status.js +41 -0
- package/serialization/types/ExternalFile.d.ts +1 -0
- package/serialization/types/ExternalFile.js +1 -0
- package/serialization/types/FileEventMessage.d.ts +16 -0
- package/serialization/types/FileEventMessage.js +47 -0
- package/serialization/types/FileEventMessageStatus.d.ts +10 -0
- package/serialization/types/FileEventMessageStatus.js +41 -0
- package/serialization/types/GetFileV1.d.ts +3 -1
- package/serialization/types/GetFileV1.js +3 -1
- package/serialization/types/GetFileV1Status.d.ts +10 -0
- package/serialization/types/GetFileV1Status.js +41 -0
- package/serialization/types/index.d.ts +5 -0
- package/serialization/types/index.js +5 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/AirtopFiles.d.ts +12 -0
- package/wrapper/AirtopFiles.js +31 -2
- package/wrapper/AirtopRequests.js +1 -1
- package/wrapper/AirtopSessions.d.ts +39 -0
- package/wrapper/AirtopSessions.js +219 -17
- package/wrapper/AirtopWindows.d.ts +26 -0
- package/wrapper/AirtopWindows.js +40 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
4
|
+
*/
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
10
|
+
}
|
11
|
+
Object.defineProperty(o, k2, desc);
|
12
|
+
}) : (function(o, m, k, k2) {
|
13
|
+
if (k2 === undefined) k2 = k;
|
14
|
+
o[k2] = m[k];
|
15
|
+
}));
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
18
|
+
}) : function(o, v) {
|
19
|
+
o["default"] = v;
|
20
|
+
});
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
22
|
+
var ownKeys = function(o) {
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
24
|
+
var ar = [];
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
26
|
+
return ar;
|
27
|
+
};
|
28
|
+
return ownKeys(o);
|
29
|
+
};
|
30
|
+
return function (mod) {
|
31
|
+
if (mod && mod.__esModule) return mod;
|
32
|
+
var result = {};
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
34
|
+
__setModuleDefault(result, mod);
|
35
|
+
return result;
|
36
|
+
};
|
37
|
+
})();
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
exports.GetFileV1Status = void 0;
|
40
|
+
const core = __importStar(require("../../core"));
|
41
|
+
exports.GetFileV1Status = core.serialization.enum_(["available", "uploading", "upload_failed", "deleted"]);
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export * from "./AiPromptResponse";
|
2
2
|
export * from "./AiResponseEnvelope";
|
3
3
|
export * from "./AsyncConfig";
|
4
|
+
export * from "./AsyncOperatorPromptResponseEnvelope";
|
4
5
|
export * from "./AsyncSessionAiResponseEnvelope";
|
5
6
|
export * from "./AutomationOutput";
|
6
7
|
export * from "./BrowserWaitNavigationConfigWaitUntil";
|
@@ -10,6 +11,7 @@ export * from "./ClickConfig";
|
|
10
11
|
export * from "./ClientProvidedResponseMetadata";
|
11
12
|
export * from "./CreateAutomationRequestBodyConfiguration";
|
12
13
|
export * from "./CreateFileV1FileType";
|
14
|
+
export * from "./CreateFileV1Status";
|
13
15
|
export * from "./CreateFileV1";
|
14
16
|
export * from "./DeleteAutomationOutputWrapperBody";
|
15
17
|
export * from "./EnvelopeCreateFileV1EnvelopeDefaultMeta";
|
@@ -25,9 +27,12 @@ export * from "./ExternalSessionAiResponseMetadata";
|
|
25
27
|
export * from "./ExternalSessionAiResponseMetadataUsage";
|
26
28
|
export * from "./ExternalSessionConfig";
|
27
29
|
export * from "./ExternalSessionWithConnectionInfo";
|
30
|
+
export * from "./FileEventMessageStatus";
|
31
|
+
export * from "./FileEventMessage";
|
28
32
|
export * from "./FilesResponse";
|
29
33
|
export * from "./FilesWithPagination";
|
30
34
|
export * from "./GetFileV1FileType";
|
35
|
+
export * from "./GetFileV1Status";
|
31
36
|
export * from "./GetFileV1";
|
32
37
|
export * from "./IntervalMonitorConfig";
|
33
38
|
export * from "./Issue";
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AiPromptResponse"), exports);
|
18
18
|
__exportStar(require("./AiResponseEnvelope"), exports);
|
19
19
|
__exportStar(require("./AsyncConfig"), exports);
|
20
|
+
__exportStar(require("./AsyncOperatorPromptResponseEnvelope"), exports);
|
20
21
|
__exportStar(require("./AsyncSessionAiResponseEnvelope"), exports);
|
21
22
|
__exportStar(require("./AutomationOutput"), exports);
|
22
23
|
__exportStar(require("./BrowserWaitNavigationConfigWaitUntil"), exports);
|
@@ -26,6 +27,7 @@ __exportStar(require("./ClickConfig"), exports);
|
|
26
27
|
__exportStar(require("./ClientProvidedResponseMetadata"), exports);
|
27
28
|
__exportStar(require("./CreateAutomationRequestBodyConfiguration"), exports);
|
28
29
|
__exportStar(require("./CreateFileV1FileType"), exports);
|
30
|
+
__exportStar(require("./CreateFileV1Status"), exports);
|
29
31
|
__exportStar(require("./CreateFileV1"), exports);
|
30
32
|
__exportStar(require("./DeleteAutomationOutputWrapperBody"), exports);
|
31
33
|
__exportStar(require("./EnvelopeCreateFileV1EnvelopeDefaultMeta"), exports);
|
@@ -41,9 +43,12 @@ __exportStar(require("./ExternalSessionAiResponseMetadata"), exports);
|
|
41
43
|
__exportStar(require("./ExternalSessionAiResponseMetadataUsage"), exports);
|
42
44
|
__exportStar(require("./ExternalSessionConfig"), exports);
|
43
45
|
__exportStar(require("./ExternalSessionWithConnectionInfo"), exports);
|
46
|
+
__exportStar(require("./FileEventMessageStatus"), exports);
|
47
|
+
__exportStar(require("./FileEventMessage"), exports);
|
44
48
|
__exportStar(require("./FilesResponse"), exports);
|
45
49
|
__exportStar(require("./FilesWithPagination"), exports);
|
46
50
|
__exportStar(require("./GetFileV1FileType"), exports);
|
51
|
+
__exportStar(require("./GetFileV1Status"), exports);
|
47
52
|
__exportStar(require("./GetFileV1"), exports);
|
48
53
|
__exportStar(require("./IntervalMonitorConfig"), exports);
|
49
54
|
__exportStar(require("./Issue"), exports);
|
package/dist/version.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
1
|
+
export declare const SDK_VERSION = "0.1.37-beta0";
|
package/dist/version.js
CHANGED
@@ -35,4 +35,16 @@ export declare class AirtopFiles extends FilesClass {
|
|
35
35
|
* )
|
36
36
|
*/
|
37
37
|
download(fileId: string, destinationPath: string, onProgress?: (downloadedBytes: number, totalBytes: number) => void, options?: FilesNamespace.RequestOptions): Promise<void>;
|
38
|
+
/**
|
39
|
+
* Waits for a file to become available for download
|
40
|
+
*
|
41
|
+
* @param fileId - The ID of the file to wait for
|
42
|
+
* @param options - Optional request configuration including timeout
|
43
|
+
* @returns The file entry once it becomes available
|
44
|
+
* @throws Error if the file doesn't become available within the timeout period
|
45
|
+
*
|
46
|
+
* @example
|
47
|
+
* const fileEntry = await client.files.waitForDownloadAvailable("123e4567-e89b-12d3-a456-426614174000")
|
48
|
+
*/
|
49
|
+
waitForDownloadAvailable(fileId: string, options?: FilesNamespace.RequestOptions): Promise<Airtop.EnvelopeGetFileV1EnvelopeDefaultMeta>;
|
38
50
|
}
|
@@ -126,6 +126,7 @@ class AirtopFiles extends Client_1.Files {
|
|
126
126
|
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
127
127
|
const fileStream = fs.createWriteStream(destinationPath);
|
128
128
|
yield new Promise((resolve, reject) => {
|
129
|
+
var _a, _b;
|
129
130
|
if (onProgress && downloadResponse.body) {
|
130
131
|
// Create a transform stream to track progress
|
131
132
|
const progressStream = new readable_stream_1.Transform({
|
@@ -140,12 +141,40 @@ class AirtopFiles extends Client_1.Files {
|
|
140
141
|
}
|
141
142
|
else {
|
142
143
|
// If no progress callback, pipe directly
|
143
|
-
downloadResponse.body.pipe(fileStream);
|
144
|
+
(_a = downloadResponse.body) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
|
144
145
|
}
|
145
|
-
downloadResponse.body.on('error', reject);
|
146
|
+
(_b = downloadResponse.body) === null || _b === void 0 ? void 0 : _b.on('error', reject);
|
146
147
|
fileStream.on('finish', resolve);
|
147
148
|
});
|
148
149
|
});
|
149
150
|
}
|
151
|
+
/**
|
152
|
+
* Waits for a file to become available for download
|
153
|
+
*
|
154
|
+
* @param fileId - The ID of the file to wait for
|
155
|
+
* @param options - Optional request configuration including timeout
|
156
|
+
* @returns The file entry once it becomes available
|
157
|
+
* @throws Error if the file doesn't become available within the timeout period
|
158
|
+
*
|
159
|
+
* @example
|
160
|
+
* const fileEntry = await client.files.waitForDownloadAvailable("123e4567-e89b-12d3-a456-426614174000")
|
161
|
+
*/
|
162
|
+
waitForDownloadAvailable(fileId, options) {
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
164
|
+
const timeoutSeconds = (options === null || options === void 0 ? void 0 : options.timeoutInSeconds) || 120;
|
165
|
+
const intervalMs = 5000; // 5 seconds
|
166
|
+
const startTime = Date.now();
|
167
|
+
while (Date.now() - startTime < timeoutSeconds * 1000) {
|
168
|
+
const fileEntry = yield this.get(fileId, options);
|
169
|
+
// Check if the file has a valid download URL and size, which indicates it's available
|
170
|
+
if (fileEntry.data.downloadUrl && fileEntry.data.fileBytes > 0) {
|
171
|
+
return fileEntry;
|
172
|
+
}
|
173
|
+
// Wait before checking again
|
174
|
+
yield new Promise((resolve) => setTimeout(resolve, intervalMs));
|
175
|
+
}
|
176
|
+
throw new Error(`Timeout waiting for file ${fileId} to become available`);
|
177
|
+
});
|
178
|
+
}
|
150
179
|
}
|
151
180
|
exports.AirtopFiles = AirtopFiles;
|
@@ -36,7 +36,7 @@ class AirtopRequests extends Client_1.Requests {
|
|
36
36
|
const timeoutMs = timeoutSeconds * 1000;
|
37
37
|
while (Date.now() - startTime < timeoutMs) {
|
38
38
|
const response = yield this.getRequestStatus(requestId, requestOptions);
|
39
|
-
if (response.status === 'completed' || response.status === '
|
39
|
+
if (response.status === 'completed' || response.status === 'error') {
|
40
40
|
return response;
|
41
41
|
}
|
42
42
|
yield new Promise((resolve) => setTimeout(resolve, intervalSeconds * 1000));
|
@@ -20,5 +20,44 @@ export declare class AirtopSessions extends SessionsClass {
|
|
20
20
|
* await client.sessions.create()
|
21
21
|
*/
|
22
22
|
create(request?: AirtopSessionRestInputV1, requestOptions?: SessionsNamespace.RequestOptions): Promise<Airtop.SessionResponse>;
|
23
|
+
/**
|
24
|
+
* Waits for a session to enter the 'running' status
|
25
|
+
*
|
26
|
+
* @param id - The ID of the session to wait for
|
27
|
+
* @param requestOptions - Optional request configuration including timeout
|
28
|
+
* @returns The session event indicating the session is ready, or null if timed out
|
29
|
+
*/
|
23
30
|
waitForSessionReady(id: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<Airtop.SessionsEventsResponse | null>;
|
31
|
+
/**
|
32
|
+
* Waits for a file to be downloaded in a session and reach 'available' status
|
33
|
+
*
|
34
|
+
* @param sessionId - The ID of the session to monitor
|
35
|
+
* @param requestOptions - Optional request configuration including timeout
|
36
|
+
* @returns Object containing file's id and downloadUrl, or null if timed out
|
37
|
+
*/
|
38
|
+
waitForDownload(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
|
39
|
+
id: string;
|
40
|
+
downloadUrl: string;
|
41
|
+
} | null>;
|
42
|
+
/**
|
43
|
+
* Waits for a file download to start in a session
|
44
|
+
*
|
45
|
+
* @param sessionId - The ID of the session to monitor
|
46
|
+
* @param requestOptions - Optional request configuration including timeout
|
47
|
+
* @returns Object containing file's id and downloadUrl, or null if timed out
|
48
|
+
*/
|
49
|
+
waitForDownloadStart(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
|
50
|
+
id: string;
|
51
|
+
downloadUrl: string;
|
52
|
+
} | null>;
|
53
|
+
/**
|
54
|
+
* Downloads the next file from a session as soon as it starts to become available
|
55
|
+
*
|
56
|
+
* @param sessionId - The ID of the session to download from
|
57
|
+
* @param destinationPath - The local path where the file should be saved
|
58
|
+
* @param onProgress - Optional callback to track download progress
|
59
|
+
* @param requestOptions - Optional request configuration including timeout
|
60
|
+
* @throws Error if no file is available to download within the timeout period
|
61
|
+
*/
|
62
|
+
downloadNextFile(sessionId: string, destinationPath: string, onProgress?: (downloadedBytes: number, totalBytes: number) => void, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
|
24
63
|
}
|
@@ -1,4 +1,37 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -15,9 +48,16 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
15
48
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
16
49
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
17
50
|
};
|
51
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
52
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
53
|
+
};
|
18
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
19
55
|
exports.AirtopSessions = void 0;
|
56
|
+
const readable_stream_1 = require("readable-stream");
|
57
|
+
const fs = __importStar(require("fs"));
|
58
|
+
const path = __importStar(require("path"));
|
20
59
|
const Client_1 = require("../api/resources/sessions/client/Client");
|
60
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
21
61
|
class AirtopSessions extends Client_1.Sessions {
|
22
62
|
constructor(_options, debug = false) {
|
23
63
|
super(_options);
|
@@ -66,30 +106,192 @@ class AirtopSessions extends Client_1.Sessions {
|
|
66
106
|
}
|
67
107
|
});
|
68
108
|
}
|
109
|
+
/**
|
110
|
+
* Waits for a session to enter the 'running' status
|
111
|
+
*
|
112
|
+
* @param id - The ID of the session to wait for
|
113
|
+
* @param requestOptions - Optional request configuration including timeout
|
114
|
+
* @returns The session event indicating the session is ready, or null if timed out
|
115
|
+
*/
|
69
116
|
waitForSessionReady(id, requestOptions) {
|
70
117
|
return __awaiter(this, void 0, void 0, function* () {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
118
|
+
const timeoutSeconds = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) || 300;
|
119
|
+
// Create a promise that resolves to null after the timeout
|
120
|
+
const timeoutPromise = new Promise((resolve) => {
|
121
|
+
setTimeout(() => resolve(null), timeoutSeconds * 1000);
|
122
|
+
});
|
123
|
+
// Create a promise for the event processing
|
124
|
+
const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
125
|
+
var _a, e_1, _b, _c;
|
126
|
+
const sessionEvents = yield this.events(id, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
|
127
|
+
try {
|
128
|
+
for (var _d = true, sessionEvents_1 = __asyncValues(sessionEvents), sessionEvents_1_1; sessionEvents_1_1 = yield sessionEvents_1.next(), _a = sessionEvents_1_1.done, !_a; _d = true) {
|
129
|
+
_c = sessionEvents_1_1.value;
|
130
|
+
_d = false;
|
131
|
+
const event = _c;
|
132
|
+
const e = event;
|
133
|
+
if (e.event === 'status') {
|
134
|
+
this.log(`status message received:\n${JSON.stringify(event, null, 2)}`);
|
135
|
+
if (e.status === 'running') {
|
136
|
+
return event;
|
137
|
+
}
|
138
|
+
}
|
82
139
|
}
|
83
140
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
141
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
142
|
+
finally {
|
143
|
+
try {
|
144
|
+
if (!_d && !_a && (_b = sessionEvents_1.return)) yield _b.call(sessionEvents_1);
|
145
|
+
}
|
146
|
+
finally { if (e_1) throw e_1.error; }
|
147
|
+
}
|
148
|
+
return null;
|
149
|
+
}))();
|
150
|
+
// Race the timeout against the event processing
|
151
|
+
return Promise.race([timeoutPromise, processEventsPromise]);
|
152
|
+
});
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Waits for a file to be downloaded in a session and reach 'available' status
|
156
|
+
*
|
157
|
+
* @param sessionId - The ID of the session to monitor
|
158
|
+
* @param requestOptions - Optional request configuration including timeout
|
159
|
+
* @returns Object containing file's id and downloadUrl, or null if timed out
|
160
|
+
*/
|
161
|
+
waitForDownload(sessionId, requestOptions) {
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
163
|
+
const timeoutSeconds = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) || 120;
|
164
|
+
// Create a promise that resolves to null after the timeout
|
165
|
+
const timeoutPromise = new Promise((resolve) => {
|
166
|
+
setTimeout(() => resolve(null), timeoutSeconds * 1000);
|
167
|
+
});
|
168
|
+
// Create a promise for the event processing
|
169
|
+
const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
170
|
+
var _a, e_2, _b, _c;
|
171
|
+
const sessionEvents = yield this.events(sessionId, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
|
172
|
+
try {
|
173
|
+
for (var _d = true, sessionEvents_2 = __asyncValues(sessionEvents), sessionEvents_2_1; sessionEvents_2_1 = yield sessionEvents_2.next(), _a = sessionEvents_2_1.done, !_a; _d = true) {
|
174
|
+
_c = sessionEvents_2_1.value;
|
175
|
+
_d = false;
|
176
|
+
const event = _c;
|
177
|
+
const e = event;
|
178
|
+
if (e.event === 'file_status') {
|
179
|
+
this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
|
180
|
+
if (e.status === 'available') {
|
181
|
+
return {
|
182
|
+
id: e.fileId,
|
183
|
+
downloadUrl: e.downloadUrl,
|
184
|
+
};
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
190
|
+
finally {
|
191
|
+
try {
|
192
|
+
if (!_d && !_a && (_b = sessionEvents_2.return)) yield _b.call(sessionEvents_2);
|
193
|
+
}
|
194
|
+
finally { if (e_2) throw e_2.error; }
|
195
|
+
}
|
196
|
+
return null;
|
197
|
+
}))();
|
198
|
+
// Race the timeout against the event processing
|
199
|
+
return Promise.race([timeoutPromise, processEventsPromise]);
|
200
|
+
});
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Waits for a file download to start in a session
|
204
|
+
*
|
205
|
+
* @param sessionId - The ID of the session to monitor
|
206
|
+
* @param requestOptions - Optional request configuration including timeout
|
207
|
+
* @returns Object containing file's id and downloadUrl, or null if timed out
|
208
|
+
*/
|
209
|
+
waitForDownloadStart(sessionId, requestOptions) {
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
211
|
+
const timeoutSeconds = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) || 60;
|
212
|
+
// Create a promise that resolves to null after the timeout
|
213
|
+
const timeoutPromise = new Promise((resolve) => {
|
214
|
+
setTimeout(() => resolve(null), timeoutSeconds * 1000);
|
215
|
+
});
|
216
|
+
// Create a promise for the event processing
|
217
|
+
const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
218
|
+
var _a, e_3, _b, _c;
|
219
|
+
const sessionEvents = yield this.events(sessionId, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
|
87
220
|
try {
|
88
|
-
|
221
|
+
for (var _d = true, sessionEvents_3 = __asyncValues(sessionEvents), sessionEvents_3_1; sessionEvents_3_1 = yield sessionEvents_3.next(), _a = sessionEvents_3_1.done, !_a; _d = true) {
|
222
|
+
_c = sessionEvents_3_1.value;
|
223
|
+
_d = false;
|
224
|
+
const event = _c;
|
225
|
+
const e = event;
|
226
|
+
if (e.event === 'file_status') {
|
227
|
+
this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
|
228
|
+
if (e.status === 'uploading') {
|
229
|
+
return {
|
230
|
+
id: e.fileId,
|
231
|
+
downloadUrl: e.downloadUrl,
|
232
|
+
};
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
}
|
237
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
238
|
+
finally {
|
239
|
+
try {
|
240
|
+
if (!_d && !_a && (_b = sessionEvents_3.return)) yield _b.call(sessionEvents_3);
|
241
|
+
}
|
242
|
+
finally { if (e_3) throw e_3.error; }
|
89
243
|
}
|
90
|
-
|
244
|
+
return null;
|
245
|
+
}))();
|
246
|
+
// Race the timeout against the event processing
|
247
|
+
return Promise.race([timeoutPromise, processEventsPromise]);
|
248
|
+
});
|
249
|
+
}
|
250
|
+
/**
|
251
|
+
* Downloads the next file from a session as soon as it starts to become available
|
252
|
+
*
|
253
|
+
* @param sessionId - The ID of the session to download from
|
254
|
+
* @param destinationPath - The local path where the file should be saved
|
255
|
+
* @param onProgress - Optional callback to track download progress
|
256
|
+
* @param requestOptions - Optional request configuration including timeout
|
257
|
+
* @throws Error if no file is available to download within the timeout period
|
258
|
+
*/
|
259
|
+
downloadNextFile(sessionId, destinationPath, onProgress, requestOptions) {
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
261
|
+
var _a;
|
262
|
+
const nextFile = yield this.waitForDownload(sessionId, requestOptions);
|
263
|
+
if (!nextFile) {
|
264
|
+
throw new Error('No file to download within timeout');
|
265
|
+
}
|
266
|
+
const downloadResponse = yield (0, node_fetch_1.default)(nextFile.downloadUrl);
|
267
|
+
if (!downloadResponse.ok) {
|
268
|
+
throw new Error(`Failed to download file: ${downloadResponse.statusText}`);
|
91
269
|
}
|
92
|
-
|
270
|
+
const totalBytes = Number.parseInt((_a = downloadResponse.headers.get('content-length')) !== null && _a !== void 0 ? _a : '0', 10);
|
271
|
+
let downloadedBytes = 0;
|
272
|
+
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
273
|
+
const fileStream = fs.createWriteStream(destinationPath);
|
274
|
+
yield new Promise((resolve, reject) => {
|
275
|
+
var _a, _b;
|
276
|
+
if (onProgress && downloadResponse.body) {
|
277
|
+
// Create a transform stream to track progress
|
278
|
+
const progressStream = new readable_stream_1.Transform({
|
279
|
+
transform(chunk, encoding, callback) {
|
280
|
+
downloadedBytes += chunk.length;
|
281
|
+
onProgress(downloadedBytes, totalBytes);
|
282
|
+
callback(null, chunk);
|
283
|
+
},
|
284
|
+
});
|
285
|
+
downloadResponse.body.pipe(progressStream).pipe(fileStream);
|
286
|
+
progressStream.on('error', reject);
|
287
|
+
}
|
288
|
+
else {
|
289
|
+
// If no progress callback, pipe directly
|
290
|
+
(_a = downloadResponse.body) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
|
291
|
+
}
|
292
|
+
(_b = downloadResponse.body) === null || _b === void 0 ? void 0 : _b.on('error', reject);
|
293
|
+
fileStream.on('finish', resolve);
|
294
|
+
});
|
93
295
|
});
|
94
296
|
}
|
95
297
|
}
|
@@ -138,6 +138,32 @@ export declare class AirtopWindows extends WindowsClass {
|
|
138
138
|
* await client.windows.scroll("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430")
|
139
139
|
*/
|
140
140
|
scroll(sessionId: string, windowId: string, request?: Airtop.SessionScrollHandlerRequestBody, requestOptions?: Windows.RequestOptions): Promise<Airtop.AiPromptResponse>;
|
141
|
+
/**
|
142
|
+
* Fill a form of a browser window synchronously using a form-filler automation
|
143
|
+
*
|
144
|
+
* @param {string} sessionId - The session id for the window.
|
145
|
+
* @param {string} windowId - The Airtop window id of the browser window.
|
146
|
+
* @param {Airtop.FillFormRequest} request
|
147
|
+
* @param {Windows.RequestOptions} requestOptions - Request-specific configuration.
|
148
|
+
*
|
149
|
+
* @example
|
150
|
+
* await client.windows.fillForm("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430", {
|
151
|
+
* automationId: "automationId"
|
152
|
+
* })
|
153
|
+
*/
|
154
|
+
fillForm(sessionId: string, windowId: string, request: Airtop.FillFormRequest, requestOptions?: Windows.RequestOptions): Promise<Airtop.AiPromptResponse>;
|
155
|
+
/**
|
156
|
+
* Create a form-filler automation synchronously for the form loaded in the browser window
|
157
|
+
*
|
158
|
+
* @param {string} sessionId - The session id for the window.
|
159
|
+
* @param {string} windowId - The Airtop window id of the browser window.
|
160
|
+
* @param {Airtop.CreateFormFillerRequest} request
|
161
|
+
* @param {Windows.RequestOptions} requestOptions - Request-specific configuration.
|
162
|
+
*
|
163
|
+
* @example
|
164
|
+
* await client.windows.createFormFiller("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430")
|
165
|
+
*/
|
166
|
+
createFormFiller(sessionId: string, windowId: string, request?: Airtop.CreateFormFillerRequest, requestOptions?: Windows.RequestOptions): Promise<Airtop.AiPromptResponse>;
|
141
167
|
/**
|
142
168
|
* @param {string} sessionId - The session id for the window.
|
143
169
|
* @param {string} windowId - The Airtop window id of the browser window.
|
@@ -238,6 +238,46 @@ class AirtopWindows extends Client_1.Windows {
|
|
238
238
|
return _super.scroll.call(this, sessionId, windowId, request, Object.assign(Object.assign({ timeoutInSeconds: 600 }, requestOptions), { maxRetries: 0 }));
|
239
239
|
});
|
240
240
|
}
|
241
|
+
/**
|
242
|
+
* Fill a form of a browser window synchronously using a form-filler automation
|
243
|
+
*
|
244
|
+
* @param {string} sessionId - The session id for the window.
|
245
|
+
* @param {string} windowId - The Airtop window id of the browser window.
|
246
|
+
* @param {Airtop.FillFormRequest} request
|
247
|
+
* @param {Windows.RequestOptions} requestOptions - Request-specific configuration.
|
248
|
+
*
|
249
|
+
* @example
|
250
|
+
* await client.windows.fillForm("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430", {
|
251
|
+
* automationId: "automationId"
|
252
|
+
* })
|
253
|
+
*/
|
254
|
+
fillForm(sessionId, windowId, request, requestOptions) {
|
255
|
+
const _super = Object.create(null, {
|
256
|
+
fillForm: { get: () => super.fillForm }
|
257
|
+
});
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
259
|
+
return _super.fillForm.call(this, sessionId, windowId, request, Object.assign(Object.assign({ timeoutInSeconds: 600 }, requestOptions), { maxRetries: 0 }));
|
260
|
+
});
|
261
|
+
}
|
262
|
+
/**
|
263
|
+
* Create a form-filler automation synchronously for the form loaded in the browser window
|
264
|
+
*
|
265
|
+
* @param {string} sessionId - The session id for the window.
|
266
|
+
* @param {string} windowId - The Airtop window id of the browser window.
|
267
|
+
* @param {Airtop.CreateFormFillerRequest} request
|
268
|
+
* @param {Windows.RequestOptions} requestOptions - Request-specific configuration.
|
269
|
+
*
|
270
|
+
* @example
|
271
|
+
* await client.windows.createFormFiller("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430")
|
272
|
+
*/
|
273
|
+
createFormFiller(sessionId_1, windowId_1) {
|
274
|
+
const _super = Object.create(null, {
|
275
|
+
createFormFiller: { get: () => super.createFormFiller }
|
276
|
+
});
|
277
|
+
return __awaiter(this, arguments, void 0, function* (sessionId, windowId, request = {}, requestOptions) {
|
278
|
+
return _super.createFormFiller.call(this, sessionId, windowId, request, Object.assign(Object.assign({ timeoutInSeconds: 600 }, requestOptions), { maxRetries: 0 }));
|
279
|
+
});
|
280
|
+
}
|
241
281
|
/**
|
242
282
|
* @param {string} sessionId - The session id for the window.
|
243
283
|
* @param {string} windowId - The Airtop window id of the browser window.
|