import { A as Promisable, D as KeyOfOrDotNotation, O as MaybeArray, S as TransportName, _ as PredicateItemWithContext, d as HookFunction, g as PredicateFn, k as NeverFallback, l as DispatchOption, n as ResultSingleHookContext, t as DataSingleHookContext, y as TransformParamsFn } from "./hook-context-BsxU1vfN.mjs"; import { d as InferFindParams, h as InferGetResult, i as InferCreateDataSingle } from "./infer-service-methods-C-9x7P40.mjs"; import { a as IffHook, i as skippable, n as ThrowIfOptions, o as iff, r as throwIf, s as iffElse, t as unless } from "./unless.hook-CVw1wX_x.mjs"; import { i as transformData, n as transformResult, r as transformQuery, t as TransformResultOptions } from "./transform-result.hook-C9wMLWs2.mjs"; import { i as resolveData, n as resolveQuery, r as resolveResult, t as resolve } from "./resolve-Cmxskunj.mjs"; import { FeathersError } from "@feathersjs/errors"; import { HookContext, NextFunction, Params, Query } from "@feathersjs/feathers"; import { RateLimiterAbstract } from "rate-limiter-flexible"; import { PropertyPath } from "lodash"; //#region src/utils/combine/combine.util.d.ts /** * Sequentially executes multiple hooks, passing the updated context from one to the next. * Returns a single hook function that runs the entire chain. If any hook throws, * the error is annotated with the current hook context. * * @example * ```ts * import { combine } from 'feathers-utils/hooks' * * const combinedHook = combine(hookA(), hookB(), hookC()) * app.service('users').hooks({ before: { create: [combinedHook] } }) * ``` * * @see https://utils.feathersjs.com/utils/combine.html */ declare function combine(...serviceHooks: HookFunction[]): (context: H) => Promise; //#endregion //#region src/hooks/cache/cache.hook.d.ts type Cache = { get: (key: string) => Promisable; set: (key: string, value: any) => Promisable; delete: (key: string) => Promisable; clear: () => any; keys: () => IterableIterator; }; type CacheEvent = { type: 'hit'; method: string; key: string; } | { type: 'miss'; method: string; key: string; } | { type: 'set'; method: string; key: string; } | { type: 'invalidate'; method: string; key: string; } | { type: 'clear'; method: string; }; type CacheOptions = { /** * The cache implementation to use. It should implement the methods `get`, `set`, `delete`, `clear`, and `keys`. * This can be a Map, Redis client, or any other cache implementation. * * Use 'lru-cache' for an LRU cache implementation. */ map: Cache; /** * The id field to use for caching. Defaults to `service.options.id` and if not found, then 'id'. */ id?: string; /** * params are stringified for the key-value cache. * There are params properties you don't want to include in the cache key. * You can use this function to transform the params before they are stringified. */ transformParams: (params: Params) => Params; /** * Custom serialization function for converting params into a cache key string. * By default, uses `stableStringify` which sorts object keys and normalizes * query operator arrays (`$or`, `$and`, `$in`, etc.) for order-independent caching. * * Override this to use a custom serialization strategy. * * @example * ```ts * cache({ * map: new Map(), * transformParams: (params) => ({ query: params.query }), * serialize: (params) => JSON.stringify(params), * }) * ``` */ serialize?: (params: Params) => string; /** * Optional logger callback for cache events (hit, miss, set, invalidate, clear). * Useful for debugging and monitoring cache behavior. * * @example * ```ts * cache({ * map: new Map(), * transformParams: (params) => ({ query: params.query }), * logger: (event) => console.log(`cache ${event.type}`, event), * }) * ``` */ logger?: (event: CacheEvent) => void; /** * How to clone results on store and on hit so callers can't mutate the shared * cached object. Defaults to a `fast-copy` deep clone. * * Set to `false` to skip cloning entirely (fastest, but the caller MUST treat * results as immutable), or pass a custom clone function (e.g. `structuredClone`). * * @default true */ clone?: boolean | ((value: T) => T); }; /** * Caches `get` and `find` results based on `params`. On mutating methods (`create`, `update`, * `patch`, `remove`), affected cache entries are automatically invalidated. * Works as a `before`, `after`, or `around` hook. * * @example * ```ts * import { cache } from 'feathers-utils/hooks' * * const myCache = new Map() * * app.service('users').hooks({ * around: { * all: [cache({ map: myCache, transformParams: (params) => ({ query: params.query }) })] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/cache.html */ declare const cache: (options: CacheOptions) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/check-multi/check-multi.hook.d.ts type CheckMultiOptions = { /** * Customize the error that is thrown if the service does not allow multi operations. * * If not provided, throws a `MethodNotAllowed` error with a message indicating the operation. */ error?: (context: HookContext) => FeathersError; }; /** * Checks if the `multi` option is enabled for the current method and throws a * `MethodNotAllowed` error if multi operations are not permitted. * Useful to guard against accidental bulk `create`, `patch`, or `remove` calls. * * @example * ```ts * import { checkMulti } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { create: [checkMulti()] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/check-multi.html */ declare function checkMulti(options?: CheckMultiOptions): { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/check-required/check-required.hook.d.ts /** * Validates that the specified fields exist on `context.data` and are not falsy. * Numeric `0` and boolean `false` are treated as valid values. * Throws a `BadRequest` error if any required field is missing or null. * * @example * ```ts * import { checkRequired } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { create: [checkRequired(['email', 'password'])] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/check-required.html */ declare function checkRequired(fieldNames: MaybeArray): { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/create-related/create-related.hook.d.ts interface CreateRelatedOptions { service: S; /** * Is relevant when the current context result is an array. * * If true, will create multiple related records in a single call to the related service's create method. * If false or not provided, will create related records one by one. * * @default false */ multi?: boolean; /** * A function that returns the data to be created in the related service. * * Receives the current item from the context result and the full hook context as arguments. * Can return a single data object, an array of data objects, or a promise that resolves to either. * * If the function returns undefined, no related record will be created for that item. */ data: (item: ResultSingleHookContext, context: H) => Promisable> | undefined>; } /** * Creates related records in other services after a successful `create` call. * For each result item, a `data` function produces the record to create in the target service. * Supports creating records one-by-one or in a single multi-create when `multi: true`. * * @example * ```ts * import { createRelated } from 'feathers-utils/hooks' * * app.service('users').hooks({ * after: { * create: [createRelated({ service: 'profiles', data: (user) => ({ userId: user.id }) })] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/create-related.html */ declare function createRelated(options: MaybeArray>): (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/debug/debug.hook.d.ts /** * Logs the current hook context to the console for debugging purposes. * Displays timestamp, service path, method, type, id, data, query, result, and * any additional param fields you specify. * * @example * ```ts * import { debug } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { find: [debug('before find', 'user')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/debug.html */ declare const debug: (msg: string, ...fieldNames: string[]) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/disable-pagination/disable-pagination.hook.d.ts /** * Disables pagination when `query.$limit` is `-1` or `'-1'`. * Removes the `$limit` from the query and sets `params.paginate = false`. * Must be used as a `before` or `around` hook on the `find` method. * * @example * ```ts * import { disablePagination } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { find: [disablePagination()] } * }) * // Then call: app.service('users').find({ query: { $limit: -1 } }) * ``` * * @see https://utils.feathersjs.com/hooks/disable-pagination.html */ declare const disablePagination: () => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/disallow/disallow.hook.d.ts /** * Prevents access to a service method completely or for specific transports. * When called without arguments, the method is blocked for all callers. * When called with transport names, only those transports are blocked. * * @example * ```ts * import { disallow } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { * remove: [disallow('external')], // block external access * update: [disallow()], // block completely * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/disallow.html */ declare const disallow: (transports?: MaybeArray) => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/find-or-create/find-or-create.hook.d.ts /** * The valid `uniqueBy` paths for a service's create data. Falls back to a plain * `string` when the create data type can't be inferred (e.g. an untyped app), so * the hook stays usable without a strongly-typed `feathers()` instance. */ type UniqueByPath = NeverFallback>, string>; interface FindOrCreateOptions { /** The service to search before creating. Must be a service registered on the app. */ service: S; /** * One or more property paths (dot-notation supported) read from `context.data` to build * the lookup query — the upsert "conflict target". A path whose value is `undefined` in * the data is skipped. */ uniqueBy: MaybeArray>; /** * Optional function returning extra `find` params. `query` is merged with (and overridden * by) the `uniqueBy` values; `paginate` is always forced to `false`. */ params?: (context: H) => InferFindParams; /** * What to do when more than one record matches the `uniqueBy` query. * - `'create'` (default): proceed to create a new record. * - `'throw'`: throw a `BadRequest`. * - `'first'`: short-circuit with the first match. * * @default 'create' */ onMultiple?: 'create' | 'throw' | 'first'; } /** * A `before:create` (or `around:create`) hook that looks for an existing record before creating one. * * It builds a query from the `uniqueBy` paths read out of `context.data`, runs * `find({ paginate: false })` on the target service, and if **exactly one** record matches, sets * `context.result` to that record — short-circuiting the create. With zero matches (or array data) * the create proceeds; with multiple matches the `onMultiple` option decides. * * @example * ```ts * import { findOrCreate } from 'feathers-utils/hooks' * * app.service('tags').hooks({ * before: { * create: [findOrCreate({ service: 'tags', uniqueBy: 'name' })] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/find-or-create.html */ declare function findOrCreate(options: FindOrCreateOptions): (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/mute-event/mute-event.hook.d.ts type MuteEventOptions = { /** * Only mute when this is truthy. Can be a boolean or a predicate that * receives the `HookContext`. Defaults to always muting. * * @example isProvider('server') */ when?: boolean | PredicateFn; }; /** * Suppresses the service event for the current call by setting `context.event` * to `null`. Feathers emits the standard `created`/`updated`/`patched`/`removed` * event (the value of `context.event`) after the method runs; setting it to * `null` prevents that emission so real-time subscribers and channels are not * notified. * * Useful for seeding, migrations and internal syncs that should not trigger * downstream listeners. Works as a `before`, `after` or `around` hook. * * @example * ```ts * import { muteEvent } from 'feathers-utils/hooks' * import { isProvider } from 'feathers-utils/predicates' * * app.service('users').hooks({ * before: { * all: [muteEvent()], // mute every call * create: [muteEvent({ when: isProvider('server') })], // only server calls * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/mute-event.html */ declare const muteEvent: (options?: MuteEventOptions) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/on-delete/on-delete.hook.d.ts type OnDeleteAction = 'cascade' | 'set null'; interface OnDeleteOptions { /** * The related service where related items should be manipulated */ service: S; /** * The propertyKey in the related service */ keyThere: NeverFallback, string>; /** * The propertyKey in the current service. */ keyHere: keyof ResultSingleHookContext; /** * The action to perform on the related items. * * - `cascade`: remove related items * - `set null`: set the related property to null */ onDelete: OnDeleteAction; /** * Additional query to merge into the service call. * Typed based on the related service's query type. */ query?: InferFindParams['query']; /** * If true, the hook will wait for the service to finish before continuing * * @default false */ blocking?: boolean; /** * Called when a non-blocking (`blocking: false`) related-service call rejects. * Without this, fire-and-forget rejections are swallowed (but never leak as an * unhandled rejection). In `blocking` mode the error is thrown to the caller instead. */ onError?: (error: any, context: H) => void; } /** * Manipulates related items when a record is deleted, similar to SQL foreign key actions. * Supports `'cascade'` (remove related records) and `'set null'` (nullify the foreign key). * Unlike database-level cascades, this hook triggers service events and hooks for related items. * * @example * ```ts * import { onDelete } from 'feathers-utils/hooks' * * app.service('users').hooks({ * after: { * remove: [onDelete({ service: 'posts', keyHere: 'id', keyThere: 'userId', onDelete: 'cascade' })] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/on-delete.html */ type OnDeleteOptionsDistributed = { [S in keyof H['app']['services'] & string]: OnDeleteOptions }[keyof H['app']['services'] & string]; declare const onDelete: (options: MaybeArray>) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/params-for-server/params-for-server.hook.d.ts type ParamsForServerOptions = { /** * @default '_$client' */ keyToHide?: string; }; /** * Client-side hook that moves whitelisted `params` properties into `query._$client` * so they survive the client-to-server transport. The server only receives `query` * from params — use `paramsFromClient` on the server to restore them. * * @example * ```ts * import { paramsForServer } from 'feathers-utils/hooks' * * // Client-side * app.service('users').hooks({ * before: { all: [paramsForServer('populateParams')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/params-for-server.html */ declare const paramsForServer: (whitelist: MaybeArray, options?: ParamsForServerOptions) => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/params-from-client/params-from-client.hook.d.ts type paramsFromClientOptions = { /** * @default '_$client' */ keyToHide?: string; }; /** * Server-side hook that extracts whitelisted properties from `query._$client` back * into `context.params`. This is the counterpart to `paramsForServer`, which encodes * params on the client side for transport. * * @example * ```ts * import { paramsFromClient } from 'feathers-utils/hooks' * * // Server-side * app.service('users').hooks({ * before: { all: [paramsFromClient('populateParams')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/params-from-client.html */ declare const paramsFromClient: (whitelist: MaybeArray, options?: paramsFromClientOptions) => { (context: HookContext): void; (context: HookContext, next: NextFunction): Promise; }; //#endregion //#region src/hooks/prevent-changes/prevent-changes.hook.d.ts type PreventChangesOptions> = { /** * Customize the error that is thrown if the service tries to patch a field that is not allowed. * * If not provided, throws a `BadRequest` error with a message indicating the field that is not allowed. */ error?: boolean | ((item: D, name: Keys) => FeathersError); }; /** * Prevents `patch` calls from modifying certain fields. By default, the protected * fields are silently removed from `context.data`. When `error` is set, a `BadRequest` * is thrown if any protected field is present. * * Supports dot.notation for nested fields. * * @example * ```ts * import { preventChanges } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { patch: [preventChanges(['email', 'role'], { error: true })] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/prevent-changes.html */ declare const preventChanges: = DataSingleHookContext, Keys extends KeyOfOrDotNotation = KeyOfOrDotNotation>(fieldNames: MaybeArray, options?: PreventChangesOptions) => (context: H, next?: import("@feathersjs/feathers").NextFunction) => Promise; //#endregion //#region src/hooks/rate-limit/rate-limit.hook.d.ts type RateLimitOptions = { /** Generate the rate-limiting key. Defaults to `context.path`. */key?: (context: H) => Promisable; /** Number of points to consume per request. Defaults to `1`. */ points?: (context: H) => Promisable; }; /** * Rate limits service method calls using `rate-limiter-flexible`. * You provide a pre-configured `RateLimiterAbstract` instance * (Memory, Redis, Mongo, etc.) and the hook consumes points per request. * * @example * ```ts * import { rateLimit } from 'feathers-utils/hooks' * import { RateLimiterMemory } from 'rate-limiter-flexible' * * const rateLimiter = new RateLimiterMemory({ points: 10, duration: 1 }) * * app.service('users').hooks({ * before: { find: [rateLimit(rateLimiter)] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/rate-limit.html */ declare const rateLimit: (rateLimiter: RateLimiterAbstract, options?: RateLimitOptions) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/set-data/set-data.hook.d.ts interface HookSetDataOptions { /** * Wether to throw if the context[from] is undefined. * * @default false */ allowUndefined?: boolean; /** * @default true */ overwrite?: boolean | PredicateItemWithContext; /** * Customize the error that is thrown if the context[from] is not available. * If not provided, throws a `Forbidden` error with a message indicating the missing field. */ error?: (context: HookContext, from: PropertyPath) => FeathersError; } /** * Sets a property on each item in `context.data` from another property on the hook context. * Supports dot-notation paths for both source and target. Throws a `Forbidden` error * if the source field is missing (unless `allowUndefined` is `true`). * * @example * ```ts * import { setData } from 'feathers-utils/hooks' * * app.service('posts').hooks({ * before: { create: [setData('params.user.id', 'userId')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/set-data.html */ declare function setData( /** * The property path of the context to set the value from. 'dot.notation' is supported. * * If the property does not exist, the hook will throw an error unless `allowUndefined` is set to true. * If the property exists, it will be set to the value of the `to` property path of the data item. * * @example 'params.user.id' */ from: PropertyPath, /** * The property path of the data item to set the value to. 'dot.notation' is supported. * * If the property does not exist, it will be created. * If the property exists, it will be overwritten unless `overwrite` is set to false. * * @example 'userId' */ to: PropertyPath, options?: HookSetDataOptions): { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/set-field/set-field.hook.d.ts interface SetFieldOptions { /** * The target path(s) to set. Pass an array to write the same value to several * paths (e.g. multiple query keys). * * @example 'params.query.userId' * @example ['params.query.userId', 'params.query.ownerId'] */ as: string | string[]; /** * The source of the value: a `dot.notation` path on the context, or a function * that derives the value from the context. * * @example 'params.user.id' * @example (context) => context.params.user?.id */ from: string | ((context: H) => unknown); /** * If set to `true`, allows the field to be undefined. * If the field is not available and this is `true`, the hook will not throw an error. * * If set to `false`, the hook will throw an error if the field is not available. * * @default false */ allowUndefined?: boolean; /** * Customize the error that is thrown if the field is not available. * * If not provided, throws a `Forbidden` error with a message indicating the missing field. */ error?: (context: H, from: string | ((context: H) => unknown)) => FeathersError; } /** * Sets a field on the hook context (e.g. `params.query`) based on the value of another * context field (e.g. `params.user.id`). Useful for scoping queries to the authenticated user. * Throws a `Forbidden` error if the source field is missing (unless `allowUndefined` is `true`). * * @example * ```ts * import { setField } from 'feathers-utils/hooks' * * app.service('posts').hooks({ * before: { all: [setField({ from: 'params.user.id', as: 'params.query.userId' })] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/set-field.html */ declare const setField: ({ as, from, allowUndefined, error }: SetFieldOptions) => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/set-query-defaults/set-query-defaults.hook.d.ts /** * Adds default properties to `context.params.query` for fields the incoming query does * not already constrain (including fields referenced nested in `$and`/`$or`/`$nor`). * The query equivalent of the `defaults` transformer: e.g. hide template rows by default * while still letting callers opt in via `{ isTemplate: true }`. This is the same pattern * `softDelete` uses to filter out deleted rows. Works as a `before` or `around` hook. * * @example * ```ts * import { setQueryDefaults } from 'feathers-utils/hooks' * * app.service('posts').hooks({ * before: { all: [setQueryDefaults({ isTemplate: false })] }, * }) * // find() => filters out templates * // find({ query: { isTemplate: true } }) => caller keeps control * ``` * * @see https://utils.feathersjs.com/hooks/set-query-defaults.html */ declare const setQueryDefaults: (defaults: Query) => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/set-result/set-result.hook.d.ts interface SetResultOptions { /** * Wether to throw if the context[from] is undefined. * * @default false */ allowUndefined?: boolean; /** * @default true */ overwrite?: boolean | PredicateItemWithContext; /** * Customize the error that is thrown if the context[from] is not available. * If not provided, throws a `Forbidden` error with a message indicating the missing field. */ error?: (context: HookContext, from: PropertyPath) => FeathersError; dispatch?: DispatchOption; } /** * Sets a property on each item in `context.result` from another property on the hook context. * Supports dot-notation paths for both source and target, and can optionally * operate on `context.dispatch` as well. * * @example * ```ts * import { setResult } from 'feathers-utils/hooks' * * app.service('posts').hooks({ * after: { all: [setResult('params.user.id', 'currentUserId')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/set-result.html */ declare function setResult( /** * The property path of the context to set the value from. 'dot.notation' is supported. * * If the property does not exist, the hook will throw an error unless `allowUndefined` is set to true. * If the property exists, it will be set to the value of the `to` property path of the data item. * * @example 'params.user.id' */ from: PropertyPath, /** * The property path of the data item to set the value to. 'dot.notation' is supported. * * If the property does not exist, it will be created. * If the property exists, it will be overwritten unless `overwrite` is set to false. * * @example 'userId' */ to: PropertyPath, options?: SetResultOptions): { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/set-slug/set-slug.hook.d.ts /** * Extracts URL route parameters (slugs) and sets them on `params.query`. * For example, given a route `/stores/:storeId`, this hook copies the resolved * `storeId` value from `params.route` into the query. Only applies to the `rest` provider. * * @example * ```ts * import { setSlug } from 'feathers-utils/hooks' * * app.service('stores/:storeId/products').hooks({ * before: { all: [setSlug('storeId')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/set-slug.html */ declare const setSlug: (slug: string, fieldName?: string) => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/soft-delete/soft-delete.hook.d.ts type SoftDeleteOptionFunction = (context?: H) => Promisable<{ [key: string]: any; }>; interface SoftDeleteOptions { /** * @example { deletedAt: null } */ deletedQuery: { [key: string]: any; } | SoftDeleteOptionFunction; /** * @example { deletedAt: new Date() } */ removeData: { [key: string]: any; } | SoftDeleteOptionFunction; /** * Transform the params before calling the service method. E.g. remove 'params.provider' or add custom params. */ transformParams?: TransformParamsFn; /** * Key in `params` to disable the soft delete functionality. * * @default 'disableSoftDelete' */ disableSoftDeleteKey?: string; /** * `softDelete` uses `._patch()` internally to mark items as deleted. * * If you set this option to `true`, it will use the `.patch()` method with hooks instead. */ usePatchWithHooks?: boolean; /** * By default, if the incoming `params.query` already references a key of * `deletedQuery` (e.g. `deletedAt`) — including nested inside `$and`/`$or`/`$nor` — * the `deletedQuery` filter is NOT added, letting the caller read soft-deleted * items while `remove` still soft-deletes them. * * Set this to `false` to always enforce the `deletedQuery` filter. * * @default true */ allowQueryOverride?: boolean; } /** * Marks items as deleted instead of physically removing them. On `remove`, the hook * patches the record with `removeData` (e.g. `{ deletedAt: new Date() }`). On all other * methods, it appends `deletedQuery` (e.g. `{ deletedAt: null }`) to filter out soft-deleted items. * * @example * ```ts * import { softDelete } from 'feathers-utils/hooks' * * app.service('users').hooks({ * around: { * all: [softDelete({ deletedQuery: { deletedAt: null }, removeData: { deletedAt: new Date() } })] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/soft-delete.html */ declare const softDelete: (options: SoftDeleteOptions) => (context: H, next?: NextFunction) => Promise; //#endregion //#region src/hooks/stashable/stashable.hook.d.ts type StashableOptions = { /** The property name on `context.params` to store the stash function. @default 'stashed' */propName?: string; /** Custom function to fetch the pre-mutation state. Defaults to `service.get` or `service.find`. */ stashFunc?: (context: HookContext) => Promise; }; /** * Stashes the pre-mutation state of a record into `context.params`. * Eagerly starts the fetch but exposes a memoized function — calling it * multiple times only hits the database once. * Use in `before` hooks on `update`, `patch`, or `remove` methods. * * @example * ```ts * import { stashable } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { patch: [stashable()] } * }) * * // In a later hook (before or after): * const before = await context.params.stashed() * ``` * * @see https://utils.feathersjs.com/hooks/stashable.html */ declare function stashable(options?: StashableOptions): { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion //#region src/hooks/throw-if-is-multi/throw-if-is-multi.hook.d.ts type ThrowIfIsMultiOptions = { /** * A predicate function to filter the contexts that should be checked for multi operations. * If provided, only contexts that pass this predicate will be checked for multi operations. */ filter?: PredicateFn; /** * Customize the error that is thrown if the context is multi and the service does not allow it. * If not provided, throws a `BadRequest` error. */ error?: (context: HookContext) => FeathersError; }; /** * Throws a `BadRequest` error when the current operation is a multi operation * (array data on `create`, or `id === null` on `patch`/`remove`). * Useful to prevent bulk operations on services that should only handle single items. * * @example * ```ts * import { throwIfIsMulti } from 'feathers-utils/hooks' * * app.service('users').hooks({ * before: { all: [throwIfIsMulti()] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/throw-if-is-multi.html */ declare const throwIfIsMulti: (options?: ThrowIfIsMultiOptions) => (context: H, next?: import("@feathersjs/feathers").NextFunction) => Promise; //#endregion //#region src/hooks/throw-if-is-provider/throw-if-is-provider.hook.d.ts type ThrowIfIsIsProviderOptions = { filter?: PredicateFn; /** * Customize the error that is thrown if the context is a provider and the service does not allow it. * If not provided, throws a `MethodNotAllowed` error. */ error?: (context: HookContext) => FeathersError; }; /** * Throws a `MethodNotAllowed` error when the request comes from one of the specified transports. * Combines `throwIf` with the `isProvider` predicate for a convenient one-liner. * Use this to restrict methods to server-only or specific transport types. * * @example * ```ts * import { throwIfIsProvider } from 'feathers-utils/hooks' * * app.service('internal').hooks({ * before: { all: [throwIfIsProvider('external')] } * }) * ``` * * @see https://utils.feathersjs.com/hooks/throw-if-is-provider.html */ declare const throwIfIsProvider: (transports: TransportName | TransportName[], options?: ThrowIfIsIsProviderOptions) => (context: H, next?: import("@feathersjs/feathers").NextFunction) => Promise; //#endregion //#region src/hooks/traverse/traverse.hook.d.ts type TraverseOptions = { transformer: (transformContext: any) => any; getObject: (context: HookContext) => Record | Record[]; /** * For `around` hooks only: run the traversal *after* `next()` instead of before. * Required when `getObject` targets `context.result`, which is only populated * once the service method has run. Defaults to `false` (run before `next()`), * which is correct for `context.data`/`context.params.query` targets. * * @default false */ runAfter?: boolean; }; /** * Recursively walks and transforms fields in record(s) using `neotraverse`. * The `getObject` function extracts the target from the context, and `transformer` * is called for every node during traversal --- ideal for deep, structural transformations. * * @example * ```ts * import { traverse } from 'feathers-utils/hooks' * * app.service('users').hooks({ * after: { * all: [traverse({ getObject: (ctx) => ctx.result, transformer: function () { if (this.key === 'password') this.remove() } })] * } * }) * ``` * * @see https://utils.feathersjs.com/hooks/traverse.html */ declare const traverse: ({ transformer, getObject, runAfter }: TraverseOptions) => { (context: H): void; (context: H, next: NextFunction): Promise; }; //#endregion export { CacheEvent, CacheOptions, CheckMultiOptions, CreateRelatedOptions, FindOrCreateOptions, HookSetDataOptions, IffHook, MuteEventOptions, OnDeleteAction, OnDeleteOptions, ParamsForServerOptions, PreventChangesOptions, RateLimitOptions, SetFieldOptions, SetResultOptions, SoftDeleteOptionFunction, SoftDeleteOptions, StashableOptions, ThrowIfIsIsProviderOptions, ThrowIfIsMultiOptions, ThrowIfOptions, TransformResultOptions, TraverseOptions, cache, checkMulti, checkRequired, combine, createRelated, debug, disablePagination, disallow, findOrCreate, iff, iff as when, iffElse, muteEvent, onDelete, paramsForServer, paramsFromClient, paramsFromClientOptions, preventChanges, rateLimit, resolve, resolveData, resolveQuery, resolveResult, setData, setField, setQueryDefaults, setResult, setSlug, skippable, softDelete, stashable, throwIf, throwIfIsMulti, throwIfIsProvider, transformData, transformQuery, transformResult, traverse, unless }; //# sourceMappingURL=hooks.d.mts.map