@openpeepshq/core 0.1.32 → 0.1.34

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 (261) hide show
  1. package/dist/accessTokens/helpers.d.ts +2 -2
  2. package/dist/accessTokens/tokens.js +14 -7
  3. package/dist/accounts/mutations.d.ts +2 -2
  4. package/dist/accounts/mutations.js +33 -35
  5. package/dist/analytics/cache.js +12 -7
  6. package/dist/analytics/compile.js +16 -10
  7. package/dist/analytics/pdfReport.d.ts +1 -0
  8. package/dist/analytics/pdfReport.js +5 -4
  9. package/dist/analytics/privacy.d.ts +18 -0
  10. package/dist/analytics/privacy.js +10 -0
  11. package/dist/analytics/read.js +75 -19
  12. package/dist/analytics/report.d.ts +21 -1
  13. package/dist/analytics/report.js +9 -2
  14. package/dist/backups/index.js +78 -15
  15. package/dist/backups/metadata.d.ts +8 -2
  16. package/dist/backups/metadata.js +6 -2
  17. package/dist/config/defaults/capabilities.js +13 -2
  18. package/dist/config/defaults/community.js +7 -9
  19. package/dist/config/defaults/core.d.ts +1 -1
  20. package/dist/config/defaults/core.js +3 -0
  21. package/dist/config/defaults/db.d.ts +0 -2
  22. package/dist/config/defaults/db.js +0 -2
  23. package/dist/config/index.d.ts +25 -3
  24. package/dist/config/index.js +7 -1
  25. package/dist/db/helpers.d.ts +7 -28
  26. package/dist/db/helpers.js +30 -152
  27. package/dist/db/index.d.ts +3 -1
  28. package/dist/db/index.js +5 -0
  29. package/dist/db/init.js +2 -2
  30. package/dist/db/migration/importCollections.d.ts +15 -10
  31. package/dist/db/migration/importCollections.js +121 -155
  32. package/dist/db/migration/shared.d.ts +2 -37
  33. package/dist/db/migration/shared.js +2 -59
  34. package/dist/db/pg/client.js +4 -0
  35. package/dist/db/pg/collections.d.ts +2 -2
  36. package/dist/db/pg/collections.js +2 -2
  37. package/dist/db/pg/filters/edges.d.ts +1 -1
  38. package/dist/db/pg/filters/edges.js +1 -1
  39. package/dist/db/pg/filters/posts.d.ts +11 -0
  40. package/dist/db/pg/filters/posts.js +37 -3
  41. package/dist/db/pg/filters/profiles.d.ts +1 -0
  42. package/dist/db/pg/filters/profiles.js +2 -1
  43. package/dist/db/pg/map/filters.js +37 -2
  44. package/dist/db/pg/map/mutations.js +13 -8
  45. package/dist/db/pg/map/registry.d.ts +5 -0
  46. package/dist/db/pg/map/registry.js +64 -24
  47. package/dist/db/pg/map/relations.d.ts +1 -1
  48. package/dist/db/pg/map/relations.js +98 -46
  49. package/dist/db/pg/migrate.d.ts +22 -0
  50. package/dist/db/pg/migrate.js +88 -2
  51. package/dist/db/pg/queries/activity.js +3 -3
  52. package/dist/db/pg/queries/sorts.d.ts +1 -0
  53. package/dist/db/pg/queries/sorts.js +4 -0
  54. package/dist/db/pg/schema/documents.d.ts +422 -41
  55. package/dist/db/pg/schema/documents.js +43 -9
  56. package/dist/db/pg/schema/edges.d.ts +117 -7
  57. package/dist/db/pg/schema/edges.js +4 -2
  58. package/dist/db/pg/schema/index.d.ts +505 -15
  59. package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
  60. package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
  61. package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
  62. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  63. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  64. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  65. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  66. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  67. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  68. package/dist/db/pg/sql/meta/{0006_snapshot.json → 0015_snapshot.json} +393 -39
  69. package/dist/db/pg/sql/meta/_journal.json +64 -1
  70. package/dist/db/replaceOrigin.js +6 -0
  71. package/dist/db/types.d.ts +0 -4
  72. package/dist/email/render.js +11 -3
  73. package/dist/events/index.d.ts +6 -1
  74. package/dist/events/index.js +55 -33
  75. package/dist/federation/activities.d.ts +17 -0
  76. package/dist/federation/activities.js +26 -0
  77. package/dist/federation/identity.d.ts +16 -0
  78. package/dist/federation/identity.js +52 -0
  79. package/dist/federation/index.d.ts +4 -0
  80. package/dist/federation/index.js +3 -0
  81. package/dist/federation/profiles.d.ts +3 -0
  82. package/dist/federation/profiles.js +14 -0
  83. package/dist/groups/finders.d.ts +3 -2
  84. package/dist/groups/helpers.d.ts +24 -6
  85. package/dist/groups/mapping.d.ts +6 -4
  86. package/dist/groups/mapping.js +2 -2
  87. package/dist/groups/mutations.js +1 -1
  88. package/dist/hashtags/finders.d.ts +6 -3
  89. package/dist/hashtags/finders.js +2 -0
  90. package/dist/hashtags/helpers.d.ts +8 -0
  91. package/dist/hashtags/helpers.js +4 -0
  92. package/dist/hashtags/index.d.ts +2 -0
  93. package/dist/hashtags/index.js +2 -0
  94. package/dist/hashtags/mutations.d.ts +3 -0
  95. package/dist/hashtags/mutations.js +13 -1
  96. package/dist/i18n/index.d.ts +1 -1
  97. package/dist/i18n/index.js +3 -1
  98. package/dist/i18n/pluginLocales.d.ts +6 -0
  99. package/dist/i18n/pluginLocales.js +15 -0
  100. package/dist/inviteLinks/helpers.d.ts +4 -4
  101. package/dist/jams/cache.d.ts +1 -1
  102. package/dist/jams/cache.js +2 -1
  103. package/dist/jams/export.d.ts +19 -0
  104. package/dist/jams/export.js +60 -0
  105. package/dist/jams/finders.d.ts +2 -1
  106. package/dist/jams/finders.js +18 -7
  107. package/dist/jams/health.d.ts +8 -0
  108. package/dist/jams/health.js +46 -0
  109. package/dist/jams/helpers.d.ts +6 -2
  110. package/dist/jams/index.d.ts +6 -3
  111. package/dist/jams/index.js +41 -27
  112. package/dist/jams/jobs.js +1 -1
  113. package/dist/jams/livekit.d.ts +93 -10
  114. package/dist/jams/livekit.js +151 -52
  115. package/dist/jams/mapping.d.ts +17 -7
  116. package/dist/jams/mutations.d.ts +3 -1
  117. package/dist/jams/recording.d.ts +10 -0
  118. package/dist/jams/recording.js +32 -0
  119. package/dist/jams/rtmp.d.ts +5 -0
  120. package/dist/jams/rtmp.js +8 -0
  121. package/dist/jams/token.d.ts +15 -3
  122. package/dist/jams/token.js +30 -16
  123. package/dist/jams/waitingRoom.d.ts +6 -6
  124. package/dist/jams/waitingRoom.js +24 -23
  125. package/dist/jobs/index.d.ts +1 -0
  126. package/dist/jobs/index.js +6 -1
  127. package/dist/jobs/jobDetail.js +1 -6
  128. package/dist/media/index.d.ts +1 -1
  129. package/dist/media/index.js +23 -8
  130. package/dist/media/processing.js +18 -7
  131. package/dist/notifications/defaultNotifications/follow/index.js +2 -2
  132. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
  133. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
  134. package/dist/notifications/defaultNotifications/index.js +4 -0
  135. package/dist/notifications/defaultNotifications/newGroupPost/index.js +12 -6
  136. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  137. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  138. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  139. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +18 -0
  140. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  141. package/dist/notifications/defaultNotifications/rsvp/index.js +7 -0
  142. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  143. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +75 -0
  144. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  145. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  146. package/dist/notifications/helpers.js +6 -2
  147. package/dist/notifications/jobs.js +3 -1
  148. package/dist/notifications/mutations.js +4 -0
  149. package/dist/notifications/push.js +11 -4
  150. package/dist/plugins/helpers.d.ts +1 -0
  151. package/dist/plugins/helpers.js +1 -8
  152. package/dist/plugins/index.d.ts +5 -0
  153. package/dist/plugins/index.js +78 -5
  154. package/dist/plugins/install.d.ts +39 -0
  155. package/dist/plugins/install.js +455 -0
  156. package/dist/plugins/pluginAuth.d.ts +1 -1
  157. package/dist/plugins/pluginAuth.js +10 -6
  158. package/dist/plugins/state.d.ts +4 -0
  159. package/dist/plugins/state.js +29 -0
  160. package/dist/posts/activity.d.ts +9 -0
  161. package/dist/posts/activity.js +35 -0
  162. package/dist/posts/contextClosure.d.ts +1 -9
  163. package/dist/posts/contextClosure.js +15 -44
  164. package/dist/posts/conversationQueries.d.ts +7 -0
  165. package/dist/posts/conversationQueries.js +76 -2
  166. package/dist/posts/eventAgenda.d.ts +166 -0
  167. package/dist/posts/eventAgenda.js +126 -0
  168. package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
  169. package/dist/posts/eventOccurrenceJobs.js +28 -0
  170. package/dist/posts/eventOccurrences.d.ts +10 -0
  171. package/dist/posts/eventOccurrences.js +61 -0
  172. package/dist/posts/finders.d.ts +47 -16
  173. package/dist/posts/finders.js +93 -62
  174. package/dist/posts/helpers/filters.js +14 -9
  175. package/dist/posts/helpers/index.d.ts +129 -30
  176. package/dist/posts/helpers/index.js +66 -33
  177. package/dist/posts/index.d.ts +7 -1
  178. package/dist/posts/index.js +7 -1
  179. package/dist/posts/mapping.d.ts +491 -13
  180. package/dist/posts/mapping.js +45 -10
  181. package/dist/posts/mutations.d.ts +441 -4
  182. package/dist/posts/mutations.js +177 -43
  183. package/dist/posts/pollEnd.d.ts +3 -0
  184. package/dist/posts/pollEnd.js +7 -0
  185. package/dist/posts/pollEndJobs.d.ts +8 -0
  186. package/dist/posts/pollEndJobs.js +49 -0
  187. package/dist/posts/replyClosure.d.ts +10 -0
  188. package/dist/posts/replyClosure.js +43 -0
  189. package/dist/posts/rsvpConfirmationEmail.js +14 -15
  190. package/dist/posts/threadPreview.d.ts +8 -0
  191. package/dist/posts/threadPreview.js +44 -0
  192. package/dist/posts/unseenCounts.d.ts +2 -0
  193. package/dist/posts/unseenCounts.js +28 -8
  194. package/dist/profileSettings/cache.js +22 -5
  195. package/dist/profileSettings/mapping.d.ts +2 -0
  196. package/dist/profiles/activityQueries.d.ts +5 -0
  197. package/dist/profiles/activityQueries.js +85 -0
  198. package/dist/profiles/activitySummary.d.ts +3 -0
  199. package/dist/profiles/activitySummary.js +87 -0
  200. package/dist/profiles/blocks.d.ts +12 -0
  201. package/dist/profiles/blocks.js +73 -0
  202. package/dist/profiles/cache.d.ts +4 -1
  203. package/dist/profiles/cache.js +28 -7
  204. package/dist/profiles/finders.d.ts +2 -1
  205. package/dist/profiles/finders.js +8 -3
  206. package/dist/profiles/helpers.d.ts +7 -5
  207. package/dist/profiles/index.d.ts +3 -1
  208. package/dist/profiles/index.js +3 -1
  209. package/dist/profiles/mapping.d.ts +10 -5
  210. package/dist/profiles/mapping.js +13 -1
  211. package/dist/profiles/mutations.d.ts +8 -4
  212. package/dist/profiles/mutations.js +42 -15
  213. package/dist/pushSubscriptions/helpers.d.ts +2 -2
  214. package/dist/pushSubscriptions/mutations.js +13 -1
  215. package/dist/redis/connection.d.ts +2 -0
  216. package/dist/redis/connection.js +25 -6
  217. package/dist/reports/helpers.d.ts +6 -6
  218. package/dist/roles/index.d.ts +1 -1
  219. package/dist/roles/index.js +1 -1
  220. package/dist/roles/mapping.d.ts +1 -0
  221. package/dist/roles/mutations.js +86 -3
  222. package/dist/search/mapping.d.ts +1 -1
  223. package/dist/search/mapping.js +6 -2
  224. package/dist/server/index.d.ts +19 -1
  225. package/dist/server/index.js +37 -18
  226. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  227. package/dist/server/stablePublicServerInfo.js +37 -0
  228. package/dist/server/status.d.ts +25 -0
  229. package/dist/server/status.js +98 -0
  230. package/dist/stats/finders.d.ts +1 -16131
  231. package/dist/stats/finders.js +9 -5
  232. package/dist/stats/mapping.d.ts +21 -1
  233. package/dist/stats/mapping.js +0 -3
  234. package/package.json +6 -12
  235. package/dist/db/arango.d.ts +0 -2
  236. package/dist/db/arango.js +0 -110
  237. package/dist/db/migration/autoMigrate.d.ts +0 -2
  238. package/dist/db/migration/autoMigrate.js +0 -111
  239. package/dist/db/migration/cli.d.ts +0 -1
  240. package/dist/db/migration/cli.js +0 -56
  241. package/dist/db/migration/detect.d.ts +0 -6
  242. package/dist/db/migration/detect.js +0 -87
  243. package/dist/db/migration/exportArango.d.ts +0 -4
  244. package/dist/db/migration/exportArango.js +0 -80
  245. package/dist/db/migration/importPostgres.d.ts +0 -3
  246. package/dist/db/migration/importPostgres.js +0 -18
  247. package/dist/db/migration/transform.d.ts +0 -18
  248. package/dist/db/migration/transform.js +0 -209
  249. package/dist/db/migration/validate.d.ts +0 -18
  250. package/dist/db/migration/validate.js +0 -69
  251. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  252. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  253. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  254. package/dist/mastodon/index.d.ts +0 -4
  255. package/dist/mastodon/index.js +0 -51
  256. package/dist/mastodon/types.d.ts +0 -7579
  257. package/dist/mastodon/types.js +0 -523
  258. package/dist/mastodon/typescript.d.ts +0 -1578
  259. package/dist/mastodon/typescript.js +0 -1
  260. package/dist/roles/defaults.d.ts +0 -2
  261. package/dist/roles/defaults.js +0 -94
