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.

47 lines (46 loc) 2.29 kB
import { type AttributeMappings } from "appwrite-utils"; /** * Deeply converts all properties of an object (or array) to strings. * @param data The input data to convert. * @returns The data with all its properties converted to strings. */ export declare const deepAnyToString: (data: any) => any; /** * Performs a deep conversion of all values in a nested structure to the specified type. * Uses a conversion function like anyToString, anyToNumber, etc. * @param data The data to convert. * @param convertFn The conversion function to apply. * @returns The converted data. */ export declare const deepConvert: <T>(data: any, convertFn: (value: any) => T) => any; /** * Converts an entire object's properties to different types based on a provided schema. * @param obj The object to convert. * @param schema A mapping of object keys to conversion functions. * @returns The converted object. */ export declare const convertObjectBySchema: (obj: Record<string, any>, schema: Record<string, (value: any) => any>) => Record<string, any>; /** * Converts the keys of an object based on a provided attributeMappings. * Each key in the object is checked against attributeMappings; if a matching entry is found, * the key is renamed to the targetKey specified in attributeMappings. * * @param obj The object to convert. * @param attributeMappings The attributeMappings defining how keys in the object should be converted. * @returns The converted object with keys renamed according to attributeMappings. */ export declare const convertObjectByAttributeMappings: (obj: Record<string, any>, attributeMappings: AttributeMappings) => Record<string, any>; /** * Ensures data conversion without mutating the original input. * @param data The data to convert. * @param convertFn The conversion function to apply. * @returns The converted data. */ export declare const immutableConvert: <T>(data: any, convertFn: (value: any) => T) => T; /** * Validates a string against a regular expression and returns the string if valid, or null. * @param value The string to validate. * @param pattern The regex pattern to validate against. * @returns The original string if valid, otherwise null. */ export declare const validateString: (value: string, pattern: RegExp) => string | null;