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.
123 lines (122 loc) • 4.87 kB
TypeScript
/**
* Result of discovering configuration files or collections/tables
*/
export interface DiscoveryResult {
found: boolean;
path?: string;
type: "yaml" | "typescript" | "json" | "none";
files?: string[];
}
/**
* Service for discovering Appwrite configuration files and collection/table definitions.
*
* Uses find-up for intelligent searching with git repository boundary detection:
* 1. Finds .git directory to establish repo root boundary
* 2. Searches UP from current directory to repo root
* 3. Searches DOWN recursively within repo root
*
* Search Priority:
* 1. YAML configs (.appwrite/config.yaml, .appwrite/config.yml, etc.)
* 2. JSON configs (appwrite.config.json, appwrite.json)
* 3. TypeScript configs (appwriteConfig.ts)
*/
export declare class ConfigDiscoveryService {
/**
* YAML configuration file names to search for
*/
private readonly YAML_FILENAMES;
/**
* JSON configuration file names to search for
*/
private readonly JSON_FILENAMES;
/**
* TypeScript configuration file names to search for
*/
private readonly TS_FILENAMES;
/**
* Finds the git repository root directory
* @param startDir The directory to start searching from
* @returns Path to the repository root, or startDir if no .git found
*/
private findRepoRoot;
/**
* Recursively searches downward for files matching patterns
* @param dir Directory to search in
* @param patterns File patterns to match
* @param maxDepth Maximum depth to search
* @param currentDepth Current recursion depth
* @returns First matching file path or null
*/
private searchDownward;
/**
* Finds any configuration file with configurable priority
* @param startDir The directory to start searching from
* @param preferJson If true, prioritizes appwrite.config.json over YAML (default: false)
* @returns Path to the configuration file or null if not found
*
* Default priority: YAML → JSON → TypeScript
* With preferJson=true: JSON → YAML → TypeScript
*/
findConfig(startDir: string, preferJson?: boolean): Promise<string | null>;
/**
* Finds YAML configuration files
* Searches UP to repo root, then DOWN from repo root
* @param startDir The directory to start searching from
* @param repoRoot The repository root boundary
* @returns Path to the YAML config file or null if not found
*/
findYamlConfig(startDir: string, repoRoot?: string): Promise<string | null>;
/**
* Finds JSON project configuration files (appwrite.config.json, appwrite.json)
* @param startDir The directory to start searching from
* @param repoRoot The repository root boundary
* @returns Path to the JSON config file or null if not found
*/
findProjectConfig(startDir: string, repoRoot?: string): Promise<string | null>;
/**
* Finds TypeScript configuration files (appwriteConfig.ts)
* @param startDir The directory to start searching from
* @param repoRoot The repository root boundary
* @returns Path to the TypeScript config file or null if not found
*/
findTypeScriptConfig(startDir: string, repoRoot?: string): Promise<string | null>;
/**
* Discovers collection YAML files in a collections/ directory
* @param collectionsDir Path to the collections directory
* @returns Discovery result with file paths
*/
discoverCollections(collectionsDir: string): Promise<DiscoveryResult>;
/**
* Discovers table YAML files in a tables/ directory
* @param tablesDir Path to the tables directory
* @returns Discovery result with file paths
*/
discoverTables(tablesDir: string): Promise<DiscoveryResult>;
/**
* Finds the .appwrite configuration directory
* @param startDir The directory to start searching from
* @returns Path to .appwrite directory or null if not found
*/
findAppwriteDirectory(startDir: string): Promise<string | null>;
/**
* Finds the functions directory
* @param startDir The directory to start searching from
* @returns Path to functions directory or null if not found
*/
findFunctionsDirectory(startDir: string): Promise<string | null>;
/**
* Gets a summary of all discoverable configuration files
* Useful for debugging configuration issues
* @param startDir The directory to start searching from
* @returns Object containing paths to all discovered config types
*/
getConfigurationSummary(startDir: string): Promise<{
yaml: string | null;
typescript: string | null;
json: string | null;
appwriteDirectory: string | null;
functionsDirectory: string | null;
selectedConfig: string | null;
repoRoot: string;
}>;
}