feat(count-aggregator): add raw-values API and Rohwerte wizard mode - #220
Conversation
🦋 Changeset detectedLatest commit: 5ddea0b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR extends the count-aggregator API + UI to support a new “raw values” (Rohwerte) mode, enabling hosts to fetch and export unaggregated telemetry via a new GET /{type}/raw-values endpoint and corresponding UI wizard option.
Changes:
- Add
/{type}/raw-valuesto the OpenAPI contract, generated client, typed helpers, and URL builders (incl. CSV export helper). - Add
features.rawValuesandValuesModeplumbing in the UI wizard (resolution select + result step) to support “raw” alongside aggregated resolutions. - Update showcase mock API + demo config to exercise the raw-values path end-to-end, plus tests/fixtures.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/count-aggregator-ui/src/types/index.ts | Introduces ValuesMode and extends config typings for raw-values mode. |
| packages/count-aggregator-ui/src/lib/i18n.ts | Adds resolution.raw translations and getValuesModeLabels. |
| packages/count-aggregator-ui/src/lib/dates.ts | Improves formatting for 5min/15min resolutions used by raw display. |
| packages/count-aggregator-ui/src/index.ts | Re-exports useRawValues. |
| packages/count-aggregator-ui/src/headless.ts | Re-exports useRawValues and getValuesModeLabels. |
| packages/count-aggregator-ui/src/config/station-types.ts | Enables rawValues feature for generated station-type app configs. |
| packages/count-aggregator-ui/src/components/wizard/result-step.tsx | Adds raw-values CSV export path + label handling and chart resolution mapping. |
| packages/count-aggregator-ui/src/components/wizard/result-step.test.tsx | Adds test coverage for Rohwerte CSV href generation. |
| packages/count-aggregator-ui/src/components/wizard/resolution-select.tsx | Generalizes selection UI from Resolution to ValuesMode. |
| packages/count-aggregator-ui/src/components/apps/count-aggregator-wizard.tsx | Wires raw-values mode into wizard state, data hooks, and metric selection behavior. |
| packages/count-aggregator-ui/src/api/mappers.ts | Adds mapper for raw-values API response into chart-compatible shape. |
| packages/count-aggregator-ui/src/api/mappers.test.ts | Adds tests for mapRawValuesMap. |
| packages/count-aggregator-ui/src/api/hooks.ts | Adds useRawValues hook backed by the new API helper. |
| packages/count-aggregator-ui/src/api/hooks.test.tsx | Adds tests verifying useRawValues request and caching behavior. |
| packages/count-aggregator-ui/README.md | Documents features.rawValues and Rohwerte in config docs. |
| packages/count-aggregator-api/src/types.ts | Exposes RawValuePoint / RawValues* response types. |
| packages/count-aggregator-api/src/lib/urls.ts | Adds raw-values URL builders (JSON + CSV). |
| packages/count-aggregator-api/src/lib/urls.test.ts | Adds tests for raw-values URL builder behavior. |
| packages/count-aggregator-api/src/index.ts | Re-exports raw-values helpers/types and URL builders. |
| packages/count-aggregator-api/src/helpers.ts | Adds typed getRawValues helper wrapping the generated client alias. |
| packages/count-aggregator-api/src/helpers.test.ts | Adds integration-style test for getRawValues using fixture. |
| packages/count-aggregator-api/src/generated/client.ts | Updates generated client schemas/endpoints to include /:type/raw-values. |
| packages/count-aggregator-api/src/fixtures/raw-values-map.json | Adds fixture data for raw-values response. |
| packages/count-aggregator-api/src/contract.test.ts | Adds contract test asserting raw-values route params shape. |
| packages/count-aggregator-api/README.md | Documents getRawValues in helper table. |
| packages/count-aggregator-api/openapi/count-aggregator.openapi.json | Adds OpenAPI path + schemas for raw-values responses. |
| apps/showcase/src/count-aggregator/count-aggregator-demo-page.tsx | Enables rawValues in showcase demo config. |
| apps/showcase/count-aggregator-mock/mock-api.ts | Adds mock implementation for /:type/raw-values (JSON + CSV). |
| .changeset/count-aggregator-ui-raw-values.md | Declares UI package minor bump for Rohwerte mode. |
| .changeset/count-aggregator-api-raw-values.md | Declares API package minor bump for raw-values endpoint support. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… max limit The raw-values contract defaults to 50 newest-first, so wizard chart and CSV exports were truncated and reversed unless the UI opted in.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 31 changed files in this pull request and generated no new comments.
Suppressed comments (5)
Previously missed (5) — in code that hasn't changed since the last review.
packages/count-aggregator-ui/src/api/hooks.ts:242
useRawValuesmodelsfromandtoas independently optional, but the OpenAPI contract requires them to be provided together (or both omitted). Encoding this in the type prevents accidental invalid requests at compile time.
export function useRawValues(
appId: string,
request: {
stationIds: readonly number[];
from?: string;
to?: string;
limit?: number;
order?: "asc" | "desc";
},
packages/count-aggregator-api/src/helpers.ts:63
RawValuesRequestcurrently allows providing onlyfromor onlyto, but the contract specifies they must be used together. Consider making the type a union so invalid combinations are rejected at compile time.
export interface RawValuesRequest {
type: StationType;
stationIds: readonly number[];
from?: string;
to?: string;
limit?: number;
order?: "asc" | "desc";
}
packages/count-aggregator-api/src/lib/urls.ts:66
MultipleRawValuesRequestallowsfrom/toindependently, but per the contract they must be provided together. Making this a union type prevents generating invalid URLs.
export interface MultipleRawValuesRequest {
type: StationType;
stationIds: readonly number[];
from?: string;
to?: string;
limit?: number;
order?: "asc" | "desc";
format?: ResponseFormat;
}
packages/count-aggregator-ui/src/components/apps/count-aggregator-wizard.tsx:237
- When
resolutionis "raw", the aggregated-values request falls back toappConfig.defaultResolution ?? "daily". If a host config omitsdefaultResolutionand also doesn’t supportdaily, this will request an unsupported resolution and can 400/fail. Prefer falling back to the first configured aggregated resolution (which is guaranteed to be supported for the station type).
resolution: isRaw
? (appConfig.defaultResolution ?? "daily")
: resolution,
apps/showcase/count-aggregator-mock/mock-api.ts:197
- The mock raw-values JSON response returns
entry.valuesas-is, ignoring the contract’sorderandlimitquery params. This can make the showcase diverge from production behavior (e.g. UI requestsorder=asc&limit=500). Consider ordering + slicing the returned series per station.
rawMap[stationId] = {
id: entry.id,
stationId: entry.stationId,
values: entry.values,
};
Summary
GET /{type}/raw-valuesto the count-aggregator OpenAPI contract, typed client, and URL helpers.features.rawValues) so hosts can fetch unaggregated values and CSV instead of a bucketed resolution.