@open-mercato/core 0.6.5-develop.4384.1.ce2ec6eaaa → 0.6.5-develop.4393.1.de282b5dfd

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 (533) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/dist/generated/entities/channel_ingest_dead_letter/index.js +25 -0
  3. package/dist/generated/entities/channel_ingest_dead_letter/index.js.map +7 -0
  4. package/dist/generated/entities/channel_thread_mapping/index.js +25 -0
  5. package/dist/generated/entities/channel_thread_mapping/index.js.map +7 -0
  6. package/dist/generated/entities/channel_thread_token/index.js +17 -0
  7. package/dist/generated/entities/channel_thread_token/index.js.map +7 -0
  8. package/dist/generated/entities/communication_channel/index.js +43 -0
  9. package/dist/generated/entities/communication_channel/index.js.map +7 -0
  10. package/dist/generated/entities/customer_interaction/index.js +4 -0
  11. package/dist/generated/entities/customer_interaction/index.js.map +2 -2
  12. package/dist/generated/entities/external_conversation/index.js +25 -0
  13. package/dist/generated/entities/external_conversation/index.js.map +7 -0
  14. package/dist/generated/entities/external_message/index.js +25 -0
  15. package/dist/generated/entities/external_message/index.js.map +7 -0
  16. package/dist/generated/entities/integration_credentials/index.js +3 -1
  17. package/dist/generated/entities/integration_credentials/index.js.map +2 -2
  18. package/dist/generated/entities/message/index.js +2 -0
  19. package/dist/generated/entities/message/index.js.map +2 -2
  20. package/dist/generated/entities/message_channel_link/index.js +33 -0
  21. package/dist/generated/entities/message_channel_link/index.js.map +7 -0
  22. package/dist/generated/entities/message_reaction/index.js +25 -0
  23. package/dist/generated/entities/message_reaction/index.js.map +7 -0
  24. package/dist/generated/entities.ids.generated.js +11 -0
  25. package/dist/generated/entities.ids.generated.js.map +2 -2
  26. package/dist/generated/entity-fields-registry.js +117 -0
  27. package/dist/generated/entity-fields-registry.js.map +2 -2
  28. package/dist/helpers/integration/authFixtures.js +2 -1
  29. package/dist/helpers/integration/authFixtures.js.map +2 -2
  30. package/dist/helpers/integration/communicationChannelsFixtures.js +58 -0
  31. package/dist/helpers/integration/communicationChannelsFixtures.js.map +7 -0
  32. package/dist/modules/communication_channels/acl.js +47 -0
  33. package/dist/modules/communication_channels/acl.js.map +7 -0
  34. package/dist/modules/communication_channels/api/delete/channels/[id]/route.js +133 -0
  35. package/dist/modules/communication_channels/api/delete/channels/[id]/route.js.map +7 -0
  36. package/dist/modules/communication_channels/api/delete/messages/[messageId]/reactions/[reactionId]/route.js +113 -0
  37. package/dist/modules/communication_channels/api/delete/messages/[messageId]/reactions/[reactionId]/route.js.map +7 -0
  38. package/dist/modules/communication_channels/api/get/channels/[id]/health/route.js +138 -0
  39. package/dist/modules/communication_channels/api/get/channels/[id]/health/route.js.map +7 -0
  40. package/dist/modules/communication_channels/api/get/channels/[id]/route.js +93 -0
  41. package/dist/modules/communication_channels/api/get/channels/[id]/route.js.map +7 -0
  42. package/dist/modules/communication_channels/api/get/channels/route.js +96 -0
  43. package/dist/modules/communication_channels/api/get/channels/route.js.map +7 -0
  44. package/dist/modules/communication_channels/api/get/me/channels/route.js +82 -0
  45. package/dist/modules/communication_channels/api/get/me/channels/route.js.map +7 -0
  46. package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js +274 -0
  47. package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js.map +7 -0
  48. package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js +168 -0
  49. package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js.map +7 -0
  50. package/dist/modules/communication_channels/api/post/channels/[id]/poll-now/route.js +143 -0
  51. package/dist/modules/communication_channels/api/post/channels/[id]/poll-now/route.js.map +7 -0
  52. package/dist/modules/communication_channels/api/post/channels/[id]/push/register/route.js +127 -0
  53. package/dist/modules/communication_channels/api/post/channels/[id]/push/register/route.js.map +7 -0
  54. package/dist/modules/communication_channels/api/post/channels/[id]/set-primary/route.js +99 -0
  55. package/dist/modules/communication_channels/api/post/channels/[id]/set-primary/route.js.map +7 -0
  56. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +197 -0
  57. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +7 -0
  58. package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js +124 -0
  59. package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js.map +7 -0
  60. package/dist/modules/communication_channels/api/post/messages/[messageId]/reactions/route.js +120 -0
  61. package/dist/modules/communication_channels/api/post/messages/[messageId]/reactions/route.js.map +7 -0
  62. package/dist/modules/communication_channels/api/post/oauth/[provider]/initiate/route.js +157 -0
  63. package/dist/modules/communication_channels/api/post/oauth/[provider]/initiate/route.js.map +7 -0
  64. package/dist/modules/communication_channels/api/post/send-as-user/route.js +115 -0
  65. package/dist/modules/communication_channels/api/post/send-as-user/route.js.map +7 -0
  66. package/dist/modules/communication_channels/api/post/test-seed/route.js +217 -0
  67. package/dist/modules/communication_channels/api/post/test-seed/route.js.map +7 -0
  68. package/dist/modules/communication_channels/api/post/webhook/[provider]/route.js +175 -0
  69. package/dist/modules/communication_channels/api/post/webhook/[provider]/route.js.map +7 -0
  70. package/dist/modules/communication_channels/api/post/webhooks/gmail/route.js +123 -0
  71. package/dist/modules/communication_channels/api/post/webhooks/gmail/route.js.map +7 -0
  72. package/dist/modules/communication_channels/api/put/threads/[threadId]/assign/route.js +117 -0
  73. package/dist/modules/communication_channels/api/put/threads/[threadId]/assign/route.js.map +7 -0
  74. package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.js +180 -0
  75. package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.js.map +7 -0
  76. package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.meta.js +36 -0
  77. package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.meta.js.map +7 -0
  78. package/dist/modules/communication_channels/backend/communication_channels/channels/page.js +107 -0
  79. package/dist/modules/communication_channels/backend/communication_channels/channels/page.js.map +7 -0
  80. package/dist/modules/communication_channels/backend/communication_channels/channels/page.meta.js +38 -0
  81. package/dist/modules/communication_channels/backend/communication_channels/channels/page.meta.js.map +7 -0
  82. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js +727 -0
  83. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +7 -0
  84. package/dist/modules/communication_channels/backend/profile/communication-channels/page.meta.js +38 -0
  85. package/dist/modules/communication_channels/backend/profile/communication-channels/page.meta.js.map +7 -0
  86. package/dist/modules/communication_channels/commands/connect-credential-channel.js +154 -0
  87. package/dist/modules/communication_channels/commands/connect-credential-channel.js.map +7 -0
  88. package/dist/modules/communication_channels/commands/delete-channel.js +137 -0
  89. package/dist/modules/communication_channels/commands/delete-channel.js.map +7 -0
  90. package/dist/modules/communication_channels/commands/deliver-outbound-message.js +400 -0
  91. package/dist/modules/communication_channels/commands/deliver-outbound-message.js.map +7 -0
  92. package/dist/modules/communication_channels/commands/disconnect-channel.js +163 -0
  93. package/dist/modules/communication_channels/commands/disconnect-channel.js.map +7 -0
  94. package/dist/modules/communication_channels/commands/ingest-inbound-message.js +413 -0
  95. package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +7 -0
  96. package/dist/modules/communication_channels/commands/interceptors.js +68 -0
  97. package/dist/modules/communication_channels/commands/interceptors.js.map +7 -0
  98. package/dist/modules/communication_channels/commands/process-inbound-reaction.js +198 -0
  99. package/dist/modules/communication_channels/commands/process-inbound-reaction.js.map +7 -0
  100. package/dist/modules/communication_channels/commands/push-register.js +146 -0
  101. package/dist/modules/communication_channels/commands/push-register.js.map +7 -0
  102. package/dist/modules/communication_channels/commands/push-renew.js +23 -0
  103. package/dist/modules/communication_channels/commands/push-renew.js.map +7 -0
  104. package/dist/modules/communication_channels/commands/push-unregister.js +108 -0
  105. package/dist/modules/communication_channels/commands/push-unregister.js.map +7 -0
  106. package/dist/modules/communication_channels/commands/queue-import-history.js +113 -0
  107. package/dist/modules/communication_channels/commands/queue-import-history.js.map +7 -0
  108. package/dist/modules/communication_channels/commands/reassign-conversation.js +193 -0
  109. package/dist/modules/communication_channels/commands/reassign-conversation.js.map +7 -0
  110. package/dist/modules/communication_channels/commands/set-primary-channel.js +114 -0
  111. package/dist/modules/communication_channels/commands/set-primary-channel.js.map +7 -0
  112. package/dist/modules/communication_channels/commands/toggle-outbound-reaction.js +260 -0
  113. package/dist/modules/communication_channels/commands/toggle-outbound-reaction.js.map +7 -0
  114. package/dist/modules/communication_channels/data/enrichers.js +286 -0
  115. package/dist/modules/communication_channels/data/enrichers.js.map +7 -0
  116. package/dist/modules/communication_channels/data/entities.js +447 -0
  117. package/dist/modules/communication_channels/data/entities.js.map +7 -0
  118. package/dist/modules/communication_channels/data/extensions.js +67 -0
  119. package/dist/modules/communication_channels/data/extensions.js.map +7 -0
  120. package/dist/modules/communication_channels/data/validators.js +123 -0
  121. package/dist/modules/communication_channels/data/validators.js.map +7 -0
  122. package/dist/modules/communication_channels/di.js +35 -0
  123. package/dist/modules/communication_channels/di.js.map +7 -0
  124. package/dist/modules/communication_channels/encryption.js +12 -0
  125. package/dist/modules/communication_channels/encryption.js.map +7 -0
  126. package/dist/modules/communication_channels/events.js +124 -0
  127. package/dist/modules/communication_channels/events.js.map +7 -0
  128. package/dist/modules/communication_channels/index.js +20 -0
  129. package/dist/modules/communication_channels/index.js.map +7 -0
  130. package/dist/modules/communication_channels/lib/access-control.js +43 -0
  131. package/dist/modules/communication_channels/lib/access-control.js.map +7 -0
  132. package/dist/modules/communication_channels/lib/adapter-compat.js +36 -0
  133. package/dist/modules/communication_channels/lib/adapter-compat.js.map +7 -0
  134. package/dist/modules/communication_channels/lib/adapter-registry-singleton.js +22 -0
  135. package/dist/modules/communication_channels/lib/adapter-registry-singleton.js.map +7 -0
  136. package/dist/modules/communication_channels/lib/adapter.js +1 -0
  137. package/dist/modules/communication_channels/lib/adapter.js.map +7 -0
  138. package/dist/modules/communication_channels/lib/connect-channel.js +95 -0
  139. package/dist/modules/communication_channels/lib/connect-channel.js.map +7 -0
  140. package/dist/modules/communication_channels/lib/contact-resolver.js +79 -0
  141. package/dist/modules/communication_channels/lib/contact-resolver.js.map +7 -0
  142. package/dist/modules/communication_channels/lib/credential-refresh.js +97 -0
  143. package/dist/modules/communication_channels/lib/credential-refresh.js.map +7 -0
  144. package/dist/modules/communication_channels/lib/dead-letter.js +62 -0
  145. package/dist/modules/communication_channels/lib/dead-letter.js.map +7 -0
  146. package/dist/modules/communication_channels/lib/email-capabilities.js +47 -0
  147. package/dist/modules/communication_channels/lib/email-capabilities.js.map +7 -0
  148. package/dist/modules/communication_channels/lib/email-contact.js +14 -0
  149. package/dist/modules/communication_channels/lib/email-contact.js.map +7 -0
  150. package/dist/modules/communication_channels/lib/email-mime.js +259 -0
  151. package/dist/modules/communication_channels/lib/email-mime.js.map +7 -0
  152. package/dist/modules/communication_channels/lib/error-classification.js +101 -0
  153. package/dist/modules/communication_channels/lib/error-classification.js.map +7 -0
  154. package/dist/modules/communication_channels/lib/gmail-pubsub-jwt.js +185 -0
  155. package/dist/modules/communication_channels/lib/gmail-pubsub-jwt.js.map +7 -0
  156. package/dist/modules/communication_channels/lib/mutation-guards.js +114 -0
  157. package/dist/modules/communication_channels/lib/mutation-guards.js.map +7 -0
  158. package/dist/modules/communication_channels/lib/oauth-client-config.js +32 -0
  159. package/dist/modules/communication_channels/lib/oauth-client-config.js.map +7 -0
  160. package/dist/modules/communication_channels/lib/oauth-state.js +128 -0
  161. package/dist/modules/communication_channels/lib/oauth-state.js.map +7 -0
  162. package/dist/modules/communication_channels/lib/oauth-token.js +45 -0
  163. package/dist/modules/communication_channels/lib/oauth-token.js.map +7 -0
  164. package/dist/modules/communication_channels/lib/pg-errors.js +11 -0
  165. package/dist/modules/communication_channels/lib/pg-errors.js.map +7 -0
  166. package/dist/modules/communication_channels/lib/provider-health.js +24 -0
  167. package/dist/modules/communication_channels/lib/provider-health.js.map +7 -0
  168. package/dist/modules/communication_channels/lib/push-state.js +19 -0
  169. package/dist/modules/communication_channels/lib/push-state.js.map +7 -0
  170. package/dist/modules/communication_channels/lib/queue.js +54 -0
  171. package/dist/modules/communication_channels/lib/queue.js.map +7 -0
  172. package/dist/modules/communication_channels/lib/reaction-processor-types.js +5 -0
  173. package/dist/modules/communication_channels/lib/reaction-processor-types.js.map +7 -0
  174. package/dist/modules/communication_channels/lib/reaction-semantics.js +11 -0
  175. package/dist/modules/communication_channels/lib/reaction-semantics.js.map +7 -0
  176. package/dist/modules/communication_channels/lib/registry.js +67 -0
  177. package/dist/modules/communication_channels/lib/registry.js.map +7 -0
  178. package/dist/modules/communication_channels/lib/route-mutation-guard.js +43 -0
  179. package/dist/modules/communication_channels/lib/route-mutation-guard.js.map +7 -0
  180. package/dist/modules/communication_channels/lib/sanitize-channel-html.js +96 -0
  181. package/dist/modules/communication_channels/lib/sanitize-channel-html.js.map +7 -0
  182. package/dist/modules/communication_channels/lib/send-as-user.js +194 -0
  183. package/dist/modules/communication_channels/lib/send-as-user.js.map +7 -0
  184. package/dist/modules/communication_channels/lib/system-user.js +22 -0
  185. package/dist/modules/communication_channels/lib/system-user.js.map +7 -0
  186. package/dist/modules/communication_channels/lib/test-seed.js +68 -0
  187. package/dist/modules/communication_channels/lib/test-seed.js.map +7 -0
  188. package/dist/modules/communication_channels/lib/thread-matcher.js +263 -0
  189. package/dist/modules/communication_channels/lib/thread-matcher.js.map +7 -0
  190. package/dist/modules/communication_channels/lib/thread-token.js +219 -0
  191. package/dist/modules/communication_channels/lib/thread-token.js.map +7 -0
  192. package/dist/modules/communication_channels/lib/use-connect-channel.js +61 -0
  193. package/dist/modules/communication_channels/lib/use-connect-channel.js.map +7 -0
  194. package/dist/modules/communication_channels/migrations/Migration20260526134719_communication_channels.js +50 -0
  195. package/dist/modules/communication_channels/migrations/Migration20260526134719_communication_channels.js.map +7 -0
  196. package/dist/modules/communication_channels/migrations/Migration20260527195446_communication_channels.js +19 -0
  197. package/dist/modules/communication_channels/migrations/Migration20260527195446_communication_channels.js.map +7 -0
  198. package/dist/modules/communication_channels/migrations/Migration20260529231848_communication_channels.js +13 -0
  199. package/dist/modules/communication_channels/migrations/Migration20260529231848_communication_channels.js.map +7 -0
  200. package/dist/modules/communication_channels/migrations/Migration20260531120000_communication_channels.js +17 -0
  201. package/dist/modules/communication_channels/migrations/Migration20260531120000_communication_channels.js.map +7 -0
  202. package/dist/modules/communication_channels/notifications.client.js +51 -0
  203. package/dist/modules/communication_channels/notifications.client.js.map +7 -0
  204. package/dist/modules/communication_channels/notifications.handlers.js +53 -0
  205. package/dist/modules/communication_channels/notifications.handlers.js.map +7 -0
  206. package/dist/modules/communication_channels/notifications.js +56 -0
  207. package/dist/modules/communication_channels/notifications.js.map +7 -0
  208. package/dist/modules/communication_channels/setup.js +105 -0
  209. package/dist/modules/communication_channels/setup.js.map +7 -0
  210. package/dist/modules/communication_channels/subscribers/channel-requires-reauth-notification.js +71 -0
  211. package/dist/modules/communication_channels/subscribers/channel-requires-reauth-notification.js.map +7 -0
  212. package/dist/modules/communication_channels/subscribers/outbound-bridge.js +103 -0
  213. package/dist/modules/communication_channels/subscribers/outbound-bridge.js.map +7 -0
  214. package/dist/modules/communication_channels/subscribers/user-deleted-cascade.js +51 -0
  215. package/dist/modules/communication_channels/subscribers/user-deleted-cascade.js.map +7 -0
  216. package/dist/modules/communication_channels/widgets/components.js +7 -0
  217. package/dist/modules/communication_channels/widgets/components.js.map +7 -0
  218. package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.client.js +18 -0
  219. package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.client.js.map +7 -0
  220. package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.js +30 -0
  221. package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.js.map +7 -0
  222. package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.client.js +185 -0
  223. package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.client.js.map +7 -0
  224. package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.js +17 -0
  225. package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.js.map +7 -0
  226. package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js +44 -0
  227. package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js.map +7 -0
  228. package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.js +17 -0
  229. package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.js.map +7 -0
  230. package/dist/modules/communication_channels/widgets/injection/profile-channels-menu/widget.js +23 -0
  231. package/dist/modules/communication_channels/widgets/injection/profile-channels-menu/widget.js.map +7 -0
  232. package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.client.js +141 -0
  233. package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.client.js.map +7 -0
  234. package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.js +17 -0
  235. package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.js.map +7 -0
  236. package/dist/modules/communication_channels/widgets/injection-table.js +38 -0
  237. package/dist/modules/communication_channels/widgets/injection-table.js.map +7 -0
  238. package/dist/modules/communication_channels/widgets/notifications/ChannelRequiresReauthRenderer.js +25 -0
  239. package/dist/modules/communication_channels/widgets/notifications/ChannelRequiresReauthRenderer.js.map +7 -0
  240. package/dist/modules/communication_channels/widgets/notifications/MessageReceivedRenderer.js +19 -0
  241. package/dist/modules/communication_channels/widgets/notifications/MessageReceivedRenderer.js.map +7 -0
  242. package/dist/modules/communication_channels/widgets/notifications/index.js +7 -0
  243. package/dist/modules/communication_channels/widgets/notifications/index.js.map +7 -0
  244. package/dist/modules/communication_channels/workers/channel-import-history.js +185 -0
  245. package/dist/modules/communication_channels/workers/channel-import-history.js.map +7 -0
  246. package/dist/modules/communication_channels/workers/gmail-history-sync.js +154 -0
  247. package/dist/modules/communication_channels/workers/gmail-history-sync.js.map +7 -0
  248. package/dist/modules/communication_channels/workers/gmail-renew-watch.js +95 -0
  249. package/dist/modules/communication_channels/workers/gmail-renew-watch.js.map +7 -0
  250. package/dist/modules/communication_channels/workers/inbound-processor.js +56 -0
  251. package/dist/modules/communication_channels/workers/inbound-processor.js.map +7 -0
  252. package/dist/modules/communication_channels/workers/outbound-delivery.js +85 -0
  253. package/dist/modules/communication_channels/workers/outbound-delivery.js.map +7 -0
  254. package/dist/modules/communication_channels/workers/poll-channel.js +240 -0
  255. package/dist/modules/communication_channels/workers/poll-channel.js.map +7 -0
  256. package/dist/modules/communication_channels/workers/poll-tick.js +132 -0
  257. package/dist/modules/communication_channels/workers/poll-tick.js.map +7 -0
  258. package/dist/modules/communication_channels/workers/reaction-processor.js +192 -0
  259. package/dist/modules/communication_channels/workers/reaction-processor.js.map +7 -0
  260. package/dist/modules/customers/acl.js +18 -0
  261. package/dist/modules/customers/acl.js.map +2 -2
  262. package/dist/modules/customers/api/activities/route.js +9 -0
  263. package/dist/modules/customers/api/activities/route.js.map +2 -2
  264. package/dist/modules/customers/api/companies/[id]/route.js +18 -7
  265. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  266. package/dist/modules/customers/api/interactions/[id]/visibility/route.js +151 -0
  267. package/dist/modules/customers/api/interactions/[id]/visibility/route.js.map +7 -0
  268. package/dist/modules/customers/api/interactions/counts/route.js +6 -0
  269. package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
  270. package/dist/modules/customers/api/interactions/route.js +26 -7
  271. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  272. package/dist/modules/customers/api/people/[id]/email-threads/route.js +82 -0
  273. package/dist/modules/customers/api/people/[id]/email-threads/route.js.map +7 -0
  274. package/dist/modules/customers/api/people/[id]/emails/route.js +157 -0
  275. package/dist/modules/customers/api/people/[id]/emails/route.js.map +7 -0
  276. package/dist/modules/customers/api/people/[id]/route.js +12 -4
  277. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  278. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +10 -0
  279. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +2 -2
  280. package/dist/modules/customers/commands/deals.js +46 -5
  281. package/dist/modules/customers/commands/deals.js.map +2 -2
  282. package/dist/modules/customers/commands/interactions.js +16 -0
  283. package/dist/modules/customers/commands/interactions.js.map +2 -2
  284. package/dist/modules/customers/components/detail/ActivityCard.js +32 -0
  285. package/dist/modules/customers/components/detail/ActivityCard.js.map +2 -2
  286. package/dist/modules/customers/components/detail/ComposeEmailDialog.js +242 -0
  287. package/dist/modules/customers/components/detail/ComposeEmailDialog.js.map +7 -0
  288. package/dist/modules/customers/components/detail/DealForm.js +2 -1
  289. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  290. package/dist/modules/customers/components/detail/DealsSection.js +10 -0
  291. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  292. package/dist/modules/customers/components/detail/EmailCardActions.js +179 -0
  293. package/dist/modules/customers/components/detail/EmailCardActions.js.map +7 -0
  294. package/dist/modules/customers/components/detail/EmailReplyForwardActions.js +52 -0
  295. package/dist/modules/customers/components/detail/EmailReplyForwardActions.js.map +7 -0
  296. package/dist/modules/customers/components/detail/PersonDetailTabs.js +7 -1
  297. package/dist/modules/customers/components/detail/PersonDetailTabs.js.map +2 -2
  298. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js +366 -0
  299. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js.map +7 -0
  300. package/dist/modules/customers/data/enrichers.js +133 -2
  301. package/dist/modules/customers/data/enrichers.js.map +2 -2
  302. package/dist/modules/customers/data/entities.js +18 -0
  303. package/dist/modules/customers/data/entities.js.map +2 -2
  304. package/dist/modules/customers/data/extensions.js +16 -0
  305. package/dist/modules/customers/data/extensions.js.map +7 -0
  306. package/dist/modules/customers/encryption.js +11 -0
  307. package/dist/modules/customers/encryption.js.map +2 -2
  308. package/dist/modules/customers/events.js +4 -1
  309. package/dist/modules/customers/events.js.map +2 -2
  310. package/dist/modules/customers/lib/findPeopleByAddresses.js +64 -0
  311. package/dist/modules/customers/lib/findPeopleByAddresses.js.map +7 -0
  312. package/dist/modules/customers/lib/kysely.js.map +2 -2
  313. package/dist/modules/customers/lib/link-channel-message-handler.js +303 -0
  314. package/dist/modules/customers/lib/link-channel-message-handler.js.map +7 -0
  315. package/dist/modules/customers/lib/personEmailThreads.js +205 -0
  316. package/dist/modules/customers/lib/personEmailThreads.js.map +7 -0
  317. package/dist/modules/customers/lib/visibilityFilter.js +51 -0
  318. package/dist/modules/customers/lib/visibilityFilter.js.map +7 -0
  319. package/dist/modules/customers/migrations/Migration20260527012240_customers.js +20 -0
  320. package/dist/modules/customers/migrations/Migration20260527012240_customers.js.map +7 -0
  321. package/dist/modules/customers/setup.js +2 -1
  322. package/dist/modules/customers/setup.js.map +2 -2
  323. package/dist/modules/customers/subscribers/link-channel-message-received.js +12 -0
  324. package/dist/modules/customers/subscribers/link-channel-message-received.js.map +7 -0
  325. package/dist/modules/customers/subscribers/link-channel-message-sent.js +12 -0
  326. package/dist/modules/customers/subscribers/link-channel-message-sent.js.map +7 -0
  327. package/dist/modules/integrations/data/entities.js +8 -1
  328. package/dist/modules/integrations/data/entities.js.map +2 -2
  329. package/dist/modules/integrations/lib/credentials-service.js +29 -14
  330. package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
  331. package/dist/modules/integrations/migrations/Migration20260526154136_integrations.js +15 -0
  332. package/dist/modules/integrations/migrations/Migration20260526154136_integrations.js.map +7 -0
  333. package/dist/modules/messages/commands/messages.js +70 -8
  334. package/dist/modules/messages/commands/messages.js.map +2 -2
  335. package/dist/modules/messages/components/ComposeMessagePageClient.js +24 -13
  336. package/dist/modules/messages/components/ComposeMessagePageClient.js.map +2 -2
  337. package/dist/modules/messages/components/MessageDetailPageClient.js +39 -2
  338. package/dist/modules/messages/components/MessageDetailPageClient.js.map +2 -2
  339. package/dist/modules/messages/components/MessagesInboxPageClient.js +1 -0
  340. package/dist/modules/messages/components/MessagesInboxPageClient.js.map +2 -2
  341. package/dist/modules/messages/data/entities.js +8 -1
  342. package/dist/modules/messages/data/entities.js.map +2 -2
  343. package/dist/modules/messages/migrations/Migration20260531130000.js +15 -0
  344. package/dist/modules/messages/migrations/Migration20260531130000.js.map +7 -0
  345. package/dist/modules/messages/widgets/injection-table.js +7 -0
  346. package/dist/modules/messages/widgets/injection-table.js.map +7 -0
  347. package/generated/entities/channel_ingest_dead_letter/index.ts +11 -0
  348. package/generated/entities/channel_thread_mapping/index.ts +11 -0
  349. package/generated/entities/channel_thread_token/index.ts +7 -0
  350. package/generated/entities/communication_channel/index.ts +20 -0
  351. package/generated/entities/customer_interaction/index.ts +2 -0
  352. package/generated/entities/external_conversation/index.ts +11 -0
  353. package/generated/entities/external_message/index.ts +11 -0
  354. package/generated/entities/integration_credentials/index.ts +1 -0
  355. package/generated/entities/message/index.ts +1 -0
  356. package/generated/entities/message_channel_link/index.ts +15 -0
  357. package/generated/entities/message_reaction/index.ts +11 -0
  358. package/generated/entities.ids.generated.ts +11 -0
  359. package/generated/entity-fields-registry.ts +117 -0
  360. package/package.json +9 -7
  361. package/src/helpers/integration/authFixtures.ts +4 -1
  362. package/src/helpers/integration/communicationChannelsFixtures.ts +124 -0
  363. package/src/modules/communication_channels/acl.ts +43 -0
  364. package/src/modules/communication_channels/api/delete/channels/[id]/route.ts +163 -0
  365. package/src/modules/communication_channels/api/delete/messages/[messageId]/reactions/[reactionId]/route.ts +143 -0
  366. package/src/modules/communication_channels/api/get/channels/[id]/health/route.ts +173 -0
  367. package/src/modules/communication_channels/api/get/channels/[id]/route.ts +111 -0
  368. package/src/modules/communication_channels/api/get/channels/route.ts +109 -0
  369. package/src/modules/communication_channels/api/get/me/channels/route.ts +100 -0
  370. package/src/modules/communication_channels/api/get/oauth/[provider]/callback/route.ts +355 -0
  371. package/src/modules/communication_channels/api/post/channels/[id]/import-history/route.ts +206 -0
  372. package/src/modules/communication_channels/api/post/channels/[id]/poll-now/route.ts +174 -0
  373. package/src/modules/communication_channels/api/post/channels/[id]/push/register/route.ts +158 -0
  374. package/src/modules/communication_channels/api/post/channels/[id]/set-primary/route.ts +114 -0
  375. package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +241 -0
  376. package/src/modules/communication_channels/api/post/channels/connect/credentials/route.ts +134 -0
  377. package/src/modules/communication_channels/api/post/messages/[messageId]/reactions/route.ts +143 -0
  378. package/src/modules/communication_channels/api/post/oauth/[provider]/initiate/route.ts +192 -0
  379. package/src/modules/communication_channels/api/post/send-as-user/route.ts +125 -0
  380. package/src/modules/communication_channels/api/post/test-seed/route.ts +267 -0
  381. package/src/modules/communication_channels/api/post/webhook/[provider]/route.ts +227 -0
  382. package/src/modules/communication_channels/api/post/webhooks/gmail/route.ts +161 -0
  383. package/src/modules/communication_channels/api/put/threads/[threadId]/assign/route.ts +132 -0
  384. package/src/modules/communication_channels/backend/communication_channels/channels/[id]/page.meta.ts +34 -0
  385. package/src/modules/communication_channels/backend/communication_channels/channels/[id]/page.tsx +250 -0
  386. package/src/modules/communication_channels/backend/communication_channels/channels/page.meta.ts +36 -0
  387. package/src/modules/communication_channels/backend/communication_channels/channels/page.tsx +137 -0
  388. package/src/modules/communication_channels/backend/profile/communication-channels/page.meta.ts +36 -0
  389. package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +907 -0
  390. package/src/modules/communication_channels/commands/connect-credential-channel.ts +243 -0
  391. package/src/modules/communication_channels/commands/delete-channel.ts +193 -0
  392. package/src/modules/communication_channels/commands/deliver-outbound-message.ts +579 -0
  393. package/src/modules/communication_channels/commands/disconnect-channel.ts +241 -0
  394. package/src/modules/communication_channels/commands/ingest-inbound-message.ts +602 -0
  395. package/src/modules/communication_channels/commands/interceptors.ts +104 -0
  396. package/src/modules/communication_channels/commands/process-inbound-reaction.ts +265 -0
  397. package/src/modules/communication_channels/commands/push-register.ts +203 -0
  398. package/src/modules/communication_channels/commands/push-renew.ts +49 -0
  399. package/src/modules/communication_channels/commands/push-unregister.ts +168 -0
  400. package/src/modules/communication_channels/commands/queue-import-history.ts +180 -0
  401. package/src/modules/communication_channels/commands/reassign-conversation.ts +273 -0
  402. package/src/modules/communication_channels/commands/set-primary-channel.ts +154 -0
  403. package/src/modules/communication_channels/commands/toggle-outbound-reaction.ts +347 -0
  404. package/src/modules/communication_channels/data/enrichers.ts +413 -0
  405. package/src/modules/communication_channels/data/entities.ts +546 -0
  406. package/src/modules/communication_channels/data/extensions.ts +76 -0
  407. package/src/modules/communication_channels/data/validators.ts +138 -0
  408. package/src/modules/communication_channels/di.ts +40 -0
  409. package/src/modules/communication_channels/encryption.ts +44 -0
  410. package/src/modules/communication_channels/events.ts +122 -0
  411. package/src/modules/communication_channels/i18n/de.json +138 -0
  412. package/src/modules/communication_channels/i18n/en.json +138 -0
  413. package/src/modules/communication_channels/i18n/es.json +138 -0
  414. package/src/modules/communication_channels/i18n/pl.json +138 -0
  415. package/src/modules/communication_channels/index.ts +19 -0
  416. package/src/modules/communication_channels/lib/access-control.ts +110 -0
  417. package/src/modules/communication_channels/lib/adapter-compat.ts +57 -0
  418. package/src/modules/communication_channels/lib/adapter-registry-singleton.ts +35 -0
  419. package/src/modules/communication_channels/lib/adapter.ts +605 -0
  420. package/src/modules/communication_channels/lib/connect-channel.ts +163 -0
  421. package/src/modules/communication_channels/lib/contact-resolver.ts +162 -0
  422. package/src/modules/communication_channels/lib/credential-refresh.ts +197 -0
  423. package/src/modules/communication_channels/lib/dead-letter.ts +87 -0
  424. package/src/modules/communication_channels/lib/email-capabilities.ts +60 -0
  425. package/src/modules/communication_channels/lib/email-contact.ts +17 -0
  426. package/src/modules/communication_channels/lib/email-mime.ts +425 -0
  427. package/src/modules/communication_channels/lib/error-classification.ts +144 -0
  428. package/src/modules/communication_channels/lib/gmail-pubsub-jwt.ts +278 -0
  429. package/src/modules/communication_channels/lib/mutation-guards.ts +215 -0
  430. package/src/modules/communication_channels/lib/oauth-client-config.ts +79 -0
  431. package/src/modules/communication_channels/lib/oauth-state.ts +228 -0
  432. package/src/modules/communication_channels/lib/oauth-token.ts +81 -0
  433. package/src/modules/communication_channels/lib/pg-errors.ts +12 -0
  434. package/src/modules/communication_channels/lib/provider-health.ts +47 -0
  435. package/src/modules/communication_channels/lib/push-state.ts +38 -0
  436. package/src/modules/communication_channels/lib/queue.ts +66 -0
  437. package/src/modules/communication_channels/lib/reaction-processor-types.ts +51 -0
  438. package/src/modules/communication_channels/lib/reaction-semantics.ts +48 -0
  439. package/src/modules/communication_channels/lib/registry.ts +99 -0
  440. package/src/modules/communication_channels/lib/route-mutation-guard.ts +68 -0
  441. package/src/modules/communication_channels/lib/sanitize-channel-html.ts +129 -0
  442. package/src/modules/communication_channels/lib/send-as-user.ts +284 -0
  443. package/src/modules/communication_channels/lib/system-user.ts +74 -0
  444. package/src/modules/communication_channels/lib/test-seed.ts +140 -0
  445. package/src/modules/communication_channels/lib/thread-matcher.ts +430 -0
  446. package/src/modules/communication_channels/lib/thread-token.ts +355 -0
  447. package/src/modules/communication_channels/lib/use-connect-channel.ts +73 -0
  448. package/src/modules/communication_channels/migrations/.snapshot-open-mercato.json +2142 -0
  449. package/src/modules/communication_channels/migrations/Migration20260526134719_communication_channels.ts +55 -0
  450. package/src/modules/communication_channels/migrations/Migration20260527195446_communication_channels.ts +20 -0
  451. package/src/modules/communication_channels/migrations/Migration20260529231848_communication_channels.ts +13 -0
  452. package/src/modules/communication_channels/migrations/Migration20260531120000_communication_channels.ts +24 -0
  453. package/src/modules/communication_channels/notifications.client.ts +50 -0
  454. package/src/modules/communication_channels/notifications.handlers.ts +86 -0
  455. package/src/modules/communication_channels/notifications.ts +52 -0
  456. package/src/modules/communication_channels/setup.ts +158 -0
  457. package/src/modules/communication_channels/subscribers/channel-requires-reauth-notification.ts +118 -0
  458. package/src/modules/communication_channels/subscribers/outbound-bridge.ts +175 -0
  459. package/src/modules/communication_channels/subscribers/user-deleted-cascade.ts +100 -0
  460. package/src/modules/communication_channels/widgets/components.ts +36 -0
  461. package/src/modules/communication_channels/widgets/injection/channel-badge/widget.client.tsx +38 -0
  462. package/src/modules/communication_channels/widgets/injection/channel-badge/widget.ts +51 -0
  463. package/src/modules/communication_channels/widgets/injection/channel-info-panel/widget.client.tsx +278 -0
  464. package/src/modules/communication_channels/widgets/injection/channel-info-panel/widget.ts +24 -0
  465. package/src/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.tsx +63 -0
  466. package/src/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.ts +29 -0
  467. package/src/modules/communication_channels/widgets/injection/profile-channels-menu/widget.ts +34 -0
  468. package/src/modules/communication_channels/widgets/injection/reaction-bar/widget.client.tsx +177 -0
  469. package/src/modules/communication_channels/widgets/injection/reaction-bar/widget.ts +26 -0
  470. package/src/modules/communication_channels/widgets/injection-table.ts +47 -0
  471. package/src/modules/communication_channels/widgets/notifications/ChannelRequiresReauthRenderer.tsx +48 -0
  472. package/src/modules/communication_channels/widgets/notifications/MessageReceivedRenderer.tsx +45 -0
  473. package/src/modules/communication_channels/widgets/notifications/index.ts +2 -0
  474. package/src/modules/communication_channels/workers/channel-import-history.ts +252 -0
  475. package/src/modules/communication_channels/workers/gmail-history-sync.ts +223 -0
  476. package/src/modules/communication_channels/workers/gmail-renew-watch.ts +141 -0
  477. package/src/modules/communication_channels/workers/inbound-processor.ts +114 -0
  478. package/src/modules/communication_channels/workers/outbound-delivery.ts +155 -0
  479. package/src/modules/communication_channels/workers/poll-channel.ts +391 -0
  480. package/src/modules/communication_channels/workers/poll-tick.ts +210 -0
  481. package/src/modules/communication_channels/workers/reaction-processor.ts +264 -0
  482. package/src/modules/customers/acl.ts +18 -0
  483. package/src/modules/customers/api/activities/route.ts +13 -0
  484. package/src/modules/customers/api/companies/[id]/route.ts +21 -1
  485. package/src/modules/customers/api/interactions/[id]/visibility/route.ts +179 -0
  486. package/src/modules/customers/api/interactions/counts/route.ts +10 -0
  487. package/src/modules/customers/api/interactions/route.ts +51 -5
  488. package/src/modules/customers/api/people/[id]/email-threads/route.ts +92 -0
  489. package/src/modules/customers/api/people/[id]/emails/route.ts +184 -0
  490. package/src/modules/customers/api/people/[id]/route.ts +17 -2
  491. package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +11 -1
  492. package/src/modules/customers/commands/deals.ts +65 -6
  493. package/src/modules/customers/commands/interactions.ts +30 -0
  494. package/src/modules/customers/components/detail/ActivityCard.tsx +48 -0
  495. package/src/modules/customers/components/detail/ComposeEmailDialog.tsx +329 -0
  496. package/src/modules/customers/components/detail/DealForm.tsx +2 -1
  497. package/src/modules/customers/components/detail/DealsSection.tsx +26 -0
  498. package/src/modules/customers/components/detail/EmailCardActions.tsx +258 -0
  499. package/src/modules/customers/components/detail/EmailReplyForwardActions.tsx +53 -0
  500. package/src/modules/customers/components/detail/PersonDetailTabs.tsx +8 -1
  501. package/src/modules/customers/components/detail/PersonEmailThreadsTab.tsx +448 -0
  502. package/src/modules/customers/data/enrichers.ts +252 -1
  503. package/src/modules/customers/data/entities.ts +46 -1
  504. package/src/modules/customers/data/extensions.ts +26 -0
  505. package/src/modules/customers/encryption.ts +11 -0
  506. package/src/modules/customers/events.ts +4 -0
  507. package/src/modules/customers/i18n/de.json +41 -0
  508. package/src/modules/customers/i18n/en.json +41 -0
  509. package/src/modules/customers/i18n/es.json +41 -0
  510. package/src/modules/customers/i18n/pl.json +41 -0
  511. package/src/modules/customers/lib/findPeopleByAddresses.ts +107 -0
  512. package/src/modules/customers/lib/kysely.ts +16 -0
  513. package/src/modules/customers/lib/link-channel-message-handler.ts +571 -0
  514. package/src/modules/customers/lib/personEmailThreads.ts +325 -0
  515. package/src/modules/customers/lib/visibilityFilter.ts +152 -0
  516. package/src/modules/customers/migrations/.snapshot-open-mercato.json +61 -0
  517. package/src/modules/customers/migrations/Migration20260527012240_customers.ts +23 -0
  518. package/src/modules/customers/setup.ts +1 -0
  519. package/src/modules/customers/subscribers/link-channel-message-received.ts +21 -0
  520. package/src/modules/customers/subscribers/link-channel-message-sent.ts +21 -0
  521. package/src/modules/integrations/AGENTS.md +9 -0
  522. package/src/modules/integrations/data/entities.ts +21 -1
  523. package/src/modules/integrations/lib/credentials-service.ts +49 -13
  524. package/src/modules/integrations/migrations/.snapshot-open-mercato.json +26 -1
  525. package/src/modules/integrations/migrations/Migration20260526154136_integrations.ts +15 -0
  526. package/src/modules/messages/commands/messages.ts +101 -8
  527. package/src/modules/messages/components/ComposeMessagePageClient.tsx +17 -0
  528. package/src/modules/messages/components/MessageDetailPageClient.tsx +43 -0
  529. package/src/modules/messages/components/MessagesInboxPageClient.tsx +4 -0
  530. package/src/modules/messages/data/entities.ts +11 -0
  531. package/src/modules/messages/migrations/.snapshot-open-mercato.json +18 -0
  532. package/src/modules/messages/migrations/Migration20260531130000.ts +15 -0
  533. package/src/modules/messages/widgets/injection-table.ts +29 -0
