Skip to content

feat(count-aggregator): add raw-values API and Rohwerte wizard mode - #220

Merged
pjeweb merged 5 commits into
mainfrom
feat/count-aggregator-raw-values
Aug 27, 2026
Merged

feat(count-aggregator): add raw-values API and Rohwerte wizard mode#220
pjeweb merged 5 commits into
mainfrom
feat/count-aggregator-raw-values

Conversation

@pjeweb

@pjeweb pjeweb commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add GET /{type}/raw-values to the count-aggregator OpenAPI contract, typed client, and URL helpers.
  • Add wizard Rohwerte mode (features.rawValues) so hosts can fetch unaggregated values and CSV instead of a bucketed resolution.
  • Teach the showcase mock API that path so the count-aggregator demo can exercise Raw values end to end.

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5ddea0b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@mapsight/count-aggregator-api Minor
@mapsight/count-aggregator-ui Minor

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-values to the OpenAPI contract, generated client, typed helpers, and URL builders (incl. CSV export helper).
  • Add features.rawValues and ValuesMode plumbing 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.

Comment thread packages/count-aggregator-ui/src/components/wizard/result-step.tsx
… 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.
@pjeweb
pjeweb requested a lite review from Copilot August 27, 2026 20:29
@pjeweb
pjeweb merged commit 3d7f91a into main Aug 27, 2026
22 checks passed
@pjeweb
pjeweb deleted the feat/count-aggregator-raw-values branch August 27, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • useRawValues models from and to as 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

  • RawValuesRequest currently allows providing only from or only to, 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

  • MultipleRawValuesRequest allows from/to independently, 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 resolution is "raw", the aggregated-values request falls back to appConfig.defaultResolution ?? "daily". If a host config omits defaultResolution and also doesn’t support daily, 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.values as-is, ignoring the contract’s order and limit query params. This can make the showcase diverge from production behavior (e.g. UI requests order=asc&limit=500). Consider ordering + slicing the returned series per station.
			rawMap[stationId] = {
				id: entry.id,
				stationId: entry.stationId,
				values: entry.values,
			};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants