import { type ArrayFactory, type AsyncArrayFactory } from '../array/array.factory'; import { type FilterUniqueFunction } from '../array/array.unique'; import { type PrimativeKey } from '../key'; import { type AsyncMapFunction, type MapFunction } from '../value/map'; /** * Used to verify each id valid and available for use. */ export type IdBatchVerifierFunction = AsyncMapFunction>; /** * Used by to verify tags have not already been taken. */ export type IdBatchVerifier = { /** * (Optional) Use to filter unique key values. */ filterUnique?: FilterUniqueFunction; verify: IdBatchVerifierFunction; /** * Max number of tags that can be verified per batch. */ maxBatchSize: number; }; export interface IdBatchFactoryConfig { readonly factory: ArrayFactory; readonly verifier: IdBatchVerifier; } /** * Used to generate valid, unused identifiers. */ export type IdBatchFactory = AsyncArrayFactory; /** * Creates an {@link IdBatchFactory} that generates batches of unique, verified identifiers. * * The factory generates identifiers in batches, filters them for uniqueness, and verifies each batch * using the configured verifier. Throws if uniqueness generation fails repeatedly (after 20 attempts). * * @param config - Configuration with the base factory for generating candidates and the verifier for validating them * @returns An async factory function that produces the requested number of valid identifiers * @throws Error if the factory cannot produce enough unique values after repeated attempts */ export declare function idBatchFactory(config: IdBatchFactoryConfig): IdBatchFactory;