@directus/storage-driver-supabase 4.0.1 → 5.0.0

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.
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ declare class DriverSupabase implements TusDriver {
27
27
  private getAuthenticatedUrl;
28
28
  private getResumableUrl;
29
29
  read(filepath: string, options?: ReadOptions): Promise<Readable>;
30
+ private find;
30
31
  stat(filepath: string): Promise<{
31
32
  size: any;
32
33
  modified: Date;
package/dist/index.js CHANGED
@@ -53,10 +53,13 @@ var DriverSupabase = class {
53
53
  requestInit.headers = { Authorization: `Bearer ${this.config.serviceRole}` };
54
54
  if (range) requestInit.headers["Range"] = `bytes=${range.start ?? ""}-${range.end ?? ""}`;
55
55
  const response = await fetch(this.getAuthenticatedUrl(filepath), requestInit);
56
- if (response.status >= 400 || !response.body) throw new Error(`No stream returned for file "${filepath}"`);
56
+ if (response.status >= 400 || !response.body) {
57
+ await response.body?.cancel();
58
+ throw new Error(`No stream returned for file "${filepath}"`);
59
+ }
57
60
  return Readable.fromWeb(response.body);
58
61
  }
59
- async stat(filepath) {
62
+ async find(filepath) {
60
63
  let rootPath = join(this.config.root, dirname(filepath));
61
64
  if (rootPath === ".") rootPath = "";
62
65
  const rootFolder = normalizePath(rootPath);
@@ -64,19 +67,19 @@ var DriverSupabase = class {
64
67
  search: basename(filepath),
65
68
  limit: 1
66
69
  });
67
- if (error || data.length === 0) throw new Error("File not found");
70
+ if (error) throw error;
71
+ return data[0];
72
+ }
73
+ async stat(filepath) {
74
+ const file = await this.find(filepath);
75
+ if (!file) throw new Error("File not found");
68
76
  return {
69
- size: data[0]?.metadata["contentLength"] ?? 0,
70
- modified: new Date(data[0]?.metadata["lastModified"] || null)
77
+ size: file.metadata["contentLength"] ?? 0,
78
+ modified: new Date(file.metadata["lastModified"] || null)
71
79
  };
72
80
  }
73
81
  async exists(filepath) {
74
- try {
75
- await this.stat(filepath);
76
- return true;
77
- } catch {
78
- return false;
79
- }
82
+ return await this.find(filepath) !== void 0;
80
83
  }
81
84
  async move(src, dest) {
82
85
  await this.bucket.move(this.fullPath(src), this.fullPath(dest));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/storage-driver-supabase",
3
- "version": "4.0.1",
3
+ "version": "5.0.0",
4
4
  "description": "Supabase file storage abstraction for `@directus/storage`",
5
5
  "homepage": "https://directus.com",
6
6
  "repository": {
@@ -23,10 +23,10 @@
23
23
  "dependencies": {
24
24
  "@supabase/storage-js": "2.81.0",
25
25
  "tus-js-client": "4.3.1",
26
- "undici": "7.28.0",
27
- "@directus/constants": "14.4.0",
28
- "@directus/storage": "13.0.0",
29
- "@directus/utils": "13.5.1"
26
+ "undici": "7.29.0",
27
+ "@directus/constants": "14.4.1",
28
+ "@directus/utils": "13.5.3",
29
+ "@directus/storage": "13.0.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@directus/tsconfig": "4.0.0",
@@ -34,8 +34,8 @@
34
34
  "@vitest/coverage-v8": "3.2.6",
35
35
  "tsdown": "0.15.11",
36
36
  "typescript": "5.9.3",
37
- "vitest": "3.2.6",
38
- "@directus/types": "16.0.0"
37
+ "vitest": "3.2.7",
38
+ "@directus/types": "16.2.0"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsdown src/index.ts --dts",