@talkpilot/core-db 1.1.7 → 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 (330) 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 +7 -7
  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.js +9 -8
  125. package/dist/talkpilot/mongodb-client.js.map +1 -1
  126. package/dist/talkpilot/phone_numbers/index.d.ts +2 -2
  127. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +3 -3
  128. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
  129. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +13 -28
  130. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
  131. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +9 -9
  132. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +1 -1
  133. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -1
  134. package/dist/talkpilot/plans/index.d.ts +2 -2
  135. package/dist/talkpilot/plans/plans.getters.d.ts +2 -2
  136. package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -1
  137. package/dist/talkpilot/plans/plans.getters.js +3 -3
  138. package/dist/talkpilot/plans/plans.getters.js.map +1 -1
  139. package/dist/talkpilot/plans/plans.types.d.ts +4 -4
  140. package/dist/talkpilot/plans/plans.types.d.ts.map +1 -1
  141. package/dist/talkpilot/plans/plans.types.js +19 -19
  142. package/dist/talkpilot/results/index.d.ts +2 -2
  143. package/dist/talkpilot/results/index.d.ts.map +1 -1
  144. package/dist/talkpilot/results/index.js.map +1 -1
  145. package/dist/talkpilot/results/results.getter.d.ts +3 -3
  146. package/dist/talkpilot/results/results.getter.d.ts.map +1 -1
  147. package/dist/talkpilot/results/results.getter.js +4 -4
  148. package/dist/talkpilot/results/results.getter.js.map +1 -1
  149. package/dist/talkpilot/results/results.schema.js +18 -18
  150. package/dist/talkpilot/results/results.types.d.ts +1 -1
  151. package/dist/talkpilot/sessions/index.d.ts +2 -2
  152. package/dist/talkpilot/sessions/sessions.getter.d.ts +3 -3
  153. package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -1
  154. package/dist/talkpilot/sessions/sessions.getter.js +10 -13
  155. package/dist/talkpilot/sessions/sessions.getter.js.map +1 -1
  156. package/dist/talkpilot/sessions/sessions.schema.js +17 -17
  157. package/dist/talkpilot/sessions/sessions.types.d.ts +2 -2
  158. package/dist/talkpilot/subscriptions/index.d.ts +3 -3
  159. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +2 -2
  160. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -1
  161. package/dist/talkpilot/subscriptions/subscriptions.getters.js +11 -11
  162. package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -1
  163. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +2 -2
  164. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -1
  165. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -1
  166. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +2 -2
  167. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -1
  168. package/dist/talkpilot/subscriptions/subscriptions.types.js +7 -7
  169. package/dist/talkpilot/utils/query.utils.d.ts +1 -1
  170. package/dist/test-utils/db-utils.d.ts +1 -1
  171. package/dist/test-utils/db-utils.js +2 -2
  172. package/dist/test-utils/factories/index.d.ts +12 -12
  173. package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
  174. package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
  175. package/dist/test-utils/factories/municipal/cities.js +1 -1
  176. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
  177. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
  178. package/dist/test-utils/factories/municipal/departmentsSubjects.js +1 -7
  179. package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
  180. package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
  181. package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
  182. package/dist/test-utils/factories/municipal/streets.js +1 -6
  183. package/dist/test-utils/factories/municipal/streets.js.map +1 -1
  184. package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
  185. package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
  186. package/dist/test-utils/factories/municipal/tickets.js +1 -7
  187. package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
  188. package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
  189. package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
  190. package/dist/test-utils/factories/talkpilot/agents.js +4 -4
  191. package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
  192. package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
  193. package/dist/test-utils/factories/talkpilot/calls.js +1 -1
  194. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
  195. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
  196. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
  197. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
  198. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
  199. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
  200. package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
  201. package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
  202. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
  203. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
  204. package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
  205. package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
  206. package/dist/test-utils/factories/talkpilot/groups.js +9 -9
  207. package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
  208. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
  209. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
  210. package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
  211. package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
  212. package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
  213. package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
  214. package/dist/utils/validation.js +2 -2
  215. package/dist/utils/validation.js.map +1 -1
  216. package/package.json +1 -3
  217. package/src/__tests__/setup.ts +3 -3
  218. package/src/connection.ts +25 -27
  219. package/src/index.ts +9 -9
  220. package/src/municipal/__tests__/validation.spec.ts +23 -35
  221. package/src/municipal/cities/cities.getters.ts +10 -16
  222. package/src/municipal/cities/cities.types.ts +1 -1
  223. package/src/municipal/cities/index.ts +2 -2
  224. package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +44 -53
  225. package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
  226. package/src/municipal/departmentsSubjects/index.ts +3 -2
  227. package/src/municipal/index.ts +10 -10
  228. package/src/municipal/mongodb-client.ts +10 -13
  229. package/src/municipal/streets/index.ts +2 -2
  230. package/src/municipal/streets/streets.getters.ts +23 -43
  231. package/src/municipal/streets/streets.types.ts +1 -1
  232. package/src/municipal/systemInstructions/__tests__/getters.spec.ts +52 -67
  233. package/src/municipal/systemInstructions/__tests__/setters.spec.ts +238 -271
  234. package/src/municipal/systemInstructions/index.ts +3 -7
  235. package/src/municipal/systemInstructions/instructions.getters.ts +18 -30
  236. package/src/municipal/systemInstructions/instructions.setters.ts +19 -43
  237. package/src/municipal/systemInstructions/instructions.types.ts +10 -10
  238. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
  239. package/src/municipal/tickets/index.ts +2 -2
  240. package/src/municipal/tickets/tickets.getters.ts +42 -69
  241. package/src/municipal/tickets/tickets.types.ts +2 -2
  242. package/src/municipal/utils/types.ts +3 -8
  243. package/src/talkpilot/__tests__/db.spec.ts +12 -12
  244. package/src/talkpilot/__tests__/mongodb-client.spec.ts +8 -7
  245. package/src/talkpilot/__tests__/validation.spec.ts +24 -30
  246. package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
  247. package/src/talkpilot/agents/agents.getters.ts +3 -3
  248. package/src/talkpilot/agents/agents.types.ts +2 -2
  249. package/src/talkpilot/agents/index.ts +2 -2
  250. package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +31 -42
  251. package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
  252. package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +3 -2
  253. package/src/talkpilot/backgroundToolResults/index.ts +2 -2
  254. package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
  255. package/src/talkpilot/calls/__tests__/calls.spec.ts +39 -79
  256. package/src/talkpilot/calls/calls.getters.ts +28 -48
  257. package/src/talkpilot/calls/calls.types.ts +16 -16
  258. package/src/talkpilot/calls/index.ts +2 -2
  259. package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +39 -73
  260. package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +11 -18
  261. package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
  262. package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
  263. package/src/talkpilot/clients/clients.getters.ts +5 -10
  264. package/src/talkpilot/clients/clients.types.ts +1 -1
  265. package/src/talkpilot/clients/index.ts +2 -2
  266. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +18 -21
  267. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +4 -6
  268. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +8 -10
  269. package/src/talkpilot/clientsConfig/index.ts +2 -2
  270. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +37 -38
  271. package/src/talkpilot/flows/flows.getter.ts +5 -8
  272. package/src/talkpilot/flows/flows.schema.ts +80 -87
  273. package/src/talkpilot/flows/flows.types.ts +24 -23
  274. package/src/talkpilot/flows/index.ts +2 -2
  275. package/src/talkpilot/groups/__tests__/groups.spec.ts +27 -34
  276. package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
  277. package/src/talkpilot/groups/groups.getters.ts +5 -8
  278. package/src/talkpilot/groups/groups.types.ts +1 -1
  279. package/src/talkpilot/groups/index.ts +3 -3
  280. package/src/talkpilot/groups/phone.utils.ts +6 -12
  281. package/src/talkpilot/index.ts +17 -17
  282. package/src/talkpilot/leads/index.ts +2 -2
  283. package/src/talkpilot/leads/leads.getter.ts +4 -5
  284. package/src/talkpilot/leads/leads.schema.ts +16 -16
  285. package/src/talkpilot/leads/leads.types.ts +1 -1
  286. package/src/talkpilot/mongodb-client.ts +12 -12
  287. package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +44 -84
  288. package/src/talkpilot/phone_numbers/index.ts +2 -2
  289. package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +22 -44
  290. package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +9 -9
  291. package/src/talkpilot/phone_numbers/phone_numbers.types.ts +1 -1
  292. package/src/talkpilot/plans/__tests__/plans.spec.ts +26 -30
  293. package/src/talkpilot/plans/index.ts +2 -2
  294. package/src/talkpilot/plans/plans.getters.ts +18 -25
  295. package/src/talkpilot/plans/plans.types.ts +23 -27
  296. package/src/talkpilot/results/index.ts +2 -5
  297. package/src/talkpilot/results/results.getter.ts +8 -9
  298. package/src/talkpilot/results/results.schema.ts +18 -18
  299. package/src/talkpilot/results/results.types.ts +1 -1
  300. package/src/talkpilot/sessions/__tests__/sessions.spec.ts +41 -65
  301. package/src/talkpilot/sessions/index.ts +2 -2
  302. package/src/talkpilot/sessions/sessions.getter.ts +16 -21
  303. package/src/talkpilot/sessions/sessions.schema.ts +17 -17
  304. package/src/talkpilot/sessions/sessions.types.ts +2 -2
  305. package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +15 -18
  306. package/src/talkpilot/subscriptions/index.ts +3 -3
  307. package/src/talkpilot/subscriptions/subscriptions.getters.ts +33 -36
  308. package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +3 -10
  309. package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
  310. package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
  311. package/src/talkpilot/utils/query.utils.ts +2 -2
  312. package/src/test-utils/db-utils.ts +5 -5
  313. package/src/test-utils/factories/index.ts +12 -12
  314. package/src/test-utils/factories/municipal/cities.ts +5 -5
  315. package/src/test-utils/factories/municipal/departmentsSubjects.ts +25 -32
  316. package/src/test-utils/factories/municipal/streets.ts +5 -10
  317. package/src/test-utils/factories/municipal/tickets.ts +6 -12
  318. package/src/test-utils/factories/talkpilot/agents.ts +8 -8
  319. package/src/test-utils/factories/talkpilot/calls.ts +5 -5
  320. package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +12 -14
  321. package/src/test-utils/factories/talkpilot/clientsConfig.ts +8 -7
  322. package/src/test-utils/factories/talkpilot/flows.ts +5 -7
  323. package/src/test-utils/factories/talkpilot/groups.ts +13 -13
  324. package/src/test-utils/factories/talkpilot/phone_numbers.ts +6 -8
  325. package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
  326. package/src/utils/validation.ts +4 -4
  327. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +0 -4
  328. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +0 -1
  329. package/dist/talkpilot/subscriptions/subscriptions.utils.js +0 -20
  330. package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +0 -1
