@adventurelabs/scout-core 1.0.52 → 1.0.54

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.
@@ -6,8 +6,6 @@ export async function get_devices_by_herd(herd_id, client) {
6
6
  const { data, error } = await client.rpc("get_devices_for_herd", {
7
7
  herd_id_caller: herd_id,
8
8
  });
9
- console.log(`[get_devices_by_herd] Raw RPC response:`, data);
10
- console.log(`[get_devices_by_herd] First device sample:`, data?.[0]);
11
9
  if (!data) {
12
10
  return IWebResponse.error("No devices found").to_compatible();
13
11
  }
@@ -0,0 +1,3 @@
1
+ import { ILayer } from "../types/db";
2
+ import { IWebResponseCompatible } from "../types/requests";
3
+ export declare function server_get_layers_by_herd(herd_id: number): Promise<IWebResponseCompatible<ILayer[]>>;
@@ -0,0 +1,21 @@
1
+ "use server";
2
+ import { newServerClient } from "../supabase/server";
3
+ import { EnumWebResponse, IWebResponse, } from "../types/requests";
4
+ // function that fetches the layers from our db given a herd id
5
+ export async function server_get_layers_by_herd(herd_id) {
6
+ const supabase = await newServerClient();
7
+ const { data, error } = await supabase
8
+ .from("layers")
9
+ .select("*")
10
+ .eq("herd_id", herd_id);
11
+ if (error) {
12
+ return {
13
+ status: EnumWebResponse.ERROR,
14
+ msg: error.message,
15
+ data: null,
16
+ };
17
+ }
18
+ else {
19
+ return IWebResponse.success(data).to_compatible();
20
+ }
21
+ }
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export * from "./helpers/gps";
19
19
  export * from "./helpers/herds";
20
20
  export * from "./helpers/location";
21
21
  export * from "./helpers/plans";
22
+ export * from "./helpers/layers";
22
23
  export * from "./helpers/sessions";
23
24
  export * from "./helpers/tags";
24
25
  export * from "./helpers/time";
@@ -36,7 +37,6 @@ export * from "./store/hooks";
36
37
  export * from "./supabase/middleware";
37
38
  export * from "./supabase/server";
38
39
  export * from "./api_keys/actions";
39
- export type { Database } from "./types/supabase";
40
40
  export type { HerdModule, IHerdModule } from "./types/herd_module";
41
- export type { IDevice, IEvent, IUser, IHerd, IEventWithTags, IZoneWithActions, IUserAndRole, IApiKeyScout, } from "./types/db";
41
+ export type { IDevice, IEvent, IUser, IHerd, IEventWithTags, IZoneWithActions, IUserAndRole, IApiKeyScout, ILayer, } from "./types/db";
42
42
  export { EnumSessionsVisibility } from "./types/events";
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ export * from "./helpers/gps";
22
22
  export * from "./helpers/herds";
23
23
  export * from "./helpers/location";
24
24
  export * from "./helpers/plans";
25
+ export * from "./helpers/layers";
25
26
  export * from "./helpers/sessions";
26
27
  export * from "./helpers/tags";
27
28
  export * from "./helpers/time";
@@ -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
- get_device_by_id: {
639
+ get_device_by_api_key: {
628
640
  Args: {
629
- device_id_caller: number;
641
+ device_api_key: string;
630
642
  };
631
643
  Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
632
644
  };
633
- get_device_by_api_key: {
645
+ get_device_by_id: {
634
646
  Args: {
635
- device_api_key: string;
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,12 +710,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
718
710
  };
719
711
  Returns: Database["public"]["CompositeTypes"]["session_with_coordinates"][];
720
712
  };
721
- get_total_events_for_herd: {
722
- Args: {
723
- herd_id_caller: number;
724
- };
725
- Returns: number;
726
- };
727
713
  get_total_events_for_session: {
728
714
  Args: {
729
715
  session_id_caller: number;
@@ -754,18 +740,22 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
754
740
  api_key_key: string;
755
741
  }[];
756
742
  };
757
- get_events_and_tags_for_devices_batch: {
743
+ load_api_keys_old: {
758
744
  Args: {
759
- device_ids: number[];
760
- limit_per_device: number;
745
+ id_of_device: string;
761
746
  };
762
- Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
747
+ Returns: string[];
748
+ };
749
+ remove_rls_broadcast_triggers: {
750
+ Args: Record<PropertyKey, never>;
751
+ Returns: undefined;
763
752
  };
764
753
  };
765
754
  Enums: {
766
755
  app_permission: "herds.delete" | "events.delete";
767
756
  device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown";
768
757
  media_type: "image" | "video" | "audio" | "text";
758
+ plan_type: "mission" | "fence" | "rally" | "markov";
769
759
  role: "admin" | "viewer" | "editor";
770
760
  tag_observation_type: "manual" | "auto";
771
761
  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
- get_device_by_id: {
630
+ get_device_by_api_key: {
619
631
  Args: {
620
- device_id_caller: number;
632
+ device_api_key: string;
621
633
  };
622
634
  Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
623
635
  };
624
- get_device_by_api_key: {
636
+ get_device_by_id: {
625
637
  Args: {
626
- device_api_key: string;
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,12 +701,6 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
709
701
  };
710
702
  Returns: Database["public"]["CompositeTypes"]["session_with_coordinates"][];
711
703
  };
712
- get_total_events_for_herd: {
713
- Args: {
714
- herd_id_caller: number;
715
- };
716
- Returns: number;
717
- };
718
704
  get_total_events_for_session: {
719
705
  Args: {
720
706
  session_id_caller: number;
@@ -745,18 +731,22 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
745
731
  api_key_key: string;
746
732
  }[];
747
733
  };
748
- get_events_and_tags_for_devices_batch: {
734
+ load_api_keys_old: {
749
735
  Args: {
750
- device_ids: number[];
751
- limit_per_device: number;
736
+ id_of_device: string;
752
737
  };
753
- Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
738
+ Returns: string[];
739
+ };
740
+ remove_rls_broadcast_triggers: {
741
+ Args: Record<PropertyKey, never>;
742
+ Returns: undefined;
754
743
  };
755
744
  };
756
745
  Enums: {
757
746
  app_permission: "herds.delete" | "events.delete";
758
747
  device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown";
759
748
  media_type: "image" | "video" | "audio" | "text";
749
+ plan_type: "mission" | "fence" | "rally" | "markov";
760
750
  role: "admin" | "viewer" | "editor";
761
751
  tag_observation_type: "manual" | "auto";
762
752
  user_status: "ONLINE" | "OFFLINE";
@@ -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
- 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[]);
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 { server_get_events_and_tags_for_devices_batch, } from "../helpers/tags";
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
  }
@@ -3,7 +3,7 @@ export type Json = string | number | boolean | null | {
3
3
  } | Json[];
4
4
  export type Database = {
5
5
  __InternalSupabase: {
6
- PostgrestVersion: "12.2.3 (519615d)";
6
+ PostgrestVersion: "12.2.12 (cd3cf9e)";
7
7
  };
8
8
  graphql_public: {
9
9
  Tables: {
@@ -306,6 +306,35 @@ export type Database = {
306
306
  }
307
307
  ];
308
308
  };
309
+ layers: {
310
+ Row: {
311
+ created_at: string;
312
+ features: Json;
313
+ herd_id: number;
314
+ id: number;
315
+ };
316
+ Insert: {
317
+ created_at?: string;
318
+ features: Json;
319
+ herd_id: number;
320
+ id?: number;
321
+ };
322
+ Update: {
323
+ created_at?: string;
324
+ features?: Json;
325
+ herd_id?: number;
326
+ id?: number;
327
+ };
328
+ Relationships: [
329
+ {
330
+ foreignKeyName: "layers_herd_id_fkey";
331
+ columns: ["herd_id"];
332
+ isOneToOne: false;
333
+ referencedRelation: "herds";
334
+ referencedColumns: ["id"];
335
+ }
336
+ ];
337
+ };
309
338
  plans: {
310
339
  Row: {
311
340
  herd_id: number;
@@ -313,6 +342,7 @@ export type Database = {
313
342
  inserted_at: string;
314
343
  instructions: string;
315
344
  name: string;
345
+ plan_type: Database["public"]["Enums"]["plan_type"];
316
346
  };
317
347
  Insert: {
318
348
  herd_id: number;
@@ -320,6 +350,7 @@ export type Database = {
320
350
  inserted_at?: string;
321
351
  instructions: string;
322
352
  name: string;
353
+ plan_type?: Database["public"]["Enums"]["plan_type"];
323
354
  };
324
355
  Update: {
325
356
  herd_id?: number;
@@ -327,6 +358,7 @@ export type Database = {
327
358
  inserted_at?: string;
328
359
  instructions?: string;
329
360
  name?: string;
361
+ plan_type?: Database["public"]["Enums"]["plan_type"];
330
362
  };
331
363
  Relationships: [
332
364
  {
@@ -346,6 +378,8 @@ export type Database = {
346
378
  device_id: number;
347
379
  distance_max_from_start: number;
348
380
  distance_total: number;
381
+ earthranger_url: string | null;
382
+ file_paths: string[] | null;
349
383
  id: number;
350
384
  inserted_at: string;
351
385
  locations: unknown;
@@ -363,6 +397,8 @@ export type Database = {
363
397
  device_id: number;
364
398
  distance_max_from_start: number;
365
399
  distance_total: number;
400
+ earthranger_url?: string | null;
401
+ file_paths?: string[] | null;
366
402
  id?: number;
367
403
  inserted_at?: string;
368
404
  locations: unknown;
@@ -380,6 +416,8 @@ export type Database = {
380
416
  device_id?: number;
381
417
  distance_max_from_start?: number;
382
418
  distance_total?: number;
419
+ earthranger_url?: string | null;
420
+ file_paths?: string[] | null;
383
421
  id?: number;
384
422
  inserted_at?: string;
385
423
  locations?: unknown;
@@ -652,45 +690,21 @@ export type Database = {
652
690
  };
653
691
  };
654
692
  Functions: {
655
- authorize: {
656
- Args: {
657
- requested_permission: Database["public"]["Enums"]["app_permission"];
658
- };
659
- Returns: boolean;
660
- };
661
- create_api_key: {
662
- Args: {
663
- id_of_device: number;
664
- };
665
- Returns: undefined;
666
- };
667
- create_user: {
668
- Args: {
669
- email: string;
670
- };
671
- Returns: string;
672
- };
673
- custom_access_token_hook: {
674
- Args: {
675
- event: Json;
676
- };
677
- Returns: Json;
678
- };
679
693
  get_connectivity_with_coordinates: {
680
694
  Args: {
681
695
  session_id_caller: number;
682
696
  };
683
697
  Returns: Database["public"]["CompositeTypes"]["connectivity_with_coordinates"][];
684
698
  };
685
- get_device_by_id: {
699
+ get_device_by_api_key: {
686
700
  Args: {
687
- device_id_caller: number;
701
+ device_api_key: string;
688
702
  };
689
703
  Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
690
704
  };
691
- get_device_by_api_key: {
705
+ get_device_by_id: {
692
706
  Args: {
693
- device_api_key: string;
707
+ device_id_caller: number;
694
708
  };
695
709
  Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
696
710
  };
@@ -713,6 +727,13 @@ export type Database = {
713
727
  };
714
728
  Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
715
729
  };
730
+ get_events_and_tags_for_devices_batch: {
731
+ Args: {
732
+ device_ids: number[];
733
+ limit_per_device?: number;
734
+ };
735
+ Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
736
+ };
716
737
  get_events_and_tags_for_herd: {
717
738
  Args: {
718
739
  herd_id_caller: number;
@@ -729,33 +750,6 @@ export type Database = {
729
750
  };
730
751
  Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
731
752
  };
732
- get_events_for_herd: {
733
- Args: {
734
- herd_id_in: number;
735
- };
736
- Returns: {
737
- altitude: number;
738
- device_id: number;
739
- earthranger_url: string | null;
740
- file_path: string | null;
741
- heading: number;
742
- id: number;
743
- inserted_at: string;
744
- is_public: boolean;
745
- location: unknown | null;
746
- media_type: Database["public"]["Enums"]["media_type"];
747
- media_url: string | null;
748
- message: string | null;
749
- session_id: number | null;
750
- timestamp_observation: string;
751
- }[];
752
- };
753
- get_events_with_tags_by_id: {
754
- Args: {
755
- event_id_caller: number;
756
- };
757
- Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"];
758
- };
759
753
  get_events_with_tags_for_herd: {
760
754
  Args: {
761
755
  herd_id_caller: number;
@@ -776,12 +770,6 @@ export type Database = {
776
770
  };
777
771
  Returns: Database["public"]["CompositeTypes"]["session_with_coordinates"][];
778
772
  };
779
- get_total_events_for_herd: {
780
- Args: {
781
- herd_id_caller: number;
782
- };
783
- Returns: number;
784
- };
785
773
  get_total_events_for_session: {
786
774
  Args: {
787
775
  session_id_caller: number;
@@ -812,18 +800,22 @@ export type Database = {
812
800
  api_key_key: string;
813
801
  }[];
814
802
  };
815
- get_events_and_tags_for_devices_batch: {
803
+ load_api_keys_old: {
816
804
  Args: {
817
- device_ids: number[];
818
- limit_per_device: number;
805
+ id_of_device: string;
819
806
  };
820
- Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
807
+ Returns: string[];
808
+ };
809
+ remove_rls_broadcast_triggers: {
810
+ Args: Record<PropertyKey, never>;
811
+ Returns: undefined;
821
812
  };
822
813
  };
823
814
  Enums: {
824
815
  app_permission: "herds.delete" | "events.delete";
825
816
  device_type: "trail_camera" | "drone_fixed_wing" | "drone_quad" | "gps_tracker" | "sentry_tower" | "smart_buoy" | "radio_mesh_base_station" | "radio_mesh_repeater" | "unknown";
826
817
  media_type: "image" | "video" | "audio" | "text";
818
+ plan_type: "mission" | "fence" | "rally" | "markov";
827
819
  role: "admin" | "viewer" | "editor";
828
820
  tag_observation_type: "manual" | "auto";
829
821
  user_status: "ONLINE" | "OFFLINE";
@@ -1010,6 +1002,7 @@ export declare const Constants: {
1010
1002
  readonly app_permission: readonly ["herds.delete", "events.delete"];
1011
1003
  readonly device_type: readonly ["trail_camera", "drone_fixed_wing", "drone_quad", "gps_tracker", "sentry_tower", "smart_buoy", "radio_mesh_base_station", "radio_mesh_repeater", "unknown"];
1012
1004
  readonly media_type: readonly ["image", "video", "audio", "text"];
1005
+ readonly plan_type: readonly ["mission", "fence", "rally", "markov"];
1013
1006
  readonly role: readonly ["admin", "viewer", "editor"];
1014
1007
  readonly tag_observation_type: readonly ["manual", "auto"];
1015
1008
  readonly user_status: readonly ["ONLINE", "OFFLINE"];
@@ -17,6 +17,7 @@ export const Constants = {
17
17
  "unknown",
18
18
  ],
19
19
  media_type: ["image", "video", "audio", "text"],
20
+ plan_type: ["mission", "fence", "rally", "markov"],
20
21
  role: ["admin", "viewer", "editor"],
21
22
  tag_observation_type: ["manual", "auto"],
22
23
  user_status: ["ONLINE", "OFFLINE"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
4
4
  "description": "Core utilities and helpers for Adventure Labs Scout applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",