@data-loom/storage-js 0.2.1-alpha.1
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/LICENSE +201 -0
- package/README.md +163 -0
- package/dist/main/StorageClient.d.ts +18 -0
- package/dist/main/StorageClient.d.ts.map +1 -0
- package/dist/main/StorageClient.js +23 -0
- package/dist/main/StorageClient.js.map +1 -0
- package/dist/main/index.d.ts +4 -0
- package/dist/main/index.d.ts.map +1 -0
- package/dist/main/index.js +22 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/lib/constants.d.ts +4 -0
- package/dist/main/lib/constants.d.ts.map +1 -0
- package/dist/main/lib/constants.js +6 -0
- package/dist/main/lib/constants.js.map +1 -0
- package/dist/main/lib/errors.d.ts +22 -0
- package/dist/main/lib/errors.d.ts.map +1 -0
- package/dist/main/lib/errors.js +45 -0
- package/dist/main/lib/errors.js.map +1 -0
- package/dist/main/lib/fetch.d.ts +16 -0
- package/dist/main/lib/fetch.d.ts.map +1 -0
- package/dist/main/lib/fetch.js +78 -0
- package/dist/main/lib/fetch.js.map +1 -0
- package/dist/main/lib/helpers.d.ts +14 -0
- package/dist/main/lib/helpers.d.ts.map +1 -0
- package/dist/main/lib/helpers.js +104 -0
- package/dist/main/lib/helpers.js.map +1 -0
- package/dist/main/lib/index.d.ts +5 -0
- package/dist/main/lib/index.d.ts.map +1 -0
- package/dist/main/lib/index.js +21 -0
- package/dist/main/lib/index.js.map +1 -0
- package/dist/main/lib/types.d.ts +139 -0
- package/dist/main/lib/types.d.ts.map +1 -0
- package/dist/main/lib/types.js +3 -0
- package/dist/main/lib/types.js.map +1 -0
- package/dist/main/lib/version.d.ts +2 -0
- package/dist/main/lib/version.d.ts.map +1 -0
- package/dist/main/lib/version.js +6 -0
- package/dist/main/lib/version.js.map +1 -0
- package/dist/main/packages/StorageBucketApi.d.ts +118 -0
- package/dist/main/packages/StorageBucketApi.d.ts.map +1 -0
- package/dist/main/packages/StorageBucketApi.js +149 -0
- package/dist/main/packages/StorageBucketApi.js.map +1 -0
- package/dist/main/packages/StorageFileApi.d.ts +243 -0
- package/dist/main/packages/StorageFileApi.d.ts.map +1 -0
- package/dist/main/packages/StorageFileApi.js +456 -0
- package/dist/main/packages/StorageFileApi.js.map +1 -0
- package/dist/module/StorageClient.d.ts +18 -0
- package/dist/module/StorageClient.d.ts.map +1 -0
- package/dist/module/StorageClient.js +16 -0
- package/dist/module/StorageClient.js.map +1 -0
- package/dist/module/index.d.ts +4 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +4 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/lib/constants.d.ts +4 -0
- package/dist/module/lib/constants.d.ts.map +1 -0
- package/dist/module/lib/constants.js +3 -0
- package/dist/module/lib/constants.js.map +1 -0
- package/dist/module/lib/errors.d.ts +22 -0
- package/dist/module/lib/errors.d.ts.map +1 -0
- package/dist/module/lib/errors.js +37 -0
- package/dist/module/lib/errors.js.map +1 -0
- package/dist/module/lib/fetch.d.ts +16 -0
- package/dist/module/lib/fetch.d.ts.map +1 -0
- package/dist/module/lib/fetch.js +70 -0
- package/dist/module/lib/fetch.js.map +1 -0
- package/dist/module/lib/helpers.d.ts +14 -0
- package/dist/module/lib/helpers.d.ts.map +1 -0
- package/dist/module/lib/helpers.js +72 -0
- package/dist/module/lib/helpers.js.map +1 -0
- package/dist/module/lib/index.d.ts +5 -0
- package/dist/module/lib/index.d.ts.map +1 -0
- package/dist/module/lib/index.js +5 -0
- package/dist/module/lib/index.js.map +1 -0
- package/dist/module/lib/types.d.ts +139 -0
- package/dist/module/lib/types.d.ts.map +1 -0
- package/dist/module/lib/types.js +2 -0
- package/dist/module/lib/types.js.map +1 -0
- package/dist/module/lib/version.d.ts +2 -0
- package/dist/module/lib/version.d.ts.map +1 -0
- package/dist/module/lib/version.js +3 -0
- package/dist/module/lib/version.js.map +1 -0
- package/dist/module/packages/StorageBucketApi.d.ts +118 -0
- package/dist/module/packages/StorageBucketApi.d.ts.map +1 -0
- package/dist/module/packages/StorageBucketApi.js +146 -0
- package/dist/module/packages/StorageBucketApi.js.map +1 -0
- package/dist/module/packages/StorageFileApi.d.ts +243 -0
- package/dist/module/packages/StorageFileApi.d.ts.map +1 -0
- package/dist/module/packages/StorageFileApi.js +453 -0
- package/dist/module/packages/StorageFileApi.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("../lib/errors");
|
|
4
|
+
const fetch_1 = require("../lib/fetch");
|
|
5
|
+
const helpers_1 = require("../lib/helpers");
|
|
6
|
+
const DEFAULT_SEARCH_OPTIONS = {
|
|
7
|
+
limit: 100,
|
|
8
|
+
offset: 0,
|
|
9
|
+
sortBy: {
|
|
10
|
+
column: 'name',
|
|
11
|
+
order: 'asc',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const DEFAULT_FILE_OPTIONS = {
|
|
15
|
+
// cacheControl: '3600',
|
|
16
|
+
// contentType: 'text/plain;charset=UTF-8',
|
|
17
|
+
upsert: false,
|
|
18
|
+
};
|
|
19
|
+
class StorageFileApi {
|
|
20
|
+
constructor(url, headers = {}, bucketId, fetch) {
|
|
21
|
+
this.url = url;
|
|
22
|
+
this.headers = headers;
|
|
23
|
+
this.bucketId = bucketId;
|
|
24
|
+
this.fetch = (0, helpers_1.resolveFetch)(fetch);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Uploads a file to an existing bucket or replaces an existing file at the specified path with a new one.
|
|
28
|
+
*
|
|
29
|
+
* @param method HTTP method.
|
|
30
|
+
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
31
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
32
|
+
*/
|
|
33
|
+
async uploadOrUpdate(path, fileBody, fileOptions) {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
try {
|
|
36
|
+
const options = Object.assign(Object.assign({}, DEFAULT_FILE_OPTIONS), fileOptions);
|
|
37
|
+
const headers = Object.assign({}, this.headers);
|
|
38
|
+
// pre-upload
|
|
39
|
+
const preUploadBody = {
|
|
40
|
+
file_size: (0, helpers_1.getUpdateFileSize)(fileBody),
|
|
41
|
+
upsert: (_a = options.upsert) !== null && _a !== void 0 ? _a : false,
|
|
42
|
+
};
|
|
43
|
+
const cleanPath = this._removeEmptyFolders(path);
|
|
44
|
+
const _path = this._getFinalPath(cleanPath);
|
|
45
|
+
const res = await (0, fetch_1.post)(this.fetch, `${this.url}/object/${this.bucketId}/${_path}`, preUploadBody, headers);
|
|
46
|
+
const { upload_id, upload_url } = (_b = res === null || res === void 0 ? void 0 : res.data) !== null && _b !== void 0 ? _b : {};
|
|
47
|
+
if (upload_url && upload_id) {
|
|
48
|
+
const tosHeaders = {};
|
|
49
|
+
if (options.cacheControl) {
|
|
50
|
+
tosHeaders['cache-control'] = `max-age=${options.cacheControl}`;
|
|
51
|
+
}
|
|
52
|
+
if (options.contentType) {
|
|
53
|
+
tosHeaders['content-type'] = options.contentType;
|
|
54
|
+
}
|
|
55
|
+
const tosRes = await (0, fetch_1.put)(this.fetch, upload_url, fileBody, {
|
|
56
|
+
noResolveJson: true,
|
|
57
|
+
}, tosHeaders);
|
|
58
|
+
const etag = (_d = (_c = tosRes === null || tosRes === void 0 ? void 0 : tosRes.headers) === null || _c === void 0 ? void 0 : _c.get('Etag')) !== null && _d !== void 0 ? _d : '';
|
|
59
|
+
const callbackRes = await (0, fetch_1.post)(this.fetch, `${this.url}/object/callback`, {
|
|
60
|
+
upload_id,
|
|
61
|
+
etag,
|
|
62
|
+
});
|
|
63
|
+
if ((0, errors_1.isErrorReturned)(callbackRes)) {
|
|
64
|
+
return {
|
|
65
|
+
data: null,
|
|
66
|
+
error: callbackRes,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
data: callbackRes.data,
|
|
71
|
+
error: null,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return {
|
|
76
|
+
data: null,
|
|
77
|
+
error: new errors_1.StorageError('upload_url or upload_id is empty'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
83
|
+
return { data: null, error };
|
|
84
|
+
}
|
|
85
|
+
return { data: null, error: new errors_1.StorageUnknownError('upload file error', error) };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Uploads a file to an existing bucket.
|
|
90
|
+
*
|
|
91
|
+
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
92
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
93
|
+
*/
|
|
94
|
+
async upload(path, fileBody, fileOptions) {
|
|
95
|
+
return this.uploadOrUpdate(path, fileBody, fileOptions);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Upload a file with a token generated from `createSignedUploadUrl`.
|
|
99
|
+
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
100
|
+
* @param token The token generated from `createSignedUploadUrl`
|
|
101
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
102
|
+
*/
|
|
103
|
+
async uploadToSignedUrl(path, token, fileBody, fileOptions) {
|
|
104
|
+
const cleanPath = this._removeEmptyFolders(path);
|
|
105
|
+
const _path = this._getFinalPath(cleanPath);
|
|
106
|
+
const url = new URL(this.url + `/object/upload/sign/${_path}`);
|
|
107
|
+
url.searchParams.set('token', token);
|
|
108
|
+
try {
|
|
109
|
+
let body;
|
|
110
|
+
const options = Object.assign({ upsert: DEFAULT_FILE_OPTIONS.upsert }, fileOptions);
|
|
111
|
+
const headers = Object.assign({}, this.headers);
|
|
112
|
+
if (typeof Blob !== 'undefined' && fileBody instanceof Blob) {
|
|
113
|
+
body = new FormData();
|
|
114
|
+
body.append('cacheControl', options.cacheControl);
|
|
115
|
+
body.append('', fileBody);
|
|
116
|
+
}
|
|
117
|
+
else if (typeof FormData !== 'undefined' && fileBody instanceof FormData) {
|
|
118
|
+
body = fileBody;
|
|
119
|
+
body.append('cacheControl', options.cacheControl);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
body = fileBody;
|
|
123
|
+
headers['cache-control'] = `max-age=${options.cacheControl}`;
|
|
124
|
+
headers['content-type'] = options.contentType;
|
|
125
|
+
}
|
|
126
|
+
const data = await (0, fetch_1.put)(this.fetch, url.toString(), body, { headers });
|
|
127
|
+
return {
|
|
128
|
+
data: { path: cleanPath, fullPath: data.Key },
|
|
129
|
+
error: null,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
134
|
+
return { data: null, error };
|
|
135
|
+
}
|
|
136
|
+
return { data: null, error: new errors_1.StorageUnknownError('upload file error', error) };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Creates a signed upload URL.
|
|
141
|
+
* Signed upload URLs can be used to upload files to the bucket without further authentication.
|
|
142
|
+
* They are valid for 2 hours.
|
|
143
|
+
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
144
|
+
* @param options.upsert If set to true, allows the file to be overwritten if it already exists.
|
|
145
|
+
*/
|
|
146
|
+
async createSignedUploadUrl(path, options) {
|
|
147
|
+
try {
|
|
148
|
+
let _path = this._getFinalPath(path);
|
|
149
|
+
const headers = Object.assign({}, this.headers);
|
|
150
|
+
// if (options?.upsert) {
|
|
151
|
+
// headers['x-upsert'] = 'true';
|
|
152
|
+
// }
|
|
153
|
+
const data = await (0, fetch_1.post)(this.fetch, `${this.url}/object/upload/sign/${_path}`, {}, { headers });
|
|
154
|
+
const url = new URL(this.url + data.url);
|
|
155
|
+
const token = url.searchParams.get('token');
|
|
156
|
+
if (!token) {
|
|
157
|
+
throw new errors_1.StorageError('No token returned by API');
|
|
158
|
+
}
|
|
159
|
+
return { data: { signedUrl: url.toString(), path, token }, error: null };
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
163
|
+
return { data: null, error };
|
|
164
|
+
}
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Replaces an existing file at the specified path with a new one.
|
|
170
|
+
*
|
|
171
|
+
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
|
|
172
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
173
|
+
*/
|
|
174
|
+
async update(path, fileBody, fileOptions) {
|
|
175
|
+
return this.uploadOrUpdate(path, fileBody, fileOptions);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Moves an existing file to a new path in the same bucket.
|
|
179
|
+
*
|
|
180
|
+
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
181
|
+
* @param toPath The new file path, including the new file name. For example `folder/image-new.png`.
|
|
182
|
+
* @param options The destination options.
|
|
183
|
+
*/
|
|
184
|
+
async move(fromPath, toPath, options) {
|
|
185
|
+
try {
|
|
186
|
+
const data = await (0, fetch_1.post)(this.fetch, `${this.url}/object/move`, {
|
|
187
|
+
bucketId: this.bucketId,
|
|
188
|
+
sourceKey: fromPath,
|
|
189
|
+
destinationKey: toPath,
|
|
190
|
+
destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket,
|
|
191
|
+
}, { headers: this.headers });
|
|
192
|
+
return { data, error: null };
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
196
|
+
return { data: null, error };
|
|
197
|
+
}
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Copies an existing file to a new path in the same bucket.
|
|
203
|
+
*
|
|
204
|
+
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
205
|
+
* @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
206
|
+
* @param options The destination options.
|
|
207
|
+
*/
|
|
208
|
+
async copy(fromPath, toPath, options) {
|
|
209
|
+
try {
|
|
210
|
+
const data = await (0, fetch_1.post)(this.fetch, `${this.url}/object/copy`, {
|
|
211
|
+
bucketId: this.bucketId,
|
|
212
|
+
sourceKey: fromPath,
|
|
213
|
+
destinationKey: toPath,
|
|
214
|
+
destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket,
|
|
215
|
+
}, { headers: this.headers });
|
|
216
|
+
return { data: { path: data.Key }, error: null };
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
220
|
+
return { data: null, error };
|
|
221
|
+
}
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
|
|
227
|
+
*
|
|
228
|
+
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
229
|
+
* @param expiresIn The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
|
|
230
|
+
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
231
|
+
* @param options.transform Transform the asset before serving it to the client.
|
|
232
|
+
*/
|
|
233
|
+
async createSignedUrl(path, expiresIn) {
|
|
234
|
+
try {
|
|
235
|
+
let _path = this._getFinalPath(path);
|
|
236
|
+
const res = await (0, fetch_1.post)(this.fetch, `${this.url}/object/sign/${_path}`, { expires_in: expiresIn }, { headers: this.headers });
|
|
237
|
+
if ((0, errors_1.isErrorReturned)(res)) {
|
|
238
|
+
return {
|
|
239
|
+
data: null,
|
|
240
|
+
error: res,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return { data: res.data, error: null };
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
247
|
+
return { data: null, error };
|
|
248
|
+
}
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
|
|
254
|
+
*
|
|
255
|
+
* @param paths The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.
|
|
256
|
+
* @param expiresIn The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.
|
|
257
|
+
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
258
|
+
*/
|
|
259
|
+
async createSignedUrls(paths, expiresIn) {
|
|
260
|
+
try {
|
|
261
|
+
const res = await (0, fetch_1.post)(this.fetch, `${this.url}/object/sign/${this.bucketId}`, { expires_in: expiresIn, paths }, { headers: this.headers });
|
|
262
|
+
if ((0, errors_1.isErrorReturned)(res)) {
|
|
263
|
+
return {
|
|
264
|
+
data: null,
|
|
265
|
+
error: res,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
data: res.data,
|
|
270
|
+
error: null,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
275
|
+
return { data: null, error };
|
|
276
|
+
}
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
|
|
282
|
+
*
|
|
283
|
+
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
284
|
+
* @param options.transform Transform the asset before serving it to the client.
|
|
285
|
+
*/
|
|
286
|
+
async download(path) {
|
|
287
|
+
try {
|
|
288
|
+
const _path = this._getFinalPath(path);
|
|
289
|
+
const res = await (0, fetch_1.get)(this.fetch, `${this.url}/object/${_path}`, {
|
|
290
|
+
headers: this.headers,
|
|
291
|
+
noResolveJson: true,
|
|
292
|
+
});
|
|
293
|
+
let resBody;
|
|
294
|
+
// only parse blob when response is from TOS, server returns 200 with errors if it can't redirect to TOS.
|
|
295
|
+
if (res.redirected && res.headers.get('server') === 'TosServer') {
|
|
296
|
+
resBody = await res.blob();
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
resBody = await res.json();
|
|
300
|
+
return { data: null, error: resBody };
|
|
301
|
+
}
|
|
302
|
+
return { data: resBody, error: null };
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
306
|
+
return { data: null, error };
|
|
307
|
+
}
|
|
308
|
+
return { data: null, error: new errors_1.StorageUnknownError('download file error', error) };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Retrieves the details of an existing file.
|
|
313
|
+
* @param path
|
|
314
|
+
*/
|
|
315
|
+
async info(path) {
|
|
316
|
+
const _path = this._getFinalPath(path);
|
|
317
|
+
try {
|
|
318
|
+
const data = await (0, fetch_1.get)(this.fetch, `${this.url}/object/info/${_path}`, {
|
|
319
|
+
headers: this.headers,
|
|
320
|
+
});
|
|
321
|
+
return { data: (0, helpers_1.recursiveToCamel)(data), error: null };
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
325
|
+
return { data: null, error };
|
|
326
|
+
}
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Checks the existence of a file.
|
|
332
|
+
* @param path
|
|
333
|
+
*/
|
|
334
|
+
async exists(path) {
|
|
335
|
+
const _path = this._getFinalPath(path);
|
|
336
|
+
try {
|
|
337
|
+
await (0, fetch_1.head)(this.fetch, `${this.url}/object/${_path}`, {
|
|
338
|
+
headers: this.headers,
|
|
339
|
+
});
|
|
340
|
+
return { data: true, error: null };
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
if ((0, errors_1.isStorageError)(error) && error instanceof errors_1.StorageUnknownError) {
|
|
344
|
+
const originalError = error.originalError;
|
|
345
|
+
if ([400, 404].includes(originalError === null || originalError === void 0 ? void 0 : originalError.status)) {
|
|
346
|
+
return { data: false, error };
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.
|
|
354
|
+
* This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
|
|
355
|
+
*
|
|
356
|
+
* @param path The path and name of the file to generate the public URL for. For example `folder/image.png`.
|
|
357
|
+
* @param options.download Triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
358
|
+
* @param options.transform Transform the asset before serving it to the client.
|
|
359
|
+
*/
|
|
360
|
+
getPublicUrl(path, options) {
|
|
361
|
+
const _path = this._getFinalPath(path);
|
|
362
|
+
const _queryString = [];
|
|
363
|
+
const downloadQueryParam = (options === null || options === void 0 ? void 0 : options.download)
|
|
364
|
+
? `download=${options.download === true ? '' : options.download}`
|
|
365
|
+
: '';
|
|
366
|
+
if (downloadQueryParam !== '') {
|
|
367
|
+
_queryString.push(downloadQueryParam);
|
|
368
|
+
}
|
|
369
|
+
const wantsTransformation = typeof (options === null || options === void 0 ? void 0 : options.transform) !== 'undefined';
|
|
370
|
+
const renderPath = wantsTransformation ? 'render/image' : 'object';
|
|
371
|
+
const transformationQuery = this.transformOptsToQueryString((options === null || options === void 0 ? void 0 : options.transform) || {});
|
|
372
|
+
if (transformationQuery !== '') {
|
|
373
|
+
_queryString.push(transformationQuery);
|
|
374
|
+
}
|
|
375
|
+
let queryString = _queryString.join('&');
|
|
376
|
+
if (queryString !== '') {
|
|
377
|
+
queryString = `?${queryString}`;
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
data: { publicUrl: encodeURI(`${this.url}/${renderPath}/public/${_path}${queryString}`) },
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Deletes files within the same bucket
|
|
385
|
+
*
|
|
386
|
+
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
387
|
+
*/
|
|
388
|
+
async remove(paths) {
|
|
389
|
+
try {
|
|
390
|
+
const res = await (0, fetch_1.remove)(this.fetch, `${this.url}/object/${this.bucketId}`, { prefixes: paths }, { headers: this.headers });
|
|
391
|
+
return { data: res.data, error: null };
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
395
|
+
return { data: null, error };
|
|
396
|
+
}
|
|
397
|
+
return { data: null, error: new errors_1.StorageUnknownError('remove file error', error) };
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Lists all the files within a bucket.
|
|
402
|
+
* @param path The folder path.
|
|
403
|
+
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
404
|
+
*/
|
|
405
|
+
async list(path, options) {
|
|
406
|
+
try {
|
|
407
|
+
const body = Object.assign(Object.assign(Object.assign({}, DEFAULT_SEARCH_OPTIONS), options), { prefix: path || '' });
|
|
408
|
+
const res = await (0, fetch_1.post)(this.fetch, `${this.url}/object/list/${this.bucketId}`, body, {
|
|
409
|
+
headers: this.headers,
|
|
410
|
+
});
|
|
411
|
+
return { data: res.data, error: null };
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
if ((0, errors_1.isStorageError)(error)) {
|
|
415
|
+
return { data: null, error };
|
|
416
|
+
}
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
encodeMetadata(metadata) {
|
|
421
|
+
return JSON.stringify(metadata);
|
|
422
|
+
}
|
|
423
|
+
toBase64(data) {
|
|
424
|
+
if (typeof Buffer !== 'undefined') {
|
|
425
|
+
return Buffer.from(data).toString('base64');
|
|
426
|
+
}
|
|
427
|
+
return btoa(data);
|
|
428
|
+
}
|
|
429
|
+
_getFinalPath(path) {
|
|
430
|
+
return `${this.bucketId}/${path.replace(/^\/+/, '')}`;
|
|
431
|
+
}
|
|
432
|
+
_removeEmptyFolders(path) {
|
|
433
|
+
return path.replace(/^\/|\/$/g, '').replace(/\/+/g, '/');
|
|
434
|
+
}
|
|
435
|
+
transformOptsToQueryString(transform) {
|
|
436
|
+
const params = [];
|
|
437
|
+
if (transform.width) {
|
|
438
|
+
params.push(`width=${transform.width}`);
|
|
439
|
+
}
|
|
440
|
+
if (transform.height) {
|
|
441
|
+
params.push(`height=${transform.height}`);
|
|
442
|
+
}
|
|
443
|
+
if (transform.resize) {
|
|
444
|
+
params.push(`resize=${transform.resize}`);
|
|
445
|
+
}
|
|
446
|
+
if (transform.format) {
|
|
447
|
+
params.push(`format=${transform.format}`);
|
|
448
|
+
}
|
|
449
|
+
if (transform.quality) {
|
|
450
|
+
params.push(`quality=${transform.quality}`);
|
|
451
|
+
}
|
|
452
|
+
return params.join('&');
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
exports.default = StorageFileApi;
|
|
456
|
+
//# sourceMappingURL=StorageFileApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageFileApi.js","sourceRoot":"","sources":["../../../src/packages/StorageFileApi.ts"],"names":[],"mappings":";;AAAA,0CAAmG;AACnG,wCAAmE;AACnE,4CAAmF;AAanF,MAAM,sBAAsB,GAAG;IAC7B,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE;QACN,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,KAAK;KACb;CACF,CAAC;AAE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;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAEO,aAAa,CAAC,IAAY;QAChC,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;IACxD,CAAC;IAEO,mBAAmB,CAAC,IAAY;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;IAEO,0BAA0B,CAAC,SAA2B;QAC5D,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,SAAS,CAAC,KAAK,EAAE;YACnB,MAAM,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;SACzC;QAED,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,MAAM,CAAC,IAAI,CAAC,UAAU,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;SAC3C;QAED,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,MAAM,CAAC,IAAI,CAAC,UAAU,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;SAC3C;QAED,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,MAAM,CAAC,IAAI,CAAC,UAAU,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;SAC3C;QAED,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,MAAM,CAAC,IAAI,CAAC,WAAW,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;SAC7C;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AA1sBD,iCA0sBC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import StorageFileApi from './packages/StorageFileApi';
|
|
2
|
+
import StorageBucketApi from './packages/StorageBucketApi';
|
|
3
|
+
import { Fetch } from './lib/fetch';
|
|
4
|
+
export interface StorageClientOptions {
|
|
5
|
+
useNewHostname?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class StorageClient extends StorageBucketApi {
|
|
8
|
+
constructor(url: string, headers?: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
}, fetch?: Fetch, opts?: StorageClientOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Perform file operation in a bucket.
|
|
13
|
+
*
|
|
14
|
+
* @param id The bucket id to operate on.
|
|
15
|
+
*/
|
|
16
|
+
from(id: string): StorageFileApi;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=StorageClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageClient.d.ts","sourceRoot":"","sources":["../../src/StorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,qBAAa,aAAc,SAAQ,gBAAgB;gBAE/C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EACvC,KAAK,CAAC,EAAE,KAAK,EACb,IAAI,CAAC,EAAE,oBAAoB;IAK7B;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc;CAGjC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import StorageFileApi from './packages/StorageFileApi';
|
|
2
|
+
import StorageBucketApi from './packages/StorageBucketApi';
|
|
3
|
+
export class StorageClient extends StorageBucketApi {
|
|
4
|
+
constructor(url, headers = {}, fetch, opts) {
|
|
5
|
+
super(url, headers, fetch, opts);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Perform file operation in a bucket.
|
|
9
|
+
*
|
|
10
|
+
* @param id The bucket id to operate on.
|
|
11
|
+
*/
|
|
12
|
+
from(id) {
|
|
13
|
+
return new StorageFileApi(this.url, this.headers, id, this.fetch);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=StorageClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageClient.js","sourceRoot":"","sources":["../../src/StorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAO3D,MAAM,OAAO,aAAc,SAAQ,gBAAgB;IACjD,YACE,GAAW,EACX,UAAqC,EAAE,EACvC,KAAa,EACb,IAA2B;QAE3B,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,EAAU;QACb,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe;;CAA+C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,eAAe,EAAE,cAAc,OAAO,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class StorageError extends Error {
|
|
2
|
+
protected __isStorageError: boolean;
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function isStorageError(error: unknown): error is StorageError;
|
|
6
|
+
export declare class StorageApiError extends StorageError {
|
|
7
|
+
status: number;
|
|
8
|
+
statusCode: string;
|
|
9
|
+
constructor(message: string, status: number, statusCode: string);
|
|
10
|
+
toJSON(): {
|
|
11
|
+
name: string;
|
|
12
|
+
message: string;
|
|
13
|
+
status: number;
|
|
14
|
+
statusCode: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare class StorageUnknownError extends StorageError {
|
|
18
|
+
originalError: unknown;
|
|
19
|
+
constructor(message: string, originalError: unknown);
|
|
20
|
+
}
|
|
21
|
+
export declare const isErrorReturned: (res: any) => any;
|
|
22
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAS,CAAC,gBAAgB,UAAQ;gBAEtB,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAO/D,MAAM;;;;;;CAQP;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,aAAa,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO;CAKpD;AAED,eAAO,MAAM,eAAe,QAAS,GAAG,QAEvC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class StorageError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.__isStorageError = true;
|
|
5
|
+
this.name = 'StorageError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function isStorageError(error) {
|
|
9
|
+
return typeof error === 'object' && error !== null && '__isStorageError' in error;
|
|
10
|
+
}
|
|
11
|
+
export class StorageApiError extends StorageError {
|
|
12
|
+
constructor(message, status, statusCode) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'StorageApiError';
|
|
15
|
+
this.status = status;
|
|
16
|
+
this.statusCode = statusCode;
|
|
17
|
+
}
|
|
18
|
+
toJSON() {
|
|
19
|
+
return {
|
|
20
|
+
name: this.name,
|
|
21
|
+
message: this.message,
|
|
22
|
+
status: this.status,
|
|
23
|
+
statusCode: this.statusCode,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class StorageUnknownError extends StorageError {
|
|
28
|
+
constructor(message, originalError) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = 'StorageUnknownError';
|
|
31
|
+
this.originalError = originalError;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export const isErrorReturned = (res) => {
|
|
35
|
+
return res.error_msg;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings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|
+
headers?: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
duplex?: string;
|
|
8
|
+
noResolveJson?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD';
|
|
11
|
+
export declare function get(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters): Promise<any>;
|
|
12
|
+
export declare function post(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>;
|
|
13
|
+
export declare function put(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>;
|
|
14
|
+
export declare function head(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters): Promise<any>;
|
|
15
|
+
export declare function remove(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>;
|
|
16
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC;AAEjC,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AA4E3E,wBAAsB,GAAG,CACvB,OAAO,EAAE,KAAK,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,EACtB,UAAU,CAAC,EAAE,eAAe,GAC3B,OAAO,CAAC,GAAG,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