@twin.org/blob-storage-connector-azure 0.0.1-next.7 → 0.0.1-next.8
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/dist/cjs/index.cjs
CHANGED
|
@@ -20,11 +20,6 @@ class AzureBlobStorageConnector {
|
|
|
20
20
|
* Runtime name for the class.
|
|
21
21
|
*/
|
|
22
22
|
CLASS_NAME = "AzureBlobStorageConnector";
|
|
23
|
-
/**
|
|
24
|
-
* The configuration for the connector.
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
_config;
|
|
28
23
|
/**
|
|
29
24
|
* The Azure Service client.
|
|
30
25
|
* @internal
|
|
@@ -43,13 +38,10 @@ class AzureBlobStorageConnector {
|
|
|
43
38
|
constructor(options) {
|
|
44
39
|
core.Guards.object(this.CLASS_NAME, "options", options);
|
|
45
40
|
core.Guards.object(this.CLASS_NAME, "options.config", options.config);
|
|
41
|
+
core.Guards.stringValue(this.CLASS_NAME, "options.config.accountName", options.config.accountName);
|
|
42
|
+
core.Guards.stringValue(this.CLASS_NAME, "options.config.accountKey", options.config.accountKey);
|
|
46
43
|
core.Guards.stringValue(this.CLASS_NAME, "options.config.containerName", options.config.containerName);
|
|
47
|
-
core.
|
|
48
|
-
core.Guards.stringValue(this.CLASS_NAME, "options.config.blobEndpoint", options.config.blobEndpoint);
|
|
49
|
-
this._config = options.config;
|
|
50
|
-
const AZURITE_CONNECTION_STRING = options.config.connectionString + options.config.blobEndpoint;
|
|
51
|
-
this._azureBlobServiceClient =
|
|
52
|
-
storageBlob.BlobServiceClient.fromConnectionString(AZURITE_CONNECTION_STRING);
|
|
44
|
+
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));
|
|
53
45
|
this._azureContainerClient = this._azureBlobServiceClient.getContainerClient(options.config.containerName);
|
|
54
46
|
}
|
|
55
47
|
/**
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
-
import { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
+
import { BlobServiceClient, StorageSharedKeyCredential } from '@azure/storage-blob';
|
|
3
3
|
import { Guards, Converter, Urn, GeneralError } from '@twin.org/core';
|
|
4
4
|
import { Sha256 } from '@twin.org/crypto';
|
|
5
5
|
|
|
@@ -18,11 +18,6 @@ class AzureBlobStorageConnector {
|
|
|
18
18
|
* Runtime name for the class.
|
|
19
19
|
*/
|
|
20
20
|
CLASS_NAME = "AzureBlobStorageConnector";
|
|
21
|
-
/**
|
|
22
|
-
* The configuration for the connector.
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
_config;
|
|
26
21
|
/**
|
|
27
22
|
* The Azure Service client.
|
|
28
23
|
* @internal
|
|
@@ -41,13 +36,10 @@ class AzureBlobStorageConnector {
|
|
|
41
36
|
constructor(options) {
|
|
42
37
|
Guards.object(this.CLASS_NAME, "options", options);
|
|
43
38
|
Guards.object(this.CLASS_NAME, "options.config", options.config);
|
|
39
|
+
Guards.stringValue(this.CLASS_NAME, "options.config.accountName", options.config.accountName);
|
|
40
|
+
Guards.stringValue(this.CLASS_NAME, "options.config.accountKey", options.config.accountKey);
|
|
44
41
|
Guards.stringValue(this.CLASS_NAME, "options.config.containerName", options.config.containerName);
|
|
45
|
-
|
|
46
|
-
Guards.stringValue(this.CLASS_NAME, "options.config.blobEndpoint", options.config.blobEndpoint);
|
|
47
|
-
this._config = options.config;
|
|
48
|
-
const AZURITE_CONNECTION_STRING = options.config.connectionString + options.config.blobEndpoint;
|
|
49
|
-
this._azureBlobServiceClient =
|
|
50
|
-
BlobServiceClient.fromConnectionString(AZURITE_CONNECTION_STRING);
|
|
42
|
+
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));
|
|
51
43
|
this._azureContainerClient = this._azureBlobServiceClient.getContainerClient(options.config.containerName);
|
|
52
44
|
}
|
|
53
45
|
/**
|
|
@@ -3,15 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface IAzureBlobStorageConnectorConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Storage account name.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
accountName: string;
|
|
9
|
+
/**
|
|
10
|
+
* Account key.
|
|
11
|
+
*/
|
|
12
|
+
accountKey: string;
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
14
|
+
* The Azure container name.
|
|
11
15
|
*/
|
|
12
|
-
|
|
16
|
+
containerName: string;
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* Endpoint defaults to `https://{accountName}.blob.core.windows.net/` where accountName will be
|
|
19
|
+
* substituted.
|
|
15
20
|
*/
|
|
16
|
-
|
|
21
|
+
endpoint?: string;
|
|
17
22
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -4,24 +4,33 @@ Configuration for the Azure Blob Storage Connector.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### accountName
|
|
8
8
|
|
|
9
|
-
> **
|
|
9
|
+
> **accountName**: `string`
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Storage account name.
|
|
12
12
|
|
|
13
13
|
***
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### accountKey
|
|
16
16
|
|
|
17
|
-
> **
|
|
17
|
+
> **accountKey**: `string`
|
|
18
|
+
|
|
19
|
+
Account key.
|
|
20
|
+
|
|
21
|
+
***
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
### containerName
|
|
24
|
+
|
|
25
|
+
> **containerName**: `string`
|
|
26
|
+
|
|
27
|
+
The Azure container name.
|
|
20
28
|
|
|
21
29
|
***
|
|
22
30
|
|
|
23
|
-
###
|
|
31
|
+
### endpoint?
|
|
24
32
|
|
|
25
|
-
> **
|
|
33
|
+
> `optional` **endpoint**: `string`
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
Endpoint defaults to `https://{accountName}.blob.core.windows.net/` where accountName will be
|
|
36
|
+
substituted.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-connector-azure",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.8",
|
|
4
4
|
"description": "Blob Storage connector implementation using Azure",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,45 +13,13 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage docs/reference",
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"build:watch": "tsc-watch --onSuccess \"npm run bundle:esm\"",
|
|
20
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
22
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
23
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
24
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
25
|
-
"docs:clean": "rimraf docs/reference",
|
|
26
|
-
"docs:generate": "typedoc",
|
|
27
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
28
|
-
"dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs",
|
|
29
|
-
"prepare": "ts-patch install -s"
|
|
30
|
-
},
|
|
31
16
|
"dependencies": {
|
|
32
17
|
"@azure/storage-blob": "^12.25.0",
|
|
33
|
-
"@twin.org/blob-storage-models": "0.0.1-next.
|
|
18
|
+
"@twin.org/blob-storage-models": "0.0.1-next.8",
|
|
34
19
|
"@twin.org/core": "next",
|
|
35
20
|
"@twin.org/crypto": "next",
|
|
36
21
|
"@twin.org/nameof": "next"
|
|
37
22
|
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@twin.org/nameof-transformer": "next",
|
|
40
|
-
"@types/node": "^22.7.5",
|
|
41
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
42
|
-
"copyfiles": "2.4.1",
|
|
43
|
-
"dotenv": "16.4.5",
|
|
44
|
-
"rimraf": "6.0.1",
|
|
45
|
-
"rollup": "4.22.4",
|
|
46
|
-
"rollup-plugin-copy": "3.5.0",
|
|
47
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
48
|
-
"ts-patch": "3.2.1",
|
|
49
|
-
"tsc-watch": "6.2.0",
|
|
50
|
-
"typedoc": "0.26.7",
|
|
51
|
-
"typedoc-plugin-markdown": "4.2.8",
|
|
52
|
-
"typescript": "5.6.2",
|
|
53
|
-
"vitest": "2.1.1"
|
|
54
|
-
},
|
|
55
23
|
"main": "./dist/cjs/index.cjs",
|
|
56
24
|
"module": "./dist/esm/index.mjs",
|
|
57
25
|
"types": "./dist/types/index.d.ts",
|