@talkpilot/core-db 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/dist/connection.d.ts +1 -1
  2. package/dist/connection.d.ts.map +1 -1
  3. package/dist/connection.js +24 -21
  4. package/dist/connection.js.map +1 -1
  5. package/dist/index.d.ts +9 -9
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/municipal/cities/cities.getters.d.ts +2 -2
  9. package/dist/municipal/cities/cities.getters.d.ts.map +1 -1
  10. package/dist/municipal/cities/cities.getters.js +4 -8
  11. package/dist/municipal/cities/cities.getters.js.map +1 -1
  12. package/dist/municipal/cities/cities.types.d.ts +1 -1
  13. package/dist/municipal/cities/index.d.ts +2 -2
  14. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts +3 -3
  15. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts.map +1 -1
  16. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js +22 -30
  17. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js.map +1 -1
  18. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts +4 -4
  19. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts.map +1 -1
  20. package/dist/municipal/departmentsSubjects/index.d.ts +2 -2
  21. package/dist/municipal/index.d.ts +8 -8
  22. package/dist/municipal/index.d.ts.map +1 -1
  23. package/dist/municipal/index.js +1 -1
  24. package/dist/municipal/mongodb-client.d.ts +1 -1
  25. package/dist/municipal/mongodb-client.d.ts.map +1 -1
  26. package/dist/municipal/mongodb-client.js +25 -13
  27. package/dist/municipal/mongodb-client.js.map +1 -1
  28. package/dist/municipal/streets/index.d.ts +2 -2
  29. package/dist/municipal/streets/streets.getters.d.ts +3 -3
  30. package/dist/municipal/streets/streets.getters.d.ts.map +1 -1
  31. package/dist/municipal/streets/streets.getters.js +9 -19
  32. package/dist/municipal/streets/streets.getters.js.map +1 -1
  33. package/dist/municipal/streets/streets.types.d.ts +1 -1
  34. package/dist/municipal/systemInstructions/index.d.ts +3 -3
  35. package/dist/municipal/systemInstructions/index.d.ts.map +1 -1
  36. package/dist/municipal/systemInstructions/instructions.getters.d.ts +3 -3
  37. package/dist/municipal/systemInstructions/instructions.getters.d.ts.map +1 -1
  38. package/dist/municipal/systemInstructions/instructions.getters.js +4 -10
  39. package/dist/municipal/systemInstructions/instructions.getters.js.map +1 -1
  40. package/dist/municipal/systemInstructions/instructions.setters.d.ts +2 -2
  41. package/dist/municipal/systemInstructions/instructions.setters.d.ts.map +1 -1
  42. package/dist/municipal/systemInstructions/instructions.setters.js +8 -13
  43. package/dist/municipal/systemInstructions/instructions.setters.js.map +1 -1
  44. package/dist/municipal/systemInstructions/instructions.types.d.ts +3 -3
  45. package/dist/municipal/systemInstructions/instructions.types.d.ts.map +1 -1
  46. package/dist/municipal/systemInstructions/instructions.types.js +6 -6
  47. package/dist/municipal/tickets/index.d.ts +2 -2
  48. package/dist/municipal/tickets/tickets.getters.d.ts +3 -3
  49. package/dist/municipal/tickets/tickets.getters.d.ts.map +1 -1
  50. package/dist/municipal/tickets/tickets.getters.js +29 -50
  51. package/dist/municipal/tickets/tickets.getters.js.map +1 -1
  52. package/dist/municipal/tickets/tickets.types.d.ts +1 -1
  53. package/dist/municipal/tickets/tickets.types.d.ts.map +1 -1
  54. package/dist/municipal/utils/types.d.ts +1 -1
  55. package/dist/municipal/utils/types.d.ts.map +1 -1
  56. package/dist/talkpilot/agents/agents.getters.d.ts +1 -1
  57. package/dist/talkpilot/agents/agents.getters.js +2 -2
  58. package/dist/talkpilot/agents/agents.types.d.ts +2 -2
  59. package/dist/talkpilot/agents/index.d.ts +2 -2
  60. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts +2 -2
  61. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts.map +1 -1
  62. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js +1 -1
  63. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js.map +1 -1
  64. package/dist/talkpilot/backgroundToolResults/backgroundToolResults.types.d.ts +2 -2
  65. package/dist/talkpilot/backgroundToolResults/index.d.ts +2 -2
  66. package/dist/talkpilot/calls/calls.getters.d.ts +3 -3
  67. package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
  68. package/dist/talkpilot/calls/calls.getters.js +15 -19
  69. package/dist/talkpilot/calls/calls.getters.js.map +1 -1
  70. package/dist/talkpilot/calls/calls.types.d.ts +3 -3
  71. package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
  72. package/dist/talkpilot/calls/calls.types.js +2 -2
  73. package/dist/talkpilot/calls/index.d.ts +2 -2
  74. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts +2 -2
  75. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts.map +1 -1
  76. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js +2 -2
  77. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js.map +1 -1
  78. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts +2 -2
  79. package/dist/talkpilot/clientAudioBuffers/index.d.ts +2 -2
  80. package/dist/talkpilot/clients/clients.getters.d.ts +2 -2
  81. package/dist/talkpilot/clients/clients.getters.d.ts.map +1 -1
  82. package/dist/talkpilot/clients/clients.getters.js +2 -5
  83. package/dist/talkpilot/clients/clients.getters.js.map +1 -1
  84. package/dist/talkpilot/clients/clients.types.d.ts +1 -1
  85. package/dist/talkpilot/clients/index.d.ts +2 -2
  86. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +2 -2
  87. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
  88. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +1 -1
  89. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
  90. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +3 -3
  91. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
  92. package/dist/talkpilot/clientsConfig/index.d.ts +2 -2
  93. package/dist/talkpilot/flows/flows.getter.d.ts +2 -2
  94. package/dist/talkpilot/flows/flows.getter.d.ts.map +1 -1
  95. package/dist/talkpilot/flows/flows.getter.js +1 -1
  96. package/dist/talkpilot/flows/flows.getter.js.map +1 -1
  97. package/dist/talkpilot/flows/flows.schema.d.ts +3 -0
  98. package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
  99. package/dist/talkpilot/flows/flows.schema.js +80 -87
  100. package/dist/talkpilot/flows/flows.schema.js.map +1 -1
  101. package/dist/talkpilot/flows/flows.types.d.ts +17 -16
  102. package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
  103. package/dist/talkpilot/flows/index.d.ts +2 -2
  104. package/dist/talkpilot/groups/groups.getters.d.ts +2 -2
  105. package/dist/talkpilot/groups/groups.getters.d.ts.map +1 -1
  106. package/dist/talkpilot/groups/groups.getters.js +2 -2
  107. package/dist/talkpilot/groups/groups.getters.js.map +1 -1
  108. package/dist/talkpilot/groups/groups.types.d.ts +1 -1
  109. package/dist/talkpilot/groups/index.d.ts +3 -3
  110. package/dist/talkpilot/groups/phone.utils.d.ts +1 -1
  111. package/dist/talkpilot/groups/phone.utils.d.ts.map +1 -1
  112. package/dist/talkpilot/groups/phone.utils.js +2 -2
  113. package/dist/talkpilot/groups/phone.utils.js.map +1 -1
  114. package/dist/talkpilot/index.d.ts +16 -16
  115. package/dist/talkpilot/index.js +1 -1
  116. package/dist/talkpilot/leads/index.d.ts +2 -2
  117. package/dist/talkpilot/leads/leads.getter.d.ts +2 -2
  118. package/dist/talkpilot/leads/leads.getter.d.ts.map +1 -1
  119. package/dist/talkpilot/leads/leads.getter.js +1 -1
  120. package/dist/talkpilot/leads/leads.getter.js.map +1 -1
  121. package/dist/talkpilot/leads/leads.schema.js +16 -16
  122. package/dist/talkpilot/leads/leads.types.d.ts +1 -1
  123. package/dist/talkpilot/mongodb-client.d.ts +1 -1
  124. package/dist/talkpilot/mongodb-client.d.ts.map +1 -1
  125. package/dist/talkpilot/mongodb-client.js +29 -16
  126. package/dist/talkpilot/mongodb-client.js.map +1 -1
  127. package/dist/talkpilot/phone_numbers/index.d.ts +2 -2
  128. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +3 -3
  129. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
  130. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +13 -28
  131. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
  132. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +9 -9
  133. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +1 -1
  134. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -1
  135. package/dist/talkpilot/plans/index.d.ts +2 -2
  136. package/dist/talkpilot/plans/plans.getters.d.ts +2 -2
  137. package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -1
  138. package/dist/talkpilot/plans/plans.getters.js +3 -3
  139. package/dist/talkpilot/plans/plans.getters.js.map +1 -1
  140. package/dist/talkpilot/plans/plans.types.d.ts +4 -4
  141. package/dist/talkpilot/plans/plans.types.d.ts.map +1 -1
  142. package/dist/talkpilot/plans/plans.types.js +19 -19
  143. package/dist/talkpilot/results/index.d.ts +2 -2
  144. package/dist/talkpilot/results/index.d.ts.map +1 -1
  145. package/dist/talkpilot/results/index.js.map +1 -1
  146. package/dist/talkpilot/results/results.getter.d.ts +3 -3
  147. package/dist/talkpilot/results/results.getter.d.ts.map +1 -1
  148. package/dist/talkpilot/results/results.getter.js +4 -4
  149. package/dist/talkpilot/results/results.getter.js.map +1 -1
  150. package/dist/talkpilot/results/results.schema.js +18 -18
  151. package/dist/talkpilot/results/results.types.d.ts +1 -1
  152. package/dist/talkpilot/sessions/index.d.ts +2 -2
  153. package/dist/talkpilot/sessions/sessions.getter.d.ts +3 -3
  154. package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -1
  155. package/dist/talkpilot/sessions/sessions.getter.js +10 -13
  156. package/dist/talkpilot/sessions/sessions.getter.js.map +1 -1
  157. package/dist/talkpilot/sessions/sessions.schema.js +17 -17
  158. package/dist/talkpilot/sessions/sessions.types.d.ts +2 -2
  159. package/dist/talkpilot/subscriptions/index.d.ts +3 -3
  160. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +2 -2
  161. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -1
  162. package/dist/talkpilot/subscriptions/subscriptions.getters.js +11 -11
  163. package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -1
  164. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +2 -2
  165. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -1
  166. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -1
  167. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +2 -2
  168. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -1
  169. package/dist/talkpilot/subscriptions/subscriptions.types.js +7 -7
  170. package/dist/talkpilot/utils/query.utils.d.ts +1 -1
  171. package/dist/test-utils/db-utils.d.ts +1 -1
  172. package/dist/test-utils/db-utils.js +2 -2
  173. package/dist/test-utils/factories/index.d.ts +12 -12
  174. package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
  175. package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
  176. package/dist/test-utils/factories/municipal/cities.js +1 -1
  177. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
  178. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
  179. package/dist/test-utils/factories/municipal/departmentsSubjects.js +1 -7
  180. package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
  181. package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
  182. package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
  183. package/dist/test-utils/factories/municipal/streets.js +1 -6
  184. package/dist/test-utils/factories/municipal/streets.js.map +1 -1
  185. package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
  186. package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
  187. package/dist/test-utils/factories/municipal/tickets.js +1 -7
  188. package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
  189. package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
  190. package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
  191. package/dist/test-utils/factories/talkpilot/agents.js +4 -4
  192. package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
  193. package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
  194. package/dist/test-utils/factories/talkpilot/calls.js +1 -1
  195. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
  196. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
  197. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
  198. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
  199. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
  200. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
  201. package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
  202. package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
  203. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
  204. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
  205. package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
  206. package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
  207. package/dist/test-utils/factories/talkpilot/groups.js +9 -9
  208. package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
  209. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
  210. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
  211. package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
  212. package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
  213. package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
  214. package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
  215. package/dist/utils/validation.js +2 -2
  216. package/dist/utils/validation.js.map +1 -1
  217. package/package.json +1 -3
  218. package/src/__tests__/setup.ts +3 -3
  219. package/src/connection.ts +25 -27
  220. package/src/index.ts +9 -9
  221. package/src/municipal/__tests__/validation.spec.ts +23 -35
  222. package/src/municipal/cities/cities.getters.ts +10 -16
  223. package/src/municipal/cities/cities.types.ts +1 -1
  224. package/src/municipal/cities/index.ts +2 -2
  225. package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +44 -53
  226. package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
  227. package/src/municipal/departmentsSubjects/index.ts +3 -2
  228. package/src/municipal/index.ts +10 -10
  229. package/src/municipal/mongodb-client.ts +26 -19
  230. package/src/municipal/streets/index.ts +2 -2
  231. package/src/municipal/streets/streets.getters.ts +23 -43
  232. package/src/municipal/streets/streets.types.ts +1 -1
  233. package/src/municipal/systemInstructions/__tests__/getters.spec.ts +52 -67
  234. package/src/municipal/systemInstructions/__tests__/setters.spec.ts +238 -271
  235. package/src/municipal/systemInstructions/index.ts +3 -7
  236. package/src/municipal/systemInstructions/instructions.getters.ts +18 -30
  237. package/src/municipal/systemInstructions/instructions.setters.ts +19 -43
  238. package/src/municipal/systemInstructions/instructions.types.ts +10 -10
  239. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
  240. package/src/municipal/tickets/index.ts +2 -2
  241. package/src/municipal/tickets/tickets.getters.ts +42 -69
  242. package/src/municipal/tickets/tickets.types.ts +2 -2
  243. package/src/municipal/utils/types.ts +3 -8
  244. package/src/talkpilot/__tests__/db.spec.ts +12 -12
  245. package/src/talkpilot/__tests__/mongodb-client.spec.ts +8 -7
  246. package/src/talkpilot/__tests__/validation.spec.ts +24 -30
  247. package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
  248. package/src/talkpilot/agents/agents.getters.ts +3 -3
  249. package/src/talkpilot/agents/agents.types.ts +2 -2
  250. package/src/talkpilot/agents/index.ts +2 -2
  251. package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +31 -42
  252. package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
  253. package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +3 -2
  254. package/src/talkpilot/backgroundToolResults/index.ts +2 -2
  255. package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
  256. package/src/talkpilot/calls/__tests__/calls.spec.ts +39 -79
  257. package/src/talkpilot/calls/calls.getters.ts +28 -48
  258. package/src/talkpilot/calls/calls.types.ts +16 -16
  259. package/src/talkpilot/calls/index.ts +2 -2
  260. package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +39 -73
  261. package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +11 -18
  262. package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
  263. package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
  264. package/src/talkpilot/clients/clients.getters.ts +5 -10
  265. package/src/talkpilot/clients/clients.types.ts +1 -1
  266. package/src/talkpilot/clients/index.ts +2 -2
  267. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +18 -21
  268. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +4 -6
  269. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +8 -10
  270. package/src/talkpilot/clientsConfig/index.ts +2 -2
  271. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +37 -38
  272. package/src/talkpilot/flows/flows.getter.ts +5 -8
  273. package/src/talkpilot/flows/flows.schema.ts +80 -87
  274. package/src/talkpilot/flows/flows.types.ts +24 -23
  275. package/src/talkpilot/flows/index.ts +2 -2
  276. package/src/talkpilot/groups/__tests__/groups.spec.ts +27 -34
  277. package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
  278. package/src/talkpilot/groups/groups.getters.ts +5 -8
  279. package/src/talkpilot/groups/groups.types.ts +1 -1
  280. package/src/talkpilot/groups/index.ts +3 -3
  281. package/src/talkpilot/groups/phone.utils.ts +6 -12
  282. package/src/talkpilot/index.ts +17 -17
  283. package/src/talkpilot/leads/index.ts +2 -2
  284. package/src/talkpilot/leads/leads.getter.ts +4 -5
  285. package/src/talkpilot/leads/leads.schema.ts +16 -16
  286. package/src/talkpilot/leads/leads.types.ts +1 -1
  287. package/src/talkpilot/mongodb-client.ts +33 -23
  288. package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +44 -84
  289. package/src/talkpilot/phone_numbers/index.ts +2 -2
  290. package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +22 -44
  291. package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +9 -9
  292. package/src/talkpilot/phone_numbers/phone_numbers.types.ts +1 -1
  293. package/src/talkpilot/plans/__tests__/plans.spec.ts +26 -30
  294. package/src/talkpilot/plans/index.ts +2 -2
  295. package/src/talkpilot/plans/plans.getters.ts +18 -25
  296. package/src/talkpilot/plans/plans.types.ts +23 -27
  297. package/src/talkpilot/results/index.ts +2 -5
  298. package/src/talkpilot/results/results.getter.ts +8 -9
  299. package/src/talkpilot/results/results.schema.ts +18 -18
  300. package/src/talkpilot/results/results.types.ts +1 -1
  301. package/src/talkpilot/sessions/__tests__/sessions.spec.ts +41 -65
  302. package/src/talkpilot/sessions/index.ts +2 -2
  303. package/src/talkpilot/sessions/sessions.getter.ts +16 -21
  304. package/src/talkpilot/sessions/sessions.schema.ts +17 -17
  305. package/src/talkpilot/sessions/sessions.types.ts +2 -2
  306. package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +15 -18
  307. package/src/talkpilot/subscriptions/index.ts +3 -3
  308. package/src/talkpilot/subscriptions/subscriptions.getters.ts +33 -36
  309. package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +3 -10
  310. package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
  311. package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
  312. package/src/talkpilot/utils/query.utils.ts +2 -2
  313. package/src/test-utils/db-utils.ts +5 -5
  314. package/src/test-utils/factories/index.ts +12 -12
  315. package/src/test-utils/factories/municipal/cities.ts +5 -5
  316. package/src/test-utils/factories/municipal/departmentsSubjects.ts +25 -32
  317. package/src/test-utils/factories/municipal/streets.ts +5 -10
  318. package/src/test-utils/factories/municipal/tickets.ts +6 -12
  319. package/src/test-utils/factories/talkpilot/agents.ts +8 -8
  320. package/src/test-utils/factories/talkpilot/calls.ts +5 -5
  321. package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +12 -14
  322. package/src/test-utils/factories/talkpilot/clientsConfig.ts +8 -7
  323. package/src/test-utils/factories/talkpilot/flows.ts +5 -7
  324. package/src/test-utils/factories/talkpilot/groups.ts +13 -13
  325. package/src/test-utils/factories/talkpilot/phone_numbers.ts +6 -8
  326. package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
  327. package/src/utils/validation.ts +4 -4
  328. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +0 -4
  329. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +0 -1
  330. package/dist/talkpilot/subscriptions/subscriptions.utils.js +0 -20
  331. package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +0 -1
