Skip to content

Commit

Permalink
Merge pull request #34 from airtop-ai/fern-bot/01-09-2025-1212AM
Browse files Browse the repository at this point in the history
Add sdk source and version headers
  • Loading branch information
pciporin25 authored Jan 9, 2025
2 parents e13413c + 54a95d8 commit 88ec813
Show file tree
Hide file tree
Showing 25 changed files with 416 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
.DS_Store
/dist
.idea/
.idea
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"node-fetch": "2.7.0",
"qs": "6.11.2",
"js-base64": "3.7.2",
"async-mutex": "0.5.0"
"async-mutex": "0.5.0",
"eventemitter3": "5.0.1"
},
"devDependencies": {
"@types/url-join": "4.0.1",
Expand Down
90 changes: 75 additions & 15 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,73 @@ await client.windows.pageQuery("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a
</dl>
</details>

<details><summary><code>client.windows.<a href="/src/api/resources/windows/client/Client.ts">paginatedExtraction</a>(sessionId, windowId, { ...params }) -> Airtop.AiPromptResponse</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```typescript
await client.windows.paginatedExtraction(
"6aac6f73-bd89-4a76-ab32-5a6c422e8b0b",
"0334da2a-91b0-42c5-6156-76a5eba87430"
);
```

</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**sessionId:** `string` — The session id for the window.

</dd>
</dl>

<dl>
<dd>

**windowId:** `string` — The Airtop window id of the browser window.

</dd>
</dl>

<dl>
<dd>

**request:** `Airtop.SessionPaginatedExtractionHandlerRequestBody`

</dd>
</dl>

<dl>
<dd>

**requestOptions:** `Windows.RequestOptions`

</dd>
</dl>
</dd>
</dl>

</dd>
</dl>
</details>

<details><summary><code>client.windows.<a href="/src/api/resources/windows/client/Client.ts">promptContent</a>(sessionId, windowId, { ...params }) -> Airtop.AiPromptResponse</code></summary>
<dl>
<dd>
Expand Down Expand Up @@ -1102,51 +1169,44 @@ await client.sessions.terminate("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b");
</dl>
</details>

<details><summary><code>client.sessions.<a href="/src/api/resources/sessions/client/Client.ts">events</a>(id) -> core.Stream<Airtop.SessionsEventsResponse></code></summary>
<details><summary><code>client.sessions.<a href="/src/api/resources/sessions/client/Client.ts">saveProfileOnTermination</a>(sessionId, profileName) -> void</code></summary>
<dl>
<dd>

#### 📝 Description
#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

Get a session event stream for a given session ID
```typescript
await client.sessions.saveProfileOnTermination("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "myProfile");
```

</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage
#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

```typescript
await client.sessions.events("string");
```
**sessionId:** `string` — ID of the session that owns the window.

</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**id:** `string`ID of the session to get status info for
**profileName:** `string`Name under which to save the profile.

</dd>
</dl>
Expand Down
62 changes: 62 additions & 0 deletions src/api/resources/sessions/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,68 @@ export class Sessions {
}
}

/**
* @param {string} sessionId - ID of the session that owns the window.
* @param {string} profileName - Name under which to save the profile.
* @param {Sessions.RequestOptions} requestOptions - Request-specific configuration.
*
* @example
* await client.sessions.saveProfileOnTermination("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "myProfile")
*/
public async saveProfileOnTermination(
sessionId: string,
profileName: string,
requestOptions?: Sessions.RequestOptions
): Promise<void> {
const _response = await (this._options.fetcher ?? core.fetcher)({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.AirtopEnvironment.Default,
`sessions/${encodeURIComponent(sessionId)}/save-profile-on-termination/${encodeURIComponent(
profileName
)}`
),
method: "PUT",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@airtop/sdk",
"X-Fern-SDK-Version": "0.1.9",
"User-Agent": "@airtop/sdk/0.1.9",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
requestType: "json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return;
}

if (_response.error.reason === "status-code") {
throw new errors.AirtopError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}

switch (_response.error.reason) {
case "non-json":
throw new errors.AirtopError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.AirtopTimeoutError();
case "unknown":
throw new errors.AirtopError({
message: _response.error.errorMessage,
});
}
}

protected async _getAuthorizationHeader(): Promise<string> {
return `Bearer ${await core.Supplier.get(this._options.apiKey)}`;
}
Expand Down
71 changes: 71 additions & 0 deletions src/api/resources/windows/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,77 @@ export class Windows {
}
}

