Files
HealthLog/src/lib/validations/dawarich.ts
T
Marc-André Bombeck 3786deb503 feat(api): publish the v1.43 contract with routes that answer 501 until filled
Every new endpoint of the contract exists, wrapped in apiHandler, with its
authentication, module gate and request validation, and answers
501 not_implemented until its behaviour lands. The OpenAPI document carries
the new operations and schemas and the additive response fields on the
changed routes. The four server feature flags are published as false.

contract-stub-inventory.test.ts registers the stubbed routes; each one
leaves the register with the change that fills it. The route, sharing,
session, security, module-gate and outcome inventories name the new routes
deliberately, and the error-code catalogue lists the codes the routes emit
today.
2026-10-15 21:49:02 +02:00

49 lines
1.4 KiB
TypeScript

/**
* v1.43 — Dawarich as movement context (daily values only). Part of the
* `environment` module; every route is the caller's own record.
*/
import { z } from "zod/v4";
const dayKey = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD");
export const dawarichConnectSchema = z.strictObject({
url: z
.string()
.trim()
.max(2048)
.url()
.refine((value) => /^https?:\/\//i.test(value), "Use http or https"),
apiKey: z.string().trim().min(1).max(512),
});
export type DawarichConnectInput = z.infer<typeof dawarichConnectSchema>;
export const dawarichPlacesQuerySchema = z.strictObject({
q: z.string().trim().max(80).optional(),
});
export const dawarichSettingsSchema = z
.strictObject({
homePlaceId: z.number().int().positive().nullable().optional(),
homeCountry: z
.string()
.regex(/^[A-Z]{2}$/, "ISO 3166-1 alpha-2")
.nullable()
.optional(),
})
.refine(
(value) =>
value.homePlaceId !== undefined || value.homeCountry !== undefined,
"Send homePlaceId, homeCountry or both",
);
export type DawarichSettingsInput = z.infer<typeof dawarichSettingsSchema>;
/** At most 365 days back, checked by the route against the account's today. */
export const DAWARICH_SYNC_MAX_DAYS = 365;
export const dawarichSyncSchema = z.strictObject({
fromDate: dayKey.optional(),
});
export const dawarichDisconnectSchema = z.strictObject({
deleteData: z.boolean().optional().default(false),
});