feathers-utils 10.0.4 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{hooks-DzXD-3FR.mjs → hooks-Bg5XWcV7.mjs} +62 -4
- package/dist/hooks-Bg5XWcV7.mjs.map +1 -0
- package/dist/hooks.d.mts +55 -1
- package/dist/hooks.mjs +2 -2
- package/dist/{index-DXXeX7lF.d.mts → index-DKA0E_ad.d.mts} +72 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/predicates.d.mts +1 -1
- package/dist/transformers.mjs +1 -1
- package/dist/{utils-C2GLf_mV.mjs → utils-Br6DNQ1B.mjs} +83 -2
- package/dist/utils-Br6DNQ1B.mjs.map +1 -0
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
- package/src/hooks/find-or-create/find-or-create.hook.ts +129 -0
- package/src/hooks/index.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/wait-for-service-event/wait-for-service-event.util.ts +177 -0
- package/dist/hooks-DzXD-3FR.mjs.map +0 -1
- package/dist/utils-C2GLf_mV.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-DzXD-3FR.mjs","names":["defaultError","_traverse"],"sources":["../src/hooks/cache/cache-utils.ts","../src/hooks/cache/cache.hook.ts","../src/hooks/check-multi/check-multi.hook.ts","../src/hooks/check-required/check-required.hook.ts","../src/hooks/create-related/create-related.hook.ts","../src/hooks/debug/debug.hook.ts","../src/hooks/disable-pagination/disable-pagination.hook.ts","../src/hooks/disallow/disallow.hook.ts","../src/hooks/on-delete/on-delete.hook.ts","../src/hooks/params-for-server/params-for-from-shared.ts","../src/hooks/params-for-server/params-for-server.hook.ts","../src/hooks/params-from-client/params-from-client.hook.ts","../src/hooks/prevent-changes/prevent-changes.hook.ts","../src/hooks/rate-limit/rate-limit.hook.ts","../src/hooks/set-data/set-data.hook.ts","../src/hooks/set-field/set-field.hook.ts","../src/hooks/set-result/set-result.hook.ts","../src/hooks/set-slug/set-slug.hook.ts","../src/hooks/soft-delete/soft-delete.hook.ts","../src/hooks/stashable/stashable.hook.ts","../src/hooks/throw-if-is-multi/throw-if-is-multi.hook.ts","../src/hooks/throw-if-is-provider/throw-if-is-provider.hook.ts","../src/hooks/traverse/traverse.hook.ts"],"sourcesContent":["import { sortQueryProperties } from '../../utils/sort-query-properties/sort-query-properties.util.js'\n\nexport { sortQueryProperties }\n\nexport const stableStringify = (obj: Record<string, any>) => {\n // Canonicalize the whole params object once (recursive key-sort + operator-array\n // sort). The JSON.stringify pass then only needs to reject non-JSON values\n // instead of re-sorting and re-allocating every node.\n const normalized = sortQueryProperties(obj as any)\n\n return JSON.stringify(normalized, (_key, value) => {\n if (typeof value === 'function') {\n throw new Error('Cannot stringify non JSON value')\n }\n return value\n })\n}\n","import type { HookContext, NextFunction, Params } from '@feathersjs/feathers'\nimport { stableStringify } from './cache-utils.js'\nimport { copy } from 'fast-copy'\nimport type { Promisable } from '../../internal.utils.js'\n\ntype Cache = {\n get: (key: string) => Promisable<any>\n set: (key: string, value: any) => Promisable<any>\n delete: (key: string) => Promisable<any>\n clear: () => any\n keys: () => IterableIterator<string>\n}\n\nexport type CacheEvent =\n | { type: 'hit'; method: string; key: string }\n | { type: 'miss'; method: string; key: string }\n | { type: 'set'; method: string; key: string }\n | { type: 'invalidate'; method: string; key: string }\n | { type: 'clear'; method: string }\n\nexport type CacheOptions = {\n /**\n * The cache implementation to use. It should implement the methods `get`, `set`, `delete`, `clear`, and `keys`.\n * This can be a Map, Redis client, or any other cache implementation.\n *\n * Use 'lru-cache' for an LRU cache implementation.\n */\n map: Cache\n /**\n * The id field to use for caching. Defaults to `service.options.id` and if not found, then 'id'.\n */\n id?: string\n /**\n * params are stringified for the key-value cache.\n * There are params properties you don't want to include in the cache key.\n * You can use this function to transform the params before they are stringified.\n */\n transformParams: (params: Params) => Params\n /**\n * Custom serialization function for converting params into a cache key string.\n * By default, uses `stableStringify` which sorts object keys and normalizes\n * query operator arrays (`$or`, `$and`, `$in`, etc.) for order-independent caching.\n *\n * Override this to use a custom serialization strategy.\n *\n * @example\n * ```ts\n * cache({\n * map: new Map(),\n * transformParams: (params) => ({ query: params.query }),\n * serialize: (params) => JSON.stringify(params),\n * })\n * ```\n */\n serialize?: (params: Params) => string\n /**\n * Optional logger callback for cache events (hit, miss, set, invalidate, clear).\n * Useful for debugging and monitoring cache behavior.\n *\n * @example\n * ```ts\n * cache({\n * map: new Map(),\n * transformParams: (params) => ({ query: params.query }),\n * logger: (event) => console.log(`cache ${event.type}`, event),\n * })\n * ```\n */\n logger?: (event: CacheEvent) => void\n /**\n * How to clone results on store and on hit so callers can't mutate the shared\n * cached object. Defaults to a `fast-copy` deep clone.\n *\n * Set to `false` to skip cloning entirely (fastest, but the caller MUST treat\n * results as immutable), or pass a custom clone function (e.g. `structuredClone`).\n *\n * @default true\n */\n clone?: boolean | (<T>(value: T) => T)\n}\n\n/**\n * Caches `get` and `find` results based on `params`. On mutating methods (`create`, `update`,\n * `patch`, `remove`), affected cache entries are automatically invalidated.\n * Works as a `before`, `after`, or `around` hook.\n *\n * @example\n * ```ts\n * import { cache } from 'feathers-utils/hooks'\n *\n * const myCache = new Map()\n *\n * app.service('users').hooks({\n * around: {\n * all: [cache({ map: myCache, transformParams: (params) => ({ query: params.query }) })]\n * }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/cache.html\n */\nexport const cache = <H extends HookContext = HookContext>(\n options: CacheOptions,\n) => {\n const cacheMap = new ContextCacheMap(options)\n return async (context: H, next?: NextFunction): Promise<void> => {\n if (context.type === 'before') {\n return await cacheBefore(context, cacheMap)\n }\n if (context.type === 'after') {\n return await cacheAfter(context, cacheMap)\n }\n\n if (context.type === 'around' && next) {\n await cacheBefore(context, cacheMap)\n await next()\n await cacheAfter(context, cacheMap)\n return\n }\n }\n}\n\nconst cacheBefore = async (\n context: HookContext,\n cacheMap: ContextCacheMap,\n): Promise<void> => {\n if (context.method === 'get' || context.method === 'find') {\n const value = await cacheMap.get(context)\n if (value) {\n context.result = value\n }\n }\n}\n\nconst cacheAfter = async (\n context: HookContext,\n cacheMap: ContextCacheMap,\n): Promise<void> => {\n if (context.method === 'get' || context.method === 'find') {\n await cacheMap.set(context)\n } else {\n await cacheMap.clear(context)\n }\n}\n\nclass ContextCacheMap {\n map: Cache\n private delimiter = ':'\n private options: CacheOptions\n private log: ((event: CacheEvent) => void) | undefined\n private serialize: (params: Params) => string\n private clone: <T>(value: T) => T\n\n constructor(options: CacheOptions) {\n this.map = options.map\n this.options = options\n this.log = options.logger\n this.serialize = options.serialize ?? stableStringify\n this.clone =\n options.clone === false\n ? (value) => value\n : typeof options.clone === 'function'\n ? options.clone\n : copy\n }\n\n private stringifyCacheKey(context: HookContext) {\n if (context.method !== 'get' && context.method !== 'find') {\n throw new Error(\n `Cache can only be used with 'get' or 'find' methods, not '${context.method}'`,\n )\n }\n\n const stringifiedParams = this.serialize(\n this.options.transformParams(context.params ?? {}),\n )\n\n return `${context.id ?? 'null'}${this.delimiter}${stringifiedParams}`\n }\n\n private getCachedId(key: string) {\n const index = key.indexOf(this.delimiter)\n if (index === -1) {\n throw new Error(\n `Cache key '${key}' does not contain a delimiter '${this.delimiter}'`,\n )\n }\n return key.substring(0, index)\n }\n\n private getId(item: Record<string, any>, context: HookContext) {\n const idField = context.service.options?.id || this.options.id || 'id'\n const id = item[idField]\n return id && id.toString ? id.toString() : id\n }\n\n /**\n * Called before get() and find()\n *\n * returns a cached result for the given context if it exists.\n */\n async get(context: HookContext) {\n const key = this.stringifyCacheKey(context)\n const result = await this.map.get(key)\n if (result) {\n this.log?.({ type: 'hit', method: context.method, key })\n return this.clone(result) // clone to avoid mutation of the cached result\n }\n this.log?.({ type: 'miss', method: context.method, key })\n }\n\n /**\n * Called after get() and find()\n *\n * Caches the result for the given context.\n */\n async set(context: HookContext) {\n const key = this.stringifyCacheKey(context)\n this.log?.({ type: 'set', method: context.method, key })\n // clone to avoid later mutation of the cached result\n return this.map.set(key, this.clone(context.result))\n }\n\n // Called after create(), update(), patch(), and remove()\n async clear<H extends HookContext>(context: H): Promise<H> {\n const results = Array.isArray(context.result)\n ? context.result\n : [context.result]\n\n const promises: Promise<any>[] = []\n\n const itemIds = results\n .map((item: any) => this.getId(item, context))\n .filter(Boolean)\n\n // If no itemIds are found, clear the entire cache to avoid stale data\n if (!itemIds.length) {\n this.log?.({ type: 'clear', method: context.method })\n await this.map.clear()\n return context\n }\n\n // O(1) membership instead of an O(itemIds) scan per cached key.\n const idSet = new Set<string>(itemIds.map((id: any) => `${id}`))\n\n for (const key of this.map.keys()) {\n const cachedId = this.getCachedId(key)\n if (cachedId === 'null') {\n // This is a cached `find` request. Any create/patch/update/del\n // could affect the results of this query so it should be deleted\n this.log?.({ type: 'invalidate', method: context.method, key })\n promises.push(this.map.delete(key))\n continue\n }\n\n // This is a cached `get` request\n\n if (context.method === 'create') {\n // If this is a create, we don't need to delete any cached get requests\n continue\n }\n\n if (idSet.has(cachedId)) {\n // If the cached id matches a mutated item id, delete the cached get\n this.log?.({ type: 'invalidate', method: context.method, key })\n promises.push(this.map.delete(key))\n }\n }\n\n await Promise.all(promises)\n\n return context\n }\n}\n","import type { FeathersError } from '@feathersjs/errors'\nimport { MethodNotAllowed } from '@feathersjs/errors'\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { isMulti } from '../../predicates/index.js'\n\nexport type CheckMultiOptions = {\n /**\n * Customize the error that is thrown if the service does not allow multi operations.\n *\n * If not provided, throws a `MethodNotAllowed` error with a message indicating the operation.\n */\n error?: (context: HookContext) => FeathersError\n}\n\n/**\n * Checks if the `multi` option is enabled for the current method and throws a\n * `MethodNotAllowed` error if multi operations are not permitted.\n * Useful to guard against accidental bulk `create`, `patch`, or `remove` calls.\n *\n * @example\n * ```ts\n * import { checkMulti } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { create: [checkMulti()] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/check-multi.html\n */\nexport function checkMulti<H extends HookContext = HookContext>(\n options?: CheckMultiOptions,\n) {\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n const { service, method } = context\n if (\n !service.allowsMulti ||\n !isMulti(context) ||\n method === 'find' ||\n service.allowsMulti(method)\n ) {\n if (next) return next()\n return\n }\n\n throw options?.error\n ? options.error(context)\n : new MethodNotAllowed(`Can not ${method} multiple entries`)\n }\n return hook\n}\n","import _get from 'lodash/get.js'\nimport _has from 'lodash/has.js'\nimport { BadRequest } from '@feathersjs/errors'\n\nimport { checkContext, getDataIsArray } from '../../utils/index.js'\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { MaybeArray } from '../../internal.utils.js'\nimport { toArray } from '../../internal.utils.js'\n\n/**\n * Validates that the specified fields exist on `context.data` and are not falsy.\n * Numeric `0` and boolean `false` are treated as valid values.\n * Throws a `BadRequest` error if any required field is missing or null.\n *\n * @example\n * ```ts\n * import { checkRequired } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { create: [checkRequired(['email', 'password'])] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/check-required.html\n */\nexport function checkRequired<H extends HookContext = HookContext>(\n fieldNames: MaybeArray<string>,\n) {\n const fieldNamesArray = toArray(fieldNames)\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n checkContext(context, {\n type: ['before', 'around'],\n method: ['create', 'update', 'patch'],\n label: 'checkRequired',\n })\n\n const { data } = getDataIsArray(context)\n\n for (let i = 0; i < data.length; i++) {\n const item = data[i]\n\n for (let j = 0; j < fieldNamesArray.length; j++) {\n const name = fieldNamesArray[j]\n\n if (!_has(item, name)) {\n throw new BadRequest(`Field ${name} does not exist. (required)`)\n }\n\n const value = _get(item, name)\n\n if (!value && value !== 0 && value !== false) {\n throw new BadRequest(`Field ${name} is null. (required)`)\n }\n }\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { checkContext, getResultIsArray } from '../../utils/index.js'\nimport type { MaybeArray, Promisable } from '../../internal.utils.js'\nimport type { InferCreateDataSingle } from '../../utility-types/infer-service-methods.js'\nimport type { ResultSingleHookContext } from '../../utility-types/hook-context.js'\n\nexport interface CreateRelatedOptions<\n H extends HookContext = HookContext,\n Services extends H['app']['services'] = H['app']['services'],\n S extends keyof Services = keyof Services,\n> {\n service: S\n /**\n * Is relevant when the current context result is an array.\n *\n * If true, will create multiple related records in a single call to the related service's create method.\n * If false or not provided, will create related records one by one.\n *\n * @default false\n */\n multi?: boolean\n /**\n * A function that returns the data to be created in the related service.\n *\n * Receives the current item from the context result and the full hook context as arguments.\n * Can return a single data object, an array of data objects, or a promise that resolves to either.\n *\n * If the function returns undefined, no related record will be created for that item.\n */\n data: (\n item: ResultSingleHookContext<H>,\n context: H,\n ) => Promisable<MaybeArray<InferCreateDataSingle<Services[S]>> | undefined>\n}\n\n/**\n * Creates related records in other services after a successful `create` call.\n * For each result item, a `data` function produces the record to create in the target service.\n * Supports creating records one-by-one or in a single multi-create when `multi: true`.\n *\n * @example\n * ```ts\n * import { createRelated } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * after: {\n * create: [createRelated({ service: 'profiles', data: (user) => ({ userId: user.id }) })]\n * }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/create-related.html\n */\nexport function createRelated<H extends HookContext = HookContext>(\n options: MaybeArray<CreateRelatedOptions<H>>,\n) {\n return async (context: H, next?: NextFunction): Promise<void> => {\n checkContext(context, {\n type: ['after', 'around'],\n method: ['create'],\n label: 'createRelated',\n })\n\n if (next) {\n await next()\n }\n\n const { result } = getResultIsArray(context)\n\n const entries = Array.isArray(options) ? options : [options]\n\n await Promise.all(\n entries.map(async (entry) => {\n const { data, service, multi } = entry\n\n const dataToCreate = (\n await Promise.all(result.map(async (item) => data(item, context)))\n )\n .flat()\n .filter((x) => !!x)\n\n if (!dataToCreate || dataToCreate.length <= 0) {\n return\n }\n\n if (multi || dataToCreate.length === 1) {\n await context.app\n .service(service as string)\n .create(\n dataToCreate.length === 1\n ? (dataToCreate[0] as any)\n : (dataToCreate as any),\n )\n } else {\n await Promise.all(\n dataToCreate.map(async (item) =>\n context.app.service(service as string).create(item as any),\n ),\n )\n }\n }),\n )\n }\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\n\n/**\n * Logs the current hook context to the console for debugging purposes.\n * Displays timestamp, service path, method, type, id, data, query, result, and\n * any additional param fields you specify.\n *\n * @example\n * ```ts\n * import { debug } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { find: [debug('before find', 'user')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/debug.html\n */\nexport const debug =\n <H extends HookContext = HookContext>(msg: string, ...fieldNames: string[]) =>\n async (context: H, next?: NextFunction): Promise<void> => {\n if (next) {\n await next()\n }\n\n // display timestamp\n const now = new Date()\n console.log(\n `${now.getFullYear()}-${\n now.getMonth() + 1\n }-${now.getDate()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`,\n )\n\n if (msg) {\n console.log(msg)\n }\n\n // display service, method & type of hook (before/after/error)\n console.log(\n `${context.type} service('${context.path}').${context.method}()`,\n )\n\n // display id for get, patch, update & remove\n if (!['find', 'create'].includes(context.method) && 'id' in context) {\n console.log('id:', context.id)\n }\n\n if (context.data) {\n console.log('data:', context.data)\n }\n\n if (context.params?.query) {\n console.log('query:', context.params.query)\n }\n\n if (context.result) {\n console.log('result:', context.result)\n }\n\n // display additional params\n const params = context.params || {}\n console.log('params props:', Object.keys(params).sort())\n\n fieldNames.forEach((name) => {\n console.log(`params.${name}:`, params[name])\n })\n\n if (context.error) {\n console.log('error', context.error)\n }\n }\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { checkContext } from '../../utils/index.js'\n\n/**\n * Disables pagination when `query.$limit` is `-1` or `'-1'`.\n * Removes the `$limit` from the query and sets `params.paginate = false`.\n * Must be used as a `before` or `around` hook on the `find` method.\n *\n * @example\n * ```ts\n * import { disablePagination } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { find: [disablePagination()] }\n * })\n * // Then call: app.service('users').find({ query: { $limit: -1 } })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/disable-pagination.html\n */\nexport const disablePagination = <H extends HookContext = HookContext>() => {\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n checkContext(context, {\n type: ['before', 'around'],\n method: ['find'],\n label: 'disablePagination',\n })\n const $limit = context.params?.query?.$limit\n\n if ($limit === '-1' || $limit === -1) {\n context.params.paginate = false\n delete context.params.query.$limit\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import { MethodNotAllowed } from '@feathersjs/errors'\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { TransportName } from '../../types.js'\nimport { isProvider } from '../../predicates/index.js'\nimport type { MaybeArray } from '../../internal.utils.js'\nimport { toArray } from '../../internal.utils.js'\n\n/**\n * Prevents access to a service method completely or for specific transports.\n * When called without arguments, the method is blocked for all callers.\n * When called with transport names, only those transports are blocked.\n *\n * @example\n * ```ts\n * import { disallow } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: {\n * remove: [disallow('external')], // block external access\n * update: [disallow()], // block completely\n * }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/disallow.html\n */\nexport const disallow = <H extends HookContext = HookContext>(\n transports?: MaybeArray<TransportName>,\n) => {\n const transportsArr = toArray(transports)\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n // No transports (undefined) or an empty list means \"block completely\".\n // Fail closed for a guard hook rather than throwing a confusing internal error.\n if (!transports || transportsArr.length === 0) {\n throw new MethodNotAllowed('Method not allowed')\n }\n\n if (isProvider(...(transportsArr as TransportName[]))(context)) {\n throw new MethodNotAllowed(\n `Provider '${context.params.provider}' can not call '${context.method}' on '${context.path}'. (disallow)`,\n )\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { checkContext, getResultIsArray } from '../../utils/index.js'\nimport type { MaybeArray, NeverFallback } from '../../internal.utils.js'\nimport type {\n InferFindParams,\n InferGetResult,\n} from '../../utility-types/infer-service-methods.js'\nimport type { ResultSingleHookContext } from '../../utility-types/hook-context.js'\n\nexport type OnDeleteAction = 'cascade' | 'set null'\n\nexport interface OnDeleteOptions<\n H extends HookContext = HookContext,\n S extends keyof H['app']['services'] = keyof H['app']['services'],\n> {\n /**\n * The related service where related items should be manipulated\n */\n service: S\n /**\n * The propertyKey in the related service\n */\n keyThere: NeverFallback<keyof InferGetResult<H['app']['services'][S]>, string>\n /**\n * The propertyKey in the current service.\n */\n keyHere: keyof ResultSingleHookContext<H>\n /**\n * The action to perform on the related items.\n *\n * - `cascade`: remove related items\n * - `set null`: set the related property to null\n */\n onDelete: OnDeleteAction\n /**\n * Additional query to merge into the service call.\n * Typed based on the related service's query type.\n */\n query?: InferFindParams<H['app']['services'][S]>['query']\n /**\n * If true, the hook will wait for the service to finish before continuing\n *\n * @default false\n */\n blocking?: boolean\n /**\n * Called when a non-blocking (`blocking: false`) related-service call rejects.\n * Without this, fire-and-forget rejections are swallowed (but never leak as an\n * unhandled rejection). In `blocking` mode the error is thrown to the caller instead.\n */\n onError?: (error: any, context: H) => void\n}\n\n/**\n * Manipulates related items when a record is deleted, similar to SQL foreign key actions.\n * Supports `'cascade'` (remove related records) and `'set null'` (nullify the foreign key).\n * Unlike database-level cascades, this hook triggers service events and hooks for related items.\n *\n * @example\n * ```ts\n * import { onDelete } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * after: {\n * remove: [onDelete({ service: 'posts', keyHere: 'id', keyThere: 'userId', onDelete: 'cascade' })]\n * }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/on-delete.html\n */\ntype OnDeleteOptionsDistributed<H extends HookContext> = {\n [S in keyof H['app']['services'] & string]: OnDeleteOptions<H, S>\n}[keyof H['app']['services'] & string]\n\nexport const onDelete = <H extends HookContext = HookContext>(\n options: MaybeArray<OnDeleteOptionsDistributed<H>>,\n) => {\n const optionsMulti = Array.isArray(options) ? options : [options]\n\n return async (context: H, next?: NextFunction): Promise<void> => {\n checkContext(context, {\n type: ['after', 'around'],\n method: 'remove',\n label: 'onDelete',\n })\n\n if (next) {\n await next()\n }\n\n const { result } = getResultIsArray(context)\n\n if (!result.length) {\n return\n }\n\n const blockingPromises: Promise<any>[] = []\n\n for (const {\n keyHere,\n keyThere,\n onDelete,\n service,\n blocking,\n query,\n onError,\n } of optionsMulti) {\n let ids = result.map((x) => x[keyHere]).filter((x) => !!x)\n ids = [...new Set(ids)]\n\n if (!ids || ids.length <= 0) {\n continue\n }\n\n const params = {\n query: {\n ...query,\n ...(ids.length === 1\n ? { [keyThere]: ids[0] }\n : { [keyThere]: { $in: ids } }),\n },\n paginate: false,\n }\n\n let promise: Promise<any> | undefined = undefined\n\n if (onDelete === 'cascade') {\n promise = context.app.service(service as string).remove(null, params)\n } else if (onDelete === 'set null') {\n const data = { [keyThere]: null }\n promise = context.app\n .service(service as string)\n .patch(null, data, params)\n }\n\n if (!promise) {\n continue\n }\n\n if (blocking) {\n blockingPromises.push(promise)\n } else {\n // fire-and-forget: always attach a catch so a rejection never becomes\n // an unhandled promise rejection. Surface it via `onError` if provided.\n promise.catch((error) => onError?.(error, context))\n }\n }\n\n if (blockingPromises.length) {\n await Promise.all(blockingPromises)\n }\n\n return\n }\n}\n","export const FROM_CLIENT_FOR_SERVER_DEFAULT_KEY = '_$client' as const\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { MaybeArray } from '../../internal.utils.js'\nimport { toArray } from '../../internal.utils.js'\nimport { FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } from './params-for-from-shared.js'\n\nexport type ParamsForServerOptions = {\n /**\n * @default '_$client'\n */\n keyToHide?: string\n}\n\n/**\n * Client-side hook that moves whitelisted `params` properties into `query._$client`\n * so they survive the client-to-server transport. The server only receives `query`\n * from params — use `paramsFromClient` on the server to restore them.\n *\n * @example\n * ```ts\n * import { paramsForServer } from 'feathers-utils/hooks'\n *\n * // Client-side\n * app.service('users').hooks({\n * before: { all: [paramsForServer('populateParams')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/params-for-server.html\n */\nexport const paramsForServer = (\n whitelist: MaybeArray<string>,\n options?: ParamsForServerOptions,\n) => {\n const whitelistArr = toArray(whitelist)\n\n const { keyToHide = FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } = options || {}\n\n function hook<H extends HookContext>(context: H): void\n function hook<H extends HookContext>(\n context: H,\n next: NextFunction,\n ): Promise<void>\n function hook<H extends HookContext>(\n context: H,\n next?: NextFunction,\n ): void | Promise<void> {\n // clone params on demand\n let clonedParams: any\n\n Object.keys(context.params).forEach((key) => {\n if (key === 'query') {\n return\n }\n\n if (whitelistArr.includes(key)) {\n if (!clonedParams) {\n clonedParams = {\n ...context.params,\n query: {\n ...context.params.query,\n },\n }\n }\n\n if (!clonedParams.query[keyToHide]) {\n clonedParams.query[keyToHide] = {}\n } else {\n // The shallow query copy still aliases a pre-existing key object;\n // clone it so we don't mutate the caller's original params.\n clonedParams.query[keyToHide] = { ...clonedParams.query[keyToHide] }\n }\n\n clonedParams.query[keyToHide][key] = clonedParams[key]\n delete clonedParams[key]\n }\n })\n\n if (clonedParams) {\n context.params = clonedParams\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { MaybeArray } from '../../internal.utils.js'\nimport { toArray } from '../../internal.utils.js'\nimport { FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } from '../params-for-server/params-for-from-shared.js'\n\nexport type paramsFromClientOptions = {\n /**\n * @default '_$client'\n */\n keyToHide?: string\n}\n\n/**\n * Server-side hook that extracts whitelisted properties from `query._$client` back\n * into `context.params`. This is the counterpart to `paramsForServer`, which encodes\n * params on the client side for transport.\n *\n * @example\n * ```ts\n * import { paramsFromClient } from 'feathers-utils/hooks'\n *\n * // Server-side\n * app.service('users').hooks({\n * before: { all: [paramsFromClient('populateParams')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/params-from-client.html\n */\nexport const paramsFromClient = (\n whitelist: MaybeArray<string>,\n options?: paramsFromClientOptions,\n) => {\n const whitelistArr = toArray(whitelist)\n const { keyToHide = FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } = options || {}\n function hook(context: HookContext): void\n function hook(context: HookContext, next: NextFunction): Promise<void>\n function hook(\n context: HookContext,\n next?: NextFunction,\n ): void | Promise<void> {\n if (\n !context.params?.query?.[keyToHide] ||\n typeof context.params.query[keyToHide] !== 'object'\n ) {\n if (next) return next()\n return\n }\n\n const params = {\n ...context.params,\n query: {\n ...context.params.query,\n [keyToHide]: {\n ...context.params.query[keyToHide],\n },\n },\n }\n\n const client = params.query[keyToHide]\n\n whitelistArr.forEach((key) => {\n if (key in client) {\n params[key] = client[key]\n delete client[key]\n }\n })\n\n if (Object.keys(client).length === 0) {\n delete params.query[keyToHide]\n }\n\n context.params = params\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import _has from 'lodash/has.js'\nimport _omit from 'lodash/omit.js'\nimport type { FeathersError } from '@feathersjs/errors'\nimport { BadRequest } from '@feathersjs/errors'\nimport { transformData } from '../transform-data/transform-data.hook.js'\nimport type { KeyOfOrDotNotation, MaybeArray } from '../../internal.utils.js'\nimport { toArray } from '../../internal.utils.js'\nimport type { HookContext } from '@feathersjs/feathers'\nimport type { DataSingleHookContext } from '../../utility-types/hook-context.js'\n\nexport type PreventChangesOptions<D, Keys extends KeyOfOrDotNotation<D>> = {\n /**\n * Customize the error that is thrown if the service tries to patch a field that is not allowed.\n *\n * If not provided, throws a `BadRequest` error with a message indicating the field that is not allowed.\n */\n error?: boolean | ((item: D, name: Keys) => FeathersError)\n}\n\n/**\n * Prevents `patch` calls from modifying certain fields. By default, the protected\n * fields are silently removed from `context.data`. When `error` is set, a `BadRequest`\n * is thrown if any protected field is present.\n *\n * Supports dot.notation for nested fields.\n *\n * @example\n * ```ts\n * import { preventChanges } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { patch: [preventChanges(['email', 'role'], { error: true })] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/prevent-changes.html\n */\nexport const preventChanges = <\n H extends HookContext = HookContext,\n D extends DataSingleHookContext<H> = DataSingleHookContext<H>,\n Keys extends KeyOfOrDotNotation<D> = KeyOfOrDotNotation<D>,\n>(\n fieldNames: MaybeArray<Keys>,\n options?: PreventChangesOptions<D, Keys>,\n) => {\n const fieldNamesArr = toArray(fieldNames)\n\n return transformData<H>((item) => {\n if (options?.error) {\n for (let i = 0; i < fieldNamesArr.length; i++) {\n const name = fieldNamesArr[i]\n\n if (_has(item, name)) {\n const error =\n typeof options.error === 'function'\n ? options.error(item as D, name)\n : new BadRequest(\n `Field ${String(name)} may not be patched. (preventChanges)`,\n )\n\n throw error\n }\n }\n } else {\n return _omit(item, fieldNamesArr)\n }\n\n return item\n })\n}\n","import { TooManyRequests } from '@feathersjs/errors'\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { RateLimiterAbstract, RateLimiterRes } from 'rate-limiter-flexible'\nimport { checkContext } from '../../utils/index.js'\nimport type { Promisable } from '../../internal.utils.js'\n\nexport type RateLimitOptions<H extends HookContext = HookContext> = {\n /** Generate the rate-limiting key. Defaults to `context.path`. */\n key?: (context: H) => Promisable<string>\n /** Number of points to consume per request. Defaults to `1`. */\n points?: (context: H) => Promisable<number>\n}\n\n/**\n * Rate limits service method calls using `rate-limiter-flexible`.\n * You provide a pre-configured `RateLimiterAbstract` instance\n * (Memory, Redis, Mongo, etc.) and the hook consumes points per request.\n *\n * @example\n * ```ts\n * import { rateLimit } from 'feathers-utils/hooks'\n * import { RateLimiterMemory } from 'rate-limiter-flexible'\n *\n * const rateLimiter = new RateLimiterMemory({ points: 10, duration: 1 })\n *\n * app.service('users').hooks({\n * before: { find: [rateLimit(rateLimiter)] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/rate-limit.html\n */\nexport const rateLimit = <H extends HookContext = HookContext>(\n rateLimiter: RateLimiterAbstract,\n options?: RateLimitOptions<H>,\n) => {\n const key = options?.key ?? ((context: HookContext) => context.path)\n const points = options?.points ?? (() => 1)\n\n return async (context: H, next?: NextFunction): Promise<void> => {\n checkContext(context, { type: ['before', 'around'], label: 'rateLimit' })\n\n const resolvedKey = await key(context)\n const resolvedPoints = await points(context)\n\n try {\n const res = await rateLimiter.consume(resolvedKey, resolvedPoints)\n context.params.rateLimit = res\n } catch (res) {\n context.params.rateLimit = res as RateLimiterRes\n throw new TooManyRequests('Too many requests', {\n rateLimitRes: res as RateLimiterRes,\n })\n }\n\n if (next) await next()\n }\n}\n","import _get from 'lodash/get.js'\nimport _set from 'lodash/set.js'\nimport _has from 'lodash/has.js'\n\nimport type { FeathersError } from '@feathersjs/errors'\nimport { Forbidden } from '@feathersjs/errors'\n\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { PropertyPath } from 'lodash'\nimport { contextToJson } from '../../utils/context-to-json/context-to-json.util.js'\nimport { getDataIsArray } from '../../utils/index.js'\nimport type { PredicateItemWithContext } from '../../types.js'\n\nexport interface HookSetDataOptions {\n /**\n * Wether to throw if the context[from] is undefined.\n *\n * @default false\n */\n allowUndefined?: boolean\n /**\n * @default true\n */\n overwrite?: boolean | PredicateItemWithContext\n /**\n * Customize the error that is thrown if the context[from] is not available.\n * If not provided, throws a `Forbidden` error with a message indicating the missing field.\n */\n error?: (context: HookContext, from: PropertyPath) => FeathersError\n}\n\n/**\n * Sets a property on each item in `context.data` from another property on the hook context.\n * Supports dot-notation paths for both source and target. Throws a `Forbidden` error\n * if the source field is missing (unless `allowUndefined` is `true`).\n *\n * @example\n * ```ts\n * import { setData } from 'feathers-utils/hooks'\n *\n * app.service('posts').hooks({\n * before: { create: [setData('params.user.id', 'userId')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/set-data.html\n */\nexport function setData<H extends HookContext = HookContext>(\n /**\n * The property path of the context to set the value from. 'dot.notation' is supported.\n *\n * If the property does not exist, the hook will throw an error unless `allowUndefined` is set to true.\n * If the property exists, it will be set to the value of the `to` property path of the data item.\n *\n * @example 'params.user.id'\n */\n from: PropertyPath,\n /**\n * The property path of the data item to set the value to. 'dot.notation' is supported.\n *\n * If the property does not exist, it will be created.\n * If the property exists, it will be overwritten unless `overwrite` is set to false.\n *\n * @example 'userId'\n */\n to: PropertyPath,\n options?: HookSetDataOptions,\n) {\n const { allowUndefined = false, overwrite = true } = options ?? {}\n\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n const { data } = getDataIsArray(context)\n\n const contextJson = contextToJson(context)\n\n if (!_has(contextJson, from)) {\n if (!context.params?.provider || allowUndefined === true) {\n if (next) return next()\n return\n }\n\n if (\n !overwrite &&\n data.every((item: Record<string, unknown>) => _has(item, to))\n ) {\n if (next) return next()\n return\n }\n\n throw options?.error\n ? options.error(context, from)\n : new Forbidden(`Expected field ${from.toString()} not available`)\n }\n\n const val = _get(contextJson, from)\n\n for (let i = 0, len = data.length; i < len; i++) {\n const item: Record<string, unknown> = data[i]\n\n const currentOverwrite =\n typeof overwrite === 'function' ? overwrite(item, context) : overwrite\n\n if (!currentOverwrite && _has(item, to)) {\n continue\n }\n\n _set(item, to, val)\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import _get from 'lodash/get.js'\nimport _setWith from 'lodash/setWith.js'\nimport _clone from 'lodash/clone.js'\nimport { checkContext } from '../../utils/index.js'\nimport type { FeathersError } from '@feathersjs/errors'\nimport { Forbidden } from '@feathersjs/errors'\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\n\nexport interface SetFieldOptions<H extends HookContext = HookContext> {\n /**\n * The target path(s) to set. Pass an array to write the same value to several\n * paths (e.g. multiple query keys).\n *\n * @example 'params.query.userId'\n * @example ['params.query.userId', 'params.query.ownerId']\n */\n as: string | string[]\n /**\n * The source of the value: a `dot.notation` path on the context, or a function\n * that derives the value from the context.\n *\n * @example 'params.user.id'\n * @example (context) => context.params.user?.id\n */\n from: string | ((context: H) => unknown)\n /**\n * If set to `true`, allows the field to be undefined.\n * If the field is not available and this is `true`, the hook will not throw an error.\n *\n * If set to `false`, the hook will throw an error if the field is not available.\n *\n * @default false\n */\n allowUndefined?: boolean\n /**\n * Customize the error that is thrown if the field is not available.\n *\n * If not provided, throws a `Forbidden` error with a message indicating the missing field.\n */\n error?: (\n context: H,\n from: string | ((context: H) => unknown),\n ) => FeathersError\n}\n\n/**\n * Sets a field on the hook context (e.g. `params.query`) based on the value of another\n * context field (e.g. `params.user.id`). Useful for scoping queries to the authenticated user.\n * Throws a `Forbidden` error if the source field is missing (unless `allowUndefined` is `true`).\n *\n * @example\n * ```ts\n * import { setField } from 'feathers-utils/hooks'\n *\n * app.service('posts').hooks({\n * before: { all: [setField({ from: 'params.user.id', as: 'params.query.userId' })] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/set-field.html\n */\nexport const setField = <H extends HookContext = HookContext>({\n as,\n from,\n allowUndefined = false,\n error,\n}: SetFieldOptions<H>) => {\n const targets = Array.isArray(as) ? as : [as]\n\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n const { params } = context\n\n checkContext(context, { type: ['before', 'around'], label: 'setField' })\n\n const value =\n typeof from === 'function' ? from(context) : _get(context, from)\n\n if (value === undefined) {\n if (!params.provider || allowUndefined) {\n if (next) return next()\n return\n }\n\n throw error\n ? error(context, from)\n : new Forbidden(`Expected field ${targets.join(', ')} not available`)\n }\n\n for (const target of targets) {\n _setWith(context, target, value, _clone)\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import _get from 'lodash/get.js'\nimport _set from 'lodash/set.js'\nimport _has from 'lodash/has.js'\nimport { copy } from 'fast-copy'\n\nimport type { FeathersError } from '@feathersjs/errors'\nimport { Forbidden } from '@feathersjs/errors'\n\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport type { PropertyPath } from 'lodash'\nimport { contextToJson } from '../../utils/context-to-json/context-to-json.util.js'\nimport { getResultIsArray } from '../../utils/index.js'\nimport type { DispatchOption, PredicateItemWithContext } from '../../types.js'\n\nexport interface SetResultOptions {\n /**\n * Wether to throw if the context[from] is undefined.\n *\n * @default false\n */\n allowUndefined?: boolean\n /**\n * @default true\n */\n overwrite?: boolean | PredicateItemWithContext\n /**\n * Customize the error that is thrown if the context[from] is not available.\n * If not provided, throws a `Forbidden` error with a message indicating the missing field.\n */\n error?: (context: HookContext, from: PropertyPath) => FeathersError\n dispatch?: DispatchOption\n}\n\n/**\n * Sets a property on each item in `context.result` from another property on the hook context.\n * Supports dot-notation paths for both source and target, and can optionally\n * operate on `context.dispatch` as well.\n *\n * @example\n * ```ts\n * import { setResult } from 'feathers-utils/hooks'\n *\n * app.service('posts').hooks({\n * after: { all: [setResult('params.user.id', 'currentUserId')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/set-result.html\n */\nexport function setResult<H extends HookContext = HookContext>(\n /**\n * The property path of the context to set the value from. 'dot.notation' is supported.\n *\n * If the property does not exist, the hook will throw an error unless `allowUndefined` is set to true.\n * If the property exists, it will be set to the value of the `to` property path of the data item.\n *\n * @example 'params.user.id'\n */\n from: PropertyPath,\n /**\n * The property path of the data item to set the value to. 'dot.notation' is supported.\n *\n * If the property does not exist, it will be created.\n * If the property exists, it will be overwritten unless `overwrite` is set to false.\n *\n * @example 'userId'\n */\n to: PropertyPath,\n options?: SetResultOptions,\n) {\n const { allowUndefined = false, overwrite = true } = options ?? {}\n\n const forResultOrDispatch = (context: H, dispatch: boolean) => {\n const { result } = getResultIsArray(context, { dispatch })\n\n const contextJson = contextToJson(context)\n\n if (!_has(contextJson, from)) {\n if (!context.params?.provider || allowUndefined === true) {\n return context\n }\n\n if (\n !overwrite &&\n result.every((item: Record<string, unknown>) => _has(item, to))\n ) {\n return context\n }\n\n throw options?.error\n ? options.error(context, from)\n : new Forbidden(`Expected field ${from.toString()} not available`)\n }\n\n const val = _get(contextJson, from)\n\n for (let i = 0; i < result.length; i++) {\n const item: Record<string, unknown> = result[i]\n\n const currentOverwrite =\n typeof overwrite === 'function' ? overwrite(item, context) : overwrite\n\n if (!currentOverwrite && _has(item, to)) {\n continue\n }\n\n _set(item, to, val)\n }\n\n return context\n }\n\n const fn = (context: H) => {\n // Seed context.dispatch from result so the dispatch branch mutates (and\n // persists to) a real object instead of a throwaway copy. Mirrors mutateResult.\n if (!!options?.dispatch && !context.dispatch) {\n context.dispatch = copy(context.result)\n }\n\n if (options?.dispatch === 'both') {\n forResultOrDispatch(context, true)\n return forResultOrDispatch(context, false)\n }\n\n return forResultOrDispatch(context, !!options?.dispatch)\n }\n\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n if (next) {\n return next().then(() => {\n fn(context)\n })\n }\n\n fn(context)\n return\n }\n return hook\n}\n","import _set from 'lodash/set.js'\nimport type { HookContext, NextFunction } from '@feathersjs/feathers'\n\n/**\n * Extracts URL route parameters (slugs) and sets them on `params.query`.\n * For example, given a route `/stores/:storeId`, this hook copies the resolved\n * `storeId` value from `params.route` into the query. Only applies to the `rest` provider.\n *\n * @example\n * ```ts\n * import { setSlug } from 'feathers-utils/hooks'\n *\n * app.service('stores/:storeId/products').hooks({\n * before: { all: [setSlug('storeId')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/set-slug.html\n */\nexport const setSlug = <H extends HookContext = HookContext>(\n slug: string,\n fieldName?: string,\n) => {\n const targetField: string =\n typeof fieldName === 'string' ? fieldName : `query.${slug}`\n\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n if (context.params && context.params.provider === 'rest') {\n const value = context.params.route[slug]\n if (typeof value === 'string' && value[0] !== ':') {\n _set(context.params, targetField, value)\n }\n }\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { addToQuery, checkContext } from '../../utils/index.js'\nimport type { TransformParamsFn } from '../../types.js'\nimport { transformParams } from '../../utils/transform-params/transform-params.util.js'\nimport { early, type Promisable } from '../../internal.utils.js'\nimport { isPromise } from '../../common/index.js'\n\nexport type SoftDeleteOptionFunction<H extends HookContext = HookContext> = (\n context?: H,\n) => Promisable<{ [key: string]: any }>\n\nexport interface SoftDeleteOptions<H extends HookContext = HookContext> {\n /**\n * @example { deletedAt: null }\n */\n deletedQuery: { [key: string]: any } | SoftDeleteOptionFunction<H>\n /**\n * @example { deletedAt: new Date() }\n */\n removeData: { [key: string]: any } | SoftDeleteOptionFunction<H>\n /**\n * Transform the params before calling the service method. E.g. remove 'params.provider' or add custom params.\n */\n transformParams?: TransformParamsFn\n\n /**\n * Key in `params` to disable the soft delete functionality.\n *\n * @default 'disableSoftDelete'\n */\n disableSoftDeleteKey?: string\n\n /**\n * `softDelete` uses `._patch()` internally to mark items as deleted.\n *\n * If you set this option to `true`, it will use the `.patch()` method with hooks instead.\n */\n usePatchWithHooks?: boolean\n}\n\n/**\n * Marks items as deleted instead of physically removing them. On `remove`, the hook\n * patches the record with `removeData` (e.g. `{ deletedAt: new Date() }`). On all other\n * methods, it appends `deletedQuery` (e.g. `{ deletedAt: null }`) to filter out soft-deleted items.\n *\n * @example\n * ```ts\n * import { softDelete } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * around: {\n * all: [softDelete({ deletedQuery: { deletedAt: null }, removeData: { deletedAt: new Date() } })]\n * }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/soft-delete.html\n */\nexport const softDelete = <H extends HookContext = HookContext>(\n options: SoftDeleteOptions<H>,\n) => {\n if (!options?.deletedQuery || !options?.removeData) {\n throw new Error(\n 'You must provide `deletedQuery` and `removeData` options to the softDelete hook.',\n )\n }\n\n return async (context: H, next?: NextFunction): Promise<void> => {\n checkContext(context, { type: ['before', 'around'], label: 'softDelete' })\n\n const { disableSoftDeleteKey = 'disableSoftDelete' } = options\n\n if (context.params[disableSoftDeleteKey]) {\n await early(context, next)\n return\n }\n\n const { deletedQuery, removeData } = options\n\n let deleteQuery = getValue(deletedQuery, context)\n if (isPromise(deleteQuery)) {\n deleteQuery = await deleteQuery\n }\n\n const query = addToQuery(context.params.query, deleteQuery)\n\n const params = transformParams(\n {\n ...context.params,\n query,\n },\n options.transformParams,\n )\n\n context.params = params\n\n if (context.method === 'remove') {\n let data = getValue(removeData, context)\n if (isPromise(data)) {\n data = await data\n }\n const method = options.usePatchWithHooks ? 'patch' : '_patch'\n const result = await context.service[method](context.id, data, params)\n\n context.result = result\n }\n\n if (next) {\n await next()\n }\n }\n}\n\nconst getValue = (value: any, ...args: any[]) => {\n if (typeof value === 'function') {\n return value(...args)\n }\n return value\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { checkContext } from '../../utils/index.js'\n\nexport type StashableOptions = {\n /** The property name on `context.params` to store the stash function. @default 'stashed' */\n propName?: string\n /** Custom function to fetch the pre-mutation state. Defaults to `service.get` or `service.find`. */\n stashFunc?: (context: HookContext) => Promise<any>\n}\n\nconst defaultStashFunc = (context: HookContext) => {\n const isMulti = context.id == null\n\n const params = {\n ...context.params,\n _stashable: true,\n ...(isMulti ? { paginate: false } : {}),\n }\n\n return isMulti\n ? context.service.find(params)\n : context.service.get(context.id, params)\n}\n\n/**\n * Stashes the pre-mutation state of a record into `context.params`.\n * Eagerly starts the fetch but exposes a memoized function — calling it\n * multiple times only hits the database once.\n * Use in `before` hooks on `update`, `patch`, or `remove` methods.\n *\n * @example\n * ```ts\n * import { stashable } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { patch: [stashable()] }\n * })\n *\n * // In a later hook (before or after):\n * const before = await context.params.stashed()\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/stashable.html\n */\nexport function stashable<H extends HookContext = HookContext>(\n options?: StashableOptions,\n) {\n const propName = options?.propName ?? 'stashed'\n const stashFunc = options?.stashFunc ?? defaultStashFunc\n\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n if (context.params._stashable) {\n if (next) return next()\n return\n }\n\n checkContext(context, {\n type: ['before', 'around'],\n method: ['update', 'patch', 'remove'],\n label: 'stashable',\n })\n\n const promise = stashFunc(context).catch(() => undefined)\n\n context.params[propName] = () => promise\n\n if (next) return next()\n\n return\n }\n return hook\n}\n","import type { HookContext } from '@feathersjs/feathers'\nimport type { PredicateFn } from '../../types.js'\nimport { BadRequest, type FeathersError } from '@feathersjs/errors'\nimport { every, isMulti } from '../../predicates/index.js'\nimport { throwIf } from '../throw-if/throw-if.hook.js'\n\nexport type ThrowIfIsMultiOptions = {\n /**\n * A predicate function to filter the contexts that should be checked for multi operations.\n * If provided, only contexts that pass this predicate will be checked for multi operations.\n */\n filter?: PredicateFn\n /**\n * Customize the error that is thrown if the context is multi and the service does not allow it.\n * If not provided, throws a `BadRequest` error.\n */\n error?: (context: HookContext) => FeathersError\n}\n\nconst defaultError = (context: HookContext) =>\n new BadRequest(`Cannot perform multi operation on method '${context.method}'`)\n\n/**\n * Throws a `BadRequest` error when the current operation is a multi operation\n * (array data on `create`, or `id === null` on `patch`/`remove`).\n * Useful to prevent bulk operations on services that should only handle single items.\n *\n * @example\n * ```ts\n * import { throwIfIsMulti } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * before: { all: [throwIfIsMulti()] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/throw-if-is-multi.html\n */\nexport const throwIfIsMulti = <H extends HookContext = HookContext>(\n options?: ThrowIfIsMultiOptions,\n) =>\n throwIf<H>(\n every(\n every(isMulti, (context) => context.method !== 'find'),\n options?.filter,\n ),\n {\n error: options?.error ?? defaultError,\n },\n )\n","import type { HookContext } from '@feathersjs/feathers'\nimport type { PredicateFn, TransportName } from '../../types.js'\nimport { throwIf } from '../throw-if/throw-if.hook.js'\nimport { every, isProvider } from '../../predicates/index.js'\nimport type { FeathersError } from '@feathersjs/errors'\nimport { MethodNotAllowed } from '@feathersjs/errors'\nimport { toArray } from '../../internal.utils.js'\n\nconst defaultError = (context: HookContext) =>\n new MethodNotAllowed(\n `Provider '${context.params.provider}' can not call '${context.method}'.`,\n )\n\nexport type ThrowIfIsIsProviderOptions = {\n filter?: PredicateFn\n /**\n * Customize the error that is thrown if the context is a provider and the service does not allow it.\n * If not provided, throws a `MethodNotAllowed` error.\n */\n error?: (context: HookContext) => FeathersError\n}\n\n/**\n * Throws a `MethodNotAllowed` error when the request comes from one of the specified transports.\n * Combines `throwIf` with the `isProvider` predicate for a convenient one-liner.\n * Use this to restrict methods to server-only or specific transport types.\n *\n * @example\n * ```ts\n * import { throwIfIsProvider } from 'feathers-utils/hooks'\n *\n * app.service('internal').hooks({\n * before: { all: [throwIfIsProvider('external')] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/throw-if-is-provider.html\n */\nexport const throwIfIsProvider = <H extends HookContext = HookContext>(\n transports: TransportName | TransportName[],\n options?: ThrowIfIsIsProviderOptions,\n) => {\n const disallowTransports = toArray(transports)\n\n return throwIf<H>(\n every(isProvider(...(disallowTransports as any)), options?.filter),\n {\n error: options?.error ?? defaultError,\n },\n )\n}\n","import type { HookContext, NextFunction } from '@feathersjs/feathers'\nimport { traverse as _traverse } from '../../common/index.js'\n\nexport type TraverseOptions = {\n transformer: (transformContext: any) => any\n getObject: (\n context: HookContext,\n ) => Record<string, any> | Record<string, any>[]\n /**\n * For `around` hooks only: run the traversal *after* `next()` instead of before.\n * Required when `getObject` targets `context.result`, which is only populated\n * once the service method has run. Defaults to `false` (run before `next()`),\n * which is correct for `context.data`/`context.params.query` targets.\n *\n * @default false\n */\n runAfter?: boolean\n}\n\n/**\n * Recursively walks and transforms fields in record(s) using `neotraverse`.\n * The `getObject` function extracts the target from the context, and `transformer`\n * is called for every node during traversal --- ideal for deep, structural transformations.\n *\n * @example\n * ```ts\n * import { traverse } from 'feathers-utils/hooks'\n *\n * app.service('users').hooks({\n * after: {\n * all: [traverse({ getObject: (ctx) => ctx.result, transformer: function () { if (this.key === 'password') this.remove() } })]\n * }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/hooks/traverse.html\n */\nexport const traverse = <H extends HookContext = HookContext>({\n transformer,\n getObject,\n runAfter = false,\n}: TraverseOptions) => {\n const runTraverse = (context: H) => _traverse(getObject(context), transformer)\n\n function hook(context: H): void\n function hook(context: H, next: NextFunction): Promise<void>\n function hook(context: H, next?: NextFunction): void | Promise<void> {\n if (next && runAfter) {\n // around hook targeting context.result: transform after the method ran\n return next().then(() => {\n runTraverse(context)\n })\n }\n\n runTraverse(context)\n\n if (next) return next()\n\n return\n }\n return hook\n}\n"],"mappings":";;;;;;;;;;;;;;AAIA,MAAa,mBAAmB,QAA6B;CAI3D,MAAM,aAAa,oBAAoB,GAAU;CAEjD,OAAO,KAAK,UAAU,aAAa,MAAM,UAAU;EACjD,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,MAAM,iCAAiC;EAEnD,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;ACqFA,MAAa,SACX,YACG;CACH,MAAM,WAAW,IAAI,gBAAgB,OAAO;CAC5C,OAAO,OAAO,SAAY,SAAuC;EAC/D,IAAI,QAAQ,SAAS,UACnB,OAAO,MAAM,YAAY,SAAS,QAAQ;EAE5C,IAAI,QAAQ,SAAS,SACnB,OAAO,MAAM,WAAW,SAAS,QAAQ;EAG3C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MAAMA,kBAAgB,YACpB,IAAI,WAAW,6CAA6C,QAAQ,OAAO,EAAE;;;;;;;;;;;;;;;;;AAkB/E,MAAa,kBACX,YAEA,QACE,MACE,MAAM,UAAU,YAAY,QAAQ,WAAW,MAAM,GACrD,SAAS,MACX,GACA,EACE,OAAO,SAAS,SAASA,eAC3B,CACF;;;ACzCF,MAAM,gBAAgB,YACpB,IAAI,iBACF,aAAa,QAAQ,OAAO,SAAS,kBAAkB,QAAQ,OAAO,GACxE;;;;;;;;;;;;;;;;;AA2BF,MAAa,qBACX,YACA,YACG;CAGH,OAAO,QACL,MAAM,WAAW,GAHQ,QAAQ,UAGK,CAAS,GAAG,SAAS,MAAM,GACjE,EACE,OAAO,SAAS,SAAS,aAC3B,CACF;AACF;;;;;;;;;;;;;;;;;;;;;ACbA,MAAa,YAAiD,EAC5D,aACA,WACA,WAAW,YACU;CACrB,MAAM,eAAe,YAAeC,WAAU,UAAU,OAAO,GAAG,WAAW;CAI7E,SAAS,KAAK,SAAY,MAA2C;EACnE,IAAI,QAAQ,UAEV,OAAO,KAAK,CAAC,CAAC,WAAW;GACvB,YAAY,OAAO;EACrB,CAAC;EAGH,YAAY,OAAO;EAEnB,IAAI,MAAM,OAAO,KAAK;CAGxB;CACA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-C2GLf_mV.mjs","names":["deepEqual"],"sources":["../src/utils/sort-query-properties/sort-query-properties.util.ts","../src/utils/add-skip/add-skip.util.ts","../src/utils/chunk-find/chunk-find.util.ts","../src/utils/add-to-query/add-to-query.util.ts","../src/utils/check-context/check-context.util.ts","../src/utils/context-to-json/context-to-json.util.ts","../src/utils/define-hooks/define-hooks.util.ts","../src/feathers-cjs-fix.ts","../src/utils/get-exposed-methods/get-exposed-methods.util.ts","../src/utils/iterate-find/iterate-find.util.ts","../src/utils/patch-batch/patch-batch.util.ts","../src/utils/skip-result/skip-result.util.ts","../src/utils/to-paginated/to-paginated.util.ts","../src/utils/transform-params/transform-params.util.ts","../src/utils/walk-query/walk-query.util.ts","../src/utils/zip-data-result/zip-data-result.util.ts"],"sourcesContent":["import type { Query } from '@feathersjs/feathers'\n\nconst arrayOperators = new Set(['$or', '$and', '$nor', '$not', '$in', '$nin'])\n\nconst isPlainObjectLike = (value: unknown): value is Record<string, any> =>\n value !== null && typeof value === 'object'\n\n/**\n * Recursively normalizes a Feathers query object for order-independent comparison.\n * Sorts object keys and sorts arrays within `$or`, `$and`, `$nor`, `$not`, `$in`,\n * and `$nin` operators so that different orderings produce the same result.\n *\n * This is useful for generating stable cache keys where\n * `{ $or: [{ a: 1 }, { b: 2 }] }` and `{ $or: [{ b: 2 }, { a: 1 }] }`\n * should be treated as equivalent.\n *\n * @example\n * ```ts\n * import { sortQueryProperties } from 'feathers-utils/utils'\n *\n * const normalized = sortQueryProperties({\n * $or: [{ name: 'Jane' }, { name: 'John' }],\n * age: { $in: [30, 25] },\n * })\n * // => { $or: [{ name: 'John' }, { name: 'Jane' }], age: { $in: [25, 30] } }\n * // (sorted by stable stringify comparison)\n * ```\n *\n * @see https://utils.feathersjs.com/utils/sort-query-properties.html\n */\nexport const sortQueryProperties = <Q extends Query>(query: Q): Q => {\n return normalize(query) as Q\n}\n\nconst normalize = (value: any): any => {\n if (Array.isArray(value)) {\n return value.map(normalize)\n }\n\n if (!isPlainObjectLike(value)) {\n return value\n }\n\n const sorted: Record<string, any> = {}\n\n for (const key of Object.keys(value).sort()) {\n const val = value[key]\n\n if (arrayOperators.has(key) && Array.isArray(val)) {\n // Schwartzian transform: serialize each normalized element once, sort by\n // that key, then unwrap. Avoids the O(n log n) repeated JSON.stringify of\n // the previous comparator (which also returned 1 for equal elements).\n sorted[key] = val\n .map((el) => {\n const normalized = normalize(el)\n return { k: JSON.stringify(normalized), v: normalized }\n })\n .sort((a, b) => (a.k < b.k ? -1 : a.k > b.k ? 1 : 0))\n .map((entry) => entry.v)\n } else {\n sorted[key] = normalize(val)\n }\n }\n\n return sorted\n}\n","import type { HookContext, HookType } from '@feathersjs/feathers'\nimport type { MaybeArray } from '../../internal.utils.js'\n\nexport type SkipHookName =\n | 'all'\n | HookType\n | `${HookType}:${string}`\n | (string & {})\n\n/**\n * Adds hook names to `context.params.skipHooks` so that `skippable`-wrapped hooks\n * will be bypassed for the current service call. Accepts a single name or an array.\n * Duplicates are automatically removed.\n *\n * @example\n * ```ts\n * import { addSkip } from 'feathers-utils/utils'\n *\n * // Inside a hook or custom code:\n * addSkip(context, 'myHook')\n * addSkip(context, ['hookA', 'hookB'])\n * ```\n *\n * @see https://utils.feathersjs.com/utils/add-skip.html\n */\nexport const addSkip = <H extends HookContext>(\n context: H,\n hooks: MaybeArray<SkipHookName>,\n) => {\n const names = Array.isArray(hooks) ? hooks : [hooks]\n\n if (context.params.skipHooks === undefined) {\n context.params = {\n ...context.params,\n skipHooks: [...names],\n }\n } else {\n if (!Array.isArray(context.params.skipHooks)) {\n throw new Error('Invalid skipHooks parameter')\n }\n\n context.params = {\n ...context.params,\n skipHooks: [...new Set([...context.params.skipHooks, ...names])],\n }\n }\n}\n","import type { Application, Params } from '@feathersjs/feathers'\nimport type { KeyOf } from '../../internal.utils.js'\nimport type {\n InferFindParams,\n InferFindResultSingle,\n} from '../../utility-types/infer-service-methods.js'\n\ntype PaginateOption = { default?: number; max?: number }\n\ntype ChunkFindOptions<P extends Params = Params> = {\n params?: P & { paginate?: PaginateOption }\n}\n\n/**\n * Use `for await` to iterate over chunks (pages) of results from a `find` method.\n *\n * This function is useful for processing large datasets in batches without loading everything into memory at once.\n * It uses pagination to fetch results in chunks, yielding each page's data array.\n *\n * @example\n * ```ts\n * import { chunkFind } from 'feathers-utils/utils'\n *\n * const app = feathers()\n *\n * // Assuming 'users' service has many records\n * for await (const users of chunkFind(app, 'users', {\n * params: { query: { active: true }, // Custom query parameters\n * } })) {\n * console.log(users) // Process each chunk of user records\n * }\n * ```\n *\n * @see https://utils.feathersjs.com/utils/chunk-find.html\n */\nexport async function* chunkFind<\n Services,\n Path extends KeyOf<Services>,\n Service extends Services[Path] = Services[Path],\n P extends Params = InferFindParams<Service>,\n Item = InferFindResultSingle<Service>,\n>(\n app: Application<Services>,\n servicePath: Path,\n options?: ChunkFindOptions<P>,\n): AsyncGenerator<Item[], void, unknown> {\n const service = app.service(servicePath)\n\n if (!service || !('find' in service)) {\n throw new Error(`Service '${servicePath}' does not have a 'find' method.`)\n }\n\n const params = {\n ...options?.params,\n query: {\n ...(options?.params?.query ?? {}),\n $limit: options?.params?.query?.$limit ?? 10,\n $skip: options?.params?.query?.$skip ?? 0,\n },\n paginate: {\n default: options?.params?.paginate?.default ?? 10,\n max: options?.params?.paginate?.max ?? 100,\n },\n }\n\n let result\n\n do {\n result = await (service as any).find(params)\n\n // Guard against an infinite loop: an empty page never advances $skip, so\n // `total > $skip` could stay true forever (e.g. $limit:0, or a stale total\n // when items are concurrently removed / filtered out by hooks).\n if (!result.data.length) {\n break\n }\n\n yield result.data\n\n params.query.$skip = (params.query.$skip ?? 0) + result.data.length\n } while (result.total > params.query.$skip)\n}\n","import type { Query } from '@feathersjs/feathers'\nimport { dequal as deepEqual } from 'dequal'\n\n/**\n * Safely merges properties into a Feathers query object. If a property already exists\n * with a different value, it wraps both in a `$and` array to preserve both conditions.\n * If the exact same key-value pair already exists, no changes are made.\n *\n * @example\n * ```ts\n * import { addToQuery } from 'feathers-utils/utils'\n *\n * const query = { status: 'active' }\n * addToQuery(query, { role: 'admin' })\n * // => { status: 'active', role: 'admin' }\n * ```\n *\n * @see https://utils.feathersjs.com/utils/add-to-query.html\n */\nexport function addToQuery<Q extends Query>(targetQuery: Q, query: Q): Q {\n targetQuery ??= {} as Q\n\n if (Object.keys(query).length === 0) {\n return targetQuery\n }\n\n const entries = Object.entries(query) as [keyof Q, any][]\n\n if (entries.every(([property]) => !(property in targetQuery))) {\n // if none of the properties exist, merge them directly\n return {\n ...targetQuery,\n ...query,\n }\n }\n\n function isAlreadyInQuery(targetQuery: Q, entries: [keyof Q, any][]) {\n return entries.every(\n ([property, value]) =>\n property in targetQuery && deepEqual(targetQuery[property], value),\n )\n }\n\n if (isAlreadyInQuery(targetQuery, entries)) {\n // if all properties already exist with the exact same value, do nothing\n return targetQuery\n }\n\n if (!targetQuery.$and) {\n return {\n ...targetQuery,\n $and: [{ ...query }],\n }\n }\n\n // check if the exact same value already exists in $and\n if (targetQuery.$and.some((q: any) => isAlreadyInQuery(q, entries))) {\n return targetQuery\n }\n\n return {\n ...targetQuery,\n $and: [...targetQuery.$and, { ...query }],\n }\n}\n","import type { HookContext } from '@feathersjs/feathers'\nimport type { HookType, MethodName } from '../../types.js'\nimport {\n isContext,\n type IsContextOptions,\n} from '../../predicates/is-context/is-context.predicate.js'\nimport type { UnpackMaybeArray } from '../../internal.utils.js'\n\ntype NarrowedContext<H extends HookContext, O> = H &\n (O extends { path: infer P }\n ? [P] extends [undefined | null]\n ? unknown\n : { path: UnpackMaybeArray<P> }\n : unknown) &\n (O extends { type: infer T }\n ? [T] extends [undefined | null]\n ? unknown\n : { type: UnpackMaybeArray<T> }\n : unknown) &\n (O extends { method: infer M }\n ? [M] extends [undefined | null]\n ? unknown\n : { method: UnpackMaybeArray<M> }\n : unknown)\n\nexport type CheckContextOptions<H extends HookContext = HookContext> =\n IsContextOptions<H> & {\n label?: string\n }\n\n/**\n * Validates that the hook context matches the expected type(s) and method(s).\n * Throws an error if the context is invalid, preventing hooks from running in\n * unsupported configurations. Typically used internally by other hooks.\n * Also narrows the context type based on the passed options.\n *\n * @example\n * ```ts\n * import { checkContext } from 'feathers-utils/utils'\n *\n * const myHook = (context) => {\n * checkContext(context, ['before', 'around'], ['create', 'patch'], 'myHook')\n * // or with options object:\n * checkContext(context, { type: ['before', 'around'], method: ['create', 'patch'], label: 'myHook' })\n * // context.type is now 'before' | 'around', context.method is now 'create' | 'patch'\n * }\n * ```\n *\n * @see https://utils.feathersjs.com/utils/check-context.html\n */\nexport function checkContext<\n H extends HookContext,\n const O extends CheckContextOptions<NoInfer<H>>,\n>(context: H, options: O): asserts context is NarrowedContext<H, O>\nexport function checkContext<\n H extends HookContext,\n const T extends HookType | HookType[] | null | undefined = undefined,\n const M extends MethodName | MethodName[] | null | undefined = undefined,\n>(\n context: H,\n type?: T,\n methods?: M,\n label?: string,\n): asserts context is NarrowedContext<H, { type: T; method: M }>\nexport function checkContext<H extends HookContext = HookContext>(\n context: H,\n typeOrOptions?:\n | HookType\n | HookType[]\n | CheckContextOptions<NoInfer<H>>\n | null,\n methods?: MethodName | MethodName[] | null,\n label = 'anonymous',\n): void {\n let options: IsContextOptions\n let hookLabel: string\n\n if (\n typeOrOptions != null &&\n typeof typeOrOptions === 'object' &&\n !Array.isArray(typeOrOptions)\n ) {\n const { label: optLabel, ...rest } = typeOrOptions\n options = rest\n hookLabel = optLabel ?? 'anonymous'\n } else {\n options = {\n method: methods ?? undefined,\n type: typeOrOptions ?? undefined,\n }\n hookLabel = label\n }\n\n if (!isContext(options)(context)) {\n const details: string[] = []\n\n if (options.type != null) {\n details.push(\n `type: expected '${Array.isArray(options.type) ? options.type.join(\"' | '\") : options.type}' but got '${context.type}'`,\n )\n }\n if (options.method != null) {\n details.push(\n `method: expected '${Array.isArray(options.method) ? options.method.join(\"' | '\") : options.method}' but got '${context.method}'`,\n )\n }\n if (options.path != null) {\n details.push(\n `path: expected '${Array.isArray(options.path) ? options.path.join(\"' | '\") : options.path}' but got '${context.path}'`,\n )\n }\n\n throw new Error(\n `The '${hookLabel}' hook has invalid context (${details.join(', ')}).`,\n )\n }\n}\n","import type { HookContext } from '@feathersjs/feathers'\n\n/**\n * Converts a FeathersJS HookContext to a plain JSON object by calling `toJSON()` if available.\n * This is important when using lodash `get`/`has` on the context, since the HookContext\n * class uses getters that may not be enumerable.\n *\n * @example\n * ```ts\n * import { contextToJson } from 'feathers-utils/utils'\n *\n * const json = contextToJson(context)\n * console.log(json)\n * ```\n *\n * @see https://utils.feathersjs.com/utils/context-to-json.html\n */\nexport const contextToJson = (context: HookContext) => {\n if (context.toJSON) {\n return context.toJSON()\n }\n return context\n}\n","import type { Application, HookOptions } from '@feathersjs/feathers'\n\n/**\n * TypeScript helper that provides full type inference and autocompletion when defining\n * service hooks. It is an identity function that simply returns its input,\n * but enables your IDE to infer the correct hook context types.\n *\n * @example\n * ```ts\n * import { defineHooks } from 'feathers-utils/utils'\n *\n * export const userHooks = defineHooks({\n * before: { create: [validateUser()] },\n * after: { all: [sanitizeResult()] }\n * })\n * ```\n *\n * @see https://utils.feathersjs.com/utils/define-hooks.html\n */\nexport function defineHooks<\n A extends Application = Application,\n S = {\n find: any\n get: any\n create: any\n update: any\n patch: any\n remove: any\n },\n Options = HookOptions<A, S>,\n>(hooks: Options): Options {\n return hooks\n}\n","// src/feathers.ts\nimport * as feathers from '@feathersjs/feathers'\n\n// Type-safe re-export of only what you need\nexport const SERVICE = (feathers as any).SERVICE || feathers.default?.SERVICE\n","import type { Service } from '@feathersjs/feathers'\nimport { SERVICE } from '../../feathers-cjs-fix.js'\n\n/**\n * Returns the list of method names that are publicly exposed by a Feathers service.\n * Reads the internal `[SERVICE].methods` property set during service registration.\n * Throws if the service does not have any exposed methods configured.\n *\n * @example\n * ```ts\n * import { getExposedMethods } from 'feathers-utils/utils'\n *\n * const methods = getExposedMethods(app.service('users'))\n * // => ['find', 'get', 'create', 'patch', 'remove']\n * ```\n *\n * @see https://utils.feathersjs.com/utils/get-exposed-methods.html\n */\nexport function getExposedMethods(service: Service) {\n const result = (service as any)[SERVICE].methods\n\n if (!result || !Array.isArray(result)) {\n throw new Error(`Service does not have exposed methods`)\n }\n\n return result\n}\n","import type { Application, Params } from '@feathersjs/feathers'\nimport type { KeyOf } from '../../internal.utils.js'\nimport type {\n InferFindParams,\n InferFindResultSingle,\n} from '../../utility-types/infer-service-methods.js'\n\ntype PaginateOption = { default?: number; max?: number }\n\ntype IterateFindOptions<P extends Params = Params> = {\n params?: P & { paginate?: PaginateOption }\n}\n\n/**\n * Use `for await` to iterate over the results of a `find` method.\n *\n * This function is useful for iterating over large datasets without loading everything into memory at once.\n * It uses pagination to fetch results in chunks, allowing you to process each item as it is retrieved.\n *\n * @example\n * ```ts\n * import { iterateFind } from 'feathers-utils/utils'\n *\n * const app = feathers()\n *\n * // Assuming 'users' service has many records\n * for await (const user of iterateFind(app, 'users', {\n * params: { query: { active: true }, // Custom query parameters\n * } })) {\n * console.log(user) // Process each user record\n * }\n * ```\n *\n * @see https://utils.feathersjs.com/utils/iterate-find.html\n */\nexport async function* iterateFind<\n Services,\n Path extends KeyOf<Services>,\n Service extends Services[Path] = Services[Path],\n P extends Params = InferFindParams<Service>,\n Item = InferFindResultSingle<Service>,\n>(\n app: Application<Services>,\n servicePath: Path,\n options?: IterateFindOptions<P>,\n): AsyncGenerator<Item, void, unknown> {\n const service = app.service(servicePath)\n\n if (!service || !('find' in service)) {\n throw new Error(`Service '${servicePath}' does not have a 'find' method.`)\n }\n\n const params = {\n ...options?.params,\n query: {\n ...(options?.params?.query ?? {}),\n $limit: options?.params?.query?.$limit,\n $skip: options?.params?.query?.$skip ?? 0,\n },\n paginate: {\n default: options?.params?.paginate?.default ?? 10,\n max: options?.params?.paginate?.max ?? 100,\n },\n }\n\n let result\n\n do {\n result = await (service as any).find(params)\n\n // Guard against an infinite loop: an empty page never advances $skip, so\n // `total > $skip` could stay true forever (e.g. $limit:0, or a stale total\n // when items are concurrently removed / filtered out by hooks).\n if (!result.data.length) {\n break\n }\n\n for (const item of result.data) {\n yield item\n }\n\n params.query.$skip = (params.query.$skip ?? 0) + result.data.length\n } while (result.total > params.query.$skip)\n}\n","import type { Id, Params } from '@feathersjs/feathers'\nimport type { KeyOf } from '../../internal.utils.js'\n\n/**\n * Deterministic, key-order-independent serialization used to group items with\n * equal patch data in O(1) per item.\n */\nconst stableKey = (value: any): string =>\n JSON.stringify(value, (_key, val) =>\n val && typeof val === 'object' && !Array.isArray(val)\n ? Object.keys(val)\n .sort()\n .reduce<Record<string, any>>((acc, k) => {\n acc[k] = val[k]\n return acc\n }, {})\n : val,\n )\n\nexport type PatchBatchOptions<IdKey extends string> = {\n /** the key of the id property */\n id?: IdKey\n}\n\nexport type PatchBatchResultItem<T = Record<string, unknown>, P = Params> = [\n Id | null,\n T,\n P | undefined,\n]\n\n/**\n * Batch patching utility that takes an array of items to be changed and returns an array of arguments to be called with the `patch` method.\n *\n * This utility is useful when you need to patch multiple items with varying data in as few requests as possible.\n *\n * @example\n * ```ts\n * const items = [\n * { id: 1, value: 10 },\n * { id: 2, value: 10 },\n * { id: 3, value: 20 },\n * ];\n *\n * const batched = patchBatch(items, { id: 'id' });\n * // batched will be:\n * // [\n * // [null, { value: 10 }, { query: { id: { $in: [1, 2] } } }],\n * // [3, { value: 20 }, undefined],\n * // ]\n *\n * await Promise.all(batched.map(args => service.patch(...args)));\n * ```\n *\n * @see https://utils.feathersjs.com/utils/patch-batch.html\n */\nexport function patchBatch<\n T extends Record<string, any>,\n IdKey extends KeyOf<T>,\n P extends Params,\n R extends Omit<T, IdKey> = Omit<T, IdKey>,\n>(\n items: T[],\n options?: PatchBatchOptions<IdKey>,\n): PatchBatchResultItem<R, P>[] {\n const idKey = options?.id ?? 'id'\n\n // group items with identical (id-stripped) data in O(n) via a Map keyed by a\n // stable serialization, instead of an O(n^2) findIndex + deepEqual scan.\n const groups = new Map<string, { ids: Id[]; data: R }>()\n\n for (const item of items) {\n const source = item as Record<string, any>\n const id = source[idKey] as Id\n // shallow copy then drop the id key, so the caller's input is never mutated.\n const data = { ...source }\n delete data[idKey as any]\n\n const key = stableKey(data)\n const existing = groups.get(key)\n\n if (existing) {\n existing.ids.push(id)\n } else {\n groups.set(key, { ids: [id], data: data as unknown as R })\n }\n }\n\n return [...groups.values()].map(({ ids, data }) => {\n return ids.length === 1\n ? ([ids[0], data, undefined] as PatchBatchResultItem<R, P>)\n : ([\n null,\n data,\n {\n query: {\n [idKey]: { $in: ids },\n },\n },\n ] as PatchBatchResultItem<R, P>)\n })\n}\n","import type { HookContext } from '@feathersjs/feathers'\nimport { isMulti, isPaginated } from '../../predicates/index.js'\n\n/**\n * Sets `context.result` to an appropriate empty value based on the hook method.\n * Returns an empty paginated object for paginated `find`, an empty array for multi\n * operations, or `null` for single-item operations. Does nothing if a result already exists.\n *\n * @example\n * ```ts\n * import { skipResult } from 'feathers-utils/utils'\n *\n * // In a before hook to skip the actual database call:\n * skipResult(context)\n * ```\n *\n * @see https://utils.feathersjs.com/utils/skip-result.html\n */\nexport const skipResult = <H extends HookContext = HookContext>(context: H) => {\n if (context.result) {\n return context\n }\n\n const multi = isMulti(context)\n\n if (multi) {\n if (context.method === 'find' && isPaginated(context)) {\n context.result = {\n total: 0,\n skip: 0,\n limit: 0,\n data: [],\n }\n } else {\n context.result = []\n }\n } else {\n context.result = null\n }\n\n return context\n}\n","import type { Paginated } from '@feathersjs/feathers'\n\n/**\n * Ensures a result is in Feathers paginated format (`{ total, limit, skip, data }`).\n * If the input is already paginated, it is returned as-is. If it is a plain array,\n * it is wrapped in a paginated object with `total` and `limit` set to the array length.\n *\n * @example\n * ```ts\n * import { toPaginated } from 'feathers-utils/utils'\n *\n * const paginated = toPaginated([{ id: 1 }, { id: 2 }])\n * // => { total: 2, limit: 2, skip: 0, data: [{ id: 1 }, { id: 2 }] }\n * ```\n *\n * @see https://utils.feathersjs.com/utils/to-paginated.html\n */\nexport function toPaginated<R>(result: R[] | Paginated<R>): Paginated<R> {\n if (Array.isArray(result)) {\n return {\n total: result.length,\n limit: result.length,\n skip: 0,\n data: result,\n }\n }\n return result\n}\n","import type { Params } from '@feathersjs/feathers'\nimport type { TransformParamsFn } from '../../types.js'\n\n/**\n * Safely applies a `transformParams` function to a params object.\n * If no function is provided, the original params are returned unchanged.\n * The function receives a shallow copy of params, so the original is not mutated.\n *\n * @example\n * ```ts\n * import { transformParams } from 'feathers-utils/utils'\n *\n * const params = transformParams(context.params, (p) => { delete p.provider; return p })\n * ```\n *\n * @see https://utils.feathersjs.com/utils/transform-params.html\n */\nexport const transformParams = <P extends Params = Params>(\n params: P,\n fn: TransformParamsFn<P> | undefined,\n): P => {\n if (!fn) {\n return params\n }\n\n const result = fn({ ...params })\n\n return result ?? params\n}\n","import type { Query } from '@feathersjs/feathers'\n\ntype WalkQueryOptionsInit = {\n property?: string\n operator?: string | undefined\n value?: any\n path: (string | number)[]\n}\n\nexport type WalkQueryOptions = {\n property: string\n operator: string | undefined\n value: any\n path: (string | number)[]\n}\n\nexport type WalkQueryCallback = (options: WalkQueryOptions) => any\n\nconst _walkQueryUtil = <Q extends Query>(\n query: Q,\n walker: WalkQueryCallback,\n options?: WalkQueryOptionsInit | WalkQueryOptions,\n): Q => {\n let cloned = false\n const clonedSecond: Record<string, boolean> = {}\n function set(key: string, value: any, secondKey?: string | number) {\n if (!cloned) {\n query = { ...query }\n cloned = true\n }\n\n if (secondKey !== undefined) {\n if (!clonedSecond[key]) {\n ;(query as any)[key] = { ...query[key] }\n clonedSecond[key] = true\n }\n query[key][secondKey] = value\n return\n }\n\n ;(query as any)[key] = value\n }\n\n for (const key in query) {\n if (\n (key === '$or' || key === '$and' || key === '$nor') &&\n Array.isArray(query[key])\n ) {\n let array = query[key]\n\n let copiedArray = false\n\n for (let i = 0, n = array.length; i < n; i++) {\n const nestedQuery = array[i]\n const transformed = _walkQueryUtil(nestedQuery, walker, {\n ...options,\n path: [...(options?.path || []), key, i],\n })\n\n if (transformed !== nestedQuery) {\n if (!copiedArray) {\n array = [...array] as any\n copiedArray = true\n }\n\n array[i] = transformed\n }\n }\n\n if (copiedArray) {\n set(key, array)\n }\n } else if (\n typeof query[key] === 'object' &&\n query[key] !== null &&\n !Array.isArray(query[key])\n ) {\n let hasOperator = false\n for (const operator in query[key]) {\n if (operator.startsWith('$')) {\n hasOperator = true\n const value = walker({\n operator,\n path: [...(options?.path ?? []), key],\n property: key,\n value: query[key][operator],\n })\n\n if (value !== undefined && value !== query[key][operator]) {\n set(key, value, operator)\n }\n }\n }\n\n if (!hasOperator) {\n const value = walker({\n operator: undefined,\n path: [...(options?.path ?? []), key],\n property: key,\n value: query[key],\n })\n\n if (value !== undefined && value !== query[key]) {\n set(key, value)\n }\n }\n } else {\n const value = walker({\n operator: undefined,\n path: [...(options?.path ?? []), key],\n property: key,\n value: query[key],\n })\n\n if (value !== undefined && value !== query[key]) {\n set(key, value)\n }\n }\n }\n\n return query\n}\n\n/**\n * Walks every property of a Feathers query (including nested `$and`/`$or`/`$nor` arrays)\n * and calls the `walker` function for each one. The walker receives the property name, operator,\n * value, and path, and can return a replacement value. Returns a new query only if changes were made.\n *\n * @example\n * ```ts\n * import { walkQuery } from 'feathers-utils/utils'\n *\n * const query = walkQuery({ age: { $gt: '18' } }, ({ value, operator }) => {\n * if (operator === '$gt') return Number(value)\n * })\n * // => { age: { $gt: 18 } }\n * ```\n *\n * @see https://utils.feathersjs.com/utils/walk-query.html\n */\nexport const walkQuery = <Q extends Query>(\n query: Q,\n walker: WalkQueryCallback,\n): Q => {\n return _walkQueryUtil(query, walker)\n}\n","import type { HookContext } from '@feathersjs/feathers'\nimport { getDataIsArray } from '../get-data-is-array/get-data-is-array.util.js'\nimport { getResultIsArray } from '../get-result-is-array/get-result-is-array.util.js'\nimport { checkContext } from '../check-context/check-context.util.js'\nimport type {\n DataSingleHookContext,\n ResultSingleHookContext,\n} from '../../utility-types/hook-context.js'\n\nexport type ZipDataResultOptions = {\n onMismatch?: (context: HookContext) => void\n}\n\nexport type ZipDataResultItem<D, R> = {\n data: D | undefined\n result: R | undefined\n}\n\n/**\n * Pairs each item in `context.data` with its corresponding item in `context.result` by index.\n * Handles both single-item and array data, normalizing them into an array of `{ data, result }` pairs.\n * Only works in `after`/`around` hooks for `create`, `update`, and `patch` methods.\n *\n * @example\n * ```ts\n * import { zipDataResult } from 'feathers-utils/utils'\n *\n * const pairs = zipDataResult(context)\n * pairs.forEach(({ data, result }) => { /* process each pair *\\/ })\n * ```\n *\n * @see https://utils.feathersjs.com/utils/zip-data-result.html\n */\nexport function zipDataResult<\n H extends HookContext,\n D extends DataSingleHookContext<H> = DataSingleHookContext<H>,\n R extends ResultSingleHookContext<H> = ResultSingleHookContext<H>,\n>(context: H, options?: ZipDataResultOptions): ZipDataResultItem<D, R>[] {\n checkContext(context, ['after', 'around'], ['create', 'update', 'patch'])\n\n const input = getDataIsArray(context)\n const output = getResultIsArray(context)\n\n if (\n input.isArray &&\n output.isArray &&\n input.data.length !== output.result.length\n ) {\n options?.onMismatch?.(context)\n }\n\n const result: ZipDataResultItem<D, R>[] = []\n\n const length = Math.max(input.data.length, output.result.length)\n\n for (let i = 0; i < length; i++) {\n const dataItem = input.isArray ? input.data.at(i) : input.data[0]\n const resultItem = output.result.at(i)\n\n result.push({\n data: dataItem,\n result: resultItem,\n })\n }\n\n return result\n}\n"],"mappings":";;;;;AAEA,MAAM,iBAAiB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAO;AAAM,CAAC;AAE7E,MAAM,qBAAqB,UACzB,UAAU,QAAQ,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;AAyBrC,MAAa,uBAAwC,UAAgB;CACnE,OAAO,UAAU,KAAK;AACxB;AAEA,MAAM,aAAa,UAAoB;CACrC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,SAAS;CAG5B,IAAI,CAAC,kBAAkB,KAAK,GAC1B,OAAO;CAGT,MAAM,SAA8B,CAAC;CAErC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,KAAK,GAAG;EAC3C,MAAM,MAAM,MAAM;EAElB,IAAI,eAAe,IAAI,GAAG,KAAK,MAAM,QAAQ,GAAG,GAI9C,OAAO,OAAO,IACX,KAAK,OAAO;GACX,MAAM,aAAa,UAAU,EAAE;GAC/B,OAAO;IAAE,GAAG,KAAK,UAAU,UAAU;IAAG,GAAG;GAAW;EACxD,CAAC,CAAC,CACD,MAAM,GAAG,MAAO,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EAAE,IAAI,IAAI,CAAE,CAAC,CACpD,KAAK,U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