/**
* @param {string} sessionId - The session id for the window.
* @param {string} windowId - The Airtop window id of the browser window.
* @param {Airtop.SessionPaginatedExtractionHandlerRequestBody} request
* @param {Windows.RequestOptions} requestOptions - Request-specific configuration.
*
* @example
* await client.windows.paginatedExtraction("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430")
*/
public async paginatedExtraction(
sessionId: string,
windowId: string,
request: Airtop.SessionPaginatedExtractionHandlerRequestBody = {},
requestOptions?: Windows.RequestOptions
): Promise<Airtop.AiPromptResponse> {
const _response = await (this._options.fetcher ?? core.fetcher)({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.AirtopEnvironment.Default,
`sessions/${encodeURIComponent(sessionId)}/windows/${encodeURIComponent(windowId)}/paginated-extraction`
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@airtop/sdk",
"X-Fern-SDK-Version": "0.1.9",
"User-Agent": "@airtop/sdk/0.1.9",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
requestType: "json",
body: serializers.SessionPaginatedExtractionHandlerRequestBody.jsonOrThrow(request, {
unrecognizedObjectKeys: "strip",
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return serializers.AiPromptResponse.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
});
}

if (_response.error.reason === "status-code") {
throw new errors.AirtopError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}

switch (_response.error.reason) {
case "non-json":
throw new errors.AirtopError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.AirtopTimeoutError();
case "unknown":
throw new errors.AirtopError({
message: _response.error.errorMessage,
});
}
}

/**
* This endpoint is deprecated. Please use the `pageQuery` endpoint instead.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as Airtop from "../../../../index";

/**
* @example
* {}
*/
export interface SessionPaginatedExtractionHandlerRequestBody {
clientRequestId?: string;
/** Request configuration */
configuration?: Airtop.PaginatedExtractionConfig;
/** A credit threshold that, once exceeded, will cause the operation to be cancelled. Note that this is *not* a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended). */
costThresholdCredits?: number;
/** A prompt providing the Airtop AI model with additional direction or constraints about the page and the details you want to extract from the page. */
prompt?: string;
/**
* A time threshold in seconds that, once exceeded, will cause the operation to be cancelled. Note that this is *not* a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended).
*
* This setting does not extend the maximum session duration provided at the time of session creation.
*/
timeThresholdSeconds?: number;
}
1 change: 1 addition & 0 deletions src/api/resources/windows/client/requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { type GetWindowInfoRequest } from "./GetWindowInfoRequest";
export { type WindowLoadUrlV1Body } from "./WindowLoadUrlV1Body";
export { type SessionClickHandlerRequestBody } from "./SessionClickHandlerRequestBody";
export { type SessionHoverHandlerRequestBody } from "./SessionHoverHandlerRequestBody";
export { type SessionPaginatedExtractionHandlerRequestBody } from "./SessionPaginatedExtractionHandlerRequestBody";
export { type ScrapeContentRequest } from "./ScrapeContentRequest";
export { type SessionSummaryHandlerRequestBody } from "./SessionSummaryHandlerRequestBody";
export { type SessionTypeHandlerRequestBody } from "./SessionTypeHandlerRequestBody";
2 changes: 1 addition & 1 deletion src/api/types/ExternalProfileV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
export interface ExternalProfileV1 {
/** Id of the profile. */
profileId: string;
/** Status of the profile. */
/** DEPRECATED. */
status?: string;
}
12 changes: 12 additions & 0 deletions src/api/types/PaginatedExtractionConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface PaginatedExtractionConfig {
/** The mode to use for interaction. If set to 'auto', Airtop AI will automatically choose the most cost-effective interaction mode. If set to 'accurate', Airtop AI will use the most accurate interaction mode. If set to 'cost-efficient', Airtop AI will use the most cost-effective interaction mode. */
interactionMode?: string;
/** JSON schema defining the structure of the output. If not provided, the format of the output might vary. */
outputSchema?: string;
/** The mode to use for pagination. If set to 'auto', Airtop AI will automatically look for pagination links first and then attempt infinite scrolling to load more content. If set to 'paginated', Airtop AI will follow pagination links to load more content. If set to 'infinite-scroll', Airtop AI will scroll the page to load more content. */
paginationMode?: string;
}
2 changes: 2 additions & 0 deletions src/api/types/SessionConfigV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as Airtop from "../index";
export interface SessionConfigV1 {
/** Id of a profile to load into the session. */
baseProfileId?: string;
/** - */
extensionIds?: string[];
/** Persist the profile. */
persistProfile?: boolean;
/** Proxy configuration. */
Expand Down
2 changes: 1 addition & 1 deletion src/api/types/SessionConfigV1ProxyItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as Airtop from "../index";

/**
* 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'
* 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'
*/
export interface SessionConfigV1ProxyItem {
domainPattern: string;
Expand Down
4 changes: 2 additions & 2 deletions src/api/types/SessionPageQueryHandlerRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export interface SessionPageQueryHandlerRequestBody {
clientRequestId?: string;
/** Request configuration */
configuration?: Airtop.PageQueryConfig;
/** A credit threshold that, once exceeded, will cause the operation to be cancelled. Note that this is _not_ a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended). */
/** A credit threshold that, once exceeded, will cause the operation to be cancelled. Note that this is *not* a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended). */
costThresholdCredits?: number;
/** Make a best effort attempt to load more content items than are originally displayed on the page, e.g. by following pagination links, clicking controls to load more content, utilizing infinite scrolling, etc. This can be quite a bit more costly, but may be necessary for sites that require additional interaction to show the needed results. You can provide constraints in your prompt (e.g. on the total number of pages or results to consider). */
followPaginationLinks?: boolean;
/** The prompt to submit about the content in the browser window. */
prompt: string;
/**
* A time threshold in seconds that, once exceeded, will cause the operation to be cancelled. Note that this is _not_ a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended).
* A time threshold in seconds that, once exceeded, will cause the operation to be cancelled. Note that this is *not* a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended).
*
* This setting does not extend the maximum session duration provided at the time of session creation.
*/
Expand Down
Loading

0 comments on commit 88ec813

Please sign in to comment.