Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
101 lines (83 loc) · 2.89 KB
/
Copy pathtypes.ts
File metadata and controls
101 lines (83 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import type { HookContext, NextFunction, Params } from '@feathersjs/feathers'
import type { Promisable } from './internal.utils.js'
export const hookTypes = ['around', 'before', 'after', 'error'] as const
export type HookType = (typeof hookTypes)[number]
export const methodNames = [
'find',
'get',
'create',
'update',
'patch',
'remove',
] as const
export type MethodName = (typeof methodNames)[number] | ({} & string) // allow custom methods
/**
* Whether multiple items may be changed in a single call: for every method
* (`true`), for none (`false`) or only for the listed methods.
*
* Mirrors the `multi` option of the feathers database adapters.
*/
export type Multi = boolean | MethodName[]
export type TransportName = 'socketio' | 'rest' | 'external' | 'server'
export type ContextFunctionSync<T, H extends HookContext = HookContext> = (
context: H,
) => T
export type ContextFunctionAsync<T, H extends HookContext = HookContext> = (
context: H,
) => Promise<T>
export type ContextFunction<T, H extends HookContext = HookContext> = (
context: H,
) => T | Promise<T>
export type PredicateContextSync<H extends HookContext = HookContext> = (
context: H,
) => boolean
export type PredicateContextAsync<H extends HookContext = HookContext> = (
context: H,
) => Promise<boolean>
export type PredicateFn<H extends HookContext = HookContext> = (
context: H,
) => boolean | Promise<boolean>
export type PredicateItemWithContext<T = any> = (
item: T,
context: HookContext,
) => boolean
export type TransformerFn<
T = Record<string, any>,
H extends HookContext = HookContext,
> = (
item: T,
options: { context: H; i: number },
) => Promisable<T | undefined | void>
export type TransformerInputFn<
T = Record<string, any>,
H extends HookContext = HookContext,
> = (item: T, options: { context: H; i: number }) => Promisable<any>
export type FieldKey<T> =
(keyof T & string) | `${Extract<keyof T, string>}.${string}`
export type StringFieldKey<T> =
| {
[K in keyof T & string]: T[K] extends string | null | undefined
? K
: never
}[keyof T & string]
| `${Extract<keyof T, string>}.${string}`
export type DefaultsInput<T extends Record<string, any>> = {
[K in keyof T & string]?: T[K] | (() => T[K])
} & {
[K in `${Extract<keyof T, string>}.${string}`]?: unknown
}
export declare type HookFunction<H extends HookContext = HookContext> = (
context: H,
next?: NextFunction,
) => Promise<H | void> | H | void
export type TransformParamsFn<P extends Params = Params> = (
params: P,
) => P | void
export type DispatchOption = boolean | 'both'
/** A single property name usable as a path segment. */
export type PropertyName = string | number | symbol
/**
* A property path, either as dot/bracket notation (`'user.address[0].city'`) or
* as pre-split segments (`['user', 'address', 0, 'city']`).
*/
export type PropertyPath = PropertyName | readonly PropertyName[]