@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,42 @@
1
+ import { queueAndWorker } from '../jobs/index.js';
2
+ import { logger } from '../log/index.js';
3
+ import { findPost } from '../posts/index.js';
4
+ import { findActiveRecording } from './finders.js';
5
+ const log = logger('app:jams:jobs');
6
+ export const JAM_RECORDING_MAX_DURATION_MS = 60 * 60 * 1000;
7
+ const recordingStopJobId = (recordingId) => `jam-recording-stop:${recordingId}`;
8
+ const [jamRecordingStopQueue, jamRecordingStopWorker] = queueAndWorker('jam-recording-stop', async (job) => {
9
+ var _a;
10
+ // Dynamic import avoids a load-time cycle with livekit.ts (which schedules
11
+ // this job when a recording starts).
12
+ const { stopRecording } = await import('./livekit.js');
13
+ const jamPost = await findPost(job.data.jamPostId);
14
+ if (!jamPost || ((_a = jamPost.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event' || !jamPost.data.jam) {
15
+ log.info(`Skipping auto-stop for missing jam ${job.data.jamPostId}`);
16
+ return;
17
+ }
18
+ const jamEvent = jamPost;
19
+ const active = await findActiveRecording(jamEvent);
20
+ if (!active || active.id !== job.data.recordingId) {
21
+ log.info(`Skipping auto-stop for jam ${job.data.jamPostId}: recording already stopped or replaced`);
22
+ return;
23
+ }
24
+ log.info(`Auto-stopping recording ${job.data.recordingId} for jam ${job.data.jamPostId}`);
25
+ await stopRecording(jamEvent);
26
+ }, {
27
+ defaultJobOptions: {
28
+ removeOnComplete: { age: 86400 },
29
+ removeOnFail: { age: 86400 * 7, count: 50 },
30
+ },
31
+ });
32
+ export const scheduleRecordingAutoStop = async (jamPostId, recordingId, delayMs = JAM_RECORDING_MAX_DURATION_MS) => {
33
+ const queue = jamRecordingStopQueue();
34
+ const jobId = recordingStopJobId(recordingId);
35
+ await queue.remove(jobId).catch(() => undefined);
36
+ await queue.add('stop', { jamPostId, recordingId }, { jobId, delay: delayMs });
37
+ };
38
+ export const cancelRecordingAutoStop = async (recordingId) => {
39
+ const queue = jamRecordingStopQueue();
40
+ await queue.remove(recordingStopJobId(recordingId)).catch(() => undefined);
41
+ };
42
+ export { jamRecordingStopQueue, jamRecordingStopWorker };
@@ -0,0 +1,24 @@
1
+ import { JamRecording, JamRecordingWithMeta, JamState, PostWithMeta, ProfileWithMeta } from '@openpeepshq/common/types';
2
+ import { RoomServiceClient } from 'livekit-server-sdk';
3
+ /** Seconds a new room stays open before anyone joins. */
4
+ export declare const JAM_ROOM_EMPTY_TIMEOUT_SEC: number;
5
+ /** Seconds a room stays open after the last participant leaves. */
6
+ export declare const JAM_ROOM_DEPARTURE_TIMEOUT_SEC = 60;
7
+ export declare const roomService: () => Promise<RoomServiceClient | undefined>;
8
+ export declare const listParticipantIds: (jamId: string) => Promise<string[]>;
9
+ /**
10
+ * Relative path for the observer view (full jam UI). Used both for human
11
+ * moderator observer links and as the page LiveKit web egress records.
12
+ */
13
+ export declare const getJamObserverPath: (jamId: string) => Promise<string>;
14
+ export declare const getJamRecordingUrl: (jamId: string) => Promise<string>;
15
+ export declare const startRecording: (profile: ProfileWithMeta, jamPost: PostWithMeta) => Promise<JamRecording>;
16
+ export declare const stopEgress: (egressId: string) => Promise<void>;
17
+ export declare const stopRecording: (jamPost: PostWithMeta) => Promise<JamRecordingWithMeta | undefined>;
18
+ /**
19
+ * Stops leftover egress and deletes a LiveKit room that has no human
20
+ * participants (egress-only / orphan rooms). Safe to call repeatedly.
21
+ */
22
+ export declare const reclaimOrphanJamRoom: (jam: PostWithMeta) => Promise<void>;
23
+ export declare const finishRecording: (jamRecording: JamRecordingWithMeta) => Promise<void>;
24
+ export declare const jamState: (jam: PostWithMeta, hideParticipants?: boolean) => Promise<JamState>;
@@ -0,0 +1,220 @@
1
+ import { config } from '../config/index.js';
2
+ import { DataPacket_Kind, EgressClient, EncodedFileOutput, EncodedFileType, EncodingOptionsPreset, RoomServiceClient, } from 'livekit-server-sdk';
3
+ import { connectRecording } from './helpers.js';
4
+ import { allpeepDb } from '../db/index.js';
5
+ import { serverRootUrl } from '../server/index.js';
6
+ import { uuidv7 } from 'uuidv7';
7
+ import { createJamEvent, updateJamRecording } from './mutations.js';
8
+ import { findActiveRecording } from './finders.js';
9
+ import { cancelRecordingAutoStop, scheduleRecordingAutoStop } from './jobs.js';
10
+ import { jamRecordingUploadSecret } from './recordingUploadAuth.js';
11
+ import { createSignedServiceToken } from '../accessTokens/tokens.js';
12
+ import { unprocessableRequest } from '../errors/index.js';
13
+ import { logger } from '../log/index.js';
14
+ const encoder = new TextEncoder();
15
+ const log = logger('app:jams:livekit');
16
+ /** Seconds a new room stays open before anyone joins. */
17
+ export const JAM_ROOM_EMPTY_TIMEOUT_SEC = 5 * 60;
18
+ /** Seconds a room stays open after the last participant leaves. */
19
+ export const JAM_ROOM_DEPARTURE_TIMEOUT_SEC = 60;
20
+ export const roomService = async () => {
21
+ const { url, apiKey, apiSecret } = (await config()).jams.livekit;
22
+ if (!url || !apiKey || !apiSecret) {
23
+ return undefined;
24
+ }
25
+ return new RoomServiceClient(url, apiKey, apiSecret);
26
+ };
27
+ export const listParticipantIds = async (jamId) => {
28
+ const rs = await roomService();
29
+ if (rs === undefined) {
30
+ return [];
31
+ }
32
+ return (await rs.listParticipants(jamId))
33
+ .map((p) => p.identity)
34
+ .filter((identity) => !identity.startsWith('EG_'));
35
+ };
36
+ const getJamEgressToken = async (jamId) => createSignedServiceToken({
37
+ scopes: [
38
+ {
39
+ resource: { type: 'jam', id: jamId },
40
+ },
41
+ ],
42
+ name: 'jam-egress',
43
+ expirationTime: '1d',
44
+ }).then((token) => token.signedToken);
45
+ const isLoopbackHost = (hostname) => hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1';
46
+ const assertEgressCanReachRecordingHost = async (recordingUrl) => {
47
+ const { jams } = await config();
48
+ if (!jams.livekit.url) {
49
+ throw unprocessableRequest({
50
+ errorKey: 'jamsRecordingEgressUnreachable',
51
+ parameters: { recordingHost: new URL(recordingUrl).hostname },
52
+ });
53
+ }
54
+ const recordingHost = new URL(recordingUrl).hostname;
55
+ const livekitHost = new URL(jams.livekit.url).hostname;
56
+ if (isLoopbackHost(recordingHost) && !isLoopbackHost(livekitHost)) {
57
+ throw unprocessableRequest({
58
+ errorKey: 'jamsRecordingEgressUnreachable',
59
+ parameters: { recordingHost },
60
+ });
61
+ }
62
+ };
63
+ /**
64
+ * Relative path for the observer view (full jam UI). Used both for human
65
+ * moderator observer links and as the page LiveKit web egress records.
66
+ */
67
+ export const getJamObserverPath = async (jamId) => {
68
+ const jamEgressToken = await getJamEgressToken(jamId);
69
+ return `/events/${jamId}/jam?observer=true&token=${jamEgressToken}`;
70
+ };
71
+ export const getJamRecordingUrl = async (jamId) => `${await serverRootUrl()}${await getJamObserverPath(jamId)}`;
72
+ const getEgressClient = async () => {
73
+ const { url, apiKey, apiSecret } = (await config()).jams.livekit;
74
+ return new EgressClient(url, apiKey, apiSecret);
75
+ };
76
+ export const startRecording = async (profile, jamPost) => {
77
+ const jamId = jamPost.id;
78
+ const recordingId = uuidv7();
79
+ // Clear any recording left `active` by a previous failed egress so the new
80
+ // one is the sole active recording for this jam.
81
+ const staleRecording = await findActiveRecording(jamPost);
82
+ if (staleRecording) {
83
+ await cancelRecordingAutoStop(staleRecording.id);
84
+ await updateJamRecording(staleRecording.id, { status: 'failed' });
85
+ }
86
+ let recording = (await allpeepDb().then(({ db }) => connectRecording(db, profile, jamPost, {
87
+ id: recordingId,
88
+ status: 'requested',
89
+ })));
90
+ // Prefer the persisted edge id in case insert paths ever diverge.
91
+ const persistedRecordingId = recording.id;
92
+ const egressClient = await getEgressClient();
93
+ const outputFilename = `${persistedRecordingId}.mp4`;
94
+ const recordingUrl = await getJamRecordingUrl(jamId);
95
+ await assertEgressCanReachRecordingHost(recordingUrl);
96
+ const uploadSecret = await jamRecordingUploadSecret(persistedRecordingId);
97
+ const egressInfo = await egressClient.startWebEgress(recordingUrl, new EncodedFileOutput({
98
+ output: {
99
+ case: 's3',
100
+ value: {
101
+ endpoint: `${await serverRootUrl()}/s3`,
102
+ bucket: 'allpeep-recordings',
103
+ accessKey: persistedRecordingId,
104
+ secret: uploadSecret,
105
+ sessionToken: persistedRecordingId,
106
+ forcePathStyle: true,
107
+ },
108
+ },
109
+ filepath: outputFilename,
110
+ fileType: EncodedFileType.MP4,
111
+ }), {
112
+ encodingOptions: EncodingOptionsPreset.H264_1080P_30,
113
+ });
114
+ recording = (await updateJamRecording(persistedRecordingId, {
115
+ egressId: egressInfo.egressId,
116
+ status: 'active',
117
+ }));
118
+ const jamEvent = await createJamEvent({
119
+ id: uuidv7(),
120
+ jamId,
121
+ type: 'recordStart',
122
+ profileId: profile.id,
123
+ });
124
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamId, encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
125
+ // BullMQ delayed job survives API/worker restarts (unlike setTimeout).
126
+ await scheduleRecordingAutoStop(jamId, persistedRecordingId);
127
+ return recording;
128
+ };
129
+ export const stopEgress = async (egressId) => {
130
+ const egressClient = await getEgressClient();
131
+ try {
132
+ await egressClient.stopEgress(egressId);
133
+ }
134
+ catch (_a) {
135
+ // LiveKit egress can time out or already be stopped/failed; the user-facing
136
+ // stop action should not fail because of that.
137
+ }
138
+ };
139
+ export const stopRecording = async (jamPost) => {
140
+ const jamRecording = await findActiveRecording(jamPost);
141
+ if (!jamRecording) {
142
+ return undefined;
143
+ }
144
+ await cancelRecordingAutoStop(jamRecording.id);
145
+ if (jamRecording.egressId) {
146
+ // Don't block the API response on egress stop; LiveKit can take 15s+ and
147
+ // may time out while the upload still completes in the background.
148
+ void stopEgress(jamRecording.egressId);
149
+ }
150
+ // Emit `recordStop` immediately so the recording overlay clears, rather than
151
+ // waiting for the egress upload to finish.
152
+ const jamEvent = await createJamEvent({
153
+ id: uuidv7(),
154
+ jamId: jamPost.id,
155
+ type: 'recordStop',
156
+ profileId: jamRecording.profile.id,
157
+ });
158
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamPost.id, encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
159
+ return jamRecording;
160
+ };
161
+ /**
162
+ * Stops leftover egress and deletes a LiveKit room that has no human
163
+ * participants (egress-only / orphan rooms). Safe to call repeatedly.
164
+ */
165
+ export const reclaimOrphanJamRoom = async (jam) => {
166
+ try {
167
+ await stopRecording(jam);
168
+ }
169
+ catch (e) {
170
+ log.warn(`Failed to stop recording while reclaiming jam ${jam.id}: ${e.message}`);
171
+ }
172
+ try {
173
+ const rs = await roomService();
174
+ await (rs === null || rs === void 0 ? void 0 : rs.deleteRoom(jam.id));
175
+ }
176
+ catch (e) {
177
+ log.warn(`Failed to delete orphan jam room ${jam.id}: ${e.message}`);
178
+ }
179
+ };
180
+ export const finishRecording = async (jamRecording) => {
181
+ const jamEvent = await createJamEvent({
182
+ id: uuidv7(),
183
+ jamId: jamRecording.post.id,
184
+ type: 'recordStop',
185
+ profileId: jamRecording.profile.id,
186
+ });
187
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamRecording.post.id, encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
188
+ };
189
+ export const jamState = async (jam, hideParticipants) => {
190
+ const rs = await roomService();
191
+ if (rs === undefined) {
192
+ return {
193
+ participants: [],
194
+ active: false,
195
+ };
196
+ }
197
+ const room = await rs
198
+ .listRooms([jam.id])
199
+ .then((rooms) => rooms.find((r) => r.name === jam.id));
200
+ if (!room) {
201
+ return {
202
+ participants: [],
203
+ active: false,
204
+ };
205
+ }
206
+ const participants = await listParticipantIds(jam.id);
207
+ if (participants.length === 0) {
208
+ // Room exists only for egress ghosts / empty leftovers — reclaim so it
209
+ // stops appearing under Live jams.
210
+ void reclaimOrphanJamRoom(jam);
211
+ return {
212
+ participants: [],
213
+ active: false,
214
+ };
215
+ }
216
+ return {
217
+ participants: hideParticipants ? [] : participants,
218
+ active: true,
219
+ };
220
+ };
@@ -0,0 +1,137 @@
1
+ import { RelationWithMapping } from '../db/pg/map';
2
+ import { JamEvent, JamRecording, PostWithMeta } from '@openpeepshq/common/types';
3
+ type EdgeMetadata = {
4
+ _from: string;
5
+ _to: string;
6
+ };
7
+ export declare const jamEventsMapping: import("../db/pg/map").Mapping<{
8
+ id: string;
9
+ jamId: string;
10
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
11
+ profileId: string;
12
+ content?: string | undefined;
13
+ reaction?: "👍" | undefined;
14
+ }, JamEvent, JamEvent>;
15
+ export declare const jamSessionStartsMapping: import("../db/pg/map").Mapping<{
16
+ id: string;
17
+ jamId: string;
18
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
19
+ profileId: string;
20
+ content?: string | undefined;
21
+ reaction?: "👍" | undefined;
22
+ }, JamEvent, JamEvent>;
23
+ export declare const jamSessionClosesMapping: import("../db/pg/map").Mapping<{
24
+ id: string;
25
+ jamId: string;
26
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
27
+ profileId: string;
28
+ content?: string | undefined;
29
+ reaction?: "👍" | undefined;
30
+ }, JamEvent, JamEvent>;
31
+ export declare const jamParticipantsMapping: import("../db/pg/map").Mapping<{
32
+ id: string;
33
+ jamId: string;
34
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
35
+ profileId: string;
36
+ content?: string | undefined;
37
+ reaction?: "👍" | undefined;
38
+ }, JamEvent, JamEvent>;
39
+ export declare const jamRecordingRelation: RelationWithMapping<PostWithMeta, JamRecording>;
40
+ export declare const jamRecordingsMapping: import("../db/pg/map").Mapping<{
41
+ status: "active" | "completed" | "failed" | "requested";
42
+ egressId?: string | undefined;
43
+ attachment?: {
44
+ type: string;
45
+ url: string;
46
+ previewUrl: string | null;
47
+ textUrl: null;
48
+ filename: string;
49
+ meta: {
50
+ usage?: string | undefined;
51
+ focus?: {
52
+ x: number;
53
+ y: number;
54
+ } | undefined;
55
+ mimetype?: string | undefined;
56
+ size?: number | undefined;
57
+ };
58
+ id: string;
59
+ createdAt: string;
60
+ updatedAt: string;
61
+ description?: string | undefined;
62
+ blurhash?: string | undefined;
63
+ status?: "ready" | "failed" | "processing" | undefined;
64
+ error?: string | undefined;
65
+ deletedAt?: string | null | undefined;
66
+ } | undefined;
67
+ replyPostId?: string | undefined;
68
+ }, {
69
+ createdAt: string;
70
+ updatedAt: string;
71
+ deletedAt?: string | null | undefined;
72
+ } & {
73
+ status: "active" | "completed" | "failed" | "requested";
74
+ egressId?: string | undefined;
75
+ attachment?: {
76
+ type: string;
77
+ url: string;
78
+ previewUrl: string | null;
79
+ textUrl: null;
80
+ filename: string;
81
+ meta: {
82
+ usage?: string | undefined;
83
+ focus?: {
84
+ x: number;
85
+ y: number;
86
+ } | undefined;
87
+ mimetype?: string | undefined;
88
+ size?: number | undefined;
89
+ };
90
+ id: string;
91
+ createdAt: string;
92
+ updatedAt: string;
93
+ description?: string | undefined;
94
+ blurhash?: string | undefined;
95
+ status?: "ready" | "failed" | "processing" | undefined;
96
+ error?: string | undefined;
97
+ deletedAt?: string | null | undefined;
98
+ } | undefined;
99
+ replyPostId?: string | undefined;
100
+ } & {
101
+ id: string;
102
+ } & EdgeMetadata, {
103
+ createdAt: string;
104
+ updatedAt: string;
105
+ deletedAt?: string | null | undefined;
106
+ } & {
107
+ status: "active" | "completed" | "failed" | "requested";
108
+ egressId?: string | undefined;
109
+ attachment?: {
110
+ type: string;
111
+ url: string;
112
+ previewUrl: string | null;
113
+ textUrl: null;
114
+ filename: string;
115
+ meta: {
116
+ usage?: string | undefined;
117
+ focus?: {
118
+ x: number;
119
+ y: number;
120
+ } | undefined;
121
+ mimetype?: string | undefined;
122
+ size?: number | undefined;
123
+ };
124
+ id: string;
125
+ createdAt: string;
126
+ updatedAt: string;
127
+ description?: string | undefined;
128
+ blurhash?: string | undefined;
129
+ status?: "ready" | "failed" | "processing" | undefined;
130
+ error?: string | undefined;
131
+ deletedAt?: string | null | undefined;
132
+ } | undefined;
133
+ replyPostId?: string | undefined;
134
+ } & {
135
+ id: string;
136
+ } & EdgeMetadata>;
137
+ export {};
@@ -0,0 +1,35 @@
1
+ import { map } from '../db/pg/map/index.js';
2
+ import { collectionInfos } from '../db/index.js';
3
+ export const jamEventsMapping = map({
4
+ collection: collectionInfos.jamEventsCollection.name,
5
+ });
6
+ export const jamSessionStartsMapping = jamEventsMapping.filter({
7
+ matches: {
8
+ type: 'start',
9
+ },
10
+ });
11
+ export const jamSessionClosesMapping = jamEventsMapping.filter({
12
+ matches: {
13
+ type: 'close',
14
+ },
15
+ });
16
+ export const jamParticipantsMapping = jamEventsMapping.filter({
17
+ matches: {
18
+ type: 'join',
19
+ },
20
+ });
21
+ export const jamRecordingRelation = {
22
+ alias: 'profile',
23
+ edgeCollection: 'jamRecordings',
24
+ direction: 'INBOUND',
25
+ skipEdge: false,
26
+ cardinality: 'many',
27
+ mapping: {
28
+ collection: 'profiles',
29
+ softDelete: true,
30
+ },
31
+ };
32
+ export const jamRecordingsMapping = map({
33
+ collection: 'jamRecordings',
34
+ keepMetadata: true,
35
+ });
@@ -0,0 +1,40 @@
1
+ import type { JamEventData, JamRecordingData } from '@openpeepshq/common/types';
2
+ export declare const createJamEvent: (jamEvent: JamEventData) => Promise<import("@openpeepshq/common").JamEvent>;
3
+ export declare const updateJamRecording: (recordingId: string, recording: Partial<JamRecordingData>) => Promise<{
4
+ createdAt: string;
5
+ updatedAt: string;
6
+ deletedAt?: string | null | undefined;
7
+ } & {
8
+ status: "active" | "completed" | "failed" | "requested";
9
+ egressId?: string | undefined;
10
+ attachment?: {
11
+ type: string;
12
+ url: string;
13
+ previewUrl: string | null;
14
+ textUrl: null;
15
+ filename: string;
16
+ meta: {
17
+ usage?: string | undefined;
18
+ focus?: {
19
+ x: number;
20
+ y: number;
21
+ } | undefined;
22
+ mimetype?: string | undefined;
23
+ size?: number | undefined;
24
+ };
25
+ id: string;
26
+ createdAt: string;
27
+ updatedAt: string;
28
+ description?: string | undefined;
29
+ blurhash?: string | undefined;
30
+ status?: "ready" | "failed" | "processing" | undefined;
31
+ error?: string | undefined;
32
+ deletedAt?: string | null | undefined;
33
+ } | undefined;
34
+ replyPostId?: string | undefined;
35
+ } & {
36
+ id: string;
37
+ } & {
38
+ _from: string;
39
+ _to: string;
40
+ }>;
@@ -0,0 +1,4 @@
1
+ import { allpeepDb } from '../db/index.js';
2
+ import { jamEventsMapping, jamRecordingsMapping } from './mapping.js';
3
+ export const createJamEvent = (jamEvent) => allpeepDb().then(({ db }) => jamEventsMapping.create(db, jamEvent));
4
+ export const updateJamRecording = (recordingId, recording) => allpeepDb().then(({ db }) => jamRecordingsMapping.update(db, recordingId, recording));
@@ -0,0 +1,8 @@
1
+ import type { JamRecording, JamRecordingWithMeta, MediaAttachment, PostWithMeta } from '@openpeepshq/common/types';
2
+ /**
3
+ * Persists the uploaded recording file as a completed jam recording and
4
+ * notifies listeners (e.g. streaming pre-warm) via `jamRecordingCompleted`.
5
+ */
6
+ export declare const completeJamRecording: (recordingId: string, attachment: MediaAttachment) => Promise<JamRecordingWithMeta | undefined>;
7
+ export declare const publishJamRecordingReply: (eventPost: PostWithMeta, recordingId: string) => Promise<JamRecording>;
8
+ export declare const deleteJamRecording: (eventPost: PostWithMeta, recordingId: string) => Promise<void>;
@@ -0,0 +1,67 @@
1
+ import { jamRecordingSchema } from '@openpeepshq/common/types';
2
+ import { hub } from '../events/index.js';
3
+ import { createPost } from '../posts/index.js';
4
+ import { allpeepDb } from '../db/index.js';
5
+ import { findJamRecording } from './finders.js';
6
+ import { jamRecordingsMapping } from './mapping.js';
7
+ import { updateJamRecording } from './mutations.js';
8
+ /**
9
+ * Persists the uploaded recording file as a completed jam recording and
10
+ * notifies listeners (e.g. streaming pre-warm) via `jamRecordingCompleted`.
11
+ */
12
+ export const completeJamRecording = async (recordingId, attachment) => {
13
+ await updateJamRecording(recordingId, {
14
+ attachment,
15
+ status: 'completed',
16
+ });
17
+ const recording = await findJamRecording(recordingId);
18
+ if (recording) {
19
+ hub.emit('jamRecordingCompleted', recording);
20
+ }
21
+ return recording;
22
+ };
23
+ export const publishJamRecordingReply = async (eventPost, recordingId) => {
24
+ const recording = await findJamRecording(recordingId);
25
+ if (!recording) {
26
+ throw new Error('Recording not found');
27
+ }
28
+ if (recording.post.id !== eventPost.id) {
29
+ throw new Error('Recording does not belong to this event');
30
+ }
31
+ if (recording.replyPostId) {
32
+ throw new Error('Recording already published');
33
+ }
34
+ if (recording.status !== 'completed' || !recording.attachment) {
35
+ throw new Error('Recording is not ready');
36
+ }
37
+ const event = eventPost.data;
38
+ const reply = await createPost({
39
+ type: 'note',
40
+ content: `Jam recording for ${event.name}`,
41
+ attachments: [recording.attachment],
42
+ }, eventPost.profile, {
43
+ type: 'note',
44
+ visibility: eventPost.visibility,
45
+ creatorId: eventPost.profile.id,
46
+ }, {
47
+ inReplyToId: eventPost.id,
48
+ groupId: eventPost.groupId,
49
+ audience: eventPost.audience,
50
+ });
51
+ await updateJamRecording(recordingId, { replyPostId: reply.id });
52
+ return jamRecordingSchema.parse(Object.assign(Object.assign({}, recording), { replyPostId: reply.id }));
53
+ };
54
+ export const deleteJamRecording = async (eventPost, recordingId) => {
55
+ const recording = await findJamRecording(recordingId);
56
+ if (!recording) {
57
+ throw new Error('Recording not found');
58
+ }
59
+ if (recording.post.id !== eventPost.id) {
60
+ throw new Error('Recording does not belong to this event');
61
+ }
62
+ if (recording.status === 'active' || recording.status === 'requested') {
63
+ throw new Error('Recording is still in progress');
64
+ }
65
+ const { db } = await allpeepDb();
66
+ await jamRecordingsMapping.delete(db, recordingId);
67
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * S3 secret LiveKit egress uses for jam recording uploads.
3
+ *
4
+ * Access key / session token remain the recording id (path-bound). The secret
5
+ * is derived from the LiveKit API secret so knowing a recording id alone is
6
+ * not enough to forge SigV4 uploads.
7
+ */
8
+ export declare const deriveJamRecordingUploadSecret: (apiSecret: string, recordingId: string) => string;
9
+ export declare const jamRecordingUploadSecret: (recordingId: string) => Promise<string>;
@@ -0,0 +1,19 @@
1
+ import { createHmac } from 'node:crypto';
2
+ import { config } from '../config/index.js';
3
+ /**
4
+ * S3 secret LiveKit egress uses for jam recording uploads.
5
+ *
6
+ * Access key / session token remain the recording id (path-bound). The secret
7
+ * is derived from the LiveKit API secret so knowing a recording id alone is
8
+ * not enough to forge SigV4 uploads.
9
+ */
10
+ export const deriveJamRecordingUploadSecret = (apiSecret, recordingId) => createHmac('sha256', apiSecret)
11
+ .update(`jam-recording-upload:${recordingId}`)
12
+ .digest('hex');
13
+ export const jamRecordingUploadSecret = async (recordingId) => {
14
+ const apiSecret = (await config()).jams.livekit.apiSecret;
15
+ if (!apiSecret) {
16
+ throw new Error('LiveKit API secret is not configured');
17
+ }
18
+ return deriveJamRecordingUploadSecret(apiSecret, recordingId);
19
+ };
@@ -0,0 +1,4 @@
1
+ import { PostWithMeta, PublicProfile } from '@openpeepshq/common/types';
2
+ export declare const assertJamRsvpAllowed: (event: PostWithMeta, profile: PublicProfile) => void;
3
+ export declare const createJamEgressToken: (event: PostWithMeta) => Promise<string>;
4
+ export declare const createJamToken: (event: PostWithMeta, profile: PublicProfile, external?: boolean) => Promise<string>;