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.
- package/dist/esm/hooks/checkMulti.d.ts +2 -0
- package/dist/esm/hooks/checkMulti.js +18 -0
- package/dist/esm/hooks/runPerItem.d.ts +4 -0
- package/dist/esm/hooks/runPerItem.js +26 -0
- package/dist/esm/hooks/setData.d.ts +4 -0
- package/dist/esm/hooks/setData.js +34 -0
- package/dist/esm/index.d.ts +30 -0
- package/dist/esm/index.js +30 -0
- package/dist/esm/mixins/debounce-mixin/DebouncedStore.d.ts +15 -0
- package/dist/esm/mixins/debounce-mixin/DebouncedStore.js +46 -0
- package/dist/esm/mixins/debounce-mixin/index.d.ts +8 -0
- package/dist/esm/mixins/debounce-mixin/index.js +20 -0
- package/dist/esm/types.d.ts +60 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/utils/filterQuery.d.ts +3 -0
- package/dist/esm/utils/filterQuery.js +28 -0
- package/dist/esm/utils/getPaginate.d.ts +7 -0
- package/dist/esm/utils/getPaginate.js +14 -0
- package/dist/esm/utils/isMulti.d.ts +2 -0
- package/dist/esm/utils/isMulti.js +17 -0
- package/dist/esm/utils/isPaginated.d.ts +2 -0
- package/dist/esm/utils/isPaginated.js +8 -0
- package/dist/esm/utils/markHookForSkip.d.ts +3 -0
- package/dist/esm/utils/markHookForSkip.js +14 -0
- package/dist/esm/utils/mergeQuery/index.d.ts +3 -0
- package/dist/esm/utils/mergeQuery/index.js +327 -0
- package/dist/esm/utils/mergeQuery/mergeArrays.d.ts +2 -0
- package/dist/esm/utils/mergeQuery/mergeArrays.js +37 -0
- package/dist/esm/utils/pushSet.d.ts +2 -0
- package/dist/esm/utils/pushSet.js +19 -0
- package/dist/esm/utils/setResultEmpty.d.ts +2 -0
- package/dist/esm/utils/setResultEmpty.js +25 -0
- package/dist/esm/utils/shouldSkip.d.ts +2 -0
- package/dist/esm/utils/shouldSkip.js +29 -0
- package/dist/hooks/checkMulti.js +2 -2
- package/dist/hooks/runPerItem.d.ts +2 -1
- package/dist/hooks/runPerItem.js +3 -2
- package/dist/hooks/setData.js +7 -6
- package/dist/index.d.ts +6 -3
- package/dist/index.js +7 -3
- package/dist/mixins/debounce-mixin/DebouncedStore.d.ts +2 -2
- package/dist/mixins/debounce-mixin/DebouncedStore.js +2 -2
- package/dist/mixins/debounce-mixin/index.d.ts +4 -1
- package/dist/mixins/debounce-mixin/index.js +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/utils/filterQuery.js +2 -2
- package/dist/utils/getPaginate.d.ts +7 -0
- package/dist/utils/getPaginate.js +15 -0
- package/dist/utils/isMulti.js +2 -3
- package/dist/utils/isPaginated.d.ts +2 -0
- package/dist/utils/isPaginated.js +12 -0
- package/dist/utils/markHookForSkip.js +1 -1
- package/dist/utils/mergeQuery/index.js +38 -38
- package/dist/utils/pushSet.js +3 -3
- package/dist/utils/setResultEmpty.d.ts +2 -0
- package/dist/utils/setResultEmpty.js +29 -0
- package/package.json +19 -13
- package/src/hooks/runPerItem.ts +4 -1
- package/src/hooks/setData.ts +1 -0
- package/src/index.ts +6 -3
- package/src/mixins/debounce-mixin/DebouncedStore.ts +1 -1
- package/src/mixins/debounce-mixin/index.ts +7 -3
- package/src/types.ts +4 -3
- package/src/utils/filterQuery.ts +2 -2
- package/src/utils/getPaginate.ts +26 -0
- package/src/utils/isMulti.ts +2 -3
- package/src/utils/isPaginated.ts +12 -0
- package/src/utils/setResultEmpty.ts +28 -0
- package/tsconfig-esm.json +9 -0
- package/.github/workflows/node.js.yml +0 -45
- package/.vscode/launch.json +0 -28
- package/.vscode/settings.json +0 -14
- package/dist/utils/addHook.d.ts +0 -3
- package/dist/utils/addHook.js +0 -40
- package/src/utils/addHook.ts +0 -49
- package/test/hooks/checkMulti.test.ts +0 -121
- package/test/hooks/setData.test.ts +0 -333
- package/test/mixins/debounce-mixin.test.ts +0 -174
- package/test/utils/addHook.test.ts +0 -307
- package/test/utils/isMulti.test.ts +0 -53
- package/test/utils/markHookForSkip.test.ts +0 -292
- package/test/utils/mergeQuery.test.ts +0 -407
- package/test/utils/pushSet.test.ts +0 -66
- 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
|
-
});
|