Fix API client path parameter handling and release version 3.4.0

This commit is contained in:
Mike Cao committed 2026-09-16 20:49:32 -07:00
1 parent 587bfafb47
commit f661219128
7 files changed
+12 -17

No files matched your search

-1
View File
@@ -77,7 +77,6 @@ describe('UmamiClient', () => {
expect(calls[0].method).toBe('POST');
expect(calls[0].url.pathname).toBe('/api/websites/w1/funnels');
expect(JSON.parse(calls[0].body as string)).toEqual({
websiteId: 'w1',
name: 'Signup funnel',
parameters: { window: 60, steps: [] },
});
@@ -4,7 +4,7 @@
import type { RequestOptions } from '../types';
import type { components, operations as OperationTypes } from './types';
export const API_VERSION = '3.3.1';
export const API_VERSION = '3.4.0';
export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
+2 -2
View File
@@ -109,7 +109,7 @@ describe('splitInput', () => {
});
});
test('routes unknown keys to the body for operations with a request body', () => {
test('routes unknown keys to the body and keeps path params out of it', () => {
expect(
splitInput(funnelOperation, {
websiteId: 'w',
@@ -119,7 +119,7 @@ describe('splitInput', () => {
).toEqual({
path: { websiteId: 'w' },
query: {},
body: { websiteId: 'w', name: 'Signup', parameters: { steps: [] } },
body: { name: 'Signup', parameters: { steps: [] } },
});
});
});
+5 -10
View File
@@ -87,8 +87,9 @@ export interface SplitInput {
/**
* Splits a flat input object into path params, query params and body according to the operation
* definition. Unknown keys go to the query string for body-less operations (dynamic filter params
* such as `browser1` or `pf_*`) and to the body otherwise.
* definition. Path parameters are only used to build the URL and are never sent in the query
* string or JSON body. Unknown keys go to the query string for body-less operations (dynamic
* filter params such as `browser1` or `pf_*`) and to the body otherwise.
*/
export function splitInput(
operation: OperationDefinition,
@@ -103,17 +104,11 @@ export function splitInput(
for (const [key, value] of Object.entries(input)) {
if (pathParams.has(key)) {
path[key] = value;
if (!operation.hasBody) {
continue;
}
}
if (queryParams.has(key)) {
} else if (queryParams.has(key)) {
query[key] = value;
} else if (operation.hasBody) {
body[key] = value;
} else if (!pathParams.has(key)) {
} else {
query[key] = value;
}
}