@agnocon/piece-brave-search 0.0.6
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 +32 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/web-search.d.ts +5 -0
- package/dist/lib/actions/web-search.d.ts.map +1 -0
- package/dist/lib/actions/web-search.js +53 -0
- package/dist/lib/actions/web-search.js.map +1 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +12 -0
- package/dist/lib/auth.js.map +1 -0
- package/package.json +46 -0
- package/src/index.ts +26 -0
- package/src/lib/actions/web-search.ts +48 -0
- package/src/lib/auth.ts +8 -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":"AAOA,eAAO,MAAM,WAAW,yGAoBtB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.braveSearch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/brave-search/src/index.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 web_search_1 = require("./lib/actions/web-search");
|
|
9
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
10
|
+
const auth_1 = require("./lib/auth");
|
|
11
|
+
exports.braveSearch = (0, pieces_framework_1.createPiece)({
|
|
12
|
+
displayName: 'Brave Search',
|
|
13
|
+
description: 'Privacy-preserving search engine',
|
|
14
|
+
auth: auth_1.braveSearchAuth,
|
|
15
|
+
minimumSupportedRelease: '0.30.0',
|
|
16
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/brave-search.png',
|
|
17
|
+
authors: ['ErisMorn', 'sanket-a11y'],
|
|
18
|
+
actions: [
|
|
19
|
+
web_search_1.braveWebSearchAction,
|
|
20
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
21
|
+
auth: auth_1.braveSearchAuth,
|
|
22
|
+
baseUrl: () => 'https://api.search.brave.com/res/v1',
|
|
23
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
return {
|
|
25
|
+
'X-Subscription-Token': auth.secret_text,
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
triggers: [],
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,wFAAwF;AACxF,qEAAqE;AACrE,gEAAmE;AACnE,yDAAgE;AAChE,0DAAmE;AACnE,qCAA6C;AAEhC,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACrC,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,kCAAkC;IAC/C,IAAI,EAAE,sBAAe;IACrB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,sDAAsD;IAC/D,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC;IACpC,OAAO,EAAE;QACP,iCAAoB;QACpB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,sBAAe;YACrB,OAAO,EAAE,GAAG,EAAE,CAAC,qCAAqC;YACpD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,sBAAsB,EAAE,IAAI,CAAC,WAAW;iBACzC,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const braveWebSearchAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
query: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
count: import("@agnocon/pieces-framework").NumberProperty<false>;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=web-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/web-search.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB;;;EA2C/B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.braveWebSearchAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/brave-search/src/lib/actions/web-search.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 auth_1 = require("../auth");
|
|
10
|
+
exports.braveWebSearchAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.braveSearchAuth,
|
|
12
|
+
name: 'web_search',
|
|
13
|
+
displayName: 'Web Search',
|
|
14
|
+
description: 'Search the web using Brave Search',
|
|
15
|
+
audience: 'both',
|
|
16
|
+
aiMetadata: {
|
|
17
|
+
description: 'Runs a web search query against the Brave Search API and returns the matching web results. Use it to retrieve current information from the public web for a given text query; set the optional count (1-20) to control how many results come back. Read-only lookup that returns the same results for the same query.',
|
|
18
|
+
idempotent: true,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
query: pieces_framework_1.Property.ShortText({
|
|
22
|
+
displayName: 'Query',
|
|
23
|
+
description: 'The search query',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
count: pieces_framework_1.Property.Number({
|
|
27
|
+
displayName: 'Count',
|
|
28
|
+
description: 'Number of results (1-20)',
|
|
29
|
+
required: false,
|
|
30
|
+
defaultValue: 10,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
run(context) {
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const query = context.propsValue.query;
|
|
36
|
+
const count = context.propsValue.count;
|
|
37
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
38
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
39
|
+
url: 'https://api.search.brave.com/res/v1/web/search',
|
|
40
|
+
headers: {
|
|
41
|
+
'X-Subscription-Token': context.auth.secret_text,
|
|
42
|
+
Accept: 'application/json',
|
|
43
|
+
},
|
|
44
|
+
queryParams: {
|
|
45
|
+
q: query,
|
|
46
|
+
count: count,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return response.body;
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=web-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../../src/lib/actions/web-search.ts"],"names":[],"mappings":";;;;AAAA,yGAAyG;AACzG,qEAAqE;AACrE,gEAAmE;AACnE,0DAAgE;AAChE,kCAA0C;AAE7B,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,mCAAmC;IAChD,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EACT,uTAAuT;QACzT,UAAU,EAAE,IAAI;KACjB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;YACvC,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;YAEvC,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,gDAAgD;gBACrD,OAAO,EAAE;oBACP,sBAAsB,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;oBAChD,MAAM,EAAE,kBAAkB;iBAC3B;gBACD,WAAW,EAAE;oBACX,CAAC,EAAE,KAAK;oBACR,KAAK,EAAE,KAA0B;iBAClC;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,8DAK1B,CAAC"}
|
package/dist/lib/auth.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.braveSearchAuth = void 0;
|
|
4
|
+
// Vendored from Activepieces packages/pieces/community/brave-search/src/lib/auth.ts (MIT).
|
|
5
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
6
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
7
|
+
exports.braveSearchAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
8
|
+
displayName: 'API Key',
|
|
9
|
+
required: true,
|
|
10
|
+
description: 'Your Brave Search API Key (get it from https://brave.com/search/api/)',
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC3F,qEAAqE;AACrE,gEAAsD;AAEzC,QAAA,eAAe,GAAG,4BAAS,CAAC,UAAU,CAAC;IAClD,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,WAAW,EACT,uEAAuE;CAC1E,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agnocon/piece-brave-search",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "AgnoCon brave search connector",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src",
|
|
17
|
+
"LICENSE.MIT-AP"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"vendor": "node ../scripts/vendor-ap.mjs piece-brave-search"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@agnocon/core-utils": "0.2.0",
|
|
25
|
+
"@agnocon/piece-types": "0.3.1",
|
|
26
|
+
"@agnocon/pieces-common": "0.12.8",
|
|
27
|
+
"@agnocon/pieces-framework": "0.36.0",
|
|
28
|
+
"tslib": "2.6.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "20.17.6",
|
|
32
|
+
"typescript": "5.5.4"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"agnocon": {
|
|
36
|
+
"originVersion": "0.0.6"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "restricted",
|
|
40
|
+
"tag": "latest"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"agnocon",
|
|
44
|
+
"connector"
|
|
45
|
+
]
|
|
46
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createPiece, PieceAuth } from '@agnocon/pieces-framework';
|
|
2
|
+
import { braveWebSearchAction } from './lib/actions/web-search';
|
|
3
|
+
import { createCustomApiCallAction } from '@agnocon/pieces-common';
|
|
4
|
+
import { braveSearchAuth } from './lib/auth';
|
|
5
|
+
|
|
6
|
+
export const braveSearch = createPiece({
|
|
7
|
+
displayName: 'Brave Search',
|
|
8
|
+
description: 'Privacy-preserving search engine',
|
|
9
|
+
auth: braveSearchAuth,
|
|
10
|
+
minimumSupportedRelease: '0.30.0',
|
|
11
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/brave-search.png',
|
|
12
|
+
authors: ['ErisMorn', 'sanket-a11y'],
|
|
13
|
+
actions: [
|
|
14
|
+
braveWebSearchAction,
|
|
15
|
+
createCustomApiCallAction({
|
|
16
|
+
auth: braveSearchAuth,
|
|
17
|
+
baseUrl: () => 'https://api.search.brave.com/res/v1',
|
|
18
|
+
authMapping: async (auth) => {
|
|
19
|
+
return {
|
|
20
|
+
'X-Subscription-Token': auth.secret_text,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
triggers: [],
|
|
26
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { httpClient, HttpMethod } from '@agnocon/pieces-common';
|
|
3
|
+
import { braveSearchAuth } from '../auth';
|
|
4
|
+
|
|
5
|
+
export const braveWebSearchAction = createAction({
|
|
6
|
+
auth: braveSearchAuth,
|
|
7
|
+
name: 'web_search',
|
|
8
|
+
displayName: 'Web Search',
|
|
9
|
+
description: 'Search the web using Brave Search',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: {
|
|
12
|
+
description:
|
|
13
|
+
'Runs a web search query against the Brave Search API and returns the matching web results. Use it to retrieve current information from the public web for a given text query; set the optional count (1-20) to control how many results come back. Read-only lookup that returns the same results for the same query.',
|
|
14
|
+
idempotent: true,
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
query: Property.ShortText({
|
|
18
|
+
displayName: 'Query',
|
|
19
|
+
description: 'The search query',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
count: Property.Number({
|
|
23
|
+
displayName: 'Count',
|
|
24
|
+
description: 'Number of results (1-20)',
|
|
25
|
+
required: false,
|
|
26
|
+
defaultValue: 10,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
async run(context) {
|
|
30
|
+
const query = context.propsValue.query;
|
|
31
|
+
const count = context.propsValue.count;
|
|
32
|
+
|
|
33
|
+
const response = await httpClient.sendRequest({
|
|
34
|
+
method: HttpMethod.GET,
|
|
35
|
+
url: 'https://api.search.brave.com/res/v1/web/search',
|
|
36
|
+
headers: {
|
|
37
|
+
'X-Subscription-Token': context.auth.secret_text,
|
|
38
|
+
Accept: 'application/json',
|
|
39
|
+
},
|
|
40
|
+
queryParams: {
|
|
41
|
+
q: query,
|
|
42
|
+
count: count as unknown as string,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return response.body;
|
|
47
|
+
},
|
|
48
|
+
});
|
package/src/lib/auth.ts
ADDED