@talkpilot/core-db 1.1.8 → 1.1.10

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/README.md +7 -0
  2. package/dist/connection.d.ts +1 -1
  3. package/dist/connection.d.ts.map +1 -1
  4. package/dist/connection.js +21 -24
  5. package/dist/connection.js.map +1 -1
  6. package/dist/index.d.ts +9 -9
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/municipal/cities/cities.getters.d.ts +2 -2
  10. package/dist/municipal/cities/cities.getters.d.ts.map +1 -1
  11. package/dist/municipal/cities/cities.getters.js +8 -4
  12. package/dist/municipal/cities/cities.getters.js.map +1 -1
  13. package/dist/municipal/cities/cities.types.d.ts +1 -1
  14. package/dist/municipal/cities/index.d.ts +2 -2
  15. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts +3 -3
  16. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts.map +1 -1
  17. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js +30 -22
  18. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js.map +1 -1
  19. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts +4 -4
  20. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts.map +1 -1
  21. package/dist/municipal/departmentsSubjects/index.d.ts +2 -2
  22. package/dist/municipal/index.d.ts +8 -8
  23. package/dist/municipal/index.d.ts.map +1 -1
  24. package/dist/municipal/index.js +1 -1
  25. package/dist/municipal/mongodb-client.d.ts +1 -1
  26. package/dist/municipal/mongodb-client.d.ts.map +1 -1
  27. package/dist/municipal/mongodb-client.js +7 -7
  28. package/dist/municipal/mongodb-client.js.map +1 -1
  29. package/dist/municipal/streets/index.d.ts +2 -2
  30. package/dist/municipal/streets/streets.getters.d.ts +3 -3
  31. package/dist/municipal/streets/streets.getters.d.ts.map +1 -1
  32. package/dist/municipal/streets/streets.getters.js +19 -9
  33. package/dist/municipal/streets/streets.getters.js.map +1 -1
  34. package/dist/municipal/streets/streets.types.d.ts +1 -1
  35. package/dist/municipal/systemInstructions/index.d.ts +3 -3
  36. package/dist/municipal/systemInstructions/index.d.ts.map +1 -1
  37. package/dist/municipal/systemInstructions/instructions.getters.d.ts +3 -3
  38. package/dist/municipal/systemInstructions/instructions.getters.d.ts.map +1 -1
  39. package/dist/municipal/systemInstructions/instructions.getters.js +10 -4
  40. package/dist/municipal/systemInstructions/instructions.getters.js.map +1 -1
  41. package/dist/municipal/systemInstructions/instructions.setters.d.ts +2 -2
  42. package/dist/municipal/systemInstructions/instructions.setters.d.ts.map +1 -1
  43. package/dist/municipal/systemInstructions/instructions.setters.js +13 -8
  44. package/dist/municipal/systemInstructions/instructions.setters.js.map +1 -1
  45. package/dist/municipal/systemInstructions/instructions.types.d.ts +3 -3
  46. package/dist/municipal/systemInstructions/instructions.types.d.ts.map +1 -1
  47. package/dist/municipal/systemInstructions/instructions.types.js +6 -6
  48. package/dist/municipal/tickets/index.d.ts +2 -2
  49. package/dist/municipal/tickets/tickets.getters.d.ts +3 -3
  50. package/dist/municipal/tickets/tickets.getters.d.ts.map +1 -1
  51. package/dist/municipal/tickets/tickets.getters.js +50 -29
  52. package/dist/municipal/tickets/tickets.getters.js.map +1 -1
  53. package/dist/municipal/tickets/tickets.types.d.ts +1 -1
  54. package/dist/municipal/tickets/tickets.types.d.ts.map +1 -1
  55. package/dist/municipal/utils/types.d.ts +1 -1
  56. package/dist/municipal/utils/types.d.ts.map +1 -1
  57. package/dist/talkpilot/agents/agents.getters.d.ts +1 -1
  58. package/dist/talkpilot/agents/agents.getters.js +2 -2
  59. package/dist/talkpilot/agents/agents.types.d.ts +2 -2
  60. package/dist/talkpilot/agents/index.d.ts +2 -2
  61. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts +2 -2
  62. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts.map +1 -1
  63. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js +1 -1
  64. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js.map +1 -1
  65. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.types.d.ts +2 -2
  66. package/dist/talkpilot/backgroundToolResults/index.d.ts +2 -2
  67. package/dist/talkpilot/calls/calls.getters.d.ts +4 -3
  68. package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
  69. package/dist/talkpilot/calls/calls.getters.js +24 -16
  70. package/dist/talkpilot/calls/calls.getters.js.map +1 -1
  71. package/dist/talkpilot/calls/calls.types.d.ts +26 -3
  72. package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
  73. package/dist/talkpilot/calls/calls.types.js +2 -2
  74. package/dist/talkpilot/calls/index.d.ts +2 -2
  75. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts +2 -2
  76. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts.map +1 -1
  77. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js +2 -2
  78. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js.map +1 -1
  79. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts +2 -2
  80. package/dist/talkpilot/clientAudioBuffers/index.d.ts +2 -2
  81. package/dist/talkpilot/clients/clients.getters.d.ts +2 -2
  82. package/dist/talkpilot/clients/clients.getters.d.ts.map +1 -1
  83. package/dist/talkpilot/clients/clients.getters.js +5 -2
  84. package/dist/talkpilot/clients/clients.getters.js.map +1 -1
  85. package/dist/talkpilot/clients/clients.types.d.ts +1 -1
  86. package/dist/talkpilot/clients/index.d.ts +2 -2
  87. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +2 -2
  88. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
  89. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +1 -1
  90. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
  91. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +3 -3
  92. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
  93. package/dist/talkpilot/clientsConfig/index.d.ts +2 -2
  94. package/dist/talkpilot/flows/flows.getter.d.ts +2 -2
  95. package/dist/talkpilot/flows/flows.getter.d.ts.map +1 -1
  96. package/dist/talkpilot/flows/flows.getter.js +1 -1
  97. package/dist/talkpilot/flows/flows.getter.js.map +1 -1
  98. package/dist/talkpilot/flows/flows.schema.d.ts +0 -3
  99. package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
  100. package/dist/talkpilot/flows/flows.schema.js +87 -80
  101. package/dist/talkpilot/flows/flows.schema.js.map +1 -1
  102. package/dist/talkpilot/flows/flows.types.d.ts +16 -17
  103. package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
  104. package/dist/talkpilot/flows/index.d.ts +2 -2
  105. package/dist/talkpilot/groups/groups.getters.d.ts +2 -2
  106. package/dist/talkpilot/groups/groups.getters.d.ts.map +1 -1
  107. package/dist/talkpilot/groups/groups.getters.js +2 -2
  108. package/dist/talkpilot/groups/groups.getters.js.map +1 -1
  109. package/dist/talkpilot/groups/groups.types.d.ts +1 -1
  110. package/dist/talkpilot/groups/index.d.ts +3 -3
  111. package/dist/talkpilot/groups/phone.utils.d.ts +1 -1
  112. package/dist/talkpilot/groups/phone.utils.d.ts.map +1 -1
  113. package/dist/talkpilot/groups/phone.utils.js +2 -2
  114. package/dist/talkpilot/groups/phone.utils.js.map +1 -1
  115. package/dist/talkpilot/index.d.ts +16 -16
  116. package/dist/talkpilot/index.js +1 -1
  117. package/dist/talkpilot/leads/index.d.ts +2 -2
  118. package/dist/talkpilot/leads/leads.getter.d.ts +2 -2
  119. package/dist/talkpilot/leads/leads.getter.d.ts.map +1 -1
  120. package/dist/talkpilot/leads/leads.getter.js +1 -1
  121. package/dist/talkpilot/leads/leads.getter.js.map +1 -1
  122. package/dist/talkpilot/leads/leads.schema.js +16 -16
  123. package/dist/talkpilot/leads/leads.types.d.ts +1 -1
  124. package/dist/talkpilot/mongodb-client.d.ts +1 -1
  125. package/dist/talkpilot/mongodb-client.js +8 -9
  126. package/dist/talkpilot/mongodb-client.js.map +1 -1
  127. package/dist/talkpilot/phone_numbers/index.d.ts +1 -1
  128. package/dist/talkpilot/phone_numbers/index.d.ts.map +1 -1
  129. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +5 -2
  130. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
  131. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +66 -12
  132. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
  133. package/dist/talkpilot/phone_numbers/phone_numbers.schema.d.ts +11 -2
  134. package/dist/talkpilot/phone_numbers/phone_numbers.schema.d.ts.map +1 -1
  135. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +5 -2
  136. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js.map +1 -1
  137. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +16 -3
  138. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -1
  139. package/dist/talkpilot/plans/index.d.ts +2 -2
  140. package/dist/talkpilot/plans/plans.getters.d.ts +2 -2
  141. package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -1
  142. package/dist/talkpilot/plans/plans.getters.js +3 -3
  143. package/dist/talkpilot/plans/plans.getters.js.map +1 -1
  144. package/dist/talkpilot/plans/plans.types.d.ts +4 -4
  145. package/dist/talkpilot/plans/plans.types.d.ts.map +1 -1
  146. package/dist/talkpilot/plans/plans.types.js +19 -19
  147. package/dist/talkpilot/results/index.d.ts +2 -2
  148. package/dist/talkpilot/results/index.d.ts.map +1 -1
  149. package/dist/talkpilot/results/index.js.map +1 -1
  150. package/dist/talkpilot/results/results.getter.d.ts +3 -3
  151. package/dist/talkpilot/results/results.getter.d.ts.map +1 -1
  152. package/dist/talkpilot/results/results.getter.js +4 -4
  153. package/dist/talkpilot/results/results.getter.js.map +1 -1
  154. package/dist/talkpilot/results/results.schema.js +18 -18
  155. package/dist/talkpilot/results/results.types.d.ts +1 -1
  156. package/dist/talkpilot/sessions/index.d.ts +2 -2
  157. package/dist/talkpilot/sessions/sessions.getter.d.ts +3 -3
  158. package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -1
  159. package/dist/talkpilot/sessions/sessions.getter.js +13 -10
  160. package/dist/talkpilot/sessions/sessions.getter.js.map +1 -1
  161. package/dist/talkpilot/sessions/sessions.schema.js +17 -17
  162. package/dist/talkpilot/sessions/sessions.types.d.ts +2 -2
  163. package/dist/talkpilot/subscriptions/index.d.ts +3 -3
  164. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +2 -2
  165. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -1
  166. package/dist/talkpilot/subscriptions/subscriptions.getters.js +11 -11
  167. package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -1
  168. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +2 -2
  169. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -1
  170. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -1
  171. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +2 -2
  172. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -1
  173. package/dist/talkpilot/subscriptions/subscriptions.types.js +7 -7
  174. package/dist/talkpilot/utils/query.utils.d.ts +1 -1
  175. package/dist/test-utils/db-utils.d.ts +1 -1
  176. package/dist/test-utils/db-utils.js +2 -2
  177. package/dist/test-utils/factories/index.d.ts +12 -12
  178. package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
  179. package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
  180. package/dist/test-utils/factories/municipal/cities.js +1 -1
  181. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
  182. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
  183. package/dist/test-utils/factories/municipal/departmentsSubjects.js +7 -1
  184. package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
  185. package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
  186. package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
  187. package/dist/test-utils/factories/municipal/streets.js +6 -1
  188. package/dist/test-utils/factories/municipal/streets.js.map +1 -1
  189. package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
  190. package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
  191. package/dist/test-utils/factories/municipal/tickets.js +7 -1
  192. package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
  193. package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
  194. package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
  195. package/dist/test-utils/factories/talkpilot/agents.js +4 -4
  196. package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
  197. package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
  198. package/dist/test-utils/factories/talkpilot/calls.js +1 -1
  199. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
  200. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
  201. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
  202. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
  203. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
  204. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
  205. package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
  206. package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
  207. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
  208. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
  209. package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
  210. package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
  211. package/dist/test-utils/factories/talkpilot/groups.js +9 -9
  212. package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
  213. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
  214. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
  215. package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
  216. package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
  217. package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
  218. package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
  219. package/dist/utils/validation.js +2 -2
  220. package/dist/utils/validation.js.map +1 -1
  221. package/package.json +3 -1
  222. package/src/__tests__/setup.ts +3 -3
  223. package/src/connection.ts +27 -25
  224. package/src/index.ts +9 -9
  225. package/src/municipal/__tests__/validation.spec.ts +35 -23
  226. package/src/municipal/cities/cities.getters.ts +16 -10
  227. package/src/municipal/cities/cities.types.ts +1 -1
  228. package/src/municipal/cities/index.ts +2 -2
  229. package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +53 -44
  230. package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
  231. package/src/municipal/departmentsSubjects/index.ts +2 -3
  232. package/src/municipal/index.ts +10 -10
  233. package/src/municipal/mongodb-client.ts +13 -10
  234. package/src/municipal/streets/index.ts +2 -2
  235. package/src/municipal/streets/streets.getters.ts +43 -23
  236. package/src/municipal/streets/streets.types.ts +1 -1
  237. package/src/municipal/systemInstructions/__tests__/getters.spec.ts +67 -52
  238. package/src/municipal/systemInstructions/__tests__/setters.spec.ts +271 -238
  239. package/src/municipal/systemInstructions/index.ts +7 -3
  240. package/src/municipal/systemInstructions/instructions.getters.ts +30 -18
  241. package/src/municipal/systemInstructions/instructions.setters.ts +43 -19
  242. package/src/municipal/systemInstructions/instructions.types.ts +10 -10
  243. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
  244. package/src/municipal/tickets/index.ts +2 -2
  245. package/src/municipal/tickets/tickets.getters.ts +69 -42
  246. package/src/municipal/tickets/tickets.types.ts +2 -2
  247. package/src/municipal/utils/types.ts +8 -3
  248. package/src/talkpilot/__tests__/db.spec.ts +12 -12
  249. package/src/talkpilot/__tests__/mongodb-client.spec.ts +7 -8
  250. package/src/talkpilot/__tests__/validation.spec.ts +30 -24
  251. package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
  252. package/src/talkpilot/agents/agents.getters.ts +3 -3
  253. package/src/talkpilot/agents/agents.types.ts +2 -2
  254. package/src/talkpilot/agents/index.ts +2 -2
  255. package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +42 -31
  256. package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
  257. package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +2 -3
  258. package/src/talkpilot/backgroundToolResults/index.ts +2 -2
  259. package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
  260. package/src/talkpilot/calls/__tests__/calls.spec.ts +178 -40
  261. package/src/talkpilot/calls/calls.getters.ts +57 -27
  262. package/src/talkpilot/calls/calls.types.ts +39 -16
  263. package/src/talkpilot/calls/index.ts +2 -2
  264. package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +73 -39
  265. package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +18 -11
  266. package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
  267. package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
  268. package/src/talkpilot/clients/clients.getters.ts +10 -5
  269. package/src/talkpilot/clients/clients.types.ts +1 -1
  270. package/src/talkpilot/clients/index.ts +2 -2
  271. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +21 -18
  272. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +6 -4
  273. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +10 -8
  274. package/src/talkpilot/clientsConfig/index.ts +2 -2
  275. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +38 -37
  276. package/src/talkpilot/flows/flows.getter.ts +8 -5
  277. package/src/talkpilot/flows/flows.schema.ts +87 -80
  278. package/src/talkpilot/flows/flows.types.ts +23 -24
  279. package/src/talkpilot/flows/index.ts +2 -2
  280. package/src/talkpilot/groups/__tests__/groups.spec.ts +34 -27
  281. package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
  282. package/src/talkpilot/groups/groups.getters.ts +8 -5
  283. package/src/talkpilot/groups/groups.types.ts +1 -1
  284. package/src/talkpilot/groups/index.ts +3 -3
  285. package/src/talkpilot/groups/phone.utils.ts +12 -6
  286. package/src/talkpilot/index.ts +17 -17
  287. package/src/talkpilot/leads/index.ts +2 -2
  288. package/src/talkpilot/leads/leads.getter.ts +5 -4
  289. package/src/talkpilot/leads/leads.schema.ts +16 -16
  290. package/src/talkpilot/leads/leads.types.ts +1 -1
  291. package/src/talkpilot/mongodb-client.ts +12 -12
  292. package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +162 -33
  293. package/src/talkpilot/phone_numbers/index.ts +1 -1
  294. package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +94 -18
  295. package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +5 -2
  296. package/src/talkpilot/phone_numbers/phone_numbers.types.ts +18 -3
  297. package/src/talkpilot/plans/__tests__/plans.spec.ts +30 -26
  298. package/src/talkpilot/plans/index.ts +2 -2
  299. package/src/talkpilot/plans/plans.getters.ts +25 -18
  300. package/src/talkpilot/plans/plans.types.ts +27 -23
  301. package/src/talkpilot/results/index.ts +5 -2
  302. package/src/talkpilot/results/results.getter.ts +9 -8
  303. package/src/talkpilot/results/results.schema.ts +18 -18
  304. package/src/talkpilot/results/results.types.ts +1 -1
  305. package/src/talkpilot/sessions/__tests__/sessions.spec.ts +65 -41
  306. package/src/talkpilot/sessions/index.ts +2 -2
  307. package/src/talkpilot/sessions/sessions.getter.ts +21 -16
  308. package/src/talkpilot/sessions/sessions.schema.ts +17 -17
  309. package/src/talkpilot/sessions/sessions.types.ts +2 -2
  310. package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +18 -15
  311. package/src/talkpilot/subscriptions/index.ts +3 -3
  312. package/src/talkpilot/subscriptions/subscriptions.getters.ts +36 -33
  313. package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +10 -3
  314. package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
  315. package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
  316. package/src/talkpilot/utils/query.utils.ts +2 -2
  317. package/src/test-utils/db-utils.ts +5 -5
  318. package/src/test-utils/factories/index.ts +12 -12
  319. package/src/test-utils/factories/municipal/cities.ts +5 -5
  320. package/src/test-utils/factories/municipal/departmentsSubjects.ts +32 -25
  321. package/src/test-utils/factories/municipal/streets.ts +10 -5
  322. package/src/test-utils/factories/municipal/tickets.ts +12 -6
  323. package/src/test-utils/factories/talkpilot/agents.ts +8 -8
  324. package/src/test-utils/factories/talkpilot/calls.ts +5 -5
  325. package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +14 -12
  326. package/src/test-utils/factories/talkpilot/clientsConfig.ts +7 -8
  327. package/src/test-utils/factories/talkpilot/flows.ts +7 -5
  328. package/src/test-utils/factories/talkpilot/groups.ts +13 -13
  329. package/src/test-utils/factories/talkpilot/phone_numbers.ts +8 -6
  330. package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
  331. package/src/utils/validation.ts +4 -4
