-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathlocation.ts
57 lines (51 loc) · 1.71 KB
/
location.ts
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
import { ConditionalPick } from 'type-fest'
import { EntryFieldTypes } from '../entry.js'
type Types = EntryFieldTypes.Location | undefined
export type ProximitySearchFilterInput = [number, number]
export type BoundingBoxSearchFilterInput = [number, number, number, number]
export type BoundingCircleSearchFilterInput = [number, number, number]
type BaseLocationFilter<
Fields,
SupportedTypes,
ValueType,
Prefix extends string,
QueryFilter extends string = '',
> = NonNullable<{
[FieldName in keyof ConditionalPick<Fields, SupportedTypes> as `${Prefix}.${string &
FieldName}[${QueryFilter}]`]?: ValueType
}>
/**
* near - location proximity search in provided fields
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/location-proximity-search | Documentation}
* @internal
*/
export type ProximitySearchFilter<Fields, Prefix extends string> = BaseLocationFilter<
Fields,
Types,
ProximitySearchFilterInput,
Prefix,
'near'
>
/**
* within - location in a bounding object in provided fields
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/locations-in-a-bounding-object | Documentation}
* @internal
*/
export type BoundingObjectSearchFilter<Fields, Prefix extends string> = BaseLocationFilter<
Fields,
Types,
BoundingCircleSearchFilterInput | BoundingBoxSearchFilterInput,
Prefix,
'within'
>
/**
* Location search
* @see {@link ProximitySearchFilter}
* @see {@link BoundingObjectSearchFilter}
* @internal
*/
export type LocationSearchFilters<Fields, Prefix extends string> = ProximitySearchFilter<
Fields,
Prefix
> &
BoundingObjectSearchFilter<Fields, Prefix>