// Generated file — do not edit by hand.
//
// Every value below is a real response from the web server, captured by the
// contract-sample test in src/web/web_integration_test.zig and canonicalized:
// object keys sorted, every number 0, strings and booleans as the deterministic
// seed produced them, repeated array elements collapsed to the first. The type
// annotations are the ones api.ts hands to its own `request<T>`, so `tsc`
// refuses a field the wire does not send, a wire field types.ts does not
// declare, and a string outside a literal union.
//
// Regenerate with:
//   zig build test -Dintegration -Dcontract-samples-out="$PWD/admin/src/lib/contractSamples.gen.ts"

import type {
	Blocklist,
	BlocklistEcho,
	CertsReload,
	Client,
	ClientPrefix,
	ConfigStatus,
	DiagnosticEvent,
	DiagnosticsPage,
	DiagnosticsPurge,
	ErrorEnvelope,
	ForwardZone,
	Group,
	Health,
	LocalRecord,
	LoginResponse,
	LogoutResponse,
	LookupResult,
	Overview,
	PauseState,
	QueriesPage,
	QueryDetail,
	Rule,
	RuleEcho,
	SettingsEnvelope,
	SourceStatus,
	Upstream,
	UpstreamEcho,
	Version,
} from "@/lib/types";

export const sample_get_health: Health = {
	diagnostics: {
		active_errors: 0,
		active_warnings: 0,
		state: "recording",
	},
	disk: {
		free_bytes: 0,
		state: "ok",
	},
	protection: {
		state: "active",
		until: null,
	},
	query_history: {
		dropped_total: 0,
		last_drop_s: null,
		state: "recording",
	},
	status: "ok",
	upstreams: {
		available: 0,
		state: "ok",
		total: 0,
	},
};

export const sample_get_version: Version = {
	git_commit: "<build>",
	uptime_seconds: 0,
	version: "w10-test",
	zig_version: "<build>",
};

export const sample_login: LoginResponse = {
	auth_required: false,
	authenticated: true,
};

export const sample_logout: LogoutResponse = {
	authenticated: false,
};

export const sample_get_diagnostics: DiagnosticsPage = {
	active: {
		errors: 0,
		warnings: 0,
	},
	events: [
		{
			code: "upstream_history.write",
			component: "upstream_history",
			detail: "Busy",
			first_seen: 0,
			id: 0,
			last_seen: 0,
			occurrences: 0,
			resolved_at: 0,
			severity: "warning",
			subject: "history",
		},
		{
			code: "blocklist.refresh",
			component: "blocklist",
			detail: "download failed: ConnectionTimedOut",
			first_seen: 0,
			id: 0,
			last_seen: 0,
			occurrences: 0,
			resolved_at: null,
			severity: "warning",
			subject: "StevenBlack",
		},
	],
	next_before: null,
};

export const sample_get_diagnostic: DiagnosticEvent = {
	code: "blocklist.refresh",
	component: "blocklist",
	detail: "download failed: ConnectionTimedOut",
	first_seen: 0,
	id: 0,
	last_seen: 0,
	occurrences: 0,
	resolved_at: null,
	severity: "warning",
	subject: "StevenBlack",
};

export const sample_purge_diagnostics: DiagnosticsPurge = {
	purged: 0,
};

export const sample_create_blocklist: BlocklistEcho = {
	enabled: false,
	id: 0,
	is_suggested: false,
	name: "ads",
	url: "https://lists.example/ads.txt",
};

export const sample_get_blocklist: Blocklist = {
	checksum: null,
	domain_count: 0,
	enabled: false,
	exception_count: 0,
	id: 0,
	is_suggested: false,
	last_updated: null,
	name: "ads",
	skipped_regex_count: 0,
	skipped_unsupported_count: 0,
	url: "https://lists.example/ads.txt",
	wildcard_count: 0,
};

