@openpeepshq/core 0.1.33 → 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 (213) hide show
  1. package/dist/accounts/mutations.js +33 -35
  2. package/dist/analytics/compile.js +16 -10
  3. package/dist/analytics/read.js +52 -9
  4. package/dist/analytics/report.d.ts +20 -0
  5. package/dist/backups/index.js +75 -15
  6. package/dist/backups/metadata.d.ts +2 -3
  7. package/dist/backups/metadata.js +6 -2
  8. package/dist/config/defaults/capabilities.js +13 -2
  9. package/dist/config/defaults/community.js +7 -3
  10. package/dist/config/defaults/core.d.ts +1 -1
  11. package/dist/config/defaults/core.js +3 -0
  12. package/dist/config/index.d.ts +21 -0
  13. package/dist/config/index.js +7 -1
  14. package/dist/db/helpers.d.ts +1 -0
  15. package/dist/db/helpers.js +11 -3
  16. package/dist/db/index.d.ts +1 -1
  17. package/dist/db/index.js +1 -0
  18. package/dist/db/init.js +2 -3
  19. package/dist/db/migration/importCollections.d.ts +14 -9
  20. package/dist/db/migration/importCollections.js +114 -164
  21. package/dist/db/migration/shared.d.ts +2 -33
  22. package/dist/db/migration/shared.js +2 -52
  23. package/dist/db/pg/collections.d.ts +2 -2
  24. package/dist/db/pg/collections.js +2 -2
  25. package/dist/db/pg/filters/posts.d.ts +10 -0
  26. package/dist/db/pg/filters/posts.js +28 -4
  27. package/dist/db/pg/filters/profiles.d.ts +1 -0
  28. package/dist/db/pg/filters/profiles.js +2 -1
  29. package/dist/db/pg/map/filters.js +32 -2
  30. package/dist/db/pg/map/mutations.js +13 -8
  31. package/dist/db/pg/map/registry.d.ts +5 -0
  32. package/dist/db/pg/map/registry.js +64 -24
  33. package/dist/db/pg/map/relations.js +9 -5
  34. package/dist/db/pg/migrate.d.ts +1 -2
  35. package/dist/db/pg/migrate.js +6 -6
  36. package/dist/db/pg/queries/activity.js +3 -3
  37. package/dist/db/pg/queries/sorts.d.ts +1 -0
  38. package/dist/db/pg/queries/sorts.js +4 -0
  39. package/dist/db/pg/schema/documents.d.ts +279 -41
  40. package/dist/db/pg/schema/documents.js +21 -8
  41. package/dist/db/pg/schema/edges.d.ts +116 -7
  42. package/dist/db/pg/schema/edges.js +2 -1
  43. package/dist/db/pg/schema/index.d.ts +362 -15
  44. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  45. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  46. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  47. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  48. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  49. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  50. package/dist/db/pg/sql/meta/{0009_snapshot.json → 0015_snapshot.json} +291 -36
  51. package/dist/db/pg/sql/meta/_journal.json +43 -1
  52. package/dist/email/render.js +11 -3
  53. package/dist/events/index.d.ts +4 -0
  54. package/dist/events/index.js +1 -0
  55. package/dist/federation/activities.d.ts +17 -0
  56. package/dist/federation/activities.js +26 -0
  57. package/dist/federation/identity.d.ts +16 -0
  58. package/dist/federation/identity.js +52 -0
  59. package/dist/federation/index.d.ts +4 -0
  60. package/dist/federation/index.js +3 -0
  61. package/dist/federation/profiles.d.ts +3 -0
  62. package/dist/federation/profiles.js +14 -0
  63. package/dist/groups/finders.d.ts +2 -1
  64. package/dist/groups/helpers.d.ts +18 -0
  65. package/dist/groups/mapping.d.ts +4 -2
  66. package/dist/hashtags/finders.d.ts +6 -3
  67. package/dist/hashtags/finders.js +2 -0
  68. package/dist/hashtags/helpers.d.ts +8 -0
  69. package/dist/hashtags/helpers.js +4 -0
  70. package/dist/hashtags/index.d.ts +2 -0
  71. package/dist/hashtags/index.js +2 -0
  72. package/dist/hashtags/mutations.d.ts +3 -0
  73. package/dist/hashtags/mutations.js +13 -1
  74. package/dist/i18n/index.d.ts +1 -1
  75. package/dist/i18n/index.js +3 -1
  76. package/dist/i18n/pluginLocales.d.ts +6 -0
  77. package/dist/i18n/pluginLocales.js +15 -0
  78. package/dist/jams/export.d.ts +19 -0
  79. package/dist/jams/export.js +60 -0
  80. package/dist/jams/health.d.ts +8 -0
  81. package/dist/jams/health.js +46 -0
  82. package/dist/jams/helpers.d.ts +2 -2
  83. package/dist/jams/index.d.ts +2 -0
  84. package/dist/jams/index.js +23 -16
  85. package/dist/jams/jobs.js +1 -1
  86. package/dist/jams/livekit.d.ts +49 -4
  87. package/dist/jams/livekit.js +56 -39
  88. package/dist/jams/mapping.d.ts +3 -3
  89. package/dist/jams/mutations.d.ts +1 -1
  90. package/dist/jams/recording.d.ts +10 -0
  91. package/dist/jams/recording.js +32 -0
  92. package/dist/jams/token.d.ts +13 -1
  93. package/dist/jams/token.js +18 -7
  94. package/dist/jams/waitingRoom.js +1 -1
  95. package/dist/jobs/index.d.ts +1 -0
  96. package/dist/jobs/index.js +6 -1
  97. package/dist/jobs/jobDetail.js +1 -6
  98. package/dist/media/index.d.ts +1 -1
  99. package/dist/media/index.js +23 -8
  100. package/dist/media/processing.js +18 -7
  101. package/dist/notifications/defaultNotifications/follow/index.js +2 -2
  102. package/dist/notifications/defaultNotifications/index.js +4 -0
  103. package/dist/notifications/defaultNotifications/newGroupPost/index.js +12 -6
  104. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  105. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  106. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  107. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +18 -0
  108. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  109. package/dist/notifications/defaultNotifications/rsvp/index.js +7 -0
  110. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  111. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +75 -0
  112. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  113. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  114. package/dist/notifications/jobs.js +3 -1
  115. package/dist/notifications/mutations.js +4 -0
  116. package/dist/plugins/index.js +37 -1
  117. package/dist/plugins/install.d.ts +28 -9
  118. package/dist/plugins/install.js +281 -49
  119. package/dist/plugins/pluginAuth.d.ts +1 -1
  120. package/dist/plugins/pluginAuth.js +10 -6
  121. package/dist/posts/activity.d.ts +9 -0
  122. package/dist/posts/activity.js +35 -0
  123. package/dist/posts/contextClosure.d.ts +1 -9
  124. package/dist/posts/contextClosure.js +15 -44
  125. package/dist/posts/conversationQueries.d.ts +7 -0
  126. package/dist/posts/conversationQueries.js +76 -2
  127. package/dist/posts/eventAgenda.d.ts +1 -0
  128. package/dist/posts/eventAgenda.js +10 -4
  129. package/dist/posts/eventOccurrenceJobs.js +7 -2
  130. package/dist/posts/eventOccurrences.d.ts +6 -0
  131. package/dist/posts/eventOccurrences.js +21 -0
  132. package/dist/posts/finders.d.ts +15 -8
  133. package/dist/posts/finders.js +67 -18
  134. package/dist/posts/helpers/filters.js +13 -8
  135. package/dist/posts/helpers/index.d.ts +27 -14
  136. package/dist/posts/helpers/index.js +34 -14
  137. package/dist/posts/index.d.ts +5 -2
  138. package/dist/posts/index.js +5 -2
  139. package/dist/posts/mapping.d.ts +216 -13
  140. package/dist/posts/mapping.js +14 -13
  141. package/dist/posts/mutations.d.ts +440 -3
  142. package/dist/posts/mutations.js +155 -32
  143. package/dist/posts/pollEnd.d.ts +3 -0
  144. package/dist/posts/pollEnd.js +7 -0
  145. package/dist/posts/pollEndJobs.d.ts +8 -0
  146. package/dist/posts/pollEndJobs.js +49 -0
  147. package/dist/posts/replyClosure.d.ts +10 -0
  148. package/dist/posts/replyClosure.js +43 -0
  149. package/dist/posts/rsvpConfirmationEmail.js +14 -16
  150. package/dist/posts/threadPreview.d.ts +8 -0
  151. package/dist/posts/threadPreview.js +44 -0
  152. package/dist/posts/unseenCounts.js +4 -1
  153. package/dist/profileSettings/cache.js +22 -5
  154. package/dist/profileSettings/mapping.d.ts +2 -0
  155. package/dist/profiles/activityQueries.d.ts +5 -0
  156. package/dist/profiles/activityQueries.js +85 -0
  157. package/dist/profiles/activitySummary.d.ts +3 -0
  158. package/dist/profiles/activitySummary.js +87 -0
  159. package/dist/profiles/blocks.d.ts +12 -0
  160. package/dist/profiles/blocks.js +73 -0
  161. package/dist/profiles/cache.d.ts +1 -0
  162. package/dist/profiles/cache.js +19 -6
  163. package/dist/profiles/finders.d.ts +2 -1
  164. package/dist/profiles/finders.js +8 -3
  165. package/dist/profiles/helpers.d.ts +2 -0
  166. package/dist/profiles/index.d.ts +2 -0
  167. package/dist/profiles/index.js +2 -0
  168. package/dist/profiles/mapping.d.ts +10 -5
  169. package/dist/profiles/mapping.js +13 -1
  170. package/dist/profiles/mutations.d.ts +8 -4
  171. package/dist/profiles/mutations.js +31 -2
  172. package/dist/redis/connection.d.ts +2 -0
  173. package/dist/redis/connection.js +25 -6
  174. package/dist/roles/index.d.ts +1 -1
  175. package/dist/roles/index.js +1 -1
  176. package/dist/roles/mapping.d.ts +1 -0
  177. package/dist/roles/mutations.js +86 -3
  178. package/dist/search/mapping.d.ts +1 -1
  179. package/dist/search/mapping.js +6 -2
  180. package/dist/server/index.d.ts +18 -0
  181. package/dist/server/index.js +24 -12
  182. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  183. package/dist/server/stablePublicServerInfo.js +37 -0
  184. package/dist/server/status.d.ts +25 -0
  185. package/dist/server/status.js +98 -0
  186. package/dist/stats/finders.d.ts +1 -17681
  187. package/dist/stats/finders.js +9 -5
  188. package/dist/stats/mapping.d.ts +0 -1
  189. package/dist/stats/mapping.js +0 -3
  190. package/package.json +4 -5
  191. package/dist/db/migration/detect.d.ts +0 -3
  192. package/dist/db/migration/detect.js +0 -33
  193. package/dist/db/migration/importPostgres.d.ts +0 -3
  194. package/dist/db/migration/importPostgres.js +0 -18
  195. package/dist/db/migration/transform.d.ts +0 -20
  196. package/dist/db/migration/transform.js +0 -232
  197. package/dist/db/migration/validate.d.ts +0 -18
  198. package/dist/db/migration/validate.js +0 -69
  199. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  200. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  201. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  202. package/dist/db/pg/sql/meta/0006_snapshot.json +0 -4200
  203. package/dist/db/pg/sql/meta/0007_snapshot.json +0 -4179
  204. package/dist/mastodon/index.d.ts +0 -4
  205. package/dist/mastodon/index.js +0 -51
  206. package/dist/mastodon/types.d.ts +0 -7579
  207. package/dist/mastodon/types.js +0 -523
  208. package/dist/mastodon/typescript.d.ts +0 -1578
  209. package/dist/mastodon/typescript.js +0 -1
  210. package/dist/migration/index.d.ts +0 -4
  211. package/dist/migration/index.js +0 -4
  212. package/dist/roles/defaults.d.ts +0 -2
  213. package/dist/roles/defaults.js +0 -95
