nestlens 0.5.2 → 0.6.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 (258) hide show
  1. package/dist/api/dashboard.controller.d.ts +7 -0
  2. package/dist/api/dashboard.controller.d.ts.map +1 -1
  3. package/dist/api/dashboard.controller.js +21 -1
  4. package/dist/api/dashboard.controller.js.map +1 -1
  5. package/dist/api/route-path.d.ts +14 -0
  6. package/dist/api/route-path.d.ts.map +1 -0
  7. package/dist/api/route-path.js +29 -0
  8. package/dist/api/route-path.js.map +1 -0
  9. package/dist/dashboard/public/assets/{BatchesPage-BGhLy-T5.js → BatchesPage-49gOGnzu.js} +1 -1
  10. package/dist/dashboard/public/assets/{CachePage-CDnNbIzo.js → CachePage-ov2Ag-N9.js} +1 -1
  11. package/dist/dashboard/public/assets/{ClickableBadge-BzF92jvt.js → ClickableBadge-DYNLPtLq.js} +1 -1
  12. package/dist/dashboard/public/assets/{CommandsPage-D8pYskAe.js → CommandsPage-mpPr6q9X.js} +1 -1
  13. package/dist/dashboard/public/assets/{DashboardPage-gFHu-Nwd.js → DashboardPage-DOdstR4a.js} +1 -1
  14. package/dist/dashboard/public/assets/{DumpsPage-Ccg_V5vS.js → DumpsPage-CQ_vpUE8.js} +1 -1
  15. package/dist/dashboard/public/assets/{EntryDetailPage-Dc_JZ1Tc.js → EntryDetailPage-CxL10HuU.js} +1 -1
  16. package/dist/dashboard/public/assets/{EntrySearchInput-DF0OUnR0.js → EntrySearchInput-DaH1CLjl.js} +1 -1
  17. package/dist/dashboard/public/assets/{EventsPage-D5vletvf.js → EventsPage-Di57VeHM.js} +1 -1
  18. package/dist/dashboard/public/assets/{ExceptionsPage-MyvF0i9X.js → ExceptionsPage-C9DcC4-2.js} +1 -1
  19. package/dist/dashboard/public/assets/{GatesPage-BN47FfAa.js → GatesPage-DBgWv2nS.js} +1 -1
  20. package/dist/dashboard/public/assets/{GraphQLPage-Ba6on48X.js → GraphQLPage-D8DcycD9.js} +1 -1
  21. package/dist/dashboard/public/assets/{HttpClientPage-BWPDXyqZ.js → HttpClientPage-PTrP2EjP.js} +1 -1
  22. package/dist/dashboard/public/assets/{JobsPage-BX4pZDnE.js → JobsPage-CraSw8O9.js} +1 -1
  23. package/dist/dashboard/public/assets/{LogsPage-98DCrWxA.js → LogsPage-7ZGkLuX9.js} +1 -1
  24. package/dist/dashboard/public/assets/{MailPage-CxE1cC46.js → MailPage-dQoSJAY3.js} +1 -1
  25. package/dist/dashboard/public/assets/{ModelsPage-YuBXpII-.js → ModelsPage-CKkb6PGt.js} +1 -1
  26. package/dist/dashboard/public/assets/{NotificationsPage-CEQRKmJB.js → NotificationsPage-CuTXZ1qY.js} +1 -1
  27. package/dist/dashboard/public/assets/{PageHeader-VKMQB2QM.js → PageHeader-q5aVtQHw.js} +1 -1
  28. package/dist/dashboard/public/assets/{QueriesPage-DiTK99vp.js → QueriesPage-CM4NansM.js} +1 -1
  29. package/dist/dashboard/public/assets/{RedisPage-D0eCbYXO.js → RedisPage-C9y6TuoK.js} +1 -1
  30. package/dist/dashboard/public/assets/{RequestsPage-B6Lvm-DQ.js → RequestsPage-Cxnqol-x.js} +1 -1
  31. package/dist/dashboard/public/assets/{SchedulePage-Cdnrs2AM.js → SchedulePage-Cp3ecH0l.js} +1 -1
  32. package/dist/dashboard/public/assets/{ViewsPage-CoL-Fxon.js → ViewsPage-BG8omC5C.js} +1 -1
  33. package/dist/dashboard/public/assets/{calendar-GxtPIdFE.js → calendar-CjIUfRxv.js} +1 -1
  34. package/dist/dashboard/public/assets/{circle-check-big-CUTcqDzy.js → circle-check-big-DDApLrDE.js} +1 -1
  35. package/dist/dashboard/public/assets/{eye-jph38F8w.js → eye-csDSrPe6.js} +1 -1
  36. package/dist/dashboard/public/assets/index-TmiQivGf.js +361 -0
  37. package/dist/dashboard/public/assets/{search-BKkZEk7u.js → search-DS3CEfeI.js} +1 -1
  38. package/dist/dashboard/public/assets/{types-Cz3zUxcx.js → types-DcORDHhK.js} +1 -1
  39. package/dist/dashboard/public/assets/{zap-Dy5QHE03.js → zap-DEs_rIzA.js} +1 -1
  40. package/dist/dashboard/public/index.html +4 -4
  41. package/dist/nestlens.module.d.ts +12 -0
  42. package/dist/nestlens.module.d.ts.map +1 -1
  43. package/dist/nestlens.module.js +26 -0
  44. package/dist/nestlens.module.js.map +1 -1
  45. package/package.json +3 -3
  46. package/dist/__tests__/api/api.controller.spec.d.ts +0 -2
  47. package/dist/__tests__/api/api.controller.spec.d.ts.map +0 -1
  48. package/dist/__tests__/api/api.controller.spec.js +0 -871
  49. package/dist/__tests__/api/api.controller.spec.js.map +0 -1
  50. package/dist/__tests__/api/api.guard.spec.d.ts +0 -2
  51. package/dist/__tests__/api/api.guard.spec.d.ts.map +0 -1
  52. package/dist/__tests__/api/api.guard.spec.js +0 -545
  53. package/dist/__tests__/api/api.guard.spec.js.map +0 -1
  54. package/dist/__tests__/api/dashboard.controller.spec.d.ts +0 -2
  55. package/dist/__tests__/api/dashboard.controller.spec.d.ts.map +0 -1
  56. package/dist/__tests__/api/dashboard.controller.spec.js +0 -159
  57. package/dist/__tests__/api/dashboard.controller.spec.js.map +0 -1
  58. package/dist/__tests__/api/nestlens-validation.pipe.spec.d.ts +0 -2
  59. package/dist/__tests__/api/nestlens-validation.pipe.spec.d.ts.map +0 -1
  60. package/dist/__tests__/api/nestlens-validation.pipe.spec.js +0 -73
  61. package/dist/__tests__/api/nestlens-validation.pipe.spec.js.map +0 -1
  62. package/dist/__tests__/api/tag.controller.spec.d.ts +0 -2
  63. package/dist/__tests__/api/tag.controller.spec.d.ts.map +0 -1
  64. package/dist/__tests__/api/tag.controller.spec.js +0 -280
  65. package/dist/__tests__/api/tag.controller.spec.js.map +0 -1
  66. package/dist/__tests__/collector.service.spec.d.ts +0 -2
  67. package/dist/__tests__/collector.service.spec.d.ts.map +0 -1
  68. package/dist/__tests__/collector.service.spec.js +0 -240
  69. package/dist/__tests__/collector.service.spec.js.map +0 -1
  70. package/dist/__tests__/core/collector.service.spec.d.ts +0 -2
  71. package/dist/__tests__/core/collector.service.spec.d.ts.map +0 -1
  72. package/dist/__tests__/core/collector.service.spec.js +0 -517
  73. package/dist/__tests__/core/collector.service.spec.js.map +0 -1
  74. package/dist/__tests__/core/family-hash.service.spec.d.ts +0 -2
  75. package/dist/__tests__/core/family-hash.service.spec.d.ts.map +0 -1
  76. package/dist/__tests__/core/family-hash.service.spec.js +0 -1117
  77. package/dist/__tests__/core/family-hash.service.spec.js.map +0 -1
  78. package/dist/__tests__/core/pruning.service.spec.d.ts +0 -2
  79. package/dist/__tests__/core/pruning.service.spec.d.ts.map +0 -1
  80. package/dist/__tests__/core/pruning.service.spec.js +0 -224
  81. package/dist/__tests__/core/pruning.service.spec.js.map +0 -1
  82. package/dist/__tests__/core/storage/memory.storage.spec.d.ts +0 -2
  83. package/dist/__tests__/core/storage/memory.storage.spec.d.ts.map +0 -1
  84. package/dist/__tests__/core/storage/memory.storage.spec.js +0 -450
  85. package/dist/__tests__/core/storage/memory.storage.spec.js.map +0 -1
  86. package/dist/__tests__/core/storage/redis.storage.spec.d.ts +0 -10
  87. package/dist/__tests__/core/storage/redis.storage.spec.d.ts.map +0 -1
  88. package/dist/__tests__/core/storage/redis.storage.spec.js +0 -657
  89. package/dist/__tests__/core/storage/redis.storage.spec.js.map +0 -1
  90. package/dist/__tests__/core/storage/sqlite.storage.spec.d.ts +0 -2
  91. package/dist/__tests__/core/storage/sqlite.storage.spec.d.ts.map +0 -1
  92. package/dist/__tests__/core/storage/sqlite.storage.spec.js +0 -1294
  93. package/dist/__tests__/core/storage/sqlite.storage.spec.js.map +0 -1
  94. package/dist/__tests__/core/storage/storage.factory.spec.d.ts +0 -2
  95. package/dist/__tests__/core/storage/storage.factory.spec.d.ts.map +0 -1
  96. package/dist/__tests__/core/storage/storage.factory.spec.js +0 -151
  97. package/dist/__tests__/core/storage/storage.factory.spec.js.map +0 -1
  98. package/dist/__tests__/core/tag.service.spec.d.ts +0 -2
  99. package/dist/__tests__/core/tag.service.spec.d.ts.map +0 -1
  100. package/dist/__tests__/core/tag.service.spec.js +0 -1126
  101. package/dist/__tests__/core/tag.service.spec.js.map +0 -1
  102. package/dist/__tests__/docs-consistency.spec.d.ts +0 -2
  103. package/dist/__tests__/docs-consistency.spec.d.ts.map +0 -1
  104. package/dist/__tests__/docs-consistency.spec.js +0 -74
  105. package/dist/__tests__/docs-consistency.spec.js.map +0 -1
  106. package/dist/__tests__/family-hash.service.spec.d.ts +0 -2
  107. package/dist/__tests__/family-hash.service.spec.d.ts.map +0 -1
  108. package/dist/__tests__/family-hash.service.spec.js +0 -325
  109. package/dist/__tests__/family-hash.service.spec.js.map +0 -1
  110. package/dist/__tests__/filters/api-filters.spec.d.ts +0 -2
  111. package/dist/__tests__/filters/api-filters.spec.d.ts.map +0 -1
  112. package/dist/__tests__/filters/api-filters.spec.js +0 -188
  113. package/dist/__tests__/filters/api-filters.spec.js.map +0 -1
  114. package/dist/__tests__/filters/badge-filter-e2e.spec.d.ts +0 -2
  115. package/dist/__tests__/filters/badge-filter-e2e.spec.d.ts.map +0 -1
  116. package/dist/__tests__/filters/badge-filter-e2e.spec.js +0 -418
  117. package/dist/__tests__/filters/badge-filter-e2e.spec.js.map +0 -1
  118. package/dist/__tests__/filters/entry-factories.d.ts +0 -20
  119. package/dist/__tests__/filters/entry-factories.d.ts.map +0 -1
  120. package/dist/__tests__/filters/entry-factories.js +0 -288
  121. package/dist/__tests__/filters/entry-factories.js.map +0 -1
  122. package/dist/__tests__/filters/filter-contract.spec.d.ts +0 -2
  123. package/dist/__tests__/filters/filter-contract.spec.d.ts.map +0 -1
  124. package/dist/__tests__/filters/filter-contract.spec.js +0 -319
  125. package/dist/__tests__/filters/filter-contract.spec.js.map +0 -1
  126. package/dist/__tests__/filters/filter-test-data.d.ts +0 -26
  127. package/dist/__tests__/filters/filter-test-data.d.ts.map +0 -1
  128. package/dist/__tests__/filters/filter-test-data.js +0 -374
  129. package/dist/__tests__/filters/filter-test-data.js.map +0 -1
  130. package/dist/__tests__/filters/storage-filters.spec.d.ts +0 -2
  131. package/dist/__tests__/filters/storage-filters.spec.d.ts.map +0 -1
  132. package/dist/__tests__/filters/storage-filters.spec.js +0 -699
  133. package/dist/__tests__/filters/storage-filters.spec.js.map +0 -1
  134. package/dist/__tests__/filters/test-utils.d.ts +0 -23
  135. package/dist/__tests__/filters/test-utils.d.ts.map +0 -1
  136. package/dist/__tests__/filters/test-utils.js +0 -54
  137. package/dist/__tests__/filters/test-utils.js.map +0 -1
  138. package/dist/__tests__/integration/adapter-compat.integration.spec.d.ts +0 -2
  139. package/dist/__tests__/integration/adapter-compat.integration.spec.d.ts.map +0 -1
  140. package/dist/__tests__/integration/adapter-compat.integration.spec.js +0 -139
  141. package/dist/__tests__/integration/adapter-compat.integration.spec.js.map +0 -1
  142. package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.d.ts +0 -16
  143. package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.d.ts.map +0 -1
  144. package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.js +0 -131
  145. package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.js.map +0 -1
  146. package/dist/__tests__/integration/schedule-watcher.integration.spec.d.ts +0 -2
  147. package/dist/__tests__/integration/schedule-watcher.integration.spec.d.ts.map +0 -1
  148. package/dist/__tests__/integration/schedule-watcher.integration.spec.js +0 -87
  149. package/dist/__tests__/integration/schedule-watcher.integration.spec.js.map +0 -1
  150. package/dist/__tests__/integration/watcher-coexistence.integration.spec.d.ts +0 -2
  151. package/dist/__tests__/integration/watcher-coexistence.integration.spec.d.ts.map +0 -1
  152. package/dist/__tests__/integration/watcher-coexistence.integration.spec.js +0 -88
  153. package/dist/__tests__/integration/watcher-coexistence.integration.spec.js.map +0 -1
  154. package/dist/__tests__/nestlens.module.spec.d.ts +0 -2
  155. package/dist/__tests__/nestlens.module.spec.d.ts.map +0 -1
  156. package/dist/__tests__/nestlens.module.spec.js +0 -620
  157. package/dist/__tests__/nestlens.module.spec.js.map +0 -1
  158. package/dist/__tests__/package-contract.spec.d.ts +0 -2
  159. package/dist/__tests__/package-contract.spec.d.ts.map +0 -1
  160. package/dist/__tests__/package-contract.spec.js +0 -88
  161. package/dist/__tests__/package-contract.spec.js.map +0 -1
  162. package/dist/__tests__/pruning.service.spec.d.ts +0 -2
  163. package/dist/__tests__/pruning.service.spec.d.ts.map +0 -1
  164. package/dist/__tests__/pruning.service.spec.js +0 -142
  165. package/dist/__tests__/pruning.service.spec.js.map +0 -1
  166. package/dist/__tests__/setup.d.ts +0 -7
  167. package/dist/__tests__/setup.d.ts.map +0 -1
  168. package/dist/__tests__/setup.js +0 -24
  169. package/dist/__tests__/setup.js.map +0 -1
  170. package/dist/__tests__/tag.service.spec.d.ts +0 -2
  171. package/dist/__tests__/tag.service.spec.d.ts.map +0 -1
  172. package/dist/__tests__/tag.service.spec.js +0 -477
  173. package/dist/__tests__/tag.service.spec.js.map +0 -1
  174. package/dist/__tests__/watchers/batch.watcher.spec.d.ts +0 -2
  175. package/dist/__tests__/watchers/batch.watcher.spec.d.ts.map +0 -1
  176. package/dist/__tests__/watchers/batch.watcher.spec.js +0 -515
  177. package/dist/__tests__/watchers/batch.watcher.spec.js.map +0 -1
  178. package/dist/__tests__/watchers/cache.watcher.spec.d.ts +0 -2
  179. package/dist/__tests__/watchers/cache.watcher.spec.d.ts.map +0 -1
  180. package/dist/__tests__/watchers/cache.watcher.spec.js +0 -397
  181. package/dist/__tests__/watchers/cache.watcher.spec.js.map +0 -1
  182. package/dist/__tests__/watchers/command.watcher.spec.d.ts +0 -2
  183. package/dist/__tests__/watchers/command.watcher.spec.d.ts.map +0 -1
  184. package/dist/__tests__/watchers/command.watcher.spec.js +0 -604
  185. package/dist/__tests__/watchers/command.watcher.spec.js.map +0 -1
  186. package/dist/__tests__/watchers/dump.watcher.spec.d.ts +0 -2
  187. package/dist/__tests__/watchers/dump.watcher.spec.d.ts.map +0 -1
  188. package/dist/__tests__/watchers/dump.watcher.spec.js +0 -723
  189. package/dist/__tests__/watchers/dump.watcher.spec.js.map +0 -1
  190. package/dist/__tests__/watchers/event.watcher.spec.d.ts +0 -2
  191. package/dist/__tests__/watchers/event.watcher.spec.d.ts.map +0 -1
  192. package/dist/__tests__/watchers/event.watcher.spec.js +0 -316
  193. package/dist/__tests__/watchers/event.watcher.spec.js.map +0 -1
  194. package/dist/__tests__/watchers/exception.watcher.spec.d.ts +0 -2
  195. package/dist/__tests__/watchers/exception.watcher.spec.d.ts.map +0 -1
  196. package/dist/__tests__/watchers/exception.watcher.spec.js +0 -507
  197. package/dist/__tests__/watchers/exception.watcher.spec.js.map +0 -1
  198. package/dist/__tests__/watchers/gate.watcher.spec.d.ts +0 -2
  199. package/dist/__tests__/watchers/gate.watcher.spec.d.ts.map +0 -1
  200. package/dist/__tests__/watchers/gate.watcher.spec.js +0 -683
  201. package/dist/__tests__/watchers/gate.watcher.spec.js.map +0 -1
  202. package/dist/__tests__/watchers/graphql/header-masking.spec.d.ts +0 -2
  203. package/dist/__tests__/watchers/graphql/header-masking.spec.d.ts.map +0 -1
  204. package/dist/__tests__/watchers/graphql/header-masking.spec.js +0 -95
  205. package/dist/__tests__/watchers/graphql/header-masking.spec.js.map +0 -1
  206. package/dist/__tests__/watchers/http-client.watcher.spec.d.ts +0 -2
  207. package/dist/__tests__/watchers/http-client.watcher.spec.d.ts.map +0 -1
  208. package/dist/__tests__/watchers/http-client.watcher.spec.js +0 -886
  209. package/dist/__tests__/watchers/http-client.watcher.spec.js.map +0 -1
  210. package/dist/__tests__/watchers/job.watcher.spec.d.ts +0 -2
  211. package/dist/__tests__/watchers/job.watcher.spec.d.ts.map +0 -1
  212. package/dist/__tests__/watchers/job.watcher.spec.js +0 -843
  213. package/dist/__tests__/watchers/job.watcher.spec.js.map +0 -1
  214. package/dist/__tests__/watchers/log.watcher.spec.d.ts +0 -2
  215. package/dist/__tests__/watchers/log.watcher.spec.d.ts.map +0 -1
  216. package/dist/__tests__/watchers/log.watcher.spec.js +0 -428
  217. package/dist/__tests__/watchers/log.watcher.spec.js.map +0 -1
  218. package/dist/__tests__/watchers/mail.watcher.spec.d.ts +0 -2
  219. package/dist/__tests__/watchers/mail.watcher.spec.d.ts.map +0 -1
  220. package/dist/__tests__/watchers/mail.watcher.spec.js +0 -426
  221. package/dist/__tests__/watchers/mail.watcher.spec.js.map +0 -1
  222. package/dist/__tests__/watchers/model.watcher.spec.d.ts +0 -2
  223. package/dist/__tests__/watchers/model.watcher.spec.d.ts.map +0 -1
  224. package/dist/__tests__/watchers/model.watcher.spec.js +0 -712
  225. package/dist/__tests__/watchers/model.watcher.spec.js.map +0 -1
  226. package/dist/__tests__/watchers/notification.watcher.spec.d.ts +0 -2
  227. package/dist/__tests__/watchers/notification.watcher.spec.d.ts.map +0 -1
  228. package/dist/__tests__/watchers/notification.watcher.spec.js +0 -595
  229. package/dist/__tests__/watchers/notification.watcher.spec.js.map +0 -1
  230. package/dist/__tests__/watchers/query/typeorm-integration.spec.d.ts +0 -2
  231. package/dist/__tests__/watchers/query/typeorm-integration.spec.d.ts.map +0 -1
  232. package/dist/__tests__/watchers/query/typeorm-integration.spec.js +0 -100
  233. package/dist/__tests__/watchers/query/typeorm-integration.spec.js.map +0 -1
  234. package/dist/__tests__/watchers/query/types.spec.d.ts +0 -2
  235. package/dist/__tests__/watchers/query/types.spec.d.ts.map +0 -1
  236. package/dist/__tests__/watchers/query/types.spec.js +0 -77
  237. package/dist/__tests__/watchers/query/types.spec.js.map +0 -1
  238. package/dist/__tests__/watchers/query.watcher.spec.d.ts +0 -2
  239. package/dist/__tests__/watchers/query.watcher.spec.d.ts.map +0 -1
  240. package/dist/__tests__/watchers/query.watcher.spec.js +0 -252
  241. package/dist/__tests__/watchers/query.watcher.spec.js.map +0 -1
  242. package/dist/__tests__/watchers/redis.watcher.spec.d.ts +0 -2
  243. package/dist/__tests__/watchers/redis.watcher.spec.d.ts.map +0 -1
  244. package/dist/__tests__/watchers/redis.watcher.spec.js +0 -636
  245. package/dist/__tests__/watchers/redis.watcher.spec.js.map +0 -1
  246. package/dist/__tests__/watchers/request.watcher.spec.d.ts +0 -2
  247. package/dist/__tests__/watchers/request.watcher.spec.d.ts.map +0 -1
  248. package/dist/__tests__/watchers/request.watcher.spec.js +0 -1064
  249. package/dist/__tests__/watchers/request.watcher.spec.js.map +0 -1
  250. package/dist/__tests__/watchers/schedule.watcher.spec.d.ts +0 -2
  251. package/dist/__tests__/watchers/schedule.watcher.spec.d.ts.map +0 -1
  252. package/dist/__tests__/watchers/schedule.watcher.spec.js +0 -345
  253. package/dist/__tests__/watchers/schedule.watcher.spec.js.map +0 -1
  254. package/dist/__tests__/watchers/view.watcher.spec.d.ts +0 -2
  255. package/dist/__tests__/watchers/view.watcher.spec.d.ts.map +0 -1
  256. package/dist/__tests__/watchers/view.watcher.spec.js +0 -566
  257. package/dist/__tests__/watchers/view.watcher.spec.js.map +0 -1
  258. package/dist/dashboard/public/assets/index-BfQJSu7W.js +0 -361
