@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
+ import { groupsMapping } from './mapping.js';
2
+ import { allpeepDb, collectionInfos } from '../db/index.js';
3
+ import { addMember, removeMember, updateMember } from './helpers.js';
4
+ import { postsMapping } from '../posts/index.js';
5
+ import { throwIfUndefined } from '../lib/utils.js';
6
+ import { profilesCache } from '../profiles/cache.js';
7
+ export const addMembersToGroup = (group, members) => allpeepDb().then(({ db }) => Promise.all(members.map((p) => addMember(db, p, group, { roles: ['member'] }).then(() => profilesCache.del(p.id)))));
8
+ export const removeMembersFromGroup = (group, members) => allpeepDb().then(({ db }) => Promise.all(members.map((p) => removeMember(db, p, group).then(() => profilesCache.del(p.id)))));
9
+ export const createGroup = async (groupData, profile, members = []) => {
10
+ const { db } = await allpeepDb();
11
+ const emptyGroup = await groupsMapping.create(db, groupData);
12
+ await addMember(db, profile, emptyGroup, {
13
+ roles: ['admin'],
14
+ });
15
+ profilesCache.del(profile.id);
16
+ const filteredMembers = members === null || members === void 0 ? void 0 : members.filter((member) => member.id !== profile.id);
17
+ const uniqueMembers = filteredMembers
18
+ ? Array.from(new Set(filteredMembers.map((m) => m.id))).map((id) => filteredMembers.find((m) => m.id === id))
19
+ : [];
20
+ await addMembersToGroup(emptyGroup, uniqueMembers);
21
+ return throwIfUndefined(await groupsMapping.find(db, emptyGroup.id));
22
+ };
23
+ export const updateGroup = (group, groupData) => allpeepDb().then(({ db }) => groupsMapping.update(db, group.id, groupData));
24
+ export const deleteGroup = async (group) => {
25
+ const { db } = await allpeepDb();
26
+ await groupsMapping.delete(db, group.id);
27
+ const posts = await groupsMapping
28
+ .relationsFrom(group, {
29
+ alias: 'posts',
30
+ edgeCollection: collectionInfos.postGroupsCollection.name,
31
+ direction: 'INBOUND',
32
+ cardinality: 'many',
33
+ mapping: postsMapping.data(),
34
+ skipEdge: true,
35
+ })
36
+ .all(db);
37
+ for (const post of posts) {
38
+ await postsMapping.delete(db, post.id);
39
+ }
40
+ };
41
+ export const setMemberRoles = async (profile, group, roles) => allpeepDb().then(({ db }) => updateMember(db, profile, group, { roles }));
@@ -0,0 +1,3 @@
1
+ export declare const findHashtag: (id: string) => Promise<import("@openpeepshq/common").Hashtag | undefined>;
2
+ export declare const findHashtagByTag: (tag: string) => Promise<import("@openpeepshq/common").Hashtag | undefined>;
3
+ export declare const findOrCreateHashtag: (tag: string) => Promise<import("@openpeepshq/common").Hashtag>;
@@ -0,0 +1,22 @@
1
+ import { normalizeHashtagTag } from '@openpeepshq/common/types';
2
+ import { allpeepDb } from '../db/index.js';
3
+ import { hashtagsMapping } from './mapping.js';
4
+ export const findHashtag = async (id) => {
5
+ const { db } = await allpeepDb();
6
+ return hashtagsMapping.find(db, id);
7
+ };
8
+ export const findHashtagByTag = async (tag) => {
9
+ const { db } = await allpeepDb();
10
+ return hashtagsMapping.findOneBy(db, {
11
+ matches: { tag: normalizeHashtagTag(tag) },
12
+ });
13
+ };
14
+ export const findOrCreateHashtag = async (tag) => {
15
+ const { db } = await allpeepDb();
16
+ const normalizedTag = normalizeHashtagTag(tag);
17
+ const hashtag = await findHashtagByTag(normalizedTag);
18
+ if (hashtag) {
19
+ return hashtag;
20
+ }
21
+ return hashtagsMapping.create(db, { tag: normalizedTag });
22
+ };
@@ -0,0 +1,2 @@
1
+ export * from './finders';
2
+ export * from './mapping';
@@ -0,0 +1,2 @@
1
+ export * from './finders.js';
2
+ export * from './mapping.js';
@@ -0,0 +1,4 @@
1
+ import { Hashtag } from '@openpeepshq/common/types';
2
+ export declare const hashtagsMapping: import("../db/pg/map").Mapping<{
3
+ tag?: string | undefined;
4
+ }, Hashtag, Hashtag>;
@@ -0,0 +1,5 @@
1
+ import { map } from '../db/pg/map/index.js';
2
+ import { collectionInfos } from '../db/index.js';
3
+ export const hashtagsMapping = map({
4
+ collection: collectionInfos.hashtagsCollection.name,
5
+ });
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,14 @@
1
+ import type { Resource, ResourceLanguage } from 'i18next';
2
+ import type { i18n } from 'i18next';
3
+ interface I18nContext {
4
+ i18n: i18n;
5
+ t: i18n['t'];
6
+ }
7
+ export declare const i18nOverrides: () => Promise<{
8
+ [k: string]: ResourceLanguage;
9
+ }>;
10
+ export declare const i18nWithPlugins: () => Promise<Resource>;
11
+ export declare const i18nComplete: () => Promise<Resource>;
12
+ export declare const updateI18nOverrides: (resources: Resource) => Promise<void>;
13
+ export declare const initI18nEmailContext: (lng?: string) => Promise<I18nContext>;
14
+ export {};
@@ -0,0 +1,53 @@
1
+ import { deepmerge } from 'deepmerge-ts';
2
+ import { i18nextResources } from '@openpeepshq/i18n';
3
+ import { allpeepDb } from '../db/index.js';
4
+ import { i18nEntries } from '../db/pg/schema/documents.js';
5
+ import { nowIso } from '../db/pg/mappers.js';
6
+ import { uuidv7 } from 'uuidv7';
7
+ import i18next from 'i18next';
8
+ import Backend from 'i18next-fs-backend';
9
+ const I18N_NAMESPACE = 'translation';
10
+ export const i18nOverrides = () => allpeepDb().then(async ({ db }) => {
11
+ const rows = await db.select().from(i18nEntries);
12
+ return Object.fromEntries(rows.map((row) => [row.locale, row.body]));
13
+ });
14
+ export const i18nWithPlugins = async () => i18nextResources;
15
+ export const i18nComplete = async () => deepmerge(await i18nWithPlugins(), await i18nOverrides());
16
+ export const updateI18nOverrides = async (resources) => allpeepDb().then(async ({ db }) => {
17
+ const ts = nowIso();
18
+ await Promise.all(Object.entries(resources).map(([locale, translations]) => db
19
+ .insert(i18nEntries)
20
+ .values({
21
+ id: uuidv7(),
22
+ locale,
23
+ namespace: I18N_NAMESPACE,
24
+ body: translations,
25
+ createdAt: ts,
26
+ updatedAt: ts,
27
+ })
28
+ .onConflictDoUpdate({
29
+ target: [i18nEntries.locale, i18nEntries.namespace],
30
+ set: { body: translations, updatedAt: ts },
31
+ })));
32
+ });
33
+ export const initI18nEmailContext = async (lng = 'en') => {
34
+ const resources = await i18nComplete();
35
+ const instance = i18next.use(Backend).createInstance({
36
+ lng,
37
+ fallbackLng: lng,
38
+ resources: {
39
+ [lng]: {
40
+ translation: resources[lng],
41
+ },
42
+ },
43
+ interpolation: {
44
+ escapeValue: false,
45
+ },
46
+ debug: true,
47
+ });
48
+ await instance.init();
49
+ return {
50
+ t: instance.t,
51
+ i18n: instance,
52
+ };
53
+ };
File without changes
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ export declare const findInviteLink: (id: string) => Promise<import("@openpeepshq/common").InviteLinkWithMeta | undefined>;
2
+ export declare const findInviteLinkBySlug: (slug: string) => Promise<import("@openpeepshq/common").InviteLinkWithMeta | undefined>;
3
+ export declare const listInviteLinks: () => Promise<import("@openpeepshq/common").InviteLinkWithMeta[]>;
@@ -0,0 +1,5 @@
1
+ import { allpeepDb } from '../db/index.js';
2
+ import { inviteLinksMapping } from './mapping.js';
3
+ export const findInviteLink = (id) => allpeepDb().then((db) => inviteLinksMapping.find(db.db, id));
4
+ export const findInviteLinkBySlug = (slug) => allpeepDb().then((db) => inviteLinksMapping.findOneBy(db.db, { matches: { slug } }));
5
+ export const listInviteLinks = () => allpeepDb().then((db) => inviteLinksMapping.all(db.db));
@@ -0,0 +1,20 @@
1
+ export declare const redeemInviteLinkConnector: (db: import("../db").PgDb, from: {
2
+ id: string;
3
+ }, to: {
4
+ id: string;
5
+ }, data?: {
6
+ id?: string;
7
+ }) => Promise<import("../db/pg/map").WithId<{
8
+ _from: string;
9
+ _to: string;
10
+ }>>;
11
+ export declare const createInviteLinkConnector: (db: import("../db").PgDb, from: {
12
+ id: string;
13
+ }, to: {
14
+ id: string;
15
+ }, data?: {
16
+ id?: string;
17
+ }) => Promise<import("../db/pg/map").WithId<{
18
+ _from: string;
19
+ _to: string;
20
+ }>>;
@@ -0,0 +1,4 @@
1
+ import { connector } from '../db/helpers.js';
2
+ import { collectionInfos } from '../db/index.js';
3
+ export const redeemInviteLinkConnector = connector(collectionInfos.profilesCollection, collectionInfos.inviteLinksCollection, collectionInfos.inviteLinkRedeemersCollection);
4
+ export const createInviteLinkConnector = connector(collectionInfos.profilesCollection, collectionInfos.inviteLinksCollection, collectionInfos.inviteLinkCreatorsCollection);
@@ -0,0 +1,3 @@
1
+ export * from './finders';
2
+ export * from './mutations';
3
+ export * from './mapping';
@@ -0,0 +1,3 @@
1
+ export * from './finders.js';
2
+ export * from './mutations.js';
3
+ export * from './mapping.js';
@@ -0,0 +1,10 @@
1
+ import { InviteLinkWithMeta } from '@openpeepshq/common/types';
2
+ export declare const inviteLinksMapping: import("../db/pg/map").Mapping<{
3
+ slug: string;
4
+ active: boolean;
5
+ maxUses: number;
6
+ expiresAt: string;
7
+ emailPatterns?: string[] | undefined;
8
+ customInvitationMessage?: string | undefined;
9
+ groupIds?: string[] | undefined;
10
+ }, InviteLinkWithMeta, InviteLinkWithMeta>;
@@ -0,0 +1,35 @@
1
+ import { map } from '../db/pg/map/index.js';
2
+ import { profilesMapping } from '../profiles/mapping.js';
3
+ import { groupsMapping } from '../groups/mapping.js';
4
+ const inviteLinkRelations = [
5
+ {
6
+ alias: 'profile',
7
+ edgeCollection: 'inviteLinkCreators',
8
+ direction: 'INBOUND',
9
+ skipEdge: true,
10
+ mapping: profilesMapping.data(),
11
+ cardinality: 'one',
12
+ },
13
+ {
14
+ alias: 'redemptions',
15
+ edgeCollection: 'inviteLinkRedeemers',
16
+ direction: 'INBOUND',
17
+ skipEdge: true,
18
+ mapping: profilesMapping.data(),
19
+ cardinality: 'many',
20
+ },
21
+ ];
22
+ export const inviteLinksMapping = map({
23
+ collection: 'inviteLinks',
24
+ relations: inviteLinkRelations,
25
+ // `groupIds` is a scalar array of group ids; resolve it through the groups
26
+ // mapping so the listing can show which groups an invite targets.
27
+ foreignKeyRelations: [
28
+ {
29
+ alias: 'groups',
30
+ foreignKeyProperty: 'groupIds',
31
+ cardinality: 'many',
32
+ mapping: groupsMapping.data(),
33
+ },
34
+ ],
35
+ });
@@ -0,0 +1,4 @@
1
+ import { InviteLinkData, InviteLinkWithMeta, PublicProfile } from '@openpeepshq/common/types';
2
+ export declare const createInviteLink: (inviteLinkData: InviteLinkData, profile: PublicProfile) => Promise<InviteLinkWithMeta>;
3
+ export declare const updateInviteLink: (id: string, inviteLinkData: Partial<InviteLinkData>) => Promise<InviteLinkWithMeta>;
4
+ export declare const redeemInviteLink: (inviteLink: InviteLinkWithMeta, profile: PublicProfile) => Promise<void>;
@@ -0,0 +1,39 @@
1
+ import { createInviteLinkConnector, redeemInviteLinkConnector, } from './helpers.js';
2
+ import { inviteLinksMapping } from './mapping.js';
3
+ import { allpeepDb } from '../db/index.js';
4
+ import { hub } from '../events/index.js';
5
+ import { addMembersToGroup } from '../groups/mutations.js';
6
+ import { findGroup } from '../groups/finders.js';
7
+ import { throwIfUndefined } from '../lib/utils.js';
8
+ import { logger } from '../log/index.js';
9
+ const log = logger('core:inviteLinks');
10
+ export const createInviteLink = async (inviteLinkData, profile) => {
11
+ const db = await allpeepDb().then((db) => db.db);
12
+ const bareInviteLink = await inviteLinksMapping.create(db, inviteLinkData);
13
+ await createInviteLinkConnector(db, profile, bareInviteLink);
14
+ return throwIfUndefined(await inviteLinksMapping.find(db, bareInviteLink.id));
15
+ };
16
+ export const updateInviteLink = async (id, inviteLinkData) => {
17
+ const db = await allpeepDb().then((db) => db.db);
18
+ return inviteLinksMapping.update(db, id, inviteLinkData);
19
+ };
20
+ export const redeemInviteLink = async (inviteLink, profile) => {
21
+ var _a, _b;
22
+ if (((_a = inviteLink.profile) === null || _a === void 0 ? void 0 : _a.id) === profile.id) {
23
+ throw new Error('Invite link creator and redeemer cannot be the same');
24
+ }
25
+ await allpeepDb().then(({ db }) => redeemInviteLinkConnector(db, profile, inviteLink));
26
+ const groupIds = [...new Set((_b = inviteLink.groupIds) !== null && _b !== void 0 ? _b : [])];
27
+ const adder = inviteLink.profile;
28
+ for (const groupId of groupIds) {
29
+ const group = await findGroup(groupId);
30
+ if (!group) {
31
+ log.warn(`Invite redeem: group ${groupId} not found, skipping auto-join`);
32
+ continue;
33
+ }
34
+ await addMembersToGroup(group, [profile]);
35
+ if (adder) {
36
+ await hub.emit('groupMemberAdded', group, profile, adder);
37
+ }
38
+ }
39
+ };
@@ -0,0 +1,9 @@
1
+ import { PostWithMeta } from '@openpeepshq/common/types';
2
+ export declare const jamStateCache: import("cache-manager").Cache;
3
+ export declare const getJamState: (jam: PostWithMeta) => Promise<{
4
+ active: boolean;
5
+ participants: string[];
6
+ }>;
7
+ /** Caches the LiveKit scan for live jam posts (before auth filtering). */
8
+ export declare const LIVE_JAMS_CACHE_KEY = "live-jams";
9
+ export declare const liveJamPostsCache: import("cache-manager").Cache;
@@ -0,0 +1,13 @@
1
+ import { createCache } from 'cache-manager';
2
+ import { jamState } from './livekit.js';
3
+ export const jamStateCache = createCache({
4
+ ttl: 20 * 1000,
5
+ refreshThreshold: 5 * 1000,
6
+ });
7
+ export const getJamState = async (jam) => jamStateCache.wrap(jam.id, () => jamState(jam));
8
+ /** Caches the LiveKit scan for live jam posts (before auth filtering). */
9
+ export const LIVE_JAMS_CACHE_KEY = 'live-jams';
10
+ export const liveJamPostsCache = createCache({
11
+ ttl: 10 * 1000,
12
+ refreshThreshold: 3 * 1000,
13
+ });
@@ -0,0 +1,23 @@
1
+ import { type JamEvent, type JamRecording, type PostWithMeta } from '@openpeepshq/common/types';
2
+ export declare const baseListJam: (props: {
3
+ jamId: string;
4
+ type?: JamEvent["type"];
5
+ }, { start, limit }: {
6
+ start?: string;
7
+ limit?: number;
8
+ }) => import("../db/pg/map").Mapping<JamEvent>;
9
+ export declare const listJamEvents: (jamId: string, { start, limit }?: {
10
+ start?: string;
11
+ limit?: number;
12
+ }) => Promise<import("../db/pg/map").WithId<JamEvent>[]>;
13
+ export declare const listAttendance: (jamId: string, { start, limit }?: {
14
+ start?: string;
15
+ limit?: number;
16
+ }) => Promise<import("../db/pg/map").WithId<JamEvent>[]>;
17
+ export declare const findJamState: (jam: PostWithMeta, hideParticipants?: boolean) => Promise<{
18
+ participants: string[];
19
+ active: boolean;
20
+ }>;
21
+ export declare const findJamRecording: (recordingId: string) => Promise<import("@openpeepshq/common").JamRecordingWithMeta | undefined>;
22
+ export declare const findActiveRecording: (jamPost: PostWithMeta) => Promise<import("@openpeepshq/common").JamRecordingWithMeta | undefined>;
23
+ export declare const listPostRecordings: (postId: string) => Promise<JamRecording[]>;
@@ -0,0 +1,24 @@
1
+ import { jamRecordingSchema, } from '@openpeepshq/common/types';
2
+ import { allpeepDb } from '../db/index.js';
3
+ import { jamEventsMapping, jamRecordingsMapping } from './mapping.js';
4
+ import { addStartLimit, sortNewestFirst } from '../db/helpers.js';
5
+ import { getJamState } from './cache.js';
6
+ import { transformJamRecordingData } from './helpers.js';
7
+ export const baseListJam = (props, { start, limit = 100 }) => addStartLimit(jamEventsMapping.filter({ matches: props }), start, limit);
8
+ export const listJamEvents = (jamId, { start, limit } = {}) => allpeepDb().then(({ db }) => baseListJam({ jamId }, { start, limit }).all(db));
9
+ export const listAttendance = (jamId, { start, limit } = {}) => allpeepDb().then(({ db }) => baseListJam({ jamId, type: 'join' }, { start, limit }).all(db));
10
+ export const findJamState = async (jam, hideParticipants) => {
11
+ const state = await getJamState(jam);
12
+ return Object.assign(Object.assign({}, state), { participants: hideParticipants ? [] : state.participants });
13
+ };
14
+ export const findJamRecording = async (recordingId) => allpeepDb()
15
+ .then(({ db }) => jamRecordingsMapping.find(db, recordingId))
16
+ .then((recording) => recording ? transformJamRecordingData(recording) : undefined);
17
+ export const findActiveRecording = async (jamPost) => allpeepDb()
18
+ .then(({ db }) => sortNewestFirst(jamRecordingsMapping.filter({
19
+ matches: { _to: `posts/${jamPost.id}`, status: 'active' },
20
+ })).first(db))
21
+ .then((recording) => recording ? transformJamRecordingData(recording) : undefined);
22
+ export const listPostRecordings = async (postId) => allpeepDb()
23
+ .then(({ db }) => sortNewestFirst(jamRecordingsMapping.filter({ matches: { _to: `posts/${postId}` } })).all(db))
24
+ .then((recordings) => recordings.map((recording) => jamRecordingSchema.parse(recording)));
@@ -0,0 +1,70 @@
1
+ import { JamRecording, JamRecordingWithMeta, PostWithMeta, ProfileWithMeta } from '@openpeepshq/common/types';
2
+ export declare const connectRecording: (db: import("../db").PgDb, from: ProfileWithMeta, to: PostWithMeta, data?: {
3
+ status: "active" | "completed" | "failed" | "requested";
4
+ egressId?: string | undefined;
5
+ attachment?: {
6
+ type: string;
7
+ url: string;
8
+ previewUrl: string | null;
9
+ textUrl: null;
10
+ filename: string;
11
+ meta: {
12
+ usage?: string | undefined;
13
+ focus?: {
14
+ x: number;
15
+ y: number;
16
+ } | undefined;
17
+ mimetype?: string | undefined;
18
+ size?: number | undefined;
19
+ };
20
+ id: string;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ description?: string | undefined;
24
+ blurhash?: string | undefined;
25
+ status?: "ready" | "failed" | "processing" | undefined;
26
+ error?: string | undefined;
27
+ deletedAt?: string | null | undefined;
28
+ } | undefined;
29
+ replyPostId?: string | undefined;
30
+ } & {
31
+ id?: string;
32
+ }) => Promise<import("../db/pg/map").WithId<{
33
+ status: "active" | "completed" | "failed" | "requested";
34
+ egressId?: string | undefined;
35
+ attachment?: {
36
+ type: string;
37
+ url: string;
38
+ previewUrl: string | null;
39
+ textUrl: null;
40
+ filename: string;
41
+ meta: {
42
+ usage?: string | undefined;
43
+ focus?: {
44
+ x: number;
45
+ y: number;
46
+ } | undefined;
47
+ mimetype?: string | undefined;
48
+ size?: number | undefined;
49
+ };
50
+ id: string;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ description?: string | undefined;
54
+ blurhash?: string | undefined;
55
+ status?: "ready" | "failed" | "processing" | undefined;
56
+ error?: string | undefined;
57
+ deletedAt?: string | null | undefined;
58
+ } | undefined;
59
+ replyPostId?: string | undefined;
60
+ } & {
61
+ _from: string;
62
+ _to: string;
63
+ }>>;
64
+ export declare const transformJamRecordingData: (recording: JamRecording & {
65
+ _from: string;
66
+ _to: string;
67
+ }) => Promise<JamRecordingWithMeta>;
68
+ /** Hostname used when stamping LiveKit room metadata (`instanceDomain`). */
69
+ export declare const localInstanceDomain: () => Promise<string | undefined>;
70
+ export declare const parseRoomInstanceDomain: (metadata: string | undefined) => string | undefined;
@@ -0,0 +1,29 @@
1
+ import { jamRecordingSchema, } from '@openpeepshq/common/types';
2
+ import { connector } from '../db/helpers.js';
3
+ import { collectionInfos } from '../db/index.js';
4
+ import { findProfile } from '../profiles/index.js';
5
+ import { findPost } from '../posts/index.js';
6
+ import { config } from '../config/index.js';
7
+ export const connectRecording = connector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.jamRecordingsCollection);
8
+ export const transformJamRecordingData = async (recording) => (Object.assign(Object.assign({}, jamRecordingSchema.parse(recording)), { profile: (await findProfile(recording._from.split('/')[1])), post: (await findPost(recording._to.split('/')[1])) }));
9
+ /** Hostname used when stamping LiveKit room metadata (`instanceDomain`). */
10
+ export const localInstanceDomain = async () => {
11
+ const host = (await config()).server.host;
12
+ if (!host)
13
+ return undefined;
14
+ const domain = (host.includes('://') ? new URL(host).hostname : host.replace(/:\d+$/, '')).toLowerCase();
15
+ return domain || undefined;
16
+ };
17
+ export const parseRoomInstanceDomain = (metadata) => {
18
+ if (!metadata)
19
+ return undefined;
20
+ try {
21
+ const parsed = JSON.parse(metadata);
22
+ return typeof parsed.instanceDomain === 'string'
23
+ ? parsed.instanceDomain.toLowerCase()
24
+ : undefined;
25
+ }
26
+ catch (_a) {
27
+ return undefined;
28
+ }
29
+ };
@@ -0,0 +1,15 @@
1
+ import { type AuthorizationData, type MuteParticipantRequest, type PostWithMeta, type Profile } from '@openpeepshq/common/types';
2
+ export { createJamToken, createJamEgressToken } from './token';
3
+ export { startRecording, stopRecording, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit';
4
+ export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs';
5
+ export * from './waitingRoom';
6
+ export * from './mutations';
7
+ export * from './finders';
8
+ export * from './recording';
9
+ export { deriveJamRecordingUploadSecret, jamRecordingUploadSecret, } from './recordingUploadAuth';
10
+ export declare const listLiveJams: (authData: AuthorizationData) => Promise<PostWithMeta[]>;
11
+ export declare const findJamEvent: (id: string) => Promise<PostWithMeta | undefined>;
12
+ export declare const closeJam: (profile: Profile, jamEvent: PostWithMeta) => Promise<import("@openpeepshq/common").JamEvent | undefined>;
13
+ export declare const muteParticipant: (jamId: string, data: MuteParticipantRequest) => Promise<{
14
+ success: boolean;
15
+ }>;
@@ -0,0 +1,108 @@
1
+ import { listParticipantIds, reclaimOrphanJamRoom, roomService, stopRecording, } from './livekit.js';
2
+ import { jamStateCache, LIVE_JAMS_CACHE_KEY, liveJamPostsCache } from './cache.js';
3
+ import { localInstanceDomain, parseRoomInstanceDomain } from './helpers.js';
4
+ import { findPost } from '../posts/index.js';
5
+ import { createJamEvent } from './mutations.js';
6
+ import { uuidv7 } from 'uuidv7';
7
+ import { canReadPost } from '../posts/helpers/index.js';
8
+ import { capabilitiesConfig } from '../config/index.js';
9
+ export { createJamToken, createJamEgressToken } from './token.js';
10
+ export { startRecording, stopRecording, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit.js';
11
+ export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs.js';
12
+ export * from './waitingRoom.js';
13
+ export * from './mutations.js';
14
+ export * from './finders.js';
15
+ export * from './recording.js';
16
+ export { deriveJamRecordingUploadSecret, jamRecordingUploadSecret, } from './recordingUploadAuth.js';
17
+ const invalidateJamCaches = async (jamId) => {
18
+ await Promise.all([
19
+ jamStateCache.del(jamId).catch(() => undefined),
20
+ liveJamPostsCache.del(LIVE_JAMS_CACHE_KEY).catch(() => undefined),
21
+ ]);
22
+ };
23
+ const reclaimLocalOrphan = (post) => {
24
+ void reclaimOrphanJamRoom(post).then(() => invalidateJamCaches(post.id));
25
+ };
26
+ /**
27
+ * Expensive LiveKit scan — shared across callers via {@link liveJamPostsCache}.
28
+ * Auth filtering happens in {@link listLiveJams} so the cache is not per-user.
29
+ */
30
+ const fetchLiveJamPosts = async () => {
31
+ const rs = await roomService();
32
+ if (rs === undefined) {
33
+ return [];
34
+ }
35
+ const [rooms, localDomain] = await Promise.all([
36
+ rs.listRooms(),
37
+ localInstanceDomain(),
38
+ ]);
39
+ const posts = await Promise.all(rooms.map(async (room) => {
40
+ const roomDomain = parseRoomInstanceDomain(room.metadata);
41
+ // Shared SFU: ignore other communities' rooms. Untagged rooms (pre-stamp)
42
+ // still go through findPost so local legacy jams keep working.
43
+ if (localDomain && roomDomain && roomDomain !== localDomain) {
44
+ return undefined;
45
+ }
46
+ // Fast path: Room.numParticipants includes hidden egress — 0 means truly empty.
47
+ if (!room.numParticipants) {
48
+ const post = await findPost(room.name);
49
+ if (post) {
50
+ reclaimLocalOrphan(post);
51
+ }
52
+ else if (!roomDomain || roomDomain === localDomain) {
53
+ void rs.deleteRoom(room.name).catch(() => undefined);
54
+ }
55
+ return undefined;
56
+ }
57
+ // Slow path only when someone (human or egress) is connected — distinguish
58
+ // egress-only ghosts from real live jams.
59
+ const humans = await listParticipantIds(room.name);
60
+ if (humans.length === 0) {
61
+ const post = await findPost(room.name);
62
+ if (post) {
63
+ reclaimLocalOrphan(post);
64
+ }
65
+ else if (!roomDomain || roomDomain === localDomain) {
66
+ void rs.deleteRoom(room.name).catch(() => undefined);
67
+ }
68
+ return undefined;
69
+ }
70
+ return findPost(room.name);
71
+ }));
72
+ return posts.filter(Boolean);
73
+ };
74
+ export const listLiveJams = async (authData) => {
75
+ const [posts, config] = await Promise.all([
76
+ liveJamPostsCache.wrap(LIVE_JAMS_CACHE_KEY, fetchLiveJamPosts),
77
+ capabilitiesConfig(),
78
+ ]);
79
+ return posts.filter(canReadPost(config, authData));
80
+ };
81
+ export const findJamEvent = async (id) => findPost(id).then((post) => { var _a, _b; return ((_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = post.data) === null || _b === void 0 ? void 0 : _b.jam) ? post : undefined; });
82
+ export const closeJam = async (profile, jamEvent) => {
83
+ const rs = await roomService();
84
+ if (rs === undefined) {
85
+ return undefined;
86
+ }
87
+ await stopRecording(jamEvent);
88
+ return rs.deleteRoom(jamEvent.id).then(async () => {
89
+ await invalidateJamCaches(jamEvent.id);
90
+ return createJamEvent({
91
+ id: uuidv7(),
92
+ jamId: jamEvent.id,
93
+ type: 'close',
94
+ profileId: profile.id,
95
+ });
96
+ });
97
+ };
98
+ export const muteParticipant = async (jamId, data) => {
99
+ const rs = await roomService();
100
+ if (rs === undefined) {
101
+ return { success: false };
102
+ }
103
+ const result = await rs.mutePublishedTrack(jamId, data.identity, data.trackSid, true);
104
+ if (!result) {
105
+ return { success: false };
106
+ }
107
+ return { success: result === null || result === void 0 ? void 0 : result.muted };
108
+ };
@@ -0,0 +1,9 @@
1
+ export declare const JAM_RECORDING_MAX_DURATION_MS: number;
2
+ export interface JamRecordingStopJobData {
3
+ jamPostId: string;
4
+ recordingId: string;
5
+ }
6
+ declare const jamRecordingStopQueue: () => import("bullmq").Queue, jamRecordingStopWorker: () => import("bullmq").Worker;
7
+ export declare const scheduleRecordingAutoStop: (jamPostId: string, recordingId: string, delayMs?: number) => Promise<void>;
8
+ export declare const cancelRecordingAutoStop: (recordingId: string) => Promise<void>;
9
+ export { jamRecordingStopQueue, jamRecordingStopWorker };