@skillful-ai/piece-web 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.
@@ -0,0 +1,2 @@
1
+ export declare function getSerpApiKey(context: any): Promise<string | null>;
2
+ export declare function getGoogleApiKey(context: any): Promise<string | null>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSerpApiKey = getSerpApiKey;
4
+ exports.getGoogleApiKey = getGoogleApiKey;
5
+ const tslib_1 = require("tslib");
6
+ function getApiKey(context, config) {
7
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
+ var _a, _b;
9
+ // Priority 1: User-provided API key from connection
10
+ if ((_b = (_a = context.auth) === null || _a === void 0 ? void 0 : _a[config.authKey]) === null || _b === void 0 ? void 0 : _b.trim()) {
11
+ return context.auth[config.authKey].trim();
12
+ }
13
+ // Priority 2: Try to get from platform connection
14
+ try {
15
+ const connection = yield context.connections.get(config.platformConnectionId);
16
+ if (connection === null || connection === void 0 ? void 0 : connection[config.platformKey]) {
17
+ return connection[config.platformKey];
18
+ }
19
+ }
20
+ catch (error) {
21
+ console.warn(`Failed to retrieve platform ${config.platformKey}:`, error);
22
+ }
23
+ return null;
24
+ });
25
+ }
26
+ const API_KEY_CONFIGS = {
27
+ SERP_API: {
28
+ authKey: 'serpApiKey',
29
+ platformConnectionId: 'web_platform_default',
30
+ platformKey: 'serpApiKey',
31
+ },
32
+ GOOGLE_API: {
33
+ authKey: 'googleApiKey',
34
+ platformConnectionId: 'web_platform_default',
35
+ platformKey: 'googleApiKey',
36
+ },
37
+ };
38
+ function getSerpApiKey(context) {
39
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
40
+ return getApiKey(context, API_KEY_CONFIGS.SERP_API);
41
+ });
42
+ }
43
+ function getGoogleApiKey(context) {
44
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
45
+ return getApiKey(context, API_KEY_CONFIGS.GOOGLE_API);
46
+ });
47
+ }
48
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/custom/web/src/lib/common.ts"],"names":[],"mappings":";;AA2CA,sCAEC;AAED,0CAEC;;AA3CD,SAAe,SAAS,CACpB,OAAY,EACZ,MAAoB;;;QAEpB,oDAAoD;QACpD,IAAI,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAG,MAAM,CAAC,OAAO,CAAC,0CAAE,IAAI,EAAE,EAAE,CAAC;YACzC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;QAC9C,CAAC;QAED,kDAAkD;QAClD,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;YAC7E,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;gBACvC,OAAO,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;YACrC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,+BAA+B,MAAM,CAAC,WAAW,GAAG,EAAE,KAAK,CAAC,CAAA;QAC7E,CAAC;QAGD,OAAO,IAAI,CAAA;IACX,CAAC;CAAA;AAEL,MAAM,eAAe,GAAG;IACpB,QAAQ,EAAE;QACN,OAAO,EAAE,YAAY;QACrB,oBAAoB,EAAE,sBAAsB;QAC5C,WAAW,EAAE,YAAY;KAC5B;IACD,UAAU,EAAE;QACR,OAAO,EAAE,cAAc;QACvB,oBAAoB,EAAE,sBAAsB;QAC5C,WAAW,EAAE,cAAc;KAC9B;CACK,CAAA;AAGV,SAAsB,aAAa,CAAC,OAAY;;QAC5C,OAAO,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IACvD,CAAC;CAAA;AAED,SAAsB,eAAe,CAAC,OAAY;;QAC9C,OAAO,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,CAAA;IACzD,CAAC;CAAA"}