@stemy/backend 3.4.0 → 3.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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('mongoose/lib/utils'), 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')) :
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', 'mongoose/lib/utils', 'stream', 'sharp', 'bson', 'fontkit', 'file-type', 'axios', 'dotenv', 'node-cron', 'zeromq', 'rxjs/operators', 'http', 'express', 'socket.io', 'uuid', 'nodemailer', 'handlebars', 'bcrypt', 'moment'], 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["mongoose-lib-utils"], 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));
5
- })(this, (function (exports, path, bodyParser, jsonwebtoken, tsyringe, routingControllers, socketControllers, routingControllersOpenapi, storage, classValidator, classValidatorJsonschema, child_process, crypto, rxjs, canReportError, fs, mongodb, mongoose, utils, stream, sharp_, bson, fontKit_, fileType, axios, dotenv, nodeCron, zeromq, operators, http, express_, socket_io, uuid, nodemailer, Handlebars, bcrypt, moment) { 'use strict';
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$x(thisArg, _arguments, P, generator) {
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$w = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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$w(this, void 0, void 0, function () {
735
- var crop, buffer, _a, cropBefore, cropAfter, img, _b, width, height, canvasScaleX, canvasScaleY, e_3;
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
- e_3 = _c.sent();
814
- console.log("Image conversion error", e_3);
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$w(this, void 0, void 0, function () {
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$w(this, void 0, void 0, function () {
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,56 +801,6 @@
972
801
  });
973
802
  return params;
974
803
  }
975
- function ResolveEntity(model, extraCheck) {
976
- var _this = this;
977
- var modelName = model.modelName;
978
- var paramName = modelName.toLowerCase();
979
- return routingControllers.createParamDecorator({
980
- required: false,
981
- value: function (action) { return __awaiter$w(_this, void 0, void 0, function () {
982
- var req, token, id, query, doc, e_4;
983
- return __generator(this, function (_a) {
984
- switch (_a.label) {
985
- case 0:
986
- req = action.request;
987
- token = req.header("x-" + paramName + "-token");
988
- id = req.params[paramName + "Id"];
989
- if (!id && !token) {
990
- throw new routingControllers.BadRequestError(modelName + " id or token should be defined!");
991
- }
992
- query = !token
993
- ? model.findById(id)
994
- : model.findOne({ token: token });
995
- doc = null;
996
- if (!isFunction(extraCheck)) return [3 /*break*/, 5];
997
- _a.label = 1;
998
- case 1:
999
- _a.trys.push([1, 3, , 4]);
1000
- return [4 /*yield*/, valueToPromise(extraCheck(query, action))];
1001
- case 2:
1002
- doc = _a.sent();
1003
- return [3 /*break*/, 4];
1004
- case 3:
1005
- e_4 = _a.sent();
1006
- throw new routingControllers.BadRequestError(modelName + " check error: " + (e_4.message || e_4));
1007
- case 4: return [3 /*break*/, 7];
1008
- case 5: return [4 /*yield*/, query];
1009
- case 6:
1010
- doc = _a.sent();
1011
- _a.label = 7;
1012
- case 7:
1013
- if (!doc) {
1014
- throw new routingControllers.HttpError(404, !token
1015
- ? modelName + " could not be found with id: " + id
1016
- : modelName + " could not be found with token: " + token);
1017
- }
1018
- action.request[paramName] = doc;
1019
- return [2 /*return*/, doc];
1020
- }
1021
- });
1022
- }); }
1023
- });
1024
- }
1025
804
  function getFileName(path$1, withExtension) {
1026
805
  if (withExtension === void 0) { withExtension = false; }
1027
806
  var name = path.basename(path$1 || "");
@@ -1118,7 +897,7 @@
1118
897
  var defaultPredicate = function () { return true; };
1119
898
  var ɵ0 = defaultPredicate;
1120
899
  function copyRecursive(target, source, predicate) {
1121
- var e_5, _a;
900
+ var e_3, _a;
1122
901
  predicate = predicate || defaultPredicate;
1123
902
  if (isPrimitive(source) || isDate(source) || isFunction(source))
1124
903
  return source;
@@ -1162,12 +941,12 @@
1162
941
  target.set(key, !shouldCopy(key, value) ? value : copyRecursive(target.get(key), value, predicate));
1163
942
  }
1164
943
  }
1165
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
944
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1166
945
  finally {
1167
946
  try {
1168
947
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1169
948
  }
1170
- finally { if (e_5) throw e_5.error; }
949
+ finally { if (e_3) throw e_3.error; }
1171
950
  }
1172
951
  }
1173
952
  return target;
@@ -1425,7 +1204,7 @@
1425
1204
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1426
1205
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1427
1206
  };
1428
- var __awaiter$v = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1207
+ var __awaiter$w = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1429
1208
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1430
1209
  return new (P || (P = Promise))(function (resolve, reject) {
1431
1210
  function fulfilled(value) { try {
@@ -1473,7 +1252,7 @@
1473
1252
  };
1474
1253
  AssetProcessor.fileTypeFromBuffer = function (buffer) {
1475
1254
  var _a;
1476
- return __awaiter$v(this, void 0, void 0, function () {
1255
+ return __awaiter$w(this, void 0, void 0, function () {
1477
1256
  var type;
1478
1257
  return __generator(this, function (_b) {
1479
1258
  switch (_b.label) {
@@ -1507,7 +1286,7 @@
1507
1286
  return imageTypes.indexOf(contentType) >= 0;
1508
1287
  };
1509
1288
  AssetProcessor.copyImageMeta = function (buffer, metadata, fileType) {
1510
- return __awaiter$v(this, void 0, void 0, function () {
1289
+ return __awaiter$w(this, void 0, void 0, function () {
1511
1290
  var match, attrs, parts, output;
1512
1291
  return __generator(this, function (_b) {
1513
1292
  switch (_b.label) {
@@ -1554,7 +1333,7 @@
1554
1333
  });
1555
1334
  };
1556
1335
  AssetProcessor.prototype.process = function (buffer, metadata, fileType) {
1557
- return __awaiter$v(this, void 0, void 0, function () {
1336
+ return __awaiter$w(this, void 0, void 0, function () {
1558
1337
  return __generator(this, function (_b) {
1559
1338
  switch (_b.label) {
1560
1339
  case 0:
@@ -1652,7 +1431,7 @@
1652
1431
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1653
1432
  return Reflect.metadata(k, v);
1654
1433
  };
1655
- var __awaiter$u = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1434
+ var __awaiter$v = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1656
1435
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1657
1436
  return new (P || (P = Promise))(function (resolve, reject) {
1658
1437
  function fulfilled(value) { try {
@@ -1700,7 +1479,7 @@
1700
1479
  configurable: true
1701
1480
  });
1702
1481
  MongoConnector.prototype.connect = function () {
1703
- return __awaiter$u(this, void 0, void 0, function () {
1482
+ return __awaiter$v(this, void 0, void 0, function () {
1704
1483
  var _a;
1705
1484
  return __generator(this, function (_b) {
1706
1485
  switch (_b.label) {
@@ -1731,7 +1510,7 @@
1731
1510
  __metadata$p("design:paramtypes", [exports.Configuration])
1732
1511
  ], exports.MongoConnector);
1733
1512
 
1734
- var __awaiter$t = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1513
+ var __awaiter$u = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1735
1514
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1736
1515
  return new (P || (P = Promise))(function (resolve, reject) {
1737
1516
  function fulfilled(value) { try {
@@ -1767,7 +1546,7 @@
1767
1546
  return this.collection.updateOne({ _id: this.mId }, { $set: this.toJSON() });
1768
1547
  };
1769
1548
  BaseEntity.prototype.load = function () {
1770
- return __awaiter$t(this, void 0, void 0, function () {
1549
+ return __awaiter$u(this, void 0, void 0, function () {
1771
1550
  var res;
1772
1551
  return __generator(this, function (_a) {
1773
1552
  switch (_a.label) {
@@ -1790,7 +1569,7 @@
1790
1569
  return BaseEntity;
1791
1570
  }());
1792
1571
 
1793
- var __awaiter$s = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1572
+ var __awaiter$t = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1794
1573
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1795
1574
  return new (P || (P = Promise))(function (resolve, reject) {
1796
1575
  function fulfilled(value) { try {
@@ -1845,7 +1624,7 @@
1845
1624
  configurable: true
1846
1625
  });
1847
1626
  Asset.prototype.unlink = function () {
1848
- return __awaiter$s(this, void 0, void 0, function () {
1627
+ return __awaiter$t(this, void 0, void 0, function () {
1849
1628
  return __generator(this, function (_a) {
1850
1629
  return [2 /*return*/, deleteFromBucket(this.bucket, this.mId)];
1851
1630
  });
@@ -1855,7 +1634,7 @@
1855
1634
  return streamToBuffer(this.stream);
1856
1635
  };
1857
1636
  Asset.prototype.download = function (metadata) {
1858
- return __awaiter$s(this, void 0, void 0, function () {
1637
+ return __awaiter$t(this, void 0, void 0, function () {
1859
1638
  return __generator(this, function (_a) {
1860
1639
  switch (_a.label) {
1861
1640
  case 0:
@@ -1875,14 +1654,14 @@
1875
1654
  };
1876
1655
  Asset.prototype.getImage = function (params) {
1877
1656
  if (params === void 0) { params = null; }
1878
- return __awaiter$s(this, void 0, void 0, function () {
1657
+ return __awaiter$t(this, void 0, void 0, function () {
1879
1658
  return __generator(this, function (_a) {
1880
1659
  return [2 /*return*/, toImage(this.stream, params, this.metadata)];
1881
1660
  });
1882
1661
  });
1883
1662
  };
1884
1663
  Asset.prototype.downloadImage = function (params, metadata) {
1885
- return __awaiter$s(this, void 0, void 0, function () {
1664
+ return __awaiter$t(this, void 0, void 0, function () {
1886
1665
  var _a;
1887
1666
  return __generator(this, function (_b) {
1888
1667
  switch (_b.label) {
@@ -1897,7 +1676,7 @@
1897
1676
  return Asset;
1898
1677
  }(BaseEntity));
1899
1678
 
1900
- var __awaiter$r = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1679
+ var __awaiter$s = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1901
1680
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1902
1681
  return new (P || (P = Promise))(function (resolve, reject) {
1903
1682
  function fulfilled(value) { try {
@@ -1932,21 +1711,21 @@
1932
1711
  configurable: true
1933
1712
  });
1934
1713
  TempAsset.prototype.unlink = function () {
1935
- return __awaiter$r(this, void 0, void 0, function () {
1714
+ return __awaiter$s(this, void 0, void 0, function () {
1936
1715
  return __generator(this, function (_a) {
1937
1716
  throw new Error("Temp asset '" + this.id + "' can not be removed!");
1938
1717
  });
1939
1718
  });
1940
1719
  };
1941
1720
  TempAsset.prototype.getBuffer = function () {
1942
- return __awaiter$r(this, void 0, void 0, function () {
1721
+ return __awaiter$s(this, void 0, void 0, function () {
1943
1722
  return __generator(this, function (_a) {
1944
1723
  return [2 /*return*/, this.buffer];
1945
1724
  });
1946
1725
  });
1947
1726
  };
1948
1727
  TempAsset.prototype.download = function (metadata) {
1949
- return __awaiter$r(this, void 0, void 0, function () {
1728
+ return __awaiter$s(this, void 0, void 0, function () {
1950
1729
  return __generator(this, function (_a) {
1951
1730
  return [2 /*return*/, this.stream];
1952
1731
  });
@@ -1960,14 +1739,14 @@
1960
1739
  return this.downloadImage(params);
1961
1740
  };
1962
1741
  TempAsset.prototype.save = function () {
1963
- return __awaiter$r(this, void 0, void 0, function () {
1742
+ return __awaiter$s(this, void 0, void 0, function () {
1964
1743
  return __generator(this, function (_a) {
1965
1744
  return [2 /*return*/, this];
1966
1745
  });
1967
1746
  });
1968
1747
  };
1969
1748
  TempAsset.prototype.load = function () {
1970
- return __awaiter$r(this, void 0, void 0, function () {
1749
+ return __awaiter$s(this, void 0, void 0, function () {
1971
1750
  return __generator(this, function (_a) {
1972
1751
  return [2 /*return*/, this];
1973
1752
  });
@@ -1998,7 +1777,7 @@
1998
1777
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1999
1778
  return Reflect.metadata(k, v);
2000
1779
  };
2001
- var __awaiter$q = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1780
+ var __awaiter$r = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2002
1781
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2003
1782
  return new (P || (P = Promise))(function (resolve, reject) {
2004
1783
  function fulfilled(value) { try {
@@ -2028,7 +1807,7 @@
2028
1807
  Assets.prototype.write = function (stream, contentType, metadata) {
2029
1808
  if (contentType === void 0) { contentType = null; }
2030
1809
  if (metadata === void 0) { metadata = null; }
2031
- return __awaiter$q(this, void 0, void 0, function () {
1810
+ return __awaiter$r(this, void 0, void 0, function () {
2032
1811
  var uploadStream, buffer, fileType, e_1;
2033
1812
  return __generator(this, function (_b) {
2034
1813
  switch (_b.label) {
@@ -2062,7 +1841,7 @@
2062
1841
  Assets.prototype.writeBuffer = function (buffer, metadata, contentType) {
2063
1842
  if (metadata === void 0) { metadata = null; }
2064
1843
  if (contentType === void 0) { contentType = null; }
2065
- return __awaiter$q(this, void 0, void 0, function () {
1844
+ return __awaiter$r(this, void 0, void 0, function () {
2066
1845
  var fileType, e_2;
2067
1846
  return __generator(this, function (_b) {
2068
1847
  switch (_b.label) {
@@ -2094,7 +1873,7 @@
2094
1873
  };
2095
1874
  Assets.prototype.writeUrl = function (url, metadata) {
2096
1875
  if (metadata === void 0) { metadata = null; }
2097
- return __awaiter$q(this, void 0, void 0, function () {
1876
+ return __awaiter$r(this, void 0, void 0, function () {
2098
1877
  var buffer;
2099
1878
  return __generator(this, function (_b) {
2100
1879
  switch (_b.label) {
@@ -2108,7 +1887,7 @@
2108
1887
  };
2109
1888
  Assets.prototype.download = function (url, contentType) {
2110
1889
  if (contentType === void 0) { contentType = null; }
2111
- return __awaiter$q(this, void 0, void 0, function () {
1890
+ return __awaiter$r(this, void 0, void 0, function () {
2112
1891
  var buffer, fileType, e_3, metadata;
2113
1892
  return __generator(this, function (_b) {
2114
1893
  switch (_b.label) {
@@ -2144,14 +1923,14 @@
2144
1923
  });
2145
1924
  };
2146
1925
  Assets.prototype.read = function (id) {
2147
- return __awaiter$q(this, void 0, void 0, function () {
1926
+ return __awaiter$r(this, void 0, void 0, function () {
2148
1927
  return __generator(this, function (_b) {
2149
1928
  return [2 /*return*/, !id ? null : this.find({ _id: new bson.ObjectId(id) })];
2150
1929
  });
2151
1930
  });
2152
1931
  };
2153
1932
  Assets.prototype.find = function (where) {
2154
- return __awaiter$q(this, void 0, void 0, function () {
1933
+ return __awaiter$r(this, void 0, void 0, function () {
2155
1934
  var data;
2156
1935
  return __generator(this, function (_b) {
2157
1936
  switch (_b.label) {
@@ -2164,7 +1943,7 @@
2164
1943
  });
2165
1944
  };
2166
1945
  Assets.prototype.findMany = function (where) {
2167
- return __awaiter$q(this, void 0, void 0, function () {
1946
+ return __awaiter$r(this, void 0, void 0, function () {
2168
1947
  var cursor, items, result, items_1, items_1_1, item;
2169
1948
  var e_4, _b;
2170
1949
  return __generator(this, function (_c) {
@@ -2196,7 +1975,7 @@
2196
1975
  });
2197
1976
  };
2198
1977
  Assets.prototype.deleteMany = function (where) {
2199
- return __awaiter$q(this, void 0, void 0, function () {
1978
+ return __awaiter$r(this, void 0, void 0, function () {
2200
1979
  var assets;
2201
1980
  return __generator(this, function (_b) {
2202
1981
  switch (_b.label) {
@@ -2209,7 +1988,7 @@
2209
1988
  });
2210
1989
  };
2211
1990
  Assets.prototype.unlink = function (id) {
2212
- return __awaiter$q(this, void 0, void 0, function () {
1991
+ return __awaiter$r(this, void 0, void 0, function () {
2213
1992
  var asset;
2214
1993
  return __generator(this, function (_b) {
2215
1994
  switch (_b.label) {
@@ -2224,7 +2003,7 @@
2224
2003
  });
2225
2004
  };
2226
2005
  Assets.prototype.upload = function (stream, fileType, metadata) {
2227
- return __awaiter$q(this, void 0, void 0, function () {
2006
+ return __awaiter$r(this, void 0, void 0, function () {
2228
2007
  var contentType;
2229
2008
  var _this = this;
2230
2009
  return __generator(this, function (_b) {
@@ -2266,7 +2045,7 @@
2266
2045
  __metadata$o("design:paramtypes", [exports.MongoConnector, exports.AssetProcessor])
2267
2046
  ], exports.Assets);
2268
2047
 
2269
- var __awaiter$p = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2048
+ var __awaiter$q = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2270
2049
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2271
2050
  return new (P || (P = Promise))(function (resolve, reject) {
2272
2051
  function fulfilled(value) { try {
@@ -2329,7 +2108,7 @@
2329
2108
  configurable: true
2330
2109
  });
2331
2110
  LazyAsset.prototype.unlink = function () {
2332
- return __awaiter$p(this, void 0, void 0, function () {
2111
+ return __awaiter$q(this, void 0, void 0, function () {
2333
2112
  return __generator(this, function (_a) {
2334
2113
  switch (_a.label) {
2335
2114
  case 0: return [4 /*yield*/, this.load()];
@@ -2361,7 +2140,7 @@
2361
2140
  });
2362
2141
  };
2363
2142
  LazyAsset.prototype.loadAsset = function () {
2364
- return __awaiter$p(this, void 0, void 0, function () {
2143
+ return __awaiter$q(this, void 0, void 0, function () {
2365
2144
  return __generator(this, function (_a) {
2366
2145
  switch (_a.label) {
2367
2146
  case 0: return [4 /*yield*/, this.load()];
@@ -2386,7 +2165,7 @@
2386
2165
  });
2387
2166
  };
2388
2167
  LazyAsset.prototype.writeAsset = function (asset) {
2389
- return __awaiter$p(this, void 0, void 0, function () {
2168
+ return __awaiter$q(this, void 0, void 0, function () {
2390
2169
  return __generator(this, function (_a) {
2391
2170
  switch (_a.label) {
2392
2171
  case 0:
@@ -2400,7 +2179,7 @@
2400
2179
  });
2401
2180
  };
2402
2181
  LazyAsset.prototype.startWorkingOnAsset = function (fromLoad) {
2403
- return __awaiter$p(this, void 0, void 0, function () {
2182
+ return __awaiter$q(this, void 0, void 0, function () {
2404
2183
  var _a;
2405
2184
  return __generator(this, function (_b) {
2406
2185
  switch (_b.label) {
@@ -2441,7 +2220,7 @@
2441
2220
  var __param$7 = (this && this.__param) || function (paramIndex, decorator) {
2442
2221
  return function (target, key) { decorator(target, key, paramIndex); };
2443
2222
  };
2444
- var __awaiter$o = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2223
+ var __awaiter$p = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2445
2224
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2446
2225
  return new (P || (P = Promise))(function (resolve, reject) {
2447
2226
  function fulfilled(value) { try {
@@ -2492,7 +2271,7 @@
2492
2271
  };
2493
2272
  JobManager.prototype.process = function (jobType, params) {
2494
2273
  if (params === void 0) { params = {}; }
2495
- return __awaiter$o(this, void 0, void 0, function () {
2274
+ return __awaiter$p(this, void 0, void 0, function () {
2496
2275
  var instance, jobName;
2497
2276
  return __generator(this, function (_a) {
2498
2277
  instance = null;
@@ -2509,7 +2288,7 @@
2509
2288
  };
2510
2289
  JobManager.prototype.enqueueWithName = function (name, params) {
2511
2290
  if (params === void 0) { params = {}; }
2512
- return __awaiter$o(this, void 0, void 0, function () {
2291
+ return __awaiter$p(this, void 0, void 0, function () {
2513
2292
  return __generator(this, function (_a) {
2514
2293
  return [2 /*return*/, this.sendToWorkers(this.tryResolveFromName(name, params), params)];
2515
2294
  });
@@ -2517,7 +2296,7 @@
2517
2296
  };
2518
2297
  JobManager.prototype.enqueue = function (jobType, params) {
2519
2298
  if (params === void 0) { params = {}; }
2520
- return __awaiter$o(this, void 0, void 0, function () {
2299
+ return __awaiter$p(this, void 0, void 0, function () {
2521
2300
  return __generator(this, function (_a) {
2522
2301
  return [2 /*return*/, this.sendToWorkers(this.tryResolveAndInit(jobType, params), params)];
2523
2302
  });
@@ -2548,7 +2327,7 @@
2548
2327
  });
2549
2328
  };
2550
2329
  JobManager.prototype.startProcessing = function () {
2551
- return __awaiter$o(this, void 0, void 0, function () {
2330
+ return __awaiter$p(this, void 0, void 0, function () {
2552
2331
  var host, pushHost, pullHost;
2553
2332
  var _this = this;
2554
2333
  return __generator(this, function (_a) {
@@ -2574,7 +2353,7 @@
2574
2353
  case 2:
2575
2354
  _a.sent();
2576
2355
  console.log("Worker consumer connected to: " + pullHost);
2577
- this.workerPull.on("message", function (name, args, uniqId) { return __awaiter$o(_this, void 0, void 0, function () {
2356
+ this.workerPull.on("message", function (name, args, uniqId) { return __awaiter$p(_this, void 0, void 0, function () {
2578
2357
  var jobName, jobParams, uniqueId, e_1, e_2;
2579
2358
  return __generator(this, function (_a) {
2580
2359
  switch (_a.label) {
@@ -2672,7 +2451,7 @@
2672
2451
  return container.resolve(jobType);
2673
2452
  };
2674
2453
  JobManager.prototype.sendToWorkers = function (jobName, params) {
2675
- return __awaiter$o(this, void 0, void 0, function () {
2454
+ return __awaiter$p(this, void 0, void 0, function () {
2676
2455
  var publisher, uniqueId;
2677
2456
  return __generator(this, function (_a) {
2678
2457
  switch (_a.label) {
@@ -2697,7 +2476,7 @@
2697
2476
  __metadata$n("design:paramtypes", [exports.Configuration, Object, Array])
2698
2477
  ], exports.JobManager);
2699
2478
 
2700
- var __awaiter$n = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2479
+ var __awaiter$o = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2701
2480
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2702
2481
  return new (P || (P = Promise))(function (resolve, reject) {
2703
2482
  function fulfilled(value) { try {
@@ -2775,7 +2554,7 @@
2775
2554
  return this;
2776
2555
  };
2777
2556
  Progress.prototype.createSubProgress = function (progressValue, max, message) {
2778
- return __awaiter$n(this, void 0, void 0, function () {
2557
+ return __awaiter$o(this, void 0, void 0, function () {
2779
2558
  return __generator(this, function (_a) {
2780
2559
  switch (_a.label) {
2781
2560
  case 0:
@@ -2797,7 +2576,7 @@
2797
2576
  });
2798
2577
  };
2799
2578
  Progress.prototype.setMax = function (max) {
2800
- return __awaiter$n(this, void 0, void 0, function () {
2579
+ return __awaiter$o(this, void 0, void 0, function () {
2801
2580
  return __generator(this, function (_a) {
2802
2581
  switch (_a.label) {
2803
2582
  case 0:
@@ -2814,7 +2593,7 @@
2814
2593
  });
2815
2594
  };
2816
2595
  Progress.prototype.setMessage = function (message) {
2817
- return __awaiter$n(this, void 0, void 0, function () {
2596
+ return __awaiter$o(this, void 0, void 0, function () {
2818
2597
  return __generator(this, function (_a) {
2819
2598
  switch (_a.label) {
2820
2599
  case 0:
@@ -2828,7 +2607,7 @@
2828
2607
  });
2829
2608
  };
2830
2609
  Progress.prototype.setError = function (error) {
2831
- return __awaiter$n(this, void 0, void 0, function () {
2610
+ return __awaiter$o(this, void 0, void 0, function () {
2832
2611
  return __generator(this, function (_a) {
2833
2612
  switch (_a.label) {
2834
2613
  case 0:
@@ -2843,7 +2622,7 @@
2843
2622
  };
2844
2623
  Progress.prototype.advance = function (value) {
2845
2624
  if (value === void 0) { value = 1; }
2846
- return __awaiter$n(this, void 0, void 0, function () {
2625
+ return __awaiter$o(this, void 0, void 0, function () {
2847
2626
  return __generator(this, function (_a) {
2848
2627
  switch (_a.label) {
2849
2628
  case 0:
@@ -2865,7 +2644,7 @@
2865
2644
  });
2866
2645
  };
2867
2646
  Progress.prototype.cancel = function () {
2868
- return __awaiter$n(this, void 0, void 0, function () {
2647
+ return __awaiter$o(this, void 0, void 0, function () {
2869
2648
  return __generator(this, function (_a) {
2870
2649
  switch (_a.label) {
2871
2650
  case 0:
@@ -2964,7 +2743,7 @@
2964
2743
  return this;
2965
2744
  };
2966
2745
  SubProgress.prototype.createSubProgress = function (progressValue, max, message) {
2967
- return __awaiter$n(this, void 0, void 0, function () {
2746
+ return __awaiter$o(this, void 0, void 0, function () {
2968
2747
  return __generator(this, function (_a) {
2969
2748
  switch (_a.label) {
2970
2749
  case 0:
@@ -2985,7 +2764,7 @@
2985
2764
  });
2986
2765
  };
2987
2766
  SubProgress.prototype.setMax = function (max) {
2988
- return __awaiter$n(this, void 0, void 0, function () {
2767
+ return __awaiter$o(this, void 0, void 0, function () {
2989
2768
  return __generator(this, function (_a) {
2990
2769
  switch (_a.label) {
2991
2770
  case 0:
@@ -3002,7 +2781,7 @@
3002
2781
  });
3003
2782
  };
3004
2783
  SubProgress.prototype.setMessage = function (message) {
3005
- return __awaiter$n(this, void 0, void 0, function () {
2784
+ return __awaiter$o(this, void 0, void 0, function () {
3006
2785
  return __generator(this, function (_a) {
3007
2786
  switch (_a.label) {
3008
2787
  case 0:
@@ -3017,7 +2796,7 @@
3017
2796
  });
3018
2797
  };
3019
2798
  SubProgress.prototype.setError = function (error) {
3020
- return __awaiter$n(this, void 0, void 0, function () {
2799
+ return __awaiter$o(this, void 0, void 0, function () {
3021
2800
  return __generator(this, function (_a) {
3022
2801
  switch (_a.label) {
3023
2802
  case 0:
@@ -3033,7 +2812,7 @@
3033
2812
  };
3034
2813
  SubProgress.prototype.advance = function (value) {
3035
2814
  if (value === void 0) { value = 1; }
3036
- return __awaiter$n(this, void 0, void 0, function () {
2815
+ return __awaiter$o(this, void 0, void 0, function () {
3037
2816
  return __generator(this, function (_a) {
3038
2817
  switch (_a.label) {
3039
2818
  case 0:
@@ -3050,7 +2829,7 @@
3050
2829
  });
3051
2830
  };
3052
2831
  SubProgress.prototype.cancel = function () {
3053
- return __awaiter$n(this, void 0, void 0, function () {
2832
+ return __awaiter$o(this, void 0, void 0, function () {
3054
2833
  return __generator(this, function (_a) {
3055
2834
  switch (_a.label) {
3056
2835
  case 0:
@@ -3065,7 +2844,7 @@
3065
2844
  });
3066
2845
  };
3067
2846
  SubProgress.prototype.save = function () {
3068
- return __awaiter$n(this, void 0, void 0, function () {
2847
+ return __awaiter$o(this, void 0, void 0, function () {
3069
2848
  var ratio, newProgress, current;
3070
2849
  return __generator(this, function (_a) {
3071
2850
  switch (_a.label) {
@@ -3084,7 +2863,7 @@
3084
2863
  });
3085
2864
  };
3086
2865
  SubProgress.prototype.load = function () {
3087
- return __awaiter$n(this, void 0, void 0, function () {
2866
+ return __awaiter$o(this, void 0, void 0, function () {
3088
2867
  return __generator(this, function (_a) {
3089
2868
  return [2 /*return*/, null];
3090
2869
  });
@@ -3110,7 +2889,7 @@
3110
2889
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3111
2890
  return Reflect.metadata(k, v);
3112
2891
  };
3113
- var __awaiter$m = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2892
+ var __awaiter$n = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3114
2893
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3115
2894
  return new (P || (P = Promise))(function (resolve, reject) {
3116
2895
  function fulfilled(value) { try {
@@ -3142,11 +2921,11 @@
3142
2921
  });
3143
2922
  }
3144
2923
  Progresses.prototype.waitToFinish = function (id) {
3145
- return __awaiter$m(this, void 0, void 0, function () {
2924
+ return __awaiter$n(this, void 0, void 0, function () {
3146
2925
  var _this = this;
3147
2926
  return __generator(this, function (_a) {
3148
2927
  return [2 /*return*/, Promise.race([
3149
- this.waitForProgress(id, function () { return __awaiter$m(_this, void 0, void 0, function () {
2928
+ this.waitForProgress(id, function () { return __awaiter$n(_this, void 0, void 0, function () {
3150
2929
  var progress;
3151
2930
  return __generator(this, function (_a) {
3152
2931
  switch (_a.label) {
@@ -3165,7 +2944,7 @@
3165
2944
  }
3166
2945
  });
3167
2946
  }); }, 500),
3168
- this.waitForProgress(id, function () { return __awaiter$m(_this, void 0, void 0, function () {
2947
+ this.waitForProgress(id, function () { return __awaiter$n(_this, void 0, void 0, function () {
3169
2948
  return __generator(this, function (_a) {
3170
2949
  return [2 /*return*/, this.progresses[id] || null];
3171
2950
  });
@@ -3175,14 +2954,14 @@
3175
2954
  });
3176
2955
  };
3177
2956
  Progresses.prototype.get = function (id) {
3178
- return __awaiter$m(this, void 0, void 0, function () {
2957
+ return __awaiter$n(this, void 0, void 0, function () {
3179
2958
  return __generator(this, function (_a) {
3180
2959
  return [2 /*return*/, !id ? null : this.find({ _id: new bson.ObjectId(id) })];
3181
2960
  });
3182
2961
  });
3183
2962
  };
3184
2963
  Progresses.prototype.find = function (where) {
3185
- return __awaiter$m(this, void 0, void 0, function () {
2964
+ return __awaiter$n(this, void 0, void 0, function () {
3186
2965
  var data;
3187
2966
  return __generator(this, function (_a) {
3188
2967
  switch (_a.label) {
@@ -3196,7 +2975,7 @@
3196
2975
  };
3197
2976
  Progresses.prototype.create = function (max) {
3198
2977
  if (max === void 0) { max = 100; }
3199
- return __awaiter$m(this, void 0, void 0, function () {
2978
+ return __awaiter$n(this, void 0, void 0, function () {
3200
2979
  var data, res;
3201
2980
  return __generator(this, function (_a) {
3202
2981
  switch (_a.label) {
@@ -3220,7 +2999,7 @@
3220
2999
  });
3221
3000
  };
3222
3001
  Progresses.prototype.remove = function (id) {
3223
- return __awaiter$m(this, void 0, void 0, function () {
3002
+ return __awaiter$n(this, void 0, void 0, function () {
3224
3003
  return __generator(this, function (_a) {
3225
3004
  switch (_a.label) {
3226
3005
  case 0: return [4 /*yield*/, this.collection.deleteOne({ _id: new bson.ObjectId(id) })];
@@ -3232,7 +3011,7 @@
3232
3011
  });
3233
3012
  };
3234
3013
  Progresses.prototype.waitForProgress = function (id, cb, delay) {
3235
- return __awaiter$m(this, void 0, void 0, function () {
3014
+ return __awaiter$n(this, void 0, void 0, function () {
3236
3015
  var isFinished, progress, waitTime;
3237
3016
  return __generator(this, function (_a) {
3238
3017
  switch (_a.label) {
@@ -3289,7 +3068,7 @@
3289
3068
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3290
3069
  return Reflect.metadata(k, v);
3291
3070
  };
3292
- var __awaiter$l = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3071
+ var __awaiter$m = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3293
3072
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3294
3073
  return new (P || (P = Promise))(function (resolve, reject) {
3295
3074
  function fulfilled(value) { try {
@@ -3319,7 +3098,7 @@
3319
3098
  LazyAssets.prototype.create = function (jobType, jobParams, jobQue) {
3320
3099
  if (jobParams === void 0) { jobParams = {}; }
3321
3100
  if (jobQue === void 0) { jobQue = "main"; }
3322
- return __awaiter$l(this, void 0, void 0, function () {
3101
+ return __awaiter$m(this, void 0, void 0, function () {
3323
3102
  var jobName, data, existingAsset, res;
3324
3103
  return __generator(this, function (_a) {
3325
3104
  switch (_a.label) {
@@ -3344,14 +3123,14 @@
3344
3123
  });
3345
3124
  };
3346
3125
  LazyAssets.prototype.read = function (id) {
3347
- return __awaiter$l(this, void 0, void 0, function () {
3126
+ return __awaiter$m(this, void 0, void 0, function () {
3348
3127
  return __generator(this, function (_a) {
3349
3128
  return [2 /*return*/, !id ? null : this.find({ _id: new bson.ObjectId(id) })];
3350
3129
  });
3351
3130
  });
3352
3131
  };
3353
3132
  LazyAssets.prototype.find = function (where) {
3354
- return __awaiter$l(this, void 0, void 0, function () {
3133
+ return __awaiter$m(this, void 0, void 0, function () {
3355
3134
  var data;
3356
3135
  return __generator(this, function (_a) {
3357
3136
  switch (_a.label) {
@@ -3366,7 +3145,7 @@
3366
3145
  });
3367
3146
  };
3368
3147
  LazyAssets.prototype.unlink = function (id) {
3369
- return __awaiter$l(this, void 0, void 0, function () {
3148
+ return __awaiter$m(this, void 0, void 0, function () {
3370
3149
  var asset;
3371
3150
  return __generator(this, function (_a) {
3372
3151
  switch (_a.label) {
@@ -3405,7 +3184,7 @@
3405
3184
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3406
3185
  return Reflect.metadata(k, v);
3407
3186
  };
3408
- var __awaiter$k = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3187
+ var __awaiter$l = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3409
3188
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3410
3189
  return new (P || (P = Promise))(function (resolve, reject) {
3411
3190
  function fulfilled(value) { try {
@@ -3431,7 +3210,7 @@
3431
3210
  }
3432
3211
  AssetResolver.prototype.resolve = function (id, lazy) {
3433
3212
  if (lazy === void 0) { lazy = false; }
3434
- return __awaiter$k(this, void 0, void 0, function () {
3213
+ return __awaiter$l(this, void 0, void 0, function () {
3435
3214
  var asset, lazyAsset, lazyAsset;
3436
3215
  return __generator(this, function (_a) {
3437
3216
  switch (_a.label) {
@@ -3486,6 +3265,7 @@
3486
3265
  exports.BackendProvider = /** @class */ (function () {
3487
3266
  function BackendProvider() {
3488
3267
  this.express = express();
3268
+ this.express.set("trust proxy", true);
3489
3269
  this.server = http.createServer(this.express);
3490
3270
  }
3491
3271
  Object.defineProperty(BackendProvider.prototype, "io", {
@@ -3514,7 +3294,7 @@
3514
3294
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3515
3295
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3516
3296
  };
3517
- var __awaiter$j = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3297
+ var __awaiter$k = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3518
3298
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3519
3299
  return new (P || (P = Promise))(function (resolve, reject) {
3520
3300
  function fulfilled(value) { try {
@@ -3537,14 +3317,14 @@
3537
3317
  function CacheProcessor() {
3538
3318
  }
3539
3319
  CacheProcessor.prototype.serialize = function (data) {
3540
- return __awaiter$j(this, void 0, void 0, function () {
3320
+ return __awaiter$k(this, void 0, void 0, function () {
3541
3321
  return __generator(this, function (_a) {
3542
3322
  return [2 /*return*/, data];
3543
3323
  });
3544
3324
  });
3545
3325
  };
3546
3326
  CacheProcessor.prototype.deserialize = function (data) {
3547
- return __awaiter$j(this, void 0, void 0, function () {
3327
+ return __awaiter$k(this, void 0, void 0, function () {
3548
3328
  return __generator(this, function (_a) {
3549
3329
  return [2 /*return*/, data];
3550
3330
  });
@@ -3571,7 +3351,7 @@
3571
3351
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3572
3352
  return Reflect.metadata(k, v);
3573
3353
  };
3574
- var __awaiter$i = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3354
+ var __awaiter$j = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3575
3355
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3576
3356
  return new (P || (P = Promise))(function (resolve, reject) {
3577
3357
  function fulfilled(value) { try {
@@ -3597,7 +3377,7 @@
3597
3377
  this.cacheProcessor = cacheProcessor;
3598
3378
  }
3599
3379
  Cache.prototype.prepare = function () {
3600
- return __awaiter$i(this, void 0, void 0, function () {
3380
+ return __awaiter$j(this, void 0, void 0, function () {
3601
3381
  return __generator(this, function (_a) {
3602
3382
  switch (_a.label) {
3603
3383
  case 0:
@@ -3618,7 +3398,7 @@
3618
3398
  Cache.prototype.set = function (key, value, ttl, expirationTimestamp, tags) {
3619
3399
  if (expirationTimestamp === void 0) { expirationTimestamp = null; }
3620
3400
  if (tags === void 0) { tags = {}; }
3621
- return __awaiter$i(this, void 0, void 0, function () {
3401
+ return __awaiter$j(this, void 0, void 0, function () {
3622
3402
  var item, _a, now;
3623
3403
  return __generator(this, function (_b) {
3624
3404
  switch (_b.label) {
@@ -3649,7 +3429,7 @@
3649
3429
  });
3650
3430
  };
3651
3431
  Cache.prototype.get = function (key) {
3652
- return __awaiter$i(this, void 0, void 0, function () {
3432
+ return __awaiter$j(this, void 0, void 0, function () {
3653
3433
  var item, now;
3654
3434
  return __generator(this, function (_a) {
3655
3435
  switch (_a.label) {
@@ -3675,7 +3455,7 @@
3675
3455
  Cache.prototype.getOrSet = function (key, valueCb, ttl, expirationTimestamp, tags) {
3676
3456
  if (expirationTimestamp === void 0) { expirationTimestamp = null; }
3677
3457
  if (tags === void 0) { tags = {}; }
3678
- return __awaiter$i(this, void 0, void 0, function () {
3458
+ return __awaiter$j(this, void 0, void 0, function () {
3679
3459
  var e_1, _a, _b;
3680
3460
  return __generator(this, function (_c) {
3681
3461
  switch (_c.label) {
@@ -3696,7 +3476,7 @@
3696
3476
  });
3697
3477
  };
3698
3478
  Cache.prototype.delete = function (key) {
3699
- return __awaiter$i(this, void 0, void 0, function () {
3479
+ return __awaiter$j(this, void 0, void 0, function () {
3700
3480
  return __generator(this, function (_a) {
3701
3481
  switch (_a.label) {
3702
3482
  case 0: return [4 /*yield*/, this.prepare()];
@@ -3728,7 +3508,7 @@
3728
3508
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3729
3509
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3730
3510
  };
3731
- var __awaiter$h = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3511
+ var __awaiter$i = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3732
3512
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3733
3513
  return new (P || (P = Promise))(function (resolve, reject) {
3734
3514
  function fulfilled(value) { try {
@@ -3751,7 +3531,7 @@
3751
3531
  function EndpointProvider() {
3752
3532
  }
3753
3533
  EndpointProvider.prototype.configure = function (app) {
3754
- return __awaiter$h(this, void 0, void 0, function () {
3534
+ return __awaiter$i(this, void 0, void 0, function () {
3755
3535
  return __generator(this, function (_a) {
3756
3536
  console.log("Express app is mounted to: " + app.mountpath);
3757
3537
  return [2 /*return*/];
@@ -3782,7 +3562,7 @@
3782
3562
  var __param$6 = (this && this.__param) || function (paramIndex, decorator) {
3783
3563
  return function (target, key) { decorator(target, key, paramIndex); };
3784
3564
  };
3785
- var __awaiter$g = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3565
+ var __awaiter$h = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3786
3566
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3787
3567
  return new (P || (P = Promise))(function (resolve, reject) {
3788
3568
  function fulfilled(value) { try {
@@ -3806,7 +3586,7 @@
3806
3586
  this.fixtures = fixtures;
3807
3587
  }
3808
3588
  Fixtures.prototype.load = function () {
3809
- return __awaiter$g(this, void 0, void 0, function () {
3589
+ return __awaiter$h(this, void 0, void 0, function () {
3810
3590
  var _a, _b, fixture, e_1_1;
3811
3591
  var e_1, _c;
3812
3592
  return __generator(this, function (_d) {
@@ -3854,7 +3634,7 @@
3854
3634
  __metadata$h("design:paramtypes", [Array])
3855
3635
  ], exports.Fixtures);
3856
3636
 
3857
- var __awaiter$f = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3637
+ var __awaiter$g = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3858
3638
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3859
3639
  return new (P || (P = Promise))(function (resolve, reject) {
3860
3640
  function fulfilled(value) { try {
@@ -3885,7 +3665,7 @@
3885
3665
  this.targetSize = !size ? { width: thumbSize, height: thumbSize } : size;
3886
3666
  }
3887
3667
  GalleryImage.prototype.serve = function (id) {
3888
- return __awaiter$f(this, void 0, void 0, function () {
3668
+ return __awaiter$g(this, void 0, void 0, function () {
3889
3669
  var isThumb, original, _a, meta, ratio, sizeRatio, size, targetHeight, targetWidth, resized, buffer;
3890
3670
  return __generator(this, function (_b) {
3891
3671
  switch (_b.label) {
@@ -3981,7 +3761,7 @@
3981
3761
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3982
3762
  return Reflect.metadata(k, v);
3983
3763
  };
3984
- var __awaiter$e = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3764
+ var __awaiter$f = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3985
3765
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3986
3766
  return new (P || (P = Promise))(function (resolve, reject) {
3987
3767
  function fulfilled(value) { try {
@@ -4011,7 +3791,7 @@
4011
3791
  }
4012
3792
  Gallery.prototype.getFolder = function (folder, size) {
4013
3793
  if (size === void 0) { size = null; }
4014
- return __awaiter$e(this, void 0, void 0, function () {
3794
+ return __awaiter$f(this, void 0, void 0, function () {
4015
3795
  var _this = this;
4016
3796
  return __generator(this, function (_a) {
4017
3797
  this.cache[folder] = this.cache[folder] || new Promise(function (resolve) {
@@ -4036,7 +3816,7 @@
4036
3816
  return;
4037
3817
  }
4038
3818
  var promises = files.map(function (file) {
4039
- return new Promise(function (resolve) { return __awaiter$e(_this, void 0, void 0, function () {
3819
+ return new Promise(function (resolve) { return __awaiter$f(_this, void 0, void 0, function () {
4040
3820
  var filePath, absoluteFilePath;
4041
3821
  var _this = this;
4042
3822
  return __generator(this, function (_a) {
@@ -4072,7 +3852,7 @@
4072
3852
  });
4073
3853
  },
4074
3854
  writeResult: function (isThumb, buffer) {
4075
- return new Promise(function (res, rej) { return __awaiter$e(_this, void 0, void 0, function () {
3855
+ return new Promise(function (res, rej) { return __awaiter$f(_this, void 0, void 0, function () {
4076
3856
  var resultPath;
4077
3857
  return __generator(this, function (_a) {
4078
3858
  switch (_a.label) {
@@ -4146,7 +3926,7 @@
4146
3926
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4147
3927
  return Reflect.metadata(k, v);
4148
3928
  };
4149
- var __awaiter$d = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3929
+ var __awaiter$e = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4150
3930
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4151
3931
  return new (P || (P = Promise))(function (resolve, reject) {
4152
3932
  function fulfilled(value) { try {
@@ -4174,7 +3954,7 @@
4174
3954
  this.parts = config.resolve("idParts");
4175
3955
  }
4176
3956
  IdGenerator.prototype.generate = function (checkCb) {
4177
- return __awaiter$d(this, void 0, void 0, function () {
3957
+ return __awaiter$e(this, void 0, void 0, function () {
4178
3958
  var id, tries, notGood;
4179
3959
  return __generator(this, function (_a) {
4180
3960
  switch (_a.label) {
@@ -4266,7 +4046,7 @@
4266
4046
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4267
4047
  return Reflect.metadata(k, v);
4268
4048
  };
4269
- var __awaiter$c = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4049
+ var __awaiter$d = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4270
4050
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4271
4051
  return new (P || (P = Promise))(function (resolve, reject) {
4272
4052
  function fulfilled(value) { try {
@@ -4291,7 +4071,7 @@
4291
4071
  this.cache = {};
4292
4072
  }
4293
4073
  Translator.prototype.getDictionary = function (language) {
4294
- return __awaiter$c(this, void 0, void 0, function () {
4074
+ return __awaiter$d(this, void 0, void 0, function () {
4295
4075
  var dictionary;
4296
4076
  return __generator(this, function (_a) {
4297
4077
  switch (_a.label) {
@@ -4376,7 +4156,7 @@
4376
4156
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4377
4157
  return Reflect.metadata(k, v);
4378
4158
  };
4379
- var __awaiter$b = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4159
+ var __awaiter$c = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4380
4160
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4381
4161
  return new (P || (P = Promise))(function (resolve, reject) {
4382
4162
  function fulfilled(value) { try {
@@ -4419,11 +4199,11 @@
4419
4199
  return this.initPromise;
4420
4200
  };
4421
4201
  TemplateRenderer.prototype.parseTemplates = function (dir, dirPath) {
4422
- return __awaiter$b(this, void 0, void 0, function () {
4202
+ return __awaiter$c(this, void 0, void 0, function () {
4423
4203
  var _this = this;
4424
4204
  return __generator(this, function (_a) {
4425
4205
  return [2 /*return*/, new Promise(function (resolve) {
4426
- fs.readdir(dir, function (err, files) { return __awaiter$b(_this, void 0, void 0, function () {
4206
+ fs.readdir(dir, function (err, files) { return __awaiter$c(_this, void 0, void 0, function () {
4427
4207
  var files_1, files_1_1, file, path$1, parts, name, fullName, content, e_1_1;
4428
4208
  var e_1, _a;
4429
4209
  return __generator(this, function (_b) {
@@ -4475,7 +4255,7 @@
4475
4255
  });
4476
4256
  };
4477
4257
  TemplateRenderer.prototype.render = function (template, language, context) {
4478
- return __awaiter$b(this, void 0, void 0, function () {
4258
+ return __awaiter$c(this, void 0, void 0, function () {
4479
4259
  var res, _a;
4480
4260
  return __generator(this, function (_b) {
4481
4261
  switch (_b.label) {
@@ -4525,7 +4305,7 @@
4525
4305
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4526
4306
  return Reflect.metadata(k, v);
4527
4307
  };
4528
- var __awaiter$a = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4308
+ var __awaiter$b = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4529
4309
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4530
4310
  return new (P || (P = Promise))(function (resolve, reject) {
4531
4311
  function fulfilled(value) { try {
@@ -4565,7 +4345,7 @@
4565
4345
  configurable: true
4566
4346
  });
4567
4347
  MailSender.prototype.sendMail = function (language, options) {
4568
- return __awaiter$a(this, void 0, void 0, function () {
4348
+ return __awaiter$b(this, void 0, void 0, function () {
4569
4349
  var subject, html;
4570
4350
  return __generator(this, function (_a) {
4571
4351
  switch (_a.label) {
@@ -4608,7 +4388,7 @@
4608
4388
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4609
4389
  return Reflect.metadata(k, v);
4610
4390
  };
4611
- var __awaiter$9 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4391
+ var __awaiter$a = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4612
4392
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4613
4393
  return new (P || (P = Promise))(function (resolve, reject) {
4614
4394
  function fulfilled(value) { try {
@@ -4635,7 +4415,7 @@
4635
4415
  MemoryCache.prototype.set = function (key, value, ttl, expirationTimestamp, tags) {
4636
4416
  if (expirationTimestamp === void 0) { expirationTimestamp = null; }
4637
4417
  if (tags === void 0) { tags = {}; }
4638
- return __awaiter$9(this, void 0, void 0, function () {
4418
+ return __awaiter$a(this, void 0, void 0, function () {
4639
4419
  var now, expTimestamp;
4640
4420
  return __generator(this, function (_a) {
4641
4421
  now = Math.round(new Date().getTime() / 1000);
@@ -4651,7 +4431,7 @@
4651
4431
  });
4652
4432
  };
4653
4433
  MemoryCache.prototype.get = function (key) {
4654
- return __awaiter$9(this, void 0, void 0, function () {
4434
+ return __awaiter$a(this, void 0, void 0, function () {
4655
4435
  var item, now, expTimestamp, value;
4656
4436
  return __generator(this, function (_a) {
4657
4437
  switch (_a.label) {
@@ -4682,7 +4462,7 @@
4682
4462
  MemoryCache.prototype.getOrSet = function (key, valueCb, ttl, expirationTimestamp, tags) {
4683
4463
  if (expirationTimestamp === void 0) { expirationTimestamp = null; }
4684
4464
  if (tags === void 0) { tags = {}; }
4685
- return __awaiter$9(this, void 0, void 0, function () {
4465
+ return __awaiter$a(this, void 0, void 0, function () {
4686
4466
  var e_1, _a, _b;
4687
4467
  return __generator(this, function (_c) {
4688
4468
  switch (_c.label) {
@@ -4703,7 +4483,7 @@
4703
4483
  });
4704
4484
  };
4705
4485
  MemoryCache.prototype.delete = function (key) {
4706
- return __awaiter$9(this, void 0, void 0, function () {
4486
+ return __awaiter$a(this, void 0, void 0, function () {
4707
4487
  return __generator(this, function (_a) {
4708
4488
  switch (_a.label) {
4709
4489
  case 0:
@@ -4734,7 +4514,7 @@
4734
4514
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4735
4515
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4736
4516
  };
4737
- var __awaiter$8 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4517
+ var __awaiter$9 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4738
4518
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4739
4519
  return new (P || (P = Promise))(function (resolve, reject) {
4740
4520
  function fulfilled(value) { try {
@@ -4763,7 +4543,7 @@
4763
4543
  function UserManager() {
4764
4544
  }
4765
4545
  UserManager.prototype.getByCredentials = function (credentials) {
4766
- return __awaiter$8(this, void 0, void 0, function () {
4546
+ return __awaiter$9(this, void 0, void 0, function () {
4767
4547
  var _a;
4768
4548
  return __generator(this, function (_b) {
4769
4549
  switch (_b.label) {
@@ -4781,14 +4561,14 @@
4781
4561
  });
4782
4562
  };
4783
4563
  UserManager.prototype.getById = function (id) {
4784
- return __awaiter$8(this, void 0, void 0, function () {
4564
+ return __awaiter$9(this, void 0, void 0, function () {
4785
4565
  return __generator(this, function (_a) {
4786
4566
  return [2 /*return*/, (sampleUser.id == id) ? sampleUser : null];
4787
4567
  });
4788
4568
  });
4789
4569
  };
4790
4570
  UserManager.prototype.serialize = function (user) {
4791
- return __awaiter$8(this, void 0, void 0, function () {
4571
+ return __awaiter$9(this, void 0, void 0, function () {
4792
4572
  var res;
4793
4573
  return __generator(this, function (_a) {
4794
4574
  res = Object.assign({}, user);
@@ -4896,7 +4676,7 @@
4896
4676
  var __param$5 = (this && this.__param) || function (paramIndex, decorator) {
4897
4677
  return function (target, key) { decorator(target, key, paramIndex); };
4898
4678
  };
4899
- var __awaiter$7 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4679
+ var __awaiter$8 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4900
4680
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4901
4681
  return new (P || (P = Promise))(function (resolve, reject) {
4902
4682
  function fulfilled(value) { try {
@@ -4921,7 +4701,7 @@
4921
4701
  this.assetResolver = assetResolver;
4922
4702
  }
4923
4703
  AssetsController.prototype.upload = function (file) {
4924
- return __awaiter$7(this, void 0, void 0, function () {
4704
+ return __awaiter$8(this, void 0, void 0, function () {
4925
4705
  var contentType, asset, e_1, msg;
4926
4706
  return __generator(this, function (_c) {
4927
4707
  switch (_c.label) {
@@ -4942,7 +4722,7 @@
4942
4722
  });
4943
4723
  };
4944
4724
  AssetsController.prototype.uploadUrl = function (body) {
4945
- return __awaiter$7(this, void 0, void 0, function () {
4725
+ return __awaiter$8(this, void 0, void 0, function () {
4946
4726
  var asset, e_2, msg;
4947
4727
  return __generator(this, function (_c) {
4948
4728
  switch (_c.label) {
@@ -4962,7 +4742,7 @@
4962
4742
  });
4963
4743
  };
4964
4744
  AssetsController.prototype.getFile = function (id, lazy, res) {
4965
- return __awaiter$7(this, void 0, void 0, function () {
4745
+ return __awaiter$8(this, void 0, void 0, function () {
4966
4746
  var asset;
4967
4747
  return __generator(this, function (_c) {
4968
4748
  switch (_c.label) {
@@ -4976,7 +4756,7 @@
4976
4756
  };
4977
4757
  AssetsController.prototype.getImageRotation = function (id, params, res, rotation) {
4978
4758
  if (rotation === void 0) { rotation = 0; }
4979
- return __awaiter$7(this, void 0, void 0, function () {
4759
+ return __awaiter$8(this, void 0, void 0, function () {
4980
4760
  var asset;
4981
4761
  return __generator(this, function (_c) {
4982
4762
  switch (_c.label) {
@@ -4992,14 +4772,14 @@
4992
4772
  });
4993
4773
  };
4994
4774
  AssetsController.prototype.getImage = function (id, params, res) {
4995
- return __awaiter$7(this, void 0, void 0, function () {
4775
+ return __awaiter$8(this, void 0, void 0, function () {
4996
4776
  return __generator(this, function (_c) {
4997
4777
  return [2 /*return*/, this.getImageRotation(id, params, res)];
4998
4778
  });
4999
4779
  });
5000
4780
  };
5001
4781
  AssetsController.prototype.getFileByName = function (name, res) {
5002
- return __awaiter$7(this, void 0, void 0, function () {
4782
+ return __awaiter$8(this, void 0, void 0, function () {
5003
4783
  var asset;
5004
4784
  return __generator(this, function (_c) {
5005
4785
  switch (_c.label) {
@@ -5012,7 +4792,7 @@
5012
4792
  });
5013
4793
  };
5014
4794
  AssetsController.prototype.getImageByName = function (name, params, res) {
5015
- return __awaiter$7(this, void 0, void 0, function () {
4795
+ return __awaiter$8(this, void 0, void 0, function () {
5016
4796
  var asset;
5017
4797
  return __generator(this, function (_c) {
5018
4798
  switch (_c.label) {
@@ -5038,7 +4818,7 @@
5038
4818
  }
5039
4819
  };
5040
4820
  AssetsController.prototype.getAsset = function (type, id, lazy, res) {
5041
- return __awaiter$7(this, void 0, void 0, function () {
4821
+ return __awaiter$8(this, void 0, void 0, function () {
5042
4822
  var asset;
5043
4823
  return __generator(this, function (_c) {
5044
4824
  switch (_c.label) {
@@ -5055,7 +4835,7 @@
5055
4835
  });
5056
4836
  };
5057
4837
  AssetsController.prototype.getAssetByName = function (type, filename, res) {
5058
- return __awaiter$7(this, void 0, void 0, function () {
4838
+ return __awaiter$8(this, void 0, void 0, function () {
5059
4839
  var asset;
5060
4840
  return __generator(this, function (_c) {
5061
4841
  switch (_c.label) {
@@ -5147,7 +4927,7 @@
5147
4927
  var __param$4 = (this && this.__param) || function (paramIndex, decorator) {
5148
4928
  return function (target, key) { decorator(target, key, paramIndex); };
5149
4929
  };
5150
- var __awaiter$6 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4930
+ var __awaiter$7 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5151
4931
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5152
4932
  return new (P || (P = Promise))(function (resolve, reject) {
5153
4933
  function fulfilled(value) { try {
@@ -5172,7 +4952,7 @@
5172
4952
  this.userManager = userManager;
5173
4953
  }
5174
4954
  AuthController.prototype.login = function (credentials, res) {
5175
- return __awaiter$6(this, void 0, void 0, function () {
4955
+ return __awaiter$7(this, void 0, void 0, function () {
5176
4956
  var user, reason_1, valid, _a, _b;
5177
4957
  return __generator(this, function (_c) {
5178
4958
  switch (_c.label) {
@@ -5292,7 +5072,7 @@
5292
5072
  var __param$2 = (this && this.__param) || function (paramIndex, decorator) {
5293
5073
  return function (target, key) { decorator(target, key, paramIndex); };
5294
5074
  };
5295
- var __awaiter$5 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5075
+ var __awaiter$6 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5296
5076
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5297
5077
  return new (P || (P = Promise))(function (resolve, reject) {
5298
5078
  function fulfilled(value) { try {
@@ -5319,7 +5099,7 @@
5319
5099
  this.connectionType = !mainEndpoint ? "polling" : "socket";
5320
5100
  }
5321
5101
  ProgressesController.prototype.getProgress = function (id) {
5322
- return __awaiter$5(this, void 0, void 0, function () {
5102
+ return __awaiter$6(this, void 0, void 0, function () {
5323
5103
  var progress, json;
5324
5104
  return __generator(this, function (_a) {
5325
5105
  switch (_a.label) {
@@ -5364,7 +5144,7 @@
5364
5144
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
5365
5145
  return Reflect.metadata(k, v);
5366
5146
  };
5367
- var __awaiter$4 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5147
+ var __awaiter$5 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5368
5148
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5369
5149
  return new (P || (P = Promise))(function (resolve, reject) {
5370
5150
  function fulfilled(value) { try {
@@ -5396,7 +5176,7 @@
5396
5176
  configurable: true
5397
5177
  });
5398
5178
  ErrorHandlerMiddleware.prototype.error = function (error, req, res, next) {
5399
- return __awaiter$4(this, void 0, void 0, function () {
5179
+ return __awaiter$5(this, void 0, void 0, function () {
5400
5180
  var result;
5401
5181
  return __generator(this, function (_a) {
5402
5182
  switch (_a.label) {
@@ -5413,7 +5193,7 @@
5413
5193
  });
5414
5194
  };
5415
5195
  ErrorHandlerMiddleware.prototype.getResult = function (error, req, res) {
5416
- return __awaiter$4(this, void 0, void 0, function () {
5196
+ return __awaiter$5(this, void 0, void 0, function () {
5417
5197
  var result, _a, _b, _c;
5418
5198
  return __generator(this, function (_d) {
5419
5199
  switch (_d.label) {
@@ -5608,7 +5388,7 @@
5608
5388
  var __param = (this && this.__param) || function (paramIndex, decorator) {
5609
5389
  return function (target, key) { decorator(target, key, paramIndex); };
5610
5390
  };
5611
- var __awaiter$3 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5391
+ var __awaiter$4 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5612
5392
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5613
5393
  return new (P || (P = Promise))(function (resolve, reject) {
5614
5394
  function fulfilled(value) { try {
@@ -5633,7 +5413,7 @@
5633
5413
  this.socketServer = socketServer;
5634
5414
  }
5635
5415
  ProgressController.prototype.advanceProgress = function (client, progressId) {
5636
- return __awaiter$3(this, void 0, void 0, function () {
5416
+ return __awaiter$4(this, void 0, void 0, function () {
5637
5417
  var progress, json;
5638
5418
  return __generator(this, function (_a) {
5639
5419
  switch (_a.label) {
@@ -5655,7 +5435,7 @@
5655
5435
  });
5656
5436
  };
5657
5437
  ProgressController.prototype.setProgressInterest = function (client, progressId) {
5658
- return __awaiter$3(this, void 0, void 0, function () {
5438
+ return __awaiter$4(this, void 0, void 0, function () {
5659
5439
  var progress, json;
5660
5440
  return __generator(this, function (_a) {
5661
5441
  switch (_a.label) {
@@ -5722,6 +5502,75 @@
5722
5502
  socketControllers.Middleware()
5723
5503
  ], CompressionMiddleware);
5724
5504
 
5505
+ var __awaiter$3 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5506
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5507
+ return new (P || (P = Promise))(function (resolve, reject) {
5508
+ function fulfilled(value) { try {
5509
+ step(generator.next(value));
5510
+ }
5511
+ catch (e) {
5512
+ reject(e);
5513
+ } }
5514
+ function rejected(value) { try {
5515
+ step(generator["throw"](value));
5516
+ }
5517
+ catch (e) {
5518
+ reject(e);
5519
+ } }
5520
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5521
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
5522
+ });
5523
+ };
5524
+ function setupStatic(rootFolder, container) {
5525
+ return __awaiter$3(this, void 0, void 0, function () {
5526
+ var browserFolder, app, ep;
5527
+ return __generator(this, function (_a) {
5528
+ switch (_a.label) {
5529
+ case 0:
5530
+ browserFolder = path.resolve(rootFolder || __dirname, "public_html");
5531
+ app = container.get(EXPRESS);
5532
+ ep = container.get(exports.EndpointProvider);
5533
+ console.log(browserFolder, fs.existsSync(browserFolder));
5534
+ if (fs.existsSync(browserFolder)) {
5535
+ console.log("public_html exists. setting up static files serving...");
5536
+ app.use(express_["static"](browserFolder, {
5537
+ maxAge: "1y"
5538
+ }));
5539
+ }
5540
+ else {
5541
+ console.log("public_html does not exist on path: \"" + browserFolder + "\"");
5542
+ }
5543
+ return [4 /*yield*/, ep.configure(app)];
5544
+ case 1:
5545
+ _a.sent();
5546
+ return [2 /*return*/];
5547
+ }
5548
+ });
5549
+ });
5550
+ }
5551
+
5552
+ var BaseDoc = /** @class */ (function () {
5553
+ function BaseDoc() {
5554
+ }
5555
+ /**
5556
+ * Casts this to DocumentType<this> to allow using document methods in get/set-s
5557
+ */
5558
+ BaseDoc.prototype.cast = function () {
5559
+ return this;
5560
+ };
5561
+ /**
5562
+ * Gets a pre-compiled model from typegoose cache by its class type
5563
+ * @param type
5564
+ */
5565
+ BaseDoc.prototype.model = function (type) {
5566
+ return typegoose.getModelForClass(type);
5567
+ };
5568
+ return BaseDoc;
5569
+ }());
5570
+ // @ts-ignore
5571
+ var PrimitiveArray = mongoose.Types.Array;
5572
+ var DocumentArray = mongoose.Types.DocumentArray;
5573
+
5725
5574
  var Tree = /** @class */ (function () {
5726
5575
  function Tree(container, exists, path) {
5727
5576
  this.container = container;
@@ -5963,67 +5812,6 @@
5963
5812
  step((generator = generator.apply(thisArg, _arguments || [])).next());
5964
5813
  });
5965
5814
  };
5966
- function setupStatic(rootFolder, container) {
5967
- return __awaiter$2(this, void 0, void 0, function () {
5968
- var browserFolder, app, ep;
5969
- return __generator(this, function (_a) {
5970
- switch (_a.label) {
5971
- case 0:
5972
- browserFolder = path.resolve(rootFolder || __dirname, "public_html");
5973
- app = container.get(EXPRESS);
5974
- ep = container.get(exports.EndpointProvider);
5975
- console.log(browserFolder, fs.existsSync(browserFolder));
5976
- if (fs.existsSync(browserFolder)) {
5977
- console.log("public_html exists. setting up static files serving...");
5978
- app.use(express_["static"](browserFolder, {
5979
- maxAge: "1y"
5980
- }));
5981
- }
5982
- else {
5983
- console.log("public_html does not exist on path: \"" + browserFolder + "\"");
5984
- }
5985
- return [4 /*yield*/, ep.configure(app)];
5986
- case 1:
5987
- _a.sent();
5988
- return [2 /*return*/];
5989
- }
5990
- });
5991
- });
5992
- }
5993
-
5994
- var BaseDoc = /** @class */ (function () {
5995
- function BaseDoc() {
5996
- }
5997
- /**
5998
- * Casts this to DocumentType<this> to allow using document methods in get/set-s
5999
- */
6000
- BaseDoc.prototype.cast = function () {
6001
- return this;
6002
- };
6003
- return BaseDoc;
6004
- }());
6005
- var DocumentArray = mongoose.Types.DocumentArray;
6006
- var PrimitiveArray = mongoose.Types.Array;
6007
-
6008
- var __awaiter$1 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6009
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6010
- return new (P || (P = Promise))(function (resolve, reject) {
6011
- function fulfilled(value) { try {
6012
- step(generator.next(value));
6013
- }
6014
- catch (e) {
6015
- reject(e);
6016
- } }
6017
- function rejected(value) { try {
6018
- step(generator["throw"](value));
6019
- }
6020
- catch (e) {
6021
- reject(e);
6022
- } }
6023
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6024
- step((generator = generator.apply(thisArg, _arguments || [])).next());
6025
- });
6026
- };
6027
5815
  var LazyAssetGenerator = /** @class */ (function () {
6028
5816
  function LazyAssetGenerator(assetResolver, progresses, lazyId) {
6029
5817
  this.assetResolver = assetResolver;
@@ -6045,7 +5833,7 @@
6045
5833
  configurable: true
6046
5834
  });
6047
5835
  LazyAssetGenerator.prototype.process = function (messaging) {
6048
- return __awaiter$1(this, void 0, void 0, function () {
5836
+ return __awaiter$2(this, void 0, void 0, function () {
6049
5837
  var lazyAsset, progress, asset, e_1;
6050
5838
  return __generator(this, function (_a) {
6051
5839
  switch (_a.label) {
@@ -6093,6 +5881,282 @@
6093
5881
  return LazyAssetGenerator;
6094
5882
  }());
6095
5883
 
5884
+ var __awaiter$1 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5885
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5886
+ return new (P || (P = Promise))(function (resolve, reject) {
5887
+ function fulfilled(value) { try {
5888
+ step(generator.next(value));
5889
+ }
5890
+ catch (e) {
5891
+ reject(e);
5892
+ } }
5893
+ function rejected(value) { try {
5894
+ step(generator["throw"](value));
5895
+ }
5896
+ catch (e) {
5897
+ reject(e);
5898
+ } }
5899
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5900
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
5901
+ });
5902
+ };
5903
+ var pluginsKey = "typegoose:plugins";
5904
+ /**
5905
+ * A mongoose/typegoose plugin to inject services from the main di container to a schema as virtuals
5906
+ * @param schema
5907
+ * @param services
5908
+ */
5909
+ function injectServices(schema, services) {
5910
+ var serviceMap = {};
5911
+ if (!isObject(services)) {
5912
+ throw new Error("services object should be defined to inject services to schema!");
5913
+ }
5914
+ Object.keys(services).forEach(function (prop) {
5915
+ schema
5916
+ .virtual(prop)
5917
+ .get(function () {
5918
+ var diContainer = diContainers.appContainer;
5919
+ serviceMap[prop] = serviceMap[prop] || (!diContainer ? {} : diContainer.resolve(services[prop]));
5920
+ return serviceMap[prop];
5921
+ });
5922
+ });
5923
+ }
5924
+ /**
5925
+ * Decorates a property to inject a service with the help of the injectServices mongoose/typegoose plugin
5926
+ * @param token optional InjectionToken to use
5927
+ * @return PropertyDecorator
5928
+ */
5929
+ function service(token) {
5930
+ return function (target, propertyKey) {
5931
+ var _b;
5932
+ var _a;
5933
+ var propertyType = Reflect.getOwnMetadata("design:type", target, propertyKey);
5934
+ var plugins = Array.from((_a = Reflect.getMetadata(pluginsKey, target.constructor)) !== null && _a !== void 0 ? _a : []);
5935
+ var plugin = plugins.find(function (t) { return t.mongoosePlugin === injectServices; });
5936
+ if (!plugin) {
5937
+ plugin = { mongoosePlugin: injectServices, options: {} };
5938
+ plugins.push(plugin);
5939
+ }
5940
+ plugin.options = Object.assign(plugin.options || {}, (_b = {}, _b[propertyKey] = token !== null && token !== void 0 ? token : propertyType, _b));
5941
+ Reflect.defineMetadata(pluginsKey, plugins, target.constructor);
5942
+ };
5943
+ }
5944
+ /**
5945
+ * Paginate using a typegoose model using a simple where query and pagination params
5946
+ * @param model Typegoose model
5947
+ * @param where Simple query to filter the results
5948
+ * @param params Pagination params
5949
+ */
5950
+ function paginate(model, where, params) {
5951
+ return model.countDocuments(where).then(function (count) {
5952
+ var query = model.find(where);
5953
+ if (isString(params.sort)) {
5954
+ query = query.sort(params.sort);
5955
+ }
5956
+ if (isArray(params.populate)) {
5957
+ params.populate.forEach(function (field) {
5958
+ query = query.populate(field);
5959
+ });
5960
+ }
5961
+ return (params.limit > 0 ? query.skip(params.page * params.limit).limit(params.limit) : query).then(function (items) {
5962
+ var meta = { total: count };
5963
+ return { count: count, items: items, meta: meta };
5964
+ });
5965
+ });
5966
+ }
5967
+ function lookupStages(from, localField, as, foreignField, shouldUnwind) {
5968
+ if (as === void 0) { as = null; }
5969
+ if (foreignField === void 0) { foreignField = "_id"; }
5970
+ if (shouldUnwind === void 0) { shouldUnwind = true; }
5971
+ as = as || localField.replace("Id", "");
5972
+ var stages = [
5973
+ {
5974
+ $lookup: {
5975
+ from: from,
5976
+ localField: localField,
5977
+ foreignField: foreignField,
5978
+ as: as
5979
+ }
5980
+ },
5981
+ {
5982
+ $unwind: {
5983
+ path: "$" + as,
5984
+ preserveNullAndEmptyArrays: true
5985
+ }
5986
+ }
5987
+ ];
5988
+ if (!shouldUnwind) {
5989
+ stages.splice(1, 1);
5990
+ }
5991
+ return stages;
5992
+ }
5993
+ function letsLookupStage(from, pipeline, as, letFields) {
5994
+ if (as === void 0) { as = null; }
5995
+ if (letFields === void 0) { letFields = null; }
5996
+ as = as || from;
5997
+ letFields = letFields || { id: "$_id" };
5998
+ return {
5999
+ $lookup: {
6000
+ from: from,
6001
+ let: letFields,
6002
+ pipeline: pipeline,
6003
+ as: as
6004
+ }
6005
+ };
6006
+ }
6007
+ function matchStage(match) {
6008
+ return { $match: match };
6009
+ }
6010
+ function matchField(field, filter, when) {
6011
+ return { field: field, filter: filter, when: when };
6012
+ }
6013
+ function matchFieldStages() {
6014
+ var fields = [];
6015
+ for (var _i = 0; _i < arguments.length; _i++) {
6016
+ fields[_i] = arguments[_i];
6017
+ }
6018
+ var match = {};
6019
+ fields.forEach(function (field) {
6020
+ if (field.when) {
6021
+ match[field.field] = field.filter;
6022
+ }
6023
+ });
6024
+ return Object.keys(match).length > 0 ? [matchStage(match)] : [];
6025
+ }
6026
+ function projectStage(fields) {
6027
+ return { $project: fields };
6028
+ }
6029
+ function unwindStage(fieldOrOpts) {
6030
+ return { $unwind: fieldOrOpts };
6031
+ }
6032
+ function hydratePopulated(modelType, json) {
6033
+ var e_1, _b;
6034
+ var object = modelType.hydrate(json);
6035
+ var _loop_1 = function (path, obj) {
6036
+ var ref = obj.ref, type = obj.type;
6037
+ if (Array.isArray(type) && type.length > 0) {
6038
+ ref = type[0].ref;
6039
+ }
6040
+ if (!ref)
6041
+ return "continue";
6042
+ var value = utils.getValue(path, json);
6043
+ var hydrateVal = function (val) {
6044
+ if (val == null || val instanceof mongoose.Types.ObjectId)
6045
+ return val;
6046
+ return hydratePopulated(mongoose.model(ref), val);
6047
+ };
6048
+ if (Array.isArray(value)) {
6049
+ utils.setValue(path, value.map(hydrateVal), object);
6050
+ return "continue";
6051
+ }
6052
+ utils.setValue(path, hydrateVal(value), object);
6053
+ };
6054
+ try {
6055
+ for (var _c = __values(Object.entries(modelType.schema.obj)), _d = _c.next(); !_d.done; _d = _c.next()) {
6056
+ var _e = __read(_d.value, 2), path = _e[0], obj = _e[1];
6057
+ _loop_1(path, obj);
6058
+ }
6059
+ }
6060
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
6061
+ finally {
6062
+ try {
6063
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
6064
+ }
6065
+ finally { if (e_1) throw e_1.error; }
6066
+ }
6067
+ return object;
6068
+ }
6069
+ function paginateAggregations(model, aggregations, params, metaProjection) {
6070
+ if (metaProjection === void 0) { metaProjection = {}; }
6071
+ return __awaiter$1(this, void 0, void 0, function () {
6072
+ var sortField, sortAggregation, result, pagination;
6073
+ var _b;
6074
+ return __generator(this, function (_c) {
6075
+ switch (_c.label) {
6076
+ case 0:
6077
+ sortField = !isString(params.sort) || !params.sort ? null : (params.sort.startsWith("-") ? params.sort.substr(1) : params.sort);
6078
+ sortAggregation = !sortField ? [] : [{
6079
+ $sort: (_b = {}, _b[sortField] = sortField == params.sort ? 1 : -1, _b)
6080
+ }];
6081
+ return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray(__spreadArray([], __read(aggregations)), __read(sortAggregation)), [
6082
+ {
6083
+ $group: {
6084
+ _id: "results",
6085
+ result: { $push: "$$CURRENT" }
6086
+ }
6087
+ },
6088
+ {
6089
+ $project: {
6090
+ _id: 0,
6091
+ items: params.limit > 0 ? { $slice: ["$result", params.page * params.limit, params.limit] } : "$result",
6092
+ count: { $size: "$result" },
6093
+ meta: Object.assign({ total: { $size: "$result" } }, metaProjection)
6094
+ }
6095
+ }
6096
+ ]))];
6097
+ case 1:
6098
+ result = _c.sent();
6099
+ pagination = result[0];
6100
+ if (!pagination) {
6101
+ return [2 /*return*/, { items: [], count: 0, meta: { total: 0 } }];
6102
+ }
6103
+ pagination.items = pagination.items.map(function (i) { return hydratePopulated(model, i); });
6104
+ return [2 /*return*/, pagination];
6105
+ }
6106
+ });
6107
+ });
6108
+ }
6109
+ function ResolveEntity(model, extraCheck) {
6110
+ var _this = this;
6111
+ var modelName = model.modelName;
6112
+ var paramName = modelName.toLowerCase();
6113
+ return routingControllers.createParamDecorator({
6114
+ required: false,
6115
+ value: function (action) { return __awaiter$1(_this, void 0, void 0, function () {
6116
+ var req, token, id, query, doc, e_2;
6117
+ return __generator(this, function (_b) {
6118
+ switch (_b.label) {
6119
+ case 0:
6120
+ req = action.request;
6121
+ token = req.header("x-" + paramName + "-token");
6122
+ id = req.params[paramName + "Id"];
6123
+ if (!id && !token) {
6124
+ throw new routingControllers.BadRequestError(modelName + " id or token should be defined!");
6125
+ }
6126
+ query = !token
6127
+ ? model.findById(id)
6128
+ : model.findOne({ token: token });
6129
+ doc = null;
6130
+ if (!isFunction(extraCheck)) return [3 /*break*/, 5];
6131
+ _b.label = 1;
6132
+ case 1:
6133
+ _b.trys.push([1, 3, , 4]);
6134
+ return [4 /*yield*/, valueToPromise(extraCheck(query, action))];
6135
+ case 2:
6136
+ doc = _b.sent();
6137
+ return [3 /*break*/, 4];
6138
+ case 3:
6139
+ e_2 = _b.sent();
6140
+ throw new routingControllers.BadRequestError(modelName + " check error: " + (e_2.message || e_2));
6141
+ case 4: return [3 /*break*/, 7];
6142
+ case 5: return [4 /*yield*/, query];
6143
+ case 6:
6144
+ doc = _b.sent();
6145
+ _b.label = 7;
6146
+ case 7:
6147
+ if (!doc) {
6148
+ throw new routingControllers.HttpError(404, !token
6149
+ ? modelName + " could not be found with id: " + id
6150
+ : modelName + " could not be found with token: " + token);
6151
+ }
6152
+ action.request[paramName] = doc;
6153
+ return [2 /*return*/, doc];
6154
+ }
6155
+ });
6156
+ }); }
6157
+ });
6158
+ }
6159
+
6096
6160
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6097
6161
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6098
6162
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -6487,6 +6551,7 @@
6487
6551
  exports.regroup = regroup;
6488
6552
  exports.replaceSpecialChars = replaceSpecialChars;
6489
6553
  exports.runCommand = runCommand;
6554
+ exports.service = service;
6490
6555
  exports.setupBackend = setupBackend;
6491
6556
  exports.streamToBuffer = streamToBuffer;
6492
6557
  exports.toImage = toImage;