@riktajs/queue 0.10.2 → 0.10.3

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 (64) hide show
  1. package/dist/index.cjs +16251 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +946 -0
  4. package/dist/index.d.ts +945 -21
  5. package/dist/index.js +16177 -29
  6. package/dist/index.js.map +1 -1
  7. package/package.json +13 -6
  8. package/dist/config/queue.config.d.ts +0 -43
  9. package/dist/config/queue.config.d.ts.map +0 -1
  10. package/dist/config/queue.config.js +0 -82
  11. package/dist/config/queue.config.js.map +0 -1
  12. package/dist/constants.d.ts +0 -33
  13. package/dist/constants.d.ts.map +0 -1
  14. package/dist/constants.js +0 -37
  15. package/dist/constants.js.map +0 -1
  16. package/dist/decorators/events.decorator.d.ts +0 -85
  17. package/dist/decorators/events.decorator.d.ts.map +0 -1
  18. package/dist/decorators/events.decorator.js +0 -120
  19. package/dist/decorators/events.decorator.js.map +0 -1
  20. package/dist/decorators/index.d.ts +0 -8
  21. package/dist/decorators/index.d.ts.map +0 -1
  22. package/dist/decorators/index.js +0 -8
  23. package/dist/decorators/index.js.map +0 -1
  24. package/dist/decorators/process.decorator.d.ts +0 -41
  25. package/dist/decorators/process.decorator.d.ts.map +0 -1
  26. package/dist/decorators/process.decorator.js +0 -61
  27. package/dist/decorators/process.decorator.js.map +0 -1
  28. package/dist/decorators/processor.decorator.d.ts +0 -41
  29. package/dist/decorators/processor.decorator.d.ts.map +0 -1
  30. package/dist/decorators/processor.decorator.js +0 -59
  31. package/dist/decorators/processor.decorator.js.map +0 -1
  32. package/dist/decorators/queue.decorator.d.ts +0 -35
  33. package/dist/decorators/queue.decorator.d.ts.map +0 -1
  34. package/dist/decorators/queue.decorator.js +0 -49
  35. package/dist/decorators/queue.decorator.js.map +0 -1
  36. package/dist/events/queue-events.d.ts +0 -32
  37. package/dist/events/queue-events.d.ts.map +0 -1
  38. package/dist/events/queue-events.js +0 -103
  39. package/dist/events/queue-events.js.map +0 -1
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/monitoring/bull-board.d.ts +0 -77
  42. package/dist/monitoring/bull-board.d.ts.map +0 -1
  43. package/dist/monitoring/bull-board.js +0 -112
  44. package/dist/monitoring/bull-board.js.map +0 -1
  45. package/dist/providers/queue.provider.d.ts +0 -113
  46. package/dist/providers/queue.provider.d.ts.map +0 -1
  47. package/dist/providers/queue.provider.js +0 -383
  48. package/dist/providers/queue.provider.js.map +0 -1
  49. package/dist/services/queue.service.d.ts +0 -133
  50. package/dist/services/queue.service.d.ts.map +0 -1
  51. package/dist/services/queue.service.js +0 -192
  52. package/dist/services/queue.service.js.map +0 -1
  53. package/dist/types.d.ts +0 -133
  54. package/dist/types.d.ts.map +0 -1
  55. package/dist/types.js +0 -5
  56. package/dist/types.js.map +0 -1
  57. package/dist/utils/connection.d.ts +0 -47
  58. package/dist/utils/connection.d.ts.map +0 -1
  59. package/dist/utils/connection.js +0 -102
  60. package/dist/utils/connection.js.map +0 -1
  61. package/dist/utils/validation.d.ts +0 -137
  62. package/dist/utils/validation.d.ts.map +0 -1
  63. package/dist/utils/validation.js +0 -156
  64. package/dist/utils/validation.js.map +0 -1
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@riktajs/queue",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "BullMQ-based job queue integration for Rikta Framework with lifecycle management and event-driven processing",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
12
19
  }
13
20
  },
