@stemy/backend 3.3.1 → 3.4.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/bundles/stemy-backend.umd.js +553 -487
- package/bundles/stemy-backend.umd.js.map +1 -1
- package/common-types.d.ts +8 -2
- package/esm2015/common-types.js +1 -1
- package/esm2015/public_api.js +5 -3
- package/esm2015/rest-controllers/auth.controller.js +11 -10
- package/esm2015/services/assets.js +1 -1
- package/esm2015/services/entities/base-entity.js +1 -1
- package/esm2015/services/lazy-assets.js +1 -1
- package/esm2015/services/mongo-connector.js +3 -1
- package/esm2015/services/progresses.js +1 -1
- package/esm2015/utilities/base-doc.js +21 -0
- package/esm2015/utilities/mongoose.js +225 -0
- package/esm2015/utils.js +2 -204
- package/fesm2015/stemy-backend.js +419 -376
- package/fesm2015/stemy-backend.js.map +1 -1
- package/package.json +5 -4
- package/public_api.d.ts +4 -2
- package/services/assets.d.ts +1 -1
- package/services/entities/base-entity.d.ts +2 -2
- package/services/lazy-assets.d.ts +1 -1
- package/services/progresses.d.ts +1 -1
- package/stemy-backend.metadata.json +1 -1
- package/utilities/base-doc.d.ts +39 -0
- package/utilities/mongoose.d.ts +36 -0
- package/utils.d.ts +3 -20
- package/bundles/stemy-backend.umd.min.js +0 -2
- package/bundles/stemy-backend.umd.min.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('body-parser'), require('jsonwebtoken'), require('tsyringe'), require('routing-controllers'), require('socket-controllers'), require('routing-controllers-openapi'), require('class-transformer/storage'), require('class-validator'), require('class-validator-jsonschema'), require('child_process'), require('crypto'), require('rxjs'), require('rxjs/internal/util/canReportError'), require('fs'), require('mongodb'), require('mongoose'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@stemy/backend', ['exports', 'path', 'body-parser', 'jsonwebtoken', 'tsyringe', 'routing-controllers', 'socket-controllers', 'routing-controllers-openapi', 'class-transformer/storage', 'class-validator', 'class-validator-jsonschema', 'child_process', 'crypto', 'rxjs', 'rxjs/internal/util/canReportError', 'fs', 'mongodb', 'mongoose', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.stemy = global.stemy || {}, global.stemy.backend = {}), global.path, global["body-parser"], global.jsonwebtoken, global.tsyringe, global["routing-controllers"], global["socket-controllers"], global["routing-controllers-openapi"], global["class-transformer/storage"], global["class-validator"], global["class-validator-jsonschema"], global.child_process, global.crypto, global.rxjs, global.rxjs["internal/util/canReportError"], global.fs, global.mongodb, global.mongoose, global
|
|
5
|
-
})(this, (function (exports, path, bodyParser, jsonwebtoken, tsyringe, routingControllers, socketControllers, routingControllersOpenapi, storage, classValidator, classValidatorJsonschema, child_process, crypto, rxjs, canReportError, fs, mongodb, mongoose,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('body-parser'), require('jsonwebtoken'), require('tsyringe'), require('routing-controllers'), require('socket-controllers'), require('routing-controllers-openapi'), require('class-transformer/storage'), require('class-validator'), require('class-validator-jsonschema'), require('child_process'), require('crypto'), require('rxjs'), require('rxjs/internal/util/canReportError'), require('fs'), require('mongodb'), require('mongoose'), require('stream'), require('sharp'), require('bson'), require('fontkit'), require('file-type'), require('axios'), require('dotenv'), require('node-cron'), require('zeromq'), require('rxjs/operators'), require('http'), require('express'), require('socket.io'), require('uuid'), require('nodemailer'), require('handlebars'), require('bcrypt'), require('moment'), require('@typegoose/typegoose'), require('mongoose/lib/utils')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@stemy/backend', ['exports', 'path', 'body-parser', 'jsonwebtoken', 'tsyringe', 'routing-controllers', 'socket-controllers', 'routing-controllers-openapi', 'class-transformer/storage', 'class-validator', 'class-validator-jsonschema', 'child_process', 'crypto', 'rxjs', 'rxjs/internal/util/canReportError', 'fs', 'mongodb', 'mongoose', 'stream', 'sharp', 'bson', 'fontkit', 'file-type', 'axios', 'dotenv', 'node-cron', 'zeromq', 'rxjs/operators', 'http', 'express', 'socket.io', 'uuid', 'nodemailer', 'handlebars', 'bcrypt', 'moment', '@typegoose/typegoose', 'mongoose/lib/utils'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.stemy = global.stemy || {}, global.stemy.backend = {}), global.path, global["body-parser"], global.jsonwebtoken, global.tsyringe, global["routing-controllers"], global["socket-controllers"], global["routing-controllers-openapi"], global["class-transformer/storage"], global["class-validator"], global["class-validator-jsonschema"], global.child_process, global.crypto, global.rxjs, global.rxjs["internal/util/canReportError"], global.fs, global.mongodb, global.mongoose, global.stream, global.sharp, global.bson, global.fontkit, global["file-type"], global.axios, global.dotenv, global["node-cron"], global.zeromq, global.rxjs.operators, global.http, global.express, global.socket.io, global.uuid, global.nodemailer, global.handlebars, global.bcrypt, global.moment, global.typegoose, global["mongoose-lib-utils"]));
|
|
5
|
+
})(this, (function (exports, path, bodyParser, jsonwebtoken, tsyringe, routingControllers, socketControllers, routingControllersOpenapi, storage, classValidator, classValidatorJsonschema, child_process, crypto, rxjs, canReportError, fs, mongodb, mongoose, stream, sharp_, bson, fontKit_, fileType, axios, dotenv, nodeCron, zeromq, operators, http, express_, socket_io, uuid, nodemailer, Handlebars, bcrypt, moment, typegoose, utils) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
105
105
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
106
106
|
}
|
|
107
|
-
function __awaiter$
|
|
107
|
+
function __awaiter$y(thisArg, _arguments, P, generator) {
|
|
108
108
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
109
109
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
110
110
|
function fulfilled(value) { try {
|
|
@@ -360,7 +360,7 @@
|
|
|
360
360
|
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
var __awaiter$
|
|
363
|
+
var __awaiter$x = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
364
364
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
365
365
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
366
366
|
function fulfilled(value) { try {
|
|
@@ -534,177 +534,6 @@
|
|
|
534
534
|
}
|
|
535
535
|
return value;
|
|
536
536
|
}
|
|
537
|
-
function injectServices(schema, services) {
|
|
538
|
-
var serviceMap = {};
|
|
539
|
-
Object.keys(services).forEach(function (prop) {
|
|
540
|
-
schema
|
|
541
|
-
.virtual(prop)
|
|
542
|
-
.get(function () {
|
|
543
|
-
var diContainer = diContainers.appContainer;
|
|
544
|
-
serviceMap[prop] = serviceMap[prop] || (!diContainer ? {} : diContainer.resolve(services[prop]));
|
|
545
|
-
return serviceMap[prop];
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
function paginate(model, where, params) {
|
|
550
|
-
return model.countDocuments(where).then(function (count) {
|
|
551
|
-
var query = model.find(where);
|
|
552
|
-
if (isString(params.sort)) {
|
|
553
|
-
query = query.sort(params.sort);
|
|
554
|
-
}
|
|
555
|
-
if (isArray(params.populate)) {
|
|
556
|
-
params.populate.forEach(function (field) {
|
|
557
|
-
query = query.populate(field);
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
return (params.limit > 0 ? query.skip(params.page * params.limit).limit(params.limit) : query).then(function (items) {
|
|
561
|
-
var meta = { total: count };
|
|
562
|
-
return { count: count, items: items, meta: meta };
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
function lookupStages(from, localField, as, foreignField, shouldUnwind) {
|
|
567
|
-
if (as === void 0) { as = null; }
|
|
568
|
-
if (foreignField === void 0) { foreignField = "_id"; }
|
|
569
|
-
if (shouldUnwind === void 0) { shouldUnwind = true; }
|
|
570
|
-
as = as || localField.replace("Id", "");
|
|
571
|
-
var stages = [
|
|
572
|
-
{
|
|
573
|
-
$lookup: {
|
|
574
|
-
from: from,
|
|
575
|
-
localField: localField,
|
|
576
|
-
foreignField: foreignField,
|
|
577
|
-
as: as
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
$unwind: {
|
|
582
|
-
path: "$" + as,
|
|
583
|
-
preserveNullAndEmptyArrays: true
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
];
|
|
587
|
-
if (!shouldUnwind) {
|
|
588
|
-
stages.splice(1, 1);
|
|
589
|
-
}
|
|
590
|
-
return stages;
|
|
591
|
-
}
|
|
592
|
-
function letsLookupStage(from, pipeline, as, letFields) {
|
|
593
|
-
if (as === void 0) { as = null; }
|
|
594
|
-
if (letFields === void 0) { letFields = null; }
|
|
595
|
-
as = as || from;
|
|
596
|
-
letFields = letFields || { id: "$_id" };
|
|
597
|
-
return {
|
|
598
|
-
$lookup: {
|
|
599
|
-
from: from,
|
|
600
|
-
let: letFields,
|
|
601
|
-
pipeline: pipeline,
|
|
602
|
-
as: as
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
function matchStage(match) {
|
|
607
|
-
return { $match: match };
|
|
608
|
-
}
|
|
609
|
-
function matchField(field, filter, when) {
|
|
610
|
-
return { field: field, filter: filter, when: when };
|
|
611
|
-
}
|
|
612
|
-
function matchFieldStages() {
|
|
613
|
-
var fields = [];
|
|
614
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
615
|
-
fields[_i] = arguments[_i];
|
|
616
|
-
}
|
|
617
|
-
var match = {};
|
|
618
|
-
fields.forEach(function (field) {
|
|
619
|
-
if (field.when) {
|
|
620
|
-
match[field.field] = field.filter;
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
return Object.keys(match).length > 0 ? [matchStage(match)] : [];
|
|
624
|
-
}
|
|
625
|
-
function projectStage(fields) {
|
|
626
|
-
return { $project: fields };
|
|
627
|
-
}
|
|
628
|
-
function unwindStage(fieldOrOpts) {
|
|
629
|
-
return { $unwind: fieldOrOpts };
|
|
630
|
-
}
|
|
631
|
-
function hydratePopulated(modelType, json) {
|
|
632
|
-
var e_2, _a;
|
|
633
|
-
var object = modelType.hydrate(json);
|
|
634
|
-
var _loop_1 = function (path, obj) {
|
|
635
|
-
var ref = obj.ref, type = obj.type;
|
|
636
|
-
if (Array.isArray(type) && type.length > 0) {
|
|
637
|
-
ref = type[0].ref;
|
|
638
|
-
}
|
|
639
|
-
if (!ref)
|
|
640
|
-
return "continue";
|
|
641
|
-
var value = utils.getValue(path, json);
|
|
642
|
-
var hydrateVal = function (val) {
|
|
643
|
-
if (val == null || val instanceof mongoose.Types.ObjectId)
|
|
644
|
-
return val;
|
|
645
|
-
return hydratePopulated(mongoose.model(ref), val);
|
|
646
|
-
};
|
|
647
|
-
if (Array.isArray(value)) {
|
|
648
|
-
utils.setValue(path, value.map(hydrateVal), object);
|
|
649
|
-
return "continue";
|
|
650
|
-
}
|
|
651
|
-
utils.setValue(path, hydrateVal(value), object);
|
|
652
|
-
};
|
|
653
|
-
try {
|
|
654
|
-
for (var _b = __values(Object.entries(modelType.schema.obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
655
|
-
var _d = __read(_c.value, 2), path = _d[0], obj = _d[1];
|
|
656
|
-
_loop_1(path, obj);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
660
|
-
finally {
|
|
661
|
-
try {
|
|
662
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
663
|
-
}
|
|
664
|
-
finally { if (e_2) throw e_2.error; }
|
|
665
|
-
}
|
|
666
|
-
return object;
|
|
667
|
-
}
|
|
668
|
-
function paginateAggregations(model, aggregations, params, metaProjection) {
|
|
669
|
-
if (metaProjection === void 0) { metaProjection = {}; }
|
|
670
|
-
return __awaiter$w(this, void 0, void 0, function () {
|
|
671
|
-
var sortField, sortAggregation, result, pagination;
|
|
672
|
-
var _a;
|
|
673
|
-
return __generator(this, function (_b) {
|
|
674
|
-
switch (_b.label) {
|
|
675
|
-
case 0:
|
|
676
|
-
sortField = !isString(params.sort) || !params.sort ? null : (params.sort.startsWith("-") ? params.sort.substr(1) : params.sort);
|
|
677
|
-
sortAggregation = !sortField ? [] : [{
|
|
678
|
-
$sort: (_a = {}, _a[sortField] = sortField == params.sort ? 1 : -1, _a)
|
|
679
|
-
}];
|
|
680
|
-
return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray(__spreadArray([], __read(aggregations)), __read(sortAggregation)), [
|
|
681
|
-
{
|
|
682
|
-
$group: {
|
|
683
|
-
_id: "results",
|
|
684
|
-
result: { $push: "$$CURRENT" }
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
$project: {
|
|
689
|
-
_id: 0,
|
|
690
|
-
items: params.limit > 0 ? { $slice: ["$result", params.page * params.limit, params.limit] } : "$result",
|
|
691
|
-
count: { $size: "$result" },
|
|
692
|
-
meta: Object.assign({ total: { $size: "$result" } }, metaProjection)
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
]))];
|
|
696
|
-
case 1:
|
|
697
|
-
result = _b.sent();
|
|
698
|
-
pagination = result[0];
|
|
699
|
-
if (!pagination) {
|
|
700
|
-
return [2 /*return*/, { items: [], count: 0, meta: { total: 0 } }];
|
|
701
|
-
}
|
|
702
|
-
pagination.items = pagination.items.map(function (i) { return hydratePopulated(model, i); });
|
|
703
|
-
return [2 /*return*/, pagination];
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
537
|
var cropInterface = {
|
|
709
538
|
x: "number",
|
|
710
539
|
y: "number",
|
|
@@ -731,8 +560,8 @@
|
|
|
731
560
|
};
|
|
732
561
|
}
|
|
733
562
|
function toImage(src, params, meta) {
|
|
734
|
-
return __awaiter$
|
|
735
|
-
var crop, buffer, _a, cropBefore, cropAfter, img, _b, width, height, canvasScaleX, canvasScaleY,
|
|
563
|
+
return __awaiter$x(this, void 0, void 0, function () {
|
|
564
|
+
var crop, buffer, _a, cropBefore, cropAfter, img, _b, width, height, canvasScaleX, canvasScaleY, e_2;
|
|
736
565
|
return __generator(this, function (_c) {
|
|
737
566
|
switch (_c.label) {
|
|
738
567
|
case 0:
|
|
@@ -810,8 +639,8 @@
|
|
|
810
639
|
src = src instanceof stream.Readable ? bufferToStream(buffer) : buffer;
|
|
811
640
|
return [2 /*return*/, src];
|
|
812
641
|
case 9:
|
|
813
|
-
|
|
814
|
-
console.log("Image conversion error",
|
|
642
|
+
e_2 = _c.sent();
|
|
643
|
+
console.log("Image conversion error", e_2);
|
|
815
644
|
src = src instanceof stream.Readable ? bufferToStream(buffer) : buffer;
|
|
816
645
|
return [2 /*return*/, src];
|
|
817
646
|
case 10: return [2 /*return*/];
|
|
@@ -892,7 +721,7 @@
|
|
|
892
721
|
}
|
|
893
722
|
function readAndDeleteFile(path, timeout) {
|
|
894
723
|
if (timeout === void 0) { timeout = 5000; }
|
|
895
|
-
return __awaiter$
|
|
724
|
+
return __awaiter$x(this, void 0, void 0, function () {
|
|
896
725
|
var data;
|
|
897
726
|
return __generator(this, function (_a) {
|
|
898
727
|
switch (_a.label) {
|
|
@@ -909,7 +738,7 @@
|
|
|
909
738
|
});
|
|
910
739
|
}
|
|
911
740
|
function writeFile(path$1, data) {
|
|
912
|
-
return __awaiter$
|
|
741
|
+
return __awaiter$x(this, void 0, void 0, function () {
|
|
913
742
|
return __generator(this, function (_a) {
|
|
914
743
|
switch (_a.label) {
|
|
915
744
|
case 0: return [4 /*yield*/, mkdirRecursive(path.dirname(path$1))];
|
|
@@ -972,80 +801,6 @@
|
|
|
972
801
|
});
|
|
973
802
|
return params;
|
|
974
803
|
}
|
|
975
|
-
function proxyFunction(name) {
|
|
976
|
-
return function () {
|
|
977
|
-
var args = Array.from(arguments);
|
|
978
|
-
args.unshift(this);
|
|
979
|
-
return this.helper[name].apply(this.helper, args);
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
function proxyFunctions(schema, helper, paramName) {
|
|
983
|
-
if (paramName === void 0) { paramName = null; }
|
|
984
|
-
paramName = paramName || lcFirst(getConstructorName(helper)).replace(/helper$/gi, "");
|
|
985
|
-
var descriptors = Object.getOwnPropertyDescriptors(helper.prototype);
|
|
986
|
-
Object.keys(descriptors).forEach(function (name) {
|
|
987
|
-
var func = descriptors[name].value;
|
|
988
|
-
if (isFunction(func) && name !== "constructor") {
|
|
989
|
-
var paramNames = getFunctionParams(func);
|
|
990
|
-
if (paramNames[0] == paramName) {
|
|
991
|
-
schema.methods[name] = proxyFunction(name);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
});
|
|
995
|
-
injectServices(schema, {
|
|
996
|
-
"helper": helper
|
|
997
|
-
});
|
|
998
|
-
}
|
|
999
|
-
function ResolveEntity(model, extraCheck) {
|
|
1000
|
-
var _this = this;
|
|
1001
|
-
var modelName = model.modelName;
|
|
1002
|
-
var paramName = modelName.toLowerCase();
|
|
1003
|
-
return routingControllers.createParamDecorator({
|
|
1004
|
-
required: false,
|
|
1005
|
-
value: function (action) { return __awaiter$w(_this, void 0, void 0, function () {
|
|
1006
|
-
var req, token, id, query, doc, e_4;
|
|
1007
|
-
return __generator(this, function (_a) {
|
|
1008
|
-
switch (_a.label) {
|
|
1009
|
-
case 0:
|
|
1010
|
-
req = action.request;
|
|
1011
|
-
token = req.header("x-" + paramName + "-token");
|
|
1012
|
-
id = req.params[paramName + "Id"];
|
|
1013
|
-
if (!id && !token) {
|
|
1014
|
-
throw new routingControllers.BadRequestError(modelName + " id or token should be defined!");
|
|
1015
|
-
}
|
|
1016
|
-
query = !token
|
|
1017
|
-
? model.findById(id)
|
|
1018
|
-
: model.findOne({ token: token });
|
|
1019
|
-
doc = null;
|
|
1020
|
-
if (!isFunction(extraCheck)) return [3 /*break*/, 5];
|
|
1021
|
-
_a.label = 1;
|
|
1022
|
-
case 1:
|
|
1023
|
-
_a.trys.push([1, 3, , 4]);
|
|
1024
|
-
return [4 /*yield*/, valueToPromise(extraCheck(query, action))];
|
|
1025
|
-
case 2:
|
|
1026
|
-
doc = _a.sent();
|
|
1027
|
-
return [3 /*break*/, 4];
|
|
1028
|
-
case 3:
|
|
1029
|
-
e_4 = _a.sent();
|
|
1030
|
-
throw new routingControllers.BadRequestError(modelName + " check error: " + (e_4.message || e_4));
|
|
1031
|
-
case 4: return [3 /*break*/, 7];
|
|
1032
|
-
case 5: return [4 /*yield*/, query];
|
|
1033
|
-
case 6:
|
|
1034
|
-
doc = _a.sent();
|
|
1035
|
-
_a.label = 7;
|
|
1036
|
-
case 7:
|
|
1037
|
-
if (!doc) {
|
|
1038
|
-
throw new routingControllers.HttpError(404, !token
|
|
1039
|
-
? modelName + " could not be found with id: " + id
|
|
1040
|
-
: modelName + " could not be found with token: " + token);
|
|
1041
|
-
}
|
|
1042
|
-
action.request[paramName] = doc;
|
|
1043
|
-
return [2 /*return*/, doc];
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
}); }
|
|
1047
|
-
});
|
|
1048
|
-
}
|
|
1049
804
|
function getFileName(path$1, withExtension) {
|
|
1050
805
|
if (withExtension === void 0) { withExtension = false; }
|
|
1051
806
|
var name = path.basename(path$1 || "");
|
|
@@ -1142,7 +897,7 @@
|
|
|
1142
897
|
var defaultPredicate = function () { return true; };
|
|
1143
898
|
var ɵ0 = defaultPredicate;
|
|
1144
899
|
function copyRecursive(target, source, predicate) {
|
|
1145
|
-
var
|
|
900
|
+
var e_3, _a;
|
|
1146
901
|
predicate = predicate || defaultPredicate;
|
|
1147
902
|
if (isPrimitive(source) || isDate(source) || isFunction(source))
|
|
1148
903
|
return source;
|
|
@@ -1186,12 +941,12 @@
|
|
|
1186
941
|
target.set(key, !shouldCopy(key, value) ? value : copyRecursive(target.get(key), value, predicate));
|
|
1187
942
|
}
|
|
1188
943
|
}
|
|
1189
|
-
catch (
|
|
944
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1190
945
|
finally {
|
|
1191
946
|
try {
|
|
1192
947
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1193
948
|
}
|
|
1194
|
-
finally { if (
|
|
949
|
+
finally { if (e_3) throw e_3.error; }
|
|
1195
950
|
}
|
|
1196
951
|
}
|
|
1197
952
|
return target;
|
|
@@ -1449,7 +1204,7 @@
|
|
|
1449
1204
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1450
1205
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1451
1206
|
};
|
|
1452
|
-
var __awaiter$
|
|
1207
|
+
var __awaiter$w = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1453
1208
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1454
1209
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1455
1210
|
function fulfilled(value) { try {
|
|
@@ -1497,7 +1252,7 @@
|
|
|
1497
1252
|
};
|
|
1498
1253
|
AssetProcessor.fileTypeFromBuffer = function (buffer) {
|
|
1499
1254
|
var _a;
|
|
1500
|
-
return __awaiter$
|
|
1255
|
+
return __awaiter$w(this, void 0, void 0, function () {
|
|
1501
1256
|
var type;
|
|
1502
1257
|
return __generator(this, function (_b) {
|
|
1503
1258
|
switch (_b.label) {
|
|
@@ -1531,7 +1286,7 @@
|
|
|
1531
1286
|
return imageTypes.indexOf(contentType) >= 0;
|
|
1532
1287
|
};
|
|
1533
1288
|
AssetProcessor.copyImageMeta = function (buffer, metadata, fileType) {
|
|
1534
|
-
return __awaiter$
|
|
1289
|
+
return __awaiter$w(this, void 0, void 0, function () {
|
|
1535
1290
|
var match, attrs, parts, output;
|
|
1536
1291
|
return __generator(this, function (_b) {
|
|
1537
1292
|
switch (_b.label) {
|
|
@@ -1578,7 +1333,7 @@
|
|
|
1578
1333
|
});
|
|
1579
1334
|
};
|
|
1580
1335
|
AssetProcessor.prototype.process = function (buffer, metadata, fileType) {
|
|
1581
|
-
return __awaiter$
|
|
1336
|
+
return __awaiter$w(this, void 0, void 0, function () {
|
|
1582
1337
|
return __generator(this, function (_b) {
|
|
1583
1338
|
switch (_b.label) {
|
|
1584
1339
|
case 0:
|
|
@@ -1676,7 +1431,7 @@
|
|
|
1676
1431
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1677
1432
|
return Reflect.metadata(k, v);
|
|
1678
1433
|
};
|
|
1679
|
-
var __awaiter$
|
|
1434
|
+
var __awaiter$v = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1680
1435
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1681
1436
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1682
1437
|
function fulfilled(value) { try {
|
|
@@ -1724,7 +1479,7 @@
|
|
|
1724
1479
|
configurable: true
|
|
1725
1480
|
});
|
|
1726
1481
|
MongoConnector.prototype.connect = function () {
|
|
1727
|
-
return __awaiter$
|
|
1482
|
+
return __awaiter$v(this, void 0, void 0, function () {
|
|
1728
1483
|
var _a;
|
|
1729
1484
|
return __generator(this, function (_b) {
|
|
1730
1485
|
switch (_b.label) {
|
|
@@ -1740,6 +1495,7 @@
|
|
|
1740
1495
|
case 1:
|
|
1741
1496
|
_a.conn = (_b.sent()).connection;
|
|
1742
1497
|
this.db = this.conn.db;
|
|
1498
|
+
console.log("DB INSTANCE", getType(this.db));
|
|
1743
1499
|
this.fsBucket = new mongodb.GridFSBucket(this.db, { bucketName: "assets" });
|
|
1744
1500
|
return [2 /*return*/];
|
|
1745
1501
|
}
|
|
@@ -1754,7 +1510,7 @@
|
|
|
1754
1510
|
__metadata$p("design:paramtypes", [exports.Configuration])
|
|
1755
1511
|
], exports.MongoConnector);
|
|
1756
1512
|
|
|
1757
|
-
var __awaiter$
|
|
1513
|
+
var __awaiter$u = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1758
1514
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1759
1515
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1760
1516
|
function fulfilled(value) { try {
|
|
@@ -1790,7 +1546,7 @@
|
|
|
1790
1546
|
return this.collection.updateOne({ _id: this.mId }, { $set: this.toJSON() });
|
|
1791
1547
|
};
|
|
1792
1548
|
BaseEntity.prototype.load = function () {
|
|
1793
|
-
return __awaiter$
|
|
1549
|
+
return __awaiter$u(this, void 0, void 0, function () {
|
|
1794
1550
|
var res;
|
|
1795
1551
|
return __generator(this, function (_a) {
|
|
1796
1552
|
switch (_a.label) {
|
|
@@ -1813,7 +1569,7 @@
|
|
|
1813
1569
|
return BaseEntity;
|
|
1814
1570
|
}());
|
|
1815
1571
|
|
|
1816
|
-
var __awaiter$
|
|
1572
|
+
var __awaiter$t = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1817
1573
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1818
1574
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1819
1575
|
function fulfilled(value) { try {
|
|
@@ -1868,7 +1624,7 @@
|
|
|
1868
1624
|
configurable: true
|
|
1869
1625
|
});
|
|
1870
1626
|
Asset.prototype.unlink = function () {
|
|
1871
|
-
return __awaiter$
|
|
1627
|
+
return __awaiter$t(this, void 0, void 0, function () {
|
|
1872
1628
|
return __generator(this, function (_a) {
|
|
1873
1629
|
return [2 /*return*/, deleteFromBucket(this.bucket, this.mId)];
|
|
1874
1630
|
});
|
|
@@ -1878,7 +1634,7 @@
|
|
|
1878
1634
|
return streamToBuffer(this.stream);
|
|
1879
1635
|
};
|
|
1880
1636
|
Asset.prototype.download = function (metadata) {
|
|
1881
|
-
return __awaiter$
|
|
1637
|
+
return __awaiter$t(this, void 0, void 0, function () {
|
|
1882
1638
|
return __generator(this, function (_a) {
|
|
1883
1639
|
switch (_a.label) {
|
|
1884
1640
|
case 0:
|
|
@@ -1898,14 +1654,14 @@
|
|
|
1898
1654
|
};
|
|
1899
1655
|
Asset.prototype.getImage = function (params) {
|
|
1900
1656
|
if (params === void 0) { params = null; }
|
|
1901
|
-
return __awaiter$
|
|
1657
|
+
return __awaiter$t(this, void 0, void 0, function () {
|
|
1902
1658
|
return __generator(this, function (_a) {
|
|
1903
1659
|
return [2 /*return*/, toImage(this.stream, params, this.metadata)];
|
|
1904
1660
|
});
|
|
1905
1661
|
});
|
|
1906
1662
|
};
|
|
1907
1663
|
Asset.prototype.downloadImage = function (params, metadata) {
|
|
1908
|
-
return __awaiter$
|
|
1664
|
+
return __awaiter$t(this, void 0, void 0, function () {
|
|
1909
1665
|
var _a;
|
|
1910
1666
|
return __generator(this, function (_b) {
|
|
1911
1667
|
switch (_b.label) {
|
|
@@ -1920,7 +1676,7 @@
|
|
|
1920
1676
|
return Asset;
|
|
1921
1677
|
}(BaseEntity));
|
|
1922
1678
|
|
|
1923
|
-
var __awaiter$
|
|
1679
|
+
var __awaiter$s = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1924
1680
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1925
1681
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1926
1682
|
function fulfilled(value) { try {
|
|
@@ -1955,21 +1711,21 @@
|
|
|
1955
1711
|
configurable: true
|
|
1956
1712
|
});
|
|
1957
1713
|
TempAsset.prototype.unlink = function () {
|
|
1958
|
-
return __awaiter$
|
|
1714
|
+
return __awaiter$s(this, void 0, void 0, function () {
|
|
1959
1715
|
return __generator(this, function (_a) {
|
|
1960
1716
|
throw new Error("Temp asset '" + this.id + "' can not be removed!");
|
|
1961
1717
|
});
|
|
1962
1718
|
});
|
|
1963
1719
|
};
|
|
1964
1720
|
TempAsset.prototype.getBuffer = function () {
|
|
1965
|
-
return __awaiter$
|
|
1721
|
+
return __awaiter$s(this, void 0, void 0, function () {
|
|
1966
1722
|
return __generator(this, function (_a) {
|
|
1967
1723
|
return [2 /*return*/, this.buffer];
|
|
1968
1724
|
});
|
|
1969
1725
|
});
|
|
1970
1726
|
};
|
|
1971
1727
|
TempAsset.prototype.download = function (metadata) {
|
|
1972
|
-
return __awaiter$
|
|
1728
|
+
return __awaiter$s(this, void 0, void 0, function () {
|
|
1973
1729
|
return __generator(this, function (_a) {
|
|
1974
1730
|
return [2 /*return*/, this.stream];
|
|
1975
1731
|
});
|
|
@@ -1983,14 +1739,14 @@
|
|
|
1983
1739
|
return this.downloadImage(params);
|
|
1984
1740
|
};
|
|
1985
1741
|
TempAsset.prototype.save = function () {
|
|
1986
|
-
return __awaiter$
|
|
1742
|
+
return __awaiter$s(this, void 0, void 0, function () {
|
|
1987
1743
|
return __generator(this, function (_a) {
|
|
1988
1744
|
return [2 /*return*/, this];
|
|
1989
1745
|
});
|
|
1990
1746
|
});
|
|
1991
1747
|
};
|
|
1992
1748
|
TempAsset.prototype.load = function () {
|
|
1993
|
-
return __awaiter$
|
|
1749
|
+
return __awaiter$s(this, void 0, void 0, function () {
|
|
1994
1750
|
return __generator(this, function (_a) {
|
|
1995
1751
|
return [2 /*return*/, this];
|
|
1996
1752
|
});
|
|
@@ -2021,7 +1777,7 @@
|
|
|
2021
1777
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2022
1778
|
return Reflect.metadata(k, v);
|
|
2023
1779
|
};
|
|
2024
|
-
var __awaiter$
|
|
1780
|
+
var __awaiter$r = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2025
1781
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2026
1782
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2027
1783
|
function fulfilled(value) { try {
|
|
@@ -2051,7 +1807,7 @@
|
|
|
2051
1807
|
Assets.prototype.write = function (stream, contentType, metadata) {
|
|
2052
1808
|
if (contentType === void 0) { contentType = null; }
|
|
2053
1809
|
if (metadata === void 0) { metadata = null; }
|
|
2054
|
-
return __awaiter$
|
|
1810
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2055
1811
|
var uploadStream, buffer, fileType, e_1;
|
|
2056
1812
|
return __generator(this, function (_b) {
|
|
2057
1813
|
switch (_b.label) {
|
|
@@ -2085,7 +1841,7 @@
|
|
|
2085
1841
|
Assets.prototype.writeBuffer = function (buffer, metadata, contentType) {
|
|
2086
1842
|
if (metadata === void 0) { metadata = null; }
|
|
2087
1843
|
if (contentType === void 0) { contentType = null; }
|
|
2088
|
-
return __awaiter$
|
|
1844
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2089
1845
|
var fileType, e_2;
|
|
2090
1846
|
return __generator(this, function (_b) {
|
|
2091
1847
|
switch (_b.label) {
|
|
@@ -2117,7 +1873,7 @@
|
|
|
2117
1873
|
};
|
|
2118
1874
|
Assets.prototype.writeUrl = function (url, metadata) {
|
|
2119
1875
|
if (metadata === void 0) { metadata = null; }
|
|
2120
|
-
return __awaiter$
|
|
1876
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2121
1877
|
var buffer;
|
|
2122
1878
|
return __generator(this, function (_b) {
|
|
2123
1879
|
switch (_b.label) {
|
|
@@ -2131,7 +1887,7 @@
|
|
|
2131
1887
|
};
|
|
2132
1888
|
Assets.prototype.download = function (url, contentType) {
|
|
2133
1889
|
if (contentType === void 0) { contentType = null; }
|
|
2134
|
-
return __awaiter$
|
|
1890
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2135
1891
|
var buffer, fileType, e_3, metadata;
|
|
2136
1892
|
return __generator(this, function (_b) {
|
|
2137
1893
|
switch (_b.label) {
|
|
@@ -2167,14 +1923,14 @@
|
|
|
2167
1923
|
});
|
|
2168
1924
|
};
|
|
2169
1925
|
Assets.prototype.read = function (id) {
|
|
2170
|
-
return __awaiter$
|
|
1926
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2171
1927
|
return __generator(this, function (_b) {
|
|
2172
1928
|
return [2 /*return*/, !id ? null : this.find({ _id: new bson.ObjectId(id) })];
|
|
2173
1929
|
});
|
|
2174
1930
|
});
|
|
2175
1931
|
};
|
|
2176
1932
|
Assets.prototype.find = function (where) {
|
|
2177
|
-
return __awaiter$
|
|
1933
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2178
1934
|
var data;
|
|
2179
1935
|
return __generator(this, function (_b) {
|
|
2180
1936
|
switch (_b.label) {
|
|
@@ -2187,7 +1943,7 @@
|
|
|
2187
1943
|
});
|
|
2188
1944
|
};
|
|
2189
1945
|
Assets.prototype.findMany = function (where) {
|
|
2190
|
-
return __awaiter$
|
|
1946
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2191
1947
|
var cursor, items, result, items_1, items_1_1, item;
|
|
2192
1948
|
var e_4, _b;
|
|
2193
1949
|
return __generator(this, function (_c) {
|
|
@@ -2219,7 +1975,7 @@
|
|
|
2219
1975
|
});
|
|
2220
1976
|
};
|
|
2221
1977
|
Assets.prototype.deleteMany = function (where) {
|
|
2222
|
-
return __awaiter$
|
|
1978
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2223
1979
|
var assets;
|
|
2224
1980
|
return __generator(this, function (_b) {
|
|
2225
1981
|
switch (_b.label) {
|
|
@@ -2232,7 +1988,7 @@
|
|
|
2232
1988
|
});
|
|
2233
1989
|
};
|
|
2234
1990
|
Assets.prototype.unlink = function (id) {
|
|
2235
|
-
return __awaiter$
|
|
1991
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2236
1992
|
var asset;
|
|
2237
1993
|
return __generator(this, function (_b) {
|
|
2238
1994
|
switch (_b.label) {
|
|
@@ -2247,7 +2003,7 @@
|
|
|
2247
2003
|
});
|
|
2248
2004
|
};
|
|
2249
2005
|
Assets.prototype.upload = function (stream, fileType, metadata) {
|
|
2250
|
-
return __awaiter$
|
|
2006
|
+
return __awaiter$r(this, void 0, void 0, function () {
|
|
2251
2007
|
var contentType;
|
|
2252
2008
|
var _this = this;
|
|
2253
2009
|
return __generator(this, function (_b) {
|
|
@@ -2289,7 +2045,7 @@
|
|
|
2289
2045
|
__metadata$o("design:paramtypes", [exports.MongoConnector, exports.AssetProcessor])
|
|
2290
2046
|
], exports.Assets);
|
|
2291
2047
|
|
|
2292
|
-
var __awaiter$
|
|
2048
|
+
var __awaiter$q = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2293
2049
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2294
2050
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2295
2051
|
function fulfilled(value) { try {
|
|
@@ -2352,7 +2108,7 @@
|
|
|
2352
2108
|
configurable: true
|
|
2353
2109
|
});
|
|
2354
2110
|
LazyAsset.prototype.unlink = function () {
|
|
2355
|
-
return __awaiter$
|
|
2111
|
+
return __awaiter$q(this, void 0, void 0, function () {
|
|
2356
2112
|
return __generator(this, function (_a) {
|
|
2357
2113
|
switch (_a.label) {
|
|
2358
2114
|
case 0: return [4 /*yield*/, this.load()];
|
|
@@ -2384,7 +2140,7 @@
|
|
|
2384
2140
|
});
|
|
2385
2141
|
};
|
|
2386
2142
|
LazyAsset.prototype.loadAsset = function () {
|
|
2387
|
-
return __awaiter$
|
|
2143
|
+
return __awaiter$q(this, void 0, void 0, function () {
|
|
2388
2144
|
return __generator(this, function (_a) {
|
|
2389
2145
|
switch (_a.label) {
|
|
2390
2146
|
case 0: return [4 /*yield*/, this.load()];
|
|
@@ -2409,7 +2165,7 @@
|
|
|
2409
2165
|
});
|
|
2410
2166
|
};
|
|
2411
2167
|
LazyAsset.prototype.writeAsset = function (asset) {
|
|
2412
|
-
return __awaiter$
|
|
2168
|
+
return __awaiter$q(this, void 0, void 0, function () {
|
|
2413
2169
|
return __generator(this, function (_a) {
|
|
2414
2170
|
switch (_a.label) {
|
|
2415
2171
|
case 0:
|
|
@@ -2423,7 +2179,7 @@
|
|
|
2423
2179
|
});
|
|
2424
2180
|
};
|
|
2425
2181
|
LazyAsset.prototype.startWorkingOnAsset = function (fromLoad) {
|
|
2426
|
-
return __awaiter$
|
|
2182
|
+
return __awaiter$q(this, void 0, void 0, function () {
|
|
2427
2183
|
var _a;
|
|
2428
2184
|
return __generator(this, function (_b) {
|
|
2429
2185
|
switch (_b.label) {
|
|
@@ -2464,7 +2220,7 @@
|
|
|
2464
2220
|
var __param$7 = (this && this.__param) || function (paramIndex, decorator) {
|
|
2465
2221
|
return function (target, key) { decorator(target, key, paramIndex); };
|
|
2466
2222
|
};
|
|
2467
|
-
var __awaiter$
|
|
2223
|
+
var __awaiter$p = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2468
2224
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2469
2225
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2470
2226
|
function fulfilled(value) { try {
|
|
@@ -2515,7 +2271,7 @@
|
|
|
2515
2271
|
};
|
|
2516
2272
|
JobManager.prototype.process = function (jobType, params) {
|
|
2517
2273
|
if (params === void 0) { params = {}; }
|
|
2518
|
-
return __awaiter$
|
|
2274
|
+
return __awaiter$p(this, void 0, void 0, function () {
|
|
2519
2275
|
var instance, jobName;
|
|
2520
2276
|
return __generator(this, function (_a) {
|
|
2521
2277
|
instance = null;
|
|
@@ -2532,7 +2288,7 @@
|
|
|
2532
2288
|
};
|
|
2533
2289
|
JobManager.prototype.enqueueWithName = function (name, params) {
|
|
2534
2290
|
if (params === void 0) { params = {}; }
|
|
2535
|
-
return __awaiter$
|
|
2291
|
+
return __awaiter$p(this, void 0, void 0, function () {
|
|
2536
2292
|
return __generator(this, function (_a) {
|
|
2537
2293
|
return [2 /*return*/, this.sendToWorkers(this.tryResolveFromName(name, params), params)];
|
|
2538
2294
|
});
|
|
@@ -2540,7 +2296,7 @@
|
|
|
2540
2296
|
};
|
|
2541
2297
|
JobManager.prototype.enqueue = function (jobType, params) {
|
|
2542
2298
|
if (params === void 0) { params = {}; }
|
|
2543
|
-
return __awaiter$
|
|
2299
|
+
return __awaiter$p(this, void 0, void 0, function () {
|
|
2544
2300
|
return __generator(this, function (_a) {
|
|
2545
2301
|
return [2 /*return*/, this.sendToWorkers(this.tryResolveAndInit(jobType, params), params)];
|
|
2546
2302
|
});
|
|
@@ -2571,7 +2327,7 @@
|
|
|
2571
2327
|
});
|
|
2572
2328
|
};
|
|
2573
2329
|
JobManager.prototype.startProcessing = function () {
|
|
2574
|
-
return __awaiter$
|
|
2330
|
+
return __awaiter$p(this, void 0, void 0, function () {
|
|
2575
2331
|
var host, pushHost, pullHost;
|
|
2576
2332
|
var _this = this;
|
|
2577
2333
|
return __generator(this, function (_a) {
|
|
@@ -2597,7 +2353,7 @@
|
|
|
2597
2353
|
case 2:
|
|
2598
2354
|
_a.sent();
|
|
2599
2355
|
console.log("Worker consumer connected to: " + pullHost);
|
|
2600
|
-
this.workerPull.on("message", function (name, args, uniqId) { return __awaiter$
|
|
2356
|
+
this.workerPull.on("message", function (name, args, uniqId) { return __awaiter$p(_this, void 0, void 0, function () {
|
|
2601
2357
|
var jobName, jobParams, uniqueId, e_1, e_2;
|
|
2602
2358
|
return __generator(this, function (_a) {
|
|
2603
2359
|
switch (_a.label) {
|
|
@@ -2695,7 +2451,7 @@
|
|
|
2695
2451
|
return container.resolve(jobType);
|
|
2696
2452
|
};
|
|
2697
2453
|
JobManager.prototype.sendToWorkers = function (jobName, params) {
|
|
2698
|
-
return __awaiter$
|
|
2454
|
+
return __awaiter$p(this, void 0, void 0, function () {
|
|
2699
2455
|
var publisher, uniqueId;
|
|
2700
2456
|
return __generator(this, function (_a) {
|
|
2701
2457
|
switch (_a.label) {
|
|
@@ -2720,7 +2476,7 @@
|
|
|
2720
2476
|
__metadata$n("design:paramtypes", [exports.Configuration, Object, Array])
|
|
2721
2477
|
], exports.JobManager);
|
|
2722
2478
|
|
|
2723
|
-
var __awaiter$
|
|
2479
|
+
var __awaiter$o = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2724
2480
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2725
2481
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2726
2482
|
function fulfilled(value) { try {
|
|
@@ -2798,7 +2554,7 @@
|
|
|
2798
2554
|
return this;
|
|
2799
2555
|
};
|
|
2800
2556
|
Progress.prototype.createSubProgress = function (progressValue, max, message) {
|
|
2801
|
-
return __awaiter$
|
|
2557
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2802
2558
|
return __generator(this, function (_a) {
|
|
2803
2559
|
switch (_a.label) {
|
|
2804
2560
|
case 0:
|
|
@@ -2820,7 +2576,7 @@
|
|
|
2820
2576
|
});
|
|
2821
2577
|
};
|
|
2822
2578
|
Progress.prototype.setMax = function (max) {
|
|
2823
|
-
return __awaiter$
|
|
2579
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2824
2580
|
return __generator(this, function (_a) {
|
|
2825
2581
|
switch (_a.label) {
|
|
2826
2582
|
case 0:
|
|
@@ -2837,7 +2593,7 @@
|
|
|
2837
2593
|
});
|
|
2838
2594
|
};
|
|
2839
2595
|
Progress.prototype.setMessage = function (message) {
|
|
2840
|
-
return __awaiter$
|
|
2596
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2841
2597
|
return __generator(this, function (_a) {
|
|
2842
2598
|
switch (_a.label) {
|
|
2843
2599
|
case 0:
|
|
@@ -2851,7 +2607,7 @@
|
|
|
2851
2607
|
});
|
|
2852
2608
|
};
|
|
2853
2609
|
Progress.prototype.setError = function (error) {
|
|
2854
|
-
return __awaiter$
|
|
2610
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2855
2611
|
return __generator(this, function (_a) {
|
|
2856
2612
|
switch (_a.label) {
|
|
2857
2613
|
case 0:
|
|
@@ -2866,7 +2622,7 @@
|
|
|
2866
2622
|
};
|
|
2867
2623
|
Progress.prototype.advance = function (value) {
|
|
2868
2624
|
if (value === void 0) { value = 1; }
|
|
2869
|
-
return __awaiter$
|
|
2625
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2870
2626
|
return __generator(this, function (_a) {
|
|
2871
2627
|
switch (_a.label) {
|
|
2872
2628
|
case 0:
|
|
@@ -2888,7 +2644,7 @@
|
|
|
2888
2644
|
});
|
|
2889
2645
|
};
|
|
2890
2646
|
Progress.prototype.cancel = function () {
|
|
2891
|
-
return __awaiter$
|
|
2647
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2892
2648
|
return __generator(this, function (_a) {
|
|
2893
2649
|
switch (_a.label) {
|
|
2894
2650
|
case 0:
|
|
@@ -2987,7 +2743,7 @@
|
|
|
2987
2743
|
return this;
|
|
2988
2744
|
};
|
|
2989
2745
|
SubProgress.prototype.createSubProgress = function (progressValue, max, message) {
|
|
2990
|
-
return __awaiter$
|
|
2746
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
2991
2747
|
return __generator(this, function (_a) {
|
|
2992
2748
|
switch (_a.label) {
|
|
2993
2749
|
case 0:
|
|
@@ -3008,7 +2764,7 @@
|
|
|
3008
2764
|
});
|
|
3009
2765
|
};
|
|
3010
2766
|
SubProgress.prototype.setMax = function (max) {
|
|
3011
|
-
return __awaiter$
|
|
2767
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3012
2768
|
return __generator(this, function (_a) {
|
|
3013
2769
|
switch (_a.label) {
|
|
3014
2770
|
case 0:
|
|
@@ -3025,7 +2781,7 @@
|
|
|
3025
2781
|
});
|
|
3026
2782
|
};
|
|
3027
2783
|
SubProgress.prototype.setMessage = function (message) {
|
|
3028
|
-
return __awaiter$
|
|
2784
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3029
2785
|
return __generator(this, function (_a) {
|
|
3030
2786
|
switch (_a.label) {
|
|
3031
2787
|
case 0:
|
|
@@ -3040,7 +2796,7 @@
|
|
|
3040
2796
|
});
|
|
3041
2797
|
};
|
|
3042
2798
|
SubProgress.prototype.setError = function (error) {
|
|
3043
|
-
return __awaiter$
|
|
2799
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3044
2800
|
return __generator(this, function (_a) {
|
|
3045
2801
|
switch (_a.label) {
|
|
3046
2802
|
case 0:
|
|
@@ -3056,7 +2812,7 @@
|
|
|
3056
2812
|
};
|
|
3057
2813
|
SubProgress.prototype.advance = function (value) {
|
|
3058
2814
|
if (value === void 0) { value = 1; }
|
|
3059
|
-
return __awaiter$
|
|
2815
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3060
2816
|
return __generator(this, function (_a) {
|
|
3061
2817
|
switch (_a.label) {
|
|
3062
2818
|
case 0:
|
|
@@ -3073,7 +2829,7 @@
|
|
|
3073
2829
|
});
|
|
3074
2830
|
};
|
|
3075
2831
|
SubProgress.prototype.cancel = function () {
|
|
3076
|
-
return __awaiter$
|
|
2832
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3077
2833
|
return __generator(this, function (_a) {
|
|
3078
2834
|
switch (_a.label) {
|
|
3079
2835
|
case 0:
|
|
@@ -3088,7 +2844,7 @@
|
|
|
3088
2844
|
});
|
|
3089
2845
|
};
|
|
3090
2846
|
SubProgress.prototype.save = function () {
|
|
3091
|
-
return __awaiter$
|
|
2847
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3092
2848
|
var ratio, newProgress, current;
|
|
3093
2849
|
return __generator(this, function (_a) {
|
|
3094
2850
|
switch (_a.label) {
|
|
@@ -3107,7 +2863,7 @@
|
|
|
3107
2863
|
});
|
|
3108
2864
|
};
|
|
3109
2865
|
SubProgress.prototype.load = function () {
|
|
3110
|
-
return __awaiter$
|
|
2866
|
+
return __awaiter$o(this, void 0, void 0, function () {
|
|
3111
2867
|
return __generator(this, function (_a) {
|
|
3112
2868
|
return [2 /*return*/, null];
|
|
3113
2869
|
});
|
|
@@ -3133,7 +2889,7 @@
|
|
|
3133
2889
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3134
2890
|
return Reflect.metadata(k, v);
|
|
3135
2891
|
};
|
|
3136
|
-
var __awaiter$
|
|
2892
|
+
var __awaiter$n = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3137
2893
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3138
2894
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3139
2895
|
function fulfilled(value) { try {
|
|
@@ -3165,11 +2921,11 @@
|
|
|
3165
2921
|
});
|
|
3166
2922
|
}
|
|
3167
2923
|
Progresses.prototype.waitToFinish = function (id) {
|
|
3168
|
-
return __awaiter$
|
|
2924
|
+
return __awaiter$n(this, void 0, void 0, function () {
|
|
3169
2925
|
var _this = this;
|
|
3170
2926
|
return __generator(this, function (_a) {
|
|
3171
2927
|
return [2 /*return*/, Promise.race([
|
|
3172
|
-
this.waitForProgress(id, function () { return __awaiter$
|
|
2928
|
+
this.waitForProgress(id, function () { return __awaiter$n(_this, void 0, void 0, function () {
|
|
3173
2929
|
var progress;
|
|
3174
2930
|
return __generator(this, function (_a) {
|
|
3175
2931
|
switch (_a.label) {
|
|
@@ -3188,7 +2944,7 @@
|
|
|
3188
2944
|
}
|
|
3189
2945
|
});
|
|
3190
2946
|
}); }, 500),
|
|
3191
|
-
this.waitForProgress(id, function () { return __awaiter$
|
|
2947
|
+
this.waitForProgress(id, function () { return __awaiter$n(_this, void 0, void 0, function () {
|
|
3192
2948
|
return __generator(this, function (_a) {
|
|
3193
2949
|
return [2 /*return*/, this.progresses[id] || null];
|
|
3194
2950
|
});
|
|
@@ -3198,14 +2954,14 @@
|
|
|
3198
2954
|
});
|
|
3199
2955
|
};
|
|
3200
2956
|
Progresses.prototype.get = function (id) {
|
|
3201
|
-
return __awaiter$
|
|
2957
|
+
return __awaiter$n(this, void 0, void 0, function () {
|
|
3202
2958
|
return __generator(this, function (_a) {
|
|
3203
2959
|
return [2 /*return*/, !id ? null : this.find({ _id: new bson.ObjectId(id) })];
|
|
3204
2960
|
});
|
|
3205
2961
|
});
|
|
3206
2962
|
};
|
|
3207
2963
|
Progresses.prototype.find = function (where) {
|
|
3208
|
-
return __awaiter$
|
|
2964
|
+
return __awaiter$n(this, void 0, void 0, function () {
|
|
3209
2965
|
var data;
|
|
3210
2966
|
return __generator(this, function (_a) {
|
|
3211
2967
|
switch (_a.label) {
|
|
@@ -3219,7 +2975,7 @@
|
|
|
3219
2975
|
};
|
|
3220
2976
|
Progresses.prototype.create = function (max) {
|
|
3221
2977
|
if (max === void 0) { max = 100; }
|
|
3222
|
-
return __awaiter$
|
|
2978
|
+
return __awaiter$n(this, void 0, void 0, function () {
|
|
3223
2979
|
var data, res;
|
|
3224
2980
|
return __generator(this, function (_a) {
|
|
3225
2981
|
switch (_a.label) {
|
|
@@ -3243,7 +2999,7 @@
|
|
|
3243
2999
|
});
|
|
3244
3000
|
};
|
|
3245
3001
|
Progresses.prototype.remove = function (id) {
|
|
3246
|
-
return __awaiter$
|
|
3002
|
+
return __awaiter$n(this, void 0, void 0, function () {
|
|
3247
3003
|
return __generator(this, function (_a) {
|
|
3248
3004
|
switch (_a.label) {
|
|
3249
3005
|
case 0: return [4 /*yield*/, this.collection.deleteOne({ _id: new bson.ObjectId(id) })];
|
|
@@ -3255,7 +3011,7 @@
|
|
|
3255
3011
|
});
|
|
3256
3012
|
};
|
|
3257
3013
|
Progresses.prototype.waitForProgress = function (id, cb, delay) {
|
|
3258
|
-
return __awaiter$
|
|
3014
|
+
return __awaiter$n(this, void 0, void 0, function () {
|
|
3259
3015
|
var isFinished, progress, waitTime;
|
|
3260
3016
|
return __generator(this, function (_a) {
|
|
3261
3017
|
switch (_a.label) {
|
|
@@ -3312,7 +3068,7 @@
|
|
|
3312
3068
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3313
3069
|
return Reflect.metadata(k, v);
|
|
3314
3070
|
};
|
|
3315
|
-
var __awaiter$
|
|
3071
|
+
var __awaiter$m = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3316
3072
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3317
3073
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3318
3074
|
function fulfilled(value) { try {
|
|
@@ -3342,7 +3098,7 @@
|
|
|
3342
3098
|
LazyAssets.prototype.create = function (jobType, jobParams, jobQue) {
|
|
3343
3099
|
if (jobParams === void 0) { jobParams = {}; }
|
|
3344
3100
|
if (jobQue === void 0) { jobQue = "main"; }
|
|
3345
|
-
return __awaiter$
|
|
3101
|
+
return __awaiter$m(this, void 0, void 0, function () {
|
|
3346
3102
|
var jobName, data, existingAsset, res;
|
|
3347
3103
|
return __generator(this, function (_a) {
|
|
3348
3104
|
switch (_a.label) {
|
|
@@ -3367,14 +3123,14 @@
|
|
|
3367
3123
|
});
|
|
3368
3124
|
};
|
|
3369
3125
|
LazyAssets.prototype.read = function (id) {
|
|
3370
|
-
return __awaiter$
|
|
3126
|
+
return __awaiter$m(this, void 0, void 0, function () {
|
|
3371
3127
|
return __generator(this, function (_a) {
|
|
3372
3128
|
return [2 /*return*/, !id ? null : this.find({ _id: new bson.ObjectId(id) })];
|
|
3373
3129
|
});
|
|
3374
3130
|
});
|
|
3375
3131
|
};
|
|
3376
3132
|
LazyAssets.prototype.find = function (where) {
|
|
3377
|
-
return __awaiter$
|
|
3133
|
+
return __awaiter$m(this, void 0, void 0, function () {
|
|
3378
3134
|
var data;
|
|
3379
3135
|
return __generator(this, function (_a) {
|
|
3380
3136
|
switch (_a.label) {
|
|
@@ -3389,7 +3145,7 @@
|
|
|
3389
3145
|
});
|
|
3390
3146
|
};
|
|
3391
3147
|
LazyAssets.prototype.unlink = function (id) {
|
|
3392
|
-
return __awaiter$
|
|
3148
|
+
return __awaiter$m(this, void 0, void 0, function () {
|
|
3393
3149
|
var asset;
|
|
3394
3150
|
return __generator(this, function (_a) {
|
|
3395
3151
|
switch (_a.label) {
|
|
@@ -3428,7 +3184,7 @@
|
|
|
3428
3184
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3429
3185
|
return Reflect.metadata(k, v);
|
|
3430
3186
|
};
|
|
3431
|
-
var __awaiter$
|
|
3187
|
+
var __awaiter$l = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3432
3188
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3433
3189
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3434
3190
|
function fulfilled(value) { try {
|
|
@@ -3454,7 +3210,7 @@
|
|
|
3454
3210
|
}
|
|
3455
3211
|
AssetResolver.prototype.resolve = function (id, lazy) {
|
|
3456
3212
|
if (lazy === void 0) { lazy = false; }
|
|
3457
|
-
return __awaiter$
|
|
3213
|
+
return __awaiter$l(this, void 0, void 0, function () {
|
|
3458
3214
|
var asset, lazyAsset, lazyAsset;
|
|
3459
3215
|
return __generator(this, function (_a) {
|
|
3460
3216
|
switch (_a.label) {
|
|
@@ -3537,7 +3293,7 @@
|
|
|
3537
3293
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3538
3294
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3539
3295
|
};
|
|
3540
|
-
var __awaiter$
|
|
3296
|
+
var __awaiter$k = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3541
3297
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3542
3298
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3543
3299
|
function fulfilled(value) { try {
|
|
@@ -3560,14 +3316,14 @@
|
|
|
3560
3316
|
function CacheProcessor() {
|
|
3561
3317
|
}
|
|
3562
3318
|
CacheProcessor.prototype.serialize = function (data) {
|
|
3563
|
-
return __awaiter$
|
|
3319
|
+
return __awaiter$k(this, void 0, void 0, function () {
|
|
3564
3320
|
return __generator(this, function (_a) {
|
|
3565
3321
|
return [2 /*return*/, data];
|
|
3566
3322
|
});
|
|
3567
3323
|
});
|
|
3568
3324
|
};
|
|
3569
3325
|
CacheProcessor.prototype.deserialize = function (data) {
|
|
3570
|
-
return __awaiter$
|
|
3326
|
+
return __awaiter$k(this, void 0, void 0, function () {
|
|
3571
3327
|
return __generator(this, function (_a) {
|
|
3572
3328
|
return [2 /*return*/, data];
|
|
3573
3329
|
});
|
|
@@ -3594,7 +3350,7 @@
|
|
|
3594
3350
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
3595
3351
|
return Reflect.metadata(k, v);
|
|
3596
3352
|
};
|
|
3597
|
-
var __awaiter$
|
|
3353
|
+
var __awaiter$j = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3598
3354
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3599
3355
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3600
3356
|
function fulfilled(value) { try {
|
|
@@ -3620,7 +3376,7 @@
|
|
|
3620
3376
|
this.cacheProcessor = cacheProcessor;
|
|
3621
3377
|
}
|
|
3622
3378
|
Cache.prototype.prepare = function () {
|
|
3623
|
-
return __awaiter$
|
|
3379
|
+
return __awaiter$j(this, void 0, void 0, function () {
|
|
3624
3380
|
return __generator(this, function (_a) {
|
|
3625
3381
|
switch (_a.label) {
|
|
3626
3382
|
case 0:
|
|
@@ -3641,7 +3397,7 @@
|
|
|
3641
3397
|
Cache.prototype.set = function (key, value, ttl, expirationTimestamp, tags) {
|
|
3642
3398
|
if (expirationTimestamp === void 0) { expirationTimestamp = null; }
|
|
3643
3399
|
if (tags === void 0) { tags = {}; }
|
|
3644
|
-
return __awaiter$
|
|
3400
|
+
return __awaiter$j(this, void 0, void 0, function () {
|
|
3645
3401
|
var item, _a, now;
|
|
3646
3402
|
return __generator(this, function (_b) {
|
|
3647
3403
|
switch (_b.label) {
|
|
@@ -3672,7 +3428,7 @@
|
|
|
3672
3428
|
});
|
|
3673
3429
|
};
|
|
3674
3430
|
Cache.prototype.get = function (key) {
|
|
3675
|
-
return __awaiter$
|
|
3431
|
+
return __awaiter$j(this, void 0, void 0, function () {
|
|
3676
3432
|
var item, now;
|
|
3677
3433
|
return __generator(this, function (_a) {
|
|
3678
3434
|
switch (_a.label) {
|
|
@@ -3698,7 +3454,7 @@
|
|
|
3698
3454
|
Cache.prototype.getOrSet = function (key, valueCb, ttl, expirationTimestamp, tags) {
|
|
3699
3455
|
if (expirationTimestamp === void 0) { expirationTimestamp = null; }
|
|
3700
3456
|
if (tags === void 0) { tags = {}; }
|
|
3701
|
-
return __awaiter$
|
|
3457
|
+
return __awaiter$j(this, void 0, void 0, function () {
|
|
3702
3458
|
var e_1, _a, _b;
|
|
3703
3459
|
return __generator(this, function (_c) {
|
|
3704
3460
|
switch (_c.label) {
|
|
@@ -3719,7 +3475,7 @@
|
|
|
3719
3475
|
});
|
|
3720
3476
|
};
|
|
3721
3477
|
Cache.prototype.delete = function (key) {
|
|
3722
|
-
return __awaiter$
|
|
3478
|
+
return __awaiter$j(this, void 0, void 0, function () {
|
|
3723
3479
|
return __generator(this, function (_a) {
|
|
3724
3480
|
switch (_a.label) {
|
|
3725
3481
|
case 0: return [4 /*yield*/, this.prepare()];
|
|
@@ -3751,7 +3507,7 @@
|
|
|
3751
3507
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3752
3508
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3753
3509
|
};
|
|
3754
|
-
var __awaiter$
|
|
3510
|
+
var __awaiter$i = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3755
3511
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3756
3512
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3757
3513
|
function fulfilled(value) { try {
|
|
@@ -3774,7 +3530,7 @@
|
|
|
3774
3530
|
function EndpointProvider() {
|
|
3775
3531
|
}
|
|
3776
3532
|
EndpointProvider.prototype.configure = function (app) {
|
|
3777
|
-
return __awaiter$
|
|
3533
|
+
return __awaiter$i(this, void 0, void 0, function () {
|
|
3778
3534
|
return __generator(this, function (_a) {
|
|
3779
3535
|
console.log("Express app is mounted to: " + app.mountpath);
|
|
3780
3536
|
return [2 /*return*/];
|
|
@@ -3805,7 +3561,7 @@
|
|
|
3805
3561
|
var __param$6 = (this && this.__param) || function (paramIndex, decorator) {
|
|
3806
3562
|
return function (target, key) { decorator(target, key, paramIndex); };
|
|
3807
3563
|
};
|
|
3808
|
-
var __awaiter$
|
|
3564
|
+
var __awaiter$h = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3809
3565
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3810
3566
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3811
3567
|
function fulfilled(value) { try {
|
|
@@ -3829,7 +3585,7 @@
|
|
|
3829
3585
|
this.fixtures = fixtures;
|
|
3830
3586
|
}
|
|
3831
3587
|
Fixtures.prototype.load = function () {
|
|
3832
|
-
return __awaiter$
|
|
3588
|
+
return __awaiter$h(this, void 0, void 0, function () {
|
|
3833
3589
|
var _a, _b, fixture, e_1_1;
|
|
3834
3590
|
var e_1, _c;
|
|
3835
3591
|
return __generator(this, function (_d) {
|
|
@@ -3877,7 +3633,7 @@
|
|
|
3877
3633
|
__metadata$h("design:paramtypes", [Array])
|
|
3878
3634
|
], exports.Fixtures);
|
|
3879
3635
|
|
|
3880
|
-
var __awaiter$
|
|
3636
|
+
var __awaiter$g = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3881
3637
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3882
3638
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3883
3639
|
function fulfilled(value) { try {
|
|
@@ -3908,7 +3664,7 @@
|
|
|
3908
3664
|
this.targetSize = !size ? { width: thumbSize, height: thumbSize } : size;
|
|
3909
3665
|
}
|
|
3910
3666
|
GalleryImage.prototype.serve = function (id) {
|
|
3911
|
-
return __awaiter$
|
|
3667
|
+
return __awaiter$g(this, void 0, void 0, function () {
|
|
3912
3668
|
var isThumb, original, _a, meta, ratio, sizeRatio, size, targetHeight, targetWidth, resized, buffer;
|
|
3913
3669
|
return __generator(this, function (_b) {
|
|
3914
3670
|
switch (_b.label) {
|
|
@@ -4004,7 +3760,7 @@
|
|
|
4004
3760
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4005
3761
|
return Reflect.metadata(k, v);
|
|
4006
3762
|
};
|
|
4007
|
-
var __awaiter$
|
|
3763
|
+
var __awaiter$f = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4008
3764
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4009
3765
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4010
3766
|
function fulfilled(value) { try {
|
|
@@ -4034,7 +3790,7 @@
|
|
|
4034
3790
|
}
|
|
4035
3791
|
Gallery.prototype.getFolder = function (folder, size) {
|
|
4036
3792
|
if (size === void 0) { size = null; }
|
|
4037
|
-
return __awaiter$
|
|
3793
|
+
return __awaiter$f(this, void 0, void 0, function () {
|
|
4038
3794
|
var _this = this;
|
|
4039
3795
|
return __generator(this, function (_a) {
|
|
4040
3796
|
this.cache[folder] = this.cache[folder] || new Promise(function (resolve) {
|
|
@@ -4059,7 +3815,7 @@
|
|
|
4059
3815
|
return;
|
|
4060
3816
|
}
|
|
4061
3817
|
var promises = files.map(function (file) {
|
|
4062
|
-
return new Promise(function (resolve) { return __awaiter$
|
|
3818
|
+
return new Promise(function (resolve) { return __awaiter$f(_this, void 0, void 0, function () {
|
|
4063
3819
|
var filePath, absoluteFilePath;
|
|
4064
3820
|
var _this = this;
|
|
4065
3821
|
return __generator(this, function (_a) {
|
|
@@ -4095,7 +3851,7 @@
|
|
|
4095
3851
|
});
|
|
4096
3852
|
},
|
|
4097
3853
|
writeResult: function (isThumb, buffer) {
|
|
4098
|
-
return new Promise(function (res, rej) { return __awaiter$
|
|
3854
|
+
return new Promise(function (res, rej) { return __awaiter$f(_this, void 0, void 0, function () {
|
|
4099
3855
|
var resultPath;
|
|
4100
3856
|
return __generator(this, function (_a) {
|
|
4101
3857
|
switch (_a.label) {
|
|
@@ -4169,7 +3925,7 @@
|
|
|
4169
3925
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4170
3926
|
return Reflect.metadata(k, v);
|
|
4171
3927
|
};
|
|
4172
|
-
var __awaiter$
|
|
3928
|
+
var __awaiter$e = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4173
3929
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4174
3930
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4175
3931
|
function fulfilled(value) { try {
|
|
@@ -4197,7 +3953,7 @@
|
|
|
4197
3953
|
this.parts = config.resolve("idParts");
|
|
4198
3954
|
}
|
|
4199
3955
|
IdGenerator.prototype.generate = function (checkCb) {
|
|
4200
|
-
return __awaiter$
|
|
3956
|
+
return __awaiter$e(this, void 0, void 0, function () {
|
|
4201
3957
|
var id, tries, notGood;
|
|
4202
3958
|
return __generator(this, function (_a) {
|
|
4203
3959
|
switch (_a.label) {
|
|
@@ -4289,7 +4045,7 @@
|
|
|
4289
4045
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4290
4046
|
return Reflect.metadata(k, v);
|
|
4291
4047
|
};
|
|
4292
|
-
var __awaiter$
|
|
4048
|
+
var __awaiter$d = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4293
4049
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4294
4050
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4295
4051
|
function fulfilled(value) { try {
|
|
@@ -4314,7 +4070,7 @@
|
|
|
4314
4070
|
this.cache = {};
|
|
4315
4071
|
}
|
|
4316
4072
|
Translator.prototype.getDictionary = function (language) {
|
|
4317
|
-
return __awaiter$
|
|
4073
|
+
return __awaiter$d(this, void 0, void 0, function () {
|
|
4318
4074
|
var dictionary;
|
|
4319
4075
|
return __generator(this, function (_a) {
|
|
4320
4076
|
switch (_a.label) {
|
|
@@ -4399,7 +4155,7 @@
|
|
|
4399
4155
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4400
4156
|
return Reflect.metadata(k, v);
|
|
4401
4157
|
};
|
|
4402
|
-
var __awaiter$
|
|
4158
|
+
var __awaiter$c = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4403
4159
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4404
4160
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4405
4161
|
function fulfilled(value) { try {
|
|
@@ -4442,11 +4198,11 @@
|
|
|
4442
4198
|
return this.initPromise;
|
|
4443
4199
|
};
|
|
4444
4200
|
TemplateRenderer.prototype.parseTemplates = function (dir, dirPath) {
|
|
4445
|
-
return __awaiter$
|
|
4201
|
+
return __awaiter$c(this, void 0, void 0, function () {
|
|
4446
4202
|
var _this = this;
|
|
4447
4203
|
return __generator(this, function (_a) {
|
|
4448
4204
|
return [2 /*return*/, new Promise(function (resolve) {
|
|
4449
|
-
fs.readdir(dir, function (err, files) { return __awaiter$
|
|
4205
|
+
fs.readdir(dir, function (err, files) { return __awaiter$c(_this, void 0, void 0, function () {
|
|
4450
4206
|
var files_1, files_1_1, file, path$1, parts, name, fullName, content, e_1_1;
|
|
4451
4207
|
var e_1, _a;
|
|
4452
4208
|
return __generator(this, function (_b) {
|
|
@@ -4498,7 +4254,7 @@
|
|
|
4498
4254
|
});
|
|
4499
4255
|
};
|
|
4500
4256
|
TemplateRenderer.prototype.render = function (template, language, context) {
|
|
4501
|
-
return __awaiter$
|
|
4257
|
+
return __awaiter$c(this, void 0, void 0, function () {
|
|
4502
4258
|
var res, _a;
|
|
4503
4259
|
return __generator(this, function (_b) {
|
|
4504
4260
|
switch (_b.label) {
|
|
@@ -4548,7 +4304,7 @@
|
|
|
4548
4304
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4549
4305
|
return Reflect.metadata(k, v);
|
|
4550
4306
|
};
|
|
4551
|
-
var __awaiter$
|
|
4307
|
+
var __awaiter$b = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4552
4308
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4553
4309
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4554
4310
|
function fulfilled(value) { try {
|
|
@@ -4588,7 +4344,7 @@
|
|
|
4588
4344
|
configurable: true
|
|
4589
4345
|
});
|
|
4590
4346
|
MailSender.prototype.sendMail = function (language, options) {
|
|
4591
|
-
return __awaiter$
|
|
4347
|
+
return __awaiter$b(this, void 0, void 0, function () {
|
|
4592
4348
|
var subject, html;
|
|
4593
4349
|
return __generator(this, function (_a) {
|
|
4594
4350
|
switch (_a.label) {
|
|
@@ -4631,7 +4387,7 @@
|
|
|
4631
4387
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4632
4388
|
return Reflect.metadata(k, v);
|
|
4633
4389
|
};
|
|
4634
|
-
var __awaiter$
|
|
4390
|
+
var __awaiter$a = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4635
4391
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4636
4392
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4637
4393
|
function fulfilled(value) { try {
|
|
@@ -4658,7 +4414,7 @@
|
|
|
4658
4414
|
MemoryCache.prototype.set = function (key, value, ttl, expirationTimestamp, tags) {
|
|
4659
4415
|
if (expirationTimestamp === void 0) { expirationTimestamp = null; }
|
|
4660
4416
|
if (tags === void 0) { tags = {}; }
|
|
4661
|
-
return __awaiter$
|
|
4417
|
+
return __awaiter$a(this, void 0, void 0, function () {
|
|
4662
4418
|
var now, expTimestamp;
|
|
4663
4419
|
return __generator(this, function (_a) {
|
|
4664
4420
|
now = Math.round(new Date().getTime() / 1000);
|
|
@@ -4674,7 +4430,7 @@
|
|
|
4674
4430
|
});
|
|
4675
4431
|
};
|
|
4676
4432
|
MemoryCache.prototype.get = function (key) {
|
|
4677
|
-
return __awaiter$
|
|
4433
|
+
return __awaiter$a(this, void 0, void 0, function () {
|
|
4678
4434
|
var item, now, expTimestamp, value;
|
|
4679
4435
|
return __generator(this, function (_a) {
|
|
4680
4436
|
switch (_a.label) {
|
|
@@ -4705,7 +4461,7 @@
|
|
|
4705
4461
|
MemoryCache.prototype.getOrSet = function (key, valueCb, ttl, expirationTimestamp, tags) {
|
|
4706
4462
|
if (expirationTimestamp === void 0) { expirationTimestamp = null; }
|
|
4707
4463
|
if (tags === void 0) { tags = {}; }
|
|
4708
|
-
return __awaiter$
|
|
4464
|
+
return __awaiter$a(this, void 0, void 0, function () {
|
|
4709
4465
|
var e_1, _a, _b;
|
|
4710
4466
|
return __generator(this, function (_c) {
|
|
4711
4467
|
switch (_c.label) {
|
|
@@ -4726,7 +4482,7 @@
|
|
|
4726
4482
|
});
|
|
4727
4483
|
};
|
|
4728
4484
|
MemoryCache.prototype.delete = function (key) {
|
|
4729
|
-
return __awaiter$
|
|
4485
|
+
return __awaiter$a(this, void 0, void 0, function () {
|
|
4730
4486
|
return __generator(this, function (_a) {
|
|
4731
4487
|
switch (_a.label) {
|
|
4732
4488
|
case 0:
|
|
@@ -4757,7 +4513,7 @@
|
|
|
4757
4513
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4758
4514
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4759
4515
|
};
|
|
4760
|
-
var __awaiter$
|
|
4516
|
+
var __awaiter$9 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4761
4517
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4762
4518
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4763
4519
|
function fulfilled(value) { try {
|
|
@@ -4786,7 +4542,7 @@
|
|
|
4786
4542
|
function UserManager() {
|
|
4787
4543
|
}
|
|
4788
4544
|
UserManager.prototype.getByCredentials = function (credentials) {
|
|
4789
|
-
return __awaiter$
|
|
4545
|
+
return __awaiter$9(this, void 0, void 0, function () {
|
|
4790
4546
|
var _a;
|
|
4791
4547
|
return __generator(this, function (_b) {
|
|
4792
4548
|
switch (_b.label) {
|
|
@@ -4804,14 +4560,14 @@
|
|
|
4804
4560
|
});
|
|
4805
4561
|
};
|
|
4806
4562
|
UserManager.prototype.getById = function (id) {
|
|
4807
|
-
return __awaiter$
|
|
4563
|
+
return __awaiter$9(this, void 0, void 0, function () {
|
|
4808
4564
|
return __generator(this, function (_a) {
|
|
4809
4565
|
return [2 /*return*/, (sampleUser.id == id) ? sampleUser : null];
|
|
4810
4566
|
});
|
|
4811
4567
|
});
|
|
4812
4568
|
};
|
|
4813
4569
|
UserManager.prototype.serialize = function (user) {
|
|
4814
|
-
return __awaiter$
|
|
4570
|
+
return __awaiter$9(this, void 0, void 0, function () {
|
|
4815
4571
|
var res;
|
|
4816
4572
|
return __generator(this, function (_a) {
|
|
4817
4573
|
res = Object.assign({}, user);
|
|
@@ -4919,7 +4675,7 @@
|
|
|
4919
4675
|
var __param$5 = (this && this.__param) || function (paramIndex, decorator) {
|
|
4920
4676
|
return function (target, key) { decorator(target, key, paramIndex); };
|
|
4921
4677
|
};
|
|
4922
|
-
var __awaiter$
|
|
4678
|
+
var __awaiter$8 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4923
4679
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4924
4680
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4925
4681
|
function fulfilled(value) { try {
|
|
@@ -4944,7 +4700,7 @@
|
|
|
4944
4700
|
this.assetResolver = assetResolver;
|
|
4945
4701
|
}
|
|
4946
4702
|
AssetsController.prototype.upload = function (file) {
|
|
4947
|
-
return __awaiter$
|
|
4703
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
4948
4704
|
var contentType, asset, e_1, msg;
|
|
4949
4705
|
return __generator(this, function (_c) {
|
|
4950
4706
|
switch (_c.label) {
|
|
@@ -4965,7 +4721,7 @@
|
|
|
4965
4721
|
});
|
|
4966
4722
|
};
|
|
4967
4723
|
AssetsController.prototype.uploadUrl = function (body) {
|
|
4968
|
-
return __awaiter$
|
|
4724
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
4969
4725
|
var asset, e_2, msg;
|
|
4970
4726
|
return __generator(this, function (_c) {
|
|
4971
4727
|
switch (_c.label) {
|
|
@@ -4985,7 +4741,7 @@
|
|
|
4985
4741
|
});
|
|
4986
4742
|
};
|
|
4987
4743
|
AssetsController.prototype.getFile = function (id, lazy, res) {
|
|
4988
|
-
return __awaiter$
|
|
4744
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
4989
4745
|
var asset;
|
|
4990
4746
|
return __generator(this, function (_c) {
|
|
4991
4747
|
switch (_c.label) {
|
|
@@ -4999,7 +4755,7 @@
|
|
|
4999
4755
|
};
|
|
5000
4756
|
AssetsController.prototype.getImageRotation = function (id, params, res, rotation) {
|
|
5001
4757
|
if (rotation === void 0) { rotation = 0; }
|
|
5002
|
-
return __awaiter$
|
|
4758
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
5003
4759
|
var asset;
|
|
5004
4760
|
return __generator(this, function (_c) {
|
|
5005
4761
|
switch (_c.label) {
|
|
@@ -5015,14 +4771,14 @@
|
|
|
5015
4771
|
});
|
|
5016
4772
|
};
|
|
5017
4773
|
AssetsController.prototype.getImage = function (id, params, res) {
|
|
5018
|
-
return __awaiter$
|
|
4774
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
5019
4775
|
return __generator(this, function (_c) {
|
|
5020
4776
|
return [2 /*return*/, this.getImageRotation(id, params, res)];
|
|
5021
4777
|
});
|
|
5022
4778
|
});
|
|
5023
4779
|
};
|
|
5024
4780
|
AssetsController.prototype.getFileByName = function (name, res) {
|
|
5025
|
-
return __awaiter$
|
|
4781
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
5026
4782
|
var asset;
|
|
5027
4783
|
return __generator(this, function (_c) {
|
|
5028
4784
|
switch (_c.label) {
|
|
@@ -5035,7 +4791,7 @@
|
|
|
5035
4791
|
});
|
|
5036
4792
|
};
|
|
5037
4793
|
AssetsController.prototype.getImageByName = function (name, params, res) {
|
|
5038
|
-
return __awaiter$
|
|
4794
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
5039
4795
|
var asset;
|
|
5040
4796
|
return __generator(this, function (_c) {
|
|
5041
4797
|
switch (_c.label) {
|
|
@@ -5061,7 +4817,7 @@
|
|
|
5061
4817
|
}
|
|
5062
4818
|
};
|
|
5063
4819
|
AssetsController.prototype.getAsset = function (type, id, lazy, res) {
|
|
5064
|
-
return __awaiter$
|
|
4820
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
5065
4821
|
var asset;
|
|
5066
4822
|
return __generator(this, function (_c) {
|
|
5067
4823
|
switch (_c.label) {
|
|
@@ -5078,7 +4834,7 @@
|
|
|
5078
4834
|
});
|
|
5079
4835
|
};
|
|
5080
4836
|
AssetsController.prototype.getAssetByName = function (type, filename, res) {
|
|
5081
|
-
return __awaiter$
|
|
4837
|
+
return __awaiter$8(this, void 0, void 0, function () {
|
|
5082
4838
|
var asset;
|
|
5083
4839
|
return __generator(this, function (_c) {
|
|
5084
4840
|
switch (_c.label) {
|
|
@@ -5170,7 +4926,7 @@
|
|
|
5170
4926
|
var __param$4 = (this && this.__param) || function (paramIndex, decorator) {
|
|
5171
4927
|
return function (target, key) { decorator(target, key, paramIndex); };
|
|
5172
4928
|
};
|
|
5173
|
-
var __awaiter$
|
|
4929
|
+
var __awaiter$7 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5174
4930
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5175
4931
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5176
4932
|
function fulfilled(value) { try {
|
|
@@ -5195,30 +4951,40 @@
|
|
|
5195
4951
|
this.userManager = userManager;
|
|
5196
4952
|
}
|
|
5197
4953
|
AuthController.prototype.login = function (credentials, res) {
|
|
5198
|
-
return __awaiter$
|
|
5199
|
-
var user, valid, _a,
|
|
5200
|
-
return __generator(this, function (
|
|
5201
|
-
switch (
|
|
4954
|
+
return __awaiter$7(this, void 0, void 0, function () {
|
|
4955
|
+
var user, reason_1, valid, _a, _b;
|
|
4956
|
+
return __generator(this, function (_c) {
|
|
4957
|
+
switch (_c.label) {
|
|
5202
4958
|
case 0:
|
|
5203
|
-
|
|
5204
|
-
|
|
4959
|
+
user = null;
|
|
4960
|
+
_c.label = 1;
|
|
5205
4961
|
case 1:
|
|
5206
|
-
|
|
5207
|
-
return [4 /*yield*/,
|
|
4962
|
+
_c.trys.push([1, 3, , 4]);
|
|
4963
|
+
return [4 /*yield*/, this.userManager.getByCredentials(credentials)];
|
|
5208
4964
|
case 2:
|
|
5209
|
-
|
|
4965
|
+
user = _c.sent();
|
|
4966
|
+
return [3 /*break*/, 4];
|
|
4967
|
+
case 3:
|
|
4968
|
+
reason_1 = _c.sent();
|
|
4969
|
+
throw new routingControllers.HttpError(401, reason_1);
|
|
4970
|
+
case 4:
|
|
4971
|
+
if (!!user) return [3 /*break*/, 5];
|
|
4972
|
+
_a = false;
|
|
4973
|
+
return [3 /*break*/, 7];
|
|
4974
|
+
case 5: return [4 /*yield*/, bcrypt.compare(credentials.password, user.password)];
|
|
4975
|
+
case 6:
|
|
4976
|
+
_a = _c.sent();
|
|
4977
|
+
_c.label = 7;
|
|
4978
|
+
case 7:
|
|
4979
|
+
valid = _a;
|
|
5210
4980
|
if (valid !== true)
|
|
5211
|
-
throw "message.login.error";
|
|
5212
|
-
|
|
4981
|
+
throw new routingControllers.UnauthorizedError("message.login.error");
|
|
4982
|
+
_b = {
|
|
5213
4983
|
token: jsonwebtoken.sign({ id: user._id || user.id }, this.config.resolve("jwtSecret"))
|
|
5214
4984
|
};
|
|
5215
4985
|
return [4 /*yield*/, this.userManager.serialize(user)];
|
|
5216
|
-
case
|
|
5217
|
-
|
|
5218
|
-
case 4:
|
|
5219
|
-
reason_1 = _b.sent();
|
|
5220
|
-
throw new routingControllers.HttpError(401, reason_1);
|
|
5221
|
-
case 5: return [2 /*return*/];
|
|
4986
|
+
case 8: return [2 /*return*/, (_b.user = _c.sent(),
|
|
4987
|
+
_b)];
|
|
5222
4988
|
}
|
|
5223
4989
|
});
|
|
5224
4990
|
});
|
|
@@ -5305,7 +5071,7 @@
|
|
|
5305
5071
|
var __param$2 = (this && this.__param) || function (paramIndex, decorator) {
|
|
5306
5072
|
return function (target, key) { decorator(target, key, paramIndex); };
|
|
5307
5073
|
};
|
|
5308
|
-
var __awaiter$
|
|
5074
|
+
var __awaiter$6 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5309
5075
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5310
5076
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5311
5077
|
function fulfilled(value) { try {
|
|
@@ -5332,7 +5098,7 @@
|
|
|
5332
5098
|
this.connectionType = !mainEndpoint ? "polling" : "socket";
|
|
5333
5099
|
}
|
|
5334
5100
|
ProgressesController.prototype.getProgress = function (id) {
|
|
5335
|
-
return __awaiter$
|
|
5101
|
+
return __awaiter$6(this, void 0, void 0, function () {
|
|
5336
5102
|
var progress, json;
|
|
5337
5103
|
return __generator(this, function (_a) {
|
|
5338
5104
|
switch (_a.label) {
|
|
@@ -5377,7 +5143,7 @@
|
|
|
5377
5143
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
5378
5144
|
return Reflect.metadata(k, v);
|
|
5379
5145
|
};
|
|
5380
|
-
var __awaiter$
|
|
5146
|
+
var __awaiter$5 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5381
5147
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5382
5148
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5383
5149
|
function fulfilled(value) { try {
|
|
@@ -5409,7 +5175,7 @@
|
|
|
5409
5175
|
configurable: true
|
|
5410
5176
|
});
|
|
5411
5177
|
ErrorHandlerMiddleware.prototype.error = function (error, req, res, next) {
|
|
5412
|
-
return __awaiter$
|
|
5178
|
+
return __awaiter$5(this, void 0, void 0, function () {
|
|
5413
5179
|
var result;
|
|
5414
5180
|
return __generator(this, function (_a) {
|
|
5415
5181
|
switch (_a.label) {
|
|
@@ -5426,7 +5192,7 @@
|
|
|
5426
5192
|
});
|
|
5427
5193
|
};
|
|
5428
5194
|
ErrorHandlerMiddleware.prototype.getResult = function (error, req, res) {
|
|
5429
|
-
return __awaiter$
|
|
5195
|
+
return __awaiter$5(this, void 0, void 0, function () {
|
|
5430
5196
|
var result, _a, _b, _c;
|
|
5431
5197
|
return __generator(this, function (_d) {
|
|
5432
5198
|
switch (_d.label) {
|
|
@@ -5621,7 +5387,7 @@
|
|
|
5621
5387
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
5622
5388
|
return function (target, key) { decorator(target, key, paramIndex); };
|
|
5623
5389
|
};
|
|
5624
|
-
var __awaiter$
|
|
5390
|
+
var __awaiter$4 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5625
5391
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5626
5392
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5627
5393
|
function fulfilled(value) { try {
|
|
@@ -5646,7 +5412,7 @@
|
|
|
5646
5412
|
this.socketServer = socketServer;
|
|
5647
5413
|
}
|
|
5648
5414
|
ProgressController.prototype.advanceProgress = function (client, progressId) {
|
|
5649
|
-
return __awaiter$
|
|
5415
|
+
return __awaiter$4(this, void 0, void 0, function () {
|
|
5650
5416
|
var progress, json;
|
|
5651
5417
|
return __generator(this, function (_a) {
|
|
5652
5418
|
switch (_a.label) {
|
|
@@ -5668,7 +5434,7 @@
|
|
|
5668
5434
|
});
|
|
5669
5435
|
};
|
|
5670
5436
|
ProgressController.prototype.setProgressInterest = function (client, progressId) {
|
|
5671
|
-
return __awaiter$
|
|
5437
|
+
return __awaiter$4(this, void 0, void 0, function () {
|
|
5672
5438
|
var progress, json;
|
|
5673
5439
|
return __generator(this, function (_a) {
|
|
5674
5440
|
switch (_a.label) {
|
|
@@ -5735,39 +5501,108 @@
|
|
|
5735
5501
|
socketControllers.Middleware()
|
|
5736
5502
|
], CompressionMiddleware);
|
|
5737
5503
|
|
|
5738
|
-
var
|
|
5739
|
-
function
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
this.map = new Map();
|
|
5744
|
-
}
|
|
5745
|
-
Object.defineProperty(Tree.prototype, "parentTree", {
|
|
5746
|
-
get: function () {
|
|
5747
|
-
return this.container.parent.tree;
|
|
5748
|
-
},
|
|
5749
|
-
enumerable: false,
|
|
5750
|
-
configurable: true
|
|
5751
|
-
});
|
|
5752
|
-
Tree.prototype.resolveService = function () {
|
|
5753
|
-
return !this.exists ? null : this.container.resolve(this.path);
|
|
5754
|
-
};
|
|
5755
|
-
Tree.prototype.resolveLeaves = function () {
|
|
5756
|
-
var map;
|
|
5757
|
-
try {
|
|
5758
|
-
var parentTree = this.parentTree.resolvePath(this.path);
|
|
5759
|
-
map = parentTree.resolveLeaves();
|
|
5504
|
+
var __awaiter$3 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5505
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5506
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5507
|
+
function fulfilled(value) { try {
|
|
5508
|
+
step(generator.next(value));
|
|
5760
5509
|
}
|
|
5761
5510
|
catch (e) {
|
|
5762
|
-
|
|
5511
|
+
reject(e);
|
|
5512
|
+
} }
|
|
5513
|
+
function rejected(value) { try {
|
|
5514
|
+
step(generator["throw"](value));
|
|
5763
5515
|
}
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5516
|
+
catch (e) {
|
|
5517
|
+
reject(e);
|
|
5518
|
+
} }
|
|
5519
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
5520
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5521
|
+
});
|
|
5522
|
+
};
|
|
5523
|
+
function setupStatic(rootFolder, container) {
|
|
5524
|
+
return __awaiter$3(this, void 0, void 0, function () {
|
|
5525
|
+
var browserFolder, app, ep;
|
|
5526
|
+
return __generator(this, function (_a) {
|
|
5527
|
+
switch (_a.label) {
|
|
5528
|
+
case 0:
|
|
5529
|
+
browserFolder = path.resolve(rootFolder || __dirname, "public_html");
|
|
5530
|
+
app = container.get(EXPRESS);
|
|
5531
|
+
ep = container.get(exports.EndpointProvider);
|
|
5532
|
+
console.log(browserFolder, fs.existsSync(browserFolder));
|
|
5533
|
+
if (fs.existsSync(browserFolder)) {
|
|
5534
|
+
console.log("public_html exists. setting up static files serving...");
|
|
5535
|
+
app.use(express_["static"](browserFolder, {
|
|
5536
|
+
maxAge: "1y"
|
|
5537
|
+
}));
|
|
5538
|
+
}
|
|
5539
|
+
else {
|
|
5540
|
+
console.log("public_html does not exist on path: \"" + browserFolder + "\"");
|
|
5541
|
+
}
|
|
5542
|
+
return [4 /*yield*/, ep.configure(app)];
|
|
5543
|
+
case 1:
|
|
5544
|
+
_a.sent();
|
|
5545
|
+
return [2 /*return*/];
|
|
5546
|
+
}
|
|
5547
|
+
});
|
|
5548
|
+
});
|
|
5549
|
+
}
|
|
5550
|
+
|
|
5551
|
+
var BaseDoc = /** @class */ (function () {
|
|
5552
|
+
function BaseDoc() {
|
|
5553
|
+
}
|
|
5554
|
+
/**
|
|
5555
|
+
* Casts this to DocumentType<this> to allow using document methods in get/set-s
|
|
5556
|
+
*/
|
|
5557
|
+
BaseDoc.prototype.cast = function () {
|
|
5558
|
+
return this;
|
|
5559
|
+
};
|
|
5560
|
+
/**
|
|
5561
|
+
* Gets a pre-compiled model from typegoose cache by its class type
|
|
5562
|
+
* @param type
|
|
5563
|
+
*/
|
|
5564
|
+
BaseDoc.prototype.model = function (type) {
|
|
5565
|
+
return typegoose.getModelForClass(type);
|
|
5566
|
+
};
|
|
5567
|
+
return BaseDoc;
|
|
5568
|
+
}());
|
|
5569
|
+
// @ts-ignore
|
|
5570
|
+
var PrimitiveArray = mongoose.Types.Array;
|
|
5571
|
+
var DocumentArray = mongoose.Types.DocumentArray;
|
|
5572
|
+
|
|
5573
|
+
var Tree = /** @class */ (function () {
|
|
5574
|
+
function Tree(container, exists, path) {
|
|
5575
|
+
this.container = container;
|
|
5576
|
+
this.exists = exists;
|
|
5577
|
+
this.path = path;
|
|
5578
|
+
this.map = new Map();
|
|
5579
|
+
}
|
|
5580
|
+
Object.defineProperty(Tree.prototype, "parentTree", {
|
|
5581
|
+
get: function () {
|
|
5582
|
+
return this.container.parent.tree;
|
|
5583
|
+
},
|
|
5584
|
+
enumerable: false,
|
|
5585
|
+
configurable: true
|
|
5586
|
+
});
|
|
5587
|
+
Tree.prototype.resolveService = function () {
|
|
5588
|
+
return !this.exists ? null : this.container.resolve(this.path);
|
|
5589
|
+
};
|
|
5590
|
+
Tree.prototype.resolveLeaves = function () {
|
|
5591
|
+
var map;
|
|
5592
|
+
try {
|
|
5593
|
+
var parentTree = this.parentTree.resolvePath(this.path);
|
|
5594
|
+
map = parentTree.resolveLeaves();
|
|
5595
|
+
}
|
|
5596
|
+
catch (e) {
|
|
5597
|
+
map = new Map();
|
|
5598
|
+
}
|
|
5599
|
+
var visitor = function (treeMap, path) {
|
|
5600
|
+
treeMap.forEach(function (tree, key) {
|
|
5601
|
+
var subKey = !path ? key : path + "." + key;
|
|
5602
|
+
if (tree.map.size == 0) {
|
|
5603
|
+
map.set(subKey, tree);
|
|
5604
|
+
return;
|
|
5605
|
+
}
|
|
5771
5606
|
visitor(tree.map, subKey);
|
|
5772
5607
|
});
|
|
5773
5608
|
};
|
|
@@ -5976,53 +5811,6 @@
|
|
|
5976
5811
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5977
5812
|
});
|
|
5978
5813
|
};
|
|
5979
|
-
function setupStatic(rootFolder, container) {
|
|
5980
|
-
return __awaiter$2(this, void 0, void 0, function () {
|
|
5981
|
-
var browserFolder, app, ep;
|
|
5982
|
-
return __generator(this, function (_a) {
|
|
5983
|
-
switch (_a.label) {
|
|
5984
|
-
case 0:
|
|
5985
|
-
browserFolder = path.resolve(rootFolder || __dirname, "public_html");
|
|
5986
|
-
app = container.get(EXPRESS);
|
|
5987
|
-
ep = container.get(exports.EndpointProvider);
|
|
5988
|
-
console.log(browserFolder, fs.existsSync(browserFolder));
|
|
5989
|
-
if (fs.existsSync(browserFolder)) {
|
|
5990
|
-
console.log("public_html exists. setting up static files serving...");
|
|
5991
|
-
app.use(express_["static"](browserFolder, {
|
|
5992
|
-
maxAge: "1y"
|
|
5993
|
-
}));
|
|
5994
|
-
}
|
|
5995
|
-
else {
|
|
5996
|
-
console.log("public_html does not exist on path: \"" + browserFolder + "\"");
|
|
5997
|
-
}
|
|
5998
|
-
return [4 /*yield*/, ep.configure(app)];
|
|
5999
|
-
case 1:
|
|
6000
|
-
_a.sent();
|
|
6001
|
-
return [2 /*return*/];
|
|
6002
|
-
}
|
|
6003
|
-
});
|
|
6004
|
-
});
|
|
6005
|
-
}
|
|
6006
|
-
|
|
6007
|
-
var __awaiter$1 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6008
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6009
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6010
|
-
function fulfilled(value) { try {
|
|
6011
|
-
step(generator.next(value));
|
|
6012
|
-
}
|
|
6013
|
-
catch (e) {
|
|
6014
|
-
reject(e);
|
|
6015
|
-
} }
|
|
6016
|
-
function rejected(value) { try {
|
|
6017
|
-
step(generator["throw"](value));
|
|
6018
|
-
}
|
|
6019
|
-
catch (e) {
|
|
6020
|
-
reject(e);
|
|
6021
|
-
} }
|
|
6022
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
6023
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
6024
|
-
});
|
|
6025
|
-
};
|
|
6026
5814
|
var LazyAssetGenerator = /** @class */ (function () {
|
|
6027
5815
|
function LazyAssetGenerator(assetResolver, progresses, lazyId) {
|
|
6028
5816
|
this.assetResolver = assetResolver;
|
|
@@ -6044,7 +5832,7 @@
|
|
|
6044
5832
|
configurable: true
|
|
6045
5833
|
});
|
|
6046
5834
|
LazyAssetGenerator.prototype.process = function (messaging) {
|
|
6047
|
-
return __awaiter$
|
|
5835
|
+
return __awaiter$2(this, void 0, void 0, function () {
|
|
6048
5836
|
var lazyAsset, progress, asset, e_1;
|
|
6049
5837
|
return __generator(this, function (_a) {
|
|
6050
5838
|
switch (_a.label) {
|
|
@@ -6092,6 +5880,282 @@
|
|
|
6092
5880
|
return LazyAssetGenerator;
|
|
6093
5881
|
}());
|
|
6094
5882
|
|
|
5883
|
+
var __awaiter$1 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5884
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5885
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5886
|
+
function fulfilled(value) { try {
|
|
5887
|
+
step(generator.next(value));
|
|
5888
|
+
}
|
|
5889
|
+
catch (e) {
|
|
5890
|
+
reject(e);
|
|
5891
|
+
} }
|
|
5892
|
+
function rejected(value) { try {
|
|
5893
|
+
step(generator["throw"](value));
|
|
5894
|
+
}
|
|
5895
|
+
catch (e) {
|
|
5896
|
+
reject(e);
|
|
5897
|
+
} }
|
|
5898
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
5899
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5900
|
+
});
|
|
5901
|
+
};
|
|
5902
|
+
var pluginsKey = "typegoose:plugins";
|
|
5903
|
+
/**
|
|
5904
|
+
* A mongoose/typegoose plugin to inject services from the main di container to a schema as virtuals
|
|
5905
|
+
* @param schema
|
|
5906
|
+
* @param services
|
|
5907
|
+
*/
|
|
5908
|
+
function injectServices(schema, services) {
|
|
5909
|
+
var serviceMap = {};
|
|
5910
|
+
if (!isObject(services)) {
|
|
5911
|
+
throw new Error("services object should be defined to inject services to schema!");
|
|
5912
|
+
}
|
|
5913
|
+
Object.keys(services).forEach(function (prop) {
|
|
5914
|
+
schema
|
|
5915
|
+
.virtual(prop)
|
|
5916
|
+
.get(function () {
|
|
5917
|
+
var diContainer = diContainers.appContainer;
|
|
5918
|
+
serviceMap[prop] = serviceMap[prop] || (!diContainer ? {} : diContainer.resolve(services[prop]));
|
|
5919
|
+
return serviceMap[prop];
|
|
5920
|
+
});
|
|
5921
|
+
});
|
|
5922
|
+
}
|
|
5923
|
+
/**
|
|
5924
|
+
* Decorates a property to inject a service with the help of the injectServices mongoose/typegoose plugin
|
|
5925
|
+
* @param token optional InjectionToken to use
|
|
5926
|
+
* @return PropertyDecorator
|
|
5927
|
+
*/
|
|
5928
|
+
function service(token) {
|
|
5929
|
+
return function (target, propertyKey) {
|
|
5930
|
+
var _b;
|
|
5931
|
+
var _a;
|
|
5932
|
+
var propertyType = Reflect.getOwnMetadata("design:type", target, propertyKey);
|
|
5933
|
+
var plugins = Array.from((_a = Reflect.getMetadata(pluginsKey, target.constructor)) !== null && _a !== void 0 ? _a : []);
|
|
5934
|
+
var plugin = plugins.find(function (t) { return t.mongoosePlugin === injectServices; });
|
|
5935
|
+
if (!plugin) {
|
|
5936
|
+
plugin = { mongoosePlugin: injectServices, options: {} };
|
|
5937
|
+
plugins.push(plugin);
|
|
5938
|
+
}
|
|
5939
|
+
plugin.options = Object.assign(plugin.options || {}, (_b = {}, _b[propertyKey] = token !== null && token !== void 0 ? token : propertyType, _b));
|
|
5940
|
+
Reflect.defineMetadata(pluginsKey, plugins, target.constructor);
|
|
5941
|
+
};
|
|
5942
|
+
}
|
|
5943
|
+
/**
|
|
5944
|
+
* Paginate using a typegoose model using a simple where query and pagination params
|
|
5945
|
+
* @param model Typegoose model
|
|
5946
|
+
* @param where Simple query to filter the results
|
|
5947
|
+
* @param params Pagination params
|
|
5948
|
+
*/
|
|
5949
|
+
function paginate(model, where, params) {
|
|
5950
|
+
return model.countDocuments(where).then(function (count) {
|
|
5951
|
+
var query = model.find(where);
|
|
5952
|
+
if (isString(params.sort)) {
|
|
5953
|
+
query = query.sort(params.sort);
|
|
5954
|
+
}
|
|
5955
|
+
if (isArray(params.populate)) {
|
|
5956
|
+
params.populate.forEach(function (field) {
|
|
5957
|
+
query = query.populate(field);
|
|
5958
|
+
});
|
|
5959
|
+
}
|
|
5960
|
+
return (params.limit > 0 ? query.skip(params.page * params.limit).limit(params.limit) : query).then(function (items) {
|
|
5961
|
+
var meta = { total: count };
|
|
5962
|
+
return { count: count, items: items, meta: meta };
|
|
5963
|
+
});
|
|
5964
|
+
});
|
|
5965
|
+
}
|
|
5966
|
+
function lookupStages(from, localField, as, foreignField, shouldUnwind) {
|
|
5967
|
+
if (as === void 0) { as = null; }
|
|
5968
|
+
if (foreignField === void 0) { foreignField = "_id"; }
|
|
5969
|
+
if (shouldUnwind === void 0) { shouldUnwind = true; }
|
|
5970
|
+
as = as || localField.replace("Id", "");
|
|
5971
|
+
var stages = [
|
|
5972
|
+
{
|
|
5973
|
+
$lookup: {
|
|
5974
|
+
from: from,
|
|
5975
|
+
localField: localField,
|
|
5976
|
+
foreignField: foreignField,
|
|
5977
|
+
as: as
|
|
5978
|
+
}
|
|
5979
|
+
},
|
|
5980
|
+
{
|
|
5981
|
+
$unwind: {
|
|
5982
|
+
path: "$" + as,
|
|
5983
|
+
preserveNullAndEmptyArrays: true
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
];
|
|
5987
|
+
if (!shouldUnwind) {
|
|
5988
|
+
stages.splice(1, 1);
|
|
5989
|
+
}
|
|
5990
|
+
return stages;
|
|
5991
|
+
}
|
|
5992
|
+
function letsLookupStage(from, pipeline, as, letFields) {
|
|
5993
|
+
if (as === void 0) { as = null; }
|
|
5994
|
+
if (letFields === void 0) { letFields = null; }
|
|
5995
|
+
as = as || from;
|
|
5996
|
+
letFields = letFields || { id: "$_id" };
|
|
5997
|
+
return {
|
|
5998
|
+
$lookup: {
|
|
5999
|
+
from: from,
|
|
6000
|
+
let: letFields,
|
|
6001
|
+
pipeline: pipeline,
|
|
6002
|
+
as: as
|
|
6003
|
+
}
|
|
6004
|
+
};
|
|
6005
|
+
}
|
|
6006
|
+
function matchStage(match) {
|
|
6007
|
+
return { $match: match };
|
|
6008
|
+
}
|
|
6009
|
+
function matchField(field, filter, when) {
|
|
6010
|
+
return { field: field, filter: filter, when: when };
|
|
6011
|
+
}
|
|
6012
|
+
function matchFieldStages() {
|
|
6013
|
+
var fields = [];
|
|
6014
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6015
|
+
fields[_i] = arguments[_i];
|
|
6016
|
+
}
|
|
6017
|
+
var match = {};
|
|
6018
|
+
fields.forEach(function (field) {
|
|
6019
|
+
if (field.when) {
|
|
6020
|
+
match[field.field] = field.filter;
|
|
6021
|
+
}
|
|
6022
|
+
});
|
|
6023
|
+
return Object.keys(match).length > 0 ? [matchStage(match)] : [];
|
|
6024
|
+
}
|
|
6025
|
+
function projectStage(fields) {
|
|
6026
|
+
return { $project: fields };
|
|
6027
|
+
}
|
|
6028
|
+
function unwindStage(fieldOrOpts) {
|
|
6029
|
+
return { $unwind: fieldOrOpts };
|
|
6030
|
+
}
|
|
6031
|
+
function hydratePopulated(modelType, json) {
|
|
6032
|
+
var e_1, _b;
|
|
6033
|
+
var object = modelType.hydrate(json);
|
|
6034
|
+
var _loop_1 = function (path, obj) {
|
|
6035
|
+
var ref = obj.ref, type = obj.type;
|
|
6036
|
+
if (Array.isArray(type) && type.length > 0) {
|
|
6037
|
+
ref = type[0].ref;
|
|
6038
|
+
}
|
|
6039
|
+
if (!ref)
|
|
6040
|
+
return "continue";
|
|
6041
|
+
var value = utils.getValue(path, json);
|
|
6042
|
+
var hydrateVal = function (val) {
|
|
6043
|
+
if (val == null || val instanceof mongoose.Types.ObjectId)
|
|
6044
|
+
return val;
|
|
6045
|
+
return hydratePopulated(mongoose.model(ref), val);
|
|
6046
|
+
};
|
|
6047
|
+
if (Array.isArray(value)) {
|
|
6048
|
+
utils.setValue(path, value.map(hydrateVal), object);
|
|
6049
|
+
return "continue";
|
|
6050
|
+
}
|
|
6051
|
+
utils.setValue(path, hydrateVal(value), object);
|
|
6052
|
+
};
|
|
6053
|
+
try {
|
|
6054
|
+
for (var _c = __values(Object.entries(modelType.schema.obj)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
6055
|
+
var _e = __read(_d.value, 2), path = _e[0], obj = _e[1];
|
|
6056
|
+
_loop_1(path, obj);
|
|
6057
|
+
}
|
|
6058
|
+
}
|
|
6059
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6060
|
+
finally {
|
|
6061
|
+
try {
|
|
6062
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
6063
|
+
}
|
|
6064
|
+
finally { if (e_1) throw e_1.error; }
|
|
6065
|
+
}
|
|
6066
|
+
return object;
|
|
6067
|
+
}
|
|
6068
|
+
function paginateAggregations(model, aggregations, params, metaProjection) {
|
|
6069
|
+
if (metaProjection === void 0) { metaProjection = {}; }
|
|
6070
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
6071
|
+
var sortField, sortAggregation, result, pagination;
|
|
6072
|
+
var _b;
|
|
6073
|
+
return __generator(this, function (_c) {
|
|
6074
|
+
switch (_c.label) {
|
|
6075
|
+
case 0:
|
|
6076
|
+
sortField = !isString(params.sort) || !params.sort ? null : (params.sort.startsWith("-") ? params.sort.substr(1) : params.sort);
|
|
6077
|
+
sortAggregation = !sortField ? [] : [{
|
|
6078
|
+
$sort: (_b = {}, _b[sortField] = sortField == params.sort ? 1 : -1, _b)
|
|
6079
|
+
}];
|
|
6080
|
+
return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray(__spreadArray([], __read(aggregations)), __read(sortAggregation)), [
|
|
6081
|
+
{
|
|
6082
|
+
$group: {
|
|
6083
|
+
_id: "results",
|
|
6084
|
+
result: { $push: "$$CURRENT" }
|
|
6085
|
+
}
|
|
6086
|
+
},
|
|
6087
|
+
{
|
|
6088
|
+
$project: {
|
|
6089
|
+
_id: 0,
|
|
6090
|
+
items: params.limit > 0 ? { $slice: ["$result", params.page * params.limit, params.limit] } : "$result",
|
|
6091
|
+
count: { $size: "$result" },
|
|
6092
|
+
meta: Object.assign({ total: { $size: "$result" } }, metaProjection)
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6095
|
+
]))];
|
|
6096
|
+
case 1:
|
|
6097
|
+
result = _c.sent();
|
|
6098
|
+
pagination = result[0];
|
|
6099
|
+
if (!pagination) {
|
|
6100
|
+
return [2 /*return*/, { items: [], count: 0, meta: { total: 0 } }];
|
|
6101
|
+
}
|
|
6102
|
+
pagination.items = pagination.items.map(function (i) { return hydratePopulated(model, i); });
|
|
6103
|
+
return [2 /*return*/, pagination];
|
|
6104
|
+
}
|
|
6105
|
+
});
|
|
6106
|
+
});
|
|
6107
|
+
}
|
|
6108
|
+
function ResolveEntity(model, extraCheck) {
|
|
6109
|
+
var _this = this;
|
|
6110
|
+
var modelName = model.modelName;
|
|
6111
|
+
var paramName = modelName.toLowerCase();
|
|
6112
|
+
return routingControllers.createParamDecorator({
|
|
6113
|
+
required: false,
|
|
6114
|
+
value: function (action) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
6115
|
+
var req, token, id, query, doc, e_2;
|
|
6116
|
+
return __generator(this, function (_b) {
|
|
6117
|
+
switch (_b.label) {
|
|
6118
|
+
case 0:
|
|
6119
|
+
req = action.request;
|
|
6120
|
+
token = req.header("x-" + paramName + "-token");
|
|
6121
|
+
id = req.params[paramName + "Id"];
|
|
6122
|
+
if (!id && !token) {
|
|
6123
|
+
throw new routingControllers.BadRequestError(modelName + " id or token should be defined!");
|
|
6124
|
+
}
|
|
6125
|
+
query = !token
|
|
6126
|
+
? model.findById(id)
|
|
6127
|
+
: model.findOne({ token: token });
|
|
6128
|
+
doc = null;
|
|
6129
|
+
if (!isFunction(extraCheck)) return [3 /*break*/, 5];
|
|
6130
|
+
_b.label = 1;
|
|
6131
|
+
case 1:
|
|
6132
|
+
_b.trys.push([1, 3, , 4]);
|
|
6133
|
+
return [4 /*yield*/, valueToPromise(extraCheck(query, action))];
|
|
6134
|
+
case 2:
|
|
6135
|
+
doc = _b.sent();
|
|
6136
|
+
return [3 /*break*/, 4];
|
|
6137
|
+
case 3:
|
|
6138
|
+
e_2 = _b.sent();
|
|
6139
|
+
throw new routingControllers.BadRequestError(modelName + " check error: " + (e_2.message || e_2));
|
|
6140
|
+
case 4: return [3 /*break*/, 7];
|
|
6141
|
+
case 5: return [4 /*yield*/, query];
|
|
6142
|
+
case 6:
|
|
6143
|
+
doc = _b.sent();
|
|
6144
|
+
_b.label = 7;
|
|
6145
|
+
case 7:
|
|
6146
|
+
if (!doc) {
|
|
6147
|
+
throw new routingControllers.HttpError(404, !token
|
|
6148
|
+
? modelName + " could not be found with id: " + id
|
|
6149
|
+
: modelName + " could not be found with token: " + token);
|
|
6150
|
+
}
|
|
6151
|
+
action.request[paramName] = doc;
|
|
6152
|
+
return [2 /*return*/, doc];
|
|
6153
|
+
}
|
|
6154
|
+
});
|
|
6155
|
+
}); }
|
|
6156
|
+
});
|
|
6157
|
+
}
|
|
6158
|
+
|
|
6095
6159
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6096
6160
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6097
6161
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -6411,7 +6475,9 @@
|
|
|
6411
6475
|
*/
|
|
6412
6476
|
|
|
6413
6477
|
exports.AssetImageParams = AssetImageParams;
|
|
6478
|
+
exports.BaseDoc = BaseDoc;
|
|
6414
6479
|
exports.DI_CONTAINER = DI_CONTAINER;
|
|
6480
|
+
exports.DocumentArray = DocumentArray;
|
|
6415
6481
|
exports.EXPRESS = EXPRESS;
|
|
6416
6482
|
exports.FIXTURE = FIXTURE;
|
|
6417
6483
|
exports.HTTP_SERVER = HTTP_SERVER;
|
|
@@ -6419,6 +6485,7 @@
|
|
|
6419
6485
|
exports.LazyAssetGenerator = LazyAssetGenerator;
|
|
6420
6486
|
exports.PARAMETER = PARAMETER;
|
|
6421
6487
|
exports.Parameter = Parameter;
|
|
6488
|
+
exports.PrimitiveArray = PrimitiveArray;
|
|
6422
6489
|
exports.ResolveEntity = ResolveEntity;
|
|
6423
6490
|
exports.SOCKET_SERVER = SOCKET_SERVER;
|
|
6424
6491
|
exports.Type = Type;
|
|
@@ -6476,8 +6543,6 @@
|
|
|
6476
6543
|
exports.paginateAggregations = paginateAggregations;
|
|
6477
6544
|
exports.projectStage = projectStage;
|
|
6478
6545
|
exports.promiseTimeout = promiseTimeout;
|
|
6479
|
-
exports.proxyFunction = proxyFunction;
|
|
6480
|
-
exports.proxyFunctions = proxyFunctions;
|
|
6481
6546
|
exports.rand = rand;
|
|
6482
6547
|
exports.random = random;
|
|
6483
6548
|
exports.readAndDeleteFile = readAndDeleteFile;
|
|
@@ -6485,6 +6550,7 @@
|
|
|
6485
6550
|
exports.regroup = regroup;
|
|
6486
6551
|
exports.replaceSpecialChars = replaceSpecialChars;
|
|
6487
6552
|
exports.runCommand = runCommand;
|
|
6553
|
+
exports.service = service;
|
|
6488
6554
|
exports.setupBackend = setupBackend;
|
|
6489
6555
|
exports.streamToBuffer = streamToBuffer;
|
|
6490
6556
|
exports.toImage = toImage;
|