nesthub 1.0.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.
Files changed (143) hide show
  1. package/README.md +108 -0
  2. package/dist/cache/README.md +91 -0
  3. package/dist/cache/index.d.ts +10 -0
  4. package/dist/cache/index.js +75 -0
  5. package/dist/cache/index.js.map +1 -0
  6. package/dist/cache/index.spec.d.ts +1 -0
  7. package/dist/cache/index.spec.js +61 -0
  8. package/dist/cache/index.spec.js.map +1 -0
  9. package/dist/excel/README.md +132 -0
  10. package/dist/excel/excel.module.d.ts +2 -0
  11. package/dist/excel/excel.module.js +21 -0
  12. package/dist/excel/excel.module.js.map +1 -0
  13. package/dist/excel/excel.service.d.ts +23 -0
  14. package/dist/excel/excel.service.js +124 -0
  15. package/dist/excel/excel.service.js.map +1 -0
  16. package/dist/excel/index.d.ts +2 -0
  17. package/dist/excel/index.js +8 -0
  18. package/dist/excel/index.js.map +1 -0
  19. package/dist/excel/interfaces.d.ts +19 -0
  20. package/dist/excel/interfaces.js +3 -0
  21. package/dist/excel/interfaces.js.map +1 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +5 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/index.spec.d.ts +1 -0
  26. package/dist/index.spec.js +11 -0
  27. package/dist/index.spec.js.map +1 -0
  28. package/dist/notification/README.md +237 -0
  29. package/dist/notification/channels/channel.interface.d.ts +10 -0
  30. package/dist/notification/channels/channel.interface.js +3 -0
  31. package/dist/notification/channels/channel.interface.js.map +1 -0
  32. package/dist/notification/channels/email.channel.d.ts +11 -0
  33. package/dist/notification/channels/email.channel.js +58 -0
  34. package/dist/notification/channels/email.channel.js.map +1 -0
  35. package/dist/notification/channels/firebase.channel.d.ts +11 -0
  36. package/dist/notification/channels/firebase.channel.js +69 -0
  37. package/dist/notification/channels/firebase.channel.js.map +1 -0
  38. package/dist/notification/channels/index.d.ts +5 -0
  39. package/dist/notification/channels/index.js +12 -0
  40. package/dist/notification/channels/index.js.map +1 -0
  41. package/dist/notification/channels/sms.channel.d.ts +8 -0
  42. package/dist/notification/channels/sms.channel.js +90 -0
  43. package/dist/notification/channels/sms.channel.js.map +1 -0
  44. package/dist/notification/channels/telegram.channel.d.ts +10 -0
  45. package/dist/notification/channels/telegram.channel.js +59 -0
  46. package/dist/notification/channels/telegram.channel.js.map +1 -0
  47. package/dist/notification/email/index.d.ts +62 -0
  48. package/dist/notification/email/index.js +253 -0
  49. package/dist/notification/email/index.js.map +1 -0
  50. package/dist/notification/email/index.spec.d.ts +1 -0
  51. package/dist/notification/email/index.spec.js +121 -0
  52. package/dist/notification/email/index.spec.js.map +1 -0
  53. package/dist/notification/entities/notification-log.entity.d.ts +15 -0
  54. package/dist/notification/entities/notification-log.entity.js +82 -0
  55. package/dist/notification/entities/notification-log.entity.js.map +1 -0
  56. package/dist/notification/firebase/index.d.ts +52 -0
  57. package/dist/notification/firebase/index.js +261 -0
  58. package/dist/notification/firebase/index.js.map +1 -0
  59. package/dist/notification/firebase/index.spec.d.ts +1 -0
  60. package/dist/notification/firebase/index.spec.js +114 -0
  61. package/dist/notification/firebase/index.spec.js.map +1 -0
  62. package/dist/notification/index.d.ts +12 -0
  63. package/dist/notification/index.js +26 -0
  64. package/dist/notification/index.js.map +1 -0
  65. package/dist/notification/index.spec.d.ts +1 -0
  66. package/dist/notification/index.spec.js +336 -0
  67. package/dist/notification/index.spec.js.map +1 -0
  68. package/dist/notification/interfaces.d.ts +98 -0
  69. package/dist/notification/interfaces.js +3 -0
  70. package/dist/notification/interfaces.js.map +1 -0
  71. package/dist/notification/notification.constants.d.ts +4 -0
  72. package/dist/notification/notification.constants.js +8 -0
  73. package/dist/notification/notification.constants.js.map +1 -0
  74. package/dist/notification/notification.module.d.ts +10 -0
  75. package/dist/notification/notification.module.js +160 -0
  76. package/dist/notification/notification.module.js.map +1 -0
  77. package/dist/notification/notification.service.d.ts +14 -0
  78. package/dist/notification/notification.service.js +184 -0
  79. package/dist/notification/notification.service.js.map +1 -0
  80. package/dist/notification/queue/index.d.ts +2 -0
  81. package/dist/notification/queue/index.js +6 -0
  82. package/dist/notification/queue/index.js.map +1 -0
  83. package/dist/notification/queue/notification-queue.service.d.ts +31 -0
  84. package/dist/notification/queue/notification-queue.service.js +134 -0
  85. package/dist/notification/queue/notification-queue.service.js.map +1 -0
  86. package/dist/notification/services/index.d.ts +1 -0
  87. package/dist/notification/services/index.js +6 -0
  88. package/dist/notification/services/index.js.map +1 -0
  89. package/dist/notification/services/template.service.d.ts +13 -0
  90. package/dist/notification/services/template.service.js +75 -0
  91. package/dist/notification/services/template.service.js.map +1 -0
  92. package/dist/notification/shared.d.ts +48 -0
  93. package/dist/notification/shared.js +95 -0
  94. package/dist/notification/shared.js.map +1 -0
  95. package/dist/notification/sms/index.d.ts +52 -0
  96. package/dist/notification/sms/index.js +234 -0
  97. package/dist/notification/sms/index.js.map +1 -0
  98. package/dist/notification/sms/index.spec.d.ts +1 -0
  99. package/dist/notification/sms/index.spec.js +123 -0
  100. package/dist/notification/sms/index.spec.js.map +1 -0
  101. package/dist/notification/telegram/index.d.ts +50 -0
  102. package/dist/notification/telegram/index.js +248 -0
  103. package/dist/notification/telegram/index.js.map +1 -0
  104. package/dist/notification/telegram/index.spec.d.ts +1 -0
  105. package/dist/notification/telegram/index.spec.js +108 -0
  106. package/dist/notification/telegram/index.spec.js.map +1 -0
  107. package/dist/notification/typeorm-storage.d.ts +28 -0
  108. package/dist/notification/typeorm-storage.js +56 -0
  109. package/dist/notification/typeorm-storage.js.map +1 -0
  110. package/dist/notification/unified.d.ts +47 -0
  111. package/dist/notification/unified.js +207 -0
  112. package/dist/notification/unified.js.map +1 -0
  113. package/dist/queue/README.md +82 -0
  114. package/dist/queue/index.d.ts +14 -0
  115. package/dist/queue/index.js +17 -0
  116. package/dist/queue/index.js.map +1 -0
  117. package/dist/queue/index.spec.d.ts +1 -0
  118. package/dist/queue/index.spec.js +76 -0
  119. package/dist/queue/index.spec.js.map +1 -0
  120. package/dist/tsconfig.build.tsbuildinfo +1 -0
  121. package/dist/tsconfig.tsbuildinfo +1 -0
  122. package/dist/typeorm/README.md +197 -0
  123. package/dist/typeorm/crud-controller.d.ts +4 -0
  124. package/dist/typeorm/crud-controller.js +81 -0
  125. package/dist/typeorm/crud-controller.js.map +1 -0
  126. package/dist/typeorm/crud-service.d.ts +6 -0
  127. package/dist/typeorm/crud-service.js +53 -0
  128. package/dist/typeorm/crud-service.js.map +1 -0
  129. package/dist/typeorm/crud.interface.d.ts +9 -0
  130. package/dist/typeorm/crud.interface.js +3 -0
  131. package/dist/typeorm/crud.interface.js.map +1 -0
  132. package/dist/typeorm/index.d.ts +23 -0
  133. package/dist/typeorm/index.js +66 -0
  134. package/dist/typeorm/index.js.map +1 -0
  135. package/dist/typeorm/index.spec.d.ts +1 -0
  136. package/dist/typeorm/index.spec.js +109 -0
  137. package/dist/typeorm/index.spec.js.map +1 -0
  138. package/package.json +229 -0
  139. package/src/cache/README.md +91 -0
  140. package/src/excel/README.md +132 -0
  141. package/src/notification/README.md +237 -0
  142. package/src/queue/README.md +82 -0
  143. package/src/typeorm/README.md +197 -0
