feathers-utils 10.0.0 → 10.0.2

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.
Files changed (80) hide show
  1. package/dist/{hooks-DPFxxjBu.mjs → hooks-yFJ5FmU5.mjs} +115 -99
  2. package/dist/hooks-yFJ5FmU5.mjs.map +1 -0
  3. package/dist/hooks.d.mts +98 -29
  4. package/dist/hooks.mjs +4 -4
  5. package/dist/{index-CNrzxmWo.d.mts → index-CgAuzxiv.d.mts} +49 -4
  6. package/dist/index.d.mts +4 -4
  7. package/dist/index.mjs +7 -7
  8. package/dist/{internal.utils-BWQ25nOd.mjs → internal.utils-3BrB8lRY.mjs} +8 -2
  9. package/dist/internal.utils-3BrB8lRY.mjs.map +1 -0
  10. package/dist/{mutate-result.util-CCBWix-G.mjs → mutate-result.util-B6FOkwrd.mjs} +73 -11
  11. package/dist/mutate-result.util-B6FOkwrd.mjs.map +1 -0
  12. package/dist/{predicates-CT08opkD.mjs → predicates-BC8p_YLo.mjs} +27 -24
  13. package/dist/predicates-BC8p_YLo.mjs.map +1 -0
  14. package/dist/predicates.d.mts +2 -2
  15. package/dist/predicates.mjs +1 -1
  16. package/dist/{resolve-Cx9osy8O.mjs → resolve-ClHfNFlm.mjs} +3 -3
  17. package/dist/resolve-ClHfNFlm.mjs.map +1 -0
  18. package/dist/resolvers.mjs +1 -1
  19. package/dist/{transform-result.hook-BUwLePT2.d.mts → transform-result.hook-C8-4Lezj.d.mts} +8 -5
  20. package/dist/{transform-result.hook-CevWK5TA.mjs → transform-result.hook-CanJtTPV.mjs} +13 -12
  21. package/dist/transform-result.hook-CanJtTPV.mjs.map +1 -0
  22. package/dist/transformers.d.mts +1 -1
  23. package/dist/transformers.mjs +8 -4
  24. package/dist/transformers.mjs.map +1 -1
  25. package/dist/{unless.hook-BYWO9hzO.d.mts → unless.hook-BX0mOvdN.d.mts} +6 -3
  26. package/dist/{utils-1I_iPZkV.mjs → utils-BrvpblXB.mjs} +38 -19
  27. package/dist/utils-BrvpblXB.mjs.map +1 -0
  28. package/dist/utils.d.mts +2 -2
  29. package/dist/utils.mjs +4 -4
  30. package/package.json +1 -1
  31. package/src/common/clone.ts +9 -7
  32. package/src/hooks/cache/cache-utils.ts +5 -18
  33. package/src/hooks/cache/cache.hook.ts +37 -16
  34. package/src/hooks/check-multi/check-multi.hook.ts +5 -2
  35. package/src/hooks/check-required/check-required.hook.ts +6 -1
  36. package/src/hooks/create-related/create-related.hook.ts +2 -2
  37. package/src/hooks/debug/debug.hook.ts +1 -1
  38. package/src/hooks/disable-pagination/disable-pagination.hook.ts +7 -4
  39. package/src/hooks/disallow/disallow.hook.ts +10 -3
  40. package/src/hooks/on-delete/on-delete.hook.ts +61 -41
  41. package/src/hooks/params-for-server/params-for-server.hook.ts +16 -5
  42. package/src/hooks/params-from-client/params-from-client.hook.ts +10 -6
  43. package/src/hooks/rate-limit/rate-limit.hook.ts +2 -2
  44. package/src/hooks/set-data/set-data.hook.ts +8 -7
  45. package/src/hooks/set-field/set-field.hook.ts +42 -17
  46. package/src/hooks/set-result/set-result.hook.ts +16 -3
  47. package/src/hooks/set-slug/set-slug.hook.ts +8 -6
  48. package/src/hooks/skippable/skippable.hook.ts +17 -12
  49. package/src/hooks/soft-delete/soft-delete.hook.ts +4 -5
  50. package/src/hooks/stashable/stashable.hook.ts +9 -8
  51. package/src/hooks/throw-if/throw-if.hook.ts +2 -2
  52. package/src/hooks/transform-data/transform-data.hook.ts +2 -4
  53. package/src/hooks/transform-query/transform-query.hook.ts +6 -5
  54. package/src/hooks/transform-result/transform-result.hook.ts +6 -9
  55. package/src/hooks/traverse/traverse.hook.ts +30 -10
  56. package/src/internal.utils.ts +6 -1
  57. package/src/predicates/and/and.predicate.ts +5 -5
  58. package/src/predicates/is-context/is-context.predicate.ts +1 -1
  59. package/src/predicates/or/or.predicate.ts +6 -8
  60. package/src/resolvers/resolve-result/resolve-result.ts +4 -1
  61. package/src/transformers/parse-date/parse-date.transformer.ts +6 -1
  62. package/src/utils/chunk-find/chunk-find.util.ts +7 -0
  63. package/src/utils/combine/combine.util.ts +8 -15
  64. package/src/utils/get-paginate/get-paginate.util.ts +1 -3
  65. package/src/utils/index.ts +2 -0
  66. package/src/utils/iterate-find/iterate-find.util.ts +8 -0
  67. package/src/utils/mutate-data/mutate-data.util.ts +21 -4
  68. package/src/utils/mutate-result/mutate-result.util.ts +4 -10
  69. package/src/utils/patch-batch/patch-batch.util.ts +32 -14
  70. package/src/utils/replace-data/replace-data.util.ts +26 -0
  71. package/src/utils/replace-result/replace-result.util.ts +60 -0
  72. package/src/utils/sort-query-properties/sort-query-properties.util.ts +15 -8
  73. package/src/utils/walk-query/walk-query.util.ts +2 -2
  74. package/dist/hooks-DPFxxjBu.mjs.map +0 -1
  75. package/dist/internal.utils-BWQ25nOd.mjs.map +0 -1
  76. package/dist/mutate-result.util-CCBWix-G.mjs.map +0 -1
  77. package/dist/predicates-CT08opkD.mjs.map +0 -1
  78. package/dist/resolve-Cx9osy8O.mjs.map +0 -1
  79. package/dist/transform-result.hook-CevWK5TA.mjs.map +0 -1
  80. package/dist/utils-1I_iPZkV.mjs.map +0 -1
