@talkpilot/core-db 1.1.4 → 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 (325) 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 +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.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/utils/query.utils.d.ts +1 -1
  169. package/dist/test-utils/db-utils.d.ts +1 -1
  170. package/dist/test-utils/db-utils.js +2 -2
  171. package/dist/test-utils/factories/index.d.ts +12 -12
  172. package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
  173. package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
  174. package/dist/test-utils/factories/municipal/cities.js +1 -1
  175. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
  176. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
  177. package/dist/test-utils/factories/municipal/departmentsSubjects.js +7 -1
  178. package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
  179. package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
  180. package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
  181. package/dist/test-utils/factories/municipal/streets.js +6 -1
  182. package/dist/test-utils/factories/municipal/streets.js.map +1 -1
  183. package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
  184. package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
  185. package/dist/test-utils/factories/municipal/tickets.js +7 -1
  186. package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
  187. package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
  188. package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
  189. package/dist/test-utils/factories/talkpilot/agents.js +4 -4
  190. package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
  191. package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
  192. package/dist/test-utils/factories/talkpilot/calls.js +1 -1
  193. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
  194. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
  195. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
  196. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
  197. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
  198. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
  199. package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
  200. package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
  201. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
  202. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
  203. package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
  204. package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
  205. package/dist/test-utils/factories/talkpilot/groups.js +9 -9
  206. package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
  207. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
  208. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
  209. package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
  210. package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
  211. package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
  212. package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
  213. package/dist/utils/validation.js +2 -2
  214. package/dist/utils/validation.js.map +1 -1
  215. package/package.json +3 -1
  216. package/src/__tests__/setup.ts +3 -3
  217. package/src/connection.ts +27 -25
  218. package/src/index.ts +9 -9
  219. package/src/municipal/__tests__/validation.spec.ts +35 -23
  220. package/src/municipal/cities/cities.getters.ts +16 -10
  221. package/src/municipal/cities/cities.types.ts +1 -1
  222. package/src/municipal/cities/index.ts +2 -2
  223. package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +53 -44
  224. package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
  225. package/src/municipal/departmentsSubjects/index.ts +2 -3
  226. package/src/municipal/index.ts +10 -10
  227. package/src/municipal/mongodb-client.ts +19 -26
  228. package/src/municipal/streets/index.ts +2 -2
  229. package/src/municipal/streets/streets.getters.ts +43 -23
  230. package/src/municipal/streets/streets.types.ts +1 -1
  231. package/src/municipal/systemInstructions/__tests__/getters.spec.ts +67 -52
  232. package/src/municipal/systemInstructions/__tests__/setters.spec.ts +271 -238
  233. package/src/municipal/systemInstructions/index.ts +7 -3
  234. package/src/municipal/systemInstructions/instructions.getters.ts +30 -18
  235. package/src/municipal/systemInstructions/instructions.setters.ts +43 -19
  236. package/src/municipal/systemInstructions/instructions.types.ts +10 -10
  237. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
  238. package/src/municipal/tickets/index.ts +2 -2
  239. package/src/municipal/tickets/tickets.getters.ts +69 -42
  240. package/src/municipal/tickets/tickets.types.ts +2 -2
  241. package/src/municipal/utils/types.ts +8 -3
  242. package/src/talkpilot/__tests__/db.spec.ts +12 -12
  243. package/src/talkpilot/__tests__/mongodb-client.spec.ts +7 -8
  244. package/src/talkpilot/__tests__/validation.spec.ts +30 -24
  245. package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
  246. package/src/talkpilot/agents/agents.getters.ts +3 -3
  247. package/src/talkpilot/agents/agents.types.ts +2 -2
  248. package/src/talkpilot/agents/index.ts +2 -2
  249. package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +42 -31
  250. package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
  251. package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +2 -3
  252. package/src/talkpilot/backgroundToolResults/index.ts +2 -2
  253. package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
  254. package/src/talkpilot/calls/__tests__/calls.spec.ts +79 -39
  255. package/src/talkpilot/calls/calls.getters.ts +48 -28
  256. package/src/talkpilot/calls/calls.types.ts +16 -16
  257. package/src/talkpilot/calls/index.ts +2 -2
  258. package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +73 -39
  259. package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +18 -11
  260. package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
  261. package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
  262. package/src/talkpilot/clients/clients.getters.ts +10 -5
  263. package/src/talkpilot/clients/clients.types.ts +1 -1
  264. package/src/talkpilot/clients/index.ts +2 -2
  265. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +21 -18
  266. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +6 -4
  267. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +10 -8
  268. package/src/talkpilot/clientsConfig/index.ts +2 -2
  269. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +38 -34
  270. package/src/talkpilot/flows/flows.getter.ts +8 -5
  271. package/src/talkpilot/flows/flows.schema.ts +87 -79
  272. package/src/talkpilot/flows/flows.types.ts +23 -23
  273. package/src/talkpilot/flows/index.ts +2 -2
  274. package/src/talkpilot/groups/__tests__/groups.spec.ts +34 -27
  275. package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
  276. package/src/talkpilot/groups/groups.getters.ts +8 -5
  277. package/src/talkpilot/groups/groups.types.ts +1 -1
  278. package/src/talkpilot/groups/index.ts +3 -3
  279. package/src/talkpilot/groups/phone.utils.ts +12 -6
  280. package/src/talkpilot/index.ts +17 -17
  281. package/src/talkpilot/leads/index.ts +2 -2
  282. package/src/talkpilot/leads/leads.getter.ts +5 -4
  283. package/src/talkpilot/leads/leads.schema.ts +16 -16
  284. package/src/talkpilot/leads/leads.types.ts +1 -1
  285. package/src/talkpilot/mongodb-client.ts +23 -33
  286. package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +84 -44
  287. package/src/talkpilot/phone_numbers/index.ts +2 -2
  288. package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +44 -22
  289. package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +9 -9
  290. package/src/talkpilot/phone_numbers/phone_numbers.types.ts +1 -1
  291. package/src/talkpilot/plans/__tests__/plans.spec.ts +30 -26
  292. package/src/talkpilot/plans/index.ts +2 -2
  293. package/src/talkpilot/plans/plans.getters.ts +25 -18
  294. package/src/talkpilot/plans/plans.types.ts +27 -23
  295. package/src/talkpilot/results/index.ts +5 -2
  296. package/src/talkpilot/results/results.getter.ts +9 -8
  297. package/src/talkpilot/results/results.schema.ts +18 -18
  298. package/src/talkpilot/results/results.types.ts +1 -1
  299. package/src/talkpilot/sessions/__tests__/sessions.spec.ts +65 -41
  300. package/src/talkpilot/sessions/index.ts +2 -2
  301. package/src/talkpilot/sessions/sessions.getter.ts +21 -16
  302. package/src/talkpilot/sessions/sessions.schema.ts +17 -17
  303. package/src/talkpilot/sessions/sessions.types.ts +2 -2
  304. package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +18 -15
  305. package/src/talkpilot/subscriptions/index.ts +3 -3
  306. package/src/talkpilot/subscriptions/subscriptions.getters.ts +36 -33
  307. package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +10 -3
  308. package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
  309. package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
  310. package/src/talkpilot/utils/query.utils.ts +2 -2
  311. package/src/test-utils/db-utils.ts +5 -5
  312. package/src/test-utils/factories/index.ts +12 -12
  313. package/src/test-utils/factories/municipal/cities.ts +5 -5
  314. package/src/test-utils/factories/municipal/departmentsSubjects.ts +32 -25
  315. package/src/test-utils/factories/municipal/streets.ts +10 -5
  316. package/src/test-utils/factories/municipal/tickets.ts +12 -6
  317. package/src/test-utils/factories/talkpilot/agents.ts +8 -8
  318. package/src/test-utils/factories/talkpilot/calls.ts +5 -5
  319. package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +14 -12
  320. package/src/test-utils/factories/talkpilot/clientsConfig.ts +7 -8
  321. package/src/test-utils/factories/talkpilot/flows.ts +7 -5
  322. package/src/test-utils/factories/talkpilot/groups.ts +13 -13
  323. package/src/test-utils/factories/talkpilot/phone_numbers.ts +8 -6
  324. package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
  325. package/src/utils/validation.ts +4 -4
