@fjell/core
Version:
Core Item and Key Framework for Fjell
33 lines (32 loc) • 1.53 kB
TypeScript
/**
* Wrapper for find() operation
*
* Provides automatic validation for find() operation parameters and supports
* hybrid pagination approach:
* - If finder returns FindOperationResult<V>, uses it directly (opt-in)
* - If finder returns V[], applies post-processing pagination
*/
import { Coordinate, FindMethod, Item } from "@fjell/types";
import type { WrapperOptions } from "./types";
/**
* Creates a wrapped find() method with automatic parameter validation and hybrid pagination support.
*
* @param coordinate - The coordinate defining the item hierarchy
* @param implementation - The core logic for the operation
* @param options - Optional configuration
* @returns A fully validated find() method that returns FindOperationResult<V>
*
* @example
* ```typescript
* const find = createFindWrapper(
* coordinate,
* async (finder, params, locations, findOptions) => {
* const finderMethod = finders[finder];
* const result = await finderMethod(params, locations, findOptions);
* // Framework handles hybrid detection and post-processing if needed
* return result;
* }
* );
* ```
*/
export declare function createFindWrapper<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(coordinate: Coordinate<S, L1, L2, L3, L4, L5>, implementation: FindMethod<V, S, L1, L2, L3, L4, L5>, options?: WrapperOptions): FindMethod<V, S, L1, L2, L3, L4, L5>;