mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
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.
49 lines
1.4 KiB
TypeScript
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),
|
|
});
|