@talkpilot/core-db 1.0.1

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 (410) hide show
  1. package/.cursor/rules/development.mdc +65 -0
  2. package/DEVELOPMENT.md +98 -0
  3. package/README.md +140 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +29 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/municipal/cities/cities.getters.d.ts +9 -0
  9. package/dist/municipal/cities/cities.getters.d.ts.map +1 -0
  10. package/dist/municipal/cities/cities.getters.js +38 -0
  11. package/dist/municipal/cities/cities.getters.js.map +1 -0
  12. package/dist/municipal/cities/cities.types.d.ts +10 -0
  13. package/dist/municipal/cities/cities.types.d.ts.map +1 -0
  14. package/dist/municipal/cities/cities.types.js +3 -0
  15. package/dist/municipal/cities/cities.types.js.map +1 -0
  16. package/dist/municipal/cities/index.d.ts +3 -0
  17. package/dist/municipal/cities/index.d.ts.map +1 -0
  18. package/dist/municipal/cities/index.js +18 -0
  19. package/dist/municipal/cities/index.js.map +1 -0
  20. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts +62 -0
  21. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts.map +1 -0
  22. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js +180 -0
  23. package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js.map +1 -0
  24. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts +69 -0
  25. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts.map +1 -0
  26. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.js +3 -0
  27. package/dist/municipal/departmentsSubjects/departmentsSubjects.types.js.map +1 -0
  28. package/dist/municipal/departmentsSubjects/index.d.ts +3 -0
  29. package/dist/municipal/departmentsSubjects/index.d.ts.map +1 -0
  30. package/dist/municipal/departmentsSubjects/index.js +18 -0
  31. package/dist/municipal/departmentsSubjects/index.js.map +1 -0
  32. package/dist/municipal/index.d.ts +10 -0
  33. package/dist/municipal/index.d.ts.map +1 -0
  34. package/dist/municipal/index.js +37 -0
  35. package/dist/municipal/index.js.map +1 -0
  36. package/dist/municipal/mongodb-client.d.ts +13 -0
  37. package/dist/municipal/mongodb-client.d.ts.map +1 -0
  38. package/dist/municipal/mongodb-client.js +56 -0
  39. package/dist/municipal/mongodb-client.js.map +1 -0
  40. package/dist/municipal/streets/index.d.ts +3 -0
  41. package/dist/municipal/streets/index.d.ts.map +1 -0
  42. package/dist/municipal/streets/index.js +18 -0
  43. package/dist/municipal/streets/index.js.map +1 -0
  44. package/dist/municipal/streets/streets.getters.d.ts +21 -0
  45. package/dist/municipal/streets/streets.getters.d.ts.map +1 -0
  46. package/dist/municipal/streets/streets.getters.js +85 -0
  47. package/dist/municipal/streets/streets.getters.js.map +1 -0
  48. package/dist/municipal/streets/streets.types.d.ts +16 -0
  49. package/dist/municipal/streets/streets.types.d.ts.map +1 -0
  50. package/dist/municipal/streets/streets.types.js +3 -0
  51. package/dist/municipal/streets/streets.types.js.map +1 -0
  52. package/dist/municipal/tickets/index.d.ts +3 -0
  53. package/dist/municipal/tickets/index.d.ts.map +1 -0
  54. package/dist/municipal/tickets/index.js +18 -0
  55. package/dist/municipal/tickets/index.js.map +1 -0
  56. package/dist/municipal/tickets/tickets.getters.d.ts +44 -0
  57. package/dist/municipal/tickets/tickets.getters.d.ts.map +1 -0
  58. package/dist/municipal/tickets/tickets.getters.js +199 -0
  59. package/dist/municipal/tickets/tickets.getters.js.map +1 -0
  60. package/dist/municipal/tickets/tickets.types.d.ts +35 -0
  61. package/dist/municipal/tickets/tickets.types.d.ts.map +1 -0
  62. package/dist/municipal/tickets/tickets.types.js +3 -0
  63. package/dist/municipal/tickets/tickets.types.js.map +1 -0
  64. package/dist/talkpilot/agents/agents.getters.d.ts +9 -0
  65. package/dist/talkpilot/agents/agents.getters.d.ts.map +1 -0
  66. package/dist/talkpilot/agents/agents.getters.js +34 -0
  67. package/dist/talkpilot/agents/agents.getters.js.map +1 -0
  68. package/dist/talkpilot/agents/agents.types.d.ts +13 -0
  69. package/dist/talkpilot/agents/agents.types.d.ts.map +1 -0
  70. package/dist/talkpilot/agents/agents.types.js +3 -0
  71. package/dist/talkpilot/agents/agents.types.js.map +1 -0
  72. package/dist/talkpilot/agents/index.d.ts +3 -0
  73. package/dist/talkpilot/agents/index.d.ts.map +1 -0
  74. package/dist/talkpilot/agents/index.js +19 -0
  75. package/dist/talkpilot/agents/index.js.map +1 -0
  76. package/dist/talkpilot/calls/calls.getters.d.ts +24 -0
  77. package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -0
  78. package/dist/talkpilot/calls/calls.getters.js +151 -0
  79. package/dist/talkpilot/calls/calls.getters.js.map +1 -0
  80. package/dist/talkpilot/calls/calls.types.d.ts +32 -0
  81. package/dist/talkpilot/calls/calls.types.d.ts.map +1 -0
  82. package/dist/talkpilot/calls/calls.types.js +3 -0
  83. package/dist/talkpilot/calls/calls.types.js.map +1 -0
  84. package/dist/talkpilot/calls/index.d.ts +3 -0
  85. package/dist/talkpilot/calls/index.d.ts.map +1 -0
  86. package/dist/talkpilot/calls/index.js +19 -0
  87. package/dist/talkpilot/calls/index.js.map +1 -0
  88. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts +9 -0
  89. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts.map +1 -0
  90. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js +76 -0
  91. package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js.map +1 -0
  92. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts +23 -0
  93. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts.map +1 -0
  94. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.js +3 -0
  95. package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.js.map +1 -0
  96. package/dist/talkpilot/clients/clients.getters.d.ts +5 -0
  97. package/dist/talkpilot/clients/clients.getters.d.ts.map +1 -0
  98. package/dist/talkpilot/clients/clients.getters.js +14 -0
  99. package/dist/talkpilot/clients/clients.getters.js.map +1 -0
  100. package/dist/talkpilot/clients/clients.types.d.ts +12 -0
  101. package/dist/talkpilot/clients/clients.types.d.ts.map +1 -0
  102. package/dist/talkpilot/clients/clients.types.js +3 -0
  103. package/dist/talkpilot/clients/clients.types.js.map +1 -0
  104. package/dist/talkpilot/clients/index.d.ts +3 -0
  105. package/dist/talkpilot/clients/index.d.ts.map +1 -0
  106. package/dist/talkpilot/clients/index.js +18 -0
  107. package/dist/talkpilot/clients/index.js.map +1 -0
  108. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +7 -0
  109. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -0
  110. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +21 -0
  111. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -0
  112. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +53 -0
  113. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -0
  114. package/dist/talkpilot/clientsConfig/clientsConfig.types.js +3 -0
  115. package/dist/talkpilot/clientsConfig/clientsConfig.types.js.map +1 -0
  116. package/dist/talkpilot/clientsConfig/index.d.ts +3 -0
  117. package/dist/talkpilot/clientsConfig/index.d.ts.map +1 -0
  118. package/dist/talkpilot/clientsConfig/index.js +19 -0
  119. package/dist/talkpilot/clientsConfig/index.js.map +1 -0
  120. package/dist/talkpilot/flows/flows.getter.d.ts +5 -0
  121. package/dist/talkpilot/flows/flows.getter.d.ts.map +1 -0
  122. package/dist/talkpilot/flows/flows.getter.js +13 -0
  123. package/dist/talkpilot/flows/flows.getter.js.map +1 -0
  124. package/dist/talkpilot/flows/flows.schema.d.ts +154 -0
  125. package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -0
  126. package/dist/talkpilot/flows/flows.schema.js +94 -0
  127. package/dist/talkpilot/flows/flows.schema.js.map +1 -0
  128. package/dist/talkpilot/flows/flows.types.d.ts +116 -0
  129. package/dist/talkpilot/flows/flows.types.d.ts.map +1 -0
  130. package/dist/talkpilot/flows/flows.types.js +3 -0
  131. package/dist/talkpilot/flows/flows.types.js.map +1 -0
  132. package/dist/talkpilot/flows/index.d.ts +3 -0
  133. package/dist/talkpilot/flows/index.d.ts.map +1 -0
  134. package/dist/talkpilot/flows/index.js +6 -0
  135. package/dist/talkpilot/flows/index.js.map +1 -0
  136. package/dist/talkpilot/groups/groups.getters.d.ts +8 -0
  137. package/dist/talkpilot/groups/groups.getters.d.ts.map +1 -0
  138. package/dist/talkpilot/groups/groups.getters.js +26 -0
  139. package/dist/talkpilot/groups/groups.getters.js.map +1 -0
  140. package/dist/talkpilot/groups/groups.types.d.ts +26 -0
  141. package/dist/talkpilot/groups/groups.types.d.ts.map +1 -0
  142. package/dist/talkpilot/groups/groups.types.js +3 -0
  143. package/dist/talkpilot/groups/groups.types.js.map +1 -0
  144. package/dist/talkpilot/groups/index.d.ts +3 -0
  145. package/dist/talkpilot/groups/index.d.ts.map +1 -0
  146. package/dist/talkpilot/groups/index.js +19 -0
  147. package/dist/talkpilot/groups/index.js.map +1 -0
  148. package/dist/talkpilot/groups/phone.utils.d.ts +4 -0
  149. package/dist/talkpilot/groups/phone.utils.d.ts.map +1 -0
  150. package/dist/talkpilot/groups/phone.utils.js +42 -0
  151. package/dist/talkpilot/groups/phone.utils.js.map +1 -0
  152. package/dist/talkpilot/index.d.ts +19 -0
  153. package/dist/talkpilot/index.d.ts.map +1 -0
  154. package/dist/talkpilot/index.js +46 -0
  155. package/dist/talkpilot/index.js.map +1 -0
  156. package/dist/talkpilot/leads/index.d.ts +3 -0
  157. package/dist/talkpilot/leads/index.d.ts.map +1 -0
  158. package/dist/talkpilot/leads/index.js +6 -0
  159. package/dist/talkpilot/leads/index.js.map +1 -0
  160. package/dist/talkpilot/leads/leads.getter.d.ts +4 -0
  161. package/dist/talkpilot/leads/leads.getter.d.ts.map +1 -0
  162. package/dist/talkpilot/leads/leads.getter.js +7 -0
  163. package/dist/talkpilot/leads/leads.getter.js.map +1 -0
  164. package/dist/talkpilot/leads/leads.schema.d.ts +50 -0
  165. package/dist/talkpilot/leads/leads.schema.d.ts.map +1 -0
  166. package/dist/talkpilot/leads/leads.schema.js +37 -0
  167. package/dist/talkpilot/leads/leads.schema.js.map +1 -0
  168. package/dist/talkpilot/leads/leads.types.d.ts +18 -0
  169. package/dist/talkpilot/leads/leads.types.d.ts.map +1 -0
  170. package/dist/talkpilot/leads/leads.types.js +3 -0
  171. package/dist/talkpilot/leads/leads.types.js.map +1 -0
  172. package/dist/talkpilot/mongodb-client.d.ts +13 -0
  173. package/dist/talkpilot/mongodb-client.d.ts.map +1 -0
  174. package/dist/talkpilot/mongodb-client.js +71 -0
  175. package/dist/talkpilot/mongodb-client.js.map +1 -0
  176. package/dist/talkpilot/phone_numbers/index.d.ts +3 -0
  177. package/dist/talkpilot/phone_numbers/index.d.ts.map +1 -0
  178. package/dist/talkpilot/phone_numbers/index.js +18 -0
  179. package/dist/talkpilot/phone_numbers/index.js.map +1 -0
  180. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +8 -0
  181. package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -0
  182. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +44 -0
  183. package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -0
  184. package/dist/talkpilot/phone_numbers/phone_numbers.schema.d.ts +29 -0
  185. package/dist/talkpilot/phone_numbers/phone_numbers.schema.d.ts.map +1 -0
  186. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +18 -0
  187. package/dist/talkpilot/phone_numbers/phone_numbers.schema.js.map +1 -0
  188. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +16 -0
  189. package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -0
  190. package/dist/talkpilot/phone_numbers/phone_numbers.types.js +3 -0
  191. package/dist/talkpilot/phone_numbers/phone_numbers.types.js.map +1 -0
  192. package/dist/talkpilot/plans/index.d.ts +3 -0
  193. package/dist/talkpilot/plans/index.d.ts.map +1 -0
  194. package/dist/talkpilot/plans/index.js +19 -0
  195. package/dist/talkpilot/plans/index.js.map +1 -0
  196. package/dist/talkpilot/plans/plans.getters.d.ts +10 -0
  197. package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -0
  198. package/dist/talkpilot/plans/plans.getters.js +103 -0
  199. package/dist/talkpilot/plans/plans.getters.js.map +1 -0
  200. package/dist/talkpilot/plans/plans.types.d.ts +53 -0
  201. package/dist/talkpilot/plans/plans.types.d.ts.map +1 -0
  202. package/dist/talkpilot/plans/plans.types.js +29 -0
  203. package/dist/talkpilot/plans/plans.types.js.map +1 -0
  204. package/dist/talkpilot/results/index.d.ts +3 -0
  205. package/dist/talkpilot/results/index.d.ts.map +1 -0
  206. package/dist/talkpilot/results/index.js +6 -0
  207. package/dist/talkpilot/results/index.js.map +1 -0
  208. package/dist/talkpilot/results/results.getter.d.ts +7 -0
  209. package/dist/talkpilot/results/results.getter.d.ts.map +1 -0
  210. package/dist/talkpilot/results/results.getter.js +26 -0
  211. package/dist/talkpilot/results/results.getter.js.map +1 -0
  212. package/dist/talkpilot/results/results.schema.d.ts +35 -0
  213. package/dist/talkpilot/results/results.schema.d.ts.map +1 -0
  214. package/dist/talkpilot/results/results.schema.js +29 -0
  215. package/dist/talkpilot/results/results.schema.js.map +1 -0
  216. package/dist/talkpilot/results/results.types.d.ts +34 -0
  217. package/dist/talkpilot/results/results.types.d.ts.map +1 -0
  218. package/dist/talkpilot/results/results.types.js +3 -0
  219. package/dist/talkpilot/results/results.types.js.map +1 -0
  220. package/dist/talkpilot/sessions/index.d.ts +3 -0
  221. package/dist/talkpilot/sessions/index.d.ts.map +1 -0
  222. package/dist/talkpilot/sessions/index.js +6 -0
  223. package/dist/talkpilot/sessions/index.js.map +1 -0
  224. package/dist/talkpilot/sessions/sessions.getter.d.ts +7 -0
  225. package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -0
  226. package/dist/talkpilot/sessions/sessions.getter.js +26 -0
  227. package/dist/talkpilot/sessions/sessions.getter.js.map +1 -0
  228. package/dist/talkpilot/sessions/sessions.schema.d.ts +53 -0
  229. package/dist/talkpilot/sessions/sessions.schema.d.ts.map +1 -0
  230. package/dist/talkpilot/sessions/sessions.schema.js +38 -0
  231. package/dist/talkpilot/sessions/sessions.schema.js.map +1 -0
  232. package/dist/talkpilot/sessions/sessions.types.d.ts +22 -0
  233. package/dist/talkpilot/sessions/sessions.types.d.ts.map +1 -0
  234. package/dist/talkpilot/sessions/sessions.types.js +3 -0
  235. package/dist/talkpilot/sessions/sessions.types.js.map +1 -0
  236. package/dist/talkpilot/subscriptions/index.d.ts +4 -0
  237. package/dist/talkpilot/subscriptions/index.d.ts.map +1 -0
  238. package/dist/talkpilot/subscriptions/index.js +20 -0
  239. package/dist/talkpilot/subscriptions/index.js.map +1 -0
  240. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +13 -0
  241. package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -0
  242. package/dist/talkpilot/subscriptions/subscriptions.getters.js +105 -0
  243. package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -0
  244. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +8 -0
  245. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -0
  246. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js +27 -0
  247. package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -0
  248. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +50 -0
  249. package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -0
  250. package/dist/talkpilot/subscriptions/subscriptions.types.js +14 -0
  251. package/dist/talkpilot/subscriptions/subscriptions.types.js.map +1 -0
  252. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +4 -0
  253. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +1 -0
  254. package/dist/talkpilot/subscriptions/subscriptions.utils.js +20 -0
  255. package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +1 -0
  256. package/dist/test-utils/db-utils.d.ts +4 -0
  257. package/dist/test-utils/db-utils.d.ts.map +1 -0
  258. package/dist/test-utils/db-utils.js +28 -0
  259. package/dist/test-utils/db-utils.js.map +1 -0
  260. package/dist/test-utils/factories/index.d.ts +13 -0
  261. package/dist/test-utils/factories/index.d.ts.map +1 -0
  262. package/dist/test-utils/factories/index.js +29 -0
  263. package/dist/test-utils/factories/index.js.map +1 -0
  264. package/dist/test-utils/factories/municipal/cities.d.ts +5 -0
  265. package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -0
  266. package/dist/test-utils/factories/municipal/cities.js +18 -0
  267. package/dist/test-utils/factories/municipal/cities.js.map +1 -0
  268. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +5 -0
  269. package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -0
  270. package/dist/test-utils/factories/municipal/departmentsSubjects.js +27 -0
  271. package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -0
  272. package/dist/test-utils/factories/municipal/streets.d.ts +5 -0
  273. package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -0
  274. package/dist/test-utils/factories/municipal/streets.js +19 -0
  275. package/dist/test-utils/factories/municipal/streets.js.map +1 -0
  276. package/dist/test-utils/factories/municipal/tickets.d.ts +5 -0
  277. package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -0
  278. package/dist/test-utils/factories/municipal/tickets.js +27 -0
  279. package/dist/test-utils/factories/municipal/tickets.js.map +1 -0
  280. package/dist/test-utils/factories/talkpilot/agents.d.ts +5 -0
  281. package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -0
  282. package/dist/test-utils/factories/talkpilot/agents.js +21 -0
  283. package/dist/test-utils/factories/talkpilot/agents.js.map +1 -0
  284. package/dist/test-utils/factories/talkpilot/calls.d.ts +6 -0
  285. package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -0
  286. package/dist/test-utils/factories/talkpilot/calls.js +39 -0
  287. package/dist/test-utils/factories/talkpilot/calls.js.map +1 -0
  288. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +5 -0
  289. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -0
  290. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +18 -0
  291. package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -0
  292. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +5 -0
  293. package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -0
  294. package/dist/test-utils/factories/talkpilot/clientsConfig.js +18 -0
  295. package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -0
  296. package/dist/test-utils/factories/talkpilot/flows.d.ts +14 -0
  297. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -0
  298. package/dist/test-utils/factories/talkpilot/flows.js +33 -0
  299. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -0
  300. package/dist/test-utils/factories/talkpilot/groups.d.ts +6 -0
  301. package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -0
  302. package/dist/test-utils/factories/talkpilot/groups.js +34 -0
  303. package/dist/test-utils/factories/talkpilot/groups.js.map +1 -0
  304. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +16 -0
  305. package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -0
  306. package/dist/test-utils/factories/talkpilot/phone_numbers.js +20 -0
  307. package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -0
  308. package/dist/test-utils/factories/talkpilot/sessions.d.ts +5 -0
  309. package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -0
  310. package/dist/test-utils/factories/talkpilot/sessions.js +37 -0
  311. package/dist/test-utils/factories/talkpilot/sessions.js.map +1 -0
  312. package/dist/utils/validation.d.ts +7 -0
  313. package/dist/utils/validation.d.ts.map +1 -0
  314. package/dist/utils/validation.js +23 -0
  315. package/dist/utils/validation.js.map +1 -0
  316. package/jest.config.js +22 -0
  317. package/package.json +43 -0
  318. package/src/__tests__/setup.ts +20 -0
  319. package/src/index.ts +13 -0
  320. package/src/municipal/__tests__/validation.spec.ts +50 -0
  321. package/src/municipal/cities/cities.getters.ts +44 -0
  322. package/src/municipal/cities/cities.types.ts +11 -0
  323. package/src/municipal/cities/index.ts +2 -0
  324. package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +273 -0
  325. package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +76 -0
  326. package/src/municipal/departmentsSubjects/index.ts +11 -0
  327. package/src/municipal/index.ts +18 -0
  328. package/src/municipal/mongodb-client.ts +58 -0
  329. package/src/municipal/streets/index.ts +2 -0
  330. package/src/municipal/streets/streets.getters.ts +105 -0
  331. package/src/municipal/streets/streets.types.ts +18 -0
  332. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +30 -0
  333. package/src/municipal/tickets/index.ts +2 -0
  334. package/src/municipal/tickets/tickets.getters.ts +234 -0
  335. package/src/municipal/tickets/tickets.types.ts +39 -0
  336. package/src/talkpilot/__tests__/db.spec.ts +38 -0
  337. package/src/talkpilot/__tests__/mongodb-client.spec.ts +19 -0
  338. package/src/talkpilot/__tests__/validation.spec.ts +62 -0
  339. package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +29 -0
  340. package/src/talkpilot/agents/agents.getters.ts +34 -0
  341. package/src/talkpilot/agents/agents.types.ts +14 -0
  342. package/src/talkpilot/agents/index.ts +2 -0
  343. package/src/talkpilot/calls/__tests__/calls.spec.ts +56 -0
  344. package/src/talkpilot/calls/calls.getters.ts +134 -0
  345. package/src/talkpilot/calls/calls.types.ts +45 -0
  346. package/src/talkpilot/calls/index.ts +2 -0
  347. package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +78 -0
  348. package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +101 -0
  349. package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +25 -0
  350. package/src/talkpilot/clients/clients.getters.ts +11 -0
  351. package/src/talkpilot/clients/clients.types.ts +12 -0
  352. package/src/talkpilot/clients/index.ts +2 -0
  353. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +28 -0
  354. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +20 -0
  355. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +55 -0
  356. package/src/talkpilot/clientsConfig/index.ts +2 -0
  357. package/src/talkpilot/flows/flows.getter.ts +11 -0
  358. package/src/talkpilot/flows/flows.schema.ts +90 -0
  359. package/src/talkpilot/flows/flows.types.ts +151 -0
  360. package/src/talkpilot/flows/index.ts +2 -0
  361. package/src/talkpilot/groups/__tests__/groups.spec.ts +83 -0
  362. package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +32 -0
  363. package/src/talkpilot/groups/groups.getters.ts +27 -0
  364. package/src/talkpilot/groups/groups.types.ts +29 -0
  365. package/src/talkpilot/groups/index.ts +2 -0
  366. package/src/talkpilot/groups/phone.utils.ts +40 -0
  367. package/src/talkpilot/index.ts +27 -0
  368. package/src/talkpilot/leads/index.ts +2 -0
  369. package/src/talkpilot/leads/leads.getter.ts +5 -0
  370. package/src/talkpilot/leads/leads.schema.ts +33 -0
  371. package/src/talkpilot/leads/leads.types.ts +20 -0
  372. package/src/talkpilot/mongodb-client.ts +78 -0
  373. package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +43 -0
  374. package/src/talkpilot/phone_numbers/index.ts +2 -0
  375. package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +47 -0
  376. package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +14 -0
  377. package/src/talkpilot/phone_numbers/phone_numbers.types.ts +15 -0
  378. package/src/talkpilot/plans/index.ts +2 -0
  379. package/src/talkpilot/plans/plans.getters.ts +121 -0
  380. package/src/talkpilot/plans/plans.types.ts +84 -0
  381. package/src/talkpilot/results/index.ts +2 -0
  382. package/src/talkpilot/results/results.getter.ts +26 -0
  383. package/src/talkpilot/results/results.schema.ts +25 -0
  384. package/src/talkpilot/results/results.types.ts +32 -0
  385. package/src/talkpilot/sessions/__tests__/sessions.spec.ts +43 -0
  386. package/src/talkpilot/sessions/index.ts +2 -0
  387. package/src/talkpilot/sessions/sessions.getter.ts +28 -0
  388. package/src/talkpilot/sessions/sessions.schema.ts +34 -0
  389. package/src/talkpilot/sessions/sessions.types.ts +28 -0
  390. package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +42 -0
  391. package/src/talkpilot/subscriptions/index.ts +3 -0
  392. package/src/talkpilot/subscriptions/subscriptions.getters.ts +147 -0
  393. package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +26 -0
  394. package/src/talkpilot/subscriptions/subscriptions.types.ts +65 -0
  395. package/src/test-utils/db-utils.ts +24 -0
  396. package/src/test-utils/factories/index.ts +12 -0
  397. package/src/test-utils/factories/municipal/cities.ts +16 -0
  398. package/src/test-utils/factories/municipal/departmentsSubjects.ts +29 -0
  399. package/src/test-utils/factories/municipal/streets.ts +17 -0
  400. package/src/test-utils/factories/municipal/tickets.ts +27 -0
  401. package/src/test-utils/factories/talkpilot/agents.ts +19 -0
  402. package/src/test-utils/factories/talkpilot/calls.ts +37 -0
  403. package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +18 -0
  404. package/src/test-utils/factories/talkpilot/clientsConfig.ts +19 -0
  405. package/src/test-utils/factories/talkpilot/flows.ts +31 -0
  406. package/src/test-utils/factories/talkpilot/groups.ts +33 -0
  407. package/src/test-utils/factories/talkpilot/phone_numbers.ts +20 -0
  408. package/src/test-utils/factories/talkpilot/sessions.ts +35 -0
  409. package/src/utils/validation.ts +23 -0
  410. package/tsconfig.json +27 -0
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: Development standards and conventions for the core-db package
3
+ globs: src/**/*.ts
4
+ alwaysApply: true
5
+ ---
6
+
7
+ # Development Standards
8
+
9
+ This package provides a centralized database layer for multiple domains (TalkPilot and Municipal). Follow these rules to maintain consistency and reliability.
10
+
11
+ ## Project Structure
12
+
13
+ - **`src/talkpilot/`**: All database logic, types, and getters related to the TalkPilot domain.
14
+ - **`src/municipal/`**: All database logic, types, and getters related to the Municipal Data domain.
15
+ - **`src/test-utils/`**: Shared testing infrastructure, including factories and database utilities.
16
+
17
+ ## Database Connection Pattern
18
+
19
+ Each domain is isolated. They have their own `db` instance and must be connected independently.
20
+
21
+ ```typescript
22
+ import { mongodbClient, municipalDataMongodbClient } from '@talk-pilot/core-db';
23
+
24
+ // TalkPilot
25
+ await mongodbClient.connect(uri);
26
+
27
+ // Municipal
28
+ await municipalDataMongodbClient.connect(uri);
29
+ ```
30
+
31
+ ## Creating New Getters
32
+
33
+ 1. **Location**: Place getters in the relevant domain folder (e.g., `src/talkpilot/agents/agents.getters.ts`).
34
+ 2. **Naming**: Use `find...` for multiple results and `get...ById` for single results.
35
+ 3. **Domain isolation**: Always use the `getDb()` function from the current domain's `index.ts`.
36
+
37
+ ## Environment Validation
38
+
39
+ Always validate configuration "on-demand" within the `connect` methods using the validation utilities.
40
+
41
+ ```typescript
42
+ import { validateConfig, validateMongoUri } from '../utils/validation';
43
+
44
+ async connect(uri?: string) {
45
+ const mongodbUri = uri || process.env.MONGO_URI;
46
+ validateConfig('MONGO_URI', mongodbUri);
47
+ validateMongoUri(mongodbUri!);
48
+ // ... connection logic
49
+ }
50
+ ```
51
+
52
+ ## Testing Standards
53
+
54
+ 1. **In-Memory DB**: Use `mongodb-memory-server` for all tests. It is automatically initialized in `src/__tests__/setup.ts`.
55
+ 2. **Factories**: Use the Fishery factories in `src/test-utils/factories/` to generate test data.
56
+ 3. **Organization**: Place tests in a `__tests__` folder within the relevant domain.
57
+
58
+ ```typescript
59
+ import { createAgent } from '../../../test-utils/factories';
60
+
61
+ it('should find agents', async () => {
62
+ const agent = createAgent({ name: 'Test' });
63
+ // ... test logic
64
+ });
65
+ ```
package/DEVELOPMENT.md ADDED
@@ -0,0 +1,98 @@
1
+ # Development Guide
2
+
3
+ Welcome to the `core-db` development guide. This document explains how to set up, develop, and test this package.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js (v18 or later)
10
+ - TypeScript
11
+
12
+ ### Setup
13
+
14
+ 1. Install dependencies:
15
+ ```bash
16
+ npm install
17
+ ```
18
+
19
+ 2. Build the project:
20
+ ```bash
21
+ npm run build
22
+ ```
23
+
24
+ ## Local Development
25
+
26
+ If you want to use this package in another project locally without publishing it:
27
+
28
+ 1. In the `core-db` folder:
29
+ ```bash
30
+ npm link
31
+ ```
32
+
33
+ 2. In your PROJECT folder:
34
+ ```bash
35
+ npm link @talk-pilot/core-db
36
+ ```
37
+
38
+ ## Adding a New Getter
39
+
40
+ 1. **Define Types**: Add your data types in the relevant domain's `types.ts` file.
41
+ 2. **Implement Getter**: Add the function in the `getters.ts` file.
42
+ 3. **Export**: Ensure the getter is exported from the domain's `index.ts` and finally from the main `src/index.ts`.
43
+ 4. **Test**: Create a test in the domain's `__tests__` folder.
44
+
45
+ ## Testing
46
+
47
+ We use Jest with `mongodb-memory-server` for fast, isolated database tests.
48
+
49
+ ### Running Tests
50
+
51
+ ```bash
52
+ npm test
53
+ ```
54
+
55
+ ### Using Factories
56
+
57
+ Always use factories to generate test data to keep tests clean and maintainable.
58
+
59
+ ```typescript
60
+ import { createCallDoc } from '../calls.getters';
61
+ import { createOutGoingCallDoc } from '../../../test-utils/factories';
62
+
63
+ it('should save a call', async () => {
64
+ const call = createOutGoingCallDoc({ callSid: 'CA123' });
65
+ await createCallDoc(call);
66
+ // ... assertions
67
+ });
68
+ ```
69
+
70
+ ## Build Process
71
+
72
+ The project is built using TypeScript (`tsc`). The output is generated in the `dist/` directory.
73
+
74
+ - `main`: `dist/index.js`
75
+ - `types`: `dist/index.d.ts`
76
+
77
+ The `prepare` script in `package.json` ensures that the project is built automatically when installed via a Git URL.
78
+
79
+ ## Team Access & Authentication
80
+
81
+ To allow the whole team to publish and install without adding individual npm accounts, we use a shared **npm Granular Access Token**.
82
+
83
+ ### One-time Local Setup
84
+
85
+ Each developer needs to add the shared token to their local npm configuration. Do **NOT** add this to the project's `.npmrc` file, as it will be committed to Git.
86
+
87
+ 1. Get the shared **npm Automation Token**.
88
+ 2. Open (or create) your global npm configuration file:
89
+ ```bash
90
+ nano ~/.npmrc
91
+ ```
92
+ 3. Add the following line (replace `[TOKEN]` with the actual token):
93
+ ```text
94
+ //registry.npmjs.org/:_authToken=[TOKEN]
95
+ ```
96
+ 4. Save and exit.
97
+
98
+ Now you can run `npm publish` and `npm install` for scoped `@talk-pilot` packages without being prompted for credentials.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # @talk-pilot/core-db
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@talk-pilot/core-db)](https://www.npmjs.com/package/@talk-pilot/core-db)
4
+
5
+ A TypeScript-based core database management package designed to provide centralized database connections, ORM integrations, and client utilities for other projects. This package manages connections to both **TalkPilot** and **Municipal** MongoDB databases.
6
+
7
+ ## Features
8
+
9
+ - 🚀 **Multi-Domain Database Management**: Centralized handlers for both TalkPilot and Municipal Data domains.
10
+ - 📦 **Reusable Getters**: Standardized functions for fetching data from various collections (calls, agents, leads, cities, etc.).
11
+ - 🏗️ **Type-safe**: Built with TypeScript for full type safety across all your database interactions.
12
+ - 🛠️ **Environment Aware**: Configurable via environment variables or explicit parameters.
13
+
14
+ ## Installation
15
+
16
+ This package is intended to be used as a dependency in other projects. If you're working locally, you can install it using a file path:
17
+
18
+ ```bash
19
+ # In your other project:
20
+ npm install /path/to/core-db
21
+ # or if published to a registry:
22
+ npm install @talk-pilot/core-db
23
+ # or via GitHub (ensure you have built or have a prepare script)
24
+ npm install github:Talk-Pilot/core-db
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ### 1. Initialize Database Connections
30
+
31
+ You must initialize the database clients before using any of the getters.
32
+
33
+ ```typescript
34
+ import { mongodbClient, municipalDataMongodbClient } from '@talk-pilot/core-db';
35
+
36
+ async function bootstrap() {
37
+ // Initialize TalkPilot DB
38
+ await mongodbClient.connect(process.env.TALKPILOT_MONGO_URI);
39
+
40
+ // Initialize Municipal Data DB (optional)
41
+ await municipalDataMongodbClient.connect(process.env.MUNICIPAL_MONGO_URI);
42
+ }
43
+
44
+ bootstrap().catch(console.error);
45
+ ```
46
+
47
+ ### 2. Using Getters
48
+
49
+ Once initialized, you can import and use any of the exported database getters.
50
+
51
+ ```typescript
52
+ import { findAgents, findCities } from '@talk-pilot/core-db';
53
+
54
+ async function getSummary() {
55
+ // Get all agents from TalkPilot DB
56
+ const agents = await findAgents();
57
+ console.log('Total Agents:', agents.length);
58
+
59
+ // Get all cities from Municipal Data DB
60
+ const cities = await findCities();
61
+ console.log('Total Cities:', cities.length);
62
+ }
63
+ ```
64
+
65
+ ## Available Domains
66
+
67
+ The package exports two main sets of tools:
68
+
69
+ ### TalkPilot Domain
70
+ Includes access to:
71
+ - `agents`, `calls`, `clients`, `flows`, `leads`, `phone_numbers`, `plans`, `results`, `sessions`, `subscriptions`, etc.
72
+ - Exported as root level functions or via `mongodbClient`.
73
+
74
+ ### Municipal Domain
75
+ Includes access to:
76
+ - `cities`, `streets`, `departmentsSubjects`, `tickets`.
77
+ - Functions are prefixed where necessary or accessible via `getMunicipalDataDb`.
78
+
79
+ ## Environment Variables
80
+
81
+ The clients will automatically attempt to use the following environment variables if no URI is provided to the `connect()` method:
82
+
83
+ - `MONGO_URI` or `MONGODB_URI`: Primary MongoDB connection string.
84
+ - `MONGODB_DB_NAME`: Database name (defaults to 'municipal-data' for the municipal client if not specified).
85
+
86
+ ## Development
87
+
88
+ ### Setup
89
+
90
+ 1. Clone the repository and install dependencies:
91
+ ```bash
92
+ git clone https://github.com/Talk-Pilot/core-db.git
93
+ cd core-db
94
+ npm install
95
+ ```
96
+
97
+ 2. Build the project:
98
+ ```bash
99
+ npm run build
100
+ ```
101
+
102
+ This will generate the `dist/` directory with the compiled JavaScript and type definitions.
103
+
104
+ ### Publishing New Versions
105
+
106
+ To publish a new version of the package:
107
+
108
+ 1. **Test your changes**:
109
+ ```bash
110
+ npm test
111
+ ```
112
+
113
+ 2. **Update the version**:
114
+ ```bash
115
+ # Bumps patch version (0.1.0 -> 0.1.1)
116
+ npm version patch
117
+ # Or for minor changes (0.1.0 -> 0.2.0)
118
+ # npm version minor
119
+ # Or for major changes (0.1.0 -> 1.0.0)
120
+ # npm version major
121
+ ```
122
+
123
+ 3. **Publish to npm**:
124
+ Ensure you have the shared team token in your `~/.npmrc` (see [Development Guide](./DEVELOPMENT.md#team-access--authentication)).
125
+ ```bash
126
+ npm publish
127
+ ```
128
+
129
+ 4. **Update in other repos**:
130
+ ```bash
131
+ npm update @talk-pilot/core-db
132
+ ```
133
+
134
+ ## License
135
+
136
+ MIT
137
+
138
+ ---
139
+
140
+ **Interested in contributing?** Check out our [Development Guide](./DEVELOPMENT.md) for standards and setup instructions.
@@ -0,0 +1,7 @@
1
+ export * from './talkpilot';
2
+ export { municipalDataMongodbClient, getDb as getMunicipalDataDb, setDb as setMunicipalDataDb, ObjectId as MunicipalDataObjectId, } from './municipal';
3
+ export * from './municipal/cities';
4
+ export * from './municipal/streets';
5
+ export * from './municipal/departmentsSubjects';
6
+ export * from './municipal/tickets';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,EAC3B,QAAQ,IAAI,qBAAqB,GAClC,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.MunicipalDataObjectId = exports.setMunicipalDataDb = exports.getMunicipalDataDb = exports.municipalDataMongodbClient = void 0;
18
+ // TalkPilot DB exports
19
+ __exportStar(require("./talkpilot"), exports);
20
+ var municipal_1 = require("./municipal");
21
+ Object.defineProperty(exports, "municipalDataMongodbClient", { enumerable: true, get: function () { return municipal_1.municipalDataMongodbClient; } });
22
+ Object.defineProperty(exports, "getMunicipalDataDb", { enumerable: true, get: function () { return municipal_1.getDb; } });
23
+ Object.defineProperty(exports, "setMunicipalDataDb", { enumerable: true, get: function () { return municipal_1.setDb; } });
24
+ Object.defineProperty(exports, "MunicipalDataObjectId", { enumerable: true, get: function () { return municipal_1.ObjectId; } });
25
+ __exportStar(require("./municipal/cities"), exports);
26
+ __exportStar(require("./municipal/streets"), exports);
27
+ __exportStar(require("./municipal/departmentsSubjects"), exports);
28
+ __exportStar(require("./municipal/tickets"), exports);
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,8CAA4B;AAE5B,yCAKqB;AAJnB,uHAAA,0BAA0B,OAAA;AAC1B,+GAAA,KAAK,OAAsB;AAC3B,+GAAA,KAAK,OAAsB;AAC3B,kHAAA,QAAQ,OAAyB;AAEnC,qDAAmC;AACnC,sDAAoC;AACpC,kEAAgD;AAChD,sDAAoC"}
@@ -0,0 +1,9 @@
1
+ import { City } from '../index';
2
+ import { Collection, Filter, ObjectId as MongoObjectId } from 'mongodb';
3
+ export declare const getCitiesCollection: () => Collection<City>;
4
+ export declare const findCities: (filter?: Filter<City>) => Promise<City[]>;
5
+ export declare const getCityById: (cityId: string) => Promise<City | null>;
6
+ export declare const createCity: (cityData: Omit<City, "_id" | "createdAt" | "updatedAt">) => Promise<MongoObjectId>;
7
+ export declare const updateCity: (cityId: string, data: Partial<Omit<City, "_id" | "createdAt" | "updatedAt">>) => Promise<City | null>;
8
+ export declare const deleteCity: (cityId: string) => Promise<boolean>;
9
+ //# sourceMappingURL=cities.getters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cities.getters.d.ts","sourceRoot":"","sources":["../../../src/municipal/cities/cities.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAExE,eAAO,MAAM,mBAAmB,QAAO,UAAU,CAAC,IAAI,CAErD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,SAAQ,MAAM,CAAC,IAAI,CAAM,KAAG,OAAO,CAAC,IAAI,EAAE,CAE1E,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAGrE,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,UAAU,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC,KACtD,OAAO,CAAC,aAAa,CAQvB,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,QAAQ,MAAM,EACd,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC,KAC3D,OAAO,CAAC,IAAI,GAAG,IAAI,CAOrB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAGhE,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteCity = exports.updateCity = exports.createCity = exports.getCityById = exports.findCities = exports.getCitiesCollection = void 0;
4
+ const index_1 = require("../index");
5
+ const getCitiesCollection = () => {
6
+ return (0, index_1.getDb)().collection('cities');
7
+ };
8
+ exports.getCitiesCollection = getCitiesCollection;
9
+ const findCities = async (filter = {}) => {
10
+ return await (0, exports.getCitiesCollection)().find(filter).toArray();
11
+ };
12
+ exports.findCities = findCities;
13
+ const getCityById = async (cityId) => {
14
+ const city = await (0, exports.getCitiesCollection)().findOne({ _id: new index_1.ObjectId(cityId) });
15
+ return city ? city : null;
16
+ };
17
+ exports.getCityById = getCityById;
18
+ const createCity = async (cityData) => {
19
+ const city = {
20
+ ...cityData,
21
+ createdAt: new Date(),
22
+ updatedAt: new Date(),
23
+ };
24
+ const { insertedId } = await (0, exports.getCitiesCollection)().insertOne(city);
25
+ return insertedId;
26
+ };
27
+ exports.createCity = createCity;
28
+ const updateCity = async (cityId, data) => {
29
+ const result = await (0, exports.getCitiesCollection)().findOneAndUpdate({ _id: new index_1.ObjectId(cityId) }, { $set: { ...data, updatedAt: new Date() } }, { returnDocument: 'after' });
30
+ return result || null;
31
+ };
32
+ exports.updateCity = updateCity;
33
+ const deleteCity = async (cityId) => {
34
+ const result = await (0, exports.getCitiesCollection)().deleteOne({ _id: new index_1.ObjectId(cityId) });
35
+ return result.deletedCount > 0;
36
+ };
37
+ exports.deleteCity = deleteCity;
38
+ //# sourceMappingURL=cities.getters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cities.getters.js","sourceRoot":"","sources":["../../../src/municipal/cities/cities.getters.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AAG1C,MAAM,mBAAmB,GAAG,GAAqB,EAAE;IACxD,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAO,QAAQ,CAAC,CAAC;AAC5C,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEK,MAAM,UAAU,GAAG,KAAK,EAAE,SAAuB,EAAE,EAAmB,EAAE;IAC7E,OAAO,MAAM,IAAA,2BAAmB,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,MAAM,WAAW,GAAG,KAAK,EAAE,MAAc,EAAwB,EAAE;IACxE,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAmB,GAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChF,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB;AAEK,MAAM,UAAU,GAAG,KAAK,EAC7B,QAAuD,EAC/B,EAAE;IAC1B,MAAM,IAAI,GAAsB;QAC9B,GAAG,QAAQ;QACX,SAAS,EAAE,IAAI,IAAI,EAAE;QACrB,SAAS,EAAE,IAAI,IAAI,EAAE;KACtB,CAAC;IACF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,2BAAmB,GAAE,CAAC,SAAS,CAAC,IAAY,CAAC,CAAC;IAC3E,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB;AAEK,MAAM,UAAU,GAAG,KAAK,EAC7B,MAAc,EACd,IAA4D,EACtC,EAAE;IACxB,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAmB,GAAE,CAAC,gBAAgB,CACzD,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,MAAM,CAAC,EAAE,EAC7B,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAC5C,EAAE,cAAc,EAAE,OAAO,EAAE,CAC5B,CAAC;IACF,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB;AAEK,MAAM,UAAU,GAAG,KAAK,EAAE,MAAc,EAAoB,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAmB,GAAE,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpF,OAAO,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB"}
@@ -0,0 +1,10 @@
1
+ import { ObjectId, WithId } from 'mongodb';
2
+ export type City = {
3
+ _id: ObjectId;
4
+ createdAt: Date;
5
+ updatedAt: Date;
6
+ name: string;
7
+ displayName: string;
8
+ };
9
+ export type CityDoc = WithId<City>;
10
+ //# sourceMappingURL=cities.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cities.types.d.ts","sourceRoot":"","sources":["../../../src/municipal/cities/cities.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,QAAQ,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=cities.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cities.types.js","sourceRoot":"","sources":["../../../src/municipal/cities/cities.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './cities.getters';
2
+ export type { City, CityDoc } from './cities.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/municipal/cities/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cities.getters"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/municipal/cities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -0,0 +1,62 @@
1
+ import { DepartmentSubject } from '../index';
2
+ import { Collection, Filter } from 'mongodb';
3
+ import { CityName, VectorSearchResult } from './departmentsSubjects.types';
4
+ export declare const getDepartmentsSubjectsCollection: () => Collection<DepartmentSubject>;
5
+ /**
6
+ * Get all departments subjects for a given city.
7
+ * No DB sort; tree build does not depend on order. Callers that need alphabetical order
8
+ * sort in memory (e.g. sortTreeAlphabetically in full-tree-subjects.service).
9
+ * @param cityName - City name to filter subjects
10
+ * @param withEmbeddings - Whether to include embedding and embedding_model fields (default: false)
11
+ * @returns Array of all department subjects for the city
12
+ */
13
+ export declare const getAllDepartmentsSubjectsByCity: (cityName: CityName, withEmbeddings?: boolean) => Promise<DepartmentSubject[]>;
14
+ /**
15
+ * Perform vector search on departmentsSubjects collection
16
+ * @param queryVector - The embedding vector to search with
17
+ * @param cityName - City name to filter results
18
+ * @param limit - Maximum number of results (default: 5)
19
+ * @param numCandidates - Number of candidates to consider (default: 800)
20
+ * @returns Array of vector search results
21
+ */
22
+ export declare const vectorSearchDepartmentsSubjects: (queryVector: number[], cityName: CityName, limit?: number, numCandidates?: number) => Promise<VectorSearchResult[]>;
23
+ export declare const addDepartmentSubjectInstruction: (filter: Filter<DepartmentSubject>, instructionText: string) => Promise<DepartmentSubject | null>;
24
+ export declare const updateDepartmentSubjectInstruction: (filter: Filter<DepartmentSubject>, instructionId: number, newInstructionText: string) => Promise<DepartmentSubject | null>;
25
+ export declare const removeDepartmentSubjectInstruction: (filter: Filter<DepartmentSubject>, instructionId: number) => Promise<DepartmentSubject | null>;
26
+ export declare const addDepartmentSubjectCommunication: (filter: Filter<DepartmentSubject>, communication: {
27
+ type: "free_text_sms" | "upload_url_sms";
28
+ message_text?: string;
29
+ template_id?: string;
30
+ to?: string;
31
+ }) => Promise<DepartmentSubject | null>;
32
+ export declare const updateDepartmentSubjectCommunication: (filter: Filter<DepartmentSubject>, communicationId: number, updates: {
33
+ type?: "free_text_sms" | "upload_url_sms";
34
+ message_text?: string | null;
35
+ template_id?: string | null;
36
+ to?: string | null;
37
+ is_deleted?: boolean | null;
38
+ }) => Promise<DepartmentSubject | null>;
39
+ export declare const removeDepartmentSubjectCommunication: (filter: Filter<DepartmentSubject>, communicationId: number) => Promise<DepartmentSubject | null>;
40
+ /**
41
+ * Get department subject by subject_id, sub_subject_id, and cityName
42
+ * @param subjectId - Subject ID (from event_subject_id)
43
+ * @param subSubjectId - Sub-subject ID (from event_sub_subject_id, optional)
44
+ * @param cityName - City name to filter results
45
+ * @returns DepartmentSubject document or null if not found
46
+ */
47
+ export declare const getDepartmentSubjectBySubjectIds: (subjectId: string, subSubjectId: string, cityName: CityName) => Promise<DepartmentSubject | null>;
48
+ /**
49
+ * Update or create guidelines field for a department subject
50
+ * @param filter - MongoDB filter to find the document
51
+ * @param guidelines - Guidelines text to set
52
+ * @returns Updated DepartmentSubject document or null if not found
53
+ */
54
+ export declare const updateDepartmentSubjectGuidelines: (filter: Filter<DepartmentSubject>, guidelines: string) => Promise<DepartmentSubject | null>;
55
+ /**
56
+ * Clear guidelines field from a department subject document (sets it to null)
57
+ * @param filter - MongoDB filter to find the document
58
+ * @returns Updated DepartmentSubject document or null if not found
59
+ */
60
+ export declare const deleteDepartmentSubjectGuidelines: (filter: Filter<DepartmentSubject>) => Promise<DepartmentSubject | null>;
61
+ export declare const findSubjectByQuery: (query: Partial<DepartmentSubject>) => Promise<import("mongodb").WithId<DepartmentSubject> | null>;
62
+ //# sourceMappingURL=departmentsSubjects.getters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"departmentsSubjects.getters.d.ts","sourceRoot":"","sources":["../../../src/municipal/departmentsSubjects/departmentsSubjects.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,eAAO,MAAM,gCAAgC,QAAO,UAAU,CAAC,iBAAiB,CAE/E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAC1C,UAAU,QAAQ,EAClB,iBAAgB,OAAe,KAC9B,OAAO,CAAC,iBAAiB,EAAE,CAW7B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAC1C,aAAa,MAAM,EAAE,EACrB,UAAU,QAAQ,EAClB,QAAO,MAAU,EACjB,gBAAe,MAAY,KAC1B,OAAO,CAAC,kBAAkB,EAAE,CAgC9B,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,iBAAiB,MAAM,KACtB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAgBlC,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,eAAe,MAAM,EACrB,oBAAoB,MAAM,KACzB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAQlC,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,eAAe,MAAM,KACpB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAWlC,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,eAAe;IACb,IAAI,EAAE,eAAe,GAAG,gBAAgB,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,KACA,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAoBlC,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAC/C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,iBAAiB,MAAM,EACvB,SAAS;IACP,IAAI,CAAC,EAAE,eAAe,GAAG,gBAAgB,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B,KACA,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAkBlC,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAC/C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,iBAAiB,MAAM,KACtB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAWlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAC3C,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,UAAU,QAAQ,KACjB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAelC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,GAC5C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,EACjC,YAAY,MAAM,KACjB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAQlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAC5C,QAAQ,MAAM,CAAC,iBAAiB,CAAC,KAChC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAQlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,OAAO,OAAO,CAAC,iBAAiB,CAAC,gEAEzE,CAAC"}