@scopieflows/app-google-search 0.0.1

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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-google-search
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-google-search` to build the library.
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@scopieflows/app-google-search",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@sinclair/typebox": "0.34.11",
9
+ "ai": "^6.0.0",
10
+ "axios": "1.13.1",
11
+ "axios-retry": "4.4.1",
12
+ "deepmerge-ts": "7.1.0",
13
+ "form-data": "4.0.4",
14
+ "i18next": "23.13.0",
15
+ "mime-types": "2.1.35",
16
+ "nanoid": "3.3.8",
17
+ "semver": "7.6.0",
18
+ "socket.io-client": "4.8.1",
19
+ "tslib": "^2.3.0",
20
+ "zod": "4.1.13",
21
+ "@scopieflows/pieces-common": "0.11.2",
22
+ "@scopieflows/pieces-framework": "0.25.0",
23
+ "@scopieflows/shared": "0.33.0"
24
+ },
25
+ "resolutions": {
26
+ "rollup": "npm:@rollup/wasm-node"
27
+ }
28
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export declare const googleSearchAuth: import("@scopieflows/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
3
+ projectId: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
4
+ appId: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
5
+ }>;
6
+ export declare const googleSearch: import("@scopieflows/pieces-framework").Piece<import("@scopieflows/pieces-framework").CustomAuthProperty<{
7
+ apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
8
+ projectId: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
9
+ appId: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
10
+ }>>;
package/src/index.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleSearch = exports.googleSearchAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@scopieflows/pieces-framework");
6
+ const pieces_common_1 = require("@scopieflows/pieces-common");
7
+ const search_1 = require("./lib/actions/search");
8
+ const markdownDescription = `
9
+ Follow these steps to obtain your Google Cloud API Key:
10
+
11
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/).
12
+ 2. Create or select a project.
13
+ 3. Navigate to **APIs & Services** > **Enabled APIs & services**.
14
+ 4. Click **+ ENABLE APIS AND SERVICES** and enable **Vertex AI Search** (Discovery Engine API).
15
+ 5. Go to **APIs & Services** > **Credentials**.
16
+ 6. Click **Create Credentials** > **API key**.
17
+ 7. Copy the API key and paste it below.
18
+ `;
19
+ exports.googleSearchAuth = pieces_framework_1.PieceAuth.CustomAuth({
20
+ description: markdownDescription,
21
+ required: true,
22
+ props: {
23
+ apiKey: pieces_framework_1.PieceAuth.SecretText({
24
+ displayName: 'API Key',
25
+ description: 'Your Google Cloud API key with Vertex AI Search access.',
26
+ required: true,
27
+ }),
28
+ projectId: pieces_framework_1.Property.ShortText({
29
+ displayName: 'Project ID',
30
+ description: 'Your Google Cloud project ID.',
31
+ required: true,
32
+ }),
33
+ appId: pieces_framework_1.Property.ShortText({
34
+ displayName: 'App ID',
35
+ description: 'The Vertex AI Search app (engine) ID.',
36
+ required: true,
37
+ }),
38
+ },
39
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
40
+ try {
41
+ const { apiKey, projectId, appId } = auth;
42
+ const url = `https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/engines/${appId}/servingConfigs/default_search:searchLite?key=${apiKey}`;
43
+ yield pieces_common_1.httpClient.sendRequest({
44
+ method: pieces_common_1.HttpMethod.POST,
45
+ url,
46
+ headers: { 'Content-Type': 'application/json' },
47
+ body: {
48
+ query: 'test',
49
+ },
50
+ });
51
+ return { valid: true };
52
+ }
53
+ catch (error) {
54
+ return {
55
+ valid: false,
56
+ error: `Authentication failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
57
+ };
58
+ }
59
+ }),
60
+ });
61
+ exports.googleSearch = (0, pieces_framework_1.createPiece)({
62
+ displayName: 'Google Search',
63
+ description: 'Search using Vertex AI Search (Discovery Engine)',
64
+ auth: exports.googleSearchAuth,
65
+ minimumSupportedRelease: '0.36.1',
66
+ logoUrl: '/pieces/google-search.png',
67
+ authors: ['onyedikachi-david'],
68
+ actions: [search_1.searchAction],
69
+ triggers: [],
70
+ });
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/google-search/src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAAiF;AACjF,8DAAoE;AACpE,iDAAoD;AAEpD,MAAM,mBAAmB,GAAG;;;;;;;;;;CAU3B,CAAC;AAEW,QAAA,gBAAgB,GAAG,4BAAS,CAAC,UAAU,CAAC;IACnD,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC3B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;YAC1C,MAAM,GAAG,GAAG,sDAAsD,SAAS,4DAA4D,KAAK,iDAAiD,MAAM,EAAE,CAAC;YACtM,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC3B,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG;gBACH,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE;oBACJ,KAAK,EAAE,MAAM;iBACd;aACF,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;aAC5F,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC;AAEU,QAAA,YAAY,GAAG,IAAA,8BAAW,EAAC;IACtC,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,kDAAkD;IAC/D,IAAI,EAAE,wBAAgB;IACtB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,CAAC,mBAAmB,CAAC;IAC9B,OAAO,EAAE,CAAC,qBAAY,CAAC;IACvB,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const searchAction: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
3
+ projectId: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
4
+ appId: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
5
+ }>, {
6
+ query: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
7
+ userPseudoId: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
8
+ }>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@scopieflows/pieces-framework");
6
+ const pieces_common_1 = require("@scopieflows/pieces-common");
7
+ const index_1 = require("../../index");
8
+ exports.searchAction = (0, pieces_framework_1.createAction)({
9
+ auth: index_1.googleSearchAuth,
10
+ name: 'search',
11
+ displayName: 'Search',
12
+ description: 'Search for content using Vertex AI Search (searchLite).',
13
+ props: {
14
+ query: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Search Query',
16
+ description: 'The query text to search.',
17
+ required: true,
18
+ }),
19
+ userPseudoId: pieces_framework_1.Property.ShortText({
20
+ displayName: 'User Pseudo ID',
21
+ description: 'A pseudonymized identifier for the user (max 128 chars). Improves personalization.',
22
+ required: false,
23
+ }),
24
+ },
25
+ run(_a) {
26
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
27
+ const { apiKey, projectId, appId } = auth.props;
28
+ const url = `https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/engines/${appId}/servingConfigs/default_search:searchLite?key=${apiKey}`;
29
+ const body = {
30
+ query: propsValue.query,
31
+ };
32
+ if (propsValue.userPseudoId) {
33
+ body['userPseudoId'] = propsValue.userPseudoId;
34
+ }
35
+ const response = yield pieces_common_1.httpClient.sendRequest({
36
+ method: pieces_common_1.HttpMethod.POST,
37
+ url,
38
+ headers: { 'Content-Type': 'application/json' },
39
+ body,
40
+ });
41
+ return response.body;
42
+ });
43
+ },
44
+ });
45
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-search/src/lib/actions/search.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,8DAAoE;AACpE,uCAA+C;AAElC,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,wBAAgB;IACtB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,yDAAyD;IACtE,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,2BAA2B;YACxC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EACT,oFAAoF;YACtF,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAChD,MAAM,GAAG,GAAG,sDAAsD,SAAS,4DAA4D,KAAK,iDAAiD,MAAM,EAAE,CAAC;YAEtM,MAAM,IAAI,GAA4B;gBACpC,KAAK,EAAE,UAAU,CAAC,KAAK;aACxB,CAAC;YAEF,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;gBAC5B,IAAI,CAAC,cAAc,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC;YACjD,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG;gBACH,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}