@@ -1,17 +1,11 @@
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";
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';
12
6
 
13
7
  export const getCallsCollection = () => {
14
- return getDb().collection<Call>("calls");
8
+ return getDb().collection<Call>('calls');
15
9
  };
16
10
 
17
11
  export const getCallByCallSid = (callSid: string) => {
@@ -19,9 +13,7 @@ export const getCallByCallSid = (callSid: string) => {
19
13
  };
20
14
 
21
15
  export const getCallsByPhoneNumber = (phoneNumber: string) => {
22
- return getCallsCollection()
23
- .find({ customerPhoneNumber: phoneNumber })
24
- .toArray();
16
+ return getCallsCollection().find({ customerPhoneNumber: phoneNumber }).toArray();
25
17
  };
26
18
 
27
19
  export const getCallsByClient = (clientId: string) => {
@@ -32,22 +24,20 @@ export const getCallsByFlow = (flowId: ObjectId) => {
32
24
  return getCallsCollection().find({ flowId }).toArray();
33
25
  };
34
26
 
35
- export const createCallDoc = (
36
- call: Omit<Call, "createdAt" | "updatedAt" | "env">,
37
- ) => {
27
+ export const createCallDoc = (call: Omit<Call, 'createdAt' | 'updatedAt' | 'env'>) => {
38
28
  return getCallsCollection().insertOne({
39
29
  ...call,
40
30
  createdAt: new Date(),
41
31
  updatedAt: new Date(),
42
- env: process.env.ENV ?? "unknown",
32
+ env: process.env.ENV ?? 'unknown',
43
33
  });
44
34
  };
45
35
 
46
36
  export const updateCallByCallSid = async (
47
37
  callSid: string,
48
- updates: CallUpdateParams,
38
+ updates: CallUpdateParams
49
39
  ): Promise<CallDoc | null> => {
50
- return await getCallsCollection().findOneAndUpdate(
40
+ const result = await getCallsCollection().findOneAndUpdate(
51
41
  { callSid: callSid },
52
42
  {
53
43
  $set: {
@@ -55,17 +45,15 @@ export const updateCallByCallSid = async (
55
45
  updatedAt: new Date(),
56
46
  },
57
47
  },
58
- { returnDocument: "after" },
48
+ { returnDocument: 'after' }
59
49
  );
50
+
51
+ return result;
60
52
  };
61
53
 
62
54
  // get calls by client and date range
63
55
  //client here is the user id
64
- export const getCallsByClientAndDateRange = (
65
- clientId: string,
66
- startDate: Date,
67
- endDate: Date,
68
- ) => {
56
+ export const getCallsByClientAndDateRange = (clientId: string, startDate: Date, endDate: Date) => {
69
57
  return getCallsCollection()
70
58
  .find({
71
59
  clientId,
@@ -79,7 +67,7 @@ export const getCallsByClientAndDateRange = (
79
67
 
80
68
  export const findCallsByQuery = async (
81
69
  query: Filter<Call>,
82
- options?: CallQueryOptions,
70
+ options?: CallQueryOptions
83
71
  ): Promise<CallDoc[]> => {
84
72
  const cursor = getCallsCollection().find(query);
85
73
  return await applyQueryOptions(cursor, options).toArray();
@@ -136,7 +124,7 @@ export const range = {
136
124
 
137
125
  export function startOfDay(d: Date = new Date()): Date {
138
126
  const x = new Date(d);
139
- x.setUTCHours(0, 0, 0, 0);
127
+ x.setHours(0, 0, 0, 0);
140
128
  return x;
141
129
  }
142
130
 
@@ -154,29 +142,21 @@ export async function getCallsStatsForDateRange(
154
142
  clientId: string,
155
143
  startStr: string,
156
144
  endStr: string,
157
- timezone: string,
145
+ timezone: string
158
146
  ): Promise<{ count: number; totalLen: number; completed: number }> {
159
147
  const coll = getCallsCollection();
160
148
  const out = await coll
161
- .aggregate<{
162
- _id: null;
163
- count: number;
164
- totalLen: number;
165
- completed: number;
166
- }>([
149
+ .aggregate<{ _id: null; count: number; totalLen: number; completed: number }>([
167
150
  // 1. Restrict to the given client
168
151
  { $match: { clientId } },
169
152
  // 2. Derive dateLocal (createdAt as YYYY-MM-DD in timezone) and isCompleted (agentHungUp or status='completed')
170
153
  {
171
154
  $addFields: {
172
155
  dateLocal: {
173
- $dateToString: { format: "%Y-%m-%d", date: "$createdAt", timezone },
156
+ $dateToString: { format: '%Y-%m-%d', date: '$createdAt', timezone },
174
157
  },
175
158
  isCompleted: {
176
- $or: [
177
- { $eq: ["$agentHungUp", true] },
178
- { $eq: ["$status", "completed"] },
179
- ],
159
+ $or: [{ $eq: ['$agentHungUp', true] }, { $eq: ['$status', 'completed'] }],
180
160
  },
181
161
  },
182
162
  },
@@ -187,8 +167,8 @@ export async function getCallsStatsForDateRange(
187
167
  $group: {
188
168
  _id: null,
189
169
  count: { $sum: 1 },
190
- totalLen: { $sum: "$callLength" },
191
- completed: { $sum: { $cond: ["$isCompleted", 1, 0] } },
170
+ totalLen: { $sum: '$callLength' },
171
+ completed: { $sum: { $cond: ['$isCompleted', 1, 0] } },
192
172
  },
193
173
  },
194
174
  ])
@@ -206,7 +186,7 @@ export async function getCallsStatsForDateRange(
206
186
  export async function getCallsHourlyAggregation(
207
187
  clientId: string,
208
188
  dateStr: string,
209
- timezone: string,
189
+ timezone: string
210
190
  ): Promise<CallsByHour[]> {
211
191
  const coll = getCallsCollection();
212
192
  const rows = await coll
@@ -217,22 +197,22 @@ export async function getCallsHourlyAggregation(
217
197
  {
218
198
  $addFields: {
219
199
  dateLocal: {
220
- $dateToString: { format: "%Y-%m-%d", date: "$createdAt", timezone },
200
+ $dateToString: { format: '%Y-%m-%d', date: '$createdAt', timezone },
221
201
  },
222
- hour: { $hour: { date: "$createdAt", timezone } },
202
+ hour: { $hour: { date: '$createdAt', timezone } },
223
203
  },
224
204
  },
225
205
  // 3. Keep only the requested date
226
206
  { $match: { dateLocal: dateStr } },
227
207
  // 4. Group by hour, sum calls per hour
228
- { $group: { _id: "$hour", calls: { $sum: 1 } } },
208
+ { $group: { _id: '$hour', calls: { $sum: 1 } } },
229
209
  // 5. Order by hour ascending (0..23)
230
210
  { $sort: { _id: 1 } },
231
211
  ])
232
212
  .toArray();
233
213
 
234
214
  return rows.map((r: any) => ({
235
- hour: `${String(r._id).padStart(2, "0")}:00`,
215
+ hour: `${String(r._id).padStart(2, '0')}:00`,
236
216
  calls: r.calls,
237
217
  }));
238
218
  }
@@ -1,8 +1,8 @@
1
- import { ObjectId, Sort, WithId } from "mongodb";
2
- import { TranscriptionSegment } from "../results";
1
+ import { ObjectId, Sort, WithId } from 'mongodb';
2
+ import { TranscriptionSegment } from '../results/results.types';
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,66 +4,46 @@ 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({
23
- _id: result.insertedId,
24
- });
22
+ const savedDoc = await getClientAudioBuffersCollection().findOne({ _id: result.insertedId });
25
23
  expect(savedDoc).toBeDefined();
26
24
  expect(savedDoc?.createdAt).toBeInstanceOf(Date);
27
25
  expect(savedDoc?.expiresAt).toBeInstanceOf(Date);
28
26
  });
29
27
 
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
- );
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 }));
44
34
 
45
- const result = await findClientAudioBuffersByCallSidAndRange(
46
- callSid,
47
- 500,
48
- 3000,
49
- );
35
+ const result = await findClientAudioBuffersByCallSidAndRange(callSid, 500, 3000);
50
36
  expect(result).toHaveLength(3);
51
37
  const bucketStartValues = result.map((doc) => doc.bucketStartMs);
52
38
  const bucketStartsSorted = bucketStartValues.sort((a, b) => a - b);
53
39
  expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
54
40
  });
55
41
 
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
- );
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 }));
67
47
 
68
48
  const result = await findClientAudioBuffersByCallSidAndRange(callSid);
69
49
  expect(result).toHaveLength(3);
@@ -72,33 +52,21 @@ describe("clientAudioBuffers getters", () => {
72
52
  expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
73
53
  });
74
54
 
75
- it("should merge audio buffers by callSid in chronological order", async () => {
76
- const callSid = "CA1234567890abcdef1234567890abcdeh";
55
+ it('should merge audio buffers by callSid in chronological order', async () => {
56
+ const callSid = 'CA1234567890abcdef1234567890abcdeh';
77
57
 
78
58
  const firstBuffer = Buffer.from([1, 2]);
79
59
  const secondBuffer = Buffer.from([3]);
80
60
  const thirdBuffer = Buffer.from([4, 5]);
81
61
 
82
62
  await insertClientAudioBuffer(
83
- createAudioBufferInput({
84
- callSid,
85
- bucketStartMs: 1000,
86
- data: secondBuffer,
87
- }),
63
+ createAudioBufferInput({ callSid, bucketStartMs: 1000, data: secondBuffer })
88
64
  );
89
65
  await insertClientAudioBuffer(
90
- createAudioBufferInput({
91
- callSid,
92
- bucketStartMs: 500,
93
- data: firstBuffer,
94
- }),
66
+ createAudioBufferInput({ callSid, bucketStartMs: 500, data: firstBuffer })
95
67
  );
96
68
  await insertClientAudioBuffer(
97
- createAudioBufferInput({
98
- callSid,
99
- bucketStartMs: 3000,
100
- data: thirdBuffer,
101
- }),
69
+ createAudioBufferInput({ callSid, bucketStartMs: 3000, data: thirdBuffer })
102
70
  );
103
71
 
104
72
  const merged = await getMergedAudioByCallSid(callSid, 10);
@@ -109,8 +77,8 @@ describe("clientAudioBuffers getters", () => {
109
77
  expect(merged.equals(expected)).toBe(true);
110
78
  });
111
79
 
112
- it("should return all audio chunks when less than or equal to limit buffers exist", async () => {
113
- const callSid = "CA1234567890abcdef1234567890abclt";
80
+ it('should return all audio chunks when less than or equal to limit buffers exist', async () => {
81
+ const callSid = 'CA1234567890abcdef1234567890abclt';
114
82
 
115
83
  const limit = 30;
116
84
  const buffers: Buffer[] = [];
@@ -118,11 +86,11 @@ describe("clientAudioBuffers getters", () => {
118
86
  const buf = Buffer.from([i]);
119
87
  buffers.push(buf);
120
88
  await insertClientAudioBuffer(
121
- createAudioBufferInput({
122
- callSid,
123
- bucketStartMs: 1000 + i * 1000,
124
- data: buf,
125
- }),
89
+ createAudioBufferInput({
90
+ callSid,
91
+ bucketStartMs: 1000 + i * 1000,
92
+ data: buf,
93
+ })
126
94
  );
127
95
  }
128
96
 
@@ -133,8 +101,8 @@ describe("clientAudioBuffers getters", () => {
133
101
  expect(Buffer.concat(chunks).equals(Buffer.concat(buffers))).toBe(true);
134
102
  });
135
103
 
136
- it("should return only the last N audio chunks when more than limit buffers exist", async () => {
137
- const callSid = "CA1234567890abcdef1234567890abclm";
104
+ it('should return only the last N audio chunks when more than limit buffers exist', async () => {
105
+ const callSid = 'CA1234567890abcdef1234567890abclm';
138
106
 
139
107
  const limit = 30;
140
108
  const buffers: Buffer[] = [];
@@ -142,19 +110,17 @@ describe("clientAudioBuffers getters", () => {
142
110
  const buf = Buffer.from([i]);
143
111
  buffers.push(buf);
144
112
  await insertClientAudioBuffer(
145
- createAudioBufferInput({
146
- callSid,
147
- bucketStartMs: 1000 + i * 1000,
148
- data: buf,
149
- }),
113
+ createAudioBufferInput({
114
+ callSid,
115
+ bucketStartMs: 1000 + i * 1000,
116
+ data: buf,
117
+ })
150
118
  );
151
119
  }
152
120
 
153
121
  const chunks = await getAudioChunksByCallSid(callSid, limit);
154
122
  const expectedBuffers = buffers.slice(-limit);
155
123
  expect(chunks).toHaveLength(expectedBuffers.length);
156
- expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(
157
- true,
158
- );
124
+ expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(true);
159
125
  });
160
126
  });
@@ -1,18 +1,17 @@
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 =
10
- (): Collection<ClientAudioBufferType> => {
11
- return getDb().collection<ClientAudioBufferType>("clientAudioBuffers");
12
- };
9
+ const getClientAudioBuffersCollection = (): Collection<ClientAudioBufferType> => {
10
+ return getDb().collection<ClientAudioBufferType>('clientAudioBuffers');
11
+ };
13
12
 
14
13
  const insertClientAudioBuffer = async (
15
- audioBufferInput: CreateAudioBufferInput,
14
+ audioBufferInput: CreateAudioBufferInput
16
15
  ): Promise<InsertOneResult<ClientAudioBufferType>> => {
17
16
  const collection = getClientAudioBuffersCollection();
18
17
  const realtimeDate = new Date();
@@ -28,7 +27,7 @@ const insertClientAudioBuffer = async (
28
27
  };
29
28
  const clientAudioBufferMongoDocument: ClientAudioBufferType = {
30
29
  ...inputFieldsForDocument,
31
- codec: "mulaw",
30
+ codec: 'mulaw',
32
31
  sampleRateHz: 8000,
33
32
  channels: 1,
34
33
  createdAt: realtimeDate,
@@ -40,7 +39,7 @@ const insertClientAudioBuffer = async (
40
39
  const findClientAudioBuffersByCallSidAndRange = async (
41
40
  callSid: string,
42
41
  startMs?: number,
43
- endMs?: number,
42
+ endMs?: number
44
43
  ): Promise<ClientAudioBufferDoc[]> => {
45
44
  const collection = getClientAudioBuffersCollection();
46
45
  if (startMs === undefined) {
@@ -58,10 +57,7 @@ const findClientAudioBuffersByCallSidAndRange = async (
58
57
  .toArray();
59
58
  };
60
59
 
61
- const getAudioChunksByCallSid = async (
62
- callSid: string,
63
- limit?: number,
64
- ): Promise<Buffer[]> => {
60
+ const getAudioChunksByCallSid = async (callSid: string, limit?: number): Promise<Buffer[]> => {
65
61
  const query = getClientAudioBuffersCollection().find({ callSid });
66
62
  if (limit) {
67
63
  query.sort({ bucketStartMs: -1 }).limit(limit);
@@ -84,10 +80,7 @@ const getAudioChunksByCallSid = async (
84
80
  });
85
81
  };
86
82
 
87
- const getMergedAudioByCallSid = async (
88
- callSid: string,
89
- limit: number,
90
- ): Promise<Buffer> => {
83
+ const getMergedAudioByCallSid = async (callSid: string, limit: number): Promise<Buffer> => {
91
84
  const buffers = await getAudioChunksByCallSid(callSid, limit);
92
85
 
93
86
  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,16 +1,11 @@
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 (
9
- apiKey: string,
10
- ): Promise<Client | null> => {
11
- const client = await getClientsCollection().findOne({
12
- apiKey,
13
- isActive: true,
14
- });
8
+ export const getClientByAPIKey = async (apiKey: string): Promise<Client | null> => {
9
+ const client = await getClientsCollection().findOne({ apiKey, isActive: true });
15
10
  return client ? client : null;
16
11
  };
@@ -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,16 +1,13 @@
1
- import {
2
- createClientConfigDoc,
3
- getClientConfig,
4
- } from "../clientsConfig.getters";
5
- import { createClientConfig } from "../../../test-utils/factories";
1
+ import { createClientConfigDoc, getClientConfig } from '../clientsConfig.getters';
2
+ import { createClientConfig } from '../../../test-utils/factories';
6
3
 
7
- describe("db.clientsConfig", () => {
8
- describe("getClientConfig", () => {
9
- it("should return client config by clientId", async () => {
10
- const clientId = "test-client-id";
4
+ describe('db.clientsConfig', () => {
5
+ describe('getClientConfig', () => {
6
+ it('should return client config by clientId', async () => {
7
+ const clientId = 'test-client-id';
11
8
  const clientConfig = createClientConfig({
12
9
  clientId,
13
- language: "Hebrew",
10
+ language: 'Hebrew',
14
11
  products: { feature1: true, feature2: false } as any,
15
12
  });
16
13
 
@@ -20,25 +17,25 @@ describe("db.clientsConfig", () => {
20
17
 
21
18
  expect(result).toMatchObject({
22
19
  clientId,
23
- language: "Hebrew",
20
+ language: 'Hebrew',
24
21
  products: { feature1: true, feature2: false },
25
22
  });
26
23
  });
27
24
 
28
- it("should return null for non-existent clientId", async () => {
29
- const result = await getClientConfig("non-existent-client");
25
+ it('should return null for non-existent clientId', async () => {
26
+ const result = await getClientConfig('non-existent-client');
30
27
  expect(result).toBeNull();
31
28
  });
32
29
 
33
- it("should support communications config", async () => {
34
- const clientId = "communications-test";
30
+ it('should support communications config', async () => {
31
+ const clientId = 'communications-test';
35
32
  const clientConfig = createClientConfig({
36
33
  clientId,
37
34
  communications: {
38
35
  sendGrid: {
39
- emailTo: ["test@example.com"],
40
- templateId: "temp-123",
41
- senderId: "sender-123",
36
+ emailTo: ['test@example.com'],
37
+ templateId: 'temp-123',
38
+ senderId: 'sender-123',
42
39
  },
43
40
  sms: {},
44
41
  whatsapp: {},
@@ -53,9 +50,9 @@ describe("db.clientsConfig", () => {
53
50
  clientId,
54
51
  communications: {
55
52
  sendGrid: {
56
- emailTo: ["test@example.com"],
57
- templateId: "temp-123",
58
- senderId: "sender-123",
53
+ emailTo: ['test@example.com'],
54
+ templateId: 'temp-123',
55
+ senderId: 'sender-123',
59
56
  },
60
57
  sms: {},
61
58
  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,8 +15,6 @@ export const getClientConfigByPhone = async (phone: string) => {
15
15
  return getClientConfig(client.clientId);
16
16
  };
17
17
 
18
- export const createClientConfigDoc = async (
19
- clientConfig: ClientConfigDoc,
20
- ): Promise<void> => {
18
+ export const createClientConfigDoc = async (clientConfig: ClientConfigDoc): Promise<void> => {
21
19
  await getClientsConfigCollection().insertOne(clientConfig);
22
20
  };