@tweedegolf/sab-adapter-backblaze-b2 1.0.7 → 3.0.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/README.md +6 -6
- package/changelog.md +12 -0
- package/dist/AbstractAdapter.d.ts +33 -105
- package/dist/AbstractAdapter.js +344 -214
- package/dist/AbstractAdapter.js.map +1 -1
- package/dist/AdapterBackblazeB2.d.ts +10 -13
- package/dist/AdapterBackblazeB2.js +462 -406
- package/dist/AdapterBackblazeB2.js.map +1 -1
- package/dist/types/backblaze-b2.d.ts +182 -0
- package/dist/types/general.d.ts +46 -102
- package/dist/types/general.js +20 -18
- package/dist/types/general.js.map +1 -1
- package/dist/types/result.d.ts +15 -9
- package/dist/util.d.ts +2 -1
- package/dist/util.js +31 -22
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ It is also possible to access all the specific functionality of the cloud servic
|
|
|
11
11
|
If you are new to the Storage Abstraction library you may want to read [this](https://github.com/tweedegolf/storage-abstraction/blob/master/README.md#how-it-works) first.
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Storage,
|
|
14
|
+
import { Storage, Provider } from "@tweedegolf/storage-abstraction";
|
|
15
15
|
|
|
16
16
|
const configuration = {
|
|
17
|
-
type:
|
|
17
|
+
type: Provider.B2,
|
|
18
18
|
applicationKey: "key",
|
|
19
19
|
applicationKeyId: "keyId",
|
|
20
20
|
};
|
|
@@ -28,13 +28,13 @@ console.log(result);
|
|
|
28
28
|
|
|
29
29
|
The Storage class is cloud service agnostic and doesn't know anything about the adapter it uses and adapters are completely interchangeable. It only expects the adapter to have implemented all methods of the `IAdapter` interface, see the [API](https://github.com/tweedegolf/storage-abstraction/blob/master/README.md#adapter-api).
|
|
30
30
|
|
|
31
|
-
When you create a Storage instance it checks the mandatory `
|
|
31
|
+
When you create a Storage instance it checks the mandatory `provider` key in the configuration object and then loads the appropriate adapter module automatically from your node_modules folder using `require()`. For more information please read [this](https://github.com/tweedegolf/storage-abstraction/blob/master/README.md#register-your-adapter).
|
|
32
32
|
|
|
33
33
|
## Configuration
|
|
34
34
|
|
|
35
35
|
The configuration object that you pass to the Storage constructor is forwarded to the constructor of the adapter.
|
|
36
36
|
|
|
37
|
-
The Storage constructor is only interested in the `
|
|
37
|
+
The Storage constructor is only interested in the `provider` key of the configuration object, all other keys are necessary for configuring the adapter.
|
|
38
38
|
|
|
39
39
|
The Storage constructor expects the configuration to be of type `StorageAdapterConfig`.
|
|
40
40
|
|
|
@@ -66,13 +66,13 @@ Examples with configuration object:
|
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
68
|
const s = new Storage({
|
|
69
|
-
type:
|
|
69
|
+
type: Provider.B2,
|
|
70
70
|
applicationKeyId: "your-key-id",
|
|
71
71
|
applicationKey: "your-key",
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
const s = new Storage({
|
|
75
|
-
type:
|
|
75
|
+
type: Provider.B2,
|
|
76
76
|
applicationKeyId: "your-key-id",
|
|
77
77
|
applicationKey: "your-key",
|
|
78
78
|
bucketName: "the-buck",
|
package/changelog.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# 3.0.1
|
|
2
|
+
- added option `checkIfBucketExists` to the `addFile`, `addFileFromPath`, `addFileFromBuffer` and `addFileFromStream`
|
|
3
|
+
|
|
4
|
+
# 3.0.0
|
|
5
|
+
- version bump to match the version of Storage and the API
|
|
6
|
+
- removed support for versioning (wasn't implemented consistently anyway)
|
|
7
|
+
- removed `getFileAsURL`
|
|
8
|
+
- removed option `{allVersions: boolean}` for `removeFile`
|
|
9
|
+
- `removeFile` does not fail if the file doesn't exist
|
|
10
|
+
- `deleteBucket` does not fail if the bucket doesn't exist
|
|
11
|
+
- see also the [migration guide](https://github.com/tweedegolf/storage-abstraction/blob/master/migration_to_api3.0.md)
|
|
12
|
+
|
|
1
13
|
# 1.0.7
|
|
2
14
|
- include @deprecated functions
|
|
3
15
|
|
|
@@ -1,45 +1,30 @@
|
|
|
1
|
-
import { AdapterConfig, IAdapter, Options, StreamOptions } from "./types/general";
|
|
1
|
+
import { AdapterConfig, IAdapter, Options, Provider, StreamOptions } from "./types/general";
|
|
2
2
|
import { FileBufferParams, FilePathParams, FileStreamParams } from "./types/add_file_params";
|
|
3
|
-
import { ResultObject, ResultObjectBoolean, ResultObjectBuckets, ResultObjectFiles, ResultObjectNumber, ResultObjectStream } from "./types/result";
|
|
3
|
+
import { ResultObject, ResultObjectBoolean, ResultObjectBuckets, ResultObjectFiles, ResultObjectNumber, ResultObjectObject, ResultObjectStream } from "./types/result";
|
|
4
4
|
export declare abstract class AbstractAdapter implements IAdapter {
|
|
5
|
-
protected
|
|
6
|
-
protected _config: AdapterConfig
|
|
7
|
-
protected _configError: string | null;
|
|
8
|
-
protected _bucketName: string;
|
|
5
|
+
protected _provider: Provider;
|
|
6
|
+
protected _config: AdapterConfig;
|
|
9
7
|
protected _client: any;
|
|
8
|
+
protected _configError: null | string;
|
|
9
|
+
protected _bucketName: null | string;
|
|
10
10
|
constructor(config: string | AdapterConfig);
|
|
11
|
-
get
|
|
12
|
-
|
|
11
|
+
get provider(): Provider;
|
|
12
|
+
getProvider(): Provider;
|
|
13
13
|
get config(): AdapterConfig;
|
|
14
14
|
getConfig(): AdapterConfig;
|
|
15
|
-
get configError(): string;
|
|
16
|
-
getConfigError(): string;
|
|
15
|
+
get configError(): null | string;
|
|
16
|
+
getConfigError(): null | string;
|
|
17
17
|
get serviceClient(): any;
|
|
18
18
|
getServiceClient(): any;
|
|
19
|
-
setSelectedBucket(bucketName:
|
|
20
|
-
getSelectedBucket():
|
|
21
|
-
set selectedBucket(bucketName:
|
|
22
|
-
get selectedBucket():
|
|
23
|
-
set bucketName(bucketName:
|
|
24
|
-
get bucketName():
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
protected _getFileAndBucketAndOptions(...args: [
|
|
29
|
-
bucketName: string,
|
|
30
|
-
fileName: string,
|
|
31
|
-
options?: boolean | Options | StreamOptions
|
|
32
|
-
] | [
|
|
33
|
-
fileName: string,
|
|
34
|
-
options?: boolean | Options | StreamOptions
|
|
35
|
-
] | [
|
|
36
|
-
options: boolean | Options | StreamOptions
|
|
37
|
-
]): {
|
|
38
|
-
bucketName: string;
|
|
39
|
-
fileName: string;
|
|
40
|
-
options: object | boolean;
|
|
41
|
-
error: string;
|
|
42
|
-
};
|
|
19
|
+
setSelectedBucket(bucketName: null | string): void;
|
|
20
|
+
getSelectedBucket(): null | string;
|
|
21
|
+
set selectedBucket(bucketName: null | string);
|
|
22
|
+
get selectedBucket(): null | string;
|
|
23
|
+
set bucketName(bucketName: null | string);
|
|
24
|
+
get bucketName(): null | string;
|
|
25
|
+
private getFileAndBucketAndOptions;
|
|
26
|
+
private checkBucket;
|
|
27
|
+
private checkFile;
|
|
43
28
|
protected abstract _listBuckets(): Promise<ResultObjectBuckets>;
|
|
44
29
|
protected abstract _createBucket(name: string, options: Options): Promise<ResultObject>;
|
|
45
30
|
protected abstract _clearBucket(name: string): Promise<ResultObject>;
|
|
@@ -51,83 +36,26 @@ export declare abstract class AbstractAdapter implements IAdapter {
|
|
|
51
36
|
protected abstract _addFile(params: FilePathParams | FileBufferParams | FileStreamParams): Promise<ResultObject>;
|
|
52
37
|
protected abstract _fileExists(bucketName: string, fileName: string): Promise<ResultObjectBoolean>;
|
|
53
38
|
protected abstract _getFileAsStream(bucketName: string, fileName: string, options: StreamOptions): Promise<ResultObjectStream>;
|
|
54
|
-
protected abstract _getFileAsURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject>;
|
|
55
39
|
protected abstract _getPublicURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject>;
|
|
56
40
|
protected abstract _getSignedURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject>;
|
|
57
|
-
protected abstract _removeFile(bucketName: string, fileName: string
|
|
41
|
+
protected abstract _removeFile(bucketName: string, fileName: string): Promise<ResultObject>;
|
|
42
|
+
protected abstract _getPresignedUploadURL(bucketName: string, fileName: string, options: Options): Promise<ResultObjectObject>;
|
|
58
43
|
listBuckets(): Promise<ResultObjectBuckets>;
|
|
59
|
-
createBucket(...args: [
|
|
60
|
-
bucketName?: string,
|
|
61
|
-
options?: Options
|
|
62
|
-
] | [
|
|
63
|
-
options?: Options
|
|
64
|
-
]): Promise<ResultObject>;
|
|
44
|
+
createBucket(...args: [bucketName?: string, options?: Options] | [options?: Options]): Promise<ResultObject>;
|
|
65
45
|
clearBucket(name?: string): Promise<ResultObject>;
|
|
66
46
|
deleteBucket(name?: string): Promise<ResultObject>;
|
|
67
47
|
bucketExists(name?: string): Promise<ResultObjectBoolean>;
|
|
68
48
|
bucketIsPublic(name?: string): Promise<ResultObjectBoolean>;
|
|
69
|
-
listFiles(...args: [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
numFiles?: number
|
|
74
|
-
] | [
|
|
75
|
-
bucketName?: string
|
|
76
|
-
]): Promise<ResultObjectFiles>;
|
|
49
|
+
listFiles(...args: [bucketName?: string, numFiles?: number] | [numFiles?: number] | [bucketName?: string]): Promise<ResultObjectFiles>;
|
|
50
|
+
addFileFromPath(params: FilePathParams): Promise<ResultObject>;
|
|
51
|
+
addFileFromBuffer(params: FileBufferParams): Promise<ResultObject>;
|
|
52
|
+
addFileFromStream(params: FileStreamParams): Promise<ResultObject>;
|
|
77
53
|
addFile(params: FilePathParams | FileBufferParams | FileStreamParams): Promise<ResultObject>;
|
|
78
|
-
getFileAsStream(...args: [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
] | [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
]): Promise<ResultObjectStream>;
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated: please use getPublicURL or getSignedURL
|
|
88
|
-
*/
|
|
89
|
-
getFileAsURL(...args: [
|
|
90
|
-
bucketName: string,
|
|
91
|
-
fileName: string,
|
|
92
|
-
options?: Options
|
|
93
|
-
] | [
|
|
94
|
-
fileName: string,
|
|
95
|
-
options?: Options
|
|
96
|
-
]): Promise<ResultObject>;
|
|
97
|
-
getPublicURL(...args: [
|
|
98
|
-
bucketName: string,
|
|
99
|
-
fileName: string,
|
|
100
|
-
options?: Options
|
|
101
|
-
] | [
|
|
102
|
-
fileName: string,
|
|
103
|
-
options?: Options
|
|
104
|
-
]): Promise<ResultObject>;
|
|
105
|
-
getSignedURL(...args: [
|
|
106
|
-
bucketName: string,
|
|
107
|
-
fileName: string,
|
|
108
|
-
options?: Options
|
|
109
|
-
] | [
|
|
110
|
-
fileName: string,
|
|
111
|
-
options?: Options
|
|
112
|
-
]): Promise<ResultObject>;
|
|
113
|
-
sizeOf(...args: [
|
|
114
|
-
bucketName: string,
|
|
115
|
-
fileName: string
|
|
116
|
-
] | [
|
|
117
|
-
fileName: string
|
|
118
|
-
]): Promise<ResultObjectNumber>;
|
|
119
|
-
fileExists(...args: [
|
|
120
|
-
bucketName: string,
|
|
121
|
-
fileName: string
|
|
122
|
-
] | [
|
|
123
|
-
fileName: string
|
|
124
|
-
]): Promise<ResultObjectBoolean>;
|
|
125
|
-
removeFile(...args: [
|
|
126
|
-
bucketName: string,
|
|
127
|
-
fileName: string,
|
|
128
|
-
allVersions?: boolean
|
|
129
|
-
] | [
|
|
130
|
-
fileName: string,
|
|
131
|
-
allVersions?: boolean
|
|
132
|
-
]): Promise<ResultObject>;
|
|
54
|
+
getFileAsStream(...args: [bucketName: string, fileName: string, options?: StreamOptions] | [fileName: string, options?: StreamOptions]): Promise<ResultObjectStream>;
|
|
55
|
+
getPublicURL(...args: [bucketName: string, fileName: string, options?: Options] | [fileName: string, options?: Options]): Promise<ResultObject>;
|
|
56
|
+
getSignedURL(...args: [bucketName: string, fileName: string, options?: Options] | [fileName: string, options?: Options]): Promise<ResultObject>;
|
|
57
|
+
sizeOf(...args: [bucketName: string, fileName: string] | [fileName: string]): Promise<ResultObjectNumber>;
|
|
58
|
+
fileExists(...args: [bucketName: string, fileName: string] | [fileName: string]): Promise<ResultObjectBoolean>;
|
|
59
|
+
removeFile(...args: [bucketName: string, fileName: string] | [fileName: string]): Promise<ResultObject>;
|
|
60
|
+
getPresignedUploadURL(...args: [bucketName: string, fileName: string, options?: Options] | [fileName: string, options?: Options]): Promise<ResultObjectObject>;
|
|
133
61
|
}
|