From 45ab367683b2bcfc791e7181a388ca191f5d1b05 Mon Sep 17 00:00:00 2001 From: fratzinger <22286818+fratzinger@users.noreply.github.com> Date: Wed, 1 Jul 2026 10:25:56 +0200 Subject: [PATCH] fix: rename passParams -> gateParams & rateLimit static values --- src/hooks/cache/cache.hook.md | 16 +++---- src/hooks/cache/cache.hook.test.ts | 12 +++--- src/hooks/cache/cache.hook.ts | 6 +-- src/hooks/rate-limit/rate-limit.hook.md | 42 +++++++++++++++---- src/hooks/rate-limit/rate-limit.hook.test.ts | 31 ++++++++++++++ src/hooks/rate-limit/rate-limit.hook.ts | 25 +++++++---- .../gate-params.util.md} | 2 +- .../gate-params.util.test-d.ts} | 8 ++-- .../gate-params.util.test.ts} | 42 +++++++++---------- .../gate-params.util.ts} | 28 ++++++------- src/utils/index.ts | 2 +- test/index.test.ts | 2 +- 12 files changed, 141 insertions(+), 75 deletions(-) rename src/utils/{pass-params/pass-params.util.md => gate-params/gate-params.util.md} (80%) rename src/utils/{pass-params/pass-params.util.test-d.ts => gate-params/gate-params.util.test-d.ts} (81%) rename src/utils/{pass-params/pass-params.util.test.ts => gate-params/gate-params.util.test.ts} (73%) rename src/utils/{pass-params/pass-params.util.ts => gate-params/gate-params.util.ts} (88%) diff --git a/src/hooks/cache/cache.hook.md b/src/hooks/cache/cache.hook.md index 388ac27..41d421c 100644 --- a/src/hooks/cache/cache.hook.md +++ b/src/hooks/cache/cache.hook.md @@ -6,7 +6,7 @@ hook: method: ['find', 'get', 'create', 'update', 'patch', 'remove'] multi: true see: - - utils/passParams + - utils/gateParams --- The `cache` hook caches `get` and `find` results based on `params`. On mutating methods (`create`, `update`, `patch`, `remove`), affected cache entries are automatically invalidated. @@ -21,16 +21,16 @@ The `cache` hook caches `get` and `find` results based on `params`. On mutating | ----------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `map` | `Cache` | The cache implementation. Must implement `get`, `set`, `delete`, `clear`, and `keys`. | | `id` | `string` | The id field to use. Defaults to `service.options.id`, then `'id'`. | -| `transformParams` | `(params) => params` | Transform params before they are used as cache key. Compose it with [`passParams`](/utils/pass-params) to declaratively pick/drop keys and avoid false hits — see [Choosing Cache-Relevant Params](#choosing-cache-relevant-params-with-passparams). | +| `transformParams` | `(params) => params` | Transform params before they are used as cache key. Compose it with [`gateParams`](/utils/gate-params) to declaratively pick/drop keys and avoid false hits — see [Choosing Cache-Relevant Params](#choosing-cache-relevant-params-with-gateparams). | -## Choosing Cache-Relevant Params (with `passParams`) +## Choosing Cache-Relevant Params (with `gateParams`) Deciding which `params` keys form the cache key is the trickiest part of caching, and the two failure modes are asymmetric: - **False hits (dangerous):** if a key that affects the result is left out (e.g. `user`/tenant, `provider`), two semantically different requests collapse to the same key — one user can be served another user's cached data. - **False misses (wasteful):** if a per-request/metrics key is included (e.g. `rateLimit`), every request produces a unique key and the cache never hits. A function-valued key (e.g. `stashed` from `stashable`) would even make serialization throw. -The [`passParams`](/utils/pass-params) utility makes this explicit and safe. It takes a declarative path schema (`true` include, `false` drop, or a predicate/projection function). `query` is always included by default, and keys you never classified are **kept by default** — the safe direction, since a forgotten key causes at worst a harmless cache miss, never a false hit. +The [`gateParams`](/utils/gate-params) utility makes this explicit and safe. It takes a declarative path schema (`true` include, `false` drop, or a predicate/projection function). `query` is always included by default, and keys you never classified are **kept by default** — the safe direction, since a forgotten key causes at worst a harmless cache miss, never a false hit. > Transient keys that feathers-utils' own hooks attach to `params` — `rateLimit` (`rateLimit`), `skipHooks` (`skippable`/`addSkip`), the `stashed` function and `_stashable` flag (`stashable`) — are never cache-relevant. Drop them with `false`, or keep only what you list via `dropUnknownParams: true`. @@ -39,12 +39,12 @@ The [`passParams`](/utils/pass-params) utility makes this explicit and safe. It Cache on everything except the keys you explicitly drop with `false`. This is the default direction — safe against false hits: ```ts -import { passParams } from 'feathers-utils/utils' +import { gateParams } from 'feathers-utils/utils' cache({ map: new Map(), transformParams: (params) => - passParams(params, { rateLimit: false, skipHooks: false }), + gateParams(params, { rateLimit: false, skipHooks: false }), }) ``` @@ -53,12 +53,12 @@ cache({ Set `dropUnknownParams: true` so only `query` (always) and the listed paths form the cache key. `user.id` is picked via dot-notation so different tenants never collide and per-request `user` fields don't bloat the key. Use `onUnknownParams` to log anything that was dropped: ```ts -import { passParams } from 'feathers-utils/utils' +import { gateParams } from 'feathers-utils/utils' cache({ map: new Map(), transformParams: (params) => - passParams( + gateParams( params, { 'user.id': true }, // `query` is included automatically { diff --git a/src/hooks/cache/cache.hook.test.ts b/src/hooks/cache/cache.hook.test.ts index f1171c8..8682add 100644 --- a/src/hooks/cache/cache.hook.test.ts +++ b/src/hooks/cache/cache.hook.test.ts @@ -7,7 +7,7 @@ import { TTLCache } from '@isaacs/ttlcache' import { MemoryService } from '@feathersjs/memory' import { expect, expectTypeOf } from 'vitest' import { copy } from 'fast-copy' -import { passParams } from '../../utils/pass-params/pass-params.util.js' +import { gateParams } from '../../utils/gate-params/gate-params.util.js' const setup = (options: CacheOptions, serviceOptions?: { id?: string }) => { const app = feathers<{ @@ -1149,12 +1149,12 @@ describe('cache hook as an around hook', () => { }) }) -describe('cache hook with passParams', () => { +describe('cache hook with gateParams', () => { it('prevents false hits across users and collapses non-id user fields (whitelist)', async () => { const { usersService, before } = setup({ map: new Map(), // `query` is included by default; only `user.id` is added explicitly. - transformParams: (params) => passParams(params, { 'user.id': true }), + transformParams: (params) => gateParams(params, { 'user.id': true }), }) await usersService.create({ id: 1, name: 'John' }) @@ -1185,7 +1185,7 @@ describe('cache hook with passParams', () => { const { usersService, before } = setup({ map: new Map(), // keep everything except the transient `rateLimit` metric. - transformParams: (params) => passParams(params, { rateLimit: false }), + transformParams: (params) => gateParams(params, { rateLimit: false }), }) await usersService.create({ id: 1, name: 'John' }) @@ -1209,7 +1209,7 @@ describe('cache hook with passParams', () => { map: new Map(), // keep only `query` (default); `stashed` (a function) is dropped. transformParams: (params) => - passParams(params, {}, { dropUnknownParams: true }), + gateParams(params, {}, { dropUnknownParams: true }), }) await usersService.create({ id: 1, name: 'John' }) @@ -1235,7 +1235,7 @@ describe('cache hook with passParams', () => { const { usersService } = setup({ map: new Map(), transformParams: (params) => - passParams(params, { query: true }, { onUnknownParams }), + gateParams(params, { query: true }, { onUnknownParams }), }) await usersService.create({ id: 1, name: 'John' }) diff --git a/src/hooks/cache/cache.hook.ts b/src/hooks/cache/cache.hook.ts index 6e5d52a..db118ac 100755 --- a/src/hooks/cache/cache.hook.ts +++ b/src/hooks/cache/cache.hook.ts @@ -35,17 +35,17 @@ export type CacheOptions = { * 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. * - * The {@link passParams} util is built for exactly this: it declaratively + * The {@link gateParams} util is built for exactly this: it declaratively * selects/projects `params` keys (keeping `query` by default) so noise like * `rateLimit` never ends up in the cache key. * * @example * ```ts - * import { passParams } from 'feathers-utils/utils' + * import { gateParams } from 'feathers-utils/utils' * * cache({ * map: new Map(), - * transformParams: (params) => passParams(params, { rateLimit: false }), + * transformParams: (params) => gateParams(params, { rateLimit: false }), * }) * ``` */ diff --git a/src/hooks/rate-limit/rate-limit.hook.md b/src/hooks/rate-limit/rate-limit.hook.md index 990754c..8539aa7 100644 --- a/src/hooks/rate-limit/rate-limit.hook.md +++ b/src/hooks/rate-limit/rate-limit.hook.md @@ -2,8 +2,8 @@ title: rateLimit category: hooks hook: - type: ["before", "around"] - method: ["find", "get", "create", "update", "patch", "remove"] + type: ['before', 'around'] + method: ['find', 'get', 'create', 'update', 'patch', 'remove'] multi: true --- @@ -13,10 +13,10 @@ Any rate limiter backend supported by `rate-limiter-flexible` can be used (Memor ## Options -| Option | Type | Description | -| --- | --- | --- | -| `key` | `(context) => string` | Generate the rate-limiting key. Defaults to `context.path`. | -| `points` | `(context) => number` | Number of points to consume per request. Defaults to `1`. | +| Option | Type | Description | +| -------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `key` | `string \| ((context) => string)` | The rate-limiting key, or a function to derive it from the context. Defaults to `context.path`. Pass a static string for a single shared bucket (a global rate limit). | +| `points` | `number \| ((context) => number)` | Number of points to consume per request, or a function to compute it from the context. Defaults to `1`. | The `RateLimiterRes` is stored on `context.params.rateLimit` on both success and failure, so downstream hooks or services can inspect `remainingPoints`, `consumedPoints`, `msBeforeNext`, etc. @@ -58,16 +58,40 @@ app.service('messages').hooks({ }) ``` +### Global Rate Limit + +Pass a static string as the `key` to share a single bucket across all requests — a global cap on an endpoint instead of one bucket per `context.path`: + +```ts +const rateLimiter = new RateLimiterMemory({ points: 1000, duration: 60 }) + +app.service('search').hooks({ + before: { + find: [rateLimit(rateLimiter, { key: 'search' })], + }, +}) +``` + ### Custom Points per Request -Use the `points` option to consume more points for expensive operations: +Pass a static number to consume a fixed cost per request: + +```ts +app.service('reports').hooks({ + before: { + find: [rateLimit(rateLimiter, { points: 5 })], + }, +}) +``` + +Or pass a function to compute the cost from the context — e.g. to charge more for expensive queries: ```ts app.service('reports').hooks({ before: { find: [ rateLimit(rateLimiter, { - points: (context) => context.params.query?.$limit > 100 ? 5 : 1, + points: (context) => (context.params.query?.$limit > 100 ? 5 : 1), }), ], }, @@ -128,4 +152,4 @@ app.service('users').hooks({ // Skip rate limiting for this call app.service('users').find({ skipHooks: ['rateLimit'] }) -``` \ No newline at end of file +``` diff --git a/src/hooks/rate-limit/rate-limit.hook.test.ts b/src/hooks/rate-limit/rate-limit.hook.test.ts index 3afb59f..588097b 100644 --- a/src/hooks/rate-limit/rate-limit.hook.test.ts +++ b/src/hooks/rate-limit/rate-limit.hook.test.ts @@ -93,6 +93,37 @@ describe('hook - rateLimit', () => { ) }) + it('uses a static string key as a shared bucket', async () => { + const context: any = { + type: 'before', + method: 'find', + path: 'users', + params: {}, + } + const rateLimiter = new RateLimiterMemory({ points: 1, duration: 1 }) + + // Both requests share the same static bucket, so the second is rejected + await rateLimit(rateLimiter, { key: 'global' })(context) + await expect( + rateLimit(rateLimiter, { key: 'global' })(context), + ).rejects.toThrow('Too many requests') + }) + + it('uses static number points', async () => { + const context: any = { + type: 'before', + method: 'find', + path: 'users', + params: {}, + } + const rateLimiter = new RateLimiterMemory({ points: 1, duration: 1 }) + + // Consuming 2 points against a 1-point limit should fail immediately + await expect( + rateLimit(rateLimiter, { points: 2 })(context), + ).rejects.toThrow('Too many requests') + }) + it('throws when used in an after hook', async () => { const context: any = { type: 'after', diff --git a/src/hooks/rate-limit/rate-limit.hook.ts b/src/hooks/rate-limit/rate-limit.hook.ts index 6ca3c47..2622394 100644 --- a/src/hooks/rate-limit/rate-limit.hook.ts +++ b/src/hooks/rate-limit/rate-limit.hook.ts @@ -5,10 +5,20 @@ import { checkContext } from '../../utils/index.js' import type { Promisable } from '../../internal.utils.js' export 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 + /** + * The rate-limiting key, or a function to derive it from the context. + * Defaults to `context.path`. + * + * Pass a static string to use a single shared bucket (a global rate limit + * across all requests), or a function to compute the key per request + * (e.g. per user or per IP). + */ + key?: string | ((context: H) => Promisable) + /** + * Number of points to consume per request, or a function to compute it from + * the context. Defaults to `1`. + */ + points?: number | ((context: H) => Promisable) } /** @@ -35,13 +45,14 @@ export const rateLimit = ( options?: RateLimitOptions, ) => { const key = options?.key ?? ((context: HookContext) => context.path) - const points = options?.points ?? (() => 1) + const points = options?.points ?? 1 return async (context: H, next?: NextFunction): Promise => { checkContext(context, { type: ['before', 'around'], label: 'rateLimit' }) - const resolvedKey = await key(context) - const resolvedPoints = await points(context) + const resolvedKey = typeof key === 'function' ? await key(context) : key + const resolvedPoints = + typeof points === 'function' ? await points(context) : points try { const res = await rateLimiter.consume(resolvedKey, resolvedPoints) diff --git a/src/utils/pass-params/pass-params.util.md b/src/utils/gate-params/gate-params.util.md similarity index 80% rename from src/utils/pass-params/pass-params.util.md rename to src/utils/gate-params/gate-params.util.md index b269534..88dda04 100644 --- a/src/utils/pass-params/pass-params.util.md +++ b/src/utils/gate-params/gate-params.util.md @@ -1,5 +1,5 @@ --- -title: passParams +title: gateParams category: utils see: - hooks/cache diff --git a/src/utils/pass-params/pass-params.util.test-d.ts b/src/utils/gate-params/gate-params.util.test-d.ts similarity index 81% rename from src/utils/pass-params/pass-params.util.test-d.ts rename to src/utils/gate-params/gate-params.util.test-d.ts index 820dcf7..340a1fb 100644 --- a/src/utils/pass-params/pass-params.util.test-d.ts +++ b/src/utils/gate-params/gate-params.util.test-d.ts @@ -1,14 +1,14 @@ import type { Params } from '@feathersjs/feathers' import { expectTypeOf } from 'vitest' -import { passParams } from './pass-params.util.js' +import { gateParams } from './gate-params.util.js' it('returns a Params object', () => { - const out = passParams({ query: {} }, { query: true }) + const out = gateParams({ query: {} }, { query: true }) expectTypeOf(out).toEqualTypeOf() }) it('accepts boolean and function rules, including nested paths and custom keys', () => { - passParams({ query: {}, user: { id: 1 }, custom: 1 } as Params, { + gateParams({ query: {}, user: { id: 1 }, custom: 1 } as Params, { query: true, paginate: false, 'user.id': true, @@ -22,7 +22,7 @@ it('accepts boolean and function rules, including nested paths and custom keys', }) it('types onUnknownParams and dropUnknownParams', () => { - passParams( + gateParams( { query: {} } as Params, { query: true }, { diff --git a/src/utils/pass-params/pass-params.util.test.ts b/src/utils/gate-params/gate-params.util.test.ts similarity index 73% rename from src/utils/pass-params/pass-params.util.test.ts rename to src/utils/gate-params/gate-params.util.test.ts index 376628e..f7c8334 100644 --- a/src/utils/pass-params/pass-params.util.test.ts +++ b/src/utils/gate-params/gate-params.util.test.ts @@ -1,95 +1,95 @@ import { describe, it, expect, vi } from 'vitest' import _omit from 'lodash/omit.js' -import { passParams } from './pass-params.util.js' +import { gateParams } from './gate-params.util.js' -describe('passParams', () => { +describe('gateParams', () => { it('rule true includes the value as-is', () => { const params = { user: { id: 5 } } as any - expect(passParams(params, { user: true })).toEqual({ user: { id: 5 } }) + expect(gateParams(params, { user: true })).toEqual({ user: { id: 5 } }) }) it('rule false drops the key', () => { const params = { query: { a: 1 }, paginate: false } as any - expect(passParams(params, { query: true, paginate: false })).toEqual({ + expect(gateParams(params, { query: true, paginate: false })).toEqual({ query: { a: 1 }, }) }) it('function returning true includes as-is', () => { const params = { query: { a: 1 } } as any - expect(passParams(params, { query: () => true })).toEqual({ + expect(gateParams(params, { query: () => true })).toEqual({ query: { a: 1 }, }) }) it('function returning false or undefined drops the key', () => { const params = { a: 1, b: 2 } as any - expect(passParams(params, { a: () => false, b: () => undefined })).toEqual( + expect(gateParams(params, { a: () => false, b: () => undefined })).toEqual( {}, ) }) it('function return value is used as a projection', () => { const params = { user: { id: 5, name: 'John' } } as any - expect(passParams(params, { user: (u) => u?.id })).toEqual({ user: 5 }) + expect(gateParams(params, { user: (u) => u?.id })).toEqual({ user: 5 }) }) it('picks a nested value via dot-notation path', () => { const params = { user: { id: 5, updatedAt: 123 } } as any - expect(passParams(params, { 'user.id': true })).toEqual({ user: { id: 5 } }) + expect(gateParams(params, { 'user.id': true })).toEqual({ user: { id: 5 } }) }) it('skips a schema path that is absent from params (no injection)', () => { const params = { query: {} } as any - expect(passParams(params, { query: true, 'user.id': true })).toEqual({ + expect(gateParams(params, { query: true, 'user.id': true })).toEqual({ query: {}, }) }) it('does not inject a top-level schema key absent from params', () => { const params = { query: {} } as any - expect(passParams(params, { query: true, user: true })).toEqual({ + expect(gateParams(params, { query: true, user: true })).toEqual({ query: {}, }) }) it('drops a nested key while keeping the parent via a projection', () => { const params = { query: { userId: 1, _$client: { foo: 1 } } } as any - expect(passParams(params, { query: (q) => _omit(q, '_$client') })).toEqual({ + expect(gateParams(params, { query: (q) => _omit(q, '_$client') })).toEqual({ query: { userId: 1 }, }) }) it('includes query by default when the schema omits it', () => { const params = { query: { a: 1 } } as any - expect(passParams(params, {})).toEqual({ query: { a: 1 } }) + expect(gateParams(params, {})).toEqual({ query: { a: 1 } }) }) it('does not include query by default when the schema sets it to false', () => { const params = { query: { a: 1 } } as any - expect(passParams(params, { query: false })).toEqual({}) + expect(gateParams(params, { query: false })).toEqual({}) }) it('does not default the whole query when a nested query path is declared', () => { const params = { query: { a: 1, b: 2 } } as any - expect(passParams(params, { 'query.a': true })).toEqual({ query: { a: 1 } }) + expect(gateParams(params, { 'query.a': true })).toEqual({ query: { a: 1 } }) }) it('keeps unknown keys by default', () => { const params = { query: {}, foo: 1 } as any - expect(passParams(params, {})).toEqual({ query: {}, foo: 1 }) + expect(gateParams(params, {})).toEqual({ query: {}, foo: 1 }) }) it('drops unknown keys with dropUnknownParams: true', () => { const params = { query: {}, foo: 1 } as any expect( - passParams(params, { 'user.id': true }, { dropUnknownParams: true }), + gateParams(params, { 'user.id': true }, { dropUnknownParams: true }), ).toEqual({ query: {} }) }) it('keeps unknown keys except the ones the schema drops with false', () => { const params = { query: {}, foo: 1, rateLimit: { remaining: 9 } } as any - expect(passParams(params, { rateLimit: false })).toEqual({ + expect(gateParams(params, { rateLimit: false })).toEqual({ query: {}, foo: 1, }) @@ -99,7 +99,7 @@ describe('passParams', () => { const params = { query: {}, user: { id: 5, updatedAt: 1 } } as any const onUnknownParams = vi.fn() - const out = passParams( + const out = gateParams( params, { query: true, 'user.id': true }, { onUnknownParams }, @@ -114,7 +114,7 @@ describe('passParams', () => { const params = { query: {}, rateLimit: { r: 1 }, mystery: 2 } as any const onUnknownParams = vi.fn() - passParams(params, { query: true, rateLimit: false }, { onUnknownParams }) + gateParams(params, { query: true, rateLimit: false }, { onUnknownParams }) expect(onUnknownParams).toHaveBeenCalledTimes(1) expect(onUnknownParams).toHaveBeenCalledWith(['mystery'], params) @@ -124,8 +124,8 @@ describe('passParams', () => { const params = { query: { a: 1 }, provider: 'rest', foo: 1 } as any const snapshot = structuredClone(params) - passParams(params, { query: true, foo: false }) - passParams(params, { 'query.a': true }) + gateParams(params, { query: true, foo: false }) + gateParams(params, { 'query.a': true }) expect(params).toEqual(snapshot) }) diff --git a/src/utils/pass-params/pass-params.util.ts b/src/utils/gate-params/gate-params.util.ts similarity index 88% rename from src/utils/pass-params/pass-params.util.ts rename to src/utils/gate-params/gate-params.util.ts index ce9aa1c..1303a31 100644 --- a/src/utils/pass-params/pass-params.util.ts +++ b/src/utils/gate-params/gate-params.util.ts @@ -8,11 +8,11 @@ import _toPath from 'lodash/toPath.js' * A rule for a single schema path. * - `true` → include the value as-is * - `false` → drop the path - * - function → unified predicate/projection (see {@link PassParamsFn}) + * - function → unified predicate/projection (see {@link GateParamsFn}) */ -export type PassParamsRule

= +export type GateParamsRule

= | boolean - | PassParamsFn

+ | GateParamsFn

/** * The flexible slot — serves as BOTH predicate and projection: @@ -23,7 +23,7 @@ export type PassParamsRule

= * @example predicate: `(value) => value != null` * @example projection: `(user) => user?.id` */ -export type PassParamsFn

= ( +export type GateParamsFn

= ( value: any, params: P, ) => boolean | undefined | unknown @@ -34,12 +34,12 @@ export type PassParamsFn

= ( * with lodash `get`/`has`; the result is built with `set` at the same path. * Any custom path is allowed. */ -export type PassParamsSchema

= Record< +export type GateParamsSchema

= Record< string, - PassParamsRule

+ GateParamsRule

> -export type PassParamsOptions

= { +export type GateParamsOptions

= { /** * Drop top-level `params` keys that the schema does not address (neither as a * top-level key nor as the root of a nested path). When `false` (the default) @@ -67,7 +67,7 @@ export type PassParamsOptions

= { * Selects and/or projects `params` keys according to a declarative path `schema`, * returning a NEW object (never mutates `params`). General-purpose — no cache * knowledge. Typically composed into the cache hook's `transformParams` option - * as `(p) => passParams(p, schema, opts)`. + * as `(p) => gateParams(p, schema, opts)`. * * Paths are resolved with lodash `get`/`has` and written with `set`, so nested * values can be picked declaratively (`'user.id': true`). @@ -81,19 +81,19 @@ export type PassParamsOptions

= { * * @example exclude specific params (default): everything except the listed noise * ```ts - * passParams(params, { rateLimit: false }) + * gateParams(params, { rateLimit: false }) * ``` * @example include only specific params * ```ts - * passParams(params, { 'user.id': true }, { dropUnknownParams: true }) + * gateParams(params, { 'user.id': true }, { dropUnknownParams: true }) * ``` * - * @see https://utils.feathersjs.com/utils/pass-params.html + * @see https://utils.feathersjs.com/utils/gate-params.html */ -export function passParams

( +export function gateParams

( params: P, - schema: PassParamsSchema

, - options?: PassParamsOptions

, + schema: GateParamsSchema

, + options?: GateParamsOptions

, ): Params { const out: Record = {} const claimedTop = new Set() diff --git a/src/utils/index.ts b/src/utils/index.ts index 0e35ab8..174d056 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,6 +4,7 @@ export * from './check-context/check-context.util.js' export * from './chunk-find/chunk-find.util.js' export * from './context-to-json/context-to-json.util.js' export * from './define-hooks/define-hooks.util.js' +export * from './gate-params/gate-params.util.js' export * from './get-data-is-array/get-data-is-array.util.js' export * from './get-exposed-methods/get-exposed-methods.util.js' export * from './get-paginate/get-paginate.util.js' @@ -12,7 +13,6 @@ export * from './iterate-find/iterate-find.util.js' export * from './merge-query/merge-query.util.js' export * from './mutate-data/mutate-data.util.js' export * from './mutate-result/mutate-result.util.js' -export * from './pass-params/pass-params.util.js' export * from './patch-batch/patch-batch.util.js' export * from './query-defaults/query-defaults.util.js' export * from './query-has-property/query-has-property.util.js' diff --git a/test/index.test.ts b/test/index.test.ts index 2efa445..f5063d0 100755 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -52,6 +52,7 @@ const utils = [ 'chunkFind', 'contextToJson', 'defineHooks', + 'gateParams', 'getDataIsArray', 'getExposedMethods', 'getPaginate', @@ -60,7 +61,6 @@ const utils = [ 'mergeQuery', 'mutateData', 'mutateResult', - 'passParams', 'patchBatch', 'queryDefaults', 'queryHasProperty',