export const sample_list_blocklists: { blocklists: Blocklist[] } = {
	blocklists: [
		{
			checksum: null,
			domain_count: 0,
			enabled: false,
			exception_count: 0,
			id: 0,
			is_suggested: false,
			last_updated: null,
			name: "ads",
			skipped_regex_count: 0,
			skipped_unsupported_count: 0,
			url: "https://lists.example/ads.txt",
			wildcard_count: 0,
		},
	],
};

export const sample_update_blocklist: BlocklistEcho = {
	enabled: false,
	id: 0,
	is_suggested: false,
	name: "ads2",
	url: "https://lists.example/ads.txt",
};

export const sample_update_blocklists_now: { sources: SourceStatus[] } = {
	sources: [
		{
			domains: 0,
			exceptions: 0,
			id: 0,
			last_attempt: 0,
			last_error: "",
			last_success: 0,
			loaded: false,
			skipped_regex: 0,
			skipped_unsupported: 0,
			state: "never_fetched",
			url: "https://lists.example/ads.txt",
			wildcards: 0,
		},
	],
};

export const sample_list_groups: { groups: Group[] } = {
	groups: [
		{
			id: 0,
			name: "default",
			safe_search: false,
		},
	],
};

export const sample_create_group: Group = {
	id: 0,
	name: "kids",
	safe_search: false,
};

export const sample_get_group: Group = {
	id: 0,
	name: "kids",
	safe_search: false,
};

export const sample_update_group: Group = {
	id: 0,
	name: "teens",
	safe_search: true,
};

export const sample_put_group_sources: { source_ids: number[] } = {
	source_ids: [0],
};

export const sample_get_group_sources: { source_ids: number[] } = {
	source_ids: [0],
};

export const sample_create_rule: RuleEcho = {
	action: "block",
	group_id: 0,
	id: 0,
	kind: "exact",
	pattern: "ads.example",
};

export const sample_get_rule: Rule = {
	action: "block",
	created_at: 0,
	group: "default",
	group_id: 0,
	id: 0,
	kind: "exact",
	pattern: "ads.example",
};

export const sample_list_rules: { rules: Rule[] } = {
	rules: [
		{
			action: "block",
			created_at: 0,
			group: "default",
			group_id: 0,
			id: 0,
			kind: "exact",
			pattern: "ads.example",
		},
	],
};

export const sample_update_rule: RuleEcho = {
	action: "block",
	group_id: 0,
	id: 0,
	kind: "wildcard",
	pattern: "*.ads.example",
};

export const sample_get_lookup: LookupResult = {
	blocked: true,
	domain: "sub.ads.example",
	forward_zone: null,
	group_id: 0,
	local_records: false,
	matched: "*.ads.example",
	reason: "rule_block_wildcard",
	safe_search_rewrite: null,
	source_url: null,
};

export const sample_create_local_record: LocalRecord = {
	id: 0,
	name: "nas.lan",
	rtype: "A",
	ttl: 0,
	value: "192.168.1.10",
};

export const sample_get_local_record: LocalRecord = {
	id: 0,
	name: "nas.lan",
	rtype: "A",
	ttl: 0,
	value: "192.168.1.10",
};

export const sample_list_local_records: { local_records: LocalRecord[] } = {
	local_records: [
		{
			id: 0,
			name: "nas.lan",
			rtype: "A",
			ttl: 0,
			value: "192.168.1.10",
		},
	],
};

export const sample_update_local_record: LocalRecord = {
	id: 0,
	name: "nas.lan",
	rtype: "A",
	ttl: 0,
	value: "192.168.1.11",
};

export const sample_create_forward_zone: ForwardZone = {
	id: 0,
	resolver: "udp://10.0.0.1:53",
	zone: "lan",
};

export const sample_get_forward_zone: ForwardZone = {
	id: 0,
	resolver: "udp://10.0.0.1:53",
	zone: "lan",
};

export const sample_list_forward_zones: { forward_zones: ForwardZone[] } = {
	forward_zones: [
		{
			id: 0,
			resolver: "udp://10.0.0.1:53",
			zone: "lan",
		},
	],
};