@@ -1,1126 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const testing_1 = require("@nestjs/testing");
4
- const tag_service_1 = require("../../core/tag.service");
5
- const storage_interface_1 = require("../../core/storage/storage.interface");
6
- describe('TagService', () => {
7
- let service;
8
- let mockStorage;
9
- beforeEach(async () => {
10
- // Arrange
11
- mockStorage = {
12
- addTags: jest.fn(),
13
- removeTags: jest.fn(),
14
- getEntryTags: jest.fn(),
15
- getAllTags: jest.fn(),
16
- findByTags: jest.fn(),
17
- addMonitoredTag: jest.fn(),
18
- removeMonitoredTag: jest.fn(),
19
- getMonitoredTags: jest.fn(),
20
- };
21
- const module = await testing_1.Test.createTestingModule({
22
- providers: [tag_service_1.TagService, { provide: storage_interface_1.STORAGE, useValue: mockStorage }],
23
- }).compile();
24
- service = module.get(tag_service_1.TagService);
25
- });
26
- afterEach(() => {
27
- jest.clearAllMocks();
28
- });
29
- describe('autoTag', () => {
30
- describe('Request Tags', () => {
31
- it('should add ERROR and 5XX tags for 500+ status', async () => {
32
- // Arrange
33
- const entry = {
34
- id: 1,
35
- type: 'request',
36
- payload: { statusCode: 500, method: 'GET', path: '/test' },
37
- };
38
- // Act
39
- const tags = await service.autoTag(entry);
40
- // Assert
41
- expect(tags).toContain('ERROR');
42
- expect(tags).toContain('5XX');
43
- expect(mockStorage.addTags).toHaveBeenCalledWith(1, expect.arrayContaining(['ERROR', '5XX']));
44
- });
45
- it('should add CLIENT-ERROR and 4XX tags for 400+ status', async () => {
46
- // Arrange
47
- const entry = {
48
- id: 1,
49
- type: 'request',
50
- payload: { statusCode: 404, method: 'GET', path: '/test' },
51
- };
52
- // Act
53
- const tags = await service.autoTag(entry);
54
- // Assert
55
- expect(tags).toContain('CLIENT-ERROR');
56
- expect(tags).toContain('4XX');
57
- });
58
- it('should add REDIRECT and 3XX tags for 300+ status', async () => {
59
- // Arrange
60
- const entry = {
61
- id: 1,
62
- type: 'request',
63
- payload: { statusCode: 301, method: 'GET', path: '/test' },
64
- };
65
- // Act
66
- const tags = await service.autoTag(entry);
67
- // Assert
68
- expect(tags).toContain('REDIRECT');
69
- expect(tags).toContain('3XX');
70
- });
71
- it('should add SUCCESS tag for 200+ status', async () => {
72
- // Arrange
73
- const entry = {
74
- id: 1,
75
- type: 'request',
76
- payload: { statusCode: 200, method: 'GET', path: '/test' },
77
- };
78
- // Act
79
- const tags = await service.autoTag(entry);
80
- // Assert
81
- expect(tags).toContain('SUCCESS');
82
- });
83
- it('should add USER tag when user.id exists', async () => {
84
- // Arrange
85
- const entry = {
86
- id: 1,
87
- type: 'request',
88
- payload: { statusCode: 200, method: 'GET', path: '/test', user: { id: 'user-123' } },
89
- };
90
- // Act
91
- const tags = await service.autoTag(entry);
92
- // Assert
93
- expect(tags).toContain('USER:user-123');
94
- });
95
- it('should add HTTP method tag for non-GraphQL requests', async () => {
96
- // Arrange
97
- const entry = {
98
- id: 1,
99
- type: 'request',
100
- payload: { statusCode: 200, method: 'POST', path: '/api/users' },
101
- };
102
- // Act
103
- const tags = await service.autoTag(entry);
104
- // Assert
105
- expect(tags).toContain('POST');
106
- });
107
- it('should NOT add method tag for GraphQL requests', async () => {
108
- // Arrange
109
- const entry = {
110
- id: 1,
111
- type: 'request',
112
- payload: { statusCode: 200, method: 'POST', path: '/graphql' },
113
- };
114
- // Act
115
- const tags = await service.autoTag(entry);
116
- // Assert
117
- expect(tags).not.toContain('POST');
118
- });
119
- it('should add SLOW tag for requests > 1000ms', async () => {
120
- // Arrange
121
- const entry = {
122
- id: 1,
123
- type: 'request',
124
- payload: { statusCode: 200, method: 'GET', path: '/test', duration: 1500 },
125
- };
126
- // Act
127
- const tags = await service.autoTag(entry);
128
- // Assert
129
- expect(tags).toContain('SLOW');
130
- });
131
- it('should include custom tags from payload', async () => {
132
- // Arrange
133
- const entry = {
134
- id: 1,
135
- type: 'request',
136
- payload: { statusCode: 200, method: 'GET', path: '/test', tags: ['important', 'debug'] },
137
- };
138
- // Act
139
- const tags = await service.autoTag(entry);
140
- // Assert
141
- expect(tags).toContain('IMPORTANT');
142
- expect(tags).toContain('DEBUG');
143
- });
144
- });
145
- describe('Query Tags', () => {
146
- it('should add SLOW tag for slow queries', async () => {
147
- // Arrange
148
- const entry = {
149
- id: 1,
150
- type: 'query',
151
- payload: { query: 'SELECT * FROM users', slow: true, duration: 1000 },
152
- };
153
- // Act
154
- const tags = await service.autoTag(entry);
155
- // Assert
156
- expect(tags).toContain('SLOW');
157
- });
158
- it('should add source tag', async () => {
159
- // Arrange
160
- const entry = {
161
- id: 1,
162
- type: 'query',
163
- payload: { query: 'SELECT * FROM users', slow: false, duration: 10, source: 'TypeORM' },
164
- };
165
- // Act
166
- const tags = await service.autoTag(entry);
167
- // Assert
168
- expect(tags).toContain('TYPEORM');
169
- });
170
- it('should detect SELECT query', async () => {
171
- // Arrange
172
- const entry = {
173
- id: 1,
174
- type: 'query',
175
- payload: { query: 'SELECT * FROM users', slow: false, duration: 10 },
176
- };
177
- // Act
178
- const tags = await service.autoTag(entry);
179
- // Assert
180
- expect(tags).toContain('SELECT');
181
- });
182
- it('should detect INSERT query', async () => {
183
- // Arrange
184
- const entry = {
185
- id: 1,
186
- type: 'query',
187
- payload: { query: 'INSERT INTO users VALUES (1)', slow: false, duration: 10 },
188
- };
189
- // Act
190
- const tags = await service.autoTag(entry);
191
- // Assert
192
- expect(tags).toContain('INSERT');
193
- });
194
- it('should detect UPDATE query', async () => {
195
- // Arrange
196
- const entry = {
197
- id: 1,
198
- type: 'query',
199
- payload: { query: 'UPDATE users SET name = ?', slow: false, duration: 10 },
200
- };
201
- // Act
202
- const tags = await service.autoTag(entry);
203
- // Assert
204
- expect(tags).toContain('UPDATE');
205
- });
206
- it('should detect DELETE query', async () => {
207
- // Arrange
208
- const entry = {
209
- id: 1,
210
- type: 'query',
211
- payload: { query: 'DELETE FROM users WHERE id = 1', slow: false, duration: 10 },
212
- };
213
- // Act
214
- const tags = await service.autoTag(entry);
215
- // Assert
216
- expect(tags).toContain('DELETE');
217
- });
218
- });
219
- describe('Exception Tags', () => {
220
- it('should add ERROR tag', async () => {
221
- // Arrange
222
- const entry = {
223
- id: 1,
224
- type: 'exception',
225
- payload: { name: 'Error', message: 'Something went wrong' },
226
- };
227
- // Act
228
- const tags = await service.autoTag(entry);
229
- // Assert
230
- expect(tags).toContain('ERROR');
231
- });
232
- it('should add exception type tag when not generic Error', async () => {
233
- // Arrange
234
- const entry = {
235
- id: 1,
236
- type: 'exception',
237
- payload: { name: 'TypeError', message: 'Cannot read property' },
238
- };
239
- // Act
240
- const tags = await service.autoTag(entry);
241
- // Assert
242
- expect(tags).toContain('TYPEERROR');
243
- });
244
- it('should NOT add exception name tag for generic Error', async () => {
245
- // Arrange
246
- const entry = {
247
- id: 1,
248
- type: 'exception',
249
- payload: { name: 'Error', message: 'Generic error' },
250
- };
251
- // Act
252
- const tags = await service.autoTag(entry);
253
- // Assert
254
- // ERROR tag is added for all exceptions, but 'ERROR' as exception name should not be duplicated
255
- expect(tags).toContain('ERROR'); // This is the standard exception tag
256
- expect(tags.filter((t) => t === 'ERROR')).toHaveLength(1); // Should only appear once
257
- });
258
- it('should add HTTP-ERROR tag for HTTP exceptions', async () => {
259
- // Arrange
260
- const entry = {
261
- id: 1,
262
- type: 'exception',
263
- payload: { name: 'HttpException', message: 'Not found' },
264
- };
265
- // Act
266
- const tags = await service.autoTag(entry);
267
- // Assert
268
- expect(tags).toContain('HTTP-ERROR');
269
- });
270
- it('should add VALIDATION-ERROR tag for validation errors', async () => {
271
- // Arrange
272
- const entry = {
273
- id: 1,
274
- type: 'exception',
275
- payload: { name: 'ValidationError', message: 'Invalid input' },
276
- };
277
- // Act
278
- const tags = await service.autoTag(entry);
279
- // Assert
280
- expect(tags).toContain('VALIDATION-ERROR');
281
- });
282
- });
283
- describe('Log Tags', () => {
284
- it('should add level tag', async () => {
285
- // Arrange
286
- const entry = {
287
- id: 1,
288
- type: 'log',
289
- payload: { level: 'warn', message: 'Warning message' },
290
- };
291
- // Act
292
- const tags = await service.autoTag(entry);
293
- // Assert
294
- expect(tags).toContain('WARN');
295
- });
296
- it('should add ERROR tag for error level', async () => {
297
- // Arrange
298
- const entry = {
299
- id: 1,
300
- type: 'log',
301
- payload: { level: 'error', message: 'Error message' },
302
- };
303
- // Act
304
- const tags = await service.autoTag(entry);
305
- // Assert
306
- expect(tags).toContain('ERROR');
307
- });
308
- it('should add WARNING tag for warn level', async () => {
309
- // Arrange
310
- const entry = {
311
- id: 1,
312
- type: 'log',
313
- payload: { level: 'warn', message: 'Warning message' },
314
- };
315
- // Act
316
- const tags = await service.autoTag(entry);
317
- // Assert
318
- expect(tags).toContain('WARNING');
319
- });
320
- it('should add context tag', async () => {
321
- // Arrange
322
- const entry = {
323
- id: 1,
324
- type: 'log',
325
- payload: { level: 'log', message: 'Message', context: 'UserService' },
326
- };
327
- // Act
328
- const tags = await service.autoTag(entry);
329
- // Assert
330
- expect(tags).toContain('USERSERVICE');
331
- });
332
- });
333
- describe('Job Tags', () => {
334
- it('should add status tag', async () => {
335
- // Arrange
336
- const entry = {
337
- id: 1,
338
- type: 'job',
339
- payload: { name: 'SendEmail', status: 'completed' },
340
- };
341
- // Act
342
- const tags = await service.autoTag(entry);
343
- // Assert
344
- expect(tags).toContain('COMPLETED');
345
- });
346
- it('should add queue tag', async () => {
347
- // Arrange
348
- const entry = {
349
- id: 1,
350
- type: 'job',
351
- payload: { name: 'SendEmail', status: 'active', queue: 'email-queue' },
352
- };
353
- // Act
354
- const tags = await service.autoTag(entry);
355
- // Assert
356
- expect(tags).toContain('EMAIL-QUEUE');
357
- });
358
- it('should add ERROR tag for failed jobs', async () => {
359
- // Arrange
360
- const entry = {
361
- id: 1,
362
- type: 'job',
363
- payload: { name: 'SendEmail', status: 'failed' },
364
- };
365
- // Act
366
- const tags = await service.autoTag(entry);
367
- // Assert
368
- expect(tags).toContain('ERROR');
369
- expect(tags).toContain('FAILED');
370
- });
371
- });
372
- describe('Cache Tags', () => {
373
- it('should add operation tag', async () => {
374
- // Arrange
375
- const entry = {
376
- id: 1,
377
- type: 'cache',
378
- payload: { key: 'user:1', operation: 'set' },
379
- };
380
- // Act
381
- const tags = await service.autoTag(entry);
382
- // Assert
383
- expect(tags).toContain('SET');
384
- });
385
- it('should add HIT tag for cache hit', async () => {
386
- // Arrange
387
- const entry = {
388
- id: 1,
389
- type: 'cache',
390
- payload: { key: 'user:1', operation: 'get', hit: true },
391
- };
392
- // Act
393
- const tags = await service.autoTag(entry);
394
- // Assert
395
- expect(tags).toContain('HIT');
396
- });
397
- it('should add MISS tag for cache miss', async () => {
398
- // Arrange
399
- const entry = {
400
- id: 1,
401
- type: 'cache',
402
- payload: { key: 'user:1', operation: 'get', hit: false },
403
- };
404
- // Act
405
- const tags = await service.autoTag(entry);
406
- // Assert
407
- expect(tags).toContain('MISS');
408
- });
409
- });
410
- describe('Event Tags', () => {
411
- it('should add event name tag', async () => {
412
- // Arrange
413
- const entry = {
414
- id: 1,
415
- type: 'event',
416
- payload: { name: 'user.created', listeners: ['Handler1'] },
417
- };
418
- // Act
419
- const tags = await service.autoTag(entry);
420
- // Assert
421
- expect(tags).toContain('USER.CREATED');
422
- });
423
- it('should add MULTI-LISTENER tag for multiple listeners', async () => {
424
- // Arrange
425
- const entry = {
426
- id: 1,
427
- type: 'event',
428
- payload: { name: 'user.created', listeners: ['Handler1', 'Handler2'] },
429
- };
430
- // Act
431
- const tags = await service.autoTag(entry);
432
- // Assert
433
- expect(tags).toContain('MULTI-LISTENER');
434
- });
435
- it('should add SLOW tag for slow events', async () => {
436
- // Arrange
437
- const entry = {
438
- id: 1,
439
- type: 'event',
440
- payload: { name: 'user.created', payload: {}, listeners: [], duration: 150 },
441
- };
442
- // Act
443
- const tags = await service.autoTag(entry);
444
- // Assert
445
- expect(tags).toContain('SLOW');
446
- });
447
- });
448
- describe('Schedule Tags', () => {
449
- it('should add status tag', async () => {
450
- // Arrange
451
- const entry = {
452
- id: 1,
453
- type: 'schedule',
454
- payload: { name: 'CleanupTask', status: 'completed' },
455
- };
456
- // Act
457
- const tags = await service.autoTag(entry);
458
- // Assert
459
- expect(tags).toContain('COMPLETED');
460
- });
461
- it('should add CRON tag for cron schedules', async () => {
462
- // Arrange
463
- const entry = {
464
- id: 1,
465
- type: 'schedule',
466
- payload: { name: 'CleanupTask', status: 'completed', cron: '0 * * * *' },
467
- };
468
- // Act
469
- const tags = await service.autoTag(entry);
470
- // Assert
471
- expect(tags).toContain('CRON');
472
- });
473
- it('should add INTERVAL tag for interval schedules', async () => {
474
- // Arrange
475
- const entry = {
476
- id: 1,
477
- type: 'schedule',
478
- payload: { name: 'HealthCheck', status: 'started', interval: 60000 },
479
- };
480
- // Act
481
- const tags = await service.autoTag(entry);
482
- // Assert
483
- expect(tags).toContain('INTERVAL');
484
- });
485
- });
486
- describe('Mail Tags', () => {
487
- it('should add status tag', async () => {
488
- // Arrange
489
- const entry = {
490
- id: 1,
491
- type: 'mail',
492
- payload: { to: 'user@example.com', subject: 'Test', status: 'sent' },
493
- };
494
- // Act
495
- const tags = await service.autoTag(entry);
496
- // Assert
497
- expect(tags).toContain('SENT');
498
- });
499
- it('should add BULK tag for multiple recipients', async () => {
500
- // Arrange
501
- const entry = {
502
- id: 1,
503
- type: 'mail',
504
- payload: {
505
- to: ['user1@example.com', 'user2@example.com'],
506
- subject: 'Test',
507
- status: 'sent',
508
- },
509
- };
510
- // Act
511
- const tags = await service.autoTag(entry);
512
- // Assert
513
- expect(tags).toContain('BULK');
514
- });
515
- it('should add HTML tag for HTML emails', async () => {
516
- // Arrange
517
- const entry = {
518
- id: 1,
519
- type: 'mail',
520
- payload: {
521
- to: 'user@example.com',
522
- subject: 'Test',
523
- status: 'sent',
524
- html: '<p>Hello</p>',
525
- },
526
- };
527
- // Act
528
- const tags = await service.autoTag(entry);
529
- // Assert
530
- expect(tags).toContain('HTML');
531
- });
532
- });
533
- describe('HTTP Client Tags', () => {
534
- it('should add method tag', async () => {
535
- // Arrange
536
- const entry = {
537
- id: 1,
538
- type: 'http-client',
539
- payload: { method: 'POST', url: 'https://api.example.com/users', statusCode: 201 },
540
- };
541
- // Act
542
- const tags = await service.autoTag(entry);
543
- // Assert
544
- expect(tags).toContain('POST');
545
- });
546
- it('should add hostname tag', async () => {
547
- // Arrange
548
- const entry = {
549
- id: 1,
550
- type: 'http-client',
551
- payload: {
552
- method: 'GET',
553
- url: 'https://api.example.com',
554
- hostname: 'api.example.com',
555
- statusCode: 200,
556
- },
557
- };
558
- // Act
559
- const tags = await service.autoTag(entry);
560
- // Assert
561
- expect(tags).toContain('API.EXAMPLE.COM');
562
- });
563
- });
564
- describe('Redis Tags', () => {
565
- it('should add command tag', async () => {
566
- // Arrange
567
- const entry = {
568
- id: 1,
569
- type: 'redis',
570
- payload: { command: 'SET', args: ['user:1', 'value'], duration: 5, status: 'success' },
571
- };
572
- // Act
573
- const tags = await service.autoTag(entry);
574
- // Assert
575
- expect(tags).toContain('SET');
576
- });
577
- it('should add ERROR tag for errors', async () => {
578
- // Arrange
579
- const entry = {
580
- id: 1,
581
- type: 'redis',
582
- payload: { command: 'GET', args: ['user:1'], status: 'error', duration: 5 },
583
- };
584
- // Act
585
- const tags = await service.autoTag(entry);
586
- // Assert
587
- expect(tags).toContain('ERROR');
588
- });
589
- it('should add SLOW tag for slow commands', async () => {
590
- // Arrange
591
- const entry = {
592
- id: 1,
593
- type: 'redis',
594
- payload: { command: 'GET', args: ['user:1'], duration: 150, status: 'success' },
595
- };
596
- // Act
597
- const tags = await service.autoTag(entry);
598
- // Assert
599
- expect(tags).toContain('SLOW');
600
- });
601
- });
602
- describe('Model Tags', () => {
603
- it('should add entity tag', async () => {
604
- // Arrange
605
- const entry = {
606
- id: 1,
607
- type: 'model',
608
- payload: { entity: 'User', action: 'create', duration: 10 },
609
- };
610
- // Act
611
- const tags = await service.autoTag(entry);
612
- // Assert
613
- expect(tags).toContain('USER');
614
- });
615
- it('should add action tag', async () => {
616
- // Arrange
617
- const entry = {
618
- id: 1,
619
- type: 'model',
620
- payload: { entity: 'User', action: 'update', duration: 10 },
621
- };
622
- // Act
623
- const tags = await service.autoTag(entry);
624
- // Assert
625
- expect(tags).toContain('UPDATE');
626
- });
627
- it('should add BULK tag for multiple records', async () => {
628
- // Arrange
629
- const entry = {
630
- id: 1,
631
- type: 'model',
632
- payload: { entity: 'User', action: 'find', recordCount: 100, duration: 10 },
633
- };
634
- // Act
635
- const tags = await service.autoTag(entry);
636
- // Assert
637
- expect(tags).toContain('BULK');
638
- });
639
- });
640
- describe('Notification Tags', () => {
641
- it('should add type tag', async () => {
642
- // Arrange
643
- const entry = {
644
- id: 1,
645
- type: 'notification',
646
- payload: { type: 'email', status: 'sent', recipient: 'user@example.com' },
647
- };
648
- // Act
649
- const tags = await service.autoTag(entry);
650
- // Assert
651
- expect(tags).toContain('EMAIL');
652
- });
653
- it('should add BULK tag for multiple recipients', async () => {
654
- // Arrange
655
- const entry = {
656
- id: 1,
657
- type: 'notification',
658
- payload: { type: 'push', status: 'sent', recipient: ['user1', 'user2'] },
659
- };
660
- // Act
661
- const tags = await service.autoTag(entry);
662
- // Assert
663
- expect(tags).toContain('BULK');
664
- });
665
- });
666
- describe('View Tags', () => {
667
- it('should add template name tag', async () => {
668
- // Arrange
669
- const entry = {
670
- id: 1,
671
- type: 'view',
672
- payload: { template: 'users/profile.html', format: 'html', duration: 10 },
673
- };
674
- // Act
675
- const tags = await service.autoTag(entry);
676
- // Assert
677
- expect(tags).toContain('USERS.PROFILE');
678
- });
679
- it('should add format tag', async () => {
680
- // Arrange
681
- const entry = {
682
- id: 1,
683
- type: 'view',
684
- payload: { template: 'report', format: 'pdf', duration: 100 },
685
- };
686
- // Act
687
- const tags = await service.autoTag(entry);
688
- // Assert
689
- expect(tags).toContain('PDF');
690
- });
691
- it('should add CACHED tag for cache hits', async () => {
692
- // Arrange
693
- const entry = {
694
- id: 1,
695
- type: 'view',
696
- payload: { template: 'home', format: 'html', cacheHit: true, duration: 1 },
697
- };
698
- // Act
699
- const tags = await service.autoTag(entry);
700
- // Assert
701
- expect(tags).toContain('CACHED');
702
- });
703
- });
704
- describe('Command Tags', () => {
705
- it('should add command name tag', async () => {
706
- // Arrange
707
- const entry = {
708
- id: 1,
709
- type: 'command',
710
- payload: { name: 'CreateUser', status: 'completed' },
711
- };
712
- // Act
713
- const tags = await service.autoTag(entry);
714
- // Assert
715
- expect(tags).toContain('CREATEUSER');
716
- });
717
- it('should add SLOW tag for slow commands', async () => {
718
- // Arrange
719
- const entry = {
720
- id: 1,
721
- type: 'command',
722
- payload: { name: 'CreateUser', status: 'completed', duration: 1500 },
723
- };
724
- // Act
725
- const tags = await service.autoTag(entry);
726
- // Assert
727
- expect(tags).toContain('SLOW');
728
- });
729
- });
730
- describe('Gate Tags', () => {
731
- it('should add ALLOWED tag when allowed', async () => {
732
- // Arrange
733
- const entry = {
734
- id: 1,
735
- type: 'gate',
736
- payload: { gate: 'CanEdit', action: 'edit', allowed: true },
737
- };
738
- // Act
739
- const tags = await service.autoTag(entry);
740
- // Assert
741
- expect(tags).toContain('ALLOWED');
742
- });
743
- it('should add DENIED tag when denied', async () => {
744
- // Arrange
745
- const entry = {
746
- id: 1,
747
- type: 'gate',
748
- payload: { gate: 'CanDelete', action: 'delete', allowed: false },
749
- };
750
- // Act
751
- const tags = await service.autoTag(entry);
752
- // Assert
753
- expect(tags).toContain('DENIED');
754
- });
755
- it('should add gate name tag', async () => {
756
- // Arrange
757
- const entry = {
758
- id: 1,
759
- type: 'gate',
760
- payload: { gate: 'CanEdit', action: 'edit', allowed: true },
761
- };
762
- // Act
763
- const tags = await service.autoTag(entry);
764
- // Assert
765
- expect(tags).toContain('CANEDIT');
766
- });
767
- });
768
- describe('Batch Tags', () => {
769
- it('should add status tag', async () => {
770
- // Arrange
771
- const entry = {
772
- id: 1,
773
- type: 'batch',
774
- payload: { name: 'ImportUsers', status: 'completed', totalItems: 100, failedItems: 0 },
775
- };
776
- // Act
777
- const tags = await service.autoTag(entry);
778
- // Assert
779
- expect(tags).toContain('COMPLETED');
780
- });
781
- it('should add LARGE tag for batches > 1000 items', async () => {
782
- // Arrange
783
- const entry = {
784
- id: 1,
785
- type: 'batch',
786
- payload: { name: 'ImportUsers', status: 'completed', totalItems: 5000, failedItems: 0 },
787
- };
788
- // Act
789
- const tags = await service.autoTag(entry);
790
- // Assert
791
- expect(tags).toContain('LARGE');
792
- });
793
- it('should add ERROR tag when failedItems > 0', async () => {
794
- // Arrange
795
- const entry = {
796
- id: 1,
797
- type: 'batch',
798
- payload: { name: 'ImportUsers', status: 'partial', totalItems: 100, failedItems: 5 },
799
- };
800
- // Act
801
- const tags = await service.autoTag(entry);
802
- // Assert
803
- expect(tags).toContain('ERROR');
804
- });
805
- });
806
- describe('Dump Tags', () => {
807
- it('should add operation tag', async () => {
808
- // Arrange
809
- const entry = {
810
- id: 1,
811
- type: 'dump',
812
- payload: { operation: 'export', format: 'sql', status: 'completed' },
813
- };
814
- // Act
815
- const tags = await service.autoTag(entry);
816
- // Assert
817
- expect(tags).toContain('EXPORT');
818
- });
819
- it('should add format tag', async () => {
820
- // Arrange
821
- const entry = {
822
- id: 1,
823
- type: 'dump',
824
- payload: { operation: 'backup', format: 'json', status: 'completed' },
825
- };
826
- // Act
827
- const tags = await service.autoTag(entry);
828
- // Assert
829
- expect(tags).toContain('JSON');
830
- });
831
- it('should add COMPRESSED tag', async () => {
832
- // Arrange
833
- const entry = {
834
- id: 1,
835
- type: 'dump',
836
- payload: { operation: 'backup', format: 'sql', compressed: true, status: 'completed' },
837
- };
838
- // Act
839
- const tags = await service.autoTag(entry);
840
- // Assert
841
- expect(tags).toContain('COMPRESSED');
842
- });
843
- it('should add ENCRYPTED tag', async () => {
844
- // Arrange
845
- const entry = {
846
- id: 1,
847
- type: 'dump',
848
- payload: { operation: 'backup', format: 'sql', encrypted: true, status: 'completed' },
849
- };
850
- // Act
851
- const tags = await service.autoTag(entry);
852
- // Assert
853
- expect(tags).toContain('ENCRYPTED');
854
- });
855
- });
856
- describe('GraphQL Tags', () => {
857
- it('should add SUCCESS tag when there are no errors', async () => {
858
- // Arrange
859
- const entry = {
860
- id: 1,
861
- type: 'graphql',
862
- payload: { operationName: 'GetUser', statusCode: 200, duration: 10 },
863
- };
864
- // Act
865
- const tags = await service.autoTag(entry);
866
- // Assert
867
- expect(tags).toContain('SUCCESS');
868
- expect(tags).not.toContain('ERROR');
869
- });
870
- it('should add ERROR tag when payload.hasErrors is true', async () => {
871
- // Arrange
872
- const entry = {
873
- id: 1,
874
- type: 'graphql',
875
- payload: { operationName: 'GetUser', hasErrors: true, statusCode: 200, duration: 10 },
876
- };
877
- // Act
878
- const tags = await service.autoTag(entry);
879
- // Assert
880
- expect(tags).toContain('ERROR');
881
- expect(tags).not.toContain('SUCCESS');
882
- });
883
- it('should add ERROR tag when statusCode >= 400', async () => {
884
- // Arrange
885
- const entry = {
886
- id: 1,
887
- type: 'graphql',
888
- payload: { operationName: 'GetUser', statusCode: 500, duration: 10 },
889
- };
890
- // Act
891
- const tags = await service.autoTag(entry);
892
- // Assert
893
- expect(tags).toContain('ERROR');
894
- });
895
- it('should add SLOW tag for operations > 1000ms', async () => {
896
- // Arrange
897
- const entry = {
898
- id: 1,
899
- type: 'graphql',
900
- payload: { operationName: 'GetUser', statusCode: 200, duration: 1500 },
901
- };
902
- // Act
903
- const tags = await service.autoTag(entry);
904
- // Assert
905
- expect(tags).toContain('SLOW');
906
- });
907
- it('should add N+1 tag when potential N+1 queries are detected', async () => {
908
- // Arrange
909
- const entry = {
910
- id: 1,
911
- type: 'graphql',
912
- payload: {
913
- operationName: 'GetUsers',
914
- statusCode: 200,
915
- duration: 10,
916
- potentialN1: [{ resolver: 'User.posts', count: 20 }],
917
- },
918
- };
919
- // Act
920
- const tags = await service.autoTag(entry);
921
- // Assert
922
- expect(tags).toContain('N+1');
923
- });
924
- it('should add USER tag when user.id exists', async () => {
925
- // Arrange
926
- const entry = {
927
- id: 1,
928
- type: 'graphql',
929
- payload: {
930
- operationName: 'GetUser',
931
- statusCode: 200,
932
- duration: 10,
933
- user: { id: 'user-42' },
934
- },
935
- };
936
- // Act
937
- const tags = await service.autoTag(entry);
938
- // Assert
939
- expect(tags).toContain('USER:user-42');
940
- });
941
- it('should include custom tags (uppercased) from the payload', async () => {
942
- // Arrange
943
- const entry = {
944
- id: 1,
945
- type: 'graphql',
946
- payload: {
947
- operationName: 'GetUser',
948
- statusCode: 200,
949
- duration: 10,
950
- tags: ['checkout', 'critical'],
951
- },
952
- };
953
- // Act
954
- const tags = await service.autoTag(entry);
955
- // Assert
956
- expect(tags).toContain('CHECKOUT');
957
- expect(tags).toContain('CRITICAL');
958
- });
959
- it('should not duplicate a custom tag that matches an auto tag', async () => {
960
- // Arrange
961
- const entry = {
962
- id: 1,
963
- type: 'graphql',
964
- payload: {
965
- operationName: 'GetUser',
966
- statusCode: 200,
967
- duration: 10,
968
- tags: ['success'],
969
- },
970
- };
971
- // Act
972
- const tags = await service.autoTag(entry);
973
- // Assert
974
- expect(tags.filter((t) => t === 'SUCCESS')).toHaveLength(1);
975
- });
976
- });
977
- describe('Entry without ID', () => {
978
- it('should not call storage.addTags when entry has no id', async () => {
979
- // Arrange
980
- const entry = {
981
- type: 'request',
982
- payload: { statusCode: 200, method: 'GET', path: '/test' },
983
- };
984
- // Act
985
- await service.autoTag(entry);
986
- // Assert
987
- expect(mockStorage.addTags).not.toHaveBeenCalled();
988
- });
989
- });
990
- });
991
- describe('Tag Management', () => {
992
- describe('addTags', () => {
993
- it('should call storage.addTags', async () => {
994
- // Act
995
- await service.addTags(1, ['tag1', 'tag2']);
996
- // Assert
997
- expect(mockStorage.addTags).toHaveBeenCalledWith(1, ['tag1', 'tag2']);
998
- });
999
- });
1000
- describe('removeTags', () => {
1001
- it('should call storage.removeTags', async () => {
1002
- // Act
1003
- await service.removeTags(1, ['tag1']);
1004
- // Assert
1005
- expect(mockStorage.removeTags).toHaveBeenCalledWith(1, ['tag1']);
1006
- });
1007
- });
1008
- describe('getEntryTags', () => {
1009
- it('should return tags from storage', async () => {
1010
- // Arrange
1011
- mockStorage.getEntryTags.mockResolvedValue(['ERROR', 'SLOW']);
1012
- // Act
1013
- const result = await service.getEntryTags(1);
1014
- // Assert
1015
- expect(result).toEqual(['ERROR', 'SLOW']);
1016
- expect(mockStorage.getEntryTags).toHaveBeenCalledWith(1);
1017
- });
1018
- });
1019
- describe('getAllTags', () => {
1020
- it('should return all tags with counts', async () => {
1021
- // Arrange
1022
- const tags = [
1023
- { tag: 'ERROR', count: 50 },
1024
- { tag: 'SUCCESS', count: 100 },
1025
- ];
1026
- mockStorage.getAllTags.mockResolvedValue(tags);
1027
- // Act
1028
- const result = await service.getAllTags();
1029
- // Assert
1030
- expect(result).toEqual(tags);
1031
- });
1032
- });
1033
- describe('findByTags', () => {
1034
- it('should call storage.findByTags with default params', async () => {
1035
- // Arrange
1036
- mockStorage.findByTags.mockResolvedValue([]);
1037
- // Act
1038
- await service.findByTags(['ERROR']);
1039
- // Assert
1040
- expect(mockStorage.findByTags).toHaveBeenCalledWith(['ERROR'], 'OR', 50);
1041
- });
1042
- it('should pass custom logic and limit', async () => {
1043
- // Arrange
1044
- mockStorage.findByTags.mockResolvedValue([]);
1045
- // Act
1046
- await service.findByTags(['ERROR', 'SLOW'], 'AND', 100);
1047
- // Assert
1048
- expect(mockStorage.findByTags).toHaveBeenCalledWith(['ERROR', 'SLOW'], 'AND', 100);
1049
- });
1050
- });
1051
- });
1052
- describe('Monitored Tags', () => {
1053
- describe('addMonitoredTag', () => {
1054
- it('should call storage.addMonitoredTag', async () => {
1055
- // Arrange
1056
- const monitoredTag = {
1057
- id: 1,
1058
- tag: 'CRITICAL',
1059
- createdAt: new Date().toISOString(),
1060
- };
1061
- mockStorage.addMonitoredTag.mockResolvedValue(monitoredTag);
1062
- // Act
1063
- const result = await service.addMonitoredTag('CRITICAL');
1064
- // Assert
1065
- expect(mockStorage.addMonitoredTag).toHaveBeenCalledWith('CRITICAL');
1066
- expect(result).toEqual(monitoredTag);
1067
- });
1068
- });
1069
- describe('removeMonitoredTag', () => {
1070
- it('should call storage.removeMonitoredTag', async () => {
1071
- // Act
1072
- await service.removeMonitoredTag('CRITICAL');
1073
- // Assert
1074
- expect(mockStorage.removeMonitoredTag).toHaveBeenCalledWith('CRITICAL');
1075
- });
1076
- });
1077
- describe('getMonitoredTags', () => {
1078
- it('should return monitored tags from storage', async () => {
1079
- // Arrange
1080
- const tags = [
1081
- { id: 1, tag: 'CRITICAL', createdAt: new Date().toISOString() },
1082
- { id: 2, tag: 'ERROR', createdAt: new Date().toISOString() },
1083
- ];
1084
- mockStorage.getMonitoredTags.mockResolvedValue(tags);
1085
- // Act
1086
- const result = await service.getMonitoredTags();
1087
- // Assert
1088
- expect(result).toEqual(tags);
1089
- });
1090
- });
1091
- describe('getMonitoredTagsWithCounts', () => {
1092
- it('should merge monitored tags with counts', async () => {
1093
- // Arrange
1094
- const monitoredTags = [
1095
- { id: 1, tag: 'CRITICAL', createdAt: '2024-01-01' },
1096
- { id: 2, tag: 'ERROR', createdAt: '2024-01-02' },
1097
- ];
1098
- const allTags = [
1099
- { tag: 'CRITICAL', count: 10 },
1100
- { tag: 'ERROR', count: 50 },
1101
- { tag: 'SUCCESS', count: 100 },
1102
- ];
1103
- mockStorage.getMonitoredTags.mockResolvedValue(monitoredTags);
1104
- mockStorage.getAllTags.mockResolvedValue(allTags);
1105
- // Act
1106
- const result = await service.getMonitoredTagsWithCounts();
1107
- // Assert
1108
- expect(result).toEqual([
1109
- { id: 1, tag: 'CRITICAL', createdAt: '2024-01-01', count: 10 },
1110
- { id: 2, tag: 'ERROR', createdAt: '2024-01-02', count: 50 },
1111
- ]);
1112
- });
1113
- it('should return 0 count for tags not found in allTags', async () => {
1114
- // Arrange
1115
- const monitoredTags = [{ id: 1, tag: 'NEWTYPE', createdAt: '2024-01-01' }];
1116
- mockStorage.getMonitoredTags.mockResolvedValue(monitoredTags);
1117
- mockStorage.getAllTags.mockResolvedValue([]);
1118
- // Act
1119
- const result = await service.getMonitoredTagsWithCounts();
1120
- // Assert
1121
- expect(result).toEqual([{ id: 1, tag: 'NEWTYPE', createdAt: '2024-01-01', count: 0 }]);
1122
- });
1123
- });
1124
- });
1125
- });
1126
- //# sourceMappingURL=tag.service.spec.js.map