feathers-utils 1.9.0 → 1.9.4

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/README.md CHANGED
@@ -19,8 +19,9 @@ npm i feathers-utils
19
19
 
20
20
  ### Hooks
21
21
 
22
- - `hooks/checkMulti()`: throws if the request is **multi** data, but the service has `allowsMulti(method)` returns `false`
23
- - `hooks/setData({ allowUndefined: Boolean })`
22
+ - `checkMulti()`: throws if the request is **multi** data, but the service has `allowsMulti(method)` returns `false`
23
+ - `runPerItem`
24
+ - `setData({ allowUndefined: Boolean })`
24
25
 
25
26
  ### Mixins
26
27
 
@@ -30,9 +31,13 @@ npm i feathers-utils
30
31
 
31
32
  - `addHook`: add hooks to specific services
32
33
  - `filterQuery`
34
+ - `getItemsIsArray(context)`: returns `{ items: any[], isArray: boolean }`
35
+ - `getPaginate`
33
36
  - `isMulti(context) => Boolean`: returns true, if `find`, `create/patch/remove`: multi
37
+ - `isPaginated`
34
38
  - `markHookForSkip`: add hookName to `context.params.skipHooks` - also see `shouldSkip`
35
39
  - `mergeQuery`: deeply merges queries
36
40
  - `mergeArrays`: merges arrays with intersection options
37
41
  - `pushSet`: if existing array: *push*, else *set*
42
+ - `setResultEmpty`
38
43
  - `shouldSkip`: checks `context.params.skipHooks` for `'all' | '${hookName}' | '${type}:${hookName}'` - also see `markHookForSkip`
@@ -1,2 +1,2 @@
1
- import type { HookContext } from "@feathersjs/feathers";
2
- export declare function checkMulti(): ((context: HookContext) => HookContext);
1
+ import type { ReturnSyncHook } from "../types";
2
+ export declare function checkMulti(): ReturnSyncHook;
@@ -1,4 +1,3 @@
1
- import type { HookRunPerItemOptions } from "../types";
1
+ import type { HookRunPerItemOptions, ReturnAsyncHook, Promisable } from "../types";
2
2
  import type { HookContext } from "@feathersjs/feathers";
3
- import type { Promisable } from "type-fest";
4
- export declare const runPerItem: (actionPerItem: (item: any, context: HookContext) => Promisable<any>, options: HookRunPerItemOptions) => (context: HookContext) => Promise<HookContext>;
3
+ export declare const runPerItem: (actionPerItem: (item: any, context: HookContext) => Promisable<any>, options: HookRunPerItemOptions) => ReturnAsyncHook;
@@ -1,5 +1,5 @@
1
- import { getItems } from "feathers-hooks-common";
2
1
  import { shouldSkip } from "../utils/shouldSkip";
