/** * Platform Portability Layer * * Abstracts Cloudflare D1/KV behind platform-agnostic interfaces. * Zero changes to route handlers - swap happens transparently. * * Philosophy: The tool recedes; only the work remains. * * @example * ```typescript * import { getPlatform } from '@create-something/components/platform'; * * export const load: PageServerLoad = async ({ platform }) => { * const { DB, CACHE } = await getPlatform(platform); * const result = await DB.prepare('SELECT * FROM users').all(); * return { users: result.results }; * }; * ``` */ export * from './types.js'; export { detectMode, isLocalMode, isCloudflareMode, getConfig } from './detect.js'; export { wrapD1, isD1Database } from './database/cloudflare.js'; export { createLocalDatabase, findLocalD1Path } from './database/sqlite.js'; export { wrapKV, isKVNamespace } from './cache/cloudflare.js'; export { createFileCache } from './cache/file.js'; import type { PlatformEnv, PlatformConfig, Database, Cache } from './types.js'; /** * Get platform with abstracted database and cache. * * Automatically detects whether running on Cloudflare or locally, * and returns the appropriate implementations. * * @param platform - SvelteKit platform object (from PageServerLoad or RequestHandler) * @param config - Optional configuration override * @returns Platform environment with DB and CACHE bindings * * @example * ```typescript * // In +page.server.ts or +server.ts * export const load: PageServerLoad = async ({ platform }) => { * const { DB, CACHE } = await getPlatform(platform); * * // Works identically on Cloudflare or local Mac Mini * const result = await DB.prepare('SELECT * FROM papers').all(); * return { papers: result.results }; * }; * ``` */ export declare function getPlatform(platform?: { env?: Record; }, config?: Partial): Promise; /** * Get database only (convenience function). * * @param platform - SvelteKit platform object * @returns Database interface */ export declare function getDatabase(platform?: { env?: Record; }): Promise; /** * Get cache only (convenience function). * * @param platform - SvelteKit platform object * @returns Cache interface */ export declare function getCache(platform?: { env?: Record; }): Promise; /** * Reset local instances (for testing). * Clears the singleton cache so new instances will be created. */ export declare function resetLocalInstances(): void;