Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(pieces-common): group the Custom API Call form into Request and Data to send cards (#16383)

Talal Jaberbe8cf06a84b3
diff --git a/packages/pieces/common/src/lib/helpers/index.ts b/packages/pieces/common/src/lib/helpers/index.ts
index 1685b7e4a0a..c16ac642f86 100644
--- a/packages/pieces/common/src/lib/helpers/index.ts
+++ b/packages/pieces/common/src/lib/helpers/index.ts
@@ -357,6 +357,22 @@ export function createCustomApiCallAction<
}),
...extraProps,
},
+ propertyGroups: [
+ {
+ key: 'request',
+ display: 'section',
+ label: 'Request',
+ icon: 'send',
+ props: ['method', 'url', 'headers', 'queryParams'],
+ },
+ {
+ key: 'payload',
+ display: 'section',
+ label: 'Data to send',
+ icon: 'code',
+ props: ['body_type', 'body'],
+ },
+ ],
run: async (context) => {
const {
diff --git a/packages/pieces/common/test/custom-api-call-property-groups.test.ts b/packages/pieces/common/test/custom-api-call-property-groups.test.ts
new file mode 100644
index 00000000000..1beca669ff7
--- /dev/null
+++ b/packages/pieces/common/test/custom-api-call-property-groups.test.ts
@@ -0,0 +1,38 @@
+/// <reference types="vitest/globals" />
+
+import { Property } from '@activepieces/pieces-framework';
+import { createCustomApiCallAction } from '../src';
+
+function buildAction() {
+ return createCustomApiCallAction({
+ baseUrl: () => 'https://api.example.com/v1',
+ authMapping: async () => ({ 'x-api-key': 'secret' }),
+ extraProps: {
+ region: Property.ShortText({ displayName: 'Region', required: false }),
+ },
+ });
+}
+
+describe('createCustomApiCallAction property groups', () => {
+ it('lays out the request and the payload as section cards', () => {
+ const groups = buildAction().propertyGroups ?? [];
+
+ expect(groups.map(({ key, display, label, icon, props }) => ({ key, display, label, icon, props }))).toEqual([
+ { key: 'request', display: 'section', label: 'Request', icon: 'send', props: ['method', 'url', 'headers', 'queryParams'] },
+ { key: 'payload', display: 'section', label: 'Data to send', icon: 'code', props: ['body_type', 'body'] },
+ ]);
+ });
+
+ it('only groups props the action defines', () => {
+ const action = buildAction();
+ const grouped = (action.propertyGroups ?? []).flatMap((group) => group.props);
+
+ expect(grouped.filter((name) => !(name in action.props))).toEqual([]);
+ });
+
+ it('keeps the advanced options and extra props outside the cards', () => {
+ const grouped = new Set((buildAction().propertyGroups ?? []).flatMap((group) => group.props));
+
+ expect(['response_is_binary', 'failsafe', 'timeout', 'followRedirects', 'region'].filter((name) => grouped.has(name))).toEqual([]);
+ });
+});