@adventurelabs/scout-core 1.0.128 → 1.0.130

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.
@@ -7,6 +7,8 @@ import { SIGNED_URL_EXPIRATION_SECONDS, } from "../constants/db";
7
7
  * @returns IFilePathParts | null - null if invalid file path
8
8
  */
9
9
  function getBucketFromFilePath(filePath) {
10
+ // delete any start or end slashes/whitespace
11
+ filePath = filePath.replace(/^\/+|\/+$/g, "");
10
12
  const parts = filePath.split("/");
11
13
  if (parts.length < 2) {
12
14
  return null;
@@ -14,6 +16,26 @@ function getBucketFromFilePath(filePath) {
14
16
  const bucket_name = parts[0];
15
17
  return bucket_name;
16
18
  }
19
+ /**
20
+ * Extracts the short path from a file path
21
+ * @param filePath
22
+ * @returns string | null - null if invalid file path
23
+ */
24
+ // for example if the input is /artifacts/10/52/test.mp4 - the output shld be 10/52/test.mp4
25
+ function getFormattedPath(filePath) {
26
+ const cleaned = cleanPath(filePath);
27
+ const parts = cleaned.split("/");
28
+ if (parts.length < 2) {
29
+ return null;
30
+ }
31
+ // Remove the first part (bucket name) and return the rest
32
+ return parts.slice(1).join("/");
33
+ }
34
+ /** Removes leading and trailing slashes and leading/trailing whitespace */
35
+ function cleanPath(filePath) {
36
+ // delete leading/trailing slash and whitespace
37
+ return filePath.trim().replace(/^\/+|\/+$/g, "");
38
+ }
17
39
  /**
18
40
  * Generates a signed URL for a file in Supabase storage
19
41
  * @param filePath - The path to the file in storage (e.g., "events/123/image.jpg")
@@ -29,9 +51,14 @@ export async function generateSignedUrl(filePath, expiresIn = SIGNED_URL_EXPIRAT
29
51
  console.error("Invalid file path:", filePath);
30
52
  return null;
31
53
  }
54
+ const formattedPath = getFormattedPath(filePath);
55
+ if (!formattedPath) {
56
+ console.error("Invalid formatted path:", formattedPath);
57
+ return null;
58
+ }
32
59
  const { data, error } = await supabase.storage
33
60
  .from(bucket_name)
34
- .createSignedUrl(filePath, expiresIn);
61
+ .createSignedUrl(formattedPath, expiresIn);
35
62
  if (error) {
36
63
  console.error("Error generating signed URL:", error.message);
37
64
  return null;
@@ -53,9 +80,14 @@ export async function generateSignedUrlsBatch(filePaths, expiresIn = SIGNED_URL_
53
80
  console.error("Invalid file path:", filePath);
54
81
  return null;
55
82
  }
83
+ const formattedPath = getFormattedPath(filePath);
84
+ if (!formattedPath) {
85
+ console.error("Invalid formatted path:", formattedPath);
86
+ return null;
87
+ }
56
88
  const { data, error } = await supabase.storage
57
89
  .from(bucket_name)
58
- .createSignedUrl(filePath, expiresIn);
90
+ .createSignedUrl(formattedPath, expiresIn);
59
91
  if (error) {
60
92
  console.warn(`Error generating signed URL for ${filePath}:`, error.message);
61
93
  return null;
@@ -55,6 +55,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
55
55
  modality: string | null;
56
56
  session_id: number | null;
57
57
  timestamp_observation: string | null;
58
+ timestamp_observation_end: string;
58
59
  updated_at: string | null;
59
60
  };
60
61
  Insert: {
@@ -65,6 +66,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
65
66
  modality?: string | null;
66
67
  session_id?: number | null;
67
68
  timestamp_observation?: string | null;
69
+ timestamp_observation_end?: string;
68
70
  updated_at?: string | null;
69
71
  };
70
72
  Update: {
@@ -75,6 +77,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
75
77
  modality?: string | null;
76
78
  session_id?: number | null;
77
79
  timestamp_observation?: string | null;
80
+ timestamp_observation_end?: string;
78
81
  updated_at?: string | null;
79
82
  };
80
83
  Relationships: [{
@@ -785,10 +788,12 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
785
788
  Row: {
786
789
  commit_hash: string | null;
787
790
  created_at: string;
788
- created_by: string | null;
789
791
  description: string;
790
792
  hyperlink: string | null;
791
793
  id: number;
794
+ min: boolean;
795
+ pre: boolean;
796
+ stable: boolean;
792
797
  system: string;
793
798
  title: string | null;
794
799
  updated_at: string | null;
@@ -797,10 +802,12 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
797
802
  Insert: {
798
803
  commit_hash?: string | null;
799
804
  created_at?: string;
800
- created_by?: string | null;
801
805
  description: string;
802
806
  hyperlink?: string | null;
803
807
  id?: number;
808
+ min?: boolean;
809
+ pre?: boolean;
810
+ stable?: boolean;
804
811
  system: string;
805
812
  title?: string | null;
806
813
  updated_at?: string | null;
@@ -809,22 +816,18 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
809
816
  Update: {
810
817
  commit_hash?: string | null;
811
818
  created_at?: string;
812
- created_by?: string | null;
813
819
  description?: string;
814
820
  hyperlink?: string | null;
815
821
  id?: number;
822
+ min?: boolean;
823
+ pre?: boolean;
824
+ stable?: boolean;
816
825
  system?: string;
817
826
  title?: string | null;
818
827
  updated_at?: string | null;
819
828
  version?: string;
820
829
  };
821
- Relationships: [{
822
- foreignKeyName: "versions_software_created_by_fkey";
823
- columns: ["created_by"];
824
- isOneToOne: false;
825
- referencedRelation: "users";
826
- referencedColumns: ["id"];
827
- }];
830
+ Relationships: [];
828
831
  };
829
832
  zones: {
830
833
  Row: {
@@ -1051,6 +1054,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1051
1054
  modality: string | null;
1052
1055
  session_id: number | null;
1053
1056
  timestamp_observation: string | null;
1057
+ timestamp_observation_end: string;
1054
1058
  updated_at: string | null;
1055
1059
  }[];
1056
1060
  SetofOptions: {
@@ -1073,6 +1077,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1073
1077
  modality: string | null;
1074
1078
  session_id: number | null;
1075
1079
  timestamp_observation: string | null;
1080
+ timestamp_observation_end: string;
1076
1081
  updated_at: string | null;
1077
1082
  }[];
1078
1083
  SetofOptions: {
@@ -1096,6 +1101,7 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1096
1101
  modality: string | null;
1097
1102
  session_id: number | null;
1098
1103
  timestamp_observation: string | null;
1104
+ timestamp_observation_end: string;
1099
1105
  updated_at: string | null;
1100
1106
  }[];
1101
1107
  SetofOptions: {
@@ -1160,18 +1166,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1160
1166
  };
1161
1167
  Returns: number;
1162
1168
  };
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
- };
1175
1169
  get_devices_for_herd: {
1176
1170
  Args: {
1177
1171
  herd_id_caller: number;
@@ -1184,18 +1178,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1184
1178
  isSetofReturn: true;
1185
1179
  };
1186
1180
  };
1187
- get_devices_with_components_for_herd: {
1188
- Args: {
1189
- herd_id_caller: number;
1190
- };
1191
- Returns: Database["public"]["CompositeTypes"]["device_with_components"][];
1192
- SetofOptions: {
1193
- from: "*";
1194
- to: "device_with_components";
1195
- isOneToOne: false;
1196
- isSetofReturn: true;
1197
- };
1198
- };
1199
1181
  get_events_and_tags_for_device: {
1200
1182
  Args: {
1201
1183
  device_id_caller: number;
@@ -1384,15 +1366,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1384
1366
  user_status: "ONLINE" | "OFFLINE";
1385
1367
  };
1386
1368
  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
- };
1396
1369
  connectivity_with_coordinates: {
1397
1370
  id: number | null;
1398
1371
  session_id: number | null;
@@ -1442,22 +1415,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1442
1415
  latitude: number | null;
1443
1416
  longitude: number | null;
1444
1417
  };
1445
- device_with_components: {
1446
- id: number | null;
1447
- inserted_at: string | null;
1448
- created_by: string | null;
1449
- herd_id: number | null;
1450
- device_type: Database["public"]["Enums"]["device_type"] | null;
1451
- domain_name: string | null;
1452
- location: string | null;
1453
- altitude: number | null;
1454
- heading: number | null;
1455
- name: string | null;
1456
- description: string | null;
1457
- latitude: number | null;
1458
- longitude: number | null;
1459
- components: Database["public"]["CompositeTypes"]["component_detail"][] | null;
1460
- };
1461
1418
  event_and_tags: {
1462
1419
  id: number | null;
1463
1420
  inserted_at: string | null;
@@ -55,6 +55,7 @@ export type Database = {
55
55
  modality: string | null;
56
56
  session_id: number | null;
57
57
  timestamp_observation: string | null;
58
+ timestamp_observation_end: string;
58
59
  updated_at: string | null;
59
60
  };
60
61
  Insert: {
@@ -65,6 +66,7 @@ export type Database = {
65
66
  modality?: string | null;
66
67
  session_id?: number | null;
67
68
  timestamp_observation?: string | null;
69
+ timestamp_observation_end?: string;
68
70
  updated_at?: string | null;
69
71
  };
70
72
  Update: {
@@ -75,6 +77,7 @@ export type Database = {
75
77
  modality?: string | null;
76
78
  session_id?: number | null;
77
79
  timestamp_observation?: string | null;
80
+ timestamp_observation_end?: string;
78
81
  updated_at?: string | null;
79
82
  };
80
83
  Relationships: [
@@ -825,10 +828,12 @@ export type Database = {
825
828
  Row: {
826
829
  commit_hash: string | null;
827
830
  created_at: string;
828
- created_by: string | null;
829
831
  description: string;
830
832
  hyperlink: string | null;
831
833
  id: number;
834
+ min: boolean;
835
+ pre: boolean;
836
+ stable: boolean;
832
837
  system: string;
833
838
  title: string | null;
834
839
  updated_at: string | null;
@@ -837,10 +842,12 @@ export type Database = {
837
842
  Insert: {
838
843
  commit_hash?: string | null;
839
844
  created_at?: string;
840
- created_by?: string | null;
841
845
  description: string;
842
846
  hyperlink?: string | null;
843
847
  id?: number;
848
+ min?: boolean;
849
+ pre?: boolean;
850
+ stable?: boolean;
844
851
  system: string;
845
852
  title?: string | null;
846
853
  updated_at?: string | null;
@@ -849,24 +856,18 @@ export type Database = {
849
856
  Update: {
850
857
  commit_hash?: string | null;
851
858
  created_at?: string;
852
- created_by?: string | null;
853
859
  description?: string;
854
860
  hyperlink?: string | null;
855
861
  id?: number;
862
+ min?: boolean;
863
+ pre?: boolean;
864
+ stable?: boolean;
856
865
  system?: string;
857
866
  title?: string | null;
858
867
  updated_at?: string | null;
859
868
  version?: string;
860
869
  };
861
- Relationships: [
862
- {
863
- foreignKeyName: "versions_software_created_by_fkey";
864
- columns: ["created_by"];
865
- isOneToOne: false;
866
- referencedRelation: "users";
867
- referencedColumns: ["id"];
868
- }
869
- ];
870
+ Relationships: [];
870
871
  };
871
872
  zones: {
872
873
  Row: {
@@ -1105,6 +1106,7 @@ export type Database = {
1105
1106
  modality: string | null;
1106
1107
  session_id: number | null;
1107
1108
  timestamp_observation: string | null;
1109
+ timestamp_observation_end: string;
1108
1110
  updated_at: string | null;
1109
1111
  }[];
1110
1112
  SetofOptions: {
@@ -1127,6 +1129,7 @@ export type Database = {
1127
1129
  modality: string | null;
1128
1130
  session_id: number | null;
1129
1131
  timestamp_observation: string | null;
1132
+ timestamp_observation_end: string;
1130
1133
  updated_at: string | null;
1131
1134
  }[];
1132
1135
  SetofOptions: {
@@ -1150,6 +1153,7 @@ export type Database = {
1150
1153
  modality: string | null;
1151
1154
  session_id: number | null;
1152
1155
  timestamp_observation: string | null;
1156
+ timestamp_observation_end: string;
1153
1157
  updated_at: string | null;
1154
1158
  }[];
1155
1159
  SetofOptions: {
@@ -1214,18 +1218,6 @@ export type Database = {
1214
1218
  };
1215
1219
  Returns: number;
1216
1220
  };
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
- };
1229
1221
  get_devices_for_herd: {
1230
1222
  Args: {
1231
1223
  herd_id_caller: number;
@@ -1238,18 +1230,6 @@ export type Database = {
1238
1230
  isSetofReturn: true;
1239
1231
  };
1240
1232
  };
1241
- get_devices_with_components_for_herd: {
1242
- Args: {
1243
- herd_id_caller: number;
1244
- };
1245
- Returns: Database["public"]["CompositeTypes"]["device_with_components"][];
1246
- SetofOptions: {
1247
- from: "*";
1248
- to: "device_with_components";
1249
- isOneToOne: false;
1250
- isSetofReturn: true;
1251
- };
1252
- };
1253
1233
  get_events_and_tags_for_device: {
1254
1234
  Args: {
1255
1235
  device_id_caller: number;
@@ -1438,15 +1418,6 @@ export type Database = {
1438
1418
  user_status: "ONLINE" | "OFFLINE";
1439
1419
  };
1440
1420
  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
- };
1450
1421
  connectivity_with_coordinates: {
1451
1422
  id: number | null;
1452
1423
  session_id: number | null;
@@ -1496,22 +1467,6 @@ export type Database = {
1496
1467
  latitude: number | null;
1497
1468
  longitude: number | null;
1498
1469
  };
1499
- device_with_components: {
1500
- id: number | null;
1501
- inserted_at: string | null;
1502
- created_by: string | null;
1503
- herd_id: number | null;
1504
- device_type: Database["public"]["Enums"]["device_type"] | null;
1505
- domain_name: string | null;
1506
- location: string | null;
1507
- altitude: number | null;
1508
- heading: number | null;
1509
- name: string | null;
1510
- description: string | null;
1511
- latitude: number | null;
1512
- longitude: number | null;
1513
- components: Database["public"]["CompositeTypes"]["component_detail"][] | null;
1514
- };
1515
1470
  event_and_tags: {
1516
1471
  id: number | null;
1517
1472
  inserted_at: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.0.128",
3
+ "version": "1.0.130",
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",