@@ -0,0 +1,207 @@
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 NotificationModule_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.NotificationModule = exports.NOTIFICATION_SERVICE = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const email_1 = require("./email");
19
+ const sms_1 = require("./sms");
20
+ const firebase_1 = require("./firebase");
21
+ const telegram_1 = require("./telegram");
22
+ exports.NOTIFICATION_SERVICE = 'NOTIFICATION_SERVICE';
23
+ let UnifiedNotificationService = class UnifiedNotificationService {
24
+ emailService;
25
+ smsService;
26
+ firebaseService;
27
+ telegramService;
28
+ constructor(emailService, smsService, firebaseService, telegramService) {
29
+ this.emailService = emailService;
30
+ this.smsService = smsService;
31
+ this.firebaseService = firebaseService;
32
+ this.telegramService = telegramService;
33
+ }
34
+ async sendEmail(options) {
35
+ if (!this.emailService)
36
+ return {
37
+ success: false,
38
+ error: 'Email not configured. Add sendgrid option.',
39
+ };
40
+ return this.emailService.sendEmail(options);
41
+ }
42
+ async sendSms(options) {
43
+ if (!this.smsService)
44
+ return {
45
+ success: false,
46
+ error: 'SMS not configured. Add twilio option.',
47
+ };
48
+ return this.smsService.sendSms(options);
49
+ }
50
+ async sendPush(options) {
51
+ if (!this.firebaseService)
52
+ return {
53
+ success: false,
54
+ error: 'Push not configured. Add firebase option.',
55
+ };
56
+ return this.firebaseService.sendPush(options);
57
+ }
58
+ async sendTelegram(options) {
59
+ if (!this.telegramService)
60
+ return {
61
+ success: false,
62
+ error: 'Telegram not configured. Add botToken option.',
63
+ };
64
+ return this.telegramService.sendTelegram(options);
65
+ }
66
+ async cancelJob(dedupId) {
67
+ await Promise.allSettled([
68
+ this.emailService?.cancelJob(dedupId),
69
+ this.smsService?.cancelJob(dedupId),
70
+ this.firebaseService?.cancelJob(dedupId),
71
+ this.telegramService?.cancelJob(dedupId),
72
+ ]);
73
+ }
74
+ };
75
+ UnifiedNotificationService = __decorate([
76
+ (0, common_1.Injectable)(),
77
+ __param(0, (0, common_1.Optional)()),
78
+ __param(0, (0, common_1.Inject)(email_1.EMAIL_SERVICE)),
79
+ __param(1, (0, common_1.Optional)()),
80
+ __param(1, (0, common_1.Inject)(sms_1.SMS_SERVICE)),
81
+ __param(2, (0, common_1.Optional)()),
82
+ __param(2, (0, common_1.Inject)(firebase_1.FIREBASE_SERVICE)),
83
+ __param(3, (0, common_1.Optional)()),
84
+ __param(3, (0, common_1.Inject)(telegram_1.TELEGRAM_SERVICE)),
85
+ __metadata("design:paramtypes", [Object, Object, Object, Object])
86
+ ], UnifiedNotificationService);
87
+ let NotificationModule = NotificationModule_1 = class NotificationModule {
88
+ static forRoot(options = {}) {
89
+ const subImports = [];
90
+ if (hasDeclared(options.sendgrid)) {
91
+ subImports.push(email_1.EmailModule.forRoot({
92
+ defaultFrom: options.defaultFrom,
93
+ defaultLocale: options.defaultLocale,
94
+ sendgrid: options.sendgrid,
95
+ queue: options.queue,
96
+ templates: options.templates,
97
+ storage: options.storage,
98
+ }));
99
+ }
100
+ if (hasDeclared(options.twilio)) {
101
+ subImports.push(sms_1.SmsModule.forRoot({
102
+ defaultFrom: options.defaultFrom,
103
+ defaultLocale: options.defaultLocale,
104
+ twilio: options.twilio,
105
+ queue: options.queue,
106
+ templates: options.templates,
107
+ storage: options.storage,
108
+ }));
109
+ }
110
+ if (hasDeclared(options.firebase)) {
111
+ subImports.push(firebase_1.FirebaseModule.forRoot({
112
+ firebase: options.firebase,
113
+ queue: options.queue,
114
+ storage: options.storage,
115
+ }));
116
+ }
117
+ if (hasDeclared(options.botToken)) {
118
+ subImports.push(telegram_1.TelegramModule.forRoot({
119
+ botToken: options.botToken,
120
+ defaultLocale: options.defaultLocale,
121
+ queue: options.queue,
122
+ templates: options.templates,
123
+ storage: options.storage,
124
+ }));
125
+ }
126
+ return {
127
+ module: NotificationModule_1,
128
+ imports: subImports,
129
+ providers: [
130
+ { provide: exports.NOTIFICATION_SERVICE, useClass: UnifiedNotificationService },
131
+ ],
132
+ exports: [exports.NOTIFICATION_SERVICE],
133
+ };
134
+ }
135
+ static forRootAsync(options) {
136
+ return {
137
+ module: NotificationModule_1,
138
+ imports: [
139
+ email_1.EmailModule.forRootAsync({
140
+ useFactory: async (...args) => {
141
+ const unified = await options.useFactory(...args);
142
+ return {
143
+ defaultFrom: unified.defaultFrom,
144
+ defaultLocale: unified.defaultLocale,
145
+ sendgrid: unified.sendgrid,
146
+ queue: unified.queue,
147
+ templates: unified.templates,
148
+ storage: unified.storage,
149
+ };
150
+ },
151
+ inject: options.inject ?? [],
152
+ }),
153
+ sms_1.SmsModule.forRootAsync({
154
+ useFactory: async (...args) => {
155
+ const unified = await options.useFactory(...args);
156
+ return {
157
+ defaultFrom: unified.defaultFrom,
158
+ defaultLocale: unified.defaultLocale,
159
+ twilio: unified.twilio,
160
+ queue: unified.queue,
161
+ templates: unified.templates,
162
+ storage: unified.storage,
163
+ };
164
+ },
165
+ inject: options.inject ?? [],
166
+ }),
167
+ firebase_1.FirebaseModule.forRootAsync({
168
+ useFactory: async (...args) => {
169
+ const unified = await options.useFactory(...args);
170
+ return {
171
+ firebase: unified.firebase,
172
+ queue: unified.queue,
173
+ storage: unified.storage,
174
+ };
175
+ },
176
+ inject: options.inject ?? [],
177
+ }),
178
+ telegram_1.TelegramModule.forRootAsync({
179
+ useFactory: async (...args) => {
180
+ const unified = await options.useFactory(...args);
181
+ return {
182
+ botToken: unified.botToken ?? '',
183
+ defaultLocale: unified.defaultLocale,
184
+ queue: unified.queue,
185
+ templates: unified.templates,
186
+ storage: unified.storage,
187
+ };
188
+ },
189
+ inject: options.inject ?? [],
190
+ }),
191
+ ],
192
+ providers: [
193
+ { provide: exports.NOTIFICATION_SERVICE, useClass: UnifiedNotificationService },
194
+ ],
195
+ exports: [exports.NOTIFICATION_SERVICE],
196
+ };
197
+ }
198
+ };
199
+ exports.NotificationModule = NotificationModule;
200
+ exports.NotificationModule = NotificationModule = NotificationModule_1 = __decorate([
201
+ (0, common_1.Global)(),
202
+ (0, common_1.Module)({})
203
+ ], NotificationModule);
204
+ function hasDeclared(value) {
205
+ return value !== undefined && value !== null;
206
+ }
207
+ //# sourceMappingURL=unified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/notification/unified.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,2CAA8E;AAW9E,mCAAqD;AAErD,+BAA+C;AAM/C,yCAA8D;AAE9D,yCAA8D;AAEjD,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAmC3D,IACM,0BAA0B,GADhC,MACM,0BAA0B;IAIX;IACiC;IAGjC;IAGA;IAVnB,YAGmB,YAA4B,EACK,UAAwB,EAGzD,eAAkC,EAGlC,eAAkC;QAPlC,iBAAY,GAAZ,YAAY,CAAgB;QACK,eAAU,GAAV,UAAU,CAAc;QAGzD,oBAAe,GAAf,eAAe,CAAmB;QAGlC,oBAAe,GAAf,eAAe,CAAmB;IAClD,CAAC;IAEJ,KAAK,CAAC,SAAS,CAAC,OAAyB;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,4CAA4C;aACpD,CAAC;QACJ,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAuB;QACnC,IAAI,CAAC,IAAI,CAAC,UAAU;YAClB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,wCAAwC;aAChD,CAAC;QACJ,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAwB;QACrC,IAAI,CAAC,IAAI,CAAC,eAAe;YACvB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,2CAA2C;aACnD,CAAC;QACJ,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,C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IAC1C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,82 @@
1
+ # nesthub/queue
2
+
3
+ RDS-style config factory for [BullMQ](https://bullmq.io) (via `@nestjs/bullmq`).
4
+
5
+ Works with either Valkey (`VALKEY_URL`) or Redis (`REDIS_URL`) environment variables.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install nesthub @nestjs/bullmq bullmq
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { BullModule } from '@nestjs/bullmq';
17
+ import { configBullMQ } from 'nesthub/queue';
18
+
19
+ @Module({
20
+ imports: [
21
+ BullModule.forRootAsync({
22
+ useFactory: configBullMQ,
23
+ inject: [ConfigService],
24
+ }),
25
+ BullModule.registerQueue({ name: 'email' }),
26
+ ],
27
+ })
28
+ export class AppModule {}
29
+ ```
30
+
31
+ ### Valkey (reads `VALKEY_URL` from env)
32
+
33
+ ```typescript
34
+ BullModule.forRootAsync({
35
+ // Requires VALKEY_URL in .env:
36
+ // VALKEY_URL=valkey://localhost:6379
37
+ useFactory: configBullMQ,
38
+ inject: [ConfigService],
39
+ })
40
+ ```
41
+
42
+ ### Redis (reads `REDIS_URL` from env)
43
+
44
+ ```typescript
45
+ BullModule.forRootAsync({
46
+ useFactory: (config: ConfigService) =>
47
+ configBullMQ(config, { store: 'redis' }),
48
+ inject: [ConfigService],
49
+ })
50
+ ```
51
+
52
+ ### With custom prefix and default job options
53
+
54
+ ```typescript
55
+ BullModule.forRootAsync({
56
+ useFactory: (config: ConfigService) =>
57
+ configBullMQ(config, {
58
+ prefix: '{myapp}',
59
+ defaultJobOptions: { attempts: 3, removeOnComplete: 100 },
60
+ }),
61
+ inject: [ConfigService],
62
+ })
63
+ ```
64
+
65
+ ### Direct URL (no env vars)
66
+
67
+ ```typescript
68
+ BullModule.forRootAsync({
69
+ useFactory: () => ({
70
+ connection: { url: 'redis://user:pass@host:6379' },
71
+ prefix: '{default}',
72
+ }),
73
+ })
74
+ ```
75
+
76
+ ## QueueModuleOptions
77
+
78
+ | Option | Default | Description |
79
+ |---|---|---|
80
+ | `store` | `'valkey'` | Backend store: `'valkey'` or `'redis'` |
81
+ | `prefix` | `'{default}'` | BullMQ key prefix |
82
+ | `defaultJobOptions` | — | Default job options for all queues (e.g. `{ attempts: 3 }`) |
@@ -0,0 +1,14 @@
1
+ import type { ConfigService } from '@nestjs/config';
2
+ export interface QueueModuleOptions {
3
+ store?: 'valkey' | 'redis';
4
+ prefix?: string;
5
+ defaultJobOptions?: Record<string, unknown>;
6
+ }
7
+ export interface BullMQModuleOptions {
8
+ connection: {
9
+ url: string;
10
+ };
11
+ prefix: string;
12
+ defaultJobOptions?: Record<string, unknown>;
13
+ }
14
+ export declare function configBullMQ(configService: ConfigService, options?: QueueModuleOptions): BullMQModuleOptions;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configBullMQ = configBullMQ;
4
+ function configBullMQ(configService, options) {
5
+ const { store = 'valkey', prefix, defaultJobOptions } = options ?? {};
6
+ const envKey = store === 'valkey' ? 'VALKEY_URL' : 'REDIS_URL';
7
+ const url = configService.get(envKey);
8
+ if (!url) {
9
+ throw new Error(`Missing ${envKey} environment variable.`);
10
+ }
11
+ return {
12
+ connection: { url },
13
+ prefix: prefix ?? '{default}',
14
+ defaultJobOptions,
15
+ };
16
+ }
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/queue/index.ts"],"names":[],"mappings":";;AAcA,oCAeC;AAfD,SAAgB,YAAY,CAC1B,aAA4B,EAC5B,OAA4B;IAE5B,MAAM,EAAE,KAAK,GAAG,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACtE,MAAM,MAAM,GAAG,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;IAC/D,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,WAAW,MAAM,wBAAwB,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO;QACL,UAAU,EAAE,EAAE,GAAG,EAAE;QACnB,MAAM,EAAE,MAAM,IAAI,WAAW;QAC7B,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ function createMockConfigService(env = {}) {
5
+ return {
6
+ get: jest.fn((key, defaultValue) => {
7
+ return key in env ? env[key] : defaultValue;
8
+ }),
9
+ };
10
+ }
11
+ describe('@vn.chemgio/nestjs-utilities/queue', () => {
12
+ describe('configBullMQ', () => {
13
+ it('should read VALKEY_URL by default', () => {
14
+ const config = createMockConfigService({
15
+ VALKEY_URL: 'valkey://localhost:6379',
16
+ });
17
+ const result = (0, index_1.configBullMQ)(config);
18
+ expect(result.connection.url).toBe('valkey://localhost:6379');
19
+ expect(config.get).toHaveBeenCalledWith('VALKEY_URL');
20
+ });
21
+ it('should read REDIS_URL for redis store', () => {
22
+ const config = createMockConfigService({
23
+ REDIS_URL: 'redis://localhost:6379',
24
+ });
25
+ const result = (0, index_1.configBullMQ)(config, {
26
+ store: 'redis',
27
+ });
28
+ expect(result.connection.url).toBe('redis://localhost:6379');
29
+ expect(config.get).toHaveBeenCalledWith('REDIS_URL');
30
+ });
31
+ it('should throw on missing env var', () => {
32
+ const config = createMockConfigService();
33
+ expect(() => (0, index_1.configBullMQ)(config)).toThrow('Missing VALKEY_URL environment variable.');
34
+ });
35
+ it('should throw with REDIS_URL for redis store', () => {
36
+ const config = createMockConfigService();
37
+ expect(() => (0, index_1.configBullMQ)(config, { store: 'redis' })).toThrow('Missing REDIS_URL environment variable.');
38
+ });
39
+ it('should apply prefix option', () => {
40
+ const config = createMockConfigService({
41
+ VALKEY_URL: 'valkey://localhost:6379',
42
+ });
43
+ const result = (0, index_1.configBullMQ)(config, {
44
+ prefix: '{myapp}',
45
+ });
46
+ expect(result.prefix).toBe('{myapp}');
47
+ });
48
+ it('should default prefix to {default}', () => {
49
+ const config = createMockConfigService({
50
+ VALKEY_URL: 'valkey://localhost:6379',
51
+ });
52
+ const result = (0, index_1.configBullMQ)(config);
53
+ expect(result.prefix).toBe('{default}');
54
+ });
55
+ it('should apply defaultJobOptions', () => {
56
+ const config = createMockConfigService({
57
+ VALKEY_URL: 'valkey://localhost:6379',
58
+ });
59
+ const result = (0, index_1.configBullMQ)(config, {
60
+ defaultJobOptions: { attempts: 3, removeOnComplete: 100 },
61
+ });
62
+ expect(result.defaultJobOptions).toEqual({
63
+ attempts: 3,
64
+ removeOnComplete: 100,
65
+ });
66
+ });
67
+ it('should return undefined defaultJobOptions when not set', () => {
68
+ const config = createMockConfigService({
69
+ VALKEY_URL: 'valkey://localhost:6379',
70
+ });
71
+ const result = (0, index_1.configBullMQ)(config);
72
+ expect(result.defaultJobOptions).toBeUndefined();
73
+ });
74
+ });
75
+ });
76
+ //# sourceMappingURL=index.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../src/queue/index.spec.ts"],"names":[],"mappings":";;AACA,mCAA2D;AAM3D,SAAS,uBAAuB,CAC9B,MAA8B,EAAE;IAEhC,OAAO;QACL,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,GAAW,EAAE,YAAsB,EAAE,EAAE;YACnD,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC9C,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,oCAAoC,EAAE,GAAG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