52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { z } from "zod"
|
|
|
|
export const geoipSettingsDtoSchema = z.object({
|
|
enabled: z.boolean(),
|
|
updateIntervalSec: z.number().int().positive(),
|
|
lastCheckAt: z.string().nullable(),
|
|
lastSuccessAt: z.string().nullable(),
|
|
lastError: z.string().nullable(),
|
|
countryBuildAt: z.string().nullable(),
|
|
asnBuildAt: z.string().nullable(),
|
|
updatedAt: z.string(),
|
|
})
|
|
|
|
export const geoipSettingsPatchSchema = z.object({
|
|
enabled: z.boolean().optional(),
|
|
updateIntervalSec: z
|
|
.number()
|
|
.int()
|
|
.min(6 * 3600)
|
|
.max(30 * 86400)
|
|
.optional(),
|
|
})
|
|
|
|
export const geoipStatusDtoSchema = z.object({
|
|
ready: z.boolean(),
|
|
countryLoaded: z.boolean(),
|
|
asnLoaded: z.boolean(),
|
|
countryFile: z.string(),
|
|
asnFile: z.string(),
|
|
dir: z.string(),
|
|
running: z.boolean(),
|
|
settings: geoipSettingsDtoSchema,
|
|
})
|
|
|
|
export const geoipUpdateSnapshotDtoSchema = z.object({
|
|
v: z.number(),
|
|
job: z.literal("geoip_update"),
|
|
sampledAt: z.string(),
|
|
skipped: z.boolean().optional(),
|
|
fatalError: z.string().optional(),
|
|
checked: z.number().int(),
|
|
downloaded: z.number().int(),
|
|
skippedUnchanged: z.number().int(),
|
|
bytes: z.number().int().nonnegative(),
|
|
errors: z.array(z.string()),
|
|
})
|
|
|
|
export type GeoipSettingsDto = z.infer<typeof geoipSettingsDtoSchema>
|
|
export type GeoipSettingsPatch = z.infer<typeof geoipSettingsPatchSchema>
|
|
export type GeoipStatusDto = z.infer<typeof geoipStatusDtoSchema>
|
|
export type GeoipUpdateSnapshotDto = z.infer<typeof geoipUpdateSnapshotDtoSchema>
|