@@ -7,43 +7,49 @@ import { apiInstance } from './axios';
77const apiSequenceResponseSchema = z . object ( {
88 id : z . number ( ) ,
99 camera_id : z . number ( ) ,
10- azimuth : z . nullable ( z . number ( ) ) ,
11- cone_azimuth : z . number ( ) ,
10+ pose_id : z . number ( ) ,
11+ sequence_azimuth : z . number ( ) ,
1212 cone_angle : z . number ( ) ,
1313 is_wildfire : z . nullable ( z . string ( ) ) ,
1414 started_at : z . nullable ( z . iso . datetime ( { local : true } ) ) ,
1515 last_seen_at : z . nullable ( z . string ( ) ) ,
16- event_groups : z . union ( [ z . undefined ( ) , z . array ( z . array ( z . number ( ) ) ) ] ) ,
17- event_smoke_locations : z . union ( [
18- z . undefined ( ) ,
19- z . array ( z . tuple ( [ z . number ( ) , z . number ( ) ] ) ) ,
20- ] ) ,
16+ } ) ;
17+
18+ const apiAlertResponseSchema = z . object ( {
19+ id : z . number ( ) ,
20+ organization_id : z . number ( ) ,
21+ lat : z . nullable ( z . number ( ) ) ,
22+ lon : z . nullable ( z . number ( ) ) ,
23+ started_at : z . iso . datetime ( { local : true } ) ,
24+ last_seen_at : z . iso . datetime ( { local : true } ) ,
25+ sequences : z . array ( apiSequenceResponseSchema ) ,
2126} ) ;
2227
2328const apiDetectionResponseSchema = z . object ( {
2429 id : z . number ( ) ,
2530 camera_id : z . number ( ) ,
26- azimuth : z . nullable ( z . number ( ) ) ,
31+ pose_id : z . number ( ) ,
32+ sequence_id : z . number ( ) ,
2733 bucket_key : z . string ( ) ,
28- bboxes : z . string ( ) ,
34+ bbox : z . string ( ) ,
35+ others_bboxes : z . nullable ( z . string ( ) ) ,
2936 created_at : z . iso . datetime ( { local : true } ) ,
3037 url : z . string ( ) ,
3138} ) ;
3239
33- export type SequenceType = z . infer < typeof apiSequenceResponseSchema > ;
34- const apiSequenceListResponseSchema = z . array ( apiSequenceResponseSchema ) ;
40+ export type SequenceTypeApi = z . infer < typeof apiSequenceResponseSchema > ;
41+ export type AlertTypeApi = z . infer < typeof apiAlertResponseSchema > ;
42+ const apiAlertListResponseSchema = z . array ( apiAlertResponseSchema ) ;
3543
3644export type DetectionType = z . infer < typeof apiDetectionResponseSchema > ;
3745const apiDetectionListResponseSchema = z . array ( apiDetectionResponseSchema ) ;
3846
39- export const getUnlabelledLatestSequences = async ( ) : Promise <
40- SequenceType [ ]
41- > => {
47+ export const getUnlabelledLatestAlerts = async ( ) : Promise < AlertTypeApi [ ] > => {
4248 return apiInstance
43- . get ( '/api/v1/sequences /unlabeled/latest' )
49+ . get ( '/api/v1/alerts /unlabeled/latest' )
4450 . then ( ( response : AxiosResponse ) => {
4551 try {
46- const result = apiSequenceListResponseSchema . safeParse ( response . data ) ;
52+ const result = apiAlertListResponseSchema . safeParse ( response . data ) ;
4753 return result . data ?? [ ] ;
4854 } catch {
4955 throw new Error ( 'INVALID_API_RESPONSE' ) ;
@@ -55,21 +61,21 @@ export const getUnlabelledLatestSequences = async (): Promise<
5561 } ) ;
5662} ;
5763
58- export const getSequencesByFilters = async (
64+ export const getAlertsByFilters = async (
5965 fromDate : string ,
6066 limit : number ,
6167 offset : number
62- ) : Promise < SequenceType [ ] > => {
68+ ) : Promise < AlertTypeApi [ ] > => {
6369 const params = {
6470 from_date : fromDate ,
6571 limit,
6672 offset,
6773 } ;
6874 return apiInstance
69- . get ( '/api/v1/sequences /all/fromdate' , { params } )
75+ . get ( '/api/v1/alerts /all/fromdate' , { params } )
7076 . then ( ( response : AxiosResponse ) => {
7177 try {
72- const result = apiSequenceListResponseSchema . safeParse ( response . data ) ;
78+ const result = apiAlertListResponseSchema . safeParse ( response . data ) ;
7379 return result . data ?? [ ] ;
7480 } catch {
7581 throw new Error ( 'INVALID_API_RESPONSE' ) ;
@@ -89,6 +95,7 @@ export const getDetectionsBySequence = async (
8995 . then ( ( response : AxiosResponse ) => {
9096 try {
9197 const result = apiDetectionListResponseSchema . safeParse ( response . data ) ;
98+ console . log ( result ) ;
9299 if ( result . data ) {
93100 result . data . sort (
94101 ( d1 , d2 ) =>
0 commit comments