atomic-queues 2.3.0 → 3.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 (204) hide show
  1. package/README.md +297 -382
  2. package/dist/cli/generators/classes.d.ts +1 -1
  3. package/dist/cli/generators/json-schema.d.ts +1 -1
  4. package/dist/cli/generators/typescript.d.ts +1 -1
  5. package/dist/cli/index.js +147 -5
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cluster/cluster-discovery.service.d.ts +91 -0
  8. package/dist/cluster/cluster-discovery.service.d.ts.map +1 -0
  9. package/dist/cluster/cluster-discovery.service.js +423 -0
  10. package/dist/cluster/cluster-discovery.service.js.map +1 -0
  11. package/dist/cluster/grpc-peer-monitor.service.d.ts +31 -0
  12. package/dist/cluster/grpc-peer-monitor.service.d.ts.map +1 -0
  13. package/dist/cluster/grpc-peer-monitor.service.js +192 -0
  14. package/dist/cluster/grpc-peer-monitor.service.js.map +1 -0
  15. package/dist/cluster/index.d.ts +7 -0
  16. package/dist/cluster/index.d.ts.map +1 -0
  17. package/dist/cluster/index.js +23 -0
  18. package/dist/cluster/index.js.map +1 -0
  19. package/dist/cluster/leader-election.service.d.ts +38 -0
  20. package/dist/cluster/leader-election.service.d.ts.map +1 -0
  21. package/dist/cluster/leader-election.service.js +184 -0
  22. package/dist/cluster/leader-election.service.js.map +1 -0
  23. package/dist/cluster/master-coordinator.d.ts +50 -0
  24. package/dist/cluster/master-coordinator.d.ts.map +1 -0
  25. package/dist/cluster/master-coordinator.js +307 -0
  26. package/dist/cluster/master-coordinator.js.map +1 -0
  27. package/dist/cluster/redis-health-monitor.service.d.ts +23 -0
  28. package/dist/cluster/redis-health-monitor.service.d.ts.map +1 -0
  29. package/dist/cluster/redis-health-monitor.service.js +100 -0
  30. package/dist/cluster/redis-health-monitor.service.js.map +1 -0
  31. package/dist/cluster/server-ring.service.d.ts +48 -0
  32. package/dist/cluster/server-ring.service.d.ts.map +1 -0
  33. package/dist/cluster/server-ring.service.js +136 -0
  34. package/dist/cluster/server-ring.service.js.map +1 -0
  35. package/dist/decorators/entity.decorators.d.ts +16 -24
  36. package/dist/decorators/entity.decorators.d.ts.map +1 -1
  37. package/dist/decorators/entity.decorators.js +0 -39
  38. package/dist/decorators/entity.decorators.js.map +1 -1
  39. package/dist/decorators/interfaces.d.ts +10 -10
  40. package/dist/decorators/interfaces.d.ts.map +1 -1
  41. package/dist/decorators/job.decorators.d.ts +4 -52
  42. package/dist/decorators/job.decorators.d.ts.map +1 -1
  43. package/dist/decorators/job.decorators.js +6 -54
  44. package/dist/decorators/job.decorators.js.map +1 -1
  45. package/dist/decorators/metadata-readers.d.ts +4 -2
  46. package/dist/decorators/metadata-readers.d.ts.map +1 -1
  47. package/dist/decorators/metadata-readers.js +2 -0
  48. package/dist/decorators/metadata-readers.js.map +1 -1
  49. package/dist/decorators/schema.decorators.d.ts +1 -1
  50. package/dist/decorators/schema.decorators.d.ts.map +1 -1
  51. package/dist/decorators/schema.decorators.js.map +1 -1
  52. package/dist/decorators/utils.d.ts +1 -1
  53. package/dist/decorators/utils.d.ts.map +1 -1
  54. package/dist/decorators/utils.js +5 -1
  55. package/dist/decorators/utils.js.map +1 -1
  56. package/dist/domain/interfaces/config.interfaces.d.ts +92 -29
  57. package/dist/domain/interfaces/config.interfaces.d.ts.map +1 -1
  58. package/dist/domain/interfaces/index.d.ts +1 -0
  59. package/dist/domain/interfaces/index.d.ts.map +1 -1
  60. package/dist/domain/interfaces/index.js +1 -0
  61. package/dist/domain/interfaces/index.js.map +1 -1
  62. package/dist/{services/registry → domain/interfaces}/registry.types.d.ts.map +1 -1
  63. package/dist/domain/interfaces/registry.types.js.map +1 -0
  64. package/dist/grpc/grpc-client-pool.service.d.ts +71 -0
  65. package/dist/grpc/grpc-client-pool.service.d.ts.map +1 -0
  66. package/dist/grpc/grpc-client-pool.service.js +307 -0
  67. package/dist/grpc/grpc-client-pool.service.js.map +1 -0
  68. package/dist/grpc/grpc-server.service.d.ts +47 -0
  69. package/dist/grpc/grpc-server.service.d.ts.map +1 -0
  70. package/dist/grpc/grpc-server.service.js +494 -0
  71. package/dist/grpc/grpc-server.service.js.map +1 -0
  72. package/dist/grpc/index.d.ts +3 -0
  73. package/dist/grpc/index.d.ts.map +1 -0
  74. package/dist/{services/executor-pool → grpc}/index.js +2 -1
  75. package/dist/grpc/index.js.map +1 -0
  76. package/dist/index.d.ts +4 -0
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +4 -0
  79. package/dist/index.js.map +1 -1
  80. package/dist/module/atomic-queues.module.d.ts +1 -0
  81. package/dist/module/atomic-queues.module.d.ts.map +1 -1
  82. package/dist/module/atomic-queues.module.js +59 -10
  83. package/dist/module/atomic-queues.module.js.map +1 -1
  84. package/dist/services/command-discovery/command-discovery.service.js +2 -2
  85. package/dist/services/command-discovery/command-discovery.service.js.map +1 -1
  86. package/dist/services/index.d.ts +2 -8
  87. package/dist/services/index.d.ts.map +1 -1
  88. package/dist/services/index.js +2 -8
  89. package/dist/services/index.js.map +1 -1
  90. package/dist/services/message-router/index.d.ts +2 -0
  91. package/dist/services/message-router/index.d.ts.map +1 -0
  92. package/dist/services/{actor-system → message-router}/index.js +1 -1
  93. package/dist/services/message-router/index.js.map +1 -0
  94. package/dist/services/message-router/message-router.service.d.ts +53 -0
  95. package/dist/services/message-router/message-router.service.d.ts.map +1 -0
  96. package/dist/services/message-router/message-router.service.js +519 -0
  97. package/dist/services/message-router/message-router.service.js.map +1 -0
  98. package/dist/services/queue-bus/cluster-contracts.d.ts +1 -1
  99. package/dist/services/queue-bus/cluster-contracts.d.ts.map +1 -1
  100. package/dist/services/queue-bus/cluster-contracts.js.map +1 -1
  101. package/dist/services/queue-bus/queue-bus.service.d.ts +3 -21
  102. package/dist/services/queue-bus/queue-bus.service.d.ts.map +1 -1
  103. package/dist/services/queue-bus/queue-bus.service.js +15 -119
  104. package/dist/services/queue-bus/queue-bus.service.js.map +1 -1
  105. package/dist/utils/id.utils.d.ts +3 -0
  106. package/dist/utils/id.utils.d.ts.map +1 -0
  107. package/dist/utils/id.utils.js +14 -0
  108. package/dist/utils/id.utils.js.map +1 -0
  109. package/dist/utils/index.d.ts +1 -0
  110. package/dist/utils/index.d.ts.map +1 -1
  111. package/dist/utils/index.js +1 -0
  112. package/dist/utils/index.js.map +1 -1
  113. package/dist/wal/index.d.ts +4 -0
  114. package/dist/wal/index.d.ts.map +1 -0
  115. package/dist/{services/gate → wal}/index.js +3 -1
  116. package/dist/wal/index.js.map +1 -0
  117. package/dist/wal/wal.scripts.d.ts +51 -0
  118. package/dist/wal/wal.scripts.d.ts.map +1 -0
  119. package/dist/wal/wal.scripts.js +84 -0
  120. package/dist/wal/wal.scripts.js.map +1 -0
  121. package/dist/wal/wal.service.d.ts +46 -0
  122. package/dist/wal/wal.service.d.ts.map +1 -0
  123. package/dist/wal/wal.service.js +243 -0
  124. package/dist/wal/wal.service.js.map +1 -0
  125. package/dist/wal/wal.types.d.ts +23 -0
  126. package/dist/wal/wal.types.d.ts.map +1 -0
  127. package/dist/wal/wal.types.js +3 -0
  128. package/dist/wal/wal.types.js.map +1 -0
  129. package/dist/workers/consistent-hash.d.ts +97 -0
  130. package/dist/workers/consistent-hash.d.ts.map +1 -0
  131. package/dist/workers/consistent-hash.js +231 -0
  132. package/dist/workers/consistent-hash.js.map +1 -0
  133. package/dist/workers/entity-worker-manager.d.ts +35 -0
  134. package/dist/workers/entity-worker-manager.d.ts.map +1 -0
  135. package/dist/workers/entity-worker-manager.js +237 -0
  136. package/dist/workers/entity-worker-manager.js.map +1 -0
  137. package/dist/workers/entity-worker.d.ts +54 -0
  138. package/dist/workers/entity-worker.d.ts.map +1 -0
  139. package/dist/workers/entity-worker.js +142 -0
  140. package/dist/workers/entity-worker.js.map +1 -0
  141. package/dist/workers/index.d.ts +4 -0
  142. package/dist/workers/index.d.ts.map +1 -0
  143. package/dist/{services/log → workers}/index.js +3 -1
  144. package/dist/workers/index.js.map +1 -0
  145. package/package.json +17 -4
  146. package/dist/services/actor-system/actor-system.service.d.ts +0 -19
  147. package/dist/services/actor-system/actor-system.service.d.ts.map +0 -1
  148. package/dist/services/actor-system/actor-system.service.js +0 -86
  149. package/dist/services/actor-system/actor-system.service.js.map +0 -1
  150. package/dist/services/actor-system/index.d.ts +0 -2
  151. package/dist/services/actor-system/index.d.ts.map +0 -1
  152. package/dist/services/actor-system/index.js.map +0 -1
  153. package/dist/services/executor-pool/executor-pool.service.d.ts +0 -38
  154. package/dist/services/executor-pool/executor-pool.service.d.ts.map +0 -1
  155. package/dist/services/executor-pool/executor-pool.service.js +0 -166
  156. package/dist/services/executor-pool/executor-pool.service.js.map +0 -1
  157. package/dist/services/executor-pool/index.d.ts +0 -2
  158. package/dist/services/executor-pool/index.d.ts.map +0 -1
  159. package/dist/services/executor-pool/index.js.map +0 -1
  160. package/dist/services/gate/gate.service.d.ts +0 -17
  161. package/dist/services/gate/gate.service.d.ts.map +0 -1
  162. package/dist/services/gate/gate.service.js +0 -81
  163. package/dist/services/gate/gate.service.js.map +0 -1
  164. package/dist/services/gate/index.d.ts +0 -2
  165. package/dist/services/gate/index.d.ts.map +0 -1
  166. package/dist/services/gate/index.js.map +0 -1
  167. package/dist/services/log/index.d.ts +0 -2
  168. package/dist/services/log/index.d.ts.map +0 -1
  169. package/dist/services/log/index.js.map +0 -1
  170. package/dist/services/log/log.service.d.ts +0 -21
  171. package/dist/services/log/log.service.d.ts.map +0 -1
  172. package/dist/services/log/log.service.js +0 -92
  173. package/dist/services/log/log.service.js.map +0 -1
  174. package/dist/services/registry/index.d.ts +0 -4
  175. package/dist/services/registry/index.d.ts.map +0 -1
  176. package/dist/services/registry/index.js +0 -20
  177. package/dist/services/registry/index.js.map +0 -1
  178. package/dist/services/registry/registry.service.d.ts +0 -43
  179. package/dist/services/registry/registry.service.d.ts.map +0 -1
  180. package/dist/services/registry/registry.service.js +0 -367
  181. package/dist/services/registry/registry.service.js.map +0 -1
  182. package/dist/services/registry/registry.types.js.map +0 -1
  183. package/dist/services/registry/schema-converter.d.ts +0 -2
  184. package/dist/services/registry/schema-converter.d.ts.map +0 -1
  185. package/dist/services/registry/schema-converter.js +0 -27
  186. package/dist/services/registry/schema-converter.js.map +0 -1
  187. package/dist/services/result-collector/index.d.ts +0 -2
  188. package/dist/services/result-collector/index.d.ts.map +0 -1
  189. package/dist/services/result-collector/index.js +0 -18
  190. package/dist/services/result-collector/index.js.map +0 -1
  191. package/dist/services/result-collector/result-collector.service.d.ts +0 -17
  192. package/dist/services/result-collector/result-collector.service.d.ts.map +0 -1
  193. package/dist/services/result-collector/result-collector.service.js +0 -92
  194. package/dist/services/result-collector/result-collector.service.js.map +0 -1
  195. package/dist/services/scheduler/index.d.ts +0 -2
  196. package/dist/services/scheduler/index.d.ts.map +0 -1
  197. package/dist/services/scheduler/index.js +0 -18
  198. package/dist/services/scheduler/index.js.map +0 -1
  199. package/dist/services/scheduler/scheduler.service.d.ts +0 -17
  200. package/dist/services/scheduler/scheduler.service.d.ts.map +0 -1
  201. package/dist/services/scheduler/scheduler.service.js +0 -140
  202. package/dist/services/scheduler/scheduler.service.js.map +0 -1
  203. /package/dist/{services/registry → domain/interfaces}/registry.types.d.ts +0 -0
  204. /package/dist/{services/registry → domain/interfaces}/registry.types.js +0 -0
