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 fetch-depth: 0
- name: Run Gitleaks - name: Run Gitleaks
uses: gitleaks/gitleaks-action@v3 uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Required for organization-owned repositories. # Required for organization-owned repositories.
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "umami", "name": "umami",
"version": "3.3.1", "version": "3.4.0",
"description": "A modern, privacy-focused alternative to Google Analytics.", "description": "A modern, privacy-focused alternative to Google Analytics.",
"author": "Umami Software, Inc. <hello@umami.is>", "author": "Umami Software, Inc. <hello@umami.is>",
"license": "MIT", "license": "MIT",
-1
View File
@@ -77,7 +77,6 @@ describe('UmamiClient', () => {
expect(calls[0].method).toBe('POST'); expect(calls[0].method).toBe('POST');
expect(calls[0].url.pathname).toBe('/api/websites/w1/funnels'); expect(calls[0].url.pathname).toBe('/api/websites/w1/funnels');
expect(JSON.parse(calls[0].body as string)).toEqual({ expect(JSON.parse(calls[0].body as string)).toEqual({
websiteId: 'w1',
name: 'Signup funnel', name: 'Signup funnel',
parameters: { window: 60, steps: [] }, parameters: { window: 60, steps: [] },
}); });
@@ -4,7 +4,7 @@
import type { RequestOptions } from '../types'; import type { RequestOptions } from '../types';
import type { components, operations as OperationTypes } 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'; 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( expect(
splitInput(funnelOperation, { splitInput(funnelOperation, {
websiteId: 'w', websiteId: 'w',
@@ -119,7 +119,7 @@ describe('splitInput', () => {
).toEqual({ ).toEqual({
path: { websiteId: 'w' }, path: { websiteId: 'w' },
query: {}, 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 * 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 * definition. Path parameters are only used to build the URL and are never sent in the query
* such as `browser1` or `pf_*`) and to the body otherwise. * 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( export function splitInput(
operation: OperationDefinition, operation: OperationDefinition,
@@ -103,17 +104,11 @@ export function splitInput(
for (const [key, value] of Object.entries(input)) { for (const [key, value] of Object.entries(input)) {
if (pathParams.has(key)) { if (pathParams.has(key)) {
path[key] = value; path[key] = value;
} else if (queryParams.has(key)) {
if (!operation.hasBody) {
continue;
}
}
if (queryParams.has(key)) {
query[key] = value; query[key] = value;
} else if (operation.hasBody) { } else if (operation.hasBody) {
body[key] = value; body[key] = value;
} else if (!pathParams.has(key)) { } else {
query[key] = value; query[key] = value;
} }
} }
@@ -34,7 +34,8 @@ export async function GET(
search, search,
page, page,
pageSize, 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); return json(annotations);