import { d as HookFunction, g as PredicateFn } from "./hook-context-BsxU1vfN.mjs"; import { FeathersError } from "@feathersjs/errors"; import { HookContext, NextFunction } from "@feathersjs/feathers"; //#region src/hooks/iff-else/iff-else.hook.d.ts /** * Executes one array of hooks when the predicate is truthy, or another array when it is falsy. * The predicate can be a boolean or a sync/async function. * Unlike `iff`, both branches are provided upfront without chaining. * * @example * ```ts * import { iffElse, isProvider } from 'feathers-utils/predicates' * * app.service('users').hooks({ * before: { * find: [iffElse(isProvider('external'), [hook1()], [hook2()])] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/iff-else.html */ declare function iffElse(predicate: boolean | PredicateFn, trueHook: HookFunction | HookFunction[] | undefined, falseHook?: HookFunction | HookFunction[] | undefined): (this: any, ctx: H, next?: NextFunction) => HookContext, any> | Promise; //#endregion //#region src/hooks/iff/iff.hook.d.ts interface IffHook extends HookFunction { else(...hooks: HookFunction[]): HookFunction; } /** * Conditionally executes a series of hooks when the predicate is truthy. * The predicate can be a boolean value or a sync/async function. * Supports an `.else(...)` chain for the falsy branch. Also exported as `when`. * * @example * ```ts * import { iff, isProvider } from 'feathers-utils/predicates' * * app.service('users').hooks({ * before: { * find: [iff(isProvider('external'), authenticate('jwt'))] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/iff.html */ declare function iff(predicate: boolean | PredicateFn, ...hooks: HookFunction[]): IffHook; //#endregion //#region src/hooks/skippable/skippable.hook.d.ts /** * Wraps a hook so it can be conditionally skipped based on a predicate. * When the predicate returns `true`, the wrapped hook is skipped entirely. * Commonly used with `shouldSkip` and `addSkip` for runtime hook control. * * @example * ```ts * import { skippable, shouldSkip } from 'feathers-utils/predicates' * * const myHook = skippable(someHook(), shouldSkip('someHook')) * ``` * * @see https://utils.feathersjs.com/hooks/skippable.html */ declare const skippable: (innerHook: HookFunction, predicate: PredicateFn) => { (context: H): H | void | Promise; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/throw-if/throw-if.hook.d.ts type ThrowIfOptions = { /** * Customize the error that is thrown if the predicate returns true. * * If not provided, throws a `BadRequest` error with 'Invalid operation'. */ error?: (context: HookContext) => FeathersError; }; /** * Throws a `BadRequest` error when the given predicate function returns `true`. * The predicate receives the hook context and can be async. * Useful for validating conditions before proceeding with a request. * * @example * ```ts * import { throwIf } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { remove: [throwIf((context) => context.id === context.params.user?.id)] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/throw-if.html */ declare const throwIf: (predicate: PredicateFn, options?: ThrowIfOptions) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/unless/unless.hook.d.ts /** * Executes a series of hooks when the predicate is falsy --- the inverse of `iff`. * The predicate can be a boolean or a sync/async function. * Useful for applying hooks to all contexts except those matching a condition. * * @example * ```ts * import { unless, isProvider } from 'feathers-utils/predicates' * * app.service('users').hooks({ * before: { all: [unless(isProvider('server'), authenticate('jwt'))] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/unless.html */ declare function unless(predicate: boolean | PredicateFn, ...hooks: HookFunction[]): (this: any, ctx: H, next?: import("@feathersjs/feathers").NextFunction) => HookContext, any> | Promise; //#endregion export { IffHook as a, skippable as i, ThrowIfOptions as n, iff as o, throwIf as r, iffElse as s, unless as t }; //# sourceMappingURL=unless.hook-CVw1wX_x.d.mts.map