/**
 * ITransport
 *
 * Defines a transport layer interface used to send data from the SDK to a backend service.
 * This abstraction allows different transport mechanisms (HTTP, message queues, etc.)
 * without coupling the SDK to any specific implementation.
 */
interface ITransport {
    /**
     * Performs a GET request to the specified backend path.
     *
     * @param path - The endpoint to query.
     * @param payload - Optional query parameters to include.
     *
     * @returns A Promise resolving with the fetched response.
     */
    get: <T = any>(path: string, payload?: any) => Promise<T>;
    /**
     * Performs a POST request to the specified backend path.
     *
     * @param path - The endpoint to post to.
     * @param payload - The data to send in the request body.
     *
     * @returns A Promise resolving with the server response.
     */
    post: <T = any>(path: string, payload?: any) => Promise<T>;
    /**
     * Performs a PUT request to the specified backend path.
     *
     * @param path - The endpoint to update.
     * @param payload - The data to update with.
     *
     * @returns A Promise resolving with the server response.
     */
    put: <T = any>(path: string, payload?: any) => Promise<T>;
    /**
     * Performs a PATCH request to the specified backend path.
     *
     * @param path - The endpoint to partially update.
     * @param payload - The data to patch.
     *
     * @returns A Promise resolving with the server response.
     */
    patch: <T = any>(path: string, payload?: any) => Promise<T>;
    /**
     * Performs a DELETE request to the specified backend path.
     *
     * @param path - The endpoint to delete.
     * @param payload - Optional data or query parameters.
     *
     * @returns A Promise resolving with the deletion result.
     */
    delete: <T = any>(path: string, payload?: any) => Promise<T>;
}

interface IContextProvider {
    veripass_username?: string;
    app_id?: string;
    session_id?: string;
    [key: string]: any;
}

interface IEnricher {
    (event: any): Promise<any> | any;
}

interface VectryConfig {
    organizationId: string;
    baseUrl?: string;
    vectryEnvironment?: 'local' | 'development' | 'production';
    contextProvider?: () => Promise<IContextProvider>;
    transport?: ITransport;
    enrichers?: IEnricher[];
    autoFlush?: boolean;
    flushIntervalMs?: number;
}

interface Status {
    id: number;
    name: string;
    title: string;
}
interface Metadata {
    [key: string]: any;
}
interface Context {
    [key: string]: any;
}
interface AuditInfo {
    user?: {
        id: any;
    };
    timestamp?: string;
}
interface BaseModel {
    id: string;
    created: AuditInfo;
    modified?: AuditInfo;
    deleted?: AuditInfo;
    status: Status;
    metadata?: Metadata;
    context?: Context;
    [key: string]: any;
}

interface EventOperationSource {
    type: string;
    id: string;
    description: string;
}
interface EventOperationChange {
    original: Record<string, any>;
    updated: Record<string, any>;
}
interface EventOperation {
    type: string;
    system_domain: string;
    system_entity: string;
    system_entity_id: string;
    source?: EventOperationSource;
    changes?: EventOperationChange;
}
interface Event extends BaseModel {
    organization_id: string;
    namespace?: string;
    title?: string;
    details?: string;
    actor_id?: string;
    actor_type?: string;
    operation: EventOperation;
}

interface Trace {
    id: string;
    organization_id: string;
    causal_thread_id?: string;
    system_domain: string;
    system_entity: string;
    system_entity_id: string;
    start_timestamp: string;
    end_timestamp?: string;
    actor_id?: string;
    created: AuditInfo;
    modified?: AuditInfo;
    deleted?: AuditInfo;
    status: Status;
    metadata?: Metadata;
    context?: Context;
}

interface CausalThread {
    id: string;
    organization_id: string;
    causal_thread_id: string;
    system_domain: string;
    system_entity: string;
    system_entity_id: string;
    start_timestamp: string;
    end_timestamp?: string;
    outcome?: string;
    created: AuditInfo;
    modified?: AuditInfo;
    deleted?: AuditInfo;
    status: Status;
    metadata?: Metadata;
    context?: Context;
}

interface ExplanationCause {
    event_id: string;
    event_type?: string;
    timestamp?: string;
    payload?: Record<string, any>;
}
interface EventExplanation {
    id: string;
    organization_id: string;
    event_id: string;
    caused_by: ExplanationCause[];
    output: string;
    created: AuditInfo;
    modified?: AuditInfo;
    deleted?: AuditInfo;
    status: Status;
    metadata?: Metadata;
    context?: Context;
}

