export { EmailStorageService, EmailAddressSchema, EmailDestinationSchema, EmailConnectionConfigSchema, EmailInboundSchema, EmailOutboundSchema, EmailAttachmentSchema, EmailStoredAttachmentSchema, EmailSendParamsSchema, EmailActivityParamsSchema, EmailActivityResultSchema, EmailActivityDataPointSchema, } from '@agentuity/core/email';
import { EmailStorageService, } from '@agentuity/core/email';
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 EmailClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the Email API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class EmailClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = EmailClientOptionsSchema.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_EMAIL_URL') || serviceUrls.email;
        const logger = validatedOptions.logger ?? createMinimalLogger();
        const headers = buildClientHeaders({
            apiKey,
            orgId: validatedOptions.orgId,
        });
        const adapter = createServerFetchAdapter({ headers }, logger);
        this.#service = new EmailStorageService(url, adapter);
    }
    async createAddress(localPart) {
        return this.#service.createAddress(localPart);
    }
    async listAddresses() {
        return this.#service.listAddresses();
    }
    async getAddress(id) {
        return this.#service.getAddress(id);
    }
    async getConnectionConfig(id) {
        return this.#service.getConnectionConfig(id);
    }
    async deleteAddress(id) {
        return this.#service.deleteAddress(id);
    }
    async createDestination(addressId, type, config) {
        return this.#service.createDestination(addressId, type, config);
    }
    async listDestinations(addressId) {
        return this.#service.listDestinations(addressId);
    }
    async deleteDestination(addressId, destinationId) {
        return this.#service.deleteDestination(addressId, destinationId);
    }
    async send(params) {
        return this.#service.send(params);
    }
    async listInbound(addressId) {
        return this.#service.listInbound(addressId);
    }
    async getInbound(id) {
        return this.#service.getInbound(id);
    }
    async deleteInbound(id) {
        return this.#service.deleteInbound(id);
    }
    async listOutbound(addressId) {
        return this.#service.listOutbound(addressId);
    }
    async getOutbound(id) {
        return this.#service.getOutbound(id);
    }
    async deleteOutbound(id) {
        return this.#service.deleteOutbound(id);
    }
    async getActivity(params) {
        return this.#service.getActivity(params);
    }
}
//# sourceMappingURL=index.js.map