export const sample_update_forward_zone: ForwardZone = {
	id: 0,
	resolver: "udp://10.0.0.2:53",
	zone: "lan",
};

export const sample_list_clients: { clients: Client[] } = {
	clients: [
		{
			first_seen: 0,
			group: "default",
			group_id: 0,
			hand_edited: false,
			id: 0,
			ip: "192.168.1.50",
			last_seen: 0,
			learned_name: "",
			name: "laptop",
		},
	],
};

export const sample_get_client: Client = {
	first_seen: 0,
	group: "default",
	group_id: 0,
	hand_edited: false,
	id: 0,
	ip: "192.168.1.50",
	last_seen: 0,
	learned_name: "",
	name: "laptop",
};

export const sample_update_client: Client = {
	first_seen: 0,
	group: "default",
	group_id: 0,
	hand_edited: true,
	id: 0,
	ip: "192.168.1.50",
	last_seen: 0,
	learned_name: "",
	name: "laptop-renamed",
};

export const sample_put_client_prefixes: { client_prefixes: ClientPrefix[] } = {
	client_prefixes: [
		{
			group: "default",
			group_id: 0,
			id: 0,
			prefix: "192.168.1.0/24",
			priority: 0,
		},
	],
};

export const sample_list_client_prefixes: { client_prefixes: ClientPrefix[] } = {
	client_prefixes: [
		{
			group: "default",
			group_id: 0,
			id: 0,
			prefix: "192.168.1.0/24",
			priority: 0,
		},
	],
};

export const sample_list_upstreams: { upstreams: Upstream[] } = {
	upstreams: [
		{
			enabled: true,
			id: 0,
			priority: 0,
			tls_name: "",
			url: "https://dns.example/dns-query",
		},
	],
};

export const sample_create_upstream: UpstreamEcho = {
	enabled: true,
	id: 0,
	priority: 0,
	restart_required: false,
	tls_name: "",
	url: "https://dns2.example/dns-query",
};

export const sample_get_upstream: Upstream = {
	enabled: true,
	id: 0,
	priority: 0,
	tls_name: "",
	url: "https://dns.example/dns-query",
};

export const sample_update_upstream: UpstreamEcho = {
	enabled: true,
	id: 0,
	priority: 0,
	restart_required: false,
	tls_name: "",
	url: "https://dns.example/dns-query",
};

export const sample_get_queries: QueriesPage = {
	coverage: {
		available_since: 0,
		complete: false,
	},
	next_before: 0,
	queries: [
		{
			blocked: true,
			cache_hit: null,
			client_ip: "192.0.2.11",
			domain: "shop.example",
			id: 0,
			policy_action: "block",
			policy_reason: "blocklist_wildcard",
			qclass: 0,
			qtype: 0,
			rcode: 0,
			response_time_us: 0,
			route_kind: "blocked",
			ts: 0,
			upstream: "",
		},
		{
			blocked: false,
			cache_hit: false,
			client_ip: "192.0.2.10",
			domain: "news.example",
			id: 0,
			policy_action: "allow",
			policy_reason: "no_match",
			qclass: 0,
			qtype: 0,
			rcode: 0,
			response_time_us: 0,
			route_kind: "upstream",
			ts: 0,
			upstream: "https://dns.example/dns-query",
		},
		{
			blocked: false,
			cache_hit: true,
			client_ip: "192.0.2.10",
			domain: "d24.example",
			id: 0,
			policy_action: "allow",
			policy_reason: "no_match",
			qclass: 0,
			qtype: 0,
			rcode: 0,
			response_time_us: 0,
			route_kind: "cache",
			ts: 0,
			upstream: "",
		},
		{
			blocked: false,
			cache_hit: false,
			client_ip: "192.0.2.10",
			domain: "d23.example",
			id: 0,
			policy_action: "allow",
			policy_reason: "no_match",
			qclass: 0,
			qtype: 0,
			rcode: 0,
			response_time_us: 0,
			route_kind: "upstream",
			ts: 0,
			upstream: "https://dns.example/dns-query",
		},
		{
			blocked: false,
			cache_hit: true,
			client_ip: "192.0.2.10",
			domain: "d22.example",
			id: 0,
			policy_action: "allow",
			policy_reason: "no_match",
			qclass: 0,
			qtype: 0,
			rcode: 0,
			response_time_us: 0,
			route_kind: "cache",
			ts: 0,
			upstream: "",
		},
	],
};

