skyeye-svc-common-utils 1.0.7 → 1.0.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/index.d.ts +24 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/apiResponse.d.ts +7 -0
- package/dist/interfaces/apiResponse.js +3 -0
- package/dist/interfaces/apiResponse.js.map +1 -0
- package/dist/interfaces/index.d.ts +6 -0
- package/dist/interfaces/index.js +10 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/pagination.d.ts +6 -0
- package/dist/interfaces/pagination.js +12 -0
- package/dist/interfaces/pagination.js.map +1 -0
- package/dist/interfaces/serviceResponse.d.ts +8 -0
- package/dist/interfaces/serviceResponse.js +3 -0
- package/dist/interfaces/serviceResponse.js.map +1 -0
- package/dist/interfaces/subcriptionFeaturePermissionModel.d.ts +8 -0
- package/dist/interfaces/subcriptionFeaturePermissionModel.js +14 -0
- package/dist/interfaces/subcriptionFeaturePermissionModel.js.map +1 -0
- package/dist/interfaces/userInfo.d.ts +17 -0
- package/dist/interfaces/userInfo.js +21 -0
- package/dist/interfaces/userInfo.js.map +1 -0
- package/dist/lib/azure/azureBlobStorage.d.ts +4 -0
- package/dist/lib/azure/azureBlobStorage.js +135 -0
- package/dist/lib/azure/azureBlobStorage.js.map +1 -0
- package/dist/lib/azure/azureKeyVault.d.ts +1 -0
- package/dist/lib/azure/azureKeyVault.js +27 -0
- package/dist/lib/azure/azureKeyVault.js.map +1 -0
- package/dist/lib/azure/azureServiceBusQueue.d.ts +1 -0
- package/dist/lib/azure/azureServiceBusQueue.js +42 -0
- package/dist/lib/azure/azureServiceBusQueue.js.map +1 -0
- package/dist/lib/azure/azureStorageQueue.d.ts +1 -0
- package/dist/lib/azure/azureStorageQueue.js +26 -0
- package/dist/lib/azure/azureStorageQueue.js.map +1 -0
- package/dist/lib/azure/azureTableStorage.d.ts +4 -0
- package/dist/lib/azure/azureTableStorage.js +66 -0
- package/dist/lib/azure/azureTableStorage.js.map +1 -0
- package/dist/lib/httpClient.d.ts +1 -0
- package/dist/lib/httpClient.js +32 -0
- package/dist/lib/httpClient.js.map +1 -0
- package/dist/lib/redisClient.d.ts +45 -0
- package/dist/lib/redisClient.js +148 -0
- package/dist/lib/redisClient.js.map +1 -0
- package/dist/lib/sendGridClient.d.ts +22 -0
- package/dist/lib/sendGridClient.js +55 -0
- package/dist/lib/sendGridClient.js.map +1 -0
- package/dist/models/baseControllerParameter.d.ts +9 -0
- package/dist/models/baseControllerParameter.js +31 -0
- package/dist/models/baseControllerParameter.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +6 -0
- package/dist/models/index.js.map +1 -0
- package/dist/utils/appConfig.d.ts +32 -0
- package/dist/utils/appConfig.js +44 -0
- package/dist/utils/appConfig.js.map +1 -0
- package/dist/utils/appConst.d.ts +113 -0
- package/dist/utils/appConst.js +137 -0
- package/dist/utils/appConst.js.map +1 -0
- package/dist/utils/authentication/auth.d.ts +2 -0
- package/dist/utils/authentication/auth.js +144 -0
- package/dist/utils/authentication/auth.js.map +1 -0
- package/dist/utils/authentication/role.d.ts +7 -0
- package/dist/utils/authentication/role.js +137 -0
- package/dist/utils/authentication/role.js.map +1 -0
- package/dist/utils/baseClass/baseController.d.ts +12 -0
- package/dist/utils/baseClass/baseController.js +176 -0
- package/dist/utils/baseClass/baseController.js.map +1 -0
- package/dist/utils/baseClass/baseService.d.ts +7 -0
- package/dist/utils/baseClass/baseService.js +11 -0
- package/dist/utils/baseClass/baseService.js.map +1 -0
- package/dist/utils/commonUtils/appUtils.d.ts +10 -0
- package/dist/utils/commonUtils/appUtils.js +128 -0
- package/dist/utils/commonUtils/appUtils.js.map +1 -0
- package/dist/utils/commonUtils/cronUtils.d.ts +9 -0
- package/dist/utils/commonUtils/cronUtils.js +32 -0
- package/dist/utils/commonUtils/cronUtils.js.map +1 -0
- package/dist/utils/commonUtils/index.d.ts +5 -0
- package/dist/utils/commonUtils/index.js +18 -0
- package/dist/utils/commonUtils/index.js.map +1 -0
- package/dist/utils/commonUtils/jwtUtils.d.ts +3 -0
- package/dist/utils/commonUtils/jwtUtils.js +75 -0
- package/dist/utils/commonUtils/jwtUtils.js.map +1 -0
- package/dist/utils/commonUtils/responseUtils.d.ts +7 -0
- package/dist/utils/commonUtils/responseUtils.js +66 -0
- package/dist/utils/commonUtils/responseUtils.js.map +1 -0
- package/dist/utils/commonUtils/validation.d.ts +6 -0
- package/dist/utils/commonUtils/validation.js +92 -0
- package/dist/utils/commonUtils/validation.js.map +1 -0
- package/dist/utils/documentation/swagger.d.ts +1 -0
- package/dist/utils/documentation/swagger.js +37 -0
- package/dist/utils/documentation/swagger.js.map +1 -0
- package/dist/utils/logger/logger.d.ts +1 -0
- package/dist/utils/logger/logger.js +29 -0
- package/dist/utils/logger/logger.js.map +1 -0
- package/dist/utils/logger/morganLogger.d.ts +4 -0
- package/dist/utils/logger/morganLogger.js +27 -0
- package/dist/utils/logger/morganLogger.js.map +1 -0
- package/dist/utils/middleware/handleError.d.ts +2 -0
- package/dist/utils/middleware/handleError.js +12 -0
- package/dist/utils/middleware/handleError.js.map +1 -0
- package/dist/utils/middleware/isPublicUser.d.ts +2 -0
- package/dist/utils/middleware/isPublicUser.js +35 -0
- package/dist/utils/middleware/isPublicUser.js.map +1 -0
- package/dist/utils/middleware/overwriteConst.d.ts +1 -0
- package/dist/utils/middleware/overwriteConst.js +84 -0
- package/dist/utils/middleware/overwriteConst.js.map +1 -0
- package/dist/utils/middleware/startdbConnection.d.ts +1 -0
- package/dist/utils/middleware/startdbConnection.js +28 -0
- package/dist/utils/middleware/startdbConnection.js.map +1 -0
- package/dist/utils/monitoring/apm.d.ts +6 -0
- package/dist/utils/monitoring/apm.js +95 -0
- package/dist/utils/monitoring/apm.js.map +1 -0
- package/package.json +2 -2
- package/src/utils/middleware/overwriteConst.ts +3 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './utils/appConfig';
|
|
2
|
+
export * from './utils/appConst';
|
|
3
|
+
export * from './utils/commonUtils';
|
|
4
|
+
export * from './utils/authentication/auth';
|
|
5
|
+
export * from './utils/logger/logger';
|
|
6
|
+
export { default as morganLogger } from './utils/logger/morganLogger';
|
|
7
|
+
export * from './utils/middleware/handleError';
|
|
8
|
+
export * from './utils/middleware/isPublicUser';
|
|
9
|
+
export * from './utils/middleware/overwriteConst';
|
|
10
|
+
export * from './utils/middleware/startdbConnection';
|
|
11
|
+
export * from './utils/baseClass/baseController';
|
|
12
|
+
export * from './utils/baseClass/baseService';
|
|
13
|
+
export * from './interfaces/index';
|
|
14
|
+
export * from './lib/azure/azureKeyVault';
|
|
15
|
+
export * from './lib/azure/azureStorageQueue';
|
|
16
|
+
export * from './lib/azure/azureServiceBusQueue';
|
|
17
|
+
export * from './lib/azure/azureTableStorage';
|
|
18
|
+
export * from './lib/azure/azureBlobStorage';
|
|
19
|
+
export * from './utils/documentation/swagger';
|
|
20
|
+
export * from './lib/httpClient';
|
|
21
|
+
export * from './utils/monitoring/apm';
|
|
22
|
+
export * from './models/baseControllerParameter';
|
|
23
|
+
export * from './lib/redisClient';
|
|
24
|
+
export * from './lib/sendGridClient';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./utils/appConfig"), exports);
|
|
14
|
+
__exportStar(require("./utils/appConst"), exports);
|
|
15
|
+
__exportStar(require("./utils/commonUtils"), exports);
|
|
16
|
+
__exportStar(require("./utils/authentication/auth"), exports);
|
|
17
|
+
__exportStar(require("./utils/logger/logger"), exports);
|
|
18
|
+
var morganLogger_1 = require("./utils/logger/morganLogger");
|
|
19
|
+
Object.defineProperty(exports, "morganLogger", { enumerable: true, get: function () { return morganLogger_1.default; } });
|
|
20
|
+
__exportStar(require("./utils/middleware/handleError"), exports);
|
|
21
|
+
__exportStar(require("./utils/middleware/isPublicUser"), exports);
|
|
22
|
+
__exportStar(require("./utils/middleware/overwriteConst"), exports);
|
|
23
|
+
__exportStar(require("./utils/middleware/startdbConnection"), exports);
|
|
24
|
+
__exportStar(require("./utils/baseClass/baseController"), exports);
|
|
25
|
+
__exportStar(require("./utils/baseClass/baseService"), exports);
|
|
26
|
+
__exportStar(require("./interfaces/index"), exports);
|
|
27
|
+
__exportStar(require("./lib/azure/azureKeyVault"), exports);
|
|
28
|
+
__exportStar(require("./lib/azure/azureStorageQueue"), exports);
|
|
29
|
+
__exportStar(require("./lib/azure/azureServiceBusQueue"), exports);
|
|
30
|
+
__exportStar(require("./lib/azure/azureTableStorage"), exports);
|
|
31
|
+
__exportStar(require("./lib/azure/azureBlobStorage"), exports);
|
|
32
|
+
__exportStar(require("./utils/documentation/swagger"), exports);
|
|
33
|
+
__exportStar(require("./lib/httpClient"), exports);
|
|
34
|
+
__exportStar(require("./utils/monitoring/apm"), exports);
|
|
35
|
+
__exportStar(require("./models/baseControllerParameter"), exports);
|
|
36
|
+
__exportStar(require("./lib/redisClient"), exports);
|
|
37
|
+
__exportStar(require("./lib/sendGridClient"), exports);
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,sDAAoC;AACpC,8DAA4C;AAC5C,wDAAsC;AACtC,4DAAsE;AAA7D,4GAAA,OAAO,OAAgB;AAChC,iEAA+C;AAC/C,kEAAgD;AAChD,oEAAkD;AAClD,uEAAqD;AACrD,mEAAiD;AACjD,gEAA8C;AAC9C,qDAAmC;AACnC,4DAA0C;AAC1C,gEAA8C;AAC9C,mEAAiD;AACjD,gEAA8C;AAC9C,+DAA6C;AAC7C,gEAA8C;AAC9C,mDAAiC;AACjC,yDAAuC;AACvC,mEAAiD;AACjD,oDAAkC;AAClC,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiResponse.js","sourceRoot":"","sources":["../../src/interfaces/apiResponse.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ApiResponse } from './apiResponse';
|
|
2
|
+
import { ServiceResponse } from './serviceResponse';
|
|
3
|
+
import { UserInfo } from './userInfo';
|
|
4
|
+
import { Pagination } from './pagination';
|
|
5
|
+
import { SubcriptionFeaturePermissionModel } from './subcriptionFeaturePermissionModel';
|
|
6
|
+
export { ApiResponse, ServiceResponse, UserInfo, Pagination, SubcriptionFeaturePermissionModel };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubcriptionFeaturePermissionModel = exports.Pagination = exports.UserInfo = void 0;
|
|
4
|
+
const userInfo_1 = require("./userInfo");
|
|
5
|
+
Object.defineProperty(exports, "UserInfo", { enumerable: true, get: function () { return userInfo_1.UserInfo; } });
|
|
6
|
+
const pagination_1 = require("./pagination");
|
|
7
|
+
Object.defineProperty(exports, "Pagination", { enumerable: true, get: function () { return pagination_1.Pagination; } });
|
|
8
|
+
const subcriptionFeaturePermissionModel_1 = require("./subcriptionFeaturePermissionModel");
|
|
9
|
+
Object.defineProperty(exports, "SubcriptionFeaturePermissionModel", { enumerable: true, get: function () { return subcriptionFeaturePermissionModel_1.SubcriptionFeaturePermissionModel; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAEA,yCAAsC;AAMlC,yFANK,mBAAQ,OAML;AALZ,6CAA0C;AAMtC,2FANK,uBAAU,OAML;AALd,2FAAwF;AAMpF,kHANK,qEAAiC,OAML"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pagination = void 0;
|
|
4
|
+
class Pagination {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.skip = 0;
|
|
7
|
+
this.take = 20;
|
|
8
|
+
this.order = null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.Pagination = Pagination;
|
|
12
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/interfaces/pagination.ts"],"names":[],"mappings":";;;AACA,MAAa,UAAU;IAInB;QACI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ;AATD,gCASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceResponse.js","sourceRoot":"","sources":["../../src/interfaces/serviceResponse.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubcriptionFeaturePermissionModel = void 0;
|
|
4
|
+
class SubcriptionFeaturePermissionModel {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.organisationGuid = null;
|
|
7
|
+
this.organisationName = null;
|
|
8
|
+
this.organisationStatus = null;
|
|
9
|
+
this.permissionList = new Array();
|
|
10
|
+
this.featureList = new Array();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SubcriptionFeaturePermissionModel = SubcriptionFeaturePermissionModel;
|
|
14
|
+
//# sourceMappingURL=subcriptionFeaturePermissionModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subcriptionFeaturePermissionModel.js","sourceRoot":"","sources":["../../src/interfaces/subcriptionFeaturePermissionModel.ts"],"names":[],"mappings":";;;AAAA,MAAa,iCAAiC;IAY1C;QACI,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,KAAK,EAAU,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,EAAU,CAAC;IAC3C,CAAC;CACJ;AAnBD,8EAmBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SubcriptionFeaturePermissionModel } from './subcriptionFeaturePermissionModel';
|
|
2
|
+
export declare class UserInfo {
|
|
3
|
+
userName: string;
|
|
4
|
+
email: string;
|
|
5
|
+
contactNumber: string;
|
|
6
|
+
userGuid: string;
|
|
7
|
+
firstName: string;
|
|
8
|
+
lastName: string;
|
|
9
|
+
subcriptionFeaturePermissionModel: SubcriptionFeaturePermissionModel[];
|
|
10
|
+
requestOrganisation: string;
|
|
11
|
+
isPublicUser: boolean;
|
|
12
|
+
internalUsage: boolean;
|
|
13
|
+
isApiUser: boolean;
|
|
14
|
+
exp: number;
|
|
15
|
+
subKeys: string[];
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserInfo = void 0;
|
|
4
|
+
class UserInfo {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.userName = null;
|
|
7
|
+
this.email = null;
|
|
8
|
+
this.userGuid = null;
|
|
9
|
+
this.firstName = null;
|
|
10
|
+
this.lastName = null;
|
|
11
|
+
this.isPublicUser = null;
|
|
12
|
+
this.internalUsage = null;
|
|
13
|
+
this.isApiUser = null;
|
|
14
|
+
this.subcriptionFeaturePermissionModel = new Array();
|
|
15
|
+
this.requestOrganisation = null;
|
|
16
|
+
this.exp = Math.floor(Date.now() / 1000) + (60 * 60);
|
|
17
|
+
this.subKeys = new Array();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.UserInfo = UserInfo;
|
|
21
|
+
//# sourceMappingURL=userInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userInfo.js","sourceRoot":"","sources":["../../src/interfaces/userInfo.ts"],"names":[],"mappings":";;;AAEA,MAAa,QAAQ;IA2BjB;QACI,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,iCAAiC,GAAG,IAAI,KAAK,EAAqC,CAAC;QACxF,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,KAAK,EAAU,CAAC;IACvC,CAAC;CACJ;AAzCD,4BAyCC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function uploadFile(containerName: string, fileName: string, content: any, connectionKey?: string): Promise<string>;
|
|
2
|
+
export declare function listFile(containerName: string, prefix?: string, connectionKey?: string): Promise<string[]>;
|
|
3
|
+
export declare function downloadFile(containerName: string, blobName: string, connectionKey?: string): Promise<string>;
|
|
4
|
+
export declare function generateSasUrl(containerName: string, fileName: string, connectionKey?: string): Promise<string>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.generateSasUrl = exports.downloadFile = exports.listFile = exports.uploadFile = void 0;
|
|
20
|
+
const { BlobServiceClient, generateBlobSASQueryParameters, StorageSharedKeyCredential, BlobSASPermissions } = require('@azure/storage-blob');
|
|
21
|
+
const appConfig_1 = require("../../utils/appConfig");
|
|
22
|
+
const azureKeyVault_1 = require("./azureKeyVault");
|
|
23
|
+
const logger_1 = require("../../utils/logger/logger");
|
|
24
|
+
function uploadFile(containerName, fileName, content, connectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
logger_1.logger.info(`start blobstorage.uploadFile : ${containerName} ; ${fileName}`);
|
|
27
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(connectionKey);
|
|
28
|
+
const blobServiceClient = BlobServiceClient.fromConnectionString(STORAGE_CONNECTION_STRING);
|
|
29
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
30
|
+
const blockBlobClient = containerClient.getBlockBlobClient(fileName);
|
|
31
|
+
let jsonStr = JSON.stringify(content);
|
|
32
|
+
const uploadBlobResponse = yield blockBlobClient.upload(jsonStr, jsonStr.length);
|
|
33
|
+
logger_1.logger.info(`end blobstorage.uploadFile : ${uploadBlobResponse.requestId}`);
|
|
34
|
+
return uploadBlobResponse.requestId;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.uploadFile = uploadFile;
|
|
38
|
+
function listFile(containerName, prefix = "", connectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
39
|
+
var e_1, _a;
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
logger_1.logger.info(`start blobstorage.listFile : ${containerName} ; ${prefix}`);
|
|
42
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(connectionKey);
|
|
43
|
+
const blobServiceClient = BlobServiceClient.fromConnectionString(STORAGE_CONNECTION_STRING);
|
|
44
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
45
|
+
let option = {
|
|
46
|
+
prefix: prefix
|
|
47
|
+
};
|
|
48
|
+
let fileNames = [];
|
|
49
|
+
try {
|
|
50
|
+
for (var _b = __asyncValues(containerClient.listBlobsFlat(option)), _c; _c = yield _b.next(), !_c.done;) {
|
|
51
|
+
const blob = _c.value;
|
|
52
|
+
fileNames.push(blob.name);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e_1) throw e_1.error; }
|
|
61
|
+
}
|
|
62
|
+
logger_1.logger.info(`end blobstorage.listFile : ${fileNames.length}`);
|
|
63
|
+
return fileNames;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.listFile = listFile;
|
|
67
|
+
function downloadFile(containerName, blobName, connectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
logger_1.logger.info(`start blobstorage.downloadFile : ${containerName} ; ${blobName}`);
|
|
70
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(connectionKey);
|
|
71
|
+
const blobServiceClient = BlobServiceClient.fromConnectionString(STORAGE_CONNECTION_STRING);
|
|
72
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
73
|
+
const blobClient = containerClient.getBlobClient(blobName);
|
|
74
|
+
const downloadResponse = yield blobClient.download();
|
|
75
|
+
const downloaded = yield streamToBuffer(downloadResponse.readableStreamBody);
|
|
76
|
+
const downloadString = downloaded.toString();
|
|
77
|
+
logger_1.logger.info(`end blobstorage.downloadFile : ${downloadString}`);
|
|
78
|
+
return downloadString;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.downloadFile = downloadFile;
|
|
82
|
+
function streamToBuffer(readableStream) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const chunks = [];
|
|
86
|
+
readableStream.on("data", (data) => {
|
|
87
|
+
chunks.push(data instanceof Buffer ? data : Buffer.from(data));
|
|
88
|
+
});
|
|
89
|
+
readableStream.on("end", () => {
|
|
90
|
+
resolve(Buffer.concat(chunks));
|
|
91
|
+
});
|
|
92
|
+
readableStream.on("error", reject);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function generateSasUrl(containerName, fileName, connectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
logger_1.logger.info(`start blobstorage.generateSasUrl : ${containerName} ; ${fileName}`);
|
|
99
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(connectionKey);
|
|
100
|
+
let keys = STORAGE_CONNECTION_STRING.split(';');
|
|
101
|
+
let accountName = "";
|
|
102
|
+
let accountKey = "";
|
|
103
|
+
let endpointSuffix = "";
|
|
104
|
+
let protocol = "";
|
|
105
|
+
for (let key of keys) {
|
|
106
|
+
if (key.startsWith("AccountName")) {
|
|
107
|
+
accountName = key.split("=")[1];
|
|
108
|
+
}
|
|
109
|
+
else if (key.startsWith("AccountKey")) {
|
|
110
|
+
accountKey = key.split("=")[1];
|
|
111
|
+
}
|
|
112
|
+
else if (key.startsWith("DefaultEndpointsProtocol")) {
|
|
113
|
+
protocol = key.split("=")[1];
|
|
114
|
+
}
|
|
115
|
+
else if (key.startsWith("EndpointSuffix")) {
|
|
116
|
+
endpointSuffix = key.split("=")[1];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
var startDate = new Date();
|
|
120
|
+
startDate.setMinutes(startDate.getMinutes() - 5);
|
|
121
|
+
var expiryDate = new Date(startDate);
|
|
122
|
+
expiryDate.setMinutes(startDate.getMinutes() + 60);
|
|
123
|
+
const sasToken = generateBlobSASQueryParameters({
|
|
124
|
+
containerName: containerName,
|
|
125
|
+
blobName: fileName,
|
|
126
|
+
expiresOn: expiryDate,
|
|
127
|
+
startsOn: startDate,
|
|
128
|
+
permissions: BlobSASPermissions.parse('r')
|
|
129
|
+
}, new StorageSharedKeyCredential(accountName, accountKey)).toString();
|
|
130
|
+
logger_1.logger.info(`end blobstorage.generateSasUrl `);
|
|
131
|
+
return `${protocol}://${accountName}.blob.${endpointSuffix}/${containerName}/${encodeURIComponent(fileName)}?${sasToken}`;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
exports.generateSasUrl = generateSasUrl;
|
|
135
|
+
//# sourceMappingURL=azureBlobStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureBlobStorage.js","sourceRoot":"","sources":["../../../src/lib/azure/azureBlobStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,MAAM,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7I,qDAAwD;AACxD,mDAAyC;AACzC,sDAAmD;AAEnD,SAAsB,UAAU,CAAC,aAAqB,EAAE,QAAgB,EAAE,OAAY,EAAE,gBAAwB,2BAAe,CAAC,2BAA2B;;QACvJ,eAAM,CAAC,IAAI,CAAC,kCAAkC,aAAa,MAAM,QAAQ,EAAE,CAAC,CAAA;QAC5E,MAAM,yBAAyB,GAAG,MAAM,sBAAM,CAAC,aAAa,CAAC,CAAC;QAC9D,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,CAAC;QAC5F,MAAM,eAAe,GAAG,iBAAiB,CAAC,kBAAkB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CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;QACjD,IAAI,UAAU,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QAEnD,MAAM,QAAQ,GAAG,8BAA8B,CAC3C;YACI,aAAa,EAAE,aAAa;YAC5B,QAAQ,EAAE,QAAQ;YAClB,SAAS,EAAE,UAAU;YACrB,QAAQ,EAAE,SAAS;YACnB,WAAW,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC;SAC7C,EACD,IAAI,0BAA0B,CAC1B,WAAW,EACX,UAAU,CACb,CACJ,CAAC,QAAQ,EAAE,CAAC;QACb,eAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;QAC9C,OAAO,GAAG,QAAQ,MAAM,WAAW,SAAS,cAAc,IAAI,aAAa,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAA;IAC7H,CAAC;CAAA;AAxCD,wCAwCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getKey(secretName: string): Promise<string>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getKey = void 0;
|
|
13
|
+
const keyvault_secrets_1 = require("@azure/keyvault-secrets");
|
|
14
|
+
const identity_1 = require("@azure/identity");
|
|
15
|
+
const appConfig_1 = require("../../utils/appConfig");
|
|
16
|
+
function getKey(secretName) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const credential = new identity_1.DefaultAzureCredential();
|
|
19
|
+
const url = `https://${appConfig_1.commonAppConfig.KeyVaultName}.vault.azure.net`;
|
|
20
|
+
const client = yield new keyvault_secrets_1.SecretClient(url, credential);
|
|
21
|
+
// Read the secret we created
|
|
22
|
+
const secret = yield client.getSecret(secretName);
|
|
23
|
+
return secret.value;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.getKey = getKey;
|
|
27
|
+
//# sourceMappingURL=azureKeyVault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureKeyVault.js","sourceRoot":"","sources":["../../../src/lib/azure/azureKeyVault.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAAuD;AACvD,8CAAyD;AACzD,qDAAuD;AAEvD,SAAsB,MAAM,CAAC,UAAmB;;QAC5C,MAAM,UAAU,GAAG,IAAI,iCAAsB,EAAE,CAAC;QAEhD,MAAM,GAAG,GAAG,WAAW,2BAAe,CAAC,YAAY,kBAAkB,CAAC;QAEtE,MAAM,MAAM,GAAG,MAAM,IAAI,+BAAY,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACvD,6BAA6B;QAC7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAElD,OAAO,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC;CAAA;AAVD,wBAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sendServiceBusMessage(queueName: string, message: string, connectionKey?: string, isConvertMsgToJson?: boolean): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.sendServiceBusMessage = void 0;
|
|
13
|
+
const service_bus_1 = require("@azure/service-bus");
|
|
14
|
+
const azureKeyVault_1 = require("./azureKeyVault");
|
|
15
|
+
const appConfig_1 = require("../../utils/appConfig");
|
|
16
|
+
const logger_1 = require("../../utils/logger/logger");
|
|
17
|
+
function sendServiceBusMessage(queueName, message, connectionKey = appConfig_1.commonAppConfig.ServiceBusConnectionKey, isConvertMsgToJson = false) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
logger_1.logger.info("start sendServiceBusMessage");
|
|
20
|
+
const SERVICE_BUS_CONNECTION_STRING = yield azureKeyVault_1.getKey(connectionKey);
|
|
21
|
+
const sbClient = new service_bus_1.ServiceBusClient(SERVICE_BUS_CONNECTION_STRING);
|
|
22
|
+
const sender = sbClient.createSender(queueName);
|
|
23
|
+
try {
|
|
24
|
+
let msg = {
|
|
25
|
+
body: isConvertMsgToJson ? JSON.parse(message) : message,
|
|
26
|
+
contentType: "application/json; charset=utf-8"
|
|
27
|
+
};
|
|
28
|
+
yield sender.sendMessages(msg);
|
|
29
|
+
yield sender.close();
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
logger_1.logger.error(`Error in sendServiceBusMessage: ${err}`);
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
yield sbClient.close();
|
|
37
|
+
}
|
|
38
|
+
logger_1.logger.info("end sendServiceBusMessage");
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.sendServiceBusMessage = sendServiceBusMessage;
|
|
42
|
+
//# sourceMappingURL=azureServiceBusQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureServiceBusQueue.js","sourceRoot":"","sources":["../../../src/lib/azure/azureServiceBusQueue.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAwE;AACxE,mDAAyC;AACzC,qDAAwD;AACxD,sDAAmD;AAEnD,SAAsB,qBAAqB,CAAC,SAAiB,EAAE,OAAe,EAAE,gBAAwB,2BAAe,CAAC,uBAAuB,EAAE,qBAA8B,KAAK;;QAChL,eAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC3C,MAAM,6BAA6B,GAAG,MAAM,sBAAM,CAAC,aAAa,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,IAAI,8BAAgB,CAAC,6BAA6B,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI;YACA,IAAI,GAAG,GAAsB;gBACzB,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;gBACxD,WAAW,EAAE,iCAAiC;aACjD,CAAC;YACF,MAAM,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;SACxB;QAAC,OAAM,GAAG,EAAE;YACT,eAAM,CAAC,KAAK,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;YACvD,MAAM,GAAG,CAAC;SACb;gBAAS;YACN,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;SAC1B;QACD,eAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC7C,CAAC;CAAA;AAnBD,sDAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sendMessage(queueName: string, message: string, connectionKey?: string): Promise<string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.sendMessage = void 0;
|
|
13
|
+
const storage_queue_1 = require("@azure/storage-queue");
|
|
14
|
+
const azureKeyVault_1 = require("./azureKeyVault");
|
|
15
|
+
const appConfig_1 = require("../../utils/appConfig");
|
|
16
|
+
function sendMessage(queueName, message, connectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(connectionKey);
|
|
19
|
+
const queueServiceClient = storage_queue_1.QueueServiceClient.fromConnectionString(STORAGE_CONNECTION_STRING);
|
|
20
|
+
const queueClient = queueServiceClient.getQueueClient(queueName);
|
|
21
|
+
let queueSendMessageResponse = yield queueClient.sendMessage(Buffer.from(message).toString('base64'));
|
|
22
|
+
return queueSendMessageResponse.messageId;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.sendMessage = sendMessage;
|
|
26
|
+
//# sourceMappingURL=azureStorageQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureStorageQueue.js","sourceRoot":"","sources":["../../../src/lib/azure/azureStorageQueue.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAoF;AACpF,mDAAyC;AACzC,qDAAwD;AACxD,SAAsB,WAAW,CAAC,SAAiB,EAAE,OAAe,EAAE,gBAAwB,2BAAe,CAAC,2BAA2B;;QACrI,MAAM,yBAAyB,GAAG,MAAM,sBAAM,CAAC,aAAa,CAAC,CAAC;QAE9D,MAAM,kBAAkB,GAAG,kCAAkB,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,CAAC;QAE9F,MAAM,WAAW,GAAG,kBAAkB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACjE,IAAI,wBAAwB,GAA6B,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChI,OAAO,wBAAwB,CAAC,SAAS,CAAC;IAC9C,CAAC;CAAA;AARD,kCAQC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import azure from 'azure-storage';
|
|
2
|
+
export declare function retrieveEntity<T>(tableName: string, partitionKey: string, rowKey: string, storageConnectionKey?: string): Promise<T>;
|
|
3
|
+
export declare function queryEntities<T>(tableName: string, tableQuery?: azure.TableQuery, storageConnectionKey?: string): Promise<T>;
|
|
4
|
+
export declare function deleteEntity(tableName: string, partitionKey: string, rowKey: string, storageConnectionKey?: string): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.deleteEntity = exports.queryEntities = exports.retrieveEntity = void 0;
|
|
16
|
+
const azure_storage_1 = __importDefault(require("azure-storage"));
|
|
17
|
+
const azureKeyVault_1 = require("./azureKeyVault");
|
|
18
|
+
const appConfig_1 = require("../../utils/appConfig");
|
|
19
|
+
function retrieveEntity(tableName, partitionKey, rowKey, storageConnectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(storageConnectionKey);
|
|
22
|
+
const tableServiceClient = azure_storage_1.default.createTableService(STORAGE_CONNECTION_STRING);
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
tableServiceClient.retrieveEntity(tableName, partitionKey, rowKey, { payloadFormat: "application/json;odata=nometadata" }, function (error, result, response) {
|
|
25
|
+
if (!error && response.isSuccessful) {
|
|
26
|
+
resolve(JSON.parse(JSON.stringify(response.body)));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
resolve(undefined);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.retrieveEntity = retrieveEntity;
|
|
36
|
+
function queryEntities(tableName, tableQuery = new azure_storage_1.default.TableQuery().top(20), storageConnectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(storageConnectionKey);
|
|
39
|
+
const tableServiceClient = azure_storage_1.default.createTableService(STORAGE_CONNECTION_STRING);
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
tableServiceClient.queryEntities(tableName, tableQuery, null, { payloadFormat: "application/json;odata=nometadata" }, function (error, result, response) {
|
|
42
|
+
if (!error && response.isSuccessful) {
|
|
43
|
+
resolve(JSON.parse(JSON.stringify(response.body)));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
resolve(undefined);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.queryEntities = queryEntities;
|
|
53
|
+
function deleteEntity(tableName, partitionKey, rowKey, storageConnectionKey = appConfig_1.commonAppConfig.StorageAccountConnectionKey) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const STORAGE_CONNECTION_STRING = yield azureKeyVault_1.getKey(storageConnectionKey);
|
|
56
|
+
const tableServiceClient = azure_storage_1.default.createTableService(STORAGE_CONNECTION_STRING);
|
|
57
|
+
var task = {
|
|
58
|
+
PartitionKey: { '_': partitionKey },
|
|
59
|
+
RowKey: { '_': rowKey }
|
|
60
|
+
};
|
|
61
|
+
tableServiceClient.deleteEntity(tableName, task, function (error, response) {
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.deleteEntity = deleteEntity;
|
|
66
|
+
//# sourceMappingURL=azureTableStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureTableStorage.js","sourceRoot":"","sources":["../../../src/lib/azure/azureTableStorage.ts"],"names":[],"mappings":";;;;;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aAAa,EAAE,mCAAmC,EAAE,EAAE,UAAU,KAAK,EAAE,MAAM,EAAE,QAAQ;gBAClJ,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,YAAY,EAAE;oBACjC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;iBACrD;qBAAM;oBACH,OAAO,CAAC,SAAS,CAAC,CAAA;iBACrB;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAA;IACN,CAAC;CAAA;AAbD,sCAaC;AAED,SAAsB,YAAY,CAAC,SAAiB,EAAE,YAAoB,EAAE,MAAc,EAAE,uBAA6B,2BAAe,CAAC,2BAA2B;;QAChK,MAAM,yBAAyB,GAAG,MAAM,sBAAM,CAAC,oBAAoB,CAAC,CAAC;QACrE,MAAM,kBAAkB,GAAG,uBAAK,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;QAE/E,IAAI,IAAI,GAAG;YACP,YAAY,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;YACnC,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;SAC1B,CAAC;QAEF,kBAAkB,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,KAAK,EAAE,QAAQ;QAC1E,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAXD,oCAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function httpRequest(method: string, url: string, data?: any, headers?: any): Promise<Response>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.httpRequest = void 0;
|
|
13
|
+
const appConst_1 = require("../utils/appConst");
|
|
14
|
+
const fetch = require('node-fetch');
|
|
15
|
+
function httpRequest(method, url, data = null, headers = appConst_1.jsonContentTypeHeaders()) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
let init = {};
|
|
18
|
+
init = data === null ? {
|
|
19
|
+
method: method,
|
|
20
|
+
cache: "no-cache",
|
|
21
|
+
headers: headers
|
|
22
|
+
} : {
|
|
23
|
+
method: method,
|
|
24
|
+
cache: "no-cache",
|
|
25
|
+
headers: headers,
|
|
26
|
+
body: JSON.stringify(data)
|
|
27
|
+
};
|
|
28
|
+
return fetch(url, init);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.httpRequest = httpRequest;
|
|
32
|
+
//# sourceMappingURL=httpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../src/lib/httpClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA0D;AAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEpC,SAAsB,WAAW,CAAC,MAAc,EAAE,GAAY,EAAG,OAAY,IAAI,EAAE,UAAgB,iCAAsB,EAAE;;QACzH,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAE;YACpB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,OAAO;SACnB,CAAC,CAAC,CAAC;YACF,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC;QAEF,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAdD,kCAcC"}
|