@@ -1,10 +1,9 @@
1
- import { g as every, p as isMulti, t as throwIf, u as isProvider } from "./predicates-CT08opkD.mjs";
2
- import { d as checkContext, f as addToQuery, h as sortQueryProperties, r as transformParams, u as contextToJson } from "./utils-1I_iPZkV.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-CevWK5TA.mjs";
6
- import "./resolve-Cx9osy8O.mjs";
7
- import isObject from "lodash/isObject.js";
1
+ import { a as traverse$1, i as isPromise, r as toArray, t as early } from "./internal.utils-3BrB8lRY.mjs";
2
+ import { g as every, p as isMulti, t as throwIf, u as isProvider } from "./predicates-BC8p_YLo.mjs";
3
+ import { d as checkContext, f as addToQuery, h as sortQueryProperties, r as transformParams, u as contextToJson } from "./utils-BrvpblXB.mjs";
4
+ import { a as getResultIsArray, o as getDataIsArray } from "./mutate-result.util-B6FOkwrd.mjs";
5
+ import { r as transformData } from "./transform-result.hook-CanJtTPV.mjs";
6
+ import "./resolve-ClHfNFlm.mjs";
8
7
  import { copy } from "fast-copy";
9
8
  import { BadRequest, Forbidden, MethodNotAllowed, TooManyRequests } from "@feathersjs/errors";
10
9
  import _get from "lodash/get.js";
@@ -15,16 +14,9 @@ import _setWith from "lodash/setWith.js";
15
14
  import _clone from "lodash/clone.js";
