feathers-utils 5.0.0 → 5.0.1
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/index.cjs +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/hooks/forEach.ts +6 -10
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -36,7 +36,7 @@ interface GetItemsIsArrayResult<T = any> {
|
|
|
36
36
|
}
|
|
37
37
|
declare const getItemsIsArray: <T = any, H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H, options?: GetItemsIsArrayOptions) => GetItemsIsArrayResult<T>;
|
|
38
38
|
|
|
39
|
-
type HookForEachOptions<T = any, H = HookContext, R =
|
|
39
|
+
type HookForEachOptions<T = any, H = HookContext, R = any> = {
|
|
40
40
|
wait?: "sequential" | "parallel" | false;
|
|
41
41
|
items?: GetItemsIsArrayOptions["from"];
|
|
42
42
|
forAll?: (items: T[], context: H) => Promisable<R>;
|
|
@@ -44,9 +44,10 @@ type HookForEachOptions<T = any, H = HookContext, R = never> = {
|
|
|
44
44
|
type ActionPerItem<T, H, R> = (item: T, options: {
|
|
45
45
|
context: H;
|
|
46
46
|
i: number;
|
|
47
|
+
} & (undefined extends R ? {} : {
|
|
47
48
|
fromAll: R;
|
|
48
|
-
}) => Promisable<any>;
|
|
49
|
-
declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R =
|
|
49
|
+
})) => Promisable<any>;
|
|
50
|
+
declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R = any>(actionPerItem: ActionPerItem<T, H, R>, options?: HookForEachOptions<T, H, R>) => ReturnAsyncHook<H>;
|
|
50
51
|
|
|
51
52
|
type OnDeleteAction = "cascade" | "set null";
|
|
52
53
|
interface OnDeleteOptions {
|
package/dist/index.d.mts
CHANGED
|
@@ -36,7 +36,7 @@ interface GetItemsIsArrayResult<T = any> {
|
|
|
36
36
|
}
|
|
37
37
|
declare const getItemsIsArray: <T = any, H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H, options?: GetItemsIsArrayOptions) => GetItemsIsArrayResult<T>;
|
|
38
38
|
|
|
39
|
-
type HookForEachOptions<T = any, H = HookContext, R =
|
|
39
|
+
type HookForEachOptions<T = any, H = HookContext, R = any> = {
|
|
40
40
|
wait?: "sequential" | "parallel" | false;
|
|
41
41
|
items?: GetItemsIsArrayOptions["from"];
|
|
42
42
|
forAll?: (items: T[], context: H) => Promisable<R>;
|
|
@@ -44,9 +44,10 @@ type HookForEachOptions<T = any, H = HookContext, R = never> = {
|
|
|
44
44
|
type ActionPerItem<T, H, R> = (item: T, options: {
|
|
45
45
|
context: H;
|
|
46
46
|
i: number;
|
|
47
|
+
} & (undefined extends R ? {} : {
|
|
47
48
|
fromAll: R;
|
|
48
|
-
}) => Promisable<any>;
|
|
49
|
-
declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R =
|
|
49
|
+
})) => Promisable<any>;
|
|
50
|
+
declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R = any>(actionPerItem: ActionPerItem<T, H, R>, options?: HookForEachOptions<T, H, R>) => ReturnAsyncHook<H>;
|
|
50
51
|
|
|
51
52
|
type OnDeleteAction = "cascade" | "set null";
|
|
52
53
|
interface OnDeleteOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ interface GetItemsIsArrayResult<T = any> {
|
|
|
36
36
|
}
|
|
37
37
|
declare const getItemsIsArray: <T = any, H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H, options?: GetItemsIsArrayOptions) => GetItemsIsArrayResult<T>;
|
|
38
38
|
|
|
39
|
-
type HookForEachOptions<T = any, H = HookContext, R =
|
|
39
|
+
type HookForEachOptions<T = any, H = HookContext, R = any> = {
|
|
40
40
|
wait?: "sequential" | "parallel" | false;
|
|
41
41
|
items?: GetItemsIsArrayOptions["from"];
|
|
42
42
|
forAll?: (items: T[], context: H) => Promisable<R>;
|
|
@@ -44,9 +44,10 @@ type HookForEachOptions<T = any, H = HookContext, R = never> = {
|
|
|
44
44
|
type ActionPerItem<T, H, R> = (item: T, options: {
|
|
45
45
|
context: H;
|
|
46
46
|
i: number;
|
|
47
|
+
} & (undefined extends R ? {} : {
|
|
47
48
|
fromAll: R;
|
|
48
|
-
}) => Promisable<any>;
|
|
49
|
-
declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R =
|
|
49
|
+
})) => Promisable<any>;
|
|
50
|
+
declare const forEach: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, T = any, R = any>(actionPerItem: ActionPerItem<T, H, R>, options?: HookForEachOptions<T, H, R>) => ReturnAsyncHook<H>;
|
|
50
51
|
|
|
51
52
|
type OnDeleteAction = "cascade" | "set null";
|
|
52
53
|
interface OnDeleteOptions {
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
package/src/hooks/forEach.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { HookContext } from "@feathersjs/feathers";
|
|
|
5
5
|
import type { GetItemsIsArrayOptions } from "../utils/getItemsIsArray";
|
|
6
6
|
import { getItemsIsArray } from "../utils/getItemsIsArray";
|
|
7
7
|
|
|
8
|
-
export type HookForEachOptions<T = any, H = HookContext, R =
|
|
8
|
+
export type HookForEachOptions<T = any, H = HookContext, R = any> = {
|
|
9
9
|
wait?: "sequential" | "parallel" | false;
|
|
10
10
|
items?: GetItemsIsArrayOptions["from"];
|
|
11
11
|
forAll?: (items: T[], context: H) => Promisable<R>;
|
|
@@ -16,15 +16,11 @@ type ActionPerItem<T, H, R> = (
|
|
|
16
16
|
options: {
|
|
17
17
|
context: H;
|
|
18
18
|
i: number;
|
|
19
|
-
|
|
20
|
-
},
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
|
+
} & (undefined extends R ? {} : { fromAll: R }),
|
|
21
21
|
) => Promisable<any>;
|
|
22
22
|
|
|
23
|
-
export const forEach = <
|
|
24
|
-
H extends HookContext = HookContext,
|
|
25
|
-
T = any,
|
|
26
|
-
R = never,
|
|
27
|
-
>(
|
|
23
|
+
export const forEach = <H extends HookContext = HookContext, T = any, R = any>(
|
|
28
24
|
actionPerItem: ActionPerItem<T, H, R>,
|
|
29
25
|
options?: HookForEachOptions<T, H, R>,
|
|
30
26
|
): ReturnAsyncHook<H> => {
|
|
@@ -49,8 +45,8 @@ export const forEach = <
|
|
|
49
45
|
const promise = actionPerItem(item, {
|
|
50
46
|
context,
|
|
51
47
|
i,
|
|
52
|
-
fromAll: forAll,
|
|
53
|
-
});
|
|
48
|
+
...(forAll ? { fromAll: forAll } : {}),
|
|
49
|
+
} as any);
|
|
54
50
|
|
|
55
51
|
if (wait === "sequential") {
|
|
56
52
|
await promise;
|