@@ -1,43 +0,0 @@
1
- import { OnModuleInit, OnApplicationShutdown } from '@nestjs/common';
2
- import { DiscoveryService } from '@nestjs/core';
3
- import Redis from 'ioredis';
4
- import { IAtomicQueuesModuleConfig } from '../../domain';
5
- import { EntityContract, MessageSpec, RegistryChange, RegistrySnapshot } from './registry.types';
6
- export declare class RegistryService implements OnModuleInit, OnApplicationShutdown {
7
- private readonly redis;
8
- private readonly config;
9
- private readonly discoveryService;
10
- private readonly logger;
11
- private readonly keyPrefix;
12
- private readonly enabled;
13
- private readonly serviceName;
14
- private readonly schemaValidation;
15
- private readonly registrationTTL;
16
- private readonly heartbeatInterval;
17
- private readonly cache;
18
- private readonly changeListeners;
19
- private heartbeatTimer;
20
- private subscriber;
21
- private readonly ownedEntityTypes;
22
- constructor(redis: Redis, config: IAtomicQueuesModuleConfig, discoveryService: DiscoveryService);
23
- onModuleInit(): Promise<void>;
24
- onApplicationShutdown(): Promise<void>;
25
- getContract(entityType: string): Promise<EntityContract | null>;
26
- listEntityTypes(): Promise<string[]>;
27
- getMessage(entityType: string, messageName: string): Promise<MessageSpec | null>;
28
- watchChanges(callback: (change: RegistryChange) => void): () => void;
29
- exportSnapshot(): Promise<RegistrySnapshot>;
30
- validate(entityType: string, messageName: string, data?: Record<string, any>): Promise<void>;
31
- isEnabled(): boolean;
32
- private publishLocalContracts;
33
- private buildMessageSpec;
34
- private getOrCreateContract;
35
- private publishContract;
36
- private refreshRegistrations;
37
- private handleRegistryUpdate;
38
- private validateJsonSchema;
39
- private getRegistryKey;
40
- private getUpdateChannel;
41
- private scanKeys;
42
- }
43
- //# sourceMappingURL=registry.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.service.d.ts","sourceRoot":"","sources":["../../../src/services/registry/registry.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EACZ,qBAAqB,EAEtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAYzD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjG,qBACa,eAAgB,YAAW,YAAY,EAAE,qBAAqB;IAgB1C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAjB/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OA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;IAgBlC,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,CAAC,kBAAkB;IA6C1B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;YAIV,QAAQ;CAUvB"}
@@ -1,367 +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 __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- var RegistryService_1;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.RegistryService = void 0;
20
- const common_1 = require("@nestjs/common");
21
- const core_1 = require("@nestjs/core");
22
- const ioredis_1 = __importDefault(require("ioredis"));
23
- const utils_1 = require("../../utils");
24
- const decorators_1 = require("../../decorators");
25
- const queue_bus_1 = require("../queue-bus");
26
- const constants_1 = require("../constants");
27
- const schema_converter_1 = require("./schema-converter");
28
- let RegistryService = RegistryService_1 = class RegistryService {
29
- constructor(redis, config, discoveryService) {
30
- this.redis = redis;
31
- this.config = config;
32
- this.discoveryService = discoveryService;
33
- this.logger = new common_1.Logger(RegistryService_1.name);
34
- this.cache = new Map();
35
- this.changeListeners = [];
36
- this.heartbeatTimer = null;
37
- this.subscriber = null;
38
- this.ownedEntityTypes = new Set();
39
- this.keyPrefix = (0, utils_1.resolveKeyPrefix)(config);
40
- this.enabled = config.registry?.enabled ?? false;
41
- this.serviceName = config.registry?.serviceName ?? 'unknown';
42
- this.schemaValidation = config.registry?.schemaValidation ?? false;
43
- this.registrationTTL = config.registry?.registrationTTL ?? 30;
44
- this.heartbeatInterval = config.registry?.heartbeatInterval ?? 10000;
45
- }
46
- async onModuleInit() {
47
- if (!this.enabled)
48
- return;
49
- this.subscriber = this.redis.duplicate();
50
- const updateChannel = this.getUpdateChannel();
51
- await this.subscriber.subscribe(updateChannel);
52
- this.subscriber.on('message', (_ch, payload) => {
53
- this.handleRegistryUpdate(payload);
54
- });
55
- await this.publishLocalContracts();
56
- this.heartbeatTimer = setInterval(() => {
57
- this.refreshRegistrations().catch((err) => {
58
- this.logger.error(`Heartbeat failed: ${err.message}`);
59
- });
60
- }, this.heartbeatInterval);
61
- this.logger.log(`Registry enabled for service '${this.serviceName}' with ${this.ownedEntityTypes.size} entity types`);
62
- }
63
- async onApplicationShutdown() {
64
- if (!this.enabled)
65
- return;
66
- if (this.heartbeatTimer) {
67
- clearInterval(this.heartbeatTimer);
68
- }
69
- if (this.subscriber) {
70
- await this.subscriber.unsubscribe();
71
- await this.subscriber.quit();
72
- }
73
- }
74
- async getContract(entityType) {
75
- if (!this.enabled)
76
- return null;
77
- const cached = this.cache.get(entityType);
78
- if (cached)
79
- return cached;
80
- const key = this.getRegistryKey(entityType);
81
- const raw = await this.redis.get(key);
82
- if (!raw)
83
- return null;
84
- const contract = JSON.parse(raw);
85
- this.cache.set(entityType, contract);
86
- return contract;
87
- }
88
- async listEntityTypes() {
89
- if (!this.enabled)
90
- return [];
91
- const pattern = `${this.keyPrefix}:registry:*`;
92
- const keys = await this.scanKeys(pattern);
93
- return keys.map((k) => k.replace(`${this.keyPrefix}:registry:`, ''));
94
- }
95
- async getMessage(entityType, messageName) {
96
- const contract = await this.getContract(entityType);
97
- if (!contract)
98
- return null;
99
- return contract.messages[messageName] ?? null;
100
- }
101
- watchChanges(callback) {
102
- this.changeListeners.push(callback);
103
- return () => {
104
- const idx = this.changeListeners.indexOf(callback);
105
- if (idx >= 0)
106
- this.changeListeners.splice(idx, 1);
107
- };
108
- }
109
- async exportSnapshot() {
110
- const entityTypes = await this.listEntityTypes();
111
- const entities = [];
112
- for (const et of entityTypes) {
113
- const contract = await this.getContract(et);
114
- if (contract)
115
- entities.push(contract);
116
- }
117
- return {
118
- generatedAt: Date.now(),
119
- keyPrefix: this.keyPrefix,
120
- entities,
121
- };
122
- }
123
- async validate(entityType, messageName, data) {
124
- if (!this.enabled)
125
- return;
126
- const contract = await this.getContract(entityType);
127
- if (!contract) {
128
- throw new Error(`[Registry] Unknown entity type '${entityType}'. ` +
129
- `No service has registered handlers for this entity type. ` +
130
- `Registered types: [${(await this.listEntityTypes()).join(', ')}]`);
131
- }
132
- const msgSpec = contract.messages[messageName];
133
- if (!msgSpec) {
134
- const accepted = Object.keys(contract.messages).join(', ');
135
- throw new Error(`[Registry] Entity '${entityType}' (service: ${contract.serviceName}) does not accept message '${messageName}'. ` +
136
- `Accepted messages: [${accepted}]`);
137
- }
138
- if (this.schemaValidation && msgSpec.schema && data) {
139
- this.validateJsonSchema(data, msgSpec.schema, entityType, messageName);
140
- }
141
- }
142
- isEnabled() {
143
- return this.enabled;
144
- }
145
- async publishLocalContracts() {
146
- if (!this.discoveryService)
147
- return;
148
- const contracts = new Map();
149
- const providers = this.discoveryService.getProviders();
150
- // 1. @JobCommand / @JobQuery classes
151
- for (const wrapper of providers) {
152
- const { metatype } = wrapper;
153
- if (!metatype)
154
- continue;
155
- const cmdMeta = (0, decorators_1.getJobCommandMetadata)(metatype);
156
- if (cmdMeta && cmdMeta.entityType) {
157
- const contract = this.getOrCreateContract(contracts, cmdMeta.entityType);
158
- const msgName = cmdMeta.targetClass.name;
159
- if (!contract.messages[msgName]) {
160
- contract.messages[msgName] = this.buildMessageSpec(cmdMeta.targetClass, 'command');
161
- }
162
- }
163
- const queryMeta = (0, decorators_1.getJobQueryMetadata)(metatype);
164
- if (queryMeta && queryMeta.entityType) {
165
- const contract = this.getOrCreateContract(contracts, queryMeta.entityType);
166
- const msgName = queryMeta.targetClass.name;
167
- if (!contract.messages[msgName]) {
168
- contract.messages[msgName] = this.buildMessageSpec(queryMeta.targetClass, 'query');
169
- }
170
- }
171
- }
172
- // 2. @CommandHandler / @QueryHandler (CQRS)
173
- const COMMAND_HANDLER_METADATA = '__commandHandler__';
174
- const QUERY_HANDLER_METADATA = '__queryHandler__';
175
- for (const wrapper of providers) {
176
- const { metatype } = wrapper;
177
- if (!metatype)
178
- continue;
179
- const commandClass = Reflect.getMetadata(COMMAND_HANDLER_METADATA, metatype);
180
- if (commandClass && typeof commandClass === 'function') {
181
- const entityType = (0, decorators_1.getEntityType)(commandClass);
182
- if (entityType) {
183
- const contract = this.getOrCreateContract(contracts, entityType);
184
- if (!contract.messages[commandClass.name]) {
185
- contract.messages[commandClass.name] = this.buildMessageSpec(commandClass, 'command');
186
- }
187
- }
188
- }
189
- const queryClass = Reflect.getMetadata(QUERY_HANDLER_METADATA, metatype);
190
- if (queryClass && typeof queryClass === 'function') {
191
- const entityType = (0, decorators_1.getEntityType)(queryClass);
192
- if (entityType) {
193
- const contract = this.getOrCreateContract(contracts, entityType);
194
- if (!contract.messages[queryClass.name]) {
195
- contract.messages[queryClass.name] = this.buildMessageSpec(queryClass, 'query');
196
- }
197
- }
198
- }
199
- }
200
- // 3. QueueBus static registry
201
- const queueBusRegistry = queue_bus_1.QueueBus.getAllRegistered();
202
- for (const [className, entry] of queueBusRegistry) {
203
- const entityType = (0, decorators_1.getEntityType)(entry.targetClass);
204
- if (entityType) {
205
- const contract = this.getOrCreateContract(contracts, entityType);
206
- if (!contract.messages[className]) {
207
- contract.messages[className] = this.buildMessageSpec(entry.targetClass, entry.isQuery ? 'query' : 'command');
208
- }
209
- }
210
- }
211
- for (const [entityType, contract] of contracts) {
212
- await this.publishContract(entityType, contract);
213
- this.ownedEntityTypes.add(entityType);
214
- }
215
- }
216
- buildMessageSpec(msgClass, kind) {
217
- const zodSchema = (0, decorators_1.getSchemaMetadata)(msgClass);
218
- const zodReplySchema = (0, decorators_1.getReplySchemaMetadata)(msgClass);
219
- // If no explicit kind given, infer 'query' when a reply schema is present
220
- const inferredKind = kind ?? (zodReplySchema ? 'query' : 'command');
221
- const spec = {
222
- kind: inferredKind,
223
- };
224
- if (zodSchema) {
225
- const jsonSchema = (0, schema_converter_1.convertZodToJsonSchema)(zodSchema);
226
- if (jsonSchema)
227
- spec.schema = jsonSchema;
228
- }
229
- if (zodReplySchema) {
230
- const jsonReplySchema = (0, schema_converter_1.convertZodToJsonSchema)(zodReplySchema);
231
- if (jsonReplySchema)
232
- spec.replySchema = jsonReplySchema;
233
- }
234
- const entityIdField = (0, decorators_1.getEntityIdProperty)(msgClass);
235
- if (entityIdField)
236
- spec.entityIdField = entityIdField;
237
- return spec;
238
- }
239
- getOrCreateContract(map, entityType) {
240
- let contract = map.get(entityType);
241
- if (!contract) {
242
- contract = {
243
- entityType,
244
- serviceName: this.serviceName,
245
- version: '1.0.0',
246
- messages: {},
247
- registeredAt: Date.now(),
248
- lastHeartbeat: Date.now(),
249
- };
250
- map.set(entityType, contract);
251
- }
252
- return contract;
253
- }
254
- async publishContract(entityType, contract) {
255
- const key = this.getRegistryKey(entityType);
256
- const existing = await this.redis.get(key);
257
- if (existing) {
258
- const existingContract = JSON.parse(existing);
259
- if (existingContract.serviceName !== this.serviceName) {
260
- this.logger.log(`Entity type '${entityType}' co-owned: merging with service '${existingContract.serviceName}'`);
261
- contract.messages = { ...existingContract.messages, ...contract.messages };
262
- }
263
- }
264
- contract.lastHeartbeat = Date.now();
265
- await this.redis.set(key, JSON.stringify(contract), 'EX', this.registrationTTL);
266
- this.cache.set(entityType, contract);
267
- const change = {
268
- entityType,
269
- action: existing ? 'updated' : 'registered',
270
- serviceName: this.serviceName,
271
- };
272
- await this.redis.publish(this.getUpdateChannel(), JSON.stringify(change));
273
- }
274
- async refreshRegistrations() {
275
- for (const entityType of this.ownedEntityTypes) {
276
- const key = this.getRegistryKey(entityType);
277
- const raw = await this.redis.get(key);
278
- if (raw) {
279
- const contract = JSON.parse(raw);
280
- contract.lastHeartbeat = Date.now();
281
- await this.redis.set(key, JSON.stringify(contract), 'EX', this.registrationTTL);
282
- }
283
- else {
284
- this.logger.warn(`Registration for '${entityType}' expired — re-publishing`);
285
- await this.publishLocalContracts();
286
- return;
287
- }
288
- }
289
- }
290
- handleRegistryUpdate(payload) {
291
- try {
292
- const change = JSON.parse(payload);
293
- this.cache.delete(change.entityType);
294
- for (const listener of this.changeListeners) {
295
- try {
296
- listener(change);
297
- }
298
- catch (err) {
299
- this.logger.error(`Registry change listener error: ${err.message}`);
300
- }
301
- }
302
- if (this.config.verbose) {
303
- this.logger.debug(`Registry update: ${change.action} ${change.entityType} by ${change.serviceName}`);
304
- }
305
- }
306
- catch {
307
- // Ignore malformed updates
308
- }
309
- }
310
- validateJsonSchema(data, schema, entityType, messageName) {
311
- if (schema.required && Array.isArray(schema.required)) {
312
- const missing = schema.required.filter((prop) => !(prop in data));
313
- if (missing.length > 0) {
314
- throw new Error(`[Registry] Schema validation failed for '${messageName}' on '${entityType}': ` +
315
- `missing required fields: [${missing.join(', ')}]`);
316
- }
317
- }
318
- if (schema.properties && typeof schema.properties === 'object') {
319
- for (const [prop, propSchema] of Object.entries(schema.properties)) {
320
- if (prop in data) {
321
- const expectedType = propSchema.type;
322
- const actualValue = data[prop];
323
- if (expectedType && actualValue !== undefined && actualValue !== null) {
324
- const actualType = typeof actualValue;
325
- const typeMatch = (expectedType === 'string' && actualType === 'string') ||
326
- (expectedType === 'number' && actualType === 'number') ||
327
- (expectedType === 'integer' &&
328
- actualType === 'number' &&
329
- Number.isInteger(actualValue)) ||
330
- (expectedType === 'boolean' && actualType === 'boolean') ||
331
- (expectedType === 'object' && actualType === 'object') ||
332
- (expectedType === 'array' && Array.isArray(actualValue));
333
- if (!typeMatch) {
334
- throw new Error(`[Registry] Schema validation failed for '${messageName}' on '${entityType}': ` +
335
- `field '${prop}' expected ${expectedType}, got ${actualType}`);
336
- }
337
- }
338
- }
339
- }
340
- }
341
- }
342
- getRegistryKey(entityType) {
343
- return `${this.keyPrefix}:registry:${entityType}`;
344
- }
345
- getUpdateChannel() {
346
- return `${this.keyPrefix}:registry:updates`;
347
- }
348
- async scanKeys(pattern) {
349
- let cursor = '0';
350
- const keys = [];
351
- do {
352
- const [nextCursor, foundKeys] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
353
- cursor = nextCursor;
354
- keys.push(...foundKeys);
355
- } while (cursor !== '0');
356
- return keys;
357
- }
358
- };
359
- exports.RegistryService = RegistryService;
360
- exports.RegistryService = RegistryService = RegistryService_1 = __decorate([
361
- (0, common_1.Injectable)(),
362
- __param(0, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_REDIS)),
363
- __param(1, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_CONFIG)),
364
- __param(2, (0, common_1.Optional)()),
365
- __metadata("design:paramtypes", [ioredis_1.default, Object, core_1.DiscoveryService])
366
- ], RegistryService);
367
- //# sourceMappingURL=registry.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.service.js","sourceRoot":"","sources":["../../../src/services/registry/registry.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,uCAAgD;AAChD,sDAA4B;AAE5B,uCAA+C;AAC/C,iDAO0B;AAC1B,4CAAwC;AACxC,4CAAyE;AAEzE,yDAA4D;AAGrD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAe1B,YAC+B,KAA6B,EAC5B,MAAkD,EACpE,gBAAmD;QAFjB,UAAK,GAAL,KAAK,CAAO;QACX,WAAM,GAAN,MAAM,CAA2B;QACnD,qBAAgB,GAAhB,gBAAgB,CAAkB;QAjBhD,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;QAQ1C,UAA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AO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA3ZY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAiBR,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,eAAM,EAAC,gCAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,iBAAQ,GAAE,CAAA;qCAF0C,iBAAK,UAEX,uBAAgB;GAlBtD,eAAe,CA2Z3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.types.js","sourceRoot":"","sources":["../../../src/services/registry/registry.types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare function convertZodToJsonSchema(zodSchema: any): Record<string, any> | undefined;
2
- //# sourceMappingURL=schema-converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-converter.d.ts","sourceRoot":"","sources":["../../../src/services/registry/schema-converter.ts"],"names":[],"mappings":"AAaA,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAYtF"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertZodToJsonSchema = convertZodToJsonSchema;
4
- const common_1 = require("@nestjs/common");
5
- const logger = new common_1.Logger('SchemaConverter');
6
- let zodToJsonSchema = null;
7
- try {
8
- const mod = require('zod-to-json-schema');
9
- zodToJsonSchema = mod.zodToJsonSchema || mod.default?.zodToJsonSchema || mod.default;
10
- }
11
- catch {
12
- // zod-to-json-schema not installed
13
- }
14
- function convertZodToJsonSchema(zodSchema) {
15
- if (!zodToJsonSchema) {
16
- logger.debug('zod-to-json-schema not available — schema will not be serialized');
17
- return undefined;
18
- }
19
- try {
20
- return zodToJsonSchema(zodSchema);
21
- }
22
- catch (err) {
23
- logger.warn(`Failed to convert Zod schema: ${err.message}`);
24
- return undefined;
25
- }
26
- }
27
- //# sourceMappingURL=schema-converter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-converter.js","sourceRoot":"","sources":["../../../src/services/registry/schema-converter.ts"],"names":[],"mappings":";;AAaA,wDAYC;AAzBD,2CAAwC;AAExC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAiB,CAAC,CAAC;AAE7C,IAAI,eAAe,GAAkC,IAAI,CAAC;AAE1D,IAAI,CAAC;IACH,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC1C,eAAe,GAAG,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,OAAO,EAAE,eAAe,IAAI,GAAG,CAAC,OAAO,CAAC;AACvF,CAAC;AAAC,MAAM,CAAC;IACP,mCAAmC;AACrC,CAAC;AAED,SAAgB,sBAAsB,CAAC,SAAc;IACnD,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACjF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,SAAS,CAAwB,CAAC;IAC3D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,iCAAkC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './result-collector.service';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/result-collector/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
@@ -1,18 +0,0 @@
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("./result-collector.service"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/result-collector/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C"}
@@ -1,17 +0,0 @@
1
- import { OnModuleInit, OnApplicationShutdown } from '@nestjs/common';
2
- import Redis from 'ioredis';
3
- import { IAtomicQueuesModuleConfig } from '../../domain';
4
- export declare class ResultCollector implements OnModuleInit, OnApplicationShutdown {
5
- private readonly redis;
6
- private readonly config;
7
- private readonly logger;
8
- private readonly keyPrefix;
9
- private readonly pending;
10
- private subscriber;
11
- constructor(redis: Redis, config: IAtomicQueuesModuleConfig);
12
- onModuleInit(): Promise<void>;
13
- onApplicationShutdown(): Promise<void>;
14
- waitForResult<R = any>(correlationId: string, timeout: number): Promise<R>;
15
- pendingCount(): number;
16
- }
17
- //# sourceMappingURL=result-collector.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"result-collector.service.d.ts","sourceRoot":"","sources":["../../../src/services/result-collector/result-collector.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAUzD,qBACa,eAAgB,YAAW,YAAY,EAAE,qBAAqB;IAO1C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,UAAU,CAAsB;gBAGQ,KAAK,EAAE,KAAK,EACX,MAAM,EAAE,yBAAyB;IAK5E,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B7B,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5C,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAW1E,YAAY,IAAI,MAAM;CAGvB"}
@@ -1,92 +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 __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- var ResultCollector_1;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.ResultCollector = void 0;
20
- const common_1 = require("@nestjs/common");
21
- const ioredis_1 = __importDefault(require("ioredis"));
22
- const utils_1 = require("../../utils");
23
- const constants_1 = require("../constants");
24
- let ResultCollector = ResultCollector_1 = class ResultCollector {
25
- constructor(redis, config) {
26
- this.redis = redis;
27
- this.config = config;
28
- this.logger = new common_1.Logger(ResultCollector_1.name);
29
- this.pending = new Map();
30
- this.subscriber = null;
31
- this.keyPrefix = (0, utils_1.resolveKeyPrefix)(config);
32
- }
33
- async onModuleInit() {
34
- this.subscriber = this.redis.duplicate();
35
- const pattern = `${this.keyPrefix}:results:*`;
36
- await this.subscriber.psubscribe(pattern);
37
- this.subscriber.on('pmessage', (_pattern, channel, payload) => {
38
- const parts = channel.split(':');
39
- const correlationId = parts[parts.length - 1];
40
- const entry = this.pending.get(correlationId);
41
- if (!entry)
42
- return;
43
- clearTimeout(entry.timer);
44
- this.pending.delete(correlationId);
45
- try {
46
- const parsed = JSON.parse(payload);
47
- if (parsed.error) {
48
- entry.reject(new Error(parsed.error));
49
- }
50
- else {
51
- entry.resolve(parsed.result);
52
- }
53
- }
54
- catch (err) {
55
- entry.reject(new Error(`Failed to parse result: ${err.message}`));
56
- }
57
- });
58
- this.logger.log('ResultCollector initialized with pattern subscription');
59
- }
60
- async onApplicationShutdown() {
61
- for (const [, entry] of this.pending) {
62
- clearTimeout(entry.timer);
63
- entry.reject(new Error('Application shutting down'));
64
- }
65
- this.pending.clear();
66
- if (this.subscriber) {
67
- await this.subscriber.punsubscribe();
68
- await this.subscriber.quit();
69
- this.subscriber = null;
70
- }
71
- }
72
- waitForResult(correlationId, timeout) {
73
- return new Promise((resolve, reject) => {
74
- const timer = setTimeout(() => {
75
- this.pending.delete(correlationId);
76
- reject(new Error(`Result timeout after ${timeout}ms for correlation ${correlationId}`));
77
- }, timeout);
78
- this.pending.set(correlationId, { resolve, reject, timer });
79
- });
80
- }
81
- pendingCount() {
82
- return this.pending.size;
83
- }
84
- };
85
- exports.ResultCollector = ResultCollector;
86
- exports.ResultCollector = ResultCollector = ResultCollector_1 = __decorate([
87
- (0, common_1.Injectable)(),
88
- __param(0, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_REDIS)),
89
- __param(1, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_CONFIG)),
90
- __metadata("design:paramtypes", [ioredis_1.default, Object])
91
- ], ResultCollector);
92
- //# sourceMappingURL=result-collector.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"result-collector.service.js","sourceRoot":"","sources":["../../../src/services/result-collector/result-collector.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAiG;AACjG,sDAA4B;AAE5B,uCAA+C;AAC/C,4CAAyE;AASlE,IAAM,eAAe,uBAArB,MAAM,eAAe;IAM1B,YAC+B,KAA6B,EAC5B,MAAkD;QADlC,UAAK,GAAL,KAAK,CAAO;QACX,WAAM,GAAN,MAAM,CAA2B;QAPjE,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;QAE1C,YAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;QACpD,eAAU,GAAiB,IAAI,CAAC;QAMtC,IAAI,CAAC,SAAS,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,SAAS,YAAY,CAAC;QAC9C,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAE1C,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAgB,EAAE,OAAe,EAAE,OAAe,EAAE,EAAE;YACpF,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE9C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,C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ACzB,CAAC;IACH,CAAC;IAED,aAAa,CAAU,aAAqB,EAAE,OAAe;QAC3D,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBACnC,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,OAAO,sBAAsB,aAAa,EAAE,CAAC,CAAC,CAAC;YAC1F,CAAC,EAAE,OAAO,CAAC,CAAC;YAEZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF,CAAA;AAvEY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,eAAM,EAAC,gCAAoB,CAAC,CAAA;qCADwB,iBAAK;GAPjD,eAAe,CAuE3B"}
@@ -1,2 +0,0 @@
1
- export * from './scheduler.service';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/scheduler/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}