export const sample_get_query_detail: QueryDetail = {
	group: {
		id: 0,
		name: "kids",
	},
	id: 0,
	policy: {
		action: "block",
		matched: "||tracker.example^",
		reason: "blocklist_wildcard",
		source_id: 0,
		source_name: "StevenBlack",
	},
	request: {
		client: "192.0.2.11",
		domain: "shop.example",
		qclass: 0,
		qtype: 0,
		time: 0,
	},
	response: {
		duration_us: 0,
		rcode: 0,
	},
	rewrites: {
		cname_target: "cdn.tracker.example",
		safe_search_target: "",
	},
	route: {
		forward_zone: "",
		kind: "blocked",
		upstream: "",
	},
};

export const sample_get_pause: PauseState = {
	paused: false,
	until: null,
};

export const sample_post_pause: PauseState = {
	paused: true,
	until: 0,
};

export const sample_get_settings: SettingsEnvelope = {
	restart_required: [
		"dns.bind_ipv4",
		"dns.bind_ipv6",
		"dns.port",
		"web.enabled",
		"web.bind",
		"web.port",
		"doh_server.enabled",
		"doh_server.bind",
		"doh_server.port",
		"dot_server.enabled",
		"dot_server.bind",
		"dot_server.port",
	],
	settings: {
		blocking: {
			response: "zero",
			ttl: 0,
		},
		blocklist_update: {
			enabled: true,
			interval_hours: 0,
		},
		cache: {
			negative_ttl_max: 0,
			size: 0,
		},
		disk: {
			min_free_mb: 0,
			warn_free_mb: 0,
		},
		dns: {
			bind_ipv4: "0.0.0.0",
			bind_ipv6: "::",
			port: 0,
			rate_limit: 0,
			rate_window_seconds: 0,
		},
		doh_server: {
			bind: "0.0.0.0",
			cert_path: "/etc/nxdns/cert.pem",
			enabled: false,
			key_path: "/etc/nxdns/key.pem",
			port: 0,
		},
		dot_server: {
			bind: "0.0.0.0",
			cert_path: "/etc/nxdns/cert.pem",
			enabled: false,
			key_path: "/etc/nxdns/key.pem",
			port: 0,
		},
		edns: {
			ecs_mode: "strip",
		},
		logging: {
			file_path: "/var/log/nxdns/nxdns.log",
			hide_client_ips: false,
			hide_domains: false,
			level: "info",
			max_files: 0,
			max_size_mb: 0,
			output: "stderr",
			query_log_buffer_max: 0,
			query_log_flush_interval_s: 0,
			retention_days: 0,
		},
		upstream: {
			attempt_timeout_ms: 0,
			read_timeout_ms: 0,
			total_timeout_ms: 0,
		},
		web: {
			api_localhost_exempt: true,
			api_rate_limit_per_min: 0,
			auth_enabled: false,
			bind: "0.0.0.0",
			enabled: true,
			port: 0,
			session_ttl_hours: 0,
			sse_max_connections_per_ip: 0,
			trusted_proxies: "",
		},
	},
};

