@talkpilot/core-db 1.1.6 → 1.1.8

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