@activepieces/piece-scrapeless 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,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScrapelessValidator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ class ScrapelessValidator {
7
+ static validateApiKey(apiKey) {
8
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
+ const errors = [];
10
+ if (!apiKey) {
11
+ errors.push('API key is required');
12
+ }
13
+ else if (typeof apiKey !== 'string') {
14
+ errors.push('API key must be a string');
15
+ }
16
+ const response = yield pieces_common_1.httpClient.sendRequest({
17
+ url: 'https://api.scrapeless.com/api/v1/me',
18
+ method: pieces_common_1.HttpMethod.GET,
19
+ headers: {
20
+ 'x-api-token': apiKey
21
+ }
22
+ });
23
+ if (response.status !== 200) {
24
+ errors.push('Invalid API key');
25
+ }
26
+ return {
27
+ isValid: errors.length === 0,
28
+ errors,
29
+ };
30
+ });
31
+ }
32
+ }
33
+ exports.ScrapelessValidator = ScrapelessValidator;
34
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/scrapeless/src/lib/utils/validator.ts"],"names":[],"mappings":";;;;AAAA,+DAAqE;AAGrE,MAAa,mBAAmB;IAE9B,MAAM,CAAO,cAAc,CAAC,MAAc;;YACxC,MAAM,MAAM,GAAa,EAAE,CAAC;YAE5B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACrC,CAAC;iBAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACtC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAC1C,CAAC;YAED,MAAM,QAAQ,GAAE,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC3C,GAAG,EAAE,sCAAsC;gBAC3C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,OAAO,EAAC;oBACN,aAAa,EAAC,MAAM;iBACrB;aACF,CAAC,CAAC;YAEH,IAAG,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC3B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACjC,CAAC;YACD,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;gBAC5B,MAAM;aACP,CAAC;QACJ,CAAC;KAAA;CACF;AA3BD,kDA2BC"}