@twin.org/blob-storage-connector-aws-s3 0.0.2-next.4 → 0.0.2-next.5

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.
@@ -18,7 +18,7 @@ class S3BlobStorageConnector {
18
18
  /**
19
19
  * Runtime name for the class.
20
20
  */
21
- CLASS_NAME = "S3BlobStorageConnector";
21
+ static CLASS_NAME = "S3BlobStorageConnector";
22
22
  /**
23
23
  * The configuration for the connector.
24
24
  * @internal
@@ -34,15 +34,15 @@ class S3BlobStorageConnector {
34
34
  * @param options The options for the connector.
35
35
  */
36
36
  constructor(options) {
37
- core.Guards.object(this.CLASS_NAME, "options", options);
38
- core.Guards.object(this.CLASS_NAME, "options.config", options.config);
39
- core.Guards.stringValue(this.CLASS_NAME, "options.config.region", options.config.region);
40
- core.Guards.stringValue(this.CLASS_NAME, "options.config.bucketName", options.config.bucketName);
37
+ core.Guards.object(S3BlobStorageConnector.CLASS_NAME, "options", options);
38
+ core.Guards.object(S3BlobStorageConnector.CLASS_NAME, "options.config", options.config);
39
+ core.Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.region", options.config.region);
40
+ core.Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.bucketName", options.config.bucketName);
41
41
  options.config.authMode ??= "credentials";
42
42
  let credentials;
43
43
  if (options.config.authMode === "credentials") {
44
- core.Guards.stringValue(this.CLASS_NAME, "options.config.accessKeyId", options.config.accessKeyId);
45
- core.Guards.stringValue(this.CLASS_NAME, "options.config.secretAccessKey", options.config.secretAccessKey);
44
+ core.Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.accessKeyId", options.config.accessKeyId);
45
+ core.Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.secretAccessKey", options.config.secretAccessKey);
46
46
  credentials = {
47
47
  accessKeyId: options.config.accessKeyId,
48
48
  secretAccessKey: options.config.secretAccessKey
@@ -66,7 +66,7 @@ class S3BlobStorageConnector {
66
66
  try {
67
67
  await nodeLogging?.log({
68
68
  level: "info",
69
- source: this.CLASS_NAME,
69
+ source: S3BlobStorageConnector.CLASS_NAME,
70
70
  message: "bucketCreating",
71
71
  data: {
72
72
  bucket: this._config.bucketName
@@ -78,7 +78,7 @@ class S3BlobStorageConnector {
78
78
  if (bucketExists) {
79
79
  await nodeLogging?.log({
80
80
  level: "info",
81
- source: this.CLASS_NAME,
81
+ source: S3BlobStorageConnector.CLASS_NAME,
82
82
  message: "bucketExists",
83
83
  data: {
84
84
  bucket: this._config.bucketName
@@ -89,7 +89,7 @@ class S3BlobStorageConnector {
89
89
  await this._s3Client.send(new clientS3.CreateBucketCommand({ Bucket: this._config.bucketName }));
90
90
  await nodeLogging?.log({
91
91
  level: "info",
92
- source: this.CLASS_NAME,
92
+ source: S3BlobStorageConnector.CLASS_NAME,
93
93
  message: "bucketCreated",
94
94
  data: {
95
95
  bucket: this._config.bucketName
@@ -100,7 +100,7 @@ class S3BlobStorageConnector {
100
100
  catch (err) {
101
101
  await nodeLogging?.log({
102
102
  level: "error",
103
- source: this.CLASS_NAME,
103
+ source: S3BlobStorageConnector.CLASS_NAME,
104
104
  message: "bucketCreateFailed",
105
105
  data: {
106
106
  bucket: this._config.bucketName
@@ -117,7 +117,7 @@ class S3BlobStorageConnector {
117
117
  * @returns The id of the stored blob in urn format.
118
118
  */
119
119
  async set(blob) {
120
- core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
120
+ core.Guards.uint8Array(S3BlobStorageConnector.CLASS_NAME, "blob", blob);
121
121
  try {
122
122
  const id = core.Converter.bytesToHex(crypto.Sha256.sum256(blob));
123
123
  const command = new clientS3.PutObjectCommand({
@@ -129,7 +129,7 @@ class S3BlobStorageConnector {
129
129
  return `blob:${new core.Urn(S3BlobStorageConnector.NAMESPACE, id).toString()}`;
130
130
  }
131
131
  catch (err) {
132
- throw new core.GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
132
+ throw new core.GeneralError(S3BlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
133
133
  }
134
134
  }
135
135
  /**
@@ -138,10 +138,10 @@ class S3BlobStorageConnector {
138
138
  * @returns The data for the blob if it can be found or undefined.
139
139
  */
140
140
  async get(id) {
141
- core.Urn.guard(this.CLASS_NAME, "id", id);
141
+ core.Urn.guard(S3BlobStorageConnector.CLASS_NAME, "id", id);
142
142
  const urnParsed = core.Urn.fromValidString(id);
143
143
  if (urnParsed.namespaceMethod() !== S3BlobStorageConnector.NAMESPACE) {
144
- throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
144
+ throw new core.GeneralError(S3BlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
145
145
  namespace: S3BlobStorageConnector.NAMESPACE,
146
146
  id
147
147
  });
@@ -157,7 +157,12 @@ class S3BlobStorageConnector {
157
157
  return new Uint8Array(await response.Body.transformToByteArray());
158
158
  }
159
159
  }
160
- catch { }
160
+ catch (err) {
161
+ throw new core.GeneralError(S3BlobStorageConnector.CLASS_NAME, "getBlobFailed", {
162
+ id,
163
+ namespace: S3BlobStorageConnector.NAMESPACE
164
+ }, err);
165
+ }
161
166
  }
162
167
  /**
163
168
  * Remove the blob.
@@ -165,10 +170,10 @@ class S3BlobStorageConnector {
165
170
  * @returns True if the blob was found.
166
171
  */
167
172
  async remove(id) {
168
- core.Urn.guard(this.CLASS_NAME, "id", id);
173
+ core.Urn.guard(S3BlobStorageConnector.CLASS_NAME, "id", id);
169
174
  const urnParsed = core.Urn.fromValidString(id);
170
175
  if (urnParsed.namespaceMethod() !== S3BlobStorageConnector.NAMESPACE) {
171
- throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
176
+ throw new core.GeneralError(S3BlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
172
177
  namespace: S3BlobStorageConnector.NAMESPACE,
173
178
  id
174
179
  });
@@ -196,7 +201,7 @@ class S3BlobStorageConnector {
196
201
  return true;
197
202
  }
198
203
  catch (err) {
199
- throw new core.GeneralError(this.CLASS_NAME, "removeBlobFailed", { id }, err);
204
+ throw new core.GeneralError(S3BlobStorageConnector.CLASS_NAME, "removeBlobFailed", { id }, err);
200
205
  }
201
206
  }
202
207
  }
@@ -16,7 +16,7 @@ class S3BlobStorageConnector {
16
16
  /**
17
17
  * Runtime name for the class.
18
18
  */
19
- CLASS_NAME = "S3BlobStorageConnector";
19
+ static CLASS_NAME = "S3BlobStorageConnector";
20
20
  /**
21
21
  * The configuration for the connector.
22
22
  * @internal
@@ -32,15 +32,15 @@ class S3BlobStorageConnector {
32
32
  * @param options The options for the connector.
33
33
  */
34
34
  constructor(options) {
35
- Guards.object(this.CLASS_NAME, "options", options);
36
- Guards.object(this.CLASS_NAME, "options.config", options.config);
37
- Guards.stringValue(this.CLASS_NAME, "options.config.region", options.config.region);
38
- Guards.stringValue(this.CLASS_NAME, "options.config.bucketName", options.config.bucketName);
35
+ Guards.object(S3BlobStorageConnector.CLASS_NAME, "options", options);
36
+ Guards.object(S3BlobStorageConnector.CLASS_NAME, "options.config", options.config);
37
+ Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.region", options.config.region);
38
+ Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.bucketName", options.config.bucketName);
39
39
  options.config.authMode ??= "credentials";
40
40
  let credentials;
41
41
  if (options.config.authMode === "credentials") {
42
- Guards.stringValue(this.CLASS_NAME, "options.config.accessKeyId", options.config.accessKeyId);
43
- Guards.stringValue(this.CLASS_NAME, "options.config.secretAccessKey", options.config.secretAccessKey);
42
+ Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.accessKeyId", options.config.accessKeyId);
43
+ Guards.stringValue(S3BlobStorageConnector.CLASS_NAME, "options.config.secretAccessKey", options.config.secretAccessKey);
44
44
  credentials = {
45
45
  accessKeyId: options.config.accessKeyId,
46
46
  secretAccessKey: options.config.secretAccessKey
@@ -64,7 +64,7 @@ class S3BlobStorageConnector {
64
64
  try {
65
65
  await nodeLogging?.log({
66
66
  level: "info",
67
- source: this.CLASS_NAME,
67
+ source: S3BlobStorageConnector.CLASS_NAME,
68
68
  message: "bucketCreating",
69
69
  data: {
70
70
  bucket: this._config.bucketName
@@ -76,7 +76,7 @@ class S3BlobStorageConnector {
76
76
  if (bucketExists) {
77
77
  await nodeLogging?.log({
78
78
  level: "info",
79
- source: this.CLASS_NAME,
79
+ source: S3BlobStorageConnector.CLASS_NAME,
80
80
  message: "bucketExists",
81
81
  data: {
82
82
  bucket: this._config.bucketName
@@ -87,7 +87,7 @@ class S3BlobStorageConnector {
87
87
  await this._s3Client.send(new CreateBucketCommand({ Bucket: this._config.bucketName }));
88
88
  await nodeLogging?.log({
89
89
  level: "info",
90
- source: this.CLASS_NAME,
90
+ source: S3BlobStorageConnector.CLASS_NAME,
91
91
  message: "bucketCreated",
92
92
  data: {
93
93
  bucket: this._config.bucketName
@@ -98,7 +98,7 @@ class S3BlobStorageConnector {
98
98
  catch (err) {
99
99
  await nodeLogging?.log({
100
100
  level: "error",
101
- source: this.CLASS_NAME,
101
+ source: S3BlobStorageConnector.CLASS_NAME,
102
102
  message: "bucketCreateFailed",
103
103
  data: {
104
104
  bucket: this._config.bucketName
@@ -115,7 +115,7 @@ class S3BlobStorageConnector {
115
115
  * @returns The id of the stored blob in urn format.
116
116
  */
117
117
  async set(blob) {
118
- Guards.uint8Array(this.CLASS_NAME, "blob", blob);
118
+ Guards.uint8Array(S3BlobStorageConnector.CLASS_NAME, "blob", blob);
119
119
  try {
120
120
  const id = Converter.bytesToHex(Sha256.sum256(blob));
121
121
  const command = new PutObjectCommand({
@@ -127,7 +127,7 @@ class S3BlobStorageConnector {
127
127
  return `blob:${new Urn(S3BlobStorageConnector.NAMESPACE, id).toString()}`;
128
128
  }
129
129
  catch (err) {
130
- throw new GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
130
+ throw new GeneralError(S3BlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
131
131
  }
132
132
  }
133
133
  /**
@@ -136,10 +136,10 @@ class S3BlobStorageConnector {
136
136
  * @returns The data for the blob if it can be found or undefined.
137
137
  */
138
138
  async get(id) {
139
- Urn.guard(this.CLASS_NAME, "id", id);
139
+ Urn.guard(S3BlobStorageConnector.CLASS_NAME, "id", id);
140
140
  const urnParsed = Urn.fromValidString(id);
141
141
  if (urnParsed.namespaceMethod() !== S3BlobStorageConnector.NAMESPACE) {
142
- throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
142
+ throw new GeneralError(S3BlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
143
143
  namespace: S3BlobStorageConnector.NAMESPACE,
144
144
  id
145
145
  });
@@ -155,7 +155,12 @@ class S3BlobStorageConnector {
155
155
  return new Uint8Array(await response.Body.transformToByteArray());
156
156
  }
157
157
  }
158
- catch { }
158
+ catch (err) {
159
+ throw new GeneralError(S3BlobStorageConnector.CLASS_NAME, "getBlobFailed", {
160
+ id,
161
+ namespace: S3BlobStorageConnector.NAMESPACE
162
+ }, err);
163
+ }
159
164
  }
160
165
  /**
161
166
  * Remove the blob.
@@ -163,10 +168,10 @@ class S3BlobStorageConnector {
163
168
  * @returns True if the blob was found.
164
169
  */
165
170
  async remove(id) {
166
- Urn.guard(this.CLASS_NAME, "id", id);
171
+ Urn.guard(S3BlobStorageConnector.CLASS_NAME, "id", id);
167
172
  const urnParsed = Urn.fromValidString(id);
168
173
  if (urnParsed.namespaceMethod() !== S3BlobStorageConnector.NAMESPACE) {
169
- throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
174
+ throw new GeneralError(S3BlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
170
175
  namespace: S3BlobStorageConnector.NAMESPACE,
171
176
  id
172
177
  });
@@ -194,7 +199,7 @@ class S3BlobStorageConnector {
194
199
  return true;
195
200
  }
196
201
  catch (err) {
197
- throw new GeneralError(this.CLASS_NAME, "removeBlobFailed", { id }, err);
202
+ throw new GeneralError(S3BlobStorageConnector.CLASS_NAME, "removeBlobFailed", { id }, err);
198
203
  }
199
204
  }
200
205
  }
@@ -12,7 +12,7 @@ export declare class S3BlobStorageConnector implements IBlobStorageConnector {
12
12
  /**
13
13
  * Runtime name for the class.
14
14
  */
15
- readonly CLASS_NAME: string;
15
+ static readonly CLASS_NAME: string;
16
16
  /**
17
17
  * Create a new instance of S3BlobStorageConnector.
18
18
  * @param options The options for the connector.
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @twin.org/blob-storage-connector-aws-s3 - Changelog
2
2
 
3
+ ## [0.0.2-next.5](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-aws-s3-v0.0.2-next.4...blob-storage-connector-aws-s3-v0.0.2-next.5) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
16
+
3
17
  ## [0.0.2-next.4](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-aws-s3-v0.0.2-next.3...blob-storage-connector-aws-s3-v0.0.2-next.4) (2025-10-02)
4
18
 
5
19
 
@@ -39,14 +39,10 @@ The namespace for the items.
39
39
 
40
40
  ### CLASS\_NAME
41
41
 
42
- > `readonly` **CLASS\_NAME**: `string`
42
+ > `readonly` `static` **CLASS\_NAME**: `string`
43
43
 
44
44
  Runtime name for the class.
45
45
 
46
- #### Implementation of
47
-
48
- `IBlobStorageConnector.CLASS_NAME`
49
-
50
46
  ## Methods
51
47
 
52
48
  ### bootstrap()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-connector-aws-s3",
3
- "version": "0.0.2-next.4",
3
+ "version": "0.0.2-next.5",
4
4
  "description": "Blob Storage connector implementation using AWS S3",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@aws-sdk/client-s3": "3.896.0",
18
- "@twin.org/blob-storage-models": "0.0.2-next.4",
17
+ "@aws-sdk/client-s3": "3.906.0",
18
+ "@twin.org/blob-storage-models": "0.0.2-next.5",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/crypto": "next",
21
21
  "@twin.org/logging-models": "next",
@@ -53,5 +53,9 @@
53
53
  "connector",
54
54
  "adapter",
55
55
  "integration"
56
- ]
56
+ ],
57
+ "bugs": {
58
+ "url": "git+https://github.com/twinfoundation/blob-storage/issues"
59
+ },
60
+ "homepage": "https://twindev.org"
57
61
  }