@adventurelabs/scout-core 1.0.41 → 1.0.43
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/api_keys/actions.d.ts +1 -1
- package/dist/api_keys/actions.js +11 -5
- package/dist/helpers/tags.d.ts +1 -1
- package/dist/helpers/tags.js +11 -5
- package/dist/providers/ScoutRefreshProvider.d.ts +2 -2
- package/dist/supabase/server.d.ts +2 -2
- package/dist/types/herd_module.js +7 -3
- package/dist/types/supabase.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IApiKeyScout } from "../types/db";
|
|
2
2
|
export declare function server_list_api_keys(device_id: string): Promise<IApiKeyScout[]>;
|
|
3
|
-
export declare function server_list_api_keys_batch(device_ids:
|
|
3
|
+
export declare function server_list_api_keys_batch(device_ids: string[]): Promise<{
|
|
4
4
|
[device_id: number]: IApiKeyScout[];
|
|
5
5
|
}>;
|
package/dist/api_keys/actions.js
CHANGED
|
@@ -18,18 +18,23 @@ export async function server_list_api_keys(device_id) {
|
|
|
18
18
|
return data_to_return;
|
|
19
19
|
}
|
|
20
20
|
export async function server_list_api_keys_batch(device_ids) {
|
|
21
|
-
|
|
21
|
+
const startTime = Date.now();
|
|
22
|
+
console.log(`[API Keys Batch] Starting batch load for ${device_ids.length} devices at ${new Date().toISOString()}`);
|
|
22
23
|
const supabase = await newServerClient();
|
|
24
|
+
console.log(`[API Keys Batch] Making RPC call to load_api_keys_batch...`);
|
|
23
25
|
const { data, error } = await supabase.rpc("load_api_keys_batch", {
|
|
24
26
|
device_ids: device_ids,
|
|
25
27
|
});
|
|
28
|
+
const duration = Date.now() - startTime;
|
|
26
29
|
if (error) {
|
|
27
|
-
console.error(
|
|
30
|
+
console.error(`[API Keys Batch] ERROR after ${duration}ms:`, error.message);
|
|
28
31
|
return {};
|
|
29
32
|
}
|
|
30
|
-
if (!data)
|
|
33
|
+
if (!data) {
|
|
34
|
+
console.log(`[API Keys Batch] No data returned after ${duration}ms`);
|
|
31
35
|
return {};
|
|
32
|
-
|
|
36
|
+
}
|
|
37
|
+
console.log(`[API Keys Batch] RPC completed in ${duration}ms, received ${data.length} API key records`);
|
|
33
38
|
const result = {};
|
|
34
39
|
// Group API keys by device_id
|
|
35
40
|
data.forEach((item) => {
|
|
@@ -42,6 +47,7 @@ export async function server_list_api_keys_batch(device_ids) {
|
|
|
42
47
|
key: item.api_key_key,
|
|
43
48
|
});
|
|
44
49
|
});
|
|
45
|
-
|
|
50
|
+
const totalDuration = Date.now() - startTime;
|
|
51
|
+
console.log(`[API Keys Batch] COMPLETED in ${totalDuration}ms - returning API keys for ${Object.keys(result).length} devices`);
|
|
46
52
|
return result;
|
|
47
53
|
}
|
package/dist/helpers/tags.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function server_delete_tags_by_ids(tag_ids: number[]): Promise<IW
|
|
|
5
5
|
export declare function server_update_tags(tags: ITag[]): Promise<IWebResponseCompatible<ITag[]>>;
|
|
6
6
|
export declare function server_get_more_events_with_tags_by_herd(herd_id: number, offset: number, page_count?: number): Promise<IWebResponseCompatible<IEventWithTags[]>>;
|
|
7
7
|
export declare function server_get_events_and_tags_for_device(device_id: number, limit?: number): Promise<IWebResponseCompatible<IEventWithTags[]>>;
|
|
8
|
-
export declare function server_get_events_and_tags_for_devices_batch(device_ids:
|
|
8
|
+
export declare function server_get_events_and_tags_for_devices_batch(device_ids: string[], limit?: number): Promise<IWebResponseCompatible<{
|
|
9
9
|
[device_id: number]: IEventWithTags[];
|
|
10
10
|
}>>;
|
|
11
11
|
export declare function get_event_and_tags_by_event_id(event_id: number): Promise<IWebResponseCompatible<IEventWithTags>>;
|
package/dist/helpers/tags.js
CHANGED
|
@@ -147,24 +147,29 @@ export async function server_get_events_and_tags_for_device(device_id, limit = 3
|
|
|
147
147
|
return IWebResponse.success(eventsWithSignedUrls).to_compatible();
|
|
148
148
|
}
|
|
149
149
|
export async function server_get_events_and_tags_for_devices_batch(device_ids, limit = 1) {
|
|
150
|
-
|
|
150
|
+
const startTime = Date.now();
|
|
151
|
+
console.log(`[Events Batch] Starting batch load for ${device_ids.length} devices (limit: ${limit}) at ${new Date().toISOString()}`);
|
|
151
152
|
const supabase = await newServerClient();
|
|
153
|
+
console.log(`[Events Batch] Making RPC call to get_events_and_tags_for_devices_batch...`);
|
|
152
154
|
// Use single RPC call for all devices
|
|
153
155
|
const { data, error } = await supabase.rpc("get_events_and_tags_for_devices_batch", {
|
|
154
156
|
device_ids: device_ids,
|
|
155
157
|
limit_per_device: limit,
|
|
156
158
|
});
|
|
159
|
+
const duration = Date.now() - startTime;
|
|
157
160
|
if (error) {
|
|
158
|
-
console.error(
|
|
161
|
+
console.error(`[Events Batch] ERROR after ${duration}ms:`, error.message);
|
|
159
162
|
return {
|
|
160
163
|
status: EnumWebResponse.ERROR,
|
|
161
164
|
msg: error.message,
|
|
162
165
|
data: {},
|
|
163
166
|
};
|
|
164
167
|
}
|
|
165
|
-
if (!data)
|
|
168
|
+
if (!data) {
|
|
169
|
+
console.log(`[Events Batch] No data returned after ${duration}ms`);
|
|
166
170
|
return IWebResponse.success({}).to_compatible();
|
|
167
|
-
|
|
171
|
+
}
|
|
172
|
+
console.log(`[Events Batch] RPC completed in ${duration}ms, received ${data.length} event records`);
|
|
168
173
|
// Group events by device_id
|
|
169
174
|
const eventsByDevice = {};
|
|
170
175
|
data.forEach((row) => {
|
|
@@ -199,7 +204,8 @@ export async function server_get_events_and_tags_for_devices_batch(device_ids, l
|
|
|
199
204
|
const eventsWithSignedUrls = await addSignedUrlsToEvents(events, supabase);
|
|
200
205
|
result[parseInt(device_id)] = eventsWithSignedUrls;
|
|
201
206
|
}
|
|
202
|
-
|
|
207
|
+
const totalDuration = Date.now() - startTime;
|
|
208
|
+
console.log(`[Events Batch] COMPLETED in ${totalDuration}ms - returning events for ${Object.keys(result).length} devices`);
|
|
203
209
|
return IWebResponse.success(result).to_compatible();
|
|
204
210
|
}
|
|
205
211
|
export async function get_event_and_tags_by_event_id(event_id) {
|
|
@@ -746,7 +746,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
746
746
|
};
|
|
747
747
|
load_api_keys_batch: {
|
|
748
748
|
Args: {
|
|
749
|
-
device_ids:
|
|
749
|
+
device_ids: string[];
|
|
750
750
|
};
|
|
751
751
|
Returns: {
|
|
752
752
|
device_id: number;
|
|
@@ -756,7 +756,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", {
|
|
|
756
756
|
};
|
|
757
757
|
get_events_and_tags_for_devices_batch: {
|
|
758
758
|
Args: {
|
|
759
|
-
device_ids:
|
|
759
|
+
device_ids: string[];
|
|
760
760
|
limit_per_device: number;
|
|
761
761
|
};
|
|
762
762
|
Returns: {
|
|
@@ -737,7 +737,7 @@ export declare function newServerClient(): Promise<import("@supabase/supabase-js
|
|
|
737
737
|
};
|
|
738
738
|
load_api_keys_batch: {
|
|
739
739
|
Args: {
|
|
740
|
-
device_ids:
|
|
740
|
+
device_ids: string[];
|
|
741
741
|
};
|
|
742
742
|
Returns: {
|
|
743
743
|
device_id: number;
|
|
@@ -747,7 +747,7 @@ 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:
|
|
750
|
+
device_ids: string[];
|
|
751
751
|
limit_per_device: number;
|
|
752
752
|
};
|
|
753
753
|
Returns: {
|
|
@@ -59,14 +59,18 @@ export class HerdModule {
|
|
|
59
59
|
// get api keys and events for all devices in batch
|
|
60
60
|
let recent_events_batch = {};
|
|
61
61
|
if (new_devices.length > 0) {
|
|
62
|
+
const batchStartTime = Date.now();
|
|
62
63
|
try {
|
|
63
|
-
const device_ids = new_devices.map((device) => device.id ?? 0);
|
|
64
|
-
console.log(`[HerdModule]
|
|
64
|
+
const device_ids = new_devices.map((device) => (device.id ?? 0).toString());
|
|
65
|
+
console.log(`[HerdModule] Starting parallel batch load for ${device_ids.length} devices at ${new Date().toISOString()}:`, device_ids);
|
|
65
66
|
// Load API keys and events in parallel
|
|
67
|
+
console.log(`[HerdModule] Initiating Promise.all for API keys and events...`);
|
|
66
68
|
const [api_keys_batch, events_response] = await Promise.all([
|
|
67
69
|
server_list_api_keys_batch(device_ids),
|
|
68
70
|
server_get_events_and_tags_for_devices_batch(device_ids, 1),
|
|
69
71
|
]);
|
|
72
|
+
const batchDuration = Date.now() - batchStartTime;
|
|
73
|
+
console.log(`[HerdModule] Parallel batch load completed in ${batchDuration}ms`);
|
|
70
74
|
// Assign API keys to devices
|
|
71
75
|
for (let i = 0; i < new_devices.length; i++) {
|
|
72
76
|
const device_id = new_devices[i].id ?? 0;
|
|
@@ -81,7 +85,7 @@ export class HerdModule {
|
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
catch (error) {
|
|
84
|
-
console.
|
|
88
|
+
console.error(`[HerdModule] CRITICAL ERROR in batch load after ${Date.now() - batchStartTime}ms:`, error);
|
|
85
89
|
// Continue without API keys and events
|
|
86
90
|
}
|
|
87
91
|
}
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -804,7 +804,7 @@ export type Database = {
|
|
|
804
804
|
};
|
|
805
805
|
load_api_keys_batch: {
|
|
806
806
|
Args: {
|
|
807
|
-
device_ids:
|
|
807
|
+
device_ids: string[];
|
|
808
808
|
};
|
|
809
809
|
Returns: {
|
|
810
810
|
device_id: number;
|
|
@@ -814,7 +814,7 @@ export type Database = {
|
|
|
814
814
|
};
|
|
815
815
|
get_events_and_tags_for_devices_batch: {
|
|
816
816
|
Args: {
|
|
817
|
-
device_ids:
|
|
817
|
+
device_ids: string[];
|
|
818
818
|
limit_per_device: number;
|
|
819
819
|
};
|
|
820
820
|
Returns: {
|