Skip to content

Commit e519ce3

Browse files
committed
refactor: Clean up types
1 parent f228227 commit e519ce3

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/hooks/useStacSearch.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
import { useCallback, useState } from 'react';
22
import StacApi from '../stac-api';
33

4+
import type { ApiError, LoadingState } from '../types';
45
import type {
56
Link,
6-
Item,
77
Bbox,
88
CollectionIdList,
9-
ApiError,
109
SearchPayload,
10+
SearchResponse,
1111
LinkBody,
12-
LoadingState
13-
} from '../types';
14-
15-
type SearchResponse = {
16-
type: 'FeatureCollection'
17-
features: Item[]
18-
links: Link[]
19-
}
12+
} from '../types/stac';
2013

2114
type PaginationHandler = () => void;
2215

src/stac-api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { Bbox, SearchPayload, DateRange, ApiError, GenericObject } from '../types';
1+
import type { ApiError, GenericObject } from '../types';
2+
import type { Bbox, SearchPayload, DateRange } from '../types/stac';
23

34
type RequestPayload = SearchPayload;
45
type FetchOptions = {

src/types/index.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type GenericObject = {
2+
[key: string]: any // eslint-disable-line @typescript-eslint/no-explicit-any
3+
}
4+
5+
export type ApiError = {
6+
detail?: GenericObject | string
7+
status: number,
8+
statusText: string
9+
}
10+
11+
export type LoadingState = 'IDLE' | 'LOADING';

src/types.ts renamed to src/types/stac.d.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type { Geometry } from 'geojson';
2-
3-
export type GenericObject = {
4-
[key: string]: any // eslint-disable-line @typescript-eslint/no-explicit-any
5-
}
2+
import type { GenericObject } from '.';
63

74
export type Bbox = [number, number, number, number];
85
export type CollectionIdList = string[];
@@ -21,6 +18,12 @@ export type LinkBody = SearchPayload & {
2118
merge?: boolean
2219
}
2320

21+
export type SearchResponse = {
22+
type: 'FeatureCollection'
23+
features: Item[]
24+
links: Link[]
25+
}
26+
2427
export type Link = {
2528
href: string
2629
rel: string
@@ -51,11 +54,3 @@ export type Item = {
5154
links: Link[]
5255
assets: ItemAsset[]
5356
}
54-
55-
export type ApiError = {
56-
detail?: GenericObject | string
57-
status: number,
58-
statusText: string
59-
}
60-
61-
export type LoadingState = 'IDLE' | 'LOADING';

0 commit comments

Comments
 (0)