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 -1
View File
@@ -19,7 +19,7 @@ jobs:
fetch-depth: 0
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v3
uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Required for organization-owned repositories.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "umami",
"version": "3.3.1",
"version": "3.4.0",
"description": "A modern, privacy-focused alternative to Google Analytics.",
"author": "Umami Software, Inc. <hello@umami.is>",
"license": "MIT",
-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;
}
}
@@ -34,7 +34,8 @@ export async function GET(
search,
page,
pageSize,
...(startAt && endAt && { startDate: new Date(startAt), endDate: new Date(endAt) }),
...(startAt != null &&
endAt != null && { startDate: new Date(startAt), endDate: new Date(endAt) }),
});
return json(annotations);