2
+ import { getItemsIsArray } from "../utils/getItemsIsArray";
3
3
  const makeOptions = (options) => {
4
4
  options = options || {};
5
5
  return Object.assign({
@@ -14,8 +14,7 @@ actionPerItem, options) => {
14
14
  if (shouldSkip("runForItems", context)) {
15
15
  return context;
16
16
  }
17
- let items = getItems(context);
18
- items = (Array.isArray(items)) ? items : [items];
17
+ const { items } = getItemsIsArray(context);
19
18
  const promises = items.map(async (item) => {
20
19
  await actionPerItem(item, context);
21
20
  });
@@ -1,4 +1,3 @@
1
- import type { HookContext } from "@feathersjs/feathers";
2
- import type { HookSetDataOptions } from "../types";
3
1
  import type { PropertyPath } from "lodash";
4
- export declare function setData(from: PropertyPath, to: PropertyPath, _options?: HookSetDataOptions): ((context: HookContext) => HookContext);
2
+ import type { HookSetDataOptions, ReturnSyncHook } from "../types";
3
+ export declare function setData(from: PropertyPath, to: PropertyPath, _options?: HookSetDataOptions): ReturnSyncHook;
@@ -1,8 +1,8 @@
1
1
  import _get from "lodash/get";
2
2
  import _set from "lodash/set";
3
3
  import _has from "lodash/has";
4
- import { getItems } from "feathers-hooks-common";
5
4
  import { Forbidden } from "@feathersjs/errors";
5
+ import { getItemsIsArray } from "../utils/getItemsIsArray";
6
6
  const defaultOptions = {
7
7
  allowUndefined: false,
8
8
  overwrite: true
@@ -10,8 +10,7 @@ const defaultOptions = {
10
10
  export function setData(from, to, _options) {
11
11
  const options = Object.assign({}, defaultOptions, _options);
12
12
  return (context) => {
13
- let items = getItems(context);
14
- items = (Array.isArray(items)) ? items : [items];
13
+ const { items } = getItemsIsArray(context);
15
14
  if (!_has(context, from)) {
16
15
  if (!context.params?.provider || options.allowUndefined === true) {
17
16
  return context;
@@ -4,7 +4,7 @@ import { runPerItem } from "./hooks/runPerItem";
4
4
  export declare const hooks: {
5
5
  checkMulti: typeof checkMulti;
6
6
  setData: typeof setData;
7
- runPerItem: (actionPerItem: (item: any, context: import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>) => any, options: import("./types").HookRunPerItemOptions) => (context: import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>) => Promise<import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>>;
7
+ runPerItem: (actionPerItem: (item: any, context: import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>) => any, options: import("./types").HookRunPerItemOptions) => import("./types").ReturnAsyncHook;
8
8
  };
9
9
  export { checkMulti };
10
10
  export { setData };
@@ -1,7 +1,11 @@
1
1
  import type { Application, HookContext, Service } from "@feathersjs/feathers";
2
2
  export declare type Path = Array<string | number>;
3
+ export declare type MaybeArray<T> = T | T[];
4
+ export declare type Promisable<T> = T | Promise<T>;
3
5
  export declare type HookType = "before" | "after" | "error";
4
6
  export declare type ServiceMethodName = "find" | "get" | "create" | "update" | "patch" | "remove";
7
+ export declare type ReturnSyncHook = (context: HookContext) => HookContext;
8
+ export declare type ReturnAsyncHook = (context: HookContext) => Promise<HookContext>;
5
9
  export declare type Handle = "target" | "source" | "combine" | "intersect" | "intersectOrFull";
6
10
  export declare type FirstLast = "first" | "last";
7
11
  export declare type Predicate<T = any> = (item: T) => boolean;
@@ -1,10 +1,18 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
2
  export const getItemsIsArray = (context) => {
3
- let itemOrItems = context.type === "before" ? context.data : context.result;
4
- itemOrItems = itemOrItems && context.method === "find" ? (itemOrItems.data || itemOrItems) : itemOrItems;
3
+ let itemOrItems = context.type === "before"
4
+ ? context.data
5
+ : context.result;
6
+ itemOrItems = itemOrItems && context.method === "find"
7
+ ? (itemOrItems.data || itemOrItems)
8
+ : itemOrItems;
5
9
  const isArray = Array.isArray(itemOrItems);
6
10
  return {
7
- items: (isArray) ? itemOrItems : [itemOrItems],
11
+ items: (isArray)
12
+ ? itemOrItems
13
+ : (itemOrItems != null)
14
+ ? [itemOrItems]
15
+ : [],
8
16
  isArray
9
17
  };
10
18
  };
@@ -1,3 +1,3 @@
1
1
  import type { HookContext } from "@feathersjs/feathers";
2
- import type { HookType } from "feathers-hooks-common/types";
3
- export declare function markHookForSkip<T>(hookName: string, type: "all" | HookType | HookType[], context?: Partial<HookContext<T>>): Partial<HookContext<T>>;
2
+ import type { HookType, MaybeArray } from "../types";
3
+ export declare function markHookForSkip<T>(hookName: string, type: "all" | MaybeArray<HookType>, context?: Partial<HookContext<T>>): Partial<HookContext<T>>;
@@ -1,2 +1,2 @@
1
- import type { HookContext } from "@feathersjs/feathers";
2
- export declare function checkMulti(): ((context: HookContext) => HookContext);
1
+ import type { ReturnSyncHook } from "../types";
2
+ export declare function checkMulti(): ReturnSyncHook;
@@ -1,4 +1,3 @@
1
- import type { HookRunPerItemOptions } from "../types";
1
+ import type { HookRunPerItemOptions, ReturnAsyncHook, Promisable } from "../types";
2
2
  import type { HookContext } from "@feathersjs/feathers";
3
- import type { Promisable } from "type-fest";
4
- export declare const runPerItem: (actionPerItem: (item: any, context: HookContext) => Promisable<any>, options: HookRunPerItemOptions) => (context: HookContext) => Promise<HookContext>;
3
+ export declare const runPerItem: (actionPerItem: (item: any, context: HookContext) => Promisable<any>, options: HookRunPerItemOptions) => ReturnAsyncHook;
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.runPerItem = void 0;
13
- const feathers_hooks_common_1 = require("feathers-hooks-common");
14
13
  const shouldSkip_1 = require("../utils/shouldSkip");
14
+ const getItemsIsArray_1 = require("../utils/getItemsIsArray");
15
15
  const makeOptions = (options) => {
16
16
  options = options || {};
17
17
  return Object.assign({
@@ -26,8 +26,7 @@ actionPerItem, options) => {
26
26
  if ((0, shouldSkip_1.shouldSkip)("runForItems", context)) {
27
27
  return context;
28
28
  }
29
- let items = (0, feathers_hooks_common_1.getItems)(context);
30
- items = (Array.isArray(items)) ? items : [items];
29
+ const { items } = (0, getItemsIsArray_1.getItemsIsArray)(context);
31
30
  const promises = items.map((item) => __awaiter(void 0, void 0, void 0, function* () {
32
31
  yield actionPerItem(item, context);
33
32
  }));
@@ -1,4 +1,3 @@
1
- import type { HookContext } from "@feathersjs/feathers";
2
- import type { HookSetDataOptions } from "../types";
3
1
  import type { PropertyPath } from "lodash";
4
- export declare function setData(from: PropertyPath, to: PropertyPath, _options?: HookSetDataOptions): ((context: HookContext) => HookContext);
2
+ import type { HookSetDataOptions, ReturnSyncHook } from "../types";
3
+ export declare function setData(from: PropertyPath, to: PropertyPath, _options?: HookSetDataOptions): ReturnSyncHook;
@@ -7,8 +7,8 @@ exports.setData = void 0;
7
7
  const get_1 = __importDefault(require("lodash/get"));
8
8
  const set_1 = __importDefault(require("lodash/set"));
9
9
  const has_1 = __importDefault(require("lodash/has"));
10
- const feathers_hooks_common_1 = require("feathers-hooks-common");
11
10
  const errors_1 = require("@feathersjs/errors");
11
+ const getItemsIsArray_1 = require("../utils/getItemsIsArray");
12
12
  const defaultOptions = {
13
13
  allowUndefined: false,
14
14
  overwrite: true
@@ -17,8 +17,7 @@ function setData(from, to, _options) {
17
17
  const options = Object.assign({}, defaultOptions, _options);
18
18
  return (context) => {
19
19
  var _a;
20
- let items = (0, feathers_hooks_common_1.getItems)(context);
21
- items = (Array.isArray(items)) ? items : [items];
20
+ const { items } = (0, getItemsIsArray_1.getItemsIsArray)(context);
22
21
  if (!(0, has_1.default)(context, from)) {
23
22
  if (!((_a = context.params) === null || _a === void 0 ? void 0 : _a.provider) || options.allowUndefined === true) {
24
23
  return context;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { runPerItem } from "./hooks/runPerItem";
4
4
  export declare const hooks: {
5
5
  checkMulti: typeof checkMulti;
6
6
  setData: typeof setData;
7
- runPerItem: (actionPerItem: (item: any, context: import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>) => any, options: import("./types").HookRunPerItemOptions) => (context: import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>) => Promise<import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>>;
7
+ runPerItem: (actionPerItem: (item: any, context: import("@feathersjs/feathers").HookContext<any, import("@feathersjs/feathers").Service<any>>) => any, options: import("./types").HookRunPerItemOptions) => import("./types").ReturnAsyncHook;
8
8
  };
9
9
  export { checkMulti };
10
10
  export { setData };
package/dist/types.d.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import type { Application, HookContext, Service } from "@feathersjs/feathers";
2
2
  export declare type Path = Array<string | number>;
3
+ export declare type MaybeArray<T> = T | T[];
4
+ export declare type Promisable<T> = T | Promise<T>;
3
5
  export declare type HookType = "before" | "after" | "error";
4
6
  export declare type ServiceMethodName = "find" | "get" | "create" | "update" | "patch" | "remove";
7
+ export declare type ReturnSyncHook = (context: HookContext) => HookContext;
8
+ export declare type ReturnAsyncHook = (context: HookContext) => Promise<HookContext>;
5
9
  export declare type Handle = "target" | "source" | "combine" | "intersect" | "intersectOrFull";
6
10
  export declare type FirstLast = "first" | "last";
7
11
  export declare type Predicate<T = any> = (item: T) => boolean;
@@ -3,11 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getItemsIsArray = void 0;
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  const getItemsIsArray = (context) => {
6
- let itemOrItems = context.type === "before" ? context.data : context.result;
7
- itemOrItems = itemOrItems && context.method === "find" ? (itemOrItems.data || itemOrItems) : itemOrItems;
6
+ let itemOrItems = context.type === "before"
7
+ ? context.data
8
+ : context.result;
9
+ itemOrItems = itemOrItems && context.method === "find"
10
+ ? (itemOrItems.data || itemOrItems)
11
+ : itemOrItems;
8
12
  const isArray = Array.isArray(itemOrItems);
9
13
  return {
10
- items: (isArray) ? itemOrItems : [itemOrItems],
14
+ items: (isArray)
15
+ ? itemOrItems
16
+ : (itemOrItems != null)
17
+ ? [itemOrItems]
18
+ : [],
11
19
  isArray
12
20
  };
13
21
  };
@@ -1,3 +1,3 @@
1
1
  import type { HookContext } from "@feathersjs/feathers";
2
- import type { HookType } from "feathers-hooks-common/types";
3
- export declare function markHookForSkip<T>(hookName: string, type: "all" | HookType | HookType[], context?: Partial<HookContext<T>>): Partial<HookContext<T>>;
2
+ import type { HookType, MaybeArray } from "../types";
3
+ export declare function markHookForSkip<T>(hookName: string, type: "all" | MaybeArray<HookType>, context?: Partial<HookContext<T>>): Partial<HookContext<T>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feathers-utils",
3
- "version": "1.9.0",
3
+ "version": "1.9.4",
4
4
  "description": "Some utils for projects using '@feathersjs/feathers'",
5
5
  "author": "fratzinger",
6
6
  "repository": {
@@ -42,28 +42,26 @@
42
42
  "@feathersjs/adapter-commons": "^4.5.12",
43
43
  "@feathersjs/errors": "^4.5.12",
44
44
  "@feathersjs/feathers": "^4.5.12",
45
- "feathers-hooks-common": "^5.0.6",
46
- "lodash": "^4.17.21",
47
- "type-fest": "^2.11.1"
45
+ "lodash": "^4.17.21"
48
46
  },
49
47
  "devDependencies": {
50
48
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
51
49
  "@types/lodash": "^4.14.178",
52
50
  "@types/mocha": "^9.1.0",
53
- "@types/node": "^17.0.14",
54
- "@typescript-eslint/eslint-plugin": "^5.10.2",
55
- "@typescript-eslint/parser": "^5.10.2",
51
+ "@types/node": "^17.0.19",
52
+ "@typescript-eslint/eslint-plugin": "^5.12.0",
53
+ "@typescript-eslint/parser": "^5.12.0",
56
54
  "cross-env": "^7.0.3",
57
- "eslint": "^8.8.0",
55
+ "eslint": "^8.9.0",
58
56
  "eslint-import-resolver-typescript": "^2.5.0",
59
57
  "eslint-plugin-import": "^2.25.4",
60
58
  "eslint-plugin-security": "^1.4.0",
61
59
  "feathers-memory": "^4.1.0",
62
- "mocha": "^9.2.0",
60
+ "mocha": "^9.2.1",
63
61
  "np": "^7.6.0",
64
62
  "nyc": "^15.1.0",
65
63
  "shx": "^0.3.4",
66
- "ts-node": "^10.4.0",
64
+ "ts-node": "^10.5.0",
67
65
  "typescript": "^4.5.5"
68
66
  }
69
67
  }
@@ -3,8 +3,10 @@ import { shouldSkip } from "../utils/shouldSkip";
3
3
  import { isMulti } from "../utils/isMulti";
4
4
 
5
5
  import type { HookContext } from "@feathersjs/feathers";
6
+ import type { ReturnSyncHook } from "../types";
6
7
 
7
- export function checkMulti(): ((context: HookContext) => HookContext) {
8
+ export function checkMulti(
9
+ ): ReturnSyncHook {
8
10
  return (context: HookContext): HookContext => {
9
11
  if (shouldSkip("checkMulti", context)) { return context; }
10
12
  const { service, method } = context;
@@ -1,10 +1,8 @@
1
- import { getItems } from "feathers-hooks-common";
2
-
3
1
  import { shouldSkip } from "../utils/shouldSkip";
4
2
 
5
- import type { HookRunPerItemOptions } from "../types";
3
+ import type { HookRunPerItemOptions, ReturnAsyncHook, Promisable } from "../types";
6
4
  import type { HookContext } from "@feathersjs/feathers";
7
- import type { Promisable } from "type-fest";
5
+ import { getItemsIsArray } from "../utils/getItemsIsArray";
8
6
 
9
7
  const makeOptions = (
10
8
  options: HookRunPerItemOptions
@@ -19,13 +17,11 @@ export const runPerItem = (
19
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
18
  actionPerItem: (item: any, context: HookContext) => Promisable<any>,
21
19
  options: HookRunPerItemOptions
22
- ): ((context: HookContext) => Promise<HookContext>) => {
20
+ ): ReturnAsyncHook => {
23
21
  options = makeOptions(options);
24
22
  return async (context: HookContext): Promise<HookContext> => {
25
23
  if (shouldSkip("runForItems", context)) { return context; }
26
- let items = getItems(context);
27
- items = (Array.isArray(items)) ? items : [items];
28
-
24
+ const { items } = getItemsIsArray(context);
29
25
  const promises = items.map(async (item: unknown) => {
30
26
  await actionPerItem(item, context);
31
27
  });
@@ -2,16 +2,16 @@ import _get from "lodash/get";
2
2
  import _set from "lodash/set";
3
3
  import _has from "lodash/has";
4
4
 
5
- import { getItems } from "feathers-hooks-common";
6
-
7
5
  import { Forbidden } from "@feathersjs/errors";
6
+ import { getItemsIsArray } from "../utils/getItemsIsArray";
8
7
 
9
8
  import type { HookContext } from "@feathersjs/feathers";
9
+ import type { PropertyPath } from "lodash";
10
10
 
11
11
  import type {
12
- HookSetDataOptions
12
+ HookSetDataOptions,
13
+ ReturnSyncHook
13
14
  } from "../types";
14
- import type { PropertyPath } from "lodash";
15
15
 
16
16
  const defaultOptions: Required<HookSetDataOptions> = {
17
17
  allowUndefined: false,
@@ -22,12 +22,11 @@ export function setData(
22
22
  from: PropertyPath,
23
23
  to: PropertyPath,
24
24
  _options?: HookSetDataOptions
25
- ): ((context: HookContext) => HookContext) {
25
+ ): ReturnSyncHook {
26
26
  const options: Required<HookSetDataOptions> = Object.assign({}, defaultOptions, _options);
27
27
  return (context: HookContext): HookContext => {
28
28
 
29
- let items = getItems(context);
30
- items = (Array.isArray(items)) ? items : [items];
29
+ const { items } = getItemsIsArray(context);
31
30
 
32
31
  if (!_has(context, from)) {
33
32
  if (!context.params?.provider || options.allowUndefined === true) {
@@ -10,7 +10,9 @@ import type {
10
10
  DebouncedStoreOptions,
11
11
  } from "../../types";
12
12
 
13
- export function debounceMixin(options?: Partial<InitDebounceMixinOptions>): ((app: Application) => void) {
13
+ export function debounceMixin(
14
+ options?: Partial<InitDebounceMixinOptions>
15
+ ): ((app: Application) => void) {
14
16
  return (app: Application): void => {
15
17
  options = options || {};
16
18
  const defaultOptions = Object.assign(makeDefaultOptions(), options?.default);
package/src/types.ts CHANGED
@@ -1,8 +1,13 @@
1
1
  import type { Application, HookContext, Service } from "@feathersjs/feathers";
2
2
 
3
3
  export type Path = Array<string|number>;
4
+ export type MaybeArray<T> = T | T[]
5
+ export type Promisable<T> = T | Promise<T>
6
+
4
7
  export type HookType = "before" | "after" | "error";
5
8
  export type ServiceMethodName = "find" | "get" | "create" | "update" | "patch" | "remove";
9
+ export type ReturnSyncHook = (context: HookContext) => HookContext
10
+ export type ReturnAsyncHook = (context: HookContext) => Promise<HookContext>
6
11
 
7
12
  export type Handle = "target" | "source" | "combine" | "intersect"| "intersectOrFull";
8
13
  export type FirstLast = "first" | "last";
@@ -8,7 +8,11 @@ const defaultOptions = (): Partial<AddHookOptions> => {
8
8
  };
9
9
  };
10
10
 
11
- export const addHook = (app: Application, hook: unknown, options: AddHookOptions): void => {
11
+ export const addHook = (
12
+ app: Application,
13
+ hook: unknown,
14
+ options: AddHookOptions
15
+ ): void => {
12
16
  options = Object.assign(defaultOptions(), options);
13
17
 
14
18
  const {
@@ -5,11 +5,19 @@ import type { GetItemsIsArrayOptions } from "..";
5
5
  export const getItemsIsArray = <T = any>(
6
6
  context: HookContext
7
7
  ): GetItemsIsArrayOptions<T> => {
8
- let itemOrItems = context.type === "before" ? context.data : context.result;
9
- itemOrItems = itemOrItems && context.method === "find" ? (itemOrItems.data || itemOrItems) : itemOrItems;
8
+ let itemOrItems = context.type === "before"
9
+ ? context.data
10
+ : context.result;
11
+ itemOrItems = itemOrItems && context.method === "find"
12
+ ? (itemOrItems.data || itemOrItems)
13
+ : itemOrItems;
10
14
  const isArray = Array.isArray(itemOrItems);
11
15
  return {
12
- items: (isArray) ? itemOrItems : [itemOrItems],
16
+ items: (isArray)
17
+ ? itemOrItems
18
+ : (itemOrItems != null)
19
+ ? [itemOrItems]
20
+ : [],
13
21
  isArray
14
22
  };
15
23
  };
@@ -1,6 +1,8 @@
1
1
  import type { HookContext } from "@feathersjs/feathers";
2
2
 
3
- export const isMulti = (context: HookContext): boolean => {
3
+ export const isMulti = (
4
+ context: HookContext
5
+ ): boolean => {
4
6
  const { method } = context;
5
7
  if (method === "find") {
6
8
  return true;
@@ -1,11 +1,11 @@
1
1
  import { pushSet } from "./pushSet";
2
2
 
3
3
  import type { HookContext } from "@feathersjs/feathers";
4
- import type { HookType } from "feathers-hooks-common/types";
4
+ import type { HookType, MaybeArray } from "../types";
5
5
 
6
6
  export function markHookForSkip<T>(
7
7
  hookName: string,
8
- type: "all" | HookType | HookType[],
8
+ type: "all" | MaybeArray<HookType>,
9
9
  context?: Partial<HookContext<T>>
10
10
  ): Partial<HookContext<T>> {
11
11
  context = context || {};
@@ -5,7 +5,10 @@ import { GeneralError } from "@feathersjs/errors";
5
5
 
6
6
  import type { HookContext } from "@feathersjs/feathers";
7
7
 
8
- export const shouldSkip = (hookName: string, context: HookContext): boolean => {
8
+ export const shouldSkip = (
9
+ hookName: string,
10
+ context: HookContext
11
+ ): boolean => {
9
12
  if (!context.params || !context.params.skipHooks) {
10
13
  return false;
11
14
  }