14
21
  "files": [
@@ -17,7 +24,7 @@
17
24
  "scripts": {
18
25
  "clean": "rm -rf dist",
19
26
  "prebuild": "npm run clean",
20
- "build": "tsc",
27
+ "build": "tsup",
21
28
  "dev": "tsc --watch",
22
29
  "test": "vitest run",
23
30
  "test:watch": "vitest",
@@ -43,7 +50,7 @@
43
50
  "ioredis": "^5.4.2"
44
51
  },
45
52
  "peerDependencies": {
46
- "@riktajs/core": ">=0.10.2",
53
+ "@riktajs/core": ">=0.10.3",
47
54
  "bullmq": ">=5.0.0",
48
55
  "reflect-metadata": ">=0.2.0"
49
56
  },
@@ -1,43 +0,0 @@
1
- /**
2
- * Queue configuration schema and loader
3
- */
4
- import { z } from 'zod';
5
- import type { QueueConfig } from '../types.js';
6
- /** Zod schema for queue configuration */
7
- export declare const QueueConfigSchema: z.ZodObject<{
8
- redis: z.ZodObject<{
9
- host: z.ZodDefault<z.ZodString>;
10
- port: z.ZodDefault<z.ZodNumber>;
11
- password: z.ZodOptional<z.ZodString>;
12
- db: z.ZodDefault<z.ZodNumber>;
13
- username: z.ZodOptional<z.ZodString>;
14
- tls: z.ZodOptional<z.ZodBoolean>;
15
- cluster: z.ZodOptional<z.ZodObject<{
16
- nodes: z.ZodArray<z.ZodObject<{
17
- host: z.ZodString;
18
- port: z.ZodNumber;
19
- }, z.core.$strip>>;
20
- }, z.core.$strip>>;
21
- }, z.core.$strip>;
22
- defaultConcurrency: z.ZodDefault<z.ZodNumber>;
23
- defaultRateLimiter: z.ZodOptional<z.ZodObject<{
24
- max: z.ZodNumber;
25
- duration: z.ZodNumber;
26
- }, z.core.$strip>>;
27
- dashboardPath: z.ZodDefault<z.ZodString>;
28
- dashboardEnabled: z.ZodDefault<z.ZodBoolean>;
29
- shutdownTimeout: z.ZodDefault<z.ZodNumber>;
30
- }, z.core.$strip>;
31
- export type QueueConfigInput = z.input<typeof QueueConfigSchema>;
32
- /**
33
- * Load queue configuration from environment variables
34
- * @param overrides - Optional configuration overrides
35
- */
36
- export declare function loadQueueConfig(overrides?: Partial<QueueConfigInput>): QueueConfig;
37
- /**
38
- * Error thrown when queue configuration is invalid
39
- */
40
- export declare class QueueConfigError extends Error {
41
- constructor(message: string);
42
- }
43
- //# sourceMappingURL=queue.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.config.d.ts","sourceRoot":"","sources":["../../src/config/queue.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA2B/C,yCAAyC;AACzC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;iBAO5B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,WAAW,CAoClF;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B"}
@@ -1,82 +0,0 @@
1
- /**
2
- * Queue configuration schema and loader
3
- */
4
- import { z } from 'zod';
5
- /** Zod schema for Redis cluster node */
6
- const RedisClusterNodeSchema = z.object({
7
- host: z.string(),
8
- port: z.number().int().positive(),
9
- });
10
- /** Zod schema for Redis connection options */
11
- const RedisConnectionSchema = z.object({
12
- host: z.string().default('localhost'),
13
- port: z.number().int().positive().default(6379),
14
- password: z.string().optional(),
15
- db: z.number().int().min(0).default(0),
16
- username: z.string().optional(),
17
- tls: z.boolean().optional(),
18
- cluster: z.object({
19
- nodes: z.array(RedisClusterNodeSchema).min(1),
20
- }).optional(),
21
- });
22
- /** Zod schema for rate limiter */
23
- const RateLimiterSchema = z.object({
24
- max: z.number().int().positive(),
25
- duration: z.number().int().positive(),
26
- });
27
- /** Zod schema for queue configuration */
28
- export const QueueConfigSchema = z.object({
29
- redis: RedisConnectionSchema,
30
- defaultConcurrency: z.number().int().positive().default(1),
31
- defaultRateLimiter: RateLimiterSchema.optional(),
32
- dashboardPath: z.string().default('/admin/queues'),
33
- dashboardEnabled: z.boolean().default(false),
34
- shutdownTimeout: z.number().int().positive().default(30000),
35
- });
36
- /**
37
- * Load queue configuration from environment variables
38
- * @param overrides - Optional configuration overrides
39
- */
40
- export function loadQueueConfig(overrides) {
41
- const envConfig = {
42
- redis: {
43
- host: process.env['QUEUE_REDIS_HOST'] || 'localhost',
44
- port: parseInt(process.env['QUEUE_REDIS_PORT'] || '6379', 10),
45
- password: process.env['QUEUE_REDIS_PASSWORD'] || undefined,
46
- db: parseInt(process.env['QUEUE_REDIS_DB'] || '0', 10),
47
- username: process.env['QUEUE_REDIS_USERNAME'] || undefined,
48
- },
49
- defaultConcurrency: parseInt(process.env['QUEUE_DEFAULT_CONCURRENCY'] || '1', 10),
50
- dashboardPath: process.env['QUEUE_DASHBOARD_PATH'] || '/admin/queues',
51
- dashboardEnabled: process.env['QUEUE_DASHBOARD_ENABLED'] === 'true',
52
- shutdownTimeout: parseInt(process.env['QUEUE_SHUTDOWN_TIMEOUT'] || '30000', 10),
53
- };
54
- // Merge with overrides
55
- const merged = {
56
- ...envConfig,
57
- ...overrides,
58
- redis: {
59
- ...envConfig.redis,
60
- ...overrides?.redis,
61
- },
62
- };
63
- // Validate and return
64
- const result = QueueConfigSchema.safeParse(merged);
65
- if (!result.success) {
66
- const errors = result.error.issues
67
- .map(e => `${e.path.join('.')}: ${e.message}`)
68
- .join(', ');
69
- throw new QueueConfigError(`Invalid queue configuration: ${errors}`);
70
- }
71
- return result.data;
72
- }
73
- /**
74
- * Error thrown when queue configuration is invalid
75
- */
76
- export class QueueConfigError extends Error {
77
- constructor(message) {
78
- super(message);
79
- this.name = 'QueueConfigError';
80
- }
81
- }
82
- //# sourceMappingURL=queue.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.config.js","sourceRoot":"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AAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,eAAe;QACrE,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,KAAK,MAAM;QACnE,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,OAAO,EAAE,EAAE,CAAC;KAChF,CAAC;IAEF,uBAAuB;IACvB,MAAM,MAAM,GAAG;QACb,GAAG,SAAS;QACZ,GAAG,SAAS;QACZ,KAAK,EAAE;YACL,GAAG,SAAS,CAAC,KAAK;YAClB,GAAG,SAAS,EAAE,KAAK;SACpB;KACF,CAAC;IAEF,sBAAsB;IACtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM;aAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;aAC7C,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,gBAAgB,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,MAAM,CAAC,IAAmB,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Constants and DI tokens for @riktajs/queue
3
- */
4
- /** Metadata keys for decorator reflection */
5
- export declare const METADATA_KEY: {
6
- /** Queue class decorator options */
7
- readonly QUEUE_OPTIONS: "riktajs:queue:options";
8
- /** Processor class decorator options */
9
- readonly PROCESSOR_OPTIONS: "riktajs:queue:processor:options";
10
- /** Job handler method metadata */
11
- readonly JOB_HANDLERS: "riktajs:queue:job:handlers";
12
- /** Event handler method metadata */
13
- readonly EVENT_HANDLERS: "riktajs:queue:event:handlers";
14
- };
15
- /** DI token for the QueueProvider */
16
- export declare const QUEUE_PROVIDER: unique symbol;
17
- /** DI token for the QueueService */
18
- export declare const QUEUE_SERVICE: unique symbol;
19
- /** DI token for the Redis connection */
20
- export declare const QUEUE_REDIS_CONNECTION: unique symbol;
21
- /** DI token for the queue configuration */
22
- export declare const QUEUE_CONFIG: unique symbol;
23
- /**
24
- * Get the DI token for a named queue
25
- * @param name - The queue name
26
- */
27
- export declare function getQueueToken(name: string): symbol;
28
- /**
29
- * Get the DI token for a named worker
30
- * @param name - The queue name
31
- */
32
- export declare function getWorkerToken(name: string): symbol;
33
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6CAA6C;AAC7C,eAAO,MAAM,YAAY;IACvB,oCAAoC;;IAEpC,wCAAwC;;IAExC,kCAAkC;;IAElC,oCAAoC;;CAE5B,CAAC;AAEX,qCAAqC;AACrC,eAAO,MAAM,cAAc,eAA+B,CAAC;AAE3D,oCAAoC;AACpC,eAAO,MAAM,aAAa,eAA8B,CAAC;AAEzD,wCAAwC;AACxC,eAAO,MAAM,sBAAsB,eAAuC,CAAC;AAE3E,2CAA2C;AAC3C,eAAO,MAAM,YAAY,eAA6B,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD"}
package/dist/constants.js DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * Constants and DI tokens for @riktajs/queue
3
- */
4
- /** Metadata keys for decorator reflection */
5
- export const METADATA_KEY = {
6
- /** Queue class decorator options */
7
- QUEUE_OPTIONS: 'riktajs:queue:options',
8
- /** Processor class decorator options */
9
- PROCESSOR_OPTIONS: 'riktajs:queue:processor:options',
10
- /** Job handler method metadata */
11
- JOB_HANDLERS: 'riktajs:queue:job:handlers',
12
- /** Event handler method metadata */
13
- EVENT_HANDLERS: 'riktajs:queue:event:handlers',
14
- };
15
- /** DI token for the QueueProvider */
16
- export const QUEUE_PROVIDER = Symbol.for('QUEUE_PROVIDER');
17
- /** DI token for the QueueService */
18
- export const QUEUE_SERVICE = Symbol.for('QUEUE_SERVICE');
19
- /** DI token for the Redis connection */
20
- export const QUEUE_REDIS_CONNECTION = Symbol.for('QUEUE_REDIS_CONNECTION');
21
- /** DI token for the queue configuration */
22
- export const QUEUE_CONFIG = Symbol.for('QUEUE_CONFIG');
23
- /**
24
- * Get the DI token for a named queue
25
- * @param name - The queue name
26
- */
27
- export function getQueueToken(name) {
28
- return Symbol.for(`QUEUE:${name}`);
29
- }
30
- /**
31
- * Get the DI token for a named worker
32
- * @param name - The queue name
33
- */
34
- export function getWorkerToken(name) {
35
- return Symbol.for(`WORKER:${name}`);
36
- }
37
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,oCAAoC;IACpC,aAAa,EAAE,uBAAuB;IACtC,wCAAwC;IACxC,iBAAiB,EAAE,iCAAiC;IACpD,kCAAkC;IAClC,YAAY,EAAE,4BAA4B;IAC1C,oCAAoC;IACpC,cAAc,EAAE,8BAA8B;CACtC,CAAC;AAEX,qCAAqC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAE3D,oCAAoC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAEzD,wCAAwC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAE3E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC"}
@@ -1,85 +0,0 @@
1
- /**
2
- * Event decorators for job lifecycle events
3
- */
4
- import 'reflect-metadata';
5
- import type { EventHandlerMeta, QueueEventName } from '../types.js';
6
- /**
7
- * Decorator for handling job completion events
8
- *
9
- * @example
10
- * ```typescript
11
- * @Processor('my-queue')
12
- * class MyProcessor {
13
- * @OnJobComplete()
14
- * async handleComplete(job: Job, result: unknown) {
15
- * console.log(`Job ${job.id} completed with:`, result);
16
- * }
17
- * }
18
- * ```
19
- */
20
- export declare function OnJobComplete(): MethodDecorator;
21
- /**
22
- * Decorator for handling job failure events
23
- *
24
- * @example
25
- * ```typescript
26
- * @Processor('my-queue')
27
- * class MyProcessor {
28
- * @OnJobFailed()
29
- * async handleFailed(job: Job, error: Error) {
30
- * console.error(`Job ${job.id} failed:`, error);
31
- * }
32
- * }
33
- * ```
34
- */
35
- export declare function OnJobFailed(): MethodDecorator;
36
- /**
37
- * Decorator for handling job progress events
38
- *
39
- * @example
40
- * ```typescript
41
- * @Processor('my-queue')
42
- * class MyProcessor {
43
- * @OnJobProgress()
44
- * async handleProgress(job: Job, progress: number | object) {
45
- * console.log(`Job ${job.id} progress:`, progress);
46
- * }
47
- * }
48
- * ```
49
- */
50
- export declare function OnJobProgress(): MethodDecorator;
51
- /**
52
- * Decorator for handling job stalled events
53
- *
54
- * @example
55
- * ```typescript
56
- * @Processor('my-queue')
57
- * class MyProcessor {
58
- * @OnJobStalled()
59
- * async handleStalled(jobId: string) {
60
- * console.warn(`Job ${jobId} stalled`);
61
- * }
62
- * }
63
- * ```
64
- */
65
- export declare function OnJobStalled(): MethodDecorator;
66
- /**
67
- * Decorator for handling worker ready events
68
- */
69
- export declare function OnWorkerReady(): MethodDecorator;
70
- /**
71
- * Decorator for handling worker error events
72
- */
73
- export declare function OnWorkerError(): MethodDecorator;
74
- /**
75
- * Get all event handlers from a processor class
76
- * @param target - The processor class
77
- */
78
- export declare function getEventHandlers(target: Function): EventHandlerMeta[];
79
- /**
80
- * Get event handlers for a specific event
81
- * @param target - The processor class
82
- * @param event - The event name
83
- */
84
- export declare function getEventHandlersFor(target: Function, event: QueueEventName): EventHandlerMeta[];
85
- //# sourceMappingURL=events.decorator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/events.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAmCpE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,IAAI,eAAe,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,IAAI,eAAe,CAE7C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,IAAI,eAAe,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAE9C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,eAAe,CAE/C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,eAAe,CAE/C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,gBAAgB,EAAE,CAErE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,QAAQ,EAChB,KAAK,EAAE,cAAc,GACpB,gBAAgB,EAAE,CAEpB"}
@@ -1,120 +0,0 @@
1
- /**
2
- * Event decorators for job lifecycle events
3
- */
4
- import 'reflect-metadata';
5
- import { METADATA_KEY } from '../constants.js';
6
- /**
7
- * Factory function to create event decorators
8
- * @internal
9
- */
10
- function createEventDecorator(event) {
11
- return (target, propertyKey, _descriptor) => {
12
- const methodName = String(propertyKey);
13
- // Get existing handlers or create new array
14
- const existingHandlers = Reflect.getMetadata(METADATA_KEY.EVENT_HANDLERS, target.constructor) || [];
15
- // Add this handler
16
- const handler = {
17
- event,
18
- methodName,
19
- };
20
- existingHandlers.push(handler);
21
- // Store updated handlers
22
- Reflect.defineMetadata(METADATA_KEY.EVENT_HANDLERS, existingHandlers, target.constructor);
23
- };
24
- }
25
- /**
26
- * Decorator for handling job completion events
27
- *
28
- * @example
29
- * ```typescript
30
- * @Processor('my-queue')
31
- * class MyProcessor {
32
- * @OnJobComplete()
33
- * async handleComplete(job: Job, result: unknown) {
34
- * console.log(`Job ${job.id} completed with:`, result);
35
- * }
36
- * }
37
- * ```
38
- */
39
- export function OnJobComplete() {
40
- return createEventDecorator('job:completed');
41
- }
42
- /**
43
- * Decorator for handling job failure events
44
- *
45
- * @example
46
- * ```typescript
47
- * @Processor('my-queue')
48
- * class MyProcessor {
49
- * @OnJobFailed()
50
- * async handleFailed(job: Job, error: Error) {
51
- * console.error(`Job ${job.id} failed:`, error);
52
- * }
53
- * }
54
- * ```
55
- */
56
- export function OnJobFailed() {
57
- return createEventDecorator('job:failed');
58
- }
59
- /**
60
- * Decorator for handling job progress events
61
- *
62
- * @example
63
- * ```typescript
64
- * @Processor('my-queue')
65
- * class MyProcessor {
66
- * @OnJobProgress()
67
- * async handleProgress(job: Job, progress: number | object) {
68
- * console.log(`Job ${job.id} progress:`, progress);
69
- * }
70
- * }
71
- * ```
72
- */
73
- export function OnJobProgress() {
74
- return createEventDecorator('job:progress');
75
- }
76
- /**
77
- * Decorator for handling job stalled events
78
- *
79
- * @example
80
- * ```typescript
81
- * @Processor('my-queue')
82
- * class MyProcessor {
83
- * @OnJobStalled()
84
- * async handleStalled(jobId: string) {
85
- * console.warn(`Job ${jobId} stalled`);
86
- * }
87
- * }
88
- * ```
89
- */
90
- export function OnJobStalled() {
91
- return createEventDecorator('job:stalled');
92
- }
93
- /**
94
- * Decorator for handling worker ready events
95
- */
96
- export function OnWorkerReady() {
97
- return createEventDecorator('worker:ready');
98
- }
99
- /**
100
- * Decorator for handling worker error events
101
- */
102
- export function OnWorkerError() {
103
- return createEventDecorator('worker:error');
104
- }
105
- /**
106
- * Get all event handlers from a processor class
107
- * @param target - The processor class
108
- */
109
- export function getEventHandlers(target) {
110
- return Reflect.getMetadata(METADATA_KEY.EVENT_HANDLERS, target) || [];
111
- }
112
- /**
113
- * Get event handlers for a specific event
114
- * @param target - The processor class
115
- * @param event - The event name
116
- */
117
- export function getEventHandlersFor(target, event) {
118
- return getEventHandlers(target).filter(h => h.event === event);
119
- }
120
- //# sourceMappingURL=events.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.decorator.js","sourceRoot":"","sources":["../../src/decorators/events.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;GAGG;AACH,SAAS,oBAAoB,CAAC,KAAqB;IACjD,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,WAA+B,EAC/B,EAAE;QACF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAEvC,4CAA4C;QAC5C,MAAM,gBAAgB,GACpB,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAE7E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AC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Decorators for @riktajs/queue
3
- */
4
- export * from './queue.decorator.js';
5
- export * from './processor.decorator.js';
6
- export * from './process.decorator.js';
7
- export * from './events.decorator.js';
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Decorators for @riktajs/queue
3
- */
4
- export * from './queue.decorator.js';
5
- export * from './processor.decorator.js';
6
- export * from './process.decorator.js';
7
- export * from './events.decorator.js';
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * @Process decorator - marks a method as a job handler
3
- */
4
- import 'reflect-metadata';
5
- import type { JobHandlerMeta } from '../types.js';
6
- /**
7
- * Decorator to define a job handler method
8
- *
9
- * @param jobName - The name of the job to handle (default: method name)
10
- * @returns MethodDecorator
11
- *
12
- * @example
13
- * ```typescript
14
- * @Processor('email-queue')
15
- * class EmailProcessor {
16
- * @Process('send')
17
- * async handleSendEmail(job: Job<EmailData>) {
18
- * await sendEmail(job.data);
19
- * return { sent: true };
20
- * }
21
- *
22
- * @Process() // Uses method name as job name
23
- * async welcome(job: Job<WelcomeData>) {
24
- * // ...
25
- * }
26
- * }
27
- * ```
28
- */
29
- export declare function Process(jobName?: string): MethodDecorator;
30
- /**
31
- * Get all job handlers from a processor class
32
- * @param target - The processor class
33
- */
34
- export declare function getJobHandlers(target: Function): JobHandlerMeta[];
35
- /**
36
- * Check if a method is decorated with @Process
37
- * @param target - The class
38
- * @param methodName - The method name
39
- */
40
- export declare function isJobHandler(target: Function, methodName: string): boolean;
41
- //# sourceMappingURL=process.decorator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/process.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe,CA4BzD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,EAAE,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAG1E"}
@@ -1,61 +0,0 @@
1
- /**
2
- * @Process decorator - marks a method as a job handler
3
- */
4
- import 'reflect-metadata';
5
- import { METADATA_KEY } from '../constants.js';
6
- /**
7
- * Decorator to define a job handler method
8
- *
9
- * @param jobName - The name of the job to handle (default: method name)
10
- * @returns MethodDecorator
11
- *
12
- * @example
13
- * ```typescript
14
- * @Processor('email-queue')
15
- * class EmailProcessor {
16
- * @Process('send')
17
- * async handleSendEmail(job: Job<EmailData>) {
18
- * await sendEmail(job.data);
19
- * return { sent: true };
20
- * }
21
- *
22
- * @Process() // Uses method name as job name
23
- * async welcome(job: Job<WelcomeData>) {
24
- * // ...
25
- * }
26
- * }
27
- * ```
28
- */
29
- export function Process(jobName) {
30
- return (target, propertyKey, _descriptor) => {
31
- const methodName = String(propertyKey);
32
- const name = jobName || methodName;
33
- // Get existing handlers or create new array
34
- const existingHandlers = Reflect.getMetadata(METADATA_KEY.JOB_HANDLERS, target.constructor) || [];
35
- // Add this handler
36
- const handler = {
37
- name,
38
- methodName,
39
- };
40
- existingHandlers.push(handler);
41
- // Store updated handlers
42
- Reflect.defineMetadata(METADATA_KEY.JOB_HANDLERS, existingHandlers, target.constructor);
43
- };
44
- }
45
- /**
46
- * Get all job handlers from a processor class
47
- * @param target - The processor class
48
- */
49
- export function getJobHandlers(target) {
50
- return Reflect.getMetadata(METADATA_KEY.JOB_HANDLERS, target) || [];
51
- }
52
- /**
53
- * Check if a method is decorated with @Process
54
- * @param target - The class
55
- * @param methodName - The method name
56
- */
57
- export function isJobHandler(target, methodName) {
58
- const handlers = getJobHandlers(target);
59
- return handlers.some(h => h.methodName === methodName);
60
- }
61
- //# sourceMappingURL=process.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.decorator.js","sourceRoot":"","sources":["../../src/decorators/process.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,WAA+B,EAC/B,EAAE;QACF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,OAAO,IAAI,UAAU,CAAC;QAEnC,4CAA4C;QAC5C,MAAM,gBAAgB,GACpB,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAE3E,mBAAmB;QACnB,MAAM,OAAO,GAAmB;YAC9B,IAAI;YACJ,UAAU;SACX,CAAC;QAEF,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/B,yBAAyB;QACzB,OAAO,CAAC,cAAc,CACpB,YAAY,CAAC,YAAY,EACzB,gBAAgB,EAChB,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAgB,EAAE,UAAkB;IAC/D,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;AACzD,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * @Processor decorator - marks a class as a job processor
3
- */
4
- import 'reflect-metadata';
5
- import type { ProcessorOptions } from '../types.js';
6
- /**
7
- * Decorator to define a job processor for a queue
8
- *
9
- * @param queueName - The name of the queue to process
10
- * @param options - Optional processor configuration
11
- * @returns ClassDecorator
12
- *
13
- * @example
14
- * ```typescript
15
- * @Processor('email-queue', { concurrency: 5 })
16
- * class EmailProcessor {
17
- * @Process('send')
18
- * async handleSendEmail(job: Job) {
19
- * // process job
20
- * }
21
- * }
22
- * ```
23
- */
24
- export declare function Processor(queueName: string, options?: Omit<ProcessorOptions, 'queueName'>): ClassDecorator;
25
- /**
26
- * Get processor options from a decorated class
27
- * @param target - The decorated class
28
- */
29
- export declare function getProcessorOptions(target: Function): ProcessorOptions | undefined;
30
- /**
31
- * Check if a class is decorated with @Processor
32
- * @param target - The class to check
33
- */
34
- export declare function isProcessor(target: Function): boolean;
35
- /**
36
- * Error thrown when @Processor decorator is used incorrectly
37
- */
38
- export declare class ProcessorDecoratorError extends Error {
39
- constructor(message: string);
40
- }
41
- //# sourceMappingURL=processor.decorator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processor.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/processor.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAC5C,cAAc,CAahB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B"}