@adventurelabs/scout-core 1.0.121 → 1.0.124

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.
@@ -3,7 +3,6 @@ import { DeviceInsert, IDevice } from "../types/db";
3
3
  import { IWebResponseCompatible } from "../types/requests";
4
4
  import { SupabaseClient } from "@supabase/supabase-js";
5
5
  export declare function get_devices_by_herd(herd_id: number, client: SupabaseClient<Database>): Promise<IWebResponseCompatible<IDevice[]>>;
6
- export declare function get_device_by_id(device_id: number, client?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IDevice | null>>;
7
6
  export declare function serverUpdateDevice(updatedDevice: IDevice): Promise<IWebResponseCompatible<IDevice | null>>;
8
7
  export declare function serverCreateDevice(newDevice: DeviceInsert): Promise<IWebResponseCompatible<IDevice | null>>;
9
8
  export declare function serverDeleteDeviceById(device_id: number): Promise<IWebResponseCompatible<IDevice | null>>;
@@ -2,8 +2,8 @@
2
2
  import { newServerClient } from "../supabase/server";
3
3
  import { IWebResponse } from "../types/requests";
4
4
  export async function get_devices_by_herd(herd_id, client) {
5
- // call get_devices_for_herd with rpc
6
- const { data, error } = await client.rpc("get_devices_for_herd", {
5
+ // call get_devices_with_components_for_herd with rpc
6
+ const { data, error } = await client.rpc("get_devices_with_components_for_herd", {
7
7
  herd_id_caller: herd_id,
8
8
  });
9
9
  if (!data) {
@@ -14,21 +14,6 @@ export async function get_devices_by_herd(herd_id, client) {
14
14
  return response.to_compatible();
15
15
  }
16
16
  }
17
- export async function get_device_by_id(device_id, client) {
18
- if (!client) {
19
- client = await newServerClient();
20
- }
21
- const { data, error } = await client.rpc("get_device_by_id", {
22
- device_id_caller: device_id,
23
- });
24
- if (!data) {
25
- return IWebResponse.error("No device found").to_compatible();
26
- }
27
- else {
28
- let response = IWebResponse.success(data);
29
- return response.to_compatible();
30
- }
31
- }
32
17
  export async function serverUpdateDevice(updatedDevice) {
33
18
  // delete api keys, latitide, and longitude
34
19
  const device_formatted = { ...updatedDevice };
@@ -1146,10 +1146,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1146
1146
  Args: {
1147
1147
  device_id_caller: number;
1148
1148
  };
1149
- Returns: Database["public"]["CompositeTypes"]["device_with_components"];
1149
+ Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
1150
1150
  SetofOptions: {
1151
1151
  from: "*";
1152
- to: "device_with_components";
1152
+ to: "device_pretty_location";
1153
1153
  isOneToOne: true;
1154
1154
  isSetofReturn: false;
1155
1155
  };
@@ -1160,7 +1160,31 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1160
1160
  };
1161
1161
  Returns: number;
1162
1162
  };
1163
+ get_device_with_components_by_id: {
1164
+ Args: {
1165
+ device_id_caller: number;
1166
+ };
1167
+ Returns: Database["public"]["CompositeTypes"]["device_with_components"];
1168
+ SetofOptions: {
1169
+ from: "*";
1170
+ to: "device_with_components";
1171
+ isOneToOne: true;
1172
+ isSetofReturn: false;
1173
+ };
1174
+ };
1163
1175
  get_devices_for_herd: {
1176
+ Args: {
1177
+ herd_id_caller: number;
1178
+ };
1179
+ Returns: Database["public"]["CompositeTypes"]["device_pretty_location"][];
1180
+ SetofOptions: {
1181
+ from: "*";
1182
+ to: "device_pretty_location";
1183
+ isOneToOne: false;
1184
+ isSetofReturn: true;
1185
+ };
1186
+ };
1187
+ get_devices_with_components_for_herd: {
1164
1188
  Args: {
1165
1189
  herd_id_caller: number;
1166
1190
  };
@@ -1360,6 +1384,15 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1360
1384
  user_status: "ONLINE" | "OFFLINE";
1361
1385
  };
1362
1386
  CompositeTypes: {
1387
+ component_detail: {
1388
+ id: number | null;
1389
+ serial_number: string | null;
1390
+ product_number: string | null;
1391
+ certificate_id: number | null;
1392
+ status: Database["public"]["Enums"]["component_status"] | null;
1393
+ created_at: string | null;
1394
+ updated_at: string | null;
1395
+ };
1363
1396
  connectivity_with_coordinates: {
1364
1397
  id: number | null;
1365
1398
  session_id: number | null;
@@ -1423,7 +1456,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1423
1456
  description: string | null;
1424
1457
  latitude: number | null;
1425
1458
  longitude: number | null;
1426
- components: import("../types/supabase").Json | null;
1459
+ components: Database["public"]["CompositeTypes"]["component_detail"][] | null;
1427
1460
  };
1428
1461
  event_and_tags: {
1429
1462
  id: number | null;
@@ -30,6 +30,31 @@ export type IArtifact = Database["public"]["Tables"]["artifacts"]["Row"];
30
30
  export type IArtifactWithMediaUrl = IArtifact & {
31
31
  media_url?: string | null;
32
32
  };
33
+ export type IComponentInfo = {
34
+ id: number;
35
+ serial_number: string;
36
+ product_number: string | null;
37
+ certificate_id: number | null;
38
+ status: Database["public"]["Enums"]["component_status"];
39
+ created_at: string;
40
+ updated_at: string | null;
41
+ };
42
+ export type IDeviceWithComponents = {
43
+ id: number;
44
+ inserted_at: string;
45
+ created_by: string | null;
46
+ herd_id: number;
47
+ device_type: Database["public"]["Enums"]["device_type"];
48
+ domain_name: string | null;
49
+ location: string | null;
50
+ altitude: number | null;
51
+ heading: number | null;
52
+ name: string | null;
53
+ description: string | null;
54
+ latitude: number | null;
55
+ longitude: number | null;
56
+ components: IComponentInfo[];
57
+ };
33
58
  export type ComponentInsert = Database["public"]["Tables"]["components"]["Insert"];
34
59
  export type VersionsSoftwareInsert = Database["public"]["Tables"]["versions_software"]["Insert"];
35
60
  export type ArtifactInsert = Database["public"]["Tables"]["artifacts"]["Insert"];
@@ -1200,10 +1200,10 @@ export type Database = {
1200
1200
  Args: {
1201
1201
  device_id_caller: number;
1202
1202
  };
1203
- Returns: Database["public"]["CompositeTypes"]["device_with_components"];
1203
+ Returns: Database["public"]["CompositeTypes"]["device_pretty_location"];
1204
1204
  SetofOptions: {
1205
1205
  from: "*";
1206
- to: "device_with_components";
1206
+ to: "device_pretty_location";
1207
1207
  isOneToOne: true;
1208
1208
  isSetofReturn: false;
1209
1209
  };
@@ -1214,7 +1214,31 @@ export type Database = {
1214
1214
  };
1215
1215
  Returns: number;
1216
1216
  };
1217
+ get_device_with_components_by_id: {
1218
+ Args: {
1219
+ device_id_caller: number;
1220
+ };
1221
+ Returns: Database["public"]["CompositeTypes"]["device_with_components"];
1222
+ SetofOptions: {
1223
+ from: "*";
1224
+ to: "device_with_components";
1225
+ isOneToOne: true;
1226
+ isSetofReturn: false;
1227
+ };
1228
+ };
1217
1229
  get_devices_for_herd: {
1230
+ Args: {
1231
+ herd_id_caller: number;
1232
+ };
1233
+ Returns: Database["public"]["CompositeTypes"]["device_pretty_location"][];
1234
+ SetofOptions: {
1235
+ from: "*";
1236
+ to: "device_pretty_location";
1237
+ isOneToOne: false;
1238
+ isSetofReturn: true;
1239
+ };
1240
+ };
1241
+ get_devices_with_components_for_herd: {
1218
1242
  Args: {
1219
1243
  herd_id_caller: number;
1220
1244
  };
@@ -1414,6 +1438,15 @@ export type Database = {
1414
1438
  user_status: "ONLINE" | "OFFLINE";
1415
1439
  };
1416
1440
  CompositeTypes: {
1441
+ component_detail: {
1442
+ id: number | null;
1443
+ serial_number: string | null;
1444
+ product_number: string | null;
1445
+ certificate_id: number | null;
1446
+ status: Database["public"]["Enums"]["component_status"] | null;
1447
+ created_at: string | null;
1448
+ updated_at: string | null;
1449
+ };
1417
1450
  connectivity_with_coordinates: {
1418
1451
  id: number | null;
1419
1452
  session_id: number | null;
@@ -1477,7 +1510,7 @@ export type Database = {
1477
1510
  description: string | null;
1478
1511
  latitude: number | null;
1479
1512
  longitude: number | null;
1480
- components: Json | null;
1513
+ components: Database["public"]["CompositeTypes"]["component_detail"][] | null;
1481
1514
  };
1482
1515
  event_and_tags: {
1483
1516
  id: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.0.121",
3
+ "version": "1.0.124",
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",