feathers-utils 1.6.1 → 2.0.0-0

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 (84) hide show
  1. package/dist/esm/hooks/checkMulti.d.ts +2 -0
  2. package/dist/esm/hooks/checkMulti.js +18 -0
  3. package/dist/esm/hooks/runPerItem.d.ts +4 -0
  4. package/dist/esm/hooks/runPerItem.js +26 -0
  5. package/dist/esm/hooks/setData.d.ts +4 -0
  6. package/dist/esm/hooks/setData.js +34 -0
  7. package/dist/esm/index.d.ts +30 -0
  8. package/dist/esm/index.js +30 -0
  9. package/dist/esm/mixins/debounce-mixin/DebouncedStore.d.ts +15 -0
  10. package/dist/esm/mixins/debounce-mixin/DebouncedStore.js +46 -0
  11. package/dist/esm/mixins/debounce-mixin/index.d.ts +8 -0
  12. package/dist/esm/mixins/debounce-mixin/index.js +20 -0
  13. package/dist/esm/types.d.ts +60 -0
  14. package/dist/esm/types.js +2 -0
  15. package/dist/esm/utils/filterQuery.d.ts +3 -0
  16. package/dist/esm/utils/filterQuery.js +28 -0
  17. package/dist/esm/utils/getPaginate.d.ts +7 -0
  18. package/dist/esm/utils/getPaginate.js +14 -0
  19. package/dist/esm/utils/isMulti.d.ts +2 -0
  20. package/dist/esm/utils/isMulti.js +17 -0
  21. package/dist/esm/utils/isPaginated.d.ts +2 -0
  22. package/dist/esm/utils/isPaginated.js +8 -0
  23. package/dist/esm/utils/markHookForSkip.d.ts +3 -0
  24. package/dist/esm/utils/markHookForSkip.js +14 -0
  25. package/dist/esm/utils/mergeQuery/index.d.ts +3 -0
  26. package/dist/esm/utils/mergeQuery/index.js +327 -0
  27. package/dist/esm/utils/mergeQuery/mergeArrays.d.ts +2 -0
  28. package/dist/esm/utils/mergeQuery/mergeArrays.js +37 -0
  29. package/dist/esm/utils/pushSet.d.ts +2 -0
  30. package/dist/esm/utils/pushSet.js +19 -0
  31. package/dist/esm/utils/setResultEmpty.d.ts +2 -0
  32. package/dist/esm/utils/setResultEmpty.js +25 -0
  33. package/dist/esm/utils/shouldSkip.d.ts +2 -0
  34. package/dist/esm/utils/shouldSkip.js +29 -0
  35. package/dist/hooks/checkMulti.js +2 -2
  36. package/dist/hooks/runPerItem.d.ts +2 -1
  37. package/dist/hooks/runPerItem.js +3 -2
  38. package/dist/hooks/setData.js +7 -6
  39. package/dist/index.d.ts +6 -3
  40. package/dist/index.js +7 -3
  41. package/dist/mixins/debounce-mixin/DebouncedStore.d.ts +2 -2
  42. package/dist/mixins/debounce-mixin/DebouncedStore.js +2 -2
  43. package/dist/mixins/debounce-mixin/index.d.ts +4 -1
  44. package/dist/mixins/debounce-mixin/index.js +1 -1
  45. package/dist/types.d.ts +3 -2
  46. package/dist/utils/filterQuery.js +2 -2
  47. package/dist/utils/getPaginate.d.ts +7 -0
  48. package/dist/utils/getPaginate.js +15 -0
  49. package/dist/utils/isMulti.js +2 -3
  50. package/dist/utils/isPaginated.d.ts +2 -0
  51. package/dist/utils/isPaginated.js +12 -0
  52. package/dist/utils/markHookForSkip.js +1 -1
  53. package/dist/utils/mergeQuery/index.js +38 -38
  54. package/dist/utils/pushSet.js +3 -3
  55. package/dist/utils/setResultEmpty.d.ts +2 -0
  56. package/dist/utils/setResultEmpty.js +29 -0
  57. package/package.json +19 -13
  58. package/src/hooks/runPerItem.ts +4 -1
  59. package/src/hooks/setData.ts +1 -0
  60. package/src/index.ts +6 -3
  61. package/src/mixins/debounce-mixin/DebouncedStore.ts +1 -1
  62. package/src/mixins/debounce-mixin/index.ts +7 -3
  63. package/src/types.ts +4 -3
  64. package/src/utils/filterQuery.ts +2 -2
  65. package/src/utils/getPaginate.ts +26 -0
  66. package/src/utils/isMulti.ts +2 -3
  67. package/src/utils/isPaginated.ts +12 -0
  68. package/src/utils/setResultEmpty.ts +28 -0
  69. package/tsconfig-esm.json +9 -0
  70. package/.github/workflows/node.js.yml +0 -45
  71. package/.vscode/launch.json +0 -28
  72. package/.vscode/settings.json +0 -14
  73. package/dist/utils/addHook.d.ts +0 -3
  74. package/dist/utils/addHook.js +0 -40
  75. package/src/utils/addHook.ts +0 -49
  76. package/test/hooks/checkMulti.test.ts +0 -121
  77. package/test/hooks/setData.test.ts +0 -333
  78. package/test/mixins/debounce-mixin.test.ts +0 -174
  79. package/test/utils/addHook.test.ts +0 -307
  80. package/test/utils/isMulti.test.ts +0 -53
  81. package/test/utils/markHookForSkip.test.ts +0 -292
  82. package/test/utils/mergeQuery.test.ts +0 -407
  83. package/test/utils/pushSet.test.ts +0 -66
  84. package/test/utils/shouldSkip.test.ts +0 -67
