@adventurelabs/scout-core 1.0.53 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/events.d.ts +0 -4
- package/dist/helpers/events.js +7 -85
- package/dist/helpers/layers.d.ts +3 -0
- package/dist/helpers/layers.js +21 -0
- package/dist/helpers/tags.d.ts +0 -1
- package/dist/helpers/tags.js +0 -42
- package/dist/hooks/useScoutDbListener.d.ts +1 -16
- package/dist/hooks/useScoutDbListener.js +112 -155
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -0
- package/dist/providers/ScoutRefreshProvider.d.ts +60 -63
- package/dist/supabase/server.d.ts +60 -63
- package/dist/types/db.d.ts +1 -0
- package/dist/types/herd_module.d.ts +4 -2
- package/dist/types/herd_module.js +16 -5
- package/dist/types/supabase.d.ts +64 -64
- package/dist/types/supabase.js +1 -0
- package/package.json +1 -1
|
@@ -271,6 +271,33 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
271
271
|
referencedColumns: ["id"];
|
|
272
272
|
}];
|
|
273
273
|
};
|
|
274
|
+
layers: {
|
|
275
|
+
Row: {
|
|
276
|
+
created_at: string;
|
|
277
|
+
features: import("../types/supabase").Json;
|
|
278
|
+
herd_id: number;
|
|
279
|
+
id: number;
|
|
280
|
+
};
|
|
281
|
+
Insert: {
|
|
282
|
+
created_at?: string;
|
|
283
|
+
features: import("../types/supabase").Json;
|
|
284
|
+
herd_id: number;
|
|
285
|
+
id?: number;
|
|
286
|
+
};
|
|
287
|
+
Update: {
|
|
288
|
+
created_at?: string;
|
|
289
|
+
features?: import("../types/supabase").Json;
|
|
290
|
+
herd_id?: number;
|
|
291
|
+
id?: number;
|
|
292
|
+
};
|
|
293
|
+
Relationships: [{
|
|
294
|
+
foreignKeyName: "layers_herd_id_fkey";
|
|
295
|
+
columns: ["herd_id"];
|
|
296
|
+
isOneToOne: false;
|
|
297
|
+
referencedRelation: "herds";
|
|
298
|
+
referencedColumns: ["id"];
|
|
299
|
+
}];
|
|
300
|
+
};
|
|
274
301
|
plans: {
|
|
275
302
|
Row: {
|
|
276
303
|
herd_id: number;
|
|
@@ -278,6 +305,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
278
305
|
inserted_at: string;
|
|
279
306
|
instructions: string;
|
|
280
307
|
name: string;
|
|
308
|
+
plan_type: Database["public"]["Enums"]["plan_type"];
|
|
281
309
|
};
|
|
282
310
|
Insert: {
|
|
283
311
|
herd_id: number;
|
|
@@ -285,6 +313,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
285
313
|
inserted_at?: string;
|
|
286
314
|
instructions: string;
|
|
287
315
|
name: string;
|
|
316
|
+
plan_type?: Database["public"]["Enums"]["plan_type"];
|
|
288
317
|
};
|
|
289
318
|
Update: {
|
|
290
319
|
herd_id?: number;
|
|
@@ -292,6 +321,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
292
321
|
inserted_at?: string;
|
|
293
322
|
instructions?: string;
|
|
294
323
|
name?: string;
|
|
324
|
+
plan_type?: Database["public"]["Enums"]["plan_type"];
|
|
295
325
|
};
|
|
296
326
|
Relationships: [{
|
|
297
327
|
foreignKeyName: "plans_herd_id_fkey";
|
|
@@ -309,6 +339,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
309
339
|
device_id: number;
|
|
310
340
|
distance_max_from_start: number;
|
|
311
341
|
distance_total: number;
|
|
342
|
+
earthranger_url: string | null;
|
|
343
|
+
file_paths: string[] | null;
|
|
312
344
|
id: number;
|
|
313
345
|
inserted_at: string;
|
|
314
346
|
locations: unknown;
|
|
@@ -326,6 +358,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
326
358
|
device_id: number;
|
|
327
359
|
distance_max_from_start: number;
|
|
328
360
|
distance_total: number;
|
|
361
|
+
earthranger_url?: string | null;
|
|
362
|
+
file_paths?: string[] | null;
|
|
329
363
|
id?: number;
|
|
330
364
|
inserted_at?: string;
|
|
331
365
|
locations: unknown;
|
|
@@ -343,6 +377,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
343
377
|
device_id?: number;
|
|
344
378
|
distance_max_from_start?: number;
|
|
345
379
|
distance_total?: number;
|
|
380
|
+
earthranger_url?: string | null;
|
|
381
|
+
file_paths?: string[] | null;
|
|
346
382
|
id?: number;
|
|
347
383
|
inserted_at?: string;
|
|
348
384
|
locations?: unknown;
|
|
@@ -594,45 +630,21 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
594
630
|
};
|
|
595
631
|
};
|
|
596
632
|
Functions: {
|
|
597
|
-
authorize: {
|
|
598
|
-
Args: {
|
|
599
|
-
requested_permission: Database["public"]["Enums"]["app_permission"];
|
|
600
|
-
};
|
|
601
|
-
Returns: boolean;
|
|
602
|
-
};
|
|
603
|
-
create_api_key: {
|
|
604
|
-
Args: {
|
|
605
|
-
id_of_device: number;
|
|
606
|
-
};
|
|
607
|
-
Returns: undefined;
|
|
608
|
-
};
|
|
609
|
-
create_user: {
|
|
610
|
-
Args: {
|
|
611
|
-
email: string;
|
|
612
|
-
};
|
|
613
|
-
Returns: string;
|
|
614
|
-
};
|
|
615
|
-
custom_access_token_hook: {
|
|
616
|
-
Args: {
|
|
617
|
-
event: import("../types/supabase").Json;
|
|
618
|
-
};
|
|
619
|
-
Returns: import("../types/supabase").Json;
|
|
620
|
-
};
|
|
621
633
|
get_connectivity_with_coordinates: {
|
|
622
634
|
Args: {
|
|
623
635
|
session_id_caller: number;
|
|
624
636
|
};
|
|
625
637
|
Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
|
|
626
638
|
};
|
|
627
|
-
|
|
639
|
+
get_device_by_api_key: {
|
|
628
640
|
Args: {
|
|
629
|
-
|
|
641
|
+
device_api_key: string;
|
|
630
642
|
};
|
|
631
643
|
Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
|
|
632
644
|
};
|
|
633
|
-
|
|
645
|
+
get_device_by_id: {
|
|
634
646
|
Args: {
|
|
635
|
-
|
|
647
|
+
device_id_caller: number;
|
|
636
648
|
};
|
|
637
649
|
Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
|
|
638
650
|
};
|
|
@@ -655,6 +667,13 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
655
667
|
};
|
|
656
668
|
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
|
|
657
669
|
};
|
|
670
|
+
get_events_and_tags_for_devices_batch: {
|
|
671
|
+
Args: {
|
|
672
|
+
device_ids: number[];
|
|
673
|
+
limit_per_device?: number;
|
|
674
|
+
};
|
|
675
|
+
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
|
|
676
|
+
};
|
|
658
677
|
get_events_and_tags_for_herd: {
|
|
659
678
|
Args: {
|
|
660
679
|
herd_id_caller: number;
|
|
@@ -671,33 +690,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
671
690
|
};
|
|
672
691
|
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
|
|
673
692
|
};
|
|
674
|
-
get_events_for_herd: {
|
|
675
|
-
Args: {
|
|
676
|
-
herd_id_in: number;
|
|
677
|
-
};
|
|
678
|
-
Returns: {
|
|
679
|
-
altitude: number;
|
|
680
|
-
device_id: number;
|
|
681
|
-
earthranger_url: string | null;
|
|
682
|
-
file_path: string | null;
|
|
683
|
-
heading: number;
|
|
684
|
-
id: number;
|
|
685
|
-
inserted_at: string;
|
|
686
|
-
is_public: boolean;
|
|
687
|
-
location: unknown | null;
|
|
688
|
-
media_type: Database["public"]["Enums"]["media_type"];
|
|
689
|
-
media_url: string | null;
|
|
690
|
-
message: string | null;
|
|
691
|
-
session_id: number | null;
|
|
692
|
-
timestamp_observation: string;
|
|
693
|
-
}[];
|
|
694
|
-
};
|
|
695
|
-
get_events_with_tags_by_id: {
|
|
696
|
-
Args: {
|
|
697
|
-
event_id_caller: number;
|
|
698
|
-
};
|
|
699
|
-
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"];
|
|
700
|
-
};
|
|
701
693
|
get_events_with_tags_for_herd: {
|
|
702
694
|
Args: {
|
|
703
695
|
herd_id_caller: number;
|
|
@@ -718,15 +710,16 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
718
710
|
};
|
|
719
711
|
Returns: Database["public"]["CompositeTypes"]["session_with_coordinates"][];
|
|
720
712
|
};
|
|
721
|
-
|
|
713
|
+
get_total_events_for_session: {
|
|
722
714
|
Args: {
|
|
723
|
-
|
|
715
|
+
session_id_caller: number;
|
|
724
716
|
};
|
|
725
717
|
Returns: number;
|
|
726
718
|
};
|
|
727
|
-
|
|
719
|
+
get_total_events_for_herd_with_session_filter: {
|
|
728
720
|
Args: {
|
|
729
|
-
|
|
721
|
+
herd_id_caller: number;
|
|
722
|
+
exclude_session_events: boolean;
|
|
730
723
|
};
|
|
731
724
|
Returns: number;
|
|
732
725
|
};
|
|
@@ -754,18 +747,22 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
754
747
|
api_key_key: string;
|
|
755
748
|
}[];
|
|
756
749
|
};
|
|
757
|
-
|
|
750
|
+
load_api_keys_old: {
|
|
758
751
|
Args: {
|
|
759
|
-
|
|
760
|
-
limit_per_device: number;
|
|
752
|
+
id_of_device: string;
|
|
761
753
|
};
|
|
762
|
-
Returns:
|
|
754
|
+
Returns: string[];
|
|
755
|
+
};
|
|
756
|
+
remove_rls_broadcast_triggers: {
|
|
757
|
+
Args: Record<PropertyKey, never>;
|
|
758
|
+
Returns: undefined;
|
|
763
759
|
};
|
|
764
760
|
};
|
|
765
761
|
Enums: {
|
|
766
762
|
app_permission: "herds.delete" | "events.delete";
|
|
767
763
|
device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown";
|
|
768
764
|
media_type: "image" | "video" | "audio" | "text";
|
|
765
|
+
plan_type: "mission" | "fence" | "rally" | "markov";
|
|
769
766
|
role: "admin" | "viewer" | "editor";
|
|
770
767
|
tag_observation_type: "manual" | "auto";
|
|
771
768
|
user_status: "ONLINE" | "OFFLINE";
|
|
@@ -262,6 +262,33 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
262
262
|
referencedColumns: ["id"];
|
|
263
263
|
}];
|
|
264
264
|
};
|
|
265
|
+
layers: {
|
|
266
|
+
Row: {
|
|
267
|
+
created_at: string;
|
|
268
|
+
features: import("../types/supabase").Json;
|
|
269
|
+
herd_id: number;
|
|
270
|
+
id: number;
|
|
271
|
+
};
|
|
272
|
+
Insert: {
|
|
273
|
+
created_at?: string;
|
|
274
|
+
features: import("../types/supabase").Json;
|
|
275
|
+
herd_id: number;
|
|
276
|
+
id?: number;
|
|
277
|
+
};
|
|
278
|
+
Update: {
|
|
279
|
+
created_at?: string;
|
|
280
|
+
features?: import("../types/supabase").Json;
|
|
281
|
+
herd_id?: number;
|
|
282
|
+
id?: number;
|
|
283
|
+
};
|
|
284
|
+
Relationships: [{
|
|
285
|
+
foreignKeyName: "layers_herd_id_fkey";
|
|
286
|
+
columns: ["herd_id"];
|
|
287
|
+
isOneToOne: false;
|
|
288
|
+
referencedRelation: "herds";
|
|
289
|
+
referencedColumns: ["id"];
|
|
290
|
+
}];
|
|
291
|
+
};
|
|
265
292
|
plans: {
|
|
266
293
|
Row: {
|
|
267
294
|
herd_id: number;
|
|
@@ -269,6 +296,7 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
269
296
|
inserted_at: string;
|
|
270
297
|
instructions: string;
|
|
271
298
|
name: string;
|
|
299
|
+
plan_type: Database["public"]["Enums"]["plan_type"];
|
|
272
300
|
};
|
|
273
301
|
Insert: {
|
|
274
302
|
herd_id: number;
|
|
@@ -276,6 +304,7 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
276
304
|
inserted_at?: string;
|
|
277
305
|
instructions: string;
|
|
278
306
|
name: string;
|
|
307
|
+
plan_type?: Database["public"]["Enums"]["plan_type"];
|
|
279
308
|
};
|
|
280
309
|
Update: {
|
|
281
310
|
herd_id?: number;
|
|
@@ -283,6 +312,7 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
283
312
|
inserted_at?: string;
|
|
284
313
|
instructions?: string;
|
|
285
314
|
name?: string;
|
|
315
|
+
plan_type?: Database["public"]["Enums"]["plan_type"];
|
|
286
316
|
};
|
|
287
317
|
Relationships: [{
|
|
288
318
|
foreignKeyName: "plans_herd_id_fkey";
|
|
@@ -300,6 +330,8 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
300
330
|
device_id: number;
|
|
301
331
|
distance_max_from_start: number;
|
|
302
332
|
distance_total: number;
|
|
333
|
+
earthranger_url: string | null;
|
|
334
|
+
file_paths: string[] | null;
|
|
303
335
|
id: number;
|
|
304
336
|
inserted_at: string;
|
|
305
337
|
locations: unknown;
|
|
@@ -317,6 +349,8 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
317
349
|
device_id: number;
|
|
318
350
|
distance_max_from_start: number;
|
|
319
351
|
distance_total: number;
|
|
352
|
+
earthranger_url?: string | null;
|
|
353
|
+
file_paths?: string[] | null;
|
|
320
354
|
id?: number;
|
|
321
355
|
inserted_at?: string;
|
|
322
356
|
locations: unknown;
|
|
@@ -334,6 +368,8 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
334
368
|
device_id?: number;
|
|
335
369
|
distance_max_from_start?: number;
|
|
336
370
|
distance_total?: number;
|
|
371
|
+
earthranger_url?: string | null;
|
|
372
|
+
file_paths?: string[] | null;
|
|
337
373
|
id?: number;
|
|
338
374
|
inserted_at?: string;
|
|
339
375
|
locations?: unknown;
|
|
@@ -585,45 +621,21 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
585
621
|
};
|
|
586
622
|
};
|
|
587
623
|
Functions: {
|
|
588
|
-
authorize: {
|
|
589
|
-
Args: {
|
|
590
|
-
requested_permission: Database["public"]["Enums"]["app_permission"];
|
|
591
|
-
};
|
|
592
|
-
Returns: boolean;
|
|
593
|
-
};
|
|
594
|
-
create_api_key: {
|
|
595
|
-
Args: {
|
|
596
|
-
id_of_device: number;
|
|
597
|
-
};
|
|
598
|
-
Returns: undefined;
|
|
599
|
-
};
|
|
600
|
-
create_user: {
|
|
601
|
-
Args: {
|
|
602
|
-
email: string;
|
|
603
|
-
};
|
|
604
|
-
Returns: string;
|
|
605
|
-
};
|
|
606
|
-
custom_access_token_hook: {
|
|
607
|
-
Args: {
|
|
608
|
-
event: import("../types/supabase").Json;
|
|
609
|
-
};
|
|
610
|
-
Returns: import("../types/supabase").Json;
|
|
611
|
-
};
|
|
612
624
|
get_connectivity_with_coordinates: {
|
|
613
625
|
Args: {
|
|
614
626
|
session_id_caller: number;
|
|
615
627
|
};
|
|
616
628
|
Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
|
|
617
629
|
};
|
|
618
|
-
|
|
630
|
+
get_device_by_api_key: {
|
|
619
631
|
Args: {
|
|
620
|
-
|
|
632
|
+
device_api_key: string;
|
|
621
633
|
};
|
|
622
634
|
Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
|
|
623
635
|
};
|
|
624
|
-
|
|
636
|
+
get_device_by_id: {
|
|
625
637
|
Args: {
|
|
626
|
-
|
|
638
|
+
device_id_caller: number;
|
|
627
639
|
};
|
|
628
640
|
Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
|
|
629
641
|
};
|
|
@@ -646,6 +658,13 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
646
658
|
};
|
|
647
659
|
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
|
|
648
660
|
};
|
|
661
|
+
get_events_and_tags_for_devices_batch: {
|
|
662
|
+
Args: {
|
|
663
|
+
device_ids: number[];
|
|
664
|
+
limit_per_device?: number;
|
|
665
|
+
};
|
|
666
|
+
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
|
|
667
|
+
};
|
|
649
668
|
get_events_and_tags_for_herd: {
|
|
650
669
|
Args: {
|
|
651
670
|
herd_id_caller: number;
|
|
@@ -662,33 +681,6 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
662
681
|
};
|
|
663
682
|
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
|
|
664
683
|
};
|
|
665
|
-
get_events_for_herd: {
|
|
666
|
-
Args: {
|
|
667
|
-
herd_id_in: number;
|
|
668
|
-
};
|
|
669
|
-
Returns: {
|
|
670
|
-
altitude: number;
|
|
671
|
-
device_id: number;
|
|
672
|
-
earthranger_url: string | null;
|
|
673
|
-
file_path: string | null;
|
|
674
|
-
heading: number;
|
|
675
|
-
id: number;
|
|
676
|
-
inserted_at: string;
|
|
677
|
-
is_public: boolean;
|
|
678
|
-
location: unknown | null;
|
|
679
|
-
media_type: Database["public"]["Enums"]["media_type"];
|
|
680
|
-
media_url: string | null;
|
|
681
|
-
message: string | null;
|
|
682
|
-
session_id: number | null;
|
|
683
|
-
timestamp_observation: string;
|
|
684
|
-
}[];
|
|
685
|
-
};
|
|
686
|
-
get_events_with_tags_by_id: {
|
|
687
|
-
Args: {
|
|
688
|
-
event_id_caller: number;
|
|
689
|
-
};
|
|
690
|
-
Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"];
|
|
691
|
-
};
|
|
692
684
|
get_events_with_tags_for_herd: {
|
|
693
685
|
Args: {
|
|
694
686
|
herd_id_caller: number;
|
|
@@ -709,15 +701,16 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
709
701
|
};
|
|
710
702
|
Returns: Database["public"]["CompositeTypes"]["session_with_coordinates"][];
|
|
711
703
|
};
|
|
712
|
-
|
|
704
|
+
get_total_events_for_session: {
|
|
713
705
|
Args: {
|
|
714
|
-
|
|
706
|
+
session_id_caller: number;
|
|
715
707
|
};
|
|
716
708
|
Returns: number;
|
|
717
709
|
};
|
|
718
|
-
|
|
710
|
+
get_total_events_for_herd_with_session_filter: {
|
|
719
711
|
Args: {
|
|
720
|
-
|
|
712
|
+
herd_id_caller: number;
|
|
713
|
+
exclude_session_events: boolean;
|
|
721
714
|
};
|
|
722
715
|
Returns: number;
|
|
723
716
|
};
|
|
@@ -745,18 +738,22 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
745
738
|
api_key_key: string;
|
|
746
739
|
}[];
|
|
747
740
|
};
|
|
748
|
-
|
|
741
|
+
load_api_keys_old: {
|
|
749
742
|
Args: {
|
|
750
|
-
|
|
751
|
-
limit_per_device: number;
|
|
743
|
+
id_of_device: string;
|
|
752
744
|
};
|
|
753
|
-
Returns:
|
|
745
|
+
Returns: string[];
|
|
746
|
+
};
|
|
747
|
+
remove_rls_broadcast_triggers: {
|
|
748
|
+
Args: Record<PropertyKey, never>;
|
|
749
|
+
Returns: undefined;
|
|
754
750
|
};
|
|
755
751
|
};
|
|
756
752
|
Enums: {
|
|
757
753
|
app_permission: "herds.delete" | "events.delete";
|
|
758
754
|
device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown";
|
|
759
755
|
media_type: "image" | "video" | "audio" | "text";
|
|
756
|
+
plan_type: "mission" | "fence" | "rally" | "markov";
|
|
760
757
|
role: "admin" | "viewer" | "editor";
|
|
761
758
|
tag_observation_type: "manual" | "auto";
|
|
762
759
|
user_status: "ONLINE" | "OFFLINE";
|
package/dist/types/db.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type IDevice = Database["public"]["CompositeTypes"]["device_pretty_locati
|
|
|
12
12
|
export type IEvent = Database["public"]["Tables"]["events"]["Row"];
|
|
13
13
|
export type ITag = Database["public"]["Tables"]["tags"]["Row"];
|
|
14
14
|
export type IPlan = Database["public"]["Tables"]["plans"]["Row"];
|
|
15
|
+
export type ILayer = Database["public"]["Tables"]["layers"]["Row"];
|
|
15
16
|
export type IAction = Database["public"]["Tables"]["actions"]["Row"];
|
|
16
17
|
export type IZone = Database["public"]["Tables"]["zones"]["Row"];
|
|
17
18
|
export type IUserRolePerHerd = Database["public"]["Tables"]["users_roles_per_herd"]["Row"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { IDevice, IEventWithTags, IHerd, IPlan, IUserAndRole, IZoneWithActions, ISessionWithCoordinates } from "../types/db";
|
|
2
|
+
import { IDevice, IEventWithTags, IHerd, IPlan, ILayer, IUserAndRole, IZoneWithActions, ISessionWithCoordinates } from "../types/db";
|
|
3
3
|
export declare class HerdModule {
|
|
4
4
|
herd: IHerd;
|
|
5
5
|
devices: IDevice[];
|
|
@@ -13,7 +13,8 @@ export declare class HerdModule {
|
|
|
13
13
|
total_events_with_filters: number;
|
|
14
14
|
labels: string[];
|
|
15
15
|
plans: IPlan[];
|
|
16
|
-
|
|
16
|
+
layers: ILayer[];
|
|
17
|
+
constructor(herd: IHerd, devices: IDevice[], events: IEventWithTags[], timestamp_last_refreshed: number, user_roles?: IUserAndRole[] | null, events_page_index?: number, total_events?: number, total_events_with_filters?: number, labels?: string[], plans?: IPlan[], zones?: IZoneWithActions[], sessions?: ISessionWithCoordinates[], layers?: ILayer[]);
|
|
17
18
|
to_serializable(): IHerdModule;
|
|
18
19
|
static from_herd(herd: IHerd, client: SupabaseClient): Promise<HerdModule>;
|
|
19
20
|
}
|
|
@@ -30,4 +31,5 @@ export interface IHerdModule {
|
|
|
30
31
|
plans: IPlan[];
|
|
31
32
|
zones: IZoneWithActions[];
|
|
32
33
|
sessions: ISessionWithCoordinates[];
|
|
34
|
+
layers: ILayer[];
|
|
33
35
|
}
|
|
@@ -3,20 +3,22 @@ import { get_devices_by_herd } from "../helpers/devices";
|
|
|
3
3
|
import { server_get_total_events_by_herd } from "../helpers/events";
|
|
4
4
|
import { EnumSessionsVisibility } from "./events";
|
|
5
5
|
import { server_get_plans_by_herd } from "../helpers/plans";
|
|
6
|
-
import {
|
|
6
|
+
import { server_get_layers_by_herd } from "../helpers/layers";
|
|
7
|
+
import { server_get_events_and_tags_for_devices_batch } from "../helpers/tags";
|
|
7
8
|
import { server_get_users_with_herd_access } from "../helpers/users";
|
|
8
9
|
import { EnumWebResponse } from "./requests";
|
|
9
10
|
import { server_get_more_zones_and_actions_for_herd } from "../helpers/zones";
|
|
10
11
|
import { server_list_api_keys_batch } from "../api_keys/actions";
|
|
11
12
|
import { getSessionsByHerdId } from "../helpers/sessions";
|
|
12
13
|
export class HerdModule {
|
|
13
|
-
constructor(herd, devices, events, timestamp_last_refreshed, user_roles = null, events_page_index = 0, total_events = 0, total_events_with_filters = 0, labels = [], plans = [], zones = [], sessions = []) {
|
|
14
|
+
constructor(herd, devices, events, timestamp_last_refreshed, user_roles = null, events_page_index = 0, total_events = 0, total_events_with_filters = 0, labels = [], plans = [], zones = [], sessions = [], layers = []) {
|
|
14
15
|
this.user_roles = null;
|
|
15
16
|
this.events_page_index = 0;
|
|
16
17
|
this.total_events = 0;
|
|
17
18
|
this.total_events_with_filters = 0;
|
|
18
19
|
this.labels = [];
|
|
19
20
|
this.plans = [];
|
|
21
|
+
this.layers = [];
|
|
20
22
|
this.herd = herd;
|
|
21
23
|
this.devices = devices;
|
|
22
24
|
this.events = events;
|
|
@@ -29,6 +31,7 @@ export class HerdModule {
|
|
|
29
31
|
this.plans = plans;
|
|
30
32
|
this.zones = zones;
|
|
31
33
|
this.sessions = sessions;
|
|
34
|
+
this.layers = layers;
|
|
32
35
|
}
|
|
33
36
|
to_serializable() {
|
|
34
37
|
return {
|
|
@@ -44,6 +47,7 @@ export class HerdModule {
|
|
|
44
47
|
plans: this.plans,
|
|
45
48
|
zones: this.zones,
|
|
46
49
|
sessions: this.sessions,
|
|
50
|
+
layers: this.layers,
|
|
47
51
|
};
|
|
48
52
|
}
|
|
49
53
|
static async from_herd(herd, client) {
|
|
@@ -84,7 +88,7 @@ export class HerdModule {
|
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
// Run all remaining requests in parallel with individual error handling
|
|
87
|
-
const [res_zones, res_user_roles, total_event_count, res_plans, res_sessions,] = await Promise.allSettled([
|
|
91
|
+
const [res_zones, res_user_roles, total_event_count, res_plans, res_sessions, res_layers,] = await Promise.allSettled([
|
|
88
92
|
server_get_more_zones_and_actions_for_herd(herd.id, 0, 10).catch((error) => {
|
|
89
93
|
console.warn(`[HerdModule] Failed to get zones and actions:`, error);
|
|
90
94
|
return { status: EnumWebResponse.ERROR, data: null };
|
|
@@ -105,6 +109,10 @@ export class HerdModule {
|
|
|
105
109
|
console.warn(`[HerdModule] Failed to get sessions:`, error);
|
|
106
110
|
return [];
|
|
107
111
|
}),
|
|
112
|
+
server_get_layers_by_herd(herd.id).catch((error) => {
|
|
113
|
+
console.warn(`[HerdModule] Failed to get layers:`, error);
|
|
114
|
+
return { status: EnumWebResponse.ERROR, data: null };
|
|
115
|
+
}),
|
|
108
116
|
]);
|
|
109
117
|
// Assign recent events to devices from batch results
|
|
110
118
|
for (let i = 0; i < new_devices.length; i++) {
|
|
@@ -134,19 +142,22 @@ export class HerdModule {
|
|
|
134
142
|
? res_plans.value.data
|
|
135
143
|
: [];
|
|
136
144
|
const sessions = res_sessions.status === "fulfilled" ? res_sessions.value : [];
|
|
145
|
+
const layers = res_layers.status === "fulfilled" && res_layers.value?.data
|
|
146
|
+
? res_layers.value.data
|
|
147
|
+
: [];
|
|
137
148
|
// TODO: store in DB and retrieve on load?
|
|
138
149
|
const newLabels = LABELS;
|
|
139
150
|
const endTime = Date.now();
|
|
140
151
|
const loadTime = endTime - startTime;
|
|
141
152
|
console.log(`[HerdModule] Loaded herd ${herd.slug} in ${loadTime}ms (${new_devices.length} devices)`);
|
|
142
|
-
return new HerdModule(herd, new_devices, [], Date.now(), user_roles, 0, total_events, total_events, newLabels, plans, zones, sessions);
|
|
153
|
+
return new HerdModule(herd, new_devices, [], Date.now(), user_roles, 0, total_events, total_events, newLabels, plans, zones, sessions, layers);
|
|
143
154
|
}
|
|
144
155
|
catch (error) {
|
|
145
156
|
const endTime = Date.now();
|
|
146
157
|
const loadTime = endTime - startTime;
|
|
147
158
|
console.error(`[HerdModule] Critical error in HerdModule.from_herd (${loadTime}ms):`, error);
|
|
148
159
|
// Return a minimal but valid HerdModule instance to prevent complete failure
|
|
149
|
-
return new HerdModule(herd, [], [], Date.now());
|
|
160
|
+
return new HerdModule(herd, [], [], Date.now(), null, 0, 0, 0, [], [], [], [], []);
|
|
150
161
|
}
|
|
151
162
|
}
|
|
152
163
|
}
|