@clairejs/server 3.25.5 → 3.26.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/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Change Log
2
2
 
3
+ #### 3.26.0
4
+
5
+ - update file upload handler
6
+
7
+ - update packages, remove exit code
8
+
3
9
  #### 3.25.5
4
10
 
5
11
  - update packages, remove exit code
@@ -1,8 +1,10 @@
1
1
  import { AbstractFileService } from "../../services/AbstractFileService";
2
2
  import { AbstractFileUploadHandler } from "./AbstractFileUploadHandler";
3
3
  export declare class FileUploadHandler extends AbstractFileUploadHandler {
4
- readonly fileService: AbstractFileService;
5
- constructor(fileService: AbstractFileService);
4
+ private readonly fileService;
5
+ private readonly prefix;
6
+ constructor(fileService: AbstractFileService, prefix?: string);
7
+ protected getPath(uri: string): string;
6
8
  moveFile(fromURI: string, toURI: string): Promise<void>;
7
9
  copyFile(fromURI: string, toURI: string): Promise<void>;
8
10
  removeFile(uri: string): Promise<void>;
@@ -1,41 +1,30 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Injectable } from "@clairejs/core";
11
- import { AbstractFileService } from "../../services/AbstractFileService";
12
1
  import { AbstractFileUploadHandler } from "./AbstractFileUploadHandler";
13
- let FileUploadHandler = class FileUploadHandler extends AbstractFileUploadHandler {
2
+ export class FileUploadHandler extends AbstractFileUploadHandler {
14
3
  fileService;
15
- constructor(fileService) {
4
+ prefix;
5
+ constructor(fileService, prefix = "") {
16
6
  super();
17
7
  this.fileService = fileService;
8
+ this.prefix = prefix;
9
+ }
10
+ getPath(uri) {
11
+ return `${this.prefix}${uri}`;
18
12
  }
19
13
  async moveFile(fromURI, toURI) {
20
- await this.fileService.moveObject([{ fromURI, toURI }]);
14
+ await this.fileService.moveObject([{ fromURI: this.getPath(fromURI), toURI: this.getPath(toURI) }]);
21
15
  }
22
16
  async copyFile(fromURI, toURI) {
23
- await this.fileService.copyObject([{ fromURI, toURI }]);
17
+ await this.fileService.copyObject([{ fromURI: this.getPath(fromURI), toURI: this.getPath(toURI) }]);
24
18
  }
25
19
  async removeFile(uri) {
26
- await this.fileService.removeObject([uri]);
20
+ await this.fileService.removeObject([this.getPath(uri)]);
27
21
  }
28
22
  async resolvePublicUrl(uri) {
29
- const result = await this.fileService.getAccessUrls([uri], true);
23
+ const result = await this.fileService.getAccessUrls([this.getPath(uri)], true);
30
24
  return result[0];
31
25
  }
32
26
  async resolvePrivateUrl(uri) {
33
- const result = await this.fileService.getAccessUrls([uri], false);
27
+ const result = await this.fileService.getAccessUrls([this.getPath(uri)], false);
34
28
  return result[0];
35
29
  }
36
- };
37
- FileUploadHandler = __decorate([
38
- Injectable(),
39
- __metadata("design:paramtypes", [AbstractFileService])
40
- ], FileUploadHandler);
41
- export { FileUploadHandler };
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.25.5",
3
+ "version": "3.26.0",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",