export * from "./service.js";
export * from "./types.js";
export { WebhookDeliveryNotFoundError, WebhookDestinationNotFoundError, WebhookError, WebhookNotFoundError, WebhookReceiptNotFoundError, } from "./errors.js";
import { WebhookService, } from "./service.js";
import { getServiceUrls } from '@agentuity/config';
import { createServiceAdapter, isLogger, resolveApiKey, resolveRegion, resolveServiceUrl, } from '@agentuity/client';
import { z } from 'zod';
export const WebhookClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the Webhook API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class WebhookClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = WebhookClientOptionsSchema.parse(options);
        const serviceUrls = getServiceUrls(resolveRegion());
        const url = resolveServiceUrl({
            url: validatedOptions.url,
            envKey: 'AGENTUITY_WEBHOOK_URL',
            fallback: serviceUrls.catalyst,
        });
        const { adapter } = createServiceAdapter({
            apiKey: resolveApiKey(validatedOptions.apiKey),
            orgId: validatedOptions.orgId,
            logger: validatedOptions.logger,
        });
        this.#service = new WebhookService(url, adapter);
    }
    async create(params) {
        return this.#service.create(params);
    }
    async list(params) {
        return this.#service.list(params);
    }
    async get(webhookId) {
        return this.#service.get(webhookId);
    }
    async update(webhookId, params) {
        return this.#service.update(webhookId, params);
    }
    async delete(webhookId) {
        return this.#service.delete(webhookId);
    }
    async createDestination(webhookId, params) {
        return this.#service.createDestination(webhookId, params);
    }
    async listDestinations(webhookId) {
        return this.#service.listDestinations(webhookId);
    }
    async deleteDestination(webhookId, destinationId) {
        return this.#service.deleteDestination(webhookId, destinationId);
    }
    async listReceipts(webhookId, params) {
        return this.#service.listReceipts(webhookId, params);
    }
    async getReceipt(webhookId, receiptId) {
        return this.#service.getReceipt(webhookId, receiptId);
    }
    async listDeliveries(webhookId, params) {
        return this.#service.listDeliveries(webhookId, params);
    }
    async retryDelivery(webhookId, deliveryId) {
        return this.#service.retryDelivery(webhookId, deliveryId);
    }
    async getOrgAnalytics(options) {
        return this.#service.getOrgAnalytics(options);
    }
    async getOrgTimeSeries(options) {
        return this.#service.getOrgTimeSeries(options);
    }
}
//# sourceMappingURL=index.js.map