@airtop/sdk 0.0.12 → 0.0.14
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/profiles/client/Client.js +4 -4
- package/api/resources/profiles/client/requests/ProfilesDeleteRequest.d.ts +1 -1
- package/api/resources/profiles/client/requests/ProfilesGetRequest.d.ts +1 -1
- package/api/resources/sessions/client/Client.d.ts +1 -1
- package/api/resources/sessions/client/Client.js +11 -11
- package/api/resources/sessions/client/requests/SessionsListRequest.d.ts +4 -4
- package/api/resources/sessions/types/SessionsListRequestStatus.d.ts +3 -3
- package/api/resources/sessions/types/SessionsListRequestStatus.js +1 -1
- package/api/resources/windows/client/Client.d.ts +9 -9
- package/api/resources/windows/client/Client.js +18 -18
- package/api/resources/windows/client/requests/GetWindowInfoRequest.d.ts +4 -4
- package/api/resources/windows/client/requests/PromptContentRequest.d.ts +8 -2
- package/api/resources/windows/client/requests/ScrapeContentRequest.d.ts +6 -0
- package/api/resources/windows/client/requests/SummarizeContentRequest.d.ts +7 -1
- package/api/types/ExternalProfileV1.d.ts +2 -2
- package/api/types/ExternalSessionAiResponseMetadata.d.ts +1 -0
- package/api/types/ExternalSessionAiResponseMetadataStatus.d.ts +3 -0
- package/api/types/ExternalSessionConfig.d.ts +3 -3
- package/api/types/ExternalSessionWithConnectionInfo.d.ts +10 -10
- package/api/types/Issue.d.ts +3 -3
- package/api/types/ScrapeResponseContent.d.ts +2 -2
- package/api/types/ScrapeResponseEnvelope.d.ts +1 -0
- package/api/types/ScrapeResponseOutput.d.ts +3 -3
- package/api/types/SessionConfigV1.d.ts +3 -3
- package/api/types/SessionsWithPagination.d.ts +2 -2
- package/api/types/Window.d.ts +2 -2
- package/dist/api/resources/profiles/client/Client.js +4 -4
- package/dist/api/resources/profiles/client/requests/ProfilesDeleteRequest.d.ts +1 -1
- package/dist/api/resources/profiles/client/requests/ProfilesGetRequest.d.ts +1 -1
- package/dist/api/resources/sessions/client/Client.d.ts +1 -1
- package/dist/api/resources/sessions/client/Client.js +11 -11
- package/dist/api/resources/sessions/client/requests/SessionsListRequest.d.ts +4 -4
- package/dist/api/resources/sessions/types/SessionsListRequestStatus.d.ts +3 -3
- package/dist/api/resources/sessions/types/SessionsListRequestStatus.js +1 -1
- package/dist/api/resources/windows/client/Client.d.ts +9 -9
- package/dist/api/resources/windows/client/Client.js +18 -18
- package/dist/api/resources/windows/client/requests/GetWindowInfoRequest.d.ts +4 -4
- package/dist/api/resources/windows/client/requests/PromptContentRequest.d.ts +8 -2
- package/dist/api/resources/windows/client/requests/ScrapeContentRequest.d.ts +6 -0
- package/dist/api/resources/windows/client/requests/SummarizeContentRequest.d.ts +7 -1
- package/dist/api/types/ExternalProfileV1.d.ts +2 -2
- package/dist/api/types/ExternalSessionAiResponseMetadata.d.ts +1 -0
- package/dist/api/types/ExternalSessionAiResponseMetadataStatus.d.ts +3 -0
- package/dist/api/types/ExternalSessionConfig.d.ts +3 -3
- package/dist/api/types/ExternalSessionWithConnectionInfo.d.ts +10 -10
- package/dist/api/types/Issue.d.ts +3 -3
- package/dist/api/types/ScrapeResponseContent.d.ts +2 -2
- package/dist/api/types/ScrapeResponseEnvelope.d.ts +1 -0
- package/dist/api/types/ScrapeResponseOutput.d.ts +3 -3
- package/dist/api/types/SessionConfigV1.d.ts +3 -3
- package/dist/api/types/SessionsWithPagination.d.ts +2 -2
- package/dist/api/types/Window.d.ts +2 -2
- package/dist/serialization/resources/sessions/types/SessionsListRequestStatus.d.ts +1 -1
- package/dist/serialization/resources/sessions/types/SessionsListRequestStatus.js +1 -1
- package/dist/wrapper/AirtopClient.js +1 -1
- package/dist/wrapper/AirtopWindows.d.ts +9 -5
- package/dist/wrapper/AirtopWindows.js +66 -15
- package/package.json +1 -1
- package/reference.md +10 -10
- package/serialization/resources/sessions/types/SessionsListRequestStatus.d.ts +1 -1
- package/serialization/resources/sessions/types/SessionsListRequestStatus.js +1 -1
- package/wrapper/AirtopClient.js +1 -1
- package/wrapper/AirtopWindows.d.ts +9 -5
- package/wrapper/AirtopWindows.js +66 -15
@@ -1,4 +1,27 @@
|
|
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 (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,11 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
32
|
});
|
10
33
|
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
11
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
38
|
exports.AirtopWindows = void 0;
|
39
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
40
|
+
const core = __importStar(require("../core"));
|
13
41
|
class AirtopWindows {
|
14
|
-
constructor(airtopClient) {
|
42
|
+
constructor(airtopClient, apiKeySupplier) {
|
15
43
|
this.airtopClient = airtopClient;
|
44
|
+
this.apiKeySupplier = apiKeySupplier;
|
16
45
|
this._windows = airtopClient.windows;
|
17
46
|
}
|
18
47
|
getWindowInfo(sessionId, windowId, request, requestOptions) {
|
@@ -22,22 +51,22 @@ class AirtopWindows {
|
|
22
51
|
}
|
23
52
|
promptContent(sessionId, windowId, request, requestOptions) {
|
24
53
|
return __awaiter(this, void 0, void 0, function* () {
|
25
|
-
return this._windows.promptContent(sessionId, windowId, request, requestOptions);
|
54
|
+
return this._windows.promptContent(sessionId, windowId, request, Object.assign({ timeoutInSeconds: 600 }, requestOptions));
|
26
55
|
});
|
27
56
|
}
|
28
|
-
scrapeContent(sessionId, windowId, requestOptions) {
|
29
|
-
return this._windows.scrapeContent(sessionId, windowId, requestOptions);
|
57
|
+
scrapeContent(sessionId, windowId, request, requestOptions) {
|
58
|
+
return this._windows.scrapeContent(sessionId, windowId, request, Object.assign({ timeoutInSeconds: 600 }, requestOptions));
|
30
59
|
}
|
31
60
|
summarizeContent(sessionId, windowId, request, requestOptions) {
|
32
|
-
return this._windows.summarizeContent(sessionId, windowId, request, requestOptions);
|
61
|
+
return this._windows.summarizeContent(sessionId, windowId, request, Object.assign({ timeoutInSeconds: 600 }, requestOptions));
|
33
62
|
}
|
34
|
-
getWindowInfoForPuppeteerPage(
|
63
|
+
getWindowInfoForPuppeteerPage(session, page, request, requestOptions) {
|
35
64
|
return __awaiter(this, void 0, void 0, function* () {
|
36
65
|
const targetId = yield page.mainFrame()._id;
|
37
|
-
return yield this.getWindowInfo(
|
66
|
+
return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
|
38
67
|
});
|
39
68
|
}
|
40
|
-
getWindowInfoForPlaywrightPage(
|
69
|
+
getWindowInfoForPlaywrightPage(session, page, request, requestOptions) {
|
41
70
|
return __awaiter(this, void 0, void 0, function* () {
|
42
71
|
// Retrieve target information
|
43
72
|
const cdpSession = yield page.context().newCDPSession(page);
|
@@ -46,19 +75,41 @@ class AirtopWindows {
|
|
46
75
|
if (!targetId) {
|
47
76
|
throw new Error('TargetId not found');
|
48
77
|
}
|
49
|
-
return yield this.getWindowInfo(
|
78
|
+
return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
|
50
79
|
});
|
51
80
|
}
|
52
|
-
|
81
|
+
executeSeleniumCDPCommand(driver, session, apiKey) {
|
53
82
|
return __awaiter(this, void 0, void 0, function* () {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
// Get the current WebDriver session ID
|
84
|
+
const webDriverSessionId = (yield driver.getSession()).getId();
|
85
|
+
if (!webDriverSessionId) {
|
86
|
+
throw new Error('No WebDriver session available');
|
87
|
+
}
|
88
|
+
const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;
|
89
|
+
const response = yield (0, node_fetch_1.default)(chromedriverSessionUrl, {
|
90
|
+
method: 'POST',
|
91
|
+
headers: {
|
92
|
+
'Content-Type': 'application/json',
|
93
|
+
Authorization: `Bearer ${apiKey}`,
|
94
|
+
},
|
95
|
+
body: JSON.stringify({
|
96
|
+
cmd: 'Target.getTargetInfo',
|
97
|
+
params: {},
|
98
|
+
}),
|
99
|
+
});
|
100
|
+
return response.json();
|
101
|
+
});
|
102
|
+
}
|
103
|
+
getWindowInfoForSeleniumDriver(session, driver, request, requestOptions) {
|
104
|
+
var _a, _b;
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
106
|
+
const apiKey = yield core.Supplier.get(this.apiKeySupplier);
|
107
|
+
const result = yield this.executeSeleniumCDPCommand(driver, session, apiKey || '');
|
108
|
+
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;
|
58
109
|
if (!targetId) {
|
59
110
|
throw new Error('TargetId not found');
|
60
111
|
}
|
61
|
-
return yield this.getWindowInfo(
|
112
|
+
return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
|
62
113
|
});
|
63
114
|
}
|
64
115
|
}
|
package/package.json
CHANGED
package/reference.md
CHANGED
@@ -351,7 +351,7 @@ await client.sessions.terminate("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b");
|
|
351
351
|
<dl>
|
352
352
|
<dd>
|
353
353
|
|
354
|
-
**id:** `string` — ID of the session to delete
|
354
|
+
**id:** `string` — ID of the session to delete.
|
355
355
|
|
356
356
|
</dd>
|
357
357
|
</dl>
|
@@ -449,7 +449,7 @@ await client.sessions.events("string");
|
|
449
449
|
|
450
450
|
```typescript
|
451
451
|
await client.windows.getWindowInfo("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "7334da2a-91b0-42c5-6156-76a5eba87430", {
|
452
|
-
screenResolution: "
|
452
|
+
screenResolution: "1280x720",
|
453
453
|
});
|
454
454
|
```
|
455
455
|
|
@@ -466,7 +466,7 @@ await client.windows.getWindowInfo("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "7334
|
|
466
466
|
<dl>
|
467
467
|
<dd>
|
468
468
|
|
469
|
-
**sessionId:** `string` — ID of the session that owns the window
|
469
|
+
**sessionId:** `string` — ID of the session that owns the window.
|
470
470
|
|
471
471
|
</dd>
|
472
472
|
</dl>
|
@@ -474,7 +474,7 @@ await client.windows.getWindowInfo("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "7334
|
|
474
474
|
<dl>
|
475
475
|
<dd>
|
476
476
|
|
477
|
-
**windowId:** `string` —
|
477
|
+
**windowId:** `string` — ID of the browser window, which can either be a normal AirTop windowId or a [CDP TargetId](https://chromedevtools.github.io/devtools-protocol/tot/Target/#type-TargetID) from a browser automation library like Puppeteer (typically associated with the page or main frame). Our SDKs will handle retrieving a TargetId for you from various popular browser automation libraries, but we also have details in our guides on how to do it manually.
|
478
478
|
|
479
479
|
</dd>
|
480
480
|
</dl>
|
@@ -532,7 +532,7 @@ await client.windows.promptContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
|
|
532
532
|
<dl>
|
533
533
|
<dd>
|
534
534
|
|
535
|
-
**sessionId:** `string` — The session id
|
535
|
+
**sessionId:** `string` — The session id for the window.
|
536
536
|
|
537
537
|
</dd>
|
538
538
|
</dl>
|
@@ -540,7 +540,7 @@ await client.windows.promptContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
|
|
540
540
|
<dl>
|
541
541
|
<dd>
|
542
542
|
|
543
|
-
**windowId:** `string` — The window id to
|
543
|
+
**windowId:** `string` — The Airtop window id of the browser window to target with an Airtop AI prompt.
|
544
544
|
|
545
545
|
</dd>
|
546
546
|
</dl>
|
@@ -596,7 +596,7 @@ await client.windows.scrapeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
|
|
596
596
|
<dl>
|
597
597
|
<dd>
|
598
598
|
|
599
|
-
**sessionId:** `string` — The session id
|
599
|
+
**sessionId:** `string` — The session id for the window.
|
600
600
|
|
601
601
|
</dd>
|
602
602
|
</dl>
|
@@ -604,7 +604,7 @@ await client.windows.scrapeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
|
|
604
604
|
<dl>
|
605
605
|
<dd>
|
606
606
|
|
607
|
-
**windowId:** `string` — The window id to scrape
|
607
|
+
**windowId:** `string` — The Airtop window id of the browser window to scrape.
|
608
608
|
|
609
609
|
</dd>
|
610
610
|
</dl>
|
@@ -660,7 +660,7 @@ await client.windows.summarizeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0
|
|
660
660
|
<dl>
|
661
661
|
<dd>
|
662
662
|
|
663
|
-
**sessionId:** `string` — The session id
|
663
|
+
**sessionId:** `string` — The session id for the window.
|
664
664
|
|
665
665
|
</dd>
|
666
666
|
</dl>
|
@@ -668,7 +668,7 @@ await client.windows.summarizeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0
|
|
668
668
|
<dl>
|
669
669
|
<dd>
|
670
670
|
|
671
|
-
**windowId:** `string` — The window id to summarize
|
671
|
+
**windowId:** `string` — The Airtop window id of the browser window to summarize.
|
672
672
|
|
673
673
|
</dd>
|
674
674
|
</dl>
|
@@ -6,5 +6,5 @@ import * as Airtop from "../../../../api/index";
|
|
6
6
|
import * as core from "../../../../core";
|
7
7
|
export declare const SessionsListRequestStatus: core.serialization.Schema<serializers.SessionsListRequestStatus.Raw, Airtop.SessionsListRequestStatus>;
|
8
8
|
export declare namespace SessionsListRequestStatus {
|
9
|
-
type Raw = "
|
9
|
+
type Raw = "awaitingCapacity" | "initializing" | "running" | "ended";
|
10
10
|
}
|
@@ -28,4 +28,4 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.SessionsListRequestStatus = void 0;
|
30
30
|
const core = __importStar(require("../../../../core"));
|
31
|
-
exports.SessionsListRequestStatus = core.serialization.enum_(["
|
31
|
+
exports.SessionsListRequestStatus = core.serialization.enum_(["awaitingCapacity", "initializing", "running", "ended"]);
|
package/wrapper/AirtopClient.js
CHANGED
@@ -8,7 +8,7 @@ class AirtopClient {
|
|
8
8
|
constructor(options) {
|
9
9
|
this._client = new Client_1.AirtopClient(options);
|
10
10
|
this.debug = (options === null || options === void 0 ? void 0 : options.debug) || false;
|
11
|
-
this._windowsWrapper = new AirtopWindows_1.AirtopWindows(this._client);
|
11
|
+
this._windowsWrapper = new AirtopWindows_1.AirtopWindows(this._client, options === null || options === void 0 ? void 0 : options.apiKey);
|
12
12
|
this._sessionsWrapper = new AirtopSessions_1.AirtopSessions(this._client, options === null || options === void 0 ? void 0 : options.debug);
|
13
13
|
}
|
14
14
|
get windows() {
|
@@ -10,22 +10,26 @@ declare namespace playwright {
|
|
10
10
|
}
|
11
11
|
declare namespace seleniumWebdriver {
|
12
12
|
interface WebDriver {
|
13
|
+
getSession(): Promise<any>;
|
13
14
|
createCDPConnection(domain: string): Promise<any>;
|
14
15
|
}
|
15
16
|
}
|
16
17
|
import { AirtopClient as FernClient } from '../Client';
|
17
18
|
import * as Airtop from '../api';
|
18
19
|
import { Windows as WindowsNamespace } from '../api/resources/windows/client/Client';
|
20
|
+
import * as core from '../core';
|
19
21
|
export declare class AirtopWindows {
|
20
22
|
private airtopClient;
|
23
|
+
private apiKeySupplier;
|
21
24
|
private _windows;
|
22
|
-
constructor(airtopClient: FernClient);
|
25
|
+
constructor(airtopClient: FernClient, apiKeySupplier: core.Supplier<core.BearerToken | undefined>);
|
23
26
|
getWindowInfo(sessionId: string, windowId: string, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
|
24
27
|
promptContent(sessionId: string, windowId: string, request: Airtop.PromptContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
|
25
|
-
scrapeContent(sessionId: string, windowId: string,
|
28
|
+
scrapeContent(sessionId: string, windowId: string, request?: Airtop.ScrapeContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.ScrapeResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
|
26
29
|
summarizeContent(sessionId: string, windowId: string, request?: Airtop.SummarizeContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
|
27
|
-
getWindowInfoForPuppeteerPage(
|
28
|
-
getWindowInfoForPlaywrightPage(
|
29
|
-
|
30
|
+
getWindowInfoForPuppeteerPage(session: Airtop.ExternalSessionWithConnectionInfo, page: puppeteer.Page, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
|
31
|
+
getWindowInfoForPlaywrightPage(session: Airtop.ExternalSessionWithConnectionInfo, page: playwright.Page, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
|
32
|
+
private executeSeleniumCDPCommand;
|
33
|
+
getWindowInfoForSeleniumDriver(session: Airtop.ExternalSessionWithConnectionInfo, driver: seleniumWebdriver.WebDriver, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
|
30
34
|
}
|
31
35
|
export {};
|
package/wrapper/AirtopWindows.js
CHANGED
@@ -1,4 +1,27 @@
|
|
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 (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,11 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
32
|
});
|
10
33
|
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
11
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
38
|
exports.AirtopWindows = void 0;
|
39
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
40
|
+
const core = __importStar(require("../core"));
|
13
41
|
class AirtopWindows {
|
14
|
-
constructor(airtopClient) {
|
42
|
+
constructor(airtopClient, apiKeySupplier) {
|
15
43
|
this.airtopClient = airtopClient;
|
44
|
+
this.apiKeySupplier = apiKeySupplier;
|
16
45
|
this._windows = airtopClient.windows;
|
17
46
|
}
|
18
47
|
getWindowInfo(sessionId, windowId, request, requestOptions) {
|
@@ -22,22 +51,22 @@ class AirtopWindows {
|
|
22
51
|
}
|
23
52
|
promptContent(sessionId, windowId, request, requestOptions) {
|
24
53
|
return __awaiter(this, void 0, void 0, function* () {
|
25
|
-
return this._windows.promptContent(sessionId, windowId, request, requestOptions);
|
54
|
+
return this._windows.promptContent(sessionId, windowId, request, Object.assign({ timeoutInSeconds: 600 }, requestOptions));
|
26
55
|
});
|
27
56
|
}
|
28
|
-
scrapeContent(sessionId, windowId, requestOptions) {
|
29
|
-
return this._windows.scrapeContent(sessionId, windowId, requestOptions);
|
57
|
+
scrapeContent(sessionId, windowId, request, requestOptions) {
|
58
|
+
return this._windows.scrapeContent(sessionId, windowId, request, Object.assign({ timeoutInSeconds: 600 }, requestOptions));
|
30
59
|
}
|
31
60
|
summarizeContent(sessionId, windowId, request, requestOptions) {
|
32
|
-
return this._windows.summarizeContent(sessionId, windowId, request, requestOptions);
|
61
|
+
return this._windows.summarizeContent(sessionId, windowId, request, Object.assign({ timeoutInSeconds: 600 }, requestOptions));
|
33
62
|
}
|
34
|
-
getWindowInfoForPuppeteerPage(
|
63
|
+
getWindowInfoForPuppeteerPage(session, page, request, requestOptions) {
|
35
64
|
return __awaiter(this, void 0, void 0, function* () {
|
36
65
|
const targetId = yield page.mainFrame()._id;
|
37
|
-
return yield this.getWindowInfo(
|
66
|
+
return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
|
38
67
|
});
|
39
68
|
}
|
40
|
-
getWindowInfoForPlaywrightPage(
|
69
|
+
getWindowInfoForPlaywrightPage(session, page, request, requestOptions) {
|
41
70
|
return __awaiter(this, void 0, void 0, function* () {
|
42
71
|
// Retrieve target information
|
43
72
|
const cdpSession = yield page.context().newCDPSession(page);
|
@@ -46,19 +75,41 @@ class AirtopWindows {
|
|
46
75
|
if (!targetId) {
|
47
76
|
throw new Error('TargetId not found');
|
48
77
|
}
|
49
|
-
return yield this.getWindowInfo(
|
78
|
+
return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
|
50
79
|
});
|
51
80
|
}
|
52
|
-
|
81
|
+
executeSeleniumCDPCommand(driver, session, apiKey) {
|
53
82
|
return __awaiter(this, void 0, void 0, function* () {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
// Get the current WebDriver session ID
|
84
|
+
const webDriverSessionId = (yield driver.getSession()).getId();
|
85
|
+
if (!webDriverSessionId) {
|
86
|
+
throw new Error('No WebDriver session available');
|
87
|
+
}
|
88
|
+
const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;
|
89
|
+
const response = yield (0, node_fetch_1.default)(chromedriverSessionUrl, {
|
90
|
+
method: 'POST',
|
91
|
+
headers: {
|
92
|
+
'Content-Type': 'application/json',
|
93
|
+
Authorization: `Bearer ${apiKey}`,
|
94
|
+
},
|
95
|
+
body: JSON.stringify({
|
96
|
+
cmd: 'Target.getTargetInfo',
|
97
|
+
params: {},
|
98
|
+
}),
|
99
|
+
});
|
100
|
+
return response.json();
|
101
|
+
});
|
102
|
+
}
|
103
|
+
getWindowInfoForSeleniumDriver(session, driver, request, requestOptions) {
|
104
|
+
var _a, _b;
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
106
|
+
const apiKey = yield core.Supplier.get(this.apiKeySupplier);
|
107
|
+
const result = yield this.executeSeleniumCDPCommand(driver, session, apiKey || '');
|
108
|
+
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;
|
58
109
|
if (!targetId) {
|
59
110
|
throw new Error('TargetId not found');
|
60
111
|
}
|
61
|
-
return yield this.getWindowInfo(
|
112
|
+
return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
|
62
113
|
});
|
63
114
|
}
|
64
115
|
}
|