feathers-utils 2.0.0-9 → 2.1.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/LICENSE +1 -1
- package/README.md +3 -1
- package/dist/index.cjs +964 -0
- package/dist/index.d.ts +262 -5
- package/dist/index.mjs +938 -0
- package/package.json +35 -38
- package/src/filters/object.ts +1 -1
- package/src/hooks/forEach.ts +47 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/makeSequelizeQuery.ts_ +4 -4
- package/src/hooks/parseFields.ts +27 -0
- package/src/hooks/runPerItem.ts +4 -6
- package/src/hooks/setData.ts +4 -5
- package/src/index.ts +1 -0
- package/src/typesInternal.ts +7 -0
- package/src/utility-types/index.ts +116 -0
- package/src/utils/getItemsIsArray.ts +27 -11
- package/src/utils/getPaginate.ts +2 -1
- package/src/utils/internal.utils.ts +6 -0
- package/src/utils/mergeQuery/mergeQuery.ts +62 -25
- package/src/utils/mergeQuery/utils.ts +82 -29
- package/dist/esm/filters/array.d.ts +0 -2
- package/dist/esm/filters/array.js +0 -17
- package/dist/esm/filters/index.d.ts +0 -2
- package/dist/esm/filters/index.js +0 -2
- package/dist/esm/filters/object.d.ts +0 -2
- package/dist/esm/filters/object.js +0 -15
- package/dist/esm/hooks/checkMulti.d.ts +0 -5
- package/dist/esm/hooks/checkMulti.js +0 -20
- package/dist/esm/hooks/createRelated.d.ts +0 -12
- package/dist/esm/hooks/createRelated.js +0 -31
- package/dist/esm/hooks/index.d.ts +0 -6
- package/dist/esm/hooks/index.js +0 -6
- package/dist/esm/hooks/onDelete.d.ts +0 -12
- package/dist/esm/hooks/onDelete.js +0 -47
- package/dist/esm/hooks/removeRelated.d.ts +0 -11
- package/dist/esm/hooks/removeRelated.js +0 -37
- package/dist/esm/hooks/runPerItem.d.ts +0 -10
- package/dist/esm/hooks/runPerItem.js +0 -29
- package/dist/esm/hooks/setData.d.ts +0 -11
- package/dist/esm/hooks/setData.js +0 -46
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.js +0 -5
- package/dist/esm/mixins/debounce-mixin/DebouncedStore.d.ts +0 -18
- package/dist/esm/mixins/debounce-mixin/DebouncedStore.js +0 -46
- package/dist/esm/mixins/debounce-mixin/debounceMixin.d.ts +0 -3
- package/dist/esm/mixins/debounce-mixin/debounceMixin.js +0 -19
- package/dist/esm/mixins/debounce-mixin/index.d.ts +0 -3
- package/dist/esm/mixins/debounce-mixin/index.js +0 -3
- package/dist/esm/mixins/debounce-mixin/types.d.ts +0 -13
- package/dist/esm/mixins/debounce-mixin/types.js +0 -1
- package/dist/esm/mixins/index.d.ts +0 -1
- package/dist/esm/mixins/index.js +0 -1
- package/dist/esm/types.d.ts +0 -3
- package/dist/esm/types.js +0 -1
- package/dist/esm/typesInternal.d.ts +0 -3
- package/dist/esm/typesInternal.js +0 -3
- package/dist/esm/utils/filterQuery.d.ts +0 -8
- package/dist/esm/utils/filterQuery.js +0 -30
- package/dist/esm/utils/getItemsIsArray.d.ts +0 -10
- package/dist/esm/utils/getItemsIsArray.js +0 -16
- package/dist/esm/utils/getPaginate.d.ts +0 -9
- package/dist/esm/utils/getPaginate.js +0 -20
- package/dist/esm/utils/index.d.ts +0 -11
- package/dist/esm/utils/index.js +0 -11
- package/dist/esm/utils/isMulti.d.ts +0 -11
- package/dist/esm/utils/isMulti.js +0 -26
- package/dist/esm/utils/isPaginated.d.ts +0 -5
- package/dist/esm/utils/isPaginated.js +0 -11
- package/dist/esm/utils/markHookForSkip.d.ts +0 -7
- package/dist/esm/utils/markHookForSkip.js +0 -18
- package/dist/esm/utils/mergeQuery/index.d.ts +0 -3
- package/dist/esm/utils/mergeQuery/index.js +0 -3
- package/dist/esm/utils/mergeQuery/mergeArrays.d.ts +0 -3
- package/dist/esm/utils/mergeQuery/mergeArrays.js +0 -37
- package/dist/esm/utils/mergeQuery/mergeQuery.d.ts +0 -3
- package/dist/esm/utils/mergeQuery/mergeQuery.js +0 -70
- package/dist/esm/utils/mergeQuery/types.d.ts +0 -13
- package/dist/esm/utils/mergeQuery/types.js +0 -1
- package/dist/esm/utils/mergeQuery/utils.d.ts +0 -11
- package/dist/esm/utils/mergeQuery/utils.js +0 -272
- package/dist/esm/utils/pushSet.d.ts +0 -8
- package/dist/esm/utils/pushSet.js +0 -22
- package/dist/esm/utils/setResultEmpty.d.ts +0 -5
- package/dist/esm/utils/setResultEmpty.js +0 -28
- package/dist/esm/utils/shouldSkip.d.ts +0 -8
- package/dist/esm/utils/shouldSkip.js +0 -29
- package/dist/esm/utils/validateQueryProperty.d.ts +0 -5
- package/dist/esm/utils/validateQueryProperty.js +0 -23
- package/dist/filters/array.d.ts +0 -2
- package/dist/filters/array.js +0 -21
- package/dist/filters/index.d.ts +0 -2
- package/dist/filters/index.js +0 -18
- package/dist/filters/object.d.ts +0 -2
- package/dist/filters/object.js +0 -22
- package/dist/hooks/checkMulti.d.ts +0 -5
- package/dist/hooks/checkMulti.js +0 -24
- package/dist/hooks/createRelated.d.ts +0 -12
- package/dist/hooks/createRelated.js +0 -44
- package/dist/hooks/index.d.ts +0 -6
- package/dist/hooks/index.js +0 -22
- package/dist/hooks/onDelete.d.ts +0 -12
- package/dist/hooks/onDelete.js +0 -60
- package/dist/hooks/removeRelated.d.ts +0 -11
- package/dist/hooks/removeRelated.js +0 -50
- package/dist/hooks/runPerItem.d.ts +0 -10
- package/dist/hooks/runPerItem.js +0 -42
- package/dist/hooks/setData.d.ts +0 -11
- package/dist/hooks/setData.js +0 -54
- package/dist/index.js +0 -21
- package/dist/mixins/debounce-mixin/DebouncedStore.d.ts +0 -18
- package/dist/mixins/debounce-mixin/DebouncedStore.js +0 -65
- package/dist/mixins/debounce-mixin/debounceMixin.d.ts +0 -3
- package/dist/mixins/debounce-mixin/debounceMixin.js +0 -23
- package/dist/mixins/debounce-mixin/index.d.ts +0 -3
- package/dist/mixins/debounce-mixin/index.js +0 -19
- package/dist/mixins/debounce-mixin/types.d.ts +0 -13
- package/dist/mixins/debounce-mixin/types.js +0 -2
- package/dist/mixins/index.d.ts +0 -1
- package/dist/mixins/index.js +0 -17
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -2
- package/dist/typesInternal.d.ts +0 -3
- package/dist/typesInternal.js +0 -4
- package/dist/utils/filterQuery.d.ts +0 -8
- package/dist/utils/filterQuery.js +0 -46
- package/dist/utils/getItemsIsArray.d.ts +0 -10
- package/dist/utils/getItemsIsArray.js +0 -20
- package/dist/utils/getPaginate.d.ts +0 -9
- package/dist/utils/getPaginate.js +0 -22
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -27
- package/dist/utils/isMulti.d.ts +0 -11
- package/dist/utils/isMulti.js +0 -30
- package/dist/utils/isPaginated.d.ts +0 -5
- package/dist/utils/isPaginated.js +0 -15
- package/dist/utils/markHookForSkip.d.ts +0 -7
- package/dist/utils/markHookForSkip.js +0 -22
- package/dist/utils/mergeQuery/index.d.ts +0 -3
- package/dist/utils/mergeQuery/index.js +0 -19
- package/dist/utils/mergeQuery/mergeArrays.d.ts +0 -3
- package/dist/utils/mergeQuery/mergeArrays.js +0 -41
- package/dist/utils/mergeQuery/mergeQuery.d.ts +0 -3
- package/dist/utils/mergeQuery/mergeQuery.js +0 -77
- package/dist/utils/mergeQuery/types.d.ts +0 -13
- package/dist/utils/mergeQuery/types.js +0 -2
- package/dist/utils/mergeQuery/utils.d.ts +0 -11
- package/dist/utils/mergeQuery/utils.js +0 -287
- package/dist/utils/pushSet.d.ts +0 -8
- package/dist/utils/pushSet.js +0 -29
- package/dist/utils/setResultEmpty.d.ts +0 -5
- package/dist/utils/setResultEmpty.js +0 -32
- package/dist/utils/shouldSkip.d.ts +0 -8
- package/dist/utils/shouldSkip.js +0 -33
- package/dist/utils/validateQueryProperty.d.ts +0 -5
- package/dist/utils/validateQueryProperty.js +0 -25
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,262 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as _feathersjs_feathers from '@feathersjs/feathers';
|
|
2
|
+
import { HookContext, Application, Id, Query } from '@feathersjs/feathers';
|
|
3
|
+
import { HookContext as HookContext$1, Application as Application$1 } from '@feathersjs/feathers/lib';
|
|
4
|
+
import { PropertyPath, DebouncedFunc } from 'lodash';
|
|
5
|
+
import { AdapterBase, FilterQueryOptions as FilterQueryOptions$1, PaginationOptions } from '@feathersjs/adapter-commons';
|
|
6
|
+
import { HookType } from 'feathers-hooks-common';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* hook to check if context is multi patch/remove and if the service allows it
|
|
10
|
+
*/
|
|
11
|
+
declare function checkMulti<H extends HookContext = HookContext>(): (context: H) => H;
|
|
12
|
+
|
|
13
|
+
type MaybeArray<T> = T | T[];
|
|
14
|
+
type Promisable<T> = T | Promise<T>;
|
|
15
|
+
type Path = Array<string | number>;
|
|
16
|
+
type ReturnAsyncHook = (context: HookContext$1) => Promise<HookContext$1>;
|
|
17
|
+
|
|
18
|
+
interface CreateRelatedOptions<S = Record<string, any>> {
|
|
19
|
+
service: keyof S;
|
|
20
|
+
multi?: boolean;
|
|
21
|
+
data: (item: any, context: HookContext) => Promisable<Record<string, any>>;
|
|
22
|
+
createItemsInDataArraySeparately?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* hook to create related items
|
|
26
|
+
*/
|
|
27
|
+
declare function createRelated<S = Record<string, any>, H extends HookContext = HookContext>({ service, multi, data, createItemsInDataArraySeparately, }: CreateRelatedOptions<S>): (context: H) => Promise<H>;
|
|
28
|
+
|
|
29
|
+
type GetItemsIsArrayOptions = {
|
|
30
|
+
from: "data" | "result" | "automatic";
|
|
31
|
+
};
|
|
32
|
+
interface GetItemsIsArrayResult<T = any> {
|
|
33
|
+
items: T[];
|
|
34
|
+
isArray: boolean;
|
|
35
|
+
}
|
|
36
|
+
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>;
|
|
37
|
+
|
|
38
|
+
interface HookForEachOptions {
|
|
39
|
+
wait?: "sequential" | "parallel" | false;
|
|
40
|
+
items?: GetItemsIsArrayOptions["from"];
|
|
41
|
+
}
|
|
42
|
+
declare const forEach: (actionPerItem: (item: any, context: HookContext) => Promisable<any>, _options?: HookForEachOptions) => ReturnAsyncHook;
|
|
43
|
+
|
|
44
|
+
type OnDeleteAction = "cascade" | "set null";
|
|
45
|
+
interface OnDeleteOptions {
|
|
46
|
+
keyThere: string;
|
|
47
|
+
keyHere: string;
|
|
48
|
+
onDelete: OnDeleteAction;
|
|
49
|
+
blocking?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* hook to manipulate related items on delete
|
|
53
|
+
*/
|
|
54
|
+
declare function onDelete<S = Record<string, any>, H extends HookContext = HookContext>(service: keyof S, { keyThere, keyHere, onDelete, blocking, }: OnDeleteOptions): (context: H) => Promise<H>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Parse fields to date or number
|
|
58
|
+
* skips undefined fields
|
|
59
|
+
*/
|
|
60
|
+
declare const parseFields: (type: "date" | "number", options: {
|
|
61
|
+
fields: string[];
|
|
62
|
+
}) => (context: HookContext) => HookContext<_feathersjs_feathers.Application<any, any>, any>;
|
|
63
|
+
|
|
64
|
+
interface RemoveRelatedOptions<S = Record<string, any>> {
|
|
65
|
+
service: keyof S;
|
|
66
|
+
keyThere: string;
|
|
67
|
+
keyHere: string;
|
|
68
|
+
blocking?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* hook to remove related items
|
|
72
|
+
*/
|
|
73
|
+
declare function removeRelated<S = Record<string, any>, H extends HookContext = HookContext>({ service, keyThere, keyHere, blocking, }: RemoveRelatedOptions<S>): (context: H) => Promise<H>;
|
|
74
|
+
|
|
75
|
+
interface HookRunPerItemOptions {
|
|
76
|
+
wait?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* hook to run a hook for each item in the context
|
|
80
|
+
* uses `context.result` if it is existent. otherwise uses context.data
|
|
81
|
+
*/
|
|
82
|
+
declare const runPerItem: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(actionPerItem: (item: any, context: H) => Promisable<any>, _options?: HookRunPerItemOptions) => (context: H) => Promise<H>;
|
|
83
|
+
|
|
84
|
+
type Predicate<T = any> = (item: T) => boolean;
|
|
85
|
+
type PredicateWithContext<T = any> = (item: T, context: HookContext) => boolean;
|
|
86
|
+
|
|
87
|
+
interface HookSetDataOptions {
|
|
88
|
+
allowUndefined?: boolean;
|
|
89
|
+
overwrite?: boolean | PredicateWithContext;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* hook to set properties on `context.result` (if existent) or `context.data` (otherwise)
|
|
93
|
+
*/
|
|
94
|
+
declare function setData<H extends HookContext = HookContext>(from: PropertyPath, to: PropertyPath, _options?: HookSetDataOptions): (context: H) => H;
|
|
95
|
+
|
|
96
|
+
interface InitDebounceMixinOptions {
|
|
97
|
+
default: Partial<DebouncedStoreOptions>;
|
|
98
|
+
blacklist: string[];
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
type DebouncedFunctionApp = (app?: Application) => void | Promise<void>;
|
|
102
|
+
interface DebouncedStoreOptions {
|
|
103
|
+
leading: boolean;
|
|
104
|
+
maxWait: number | undefined;
|
|
105
|
+
trailing: boolean;
|
|
106
|
+
wait: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare const makeDefaultOptions: () => DebouncedStoreOptions;
|
|
110
|
+
type DebouncedService<T = any> = T & {
|
|
111
|
+
debouncedStore: DebouncedStore;
|
|
112
|
+
};
|
|
113
|
+
declare class DebouncedStore {
|
|
114
|
+
private _app;
|
|
115
|
+
private _options;
|
|
116
|
+
private _isRunningById;
|
|
117
|
+
_queueById: Record<string, DebouncedFunc<(id: Id, action: DebouncedFunctionApp) => void | Promise<void>>>;
|
|
118
|
+
add: (id: Id, action: (app?: Application) => void | Promise<void>) => void | Promise<void> | undefined;
|
|
119
|
+
constructor(app: Application, options?: Partial<DebouncedStoreOptions>);
|
|
120
|
+
private unbounced;
|
|
121
|
+
private debounceById;
|
|
122
|
+
cancel(id: Id): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare function debounceMixin(options?: Partial<InitDebounceMixinOptions>): (app: Application$1) => void;
|
|
126
|
+
|
|
127
|
+
interface FilterQueryOptions<T> {
|
|
128
|
+
service?: AdapterBase<T>;
|
|
129
|
+
operators?: FilterQueryOptions$1["operators"];
|
|
130
|
+
filters?: FilterQueryOptions$1["filters"];
|
|
131
|
+
}
|
|
132
|
+
declare function filterQuery<T>(query: Query, _options?: FilterQueryOptions<T>): any;
|
|
133
|
+
|
|
134
|
+
type Handle = "target" | "source" | "combine" | "intersect" | "intersectOrFull";
|
|
135
|
+
type FirstLast = "first" | "last";
|
|
136
|
+
type ActionOnEmptyIntersect = (target: unknown, source: unknown, prependKey: Path) => void;
|
|
137
|
+
interface MergeQueryOptions<T> extends FilterQueryOptions<T> {
|
|
138
|
+
defaultHandle: Handle;
|
|
139
|
+
actionOnEmptyIntersect: ActionOnEmptyIntersect;
|
|
140
|
+
useLogicalConjunction: boolean;
|
|
141
|
+
handle?: {
|
|
142
|
+
[key: string]: Handle;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare function mergeArrays<T>(targetArr: T[], sourceArr: T[], handle: Handle, prependKey?: Path, actionOnEmptyIntersect?: ActionOnEmptyIntersect): T[] | undefined;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Merges two queries into one.
|
|
150
|
+
* @param target Query to be merged into
|
|
151
|
+
* @param source Query to be merged from
|
|
152
|
+
* @param _options
|
|
153
|
+
* @returns Query
|
|
154
|
+
*/
|
|
155
|
+
declare function mergeQuery<T = any>(target: Query, source: Query, _options?: Partial<MergeQueryOptions<T>>): Query;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* util to get paginate options from context
|
|
159
|
+
* 1. it uses `context.params.paginate` if it exists
|
|
160
|
+
* 2. it uses `service.options.paginate` if it exists
|
|
161
|
+
* 3. it uses `context.params.adapter` if it exists
|
|
162
|
+
*/
|
|
163
|
+
declare const getPaginate: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => PaginationOptions | undefined;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* util to check if a hook is a multi hook:
|
|
167
|
+
* - find: true
|
|
168
|
+
* - get: false
|
|
169
|
+
* - create: `context.data` is an array
|
|
170
|
+
* - update: false
|
|
171
|
+
* - patch: `context.id == null`
|
|
172
|
+
* - remove: `context.id == null`
|
|
173
|
+
*/
|
|
174
|
+
declare const isMulti: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => boolean;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* util to check if a hook is a paginated hook using `getPaginate`
|
|
178
|
+
*/
|
|
179
|
+
declare const isPaginated: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => boolean;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* util to mark a hook for skip, has to be used with `shouldSkip`
|
|
183
|
+
*/
|
|
184
|
+
declare function markHookForSkip<H extends HookContext = HookContext>(hookName: string, type: "all" | MaybeArray<HookType>, context?: H): H | undefined;
|
|
185
|
+
|
|
186
|
+
interface PushSetOptions {
|
|
187
|
+
unique?: boolean;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* util to push a value to an array at a given path in an object
|
|
191
|
+
*/
|
|
192
|
+
declare const pushSet: (obj: Record<string, unknown>, path: string | Path, val: unknown, options?: PushSetOptions) => unknown[];
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* util to set `context.result` to an empty array or object, depending on the hook type
|
|
196
|
+
*/
|
|
197
|
+
declare const setResultEmpty: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(context: H) => H;
|
|
198
|
+
|
|
199
|
+
type ShouldSkipOptions = {
|
|
200
|
+
notSkippable?: boolean;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* util to detect if a hook should be skipped
|
|
204
|
+
*/
|
|
205
|
+
declare const shouldSkip: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, O extends ShouldSkipOptions = ShouldSkipOptions>(hookName: string, context: H, options?: O | undefined) => boolean;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* util to validate a query for operators
|
|
209
|
+
*/
|
|
210
|
+
declare const validateQueryProperty: (query: any, operators?: string[]) => Query;
|
|
211
|
+
|
|
212
|
+
declare const filterArray: <T extends string[]>(...keys: T) => { [key in T[number]]: (value: any, options: FilterQueryOptions$1) => any; };
|
|
213
|
+
|
|
214
|
+
declare const filterObject: <T extends string[]>(...keys: T) => { [key in T[number]]: (value: any, options: FilterQueryOptions$1) => any; };
|
|
215
|
+
|
|
216
|
+
type Single<T> = T extends Array<infer U> ? U : T;
|
|
217
|
+
type AsArray<T> = T extends any[] ? T : [T];
|
|
218
|
+
type InferCreateData<S> = S extends {
|
|
219
|
+
create: (data: infer D, params: any) => any;
|
|
220
|
+
} ? D : never;
|
|
221
|
+
type InferCreateDataSingle<S> = Single<InferCreateData<S>>;
|
|
222
|
+
type InferUpdateData<S> = S extends {
|
|
223
|
+
update: (id: any, data: infer D, params: any) => any;
|
|
224
|
+
} ? D : never;
|
|
225
|
+
type InferPatchData<S> = S extends {
|
|
226
|
+
patch: (id: any, data: infer D, params: any) => any;
|
|
227
|
+
} ? D : never;
|
|
228
|
+
type InferGetResult<S> = S extends {
|
|
229
|
+
get: (id: any, params: any) => infer R;
|
|
230
|
+
} ? Awaited<R> : never;
|
|
231
|
+
type InferFindResult<S> = S extends {
|
|
232
|
+
find: (params: any) => infer R;
|
|
233
|
+
} ? Awaited<R> : never;
|
|
234
|
+
type InferCreateResult<S, D = unknown> = S extends {
|
|
235
|
+
create: (data: any, params: any) => infer R;
|
|
236
|
+
} ? D extends any[] ? AsArray<Awaited<R>> : D extends InferCreateDataSingle<S> ? Single<Awaited<R>> : Awaited<R> : never;
|
|
237
|
+
type InferCreateResultSingle<S> = Single<InferCreateResult<S>>;
|
|
238
|
+
type InferUpdateResult<S> = S extends {
|
|
239
|
+
update: (id: any, data: any, params: any) => infer R;
|
|
240
|
+
} ? Awaited<R> : never;
|
|
241
|
+
type InferPatchResult<S, IdOrNullable = any> = S extends {
|
|
242
|
+
patch: (id: Id, data: any, params: any) => infer R;
|
|
243
|
+
} ? IdOrNullable extends Id ? Single<Awaited<R>> : IdOrNullable extends null ? AsArray<Awaited<R>> : Awaited<R> : never;
|
|
244
|
+
type InferRemoveResult<S, IdOrNullable = any> = S extends {
|
|
245
|
+
remove: (id: IdOrNullable, params: any) => infer R;
|
|
246
|
+
} ? IdOrNullable extends Id ? Single<Awaited<R>> : IdOrNullable extends null ? AsArray<Awaited<R>> : Awaited<R> : never;
|
|
247
|
+
type GetService<App extends Application, Path extends string> = App["services"][Path];
|
|
248
|
+
type InferGetResultFromPath<App extends Application, Path extends string> = InferGetResult<GetService<App, Path>>;
|
|
249
|
+
type InferFindResultFromPath<App extends Application, Path extends string> = InferFindResult<GetService<App, Path>>;
|
|
250
|
+
type InferCreateDataFromPath<App extends Application, Path extends string> = InferCreateData<GetService<App, Path>>;
|
|
251
|
+
type InferCreateDataSingleFromPath<App extends Application, Path extends string> = InferCreateDataSingle<GetService<App, Path>>;
|
|
252
|
+
type InferCreateResultFromPath<App extends Application, Path extends string, D = unknown> = InferCreateResult<GetService<App, Path>, D>;
|
|
253
|
+
type InferCreateResultSingleFromPath<App extends Application, Path extends string> = InferCreateResultSingle<GetService<App, Path>>;
|
|
254
|
+
type InferUpdateDataFromPath<App extends Application, Path extends string> = InferUpdateData<GetService<App, Path>>;
|
|
255
|
+
type InferPatchDataFromPath<App extends Application, Path extends string> = InferPatchData<GetService<App, Path>>;
|
|
256
|
+
type InferUpdateResultFromPath<App extends Application, Path extends string> = InferUpdateResult<GetService<App, Path>>;
|
|
257
|
+
type InferPatchResultFromPath<App extends Application, Path extends string, IdOrNullable = any> = InferPatchResult<GetService<App, Path>, IdOrNullable>;
|
|
258
|
+
type InferRemoveResultFromPath<App extends Application, Path extends string, IdOrNullable = any> = InferRemoveResult<GetService<App, Path>, IdOrNullable>;
|
|
259
|
+
type InferDataFromPath<App extends Application, Path extends string, Method extends "create" | "update" | "patch"> = Method extends "create" ? InferCreateDataFromPath<App, Path> : Method extends "update" ? InferUpdateDataFromPath<App, Path> : Method extends "patch" ? InferPatchDataFromPath<App, Path> : never;
|
|
260
|
+
type InferResultFromPath<App extends Application, Path extends string, Method extends "get" | "find" | "create" | "update" | "patch" | "remove"> = Method extends "get" ? InferGetResultFromPath<App, Path> : Method extends "find" ? InferFindResultFromPath<App, Path> : Method extends "create" ? InferCreateResultFromPath<App, Path> : Method extends "update" ? InferUpdateResultFromPath<App, Path> : Method extends "patch" ? InferPatchResultFromPath<App, Path> : Method extends "remove" ? InferRemoveResultFromPath<App, Path> : never;
|
|
261
|
+
|
|
262
|
+
export { ActionOnEmptyIntersect, CreateRelatedOptions, DebouncedFunctionApp, DebouncedService, DebouncedStore, DebouncedStoreOptions, FilterQueryOptions, FirstLast, GetItemsIsArrayOptions, GetItemsIsArrayResult, GetService, Handle, HookForEachOptions, HookRunPerItemOptions, HookSetDataOptions, InferCreateData, InferCreateDataFromPath, InferCreateDataSingle, InferCreateDataSingleFromPath, InferCreateResult, InferCreateResultFromPath, InferCreateResultSingle, InferCreateResultSingleFromPath, InferDataFromPath, InferFindResult, InferFindResultFromPath, InferGetResult, InferGetResultFromPath, InferPatchData, InferPatchDataFromPath, InferPatchResult, InferPatchResultFromPath, InferRemoveResult, InferRemoveResultFromPath, InferResultFromPath, InferUpdateData, InferUpdateDataFromPath, InferUpdateResult, InferUpdateResultFromPath, InitDebounceMixinOptions, MergeQueryOptions, OnDeleteAction, OnDeleteOptions, Predicate, PredicateWithContext, PushSetOptions, RemoveRelatedOptions, ShouldSkipOptions, checkMulti, createRelated, debounceMixin, filterArray, filterObject, filterQuery, forEach, getItemsIsArray, getPaginate, isMulti, isPaginated, makeDefaultOptions, markHookForSkip, mergeArrays, mergeQuery, onDelete, parseFields, pushSet, removeRelated, runPerItem, setData, setResultEmpty, shouldSkip, validateQueryProperty };
|