import { type Entity, Repository, type Search } from 'redis-om'; import { AdapterBase, type PaginationOptions, type AdapterQuery } from '@feathersjs/adapter-commons'; import { type PaginationParams, type Id, type NullableId, type Paginated } from '@feathersjs/feathers'; import { type RedisAdapterOptions, type RedisAdapterParams } from './declarations'; /** * RedisAdapter class extends the AdapterBase class to provide a Redis-based * implementation for FeathersJS services. * * @template Result - The type of the result entity. * @template Data - The type of the data for creating/updating entities. * @template ServiceParams - The type of the service parameters. * @template PatchData - The type of the data for patching entities. */ export declare class RedisAdapter, ServiceParams extends RedisAdapterParams = RedisAdapterParams, PatchData = Partial> extends AdapterBase { repository: Repository; expiration: number | undefined; /** * Constructor for the RedisAdapter class. * * @param options - The options for the Redis adapter, including the Redis client and schema. * @throws {Error} If the options, Model, or schema are not provided. */ constructor(options: RedisAdapterOptions); /** * Function to set the expiration time for a key in Redis. * * @param key - The key to set the expiration time for. * @param seconds - The number of seconds to set the expiration time for. * @returns A promise that resolves when the expiration time is set. */ expire(key: string, seconds: number): Promise; expire(key: Result, seconds: number): Promise; /** * Function to create redis-om queries based on the FeathersJS query object. * * @param search - The Redis OM search instance. * @param query - The FeathersJS query object. * @param parentKey - The parent key for nested queries. * @returns The modified search instance. */ redisQuery(search: Search, query: AdapterQuery, parentKey?: string): any; /** * Filters the query parameters to extract pagination and sorting options. * * @param params - The service parameters. * @returns An object containing pagination, filters, and the query. */ filterQuery(params: ServiceParams): { paginate?: PaginationParams; filters: { $select?: string[]; $sort?: Record; $limit: number; $skip: number; }; query: AdapterQuery; }; /** * Finds entities based on the provided parameters. * * @param params - The service parameters, including pagination options. * @returns A promise that resolves to the found entities or paginated results. */ _find(params?: ServiceParams & { paginate?: PaginationOptions; }): Promise>; _find(params?: ServiceParams & { paginate: false; }): Promise; _find(params?: ServiceParams): Promise | Result[]>; /** * Retrieves an entity by its ID. * * @param id - The ID of the entity to retrieve. * @param _params - The service parameters. * @returns A promise that resolves to the retrieved entity. * @throws {NotFound} If no record is found for the given ID. */ _get(id: Id, _params?: ServiceParams): Promise; /** * Creates a new entity or entities. * * @param data - The data for the new entity or entities. * @param _params - The service parameters. * @returns A promise that resolves to the created entity or entities. */ _create(data: Data, _params?: ServiceParams): Promise; _create(data: Data[], _params?: ServiceParams): Promise; /** * Patches an existing entity by its ID. * * @param id - The ID of the entity to patch. * @param data - The data to patch the entity with. * @param params - The service parameters. * @returns A promise that resolves to the patched entity or entities. * @throws {MethodNotAllowed} If attempting to patch multiple entries without an ID. */ _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise; _patch(id: Id, data: PatchData | Partial, params?: ServiceParams): Promise; _patch(id: NullableId, data: PatchData | Partial, _params?: ServiceParams): Promise; /** * Updates an existing entity by its ID. * * @param id - The ID of the entity to update. * @param data - The data to update the entity with. * @param _params - The service parameters. * @returns A promise that resolves to the updated entity. * @throws {BadRequest} If no ID is provided. * @throws {NotFound} If no record is found for the given ID. */ _update(id: string, data: Data, _params?: ServiceParams): Promise; /** * Removes an entity by its ID. * * @param id - The ID of the entity to remove. * @param params - The service parameters. * @returns A promise that resolves to the removed entity or entities. * @throws {MethodNotAllowed} If attempting to remove multiple entries without an ID. */ _remove(id: Id, params?: ServiceParams): Promise; _remove(id: null, params?: ServiceParams): Promise; _remove(id: NullableId, params?: ServiceParams): Promise; }