itlab-internal-services 1.12.0 → 1.12.2

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.
@@ -12,8 +12,7 @@ export declare enum Targets {
12
12
  HACKSCHOOL_COURSE = "hackschool-course",
13
13
  TEAM_MEMBER = "team-member",
14
14
  HUB_USER = "hub-user",
15
- HUB_FILE = "hub-file",
16
- UNKNOWN = "unknown"
15
+ HUB_FILE = "hub-file"
17
16
  }
18
17
  export declare class InvalidTargetException extends HttpException {
19
18
  constructor(param: string);
@@ -18,7 +18,6 @@ var Targets;
18
18
  Targets["TEAM_MEMBER"] = "team-member";
19
19
  Targets["HUB_USER"] = "hub-user";
20
20
  Targets["HUB_FILE"] = "hub-file";
21
- Targets["UNKNOWN"] = "unknown";
22
21
  })(Targets = exports.Targets || (exports.Targets = {}));
23
22
  function generateExamples() {
24
23
  const map = {};
@@ -4,6 +4,5 @@ export declare class AccountService {
4
4
  protected readonly instance: AxiosInstance;
5
5
  constructor(instance?: AxiosInstance);
6
6
  protected prefix: string;
7
- create(accountId: string, email: string): Promise<void>;
8
7
  get(accountId: string): Promise<AccountInformation>;
9
8
  }
@@ -33,16 +33,6 @@ let AccountService = class AccountService {
33
33
  this.instance = instance;
34
34
  this.prefix = 'account/internal';
35
35
  }
36
- create(accountId, email) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return new Promise((resolve, reject) => {
39
- this.instance
40
- .post(`${this.prefix}`, { accountId, email })
41
- .then(() => resolve())
42
- .catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
43
- });
44
- });
45
- }
46
36
  get(accountId) {
47
37
  return __awaiter(this, void 0, void 0, function* () {
48
38
  return new Promise((resolve) => {
@@ -9,6 +9,7 @@ export declare class Comment {
9
9
  export declare class CommentService {
10
10
  protected readonly instance: AxiosInstance;
11
11
  constructor(instance?: AxiosInstance);
12
+ private logger;
12
13
  protected prefix: string;
13
14
  post(targetId: string, authorId: string, comment: ContentRichtext, target: Targets): Promise<Comment>;
14
15
  delete(targetId: string, target: Targets): Promise<void>;
@@ -47,25 +47,40 @@ exports.Comment = Comment;
47
47
  let CommentService = class CommentService {
48
48
  constructor(instance = axios_1.default) {
49
49
  this.instance = instance;
50
+ this.logger = new common_1.Logger(CommentService.name);
50
51
  this.prefix = 'comment/internal';
51
52
  }
52
53
  post(targetId, authorId, comment, target) {
53
54
  return __awaiter(this, void 0, void 0, function* () {
55
+ this.logger.log(`Posting comment for ${target} (${targetId}) by ${authorId}`);
54
56
  return new Promise((resolve, reject) => {
55
57
  this.instance
56
58
  .post(`${this.prefix}/${target}/${targetId}/${authorId}`, comment)
57
- .then(({ data }) => resolve(data))
58
- .catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
59
+ .then(({ data }) => {
60
+ this.logger.log(`Comment for ${target} (${targetId}) posted`);
61
+ resolve(data);
62
+ })
63
+ .catch(({ response }) => {
64
+ this.logger.error(`Couldn't post comment for ${target} (${targetId})`, response.data);
65
+ reject(new common_1.HttpException(response.data, response.status));
66
+ });
59
67
  });
60
68
  });
61
69
  }
62
70
  delete(targetId, target) {
63
71
  return __awaiter(this, void 0, void 0, function* () {
72
+ this.logger.log(`Deleting all comments for ${target} (${targetId})`);
64
73
  return new Promise((resolve, reject) => {
65
74
  this.instance
66
75
  .delete(`${this.prefix}/${target}/${targetId}`)
67
- .then(() => resolve())
68
- .catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
76
+ .then(() => {
77
+ this.logger.log(`All comments for ${target} (${targetId}) deleted`);
78
+ resolve();
79
+ })
80
+ .catch(({ response }) => {
81
+ this.logger.error(`Couldn't delete all comments for ${target} (${targetId})`, response.data);
82
+ reject(new common_1.HttpException(response.data, response.status));
83
+ });
69
84
  });
70
85
  });
71
86
  }
@@ -36,31 +36,52 @@ let ContentService = class ContentService {
36
36
  }
37
37
  verify(content) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
+ this.logger.log('Verifing content');
39
40
  return new Promise((resolve, reject) => {
40
41
  this.instance
41
42
  .post(`${this.prefix}/verify`, { content })
42
- .then(() => resolve())
43
- .catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
43
+ .then(() => {
44
+ this.logger.log('Content is valid');
45
+ resolve();
46
+ })
47
+ .catch(({ response }) => {
48
+ this.logger.error('Content is invalid', response.data);
49
+ reject(new common_1.HttpException(response.data, response.status));
50
+ });
44
51
  });
45
52
  });
46
53
  }
47
54
  post(targetId, content, target) {
48
55
  return __awaiter(this, void 0, void 0, function* () {
56
+ this.logger.log(`Posting content of ${target} (${targetId})`);
49
57
  return new Promise((resolve, reject) => {
50
58
  this.instance
51
59
  .post(`${this.prefix}/${target}/${targetId}`, { content })
52
- .then(({ data }) => resolve(data))
53
- .catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
60
+ .then(({ data }) => {
61
+ this.logger.log(`Content of ${target} (${targetId}) posted`);
62
+ resolve(data);
63
+ })
64
+ .catch(({ response }) => {
65
+ this.logger.error(`Couldn't post content of ${target} (${targetId})...`, response.data);
66
+ reject(new common_1.HttpException(response.data, response.status));
67
+ });
54
68
  });
55
69
  });
56
70
  }
57
71
  delete(targetId, target) {
58
72
  return __awaiter(this, void 0, void 0, function* () {
73
+ this.logger.log(`Deleting content of ${target} (${targetId})`);
59
74
  return new Promise((resolve, reject) => {
60
75
  this.instance
61
76
  .delete(`${this.prefix}/${target}/${targetId}`)
62
- .then(() => resolve())
63
- .catch(({ response }) => reject(new common_1.HttpException(response.data, response.status)));
77
+ .then(() => {
78
+ this.logger.log(`Content of ${target} (${targetId}) deleted`);
79
+ resolve();
80
+ })
81
+ .catch(({ response }) => {
82
+ this.logger.error(`Couldn't delete content of ${target} (${targetId})...`, response.data);
83
+ reject(new common_1.HttpException(response.data, response.status));
84
+ });
64
85
  });
65
86
  });
66
87
  }
@@ -26,10 +26,11 @@ let MailService = class MailService {
26
26
  this.prefix = 'email/internal';
27
27
  }
28
28
  sendToken(token, address) {
29
+ this.logger.log('Sending token');
29
30
  this.instance
30
31
  .post(`${this.prefix}/token`, { token, address })
31
32
  .then(() => this.logger.log('Token sent'))
32
- .catch((error) => this.logger.error("Couldn't send token", error));
33
+ .catch(({ response }) => this.logger.error("Couldn't send token...", response.data));
33
34
  }
34
35
  };
35
36
  MailService = __decorate([
@@ -46,16 +46,18 @@ let SearchService = class SearchService {
46
46
  this.prefix = 'search/internal';
47
47
  }
48
48
  index(targetId, document, target) {
49
+ this.logger.log(`Indexing ${target} (${targetId})`);
49
50
  this.instance
50
51
  .post(`${this.prefix}/${target}/${targetId}`, document)
51
- .then(() => this.logger.log(`Sucessfully indexed ${targetId} in ${target}`))
52
- .catch((error) => this.logger.error(`Couldn't index ${targetId} in ${target}`, error));
52
+ .then(() => this.logger.log(`Sucessfully indexed ${target} (${targetId})`))
53
+ .catch(({ response }) => this.logger.error(`Couldn't index ${target} (${targetId})`, response.data));
53
54
  }
54
55
  remove(targetId, target) {
56
+ this.logger.log(`Removing ${target} (${targetId})`);
55
57
  this.instance
56
58
  .delete(`${this.prefix}/${target}/${targetId}`)
57
- .then(() => this.logger.log(`Sucessfully removed ${targetId} in ${target}`))
58
- .catch((error) => this.logger.error(`Couldn't remove ${targetId} in ${target}`, error));
59
+ .then(() => this.logger.log(`Sucessfully removed ${target} (${targetId})`))
60
+ .catch(({ response }) => this.logger.error(`Couldn't remove ${target} (${targetId})`, response.data));
59
61
  }
60
62
  };
61
63
  SearchService = __decorate([
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "timo.scheuermann@sv-informatik.de",
6
6
  "url": "https://timos.design"
7
7
  },
8
- "version": "1.12.0",
8
+ "version": "1.12.2",
9
9
  "type": "commonjs",
10
10
  "files": [
11
11
  "dist"