@stemy/backend 2.9.8 → 3.1.0

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('mongoose'), require('mongoose/lib/utils'), require('stream'), require('bson'), require('fontkit'), require('file-type'), require('sharp'), require('axios'), require('mongodb'), require('dotenv'), require('node-resque'), require('node-cron'), require('ioredis'), require('socket.io-client'), 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', 'mongoose', 'mongoose/lib/utils', 'stream', 'bson', 'fontkit', 'file-type', 'sharp', 'axios', 'mongodb', 'dotenv', 'node-resque', 'node-cron', 'ioredis', 'socket.io-client', '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.mongoose, global["mongoose-lib-utils"], global.stream, global.bson, global.fontkit, global["file-type"], global.sharp, global.axios, global.mongodb, global.dotenv, global["node-resque"], global["node-cron"], global.ioredis, global.socket["io-client"], 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, mongoose, utils, stream, bson, fontKit_, fileType, sharp_, axios, mongodb, dotenv, nodeResque, nodeCron, ioredis, socket_io_client, 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('mongoose'), require('mongoose/lib/utils'), require('stream'), require('bson'), require('fontkit'), require('file-type'), require('sharp'), require('axios'), require('mongodb'), 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', 'mongoose', 'mongoose/lib/utils', 'stream', 'bson', 'fontkit', 'file-type', 'sharp', 'axios', 'mongodb', '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.mongoose, global["mongoose-lib-utils"], global.stream, global.bson, global.fontkit, global["file-type"], global.sharp, global.axios, global.mongodb, 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, mongoose, utils, stream, bson, fontKit_, fileType, sharp_, axios, mongodb, dotenv, nodeCron, zeromq, operators, http, express_, socket_io, uuid, nodemailer, Handlebars, bcrypt, moment) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -28,8 +28,6 @@
28
28
  var sharp___default = /*#__PURE__*/_interopDefaultLegacy(sharp_);
29
29
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
30
30
  var dotenv__default = /*#__PURE__*/_interopDefaultLegacy(dotenv);
31
- var ioredis__default = /*#__PURE__*/_interopDefaultLegacy(ioredis);
32
- var socket_io_client__default = /*#__PURE__*/_interopDefaultLegacy(socket_io_client);
33
31
  var express___default = /*#__PURE__*/_interopDefaultLegacy(express_);
34
32
  var socket_io__default = /*#__PURE__*/_interopDefaultLegacy(socket_io);
35
33
  var Handlebars__namespace = /*#__PURE__*/_interopNamespace(Handlebars);
@@ -745,11 +743,16 @@
745
743
  function valueToPromise(value) {
746
744
  return value instanceof Promise ? value : Promise.resolve(value);
747
745
  }
748
- function promiseTimeout(timeout) {
746
+ function promiseTimeout(timeout, error) {
749
747
  if (timeout === void 0) { timeout = 1000; }
750
- return new Promise(function (resolve) {
748
+ if (error === void 0) { error = false; }
749
+ return new Promise(function (resolve, reject) {
751
750
  setTimeout(function () {
752
- resolve();
751
+ if (error) {
752
+ reject("Timeout exceeded: " + timeout + "ms");
753
+ return;
754
+ }
755
+ resolve("Timeout: " + timeout + "ms");
753
756
  }, timeout);
754
757
  });
755
758
  }
@@ -1059,6 +1062,72 @@
1059
1062
  console.error(data.toString());
1060
1063
  });
1061
1064
  });
1065
+ }
1066
+ exports.ConsoleColor = void 0;
1067
+ (function (ConsoleColor) {
1068
+ ConsoleColor["Reset"] = "\u001B[0m";
1069
+ ConsoleColor["Bright"] = "\u001B[1m";
1070
+ ConsoleColor["Dim"] = "\u001B[2m";
1071
+ ConsoleColor["Underscore"] = "\u001B[4m";
1072
+ ConsoleColor["Blink"] = "\u001B[5m";
1073
+ ConsoleColor["Reverse"] = "\u001B[7m";
1074
+ ConsoleColor["Hidden"] = "\u001B[8m";
1075
+ ConsoleColor["FgBlack"] = "\u001B[30m";
1076
+ ConsoleColor["FgRed"] = "\u001B[31m";
1077
+ ConsoleColor["FgGreen"] = "\u001B[32m";
1078
+ ConsoleColor["FgYellow"] = "\u001B[33m";
1079
+ ConsoleColor["FgBlue"] = "\u001B[34m";
1080
+ ConsoleColor["FgMagenta"] = "\u001B[35m";
1081
+ ConsoleColor["FgCyan"] = "\u001B[36m";
1082
+ ConsoleColor["FgWhite"] = "\u001B[37m";
1083
+ ConsoleColor["FgDefault"] = "\u001B[38m";
1084
+ ConsoleColor["BgBlack"] = "\u001B[40m";
1085
+ ConsoleColor["BgRed"] = "\u001B[41m";
1086
+ ConsoleColor["BgGreen"] = "\u001B[42m";
1087
+ ConsoleColor["BgYellow"] = "\u001B[43m";
1088
+ ConsoleColor["BgBlue"] = "\u001B[44m";
1089
+ ConsoleColor["BgMagenta"] = "\u001B[45m";
1090
+ ConsoleColor["BgCyan"] = "\u001B[46m";
1091
+ ConsoleColor["BgWhite"] = "\u001B[47m";
1092
+ ConsoleColor["BgDefault"] = "\u001B[48m";
1093
+ })(exports.ConsoleColor || (exports.ConsoleColor = {}));
1094
+ var defaultColors = {
1095
+ keyColor: exports.ConsoleColor.FgWhite,
1096
+ numberColor: exports.ConsoleColor.FgBlue,
1097
+ stringColor: exports.ConsoleColor.FgYellow,
1098
+ trueColor: exports.ConsoleColor.FgGreen,
1099
+ falseColor: exports.ConsoleColor.FgRed,
1100
+ nullColor: exports.ConsoleColor.BgMagenta
1101
+ };
1102
+ var MAX_TIMEOUT = 120000;
1103
+ function colorize(input, color) {
1104
+ return "" + color + input + exports.ConsoleColor.Reset;
1105
+ }
1106
+ function jsonHighlight(input, colorOptions) {
1107
+ var colors = Object.assign({}, defaultColors, colorOptions);
1108
+ var json = (isString(input) ? input : JSON.stringify(input, null, 2)).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
1109
+ return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+]?\d+)?)/g, function (match) {
1110
+ var color = colors.numberColor;
1111
+ if (/^"/.test(match)) {
1112
+ if (/:$/.test(match)) {
1113
+ color = colors.keyColor;
1114
+ }
1115
+ else {
1116
+ color = colors.stringColor;
1117
+ match = '"' + match.substr(1, match.length - 2) + '"';
1118
+ }
1119
+ }
1120
+ else {
1121
+ color = /true/.test(match)
1122
+ ? colors.trueColor
1123
+ : /false/.test(match)
1124
+ ? colors.falseColor
1125
+ : /null/.test(match)
1126
+ ? colors.nullColor
1127
+ : color;
1128
+ }
1129
+ return "" + color + match + exports.ConsoleColor.Reset;
1130
+ });
1062
1131
  }
