@talkpilot/core-db 1.1.3 → 1.1.5

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 (329) hide show
  1. package/dist/connection.d.ts +1 -1
  2. package/dist/connection.d.ts.map +1 -1
  3. package/dist/connection.js +21 -24
  4. package/dist/connection.js.map +1 -1
  5. package/dist/index.d.ts +9 -9
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/municipal/cities/cities.getters.d.ts +2 -2
  9. package/dist/municipal/cities/cities.getters.d.ts.map +1 -1
  10. package/dist/municipal/cities/cities.getters.js +8 -4
  11. package/dist/municipal/cities/cities.getters.js.map +1 -1
  12. package/dist/municipal/cities/cities.types.d.ts +1 -1
  13. package/dist/municipal/cities/index.d.ts +2 -2
  14. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts +3 -3
  15. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts.map +1 -1
  16. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js +30 -22
  17. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js.map +1 -1
  18. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts +4 -4
  19. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts.map +1 -1
  20. package/dist/municipal/departmentsSubjects/index.d.ts +2 -2
  21. package/dist/municipal/index.d.ts +8 -8
  22. package/dist/municipal/index.d.ts.map +1 -1
  23. package/dist/municipal/index.js +1 -1
  24. package/dist/municipal/mongodb-client.d.ts +1 -1
  25. package/dist/municipal/mongodb-client.d.ts.map +1 -1
  26. package/dist/municipal/mongodb-client.js +13 -25
  27. package/dist/municipal/mongodb-client.js.map +1 -1
  28. package/dist/municipal/streets/index.d.ts +2 -2
  29. package/dist/municipal/streets/streets.getters.d.ts +3 -3
  30. package/dist/municipal/streets/streets.getters.d.ts.map +1 -1
  31. package/dist/municipal/streets/streets.getters.js +19 -9
  32. package/dist/municipal/streets/streets.getters.js.map +1 -1
  33. package/dist/municipal/streets/streets.types.d.ts +1 -1
  34. package/dist/municipal/systemInstructions/index.d.ts +3 -3
  35. package/dist/municipal/systemInstructions/index.d.ts.map +1 -1
  36. package/dist/municipal/systemInstructions/instructions.getters.d.ts +3 -3
  37. package/dist/municipal/systemInstructions/instructions.getters.d.ts.map +1 -1
  38. package/dist/municipal/systemInstructions/instructions.getters.js +10 -4
  39. package/dist/municipal/systemInstructions/instructions.getters.js.map +1 -1
  40. package/dist/municipal/systemInstructions/instructions.setters.d.ts +2 -2
  41. package/dist/municipal/systemInstructions/instructions.setters.d.ts.map +1 -1
  42. package/dist/municipal/systemInstructions/instructions.setters.js +13 -8
  43. package/dist/municipal/systemInstructions/instructions.setters.js.map +1 -1
  44. package/dist/municipal/systemInstructions/instructions.types.d.ts +3 -3
  45. package/dist/municipal/systemInstructions/instructions.types.d.ts.map +1 -1
  46. package/dist/municipal/systemInstructions/instructions.types.js +6 -6
  47. package/dist/municipal/tickets/index.d.ts +2 -2
  48. package/dist/municipal/tickets/tickets.getters.d.ts +3 -3
  49. package/dist/municipal/tickets/tickets.getters.d.ts.map +1 -1
  50. package/dist/municipal/tickets/tickets.getters.js +50 -29
  51. package/dist/municipal/tickets/tickets.getters.js.map +1 -1
  52. package/dist/municipal/tickets/tickets.types.d.ts +1 -1
  53. package/dist/municipal/tickets/tickets.types.d.ts.map +1 -1
  54. package/dist/municipal/utils/types.d.ts +1 -1
  55. package/dist/municipal/utils/types.d.ts.map +1 -1
  56. package/dist/talkpilot/agents/agents.getters.d.ts +1 -1
  57. package/dist/talkpilot/agents/agents.getters.js +2 -2
  58. package/dist/talkpilot/agents/agents.types.d.ts +2 -2
  59. package/dist/talkpilot/agents/index.d.ts +2 -2
  60. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts +2 -2
  61. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts.map +1 -1
  62. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js +1 -1
  63. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js.map +1 -1
  64. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.types.d.ts +2 -2
  65. package/dist/talkpilot/backgroundToolResults/index.d.ts +2 -2
  66. package/dist/talkpilot/calls/calls.getters.d.ts +3 -3
  67. package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
  68. package/dist/talkpilot/calls/calls.getters.js +19 -15
  69. package/dist/talkpilot/calls/calls.getters.js.map +1 -1
  70. package/dist/talkpilot/calls/calls.types.d.ts +3 -3
  71. package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
  72. package/dist/talkpilot/calls/calls.types.js +2 -2
  73. package/dist/talkpilot/calls/index.d.ts +2 -2
  74. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts +2 -2
  75. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts.map +1 -1
  76. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js +2 -2
  77. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js.map +1 -1
  78. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts +2 -2
  79. package/dist/talkpilot/clientAudioBuffers/index.d.ts +2 -2
  80. package/dist/talkpilot/clients/clients.getters.d.ts +2 -2
  81. package/dist/talkpilot/clients/clients.getters.d.ts.map +1 -1
  82. package/dist/talkpilot/clients/clients.getters.js +5 -2
  83. package/dist/talkpilot/clients/clients.getters.js.map +1 -1
  84. package/dist/talkpilot/clients/clients.types.d.ts +1 -1
  85. package/dist/talkpilot/clients/index.d.ts +2 -2
  86. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +2 -2
  87. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
  88. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +1 -1
  89. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
  90. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +9 -2
  91. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
  92. package/dist/talkpilot/clientsConfig/index.d.ts +2 -2
  93. package/dist/talkpilot/flows/flows.getter.d.ts +2 -2
  94. package/dist/talkpilot/flows/flows.getter.d.ts.map +1 -1
  95. package/dist/talkpilot/flows/flows.getter.js +1 -1
  96. package/dist/talkpilot/flows/flows.getter.js.map +1 -1
  97. package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
  98. package/dist/talkpilot/flows/flows.schema.js +87 -79
  99. package/dist/talkpilot/flows/flows.schema.js.map +1 -1
  100. package/dist/talkpilot/flows/flows.types.d.ts +16 -16
  101. package/dist/talkpilot/flows/index.d.ts +2 -2
  102. package/dist/talkpilot/groups/groups.getters.d.ts +2 -2
  103. package/dist/talkpilot/groups/groups.getters.d.ts.map +1 -1
  104. package/dist/talkpilot/groups/groups.getters.js +2 -2
  105. package/dist/talkpilot/groups/groups.getters.js.map +1 -1
  106. package/dist/talkpilot/groups/groups.types.d.ts +1 -1
  107. package/dist/talkpilot/groups/index.d.ts +3 -3
  108. package/dist/talkpilot/groups/phone.utils.d.ts +1 -1
  109. package/dist/talkpilot/groups/phone.utils.d.ts.map +1 -1
  110. package/dist/talkpilot/groups/phone.utils.js +2 -2
  111. package/dist/talkpilot/groups/phone.utils.js.map +1 -1
  112. package/dist/talkpilot/index.d.ts +16 -16
  113. package/dist/talkpilot/index.js +1 -1
  114. package/dist/talkpilot/leads/index.d.ts +2 -2
  115. package/dist/talkpilot/leads/leads.getter.d.ts +2 -2
  116. package/dist/talkpilot/leads/leads.getter.d.ts.map +1 -1
  117. package/dist/talkpilot/leads/leads.getter.js +1 -1
  118. package/dist/talkpilot/leads/leads.getter.js.map +1 -1
  119. package/dist/talkpilot/leads/leads.schema.js +16 -16
  120. package/dist/talkpilot/leads/leads.types.d.ts +1 -1
  121. package/dist/talkpilot/mongodb-client.d.ts +1 -1
  122. package/dist/talkpilot/mongodb-client.d.ts.map +1 -1
  123. package/dist/talkpilot/mongodb-client.js +16 -29
  124. package/dist/talkpilot/mongodb-client.js.map +1 -1
  125. package/dist/talkpilot/phone_numbers/index.d.ts +2 -2
  126. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +3 -3
  127. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
  128. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +28 -13
  129. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
  130. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +9 -9
  131. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +1 -1
  132. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -1
  133. package/dist/talkpilot/plans/index.d.ts +2 -2
  134. package/dist/talkpilot/plans/plans.getters.d.ts +2 -2
  135. package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -1
  136. package/dist/talkpilot/plans/plans.getters.js +3 -3
  137. package/dist/talkpilot/plans/plans.getters.js.map +1 -1
  138. package/dist/talkpilot/plans/plans.types.d.ts +4 -4
  139. package/dist/talkpilot/plans/plans.types.d.ts.map +1 -1
  140. package/dist/talkpilot/plans/plans.types.js +19 -19
  141. package/dist/talkpilot/results/index.d.ts +2 -2
  142. package/dist/talkpilot/results/index.d.ts.map +1 -1
  143. package/dist/talkpilot/results/index.js.map +1 -1
  144. package/dist/talkpilot/results/results.getter.d.ts +3 -3
  145. package/dist/talkpilot/results/results.getter.d.ts.map +1 -1
  146. package/dist/talkpilot/results/results.getter.js +4 -4
  147. package/dist/talkpilot/results/results.getter.js.map +1 -1
  148. package/dist/talkpilot/results/results.schema.js +18 -18
  149. package/dist/talkpilot/results/results.types.d.ts +1 -1
  150. package/dist/talkpilot/sessions/index.d.ts +2 -2
  151. package/dist/talkpilot/sessions/sessions.getter.d.ts +3 -3
  152. package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -1
  153. package/dist/talkpilot/sessions/sessions.getter.js +13 -10
  154. package/dist/talkpilot/sessions/sessions.getter.js.map +1 -1
  155. package/dist/talkpilot/sessions/sessions.schema.js +17 -17
  156. package/dist/talkpilot/sessions/sessions.types.d.ts +2 -2
  157. package/dist/talkpilot/subscriptions/index.d.ts +3 -3
  158. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +2 -2
  159. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -1
  160. package/dist/talkpilot/subscriptions/subscriptions.getters.js +11 -11
  161. package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -1
  162. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +2 -2
  163. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -1
  164. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -1
  165. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +2 -2
  166. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -1
  167. package/dist/talkpilot/subscriptions/subscriptions.types.js +7 -7
  168. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +4 -0
  169. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +1 -0
  170. package/dist/talkpilot/subscriptions/subscriptions.utils.js +20 -0
  171. package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +1 -0
  172. package/dist/talkpilot/utils/query.utils.d.ts +1 -1
  173. package/dist/test-utils/db-utils.d.ts +1 -1
  174. package/dist/test-utils/db-utils.js +2 -2
  175. package/dist/test-utils/factories/index.d.ts +12 -12
  176. package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
  177. package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
  178. package/dist/test-utils/factories/municipal/cities.js +1 -1
  179. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
  180. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
  181. package/dist/test-utils/factories/municipal/departmentsSubjects.js +7 -1
  182. package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
  183. package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
  184. package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
  185. package/dist/test-utils/factories/municipal/streets.js +6 -1
  186. package/dist/test-utils/factories/municipal/streets.js.map +1 -1
  187. package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
  188. package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
  189. package/dist/test-utils/factories/municipal/tickets.js +7 -1
  190. package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
  191. package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
  192. package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
  193. package/dist/test-utils/factories/talkpilot/agents.js +4 -4
  194. package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
  195. package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
  196. package/dist/test-utils/factories/talkpilot/calls.js +1 -1
  197. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
  198. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
  199. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
  200. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
  201. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
  202. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
  203. package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
  204. package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
  205. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
  206. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
  207. package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
  208. package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
  209. package/dist/test-utils/factories/talkpilot/groups.js +9 -9
  210. package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
  211. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
  212. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
  213. package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
  214. package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
  215. package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
  216. package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
  217. package/dist/utils/validation.js +2 -2
  218. package/dist/utils/validation.js.map +1 -1
  219. package/package.json +3 -1
  220. package/src/__tests__/setup.ts +3 -3
  221. package/src/connection.ts +27 -25
  222. package/src/index.ts +9 -9
  223. package/src/municipal/__tests__/validation.spec.ts +35 -23
  224. package/src/municipal/cities/cities.getters.ts +16 -10
  225. package/src/municipal/cities/cities.types.ts +1 -1
  226. package/src/municipal/cities/index.ts +2 -2
  227. package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +53 -44
  228. package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
  229. package/src/municipal/departmentsSubjects/index.ts +2 -3
  230. package/src/municipal/index.ts +10 -10
  231. package/src/municipal/mongodb-client.ts +19 -26
  232. package/src/municipal/streets/index.ts +2 -2
  233. package/src/municipal/streets/streets.getters.ts +43 -23
  234. package/src/municipal/streets/streets.types.ts +1 -1
  235. package/src/municipal/systemInstructions/__tests__/getters.spec.ts +67 -52
  236. package/src/municipal/systemInstructions/__tests__/setters.spec.ts +271 -238
  237. package/src/municipal/systemInstructions/index.ts +7 -3
  238. package/src/municipal/systemInstructions/instructions.getters.ts +30 -18
  239. package/src/municipal/systemInstructions/instructions.setters.ts +43 -19
  240. package/src/municipal/systemInstructions/instructions.types.ts +10 -10
  241. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
  242. package/src/municipal/tickets/index.ts +2 -2
  243. package/src/municipal/tickets/tickets.getters.ts +69 -42
  244. package/src/municipal/tickets/tickets.types.ts +2 -2
  245. package/src/municipal/utils/types.ts +8 -3
  246. package/src/talkpilot/__tests__/db.spec.ts +12 -12
  247. package/src/talkpilot/__tests__/mongodb-client.spec.ts +7 -8
  248. package/src/talkpilot/__tests__/validation.spec.ts +30 -24
  249. package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
  250. package/src/talkpilot/agents/agents.getters.ts +3 -3
  251. package/src/talkpilot/agents/agents.types.ts +2 -2
  252. package/src/talkpilot/agents/index.ts +2 -2
  253. package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +42 -31
  254. package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
  255. package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +2 -3
  256. package/src/talkpilot/backgroundToolResults/index.ts +2 -2
  257. package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
  258. package/src/talkpilot/calls/__tests__/calls.spec.ts +79 -39
  259. package/src/talkpilot/calls/calls.getters.ts +48 -28
  260. package/src/talkpilot/calls/calls.types.ts +16 -16
  261. package/src/talkpilot/calls/index.ts +2 -2
  262. package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +73 -39
  263. package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +18 -11
  264. package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
  265. package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
  266. package/src/talkpilot/clients/clients.getters.ts +10 -5
  267. package/src/talkpilot/clients/clients.types.ts +1 -1
  268. package/src/talkpilot/clients/index.ts +2 -2
  269. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +21 -18
  270. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +6 -4
  271. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +17 -7
  272. package/src/talkpilot/clientsConfig/index.ts +2 -2
  273. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +38 -34
  274. package/src/talkpilot/flows/flows.getter.ts +8 -5
  275. package/src/talkpilot/flows/flows.schema.ts +87 -79
  276. package/src/talkpilot/flows/flows.types.ts +23 -23
  277. package/src/talkpilot/flows/index.ts +2 -2
  278. package/src/talkpilot/groups/__tests__/groups.spec.ts +34 -27
  279. package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
  280. package/src/talkpilot/groups/groups.getters.ts +8 -5
  281. package/src/talkpilot/groups/groups.types.ts +1 -1
  282. package/src/talkpilot/groups/index.ts +3 -3
  283. package/src/talkpilot/groups/phone.utils.ts +12 -6
  284. package/src/talkpilot/index.ts +17 -17
  285. package/src/talkpilot/leads/index.ts +2 -2
  286. package/src/talkpilot/leads/leads.getter.ts +5 -4
  287. package/src/talkpilot/leads/leads.schema.ts +16 -16
  288. package/src/talkpilot/leads/leads.types.ts +1 -1
  289. package/src/talkpilot/mongodb-client.ts +23 -33
  290. package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +84 -44
  291. package/src/talkpilot/phone_numbers/index.ts +2 -2
  292. package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +44 -22
  293. package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +9 -9
  294. package/src/talkpilot/phone_numbers/phone_numbers.types.ts +1 -1
  295. package/src/talkpilot/plans/__tests__/plans.spec.ts +30 -26
  296. package/src/talkpilot/plans/index.ts +2 -2
  297. package/src/talkpilot/plans/plans.getters.ts +25 -18
  298. package/src/talkpilot/plans/plans.types.ts +27 -23
  299. package/src/talkpilot/results/index.ts +5 -2
  300. package/src/talkpilot/results/results.getter.ts +9 -8
  301. package/src/talkpilot/results/results.schema.ts +18 -18
  302. package/src/talkpilot/results/results.types.ts +1 -1
  303. package/src/talkpilot/sessions/__tests__/sessions.spec.ts +65 -41
  304. package/src/talkpilot/sessions/index.ts +2 -2
  305. package/src/talkpilot/sessions/sessions.getter.ts +21 -16
  306. package/src/talkpilot/sessions/sessions.schema.ts +17 -17
  307. package/src/talkpilot/sessions/sessions.types.ts +2 -2
  308. package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +18 -15
  309. package/src/talkpilot/subscriptions/index.ts +3 -3
  310. package/src/talkpilot/subscriptions/subscriptions.getters.ts +36 -33
  311. package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +10 -3
  312. package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
  313. package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
  314. package/src/talkpilot/utils/query.utils.ts +2 -2
  315. package/src/test-utils/db-utils.ts +5 -5
  316. package/src/test-utils/factories/index.ts +12 -12
  317. package/src/test-utils/factories/municipal/cities.ts +5 -5
  318. package/src/test-utils/factories/municipal/departmentsSubjects.ts +32 -25
  319. package/src/test-utils/factories/municipal/streets.ts +10 -5
  320. package/src/test-utils/factories/municipal/tickets.ts +12 -6
  321. package/src/test-utils/factories/talkpilot/agents.ts +8 -8
  322. package/src/test-utils/factories/talkpilot/calls.ts +5 -5
  323. package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +14 -12
  324. package/src/test-utils/factories/talkpilot/clientsConfig.ts +7 -8
  325. package/src/test-utils/factories/talkpilot/flows.ts +7 -5
  326. package/src/test-utils/factories/talkpilot/groups.ts +13 -13
  327. package/src/test-utils/factories/talkpilot/phone_numbers.ts +8 -6
  328. package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
  329. package/src/utils/validation.ts +4 -4
