@adventurelabs/scout-core 1.0.122 → 1.0.125

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_with_components_for_herd with rpc
6
- const { data, error } = await client.rpc("get_devices_with_components_for_herd", {
5
+ // call get_devices_for_herd with rpc
6
+ const { data, error } = await client.rpc("get_devices_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_with_components_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
  };
@@ -1384,6 +1384,15 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1384
1384
  user_status: "ONLINE" | "OFFLINE";
1385
1385
  };
1386
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
+ };
1387
1396
  connectivity_with_coordinates: {
1388
1397
  id: number | null;
1389
1398
  session_id: number | null;
@@ -1447,7 +1456,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1447
1456
  description: string | null;
1448
1457
  latitude: number | null;
1449
1458
  longitude: number | null;
1450
- components: import("../types/supabase").Json | null;
1459
+ components: Database["public"]["CompositeTypes"]["component_detail"][] | null;
1451
1460
  };
1452
1461
  event_and_tags: {
1453
1462
  id: number | null;
@@ -6,9 +6,8 @@ export type DeviceType = Database["public"]["Enums"]["device_type"];
6
6
  export type MediaType = Database["public"]["Enums"]["media_type"];
7
7
  export type TagObservationType = Database["public"]["Enums"]["tag_observation_type"];
8
8
  export type IUser = User;
9
- export type IDevice = Database["public"]["CompositeTypes"]["device_with_components"] & {
9
+ export type IDevice = Database["public"]["CompositeTypes"]["device_pretty_location"] & {
10
10
  api_keys_scout?: IApiKeyScout[];
11
- recent_events?: IEventAndTagsPrettyLocation[];
12
11
  };
13
12
  export type IEvent = Database["public"]["Tables"]["events"]["Row"];
14
13
  export type ITag = Database["public"]["Tables"]["tags"]["Row"];
@@ -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
  };
@@ -1438,6 +1438,15 @@ export type Database = {
1438
1438
  user_status: "ONLINE" | "OFFLINE";
1439
1439
  };
1440
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
+ };
1441
1450
  connectivity_with_coordinates: {
1442
1451
  id: number | null;
1443
1452
  session_id: number | null;
@@ -1501,7 +1510,7 @@ export type Database = {
1501
1510
  description: string | null;
1502
1511
  latitude: number | null;
1503
1512
  longitude: number | null;
1504
- components: Json | null;
1513
+ components: Database["public"]["CompositeTypes"]["component_detail"][] | null;
1505
1514
  };
1506
1515
  event_and_tags: {
1507
1516
  id: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.0.122",
3
+ "version": "1.0.125",
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",