UNPKG

appwrite-utils

Version:

`appwrite-utils` is a comprehensive TypeScript library designed to streamline the development process for Appwrite projects. Version 1.0.0 aligns with the YAML-first architecture of `appwrite-utils-cli`, providing enhanced integration capabilities and rob

38 lines (37 loc) 1.75 kB
import { Databases } from "appwrite"; /** * Tries to execute the given createFunction and retries up to 5 times if it fails. * * @param {() => Promise<any>} createFunction - The function to be executed. * @param {number} [attemptNum=0] - The number of attempts made so far (default: 0). * @return {Promise<any>} - A promise that resolves to the result of the createFunction or rejects with an error if it fails after 5 attempts. */ export declare const tryAwaitWithRetry: <T>(createFunction: () => Promise<T>, attemptNum?: number) => Promise<T>; /** * Compares existing and updated objects to determine if an update is needed. * Filters out Appwrite system fields before comparison. * * @param existing - The existing object * @param updated - The updated object * @returns true if the object needs to be updated, false otherwise */ export declare const objectNeedsUpdate: (existing: any, updated: any) => boolean; /** * Removes Appwrite system fields from an object before create/update operations. * * @param obj - The object to clean * @returns A new object with Appwrite system fields removed */ export declare const cleanObjectForAppwrite: (obj: any) => any; /** * Appwrite only supports Query.equal("$id", [someArrayOfIds]) * with 100 ids at a time, so we have this helper function to list documents in batches * * @param databases - Appwrite Databases instance * @param databaseId - Database ID * @param collectionId - Collection ID * @param field - Field to query (typically "$id") * @param ids - Array of IDs to query * @returns Array of documents */ export declare const listDocumentsBatched: <T>(databases: Databases, databaseId: string, collectionId: string, field: string, ids: string[]) => Promise<T[]>;