@nest-omni/core 2.0.1-9 → 3.1.1-11

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.
Files changed (45) hide show
  1. package/common/boilerplate.polyfill.d.ts +11 -0
  2. package/common/boilerplate.polyfill.js +57 -0
  3. package/common/dto/page-options.dto.d.ts +1 -1
  4. package/common/index.d.ts +0 -1
  5. package/common/index.js +0 -1
  6. package/decorators/controller.decorator.d.ts +1 -1
  7. package/decorators/property.decorators.js +1 -1
  8. package/decorators/timestamp-column.decorator.d.ts +1 -1
  9. package/decorators/user_auth.decorator.d.ts +1 -1
  10. package/health-checker/health-checker.controller.d.ts +2 -4
  11. package/health-checker/health-checker.controller.js +2 -5
  12. package/health-checker/health-checker.module.js +2 -3
  13. package/health-checker/index.d.ts +2 -0
  14. package/health-checker/index.js +18 -0
  15. package/helpers/date.helper.js +10 -10
  16. package/index.d.ts +4 -0
  17. package/index.js +4 -0
  18. package/package.json +142 -46
  19. package/setup/bootstrap.setup.js +37 -87
  20. package/setup/index.d.ts +5 -0
  21. package/setup/index.js +5 -0
  22. package/setup/mode.setup.d.ts +12 -0
  23. package/setup/mode.setup.js +60 -0
  24. package/setup/redis-lock.decorator.d.ts +5 -0
  25. package/setup/redis-lock.decorator.js +78 -0
  26. package/setup/redis-lock.service.d.ts +59 -0
  27. package/setup/redis-lock.service.js +362 -0
  28. package/setup/schedule.decorator.d.ts +23 -0
  29. package/setup/schedule.decorator.examples.d.ts +18 -0
  30. package/setup/schedule.decorator.examples.js +255 -0
  31. package/setup/schedule.decorator.js +233 -0
  32. package/setup/worker.decorator.d.ts +14 -0
  33. package/setup/worker.decorator.js +130 -0
  34. package/shared/serviceRegistryModule.js +17 -19
  35. package/shared/services/api-config.service.d.ts +9 -8
  36. package/shared/services/api-config.service.js +55 -46
  37. package/validator-json/default.js +9 -1
  38. package/validators/is-exists.validator.js +0 -2
  39. package/validators/is-unique.validator.js +0 -2
  40. package/validators/skip-empty.validator.d.ts +1 -1
  41. package/common/abstract-client.service.d.ts +0 -16
  42. package/common/abstract-client.service.js +0 -35
  43. package/health-checker/health-indicators/service.indicator.d.ts +0 -8
  44. package/health-checker/health-indicators/service.indicator.js +0 -66
  45. package/tsconfig.tsbuildinfo +0 -1
@@ -22,13 +22,11 @@ exports.IsExistsValidator = void 0;
22
22
  exports.IsExists = IsExists;
23
23
  const class_validator_1 = require("class-validator");
24
24
  const typeorm_1 = require("typeorm");
25
- const typeorm_transactional_1 = require("typeorm-transactional");
26
25
  const nestjs_i18n_1 = require("nestjs-i18n");
27
26
  const common_1 = require("@nestjs/common");
