@stemy/backend 3.0.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/stemy-backend.umd.js +243 -145
- 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 +7 -5
- package/esm2015/services/entities/lazy-asset.js +3 -4
- package/esm2015/services/entities/progress.js +18 -6
- package/esm2015/services/job-manager.js +82 -47
- package/esm2015/services/lazy-assets.js +7 -5
- package/esm2015/services/progresses.js +53 -29
- package/esm2015/utilities/lazy-asset-generator.js +4 -3
- package/esm2015/utils.js +20 -1
- package/fesm2015/stemy-backend.js +182 -89
- 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 +16 -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';
|
|
@@ -118,6 +118,22 @@ function firstItem(value) {
|
|
|
118
118
|
function lastItem(value) {
|
|
119
119
|
return value[value.length - 1];
|
|
120
120
|
}
|
|
121
|
+
function regroup(value, comparator) {
|
|
122
|
+
const result = [];
|
|
123
|
+
if (!isArray(value) || value.length == 0)
|
|
124
|
+
return result;
|
|
125
|
+
value = Array.from(value);
|
|
126
|
+
result.push([value.shift()]);
|
|
127
|
+
value.forEach(item => {
|
|
128
|
+
const group = result.find(g => g.some(a => comparator(a, item)));
|
|
129
|
+
if (group) {
|
|
130
|
+
group.push(item);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
result.push([item]);
|
|
134
|
+
});
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
121
137
|
function getValue(obj, key, defaultValue, treeFallback = false) {
|
|
122
138
|
key = key || "";
|
|
123
139
|
const keys = key.split(".");
|
|
@@ -680,6 +696,9 @@ const defaultColors = {
|
|
|
680
696
|
falseColor: ConsoleColor.FgRed,
|
|
681
697
|
nullColor: ConsoleColor.BgMagenta
|
|
682
698
|
};
|
|
699
|
+
function colorize(input, color) {
|
|
700
|
+
return `${color}${input}${ConsoleColor.Reset}`;
|
|
701
|
+
}
|
|
683
702
|
function jsonHighlight(input, colorOptions) {
|
|
684
703
|
const colors = Object.assign({}, defaultColors, colorOptions);
|
|
685
704
|
const json = (isString(input) ? input : JSON.stringify(input, null, 2)).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
@@ -1459,11 +1478,10 @@ var __awaiter$p = (this && this.__awaiter) || function (thisArg, _arguments, P,
|
|
|
1459
1478
|
});
|
|
1460
1479
|
};
|
|
1461
1480
|
class LazyAsset extends BaseEntity {
|
|
1462
|
-
constructor(id, data, collection, assets, progresses
|
|
1481
|
+
constructor(id, data, collection, assets, progresses) {
|
|
1463
1482
|
super(id, data, collection);
|
|
1464
1483
|
this.assets = assets;
|
|
1465
1484
|
this.progresses = progresses;
|
|
1466
|
-
this.jobMan = jobMan;
|
|
1467
1485
|
}
|
|
1468
1486
|
get jobName() {
|
|
1469
1487
|
return this.data.jobName;
|
|
@@ -1531,7 +1549,7 @@ class LazyAsset extends BaseEntity {
|
|
|
1531
1549
|
this.data.progressId = (yield this.progresses.create()).id;
|
|
1532
1550
|
this.data.assetId = null;
|
|
1533
1551
|
yield this.save();
|
|
1534
|
-
yield this.jobMan.enqueueWithName(this.data.jobName, Object.assign(Object.assign({}, this.data.jobParams), { lazyId: this.id, fromLoad }));
|
|
1552
|
+
yield this.progresses.jobMan.enqueueWithName(this.data.jobName, Object.assign(Object.assign({}, this.data.jobParams), { lazyId: this.id, fromLoad }));
|
|
1535
1553
|
});
|
|
1536
1554
|
}
|
|
1537
1555
|
}
|
|
@@ -1565,10 +1583,23 @@ let JobManager = class JobManager {
|
|
|
1565
1583
|
this.jobs = this.jobTypes.reduce((res, jobType) => {
|
|
1566
1584
|
res[getConstructorName(jobType)] = (jobParams) => {
|
|
1567
1585
|
const job = this.resolveJobInstance(jobType, jobParams);
|
|
1568
|
-
return job.process();
|
|
1586
|
+
return job.process(this.messageBridge);
|
|
1569
1587
|
};
|
|
1570
1588
|
return res;
|
|
1571
1589
|
}, {});
|
|
1590
|
+
this.messages = new Subject();
|
|
1591
|
+
this.messageBridge = {
|
|
1592
|
+
sendMessage: (message, params) => {
|
|
1593
|
+
this.workerPush.send([message, JSON.stringify(params)]);
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
this.processing = false;
|
|
1597
|
+
this.maxTimeout = this.config.resolve("jobTimeout");
|
|
1598
|
+
}
|
|
1599
|
+
on(message, cb) {
|
|
1600
|
+
return this.messages
|
|
1601
|
+
.pipe(filter$1(t => t.message === message))
|
|
1602
|
+
.pipe(map(t => t.params)).subscribe(cb);
|
|
1572
1603
|
}
|
|
1573
1604
|
process(jobType, params = {}) {
|
|
1574
1605
|
return __awaiter$o(this, void 0, void 0, function* () {
|
|
@@ -1585,20 +1616,12 @@ let JobManager = class JobManager {
|
|
|
1585
1616
|
}
|
|
1586
1617
|
enqueueWithName(name, params = {}) {
|
|
1587
1618
|
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1588
|
-
|
|
1589
|
-
return this.sendToWorkers(jobName, params);
|
|
1619
|
+
return this.sendToWorkers(this.tryResolveFromName(name, params), params);
|
|
1590
1620
|
});
|
|
1591
1621
|
}
|
|
1592
1622
|
enqueue(jobType, params = {}) {
|
|
1593
1623
|
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()]);
|
|
1624
|
+
return this.sendToWorkers(this.tryResolveAndInit(jobType, params), params);
|
|
1602
1625
|
});
|
|
1603
1626
|
}
|
|
1604
1627
|
schedule(minute, hour, dayOfMonth, month, dayOfWeek, jobType, params = {}) {
|
|
@@ -1624,32 +1647,45 @@ let JobManager = class JobManager {
|
|
|
1624
1647
|
});
|
|
1625
1648
|
}
|
|
1626
1649
|
startProcessing() {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1650
|
+
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1651
|
+
if (this.processing)
|
|
1652
|
+
return null;
|
|
1653
|
+
this.processing = true;
|
|
1654
|
+
if (!this.config.resolve("isWorker")) {
|
|
1655
|
+
console.log(colorize(`Processing can not be started because this is NOT a worker process!`, ConsoleColor.FgRed));
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1658
|
+
const host = this.config.resolve("zmqRemoteHost");
|
|
1659
|
+
const pushHost = `${host}:${this.config.resolve("zmqBackPort")}`;
|
|
1660
|
+
this.workerPush = socket("push");
|
|
1661
|
+
yield this.workerPush.connect(pushHost);
|
|
1662
|
+
console.log(`Worker producer connected to: ${pushHost}`);
|
|
1663
|
+
const pullHost = `${host}:${this.config.resolve("zmqPort")}`;
|
|
1664
|
+
this.workerPull = socket("pull");
|
|
1665
|
+
yield this.workerPull.connect(pullHost);
|
|
1666
|
+
console.log(`Worker consumer connected to: ${pullHost}`);
|
|
1667
|
+
this.workerPull.on("message", (name, args, uniqueId) => __awaiter$o(this, void 0, void 0, function* () {
|
|
1639
1668
|
try {
|
|
1640
|
-
|
|
1641
|
-
|
|
1669
|
+
const jobName = name.toString("utf8");
|
|
1670
|
+
const jobParams = JSON.parse(args.toString("utf8"));
|
|
1671
|
+
const timerId = uniqueId === null || uniqueId === void 0 ? void 0 : uniqueId.toString("utf8");
|
|
1672
|
+
console.time(timerId);
|
|
1673
|
+
console.timeLog(timerId, `Started working on background job: ${colorize(jobName, ConsoleColor.FgCyan)} with args: \n${jsonHighlight(jobParams)}\n\n`);
|
|
1674
|
+
this.messageBridge.sendMessage(`job-started`, { name: jobName });
|
|
1675
|
+
try {
|
|
1676
|
+
yield Promise.race([this.jobs[jobName](jobParams), promiseTimeout(this.maxTimeout, true)]);
|
|
1677
|
+
console.timeLog(timerId, `Finished working on background job: ${colorize(jobName, ConsoleColor.FgCyan)}\n\n`);
|
|
1678
|
+
}
|
|
1679
|
+
catch (e) {
|
|
1680
|
+
console.timeLog(timerId, `Background job failed: ${colorize(jobName, ConsoleColor.FgRed)}\n${e}\n\n`);
|
|
1681
|
+
}
|
|
1682
|
+
console.timeEnd(timerId);
|
|
1642
1683
|
}
|
|
1643
1684
|
catch (e) {
|
|
1644
|
-
console.
|
|
1685
|
+
console.log(`Failed to start job: ${e.message}`);
|
|
1645
1686
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
catch (e) {
|
|
1649
|
-
console.log(`Failed to start job: ${e.message}`);
|
|
1650
|
-
}
|
|
1651
|
-
}));
|
|
1652
|
-
console.log(`Waiting for jobs at: ${host}`);
|
|
1687
|
+
}));
|
|
1688
|
+
});
|
|
1653
1689
|
}
|
|
1654
1690
|
tryResolve(jobType, params) {
|
|
1655
1691
|
const jobName = getConstructorName(jobType);
|
|
@@ -1671,19 +1707,28 @@ let JobManager = class JobManager {
|
|
|
1671
1707
|
if (!jobType) {
|
|
1672
1708
|
throw `Can't find job type with name: ${jobName} so it can't be enqueued!`;
|
|
1673
1709
|
}
|
|
1674
|
-
return this.
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1710
|
+
return this.tryResolveAndInit(jobType, params);
|
|
1711
|
+
}
|
|
1712
|
+
tryResolveAndInit(jobType, params) {
|
|
1713
|
+
if (!this.apiPush) {
|
|
1714
|
+
const port = this.config.resolve("zmqPort");
|
|
1715
|
+
this.apiPush = socket("push");
|
|
1716
|
+
this.apiPush.bind(`tcp://0.0.0.0:${port}`);
|
|
1717
|
+
console.log(`API producer bound to port: ${port}`);
|
|
1718
|
+
}
|
|
1719
|
+
if (!this.apiPull) {
|
|
1720
|
+
const backPort = this.config.resolve("zmqBackPort");
|
|
1721
|
+
this.apiPull = socket("pull");
|
|
1722
|
+
this.apiPull.bind(`tcp://0.0.0.0:${backPort}`);
|
|
1723
|
+
this.apiPull.on("message", (name, args) => {
|
|
1724
|
+
const message = name.toString("utf8");
|
|
1725
|
+
const params = JSON.parse((args === null || args === void 0 ? void 0 : args.toString("utf8")) || "{}");
|
|
1726
|
+
console.log(`Received a message from worker: "${colorize(message, ConsoleColor.FgCyan)}" with args: ${jsonHighlight(params)}\n\n`);
|
|
1727
|
+
this.messages.next({ message, params });
|
|
1728
|
+
});
|
|
1729
|
+
console.log(`API consumer bound to port: ${backPort}`);
|
|
1730
|
+
}
|
|
1731
|
+
return this.tryResolve(jobType, params);
|
|
1687
1732
|
}
|
|
1688
1733
|
resolveJobInstance(jobType, params) {
|
|
1689
1734
|
const container = this.container.createChildContainer();
|
|
@@ -1693,6 +1738,12 @@ let JobManager = class JobManager {
|
|
|
1693
1738
|
container.register(jobType, jobType);
|
|
1694
1739
|
return container.resolve(jobType);
|
|
1695
1740
|
}
|
|
1741
|
+
sendToWorkers(jobName, params) {
|
|
1742
|
+
return __awaiter$o(this, void 0, void 0, function* () {
|
|
1743
|
+
const publisher = yield this.apiPush;
|
|
1744
|
+
yield publisher.send([jobName, JSON.stringify(params), new ObjectId().toHexString()]);
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1696
1747
|
};
|
|
1697
1748
|
JobManager = __decorate$s([
|
|
1698
1749
|
injectable(),
|
|
@@ -1711,9 +1762,8 @@ var __awaiter$n = (this && this.__awaiter) || function (thisArg, _arguments, P,
|
|
|
1711
1762
|
});
|
|
1712
1763
|
};
|
|
1713
1764
|
class Progress extends BaseEntity {
|
|
1714
|
-
constructor(id, data, collection
|
|
1765
|
+
constructor(id, data, collection) {
|
|
1715
1766
|
super(id, data, collection);
|
|
1716
|
-
this.client = client;
|
|
1717
1767
|
}
|
|
1718
1768
|
get current() {
|
|
1719
1769
|
return this.data.current;
|
|
@@ -1736,6 +1786,10 @@ class Progress extends BaseEntity {
|
|
|
1736
1786
|
get remaining() {
|
|
1737
1787
|
return this.max > 0 ? this.max - this.current : 0;
|
|
1738
1788
|
}
|
|
1789
|
+
setMessageBridge(messageBridge) {
|
|
1790
|
+
this.messageBridge = messageBridge || this.messageBridge;
|
|
1791
|
+
return this;
|
|
1792
|
+
}
|
|
1739
1793
|
createSubProgress(progressValue, max, message) {
|
|
1740
1794
|
return __awaiter$n(this, void 0, void 0, function* () {
|
|
1741
1795
|
if (max <= 0 && progressValue > 0) {
|
|
@@ -1779,9 +1833,6 @@ class Progress extends BaseEntity {
|
|
|
1779
1833
|
return null;
|
|
1780
1834
|
this.data.current = Math.min(this.max, this.current + value);
|
|
1781
1835
|
yield this.save();
|
|
1782
|
-
if (!this.client)
|
|
1783
|
-
return;
|
|
1784
|
-
this.client.emit("background-progress", this.id);
|
|
1785
1836
|
});
|
|
1786
1837
|
}
|
|
1787
1838
|
cancel() {
|
|
@@ -1790,6 +1841,12 @@ class Progress extends BaseEntity {
|
|
|
1790
1841
|
yield this.save();
|
|
1791
1842
|
});
|
|
1792
1843
|
}
|
|
1844
|
+
save() {
|
|
1845
|
+
if (this.messageBridge) {
|
|
1846
|
+
this.messageBridge.sendMessage(`progress-changed`, this.toJSON());
|
|
1847
|
+
}
|
|
1848
|
+
return super.save();
|
|
1849
|
+
}
|
|
1793
1850
|
}
|
|
1794
1851
|
class SubProgress {
|
|
1795
1852
|
constructor(parent, progressFrom, progressValue, mMax = 100) {
|
|
@@ -1829,6 +1886,12 @@ class SubProgress {
|
|
|
1829
1886
|
get canceled() {
|
|
1830
1887
|
return !this.parent || this.parent.canceled;
|
|
1831
1888
|
}
|
|
1889
|
+
setMessageBridge(messageBridge) {
|
|
1890
|
+
if (!this.parent)
|
|
1891
|
+
return this;
|
|
1892
|
+
this.parent.setMessageBridge(messageBridge);
|
|
1893
|
+
return this;
|
|
1894
|
+
}
|
|
1832
1895
|
createSubProgress(progressValue, max, message) {
|
|
1833
1896
|
return __awaiter$n(this, void 0, void 0, function* () {
|
|
1834
1897
|
if (max <= 0 && progressValue > 0) {
|
|
@@ -1917,33 +1980,34 @@ var __awaiter$m = (this && this.__awaiter) || function (thisArg, _arguments, P,
|
|
|
1917
1980
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1918
1981
|
});
|
|
1919
1982
|
};
|
|
1920
|
-
const socketIOClient = socket_io_client;
|
|
1921
1983
|
let Progresses = class Progresses {
|
|
1922
|
-
constructor(connector,
|
|
1984
|
+
constructor(connector, jobMan) {
|
|
1923
1985
|
this.connector = connector;
|
|
1924
|
-
this.
|
|
1925
|
-
const mainEndpoint = this.config.resolve("mainEndpoint");
|
|
1926
|
-
this.client = !mainEndpoint ? null : socketIOClient(mainEndpoint, { path: "/socket" });
|
|
1986
|
+
this.jobMan = jobMan;
|
|
1927
1987
|
this.collection = connector.database.collection("progresses");
|
|
1988
|
+
this.progresses = {};
|
|
1989
|
+
this.jobMan.on("progress-changed", progress => {
|
|
1990
|
+
const id = progress.id;
|
|
1991
|
+
this.progresses[id] = new Progress(new ObjectId(id), progress, this.collection);
|
|
1992
|
+
});
|
|
1928
1993
|
}
|
|
1929
1994
|
waitToFinish(id) {
|
|
1930
1995
|
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;
|
|
1996
|
+
return Promise.race([
|
|
1997
|
+
this.waitForProgress(id, () => __awaiter$m(this, void 0, void 0, function* () {
|
|
1998
|
+
let progress = this.progresses[id];
|
|
1999
|
+
if (!progress || progress.percent < 100) {
|
|
2000
|
+
progress = yield this.get(id);
|
|
2001
|
+
}
|
|
2002
|
+
if (!progress) {
|
|
2003
|
+
throw new Error(`Progress does not exists with id: ${id}`);
|
|
2004
|
+
}
|
|
2005
|
+
return progress;
|
|
2006
|
+
}), 500),
|
|
2007
|
+
this.waitForProgress(id, () => __awaiter$m(this, void 0, void 0, function* () {
|
|
2008
|
+
return this.progresses[id] || null;
|
|
2009
|
+
}), 25)
|
|
2010
|
+
]);
|
|
1947
2011
|
});
|
|
1948
2012
|
}
|
|
1949
2013
|
get(id) {
|
|
@@ -1954,13 +2018,13 @@ let Progresses = class Progresses {
|
|
|
1954
2018
|
find(where) {
|
|
1955
2019
|
return __awaiter$m(this, void 0, void 0, function* () {
|
|
1956
2020
|
const data = yield this.collection.findOne(where);
|
|
1957
|
-
return !data ? null : new Progress(data._id, data, this.collection
|
|
2021
|
+
return !data ? null : new Progress(data._id, data, this.collection);
|
|
1958
2022
|
});
|
|
1959
2023
|
}
|
|
1960
2024
|
create(max = 100) {
|
|
1961
2025
|
return __awaiter$m(this, void 0, void 0, function* () {
|
|
1962
2026
|
if (isNaN(max) || max <= 0) {
|
|
1963
|
-
throw
|
|
2027
|
+
throw new Error(`Max progress value must be bigger than zero`);
|
|
1964
2028
|
}
|
|
1965
2029
|
const data = {
|
|
1966
2030
|
current: 0,
|
|
@@ -1970,7 +2034,7 @@ let Progresses = class Progresses {
|
|
|
1970
2034
|
canceled: false
|
|
1971
2035
|
};
|
|
1972
2036
|
const res = yield this.collection.insertOne(data);
|
|
1973
|
-
return new Progress(res.insertedId, data, this.collection
|
|
2037
|
+
return new Progress(res.insertedId, data, this.collection);
|
|
1974
2038
|
});
|
|
1975
2039
|
}
|
|
1976
2040
|
remove(id) {
|
|
@@ -1979,11 +2043,35 @@ let Progresses = class Progresses {
|
|
|
1979
2043
|
return id;
|
|
1980
2044
|
});
|
|
1981
2045
|
}
|
|
2046
|
+
waitForProgress(id, cb, delay) {
|
|
2047
|
+
return __awaiter$m(this, void 0, void 0, function* () {
|
|
2048
|
+
let isFinished = false;
|
|
2049
|
+
let progress = null;
|
|
2050
|
+
let waitTime = 0;
|
|
2051
|
+
while (!isFinished) {
|
|
2052
|
+
progress = yield cb();
|
|
2053
|
+
waitTime += delay;
|
|
2054
|
+
if (progress) {
|
|
2055
|
+
if (progress.error) {
|
|
2056
|
+
throw new Error(progress.error);
|
|
2057
|
+
}
|
|
2058
|
+
isFinished = progress.percent >= 100;
|
|
2059
|
+
}
|
|
2060
|
+
if (!isFinished) {
|
|
2061
|
+
if (waitTime >= this.jobMan.maxTimeout) {
|
|
2062
|
+
throw new Error(`Progress with id: ${id} probably never will be finished!`);
|
|
2063
|
+
}
|
|
2064
|
+
yield promiseTimeout(delay);
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
return progress;
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
1982
2070
|
};
|
|
1983
2071
|
Progresses = __decorate$r([
|
|
1984
2072
|
injectable(),
|
|
1985
2073
|
singleton(),
|
|
1986
|
-
__metadata$l("design:paramtypes", [MongoConnector,
|
|
2074
|
+
__metadata$l("design:paramtypes", [MongoConnector, JobManager])
|
|
1987
2075
|
], Progresses);
|
|
1988
2076
|
|
|
1989
2077
|
var __decorate$q = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -2024,7 +2112,7 @@ let LazyAssets = class LazyAssets {
|
|
|
2024
2112
|
if (existingAsset)
|
|
2025
2113
|
return existingAsset;
|
|
2026
2114
|
const res = yield this.collection.insertOne(data);
|
|
2027
|
-
return new LazyAsset(res.insertedId, data, this.collection, this.assets, this.progresses
|
|
2115
|
+
return new LazyAsset(res.insertedId, data, this.collection, this.assets, this.progresses);
|
|
2028
2116
|
});
|
|
2029
2117
|
}
|
|
2030
2118
|
read(id) {
|
|
@@ -2037,7 +2125,7 @@ let LazyAssets = class LazyAssets {
|
|
|
2037
2125
|
const data = yield this.collection.findOne(where);
|
|
2038
2126
|
return !data
|
|
2039
2127
|
? null
|
|
2040
|
-
: new LazyAsset(data._id, data, this.collection, this.assets, this.progresses
|
|
2128
|
+
: new LazyAsset(data._id, data, this.collection, this.assets, this.progresses);
|
|
2041
2129
|
});
|
|
2042
2130
|
}
|
|
2043
2131
|
unlink(id) {
|
|
@@ -2052,8 +2140,10 @@ let LazyAssets = class LazyAssets {
|
|
|
2052
2140
|
LazyAssets = __decorate$q([
|
|
2053
2141
|
injectable(),
|
|
2054
2142
|
scoped(Lifecycle.ContainerScoped),
|
|
2055
|
-
__metadata$k("design:paramtypes", [MongoConnector,
|
|
2056
|
-
|
|
2143
|
+
__metadata$k("design:paramtypes", [MongoConnector,
|
|
2144
|
+
Assets,
|
|
2145
|
+
Progresses,
|
|
2146
|
+
JobManager])
|
|
2057
2147
|
], LazyAssets);
|
|
2058
2148
|
|
|
2059
2149
|
var __decorate$p = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -3754,14 +3844,15 @@ class LazyAssetGenerator {
|
|
|
3754
3844
|
get lazyAssets() {
|
|
3755
3845
|
return this.assetResolver.lazyAssets;
|
|
3756
3846
|
}
|
|
3757
|
-
process() {
|
|
3847
|
+
process(messaging) {
|
|
3758
3848
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
3759
3849
|
const lazyAsset = yield this.lazyAssets.read(this.lazyId);
|
|
3760
3850
|
let progress = yield this.progresses.get(lazyAsset.progressId);
|
|
3761
3851
|
if (!progress || progress.canceled)
|
|
3762
3852
|
return null;
|
|
3853
|
+
progress.setMessageBridge(messaging);
|
|
3763
3854
|
try {
|
|
3764
|
-
const asset = yield this.generate(progress);
|
|
3855
|
+
const asset = yield this.generate(progress, messaging);
|
|
3765
3856
|
progress = yield progress.load();
|
|
3766
3857
|
if (!progress || progress.canceled)
|
|
3767
3858
|
return null;
|
|
@@ -3825,10 +3916,11 @@ function createServices() {
|
|
|
3825
3916
|
new Parameter("mongoDb", "node-backend"),
|
|
3826
3917
|
new Parameter("mongoUser", null),
|
|
3827
3918
|
new Parameter("mongoPassword", null),
|
|
3828
|
-
new Parameter("nodeEnv", "
|
|
3919
|
+
new Parameter("nodeEnv", "production"),
|
|
3829
3920
|
new Parameter("appPort", 80),
|
|
3830
3921
|
new Parameter("zmqPort", 3000),
|
|
3831
|
-
new Parameter("
|
|
3922
|
+
new Parameter("zmqBackPort", 3100),
|
|
3923
|
+
new Parameter("zmqRemoteHost", "tcp://127.0.0.1"),
|
|
3832
3924
|
new Parameter("isWorker", false),
|
|
3833
3925
|
new Parameter("mainEndpoint", ""),
|
|
3834
3926
|
new Parameter("idChars", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
|
@@ -3836,6 +3928,7 @@ function createServices() {
|
|
|
3836
3928
|
new Parameter("idPrefix", "ID-"),
|
|
3837
3929
|
new Parameter("idParts", [4, 4]),
|
|
3838
3930
|
new Parameter("jsonLimit", "250mb"),
|
|
3931
|
+
new Parameter("jobTimeout", 5 * 60 * 1000),
|
|
3839
3932
|
new Parameter("cacheCollection", "cache"),
|
|
3840
3933
|
];
|
|
3841
3934
|
// Convert parameters to providers
|
|
@@ -4034,5 +4127,5 @@ function setupBackend(config, providers, parent) {
|
|
|
4034
4127
|
* Generated bundle index. Do not edit.
|
|
4035
4128
|
*/
|
|
4036
4129
|
|
|
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 };
|
|
4130
|
+
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, regroup, runCommand, setupBackend, streamToBuffer, ucFirst, valueToPromise, writeFile };
|
|
4038
4131
|
//# sourceMappingURL=stemy-backend.js.map
|