Skip to content

Commit 219e9f9

Browse files
committed
[Components] anchor_browser - new components
1 parent e49a80d commit 219e9f9

File tree

7 files changed

+422
-10
lines changed

7 files changed

+422
-10
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import app from "../../anchor_browser.app.mjs";
2+
3+
export default {
4+
key: "anchor_browser-create-profile",
5+
name: "Create Profile",
6+
description: "Creates a new profile from a session. A Profile stores cookies, local storage, and cache. [See the documentation](https://docs.anchorbrowser.io/api-reference/profiles/create-profile).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
propDefinition: [
13+
app,
14+
"name",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
source: {
24+
propDefinition: [
25+
app,
26+
"source",
27+
],
28+
},
29+
sessionId: {
30+
propDefinition: [
31+
app,
32+
"sessionId",
33+
],
34+
},
35+
},
36+
methods: {
37+
createProfile(args = {}) {
38+
return this.app.post({
39+
path: "/profiles",
40+
...args,
41+
});
42+
},
43+
},
44+
async run({ $ }) {
45+
const {
46+
createProfile,
47+
name,
48+
description,
49+
source,
50+
sessionId,
51+
} = this;
52+
53+
const response = await createProfile({
54+
$,
55+
data: {
56+
name,
57+
description,
58+
source,
59+
session_id: sessionId,
60+
},
61+
});
62+
63+
$.export("$summary", "Successfully created profile.");
64+
return response;
65+
},
66+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import app from "../../anchor_browser.app.mjs";
2+
3+
export default {
4+
key: "anchor_browser-delete-profile",
5+
name: "Delete Profile",
6+
description: "Deletes an existing profile by its name. [See the documentation](https://docs.anchorbrowser.io/api-reference/profiles/delete-profile).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
profileName: {
12+
description: "The name of the profile to delete.",
13+
propDefinition: [
14+
app,
15+
"profileName",
16+
],
17+
},
18+
},
19+
methods: {
20+
deleteProfile({
21+
profileName, ...args
22+
} = {}) {
23+
return this.app.delete({
24+
path: `/profiles/${encodeURIComponent(profileName)}`,
25+
...args,
26+
});
27+
},
28+
},
29+
async run({ $ }) {
30+
const {
31+
deleteProfile,
32+
profileName,
33+
} = this;
34+
35+
const response = await deleteProfile({
36+
$,
37+
profileName,
38+
});
39+
40+
$.export("$summary", "Successfully deleted profile.");
41+
return response;
42+
},
43+
};
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import app from "../../anchor_browser.app.mjs";
2+
3+
export default {
4+
key: "anchor_browser-start-browser",
5+
name: "Start Browser",
6+
description: "Allocates a new browser session for the user, with optional configurations for ad-blocking, captcha solving, proxy usage, and idle timeout. [See the documentation](https://docs.anchorbrowser.io/api-reference/browser-sessions/start-browser).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
adblockConfigActive: {
12+
type: "boolean",
13+
label: "Adblock Configuration - Active",
14+
description: "Whether adblock configuration is active",
15+
},
16+
adblockConfigPopupBlockingActive: {
17+
type: "boolean",
18+
label: "Adblock Configuration - Popup Blocking Active",
19+
description: "Whether popup blocking is active",
20+
},
21+
captchaConfigActive: {
22+
type: "boolean",
23+
label: "Captcha Configuration - Active",
24+
description: "Whether captcha configuration is active",
25+
},
26+
headless: {
27+
type: "boolean",
28+
label: "Headless",
29+
description: "Whether browser should be headless or headfull.",
30+
},
31+
proxyConfigType: {
32+
type: "string",
33+
label: "Proxy Configuration - Type",
34+
description: "The type of proxy configuration to use. Eg. `anchor_residential`.",
35+
optional: true,
36+
},
37+
proxyConfigActive: {
38+
type: "boolean",
39+
label: "Proxy Configuration - Active",
40+
description: "Whether proxy configuration is active",
41+
optional: true,
42+
},
43+
recordingActive: {
44+
type: "boolean",
45+
label: "Recording - Active",
46+
description: "Whether recording is active",
47+
optional: true,
48+
},
49+
profileName: {
50+
description: "The name of the profile to use for the browser session.",
51+
propDefinition: [
52+
app,
53+
"profileName",
54+
],
55+
},
56+
profilePersist: {
57+
type: "boolean",
58+
label: "Profile - Persist",
59+
description: "Whether the profile should persist after the session ends.",
60+
},
61+
viewportWidth: {
62+
type: "integer",
63+
label: "Viewport - Width",
64+
description: "The width of the viewport",
65+
},
66+
viewportHeight: {
67+
type: "integer",
68+
label: "Viewport - Height",
69+
description: "The height of the viewport",
70+
},
71+
timeout: {
72+
type: "string",
73+
label: "Timeout",
74+
description: "Maximum amount of time (in minutes) for the browser to run, before terminating. Defaults to `-1`, which disables the global timeout mechanism.",
75+
optional: true,
76+
},
77+
idleTimeout: {
78+
type: "string",
79+
label: "Idle Timeout",
80+
description: "The amount of time (in minutes) the session waits for new connections after all others are closed before stopping. Defaults to `1`. Setting it to `-1` let the browser session continue forever [**CAUTION** - Keep track of long living sessions and manually kill them].",
81+
optional: true,
82+
},
83+
},
84+
methods: {
85+
startBrowserSession(args = {}) {
86+
return this.app.post({
87+
path: "/sessions",
88+
...args,
89+
});
90+
},
91+
},
92+
async run({ $ }) {
93+
const {
94+
startBrowserSession,
95+
adblockConfigActive,
96+
adblockConfigPopupBlockingActive,
97+
captchaConfigActive,
98+
headless,
99+
proxyConfigType,
100+
proxyConfigActive,
101+
recordingActive,
102+
profileName,
103+
profilePersist,
104+
viewportWidth,
105+
viewportHeight,
106+
timeout,
107+
idleTimeout,
108+
} = this;
109+
110+
const response = await startBrowserSession({
111+
$,
112+
data: {
113+
adblock_config: {
114+
active: adblockConfigActive,
115+
popup_blocking_active: adblockConfigPopupBlockingActive,
116+
},
117+
captcha_config: {
118+
active: captchaConfigActive,
119+
},
120+
headless,
121+
proxy_config: {
122+
type: proxyConfigType,
123+
active: proxyConfigActive,
124+
},
125+
recording: {
126+
active: recordingActive,
127+
},
128+
profile: {
129+
name: profileName,
130+
persist: profilePersist,
131+
},
132+
viewport: {
133+
width: viewportWidth,
134+
height: viewportHeight,
135+
},
136+
timeout,
137+
idle_timeout: idleTimeout,
138+
},
139+
});
140+
141+
$.export("$summary", "Successfully started browser session.");
142+
return response;
143+
},
144+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import app from "../../anchor_browser.app.mjs";
2+
3+
export default {
4+
key: "anchor_browser-update-profile",
5+
name: "Update Profile",
6+
description: "Updates the description or data of an existing profile using a session. [See the documentation](https://docs.anchorbrowser.io/api-reference/profiles/update-profile).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
profileName: {
12+
propDefinition: [
13+
app,
14+
"profileName",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
source: {
24+
propDefinition: [
25+
app,
26+
"source",
27+
],
28+
},
29+
sessionId: {
30+
propDefinition: [
31+
app,
32+
"sessionId",
33+
],
34+
},
35+
},
36+
methods: {
37+
updateProfile({
38+
profileName, ...args
39+
} = {}) {
40+
return this.app.put({
41+
path: `/profiles/${encodeURIComponent(profileName)}`,
42+
...args,
43+
});
44+
},
45+
},
46+
async run({ $ }) {
47+
const {
48+
updateProfile,
49+
profileName,
50+
description,
51+
source,
52+
sessionId,
53+
} = this;
54+
55+
const response = await updateProfile({
56+
$,
57+
profileName,
58+
data: {
59+
description,
60+
source,
61+
session_id: sessionId,
62+
},
63+
});
64+
65+
$.export("$summary", "Successfully updated profile.");
66+
return response;
67+
},
68+
};

0 commit comments

Comments
 (0)