Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions components/airtop/actions/create-session/create-session.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { parseObjectEntries } from "../../common/utils.mjs";
import app from "../../airtop.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "airtop-create-session",
name: "Create Session",
description: "Create a new cloud browser session. [See the documentation](https://docs.airtop.ai/api-reference/airtop-api/sessions/create)",
version: "0.0.1",
type: "action",
props: {
app,
profileName: {
type: "string",
label: "Profile Name",
description: "Name of a profile to load into the session. Only letters, numbers and hyphens are allowed. [See the documentation](https://docs.airtop.ai/guides/how-to/saving-a-profile) for more information",
optional: true,
},
saveProfileOnTermination: {
type: "boolean",
label: "Save Profile on Termination",
description: "If enabled, [the profile will be saved when the session terminates](https://docs.airtop.ai/api-reference/airtop-api/sessions/save-profile-on-termination). Only relevant if `Profile Name` is provided",
optional: true,
},
timeoutMinutes: {
type: "integer",
label: "Timeout (Minutes)",
description: "Number of minutes of inactivity (idle timeout) after which the session will terminate",
optional: true,
},
record: {
type: "boolean",
label: "Record",
description: "Whether to enable session recording",
optional: true,
},
solveCaptcha: {
type: "boolean",
label: "Solve Captcha",
description: "Whether to automatically solve captcha challenges",
optional: true,
},
additionalOptions: {
type: "object",
label: "Additional Options",
description: "Additional configuration parameters to send in the request. [See the documentation](https://docs.airtop.ai/api-reference/airtop-api/sessions/create) for available parameters (e.g., `proxy`). Values will be parsed as JSON where applicable.",
optional: true,
},
},
async run({ $ }) {
const {
profileName,
saveProfileOnTermination,
timeoutMinutes,
record,
solveCaptcha,
additionalOptions,
} = this;

if (profileName && !/^[a-zA-Z0-9-]+$/.test(profileName)) {
throw new ConfigurationError(`Profile name \`${profileName}\` must contain only letters, numbers and hyphens`);
}

const data = {
configuration: {
profileName,
timeoutMinutes,
record,
solveCaptcha,
...parseObjectEntries(additionalOptions),
},
};

const response = await this.app.createSession({
$,
data,
});

const sessionId = response.id;

let saveProfileOnTerminationResponse;
if (saveProfileOnTermination && profileName) {
saveProfileOnTerminationResponse = await this.app.saveProfileOnTermination({
$,
sessionId,
profileName,
});
}

$.export("$summary", `Successfully created session \`${sessionId}\` with status: ${response.status}`);
return {
response,
saveProfileOnTerminationResponse,
};
},
};

70 changes: 70 additions & 0 deletions components/airtop/actions/create-window/create-window.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import app from "../../airtop.app.mjs";

export default {
key: "airtop-create-window",
name: "Create Window",
description: "Create a new browser window in an active session. [See the documentation](https://docs.airtop.ai/api-reference/airtop-api/windows/create)",
version: "0.0.1",
type: "action",
props: {
app,
sessionId: {
propDefinition: [
app,
"sessionId",
],
},
url: {
type: "string",
label: "Initial URL",
description: "Optional URL to navigate to immediately after creating the window.",
optional: true,
default: "https://www.pipedream.com",
},
screenResolution: {
type: "string",
label: "Screen Resolution",
description: "Affects the live view configuration. By default, a live view will fill the parent frame when initially loaded. This parameter can be used to configure fixed dimensions (e.g. `1280x720`).",
optional: true,
default: "1280x720",
},
waitUntil: {
propDefinition: [
app,
"waitUntil",
],
},
waitUntilTimeoutSeconds: {
propDefinition: [
app,
"waitUntilTimeoutSeconds",
],
},
},
async run({ $ }) {
const {
sessionId,
url,
screenResolution,
waitUntil,
waitUntilTimeoutSeconds,
} = this;

const response = await this.app.createWindow({
$,
sessionId,
data: {
url,
screenResolution,
waitUntil,
waitUntilTimeoutSeconds,
},
});

const windowId = response.id;

$.export("$summary", `Successfully created window ${windowId}`);
return response;
},
};

30 changes: 30 additions & 0 deletions components/airtop/actions/end-session/end-session.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import app from "../../airtop.app.mjs";

export default {
key: "airtop-end-session",
name: "End Session",
description: "End a browser session. [See the documentation](https://docs.airtop.ai/api-reference/airtop-api/sessions/terminate)",
version: "0.0.1",
type: "action",
props: {
app,
sessionId: {
propDefinition: [
app,
"sessionId",
],
},
},
async run({ $ }) {
const { sessionId } = this;

const response = await this.app.endSession({
$,
sessionId,
});

$.export("$summary", `Successfully terminated session ${sessionId}`);
return response;
},
};

68 changes: 68 additions & 0 deletions components/airtop/actions/load-url/load-url.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import app from "../../airtop.app.mjs";

export default {
key: "airtop-load-url",
name: "Load URL",
description: "Navigate a browser window to a specific URL. [See the documentation](https://docs.airtop.ai/api-reference/airtop-api/windows/load-url)",
version: "0.0.1",
type: "action",
props: {
app,
sessionId: {
propDefinition: [
app,
"sessionId",
],
},
windowId: {
propDefinition: [
app,
"windowId",
({ sessionId }) => ({
sessionId,
}),
],
},
url: {
type: "string",
label: "URL",
description: "The URL to navigate to (e.g. `https://www.pipedream.com`)",
},
waitUntil: {
propDefinition: [
app,
"waitUntil",
],
},
waitUntilTimeoutSeconds: {
propDefinition: [
app,
"waitUntilTimeoutSeconds",
],
},
},
async run({ $ }) {
const {
sessionId,
windowId,
url,
waitUntil,
waitUntilTimeoutSeconds,
} = this;

const response = await this.app.loadUrl({
$,
sessionId,
windowId,
data: {
url,
waitUntil,
waitUntilTimeoutSeconds,
},
});

$.export("$summary", `Successfully navigated to ${url}`);
return response;
},
};

78 changes: 78 additions & 0 deletions components/airtop/actions/query-page/query-page.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import app from "../../airtop.app.mjs";

export default {
key: "airtop-query-page",
name: "Query Page",
description: "Extract data or ask questions about page content using AI. [See the documentation](https://docs.airtop.ai/api-reference/airtop-api/windows/page-query)",
version: "0.0.1",
type: "action",
props: {
app,
sessionId: {
propDefinition: [
app,
"sessionId",
],
},
windowId: {
propDefinition: [
app,
"windowId",
({ sessionId }) => ({
sessionId,
}),
],
},
prompt: {
type: "string",
label: "Prompt",
description: "The prompt to submit about the content in the browser window.",
},
followPaginationLinks: {
propDefinition: [
app,
"followPaginationLinks",
],
},
costThresholdCredits: {
propDefinition: [
app,
"costThresholdCredits",
],
},
timeThresholdSeconds: {
propDefinition: [
app,
"timeThresholdSeconds",
],
},
},
async run({ $ }) {
const {
sessionId,
windowId,
prompt,
followPaginationLinks,
costThresholdCredits,
timeThresholdSeconds,
} = this;

const response = await this.app.queryPage({
$,
sessionId,
windowId,
data: {
prompt,
configuration: {
followPaginationLinks,
costThresholdCredits,
timeThresholdSeconds,
},
},
});

$.export("$summary", "Successfully queried page");
return response;
},
};

Loading
Loading