azure-blob-wrapper 0.0.2 → 0.0.3

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/auth.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { StorageSharedKeyCredential } from '@azure/storage-blob';
2
+ export declare function getStorageSharedKeyCredential(accountName: string, accountKey: string): StorageSharedKeyCredential;
package/dist/auth.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStorageSharedKeyCredential = getStorageSharedKeyCredential;
4
+ const storage_blob_1 = require("@azure/storage-blob");
5
+ function getStorageSharedKeyCredential(accountName, accountKey) {
6
+ return new storage_blob_1.StorageSharedKeyCredential(accountName, accountKey);
7
+ }
@@ -0,0 +1,3 @@
1
+ import { BlobClient } from '@azure/storage-blob';
2
+ import { BlobServiceAuth } from './types';
3
+ export declare function createBlobClient(blobUrl: string, auth: BlobServiceAuth): BlobClient;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBlobClient = createBlobClient;
4
+ const storage_blob_1 = require("@azure/storage-blob");
5
+ const auth_1 = require("./auth");
6
+ function createBlobClient(blobUrl, auth) {
7
+ if ('accountName' in auth && 'accountKey' in auth) {
8
+ return new storage_blob_1.BlobClient(blobUrl, (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
9
+ }
10
+ throw new Error('Invalid authentication configuration');
11
+ }
@@ -1,3 +1,3 @@
1
1
  import { BlobServiceClient } from '@azure/storage-blob';
2
2
  import { BlobServiceAuth } from './types';
3
- export declare function createServiceClient(auth: BlobServiceAuth): BlobServiceClient;
3
+ export declare function createBlobServiceClient(auth: BlobServiceAuth): BlobServiceClient;
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createServiceClient = createServiceClient;
3
+ exports.createBlobServiceClient = createBlobServiceClient;
4
4
  const storage_blob_1 = require("@azure/storage-blob");
5
- function createServiceClient(auth) {
6
- return createBlobServiceClient(auth);
7
- }
8
- function buildUrl(accountName) {
9
- return `https://${accountName}.blob.core.windows.net`;
10
- }
5
+ const helpers_1 = require("./helpers");
6
+ const auth_1 = require("./auth");
11
7
  function createBlobServiceClient(auth) {
12
- switch (auth.type) {
13
- case 'sharedKey':
14
- return new storage_blob_1.BlobServiceClient(buildUrl(auth.accountName), new storage_blob_1.StorageSharedKeyCredential(auth.accountName, auth.accountKey));
15
- case 'connectionString':
16
- return storage_blob_1.BlobServiceClient.fromConnectionString(auth.connectionString);
17
- case 'tokenCredential':
18
- return new storage_blob_1.BlobServiceClient(buildUrl(auth.accountName), auth.credential);
8
+ if ('accountName' in auth && 'accountKey' in auth) {
9
+ return new storage_blob_1.BlobServiceClient((0, helpers_1.buildUrl)(auth.accountName), (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
19
10
  }
11
+ throw new Error('Invalid authentication configuration');
20
12
  }
@@ -0,0 +1,3 @@
1
+ import { BlockBlobClient } from '@azure/storage-blob';
2
+ import { BlobServiceAuth } from './types';
3
+ export declare function createBlockBlobClient(blobUrl: string, auth: BlobServiceAuth): BlockBlobClient;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBlockBlobClient = createBlockBlobClient;
4
+ const storage_blob_1 = require("@azure/storage-blob");
5
+ const auth_1 = require("./auth");
6
+ function createBlockBlobClient(blobUrl, auth) {
7
+ if ('accountName' in auth && 'accountKey' in auth) {
8
+ return new storage_blob_1.BlockBlobClient(blobUrl, (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
9
+ }
10
+ throw new Error('Invalid authentication configuration');
11
+ }
@@ -0,0 +1,3 @@
1
+ import { ContainerClient } from '@azure/storage-blob';
2
+ import { BlobServiceAuth } from './types';
3
+ export declare function createContainerClient(container: string, auth: BlobServiceAuth): ContainerClient;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createContainerClient = createContainerClient;
4
+ const storage_blob_1 = require("@azure/storage-blob");
5
+ const auth_1 = require("./auth");
6
+ function createContainerClient(container, auth) {
7
+ if ('accountName' in auth && 'accountKey' in auth) {
8
+ return new storage_blob_1.ContainerClient(container, (0, auth_1.getStorageSharedKeyCredential)(auth.accountName, auth.accountKey));
9
+ }
10
+ throw new Error('Invalid authentication configuration');
11
+ }
@@ -0,0 +1 @@
1
+ export declare function buildUrl(accountName: string): string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildUrl = buildUrl;
4
+ function buildUrl(accountName) {
5
+ return `https://${accountName}.blob.core.windows.net`;
6
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  export * from './types';
2
2
  export * from './blob-service-client';
3
+ export * from './blob-client';
4
+ export * from './container-client';
5
+ export * from './block-blob-client';
6
+ export * from './helpers';
7
+ export * from './auth';
package/dist/index.js CHANGED
@@ -3,3 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./types"), exports);
5
5
  tslib_1.__exportStar(require("./blob-service-client"), exports);
6
+ tslib_1.__exportStar(require("./blob-client"), exports);
7
+ tslib_1.__exportStar(require("./container-client"), exports);
8
+ tslib_1.__exportStar(require("./block-blob-client"), exports);
9
+ tslib_1.__exportStar(require("./helpers"), exports);
10
+ tslib_1.__exportStar(require("./auth"), exports);
package/dist/types.d.ts CHANGED
@@ -1,15 +1,12 @@
1
1
  import { TokenCredential } from '@azure/core-auth';
2
2
  interface SharedKeyAuth {
3
- type: 'sharedKey';
4
3
  accountName: string;
5
4
  accountKey: string;
6
5
  }
7
6
  interface ConnectionStringAuth {
8
- type: 'connectionString';
9
7
  connectionString: string;
10
8
  }
11
9
  interface TokenCredentialAuth {
12
- type: 'tokenCredential';
13
10
  accountName: string;
14
11
  credential: TokenCredential;
15
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-blob-wrapper",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Wrapper for @azure/storage-blob",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,9 +14,7 @@
14
14
  "dependencies": {
15
15
  "@azure/core-auth": "^1.10.1",
16
16
  "@azure/core-paging": "^1.6.2",
17
- "@azure/storage-blob": "^12.24.0",
18
- "dotenv": "^16.4.5",
19
- "list-data-reader": "github:moxalibudbud/list-data-reader#main"
17
+ "@azure/storage-blob": "^12.24.0"
20
18
  },
21
19
  "devDependencies": {
22
20
  "@babel/cli": "^7.24.8",