@@ -1,3 +1,4 @@
1
+ import { jamRoomName } from '@openpeepshq/common/lib';
1
2
  import { config } from '../config/index.js';
2
3
  import { DataPacket_Kind, EgressClient, EncodedFileOutput, EncodedFileType, EncodingOptionsPreset, RoomServiceClient, } from 'livekit-server-sdk';
3
4
  import { connectRecording } from './helpers.js';
@@ -5,18 +6,28 @@ import { allpeepDb } from '../db/index.js';
5
6
  import { serverRootUrl } from '../server/index.js';
6
7
  import { uuidv7 } from 'uuidv7';
7
8
  import { createJamEvent, updateJamRecording } from './mutations.js';
8
- import { findActiveRecording } from './finders.js';
9
+ import { findActiveRecording, findActiveRtmpStream } from './finders.js';
9
10
  import { cancelRecordingAutoStop, scheduleRecordingAutoStop } from './jobs.js';
11
+ import { finalizeJamRecording } from './recording.js';
10
12
  import { jamRecordingUploadSecret } from './recordingUploadAuth.js';
11
13
  import { createSignedServiceToken } from '../accessTokens/tokens.js';
12
14
  import { unprocessableRequest } from '../errors/index.js';
13
15
  import { logger } from '../log/index.js';
