@stemy/backend 2.9.0 → 2.9.4
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 +27 -22
- 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 +1 -0
- package/esm2015/common-types.js +1 -1
- package/esm2015/rest-controllers/assets.controller.js +18 -19
- package/esm2015/services/assets.js +2 -3
- package/esm2015/services/progresses.js +2 -2
- package/fesm2015/stemy-backend.js +20 -22
- package/fesm2015/stemy-backend.js.map +1 -1
- package/package.json +2 -2
- package/rest-controllers/assets.controller.d.ts +5 -4
|
@@ -1947,18 +1947,17 @@
|
|
|
1947
1947
|
};
|
|
1948
1948
|
Assets.prototype.upload = function (stream, fileType, metadata) {
|
|
1949
1949
|
return __awaiter$q(this, void 0, void 0, function () {
|
|
1950
|
-
var contentType
|
|
1950
|
+
var contentType;
|
|
1951
1951
|
var _this = this;
|
|
1952
1952
|
return __generator(this, function (_b) {
|
|
1953
1953
|
contentType = fileType.mime.trim();
|
|
1954
|
-
extension = (fileType.ext || "").trim();
|
|
1955
1954
|
metadata = Object.assign({
|
|
1956
|
-
extension: extension,
|
|
1957
1955
|
downloadCount: 0,
|
|
1958
1956
|
firstDownload: null,
|
|
1959
1957
|
lastDownload: null
|
|
1960
1958
|
}, metadata || {});
|
|
1961
1959
|
metadata.filename = metadata.filename || new bson.ObjectId().toHexString();
|
|
1960
|
+
metadata.extension = (fileType.ext || "").trim();
|
|
1962
1961
|
return [2 /*return*/, new Promise((function (resolve, reject) {
|
|
1963
1962
|
var uploaderStream = _this.bucket.openUploadStream(metadata.filename);
|
|
1964
1963
|
stream.pipe(uploaderStream)
|
|
@@ -2890,7 +2889,7 @@
|
|
|
2890
2889
|
}
|
|
2891
2890
|
isFinished = progress.percent == 100;
|
|
2892
2891
|
if (!!isFinished) return [3 /*break*/, 4];
|
|
2893
|
-
return [4 /*yield*/, promiseTimeout(
|
|
2892
|
+
return [4 /*yield*/, promiseTimeout(50)];
|
|
2894
2893
|
case 3:
|
|
2895
2894
|
_a.sent();
|
|
2896
2895
|
_a.label = 4;
|
|
@@ -4574,36 +4573,42 @@
|
|
|
4574
4573
|
});
|
|
4575
4574
|
});
|
|
4576
4575
|
};
|
|
4577
|
-
AssetsController.prototype.getImageRotation = function (id, params, rotation) {
|
|
4576
|
+
AssetsController.prototype.getImageRotation = function (id, params, res, rotation) {
|
|
4578
4577
|
if (rotation === void 0) { rotation = 0; }
|
|
4579
|
-
var _a;
|
|
4580
4578
|
return __awaiter$7(this, void 0, void 0, function () {
|
|
4581
4579
|
var asset;
|
|
4582
4580
|
return __generator(this, function (_c) {
|
|
4583
4581
|
switch (_c.label) {
|
|
4584
|
-
case 0: return [4 /*yield*/, this.
|
|
4582
|
+
case 0: return [4 /*yield*/, this.getAsset("Image", id, params.lazy, res)];
|
|
4585
4583
|
case 1:
|
|
4586
4584
|
asset = _c.sent();
|
|
4587
|
-
if (!asset) {
|
|
4588
|
-
throw new routingControllers.HttpError(404, "Image with id: '" + id + "' not found.");
|
|
4589
|
-
}
|
|
4590
|
-
if ((_a = asset.metadata) === null || _a === void 0 ? void 0 : _a.classified) {
|
|
4591
|
-
throw new routingControllers.HttpError(403, "Image is classified, and can be only downloaded from a custom url.");
|
|
4592
|
-
}
|
|
4593
4585
|
params.rotation = params.rotation || rotation;
|
|
4594
4586
|
return [2 /*return*/, asset.downloadImage(params)];
|
|
4595
4587
|
}
|
|
4596
4588
|
});
|
|
4597
4589
|
});
|
|
4598
4590
|
};
|
|
4599
|
-
AssetsController.prototype.getImage = function (id, params) {
|
|
4591
|
+
AssetsController.prototype.getImage = function (id, params, res) {
|
|
4600
4592
|
return __awaiter$7(this, void 0, void 0, function () {
|
|
4601
4593
|
return __generator(this, function (_c) {
|
|
4602
|
-
return [2 /*return*/, this.getImageRotation(id, params)];
|
|
4594
|
+
return [2 /*return*/, this.getImageRotation(id, params, res)];
|
|
4603
4595
|
});
|
|
4604
4596
|
});
|
|
4605
4597
|
};
|
|
4606
4598
|
AssetsController.prototype.getFile = function (id, lazy, res) {
|
|
4599
|
+
return __awaiter$7(this, void 0, void 0, function () {
|
|
4600
|
+
var asset;
|
|
4601
|
+
return __generator(this, function (_c) {
|
|
4602
|
+
switch (_c.label) {
|
|
4603
|
+
case 0: return [4 /*yield*/, this.getAsset("Asset", id, lazy, res)];
|
|
4604
|
+
case 1:
|
|
4605
|
+
asset = _c.sent();
|
|
4606
|
+
return [2 /*return*/, asset.download()];
|
|
4607
|
+
}
|
|
4608
|
+
});
|
|
4609
|
+
});
|
|
4610
|
+
};
|
|
4611
|
+
AssetsController.prototype.getAsset = function (type, id, lazy, res) {
|
|
4607
4612
|
var _a, _b;
|
|
4608
4613
|
return __awaiter$7(this, void 0, void 0, function () {
|
|
4609
4614
|
var asset, ext;
|
|
@@ -4613,10 +4618,10 @@
|
|
|
4613
4618
|
case 1:
|
|
4614
4619
|
asset = _c.sent();
|
|
4615
4620
|
if (!asset) {
|
|
4616
|
-
throw new routingControllers.HttpError(404, "
|
|
4621
|
+
throw new routingControllers.HttpError(404, type + " with id: '" + id + "' not found.");
|
|
4617
4622
|
}
|
|
4618
4623
|
if ((_a = asset.metadata) === null || _a === void 0 ? void 0 : _a.classified) {
|
|
4619
|
-
throw new routingControllers.HttpError(403, "
|
|
4624
|
+
throw new routingControllers.HttpError(403, type + " is classified, and can be only downloaded from a custom url.");
|
|
4620
4625
|
}
|
|
4621
4626
|
ext = (_b = asset.metadata) === null || _b === void 0 ? void 0 : _b.extension;
|
|
4622
4627
|
if (ext) {
|
|
@@ -4625,7 +4630,7 @@
|
|
|
4625
4630
|
if (asset.contentType) {
|
|
4626
4631
|
res.header("content-type", asset.contentType);
|
|
4627
4632
|
}
|
|
4628
|
-
return [2 /*return*/, asset
|
|
4633
|
+
return [2 /*return*/, asset];
|
|
4629
4634
|
}
|
|
4630
4635
|
});
|
|
4631
4636
|
});
|
|
@@ -4650,16 +4655,16 @@
|
|
|
4650
4655
|
], AssetsController.prototype, "uploadUrl", null);
|
|
4651
4656
|
__decorate$a([
|
|
4652
4657
|
routingControllers.Get("/image/:id/:rotation"),
|
|
4653
|
-
__param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Param("rotation")),
|
|
4658
|
+
__param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Res()), __param$5(3, routingControllers.Param("rotation")),
|
|
4654
4659
|
__metadata$7("design:type", Function),
|
|
4655
|
-
__metadata$7("design:paramtypes", [String, Object, Number]),
|
|
4660
|
+
__metadata$7("design:paramtypes", [String, Object, Object, Number]),
|
|
4656
4661
|
__metadata$7("design:returntype", Promise)
|
|
4657
4662
|
], AssetsController.prototype, "getImageRotation", null);
|
|
4658
4663
|
__decorate$a([
|
|
4659
4664
|
routingControllers.Get("/image/:id"),
|
|
4660
|
-
__param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()),
|
|
4665
|
+
__param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Res()),
|
|
4661
4666
|
__metadata$7("design:type", Function),
|
|
4662
|
-
__metadata$7("design:paramtypes", [String, Object]),
|
|
4667
|
+
__metadata$7("design:paramtypes", [String, Object, Object]),
|
|
4663
4668
|
__metadata$7("design:returntype", Promise)
|
|
4664
4669
|
], AssetsController.prototype, "getImage", null);
|
|
4665
4670
|
__decorate$a([
|