@agnocon/piece-browse-ai 0.1.7
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/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/get-task-details.d.ts +5 -0
- package/dist/lib/actions/get-task-details.d.ts.map +1 -0
- package/dist/lib/actions/get-task-details.js +50 -0
- package/dist/lib/actions/get-task-details.js.map +1 -0
- package/dist/lib/actions/list-robots.d.ts +2 -0
- package/dist/lib/actions/list-robots.d.ts.map +1 -0
- package/dist/lib/actions/list-robots.js +45 -0
- package/dist/lib/actions/list-robots.js.map +1 -0
- package/dist/lib/actions/run-robot.d.ts +6 -0
- package/dist/lib/actions/run-robot.d.ts.map +1 -0
- package/dist/lib/actions/run-robot.js +64 -0
- package/dist/lib/actions/run-robot.js.map +1 -0
- package/dist/lib/common/auth.d.ts +2 -0
- package/dist/lib/common/auth.d.ts.map +1 -0
- package/dist/lib/common/auth.js +31 -0
- package/dist/lib/common/auth.js.map +1 -0
- package/dist/lib/common/client.d.ts +13 -0
- package/dist/lib/common/client.d.ts.map +1 -0
- package/dist/lib/common/client.js +63 -0
- package/dist/lib/common/client.js.map +1 -0
- package/dist/lib/common/props.d.ts +4 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +168 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/triggers/task-finished-successfully.d.ts +11 -0
- package/dist/lib/triggers/task-finished-successfully.d.ts.map +1 -0
- package/dist/lib/triggers/task-finished-successfully.js +110 -0
- package/dist/lib/triggers/task-finished-successfully.js.map +1 -0
- package/dist/lib/triggers/task-finished-with-error.d.ts +11 -0
- package/dist/lib/triggers/task-finished-with-error.d.ts.map +1 -0
- package/dist/lib/triggers/task-finished-with-error.js +110 -0
- package/dist/lib/triggers/task-finished-with-error.js.map +1 -0
- package/package.json +46 -0
- package/src/index.ts +34 -0
- package/src/lib/actions/get-task-details.ts +52 -0
- package/src/lib/actions/list-robots.ts +41 -0
- package/src/lib/actions/run-robot.ts +65 -0
- package/src/lib/common/auth.ts +24 -0
- package/src/lib/common/client.ts +85 -0
- package/src/lib/common/props.ts +213 -0
- package/src/lib/triggers/task-finished-successfully.ts +139 -0
- package/src/lib/triggers/task-finished-with-error.ts +138 -0
package/LICENSE.MIT-AP
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Activepieces AB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Derived helpers in this folder are adapted from Activepieces (MIT) for use
|
|
24
|
+
inside CX without depending on @activepieces/* packages at runtime.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,QAAQ,yGAuBnB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.browseAi = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/index.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const auth_1 = require("./lib/common/auth");
|
|
10
|
+
const get_task_details_1 = require("./lib/actions/get-task-details");
|
|
11
|
+
const list_robots_1 = require("./lib/actions/list-robots");
|
|
12
|
+
const run_robot_1 = require("./lib/actions/run-robot");
|
|
13
|
+
const task_finished_with_error_1 = require("./lib/triggers/task-finished-with-error");
|
|
14
|
+
const task_finished_successfully_1 = require("./lib/triggers/task-finished-successfully");
|
|
15
|
+
const pieces_framework_2 = require("@agnocon/pieces-framework");
|
|
16
|
+
exports.browseAi = (0, pieces_framework_1.createPiece)({
|
|
17
|
+
displayName: 'Browse AI',
|
|
18
|
+
auth: auth_1.browseAiAuth,
|
|
19
|
+
minimumSupportedRelease: '0.36.1',
|
|
20
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/browse-ai.png',
|
|
21
|
+
categories: [pieces_framework_2.PieceCategory.PRODUCTIVITY],
|
|
22
|
+
authors: ['aryel780'],
|
|
23
|
+
actions: [
|
|
24
|
+
get_task_details_1.getTaskDetailsAction,
|
|
25
|
+
list_robots_1.listRobotsAction,
|
|
26
|
+
run_robot_1.runRobotAction,
|
|
27
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
28
|
+
auth: auth_1.browseAiAuth,
|
|
29
|
+
baseUrl: () => 'https://api.browse.ai/v2',
|
|
30
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
return ({
|
|
32
|
+
Authorization: `Bearer ${auth.secret_text}`,
|
|
33
|
+
});
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
triggers: [
|
|
38
|
+
task_finished_with_error_1.taskFinishedWithErrorTrigger,
|
|
39
|
+
task_finished_successfully_1.taskFinishedSuccessfullyTrigger,
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,qFAAqF;AACrF,qEAAqE;AACrE,0DAAmE;AACnE,gEAAwD;AACxD,4CAAiD;AACjD,qEAAsE;AACtE,2DAA6D;AAC7D,uDAAyD;AACzD,sFAAuF;AACvF,0FAA4F;AAC5F,gEAA0D;AAE7C,QAAA,QAAQ,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,mBAAY;IAClB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,mDAAmD;IAC5D,UAAU,EAAC,CAAC,gCAAa,CAAC,YAAY,CAAC;IACvC,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE;QACP,uCAAoB;QACpB,8BAAgB;QAChB,0BAAc;QACd,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,mBAAY;YAClB,OAAO,EAAE,GAAG,EAAE,CAAC,0BAA0B;YACzC,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAU,IAAI,CAAC,WAAW,EAAE;iBAC5C,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE;QACR,uDAA4B;QAC5B,4DAA+B;KAChC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getTaskDetailsAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
robotId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
taskId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=get-task-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-task-details.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/get-task-details.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,oBAAoB;;;EA6C/B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTaskDetailsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/lib/actions/get-task-details.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const client_1 = require("../common/client");
|
|
10
|
+
const auth_1 = require("../common/auth");
|
|
11
|
+
const props_1 = require("../common/props");
|
|
12
|
+
exports.getTaskDetailsAction = (0, pieces_framework_1.createAction)({
|
|
13
|
+
name: 'get-task-details',
|
|
14
|
+
auth: auth_1.browseAiAuth,
|
|
15
|
+
displayName: 'Get Task Details',
|
|
16
|
+
description: 'Retrieves the details of a specific task executed by a Browse AI robot.',
|
|
17
|
+
audience: 'both',
|
|
18
|
+
aiMetadata: {
|
|
19
|
+
description: 'Fetches the full record of one previously-run Browse AI scraping task by robot ID and task ID, including its status and any captured/extracted data. Use to check the outcome or pull results of a known task. Requires both the robot ID and the task ID; read-only and idempotent.',
|
|
20
|
+
idempotent: true,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
robotId: props_1.robotIdDropdown,
|
|
24
|
+
taskId: props_1.taskIdDropdown,
|
|
25
|
+
},
|
|
26
|
+
run(context) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const { robotId, taskId } = context.propsValue;
|
|
30
|
+
try {
|
|
31
|
+
const response = yield (0, client_1.browseAiApiCall)({
|
|
32
|
+
auth: { apiKey: context.auth.secret_text },
|
|
33
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
34
|
+
resourceUri: `/robots/${robotId}/tasks/${taskId}`,
|
|
35
|
+
});
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
40
|
+
throw new Error('Task not found. Please verify the Robot ID and Task ID.');
|
|
41
|
+
}
|
|
42
|
+
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
|
|
43
|
+
throw new Error('Authentication failed. Please check your API key.');
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Failed to fetch task details: ${error.message || 'Unknown error occurred'}`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=get-task-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-task-details.js","sourceRoot":"","sources":["../../../src/lib/actions/get-task-details.ts"],"names":[],"mappings":";;;;AAAA,4GAA4G;AAC5G,qEAAqE;AACrE,gEAA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 -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-robots.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/list-robots.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB,+GAmC3B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listRobotsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/lib/actions/list-robots.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const client_1 = require("../common/client");
|
|
10
|
+
const auth_1 = require("../common/auth");
|
|
11
|
+
exports.listRobotsAction = (0, pieces_framework_1.createAction)({
|
|
12
|
+
name: 'list-robots',
|
|
13
|
+
auth: auth_1.browseAiAuth,
|
|
14
|
+
displayName: 'List Robots',
|
|
15
|
+
description: 'Retrieves all robots available in your account.',
|
|
16
|
+
audience: 'both',
|
|
17
|
+
aiMetadata: {
|
|
18
|
+
description: 'Lists all Browse AI robots in the connected account, returning each robot and its ID. Use to discover the available robots or resolve a robot name to the ID needed by other Browse AI actions. Takes no input; read-only and idempotent.',
|
|
19
|
+
idempotent: true,
|
|
20
|
+
},
|
|
21
|
+
props: {},
|
|
22
|
+
run(context) {
|
|
23
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
try {
|
|
26
|
+
const response = yield (0, client_1.browseAiApiCall)({
|
|
27
|
+
auth: { apiKey: context.auth.secret_text },
|
|
28
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
29
|
+
resourceUri: '/robots',
|
|
30
|
+
});
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
35
|
+
throw new Error('Authentication failed. Please check your API key.');
|
|
36
|
+
}
|
|
37
|
+
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 429) {
|
|
38
|
+
throw new Error('Rate limit exceeded. Please wait before retrying.');
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`Failed to fetch robots: ${error.message || 'Unknown error occurred'}`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=list-robots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-robots.js","sourceRoot":"","sources":["../../../src/lib/actions/list-robots.ts"],"names":[],"mappings":";;;;AAAA,uGAAuG;AACvG,qEAAqE;AACrE,gEAAyD;AACzD,0DAAoD;AACpD,6CAAmD;AACnD,yCAA8C;AAEjC,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,mBAAY;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,iDAAiD;IAC9D,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EACT,2OAA2O;QAC7O,UAAU,EAAE,IAAI;KACjB;IACD,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;;YACf,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAe,EAAC;oBACrC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,WAAW,EAAE,SAAS;iBACvB,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACvE,CAAC;gBAED,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACvE,CAAC;gBAED,MAAM,IAAI,KAAK,CACb,2BAA2B,KAAK,CAAC,OAAO,IAAI,wBAAwB,EAAE,CACvE,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const runRobotAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
robotId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
recordVideo: import("@agnocon/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
robotParams: import("@agnocon/pieces-framework").DynamicProperties<true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=run-robot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-robot.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/run-robot.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc;;;;EA0DzB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runRobotAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/lib/actions/run-robot.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const client_1 = require("../common/client");
|
|
10
|
+
const auth_1 = require("../common/auth");
|
|
11
|
+
const props_1 = require("../common/props");
|
|
12
|
+
exports.runRobotAction = (0, pieces_framework_1.createAction)({
|
|
13
|
+
name: 'run-robot',
|
|
14
|
+
auth: auth_1.browseAiAuth,
|
|
15
|
+
displayName: 'Run a Robot',
|
|
16
|
+
description: 'Runs a robot on-demand with custom input parameters.',
|
|
17
|
+
audience: 'both',
|
|
18
|
+
aiMetadata: {
|
|
19
|
+
description: 'Starts a new on-demand run of a Browse AI robot, creating a fresh scraping task with the robot-specific input parameters (the required inputs vary per robot and are pulled from its definition). Use to trigger a scrape/extraction; results arrive asynchronously, so poll Get Task Details or use a task-finished trigger for the outcome. Not idempotent: each call queues another task run.',
|
|
20
|
+
idempotent: false,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
robotId: props_1.robotIdDropdown,
|
|
24
|
+
recordVideo: pieces_framework_1.Property.Checkbox({
|
|
25
|
+
displayName: 'Record Video',
|
|
26
|
+
description: 'Try to record a video while running the task.',
|
|
27
|
+
required: false,
|
|
28
|
+
defaultValue: false,
|
|
29
|
+
}),
|
|
30
|
+
robotParams: props_1.robotParameters,
|
|
31
|
+
},
|
|
32
|
+
run(context) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
const { robotId, recordVideo } = context.propsValue;
|
|
36
|
+
const inputParameters = (_a = context.propsValue.robotParams) !== null && _a !== void 0 ? _a : {};
|
|
37
|
+
try {
|
|
38
|
+
const response = yield (0, client_1.browseAiApiCall)({
|
|
39
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
40
|
+
resourceUri: `/robots/${robotId}/tasks`,
|
|
41
|
+
auth: { apiKey: context.auth.secret_text },
|
|
42
|
+
body: {
|
|
43
|
+
recordVideo: recordVideo || false,
|
|
44
|
+
inputParameters,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return response;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
|
|
51
|
+
throw new Error('Authentication failed. Please check your API key.');
|
|
52
|
+
}
|
|
53
|
+
if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 404) {
|
|
54
|
+
throw new Error('Robot not found. Please verify the robot ID.');
|
|
55
|
+
}
|
|
56
|
+
if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) === 429) {
|
|
57
|
+
throw new Error('Rate limit exceeded. Please wait before retrying.');
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`Failed to run robot: ${error.message || 'Unknown error occurred'}`);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=run-robot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-robot.js","sourceRoot":"","sources":["../../../src/lib/actions/run-robot.ts"],"names":[],"mappings":";;;;AAAA,qGAAqG;AACrG,qEAAqE;AACrE,0DAAoD;AACpD,gEAAmE;AACnE,6CAAmD;AACnD,yCAA8C;AAC9C,2CAAmE;AAEtD,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,mBAAY;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EACT,sDAAsD;IACxD,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EACT,kYAAkY;QACpY,UAAU,EAAE,KAAK;KAClB;IACD,KAAK,EAAE;QACL,OAAO,EAAE,uBAAe;QACxB,WAAW,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC7B,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,+CAA+C;YACjD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACpB,CA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Root":"","sources":["../../../src/lib/common/auth.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,8DAmBvB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.browseAiAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/lib/common/auth.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const client_1 = require("./client");
|
|
10
|
+
exports.browseAiAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
11
|
+
displayName: 'API Key',
|
|
12
|
+
description: 'You can find your Browse AI API key on the dashboard under Settings → API Key.',
|
|
13
|
+
required: true,
|
|
14
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
try {
|
|
16
|
+
yield (0, client_1.browseAiApiCall)({
|
|
17
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
18
|
+
resourceUri: '/status',
|
|
19
|
+
auth: { apiKey: auth },
|
|
20
|
+
});
|
|
21
|
+
return { valid: true };
|
|
22
|
+
}
|
|
23
|
+
catch (_b) {
|
|
24
|
+
return {
|
|
25
|
+
valid: false,
|
|
26
|
+
error: 'Invalid API Key. Please check your Browse AI credentials.',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,+FAA+F;AAC/F,qEAAqE;AACrE,gEAAsD;AACtD,0DAAoD;AACpD,qCAA2C;AAE9B,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,gFAAgF;IAC7F,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAA,wBAAe,EAAC;gBACpB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;aACvB,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,WAAM,CAAC;YACP,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,2DAA2D;aACnE,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpMethod, HttpMessageBody } from '@agnocon/pieces-common';
|
|
2
|
+
export type BrowseAiAuthProps = {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
};
|
|
5
|
+
export type BrowseAiApiCallParams = {
|
|
6
|
+
method: HttpMethod;
|
|
7
|
+
resourceUri: string;
|
|
8
|
+
query?: Record<string, string | number | string[] | undefined>;
|
|
9
|
+
body?: unknown;
|
|
10
|
+
auth: BrowseAiAuthProps;
|
|
11
|
+
};
|
|
12
|
+
export declare function browseAiApiCall<T extends HttpMessageBody>({ method, resourceUri, query, body, auth, }: BrowseAiApiCallParams): Promise<T>;
|
|
13
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/common/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAEV,eAAe,EAEhB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,wBAAsB,eAAe,CAAC,CAAC,SAAS,eAAe,EAAE,EAC/D,MAAM,EACN,WAAW,EACX,KAAK,EACL,IAAI,EACJ,IAAI,GACL,EAAE,qBAAqB,GAAG,OAAO,CAAC,CAAC,CAAC,CA0DpC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.browseAiApiCall = browseAiApiCall;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/lib/common/client.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
function browseAiApiCall(_a) {
|
|
9
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ method, resourceUri, query, body, auth, }) {
|
|
10
|
+
var _b, _c;
|
|
11
|
+
const { apiKey } = auth;
|
|
12
|
+
if (!apiKey) {
|
|
13
|
+
throw new Error('Browse AI API key is required for authentication');
|
|
14
|
+
}
|
|
15
|
+
const queryParams = {};
|
|
16
|
+
if (query) {
|
|
17
|
+
for (const [key, value] of Object.entries(query)) {
|
|
18
|
+
if (value !== null && value !== undefined) {
|
|
19
|
+
queryParams[key] = String(value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const baseUrl = `https://api.browse.ai/v2`;
|
|
24
|
+
const request = {
|
|
25
|
+
method,
|
|
26
|
+
url: `${baseUrl}${resourceUri}`,
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: `Bearer ${apiKey}`,
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
queryParams,
|
|
32
|
+
body,
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
36
|
+
return response.body;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const statusCode = (_b = error.response) === null || _b === void 0 ? void 0 : _b.status;
|
|
40
|
+
const errorData = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data;
|
|
41
|
+
switch (statusCode) {
|
|
42
|
+
case 400:
|
|
43
|
+
throw new Error(`Bad Request: ${(errorData === null || errorData === void 0 ? void 0 : errorData.message) || 'Invalid parameters'}`);
|
|
44
|
+
case 401:
|
|
45
|
+
throw new Error('Unauthorized: Invalid API key. Please check your credentials.');
|
|
46
|
+
case 403:
|
|
47
|
+
throw new Error('Forbidden: You do not have permission to access this resource.');
|
|
48
|
+
case 404:
|
|
49
|
+
throw new Error('Not Found: The requested resource does not exist.');
|
|
50
|
+
case 429:
|
|
51
|
+
throw new Error('Rate Limit Exceeded: Please slow down your requests.');
|
|
52
|
+
case 500:
|
|
53
|
+
throw new Error('Internal Server Error: Something went wrong on Browse AI’s side.');
|
|
54
|
+
default:
|
|
55
|
+
{
|
|
56
|
+
const message = (errorData === null || errorData === void 0 ? void 0 : errorData.message) || error.message || 'Unknown error';
|
|
57
|
+
throw new Error(`Browse AI API Error (${statusCode || 'Unknown'}): ${message}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../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C,QAAQ,UAAU,EAAE,CAAC;gBACnB,KAAK,GAAG;oBACN,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,KAAI,oBAAoB,EAAE,CAAC,CAAC;gBAChF,KAAK,GAAG;oBACN,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;gBACnF,KAAK,GAAG;oBACN,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;gBACpF,KAAK,GAAG;oBACN,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACvE,KAAK,GAAG;oBACN,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;gBAC1E,KAAK,GAAG;oBACN,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;gBACtF;oBACE,CAAC;wBACD,MAAM,OAAO,GAAG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,KAAI,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC;wBACvE,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,IAAI,SAAS,MAAM,OAAO,EAAE,CAAC,CAAC;oBAChF,CAAC;YAEL,CAAC;QACH,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const robotIdDropdown: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
2
|
+
export declare const taskIdDropdown: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
export declare const robotParameters: import("@agnocon/pieces-framework").DynamicProperties<true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":"AA6CA,eAAO,MAAM,eAAe,kIAkD1B,CAAC;AAEH,eAAO,MAAM,cAAc,kIA8DzB,CAAC;AAEH,eAAO,MAAM,eAAe,2HAqD1B,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.robotParameters = exports.taskIdDropdown = exports.robotIdDropdown = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/browse-ai/src/lib/common/props.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const client_1 = require("./client");
|
|
10
|
+
const auth_1 = require("./auth");
|
|
11
|
+
exports.robotIdDropdown = pieces_framework_1.Property.Dropdown({
|
|
12
|
+
auth: auth_1.browseAiAuth,
|
|
13
|
+
displayName: 'Robot',
|
|
14
|
+
description: 'Select a robot from your Browse AI account',
|
|
15
|
+
required: true,
|
|
16
|
+
refreshers: [],
|
|
17
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
18
|
+
var _b, _c;
|
|
19
|
+
if (!auth) {
|
|
20
|
+
return {
|
|
21
|
+
disabled: true,
|
|
22
|
+
options: [],
|
|
23
|
+
placeholder: 'Please connect your Browse AI account first.',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const response = yield (0, client_1.browseAiApiCall)({
|
|
28
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
29
|
+
resourceUri: '/robots',
|
|
30
|
+
auth: { apiKey: auth.secret_text },
|
|
31
|
+
});
|
|
32
|
+
const robots = (_c = (_b = response === null || response === void 0 ? void 0 : response.robots) === null || _b === void 0 ? void 0 : _b.items) !== null && _c !== void 0 ? _c : [];
|
|
33
|
+
if (robots.length === 0) {
|
|
34
|
+
return {
|
|
35
|
+
disabled: true,
|
|
36
|
+
options: [],
|
|
37
|
+
placeholder: 'No robots found in your account.',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
disabled: false,
|
|
42
|
+
options: robots.map((robot) => ({
|
|
43
|
+
label: robot.name,
|
|
44
|
+
value: robot.id,
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
disabled: true,
|
|
51
|
+
options: [],
|
|
52
|
+
placeholder: 'Failed to load robots. Please check your API key and try again.',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
exports.taskIdDropdown = pieces_framework_1.Property.Dropdown({
|
|
58
|
+
auth: auth_1.browseAiAuth,
|
|
59
|
+
displayName: 'Task',
|
|
60
|
+
description: 'Select a task associated with the selected robot',
|
|
61
|
+
required: true,
|
|
62
|
+
refreshers: ['robotId'],
|
|
63
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, robotId }) {
|
|
64
|
+
var _b, _c, _d;
|
|
65
|
+
if (!auth) {
|
|
66
|
+
return {
|
|
67
|
+
disabled: true,
|
|
68
|
+
options: [],
|
|
69
|
+
placeholder: 'Please connect your Browse AI account.',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (!robotId) {
|
|
73
|
+
return {
|
|
74
|
+
disabled: true,
|
|
75
|
+
options: [],
|
|
76
|
+
placeholder: 'Please select a robot first.',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const response = yield (0, client_1.browseAiApiCall)({
|
|
81
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
82
|
+
resourceUri: `/robots/${robotId}/tasks`,
|
|
83
|
+
auth: { apiKey: auth.secret_text },
|
|
84
|
+
});
|
|
85
|
+
const tasks = (_d = (_c = (_b = response.result) === null || _b === void 0 ? void 0 : _b.robotTasks) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
|
|
86
|
+
if (tasks.length === 0) {
|
|
87
|
+
return {
|
|
88
|
+
disabled: true,
|
|
89
|
+
options: [],
|
|
90
|
+
placeholder: 'No tasks found for the selected robot.',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
disabled: false,
|
|
95
|
+
options: tasks.map((task) => {
|
|
96
|
+
const createdDate = task.createdAt
|
|
97
|
+
? new Date(task.createdAt).toLocaleDateString()
|
|
98
|
+
: 'Unknown date';
|
|
99
|
+
return {
|
|
100
|
+
label: `${task.id} - ${task.status} (${createdDate})`,
|
|
101
|
+
value: task.id,
|
|
102
|
+
};
|
|
103
|
+
}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
return {
|
|
108
|
+
disabled: true,
|
|
109
|
+
options: [],
|
|
110
|
+
placeholder: `Error fetching tasks: ${e instanceof Error ? e.message : 'Unknown error'}`,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
});
|
|
115
|
+
exports.robotParameters = pieces_framework_1.Property.DynamicProperties({
|
|
116
|
+
auth: auth_1.browseAiAuth,
|
|
117
|
+
displayName: 'Input Parameters',
|
|
118
|
+
refreshers: ['robotId'],
|
|
119
|
+
required: true,
|
|
120
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, robotId }) {
|
|
121
|
+
var _b;
|
|
122
|
+
if (!auth || !robotId)
|
|
123
|
+
return {};
|
|
124
|
+
try {
|
|
125
|
+
const response = yield (0, client_1.browseAiApiCall)({
|
|
126
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
127
|
+
resourceUri: `/robots/${robotId}`,
|
|
128
|
+
auth: { apiKey: auth.secret_text },
|
|
129
|
+
});
|
|
130
|
+
const props = {};
|
|
131
|
+
const params = (_b = response.robot.inputParameters) !== null && _b !== void 0 ? _b : [];
|
|
132
|
+
for (const param of params) {
|
|
133
|
+
switch (param.type) {
|
|
134
|
+
case 'number':
|
|
135
|
+
props[param.name] = pieces_framework_1.Property.Number({
|
|
136
|
+
displayName: param.label,
|
|
137
|
+
required: param.required,
|
|
138
|
+
});
|
|
139
|
+
break;
|
|
140
|
+
case 'url':
|
|
141
|
+
case 'string':
|
|
142
|
+
props[param.name] = pieces_framework_1.Property.ShortText({
|
|
143
|
+
displayName: param.label,
|
|
144
|
+
required: param.required,
|
|
145
|
+
});
|
|
146
|
+
break;
|
|
147
|
+
case 'select':
|
|
148
|
+
props[param.name] = pieces_framework_1.Property.StaticDropdown({
|
|
149
|
+
displayName: param.label,
|
|
150
|
+
required: param.required,
|
|
151
|
+
options: {
|
|
152
|
+
disabled: false,
|
|
153
|
+
options: param.options ? param.options : [],
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return props;
|
|
162
|
+
}
|
|
163
|
+
catch (_c) {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
});
|
|
168
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,gGAAgG;AAChG,qEAAqE;AACrE,gEAAwE;AACxE,0DAAoD;AACpD,qCAA2C;AAC3C,iCAAsC;AAwCzB,QAAA,eAAe,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC/C,IAAI,EAAE,mBAAY;IAClB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,4CAA4C;IACzD,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EA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xB,QAAQ,EAAE,KAAK,CAAC,QAAQ;yBACzB,CAAC,CAAC;wBACH,MAAM;oBACR,KAAK,KAAK,CAAC;oBACX,KAAK,QAAQ;wBACX,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,2BAAQ,CAAC,SAAS,CAAC;4BACrC,WAAW,EAAE,KAAK,CAAC,KAAK;4BACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;yBACzB,CAAC,CAAC;wBACH,MAAM;oBACR,KAAK,QAAQ;wBACX,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,2BAAQ,CAAC,cAAc,CAAC;4BAC1C,WAAW,EAAE,KAAK,CAAC,KAAK;4BACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;4BACxB,OAAO,EAAE;gCACP,QAAQ,EAAE,KAAK;gCACf,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;6BAC5C;yBACF,CAAC,CAAC;wBACH,MAAM;oBACR;wBACE,MAAM;gBACV,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const taskFinishedSuccessfullyTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
robotId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
5
|
+
robotId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
7
|
+
robotId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
robotId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=task-finished-successfully.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-finished-successfully.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/task-finished-successfully.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAQ3E,eAAO,MAAM,+BAA+B;;;;;;;;EAiI1C,CAAC"}
|