@activepieces/pieces-common 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.
Files changed (59) hide show
  1. package/README.md +7 -0
  2. package/package.json +15 -0
  3. package/src/index.d.ts +4 -0
  4. package/src/index.js +8 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/authentication/index.d.ts +15 -0
  7. package/src/lib/authentication/index.js +9 -0
  8. package/src/lib/authentication/index.js.map +1 -0
  9. package/src/lib/helpers/assertions.d.ts +2 -0
  10. package/src/lib/helpers/assertions.js +14 -0
  11. package/src/lib/helpers/assertions.js.map +1 -0
  12. package/src/lib/helpers/index.d.ts +3 -0
  13. package/src/lib/helpers/index.js +14 -0
  14. package/src/lib/helpers/index.js.map +1 -0
  15. package/src/lib/http/axios/axios-http-client.d.ts +12 -0
  16. package/src/lib/http/axios/axios-http-client.js +49 -0
  17. package/src/lib/http/axios/axios-http-client.js.map +1 -0
  18. package/src/lib/http/core/base-http-client.d.ts +15 -0
  19. package/src/lib/http/core/base-http-client.js +41 -0
  20. package/src/lib/http/core/base-http-client.js.map +1 -0
  21. package/src/lib/http/core/delegating-authentication-converter.d.ts +17 -0
  22. package/src/lib/http/core/delegating-authentication-converter.js +33 -0
  23. package/src/lib/http/core/delegating-authentication-converter.js.map +1 -0
  24. package/src/lib/http/core/http-client.d.ts +8 -0
  25. package/src/lib/http/core/http-client.js +6 -0
  26. package/src/lib/http/core/http-client.js.map +1 -0
  27. package/src/lib/http/core/http-error.d.ts +13 -0
  28. package/src/lib/http/core/http-error.js +33 -0
  29. package/src/lib/http/core/http-error.js.map +1 -0
  30. package/src/lib/http/core/http-header.d.ts +5 -0
  31. package/src/lib/http/core/http-header.js +10 -0
  32. package/src/lib/http/core/http-header.js.map +1 -0
  33. package/src/lib/http/core/http-headers.d.ts +1 -0
  34. package/src/lib/http/core/http-headers.js +3 -0
  35. package/src/lib/http/core/http-headers.js.map +1 -0
  36. package/src/lib/http/core/http-message-body.d.ts +1 -0
  37. package/src/lib/http/core/http-message-body.js +3 -0
  38. package/src/lib/http/core/http-message-body.js.map +1 -0
  39. package/src/lib/http/core/http-method.d.ts +8 -0
  40. package/src/lib/http/core/http-method.js +13 -0
  41. package/src/lib/http/core/http-method.js.map +1 -0
  42. package/src/lib/http/core/http-request.d.ts +13 -0
  43. package/src/lib/http/core/http-request.js +3 -0
  44. package/src/lib/http/core/http-request.js.map +1 -0
  45. package/src/lib/http/core/http-response.d.ts +7 -0
  46. package/src/lib/http/core/http-response.js +3 -0
  47. package/src/lib/http/core/http-response.js.map +1 -0
  48. package/src/lib/http/core/media-type.d.ts +3 -0
  49. package/src/lib/http/core/media-type.js +8 -0
  50. package/src/lib/http/core/media-type.js.map +1 -0
  51. package/src/lib/http/core/query-params.d.ts +1 -0
  52. package/src/lib/http/core/query-params.js +3 -0
  53. package/src/lib/http/core/query-params.js.map +1 -0
  54. package/src/lib/http/index.d.ts +13 -0
  55. package/src/lib/http/index.js +17 -0
  56. package/src/lib/http/index.js.map +1 -0
  57. package/src/lib/polling/index.d.ts +44 -0
  58. package/src/lib/polling/index.js +87 -0
  59. package/src/lib/polling/index.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-common
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-common` to build the library.
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@activepieces/pieces-common",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "dependencies": {
6
+ "@sinclair/typebox": "0.26.8",
7
+ "axios": "1.2.4",
8
+ "nanoid": "3.3.4",
9
+ "@activepieces/pieces-framework": "0.3.13",
10
+ "@activepieces/shared": "0.3.11",
11
+ "tslib": "2.4.1"
12
+ },
13
+ "main": "./src/index.js",
14
+ "types": "./src/index.d.ts"
15
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './lib/authentication';
2
+ export * from './lib/helpers';
3
+ export * from './lib/http';
4
+ export * from './lib/polling';
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/authentication"), exports);
5
+ tslib_1.__exportStar(require("./lib/helpers"), exports);
6
+ tslib_1.__exportStar(require("./lib/http"), exports);
7
+ tslib_1.__exportStar(require("./lib/polling"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/common/src/index.ts"],"names":[],"mappings":";;;AAAA,+DAAoC;AACpC,wDAA6B;AAC7B,qDAA0B;AAC1B,wDAA8B"}
@@ -0,0 +1,15 @@
1
+ export declare type Authentication = BearerTokenAuthentication | BasicAuthentication;
2
+ export declare enum AuthenticationType {
3
+ BEARER_TOKEN = "BEARER_TOKEN",
4
+ BASIC = "BASIC"
5
+ }
6
+ export declare type BaseAuthentication<T extends AuthenticationType> = {
7
+ type: T;
8
+ };
9
+ export declare type BearerTokenAuthentication = BaseAuthentication<AuthenticationType.BEARER_TOKEN> & {
10
+ token: string;
11
+ };
12
+ export declare type BasicAuthentication = BaseAuthentication<AuthenticationType.BASIC> & {
13
+ username: string;
14
+ password: string;
15
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthenticationType = void 0;
4
+ var AuthenticationType;
5
+ (function (AuthenticationType) {
6
+ AuthenticationType["BEARER_TOKEN"] = "BEARER_TOKEN";
7
+ AuthenticationType["BASIC"] = "BASIC";
8
+ })(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/common/src/lib/authentication/index.ts"],"names":[],"mappings":";;;AAEA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,mDAA6B,CAAA;IAC7B,qCAAe,CAAA;AAChB,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B"}
@@ -0,0 +1,2 @@
1
+ export declare function assertNotNullOrUndefined<T>(value: T | null | undefined, fieldName: string): asserts value is T;
2
+ export declare const isNotUndefined: <T>(value: T | undefined) => value is T;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNotUndefined = exports.assertNotNullOrUndefined = void 0;
4
+ function assertNotNullOrUndefined(value, fieldName) {
5
+ if (value === null || value === undefined) {
6
+ throw new Error(`${fieldName} is null or undefined`);
7
+ }
8
+ }
9
+ exports.assertNotNullOrUndefined = assertNotNullOrUndefined;
10
+ const isNotUndefined = (value) => {
11
+ return value !== undefined;
12
+ };
13
+ exports.isNotUndefined = isNotUndefined;
14
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/common/src/lib/helpers/assertions.ts"],"names":[],"mappings":";;;AAAA,SAAgB,wBAAwB,CACtC,KAA2B,EAC3B,SAAiB;IAEjB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,uBAAuB,CAAC,CAAC;KACtD;AACH,CAAC;AAPD,4DAOC;AAEM,MAAM,cAAc,GAAG,CAAI,KAAoB,EAAc,EAAE;IACpE,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B"}
@@ -0,0 +1,3 @@
1
+ import { OAuth2PropertyValue } from "@activepieces/pieces-framework";
2
+ export declare const getAccessTokenOrThrow: (auth: OAuth2PropertyValue | undefined) => string;
3
+ export * from './assertions';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAccessTokenOrThrow = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const getAccessTokenOrThrow = (auth) => {
6
+ const accessToken = auth === null || auth === void 0 ? void 0 : auth.access_token;
7
+ if (accessToken === undefined) {
8
+ throw new Error("Invalid bearer token");
9
+ }
10
+ return accessToken;
11
+ };
12
+ exports.getAccessTokenOrThrow = getAccessTokenOrThrow;
13
+ tslib_1.__exportStar(require("./assertions"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/common/src/lib/helpers/index.ts"],"names":[],"mappings":";;;;AAEO,MAAM,qBAAqB,GAAG,CAAC,IAAqC,EAAU,EAAE;IACrF,MAAM,WAAW,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC;IAEvC,IAAI,WAAW,KAAK,SAAS,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC;AAEF,uDAA4B"}
@@ -0,0 +1,12 @@
1
+ import { AxiosStatic } from 'axios';
2
+ import { DelegatingAuthenticationConverter } from '../core/delegating-authentication-converter';
3
+ import { BaseHttpClient } from '../core/base-http-client';
4
+ import { HttpMessageBody } from '../core/http-message-body';
5
+ import { HttpRequest } from '../core/http-request';
6
+ import { HttpResponse } from '../core/http-response';
7
+ export declare class AxiosHttpClient extends BaseHttpClient {
8
+ private readonly client;
9
+ constructor(baseUrl?: string, authenticationConverter?: DelegatingAuthenticationConverter, client?: AxiosStatic);
10
+ sendRequest<ResponseBody extends HttpMessageBody>(request: HttpRequest<HttpMessageBody>): Promise<HttpResponse<ResponseBody>>;
11
+ private getAxiosRequestMethod;
12
+ }
@@ -0,0 +1,49 @@
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 delegating_authentication_converter_1 = require("../core/delegating-authentication-converter");
7
+ const base_http_client_1 = require("../core/base-http-client");
8
+ const http_error_1 = require("../core/http-error");
9
+ class AxiosHttpClient extends base_http_client_1.BaseHttpClient {
10
+ constructor(baseUrl = '', authenticationConverter = new delegating_authentication_converter_1.DelegatingAuthenticationConverter(), client = axios_1.default) {
11
+ super(baseUrl, authenticationConverter);
12
+ this.client = client;
13
+ }
14
+ sendRequest(request) {
15
+ var _a, _b;
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ try {
18
+ const url = this.getUrl(request);
19
+ const headers = this.getHeaders(request);
20
+ const axiosRequestMethod = this.getAxiosRequestMethod(request.method);
21
+ const response = yield axios_1.default.request({
22
+ method: axiosRequestMethod,
23
+ url,
24
+ headers,
25
+ data: request.body,
26
+ });
27
+ return {
28
+ status: response.status,
29
+ headers: response.headers,
30
+ body: response.data,
31
+ };
32
+ }
33
+ catch (e) {
34
+ if (axios_1.default.isAxiosError(e)) {
35
+ console.error('[HttpClient#sendRequest] error, responseStatus:', (_a = e.response) === null || _a === void 0 ? void 0 : _a.status);
36
+ console.error('[HttpClient#sendRequest] error, responseBody:', (_b = e.response) === null || _b === void 0 ? void 0 : _b.data);
37
+ throw new http_error_1.HttpError(request.body, e);
38
+ }
39
+ console.error('[HttpClient#sendRequest] error:', e);
40
+ throw e;
41
+ }
42
+ });
43
+ }
44
+ getAxiosRequestMethod(httpMethod) {
45
+ return httpMethod.toString();
46
+ }
47
+ }
48
+ exports.AxiosHttpClient = AxiosHttpClient;
49
+ //# sourceMappingURL=axios-http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-http-client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/axios/axios-http-client.ts"],"names":[],"mappings":";;;;AAAA,0DAA2C;AAC3C,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AAC,CAAC;gBAC7D,MAAM,CAAC,CAAC;aACR;;KACD;IAEO,qBAAqB,CAAC,UAAsB;QACnD,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CACD;AA7CD,0CA6CC"}
@@ -0,0 +1,15 @@
1
+ import type { HttpClient } from './http-client';
2
+ import type { HttpMessageBody } from './http-message-body';
3
+ import type { HttpRequest } from './http-request';
4
+ import type { HttpHeaders } from './http-headers';
5
+ import { HttpResponse } from './http-response';
6
+ import { DelegatingAuthenticationConverter } from './delegating-authentication-converter';
7
+ export declare abstract class BaseHttpClient implements HttpClient {
8
+ private readonly baseUrl;
9
+ private readonly authenticationConverter;
10
+ constructor(baseUrl: string, authenticationConverter: DelegatingAuthenticationConverter);
11
+ abstract sendRequest<RequestBody extends HttpMessageBody, ResponseBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): Promise<HttpResponse<ResponseBody>>;
12
+ protected getUrl<RequestBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): string;
13
+ protected getHeaders<RequestBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): HttpHeaders;
14
+ private populateAuthentication;
15
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseHttpClient = void 0;
4
+ const node_url_1 = require("node:url");
5
+ const http_header_1 = require("./http-header");
6
+ const media_type_1 = require("./media-type");
7
+ class BaseHttpClient {
8
+ constructor(baseUrl, authenticationConverter) {
9
+ this.baseUrl = baseUrl;
10
+ this.authenticationConverter = authenticationConverter;
11
+ }
12
+ getUrl(request) {
13
+ const url = new node_url_1.URL(`${this.baseUrl}${request.url}`);
14
+ if (request.queryParams) {
15
+ for (const [name, value] of Object.entries(request.queryParams)) {
16
+ url.searchParams.append(name, value);
17
+ }
18
+ }
19
+ return url.toString();
20
+ }
21
+ getHeaders(request) {
22
+ let requestHeaders = {
23
+ [http_header_1.HttpHeader.ACCEPT]: media_type_1.MediaType.APPLICATION_JSON,
24
+ };
25
+ if (request.authentication) {
26
+ this.populateAuthentication(request.authentication, requestHeaders);
27
+ }
28
+ if (request.body) {
29
+ requestHeaders[http_header_1.HttpHeader.CONTENT_TYPE] = media_type_1.MediaType.APPLICATION_JSON;
30
+ }
31
+ if (request.headers) {
32
+ requestHeaders = Object.assign(Object.assign({}, requestHeaders), request.headers);
33
+ }
34
+ return requestHeaders;
35
+ }
36
+ populateAuthentication(authentication, headers) {
37
+ this.authenticationConverter.convert(authentication, headers);
38
+ }
39
+ }
40
+ exports.BaseHttpClient = BaseHttpClient;
41
+ //# sourceMappingURL=base-http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-http-client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/core/base-http-client.ts"],"names":[],"mappings":";;;AAAA,uCAA+B;AAE/B,+CAAyC;AAGzC,6CAAuC;AAMvC,MAAsB,cAAc;IACnC,YACkB,OAAe,EACf,uBAA0D;QAD1D,YAAO,GAAP,OAAO,CAAQ;QACf,4BAAuB,GAAvB,uBAAuB,CAAmC;IACzE,CAAC;IAMM,MAAM,CAAsC,OAAiC;QACtF,MAAM,GAAG,GAAG,IAAI,cAAG,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAErD,IAAI,OAAO,CAAC,WAAW,EAAE;YACxB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAChE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACrC;SACD;QAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAES,UAAU,CACnB,OAAiC;QAEjC,IAAI,cAAc,GAAgB;YACjC,CAAC,wBAAU,CAAC,MAAM,CAAC,EAAE,sBAAS,CAAC,gBAAgB;SAC/C,CAAC;QAEF,IAAI,OAAO,CAAC,cAAc,EAAE;YAC3B,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;SACpE;QAED,IAAI,OAAO,CAAC,IAAI,EAAE;YACjB,cAAc,CAAC,wBAAU,CAAC,YAAY,CAAC,GAAG,sBAAS,CAAC,gBAAgB,CAAC;SACrE;QACD,IAAG,OAAO,CAAC,OAAO,EAAC;YAClB,cAAc,mCAAO,cAAc,GAAK,OAAO,CAAC,OAAO,CAAC,CAAC;SACzD;QACD,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,sBAAsB,CAAC,cAA8B,EAAE,OAAoB;QAClF,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;CACD;AA7CD,wCA6CC"}
@@ -0,0 +1,17 @@
1
+ import type { HttpHeaders } from './http-headers';
2
+ import { Authentication, BasicAuthentication, 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
+ declare 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/common/src/lib/http/core/delegating-authentication-converter.ts"],"names":[],"mappings":";;;AACA,+CAA2C;AAC3C,yDAA0H;AAE1H,MAAa,iCAAiC;IAG7C,YACC,oBAAoB,GAAG,IAAI,kCAAkC,EAAE,EAC/D,mBAAmB,GAAG,IAAI,iCAAiC,EAAE;QAE7D,IAAI,CAAC,UAAU,GAAG;YACjB,CAAC,mCAAkB,CAAC,YAAY,CAAC,EAAE,oBAAoB;YACvD,CAAC,mCAAkB,CAAC,KAAK,CAAC,EAAE,mBAAmB;SAC/C,CAAC;IACH,CAAC;IAED,OAAO,CAAC,cAA8B,EAAE,OAAoB;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACvD,OAAO,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACD;AAjBD,8EAiBC;AAED,MAAM,kCAAkC;IACvC,OAAO,CAAC,cAAyC,EAAE,OAAoB;QACtE,OAAO,CAAC,wBAAU,CAAC,aAAa,CAAC,GAAG,UAAU,cAAc,CAAC,KAAK,EAAE,CAAC;QACrE,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAED,MAAM,iCAAiC;IACtC,OAAO,CAAC,cAAmC,EAAE,OAAoB;QAChE,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;IAChB,CAAC;CACD"}
@@ -0,0 +1,8 @@
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 { HttpResponse } from './http-response';
5
+ export declare type HttpClient = {
6
+ sendRequest<RequestBody extends HttpMessageBody, ResponseBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): Promise<HttpResponse<ResponseBody>>;
7
+ };
8
+ 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/common/src/lib/http/core/http-client.ts"],"names":[],"mappings":";;;AAAA,kEAA6D;AAWhD,QAAA,UAAU,GAAG,IAAI,mCAAe,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { AxiosError } from 'axios';
2
+ export declare class HttpError extends Error {
3
+ private readonly _requestBody;
4
+ private readonly _err;
5
+ constructor(_requestBody: unknown, _err: AxiosError);
6
+ get response(): {
7
+ status: number;
8
+ body: unknown;
9
+ };
10
+ get request(): {
11
+ body: unknown;
12
+ };
13
+ }
@@ -0,0 +1,33 @@
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
+ super(JSON.stringify({
8
+ response: {
9
+ status: ((_a = _err === null || _err === void 0 ? void 0 : _err.response) === null || _a === void 0 ? void 0 : _a.status) || 500,
10
+ body: (_b = _err === null || _err === void 0 ? void 0 : _err.response) === null || _b === void 0 ? void 0 : _b.data
11
+ },
12
+ request: {
13
+ body: _requestBody
14
+ }
15
+ }));
16
+ this._requestBody = _requestBody;
17
+ this._err = _err;
18
+ }
19
+ get response() {
20
+ var _a, _b, _c, _d;
21
+ return {
22
+ status: ((_b = (_a = this._err) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.status) || 500,
23
+ body: (_d = (_c = this._err) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data
24
+ };
25
+ }
26
+ get request() {
27
+ return {
28
+ body: this._requestBody
29
+ };
30
+ }
31
+ }
32
+ exports.HttpError = HttpError;
33
+ //# sourceMappingURL=http-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-error.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/core/http-error.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAU,SAAQ,KAAK;IACnC,YACkB,YAAqB,EACrB,IAAgB;;QAEjC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YACpB,QAAQ,EAAE;gBACT,MAAM,EAAE,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,0CAAE,MAAM,KAAI,GAAG;gBACrC,IAAI,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,0CAAE,IAAI;aAC1B;YACD,OAAO,EAAE;gBACR,IAAI,EAAE,YAAY;aAClB;SACD,CAAC,CAAC,CAAC;QAXa,iBAAY,GAAZ,YAAY,CAAS;QACrB,SAAI,GAAJ,IAAI,CAAY;IAWlC,CAAC;IAED,IAAI,QAAQ;;QACX,OAAO;YACN,MAAM,EAAE,CAAA,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,QAAQ,0CAAE,MAAM,KAAI,GAAG;YAC1C,IAAI,EAAE,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,QAAQ,0CAAE,IAAI;SAC/B,CAAC;IACH,CAAC;IAED,IAAI,OAAO;QACV,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,YAAY;SACvB,CAAC;IACH,CAAC;CACD;AA5BD,8BA4BC"}
@@ -0,0 +1,5 @@
1
+ export declare enum HttpHeader {
2
+ AUTHORIZATION = "Authorization",
3
+ ACCEPT = "Accept",
4
+ CONTENT_TYPE = "ContentType"
5
+ }
@@ -0,0 +1,10 @@
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["CONTENT_TYPE"] = "ContentType";
9
+ })(HttpHeader = exports.HttpHeader || (exports.HttpHeader = {}));
10
+ //# sourceMappingURL=http-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-header.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/core/http-header.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAIX;AAJD,WAAY,UAAU;IACrB,6CAA+B,CAAA;IAC/B,+BAAiB,CAAA;IACjB,0CAA4B,CAAA;AAC7B,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB"}
@@ -0,0 +1 @@
1
+ export declare 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/common/src/lib/http/core/http-headers.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export declare type HttpMessageBody = Record<string, 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/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 || (exports.HttpMethod = {}));
13
+ //# sourceMappingURL=http-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-method.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/core/http-method.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAOX;AAPD,WAAY,UAAU;IACrB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACd,CAAC,EAPW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAOrB"}
@@ -0,0 +1,13 @@
1
+ import type { HttpMessageBody } from './http-message-body';
2
+ import type { HttpMethod } from './http-method';
3
+ import type { QueryParams } from './query-params';
4
+ import { HttpHeaders } from './http-headers';
5
+ import { Authentication } from '../../authentication';
6
+ export declare type HttpRequest<RequestBody extends HttpMessageBody = any> = {
7
+ method: HttpMethod;
8
+ url: string;
9
+ body?: RequestBody | undefined;
10
+ headers?: HttpHeaders;
11
+ authentication?: Authentication | undefined;
12
+ queryParams?: QueryParams | undefined;
13
+ };
@@ -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/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 declare 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/common/src/lib/http/core/http-response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare enum MediaType {
2
+ APPLICATION_JSON = "application/json"
3
+ }
@@ -0,0 +1,8 @@
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 = exports.MediaType || (exports.MediaType = {}));
8
+ //# sourceMappingURL=media-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-type.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/core/media-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAEX;AAFD,WAAY,SAAS;IACpB,kDAAqC,CAAA;AACtC,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB"}
@@ -0,0 +1 @@
1
+ export declare 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-params.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/common/src/lib/http/core/query-params.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ export * from './axios/axios-http-client';
2
+ export * from './core/base-http-client';
3
+ export * from './core/delegating-authentication-converter';
4
+ export * from './core/http-client';
5
+ export * from './core/http-error';
6
+ export * from './core/http-header';
7
+ export * from './core/http-headers';
8
+ export * from './core/http-message-body';
9
+ export * from './core/http-method';
10
+ export * from './core/http-request';
11
+ export * from './core/http-response';
12
+ export * from './core/media-type';
13
+ export * from './core/query-params';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./axios/axios-http-client"), exports);
5
+ tslib_1.__exportStar(require("./core/base-http-client"), exports);
6
+ tslib_1.__exportStar(require("./core/delegating-authentication-converter"), exports);
7
+ tslib_1.__exportStar(require("./core/http-client"), exports);
8
+ tslib_1.__exportStar(require("./core/http-error"), exports);
9
+ tslib_1.__exportStar(require("./core/http-header"), exports);
10
+ tslib_1.__exportStar(require("./core/http-headers"), exports);
11
+ tslib_1.__exportStar(require("./core/http-message-body"), exports);
12
+ tslib_1.__exportStar(require("./core/http-method"), exports);
13
+ tslib_1.__exportStar(require("./core/http-request"), exports);
14
+ tslib_1.__exportStar(require("./core/http-response"), exports);
15
+ tslib_1.__exportStar(require("./core/media-type"), exports);
16
+ tslib_1.__exportStar(require("./core/query-params"), exports);
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/common/src/lib/http/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyC;AACzC,kEAAuC;AACvC,qFAA0D;AAC1D,6DAAkC;AAClC,4DAAiC;AACjC,6DAAkC;AAClC,8DAAmC;AACnC,mEAAwC;AACxC,6DAAkC;AAClC,8DAAmC;AACnC,+DAAoC;AACpC,4DAAiC;AACjC,8DAAmC"}
@@ -0,0 +1,44 @@
1
+ import { Store } from "@activepieces/pieces-framework";
2
+ interface TimebasedPolling<INPUT> {
3
+ strategy: DedupeStrategy.TIMEBASED;
4
+ items: ({ propsValue, lastFetchEpochMS }: {
5
+ propsValue: INPUT;
6
+ lastFetchEpochMS: number;
7
+ }) => Promise<{
8
+ epochMilliSeconds: number;
9
+ data: unknown;
10
+ }[]>;
11
+ }
12
+ interface LastItemPolling<INPUT> {
13
+ strategy: DedupeStrategy.LAST_ITEM;
14
+ items: ({ propsValue }: {
15
+ propsValue: INPUT;
16
+ }) => Promise<{
17
+ id: unknown;
18
+ data: unknown;
19
+ }[]>;
20
+ }
21
+ export declare enum DedupeStrategy {
22
+ TIMEBASED = 0,
23
+ LAST_ITEM = 1
24
+ }
25
+ export declare type Polling<T> = TimebasedPolling<T> | LastItemPolling<T>;
26
+ export declare const pollingHelper: {
27
+ poll<INPUT>(polling: Polling<INPUT>, { store, propsValue }: {
28
+ store: Store;
29
+ propsValue: INPUT;
30
+ }): Promise<unknown[]>;
31
+ onEnable<INPUT_1>(polling: Polling<INPUT_1>, { store, propsValue }: {
32
+ store: Store;
33
+ propsValue: INPUT_1;
34
+ }): Promise<void>;
35
+ onDisable<INPUT_2>(polling: Polling<INPUT_2>, { store, propsValue }: {
36
+ store: Store;
37
+ propsValue: INPUT_2;
38
+ }): Promise<void>;
39
+ test<INPUT_3>(polling: Polling<INPUT_3>, { propsValue }: {
40
+ store: Store;
41
+ propsValue: INPUT_3;
42
+ }): Promise<unknown[]>;
43
+ };
44
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pollingHelper = exports.DedupeStrategy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var DedupeStrategy;
6
+ (function (DedupeStrategy) {
7
+ DedupeStrategy[DedupeStrategy["TIMEBASED"] = 0] = "TIMEBASED";
8
+ DedupeStrategy[DedupeStrategy["LAST_ITEM"] = 1] = "LAST_ITEM";
9
+ })(DedupeStrategy = exports.DedupeStrategy || (exports.DedupeStrategy = {}));
10
+ exports.pollingHelper = {
11
+ poll(polling, { store, propsValue }) {
12
+ var _a, _b, _c;
13
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ switch (polling.strategy) {
15
+ case DedupeStrategy.TIMEBASED: {
16
+ const lastEpochMilliSeconds = (_a = (yield store.get("lastPoll"))) !== null && _a !== void 0 ? _a : 0;
17
+ const items = yield polling.items({ propsValue, lastFetchEpochMS: lastEpochMilliSeconds });
18
+ const newLastEpochMilliSeconds = items.reduce((acc, item) => Math.max(acc, item.epochMilliSeconds), lastEpochMilliSeconds);
19
+ yield store.put("lastPoll", newLastEpochMilliSeconds);
20
+ return items.filter(f => f.epochMilliSeconds > lastEpochMilliSeconds).map((item) => item.data);
21
+ }
22
+ case DedupeStrategy.LAST_ITEM: {
23
+ const lastItemId = (yield store.get("lastItem"));
24
+ const items = yield polling.items({ propsValue });
25
+ const newLastItem = (_b = items === null || items === void 0 ? void 0 : items[0]) === null || _b === void 0 ? void 0 : _b.id;
26
+ if (!newLastItem) {
27
+ return items;
28
+ }
29
+ yield store.put("lastItem", newLastItem);
30
+ // get items until you find the last item
31
+ const lastItemIndex = items.findIndex(f => f.id === lastItemId);
32
+ return (_c = items === null || items === void 0 ? void 0 : items.slice(0, lastItemIndex).map((item) => item.data)) !== null && _c !== void 0 ? _c : [];
33
+ }
34
+ }
35
+ });
36
+ },
37
+ onEnable(polling, { store, propsValue }) {
38
+ var _a;
39
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
40
+ switch (polling.strategy) {
41
+ case DedupeStrategy.TIMEBASED: {
42
+ yield store.put("lastPoll", Date.now());
43
+ break;
44
+ }
45
+ case DedupeStrategy.LAST_ITEM: {
46
+ const items = (yield polling.items({ propsValue }));
47
+ yield store.put("lastItem", (_a = items === null || items === void 0 ? void 0 : items[0]) === null || _a === void 0 ? void 0 : _a.id);
48
+ break;
49
+ }
50
+ }
51
+ });
52
+ },
53
+ onDisable(polling, { store, propsValue }) {
54
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
55
+ switch (polling.strategy) {
56
+ case DedupeStrategy.TIMEBASED:
57
+ case DedupeStrategy.LAST_ITEM:
58
+ return;
59
+ }
60
+ });
61
+ },
62
+ test(polling, { propsValue }) {
63
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
64
+ let items = [];
65
+ switch (polling.strategy) {
66
+ case DedupeStrategy.TIMEBASED: {
67
+ items = yield polling.items({ propsValue, lastFetchEpochMS: 0 });
68
+ break;
69
+ }
70
+ case DedupeStrategy.LAST_ITEM: {
71
+ items = yield polling.items({ propsValue });
72
+ break;
73
+ }
74
+ }
75
+ return getFirstFiveOrAll(items.map((item) => item.data));
76
+ });
77
+ }
78
+ };
79
+ function getFirstFiveOrAll(array) {
80
+ if (array.length <= 5) {
81
+ return array;
82
+ }
83
+ else {
84
+ return array.slice(0, 5);
85
+ }
86
+ }
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/common/src/lib/polling/index.ts"],"names":[],"mappings":";;;;AAwBA,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,6DAAS,CAAA;IACT,6DAAS,CAAA;AACb,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAIY,QAAA,aAAa,GAAG;IACnB,IAAI,CAAQ,OAAuB,EAAE,EAAE,KAAK,EAAE,UAAU,EAAuC;;;YACjG,QAAQ,OAAO,CAAC,QAAQ,EAAE;gBACtB,KAAK,cAAc,CAAC,SAAS,CAAC,CAAC;oBAC3B,MAAM,qBAAqB,GAAG,MAAA,CAAC,MAAM,KAAK,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC,mCAAI,CAAC,CAAC;oBACzE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,qBAAqB,EAAC,CAAC,CAAC;oBAC1F,MAAM,wBAAwB,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,qBAAqB,CAAC,CAAC;oBAC3H,MAAM,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;oBACtD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,GAAG,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAClG;gBACD,KAAK,cAAc,CAAC,SAAS,CAAC,CAAC;oBAC3B,MAAM,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