@twin.org/blob-storage-connector-azure 0.0.2-next.3 → 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 AzureBlobStorageConnector {
18
18
  /**
19
19
  * Runtime name for the class.
20
20
  */
21
- CLASS_NAME = "AzureBlobStorageConnector";
21
+ static CLASS_NAME = "AzureBlobStorageConnector";
22
22
  /**
23
23
  * The configuration for the connector.
24
24
  * @internal
@@ -39,11 +39,11 @@ class AzureBlobStorageConnector {
39
39
  * @param options The options for the connector.
40
40
  */
41
41
  constructor(options) {
42
- core.Guards.object(this.CLASS_NAME, "options", options);
43
- core.Guards.object(this.CLASS_NAME, "options.config", options.config);
44
- core.Guards.stringValue(this.CLASS_NAME, "options.config.accountName", options.config.accountName);
45
- core.Guards.stringValue(this.CLASS_NAME, "options.config.accountKey", options.config.accountKey);
46
- core.Guards.stringValue(this.CLASS_NAME, "options.config.containerName", options.config.containerName);
42
+ core.Guards.object(AzureBlobStorageConnector.CLASS_NAME, "options", options);
43
+ core.Guards.object(AzureBlobStorageConnector.CLASS_NAME, "options.config", options.config);
44
+ core.Guards.stringValue(AzureBlobStorageConnector.CLASS_NAME, "options.config.accountName", options.config.accountName);
45
+ core.Guards.stringValue(AzureBlobStorageConnector.CLASS_NAME, "options.config.accountKey", options.config.accountKey);
46
+ core.Guards.stringValue(AzureBlobStorageConnector.CLASS_NAME, "options.config.containerName", options.config.containerName);
47
47
  this._config = options.config;
48
48
  this._azureBlobServiceClient = new storageBlob.BlobServiceClient((options.config.endpoint ?? "https://{accountName}.blob.core.windows.net/").replace("{accountName}", options.config.accountName), new storageBlob.StorageSharedKeyCredential(options.config.accountName, options.config.accountKey));
49
49
  this._azureContainerClient = this._azureBlobServiceClient.getContainerClient(options.config.containerName);
@@ -58,7 +58,7 @@ class AzureBlobStorageConnector {
58
58
  try {
59
59
  await nodeLogging?.log({
60
60
  level: "info",
61
- source: this.CLASS_NAME,
61
+ source: AzureBlobStorageConnector.CLASS_NAME,
62
62
  message: "containerCreating",
63
63
  data: {
64
64
  container: this._config.containerName
@@ -68,7 +68,7 @@ class AzureBlobStorageConnector {
68
68
  if (exists) {
69
69
  await nodeLogging?.log({
70
70
  level: "info",
71
- source: this.CLASS_NAME,
71
+ source: AzureBlobStorageConnector.CLASS_NAME,
72
72
  message: "containerExists",
73
73
  data: {
74
74
  container: this._config.containerName
@@ -79,7 +79,7 @@ class AzureBlobStorageConnector {
79
79
  await this._azureContainerClient.create();
80
80
  await nodeLogging?.log({
81
81
  level: "info",
82
- source: this.CLASS_NAME,
82
+ source: AzureBlobStorageConnector.CLASS_NAME,
83
83
  message: "containerCreated",
84
84
  data: {
85
85
  container: this._config.containerName
@@ -90,7 +90,7 @@ class AzureBlobStorageConnector {
90
90
  catch (err) {
91
91
  await nodeLogging?.log({
92
92
  level: "error",
93
- source: this.CLASS_NAME,
93
+ source: AzureBlobStorageConnector.CLASS_NAME,
94
94
  message: "containerCreateFailed",
95
95
  data: {
96
96
  container: this._config.containerName
@@ -107,7 +107,7 @@ class AzureBlobStorageConnector {
107
107
  * @returns The id of the stored blob in urn format.
108
108
  */
109
109
  async set(blob) {
110
- core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
110
+ core.Guards.uint8Array(AzureBlobStorageConnector.CLASS_NAME, "blob", blob);
111
111
  try {
112
112
  const id = core.Converter.bytesToHex(crypto.Sha256.sum256(blob));
113
113
  const blockBlobClient = this._azureContainerClient.getBlockBlobClient(id);
@@ -115,7 +115,7 @@ class AzureBlobStorageConnector {
115
115
  return `blob:${new core.Urn(AzureBlobStorageConnector.NAMESPACE, id).toString()}`;
116
116
  }
117
117
  catch (err) {
118
- throw new core.GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
118
+ throw new core.GeneralError(AzureBlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
119
119
  }
120
120
  }
121
121
  /**
@@ -124,10 +124,10 @@ class AzureBlobStorageConnector {
124
124
  * @returns The data for the blob if it can be found or undefined.
125
125
  */
126
126
  async get(id) {
127
- core.Urn.guard(this.CLASS_NAME, "id", id);
127
+ core.Urn.guard(AzureBlobStorageConnector.CLASS_NAME, "id", id);
128
128
  const urnParsed = core.Urn.fromValidString(id);
129
129
  if (urnParsed.namespaceMethod() !== AzureBlobStorageConnector.NAMESPACE) {
130
- throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
130
+ throw new core.GeneralError(AzureBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
131
131
  namespace: AzureBlobStorageConnector.NAMESPACE,
132
132
  id
133
133
  });
@@ -139,7 +139,7 @@ class AzureBlobStorageConnector {
139
139
  return new Uint8Array(buffer);
140
140
  }
141
141
  catch (err) {
142
- throw new core.GeneralError(this.CLASS_NAME, "getBlobFailed", {
142
+ throw new core.GeneralError(AzureBlobStorageConnector.CLASS_NAME, "getBlobFailed", {
143
143
  id,
144
144
  namespace: AzureBlobStorageConnector.NAMESPACE
145
145
  }, err);
@@ -151,10 +151,10 @@ class AzureBlobStorageConnector {
151
151
  * @returns True if the blob was found.
152
152
  */
153
153
  async remove(id) {
154
- core.Urn.guard(this.CLASS_NAME, "id", id);
154
+ core.Urn.guard(AzureBlobStorageConnector.CLASS_NAME, "id", id);
155
155
  const urnParsed = core.Urn.fromValidString(id);
156
156
  if (urnParsed.namespaceMethod() !== AzureBlobStorageConnector.NAMESPACE) {
157
- throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
157
+ throw new core.GeneralError(AzureBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
158
158
  namespace: AzureBlobStorageConnector.NAMESPACE,
159
159
  id
160
160
  });
@@ -172,10 +172,10 @@ class AzureBlobStorageConnector {
172
172
  return false;
173
173
  }
174
174
  catch (err) {
175
- if (err instanceof Error && "statusCode" in err && err.statusCode === 404) {
175
+ if (core.Is.object(err) && err.statusCode === 404) {
176
176
  return false;
177
177
  }
178
- throw new core.GeneralError(this.CLASS_NAME, "removeBlobFailed", { id }, err);
178
+ throw new core.GeneralError(AzureBlobStorageConnector.CLASS_NAME, "removeBlobFailed", { id }, err);
179
179
  }
180
180
  }
181
181
  }
@@ -1,5 +1,5 @@
1
1
  import { BlobServiceClient, StorageSharedKeyCredential } from '@azure/storage-blob';
2
- import { Guards, ComponentFactory, BaseError, Converter, Urn, GeneralError } from '@twin.org/core';
2
+ import { Guards, ComponentFactory, BaseError, Converter, Urn, GeneralError, Is } from '@twin.org/core';
3
3
  import { Sha256 } from '@twin.org/crypto';
4
4
 
5
5
  // Copyright 2024 IOTA Stiftung.
@@ -16,7 +16,7 @@ class AzureBlobStorageConnector {
16
16
  /**
17
17
  * Runtime name for the class.
18
18
  */
19
- CLASS_NAME = "AzureBlobStorageConnector";
19
+ static CLASS_NAME = "AzureBlobStorageConnector";
20
20
  /**
21
21
  * The configuration for the connector.
22
22
  * @internal
@@ -37,11 +37,11 @@ class AzureBlobStorageConnector {
37
37
  * @param options The options for the connector.
38
38
  */
39
39
  constructor(options) {
40
- Guards.object(this.CLASS_NAME, "options", options);
41
- Guards.object(this.CLASS_NAME, "options.config", options.config);
42
- Guards.stringValue(this.CLASS_NAME, "options.config.accountName", options.config.accountName);
43
- Guards.stringValue(this.CLASS_NAME, "options.config.accountKey", options.config.accountKey);
44
- Guards.stringValue(this.CLASS_NAME, "options.config.containerName", options.config.containerName);
40
+ Guards.object(AzureBlobStorageConnector.CLASS_NAME, "options", options);
41
+ Guards.object(AzureBlobStorageConnector.CLASS_NAME, "options.config", options.config);
42
+ Guards.stringValue(AzureBlobStorageConnector.CLASS_NAME, "options.config.accountName", options.config.accountName);
43
+ Guards.stringValue(AzureBlobStorageConnector.CLASS_NAME, "options.config.accountKey", options.config.accountKey);
44
+ Guards.stringValue(AzureBlobStorageConnector.CLASS_NAME, "options.config.containerName", options.config.containerName);
45
45
  this._config = options.config;
46
46
  this._azureBlobServiceClient = new BlobServiceClient((options.config.endpoint ?? "https://{accountName}.blob.core.windows.net/").replace("{accountName}", options.config.accountName), new StorageSharedKeyCredential(options.config.accountName, options.config.accountKey));
47
47
  this._azureContainerClient = this._azureBlobServiceClient.getContainerClient(options.config.containerName);
@@ -56,7 +56,7 @@ class AzureBlobStorageConnector {
56
56
  try {
57
57
  await nodeLogging?.log({
58
58
  level: "info",
59
- source: this.CLASS_NAME,
59
+ source: AzureBlobStorageConnector.CLASS_NAME,
60
60
  message: "containerCreating",
61
61
  data: {
62
62
  container: this._config.containerName
@@ -66,7 +66,7 @@ class AzureBlobStorageConnector {
66
66
  if (exists) {
67
67
  await nodeLogging?.log({
68
68
  level: "info",
69
- source: this.CLASS_NAME,
69
+ source: AzureBlobStorageConnector.CLASS_NAME,
70
70
  message: "containerExists",
71
71
  data: {
72
72
  container: this._config.containerName
@@ -77,7 +77,7 @@ class AzureBlobStorageConnector {
77
77
  await this._azureContainerClient.create();
78
78
  await nodeLogging?.log({
79
79
  level: "info",
80
- source: this.CLASS_NAME,
80
+ source: AzureBlobStorageConnector.CLASS_NAME,
81
81
  message: "containerCreated",
82
82
  data: {
83
83
  container: this._config.containerName
@@ -88,7 +88,7 @@ class AzureBlobStorageConnector {
88
88
  catch (err) {
89
89
  await nodeLogging?.log({
90
90
  level: "error",
91
- source: this.CLASS_NAME,
91
+ source: AzureBlobStorageConnector.CLASS_NAME,
92
92
  message: "containerCreateFailed",
93
93
  data: {
94
94
  container: this._config.containerName
@@ -105,7 +105,7 @@ class AzureBlobStorageConnector {
105
105
  * @returns The id of the stored blob in urn format.
106
106
  */
107
107
  async set(blob) {
108
- Guards.uint8Array(this.CLASS_NAME, "blob", blob);
108
+ Guards.uint8Array(AzureBlobStorageConnector.CLASS_NAME, "blob", blob);
109
109
  try {
110
110
  const id = Converter.bytesToHex(Sha256.sum256(blob));
111
111
  const blockBlobClient = this._azureContainerClient.getBlockBlobClient(id);
@@ -113,7 +113,7 @@ class AzureBlobStorageConnector {
113
113
  return `blob:${new Urn(AzureBlobStorageConnector.NAMESPACE, id).toString()}`;
114
114
  }
115
115
  catch (err) {
116
- throw new GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
116
+ throw new GeneralError(AzureBlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
117
117
  }
118
118
  }
119
119
  /**
@@ -122,10 +122,10 @@ class AzureBlobStorageConnector {
122
122
  * @returns The data for the blob if it can be found or undefined.
123
123
  */
124
124
  async get(id) {
125
- Urn.guard(this.CLASS_NAME, "id", id);
125
+ Urn.guard(AzureBlobStorageConnector.CLASS_NAME, "id", id);
126
126
  const urnParsed = Urn.fromValidString(id);
127
127
  if (urnParsed.namespaceMethod() !== AzureBlobStorageConnector.NAMESPACE) {
128
- throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
128
+ throw new GeneralError(AzureBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
129
129
  namespace: AzureBlobStorageConnector.NAMESPACE,
130
130
  id
131
131
  });
@@ -137,7 +137,7 @@ class AzureBlobStorageConnector {
137
137
  return new Uint8Array(buffer);
138
138
  }
139
139
  catch (err) {
140
- throw new GeneralError(this.CLASS_NAME, "getBlobFailed", {
140
+ throw new GeneralError(AzureBlobStorageConnector.CLASS_NAME, "getBlobFailed", {
141
141
  id,
142
142
  namespace: AzureBlobStorageConnector.NAMESPACE
143
143
  }, err);
@@ -149,10 +149,10 @@ class AzureBlobStorageConnector {
149
149
  * @returns True if the blob was found.
150
150
  */
151
151
  async remove(id) {
152
- Urn.guard(this.CLASS_NAME, "id", id);
152
+ Urn.guard(AzureBlobStorageConnector.CLASS_NAME, "id", id);
153
153
  const urnParsed = Urn.fromValidString(id);
154
154
  if (urnParsed.namespaceMethod() !== AzureBlobStorageConnector.NAMESPACE) {
155
- throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
155
+ throw new GeneralError(AzureBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
156
156
  namespace: AzureBlobStorageConnector.NAMESPACE,
157
157
  id
158
158
  });
@@ -170,10 +170,10 @@ class AzureBlobStorageConnector {
170
170
  return false;
171
171
  }
172
172
  catch (err) {
173
- if (err instanceof Error && "statusCode" in err && err.statusCode === 404) {
173
+ if (Is.object(err) && err.statusCode === 404) {
174
174
  return false;
175
175
  }
176
- throw new GeneralError(this.CLASS_NAME, "removeBlobFailed", { id }, err);
176
+ throw new GeneralError(AzureBlobStorageConnector.CLASS_NAME, "removeBlobFailed", { id }, err);
177
177
  }
178
178
  }
179
179
  }
@@ -12,7 +12,7 @@ export declare class AzureBlobStorageConnector 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 AzureBlobStorageConnector.
18
18
  * @param options The options for the connector.
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/blob-storage-connector-azure - Changelog
2
2
 
3
+ ## [0.0.2-next.5](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-azure-v0.0.2-next.4...blob-storage-connector-azure-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
+
17
+ ## [0.0.2-next.4](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-azure-v0.0.2-next.3...blob-storage-connector-azure-v0.0.2-next.4) (2025-10-02)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **blob-storage-connector-azure:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
30
+
3
31
  ## [0.0.2-next.3](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-azure-v0.0.2-next.2...blob-storage-connector-azure-v0.0.2-next.3) (2025-08-29)
4
32
 
5
33
 
@@ -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-azure",
3
- "version": "0.0.2-next.3",
3
+ "version": "0.0.2-next.5",
4
4
  "description": "Blob Storage connector implementation using Azure",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@azure/storage-blob": "12.28.0",
18
- "@twin.org/blob-storage-models": "0.0.2-next.3",
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",
@@ -38,5 +38,24 @@
38
38
  "dist/types",
39
39
  "locales",
40
40
  "docs"
41
- ]
41
+ ],
42
+ "keywords": [
43
+ "twin",
44
+ "trade",
45
+ "iota",
46
+ "framework",
47
+ "blockchain",
48
+ "blob-storage",
49
+ "blob",
50
+ "storage",
51
+ "files",
52
+ "binary",
53
+ "connector",
54
+ "adapter",
55
+ "integration"
56
+ ],
57
+ "bugs": {
58
+ "url": "git+https://github.com/twinfoundation/blob-storage/issues"
59
+ },
60
+ "homepage": "https://twindev.org"
42
61
  }