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.
56 lines (55 loc) • 2.64 kB
TypeScript
import type { AttributeMappings, ConfigDatabase, CollectionCreate } from "appwrite-utils";
import type { ImportDataActions } from "../importDataActions.js";
/**
* Service responsible for data transformation during import.
* Extracted from DataLoader to provide focused, testable transformation logic.
*/
export declare class DataTransformationService {
private importDataActions;
constructor(importDataActions: ImportDataActions);
/**
* Transforms the given item based on the provided attribute mappings.
* This method applies conversion rules to the item's attributes as defined in the attribute mappings.
*
* Preserves existing transformation logic from DataLoader.
*
* @param item - The item to be transformed.
* @param attributeMappings - The mappings that define how each attribute should be transformed.
* @returns The transformed item.
*/
transformData(item: any, attributeMappings: AttributeMappings): any;
/**
* Creates a context object for data transformation.
* Preserves existing context creation logic from DataLoader.
*
* @param db - The database configuration
* @param collection - The collection configuration
* @param item - The raw item data
* @param docId - The document ID
* @returns Context object for transformation
*/
createContext(db: ConfigDatabase, collection: CollectionCreate, item: any, docId: string): any;
/**
* Merges two objects by updating the source object with the target object's values.
* Preserves existing merge logic from DataLoader.
*
* It iterates through the target object's keys and updates the source object if:
* - The source object has the key.
* - The target object's value for that key is not null, undefined, or an empty string.
* - If the target object has an array value, it concatenates the values and removes duplicates.
*
* @param source - The source object to be updated.
* @param update - The target object with values to update the source object.
* @returns The updated source object.
*/
mergeObjects(source: any, update: any): any;
/**
* Validates the transformed data item using existing validation logic.
*
* @param transformedData - The transformed data to validate
* @param attributeMappings - The attribute mappings containing validation rules
* @param context - The context for validation
* @returns True if valid, false otherwise
*/
validateTransformedData(transformedData: any, attributeMappings: AttributeMappings, context: any): boolean;
}