azure-blob-wrapper 0.0.1 → 0.0.2
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/package.json +2 -2
- package/dist/src/examples/out-file-etl.d.ts +0 -6
- package/dist/src/examples/out-file-etl.js +0 -30
- package/dist/src/examples/out-file-line-model.d.ts +0 -8
- package/dist/src/examples/out-file-line-model.js +0 -23
- package/dist/src/tests/azure-blob.test.d.ts +0 -1
- package/dist/src/tests/azure-blob.test.js +0 -36
- package/dist/src/tests/blob-client.test.d.ts +0 -1
- package/dist/src/tests/blob-client.test.js +0 -16
- package/dist/src/tests/blob-line-reader.test.d.ts +0 -1
- package/dist/src/tests/blob-line-reader.test.js +0 -78
- package/dist/src/tests/blob-service-client.test.d.ts +0 -1
- package/dist/src/tests/blob-service-client.test.js +0 -26
- package/dist/src/tests/block-blob-client.test.d.ts +0 -1
- package/dist/src/tests/block-blob-client.test.js +0 -16
- package/dist/src/tests/example.test.d.ts +0 -1
- package/dist/src/tests/example.test.js +0 -20
- package/dist/todo/blob-client.d.ts +0 -2
- package/dist/todo/blob-client.js +0 -8
- package/dist/todo/blob-line-reader.d.ts +0 -26
- package/dist/todo/blob-line-reader.js +0 -67
- package/dist/todo/blob.d.ts +0 -6
- package/dist/todo/blob.js +0 -18
- package/dist/todo/block-blob-client.d.ts +0 -2
- package/dist/todo/block-blob-client.js +0 -8
- package/dist/todo/container.d.ts +0 -10
- package/dist/todo/container.js +0 -23
- package/dist/todo/enums.d.ts +0 -31
- package/dist/todo/enums.js +0 -38
- package/dist/todo/service-client.d.ts +0 -7
- package/dist/todo/service-client.js +0 -22
- /package/dist/{src/blob-service-client.d.ts → blob-service-client.d.ts} +0 -0
- /package/dist/{src/blob-service-client.js → blob-service-client.js} +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{src/types.js → types.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-blob-wrapper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Wrapper for @azure/storage-blob",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"watch": "nodemon --config nodemon.json",
|
|
40
|
-
"build": "tsc --build tsconfig.prod.json",
|
|
40
|
+
"build": "sh -c '[ -d dist ] && rm -R dist' && tsc --build tsconfig.prod.json",
|
|
41
41
|
"release": "pnpm publish --access public",
|
|
42
42
|
"test": "jest",
|
|
43
43
|
"test:prod": "jest --testPathPattern=dist/tests --detectOpenHandles",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OutFileETL = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const blob_line_reader_1 = require("../../todo/blob-line-reader");
|
|
6
|
-
class OutFileETL extends blob_line_reader_1.BlobLineReader {
|
|
7
|
-
constructor(filepath) {
|
|
8
|
-
super(filepath);
|
|
9
|
-
}
|
|
10
|
-
readContent() {
|
|
11
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
try {
|
|
13
|
-
const data = yield this.readBlob();
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
readBlob() {
|
|
22
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const arr = [];
|
|
24
|
-
const handleOnLine = (chunk) => arr.push(chunk);
|
|
25
|
-
const handleOnClose = (resolve) => resolve(arr);
|
|
26
|
-
return this.readlineInterfacePromise(handleOnLine, handleOnClose);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.OutFileETL = OutFileETL;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OutFileLineModel = void 0;
|
|
4
|
-
class OutFileLineModel {
|
|
5
|
-
constructor(line) {
|
|
6
|
-
this.line = line;
|
|
7
|
-
}
|
|
8
|
-
toJSON() {
|
|
9
|
-
const arr = this.line.split('|');
|
|
10
|
-
const data = {};
|
|
11
|
-
arr.map((value, index) => {
|
|
12
|
-
data[`index-${index}`] = value;
|
|
13
|
-
});
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
|
-
validate() {
|
|
17
|
-
this.error = 'sample error';
|
|
18
|
-
}
|
|
19
|
-
get isValid() {
|
|
20
|
-
return !this.error;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.OutFileLineModel = OutFileLineModel;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
6
|
-
const enums_1 = require("../../todo/enums");
|
|
7
|
-
(0, globals_1.describe)('Azure Blob Storage library tests', () => {
|
|
8
|
-
let ServiceClientModule;
|
|
9
|
-
(0, globals_1.beforeEach)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME = 'testaccount';
|
|
11
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY = 'xJ/JhgA6Fq000x06IvHPZ47j7v00000/Y7XGDEHO8ra1ZCMXNkf2CkLPjZ36hQR80sHA1xZ/FpOA+AStP9bJXX==';
|
|
12
|
-
ServiceClientModule = yield Promise.resolve().then(() => tslib_1.__importStar(require('../../todo/service-client')));
|
|
13
|
-
}));
|
|
14
|
-
(0, globals_1.test)('Service Client should pass with arguments', () => {
|
|
15
|
-
const { serviceClient } = ServiceClientModule;
|
|
16
|
-
const AZURE_BLOB_STORAGE_ACCOUNT_NAME = process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME;
|
|
17
|
-
const AZURE_BLOB_STORAGE_ACCOUNT_KEY = process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY;
|
|
18
|
-
const credentials = {
|
|
19
|
-
credentials: new storage_blob_1.StorageSharedKeyCredential(AZURE_BLOB_STORAGE_ACCOUNT_NAME, AZURE_BLOB_STORAGE_ACCOUNT_KEY),
|
|
20
|
-
accountName: AZURE_BLOB_STORAGE_ACCOUNT_NAME,
|
|
21
|
-
};
|
|
22
|
-
const client = serviceClient(credentials);
|
|
23
|
-
(0, globals_1.expect)(client).toBeInstanceOf(storage_blob_1.BlobServiceClient);
|
|
24
|
-
});
|
|
25
|
-
(0, globals_1.test)('Service Client should pass without arguments', () => {
|
|
26
|
-
const { serviceClient } = ServiceClientModule;
|
|
27
|
-
const client = serviceClient();
|
|
28
|
-
(0, globals_1.expect)(client).toBeInstanceOf(storage_blob_1.BlobServiceClient);
|
|
29
|
-
});
|
|
30
|
-
(0, globals_1.test)('Container object should pass correct property instances ', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
const { Container } = yield Promise.resolve().then(() => tslib_1.__importStar(require('../../todo/container')));
|
|
32
|
-
const containerClient = new Container(enums_1.AzureBlobContainers.SIOCS_SOH);
|
|
33
|
-
(0, globals_1.expect)(containerClient.serviceClient).toBeInstanceOf(storage_blob_1.BlobServiceClient);
|
|
34
|
-
(0, globals_1.expect)(containerClient.containerClient).toBeInstanceOf(storage_blob_1.ContainerClient);
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
6
|
-
(0, globals_1.describe)('Blob tests', () => {
|
|
7
|
-
(0, globals_1.beforeAll)(() => {
|
|
8
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME = 'testaccount';
|
|
9
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY = 'XX/XXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXX+XXXXXXXXX==';
|
|
10
|
-
});
|
|
11
|
-
(0, globals_1.test)('blob.blobClient must instance of BlobClient', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
const { createBlobClient } = yield Promise.resolve().then(() => tslib_1.__importStar(require('../../todo/blob-client')));
|
|
13
|
-
const blobClient = createBlobClient('https://storageaccount.blob.core.windows.net/container/file.csv');
|
|
14
|
-
(0, globals_1.expect)(blobClient).toBeInstanceOf(storage_blob_1.BlobClient);
|
|
15
|
-
}));
|
|
16
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
const readline_1 = tslib_1.__importDefault(require("readline"));
|
|
6
|
-
const stream_1 = require("stream");
|
|
7
|
-
const BLOB_URL = 'https://alshayastaging.blob.core.windows.net/wip/item-master.csv';
|
|
8
|
-
(0, globals_1.describe)('Azure Blob Line Reader tests', () => {
|
|
9
|
-
let mockReader;
|
|
10
|
-
(0, globals_1.beforeEach)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME = 'testaccount';
|
|
12
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY = 'xJ/JhgA6Fq000x06IvHPZ47j7v00000/Y7XGDEHO8ra1ZCMXNkf2CkLPjZ36hQR80sHA1xZ/FpOA+AStP9bJXX==';
|
|
13
|
-
const { BlobLineReader } = yield Promise.resolve().then(() => tslib_1.__importStar(require('../../todo/blob-line-reader')));
|
|
14
|
-
class MockReader extends BlobLineReader {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(BLOB_URL);
|
|
17
|
-
}
|
|
18
|
-
readContent() {
|
|
19
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
try {
|
|
21
|
-
const data = yield this.readBlob();
|
|
22
|
-
return data;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
readBlob() {
|
|
30
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const arr = [];
|
|
32
|
-
const handleOnLine = (chunk) => {
|
|
33
|
-
arr.push(chunk);
|
|
34
|
-
};
|
|
35
|
-
const handleOnClose = (resolve) => resolve(arr);
|
|
36
|
-
return this.readlineInterfacePromise(handleOnLine, handleOnClose);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
mockReader = new MockReader();
|
|
41
|
-
}));
|
|
42
|
-
(0, globals_1.test)('getters should pass', () => {
|
|
43
|
-
(0, globals_1.expect)(mockReader.extension).toBe('csv');
|
|
44
|
-
(0, globals_1.expect)(mockReader.filename).toBe('item-master.csv');
|
|
45
|
-
});
|
|
46
|
-
(0, globals_1.test)('readlineInterface property must be undefined', () => {
|
|
47
|
-
(0, globals_1.expect)(mockReader.readlineInterface).toBe(undefined);
|
|
48
|
-
});
|
|
49
|
-
(0, globals_1.test)('readlineInterface should pass', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
var _a;
|
|
51
|
-
const reader = mockReader;
|
|
52
|
-
const mockStream = new stream_1.Readable();
|
|
53
|
-
mockStream.push('line1\nline2\nline3\n');
|
|
54
|
-
mockStream.push(null);
|
|
55
|
-
globals_1.jest.spyOn(reader, 'getReadableStream').mockResolvedValue(mockStream);
|
|
56
|
-
yield reader.createReadlineInterface();
|
|
57
|
-
reader.cleanUpPreviousListeners();
|
|
58
|
-
(_a = reader.readlineInterface) === null || _a === void 0 ? void 0 : _a.on('close', () => {
|
|
59
|
-
var _a;
|
|
60
|
-
(_a = reader.readlineInterface) === null || _a === void 0 ? void 0 : _a.close();
|
|
61
|
-
});
|
|
62
|
-
(0, globals_1.expect)(reader.readlineInterface).toBeInstanceOf(readline_1.default.Interface);
|
|
63
|
-
}));
|
|
64
|
-
(0, globals_1.test)('readlineInterface should call removeAllListeners on initialization and close on end of input stream', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
const reader = mockReader;
|
|
66
|
-
const mockStream = new stream_1.Readable();
|
|
67
|
-
mockStream.push('line1\nline2\nline3\n');
|
|
68
|
-
mockStream.push(null);
|
|
69
|
-
globals_1.jest.spyOn(reader, 'getReadableStream').mockResolvedValue(mockStream);
|
|
70
|
-
yield reader.createReadlineInterface();
|
|
71
|
-
const spyClose = globals_1.jest.spyOn(reader.readlineInterface, 'close');
|
|
72
|
-
const spyRemoveAllListeners = globals_1.jest.spyOn(reader.readlineInterface, 'removeAllListeners');
|
|
73
|
-
const result = yield reader.readBlob();
|
|
74
|
-
(0, globals_1.expect)(spyClose).toHaveBeenCalled();
|
|
75
|
-
(0, globals_1.expect)(spyRemoveAllListeners).toHaveBeenCalled();
|
|
76
|
-
(0, globals_1.expect)(result).toEqual(globals_1.expect.arrayContaining(['line1', 'line2', 'line3']));
|
|
77
|
-
}));
|
|
78
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
6
|
-
const blob_service_client_1 = require("../blob-service-client");
|
|
7
|
-
(0, globals_1.describe)('createServiceClient', () => {
|
|
8
|
-
const accountName = 'testaccount';
|
|
9
|
-
const accountKey = 'dGVzdGtleXRlc3RrZXl0ZXN0a2V5dGVzdGtleXRlc3RrZXl0ZXN0a2V5dGVzdGtleXRlc3RrZXk=';
|
|
10
|
-
(0, globals_1.test)('returns BlobServiceClient with sharedKey auth', () => {
|
|
11
|
-
const client = (0, blob_service_client_1.createServiceClient)({ type: 'sharedKey', accountName, accountKey });
|
|
12
|
-
(0, globals_1.expect)(client).toBeInstanceOf(storage_blob_1.BlobServiceClient);
|
|
13
|
-
(0, globals_1.expect)(client.url).toBe(`https://${accountName}.blob.core.windows.net/`);
|
|
14
|
-
});
|
|
15
|
-
(0, globals_1.test)('returns BlobServiceClient with connectionString auth', () => {
|
|
16
|
-
const connectionString = `DefaultEndpointsProtocol=https;AccountName=${accountName};AccountKey=${accountKey};EndpointSuffix=core.windows.net`;
|
|
17
|
-
const client = (0, blob_service_client_1.createServiceClient)({ type: 'connectionString', connectionString });
|
|
18
|
-
(0, globals_1.expect)(client).toBeInstanceOf(storage_blob_1.BlobServiceClient);
|
|
19
|
-
});
|
|
20
|
-
(0, globals_1.test)('returns BlobServiceClient with tokenCredential auth', () => {
|
|
21
|
-
const credential = { getToken: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return ({ token: 'test', expiresOnTimestamp: 0 }); }) };
|
|
22
|
-
const client = (0, blob_service_client_1.createServiceClient)({ type: 'tokenCredential', accountName, credential });
|
|
23
|
-
(0, globals_1.expect)(client).toBeInstanceOf(storage_blob_1.BlobServiceClient);
|
|
24
|
-
(0, globals_1.expect)(client.url).toBe(`https://${accountName}.blob.core.windows.net/`);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
6
|
-
(0, globals_1.describe)('Blob tests', () => {
|
|
7
|
-
(0, globals_1.beforeAll)(() => {
|
|
8
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME = 'testaccount';
|
|
9
|
-
process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY = 'XX/XXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXX+XXXXXXXXX==';
|
|
10
|
-
});
|
|
11
|
-
(0, globals_1.test)('blob.blobClient must instance of BlobClient', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
const { createBlockBlobClient } = yield Promise.resolve().then(() => tslib_1.__importStar(require('../../todo/block-blob-client')));
|
|
13
|
-
const blobClient = createBlockBlobClient('https://storageaccount.blob.core.windows.net/container/file.csv');
|
|
14
|
-
(0, globals_1.expect)(blobClient).toBeInstanceOf(storage_blob_1.BlockBlobClient);
|
|
15
|
-
}));
|
|
16
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("dotenv/config");
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
const out_file_line_model_1 = require("../examples/out-file-line-model");
|
|
6
|
-
(0, globals_1.describe)('Test examples', () => {
|
|
7
|
-
const line = '400346858677|129006063|2154-5464|MADRAS NICK STRIPE SHIRT|GREEN|MEDIUM|106|AME_MENS APPAREL|9|015-MENS SHIRTS|7|SS FASHION SHIRTS|1.7334';
|
|
8
|
-
const model = new out_file_line_model_1.OutFileLineModel(line);
|
|
9
|
-
(0, globals_1.test)('toJSON should pass', () => {
|
|
10
|
-
const result = model.toJSON();
|
|
11
|
-
const exist = !!result['index-1'];
|
|
12
|
-
(0, globals_1.expect)(exist).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
(0, globals_1.test)('validate should pass', () => {
|
|
15
|
-
model.error = 'sample error';
|
|
16
|
-
(0, globals_1.expect)(model.isValid).toBeFalsy();
|
|
17
|
-
model.error = undefined;
|
|
18
|
-
(0, globals_1.expect)(model.isValid).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
});
|
package/dist/todo/blob-client.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBlobClient = createBlobClient;
|
|
4
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
-
function createBlobClient(blobUrl) {
|
|
6
|
-
const credentials = new storage_blob_1.StorageSharedKeyCredential(process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME, process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY);
|
|
7
|
-
return new storage_blob_1.BlobClient(blobUrl, credentials);
|
|
8
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import readline from 'readline';
|
|
2
|
-
import { File } from 'list-data-reader';
|
|
3
|
-
import { BlobClient } from '@azure/storage-blob';
|
|
4
|
-
export interface ReadlineInterfaceCloseHandler {
|
|
5
|
-
(resolve: Function): void;
|
|
6
|
-
}
|
|
7
|
-
export interface ReadlineInterfaceErrorHandler {
|
|
8
|
-
(reject: Function): void;
|
|
9
|
-
}
|
|
10
|
-
export interface ReadlineInterfaceLineHandler {
|
|
11
|
-
(...args: any): void;
|
|
12
|
-
}
|
|
13
|
-
export declare abstract class BlobLineReader {
|
|
14
|
-
file: File;
|
|
15
|
-
readlineInterface?: readline.Interface;
|
|
16
|
-
constructor(url: string);
|
|
17
|
-
get url(): string;
|
|
18
|
-
get extension(): string;
|
|
19
|
-
get filename(): string;
|
|
20
|
-
get sourceBlobClient(): BlobClient;
|
|
21
|
-
getReadableStream(): Promise<NodeJS.ReadableStream | undefined>;
|
|
22
|
-
createReadlineInterface(): Promise<void>;
|
|
23
|
-
cleanUpPreviousListeners(): void;
|
|
24
|
-
readlineInterfacePromise(onLineHandler: ReadlineInterfaceLineHandler, onCloseHandler: ReadlineInterfaceCloseHandler): Promise<any>;
|
|
25
|
-
abstract readBlob(): Promise<any> | undefined;
|
|
26
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlobLineReader = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const readline_1 = tslib_1.__importDefault(require("readline"));
|
|
6
|
-
const list_data_reader_1 = require("list-data-reader");
|
|
7
|
-
const blob_client_1 = require("./blob-client");
|
|
8
|
-
class BlobLineReader {
|
|
9
|
-
constructor(url) {
|
|
10
|
-
this.file = new list_data_reader_1.File(url);
|
|
11
|
-
}
|
|
12
|
-
get url() {
|
|
13
|
-
return this.file.filepath;
|
|
14
|
-
}
|
|
15
|
-
get extension() {
|
|
16
|
-
return this.file.extension;
|
|
17
|
-
}
|
|
18
|
-
get filename() {
|
|
19
|
-
return this.file.filename;
|
|
20
|
-
}
|
|
21
|
-
get sourceBlobClient() {
|
|
22
|
-
return (0, blob_client_1.createBlobClient)(this.url);
|
|
23
|
-
}
|
|
24
|
-
getReadableStream() {
|
|
25
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const downloadBlockBlobResponse = yield this.sourceBlobClient.download(0);
|
|
27
|
-
return downloadBlockBlobResponse.readableStreamBody;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
createReadlineInterface() {
|
|
31
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const readableStream = yield this.getReadableStream();
|
|
33
|
-
if (!readableStream)
|
|
34
|
-
return;
|
|
35
|
-
this.readlineInterface = readline_1.default.createInterface({
|
|
36
|
-
input: readableStream,
|
|
37
|
-
crlfDelay: Infinity,
|
|
38
|
-
terminal: false
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
cleanUpPreviousListeners() {
|
|
43
|
-
if (!this.readlineInterface)
|
|
44
|
-
return;
|
|
45
|
-
this.readlineInterface.removeAllListeners('line');
|
|
46
|
-
this.readlineInterface.removeAllListeners('close');
|
|
47
|
-
}
|
|
48
|
-
readlineInterfacePromise(onLineHandler, onCloseHandler) {
|
|
49
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
if (!this.readlineInterface) {
|
|
51
|
-
yield this.createReadlineInterface();
|
|
52
|
-
}
|
|
53
|
-
this.cleanUpPreviousListeners();
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
try {
|
|
57
|
-
(_a = this.readlineInterface) === null || _a === void 0 ? void 0 : _a.on('line', onLineHandler);
|
|
58
|
-
(_b = this.readlineInterface) === null || _b === void 0 ? void 0 : _b.on('close', () => onCloseHandler(resolve));
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
reject(e);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.BlobLineReader = BlobLineReader;
|
package/dist/todo/blob.d.ts
DELETED
package/dist/todo/blob.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Blob = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
class Blob {
|
|
6
|
-
constructor(blobName, containerClient) {
|
|
7
|
-
this.blobClient = containerClient.getBlobClient(blobName);
|
|
8
|
-
}
|
|
9
|
-
delete() {
|
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
const response = yield this.blobClient.delete({
|
|
12
|
-
deleteSnapshots: 'include'
|
|
13
|
-
});
|
|
14
|
-
return response;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.Blob = Blob;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBlockBlobClient = createBlockBlobClient;
|
|
4
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
5
|
-
function createBlockBlobClient(blobUrl) {
|
|
6
|
-
const credentials = new storage_blob_1.StorageSharedKeyCredential(process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME, process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY);
|
|
7
|
-
return new storage_blob_1.BlockBlobClient(blobUrl, credentials);
|
|
8
|
-
}
|
package/dist/todo/container.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BlobClient, BlobItem, BlobServiceClient, ContainerClient, FilterBlobItem } from '@azure/storage-blob';
|
|
2
|
-
export declare class Container {
|
|
3
|
-
serviceClient: BlobServiceClient;
|
|
4
|
-
containerClient: ContainerClient;
|
|
5
|
-
constructor(containerName: string);
|
|
6
|
-
listBlobsFlat(): import("@azure/core-paging").PagedAsyncIterableIterator<BlobItem, import("@azure/storage-blob").ContainerListBlobFlatSegmentResponse, import("@azure/core-paging").PageSettings>;
|
|
7
|
-
listByTag(query: string): import("@azure/core-paging").PagedAsyncIterableIterator<FilterBlobItem, import("@azure/storage-blob").ContainerFindBlobsByTagsSegmentResponse, import("@azure/core-paging").PageSettings>;
|
|
8
|
-
createBlobClients(blobs: BlobItem[] | FilterBlobItem[]): BlobClient[];
|
|
9
|
-
blobClient(blobName: string): BlobClient;
|
|
10
|
-
}
|
package/dist/todo/container.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Container = void 0;
|
|
4
|
-
const service_client_1 = require("./service-client");
|
|
5
|
-
class Container {
|
|
6
|
-
constructor(containerName) {
|
|
7
|
-
this.serviceClient = (0, service_client_1.serviceClient)();
|
|
8
|
-
this.containerClient = this.serviceClient.getContainerClient(containerName);
|
|
9
|
-
}
|
|
10
|
-
listBlobsFlat() {
|
|
11
|
-
return this.containerClient.listBlobsFlat();
|
|
12
|
-
}
|
|
13
|
-
listByTag(query) {
|
|
14
|
-
return this.containerClient.findBlobsByTags(query);
|
|
15
|
-
}
|
|
16
|
-
createBlobClients(blobs) {
|
|
17
|
-
return blobs.map(blob => this.containerClient.getBlobClient(blob.name));
|
|
18
|
-
}
|
|
19
|
-
blobClient(blobName) {
|
|
20
|
-
return this.containerClient.getBlobClient(blobName);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.Container = Container;
|
package/dist/todo/enums.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare enum AzureBlobContainers {
|
|
2
|
-
DATASCAN_ITEM_MASTER = "datascan-item-master",
|
|
3
|
-
DATASCAN_COUNT_FILE = "datascan-count-files",
|
|
4
|
-
DATASCAN_SOH = "datascan-soh",
|
|
5
|
-
GOLD_ITEM_MASTER = "gold-item-master",
|
|
6
|
-
GOLD_COUNT_FILE = "gold-count-files",
|
|
7
|
-
GOLD_SOH = "gold-soh",
|
|
8
|
-
RMS_ITEM_MASTER = "rms-item-master",
|
|
9
|
-
RMS_COUNT_FILE = "rms-count-files",
|
|
10
|
-
RMS_SOH = "rms-soh",
|
|
11
|
-
SIOCS_ITEM_MASTER = "siocs-item-master",
|
|
12
|
-
SIOCS_COUNT_FILE = "siocs-count-files",
|
|
13
|
-
SIOCS_SOH = "siocs-soh",
|
|
14
|
-
WIP = "wip"
|
|
15
|
-
}
|
|
16
|
-
export declare enum WIPContainerStatus {
|
|
17
|
-
TO_PROCESS = "to_process",
|
|
18
|
-
WAITING_TO_PROCESS = "waiting_to_process",
|
|
19
|
-
WIP = "wip",
|
|
20
|
-
VALIDATED = "validated",
|
|
21
|
-
REJECTED = "rejected"
|
|
22
|
-
}
|
|
23
|
-
export declare enum FileGeneratedStatus {
|
|
24
|
-
GENERATED = "1",
|
|
25
|
-
NOT_GENERATED = "0",
|
|
26
|
-
LOCALLY = "2"
|
|
27
|
-
}
|
|
28
|
-
export declare enum DatascanSentStatus {
|
|
29
|
-
TRUE = "1",
|
|
30
|
-
FALSE = "0"
|
|
31
|
-
}
|
package/dist/todo/enums.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatascanSentStatus = exports.FileGeneratedStatus = exports.WIPContainerStatus = exports.AzureBlobContainers = void 0;
|
|
4
|
-
var AzureBlobContainers;
|
|
5
|
-
(function (AzureBlobContainers) {
|
|
6
|
-
AzureBlobContainers["DATASCAN_ITEM_MASTER"] = "datascan-item-master";
|
|
7
|
-
AzureBlobContainers["DATASCAN_COUNT_FILE"] = "datascan-count-files";
|
|
8
|
-
AzureBlobContainers["DATASCAN_SOH"] = "datascan-soh";
|
|
9
|
-
AzureBlobContainers["GOLD_ITEM_MASTER"] = "gold-item-master";
|
|
10
|
-
AzureBlobContainers["GOLD_COUNT_FILE"] = "gold-count-files";
|
|
11
|
-
AzureBlobContainers["GOLD_SOH"] = "gold-soh";
|
|
12
|
-
AzureBlobContainers["RMS_ITEM_MASTER"] = "rms-item-master";
|
|
13
|
-
AzureBlobContainers["RMS_COUNT_FILE"] = "rms-count-files";
|
|
14
|
-
AzureBlobContainers["RMS_SOH"] = "rms-soh";
|
|
15
|
-
AzureBlobContainers["SIOCS_ITEM_MASTER"] = "siocs-item-master";
|
|
16
|
-
AzureBlobContainers["SIOCS_COUNT_FILE"] = "siocs-count-files";
|
|
17
|
-
AzureBlobContainers["SIOCS_SOH"] = "siocs-soh";
|
|
18
|
-
AzureBlobContainers["WIP"] = "wip";
|
|
19
|
-
})(AzureBlobContainers || (exports.AzureBlobContainers = AzureBlobContainers = {}));
|
|
20
|
-
var WIPContainerStatus;
|
|
21
|
-
(function (WIPContainerStatus) {
|
|
22
|
-
WIPContainerStatus["TO_PROCESS"] = "to_process";
|
|
23
|
-
WIPContainerStatus["WAITING_TO_PROCESS"] = "waiting_to_process";
|
|
24
|
-
WIPContainerStatus["WIP"] = "wip";
|
|
25
|
-
WIPContainerStatus["VALIDATED"] = "validated";
|
|
26
|
-
WIPContainerStatus["REJECTED"] = "rejected";
|
|
27
|
-
})(WIPContainerStatus || (exports.WIPContainerStatus = WIPContainerStatus = {}));
|
|
28
|
-
var FileGeneratedStatus;
|
|
29
|
-
(function (FileGeneratedStatus) {
|
|
30
|
-
FileGeneratedStatus["GENERATED"] = "1";
|
|
31
|
-
FileGeneratedStatus["NOT_GENERATED"] = "0";
|
|
32
|
-
FileGeneratedStatus["LOCALLY"] = "2";
|
|
33
|
-
})(FileGeneratedStatus || (exports.FileGeneratedStatus = FileGeneratedStatus = {}));
|
|
34
|
-
var DatascanSentStatus;
|
|
35
|
-
(function (DatascanSentStatus) {
|
|
36
|
-
DatascanSentStatus["TRUE"] = "1";
|
|
37
|
-
DatascanSentStatus["FALSE"] = "0";
|
|
38
|
-
})(DatascanSentStatus || (exports.DatascanSentStatus = DatascanSentStatus = {}));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BlobServiceClient, StorageSharedKeyCredential } from '@azure/storage-blob';
|
|
2
|
-
export interface ServiceClientCredentials {
|
|
3
|
-
credentials: StorageSharedKeyCredential;
|
|
4
|
-
accountName: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function getDefaultOptions(): ServiceClientCredentials;
|
|
7
|
-
export declare function serviceClient(options?: ServiceClientCredentials): BlobServiceClient;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultOptions = getDefaultOptions;
|
|
4
|
-
exports.serviceClient = serviceClient;
|
|
5
|
-
const storage_blob_1 = require("@azure/storage-blob");
|
|
6
|
-
function getDefaultOptions() {
|
|
7
|
-
const options = {
|
|
8
|
-
credentials: new storage_blob_1.StorageSharedKeyCredential(process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME, process.env.AZURE_BLOB_STORAGE_ACCOUNT_KEY),
|
|
9
|
-
accountName: process.env.AZURE_BLOB_STORAGE_ACCOUNT_NAME
|
|
10
|
-
};
|
|
11
|
-
return options;
|
|
12
|
-
}
|
|
13
|
-
function buildBlobServiceClient(options) {
|
|
14
|
-
return new storage_blob_1.BlobServiceClient(`https://${options.accountName}.blob.core.windows.net`, options.credentials);
|
|
15
|
-
}
|
|
16
|
-
function buildBlobClient(blobUrl, options) {
|
|
17
|
-
return new storage_blob_1.BlobClient(blobUrl, options.credentials);
|
|
18
|
-
}
|
|
19
|
-
function serviceClient(options) {
|
|
20
|
-
const serviceClient = buildBlobServiceClient(options ? options : getDefaultOptions());
|
|
21
|
-
return serviceClient;
|
|
22
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|