itlab-internal-services 1.11.2 → 1.12.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.
@@ -1,9 +1,7 @@
1
1
  import { ModuleMetadata, Provider, Type } from '@nestjs/common';
2
- import { Targets } from '../pipes/target.pipe';
3
2
  export declare type InternalModuleOptions = {
4
3
  jwt_secret: string;
5
4
  token: string;
6
- target: Targets;
7
5
  };
8
6
  export interface InternalModuleOptionsFactory {
9
7
  createInternalOptions(): Promise<InternalModuleOptions> | InternalModuleOptions;
@@ -1,6 +1,5 @@
1
1
  export declare const AXIOS_INSTANCE_TOKEN = "AXIOS_INSTANCE_TOKEN";
2
2
  export declare const INTERNAL_MODULE_ID = "INTERNAL_MODULE_ID";
3
3
  export declare const INTERNAL_MODULE_OPTIONS = "INTERNAL_MODULE_OPTIONS";
4
- export declare const INTERNAL_MODULE_TARGET = "INTERNAL_MODULE_TARGET";
5
4
  export declare const INTERNAL_MODULE_JWT_SECRET = "INTERNAL_MODULE_JWT_SECRET";
6
5
  export declare const INTERNAL_MODULE_HEADER_TOKEN = "INTERNAL_MODULE_HEADER_TOKEN";
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INTERNAL_MODULE_HEADER_TOKEN = exports.INTERNAL_MODULE_JWT_SECRET = exports.INTERNAL_MODULE_TARGET = exports.INTERNAL_MODULE_OPTIONS = exports.INTERNAL_MODULE_ID = exports.AXIOS_INSTANCE_TOKEN = void 0;
3
+ exports.INTERNAL_MODULE_HEADER_TOKEN = exports.INTERNAL_MODULE_JWT_SECRET = exports.INTERNAL_MODULE_OPTIONS = exports.INTERNAL_MODULE_ID = exports.AXIOS_INSTANCE_TOKEN = void 0;
4
4
  exports.AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN';
5
5
  exports.INTERNAL_MODULE_ID = 'INTERNAL_MODULE_ID';
6
6
  exports.INTERNAL_MODULE_OPTIONS = 'INTERNAL_MODULE_OPTIONS';
7
- exports.INTERNAL_MODULE_TARGET = 'INTERNAL_MODULE_TARGET';
8
7
  exports.INTERNAL_MODULE_JWT_SECRET = 'INTERNAL_MODULE_JWT_SECRET';
9
8
  exports.INTERNAL_MODULE_HEADER_TOKEN = 'INTERNAL_MODULE_HEADER_TOKEN';
@@ -37,7 +37,6 @@ let InternalModule = InternalModule_1 = class InternalModule {
37
37
  providers: [
38
38
  { provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue: createAxios(options.token) },
39
39
  { provide: internal_constants_1.INTERNAL_MODULE_ID, useValue: (0, random_string_generator_util_1.randomStringGenerator)() },
40
- { provide: internal_constants_1.INTERNAL_MODULE_TARGET, useValue: options.target },
41
40
  { provide: internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN, useValue: options.token },
42
41
  { provide: internal_constants_1.INTERNAL_MODULE_JWT_SECRET, useValue: options.jwt_secret },
43
42
  ],
@@ -58,11 +57,6 @@ let InternalModule = InternalModule_1 = class InternalModule {
58
57
  provide: internal_constants_1.INTERNAL_MODULE_ID,
59
58
  useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
60
59
  },
61
- {
62
- provide: internal_constants_1.INTERNAL_MODULE_TARGET,
63
- useFactory: (config) => config.target,
64
- inject: [internal_constants_1.INTERNAL_MODULE_OPTIONS],
65
- },
66
60
  {
67
61
  provide: internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN,
68
62
  useFactory: (config) => config.token,
@@ -113,7 +107,6 @@ InternalModule = InternalModule_1 = __decorate([
113
107
  services_1.MailService,
114
108
  services_1.AccountService,
115
109
  { provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue: axios_1.default },
116
- { provide: internal_constants_1.INTERNAL_MODULE_TARGET, useValue: '' },
117
110
  { provide: internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN, useValue: '' },
118
111
  { provide: internal_constants_1.INTERNAL_MODULE_JWT_SECRET, useValue: '' },
119
112
  guards_1.JwtStrategy,
@@ -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) => {
@@ -8,9 +8,8 @@ export declare class Comment {
8
8
  }
9
9
  export declare class CommentService {
10
10
  protected readonly instance: AxiosInstance;
11
- protected readonly target: Targets;
12
- constructor(instance?: AxiosInstance, target?: Targets);
11
+ constructor(instance?: AxiosInstance);
13
12
  protected prefix: string;
14
- post(targetId: string, authorId: string, comment: ContentRichtext, target?: Targets): Promise<Comment>;
15
- delete(targetId: string, target?: Targets): Promise<void>;
13
+ post(targetId: string, authorId: string, comment: ContentRichtext, target: Targets): Promise<Comment>;
14
+ delete(targetId: string, target: Targets): Promise<void>;
16
15
  }
@@ -29,7 +29,6 @@ const common_1 = require("@nestjs/common");
29
29
  const swagger_1 = require("@nestjs/swagger");
30
30
  const axios_1 = __importDefault(require("axios"));
31
31
  const internal_constants_1 = require("../internal.constants");
32
- const target_pipe_1 = require("../pipes/target.pipe");
33
32
  class Comment {
34
33
  }
35
34
  __decorate([
@@ -46,12 +45,11 @@ __decorate([
46
45
  ], Comment.prototype, "richtext", void 0);
47
46
  exports.Comment = Comment;
48
47
  let CommentService = class CommentService {
49
- constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
48
+ constructor(instance = axios_1.default) {
50
49
  this.instance = instance;
51
- this.target = target;
52
50
  this.prefix = 'comment/internal';
53
51
  }
54
- post(targetId, authorId, comment, target = this.target) {
52
+ post(targetId, authorId, comment, target) {
55
53
  return __awaiter(this, void 0, void 0, function* () {
56
54
  return new Promise((resolve, reject) => {
57
55
  this.instance
@@ -61,7 +59,7 @@ let CommentService = class CommentService {
61
59
  });
62
60
  });
63
61
  }
64
- delete(targetId, target = this.target) {
62
+ delete(targetId, target) {
65
63
  return __awaiter(this, void 0, void 0, function* () {
66
64
  return new Promise((resolve, reject) => {
67
65
  this.instance
@@ -74,7 +72,6 @@ let CommentService = class CommentService {
74
72
  };
75
73
  CommentService = __decorate([
76
74
  __param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
77
- __param(1, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_TARGET)),
78
- __metadata("design:paramtypes", [Function, String])
75
+ __metadata("design:paramtypes", [Function])
79
76
  ], CommentService);
80
77
  exports.CommentService = CommentService;
@@ -3,11 +3,10 @@ import { Content } from 'itlab-functions';
3
3
  import { Targets } from '../pipes/target.pipe';
4
4
  export declare class ContentService {
5
5
  protected readonly instance: AxiosInstance;
6
- protected readonly target: Targets;
7
- constructor(instance?: AxiosInstance, target?: Targets);
6
+ constructor(instance?: AxiosInstance);
8
7
  private logger;
9
8
  protected prefix: string;
10
9
  verify(content: Content): Promise<void>;
11
- post(targetId: string, content: Content, target?: Targets): Promise<string>;
12
- delete(targetId: string, target?: Targets): Promise<void>;
10
+ post(targetId: string, content: Content, target: Targets): Promise<string>;
11
+ delete(targetId: string, target: Targets): Promise<void>;
13
12
  }
@@ -28,11 +28,9 @@ exports.ContentService = void 0;
28
28
  const common_1 = require("@nestjs/common");
29
29
  const axios_1 = __importDefault(require("axios"));
30
30
  const internal_constants_1 = require("../internal.constants");
31
- const target_pipe_1 = require("../pipes/target.pipe");
32
31
  let ContentService = class ContentService {
33
- constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
32
+ constructor(instance = axios_1.default) {
34
33
  this.instance = instance;
35
- this.target = target;
36
34
  this.logger = new common_1.Logger(ContentService.name);
37
35
  this.prefix = 'content/internal';
38
36
  }
@@ -46,7 +44,7 @@ let ContentService = class ContentService {
46
44
  });
47
45
  });
48
46
  }
49
- post(targetId, content, target = this.target) {
47
+ post(targetId, content, target) {
50
48
  return __awaiter(this, void 0, void 0, function* () {
51
49
  return new Promise((resolve, reject) => {
52
50
  this.instance
@@ -56,7 +54,7 @@ let ContentService = class ContentService {
56
54
  });
57
55
  });
58
56
  }
59
- delete(targetId, target = this.target) {
57
+ delete(targetId, target) {
60
58
  return __awaiter(this, void 0, void 0, function* () {
61
59
  return new Promise((resolve, reject) => {
62
60
  this.instance
@@ -69,7 +67,6 @@ let ContentService = class ContentService {
69
67
  };
70
68
  ContentService = __decorate([
71
69
  __param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
72
- __param(1, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_TARGET)),
73
- __metadata("design:paramtypes", [Function, String])
70
+ __metadata("design:paramtypes", [Function])
74
71
  ], ContentService);
75
72
  exports.ContentService = ContentService;
@@ -8,10 +8,9 @@ export declare class SearchableDocument {
8
8
  }
9
9
  export declare class SearchService {
10
10
  protected readonly instance: AxiosInstance;
11
- protected readonly target: Targets;
12
- constructor(instance?: AxiosInstance, target?: Targets);
11
+ constructor(instance?: AxiosInstance);
13
12
  private logger;
14
13
  protected prefix: string;
15
- index(targetId: string, document: SearchableDocument, target?: Targets): void;
16
- remove(targetId: string, target?: Targets): void;
14
+ index(targetId: string, document: SearchableDocument, target: Targets): void;
15
+ remove(targetId: string, target: Targets): void;
17
16
  }
@@ -20,7 +20,6 @@ const common_1 = require("@nestjs/common");
20
20
  const swagger_1 = require("@nestjs/swagger");
21
21
  const axios_1 = __importDefault(require("axios"));
22
22
  const internal_constants_1 = require("../internal.constants");
23
- const target_pipe_1 = require("../pipes/target.pipe");
24
23
  class SearchableDocument {
25
24
  }
26
25
  __decorate([
@@ -41,19 +40,18 @@ __decorate([
41
40
  ], SearchableDocument.prototype, "data", void 0);
42
41
  exports.SearchableDocument = SearchableDocument;
43
42
  let SearchService = class SearchService {
44
- constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
43
+ constructor(instance = axios_1.default) {
45
44
  this.instance = instance;
46
- this.target = target;
47
45
  this.logger = new common_1.Logger(SearchService.name);
48
46
  this.prefix = 'search/internal';
49
47
  }
50
- index(targetId, document, target = this.target) {
48
+ index(targetId, document, target) {
51
49
  this.instance
52
50
  .post(`${this.prefix}/${target}/${targetId}`, document)
53
51
  .then(() => this.logger.log(`Sucessfully indexed ${targetId} in ${target}`))
54
52
  .catch((error) => this.logger.error(`Couldn't index ${targetId} in ${target}`, error));
55
53
  }
56
- remove(targetId, target = this.target) {
54
+ remove(targetId, target) {
57
55
  this.instance
58
56
  .delete(`${this.prefix}/${target}/${targetId}`)
59
57
  .then(() => this.logger.log(`Sucessfully removed ${targetId} in ${target}`))
@@ -62,7 +60,6 @@ let SearchService = class SearchService {
62
60
  };
63
61
  SearchService = __decorate([
64
62
  __param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
65
- __param(1, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_TARGET)),
66
- __metadata("design:paramtypes", [Function, String])
63
+ __metadata("design:paramtypes", [Function])
67
64
  ], SearchService);
68
65
  exports.SearchService = SearchService;
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.11.2",
8
+ "version": "1.12.1",
9
9
  "type": "commonjs",
10
10
  "files": [
11
11
  "dist"