28
27
  let IsExistsValidator = class IsExistsValidator {
29
28
  constructor(dataSource) {
30
29
  this.dataSource = dataSource;
31
- this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
32
30
  }
33
31
  validate(value, args) {
34
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -22,12 +22,10 @@ exports.IsUniqueValidator = void 0;
22
22
  exports.IsUnique = IsUnique;
23
23
  const class_validator_1 = require("class-validator");
24
24
  const typeorm_1 = require("typeorm");
25
- const typeorm_transactional_1 = require("typeorm-transactional");
26
25
  const nestjs_i18n_1 = require("nestjs-i18n");
27
26
  let IsUniqueValidator = class IsUniqueValidator {
28
27
  constructor(dataSource) {
29
28
  this.dataSource = dataSource;
30
- this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
31
29
  }
32
30
  validate(value, args) {
33
31
  return __awaiter(this, void 0, void 0, function* () {
@@ -1 +1 @@
1
- export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
1
+ export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,16 +0,0 @@
1
- import type { ClientProxy } from '@nestjs/microservices';
2
- import type { Constructor } from './types';
3
- import type { PageDto } from './dto/page.dto';
4
- export declare class AbstractClientService<ActionType> {
5
- private client;
6
- constructor(client: ClientProxy);
7
- send(pattern: ActionType, data: unknown): Promise<void>;
8
- send<R>(pattern: ActionType, data: unknown, returnDataOptions: {
9
- class: Constructor<R>;
10
- isPage: true;
11
- }): Promise<PageDto<R>>;
12
- send<R>(pattern: ActionType, data: unknown, returnDataOptions?: {
13
- class: Constructor<R>;
14
- isPage?: false;
15
- }): Promise<R>;
16
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AbstractClientService = void 0;
13
- const class_transformer_1 = require("class-transformer");
14
- const rxjs_1 = require("rxjs");
15
- const page_type_exception_1 = require("../exceptions/page-type.exception");
16
- class AbstractClientService {
17
- constructor(client) {
18
- this.client = client;
19
- }
20
- send(pattern, data, returnDataOptions) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const returnData = yield (0, rxjs_1.firstValueFrom)(this.client.send(pattern, data), {
23
- defaultValue: undefined,
24
- });
25
- if ((returnDataOptions === null || returnDataOptions === void 0 ? void 0 : returnDataOptions.isPage) && (!(returnData === null || returnData === void 0 ? void 0 : returnData.data) || !returnData.meta)) {
26
- throw new page_type_exception_1.PageTypeException();
27
- }
28
- if (!(returnDataOptions === null || returnDataOptions === void 0 ? void 0 : returnDataOptions.class) || returnDataOptions.isPage) {
29
- return returnData;
30
- }
31
- return (0, class_transformer_1.plainToInstance)(returnDataOptions.class, returnData);
32
- });
33
- }
34
- }
35
- exports.AbstractClientService = AbstractClientService;
@@ -1,8 +0,0 @@
1
- import { ClientProxy } from '@nestjs/microservices';
2
- import type { HealthIndicatorResult } from '@nestjs/terminus';
3
- import { HealthIndicator } from '@nestjs/terminus';
4
- export declare class ServiceHealthIndicator extends HealthIndicator {
5
- private readonly clientProxy?;
6
- constructor(clientProxy?: ClientProxy);
7
- isHealthy(eventName: string): Promise<HealthIndicatorResult>;
8
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.ServiceHealthIndicator = void 0;
25
- const common_1 = require("@nestjs/common");
26
- const microservices_1 = require("@nestjs/microservices");
27
- const terminus_1 = require("@nestjs/terminus");
28
- const rxjs_1 = require("rxjs");
29
- const operators_1 = require("rxjs/operators");
30
- let ServiceHealthIndicator = class ServiceHealthIndicator extends terminus_1.HealthIndicator {
31
- constructor(clientProxy) {
32
- super();
33
- this.clientProxy = clientProxy;
34
- }
35
- isHealthy(eventName) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- try {
38
- if (!this.clientProxy) {
39
- return {
40
- [eventName]: {
41
- status: 'down',
42
- },
43
- };
44
- }
45
- const result = yield (0, rxjs_1.firstValueFrom)(this.clientProxy.send(eventName, { check: true }).pipe((0, operators_1.timeout)(10000)), {
46
- defaultValue: undefined,
47
- });
48
- return {
49
- [eventName]: result,
50
- };
51
- }
52
- catch (error) {
53
- throw new terminus_1.HealthCheckError(`${eventName} failed`, {
54
- [eventName]: error,
55
- });
56
- }
57
- });
58
- }
59
- };
60
- exports.ServiceHealthIndicator = ServiceHealthIndicator;
61
- exports.ServiceHealthIndicator = ServiceHealthIndicator = __decorate([
62
- (0, common_1.Injectable)(),
63
- __param(0, (0, common_1.Optional)()),
64
- __param(0, (0, common_1.Inject)('NATS_SERVICE')),
65
- __metadata("design:paramtypes", [microservices_1.ClientProxy])
66
- ], ServiceHealthIndicator);