@stemy/backend 3.0.1 → 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.
- package/bundles/stemy-backend.umd.js +226 -144
- package/bundles/stemy-backend.umd.js.map +1 -1
- package/bundles/stemy-backend.umd.min.js +1 -1
- package/bundles/stemy-backend.umd.min.js.map +1 -1
- package/common-types.d.ts +13 -4
- package/esm2015/common-types.js +1 -1
- package/esm2015/public_api.js +5 -4
- package/esm2015/services/entities/lazy-asset.js +3 -4
- package/esm2015/services/entities/progress.js +18 -6
- package/esm2015/services/job-manager.js +83 -47
- package/esm2015/services/lazy-assets.js +7 -5
- package/esm2015/services/progresses.js +54 -30
- package/esm2015/utilities/lazy-asset-generator.js +4 -3
- package/esm2015/utils.js +5 -1
- package/fesm2015/stemy-backend.js +166 -88
- package/fesm2015/stemy-backend.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +2 -2
- package/services/entities/lazy-asset.d.ts +1 -3
- package/services/entities/progress.d.ts +6 -4
- package/services/job-manager.d.ts +15 -8
- package/services/progresses.d.ts +9 -7
- package/stemy-backend.metadata.json +1 -1
- package/utilities/lazy-asset-generator.d.ts +3 -3
- package/utils.d.ts +2 -0
|
@@ -25,7 +25,7 @@ import { GridFSBucket } from 'mongodb';
|
|
|
25
25
|
import dotenv from 'dotenv';
|
|
26
26
|
import { validate, schedule } from 'node-cron';
|
|
27
27
|
import { socket } from 'zeromq';
|
|
28
|
-
import
|
|
28
|
+
import { filter as filter$1, map } from 'rxjs/operators';
|
|
29
29
|
import { createServer } from 'http';
|
|
30
30
|
import express_, { static as static$1 } from 'express';
|
|
31
31
|
import socket_io from 'socket.io';
|
|
@@ -680,6 +680,10 @@ const defaultColors = {
|
|
|
680
680
|
falseColor: ConsoleColor.FgRed,
|
|
681
681
|
nullColor: ConsoleColor.BgMagenta
|
|
682
682
|
};
|
|
683
|
+
const MAX_TIMEOUT = 120000;
|
|
684
|
+
function colorize(input, color) {
|
|
685
|
+
return `${color}${input}${ConsoleColor.Reset}`;
|
|
686
|
+
}
|
|
683
687
|
function jsonHighlight(input, colorOptions) {
|
|
684
688
|
const colors = Object.assign({}, defaultColors, colorOptions);
|
|
685
689
|
const json = (isString(input) ? input : JSON.stringify(input, null, 2)).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
@@ -1459,11 +1463,10 @@ var __awaiter$p = (this && this.__awaiter) || function (thisArg, _arguments, P,
|
|
|
1459
1463
|
});
|
|
1460
1464
|
};
|
|
1461
1465
|
class LazyAsset extends BaseEntity {
|
|
1462
|
-
constructor(id, data, collection, assets, progresses
|
|
1466
|
+
constructor(id, data, collection, assets, progresses) {
|
|
1463
1467
|
super(id, data, collection);
|
|
1464
1468
|
this.assets = assets;
|
|
1465
1469
|
this.progresses = progresses;
|
|
1466
|
-
this.jobMan = jobMan;
|
|
1467
1470
|
}
|
|
1468
1471
|
get jobName() {
|
|
1469
1472
|
return this.data.jobName;
|
|
@@ -1531,7 +1534,7 @@ class LazyAsset extends BaseEntity {
|
|
|
1531
1534
|
this.data.progressId = (yield this.progresses.create()).id;
|
|
1532
1535
|
this.data.assetId = null;
|
|
1533
1536
|
yield this.save();
|
|
1534
|
-
yield this.jobMan.enqueueWithName(this.data.jobName, Object.assign(Object.assign({}, this.data.jobParams), { lazyId: this.id, fromLoad }));
|
|
1537
|
+
yield this.progresses.jobMan.enqueueWithName(this.data.jobName, Object.assign(Object.assign({}, this.data.jobParams), { lazyId: this.id, fromLoad }));
|
|
1535
1538
|
});
|
|
1536
1539
|
}
|
|
1537
1540
|
}
|
|
@@ -1565,10 +1568,22 @@ let JobManager = class JobManager {
|
|
|
1565
1568
|
this.jobs = this.jobTypes.reduce((res, jobType) => {
|
|
1566
1569
|
res[getConstructorName(jobType)] = (jobParams) => {
|
|
1567
1570
|
const job = this.resolveJobInstance(jobType, jobParams);
|
|
1568
|
-
return job.process();
|
|
1571
|
+
return job.process(this.messageBridge);
|
|
1569
1572
|
};
|
|
1570
1573
|
return res;
|
|
1571
1574
|
}, {});
|
|
1575
|
+
this.messages = new Subject();
|
|
1576
|
+
this.messageBridge = {
|
|
1577
|
+
sendMessage: (message, params) => {
|
|
1578
|
+
this.workerPush.send([message, JSON.stringify(params)]);
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
this.processing = false;
|
|
1582
|
+
}
|
|
1583
|
+
on(message, cb) {
|
|
1584
|
+
return this.messages
|
|
1585
|
+
.pipe(filter$1(t => t.message === message))
|
|
1586
|
+
.pipe(map(t => t.params)).subscribe(cb);
|
|
1572
1587
|
}
|
|
1573
1588
|
process(jobType, params = {}) {
|
|
1574
1589
|
return __awaiter$o(this, void 0, void 0, function* () {
|
|
@@ -1585,20 +1600,12 @@ let JobManager = class JobManager {
|
|
|
1585
1600
|
}
|
|
1586
1601
|
enqueueWithName(name, params = {}) {
|
|
1587
1602
|
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1588
|
-
|
|
1589
|
-
return this.sendToWorkers(jobName, params);
|
|
1603
|
+
return this.sendToWorkers(this.tryResolveFromName(name, params), params);
|
|
1590
1604
|
});
|
|
1591
1605
|
}
|
|
1592
1606
|
enqueue(jobType, params = {}) {
|
|
1593
1607
|
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1594
|
-
|
|
1595
|
-
return this.sendToWorkers(jobName, params);
|
|
1596
|
-
});
|
|
1597
|
-
}
|
|
1598
|
-
sendToWorkers(jobName, params) {
|
|
1599
|
-
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1600
|
-
const publisher = yield this.scheduler;
|
|
1601
|
-
yield publisher.send([jobName, JSON.stringify(params), new ObjectId().toHexString()]);
|
|
1608
|
+
return this.sendToWorkers(this.tryResolveAndInit(jobType, params), params);
|
|
1602
1609
|
});
|
|
1603
1610
|
}
|
|
1604
1611
|
schedule(minute, hour, dayOfMonth, month, dayOfWeek, jobType, params = {}) {
|
|
@@ -1624,32 +1631,47 @@ let JobManager = class JobManager {
|
|
|
1624
1631
|
});
|
|
1625
1632
|
}
|
|
1626
1633
|
startProcessing() {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1634
|
+
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1635
|
+
if (this.processing)
|
|
1636
|
+
return null;
|
|
1637
|
+
this.processing = true;
|
|
1638
|
+
if (!this.config.resolve("isWorker")) {
|
|
1639
|
+
console.log(colorize(`Processing can not be started because this is NOT a worker process!`, ConsoleColor.FgRed));
|
|
1640
|
+
return null;
|
|
1641
|
+
}
|
|
1642
|
+
const host = this.config.resolve("zmqRemoteHost");
|
|
1643
|
+
const pushHost = `${host}:${this.config.resolve("zmqBackPort")}`;
|
|
1644
|
+
this.workerPush = socket("push");
|
|
1645
|
+
yield this.workerPush.connect(pushHost);
|
|
1646
|
+
console.log(`Worker producer connected to: ${pushHost}`);
|
|
1647
|
+
const pullHost = `${host}:${this.config.resolve("zmqPort")}`;
|
|
1648
|
+
this.workerPull = socket("pull");
|
|
1649
|
+
yield this.workerPull.connect(pullHost);
|
|
1650
|
+
console.log(`Worker consumer connected to: ${pullHost}`);
|
|
1651
|
+
this.workerPull.on("message", (name, args, uniqueId) => __awaiter$o(this, void 0, void 0, function* () {
|
|
1639
1652
|
try {
|
|
1640
|
-
|
|
1641
|
-
|
|
1653
|
+
const jobName = name.toString("utf8");
|
|
1654
|
+
const jobParams = JSON.parse(args.toString("utf8"));
|
|
1655
|
+
const timerId = uniqueId === null || uniqueId === void 0 ? void 0 : uniqueId.toString("utf8");
|
|
1656
|
+
const jobNameLog = `\x1b[36m"${jobName}"\x1b[0m`;
|
|
1657
|
+
const jobArgsLog = `\n${jsonHighlight(jobParams)}`;
|
|
1658
|
+
console.time(timerId);
|
|
1659
|
+
console.timeLog(timerId, `Started working on background job: ${jobNameLog} with args: ${jobArgsLog}\n\n`);
|
|
1660
|
+
this.messageBridge.sendMessage(`job-started`, { name: jobName });
|
|
1661
|
+
try {
|
|
1662
|
+
yield Promise.race([this.jobs[jobName](jobParams), promiseTimeout(MAX_TIMEOUT, true)]);
|
|
1663
|
+
console.timeLog(timerId, `Finished working on background job: ${jobNameLog}\n\n`);
|
|
1664
|
+
}
|
|
1665
|
+
catch (e) {
|
|
1666
|
+
console.timeLog(timerId, `Background job failed: ${jobNameLog}\n${e.message}\n\n`);
|
|
1667
|
+
}
|
|
1668
|
+
console.timeEnd(timerId);
|
|
1642
1669
|
}
|
|
1643
1670
|
catch (e) {
|
|
1644
|
-
console.
|
|
1671
|
+
console.log(`Failed to start job: ${e.message}`);
|
|
1645
1672
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
catch (e) {
|
|
1649
|
-
console.log(`Failed to start job: ${e.message}`);
|
|
1650
|
-
}
|
|
1651
|
-
}));
|
|
1652
|
-
console.log(`Waiting for jobs at: ${host}`);
|
|
1673
|
+
}));
|
|
1674
|
+
});
|
|
1653
1675
|
}
|
|
1654
1676
|
tryResolve(jobType, params) {
|
|
1655
1677
|
const jobName = getConstructorName(jobType);
|
|
@@ -1671,19 +1693,28 @@ let JobManager = class JobManager {
|
|
|
1671
1693
|
if (!jobType) {
|
|
1672
1694
|
throw `Can't find job type with name: ${jobName} so it can't be enqueued!`;
|
|
1673
1695
|
}
|
|
1674
|
-
return this.
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1696
|
+
return this.tryResolveAndInit(jobType, params);
|
|
1697
|
+
}
|
|
1698
|
+
tryResolveAndInit(jobType, params) {
|
|
1699
|
+
if (!this.apiPush) {
|
|
1700
|
+
const port = this.config.resolve("zmqPort");
|
|
1701
|
+
this.apiPush = socket("push");
|
|
1702
|
+
this.apiPush.bind(`tcp://0.0.0.0:${port}`);
|
|
1703
|
+
console.log(`API producer bound to port: ${port}`);
|
|
1704
|
+
}
|
|
1705
|
+
if (!this.apiPull) {
|
|
1706
|
+
const backPort = this.config.resolve("zmqBackPort");
|
|
1707
|
+
this.apiPull = socket("pull");
|
|
1708
|
+
this.apiPull.bind(`tcp://0.0.0.0:${backPort}`);
|
|
1709
|
+
this.apiPull.on("message", (name, args) => {
|
|
1710
|
+
const message = name.toString("utf8");
|
|
1711
|
+
const params = JSON.parse((args === null || args === void 0 ? void 0 : args.toString("utf8")) || "{}");
|
|
1712
|
+
console.log(`Received a message from worker: "${colorize(message, ConsoleColor.FgCyan)}" with args: ${jsonHighlight(params)}\n\n`);
|
|
1713
|
+
this.messages.next({ message, params });
|
|
1714
|
+
});
|
|
1715
|
+
console.log(`API consumer bound to port: ${backPort}`);
|
|
1716
|
+
}
|
|
1717
|
+
return this.tryResolve(jobType, params);
|
|
1687
1718
|
}
|
|
1688
1719
|
resolveJobInstance(jobType, params) {
|
|
1689
1720
|
const container = this.container.createChildContainer();
|
|
@@ -1693,6 +1724,12 @@ let JobManager = class JobManager {
|
|
|
1693
1724
|
container.register(jobType, jobType);
|
|
1694
1725
|
return container.resolve(jobType);
|
|
1695
1726
|
}
|
|
1727
|
+
sendToWorkers(jobName, params) {
|
|
1728
|
+
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1729
|
+
const publisher = yield this.apiPush;
|
|
1730
|
+
yield publisher.send([jobName, JSON.stringify(params), new ObjectId().toHexString()]);
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1696
1733
|
};
|
|
1697
1734
|
JobManager = __decorate$s([
|
|
1698
1735
|
injectable(),
|
|
@@ -1711,9 +1748,8 @@ var __awaiter$n = (this && this.__awaiter) || function (thisArg, _arguments, P,
|
|
|
1711
1748
|
});
|
|
1712
1749
|
};
|
|
1713
1750
|
class Progress extends BaseEntity {
|
|
1714
|
-
constructor(id, data, collection
|
|
1751
|
+
constructor(id, data, collection) {
|
|
1715
1752
|
super(id, data, collection);
|
|
1716
|
-
this.client = client;
|
|
1717
1753
|
}
|
|
1718
1754
|
get current() {
|
|
1719
1755
|
return this.data.current;
|
|
@@ -1736,6 +1772,10 @@ class Progress extends BaseEntity {
|
|
|
1736
1772
|
get remaining() {
|
|
1737
1773
|
return this.max > 0 ? this.max - this.current : 0;
|
|
1738
1774
|
}
|
|
1775
|
+
setMessageBridge(messageBridge) {
|
|
1776
|
+
this.messageBridge = messageBridge || this.messageBridge;
|
|
1777
|
+
return this;
|
|
1778
|
+
}
|
|
1739
1779
|
createSubProgress(progressValue, max, message) {
|
|
1740
1780
|
return __awaiter$n(this, void 0, void 0, function* () {
|
|
1741
1781
|
if (max <= 0 && progressValue > 0) {
|
|
@@ -1779,9 +1819,6 @@ class Progress extends BaseEntity {
|
|
|
1779
1819
|
return null;
|
|
1780
1820
|
this.data.current = Math.min(this.max, this.current + value);
|
|
1781
1821
|
yield this.save();
|
|
1782
|
-
if (!this.client)
|
|
1783
|
-
return;
|
|
1784
|
-
this.client.emit("background-progress", this.id);
|
|
1785
1822
|
});
|
|
1786
1823
|
}
|
|
1787
1824
|
cancel() {
|
|
@@ -1790,6 +1827,12 @@ class Progress extends BaseEntity {
|
|
|
1790
1827
|
yield this.save();
|
|
1791
1828
|
});
|
|
1792
1829
|
}
|
|
1830
|
+
save() {
|
|
1831
|
+
if (this.messageBridge) {
|
|
1832
|
+
this.messageBridge.sendMessage(`progress-changed`, this.toJSON());
|
|
1833
|
+
}
|
|
1834
|
+
return super.save();
|
|
1835
|
+
}
|
|
1793
1836
|
}
|
|
1794
1837
|
class SubProgress {
|
|
1795
1838
|
constructor(parent, progressFrom, progressValue, mMax = 100) {
|
|
@@ -1829,6 +1872,12 @@ class SubProgress {
|
|
|
1829
1872
|
get canceled() {
|
|
1830
1873
|
return !this.parent || this.parent.canceled;
|
|
1831
1874
|
}
|
|
1875
|
+
setMessageBridge(messageBridge) {
|
|
1876
|
+
if (!this.parent)
|
|
1877
|
+
return this;
|
|
1878
|
+
this.parent.setMessageBridge(messageBridge);
|
|
1879
|
+
return this;
|
|
1880
|
+
}
|
|
1832
1881
|
createSubProgress(progressValue, max, message) {
|
|
1833
1882
|
return __awaiter$n(this, void 0, void 0, function* () {
|
|
1834
1883
|
if (max <= 0 && progressValue > 0) {
|
|
@@ -1917,33 +1966,34 @@ var __awaiter$m = (this && this.__awaiter) || function (thisArg, _arguments, P,
|
|
|
1917
1966
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1918
1967
|
});
|
|
1919
1968
|
};
|
|
1920
|
-
const socketIOClient = socket_io_client;
|
|
1921
1969
|
let Progresses = class Progresses {
|
|
1922
|
-
constructor(connector,
|
|
1970
|
+
constructor(connector, jobMan) {
|
|
1923
1971
|
this.connector = connector;
|
|
1924
|
-
this.
|
|
1925
|
-
const mainEndpoint = this.config.resolve("mainEndpoint");
|
|
1926
|
-
this.client = !mainEndpoint ? null : socketIOClient(mainEndpoint, { path: "/socket" });
|
|
1972
|
+
this.jobMan = jobMan;
|
|
1927
1973
|
this.collection = connector.database.collection("progresses");
|
|
1974
|
+
this.progresses = {};
|
|
1975
|
+
this.jobMan.on("progress-changed", progress => {
|
|
1976
|
+
const id = progress.id;
|
|
1977
|
+
this.progresses[id] = new Progress(new ObjectId(id), progress, this.collection);
|
|
1978
|
+
});
|
|
1928
1979
|
}
|
|
1929
1980
|
waitToFinish(id) {
|
|
1930
1981
|
return __awaiter$m(this, void 0, void 0, function* () {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
return progress;
|
|
1982
|
+
return Promise.race([
|
|
1983
|
+
this.waitForProgress(id, () => __awaiter$m(this, void 0, void 0, function* () {
|
|
1984
|
+
let progress = this.progresses[id];
|
|
1985
|
+
if (!progress || progress.percent < 100) {
|
|
1986
|
+
progress = yield this.get(id);
|
|
1987
|
+
}
|
|
1988
|
+
if (!progress) {
|
|
1989
|
+
throw new Error(`Progress does not exists with id: ${id}`);
|
|
1990
|
+
}
|
|
1991
|
+
return progress;
|
|
1992
|
+
}), 500),
|
|
1993
|
+
this.waitForProgress(id, () => __awaiter$m(this, void 0, void 0, function* () {
|
|
1994
|
+
return this.progresses[id] || null;
|
|
1995
|
+
}), 25)
|
|
1996
|
+
]);
|
|
1947
1997
|
});
|
|
1948
1998
|
}
|
|
1949
1999
|
get(id) {
|
|
@@ -1954,13 +2004,13 @@ let Progresses = class Progresses {
|
|
|
1954
2004
|
find(where) {
|
|
1955
2005
|
return __awaiter$m(this, void 0, void 0, function* () {
|
|
1956
2006
|
const data = yield this.collection.findOne(where);
|
|
1957
|
-
return !data ? null : new Progress(data._id, data, this.collection
|
|
2007
|
+
return !data ? null : new Progress(data._id, data, this.collection);
|
|
1958
2008
|
});
|
|
1959
2009
|
}
|
|
1960
2010
|
create(max = 100) {
|
|
1961
2011
|
return __awaiter$m(this, void 0, void 0, function* () {
|
|
1962
2012
|
if (isNaN(max) || max <= 0) {
|
|
1963
|
-
throw
|
|
2013
|
+
throw new Error(`Max progress value must be bigger than zero`);
|
|
1964
2014
|
}
|
|
1965
2015
|
const data = {
|
|
1966
2016
|
current: 0,
|
|
@@ -1970,7 +2020,7 @@ let Progresses = class Progresses {
|
|
|
1970
2020
|
canceled: false
|
|
1971
2021
|
};
|
|
1972
2022
|
const res = yield this.collection.insertOne(data);
|
|
1973
|
-
return new Progress(res.insertedId, data, this.collection
|
|
2023
|
+
return new Progress(res.insertedId, data, this.collection);
|
|
1974
2024
|
});
|
|
1975
2025
|
}
|
|
1976
2026
|
remove(id) {
|
|
@@ -1979,11 +2029,35 @@ let Progresses = class Progresses {
|
|
|
1979
2029
|
return id;
|
|
1980
2030
|
});
|
|
1981
2031
|
}
|
|
2032
|
+
waitForProgress(id, cb, delay) {
|
|
2033
|
+
return __awaiter$m(this, void 0, void 0, function* () {
|
|
2034
|
+
let isFinished = false;
|
|
2035
|
+
let progress = null;
|
|
2036
|
+
let waitTime = 0;
|
|
2037
|
+
while (!isFinished) {
|
|
2038
|
+
progress = yield cb();
|
|
2039
|
+
waitTime += delay;
|
|
2040
|
+
if (progress) {
|
|
2041
|
+
if (progress.error) {
|
|
2042
|
+
throw new Error(progress.error);
|
|
2043
|
+
}
|
|
2044
|
+
isFinished = progress.percent >= 100;
|
|
2045
|
+
}
|
|
2046
|
+
if (!isFinished) {
|
|
2047
|
+
if (waitTime >= MAX_TIMEOUT) {
|
|
2048
|
+
throw new Error(`Progress with id: ${id} probably never will be finished!`);
|
|
2049
|
+
}
|
|
2050
|
+
yield promiseTimeout(delay);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
return progress;
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
1982
2056
|
};
|
|
1983
2057
|
Progresses = __decorate$r([
|
|
1984
2058
|
injectable(),
|
|
1985
2059
|
singleton(),
|
|
1986
|
-
__metadata$l("design:paramtypes", [MongoConnector,
|
|
2060
|
+
__metadata$l("design:paramtypes", [MongoConnector, JobManager])
|
|
1987
2061
|
], Progresses);
|
|
1988
2062
|
|
|
1989
2063
|
var __decorate$q = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -2024,7 +2098,7 @@ let LazyAssets = class LazyAssets {
|
|
|
2024
2098
|
if (existingAsset)
|
|
2025
2099
|
return existingAsset;
|
|
2026
2100
|
const res = yield this.collection.insertOne(data);
|
|
2027
|
-
return new LazyAsset(res.insertedId, data, this.collection, this.assets, this.progresses
|
|
2101
|
+
return new LazyAsset(res.insertedId, data, this.collection, this.assets, this.progresses);
|
|
2028
2102
|
});
|
|
2029
2103
|
}
|
|
2030
2104
|
read(id) {
|
|
@@ -2037,7 +2111,7 @@ let LazyAssets = class LazyAssets {
|
|
|
2037
2111
|
const data = yield this.collection.findOne(where);
|
|
2038
2112
|
return !data
|
|
2039
2113
|
? null
|
|
2040
|
-
: new LazyAsset(data._id, data, this.collection, this.assets, this.progresses
|
|
2114
|
+
: new LazyAsset(data._id, data, this.collection, this.assets, this.progresses);
|
|
2041
2115
|
});
|
|
2042
2116
|
}
|
|
2043
2117
|
unlink(id) {
|
|
@@ -2052,8 +2126,10 @@ let LazyAssets = class LazyAssets {
|
|
|
2052
2126
|
LazyAssets = __decorate$q([
|
|
2053
2127
|
injectable(),
|
|
2054
2128
|
scoped(Lifecycle.ContainerScoped),
|
|
2055
|
-
__metadata$k("design:paramtypes", [MongoConnector,
|
|
2056
|
-
|
|
2129
|
+
__metadata$k("design:paramtypes", [MongoConnector,
|
|
2130
|
+
Assets,
|
|
2131
|
+
Progresses,
|
|
2132
|
+
JobManager])
|
|
2057
2133
|
], LazyAssets);
|
|
2058
2134
|
|
|
2059
2135
|
var __decorate$p = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -3754,14 +3830,15 @@ class LazyAssetGenerator {
|
|
|
3754
3830
|
get lazyAssets() {
|
|
3755
3831
|
return this.assetResolver.lazyAssets;
|
|
3756
3832
|
}
|
|
3757
|
-
process() {
|
|
3833
|
+
process(messaging) {
|
|
3758
3834
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
3759
3835
|
const lazyAsset = yield this.lazyAssets.read(this.lazyId);
|
|
3760
3836
|
let progress = yield this.progresses.get(lazyAsset.progressId);
|
|
3761
3837
|
if (!progress || progress.canceled)
|
|
3762
3838
|
return null;
|
|
3839
|
+
progress.setMessageBridge(messaging);
|
|
3763
3840
|
try {
|
|
3764
|
-
const asset = yield this.generate(progress);
|
|
3841
|
+
const asset = yield this.generate(progress, messaging);
|
|
3765
3842
|
progress = yield progress.load();
|
|
3766
3843
|
if (!progress || progress.canceled)
|
|
3767
3844
|
return null;
|
|
@@ -3828,7 +3905,8 @@ function createServices() {
|
|
|
3828
3905
|
new Parameter("nodeEnv", "development"),
|
|
3829
3906
|
new Parameter("appPort", 80),
|
|
3830
3907
|
new Parameter("zmqPort", 3000),
|
|
3831
|
-
new Parameter("
|
|
3908
|
+
new Parameter("zmqBackPort", 3100),
|
|
3909
|
+
new Parameter("zmqRemoteHost", "tcp://127.0.0.1"),
|
|
3832
3910
|
new Parameter("isWorker", false),
|
|
3833
3911
|
new Parameter("mainEndpoint", ""),
|
|
3834
3912
|
new Parameter("idChars", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
|
@@ -4034,5 +4112,5 @@ function setupBackend(config, providers, parent) {
|
|
|
4034
4112
|
* Generated bundle index. Do not edit.
|
|
4035
4113
|
*/
|
|
4036
4114
|
|
|
4037
|
-
export { AssetProcessor, AssetResolver, Assets, AuthController, BackendProvider, Cache, CacheProcessor, Configuration, ConsoleColor, DI_CONTAINER, EXPRESS, EndpointProvider, ErrorHandlerMiddleware, FIXTURE, Fixtures, Gallery, GalleryCache, GalleryController, HTTP_SERVER, IdGenerator, IsFile, IsObjectId, JOB, JobManager, LanguageMiddleware, LazyAssetGenerator, LazyAssets, MailSender, MemoryCache, MongoConnector, PARAMETER, Parameter, Progresses, ResolveEntity, SOCKET_SERVER, TemplateRenderer, TranslationProvider, Translator, Type, UserManager, assign, broadcast, bufferToStream, convertValue, copy, copyStream, createServices, createTransformer, deleteFile, deleteFromBucket, filter, firstItem, getConstructorName, getExtension, getFileName, getFunctionParams, getType, getValue, groupBy, hydratePopulated, idToString, injectServices, isArray, isBoolean, isConstructor, isDate, isDefined, isFunction, isInterface, isNullOrUndefined, isObject, isPrimitive, isString, isType, jsonHighlight, lastItem, lcFirst, lookupPipelines, md5, mkdirRecursive, multiSubscription, observableFromFunction, padLeft, padRight, paginate, paginateAggregations, promiseTimeout, proxyFunction, proxyFunctions, rand, random, readAndDeleteFile, readFile, runCommand, setupBackend, streamToBuffer, ucFirst, valueToPromise, writeFile };
|
|
4115
|
+
export { AssetProcessor, AssetResolver, Assets, AuthController, BackendProvider, Cache, CacheProcessor, Configuration, ConsoleColor, DI_CONTAINER, EXPRESS, EndpointProvider, ErrorHandlerMiddleware, FIXTURE, Fixtures, Gallery, GalleryCache, GalleryController, HTTP_SERVER, IdGenerator, IsFile, IsObjectId, JOB, JobManager, LanguageMiddleware, LazyAssetGenerator, LazyAssets, MailSender, MemoryCache, MongoConnector, PARAMETER, Parameter, Progresses, ResolveEntity, SOCKET_SERVER, TemplateRenderer, TranslationProvider, Translator, Type, UserManager, assign, broadcast, bufferToStream, colorize, convertValue, copy, copyStream, createServices, createTransformer, deleteFile, deleteFromBucket, filter, firstItem, getConstructorName, getExtension, getFileName, getFunctionParams, getType, getValue, groupBy, hydratePopulated, idToString, injectServices, isArray, isBoolean, isConstructor, isDate, isDefined, isFunction, isInterface, isNullOrUndefined, isObject, isPrimitive, isString, isType, jsonHighlight, lastItem, lcFirst, lookupPipelines, md5, mkdirRecursive, multiSubscription, observableFromFunction, padLeft, padRight, paginate, paginateAggregations, promiseTimeout, proxyFunction, proxyFunctions, rand, random, readAndDeleteFile, readFile, runCommand, setupBackend, streamToBuffer, ucFirst, valueToPromise, writeFile };
|
|
4038
4116
|
//# sourceMappingURL=stemy-backend.js.map
|