@adventurelabs/scout-core 1.4.41 → 1.4.42
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/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/observations.d.ts +9 -0
- package/dist/helpers/observations.js +73 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/providers/ScoutRefreshProvider.d.ts +3 -0
- package/dist/types/db.d.ts +3 -0
- package/dist/types/supabase.d.ts +3 -0
- package/package.json +1 -1
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Database } from "../types/supabase";
|
|
2
|
+
import { IObservation, ObservationInsert, ObservationUpdate } from "../types/db";
|
|
3
|
+
import { IWebResponseCompatible } from "../types/requests";
|
|
4
|
+
import { SupabaseClient } from "@supabase/supabase-js";
|
|
5
|
+
export declare function get_observations_for_session(client: SupabaseClient<Database>, session_id: number): Promise<IWebResponseCompatible<IObservation[]>>;
|
|
6
|
+
export declare function get_observation_by_id(client: SupabaseClient<Database>, observation_id: number): Promise<IWebResponseCompatible<IObservation | null>>;
|
|
7
|
+
export declare function create_observation(client: SupabaseClient<Database>, row: ObservationInsert): Promise<IWebResponseCompatible<IObservation | null>>;
|
|
8
|
+
export declare function update_observation(client: SupabaseClient<Database>, observation_id: number, patch: ObservationUpdate): Promise<IWebResponseCompatible<IObservation | null>>;
|
|
9
|
+
export declare function delete_observation(client: SupabaseClient<Database>, observation_id: number): Promise<IWebResponseCompatible<IObservation | null>>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { IWebResponse } from "../types/requests";
|
|
2
|
+
export async function get_observations_for_session(client, session_id) {
|
|
3
|
+
const { data, error } = await client
|
|
4
|
+
.from("observations")
|
|
5
|
+
.select("*")
|
|
6
|
+
.eq("session_id", session_id)
|
|
7
|
+
.order("inserted_at", { ascending: false });
|
|
8
|
+
if (error) {
|
|
9
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
10
|
+
}
|
|
11
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
12
|
+
}
|
|
13
|
+
export async function get_observation_by_id(client, observation_id) {
|
|
14
|
+
const { data, error } = await client
|
|
15
|
+
.from("observations")
|
|
16
|
+
.select("*")
|
|
17
|
+
.eq("id", observation_id)
|
|
18
|
+
.single();
|
|
19
|
+
if (error) {
|
|
20
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
21
|
+
}
|
|
22
|
+
if (!data) {
|
|
23
|
+
return IWebResponse.error("Observation not found").to_compatible();
|
|
24
|
+
}
|
|
25
|
+
return IWebResponse.success(data).to_compatible();
|
|
26
|
+
}
|
|
27
|
+
export async function create_observation(client, row) {
|
|
28
|
+
const { data, error } = await client
|
|
29
|
+
.from("observations")
|
|
30
|
+
.insert([row])
|
|
31
|
+
.select("*")
|
|
32
|
+
.single();
|
|
33
|
+
if (error) {
|
|
34
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
35
|
+
}
|
|
36
|
+
if (!data) {
|
|
37
|
+
return IWebResponse.error("Failed to create observation").to_compatible();
|
|
38
|
+
}
|
|
39
|
+
return IWebResponse.success(data).to_compatible();
|
|
40
|
+
}
|
|
41
|
+
export async function update_observation(client, observation_id, patch) {
|
|
42
|
+
const updateData = { ...patch };
|
|
43
|
+
delete updateData.id;
|
|
44
|
+
delete updateData.inserted_at;
|
|
45
|
+
const { data, error } = await client
|
|
46
|
+
.from("observations")
|
|
47
|
+
.update(updateData)
|
|
48
|
+
.eq("id", observation_id)
|
|
49
|
+
.select("*")
|
|
50
|
+
.single();
|
|
51
|
+
if (error) {
|
|
52
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
53
|
+
}
|
|
54
|
+
if (!data) {
|
|
55
|
+
return IWebResponse.error("Observation not found or update failed").to_compatible();
|
|
56
|
+
}
|
|
57
|
+
return IWebResponse.success(data).to_compatible();
|
|
58
|
+
}
|
|
59
|
+
export async function delete_observation(client, observation_id) {
|
|
60
|
+
const { data, error } = await client
|
|
61
|
+
.from("observations")
|
|
62
|
+
.delete()
|
|
63
|
+
.eq("id", observation_id)
|
|
64
|
+
.select("*")
|
|
65
|
+
.single();
|
|
66
|
+
if (error) {
|
|
67
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
68
|
+
}
|
|
69
|
+
if (!data) {
|
|
70
|
+
return IWebResponse.error("Observation not found or deletion failed").to_compatible();
|
|
71
|
+
}
|
|
72
|
+
return IWebResponse.success(data).to_compatible();
|
|
73
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export * from "./helpers/cache";
|
|
|
39
39
|
export * from "./helpers/health_metrics";
|
|
40
40
|
export * from "./helpers/heartbeats";
|
|
41
41
|
export * from "./helpers/providers";
|
|
42
|
+
export * from "./helpers/observations";
|
|
42
43
|
export * from "./helpers/operators";
|
|
43
44
|
export * from "./helpers/versions_software";
|
|
44
45
|
export * from "./helpers/versions_software_server";
|
|
@@ -62,5 +63,5 @@ export * from "./supabase/middleware";
|
|
|
62
63
|
export * from "./supabase/server";
|
|
63
64
|
export * from "./api_keys/actions";
|
|
64
65
|
export type { HerdModule, IHerdModule } from "./types/herd_module";
|
|
65
|
-
export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, IUserAndRole, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, } from "./types/db";
|
|
66
|
+
export type { IDevice, IEvent, IUser, IHerd, IHerdPrettyLocation, IEventWithTags, IZoneWithActions, IUserAndRole, IApiKeyScout, ILayer, IHeartbeat, IProvider, IConnectivity, ISession, ISessionWithCoordinates, IConnectivityWithCoordinates, IObservation, ObservationInsert, ObservationUpdate, } from "./types/db";
|
|
66
67
|
export { EnumSessionsVisibility } from "./types/events";
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export * from "./helpers/cache";
|
|
|
42
42
|
export * from "./helpers/health_metrics";
|
|
43
43
|
export * from "./helpers/heartbeats";
|
|
44
44
|
export * from "./helpers/providers";
|
|
45
|
+
export * from "./helpers/observations";
|
|
45
46
|
export * from "./helpers/operators";
|
|
46
47
|
export * from "./helpers/versions_software";
|
|
47
48
|
export * from "./helpers/versions_software_server";
|
|
@@ -703,6 +703,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
703
703
|
id: number;
|
|
704
704
|
inserted_at: string;
|
|
705
705
|
session_id: number;
|
|
706
|
+
timestamp: string | null;
|
|
706
707
|
updated_at: string | null;
|
|
707
708
|
};
|
|
708
709
|
Insert: {
|
|
@@ -712,6 +713,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
712
713
|
id?: number;
|
|
713
714
|
inserted_at?: string;
|
|
714
715
|
session_id: number;
|
|
716
|
+
timestamp?: string | null;
|
|
715
717
|
updated_at?: string | null;
|
|
716
718
|
};
|
|
717
719
|
Update: {
|
|
@@ -721,6 +723,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
721
723
|
id?: number;
|
|
722
724
|
inserted_at?: string;
|
|
723
725
|
session_id?: number;
|
|
726
|
+
timestamp?: string | null;
|
|
724
727
|
updated_at?: string | null;
|
|
725
728
|
};
|
|
726
729
|
Relationships: [{
|
package/dist/types/db.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type ISession = Database["public"]["Tables"]["sessions"]["Row"];
|
|
|
24
24
|
export type IConnectivity = Database["public"]["Tables"]["connectivity"]["Row"];
|
|
25
25
|
export type IHeartbeat = Database["public"]["Tables"]["heartbeats"]["Row"];
|
|
26
26
|
export type IOperator = Database["public"]["Tables"]["operators"]["Row"];
|
|
27
|
+
export type IObservation = Database["public"]["Tables"]["observations"]["Row"];
|
|
27
28
|
export type IProvider = Database["public"]["Tables"]["providers"]["Row"];
|
|
28
29
|
export type IPart = Database["public"]["Tables"]["parts"]["Row"];
|
|
29
30
|
export type IVersionsSoftware = Database["public"]["Tables"]["versions_software"]["Row"];
|
|
@@ -70,6 +71,8 @@ export type ConnectivityUpdate = Database["public"]["Tables"]["connectivity"]["U
|
|
|
70
71
|
export type EventInsert = Database["public"]["Tables"]["events"]["Insert"];
|
|
71
72
|
export type EventUpdate = Database["public"]["Tables"]["events"]["Update"];
|
|
72
73
|
export type TagInsert = Database["public"]["Tables"]["tags"]["Insert"];
|
|
74
|
+
export type ObservationInsert = Database["public"]["Tables"]["observations"]["Insert"];
|
|
75
|
+
export type ObservationUpdate = Database["public"]["Tables"]["observations"]["Update"];
|
|
73
76
|
export type IEventWithTags = Database["public"]["CompositeTypes"]["event_with_tags"] & {
|
|
74
77
|
earthranger_url: string | null;
|
|
75
78
|
file_path: string | null;
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -736,6 +736,7 @@ export type Database = {
|
|
|
736
736
|
id: number;
|
|
737
737
|
inserted_at: string;
|
|
738
738
|
session_id: number;
|
|
739
|
+
timestamp: string | null;
|
|
739
740
|
updated_at: string | null;
|
|
740
741
|
};
|
|
741
742
|
Insert: {
|
|
@@ -745,6 +746,7 @@ export type Database = {
|
|
|
745
746
|
id?: number;
|
|
746
747
|
inserted_at?: string;
|
|
747
748
|
session_id: number;
|
|
749
|
+
timestamp?: string | null;
|
|
748
750
|
updated_at?: string | null;
|
|
749
751
|
};
|
|
750
752
|
Update: {
|
|
@@ -754,6 +756,7 @@ export type Database = {
|
|
|
754
756
|
id?: number;
|
|
755
757
|
inserted_at?: string;
|
|
756
758
|
session_id?: number;
|
|
759
|
+
timestamp?: string | null;
|
|
757
760
|
updated_at?: string | null;
|
|
758
761
|
};
|
|
759
762
|
Relationships: [
|