@stemy/backend 5.1.0 → 5.1.1
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/common-types.d.ts +16 -16
- package/esm2020/rest-middlewares/error-handler.middleware.mjs +4 -4
- package/esm2020/services/backend-provider.mjs +5 -5
- package/esm2020/services/entities/asset.mjs +5 -5
- package/esm2020/services/entities/base-entity.mjs +4 -4
- package/esm2020/services/entities/lazy-asset.mjs +7 -7
- package/esm2020/services/entities/progress.mjs +17 -17
- package/esm2020/services/entities/temp-asset.mjs +4 -4
- package/esm2020/services/mail-sender.mjs +4 -4
- package/esm2020/services/mongo-connector.mjs +7 -7
- package/esm2020/services/open-api.mjs +6 -6
- package/esm2020/utilities/base-doc.mjs +1 -1
- package/esm2020/utilities/di-container.mjs +7 -7
- package/esm2020/utilities/lazy-asset-generator.mjs +6 -6
- package/esm2020/utilities/tree.mjs +4 -4
- package/fesm2015/stemy-backend.mjs +68 -68
- package/fesm2015/stemy-backend.mjs.map +1 -1
- package/fesm2020/stemy-backend.mjs +67 -67
- package/fesm2020/stemy-backend.mjs.map +1 -1
- package/package.json +1 -1
- package/utilities/base-doc.d.ts +3 -3
- package/utils.d.ts +1 -1
|
@@ -925,12 +925,6 @@ Configuration = __decorate([
|
|
|
925
925
|
], Configuration);
|
|
926
926
|
|
|
927
927
|
let MongoConnector = class MongoConnector {
|
|
928
|
-
constructor(configuration) {
|
|
929
|
-
this.configuration = configuration;
|
|
930
|
-
this.conn = null;
|
|
931
|
-
this.db = null;
|
|
932
|
-
this.fsBucket = null;
|
|
933
|
-
}
|
|
934
928
|
get connection() {
|
|
935
929
|
return this.conn;
|
|
936
930
|
}
|
|
@@ -940,6 +934,12 @@ let MongoConnector = class MongoConnector {
|
|
|
940
934
|
get bucket() {
|
|
941
935
|
return this.fsBucket;
|
|
942
936
|
}
|
|
937
|
+
constructor(configuration) {
|
|
938
|
+
this.configuration = configuration;
|
|
939
|
+
this.conn = null;
|
|
940
|
+
this.db = null;
|
|
941
|
+
this.fsBucket = null;
|
|
942
|
+
}
|
|
943
943
|
async connect() {
|
|
944
944
|
if (this.db)
|
|
945
945
|
return this.db;
|
|
@@ -958,14 +958,14 @@ MongoConnector = __decorate([
|
|
|
958
958
|
], MongoConnector);
|
|
959
959
|
|
|
960
960
|
class BaseEntity {
|
|
961
|
+
get id() {
|
|
962
|
+
return this.mId.toHexString();
|
|
963
|
+
}
|
|
961
964
|
constructor(mId, data, collection) {
|
|
962
965
|
this.mId = mId;
|
|
963
966
|
this.data = data;
|
|
964
967
|
this.collection = collection;
|
|
965
968
|
}
|
|
966
|
-
get id() {
|
|
967
|
-
return this.mId.toHexString();
|
|
968
|
-
}
|
|
969
969
|
save() {
|
|
970
970
|
return this.collection.updateOne({ _id: this.mId }, { $set: this.toJSON() });
|
|
971
971
|
}
|
|
@@ -986,10 +986,6 @@ class BaseEntity {
|
|
|
986
986
|
}
|
|
987
987
|
|
|
988
988
|
class Asset extends BaseEntity {
|
|
989
|
-
constructor(id, data, collection, bucket) {
|
|
990
|
-
super(id, data, collection);
|
|
991
|
-
this.bucket = bucket;
|
|
992
|
-
}
|
|
993
989
|
get filename() {
|
|
994
990
|
return this.data.filename;
|
|
995
991
|
}
|
|
@@ -1002,6 +998,10 @@ class Asset extends BaseEntity {
|
|
|
1002
998
|
get stream() {
|
|
1003
999
|
return this.bucket.openDownloadStream(this.mId);
|
|
1004
1000
|
}
|
|
1001
|
+
constructor(id, data, collection, bucket) {
|
|
1002
|
+
super(id, data, collection);
|
|
1003
|
+
this.bucket = bucket;
|
|
1004
|
+
}
|
|
1005
1005
|
async unlink() {
|
|
1006
1006
|
return deleteFromBucket(this.bucket, this.mId);
|
|
1007
1007
|
}
|
|
@@ -1031,6 +1031,9 @@ class Asset extends BaseEntity {
|
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
1033
1033
|
class TempAsset {
|
|
1034
|
+
get stream() {
|
|
1035
|
+
return bufferToStream(this.buffer);
|
|
1036
|
+
}
|
|
1034
1037
|
constructor(buffer, filename, contentType, metadata) {
|
|
1035
1038
|
this.buffer = buffer;
|
|
1036
1039
|
this.filename = filename;
|
|
@@ -1038,9 +1041,6 @@ class TempAsset {
|
|
|
1038
1041
|
this.metadata = metadata;
|
|
1039
1042
|
this.id = new ObjectId$1().toHexString();
|
|
1040
1043
|
}
|
|
1041
|
-
get stream() {
|
|
1042
|
-
return bufferToStream(this.buffer);
|
|
1043
|
-
}
|
|
1044
1044
|
async unlink() {
|
|
1045
1045
|
throw new Error(`Temp asset '${this.id}' can not be removed!`);
|
|
1046
1046
|
}
|
|
@@ -1210,12 +1210,6 @@ Assets = __decorate([
|
|
|
1210
1210
|
], Assets);
|
|
1211
1211
|
|
|
1212
1212
|
class LazyAsset extends BaseEntity {
|
|
1213
|
-
constructor(id, data, collection, logger, assets, progresses) {
|
|
1214
|
-
super(id, data, collection);
|
|
1215
|
-
this.logger = logger;
|
|
1216
|
-
this.assets = assets;
|
|
1217
|
-
this.progresses = progresses;
|
|
1218
|
-
}
|
|
1219
1213
|
get jobName() {
|
|
1220
1214
|
return this.data.jobName;
|
|
1221
1215
|
}
|
|
@@ -1237,6 +1231,12 @@ class LazyAsset extends BaseEntity {
|
|
|
1237
1231
|
get assetId() {
|
|
1238
1232
|
return this.data.assetId;
|
|
1239
1233
|
}
|
|
1234
|
+
constructor(id, data, collection, logger, assets, progresses) {
|
|
1235
|
+
super(id, data, collection);
|
|
1236
|
+
this.logger = logger;
|
|
1237
|
+
this.assets = assets;
|
|
1238
|
+
this.progresses = progresses;
|
|
1239
|
+
}
|
|
1240
1240
|
async unlink() {
|
|
1241
1241
|
await this.load();
|
|
1242
1242
|
if (!this.progressId) {
|
|
@@ -1485,9 +1485,6 @@ JobManager = __decorate([
|
|
|
1485
1485
|
], JobManager);
|
|
1486
1486
|
|
|
1487
1487
|
class Progress extends BaseEntity {
|
|
1488
|
-
constructor(id, data, collection) {
|
|
1489
|
-
super(id, data, collection);
|
|
1490
|
-
}
|
|
1491
1488
|
get current() {
|
|
1492
1489
|
return this.data.current;
|
|
1493
1490
|
}
|
|
@@ -1509,6 +1506,9 @@ class Progress extends BaseEntity {
|
|
|
1509
1506
|
get remaining() {
|
|
1510
1507
|
return this.max > 0 ? this.max - this.current : 0;
|
|
1511
1508
|
}
|
|
1509
|
+
constructor(id, data, collection) {
|
|
1510
|
+
super(id, data, collection);
|
|
1511
|
+
}
|
|
1512
1512
|
setMessageBridge(messageBridge) {
|
|
1513
1513
|
this.messageBridge = messageBridge || this.messageBridge;
|
|
1514
1514
|
return this;
|
|
@@ -1562,19 +1562,6 @@ class Progress extends BaseEntity {
|
|
|
1562
1562
|
}
|
|
1563
1563
|
}
|
|
1564
1564
|
class SubProgress {
|
|
1565
|
-
constructor(parent, progressFrom, progressValue, mMax = 100) {
|
|
1566
|
-
this.parent = parent;
|
|
1567
|
-
this.progressFrom = progressFrom;
|
|
1568
|
-
this.progressValue = progressValue;
|
|
1569
|
-
this.mMax = mMax;
|
|
1570
|
-
if (progressFrom < 0) {
|
|
1571
|
-
throw "Progress from must be bigger than or zero";
|
|
1572
|
-
}
|
|
1573
|
-
if (progressValue <= 0) {
|
|
1574
|
-
throw "Progress value must be bigger than zero";
|
|
1575
|
-
}
|
|
1576
|
-
this.mCurrent = 0;
|
|
1577
|
-
}
|
|
1578
1565
|
get id() {
|
|
1579
1566
|
return this.parent.id;
|
|
1580
1567
|
}
|
|
@@ -1599,6 +1586,19 @@ class SubProgress {
|
|
|
1599
1586
|
get canceled() {
|
|
1600
1587
|
return !this.parent || this.parent.canceled;
|
|
1601
1588
|
}
|
|
1589
|
+
constructor(parent, progressFrom, progressValue, mMax = 100) {
|
|
1590
|
+
this.parent = parent;
|
|
1591
|
+
this.progressFrom = progressFrom;
|
|
1592
|
+
this.progressValue = progressValue;
|
|
1593
|
+
this.mMax = mMax;
|
|
1594
|
+
if (progressFrom < 0) {
|
|
1595
|
+
throw "Progress from must be bigger than or zero";
|
|
1596
|
+
}
|
|
1597
|
+
if (progressValue <= 0) {
|
|
1598
|
+
throw "Progress value must be bigger than zero";
|
|
1599
|
+
}
|
|
1600
|
+
this.mCurrent = 0;
|
|
1601
|
+
}
|
|
1602
1602
|
setMessageBridge(messageBridge) {
|
|
1603
1603
|
if (!this.parent)
|
|
1604
1604
|
return this;
|
|
@@ -1862,11 +1862,6 @@ IsObjectId = __decorate([
|
|
|
1862
1862
|
], IsObjectId);
|
|
1863
1863
|
|
|
1864
1864
|
let OpenApi = class OpenApi {
|
|
1865
|
-
constructor(container, customValidation) {
|
|
1866
|
-
this.container = container;
|
|
1867
|
-
this.customValidation = customValidation;
|
|
1868
|
-
this.docs = null;
|
|
1869
|
-
}
|
|
1870
1865
|
get apiDocs() {
|
|
1871
1866
|
if (!this.docs)
|
|
1872
1867
|
this.docs = this.createApiDocs();
|
|
@@ -1877,6 +1872,11 @@ let OpenApi = class OpenApi {
|
|
|
1877
1872
|
this.docsStr = JSON.stringify(this.apiDocs);
|
|
1878
1873
|
return this.docsStr;
|
|
1879
1874
|
}
|
|
1875
|
+
constructor(container, customValidation) {
|
|
1876
|
+
this.container = container;
|
|
1877
|
+
this.customValidation = customValidation;
|
|
1878
|
+
this.docs = null;
|
|
1879
|
+
}
|
|
1880
1880
|
async schemaToExample(src, req) {
|
|
1881
1881
|
const maybeRef = src;
|
|
1882
1882
|
if (maybeRef.$ref) {
|
|
@@ -2002,10 +2002,6 @@ Fixtures = __decorate([
|
|
|
2002
2002
|
|
|
2003
2003
|
const express = express_;
|
|
2004
2004
|
let BackendProvider = class BackendProvider {
|
|
2005
|
-
constructor(config, container) {
|
|
2006
|
-
this.config = config;
|
|
2007
|
-
this.container = container;
|
|
2008
|
-
}
|
|
2009
2005
|
get io() {
|
|
2010
2006
|
this.ioServer = this.ioServer || new Server(this.server, {
|
|
2011
2007
|
path: "/socket",
|
|
@@ -2039,6 +2035,10 @@ let BackendProvider = class BackendProvider {
|
|
|
2039
2035
|
this.httpServer = this.httpServer || createServer(this.express);
|
|
2040
2036
|
return this.httpServer;
|
|
2041
2037
|
}
|
|
2038
|
+
constructor(config, container) {
|
|
2039
|
+
this.config = config;
|
|
2040
|
+
this.container = container;
|
|
2041
|
+
}
|
|
2042
2042
|
async quickStart() {
|
|
2043
2043
|
const port = this.config.resolve("appPort");
|
|
2044
2044
|
const isWorker = this.config.resolve("isWorker");
|
|
@@ -2504,6 +2504,9 @@ TemplateRenderer = __decorate([
|
|
|
2504
2504
|
], TemplateRenderer);
|
|
2505
2505
|
|
|
2506
2506
|
let MailSender = class MailSender {
|
|
2507
|
+
get translator() {
|
|
2508
|
+
return this.renderer.translator;
|
|
2509
|
+
}
|
|
2507
2510
|
constructor(config, renderer) {
|
|
2508
2511
|
this.config = config;
|
|
2509
2512
|
this.renderer = renderer;
|
|
@@ -2516,9 +2519,6 @@ let MailSender = class MailSender {
|
|
|
2516
2519
|
}
|
|
2517
2520
|
});
|
|
2518
2521
|
}
|
|
2519
|
-
get translator() {
|
|
2520
|
-
return this.renderer.translator;
|
|
2521
|
-
}
|
|
2522
2522
|
async sendMail(language, options) {
|
|
2523
2523
|
const subject = await this.translator.getTranslation(language, options.subject || "-");
|
|
2524
2524
|
const html = await this.renderer.render(options.template, language, options.context);
|
|
@@ -3228,13 +3228,13 @@ TerminalController$1 = __decorate([
|
|
|
3228
3228
|
], TerminalController$1);
|
|
3229
3229
|
|
|
3230
3230
|
let ErrorHandlerMiddleware = class ErrorHandlerMiddleware {
|
|
3231
|
+
get isDev() {
|
|
3232
|
+
return this.configuration.resolve("nodeEnv") === "development";
|
|
3233
|
+
}
|
|
3231
3234
|
constructor(configuration, translator) {
|
|
3232
3235
|
this.configuration = configuration;
|
|
3233
3236
|
this.translator = translator;
|
|
3234
3237
|
}
|
|
3235
|
-
get isDev() {
|
|
3236
|
-
return this.configuration.resolve("nodeEnv") === "development";
|
|
3237
|
-
}
|
|
3238
3238
|
async error(error, req, res, next) {
|
|
3239
3239
|
const result = await this.getResult(error, req, res);
|
|
3240
3240
|
if (this.isDev) {
|
|
@@ -3563,15 +3563,15 @@ CompressionMiddleware = __decorate([
|
|
|
3563
3563
|
], CompressionMiddleware);
|
|
3564
3564
|
|
|
3565
3565
|
class Tree {
|
|
3566
|
+
get parentTree() {
|
|
3567
|
+
return this.container.parent.tree;
|
|
3568
|
+
}
|
|
3566
3569
|
constructor(container, exists, path) {
|
|
3567
3570
|
this.container = container;
|
|
3568
3571
|
this.exists = exists;
|
|
3569
3572
|
this.path = path;
|
|
3570
3573
|
this.map = new Map();
|
|
3571
3574
|
}
|
|
3572
|
-
get parentTree() {
|
|
3573
|
-
return this.container.parent.tree;
|
|
3574
|
-
}
|
|
3575
3575
|
resolveService() {
|
|
3576
3576
|
return !this.exists ? null : this.container.resolve(this.path);
|
|
3577
3577
|
}
|
|
@@ -3677,6 +3677,12 @@ class Tree {
|
|
|
3677
3677
|
}
|
|
3678
3678
|
|
|
3679
3679
|
class DiContainer {
|
|
3680
|
+
get registeredTokens() {
|
|
3681
|
+
return (this.parent?.registeredTokens || []).concat(this.tokens);
|
|
3682
|
+
}
|
|
3683
|
+
get tree() {
|
|
3684
|
+
return this.root;
|
|
3685
|
+
}
|
|
3680
3686
|
constructor(container, parent = null) {
|
|
3681
3687
|
this.container = container;
|
|
3682
3688
|
this.parent = parent;
|
|
@@ -3685,12 +3691,6 @@ class DiContainer {
|
|
|
3685
3691
|
this.tokenSet = new Set();
|
|
3686
3692
|
this.root = new Tree(this, false, "");
|
|
3687
3693
|
}
|
|
3688
|
-
get registeredTokens() {
|
|
3689
|
-
return (this.parent?.registeredTokens || []).concat(this.tokens);
|
|
3690
|
-
}
|
|
3691
|
-
get tree() {
|
|
3692
|
-
return this.root;
|
|
3693
|
-
}
|
|
3694
3694
|
beforeResolution(token, callback, options) {
|
|
3695
3695
|
this.container.beforeResolution(token, callback, options);
|
|
3696
3696
|
}
|
|
@@ -3912,17 +3912,17 @@ function ResponseType(type, options = {}) {
|
|
|
3912
3912
|
}
|
|
3913
3913
|
|
|
3914
3914
|
class LazyAssetGenerator {
|
|
3915
|
-
constructor(assetResolver, progresses, lazyId) {
|
|
3916
|
-
this.assetResolver = assetResolver;
|
|
3917
|
-
this.progresses = progresses;
|
|
3918
|
-
this.lazyId = lazyId;
|
|
3919
|
-
}
|
|
3920
3915
|
get assets() {
|
|
3921
3916
|
return this.assetResolver.assets;
|
|
3922
3917
|
}
|
|
3923
3918
|
get lazyAssets() {
|
|
3924
3919
|
return this.assetResolver.lazyAssets;
|
|
3925
3920
|
}
|
|
3921
|
+
constructor(assetResolver, progresses, lazyId) {
|
|
3922
|
+
this.assetResolver = assetResolver;
|
|
3923
|
+
this.progresses = progresses;
|
|
3924
|
+
this.lazyId = lazyId;
|
|
3925
|
+
}
|
|
3926
3926
|
async process(messaging) {
|
|
3927
3927
|
const lazyAsset = await this.lazyAssets.read(this.lazyId);
|
|
3928
3928
|
let progress = await this.progresses.get(lazyAsset.progressId);
|