16
15
  //#region src/hooks/cache/cache-utils.ts
17
16
  const stableStringify = (obj) => {
18
- if (obj.query) obj = {
19
- ...obj,
20
- query: sortQueryProperties(obj.query)
21
- };
22
- return JSON.stringify(obj, (key, value) => {
17
+ const normalized = sortQueryProperties(obj);
18
+ return JSON.stringify(normalized, (_key, value) => {
23
19
  if (typeof value === "function") throw new Error("Cannot stringify non JSON value");
24
- if (isObject(value)) return Object.keys(value).sort().reduce((result, key) => {
25
- result[key] = value[key];
26
- return result;
27
- }, {});
28
20
  return value;
29
21
  });
30
22
  };
@@ -68,12 +60,10 @@ const cacheBefore = async (context, cacheMap) => {
68
60
  const value = await cacheMap.get(context);
69
61
  if (value) context.result = value;
70
62
  }
71
- return context;
72
63
  };
73
64
  const cacheAfter = async (context, cacheMap) => {
74
65
  if (context.method === "get" || context.method === "find") await cacheMap.set(context);
75
66
  else await cacheMap.clear(context);
76
- return context;
77
67
  };
78
68
  var ContextCacheMap = class {
79
69
  map;
@@ -81,11 +71,13 @@ var ContextCacheMap = class {
81
71
  options;
82
72
  log;
83
73
  serialize;
74
+ clone;
84
75
  constructor(options) {
85
76
  this.map = options.map;
86
77
  this.options = options;
87
78
  this.log = options.logger;
88
79
  this.serialize = options.serialize ?? stableStringify;
80
+ this.clone = options.clone === false ? (value) => value : typeof options.clone === "function" ? options.clone : copy;
89
81
  }
90
82
  stringifyCacheKey(context) {
91
83
  if (context.method !== "get" && context.method !== "find") throw new Error(`Cache can only be used with 'get' or 'find' methods, not '${context.method}'`);
@@ -108,14 +100,14 @@ var ContextCacheMap = class {
108
100
  */
109
101
  async get(context) {
110
102
  const key = this.stringifyCacheKey(context);
111
- const result = this.map.get(key);
103
+ const result = await this.map.get(key);
112
104
  if (result) {
113
105
  this.log?.({
114
106
  type: "hit",
115
107
  method: context.method,
116
108
  key
117
109
  });
118
- return copy(result);
110
+ return this.clone(result);
119
111
  }
120
112
  this.log?.({
121
113
  type: "miss",
@@ -135,7 +127,7 @@ var ContextCacheMap = class {
135
127
  method: context.method,
136
128
  key
137
129
  });
138
- return this.map.set(key, copy(context.result));
130
+ return this.map.set(key, this.clone(context.result));
139
131
  }
140
132
  async clear(context) {
141
133
  const results = Array.isArray(context.result) ? context.result : [context.result];
@@ -149,6 +141,7 @@ var ContextCacheMap = class {
149
141
  await this.map.clear();
150
142
  return context;
151
143
  }
144
+ const idSet = new Set(itemIds.map((id) => `${id}`));
152
145
  for (const key of this.map.keys()) {
153
146
  const cachedId = this.getCachedId(key);
154
147
  if (cachedId === "null") {
@@ -161,7 +154,7 @@ var ContextCacheMap = class {
161
154
  continue;
162
155
  }
163
156
  if (context.method === "create") continue;
164
- for (const itemId of itemIds) if (cachedId === itemId) {
157
+ if (idSet.has(cachedId)) {
165
158
  this.log?.({
166
159
  type: "invalidate",
167
160
  method: context.method,
@@ -193,14 +186,15 @@ var ContextCacheMap = class {
193
186
  * @see https://utils.feathersjs.com/hooks/check-multi.html
194
187
  */
195
188
  function checkMulti(options) {
196
- return (context, next) => {
189
+ function hook(context, next) {
197
190
  const { service, method } = context;
198
191
  if (!service.allowsMulti || !isMulti(context) || method === "find" || service.allowsMulti(method)) {
199
192
  if (next) return next();
200
- return context;
193
+ return;
201
194
  }
202
195
  throw options?.error ? options.error(context) : new MethodNotAllowed(`Can not ${method} multiple entries`);
203
- };
196
+ }
197
+ return hook;
204
198
  }
205
199
  //#endregion
206
200
  //#region src/hooks/check-required/check-required.hook.ts
@@ -222,7 +216,7 @@ function checkMulti(options) {
222
216
  */
223
217
  function checkRequired(fieldNames) {
224
218
  const fieldNamesArray = toArray(fieldNames);
225
- return (context, next) => {
219
+ function hook(context, next) {
226
220
  checkContext(context, {
227
221
  type: ["before", "around"],
228
222
  method: [
@@ -243,7 +237,8 @@ function checkRequired(fieldNames) {
243
237
  }
244
238
  }
245
239
  if (next) return next();
246
- };
240
+ }
241
+ return hook;
247
242
  }
248
243
  //#endregion
249
244
  //#region src/hooks/create-related/create-related.hook.ts
@@ -278,7 +273,7 @@ function createRelated(options) {
278
273
  await Promise.all(entries.map(async (entry) => {
279
274
  const { data, service, multi } = entry;
280
275
  const dataToCreate = (await Promise.all(result.map(async (item) => data(item, context)))).flat().filter((x) => !!x);
281
- if (!dataToCreate || dataToCreate.length <= 0) return context;
276
+ if (!dataToCreate || dataToCreate.length <= 0) return;
282
277
  if (multi || dataToCreate.length === 1) await context.app.service(service).create(dataToCreate.length === 1 ? dataToCreate[0] : dataToCreate);
283
278
  else await Promise.all(dataToCreate.map(async (item) => context.app.service(service).create(item)));
284
279
  }));
@@ -338,19 +333,21 @@ const debug = (msg, ...fieldNames) => async (context, next) => {
338
333
  *
339
334
  * @see https://utils.feathersjs.com/hooks/disable-pagination.html
340
335
  */
341
- const disablePagination = () => (context, next) => {
342
- checkContext(context, {
343
- type: ["before", "around"],
344
- method: ["find"],
345
- label: "disablePagination"
346
- });
347
- const $limit = context.params?.query?.$limit;
348
- if ($limit === "-1" || $limit === -1) {
349
- context.params.paginate = false;
350
- delete context.params.query.$limit;
336
+ const disablePagination = () => {
337
+ function hook(context, next) {
338
+ checkContext(context, {
339
+ type: ["before", "around"],
340
+ method: ["find"],
341
+ label: "disablePagination"
342
+ });
343
+ const $limit = context.params?.query?.$limit;
344
+ if ($limit === "-1" || $limit === -1) {
345
+ context.params.paginate = false;
346
+ delete context.params.query.$limit;
347
+ }
348
+ if (next) return next();
351
349
  }
352
- if (next) return next();
353
- return context;
350
+ return hook;
354
351
  };
355
352
  //#endregion
356
353
  //#region src/hooks/disallow/disallow.hook.ts
@@ -375,11 +372,12 @@ const disablePagination = () => (context, next) => {
375
372
  */
376
373
  const disallow = (transports) => {
377
374
  const transportsArr = toArray(transports);
378
- return (context, next) => {
379
- if (!transports) throw new MethodNotAllowed("Method not allowed");
375
+ function hook(context, next) {
376
+ if (!transports || transportsArr.length === 0) throw new MethodNotAllowed("Method not allowed");
380
377
  if (isProvider(...transportsArr)(context)) throw new MethodNotAllowed(`Provider '${context.params.provider}' can not call '${context.method}' on '${context.path}'. (disallow)`);
381
- if (next) return next().then(() => context);
382
- };
378
+ if (next) return next();
379
+ }
380
+ return hook;
383
381
  };
384
382
  //#endregion
385
383
  //#region src/hooks/on-delete/on-delete.hook.ts
@@ -394,11 +392,11 @@ const onDelete = (options) => {
394
392
  if (next) await next();
395
393
  const { result } = getResultIsArray(context);
396
394
  if (!result.length) return;
397
- const promises = [];
398
- optionsMulti.forEach(async ({ keyHere, keyThere, onDelete, service, blocking, query }) => {
395
+ const blockingPromises = [];
396
+ for (const { keyHere, keyThere, onDelete, service, blocking, query, onError } of optionsMulti) {
399
397
  let ids = result.map((x) => x[keyHere]).filter((x) => !!x);
400
398
  ids = [...new Set(ids)];
401
- if (!ids || ids.length <= 0) return context;
399
+ if (!ids || ids.length <= 0) continue;
402
400
  const params = {
403
401
  query: {
404
402
  ...query,
@@ -412,9 +410,11 @@ const onDelete = (options) => {
412
410
  const data = { [keyThere]: null };
413
411
  promise = context.app.service(service).patch(null, data, params);
414
412
  }
415
- if (promise && blocking) promises.push(promise);
416
- });
417
- if (promises.length) await Promise.all(promises);
413
+ if (!promise) continue;
414
+ if (blocking) blockingPromises.push(promise);
415
+ else promise.catch((error) => onError?.(error, context));
416
+ }
417
+ if (blockingPromises.length) await Promise.all(blockingPromises);
418
418
  };
419
419
  };
420
420
  //#endregion
@@ -442,7 +442,7 @@ const FROM_CLIENT_FOR_SERVER_DEFAULT_KEY = "_$client";
442
442
  const paramsForServer = (whitelist, options) => {
443
443
  const whitelistArr = toArray(whitelist);
444
444
  const { keyToHide = FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } = options || {};
445
- return (context, next) => {
445
+ function hook(context, next) {
446
446
  let clonedParams;
447
447
  Object.keys(context.params).forEach((key) => {
448
448
  if (key === "query") return;
@@ -452,14 +452,15 @@ const paramsForServer = (whitelist, options) => {
452
452
  query: { ...context.params.query }
453
453
  };
454
454
  if (!clonedParams.query[keyToHide]) clonedParams.query[keyToHide] = {};
455
+ else clonedParams.query[keyToHide] = { ...clonedParams.query[keyToHide] };
455
456
  clonedParams.query[keyToHide][key] = clonedParams[key];
456
457
  delete clonedParams[key];
457
458
  }
458
459
  });
459
460
  if (clonedParams) context.params = clonedParams;
460
461
  if (next) return next();
461
- return context;
462
- };
462
+ }
463
+ return hook;
463
464
  };
464
465
  //#endregion
465
466
  //#region src/hooks/params-from-client/params-from-client.hook.ts
@@ -483,10 +484,10 @@ const paramsForServer = (whitelist, options) => {
483
484
  const paramsFromClient = (whitelist, options) => {
484
485
  const whitelistArr = toArray(whitelist);
485
486
  const { keyToHide = FROM_CLIENT_FOR_SERVER_DEFAULT_KEY } = options || {};
486
- return (context, next) => {
487
+ function hook(context, next) {
487
488
  if (!context.params?.query?.[keyToHide] || typeof context.params.query[keyToHide] !== "object") {
488
489
  if (next) return next();
489
- return context;
490
+ return;
490
491
  }
491
492
  const params = {
492
493
  ...context.params,
@@ -505,8 +506,8 @@ const paramsFromClient = (whitelist, options) => {
505
506
  if (Object.keys(client).length === 0) delete params.query[keyToHide];
506
507
  context.params = params;
507
508
  if (next) return next();
508
- return context;
509
- };
509
+ }
510
+ return hook;
510
511
  };
511
512
  //#endregion
512
513
  //#region src/hooks/prevent-changes/prevent-changes.hook.ts
@@ -577,7 +578,7 @@ const rateLimit = (rateLimiter, options) => {
577
578
  context.params.rateLimit = res;
578
579
  throw new TooManyRequests("Too many requests", { rateLimitRes: res });
579
580
  }
580
- if (next) return await next();
581
+ if (next) await next();
581
582
  };
582
583
  };
583
584
  //#endregion
@@ -600,17 +601,17 @@ const rateLimit = (rateLimiter, options) => {
600
601
  */
601
602
  function setData(from, to, options) {
602
603
  const { allowUndefined = false, overwrite = true } = options ?? {};
603
- return (context, next) => {
604
+ function hook(context, next) {
604
605
  const { data } = getDataIsArray(context);
605
606
  const contextJson = contextToJson(context);
606
607
  if (!_has(contextJson, from)) {
607
608
  if (!context.params?.provider || allowUndefined === true) {
608
609
  if (next) return next();
609
- return context;
610
+ return;
610
611
  }
611
612
  if (!overwrite && data.every((item) => _has(item, to))) {
612
613
  if (next) return next();
613
- return context;
614
+ return;
614
615
  }
615
616
  throw options?.error ? options.error(context, from) : new Forbidden(`Expected field ${from.toString()} not available`);
616
617
  }
@@ -621,8 +622,8 @@ function setData(from, to, options) {
621
622
  _set(item, to, val);
622
623
  }
623
624
  if (next) return next();
624
- return context;
625
- };
625
+ }
626
+ return hook;
626
627
  }
627
628
  //#endregion
628
629
  //#region src/hooks/set-field/set-field.hook.ts
@@ -642,23 +643,26 @@ function setData(from, to, options) {
642
643
  *
643
644
  * @see https://utils.feathersjs.com/hooks/set-field.html
644
645
  */
645
- const setField = ({ as, from, allowUndefined = false, error }) => (context, next) => {
646
- const { params } = context;
647
- checkContext(context, {
648
- type: ["before", "around"],
649
- label: "setField"
650
- });
651
- const value = _get(context, from);
652
- if (value === void 0) {
653
- if (!params.provider || allowUndefined) {
654
- if (next) return next();
655
- return context;
646
+ const setField = ({ as, from, allowUndefined = false, error }) => {
647
+ const targets = Array.isArray(as) ? as : [as];
648
+ function hook(context, next) {
649
+ const { params } = context;
650
+ checkContext(context, {
651
+ type: ["before", "around"],
652
+ label: "setField"
653
+ });
654
+ const value = typeof from === "function" ? from(context) : _get(context, from);
655
+ if (value === void 0) {
656
+ if (!params.provider || allowUndefined) {
657
+ if (next) return next();
658
+ return;
659
+ }
660
+ throw error ? error(context, from) : new Forbidden(`Expected field ${targets.join(", ")} not available`);
656
661
  }
657
- throw error ? error(context, from) : new Forbidden(`Expected field ${as} not available`);
662
+ for (const target of targets) _setWith(context, target, value, _clone);
663
+ if (next) return next();
658
664
  }
659
- context = _setWith(context, as, value, _clone);
660
- if (next) return next();
661
- return context;
665
+ return hook;
662
666
  };
663
667
  //#endregion
664
668
  //#region src/hooks/set-result/set-result.hook.ts
@@ -697,16 +701,20 @@ function setResult(from, to, options) {
697
701
  return context;
698
702
  };
699
703
  const fn = (context) => {
704
+ if (!!options?.dispatch && !context.dispatch) context.dispatch = copy(context.result);
700
705
  if (options?.dispatch === "both") {
701
706
  forResultOrDispatch(context, true);
702
707
  return forResultOrDispatch(context, false);
703
708
  }
704
709
  return forResultOrDispatch(context, !!options?.dispatch);
705
710
  };
706
- return (context, next) => {
707
- if (next) return next().then(() => fn(context));
708
- return fn(context);
709
- };
711
+ function hook(context, next) {
712
+ if (next) return next().then(() => {
713
+ fn(context);
714
+ });
715
+ fn(context);
716
+ }
717
+ return hook;
710
718
  }
711
719
  //#endregion
712
720
  //#region src/hooks/set-slug/set-slug.hook.ts
@@ -727,15 +735,15 @@ function setResult(from, to, options) {
727
735
  * @see https://utils.feathersjs.com/hooks/set-slug.html
728
736
  */
729
737
  const setSlug = (slug, fieldName) => {
730
- if (typeof fieldName !== "string") fieldName = `query.${slug}`;
731
- return (context, next) => {
738
+ const targetField = typeof fieldName === "string" ? fieldName : `query.${slug}`;
739
+ function hook(context, next) {
732
740
  if (context.params && context.params.provider === "rest") {
733
741
  const value = context.params.route[slug];
734
- if (typeof value === "string" && value[0] !== ":") _set(context.params, fieldName, value);
742
+ if (typeof value === "string" && value[0] !== ":") _set(context.params, targetField, value);
735
743
  }
736
744
  if (next) return next();
737
- return context;
738
- };
745
+ }
746
+ return hook;
739
747
  };
740
748
  //#endregion
741
749
  //#region src/hooks/soft-delete/soft-delete.hook.ts
@@ -765,7 +773,10 @@ const softDelete = (options) => {
765
773
  label: "softDelete"
766
774
  });
767
775
  const { disableSoftDeleteKey = "disableSoftDelete" } = options;
768
- if (context.params[disableSoftDeleteKey]) return early(context, next);
776
+ if (context.params[disableSoftDeleteKey]) {
777
+ await early(context, next);
778
+ return;
779
+ }
769
780
  const { deletedQuery, removeData } = options;
770
781
  let deleteQuery = getValue(deletedQuery, context);
771
782
  if (isPromise(deleteQuery)) deleteQuery = await deleteQuery;
@@ -781,8 +792,7 @@ const softDelete = (options) => {
781
792
  const method = options.usePatchWithHooks ? "patch" : "_patch";
782
793
  context.result = await context.service[method](context.id, data, params);
783
794
  }
784
- if (next) return await next();
785
- return context;
795
+ if (next) await next();
786
796
  };
787
797
  };
788
798
  const getValue = (value, ...args) => {
@@ -823,10 +833,10 @@ const defaultStashFunc = (context) => {
823
833
  function stashable(options) {
824
834
  const propName = options?.propName ?? "stashed";
825
835
  const stashFunc = options?.stashFunc ?? defaultStashFunc;
826
- return ((context, next) => {
836
+ function hook(context, next) {
827
837
  if (context.params._stashable) {
828
838
  if (next) return next();
829
- return context;
839
+ return;
830
840
  }
831
841
  checkContext(context, {
832
842
  type: ["before", "around"],
@@ -840,8 +850,8 @@ function stashable(options) {
840
850
  const promise = stashFunc(context).catch(() => void 0);
841
851
  context.params[propName] = () => promise;
842
852
  if (next) return next();
843
- return context;
844
- });
853
+ }
854
+ return hook;
845
855
  }
846
856
  //#endregion
847
857
  //#region src/hooks/throw-if-is-multi/throw-if-is-multi.hook.ts
@@ -905,12 +915,18 @@ const throwIfIsProvider = (transports, options) => {
905
915
  *
906
916
  * @see https://utils.feathersjs.com/hooks/traverse.html
907
917
  */
908
- const traverse = ({ transformer, getObject }) => (context, next) => {
909
- traverse$1(getObject(context), transformer);
910
- if (next) return next();
911
- return context;
918
+ const traverse = ({ transformer, getObject, runAfter = false }) => {
919
+ const runTraverse = (context) => traverse$1(getObject(context), transformer);
920
+ function hook(context, next) {
921
+ if (next && runAfter) return next().then(() => {
922
+ runTraverse(context);
923
+ });
924
+ runTraverse(context);
925
+ if (next) return next();
926
+ }
927
+ return hook;
912
928
  };
913
929
  //#endregion
914
930
  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 };
915
931
 
916
- //# sourceMappingURL=hooks-DPFxxjBu.mjs.map
932
+ //# sourceMappingURL=hooks-yFJ5FmU5.mjs.map