feathers-utils 10.0.0-rc.9 → 10.0.1
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/guards.mjs +1 -1
- package/dist/guards.mjs.map +1 -1
- package/dist/{hook-context-D16ztLk5.d.mts → hook-context-aHkq1h0N.d.mts} +3 -2
- package/dist/{traverse.hook-C2VIvQrn.mjs → hooks-CzxNpt2c.mjs} +181 -110
- package/dist/hooks-CzxNpt2c.mjs.map +1 -0
- package/dist/hooks.d.mts +84 -24
- package/dist/hooks.mjs +5 -9
- package/dist/{zip-data-result.util-Bjinzz8t.d.mts → index-CNrzxmWo.d.mts} +55 -8
- package/dist/index.d.mts +9 -10
- package/dist/index.mjs +8 -12
- package/dist/index.mjs.map +1 -1
- package/dist/{infer-service-methods-DRcpjEXa.d.mts → infer-service-methods-D7zRVQeJ.d.mts} +2 -2
- package/dist/{internal.utils-C8LH1H55.mjs → internal.utils-BWQ25nOd.mjs} +2 -5
- package/dist/internal.utils-BWQ25nOd.mjs.map +1 -0
- package/dist/{mutate-result.util-BBqz9sPw.d.mts → mutate-result.util-BIeYlqqT.d.mts} +2 -2
- package/dist/{mutate-result.util-C8ZumXWd.mjs → mutate-result.util-CCBWix-G.mjs} +3 -7
- package/dist/{mutate-result.util-C8ZumXWd.mjs.map → mutate-result.util-CCBWix-G.mjs.map} +1 -1
- package/dist/{throw-if.hook-CiuUMtny.mjs → predicates-C2SeOKGd.mjs} +80 -84
- package/dist/predicates-C2SeOKGd.mjs.map +1 -0
- package/dist/predicates.d.mts +18 -42
- package/dist/predicates.mjs +2 -4
- package/dist/{resolve-B-y8cmo6.mjs → resolve-B81gQqXW.mjs} +4 -8
- package/dist/resolve-B81gQqXW.mjs.map +1 -0
- package/dist/{resolve-CsbBZQE9.d.mts → resolve-CA7-EaTw.d.mts} +7 -7
- package/dist/resolvers.d.mts +2 -2
- package/dist/resolvers.mjs +2 -12
- package/dist/resolvers.mjs.map +1 -1
- package/dist/{transform-result.hook-CTPT14PS.d.mts → transform-result.hook-C8-4Lezj.d.mts} +8 -5
- package/dist/{transform-result.hook-BZ55kPq7.mjs → transform-result.hook-DifNj7zf.mjs} +14 -16
- package/dist/transform-result.hook-DifNj7zf.mjs.map +1 -0
- package/dist/transformers.d.mts +3 -3
- package/dist/transformers.mjs +4 -11
- package/dist/transformers.mjs.map +1 -1
- package/dist/{unless.hook-s-Efoy7S.d.mts → unless.hook-CVD7SrZh.d.mts} +10 -7
- package/dist/{zip-data-result.util-CVD17gWe.mjs → utils-ByzrJKGQ.mjs} +25 -42
- package/dist/utils-ByzrJKGQ.mjs.map +1 -0
- package/dist/utils.d.mts +3 -5
- package/dist/utils.mjs +4 -6
- package/package.json +42 -30
- package/src/hooks/cache/cache.hook.ts +9 -7
- package/src/hooks/check-multi/check-multi.hook.ts +15 -14
- package/src/hooks/check-required/check-required.hook.ts +11 -7
- package/src/hooks/create-related/create-related.hook.ts +7 -3
- package/src/hooks/debug/debug.hook.ts +1 -1
- package/src/hooks/disable-pagination/disable-pagination.hook.ts +12 -5
- package/src/hooks/disallow/disallow.hook.ts +8 -3
- package/src/hooks/iff/iff.hook.ts +5 -5
- package/src/hooks/iff-else/iff-else.hook.ts +20 -9
- package/src/hooks/index.ts +1 -0
- package/src/hooks/on-delete/on-delete.hook.ts +7 -3
- package/src/hooks/params-for-server/params-for-server.hook.ts +12 -5
- package/src/hooks/params-from-client/params-from-client.hook.ts +11 -6
- package/src/hooks/rate-limit/rate-limit.hook.ts +58 -0
- package/src/hooks/set-data/set-data.hook.ts +10 -7
- package/src/hooks/set-field/set-field.hook.ts +16 -12
- package/src/hooks/set-result/set-result.hook.ts +9 -3
- package/src/hooks/set-slug/set-slug.hook.ts +8 -6
- package/src/hooks/skippable/skippable.hook.ts +16 -12
- package/src/hooks/soft-delete/soft-delete.hook.ts +5 -6
- package/src/hooks/stashable/stashable.hook.ts +14 -14
- package/src/hooks/throw-if/throw-if.hook.ts +2 -2
- package/src/hooks/transform-data/transform-data.hook.ts +4 -6
- package/src/hooks/transform-query/transform-query.hook.ts +6 -5
- package/src/hooks/transform-result/transform-result.hook.ts +8 -11
- package/src/hooks/traverse/traverse.hook.ts +11 -10
- package/src/internal.utils.ts +1 -0
- package/src/predicates/and/and.predicate.ts +57 -0
- package/src/predicates/index.ts +2 -2
- package/src/predicates/is-context/is-context.predicate.ts +20 -27
- package/src/predicates/or/or.predicate.ts +60 -0
- package/src/resolvers/resolve/resolve.ts +4 -2
- package/src/resolvers/resolve-data/resolve-data.ts +3 -3
- package/src/resolvers/resolve-query/resolve-query.ts +6 -1
- package/src/resolvers/resolve-result/resolve-result.ts +6 -3
- package/src/utils/check-context/check-context.util.ts +89 -8
- package/dist/internal.utils-C8LH1H55.mjs.map +0 -1
- package/dist/resolve-B-y8cmo6.mjs.map +0 -1
- package/dist/throw-if.hook-CiuUMtny.mjs.map +0 -1
- package/dist/transform-result.hook-BZ55kPq7.mjs.map +0 -1
- package/dist/traverse.hook-C2VIvQrn.mjs.map +0 -1
- package/dist/zip-data-result.util-CVD17gWe.mjs.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/guards/has-query/has-query.guard.md +0 -6
- package/src/hooks/.DS_Store +0 -0
- package/src/hooks/cache/cache.hook.md +0 -227
- package/src/hooks/cache/cache.hook.test.ts +0 -944
- package/src/hooks/check-multi/check-multi.hook.md +0 -10
- package/src/hooks/check-multi/check-multi.hook.test.ts +0 -173
- package/src/hooks/check-required/check-required.hook.md +0 -8
- package/src/hooks/check-required/check-required.hook.test.ts +0 -41
- package/src/hooks/create-related/create-related.hook.md +0 -8
- package/src/hooks/create-related/create-related.hook.test.ts +0 -405
- package/src/hooks/debug/debug.hook.md +0 -8
- package/src/hooks/debug/debug.hook.test.ts +0 -25
- package/src/hooks/disable-pagination/disable-pagination.hook.md +0 -8
- package/src/hooks/disable-pagination/disable-pagination.hook.test.ts +0 -61
- package/src/hooks/disallow/disallow.hook.md +0 -9
- package/src/hooks/disallow/disallow.hook.test.ts +0 -159
- package/src/hooks/iff/iff.hook.md +0 -19
- package/src/hooks/iff/iff.hook.test.ts +0 -469
- package/src/hooks/iff-else/iff-else.hook.md +0 -19
- package/src/hooks/iff-else/iff-else.hook.test.ts +0 -219
- package/src/hooks/on-delete/on-delete.hook.md +0 -32
- package/src/hooks/on-delete/on-delete.hook.test.ts +0 -918
- package/src/hooks/params-for-server/params-for-server.hook.md +0 -10
- package/src/hooks/params-for-server/params-for-server.hook.test.ts +0 -68
- package/src/hooks/params-from-client/params-from-client.hook.md +0 -10
- package/src/hooks/params-from-client/params-from-client.hook.test.ts +0 -54
- package/src/hooks/prevent-changes/prevent-changes.hook.md +0 -8
- package/src/hooks/prevent-changes/prevent-changes.hook.test.ts +0 -206
- package/src/hooks/set-data/set-data.hook.md +0 -8
- package/src/hooks/set-data/set-data.hook.test.ts +0 -390
- package/src/hooks/set-field/set-field.hook.md +0 -8
- package/src/hooks/set-field/set-field.hook.test.ts +0 -94
- package/src/hooks/set-result/set-result.hook.md +0 -8
- package/src/hooks/set-result/set-result.hook.test.ts +0 -417
- package/src/hooks/set-slug/set-slug.hook.md +0 -8
- package/src/hooks/set-slug/set-slug.hook.test.ts +0 -57
- package/src/hooks/skippable/skippable.hook.md +0 -20
- package/src/hooks/skippable/skippable.hook.test.ts +0 -124
- package/src/hooks/soft-delete/soft-delete.hook.md +0 -8
- package/src/hooks/soft-delete/soft-delete.hook.test.ts +0 -213
- package/src/hooks/stashable/stashable.hook.md +0 -8
- package/src/hooks/stashable/stashable.hook.test.ts +0 -255
- package/src/hooks/throw-if/throw-if.hook.md +0 -9
- package/src/hooks/throw-if/throw-if.hook.test.ts +0 -27
- package/src/hooks/throw-if-is-multi/throw-if-is-multi.hook.md +0 -10
- package/src/hooks/throw-if-is-multi/throw-if-is-multi.hook.test.ts +0 -148
- package/src/hooks/throw-if-is-provider/throw-if-is-provider.hook.md +0 -10
- package/src/hooks/throw-if-is-provider/throw-if-is-provider.hook.test.ts +0 -39
- package/src/hooks/transform-data/transform-data.hook.md +0 -49
- package/src/hooks/transform-data/transform-data.hook.test-d.ts +0 -104
- package/src/hooks/transform-data/transform-data.hook.test.ts +0 -115
- package/src/hooks/transform-query/transform-query.hook.md +0 -19
- package/src/hooks/transform-query/transform-query.hook.test.ts +0 -30
- package/src/hooks/transform-result/transform-result.hook.md +0 -41
- package/src/hooks/transform-result/transform-result.hook.test-d.ts +0 -104
- package/src/hooks/transform-result/transform-result.hook.test.ts +0 -248
- package/src/hooks/traverse/traverse.hook.md +0 -8
- package/src/hooks/traverse/traverse.hook.test.ts +0 -128
- package/src/hooks/unless/unless.hook.md +0 -13
- package/src/hooks/unless/unless.hook.test.ts +0 -450
- package/src/predicates/.DS_Store +0 -0
- package/src/predicates/every/every.predicate.md +0 -9
- package/src/predicates/every/every.predicate.test.ts +0 -186
- package/src/predicates/every/every.predicate.ts +0 -66
- package/src/predicates/is-context/is-context.predicate.md +0 -4
- package/src/predicates/is-context/is-context.predicate.test.ts +0 -64
- package/src/predicates/is-multi/is-multi.predicate.md +0 -4
- package/src/predicates/is-multi/is-multi.predicate.test.ts +0 -57
- package/src/predicates/is-paginated/is-paginated.predicate.md +0 -6
- package/src/predicates/is-paginated/is-paginated.predicate.test.ts +0 -72
- package/src/predicates/is-provider/is-provider.predicate.md +0 -4
- package/src/predicates/is-provider/is-provider.predicate.test.ts +0 -138
- package/src/predicates/not/not.predicate.md +0 -9
- package/src/predicates/not/not.predicate.test.ts +0 -124
- package/src/predicates/should-skip/should-skip.predicate.md +0 -7
- package/src/predicates/should-skip/should-skip.predicate.test.ts +0 -121
- package/src/predicates/some/some.predicate.md +0 -9
- package/src/predicates/some/some.predicate.test.ts +0 -66
- package/src/predicates/some/some.predicate.ts +0 -69
- package/src/resolvers/from-predicate/from-predicate.md +0 -27
- package/src/resolvers/from-predicate/from-predicate.test-d.ts +0 -33
- package/src/resolvers/from-predicate/from-predicate.test.ts +0 -52
- package/src/resolvers/helpers/defaults/defaults.md +0 -9
- package/src/resolvers/helpers/helpers.test-d.ts +0 -96
- package/src/resolvers/helpers/helpers.test.ts +0 -117
- package/src/resolvers/helpers/lowercase/lowercase.md +0 -9
- package/src/resolvers/helpers/omit/omit.md +0 -9
- package/src/resolvers/helpers/set-now/set-now.md +0 -9
- package/src/resolvers/helpers/trim/trim.md +0 -9
- package/src/resolvers/resolve/resolve.md +0 -19
- package/src/resolvers/resolve/resolve.test-d.ts +0 -63
- package/src/resolvers/resolve/resolve.test.ts +0 -130
- package/src/resolvers/resolve-data/resolve-data.md +0 -17
- package/src/resolvers/resolve-data/resolve-data.test-d.ts +0 -73
- package/src/resolvers/resolve-data/resolve-data.test.ts +0 -420
- package/src/resolvers/resolve-query/resolve-query.md +0 -17
- package/src/resolvers/resolve-query/resolve-query.test-d.ts +0 -50
- package/src/resolvers/resolve-query/resolve-query.test.ts +0 -230
- package/src/resolvers/resolve-result/resolve-result.md +0 -17
- package/src/resolvers/resolve-result/resolve-result.test-d.ts +0 -64
- package/src/resolvers/resolve-result/resolve-result.test.ts +0 -369
- package/src/transformers/defaults/defaults.transformer.md +0 -4
- package/src/transformers/defaults/defaults.transformer.test-d.ts +0 -79
- package/src/transformers/defaults/defaults.transformer.test.ts +0 -58
- package/src/transformers/lowercase/lowercase.transformer.md +0 -4
- package/src/transformers/lowercase/lowercase.transformer.test.ts +0 -40
- package/src/transformers/omit/omit.transformer.md +0 -4
- package/src/transformers/omit/omit.transformer.test.ts +0 -29
- package/src/transformers/parse-date/parse-date.transformer.md +0 -4
- package/src/transformers/parse-date/parse-date.transformer.test.ts +0 -41
- package/src/transformers/pick/pick.transformer.md +0 -4
- package/src/transformers/pick/pick.transformer.test.ts +0 -27
- package/src/transformers/set-now/set-now.transformer.md +0 -4
- package/src/transformers/set-now/set-now.transformer.test.ts +0 -28
- package/src/transformers/trim/trim.transformer.md +0 -4
- package/src/transformers/trim/trim.transformer.test.ts +0 -40
- package/src/utils/.DS_Store +0 -0
- package/src/utils/add-skip/add-skip.util.md +0 -6
- package/src/utils/add-skip/add-skip.util.test.ts +0 -29
- package/src/utils/add-to-query/add-to-query.util.md +0 -4
- package/src/utils/add-to-query/add-to-query.util.test.ts +0 -72
- package/src/utils/check-context/check-context.util.md +0 -4
- package/src/utils/check-context/check-context.util.test.ts +0 -107
- package/src/utils/chunk-find/chunk-find.util.md +0 -6
- package/src/utils/chunk-find/chunk-find.util.test.ts +0 -118
- package/src/utils/combine/combine.util.md +0 -8
- package/src/utils/combine/combine.util.test.ts +0 -158
- package/src/utils/context-to-json/context-to-json.util.md +0 -4
- package/src/utils/define-hooks/define-hooks.util.md +0 -27
- package/src/utils/define-hooks/define-hooks.util.test.ts +0 -27
- package/src/utils/get-data-is-array/get-data-is-array.util.md +0 -4
- package/src/utils/get-data-is-array/get-data-is-array.util.test.ts +0 -63
- package/src/utils/get-exposed-methods/get-exposed-methods.util.md +0 -4
- package/src/utils/get-exposed-methods/get-exposed-methods.util.test.ts +0 -47
- package/src/utils/get-paginate/get-paginate.util.md +0 -4
- package/src/utils/get-paginate/get-paginate.util.test.ts +0 -73
- package/src/utils/get-result-is-array/get-result-is-array.util.md +0 -4
- package/src/utils/get-result-is-array/get-result-is-array.util.test.ts +0 -187
- package/src/utils/iterate-find/iterate-find.util.md +0 -6
- package/src/utils/iterate-find/iterate-find.util.test.ts +0 -122
- package/src/utils/mutate-data/mutate-data.util.md +0 -8
- package/src/utils/mutate-result/mutate-result.util.md +0 -8
- package/src/utils/mutate-result/mutate-result.util.test.ts +0 -175
- package/src/utils/patch-batch/patch-batch.util.md +0 -4
- package/src/utils/patch-batch/patch-batch.util.test.ts +0 -41
- package/src/utils/skip-result/skip-result.util.md +0 -4
- package/src/utils/skip-result/skip-result.util.test.ts +0 -262
- package/src/utils/sort-query-properties/sort-query-properties.util.md +0 -4
- package/src/utils/sort-query-properties/sort-query-properties.util.test.ts +0 -93
- package/src/utils/to-paginated/to-paginated.util.md +0 -4
- package/src/utils/to-paginated/to-paginated.util.test.ts +0 -27
- package/src/utils/transform-params/transform-params.util.md +0 -4
- package/src/utils/walk-query/walk-query.util.md +0 -4
- package/src/utils/walk-query/walk-query.util.test.ts +0 -141
- package/src/utils/zip-data-result/zip-data-result.util.md +0 -4
- package/src/utils/zip-data-result/zip-data-result.util.test.ts +0 -180
package/dist/guards.mjs
CHANGED
package/dist/guards.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.mjs","names":[],"sources":["../src/guards/has-query/has-query.guard.ts"],"sourcesContent":["import type { Params } from '@feathersjs/feathers'\nimport type { RequiredQuery } from '../../utility-types/required-query.js'\n\n/**\n * Type guard to check if the `query` property of `Params` is present and non-nullable.\n *\n * @param params - The `Params` object to check.\n * @returns `true` if `params.query` is present and non-nullable, otherwise `false`.\n *\n * @see https://utils.feathersjs.com/guards/has-query.html\n *\n * @example\n * ```ts\n * import { hasQuery } from 'feathers-utils/guards'\n *\n * function example(params: Params) {\n * // `params.query` is optional and can be undefined at this point\n * if (!hasQuery(params)) {\n * return;\n * }\n *\n * // TypeScript now knows that params.query is present and non-nullable\n * // You can safely access params.query here without additional checks\n * }\n * ```\n */\nexport function hasQuery<P extends Params>(\n params: P,\n): params is RequiredQuery<P> {\n return !!params.query\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,SACd,QAC4B;
|
|
1
|
+
{"version":3,"file":"guards.mjs","names":[],"sources":["../src/guards/has-query/has-query.guard.ts"],"sourcesContent":["import type { Params } from '@feathersjs/feathers'\nimport type { RequiredQuery } from '../../utility-types/required-query.js'\n\n/**\n * Type guard to check if the `query` property of `Params` is present and non-nullable.\n *\n * @param params - The `Params` object to check.\n * @returns `true` if `params.query` is present and non-nullable, otherwise `false`.\n *\n * @see https://utils.feathersjs.com/guards/has-query.html\n *\n * @example\n * ```ts\n * import { hasQuery } from 'feathers-utils/guards'\n *\n * function example(params: Params) {\n * // `params.query` is optional and can be undefined at this point\n * if (!hasQuery(params)) {\n * return;\n * }\n *\n * // TypeScript now knows that params.query is present and non-nullable\n * // You can safely access params.query here without additional checks\n * }\n * ```\n */\nexport function hasQuery<P extends Params>(\n params: P,\n): params is RequiredQuery<P> {\n return !!params.query\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,SACd,QAC4B;CAC5B,OAAO,CAAC,CAAC,OAAO"}
|
|
@@ -2,6 +2,7 @@ import { HookContext, NextFunction, Paginated, Params } from "@feathersjs/feathe
|
|
|
2
2
|
|
|
3
3
|
//#region src/internal.utils.d.ts
|
|
4
4
|
type MaybeArray<T> = T | readonly T[];
|
|
5
|
+
type UnpackMaybeArray<T> = T extends readonly (infer E)[] ? E : T;
|
|
5
6
|
type Promisable<T> = T | Promise<T>;
|
|
6
7
|
type KeyOf<T> = Extract<keyof T, string>;
|
|
7
8
|
type UnwrapArray<T> = T extends Array<infer U> ? U : T;
|
|
@@ -46,5 +47,5 @@ type UnwrapPaginatedOrArray<T> = T extends Paginated<infer D> ? D : T extends an
|
|
|
46
47
|
type ResultSingleHookContext<H extends HookContext> = UnwrapPaginatedOrArray<NonNullable<H['result']>>;
|
|
47
48
|
type DataSingleHookContext<H extends HookContext> = UnwrapArray<NonNullable<H['data']>>;
|
|
48
49
|
//#endregion
|
|
49
|
-
export { Promisable as A, hookTypes as C, KeyOfOrDotNotation as D, KeyOf as E, MaybeArray as O, TransportName as S, AnyFallback as T, PredicateItemWithContext as _, ContextFunction as a, TransformerFn as b, DefaultsInput as c, HookFunction as d, HookType$1 as f, PredicateFn as g, PredicateContextSync as h, UnwrapPaginatedOrArray as i,
|
|
50
|
-
//# sourceMappingURL=hook-context-
|
|
50
|
+
export { Promisable as A, hookTypes as C, KeyOfOrDotNotation as D, KeyOf as E, UnwrapArray as M, MaybeArray as O, TransportName as S, AnyFallback as T, PredicateItemWithContext as _, ContextFunction as a, TransformerFn as b, DefaultsInput as c, HookFunction as d, HookType$1 as f, PredicateFn as g, PredicateContextSync as h, UnwrapPaginatedOrArray as i, UnpackMaybeArray as j, NeverFallback as k, DispatchOption as l, PredicateContextAsync as m, ResultSingleHookContext as n, ContextFunctionAsync as o, MethodName as p, UnwrapPaginated as r, ContextFunctionSync as s, DataSingleHookContext as t, FieldKey as u, StringFieldKey as v, methodNames as w, TransformerInputFn as x, TransformParamsFn as y };
|
|
51
|
+
//# sourceMappingURL=hook-context-aHkq1h0N.d.mts.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as checkContext, f as addToQuery, h as sortQueryProperties, r as transformParams, u as contextToJson } from "./
|
|
3
|
-
import { a as traverse$1, i as isPromise, r as toArray, t as early } from "./internal.utils-
|
|
4
|
-
import { i as getDataIsArray, r as getResultIsArray } from "./mutate-result.util-
|
|
5
|
-
import { r as transformData } from "./transform-result.hook-
|
|
1
|
+
import { g as every, p as isMulti, t as throwIf, u as isProvider } from "./predicates-C2SeOKGd.mjs";
|
|
2
|
+
import { d as checkContext, f as addToQuery, h as sortQueryProperties, r as transformParams, u as contextToJson } from "./utils-ByzrJKGQ.mjs";
|
|
3
|
+
import { a as traverse$1, i as isPromise, r as toArray, t as early } from "./internal.utils-BWQ25nOd.mjs";
|
|
4
|
+
import { i as getDataIsArray, r as getResultIsArray } from "./mutate-result.util-CCBWix-G.mjs";
|
|
5
|
+
import { r as transformData } from "./transform-result.hook-DifNj7zf.mjs";
|
|
6
|
+
import "./resolve-B81gQqXW.mjs";
|
|
6
7
|
import isObject from "lodash/isObject.js";
|
|
7
8
|
import { copy } from "fast-copy";
|
|
8
|
-
import { BadRequest, Forbidden, MethodNotAllowed } from "@feathersjs/errors";
|
|
9
|
+
import { BadRequest, Forbidden, MethodNotAllowed, TooManyRequests } from "@feathersjs/errors";
|
|
9
10
|
import _get from "lodash/get.js";
|
|
10
11
|
import _has from "lodash/has.js";
|
|
11
12
|
import _omit from "lodash/omit.js";
|
|
12
13
|
import _set from "lodash/set.js";
|
|
13
14
|
import _setWith from "lodash/setWith.js";
|
|
14
15
|
import _clone from "lodash/clone.js";
|
|
15
|
-
|
|
16
16
|
//#region src/hooks/cache/cache-utils.ts
|
|
17
17
|
const stableStringify = (obj) => {
|
|
18
18
|
if (obj.query) obj = {
|
|
@@ -28,7 +28,6 @@ const stableStringify = (obj) => {
|
|
|
28
28
|
return value;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
|
|
32
31
|
//#endregion
|
|
33
32
|
//#region src/hooks/cache/cache.hook.ts
|
|
34
33
|
/**
|
|
@@ -69,12 +68,10 @@ const cacheBefore = async (context, cacheMap) => {
|
|
|
69
68
|
const value = await cacheMap.get(context);
|
|
70
69
|
if (value) context.result = value;
|
|
71
70
|
}
|
|
72
|
-
return context;
|
|
73
71
|
};
|
|
74
72
|
const cacheAfter = async (context, cacheMap) => {
|
|
75
73
|
if (context.method === "get" || context.method === "find") await cacheMap.set(context);
|
|
76
74
|
else await cacheMap.clear(context);
|
|
77
|
-
return context;
|
|
78
75
|
};
|
|
79
76
|
var ContextCacheMap = class {
|
|
80
77
|
map;
|
|
@@ -175,7 +172,6 @@ var ContextCacheMap = class {
|
|
|
175
172
|
return context;
|
|
176
173
|
}
|
|
177
174
|
};
|
|
178
|
-
|
|
179
175
|
//#endregion
|
|
180
176
|
//#region src/hooks/check-multi/check-multi.hook.ts
|
|
181
177
|
/**
|
|
@@ -195,15 +191,16 @@ var ContextCacheMap = class {
|
|
|
195
191
|
* @see https://utils.feathersjs.com/hooks/check-multi.html
|
|
196
192
|
*/
|
|
197
193
|
function checkMulti(options) {
|
|
198
|
-
|
|
194
|
+
function hook(context, next) {
|
|
199
195
|
const { service, method } = context;
|
|
200
|
-
if (!service.allowsMulti || !isMulti(context) || method === "find")
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
if (!service.allowsMulti || !isMulti(context) || method === "find" || service.allowsMulti(method)) {
|
|
197
|
+
if (next) return next();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
throw options?.error ? options.error(context) : new MethodNotAllowed(`Can not ${method} multiple entries`);
|
|
201
|
+
}
|
|
202
|
+
return hook;
|
|
205
203
|
}
|
|
206
|
-
|
|
207
204
|
//#endregion
|
|
208
205
|
//#region src/hooks/check-required/check-required.hook.ts
|
|
209
206
|
/**
|
|
@@ -224,12 +221,16 @@ function checkMulti(options) {
|
|
|
224
221
|
*/
|
|
225
222
|
function checkRequired(fieldNames) {
|
|
226
223
|
const fieldNamesArray = toArray(fieldNames);
|
|
227
|
-
|
|
228
|
-
checkContext(context,
|
|
229
|
-
"
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
function hook(context, next) {
|
|
225
|
+
checkContext(context, {
|
|
226
|
+
type: ["before", "around"],
|
|
227
|
+
method: [
|
|
228
|
+
"create",
|
|
229
|
+
"update",
|
|
230
|
+
"patch"
|
|
231
|
+
],
|
|
232
|
+
label: "checkRequired"
|
|
233
|
+
});
|
|
233
234
|
const { data } = getDataIsArray(context);
|
|
234
235
|
for (let i = 0; i < data.length; i++) {
|
|
235
236
|
const item = data[i];
|
|
@@ -241,9 +242,9 @@ function checkRequired(fieldNames) {
|
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
if (next) return next();
|
|
244
|
-
}
|
|
245
|
+
}
|
|
246
|
+
return hook;
|
|
245
247
|
}
|
|
246
|
-
|
|
247
248
|
//#endregion
|
|
248
249
|
//#region src/hooks/create-related/create-related.hook.ts
|
|
249
250
|
/**
|
|
@@ -266,20 +267,23 @@ function checkRequired(fieldNames) {
|
|
|
266
267
|
*/
|
|
267
268
|
function createRelated(options) {
|
|
268
269
|
return async (context, next) => {
|
|
269
|
-
checkContext(context,
|
|
270
|
+
checkContext(context, {
|
|
271
|
+
type: ["after", "around"],
|
|
272
|
+
method: ["create"],
|
|
273
|
+
label: "createRelated"
|
|
274
|
+
});
|
|
270
275
|
if (next) await next();
|
|
271
276
|
const { result } = getResultIsArray(context);
|
|
272
277
|
const entries = Array.isArray(options) ? options : [options];
|
|
273
278
|
await Promise.all(entries.map(async (entry) => {
|
|
274
279
|
const { data, service, multi } = entry;
|
|
275
280
|
const dataToCreate = (await Promise.all(result.map(async (item) => data(item, context)))).flat().filter((x) => !!x);
|
|
276
|
-
if (!dataToCreate || dataToCreate.length <= 0) return
|
|
281
|
+
if (!dataToCreate || dataToCreate.length <= 0) return;
|
|
277
282
|
if (multi || dataToCreate.length === 1) await context.app.service(service).create(dataToCreate.length === 1 ? dataToCreate[0] : dataToCreate);
|
|
278
283
|
else await Promise.all(dataToCreate.map(async (item) => context.app.service(service).create(item)));
|
|
279
284
|
}));
|
|
280
285
|
};
|
|
281
286
|
}
|
|
282
|
-
|
|
283
287
|
//#endregion
|
|
284
288
|
//#region src/hooks/debug/debug.hook.ts
|
|
285
289
|
/**
|
|
@@ -315,7 +319,6 @@ const debug = (msg, ...fieldNames) => async (context, next) => {
|
|
|
315
319
|
});
|
|
316
320
|
if (context.error) console.log("error", context.error);
|
|
317
321
|
};
|
|
318
|
-
|
|
319
322
|
//#endregion
|
|
320
323
|
//#region src/hooks/disable-pagination/disable-pagination.hook.ts
|
|
321
324
|
/**
|
|
@@ -335,17 +338,22 @@ const debug = (msg, ...fieldNames) => async (context, next) => {
|
|
|
335
338
|
*
|
|
336
339
|
* @see https://utils.feathersjs.com/hooks/disable-pagination.html
|
|
337
340
|
*/
|
|
338
|
-
const disablePagination = () =>
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
const disablePagination = () => {
|
|
342
|
+
function hook(context, next) {
|
|
343
|
+
checkContext(context, {
|
|
344
|
+
type: ["before", "around"],
|
|
345
|
+
method: ["find"],
|
|
346
|
+
label: "disablePagination"
|
|
347
|
+
});
|
|
348
|
+
const $limit = context.params?.query?.$limit;
|
|
349
|
+
if ($limit === "-1" || $limit === -1) {
|
|
350
|
+
context.params.paginate = false;
|
|
351
|
+
delete context.params.query.$limit;
|
|
352
|
+
}
|
|
353
|
+
if (next) return next();
|
|
344
354
|
}
|
|
345
|
-
|
|
346
|
-
return context;
|
|
355
|
+
return hook;
|
|
347
356
|
};
|
|
348
|
-
|
|
349
357
|
//#endregion
|
|
350
358
|
//#region src/hooks/disallow/disallow.hook.ts
|
|
351
359
|
/**
|
|
@@ -369,19 +377,23 @@ const disablePagination = () => (context, next) => {
|
|
|
369
377
|
*/
|
|
370
378
|
const disallow = (transports) => {
|
|
371
379
|
const transportsArr = toArray(transports);
|
|
372
|
-
|
|
380
|
+
function hook(context, next) {
|
|
373
381
|
if (!transports) throw new MethodNotAllowed("Method not allowed");
|
|
374
|
-
if (isProvider(...transportsArr)(context)) throw new MethodNotAllowed(`Provider '${context.params.provider}' can not call '${context.method}'. (disallow)`);
|
|
375
|
-
if (next) return next()
|
|
376
|
-
}
|
|
382
|
+
if (isProvider(...transportsArr)(context)) throw new MethodNotAllowed(`Provider '${context.params.provider}' can not call '${context.method}' on '${context.path}'. (disallow)`);
|
|
383
|
+
if (next) return next();
|
|
384
|
+
}
|
|
385
|
+
return hook;
|
|
377
386
|
};
|
|
378
|
-
|
|
379
387
|
//#endregion
|
|
380
388
|
//#region src/hooks/on-delete/on-delete.hook.ts
|
|
381
389
|
const onDelete = (options) => {
|
|
382
390
|
const optionsMulti = Array.isArray(options) ? options : [options];
|
|
383
391
|
return async (context, next) => {
|
|
384
|
-
checkContext(context,
|
|
392
|
+
checkContext(context, {
|
|
393
|
+
type: ["after", "around"],
|
|
394
|
+
method: "remove",
|
|
395
|
+
label: "onDelete"
|
|
396
|
+
});
|
|
385
397
|
if (next) await next();
|
|
386
398
|
const { result } = getResultIsArray(context);
|
|
387
399
|
if (!result.length) return;
|
|
@@ -389,7 +401,7 @@ const onDelete = (options) => {
|
|
|
389
401
|
optionsMulti.forEach(async ({ keyHere, keyThere, onDelete, service, blocking, query }) => {
|
|
390
402
|
let ids = result.map((x) => x[keyHere]).filter((x) => !!x);
|
|
391
403
|
ids = [...new Set(ids)];
|
|
392
|
-
if (!ids || ids.length <= 0) return
|
|
404
|
+
if (!ids || ids.length <= 0) return;
|
|
393
405
|
const params = {
|
|
394
406
|
query: {
|
|
395
407
|
...query,
|
|
@@ -408,11 +420,9 @@ const onDelete = (options) => {
|
|
|
408
420
|
if (promises.length) await Promise.all(promises);
|
|
409
421
|
};
|
|
410
422
|
};
|
|
411
|
-
|
|
412
423
|
//#endregion
|
|
413
424
|
//#region src/hooks/params-for-server/params-for-from-shared.ts
|
|
414
425
|
const FROM_CLIENT_FOR_SERVER_DEFAULT_KEY = "_$client";
|
|
415
|
-
|
|
416
426
|
//#endregion
|
|
417
427
|
//#region src/hooks/params-for-server/params-for-server.hook.ts
|
|
418
428
|
/**
|
|
@@ -435,7 +445,7 @@ const FROM_CLIENT_FOR_SERVER_DEFAULT_KEY = "_$client";
|
|
|
435
445
|
const paramsForServer = (whitelist, options) => {
|
|
436
446
|
const whitelistArr = toArray(whitelist);
|
|
437
447
|
const { keyToHide = FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } = options || {};
|
|
438
|
-
|
|
448
|
+
function hook(context, next) {
|
|
439
449
|
let clonedParams;
|
|
440
450
|
Object.keys(context.params).forEach((key) => {
|
|
441
451
|
if (key === "query") return;
|
|
@@ -451,10 +461,9 @@ const paramsForServer = (whitelist, options) => {
|
|
|
451
461
|
});
|
|
452
462
|
if (clonedParams) context.params = clonedParams;
|
|
453
463
|
if (next) return next();
|
|
454
|
-
|
|
455
|
-
|
|
464
|
+
}
|
|
465
|
+
return hook;
|
|
456
466
|
};
|
|
457
|
-
|
|
458
467
|
//#endregion
|
|
459
468
|
//#region src/hooks/params-from-client/params-from-client.hook.ts
|
|
460
469
|
/**
|
|
@@ -477,8 +486,11 @@ const paramsForServer = (whitelist, options) => {
|
|
|
477
486
|
const paramsFromClient = (whitelist, options) => {
|
|
478
487
|
const whitelistArr = toArray(whitelist);
|
|
479
488
|
const { keyToHide = FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } = options || {};
|
|
480
|
-
|
|
481
|
-
if (!context.params?.query?.[keyToHide] || typeof context.params.query[keyToHide] !== "object")
|
|
489
|
+
function hook(context, next) {
|
|
490
|
+
if (!context.params?.query?.[keyToHide] || typeof context.params.query[keyToHide] !== "object") {
|
|
491
|
+
if (next) return next();
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
482
494
|
const params = {
|
|
483
495
|
...context.params,
|
|
484
496
|
query: {
|
|
@@ -496,10 +508,9 @@ const paramsFromClient = (whitelist, options) => {
|
|
|
496
508
|
if (Object.keys(client).length === 0) delete params.query[keyToHide];
|
|
497
509
|
context.params = params;
|
|
498
510
|
if (next) return next();
|
|
499
|
-
|
|
500
|
-
|
|
511
|
+
}
|
|
512
|
+
return hook;
|
|
501
513
|
};
|
|
502
|
-
|
|
503
514
|
//#endregion
|
|
504
515
|
//#region src/hooks/prevent-changes/prevent-changes.hook.ts
|
|
505
516
|
/**
|
|
@@ -531,7 +542,47 @@ const preventChanges = (fieldNames, options) => {
|
|
|
531
542
|
return item;
|
|
532
543
|
});
|
|
533
544
|
};
|
|
534
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/hooks/rate-limit/rate-limit.hook.ts
|
|
547
|
+
/**
|
|
548
|
+
* Rate limits service method calls using `rate-limiter-flexible`.
|
|
549
|
+
* You provide a pre-configured `RateLimiterAbstract` instance
|
|
550
|
+
* (Memory, Redis, Mongo, etc.) and the hook consumes points per request.
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```ts
|
|
554
|
+
* import { rateLimit } from 'feathers-utils/hooks'
|
|
555
|
+
* import { RateLimiterMemory } from 'rate-limiter-flexible'
|
|
556
|
+
*
|
|
557
|
+
* const rateLimiter = new RateLimiterMemory({ points: 10, duration: 1 })
|
|
558
|
+
*
|
|
559
|
+
* app.service('users').hooks({
|
|
560
|
+
* before: { find: [rateLimit(rateLimiter)] }
|
|
561
|
+
* })
|
|
562
|
+
* ```
|
|
563
|
+
*
|
|
564
|
+
* @see https://utils.feathersjs.com/hooks/rate-limit.html
|
|
565
|
+
*/
|
|
566
|
+
const rateLimit = (rateLimiter, options) => {
|
|
567
|
+
const key = options?.key ?? ((context) => context.path);
|
|
568
|
+
const points = options?.points ?? (() => 1);
|
|
569
|
+
return async (context, next) => {
|
|
570
|
+
checkContext(context, {
|
|
571
|
+
type: ["before", "around"],
|
|
572
|
+
label: "rateLimit"
|
|
573
|
+
});
|
|
574
|
+
const resolvedKey = await key(context);
|
|
575
|
+
const resolvedPoints = await points(context);
|
|
576
|
+
try {
|
|
577
|
+
const res = await rateLimiter.consume(resolvedKey, resolvedPoints);
|
|
578
|
+
context.params.rateLimit = res;
|
|
579
|
+
} catch (res) {
|
|
580
|
+
context.params.rateLimit = res;
|
|
581
|
+
throw new TooManyRequests("Too many requests", { rateLimitRes: res });
|
|
582
|
+
}
|
|
583
|
+
if (next) await next();
|
|
584
|
+
};
|
|
585
|
+
};
|
|
535
586
|
//#endregion
|
|
536
587
|
//#region src/hooks/set-data/set-data.hook.ts
|
|
537
588
|
/**
|
|
@@ -552,12 +603,18 @@ const preventChanges = (fieldNames, options) => {
|
|
|
552
603
|
*/
|
|
553
604
|
function setData(from, to, options) {
|
|
554
605
|
const { allowUndefined = false, overwrite = true } = options ?? {};
|
|
555
|
-
|
|
606
|
+
function hook(context, next) {
|
|
556
607
|
const { data } = getDataIsArray(context);
|
|
557
608
|
const contextJson = contextToJson(context);
|
|
558
609
|
if (!_has(contextJson, from)) {
|
|
559
|
-
if (!context.params?.provider || allowUndefined === true)
|
|
560
|
-
|
|
610
|
+
if (!context.params?.provider || allowUndefined === true) {
|
|
611
|
+
if (next) return next();
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if (!overwrite && data.every((item) => _has(item, to))) {
|
|
615
|
+
if (next) return next();
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
561
618
|
throw options?.error ? options.error(context, from) : new Forbidden(`Expected field ${from.toString()} not available`);
|
|
562
619
|
}
|
|
563
620
|
const val = _get(contextJson, from);
|
|
@@ -567,10 +624,9 @@ function setData(from, to, options) {
|
|
|
567
624
|
_set(item, to, val);
|
|
568
625
|
}
|
|
569
626
|
if (next) return next();
|
|
570
|
-
|
|
571
|
-
|
|
627
|
+
}
|
|
628
|
+
return hook;
|
|
572
629
|
}
|
|
573
|
-
|
|
574
630
|
//#endregion
|
|
575
631
|
//#region src/hooks/set-field/set-field.hook.ts
|
|
576
632
|
/**
|
|
@@ -589,19 +645,26 @@ function setData(from, to, options) {
|
|
|
589
645
|
*
|
|
590
646
|
* @see https://utils.feathersjs.com/hooks/set-field.html
|
|
591
647
|
*/
|
|
592
|
-
const setField = ({ as, from, allowUndefined = false, error }) =>
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
648
|
+
const setField = ({ as, from, allowUndefined = false, error }) => {
|
|
649
|
+
function hook(context, next) {
|
|
650
|
+
const { params } = context;
|
|
651
|
+
checkContext(context, {
|
|
652
|
+
type: ["before", "around"],
|
|
653
|
+
label: "setField"
|
|
654
|
+
});
|
|
655
|
+
const value = _get(context, from);
|
|
656
|
+
if (value === void 0) {
|
|
657
|
+
if (!params.provider || allowUndefined) {
|
|
658
|
+
if (next) return next();
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
throw error ? error(context, from) : new Forbidden(`Expected field ${as} not available`);
|
|
662
|
+
}
|
|
663
|
+
_setWith(context, as, value, _clone);
|
|
664
|
+
if (next) return next();
|
|
599
665
|
}
|
|
600
|
-
|
|
601
|
-
if (next) return next();
|
|
602
|
-
return context;
|
|
666
|
+
return hook;
|
|
603
667
|
};
|
|
604
|
-
|
|
605
668
|
//#endregion
|
|
606
669
|
//#region src/hooks/set-result/set-result.hook.ts
|
|
607
670
|
/**
|
|
@@ -645,12 +708,14 @@ function setResult(from, to, options) {
|
|
|
645
708
|
}
|
|
646
709
|
return forResultOrDispatch(context, !!options?.dispatch);
|
|
647
710
|
};
|
|
648
|
-
|
|
649
|
-
if (next) next().then(() =>
|
|
650
|
-
|
|
651
|
-
|
|
711
|
+
function hook(context, next) {
|
|
712
|
+
if (next) return next().then(() => {
|
|
713
|
+
fn(context);
|
|
714
|
+
});
|
|
715
|
+
fn(context);
|
|
716
|
+
}
|
|
717
|
+
return hook;
|
|
652
718
|
}
|
|
653
|
-
|
|
654
719
|
//#endregion
|
|
655
720
|
//#region src/hooks/set-slug/set-slug.hook.ts
|
|
656
721
|
/**
|
|
@@ -670,17 +735,16 @@ function setResult(from, to, options) {
|
|
|
670
735
|
* @see https://utils.feathersjs.com/hooks/set-slug.html
|
|
671
736
|
*/
|
|
672
737
|
const setSlug = (slug, fieldName) => {
|
|
673
|
-
|
|
674
|
-
|
|
738
|
+
const targetField = typeof fieldName === "string" ? fieldName : `query.${slug}`;
|
|
739
|
+
function hook(context, next) {
|
|
675
740
|
if (context.params && context.params.provider === "rest") {
|
|
676
741
|
const value = context.params.route[slug];
|
|
677
|
-
if (typeof value === "string" && value[0] !== ":") _set(context.params,
|
|
742
|
+
if (typeof value === "string" && value[0] !== ":") _set(context.params, targetField, value);
|
|
678
743
|
}
|
|
679
744
|
if (next) return next();
|
|
680
|
-
|
|
681
|
-
|
|
745
|
+
}
|
|
746
|
+
return hook;
|
|
682
747
|
};
|
|
683
|
-
|
|
684
748
|
//#endregion
|
|
685
749
|
//#region src/hooks/soft-delete/soft-delete.hook.ts
|
|
686
750
|
/**
|
|
@@ -704,9 +768,15 @@ const setSlug = (slug, fieldName) => {
|
|
|
704
768
|
const softDelete = (options) => {
|
|
705
769
|
if (!options?.deletedQuery || !options?.removeData) throw new Error("You must provide `deletedQuery` and `removeData` options to the softDelete hook.");
|
|
706
770
|
return async (context, next) => {
|
|
707
|
-
checkContext(context,
|
|
771
|
+
checkContext(context, {
|
|
772
|
+
type: ["before", "around"],
|
|
773
|
+
label: "softDelete"
|
|
774
|
+
});
|
|
708
775
|
const { disableSoftDeleteKey = "disableSoftDelete" } = options;
|
|
709
|
-
if (context.params[disableSoftDeleteKey])
|
|
776
|
+
if (context.params[disableSoftDeleteKey]) {
|
|
777
|
+
await early(context, next);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
710
780
|
const { deletedQuery, removeData } = options;
|
|
711
781
|
let deleteQuery = getValue(deletedQuery, context);
|
|
712
782
|
if (isPromise(deleteQuery)) deleteQuery = await deleteQuery;
|
|
@@ -722,15 +792,13 @@ const softDelete = (options) => {
|
|
|
722
792
|
const method = options.usePatchWithHooks ? "patch" : "_patch";
|
|
723
793
|
context.result = await context.service[method](context.id, data, params);
|
|
724
794
|
}
|
|
725
|
-
if (next)
|
|
726
|
-
return context;
|
|
795
|
+
if (next) await next();
|
|
727
796
|
};
|
|
728
797
|
};
|
|
729
798
|
const getValue = (value, ...args) => {
|
|
730
799
|
if (typeof value === "function") return value(...args);
|
|
731
800
|
return value;
|
|
732
801
|
};
|
|
733
|
-
|
|
734
802
|
//#endregion
|
|
735
803
|
//#region src/hooks/stashable/stashable.hook.ts
|
|
736
804
|
const defaultStashFunc = (context) => {
|
|
@@ -765,23 +833,26 @@ const defaultStashFunc = (context) => {
|
|
|
765
833
|
function stashable(options) {
|
|
766
834
|
const propName = options?.propName ?? "stashed";
|
|
767
835
|
const stashFunc = options?.stashFunc ?? defaultStashFunc;
|
|
768
|
-
|
|
836
|
+
function hook(context, next) {
|
|
769
837
|
if (context.params._stashable) {
|
|
770
838
|
if (next) return next();
|
|
771
|
-
return
|
|
839
|
+
return;
|
|
772
840
|
}
|
|
773
|
-
checkContext(context,
|
|
774
|
-
"
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
841
|
+
checkContext(context, {
|
|
842
|
+
type: ["before", "around"],
|
|
843
|
+
method: [
|
|
844
|
+
"update",
|
|
845
|
+
"patch",
|
|
846
|
+
"remove"
|
|
847
|
+
],
|
|
848
|
+
label: "stashable"
|
|
849
|
+
});
|
|
778
850
|
const promise = stashFunc(context).catch(() => void 0);
|
|
779
851
|
context.params[propName] = () => promise;
|
|
780
852
|
if (next) return next();
|
|
781
|
-
|
|
782
|
-
|
|
853
|
+
}
|
|
854
|
+
return hook;
|
|
783
855
|
}
|
|
784
|
-
|
|
785
856
|
//#endregion
|
|
786
857
|
//#region src/hooks/throw-if-is-multi/throw-if-is-multi.hook.ts
|
|
787
858
|
const defaultError$1 = (context) => new BadRequest(`Cannot perform multi operation on method '${context.method}'`);
|
|
@@ -802,7 +873,6 @@ const defaultError$1 = (context) => new BadRequest(`Cannot perform multi operati
|
|
|
802
873
|
* @see https://utils.feathersjs.com/hooks/throw-if-is-multi.html
|
|
803
874
|
*/
|
|
804
875
|
const throwIfIsMulti = (options) => throwIf(every(every(isMulti, (context) => context.method !== "find"), options?.filter), { error: options?.error ?? defaultError$1 });
|
|
805
|
-
|
|
806
876
|
//#endregion
|
|
807
877
|
//#region src/hooks/throw-if-is-provider/throw-if-is-provider.hook.ts
|
|
808
878
|
const defaultError = (context) => new MethodNotAllowed(`Provider '${context.params.provider}' can not call '${context.method}'.`);
|
|
@@ -825,7 +895,6 @@ const defaultError = (context) => new MethodNotAllowed(`Provider '${context.para
|
|
|
825
895
|
const throwIfIsProvider = (transports, options) => {
|
|
826
896
|
return throwIf(every(isProvider(...toArray(transports)), options?.filter), { error: options?.error ?? defaultError });
|
|
827
897
|
};
|
|
828
|
-
|
|
829
898
|
//#endregion
|
|
830
899
|
//#region src/hooks/traverse/traverse.hook.ts
|
|
831
900
|
/**
|
|
@@ -846,12 +915,14 @@ const throwIfIsProvider = (transports, options) => {
|
|
|
846
915
|
*
|
|
847
916
|
* @see https://utils.feathersjs.com/hooks/traverse.html
|
|
848
917
|
*/
|
|
849
|
-
const traverse = ({ transformer, getObject }) =>
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
918
|
+
const traverse = ({ transformer, getObject }) => {
|
|
919
|
+
function hook(context, next) {
|
|
920
|
+
traverse$1(getObject(context), transformer);
|
|
921
|
+
if (next) return next();
|
|
922
|
+
}
|
|
923
|
+
return hook;
|
|
853
924
|
};
|
|
854
|
-
|
|
855
925
|
//#endregion
|
|
856
|
-
export {
|
|
857
|
-
|
|
926
|
+
export { debug as _, softDelete as a, checkMulti as b, setField as c, preventChanges as d, paramsFromClient as f, disablePagination as g, disallow as h, stashable as i, setData as l, onDelete as m, throwIfIsProvider as n, setSlug as o, paramsForServer as p, throwIfIsMulti as r, setResult as s, traverse as t, rateLimit as u, createRelated as v, cache as x, checkRequired as y };
|
|
927
|
+
|
|
928
|
+
//# sourceMappingURL=hooks-CzxNpt2c.mjs.map
|