@adventurelabs/scout-core 1.0.128 → 1.0.129

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;
@@ -785,10 +785,11 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
785
785
  Row: {
786
786
  commit_hash: string | null;
787
787
  created_at: string;
788
- created_by: string | null;
789
788
  description: string;
790
789
  hyperlink: string | null;
791
790
  id: number;
791
+ pre: boolean;
792
+ stable: boolean;
792
793
  system: string;
793
794
  title: string | null;
794
795
  updated_at: string | null;
@@ -797,10 +798,11 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
797
798
  Insert: {
798
799
  commit_hash?: string | null;
799
800
  created_at?: string;
800
- created_by?: string | null;
801
801
  description: string;
802
802
  hyperlink?: string | null;
803
803
  id?: number;
804
+ pre?: boolean;
805
+ stable?: boolean;
804
806
  system: string;
805
807
  title?: string | null;
806
808
  updated_at?: string | null;
@@ -809,22 +811,17 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
809
811
  Update: {
810
812
  commit_hash?: string | null;
811
813
  created_at?: string;
812
- created_by?: string | null;
813
814
  description?: string;
814
815
  hyperlink?: string | null;
815
816
  id?: number;
817
+ pre?: boolean;
818
+ stable?: boolean;
816
819
  system?: string;
817
820
  title?: string | null;
818
821
  updated_at?: string | null;
819
822
  version?: string;
820
823
  };
821
- Relationships: [{
822
- foreignKeyName: "versions_software_created_by_fkey";
823
- columns: ["created_by"];
824
- isOneToOne: false;
825
- referencedRelation: "users";
826
- referencedColumns: ["id"];
827
- }];
824
+ Relationships: [];
828
825
  };
829
826
  zones: {
830
827
  Row: {
@@ -1160,18 +1157,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1160
1157
  };
1161
1158
  Returns: number;
1162
1159
  };
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
1160
  get_devices_for_herd: {
1176
1161
  Args: {
1177
1162
  herd_id_caller: number;
@@ -1184,18 +1169,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1184
1169
  isSetofReturn: true;
1185
1170
  };
1186
1171
  };
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
1172
  get_events_and_tags_for_device: {
1200
1173
  Args: {
1201
1174
  device_id_caller: number;
@@ -1384,15 +1357,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1384
1357
  user_status: "ONLINE" | "OFFLINE";
1385
1358
  };
1386
1359
  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
1360
  connectivity_with_coordinates: {
1397
1361
  id: number | null;
1398
1362
  session_id: number | null;
@@ -1442,22 +1406,6 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
1442
1406
  latitude: number | null;
1443
1407
  longitude: number | null;
1444
1408
  };
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
1409
  event_and_tags: {
1462
1410
  id: number | null;
1463
1411
  inserted_at: string | null;
@@ -825,10 +825,11 @@ export type Database = {
825
825
  Row: {
826
826
  commit_hash: string | null;
827
827
  created_at: string;
828
- created_by: string | null;
829
828
  description: string;
830
829
  hyperlink: string | null;
831
830
  id: number;
831
+ pre: boolean;
832
+ stable: boolean;
832
833
  system: string;
833
834
  title: string | null;
834
835
  updated_at: string | null;
@@ -837,10 +838,11 @@ export type Database = {
837
838
  Insert: {
838
839
  commit_hash?: string | null;
839
840
  created_at?: string;
840
- created_by?: string | null;
841
841
  description: string;
842
842
  hyperlink?: string | null;
843
843
  id?: number;
844
+ pre?: boolean;
845
+ stable?: boolean;
844
846
  system: string;
845
847
  title?: string | null;
846
848
  updated_at?: string | null;
@@ -849,24 +851,17 @@ export type Database = {
849
851
  Update: {
850
852
  commit_hash?: string | null;
851
853
  created_at?: string;
852
- created_by?: string | null;
853
854
  description?: string;
854
855
  hyperlink?: string | null;
855
856
  id?: number;
857
+ pre?: boolean;
858
+ stable?: boolean;
856
859
  system?: string;
857
860
  title?: string | null;
858
861
  updated_at?: string | null;
859
862
  version?: string;
860
863
  };
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
- ];
864
+ Relationships: [];
870
865
  };
871
866
  zones: {
872
867
  Row: {
@@ -1214,18 +1209,6 @@ export type Database = {
1214
1209
  };
1215
1210
  Returns: number;
1216
1211
  };
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
1212
  get_devices_for_herd: {
1230
1213
  Args: {
1231
1214
  herd_id_caller: number;
@@ -1238,18 +1221,6 @@ export type Database = {
1238
1221
  isSetofReturn: true;
1239
1222
  };
1240
1223
  };
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
1224
  get_events_and_tags_for_device: {
1254
1225
  Args: {
1255
1226
  device_id_caller: number;
@@ -1438,15 +1409,6 @@ export type Database = {
1438
1409
  user_status: "ONLINE" | "OFFLINE";
1439
1410
  };
1440
1411
  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
1412
  connectivity_with_coordinates: {
1451
1413
  id: number | null;
1452
1414
  session_id: number | null;
@@ -1496,22 +1458,6 @@ export type Database = {
1496
1458
  latitude: number | null;
1497
1459
  longitude: number | null;
1498
1460
  };
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
1461
  event_and_tags: {
1516
1462
  id: number | null;
1517
1463
  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.129",
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",