UNPKG

amplifyquery

Version:
142 lines (141 loc) 4.89 kB
import { getClient } from "./client"; import { queryClient, getQueryClient, createQueryKeys, invalidateModel, invalidateModelItem, invalidateModelByField, invalidateAll, ensureMutationsFlushed } from "./query"; import { createAmplifyService } from "./service"; import { createSingletonService } from "./singleton"; import { AmplifyQueryConfig } from "./types"; import { createRelationalHook, setAppUrl, getAppUrl } from "./utils"; import { setModelOwnerQueryMap, setDefaultAuthMode, getModelOwnerQueryMap, getDefaultAuthMode, resetConfig } from "./config"; /** * Initialization function for the AmplifyQuery library. * * This function must be called before using the library. * * @example * ```typescript * import { generateClient } from 'aws-amplify/api'; * import { AmplifyQuery } from 'amplifyquery'; * * // Create Amplify client and initialize AmplifyQuery * const client = generateClient(); * AmplifyQuery.configure({ * client, * // Additional caching options, etc. * isCachingEnabled: true, * storage: { * mmkvId: "custom.cache", * maxAge: 1000 * 60 * 60 * 24 // 1 day * } * }); * ``` */ export declare function configure(config: AmplifyQueryConfig): void; export * from "./types"; export { queryClient, getQueryClient, invalidateModel, invalidateModelItem, invalidateModelByField, invalidateAll, ensureMutationsFlushed, createQueryKeys, }; export { getClient }; export * from "./provider"; export declare const Utils: { getUserId: () => Promise<string>; formatTimestamp: (date?: Date) => string; getDateString: (dateStr: string | undefined) => string; removeOwnerField: <T extends Record<string, any>>(data: T, operation: "create" | "update" | "upsert") => Omit<T, "owner">; }; export declare const Storage: { _types: { Item: { url: string; expiresAt: number; }; CacheData: { [key: string]: { url: string; expiresAt: number; }; }; }; _urlCache: Map<string, { url: string; expiresAt: number; }>; _CACHE_KEY: string; _initialized: boolean; _initCache: () => void; _saveCache: () => void; uploadImage: (file: Blob | File, key?: string) => Promise<string>; getFileUrl: (key: string, options?: { forceRefresh?: boolean; }) => Promise<string>; deleteFile: (key: string) => Promise<void>; clearUrlCache: () => void; clearUrlCacheForKey: (key: string) => void; clearExpiredUrlCache: () => void; downloadAudioFile: (audioKey: string) => Promise<string>; }; export declare const Auth: { getCurrentUserInfo: () => Promise<{ userId: string; username: string; }>; }; export { setAppUrl, getAppUrl }; /** * Main object for the AmplifyQuery library. */ export declare const AmplifyQuery: { configure: typeof configure; createQueryKeys: typeof createQueryKeys; createAmplifyService: typeof createAmplifyService; createSingletonService: typeof createSingletonService; createRelationalHook: typeof createRelationalHook; Utils: { getUserId: () => Promise<string>; formatTimestamp: (date?: Date) => string; getDateString: (dateStr: string | undefined) => string; removeOwnerField: <T extends Record<string, any>>(data: T, operation: "create" | "update" | "upsert") => Omit<T, "owner">; }; Storage: { _types: { Item: { url: string; expiresAt: number; }; CacheData: { [key: string]: { url: string; expiresAt: number; }; }; }; _urlCache: Map<string, { url: string; expiresAt: number; }>; _CACHE_KEY: string; _initialized: boolean; _initCache: () => void; _saveCache: () => void; uploadImage: (file: Blob | File, key?: string) => Promise<string>; getFileUrl: (key: string, options?: { forceRefresh?: boolean; }) => Promise<string>; deleteFile: (key: string) => Promise<void>; clearUrlCache: () => void; clearUrlCacheForKey: (key: string) => void; clearExpiredUrlCache: () => void; downloadAudioFile: (audioKey: string) => Promise<string>; }; Auth: { getCurrentUserInfo: () => Promise<{ userId: string; username: string; }>; }; getModelIds: { User: () => Promise<string>; }; getQueryClient: typeof getQueryClient; setModelOwnerQueryMap: typeof setModelOwnerQueryMap; getModelOwnerQueryMap: typeof getModelOwnerQueryMap; setDefaultAuthMode: typeof setDefaultAuthMode; getDefaultAuthMode: typeof getDefaultAuthMode; resetConfig: typeof resetConfig; };