@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,11 +1,17 @@
1
- import { getDb, Call, CallDoc, CallUpdateParams, CallQueryOptions } from '../index';
2
- import type { CallsByHour, CountOpts, DateRange } from './calls.types';
3
- import { ObjectId, Filter } from 'mongodb';
4
- import * as process from 'node:process';
5
- import { applyQueryOptions } from '../utils/query.utils';
1
+ import {
2
+ Call,
3
+ CallDoc,
4
+ CallQueryOptions,
5
+ CallUpdateParams,
6
+ getDb,
7
+ } from "../index";
8
+ import type { CallsByHour, CountOpts, DateRange } from "./calls.types";
9
+ import { Filter, ObjectId } from "mongodb";
10
+ import * as process from "node:process";
11
+ import { applyQueryOptions } from "../utils/query.utils";
6
12
 
7
13
  export const getCallsCollection = () => {
8
- return getDb().collection<Call>('calls');
14
+ return getDb().collection<Call>("calls");
9
15
  };
10
16
 
11
17
  export const getCallByCallSid = (callSid: string) => {
@@ -13,7 +19,9 @@ export const getCallByCallSid = (callSid: string) => {
13
19
  };
14
20
 
15
21
  export const getCallsByPhoneNumber = (phoneNumber: string) => {
16
- return getCallsCollection().find({ customerPhoneNumber: phoneNumber }).toArray();
22
+ return getCallsCollection()
23
+ .find({ customerPhoneNumber: phoneNumber })
24
+ .toArray();
17
25
  };
18
26
 
19
27
  export const getCallsByClient = (clientId: string) => {
@@ -24,20 +32,22 @@ export const getCallsByFlow = (flowId: ObjectId) => {
24
32
  return getCallsCollection().find({ flowId }).toArray();
25
33
  };
26
34
 
27
- export const createCallDoc = (call: Omit<Call, 'createdAt' | 'updatedAt' | 'env'>) => {
35
+ export const createCallDoc = (
36
+ call: Omit<Call, "createdAt" | "updatedAt" | "env">,
37
+ ) => {
28
38
  return getCallsCollection().insertOne({
29
39
  ...call,
30
40
  createdAt: new Date(),
31
41
  updatedAt: new Date(),
32
- env: process.env.ENV ?? 'unknown',
42
+ env: process.env.ENV ?? "unknown",
33
43
  });
34
44
  };
35
45
 
36
46
  export const updateCallByCallSid = async (
37
47
  callSid: string,
38
- updates: CallUpdateParams
48
+ updates: CallUpdateParams,
39
49
  ): Promise<CallDoc | null> => {
40
- const result = await getCallsCollection().findOneAndUpdate(
50
+ return await getCallsCollection().findOneAndUpdate(
41
51
  { callSid: callSid },
42
52
  {
43
53
  $set: {
@@ -45,15 +55,17 @@ export const updateCallByCallSid = async (
45
55
  updatedAt: new Date(),
46
56
  },
47
57
  },
48
- { returnDocument: 'after' }
58
+ { returnDocument: "after" },
49
59
  );
50
-
51
- return result;
52
60
  };
53
61
 
54
62
  // get calls by client and date range
55
63
  //client here is the user id
56
- export const getCallsByClientAndDateRange = (clientId: string, startDate: Date, endDate: Date) => {
64
+ export const getCallsByClientAndDateRange = (
65
+ clientId: string,
66
+ startDate: Date,
67
+ endDate: Date,
68
+ ) => {
57
69
  return getCallsCollection()
58
70
  .find({
59
71
  clientId,
@@ -67,7 +79,7 @@ export const getCallsByClientAndDateRange = (clientId: string, startDate: Date,
67
79
 
68
80
  export const findCallsByQuery = async (
69
81
  query: Filter<Call>,
70
- options?: CallQueryOptions
82
+ options?: CallQueryOptions,
71
83
  ): Promise<CallDoc[]> => {
72
84
  const cursor = getCallsCollection().find(query);
73
85
  return await applyQueryOptions(cursor, options).toArray();
@@ -124,7 +136,7 @@ export const range = {
124
136
 
125
137
  export function startOfDay(d: Date = new Date()): Date {
126
138
  const x = new Date(d);
127
- x.setHours(0, 0, 0, 0);
139
+ x.setUTCHours(0, 0, 0, 0);
128
140
  return x;
129
141
  }
130
142
 
@@ -142,21 +154,29 @@ export async function getCallsStatsForDateRange(
142
154
  clientId: string,
143
155
  startStr: string,
144
156
  endStr: string,
145
- timezone: string
157
+ timezone: string,
146
158
  ): Promise<{ count: number; totalLen: number; completed: number }> {
147
159
  const coll = getCallsCollection();
148
160
  const out = await coll
149
- .aggregate<{ _id: null; count: number; totalLen: number; completed: number }>([
161
+ .aggregate<{
162
+ _id: null;
163
+ count: number;
164
+ totalLen: number;
165
+ completed: number;
166
+ }>([
150
167
  // 1. Restrict to the given client
151
168
  { $match: { clientId } },
152
169
  // 2. Derive dateLocal (createdAt as YYYY-MM-DD in timezone) and isCompleted (agentHungUp or status='completed')
153
170
  {
154
171
  $addFields: {
155
172
  dateLocal: {
156
- $dateToString: { format: '%Y-%m-%d', date: '$createdAt', timezone },
173
+ $dateToString: { format: "%Y-%m-%d", date: "$createdAt", timezone },
157
174
  },
158
175
  isCompleted: {
159
- $or: [{ $eq: ['$agentHungUp', true] }, { $eq: ['$status', 'completed'] }],
176
+ $or: [
177
+ { $eq: ["$agentHungUp", true] },
178
+ { $eq: ["$status", "completed"] },
179
+ ],
160
180
  },
161
181
  },
162
182
  },
@@ -167,8 +187,8 @@ export async function getCallsStatsForDateRange(
167
187
  $group: {
168
188
  _id: null,
169
189
  count: { $sum: 1 },
170
- totalLen: { $sum: '$callLength' },
171
- completed: { $sum: { $cond: ['$isCompleted', 1, 0] } },
190
+ totalLen: { $sum: "$callLength" },
191
+ completed: { $sum: { $cond: ["$isCompleted", 1, 0] } },
172
192
  },
173
193
  },
174
194
  ])
@@ -186,7 +206,7 @@ export async function getCallsStatsForDateRange(
186
206
  export async function getCallsHourlyAggregation(
187
207
  clientId: string,
188
208
  dateStr: string,
189
- timezone: string
209
+ timezone: string,
190
210
  ): Promise<CallsByHour[]> {
191
211
  const coll = getCallsCollection();
192
212
  const rows = await coll
@@ -197,22 +217,22 @@ export async function getCallsHourlyAggregation(
197
217
  {
198
218
  $addFields: {
199
219
  dateLocal: {
200
- $dateToString: { format: '%Y-%m-%d', date: '$createdAt', timezone },
220
+ $dateToString: { format: "%Y-%m-%d", date: "$createdAt", timezone },
201
221
  },
202
- hour: { $hour: { date: '$createdAt', timezone } },
222
+ hour: { $hour: { date: "$createdAt", timezone } },
203
223
  },
204
224
  },
205
225
  // 3. Keep only the requested date
206
226
  { $match: { dateLocal: dateStr } },
207
227
  // 4. Group by hour, sum calls per hour
208
- { $group: { _id: '$hour', calls: { $sum: 1 } } },
228
+ { $group: { _id: "$hour", calls: { $sum: 1 } } },
209
229
  // 5. Order by hour ascending (0..23)
210
230
  { $sort: { _id: 1 } },
211
231
  ])
212
232
  .toArray();
213
233
 
214
234
  return rows.map((r: any) => ({
215
- hour: `${String(r._id).padStart(2, '0')}:00`,
235
+ hour: `${String(r._id).padStart(2, "0")}:00`,
216
236
  calls: r.calls,
217
237
  }));
218
238
  }
@@ -1,8 +1,8 @@
1
- import { ObjectId, Sort, WithId } from 'mongodb';
2
- import { TranscriptionSegment } from '../results/results.types';
1
+ import { ObjectId, Sort, WithId } from "mongodb";
2
+ import { TranscriptionSegment } from "../results";
3
3
 
4
- export const CONFERENCE_ROLE_CUSTOMER = 'customer' as const;
5
- export const CONFERENCE_ROLE_SUPERVISOR = 'supervisor' as const;
4
+ export const CONFERENCE_ROLE_CUSTOMER = "customer" as const;
5
+ export const CONFERENCE_ROLE_SUPERVISOR = "supervisor" as const;
6
6
 
7
7
  export type ConferenceRole =
8
8
  | typeof CONFERENCE_ROLE_CUSTOMER
@@ -62,18 +62,18 @@ export type CallsFilterParams = {
62
62
  };
63
63
 
64
64
  export type ImmutableCallFields =
65
- | 'customerPhoneNumber'
66
- | 'agentPhoneNumber'
67
- | 'isIncomingCall'
68
- | 'isOutgoingCall'
69
- | 'sessionId'
70
- | 'callSid'
71
- | 'flowId'
72
- | 'clientId'
73
- | 'runId'
74
- | 'resultId'
75
- | 'env'
76
- | 'createdAt';
65
+ | "customerPhoneNumber"
66
+ | "agentPhoneNumber"
67
+ | "isIncomingCall"
68
+ | "isOutgoingCall"
69
+ | "sessionId"
70
+ | "callSid"
71
+ | "flowId"
72
+ | "clientId"
73
+ | "runId"
74
+ | "resultId"
75
+ | "env"
76
+ | "createdAt";
77
77
 
78
78
  export type CallUpdateParams = Partial<Omit<Call, ImmutableCallFields>>;
79
79
 
@@ -1,2 +1,2 @@
1
- export * from './calls.types';
2
- export * from './calls.getters';
1
+ export * from "./calls.types";
2
+ export * from "./calls.getters";
@@ -4,46 +4,66 @@ import {
4
4
  findClientAudioBuffersByCallSidAndRange,
5
5
  getMergedAudioByCallSid,
6
6
  getAudioChunksByCallSid,
7
- } from '../clientAudioBuffer.getters';
8
- import { ObjectId } from '../../index';
9
- import { createAudioBufferInput } from '../../../test-utils/factories';
7
+ } from "../clientAudioBuffer.getters";
8
+ import { ObjectId } from "../../index";
9
+ import { createAudioBufferInput } from "../../../test-utils/factories";
10
10
 
11
- describe('clientAudioBuffers getters', () => {
11
+ describe("clientAudioBuffers getters", () => {
12
12
  it('should return the "clientAudioBuffers" collection', () => {
13
13
  const collection = getClientAudioBuffersCollection();
14
- expect(collection.collectionName).toBe('clientAudioBuffers');
14
+ expect(collection.collectionName).toBe("clientAudioBuffers");
15
15
  });
16
16
 
17
- it('should insert a client audio buffer and return insertedId', async () => {
17
+ it("should insert a client audio buffer and return insertedId", async () => {
18
18
  const inputToCheck = createAudioBufferInput();
19
19
  const result = await insertClientAudioBuffer(inputToCheck);
20
20
  expect(result.insertedId).toBeInstanceOf(ObjectId);
21
21
 
22
- const savedDoc = await getClientAudioBuffersCollection().findOne({ _id: result.insertedId });
22
+ const savedDoc = await getClientAudioBuffersCollection().findOne({
23
+ _id: result.insertedId,
24
+ });
23
25
  expect(savedDoc).toBeDefined();
24
26
  expect(savedDoc?.createdAt).toBeInstanceOf(Date);
25
27
  expect(savedDoc?.expiresAt).toBeInstanceOf(Date);
26
28
  });
27
29
 
28
- it('should return only buffers in the specified bucketStartMs range', async () => {
29
- const callSid = 'CA1234567890abcdef1234567890abcdef';
30
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 500 }));
31
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 1000 }));
32
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 3000 }));
33
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 6000 }));
30
+ it("should return only buffers in the specified bucketStartMs range", async () => {
31
+ const callSid = "CA1234567890abcdef1234567890abcdef";
32
+ await insertClientAudioBuffer(
33
+ createAudioBufferInput({ callSid, bucketStartMs: 500 }),
34
+ );
35
+ await insertClientAudioBuffer(
36
+ createAudioBufferInput({ callSid, bucketStartMs: 1000 }),
37
+ );
38
+ await insertClientAudioBuffer(
39
+ createAudioBufferInput({ callSid, bucketStartMs: 3000 }),
40
+ );
41
+ await insertClientAudioBuffer(
42
+ createAudioBufferInput({ callSid, bucketStartMs: 6000 }),
43
+ );
34
44
 
35
- const result = await findClientAudioBuffersByCallSidAndRange(callSid, 500, 3000);
45
+ const result = await findClientAudioBuffersByCallSidAndRange(
46
+ callSid,
47
+ 500,
48
+ 3000,
49
+ );
36
50
  expect(result).toHaveLength(3);
37
51
  const bucketStartValues = result.map((doc) => doc.bucketStartMs);
38
52
  const bucketStartsSorted = bucketStartValues.sort((a, b) => a - b);
39
53
  expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
40
54
  });
41
55
 
42
- it('should return all buffers when no range is provided', async () => {
43
- const callSid = 'CA1234567890abcdef1234567890abcdeg';
44
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 500 }));
45
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 1000 }));
46
- await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 3000 }));
56
+ it("should return all buffers when no range is provided", async () => {
57
+ const callSid = "CA1234567890abcdef1234567890abcdeg";
58
+ await insertClientAudioBuffer(
59
+ createAudioBufferInput({ callSid, bucketStartMs: 500 }),
60
+ );
61
+ await insertClientAudioBuffer(
62
+ createAudioBufferInput({ callSid, bucketStartMs: 1000 }),
63
+ );
64
+ await insertClientAudioBuffer(
65
+ createAudioBufferInput({ callSid, bucketStartMs: 3000 }),
66
+ );
47
67
 
48
68
  const result = await findClientAudioBuffersByCallSidAndRange(callSid);
49
69
  expect(result).toHaveLength(3);
@@ -52,21 +72,33 @@ describe('clientAudioBuffers getters', () => {
52
72
  expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
53
73
  });
54
74
 
55
- it('should merge audio buffers by callSid in chronological order', async () => {
56
- const callSid = 'CA1234567890abcdef1234567890abcdeh';
75
+ it("should merge audio buffers by callSid in chronological order", async () => {
76
+ const callSid = "CA1234567890abcdef1234567890abcdeh";
57
77
 
58
78
  const firstBuffer = Buffer.from([1, 2]);
59
79
  const secondBuffer = Buffer.from([3]);
60
80
  const thirdBuffer = Buffer.from([4, 5]);
61
81
 
62
82
  await insertClientAudioBuffer(
63
- createAudioBufferInput({ callSid, bucketStartMs: 1000, data: secondBuffer })
83
+ createAudioBufferInput({
84
+ callSid,
85
+ bucketStartMs: 1000,
86
+ data: secondBuffer,
87
+ }),
64
88
  );
65
89
  await insertClientAudioBuffer(
66
- createAudioBufferInput({ callSid, bucketStartMs: 500, data: firstBuffer })
90
+ createAudioBufferInput({
91
+ callSid,
92
+ bucketStartMs: 500,
93
+ data: firstBuffer,
94
+ }),
67
95
  );
68
96
  await insertClientAudioBuffer(
69
- createAudioBufferInput({ callSid, bucketStartMs: 3000, data: thirdBuffer })
97
+ createAudioBufferInput({
98
+ callSid,
99
+ bucketStartMs: 3000,
100
+ data: thirdBuffer,
101
+ }),
70
102
  );
71
103
 
72
104
  const merged = await getMergedAudioByCallSid(callSid, 10);
@@ -77,8 +109,8 @@ describe('clientAudioBuffers getters', () => {
77
109
  expect(merged.equals(expected)).toBe(true);
78
110
  });
79
111
 
80
- it('should return all audio chunks when less than or equal to limit buffers exist', async () => {
81
- const callSid = 'CA1234567890abcdef1234567890abclt';
112
+ it("should return all audio chunks when less than or equal to limit buffers exist", async () => {
113
+ const callSid = "CA1234567890abcdef1234567890abclt";
82
114
 
83
115
  const limit = 30;
84
116
  const buffers: Buffer[] = [];
@@ -86,11 +118,11 @@ describe('clientAudioBuffers getters', () => {
86
118
  const buf = Buffer.from([i]);
87
119
  buffers.push(buf);
88
120
  await insertClientAudioBuffer(
89
- createAudioBufferInput({
90
- callSid,
91
- bucketStartMs: 1000 + i * 1000,
92
- data: buf,
93
- })
121
+ createAudioBufferInput({
122
+ callSid,
123
+ bucketStartMs: 1000 + i * 1000,
124
+ data: buf,
125
+ }),
94
126
  );
95
127
  }
96
128
 
@@ -101,8 +133,8 @@ describe('clientAudioBuffers getters', () => {
101
133
  expect(Buffer.concat(chunks).equals(Buffer.concat(buffers))).toBe(true);
102
134
  });
103
135
 
104
- it('should return only the last N audio chunks when more than limit buffers exist', async () => {
105
- const callSid = 'CA1234567890abcdef1234567890abclm';
136
+ it("should return only the last N audio chunks when more than limit buffers exist", async () => {
137
+ const callSid = "CA1234567890abcdef1234567890abclm";
106
138
 
107
139
  const limit = 30;
108
140
  const buffers: Buffer[] = [];
@@ -110,17 +142,19 @@ describe('clientAudioBuffers getters', () => {
110
142
  const buf = Buffer.from([i]);
111
143
  buffers.push(buf);
112
144
  await insertClientAudioBuffer(
113
- createAudioBufferInput({
114
- callSid,
115
- bucketStartMs: 1000 + i * 1000,
116
- data: buf,
117
- })
145
+ createAudioBufferInput({
146
+ callSid,
147
+ bucketStartMs: 1000 + i * 1000,
148
+ data: buf,
149
+ }),
118
150
  );
119
151
  }
120
152
 
121
153
  const chunks = await getAudioChunksByCallSid(callSid, limit);
122
154
  const expectedBuffers = buffers.slice(-limit);
123
155
  expect(chunks).toHaveLength(expectedBuffers.length);
124
- expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(true);
156
+ expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(
157
+ true,
158
+ );
125
159
  });
126
160
  });
@@ -1,17 +1,18 @@
1
- import { getDb } from '../index';
1
+ import { getDb } from "../index";
2
2
  import {
3
3
  ClientAudioBufferDoc,
4
4
  ClientAudioBufferType,
5
5
  CreateAudioBufferInput,
6
- } from './clientsAudioBuffers.types';
7
- import { Collection, InsertOneResult } from 'mongodb';
6
+ } from "./clientsAudioBuffers.types";
7
+ import { Collection, InsertOneResult } from "mongodb";
8
8
 
9
- const getClientAudioBuffersCollection = (): Collection<ClientAudioBufferType> => {
10
- return getDb().collection<ClientAudioBufferType>('clientAudioBuffers');
11
- };
9
+ const getClientAudioBuffersCollection =
10
+ (): Collection<ClientAudioBufferType> => {
11
+ return getDb().collection<ClientAudioBufferType>("clientAudioBuffers");
12
+ };
12
13
 
13
14
  const insertClientAudioBuffer = async (
14
- audioBufferInput: CreateAudioBufferInput
15
+ audioBufferInput: CreateAudioBufferInput,
15
16
  ): Promise<InsertOneResult<ClientAudioBufferType>> => {
16
17
  const collection = getClientAudioBuffersCollection();
17
18
  const realtimeDate = new Date();
@@ -27,7 +28,7 @@ const insertClientAudioBuffer = async (
27
28
  };
28
29
  const clientAudioBufferMongoDocument: ClientAudioBufferType = {
29
30
  ...inputFieldsForDocument,
30
- codec: 'mulaw',
31
+ codec: "mulaw",
31
32
  sampleRateHz: 8000,
32
33
  channels: 1,
33
34
  createdAt: realtimeDate,
@@ -39,7 +40,7 @@ const insertClientAudioBuffer = async (
39
40
  const findClientAudioBuffersByCallSidAndRange = async (
40
41
  callSid: string,
41
42
  startMs?: number,
42
- endMs?: number
43
+ endMs?: number,
43
44
  ): Promise<ClientAudioBufferDoc[]> => {
44
45
  const collection = getClientAudioBuffersCollection();
45
46
  if (startMs === undefined) {
@@ -57,7 +58,10 @@ const findClientAudioBuffersByCallSidAndRange = async (
57
58
  .toArray();
58
59
  };
59
60
 
60
- const getAudioChunksByCallSid = async (callSid: string, limit?: number): Promise<Buffer[]> => {
61
+ const getAudioChunksByCallSid = async (
62
+ callSid: string,
63
+ limit?: number,
64
+ ): Promise<Buffer[]> => {
61
65
  const query = getClientAudioBuffersCollection().find({ callSid });
62
66
  if (limit) {
63
67
  query.sort({ bucketStartMs: -1 }).limit(limit);
@@ -80,7 +84,10 @@ const getAudioChunksByCallSid = async (callSid: string, limit?: number): Promise
80
84
  });
81
85
  };
82
86
 
83
- const getMergedAudioByCallSid = async (callSid: string, limit: number): Promise<Buffer> => {
87
+ const getMergedAudioByCallSid = async (
88
+ callSid: string,
89
+ limit: number,
90
+ ): Promise<Buffer> => {
84
91
  const buffers = await getAudioChunksByCallSid(callSid, limit);
85
92
 
86
93
  if (!buffers.length) {
@@ -1,11 +1,11 @@
1
- import { WithId } from 'mongodb';
1
+ import { WithId } from "mongodb";
2
2
 
3
3
  export type ClientAudioBufferType = {
4
4
  callSid: string;
5
5
  clientId: string;
6
6
  bucketStartMs: number;
7
7
  bucketDurationMs: number;
8
- codec: 'mulaw';
8
+ codec: "mulaw";
9
9
  sampleRateHz: 8000;
10
10
  channels: 1;
11
11
  data: Buffer;
@@ -1,2 +1,2 @@
1
- export * from './clientAudioBuffer.getters';
2
- export * from './clientsAudioBuffers.types';
1
+ export * from "./clientAudioBuffer.getters";
2
+ export * from "./clientsAudioBuffers.types";
@@ -1,11 +1,16 @@
1
- import { getDb, Client } from '../index';
2
- import { Collection } from 'mongodb';
1
+ import { getDb, Client } from "../index";
2
+ import { Collection } from "mongodb";
3
3
 
4
4
  export const getClientsCollection = (): Collection<Client> => {
5
- return getDb().collection<Client>('clients');
5
+ return getDb().collection<Client>("clients");
6
6
  };
7
7
 
8
- export const getClientByAPIKey = async (apiKey: string): Promise<Client | null> => {
9
- const client = await getClientsCollection().findOne({ apiKey, isActive: true });
8
+ export const getClientByAPIKey = async (
9
+ apiKey: string,
10
+ ): Promise<Client | null> => {
11
+ const client = await getClientsCollection().findOne({
12
+ apiKey,
13
+ isActive: true,
14
+ });
10
15
  return client ? client : null;
11
16
  };
@@ -1,4 +1,4 @@
1
- import { ObjectId } from 'mongodb';
1
+ import { ObjectId } from "mongodb";
2
2
 
3
3
  export type Client = {
4
4
  _id?: ObjectId;
@@ -1,2 +1,2 @@
1
- export * from './clients.getters';
2
- export * from './clients.types';
1
+ export * from "./clients.getters";
2
+ export * from "./clients.types";
@@ -1,13 +1,16 @@
1
- import { createClientConfigDoc, getClientConfig } from '../clientsConfig.getters';
2
- import { createClientConfig } from '../../../test-utils/factories';
1
+ import {
2
+ createClientConfigDoc,
3
+ getClientConfig,
4
+ } from "../clientsConfig.getters";
5
+ import { createClientConfig } from "../../../test-utils/factories";
3
6
 
4
- describe('db.clientsConfig', () => {
5
- describe('getClientConfig', () => {
6
- it('should return client config by clientId', async () => {
7
- const clientId = 'test-client-id';
7
+ describe("db.clientsConfig", () => {
8
+ describe("getClientConfig", () => {
9
+ it("should return client config by clientId", async () => {
10
+ const clientId = "test-client-id";
8
11
  const clientConfig = createClientConfig({
9
12
  clientId,
10
- language: 'Hebrew',
13
+ language: "Hebrew",
11
14
  products: { feature1: true, feature2: false } as any,
12
15
  });
13
16
 
@@ -17,25 +20,25 @@ describe('db.clientsConfig', () => {
17
20
 
18
21
  expect(result).toMatchObject({
19
22
  clientId,
20
- language: 'Hebrew',
23
+ language: "Hebrew",
21
24
  products: { feature1: true, feature2: false },
22
25
  });
23
26
  });
24
27
 
25
- it('should return null for non-existent clientId', async () => {
26
- const result = await getClientConfig('non-existent-client');
28
+ it("should return null for non-existent clientId", async () => {
29
+ const result = await getClientConfig("non-existent-client");
27
30
  expect(result).toBeNull();
28
31
  });
29
32
 
30
- it('should support communications config', async () => {
31
- const clientId = 'communications-test';
33
+ it("should support communications config", async () => {
34
+ const clientId = "communications-test";
32
35
  const clientConfig = createClientConfig({
33
36
  clientId,
34
37
  communications: {
35
38
  sendGrid: {
36
- emailTo: ['test@example.com'],
37
- templateId: 'temp-123',
38
- senderId: 'sender-123',
39
+ emailTo: ["test@example.com"],
40
+ templateId: "temp-123",
41
+ senderId: "sender-123",
39
42
  },
40
43
  sms: {},
41
44
  whatsapp: {},
@@ -50,9 +53,9 @@ describe('db.clientsConfig', () => {
50
53
  clientId,
51
54
  communications: {
52
55
  sendGrid: {
53
- emailTo: ['test@example.com'],
54
- templateId: 'temp-123',
55
- senderId: 'sender-123',
56
+ emailTo: ["test@example.com"],
57
+ templateId: "temp-123",
58
+ senderId: "sender-123",
56
59
  },
57
60
  sms: {},
58
61
  whatsapp: {},
@@ -1,8 +1,8 @@
1
- import { ClientConfigDoc, getDb, findClientByPhoneNumber } from '../index';
2
- import { Collection } from 'mongodb';
1
+ import { ClientConfigDoc, getDb, findClientByPhoneNumber } from "../index";
2
+ import { Collection } from "mongodb";
3
3
 
4
4
  export const getClientsConfigCollection = (): Collection<ClientConfigDoc> => {
5
- return getDb().collection<ClientConfigDoc>('clientsConfig');
5
+ return getDb().collection<ClientConfigDoc>("clientsConfig");
6
6
  };
7
7
 
8
8
  export const getClientConfig = (clientId: string) => {
@@ -15,6 +15,8 @@ export const getClientConfigByPhone = async (phone: string) => {
15
15
  return getClientConfig(client.clientId);
16
16
  };
17
17
 
18
- export const createClientConfigDoc = async (clientConfig: ClientConfigDoc): Promise<void> => {
18
+ export const createClientConfigDoc = async (
19
+ clientConfig: ClientConfigDoc,
20
+ ): Promise<void> => {
19
21
  await getClientsConfigCollection().insertOne(clientConfig);
20
22
  };