UNPKG

@energica-city/shared-amplify-utils

Version:

Shared utilities for AWS Amplify projects

44 lines 1.75 kB
import type { OperationType, DatabaseResponse } from './types'; /** * Logs the start of a database operation. * @internal * @param nameStr - The model name * @param operation - The type of operation being performed. * @param data - Additional data to log with the operation. */ export declare const logOperation: (nameStr: string, operation: OperationType, data?: unknown) => void; /** * Logs the successful completion of a database operation. * @internal * @param operation - The type of operation that was completed. * @param additionalInfo - Any additional information to include in the log. */ export declare const logSuccess: (operation: OperationType, additionalInfo?: unknown) => void; /** * Validates a GraphQL-like response object. * Ensures the response is present, correctly structured, and free of errors. * * @template R The expected type of the `data` property in the response * @param props The arguments for the validation * @returns The `data` from the response * @throws Will throw an error if the response is invalid */ export declare const validateResponse: <R>(props: { response: { data: R | null; errors?: unknown[]; } | null | undefined; operation: string; name: string; input?: unknown; }) => R; /** * Validates a database response and returns the data if valid. * @internal * @param response - The response from the database operation. * @param operation - The type of operation that was performed. * @param input - The input that was provided to the operation. * @returns The validated data from the response. */ export declare const validateAndReturn: <T>(response: DatabaseResponse<T>, operation: string, input: unknown) => T; //# sourceMappingURL=helpers.d.ts.map