UNPKG

@energica-city/shared-amplify-utils

Version:

Shared utilities for AWS Amplify projects

40 lines 1.72 kB
import type { AmplifyModelType, QueryFactoryConfig, QueryFactoryResult } from './types'; /** * Creates type-safe CRUD operations for AWS Amplify Data models. * * Generates a complete set of database operations (create, read, update, delete, list) * with comprehensive error handling, logging, and optional caching. All operations * preserve TypeScript types across package boundaries. * * **Features:** * - Type-safe operations with full TypeScript support * - Automatic error handling and logging * - Optional LRU caching with smart invalidation * - Pagination support with automatic following * - Schema-aware identifier extraction * - Client isolation via unique keys * * @template Types - Record of all available Amplify model types * @template TName - Specific model name as string literal * @param config - Configuration object for factory creation * @returns Promise resolving to complete CRUD operations interface * * @example * ```typescript * const userFactory = await QueryFactory({ * name: "User", * clientKey: "main", * cache: { enabled: true, maxSize: 10 * 1024 * 1024 } * }); * * const user = await userFactory.get({ input: { userId: "123" } }); * const users = await userFactory.list({ limit: 50, followNextToken: true }); * ``` */ export declare function QueryFactory<Types extends Record<string, AmplifyModelType>, TName extends keyof Types & string>(config: QueryFactoryConfig<TName>): Promise<QueryFactoryResult<TName, Types>>; /** * Selection set type for specifying which fields to retrieve. * Supports dot notation for nested fields (e.g., 'author.email', 'posts.*') */ export type SelectionSet = readonly string[]; //# sourceMappingURL=QueryFactory.d.ts.map