quetch
- AggregateFunction
- AggregateFunctionOperator
- Any
- Context
- CustomFieldAggregateMap
- CustomFieldMap
- Field
- FieldFiltered
- FieldFunction
- FieldFunctionCustom
- FieldFunctionFormatDate
- FieldFunctionReturn
- Filter
- FilterArray
- FilterBoolean
- FilterChildren
- FilterCustom
- FilterField
- FilterGroup
- FilterNumber
- FilterOperator
- FilterString
- FilterStringIntersect
- FilterStringMatch
- Get
- Group
- Handler
- Immutable
- InjectCustomFields
- Item
- Key
- KeyFiltered
- Locale
- Mutable
- NextHandler
- Order
- Parameters
- Path
- PathFiltered
- Query
- QueryAggregate
- QueryCreate
- QueryCreateMultiple
- QueryDelete
- QueryDeleteMultiple
- QueryMethod
- QueryRead
- QueryReadMultiple
- QuerySettings
- QueryUpdate
- QueryUpdateMultiple
- Result
- Store
- aggregate
- branch
- cache
- combine
- cork
- defineCheckQuery
- defineCustomFetch
- defineGenericFetch
- escapeRegex
- fetchExternal
- fetchLocal
- filterChildren
- filterFromContext
- filterItem
- get
- identity
- isFilterGroup
- log
- normalizeOrder
- queryItemList
- retry
- sortItemList
Ƭ AggregateFunction<T
>: "length"
| { operator
: "length"
} | { field
: keyof T
; operator
: "median"
| "standardDeviation"
| "mean"
| "minimum"
| "maximum"
| "variance"
| "mode"
}
Aggregation function.
Name | Type |
---|---|
T |
extends object |
lib/types/AggregateFunction.ts:4
Ƭ AggregateFunctionOperator: Exclude
<AggregateFunction
<{}>, string
>["operator"
]
lib/types/AggregateFunctionOperator.ts:3
Ƭ Any: boolean
| string
| number
| object
| symbol
| null
| undefined
| any
[] | (...args
: any
[]) => any
Ƭ Context<T
>: { [K in keyof T]?: T[K] }
Name | Type |
---|---|
T |
extends object |
Ƭ CustomFieldAggregateMap<T
>: Record
<string
, AggregateFunction
<T
>>
Name | Type |
---|---|
T |
extends object |
lib/types/CustomFieldAggregateMap.ts:3
Ƭ CustomFieldMap<T
>: Record
<string
, FieldFunction
<T
>>
Name | Type |
---|---|
T |
extends object |
Ƭ Field<T
>: keyof T
| Path
<T
>
Name | Type |
---|---|
T |
extends object |
Ƭ FieldFiltered<T
, P
>: KeyFiltered
<T
, P
> | PathFiltered
<T
, P
>
Name | Type |
---|---|
T |
extends object |
P |
P |
Ƭ FieldFunction<T
>: FieldFunctionCustom
<T
> | FieldFunctionFormatDate
<T
>
Name | Type |
---|---|
T |
extends object |
Ƭ FieldFunctionCustom<T
>: Object
Applies a custom field transform function.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
operator |
"custom" |
value |
(item : T ) => any |
lib/types/FieldFunctionCustom.ts:4
Ƭ FieldFunctionFormatDate<T
>: Object
Formats the date found in a given field, which can be an ISO string date or a timestamp.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
field |
FieldFiltered <T , string | number > |
format |
string |
operator |
"formatDate" |
lib/types/FieldFunctionFormatDate.ts:6
Ƭ FieldFunctionReturn: Object
Return types of custom field functions.
Name | Type |
---|---|
formatDate |
string |
lib/types/FieldFunctionReturn.ts:4
Ƭ Filter<T
>: FilterArray
<T
> | FilterBoolean
<T
> | FilterChildren
<T
> | FilterCustom
<T
> | FilterField
<T
> | FilterNumber
<T
> | FilterGroup
<T
> | FilterString
<T
> | FilterStringIntersect
<T
> | FilterStringMatch
<T
>
Describes a predicate for filtering items.
Name | Type |
---|---|
T |
extends object |
Ƭ FilterArray<T
, P
>: Object
Checks if a given array field matches a given array value according to a given operator.
Name | Type |
---|---|
T |
extends object |
P |
Any |
Name | Type |
---|---|
field |
FieldFiltered <T , P []> |
operator |
"equal" | "include" | "intersect" |
value |
P [] |
Ƭ FilterBoolean<T
>: Object
Checks if a given boolean field is true
or false
.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
field |
FieldFiltered <T , boolean > |
operator |
"equal" | "notEqual" |
value |
boolean |
Ƭ FilterChildren<T
>: Object
Matches the direct children of a specified value
item.
If deep
is true
, also captures all the descendants.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
[SymbolCache]? |
Filter <T > |
deep? |
boolean |
operator |
"children" |
value? |
Context <T > | string |
lib/types/FilterChildren.ts:10
Ƭ FilterCustom<T
>: Object
Custom filter where value(item)
returns true
for matching items.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
operator |
"custom" |
value |
(item : T ) => boolean |
Ƭ FilterField<T
>: Object
Checks if a given field exists.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
operator |
"exist" |
- |
value |
Field <T > |
The field name for which to check its existence. |
Ƭ FilterGroup<T
>: { operator
: "all"
; value
: Filter
<T
>[] } | { operator
: "any"
| "none"
; value?
: Filter
<T
>[] }
Joins a list of filters with a specific boolean operator.
Name | Type |
---|---|
T |
extends object |
Ƭ FilterNumber<T
>: Object
Checks if a given number field matches a given number value according to a given operator.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
field |
FieldFiltered <T , number > |
operator |
"equal" | "notEqual" | "greaterThan" | "greaterThanOrEqual" | "lowerThan" | "lowerThanOrEqual" |
value |
number |
Ƭ FilterOperator: Filter
<never
>["operator"
]
Ƭ FilterString<T
>: Object
Checks if a given string field matches a given string value according to a given operator.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
field |
FieldFiltered <T , string > |
locale? |
Locale |
operator |
"equal" | "notEqual" | "startWith" | "endWith" | "include" | "greaterThan" | "greaterThanOrEqual" | "lowerThan" | "lowerThanOrEqual" |
options? |
Intl.CollatorOptions |
value |
string |
Ƭ FilterStringIntersect<T
>: Object
Checks if a given string field has any of the provided values.
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
field |
FieldFiltered <T , string > |
locale? |
Locale |
operator |
"intersect" |
options? |
Intl.CollatorOptions |
value |
string [] |
lib/types/FilterStringIntersect.ts:7
Ƭ FilterStringMatch<T
>: Object
Checks if a given string field matches a given regular expression.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
[SymbolCache]? |
RegExp |
Compiled regular expression generated by the testFilter function. |
field |
FieldFiltered <T , string > |
- |
operator |
"match" |
- |
options? |
{ dotAll? : boolean ; ignoreCase? : boolean } |
Regular expression options. |
options.dotAll? |
boolean |
Allow . to match newlines. |
options.ignoreCase? |
boolean |
Ignore casing differences if true . |
value |
string |
Raw regular expression string. |
lib/types/FilterStringMatch.ts:8
Ƭ Get<T
, P
>: [P
] extends [[infer K, ...(infer R)]] ? K
extends keyof T
? R
extends Path
<T
[K
]> ? Get
<T
[K
], R
> : T
[K
] : never
: never
Returns the type of the property at the specified K
key.
Name |
---|
T |
P |
Ƭ Group<T
>: keyof T
| { field
: keyof T
}
Specifies how items should be grouped.
Name | Type |
---|---|
T |
extends object |
Ƭ Handler<I
, O
, NI
, No
>: (input
: I
, next
: NextHandler
<NI
, No
>) => Promise
<O
>
Handles an input
query and returns an output
promise, eventually using the next
handler.
Name |
---|
I |
O |
NI |
No |
▸ (input
, next
): Promise
<O
>
Name | Type |
---|---|
input |
I |
next |
NextHandler <NI , No > |
Promise
<O
>
Ƭ Immutable<T
>: { readonly [K in keyof T]: T[K] }
Name | Type |
---|---|
T |
extends object |
Ƭ InjectCustomFields<T
, C
>: C
extends CustomFieldMap
<T
> ? { readonly [K in keyof T | keyof C]: K extends keyof T ? T[K] : K extends keyof C ? C[K] extends FieldFunctionCustom<T> ? ReturnType<C[K]["value"]> : C[K]["operator"] extends keyof FieldFunctionReturn ? FieldFunctionReturn[C[K]["operator"]] : never : never } : T
Injects the custom fields into the entity type.
Name | Type |
---|---|
T |
extends object |
C |
extends CustomFieldMap <T > | undefined |
lib/types/InjectCustomFields.ts:8
Ƭ Item<T
, S
>: T
extends infer I[] ? I
: T
extends ReadonlyArray
<infer I> ? I
: S
Returns the inferred item type of an array, or an alternative type if it is something else (e.g., undefined
).
Name | Type |
---|---|
T |
T |
S |
undefined |
Ƭ Key: string
| number
| symbol
Ƭ KeyFiltered<T
, P
>: keyof T
& keyof { [K in keyof T as T[K] extends P ? K : never]-?: T[K] }
Returns object type with field extending the provided P
type.
Name | Type |
---|---|
T |
extends object |
P |
P |
Ƭ Locale: string
| string
[]
Ƭ Mutable<T
>: { -readonly [K in keyof T]: T[K] }
Name | Type |
---|---|
T |
extends object |
Ƭ NextHandler<I
, R
>: (input
: I
) => Promise
<R
>
Handles an input
query and returns an output
promise.
Name |
---|
I |
R |
▸ (input
): Promise
<R
>
Name | Type |
---|---|
input |
I |
Promise
<R
>
Ƭ Order<T
>: keyof T
| { descending?
: boolean
; field
: keyof T
}
Order item.
Name | Type |
---|---|
T |
extends object |
Ƭ Parameters: Record
<string
, string
| string
[] | number
| number
[]>
Ƭ Path<T
>: T
extends infer P[] ? [number
] | [number
, ...Path<P>] : T
extends object
? { [K in keyof T]-?: [K] | [K, ...Path<T[K]>] }[keyof T
] : never
Name |
---|
T |
Ƭ PathFiltered<T
, P
>: T
extends infer I[] ? I
extends P
? [number
] : [number
, ...PathFiltered<I, P>] : T
extends object
? { [K in keyof T]-?: T[K] extends P ? [K] : [K, ...PathFiltered<T[K], P>] }[keyof T
] : never
Name |
---|
T |
P |
Ƭ Query<T
>: QueryRead
<T
> | QueryReadMultiple
<T
> | QueryCreate
<T
> | QueryCreateMultiple
<T
> | QueryUpdate
<T
> | QueryUpdateMultiple
<T
> | QueryDelete
<T
> | QueryDeleteMultiple
<T
> | QueryAggregate
<T
>
Query that fetches or mutates an entity.
Name | Type |
---|---|
T |
extends object |
Ƭ QueryAggregate<T
>: Object
Query for computing an aggregated value.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
aggregator |
AggregateFunction <T > |
- |
context? |
Context <T > |
Common item properties to use for identifying the item. |
filter? |
Filter <T > |
- |
method |
"aggregate" |
- |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
lib/types/QueryAggregate.ts:10
Ƭ QueryCreate<T
>: Object
Query for creating an item.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to create the item. |
method |
"create" |
- |
multiple? |
false |
- |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
value |
Partial <T > |
Value properties of the item to create. |
Ƭ QueryCreateMultiple<T
>: Object
Query for creating multiple items.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to create the items. |
method |
"create" |
- |
multiple |
true |
- |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
value |
Partial <T >[] |
- |
lib/types/QueryCreateMultiple.ts:8
Ƭ QueryDelete<T
>: Object
Query for deleting an item.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to delete the item. |
filter? |
Filter <T > |
- |
method |
"delete" |
- |
multiple? |
false |
- |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
Ƭ QueryDeleteMultiple<T
>: Object
Query for deleting multiple items.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to delete the item. |
filter? |
Filter <T > |
- |
method |
"delete" |
- |
multiple |
true |
- |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
lib/types/QueryDeleteMultiple.ts:9
Ƭ QueryMethod: Exclude
<Query
<never
>["method"
], undefined
>
Available query methods.
Ƭ QueryRead<T
>: Object
Query for reading a single item.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to delete the item. |
fields? |
readonly keyof T [] |
Item fields to pick. If omitted, all fields are picked. |
filter? |
Filter <T > |
Filter for finding the item, if it cannot be found based on the context . |
group? |
never |
- |
limit? |
never |
- |
method? |
"read" |
- |
multiple? |
false |
- |
offset? |
never |
- |
order? |
Order <T >[] |
Order by which the items should be sorted. |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
Ƭ QueryReadMultiple<T
>: Object
Query for getting a list of items.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the item. |
fields? |
readonly keyof T [] |
Item fields to pick. If omitted, all fields are picked. |
filter? |
Filter <T > |
Filter that picks the items. |
group? |
Group <T >[] |
Groups items by specified fields. |
limit? |
number |
Upper bound of the number of items to return. |
method? |
"read" |
- |
multiple |
true |
- |
offset? |
number |
Offset of the first matching item. |
order? |
Order <T >[] |
Order by which the items should be sorted. |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
lib/types/QueryReadMultiple.ts:11
Ƭ QuerySettings<T
>: Object
Settings to use when doing a query.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
abortController? |
AbortController |
Abort controller to abort the query. |
pathFieldKey? |
FieldFiltered <T , string > |
Field key to that contains the path value of an item. |
pathFieldSeparator? |
string |
String used to separate the path nodes of an item. |
signal? |
AbortSignal |
Abort signal to abort the query. |
transformFilterChildren? |
(filter : FilterChildren <T >) => Exclude <Filter <T >, { operator : "children" }> |
- |
Ƭ QueryUpdate<T
>: Object
Query for updating an item.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to update the item. |
filter? |
Filter <T > |
Filter for finding the item, if it cannot be found based on the context . |
group? |
never |
- |
method |
"update" |
- |
multiple? |
false |
- |
offset? |
never |
- |
order |
never |
- |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
value |
Partial <T > |
Partial property values to update. |
Ƭ QueryUpdateMultiple<T
>: Object
Query for updating multiple items.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
context? |
Context <T > |
Common item properties to use for identifying the context in which to update the item. |
filter? |
Filter <T > |
- |
limit? |
number |
Sets the upper bound of the number of items to update. |
method |
"update" |
- |
multiple |
true |
- |
offset? |
number |
Offset of the first matching item to update. |
order? |
Order <T >[] |
Order by which the items should be sorted. |
parameters? |
Parameters |
Query parameters. |
settings? |
QuerySettings <T > |
Query settings. |
value |
Partial <T >[] |
Partial property values to update. |
lib/types/QueryUpdateMultiple.ts:10
Ƭ Result<T
, Q
>: [Q
] extends [{ method
: "read"
}] ? [Q
] extends [{ multiple
: true
}] ? ResultRead
<T
, Q
>[] : ResultRead
<T
, Q
> : [Q
] extends [{ method
: "aggregate"
}] ? number
: [Q
] extends [{ multiple
: true
}] ? ResultRead
<T
, Q
>[] : ResultRead
<T
, Q
>
Name | Type |
---|---|
T |
extends object |
Q |
extends Query <T > |
Ƭ Store<T
>: Object
Name | Type |
---|---|
T |
any |
Name | Type |
---|---|
delete |
(key : string ) => Promise <void > |
get |
(key : string ) => Promise <T > |
has |
(key : string ) => Promise <boolean > |
set |
(key : string , value : T ) => Promise <void > |
▸ aggregate<I
, O
, In
, On
>(options
): Handler
<I
, O
, In
, On
>
Aggregates multiple incoming query calls into one query.
Queries are grouped according to the string key returned by queryGroupId(query)
. Inside a group, each query is identified with queryId(query)
.
The aggregated query is built from the object returned by queryForGroup(queryList, groupId)
, after at least delay
milliseconds after the first non-aggregated aggregatable query call.
When the aggregated query resolves, the result is dispatched back to each aggregatable query call of the category by dispatching the result for each query returned by resultForQuery(result, query)
.
If a query occurs twice, mergeQuery(query, currentQuery)
is called and the output replaces the previous query.
Name | Type |
---|---|
I |
extends Query <any > & { type : any } |
O |
O |
In |
extends Query <any > & { type : any } |
On |
On |
Name | Type | Default value |
---|---|---|
options |
Object |
undefined |
options.delay? |
number |
200 |
options.mergeQuery? |
(query : I , currentQuery : I ) => I |
undefined |
options.queryForGroup |
(queryList : I [], group : string ) => Query <any > & { type : any } |
undefined |
options.queryGroupId? |
(query : I ) => undefined | string |
undefined |
options.queryId? |
(query : I ) => undefined | string |
undefined |
options.resultForQuery |
(resultList : O [], query : I ) => O |
undefined |
Handler
<I
, O
, In
, On
>
lib/middlewares/aggregate.ts:16
▸ branch<I
, O
, In
, On
>(condition
, left
, right?
): Handler
<I
, O
, In
, On
>
Dispatches an incoming query to left
if condition(query)
returns a truthy value, right
otherwise. This is helpful for sending queries to different resolvers.
Name |
---|
I |
O |
In |
On |
Name | Type |
---|---|
condition |
(input : I ) => boolean |
left |
Handler <I , O , In , On > |
right |
Handler <I , O , In , On > |
Handler
<I
, O
, In
, On
>
Example
const customFetch = combine(
branch(query => query.protocol === 'gql', gqlHandlers),
restHandlers,
)
▸ cache<I
, O
, In
, On
>(«destructured»
): Handler
<I
, O
, In
, On
>
Name | Type |
---|---|
I |
extends Query <any > & { type : any } |
O |
O |
In |
extends Query <any > |
On |
On |
Name | Type | Description |
---|---|---|
«destructured» |
Object |
- |
› extendCachedQuery |
(query : I , cachedQuery : I ) => undefined | I |
Returns a query that completes the cached value. Returns undefined if the query should not be completed. |
› invalidatesItem |
(query : I , cachedQuery : I , cachedValue : any ) => boolean |
Returns true if the cached item must be invalidated. |
› itemId? |
(query : I ) => undefined | string |
Unique identifier for the item to cache. Returns undefined if the item should not be cached. |
› mergeItem |
(value : any , cachedValue : any , query : I , cachedQuery : I ) => any |
Merges the value from the extended query with the cached value. Only called when extendCachedQuery returns a query. |
› mergeQuery |
(extendedQuery : I , cachedQuery : I ) => I |
Merges the extended query with the cached query. Only called when extendCachedQuery returns a query. |
› store |
Store <CachedItem <I >> |
Cache store. |
Handler
<I
, O
, In
, On
>
▸ combine<I0
, O0
, I1
, O1
, I2
, O2
, I3
, O3
, I4
, O4
, I5
, O5
, I6
, O6
, I7
, O7
, I8
, O8
, I9
, O9
, I10
, O10
, I11
, O11
, I12
, O12
, I13
, O13
, I14
, O14
, I15
, O15
, I16
, O16
, I17
, O17
, I18
, O18
, I19
, O19
, I20
, O20
, I21
, O21
>(...handlerList
): Handler
<I0
, O0
, I21
, O21
>
Combines the provided handler into a single handler.
Name |
---|
I0 |
O0 |
I1 |
O1 |
I2 |
O2 |
I3 |
O3 |
I4 |
O4 |
I5 |
O5 |
I6 |
O6 |
I7 |
O7 |
I8 |
O8 |
I9 |
O9 |
I10 |
O10 |
I11 |
O11 |
I12 |
O12 |
I13 |
O13 |
I14 |
O14 |
I15 |
O15 |
I16 |
O16 |
I17 |
O17 |
I18 |
O18 |
I19 |
O19 |
I20 |
O20 |
I21 |
O21 |
Name | Type | Description |
---|---|---|
...handlerList |
readonly [Handler <I0 , O0 , I1 , O1 >, Handler <I1 , O1 , I2 , O2 >, undefined | Handler <I2 , O2 , I3 , O3 >, undefined | Handler <I3 , O3 , I4 , O4 >, undefined | Handler <I4 , O4 , I5 , O5 >, undefined | Handler <I5 , O5 , I6 , O6 >, undefined | Handler <I6 , O6 , I7 , O7 >, undefined | Handler <I7 , O7 , I8 , O8 >, undefined | Handler <I8 , O8 , I9 , O9 >, undefined | Handler <I9 , O9 , I10 , O10 >, undefined | Handler <I10 , O10 , I11 , O11 >, undefined | Handler <I11 , O11 , I12 , O12 >, undefined | Handler <I12 , O12 , I13 , O13 >, undefined | Handler <I13 , O13 , I14 , O14 >, undefined | Handler <I14 , O14 , I15 , O15 >, undefined | Handler <I15 , O15 , I16 , O16 >, undefined | Handler <I16 , O16 , I17 , O17 >, undefined | Handler <I17 , O17 , I18 , O18 >, undefined | Handler <I18 , O18 , I19 , O19 >, undefined | Handler <I19 , O19 , I20 , O20 >, undefined | Handler <I20 , O20 , I21 , O21 >] |
List of handlers to combine. |
Handler
<I0
, O0
, I21
, O21
>
Handler that combines all provided handlers.
lib/middlewares/combine.ts:801
▸ cork(input
): Promise
<never
>
Uncallable handler used to terminate a sequence of handlers combined with combine
.
Name | Type |
---|---|
input |
never |
Promise
<never
>
▸ defineCheckQuery<M
>(): <T, Q>(query
: Q
& { type
: T
[] }) => typeof query
<K, T, Q>(query
: Q
& { type
: K
}) => typeof query
Returns a function that checks queries. This is useful to prevent the query to have its type being narrowed if declared outside of a custom fetcher function argument.
Name | Type |
---|---|
M |
extends Record <string , object > |
fn
Function that checks queries.
▸ <T
, Q
>(query
): typeof query
Name | Type |
---|---|
T |
extends object |
Q |
extends Query <T > |
Name | Type |
---|---|
query |
Q & { type : T [] } |
typeof query
▸ <K
, T
, Q
>(query
): typeof query
Name | Type |
---|---|
K |
extends string | number | symbol |
T |
extends object |
Q |
extends Query <T > |
Name | Type |
---|---|
query |
Q & { type : K } |
typeof query
lib/tools/defineCheckQuery.ts:8
▸ defineCustomFetch<M
>(handler
): <K, T, Q>(query
: Q
& { type
: K
}) => Promise
<Result
<T
, Q
>><T, Q>(type
: T
[], query
: Q
) => Promise
<Result
<T
, Q
>>
Returns a custom fetch function that handles a query
Name | Type |
---|---|
M |
extends Record <string , object > |
Name | Type | Description |
---|---|---|
handler |
Handler <Query <any > & { type : any[] | Key }, any , never , never > |
The query handler. |
fn
A custom fetch function.
▸ <K
, T
, Q
>(query
): Promise
<Result
<T
, Q
>>
Name | Type |
---|---|
K |
extends string | number | symbol |
T |
extends object |
Q |
extends Query <T > |
Name | Type |
---|---|
query |
Q & { type : K } |
Promise
<Result
<T
, Q
>>
▸ <T
, Q
>(type
, query
): Promise
<Result
<T
, Q
>>
Name | Type |
---|---|
T |
extends object |
Q |
extends Query <T > |
Name | Type |
---|---|
type |
T [] |
query |
Q |
Promise
<Result
<T
, Q
>>
lib/tools/defineCustomFetch.ts:11
▸ defineGenericFetch<K
>(handler
): <T>() => <Q>(query
: Q
& { type
: K
| T
[] }) => Promise
<Result
<T
, Q
>>
Returns a generic fetch function that has to be called like this:
genericFetch<T>()(query)
Name | Type |
---|---|
K |
extends string |
Name | Type | Description |
---|---|---|
handler |
Handler <Query <any > & { type : any[] | Key }, any , never , never > |
The query handler. |
fn
A curried generic fetch function.
▸ <T
>(): <Q>(query
: Q
& { type
: K
| T
[] }) => Promise
<Result
<T
, Q
>>
Name | Type |
---|---|
T |
extends object |
fn
▸ <Q
>(query
): Promise
<Result
<T
, Q
>>
Name | Type |
---|---|
Q |
extends Query <T > |
Name | Type |
---|---|
query |
Q & { type : K | T [] } |
Promise
<Result
<T
, Q
>>
lib/tools/defineGenericFetch.ts:14
▸ escapeRegex(pattern
): string
Escapes special characters of a given regular expresion pattern
.
Name | Type | Description |
---|---|---|
pattern |
string |
Regular expression string to escape. |
string
Escaped regular expression
▸ fetchExternal(fetch?
): Handler
<Request
, Response
, never
, never
>
Calls the provided fetch
function, which defaults to the DOM fetch
function, with the incoming query
.
Name | Type | Description |
---|---|---|
fetch |
(input : RequestInfo | URL , init? : RequestInit ) => Promise <Response > |
MDN Reference |
Handler
<Request
, Response
, never
, never
>
Handler that returns a promise that resolves to the response.
lib/middlewares/fetchExternal.ts:12
▸ fetchLocal<T
>(): Handler
<Query
<T
> & { type
: T
[] }, any
, never
, never
>
Performs the fetch query on local data.
Name | Type |
---|---|
T |
extends object |
Handler
<Query
<T
> & { type
: T
[] }, any
, never
, never
>
Promise that resolves to the response.
lib/middlewares/fetchLocal.ts:9
▸ filterChildren<T
>(parentPath
, pathFieldKey
, deep?
, pathSeparator?
): Filter
<T
>
Name | Type |
---|---|
T |
extends object |
Name | Type | Default value |
---|---|---|
parentPath |
string |
undefined |
pathFieldKey |
FieldFiltered <T , string > |
undefined |
deep |
boolean |
false |
pathSeparator |
string |
"/" |
Filter
<T
>
▸ filterFromContext<T
>(context
): Filter
<T
>
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
context |
Context <T > |
Filter
<T
>
lib/tools/filterFromContext.ts:5
▸ filterItem<T
>(filter
, value
, settings?
): boolean
Checks wether the provided value
matches the filter
or not.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
filter |
undefined | Filter <T > |
The filter to apply. |
value |
undefined | T |
The value to check. |
settings? |
QuerySettings <T > |
Optional query settings. |
boolean
true
if the value
matches the filter
and false
otherwise.
▸ get<T
, P
>(value
, path?
): Get
<T
, P
>
Gets the property value of the given value
at the specified path
(an array of object property names or array indexes).
If the path
is undefined, returns the value
itself.
If the path
is a string, it is considered as a path with one item.
If the path
leads to an unknown property, returns undefined
.
Name | Type |
---|---|
T |
T |
P |
extends string | number | symbol | [number ] | [keyof T <T >] | [keyof T <T >, ...Path<T<T>[keyof T<T>]>[]] |
Name | Type | Description |
---|---|---|
value |
T |
The value from which to get the property value. |
path? |
P |
The path leading to the property value or a property name or undefined . |
Get
<T
, P
>
The property value found at the given path, or undefined
if it cannot be found.
▸ identity<I
, O
, In
, On
>(input
, next
): Promise
<O
>
Name |
---|
I |
O |
In |
On |
Name | Type |
---|---|
input |
I |
next |
NextHandler <In , On > |
Promise
<O
>
▸ isFilterGroup<T
>(value
): value is FilterGroup<T>
Returns true
if the provided filter value
is a group filter or not.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
value |
undefined | Filter <T > |
The filter to test. |
value is FilterGroup<T>
Whether the provided filter is a group filter or not.
▸ log<I
, O
, In
, On
>(title?
): Handler
<I
, O
, In
, On
>
Logs the outgoing query and the incoming result or the error.
Name |
---|
I |
O |
In |
On |
Name | Type | Default value |
---|---|---|
title |
string |
"Query" |
Handler
<I
, O
, In
, On
>
Query handler
▸ normalizeOrder<T
>(order
): Object
Name | Type |
---|---|
T |
extends object |
Name | Type |
---|---|
order |
Order <T > |
Object
Name | Type |
---|---|
descending? |
boolean |
field |
keyof T |
▸ queryItemList<T
, Q
>(query
): Result
<T
, Q
>
Name | Type |
---|---|
T |
extends object |
Q |
extends Query <T > |
Name | Type |
---|---|
query |
Q & { type : T [] } |
Result
<T
, Q
>
▸ retry(options?
): Handler
<Request
, Response
, Request
, Response
>
Retries a failed query call up to amount
times, with a given delay
in milliseconds at ±delayDelta
milliseconds.
Note that an amount
set to Infinity
results in indefinitely trying to resolve a query call.
Only instances of RequestError
that do not result in a 500
status error will result in new tries. Other errors will propagate immediately.
Name | Type | Default value |
---|---|---|
options |
Object |
{} |
options.amount |
undefined | number |
5 |
options.delay |
undefined | number |
1000 |
options.delayDelta |
undefined | number |
500 |
Handler
<Request
, Response
, Request
, Response
>
Handler
▸ sortItemList<T
>(orderList
, value
): T
[]
Sorts provided value
array in place according to the orderList
.
Name | Type |
---|---|
T |
extends object |
Name | Type | Description |
---|---|---|
orderList |
undefined | Order <T >[] |
The order to use for sorting. |
value |
T [] |
The array to sort. |
T
[]
The same array sorted in place.