@airtop/sdk 0.1.41 → 0.1.42
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 +5 -5
- package/api/resources/files/client/requests/CreateFileRestInputV1.d.ts +1 -1
- 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/windows/client/Client.d.ts +9 -5
- package/api/resources/windows/client/Client.js +32 -28
- package/api/resources/windows/client/requests/SessionFileInputHandlerRequestBody.d.ts +4 -4
- package/api/types/FileEventData.d.ts +7 -0
- package/api/types/FileEventData.js +5 -0
- package/api/types/FileEventMessage.d.ts +2 -1
- package/api/types/index.d.ts +1 -0
- package/api/types/index.js +1 -0
- package/dist/api/resources/automations/client/Client.js +4 -4
- package/dist/api/resources/files/client/Client.js +5 -5
- package/dist/api/resources/files/client/requests/CreateFileRestInputV1.d.ts +1 -1
- 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/windows/client/Client.d.ts +9 -5
- package/dist/api/resources/windows/client/Client.js +32 -28
- package/dist/api/resources/windows/client/requests/SessionFileInputHandlerRequestBody.d.ts +4 -4
- package/dist/api/types/FileEventData.d.ts +7 -0
- package/dist/api/types/FileEventData.js +5 -0
- package/dist/api/types/FileEventMessage.d.ts +2 -1
- package/dist/api/types/index.d.ts +1 -0
- package/dist/api/types/index.js +1 -0
- package/dist/serialization/resources/windows/client/requests/SessionFileInputHandlerRequestBody.d.ts +2 -1
- package/dist/serialization/resources/windows/client/requests/SessionFileInputHandlerRequestBody.js +2 -1
- package/dist/serialization/types/FileEventData.d.ts +13 -0
- package/dist/serialization/types/FileEventData.js +44 -0
- package/dist/serialization/types/FileEventMessage.d.ts +2 -1
- package/dist/serialization/types/FileEventMessage.js +2 -1
- package/dist/serialization/types/index.d.ts +1 -0
- package/dist/serialization/types/index.js +1 -0
- package/dist/utils/upload.js +12 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wrapper/AirtopSessions.js +12 -5
- package/package.json +1 -1
- package/reference.md +8 -4
- package/serialization/resources/windows/client/requests/SessionFileInputHandlerRequestBody.d.ts +2 -1
- package/serialization/resources/windows/client/requests/SessionFileInputHandlerRequestBody.js +2 -1
- package/serialization/types/FileEventData.d.ts +13 -0
- package/serialization/types/FileEventData.js +44 -0
- package/serialization/types/FileEventMessage.d.ts +2 -1
- package/serialization/types/FileEventMessage.js +2 -1
- package/serialization/types/index.d.ts +1 -0
- package/serialization/types/index.js +1 -0
- package/utils/upload.js +12 -7
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/AirtopSessions.js +12 -5
@@ -0,0 +1,13 @@
|
|
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
|
+
export declare const FileEventData: core.serialization.ObjectSchema<serializers.FileEventData.Raw, Airtop.FileEventData>;
|
8
|
+
export declare namespace FileEventData {
|
9
|
+
interface Raw {
|
10
|
+
error: string;
|
11
|
+
filePath: string;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,44 @@
|
|
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.FileEventData = void 0;
|
40
|
+
const core = __importStar(require("../../core"));
|
41
|
+
exports.FileEventData = core.serialization.object({
|
42
|
+
error: core.serialization.string(),
|
43
|
+
filePath: core.serialization.string(),
|
44
|
+
});
|
@@ -4,13 +4,14 @@
|
|
4
4
|
import * as serializers from "../index";
|
5
5
|
import * as Airtop from "../../api/index";
|
6
6
|
import * as core from "../../core";
|
7
|
+
import { FileEventData } from "./FileEventData";
|
7
8
|
import { FileEventMessageStatus } from "./FileEventMessageStatus";
|
8
9
|
export declare const FileEventMessage: core.serialization.ObjectSchema<serializers.FileEventMessage.Raw, Airtop.FileEventMessage>;
|
9
10
|
export declare namespace FileEventMessage {
|
10
11
|
interface Raw {
|
11
12
|
downloadUrl: string;
|
12
13
|
event: string;
|
13
|
-
eventData?:
|
14
|
+
eventData?: FileEventData.Raw | null;
|
14
15
|
eventTime: string;
|
15
16
|
fileId: string;
|
16
17
|
status: FileEventMessageStatus.Raw;
|
@@ -38,11 +38,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
39
|
exports.FileEventMessage = void 0;
|
40
40
|
const core = __importStar(require("../../core"));
|
41
|
+
const FileEventData_1 = require("./FileEventData");
|
41
42
|
const FileEventMessageStatus_1 = require("./FileEventMessageStatus");
|
42
43
|
exports.FileEventMessage = core.serialization.object({
|
43
44
|
downloadUrl: core.serialization.string(),
|
44
45
|
event: core.serialization.string(),
|
45
|
-
eventData:
|
46
|
+
eventData: FileEventData_1.FileEventData.optional(),
|
46
47
|
eventTime: core.serialization.date(),
|
47
48
|
fileId: core.serialization.string(),
|
48
49
|
status: FileEventMessageStatus_1.FileEventMessageStatus,
|
@@ -28,6 +28,7 @@ export * from "./ExternalSessionAiResponseMetadata";
|
|
28
28
|
export * from "./ExternalSessionAiResponseMetadataUsage";
|
29
29
|
export * from "./ExternalSessionConfig";
|
30
30
|
export * from "./ExternalSessionWithConnectionInfo";
|
31
|
+
export * from "./FileEventData";
|
31
32
|
export * from "./FileEventMessageStatus";
|
32
33
|
export * from "./FileEventMessage";
|
33
34
|
export * from "./FilesResponse";
|
@@ -44,6 +44,7 @@ __exportStar(require("./ExternalSessionAiResponseMetadata"), exports);
|
|
44
44
|
__exportStar(require("./ExternalSessionAiResponseMetadataUsage"), exports);
|
45
45
|
__exportStar(require("./ExternalSessionConfig"), exports);
|
46
46
|
__exportStar(require("./ExternalSessionWithConnectionInfo"), exports);
|
47
|
+
__exportStar(require("./FileEventData"), exports);
|
47
48
|
__exportStar(require("./FileEventMessageStatus"), exports);
|
48
49
|
__exportStar(require("./FileEventMessage"), exports);
|
49
50
|
__exportStar(require("./FilesResponse"), exports);
|
package/dist/utils/upload.js
CHANGED
@@ -8,16 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.uploadFileAndSelectInput = uploadFileAndSelectInput;
|
16
|
+
const path_1 = __importDefault(require("path"));
|
13
17
|
function uploadFileAndSelectInput(_a) {
|
14
18
|
return __awaiter(this, arguments, void 0, function* ({ client, sessionId, windowId, configuration, }) {
|
19
|
+
var _b;
|
15
20
|
const windowInfo = yield client.windows.getWindowInfo(sessionId, windowId);
|
16
21
|
if (!windowInfo) {
|
17
22
|
throw new Error('window not found');
|
18
23
|
}
|
19
24
|
client.log(`starting file upload: sessionId: ${sessionId}, windowId: ${windowId}, uploadFilePath: ${configuration.uploadFilePath}`);
|
20
|
-
const fileUploadResponse = yield client.files.upload(configuration.uploadFilePath
|
25
|
+
const fileUploadResponse = yield client.files.upload(configuration.uploadFilePath, {
|
26
|
+
fileName: (_b = configuration.fileName) !== null && _b !== void 0 ? _b : path_1.default.basename(configuration.uploadFilePath),
|
27
|
+
});
|
21
28
|
if (fileUploadResponse.errors && fileUploadResponse.errors.length > 0) {
|
22
29
|
client.log(`file upload failed: ${JSON.stringify(fileUploadResponse.errors)}`);
|
23
30
|
throw new Error('file upload failed');
|
@@ -28,7 +35,7 @@ function uploadFileAndSelectInput(_a) {
|
|
28
35
|
sessionIds: [sessionId],
|
29
36
|
});
|
30
37
|
client.log('file pushed to session');
|
31
|
-
client.log(
|
38
|
+
client.log(`waiting for file upload to become available ${fileId}`);
|
32
39
|
const waitResult = yield client.sessions.waitForUploadAvailable(sessionId, fileId);
|
33
40
|
if (waitResult) {
|
34
41
|
client.log('file upload available');
|
@@ -37,12 +44,10 @@ function uploadFileAndSelectInput(_a) {
|
|
37
44
|
client.log('file upload not available within timeout');
|
38
45
|
throw new Error('file upload not available within timeout');
|
39
46
|
}
|
40
|
-
client.log(
|
41
|
-
const fileInputResponse = yield client.windows.fileInput(sessionId, windowId, {
|
42
|
-
fileId: fileId,
|
43
|
-
elementDescription: configuration.elementDescription,
|
44
|
-
});
|
47
|
+
client.log(`executing file input interaction ${JSON.stringify(configuration)}`);
|
48
|
+
const fileInputResponse = yield client.windows.fileInput(sessionId, windowId, Object.assign({ fileId: fileId }, configuration));
|
45
49
|
if (fileInputResponse.errors && fileInputResponse.errors.length > 0) {
|
50
|
+
client.log(`file input failed: ${JSON.stringify(fileInputResponse.errors)}`);
|
46
51
|
throw new Error('file input failed');
|
47
52
|
}
|
48
53
|
client.log('file upload and file input interaction complete');
|
package/dist/version.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
1
|
+
export declare const SDK_VERSION = "0.1.42";
|
package/dist/version.js
CHANGED
@@ -336,6 +336,7 @@ class AirtopSessions extends Client_1.Sessions {
|
|
336
336
|
*/
|
337
337
|
waitForUploadAvailable(sessionId_1, fileId_1) {
|
338
338
|
return __awaiter(this, arguments, void 0, function* (sessionId, fileId, timeoutSeconds = 300) {
|
339
|
+
this.log(`waiting for uploaded file to be available on session: ${sessionId} ${fileId}`);
|
339
340
|
// Create a promise that resolves to null after the timeout
|
340
341
|
const timeoutPromise = new Promise((resolve) => {
|
341
342
|
setTimeout(() => resolve(null), timeoutSeconds * 1000);
|
@@ -351,9 +352,15 @@ class AirtopSessions extends Client_1.Sessions {
|
|
351
352
|
const event = _c;
|
352
353
|
const e = event;
|
353
354
|
if (e.event === 'file_upload_status') {
|
354
|
-
|
355
|
-
|
356
|
-
|
355
|
+
if (e.fileId === fileId) {
|
356
|
+
if (e.status === 'available') {
|
357
|
+
this.log(`uploaded file is now available on session: ${sessionId} ${fileId}`);
|
358
|
+
return event;
|
359
|
+
}
|
360
|
+
if (e.status === 'upload_failed') {
|
361
|
+
this.log(`upload failed: ${sessionId} ${fileId}`);
|
362
|
+
throw new Error(`upload failed: ${e.eventData.error}`);
|
363
|
+
}
|
357
364
|
}
|
358
365
|
}
|
359
366
|
}
|
@@ -409,7 +416,7 @@ class AirtopSessions extends Client_1.Sessions {
|
|
409
416
|
}
|
410
417
|
lastCallbackPromise = lastCallbackPromise
|
411
418
|
.then(() => callback(msg))
|
412
|
-
.catch(error => this.log(`Error in captcha callback: ${error}`));
|
419
|
+
.catch((error) => this.log(`Error in captcha callback: ${error}`));
|
413
420
|
}
|
414
421
|
}
|
415
422
|
}
|
@@ -420,7 +427,7 @@ class AirtopSessions extends Client_1.Sessions {
|
|
420
427
|
}
|
421
428
|
finally { if (e_5) throw e_5.error; }
|
422
429
|
}
|
423
|
-
}))().catch(error => {
|
430
|
+
}))().catch((error) => {
|
424
431
|
if (error.name !== 'AbortError') {
|
425
432
|
this.log(`Error in event processing: ${error}`);
|
426
433
|
}
|
package/package.json
CHANGED
package/reference.md
CHANGED
@@ -808,7 +808,13 @@ await client.windows.createFormFiller("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0
|
|
808
808
|
<dl>
|
809
809
|
<dd>
|
810
810
|
|
811
|
-
Execute a file input interaction in a specific browser window
|
811
|
+
Execute a file input interaction in a specific browser window.
|
812
|
+
includeHiddenElements defaults to true and considers hidden file input elements.
|
813
|
+
If there is only one file input element, it will be used directly.
|
814
|
+
If there are multiple file input elements, the elementDescription will be used by AI to
|
815
|
+
select among them.
|
816
|
+
If no file input elements are found by inspecting the page structure, elementDescription
|
817
|
+
will be used by AI to try to find a match visually.
|
812
818
|
|
813
819
|
</dd>
|
814
820
|
</dl>
|
@@ -824,9 +830,7 @@ Execute a file input interaction in a specific browser window
|
|
824
830
|
<dd>
|
825
831
|
|
826
832
|
```typescript
|
827
|
-
await client.windows.fileInput("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430"
|
828
|
-
elementDescription: "The file input in the bottom left corner",
|
829
|
-
});
|
833
|
+
await client.windows.fileInput("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430");
|
830
834
|
```
|
831
835
|
|
832
836
|
</dd>
|
package/serialization/resources/windows/client/requests/SessionFileInputHandlerRequestBody.d.ts
CHANGED
@@ -11,9 +11,10 @@ export declare namespace SessionFileInputHandlerRequestBody {
|
|
11
11
|
clientRequestId?: string | null;
|
12
12
|
configuration?: MicroInteractionConfigWithExperimental.Raw | null;
|
13
13
|
costThresholdCredits?: number | null;
|
14
|
-
elementDescription
|
14
|
+
elementDescription?: string | null;
|
15
15
|
fileId?: string | null;
|
16
16
|
fileName?: string | null;
|
17
|
+
includeHiddenElements?: boolean | null;
|
17
18
|
timeThresholdSeconds?: number | null;
|
18
19
|
waitForNavigation?: boolean | null;
|
19
20
|
}
|
package/serialization/resources/windows/client/requests/SessionFileInputHandlerRequestBody.js
CHANGED
@@ -43,9 +43,10 @@ exports.SessionFileInputHandlerRequestBody = core.serialization.object({
|
|
43
43
|
clientRequestId: core.serialization.string().optional(),
|
44
44
|
configuration: MicroInteractionConfigWithExperimental_1.MicroInteractionConfigWithExperimental.optional(),
|
45
45
|
costThresholdCredits: core.serialization.number().optional(),
|
46
|
-
elementDescription: core.serialization.string(),
|
46
|
+
elementDescription: core.serialization.string().optional(),
|
47
47
|
fileId: core.serialization.string().optional(),
|
48
48
|
fileName: core.serialization.string().optional(),
|
49
|
+
includeHiddenElements: core.serialization.boolean().optional(),
|
49
50
|
timeThresholdSeconds: core.serialization.number().optional(),
|
50
51
|
waitForNavigation: core.serialization.boolean().optional(),
|
51
52
|
});
|
@@ -0,0 +1,13 @@
|
|
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
|
+
export declare const FileEventData: core.serialization.ObjectSchema<serializers.FileEventData.Raw, Airtop.FileEventData>;
|
8
|
+
export declare namespace FileEventData {
|
9
|
+
interface Raw {
|
10
|
+
error: string;
|
11
|
+
filePath: string;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,44 @@
|
|
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.FileEventData = void 0;
|
40
|
+
const core = __importStar(require("../../core"));
|
41
|
+
exports.FileEventData = core.serialization.object({
|
42
|
+
error: core.serialization.string(),
|
43
|
+
filePath: core.serialization.string(),
|
44
|
+
});
|
@@ -4,13 +4,14 @@
|
|
4
4
|
import * as serializers from "../index";
|
5
5
|
import * as Airtop from "../../api/index";
|
6
6
|
import * as core from "../../core";
|
7
|
+
import { FileEventData } from "./FileEventData";
|
7
8
|
import { FileEventMessageStatus } from "./FileEventMessageStatus";
|
8
9
|
export declare const FileEventMessage: core.serialization.ObjectSchema<serializers.FileEventMessage.Raw, Airtop.FileEventMessage>;
|
9
10
|
export declare namespace FileEventMessage {
|
10
11
|
interface Raw {
|
11
12
|
downloadUrl: string;
|
12
13
|
event: string;
|
13
|
-
eventData?:
|
14
|
+
eventData?: FileEventData.Raw | null;
|
14
15
|
eventTime: string;
|
15
16
|
fileId: string;
|
16
17
|
status: FileEventMessageStatus.Raw;
|
@@ -38,11 +38,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
39
|
exports.FileEventMessage = void 0;
|
40
40
|
const core = __importStar(require("../../core"));
|
41
|
+
const FileEventData_1 = require("./FileEventData");
|
41
42
|
const FileEventMessageStatus_1 = require("./FileEventMessageStatus");
|
42
43
|
exports.FileEventMessage = core.serialization.object({
|
43
44
|
downloadUrl: core.serialization.string(),
|
44
45
|
event: core.serialization.string(),
|
45
|
-
eventData:
|
46
|
+
eventData: FileEventData_1.FileEventData.optional(),
|
46
47
|
eventTime: core.serialization.date(),
|
47
48
|
fileId: core.serialization.string(),
|
48
49
|
status: FileEventMessageStatus_1.FileEventMessageStatus,
|
@@ -28,6 +28,7 @@ export * from "./ExternalSessionAiResponseMetadata";
|
|
28
28
|
export * from "./ExternalSessionAiResponseMetadataUsage";
|
29
29
|
export * from "./ExternalSessionConfig";
|
30
30
|
export * from "./ExternalSessionWithConnectionInfo";
|
31
|
+
export * from "./FileEventData";
|
31
32
|
export * from "./FileEventMessageStatus";
|
32
33
|
export * from "./FileEventMessage";
|
33
34
|
export * from "./FilesResponse";
|
@@ -44,6 +44,7 @@ __exportStar(require("./ExternalSessionAiResponseMetadata"), exports);
|
|
44
44
|
__exportStar(require("./ExternalSessionAiResponseMetadataUsage"), exports);
|
45
45
|
__exportStar(require("./ExternalSessionConfig"), exports);
|
46
46
|
__exportStar(require("./ExternalSessionWithConnectionInfo"), exports);
|
47
|
+
__exportStar(require("./FileEventData"), exports);
|
47
48
|
__exportStar(require("./FileEventMessageStatus"), exports);
|
48
49
|
__exportStar(require("./FileEventMessage"), exports);
|
49
50
|
__exportStar(require("./FilesResponse"), exports);
|
package/utils/upload.js
CHANGED
@@ -8,16 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.uploadFileAndSelectInput = uploadFileAndSelectInput;
|
16
|
+
const path_1 = __importDefault(require("path"));
|
13
17
|
function uploadFileAndSelectInput(_a) {
|
14
18
|
return __awaiter(this, arguments, void 0, function* ({ client, sessionId, windowId, configuration, }) {
|
19
|
+
var _b;
|
15
20
|
const windowInfo = yield client.windows.getWindowInfo(sessionId, windowId);
|
16
21
|
if (!windowInfo) {
|
17
22
|
throw new Error('window not found');
|
18
23
|
}
|
19
24
|
client.log(`starting file upload: sessionId: ${sessionId}, windowId: ${windowId}, uploadFilePath: ${configuration.uploadFilePath}`);
|
20
|
-
const fileUploadResponse = yield client.files.upload(configuration.uploadFilePath
|
25
|
+
const fileUploadResponse = yield client.files.upload(configuration.uploadFilePath, {
|
26
|
+
fileName: (_b = configuration.fileName) !== null && _b !== void 0 ? _b : path_1.default.basename(configuration.uploadFilePath),
|
27
|
+
});
|
21
28
|
if (fileUploadResponse.errors && fileUploadResponse.errors.length > 0) {
|
22
29
|
client.log(`file upload failed: ${JSON.stringify(fileUploadResponse.errors)}`);
|
23
30
|
throw new Error('file upload failed');
|
@@ -28,7 +35,7 @@ function uploadFileAndSelectInput(_a) {
|
|
28
35
|
sessionIds: [sessionId],
|
29
36
|
});
|
30
37
|
client.log('file pushed to session');
|
31
|
-
client.log(
|
38
|
+
client.log(`waiting for file upload to become available ${fileId}`);
|
32
39
|
const waitResult = yield client.sessions.waitForUploadAvailable(sessionId, fileId);
|
33
40
|
if (waitResult) {
|
34
41
|
client.log('file upload available');
|
@@ -37,12 +44,10 @@ function uploadFileAndSelectInput(_a) {
|
|
37
44
|
client.log('file upload not available within timeout');
|
38
45
|
throw new Error('file upload not available within timeout');
|
39
46
|
}
|
40
|
-
client.log(
|
41
|
-
const fileInputResponse = yield client.windows.fileInput(sessionId, windowId, {
|
42
|
-
fileId: fileId,
|
43
|
-
elementDescription: configuration.elementDescription,
|
44
|
-
});
|
47
|
+
client.log(`executing file input interaction ${JSON.stringify(configuration)}`);
|
48
|
+
const fileInputResponse = yield client.windows.fileInput(sessionId, windowId, Object.assign({ fileId: fileId }, configuration));
|
45
49
|
if (fileInputResponse.errors && fileInputResponse.errors.length > 0) {
|
50
|
+
client.log(`file input failed: ${JSON.stringify(fileInputResponse.errors)}`);
|
46
51
|
throw new Error('file input failed');
|
47
52
|
}
|
48
53
|
client.log('file upload and file input interaction complete');
|
package/version.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
1
|
+
export declare const SDK_VERSION = "0.1.42";
|
package/version.js
CHANGED
@@ -336,6 +336,7 @@ class AirtopSessions extends Client_1.Sessions {
|
|
336
336
|
*/
|
337
337
|
waitForUploadAvailable(sessionId_1, fileId_1) {
|
338
338
|
return __awaiter(this, arguments, void 0, function* (sessionId, fileId, timeoutSeconds = 300) {
|
339
|
+
this.log(`waiting for uploaded file to be available on session: ${sessionId} ${fileId}`);
|
339
340
|
// Create a promise that resolves to null after the timeout
|
340
341
|
const timeoutPromise = new Promise((resolve) => {
|
341
342
|
setTimeout(() => resolve(null), timeoutSeconds * 1000);
|
@@ -351,9 +352,15 @@ class AirtopSessions extends Client_1.Sessions {
|
|
351
352
|
const event = _c;
|
352
353
|
const e = event;
|
353
354
|
if (e.event === 'file_upload_status') {
|
354
|
-
|
355
|
-
|
356
|
-
|
355
|
+
if (e.fileId === fileId) {
|
356
|
+
if (e.status === 'available') {
|
357
|
+
this.log(`uploaded file is now available on session: ${sessionId} ${fileId}`);
|
358
|
+
return event;
|
359
|
+
}
|
360
|
+
if (e.status === 'upload_failed') {
|
361
|
+
this.log(`upload failed: ${sessionId} ${fileId}`);
|
362
|
+
throw new Error(`upload failed: ${e.eventData.error}`);
|
363
|
+
}
|
357
364
|
}
|
358
365
|
}
|
359
366
|
}
|
@@ -409,7 +416,7 @@ class AirtopSessions extends Client_1.Sessions {
|
|
409
416
|
}
|
410
417
|
lastCallbackPromise = lastCallbackPromise
|
411
418
|
.then(() => callback(msg))
|
412
|
-
.catch(error => this.log(`Error in captcha callback: ${error}`));
|
419
|
+
.catch((error) => this.log(`Error in captcha callback: ${error}`));
|
413
420
|
}
|
414
421
|
}
|
415
422
|
}
|
@@ -420,7 +427,7 @@ class AirtopSessions extends Client_1.Sessions {
|
|
420
427
|
}
|
421
428
|
finally { if (e_5) throw e_5.error; }
|
422
429
|
}
|
423
|
-
}))().catch(error => {
|
430
|
+
}))().catch((error) => {
|
424
431
|
if (error.name !== 'AbortError') {
|
425
432
|
this.log(`Error in event processing: ${error}`);
|
426
433
|
}
|