@@ -1,141 +1,148 @@
1
1
  export const flowMongoSchema = {
2
- bsonType: 'object',
3
- required: ['flowName', 'systemInstructions', 'initialSentence', 'interactions'],
2
+ bsonType: "object",
3
+ required: [
4
+ "flowName",
5
+ "systemInstructions",
6
+ "initialSentence",
7
+ "interactions",
8
+ ],
4
9
  properties: {
5
- _id: { bsonType: 'objectId' },
6
- flowName: { bsonType: 'string' },
7
- clientId: { bsonType: 'string' },
8
- systemInstructions: { bsonType: 'string' },
9
- initialSentence: { bsonType: 'string' },
10
- voice: { bsonType: ['string', 'null'] },
10
+ _id: { bsonType: "objectId" },
11
+ flowName: { bsonType: "string" },
12
+ clientId: { bsonType: "string" },
13
+ systemInstructions: { bsonType: "string" },
14
+ initialSentence: { bsonType: "string" },
15
+ voice: { bsonType: ["string", "null"] },
11
16
  conversationSettings: {
12
- bsonType: ['object', 'null'],
17
+ bsonType: ["object", "null"],
13
18
  properties: {
14
19
  interruptions: {
15
- bsonType: ['object', 'null'],
20
+ bsonType: ["object", "null"],
16
21
  properties: {
17
- enableInterruptionDetection: { bsonType: 'bool' },
18
- interruptionWindowSeconds: { bsonType: 'number' },
19
- interruptionThresholdSeconds: { bsonType: 'number' },
20
- interruptionInstruction: { bsonType: 'string' },
22
+ enableInterruptionDetection: { bsonType: "bool" },
23
+ interruptionWindowSeconds: { bsonType: "number" },
24
+ interruptionThresholdSeconds: { bsonType: "number" },
25
+ interruptionInstruction: { bsonType: "string" },
21
26
  },
22
27
  additionalProperties: false,
23
28
  },
24
29
  silence: {
25
- bsonType: ['object', 'null'],
30
+ bsonType: ["object", "null"],
26
31
  properties: {
27
- enableSilenceDetection: { bsonType: 'bool' },
28
- firstWarningSilenceSeconds: { bsonType: 'number' },
29
- firstWarningInstruction: { bsonType: 'string' },
30
- secondWarningSilenceSeconds: { bsonType: 'number' },
31
- secondWarningInstruction: { bsonType: 'string' },
32
- disconnectSilenceSeconds: { bsonType: 'number' },
32
+ enableSilenceDetection: { bsonType: "bool" },
33
+ firstWarningSilenceSeconds: { bsonType: "number" },
34
+ firstWarningInstruction: { bsonType: "string" },
35
+ secondWarningSilenceSeconds: { bsonType: "number" },
36
+ secondWarningInstruction: { bsonType: "string" },
37
+ disconnectSilenceSeconds: { bsonType: "number" },
33
38
  },
34
39
  additionalProperties: false,
35
40
  },
36
- liveTimeUpdates: { bsonType: 'bool' },
41
+ liveTimeUpdates: { bsonType: "bool" },
37
42
  },
38
43
  additionalProperties: false,
39
44
  },
40
45
  interactions: {
41
- bsonType: 'array',
46
+ bsonType: "array",
42
47
  items: {
43
- bsonType: 'object',
44
- required: ['id', 'type', 'text', 'position'],
48
+ bsonType: "object",
49
+ required: ["id", "type", "text", "position"],
45
50
  properties: {
46
- id: { bsonType: 'string' },
47
- type: { bsonType: 'string' },
48
- text: { bsonType: 'string' },
49
- successStatus: { bsonType: ['string', 'null'] },
51
+ id: { bsonType: "string" },
52
+ type: { bsonType: "string" },
53
+ text: { bsonType: "string" },
54
+ successStatus: { bsonType: ["string", "null"] },
50
55
  conditions: {
51
- bsonType: ['array', 'null'],
56
+ bsonType: ["array", "null"],
52
57
  items: {
53
- bsonType: 'object',
54
- required: ['conditionString'],
58
+ bsonType: "object",
59
+ required: ["conditionString"],
55
60
  properties: {
56
- conditionString: { bsonType: 'string' },
57
- nodeType: { bsonType: ['string', 'null'] },
58
- id: { bsonType: ['string', 'null'] },
61
+ conditionString: { bsonType: "string" },
62
+ nodeType: { bsonType: ["string", "null"] },
63
+ id: { bsonType: ["string", "null"] },
59
64
  },
60
65
  },
61
66
  },
62
- defaultNodeType: { bsonType: ['string', 'null'] },
67
+ defaultNodeType: { bsonType: ["string", "null"] },
63
68
  defaultChild: {
64
- bsonType: ['object', 'null'],
65
- properties: { id: { bsonType: 'string' } },
69
+ bsonType: ["object", "null"],
70
+ properties: { id: { bsonType: "string" } },
66
71
  },
67
72
  position: {
68
- bsonType: 'object',
69
- required: ['x', 'y'],
73
+ bsonType: "object",
74
+ required: ["x", "y"],
70
75
  properties: {
71
- x: { bsonType: 'number' },
72
- y: { bsonType: 'number' },
76
+ x: { bsonType: "number" },
77
+ y: { bsonType: "number" },
73
78
  },
74
79
  },
75
- name: { bsonType: ['string', 'null'] },
76
- children: { bsonType: ['array', 'null'], items: { bsonType: 'string' } },
77
- resultsLabel: { bsonType: ['string', 'null'] },
78
- resultsColor: { bsonType: ['string', 'null'] },
80
+ name: { bsonType: ["string", "null"] },
81
+ children: {
82
+ bsonType: ["array", "null"],
83
+ items: { bsonType: "string" },
84
+ },
85
+ resultsLabel: { bsonType: ["string", "null"] },
86
+ resultsColor: { bsonType: ["string", "null"] },
79
87
  },
80
88
  },
81
89
  },
82
90
  edges: {
83
- bsonType: ['array', 'null'],
91
+ bsonType: ["array", "null"],
84
92
  items: {
85
- bsonType: 'object',
86
- required: ['id', 'source', 'target'],
93
+ bsonType: "object",
94
+ required: ["id", "source", "target"],
87
95
  properties: {
88
- id: { bsonType: 'string' },
89
- source: { bsonType: 'string' },
90
- target: { bsonType: 'string' },
91
- label: { bsonType: ['string', 'null'] },
96
+ id: { bsonType: "string" },
97
+ source: { bsonType: "string" },
98
+ target: { bsonType: "string" },
99
+ label: { bsonType: ["string", "null"] },
92
100
  },
93
101
  },
94
102
  },
95
103
  metaKeys: {
96
- bsonType: ['array', 'null'],
104
+ bsonType: ["array", "null"],
97
105
  items: {
98
- bsonType: 'object',
99
- required: ['key'],
106
+ bsonType: "object",
107
+ required: ["key"],
100
108
  properties: {
101
- key: { bsonType: 'string' },
102
- required: { bsonType: 'bool' },
109
+ key: { bsonType: "string" },
110
+ required: { bsonType: "bool" },
103
111
  },
104
112
  },
105
113
  },
106
114
  userProperties: {
107
- bsonType: ['array', 'null'],
115
+ bsonType: ["array", "null"],
108
116
  items: {
109
- bsonType: 'object',
110
- required: ['name', 'description'],
117
+ bsonType: "object",
118
+ required: ["name", "description"],
111
119
  properties: {
112
- name: { bsonType: 'string' },
113
- description: { bsonType: 'string' },
120
+ name: { bsonType: "string" },
121
+ description: { bsonType: "string" },
114
122
  },
115
123
  },
116
124
  },
117
125
  tools: {
118
- bsonType: ['array', 'null'],
126
+ bsonType: ["array", "null"],
119
127
  items: {
120
- bsonType: 'object',
121
- required: ['id', 'name', 'url', 'method', 'parameters'],
128
+ bsonType: "object",
129
+ required: ["id", "name", "url", "method", "parameters"],
122
130
  properties: {
123
- id: { bsonType: 'string' },
124
- name: { bsonType: 'string' },
125
- description: { bsonType: 'string' },
126
- url: { bsonType: 'string' },
127
- method: { bsonType: 'string' },
128
- headers: { bsonType: 'object' },
129
- parameters: { bsonType: 'object' },
130
- bodyFormat: { bsonType: 'string', enum: ['json', 'form-data'] },
131
- preventAudioDuringTool: { bsonType: 'bool' },
132
- sendUserAuthToken: { bsonType: 'bool' },
133
- runInBackground: { bsonType: 'bool' },
131
+ id: { bsonType: "string" },
132
+ name: { bsonType: "string" },
133
+ description: { bsonType: "string" },
134
+ url: { bsonType: "string" },
135
+ method: { bsonType: "string" },
136
+ headers: { bsonType: "object" },
137
+ parameters: { bsonType: "object" },
138
+ bodyFormat: { bsonType: "string", enum: ["json", "form-data"] },
139
+ preventAudioDuringTool: { bsonType: "bool" },
140
+ sendUserAuthToken: { bsonType: "bool" },
141
+ runInBackground: { bsonType: "bool" },
134
142
  backgroundToolType: {
135
- bsonType: 'string',
136
- enum: ['backgroundToolAlways', 'backgroundToolOnce'],
143
+ bsonType: "string",
144
+ enum: ["backgroundToolAlways", "backgroundToolOnce"],
137
145
  },
138
- backgroundContinuationInstructions: { bsonType: 'string' },
139
146
  },
140
147
  additionalProperties: false,
141
148
  },
@@ -1,12 +1,12 @@
1
- import { ObjectId } from 'mongodb';
1
+ import { ObjectId } from "mongodb";
2
2
 
3
3
  /* ---------- Basic helpers ---------- */
4
4
 
5
5
  export type Position = { x: number; y: number };
6
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
6
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
7
7
 
8
- export type QuestionType = 'open' | 'multiple' | 'table';
9
- export type SelectionType = 'single' | 'multiple';
8
+ export type QuestionType = "open" | "multiple" | "table";
9
+ export type SelectionType = "single" | "multiple";
10
10
 
11
11
  export type Question = {
12
12
  id: string;
@@ -24,14 +24,14 @@ export type Question = {
24
24
  };
25
25
 
26
26
  export type NodeKind =
27
- | 'start'
28
- | 'say'
29
- | 'condition'
30
- | 'improvise'
31
- | 'tool'
32
- | 'sendMessage'
33
- | 'questionsList'
34
- | 'end';
27
+ | "start"
28
+ | "say"
29
+ | "condition"
30
+ | "improvise"
31
+ | "tool"
32
+ | "sendMessage"
33
+ | "questionsList"
34
+ | "end";
35
35
  type BaseNode = {
36
36
  id: string;
37
37
  type: NodeKind;
@@ -44,12 +44,12 @@ type BaseNode = {
44
44
  questions?: Question[] | null;
45
45
  };
46
46
 
47
- export type StartNode = BaseNode & { type: 'start' };
47
+ export type StartNode = BaseNode & { type: "start" };
48
48
 
49
- export type SayNode = BaseNode & { type: 'say' };
49
+ export type SayNode = BaseNode & { type: "say" };
50
50
 
51
51
  export type ConditionNode = BaseNode & {
52
- type: 'condition';
52
+ type: "condition";
53
53
  conditions: Array<{
54
54
  conditionString: string;
55
55
  nodeType?: string | null;
@@ -59,7 +59,7 @@ export type ConditionNode = BaseNode & {
59
59
  defaultChild?: { id?: string } | null;
60
60
  };
61
61
 
62
- export type ImproviseNode = BaseNode & { type: 'improvise' };
62
+ export type ImproviseNode = BaseNode & { type: "improvise" };
63
63
 
64
64
  export type FlowTool = {
65
65
  id: string;
@@ -69,18 +69,17 @@ export type FlowTool = {
69
69
  method: HttpMethod;
70
70
  headers?: Record<string, string>;
71
71
  parameters: Record<string, unknown>;
72
- bodyFormat?: 'json' | 'form-data';
72
+ bodyFormat?: "json" | "form-data";
73
73
  preventAudioDuringTool?: boolean;
74
74
  sendUserAuthToken?: boolean;
75
75
  runInBackground?: boolean;
76
- backgroundToolType?: 'backgroundToolAlways' | 'backgroundToolOnce';
77
- backgroundContinuationInstructions?: string;
76
+ backgroundToolType?: "backgroundToolAlways" | "backgroundToolOnce";
78
77
  };
79
78
 
80
- export type SendMethod = 'sms' | 'whatsapp';
79
+ export type SendMethod = "sms" | "whatsapp";
81
80
 
82
81
  export type SendMessageNode = BaseNode & {
83
- type: 'sendMessage';
82
+ type: "sendMessage";
84
83
  /** Which channel to use. If omitted, decide at runtime (e.g., default to whatsapp). */
85
84
  send_method: SendMethod;
86
85
  /** Destination phone (E.164 or templated string like "{{userPhone}}"). */
@@ -88,17 +87,17 @@ export type SendMessageNode = BaseNode & {
88
87
  };
89
88
 
90
89
  export type ToolNode = BaseNode & {
91
- type: 'tool';
90
+ type: "tool";
92
91
  name: string;
93
92
  text: string;
94
93
  };
95
94
 
96
95
  export type QuestionsListNode = BaseNode & {
97
- type: 'questionsList';
96
+ type: "questionsList";
98
97
  questions: Question[];
99
98
  };
100
99
 
101
- export type EndNode = BaseNode & { type: 'end' };
100
+ export type EndNode = BaseNode & { type: "end" };
102
101
 
103
102
  export type Interaction =
104
103
  | StartNode
@@ -1,2 +1,2 @@
1
- export { getFlowsCollection, findFlowById } from './flows.getter';
2
- export type * from './flows.types';
1
+ export { getFlowsCollection, findFlowById } from "./flows.getter";
2
+ export type * from "./flows.types";
@@ -1,27 +1,30 @@
1
- import { ObjectId } from 'mongodb';
2
- import { faker } from '@faker-js/faker';
1
+ import { ObjectId } from "mongodb";
2
+ import { faker } from "@faker-js/faker";
3
3
  import {
4
4
  getGroupsCollection,
5
5
  findGroups,
6
6
  createGroup,
7
7
  updateGroup,
8
8
  removeGroup,
9
- } from '../groups.getters';
10
- import { createGroup as createGroupDoc } from '../../../test-utils/factories';
9
+ } from "../groups.getters";
10
+ import { createGroup as createGroupDoc } from "../../../test-utils/factories";
11
11
 
12
- describe('db.groups', () => {
13
- describe('getGroupsCollection', () => {
12
+ describe("db.groups", () => {
13
+ describe("getGroupsCollection", () => {
14
14
  it('returns the "groups" collection', () => {
15
- expect(getGroupsCollection().collectionName).toBe('groups');
15
+ expect(getGroupsCollection().collectionName).toBe("groups");
16
16
  });
17
17
  });
18
18
 
19
- describe('findGroups', () => {
20
- it('returns groups matching the provided filter', async () => {
19
+ describe("findGroups", () => {
20
+ it("returns groups matching the provided filter", async () => {
21
21
  const clientId = faker.string.uuid();
22
- const g1 = createGroupDoc({ clientId, name: 'Group A' });
23
- const g2 = createGroupDoc({ clientId, name: 'Group B' });
24
- const gOther = createGroupDoc({ clientId: faker.string.uuid(), name: 'Group C' });
22
+ const g1 = createGroupDoc({ clientId, name: "Group A" });
23
+ const g2 = createGroupDoc({ clientId, name: "Group B" });
24
+ const gOther = createGroupDoc({
25
+ clientId: faker.string.uuid(),
26
+ name: "Group C",
27
+ });
25
28
 
26
29
  await getGroupsCollection().insertMany([g1, g2, gOther]);
27
30
 
@@ -29,26 +32,29 @@ describe('db.groups', () => {
29
32
  const names = result.map((g) => g.name).sort();
30
33
 
31
34
  expect(result).toHaveLength(2);
32
- expect(names).toEqual(['Group A', 'Group B']);
35
+ expect(names).toEqual(["Group A", "Group B"]);
33
36
  });
34
37
  });
35
38
 
36
- describe('createGroup', () => {
37
- it('inserts a group and returns insertedId', async () => {
38
- const toInsert = createGroupDoc({ name: 'New Group' });
39
+ describe("createGroup", () => {
40
+ it("inserts a group and returns insertedId", async () => {
41
+ const toInsert = createGroupDoc({ name: "New Group" });
39
42
 
40
43
  const insertedId = await createGroup(toInsert);
41
44
  expect(insertedId).toBeInstanceOf(ObjectId);
42
45
 
43
46
  const fromDb = await getGroupsCollection().findOne({ _id: insertedId });
44
- expect(fromDb?.name).toBe('New Group');
47
+ expect(fromDb?.name).toBe("New Group");
45
48
  expect(fromDb?.clientId).toBe(toInsert.clientId);
46
49
  });
47
50
  });
48
51
 
49
- describe('updateGroup', () => {
50
- it('updates the group and sets updatedAt, returning the updated document', async () => {
51
- const original = createGroupDoc({ name: 'Before', description: 'Old desc' });
52
+ describe("updateGroup", () => {
53
+ it("updates the group and sets updatedAt, returning the updated document", async () => {
54
+ const original = createGroupDoc({
55
+ name: "Before",
56
+ description: "Old desc",
57
+ });
52
58
  const { insertedId } = await getGroupsCollection().insertOne(original);
53
59
  const before = await getGroupsCollection().findOne({ _id: insertedId });
54
60
 
@@ -57,21 +63,22 @@ describe('db.groups', () => {
57
63
 
58
64
  const res = await updateGroup(
59
65
  { _id: insertedId },
60
- { name: 'After', description: 'New desc' }
66
+ { name: "After", description: "New desc" },
61
67
  );
62
68
 
63
69
  expect(res?._id).toEqual(insertedId);
64
- expect(res?.name).toBe('After');
65
- expect(res?.description).toBe('New desc');
70
+ expect(res?.name).toBe("After");
71
+ expect(res?.description).toBe("New desc");
66
72
  expect(new Date(res!.updatedAt).getTime()).toBeGreaterThan(
67
- new Date(before!.updatedAt).getTime()
73
+ new Date(before!.updatedAt).getTime(),
68
74
  );
69
75
  });
70
76
  });
71
77
 
72
- describe('removeGroup', () => {
73
- it('removes a group by string id', async () => {
74
- const { insertedId } = await getGroupsCollection().insertOne(createGroupDoc());
78
+ describe("removeGroup", () => {
79
+ it("removes a group by string id", async () => {
80
+ const { insertedId } =
81
+ await getGroupsCollection().insertOne(createGroupDoc());
75
82
 
76
83
  const result = await removeGroup(insertedId.toHexString());
77
84
  expect(result.deletedCount).toBe(1);
@@ -1,32 +1,32 @@
1
- import { enrichPhoneNumber, isValidE164 } from '../phone.utils';
1
+ import { enrichPhoneNumber, isValidE164 } from "../phone.utils";
2
2
 
3
- describe('Phone Utilities', () => {
4
- describe('enrichPhoneNumber', () => {
5
- it('should enrich Israeli number', () => {
6
- const result = enrichPhoneNumber('+972507725874');
7
- expect(result?.e164).toBe('+972507725874');
3
+ describe("Phone Utilities", () => {
4
+ describe("enrichPhoneNumber", () => {
5
+ it("should enrich Israeli number", () => {
6
+ const result = enrichPhoneNumber("+972507725874");
7
+ expect(result?.e164).toBe("+972507725874");
8
8
  expect(result?.region).toBeDefined();
9
- expect(result?.countryCallingCode).toBe('972');
9
+ expect(result?.countryCallingCode).toBe("972");
10
10
  });
11
11
 
12
- it('should enrich US number', () => {
13
- const result = enrichPhoneNumber('+12025551234');
14
- expect(result?.region).toBe('US');
15
- expect(result?.countryCallingCode).toBe('1');
12
+ it("should enrich US number", () => {
13
+ const result = enrichPhoneNumber("+12025551234");
14
+ expect(result?.region).toBe("US");
15
+ expect(result?.countryCallingCode).toBe("1");
16
16
  });
17
17
 
18
- it('should return null for invalid', () => {
19
- expect(enrichPhoneNumber('invalid')).toBeNull();
20
- expect(enrichPhoneNumber('0507725874')).toBeNull();
18
+ it("should return null for invalid", () => {
19
+ expect(enrichPhoneNumber("invalid")).toBeNull();
20
+ expect(enrichPhoneNumber("0507725874")).toBeNull();
21
21
  });
22
22
  });
23
23
 
24
- describe('isValidE164', () => {
25
- it('should validate E.164 format', () => {
26
- expect(isValidE164('+972508832983')).toBe(true);
27
- expect(isValidE164('+12025551234')).toBe(true);
28
- expect(isValidE164('0501234567')).toBe(false);
29
- expect(isValidE164('invalid')).toBe(false);
24
+ describe("isValidE164", () => {
25
+ it("should validate E.164 format", () => {
26
+ expect(isValidE164("+972508832983")).toBe(true);
27
+ expect(isValidE164("+12025551234")).toBe(true);
28
+ expect(isValidE164("0501234567")).toBe(false);
29
+ expect(isValidE164("invalid")).toBe(false);
30
30
  });
31
31
  });
32
32
  });
@@ -1,8 +1,8 @@
1
- import { getDb, ObjectId, Group } from '../index';
2
- import { Collection, Filter } from 'mongodb';
1
+ import { getDb, ObjectId, Group } from "../index";
2
+ import { Collection, Filter } from "mongodb";
3
3
 
4
4
  export const getGroupsCollection = (): Collection<Group> => {
5
- return getDb().collection<Group>('groups');
5
+ return getDb().collection<Group>("groups");
6
6
  };
7
7
 
8
8
  export const findGroups = async (filter: Filter<Group>): Promise<Group[]> => {
@@ -14,11 +14,14 @@ export const createGroup = async (group: Group) => {
14
14
  return insertedId;
15
15
  };
16
16
 
17
- export const updateGroup = async (filter: Filter<Group>, data: Partial<Group>) => {
17
+ export const updateGroup = async (
18
+ filter: Filter<Group>,
19
+ data: Partial<Group>,
20
+ ) => {
18
21
  return await getGroupsCollection().findOneAndUpdate(
19
22
  filter,
20
23
  { $set: { ...data, updatedAt: new Date() } },
21
- { returnDocument: 'after' }
24
+ { returnDocument: "after" },
22
25
  );
23
26
  };
24
27
 
@@ -1,4 +1,4 @@
1
- import { WithId } from 'mongodb';
1
+ import { WithId } from "mongodb";
2
2
  export type E164 = `+${string}`;
3
3
  export type CountryISO = Uppercase<string>;
4
4
 
@@ -1,3 +1,3 @@
1
- export * from './groups.getters';
2
- export * from './groups.types';
3
- export * from './phone.utils';
1
+ export * from "./groups.getters";
2
+ export * from "./groups.types";
3
+ export * from "./phone.utils";
@@ -1,21 +1,27 @@
1
- import { PhoneNumberUtil, PhoneNumberFormat } from 'google-libphonenumber';
2
- import type { Phone, E164, CountryISO } from './groups.types';
1
+ import { PhoneNumberUtil, PhoneNumberFormat } from "google-libphonenumber";
2
+ import type { Phone, E164, CountryISO } from "./groups.types";
3
3
 
4
4
  const phoneUtil = PhoneNumberUtil.getInstance();
5
5
 
6
6
  export const enrichPhoneNumber = (e164: string): Phone | null => {
7
7
  try {
8
- const phoneNumber = phoneUtil.parse(e164, 'ZZ');
8
+ const phoneNumber = phoneUtil.parse(e164, "ZZ");
9
9
  if (!phoneUtil.isValidNumber(phoneNumber)) {
10
10
  return null;
11
11
  }
12
12
 
13
- const normalizedE164 = phoneUtil.format(phoneNumber, PhoneNumberFormat.E164) as E164;
13
+ const normalizedE164 = phoneUtil.format(
14
+ phoneNumber,
15
+ PhoneNumberFormat.E164,
16
+ ) as E164;
14
17
  const region = phoneUtil.getRegionCodeForNumber(phoneNumber) as CountryISO;
15
18
  const countryCallingCode = phoneNumber.getCountryCode()?.toString();
16
19
  const national = phoneNumber.getNationalNumber()?.toString();
17
20
  const ext = phoneNumber.getExtension() || undefined;
18
- const formatted = phoneUtil.format(phoneNumber, PhoneNumberFormat.INTERNATIONAL);
21
+ const formatted = phoneUtil.format(
22
+ phoneNumber,
23
+ PhoneNumberFormat.INTERNATIONAL,
24
+ );
19
25
 
20
26
  return {
21
27
  e164: normalizedE164,
@@ -32,7 +38,7 @@ export const enrichPhoneNumber = (e164: string): Phone | null => {
32
38
 
33
39
  export const isValidE164 = (e164: string): boolean => {
34
40
  try {
35
- const phoneNumber = phoneUtil.parse(e164, 'ZZ');
41
+ const phoneNumber = phoneUtil.parse(e164, "ZZ");
36
42
  return phoneUtil.isValidNumber(phoneNumber);
37
43
  } catch (error) {
38
44
  return false;
@@ -1,27 +1,27 @@
1
- import { Db, ObjectId as MongoObjectId } from 'mongodb';
1
+ import { Db, ObjectId as MongoObjectId } from "mongodb";
2
2
 
3
- export * from './flows';
4
- export * from './results';
5
- export * from './sessions';
6
- export * from './phone_numbers';
7
- export * from './leads';
8
- export * from './clients';
9
- export * from './agents';
10
- export * from './plans';
11
- export * from './subscriptions';
12
- export * from './groups';
13
- export * from './calls';
14
- export * from './clientAudioBuffers';
15
- export * from './clientsConfig';
16
- export * from './backgroundToolResults';
17
- export { mongodbClient } from './mongodb-client';
3
+ export * from "./flows";
4
+ export * from "./results";
5
+ export * from "./sessions";
6
+ export * from "./phone_numbers";
7
+ export * from "./leads";
8
+ export * from "./clients";
9
+ export * from "./agents";
10
+ export * from "./plans";
11
+ export * from "./subscriptions";
12
+ export * from "./groups";
13
+ export * from "./calls";
14
+ export * from "./clientAudioBuffers";
15
+ export * from "./clientsConfig";
16
+ export * from "./backgroundToolResults";
17
+ export { mongodbClient } from "./mongodb-client";
18
18
 
19
19
  let db: Db;
20
20
  export const setDb = (d: Db) => {
21
21
  db = d;
22
22
  };
23
23
  export const getDb = (): Db => {
24
- if (!db) throw new Error('DB not initialised');
24
+ if (!db) throw new Error("DB not initialised");
25
25
  return db;
26
26
  };
27
27