16
+ import { rtmpStreamOutput, rtmpWebEgressOptions } from './rtmp.js';
14
17
  const encoder = new TextEncoder();
15
18
  const log = logger('app:jams:livekit');
16
19
  /** Seconds a new room stays open before anyone joins. */
17
20
  export const JAM_ROOM_EMPTY_TIMEOUT_SEC = 5 * 60;
18
21
  /** Seconds a room stays open after the last participant leaves. */
19
22
  export const JAM_ROOM_DEPARTURE_TIMEOUT_SEC = 60;
23
+ /**
24
+ * LiveKit closes rooms with no participants via emptyTimeout (host still
25
+ * connecting after Start) and departureTimeout (reconnect). Those rooms must
26
+ * not be deleted here. Reclaim only when a non-human participant (egress) is
27
+ * holding the room open — they count toward `numParticipants`, so LiveKit
28
+ * will not time the room out.
29
+ */
30
+ export const shouldReclaimJamRoom = (numParticipants, humanCount) => humanCount === 0 && numParticipants > 0;
20
31
  export const roomService = async () => {
21
32
  const { url, apiKey, apiSecret } = (await config()).jams.livekit;
22
33
  if (!url || !apiKey || !apiSecret) {
@@ -36,7 +47,7 @@ export const listParticipantIds = async (jamId) => {
36
47
  const getJamEgressToken = async (jamId) => createSignedServiceToken({
37
48
  scopes: [
38
49
  {
39
- resource: { type: 'jam', id: jamId },
50
+ resource: { type: 'jams', id: jamId },
40
51
  },
41
52
  ],
42
53
  name: 'jam-egress',
@@ -61,27 +72,45 @@ const assertEgressCanReachRecordingHost = async (recordingUrl) => {
61
72
  }
62
73
  };
63
74
  /**
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.
75
+ * Relative path for the observer view (full jam UI). Used for human
76
+ * moderator observer links, jam recording web egress, and RTMP web egress.
66
77
  */
67
- export const getJamObserverPath = async (jamId) => {
78
+ export const getJamObserverPath = async (jamId, recurrenceId) => {
68
79
  const jamEgressToken = await getJamEgressToken(jamId);
69
- return `/events/${jamId}/jam?observer=true&token=${jamEgressToken}`;
80
+ const occurrence = recurrenceId
81
+ ? `&occurrence=${encodeURIComponent(recurrenceId)}`
82
+ : '';
83
+ return `/events/${jamId}/jam?observer=true&token=${jamEgressToken}${occurrence}`;
70
84
  };
71
- export const getJamRecordingUrl = async (jamId) => `${await serverRootUrl()}${await getJamObserverPath(jamId)}`;
85
+ export const getJamRecordingUrl = async (jamId, recurrenceId) => `${await serverRootUrl()}${await getJamObserverPath(jamId, recurrenceId)}`;
72
86
  const getEgressClient = async () => {
73
87
  const { url, apiKey, apiSecret } = (await config()).jams.livekit;
74
88
  return new EgressClient(url, apiKey, apiSecret);
75
89
  };
76
- export const startRecording = async (profile, jamPost) => {
90
+ export const stopEgress = async (egressId) => {
91
+ const egressClient = await getEgressClient();
92
+ try {
93
+ await egressClient.stopEgress(egressId);
94
+ }
95
+ catch (_a) {
96
+ // LiveKit egress can time out or already be stopped/failed; the user-facing
97
+ // stop action should not fail because of that.
98
+ }
99
+ };
100
+ export const startRecording = async (profile, jamPost, recurrenceId) => {
77
101
  const jamId = jamPost.id;
102
+ const roomName = jamRoomName(jamPost.id, recurrenceId);
78
103
  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.
104
+ // A leftover `active` row may still be uploading after stop. Finalize it so
105
+ // Complete can succeed, and stop its egress so this start is the only live
106
+ // take.
81
107
  const staleRecording = await findActiveRecording(jamPost);
82
108
  if (staleRecording) {
83
109
  await cancelRecordingAutoStop(staleRecording.id);
84
- await updateJamRecording(staleRecording.id, { status: 'failed' });
110
+ if (staleRecording.egressId) {
111
+ void stopEgress(staleRecording.egressId);
112
+ }
113
+ await finalizeJamRecording(staleRecording.id);
85
114
  }
86
115
  let recording = (await allpeepDb().then(({ db }) => connectRecording(db, profile, jamPost, {
87
116
  id: recordingId,
@@ -91,7 +120,7 @@ export const startRecording = async (profile, jamPost) => {
91
120
  const persistedRecordingId = recording.id;
92
121
  const egressClient = await getEgressClient();
93
122
  const outputFilename = `${persistedRecordingId}.mp4`;
94
- const recordingUrl = await getJamRecordingUrl(jamId);
123
+ const recordingUrl = await getJamRecordingUrl(jamId, recurrenceId);
95
124
  await assertEgressCanReachRecordingHost(recordingUrl);
96
125
  const uploadSecret = await jamRecordingUploadSecret(persistedRecordingId);
97
126
  const egressInfo = await egressClient.startWebEgress(recordingUrl, new EncodedFileOutput({
@@ -120,23 +149,81 @@ export const startRecording = async (profile, jamPost) => {
120
149
  jamId,
121
150
  type: 'recordStart',
122
151
  profileId: profile.id,
152
+ recurrenceId,
123
153
  });
124
- await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamId, encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
154
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(roomName, encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
125
155
  // BullMQ delayed job survives API/worker restarts (unlike setTimeout).
126
156
  await scheduleRecordingAutoStop(jamId, persistedRecordingId);
127
157
  return recording;
128
158
  };
129
- export const stopEgress = async (egressId) => {
159
+ const assertLivekitConfigured = async () => {
160
+ const { url, apiKey, apiSecret } = (await config()).jams.livekit;
161
+ if (!url || !apiKey || !apiSecret) {
162
+ throw unprocessableRequest({ errorKey: 'error.jamsUnavailable' });
163
+ }
164
+ };
165
+ const assertJamRoomOpen = async (jamId) => {
166
+ const rs = await roomService();
167
+ if (rs === undefined) {
168
+ throw unprocessableRequest({ errorKey: 'error.jamsUnavailable' });
169
+ }
170
+ const rooms = await rs.listRooms([jamId]);
171
+ if (rooms.length !== 1) {
172
+ throw unprocessableRequest({ errorKey: 'error.jamNotOpen' });
173
+ }
174
+ };
175
+ const emitJamEvent = async (jamId, jamEvent) => {
176
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamId, encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
177
+ };
178
+ export const startRtmpStream = async (profile, jamPost, rtmpUrl, destinationHost) => {
179
+ await assertLivekitConfigured();
180
+ await assertJamRoomOpen(jamPost.id);
181
+ await stopRtmpStream(jamPost);
182
+ const jamId = jamPost.id;
183
+ const recordingId = uuidv7();
184
+ let recording = (await allpeepDb().then(({ db }) => connectRecording(db, profile, jamPost, {
185
+ id: recordingId,
186
+ status: 'requested',
187
+ kind: 'rtmp',
188
+ destinationHost,
189
+ })));
190
+ const persistedRecordingId = recording.id;
191
+ const observerUrl = await getJamRecordingUrl(jamId);
192
+ await assertEgressCanReachRecordingHost(observerUrl);
130
193
  const egressClient = await getEgressClient();
131
- try {
132
- await egressClient.stopEgress(egressId);
194
+ const egressInfo = await egressClient.startWebEgress(observerUrl, rtmpStreamOutput(rtmpUrl), rtmpWebEgressOptions);
195
+ recording = (await updateJamRecording(persistedRecordingId, {
196
+ egressId: egressInfo.egressId,
197
+ status: 'active',
198
+ }));
199
+ const jamEvent = await createJamEvent({
200
+ id: uuidv7(),
201
+ jamId,
202
+ type: 'streamStart',
203
+ profileId: profile.id,
204
+ });
205
+ await emitJamEvent(jamId, jamEvent);
206
+ return recording;
207
+ };
208
+ export const stopRtmpStream = async (jamPost) => {
209
+ const stream = await findActiveRtmpStream(jamPost);
210
+ if (!stream) {
211
+ return undefined;
133
212
  }
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.
213
+ if (stream.egressId) {
214
+ void stopEgress(stream.egressId);
137
215
  }
216
+ await updateJamRecording(stream.id, { status: 'completed' });
217
+ const jamEvent = await createJamEvent({
218
+ id: uuidv7(),
219
+ jamId: jamPost.id,
220
+ type: 'streamStop',
221
+ profileId: stream.profile.id,
222
+ });
223
+ await emitJamEvent(jamPost.id, jamEvent);
224
+ return Object.assign(Object.assign({}, stream), { status: 'completed' });
138
225
  };
139
- export const stopRecording = async (jamPost) => {
226
+ export const stopRecording = async (jamPost, recurrenceId) => {
140
227
  const jamRecording = await findActiveRecording(jamPost);
141
228
  if (!jamRecording) {
142
229
  return undefined;
@@ -154,27 +241,36 @@ export const stopRecording = async (jamPost) => {
154
241
  jamId: jamPost.id,
155
242
  type: 'recordStop',
156
243
  profileId: jamRecording.profile.id,
244
+ recurrenceId,
157
245
  });
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;
246
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamRoomName(jamPost.id, recurrenceId), encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
247
+ await finalizeJamRecording(jamRecording.id);
248
+ return Object.assign(Object.assign({}, jamRecording), { status: 'finalizing' });
160
249
  };
161
250
  /**
162
- * Stops leftover egress and deletes a LiveKit room that has no human
163
- * participants (egress-only / orphan rooms). Safe to call repeatedly.
251
+ * Stops leftover egress and deletes an egress-only LiveKit room.
252
+ * Do not call this for a room with zero participants — that room is still
253
+ * inside emptyTimeout or departureTimeout. Safe to call repeatedly.
164
254
  */
165
- export const reclaimOrphanJamRoom = async (jam) => {
255
+ export const reclaimOrphanJamRoom = async (jam, roomName = jam.id) => {
166
256
  try {
167
257
  await stopRecording(jam);
168
258
  }
169
259
  catch (e) {
170
260
  log.warn(`Failed to stop recording while reclaiming jam ${jam.id}: ${e.message}`);
171
261
  }
262
+ try {
263
+ await stopRtmpStream(jam);
264
+ }
265
+ catch (e) {
266
+ log.warn(`Failed to stop RTMP stream while reclaiming jam ${jam.id}: ${e.message}`);
267
+ }
172
268
  try {
173
269
  const rs = await roomService();
174
- await (rs === null || rs === void 0 ? void 0 : rs.deleteRoom(jam.id));
270
+ await (rs === null || rs === void 0 ? void 0 : rs.deleteRoom(roomName));
175
271
  }
176
272
  catch (e) {
177
- log.warn(`Failed to delete orphan jam room ${jam.id}: ${e.message}`);
273
+ log.warn(`Failed to delete orphan jam room ${roomName}: ${e.message}`);
178
274
  }
179
275
  };
180
276
  export const finishRecording = async (jamRecording) => {
@@ -184,37 +280,40 @@ export const finishRecording = async (jamRecording) => {
184
280
  type: 'recordStop',
185
281
  profileId: jamRecording.profile.id,
186
282
  });
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, {}));
283
+ await roomService().then(async (rs) => rs === null || rs === void 0 ? void 0 : rs.sendData(jamRoomName(jamRecording.post.id), encoder.encode(JSON.stringify(jamEvent)), DataPacket_Kind.LOSSY, {}));
188
284
  };
189
- export const jamState = async (jam, hideParticipants) => {
285
+ export const jamState = async (jam, hideParticipants, recurrenceId) => {
286
+ const inactive = { participants: [], active: false };
190
287
  const rs = await roomService();
288
+ const roomName = jamRoomName(jam.id, recurrenceId);
191
289
  if (rs === undefined) {
192
- return {
193
- participants: [],
194
- active: false,
195
- };
290
+ return inactive;
196
291
  }
197
- const room = await rs
198
- .listRooms([jam.id])
199
- .then((rooms) => rooms.find((r) => r.name === jam.id));
200
- if (!room) {
292
+ try {
293
+ const room = await rs
294
+ .listRooms([roomName])
295
+ .then((rooms) => rooms.find((r) => r.name === roomName));
296
+ if (!room) {
297
+ return inactive;
298
+ }
299
+ // No one has joined yet, or the last person just left. Leave the room
300
+ // for LiveKit's empty/departure timeout so a host on "Connecting" is
301
+ // not kicked back to the lobby.
302
+ if (!room.numParticipants) {
303
+ return inactive;
304
+ }
305
+ const participants = await listParticipantIds(roomName);
306
+ if (shouldReclaimJamRoom(room.numParticipants, participants.length)) {
307
+ void reclaimOrphanJamRoom(jam, roomName);
308
+ return inactive;
309
+ }
201
310
  return {
202
- participants: [],
203
- active: false,
311
+ participants: hideParticipants ? [] : participants,
312
+ active: true,
204
313
  };
205
314
  }
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
- };
315
+ catch (e) {
316
+ log.warn(`Failed to read jam state for ${roomName}: ${e.message}`);
317
+ return inactive;
215
318
  }
216
- return {
217
- participants: hideParticipants ? [] : participants,
218
- active: true,
219
- };
220
319
  };
@@ -7,38 +7,44 @@ type EdgeMetadata = {
7
7
  export declare const jamEventsMapping: import("../db/pg/map").Mapping<{
8
8
  id: string;
9
9
  jamId: string;
10
- type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
10
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
11
11
  profileId: string;
12
12
  content?: string | undefined;
13
13
  reaction?: "👍" | undefined;
14
+ recurrenceId?: string | undefined;
14
15
  }, JamEvent, JamEvent>;
15
16
  export declare const jamSessionStartsMapping: import("../db/pg/map").Mapping<{
16
17
  id: string;
17
18
  jamId: string;
18
- type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
19
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
19
20
  profileId: string;
20
21
  content?: string | undefined;
21
22
  reaction?: "👍" | undefined;
23
+ recurrenceId?: string | undefined;
22
24
  }, JamEvent, JamEvent>;
23
25
  export declare const jamSessionClosesMapping: import("../db/pg/map").Mapping<{
24
26
  id: string;
25
27
  jamId: string;
26
- type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
28
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
27
29
  profileId: string;
28
30
  content?: string | undefined;
29
31
  reaction?: "👍" | undefined;
32
+ recurrenceId?: string | undefined;
30
33
  }, JamEvent, JamEvent>;
31
34
  export declare const jamParticipantsMapping: import("../db/pg/map").Mapping<{
32
35
  id: string;
33
36
  jamId: string;
34
- type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop";
37
+ type: "close" | "join" | "message" | "start" | "reaction" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
35
38
  profileId: string;
36
39
  content?: string | undefined;
37
40
  reaction?: "👍" | undefined;
41
+ recurrenceId?: string | undefined;
38
42
  }, JamEvent, JamEvent>;
39
43
  export declare const jamRecordingRelation: RelationWithMapping<PostWithMeta, JamRecording>;
40
44
  export declare const jamRecordingsMapping: import("../db/pg/map").Mapping<{
41
- status: "active" | "completed" | "failed" | "requested";
45
+ status: "active" | "completed" | "failed" | "requested" | "finalizing";
46
+ kind?: "file" | "rtmp" | undefined;
47
+ destinationHost?: string | undefined;
42
48
  egressId?: string | undefined;
43
49
  attachment?: {
44
50
  type: string;
@@ -70,7 +76,9 @@ export declare const jamRecordingsMapping: import("../db/pg/map").Mapping<{
70
76
  updatedAt: string;
71
77
  deletedAt?: string | null | undefined;
72
78
  } & {
73
- status: "active" | "completed" | "failed" | "requested";
79
+ status: "active" | "completed" | "failed" | "requested" | "finalizing";
80
+ kind?: "file" | "rtmp" | undefined;
81
+ destinationHost?: string | undefined;
74
82
  egressId?: string | undefined;
75
83
  attachment?: {
76
84
  type: string;
@@ -104,7 +112,9 @@ export declare const jamRecordingsMapping: import("../db/pg/map").Mapping<{
104
112
  updatedAt: string;
105
113
  deletedAt?: string | null | undefined;
106
114
  } & {
107
- status: "active" | "completed" | "failed" | "requested";
115
+ status: "active" | "completed" | "failed" | "requested" | "finalizing";
116
+ kind?: "file" | "rtmp" | undefined;
117
+ destinationHost?: string | undefined;
108
118
  egressId?: string | undefined;
109
119
  attachment?: {
110
120
  type: string;
@@ -5,7 +5,9 @@ export declare const updateJamRecording: (recordingId: string, recording: Partia
5
5
  updatedAt: string;
6
6
  deletedAt?: string | null | undefined;
7
7
  } & {
8
- status: "active" | "completed" | "failed" | "requested";
8
+ status: "active" | "completed" | "failed" | "requested" | "finalizing";
9
+ kind?: "file" | "rtmp" | undefined;
10
+ destinationHost?: string | undefined;
9
11
  egressId?: string | undefined;
10
12
  attachment?: {
11
13
  type: string;
@@ -4,5 +4,15 @@ import type { JamRecording, JamRecordingWithMeta, MediaAttachment, PostWithMeta
4
4
  * notifies listeners (e.g. streaming pre-warm) via `jamRecordingCompleted`.
5
5
  */
6
6
  export declare const completeJamRecording: (recordingId: string, attachment: MediaAttachment) => Promise<JamRecordingWithMeta | undefined>;
7
+ /**
8
+ * Marks a stopped recording as still accepting its multipart complete. Used
9
+ * after egress stop so a later start does not fail the in-flight upload.
10
+ */
11
+ export declare const finalizeJamRecording: (recordingId: string) => Promise<void>;
12
+ /**
13
+ * Marks an in-progress or finalizing recording failed. Completed recordings
14
+ * are left unchanged. Multipart temp files are the S3 layer's responsibility.
15
+ */
16
+ export declare const failJamRecording: (recordingId: string) => Promise<void>;
7
17
  export declare const publishJamRecordingReply: (eventPost: PostWithMeta, recordingId: string) => Promise<JamRecording>;
8
18
  export declare const deleteJamRecording: (eventPost: PostWithMeta, recordingId: string) => Promise<void>;
@@ -1,8 +1,10 @@
1
1
  import { jamRecordingSchema } from '@openpeepshq/common/types';
2
+ import { jamRecordingAcceptsUpload } from '@openpeepshq/common/lib';
2
3
  import { hub } from '../events/index.js';
3
4
  import { createPost } from '../posts/index.js';
4
5
  import { allpeepDb } from '../db/index.js';
5
6
  import { findJamRecording } from './finders.js';
7
+ import { cancelRecordingAutoStop } from './jobs.js';
6
8
  import { jamRecordingsMapping } from './mapping.js';
7
9
  import { updateJamRecording } from './mutations.js';
8
10
  /**
@@ -20,6 +22,36 @@ export const completeJamRecording = async (recordingId, attachment) => {
20
22
  }
21
23
  return recording;
22
24
  };
25
+ /**
26
+ * Marks a stopped recording as still accepting its multipart complete. Used
27
+ * after egress stop so a later start does not fail the in-flight upload.
28
+ */
29
+ export const finalizeJamRecording = async (recordingId) => {
30
+ const recording = await findJamRecording(recordingId);
31
+ if (!recording) {
32
+ return;
33
+ }
34
+ if (recording.status !== 'requested' && recording.status !== 'active') {
35
+ return;
36
+ }
37
+ await cancelRecordingAutoStop(recordingId);
38
+ await updateJamRecording(recordingId, { status: 'finalizing' });
39
+ };
40
+ /**
41
+ * Marks an in-progress or finalizing recording failed. Completed recordings
42
+ * are left unchanged. Multipart temp files are the S3 layer's responsibility.
43
+ */
44
+ export const failJamRecording = async (recordingId) => {
45
+ const recording = await findJamRecording(recordingId);
46
+ if (!recording) {
47
+ return;
48
+ }
49
+ if (!jamRecordingAcceptsUpload(recording.status)) {
50
+ return;
51
+ }
52
+ await cancelRecordingAutoStop(recordingId);
53
+ await updateJamRecording(recordingId, { status: 'failed' });
54
+ };
23
55
  export const publishJamRecordingReply = async (eventPost, recordingId) => {
24
56
  const recording = await findJamRecording(recordingId);
25
57
  if (!recording) {
@@ -0,0 +1,5 @@
1
+ import { EncodingOptionsPreset, StreamOutput } from 'livekit-server-sdk';
2
+ export declare const rtmpStreamOutput: (rtmpUrl: string) => StreamOutput;
3
+ export declare const rtmpWebEgressOptions: {
4
+ readonly encodingOptions: EncodingOptionsPreset.H264_1080P_30;
5
+ };
@@ -0,0 +1,8 @@
1
+ import { EncodingOptionsPreset, StreamOutput, StreamProtocol, } from 'livekit-server-sdk';
2
+ export const rtmpStreamOutput = (rtmpUrl) => new StreamOutput({
3
+ protocol: StreamProtocol.RTMP,
4
+ urls: [rtmpUrl],
5
+ });
6
+ export const rtmpWebEgressOptions = {
7
+ encodingOptions: EncodingOptionsPreset.H264_1080P_30,
8
+ };
@@ -1,4 +1,16 @@
1
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>;
2
+ export declare const assertJamRsvpAllowed: (event: PostWithMeta, profile: PublicProfile, recurrenceId?: string) => void;
3
+ export declare const createJamEgressToken: (event: PostWithMeta, recurrenceId?: string) => Promise<string>;
4
+ export type CreateJamTokenOptions = {
5
+ /** Participant is joining from another instance. */
6
+ external?: boolean;
7
+ recurrenceId?: string;
8
+ /**
9
+ * Automatic re-join after a dropped connection, as opposed to a participant
10
+ * deliberately joining. A reconnect must never open the room: a moderator
11
+ * whose client re-tokens into an ended jam would put it back on the live
12
+ * list and notify the community all over again.
13
+ */
14
+ reconnect?: boolean;
15
+ };
16
+ export declare const createJamToken: (event: PostWithMeta, profile: PublicProfile, { external, recurrenceId, reconnect, }?: CreateJamTokenOptions) => Promise<string>;
@@ -1,5 +1,5 @@
1
1
  import { publicProfileSchema, } from '@openpeepshq/common/types';
2
- import { canModerateJam, countYesRsvps, getEffectiveRsvp, } from '@openpeepshq/common/lib';
2
+ import { canModerateJam, countYesRsvps, getEffectiveRsvp, isBlockedPair, jamRoomName, } from '@openpeepshq/common/lib';
3
3
  import { authNeeded, forbidden, notFound } from '../errors/index.js';
4
4
  import { config } from '../config/index.js';
5
5
  import { AccessToken, TrackSource } from 'livekit-server-sdk';
@@ -8,6 +8,7 @@ import { JAM_ROOM_DEPARTURE_TIMEOUT_SEC, JAM_ROOM_EMPTY_TIMEOUT_SEC, roomService
8
8
  import { localInstanceDomain } from './helpers.js';
9
9
  import { createJamEvent } from './mutations.js';
10
10
  import { uuidv7 } from 'uuidv7';
11
+ import { findProfile } from '../profiles/index.js';
11
12
  const calculateSources = (jam, profile) => {
12
13
  var _a;
13
14
  const sources = [TrackSource.MICROPHONE];
@@ -19,7 +20,7 @@ const calculateSources = (jam, profile) => {
19
20
  }
20
21
  return sources;
21
22
  };
22
- export const assertJamRsvpAllowed = (event, profile) => {
23
+ export const assertJamRsvpAllowed = (event, profile, recurrenceId) => {
23
24
  var _a, _b;
24
25
  const eventData = ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' ? event.data : undefined;
25
26
  if (!(eventData === null || eventData === void 0 ? void 0 : eventData.maxAttendees)) {
@@ -28,17 +29,18 @@ export const assertJamRsvpAllowed = (event, profile) => {
28
29
  if (canModerateJam(profile, event)) {
29
30
  return;
30
31
  }
31
- if (((_b = getEffectiveRsvp(event, profile.id)) === null || _b === void 0 ? void 0 : _b.response) === 'yes') {
32
+ if (((_b = getEffectiveRsvp(event, profile.id, recurrenceId)) === null || _b === void 0 ? void 0 : _b.response) === 'yes') {
32
33
  return;
33
34
  }
34
- if (countYesRsvps(event) >= eventData.maxAttendees) {
35
+ if (countYesRsvps(event, recurrenceId) >= eventData.maxAttendees) {
35
36
  throw forbidden({ errorKey: 'error.eventAtCapacity' });
36
37
  }
37
38
  throw forbidden({ errorKey: 'error.jamRsvpRequired' });
38
39
  };
39
- export const createJamEgressToken = async (event) => {
40
+ export const createJamEgressToken = async (event, recurrenceId) => {
40
41
  var _a, _b;
41
42
  const jamId = event.id;
43
+ const roomName = jamRoomName(event.id, recurrenceId);
42
44
  const jam = ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.jam);
43
45
  if (!jam) {
44
46
  throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
@@ -51,7 +53,7 @@ export const createJamEgressToken = async (event) => {
51
53
  }),
52
54
  });
53
55
  accessToken.addGrant({
54
- room: jamId,
56
+ room: roomName,
55
57
  hidden: true,
56
58
  roomJoin: true,
57
59
  roomRecord: true,
@@ -59,23 +61,34 @@ export const createJamEgressToken = async (event) => {
59
61
  });
60
62
  return accessToken.toJwt();
61
63
  };
62
- export const createJamToken = async (event, profile, external = false) => {
63
- var _a, _b, _c;
64
+ export const createJamToken = async (event, profile, { external = false, recurrenceId, reconnect = false, } = {}) => {
65
+ var _a, _b, _c, _d;
64
66
  if (!profile.id)
65
67
  throw authNeeded({ errorKey: 'error.profileRequired' });
66
68
  const jamId = event.id;
69
+ const roomName = jamRoomName(event.id, recurrenceId);
67
70
  const jam = ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.jam);
68
71
  if (!jam) {
69
72
  throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
70
73
  }
71
- assertJamRsvpAllowed(event, profile);
74
+ const joiner = await findProfile(profile.id);
75
+ if (joiner && isBlockedPair(joiner, (_c = event.profile) === null || _c === void 0 ? void 0 : _c.id)) {
76
+ throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
77
+ }
78
+ assertJamRsvpAllowed(event, profile, recurrenceId);
72
79
  const rs = await roomService();
73
80
  if (rs === undefined) {
74
- throw forbidden({ errorKey: 'error.jamNotOpen' });
81
+ throw forbidden({ errorKey: 'error.jamsUnavailable' });
82
+ }
83
+ let rooms;
84
+ try {
85
+ rooms = await rs.listRooms([roomName]);
86
+ }
87
+ catch (_e) {
88
+ throw forbidden({ errorKey: 'error.jamsUnavailable' });
75
89
  }
76
- const rooms = await rs.listRooms([jamId]);
77
90
  const jamOpen = rooms.length === 1;
78
- if (!jamOpen && !(jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id))) {
91
+ if (!jamOpen && (reconnect || !(jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id)))) {
79
92
  throw forbidden({ errorKey: 'error.jamNotOpen' });
80
93
  }
81
94
  if (!jamOpen) {
@@ -84,13 +97,13 @@ export const createJamToken = async (event, profile, external = false) => {
84
97
  if (instanceDomain) {
85
98
  try {
86
99
  await rs.createRoom({
87
- name: jamId,
100
+ name: roomName,
88
101
  metadata: JSON.stringify({ instanceDomain }),
89
102
  emptyTimeout: JAM_ROOM_EMPTY_TIMEOUT_SEC,
90
103
  departureTimeout: JAM_ROOM_DEPARTURE_TIMEOUT_SEC,
91
104
  });
92
105
  }
93
- catch (_d) {
106
+ catch (_f) {
94
107
  // Concurrent open may have created the room already.
95
108
  }
96
109
  }
@@ -99,6 +112,7 @@ export const createJamToken = async (event, profile, external = false) => {
99
112
  jamId,
100
113
  type: 'start',
101
114
  profileId: profile.id,
115
+ recurrenceId,
102
116
  });
103
117
  }
104
118
  const { apiKey, apiSecret } = (await config()).jams.livekit;
@@ -112,11 +126,11 @@ export const createJamToken = async (event, profile, external = false) => {
112
126
  }),
113
127
  });
114
128
  accessToken.addGrant({
115
- room: jamId,
129
+ room: roomName,
116
130
  roomJoin: true,
117
131
  roomAdmin: jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id),
118
132
  roomRecord: jam === null || jam === void 0 ? void 0 : jam.moderators.includes(profile.id),
119
- canPublish: (jam === null || jam === void 0 ? void 0 : jam.type) === 'video-call' || !!((_c = jam === null || jam === void 0 ? void 0 : jam.speakers) === null || _c === void 0 ? void 0 : _c.includes(profile.id)),
133
+ canPublish: (jam === null || jam === void 0 ? void 0 : jam.type) === 'video-call' || !!((_d = jam === null || jam === void 0 ? void 0 : jam.speakers) === null || _d === void 0 ? void 0 : _d.includes(profile.id)),
120
134
  canPublishSources: calculateSources(jam, profile),
121
135
  canPublishData: true,
122
136
  canSubscribe: true,
@@ -1,7 +1,7 @@
1
1
  import { type PublicProfile, type PostWithMeta } from '@openpeepshq/common/types';
2
- export declare const isAdmittedToJam: (event: PostWithMeta, profileId: string) => Promise<boolean>;
3
- export declare const clearJamAdmittance: (event: PostWithMeta) => Promise<void>;
4
- export declare const currentWaitingRoomWatch: (jamEvent: PostWithMeta, onChange: (waitingRoom: Record<string, PublicProfile>) => void | Promise<void>) => Promise<() => Promise<void>>;
5
- export declare const admittanceWatch: (jamEvent: PostWithMeta, profileId: string, onToken: (token: string) => Promise<void> | void) => Promise<() => Promise<void>>;
6
- export declare const joinWaitingRoom: (event: PostWithMeta, profile: PublicProfile) => Promise<void>;
7
- export declare const acceptFromWaitingRoom: (event: PostWithMeta, profileId: string) => Promise<undefined>;
2
+ export declare const isAdmittedToJam: (event: PostWithMeta, profileId: string, recurrenceId?: string) => Promise<boolean>;
3
+ export declare const clearJamAdmittance: (event: PostWithMeta, recurrenceId?: string) => Promise<void>;
4
+ export declare const currentWaitingRoomWatch: (jamEvent: PostWithMeta, onChange: (waitingRoom: Record<string, PublicProfile>) => void | Promise<void>, recurrenceId?: string) => Promise<() => Promise<void>>;
5
+ export declare const admittanceWatch: (jamEvent: PostWithMeta, profileId: string, onToken: (token: string) => Promise<void> | void, recurrenceId?: string) => Promise<() => Promise<void>>;
6
+ export declare const joinWaitingRoom: (event: PostWithMeta, profile: PublicProfile, recurrenceId?: string) => Promise<void>;
7
+ export declare const acceptFromWaitingRoom: (event: PostWithMeta, profileId: string, recurrenceId?: string) => Promise<undefined>;