export { WebhookService, WebhookSchema, WebhookDestinationSchema, WebhookDeliverySchema, WebhookReceiptSchema, CreateWebhookRequestSchema, CreateWebhookDestinationRequestSchema, UpdateWebhookRequestSchema, WebhookApiOptionsSchema, WebhookDeliveryStatusSchema, WebhookDestinationTypeSchema, WebhookAnalyticsGranularitySchema, WebhookAnalyticsOptionsSchema, WebhookAnalyticsSummarySchema, WebhookOrgAnalyticsSchema, WebhookTimePeriodSchema, WebhookTimeSeriesDataSchema, WebhookTimeSeriesPointSchema, WebhookNotFoundError, WebhookDestinationNotFoundError, WebhookDeliveryNotFoundError, WebhookReceiptNotFoundError, WebhookError, } from '@agentuity/core/webhook';
import { WebhookService, } from '@agentuity/core/webhook';
import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/server';
import { createMinimalLogger } from '@agentuity/core';
import { getEnv } from '@agentuity/core';
import { getServiceUrls } from '@agentuity/core/config';
import { z } from 'zod';
const isLogger = (val) => typeof val === 'object' &&
    val !== null &&
    ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function');
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 apiKey = validatedOptions.apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
        const region = getEnv('AGENTUITY_REGION') ?? 'usc';
        const serviceUrls = getServiceUrls(region);
        const url = validatedOptions.url || getEnv('AGENTUITY_WEBHOOK_URL') || serviceUrls.catalyst;
        const logger = validatedOptions.logger ?? createMinimalLogger();
        const headers = buildClientHeaders({
            apiKey,
            orgId: validatedOptions.orgId,
        });
        const adapter = createServerFetchAdapter({ headers }, 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