@openpeepshq/core 0.1.31

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 (500) hide show
  1. package/LICENSE +674 -0
  2. package/dist/accessTokens/finders.d.ts +11 -0
  3. package/dist/accessTokens/finders.js +43 -0
  4. package/dist/accessTokens/helpers.d.ts +13 -0
  5. package/dist/accessTokens/helpers.js +15 -0
  6. package/dist/accessTokens/index.d.ts +4 -0
  7. package/dist/accessTokens/index.js +4 -0
  8. package/dist/accessTokens/mapping.d.ts +10 -0
  9. package/dist/accessTokens/mapping.js +25 -0
  10. package/dist/accessTokens/mutations.d.ts +4 -0
  11. package/dist/accessTokens/mutations.js +24 -0
  12. package/dist/accessTokens/revokations.d.ts +2 -0
  13. package/dist/accessTokens/revokations.js +18 -0
  14. package/dist/accessTokens/tokens.d.ts +31 -0
  15. package/dist/accessTokens/tokens.js +174 -0
  16. package/dist/accounts/cache.d.ts +3 -0
  17. package/dist/accounts/cache.js +13 -0
  18. package/dist/accounts/finders.d.ts +6 -0
  19. package/dist/accounts/finders.js +17 -0
  20. package/dist/accounts/helpers.d.ts +7 -0
  21. package/dist/accounts/helpers.js +36 -0
  22. package/dist/accounts/index.d.ts +6 -0
  23. package/dist/accounts/index.js +6 -0
  24. package/dist/accounts/mapping.d.ts +10 -0
  25. package/dist/accounts/mapping.js +28 -0
  26. package/dist/accounts/mutations.d.ts +21 -0
  27. package/dist/accounts/mutations.js +204 -0
  28. package/dist/analytics/cache.d.ts +6 -0
  29. package/dist/analytics/cache.js +29 -0
  30. package/dist/analytics/compile.d.ts +4 -0
  31. package/dist/analytics/compile.js +296 -0
  32. package/dist/analytics/dateRange.d.ts +39 -0
  33. package/dist/analytics/dateRange.js +181 -0
  34. package/dist/analytics/index.d.ts +8 -0
  35. package/dist/analytics/index.js +8 -0
  36. package/dist/analytics/jobs.d.ts +20 -0
  37. package/dist/analytics/jobs.js +84 -0
  38. package/dist/analytics/metrics.d.ts +4 -0
  39. package/dist/analytics/metrics.js +13 -0
  40. package/dist/analytics/pdfReport.d.ts +8 -0
  41. package/dist/analytics/pdfReport.js +821 -0
  42. package/dist/analytics/read.d.ts +6 -0
  43. package/dist/analytics/read.js +696 -0
  44. package/dist/analytics/report.d.ts +293 -0
  45. package/dist/analytics/report.js +153 -0
  46. package/dist/analytics/settings.d.ts +3 -0
  47. package/dist/analytics/settings.js +37 -0
  48. package/dist/backups/index.d.ts +5 -0
  49. package/dist/backups/index.js +260 -0
  50. package/dist/backups/metadata.d.ts +9 -0
  51. package/dist/backups/metadata.js +2 -0
  52. package/dist/config/db.d.ts +7 -0
  53. package/dist/config/db.js +26 -0
  54. package/dist/config/defaults/capabilities.d.ts +2 -0
  55. package/dist/config/defaults/capabilities.js +47 -0
  56. package/dist/config/defaults/community.d.ts +2 -0
  57. package/dist/config/defaults/community.js +41 -0
  58. package/dist/config/defaults/core.d.ts +2 -0
  59. package/dist/config/defaults/core.js +113 -0
  60. package/dist/config/defaults/db.d.ts +6 -0
  61. package/dist/config/defaults/db.js +8 -0
  62. package/dist/config/defaults/logs.d.ts +6 -0
  63. package/dist/config/defaults/logs.js +7 -0
  64. package/dist/config/defaults/redis.d.ts +4 -0
  65. package/dist/config/defaults/redis.js +5 -0
  66. package/dist/config/helpers.d.ts +11 -0
  67. package/dist/config/helpers.js +31 -0
  68. package/dist/config/index.d.ts +392 -0
  69. package/dist/config/index.js +83 -0
  70. package/dist/config/pruneEmptyConfigStrings.d.ts +7 -0
  71. package/dist/config/pruneEmptyConfigStrings.js +29 -0
  72. package/dist/db/aql.d.ts +0 -0
  73. package/dist/db/aql.js +1 -0
  74. package/dist/db/arango.d.ts +2 -0
  75. package/dist/db/arango.js +110 -0
  76. package/dist/db/bootMigrate.d.ts +1 -0
  77. package/dist/db/bootMigrate.js +15 -0
  78. package/dist/db/examples.d.ts +1 -0
  79. package/dist/db/examples.js +13 -0
  80. package/dist/db/explorer/csv.d.ts +1 -0
  81. package/dist/db/explorer/csv.js +18 -0
  82. package/dist/db/explorer/index.d.ts +6 -0
  83. package/dist/db/explorer/index.js +5 -0
  84. package/dist/db/explorer/mutate.d.ts +6 -0
  85. package/dist/db/explorer/mutate.js +66 -0
  86. package/dist/db/explorer/query.d.ts +17 -0
  87. package/dist/db/explorer/query.js +48 -0
  88. package/dist/db/explorer/sql.d.ts +11 -0
  89. package/dist/db/explorer/sql.js +42 -0
  90. package/dist/db/explorer/tables.d.ts +9 -0
  91. package/dist/db/explorer/tables.js +65 -0
  92. package/dist/db/helpers.d.ts +64 -0
  93. package/dist/db/helpers.js +240 -0
  94. package/dist/db/index.d.ts +13 -0
  95. package/dist/db/index.js +15 -0
  96. package/dist/db/init.d.ts +2 -0
  97. package/dist/db/init.js +10 -0
  98. package/dist/db/migration/autoMigrate.d.ts +2 -0
  99. package/dist/db/migration/autoMigrate.js +111 -0
  100. package/dist/db/migration/cli.d.ts +1 -0
  101. package/dist/db/migration/cli.js +56 -0
  102. package/dist/db/migration/detect.d.ts +6 -0
  103. package/dist/db/migration/detect.js +87 -0
  104. package/dist/db/migration/exportArango.d.ts +4 -0
  105. package/dist/db/migration/exportArango.js +80 -0
  106. package/dist/db/migration/importCollections.d.ts +19 -0
  107. package/dist/db/migration/importCollections.js +280 -0
  108. package/dist/db/migration/importPostgres.d.ts +3 -0
  109. package/dist/db/migration/importPostgres.js +18 -0
  110. package/dist/db/migration/shared.d.ts +39 -0
  111. package/dist/db/migration/shared.js +158 -0
  112. package/dist/db/migration/transform.d.ts +18 -0
  113. package/dist/db/migration/transform.js +209 -0
  114. package/dist/db/migration/validate.d.ts +18 -0
  115. package/dist/db/migration/validate.js +69 -0
  116. package/dist/db/pg/client.d.ts +35 -0
  117. package/dist/db/pg/client.js +126 -0
  118. package/dist/db/pg/collections.d.ts +48 -0
  119. package/dist/db/pg/collections.js +53 -0
  120. package/dist/db/pg/filters/common.d.ts +21 -0
  121. package/dist/db/pg/filters/common.js +48 -0
  122. package/dist/db/pg/filters/edges.d.ts +9 -0
  123. package/dist/db/pg/filters/edges.js +10 -0
  124. package/dist/db/pg/filters/groups.d.ts +7 -0
  125. package/dist/db/pg/filters/groups.js +15 -0
  126. package/dist/db/pg/filters/index.d.ts +22 -0
  127. package/dist/db/pg/filters/index.js +35 -0
  128. package/dist/db/pg/filters/notifications.d.ts +6 -0
  129. package/dist/db/pg/filters/notifications.js +10 -0
  130. package/dist/db/pg/filters/posts.d.ts +18 -0
  131. package/dist/db/pg/filters/posts.js +25 -0
  132. package/dist/db/pg/filters/profiles.d.ts +6 -0
  133. package/dist/db/pg/filters/profiles.js +9 -0
  134. package/dist/db/pg/filters/types.d.ts +7 -0
  135. package/dist/db/pg/filters/types.js +5 -0
  136. package/dist/db/pg/helpers.d.ts +19 -0
  137. package/dist/db/pg/helpers.js +67 -0
  138. package/dist/db/pg/map/filters.d.ts +22 -0
  139. package/dist/db/pg/map/filters.js +566 -0
  140. package/dist/db/pg/map/helpers.d.ts +2 -0
  141. package/dist/db/pg/map/helpers.js +2 -0
  142. package/dist/db/pg/map/index.d.ts +46 -0
  143. package/dist/db/pg/map/index.js +93 -0
  144. package/dist/db/pg/map/mutations.d.ts +11 -0
  145. package/dist/db/pg/map/mutations.js +135 -0
  146. package/dist/db/pg/map/queryTypes.d.ts +115 -0
  147. package/dist/db/pg/map/queryTypes.js +1 -0
  148. package/dist/db/pg/map/registry.d.ts +29 -0
  149. package/dist/db/pg/map/registry.js +413 -0
  150. package/dist/db/pg/map/relations.d.ts +28 -0
  151. package/dist/db/pg/map/relations.js +399 -0
  152. package/dist/db/pg/map/search.d.ts +6 -0
  153. package/dist/db/pg/map/search.js +190 -0
  154. package/dist/db/pg/map/types.d.ts +11 -0
  155. package/dist/db/pg/map/types.js +1 -0
  156. package/dist/db/pg/mappers.d.ts +28 -0
  157. package/dist/db/pg/mappers.js +29 -0
  158. package/dist/db/pg/migrate.d.ts +14 -0
  159. package/dist/db/pg/migrate.js +134 -0
  160. package/dist/db/pg/queries/activity.d.ts +10 -0
  161. package/dist/db/pg/queries/activity.js +47 -0
  162. package/dist/db/pg/queries/computed.d.ts +7 -0
  163. package/dist/db/pg/queries/computed.js +19 -0
  164. package/dist/db/pg/queries/derived.d.ts +22 -0
  165. package/dist/db/pg/queries/derived.js +100 -0
  166. package/dist/db/pg/queries/index.d.ts +4 -0
  167. package/dist/db/pg/queries/index.js +4 -0
  168. package/dist/db/pg/queries/sorts.d.ts +10 -0
  169. package/dist/db/pg/queries/sorts.js +9 -0
  170. package/dist/db/pg/schema/analytics.d.ts +998 -0
  171. package/dist/db/pg/schema/analytics.js +110 -0
  172. package/dist/db/pg/schema/base.d.ts +36 -0
  173. package/dist/db/pg/schema/base.js +23 -0
  174. package/dist/db/pg/schema/documents.d.ts +2002 -0
  175. package/dist/db/pg/schema/documents.js +40 -0
  176. package/dist/db/pg/schema/edges.d.ts +2725 -0
  177. package/dist/db/pg/schema/edges.js +34 -0
  178. package/dist/db/pg/schema/index.d.ts +5724 -0
  179. package/dist/db/pg/schema/index.js +7 -0
  180. package/dist/db/pg/sql/0000_bizarre_chat.sql +456 -0
  181. package/dist/db/pg/sql/0001_search_vector.sql +122 -0
  182. package/dist/db/pg/sql/0002_data_migrations_id_text.sql +1 -0
  183. package/dist/db/pg/sql/0003_fix_group_post_visibility.sql +4 -0
  184. package/dist/db/pg/sql/0004_analytics.sql +90 -0
  185. package/dist/db/pg/sql/meta/0000_snapshot.json +3380 -0
  186. package/dist/db/pg/sql/meta/0004_snapshot.json +4114 -0
  187. package/dist/db/pg/sql/meta/_journal.json +41 -0
  188. package/dist/db/replaceHostname.d.ts +1 -0
  189. package/dist/db/replaceHostname.js +88 -0
  190. package/dist/db/types.d.ts +17 -0
  191. package/dist/db/types.js +1 -0
  192. package/dist/email/index.d.ts +9 -0
  193. package/dist/email/index.js +19 -0
  194. package/dist/email/jobs.d.ts +3 -0
  195. package/dist/email/jobs.js +13 -0
  196. package/dist/email/queueStats.d.ts +2 -0
  197. package/dist/email/queueStats.js +27 -0
  198. package/dist/email/registry.d.ts +3 -0
  199. package/dist/email/registry.js +4 -0
  200. package/dist/email/render.d.ts +8 -0
  201. package/dist/email/render.js +34 -0
  202. package/dist/email/send.d.ts +9 -0
  203. package/dist/email/send.js +97 -0
  204. package/dist/email/smtpTest.d.ts +2 -0
  205. package/dist/email/smtpTest.js +26 -0
  206. package/dist/errors/index.d.ts +8 -0
  207. package/dist/errors/index.js +13 -0
  208. package/dist/events/index.d.ts +31 -0
  209. package/dist/events/index.js +66 -0
  210. package/dist/events/once.d.ts +4 -0
  211. package/dist/events/once.js +23 -0
  212. package/dist/groups/finders.d.ts +125 -0
  213. package/dist/groups/finders.js +18 -0
  214. package/dist/groups/helpers.d.ts +227 -0
  215. package/dist/groups/helpers.js +17 -0
  216. package/dist/groups/index.d.ts +3 -0
  217. package/dist/groups/index.js +3 -0
  218. package/dist/groups/mapping.d.ts +188 -0
  219. package/dist/groups/mapping.js +47 -0
  220. package/dist/groups/mutations.d.ts +26 -0
  221. package/dist/groups/mutations.js +41 -0
  222. package/dist/hashtags/finders.d.ts +3 -0
  223. package/dist/hashtags/finders.js +22 -0
  224. package/dist/hashtags/index.d.ts +2 -0
  225. package/dist/hashtags/index.js +2 -0
  226. package/dist/hashtags/mapping.d.ts +4 -0
  227. package/dist/hashtags/mapping.js +5 -0
  228. package/dist/hashtags/mutations.d.ts +0 -0
  229. package/dist/hashtags/mutations.js +1 -0
  230. package/dist/i18n/index.d.ts +14 -0
  231. package/dist/i18n/index.js +53 -0
  232. package/dist/index.d.ts +0 -0
  233. package/dist/index.js +1 -0
  234. package/dist/inviteLinks/finders.d.ts +3 -0
  235. package/dist/inviteLinks/finders.js +5 -0
  236. package/dist/inviteLinks/helpers.d.ts +20 -0
  237. package/dist/inviteLinks/helpers.js +4 -0
  238. package/dist/inviteLinks/index.d.ts +3 -0
  239. package/dist/inviteLinks/index.js +3 -0
  240. package/dist/inviteLinks/mapping.d.ts +10 -0
  241. package/dist/inviteLinks/mapping.js +35 -0
  242. package/dist/inviteLinks/mutations.d.ts +4 -0
  243. package/dist/inviteLinks/mutations.js +39 -0
  244. package/dist/jams/cache.d.ts +9 -0
  245. package/dist/jams/cache.js +13 -0
  246. package/dist/jams/finders.d.ts +23 -0
  247. package/dist/jams/finders.js +24 -0
  248. package/dist/jams/helpers.d.ts +70 -0
  249. package/dist/jams/helpers.js +29 -0
  250. package/dist/jams/index.d.ts +15 -0
  251. package/dist/jams/index.js +108 -0
  252. package/dist/jams/jobs.d.ts +9 -0
  253. package/dist/jams/jobs.js +42 -0
  254. package/dist/jams/livekit.d.ts +24 -0
  255. package/dist/jams/livekit.js +220 -0
  256. package/dist/jams/mapping.d.ts +137 -0
  257. package/dist/jams/mapping.js +35 -0
  258. package/dist/jams/mutations.d.ts +40 -0
  259. package/dist/jams/mutations.js +4 -0
  260. package/dist/jams/recording.d.ts +8 -0
  261. package/dist/jams/recording.js +67 -0
  262. package/dist/jams/recordingUploadAuth.d.ts +9 -0
  263. package/dist/jams/recordingUploadAuth.js +19 -0
  264. package/dist/jams/token.d.ts +4 -0
  265. package/dist/jams/token.js +129 -0
  266. package/dist/jams/waitingRoom.d.ts +5 -0
  267. package/dist/jams/waitingRoom.js +71 -0
  268. package/dist/jobs/index.d.ts +10 -0
  269. package/dist/jobs/index.js +60 -0
  270. package/dist/jobs/jobDetail.d.ts +2 -0
  271. package/dist/jobs/jobDetail.js +31 -0
  272. package/dist/jobs/jobLog.d.ts +18 -0
  273. package/dist/jobs/jobLog.js +61 -0
  274. package/dist/jwt/index.d.ts +10 -0
  275. package/dist/jwt/index.js +43 -0
  276. package/dist/lib/index.d.ts +2 -0
  277. package/dist/lib/index.js +2 -0
  278. package/dist/lib/streams.d.ts +2 -0
  279. package/dist/lib/streams.js +56 -0
  280. package/dist/lib/utils.d.ts +2 -0
  281. package/dist/lib/utils.js +17 -0
  282. package/dist/lib/zodDeepPartial.d.ts +3 -0
  283. package/dist/lib/zodDeepPartial.js +26 -0
  284. package/dist/location/index.d.ts +2 -0
  285. package/dist/location/index.js +28 -0
  286. package/dist/log/index.d.ts +3 -0
  287. package/dist/log/index.js +97 -0
  288. package/dist/mastodon/index.d.ts +4 -0
  289. package/dist/mastodon/index.js +51 -0
  290. package/dist/mastodon/types.d.ts +7579 -0
  291. package/dist/mastodon/types.js +523 -0
  292. package/dist/mastodon/typescript.d.ts +1578 -0
  293. package/dist/mastodon/typescript.js +1 -0
  294. package/dist/media/index.d.ts +40 -0
  295. package/dist/media/index.js +248 -0
  296. package/dist/media/ipfs/index.d.ts +0 -0
  297. package/dist/media/ipfs/index.js +39 -0
  298. package/dist/media/jobs.d.ts +19 -0
  299. package/dist/media/jobs.js +90 -0
  300. package/dist/media/openpeeps/index.d.ts +3 -0
  301. package/dist/media/openpeeps/index.js +131 -0
  302. package/dist/media/processing.d.ts +19 -0
  303. package/dist/media/processing.js +83 -0
  304. package/dist/media/streaming.d.ts +77 -0
  305. package/dist/media/streaming.js +257 -0
  306. package/dist/media/streamingCleanupJobs.d.ts +14 -0
  307. package/dist/media/streamingCleanupJobs.js +47 -0
  308. package/dist/media/streamingJobs.d.ts +5 -0
  309. package/dist/media/streamingJobs.js +329 -0
  310. package/dist/media/streamingPrewarm.d.ts +36 -0
  311. package/dist/media/streamingPrewarm.js +109 -0
  312. package/dist/mediaAttachments/finders.d.ts +1 -0
  313. package/dist/mediaAttachments/finders.js +3 -0
  314. package/dist/mediaAttachments/index.d.ts +5 -0
  315. package/dist/mediaAttachments/index.js +12 -0
  316. package/dist/mediaAttachments/mapping.d.ts +21 -0
  317. package/dist/mediaAttachments/mapping.js +4 -0
  318. package/dist/mediaAttachments/mutations.d.ts +3 -0
  319. package/dist/mediaAttachments/mutations.js +10 -0
  320. package/dist/notifications/defaultNotifications/announcement/index.d.ts +24 -0
  321. package/dist/notifications/defaultNotifications/announcement/index.js +42 -0
  322. package/dist/notifications/defaultNotifications/directMessage/index.d.ts +28 -0
  323. package/dist/notifications/defaultNotifications/directMessage/index.js +69 -0
  324. package/dist/notifications/defaultNotifications/follow/index.d.ts +24 -0
  325. package/dist/notifications/defaultNotifications/follow/index.js +31 -0
  326. package/dist/notifications/defaultNotifications/groupAdded/index.d.ts +18 -0
  327. package/dist/notifications/defaultNotifications/groupAdded/index.js +33 -0
  328. package/dist/notifications/defaultNotifications/groupMemberJoined/index.d.ts +18 -0
  329. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +36 -0
  330. package/dist/notifications/defaultNotifications/groupMemberLeft/index.d.ts +18 -0
  331. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +36 -0
  332. package/dist/notifications/defaultNotifications/index.d.ts +3 -0
  333. package/dist/notifications/defaultNotifications/index.js +43 -0
  334. package/dist/notifications/defaultNotifications/jamModerator/index.d.ts +23 -0
  335. package/dist/notifications/defaultNotifications/jamModerator/index.js +49 -0
  336. package/dist/notifications/defaultNotifications/jamSpeaker/index.d.ts +23 -0
  337. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +47 -0
  338. package/dist/notifications/defaultNotifications/jamStarted/index.d.ts +18 -0
  339. package/dist/notifications/defaultNotifications/jamStarted/index.js +82 -0
  340. package/dist/notifications/defaultNotifications/mention/index.d.ts +24 -0
  341. package/dist/notifications/defaultNotifications/mention/index.js +89 -0
  342. package/dist/notifications/defaultNotifications/newGroupPost/index.d.ts +24 -0
  343. package/dist/notifications/defaultNotifications/newGroupPost/index.js +47 -0
  344. package/dist/notifications/defaultNotifications/newProfile/index.d.ts +24 -0
  345. package/dist/notifications/defaultNotifications/newProfile/index.js +40 -0
  346. package/dist/notifications/defaultNotifications/pollVote/index.d.ts +19 -0
  347. package/dist/notifications/defaultNotifications/pollVote/index.js +40 -0
  348. package/dist/notifications/defaultNotifications/reaction/index.d.ts +18 -0
  349. package/dist/notifications/defaultNotifications/reaction/index.js +43 -0
  350. package/dist/notifications/defaultNotifications/reply/index.d.ts +25 -0
  351. package/dist/notifications/defaultNotifications/reply/index.js +57 -0
  352. package/dist/notifications/defaultNotifications/repost/index.d.ts +18 -0
  353. package/dist/notifications/defaultNotifications/repost/index.js +42 -0
  354. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +19 -0
  355. package/dist/notifications/defaultNotifications/rsvp/index.js +40 -0
  356. package/dist/notifications/fcmCredential.d.ts +14 -0
  357. package/dist/notifications/fcmCredential.js +68 -0
  358. package/dist/notifications/finders.d.ts +7 -0
  359. package/dist/notifications/finders.js +13 -0
  360. package/dist/notifications/firebase.d.ts +1 -0
  361. package/dist/notifications/firebase.js +33 -0
  362. package/dist/notifications/handlers.d.ts +3 -0
  363. package/dist/notifications/handlers.js +6 -0
  364. package/dist/notifications/helpers.d.ts +7 -0
  365. package/dist/notifications/helpers.js +31 -0
  366. package/dist/notifications/index.d.ts +9 -0
  367. package/dist/notifications/index.js +43 -0
  368. package/dist/notifications/jobs.d.ts +2 -0
  369. package/dist/notifications/jobs.js +75 -0
  370. package/dist/notifications/mapping.d.ts +25 -0
  371. package/dist/notifications/mapping.js +25 -0
  372. package/dist/notifications/mutations.d.ts +6 -0
  373. package/dist/notifications/mutations.js +40 -0
  374. package/dist/notifications/push.d.ts +9 -0
  375. package/dist/notifications/push.js +261 -0
  376. package/dist/notifications/pushInvalidation.d.ts +10 -0
  377. package/dist/notifications/pushInvalidation.js +10 -0
  378. package/dist/performance/index.d.ts +24 -0
  379. package/dist/performance/index.js +61 -0
  380. package/dist/plugins/helpers.d.ts +3 -0
  381. package/dist/plugins/helpers.js +72 -0
  382. package/dist/plugins/index.d.ts +10 -0
  383. package/dist/plugins/index.js +84 -0
  384. package/dist/plugins/pluginAuth.d.ts +30 -0
  385. package/dist/plugins/pluginAuth.js +44 -0
  386. package/dist/posts/contextClosure.d.ts +16 -0
  387. package/dist/posts/contextClosure.js +66 -0
  388. package/dist/posts/finders.d.ts +298 -0
  389. package/dist/posts/finders.js +259 -0
  390. package/dist/posts/helpers/filters.d.ts +14 -0
  391. package/dist/posts/helpers/filters.js +39 -0
  392. package/dist/posts/helpers/index.d.ts +837 -0
  393. package/dist/posts/helpers/index.js +117 -0
  394. package/dist/posts/index.d.ts +6 -0
  395. package/dist/posts/index.js +6 -0
  396. package/dist/posts/mapping.d.ts +2187 -0
  397. package/dist/posts/mapping.js +222 -0
  398. package/dist/posts/mutations.d.ts +19 -0
  399. package/dist/posts/mutations.js +202 -0
  400. package/dist/posts/rsvpConfirmationEmail.d.ts +2 -0
  401. package/dist/posts/rsvpConfirmationEmail.js +82 -0
  402. package/dist/processingStats/index.d.ts +3 -0
  403. package/dist/processingStats/index.js +3 -0
  404. package/dist/processingStats/mapping.d.ts +7 -0
  405. package/dist/processingStats/mapping.js +4 -0
  406. package/dist/processingStats/mutations.d.ts +2 -0
  407. package/dist/processingStats/mutations.js +6 -0
  408. package/dist/processingStats/queries.d.ts +4 -0
  409. package/dist/processingStats/queries.js +46 -0
  410. package/dist/profileSettings/cache.d.ts +2 -0
  411. package/dist/profileSettings/cache.js +24 -0
  412. package/dist/profileSettings/finders.d.ts +1 -0
  413. package/dist/profileSettings/finders.js +2 -0
  414. package/dist/profileSettings/index.d.ts +3 -0
  415. package/dist/profileSettings/index.js +3 -0
  416. package/dist/profileSettings/mapping.d.ts +38 -0
  417. package/dist/profileSettings/mapping.js +5 -0
  418. package/dist/profileSettings/mutations.d.ts +3 -0
  419. package/dist/profileSettings/mutations.js +24 -0
  420. package/dist/profiles/cache.d.ts +5 -0
  421. package/dist/profiles/cache.js +19 -0
  422. package/dist/profiles/capacity.d.ts +2 -0
  423. package/dist/profiles/capacity.js +20 -0
  424. package/dist/profiles/export.d.ts +3 -0
  425. package/dist/profiles/export.js +85 -0
  426. package/dist/profiles/finders.d.ts +11 -0
  427. package/dist/profiles/finders.js +39 -0
  428. package/dist/profiles/helpers.d.ts +35 -0
  429. package/dist/profiles/helpers.js +10 -0
  430. package/dist/profiles/index.d.ts +5 -0
  431. package/dist/profiles/index.js +18 -0
  432. package/dist/profiles/mapping.d.ts +157 -0
  433. package/dist/profiles/mapping.js +132 -0
  434. package/dist/profiles/mutations.d.ts +9 -0
  435. package/dist/profiles/mutations.js +75 -0
  436. package/dist/pushSubscriptions/finders.d.ts +187 -0
  437. package/dist/pushSubscriptions/finders.js +6 -0
  438. package/dist/pushSubscriptions/helpers.d.ts +99 -0
  439. package/dist/pushSubscriptions/helpers.js +3 -0
  440. package/dist/pushSubscriptions/index.d.ts +3 -0
  441. package/dist/pushSubscriptions/index.js +3 -0
  442. package/dist/pushSubscriptions/mapping.d.ts +261 -0
  443. package/dist/pushSubscriptions/mapping.js +6 -0
  444. package/dist/pushSubscriptions/mutations.d.ts +95 -0
  445. package/dist/pushSubscriptions/mutations.js +21 -0
  446. package/dist/redis/connection.d.ts +4 -0
  447. package/dist/redis/connection.js +17 -0
  448. package/dist/redis/index.d.ts +1 -0
  449. package/dist/redis/index.js +1 -0
  450. package/dist/reports/finders.d.ts +6 -0
  451. package/dist/reports/finders.js +44 -0
  452. package/dist/reports/helpers.d.ts +21 -0
  453. package/dist/reports/helpers.js +12 -0
  454. package/dist/reports/index.d.ts +3 -0
  455. package/dist/reports/index.js +3 -0
  456. package/dist/reports/mapping.d.ts +9 -0
  457. package/dist/reports/mapping.js +34 -0
  458. package/dist/reports/mutations.d.ts +5 -0
  459. package/dist/reports/mutations.js +16 -0
  460. package/dist/roles/defaults.d.ts +2 -0
  461. package/dist/roles/defaults.js +94 -0
  462. package/dist/roles/finders.d.ts +5 -0
  463. package/dist/roles/finders.js +9 -0
  464. package/dist/roles/index.d.ts +4 -0
  465. package/dist/roles/index.js +4 -0
  466. package/dist/roles/mapping.d.ts +11 -0
  467. package/dist/roles/mapping.js +5 -0
  468. package/dist/roles/mutations.d.ts +4 -0
  469. package/dist/roles/mutations.js +30 -0
  470. package/dist/search/finders.d.ts +47 -0
  471. package/dist/search/finders.js +59 -0
  472. package/dist/search/helpers.d.ts +3 -0
  473. package/dist/search/helpers.js +1 -0
  474. package/dist/search/index.d.ts +1 -0
  475. package/dist/search/index.js +1 -0
  476. package/dist/search/mapping.d.ts +40 -0
  477. package/dist/search/mapping.js +43 -0
  478. package/dist/sentry/index.d.ts +34 -0
  479. package/dist/sentry/index.js +113 -0
  480. package/dist/server/helpers.d.ts +0 -0
  481. package/dist/server/helpers.js +1 -0
  482. package/dist/server/index.d.ts +105 -0
  483. package/dist/server/index.js +64 -0
  484. package/dist/stats/finders.d.ts +16156 -0
  485. package/dist/stats/finders.js +167 -0
  486. package/dist/stats/helpers.d.ts +17 -0
  487. package/dist/stats/helpers.js +34 -0
  488. package/dist/stats/index.d.ts +1 -0
  489. package/dist/stats/index.js +1 -0
  490. package/dist/stats/mapping.d.ts +188 -0
  491. package/dist/stats/mapping.js +19 -0
  492. package/dist/stripe/cache.d.ts +30 -0
  493. package/dist/stripe/cache.js +37 -0
  494. package/dist/stripe/connection.d.ts +5 -0
  495. package/dist/stripe/connection.js +23 -0
  496. package/dist/stripe/helpers.d.ts +25 -0
  497. package/dist/stripe/helpers.js +211 -0
  498. package/dist/stripe/index.d.ts +3 -0
  499. package/dist/stripe/index.js +3 -0
  500. package/package.json +99 -0
