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.
51 lines (50 loc) • 2.51 kB
TypeScript
import { type Databases, type Storage } from "node-appwrite";
import type { AppwriteConfig } from "appwrite-utils";
import { type ValidationRules, type AttributeMappings } from "appwrite-utils";
import { type ConverterFunctions } from "appwrite-utils";
import { type AfterImportActions } from "appwrite-utils";
export declare class ImportDataActions {
private db;
private storage;
private config;
private converterDefinitions;
private validityRuleDefinitions;
private afterImportActionsDefinitions;
constructor(db: Databases, storage: Storage, config: AppwriteConfig, converterDefinitions: ConverterFunctions, validityRuleDefinitions: ValidationRules, afterImportActionsDefinitions: AfterImportActions);
/**
* Runs converter functions on the item based on the provided attribute mappings.
*
* @param item - The item to be transformed.
* @param attributeMappings - The mappings that define how each attribute should be transformed.
* @returns The transformed item.
*/
runConverterFunctions(item: any, attributeMappings: AttributeMappings): any;
/**
* Validates a single data item based on defined validation rules.
* @param item The data item to validate.
* @param attributeMap The attribute mappings for the data item.
* @param context The context for resolving templated parameters in validation rules.
* @returns A promise that resolves to true if the item is valid, false otherwise.
*/
validateItem(item: any, attributeMap: AttributeMappings, context: {
[key: string]: any;
}): boolean;
executeAfterImportActions(item: any, attributeMap: AttributeMappings, context: {
[key: string]: any;
}): Promise<void>;
executeAction(actionName: string, params: any[], // Accepts any type, including objects
context: {
[key: string]: any;
}, item: any): Promise<void>;
/**
* Resolves a templated string or object using the provided context and current data item.
* If the template is a string that starts and ends with "{}", it replaces it with the corresponding value from item or context.
* If the template is an object, it recursively resolves its properties.
* @param template The templated string or object.
* @param context The context for resolving the template.
* @param item The current data item being processed.
*/
resolveTemplate(template: any, context: {
[key: string]: any;
}, item: any): any;
}