@adventurelabs/scout-core 1.3.5 → 1.3.6
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,7 @@
|
|
|
1
|
-
import { ISessionWithCoordinates, ISessionUsageOverTime } from "../types/db";
|
|
1
|
+
import { ISessionWithCoordinates, ISessionUsageOverTime, IEventAndTagsPrettyLocation } from "../types/db";
|
|
2
2
|
import { IWebResponseCompatible } from "../types/requests";
|
|
3
3
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
4
4
|
export declare function server_get_session_by_id(sessionId: number, client?: SupabaseClient): Promise<IWebResponseCompatible<ISessionWithCoordinates | null>>;
|
|
5
5
|
export declare function server_get_session_usage_over_time_by_herd(herd_id: number, client?: SupabaseClient): Promise<IWebResponseCompatible<ISessionUsageOverTime>>;
|
|
6
6
|
export declare function server_get_session_usage_over_time_by_device(device_id: number, client?: SupabaseClient): Promise<IWebResponseCompatible<ISessionUsageOverTime>>;
|
|
7
|
+
export declare function server_get_events_and_tags_by_session_id(sessionId: number, limit?: number, offset?: number): Promise<IWebResponseCompatible<IEventAndTagsPrettyLocation[]>>;
|
package/dist/helpers/sessions.js
CHANGED
|
@@ -53,3 +53,21 @@ export async function server_get_session_usage_over_time_by_device(device_id, cl
|
|
|
53
53
|
}
|
|
54
54
|
return IWebResponse.success(data).to_compatible();
|
|
55
55
|
}
|
|
56
|
+
// Get events with tags by session id using RPC function
|
|
57
|
+
export async function server_get_events_and_tags_by_session_id(sessionId, limit = 50, offset = 0) {
|
|
58
|
+
const supabase = await newServerClient();
|
|
59
|
+
const { data, error } = await supabase.rpc("get_events_and_tags_for_session", {
|
|
60
|
+
session_id_caller: sessionId,
|
|
61
|
+
limit_caller: limit,
|
|
62
|
+
offset_caller: offset,
|
|
63
|
+
});
|
|
64
|
+
if (error) {
|
|
65
|
+
console.warn("Error fetching events and tags by session id:", error.message);
|
|
66
|
+
return {
|
|
67
|
+
status: EnumWebResponse.ERROR,
|
|
68
|
+
msg: error.message,
|
|
69
|
+
data: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return IWebResponse.success(data || []).to_compatible();
|
|
73
|
+
}
|