feathers-utils 6.0.0 → 7.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.
Files changed (59) hide show
  1. package/README.md +3 -4
  2. package/dist/index.cjs +81 -99
  3. package/dist/index.d.cts +35 -33
  4. package/dist/index.d.mts +35 -33
  5. package/dist/index.d.ts +35 -33
  6. package/dist/index.mjs +81 -99
  7. package/package.json +29 -32
  8. package/src/.DS_Store +0 -0
  9. package/src/filters/array.ts +11 -13
  10. package/src/filters/index.ts +2 -2
  11. package/src/filters/object.ts +11 -11
  12. package/src/hooks/.DS_Store +0 -0
  13. package/src/hooks/checkMulti.ts +98 -82
  14. package/src/hooks/createRelated.ts +41 -41
  15. package/src/hooks/forEach.ts +32 -32
  16. package/src/hooks/from-client-for-server/common.ts +1 -1
  17. package/src/hooks/from-client-for-server/index.ts +2 -2
  18. package/src/hooks/from-client-for-server/paramsForServer.ts +32 -32
  19. package/src/hooks/from-client-for-server/paramsFromClient.ts +25 -25
  20. package/src/hooks/index.ts +9 -9
  21. package/src/hooks/onDelete.ts +54 -55
  22. package/src/hooks/parseFields.ts +13 -13
  23. package/src/hooks/removeRelated.ts +22 -20
  24. package/src/hooks/runPerItem.ts +17 -18
  25. package/src/hooks/setData.ts +295 -264
  26. package/src/index.ts +6 -6
  27. package/src/mixins/debounce-mixin/DebouncedStore.ts +29 -29
  28. package/src/mixins/debounce-mixin/debounceMixin.ts +17 -17
  29. package/src/mixins/debounce-mixin/index.ts +3 -3
  30. package/src/mixins/debounce-mixin/types.ts +9 -9
  31. package/src/mixins/debounce-mixin/utils.ts +3 -3
  32. package/src/mixins/index.ts +1 -1
  33. package/src/types.ts +3 -5
  34. package/src/typesInternal.ts +14 -14
  35. package/src/utility-types/index.ts +48 -48
  36. package/src/utils/_utils.internal.ts +5 -5
  37. package/src/utils/defineHooks.ts +8 -8
  38. package/src/utils/deflattenQuery.ts +31 -31
  39. package/src/utils/filterQuery.ts +58 -58
  40. package/src/utils/flattenQuery.ts +54 -54
  41. package/src/utils/getItemsIsArray.ts +148 -149
  42. package/src/utils/getPaginate.ts +31 -31
  43. package/src/utils/index.ts +17 -17
  44. package/src/utils/isMulti.ts +48 -40
  45. package/src/utils/isPaginated.ts +30 -30
  46. package/src/utils/markHookForSkip.ts +177 -178
  47. package/src/utils/mergeQuery/index.ts +3 -3
  48. package/src/utils/mergeQuery/mergeArrays.ts +67 -67
  49. package/src/utils/mergeQuery/mergeQuery.ts +211 -211
  50. package/src/utils/mergeQuery/types.ts +12 -12
  51. package/src/utils/mergeQuery/utils.ts +224 -224
  52. package/src/utils/optimizeBatchPatch.ts +42 -42
  53. package/src/utils/pushSet.ts +57 -57
  54. package/src/utils/setQueryKeySafely.ts +68 -68
  55. package/src/utils/setResultEmpty.ts +125 -123
  56. package/src/utils/shouldSkip.ts +72 -72
  57. package/src/utils/toJSON.ts +4 -4
  58. package/src/utils/validateQueryProperty.ts +10 -10
  59. package/src/hooks/makeSequelizeQuery.ts_ +0 -90
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # feathers-utils
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/feathers-utils)](https://www.npmjs.com/package/feathers-utils)
4
- [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/fratzinger/feathers-utils/node.js.yml?branch=main)](https://github.com/fratzinger/feathers-utils/actions/workflows/node.js.yml?query=branch%3Amain)
4
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/fratzinger/feathers-utils/node.js.yaml?branch=main)](https://github.com/fratzinger/feathers-utils/actions/workflows/node.js.yaml?query=branch%3Amain)
5
5
  [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/fratzinger/feathers-utils)](https://codeclimate.com/github/fratzinger/feathers-utils)
6
6
  [![Code Climate coverage](https://img.shields.io/codeclimate/coverage/fratzinger/feathers-utils)](https://codeclimate.com/github/fratzinger/feathers-utils)
7
7
  [![npm](https://img.shields.io/npm/dm/feathers-utils)](https://www.npmjs.com/package/feathers-utils)
@@ -9,7 +9,6 @@
9
9
 
10
10
  > NOTE: This is the version for Feathers v5. For Feathers v4 use [feathers-utils v1](https://github.com/fratzinger/feathers-utils/tree/crow)
11
11
 
12
-
13
12
  ## Installation
14
13
 
15
14
  ```shell
@@ -48,7 +47,7 @@ npm i feathers-utils
48
47
  - `markHookForSkip`: add hookName to `context.params.skipHooks` - also see `shouldSkip`
49
48
  - `mergeQuery`: deeply merges queries
50
49
  - `mergeArrays`: merges arrays with intersection options
51
- - `pushSet`: if existing array: *push*, else *set*
50
+ - `pushSet`: if existing array: _push_, else _set_
52
51
  - `setQueryKeySafely`
53
52
  - `setResultEmpty`
54
- - `shouldSkip`: checks `context.params.skipHooks` for `'all' | '${hookName}' | '${type}:${hookName}'` - also see `markHookForSkip`
53
+ - `shouldSkip`: checks `context.params.skipHooks` for `'all' | '${hookName}' | '${type}:${hookName}'` - also see `markHookForSkip`
package/dist/index.cjs CHANGED
@@ -24,7 +24,7 @@ function defineHooks(hooks) {
24
24
  }
25
25
 
26
26
  function filterQuery(providedQuery) {
27
- providedQuery ?? (providedQuery = {});
27
+ providedQuery ??= {};
28
28
  const { $select, $limit, $skip, $sort, ...query } = providedQuery;
29
29
  const result = { query };
30
30
  if ("$select" in providedQuery) {
@@ -392,12 +392,12 @@ function handleCircular(target, source, prependKey, options) {
392
392
  }
393
393
  }
394
394
  function makeDefaultOptions$1(options) {
395
- options ?? (options = {});
396
- options.defaultHandle ?? (options.defaultHandle = "combine");
397
- options.useLogicalConjunction ?? (options.useLogicalConjunction = false);
398
- options.actionOnEmptyIntersect ?? (options.actionOnEmptyIntersect = () => {
395
+ options ??= {};
396
+ options.defaultHandle ??= "combine";
397
+ options.useLogicalConjunction ??= false;
398
+ options.actionOnEmptyIntersect ??= () => {
399
399
  throw new errors.Forbidden("You're not allowed to make this request");
400
- });
400
+ };
401
401
  options.handle = options.handle || {};
402
402
  if (options.defaultHandle === "intersect") {
403
403
  options.handle.$select = options.handle.$select || "intersectOrFull";
@@ -517,7 +517,6 @@ function mergeQuery(target, source, _options) {
517
517
  }
518
518
 
519
519
  const setQueryKeySafely = (params, key, value, operator = "$eq", options) => {
520
- var _a;
521
520
  const { mutate = false } = options || {};
522
521
  if (!mutate) {
523
522
  params = structuredClone(params);
@@ -538,7 +537,7 @@ const setQueryKeySafely = (params, key, value, operator = "$eq", options) => {
538
537
  if (isPlainObject(params.query[key]) && !(operator in params.query[key])) {
539
538
  params.query[key][operator] = value;
540
539
  } else {
541
- (_a = params.query).$and ?? (_a.$and = []);
540
+ params.query.$and ??= [];
542
541
  params.query.$and.push(
543
542
  operator === "$eq" ? { [key]: value } : {
544
543
  [key]: {
@@ -729,37 +728,35 @@ function checkMulti() {
729
728
  };
730
729
  }
731
730
 
732
- function createRelated({
733
- service,
734
- multi = true,
735
- data,
736
- createItemsInDataArraySeparately = true
737
- }) {
738
- if (!service || !data) {
739
- throw "initialize hook 'createRelated' completely!";
740
- }
731
+ function createRelated(options) {
741
732
  return async (context) => {
742
733
  if (shouldSkip("createRelated", context)) {
743
734
  return context;
744
735
  }
745
736
  feathersHooksCommon.checkContext(context, "after", void 0, "createRelated");
746
737
  const { items } = getItemsIsArray(context);
747
- let dataToCreate = (await Promise.all(items.map(async (item) => data(item, context)))).filter((x) => !!x);
748
- if (createItemsInDataArraySeparately) {
749
- dataToCreate = dataToCreate.flat();
750
- }
751
- if (!dataToCreate || dataToCreate.length <= 0) {
752
- return context;
753
- }
754
- if (multi) {
755
- await context.app.service(service).create(dataToCreate);
756
- } else {
757
- await Promise.all(
758
- dataToCreate.map(
759
- async (item) => context.app.service(service).create(item)
760
- )
761
- );
762
- }
738
+ const entries = Array.isArray(options) ? options : [options];
739
+ await Promise.all(
740
+ entries.map(async (entry) => {
741
+ const { data, service, createItemsInDataArraySeparately, multi } = entry;
742
+ let dataToCreate = (await Promise.all(items.map(async (item) => data(item, context)))).filter((x) => !!x);
743
+ if (createItemsInDataArraySeparately) {
744
+ dataToCreate = dataToCreate.flat();
745
+ }
746
+ if (!dataToCreate || dataToCreate.length <= 0) {
747
+ return context;
748
+ }
749
+ if (multi) {
750
+ await context.app.service(service).create(dataToCreate);
751
+ } else {
752
+ await Promise.all(
753
+ dataToCreate.map(
754
+ async (item) => context.app.service(service).create(item)
755
+ )
756
+ );
757
+ }
758
+ })
759
+ );
763
760
  return context;
764
761
  };
765
762
  }
@@ -797,46 +794,44 @@ const forEach = (actionPerItem, options) => {
797
794
  };
798
795
  };
799
796
 
800
- function onDelete(service, {
801
- keyThere,
802
- keyHere = "id",
803
- onDelete: onDelete2 = "cascade",
804
- blocking = true
805
- }) {
806
- if (!service || !keyThere) {
807
- throw "initialize hook 'removeRelated' completely!";
808
- }
809
- if (!["cascade", "set null"].includes(onDelete2)) {
810
- throw "onDelete must be 'cascade' or 'set null'";
811
- }
797
+ function onDelete(options) {
812
798
  return async (context) => {
813
799
  if (shouldSkip("onDelete", context)) {
814
800
  return context;
815
801
  }
816
802
  feathersHooksCommon.checkContext(context, "after", "remove", "onDelete");
817
803
  const { items } = getItemsIsArray(context);
818
- let ids = items.map((x) => x[keyHere]).filter((x) => !!x);
819
- ids = [...new Set(ids)];
820
- if (!ids || ids.length <= 0) {
821
- return context;
822
- }
823
- const params = {
824
- query: {
825
- [keyThere]: {
826
- $in: ids
804
+ const entries = Array.isArray(options) ? options : [options];
805
+ const promises = [];
806
+ entries.forEach(
807
+ async ({ keyHere, keyThere, onDelete: onDelete2, service, blocking }) => {
808
+ let ids = items.map((x) => x[keyHere]).filter((x) => !!x);
809
+ ids = [...new Set(ids)];
810
+ if (!ids || ids.length <= 0) {
811
+ return context;
827
812
  }
828
- },
829
- paginate: false
830
- };
831
- let promise;
832
- if (onDelete2 === "cascade") {
833
- promise = context.app.service(service).remove(null, params);
834
- } else if (onDelete2 === "set null") {
835
- const data = { [keyThere]: null };
836
- promise = context.app.service(service).patch(null, data, params);
837
- }
838
- if (blocking) {
839
- await promise;
813
+ const params = {
814
+ query: {
815
+ [keyThere]: {
816
+ $in: ids
817
+ }
818
+ },
819
+ paginate: false
820
+ };
821
+ let promise = void 0;
822
+ if (onDelete2 === "cascade") {
823
+ promise = context.app.service(service).remove(null, params);
824
+ } else if (onDelete2 === "set null") {
825
+ const data = { [keyThere]: null };
826
+ promise = context.app.service(service).patch(null, data, params);
827
+ }
828
+ if (blocking && promise) {
829
+ promises.push(promise);
830
+ }
831
+ }
832
+ );
833
+ if (promises.length) {
834
+ await Promise.all(promises);
840
835
  }
841
836
  return context;
842
837
  };
@@ -970,19 +965,18 @@ function defineParamsForServer(keyToHide) {
970
965
  return;
971
966
  }
972
967
  if (whitelist.includes(key)) {
973
- if (!clonedParams) {
974
- clonedParams = {
975
- ...context.params,
976
- query: {
977
- ...context.params.query
978
- }
979
- };
968
+ const currentParams = clonedParams ?? {
969
+ ...context.params,
970
+ query: {
971
+ ...context.params.query
972
+ }
973
+ };
974
+ if (!currentParams.query[keyToHide]) {
975
+ currentParams.query[keyToHide] = {};
980
976
  }
981
- if (!clonedParams.query[keyToHide]) {
982
- clonedParams.query[keyToHide] = {};
983
- }
984
- clonedParams.query[keyToHide][key] = clonedParams[key];
985
- delete clonedParams[key];
977
+ currentParams.query[keyToHide][key] = currentParams[key];
978
+ delete currentParams[key];
979
+ clonedParams = currentParams;
986
980
  }
987
981
  });
988
982
  if (clonedParams) {
@@ -1039,20 +1033,14 @@ const makeDefaultOptions = () => {
1039
1033
  };
1040
1034
  };
1041
1035
 
1042
- var __defProp = Object.defineProperty;
1043
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1044
- var __publicField = (obj, key, value) => {
1045
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1046
- return value;
1047
- };
1048
1036
  class DebouncedStore {
1037
+ _app;
1038
+ _options;
1039
+ _isRunningById;
1040
+ _queueById;
1041
+ //_waitingById: Record<string, WaitingObject>;
1042
+ add;
1049
1043
  constructor(app, options) {
1050
- __publicField(this, "_app");
1051
- __publicField(this, "_options");
1052
- __publicField(this, "_isRunningById");
1053
- __publicField(this, "_queueById");
1054
- //_waitingById: Record<string, WaitingObject>;
1055
- __publicField(this, "add");
1056
1044
  this._app = app;
1057
1045
  this._options = Object.assign(makeDefaultOptions(), options);
1058
1046
  this._queueById = {};
@@ -1095,13 +1083,9 @@ class DebouncedStore {
1095
1083
  function debounceMixin(options) {
1096
1084
  return (app) => {
1097
1085
  options = options || {};
1098
- const defaultOptions = Object.assign(
1099
- makeDefaultOptions(),
1100
- options?.default
1101
- );
1086
+ const defaultOptions = Object.assign(makeDefaultOptions(), options?.default);
1102
1087
  app.mixins.push((service, path) => {
1103
- if (options?.blacklist && options.blacklist.includes(path))
1104
- return;
1088
+ if (options?.blacklist && options.blacklist.includes(path)) return;
1105
1089
  if (service.debouncedStore) {
1106
1090
  console.warn(
1107
1091
  `[feathers-utils] service: '${path}' already has a property 'debouncedStore'. Mixin will skip creating a new debouncedStore`
@@ -1119,9 +1103,7 @@ function debounceMixin(options) {
1119
1103
 
1120
1104
  const filterQueryArray = (key) => (arr, { operators }) => {
1121
1105
  if (arr && !Array.isArray(arr)) {
1122
- throw new Error(
1123
- `Invalid query parameter '${key}'. It has to be an array`
1124
- );
1106
+ throw new Error(`Invalid query parameter '${key}'. It has to be an array`);
1125
1107
  }
1126
1108
  if (Array.isArray(arr)) {
1127
1109
  return arr.map((current) => validateQueryProperty(current, operators));
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as _feathersjs_feathers from '@feathersjs/feathers';
2
2
  import { HookContext, Application, Id, HookOptions, Query, Params } from '@feathersjs/feathers';
3
- import { HookContext as HookContext$1, Application as Application$1 } from '@feathersjs/feathers/lib';
4
3
  import { PropertyPath, DebouncedFunc } from 'lodash';
5
4
  import { PaginationOptions, FilterQueryOptions } from '@feathersjs/adapter-commons';
6
5
  import { HookType } from 'feathers-hooks-common';
@@ -13,7 +12,7 @@ declare function checkMulti<H extends HookContext = HookContext>(): (context: H)
13
12
  type MaybeArray<T> = T | T[];
14
13
  type Promisable<T> = T | Promise<T>;
15
14
  type Path = Array<string | number>;
16
- type ReturnAsyncHook<H extends HookContext$1 = HookContext$1> = (context: H) => Promise<H>;
15
+ type ReturnAsyncHook<H extends HookContext = HookContext> = (context: H) => Promise<H>;
17
16
  type KeyOf<T> = Extract<keyof T, string>;
18
17
 
19
18
  interface CreateRelatedOptions<S = Record<string, any>> {
@@ -25,9 +24,9 @@ interface CreateRelatedOptions<S = Record<string, any>> {
25
24
  /**
26
25
  * hook to create related items
27
26
  */
28
- declare function createRelated<S = Record<string, any>, H extends HookContext = HookContext>({ service, multi, data, createItemsInDataArraySeparately, }: CreateRelatedOptions<S>): (context: H) => Promise<H>;
27
+ declare function createRelated<S = Record<string, any>, H extends HookContext = HookContext>(options: MaybeArray<CreateRelatedOptions<S>>): (context: H) => Promise<H>;
29
28
 
30
- type GetItemsIsArrayFrom = "data" | "result" | "automatic";
29
+ type GetItemsIsArrayFrom = 'data' | 'result' | 'automatic';
31
30
  type GetItemsIsArrayOptions = {
32
31
  from?: GetItemsIsArrayFrom;
33
32
  };
@@ -35,11 +34,11 @@ interface GetItemsIsArrayResult<T = any> {
35
34
  items: T[];
36
35
  isArray: boolean;
37
36
  }
38
- declare const getItemsIsArray: <T = any, H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H, options?: GetItemsIsArrayOptions) => GetItemsIsArrayResult<T>;
37
+ declare const getItemsIsArray: <T = any, H extends HookContext = HookContext>(context: H, options?: GetItemsIsArrayOptions) => GetItemsIsArrayResult<T>;
39
38
 
40
39
  type HookForEachOptions<T = any, H = HookContext, R = any> = {
41
- wait?: "sequential" | "parallel" | false;
42
- items?: GetItemsIsArrayOptions["from"];
40
+ wait?: 'sequential' | 'parallel' | false;
41
+ items?: GetItemsIsArrayOptions['from'];
43
42
  forAll?: (items: T[], context: H) => Promisable<R>;
44
43
  skip?: (context: H) => Promisable<boolean>;
45
44
  };
@@ -49,10 +48,11 @@ type ActionPerItem<T, H, R> = (item: T, options: {
49
48
  } & (undefined extends R ? {} : {
50
49
  fromAll: R;
51
50
  })) => Promisable<any>;
52
- declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R = any>(actionPerItem: ActionPerItem<T, H, R>, options?: HookForEachOptions<T, H, R>) => ReturnAsyncHook<H>;
51
+ declare const forEach: <H extends HookContext = HookContext, T = any, R = any>(actionPerItem: ActionPerItem<T, H, R>, options?: HookForEachOptions<T, H, R>) => ReturnAsyncHook<H>;
53
52
 
54
- type OnDeleteAction = "cascade" | "set null";
55
- interface OnDeleteOptions {
53
+ type OnDeleteAction = 'cascade' | 'set null';
54
+ interface OnDeleteOptions<Path extends string = string> {
55
+ service: Path;
56
56
  keyThere: string;
57
57
  keyHere: string;
58
58
  onDelete: OnDeleteAction;
@@ -61,7 +61,7 @@ interface OnDeleteOptions {
61
61
  /**
62
62
  * hook to manipulate related items on delete
63
63
  */
64
- declare function onDelete<S = Record<string, any>, H extends HookContext = HookContext>(service: keyof S, { keyThere, keyHere, onDelete, blocking, }: OnDeleteOptions): (context: H) => Promise<H>;
64
+ declare function onDelete<S = Record<string, any>, H extends HookContext = HookContext>(options: MaybeArray<OnDeleteOptions<KeyOf<S>>>): (context: H) => Promise<H>;
65
65
 
66
66
  /**
67
67
  * Parse fields to date or number
@@ -79,6 +79,8 @@ interface RemoveRelatedOptions<S = Record<string, any>> {
79
79
  }
80
80
  /**
81
81
  * hook to remove related items
82
+ *
83
+ * @deprecated use 'onDelete' instead
82
84
  */
83
85
  declare function removeRelated<S = Record<string, any>, H extends HookContext = HookContext>({ service, keyThere, keyHere, blocking, }: RemoveRelatedOptions<S>): (context: H) => Promise<H>;
84
86
 
@@ -89,7 +91,7 @@ interface HookRunPerItemOptions {
89
91
  * hook to run a hook for each item in the context
90
92
  * uses `context.result` if it is existent. otherwise uses context.data
91
93
  */
92
- declare const runPerItem: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any>(actionPerItem: (item: T, context: H) => Promisable<any>, _options?: HookRunPerItemOptions) => (context: H) => Promise<H>;
94
+ declare const runPerItem: <H extends HookContext = HookContext, T = any>(actionPerItem: (item: T, context: H) => Promisable<any>, _options?: HookRunPerItemOptions) => (context: H) => Promise<H>;
93
95
 
94
96
  type Predicate<T = any> = (item: T) => boolean;
95
97
  type PredicateWithContext<T = any> = (item: T, context: HookContext) => boolean;
@@ -103,14 +105,14 @@ interface HookSetDataOptions {
103
105
  */
104
106
  declare function setData<H extends HookContext = HookContext>(from: PropertyPath, to: PropertyPath, _options?: HookSetDataOptions): (context: H) => H;
105
107
 
106
- declare function defineParamsForServer(keyToHide: string): (...whitelist: string[]) => <H extends HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => H;
108
+ declare function defineParamsForServer(keyToHide: string): (...whitelist: string[]) => <H extends HookContext>(context: H) => H;
107
109
  /**
108
110
  * a hook to move params to query._$client
109
111
  * the server only receives 'query' from params. All other params are ignored.
110
112
  * So, to use `$populateParams` on the server, we need to move the params to query._$client
111
113
  * the server will move them back to params
112
114
  */
113
- declare const paramsForServer: (...whitelist: string[]) => <H extends HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => H;
115
+ declare const paramsForServer: (...whitelist: string[]) => <H extends HookContext>(context: H) => H;
114
116
 
115
117
  declare function defineParamsFromClient(keyToHide: string): (...whitelist: string[]) => (context: HookContext) => HookContext;
116
118
  declare const paramsFromClient: (...whitelist: string[]) => (context: HookContext) => HookContext;
@@ -136,14 +138,14 @@ declare class DebouncedStore {
136
138
  private _options;
137
139
  private _isRunningById;
138
140
  _queueById: Record<string, DebouncedFunc<(id: Id, action: DebouncedFunctionApp) => void | Promise<void>>>;
139
- add: any;
141
+ add: (id: Id, action: (app?: Application) => void | Promise<void>) => void | Promise<void> | undefined;
140
142
  constructor(app: Application, options?: Partial<DebouncedStoreOptions>);
141
143
  private unbounced;
142
144
  private debounceById;
143
145
  cancel(id: Id): void;
144
146
  }
145
147
 
146
- declare function debounceMixin(options?: Partial<InitDebounceMixinOptions>): (app: Application$1) => void;
148
+ declare function debounceMixin(options?: Partial<InitDebounceMixinOptions>): (app: Application) => void;
147
149
 
148
150
  declare function defineHooks<A extends Application = Application, S = {
149
151
  find: any;
@@ -155,11 +157,11 @@ declare function defineHooks<A extends Application = Application, S = {
155
157
  }, Options = HookOptions<A, S>>(hooks: Options): Options;
156
158
 
157
159
  type FilterQueryResult<Q extends Query = Query> = {
158
- $select: Q["$select"] extends any ? Q["$select"] : never;
159
- $limit: Q["$limit"] extends any ? Q["$limit"] : never;
160
- $skip: Q["$skip"] extends any ? Q["$skip"] : never;
161
- $sort: Q["$sort"] extends any ? Q["$sort"] : never;
162
- query: Omit<Q, "$select" | "$limit" | "$skip" | "$sort">;
160
+ $select: Q['$select'] extends any ? Q['$select'] : never;
161
+ $limit: Q['$limit'] extends any ? Q['$limit'] : never;
162
+ $skip: Q['$skip'] extends any ? Q['$skip'] : never;
163
+ $sort: Q['$sort'] extends any ? Q['$sort'] : never;
164
+ query: Omit<Q, '$select' | '$limit' | '$skip' | '$sort'>;
163
165
  };
164
166
  /**
165
167
  * Extracts $select, $limit, $skip, $sort from a query and returns the rest as a query object.
@@ -176,7 +178,7 @@ declare function reassembleQuery(query: FilterQueryResult): Query;
176
178
  * 2. it uses `service.options.paginate` if it exists
177
179
  * 3. it uses `context.params.adapter` if it exists
178
180
  */
179
- declare const getPaginate: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => PaginationOptions | undefined;
181
+ declare const getPaginate: <H extends HookContext = HookContext>(context: H) => PaginationOptions | undefined;
180
182
 
181
183
  /**
182
184
  * util to check if a hook is a multi hook:
@@ -187,19 +189,19 @@ declare const getPaginate: <H extends HookContext<_feathersjs_feathers.Applicati
187
189
  * - patch: `context.id == null`
188
190
  * - remove: `context.id == null`
189
191
  */
190
- declare const isMulti: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => boolean;
192
+ declare const isMulti: <H extends HookContext = HookContext>(context: H) => boolean;
191
193
 
192
194
  /**
193
195
  * util to check if a hook is a paginated hook using `getPaginate`
194
196
  */
195
- declare const isPaginated: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => boolean;
197
+ declare const isPaginated: <H extends HookContext = HookContext>(context: H) => boolean;
196
198
 
197
199
  /**
198
200
  * util to mark a hook for skip, has to be used with `shouldSkip`
199
201
  */
200
- declare function markHookForSkip<H extends HookContext = HookContext>(hookName: string, type: "all" | MaybeArray<HookType>, context?: H): H;
202
+ declare function markHookForSkip<H extends HookContext = HookContext>(hookName: string, type: 'all' | MaybeArray<HookType>, context?: H): H | undefined;
201
203
 
202
- type Handle = "target" | "source" | "combine" | "intersect" | "intersectOrFull";
204
+ type Handle = 'target' | 'source' | 'combine' | 'intersect' | 'intersectOrFull';
203
205
  type ActionOnEmptyIntersect = (target: unknown, source: unknown, prependKey: Path) => void;
204
206
  interface MergeQueryOptions {
205
207
  defaultHandle: Handle;
@@ -237,7 +239,7 @@ declare const setQueryKeySafely: (params: Params, key: string, value: any, opera
237
239
  /**
238
240
  * util to set `context.result` to an empty array or object, depending on the hook type
239
241
  */
240
- declare const setResultEmpty: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => H;
242
+ declare const setResultEmpty: <H extends HookContext = HookContext>(context: H) => H;
241
243
 
242
244
  type ShouldSkipOptions = {
243
245
  notSkippable?: boolean;
@@ -245,7 +247,7 @@ type ShouldSkipOptions = {
245
247
  /**
246
248
  * util to detect if a hook should be skipped
247
249
  */
248
- declare const shouldSkip: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(hookName: string, context: H, options?: ShouldSkipOptions) => boolean;
250
+ declare const shouldSkip: <H extends HookContext = HookContext>(hookName: string, context: H, options?: ShouldSkipOptions) => boolean;
249
251
 
250
252
  declare const toJSON: (context: HookContext) => HookContext<_feathersjs_feathers.Application<any, any>, any>;
251
253
 
@@ -258,10 +260,10 @@ type OptimizeBatchPatchOptions<IdKey extends string> = {
258
260
  /** the key of the id property */
259
261
  id?: IdKey;
260
262
  };
261
- type OptimizeBatchPatchResultItem<T = Record<string, unknown>, P = Params> = [Id, T, P | undefined];
263
+ type OptimizeBatchPatchResultItem<T = Record<string, unknown>, P = Params> = [Id | null, T, P | undefined];
262
264
  declare function optimizeBatchPatch<T extends Record<string, any>, IdKey extends KeyOf<T>, P extends Params, R extends Omit<T, IdKey> = Omit<T, IdKey>>(items: T[], options?: OptimizeBatchPatchOptions<IdKey>): OptimizeBatchPatchResultItem<R, P>[];
263
265
 
264
- declare function flattenQuery(q: Query): any;
266
+ declare function flattenQuery(q: Query): Query;
265
267
 
266
268
  declare function deflattenQuery(query: Query): Query;
267
269
 
@@ -300,7 +302,7 @@ type InferPatchResult<S, IdOrNullable = any> = S extends {
300
302
  type InferRemoveResult<S, IdOrNullable = any> = S extends {
301
303
  remove: (id: IdOrNullable, params: any) => infer R;
302
304
  } ? IdOrNullable extends Id ? Single<Awaited<R>> : IdOrNullable extends null ? AsArray<Awaited<R>> : Awaited<R> : never;
303
- type GetService<App extends Application, Path extends string> = App["services"][Path];
305
+ type GetService<App extends Application, Path extends string> = App['services'][Path];
304
306
  type InferGetResultFromPath<App extends Application, Path extends string> = InferGetResult<GetService<App, Path>>;
305
307
  type InferFindResultFromPath<App extends Application, Path extends string> = InferFindResult<GetService<App, Path>>;
306
308
  type InferCreateDataFromPath<App extends Application, Path extends string> = InferCreateData<GetService<App, Path>>;
@@ -312,7 +314,7 @@ type InferPatchDataFromPath<App extends Application, Path extends string> = Infe
312
314
  type InferUpdateResultFromPath<App extends Application, Path extends string> = InferUpdateResult<GetService<App, Path>>;
313
315
  type InferPatchResultFromPath<App extends Application, Path extends string, IdOrNullable = any> = InferPatchResult<GetService<App, Path>, IdOrNullable>;
314
316
  type InferRemoveResultFromPath<App extends Application, Path extends string, IdOrNullable = any> = InferRemoveResult<GetService<App, Path>, IdOrNullable>;
315
- type InferDataFromPath<App extends Application, Path extends string, Method extends "create" | "update" | "patch"> = Method extends "create" ? InferCreateDataFromPath<App, Path> : Method extends "update" ? InferUpdateDataFromPath<App, Path> : Method extends "patch" ? InferPatchDataFromPath<App, Path> : never;
316
- type InferResultFromPath<App extends Application, Path extends string, Method extends "get" | "find" | "create" | "update" | "patch" | "remove"> = Method extends "get" ? InferGetResultFromPath<App, Path> : Method extends "find" ? InferFindResultFromPath<App, Path> : Method extends "create" ? InferCreateResultFromPath<App, Path> : Method extends "update" ? InferUpdateResultFromPath<App, Path> : Method extends "patch" ? InferPatchResultFromPath<App, Path> : Method extends "remove" ? InferRemoveResultFromPath<App, Path> : never;
317
+ type InferDataFromPath<App extends Application, Path extends string, Method extends 'create' | 'update' | 'patch'> = Method extends 'create' ? InferCreateDataFromPath<App, Path> : Method extends 'update' ? InferUpdateDataFromPath<App, Path> : Method extends 'patch' ? InferPatchDataFromPath<App, Path> : never;
318
+ type InferResultFromPath<App extends Application, Path extends string, Method extends 'get' | 'find' | 'create' | 'update' | 'patch' | 'remove'> = Method extends 'get' ? InferGetResultFromPath<App, Path> : Method extends 'find' ? InferFindResultFromPath<App, Path> : Method extends 'create' ? InferCreateResultFromPath<App, Path> : Method extends 'update' ? InferUpdateResultFromPath<App, Path> : Method extends 'patch' ? InferPatchResultFromPath<App, Path> : Method extends 'remove' ? InferRemoveResultFromPath<App, Path> : never;
317
319
 
318
320
  export { type ActionOnEmptyIntersect, type CreateRelatedOptions, type DebouncedFunctionApp, type DebouncedService, DebouncedStore, type DebouncedStoreOptions, type GetItemsIsArrayFrom, type GetItemsIsArrayOptions, type GetItemsIsArrayResult, type GetService, type Handle, type HookForEachOptions, type HookRunPerItemOptions, type HookSetDataOptions, type InferCreateData, type InferCreateDataFromPath, type InferCreateDataSingle, type InferCreateDataSingleFromPath, type InferCreateResult, type InferCreateResultFromPath, type InferCreateResultSingle, type InferCreateResultSingleFromPath, type InferDataFromPath, type InferFindResult, type InferFindResultFromPath, type InferGetResult, type InferGetResultFromPath, type InferPatchData, type InferPatchDataFromPath, type InferPatchResult, type InferPatchResultFromPath, type InferRemoveResult, type InferRemoveResultFromPath, type InferResultFromPath, type InferUpdateData, type InferUpdateDataFromPath, type InferUpdateResult, type InferUpdateResultFromPath, type InitDebounceMixinOptions, type MergeQueryOptions, type OnDeleteAction, type OnDeleteOptions, type OptimizeBatchPatchOptions, type OptimizeBatchPatchResultItem, type Predicate, type PredicateWithContext, type PushSetOptions, type RemoveRelatedOptions, type SetQueryKeySafelyOptions, type ShouldSkipOptions, checkMulti, createRelated, debounceMixin, defineHooks, defineParamsForServer, defineParamsFromClient, deflattenQuery, filterArray, filterObject, filterQuery, flattenQuery, forEach, getItemsIsArray, getPaginate, isMulti, isPaginated, markHookForSkip, mergeArrays, mergeQuery, onDelete, optimizeBatchPatch, paramsForServer, paramsFromClient, parseFields, pushSet, reassembleQuery, removeRelated, runPerItem, setData, setQueryKeySafely, setResultEmpty, shouldSkip, toJSON, validateQueryProperty };