type AnomalyLevel = 'event' | 'trace' | 'causal_thread';
interface Anomaly {
    id: string;
    organization_id: string;
    level: AnomalyLevel;
    reference_id: string;
    anomaly_type: string;
    description?: string;
    detected_at: string;
    expected_pattern?: string[];
    actual_pattern?: string[];
    deviation_score?: number;
    event_explanation_id?: string;
    created: AuditInfo;
    modified?: AuditInfo;
    deleted?: AuditInfo;
    status: Status;
    metadata?: Metadata;
    context?: Context;
}

interface Response {
    status: string;
    success: boolean;
    message: string;
    result: any;
}

interface EndpointMap {
    get?: string;
    create?: string;
    update?: string;
    delete?: string;
    patch?: string;
    put?: string;
    [key: string]: string | undefined;
}
interface IApiService {
    config: VectryConfig;
    baseUrl: string;
    endpoints: EndpointMap;
}
declare abstract class ApiService {
    protected apiServiceConfig: VectryConfig;
    protected endpointUrl: string;
    protected endpoints: EndpointMap;
    constructor(apiServiceParameters: IApiService);
    protected objectToQueryString(obj: any): string;
    getByParameters(data: {
        queryselector: string;
        [key: string]: any;
    }): Promise<Response | undefined>;
    create(payload: any): Promise<Response | undefined>;
    update(payload: any): Promise<Response | undefined>;
    delete(payload: any): Promise<Response | undefined>;
    post(payload: any, endpoint?: string): Promise<Response | undefined>;
    put(payload: any, endpoint?: string): Promise<Response | undefined>;
    patch(payload: any, endpoint?: string): Promise<Response | undefined>;
}

declare class EventService extends ApiService {
    constructor(config: VectryConfig);
    /**
     * Fetches events based on custom filtering parameters.
     * @param data An object containing the query selector and filters.
     */
    getByParameters(data: {
        queryselector: string;
        [key: string]: any;
    }): Promise<Response | undefined>;
    /**
     * Sends a new event to the backend.
     * @param payload Event data to be created.
     */
    create(payload: Partial<Event>): Promise<Response | undefined>;
    /**
     * Updates an existing event.
     * @param payload Event data to be updated.
     */
    update(payload: Partial<Event>): Promise<Response | undefined>;
    /**
     * Deletes an event.
     * @param payload Identifier or full object of the event to delete.
     */
    delete(payload: Partial<Event>): Promise<Response | undefined>;
}

declare class EventExplanationService extends ApiService {
    constructor(config: VectryConfig);
    /**
     * Fetches events based on custom filtering parameters.
     * @param data An object containing the query selector and filters.
     */
    getByParameters(data: {
        queryselector: string;
        [key: string]: any;
    }): Promise<Response | undefined>;
    /**
     * Sends a new event to the backend.
     * @param payload EventExplanation data to be created.
     */
    create(payload: Partial<EventExplanation>): Promise<Response | undefined>;
    /**
     * Updates an existing event.
     * @param payload EventExplanation data to be updated.
     */
    update(payload: Partial<EventExplanation>): Promise<Response | undefined>;
    /**
     * Deletes an event.
     * @param payload Identifier or full object of the event to delete.
     */
    delete(payload: Partial<EventExplanation>): Promise<Response | undefined>;
}

declare class TraceService extends ApiService {
    constructor(config: VectryConfig);
    /**
     * Fetches events based on custom filtering parameters.
     * @param data An object containing the query selector and filters.
     */
    getByParameters(data: {
        queryselector: string;
        [key: string]: any;
    }): Promise<Response | undefined>;
    /**
     * Sends a new event to the backend.
     * @param payload Trace data to be created.
     */
    create(payload: Partial<Trace>): Promise<Response | undefined>;
    /**
     * Updates an existing event.
     * @param payload Trace data to be updated.
     */
    update(payload: Partial<Trace>): Promise<Response | undefined>;
    /**
     * Deletes an event.
     * @param payload Identifier or full object of the event to delete.
     */
    delete(payload: Partial<Trace>): Promise<Response | undefined>;
}

