import { FetchAdapter } from '../adapter.ts';
import { z } from 'zod';
/**
 * Minimum TTL value in seconds (1 minute)
 */
export declare const KV_MIN_TTL_SECONDS = 60;
/**
 * Maximum TTL value in seconds (365 days)
 */
export declare const KV_MAX_TTL_SECONDS = 31536000;
/**
 * Default TTL value in seconds (7 days) - used when namespace is auto-created or no TTL specified
 */
export declare const KV_DEFAULT_TTL_SECONDS = 604800;
/**
 * the result of a data operation when the data is found
 */
export declare const DataResultFoundSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodObject<{
    data: T;
    contentType: z.ZodString;
    exists: z.ZodLiteral<true>;
    expiresAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export type DataResultFound<T> = {
    /** the data from the result of the operation */
    data: T;
    /** the content type of the data */
    contentType: string;
    /** the data was found */
    exists: true;
    /**
     * the expiration time of the data as an ISO 8601 timestamp.
     * undefined if the key does not expire.
     */
    expiresAt?: string;
};
/**
 * the result of a data operation when the data is not found
 */
export declare const DataResultNotFoundSchema: z.ZodObject<{
    data: z.ZodNever;
    exists: z.ZodLiteral<false>;
}, z.core.$strip>;
export type DataResultNotFound = z.infer<typeof DataResultNotFoundSchema>;
/**
 * the result of a data operation
 */
export declare const DataResultSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodDiscriminatedUnion<[z.ZodObject<{
    data: T;
    contentType: z.ZodString;
    exists: z.ZodLiteral<true>;
    expiresAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>, z.ZodObject<{
    data: z.ZodNever;
    exists: z.ZodLiteral<false>;
}, z.core.$strip>], "exists">;
export type DataResult<T> = DataResultFound<T> | DataResultNotFound;
export declare const KeyValueStorageSetParamsSchema: z.ZodObject<{
    ttl: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
    contentType: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export type KeyValueStorageSetParams = z.infer<typeof KeyValueStorageSetParamsSchema>;
/**
 * Parameters for creating a namespace
 */
export declare const CreateNamespaceParamsSchema: z.ZodObject<{
    defaultTTLSeconds: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
export type CreateNamespaceParams = z.infer<typeof CreateNamespaceParamsSchema>;
/**
 * Statistics for a key-value store namespace
 */
export declare const KeyValueStatsSchema: z.ZodObject<{
    sum: z.ZodNumber;
    count: z.ZodNumber;
    createdAt: z.ZodOptional<z.ZodNumber>;
    lastUsedAt: z.ZodOptional<z.ZodNumber>;
    internal: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
export type KeyValueStats = z.infer<typeof KeyValueStatsSchema>;
/**
 * Item with metadata from search results
 */
export declare const KeyValueItemWithMetadataSchema: <T extends z.ZodTypeAny>(valueSchema: T) => z.ZodObject<{
    value: T;
    contentType: z.ZodString;
    contentEncoding: z.ZodOptional<z.ZodNullable<z.ZodString>>;
    size: z.ZodNumber;
    expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
    firstUsed: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
    lastUsed: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
    count: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
}, z.core.$strip>;
export type KeyValueItemWithMetadata<T = unknown> = {
    value: T;
    contentType: string;
    contentEncoding?: string | null;
    size: number;
    expiresAt?: string | null;
    firstUsed?: number | null;
    lastUsed?: number | null;
    count?: number | null;
};
export declare const KVSortFieldSchema: z.ZodEnum<{
    name: "name";
    created: "created";
    size: "size";
    records: "records";
    lastUsed: "lastUsed";
}>;
export type KVSortField = z.infer<typeof KVSortFieldSchema>;
/**
 * Parameters for getting all namespace statistics with optional pagination
 */
export declare const GetAllStatsParamsSchema: z.ZodObject<{
    name: z.ZodOptional<z.ZodString>;
    projectId: z.ZodOptional<z.ZodString>;
    agentId: z.ZodOptional<z.ZodString>;
    projectName: z.ZodOptional<z.ZodString>;
    agentName: z.ZodOptional<z.ZodString>;
    limit: z.ZodOptional<z.ZodNumber>;
    offset: z.ZodOptional<z.ZodNumber>;
    sort: z.ZodOptional<z.ZodEnum<{
        name: "name";
        created: "created";
        size: "size";
        records: "records";
        lastUsed: "lastUsed";
    }>>;
    direction: z.ZodOptional<z.ZodEnum<{
        asc: "asc";
        desc: "desc";
    }>>;
}, z.core.$strip>;
export type GetAllStatsParams = z.infer<typeof GetAllStatsParamsSchema>;
/**
 * Paginated response for namespace statistics
 */
export declare const KeyValueStatsPaginatedSchema: z.ZodObject<{
    namespaces: z.ZodRecord<z.ZodString, z.ZodObject<{
        sum: z.ZodNumber;
        count: z.ZodNumber;
        createdAt: z.ZodOptional<z.ZodNumber>;
        lastUsedAt: z.ZodOptional<z.ZodNumber>;
        internal: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$strip>>;
    total: z.ZodNumber;
    limit: z.ZodNumber;
    offset: z.ZodNumber;
    hasMore: z.ZodBoolean;
}, z.core.$strip>;
export type KeyValueStatsPaginated = z.infer<typeof KeyValueStatsPaginatedSchema>;
export interface KeyValueStorage {
    /**
     * get a value from the key value storage
     *
     * @param name - the name of the key value storage
     * @param key - the key to get the value of
     * @returns the DataResult object
     */
    get<T>(name: string, key: string): Promise<DataResult<T>>;
    /**
     * set a value in the key value storage
     *
     * @param name - the name of the key value storage
     * @param key - the key to set the value of
     * @param value - the value to set in any of the supported data types
     * @param params - the KeyValueStorageSetParams
     */
    set<T = unknown>(name: string, key: string, value: T, params?: KeyValueStorageSetParams): Promise<void>;
    /**
     * delete a value from the key value storage
     *
     * @param name - the name of the key value storage
     * @param key - the key to delete
     */
    delete(name: string, key: string): Promise<void>;
    /**
     * get statistics for a specific namespace
     *
     * @param name - the name of the key value storage
     * @returns statistics for the namespace
     */
    getStats(name: string): Promise<KeyValueStats>;
    /**
     * get statistics for all namespaces
     *
     * @param params - optional pagination parameters
     * @returns map of namespace names to statistics, or paginated response if params provided
     */
    getAllStats(params?: GetAllStatsParams): Promise<Record<string, KeyValueStats> | KeyValueStatsPaginated>;
    /**
     * get all namespace names
     *
     * @returns array of namespace names (up to 1000)
     *
     * @remarks
     * This method returns a maximum of 1000 namespace names.
     * If you have more than 1000 namespaces, only the first 1000
     * (ordered by creation date, most recent first) will be returned.
     */
    getNamespaces(): Promise<string[]>;
    /**
     * search for keys matching a keyword
     *
     * @param name - the name of the key value storage
     * @param keyword - the keyword to search for
     * @returns map of keys to items with metadata
     */
    search<T = unknown>(name: string, keyword: string): Promise<Record<string, KeyValueItemWithMetadata<T>>>;
    /**
     * get all keys in a namespace
     *
     * @param name - the name of the key value storage
     * @returns array of keys
     */
    getKeys(name: string): Promise<string[]>;
    /**
     * delete all keys in a namespace
     *
     * @param name - the name of the key value storage
     */
    deleteNamespace(name: string): Promise<void>;
    /**
     * create a new namespace
     *
     * @param name - the name of the key value storage to create
     * @param params - optional parameters including default TTL
     */
    createNamespace(name: string, params?: CreateNamespaceParams): Promise<void>;
}
export declare class KeyValueStorageService implements KeyValueStorage {
    #private;
    constructor(baseUrl: string, adapter: FetchAdapter);
    get<T>(name: string, key: string): Promise<DataResult<T>>;
    /**
     * set a value in the key value storage
     *
     * @param name - the name of the key value storage
     * @param key - the key to set the value of
     * @param value - the value to set in any of the supported data types
     * @param params - the KeyValueStorageSetParams
     *
     * @remarks
     * TTL behavior:
     * - If TTL is not specified (undefined), the key inherits the namespace's default TTL
     * - If TTL is null or 0, the key will not expire
     * - If TTL is a positive number, the key expires after that many seconds
     * - TTL values below 60 seconds are clamped to 60 seconds by the server
     * - TTL values above 31,536,000 seconds (365 days) are clamped to 365 days
     * - If the namespace doesn't exist, it is auto-created with a 7-day default TTL
     */
    set<T = unknown>(name: string, key: string, value: T, params?: KeyValueStorageSetParams): Promise<void>;
    delete(name: string, key: string): Promise<void>;
    getStats(name: string): Promise<KeyValueStats>;
    getAllStats(params?: GetAllStatsParams): Promise<Record<string, KeyValueStats> | KeyValueStatsPaginated>;
    getNamespaces(): Promise<string[]>;
    search<T = unknown>(name: string, keyword: string): Promise<Record<string, KeyValueItemWithMetadata<T>>>;
    getKeys(name: string): Promise<string[]>;
    deleteNamespace(name: string): Promise<void>;
    createNamespace(name: string, params?: CreateNamespaceParams): Promise<void>;
}
//# sourceMappingURL=service.d.ts.map