2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
/** @see {@link https://docs.joinmastodon.org/entities/Admin_Measure/} */
|
2024-10-13 15:25:30 -07:00
|
|
|
const adminMeasureSchema = v.object({
|
|
|
|
key: v.string(),
|
|
|
|
unit: v.fallback(v.nullable(v.string()), null),
|
2024-10-14 13:50:34 -07:00
|
|
|
total: v.pipe(v.unknown(), v.transform(Number)),
|
2024-10-13 15:25:30 -07:00
|
|
|
human_value: v.fallback(v.optional(v.string()), undefined),
|
2024-10-14 13:50:34 -07:00
|
|
|
previous_total: v.fallback(v.optional(v.pipe(v.unknown(), v.transform(String))), undefined),
|
|
|
|
data: v.array(v.object({
|
2024-08-28 04:43:23 -07:00
|
|
|
date: z.string().datetime({ offset: true }),
|
2024-10-14 13:50:34 -07:00
|
|
|
value: v.pipe(v.unknown(), v.transform(String)),
|
2024-08-28 04:43:23 -07:00
|
|
|
})),
|
|
|
|
});
|
|
|
|
|
2024-10-13 15:25:30 -07:00
|
|
|
type AdminMeasure = v.InferOutput<typeof adminMeasureSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export {
|
|
|
|
adminMeasureSchema,
|
|
|
|
type AdminMeasure,
|
|
|
|
};
|