From c021f2f2b3fecbe089825a3391b4ef1bc7e26f42 Mon Sep 17 00:00:00 2001 From: fratzinger <22286818+fratzinger@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:06:48 +0100 Subject: [PATCH 1/5] modernize --- .eslintrc | 137 - README.md | 18 + docs/.vitepress/config.mts | 80 +- docs/.vitepress/meta.ts | 8 +- docs/.vitepress/theme/index.ts | 6 +- eslint.config.mjs | 51 + package-lock.json | 22011 ++++------------ package.json | 60 +- src/common/index.ts | 1 - src/common/pluck.ts | 24 - .../act-on-dispatch}/act-on-dispatch.test.ts | 3 +- .../{ => act-on-dispatch}/act-on-dispatch.ts | 6 +- src/hooks/alter-items/alter-data.test.ts | 96 + src/hooks/alter-items/alter-data.ts | 20 + .../hooks/alter-items}/alter-items.test.ts | 2 +- src/hooks/{ => alter-items}/alter-items.ts | 7 +- src/hooks/alter-items/alter-result.test.ts | 143 + src/hooks/alter-items/alter-result.ts | 26 + {test/hooks => src/hooks/cache}/cache.test.ts | 2 +- src/hooks/{ => cache}/cache.ts | 4 +- .../hooks/de-populate}/de-populate.test.ts | 7 +- src/hooks/{ => de-populate}/de-populate.ts | 3 +- {test/hooks => src/hooks/debug}/debug.test.ts | 2 +- src/hooks/{ => debug}/debug.ts | 2 - .../disable-pagination.test.ts | 2 +- .../disable-pagination.ts | 5 +- .../hooks/disallow}/disallow.test.ts | 9 +- src/hooks/{ => disallow}/disallow.ts | 2 +- src/hooks/discard-query.ts | 19 - .../hooks/fast-join}/fast-join-cache.test.ts | 19 +- .../hooks/fast-join}/fast-join.test.ts | 6 +- src/hooks/{ => fast-join}/fast-join.ts | 28 +- .../hooks/fast-join/test}/make-services.ts | 0 .../hooks/fgraphql}/fgraphql.test.ts | 15 +- src/hooks/{ => fgraphql}/fgraphql.ts | 5 +- .../hooks/iff/iff-else.test.ts | 9 +- src/hooks/{ => iff}/iff-else.ts | 6 +- {test/hooks => src/hooks/iff}/iff.test.ts | 10 +- src/hooks/{ => iff}/iff.ts | 2 +- src/hooks/index.ts | 62 + .../keep-in-array}/keep-in-array.test.ts | 2 +- .../{ => keep-in-array}/keep-in-array.ts | 2 +- .../keep-query-in-array.test.ts | 2 +- .../keep-query-in-array.ts | 2 +- src/hooks/keep-query.ts | 18 - src/hooks/lowercase/lowercase-data.test.ts | 96 + src/hooks/lowercase/lowercase-data.ts | 26 + src/hooks/lowercase/lowercase-result.test.ts | 54 + src/hooks/lowercase/lowercase-result.ts | 26 + .../hooks/lowercase}/lowercase.test.ts | 4 +- .../{lower-case.ts => lowercase/lowercase.ts} | 14 +- .../hooks/mongo-keys}/mongo-keys.test.ts | 2 +- src/hooks/{ => mongo-keys}/mongo-keys.ts | 2 +- .../hooks/omit-query/omit-query.test.ts | 20 +- src/hooks/omit-query/omit-query.ts | 20 + .../hooks/omit/omit-1.test.ts | 8 +- .../hooks/omit/omit-2.test.ts | 10 +- src/hooks/omit/omit-data-1.test.ts | 91 + src/hooks/omit/omit-data.test.ts | 94 + src/hooks/omit/omit-data.ts | 12 + src/hooks/omit/omit-result-1.test.ts | 86 + src/hooks/omit/omit-result-2.test.ts | 121 + src/hooks/omit/omit-result.test.ts | 109 + src/hooks/omit/omit-result.ts | 12 + .../hooks/omit/omit.test.ts | 32 +- src/hooks/{discard.ts => omit/omit.ts} | 14 +- .../params-from-client.test.ts | 2 +- .../params-from-client.ts | 0 .../hooks/pick-query/pick-query.test.ts | 22 +- src/hooks/pick-query/pick-query.ts | 21 + src/hooks/pick/pick-data.test.ts | 153 + src/hooks/pick/pick-data.ts | 17 + src/hooks/pick/pick-result.test.ts | 77 + src/hooks/pick/pick-result.ts | 17 + .../hooks/pick/pick.test.ts | 40 +- src/hooks/{keep.ts => pick/pick.ts} | 24 +- .../populate}/populate-1deep-1child.test.ts | 11 +- .../hooks/populate}/populate-basics.test.ts | 7 +- .../hooks/populate}/populate-misc.test.ts | 19 +- .../populate}/populate-relations.test.ts | 11 +- .../populate}/populate-scaffolding.test.ts | 2 +- src/hooks/{ => populate}/populate.ts | 3 +- .../hooks/populate/test}/config-app.ts | 20 +- .../hooks/populate/test}/get-init-db.ts | 0 src/hooks/prevent-changes.ts | 41 - .../prevent-changes}/prevent-changes.test.ts | 72 +- src/hooks/prevent-changes/prevent-changes.ts | 25 + .../hooks/required}/required.test.ts | 2 +- src/hooks/{ => required}/required.ts | 27 +- .../hooks/run-parallel}/run-parallel.test.ts | 2 +- src/hooks/{ => run-parallel}/run-parallel.ts | 2 +- .../sequelize-convert.test.ts | 2 +- .../sequelize-convert.ts | 3 +- .../hooks/serialize}/serialize.test.ts | 9 +- src/hooks/{ => serialize}/serialize.ts | 5 +- .../hooks/set-field}/set-field.test.ts | 4 +- src/hooks/{ => set-field}/set-field.ts | 2 +- src/hooks/set-now/set-now-data.test.ts | 136 + src/hooks/set-now/set-now-data.ts | 16 + src/hooks/set-now/set-now-result.test.ts | 69 + src/hooks/set-now/set-now-result.ts | 16 + .../hooks/set-now}/set-now.test.ts | 7 +- src/hooks/{ => set-now}/set-now.ts | 8 +- .../hooks/set-slug}/set-slug.test.ts | 2 +- src/hooks/{ => set-slug}/set-slug.ts | 5 - src/hooks/sifter.ts | 28 - .../hooks => src/hooks/sifter}/sifter.test.ts | 21 +- src/hooks/sifter/sifter.ts | 20 + .../hooks/soft-delete}/soft-delete.test.ts | 2 +- src/hooks/{ => soft-delete}/soft-delete.ts | 3 +- .../hooks/stash-before}/stash-before.test.ts | 13 +- src/hooks/{ => stash-before}/stash-before.ts | 2 +- .../hooks/traverse}/traverse.test.ts | 11 +- src/hooks/{ => traverse}/traverse.ts | 6 +- .../hooks => src/hooks/unless}/unless.test.ts | 10 +- src/hooks/{ => unless}/unless.ts | 2 +- .../validate-schema}/validate-schema.test.ts | 2 +- .../{ => validate-schema}/validate-schema.ts | 4 +- .../hooks/validate}/validate.test.ts | 9 +- src/hooks/{ => validate}/validate.ts | 6 +- src/index.ts | 51 +- src/types.ts | 12 +- .../calling-params}/calling-params-1.test.ts | 2 +- .../calling-params}/calling-params-2.test.ts | 2 +- .../{ => calling-params}/calling-params.ts | 0 src/utils/check-context-if.ts | 2 +- .../check-context}/check-context.test.ts | 2 +- .../{ => check-context}/check-context.ts | 4 +- .../utils/combine}/combine.test.ts | 13 +- src/utils/{ => combine}/combine.ts | 5 +- {test/utils => src/utils/every}/every.test.ts | 3 +- src/utils/{ => every}/every.ts | 2 +- .../get-data-is-array.test.ts | 31 + .../get-data-is-array/get-data-is-array.ts | 19 + src/utils/get-items/get-items.test.ts | 117 + src/utils/{ => get-items}/get-items.ts | 2 + .../get-result-is-array.test.ts | 59 + .../get-result-is-array.ts | 26 + src/utils/index.ts | 20 + .../utils => src/utils/is-not}/is-not.test.ts | 11 +- src/utils/{ => is-not}/is-not.ts | 4 +- .../utils/is-provider}/is-provider.test.ts | 11 +- src/utils/{ => is-provider}/is-provider.ts | 2 +- .../params-for-server.test.ts | 2 +- .../params-for-server.ts | 0 src/utils/replace-items/replace-data.ts | 43 + src/utils/replace-items/replace-items.test.ts | 132 + .../{ => replace-items}/replace-items.ts | 2 + src/utils/replace-items/replace-result.ts | 60 + .../utils/run-hook}/run-hook.test.ts | 3 +- src/utils/{ => run-hook}/run-hook.ts | 0 {test/utils => src/utils/some}/some.test.ts | 4 +- src/utils/{ => some}/some.ts | 0 test/hooks/get-replace-items.test.ts | 241 - test/hooks/iff-else.test.ts | 681 - test/hooks/when.test.ts | 403 - test/index.test.ts | 47 +- vite.config.ts | 12 +- 158 files changed, 7754 insertions(+), 19113 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs delete mode 100755 src/common/pluck.ts rename {test/hooks => src/hooks/act-on-dispatch}/act-on-dispatch.test.ts (95%) rename src/hooks/{ => act-on-dispatch}/act-on-dispatch.ts (88%) create mode 100755 src/hooks/alter-items/alter-data.test.ts create mode 100755 src/hooks/alter-items/alter-data.ts rename {test/hooks => src/hooks/alter-items}/alter-items.test.ts (99%) rename src/hooks/{ => alter-items}/alter-items.ts (88%) create mode 100755 src/hooks/alter-items/alter-result.test.ts create mode 100755 src/hooks/alter-items/alter-result.ts rename {test/hooks => src/hooks/cache}/cache.test.ts (99%) rename src/hooks/{ => cache}/cache.ts (95%) rename {test/hooks => src/hooks/de-populate}/de-populate.test.ts (98%) rename src/hooks/{ => de-populate}/de-populate.ts (89%) rename {test/hooks => src/hooks/debug}/debug.test.ts (93%) rename src/hooks/{ => debug}/debug.ts (96%) rename {test/hooks => src/hooks/disable-pagination}/disable-pagination.test.ts (94%) rename src/hooks/{ => disable-pagination}/disable-pagination.ts (80%) rename {test/hooks => src/hooks/disallow}/disallow.test.ts (96%) rename src/hooks/{ => disallow}/disallow.ts (94%) delete mode 100755 src/hooks/discard-query.ts rename {test/hooks => src/hooks/fast-join}/fast-join-cache.test.ts (96%) rename {test/hooks => src/hooks/fast-join}/fast-join.test.ts (99%) rename src/hooks/{ => fast-join}/fast-join.ts (88%) rename {test/helpers => src/hooks/fast-join/test}/make-services.ts (100%) rename {test/hooks => src/hooks/fgraphql}/fgraphql.test.ts (97%) rename src/hooks/{ => fgraphql}/fgraphql.ts (98%) rename test/hooks/iffelse.test.ts => src/hooks/iff/iff-else.test.ts (97%) rename src/hooks/{ => iff}/iff-else.ts (90%) rename {test/hooks => src/hooks/iff}/iff.test.ts (98%) rename src/hooks/{ => iff}/iff.ts (93%) create mode 100644 src/hooks/index.ts rename {test/hooks => src/hooks/keep-in-array}/keep-in-array.test.ts (99%) rename src/hooks/{ => keep-in-array}/keep-in-array.ts (96%) rename {test/hooks => src/hooks/keep-query-in-array}/keep-query-in-array.test.ts (98%) rename src/hooks/{ => keep-query-in-array}/keep-query-in-array.ts (96%) delete mode 100755 src/hooks/keep-query.ts create mode 100755 src/hooks/lowercase/lowercase-data.test.ts create mode 100755 src/hooks/lowercase/lowercase-data.ts create mode 100755 src/hooks/lowercase/lowercase-result.test.ts create mode 100755 src/hooks/lowercase/lowercase-result.ts rename {test/hooks => src/hooks/lowercase}/lowercase.test.ts (98%) rename src/hooks/{lower-case.ts => lowercase/lowercase.ts} (72%) rename {test/hooks => src/hooks/mongo-keys}/mongo-keys.test.ts (98%) rename src/hooks/{ => mongo-keys}/mongo-keys.ts (97%) rename test/hooks/discard-query.test.ts => src/hooks/omit-query/omit-query.test.ts (81%) create mode 100755 src/hooks/omit-query/omit-query.ts rename test/hooks/discard-1.test.ts => src/hooks/omit/omit-1.test.ts (96%) rename test/hooks/discard-2.test.ts => src/hooks/omit/omit-2.test.ts (94%) create mode 100755 src/hooks/omit/omit-data-1.test.ts create mode 100755 src/hooks/omit/omit-data.test.ts create mode 100755 src/hooks/omit/omit-data.ts create mode 100755 src/hooks/omit/omit-result-1.test.ts create mode 100755 src/hooks/omit/omit-result-2.test.ts create mode 100755 src/hooks/omit/omit-result.test.ts create mode 100755 src/hooks/omit/omit-result.ts rename test/hooks/discard.test.ts => src/hooks/omit/omit.test.ts (86%) rename src/hooks/{discard.ts => omit/omit.ts} (56%) rename {test/hooks => src/hooks/params-from-client}/params-from-client.test.ts (98%) rename src/hooks/{ => params-from-client}/params-from-client.ts (100%) rename test/hooks/keep-query.test.ts => src/hooks/pick-query/pick-query.test.ts (81%) create mode 100755 src/hooks/pick-query/pick-query.ts create mode 100755 src/hooks/pick/pick-data.test.ts create mode 100755 src/hooks/pick/pick-data.ts create mode 100755 src/hooks/pick/pick-result.test.ts create mode 100755 src/hooks/pick/pick-result.ts rename test/hooks/keep.test.ts => src/hooks/pick/pick.test.ts (88%) rename src/hooks/{keep.ts => pick/pick.ts} (57%) rename {test/hooks => src/hooks/populate}/populate-1deep-1child.test.ts (98%) rename {test/hooks => src/hooks/populate}/populate-basics.test.ts (96%) rename {test/hooks => src/hooks/populate}/populate-misc.test.ts (96%) rename {test/hooks => src/hooks/populate}/populate-relations.test.ts (98%) rename {test/hooks => src/hooks/populate}/populate-scaffolding.test.ts (94%) rename src/hooks/{ => populate}/populate.ts (99%) rename {test/helpers => src/hooks/populate/test}/config-app.ts (51%) rename {test/helpers => src/hooks/populate/test}/get-init-db.ts (100%) delete mode 100755 src/hooks/prevent-changes.ts rename {test/hooks => src/hooks/prevent-changes}/prevent-changes.test.ts (58%) create mode 100755 src/hooks/prevent-changes/prevent-changes.ts rename {test/hooks => src/hooks/required}/required.test.ts (95%) rename src/hooks/{ => required}/required.ts (57%) rename {test/hooks => src/hooks/run-parallel}/run-parallel.test.ts (97%) rename src/hooks/{ => run-parallel}/run-parallel.ts (93%) rename {test/hooks => src/hooks/sequelize-convert}/sequelize-convert.test.ts (99%) rename src/hooks/{ => sequelize-convert}/sequelize-convert.ts (95%) rename {test/hooks => src/hooks/serialize}/serialize.test.ts (97%) rename src/hooks/{ => serialize}/serialize.ts (94%) rename {test/hooks => src/hooks/set-field}/set-field.test.ts (98%) rename src/hooks/{ => set-field}/set-field.ts (96%) create mode 100755 src/hooks/set-now/set-now-data.test.ts create mode 100755 src/hooks/set-now/set-now-data.ts create mode 100755 src/hooks/set-now/set-now-result.test.ts create mode 100755 src/hooks/set-now/set-now-result.ts rename {test/hooks => src/hooks/set-now}/set-now.test.ts (98%) rename src/hooks/{ => set-now}/set-now.ts (68%) rename {test/hooks => src/hooks/set-slug}/set-slug.test.ts (97%) rename src/hooks/{ => set-slug}/set-slug.ts (79%) delete mode 100755 src/hooks/sifter.ts rename {test/hooks => src/hooks/sifter}/sifter.test.ts (74%) create mode 100755 src/hooks/sifter/sifter.ts rename {test/hooks => src/hooks/soft-delete}/soft-delete.test.ts (99%) rename src/hooks/{ => soft-delete}/soft-delete.ts (95%) rename {test/hooks => src/hooks/stash-before}/stash-before.test.ts (92%) rename src/hooks/{ => stash-before}/stash-before.ts (96%) rename {test/common => src/hooks/traverse}/traverse.test.ts (94%) rename src/hooks/{ => traverse}/traverse.ts (81%) rename {test/hooks => src/hooks/unless}/unless.test.ts (98%) rename src/hooks/{ => unless}/unless.ts (87%) rename {test/hooks => src/hooks/validate-schema}/validate-schema.test.ts (99%) rename src/hooks/{ => validate-schema}/validate-schema.ts (95%) rename {test/hooks => src/hooks/validate}/validate.test.ts (95%) rename src/hooks/{ => validate}/validate.ts (91%) rename {test/utils => src/utils/calling-params}/calling-params-1.test.ts (98%) rename {test/utils => src/utils/calling-params}/calling-params-2.test.ts (97%) rename src/utils/{ => calling-params}/calling-params.ts (100%) rename {test/utils => src/utils/check-context}/check-context.test.ts (98%) rename src/utils/{ => check-context}/check-context.ts (91%) rename {test/utils => src/utils/combine}/combine.test.ts (94%) rename src/utils/{ => combine}/combine.ts (89%) rename {test/utils => src/utils/every}/every.test.ts (97%) rename src/utils/{ => every}/every.ts (89%) create mode 100644 src/utils/get-data-is-array/get-data-is-array.test.ts create mode 100644 src/utils/get-data-is-array/get-data-is-array.ts create mode 100644 src/utils/get-items/get-items.test.ts rename src/utils/{ => get-items}/get-items.ts (89%) create mode 100644 src/utils/get-result-is-array/get-result-is-array.test.ts create mode 100644 src/utils/get-result-is-array/get-result-is-array.ts create mode 100644 src/utils/index.ts rename {test/utils => src/utils/is-not}/is-not.test.ts (94%) rename src/utils/{ => is-not}/is-not.ts (88%) rename {test/hooks => src/utils/is-provider}/is-provider.test.ts (94%) rename src/utils/{ => is-provider}/is-provider.ts (93%) rename {test/utils => src/utils/params-for-server}/params-for-server.test.ts (95%) rename src/utils/{ => params-for-server}/params-for-server.ts (100%) create mode 100644 src/utils/replace-items/replace-data.ts create mode 100644 src/utils/replace-items/replace-items.test.ts rename src/utils/{ => replace-items}/replace-items.ts (93%) create mode 100644 src/utils/replace-items/replace-result.ts rename {test/utils => src/utils/run-hook}/run-hook.test.ts (97%) rename src/utils/{ => run-hook}/run-hook.ts (100%) rename {test/utils => src/utils/some}/some.test.ts (96%) rename src/utils/{ => some}/some.ts (100%) delete mode 100755 test/hooks/get-replace-items.test.ts delete mode 100755 test/hooks/iff-else.test.ts delete mode 100755 test/hooks/when.test.ts diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index e7ab5c05..00000000 --- a/.eslintrc +++ /dev/null @@ -1,137 +0,0 @@ -{ - "root": true, - "env": { - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": ["./tsconfig.json"] - }, - "plugins": [ - "eslint-plugin-import", - "eslint-plugin-prefer-arrow", - "@typescript-eslint", - "prettier" - ], - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "plugin:prettier/recommended" - ], - "rules": { - // "indent": ["warn", 2], - "prefer-rest-params": "off", - "prefer-spread": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-floating-promises": "off", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/require-await": "off", - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/unbound-method": "off", - "@typescript-eslint/no-this-alias": "off", - "@typescript-eslint/prefer-regexp-exec": "off", - "@typescript-eslint/no-misused-promises": "off", - "@typescript-eslint/restrict-plus-operands": "off", - // ---- - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/array-type": [ - "error", - { - "default": "array" - } - ], - "@typescript-eslint/ban-types": "off", - "@typescript-eslint/consistent-type-assertions": "error", - "@typescript-eslint/dot-notation": "error", - "@typescript-eslint/explicit-member-accessibility": [ - "error", - { - "accessibility": "no-public" - } - ], - "@typescript-eslint/naming-convention": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-empty-interface": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-misused-new": "error", - "@typescript-eslint/no-namespace": "error", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-unused-expressions": "error", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/prefer-function-type": "error", - "@typescript-eslint/prefer-namespace-keyword": "error", - "@typescript-eslint/triple-slash-reference": [ - "error", - { - "path": "always", - "types": "prefer-import", - "lib": "always" - } - ], - "@typescript-eslint/unified-signatures": "error", - "@typescript-eslint/consistent-type-imports": ["warn", { "prefer": "type-imports" }], - "arrow-parens": ["off", "always"], - "complexity": "off", - "constructor-super": "error", - "eqeqeq": ["error", "smart"], - "guard-for-in": "error", - "id-blacklist": "off", - "id-match": "off", - "import/order": "off", - "max-classes-per-file": "off", - "max-len": "off", - "no-bitwise": "error", - "no-caller": "error", - "no-cond-assign": "error", - "no-console": "error", - "no-debugger": "error", - "no-empty": "off", - "no-eval": "error", - "no-fallthrough": "off", - "no-invalid-this": "off", - "no-new-wrappers": "error", - "no-shadow": [ - "off", - { - "hoist": "all" - } - ], - "no-throw-literal": "error", - "no-undef-init": "error", - "no-underscore-dangle": "off", - "no-unsafe-finally": "error", - "no-unused-labels": "error", - "no-var": "error", - "object-shorthand": "error", - "one-var": ["error", "never"], - "prefer-arrow/prefer-arrow-functions": "off", - "prefer-const": "error", - "radix": "error", - "spaced-comment": [ - "error", - "always", - { - "markers": ["/"] - } - ], - "use-isnan": "error", - "valid-typeof": "off" - }, - "overrides": [ - { - "files": ["test/**/*.ts"], - "rules": { - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/no-unused-vars": "off", - "no-console": "off" - } - } - ] -} diff --git a/README.md b/README.md index b97998b9..7c0505c2 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,23 @@ ## feathers-hooks-common +### WIP Changes: + +- added alterData, alterResult, deprecated alterItems +- added discardData, discardResult, deprecated discard + - moved to omitData, omitResult, deprecated omit +- added keepData, keepResult, deprecated keep + - moved to pickData, pickResult, deprecated pick +- added lowercaseData, lowercaseResult, deprecated lowercase +- added setNowData, setNowResult, deprecated setNow + +- added getDataIsArray, getResultIsArray, deprecated getItems +- added replaceData, replaceResult, deprecated replaceItems + +- removed several checks that are handled by typescript +- removed check for `preventChanges(true, ...fieldNames)` + +- renamed 'keepQuery' to 'pickQuery', added alias +
= (params: P) => P | void;
+
+export type DispatchOption = boolean | 'both';
diff --git a/src/utils/calling-params/calling-params.ts b/src/utils/calling-params/calling-params.ts
index 08ee037e..8a1e08b8 100755
--- a/src/utils/calling-params/calling-params.ts
+++ b/src/utils/calling-params/calling-params.ts
@@ -58,14 +58,15 @@ export function callingParamsDefaults(propNames: string[], newProps?: any): void
* Build params for a service call. (Utility function.)
* @see https://hooks-common.feathersjs.com/utilities.html#callingparams
*/
-export function callingParams (
+ params: P,
+ fn: TransformParamsFn | undefined,
+): P => {
+ if (!fn) {
+ return params;
+ }
+
+ const result = fn({ ...params });
+
+ return result ?? params;
+};
diff --git a/test/index.test.ts b/test/index.test.ts
index de9f42a6..67d80b94 100755
--- a/test/index.test.ts
+++ b/test/index.test.ts
@@ -72,6 +72,7 @@ const members = [
'replaceData',
'replaceResult',
+ 'checkRequired',
'required',
'runHook',
'runParallel',
@@ -96,13 +97,17 @@ const members = [
'iff',
'when',
'unless',
+
+ // predicates
'some',
'every',
'isNot',
-
- 'getPaginate',
+ 'not',
'isMulti',
'isPaginated',
+ 'isContext',
+
+ 'getPaginate',
'skipResult',
].sort();
From e6bb8c02d5ca1b22da936506dee17c2df9820d8c Mon Sep 17 00:00:00 2001
From: fratzinger <22286818+fratzinger@users.noreply.github.com>
Date: Tue, 18 Feb 2025 23:07:36 +0100
Subject: [PATCH 5/5] WIP
---
README.md | 15 +++++----------
src/predicates/not/not.ts | 1 -
src/utils/index.ts | 2 --
3 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index b9035ba5..07226b81 100755
--- a/README.md
+++ b/README.md
@@ -23,6 +23,10 @@
- added 'onDelete' & 'createRelated'
+- stashBefore multi
+
+- softDelete: added 'transformParams' & added 'key' option
+
- rm support for spread argument
#### predicates
@@ -37,16 +41,7 @@
- added getDataIsArray, getResultIsArray, deprecated getItems
- added replaceData, replaceResult, deprecated replaceItems
- added util getPaginate
-- added util setResultEmpty
-
-- add onDelete
-
-- stashBefore multi
-
-- new: createRelated
-- new: onDelete
-
-- softDelete: added 'transformParams' & added 'key' option
+- added util skipResult
### Hooks to discuss
diff --git a/src/predicates/not/not.ts b/src/predicates/not/not.ts
index 14709db2..6de6a03f 100755
--- a/src/predicates/not/not.ts
+++ b/src/predicates/not/not.ts
@@ -1,4 +1,3 @@
-import { MethodNotAllowed } from '@feathersjs/errors';
import type { HookContext } from '@feathersjs/feathers';
import { isPromise } from '../../common';
import type { PredicateFn } from '../../types';
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 0008a25e..7d39e7f6 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -16,6 +16,4 @@ export * from './replace-items/replace-result';
export * from './run-hook/run-hook';
export * from './get-paginate/get-paginate';
-export * from '../predicates/is-multi/is-multi';
-export * from '../predicates/is-paginated/is-paginated';
export * from './skip-result/skip-result';