feathers-utils 2.0.0-2 → 2.0.0-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/dist/esm/filters/array.d.ts +1 -1
- package/dist/esm/filters/array.js +2 -2
- package/dist/esm/filters/object.d.ts +2 -0
- package/dist/esm/filters/object.js +8 -0
- package/dist/esm/hooks/checkMulti.d.ts +2 -2
- package/dist/esm/hooks/createRelated.d.ts +8 -2
- package/dist/esm/hooks/createRelated.js +2 -3
- package/dist/esm/hooks/onDelete.d.ts +8 -2
- package/dist/esm/hooks/onDelete.js +8 -7
- package/dist/esm/hooks/removeRelated.d.ts +7 -2
- package/dist/esm/hooks/removeRelated.js +8 -7
- package/dist/esm/hooks/runPerItem.d.ts +5 -2
- package/dist/esm/hooks/runPerItem.js +1 -1
- package/dist/esm/hooks/setData.d.ts +7 -2
- package/dist/esm/hooks/setData.js +3 -2
- package/dist/esm/index.d.ts +19 -34
- package/dist/esm/index.js +21 -33
- package/dist/esm/mixins/debounce-mixin/DebouncedStore.d.ts +5 -2
- package/dist/esm/mixins/debounce-mixin/DebouncedStore.js +2 -2
- package/dist/esm/mixins/debounce-mixin/debounceMixin.d.ts +3 -0
- package/dist/esm/mixins/debounce-mixin/debounceMixin.js +19 -0
- package/dist/esm/mixins/debounce-mixin/index.d.ts +3 -8
- package/dist/esm/mixins/debounce-mixin/index.js +3 -20
- package/dist/esm/mixins/debounce-mixin/types.d.ts +13 -0
- package/dist/esm/mixins/debounce-mixin/types.js +1 -0
- package/dist/esm/types.d.ts +1 -77
- package/dist/esm/types.js +0 -1
- package/dist/esm/typesInternal.d.ts +3 -0
- package/dist/esm/typesInternal.js +3 -0
- package/dist/esm/utils/filterQuery.d.ts +6 -1
- package/dist/esm/utils/filterQuery.js +5 -3
- package/dist/esm/utils/getItemsIsArray.d.ts +5 -2
- package/dist/esm/utils/getItemsIsArray.js +7 -12
- package/dist/esm/utils/getPaginate.d.ts +2 -6
- package/dist/esm/utils/getPaginate.js +1 -1
- package/dist/esm/utils/isMulti.d.ts +1 -1
- package/dist/esm/utils/isPaginated.d.ts +1 -1
- package/dist/esm/utils/markHookForSkip.d.ts +3 -2
- package/dist/esm/utils/markHookForSkip.js +6 -5
- package/dist/esm/utils/mergeQuery/index.d.ts +3 -3
- package/dist/esm/utils/mergeQuery/index.js +3 -338
- package/dist/esm/utils/mergeQuery/mergeArrays.d.ts +2 -1
- package/dist/esm/utils/mergeQuery/mergeArrays.js +2 -2
- package/dist/esm/utils/mergeQuery/mergeQuery.d.ts +3 -0
- package/dist/esm/utils/mergeQuery/mergeQuery.js +68 -0
- package/dist/esm/utils/mergeQuery/types.d.ts +13 -0
- package/dist/esm/utils/mergeQuery/types.js +1 -0
- package/dist/esm/utils/mergeQuery/utils.d.ts +11 -0
- package/dist/esm/utils/mergeQuery/utils.js +272 -0
- package/dist/esm/utils/pushSet.d.ts +4 -1
- package/dist/esm/utils/pushSet.js +1 -1
- package/dist/esm/utils/setResultEmpty.d.ts +1 -1
- package/dist/esm/utils/setResultEmpty.js +1 -1
- package/dist/esm/utils/shouldSkip.d.ts +1 -1
- package/dist/esm/utils/validateQueryProperty.js +1 -1
- package/dist/filters/array.d.ts +1 -1
- package/dist/filters/array.js +2 -2
- package/dist/filters/object.d.ts +2 -0
- package/dist/filters/object.js +15 -0
- package/dist/hooks/checkMulti.d.ts +2 -2
- package/dist/hooks/createRelated.d.ts +8 -2
- package/dist/hooks/createRelated.js +2 -3
- package/dist/hooks/onDelete.d.ts +8 -2
- package/dist/hooks/onDelete.js +8 -7
- package/dist/hooks/removeRelated.d.ts +7 -2
- package/dist/hooks/removeRelated.js +8 -7
- package/dist/hooks/runPerItem.d.ts +5 -2
- package/dist/hooks/runPerItem.js +1 -1
- package/dist/hooks/setData.d.ts +7 -2
- package/dist/hooks/setData.js +3 -2
- package/dist/index.d.ts +19 -34
- package/dist/index.js +23 -49
- package/dist/mixins/debounce-mixin/DebouncedStore.d.ts +5 -2
- package/dist/mixins/debounce-mixin/DebouncedStore.js +2 -2
- package/dist/mixins/debounce-mixin/debounceMixin.d.ts +3 -0
- package/dist/mixins/debounce-mixin/debounceMixin.js +23 -0
- package/dist/mixins/debounce-mixin/index.d.ts +3 -8
- package/dist/mixins/debounce-mixin/index.js +17 -22
- package/dist/mixins/debounce-mixin/types.d.ts +13 -0
- package/dist/mixins/debounce-mixin/types.js +2 -0
- package/dist/types.d.ts +1 -77
- package/dist/types.js +0 -1
- package/dist/typesInternal.d.ts +3 -0
- package/dist/typesInternal.js +4 -0
- package/dist/utils/filterQuery.d.ts +6 -1
- package/dist/utils/filterQuery.js +4 -2
- package/dist/utils/getItemsIsArray.d.ts +5 -2
- package/dist/utils/getItemsIsArray.js +7 -12
- package/dist/utils/getPaginate.d.ts +2 -6
- package/dist/utils/isMulti.d.ts +1 -1
- package/dist/utils/isPaginated.d.ts +1 -1
- package/dist/utils/markHookForSkip.d.ts +3 -2
- package/dist/utils/markHookForSkip.js +6 -5
- package/dist/utils/mergeQuery/index.d.ts +3 -3
- package/dist/utils/mergeQuery/index.js +16 -342
- package/dist/utils/mergeQuery/mergeArrays.d.ts +2 -1
- package/dist/utils/mergeQuery/mergeArrays.js +2 -2
- package/dist/utils/mergeQuery/mergeQuery.d.ts +3 -0
- package/dist/utils/mergeQuery/mergeQuery.js +75 -0
- package/dist/utils/mergeQuery/types.d.ts +13 -0
- package/dist/utils/mergeQuery/types.js +2 -0
- package/dist/utils/mergeQuery/utils.d.ts +11 -0
- package/dist/utils/mergeQuery/utils.js +287 -0
- package/dist/utils/pushSet.d.ts +4 -1
- package/dist/utils/pushSet.js +1 -1
- package/dist/utils/setResultEmpty.d.ts +1 -1
- package/dist/utils/setResultEmpty.js +1 -1
- package/dist/utils/shouldSkip.d.ts +1 -1
- package/package.json +5 -2
- package/src/filters/array.ts +13 -9
- package/src/filters/object.ts +15 -0
- package/src/hooks/checkMulti.ts +8 -6
- package/src/hooks/createRelated.ts +21 -12
- package/src/hooks/onDelete.ts +28 -13
- package/src/hooks/removeRelated.ts +28 -16
- package/src/hooks/runPerItem.ts +19 -10
- package/src/hooks/setData.ts +24 -15
- package/src/index.ts +21 -38
- package/src/mixins/debounce-mixin/DebouncedStore.ts +29 -24
- package/src/mixins/debounce-mixin/debounceMixin.ts +33 -0
- package/src/mixins/debounce-mixin/index.ts +3 -39
- package/src/mixins/debounce-mixin/types.ts +16 -0
- package/src/types.ts +6 -117
- package/src/typesInternal.ts +6 -0
- package/src/utils/filterQuery.ts +22 -10
- package/src/utils/getItemsIsArray.ts +15 -16
- package/src/utils/getPaginate.ts +11 -14
- package/src/utils/isMulti.ts +3 -3
- package/src/utils/isPaginated.ts +6 -4
- package/src/utils/markHookForSkip.ts +18 -16
- package/src/utils/mergeQuery/index.ts +3 -379
- package/src/utils/mergeQuery/mergeArrays.ts +25 -18
- package/src/utils/mergeQuery/mergeQuery.ts +102 -0
- package/src/utils/mergeQuery/types.ts +25 -0
- package/src/utils/mergeQuery/utils.ts +342 -0
- package/src/utils/pushSet.ts +14 -7
- package/src/utils/setResultEmpty.ts +8 -6
- package/src/utils/shouldSkip.ts +4 -4
- package/src/utils/validateQueryProperty.ts +8 -4
package/dist/index.js
CHANGED
|
@@ -14,57 +14,31 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.filterObject = exports.filterArray = void 0;
|
|
18
18
|
// hooks
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports
|
|
38
|
-
|
|
39
|
-
DebouncedStore: debounce_mixin_1.DebouncedStore
|
|
40
|
-
};
|
|
41
|
-
var getPaginate_1 = require("./utils/getPaginate");
|
|
42
|
-
Object.defineProperty(exports, "getPaginate", { enumerable: true, get: function () { return getPaginate_1.getPaginate; } });
|
|
43
|
-
var isMulti_1 = require("./utils/isMulti");
|
|
44
|
-
Object.defineProperty(exports, "isMulti", { enumerable: true, get: function () { return isMulti_1.isMulti; } });
|
|
45
|
-
var isPaginated_1 = require("./utils/isPaginated");
|
|
46
|
-
Object.defineProperty(exports, "isPaginated", { enumerable: true, get: function () { return isPaginated_1.isPaginated; } });
|
|
47
|
-
var index_1 = require("./utils/mergeQuery/index");
|
|
48
|
-
Object.defineProperty(exports, "mergeQuery", { enumerable: true, get: function () { return index_1.mergeQuery; } });
|
|
49
|
-
var mergeArrays_1 = require("./utils/mergeQuery/mergeArrays");
|
|
50
|
-
Object.defineProperty(exports, "mergeArrays", { enumerable: true, get: function () { return mergeArrays_1.mergeArrays; } });
|
|
51
|
-
var pushSet_1 = require("./utils/pushSet");
|
|
52
|
-
Object.defineProperty(exports, "pushSet", { enumerable: true, get: function () { return pushSet_1.pushSet; } });
|
|
53
|
-
var setResultEmpty_1 = require("./utils/setResultEmpty");
|
|
54
|
-
Object.defineProperty(exports, "setResultEmpty", { enumerable: true, get: function () { return setResultEmpty_1.setResultEmpty; } });
|
|
55
|
-
var markHookForSkip_1 = require("./utils/markHookForSkip");
|
|
56
|
-
Object.defineProperty(exports, "markHookForSkip", { enumerable: true, get: function () { return markHookForSkip_1.markHookForSkip; } });
|
|
57
|
-
var filterQuery_1 = require("./utils/filterQuery");
|
|
58
|
-
Object.defineProperty(exports, "filterQuery", { enumerable: true, get: function () { return filterQuery_1.filterQuery; } });
|
|
59
|
-
var getItemsIsArray_1 = require("./utils/getItemsIsArray");
|
|
60
|
-
Object.defineProperty(exports, "getItemsIsArray", { enumerable: true, get: function () { return getItemsIsArray_1.getItemsIsArray; } });
|
|
61
|
-
var onDelete_1 = require("./hooks/onDelete");
|
|
62
|
-
Object.defineProperty(exports, "onDelete", { enumerable: true, get: function () { return onDelete_1.onDelete; } });
|
|
63
|
-
var shouldSkip_1 = require("./utils/shouldSkip");
|
|
64
|
-
Object.defineProperty(exports, "shouldSkip", { enumerable: true, get: function () { return shouldSkip_1.shouldSkip; } });
|
|
65
|
-
var validateQueryProperty_1 = require("./utils/validateQueryProperty");
|
|
66
|
-
Object.defineProperty(exports, "validateQueryProperty", { enumerable: true, get: function () { return validateQueryProperty_1.validateQueryProperty; } });
|
|
19
|
+
__exportStar(require("./hooks/checkMulti"), exports);
|
|
20
|
+
__exportStar(require("./hooks/createRelated"), exports);
|
|
21
|
+
__exportStar(require("./hooks/onDelete"), exports);
|
|
22
|
+
__exportStar(require("./hooks/removeRelated"), exports);
|
|
23
|
+
__exportStar(require("./hooks/runPerItem"), exports);
|
|
24
|
+
__exportStar(require("./hooks/setData"), exports);
|
|
25
|
+
// mixins
|
|
26
|
+
__exportStar(require("./mixins/debounce-mixin"), exports);
|
|
27
|
+
// utils
|
|
28
|
+
__exportStar(require("./utils/isMulti"), exports);
|
|
29
|
+
__exportStar(require("./utils/getPaginate"), exports);
|
|
30
|
+
__exportStar(require("./utils/isPaginated"), exports);
|
|
31
|
+
__exportStar(require("./utils/mergeQuery"), exports);
|
|
32
|
+
__exportStar(require("./utils/pushSet"), exports);
|
|
33
|
+
__exportStar(require("./utils/setResultEmpty"), exports);
|
|
34
|
+
__exportStar(require("./utils/filterQuery"), exports);
|
|
35
|
+
__exportStar(require("./utils/getItemsIsArray"), exports);
|
|
36
|
+
__exportStar(require("./utils/shouldSkip"), exports);
|
|
37
|
+
__exportStar(require("./utils/markHookForSkip"), exports);
|
|
38
|
+
__exportStar(require("./utils/validateQueryProperty"), exports);
|
|
67
39
|
// query filters
|
|
68
40
|
var array_1 = require("./filters/array");
|
|
69
41
|
Object.defineProperty(exports, "filterArray", { enumerable: true, get: function () { return array_1.filterArray; } });
|
|
42
|
+
var object_1 = require("./filters/object");
|
|
43
|
+
Object.defineProperty(exports, "filterObject", { enumerable: true, get: function () { return object_1.filterObject; } });
|
|
70
44
|
__exportStar(require("./types"), exports);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { DebouncedFunc } from "lodash";
|
|
2
2
|
import type { Application, Id } from "@feathersjs/feathers";
|
|
3
|
-
import type { DebouncedFunctionApp, DebouncedStoreOptions } from "
|
|
3
|
+
import type { DebouncedFunctionApp, DebouncedStoreOptions } from "./types";
|
|
4
4
|
export declare const makeDefaultOptions: () => DebouncedStoreOptions;
|
|
5
|
+
export declare type DebouncedService<T = any> = T & {
|
|
6
|
+
debouncedStore: DebouncedStore;
|
|
7
|
+
};
|
|
5
8
|
export declare class DebouncedStore {
|
|
6
9
|
private _app;
|
|
7
10
|
private _options;
|
|
8
11
|
private _isRunningById;
|
|
9
|
-
_queueById: Record<string, DebouncedFunc<(
|
|
12
|
+
_queueById: Record<string, DebouncedFunc<(id: Id, action: DebouncedFunctionApp) => void | Promise<void>>>;
|
|
10
13
|
add: (id: Id, action: (app?: Application) => void | Promise<void>) => void | Promise<void> | undefined;
|
|
11
14
|
constructor(app: Application, options?: Partial<DebouncedStoreOptions>);
|
|
12
15
|
private unbounced;
|
|
@@ -19,7 +19,7 @@ const makeDefaultOptions = () => {
|
|
|
19
19
|
leading: false,
|
|
20
20
|
maxWait: undefined,
|
|
21
21
|
trailing: true,
|
|
22
|
-
wait: 100
|
|
22
|
+
wait: 100,
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
exports.makeDefaultOptions = makeDefaultOptions;
|
|
@@ -33,7 +33,7 @@ class DebouncedStore {
|
|
|
33
33
|
this.add = this.debounceById(this.unbounced, this._options.wait, {
|
|
34
34
|
leading: this._options.leading,
|
|
35
35
|
maxWait: this._options.maxWait,
|
|
36
|
-
trailing: this._options.trailing
|
|
36
|
+
trailing: this._options.trailing,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
unbounced(id, action) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.debounceMixin = void 0;
|
|
4
|
+
const DebouncedStore_1 = require("./DebouncedStore");
|
|
5
|
+
function debounceMixin(options) {
|
|
6
|
+
return (app) => {
|
|
7
|
+
options = options || {};
|
|
8
|
+
const defaultOptions = Object.assign((0, DebouncedStore_1.makeDefaultOptions)(), options === null || options === void 0 ? void 0 : options.default);
|
|
9
|
+
app.mixins.push((service, path) => {
|
|
10
|
+
// if path is on blacklist, don't add debouncedStore to service
|
|
11
|
+
if ((options === null || options === void 0 ? void 0 : options.blacklist) && options.blacklist.includes(path))
|
|
12
|
+
return;
|
|
13
|
+
// if service already has registered something on `debouncedStore`
|
|
14
|
+
if (service.debouncedStore) {
|
|
15
|
+
console.warn(`[feathers-utils] service: '${path}' already has a property 'debouncedStore'. Mixin will skip creating a new debouncedStore`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const serviceOptions = Object.assign({}, defaultOptions, options === null || options === void 0 ? void 0 : options[path]);
|
|
19
|
+
service.debouncedStore = new DebouncedStore_1.DebouncedStore(app, serviceOptions);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.debounceMixin = debounceMixin;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare type DebouncedService = FeathersService & {
|
|
5
|
-
debouncedStore: DebouncedStore;
|
|
6
|
-
};
|
|
7
|
-
export declare function debounceMixin(options?: Partial<InitDebounceMixinOptions>): ((app: Application) => void);
|
|
8
|
-
export { DebouncedStore };
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./DebouncedStore";
|
|
3
|
+
export * from "./debounceMixin";
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function debounceMixin(options) {
|
|
7
|
-
return (app) => {
|
|
8
|
-
options = options || {};
|
|
9
|
-
const defaultOptions = Object.assign((0, DebouncedStore_1.makeDefaultOptions)(), options === null || options === void 0 ? void 0 : options.default);
|
|
10
|
-
app.mixins.push((service, path) => {
|
|
11
|
-
// if path is on blacklist, don't add debouncedStore to service
|
|
12
|
-
if ((options === null || options === void 0 ? void 0 : options.blacklist) && options.blacklist.includes(path))
|
|
13
|
-
return;
|
|
14
|
-
// if service already has registered something on `debouncedStore`
|
|
15
|
-
if (service.debouncedStore) {
|
|
16
|
-
console.warn(`[feathers-utils] service: '${path}' already has a property 'debouncedStore'. Mixin will skip creating a new debouncedStore`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const serviceOptions = Object.assign({}, defaultOptions, options === null || options === void 0 ? void 0 : options[path]);
|
|
20
|
-
service.debouncedStore = new DebouncedStore_1.DebouncedStore(app, serviceOptions);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.debounceMixin = debounceMixin;
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./DebouncedStore"), exports);
|
|
19
|
+
__exportStar(require("./debounceMixin"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Application } from "@feathersjs/feathers";
|
|
2
|
+
export interface InitDebounceMixinOptions {
|
|
3
|
+
default: Partial<DebouncedStoreOptions>;
|
|
4
|
+
blacklist: string[];
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare type DebouncedFunctionApp = (app?: Application) => void | Promise<void>;
|
|
8
|
+
export interface DebouncedStoreOptions {
|
|
9
|
+
leading: boolean;
|
|
10
|
+
maxWait: number | undefined;
|
|
11
|
+
trailing: boolean;
|
|
12
|
+
wait: number;
|
|
13
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,79 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AdapterBase, FilterQueryOptions as PlainFilterQueryOptions } from "@feathersjs/adapter-commons";
|
|
3
|
-
export declare type Path = Array<string | number>;
|
|
4
|
-
export declare type MaybeArray<T> = T | T[];
|
|
5
|
-
export declare type Promisable<T> = T | Promise<T>;
|
|
6
|
-
export declare type HookType = "before" | "after" | "error";
|
|
7
|
-
export declare type ServiceMethodName = "find" | "get" | "create" | "update" | "patch" | "remove";
|
|
8
|
-
export declare type ReturnSyncHook = (context: HookContext) => HookContext;
|
|
9
|
-
export declare type ReturnAsyncHook = (context: HookContext) => Promise<HookContext>;
|
|
10
|
-
export declare type Handle = "target" | "source" | "combine" | "intersect" | "intersectOrFull";
|
|
11
|
-
export declare type FirstLast = "first" | "last";
|
|
1
|
+
import type { HookContext } from "@feathersjs/feathers";
|
|
12
2
|
export declare type Predicate<T = any> = (item: T) => boolean;
|
|
13
3
|
export declare type PredicateWithContext<T = any> = (item: T, context: HookContext) => boolean;
|
|
14
|
-
export interface HookSetDataOptions {
|
|
15
|
-
allowUndefined?: boolean;
|
|
16
|
-
overwrite?: boolean | PredicateWithContext;
|
|
17
|
-
}
|
|
18
|
-
export interface AddHookOptions {
|
|
19
|
-
types: HookType[];
|
|
20
|
-
methods: ServiceMethodName[];
|
|
21
|
-
orderByType: Record<HookType, FirstLast>;
|
|
22
|
-
whitelist?: string[];
|
|
23
|
-
blacklist?: string[];
|
|
24
|
-
}
|
|
25
|
-
export interface HookRunPerItemOptions {
|
|
26
|
-
wait?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface RemoveRelatedOptions<S = Record<string, any>> {
|
|
29
|
-
service: keyof S;
|
|
30
|
-
keyThere: string;
|
|
31
|
-
keyHere: string;
|
|
32
|
-
blocking?: boolean;
|
|
33
|
-
}
|
|
34
|
-
export interface CreateRelatedOptions<S = Record<string, any>> {
|
|
35
|
-
service: keyof S;
|
|
36
|
-
multi?: boolean;
|
|
37
|
-
data: (item: any, context: HookContext) => Promisable<Record<string, any>>;
|
|
38
|
-
createItemsInDataArraySeparately?: boolean;
|
|
39
|
-
}
|
|
40
|
-
export declare type OnDeleteAction = "cascade" | "set null";
|
|
41
|
-
export interface OnDeleteOptions {
|
|
42
|
-
keyThere: string;
|
|
43
|
-
keyHere: string;
|
|
44
|
-
onDelete: OnDeleteAction;
|
|
45
|
-
blocking?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export interface InitDebounceMixinOptions {
|
|
48
|
-
default: Partial<DebouncedStoreOptions>;
|
|
49
|
-
blacklist: string[];
|
|
50
|
-
[key: string]: unknown;
|
|
51
|
-
}
|
|
52
|
-
export declare type DebouncedFunctionApp = (app?: Application) => void | Promise<void>;
|
|
53
|
-
export interface DebouncedStoreOptions {
|
|
54
|
-
leading: boolean;
|
|
55
|
-
maxWait: number | undefined;
|
|
56
|
-
trailing: boolean;
|
|
57
|
-
wait: number;
|
|
58
|
-
}
|
|
59
|
-
export interface PushSetOptions {
|
|
60
|
-
unique?: boolean;
|
|
61
|
-
}
|
|
62
|
-
export declare type ActionOnEmptyIntersect = (target: unknown, source: unknown, prependKey: Path) => void;
|
|
63
|
-
export interface MergeQueryOptions<T> extends FilterQueryOptions<T> {
|
|
64
|
-
defaultHandle: Handle;
|
|
65
|
-
actionOnEmptyIntersect: ActionOnEmptyIntersect;
|
|
66
|
-
useLogicalConjunction: boolean;
|
|
67
|
-
handle?: {
|
|
68
|
-
[key: string]: Handle;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export interface FilterQueryOptions<T> {
|
|
72
|
-
service?: AdapterBase<T>;
|
|
73
|
-
operators?: PlainFilterQueryOptions["operators"];
|
|
74
|
-
filters?: PlainFilterQueryOptions["filters"];
|
|
75
|
-
}
|
|
76
|
-
export interface GetItemsIsArrayOptions<T = any> {
|
|
77
|
-
items: T[];
|
|
78
|
-
isArray: boolean;
|
|
79
|
-
}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { FilterQueryOptions as PlainFilterQueryOptions, AdapterBase } from "@feathersjs/adapter-commons";
|
|
1
2
|
import type { Query } from "@feathersjs/feathers";
|
|
2
|
-
|
|
3
|
+
export interface FilterQueryOptions<T> {
|
|
4
|
+
service?: AdapterBase<T>;
|
|
5
|
+
operators?: PlainFilterQueryOptions["operators"];
|
|
6
|
+
filters?: PlainFilterQueryOptions["filters"];
|
|
7
|
+
}
|
|
3
8
|
export declare function filterQuery<T>(query: Query, _options?: FilterQueryOptions<T>): any;
|
|
@@ -32,8 +32,10 @@ function filterQuery(query, _options) {
|
|
|
32
32
|
if (filters) {
|
|
33
33
|
optionsForFilterQuery.filters = filters;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (service &&
|
|
36
|
+
"filterQuery" in service &&
|
|
37
|
+
// @ts-expect-error service is of type 'never'
|
|
38
|
+
typeof service.filterQuery === "function") {
|
|
37
39
|
// @ts-expect-error service has no filterQuery method
|
|
38
40
|
return service.filterQuery({ query }, optionsForFilterQuery);
|
|
39
41
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { HookContext } from "@feathersjs/feathers";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export interface GetItemsIsArrayOptions<T = any> {
|
|
3
|
+
items: T[];
|
|
4
|
+
isArray: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const getItemsIsArray: <T = any, H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any> = HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(context: H) => GetItemsIsArrayOptions<T>;
|
|
@@ -3,20 +3,15 @@ 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"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
: itemOrItems;
|
|
6
|
+
let itemOrItems = context.type === "before" ? context.data : context.result;
|
|
7
|
+
itemOrItems =
|
|
8
|
+
itemOrItems && context.method === "find"
|
|
9
|
+
? itemOrItems.data || itemOrItems
|
|
10
|
+
: itemOrItems;
|
|
12
11
|
const isArray = Array.isArray(itemOrItems);
|
|
13
12
|
return {
|
|
14
|
-
items:
|
|
15
|
-
|
|
16
|
-
: (itemOrItems != null)
|
|
17
|
-
? [itemOrItems]
|
|
18
|
-
: [],
|
|
19
|
-
isArray
|
|
13
|
+
items: isArray ? itemOrItems : itemOrItems != null ? [itemOrItems] : [],
|
|
14
|
+
isArray,
|
|
20
15
|
};
|
|
21
16
|
};
|
|
22
17
|
exports.getItemsIsArray = getItemsIsArray;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
+
import type { PaginationOptions } from "@feathersjs/adapter-commons";
|
|
1
2
|
import type { HookContext } from "@feathersjs/feathers";
|
|
2
|
-
|
|
3
|
-
default: number;
|
|
4
|
-
max: number;
|
|
5
|
-
}
|
|
6
|
-
export declare const getPaginate: (context: HookContext) => PaginationOptions | undefined;
|
|
7
|
-
export {};
|
|
3
|
+
export declare const getPaginate: <H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any> = HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(context: H) => PaginationOptions | undefined;
|
package/dist/utils/isMulti.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { HookContext } from "@feathersjs/feathers";
|
|
2
|
-
export declare const isMulti: (context:
|
|
2
|
+
export declare const isMulti: <H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any> = HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(context: H) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { HookContext } from "@feathersjs/feathers";
|
|
2
|
-
export declare const isPaginated: (context:
|
|
2
|
+
export declare const isPaginated: <H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any> = HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(context: H) => boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { HookContext } from "@feathersjs/feathers";
|
|
2
|
-
import type { HookType
|
|
3
|
-
|
|
2
|
+
import type { HookType } from "feathers-hooks-common";
|
|
3
|
+
import type { MaybeArray } from "../typesInternal";
|
|
4
|
+
export declare function markHookForSkip<H extends HookContext = HookContext>(hookName: string, type: "all" | MaybeArray<HookType>, context?: H): H | undefined;
|
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.markHookForSkip = void 0;
|
|
4
4
|
const pushSet_1 = require("./pushSet");
|
|
5
5
|
function markHookForSkip(hookName, type, context) {
|
|
6
|
+
// @ts-expect-error context is not of type 'H'
|
|
6
7
|
context = context || {};
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
9
|
const params = context.params || {};
|
|
8
|
-
const types =
|
|
9
|
-
types.forEach(t => {
|
|
10
|
-
const combinedName =
|
|
11
|
-
? hookName
|
|
12
|
-
: `${type}:${hookName}`;
|
|
10
|
+
const types = Array.isArray(type) ? type : [type];
|
|
11
|
+
types.forEach((t) => {
|
|
12
|
+
const combinedName = t === "all" ? hookName : `${type}:${hookName}`;
|
|
13
13
|
(0, pushSet_1.pushSet)(params, ["skipHooks"], combinedName, { unique: true });
|
|
14
14
|
});
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
16
|
context.params = params;
|
|
16
17
|
return context;
|
|
17
18
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
export * from "./mergeArrays";
|
|
2
|
+
export * from "./mergeQuery";
|
|
3
|
+
export * from "./types";
|