@adventurelabs/scout-core 1.0.48 → 1.0.50

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.
@@ -1,6 +1,6 @@
1
1
  import { IApiKeyScout } from "../types/db";
2
- export declare function test_api_key_loading(device_id: string): Promise<boolean>;
3
- export declare function server_list_api_keys(device_id: string): Promise<IApiKeyScout[]>;
4
- export declare function server_list_api_keys_batch(device_ids: string[]): Promise<{
2
+ export declare function test_api_key_loading(device_id: number): Promise<boolean>;
3
+ export declare function server_list_api_keys(device_id: number): Promise<IApiKeyScout[]>;
4
+ export declare function server_list_api_keys_batch(device_ids: number[]): Promise<{
5
5
  [device_id: number]: IApiKeyScout[];
6
6
  }>;
@@ -25,6 +25,7 @@ export async function server_list_api_keys(device_id) {
25
25
  return [];
26
26
  const data_to_return = [];
27
27
  for (let i = 0; i < data.length; i++) {
28
+ // Parse the JSON string from the text array
28
29
  const converted_data = JSON.parse(data[i]);
29
30
  data_to_return.push(converted_data);
30
31
  }
@@ -53,11 +54,11 @@ export async function server_list_api_keys_batch(device_ids) {
53
54
  const promises = device_ids.map(async (device_id) => {
54
55
  try {
55
56
  const api_keys = await server_list_api_keys(device_id);
56
- result[parseInt(device_id)] = api_keys;
57
+ result[device_id] = api_keys;
57
58
  }
58
59
  catch (err) {
59
60
  console.warn(`[API Keys Batch] Failed for device ${device_id}:`, err);
60
- result[parseInt(device_id)] = [];
61
+ result[device_id] = [];
61
62
  }
62
63
  });
63
64
  await Promise.all(promises);
@@ -88,11 +89,11 @@ export async function server_list_api_keys_batch(device_ids) {
88
89
  const promises = device_ids.map(async (device_id) => {
89
90
  try {
90
91
  const api_keys = await server_list_api_keys(device_id);
91
- result[parseInt(device_id)] = api_keys;
92
+ result[device_id] = api_keys;
92
93
  }
93
94
  catch (err) {
94
95
  console.warn(`[API Keys Batch] Failed for device ${device_id}:`, err);
95
- result[parseInt(device_id)] = [];
96
+ result[device_id] = [];
96
97
  }
97
98
  });
98
99
  await Promise.all(promises);
@@ -6,7 +6,7 @@ export declare function server_delete_tags_by_ids(tag_ids: number[]): Promise<IW
6
6
  export declare function server_update_tags(tags: ITag[]): Promise<IWebResponseCompatible<ITag[]>>;
7
7
  export declare function server_get_more_events_with_tags_by_herd(herd_id: number, offset: number, page_count?: number): Promise<IWebResponseCompatible<IEventWithTags[]>>;
8
8
  export declare function server_get_events_and_tags_for_device(device_id: number, limit?: number): Promise<IWebResponseCompatible<IEventWithTags[]>>;
9
- export declare function server_get_events_and_tags_for_devices_batch(device_ids: string[], limit?: number): Promise<IWebResponseCompatible<{
9
+ export declare function server_get_events_and_tags_for_devices_batch(device_ids: number[], limit?: number): Promise<IWebResponseCompatible<{
10
10
  [device_id: number]: IEventWithTags[];
11
11
  }>>;
12
12
  export declare function get_event_and_tags_by_event_id(event_id: number): Promise<IWebResponseCompatible<IEventWithTags>>;
@@ -180,18 +180,18 @@ export async function server_get_events_and_tags_for_devices_batch(device_ids, l
180
180
  const result = {};
181
181
  const promises = device_ids.map(async (device_id) => {
182
182
  try {
183
- const events_response = await server_get_events_and_tags_for_device(parseInt(device_id), limit);
183
+ const events_response = await server_get_events_and_tags_for_device(device_id, limit);
184
184
  if (events_response.status === EnumWebResponse.SUCCESS &&
185
185
  events_response.data) {
186
- result[parseInt(device_id)] = events_response.data;
186
+ result[device_id] = events_response.data;
187
187
  }
188
188
  else {
189
- result[parseInt(device_id)] = [];
189
+ result[device_id] = [];
190
190
  }
191
191
  }
192
192
  catch (err) {
193
193
  console.warn(`[Events Batch] Failed for device ${device_id}:`, err);
194
- result[parseInt(device_id)] = [];
194
+ result[device_id] = [];
195
195
  }
196
196
  });
197
197
  await Promise.all(promises);
@@ -207,9 +207,9 @@ export async function server_get_events_and_tags_for_devices_batch(device_ids, l
207
207
  if (!eventsByDevice[device_id]) {
208
208
  eventsByDevice[device_id] = [];
209
209
  }
210
- // Create event object from the database function structure
210
+ // Create event object from the event_and_tags_pretty_location structure
211
211
  const event = {
212
- id: row.event_id,
212
+ id: row.id, // Changed from row.event_id to row.id
213
213
  inserted_at: row.inserted_at,
214
214
  message: row.message,
215
215
  media_url: row.media_url,
@@ -740,13 +740,13 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
740
740
  };
741
741
  load_api_keys: {
742
742
  Args: {
743
- id_of_device: string;
743
+ id_of_device: number;
744
744
  };
745
745
  Returns: string[];
746
746
  };
747
747
  load_api_keys_batch: {
748
748
  Args: {
749
- device_ids: string[];
749
+ device_ids: number[];
750
750
  };
751
751
  Returns: {
752
752
  device_id: number;
@@ -756,27 +756,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
756
756
  };
757
757
  get_events_and_tags_for_devices_batch: {
758
758
  Args: {
759
- device_ids: string[];
759
+ device_ids: number[];
760
760
  limit_per_device: number;
761
761
  };
762
- Returns: {
763
- event_id: number;
764
- inserted_at: string;
765
- message: string | null;
766
- media_url: string | null;
767
- file_path: string | null;
768
- latitude: number | null;
769
- longitude: number | null;
770
- earthranger_url: string | null;
771
- altitude: number;
772
- heading: number;
773
- media_type: string;
774
- device_id: number;
775
- timestamp_observation: string;
776
- is_public: boolean;
777
- tags: import("../types/supabase").Json;
778
- herd_id: number | null;
779
- }[];
762
+ Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
780
763
  };
781
764
  };
782
765
  Enums: {
@@ -731,13 +731,13 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
731
731
  };
732
732
  load_api_keys: {
733
733
  Args: {
734
- id_of_device: string;
734
+ id_of_device: number;
735
735
  };
736
736
  Returns: string[];
737
737
  };
738
738
  load_api_keys_batch: {
739
739
  Args: {
740
- device_ids: string[];
740
+ device_ids: number[];
741
741
  };
742
742
  Returns: {
743
743
  device_id: number;
@@ -747,27 +747,10 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
747
747
  };
748
748
  get_events_and_tags_for_devices_batch: {
749
749
  Args: {
750
- device_ids: string[];
750
+ device_ids: number[];
751
751
  limit_per_device: number;
752
752
  };
753
- Returns: {
754
- event_id: number;
755
- inserted_at: string;
756
- message: string | null;
757
- media_url: string | null;
758
- file_path: string | null;
759
- latitude: number | null;
760
- longitude: number | null;
761
- earthranger_url: string | null;
762
- altitude: number;
763
- heading: number;
764
- media_type: string;
765
- device_id: number;
766
- timestamp_observation: string;
767
- is_public: boolean;
768
- tags: import("../types/supabase").Json;
769
- herd_id: number | null;
770
- }[];
753
+ Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
771
754
  };
772
755
  };
773
756
  Enums: {
@@ -61,7 +61,7 @@ export class HerdModule {
61
61
  if (new_devices.length > 0) {
62
62
  const batchStartTime = Date.now();
63
63
  try {
64
- const device_ids = new_devices.map((device) => (device.id ?? 0).toString());
64
+ const device_ids = new_devices.map((device) => device.id ?? 0);
65
65
  // Load API keys and events in parallel
66
66
  const [api_keys_batch, events_response] = await Promise.all([
67
67
  server_list_api_keys_batch(device_ids),
@@ -798,13 +798,13 @@ export type Database = {
798
798
  };
799
799
  load_api_keys: {
800
800
  Args: {
801
- id_of_device: string;
801
+ id_of_device: number;
802
802
  };
803
803
  Returns: string[];
804
804
  };
805
805
  load_api_keys_batch: {
806
806
  Args: {
807
- device_ids: string[];
807
+ device_ids: number[];
808
808
  };
809
809
  Returns: {
810
810
  device_id: number;
@@ -814,27 +814,10 @@ export type Database = {
814
814
  };
815
815
  get_events_and_tags_for_devices_batch: {
816
816
  Args: {
817
- device_ids: string[];
817
+ device_ids: number[];
818
818
  limit_per_device: number;
819
819
  };
820
- Returns: {
821
- event_id: number;
822
- inserted_at: string;
823
- message: string | null;
824
- media_url: string | null;
825
- file_path: string | null;
826
- latitude: number | null;
827
- longitude: number | null;
828
- earthranger_url: string | null;
829
- altitude: number;
830
- heading: number;
831
- media_type: string;
832
- device_id: number;
833
- timestamp_observation: string;
834
- is_public: boolean;
835
- tags: Json;
836
- herd_id: number | null;
837
- }[];
820
+ Returns: Database["public"]["CompositeTypes"]["event_and_tags_pretty_location"][];
838
821
  };
839
822
  };
840
823
  Enums: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
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",