semantic update

This commit is contained in:
2026-02-24 21:08:12 +03:00
parent 7a12ed0931
commit 95ae9c6af1
32 changed files with 60376 additions and 59911 deletions

View File

@@ -13,6 +13,7 @@ import { api } from '../api.js';
// @PRE: options is an object with optional report query fields.
// @POST: Returns URL query string without leading '?'.
export function buildReportQueryString(options = {}) {
console.log("[reports][api][buildReportQueryString:START]");
const params = new URLSearchParams();
if (options.page != null) params.append('page', String(options.page));
@@ -40,6 +41,7 @@ export function buildReportQueryString(options = {}) {
// @PRE: error may be Error/string/object.
// @POST: Returns structured error object.
export function normalizeApiError(error) {
console.log("[reports][api][normalizeApiError:START]");
const message =
(error && typeof error.message === 'string' && error.message) ||
(typeof error === 'string' && error) ||
@@ -59,9 +61,13 @@ export function normalizeApiError(error) {
// @POST: Returns parsed payload or structured error for UI-state mapping.
export async function getReports(options = {}) {
try {
console.log("[reports][api][getReports:STARTED]", options);
const query = buildReportQueryString(options);
return await api.fetchApi(`/reports${query ? `?${query}` : ''}`);
const res = await api.fetchApi(`/reports${query ? `?${query}` : ''}`);
console.log("[reports][api][getReports:SUCCESS]", res);
return res;
} catch (error) {
console.error("[reports][api][getReports:FAILED]", error);
throw normalizeApiError(error);
}
}
@@ -73,8 +79,12 @@ export async function getReports(options = {}) {
// @POST: Returns parsed detail payload or structured error object.
export async function getReportDetail(reportId) {
try {
return await api.fetchApi(`/reports/${reportId}`);
console.log(`[reports][api][getReportDetail:STARTED] id=${reportId}`);
const res = await api.fetchApi(`/reports/${reportId}`);
console.log(`[reports][api][getReportDetail:SUCCESS] id=${reportId}`);
return res;
} catch (error) {
console.error(`[reports][api][getReportDetail:FAILED] id=${reportId}`, error);
throw normalizeApiError(error);
}
}