Skip to content

Commit a28df62

Browse files
committed
remove camelCase param normalization from custom integrations, use snake_case only
1 parent 0ab0f48 commit a28df62

3 files changed

Lines changed: 4 additions & 101 deletions

File tree

src/modules/custom-integrations.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,6 @@ import {
55
CustomIntegrationCallResponse,
66
} from "./custom-integrations.types.js";
77

8-
/**
9-
* Normalizes parameters to snake_case for the API.
10-
*
11-
* Supports both camelCase (pathParams) and snake_case (path_params) input,
12-
* always outputting snake_case for the backend.
13-
*/
14-
function normalizeParams(params?: CustomIntegrationCallParams): Record<string, any> {
15-
if (!params) {
16-
return {};
17-
}
18-
19-
const normalized: Record<string, any> = {};
20-
21-
// Handle payload
22-
if (params.payload !== undefined) {
23-
normalized.payload = params.payload;
24-
}
25-
26-
// Handle path_params (support both camelCase and snake_case)
27-
const pathParams = params.pathParams ?? params.path_params;
28-
if (pathParams !== undefined) {
29-
normalized.path_params = pathParams;
30-
}
31-
32-
// Handle query_params (support both camelCase and snake_case)
33-
const queryParams = params.queryParams ?? params.query_params;
34-
if (queryParams !== undefined) {
35-
normalized.query_params = queryParams;
36-
}
37-
38-
// Handle headers
39-
if (params.headers !== undefined) {
40-
normalized.headers = params.headers;
41-
}
42-
43-
return normalized;
44-
}
45-
468
/**
479
* Creates the custom integrations module for the Base44 SDK.
4810
*
@@ -69,13 +31,10 @@ export function createCustomIntegrationsModule(
6931
throw new Error("Operation ID is required");
7032
}
7133

72-
// Normalize parameters to snake_case
73-
const normalizedParams = normalizeParams(params);
74-
7534
// Make the API call
7635
const response = await axios.post<CustomIntegrationCallResponse>(
7736
`/apps/${appId}/integrations/custom/${slug}/${operationId}`,
78-
normalizedParams
37+
params ?? {}
7938
);
8039

8140
// Return the response data
@@ -84,4 +43,3 @@ export function createCustomIntegrationsModule(
8443
},
8544
};
8645
}
87-

src/modules/custom-integrations.types.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/**
22
* Parameters for calling a custom integration endpoint.
3-
*
4-
* Supports both camelCase and snake_case parameter names for developer convenience.
5-
* The SDK will normalize to snake_case before sending to the API.
63
*/
74
export interface CustomIntegrationCallParams {
85
/**
@@ -12,25 +9,11 @@ export interface CustomIntegrationCallParams {
129

1310
/**
1411
* Path parameters to substitute in the URL (e.g., `{ owner: "user", repo: "repo" }`).
15-
* Can use either `pathParams` (camelCase) or `path_params` (snake_case).
16-
*/
17-
pathParams?: Record<string, string>;
18-
19-
/**
20-
* Path parameters to substitute in the URL (snake_case variant).
21-
* @see {@link pathParams}
2212
*/
2313
path_params?: Record<string, string>;
2414

2515
/**
2616
* Query string parameters to append to the URL.
27-
* Can use either `queryParams` (camelCase) or `query_params` (snake_case).
28-
*/
29-
queryParams?: Record<string, any>;
30-
31-
/**
32-
* Query string parameters (snake_case variant).
33-
* @see {@link queryParams}
3417
*/
3518
query_params?: Record<string, any>;
3619

@@ -81,8 +64,8 @@ export interface CustomIntegrationCallResponse {
8164
* "github", // integration slug (defined by workspace admin)
8265
* "listIssues", // operation ID from the OpenAPI spec
8366
* {
84-
* pathParams: { owner: "myorg", repo: "myrepo" },
85-
* queryParams: { state: "open", per_page: 100 }
67+
* path_params: { owner: "myorg", repo: "myrepo" },
68+
* query_params: { state: "open", per_page: 100 }
8669
* }
8770
* );
8871
*
@@ -100,7 +83,7 @@ export interface CustomIntegrationCallResponse {
10083
* "github",
10184
* "createIssue",
10285
* {
103-
* pathParams: { owner: "myorg", repo: "myrepo" },
86+
* path_params: { owner: "myorg", repo: "myrepo" },
10487
* payload: {
10588
* title: "Bug report",
10689
* body: "Something is broken",
@@ -131,4 +114,3 @@ export interface CustomIntegrationsModule {
131114
params?: CustomIntegrationCallParams
132115
): Promise<CustomIntegrationCallResponse>;
133116
}
134-

tests/unit/custom-integrations.test.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -56,42 +56,6 @@ describe('Custom Integrations Module', () => {
5656
expect(scope.isDone()).toBe(true);
5757
});
5858

59-
test('custom.call() should support camelCase parameter names', async () => {
60-
const slug = 'github';
61-
const operationId = 'getRepo';
62-
const params = {
63-
pathParams: { owner: 'testuser', repo: 'testrepo' },
64-
queryParams: { include: 'stats' },
65-
};
66-
67-
// Expected body should have snake_case keys
68-
const expectedBody = {
69-
path_params: { owner: 'testuser', repo: 'testrepo' },
70-
query_params: { include: 'stats' },
71-
};
72-
73-
const mockResponse = {
74-
success: true,
75-
status_code: 200,
76-
data: { name: 'testrepo', stars: 100 },
77-
};
78-
79-
// Mock the API response - expecting snake_case in the body
80-
scope
81-
.post(`/api/apps/${appId}/integrations/custom/${slug}/${operationId}`, expectedBody)
82-
.reply(200, mockResponse);
83-
84-
// Call with camelCase params
85-
const result = await base44.integrations.custom.call(slug, operationId, params);
86-
87-
// Verify the response
88-
expect(result.success).toBe(true);
89-
expect(result.data.name).toBe('testrepo');
90-
91-
// Verify all mocks were called
92-
expect(scope.isDone()).toBe(true);
93-
});
94-
9559
test('custom.call() should work with empty params', async () => {
9660
const slug = 'github';
9761
const operationId = 'getAuthenticatedUser';
@@ -255,4 +219,3 @@ describe('Custom Integrations Module', () => {
255219
expect(scope.isDone()).toBe(true);
256220
});
257221
});
258-

0 commit comments

Comments
 (0)