@optimiser/common 1.0.427 → 1.0.429
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/aws/awsservices.d.ts +6 -0
- package/dist/aws/awsservices.js +53 -0
- package/dist/constants.js +1 -1
- package/dist/lib/utility.js +27 -17
- package/package.json +59 -59
|
@@ -33,6 +33,12 @@ export default class AwsServices {
|
|
|
33
33
|
GeneratePreSignedUrlNotAccelerated(params: {
|
|
34
34
|
[key: string]: any;
|
|
35
35
|
}): Promise<string | Error>;
|
|
36
|
+
GeneratePreSignedUrlForVideoUpload(params: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}): Promise<string | Error>;
|
|
39
|
+
GeneratePreSignedUrlForPlayback(params: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}): Promise<string | Error>;
|
|
36
42
|
GeneratePreSignedUrl(Bucket: string, Path: string, Acl: string, Region: string, ContentType: string, FileName: string, ContryRegionName: string): Promise<string | Error>;
|
|
37
43
|
ImageUpload(BucketName: string, Region: string, FilePath: string, base64String: string, ContentType: string, FileName: string, FileType: string, UploadType: string, Acltype: string, Socketid: string, req: Express.Request): Promise<S3.ManagedUpload.SendData | Error>;
|
|
38
44
|
uploadFromStream(params: S3.Types.PutObjectRequest): Promise<S3.ManagedUpload.SendData>;
|
package/dist/aws/awsservices.js
CHANGED
|
@@ -293,6 +293,59 @@ var AwsServices = /** @class */ (function () {
|
|
|
293
293
|
});
|
|
294
294
|
});
|
|
295
295
|
};
|
|
296
|
+
AwsServices.prototype.GeneratePreSignedUrlForVideoUpload = function (params) {
|
|
297
|
+
var region = params.region, bucket = params.bucket, path = params.path, _a = params.expires, expires = _a === void 0 ? 60 : _a, _b = params.acl, acl = _b === void 0 ? 'private' : _b, _c = params.contentType, contentType = _c === void 0 ? 'application/octet-stream' : _c, _d = params.accessKeyId, accessKeyId = _d === void 0 ? this.accessKeyId : _d, _e = params.secretAccessKey, secretAccessKey = _e === void 0 ? this.secretAccessKey : _e;
|
|
298
|
+
if (params.accessType != '' && params.accessType != undefined && params.accessType != null) {
|
|
299
|
+
acl = params.accessType;
|
|
300
|
+
}
|
|
301
|
+
var S3 = new aws_sdk_1.default.S3({
|
|
302
|
+
accessKeyId: accessKeyId,
|
|
303
|
+
secretAccessKey: secretAccessKey,
|
|
304
|
+
region: region,
|
|
305
|
+
endpoint: new aws_sdk_1.default.Endpoint("optimiser-".concat(params.bucketSuffix, ".s3-accelerate.amazonaws.com")),
|
|
306
|
+
useAccelerateEndpoint: true,
|
|
307
|
+
s3ForcePathStyle: true,
|
|
308
|
+
signatureVersion: 'v4'
|
|
309
|
+
});
|
|
310
|
+
var Params = { Bucket: bucket, Key: path, Expires: expires, ACL: acl, ContentType: contentType };
|
|
311
|
+
return new Promise(function (resolve, reject) {
|
|
312
|
+
S3.getSignedUrl('putObject', Params, function (err, url) {
|
|
313
|
+
if (err) {
|
|
314
|
+
resolve(err);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
resolve(url);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
AwsServices.prototype.GeneratePreSignedUrlForPlayback = function (params) {
|
|
323
|
+
var region = params.region, bucket = params.bucket, path = params.path, _a = params.expires, expires = _a === void 0 ? 3600 : _a, _b = params.accessKeyId, accessKeyId = _b === void 0 ? this.accessKeyId : _b, _c = params.secretAccessKey, secretAccessKey = _c === void 0 ? this.secretAccessKey : _c;
|
|
324
|
+
var S3 = new aws_sdk_1.default.S3({
|
|
325
|
+
accessKeyId: accessKeyId,
|
|
326
|
+
secretAccessKey: secretAccessKey,
|
|
327
|
+
region: region,
|
|
328
|
+
endpoint: new aws_sdk_1.default.Endpoint("optimiser-".concat(params.bucketSuffix, ".s3-accelerate.amazonaws.com")),
|
|
329
|
+
useAccelerateEndpoint: true,
|
|
330
|
+
s3ForcePathStyle: true,
|
|
331
|
+
signatureVersion: 'v4'
|
|
332
|
+
});
|
|
333
|
+
var Params = {
|
|
334
|
+
Bucket: bucket,
|
|
335
|
+
Key: path,
|
|
336
|
+
Expires: expires
|
|
337
|
+
};
|
|
338
|
+
return new Promise(function (resolve, reject) {
|
|
339
|
+
S3.getSignedUrl('getObject', Params, function (err, url) {
|
|
340
|
+
if (err) {
|
|
341
|
+
reject(err);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
resolve(url);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
};
|
|
296
349
|
AwsServices.prototype.GeneratePreSignedUrl = function (Bucket, Path, Acl, Region, ContentType, FileName, ContryRegionName) {
|
|
297
350
|
var _this = this;
|
|
298
351
|
return new Promise(function (resolve, reject) {
|
package/dist/constants.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
4
|
LookupAlias: '_LookupData',
|
|
5
|
-
LookupTypeFields: ["lookup", "multilookup", "dropdown", "multiselect", "file", "image"],
|
|
5
|
+
LookupTypeFields: ["lookup", "multilookup", "dropdown", "multiselect", "file", "image", "video"],
|
|
6
6
|
SearchValueAlias: '_SearchValue',
|
|
7
7
|
USER_STATUS: {
|
|
8
8
|
ACTIVE: 'Active',
|
package/dist/lib/utility.js
CHANGED
|
@@ -1580,7 +1580,7 @@ exports.GetObjectByString = GetObjectByString;
|
|
|
1580
1580
|
function BuildLookupDataField(fieldSchema, updateObj, db) {
|
|
1581
1581
|
var _a, _b;
|
|
1582
1582
|
return __awaiter(this, void 0, void 0, function () {
|
|
1583
|
-
var fldValue, fldName_2, alias, searchAlias, fldLookupData, aggregateArry, project_1, i, obj, lookupObj, i, i, data, _c, result, _loop_10, j, i, unionDetail, unionPipeline, unionObj, result, i, lookupRecord, j, result, j, result, i, lookupRecord, j, result, i, lookupRecord, fetchFileData, video_Id, thumbnail_Id, error_2, fieldValueType, errMsg;
|
|
1583
|
+
var fldValue, fldName_2, alias, searchAlias, fldLookupData, aggregateArry, project_1, i, obj, lookupObj, i, i, data, _c, result, _loop_10, j, i, unionDetail, unionPipeline, unionObj, result, i, lookupRecord, j, result, j, result, i, lookupRecord, j, result, i, lookupRecord, fetchFileData, video_Id, thumbnail_Id, isManualThumbnail_1, promises, error_2, fieldValueType, errMsg;
|
|
1584
1584
|
return __generator(this, function (_d) {
|
|
1585
1585
|
switch (_d.label) {
|
|
1586
1586
|
case 0:
|
|
@@ -1844,39 +1844,42 @@ function BuildLookupDataField(fieldSchema, updateObj, db) {
|
|
|
1844
1844
|
// }
|
|
1845
1845
|
return [3 /*break*/, 21];
|
|
1846
1846
|
case 19:
|
|
1847
|
-
{
|
|
1848
|
-
// // Remove previous lookup data
|
|
1847
|
+
{ // Remove previous lookup data
|
|
1849
1848
|
delete updateObj[fldName_2]['VideoFile_LookupData'];
|
|
1850
1849
|
delete updateObj[fldName_2]['ThumbnailImage_LookupData'];
|
|
1851
1850
|
fetchFileData = function (fileId, includeDuration) {
|
|
1852
1851
|
if (!fileId)
|
|
1853
1852
|
return Promise.resolve([]);
|
|
1854
|
-
var
|
|
1853
|
+
var parsedId = mongodb_1.ObjectId.isValid(fileId) ? new mongodb_1.ObjectId(fileId) : fileId;
|
|
1854
|
+
var projectQuery = __assign(__assign({}, project_1), { FileName: 1 });
|
|
1855
1855
|
if (includeDuration) {
|
|
1856
1856
|
projectQuery['Duration'] = 1;
|
|
1857
|
+
projectQuery['Thumbnail'] = 1;
|
|
1857
1858
|
}
|
|
1858
1859
|
return db.collection('Drive').aggregate([
|
|
1859
|
-
{ $match: { _id:
|
|
1860
|
+
{ $match: { _id: parsedId } },
|
|
1860
1861
|
{ $project: projectQuery }
|
|
1861
1862
|
]).toArray();
|
|
1862
1863
|
};
|
|
1863
1864
|
video_Id = fldValue["VideoFile"];
|
|
1864
1865
|
thumbnail_Id = fldValue["ThumbnailImage"];
|
|
1865
|
-
|
|
1866
|
+
isManualThumbnail_1 = updateObj[fldName_2]['Thumbnail'] === 'manual';
|
|
1867
|
+
promises = [
|
|
1866
1868
|
fetchFileData(video_Id !== null && video_Id !== void 0 ? video_Id : "", true),
|
|
1867
|
-
fetchFileData(thumbnail_Id !== null && thumbnail_Id !== void 0 ? thumbnail_Id : "", false)
|
|
1868
|
-
]
|
|
1869
|
+
isManualThumbnail_1 ? fetchFileData(thumbnail_Id !== null && thumbnail_Id !== void 0 ? thumbnail_Id : "", false) : Promise.resolve([])
|
|
1870
|
+
];
|
|
1871
|
+
Promise.all(promises)
|
|
1869
1872
|
.then(function (_a) {
|
|
1870
1873
|
var videoData = _a[0], thumbnailData = _a[1];
|
|
1871
1874
|
if (videoData.length > 0) {
|
|
1872
1875
|
updateObj[fldName_2]['VideoFile_LookupData'] = videoData[0];
|
|
1873
1876
|
}
|
|
1874
|
-
if (thumbnailData.length > 0) {
|
|
1877
|
+
if (thumbnailData.length > 0 && isManualThumbnail_1) {
|
|
1875
1878
|
updateObj[fldName_2]['ThumbnailImage_LookupData'] = thumbnailData[0];
|
|
1876
1879
|
}
|
|
1877
1880
|
})
|
|
1878
|
-
.catch(function (
|
|
1879
|
-
console.error("Error
|
|
1881
|
+
.catch(function (err) {
|
|
1882
|
+
console.error("Error fetching lookup data:", err);
|
|
1880
1883
|
});
|
|
1881
1884
|
}
|
|
1882
1885
|
return [3 /*break*/, 21];
|
|
@@ -4906,7 +4909,7 @@ function ValidateUserInput(options) {
|
|
|
4906
4909
|
}
|
|
4907
4910
|
}
|
|
4908
4911
|
_loop_20 = function (pageField) {
|
|
4909
|
-
var fieldName, fieldData, field, parentData, oldValue, newValue, isSame, searchQuery, result, fld, _k, minValue, maxValue, filter, searchObj, dbConnection, result, searchObj, totalRecord, _l, schemaData, result, searchObj, result, schemaData, result, searchObj, totalRecord, regexpression, phone, files, _m, fieldData_1, obj, searchObj, totalRecord, searchObj, result, searchVideoObj, searchThumbnailObj, _o, videoResult, thumbnailResult, _p, fieldData_2, obj;
|
|
4912
|
+
var fieldName, fieldData, field, parentData, oldValue, newValue, isSame, searchQuery, result, fld, _k, minValue, maxValue, filter, searchObj, dbConnection, result, searchObj, totalRecord, _l, schemaData, result, searchObj, result, schemaData, result, searchObj, totalRecord, regexpression, phone, files, _m, fieldData_1, obj, searchObj, totalRecord, searchObj, result, searchVideoObj, videoPromise, thumbnailPromise, searchThumbnailObj, _o, videoResult, thumbnailResult, _p, fieldData_2, obj;
|
|
4910
4913
|
return __generator(this, function (_q) {
|
|
4911
4914
|
switch (_q.label) {
|
|
4912
4915
|
case 0:
|
|
@@ -5305,21 +5308,28 @@ function ValidateUserInput(options) {
|
|
|
5305
5308
|
case 50: return [3 /*break*/, 59];
|
|
5306
5309
|
case 51:
|
|
5307
5310
|
searchVideoObj = { _id: fieldData['VideoFile'] };
|
|
5308
|
-
searchThumbnailObj = { _id: fieldData['ThumbnailImage'] };
|
|
5309
5311
|
if (action === 'add') {
|
|
5310
5312
|
searchVideoObj.IsActive = true;
|
|
5311
|
-
|
|
5313
|
+
}
|
|
5314
|
+
videoPromise = db.collection("Drive").findOne(searchVideoObj);
|
|
5315
|
+
thumbnailPromise = Promise.resolve(true);
|
|
5316
|
+
if (fieldData['Thumbnail'] === 'manual') {
|
|
5317
|
+
searchThumbnailObj = { _id: fieldData['ThumbnailImage'] };
|
|
5318
|
+
if (action === 'add') {
|
|
5319
|
+
searchThumbnailObj.IsActive = true;
|
|
5320
|
+
}
|
|
5321
|
+
thumbnailPromise = db.collection("Drive").findOne(searchThumbnailObj);
|
|
5312
5322
|
}
|
|
5313
5323
|
return [4 /*yield*/, Promise.all([
|
|
5314
|
-
|
|
5315
|
-
|
|
5324
|
+
videoPromise,
|
|
5325
|
+
thumbnailPromise
|
|
5316
5326
|
])];
|
|
5317
5327
|
case 52:
|
|
5318
5328
|
_o = _q.sent(), videoResult = _o[0], thumbnailResult = _o[1];
|
|
5319
5329
|
if (!videoResult) {
|
|
5320
5330
|
msg = field.DisplayName + ' (VideoFile) does not exist!';
|
|
5321
5331
|
}
|
|
5322
|
-
if (!thumbnailResult) {
|
|
5332
|
+
if (fieldData['Thumbnail'] === 'manual' && !thumbnailResult) {
|
|
5323
5333
|
msg += (msg ? ' ' : '') + field.DisplayName + ' (ThumbnailImage) does not exist!';
|
|
5324
5334
|
}
|
|
5325
5335
|
return [3 /*break*/, 59];
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@optimiser/common",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"compile": "tsc",
|
|
8
|
-
"push": "tsc && npm version patch -git-tag-version false && npm publish"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"dist/*"
|
|
12
|
-
],
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@types/geoip-lite": "^1.4.0",
|
|
17
|
-
"@types/promise.allsettled": "^1.0.3",
|
|
18
|
-
"@types/request": "^2.48.5",
|
|
19
|
-
"@types/sanitize-html": "^2.11.0",
|
|
20
|
-
"@types/sequelize": "^4.28.9",
|
|
21
|
-
"@types/unzipper": "^0.10.3",
|
|
22
|
-
"@types/uuid": "^8.3.0",
|
|
23
|
-
"aws-sdk": "^2.786.0",
|
|
24
|
-
"axios": "^0.21.4",
|
|
25
|
-
"bson": "^4.2.0",
|
|
26
|
-
"exceljs": "^4.3.0",
|
|
27
|
-
"express": "^4.17.1",
|
|
28
|
-
"express-validator": "^6.9.2",
|
|
29
|
-
"firebase-admin": "^12.0.0",
|
|
30
|
-
"geoip-lite": "^1.4.2",
|
|
31
|
-
"google-libphonenumber": "^3.2.30",
|
|
32
|
-
"ioredis": "^4.17.3",
|
|
33
|
-
"libphonenumber-js": "^1.9.51",
|
|
34
|
-
"moment": "^2.25.3",
|
|
35
|
-
"moment-timezone": "^0.5.27",
|
|
36
|
-
"mongo-sanitize": "^1.1.0",
|
|
37
|
-
"mongodb": "^3.6.2",
|
|
38
|
-
"nodemailer": "^6.4.11",
|
|
39
|
-
"promise.allsettled": "^1.0.2",
|
|
40
|
-
"qrcode": "^1.5.3",
|
|
41
|
-
"request": "^2.88.2",
|
|
42
|
-
"sanitize-html": "^2.13.0",
|
|
43
|
-
"sequelize": "^6.3.5",
|
|
44
|
-
"typescript": "^5.3.3",
|
|
45
|
-
"unzipper": "^0.10.11",
|
|
46
|
-
"uuid": "^8.3.1"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/aws-sdk": "^2.7.0",
|
|
50
|
-
"@types/bson": "^4.0.2",
|
|
51
|
-
"@types/exceljs": "^1.3.0",
|
|
52
|
-
"@types/express": "^4.17.8",
|
|
53
|
-
"@types/ioredis": "^4.17.4",
|
|
54
|
-
"@types/moment": "^2.13.0",
|
|
55
|
-
"@types/moment-timezone": "^0.5.30",
|
|
56
|
-
"@types/mongodb": "^3.5.27",
|
|
57
|
-
"@types/nodemailer": "^6.4.0"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@optimiser/common",
|
|
3
|
+
"version": "1.0.429",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"compile": "tsc",
|
|
8
|
+
"push": "tsc && npm version patch -git-tag-version false && npm publish"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/*"
|
|
12
|
+
],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@types/geoip-lite": "^1.4.0",
|
|
17
|
+
"@types/promise.allsettled": "^1.0.3",
|
|
18
|
+
"@types/request": "^2.48.5",
|
|
19
|
+
"@types/sanitize-html": "^2.11.0",
|
|
20
|
+
"@types/sequelize": "^4.28.9",
|
|
21
|
+
"@types/unzipper": "^0.10.3",
|
|
22
|
+
"@types/uuid": "^8.3.0",
|
|
23
|
+
"aws-sdk": "^2.786.0",
|
|
24
|
+
"axios": "^0.21.4",
|
|
25
|
+
"bson": "^4.2.0",
|
|
26
|
+
"exceljs": "^4.3.0",
|
|
27
|
+
"express": "^4.17.1",
|
|
28
|
+
"express-validator": "^6.9.2",
|
|
29
|
+
"firebase-admin": "^12.0.0",
|
|
30
|
+
"geoip-lite": "^1.4.2",
|
|
31
|
+
"google-libphonenumber": "^3.2.30",
|
|
32
|
+
"ioredis": "^4.17.3",
|
|
33
|
+
"libphonenumber-js": "^1.9.51",
|
|
34
|
+
"moment": "^2.25.3",
|
|
35
|
+
"moment-timezone": "^0.5.27",
|
|
36
|
+
"mongo-sanitize": "^1.1.0",
|
|
37
|
+
"mongodb": "^3.6.2",
|
|
38
|
+
"nodemailer": "^6.4.11",
|
|
39
|
+
"promise.allsettled": "^1.0.2",
|
|
40
|
+
"qrcode": "^1.5.3",
|
|
41
|
+
"request": "^2.88.2",
|
|
42
|
+
"sanitize-html": "^2.13.0",
|
|
43
|
+
"sequelize": "^6.3.5",
|
|
44
|
+
"typescript": "^5.3.3",
|
|
45
|
+
"unzipper": "^0.10.11",
|
|
46
|
+
"uuid": "^8.3.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/aws-sdk": "^2.7.0",
|
|
50
|
+
"@types/bson": "^4.0.2",
|
|
51
|
+
"@types/exceljs": "^1.3.0",
|
|
52
|
+
"@types/express": "^4.17.8",
|
|
53
|
+
"@types/ioredis": "^4.17.4",
|
|
54
|
+
"@types/moment": "^2.13.0",
|
|
55
|
+
"@types/moment-timezone": "^0.5.30",
|
|
56
|
+
"@types/mongodb": "^3.5.27",
|
|
57
|
+
"@types/nodemailer": "^6.4.0"
|
|
58
|
+
}
|
|
59
|
+
}
|