import type { Context } from "../context.js"; import { Resource } from "../resource.js"; import { CloudflareApi, type CloudflareApiOptions } from "./api.js"; /** * Properties for creating or updating a KV Namespace */ export interface KVNamespaceProps extends CloudflareApiOptions { /** * Title of the namespace */ title: string; /** * KV pairs to store in the namespace * Only used for initial setup or updates */ values?: KVPair[]; } /** * Key-value pair to store in a KV Namespace */ export interface KVPair { /** * Key name */ key: string; /** * Value to store (string or JSON object) */ value: string | object; /** * Optional expiration in seconds from now */ expiration?: number; /** * Optional expiration timestamp in seconds since epoch */ expirationTtl?: number; /** * Optional metadata for the key */ metadata?: any; } /** * Output returned after KV Namespace creation/update */ export interface KVNamespace extends Resource<"cloudflare::KVNamespace">, KVNamespaceProps { type: "kv_namespace"; /** * The ID of the namespace */ namespaceId: string; /** * Time at which the namespace was created */ createdAt: number; /** * Time at which the namespace was last modified */ modifiedAt: number; } /** * A Cloudflare KV Namespace is a key-value store that can be used to store data for your application. * * @see https://developers.cloudflare.com/kv/concepts/kv-namespaces/ * * @example * // Create a basic KV namespace for storing user data * const users = await KVNamespace("users", { * title: "user-data" * }); * * @example * // Create a KV namespace with initial values and TTL * const sessions = await KVNamespace("sessions", { * title: "user-sessions", * values: [{ * key: "session_123", * value: { userId: "user_456", role: "admin" }, * expirationTtl: 3600 // Expires in 1 hour * }] * }); * * @example * // Create a KV namespace with metadata for caching * const assets = await KVNamespace("assets", { * title: "static-assets", * values: [{ * key: "main.js", * value: "content...", * metadata: { * contentType: "application/javascript", * etag: "abc123" * } * }] * }); */ export declare const KVNamespace: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context, id: string, props: KVNamespaceProps) => Promise); export declare function createKVNamespace(api: CloudflareApi, props: KVNamespaceProps): Promise<{ id: string; }>; export declare function deleteKVNamespace(api: CloudflareApi, namespaceId: string): Promise; export declare function insertKVRecords(api: CloudflareApi, namespaceId: string, props: KVNamespaceProps): Promise; //# sourceMappingURL=kv-namespace.d.ts.map