import { Type } from "@sinclair/typebox";

import type { CheckerSchemas } from "../types";

import { createRawValueExpectationSchema } from "../../schema/fragments";

export const icmpCheckerSchemas: CheckerSchemas = {
  config: Type.Object(
    {
      count: Type.Optional(Type.Integer({ maximum: 100, minimum: 1 })),
      host: Type.String({ minLength: 1 }),
      packetSize: Type.Optional(Type.Integer({ maximum: 65500, minimum: 1 })),
    },
    { additionalProperties: false },
  ),
  defaults: Type.Object({}, { additionalProperties: false }),
  expect: Type.Object(
    {
      alive: Type.Optional(Type.Boolean()),
      avgLatencyMs: Type.Optional(createRawValueExpectationSchema()),
      durationMs: Type.Optional(createRawValueExpectationSchema()),
      maxLatencyMs: Type.Optional(createRawValueExpectationSchema()),
      packetLossPercent: Type.Optional(createRawValueExpectationSchema()),
    },
    { additionalProperties: false },
  ),
};
