@quatrain/storage-supabase 1.1.30 → 1.2.2
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,5 +1,5 @@
|
|
|
1
1
|
import { AbstractStorageAdapter, FileType, FileResponseLinkType, StorageParameters, DownloadFileMetaType } from '@quatrain/storage';
|
|
2
|
-
import { Readable, Stream } from 'stream';
|
|
2
|
+
import { Readable, Stream } from 'node:stream';
|
|
3
3
|
import { StorageClient } from '@supabase/storage-js';
|
|
4
4
|
export declare class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
5
5
|
protected _client: StorageClient;
|
|
@@ -12,7 +12,7 @@ export declare class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
12
12
|
create(file: FileType, stream: Readable | string): Promise<FileType>;
|
|
13
13
|
copy(file: FileType, destFile: FileType): Promise<void>;
|
|
14
14
|
move(file: FileType, destFile: FileType): Promise<FileType>;
|
|
15
|
-
|
|
15
|
+
_getUrl(file: FileType, expiresIn?: number, action?: any, extra?: any): Promise<{
|
|
16
16
|
url: string;
|
|
17
17
|
expiresIn: number;
|
|
18
18
|
}>;
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SupabaseStorageAdapter = void 0;
|
|
16
16
|
const storage_1 = require("@quatrain/storage");
|
|
17
|
-
const
|
|
17
|
+
const node_stream_1 = require("node:stream");
|
|
18
18
|
const storage_js_1 = require("@supabase/storage-js");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const node_os_1 = require("node:os");
|
|
20
|
+
const node_path_1 = require("node:path");
|
|
21
21
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
22
22
|
class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
23
23
|
constructor(params) {
|
|
@@ -132,7 +132,7 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
132
132
|
return destFile;
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
_getUrl(file_1) {
|
|
136
136
|
return __awaiter(this, arguments, void 0, function* (file, expiresIn = 3600, action = 'read', extra = {}) {
|
|
137
137
|
storage_1.Storage.debug(`Getting signed url for file ${file.ref} in bucket ${file.bucket}`);
|
|
138
138
|
const cacheControl = extra.cacheControl || (this._params.config.publicCacheDuration ? `${this._params.config.publicCacheDuration}` : undefined);
|
|
@@ -162,10 +162,10 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
162
162
|
getReadable(file) {
|
|
163
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
164
|
storage_1.Storage.debug(`GET Readable : ${file.ref}`);
|
|
165
|
-
const path = (0,
|
|
165
|
+
const path = (0, node_path_1.join)((0, node_os_1.tmpdir)(), String(Date.now()));
|
|
166
166
|
const item = yield this.download(file, { path, onlyContent: true });
|
|
167
167
|
const buffer = Buffer.from(item.toString(), 'base64');
|
|
168
|
-
const readable = new
|
|
168
|
+
const readable = new node_stream_1.Readable();
|
|
169
169
|
readable.push(buffer);
|
|
170
170
|
readable.push(null);
|
|
171
171
|
return readable;
|
|
@@ -174,10 +174,10 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
174
174
|
stream(file, res) {
|
|
175
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
176
|
storage_1.Storage.debug(`GET Stream : ${file.ref}`);
|
|
177
|
-
const path = (0,
|
|
177
|
+
const path = (0, node_path_1.join)((0, node_os_1.tmpdir)(), String(Date.now()));
|
|
178
178
|
const item = yield this.download(file, { path, onlyContent: true });
|
|
179
179
|
const buffer = Buffer.from(item.toString(), 'base64');
|
|
180
|
-
const readable = new
|
|
180
|
+
const readable = new node_stream_1.Readable();
|
|
181
181
|
readable.push(buffer);
|
|
182
182
|
readable.push(null);
|
|
183
183
|
return readable.pipe(res);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/storage-supabase",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Storage adapter for Supabase Storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"typescript": "^5.1.5"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@quatrain/core": "^1.
|
|
35
|
-
"@quatrain/storage": "^1.
|
|
34
|
+
"@quatrain/core": "^1.2.5",
|
|
35
|
+
"@quatrain/storage": "^1.2.2",
|
|
36
36
|
"@supabase/storage-js": "^2.7.2",
|
|
37
37
|
"@supabase/supabase-js": "^2.87.3"
|
|
38
38
|
},
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
StorageParameters,
|
|
7
7
|
DownloadFileMetaType,
|
|
8
8
|
} from '@quatrain/storage'
|
|
9
|
-
import { Readable, Stream } from 'stream'
|
|
9
|
+
import { Readable, Stream } from 'node:stream'
|
|
10
10
|
import { StorageClient } from '@supabase/storage-js'
|
|
11
|
-
import { tmpdir } from 'os'
|
|
12
|
-
import { join } from 'path'
|
|
11
|
+
import { tmpdir } from 'node:os'
|
|
12
|
+
import { join } from 'node:path'
|
|
13
13
|
import fs from 'node:fs'
|
|
14
14
|
|
|
15
15
|
export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
@@ -138,7 +138,7 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
138
138
|
return destFile
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
async
|
|
141
|
+
async _getUrl(file: FileType, expiresIn = 3600, action: any = 'read', extra: any = {}) {
|
|
142
142
|
Storage.debug(
|
|
143
143
|
`Getting signed url for file ${file.ref} in bucket ${file.bucket}`
|
|
144
144
|
)
|