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.

75 lines (74 loc) 3.31 kB
import type { AttributeMappings, ImportDef, CollectionCreate } from "appwrite-utils"; import type { ImportDataActions } from "../importDataActions.js"; /** * Service responsible for validation during import operations. * Provides centralized validation logic extracted from ImportDataActions and DataLoader. */ export declare class ValidationService { private importDataActions; constructor(importDataActions: ImportDataActions); /** * Validates a single data item based on defined validation rules. * Preserves existing validation logic from ImportDataActions. * * @param item - The data item to validate * @param attributeMappings - The attribute mappings for the data item * @param context - The context for resolving templated parameters in validation rules * @returns True if the item is valid, false otherwise */ validateDataItem(item: any, attributeMappings: AttributeMappings, context: { [key: string]: any; }): boolean; /** * Validates an import definition before processing begins. * Provides early validation to catch configuration issues. * * @param importDef - The import definition to validate * @returns Array of validation errors (empty if valid) */ validateImportDefinition(importDef: ImportDef): string[]; /** * Validates a collection configuration for import compatibility. * Ensures the collection has the necessary attributes for import operations. * * @param collection - The collection to validate * @param importDefs - The import definitions that will be used with this collection * @returns Array of validation errors (empty if valid) */ validateCollectionForImport(collection: CollectionCreate, importDefs: ImportDef[]): string[]; /** * Validates data consistency across multiple collections. * Checks for relationship integrity and data consistency. * * @param collections - Array of collections to validate * @returns Array of validation errors (empty if valid) */ validateCrossCollectionConsistency(collections: CollectionCreate[]): string[]; /** * Performs comprehensive pre-import validation. * Validates all aspects of the import configuration before starting. * * @param collections - Collections that will be imported * @param appwriteFolderPath - Path to the appwrite folder for file validation * @returns Validation result with errors and warnings */ performPreImportValidation(collections: CollectionCreate[], appwriteFolderPath: string): { errors: string[]; warnings: string[]; isValid: boolean; }; /** * Validates import progress and data integrity during import. * Can be used for periodic validation during long-running imports. * * @param processedItems - Number of items processed so far * @param totalItems - Total number of items to process * @param errorCount - Number of errors encountered * @returns Validation status with recommendations */ validateImportProgress(processedItems: number, totalItems: number, errorCount: number): { status: "healthy" | "warning" | "critical"; message: string; shouldContinue: boolean; }; }