UNPKG

appwrite-utils-cli

Version:

Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.

59 lines (58 loc) 2.31 kB
/** * Version Detection Utility for Appwrite API Compatibility * * This module provides functions to detect whether an Appwrite instance * supports the new TablesDB API or uses the legacy Databases API. * * Detection Strategy: * 1. Primary: Test TablesDB-specific endpoint availability * 2. Secondary: Health endpoint version check * 3. Fallback: Default to legacy mode for safety */ export type ApiMode = 'legacy' | 'tablesdb'; export interface VersionDetectionResult { apiMode: ApiMode; detectionMethod: 'endpoint_probe' | 'health_check' | 'fallback'; serverVersion?: string; confidence: 'high' | 'medium' | 'low'; } /** * Detects Appwrite API version and TablesDB support * * @param endpoint - Appwrite server endpoint URL * @param project - Project ID * @param apiKey - API key for authentication * @returns Promise resolving to version detection result */ export declare function detectAppwriteVersion(endpoint: string, project: string, apiKey: string): Promise<VersionDetectionResult>; /** * Cached version detection with automatic cache management * * @param endpoint - Appwrite server endpoint URL * @param project - Project ID * @param apiKey - API key for authentication * @param forceRefresh - Skip cache and force fresh detection * @returns Promise resolving to version detection result */ export declare function detectAppwriteVersionCached(endpoint: string, project: string, apiKey: string, forceRefresh?: boolean): Promise<VersionDetectionResult>; /** * Quick check for cloud.appwrite.io instances (likely have TablesDB) * * @param endpoint - Appwrite server endpoint URL * @returns boolean indicating if endpoint is likely cloud-hosted */ export declare function isCloudAppwriteEndpoint(endpoint: string): boolean; /** * SDK feature detection as a fallback method * Attempts to dynamically import TablesDB to check availability */ /** * Clear version detection cache (useful for testing) */ export declare function clearVersionDetectionCache(): void; /** * Fetch server version from /health/version (no auth required) */ export declare function fetchServerVersion(endpoint: string): Promise<string | null>; /** Compare semantic versions (basic) */ export declare function isVersionAtLeast(current: string | undefined, target: string): boolean;