llm-content-creator 0.1.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 (438) hide show
  1. package/README.md +309 -0
  2. package/dist/application/workflow/SyncExecutor.d.ts +75 -0
  3. package/dist/application/workflow/SyncExecutor.d.ts.map +1 -0
  4. package/dist/application/workflow/SyncExecutor.js +370 -0
  5. package/dist/application/workflow/SyncExecutor.js.map +1 -0
  6. package/dist/application/workflow/types.d.ts +46 -0
  7. package/dist/application/workflow/types.d.ts.map +1 -0
  8. package/dist/application/workflow/types.js +7 -0
  9. package/dist/application/workflow/types.js.map +1 -0
  10. package/dist/config/index.d.ts +173 -0
  11. package/dist/config/index.d.ts.map +1 -0
  12. package/dist/config/index.js +288 -0
  13. package/dist/config/index.js.map +1 -0
  14. package/dist/domain/entities/QualityCheck.d.ts +181 -0
  15. package/dist/domain/entities/QualityCheck.d.ts.map +1 -0
  16. package/dist/domain/entities/QualityCheck.js +39 -0
  17. package/dist/domain/entities/QualityCheck.js.map +1 -0
  18. package/dist/domain/entities/Result.d.ts +103 -0
  19. package/dist/domain/entities/Result.d.ts.map +1 -0
  20. package/dist/domain/entities/Result.js +15 -0
  21. package/dist/domain/entities/Result.js.map +1 -0
  22. package/dist/domain/entities/Task.d.ts +130 -0
  23. package/dist/domain/entities/Task.d.ts.map +1 -0
  24. package/dist/domain/entities/Task.js +64 -0
  25. package/dist/domain/entities/Task.js.map +1 -0
  26. package/dist/domain/entities/TaskStep.d.ts +160 -0
  27. package/dist/domain/entities/TaskStep.d.ts.map +1 -0
  28. package/dist/domain/entities/TaskStep.js +30 -0
  29. package/dist/domain/entities/TaskStep.js.map +1 -0
  30. package/dist/domain/entities/TokenUsage.d.ts +70 -0
  31. package/dist/domain/entities/TokenUsage.d.ts.map +1 -0
  32. package/dist/domain/entities/TokenUsage.js +42 -0
  33. package/dist/domain/entities/TokenUsage.js.map +1 -0
  34. package/dist/domain/entities/index.d.ts +11 -0
  35. package/dist/domain/entities/index.d.ts.map +1 -0
  36. package/dist/domain/entities/index.js +16 -0
  37. package/dist/domain/entities/index.js.map +1 -0
  38. package/dist/domain/repositories/QualityCheckRepository.d.ts +49 -0
  39. package/dist/domain/repositories/QualityCheckRepository.d.ts.map +1 -0
  40. package/dist/domain/repositories/QualityCheckRepository.js +5 -0
  41. package/dist/domain/repositories/QualityCheckRepository.js.map +1 -0
  42. package/dist/domain/repositories/ResultRepository.d.ts +43 -0
  43. package/dist/domain/repositories/ResultRepository.d.ts.map +1 -0
  44. package/dist/domain/repositories/ResultRepository.js +5 -0
  45. package/dist/domain/repositories/ResultRepository.js.map +1 -0
  46. package/dist/domain/repositories/TaskRepository.d.ts +240 -0
  47. package/dist/domain/repositories/TaskRepository.d.ts.map +1 -0
  48. package/dist/domain/repositories/TaskRepository.js +7 -0
  49. package/dist/domain/repositories/TaskRepository.js.map +1 -0
  50. package/dist/domain/workflow/CheckpointManager.d.ts +94 -0
  51. package/dist/domain/workflow/CheckpointManager.d.ts.map +1 -0
  52. package/dist/domain/workflow/CheckpointManager.js +224 -0
  53. package/dist/domain/workflow/CheckpointManager.js.map +1 -0
  54. package/dist/domain/workflow/ContentCreatorGraph.d.ts +17 -0
  55. package/dist/domain/workflow/ContentCreatorGraph.d.ts.map +1 -0
  56. package/dist/domain/workflow/ContentCreatorGraph.js +381 -0
  57. package/dist/domain/workflow/ContentCreatorGraph.js.map +1 -0
  58. package/dist/domain/workflow/State.d.ts +172 -0
  59. package/dist/domain/workflow/State.d.ts.map +1 -0
  60. package/dist/domain/workflow/State.js +184 -0
  61. package/dist/domain/workflow/State.js.map +1 -0
  62. package/dist/domain/workflow/index.d.ts +11 -0
  63. package/dist/domain/workflow/index.d.ts.map +1 -0
  64. package/dist/domain/workflow/index.js +15 -0
  65. package/dist/domain/workflow/index.js.map +1 -0
  66. package/dist/domain/workflow/nodes/BaseNode.d.ts +134 -0
  67. package/dist/domain/workflow/nodes/BaseNode.d.ts.map +1 -0
  68. package/dist/domain/workflow/nodes/BaseNode.js +253 -0
  69. package/dist/domain/workflow/nodes/BaseNode.js.map +1 -0
  70. package/dist/domain/workflow/nodes/CheckImageNode.d.ts +43 -0
  71. package/dist/domain/workflow/nodes/CheckImageNode.d.ts.map +1 -0
  72. package/dist/domain/workflow/nodes/CheckImageNode.js +254 -0
  73. package/dist/domain/workflow/nodes/CheckImageNode.js.map +1 -0
  74. package/dist/domain/workflow/nodes/CheckTextNode.d.ts +66 -0
  75. package/dist/domain/workflow/nodes/CheckTextNode.d.ts.map +1 -0
  76. package/dist/domain/workflow/nodes/CheckTextNode.js +530 -0
  77. package/dist/domain/workflow/nodes/CheckTextNode.js.map +1 -0
  78. package/dist/domain/workflow/nodes/GenerateImageNode.d.ts +44 -0
  79. package/dist/domain/workflow/nodes/GenerateImageNode.d.ts.map +1 -0
  80. package/dist/domain/workflow/nodes/GenerateImageNode.js +272 -0
  81. package/dist/domain/workflow/nodes/GenerateImageNode.js.map +1 -0
  82. package/dist/domain/workflow/nodes/OrganizeNode.d.ts +49 -0
  83. package/dist/domain/workflow/nodes/OrganizeNode.d.ts.map +1 -0
  84. package/dist/domain/workflow/nodes/OrganizeNode.js +241 -0
  85. package/dist/domain/workflow/nodes/OrganizeNode.js.map +1 -0
  86. package/dist/domain/workflow/nodes/SearchNode.d.ts +48 -0
  87. package/dist/domain/workflow/nodes/SearchNode.d.ts.map +1 -0
  88. package/dist/domain/workflow/nodes/SearchNode.js +151 -0
  89. package/dist/domain/workflow/nodes/SearchNode.js.map +1 -0
  90. package/dist/domain/workflow/nodes/WriteNode.d.ts +68 -0
  91. package/dist/domain/workflow/nodes/WriteNode.d.ts.map +1 -0
  92. package/dist/domain/workflow/nodes/WriteNode.js +431 -0
  93. package/dist/domain/workflow/nodes/WriteNode.js.map +1 -0
  94. package/dist/domain/workflow/nodes/config/index.js +287 -0
  95. package/dist/domain/workflow/nodes/domain/entities/Task.js +68 -0
  96. package/dist/domain/workflow/nodes/domain/workflow/State.js +200 -0
  97. package/dist/domain/workflow/nodes/domain/workflow/nodes/BaseNode.js +328 -0
  98. package/dist/domain/workflow/nodes/domain/workflow/nodes/CheckTextNode.js +500 -0
  99. package/dist/domain/workflow/nodes/index.d.ts +13 -0
  100. package/dist/domain/workflow/nodes/index.d.ts.map +1 -0
  101. package/dist/domain/workflow/nodes/index.js +13 -0
  102. package/dist/domain/workflow/nodes/index.js.map +1 -0
  103. package/dist/domain/workflow/nodes/infrastructure/logging/logger.js +275 -0
  104. package/dist/domain/workflow/nodes/services/llm/EnhancedLLMService.js +559 -0
  105. package/dist/index.d.ts +24 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +34 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/infrastructure/cache/CacheService.d.ts +139 -0
  110. package/dist/infrastructure/cache/CacheService.d.ts.map +1 -0
  111. package/dist/infrastructure/cache/CacheService.js +419 -0
  112. package/dist/infrastructure/cache/CacheService.js.map +1 -0
  113. package/dist/infrastructure/cache/index.d.ts +5 -0
  114. package/dist/infrastructure/cache/index.d.ts.map +1 -0
  115. package/dist/infrastructure/cache/index.js +6 -0
  116. package/dist/infrastructure/cache/index.js.map +1 -0
  117. package/dist/infrastructure/database/BaseRepository.d.ts +98 -0
  118. package/dist/infrastructure/database/BaseRepository.d.ts.map +1 -0
  119. package/dist/infrastructure/database/BaseRepository.js +178 -0
  120. package/dist/infrastructure/database/BaseRepository.js.map +1 -0
  121. package/dist/infrastructure/database/MemoryTaskRepository.d.ts +77 -0
  122. package/dist/infrastructure/database/MemoryTaskRepository.d.ts.map +1 -0
  123. package/dist/infrastructure/database/MemoryTaskRepository.js +309 -0
  124. package/dist/infrastructure/database/MemoryTaskRepository.js.map +1 -0
  125. package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts +36 -0
  126. package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts.map +1 -0
  127. package/dist/infrastructure/database/PostgresQualityCheckRepository.js +89 -0
  128. package/dist/infrastructure/database/PostgresQualityCheckRepository.js.map +1 -0
  129. package/dist/infrastructure/database/PostgresTaskRepository.d.ts +94 -0
  130. package/dist/infrastructure/database/PostgresTaskRepository.d.ts.map +1 -0
  131. package/dist/infrastructure/database/PostgresTaskRepository.js +364 -0
  132. package/dist/infrastructure/database/PostgresTaskRepository.js.map +1 -0
  133. package/dist/infrastructure/database/ResultRepository.d.ts +41 -0
  134. package/dist/infrastructure/database/ResultRepository.d.ts.map +1 -0
  135. package/dist/infrastructure/database/ResultRepository.js +86 -0
  136. package/dist/infrastructure/database/ResultRepository.js.map +1 -0
  137. package/dist/infrastructure/database/SQLiteTaskRepository.d.ts +101 -0
  138. package/dist/infrastructure/database/SQLiteTaskRepository.d.ts.map +1 -0
  139. package/dist/infrastructure/database/SQLiteTaskRepository.js +548 -0
  140. package/dist/infrastructure/database/SQLiteTaskRepository.js.map +1 -0
  141. package/dist/infrastructure/database/index.d.ts +32 -0
  142. package/dist/infrastructure/database/index.d.ts.map +1 -0
  143. package/dist/infrastructure/database/index.js +72 -0
  144. package/dist/infrastructure/database/index.js.map +1 -0
  145. package/dist/infrastructure/logging/logger.d.ts +69 -0
  146. package/dist/infrastructure/logging/logger.d.ts.map +1 -0
  147. package/dist/infrastructure/logging/logger.js +169 -0
  148. package/dist/infrastructure/logging/logger.js.map +1 -0
  149. package/dist/infrastructure/monitoring/LoggingService.d.ts +109 -0
  150. package/dist/infrastructure/monitoring/LoggingService.d.ts.map +1 -0
  151. package/dist/infrastructure/monitoring/LoggingService.js +198 -0
  152. package/dist/infrastructure/monitoring/LoggingService.js.map +1 -0
  153. package/dist/infrastructure/monitoring/MetricsService.d.ts +112 -0
  154. package/dist/infrastructure/monitoring/MetricsService.d.ts.map +1 -0
  155. package/dist/infrastructure/monitoring/MetricsService.js +362 -0
  156. package/dist/infrastructure/monitoring/MetricsService.js.map +1 -0
  157. package/dist/infrastructure/monitoring/SentryService.d.ts +108 -0
  158. package/dist/infrastructure/monitoring/SentryService.d.ts.map +1 -0
  159. package/dist/infrastructure/monitoring/SentryService.js +282 -0
  160. package/dist/infrastructure/monitoring/SentryService.js.map +1 -0
  161. package/dist/infrastructure/monitoring/index.d.ts +7 -0
  162. package/dist/infrastructure/monitoring/index.d.ts.map +1 -0
  163. package/dist/infrastructure/monitoring/index.js +10 -0
  164. package/dist/infrastructure/monitoring/index.js.map +1 -0
  165. package/dist/infrastructure/queue/TaskQueue.d.ts +110 -0
  166. package/dist/infrastructure/queue/TaskQueue.d.ts.map +1 -0
  167. package/dist/infrastructure/queue/TaskQueue.js +363 -0
  168. package/dist/infrastructure/queue/TaskQueue.js.map +1 -0
  169. package/dist/infrastructure/queue/index.d.ts +5 -0
  170. package/dist/infrastructure/queue/index.d.ts.map +1 -0
  171. package/dist/infrastructure/queue/index.js +5 -0
  172. package/dist/infrastructure/queue/index.js.map +1 -0
  173. package/dist/infrastructure/redis/connection.d.ts +61 -0
  174. package/dist/infrastructure/redis/connection.d.ts.map +1 -0
  175. package/dist/infrastructure/redis/connection.js +184 -0
  176. package/dist/infrastructure/redis/connection.js.map +1 -0
  177. package/dist/infrastructure/redis/index.d.ts +5 -0
  178. package/dist/infrastructure/redis/index.d.ts.map +1 -0
  179. package/dist/infrastructure/redis/index.js +5 -0
  180. package/dist/infrastructure/redis/index.js.map +1 -0
  181. package/dist/infrastructure/security/ApiKeyService.d.ts +103 -0
  182. package/dist/infrastructure/security/ApiKeyService.d.ts.map +1 -0
  183. package/dist/infrastructure/security/ApiKeyService.js +250 -0
  184. package/dist/infrastructure/security/ApiKeyService.js.map +1 -0
  185. package/dist/infrastructure/security/QuotaService.d.ts +87 -0
  186. package/dist/infrastructure/security/QuotaService.d.ts.map +1 -0
  187. package/dist/infrastructure/security/QuotaService.js +303 -0
  188. package/dist/infrastructure/security/QuotaService.js.map +1 -0
  189. package/dist/infrastructure/security/RateLimiter.d.ts +104 -0
  190. package/dist/infrastructure/security/RateLimiter.d.ts.map +1 -0
  191. package/dist/infrastructure/security/RateLimiter.js +331 -0
  192. package/dist/infrastructure/security/RateLimiter.js.map +1 -0
  193. package/dist/infrastructure/security/index.d.ts +7 -0
  194. package/dist/infrastructure/security/index.d.ts.map +1 -0
  195. package/dist/infrastructure/security/index.js +10 -0
  196. package/dist/infrastructure/security/index.js.map +1 -0
  197. package/dist/monitoring/index.d.ts +5 -0
  198. package/dist/monitoring/index.d.ts.map +1 -0
  199. package/dist/monitoring/index.js +5 -0
  200. package/dist/monitoring/index.js.map +1 -0
  201. package/dist/monitoring/server.d.ts +14 -0
  202. package/dist/monitoring/server.d.ts.map +1 -0
  203. package/dist/monitoring/server.js +99 -0
  204. package/dist/monitoring/server.js.map +1 -0
  205. package/dist/presentation/cli/commands/cancel.d.ts +8 -0
  206. package/dist/presentation/cli/commands/cancel.d.ts.map +1 -0
  207. package/dist/presentation/cli/commands/cancel.js +57 -0
  208. package/dist/presentation/cli/commands/cancel.js.map +1 -0
  209. package/dist/presentation/cli/commands/create.d.ts +8 -0
  210. package/dist/presentation/cli/commands/create.d.ts.map +1 -0
  211. package/dist/presentation/cli/commands/create.js +368 -0
  212. package/dist/presentation/cli/commands/create.js.map +1 -0
  213. package/dist/presentation/cli/commands/result.d.ts +8 -0
  214. package/dist/presentation/cli/commands/result.d.ts.map +1 -0
  215. package/dist/presentation/cli/commands/result.js +121 -0
  216. package/dist/presentation/cli/commands/result.js.map +1 -0
  217. package/dist/presentation/cli/commands/status.d.ts +8 -0
  218. package/dist/presentation/cli/commands/status.d.ts.map +1 -0
  219. package/dist/presentation/cli/commands/status.js +92 -0
  220. package/dist/presentation/cli/commands/status.js.map +1 -0
  221. package/dist/presentation/cli/index.d.ts +8 -0
  222. package/dist/presentation/cli/index.d.ts.map +1 -0
  223. package/dist/presentation/cli/index.js +32 -0
  224. package/dist/presentation/cli/index.js.map +1 -0
  225. package/dist/presentation/cli/utils/cleanup.d.ts +14 -0
  226. package/dist/presentation/cli/utils/cleanup.d.ts.map +1 -0
  227. package/dist/presentation/cli/utils/cleanup.js +62 -0
  228. package/dist/presentation/cli/utils/cleanup.js.map +1 -0
  229. package/dist/presentation/cli/utils/formatter.d.ts +28 -0
  230. package/dist/presentation/cli/utils/formatter.d.ts.map +1 -0
  231. package/dist/presentation/cli/utils/formatter.js +68 -0
  232. package/dist/presentation/cli/utils/formatter.js.map +1 -0
  233. package/dist/presentation/cli.d.ts +7 -0
  234. package/dist/presentation/cli.d.ts.map +1 -0
  235. package/dist/presentation/cli.js +8 -0
  236. package/dist/presentation/cli.js.map +1 -0
  237. package/dist/presentation/monitor-cli.d.ts +8 -0
  238. package/dist/presentation/monitor-cli.d.ts.map +1 -0
  239. package/dist/presentation/monitor-cli.js +44 -0
  240. package/dist/presentation/monitor-cli.js.map +1 -0
  241. package/dist/presentation/worker-cli.d.ts +8 -0
  242. package/dist/presentation/worker-cli.d.ts.map +1 -0
  243. package/dist/presentation/worker-cli.js +51 -0
  244. package/dist/presentation/worker-cli.js.map +1 -0
  245. package/dist/schedulers/TaskScheduler.d.ts +99 -0
  246. package/dist/schedulers/TaskScheduler.d.ts.map +1 -0
  247. package/dist/schedulers/TaskScheduler.js +233 -0
  248. package/dist/schedulers/TaskScheduler.js.map +1 -0
  249. package/dist/schedulers/index.d.ts +5 -0
  250. package/dist/schedulers/index.d.ts.map +1 -0
  251. package/dist/schedulers/index.js +5 -0
  252. package/dist/schedulers/index.js.map +1 -0
  253. package/dist/services/image/ImageService.d.ts +68 -0
  254. package/dist/services/image/ImageService.d.ts.map +1 -0
  255. package/dist/services/image/ImageService.js +166 -0
  256. package/dist/services/image/ImageService.js.map +1 -0
  257. package/dist/services/index.d.ts +8 -0
  258. package/dist/services/index.d.ts.map +1 -0
  259. package/dist/services/index.js +12 -0
  260. package/dist/services/index.js.map +1 -0
  261. package/dist/services/llm/EnhancedLLMService.d.ts +148 -0
  262. package/dist/services/llm/EnhancedLLMService.d.ts.map +1 -0
  263. package/dist/services/llm/EnhancedLLMService.js +425 -0
  264. package/dist/services/llm/EnhancedLLMService.js.map +1 -0
  265. package/dist/services/llm/LLMService.d.ts +103 -0
  266. package/dist/services/llm/LLMService.d.ts.map +1 -0
  267. package/dist/services/llm/LLMService.js +212 -0
  268. package/dist/services/llm/LLMService.js.map +1 -0
  269. package/dist/services/quality/HardRuleChecker.d.ts +143 -0
  270. package/dist/services/quality/HardRuleChecker.d.ts.map +1 -0
  271. package/dist/services/quality/HardRuleChecker.js +353 -0
  272. package/dist/services/quality/HardRuleChecker.js.map +1 -0
  273. package/dist/services/quality/LLMEvaluator.d.ts +105 -0
  274. package/dist/services/quality/LLMEvaluator.d.ts.map +1 -0
  275. package/dist/services/quality/LLMEvaluator.js +312 -0
  276. package/dist/services/quality/LLMEvaluator.js.map +1 -0
  277. package/dist/services/quality/QualityCheckService.d.ts +112 -0
  278. package/dist/services/quality/QualityCheckService.d.ts.map +1 -0
  279. package/dist/services/quality/QualityCheckService.js +342 -0
  280. package/dist/services/quality/QualityCheckService.js.map +1 -0
  281. package/dist/services/quality/QualityService.d.ts +75 -0
  282. package/dist/services/quality/QualityService.d.ts.map +1 -0
  283. package/dist/services/quality/QualityService.js +360 -0
  284. package/dist/services/quality/QualityService.js.map +1 -0
  285. package/dist/services/quality/index.d.ts +7 -0
  286. package/dist/services/quality/index.d.ts.map +1 -0
  287. package/dist/services/quality/index.js +10 -0
  288. package/dist/services/quality/index.js.map +1 -0
  289. package/dist/services/search/SearchService.d.ts +79 -0
  290. package/dist/services/search/SearchService.d.ts.map +1 -0
  291. package/dist/services/search/SearchService.js +193 -0
  292. package/dist/services/search/SearchService.js.map +1 -0
  293. package/dist/workers/TaskWorker.d.ts +61 -0
  294. package/dist/workers/TaskWorker.d.ts.map +1 -0
  295. package/dist/workers/TaskWorker.js +256 -0
  296. package/dist/workers/TaskWorker.js.map +1 -0
  297. package/dist/workers/index.d.ts +5 -0
  298. package/dist/workers/index.d.ts.map +1 -0
  299. package/dist/workers/index.js +5 -0
  300. package/dist/workers/index.js.map +1 -0
  301. package/docs/DOCUMENTATION-ANALYSIS.md +190 -0
  302. package/docs/README.md +145 -0
  303. package/docs/SOURCE-CODE-ANALYSIS.md +1107 -0
  304. package/docs/architecture-complete.md +5524 -0
  305. package/docs/archive/implementation/implementation-analysis/README.md +244 -0
  306. package/docs/archive/implementation/implementation-analysis/implementation-analysis-context.md +483 -0
  307. package/docs/archive/implementation/implementation-analysis/implementation-analysis-plan.md +1242 -0
  308. package/docs/archive/implementation/implementation-analysis/implementation-analysis-tasks.md +777 -0
  309. package/docs/archive/phases/phase-1/phase-1-completion-summary.md +284 -0
  310. package/docs/archive/phases/phase-1/phase-1-implementation-guide.md +1380 -0
  311. package/docs/archive/phases/phase-2/phase-2a/phase-2a-completion-summary.md +443 -0
  312. package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-report.md +430 -0
  313. package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-summary.md +592 -0
  314. package/docs/archive/phases/phase-2/phase-2b/phase-2b-final-summary.md +371 -0
  315. package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation-complete.md +343 -0
  316. package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation.md +945 -0
  317. package/docs/archive/phases/phase-2/phase-2b/phase-2b-progress-update.md +366 -0
  318. package/docs/archive/phases/phase-3/phase-3-completion-summary.md +354 -0
  319. package/docs/archive/phases/phase-3/phase-3-development-plan.md +878 -0
  320. package/docs/archive/phases/phase-3/phase-3-quick-start.md +324 -0
  321. package/docs/archive/phases/phase-4/phase-4-completion-summary.md +708 -0
  322. package/docs/archive/phases/phase-4/phase-4-development-plan.md +740 -0
  323. package/docs/archive/phases/phase-4/phase-4-quick-start.md +632 -0
  324. package/docs/archive/phases/phase-4/phase-4-session-3-security-testing.md +484 -0
  325. package/docs/archive/phases/phase-4/phase-4-session-4-unit-tests.md +550 -0
  326. package/docs/archive/phases/phase-4/phase-4-session-5-security-tests.md +564 -0
  327. package/docs/archive/phases/phase-4/phase-4-session-6-cache-integration.md +456 -0
  328. package/docs/archive/phases/phase-4/phase-4-session-7-test-fixes.md +348 -0
  329. package/docs/archive/phases/phase-4/phase-4-session-8-taskqueue-fixes.md +323 -0
  330. package/docs/archive/phases/phase-4/phase-4-session-summary-continued.md +373 -0
  331. package/docs/archive/phases/phase-4/phase-4-session-summary.md +595 -0
  332. package/docs/archive/reports/progress-reports/PHASE_0_PROGRESS.md +242 -0
  333. package/docs/archive/reports/progress-reports/PHASE_0_SUMMARY.md +262 -0
  334. package/docs/archive/reports/progress-reports/PHASE_1_2_ISSUES.md +399 -0
  335. package/docs/archive/reports/progress-reports/PHASE_1_PROGRESS.md +388 -0
  336. package/docs/archive/reports/progress-reports/PHASE_3_PREPARATION.md +574 -0
  337. package/docs/archive/reports/progress-reports/current-progress-update.md +294 -0
  338. package/docs/archive/reports/progress-reports/final-summary.md +215 -0
  339. package/docs/archive/reports/progress-reports/implementation-summary.md +287 -0
  340. package/docs/archive/reports/progress-reports/project-progress-report.md +440 -0
  341. package/docs/archive/reports/progress-reports/project-progress.md +386 -0
  342. package/docs/archive/reports/test-reports/TEST-COVERAGE-REPORT.md +441 -0
  343. package/docs/archive/reports/test-reports/e2e-test-report.md +293 -0
  344. package/docs/archive/reports/test-reports/final-test-report.md +367 -0
  345. package/docs/archive/reports/test-reports/real-env-test-report.md +391 -0
  346. package/docs/archive/reports/test-reports/test-completion-summary.md +356 -0
  347. package/docs/archive/reports/test-reports/test-report.md +371 -0
  348. package/docs/archive/sessions/session-2-summary.md +429 -0
  349. package/docs/archive/sessions/session-3-summary.md +395 -0
  350. package/docs/archive/sessions/session-summary.md +370 -0
  351. package/docs/config-system-update.md +239 -0
  352. package/docs/database-refactoring-PLAN.md +199 -0
  353. package/docs/database-refactoring-SUMMARY.md +384 -0
  354. package/docs/quality-check-architecture.md +1030 -0
  355. package/docs/quick-start.md +388 -0
  356. package/docs/references/bullmq-quick-reference.md +525 -0
  357. package/docs/references/monitoring-optimization-guide.md +871 -0
  358. package/docs/references/performance-optimization-guide.md +933 -0
  359. package/docs/storage-guide.md +612 -0
  360. package/docs/test-implementation-PLAN.md +223 -0
  361. package/docs/test-implementation-SUMMARY.md +194 -0
  362. package/docs/user-guide.md +719 -0
  363. package/docs/workflow-architecture.md +549 -0
  364. package/package.json +126 -0
  365. package/src/application/workflow/SyncExecutor.ts +444 -0
  366. package/src/application/workflow/types.ts +57 -0
  367. package/src/config/index.ts +352 -0
  368. package/src/domain/entities/QualityCheck.ts +202 -0
  369. package/src/domain/entities/Result.ts +130 -0
  370. package/src/domain/entities/Task.ts +178 -0
  371. package/src/domain/entities/TaskStep.ts +188 -0
  372. package/src/domain/entities/TokenUsage.ts +119 -0
  373. package/src/domain/entities/index.ts +20 -0
  374. package/src/domain/repositories/QualityCheckRepository.ts +52 -0
  375. package/src/domain/repositories/ResultRepository.ts +47 -0
  376. package/src/domain/repositories/TaskRepository.ts +271 -0
  377. package/src/domain/workflow/CheckpointManager.ts +283 -0
  378. package/src/domain/workflow/ContentCreatorGraph.ts +446 -0
  379. package/src/domain/workflow/State.ts +321 -0
  380. package/src/domain/workflow/index.ts +18 -0
  381. package/src/domain/workflow/nodes/BaseNode.ts +325 -0
  382. package/src/domain/workflow/nodes/CheckImageNode.ts +325 -0
  383. package/src/domain/workflow/nodes/CheckTextNode.ts +709 -0
  384. package/src/domain/workflow/nodes/GenerateImageNode.ts +342 -0
  385. package/src/domain/workflow/nodes/OrganizeNode.ts +304 -0
  386. package/src/domain/workflow/nodes/SearchNode.ts +192 -0
  387. package/src/domain/workflow/nodes/WriteNode.ts +505 -0
  388. package/src/domain/workflow/nodes/index.ts +13 -0
  389. package/src/index.ts +43 -0
  390. package/src/infrastructure/cache/CacheService.ts +483 -0
  391. package/src/infrastructure/cache/index.ts +6 -0
  392. package/src/infrastructure/database/BaseRepository.ts +214 -0
  393. package/src/infrastructure/database/MemoryTaskRepository.ts +377 -0
  394. package/src/infrastructure/database/PostgresQualityCheckRepository.ts +115 -0
  395. package/src/infrastructure/database/PostgresTaskRepository.ts +424 -0
  396. package/src/infrastructure/database/ResultRepository.ts +113 -0
  397. package/src/infrastructure/database/SQLiteTaskRepository.ts +651 -0
  398. package/src/infrastructure/database/index.ts +83 -0
  399. package/src/infrastructure/logging/logger.ts +231 -0
  400. package/src/infrastructure/monitoring/LoggingService.ts +292 -0
  401. package/src/infrastructure/monitoring/MetricsService.ts +468 -0
  402. package/src/infrastructure/monitoring/SentryService.ts +345 -0
  403. package/src/infrastructure/monitoring/index.ts +12 -0
  404. package/src/infrastructure/queue/TaskQueue.ts +429 -0
  405. package/src/infrastructure/queue/index.ts +5 -0
  406. package/src/infrastructure/redis/connection.ts +215 -0
  407. package/src/infrastructure/redis/index.ts +5 -0
  408. package/src/infrastructure/security/ApiKeyService.ts +340 -0
  409. package/src/infrastructure/security/QuotaService.ts +411 -0
  410. package/src/infrastructure/security/RateLimiter.ts +417 -0
  411. package/src/infrastructure/security/index.ts +12 -0
  412. package/src/monitoring/index.ts +5 -0
  413. package/src/monitoring/server.ts +109 -0
  414. package/src/presentation/cli/commands/cancel.ts +64 -0
  415. package/src/presentation/cli/commands/create.ts +400 -0
  416. package/src/presentation/cli/commands/result.ts +136 -0
  417. package/src/presentation/cli/commands/status.ts +102 -0
  418. package/src/presentation/cli/index.ts +39 -0
  419. package/src/presentation/cli/utils/cleanup.ts +65 -0
  420. package/src/presentation/cli/utils/formatter.ts +74 -0
  421. package/src/presentation/cli.ts +8 -0
  422. package/src/presentation/monitor-cli.ts +52 -0
  423. package/src/presentation/worker-cli.ts +62 -0
  424. package/src/schedulers/TaskScheduler.ts +314 -0
  425. package/src/schedulers/index.ts +11 -0
  426. package/src/services/image/ImageService.ts +221 -0
  427. package/src/services/index.ts +15 -0
  428. package/src/services/llm/EnhancedLLMService.ts +596 -0
  429. package/src/services/llm/LLMService.ts +310 -0
  430. package/src/services/quality/HardRuleChecker.ts +509 -0
  431. package/src/services/quality/LLMEvaluator.ts +400 -0
  432. package/src/services/quality/QualityCheckService.ts +473 -0
  433. package/src/services/quality/QualityService.ts +445 -0
  434. package/src/services/quality/index.ts +12 -0
  435. package/src/services/search/SearchService.ts +266 -0
  436. package/src/types/global.d.ts +17 -0
  437. package/src/workers/TaskWorker.ts +320 -0
  438. package/src/workers/index.ts +5 -0
