70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
export type SearchUsageReport = {
|
|
installed: boolean;
|
|
enabled_now: boolean;
|
|
applicable: boolean;
|
|
from: string;
|
|
to: string;
|
|
timezone: string;
|
|
read_at: string;
|
|
definition_version: string;
|
|
available_definitions: string[];
|
|
definition_conflict_now: boolean;
|
|
responses: number | null;
|
|
zero_responses: number | null;
|
|
zero_rate: number | null;
|
|
channels: {
|
|
id: string;
|
|
label: string;
|
|
responses: number | null;
|
|
zero_responses: number | null;
|
|
zero_rate: number | null;
|
|
first_recorded_at: string | null;
|
|
last_recorded_at: string | null;
|
|
definition_versions: string[];
|
|
}[];
|
|
exclusions: string[];
|
|
limits: string[];
|
|
completeness: string;
|
|
temporal_basis: string;
|
|
};
|
|
export type UsageReport = {
|
|
definition_version: string;
|
|
generated_at: string;
|
|
timezone: string;
|
|
observed_before: string;
|
|
filters: {
|
|
from: string;
|
|
to: string;
|
|
service_code: string | null;
|
|
search_definition?: string;
|
|
};
|
|
search?: SearchUsageReport;
|
|
services: { code: string; title: string; version: number }[];
|
|
coverage: Record<string, number | null>;
|
|
metrics: {
|
|
id: string;
|
|
title: string;
|
|
value: number | null;
|
|
unit: string;
|
|
numerator: number | null;
|
|
denominator: number | null;
|
|
state: string;
|
|
source: string;
|
|
limits: string;
|
|
}[];
|
|
unmeasured: { id: string; title: string; reason: string; href?: string }[];
|
|
limits: string[];
|
|
fingerprint: string;
|
|
read_consistency: string;
|
|
};
|
|
|
|
export function usageValue(value: number | null, unit = ''): string {
|
|
if (value === null) return 'Sem medição';
|
|
return `${value.toLocaleString('pt-PT', { maximumFractionDigits: 2 })}${unit ? ` ${unit}` : ''}`;
|
|
}
|
|
|
|
/** Export the applied server snapshot, never the pending filter form. */
|
|
export function usageExport(report: UsageReport): string {
|
|
return JSON.stringify(report, null, 2);
|
|
}
|