@activeboxes/pieces-common 0.4.0

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.
Files changed (80) hide show
  1. package/README.md +7 -0
  2. package/package.json +35 -0
  3. package/src/index.d.ts +6 -0
  4. package/src/index.js +10 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/ai/index.d.ts +94 -0
  7. package/src/lib/ai/index.js +44 -0
  8. package/src/lib/ai/index.js.map +1 -0
  9. package/src/lib/ai/providers/anthropic/index.d.ts +2 -0
  10. package/src/lib/ai/providers/anthropic/index.js +148 -0
  11. package/src/lib/ai/providers/anthropic/index.js.map +1 -0
  12. package/src/lib/ai/providers/index.d.ts +79 -0
  13. package/src/lib/ai/providers/index.js +170 -0
  14. package/src/lib/ai/providers/index.js.map +1 -0
  15. package/src/lib/ai/providers/openai/index.d.ts +22 -0
  16. package/src/lib/ai/providers/openai/index.js +224 -0
  17. package/src/lib/ai/providers/openai/index.js.map +1 -0
  18. package/src/lib/ai/providers/replicate/index.d.ts +10 -0
  19. package/src/lib/ai/providers/replicate/index.js +185 -0
  20. package/src/lib/ai/providers/replicate/index.js.map +1 -0
  21. package/src/lib/ai/providers/utils.d.ts +58 -0
  22. package/src/lib/ai/providers/utils.js +48 -0
  23. package/src/lib/ai/providers/utils.js.map +1 -0
  24. package/src/lib/authentication/index.d.ts +15 -0
  25. package/src/lib/authentication/index.js +9 -0
  26. package/src/lib/authentication/index.js.map +1 -0
  27. package/src/lib/helpers/index.d.ts +29 -0
  28. package/src/lib/helpers/index.js +101 -0
  29. package/src/lib/helpers/index.js.map +1 -0
  30. package/src/lib/http/axios/axios-http-client.d.ts +11 -0
  31. package/src/lib/http/axios/axios-http-client.js +74 -0
  32. package/src/lib/http/axios/axios-http-client.js.map +1 -0
  33. package/src/lib/http/core/base-http-client.d.ts +19 -0
  34. package/src/lib/http/core/base-http-client.js +52 -0
  35. package/src/lib/http/core/base-http-client.js.map +1 -0
  36. package/src/lib/http/core/delegating-authentication-converter.d.ts +17 -0
  37. package/src/lib/http/core/delegating-authentication-converter.js +33 -0
  38. package/src/lib/http/core/delegating-authentication-converter.js.map +1 -0
  39. package/src/lib/http/core/http-client.d.ts +9 -0
  40. package/src/lib/http/core/http-client.js +6 -0
  41. package/src/lib/http/core/http-client.js.map +1 -0
  42. package/src/lib/http/core/http-error.d.ts +33 -0
  43. package/src/lib/http/core/http-error.js +56 -0
  44. package/src/lib/http/core/http-error.js.map +1 -0
  45. package/src/lib/http/core/http-header.d.ts +6 -0
  46. package/src/lib/http/core/http-header.js +11 -0
  47. package/src/lib/http/core/http-header.js.map +1 -0
  48. package/src/lib/http/core/http-headers.d.ts +1 -0
  49. package/src/lib/http/core/http-headers.js +3 -0
  50. package/src/lib/http/core/http-headers.js.map +1 -0
  51. package/src/lib/http/core/http-message-body.d.ts +1 -0
  52. package/src/lib/http/core/http-message-body.js +3 -0
  53. package/src/lib/http/core/http-message-body.js.map +1 -0
  54. package/src/lib/http/core/http-method.d.ts +8 -0
  55. package/src/lib/http/core/http-method.js +13 -0
  56. package/src/lib/http/core/http-method.js.map +1 -0
  57. package/src/lib/http/core/http-request-body.d.ts +2 -0
  58. package/src/lib/http/core/http-request-body.js +3 -0
  59. package/src/lib/http/core/http-request-body.js.map +1 -0
  60. package/src/lib/http/core/http-request.d.ts +17 -0
  61. package/src/lib/http/core/http-request.js +3 -0
  62. package/src/lib/http/core/http-request.js.map +1 -0
  63. package/src/lib/http/core/http-response.d.ts +7 -0
  64. package/src/lib/http/core/http-response.js +3 -0
  65. package/src/lib/http/core/http-response.js.map +1 -0
  66. package/src/lib/http/core/media-type.d.ts +4 -0
  67. package/src/lib/http/core/media-type.js +9 -0
  68. package/src/lib/http/core/media-type.js.map +1 -0
  69. package/src/lib/http/core/query-params.d.ts +1 -0
  70. package/src/lib/http/core/query-params.js +3 -0
  71. package/src/lib/http/core/query-params.js.map +1 -0
  72. package/src/lib/http/index.d.ts +13 -0
  73. package/src/lib/http/index.js +17 -0
  74. package/src/lib/http/index.js.map +1 -0
  75. package/src/lib/polling/index.d.ts +57 -0
  76. package/src/lib/polling/index.js +136 -0
  77. package/src/lib/polling/index.js.map +1 -0
  78. package/src/lib/validation/index.d.ts +4 -0
  79. package/src/lib/validation/index.js +26 -0
  80. package/src/lib/validation/index.js.map +1 -0
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAccessTokenOrThrow = void 0;
4
+ exports.createCustomApiCallAction = createCustomApiCallAction;
5
+ const tslib_1 = require("tslib");
6
+ const pieces_framework_1 = require("@activeboxes/pieces-framework");
7
+ const http_1 = require("../http");
8
+ const shared_1 = require("@activeboxes/shared");
9
+ const getAccessTokenOrThrow = (auth) => {
10
+ const accessToken = auth === null || auth === void 0 ? void 0 : auth.access_token;
11
+ if (accessToken === undefined) {
12
+ throw new Error('Invalid bearer token');
13
+ }
14
+ return accessToken;
15
+ };
16
+ exports.getAccessTokenOrThrow = getAccessTokenOrThrow;
17
+ const joinBaseUrlWithRelativePath = ({ baseUrl, relativePath }) => {
18
+ const baseUrlWithSlash = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
19
+ const relativePathWithoutSlash = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;
20
+ return `${baseUrlWithSlash}${relativePathWithoutSlash}`;
21
+ };
22
+ const getBaseUrlForDescription = (baseUrl, auth) => {
23
+ const exampleBaseUrl = `https://api.example.com`;
24
+ try {
25
+ const baseUrlValue = auth ? baseUrl(auth) : undefined;
26
+ const baseUrlValueWithoutTrailingSlash = (baseUrlValue === null || baseUrlValue === void 0 ? void 0 : baseUrlValue.endsWith('/')) ? baseUrlValue.slice(0, -1) : baseUrlValue;
27
+ return baseUrlValueWithoutTrailingSlash !== null && baseUrlValueWithoutTrailingSlash !== void 0 ? baseUrlValueWithoutTrailingSlash : exampleBaseUrl;
28
+ }
29
+ //If baseUrl fails we stil want to return a valid baseUrl for description
30
+ catch (error) {
31
+ {
32
+ return exampleBaseUrl;
33
+ }
34
+ }
35
+ };
36
+ function createCustomApiCallAction({ auth, baseUrl, authMapping, description, displayName, name, props, extraProps, }) {
37
+ var _a, _b, _c, _d, _e, _f;
38
+ return (0, pieces_framework_1.createAction)({
39
+ name: name ? name : 'custom_api_call',
40
+ displayName: displayName ? displayName : 'Custom API Call',
41
+ description: description
42
+ ? description
43
+ : 'Make a custom API call to a specific endpoint',
44
+ auth: auth ? auth : undefined,
45
+ requireAuth: auth ? true : false,
46
+ props: Object.assign({ url: pieces_framework_1.Property.DynamicProperties({
47
+ displayName: '',
48
+ required: true,
49
+ refreshers: [],
50
+ props: (_a) => tslib_1.__awaiter(this, [_a], void 0, function* ({ auth }) {
51
+ var _b;
52
+ return {
53
+ url: pieces_framework_1.Property.ShortText(Object.assign({ displayName: 'URL', description: `You can either use the full URL or the relative path to the base URL
54
+ i.e ${getBaseUrlForDescription(baseUrl, auth)}/resource or /resource`, required: true, defaultValue: baseUrl(auth) }, ((_b = props === null || props === void 0 ? void 0 : props.url) !== null && _b !== void 0 ? _b : {}))),
55
+ };
56
+ }),
57
+ }), method: pieces_framework_1.Property.StaticDropdown(Object.assign({ displayName: 'Method', required: true, options: {
58
+ options: Object.values(http_1.HttpMethod).map((v) => {
59
+ return {
60
+ label: v,
61
+ value: v,
62
+ };
63
+ }),
64
+ } }, ((_a = props === null || props === void 0 ? void 0 : props.method) !== null && _a !== void 0 ? _a : {}))), headers: pieces_framework_1.Property.Object(Object.assign({ displayName: 'Headers', description: 'Authorization headers are injected automatically from your connection.', required: true }, ((_b = props === null || props === void 0 ? void 0 : props.headers) !== null && _b !== void 0 ? _b : {}))), queryParams: pieces_framework_1.Property.Object(Object.assign({ displayName: 'Query Parameters', required: true }, ((_c = props === null || props === void 0 ? void 0 : props.queryParams) !== null && _c !== void 0 ? _c : {}))), body: pieces_framework_1.Property.Json(Object.assign({ displayName: 'Body', required: false }, ((_d = props === null || props === void 0 ? void 0 : props.body) !== null && _d !== void 0 ? _d : {}))), failsafe: pieces_framework_1.Property.Checkbox(Object.assign({ displayName: 'No Error on Failure', required: false }, ((_e = props === null || props === void 0 ? void 0 : props.failsafe) !== null && _e !== void 0 ? _e : {}))), timeout: pieces_framework_1.Property.Number(Object.assign({ displayName: 'Timeout (in seconds)', required: false }, ((_f = props === null || props === void 0 ? void 0 : props.timeout) !== null && _f !== void 0 ? _f : {}))) }, extraProps),
65
+ run: (context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
66
+ const { method, url, headers, queryParams, body, failsafe, timeout } = context.propsValue;
67
+ (0, shared_1.assertNotNullOrUndefined)(method, 'Method');
68
+ (0, shared_1.assertNotNullOrUndefined)(url, 'URL');
69
+ let headersValue = headers;
70
+ if (authMapping) {
71
+ const headers = yield authMapping(context.auth, context.propsValue);
72
+ if (headers) {
73
+ headersValue = Object.assign(Object.assign({}, headersValue), headers);
74
+ }
75
+ }
76
+ const urlValue = url['url'];
77
+ const fullUrl = urlValue.startsWith('http://') || urlValue.startsWith('https://') ? urlValue :
78
+ joinBaseUrlWithRelativePath({ baseUrl: baseUrl(context.auth), relativePath: urlValue });
79
+ const request = {
80
+ method,
81
+ url: fullUrl,
82
+ headers: headersValue,
83
+ queryParams: queryParams,
84
+ timeout: timeout ? timeout * 1000 : 0,
85
+ };
86
+ if (body) {
87
+ request.body = body;
88
+ }
89
+ try {
90
+ return yield http_1.httpClient.sendRequest(request);
91
+ }
92
+ catch (error) {
93
+ if (failsafe) {
94
+ return error.errorMessage();
95
+ }
96
+ throw error;
97
+ }
98
+ }),
99
+ });
100
+ }
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/common/src/lib/helpers/index.ts"],"names":[],"mappings":";;;AAmDA,8DA+IC;;AAlMD,oEAQuC;AACvC,kCAOiB;AACjB,gDAA+D;AAExD,MAAM,qBAAqB,GAAG,CACnC,IAAqC,EAC7B,EAA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C;YAC/C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,QAAQ,EAAE,CAAC;oBACb,OAAQ,KAAmB,CAAC,YAAY,EAAE,CAAC;gBAC7C,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAA;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { DelegatingAuthenticationConverter } from '../core/delegating-authentication-converter';
2
+ import { BaseHttpClient } from '../core/base-http-client';
3
+ import { HttpMessageBody } from '../core/http-message-body';
4
+ import { HttpRequest } from '../core/http-request';
5
+ import { HttpResponse } from '../core/http-response';
6
+ import { HttpRequestBody } from '../core/http-request-body';
7
+ export declare class AxiosHttpClient extends BaseHttpClient {
8
+ constructor(baseUrl?: string, authenticationConverter?: DelegatingAuthenticationConverter);
9
+ sendRequest<ResponseBody extends HttpMessageBody = any>(request: HttpRequest<HttpRequestBody>): Promise<HttpResponse<ResponseBody>>;
10
+ private getAxiosRequestMethod;
11
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AxiosHttpClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const axios_retry_1 = tslib_1.__importDefault(require("axios-retry"));
7
+ const delegating_authentication_converter_1 = require("../core/delegating-authentication-converter");
8
+ const base_http_client_1 = require("../core/base-http-client");
9
+ const http_error_1 = require("../core/http-error");
10
+ const https = tslib_1.__importStar(require("node:https"));
11
+ class AxiosHttpClient extends base_http_client_1.BaseHttpClient {
12
+ constructor(baseUrl = '', authenticationConverter = new delegating_authentication_converter_1.DelegatingAuthenticationConverter()) {
13
+ super(baseUrl, authenticationConverter);
14
+ }
15
+ sendRequest(request) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ var _a, _b;
18
+ try {
19
+ const { urlWithoutQueryParams, queryParams: urlQueryParams } = this.getUrl(request);
20
+ const headers = this.getHeaders(request);
21
+ const axiosRequestMethod = this.getAxiosRequestMethod(request.method);
22
+ const timeout = request.timeout ? request.timeout : 0;
23
+ const queryParams = request.queryParams || {};
24
+ const responseType = request.responseType || 'json';
25
+ const axiosInstance = axios_1.default.create({
26
+ httpsAgent: new https.Agent({
27
+ rejectUnauthorized: request.rejectUnauthorized,
28
+ })
29
+ });
30
+ for (const [key, value] of urlQueryParams) {
31
+ queryParams[key] = value;
32
+ }
33
+ const config = {
34
+ method: axiosRequestMethod,
35
+ url: urlWithoutQueryParams,
36
+ params: queryParams,
37
+ headers,
38
+ data: request.body,
39
+ timeout,
40
+ responseType,
41
+ };
42
+ if (request.retries && request.retries > 0) {
43
+ (0, axios_retry_1.default)(axiosInstance, {
44
+ retries: request.retries,
45
+ retryDelay: axios_retry_1.default.exponentialDelay,
46
+ retryCondition: (error) => {
47
+ return axios_retry_1.default.isNetworkOrIdempotentRequestError(error) || (error.response && error.response.status >= 500) || false;
48
+ },
49
+ });
50
+ }
51
+ const response = yield axiosInstance.request(config);
52
+ return {
53
+ status: response.status,
54
+ headers: response.headers,
55
+ body: response.data,
56
+ };
57
+ }
58
+ catch (e) {
59
+ console.error('[HttpClient#sendRequest] error:', e);
60
+ if (axios_1.default.isAxiosError(e)) {
61
+ console.error('[HttpClient#sendRequest] error, responseStatus:', (_a = e.response) === null || _a === void 0 ? void 0 : _a.status);
62
+ console.error('[HttpClient#sendRequest] error, responseBody:', JSON.stringify((_b = e.response) === null || _b === void 0 ? void 0 : _b.data));
63
+ throw new http_error_1.HttpError(request.body, e);
64
+ }
65
+ throw e;
66
+ }
67
+ });
68
+ }
69
+ getAxiosRequestMethod(httpMethod) {
70
+ return httpMethod.toString();
71
+ }
72
+ }
73
+ exports.AxiosHttpClient = AxiosHttpClient;
74
+ //# sourceMappingURL=axios-http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-http-client.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http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gBAED,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;KAAA;IAEO,qBAAqB,CAAC,UAAsB;QAClD,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF;AA9ED,0CA8EC"}
@@ -0,0 +1,19 @@
1
+ import { DelegatingAuthenticationConverter } from './delegating-authentication-converter';
2
+ import type { HttpClient } from './http-client';
3
+ import type { HttpHeaders } from './http-headers';
4
+ import type { HttpMessageBody } from './http-message-body';
5
+ import type { HttpRequest } from './http-request';
6
+ import { HttpRequestBody } from './http-request-body';
7
+ import { HttpResponse } from './http-response';
8
+ export declare abstract class BaseHttpClient implements HttpClient {
9
+ private readonly baseUrl;
10
+ private readonly authenticationConverter;
11
+ constructor(baseUrl: string, authenticationConverter: DelegatingAuthenticationConverter);
12
+ abstract sendRequest<RequestBody extends HttpMessageBody, ResponseBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): Promise<HttpResponse<ResponseBody>>;
13
+ protected getUrl<RequestBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): {
14
+ urlWithoutQueryParams: string;
15
+ queryParams: URLSearchParams;
16
+ };
17
+ protected getHeaders<RequestBody extends HttpRequestBody>(request: HttpRequest<RequestBody>): HttpHeaders;
18
+ private populateAuthentication;
19
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseHttpClient = void 0;
4
+ const http_header_1 = require("./http-header");
5
+ const media_type_1 = require("./media-type");
6
+ class BaseHttpClient {
7
+ constructor(baseUrl, authenticationConverter) {
8
+ this.baseUrl = baseUrl;
9
+ this.authenticationConverter = authenticationConverter;
10
+ }
11
+ getUrl(request) {
12
+ const url = new URL(`${this.baseUrl}${request.url}`);
13
+ const urlWithoutQueryParams = `${url.origin}${url.pathname}`;
14
+ const queryParams = new URLSearchParams();
15
+ // Extract query parameters
16
+ url.searchParams.forEach((value, key) => {
17
+ queryParams.append(key, value);
18
+ });
19
+ return {
20
+ urlWithoutQueryParams,
21
+ queryParams,
22
+ };
23
+ }
24
+ getHeaders(request) {
25
+ var _a;
26
+ let requestHeaders = {
27
+ [http_header_1.HttpHeader.ACCEPT]: media_type_1.MediaType.APPLICATION_JSON,
28
+ };
29
+ if (request.authentication) {
30
+ this.populateAuthentication(request.authentication, requestHeaders);
31
+ }
32
+ if (request.body) {
33
+ switch ((_a = request.headers) === null || _a === void 0 ? void 0 : _a['Content-Type']) {
34
+ case 'text/csv':
35
+ requestHeaders[http_header_1.HttpHeader.CONTENT_TYPE] = media_type_1.MediaType.TEXT_CSV;
36
+ break;
37
+ default:
38
+ requestHeaders[http_header_1.HttpHeader.CONTENT_TYPE] = media_type_1.MediaType.APPLICATION_JSON;
39
+ break;
40
+ }
41
+ }
42
+ if (request.headers) {
43
+ requestHeaders = Object.assign(Object.assign({}, requestHeaders), request.headers);
44
+ }
45
+ return requestHeaders;
46
+ }
47
+ populateAuthentication(authentication, headers) {
48
+ this.authenticationConverter.convert(authentication, headers);
49
+ }
50
+ }
51
+ exports.BaseHttpClient = BaseHttpClient;
52
+ //# sourceMappingURL=base-http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-http-client.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/base-http-client.ts"],"names":[],"mappings":";;;AAGA,+CAA2C;AAM3C,6CAAyC;AAEzC,MAAsB,cAAc;IAClC,YACmB,OAAe,EACf,uBAA0D;QAD1D,YAAO,GAAP,OAAO,CAAQ;QACf,4BAAuB,GAAvB,uBAAuB,CAAmC;IAC1E,CAAC;IAOM,MAAM,CACd,OAAiC;QAKjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrD,MAAM,qBAAqB,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC7D,MAAM,WAAW,GAA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uthentication, BearerTokenAuthentication } from '../../authentication';
3
+ export declare class DelegatingAuthenticationConverter implements AuthenticationConverter<Authentication> {
4
+ private readonly converters;
5
+ constructor(bearerTokenConverter?: BearerTokenAuthenticationConverter, basicTokenConverter?: BasicTokenAuthenticationConverter);
6
+ convert(authentication: Authentication, headers: HttpHeaders): HttpHeaders;
7
+ }
8
+ declare class BearerTokenAuthenticationConverter implements AuthenticationConverter<BearerTokenAuthentication> {
9
+ convert(authentication: BearerTokenAuthentication, headers: HttpHeaders): HttpHeaders;
10
+ }
11
+ declare class BasicTokenAuthenticationConverter implements AuthenticationConverter<BasicAuthentication> {
12
+ convert(authentication: BasicAuthentication, headers: HttpHeaders): HttpHeaders;
13
+ }
14
+ type AuthenticationConverter<T extends Authentication> = {
15
+ convert: (authentication: T, headers: HttpHeaders) => HttpHeaders;
16
+ };
17
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatingAuthenticationConverter = void 0;
4
+ const http_header_1 = require("./http-header");
5
+ const authentication_1 = require("../../authentication");
6
+ class DelegatingAuthenticationConverter {
7
+ constructor(bearerTokenConverter = new BearerTokenAuthenticationConverter(), basicTokenConverter = new BasicTokenAuthenticationConverter()) {
8
+ this.converters = {
9
+ [authentication_1.AuthenticationType.BEARER_TOKEN]: bearerTokenConverter,
10
+ [authentication_1.AuthenticationType.BASIC]: basicTokenConverter,
11
+ };
12
+ }
13
+ convert(authentication, headers) {
14
+ const converter = this.converters[authentication.type];
15
+ return converter.convert(authentication, headers);
16
+ }
17
+ }
18
+ exports.DelegatingAuthenticationConverter = DelegatingAuthenticationConverter;
19
+ class BearerTokenAuthenticationConverter {
20
+ convert(authentication, headers) {
21
+ headers[http_header_1.HttpHeader.AUTHORIZATION] = `Bearer ${authentication.token}`;
22
+ return headers;
23
+ }
24
+ }
25
+ class BasicTokenAuthenticationConverter {
26
+ convert(authentication, headers) {
27
+ const credentials = `${authentication.username}:${authentication.password}`;
28
+ const encoded = Buffer.from(credentials).toString('base64');
29
+ headers[http_header_1.HttpHeader.AUTHORIZATION] = `Basic ${encoded}`;
30
+ return headers;
31
+ }
32
+ }
33
+ //# sourceMappingURL=delegating-authentication-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegating-authentication-converter.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/delegating-authentication-converter.ts"],"names":[],"mappings":";;;AACA,+CAA2C;AAC3C,yDAK8B;AAE9B,MAAa,iCAAiC;IAQ5C,YACE,oBAAoB,GAAG,IAAI,kCAAkC,EAAE,EAC/D,mBAAmB,GAAG,IAAI,iCAAiC,EAAE;QAE7D,IAAI,CAAC,UAAU,GAAG;YAChB,CAAC,mCAAkB,CAAC,YAAY,CAAC,EAAE,oBAAoB;YACvD,CAAC,mCAAkB,CAAC,KAAK,CAAC,EAAE,mBAAmB;SAChD,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,cAA8B,EAAE,OAAoB;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACvD,OAAO,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF;AAtBD,8EAsBC;AAED,MAAM,kCAAkC;IAGtC,OAAO,CACL,cAAyC,EACzC,OAAoB;QAEpB,OAAO,CAAC,wBAAU,CAAC,aAAa,CAAC,GAAG,UAAU,cAAc,CAAC,KAAK,EAAE,CAAC;QACrE,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,MAAM,iCAAiC;IAGrC,OAAO,CACL,cAAmC,EACnC,OAAoB;QAEpB,MAAM,WAAW,GAAG,GAAG,cAAc,CAAC,QAAQ,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC5E,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,CAAC,wBAAU,CAAC,aAAa,CAAC,GAAG,SAAS,OAAO,EAAE,CAAC;QACvD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { AxiosHttpClient } from '../axios/axios-http-client';
2
+ import type { HttpMessageBody } from './http-message-body';
3
+ import type { HttpRequest } from './http-request';
4
+ import { HttpRequestBody } from './http-request-body';
5
+ import { HttpResponse } from './http-response';
6
+ export type HttpClient = {
7
+ sendRequest<RequestBody extends HttpRequestBody, ResponseBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): Promise<HttpResponse<ResponseBody>>;
8
+ };
9
+ export declare const httpClient: AxiosHttpClient;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpClient = void 0;
4
+ const axios_http_client_1 = require("../axios/axios-http-client");
5
+ exports.httpClient = new axios_http_client_1.AxiosHttpClient();
6
+ //# sourceMappingURL=http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-client.ts"],"names":[],"mappings":";;;AAAA,kEAA6D;AAehD,QAAA,UAAU,GAAG,IAAI,mCAAe,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { AxiosError } from 'axios';
2
+ export declare class HttpError extends Error {
3
+ private readonly requestBody;
4
+ private readonly errorString;
5
+ private readonly errorCode;
6
+ private readonly status;
7
+ private readonly responseBody;
8
+ constructor(requestBody: unknown, err: AxiosError);
9
+ errorMessage(): {
10
+ response: {
11
+ status: number;
12
+ body: unknown;
13
+ };
14
+ request: {
15
+ body: unknown;
16
+ };
17
+ error: {
18
+ message: string;
19
+ code: string | undefined;
20
+ };
21
+ };
22
+ get response(): {
23
+ status: number;
24
+ body: unknown;
25
+ };
26
+ get request(): {
27
+ body: unknown;
28
+ };
29
+ get error(): {
30
+ message: string;
31
+ code: string | undefined;
32
+ };
33
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpError = void 0;
4
+ class HttpError extends Error {
5
+ constructor(requestBody, err) {
6
+ var _a, _b;
7
+ const message = err === null || err === void 0 ? void 0 : err.message;
8
+ const code = err === null || err === void 0 ? void 0 : err.code;
9
+ const status = ((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
10
+ const responseBody = (_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.data;
11
+ super(JSON.stringify({
12
+ response: {
13
+ status: status,
14
+ body: responseBody,
15
+ },
16
+ request: {
17
+ body: requestBody,
18
+ },
19
+ error: {
20
+ message: message,
21
+ code: code,
22
+ },
23
+ }));
24
+ this.requestBody = requestBody;
25
+ this.errorString = message;
26
+ this.errorCode = code;
27
+ this.status = status;
28
+ this.responseBody = responseBody;
29
+ }
30
+ errorMessage() {
31
+ return {
32
+ response: this.response,
33
+ request: this.request,
34
+ error: this.error,
35
+ };
36
+ }
37
+ get response() {
38
+ return {
39
+ status: this.status,
40
+ body: this.responseBody,
41
+ };
42
+ }
43
+ get request() {
44
+ return {
45
+ body: this.requestBody,
46
+ };
47
+ }
48
+ get error() {
49
+ return {
50
+ message: this.errorString,
51
+ code: this.errorCode,
52
+ };
53
+ }
54
+ }
55
+ exports.HttpError = HttpError;
56
+ //# sourceMappingURL=http-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-error.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-error.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAU,SAAQ,KAAK;IAMlC,YAA6B,WAAoB,EAAE,GAAe;;QAChE,MAAM,OAAO,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC;QAC7B,MAAM,IAAI,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,I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ttpHeader {
2
+ AUTHORIZATION = "Authorization",
3
+ ACCEPT = "Accept",
4
+ API_KEY = "Api-Key",
5
+ CONTENT_TYPE = "Content-Type"
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpHeader = void 0;
4
+ var HttpHeader;
5
+ (function (HttpHeader) {
6
+ HttpHeader["AUTHORIZATION"] = "Authorization";
7
+ HttpHeader["ACCEPT"] = "Accept";
8
+ HttpHeader["API_KEY"] = "Api-Key";
9
+ HttpHeader["CONTENT_TYPE"] = "Content-Type";
10
+ })(HttpHeader || (exports.HttpHeader = HttpHeader = {}));
11
+ //# sourceMappingURL=http-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-header.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-header.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6CAA+B,CAAA;IAC/B,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,2CAA6B,CAAA;AAC/B,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
@@ -0,0 +1 @@
1
+ export type HttpHeaders = Record<string, string | string[] | undefined>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=http-headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-headers.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-headers.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export type HttpMessageBody = any;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=http-message-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-message-body.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-message-body.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export declare enum HttpMethod {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ PATCH = "PATCH",
5
+ PUT = "PUT",
6
+ DELETE = "DELETE",
7
+ HEAD = "HEAD"
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpMethod = void 0;
4
+ var HttpMethod;
5
+ (function (HttpMethod) {
6
+ HttpMethod["GET"] = "GET";
7
+ HttpMethod["POST"] = "POST";
8
+ HttpMethod["PATCH"] = "PATCH";
9
+ HttpMethod["PUT"] = "PUT";
10
+ HttpMethod["DELETE"] = "DELETE";
11
+ HttpMethod["HEAD"] = "HEAD";
12
+ })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
13
+ //# sourceMappingURL=http-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-method.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-method.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACf,CAAC,EAPW,UAAU,0BAAV,UAAU,QAOrB"}
@@ -0,0 +1,2 @@
1
+ import { HttpMessageBody } from "./http-message-body";
2
+ export type HttpRequestBody = HttpMessageBody | string;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=http-request-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-request-body.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-request-body.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { HttpMethod } from './http-method';
2
+ import type { QueryParams } from './query-params';
3
+ import { HttpHeaders } from './http-headers';
4
+ import { Authentication } from '../../authentication';
5
+ import { HttpRequestBody } from './http-request-body';
6
+ export type HttpRequest<RequestBody extends HttpRequestBody = any> = {
7
+ method: HttpMethod;
8
+ url: string;
9
+ body?: RequestBody | undefined;
10
+ headers?: HttpHeaders;
11
+ authentication?: Authentication | undefined;
12
+ queryParams?: QueryParams | undefined;
13
+ timeout?: number;
14
+ retries?: number;
15
+ responseType?: 'arraybuffer' | 'json' | 'blob' | 'text';
16
+ rejectUnauthorized?: boolean;
17
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=http-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-request.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-request.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { HttpMessageBody } from './http-message-body';
2
+ import { HttpHeaders } from './http-headers';
3
+ export type HttpResponse<RequestBody extends HttpMessageBody = any> = {
4
+ status: number;
5
+ headers?: HttpHeaders | undefined;
6
+ body: RequestBody;
7
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=http-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-response.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/http-response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export declare enum MediaType {
2
+ APPLICATION_JSON = "application/json",
3
+ TEXT_CSV = "text/csv"
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MediaType = void 0;
4
+ var MediaType;
5
+ (function (MediaType) {
6
+ MediaType["APPLICATION_JSON"] = "application/json";
7
+ MediaType["TEXT_CSV"] = "text/csv";
8
+ })(MediaType || (exports.MediaType = MediaType = {}));
9
+ //# sourceMappingURL=media-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-type.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/community/common/src/lib/http/core/media-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,kDAAqC,CAAA;IACrC,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB"}
@@ -0,0 +1 @@
1
+ export type QueryParams = Record<string, string>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=query-params.js.map