kozukata-toa/src/servers/allnet/types/download-report.ts

36 lines
953 B
TypeScript

import { z } from "zod";
const zodOptionalInteger = z.number().int().optional();
export const DownloadOptImageReportSchema = z.object({
serial: z.string().min(1).max(11),
dfl: z.array(z.string().min(1)).optional(),
wfl: z.array(z.string().min(1)).optional(),
tsc: z.number().int(),
tdsc: z.number().int(),
at: zodOptionalInteger,
ot: zodOptionalInteger,
rt: zodOptionalInteger,
as: z.number().int().gte(1).lte(2),
rf_state: zodOptionalInteger,
gd: z.string(),
dav: z.string(),
dov: z.string(),
});
export const DownloadAppImageReportSchema = DownloadOptImageReportSchema.extend({
wdav: z.string(),
wdov: z.string(),
});
export const DownloadReportSchema = z
.object({
appimage: DownloadAppImageReportSchema.optional(),
optimage: DownloadOptImageReportSchema.optional(),
})
// One of these must be present
.refine(
(arg) => !!arg.appimage || !!arg.optimage,
"At least one of 'appimage' or 'optimage' must be available"
);