import { newClient } from '@cipherstash/jseql-ffi';
import { LockContext } from './identify/index.cjs';
export { Context, CtsRegions, CtsToken, GetLockContextResponse, IdentifyOptions, LockContextOptions } from './identify/index.cjs';

type EncryptPayload = string | null;
type EncryptedPayload = {
    c: string;
} | null;
type BulkEncryptPayload = {
    plaintext: string;
    id: string;
}[];
type BulkEncryptedData = {
    c: string;
    id: string;
}[] | null;
type BulkDecryptedData = ({
    plaintext: string;
    id: string;
} | null)[] | null;
type EncryptOptions = {
    column: string;
    table: string;
};
type Client = Awaited<ReturnType<typeof newClient>> | undefined;
declare class EncryptOperation implements PromiseLike<EncryptedPayload> {
    private client;
    private plaintext;
    private column;
    private table;
    constructor(client: Client, plaintext: EncryptPayload, opts: EncryptOptions);
    withLockContext(lockContext: LockContext): EncryptOperationWithLockContext;
    /** Implement the PromiseLike interface so `await` works. */
    then<TResult1 = EncryptedPayload, TResult2 = never>(onfulfilled?: ((value: EncryptedPayload) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    /** Actual encryption logic, deferred until `then()` is called. */
    private execute;
    getOperation(): {
        client: Client;
        plaintext: EncryptPayload;
        column: string;
        table: string;
    };
}
declare class EncryptOperationWithLockContext implements PromiseLike<EncryptedPayload> {
    private operation;
    private lockContext;
    constructor(operation: EncryptOperation, lockContext: LockContext);
    then<TResult1 = EncryptedPayload, TResult2 = never>(onfulfilled?: ((value: EncryptedPayload) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
}
declare class DecryptOperation implements PromiseLike<string | null> {
    private client;
    private encryptedPayload;
    constructor(client: Client, encryptedPayload: EncryptedPayload);
    withLockContext(lockContext: LockContext): DecryptOperationWithLockContext;
    then<TResult1 = string | null, TResult2 = never>(onfulfilled?: ((value: string | null) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
    getOperation(): {
        client: Client;
        encryptedPayload: EncryptedPayload;
    };
}
declare class DecryptOperationWithLockContext implements PromiseLike<string | null> {
    private operation;
    private lockContext;
    constructor(operation: DecryptOperation, lockContext: LockContext);
    then<TResult1 = string | null, TResult2 = never>(onfulfilled?: ((value: string | null) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
}
declare class BulkEncryptOperation implements PromiseLike<BulkEncryptedData> {
    private client;
    private plaintexts;
    private column;
    private table;
    constructor(client: Client, plaintexts: BulkEncryptPayload, opts: EncryptOptions);
    withLockContext(lockContext: LockContext): BulkEncryptOperationWithLockContext;
    then<TResult1 = BulkEncryptedData, TResult2 = never>(onfulfilled?: ((value: BulkEncryptedData) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
    getOperation(): {
        client: Client;
        plaintexts: BulkEncryptPayload;
        column: string;
        table: string;
    };
}
declare class BulkEncryptOperationWithLockContext implements PromiseLike<BulkEncryptedData> {
    private operation;
    private lockContext;
    constructor(operation: BulkEncryptOperation, lockContext: LockContext);
    then<TResult1 = BulkEncryptedData, TResult2 = never>(onfulfilled?: ((value: BulkEncryptedData) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
}
declare class BulkDecryptOperation implements PromiseLike<BulkDecryptedData> {
    private client;
    private encryptedPayloads;
    constructor(client: Client, encryptedPayloads: BulkEncryptedData);
    withLockContext(lockContext: LockContext): BulkDecryptOperationWithLockContext;
    then<TResult1 = BulkDecryptedData, TResult2 = never>(onfulfilled?: ((value: BulkDecryptedData) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
    getOperation(): {
        client: Client;
        encryptedPayloads: BulkEncryptedData;
    };
}
declare class BulkDecryptOperationWithLockContext implements PromiseLike<BulkDecryptedData> {
    private operation;
    private lockContext;
    constructor(operation: BulkDecryptOperation, lockContext: LockContext);
    then<TResult1 = BulkDecryptedData, TResult2 = never>(onfulfilled?: ((value: BulkDecryptedData) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
    private execute;
}
declare class EqlClient {
    private client;
    private workspaceId;
    constructor();
    init(): Promise<EqlClient>;
    /**
     * Encryption - returns a thenable object.
     * Usage:
     *    await eqlClient.encrypt(plaintext, { column, table })
     *    await eqlClient.encrypt(plaintext, { column, table }).withLockContext(lockContext)
     */
    encrypt(plaintext: EncryptPayload, opts: EncryptOptions): EncryptOperation;
    /**
     * Decryption - returns a thenable object.
     * Usage:
     *    await eqlClient.decrypt(encryptedPayload)
     *    await eqlClient.decrypt(encryptedPayload).withLockContext(lockContext)
     */
    decrypt(encryptedPayload: EncryptedPayload): DecryptOperation;
    /**
     * Bulk Encrypt - returns a thenable object.
     * Usage:
     *    await eqlClient.bulkEncrypt([{ plaintext, id }, ...], { column, table })
     *    await eqlClient
     *      .bulkEncrypt([{ plaintext, id }, ...], { column, table })
     *      .withLockContext(lockContext)
     */
    bulkEncrypt(plaintexts: BulkEncryptPayload, opts: EncryptOptions): BulkEncryptOperation;
    /**
     * Bulk Decrypt - returns a thenable object.
     * Usage:
     *    await eqlClient.bulkDecrypt(encryptedPayloads)
     *    await eqlClient.bulkDecrypt(encryptedPayloads).withLockContext(lockContext)
     */
    bulkDecrypt(encryptedPayloads: BulkEncryptedData): BulkDecryptOperation;
    /** e.g., debugging or environment info */
    clientInfo(): {
        workspaceId: string | undefined;
    };
}

/**
 * This file was automatically generated by json-schema-to-typescript.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
 * and run json-schema-to-typescript to regenerate this file.
 */
type SchemaVersion = number;
type Kind = 'pt';
type Table = string;
type Column = string;
type Plaintext = string;
/**
 * Specifies that the plaintext should be encrypted for a specific query operation. If null, source encryption and encryption for all indexes will be performed.
 */
type ForQuery = 'match' | 'ore' | 'unique' | 'ste_vec' | 'ejson_path';
/**
 * The EQL plaintext JSON payload sent by a client (such as an application) to CipherStash Proxy.
 */
interface CsPlaintextV1Schema {
    v: SchemaVersion;
    k: Kind;
    i: Ident;
    p: Plaintext;
    q?: ForQuery;
    [k: string]: unknown;
}
interface Ident {
    t: Table;
    c: Column;
    [k: string]: unknown;
}

type CreateEqlPayload = {
    plaintext: Plaintext;
    table: Table;
    column: Column;
    schemaVersion?: SchemaVersion;
    queryType?: ForQuery | null;
};
type Result = {
    failure?: boolean;
    error?: Error;
    plaintext?: Plaintext;
};
declare const createEqlPayload: ({ plaintext, table, column, schemaVersion, queryType, }: CreateEqlPayload) => CsPlaintextV1Schema;
declare const getPlaintext: (payload: CsPlaintextV1Schema) => Result;

declare const eql: () => Promise<EqlClient>;

export { type Column, type CreateEqlPayload, type CsPlaintextV1Schema, EqlClient, type ForQuery, type Ident, type Kind, LockContext, type Plaintext, type Result, type SchemaVersion, type Table, createEqlPayload, eql, getPlaintext };
