@stemy/backend 2.9.0 → 2.9.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.
@@ -4574,36 +4574,42 @@
4574
4574
  });
4575
4575
  });
4576
4576
  };
4577
- AssetsController.prototype.getImageRotation = function (id, params, rotation) {
4577
+ AssetsController.prototype.getImageRotation = function (id, params, res, rotation) {
4578
4578
  if (rotation === void 0) { rotation = 0; }
4579
- var _a;
4580
4579
  return __awaiter$7(this, void 0, void 0, function () {
4581
4580
  var asset;
4582
4581
  return __generator(this, function (_c) {
4583
4582
  switch (_c.label) {
4584
- case 0: return [4 /*yield*/, this.assetResolver.resolve(id, params.lazy)];
4583
+ case 0: return [4 /*yield*/, this.getAsset("Asset", id, params.lazy, res)];
4585
4584
  case 1:
4586
4585
  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
4586
  params.rotation = params.rotation || rotation;
4594
4587
  return [2 /*return*/, asset.downloadImage(params)];
4595
4588
  }
4596
4589
  });
4597
4590
  });
4598
4591
  };
4599
- AssetsController.prototype.getImage = function (id, params) {
4592
+ AssetsController.prototype.getImage = function (id, params, res) {
4600
4593
  return __awaiter$7(this, void 0, void 0, function () {
4601
4594
  return __generator(this, function (_c) {
4602
- return [2 /*return*/, this.getImageRotation(id, params)];
4595
+ return [2 /*return*/, this.getImageRotation(id, params, res)];
4603
4596
  });
4604
4597
  });
4605
4598
  };
4606
4599
  AssetsController.prototype.getFile = function (id, lazy, res) {
4600
+ return __awaiter$7(this, void 0, void 0, function () {
4601
+ var asset;
4602
+ return __generator(this, function (_c) {
4603
+ switch (_c.label) {
4604
+ case 0: return [4 /*yield*/, this.getAsset("Asset", id, lazy, res)];
4605
+ case 1:
4606
+ asset = _c.sent();
4607
+ return [2 /*return*/, asset.download()];
4608
+ }
4609
+ });
4610
+ });
4611
+ };
4612
+ AssetsController.prototype.getAsset = function (type, id, lazy, res) {
4607
4613
  var _a, _b;
4608
4614
  return __awaiter$7(this, void 0, void 0, function () {
4609
4615
  var asset, ext;
@@ -4613,10 +4619,10 @@
4613
4619
  case 1:
4614
4620
  asset = _c.sent();
4615
4621
  if (!asset) {
4616
- throw new routingControllers.HttpError(404, "File with id: '" + id + "' not found.");
4622
+ throw new routingControllers.HttpError(404, type + " with id: '" + id + "' not found.");
4617
4623
  }
4618
4624
  if ((_a = asset.metadata) === null || _a === void 0 ? void 0 : _a.classified) {
4619
- throw new routingControllers.HttpError(403, "Asset is classified, and can be only downloaded from a custom url.");
4625
+ throw new routingControllers.HttpError(403, type + " is classified, and can be only downloaded from a custom url.");
4620
4626
  }
4621
4627
  ext = (_b = asset.metadata) === null || _b === void 0 ? void 0 : _b.extension;
4622
4628
  if (ext) {
@@ -4625,7 +4631,7 @@
4625
4631
  if (asset.contentType) {
4626
4632
  res.header("content-type", asset.contentType);
4627
4633
  }
4628
- return [2 /*return*/, asset.download()];
4634
+ return [2 /*return*/, asset];
4629
4635
  }
4630
4636
  });
4631
4637
  });
@@ -4650,16 +4656,16 @@
4650
4656
  ], AssetsController.prototype, "uploadUrl", null);
4651
4657
  __decorate$a([
4652
4658
  routingControllers.Get("/image/:id/:rotation"),
4653
- __param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Param("rotation")),
4659
+ __param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Res()), __param$5(3, routingControllers.Param("rotation")),
4654
4660
  __metadata$7("design:type", Function),
4655
- __metadata$7("design:paramtypes", [String, Object, Number]),
4661
+ __metadata$7("design:paramtypes", [String, Object, Object, Number]),
4656
4662
  __metadata$7("design:returntype", Promise)
4657
4663
  ], AssetsController.prototype, "getImageRotation", null);
4658
4664
  __decorate$a([
4659
4665
  routingControllers.Get("/image/:id"),
4660
- __param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()),
4666
+ __param$5(0, routingControllers.Param("id")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Res()),
4661
4667
  __metadata$7("design:type", Function),
4662
- __metadata$7("design:paramtypes", [String, Object]),
4668
+ __metadata$7("design:paramtypes", [String, Object, Object]),
4663
4669
  __metadata$7("design:returntype", Promise)
4664
4670
  ], AssetsController.prototype, "getImage", null);
4665
4671
  __decorate$a([