@@ -0,0 +1,447 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+ import { OptionalProps } from "@mikro-orm/core";
12
+ import { Check, Entity, Index, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
13
+ OptionalProps;
14
+ let CommunicationChannel = class {
15
+ constructor() {
16
+ this.isActive = true;
17
+ this.isPrimary = false;
18
+ this.status = "connected";
19
+ this.createdAt = /* @__PURE__ */ new Date();
20
+ this.updatedAt = /* @__PURE__ */ new Date();
21
+ }
22
+ };
23
+ __decorateClass([
24
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
25
+ ], CommunicationChannel.prototype, "id", 2);
26
+ __decorateClass([
27
+ Property({ name: "provider_key", type: "text" })
28
+ ], CommunicationChannel.prototype, "providerKey", 2);
29
+ __decorateClass([
30
+ Property({ name: "channel_type", type: "text" })
31
+ ], CommunicationChannel.prototype, "channelType", 2);
32
+ __decorateClass([
33
+ Property({ name: "display_name", type: "text" })
34
+ ], CommunicationChannel.prototype, "displayName", 2);
35
+ __decorateClass([
36
+ Property({ name: "external_identifier", type: "text", nullable: true })
37
+ ], CommunicationChannel.prototype, "externalIdentifier", 2);
38
+ __decorateClass([
39
+ Property({ name: "credentials_ref", type: "uuid", nullable: true })
40
+ ], CommunicationChannel.prototype, "credentialsRef", 2);
41
+ __decorateClass([
42
+ Property({ name: "capabilities", type: "json", nullable: true })
43
+ ], CommunicationChannel.prototype, "capabilities", 2);
44
+ __decorateClass([
45
+ Property({ name: "is_active", type: "boolean", default: true })
46
+ ], CommunicationChannel.prototype, "isActive", 2);
47
+ __decorateClass([
48
+ Property({ name: "user_id", type: "uuid", nullable: true })
49
+ ], CommunicationChannel.prototype, "userId", 2);
50
+ __decorateClass([
51
+ Property({ name: "is_primary", type: "boolean", default: false })
52
+ ], CommunicationChannel.prototype, "isPrimary", 2);
53
+ __decorateClass([
54
+ Property({ name: "poll_interval_seconds", type: "int", nullable: true })
55
+ ], CommunicationChannel.prototype, "pollIntervalSeconds", 2);
56
+ __decorateClass([
57
+ Property({ name: "last_polled_at", type: Date, nullable: true })
58
+ ], CommunicationChannel.prototype, "lastPolledAt", 2);
59
+ __decorateClass([
60
+ Property({ name: "status", type: "text", default: "connected" })
61
+ ], CommunicationChannel.prototype, "status", 2);
62
+ __decorateClass([
63
+ Property({ name: "last_error", type: "text", nullable: true })
64
+ ], CommunicationChannel.prototype, "lastError", 2);
65
+ __decorateClass([
66
+ Property({ name: "channel_state", type: "json", nullable: true })
67
+ ], CommunicationChannel.prototype, "channelState", 2);
68
+ __decorateClass([
69
+ Property({ name: "tenant_id", type: "uuid" })
70
+ ], CommunicationChannel.prototype, "tenantId", 2);
71
+ __decorateClass([
72
+ Property({ name: "organization_id", type: "uuid", nullable: true })
73
+ ], CommunicationChannel.prototype, "organizationId", 2);
74
+ __decorateClass([
75
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
76
+ ], CommunicationChannel.prototype, "createdAt", 2);
77
+ __decorateClass([
78
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
79
+ ], CommunicationChannel.prototype, "updatedAt", 2);
80
+ __decorateClass([
81
+ Property({ name: "deleted_at", type: Date, nullable: true })
82
+ ], CommunicationChannel.prototype, "deletedAt", 2);
83
+ CommunicationChannel = __decorateClass([
84
+ Entity({ tableName: "communication_channels" }),
85
+ Index({ name: "communication_channels_tenant_provider_idx", properties: ["tenantId", "providerKey"] }),
86
+ Index({
87
+ name: "communication_channels_provider_external_idx",
88
+ expression: `create index "communication_channels_provider_external_idx" on "communication_channels" ("provider_key", "external_identifier") where "deleted_at" is null`
89
+ }),
90
+ Index({ name: "communication_channels_tenant_type_active_idx", properties: ["tenantId", "channelType", "isActive"] }),
91
+ Index({
92
+ name: "communication_channels_user_lookup_idx",
93
+ properties: ["userId", "channelType", "deletedAt"]
94
+ }),
95
+ Index({
96
+ name: "communication_channels_poll_due_idx",
97
+ expression: `create index "communication_channels_poll_due_idx" on "communication_channels" ("is_active", "last_polled_at") where "deleted_at" is null`
98
+ }),
99
+ Index({
100
+ name: "communication_channels_one_primary_per_user_uq",
101
+ expression: `create unique index "communication_channels_one_primary_per_user_uq" on "communication_channels" ("user_id") where "is_primary" and "user_id" is not null and "deleted_at" is null`
102
+ }),
103
+ Index({
104
+ name: "communication_channels_user_provider_external_uq",
105
+ expression: `create unique index "communication_channels_user_provider_external_uq" on "communication_channels" ("tenant_id", "user_id", "provider_key", "external_identifier") where "deleted_at" is null and "user_id" is not null and "external_identifier" is not null`
106
+ })
107
+ ], CommunicationChannel);
108
+ OptionalProps;
109
+ let ExternalConversation = class {
110
+ constructor() {
111
+ this.createdAt = /* @__PURE__ */ new Date();
112
+ this.updatedAt = /* @__PURE__ */ new Date();
113
+ }
114
+ };
115
+ __decorateClass([
116
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
117
+ ], ExternalConversation.prototype, "id", 2);
118
+ __decorateClass([
119
+ Property({ name: "channel_id", type: "uuid" })
120
+ ], ExternalConversation.prototype, "channelId", 2);
121
+ __decorateClass([
122
+ Property({ name: "external_conversation_id", type: "text" })
123
+ ], ExternalConversation.prototype, "externalConversationId", 2);
124
+ __decorateClass([
125
+ Property({ name: "subject", type: "text", nullable: true })
126
+ ], ExternalConversation.prototype, "subject", 2);
127
+ __decorateClass([
128
+ Property({ name: "contact_person_id", type: "uuid", nullable: true })
129
+ ], ExternalConversation.prototype, "contactPersonId", 2);
130
+ __decorateClass([
131
+ Property({ name: "assigned_user_id", type: "uuid", nullable: true })
132
+ ], ExternalConversation.prototype, "assignedUserId", 2);
133
+ __decorateClass([
134
+ Property({ name: "last_message_at", type: Date, nullable: true })
135
+ ], ExternalConversation.prototype, "lastMessageAt", 2);
136
+ __decorateClass([
137
+ Property({ name: "tenant_id", type: "uuid" })
138
+ ], ExternalConversation.prototype, "tenantId", 2);
139
+ __decorateClass([
140
+ Property({ name: "organization_id", type: "uuid", nullable: true })
141
+ ], ExternalConversation.prototype, "organizationId", 2);
142
+ __decorateClass([
143
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
144
+ ], ExternalConversation.prototype, "createdAt", 2);
145
+ __decorateClass([
146
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
147
+ ], ExternalConversation.prototype, "updatedAt", 2);
148
+ ExternalConversation = __decorateClass([
149
+ Entity({ tableName: "external_conversations" }),
150
+ Index({ name: "external_conversations_channel_idx", properties: ["channelId", "externalConversationId"] }),
151
+ Index({ name: "external_conversations_contact_person_idx", properties: ["contactPersonId"] }),
152
+ Index({ name: "external_conversations_assigned_user_idx", properties: ["assignedUserId"] }),
153
+ Unique({ name: "external_conversations_channel_external_uq", properties: ["channelId", "externalConversationId"] })
154
+ ], ExternalConversation);
155
+ OptionalProps;
156
+ let ExternalMessage = class {
157
+ constructor() {
158
+ this.createdAt = /* @__PURE__ */ new Date();
159
+ }
160
+ };
161
+ __decorateClass([
162
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
163
+ ], ExternalMessage.prototype, "id", 2);
164
+ __decorateClass([
165
+ Property({ name: "channel_id", type: "uuid" })
166
+ ], ExternalMessage.prototype, "channelId", 2);
167
+ __decorateClass([
168
+ Property({ name: "conversation_id", type: "uuid" })
169
+ ], ExternalMessage.prototype, "conversationId", 2);
170
+ __decorateClass([
171
+ Property({ name: "external_message_id", type: "text" })
172
+ ], ExternalMessage.prototype, "externalMessageId", 2);
173
+ __decorateClass([
174
+ Property({ name: "direction", type: "text" })
175
+ ], ExternalMessage.prototype, "direction", 2);
176
+ __decorateClass([
177
+ Property({ name: "sender_identifier", type: "text", nullable: true })
178
+ ], ExternalMessage.prototype, "senderIdentifier", 2);
179
+ __decorateClass([
180
+ Property({ name: "sender_display_name", type: "text", nullable: true })
181
+ ], ExternalMessage.prototype, "senderDisplayName", 2);
182
+ __decorateClass([
183
+ Property({ name: "provider_timestamp", type: Date, nullable: true })
184
+ ], ExternalMessage.prototype, "providerTimestamp", 2);
185
+ __decorateClass([
186
+ Property({ name: "tenant_id", type: "uuid" })
187
+ ], ExternalMessage.prototype, "tenantId", 2);
188
+ __decorateClass([
189
+ Property({ name: "organization_id", type: "uuid", nullable: true })
190
+ ], ExternalMessage.prototype, "organizationId", 2);
191
+ __decorateClass([
192
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
193
+ ], ExternalMessage.prototype, "createdAt", 2);
194
+ ExternalMessage = __decorateClass([
195
+ Entity({ tableName: "external_messages" }),
196
+ Index({ name: "external_messages_conversation_idx", properties: ["conversationId"] }),
197
+ Index({ name: "external_messages_channel_external_idx", properties: ["channelId", "externalMessageId"] }),
198
+ Unique({ name: "external_messages_channel_external_uq", properties: ["channelId", "externalMessageId"] })
199
+ ], ExternalMessage);
200
+ OptionalProps;
201
+ let MessageChannelLink = class {
202
+ constructor() {
203
+ this.deliveryStatus = "pending";
204
+ this.createdAt = /* @__PURE__ */ new Date();
205
+ }
206
+ };
207
+ __decorateClass([
208
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
209
+ ], MessageChannelLink.prototype, "id", 2);
210
+ __decorateClass([
211
+ Property({ name: "message_id", type: "uuid" })
212
+ ], MessageChannelLink.prototype, "messageId", 2);
213
+ __decorateClass([
214
+ Property({ name: "external_conversation_id", type: "uuid" })
215
+ ], MessageChannelLink.prototype, "externalConversationId", 2);
216
+ __decorateClass([
217
+ Property({ name: "external_message_id", type: "uuid", nullable: true })
218
+ ], MessageChannelLink.prototype, "externalMessageId", 2);
219
+ __decorateClass([
220
+ Property({ name: "provider_key", type: "text" })
221
+ ], MessageChannelLink.prototype, "providerKey", 2);
222
+ __decorateClass([
223
+ Property({ name: "channel_type", type: "text" })
224
+ ], MessageChannelLink.prototype, "channelType", 2);
225
+ __decorateClass([
226
+ Property({ name: "direction", type: "text" })
227
+ ], MessageChannelLink.prototype, "direction", 2);
228
+ __decorateClass([
229
+ Property({ name: "delivery_status", type: "text" })
230
+ ], MessageChannelLink.prototype, "deliveryStatus", 2);
231
+ __decorateClass([
232
+ Property({ name: "channel_payload", type: "json", nullable: true })
233
+ ], MessageChannelLink.prototype, "channelPayload", 2);
234
+ __decorateClass([
235
+ Property({ name: "channel_content_type", type: "text", nullable: true })
236
+ ], MessageChannelLink.prototype, "channelContentType", 2);
237
+ __decorateClass([
238
+ Property({ name: "interactive_state", type: "json", nullable: true })
239
+ ], MessageChannelLink.prototype, "interactiveState", 2);
240
+ __decorateClass([
241
+ Property({ name: "channel_metadata", type: "json", nullable: true })
242
+ ], MessageChannelLink.prototype, "channelMetadata", 2);
243
+ __decorateClass([
244
+ Property({ name: "tenant_id", type: "uuid" })
245
+ ], MessageChannelLink.prototype, "tenantId", 2);
246
+ __decorateClass([
247
+ Property({ name: "organization_id", type: "uuid", nullable: true })
248
+ ], MessageChannelLink.prototype, "organizationId", 2);
249
+ __decorateClass([
250
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
251
+ ], MessageChannelLink.prototype, "createdAt", 2);
252
+ MessageChannelLink = __decorateClass([
253
+ Entity({ tableName: "message_channel_links" }),
254
+ Index({ name: "message_channel_links_message_idx", properties: ["messageId"] }),
255
+ Index({ name: "message_channel_links_ext_conv_idx", properties: ["externalConversationId"] }),
256
+ Index({ name: "message_channel_links_ext_msg_idx", properties: ["externalMessageId"] }),
257
+ Unique({ name: "message_channel_links_message_uq", properties: ["messageId"] })
258
+ ], MessageChannelLink);
259
+ OptionalProps;
260
+ let ChannelThreadMapping = class {
261
+ constructor() {
262
+ this.createdAt = /* @__PURE__ */ new Date();
263
+ this.updatedAt = /* @__PURE__ */ new Date();
264
+ }
265
+ };
266
+ __decorateClass([
267
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
268
+ ], ChannelThreadMapping.prototype, "id", 2);
269
+ __decorateClass([
270
+ Property({ name: "external_conversation_id", type: "uuid" })
271
+ ], ChannelThreadMapping.prototype, "externalConversationId", 2);
272
+ __decorateClass([
273
+ Property({ name: "message_thread_id", type: "uuid" })
274
+ ], ChannelThreadMapping.prototype, "messageThreadId", 2);
275
+ __decorateClass([
276
+ Property({ name: "channel_id", type: "uuid" })
277
+ ], ChannelThreadMapping.prototype, "channelId", 2);
278
+ __decorateClass([
279
+ Property({ name: "provider_key", type: "text" })
280
+ ], ChannelThreadMapping.prototype, "providerKey", 2);
281
+ __decorateClass([
282
+ Property({ name: "external_thread_ref", type: "text" })
283
+ ], ChannelThreadMapping.prototype, "externalThreadRef", 2);
284
+ __decorateClass([
285
+ Property({ name: "assigned_user_id", type: "uuid", nullable: true })
286
+ ], ChannelThreadMapping.prototype, "assignedUserId", 2);
287
+ __decorateClass([
288
+ Property({ name: "tenant_id", type: "uuid" })
289
+ ], ChannelThreadMapping.prototype, "tenantId", 2);
290
+ __decorateClass([
291
+ Property({ name: "organization_id", type: "uuid", nullable: true })
292
+ ], ChannelThreadMapping.prototype, "organizationId", 2);
293
+ __decorateClass([
294
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
295
+ ], ChannelThreadMapping.prototype, "createdAt", 2);
296
+ __decorateClass([
297
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
298
+ ], ChannelThreadMapping.prototype, "updatedAt", 2);
299
+ ChannelThreadMapping = __decorateClass([
300
+ Entity({ tableName: "channel_thread_mappings" }),
301
+ Index({ name: "channel_thread_mappings_ext_conv_idx", properties: ["externalConversationId", "tenantId"] }),
302
+ Index({ name: "channel_thread_mappings_thread_idx", properties: ["messageThreadId", "tenantId"] }),
303
+ Unique({ name: "channel_thread_mappings_ext_conv_uq", properties: ["externalConversationId", "tenantId"] })
304
+ ], ChannelThreadMapping);
305
+ OptionalProps;
306
+ let MessageReaction = class {
307
+ constructor() {
308
+ this.createdAt = /* @__PURE__ */ new Date();
309
+ }
310
+ };
311
+ __decorateClass([
312
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
313
+ ], MessageReaction.prototype, "id", 2);
314
+ __decorateClass([
315
+ Property({ name: "message_id", type: "uuid" })
316
+ ], MessageReaction.prototype, "messageId", 2);
317
+ __decorateClass([
318
+ Property({ name: "emoji", type: "text" })
319
+ ], MessageReaction.prototype, "emoji", 2);
320
+ __decorateClass([
321
+ Property({ name: "reacted_by_user_id", type: "uuid", nullable: true })
322
+ ], MessageReaction.prototype, "reactedByUserId", 2);
323
+ __decorateClass([
324
+ Property({ name: "reacted_by_external_id", type: "text", nullable: true })
325
+ ], MessageReaction.prototype, "reactedByExternalId", 2);
326
+ __decorateClass([
327
+ Property({ name: "reacted_by_display_name", type: "text", nullable: true })
328
+ ], MessageReaction.prototype, "reactedByDisplayName", 2);
329
+ __decorateClass([
330
+ Property({ name: "provider_key", type: "text", nullable: true })
331
+ ], MessageReaction.prototype, "providerKey", 2);
332
+ __decorateClass([
333
+ Property({ name: "external_reaction_id", type: "text", nullable: true })
334
+ ], MessageReaction.prototype, "externalReactionId", 2);
335
+ __decorateClass([
336
+ Property({ name: "tenant_id", type: "uuid" })
337
+ ], MessageReaction.prototype, "tenantId", 2);
338
+ __decorateClass([
339
+ Property({ name: "organization_id", type: "uuid", nullable: true })
340
+ ], MessageReaction.prototype, "organizationId", 2);
341
+ __decorateClass([
342
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
343
+ ], MessageReaction.prototype, "createdAt", 2);
344
+ MessageReaction = __decorateClass([
345
+ Entity({ tableName: "message_reactions" }),
346
+ Index({ name: "message_reactions_message_idx", properties: ["messageId"] }),
347
+ Index({ name: "message_reactions_message_emoji_idx", properties: ["messageId", "emoji"] }),
348
+ Index({
349
+ name: "message_reactions_internal_actor_uq",
350
+ expression: `create unique index "message_reactions_internal_actor_uq" on "message_reactions" ("tenant_id", "message_id", "emoji", "reacted_by_user_id") where "reacted_by_user_id" is not null`
351
+ }),
352
+ Index({
353
+ name: "message_reactions_external_actor_uq",
354
+ expression: `create unique index "message_reactions_external_actor_uq" on "message_reactions" ("tenant_id", "message_id", "emoji", "reacted_by_external_id") where "reacted_by_external_id" is not null`
355
+ }),
356
+ Check({
357
+ name: "message_reactions_exactly_one_actor_chk",
358
+ expression: `("reacted_by_user_id" is null) <> ("reacted_by_external_id" is null)`
359
+ })
360
+ ], MessageReaction);
361
+ OptionalProps;
362
+ let ChannelThreadToken = class {
363
+ constructor() {
364
+ this.createdAt = /* @__PURE__ */ new Date();
365
+ }
366
+ };
367
+ __decorateClass([
368
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
369
+ ], ChannelThreadToken.prototype, "id", 2);
370
+ __decorateClass([
371
+ Property({ name: "tenant_id", type: "uuid" })
372
+ ], ChannelThreadToken.prototype, "tenantId", 2);
373
+ __decorateClass([
374
+ Property({ name: "organization_id", type: "uuid", nullable: true })
375
+ ], ChannelThreadToken.prototype, "organizationId", 2);
376
+ __decorateClass([
377
+ Property({ name: "message_thread_id", type: "uuid" })
378
+ ], ChannelThreadToken.prototype, "messageThreadId", 2);
379
+ __decorateClass([
380
+ Property({ name: "token", type: "text" })
381
+ ], ChannelThreadToken.prototype, "token", 2);
382
+ __decorateClass([
383
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
384
+ ], ChannelThreadToken.prototype, "createdAt", 2);
385
+ __decorateClass([
386
+ Property({ name: "last_seen_at", type: Date, nullable: true })
387
+ ], ChannelThreadToken.prototype, "lastSeenAt", 2);
388
+ ChannelThreadToken = __decorateClass([
389
+ Entity({ tableName: "channel_thread_tokens" }),
390
+ Unique({ name: "channel_thread_tokens_thread_uq", properties: ["tenantId", "messageThreadId"] }),
391
+ Unique({ name: "channel_thread_tokens_token_uq", properties: ["tenantId", "token"] })
392
+ ], ChannelThreadToken);
393
+ OptionalProps;
394
+ let ChannelIngestDeadLetter = class {
395
+ constructor() {
396
+ this.createdAt = /* @__PURE__ */ new Date();
397
+ }
398
+ };
399
+ __decorateClass([
400
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
401
+ ], ChannelIngestDeadLetter.prototype, "id", 2);
402
+ __decorateClass([
403
+ Property({ name: "tenant_id", type: "uuid" })
404
+ ], ChannelIngestDeadLetter.prototype, "tenantId", 2);
405
+ __decorateClass([
406
+ Property({ name: "organization_id", type: "uuid", nullable: true })
407
+ ], ChannelIngestDeadLetter.prototype, "organizationId", 2);
408
+ __decorateClass([
409
+ Property({ name: "channel_id", type: "uuid" })
410
+ ], ChannelIngestDeadLetter.prototype, "channelId", 2);
411
+ __decorateClass([
412
+ Property({ name: "provider_key", type: "text" })
413
+ ], ChannelIngestDeadLetter.prototype, "providerKey", 2);
414
+ __decorateClass([
415
+ Property({ name: "external_uid", type: "text", nullable: true })
416
+ ], ChannelIngestDeadLetter.prototype, "externalUid", 2);
417
+ __decorateClass([
418
+ Property({ name: "external_message_id", type: "text", nullable: true })
419
+ ], ChannelIngestDeadLetter.prototype, "externalMessageId", 2);
420
+ __decorateClass([
421
+ Property({ name: "error_class", type: "text" })
422
+ ], ChannelIngestDeadLetter.prototype, "errorClass", 2);
423
+ __decorateClass([
424
+ Property({ name: "error_message", type: "text" })
425
+ ], ChannelIngestDeadLetter.prototype, "errorMessage", 2);
426
+ __decorateClass([
427
+ Property({ name: "raw_body", type: "text", nullable: true })
428
+ ], ChannelIngestDeadLetter.prototype, "rawBody", 2);
429
+ __decorateClass([
430
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
431
+ ], ChannelIngestDeadLetter.prototype, "createdAt", 2);
432
+ ChannelIngestDeadLetter = __decorateClass([
433
+ Entity({ tableName: "channel_ingest_dead_letters" }),
434
+ Index({ name: "channel_ingest_dead_letters_channel_idx", properties: ["channelId", "tenantId"] }),
435
+ Index({ name: "channel_ingest_dead_letters_created_idx", properties: ["tenantId", "createdAt"] })
436
+ ], ChannelIngestDeadLetter);
437
+ export {
438
+ ChannelIngestDeadLetter,
439
+ ChannelThreadMapping,
440
+ ChannelThreadToken,
441
+ CommunicationChannel,
442
+ ExternalConversation,
443
+ ExternalMessage,
444
+ MessageChannelLink,
445
+ MessageReaction
446
+ };
447
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/communication_channels/data/entities.ts"],
4
+ "sourcesContent": ["import { OptionalProps } from '@mikro-orm/core'\nimport { Check, Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\n\n/**\n * Hub entities for the Communication Channels module.\n *\n * Cross-module references (e.g. `MessageChannelLink.messageId \u2192 messages.message.id`)\n * use plain `uuid` columns, NOT MikroORM `@ManyToOne` decorators. Project rule:\n * \"No direct ORM relationships between modules \u2014 use foreign key IDs, fetch separately.\"\n * Cross-module links are declared in `data/extensions.ts` via `EntityExtension`.\n *\n * See SPEC-045d \u00A72.2.\n */\n\n// \u2500\u2500 CommunicationChannel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Per-channel lifecycle status. Set by the polling worker / outbound subscriber\n * + the `markChannelRequiresReauth` command. Existing `isActive` remains for the\n * coarse admin enable/disable toggle; `status` is the finer-grained operational\n * state used by per-user reconnect flows.\n *\n * Email integration spec \u00A7 Hub Deltas \u2192 Delta 2.\n */\nexport type CommunicationChannelStatus =\n | 'connected'\n | 'requires_reauth'\n | 'error'\n | 'disconnected'\n\n@Entity({ tableName: 'communication_channels' })\n@Index({ name: 'communication_channels_tenant_provider_idx', properties: ['tenantId', 'providerKey'] })\n// Provider-push webhooks (Gmail Pub/Sub) resolve channels by (provider_key,\n// external_identifier) WITHOUT a tenant_id \u2014 they only know the mailbox address.\n// Without this index that lookup is a full scan over every channel of the\n// provider, which a (signature-verified) push or replay repeats on every hit.\n@Index({\n name: 'communication_channels_provider_external_idx',\n expression:\n `create index \"communication_channels_provider_external_idx\" on \"communication_channels\" (\"provider_key\", \"external_identifier\") where \"deleted_at\" is null`,\n})\n@Index({ name: 'communication_channels_tenant_type_active_idx', properties: ['tenantId', 'channelType', 'isActive'] })\n@Index({\n name: 'communication_channels_user_lookup_idx',\n properties: ['userId', 'channelType', 'deletedAt'],\n})\n@Index({\n name: 'communication_channels_poll_due_idx',\n expression:\n `create index \"communication_channels_poll_due_idx\" on \"communication_channels\" (\"is_active\", \"last_polled_at\") where \"deleted_at\" is null`,\n})\n@Index({\n name: 'communication_channels_one_primary_per_user_uq',\n expression:\n `create unique index \"communication_channels_one_primary_per_user_uq\" on \"communication_channels\" (\"user_id\") where \"is_primary\" and \"user_id\" is not null and \"deleted_at\" is null`,\n})\n// One channel per (tenant, user, provider, mailbox): a reconnect heals the\n// existing row in place (see `createConnectedChannelRow`) instead of inserting a\n// duplicate that would stay polled + keep its own push subscription. Partial so\n// tenant-wide channels (null user_id) and identifier-less rows are exempt.\n@Index({\n name: 'communication_channels_user_provider_external_uq',\n expression:\n `create unique index \"communication_channels_user_provider_external_uq\" on \"communication_channels\" (\"tenant_id\", \"user_id\", \"provider_key\", \"external_identifier\") where \"deleted_at\" is null and \"user_id\" is not null and \"external_identifier\" is not null`,\n})\nexport class CommunicationChannel {\n [OptionalProps]?:\n | 'createdAt'\n | 'updatedAt'\n | 'isActive'\n | 'capabilities'\n | 'deletedAt'\n | 'externalIdentifier'\n | 'credentialsRef'\n | 'organizationId'\n | 'userId'\n | 'isPrimary'\n | 'pollIntervalSeconds'\n | 'lastPolledAt'\n | 'status'\n | 'lastError'\n | 'channelState'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n @Property({ name: 'channel_type', type: 'text' })\n channelType!: string\n\n @Property({ name: 'display_name', type: 'text' })\n displayName!: string\n\n @Property({ name: 'external_identifier', type: 'text', nullable: true })\n externalIdentifier?: string | null\n\n @Property({ name: 'credentials_ref', type: 'uuid', nullable: true })\n credentialsRef?: string | null\n\n @Property({ name: 'capabilities', type: 'json', nullable: true })\n capabilities?: Record<string, unknown> | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n /**\n * Per-user channel owner. NULL = tenant-scoped (existing behaviour, e.g. WhatsApp Business).\n * Set = user-scoped (e.g. Jane's personal Gmail). Visible only to the owning user\n * and to admins with `communication_channels.admin`. Linked to `auth:user` via\n * `EntityExtension` in `data/extensions.ts` \u2014 never a raw DB FK.\n */\n @Property({ name: 'user_id', type: 'uuid', nullable: true })\n userId?: string | null\n\n /**\n * Per-user \"primary\" flag. Only meaningful when `userId IS NOT NULL`; ignored\n * for tenant-scoped channels. Enforced as one-primary-per-user by the partial\n * unique index `communication_channels_one_primary_per_user_uq`.\n */\n @Property({ name: 'is_primary', type: 'boolean', default: false })\n isPrimary: boolean = false\n\n /**\n * Polling cadence in seconds. NULL means \"this channel does not poll\" \u2014 i.e. it\n * is push-only (webhook) or its provider opted out via\n * `ChannelCapabilities.realtimePush !== false`. Set means hub-managed polling\n * at that interval via the `poll-tick` scheduler entry.\n */\n @Property({ name: 'poll_interval_seconds', type: 'int', nullable: true })\n pollIntervalSeconds?: number | null\n\n /** Last successful poll timestamp; the scheduler enumerates by this column. */\n @Property({ name: 'last_polled_at', type: Date, nullable: true })\n lastPolledAt?: Date | null\n\n /**\n * Per-channel lifecycle status. See {@link CommunicationChannelStatus}.\n * Migration sets `status = 'connected'` for all existing active channels (default value).\n */\n @Property({ name: 'status', type: 'text', default: 'connected' })\n status: CommunicationChannelStatus = 'connected'\n\n /** Most recent classified error message for diagnostics. */\n @Property({ name: 'last_error', type: 'text', nullable: true })\n lastError?: string | null\n\n /**\n * Provider-specific resumption state, opaque to the hub. Polling adapters\n * encode their incremental cursor here (Gmail historyId, IMAP\n * UIDVALIDITY+UIDNEXT). The polling worker reads it before each\n * `fetchHistory` call and writes the adapter's returned `nextCursor` back\n * after a successful poll. Empty / NULL means \"bootstrap on next poll\".\n */\n @Property({ name: 'channel_state', type: 'json', nullable: true })\n channelState?: Record<string, unknown> | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500 ExternalConversation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n@Entity({ tableName: 'external_conversations' })\n@Index({ name: 'external_conversations_channel_idx', properties: ['channelId', 'externalConversationId'] })\n@Index({ name: 'external_conversations_contact_person_idx', properties: ['contactPersonId'] })\n@Index({ name: 'external_conversations_assigned_user_idx', properties: ['assignedUserId'] })\n@Unique({ name: 'external_conversations_channel_external_uq', properties: ['channelId', 'externalConversationId'] })\nexport class ExternalConversation {\n [OptionalProps]?: 'createdAt' | 'updatedAt' | 'lastMessageAt' | 'subject' | 'contactPersonId' | 'assignedUserId' | 'organizationId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'channel_id', type: 'uuid' })\n channelId!: string\n\n @Property({ name: 'external_conversation_id', type: 'text' })\n externalConversationId!: string\n\n @Property({ name: 'subject', type: 'text', nullable: true })\n subject?: string | null\n\n @Property({ name: 'contact_person_id', type: 'uuid', nullable: true })\n contactPersonId?: string | null\n\n @Property({ name: 'assigned_user_id', type: 'uuid', nullable: true })\n assignedUserId?: string | null\n\n @Property({ name: 'last_message_at', type: Date, nullable: true })\n lastMessageAt?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// \u2500\u2500 ExternalMessage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n@Entity({ tableName: 'external_messages' })\n@Index({ name: 'external_messages_conversation_idx', properties: ['conversationId'] })\n@Index({ name: 'external_messages_channel_external_idx', properties: ['channelId', 'externalMessageId'] })\n@Unique({ name: 'external_messages_channel_external_uq', properties: ['channelId', 'externalMessageId'] })\nexport class ExternalMessage {\n [OptionalProps]?: 'createdAt' | 'senderIdentifier' | 'senderDisplayName' | 'providerTimestamp' | 'organizationId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'channel_id', type: 'uuid' })\n channelId!: string\n\n @Property({ name: 'conversation_id', type: 'uuid' })\n conversationId!: string\n\n @Property({ name: 'external_message_id', type: 'text' })\n externalMessageId!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'inbound' | 'outbound'\n\n @Property({ name: 'sender_identifier', type: 'text', nullable: true })\n senderIdentifier?: string | null\n\n @Property({ name: 'sender_display_name', type: 'text', nullable: true })\n senderDisplayName?: string | null\n\n @Property({ name: 'provider_timestamp', type: Date, nullable: true })\n providerTimestamp?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n// \u2500\u2500 MessageChannelLink \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n@Entity({ tableName: 'message_channel_links' })\n@Index({ name: 'message_channel_links_message_idx', properties: ['messageId'] })\n@Index({ name: 'message_channel_links_ext_conv_idx', properties: ['externalConversationId'] })\n@Index({ name: 'message_channel_links_ext_msg_idx', properties: ['externalMessageId'] })\n@Unique({ name: 'message_channel_links_message_uq', properties: ['messageId'] })\nexport class MessageChannelLink {\n [OptionalProps]?: 'createdAt' | 'deliveryStatus' | 'externalMessageId' | 'channelPayload' | 'channelContentType' | 'interactiveState' | 'channelMetadata' | 'organizationId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n /** Logical link to messages.message.id (no DB FK \u2014 cross-module via EntityExtension). */\n @Property({ name: 'message_id', type: 'uuid' })\n messageId!: string\n\n /** FK to external_conversations.id (intra-module \u2014 DB FK acceptable but kept as plain uuid for symmetry). */\n @Property({ name: 'external_conversation_id', type: 'uuid' })\n externalConversationId!: string\n\n @Property({ name: 'external_message_id', type: 'uuid', nullable: true })\n externalMessageId?: string | null\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n @Property({ name: 'channel_type', type: 'text' })\n channelType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'inbound' | 'outbound'\n\n @Property({ name: 'delivery_status', type: 'text' })\n deliveryStatus: string = 'pending'\n\n @Property({ name: 'channel_payload', type: 'json', nullable: true })\n channelPayload?: Record<string, unknown> | null\n\n @Property({ name: 'channel_content_type', type: 'text', nullable: true })\n channelContentType?: string | null\n\n @Property({ name: 'interactive_state', type: 'json', nullable: true })\n interactiveState?: Record<string, unknown> | null\n\n @Property({ name: 'channel_metadata', type: 'json', nullable: true })\n channelMetadata?: Record<string, unknown> | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n// \u2500\u2500 ChannelThreadMapping \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n@Entity({ tableName: 'channel_thread_mappings' })\n@Index({ name: 'channel_thread_mappings_ext_conv_idx', properties: ['externalConversationId', 'tenantId'] })\n@Index({ name: 'channel_thread_mappings_thread_idx', properties: ['messageThreadId', 'tenantId'] })\n@Unique({ name: 'channel_thread_mappings_ext_conv_uq', properties: ['externalConversationId', 'tenantId'] })\nexport class ChannelThreadMapping {\n [OptionalProps]?: 'createdAt' | 'updatedAt' | 'assignedUserId' | 'organizationId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'external_conversation_id', type: 'uuid' })\n externalConversationId!: string\n\n /** Logical link to messages.message.thread_id (no DB FK \u2014 cross-module). */\n @Property({ name: 'message_thread_id', type: 'uuid' })\n messageThreadId!: string\n\n @Property({ name: 'channel_id', type: 'uuid' })\n channelId!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n @Property({ name: 'external_thread_ref', type: 'text' })\n externalThreadRef!: string\n\n /** Logical link to auth.user.id (no DB FK \u2014 cross-module). */\n @Property({ name: 'assigned_user_id', type: 'uuid', nullable: true })\n assignedUserId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// \u2500\u2500 MessageReaction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n@Entity({ tableName: 'message_reactions' })\n@Index({ name: 'message_reactions_message_idx', properties: ['messageId'] })\n@Index({ name: 'message_reactions_message_emoji_idx', properties: ['messageId', 'emoji'] })\n@Index({\n name: 'message_reactions_internal_actor_uq',\n expression:\n `create unique index \"message_reactions_internal_actor_uq\" on \"message_reactions\" (\"tenant_id\", \"message_id\", \"emoji\", \"reacted_by_user_id\") where \"reacted_by_user_id\" is not null`,\n})\n@Index({\n name: 'message_reactions_external_actor_uq',\n expression:\n `create unique index \"message_reactions_external_actor_uq\" on \"message_reactions\" (\"tenant_id\", \"message_id\", \"emoji\", \"reacted_by_external_id\") where \"reacted_by_external_id\" is not null`,\n})\n@Check({\n name: 'message_reactions_exactly_one_actor_chk',\n expression: `(\"reacted_by_user_id\" is null) <> (\"reacted_by_external_id\" is null)`,\n})\nexport class MessageReaction {\n [OptionalProps]?: 'createdAt' | 'reactedByUserId' | 'reactedByExternalId' | 'reactedByDisplayName' | 'providerKey' | 'externalReactionId' | 'organizationId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n /** Logical link to messages.message.id (no DB FK \u2014 cross-module). */\n @Property({ name: 'message_id', type: 'uuid' })\n messageId!: string\n\n @Property({ name: 'emoji', type: 'text' })\n emoji!: string\n\n /** Logical link to auth.user.id (no DB FK \u2014 cross-module). NULL for external reactions. */\n @Property({ name: 'reacted_by_user_id', type: 'uuid', nullable: true })\n reactedByUserId?: string | null\n\n @Property({ name: 'reacted_by_external_id', type: 'text', nullable: true })\n reactedByExternalId?: string | null\n\n @Property({ name: 'reacted_by_display_name', type: 'text', nullable: true })\n reactedByDisplayName?: string | null\n\n @Property({ name: 'provider_key', type: 'text', nullable: true })\n providerKey?: string | null\n\n @Property({ name: 'external_reaction_id', type: 'text', nullable: true })\n externalReactionId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n// \u2500\u2500 ChannelThreadToken \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Per-thread HMAC-signed opaque token used by the layered thread-matcher to\n * reliably attach inbound replies to the originating Open Mercato message\n * thread, even when the recipient's mail client strips RFC 5322 headers.\n *\n * Created lazily on the first outbound message in a thread by the\n * `outbound-bridge` subscriber. The token is injected into:\n * 1. The MIME `References:` header as `<om_TOKEN@open-mercato.invalid>` \u2014\n * invisible to the recipient and survives most reply clients.\n * 2. A hidden HTML body span `<span style=\"display:none\">[OM:om_TOKEN]</span>` \u2014\n * survives when References is stripped (e.g. some mobile clients).\n * 3. A plain-text trailer `[OM:om_TOKEN]` \u2014 survives plain-text-only replies.\n *\n * The unique constraint is `(tenantId, token)` \u2014 tenant isolation by\n * construction. HMAC verification (via `lib/thread-token.ts`) defends against\n * forged inbound messages: tokens that don't HMAC-verify never reach the DB\n * lookup.\n *\n * See `.ai/specs/2026-05-27-email-integration-inbound-reliability-and-threading.md`.\n */\n@Entity({ tableName: 'channel_thread_tokens' })\n// One token row per (tenant, thread): the matcher resolves every reply to the\n// same thread regardless of which outbound send minted the token. The unique\n// constraint also makes `getOrCreateThreadToken` race-safe (insert-on-conflict).\n@Unique({ name: 'channel_thread_tokens_thread_uq', properties: ['tenantId', 'messageThreadId'] })\n@Unique({ name: 'channel_thread_tokens_token_uq', properties: ['tenantId', 'token'] })\nexport class ChannelThreadToken {\n [OptionalProps]?: 'createdAt' | 'lastSeenAt' | 'organizationId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n /** Logical link to messages.message.thread_id (no DB FK \u2014 cross-module). */\n @Property({ name: 'message_thread_id', type: 'uuid' })\n messageThreadId!: string\n\n /**\n * HMAC-signed opaque token, format: `om_<22b64url>_<11b64url>` (16 random\n * bytes + 8 HMAC bytes, each base64url-encoded without padding), ~37 chars.\n */\n @Property({ name: 'token', type: 'text' })\n token!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n /**\n * Updated whenever a thread-matcher token-based strategy resolves to this\n * row. Used for future GC: tokens with `last_seen_at < now() - 90 days`\n * are pruning candidates.\n */\n @Property({ name: 'last_seen_at', type: Date, nullable: true })\n lastSeenAt?: Date | null\n}\n\n// \u2500\u2500 ChannelIngestDeadLetter \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Inbound messages that fail permanently during ingest land here so an\n * operator can replay them after fixing parsers / schemas. Transient\n * failures (DB blip, network timeout) DO NOT write here \u2014 those abort the\n * poll loop without advancing the cursor so the message is re-fetched on\n * the next tick.\n *\n * `raw_body` is encrypted at rest via the module's `encryption.ts`\n * `defaultEncryptionMaps` entry (MIME bodies may contain PII).\n *\n * See `.ai/specs/2026-05-27-email-integration-inbound-reliability-and-threading.md`\n * (\u00A7 3 Data Model).\n */\n@Entity({ tableName: 'channel_ingest_dead_letters' })\n@Index({ name: 'channel_ingest_dead_letters_channel_idx', properties: ['channelId', 'tenantId'] })\n@Index({ name: 'channel_ingest_dead_letters_created_idx', properties: ['tenantId', 'createdAt'] })\nexport class ChannelIngestDeadLetter {\n [OptionalProps]?:\n | 'createdAt'\n | 'organizationId'\n | 'externalMessageId'\n | 'externalUid'\n | 'rawBody'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'channel_id', type: 'uuid' })\n channelId!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n /** External UID / sequence-number for the provider (e.g. IMAP UID, Gmail messageId). */\n @Property({ name: 'external_uid', type: 'text', nullable: true })\n externalUid?: string | null\n\n @Property({ name: 'external_message_id', type: 'text', nullable: true })\n externalMessageId?: string | null\n\n @Property({ name: 'error_class', type: 'text' })\n errorClass!: string\n\n @Property({ name: 'error_message', type: 'text' })\n errorMessage!: string\n\n /** Truncated source \u2014 first N bytes of the raw MIME / payload (encrypted at rest). */\n @Property({ name: 'raw_body', type: 'text', nullable: true })\n rawBody?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n"],
5
+ "mappings": ";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,OAAO,QAAQ,OAAO,YAAY,UAAU,cAAc;AAiEhE;AADI,IAAM,uBAAN,MAA2B;AAAA,EAA3B;AAwCL,oBAAoB;AAiBpB,qBAAqB;AAoBrB,kBAAqC;AAuBrC,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AAxFE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GAlBlD,qBAmBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,gBAAgB,MAAM,OAAO,CAAC;AAAA,GArBrC,qBAsBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,gBAAgB,MAAM,OAAO,CAAC;AAAA,GAxBrC,qBAyBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,gBAAgB,MAAM,OAAO,CAAC;AAAA,GA3BrC,qBA4BX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,uBAAuB,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GA9B5D,qBA+BX;AAGA;AAAA,EADC,SAAS,EAAE,MAA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GApBrC,wBAqBX;AAIA;AAAA,EADC,SAAS,EAAE,MAAM,gBAAgB,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAxBrD,wBAyBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,uBAAuB,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GA3B5D,wBA4BX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,OAAO,CAAC;AAAA,GA9BpC,wBA+BX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,OAAO,CAAC;AAAA,GAjCtC,wBAkCX;AAIA;AAAA,EADC,SAAS,EAAE,MAAM,YAAY,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GArCjD,wBAsCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GAxC7D,wBAyCX;AAzCW,0BAAN;AAAA,EAHN,OAAO,EAAE,WAAW,8BAA8B,CAAC;AAAA,EACnD,MAAM,EAAE,MAAM,2CAA2C,YAAY,CAAC,aAAa,UAAU,EAAE,CAAC;AAAA,EAChG,MAAM,EAAE,MAAM,2CAA2C,YAAY,CAAC,YAAY,WAAW,EAAE,CAAC;AAAA,GACpF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,67 @@
1
+ const entityExtensions = [
2
+ {
3
+ base: "messages:message",
4
+ extension: "communication_channels:message_channel_link",
5
+ join: { baseKey: "id", extensionKey: "message_id" },
6
+ cardinality: "one-to-one",
7
+ description: "Links Messages to external channel conversations"
8
+ },
9
+ {
10
+ base: "messages:message",
11
+ extension: "communication_channels:message_reaction",
12
+ join: { baseKey: "id", extensionKey: "message_id" },
13
+ cardinality: "one-to-many",
14
+ description: "Emoji reactions on messages from external channels and internal users"
15
+ },
16
+ {
17
+ base: "auth:user",
18
+ extension: "communication_channels:external_conversation",
19
+ join: { baseKey: "id", extensionKey: "assigned_user_id" },
20
+ cardinality: "one-to-many",
21
+ description: "Conversations assigned to a user in the unified inbox"
22
+ },
23
+ {
24
+ base: "customers:customer_entity",
25
+ extension: "communication_channels:external_conversation",
26
+ join: { baseKey: "id", extensionKey: "contact_person_id" },
27
+ cardinality: "one-to-many",
28
+ description: "Conversations matched to a CRM person"
29
+ },
30
+ /**
31
+ * Per-user channel ownership (added by the email integration spec).
32
+ *
33
+ * Links every `CommunicationChannel` row whose `user_id IS NOT NULL` back to
34
+ * its owning `auth:user`. Powers the per-user profile page, RBAC filters, and
35
+ * future ownership-aware features (CRM, automations).
36
+ */
37
+ {
38
+ base: "auth:user",
39
+ extension: "communication_channels:communication_channel",
40
+ join: { baseKey: "id", extensionKey: "user_id" },
41
+ cardinality: "one-to-many",
42
+ description: "Per-user owned channels (Gmail/IMAP personal mailboxes)"
43
+ },
44
+ /**
45
+ * Per-user credentials scoping (added by the email integration spec).
46
+ *
47
+ * Links `integration_credentials.user_id` back to `auth:user`. Set when a
48
+ * channel's credentials belong to a specific user (e.g. that user's OAuth
49
+ * refresh token), NULL for tenant-wide shared secrets. The hub spec owns the
50
+ * EXTENSION declaration; the integrations module owns the COLUMN — coordinated
51
+ * change shipped in the same PR.
52
+ */
53
+ {
54
+ base: "auth:user",
55
+ extension: "integrations:integration_credentials",
56
+ join: { baseKey: "id", extensionKey: "user_id" },
57
+ cardinality: "one-to-many",
58
+ description: "Per-user credentials (OAuth refresh tokens, per-user IMAP/SMTP passwords)"
59
+ }
60
+ ];
61
+ const extensions = entityExtensions;
62
+ var extensions_default = entityExtensions;
63
+ export {
64
+ extensions_default as default,
65
+ extensions
66
+ };
67
+ //# sourceMappingURL=extensions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/communication_channels/data/extensions.ts"],
4
+ "sourcesContent": ["import type { EntityExtension } from '@open-mercato/shared/modules/entities'\n\n/**\n * Cross-module entity links declared by the communication_channels hub.\n *\n * The hub knows about other modules (auth, customers, messages) but those modules\n * do NOT know about the hub \u2014 dependency direction is one-way (hub \u2192 others).\n * Lookups across these links happen via the query engine, never via raw SQL joins.\n *\n * Canonical EntityExtension shape from `@open-mercato/shared/modules/entities`:\n * `{ base, extension, join: { baseKey, extensionKey }, cardinality?, required?, description? }`\n */\n\nconst entityExtensions: EntityExtension[] = [\n {\n base: 'messages:message',\n extension: 'communication_channels:message_channel_link',\n join: { baseKey: 'id', extensionKey: 'message_id' },\n cardinality: 'one-to-one',\n description: 'Links Messages to external channel conversations',\n },\n {\n base: 'messages:message',\n extension: 'communication_channels:message_reaction',\n join: { baseKey: 'id', extensionKey: 'message_id' },\n cardinality: 'one-to-many',\n description: 'Emoji reactions on messages from external channels and internal users',\n },\n {\n base: 'auth:user',\n extension: 'communication_channels:external_conversation',\n join: { baseKey: 'id', extensionKey: 'assigned_user_id' },\n cardinality: 'one-to-many',\n description: 'Conversations assigned to a user in the unified inbox',\n },\n {\n base: 'customers:customer_entity',\n extension: 'communication_channels:external_conversation',\n join: { baseKey: 'id', extensionKey: 'contact_person_id' },\n cardinality: 'one-to-many',\n description: 'Conversations matched to a CRM person',\n },\n /**\n * Per-user channel ownership (added by the email integration spec).\n *\n * Links every `CommunicationChannel` row whose `user_id IS NOT NULL` back to\n * its owning `auth:user`. Powers the per-user profile page, RBAC filters, and\n * future ownership-aware features (CRM, automations).\n */\n {\n base: 'auth:user',\n extension: 'communication_channels:communication_channel',\n join: { baseKey: 'id', extensionKey: 'user_id' },\n cardinality: 'one-to-many',\n description: 'Per-user owned channels (Gmail/IMAP personal mailboxes)',\n },\n /**\n * Per-user credentials scoping (added by the email integration spec).\n *\n * Links `integration_credentials.user_id` back to `auth:user`. Set when a\n * channel's credentials belong to a specific user (e.g. that user's OAuth\n * refresh token), NULL for tenant-wide shared secrets. The hub spec owns the\n * EXTENSION declaration; the integrations module owns the COLUMN \u2014 coordinated\n * change shipped in the same PR.\n */\n {\n base: 'auth:user',\n extension: 'integrations:integration_credentials',\n join: { baseKey: 'id', extensionKey: 'user_id' },\n cardinality: 'one-to-many',\n description: 'Per-user credentials (OAuth refresh tokens, per-user IMAP/SMTP passwords)',\n },\n]\n\nexport const extensions = entityExtensions\nexport default entityExtensions\n"],
5
+ "mappings": "AAaA,MAAM,mBAAsC;AAAA,EAC1C;AAAA,IACE,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM,EAAE,SAAS,MAAM,cAAc,aAAa;AAAA,IAClD,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM,EAAE,SAAS,MAAM,cAAc,aAAa;AAAA,IAClD,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM,EAAE,SAAS,MAAM,cAAc,mBAAmB;AAAA,IACxD,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM,EAAE,SAAS,MAAM,cAAc,oBAAoB;AAAA,IACzD,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA;AAAA,IACE,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM,EAAE,SAAS,MAAM,cAAc,UAAU;AAAA,IAC/C,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AAAA,IACE,MAAM;AAAA,IACN,WAAW;AAAA,IACX,MAAM,EAAE,SAAS,MAAM,cAAc,UAAU;AAAA,IAC/C,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AACF;AAEO,MAAM,aAAa;AAC1B,IAAO,qBAAQ;",
6
+ "names": []
7
+ }