@@ -1,4 +1,4 @@
1
- import { WithId } from 'mongodb';
1
+ import { WithId } from "mongodb";
2
2
 
3
3
  export type InitiateCallForShortSlaConfig = {
4
4
  active: boolean;
@@ -35,16 +35,16 @@ export type Products = {
35
35
  export type ClinicsProduct = {
36
36
  api_key_secret_name: string;
37
37
  base_api_url: string;
38
- provider: 'clinix' | (string & {});
38
+ provider: "clinix" | (string & {});
39
39
  description?: string;
40
40
  };
41
41
 
42
42
  export type ClientLanguageName =
43
- | 'Hebrew'
44
- | 'English'
45
- | 'Russian'
46
- | 'French'
47
- | 'Spanish'
43
+ | "Hebrew"
44
+ | "English"
45
+ | "Russian"
46
+ | "French"
47
+ | "Spanish"
48
48
  | (string & {});
49
49
 
50
50
  export type SendGridConfig = {
@@ -72,4 +72,6 @@ export type ClientConfig<P extends Products = Products> = {
72
72
  communications?: CommunicationsConfig;
73
73
  };
74
74
 
75
- export type ClientConfigDoc<P extends Products = Products> = WithId<ClientConfig<P>>;
75
+ export type ClientConfigDoc<P extends Products = Products> = WithId<
76
+ ClientConfig<P>
77
+ >;
@@ -1,2 +1,2 @@
1
- export * from './clientsConfig.types';
2
- export * from './clientsConfig.getters';
1
+ export * from "./clientsConfig.types";
2
+ export * from "./clientsConfig.getters";
@@ -1,60 +1,64 @@
1
- import { flowMongoSchema } from '../flows.schema';
1
+ import { flowMongoSchema } from "../flows.schema";
2
2
 
3
- describe('flowMongoSchema', () => {
4
- it('defines conversationSettings as optional object or null', () => {
3
+ describe("flowMongoSchema", () => {
4
+ it("defines conversationSettings as optional object or null", () => {
5
5
  const schema: any = flowMongoSchema;
6
6
 
7
- expect(schema.properties).toHaveProperty('conversationSettings');
8
- expect(schema.properties.conversationSettings.bsonType).toEqual(['object', 'null']);
9
- expect(schema.required).not.toContain('conversationSettings');
7
+ expect(schema.properties).toHaveProperty("conversationSettings");
8
+ expect(schema.properties.conversationSettings.bsonType).toEqual([
9
+ "object",
10
+ "null",
11
+ ]);
12
+ expect(schema.required).not.toContain("conversationSettings");
10
13
  expect(schema.additionalProperties).toBe(false);
11
14
  });
12
15
 
13
- it('defines conversationSettings with expected nested properties', () => {
16
+ it("defines conversationSettings with expected nested properties", () => {
14
17
  const schema: any = flowMongoSchema;
15
18
  const convSettings = schema.properties.conversationSettings.properties;
16
19
 
17
- expect(convSettings).toHaveProperty('interruptions');
18
- expect(convSettings.interruptions.bsonType).toEqual(['object', 'null']);
20
+ expect(convSettings).toHaveProperty("interruptions");
21
+ expect(convSettings.interruptions.bsonType).toEqual(["object", "null"]);
19
22
 
20
23
  const interruptions = convSettings.interruptions.properties;
21
- expect(interruptions.enableInterruptionDetection.bsonType).toEqual('bool');
22
- expect(interruptions.interruptionWindowSeconds.bsonType).toEqual('number');
23
- expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual('number');
24
- expect(interruptions.interruptionInstruction.bsonType).toEqual('string');
24
+ expect(interruptions.enableInterruptionDetection.bsonType).toEqual("bool");
25
+ expect(interruptions.interruptionWindowSeconds.bsonType).toEqual("number");
26
+ expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual(
27
+ "number",
28
+ );
29
+ expect(interruptions.interruptionInstruction.bsonType).toEqual("string");
25
30
 
26
- expect(convSettings).toHaveProperty('silence');
27
- expect(convSettings.silence.bsonType).toEqual(['object', 'null']);
31
+ expect(convSettings).toHaveProperty("silence");
32
+ expect(convSettings.silence.bsonType).toEqual(["object", "null"]);
28
33
 
29
34
  const silence = convSettings.silence.properties;
30
- expect(silence.enableSilenceDetection.bsonType).toEqual('bool');
31
- expect(silence.firstWarningSilenceSeconds.bsonType).toEqual('number');
32
- expect(silence.firstWarningInstruction.bsonType).toEqual('string');
33
- expect(silence.secondWarningSilenceSeconds.bsonType).toEqual('number');
34
- expect(silence.secondWarningInstruction.bsonType).toEqual('string');
35
- expect(silence.disconnectSilenceSeconds.bsonType).toEqual('number');
36
- expect(convSettings).toHaveProperty('liveTimeUpdates');
37
- expect(convSettings.liveTimeUpdates.bsonType).toEqual('bool');
35
+ expect(silence.enableSilenceDetection.bsonType).toEqual("bool");
36
+ expect(silence.firstWarningSilenceSeconds.bsonType).toEqual("number");
37
+ expect(silence.firstWarningInstruction.bsonType).toEqual("string");
38
+ expect(silence.secondWarningSilenceSeconds.bsonType).toEqual("number");
39
+ expect(silence.secondWarningInstruction.bsonType).toEqual("string");
40
+ expect(silence.disconnectSilenceSeconds.bsonType).toEqual("number");
41
+ expect(convSettings).toHaveProperty("liveTimeUpdates");
42
+ expect(convSettings.liveTimeUpdates.bsonType).toEqual("bool");
38
43
  });
39
44
 
40
- it('should define tools schema and return a backgroundToolType enum with allowed values', () => {
45
+ it("should define tools schema and return a backgroundToolType enum with allowed values", () => {
41
46
  const schema: any = flowMongoSchema;
42
47
 
43
- expect(schema.properties).toHaveProperty('tools');
44
- expect(schema.properties.tools.bsonType).toEqual(['array', 'null']);
48
+ expect(schema.properties).toHaveProperty("tools");
49
+ expect(schema.properties.tools.bsonType).toEqual(["array", "null"]);
45
50
 
46
51
  const toolItem = schema.properties.tools.items;
47
- expect(toolItem.bsonType).toBe('object');
52
+ expect(toolItem.bsonType).toBe("object");
48
53
 
49
- expect(toolItem.properties).toHaveProperty('runInBackground');
50
- expect(toolItem.properties.runInBackground.bsonType).toBe('bool');
54
+ expect(toolItem.properties).toHaveProperty("runInBackground");
55
+ expect(toolItem.properties.runInBackground.bsonType).toBe("bool");
51
56
 
52
- expect(toolItem.properties).toHaveProperty('backgroundToolType');
53
- expect(toolItem.properties.backgroundToolType.bsonType).toBe('string');
57
+ expect(toolItem.properties).toHaveProperty("backgroundToolType");
58
+ expect(toolItem.properties.backgroundToolType.bsonType).toBe("string");
54
59
  expect(toolItem.properties.backgroundToolType.enum).toEqual([
55
- 'backgroundToolAlways',
56
- 'backgroundToolOnce',
60
+ "backgroundToolAlways",
61
+ "backgroundToolOnce",
57
62
  ]);
58
63
  });
59
64
  });
60
-
@@ -1,11 +1,14 @@
1
- import type { Collection, ObjectId, WithId } from 'mongodb';
2
- import { getDb } from '../index';
3
- import type { Flow } from './flows.types';
1
+ import type { Collection, ObjectId, WithId } from "mongodb";
2
+ import { getDb } from "../index";
3
+ import type { Flow } from "./flows.types";
4
4
 
5
5
  export const getFlowsCollection = (): Collection<Flow> => {
6
- return getDb().collection<Flow>('flows');
6
+ return getDb().collection<Flow>("flows");
7
7
  };
8
8
 
9
- export const findFlowById = (flowId: ObjectId, clientId: string): Promise<WithId<Flow> | null> => {
9
+ export const findFlowById = (
10
+ flowId: ObjectId,
11
+ clientId: string,
12
+ ): Promise<WithId<Flow> | null> => {
10
13
  return getFlowsCollection().findOne({ _id: flowId, clientId });
11
14
  };
@@ -1,139 +1,147 @@
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
146
  },
139
147
  additionalProperties: false,
@@ -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,17 +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';
76
+ backgroundToolType?: "backgroundToolAlways" | "backgroundToolOnce";
77
77
  };
78
78
 
79
- export type SendMethod = 'sms' | 'whatsapp';
79
+ export type SendMethod = "sms" | "whatsapp";
80
80
 
81
81
  export type SendMessageNode = BaseNode & {
82
- type: 'sendMessage';
82
+ type: "sendMessage";
83
83
  /** Which channel to use. If omitted, decide at runtime (e.g., default to whatsapp). */
84
84
  send_method: SendMethod;
85
85
  /** Destination phone (E.164 or templated string like "{{userPhone}}"). */
@@ -87,17 +87,17 @@ export type SendMessageNode = BaseNode & {
87
87
  };
88
88
 
89
89
  export type ToolNode = BaseNode & {
90
- type: 'tool';
90
+ type: "tool";
91
91
  name: string;
92
92
  text: string;
93
93
  };
94
94
 
95
95
  export type QuestionsListNode = BaseNode & {
96
- type: 'questionsList';
96
+ type: "questionsList";
97
97
  questions: Question[];
98
98
  };
99
99
 
100
- export type EndNode = BaseNode & { type: 'end' };
100
+ export type EndNode = BaseNode & { type: "end" };
101
101
 
102
102
  export type Interaction =
103
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);