@@ -0,0 +1,41 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1781969876190,
9
+ "tag": "0000_bizarre_chat",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1782056276190,
16
+ "tag": "0001_search_vector",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1782142676190,
23
+ "tag": "0002_data_migrations_id_text",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "7",
29
+ "when": 1783440000000,
30
+ "tag": "0003_fix_group_post_visibility",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "7",
36
+ "when": 1785770303150,
37
+ "tag": "0004_analytics",
38
+ "breakpoints": true
39
+ }
40
+ ]
41
+ }
@@ -0,0 +1 @@
1
+ export declare const replaceHostname: (oldHostname?: string, newHostname?: string) => Promise<void>;
@@ -0,0 +1,88 @@
1
+ import { eq } from 'drizzle-orm';
2
+ import { logger } from '../log/index.js';
3
+ import { pgDb } from './pg/client.js';
4
+ import { asTable, getTableForCollection } from './pg/map/registry.js';
5
+ const log = logger('db:replaceHostname');
6
+ const hostnameCollections = [
7
+ 'configs',
8
+ 'entries',
9
+ 'jamEvents',
10
+ 'mediaAttachments',
11
+ 'profiles',
12
+ ];
13
+ const absoluteHttpUrlPattern = /https?:\/\/[^\s"'<>`]+/g;
14
+ const replaceHostnameInUrl = (urlValue, oldHostname, newHostname) => {
15
+ try {
16
+ const url = new URL(urlValue);
17
+ if (!['http:', 'https:'].includes(url.protocol) ||
18
+ url.hostname !== oldHostname) {
19
+ return urlValue;
20
+ }
21
+ const authorityStart = urlValue.indexOf('://') + 3;
22
+ const afterAuthority = urlValue.slice(authorityStart).search(/[/?#]/);
23
+ const authorityEnd = afterAuthority === -1 ? urlValue.length : authorityStart + afterAuthority;
24
+ const authority = urlValue.slice(authorityStart, authorityEnd);
25
+ const hostStart = authority.lastIndexOf('@') + 1;
26
+ const updatedAuthority = authority.slice(0, hostStart) +
27
+ authority.slice(hostStart).replace(oldHostname, newHostname);
28
+ return (urlValue.slice(0, authorityStart) +
29
+ updatedAuthority +
30
+ urlValue.slice(authorityEnd));
31
+ }
32
+ catch (_a) {
33
+ return urlValue;
34
+ }
35
+ };
36
+ const replaceHostnameInUrls = (value, oldHostname, newHostname) => value.replace(absoluteHttpUrlPattern, (urlValue) => replaceHostnameInUrl(urlValue, oldHostname, newHostname));
37
+ const replaceInValue = (value, oldHostname, newHostname) => {
38
+ if (typeof value === 'string') {
39
+ return replaceHostnameInUrls(value, oldHostname, newHostname);
40
+ }
41
+ if (Array.isArray(value)) {
42
+ return value.map((item) => replaceInValue(item, oldHostname, newHostname));
43
+ }
44
+ if (value && typeof value === 'object') {
45
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
46
+ key,
47
+ replaceInValue(item, oldHostname, newHostname),
48
+ ]));
49
+ }
50
+ return value;
51
+ };
52
+ export const replaceHostname = async (oldHostname, newHostname) => {
53
+ if (!oldHostname || !newHostname || oldHostname === newHostname) {
54
+ log.info('No hostname to replace');
55
+ return;
56
+ }
57
+ log.info(`Replacing restored hostname ${oldHostname} with ${newHostname}`);
58
+ const db = pgDb();
59
+ for (const collectionName of hostnameCollections) {
60
+ const table = getTableForCollection(collectionName);
61
+ const rows = await db.select().from(table);
62
+ let replacedCount = 0;
63
+ for (const row of rows) {
64
+ const current = row;
65
+ const updated = replaceInValue(current, oldHostname, newHostname);
66
+ if (JSON.stringify(current) === JSON.stringify(updated)) {
67
+ continue;
68
+ }
69
+ const t = asTable(table);
70
+ if (collectionName === 'configs') {
71
+ await db
72
+ .update(table)
73
+ .set(updated)
74
+ .where(eq(t.key, current.key));
75
+ }
76
+ else {
77
+ await db
78
+ .update(table)
79
+ .set(updated)
80
+ .where(eq(t.id, current.id));
81
+ }
82
+ replacedCount += 1;
83
+ }
84
+ if (replacedCount > 0) {
85
+ log.info(`Replaced hostname in ${replacedCount} ${collectionName} row(s)`);
86
+ }
87
+ }
88
+ };
@@ -0,0 +1,17 @@
1
+ import type { PgDb } from './pg/client';
2
+ export interface OpenpeepsDatabase {
3
+ db: PgDb;
4
+ }
5
+ export interface UserFunctionDefinition {
6
+ name: string;
7
+ dbFunction: Function;
8
+ }
9
+ export interface ObjectFilter<O extends object> {
10
+ (item: O): boolean;
11
+ }
12
+ export interface FilterAndTransformOptions<I extends object, O extends object = I> {
13
+ filter?: (item: O) => boolean;
14
+ transform?: (item: I) => Promise<O>;
15
+ limit?: number;
16
+ offset?: number;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { EmailService } from '@openpeepshq/common/types';
2
+ export declare const emailService: () => Promise<EmailService>;
3
+ export declare const queueTestEmail: (to: string) => Promise<void>;
4
+ export { sendEmailWorker, sendEmailQueue } from './jobs';
5
+ export { registerEmailRenderer } from './registry';
6
+ export { sendEmail } from './send';
7
+ export { sendSmtpTestEmail } from './smtpTest';
8
+ export { getSendEmailQueueStats } from './queueStats';
9
+ export { SEND_EMAIL_QUEUE_NAME } from './jobs';
@@ -0,0 +1,19 @@
1
+ import { logger } from '../log/index.js';
2
+ import { sendEmailQueue } from './jobs.js';
3
+ import { render } from './render.js';
4
+ const log = logger('openpeeps:email');
5
+ const defaultEmailService = {
6
+ send: async (emailOptions) => sendEmailQueue()
7
+ .add(`${emailOptions.template}->${emailOptions.to}`, emailOptions)
8
+ .catch(log.error)
9
+ .then(),
10
+ render: async (emailOptions) => render(emailOptions),
11
+ };
12
+ export const emailService = async () => defaultEmailService;
13
+ export const queueTestEmail = async (to) => (await emailService()).send({ to, template: 'test' });
14
+ export { sendEmailWorker, sendEmailQueue } from './jobs.js';
15
+ export { registerEmailRenderer } from './registry.js';
16
+ export { sendEmail } from './send.js';
17
+ export { sendSmtpTestEmail } from './smtpTest.js';
18
+ export { getSendEmailQueueStats } from './queueStats.js';
19
+ export { SEND_EMAIL_QUEUE_NAME } from './jobs.js';
@@ -0,0 +1,3 @@
1
+ export declare const SEND_EMAIL_QUEUE_NAME = "send-email";
2
+ declare const sendEmailQueue: () => import("bullmq").Queue, sendEmailWorker: () => import("bullmq").Worker;
3
+ export { sendEmailQueue, sendEmailWorker };
@@ -0,0 +1,13 @@
1
+ import { queueAndWorker } from '../jobs/index.js';
2
+ import { send } from './send.js';
3
+ export const SEND_EMAIL_QUEUE_NAME = 'send-email';
4
+ const [sendEmailQueue, sendEmailWorker] = queueAndWorker(SEND_EMAIL_QUEUE_NAME, (job) => send(job), {
5
+ defaultJobOptions: {
6
+ removeOnComplete: { age: 86400 }, // Remove successful tasks after 1 day
7
+ removeOnFail: {
8
+ age: 86400 * 7,
9
+ count: 50,
10
+ }, // Remove failed tasks after 7 days and after 50 failed tasks
11
+ },
12
+ });
13
+ export { sendEmailQueue, sendEmailWorker };
@@ -0,0 +1,2 @@
1
+ import type { AdminEmailQueueStats } from '@openpeepshq/common/types';
2
+ export declare const getSendEmailQueueStats: () => Promise<AdminEmailQueueStats>;
@@ -0,0 +1,27 @@
1
+ import { SEND_EMAIL_QUEUE_NAME, sendEmailQueue } from './jobs.js';
2
+ const n = (record, key) => { var _a; return (_a = record[key]) !== null && _a !== void 0 ? _a : 0; };
3
+ export const getSendEmailQueueStats = async () => {
4
+ const queue = sendEmailQueue();
5
+ const raw = await queue.getJobCounts();
6
+ const failedJobs = await queue.getFailed(0, 9);
7
+ return {
8
+ counts: {
9
+ waiting: n(raw, 'waiting') + n(raw, 'paused'),
10
+ active: n(raw, 'active'),
11
+ completed: n(raw, 'completed'),
12
+ failed: n(raw, 'failed'),
13
+ delayed: n(raw, 'delayed'),
14
+ prioritized: n(raw, 'prioritized'),
15
+ },
16
+ recentFailures: failedJobs.map((j) => {
17
+ var _a, _b, _c;
18
+ return ({
19
+ queue: SEND_EMAIL_QUEUE_NAME,
20
+ id: (_a = j.id) !== null && _a !== void 0 ? _a : null,
21
+ name: j.name,
22
+ failedReason: (_b = j.failedReason) !== null && _b !== void 0 ? _b : '',
23
+ finishedOn: (_c = j.finishedOn) !== null && _c !== void 0 ? _c : null,
24
+ });
25
+ }),
26
+ };
27
+ };
@@ -0,0 +1,3 @@
1
+ import { EmailRenderer } from '@openpeepshq/common/types';
2
+ export declare const registeredTemplates: Map<string, EmailRenderer>;
3
+ export declare const registerEmailRenderer: (templateId: string, renderer: EmailRenderer) => void;
@@ -0,0 +1,4 @@
1
+ export const registeredTemplates = new Map();
2
+ export const registerEmailRenderer = (templateId, renderer) => {
3
+ registeredTemplates.set(templateId, renderer);
4
+ };
@@ -0,0 +1,8 @@
1
+ import type { EmailOptions } from '@openpeepshq/common/types';
2
+ export declare const render: (emailData: EmailOptions) => Promise<{
3
+ to: string;
4
+ template: string;
5
+ subject: string;
6
+ html: string;
7
+ text: string;
8
+ }>;
@@ -0,0 +1,34 @@
1
+ import { communityConfig, config } from '../config/index.js';
2
+ import { convert } from 'html-to-text';
3
+ import { registeredTemplates } from './registry.js';
4
+ import { serverRootUrl } from '../server/index.js';
5
+ import { initI18nEmailContext } from '../i18n/index.js';
6
+ const globals = async () => {
7
+ const serverConfig = await config();
8
+ const rootUrl = await serverRootUrl();
9
+ return {
10
+ communityConfig: await communityConfig(),
11
+ serverData: {
12
+ rootUrl,
13
+ iosUrl: serverConfig.apps.ios.url,
14
+ androidUrl: serverConfig.apps.android.url,
15
+ },
16
+ i18nContext: await initI18nEmailContext(),
17
+ };
18
+ };
19
+ export const render = async (emailData) => {
20
+ const locals = emailData.locals;
21
+ const render = registeredTemplates.get(emailData.template);
22
+ if (!render) {
23
+ throw Error(`No renderer registered for ${emailData.template}`);
24
+ }
25
+ const { html, subject } = await render(Object.assign(Object.assign({}, emailData), { globals: await globals(), locals: locals || {} }));
26
+ const text = convert(html);
27
+ return {
28
+ to: emailData.to,
29
+ template: emailData.template,
30
+ subject,
31
+ html,
32
+ text,
33
+ };
34
+ };
@@ -0,0 +1,9 @@
1
+ import type { Job } from 'bullmq';
2
+ import { CoreConfig, EmailOptions } from '@openpeepshq/common/types';
3
+ export type EmailJobLog = (message: string) => void | Promise<void>;
4
+ export type SendEmailOptions = {
5
+ /** Writes to BullMQ job logs when processing a queued email. */
6
+ log?: EmailJobLog;
7
+ };
8
+ export declare const sendEmail: (emailData: EmailOptions, coreConfig: CoreConfig, options?: SendEmailOptions) => Promise<import("nodemailer/lib/smtp-transport").SentMessageInfo>;
9
+ export declare const send: (job: Job<EmailOptions>) => Promise<import("nodemailer/lib/smtp-transport").SentMessageInfo>;
@@ -0,0 +1,97 @@
1
+ import { communityConfig, config } from '../config/index.js';
2
+ import nodemailer from 'nodemailer';
3
+ import { render } from './render.js';
4
+ import { logger } from '../log/index.js';
5
+ const serverLog = logger('openpeeps:email');
6
+ const logStep = async (log, message) => {
7
+ if (!log)
8
+ return;
9
+ await log(message);
10
+ serverLog.info(message);
11
+ };
12
+ const formatTransportSummary = (transportConfig) => {
13
+ var _a;
14
+ if (!transportConfig)
15
+ return '(no transport config)';
16
+ const { host, port, secure, auth } = transportConfig;
17
+ return JSON.stringify({
18
+ host: host !== null && host !== void 0 ? host : null,
19
+ port: port !== null && port !== void 0 ? port : null,
20
+ secure: secure !== null && secure !== void 0 ? secure : null,
21
+ authUser: (_a = auth === null || auth === void 0 ? void 0 : auth.user) !== null && _a !== void 0 ? _a : null,
22
+ authPass: (auth === null || auth === void 0 ? void 0 : auth.pass) ? '[set]' : auth ? '[empty]' : null,
23
+ });
24
+ };
25
+ const formatErrorDetail = (err) => {
26
+ if (!(err instanceof Error))
27
+ return String(err);
28
+ const nodemailerErr = err;
29
+ const parts = [err.message];
30
+ if (nodemailerErr.code)
31
+ parts.push(`code=${nodemailerErr.code}`);
32
+ if (nodemailerErr.command)
33
+ parts.push(`command=${nodemailerErr.command}`);
34
+ if (nodemailerErr.responseCode != null) {
35
+ parts.push(`responseCode=${nodemailerErr.responseCode}`);
36
+ }
37
+ if (nodemailerErr.response)
38
+ parts.push(`response=${nodemailerErr.response}`);
39
+ return parts.join(' | ');
40
+ };
41
+ const logFailure = async (log, err) => {
42
+ await logStep(log, `Failed: ${formatErrorDetail(err)}`);
43
+ if (err instanceof Error && err.stack) {
44
+ await logStep(log, err.stack);
45
+ }
46
+ if (err && typeof err === 'object' && 'cause' in err && err.cause) {
47
+ await logStep(log, `Caused by: ${formatErrorDetail(err.cause)}`);
48
+ }
49
+ };
50
+ export const sendEmail = async (emailData, coreConfig, options) => {
51
+ var _a, _b, _c, _d, _e, _f;
52
+ const log = options === null || options === void 0 ? void 0 : options.log;
53
+ const localKeys = Object.keys((_a = emailData.locals) !== null && _a !== void 0 ? _a : {});
54
+ await logStep(log, `Template "${emailData.template}" → ${emailData.to}${localKeys.length ? ` (locals: ${localKeys.join(', ')})` : ''}`);
55
+ await logStep(log, `defaultFrom=${(_b = coreConfig.email.defaultFrom) !== null && _b !== void 0 ? _b : '(unset)'}`);
56
+ await logStep(log, `SMTP transport: ${formatTransportSummary(coreConfig.email.transportConfig)}`);
57
+ let renderedEmail;
58
+ await logStep(log, 'Render in-process (worker templates)');
59
+ try {
60
+ renderedEmail = await render(emailData);
61
+ }
62
+ catch (err) {
63
+ await logFailure(log, err);
64
+ throw err;
65
+ }
66
+ await logStep(log, `Rendered subject="${renderedEmail.subject}" (html ${renderedEmail.html.length} chars, text ${renderedEmail.text.length} chars)`);
67
+ const communityConf = await communityConfig();
68
+ const from = `"${communityConf.info.name}" <${coreConfig.email.defaultFrom}>`;
69
+ await logStep(log, `Sending via SMTP as ${from}`);
70
+ if (communityConf.info.contactEmail) {
71
+ await logStep(log, `replyTo=${communityConf.info.contactEmail}`);
72
+ }
73
+ const emailTransport = nodemailer.createTransport(coreConfig.email.transportConfig);
74
+ try {
75
+ const result = await emailTransport.sendMail(Object.assign(Object.assign({ from, replyTo: communityConf.info.contactEmail }, renderedEmail), (((_c = emailData.attachments) === null || _c === void 0 ? void 0 : _c.length)
76
+ ? { attachments: emailData.attachments }
77
+ : {})));
78
+ await logStep(log, `SMTP accepted message (messageId: ${(_d = result.messageId) !== null && _d !== void 0 ? _d : 'n/a'}, response: ${(_e = result.response) !== null && _e !== void 0 ? _e : 'n/a'})`);
79
+ if ((_f = result.rejected) === null || _f === void 0 ? void 0 : _f.length) {
80
+ await logStep(log, `SMTP rejected recipients: ${result.rejected.join(', ')}`);
81
+ }
82
+ return result;
83
+ }
84
+ catch (err) {
85
+ await logFailure(log, err);
86
+ throw err;
87
+ }
88
+ };
89
+ export const send = async (job) => {
90
+ var _a;
91
+ const log = (message) => job.log(message).then(() => undefined);
92
+ const attempt = job.attemptsMade + 1;
93
+ await logStep(log, `Job ${job.id} started (attempt ${attempt}/${(_a = job.opts.attempts) !== null && _a !== void 0 ? _a : 1}, name="${job.name}")`);
94
+ const coreConfig = await config();
95
+ await logStep(log, 'Loaded core config');
96
+ return sendEmail(job.data, coreConfig, { log });
97
+ };
@@ -0,0 +1,2 @@
1
+ import type { AdminEmailTestInput } from '@openpeepshq/common/types';
2
+ export declare const sendSmtpTestEmail: (input: AdminEmailTestInput) => Promise<void>;
@@ -0,0 +1,26 @@
1
+ import { deepmerge } from 'deepmerge-ts';
2
+ import { passwordPlaceHolder } from '@openpeepshq/common/types';
3
+ import { config } from '../config/index.js';
4
+ import { sendEmail } from './send.js';
5
+ const mergeEmailForTest = (base, override) => {
6
+ var _a, _b, _c;
7
+ if (!override) {
8
+ return base;
9
+ }
10
+ const merged = deepmerge(base, override);
11
+ const pass = (_b = (_a = override.transportConfig) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.pass;
12
+ if (pass === undefined || pass === '' || pass === passwordPlaceHolder) {
13
+ merged.transportConfig = Object.assign(Object.assign({}, merged.transportConfig), { auth: Object.assign(Object.assign({}, merged.transportConfig.auth), { pass: (_c = base.transportConfig.auth) === null || _c === void 0 ? void 0 : _c.pass }) });
14
+ }
15
+ return merged;
16
+ };
17
+ export const sendSmtpTestEmail = async (input) => {
18
+ var _a;
19
+ const saved = await config();
20
+ const emailSettings = mergeEmailForTest(saved.email, input.email);
21
+ if (!((_a = emailSettings.defaultFrom) === null || _a === void 0 ? void 0 : _a.trim())) {
22
+ throw new Error('defaultFrom is required to send mail');
23
+ }
24
+ const draftConfig = Object.assign(Object.assign({}, saved), { email: emailSettings });
25
+ await sendEmail({ to: input.to, template: 'test' }, draftConfig);
26
+ };
@@ -0,0 +1,8 @@
1
+ import { OpenpeepsError, OpenpeepsErrorData } from '@openpeepshq/common/types';
2
+ export declare const authNeeded: ({ errorKey, parameters, }: OpenpeepsErrorData) => OpenpeepsError;
3
+ export declare const forbidden: ({ errorKey, parameters, }: OpenpeepsErrorData) => OpenpeepsError;
4
+ export declare const notFound: ({ errorKey, parameters, }: OpenpeepsErrorData) => OpenpeepsError;
5
+ export declare const conflict: ({ errorKey, parameters, }: OpenpeepsErrorData) => OpenpeepsError;
6
+ export declare const unprocessableRequest: ({ errorKey, parameters, }: OpenpeepsErrorData) => OpenpeepsError;
7
+ export declare const internalError: ({ errorKey, parameters, }: OpenpeepsErrorData) => OpenpeepsError;
8
+ export declare const isOpenpeepsError: (o?: unknown) => boolean;
@@ -0,0 +1,13 @@
1
+ const allPeepError = ({ code = 500, errorKey, parameters, }) => ({
2
+ __allPeepError__: true,
3
+ code: code,
4
+ errorKey,
5
+ parameters,
6
+ });
7
+ export const authNeeded = ({ errorKey = 'authNeeded', parameters, }) => allPeepError({ code: 401, errorKey, parameters });
8
+ export const forbidden = ({ errorKey = 'forbidden', parameters, }) => allPeepError({ code: 403, errorKey, parameters });
9
+ export const notFound = ({ errorKey = 'notFound', parameters, }) => allPeepError({ code: 404, errorKey, parameters });
10
+ export const conflict = ({ errorKey = 'conflict', parameters, }) => allPeepError({ code: 409, errorKey, parameters });
11
+ export const unprocessableRequest = ({ errorKey = 'unprocessableRequest', parameters, }) => allPeepError({ code: 422, errorKey, parameters });
12
+ export const internalError = ({ errorKey = 'internalError', parameters, }) => allPeepError({ code: 500, errorKey, parameters });
13
+ export const isOpenpeepsError = (o) => o === null || o === void 0 ? void 0 : o.__allPeepError__;
@@ -0,0 +1,31 @@
1
+ import type { Profile, EntryData, PostWithMeta, Notification, ReactionData, JamRecordingWithMeta, RSVP, RsvpResponse } from '@openpeepshq/common/types';
2
+ export type CoreEvents = {
3
+ profileCreated: (profile: Profile) => void;
4
+ postCreated: (post: PostWithMeta) => void;
5
+ jamRecordingCompleted: (recording: JamRecordingWithMeta) => void;
6
+ followCreated: (follower: Profile, followed: Profile) => void;
7
+ notificationCreated: (notification: Notification) => void;
8
+ reactionCreated: (profile: Profile, post: PostWithMeta, data: ReactionData) => void;
9
+ entryCreated: (profile: Profile, post: PostWithMeta, data: EntryData) => void;
10
+ rsvpCreated: (profile: Profile, post: PostWithMeta, data: {
11
+ type: 'rsvp';
12
+ data: RSVP;
13
+ previousResponse?: RsvpResponse;
14
+ }) => void;
15
+ postAnnounced: (post: PostWithMeta) => void;
16
+ configUpdated: (namespace: string, name: string) => void;
17
+ /** Profile settings changed — clear in-process caches in all services. */
18
+ profileSettingsUpdated: (profileId: string) => void;
19
+ };
20
+ export type CoreEventKey = keyof CoreEvents;
21
+ export declare const VALID_EVENT_KEYS: CoreEventKey[];
22
+ export declare const hub: {
23
+ /**
24
+ * Fan-out must not fail the caller (register/react/etc.). Redis publish and
25
+ * the BullMQ once-queue are best-effort side channels.
26
+ */
27
+ emit: (eventType: string, ...eventArgs: unknown[]) => Promise<void>;
28
+ on: <T extends unknown[]>(eventType: string, handler: (...args: T) => unknown) => void;
29
+ once: (eventType: string, handler: (...args: unknown[]) => unknown) => void;
30
+ };
31
+ export { onceWorker, onceQueue } from './once';
@@ -0,0 +1,66 @@
1
+ import { getConnection } from '../redis/connection.js';
2
+ import { logger } from '../log/index.js';
3
+ import { onceQueue, registerOnceHandler } from './once.js';
4
+ const log = logger('app:events');
5
+ // `satisfies Record<CoreEventKey, true>` guarantees at compile time that every
6
+ // event key is present and that no unexpected keys can slip in.
7
+ const validEventKeyMap = {
8
+ profileCreated: true,
9
+ postCreated: true,
10
+ jamRecordingCompleted: true,
11
+ followCreated: true,
12
+ notificationCreated: true,
13
+ reactionCreated: true,
14
+ entryCreated: true,
15
+ rsvpCreated: true,
16
+ postAnnounced: true,
17
+ configUpdated: true,
18
+ profileSettingsUpdated: true,
19
+ };
20
+ export const VALID_EVENT_KEYS = Object.keys(validEventKeyMap);
21
+ let connectionPromise = undefined;
22
+ const publishConnection = async () => {
23
+ if (connectionPromise) {
24
+ const existing = await connectionPromise;
25
+ if (existing.isOpen)
26
+ return existing;
27
+ connectionPromise = undefined;
28
+ }
29
+ connectionPromise = getConnection();
30
+ return connectionPromise;
31
+ };
32
+ const baseHub = (prefix) => ({
33
+ /**
34
+ * Fan-out must not fail the caller (register/react/etc.). Redis publish and
35
+ * the BullMQ once-queue are best-effort side channels.
36
+ */
37
+ emit: async (eventType, ...eventArgs) => {
38
+ const qualifiedEventType = `${prefix}:${eventType}`;
39
+ try {
40
+ const conn = await publishConnection();
41
+ await conn.publish(qualifiedEventType, JSON.stringify(eventArgs));
42
+ log.info({ qualifiedEventType }, 'hub event published');
43
+ }
44
+ catch (err) {
45
+ log.error({ qualifiedEventType, err }, 'hub publish failed');
46
+ }
47
+ try {
48
+ await onceQueue().add(qualifiedEventType, eventArgs);
49
+ }
50
+ catch (err) {
51
+ log.error({ qualifiedEventType, err }, 'hub once-queue enqueue failed');
52
+ }
53
+ },
54
+ on: (eventType, handler) => {
55
+ // Subscriber mode requires a dedicated connection (not the publisher).
56
+ getConnection().then((conn) => conn.subscribe(`${prefix}:${eventType}`, (message) => {
57
+ const args = JSON.parse(message);
58
+ handler(...args);
59
+ }));
60
+ },
61
+ once: (eventType, handler) => {
62
+ registerOnceHandler(`${prefix}:${eventType}`, handler);
63
+ },
64
+ });
65
+ export const hub = baseHub('allpeep:core');
66
+ export { onceWorker, onceQueue } from './once.js';
@@ -0,0 +1,4 @@
1
+ export declare const registeredHandlers: Map<string, ((...args: unknown[]) => unknown)[]>;
2
+ export declare const registerOnceHandler: (qualifiedEventType: string, handler: (...args: unknown[]) => unknown) => void;
3
+ declare const onceQueue: () => import("bullmq").Queue, onceWorker: () => import("bullmq").Worker;
4
+ export { onceQueue, onceWorker };
@@ -0,0 +1,23 @@
1
+ import { queueAndWorker } from '../jobs/index.js';
2
+ export const registeredHandlers = new Map();
3
+ export const registerOnceHandler = (qualifiedEventType, handler) => {
4
+ var _a;
5
+ if (registeredHandlers.has(qualifiedEventType)) {
6
+ (_a = registeredHandlers.get(qualifiedEventType)) === null || _a === void 0 ? void 0 : _a.push(handler);
7
+ }
8
+ else {
9
+ registeredHandlers.set(qualifiedEventType, [handler]);
10
+ }
11
+ };
12
+ const [onceQueue, onceWorker] = queueAndWorker('once', async (job) => {
13
+ var _a;
14
+ const event = job.name;
15
+ const args = job.data;
16
+ return Promise.all(((_a = registeredHandlers.get(event)) !== null && _a !== void 0 ? _a : []).map((handler) => handler(...args)));
17
+ }, {
18
+ defaultJobOptions: {
19
+ removeOnComplete: { age: 3600 }, // Remove successful tasks after 1 hour
20
+ removeOnFail: { age: 2592000 }, // Remove failed tasks after 1 month (30 days)
21
+ },
22
+ });
23
+ export { onceQueue, onceWorker };