@@ -0,0 +1,363 @@
1
+ /**
2
+ * TaskQueue - BullMQ 任务队列
3
+ *
4
+ * 负责任务的添加、调度和管理
5
+ * 仅在 Redis 可用时启用
6
+ */
7
+ import { Queue } from 'bullmq';
8
+ import { createLogger } from '../logging/logger.js';
9
+ import { config } from '../../config/index.js';
10
+ const logger = createLogger('TaskQueue');
11
+ /**
12
+ * TaskQueue 类
13
+ *
14
+ * 封装 BullMQ Queue,提供任务队列管理功能
15
+ * 仅在 Redis 可用时启用
16
+ */
17
+ export class TaskQueue {
18
+ queue = null;
19
+ initialized = false;
20
+ enabled;
21
+ constructor(name = 'content-creator-tasks', options) {
22
+ // 检查 Redis 是否可用
23
+ this.enabled = config.redis.enabled;
24
+ if (!this.enabled) {
25
+ logger.info('TaskQueue is disabled (Redis not configured)');
26
+ return;
27
+ }
28
+ try {
29
+ // 从配置中解析 Redis URL
30
+ if (!config.redis.url) {
31
+ throw new Error('REDIS_URL is not configured');
32
+ }
33
+ const redisUrl = new URL(config.redis.url);
34
+ const redisConnection = {
35
+ host: redisUrl.hostname,
36
+ port: parseInt(redisUrl.port) || 6379,
37
+ db: config.redis.db,
38
+ };
39
+ // 添加密码(如果存在)
40
+ if (config.redis.password) {
41
+ redisConnection.password = config.redis.password;
42
+ }
43
+ else if (redisUrl.password) {
44
+ redisConnection.password = decodeURIComponent(redisUrl.password);
45
+ }
46
+ logger.info('Creating TaskQueue with Redis config', {
47
+ host: redisConnection.host,
48
+ port: redisConnection.port,
49
+ db: redisConnection.db,
50
+ hasPassword: !!redisConnection.password,
51
+ });
52
+ // 创建 Queue,使用配置的 Redis 连接
53
+ this.queue = new Queue(name, {
54
+ defaultJobOptions: {
55
+ attempts: 3, // 默认重试 3 次
56
+ backoff: {
57
+ type: 'exponential',
58
+ delay: 2000, // 指数退避,初始 2 秒
59
+ },
60
+ removeOnComplete: {
61
+ count: 1000, // 保留最近 1000 个完成的任务
62
+ age: 24 * 3600, // 或保留 24 小时
63
+ },
64
+ removeOnFail: {
65
+ count: 5000, // 保留最近 5000 个失败的任务
66
+ age: 7 * 24 * 3600, // 或保留 7 天
67
+ },
68
+ },
69
+ connection: redisConnection,
70
+ ...options,
71
+ });
72
+ }
73
+ catch (error) {
74
+ logger.warn('Failed to create TaskQueue, disabling queue', { error: error instanceof Error ? error.message : String(error) });
75
+ this.enabled = false;
76
+ this.queue = null;
77
+ }
78
+ }
79
+ /**
80
+ * 检查队列是否可用
81
+ */
82
+ isAvailable() {
83
+ return this.enabled && this.queue !== null;
84
+ }
85
+ /**
86
+ * 初始化队列
87
+ */
88
+ async initialize() {
89
+ if (!this.isAvailable()) {
90
+ logger.info('TaskQueue is not available (Redis disabled or initialization failed)');
91
+ return;
92
+ }
93
+ if (this.initialized) {
94
+ return;
95
+ }
96
+ if (!this.queue) {
97
+ logger.warn('TaskQueue instance is null');
98
+ return;
99
+ }
100
+ try {
101
+ // BullMQ 会在第一次使用时自动连接 Redis
102
+ // 这里我们只需要标记为已初始化
103
+ await this.queue.waitUntilReady();
104
+ this.initialized = true;
105
+ logger.info('TaskQueue initialized');
106
+ }
107
+ catch (error) {
108
+ logger.error('Failed to initialize TaskQueue', error);
109
+ throw error;
110
+ }
111
+ }
112
+ /**
113
+ * 添加任务到队列
114
+ */
115
+ async addTask(data, options) {
116
+ if (!this.isAvailable()) {
117
+ throw new Error('TaskQueue is not available. Redis is not configured or connection failed. Please use sync mode instead.');
118
+ }
119
+ await this.ensureInitialized();
120
+ if (!this.queue) {
121
+ throw new Error('Queue is not initialized');
122
+ }
123
+ try {
124
+ await this.queue.add('process-content', data, {
125
+ priority: this.calculatePriority(data),
126
+ ...options,
127
+ });
128
+ logger.info('Task added to queue', {
129
+ taskId: data.taskId,
130
+ mode: data.mode,
131
+ topic: data.topic,
132
+ });
133
+ }
134
+ catch (error) {
135
+ logger.error('Failed to add task to queue', error, {
136
+ taskId: data.taskId,
137
+ });
138
+ throw error;
139
+ }
140
+ }
141
+ /**
142
+ * 添加延迟任务
143
+ */
144
+ async addDelayedTask(data, delayMs) {
145
+ await this.ensureInitialized();
146
+ try {
147
+ if (!this.queue) {
148
+ throw new Error('Queue is not initialized');
149
+ }
150
+ await this.queue.add('process-content', data, {
151
+ delay: delayMs,
152
+ priority: this.calculatePriority(data),
153
+ });
154
+ logger.info('Delayed task added to queue', {
155
+ taskId: data.taskId,
156
+ delay: delayMs,
157
+ });
158
+ }
159
+ catch (error) {
160
+ logger.error('Failed to add delayed task to queue', error, {
161
+ taskId: data.taskId,
162
+ });
163
+ throw error;
164
+ }
165
+ }
166
+ /**
167
+ * 批量添加任务
168
+ */
169
+ async addBatchTasks(dataList, options) {
170
+ await this.ensureInitialized();
171
+ try {
172
+ const jobs = dataList.map((data) => ({
173
+ name: 'process-content',
174
+ data,
175
+ opts: {
176
+ priority: this.calculatePriority(data),
177
+ ...options,
178
+ },
179
+ }));
180
+ if (!this.queue) {
181
+ throw new Error('Queue is not initialized');
182
+ }
183
+ await this.queue.addBulk(jobs);
184
+ logger.info('Batch tasks added to queue', {
185
+ count: dataList.length,
186
+ });
187
+ }
188
+ catch (error) {
189
+ logger.error('Failed to add batch tasks to queue', error);
190
+ throw error;
191
+ }
192
+ }
193
+ /**
194
+ * 计算任务优先级(1-10,数字越小优先级越高)
195
+ */
196
+ calculatePriority(data) {
197
+ // 同步任务优先级最高
198
+ if (data.mode === 'sync') {
199
+ return 1;
200
+ }
201
+ // 根据任务类型或其他因素计算优先级
202
+ // 这里可以根据业务需求自定义
203
+ return 5; // 默认优先级
204
+ }
205
+ /**
206
+ * 暂停队列
207
+ */
208
+ async pause() {
209
+ if (!this.queue || !this.isAvailable()) {
210
+ logger.warn('Cannot pause queue (not available)');
211
+ return;
212
+ }
213
+ await this.queue.pause();
214
+ logger.info('TaskQueue paused');
215
+ }
216
+ /**
217
+ * 恢复队列
218
+ */
219
+ async resume() {
220
+ if (!this.queue || !this.isAvailable()) {
221
+ logger.warn('Cannot resume queue (not available)');
222
+ return;
223
+ }
224
+ await this.queue.resume();
225
+ logger.info('TaskQueue resumed');
226
+ }
227
+ /**
228
+ * 清空队列(等待中的任务)
229
+ */
230
+ async drain() {
231
+ if (!this.queue || !this.isAvailable()) {
232
+ logger.warn('Cannot drain queue (not available)');
233
+ return;
234
+ }
235
+ await this.queue.drain();
236
+ logger.info('TaskQueue drained');
237
+ }
238
+ /**
239
+ * 获取队列统计信息
240
+ */
241
+ async getStats() {
242
+ if (!this.queue || !this.isAvailable()) {
243
+ logger.warn('Cannot get stats (queue not available)');
244
+ return {
245
+ waiting: 0,
246
+ active: 0,
247
+ completed: 0,
248
+ failed: 0,
249
+ delayed: 0,
250
+ repeat: 0,
251
+ };
252
+ }
253
+ return {
254
+ waiting: await this.queue.getWaitingCount(),
255
+ active: await this.queue.getActiveCount(),
256
+ completed: await this.queue.getCompletedCount(),
257
+ failed: await this.queue.getFailedCount(),
258
+ delayed: await this.queue.getDelayedCount(),
259
+ // getRepeatCount 可能在某些版本的 BullMQ 中不可用
260
+ repeat: 0, // BullMQ 5.x 中重复任务已被重构
261
+ };
262
+ }
263
+ /**
264
+ * 获取队列实例(用于 Bull Board)
265
+ */
266
+ getQueue() {
267
+ return this.queue;
268
+ }
269
+ /**
270
+ * 确保队列已初始化
271
+ */
272
+ async ensureInitialized() {
273
+ if (!this.initialized) {
274
+ await this.initialize();
275
+ }
276
+ }
277
+ /**
278
+ * 关闭队列
279
+ */
280
+ async close() {
281
+ if (!this.queue) {
282
+ logger.warn('Cannot close queue (not initialized)');
283
+ return;
284
+ }
285
+ await this.queue.close();
286
+ this.initialized = false;
287
+ logger.info('TaskQueue closed');
288
+ }
289
+ /**
290
+ * 获取任务状态
291
+ */
292
+ async getJobState(jobId) {
293
+ if (!this.queue || !this.isAvailable()) {
294
+ logger.warn('Cannot get job state (queue not available)', { jobId });
295
+ return null;
296
+ }
297
+ try {
298
+ const job = await this.queue.getJob(jobId);
299
+ if (!job) {
300
+ return null;
301
+ }
302
+ const state = await job.getState();
303
+ return state;
304
+ }
305
+ catch (error) {
306
+ logger.error('Failed to get job state', error, { jobId });
307
+ return null;
308
+ }
309
+ }
310
+ /**
311
+ * 删除任务
312
+ */
313
+ async removeJob(jobId) {
314
+ if (!this.queue || !this.isAvailable()) {
315
+ logger.warn('Cannot remove job (queue not available)', { jobId });
316
+ return false;
317
+ }
318
+ try {
319
+ const job = await this.queue.getJob(jobId);
320
+ if (!job) {
321
+ return false;
322
+ }
323
+ await job.remove();
324
+ logger.info('Job removed', { jobId });
325
+ return true;
326
+ }
327
+ catch (error) {
328
+ logger.error('Failed to remove job', error, { jobId });
329
+ return false;
330
+ }
331
+ }
332
+ /**
333
+ * 重试失败的任务
334
+ */
335
+ async retryJob(jobId) {
336
+ if (!this.queue || !this.isAvailable()) {
337
+ logger.warn('Cannot retry job (queue not available)', { jobId });
338
+ return false;
339
+ }
340
+ try {
341
+ const job = await this.queue.getJob(jobId);
342
+ if (!job) {
343
+ return false;
344
+ }
345
+ await job.retry();
346
+ logger.info('Job retried', { jobId });
347
+ return true;
348
+ }
349
+ catch (error) {
350
+ logger.error('Failed to retry job', error, { jobId });
351
+ return false;
352
+ }
353
+ }
354
+ }
355
+ /**
356
+ * 创建默认任务队列实例
357
+ */
358
+ export async function createTaskQueue() {
359
+ const queue = new TaskQueue();
360
+ await queue.initialize();
361
+ return queue;
362
+ }
363
+ //# sourceMappingURL=TaskQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskQueue.js","sourceRoot":"","sources":["../../../src/infrastructure/queue/TaskQueue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MA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AAC;YACf,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC/D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;IAC9B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;IACzB,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 队列导出
3
+ */
4
+ export { TaskQueue, createTaskQueue, type TaskJobData } from './TaskQueue.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/queue/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 队列导出
3
+ */
4
+ export { TaskQueue, createTaskQueue } from './TaskQueue.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/queue/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAoB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Redis 连接池
3
+ *
4
+ * 提供 Redis 连接管理和错误处理
5
+ */
6
+ /**
7
+ * Redis 客户端类
8
+ */
9
+ export declare class RedisClient {
10
+ private client;
11
+ private isConnecting;
12
+ private reconnectAttempts;
13
+ private maxReconnectAttempts;
14
+ private enabled;
15
+ constructor();
16
+ /**
17
+ * 检查 Redis 是否启用
18
+ */
19
+ isEnabled(): boolean;
20
+ /**
21
+ * 获取 Redis 客户端实例(单例)
22
+ */
23
+ getClient(): Promise<any>;
24
+ /**
25
+ * 连接到 Redis
26
+ */
27
+ private connect;
28
+ /**
29
+ * 等待连接完成
30
+ */
31
+ private waitForConnection;
32
+ /**
33
+ * 断开 Redis 连接
34
+ */
35
+ disconnect(): Promise<void>;
36
+ /**
37
+ * 检查连接状态
38
+ */
39
+ isConnected(): boolean;
40
+ /**
41
+ * Ping Redis
42
+ */
43
+ ping(): Promise<string>;
44
+ /**
45
+ * 获取 Redis 信息
46
+ */
47
+ info(section?: string): Promise<string>;
48
+ }
49
+ /**
50
+ * Redis 客户端单例
51
+ */
52
+ export declare const redisClient: RedisClient;
53
+ /**
54
+ * 获取 Redis 客户端便捷方法
55
+ */
56
+ export declare function getRedisClient(): Promise<any>;
57
+ /**
58
+ * 检查 Redis 是否可用
59
+ */
60
+ export declare function isRedisEnabled(): boolean;
61
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/redis/connection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAM;IAClC,OAAO,CAAC,OAAO,CAAU;;IASzB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC;IAkB/B;;OAEG;YACW,OAAO;IAoFrB;;OAEG;YACW,iBAAiB;IAc/B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAI9C;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,aAAoB,CAAC;AAE7C;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,CAEnD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Redis 连接池
3
+ *
4
+ * 提供 Redis 连接管理和错误处理
5
+ */
6
+ import Redis from 'ioredis';
7
+ import { config } from '../../config/index.js';
8
+ import { createLogger } from '../logging/logger.js';
9
+ const logger = createLogger('Redis');
10
+ /**
11
+ * Redis 客户端类
12
+ */
13
+ export class RedisClient {
14
+ client = null;
15
+ isConnecting = false;
16
+ reconnectAttempts = 0;
17
+ maxReconnectAttempts = 10;
18
+ enabled;
19
+ constructor() {
20
+ this.enabled = config.redis.enabled;
21
+ if (!this.enabled) {
22
+ logger.info('Redis is disabled in configuration');
23
+ }
24
+ }
25
+ /**
26
+ * 检查 Redis 是否启用
27
+ */
28
+ isEnabled() {
29
+ return this.enabled;
30
+ }
31
+ /**
32
+ * 获取 Redis 客户端实例(单例)
33
+ */
34
+ async getClient() {
35
+ if (!this.enabled) {
36
+ throw new Error('Redis is not configured');
37
+ }
38
+ if (this.client) {
39
+ return this.client;
40
+ }
41
+ if (this.isConnecting) {
42
+ // 等待连接完成
43
+ await this.waitForConnection();
44
+ return this.client;
45
+ }
46
+ return this.connect();
47
+ }
48
+ /**
49
+ * 连接到 Redis
50
+ */
51
+ async connect() {
52
+ this.isConnecting = true;
53
+ try {
54
+ // 检查 Redis URL 是否配置
55
+ if (!config.redis.url) {
56
+ throw new Error('REDIS_URL is not configured');
57
+ }
58
+ // 解析 Redis URL
59
+ const redisUrl = new URL(config.redis.url);
60
+ logger.info('Connecting to Redis', {
61
+ host: redisUrl.hostname,
62
+ port: redisUrl.port,
63
+ password: redisUrl.password ? '****' : 'none',
64
+ });
65
+ // 创建 Redis 客户端配置
66
+ const redisOptions = {
67
+ host: redisUrl.hostname,
68
+ port: parseInt(redisUrl.port) || 6379,
69
+ db: config.redis.db,
70
+ maxRetriesPerRequest: config.redis.maxRetriesPerRequest,
71
+ retryStrategy: (times) => {
72
+ const delay = Math.min(times * 50, 2000);
73
+ logger.debug(`Redis retry attempt ${times}, delay: ${delay}ms`);
74
+ return delay;
75
+ },
76
+ connectTimeout: config.redis.connectTimeout,
77
+ commandTimeout: config.redis.commandTimeout,
78
+ };
79
+ // 优先使用配置中的密码,否则使用 URL 中的密码
80
+ if (config.redis.password) {
81
+ redisOptions.password = config.redis.password;
82
+ }
83
+ else if (redisUrl.password) {
84
+ redisOptions.password = decodeURIComponent(redisUrl.password);
85
+ }
86
+ // 创建 Redis 客户端
87
+ this.client = new Redis(redisOptions);
88
+ // 监听连接事件
89
+ this.client.on('connect', () => {
90
+ logger.info('Redis connected');
91
+ this.reconnectAttempts = 0;
92
+ this.isConnecting = false;
93
+ });
94
+ this.client.on('ready', () => {
95
+ logger.info('Redis ready');
96
+ });
97
+ this.client.on('error', (error) => {
98
+ logger.error('Redis error', error);
99
+ });
100
+ this.client.on('close', () => {
101
+ logger.warn('Redis connection closed');
102
+ });
103
+ this.client.on('reconnecting', () => {
104
+ this.reconnectAttempts++;
105
+ logger.info(`Redis reconnecting (attempt ${this.reconnectAttempts})`);
106
+ if (this.reconnectAttempts > this.maxReconnectAttempts) {
107
+ logger.error('Max reconnection attempts reached');
108
+ this.disconnect();
109
+ }
110
+ });
111
+ // 等待连接就绪
112
+ await this.client.ready;
113
+ logger.info('Redis connection established');
114
+ return this.client;
115
+ }
116
+ catch (error) {
117
+ this.isConnecting = false;
118
+ logger.error('Failed to connect to Redis', error);
119
+ throw error;
120
+ }
121
+ }
122
+ /**
123
+ * 等待连接完成
124
+ */
125
+ async waitForConnection() {
126
+ let attempts = 0;
127
+ const maxAttempts = 100;
128
+ while (this.isConnecting && attempts < maxAttempts) {
129
+ await new Promise((resolve) => setTimeout(resolve, 100));
130
+ attempts++;
131
+ }
132
+ if (!this.client) {
133
+ throw new Error('Redis connection failed');
134
+ }
135
+ }
136
+ /**
137
+ * 断开 Redis 连接
138
+ */
139
+ async disconnect() {
140
+ if (this.client) {
141
+ logger.info('Disconnecting Redis');
142
+ await this.client.quit();
143
+ this.client = null;
144
+ this.isConnecting = false;
145
+ }
146
+ }
147
+ /**
148
+ * 检查连接状态
149
+ */
150
+ isConnected() {
151
+ return this.client !== null && this.client.status === 'ready';
152
+ }
153
+ /**
154
+ * Ping Redis
155
+ */
156
+ async ping() {
157
+ const client = await this.getClient();
158
+ return await client.ping();
159
+ }
160
+ /**
161
+ * 获取 Redis 信息
162
+ */
163
+ async info(section) {
164
+ const client = await this.getClient();
165
+ return await client.info(section);
166
+ }
167
+ }
168
+ /**
169
+ * Redis 客户端单例
170
+ */
171
+ export const redisClient = new RedisClient();
172
+ /**
173
+ * 获取 Redis 客户端便捷方法
174
+ */
175
+ export async function getRedisClient() {
176
+ return await redisClient.getClient();
177
+ }
178
+ /**
179
+ * 检查 Redis 是否可用
180
+ */
181
+ export function isRedisEnabled() {
182
+ return redisClient.isEnabled();
183
+ }
184
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/infrastructure/redis/connection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,GAAe,IAAI,CAAC;IAC1B,YAAY,GAAG,KAAK,CAAC;IACrB,iBAAiB,GAAG,CAAC,CAAC;IACtB,oBAAoB,GAAG,EAAE,CAAC;IAC1B,OAAO,CAAU;IAEzB;QACE,IAAI,CAAC,OAA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AM,CAAC,KAAK,UAAU,cAAc;IAClC,OAAO,MAAM,WAAW,CAAC,SAAS,EAAE,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Redis 连接导出
3
+ */
4
+ export { redisClient, getRedisClient, RedisClient } from './connection.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/redis/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Redis 连接导出
3
+ */
4
+ export { redisClient, getRedisClient, RedisClient } from './connection.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/redis/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}