1063
1132
 
1064
1133
  var __decorate$x = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -1606,15 +1675,16 @@
1606
1675
  };
1607
1676
  Asset.toImage = function (stream, meta, params) {
1608
1677
  return __awaiter$s(this, void 0, void 0, function () {
1609
- var crop, buffer, cropBefore, cropAfter, imgMeta, width, height, e_1;
1610
- return __generator(this, function (_a) {
1611
- switch (_a.label) {
1678
+ var crop, buffer, cropBefore, cropAfter, img, _a, width, height, canvasScaleX, canvasScaleY, _b, e_1;
1679
+ return __generator(this, function (_c) {
1680
+ switch (_c.label) {
1612
1681
  case 0:
1613
1682
  params = params || {};
1614
1683
  crop = Asset.toCropRegion(meta.crop);
1615
- // Return back the stream if there is no params and no default crop exists
1616
- if (Object.keys(params).length == 0 && !crop)
1684
+ // Return the stream if there is no params and no default crop exists
1685
+ if ((meta === null || meta === void 0 ? void 0 : meta.extension) === "svg" || (Object.keys(params).length == 0 && !crop)) {
1617
1686
  return [2 /*return*/, stream];
1687
+ }
1618
1688
  // Parse params
1619
1689
  params.rotation = isNaN(params.rotation) ? 0 : Math.round(params.rotation / 90) * 90;
1620
1690
  params.canvasScaleX = isNaN(params.canvasScaleX) ? 1 : Number(params.canvasScaleX);
@@ -1624,76 +1694,59 @@
1624
1694
  params.crop = isBoolean(params.crop) ? params.crop : params.crop == "true";
1625
1695
  return [4 /*yield*/, streamToBuffer(stream)];
1626
1696
  case 1:
1627
- buffer = _a.sent();
1628
- _a.label = 2;
1697
+ buffer = _c.sent();
1698
+ _c.label = 2;
1629
1699
  case 2:
1630
- _a.trys.push([2, 16, , 17]);
1700
+ _c.trys.push([2, 7, , 8]);
1631
1701
  cropBefore = Asset.toCropRegion(params.cropBefore || (params.crop ? meta.cropBefore : null));
1632
1702
  cropAfter = Asset.toCropRegion(params.cropAfter || (params.crop ? meta.cropAfter : null));
1633
- return [4 /*yield*/, sharp$2(buffer).metadata()];
1703
+ img = sharp$2(buffer);
1704
+ return [4 /*yield*/, img.metadata()];
1634
1705
  case 3:
1635
- imgMeta = _a.sent();
1636
- width = imgMeta.width;
1637
- height = imgMeta.height;
1638
- if (!cropBefore) return [3 /*break*/, 5];
1639
- return [4 /*yield*/, sharp$2(buffer)
1640
- .extract(cropBefore)
1641
- .toBuffer()];
1706
+ _a = _c.sent(), width = _a.width, height = _a.height;
1707
+ // Crop before resize
1708
+ if (cropBefore) {
1709
+ width = cropBefore.width;
1710
+ height = cropBefore.height;
1711
+ img = img.extract(cropBefore);
1712
+ }
1713
+ else if (crop) {
1714
+ width = crop.width;
1715
+ height = crop.height;
1716
+ img = img.extract(crop);
1717
+ }
1718
+ canvasScaleX = (meta === null || meta === void 0 ? void 0 : meta.canvasScaleX) || 1;
1719
+ canvasScaleY = (meta === null || meta === void 0 ? void 0 : meta.canvasScaleY) || 1;
1720
+ if (params.canvasScaleX !== canvasScaleX || params.canvasScaleY !== canvasScaleY) {
1721
+ width = Math.round(width * params.canvasScaleX);
1722
+ height = Math.round(height * params.canvasScaleY);
1723
+ img = img.resize({ width: width, height: height, background: "#00000000", fit: "contain" });
1724
+ }
1725
+ // Resize image
1726
+ if (params.scaleX !== 1 || params.scaleY !== 1) {
1727
+ width = Math.round(width * params.scaleX);
1728
+ height = Math.round(height * params.scaleY);
1729
+ img = img.resize({ width: width, height: height, background: "#00000000", fit: "fill" });
1730
+ }
1731
+ // Crop after resize
1732
+ if (cropAfter) {
1733
+ img = img.extract(cropAfter);
1734
+ }
1735
+ if (!(params.rotation !== 0)) return [3 /*break*/, 5];
1736
+ return [4 /*yield*/, img.toBuffer()];
1642
1737
  case 4:
1643
- buffer = _a.sent();
1644
- width = cropBefore.width;
1645
- height = cropBefore.height;
1646
- return [3 /*break*/, 7];
1738
+ buffer = _c.sent();
1739
+ img = sharp$2(buffer).rotate(params.rotation);
1740
+ _c.label = 5;
1647
1741
  case 5:
1648
- if (!crop) return [3 /*break*/, 7];
1649
- return [4 /*yield*/, sharp$2(buffer)
1650
- .extract(crop)
1651
- .toBuffer()];
1652
- case 6:
1653
- buffer = _a.sent();
1654
- width = crop.width;
1655
- height = crop.height;
1656
- _a.label = 7;
1742
+ _b = bufferToStream;
1743
+ return [4 /*yield*/, img.toBuffer()];
1744
+ case 6: return [2 /*return*/, _b.apply(void 0, [_c.sent()])];
1657
1745
  case 7:
1658
- if (!(params.canvasScaleX !== 1 || params.canvasScaleY !== 1)) return [3 /*break*/, 9];
1659
- width = Math.round(width * params.canvasScaleX);
1660
- height = Math.round(height * params.canvasScaleY);
1661
- return [4 /*yield*/, sharp$2(buffer)
1662
- .resize({ width: width, height: height, background: "#00000000", fit: "contain" })
1663
- .toBuffer()];
1664
- case 8:
1665
- buffer = _a.sent();
1666
- _a.label = 9;
1667
- case 9:
1668
- if (!(params.scaleX !== 1 || params.scaleY !== 1)) return [3 /*break*/, 11];
1669
- width = Math.round(width * params.scaleX);
1670
- height = Math.round(height * params.scaleY);
1671
- return [4 /*yield*/, sharp$2(buffer)
1672
- .resize({ width: width, height: height, background: "#00000000", fit: "fill" })
1673
- .toBuffer()];
1674
- case 10:
1675
- buffer = _a.sent();
1676
- _a.label = 11;
1677
- case 11:
1678
- if (!cropAfter) return [3 /*break*/, 13];
1679
- return [4 /*yield*/, sharp$2(buffer)
1680
- .extract(cropAfter)
1681
- .toBuffer()];
1682
- case 12:
1683
- buffer = _a.sent();
1684
- _a.label = 13;
1685
- case 13:
1686
- if (!(params.rotation !== 0)) return [3 /*break*/, 15];
1687
- return [4 /*yield*/, sharp$2(buffer).rotate(params.rotation).toBuffer()];
1688
- case 14:
1689
- buffer = _a.sent();
1690
- _a.label = 15;
1691
- case 15: return [2 /*return*/, bufferToStream(buffer)];
1692
- case 16:
1693
- e_1 = _a.sent();
1746
+ e_1 = _c.sent();
1694
1747
  console.log("Asset image conversion error", e_1);
1695
1748
  return [2 /*return*/, bufferToStream(buffer)];
1696
- case 17: return [2 /*return*/];
1749
+ case 8: return [2 /*return*/];
1697
1750
  }
1698
1751
  });
1699
1752
  });
@@ -2156,11 +2209,10 @@
2156
2209
  };
2157
2210
  var LazyAsset = /** @class */ (function (_super) {
2158
2211
  __extends(LazyAsset, _super);
2159
- function LazyAsset(id, data, collection, assets, progresses, jobMan) {
2212
+ function LazyAsset(id, data, collection, assets, progresses) {
2160
2213
  var _this = _super.call(this, id, data, collection) || this;
2161
2214
  _this.assets = assets;
2162
2215
  _this.progresses = progresses;
2163
- _this.jobMan = jobMan;
2164
2216
  return _this;
2165
2217
  }
2166
2218
  Object.defineProperty(LazyAsset.prototype, "jobName", {
@@ -2223,7 +2275,7 @@
2223
2275
  _this.progresses.get(_this.progressId).then(function (p) {
2224
2276
  p === null || p === void 0 ? void 0 : p.cancel();
2225
2277
  });
2226
- _this.startWorkingOnAsset().then(function () {
2278
+ _this.startWorkingOnAsset(false).then(function () {
2227
2279
  console.log("Started working on lazy asset: " + _this.id);
2228
2280
  }).catch(function (reason) {
2229
2281
  console.log("Can't start working on lazy asset: " + _this.id + "\nReason: " + reason);
@@ -2247,7 +2299,7 @@
2247
2299
  case 2:
2248
2300
  _a.sent();
2249
2301
  return [2 /*return*/, this.loadAsset()];
2250
- case 3: return [4 /*yield*/, this.startWorkingOnAsset()];
2302
+ case 3: return [4 /*yield*/, this.startWorkingOnAsset(true)];
2251
2303
  case 4:
2252
2304
  _a.sent();
2253
2305
  return [2 /*return*/, this.loadAsset()];
@@ -2269,7 +2321,7 @@
2269
2321
  });
2270
2322
  });
2271
2323
  };
2272
- LazyAsset.prototype.startWorkingOnAsset = function () {
2324
+ LazyAsset.prototype.startWorkingOnAsset = function (fromLoad) {
2273
2325
  return __awaiter$p(this, void 0, void 0, function () {
2274
2326
  var _a;
2275
2327
  return __generator(this, function (_b) {
@@ -2283,7 +2335,7 @@
2283
2335
  return [4 /*yield*/, this.save()];
2284
2336
  case 2:
2285
2337
  _b.sent();
2286
- return [4 /*yield*/, this.jobMan.enqueueWithName(this.data.jobName, Object.assign(Object.assign({}, this.data.jobParams), { lazyId: this.id }))];
2338
+ return [4 /*yield*/, this.progresses.jobMan.enqueueWithName(this.data.jobName, Object.assign(Object.assign({}, this.data.jobParams), { lazyId: this.id, fromLoad: fromLoad }))];
2287
2339
  case 3:
2288
2340
  _b.sent();
2289
2341
  return [2 /*return*/];
@@ -2330,7 +2382,6 @@
2330
2382
  step((generator = generator.apply(thisArg, _arguments || [])).next());
2331
2383
  });
2332
2384
  };
2333
- var IORedis = ioredis__default["default"];
2334
2385
  exports.JobManager = /** @class */ (function () {
2335
2386
  function JobManager(config, container, jobTypes) {
2336
2387
  var _this = this;
@@ -2338,12 +2389,25 @@
2338
2389
  this.container = container;
2339
2390
  this.jobTypes = jobTypes || [];
2340
2391
  this.jobs = this.jobTypes.reduce(function (res, jobType) {
2341
- res[getConstructorName(jobType)] = {
2342
- perform: _this.toPerformFunction(jobType)
2392
+ res[getConstructorName(jobType)] = function (jobParams) {
2393
+ var job = _this.resolveJobInstance(jobType, jobParams);
2394
+ return job.process(_this.messageBridge);
2343
2395
  };
2344
2396
  return res;
2345
2397
  }, {});
2398
+ this.messages = new rxjs.Subject();
2399
+ this.messageBridge = {
2400
+ sendMessage: function (message, params) {
2401
+ _this.workerPush.send([message, JSON.stringify(params)]);
2402
+ }
2403
+ };
2404
+ this.processing = false;
2346
2405
  }
2406
+ JobManager.prototype.on = function (message, cb) {
2407
+ return this.messages
2408
+ .pipe(operators.filter(function (t) { return t.message === message; }))
2409
+ .pipe(operators.map(function (t) { return t.params; })).subscribe(cb);
2410
+ };
2347
2411
  JobManager.prototype.process = function (jobType, params) {
2348
2412
  if (params === void 0) { params = {}; }
2349
2413
  return __awaiter$o(this, void 0, void 0, function () {
@@ -2361,82 +2425,25 @@
2361
2425
  });
2362
2426
  });
2363
2427
  };
2364
- JobManager.prototype.enqueueWithName = function (name, params, que) {
2428
+ JobManager.prototype.enqueueWithName = function (name, params) {
2365
2429
  if (params === void 0) { params = {}; }
2366
- if (que === void 0) { que = "main"; }
2367
2430
  return __awaiter$o(this, void 0, void 0, function () {
2368
- var jobName;
2369
2431
  return __generator(this, function (_a) {
2370
- switch (_a.label) {
2371
- case 0: return [4 /*yield*/, this.tryResolveFromName(name, params)];
2372
- case 1:
2373
- jobName = _a.sent();
2374
- return [4 /*yield*/, this.queue.enqueue(que, jobName, [params])];
2375
- case 2:
2376
- _a.sent();
2377
- return [2 /*return*/];
2378
- }
2432
+ return [2 /*return*/, this.sendToWorkers(this.tryResolveFromName(name, params), params)];
2379
2433
  });
2380
2434
  });
2381
2435
  };
2382
- JobManager.prototype.enqueue = function (jobType, params, que) {
2436
+ JobManager.prototype.enqueue = function (jobType, params) {
2383
2437
  if (params === void 0) { params = {}; }
2384
- if (que === void 0) { que = "main"; }
2385
2438
  return __awaiter$o(this, void 0, void 0, function () {
2386
- var jobName;
2387
2439
  return __generator(this, function (_a) {
2388
- switch (_a.label) {
2389
- case 0: return [4 /*yield*/, this.tryResolveAndConnect(jobType, params)];
2390
- case 1:
2391
- jobName = _a.sent();
2392
- return [4 /*yield*/, this.queue.enqueue(que, jobName, [params])];
2393
- case 2:
2394
- _a.sent();
2395
- return [2 /*return*/];
2396
- }
2440
+ return [2 /*return*/, this.sendToWorkers(this.tryResolveAndInit(jobType, params), params)];
2397
2441
  });
2398
2442
  });
2399
2443
  };
2400
- JobManager.prototype.enqueueAt = function (timestamp, jobType, params, que) {
2401
- if (params === void 0) { params = {}; }
2402
- if (que === void 0) { que = "main"; }
2403
- return __awaiter$o(this, void 0, void 0, function () {
2404
- var jobName;
2405
- return __generator(this, function (_a) {
2406
- switch (_a.label) {
2407
- case 0: return [4 /*yield*/, this.tryResolveAndConnect(jobType, params)];
2408
- case 1:
2409
- jobName = _a.sent();
2410
- return [4 /*yield*/, this.queue.enqueueAt(timestamp, que, jobName, [params])];
2411
- case 2:
2412
- _a.sent();
2413
- return [2 /*return*/];
2414
- }
2415
- });
2416
- });
2417
- };
2418
- JobManager.prototype.enqueueIn = function (time, jobType, params, que) {
2419
- if (params === void 0) { params = {}; }
2420
- if (que === void 0) { que = "main"; }
2421
- return __awaiter$o(this, void 0, void 0, function () {
2422
- var jobName;
2423
- return __generator(this, function (_a) {
2424
- switch (_a.label) {
2425
- case 0: return [4 /*yield*/, this.tryResolveAndConnect(jobType, params)];
2426
- case 1:
2427
- jobName = _a.sent();
2428
- return [4 /*yield*/, this.queue.enqueueIn(time, que, jobName, [params])];
2429
- case 2:
2430
- _a.sent();
2431
- return [2 /*return*/];
2432
- }
2433
- });
2434
- });
2435
- };
2436
- JobManager.prototype.schedule = function (minute, hour, dayOfMonth, month, dayOfWeek, jobType, params, que) {
2444
+ JobManager.prototype.schedule = function (minute, hour, dayOfMonth, month, dayOfWeek, jobType, params) {
2437
2445
  var _this = this;
2438
2446
  if (params === void 0) { params = {}; }
2439
- if (que === void 0) { que = "main"; }
2440
2447
  var expression = [minute, hour, dayOfMonth, month, dayOfWeek].map(function (t) {
2441
2448
  if (isObject(t)) {
2442
2449
  var range = t;
@@ -2453,29 +2460,75 @@
2453
2460
  return null;
2454
2461
  }
2455
2462
  return nodeCron.schedule(expression, function () {
2456
- _this.enqueue(jobType, params, que).catch(function (e) {
2463
+ _this.enqueue(jobType, params).catch(function (e) {
2457
2464
  console.log("Can't enqueue job: '" + jobName + "' because: " + e);
2458
2465
  });
2459
2466
  });
2460
2467
  };
2461
2468
  JobManager.prototype.startProcessing = function () {
2462
2469
  return __awaiter$o(this, void 0, void 0, function () {
2470
+ var host, pushHost, pullHost;
2471
+ var _this = this;
2463
2472
  return __generator(this, function (_a) {
2464
2473
  switch (_a.label) {
2465
2474
  case 0:
2466
- this.initialize();
2467
- return [4 /*yield*/, this.worker.connect()];
2475
+ if (this.processing)
2476
+ return [2 /*return*/, null];
2477
+ this.processing = true;
2478
+ if (!this.config.resolve("isWorker")) {
2479
+ console.log(colorize("Processing can not be started because this is NOT a worker process!", exports.ConsoleColor.FgRed));
2480
+ return [2 /*return*/, null];
2481
+ }
2482
+ host = this.config.resolve("zmqRemoteHost");
2483
+ pushHost = host + ":" + this.config.resolve("zmqBackPort");
2484
+ this.workerPush = zeromq.socket("push");
2485
+ return [4 /*yield*/, this.workerPush.connect(pushHost)];
2468
2486
  case 1:
2469
2487
  _a.sent();
2470
- return [4 /*yield*/, this.worker.start()];
2488
+ console.log("Worker producer connected to: " + pushHost);
2489
+ pullHost = host + ":" + this.config.resolve("zmqPort");
2490
+ this.workerPull = zeromq.socket("pull");
2491
+ return [4 /*yield*/, this.workerPull.connect(pullHost)];
2471
2492
  case 2:
2472
2493
  _a.sent();
2473
- return [4 /*yield*/, this.scheduler.connect()];
2474
- case 3:
2475
- _a.sent();
2476
- return [4 /*yield*/, this.scheduler.start()];
2477
- case 4:
2478
- _a.sent();
2494
+ console.log("Worker consumer connected to: " + pullHost);
2495
+ this.workerPull.on("message", function (name, args, uniqueId) { return __awaiter$o(_this, void 0, void 0, function () {
2496
+ var jobName, jobParams, timerId, jobNameLog, jobArgsLog, e_1, e_2;
2497
+ return __generator(this, function (_a) {
2498
+ switch (_a.label) {
2499
+ case 0:
2500
+ _a.trys.push([0, 5, , 6]);
2501
+ jobName = name.toString("utf8");
2502
+ jobParams = JSON.parse(args.toString("utf8"));
2503
+ timerId = uniqueId === null || uniqueId === void 0 ? void 0 : uniqueId.toString("utf8");
2504
+ jobNameLog = "\u001B[36m\"" + jobName + "\"\u001B[0m";
2505
+ jobArgsLog = "\n" + jsonHighlight(jobParams);
2506
+ console.time(timerId);
2507
+ console.timeLog(timerId, "Started working on background job: " + jobNameLog + " with args: " + jobArgsLog + "\n\n");
2508
+ this.messageBridge.sendMessage("job-started", { name: jobName });
2509
+ _a.label = 1;
2510
+ case 1:
2511
+ _a.trys.push([1, 3, , 4]);
2512
+ return [4 /*yield*/, Promise.race([this.jobs[jobName](jobParams), promiseTimeout(MAX_TIMEOUT, true)])];
2513
+ case 2:
2514
+ _a.sent();
2515
+ console.timeLog(timerId, "Finished working on background job: " + jobNameLog + "\n\n");
2516
+ return [3 /*break*/, 4];
2517
+ case 3:
2518
+ e_1 = _a.sent();
2519
+ console.timeLog(timerId, "Background job failed: " + jobNameLog + "\n" + e_1.message + "\n\n");
2520
+ return [3 /*break*/, 4];
2521
+ case 4:
2522
+ console.timeEnd(timerId);
2523
+ return [3 /*break*/, 6];
2524
+ case 5:
2525
+ e_2 = _a.sent();
2526
+ console.log("Failed to start job: " + e_2.message);
2527
+ return [3 /*break*/, 6];
2528
+ case 6: return [2 /*return*/];
2529
+ }
2530
+ });
2531
+ }); });
2479
2532
  return [2 /*return*/];
2480
2533
  }
2481
2534
  });
@@ -2494,47 +2547,6 @@
2494
2547
  }
2495
2548
  return jobName;
2496
2549
  };
2497
- JobManager.prototype.initialize = function () {
2498
- if (this.queue)
2499
- return;
2500
- var config = this.config;
2501
- var options = { password: config.resolve("redisPassword") };
2502
- var sentinels = config.resolve("redisSentinels");
2503
- var redis = !sentinels
2504
- ? null
2505
- : new IORedis({
2506
- sentinels: sentinels,
2507
- name: config.resolve("redisCluster"),
2508
- });
2509
- var connection = {
2510
- pkg: "ioredis",
2511
- host: config.resolve("redisHost"),
2512
- password: options.password,
2513
- port: config.resolve("redisPort"),
2514
- namespace: config.resolve("redisNamespace"),
2515
- redis: redis,
2516
- options: options
2517
- };
2518
- var queues = config.resolve("workQueues");
2519
- this.queue = new nodeResque.Queue({ connection: connection }, this.jobs);
2520
- this.worker = new nodeResque.Worker({ connection: connection, queues: queues }, this.jobs);
2521
- this.worker.on("job", function (queue, job) {
2522
- console.log("working job " + queue + " " + JSON.stringify(job));
2523
- });
2524
- this.worker.on("reEnqueue", function (queue, job, plugin) {
2525
- console.log("reEnqueue job (" + plugin + ") " + queue + " " + JSON.stringify(job));
2526
- });
2527
- this.worker.on("success", function (queue, job, result, duration) {
2528
- console.log("job success " + queue + " " + JSON.stringify(job) + " >> " + result + " (" + duration + "ms)");
2529
- });
2530
- this.worker.on("failure", function (queue, job, failure, duration) {
2531
- console.log("job failure " + queue + " " + JSON.stringify(job) + " >> " + failure + " (" + duration + "ms)");
2532
- });
2533
- this.worker.on("error", function (error, queue, job) {
2534
- console.log("error " + queue + " " + JSON.stringify(job) + " >> " + error);
2535
- });
2536
- this.scheduler = new nodeResque.Scheduler({ connection: connection }, this.jobs);
2537
- };
2538
2550
  JobManager.prototype.tryResolveFromName = function (jobName, params) {
2539
2551
  var jobType = this.jobTypes.find(function (type) {
2540
2552
  return getConstructorName(type) == jobName;
@@ -2542,23 +2554,29 @@
2542
2554
  if (!jobType) {
2543
2555
  throw "Can't find job type with name: " + jobName + " so it can't be enqueued!";
2544
2556
  }
2545
- return this.tryResolveAndConnect(jobType, params);
2557
+ return this.tryResolveAndInit(jobType, params);
2546
2558
  };
2547
- JobManager.prototype.tryResolveAndConnect = function (jobType, params) {
2548
- return __awaiter$o(this, void 0, void 0, function () {
2549
- var jobName;
2550
- return __generator(this, function (_a) {
2551
- switch (_a.label) {
2552
- case 0:
2553
- this.initialize();
2554
- jobName = this.tryResolve(jobType, params);
2555
- return [4 /*yield*/, this.queue.connect()];
2556
- case 1:
2557
- _a.sent();
2558
- return [2 /*return*/, jobName];
2559
- }
2559
+ JobManager.prototype.tryResolveAndInit = function (jobType, params) {
2560
+ var _this = this;
2561
+ if (!this.apiPush) {
2562
+ var port = this.config.resolve("zmqPort");
2563
+ this.apiPush = zeromq.socket("push");
2564
+ this.apiPush.bind("tcp://0.0.0.0:" + port);
2565
+ console.log("API producer bound to port: " + port);
2566
+ }
2567
+ if (!this.apiPull) {
2568
+ var backPort = this.config.resolve("zmqBackPort");
2569
+ this.apiPull = zeromq.socket("pull");
2570
+ this.apiPull.bind("tcp://0.0.0.0:" + backPort);
2571
+ this.apiPull.on("message", function (name, args) {
2572
+ var message = name.toString("utf8");
2573
+ var params = JSON.parse((args === null || args === void 0 ? void 0 : args.toString("utf8")) || "{}");
2574
+ console.log("Received a message from worker: \"" + colorize(message, exports.ConsoleColor.FgCyan) + "\" with args: " + jsonHighlight(params) + "\n\n");
2575
+ _this.messages.next({ message: message, params: params });
2560
2576
  });
2561
- });
2577
+ console.log("API consumer bound to port: " + backPort);
2578
+ }
2579
+ return this.tryResolve(jobType, params);
2562
2580
  };
2563
2581
  JobManager.prototype.resolveJobInstance = function (jobType, params) {
2564
2582
  var container = this.container.createChildContainer();
@@ -2568,12 +2586,21 @@
2568
2586
  container.register(jobType, jobType);
2569
2587
  return container.resolve(jobType);
2570
2588
  };
2571
- JobManager.prototype.toPerformFunction = function (jobType) {
2572
- var _this = this;
2573
- return function (jobParams) {
2574
- var job = _this.resolveJobInstance(jobType, jobParams);
2575
- return job.process();
2576
- };
2589
+ JobManager.prototype.sendToWorkers = function (jobName, params) {
2590
+ return __awaiter$o(this, void 0, void 0, function () {
2591
+ var publisher;
2592
+ return __generator(this, function (_a) {
2593
+ switch (_a.label) {
2594
+ case 0: return [4 /*yield*/, this.apiPush];
2595
+ case 1:
2596
+ publisher = _a.sent();
2597
+ return [4 /*yield*/, publisher.send([jobName, JSON.stringify(params), new bson.ObjectId().toHexString()])];
2598
+ case 2:
2599
+ _a.sent();
2600
+ return [2 /*return*/];
2601
+ }
2602
+ });
2603
+ });
2577
2604
  };
2578
2605
  return JobManager;
2579
2606
  }());
@@ -2605,10 +2632,8 @@
2605
2632
  };
2606
2633
  var Progress = /** @class */ (function (_super) {
2607
2634
  __extends(Progress, _super);
2608
- function Progress(id, data, collection, client) {
2609
- var _this = _super.call(this, id, data, collection) || this;
2610
- _this.client = client;
2611
- return _this;
2635
+ function Progress(id, data, collection) {
2636
+ return _super.call(this, id, data, collection) || this;
2612
2637
  }
2613
2638
  Object.defineProperty(Progress.prototype, "current", {
2614
2639
  get: function () {
@@ -2659,6 +2684,10 @@
2659
2684
  enumerable: false,
2660
2685
  configurable: true
2661
2686
  });
2687
+ Progress.prototype.setMessageBridge = function (messageBridge) {
2688
+ this.messageBridge = messageBridge || this.messageBridge;
2689
+ return this;
2690
+ };
2662
2691
  Progress.prototype.createSubProgress = function (progressValue, max, message) {
2663
2692
  return __awaiter$n(this, void 0, void 0, function () {
2664
2693
  return __generator(this, function (_a) {
@@ -2744,9 +2773,6 @@
2744
2773
  return [4 /*yield*/, this.save()];
2745
2774
  case 2:
2746
2775
  _a.sent();
2747
- if (!this.client)
2748
- return [2 /*return*/];
2749
- this.client.emit("background-progress", this.id);
2750
2776
  return [2 /*return*/];
2751
2777
  }
2752
2778
  });
@@ -2766,6 +2792,12 @@
2766
2792
  });
2767
2793
  });
2768
2794
  };
2795
+ Progress.prototype.save = function () {
2796
+ if (this.messageBridge) {
2797
+ this.messageBridge.sendMessage("progress-changed", this.toJSON());
2798
+ }
2799
+ return _super.prototype.save.call(this);
2800
+ };
2769
2801
  return Progress;
2770
2802
  }(BaseEntity));
2771
2803
  var SubProgress = /** @class */ (function () {
@@ -2839,6 +2871,12 @@
2839
2871
  enumerable: false,
2840
2872
  configurable: true
2841
2873
  });
2874
+ SubProgress.prototype.setMessageBridge = function (messageBridge) {
2875
+ if (!this.parent)
2876
+ return this;
2877
+ this.parent.setMessageBridge(messageBridge);
2878
+ return this;
2879
+ };
2842
2880
  SubProgress.prototype.createSubProgress = function (progressValue, max, message) {
2843
2881
  return __awaiter$n(this, void 0, void 0, function () {
2844
2882
  return __generator(this, function (_a) {
@@ -3005,44 +3043,48 @@
3005
3043
  step((generator = generator.apply(thisArg, _arguments || [])).next());
3006
3044
  });
3007
3045
  };
3008
- var socketIOClient = socket_io_client__default["default"];
3009
3046
  exports.Progresses = /** @class */ (function () {
3010
- function Progresses(connector, config) {
3047
+ function Progresses(connector, jobMan) {
3048
+ var _this = this;
3011
3049
  this.connector = connector;
3012
- this.config = config;
3013
- var mainEndpoint = this.config.resolve("mainEndpoint");
3014
- this.client = !mainEndpoint ? null : socketIOClient(mainEndpoint, { path: "/socket" });
3050
+ this.jobMan = jobMan;
3015
3051
  this.collection = connector.database.collection("progresses");
3052
+ this.progresses = {};
3053
+ this.jobMan.on("progress-changed", function (progress) {
3054
+ var id = progress.id;
3055
+ _this.progresses[id] = new Progress(new bson.ObjectId(id), progress, _this.collection);
3056
+ });
3016
3057
  }
3017
3058
  Progresses.prototype.waitToFinish = function (id) {
3018
3059
  return __awaiter$m(this, void 0, void 0, function () {
3019
- var isFinished, progress;
3060
+ var _this = this;
3020
3061
  return __generator(this, function (_a) {
3021
- switch (_a.label) {
3022
- case 0:
3023
- isFinished = false;
3024
- progress = null;
3025
- _a.label = 1;
3026
- case 1:
3027
- if (!!isFinished) return [3 /*break*/, 5];
3028
- return [4 /*yield*/, this.get(id)];
3029
- case 2:
3030
- progress = _a.sent();
3031
- if (!progress) {
3032
- throw "Progress does not exists with id: " + id;
3033
- }
3034
- if (progress.error) {
3035
- throw progress.error;
3036
- }
3037
- isFinished = progress.percent == 100;
3038
- if (!!isFinished) return [3 /*break*/, 4];
3039
- return [4 /*yield*/, promiseTimeout(50)];
3040
- case 3:
3041
- _a.sent();
3042
- _a.label = 4;
3043
- case 4: return [3 /*break*/, 1];
3044
- case 5: return [2 /*return*/, progress];
3045
- }
3062
+ return [2 /*return*/, Promise.race([
3063
+ this.waitForProgress(id, function () { return __awaiter$m(_this, void 0, void 0, function () {
3064
+ var progress;
3065
+ return __generator(this, function (_a) {
3066
+ switch (_a.label) {
3067
+ case 0:
3068
+ progress = this.progresses[id];
3069
+ if (!(!progress || progress.percent < 100)) return [3 /*break*/, 2];
3070
+ return [4 /*yield*/, this.get(id)];
3071
+ case 1:
3072
+ progress = _a.sent();
3073
+ _a.label = 2;
3074
+ case 2:
3075
+ if (!progress) {
3076
+ throw new Error("Progress does not exists with id: " + id);
3077
+ }
3078
+ return [2 /*return*/, progress];
3079
+ }
3080
+ });
3081
+ }); }, 500),
3082
+ this.waitForProgress(id, function () { return __awaiter$m(_this, void 0, void 0, function () {
3083
+ return __generator(this, function (_a) {
3084
+ return [2 /*return*/, this.progresses[id] || null];
3085
+ });
3086
+ }); }, 25)
3087
+ ])];
3046
3088
  });
3047
3089
  });
3048
3090
  };
@@ -3061,7 +3103,7 @@
3061
3103
  case 0: return [4 /*yield*/, this.collection.findOne(where)];
3062
3104
  case 1:
3063
3105
  data = _a.sent();
3064
- return [2 /*return*/, !data ? null : new Progress(data._id, data, this.collection, this.client)];
3106
+ return [2 /*return*/, !data ? null : new Progress(data._id, data, this.collection)];
3065
3107
  }
3066
3108
  });
3067
3109
  });
@@ -3074,7 +3116,7 @@
3074
3116
  switch (_a.label) {
3075
3117
  case 0:
3076
3118
  if (isNaN(max) || max <= 0) {
3077
- throw "Max progress value must be bigger than zero";
3119
+ throw new Error("Max progress value must be bigger than zero");
3078
3120
  }
3079
3121
  data = {
3080
3122
  current: 0,
@@ -3086,7 +3128,7 @@
3086
3128
  return [4 /*yield*/, this.collection.insertOne(data)];
3087
3129
  case 1:
3088
3130
  res = _a.sent();
3089
- return [2 /*return*/, new Progress(res.insertedId, data, this.collection, this.client)];
3131
+ return [2 /*return*/, new Progress(res.insertedId, data, this.collection)];
3090
3132
  }
3091
3133
  });
3092
3134
  });
@@ -3103,12 +3145,48 @@
3103
3145
  });
3104
3146
  });
3105
3147
  };
3148
+ Progresses.prototype.waitForProgress = function (id, cb, delay) {
3149
+ return __awaiter$m(this, void 0, void 0, function () {
3150
+ var isFinished, progress, waitTime;
3151
+ return __generator(this, function (_a) {
3152
+ switch (_a.label) {
3153
+ case 0:
3154
+ isFinished = false;
3155
+ progress = null;
3156
+ waitTime = 0;
3157
+ _a.label = 1;
3158
+ case 1:
3159
+ if (!!isFinished) return [3 /*break*/, 5];
3160
+ return [4 /*yield*/, cb()];
3161
+ case 2:
3162
+ progress = _a.sent();
3163
+ waitTime += delay;
3164
+ if (progress) {
3165
+ if (progress.error) {
3166
+ throw new Error(progress.error);
3167
+ }
3168
+ isFinished = progress.percent >= 100;
3169
+ }
3170
+ if (!!isFinished) return [3 /*break*/, 4];
3171
+ if (waitTime >= MAX_TIMEOUT) {
3172
+ throw new Error("Progress with id: " + id + " probably never will be finished!");
3173
+ }
3174
+ return [4 /*yield*/, promiseTimeout(delay)];
3175
+ case 3:
3176
+ _a.sent();
3177
+ _a.label = 4;
3178
+ case 4: return [3 /*break*/, 1];
3179
+ case 5: return [2 /*return*/, progress];
3180
+ }
3181
+ });
3182
+ });
3183
+ };
3106
3184
  return Progresses;
3107
3185
  }());
3108
3186
  exports.Progresses = __decorate$r([
3109
3187
  tsyringe.injectable(),
3110
3188
  tsyringe.singleton(),
3111
- __metadata$l("design:paramtypes", [exports.MongoConnector, exports.Configuration])
3189
+ __metadata$l("design:paramtypes", [exports.MongoConnector, exports.JobManager])
3112
3190
  ], exports.Progresses);
3113
3191
 
3114
3192
  var __decorate$q = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -3174,7 +3252,7 @@
3174
3252
  return [4 /*yield*/, this.collection.insertOne(data)];
3175
3253
  case 2:
3176
3254
  res = _a.sent();
3177
- return [2 /*return*/, new LazyAsset(res.insertedId, data, this.collection, this.assets, this.progresses, this.jobMan)];
3255
+ return [2 /*return*/, new LazyAsset(res.insertedId, data, this.collection, this.assets, this.progresses)];
3178
3256
  }
3179
3257
  });
3180
3258
  });
@@ -3196,7 +3274,7 @@
3196
3274
  data = _a.sent();
3197
3275
  return [2 /*return*/, !data
3198
3276
  ? null
3199
- : new LazyAsset(data._id, data, this.collection, this.assets, this.progresses, this.jobMan)];
3277
+ : new LazyAsset(data._id, data, this.collection, this.assets, this.progresses)];
3200
3278
  }
3201
3279
  });
3202
3280
  });
