@adventurelabs/scout-core 1.4.41 → 1.4.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/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 +6 -0
- package/dist/types/db.d.ts +3 -0
- package/dist/types/supabase.d.ts +6 -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";
|
|
@@ -305,6 +305,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
305
305
|
devices: {
|
|
306
306
|
Row: {
|
|
307
307
|
altitude: number | null;
|
|
308
|
+
color: string | null;
|
|
308
309
|
created_by: string;
|
|
309
310
|
description: string;
|
|
310
311
|
device_type: Database["public"]["Enums"]["device_type"];
|
|
@@ -320,6 +321,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
320
321
|
};
|
|
321
322
|
Insert: {
|
|
322
323
|
altitude?: number | null;
|
|
324
|
+
color?: string | null;
|
|
323
325
|
created_by: string;
|
|
324
326
|
description: string;
|
|
325
327
|
device_type?: Database["public"]["Enums"]["device_type"];
|
|
@@ -335,6 +337,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
335
337
|
};
|
|
336
338
|
Update: {
|
|
337
339
|
altitude?: number | null;
|
|
340
|
+
color?: string | null;
|
|
338
341
|
created_by?: string;
|
|
339
342
|
description?: string;
|
|
340
343
|
device_type?: Database["public"]["Enums"]["device_type"];
|
|
@@ -703,6 +706,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
703
706
|
id: number;
|
|
704
707
|
inserted_at: string;
|
|
705
708
|
session_id: number;
|
|
709
|
+
timestamp: string | null;
|
|
706
710
|
updated_at: string | null;
|
|
707
711
|
};
|
|
708
712
|
Insert: {
|
|
@@ -712,6 +716,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
712
716
|
id?: number;
|
|
713
717
|
inserted_at?: string;
|
|
714
718
|
session_id: number;
|
|
719
|
+
timestamp?: string | null;
|
|
715
720
|
updated_at?: string | null;
|
|
716
721
|
};
|
|
717
722
|
Update: {
|
|
@@ -721,6 +726,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
721
726
|
id?: number;
|
|
722
727
|
inserted_at?: string;
|
|
723
728
|
session_id?: number;
|
|
729
|
+
timestamp?: string | null;
|
|
724
730
|
updated_at?: string | null;
|
|
725
731
|
};
|
|
726
732
|
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
|
@@ -317,6 +317,7 @@ export type Database = {
|
|
|
317
317
|
devices: {
|
|
318
318
|
Row: {
|
|
319
319
|
altitude: number | null;
|
|
320
|
+
color: string | null;
|
|
320
321
|
created_by: string;
|
|
321
322
|
description: string;
|
|
322
323
|
device_type: Database["public"]["Enums"]["device_type"];
|
|
@@ -332,6 +333,7 @@ export type Database = {
|
|
|
332
333
|
};
|
|
333
334
|
Insert: {
|
|
334
335
|
altitude?: number | null;
|
|
336
|
+
color?: string | null;
|
|
335
337
|
created_by: string;
|
|
336
338
|
description: string;
|
|
337
339
|
device_type?: Database["public"]["Enums"]["device_type"];
|
|
@@ -347,6 +349,7 @@ export type Database = {
|
|
|
347
349
|
};
|
|
348
350
|
Update: {
|
|
349
351
|
altitude?: number | null;
|
|
352
|
+
color?: string | null;
|
|
350
353
|
created_by?: string;
|
|
351
354
|
description?: string;
|
|
352
355
|
device_type?: Database["public"]["Enums"]["device_type"];
|
|
@@ -736,6 +739,7 @@ export type Database = {
|
|
|
736
739
|
id: number;
|
|
737
740
|
inserted_at: string;
|
|
738
741
|
session_id: number;
|
|
742
|
+
timestamp: string | null;
|
|
739
743
|
updated_at: string | null;
|
|
740
744
|
};
|
|
741
745
|
Insert: {
|
|
@@ -745,6 +749,7 @@ export type Database = {
|
|
|
745
749
|
id?: number;
|
|
746
750
|
inserted_at?: string;
|
|
747
751
|
session_id: number;
|
|
752
|
+
timestamp?: string | null;
|
|
748
753
|
updated_at?: string | null;
|
|
749
754
|
};
|
|
750
755
|
Update: {
|
|
@@ -754,6 +759,7 @@ export type Database = {
|
|
|
754
759
|
id?: number;
|
|
755
760
|
inserted_at?: string;
|
|
756
761
|
session_id?: number;
|
|
762
|
+
timestamp?: string | null;
|
|
757
763
|
updated_at?: string | null;
|
|
758
764
|
};
|
|
759
765
|
Relationships: [
|