@@ -0,0 +1,3 @@
1
+ export { findApActivityByUri, recordApActivity } from './activities.js';
2
+ export { actorUri, backfillLocalFederationIdentities, generateActorKeyPair, localActorScalars, localObjectScalars, objectUri, } from './identity.js';
3
+ export { findProfileByHandleAndDomain, findProfileByUri } from './profiles.js';
@@ -0,0 +1,3 @@
1
+ import type { ProfileWithMeta } from '@openpeepshq/common/types';
2
+ export declare const findProfileByUri: (uri: string) => Promise<ProfileWithMeta | undefined>;
3
+ export declare const findProfileByHandleAndDomain: (handle: string, domain: string) => Promise<ProfileWithMeta | undefined>;
@@ -0,0 +1,14 @@
1
+ import { allpeepDb } from '../db/index.js';
2
+ import { profilesMapping } from '../profiles/mapping.js';
3
+ export const findProfileByUri = async (uri) => {
4
+ const { db } = await allpeepDb();
5
+ return profilesMapping.findOneBy(db, {
6
+ matches: { uri },
7
+ });
8
+ };
9
+ export const findProfileByHandleAndDomain = async (handle, domain) => {
10
+ const { db } = await allpeepDb();
11
+ return profilesMapping.findOneBy(db, {
12
+ matches: { handle, activityPub: { domain } },
13
+ });
14
+ };
@@ -107,10 +107,11 @@ export declare const listAdminGroups: () => Promise<{
107
107
  guestData?: {
108
108
  email?: string | undefined;
109
109
  resource?: {
110
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
110
+ type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
111
111
  id?: string | undefined;
112
112
  } | undefined;
113
113
  } | undefined;
114
+ pinnedPostId?: string | undefined;
114
115
  deletedAt?: string | null | undefined;
115
116
  }[];
