@stemy/backend 3.1.5 → 3.2.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 +40 -8
- 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 +2 -1
- package/esm2015/common-types.js +1 -1
- package/esm2015/public_api.js +4 -2
- package/esm2015/services/job-manager.js +8 -4
- package/esm2015/utils.js +26 -6
- package/fesm2015/stemy-backend.js +34 -8
- package/fesm2015/stemy-backend.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +2 -2
- package/stemy-backend.metadata.json +1 -1
- package/utils.d.ts +11 -1
|
@@ -480,6 +480,9 @@
|
|
|
480
480
|
});
|
|
481
481
|
return result;
|
|
482
482
|
}
|
|
483
|
+
function uniqueItems(value) {
|
|
484
|
+
return value.filter(function (v, ix) { return value.indexOf(v) === ix; });
|
|
485
|
+
}
|
|
483
486
|
function getValue(obj, key, defaultValue, treeFallback) {
|
|
484
487
|
if (treeFallback === void 0) { treeFallback = false; }
|
|
485
488
|
key = key || "";
|
|
@@ -556,7 +559,7 @@
|
|
|
556
559
|
});
|
|
557
560
|
});
|
|
558
561
|
}
|
|
559
|
-
function
|
|
562
|
+
function lookupStages(from, localField, as, foreignField, shouldUnwind) {
|
|
560
563
|
if (as === void 0) { as = null; }
|
|
561
564
|
if (foreignField === void 0) { foreignField = "_id"; }
|
|
562
565
|
if (shouldUnwind === void 0) { shouldUnwind = true; }
|
|
@@ -569,15 +572,31 @@
|
|
|
569
572
|
foreignField: foreignField,
|
|
570
573
|
as: as
|
|
571
574
|
}
|
|
572
|
-
}
|
|
573
|
-
|
|
575
|
+
}
|
|
576
|
+
];
|
|
577
|
+
if (shouldUnwind) {
|
|
578
|
+
pipelines.push({
|
|
574
579
|
$unwind: {
|
|
575
580
|
path: "$" + as,
|
|
576
581
|
preserveNullAndEmptyArrays: true
|
|
577
582
|
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
return pipelines;
|
|
586
|
+
}
|
|
587
|
+
function letsLookupStage(from, pipeline, as, letFields) {
|
|
588
|
+
if (as === void 0) { as = null; }
|
|
589
|
+
if (letFields === void 0) { letFields = null; }
|
|
590
|
+
as = as || from;
|
|
591
|
+
letFields = letFields || { id: "$_id" };
|
|
592
|
+
return {
|
|
593
|
+
$lookup: {
|
|
594
|
+
from: from,
|
|
595
|
+
let: letFields,
|
|
596
|
+
pipeline: pipeline,
|
|
597
|
+
as: as
|
|
578
598
|
}
|
|
579
|
-
|
|
580
|
-
return shouldUnwind ? pipelines : pipelines.slice(0, 0);
|
|
599
|
+
};
|
|
581
600
|
}
|
|
582
601
|
function hydratePopulated(modelType, json) {
|
|
583
602
|
var e_2, _a;
|
|
@@ -1152,6 +1171,10 @@
|
|
|
1152
1171
|
}
|
|
1153
1172
|
return "" + color + match + exports.ConsoleColor.Reset;
|
|
1154
1173
|
});
|
|
1174
|
+
}
|
|
1175
|
+
function replaceSpecialChars(str, to) {
|
|
1176
|
+
if (to === void 0) { to = "-"; }
|
|
1177
|
+
return ("" + str).replace(/[&\/\\#, +()$~%.@'":*?<>{}]/g, to);
|
|
1155
1178
|
}
|
|
1156
1179
|
|
|
1157
1180
|
var __decorate$x = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -2596,7 +2619,11 @@
|
|
|
2596
2619
|
this.apiPull.on("message", function (name, args) {
|
|
2597
2620
|
var message = name.toString("utf8");
|
|
2598
2621
|
var params = JSON.parse((args === null || args === void 0 ? void 0 : args.toString("utf8")) || "{}");
|
|
2599
|
-
|
|
2622
|
+
var paramTypes = Object.keys(params).reduce(function (res, key) {
|
|
2623
|
+
res[key] = getType(params[key]);
|
|
2624
|
+
return res;
|
|
2625
|
+
}, {});
|
|
2626
|
+
console.log("Received a message from worker: \"" + colorize(message, exports.ConsoleColor.FgCyan) + "\" with args: " + jsonHighlight(paramTypes) + "\n\n");
|
|
2600
2627
|
_this.messages.next({ message: message, params: params });
|
|
2601
2628
|
});
|
|
2602
2629
|
console.log("API consumer bound to port: " + backPort);
|
|
@@ -2604,7 +2631,7 @@
|
|
|
2604
2631
|
return this.tryResolve(jobType, params);
|
|
2605
2632
|
};
|
|
2606
2633
|
JobManager.prototype.resolveJobInstance = function (jobType, params, uniqueId) {
|
|
2607
|
-
if (uniqueId === void 0) { uniqueId =
|
|
2634
|
+
if (uniqueId === void 0) { uniqueId = ""; }
|
|
2608
2635
|
var container = this.container.createChildContainer();
|
|
2609
2636
|
Object.keys(params).map(function (name) {
|
|
2610
2637
|
container.register(name, { useValue: params[name] });
|
|
@@ -6074,6 +6101,8 @@
|
|
|
6074
6101
|
diContainer = parent.createChildContainer();
|
|
6075
6102
|
allProviders.forEach(function (provider) {
|
|
6076
6103
|
if (isType(provider)) {
|
|
6104
|
+
if (tsyringe.container.isRegistered(provider))
|
|
6105
|
+
return;
|
|
6077
6106
|
diContainer.register(provider, provider);
|
|
6078
6107
|
return;
|
|
6079
6108
|
}
|
|
@@ -6241,7 +6270,8 @@
|
|
|
6241
6270
|
exports.jsonHighlight = jsonHighlight;
|
|
6242
6271
|
exports.lastItem = lastItem;
|
|
6243
6272
|
exports.lcFirst = lcFirst;
|
|
6244
|
-
exports.
|
|
6273
|
+
exports.letsLookupStage = letsLookupStage;
|
|
6274
|
+
exports.lookupStages = lookupStages;
|
|
6245
6275
|
exports.md5 = md5;
|
|
6246
6276
|
exports.mkdirRecursive = mkdirRecursive;
|
|
6247
6277
|
exports.multiSubscription = multiSubscription;
|
|
@@ -6258,10 +6288,12 @@
|
|
|
6258
6288
|
exports.readAndDeleteFile = readAndDeleteFile;
|
|
6259
6289
|
exports.readFile = readFile;
|
|
6260
6290
|
exports.regroup = regroup;
|
|
6291
|
+
exports.replaceSpecialChars = replaceSpecialChars;
|
|
6261
6292
|
exports.runCommand = runCommand;
|
|
6262
6293
|
exports.setupBackend = setupBackend;
|
|
6263
6294
|
exports.streamToBuffer = streamToBuffer;
|
|
6264
6295
|
exports.ucFirst = ucFirst;
|
|
6296
|
+
exports.uniqueItems = uniqueItems;
|
|
6265
6297
|
exports.valueToPromise = valueToPromise;
|
|
6266
6298
|
exports.writeFile = writeFile;
|
|
6267
6299
|
|