@activepieces/pieces-common 0.2.34 → 0.2.37
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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/pieces-common",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.37",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@anthropic-ai/sdk": "0.27.3",
|
|
7
7
|
"@sinclair/typebox": "0.33.18",
|
|
8
|
-
"axios": "1.7.
|
|
8
|
+
"axios": "1.7.8",
|
|
9
9
|
"axios-retry": "4.4.1",
|
|
10
10
|
"deepmerge": "4.3.1",
|
|
11
11
|
"mime-types": "2.1.35",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"replicate": "0.34.1",
|
|
15
15
|
"semver": "7.6.0",
|
|
16
16
|
"zod": "3.23.8",
|
|
17
|
-
"@activepieces/pieces-framework": "0.7.
|
|
18
|
-
"@activepieces/shared": "0.10.
|
|
17
|
+
"@activepieces/pieces-framework": "0.7.41",
|
|
18
|
+
"@activepieces/shared": "0.10.132",
|
|
19
19
|
"tslib": "1.14.1"
|
|
20
20
|
},
|
|
21
21
|
"overrides": {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { OAuth2PropertyValue, PieceAuthProperty, Property, StaticDropdownProperty } from
|
|
2
|
-
import { HttpHeaders, HttpMethod } from
|
|
1
|
+
import { OAuth2PropertyValue, PieceAuthProperty, Property, StaticDropdownProperty, StaticPropsValue, InputPropertyMap } from '@activepieces/pieces-framework';
|
|
2
|
+
import { HttpHeaders, HttpMethod } from '../http';
|
|
3
3
|
export declare const getAccessTokenOrThrow: (auth: OAuth2PropertyValue | undefined) => string;
|
|
4
|
-
export declare function createCustomApiCallAction({ auth, baseUrl, authMapping, description, displayName, name, props }: {
|
|
4
|
+
export declare function createCustomApiCallAction({ auth, baseUrl, authMapping, description, displayName, name, props, extraProps, }: {
|
|
5
5
|
auth?: PieceAuthProperty;
|
|
6
6
|
baseUrl: (auth?: unknown) => string;
|
|
7
|
-
authMapping?: (auth: unknown) => Promise<HttpHeaders>;
|
|
7
|
+
authMapping?: (auth: unknown, propsValue: StaticPropsValue<any>) => Promise<HttpHeaders>;
|
|
8
8
|
description?: string | null;
|
|
9
9
|
displayName?: string | null;
|
|
10
10
|
name?: string | null;
|
|
@@ -17,6 +17,7 @@ export declare function createCustomApiCallAction({ auth, baseUrl, authMapping,
|
|
|
17
17
|
failsafe?: Partial<ReturnType<typeof Property.Checkbox>>;
|
|
18
18
|
timeout?: Partial<ReturnType<typeof Property.Number>>;
|
|
19
19
|
};
|
|
20
|
+
extraProps?: InputPropertyMap;
|
|
20
21
|
}): import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").BasicAuthProperty | import("@activepieces/pieces-framework").CustomAuthProperty<any> | import("@activepieces/pieces-framework").OAuth2Property<any> | import("@activepieces/pieces-framework").SecretTextProperty<boolean>, {
|
|
21
22
|
url: import("@activepieces/pieces-framework").DynamicProperties<true>;
|
|
22
23
|
method: StaticDropdownProperty<HttpMethod, false> | StaticDropdownProperty<HttpMethod, true>;
|
package/src/lib/helpers/index.js
CHANGED
|
@@ -9,52 +9,46 @@ const shared_1 = require("@activepieces/shared");
|
|
|
9
9
|
const getAccessTokenOrThrow = (auth) => {
|
|
10
10
|
const accessToken = auth === null || auth === void 0 ? void 0 : auth.access_token;
|
|
11
11
|
if (accessToken === undefined) {
|
|
12
|
-
throw new Error(
|
|
12
|
+
throw new Error('Invalid bearer token');
|
|
13
13
|
}
|
|
14
14
|
return accessToken;
|
|
15
15
|
};
|
|
16
16
|
exports.getAccessTokenOrThrow = getAccessTokenOrThrow;
|
|
17
|
-
function createCustomApiCallAction({ auth, baseUrl, authMapping, description, displayName, name, props }) {
|
|
17
|
+
function createCustomApiCallAction({ auth, baseUrl, authMapping, description, displayName, name, props, extraProps, }) {
|
|
18
18
|
var _a, _b, _c, _d, _e, _f;
|
|
19
19
|
return (0, pieces_framework_1.createAction)({
|
|
20
20
|
name: name ? name : 'custom_api_call',
|
|
21
21
|
displayName: displayName ? displayName : 'Custom API Call',
|
|
22
|
-
description: description
|
|
22
|
+
description: description
|
|
23
|
+
? description
|
|
24
|
+
: 'Make a custom API call to a specific endpoint',
|
|
23
25
|
auth: auth ? auth : undefined,
|
|
24
26
|
requireAuth: auth ? true : false,
|
|
25
|
-
props: {
|
|
26
|
-
url: pieces_framework_1.Property.DynamicProperties({
|
|
27
|
+
props: Object.assign({ url: pieces_framework_1.Property.DynamicProperties({
|
|
27
28
|
displayName: '',
|
|
28
29
|
required: true,
|
|
29
30
|
refreshers: [],
|
|
30
31
|
props: (_a) => tslib_1.__awaiter(this, [_a], void 0, function* ({ auth }) {
|
|
31
32
|
var _b;
|
|
32
33
|
return {
|
|
33
|
-
url: pieces_framework_1.Property.ShortText(Object.assign({ displayName: 'URL', description: 'The full URL to use, including the base URL', required: true, defaultValue: baseUrl(auth) }, ((_b = props === null || props === void 0 ? void 0 : props.url) !== null && _b !== void 0 ? _b : {})))
|
|
34
|
+
url: pieces_framework_1.Property.ShortText(Object.assign({ displayName: 'URL', description: 'The full URL to use, including the base URL', required: true, defaultValue: baseUrl(auth) }, ((_b = props === null || props === void 0 ? void 0 : props.url) !== null && _b !== void 0 ? _b : {}))),
|
|
34
35
|
};
|
|
35
|
-
})
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
options: Object.values(http_1.HttpMethod).map(v => {
|
|
36
|
+
}),
|
|
37
|
+
}), method: pieces_framework_1.Property.StaticDropdown(Object.assign({ displayName: 'Method', required: true, options: {
|
|
38
|
+
options: Object.values(http_1.HttpMethod).map((v) => {
|
|
39
39
|
return {
|
|
40
40
|
label: v,
|
|
41
41
|
value: v,
|
|
42
42
|
};
|
|
43
|
-
})
|
|
44
|
-
} }, ((_a = props === null || props === void 0 ? void 0 : props.method) !== null && _a !== void 0 ? _a : {}))),
|
|
45
|
-
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 : {}))),
|
|
46
|
-
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 : {}))),
|
|
47
|
-
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 : {}))),
|
|
48
|
-
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 : {}))),
|
|
49
|
-
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 : {}))),
|
|
50
|
-
},
|
|
43
|
+
}),
|
|
44
|
+
} }, ((_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),
|
|
51
45
|
run: (context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
46
|
const { method, url, headers, queryParams, body, failsafe, timeout } = context.propsValue;
|
|
53
47
|
(0, shared_1.assertNotNullOrUndefined)(method, 'Method');
|
|
54
48
|
(0, shared_1.assertNotNullOrUndefined)(url, 'URL');
|
|
55
49
|
let headersValue = headers;
|
|
56
50
|
if (authMapping) {
|
|
57
|
-
const headers = yield authMapping(context.auth);
|
|
51
|
+
const headers = yield authMapping(context.auth, context.propsValue);
|
|
58
52
|
if (headers) {
|
|
59
53
|
headersValue = Object.assign(Object.assign({}, headersValue), headers);
|
|
60
54
|
}
|
|
@@ -78,7 +72,7 @@ function createCustomApiCallAction({ auth, baseUrl, authMapping, description, di
|
|
|
78
72
|
}
|
|
79
73
|
throw error;
|
|
80
74
|
}
|
|
81
|
-
})
|
|
75
|
+
}),
|
|
82
76
|
});
|
|
83
77
|
}
|
|
84
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/common/src/lib/helpers/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/common/src/lib/helpers/index.ts"],"names":[],"mappings":";;;AA+BA,8DA2IC;;AA1KD,qEAQwC;AACxC,kCAOiB;AACjB,iDAAgE;AAEzD,MAAM,qBAAqB,GAAG,CACnC,IAAqC,EAC7B,EAAE;IACV,MAAM,WAAW,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC;IAEvC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sBA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T extends Record<string, unknown>>(props: T, schema: Partial<Record<keyof T, z.ZodType>>): void
|
|
3
|
+
validateZod<T extends Record<string, unknown>>(props: T, schema: Partial<Record<keyof T, z.ZodType>>): Promise<void>;
|
|
4
4
|
};
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.propsValidation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const zod_1 = require("zod");
|
|
5
6
|
exports.propsValidation = {
|
|
6
7
|
validateZod(props, schema) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
catch (error) {
|
|
12
|
-
if (error instanceof zod_1.z.ZodError) {
|
|
13
|
-
const errors = error.errors.reduce((acc, err) => {
|
|
14
|
-
const path = err.path.join('.');
|
|
15
|
-
return Object.assign(Object.assign({}, acc), { [path]: err.message });
|
|
16
|
-
}, {});
|
|
17
|
-
throw new Error(JSON.stringify({ errors }, null, 2));
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const schemaObj = zod_1.z.object(Object.entries(schema).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: value })), {}));
|
|
10
|
+
try {
|
|
11
|
+
yield schemaObj.parseAsync(props);
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
15
|
+
const errors = error.errors.reduce((acc, err) => {
|
|
16
|
+
const path = err.path.join('.');
|
|
17
|
+
return Object.assign(Object.assign({}, acc), { [path]: err.message });
|
|
18
|
+
}, {});
|
|
19
|
+
throw new Error(JSON.stringify({ errors }, null, 2));
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
};
|
|
23
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/common/src/lib/validation/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/common/src/lib/validation/index.ts"],"names":[],"mappings":";;;;AAAA,6BAAuB;AAEV,QAAA,eAAe,GAAG;IACrB,WAAW,CAAoC,KAAQ,EAAE,MAA2C;;YACtG,MAAM,SAAS,GAAG,OAAC,CAAC,MAAM,CACtB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,iCAC9C,GAAG,KACN,CAAC,GAAG,CAAC,EAAE,KAAK,IACd,EAAE,EAAE,CAAC,CACV,CAAA;YAED,IAAI,CAAC;gBACD,MAAM,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YACrC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,KAAK,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;oBAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;wBAC5C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;wBAC/B,uCACO,GAAG,KACN,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,IACtB;oBACL,CAAC,EAAE,EAAE,CAAC,CAAA;oBACN,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;gBACxD,CAAC;gBACD,MAAM,KAAK,CAAA;YACf,CAAC;QACL,CAAC;KAAA;CACJ,CAAA"}
|