@@ -1,14 +1,14 @@
1
- import { findAgents } from '../agents.getters';
2
- import { setDb } from '../../index';
3
- import { Db, Collection } from 'mongodb';
4
- import { createAgent } from '../../../test-utils/factories';
1
+ import { findAgents } from "../agents.getters";
2
+ import { setDb } from "../../index";
3
+ import { Db, Collection } from "mongodb";
4
+ import { createAgent } from "../../../test-utils/factories";
5
5
 
6
- describe('agents getters', () => {
6
+ describe("agents getters", () => {
7
7
  let mockDb: Partial<Db>;
8
8
  let mockCollection: Partial<Collection>;
9
9
 
10
10
  beforeEach(() => {
11
- const mockAgent = createAgent({ name: 'Agent Smith' });
11
+ const mockAgent = createAgent({ name: "Agent Smith" });
12
12
  mockCollection = {
13
13
  find: jest.fn().mockReturnValue({
14
14
  toArray: jest.fn().mockResolvedValue([mockAgent]),
@@ -20,10 +20,10 @@ describe('agents getters', () => {
20
20
  setDb(mockDb as Db);
21
21
  });
22
22
 
23
- it('findAgents should return agents', async () => {
23
+ it("findAgents should return agents", async () => {
24
24
  const result = await findAgents();
25
-
26
- expect(mockDb.collection).toHaveBeenCalledWith('agents');
27
- expect(result[0].name).toBe('Agent Smith');
25
+
26
+ expect(mockDb.collection).toHaveBeenCalledWith("agents");
27
+ expect(result[0].name).toBe("Agent Smith");
28
28
  });
29
29
  });
@@ -1,7 +1,7 @@
1
- import { getDb, Agent, ObjectId } from '../index';
1
+ import { getDb, Agent, ObjectId } from "../index";
2
2
 
3
3
  export const getAgentsCollection = () => {
4
- return getDb().collection<Agent>('agents');
4
+ return getDb().collection<Agent>("agents");
5
5
  };
6
6
 
7
7
  export const findAgents = async (filter: any = {}) => {
@@ -25,7 +25,7 @@ export const updateAgent = (agentId: string, data: Partial<Agent>) => {
25
25
  return getAgentsCollection().findOneAndUpdate(
26
26
  { _id: new ObjectId(agentId) },
27
27
  { $set: data },
28
- { returnDocument: 'after' }
28
+ { returnDocument: "after" },
29
29
  );
30
30
  };
31
31
 
@@ -1,4 +1,4 @@
1
- import { WithId } from 'mongodb';
1
+ import { WithId } from "mongodb";
2
2
 
3
3
  export type Agent = {
4
4
  name: string;
@@ -8,7 +8,7 @@ export type Agent = {
8
8
  labels: string[];
9
9
  clientId: string;
10
10
  role: string;
11
- gender: 'male' | 'female';
11
+ gender: "male" | "female";
12
12
  };
13
13
 
14
14
  export type AgentDoc = WithId<Agent>;
@@ -1,2 +1,2 @@
1
- export * from './agents.getters';
2
- export * from './agents.types';
1
+ export * from "./agents.getters";
2
+ export * from "./agents.types";
@@ -3,23 +3,28 @@ import {
3
3
  upsertBackgroundToolResult,
4
4
  findBackgroundToolResult,
5
5
  findBackgroundToolResultsByCallSid,
6
- } from '../backgroundToolResults.getters';
7
- import { BackgroundToolStatus } from '../backgroundToolResults.types';
6
+ } from "../backgroundToolResults.getters";
7
+ import { BackgroundToolStatus } from "../backgroundToolResults.types";
8
8
 
9
- describe('backgroundToolResults getters', () => {
9
+ describe("backgroundToolResults getters", () => {
10
10
  it('should return the "backgroundToolResults" collection', () => {
11
11
  const collection = getBackgroundToolResultsCollection();
12
- expect(collection.collectionName).toBe('backgroundToolResults');
12
+ expect(collection.collectionName).toBe("backgroundToolResults");
13
13
  });
14
14
 
15
- it('should create a new background tool result with correct fields and default TTL', async () => {
16
- const callSid = 'CA-background-call-1';
17
- const toolName = 'exampleTool';
18
- const status: BackgroundToolStatus = 'pending';
15
+ it("should create a new background tool result with correct fields and default TTL", async () => {
16
+ const callSid = "CA-background-call-1";
17
+ const toolName = "exampleTool";
18
+ const status: BackgroundToolStatus = "pending";
19
19
  const result = null;
20
20
 
21
21
  const before = new Date();
22
- const doc = await upsertBackgroundToolResult({ callSid, toolName, status, result });
22
+ const doc = await upsertBackgroundToolResult({
23
+ callSid,
24
+ toolName,
25
+ status,
26
+ result,
27
+ });
23
28
  const after = new Date();
24
29
 
25
30
  expect(doc).not.toBeNull();
@@ -42,14 +47,14 @@ describe('backgroundToolResults getters', () => {
42
47
  expect(doc!.updatedAt.getTime()).toBeLessThanOrEqual(after.getTime());
43
48
  });
44
49
 
45
- it('should upsert by callSid + toolName and keep createdAt while updating other fields', async () => {
46
- const callSid = 'CA-background-call-2';
47
- const toolName = 'aggregationTool';
50
+ it("should upsert by callSid + toolName and keep createdAt while updating other fields", async () => {
51
+ const callSid = "CA-background-call-2";
52
+ const toolName = "aggregationTool";
48
53
 
49
54
  const first = await upsertBackgroundToolResult({
50
55
  callSid,
51
56
  toolName,
52
- status: 'pending',
57
+ status: "pending",
53
58
  result: null,
54
59
  });
55
60
 
@@ -65,7 +70,7 @@ describe('backgroundToolResults getters', () => {
65
70
  const second = await upsertBackgroundToolResult({
66
71
  callSid,
67
72
  toolName,
68
- status: 'success',
73
+ status: "success",
69
74
  result: secondResultPayload,
70
75
  ttlMs: customTtlMs,
71
76
  });
@@ -74,12 +79,14 @@ describe('backgroundToolResults getters', () => {
74
79
  expect(second!._id.toHexString()).toBe(first!._id.toHexString());
75
80
  expect(second!.callSid).toBe(callSid);
76
81
  expect(second!.toolName).toBe(toolName);
77
- expect(second!.status).toBe('success');
82
+ expect(second!.status).toBe("success");
78
83
  expect(second!.result).toEqual(secondResultPayload);
79
84
 
80
85
  expect(second!.createdAt.getTime()).toBe(firstCreatedAt.getTime());
81
86
 
82
- expect(second!.updatedAt.getTime()).toBeGreaterThanOrEqual(firstUpdatedAt.getTime());
87
+ expect(second!.updatedAt.getTime()).toBeGreaterThanOrEqual(
88
+ firstUpdatedAt.getTime(),
89
+ );
83
90
  expect(second!.expiredAt.getTime()).not.toBe(firstExpiredAt.getTime());
84
91
 
85
92
  const ttlMs = second!.expiredAt.getTime() - second!.updatedAt.getTime();
@@ -87,15 +94,15 @@ describe('backgroundToolResults getters', () => {
87
94
  expect(ttlMs).toBeLessThanOrEqual(customTtlMs + 1000);
88
95
  });
89
96
 
90
- it('should find background tool result by callSid and toolName', async () => {
91
- const callSid = 'CA-background-call-3';
92
- const toolName = 'fetchUserData';
97
+ it("should find background tool result by callSid and toolName", async () => {
98
+ const callSid = "CA-background-call-3";
99
+ const toolName = "fetchUserData";
93
100
 
94
101
  await upsertBackgroundToolResult({
95
102
  callSid,
96
103
  toolName,
97
- status: 'success',
98
- result: { foo: 'bar' },
104
+ status: "success",
105
+ result: { foo: "bar" },
99
106
  });
100
107
 
101
108
  const found = await findBackgroundToolResult(callSid, toolName);
@@ -104,18 +111,21 @@ describe('backgroundToolResults getters', () => {
104
111
  expect(found?.toolName).toBe(toolName);
105
112
  });
106
113
 
107
- it('should return null when background tool result does not exist', async () => {
108
- const found = await findBackgroundToolResult('non-existing-callSid', 'nonExistingTool');
114
+ it("should return null when background tool result does not exist", async () => {
115
+ const found = await findBackgroundToolResult(
116
+ "non-existing-callSid",
117
+ "nonExistingTool",
118
+ );
109
119
  expect(found).toBeNull();
110
120
  });
111
121
 
112
- it('should return all background tool results for a callSid ordered by createdAt', async () => {
113
- const callSid = 'CA-background-call-4';
122
+ it("should return all background tool results for a callSid ordered by createdAt", async () => {
123
+ const callSid = "CA-background-call-4";
114
124
 
115
125
  await upsertBackgroundToolResult({
116
126
  callSid,
117
- toolName: 'toolA',
118
- status: 'pending',
127
+ toolName: "toolA",
128
+ status: "pending",
119
129
  result: null,
120
130
  });
121
131
 
@@ -123,14 +133,15 @@ describe('backgroundToolResults getters', () => {
123
133
 
124
134
  await upsertBackgroundToolResult({
125
135
  callSid,
126
- toolName: 'toolB',
127
- status: 'success',
136
+ toolName: "toolB",
137
+ status: "success",
128
138
  result: { ok: true },
129
139
  });
130
140
 
131
141
  const results = await findBackgroundToolResultsByCallSid(callSid);
132
142
  expect(results).toHaveLength(2);
133
- expect(results[0].createdAt.getTime()).toBeLessThanOrEqual(results[1].createdAt.getTime());
143
+ expect(results[0].createdAt.getTime()).toBeLessThanOrEqual(
144
+ results[1].createdAt.getTime(),
145
+ );
134
146
  });
135
147
  });
136
-
@@ -1,17 +1,18 @@
1
- import { Collection } from 'mongodb';
2
- import { getDb } from '../index';
1
+ import { Collection } from "mongodb";
2
+ import { getDb } from "../index";
3
3
  import {
4
4
  BackgroundToolResult,
5
5
  BackgroundToolResultDoc,
6
6
  UpsertBackgroundToolResultInput,
7
- } from './backgroundToolResults.types';
7
+ } from "./backgroundToolResults.types";
8
8
 
9
- const getBackgroundToolResultsCollection = (): Collection<BackgroundToolResult> => {
10
- return getDb().collection<BackgroundToolResult>('backgroundToolResults');
11
- };
9
+ const getBackgroundToolResultsCollection =
10
+ (): Collection<BackgroundToolResult> => {
11
+ return getDb().collection<BackgroundToolResult>("backgroundToolResults");
12
+ };
12
13
 
13
14
  const upsertBackgroundToolResult = async (
14
- input: UpsertBackgroundToolResultInput
15
+ input: UpsertBackgroundToolResultInput,
15
16
  ): Promise<BackgroundToolResultDoc | null> => {
16
17
  const collection = getBackgroundToolResultsCollection();
17
18
  const now = new Date();
@@ -35,7 +36,7 @@ const upsertBackgroundToolResult = async (
35
36
  createdAt: now,
36
37
  },
37
38
  },
38
- { upsert: true }
39
+ { upsert: true },
39
40
  );
40
41
 
41
42
  return collection.findOne(filter);
@@ -43,14 +44,14 @@ const upsertBackgroundToolResult = async (
43
44
 
44
45
  const findBackgroundToolResult = async (
45
46
  callSid: string,
46
- toolName: string
47
+ toolName: string,
47
48
  ): Promise<BackgroundToolResultDoc | null> => {
48
49
  const collection = getBackgroundToolResultsCollection();
49
50
  return collection.findOne({ callSid, toolName });
50
51
  };
51
52
 
52
53
  const findBackgroundToolResultsByCallSid = async (
53
- callSid: string
54
+ callSid: string,
54
55
  ): Promise<BackgroundToolResultDoc[]> => {
55
56
  const collection = getBackgroundToolResultsCollection();
56
57
  return collection.find({ callSid }).sort({ createdAt: 1 }).toArray();
@@ -62,4 +63,3 @@ export {
62
63
  findBackgroundToolResult,
63
64
  findBackgroundToolResultsByCallSid,
64
65
  };
65
-
@@ -1,6 +1,6 @@
1
- import { WithId } from 'mongodb';
1
+ import { WithId } from "mongodb";
2
2
 
3
- export type BackgroundToolStatus = 'success' | 'pending' | 'error';
3
+ export type BackgroundToolStatus = "success" | "pending" | "error";
4
4
 
5
5
  export interface BackgroundToolResult {
6
6
  callSid: string;
@@ -21,4 +21,3 @@ export interface UpsertBackgroundToolResultInput {
21
21
  status: BackgroundToolStatus;
22
22
  ttlMs?: number;
23
23
  }
24
-
@@ -1,2 +1,2 @@
1
- export * from './backgroundToolResults.getters';
2
- export type * from './backgroundToolResults.types';
1
+ export * from "./backgroundToolResults.getters";
2
+ export type * from "./backgroundToolResults.types";
@@ -4,14 +4,17 @@ import {
4
4
  range,
5
5
  startOfDay,
6
6
  getCallsCollection,
7
- } from '../calls.getters';
8
- import { createIncomingCallDoc, createOutGoingCallDoc } from '../../../test-utils/factories';
7
+ } from "../calls.getters";
8
+ import {
9
+ createIncomingCallDoc,
10
+ createOutGoingCallDoc,
11
+ } from "../../../test-utils/factories";
9
12
 
10
- describe('callStats.utils', () => {
11
- describe('countCallsByPhoneInRange', () => {
12
- it('counts outgoing calls for a phone within a date range', async () => {
13
- const phone = '+972500000001';
14
- const baseDate = new Date('2023-01-10T10:00:00Z');
13
+ describe("callStats.utils", () => {
14
+ describe("countCallsByPhoneInRange", () => {
15
+ it("counts outgoing calls for a phone within a date range", async () => {
16
+ const phone = "+972500000001";
17
+ const baseDate = new Date("2023-01-10T10:00:00Z");
15
18
 
16
19
  const outgoingInside = createOutGoingCallDoc({
17
20
  customerPhoneNumber: phone,
@@ -27,16 +30,16 @@ describe('callStats.utils', () => {
27
30
  });
28
31
 
29
32
  await getCallsCollection().insertMany([
30
- { ...outgoingInside, updatedAt: outgoingInside.createdAt, env: 'test' },
33
+ { ...outgoingInside, updatedAt: outgoingInside.createdAt, env: "test" },
31
34
  {
32
35
  ...outgoingOutsideBefore,
33
36
  updatedAt: outgoingOutsideBefore.createdAt,
34
- env: 'test',
37
+ env: "test",
35
38
  },
36
39
  {
37
40
  ...outgoingOutsideAfter,
38
41
  updatedAt: outgoingOutsideAfter.createdAt,
39
- env: 'test',
42
+ env: "test",
40
43
  },
41
44
  ]);
42
45
 
@@ -52,9 +55,9 @@ describe('callStats.utils', () => {
52
55
  expect(count).toBe(1);
53
56
  });
54
57
 
55
- it('filters by incoming/outgoing flags', async () => {
56
- const phone = '+972500000002';
57
- const createdAt = new Date('2023-02-01T12:00:00Z');
58
+ it("filters by incoming/outgoing flags", async () => {
59
+ const phone = "+972500000002";
60
+ const createdAt = new Date("2023-02-01T12:00:00Z");
58
61
 
59
62
  const outgoing = createOutGoingCallDoc({
60
63
  customerPhoneNumber: phone,
@@ -66,8 +69,8 @@ describe('callStats.utils', () => {
66
69
  });
67
70
 
68
71
  await getCallsCollection().insertMany([
69
- { ...outgoing, updatedAt: outgoing.createdAt, env: 'test' },
70
- { ...incoming, updatedAt: incoming.createdAt, env: 'test' },
72
+ { ...outgoing, updatedAt: outgoing.createdAt, env: "test" },
73
+ { ...incoming, updatedAt: incoming.createdAt, env: "test" },
71
74
  ]);
72
75
 
73
76
  const outgoingCount = await countCallsByPhoneInRange(
@@ -86,9 +89,9 @@ describe('callStats.utils', () => {
86
89
  });
87
90
  });
88
91
 
89
- describe('date helpers', () => {
90
- it('startOfDay normalizes to midnight', () => {
91
- const d = new Date('2023-03-10T15:30:45.000Z');
92
+ describe("date helpers", () => {
93
+ it("startOfDay normalizes to midnight", () => {
94
+ const d = new Date("2023-03-10T15:30:45.000Z");
92
95
  const s = startOfDay(d);
93
96
  expect(s.getUTCHours()).toBe(0);
94
97
  expect(s.getUTCMinutes()).toBe(0);
@@ -96,19 +99,16 @@ describe('callStats.utils', () => {
96
99
  expect(s.getUTCMilliseconds()).toBe(0);
97
100
  });
98
101
 
99
- it('addDays shifts the date by given days', () => {
100
- const d = new Date('2023-03-10T00:00:00.000Z');
102
+ it("addDays shifts the date by given days", () => {
103
+ const d = new Date("2023-03-10T00:00:00.000Z");
101
104
  expect(addDays(d, 1).getUTCDate()).toBe(11);
102
105
  expect(addDays(d, -1).getUTCDate()).toBe(9);
103
106
  });
104
107
 
105
- it('range helpers produce expected bounds', () => {
106
- const base = new Date('2023-03-15T10:00:00.000Z');
108
+ it("range helpers produce expected bounds", () => {
109
+ const base = new Date("2023-03-15T10:00:00.000Z");
107
110
 
108
- const betweenRange = range.between(
109
- addDays(base, -1),
110
- addDays(base, 1),
111
- );
111
+ const betweenRange = range.between(addDays(base, -1), addDays(base, 1));
112
112
  expect(betweenRange.since).toEqual(addDays(base, -1));
113
113
  expect(betweenRange.until).toEqual(addDays(base, 1));
114
114
 
@@ -125,4 +125,4 @@ describe('callStats.utils', () => {
125
125
  expect(startToNowRange.until).toBeInstanceOf(Date);
126
126
  });
127
127
  });
128
- })
128
+ });
@@ -8,12 +8,12 @@ import {
8
8
  countCalls,
9
9
  getCallsByClientAndDateRange,
10
10
  getCallsCollection,
11
- } from '../calls.getters';
12
- import { ObjectId } from 'mongodb';
13
- import { createOutGoingCallDoc } from '../../../test-utils/factories';
11
+ } from "../calls.getters";
12
+ import { ObjectId } from "mongodb";
13
+ import { createOutGoingCallDoc } from "../../../test-utils/factories";
14
14
 
15
- describe('db.calls', () => {
16
- it('should return calls by flow', async () => {
15
+ describe("db.calls", () => {
16
+ it("should return calls by flow", async () => {
17
17
  const flowId = new ObjectId();
18
18
  const call1 = createOutGoingCallDoc({ flowId });
19
19
  const call2 = createOutGoingCallDoc({ flowId });
@@ -26,11 +26,11 @@ describe('db.calls', () => {
26
26
  expect(result.length).toBe(2);
27
27
  expect(result).toMatchObject([
28
28
  { callSid: call1.callSid },
29
- { callSid: call2.callSid }
29
+ { callSid: call2.callSid },
30
30
  ]);
31
31
  });
32
32
 
33
- it('should get call by callSid', async () => {
33
+ it("should get call by callSid", async () => {
34
34
  const call = createOutGoingCallDoc();
35
35
  await createCallDoc(call);
36
36
 
@@ -40,39 +40,54 @@ describe('db.calls', () => {
40
40
  expect(result?.callSid).toBe(call.callSid);
41
41
  });
42
42
 
43
- it('should get calls by client', async () => {
43
+ it("should get calls by client", async () => {
44
44
  const call = createOutGoingCallDoc();
45
45
  await createCallDoc(call);
46
46
 
47
47
  const result = await getCallsByClient(call.clientId);
48
48
 
49
- expect(result.some(c => c.callSid === call.callSid)).toBe(true);
49
+ expect(result.some((c) => c.callSid === call.callSid)).toBe(true);
50
50
  });
51
51
 
52
- it('should get calls by phone number', async () => {
52
+ it("should get calls by phone number", async () => {
53
53
  const call = createOutGoingCallDoc();
54
54
  await createCallDoc(call);
55
55
 
56
56
  const result = await getCallsByPhoneNumber(call.customerPhoneNumber);
57
57
 
58
- expect(result.some(c => c.callSid === call.callSid)).toBe(true);
58
+ expect(result.some((c) => c.callSid === call.callSid)).toBe(true);
59
59
  });
60
60
 
61
- describe('findCallsByQuery()', () => {
62
- it('should find calls by status with limit and sort', async () => {
63
- const clientId = 'client123';
64
- const call1 = createOutGoingCallDoc({ clientId, status: 'completed' });
65
- const call2 = createOutGoingCallDoc({ clientId, status: 'completed' });
66
- const call3 = createOutGoingCallDoc({ clientId, status: 'busy' });
61
+ describe("findCallsByQuery()", () => {
62
+ it("should find calls by status with limit and sort", async () => {
63
+ const clientId = "client123";
64
+ const call1 = createOutGoingCallDoc({ clientId, status: "completed" });
65
+ const call2 = createOutGoingCallDoc({ clientId, status: "completed" });
66
+ const call3 = createOutGoingCallDoc({ clientId, status: "busy" });
67
67
 
68
68
  // We need to control createdAt to test sort. We'll insert directly.
69
- await getCallsCollection().insertOne({ ...call1, createdAt: new Date('2023-01-01'), updatedAt: new Date(), env: 'test' });
70
- await getCallsCollection().insertOne({ ...call2, createdAt: new Date('2023-01-02'), updatedAt: new Date(), env: 'test' });
71
- await getCallsCollection().insertOne({ ...call3, createdAt: new Date(), updatedAt: new Date(), env: 'test' });
69
+ await getCallsCollection().insertOne({
70
+ ...call1,
71
+ createdAt: new Date("2023-01-01"),
72
+ updatedAt: new Date(),
73
+ env: "test",
74
+ });
75
+ await getCallsCollection().insertOne({
76
+ ...call2,
77
+ createdAt: new Date("2023-01-02"),
78
+ updatedAt: new Date(),
79
+ env: "test",
80
+ });
81
+ await getCallsCollection().insertOne({
82
+ ...call3,
83
+ createdAt: new Date(),
84
+ updatedAt: new Date(),
85
+ env: "test",
86
+ });
72
87
 
73
88
  const result = await findCallsByQuery(
74
- { clientId, status: 'completed' },
75
- { sort: { createdAt: -1 }, limit: 1 }
89
+ { clientId, status: "completed" },
90
+ { sort: { createdAt: -1 }, limit: 1 },
76
91
  );
77
92
 
78
93
  expect(result.length).toBe(1);
@@ -80,33 +95,58 @@ describe('db.calls', () => {
80
95
  });
81
96
  });
82
97
 
83
- describe('countCalls()', () => {
84
- it('should count calls matching query', async () => {
85
- const clientId = 'countClient';
86
- await createCallDoc(createOutGoingCallDoc({ clientId, status: 'completed' }));
87
- await createCallDoc(createOutGoingCallDoc({ clientId, status: 'completed' }));
88
- await createCallDoc(createOutGoingCallDoc({ clientId, status: 'failed' }));
98
+ describe("countCalls()", () => {
99
+ it("should count calls matching query", async () => {
100
+ const clientId = "countClient";
101
+ await createCallDoc(
102
+ createOutGoingCallDoc({ clientId, status: "completed" }),
103
+ );
104
+ await createCallDoc(
105
+ createOutGoingCallDoc({ clientId, status: "completed" }),
106
+ );
107
+ await createCallDoc(
108
+ createOutGoingCallDoc({ clientId, status: "failed" }),
109
+ );
89
110
 
90
- const count = await countCalls({ clientId, status: 'completed' });
111
+ const count = await countCalls({ clientId, status: "completed" });
91
112
  expect(count).toBe(2);
92
113
  });
93
114
  });
94
115
 
95
- describe('getCallsByClientAndDateRange()', () => {
96
- it('should return calls within date range', async () => {
97
- const clientId = 'dateRangeClient';
98
- const startDate = new Date('2023-05-01');
99
- const endDate = new Date('2023-05-31');
116
+ describe("getCallsByClientAndDateRange()", () => {
117
+ it("should return calls within date range", async () => {
118
+ const clientId = "dateRangeClient";
119
+ const startDate = new Date("2023-05-01");
120
+ const endDate = new Date("2023-05-31");
100
121
 
101
122
  const callInside = createOutGoingCallDoc({ clientId });
102
123
  const callBefore = createOutGoingCallDoc({ clientId });
103
124
  const callAfter = createOutGoingCallDoc({ clientId });
104
125
 
105
- await getCallsCollection().insertOne({ ...callInside, createdAt: new Date('2023-05-15'), updatedAt: new Date(), env: 'test' });
106
- await getCallsCollection().insertOne({ ...callBefore, createdAt: new Date('2023-04-30'), updatedAt: new Date(), env: 'test' });
107
- await getCallsCollection().insertOne({ ...callAfter, createdAt: new Date('2023-06-01'), updatedAt: new Date(), env: 'test' });
108
-
109
- const result = await getCallsByClientAndDateRange(clientId, startDate, endDate);
126
+ await getCallsCollection().insertOne({
127
+ ...callInside,
128
+ createdAt: new Date("2023-05-15"),
129
+ updatedAt: new Date(),
130
+ env: "test",
131
+ });
132
+ await getCallsCollection().insertOne({
133
+ ...callBefore,
134
+ createdAt: new Date("2023-04-30"),
135
+ updatedAt: new Date(),
136
+ env: "test",
137
+ });
138
+ await getCallsCollection().insertOne({
139
+ ...callAfter,
140
+ createdAt: new Date("2023-06-01"),
141
+ updatedAt: new Date(),
142
+ env: "test",
143
+ });
144
+
145
+ const result = await getCallsByClientAndDateRange(
146
+ clientId,
147
+ startDate,
148
+ endDate,
149
+ );
110
150
  expect(result.length).toBe(1);
111
151
  expect(result[0].callSid).toBe(callInside.callSid);
112
152
  });