@@ -1,66 +0,0 @@
1
- import assert from "assert";
2
- import { pushSet } from "../../src";
3
-
4
- describe("util - pushSet", function() {
5
- it("pushes to existing array", function() {
6
- const obj = {
7
- arr: [1]
8
- };
9
- pushSet(obj, ["arr"], 2);
10
- assert.deepStrictEqual(obj, { arr: [1, 2] });
11
- });
12
-
13
- it("sets array for not existing", function() {
14
- const obj = {};
15
- pushSet(obj, ["arr"], 2);
16
- assert.deepStrictEqual(obj, { arr: [2] });
17
- });
18
-
19
- it("adds existing element", function() {
20
- const obj = {
21
- arr: [1]
22
- };
23
- pushSet(obj, ["arr"], 1);
24
- assert.deepStrictEqual(obj, { arr: [1, 1] });
25
- });
26
-
27
- it("skips existing element", function() {
28
- const obj = {
29
- arr: [1]
30
- };
31
- pushSet(obj, ["arr"], 1, { unique: true });
32
- assert.deepStrictEqual(obj, { arr: [1] });
33
- });
34
-
35
- describe("deep dot notation", function() {
36
- it("deep: pushes to existing array", function() {
37
- const obj = {
38
- nested: { deep:[{ arr: [1] }] }
39
- };
40
- pushSet(obj, ["nested", "deep", 0, "arr"], 2);
41
- assert.deepStrictEqual(obj, { nested: { deep:[{ arr: [1, 2] }] } });
42
- });
43
-
44
- it("deep: sets array for not existing", function() {
45
- const obj = {};
46
- pushSet(obj, ["nested", "deep", 0, "arr"], 2);
47
- assert.deepStrictEqual(obj, { nested: { deep:[{ arr: [2] }] } });
48
- });
49
-
50
- it("deep: adds existing element", function() {
51
- const obj = {
52
- nested: { deep:[{ arr: [1] }] }
53
- };
54
- pushSet(obj, ["nested", "deep", 0, "arr"], 1);
55
- assert.deepStrictEqual(obj, { nested: { deep:[{ arr: [1, 1] }] } });
56
- });
57
-
58
- it("deep: skips existing element", function() {
59
- const obj = {
60
- nested: { deep:[{ arr: [1] }] }
61
- };
62
- pushSet(obj, ["nested", "deep", 0, "arr"], 1, { unique: true });
63
- assert.deepStrictEqual(obj, { nested: { deep:[{ arr: [1] }] } });
64
- });
65
- });
66
- });
@@ -1,67 +0,0 @@
1
- import assert from "assert";
2
- import { shouldSkip } from "../../src";
3
-
4
- describe("util - shouldSkip", function() {
5
- it("returns false if skipHooks not defined", function() {
6
- ["before", "after"].forEach(type => {
7
- ["find", "get", "create", "update", "patch", "remove"].forEach(method => {
8
- const context = { type, method };
9
- //@ts-ignore
10
- assert.strictEqual(shouldSkip("all", context), false, `'${type}:${method}': returns false`);
11
- });
12
- });
13
- });
14
-
15
- it("returns true for skipHooks: ['all']", function() {
16
- ["before", "after", "error"].forEach(type => {
17
- ["find", "get", "create", "update", "patch", "remove"].forEach(method => {
18
- const context = { type, method, params: { skipHooks: ["all"] } };
19
- //@ts-ignore
20
- assert.strictEqual(shouldSkip("test", context), true, `'${type}:${method}': returns true`);
21
- });
22
- });
23
- });
24
-
25
- it("returns true for skipHooks: [`type`]", function() {
26
- ["before", "after", "error"].forEach(type => {
27
- ["find", "get", "create", "update", "patch", "remove"].forEach(method => {
28
- const context = { type, method, params: { skipHooks: [type] } };
29
- //@ts-ignore
30
- assert.strictEqual(shouldSkip("test", context), true, `'${type}:${method}': returns true`);
31
- });
32
- });
33
- });
34
-
35
- it("returns true for skipHooks: ['`type`:test']", function() {
36
- ["before", "after", "error"].forEach(type => {
37
- ["find", "get", "create", "update", "patch", "remove"].forEach(method => {
38
- const context = { type, method, params: { skipHooks: [`${type}:test`] } };
39
- //@ts-ignore
40
- assert.strictEqual(shouldSkip("test", context), true, `'${type}:${method}': returns true`);
41
- });
42
- });
43
- });
44
-
45
- it("returns true for skipHooks: ['test']", function() {
46
- ["before", "after", "error"].forEach(type => {
47
- ["find", "get", "create", "update", "patch", "remove"].forEach(method => {
48
- const context = { type, method, params: { skipHooks: ["test"] } };
49
- //@ts-ignore
50
- assert.strictEqual(shouldSkip("test", context), true, `'${type}:${method}': returns true`);
51
- });
52
- });
53
- });
54
-
55
- it("returns false for skipHooks other than test", function() {
56
- const types = ["before", "after", "error"];
57
- types.forEach(type => {
58
- ["find", "get", "create", "update", "patch", "remove"].forEach(method => {
59
- const remainingTypes = types.filter(x => x !== type);
60
- const skipHooks = ["test2", `${type}:test2`, ...remainingTypes.map(t => `${t}:test1`)];
61
- const context = { type, method, params: { skipHooks } };
62
- //@ts-ignore
63
- assert.strictEqual(shouldSkip("test1", context), false, `'${type}:${method}': returns true`);
64
- });
65
- });
66
- });
67
- });