ws.ts 756 B

1234567891011121314151617
  1. import { z } from 'zod';
  2. // WebSocket stream uses the flat V1-style header map (string values only,
  3. // not arrays — the panel calls toV2Headers with arr=false). `path` and
  4. // `host` are the WS request line / Host header overrides. `heartbeatPeriod`
  5. // in seconds; 0 disables heartbeats.
  6. export const WsHeaderMapSchema = z.record(z.string(), z.string());
  7. export type WsHeaderMap = z.infer<typeof WsHeaderMapSchema>;
  8. export const WsStreamSettingsSchema = z.object({
  9. acceptProxyProtocol: z.boolean().default(false),
  10. path: z.string().default('/'),
  11. host: z.string().default(''),
  12. headers: WsHeaderMapSchema.default({}),
  13. heartbeatPeriod: z.number().int().min(0).default(0),
  14. });
  15. export type WsStreamSettings = z.infer<typeof WsStreamSettingsSchema>;