@rsdk/nest-tools 1.0.12 → 2.4.1-next.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/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.4.1-next.0](https://github.com/R-Vision/rsdk/compare/v2.4.0...v2.4.1-next.0) (2023-06-15)
7
+
8
+ **Note:** Version bump only for package @rsdk/nest-tools
9
+
10
+ # [2.0.0](https://github.com/R-Vision/rsdk/compare/v1.0.12...v2.0.0) (2023-06-06)
11
+
12
+ ### Draft
13
+
14
+ * Pfm 303 static to meta migration ([#45](https://github.com/R-Vision/rsdk/issues/45)) ([d98e303](https://github.com/R-Vision/rsdk/commit/d98e3032f9b10446b478427d841b9209ed68fa2d))
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * GrpcClientModule removed
19
+ new way for declaration with `GrpcServers.define()` and `@InjectGrpcClient`
20
+
21
+ * fix: rework interaction with metadata and generating modules from metadata
22
+
23
+ * refactor: destructring added
24
+
25
+ * docs: added docs for autodoc pre-commit hook
26
+
27
+ * chore: spell fix
28
+
29
+ * chore: some improves declaration
30
+
31
+ * chore: laconic naming for constants
32
+
33
+ * chore: remove useless
34
+
35
+ * chore: move file to suitable place
36
+
37
+ * chore: remove useless imports
38
+
39
+ * chore!: remove boostrap tasks from Makefile
40
+
41
+ * chore: rework test tasks
42
+
43
+ * feat: grpc client plugin useless
44
+
45
+ * chore: verbosed naming
46
+
47
+ * docs: improve verbosity
48
+
6
49
  ## 1.0.12 (2023-05-23)
7
50
 
8
51
  ### Bug Fixes
package/dist/constants.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NestDefinitionType = void 0;
4
4
  var NestDefinitionType;
5
5
  (function (NestDefinitionType) {
6
+ // eslint-disable-next-line unicorn/prefer-math-trunc
6
7
  NestDefinitionType[NestDefinitionType["Module"] = 1] = "Module";
7
8
  NestDefinitionType[NestDefinitionType["Controllers"] = 2] = "Controllers";
8
9
  NestDefinitionType[NestDefinitionType["Providers"] = 4] = "Providers";
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { NestDefinitionType } from './constants';
2
- export { NestDefinitionMediator } from './nest-definition.mediator';
2
+ export { NestDefinitionIterator } from './nest-definition.iterator';
3
3
  export { NestDefinition } from './nest-definition';
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NestDefinition = exports.NestDefinitionMediator = exports.NestDefinitionType = void 0;
3
+ exports.NestDefinition = exports.NestDefinitionIterator = exports.NestDefinitionType = void 0;
4
4
  var constants_1 = require("./constants");
5
5
  Object.defineProperty(exports, "NestDefinitionType", { enumerable: true, get: function () { return constants_1.NestDefinitionType; } });
6
- var nest_definition_mediator_1 = require("./nest-definition.mediator");
7
- Object.defineProperty(exports, "NestDefinitionMediator", { enumerable: true, get: function () { return nest_definition_mediator_1.NestDefinitionMediator; } });
6
+ var nest_definition_iterator_1 = require("./nest-definition.iterator");
7
+ Object.defineProperty(exports, "NestDefinitionIterator", { enumerable: true, get: function () { return nest_definition_iterator_1.NestDefinitionIterator; } });
8
8
  var nest_definition_1 = require("./nest-definition");
9
9
  Object.defineProperty(exports, "NestDefinition", { enumerable: true, get: function () { return nest_definition_1.NestDefinition; } });
@@ -3,8 +3,6 @@ export type NestModuleDefinition = DynamicModule | Type;
3
3
  /**
4
4
  * Хелпер для работы с объявлением модуля nest.
5
5
  * Получения провайдеров и импортов
6
- *
7
- * TODO: Объяснить что это за нафиг?
8
6
  */
9
7
  export declare class NestDefinition {
10
8
  private definition;
@@ -1,8 +1,13 @@
1
1
  import type { Provider } from '@nestjs/common';
2
+ import type { Promisable } from 'type-fest';
2
3
  import { NestDefinitionType } from './constants';
3
4
  import type { NestModuleDefinition } from './nest-definition';
4
- export declare class NestDefinitionMediator {
5
+ export declare class NestDefinitionIterator {
5
6
  private nestModuleDefinition;
6
- constructor(nestModuleDefinition: NestModuleDefinition);
7
+ constructor(nestModuleDefinition: Promisable<NestModuleDefinition>);
8
+ /**
9
+ * By default dont iterate by exports
10
+ * @param type
11
+ */
7
12
  iterate(type?: NestDefinitionType): AsyncIterableIterator<NestModuleDefinition | Provider>;
8
13
  }
@@ -1,20 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NestDefinitionMediator = void 0;
3
+ exports.NestDefinitionIterator = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const nest_definition_1 = require("./nest-definition");
6
- class NestDefinitionMediator {
6
+ class NestDefinitionIterator {
7
7
  nestModuleDefinition;
8
8
  constructor(nestModuleDefinition) {
9
9
  this.nestModuleDefinition = nestModuleDefinition;
10
10
  }
11
+ /**
12
+ * By default dont iterate by exports
13
+ * @param type
14
+ */
11
15
  async *iterate(type) {
12
- const iterateAll = typeof type === 'undefined';
16
+ const iterateAll = type === undefined;
13
17
  const iterateModule = iterateAll || type & constants_1.NestDefinitionType.Module;
18
+ const awaitedNestModuleDefinition = await this.nestModuleDefinition;
14
19
  if (iterateModule) {
15
- yield this.nestModuleDefinition;
20
+ yield awaitedNestModuleDefinition;
21
+ if ('module' in awaitedNestModuleDefinition) {
22
+ yield awaitedNestModuleDefinition.module;
23
+ }
16
24
  }
17
- const nestDefinition = new nest_definition_1.NestDefinition(this.nestModuleDefinition);
25
+ const nestDefinition = new nest_definition_1.NestDefinition(awaitedNestModuleDefinition);
18
26
  const nestImports = await nestDefinition.getImports();
19
27
  const iterateProviders = iterateAll || type & constants_1.NestDefinitionType.Providers;
20
28
  if (iterateProviders) {
@@ -23,7 +31,7 @@ class NestDefinitionMediator {
23
31
  yield provider;
24
32
  }
25
33
  }
26
- const iterateExports = iterateAll || type & constants_1.NestDefinitionType.Exports;
34
+ const iterateExports = type !== undefined && type & constants_1.NestDefinitionType.Exports;
27
35
  if (iterateExports) {
28
36
  const exports = nestDefinition.getExports();
29
37
  for (const nestExport of exports ?? []) {
@@ -38,8 +46,8 @@ class NestDefinitionMediator {
38
46
  }
39
47
  }
40
48
  for (const nestImport of nestImports ?? []) {
41
- yield* new NestDefinitionMediator(nestImport).iterate(type);
49
+ yield* new NestDefinitionIterator(nestImport).iterate(type);
42
50
  }
43
51
  }
44
52
  }
45
- exports.NestDefinitionMediator = NestDefinitionMediator;
53
+ exports.NestDefinitionIterator = NestDefinitionIterator;
@@ -6,8 +6,6 @@ const scanner_1 = require("@nestjs/core/scanner");
6
6
  /**
7
7
  * Хелпер для работы с объявлением модуля nest.
8
8
  * Получения провайдеров и импортов
9
- *
10
- * TODO: Объяснить что это за нафиг?
11
9
  */
12
10
  class NestDefinition {
13
11
  definition;
@@ -15,36 +13,36 @@ class NestDefinition {
15
13
  this.definition = definition;
16
14
  }
17
15
  getProviders() {
18
- return !scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
19
- ? this.reflectMetadata(constants_1.MODULE_METADATA.PROVIDERS, this.definition)
20
- : [
16
+ return scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
17
+ ? [
21
18
  ...this.reflectMetadata(constants_1.MODULE_METADATA.PROVIDERS, this.definition.module),
22
19
  ...(this.definition.providers || []),
23
- ];
20
+ ]
21
+ : this.reflectMetadata(constants_1.MODULE_METADATA.PROVIDERS, this.definition);
24
22
  }
25
23
  getImports() {
26
- return !scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
27
- ? this.reflectMetadata(constants_1.MODULE_METADATA.IMPORTS, this.definition)
28
- : [
24
+ return scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
25
+ ? [
29
26
  ...this.reflectMetadata(constants_1.MODULE_METADATA.IMPORTS, this.definition.module),
30
27
  ...(this.definition.imports || []),
31
- ];
28
+ ]
29
+ : this.reflectMetadata(constants_1.MODULE_METADATA.IMPORTS, this.definition);
32
30
  }
33
31
  getControllers() {
34
- return !scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
35
- ? this.reflectMetadata(constants_1.MODULE_METADATA.CONTROLLERS, this.definition)
36
- : [
32
+ return scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
33
+ ? [
37
34
  ...this.reflectMetadata(constants_1.MODULE_METADATA.CONTROLLERS, this.definition.module),
38
35
  ...(this.definition.controllers || []),
39
- ];
36
+ ]
37
+ : this.reflectMetadata(constants_1.MODULE_METADATA.CONTROLLERS, this.definition);
40
38
  }
41
39
  getExports() {
42
- return !scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
43
- ? this.reflectMetadata(constants_1.MODULE_METADATA.EXPORTS, this.definition)
44
- : [
40
+ return scanner_1.DependenciesScanner.prototype.isDynamicModule(this.definition)
41
+ ? [
45
42
  ...this.reflectMetadata(constants_1.MODULE_METADATA.EXPORTS, this.definition.module),
46
43
  ...(this.definition.exports || []),
47
- ];
44
+ ]
45
+ : this.reflectMetadata(constants_1.MODULE_METADATA.EXPORTS, this.definition);
48
46
  }
49
47
  reflectMetadata(metadataKey, metatype) {
50
48
  return Reflect.getMetadata(metadataKey, metatype) || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/nest-tools",
3
- "version": "1.0.12",
3
+ "version": "2.4.1-next.0",
4
4
  "license": "Apache License 2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,5 +10,5 @@
10
10
  "@nestjs/common": "^9.0.0",
11
11
  "@nestjs/core": "^9.0.0"
12
12
  },
13
- "gitHead": "e2741fe798655b87946330f8db0705e0f7ba2fb2"
13
+ "gitHead": "02cbc6be59dcf7d7784b316b315eb746c6d5ac4a"
14
14
  }
package/src/constants.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export enum NestDefinitionType {
2
+ // eslint-disable-next-line unicorn/prefer-math-trunc
2
3
  Module = 1 << 0,
3
4
  Controllers = 1 << 1,
4
5
  Providers = 1 << 2,
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { NestDefinitionType } from './constants';
2
2
 
3
- export { NestDefinitionMediator } from './nest-definition.mediator';
3
+ export { NestDefinitionIterator } from './nest-definition.iterator';
4
4
 
5
5
  export { NestDefinition } from './nest-definition';
@@ -1,21 +1,30 @@
1
1
  import type { Provider } from '@nestjs/common';
2
+ import type { Promisable } from 'type-fest';
2
3
 
3
4
  import { NestDefinitionType } from './constants';
4
5
  import type { NestModuleDefinition } from './nest-definition';
5
6
  import { NestDefinition } from './nest-definition';
6
7
 
7
- export class NestDefinitionMediator {
8
- constructor(private nestModuleDefinition: NestModuleDefinition) {}
8
+ export class NestDefinitionIterator {
9
+ constructor(private nestModuleDefinition: Promisable<NestModuleDefinition>) {}
9
10
 
11
+ /**
12
+ * By default dont iterate by exports
13
+ * @param type
14
+ */
10
15
  async *iterate(
11
16
  type?: NestDefinitionType,
12
17
  ): AsyncIterableIterator<NestModuleDefinition | Provider> {
13
- const iterateAll = typeof type === 'undefined';
18
+ const iterateAll = type === undefined;
14
19
  const iterateModule = iterateAll || type & NestDefinitionType.Module;
20
+ const awaitedNestModuleDefinition = await this.nestModuleDefinition;
15
21
  if (iterateModule) {
16
- yield this.nestModuleDefinition;
22
+ yield awaitedNestModuleDefinition;
23
+ if ('module' in awaitedNestModuleDefinition) {
24
+ yield awaitedNestModuleDefinition.module;
25
+ }
17
26
  }
18
- const nestDefinition = new NestDefinition(this.nestModuleDefinition);
27
+ const nestDefinition = new NestDefinition(awaitedNestModuleDefinition);
19
28
 
20
29
  const nestImports = await nestDefinition.getImports();
21
30
 
@@ -28,7 +37,8 @@ export class NestDefinitionMediator {
28
37
  }
29
38
  }
30
39
 
31
- const iterateExports = iterateAll || type & NestDefinitionType.Exports;
40
+ const iterateExports =
41
+ type !== undefined && type & NestDefinitionType.Exports;
32
42
 
33
43
  if (iterateExports) {
34
44
  const exports = nestDefinition.getExports();
@@ -50,7 +60,7 @@ export class NestDefinitionMediator {
50
60
  }
51
61
 
52
62
  for (const nestImport of nestImports ?? []) {
53
- yield* new NestDefinitionMediator(nestImport).iterate(type);
63
+ yield* new NestDefinitionIterator(nestImport).iterate(type);
54
64
  }
55
65
  }
56
66
  }
@@ -7,58 +7,56 @@ export type NestModuleDefinition = DynamicModule | Type;
7
7
  /**
8
8
  * Хелпер для работы с объявлением модуля nest.
9
9
  * Получения провайдеров и импортов
10
- *
11
- * TODO: Объяснить что это за нафиг?
12
10
  */
13
11
  export class NestDefinition {
14
12
  constructor(private definition: NestModuleDefinition) {}
15
13
 
16
14
  getProviders(): Provider[] | undefined {
17
- return !DependenciesScanner.prototype.isDynamicModule(this.definition)
18
- ? this.reflectMetadata(MODULE_METADATA.PROVIDERS, this.definition)
19
- : [
15
+ return DependenciesScanner.prototype.isDynamicModule(this.definition)
16
+ ? [
20
17
  ...this.reflectMetadata(
21
18
  MODULE_METADATA.PROVIDERS,
22
19
  this.definition.module,
23
20
  ),
24
21
  ...(this.definition.providers || []),
25
- ];
22
+ ]
23
+ : this.reflectMetadata(MODULE_METADATA.PROVIDERS, this.definition);
26
24
  }
27
25
 
28
26
  getImports(): NestModuleDefinition[] | undefined {
29
- return !DependenciesScanner.prototype.isDynamicModule(this.definition)
30
- ? this.reflectMetadata(MODULE_METADATA.IMPORTS, this.definition)
31
- : [
27
+ return DependenciesScanner.prototype.isDynamicModule(this.definition)
28
+ ? [
32
29
  ...this.reflectMetadata(
33
30
  MODULE_METADATA.IMPORTS,
34
31
  this.definition.module,
35
32
  ),
36
33
  ...(this.definition.imports || []),
37
- ];
34
+ ]
35
+ : this.reflectMetadata(MODULE_METADATA.IMPORTS, this.definition);
38
36
  }
39
37
 
40
38
  getControllers(): Type[] | undefined {
41
- return !DependenciesScanner.prototype.isDynamicModule(this.definition)
42
- ? this.reflectMetadata(MODULE_METADATA.CONTROLLERS, this.definition)
43
- : [
39
+ return DependenciesScanner.prototype.isDynamicModule(this.definition)
40
+ ? [
44
41
  ...this.reflectMetadata(
45
42
  MODULE_METADATA.CONTROLLERS,
46
43
  this.definition.module,
47
44
  ),
48
45
  ...(this.definition.controllers || []),
49
- ];
46
+ ]
47
+ : this.reflectMetadata(MODULE_METADATA.CONTROLLERS, this.definition);
50
48
  }
51
49
 
52
50
  getExports(): Type[] | undefined {
53
- return !DependenciesScanner.prototype.isDynamicModule(this.definition)
54
- ? this.reflectMetadata(MODULE_METADATA.EXPORTS, this.definition)
55
- : [
51
+ return DependenciesScanner.prototype.isDynamicModule(this.definition)
52
+ ? [
56
53
  ...this.reflectMetadata(
57
54
  MODULE_METADATA.EXPORTS,
58
55
  this.definition.module,
59
56
  ),
60
57
  ...(this.definition.exports || []),
61
- ];
58
+ ]
59
+ : this.reflectMetadata(MODULE_METADATA.EXPORTS, this.definition);
62
60
  }
63
61
 
64
62
  private reflectMetadata<T = any>(metadataKey: string, metatype: Type): T[] {