@@ -3221,8 +3299,10 @@
3221
3299
  exports.LazyAssets = __decorate$q([
3222
3300
  tsyringe.injectable(),
3223
3301
  tsyringe.scoped(tsyringe.Lifecycle.ContainerScoped),
3224
- __metadata$k("design:paramtypes", [exports.MongoConnector, exports.Assets,
3225
- exports.Progresses, exports.JobManager])
3302
+ __metadata$k("design:paramtypes", [exports.MongoConnector,
3303
+ exports.Assets,
3304
+ exports.Progresses,
3305
+ exports.JobManager])
3226
3306
  ], exports.LazyAssets);
3227
3307
 
3228
3308
  var __decorate$p = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -4729,7 +4809,9 @@
4729
4809
  case 0: return [4 /*yield*/, this.getAsset("Image", id, params.lazy, res)];
4730
4810
  case 1:
4731
4811
  asset = _c.sent();
4732
- params.rotation = params.rotation || rotation;
4812
+ if (rotation !== 0) {
4813
+ params.rotation = params.rotation || rotation;
4814
+ }
4733
4815
  return [2 /*return*/, asset.downloadImage(params)];
4734
4816
  }
4735
4817
  });
@@ -5717,7 +5799,7 @@
5717
5799
  enumerable: false,
