@tweedegolf/sab-adapter-backblaze-b2 1.0.6 → 3.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/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, StorageType } from "@tweedegolf/storage-abstraction";
14
+ import { Storage, Provider } from "@tweedegolf/storage-abstraction";
15
15
 
16
16
  const configuration = {
17
- type: StorageType.B2,
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 `type` 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).
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 `type` key of the configuration object, all other keys are necessary for configuring the adapter.
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: StorageType.B2,
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: StorageType.B2,
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.0
2
+ - version bump to match the version of Storage and the API
3
+ - removed support for versioning (wasn't implemented consistently anyway)
4
+ - removed `getFileAsURL`
5
+ - removed option `{allVersions: boolean}` for `removeFile`
6
+ - `removeFile` does not fail if the file doesn't exist
7
+ - `deleteBucket` does not fail if the bucket doesn't exist
8
+ - see also the [migration guide](https://github.com/tweedegolf/storage-abstraction/blob/master/migration_to_api3.0.md)
9
+
10
+ # 1.0.7
11
+ - include @deprecated functions
12
+
1
13
  # 1.0.6
2
14
  - implemented new API methods `bucketIsPublic`, `getPublicURL` and `getSignedURL`
3
15
 
@@ -1,15 +1,15 @@
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 _type: string;
5
+ protected _provider: Provider;
6
6
  protected _config: AdapterConfig | null;
7
7
  protected _configError: string | null;
8
8
  protected _bucketName: string;
9
9
  protected _client: any;
10
10
  constructor(config: string | AdapterConfig);
11
- get type(): string;
12
- getType(): string;
11
+ get provider(): Provider;
12
+ getProvider(): Provider;
13
13
  get config(): AdapterConfig;
14
14
  getConfig(): AdapterConfig;
15
15
  get configError(): string;
@@ -18,42 +18,99 @@ export declare abstract class AbstractAdapter implements IAdapter {
18
18
  getServiceClient(): any;
19
19
  setSelectedBucket(bucketName: string | null): void;
20
20
  getSelectedBucket(): string | null;
21
- set(bucketName: string | null): void;
21
+ set selectedBucket(bucketName: string | null);
22
+ get selectedBucket(): string | null;
23
+ set bucketName(bucketName: string | null);
22
24
  get bucketName(): string | null;
23
- addFileFromPath(params: FilePathParams): Promise<ResultObject>;
24
- addFileFromBuffer(params: FileBufferParams): Promise<ResultObject>;
25
- addFileFromStream(params: FileStreamParams): Promise<ResultObject>;
26
- protected _getFileAndBucket(arg1: string, arg2?: string): {
27
- bucketName: string;
28
- fileName: string;
29
- error: string;
30
- };
25
+ private getFileAndBucketAndOptions;
26
+ private checkBucket;
27
+ private checkFile;
28
+ protected abstract _listBuckets(): Promise<ResultObjectBuckets>;
29
+ protected abstract _createBucket(name: string, options: Options): Promise<ResultObject>;
31
30
  protected abstract _clearBucket(name: string): Promise<ResultObject>;
32
31
  protected abstract _deleteBucket(name: string): Promise<ResultObject>;
33
32
  protected abstract _bucketExists(name: string): Promise<ResultObjectBoolean>;
33
+ protected abstract _bucketIsPublic(name: string): Promise<ResultObjectBoolean>;
34
34
  protected abstract _listFiles(bucketName: string, numFiles: number): Promise<ResultObjectFiles>;
35
35
  protected abstract _sizeOf(bucketName: string, fileName: string): Promise<ResultObjectNumber>;
36
36
  protected abstract _addFile(params: FilePathParams | FileBufferParams | FileStreamParams): Promise<ResultObject>;
37
37
  protected abstract _fileExists(bucketName: string, fileName: string): Promise<ResultObjectBoolean>;
38
38
  protected abstract _getFileAsStream(bucketName: string, fileName: string, options: StreamOptions): Promise<ResultObjectStream>;
39
- protected abstract _getFileAsURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject>;
40
- protected abstract _removeFile(bucketName: string, fileName: string, allVersions: boolean): Promise<ResultObject>;
41
- abstract listBuckets(): Promise<ResultObjectBuckets>;
42
- abstract createBucket(name: string, options?: Options): Promise<ResultObject>;
39
+ protected abstract _getPublicURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject>;
40
+ protected abstract _getSignedURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject>;
41
+ protected abstract _removeFile(bucketName: string, fileName: string): Promise<ResultObject>;
42
+ protected abstract _getPresignedUploadURL(bucketName: string, fileName: string, options: Options): Promise<ResultObjectObject>;
43
+ listBuckets(): Promise<ResultObjectBuckets>;
44
+ createBucket(...args: [
45
+ bucketName?: string,
46
+ options?: Options
47
+ ] | [
48
+ options?: Options
49
+ ]): Promise<ResultObject>;
43
50
  clearBucket(name?: string): Promise<ResultObject>;
44
51
  deleteBucket(name?: string): Promise<ResultObject>;
45
52
  bucketExists(name?: string): Promise<ResultObjectBoolean>;
46
- listFiles(bucketName: string, numFiles?: number): Promise<ResultObjectFiles>;
47
- listFiles(numFiles?: number): Promise<ResultObjectFiles>;
53
+ bucketIsPublic(name?: string): Promise<ResultObjectBoolean>;
54
+ listFiles(...args: [
55
+ bucketName?: string,
56
+ numFiles?: number
57
+ ] | [
58
+ numFiles?: number
59
+ ] | [
60
+ bucketName?: string
61
+ ]): Promise<ResultObjectFiles>;
62
+ addFileFromPath(params: FilePathParams): Promise<ResultObject>;
63
+ addFileFromBuffer(params: FileBufferParams): Promise<ResultObject>;
64
+ addFileFromStream(params: FileStreamParams): Promise<ResultObject>;
48
65
  addFile(params: FilePathParams | FileBufferParams | FileStreamParams): Promise<ResultObject>;
49
- getFileAsStream(bucketName: string, fileName: string, options?: StreamOptions): Promise<ResultObjectStream>;
50
- getFileAsStream(fileName: string, options?: StreamOptions): Promise<ResultObjectStream>;
51
- getFileAsURL(bucketName: string, fileName: string, options?: Options): Promise<ResultObject>;
52
- getFileAsURL(fileName: string, options?: Options): Promise<ResultObject>;
53
- sizeOf(bucketName: string, fileName: string): Promise<ResultObjectNumber>;
54
- sizeOf(fileName: string): Promise<ResultObjectNumber>;
55
- fileExists(bucketName: string, fileName: string): Promise<ResultObjectBoolean>;
56
- fileExists(fileName: string): Promise<ResultObjectBoolean>;
57
- removeFile(bucketName: string, fileName: string, allVersions?: boolean): Promise<ResultObject>;
58
- removeFile(fileName: string, allVersions?: boolean): Promise<ResultObject>;
66
+ getFileAsStream(...args: [
67
+ bucketName: string,
68
+ fileName: string,
69
+ options?: StreamOptions
70
+ ] | [
71
+ fileName: string,
72
+ options?: StreamOptions
73
+ ]): Promise<ResultObjectStream>;
74
+ getPublicURL(...args: [
75
+ bucketName: string,
76
+ fileName: string,
77
+ options?: Options
78
+ ] | [
79
+ fileName: string,
80
+ options?: Options
81
+ ]): Promise<ResultObject>;
82
+ getSignedURL(...args: [
83
+ bucketName: string,
84
+ fileName: string,
85
+ options?: Options
86
+ ] | [
87
+ fileName: string,
88
+ options?: Options
89
+ ]): Promise<ResultObject>;
90
+ sizeOf(...args: [
91
+ bucketName: string,
92
+ fileName: string
93
+ ] | [
94
+ fileName: string
95
+ ]): Promise<ResultObjectNumber>;
96
+ fileExists(...args: [
97
+ bucketName: string,
98
+ fileName: string
99
+ ] | [
100
+ fileName: string
101
+ ]): Promise<ResultObjectBoolean>;
102
+ removeFile(...args: [
103
+ bucketName: string,
104
+ fileName: string
105
+ ] | [
106
+ fileName: string
107
+ ]): Promise<ResultObject>;
108
+ getPresignedUploadURL(...args: [
109
+ bucketName: string,
110
+ fileName: string,
111
+ options?: Options
112
+ ] | [
113
+ fileName: string,
114
+ options?: Options
115
+ ]): Promise<ResultObjectObject>;
59
116
  }