export const sample_put_settings: SettingsEnvelope = {
	restart_required: [
		"dns.bind_ipv4",
		"dns.bind_ipv6",
		"dns.port",
		"web.enabled",
		"web.bind",
		"web.port",
		"doh_server.enabled",
		"doh_server.bind",
		"doh_server.port",
		"dot_server.enabled",
		"dot_server.bind",
		"dot_server.port",
	],
	settings: {
		blocking: {
			response: "zero",
			ttl: 0,
		},
		blocklist_update: {
			enabled: true,
			interval_hours: 0,
		},
		cache: {
			negative_ttl_max: 0,
			size: 0,
		},
		disk: {
			min_free_mb: 0,
			warn_free_mb: 0,
		},
		dns: {
			bind_ipv4: "0.0.0.0",
			bind_ipv6: "::",
			port: 0,
			rate_limit: 0,
			rate_window_seconds: 0,
		},
		doh_server: {
			bind: "0.0.0.0",
			cert_path: "/etc/nxdns/cert.pem",
			enabled: false,
			key_path: "/etc/nxdns/key.pem",
			port: 0,
		},
		dot_server: {
			bind: "0.0.0.0",
			cert_path: "/etc/nxdns/cert.pem",
			enabled: false,
			key_path: "/etc/nxdns/key.pem",
			port: 0,
		},
		edns: {
			ecs_mode: "strip",
		},
		logging: {
			file_path: "/var/log/nxdns/nxdns.log",
			hide_client_ips: false,
			hide_domains: false,
			level: "info",
			max_files: 0,
			max_size_mb: 0,
			output: "stderr",
			query_log_buffer_max: 0,
			query_log_flush_interval_s: 0,
			retention_days: 0,
		},
		upstream: {
			attempt_timeout_ms: 0,
			read_timeout_ms: 0,
			total_timeout_ms: 0,
		},
		web: {
			api_localhost_exempt: true,
			api_rate_limit_per_min: 0,
			auth_enabled: false,
			bind: "0.0.0.0",
			enabled: true,
			port: 0,
			session_ttl_hours: 0,
			sse_max_connections_per_ip: 0,
			trusted_proxies: "",
		},
	},
};

export const sample_get_config_status: ConfigStatus = {
	authority: "database",
	path: null,
	reconciled_at: null,
	restart_pending: true,
};

export const sample_reload_certs: CertsReload = {
	doh: {
		enabled: false,
		error: null,
		reloaded: false,
	},
	dot: {
		enabled: false,
		error: null,
		reloaded: false,
	},
};

export const sample_error_bad_request: ErrorEnvelope = {
	error: "logging.level: not one of the values this setting accepts",
};

export const sample_error_conflict: ErrorEnvelope = {
	error: "an upstream with that url already exists",
};

export const sample_error_not_found: ErrorEnvelope = {
	error: "not found",
};

export const sample_get_overview: Overview = {
	bucket_seconds: 0,
	buckets: [
		{
			blocked: 0,
			cached: 0,
			queries: 0,
			ts: 0,
		},
	],
	clients: [
		{
			buckets: [0],
			client: "192.0.2.30",
		},
		{
			buckets: [0],
			client: "192.0.2.31",
		},
		{
			buckets: [0],
			client: "192.0.2.32",
		},
	],
	coverage: {
		available_since: 0,
		complete: true,
	},
	other: [0],
	period: "1h",
	routes: [
		{
			count: 0,
			route: "upstream",
			source: "https://dns.example/dns-query",
		},
		{
			count: 0,
			route: "blocked",
			source: null,
		},
		{
			count: 0,
			route: "cache",
			source: null,
		},
		{
			count: 0,
			route: "forward_zone",
			source: "lan",
		},
		{
			count: 0,
			route: "local",
			source: null,
		},
		{
			count: 0,
			route: "rejected",
			source: null,
		},
		{
			count: 0,
			route: "upstream",
			source: "https://dns2.example/dns-query",
		},
		{
			count: 0,
			route: "upstream",
			source: null,
		},
	],
	since: 0,
	totals: {
		avg_response_time_us: 0,
		blocked: 0,
		clients: 0,
		queries: 0,
	},
	types: [
		{
			count: 0,
			qtype: 0,
		},
		{
			count: 0,
			qtype: null,
		},
	],
	until: 0,
};

export const sample_error_unauthorized: ErrorEnvelope = {
	error: "authentication required",
};

export const sample_error_rate_limited: ErrorEnvelope = {
	error: "rate limited",
};
