@lyrolab/nest-shared 0.0.0-semantically-released

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 (90) hide show
  1. package/.releaserc.json +25 -0
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +45 -0
  4. package/dist/ai/index.d.ts +2 -0
  5. package/dist/ai/index.js +19 -0
  6. package/dist/ai/index.js.map +1 -0
  7. package/dist/ai/services/ai.service.d.ts +14 -0
  8. package/dist/ai/services/ai.service.js +58 -0
  9. package/dist/ai/services/ai.service.js.map +1 -0
  10. package/dist/ai/shared-ai.module.d.ts +2 -0
  11. package/dist/ai/shared-ai.module.js +21 -0
  12. package/dist/ai/shared-ai.module.js.map +1 -0
  13. package/dist/app.module.d.ts +2 -0
  14. package/dist/app.module.js +21 -0
  15. package/dist/app.module.js.map +1 -0
  16. package/dist/bull/index.d.ts +1 -0
  17. package/dist/bull/index.js +18 -0
  18. package/dist/bull/index.js.map +1 -0
  19. package/dist/bull/shared-bull.module.d.ts +4 -0
  20. package/dist/bull/shared-bull.module.js +40 -0
  21. package/dist/bull/shared-bull.module.js.map +1 -0
  22. package/dist/cache/index.d.ts +1 -0
  23. package/dist/cache/index.js +18 -0
  24. package/dist/cache/index.js.map +1 -0
  25. package/dist/cache/shared-cache.module.d.ts +4 -0
  26. package/dist/cache/shared-cache.module.js +42 -0
  27. package/dist/cache/shared-cache.module.js.map +1 -0
  28. package/dist/database/filters/typeorm-exception.filter.d.ts +7 -0
  29. package/dist/database/filters/typeorm-exception.filter.js +35 -0
  30. package/dist/database/filters/typeorm-exception.filter.js.map +1 -0
  31. package/dist/database/helpers/find-main-path.d.ts +1 -0
  32. package/dist/database/helpers/find-main-path.js +23 -0
  33. package/dist/database/helpers/find-main-path.js.map +1 -0
  34. package/dist/database/index.d.ts +2 -0
  35. package/dist/database/index.js +19 -0
  36. package/dist/database/index.js.map +1 -0
  37. package/dist/database/shared-database.module.d.ts +18 -0
  38. package/dist/database/shared-database.module.js +120 -0
  39. package/dist/database/shared-database.module.js.map +1 -0
  40. package/dist/health/health.controller.d.ts +7 -0
  41. package/dist/health/health.controller.js +39 -0
  42. package/dist/health/health.controller.js.map +1 -0
  43. package/dist/health/index.d.ts +1 -0
  44. package/dist/health/index.js +18 -0
  45. package/dist/health/index.js.map +1 -0
  46. package/dist/health/shared-health.module.d.ts +2 -0
  47. package/dist/health/shared-health.module.js +22 -0
  48. package/dist/health/shared-health.module.js.map +1 -0
  49. package/dist/queue/controllers/queue.controller.d.ts +7 -0
  50. package/dist/queue/controllers/queue.controller.js +40 -0
  51. package/dist/queue/controllers/queue.controller.js.map +1 -0
  52. package/dist/queue/decorators/queue.decorator.d.ts +5 -0
  53. package/dist/queue/decorators/queue.decorator.js +6 -0
  54. package/dist/queue/decorators/queue.decorator.js.map +1 -0
  55. package/dist/queue/index.d.ts +5 -0
  56. package/dist/queue/index.js +22 -0
  57. package/dist/queue/index.js.map +1 -0
  58. package/dist/queue/interfaces/queue-options.interface.d.ts +13 -0
  59. package/dist/queue/interfaces/queue-options.interface.js +3 -0
  60. package/dist/queue/interfaces/queue-options.interface.js.map +1 -0
  61. package/dist/queue/models/dto/queue-add.dto.d.ts +4 -0
  62. package/dist/queue/models/dto/queue-add.dto.js +28 -0
  63. package/dist/queue/models/dto/queue-add.dto.js.map +1 -0
  64. package/dist/queue/models/job-processor-interface.d.ts +4 -0
  65. package/dist/queue/models/job-processor-interface.js +3 -0
  66. package/dist/queue/models/job-processor-interface.js.map +1 -0
  67. package/dist/queue/processors/queue.processor.d.ts +17 -0
  68. package/dist/queue/processors/queue.processor.js +109 -0
  69. package/dist/queue/processors/queue.processor.js.map +1 -0
  70. package/dist/queue/queue.constants.d.ts +2 -0
  71. package/dist/queue/queue.constants.js +6 -0
  72. package/dist/queue/queue.constants.js.map +1 -0
  73. package/dist/queue/services/queue.service.d.ts +6 -0
  74. package/dist/queue/services/queue.service.js +35 -0
  75. package/dist/queue/services/queue.service.js.map +1 -0
  76. package/dist/queue/shared-queue.module.d.ts +8 -0
  77. package/dist/queue/shared-queue.module.js +90 -0
  78. package/dist/queue/shared-queue.module.js.map +1 -0
  79. package/dist/redis/index.d.ts +2 -0
  80. package/dist/redis/index.js +19 -0
  81. package/dist/redis/index.js.map +1 -0
  82. package/dist/redis/redis.config.d.ts +4 -0
  83. package/dist/redis/redis.config.js +11 -0
  84. package/dist/redis/redis.config.js.map +1 -0
  85. package/dist/redis/shared-redis.module.d.ts +9 -0
  86. package/dist/redis/shared-redis.module.js +68 -0
  87. package/dist/redis/shared-redis.module.js.map +1 -0
  88. package/dist/tsconfig.tsbuildinfo +1 -0
  89. package/eslint.config.mjs +35 -0
  90. package/package.json +165 -0