declare class CausalThreadService extends ApiService {
    constructor(config: VectryConfig);
    /**
     * Fetches events based on custom filtering parameters.
     * @param data An object containing the query selector and filters.
     */
    getByParameters(data: {
        queryselector: string;
        [key: string]: any;
    }): Promise<Response | undefined>;
    /**
     * Sends a new event to the backend.
     * @param payload CausalThread data to be created.
     */
    create(payload: Partial<CausalThread>): Promise<Response | undefined>;
    /**
     * Updates an existing event.
     * @param payload CausalThread data to be updated.
     */
    update(payload: Partial<CausalThread>): Promise<Response | undefined>;
    /**
     * Deletes an event.
     * @param payload Identifier or full object of the event to delete.
     */
    delete(payload: Partial<CausalThread>): Promise<Response | undefined>;
}

declare class AnomalyService extends ApiService {
    constructor(config: VectryConfig);
    /**
     * Fetches events based on custom filtering parameters.
     * @param data An object containing the query selector and filters.
     */
    getByParameters(data: {
        queryselector: string;
        [key: string]: any;
    }): Promise<Response | undefined>;
    /**
     * Sends a new event to the backend.
     * @param payload Anomaly data to be created.
     */
    create(payload: Partial<Anomaly>): Promise<Response | undefined>;
    /**
     * Updates an existing event.
     * @param payload Anomaly data to be updated.
     */
    update(payload: Partial<Anomaly>): Promise<Response | undefined>;
    /**
     * Deletes an event.
     * @param payload Identifier or full object of the event to delete.
     */
    delete(payload: Partial<Anomaly>): Promise<Response | undefined>;
}

declare function getCurrentTimestamp(): string;
declare function normalizeTimestamp(input: string | number | Date): string;

declare function deepClone<T>(obj: T): T;
declare function isEmptyObject(obj: Record<string, any>): boolean;

interface IMutationInput {
    original: Record<string, any>;
    updated: Record<string, any>;
    ignoreProperties?: string[];
}
/**
 * Compares two object snapshots and returns a structured mutation result.
 * Ignores any keys specified in `ignoreProperties`.
 * If no differences are found, returns null.
 *
 * @param input Object containing `original`, `updated` and optional `ignoreProperties`
 * @returns A mutation object with only the fields that changed, or null
 */
declare function detectMutation(input: IMutationInput): IMutationInput | null;

declare class VectryCore {
    private transport;
    detectMutation: typeof detectMutation;
    organizationId?: string;
    event: EventService;
    trace: TraceService;
    thread: CausalThreadService;
    eventExplanation: EventExplanationService;
    anomaly: AnomalyService;
    constructor(args: VectryConfig);
    /**
     * Captures a raw event and sends it to Vectry using the core handler.
     * Automatically enriches, validates, and dispatches the event.
     */
    capture(event: any): Promise<Response | undefined>;
}

declare function capture(event: Event): Promise<Response | undefined>;

/**
 * Enriches an Event with system-generated fields like id, created timestamp,
 * and ensures required nested objects are present.
 *
 * @param event - Partial input provided by the integrator.
 * @returns Complete Event object, ready to be validated and sent.
 */
declare function enrichEvent(event: Event): Event;

declare function validateEvent(event: Event): void;

declare const defaultConfig: VectryConfig;

/**
 * Retrieves the current Vectry runtime configuration.
 * @returns {VectryConfig}
 */
declare function getRuntimeConfig(): VectryConfig;
/**
 * Merges and updates the runtime configuration.
 * @param config Partial configuration to override defaults.
 */
declare function setRuntimeConfig(config: Partial<VectryConfig>): void;

declare const EnvironmentBaseUrls: Record<string, string>;

export { type Anomaly, type AnomalyLevel, AnomalyService, type AuditInfo, type BaseModel, type CausalThread, CausalThreadService, type Context, EnvironmentBaseUrls, type Event, type EventExplanation, EventExplanationService, type EventOperation, type EventOperationChange, type EventOperationSource, EventService, type ExplanationCause, type IContextProvider, type IEnricher, type IMutationInput, type ITransport, type Metadata, type Response, type Status, type Trace, TraceService, type VectryConfig, VectryCore, capture, deepClone, defaultConfig, detectMutation, enrichEvent, getCurrentTimestamp, getRuntimeConfig, isEmptyObject, normalizeTimestamp, setRuntimeConfig, validateEvent };