116
117
  avatar?: string | null | undefined;
@@ -43,6 +43,10 @@ export declare const addMember: (db: import("../db").PgDb, from: {
43
43
  locked?: boolean | undefined;
44
44
  bot?: boolean | undefined;
45
45
  discoverable?: boolean | undefined;
46
+ roles?: {
47
+ key: string;
48
+ displayName: string;
49
+ }[] | undefined;
46
50
  fields?: {
47
51
  name: string;
48
52
  value: string;
@@ -51,6 +55,8 @@ export declare const addMember: (db: import("../db").PgDb, from: {
51
55
  followersCount: number;
52
56
  followingCount: number;
53
57
  } | undefined;
58
+ pinnedPostId?: string | undefined;
59
+ blockedByMe?: boolean | undefined;
54
60
  }, to: {
55
61
  handle: string;
56
62
  capabilities: Record<string, {
@@ -123,6 +129,10 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
123
129
  locked?: boolean | undefined;
124
130
  bot?: boolean | undefined;
125
131
  discoverable?: boolean | undefined;
132
+ roles?: {
133
+ key: string;
134
+ displayName: string;
135
+ }[] | undefined;
126
136
  fields?: {
127
137
  name: string;
128
138
  value: string;
@@ -131,6 +141,8 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
131
141
  followersCount: number;
132
142
  followingCount: number;
133
143
  } | undefined;
144
+ pinnedPostId?: string | undefined;
145
+ blockedByMe?: boolean | undefined;
134
146
  }, to: {
135
147
  handle: string;
136
148
  capabilities: Record<string, {
@@ -194,6 +206,10 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
194
206
  locked?: boolean | undefined;
195
207
  bot?: boolean | undefined;
196
208
  discoverable?: boolean | undefined;
209
+ roles?: {
210
+ key: string;
211
+ displayName: string;
212
+ }[] | undefined;
197
213
  fields?: {
198
214
  name: string;
199
215
  value: string;
@@ -202,6 +218,8 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
202
218
  followersCount: number;
203
219
  followingCount: number;
204
220
  } | undefined;
221
+ pinnedPostId?: string | undefined;
222
+ blockedByMe?: boolean | undefined;
205
223
  }, to: {
206
224
  handle: string;
207
225
  capabilities: Record<string, {
@@ -109,10 +109,11 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
109
109
  guestData?: {
110
110
  email?: string | undefined;
111
111
  resource?: {
112
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
112
+ type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
113
113
  id?: string | undefined;
114
114
  } | undefined;
115
115
  } | undefined;
116
+ pinnedPostId?: string | undefined;
116
117
  deletedAt?: string | null | undefined;
117
118
  }[];
118
119
  avatar?: string | null | undefined;
@@ -170,10 +171,11 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
170
171
  guestData?: {
171
172
  email?: string | undefined;
172
173
  resource?: {
173
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "jams" | "*" | "webhooks" | "analytics" | "render";
174
+ type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
174
175
  id?: string | undefined;
175
176
  } | undefined;
176
177
  } | undefined;
178
+ pinnedPostId?: string | undefined;
177
179
  deletedAt?: string | null | undefined;
178
180
  }[];
179
181
  avatar?: string | null | undefined;
@@ -1,3 +1,6 @@
1
- export declare const findHashtag: (id: string) => Promise<import("@openpeepshq/common").Hashtag | undefined>;
2
- export declare const findHashtagByTag: (tag: string) => Promise<import("@openpeepshq/common").Hashtag | undefined>;
3
- export declare const findOrCreateHashtag: (tag: string) => Promise<import("@openpeepshq/common").Hashtag>;
1
+ import type { Hashtag, ProfileWithMeta } from '@openpeepshq/common/types';
2
+ export declare const findHashtag: (id: string) => Promise<Hashtag | undefined>;
3
+ export declare const findHashtagByTag: (tag: string) => Promise<Hashtag | undefined>;
4
+ export declare const findOrCreateHashtag: (tag: string) => Promise<Hashtag>;
5
+ export declare const listFollowedHashtags: (profile: ProfileWithMeta) => Hashtag[];
6
+ export declare const isFollowingHashtag: (profile: ProfileWithMeta, hashtag: Pick<Hashtag, "id">) => boolean;
@@ -20,3 +20,5 @@ export const findOrCreateHashtag = async (tag) => {
20
20
  }
21
21
  return hashtagsMapping.create(db, { tag: normalizedTag });
22
22
  };
23
+ export const listFollowedHashtags = (profile) => { var _a; return (_a = profile.followedHashtags) !== null && _a !== void 0 ? _a : []; };
24
+ export const isFollowingHashtag = (profile, hashtag) => { var _a, _b; return (_b = (_a = profile.followedHashtags) === null || _a === void 0 ? void 0 : _a.some((h) => h.id === hashtag.id)) !== null && _b !== void 0 ? _b : false; };
@@ -0,0 +1,8 @@
1
+ import type { Hashtag, Profile } from '@openpeepshq/common/types';
2
+ export declare const profileHashtagConnector: (db: import("../db").PgDb, from: Profile, to: Hashtag, data?: object & {
3
+ id?: string;
4
+ }) => Promise<import("../db/pg/map").WithId<object & {
5
+ _from: string;
6
+ _to: string;
7
+ }>>;
8
+ export declare const profileHashtagDisconnector: (db: import("../db").PgDb, from: Profile, to: Hashtag) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { connector, disconnector } from '../db/helpers.js';
2
+ import { collectionInfos } from '../db/index.js';
3
+ export const profileHashtagConnector = connector(collectionInfos.profilesCollection, collectionInfos.hashtagsCollection, collectionInfos.profileHashtagsCollection);
4
+ export const profileHashtagDisconnector = disconnector(collectionInfos.profilesCollection, collectionInfos.hashtagsCollection, collectionInfos.profileHashtagsCollection);
@@ -1,2 +1,4 @@
1
1
  export * from './finders';
2
2
  export * from './mapping';
3
+ export * from './mutations';
4
+ export * from './helpers';
@@ -1,2 +1,4 @@
1
1
  export * from './finders.js';
2
2
  export * from './mapping.js';
3
+ export * from './mutations.js';
4
+ export * from './helpers.js';
@@ -0,0 +1,3 @@
1
+ import type { Hashtag, Profile } from '@openpeepshq/common/types';
2
+ export declare const followHashtag: (profile: Profile, hashtag: Hashtag) => Promise<void>;
3
+ export declare const unfollowHashtag: (profile: Profile, hashtag: Hashtag) => Promise<void>;
@@ -1 +1,13 @@
1
- "use strict";
1
+ import { allpeepDb } from '../db/index.js';
2
+ import { clearProfileCache } from '../profiles/cache.js';
3
+ import { profileHashtagConnector, profileHashtagDisconnector } from './helpers.js';
4
+ export const followHashtag = async (profile, hashtag) => {
5
+ const { db } = await allpeepDb();
6
+ await profileHashtagConnector(db, profile, hashtag);
7
+ await clearProfileCache(profile);
8
+ };
9
+ export const unfollowHashtag = async (profile, hashtag) => {
10
+ const { db } = await allpeepDb();
11
+ await profileHashtagDisconnector(db, profile, hashtag);
12
+ await clearProfileCache(profile);
13
+ };
@@ -1,5 +1,6 @@
1
1
  import type { Resource, ResourceLanguage } from 'i18next';
2
2
  import type { i18n } from 'i18next';
3
+ export { clearPluginLocales, mergeHostAndPluginLocales, registerPluginLocales, } from './pluginLocales';
3
4
  interface I18nContext {
4
5
  i18n: i18n;
5
6
  t: i18n['t'];
@@ -11,4 +12,3 @@ export declare const i18nWithPlugins: () => Promise<Resource>;
11
12
  export declare const i18nComplete: () => Promise<Resource>;
12
13
  export declare const updateI18nOverrides: (resources: Resource) => Promise<void>;
13
14
  export declare const initI18nEmailContext: (lng?: string) => Promise<I18nContext>;
14
- export {};
@@ -6,12 +6,14 @@ import { nowIso } from '../db/pg/mappers.js';
6
6
  import { uuidv7 } from 'uuidv7';
7
7
  import i18next from 'i18next';
8
8
  import Backend from 'i18next-fs-backend';
9
+ import { mergeHostAndPluginLocales, registeredPluginLocales, } from './pluginLocales.js';
10
+ export { clearPluginLocales, mergeHostAndPluginLocales, registerPluginLocales, } from './pluginLocales.js';
9
11
  const I18N_NAMESPACE = 'translation';
10
12
  export const i18nOverrides = () => allpeepDb().then(async ({ db }) => {
11
13
  const rows = await db.select().from(i18nEntries);
12
14
  return Object.fromEntries(rows.map((row) => [row.locale, row.body]));
13
15
  });
14
- export const i18nWithPlugins = async () => i18nextResources;
16
+ export const i18nWithPlugins = async () => mergeHostAndPluginLocales(i18nextResources, registeredPluginLocales());
15
17
  export const i18nComplete = async () => deepmerge(await i18nWithPlugins(), await i18nOverrides());
16
18
  export const updateI18nOverrides = async (resources) => allpeepDb().then(async ({ db }) => {
17
19
  const ts = nowIso();
@@ -0,0 +1,6 @@
1
+ import type { Resource } from 'i18next';
2
+ export declare const registerPluginLocales: (pluginKey: string, locales: Resource) => void;
3
+ export declare const clearPluginLocales: () => void;
4
+ export declare const registeredPluginLocales: () => Resource[];
5
+ /** Plugin packs first, host last so plugins cannot overwrite host strings. */
6
+ export declare const mergeHostAndPluginLocales: (host: Resource, pluginLocales: readonly Resource[]) => Resource;
@@ -0,0 +1,15 @@
1
+ import { deepmerge } from 'deepmerge-ts';
2
+ const pluginLocaleRegistry = new Map();
3
+ export const registerPluginLocales = (pluginKey, locales) => {
4
+ pluginLocaleRegistry.set(pluginKey, locales);
5
+ };
6
+ export const clearPluginLocales = () => {
7
+ pluginLocaleRegistry.clear();
8
+ };
9
+ export const registeredPluginLocales = () => [
10
+ ...pluginLocaleRegistry.values(),
11
+ ];
12
+ /** Plugin packs first, host last so plugins cannot overwrite host strings. */
13
+ export const mergeHostAndPluginLocales = (host, pluginLocales) => pluginLocales.length === 0
14
+ ? host
15
+ : deepmerge(...pluginLocales, host);
@@ -0,0 +1,19 @@
1
+ import type { Profile } from '@openpeepshq/common/types';
2
+ export type JamAttendanceKind = 'community' | 'public';
3
+ export type JamAttendanceExportRow = {
4
+ kind: JamAttendanceKind | '';
5
+ name: string;
6
+ email: string;
7
+ handle: string;
8
+ joinedAt: string;
9
+ };
10
+ type JoinRecord = {
11
+ profileId: string;
12
+ createdAt: string;
13
+ };
14
+ type AttendanceProfile = Pick<Profile, 'type' | 'displayName' | 'handle' | 'guestData'>;
15
+ export declare const jamAttendanceExportHeaders: readonly ["Type", "Name", "Email", "Handle", "Joined At"];
16
+ export declare const jamAttendanceRowFromJoin: (join: JoinRecord, profile: AttendanceProfile | undefined) => JamAttendanceExportRow;
17
+ export declare const jamAttendanceExportCsv: (rows: JamAttendanceExportRow[]) => string;
18
+ export declare const exportJamAttendanceCsv: (jamId: string) => Promise<string>;
19
+ export {};
@@ -0,0 +1,60 @@
1
+ import { and, asc, eq, isNull, sql } from 'drizzle-orm';
2
+ import { toCsvRow } from '@openpeepshq/common/lib';
3
+ import { database } from '../db/index.js';
4
+ import { jamEvents } from '../db/pg/schema/index.js';
5
+ import { normalizeIsoDatetime } from '../db/pg/mappers.js';
6
+ import { getProfiles } from '../profiles/index.js';
7
+ export const jamAttendanceExportHeaders = [
8
+ 'Type',
9
+ 'Name',
10
+ 'Email',
11
+ 'Handle',
12
+ 'Joined At',
13
+ ];
14
+ export const jamAttendanceRowFromJoin = (join, profile) => {
15
+ var _a, _b, _c, _d;
16
+ const isPublic = (profile === null || profile === void 0 ? void 0 : profile.type) === 'guest';
17
+ return {
18
+ kind: profile ? (isPublic ? 'public' : 'community') : '',
19
+ name: (profile === null || profile === void 0 ? void 0 : profile.displayName) || (isPublic ? '' : ((_a = profile === null || profile === void 0 ? void 0 : profile.handle) !== null && _a !== void 0 ? _a : '')),
20
+ // Community emails aren't here: several accounts can control one profile.
21
+ email: isPublic ? ((_c = (_b = profile === null || profile === void 0 ? void 0 : profile.guestData) === null || _b === void 0 ? void 0 : _b.email) !== null && _c !== void 0 ? _c : '') : '',
22
+ handle: isPublic ? '' : ((_d = profile === null || profile === void 0 ? void 0 : profile.handle) !== null && _d !== void 0 ? _d : ''),
23
+ joinedAt: join.createdAt,
24
+ };
25
+ };
26
+ export const jamAttendanceExportCsv = (rows) => [
27
+ toCsvRow([...jamAttendanceExportHeaders]),
28
+ ...rows.map((row) => toCsvRow([row.kind, row.name, row.email, row.handle, row.joinedAt])),
29
+ ].join('\n');
30
+ const listJamJoinEvents = async (jamId) => {
31
+ const db = await database();
32
+ const rows = await db
33
+ .select({
34
+ createdAt: jamEvents.createdAt,
35
+ body: jamEvents.body,
36
+ })
37
+ .from(jamEvents)
38
+ .where(and(eq(jamEvents.postId, jamId), isNull(jamEvents.deletedAt), sql `${jamEvents.body}->>'type' = 'join'`))
39
+ .orderBy(asc(jamEvents.createdAt), asc(jamEvents.id));
40
+ return rows.flatMap((row) => {
41
+ var _a;
42
+ const profileId = (_a = row.body) === null || _a === void 0 ? void 0 : _a.profileId;
43
+ if (typeof profileId !== 'string' || !profileId) {
44
+ return [];
45
+ }
46
+ return [
47
+ {
48
+ profileId,
49
+ createdAt: normalizeIsoDatetime(row.createdAt),
50
+ },
51
+ ];
52
+ });
53
+ };
54
+ export const exportJamAttendanceCsv = async (jamId) => {
55
+ const joins = await listJamJoinEvents(jamId);
56
+ const profileIds = [...new Set(joins.map((join) => join.profileId))];
57
+ const profiles = profileIds.length ? await getProfiles(profileIds) : [];
58
+ const profilesById = new Map(profiles.map((profile) => [profile.id, profile]));
59
+ return jamAttendanceExportCsv(joins.map((join) => jamAttendanceRowFromJoin(join, profilesById.get(join.profileId))));
60
+ };
@@ -0,0 +1,8 @@
1
+ export declare const LIVEKIT_HEALTH_TIMEOUT_MS = 1500;
2
+ /**
3
+ * True when a LiveKit RoomService call succeeds. Credentials in config are not
4
+ * enough — invalid keys still construct a client, then fail on first RPC.
5
+ */
6
+ export declare const probeLivekitConnection: (listRooms: () => Promise<unknown>, timeoutMs?: number) => Promise<boolean>;
7
+ /** Cached LiveKit reachability. False when unset, unauthorized, or unreachable. */
8
+ export declare const isLivekitConnected: () => Promise<boolean>;
@@ -0,0 +1,46 @@
1
+ import { createCache } from 'cache-manager';
2
+ import { logger } from '../log/index.js';
3
+ import { roomService } from './livekit.js';
4
+ const log = logger('app:jams:livekit');
5
+ /** Sentinel room name so the probe authenticates without listing every room. */
6
+ const LIVEKIT_HEALTH_ROOM = '__openpeeps_livekit_health__';
7
+ const LIVEKIT_HEALTH_CACHE_KEY = 'livekit-health';
8
+ export const LIVEKIT_HEALTH_TIMEOUT_MS = 1500;
9
+ const livekitHealthCache = createCache({
10
+ ttl: 20 * 1000,
11
+ refreshThreshold: 5 * 1000,
12
+ });
13
+ const withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
14
+ const timer = setTimeout(() => {
15
+ reject(new Error('LiveKit health check timed out'));
16
+ }, timeoutMs);
17
+ promise.then((value) => {
18
+ clearTimeout(timer);
19
+ resolve(value);
20
+ }, (err) => {
21
+ clearTimeout(timer);
22
+ reject(err);
23
+ });
24
+ });
25
+ /**
26
+ * True when a LiveKit RoomService call succeeds. Credentials in config are not
27
+ * enough — invalid keys still construct a client, then fail on first RPC.
28
+ */
29
+ export const probeLivekitConnection = async (listRooms, timeoutMs = LIVEKIT_HEALTH_TIMEOUT_MS) => {
30
+ try {
31
+ await withTimeout(listRooms(), timeoutMs);
32
+ return true;
33
+ }
34
+ catch (e) {
35
+ log.warn(`LiveKit health check failed: ${e.message}`);
36
+ return false;
37
+ }
38
+ };
39
+ /** Cached LiveKit reachability. False when unset, unauthorized, or unreachable. */
40
+ export const isLivekitConnected = () => livekitHealthCache.wrap(LIVEKIT_HEALTH_CACHE_KEY, async () => {
41
+ const rs = await roomService();
42
+ if (rs === undefined) {
43
+ return false;
44
+ }
45
+ return probeLivekitConnection(() => rs.listRooms([LIVEKIT_HEALTH_ROOM]));
46
+ });
@@ -1,6 +1,6 @@
1
1
  import { JamRecording, JamRecordingWithMeta, PostWithMeta, ProfileWithMeta } from '@openpeepshq/common/types';
2
2
  export declare const connectRecording: (db: import("../db").PgDb, from: ProfileWithMeta, to: PostWithMeta, data?: {
3
- status: "completed" | "failed" | "active" | "requested";
3
+ status: "completed" | "failed" | "active" | "requested" | "finalizing";
4
4
  kind?: "file" | "rtmp" | undefined;
5
5
  destinationHost?: string | undefined;
6
6
  egressId?: string | undefined;
@@ -32,7 +32,7 @@ export declare const connectRecording: (db: import("../db").PgDb, from: ProfileW
32
32
  } & {
33
33
  id?: string;
34
34
  }) => Promise<import("../db/pg/map").WithId<{
35
- status: "completed" | "failed" | "active" | "requested";
35
+ status: "completed" | "failed" | "active" | "requested" | "finalizing";
36
36
  kind?: "file" | "rtmp" | undefined;
37
37
  destinationHost?: string | undefined;
38
38
  egressId?: string | undefined;
@@ -1,11 +1,13 @@
1
1
  import { type AuthorizationData, type MuteParticipantRequest, type PostWithMeta, type Profile } from '@openpeepshq/common/types';
2
2
  export { createJamToken, createJamEgressToken } from './token';
3
+ export { isLivekitConnected } from './health';
3
4
  export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit';
4
5
  export { rtmpStreamOutput } from './rtmp';
5
6
  export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs';
6
7
  export * from './waitingRoom';
7
8
  export * from './mutations';
8
9
  export * from './finders';
10
+ export * from './export';
9
11
  export * from './recording';
10
12
  export { deriveJamRecordingUploadSecret, jamRecordingUploadSecret, } from './recordingUploadAuth';
11
13
  export declare const listLiveJams: (authData: AuthorizationData) => Promise<PostWithMeta[]>;
@@ -1,5 +1,5 @@
1
1
  import { jamRoomName, postIdFromJamRoomName, uniquePostsById, } from '@openpeepshq/common/lib';
2
- import { listParticipantIds, reclaimOrphanJamRoom, roomService, stopRecording, stopRtmpStream, } from './livekit.js';
2
+ import { listParticipantIds, reclaimOrphanJamRoom, roomService, shouldReclaimJamRoom, stopRecording, stopRtmpStream, } from './livekit.js';
3
3
  import { jamStateCache, LIVE_JAMS_CACHE_KEY, liveJamPostsCache } from './cache.js';
4
4
  import { localInstanceDomain, parseRoomInstanceDomain } from './helpers.js';
5
5
  import { findPost } from '../posts/index.js';
@@ -8,15 +8,19 @@ import { clearJamAdmittance } from './waitingRoom.js';
8
8
  import { uuidv7 } from 'uuidv7';
9
9
  import { canReadPost } from '../posts/helpers/index.js';
10
10
  import { capabilitiesConfig } from '../config/index.js';
11
+ import { logger } from '../log/index.js';
11
12
  export { createJamToken, createJamEgressToken } from './token.js';
13
+ export { isLivekitConnected } from './health.js';
12
14
  export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit.js';
13
15
  export { rtmpStreamOutput } from './rtmp.js';
14
16
  export { jamRecordingStopQueue, jamRecordingStopWorker, scheduleRecordingAutoStop, cancelRecordingAutoStop, JAM_RECORDING_MAX_DURATION_MS, } from './jobs.js';
15
17
  export * from './waitingRoom.js';
16
18
  export * from './mutations.js';
17
19
  export * from './finders.js';
20
+ export * from './export.js';
18
21
  export * from './recording.js';
19
22
  export { deriveJamRecordingUploadSecret, jamRecordingUploadSecret, } from './recordingUploadAuth.js';
23
+ const log = logger('app:jams:livekit');
20
24
  const invalidateJamCaches = async (jamId) => {
21
25
  await Promise.all([
22
26
  jamStateCache.del(jamId).catch(() => undefined),
@@ -35,10 +39,18 @@ const fetchLiveJamPosts = async () => {
35
39
  if (rs === undefined) {
36
40
  return [];
37
41
  }
38
- const [rooms, localDomain] = await Promise.all([
39
- rs.listRooms(),
40
- localInstanceDomain(),
41
- ]);
42
+ let rooms;
43
+ let localDomain;
44
+ try {
45
+ [rooms, localDomain] = await Promise.all([
46
+ rs.listRooms(),
47
+ localInstanceDomain(),
48
+ ]);
49
+ }
50
+ catch (e) {
51
+ log.warn(`Failed to list live jam rooms: ${e.message}`);
52
+ return [];
53
+ }
42
54
  const posts = await Promise.all(rooms.map(async (room) => {
43
55
  const roomDomain = parseRoomInstanceDomain(room.metadata);
44
56
  // Shared SFU: ignore other communities' rooms. Untagged rooms (pre-stamp)
@@ -47,21 +59,16 @@ const fetchLiveJamPosts = async () => {
47
59
  return undefined;
48
60
  }
49
61
  const postId = postIdFromJamRoomName(room.name);
50
- // Fast path: Room.numParticipants includes hidden egress — 0 means truly empty.
62
+ // Zero participants: host may still be connecting after Start, or the
63
+ // room is inside departureTimeout. LiveKit closes these; deleting them
64
+ // drops the host back to the join screen.
51
65
  if (!room.numParticipants) {
52
- const post = await findPost(postId);
53
- if (post) {
54
- reclaimLocalOrphan(post);
55
- }
56
- else if (!roomDomain || roomDomain === localDomain) {
57
- void rs.deleteRoom(room.name).catch(() => undefined);
58
- }
59
66
  return undefined;
60
67
  }
61
- // Slow path only when someone (human or egress) is connected — distinguish
62
- // egress-only ghosts from real live jams.
68
+ // Someone is connected. Egress counts toward numParticipants, so an
69
+ // egress-only room never hits emptyTimeout and has to be reclaimed.
63
70
  const humans = await listParticipantIds(room.name);
64
- if (humans.length === 0) {
71
+ if (shouldReclaimJamRoom(room.numParticipants, humans.length)) {
65
72
  const post = await findPost(postId);
66
73
  if (post) {
67
74
  reclaimLocalOrphan(post);
package/dist/jams/jobs.js CHANGED
@@ -3,7 +3,7 @@ import { logger } from '../log/index.js';
3
3
  import { findPost } from '../posts/index.js';
4
4
  import { findActiveRecording } from './finders.js';
5
5
  const log = logger('app:jams:jobs');
6
- export const JAM_RECORDING_MAX_DURATION_MS = 60 * 60 * 1000;
6
+ export const JAM_RECORDING_MAX_DURATION_MS = 2 * 60 * 60 * 1000;
7
7
  const recordingStopJobId = (recordingId) => `jam-recording-stop:${recordingId}`;
8
8
  const [jamRecordingStopQueue, jamRecordingStopWorker] = queueAndWorker('jam-recording-stop', async (job) => {
9
9
  var _a;
@@ -4,6 +4,14 @@ import { RoomServiceClient } from 'livekit-server-sdk';
4
4
  export declare const JAM_ROOM_EMPTY_TIMEOUT_SEC: number;
5
5
  /** Seconds a room stays open after the last participant leaves. */
6
6
  export declare const JAM_ROOM_DEPARTURE_TIMEOUT_SEC = 60;
7
+ /**
8
+ * LiveKit closes rooms with no participants via emptyTimeout (host still
9
+ * connecting after Start) and departureTimeout (reconnect). Those rooms must
10
+ * not be deleted here. Reclaim only when a non-human participant (egress) is
11
+ * holding the room open — they count toward `numParticipants`, so LiveKit
12
+ * will not time the room out.
13
+ */
14
+ export declare const shouldReclaimJamRoom: (numParticipants: number, humanCount: number) => boolean;
7
15
  export declare const roomService: () => Promise<RoomServiceClient | undefined>;
8
16
  export declare const listParticipantIds: (jamId: string) => Promise<string[]>;
9
17
  /**
@@ -12,6 +20,7 @@ export declare const listParticipantIds: (jamId: string) => Promise<string[]>;
12
20
  */
13
21
  export declare const getJamObserverPath: (jamId: string, recurrenceId?: string) => Promise<string>;
14
22
  export declare const getJamRecordingUrl: (jamId: string, recurrenceId?: string) => Promise<string>;
23
+ export declare const stopEgress: (egressId: string) => Promise<void>;
15
24
  export declare const startRecording: (profile: ProfileWithMeta, jamPost: PostWithMeta, recurrenceId?: string) => Promise<JamRecording>;
16
25
  export declare const startRtmpStream: (profile: ProfileWithMeta, jamPost: PostWithMeta, rtmpUrl: string, destinationHost?: string) => Promise<JamRecording>;
17
26
  export declare const stopRtmpStream: (jamPost: PostWithMeta) => Promise<{
@@ -51,11 +60,47 @@ export declare const stopRtmpStream: (jamPost: PostWithMeta) => Promise<{
51
60
  profile: ProfileWithMeta;
52
61
  post: PostWithMeta;
53
62
  } | undefined>;
54
- export declare const stopEgress: (egressId: string) => Promise<void>;
55
- export declare const stopRecording: (jamPost: PostWithMeta, recurrenceId?: string) => Promise<JamRecordingWithMeta | undefined>;
63
+ export declare const stopRecording: (jamPost: PostWithMeta, recurrenceId?: string) => Promise<{
64
+ status: "finalizing";
65
+ createdAt: string;
66
+ updatedAt: string;
67
+ deletedAt?: string | null | undefined;
68
+ kind?: "file" | "rtmp" | undefined;
69
+ destinationHost?: string | undefined;
70
+ egressId?: string | undefined;
71
+ attachment?: {
72
+ type: string;
73
+ url: string;
74
+ previewUrl: string | null;
75
+ textUrl: null;
76
+ filename: string;
77
+ meta: {
78
+ usage?: string | undefined;
79
+ focus?: {
80
+ x: number;
81
+ y: number;
82
+ } | undefined;
83
+ mimetype?: string | undefined;
84
+ size?: number | undefined;
85
+ };
86
+ id: string;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ description?: string | undefined;
90
+ blurhash?: string | undefined;
91
+ status?: "failed" | "processing" | "ready" | undefined;
92
+ error?: string | undefined;
93
+ deletedAt?: string | null | undefined;
94
+ } | undefined;
95
+ replyPostId?: string | undefined;
96
+ id: string;
97
+ profile: ProfileWithMeta;
98
+ post: PostWithMeta;
99
+ } | undefined>;
56
100
  /**
57
- * Stops leftover egress and deletes a LiveKit room that has no human
58
- * participants (egress-only / orphan rooms). Safe to call repeatedly.
101
+ * Stops leftover egress and deletes an egress-only LiveKit room.
102
+ * Do not call this for a room with zero participants — that room is still
103
+ * inside emptyTimeout or departureTimeout. Safe to call repeatedly.
59
104
  */
60
105
  export declare const reclaimOrphanJamRoom: (jam: PostWithMeta, roomName?: string) => Promise<void>;
61
106
  export declare const finishRecording: (jamRecording: JamRecordingWithMeta) => Promise<void>;