5718
5800
  configurable: true
5719
5801
  });
5720
- LazyAssetGenerator.prototype.process = function () {
5802
+ LazyAssetGenerator.prototype.process = function (messaging) {
5721
5803
  return __awaiter$1(this, void 0, void 0, function () {
5722
5804
  var lazyAsset, progress, asset, e_1;
5723
5805
  return __generator(this, function (_a) {
@@ -5730,10 +5812,11 @@
5730
5812
  progress = _a.sent();
5731
5813
  if (!progress || progress.canceled)
5732
5814
  return [2 /*return*/, null];
5815
+ progress.setMessageBridge(messaging);
5733
5816
  _a.label = 3;
5734
5817
  case 3:
5735
5818
  _a.trys.push([3, 7, , 9]);
5736
- return [4 /*yield*/, this.generate(progress)];
5819
+ return [4 /*yield*/, this.generate(progress, messaging)];
5737
5820
  case 4:
5738
5821
  asset = _a.sent();
5739
5822
  return [4 /*yield*/, progress.load()];
@@ -5833,20 +5916,9 @@
5833
5916
  new Parameter("mongoPassword", null),
5834
5917
  new Parameter("nodeEnv", "development"),
5835
5918
  new Parameter("appPort", 80),
5836
- new Parameter("redisHost", "127.0.0.1"),
5837
- new Parameter("redisPort", 6379),
5838
- new Parameter("redisPassword", "123456"),
5839
- new Parameter("redisNamespace", "resque"),
5840
- new Parameter("redisCluster", "mymaster"),
5841
- new Parameter("redisSentinels", null, function (value) {
5842
- if (!value)
5843
- return null;
5844
- return value.split(", ").map(function (item) {
5845
- var values = item.split(":");
5846
- return { host: values[0], port: Number(values[1]) };
5847
- });
5848
- }),
5849
- new Parameter("workQueues", ["main"]),
5919
+ new Parameter("zmqPort", 3000),
5920
+ new Parameter("zmqBackPort", 3100),
5921
+ new Parameter("zmqRemoteHost", "tcp://127.0.0.1"),
5850
5922
  new Parameter("isWorker", false),
5851
5923
  new Parameter("mainEndpoint", ""),
5852
5924
  new Parameter("idChars", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
@@ -6104,6 +6176,7 @@
6104
6176
  exports.assign = assign;
6105
6177
  exports.broadcast = broadcast;
6106
6178
  exports.bufferToStream = bufferToStream;
6179
+ exports.colorize = colorize;
6107
6180
  exports.convertValue = convertValue;
6108
6181
  exports.copy = copy;
6109
6182
  exports.copyStream = copyStream;
@@ -6135,6 +6208,7 @@
6135
6208
  exports.isPrimitive = isPrimitive;
6136
6209
  exports.isString = isString;
6137
6210
  exports.isType = isType;
6211
+ exports.jsonHighlight = jsonHighlight;
6138
6212
  exports.lastItem = lastItem;
6139
6213
  exports.lcFirst = lcFirst;
6140
6214
  exports.lookupPipelines = lookupPipelines;