@adventurelabs/scout-core 1.4.58 → 1.4.59
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.
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
2
|
import { Database } from "../types/supabase";
|
|
3
|
-
|
|
4
|
-
export declare function parseStorageFilePath(filePath: string): {
|
|
5
|
-
bucket: string;
|
|
6
|
-
objectPath: string;
|
|
7
|
-
} | null;
|
|
3
|
+
export { parseStorageFilePath } from "./storagePath";
|
|
8
4
|
export declare function generateSignedUrl(filePath: string, expiresIn?: number, supabaseClient?: SupabaseClient<Database>): Promise<string | null>;
|
|
9
5
|
export declare function generateSignedUrlsBatch(filePaths: string[], expiresIn?: number, supabaseClient?: SupabaseClient<Database>): Promise<(string | null)[]>;
|
package/dist/helpers/storage.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import { newServerClient } from "../supabase/server";
|
|
3
2
|
import { SIGNED_URL_EXPIRATION_SECONDS } from "../constants/db";
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
const cleaned = filePath.trim().replace(/^\/+|\/+$/g, "");
|
|
7
|
-
if (!cleaned) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const parts = cleaned.split("/");
|
|
11
|
-
if (parts.length < 2) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const bucket = parts[0];
|
|
15
|
-
if (/^[0-9]+$/.test(bucket)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return { bucket, objectPath: parts.slice(1).join("/") };
|
|
19
|
-
}
|
|
3
|
+
import { parseStorageFilePath } from "./storagePath";
|
|
4
|
+
export { parseStorageFilePath } from "./storagePath";
|
|
20
5
|
export async function generateSignedUrl(filePath, expiresIn = SIGNED_URL_EXPIRATION_SECONDS, supabaseClient) {
|
|
21
6
|
try {
|
|
22
7
|
const supabase = supabaseClient || (await newServerClient());
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Assumes DB `file_path` is always `bucket/object/...` */
|
|
2
|
+
export function parseStorageFilePath(filePath) {
|
|
3
|
+
const cleaned = filePath.trim().replace(/^\/+|\/+$/g, "");
|
|
4
|
+
if (!cleaned) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const parts = cleaned.split("/");
|
|
8
|
+
if (parts.length < 2) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const bucket = parts[0];
|
|
12
|
+
if (/^[0-9]+$/.test(bucket)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return { bucket, objectPath: parts.slice(1).join("/") };
|
|
16
|
+
}
|