import { z } from "zod";

export const GithubRepositorySchema = z.object({
	id: z.number(),
	name: z.string(),
	full_name: z.string(),
	html_url: z.string(),
	ssh_url: z.string(),
});

export const GithubRepositoriesSchema = z.array(GithubRepositorySchema);

export const DeployKeysSchema = z.array(
	z.object({
		id: z.number(),
		key: z.string(),
	}),
);

export const WebhookSchema = z.object({
	id: z.number(),
	config: z.object({
		url: z.string().optional(), // url might not always be present
		content_type: z.string().optional(),
	}),
	events: z.array(z.string()),
	active: z.boolean(),
});

export const ListWebhooksResponseSchema = z.array(WebhookSchema);
export type DeployKeys = z.infer<typeof DeployKeysSchema>;
export type Webhook = z.infer<typeof WebhookSchema>;
export type ListWebhooksResponse = z.infer<typeof ListWebhooksResponseSchema>;
export type GithubRepository = z.infer<typeof GithubRepositorySchema>;
export type GithubRepositories = z.infer<typeof GithubRepositoriesSchema>;