@@ -0,0 +1,90 @@
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 SharedQueueModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SharedQueueModule = void 0;
11
+ const bullmq_1 = require("@nestjs/bullmq");
12
+ const common_1 = require("@nestjs/common");
13
+ const core_1 = require("@nestjs/core");
14
+ const queue_controller_1 = require("./controllers/queue.controller");
15
+ const queue_processor_1 = require("./processors/queue.processor");
16
+ const queue_constants_1 = require("./queue.constants");
17
+ const queue_service_1 = require("./services/queue.service");
18
+ let SharedQueueModule = SharedQueueModule_1 = class SharedQueueModule {
19
+ static forRoot(options = {}) {
20
+ return {
21
+ module: SharedQueueModule_1,
22
+ global: true,
23
+ imports: [
24
+ bullmq_1.BullModule.registerQueue({ name: queue_constants_1.DEFAULT_QUEUE }),
25
+ core_1.DiscoveryModule,
26
+ ],
27
+ providers: [
28
+ {
29
+ provide: queue_constants_1.QUEUE_MODULE_OPTIONS,
30
+ useValue: options,
31
+ },
32
+ queue_service_1.QueueService,
33
+ queue_processor_1.QueueProcessor,
34
+ ],
35
+ exports: [queue_service_1.QueueService],
36
+ controllers: [queue_controller_1.QueueController],
37
+ };
38
+ }
39
+ static forRootAsync(options) {
40
+ return {
41
+ module: SharedQueueModule_1,
42
+ global: true,
43
+ imports: [
44
+ bullmq_1.BullModule.registerQueue({ name: queue_constants_1.DEFAULT_QUEUE }),
45
+ core_1.DiscoveryModule,
46
+ ...(options.imports || []),
47
+ ],
48
+ providers: [
49
+ ...this.createAsyncProviders(options),
50
+ queue_service_1.QueueService,
51
+ queue_processor_1.QueueProcessor,
52
+ ],
53
+ exports: [queue_service_1.QueueService],
54
+ controllers: [queue_controller_1.QueueController],
55
+ };
56
+ }
57
+ static createAsyncProviders(options) {
58
+ if (options.useExisting || options.useFactory) {
59
+ return [this.createAsyncOptionsProvider(options)];
60
+ }
61
+ return [
62
+ this.createAsyncOptionsProvider(options),
63
+ {
64
+ provide: options.useClass,
65
+ useClass: options.useClass,
66
+ },
67
+ ];
68
+ }
69
+ static createAsyncOptionsProvider(options) {
70
+ if (options.useFactory) {
71
+ return {
72
+ provide: queue_constants_1.QUEUE_MODULE_OPTIONS,
73
+ useFactory: options.useFactory,
74
+ inject: options.inject || [],
75
+ };
76
+ }
77
+ return {
78
+ provide: queue_constants_1.QUEUE_MODULE_OPTIONS,
79
+ useFactory: async (optionsFactory) => {
80
+ return optionsFactory.createQueueOptions();
81
+ },
82
+ inject: [options.useExisting || options.useClass],
83
+ };
84
+ }
85
+ };
86
+ exports.SharedQueueModule = SharedQueueModule;
87
+ exports.SharedQueueModule = SharedQueueModule = SharedQueueModule_1 = __decorate([
88
+ (0, common_1.Module)({})
89
+ ], SharedQueueModule);
90
+ //# sourceMappingURL=shared-queue.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-queue.module.js","sourceRoot":"","sources":["../../src/queue/shared-queue.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA2C;AAC3C,2CAAgE;AAChE,uCAA8C;AAC9C,qEAAgE;AAMhE,kEAA6D;AAC7D,uDAAuE;AACvE,4DAAuD;AAGhD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO,CAAC,UAA8B,EAAE;QAC7C,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE;gBACP,mBAAU,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,+BAAa,EAAE,CAAC;gBACjD,sBAAe;aAChB;YACD,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,sCAAoB;oBAC7B,QAAQ,EAAE,OAAO;iBAClB;gBACD,4BAAY;gBACZ,gCAAc;aACf;YACD,OAAO,EAAE,CAAC,4BAAY,CAAC;YACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;SAC/B,CAAA;IACH,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAgC;QAClD,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE;gBACP,mBAAU,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,+BAAa,EAAE,CAAC;gBACjD,sBAAe;gBACf,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;aAC3B;YACD,SAAS,EAAE;gBACT,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;gBACrC,4BAAY;gBACZ,gCAAc;aACf;YACD,OAAO,EAAE,CAAC,4BAAY,CAAC;YACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;SAC/B,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,oBAAoB,CACjC,OAAgC;QAEhC,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAA;QACnD,CAAC;QAED,OAAO;YACL,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC;YACxC;gBACE,OAAO,EAAE,OAAO,CAAC,QAAS;gBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAS;aAC5B;SACF,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,0BAA0B,CACvC,OAAgC;QAEhC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO;gBACL,OAAO,EAAE,sCAAoB;gBAC7B,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;aAC7B,CAAA;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,sCAAoB;YAC7B,UAAU,EAAE,KAAK,EAAE,cAAmC,EAAE,EAAE;gBACxD,OAAO,cAAc,CAAC,kBAAkB,EAAE,CAAA;YAC5C,CAAC;YACD,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAS,CAAC;SACnD,CAAA;IACH,CAAC;CACF,CAAA;AA5EY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CA4E7B"}
@@ -0,0 +1,2 @@
1
+ export * from "./shared-redis.module";
2
+ export * from "./redis.config";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./shared-redis.module"), exports);
18
+ __exportStar(require("./redis.config"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,iDAA8B"}
@@ -0,0 +1,4 @@
1
+ export declare class RedisConfig {
2
+ readonly url: string;
3
+ constructor(url: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RedisConfig = void 0;
4
+ class RedisConfig {
5
+ url;
6
+ constructor(url) {
7
+ this.url = url;
8
+ }
9
+ }
10
+ exports.RedisConfig = RedisConfig;
11
+ //# sourceMappingURL=redis.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.config.js","sourceRoot":"","sources":["../../src/redis/redis.config.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACM;IAA5B,YAA4B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;CAC5C;AAFD,kCAEC"}
@@ -0,0 +1,9 @@
1
+ import { DynamicModule, OnModuleDestroy } from "@nestjs/common";
2
+ export declare class SharedRedisModule implements OnModuleDestroy {
3
+ private static testContainer;
4
+ static forRoot(): DynamicModule;
5
+ private static createTestConfiguration;
6
+ private static createProductionConfiguration;
7
+ static closeTestConnection(): Promise<void>;
8
+ onModuleDestroy(): Promise<void>;
9
+ }
@@ -0,0 +1,68 @@
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 SharedRedisModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SharedRedisModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const config_1 = require("@nestjs/config");
13
+ const testcontainers_1 = require("testcontainers");
14
+ const redis_config_1 = require("./redis.config");
15
+ let SharedRedisModule = class SharedRedisModule {
16
+ static { SharedRedisModule_1 = this; }
17
+ static testContainer = null;
18
+ static forRoot() {
19
+ return {
20
+ module: SharedRedisModule_1,
21
+ providers: [
22
+ {
23
+ provide: redis_config_1.RedisConfig,
24
+ useFactory: async (configService) => {
25
+ const isTestEnvironment = process.env.NODE_ENV === "test";
26
+ if (isTestEnvironment) {
27
+ return new redis_config_1.RedisConfig(await this.createTestConfiguration());
28
+ }
29
+ return new redis_config_1.RedisConfig(this.createProductionConfiguration(configService));
30
+ },
31
+ inject: [config_1.ConfigService],
32
+ },
33
+ ],
34
+ exports: [redis_config_1.RedisConfig],
35
+ imports: [config_1.ConfigModule],
36
+ global: true,
37
+ };
38
+ }
39
+ static async createTestConfiguration() {
40
+ if (!this.testContainer) {
41
+ this.testContainer = await new testcontainers_1.GenericContainer("redis")
42
+ .withExposedPorts(6379)
43
+ .withWaitStrategy(testcontainers_1.Wait.forAll([
44
+ testcontainers_1.Wait.forListeningPorts(),
45
+ testcontainers_1.Wait.forLogMessage("Ready to accept connections tcp"),
46
+ ]))
47
+ .start();
48
+ }
49
+ return `redis://${this.testContainer.getHost()}:${this.testContainer.getMappedPort(6379)}`;
50
+ }
51
+ static createProductionConfiguration(configService) {
52
+ return configService.get("REDIS_URL");
53
+ }
54
+ static async closeTestConnection() {
55
+ if (this.testContainer) {
56
+ await this.testContainer.stop();
57
+ this.testContainer = null;
58
+ }
59
+ }
60
+ async onModuleDestroy() {
61
+ await SharedRedisModule_1.closeTestConnection();
62
+ }
63
+ };
64
+ exports.SharedRedisModule = SharedRedisModule;
65
+ exports.SharedRedisModule = SharedRedisModule = SharedRedisModule_1 = __decorate([
66
+ (0, common_1.Module)({})
67
+ ], SharedRedisModule);
68
+ //# sourceMappingURL=shared-redis.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-redis.module.js","sourceRoot":"","sources":["../../src/redis/shared-redis.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuE;AACvE,2CAA4D;AAC5D,mDAA6E;AAC7E,iDAA4C;AAGrC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;;IACpB,MAAM,CAAC,aAAa,GAAgC,IAAI,CAAA;IAEhE,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,0BAAW;oBACpB,UAAU,EAAE,KAAK,EAAE,aAA4B,EAAE,EAAE;wBACjD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAA;wBAEzD,IAAI,iBAAiB,EAAE,CAAC;4BACtB,OAAO,IAAI,0BAAW,CAAC,MAAM,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAA;wBAC9D,CAAC;wBAED,OAAO,IAAI,0BAAW,CACpB,IAAI,CAAC,6BAA6B,CAAC,aAAa,CAAC,CAClD,CAAA;oBACH,CAAC;oBACD,MAAM,EAAE,CAAC,sBAAa,CAAC;iBACxB;aACF;YACD,OAAO,EAAE,CAAC,0BAAW,CAAC;YACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;YACvB,MAAM,EAAE,IAAI;SACb,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,uBAAuB;QAC1C,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,aAAa,GAAG,MAAM,IAAI,iCAAgB,CAAC,OAAO,CAAC;iBACrD,gBAAgB,CAAC,IAAI,CAAC;iBACtB,gBAAgB,CACf,qBAAI,CAAC,MAAM,CAAC;gBACV,qBAAI,CAAC,iBAAiB,EAAE;gBACxB,qBAAI,CAAC,aAAa,CAAC,iCAAiC,CAAC;aACtD,CAAC,CACH;iBACA,KAAK,EAAE,CAAA;QACZ,CAAC;QAED,OAAO,WAAW,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAA;IAC5F,CAAC;IAEO,MAAM,CAAC,6BAA6B,CAAC,aAA4B;QACvE,OAAO,aAAa,CAAC,GAAG,CAAC,WAAW,CAAW,CAAA;IACjD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,mBAAmB;QAC9B,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAA;YAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;QAC3B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,mBAAiB,CAAC,mBAAmB,EAAE,CAAA;IAC/C,CAAC;;AA1DU,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CA2D7B"}