@storecraft/storage-s3-compatible 1.0.10 → 1.0.11
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/adapter.js +19 -21
- package/aws4fetch.js +1 -1
- package/package.json +1 -1
package/adapter.js
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* @import { AwsS3Config, Config, R2Config } from './types.public.js'
|
3
|
+
* @import { storage_driver, StorageFeatures } from '@storecraft/core/storage'
|
4
|
+
*/
|
1
5
|
import { App } from '@storecraft/core'
|
2
6
|
import { AwsClient } from './aws4fetch.js';
|
3
7
|
|
@@ -24,16 +28,10 @@ const infer_content_type = (name) => {
|
|
24
28
|
}
|
25
29
|
|
26
30
|
|
27
|
-
/**
|
28
|
-
* @typedef {import('./types.public.d.ts').Config} Config
|
29
|
-
*/
|
30
|
-
|
31
31
|
/**
|
32
32
|
* @description The base S3 compatible class
|
33
33
|
*
|
34
|
-
* @
|
35
|
-
*
|
36
|
-
* @implements {storage}
|
34
|
+
* @implements {storage_driver}
|
37
35
|
*/
|
38
36
|
export class S3CompatibleStorage {
|
39
37
|
|
@@ -75,7 +73,7 @@ export class S3CompatibleStorage {
|
|
75
73
|
get config() { return this.#_config; }
|
76
74
|
|
77
75
|
features() {
|
78
|
-
/** @type {
|
76
|
+
/** @type {StorageFeatures} */
|
79
77
|
const f = {
|
80
78
|
supports_signed_urls: true
|
81
79
|
}
|
@@ -85,7 +83,7 @@ export class S3CompatibleStorage {
|
|
85
83
|
|
86
84
|
/**
|
87
85
|
*
|
88
|
-
* @type {
|
86
|
+
* @type {storage_driver["init"]}
|
89
87
|
*/
|
90
88
|
async init(app) { return this; }
|
91
89
|
|
@@ -118,7 +116,7 @@ export class S3CompatibleStorage {
|
|
118
116
|
|
119
117
|
/**
|
120
118
|
*
|
121
|
-
* @type {
|
119
|
+
* @type {storage_driver["putBlob"]}
|
122
120
|
*/
|
123
121
|
async putBlob(key, blob) {
|
124
122
|
return this.#put_internal(key, blob);
|
@@ -126,7 +124,7 @@ export class S3CompatibleStorage {
|
|
126
124
|
|
127
125
|
/**
|
128
126
|
*
|
129
|
-
* @type {
|
127
|
+
* @type {storage_driver["putArraybuffer"]}
|
130
128
|
*/
|
131
129
|
async putArraybuffer(key, buffer) {
|
132
130
|
return this.#put_internal(key, buffer);
|
@@ -134,7 +132,7 @@ export class S3CompatibleStorage {
|
|
134
132
|
|
135
133
|
/**
|
136
134
|
*
|
137
|
-
* @type {
|
135
|
+
* @type {storage_driver["putStream"]}
|
138
136
|
*/
|
139
137
|
async putStream(key, stream, meta={}, bytesLength=0) {
|
140
138
|
const extra_headers = {};
|
@@ -150,7 +148,7 @@ export class S3CompatibleStorage {
|
|
150
148
|
|
151
149
|
/**
|
152
150
|
*
|
153
|
-
* @type {
|
151
|
+
* @type {storage_driver["putSigned"]}
|
154
152
|
*/
|
155
153
|
async putSigned(key) {
|
156
154
|
const url = new URL(this.get_file_url(key));
|
@@ -183,7 +181,7 @@ export class S3CompatibleStorage {
|
|
183
181
|
}
|
184
182
|
|
185
183
|
/**
|
186
|
-
* @type {
|
184
|
+
* @type {storage_driver["getArraybuffer"]}
|
187
185
|
*/
|
188
186
|
async getArraybuffer(key) {
|
189
187
|
const r = await this.#get_request(key);
|
@@ -199,7 +197,7 @@ export class S3CompatibleStorage {
|
|
199
197
|
|
200
198
|
/**
|
201
199
|
*
|
202
|
-
* @type {
|
200
|
+
* @type {storage_driver["getBlob"]}
|
203
201
|
*/
|
204
202
|
async getBlob(key) {
|
205
203
|
const r = await this.#get_request(key);
|
@@ -214,7 +212,7 @@ export class S3CompatibleStorage {
|
|
214
212
|
}
|
215
213
|
|
216
214
|
/**
|
217
|
-
* @type {
|
215
|
+
* @type {storage_driver["getStream"]}
|
218
216
|
*/
|
219
217
|
async getStream(key) {
|
220
218
|
const r = await this.#get_request(key);
|
@@ -231,7 +229,7 @@ export class S3CompatibleStorage {
|
|
231
229
|
|
232
230
|
/**
|
233
231
|
*
|
234
|
-
* @type {
|
232
|
+
* @type {storage_driver["getSigned"]}
|
235
233
|
*/
|
236
234
|
async getSigned(key) {
|
237
235
|
const url = new URL(this.get_file_url(key));
|
@@ -256,7 +254,7 @@ export class S3CompatibleStorage {
|
|
256
254
|
|
257
255
|
/**
|
258
256
|
*
|
259
|
-
* @type {
|
257
|
+
* @type {storage_driver["remove"]}
|
260
258
|
*/
|
261
259
|
async remove(key) {
|
262
260
|
const r = await this.client.fetch(
|
@@ -272,7 +270,7 @@ export class S3CompatibleStorage {
|
|
272
270
|
export class R2 extends S3CompatibleStorage {
|
273
271
|
|
274
272
|
/**
|
275
|
-
* @param {
|
273
|
+
* @param {R2Config} config
|
276
274
|
*/
|
277
275
|
constructor({bucket, account_id, accessKeyId, secretAccessKey}) {
|
278
276
|
super(
|
@@ -292,7 +290,7 @@ export class R2 extends S3CompatibleStorage {
|
|
292
290
|
export class S3 extends S3CompatibleStorage {
|
293
291
|
|
294
292
|
/**
|
295
|
-
* @param {
|
293
|
+
* @param {AwsS3Config} config
|
296
294
|
*/
|
297
295
|
constructor({bucket, region, accessKeyId, secretAccessKey, forcePathStyle=false}) {
|
298
296
|
super(
|
@@ -312,7 +310,7 @@ export class S3 extends S3CompatibleStorage {
|
|
312
310
|
export class DigitalOceanSpaces extends S3CompatibleStorage {
|
313
311
|
|
314
312
|
/**
|
315
|
-
* @param {Omit<
|
313
|
+
* @param {Omit<Config, 'endpoint' | 'forcePathStyle'>} config
|
316
314
|
*/
|
317
315
|
constructor({bucket, region, accessKeyId, secretAccessKey}) {
|
318
316
|
super(
|
package/aws4fetch.js
CHANGED
package/package.json
CHANGED