@@ -1,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,6 +72,4 @@ export type ClientConfig<P extends Products = Products> = {
72
72
  communications?: CommunicationsConfig;
73
73
  };
74
74
 
75
- export type ClientConfigDoc<P extends Products = Products> = WithId<
76
- ClientConfig<P>
77
- >;
75
+ export type ClientConfigDoc<P extends Products = Products> = WithId<ClientConfig<P>>;
@@ -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,64 +1,63 @@
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([
9
- "object",
10
- "null",
11
- ]);
12
- expect(schema.required).not.toContain("conversationSettings");
7
+ expect(schema.properties).toHaveProperty('conversationSettings');
8
+ expect(schema.properties.conversationSettings.bsonType).toEqual(['object', 'null']);
9
+ expect(schema.required).not.toContain('conversationSettings');
13
10
  expect(schema.additionalProperties).toBe(false);
14
11
  });
15
12
 
16
- it("defines conversationSettings with expected nested properties", () => {
13
+ it('defines conversationSettings with expected nested properties', () => {
17
14
  const schema: any = flowMongoSchema;
18
15
  const convSettings = schema.properties.conversationSettings.properties;
19
16
 
20
- expect(convSettings).toHaveProperty("interruptions");
21
- expect(convSettings.interruptions.bsonType).toEqual(["object", "null"]);
17
+ expect(convSettings).toHaveProperty('interruptions');
18
+ expect(convSettings.interruptions.bsonType).toEqual(['object', 'null']);
22
19
 
23
20
  const interruptions = convSettings.interruptions.properties;
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");
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');
30
25
 
31
- expect(convSettings).toHaveProperty("silence");
32
- expect(convSettings.silence.bsonType).toEqual(["object", "null"]);
26
+ expect(convSettings).toHaveProperty('silence');
27
+ expect(convSettings.silence.bsonType).toEqual(['object', 'null']);
33
28
 
34
29
  const silence = convSettings.silence.properties;
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");
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');
43
38
  });
44
39
 
45
- it("should define tools schema and return a backgroundToolType enum with allowed values", () => {
40
+ it('should define tools schema and return a backgroundToolType enum with allowed values', () => {
46
41
  const schema: any = flowMongoSchema;
47
42
 
48
- expect(schema.properties).toHaveProperty("tools");
49
- expect(schema.properties.tools.bsonType).toEqual(["array", "null"]);
43
+ expect(schema.properties).toHaveProperty('tools');
44
+ expect(schema.properties.tools.bsonType).toEqual(['array', 'null']);
50
45
 
51
46
  const toolItem = schema.properties.tools.items;
52
- expect(toolItem.bsonType).toBe("object");
47
+ expect(toolItem.bsonType).toBe('object');
53
48
 
54
- expect(toolItem.properties).toHaveProperty("runInBackground");
55
- expect(toolItem.properties.runInBackground.bsonType).toBe("bool");
49
+ expect(toolItem.properties).toHaveProperty('runInBackground');
50
+ expect(toolItem.properties.runInBackground.bsonType).toBe('bool');
56
51
 
57
- expect(toolItem.properties).toHaveProperty("backgroundToolType");
58
- expect(toolItem.properties.backgroundToolType.bsonType).toBe("string");
52
+ expect(toolItem.properties).toHaveProperty('backgroundToolType');
53
+ expect(toolItem.properties.backgroundToolType.bsonType).toBe('string');
59
54
  expect(toolItem.properties.backgroundToolType.enum).toEqual([
60
- "backgroundToolAlways",
61
- "backgroundToolOnce",
55
+ 'backgroundToolAlways',
56
+ 'backgroundToolOnce',
62
57
  ]);
58
+
59
+ expect(toolItem.properties).toHaveProperty('backgroundContinuationInstructions');
60
+ expect(toolItem.properties.backgroundContinuationInstructions.bsonType).toBe('string');
63
61
  });
64
62
  });
63
+
@@ -1,14 +1,11 @@
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 = (
10
- flowId: ObjectId,
11
- clientId: string,
12
- ): Promise<WithId<Flow> | null> => {
9
+ export const findFlowById = (flowId: ObjectId, clientId: string): Promise<WithId<Flow> | null> => {
13
10
  return getFlowsCollection().findOne({ _id: flowId, clientId });
14
11
  };
@@ -1,148 +1,141 @@
1
1
  export const flowMongoSchema = {
2
- bsonType: "object",
3
- required: [
4
- "flowName",
5
- "systemInstructions",
6
- "initialSentence",
7
- "interactions",
8
- ],
2
+ bsonType: 'object',
3
+ required: ['flowName', 'systemInstructions', 'initialSentence', 'interactions'],
9
4
  properties: {
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"] },
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'] },
16
11
  conversationSettings: {
17
- bsonType: ["object", "null"],
12
+ bsonType: ['object', 'null'],
18
13
  properties: {
19
14
  interruptions: {
20
- bsonType: ["object", "null"],
15
+ bsonType: ['object', 'null'],
21
16
  properties: {
22
- enableInterruptionDetection: { bsonType: "bool" },
23
- interruptionWindowSeconds: { bsonType: "number" },
24
- interruptionThresholdSeconds: { bsonType: "number" },
25
- interruptionInstruction: { bsonType: "string" },
17
+ enableInterruptionDetection: { bsonType: 'bool' },
18
+ interruptionWindowSeconds: { bsonType: 'number' },
19
+ interruptionThresholdSeconds: { bsonType: 'number' },
20
+ interruptionInstruction: { bsonType: 'string' },
26
21
  },
27
22
  additionalProperties: false,
28
23
  },
29
24
  silence: {
30
- bsonType: ["object", "null"],
25
+ bsonType: ['object', 'null'],
31
26
  properties: {
32
- enableSilenceDetection: { bsonType: "bool" },
33
- firstWarningSilenceSeconds: { bsonType: "number" },
34
- firstWarningInstruction: { bsonType: "string" },
35
- secondWarningSilenceSeconds: { bsonType: "number" },
36
- secondWarningInstruction: { bsonType: "string" },
37
- disconnectSilenceSeconds: { bsonType: "number" },
27
+ enableSilenceDetection: { bsonType: 'bool' },
28
+ firstWarningSilenceSeconds: { bsonType: 'number' },
29
+ firstWarningInstruction: { bsonType: 'string' },
30
+ secondWarningSilenceSeconds: { bsonType: 'number' },
31
+ secondWarningInstruction: { bsonType: 'string' },
32
+ disconnectSilenceSeconds: { bsonType: 'number' },
38
33
  },
39
34
  additionalProperties: false,
40
35
  },
41
- liveTimeUpdates: { bsonType: "bool" },
36
+ liveTimeUpdates: { bsonType: 'bool' },
42
37
  },
43
38
  additionalProperties: false,
44
39
  },
45
40
  interactions: {
46
- bsonType: "array",
41
+ bsonType: 'array',
47
42
  items: {
48
- bsonType: "object",
49
- required: ["id", "type", "text", "position"],
43
+ bsonType: 'object',
44
+ required: ['id', 'type', 'text', 'position'],
50
45
  properties: {
51
- id: { bsonType: "string" },
52
- type: { bsonType: "string" },
53
- text: { bsonType: "string" },
54
- successStatus: { bsonType: ["string", "null"] },
46
+ id: { bsonType: 'string' },
47
+ type: { bsonType: 'string' },
48
+ text: { bsonType: 'string' },
49
+ successStatus: { bsonType: ['string', 'null'] },
55
50
  conditions: {
56
- bsonType: ["array", "null"],
51
+ bsonType: ['array', 'null'],
57
52
  items: {
58
- bsonType: "object",
59
- required: ["conditionString"],
53
+ bsonType: 'object',
54
+ required: ['conditionString'],
60
55
  properties: {
61
- conditionString: { bsonType: "string" },
62
- nodeType: { bsonType: ["string", "null"] },
63
- id: { bsonType: ["string", "null"] },
56
+ conditionString: { bsonType: 'string' },
57
+ nodeType: { bsonType: ['string', 'null'] },
58
+ id: { bsonType: ['string', 'null'] },
64
59
  },
65
60
  },
66
61
  },
67
- defaultNodeType: { bsonType: ["string", "null"] },
62
+ defaultNodeType: { bsonType: ['string', 'null'] },
68
63
  defaultChild: {
69
- bsonType: ["object", "null"],
70
- properties: { id: { bsonType: "string" } },
64
+ bsonType: ['object', 'null'],
65
+ properties: { id: { bsonType: 'string' } },
71
66
  },
72
67
  position: {
73
- bsonType: "object",
74
- required: ["x", "y"],
68
+ bsonType: 'object',
69
+ required: ['x', 'y'],
75
70
  properties: {
76
- x: { bsonType: "number" },
77
- y: { bsonType: "number" },
71
+ x: { bsonType: 'number' },
72
+ y: { bsonType: 'number' },
78
73
  },
79
74
  },
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"] },
75
+ name: { bsonType: ['string', 'null'] },
76
+ children: { bsonType: ['array', 'null'], items: { bsonType: 'string' } },
77
+ resultsLabel: { bsonType: ['string', 'null'] },
78
+ resultsColor: { bsonType: ['string', 'null'] },
87
79
  },
88
80
  },
89
81
  },
90
82
  edges: {
91
- bsonType: ["array", "null"],
83
+ bsonType: ['array', 'null'],
92
84
  items: {
93
- bsonType: "object",
94
- required: ["id", "source", "target"],
85
+ bsonType: 'object',
86
+ required: ['id', 'source', 'target'],
95
87
  properties: {
96
- id: { bsonType: "string" },
97
- source: { bsonType: "string" },
98
- target: { bsonType: "string" },
99
- label: { bsonType: ["string", "null"] },
88
+ id: { bsonType: 'string' },
89
+ source: { bsonType: 'string' },
90
+ target: { bsonType: 'string' },
91
+ label: { bsonType: ['string', 'null'] },
100
92
  },
101
93
  },
102
94
  },
103
95
  metaKeys: {
104
- bsonType: ["array", "null"],
96
+ bsonType: ['array', 'null'],
105
97
  items: {
106
- bsonType: "object",
107
- required: ["key"],
98
+ bsonType: 'object',
99
+ required: ['key'],
108
100
  properties: {
109
- key: { bsonType: "string" },
110
- required: { bsonType: "bool" },
101
+ key: { bsonType: 'string' },
102
+ required: { bsonType: 'bool' },
111
103
  },
112
104
  },
113
105
  },
114
106
  userProperties: {
115
- bsonType: ["array", "null"],
107
+ bsonType: ['array', 'null'],
116
108
  items: {
117
- bsonType: "object",
118
- required: ["name", "description"],
109
+ bsonType: 'object',
110
+ required: ['name', 'description'],
119
111
  properties: {
120
- name: { bsonType: "string" },
121
- description: { bsonType: "string" },
112
+ name: { bsonType: 'string' },
113
+ description: { bsonType: 'string' },
122
114
  },
123
115
  },
124
116
  },
125
117
  tools: {
126
- bsonType: ["array", "null"],
118
+ bsonType: ['array', 'null'],
127
119
  items: {
128
- bsonType: "object",
129
- required: ["id", "name", "url", "method", "parameters"],
120
+ bsonType: 'object',
121
+ required: ['id', 'name', 'url', 'method', 'parameters'],
130
122
  properties: {
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" },
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' },
142
134
  backgroundToolType: {
143
- bsonType: "string",
144
- enum: ["backgroundToolAlways", "backgroundToolOnce"],
135
+ bsonType: 'string',
136
+ enum: ['backgroundToolAlways', 'backgroundToolOnce'],
145
137
  },
138
+ backgroundContinuationInstructions: { bsonType: 'string' },
146
139
  },
147
140
  additionalProperties: false,
148
141
  },
@@ -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,18 @@ 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
+ backgroundContinuationInstructions?: string;
77
78
  };
78
79
 
79
- export type SendMethod = "sms" | "whatsapp";
80
+ export type SendMethod = 'sms' | 'whatsapp';
80
81
 
81
82
  export type SendMessageNode = BaseNode & {
82
- type: "sendMessage";
83
+ type: 'sendMessage';
83
84
  /** Which channel to use. If omitted, decide at runtime (e.g., default to whatsapp). */
84
85
  send_method: SendMethod;
85
86
  /** Destination phone (E.164 or templated string like "{{userPhone}}"). */
@@ -87,17 +88,17 @@ export type SendMessageNode = BaseNode & {
87
88
  };
88
89
 
89
90
  export type ToolNode = BaseNode & {
90
- type: "tool";
91
+ type: 'tool';
91
92
  name: string;
92
93
  text: string;
93
94
  };
94
95
 
95
96
  export type QuestionsListNode = BaseNode & {
96
- type: "questionsList";
97
+ type: 'questionsList';
97
98
  questions: Question[];
98
99
  };
99
100
 
100
- export type EndNode = BaseNode & { type: "end" };
101
+ export type EndNode = BaseNode & { type: 'end' };
101
102
 
102
103
  export type Interaction =
103
104
  | 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,30 +1,27 @@
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({
25
- clientId: faker.string.uuid(),
26
- name: "Group C",
27
- });
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' });
28
25
 
29
26
  await getGroupsCollection().insertMany([g1, g2, gOther]);
30
27
 
@@ -32,29 +29,26 @@ describe("db.groups", () => {
32
29
  const names = result.map((g) => g.name).sort();
33
30
 
34
31
  expect(result).toHaveLength(2);
35
- expect(names).toEqual(["Group A", "Group B"]);
32
+ expect(names).toEqual(['Group A', 'Group B']);
36
33
  });
37
34
  });
38
35
 
39
- describe("createGroup", () => {
40
- it("inserts a group and returns insertedId", async () => {
41
- const toInsert = createGroupDoc({ name: "New Group" });
36
+ describe('createGroup', () => {
37
+ it('inserts a group and returns insertedId', async () => {
38
+ const toInsert = createGroupDoc({ name: 'New Group' });
42
39
 
43
40
  const insertedId = await createGroup(toInsert);
44
41
  expect(insertedId).toBeInstanceOf(ObjectId);
45
42
 
46
43
  const fromDb = await getGroupsCollection().findOne({ _id: insertedId });
47
- expect(fromDb?.name).toBe("New Group");
44
+ expect(fromDb?.name).toBe('New Group');
48
45
  expect(fromDb?.clientId).toBe(toInsert.clientId);
49
46
  });
50
47
  });
51
48
 
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
- });
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' });
58
52
  const { insertedId } = await getGroupsCollection().insertOne(original);
59
53
  const before = await getGroupsCollection().findOne({ _id: insertedId });
60
54
 
@@ -63,22 +57,21 @@ describe("db.groups", () => {
63
57
 
64
58
  const res = await updateGroup(
65
59
  { _id: insertedId },
66
- { name: "After", description: "New desc" },
60
+ { name: 'After', description: 'New desc' }
67
61
  );
68
62
 
69
63
  expect(res?._id).toEqual(insertedId);
70
- expect(res?.name).toBe("After");
71
- expect(res?.description).toBe("New desc");
64
+ expect(res?.name).toBe('After');
65
+ expect(res?.description).toBe('New desc');
72
66
  expect(new Date(res!.updatedAt).getTime()).toBeGreaterThan(
73
- new Date(before!.updatedAt).getTime(),
67
+ new Date(before!.updatedAt).getTime()
74
68
  );
75
69
  });
76
70
  });
77
71
 
78
- describe("removeGroup", () => {
79
- it("removes a group by string id", async () => {
80
- const { insertedId } =
81
- await getGroupsCollection().insertOne(createGroupDoc());
72
+ describe('removeGroup', () => {
73
+ it('removes a group by string id', async () => {
74
+ const { insertedId } = await getGroupsCollection().insertOne(createGroupDoc());
82
75
 
83
76
  const result = await removeGroup(insertedId.toHexString());
84
77
  expect(result.deletedCount).toBe(1);