@openpeepshq/core 0.1.34 → 0.2.0

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 (192) hide show
  1. package/dist/accessTokens/finders.js +5 -6
  2. package/dist/accessTokens/mutations.js +1 -1
  3. package/dist/accessTokens/tokens.js +8 -11
  4. package/dist/accounts/helpers.js +6 -2
  5. package/dist/accounts/mutations.js +13 -8
  6. package/dist/analytics/cache.js +3 -3
  7. package/dist/analytics/clicks.js +14 -22
  8. package/dist/analytics/compile.js +1 -2
  9. package/dist/analytics/dateRange.js +3 -5
  10. package/dist/analytics/jobs.js +3 -4
  11. package/dist/analytics/pdfReport.js +45 -61
  12. package/dist/analytics/privacy.js +1 -1
  13. package/dist/analytics/read.js +116 -135
  14. package/dist/analytics/report.d.ts +2 -1
  15. package/dist/analytics/report.js +2 -3
  16. package/dist/analytics/settings.js +3 -4
  17. package/dist/backups/index.js +13 -16
  18. package/dist/backups/metadata.js +1 -1
  19. package/dist/config/db.js +2 -4
  20. package/dist/config/defaults/community.js +1 -0
  21. package/dist/config/defaults/core.js +13 -8
  22. package/dist/config/defaults/logs.d.ts +4 -0
  23. package/dist/config/defaults/logs.js +5 -0
  24. package/dist/config/index.d.ts +9 -0
  25. package/dist/config/index.js +9 -11
  26. package/dist/db/explorer/query.js +9 -8
  27. package/dist/db/explorer/sql.js +8 -8
  28. package/dist/db/helpers.js +15 -5
  29. package/dist/db/migration/importCollections.js +15 -18
  30. package/dist/db/migration/shared.js +15 -35
  31. package/dist/db/pg/client.js +4 -7
  32. package/dist/db/pg/filters/index.js +1 -1
  33. package/dist/db/pg/filters/posts.d.ts +2 -0
  34. package/dist/db/pg/filters/posts.js +3 -1
  35. package/dist/db/pg/helpers.js +2 -14
  36. package/dist/db/pg/map/filters.js +8 -8
  37. package/dist/db/pg/map/helpers.js +5 -1
  38. package/dist/db/pg/map/index.js +46 -51
  39. package/dist/db/pg/map/mutations.js +56 -21
  40. package/dist/db/pg/map/registry.js +87 -50
  41. package/dist/db/pg/map/relations.js +67 -63
  42. package/dist/db/pg/map/search.js +15 -37
  43. package/dist/db/pg/mappers.js +13 -7
  44. package/dist/db/pg/migrate.js +2 -3
  45. package/dist/db/pg/queries/activity.js +2 -2
  46. package/dist/db/pg/queries/derived.js +8 -12
  47. package/dist/db/pg/schema/documents.js +119 -18
  48. package/dist/db/pg/schema/edges.js +7 -1
  49. package/dist/db/pg/schema/index.js +5 -1
  50. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  51. package/dist/db/pg/sql/meta/_journal.json +8 -1
  52. package/dist/db/replaceOrigin.js +1 -1
  53. package/dist/email/queueStats.js +8 -11
  54. package/dist/email/render.js +7 -4
  55. package/dist/email/send.js +19 -17
  56. package/dist/email/smtpTest.js +10 -6
  57. package/dist/errors/index.js +1 -1
  58. package/dist/events/once.js +2 -4
  59. package/dist/federation/activities.js +1 -2
  60. package/dist/groups/finders.d.ts +2 -2
  61. package/dist/groups/helpers.d.ts +6 -6
  62. package/dist/groups/helpers.js +1 -2
  63. package/dist/groups/mapping.d.ts +4 -4
  64. package/dist/groups/mutations.js +1 -1
  65. package/dist/hashtags/finders.js +2 -2
  66. package/dist/inviteLinks/mutations.js +2 -3
  67. package/dist/jams/export.js +5 -7
  68. package/dist/jams/finders.js +4 -1
  69. package/dist/jams/health.d.ts +6 -4
  70. package/dist/jams/health.js +15 -11
  71. package/dist/jams/helpers.d.ts +2 -2
  72. package/dist/jams/helpers.js +6 -2
  73. package/dist/jams/index.js +2 -2
  74. package/dist/jams/jobs.js +1 -2
  75. package/dist/jams/livekit.d.ts +2 -2
  76. package/dist/jams/livekit.js +8 -8
  77. package/dist/jams/mapping.d.ts +10 -10
  78. package/dist/jams/mutations.d.ts +2 -2
  79. package/dist/jams/recording.js +1 -1
  80. package/dist/jams/token.js +13 -17
  81. package/dist/jobs/index.js +7 -6
  82. package/dist/jobs/jobDetail.js +5 -6
  83. package/dist/jobs/jobLog.js +2 -3
  84. package/dist/lib/streams.js +4 -39
  85. package/dist/lib/zodDeepPartial.d.ts +1 -1
  86. package/dist/lib/zodDeepPartial.js +1 -1
  87. package/dist/log/index.d.ts +1 -0
  88. package/dist/log/index.js +14 -29
  89. package/dist/log/retention.d.ts +9 -0
  90. package/dist/log/retention.js +83 -0
  91. package/dist/log/retentionJobs.d.ts +17 -0
  92. package/dist/log/retentionJobs.js +50 -0
  93. package/dist/media/index.js +127 -4
  94. package/dist/media/jobs.js +1 -2
  95. package/dist/media/openpeeps/index.js +11 -46
  96. package/dist/media/processing.js +7 -4
  97. package/dist/media/streaming.js +5 -5
  98. package/dist/media/streamingCleanupJobs.js +1 -2
  99. package/dist/media/streamingJobs.js +3 -4
  100. package/dist/media/streamingPrewarm.js +7 -11
  101. package/dist/mediaAttachments/index.js +6 -2
  102. package/dist/mediaAttachments/mapping.d.ts +1 -1
  103. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  104. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  105. package/dist/notifications/defaultNotifications/follow/index.js +14 -17
  106. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  107. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  108. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  109. package/dist/notifications/defaultNotifications/jamModerator/index.js +27 -20
  110. package/dist/notifications/defaultNotifications/jamModerator/recipients.d.ts +2 -0
  111. package/dist/notifications/defaultNotifications/jamModerator/recipients.js +5 -0
  112. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  113. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  114. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  115. package/dist/notifications/defaultNotifications/newGroupPost/index.js +9 -10
  116. package/dist/notifications/defaultNotifications/newGroupPost/recipients.d.ts +5 -0
  117. package/dist/notifications/defaultNotifications/newGroupPost/recipients.js +23 -0
  118. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  119. package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
  120. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
  121. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  122. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  123. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  124. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  125. package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
  126. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
  127. package/dist/notifications/eventIcsAttachment.d.ts +6 -0
  128. package/dist/notifications/eventIcsAttachment.js +32 -0
  129. package/dist/notifications/fcmCredential.js +1 -1
  130. package/dist/notifications/finders.js +1 -1
  131. package/dist/notifications/helpers.d.ts +11 -1
  132. package/dist/notifications/helpers.js +38 -9
  133. package/dist/notifications/jobs.js +16 -7
  134. package/dist/notifications/mutations.js +13 -2
  135. package/dist/notifications/push.js +11 -16
  136. package/dist/performance/index.js +3 -3
  137. package/dist/plugins/helpers.js +3 -6
  138. package/dist/plugins/index.js +2 -3
  139. package/dist/plugins/install.js +31 -17
  140. package/dist/plugins/pluginAuth.js +3 -4
  141. package/dist/plugins/state.js +2 -3
  142. package/dist/posts/activity.d.ts +1 -1
  143. package/dist/posts/activity.js +2 -3
  144. package/dist/posts/contextClosure.js +1 -2
  145. package/dist/posts/conversationQueries.js +2 -4
  146. package/dist/posts/eventAgenda.js +12 -7
  147. package/dist/posts/eventOccurrences.js +2 -2
  148. package/dist/posts/finders.d.ts +46 -6
  149. package/dist/posts/finders.js +21 -9
  150. package/dist/posts/helpers/filters.js +2 -3
  151. package/dist/posts/helpers/index.d.ts +170 -18
  152. package/dist/posts/helpers/index.js +43 -27
  153. package/dist/posts/mapping.d.ts +616 -84
  154. package/dist/posts/mapping.js +60 -18
  155. package/dist/posts/mutations.d.ts +85 -9
  156. package/dist/posts/mutations.js +47 -34
  157. package/dist/posts/pollEnd.js +3 -6
  158. package/dist/posts/rsvpConfirmationEmail.js +18 -8
  159. package/dist/posts/threadPreview.js +1 -1
  160. package/dist/processingStats/queries.js +6 -7
  161. package/dist/profileSettings/cache.js +1 -2
  162. package/dist/profileSettings/mapping.d.ts +1 -0
  163. package/dist/profiles/activitySummary.js +23 -28
  164. package/dist/profiles/cache.js +15 -8
  165. package/dist/profiles/export.js +30 -39
  166. package/dist/profiles/finders.js +7 -5
  167. package/dist/profiles/mapping.d.ts +10 -10
  168. package/dist/profiles/mutations.js +3 -5
  169. package/dist/redis/connection.js +1 -1
  170. package/dist/reports/helpers.js +7 -3
  171. package/dist/reports/mapping.d.ts +1 -1
  172. package/dist/roles/mutations.js +20 -21
  173. package/dist/search/finders.js +15 -3
  174. package/dist/search/helpers.js +1 -1
  175. package/dist/sentry/index.js +9 -11
  176. package/dist/seo/index.d.ts +50 -0
  177. package/dist/seo/index.js +145 -0
  178. package/dist/seo/route.d.ts +18 -0
  179. package/dist/seo/route.js +19 -0
  180. package/dist/server/index.d.ts +1 -0
  181. package/dist/server/index.js +16 -11
  182. package/dist/server/status.js +6 -7
  183. package/dist/session/index.js +2 -2
  184. package/dist/stats/finders.js +13 -4
  185. package/dist/stats/helpers.js +4 -1
  186. package/dist/stats/mapping.d.ts +43 -5
  187. package/dist/stats/mapping.js +9 -2
  188. package/dist/stripe/cache.js +5 -6
  189. package/dist/stripe/connection.js +3 -4
  190. package/dist/stripe/helpers.js +15 -20
  191. package/package.json +5 -6
  192. package/LICENSE +0 -674
@@ -8,7 +8,7 @@ import { listBlockedByIds } from './blocks.js';
8
8
  import { findProfile } from './finders.js';
9
9
  import { listReportsByReportedProfile } from '../reports/finders.js';
10
10
  import { profileActivityCountsSql, profileTopPostScoresSql, takeTopReadablePosts, } from './activityQueries.js';
11
- const sqlRows = (result) => { var _a; return (_a = result.rows) !== null && _a !== void 0 ? _a : []; };
11
+ const sqlRows = (result) => result.rows ?? [];
12
12
  const loadPostsByIds = async (db, ids, authData) => {
13
13
  if (ids.length === 0)
14
14
  return [];
@@ -24,46 +24,41 @@ const loadPostsByIds = async (db, ids, authData) => {
24
24
  .filter((post) => !!post);
25
25
  };
26
26
  export const getProfileActivitySummary = async (authData, profileId) => {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
28
27
  const { db } = await allpeepDb();
29
28
  const [countRow] = sqlRows(await db.execute(profileActivityCountsSql(profileId)));
30
29
  const scored = sqlRows(await db.execute(profileTopPostScoresSql(profileId)))
31
- .map((row) => {
32
- var _a, _b;
33
- return ({
34
- id: String((_a = row.id) !== null && _a !== void 0 ? _a : ''),
35
- activityScore: Number((_b = row.activity_score) !== null && _b !== void 0 ? _b : 0),
36
- });
37
- })
30
+ .map((row) => ({
31
+ id: String(row.id ?? ''),
32
+ activityScore: Number(row.activity_score ?? 0),
33
+ }))
38
34
  .filter((row) => row.id);
39
35
  const scoreById = new Map(scored.map((row) => [row.id, row.activityScore]));
40
36
  const loaded = await loadPostsByIds(db, scored.map((row) => row.id), authData);
41
37
  const config = await capabilitiesConfig();
42
38
  const readable = canReadPost(config, authData);
43
39
  const topPosts = takeTopReadablePosts(loaded, readable)
44
- .map((post) => {
45
- var _a;
46
- return publicPostWithActivityScoreSchema.safeParse(Object.assign(Object.assign({}, post), { activityScore: (_a = scoreById.get(post.id)) !== null && _a !== void 0 ? _a : 0 }));
47
- })
40
+ .map((post) => publicPostWithActivityScoreSchema.safeParse({
41
+ ...post,
42
+ activityScore: scoreById.get(post.id) ?? 0,
43
+ }))
48
44
  .filter((result) => result.success)
49
45
  .map((result) => result.data);
50
46
  return profileActivitySummarySchema.parse({
51
- postsCount: Number((_a = countRow === null || countRow === void 0 ? void 0 : countRow.posts_count) !== null && _a !== void 0 ? _a : 0),
52
- repliesCount: Number((_b = countRow === null || countRow === void 0 ? void 0 : countRow.replies_count) !== null && _b !== void 0 ? _b : 0),
53
- eventsCount: Number((_c = countRow === null || countRow === void 0 ? void 0 : countRow.events_count) !== null && _c !== void 0 ? _c : 0),
54
- reactionsGiven: Number((_d = countRow === null || countRow === void 0 ? void 0 : countRow.reactions_given) !== null && _d !== void 0 ? _d : 0),
55
- reactionsReceived: Number((_e = countRow === null || countRow === void 0 ? void 0 : countRow.reactions_received) !== null && _e !== void 0 ? _e : 0),
56
- repostsCount: Number((_f = countRow === null || countRow === void 0 ? void 0 : countRow.reposts_count) !== null && _f !== void 0 ? _f : 0),
57
- repostsReceived: Number((_g = countRow === null || countRow === void 0 ? void 0 : countRow.reposts_received) !== null && _g !== void 0 ? _g : 0),
58
- repliesReceived: Number((_h = countRow === null || countRow === void 0 ? void 0 : countRow.replies_received) !== null && _h !== void 0 ? _h : 0),
59
- rsvpsCount: Number((_j = countRow === null || countRow === void 0 ? void 0 : countRow.rsvps_count) !== null && _j !== void 0 ? _j : 0),
60
- bookmarksCount: Number((_k = countRow === null || countRow === void 0 ? void 0 : countRow.bookmarks_count) !== null && _k !== void 0 ? _k : 0),
61
- groupsCount: Number((_l = countRow === null || countRow === void 0 ? void 0 : countRow.groups_count) !== null && _l !== void 0 ? _l : 0),
47
+ postsCount: Number(countRow?.posts_count ?? 0),
48
+ repliesCount: Number(countRow?.replies_count ?? 0),
49
+ eventsCount: Number(countRow?.events_count ?? 0),
50
+ reactionsGiven: Number(countRow?.reactions_given ?? 0),
51
+ reactionsReceived: Number(countRow?.reactions_received ?? 0),
52
+ repostsCount: Number(countRow?.reposts_count ?? 0),
53
+ repostsReceived: Number(countRow?.reposts_received ?? 0),
54
+ repliesReceived: Number(countRow?.replies_received ?? 0),
55
+ rsvpsCount: Number(countRow?.rsvps_count ?? 0),
56
+ bookmarksCount: Number(countRow?.bookmarks_count ?? 0),
57
+ groupsCount: Number(countRow?.groups_count ?? 0),
62
58
  topPosts,
63
59
  });
64
60
  };
65
61
  export const getAdminProfileSummary = async (authData, profileId) => {
66
- var _a, _b, _c, _d, _e, _f;
67
62
  const profile = await findProfile(profileId);
68
63
  if (!profile) {
69
64
  throw new Error(`Profile with id ${profileId} not found`);
@@ -78,9 +73,9 @@ export const getAdminProfileSummary = async (authData, profileId) => {
78
73
  profile: publicProfileSchema.parse(profile),
79
74
  activity,
80
75
  createdAt: profile.createdAt,
81
- email: (_b = (_a = profile.controllers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.email,
82
- followersCount: (_d = (_c = profile.profileStats) === null || _c === void 0 ? void 0 : _c.followersCount) !== null && _d !== void 0 ? _d : 0,
83
- followingCount: (_f = (_e = profile.profileStats) === null || _e === void 0 ? void 0 : _e.followingCount) !== null && _f !== void 0 ? _f : 0,
76
+ email: profile.controllers?.[0]?.email,
77
+ followersCount: profile.profileStats?.followersCount ?? 0,
78
+ followingCount: profile.profileStats?.followingCount ?? 0,
84
79
  reportsCount: reports.length,
85
80
  blockedByCount: blockedByIds.length,
86
81
  });
@@ -18,19 +18,26 @@ export const clearProfileCache = async (profile) => {
18
18
  publicProfilesCache.del(`all:${profile.id}`),
19
19
  ]);
20
20
  };
21
- const withEmptyFollowGraphs = (profile) => {
22
- var _a, _b, _c, _d, _e, _f;
23
- return (Object.assign(Object.assign({}, profile), { roles: (_a = profile.roles) !== null && _a !== void 0 ? _a : [], followers: [], following: [], controllers: (_b = profile.controllers) !== null && _b !== void 0 ? _b : [], memberships: (_c = profile.memberships) !== null && _c !== void 0 ? _c : [], profileStats: (_d = profile.profileStats) !== null && _d !== void 0 ? _d : {
24
- followersCount: 0,
25
- followingCount: 0,
26
- }, blockingIds: (_e = profile.blockingIds) !== null && _e !== void 0 ? _e : [], blockedByIds: (_f = profile.blockedByIds) !== null && _f !== void 0 ? _f : [] }));
27
- };
21
+ const withEmptyFollowGraphs = (profile) => ({
22
+ ...profile,
23
+ roles: profile.roles ?? [],
24
+ followers: [],
25
+ following: [],
26
+ controllers: profile.controllers ?? [],
27
+ memberships: profile.memberships ?? [],
28
+ profileStats: profile.profileStats ?? {
29
+ followersCount: 0,
30
+ followingCount: 0,
31
+ },
32
+ blockingIds: profile.blockingIds ?? [],
33
+ blockedByIds: profile.blockedByIds ?? [],
34
+ });
28
35
  const withBlockIds = async (profile) => {
29
36
  if (!profile)
30
37
  return undefined;
31
38
  const { db } = await allpeepDb();
32
39
  const { blockingIds, blockedByIds } = await loadBlockIds(db, profile.id);
33
- return Object.assign(Object.assign({}, profile), { blockingIds, blockedByIds });
40
+ return { ...profile, blockingIds, blockedByIds };
34
41
  };
35
42
  export const getProfile = async (id, ignoreSoftDelete = false) => profilesCache.wrap(id, () => allpeepDb()
36
43
  .then(({ db }) => ignoreSoftDelete
@@ -9,14 +9,11 @@ const emptyStats = () => ({
9
9
  reactionsCount: 0,
10
10
  lastSeen: null,
11
11
  });
12
- const toMemberExportStats = (row) => {
13
- var _a, _b, _c;
14
- return ({
15
- postsCount: (_a = row === null || row === void 0 ? void 0 : row.postsCount) !== null && _a !== void 0 ? _a : 0,
16
- reactionsCount: (_b = row === null || row === void 0 ? void 0 : row.reactionsCount) !== null && _b !== void 0 ? _b : 0,
17
- lastSeen: (_c = row === null || row === void 0 ? void 0 : row.lastSeen) !== null && _c !== void 0 ? _c : null,
18
- });
19
- };
12
+ const toMemberExportStats = (row) => ({
13
+ postsCount: row?.postsCount ?? 0,
14
+ reactionsCount: row?.reactionsCount ?? 0,
15
+ lastSeen: row?.lastSeen ?? null,
16
+ });
20
17
  export const listMembersForExport = async () => {
21
18
  const { db } = await allpeepDb();
22
19
  const [profiles, statsRows] = await Promise.all([
@@ -24,22 +21,19 @@ export const listMembersForExport = async () => {
24
21
  membersExportMapping.filter(guestFilter).all(db),
25
22
  ]);
26
23
  const statsById = new Map(statsRows.map((row) => [row.id, toMemberExportStats(row)]));
27
- return profiles.map((profile) => {
28
- var _a;
29
- return (Object.assign(Object.assign({}, profile), ((_a = statsById.get(profile.id)) !== null && _a !== void 0 ? _a : emptyStats())));
30
- });
24
+ return profiles.map((profile) => ({
25
+ ...profile,
26
+ ...(statsById.get(profile.id) ?? emptyStats()),
27
+ }));
31
28
  };
32
29
  const formatCustomFields = (fields) => formatMemberExportCustomFields(fields);
33
30
  const formatEmailVerified = (controllers) => {
34
- var _a;
35
- const validated = (_a = controllers[0]) === null || _a === void 0 ? void 0 : _a.emailValidated;
31
+ const validated = controllers[0]?.emailValidated;
36
32
  return validated == null ? '' : validated ? 'yes' : 'no';
37
33
  };
38
- const formatGroups = (memberships) => {
39
- var _a;
40
- return (_a = memberships === null || memberships === void 0 ? void 0 : memberships.map((membership) => membership.group.displayName).join('; ')) !== null && _a !== void 0 ? _a : '';
41
- };
42
- const formatRoles = (roles) => { var _a; return (_a = roles === null || roles === void 0 ? void 0 : roles.map((role) => role.displayName || role.key).join('; ')) !== null && _a !== void 0 ? _a : ''; };
34
+ const formatGroups = (memberships) => memberships?.map((membership) => membership.group.displayName).join('; ') ??
35
+ '';
36
+ const formatRoles = (roles) => roles?.map((role) => role.displayName || role.key).join('; ') ?? '';
43
37
  const memberExportHeaders = [
44
38
  'Email',
45
39
  'Email Verified',
@@ -61,25 +55,22 @@ export const exportMembersCsv = async () => {
61
55
  const members = await listMembersForExport();
62
56
  return [
63
57
  toCsvRow([...memberExportHeaders]),
64
- ...members.map((member) => {
65
- var _a, _b, _c, _d, _e, _f, _g;
66
- return toCsvRow([
67
- (_b = (_a = member.controllers[0]) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : '',
68
- formatEmailVerified(member.controllers),
69
- member.createdAt,
70
- member.handle,
71
- (_c = member.displayName) !== null && _c !== void 0 ? _c : '',
72
- formatRoles(member.roles),
73
- (_d = member.bio) !== null && _d !== void 0 ? _d : '',
74
- (_f = (_e = member.location) === null || _e === void 0 ? void 0 : _e.text) !== null && _f !== void 0 ? _f : '',
75
- formatCustomFields(member.fields),
76
- formatGroups(member.memberships),
77
- (_g = member.lastSeen) !== null && _g !== void 0 ? _g : '',
78
- member.postsCount,
79
- member.reactionsCount,
80
- member.profileStats.followersCount,
81
- member.profileStats.followingCount,
82
- ]);
83
- }),
58
+ ...members.map((member) => toCsvRow([
59
+ member.controllers[0]?.email ?? '',
60
+ formatEmailVerified(member.controllers),
61
+ member.createdAt,
62
+ member.handle,
63
+ member.displayName ?? '',
64
+ formatRoles(member.roles),
65
+ member.bio ?? '',
66
+ member.location?.text ?? '',
67
+ formatCustomFields(member.fields),
68
+ formatGroups(member.memberships),
69
+ member.lastSeen ?? '',
70
+ member.postsCount,
71
+ member.reactionsCount,
72
+ member.profileStats.followersCount,
73
+ member.profileStats.followingCount,
74
+ ])),
84
75
  ].join('\n');
85
76
  };
@@ -32,13 +32,15 @@ export const follows = (follower, followed) => allpeepDb().then(({ db }) => foll
32
32
  export const listGroupMembers = (group) => allpeepDb()
33
33
  .then(({ db }) => groupsMapping.relationsFrom(group, membersRelation).all(db))
34
34
  .then((members) => Promise.all(members
35
- .filter((m) => { var _a; return (_a = m.profile) === null || _a === void 0 ? void 0 : _a.id; })
36
- .map(async (m) => (Object.assign(Object.assign({}, m), { profile: (await getProfile(m.profile.id)) })))))
35
+ .filter((m) => m.profile?.id)
36
+ .map(async (m) => ({
37
+ ...m,
38
+ profile: (await getProfile(m.profile.id)),
39
+ }))))
37
40
  .then((members) => members.filter((m) => !!m.profile));
38
41
  export const listCommonGroups = async (profile1, profile2) => {
39
- var _a, _b;
40
42
  const groups = await listGroups({ profile: profile1, scopes: [] });
41
- const profile1GroupIds = new Set(((_a = profile1.memberships) === null || _a === void 0 ? void 0 : _a.map((m) => m.group.id)) || []);
42
- const profile2GroupIds = new Set(((_b = profile2.memberships) === null || _b === void 0 ? void 0 : _b.map((m) => m.group.id)) || []);
43
+ const profile1GroupIds = new Set(profile1.memberships?.map((m) => m.group.id) || []);
44
+ const profile2GroupIds = new Set(profile2.memberships?.map((m) => m.group.id) || []);
43
45
  return groups.filter((group) => profile1GroupIds.has(group.id) && profile2GroupIds.has(group.id));
44
46
  };
@@ -5,7 +5,7 @@ export declare const baseProfileRelations: Relation[];
5
5
  export declare const profileRelations: Relation[];
6
6
  export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
7
7
  handle: string;
8
- type: "guest" | "local" | "federated";
8
+ type: "local" | "guest" | "federated";
9
9
  deletedHandle?: string | undefined;
10
10
  avatar?: string | null | undefined;
11
11
  header?: string | null | undefined;
@@ -35,7 +35,7 @@ export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
35
35
  guestData?: {
36
36
  email?: string | undefined;
37
37
  resource?: {
38
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
38
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
39
39
  id?: string | undefined;
40
40
  } | undefined;
41
41
  } | undefined;
@@ -44,7 +44,7 @@ export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
44
44
  /** Lean mapping for public search results (memberships only). */
45
45
  export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping<{
46
46
  handle: string;
47
- type: "guest" | "local" | "federated";
47
+ type: "local" | "guest" | "federated";
48
48
  deletedHandle?: string | undefined;
49
49
  avatar?: string | null | undefined;
50
50
  header?: string | null | undefined;
@@ -74,7 +74,7 @@ export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping
74
74
  guestData?: {
75
75
  email?: string | undefined;
76
76
  resource?: {
77
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
77
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
78
78
  id?: string | undefined;
79
79
  } | undefined;
80
80
  } | undefined;
@@ -86,7 +86,7 @@ export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping
86
86
  */
87
87
  export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
88
88
  handle: string;
89
- type: "guest" | "local" | "federated";
89
+ type: "local" | "guest" | "federated";
90
90
  deletedHandle?: string | undefined;
91
91
  avatar?: string | null | undefined;
92
92
  header?: string | null | undefined;
@@ -116,7 +116,7 @@ export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
116
116
  guestData?: {
117
117
  email?: string | undefined;
118
118
  resource?: {
119
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
119
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
120
120
  id?: string | undefined;
121
121
  } | undefined;
122
122
  } | undefined;
@@ -124,7 +124,7 @@ export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
124
124
  }, ProfileWithMeta, ProfileWithMeta>;
125
125
  export declare const profilesMapping: import("../db/pg/map").Mapping<{
126
126
  handle: string;
127
- type: "guest" | "local" | "federated";
127
+ type: "local" | "guest" | "federated";
128
128
  deletedHandle?: string | undefined;
129
129
  avatar?: string | null | undefined;
130
130
  header?: string | null | undefined;
@@ -154,7 +154,7 @@ export declare const profilesMapping: import("../db/pg/map").Mapping<{
154
154
  guestData?: {
155
155
  email?: string | undefined;
156
156
  resource?: {
157
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
157
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
158
158
  id?: string | undefined;
159
159
  } | undefined;
160
160
  } | undefined;
@@ -162,7 +162,7 @@ export declare const profilesMapping: import("../db/pg/map").Mapping<{
162
162
  }, ProfileWithMeta, ProfileWithMeta>;
163
163
  export declare const membersExportMapping: import("../db/pg/map").Mapping<{
164
164
  handle: string;
165
- type: "guest" | "local" | "federated";
165
+ type: "local" | "guest" | "federated";
166
166
  deletedHandle?: string | undefined;
167
167
  avatar?: string | null | undefined;
168
168
  header?: string | null | undefined;
@@ -192,7 +192,7 @@ export declare const membersExportMapping: import("../db/pg/map").Mapping<{
192
192
  guestData?: {
193
193
  email?: string | undefined;
194
194
  resource?: {
195
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
195
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
196
196
  id?: string | undefined;
197
197
  } | undefined;
198
198
  } | undefined;
@@ -11,13 +11,12 @@ import { deleteBlock, dropFollowsBetween, insertBlock, listBlockingIds, } from '
11
11
  import { localActorScalars } from '../federation/identity.js';
12
12
  import { uuidv7 } from 'uuidv7';
13
13
  export const createProfile = async (data, controllingAccount) => {
14
- var _a;
15
14
  await assertProfileCapacity();
16
15
  const db = await allpeepDb().then((db) => db.db);
17
16
  const id = uuidv7();
18
- const domain = (_a = data.activityPub) === null || _a === void 0 ? void 0 : _a.domain;
17
+ const domain = data.activityPub?.domain;
19
18
  const actor = data.type === 'local' && domain ? localActorScalars(id, domain) : {};
20
- const profile = await profilesMapping.create(db, Object.assign(Object.assign(Object.assign({}, data), { id }), actor));
19
+ const profile = await profilesMapping.create(db, { ...data, id, ...actor });
21
20
  if (controllingAccount) {
22
21
  await giveControl(db, controllingAccount, profile);
23
22
  await accountsCache.del(controllingAccount.id);
@@ -50,11 +49,10 @@ export const pinPostOnProfile = async (profile, pinnedPostId) => {
50
49
  return updated;
51
50
  };
52
51
  export const deleteProfile = async (profileId) => {
53
- var _a, _b;
54
52
  const db = await allpeepDb().then((db) => db.db);
55
53
  const profileToDelete = await getProfile(profileId);
56
54
  if (profileToDelete) {
57
- await Promise.all((_b = (_a = profileToDelete.controllers) === null || _a === void 0 ? void 0 : _a.map((account) => accountsCache.del(account.id))) !== null && _b !== void 0 ? _b : []);
55
+ await Promise.all(profileToDelete.controllers?.map((account) => accountsCache.del(account.id)) ?? []);
58
56
  if (profileToDelete.following && profileToDelete.following.length > 0) {
59
57
  await Promise.all(profileToDelete.following.map((followed) => profilesCache.del(followed.id)));
60
58
  }
@@ -21,7 +21,7 @@ export const closeRedisConnections = async () => {
21
21
  try {
22
22
  await conn.disconnect();
23
23
  }
24
- catch (_a) {
24
+ catch {
25
25
  // already closed
26
26
  }
27
27
  }));
@@ -3,9 +3,13 @@ import { collectionInfos } from '../db/index.js';
3
3
  import { tombstoneProfileWithMetaIfDeleted } from '@openpeepshq/common/lib';
4
4
  import { transformPost } from '../posts/index.js';
5
5
  export const transformReport = async (report) => {
6
- var _a;
7
- const rawPosts = ((_a = report.reportedPosts) !== null && _a !== void 0 ? _a : []);
8
- return Object.assign(Object.assign({}, report), { reporterProfile: tombstoneProfileWithMetaIfDeleted(report.reporterProfile), reportedProfile: tombstoneProfileWithMetaIfDeleted(report.reportedProfile), reportedPosts: await Promise.all(rawPosts.map((post) => transformPost(post))) });
6
+ const rawPosts = (report.reportedPosts ?? []);
7
+ return {
8
+ ...report,
9
+ reporterProfile: tombstoneProfileWithMetaIfDeleted(report.reporterProfile),
10
+ reportedProfile: tombstoneProfileWithMetaIfDeleted(report.reportedProfile),
11
+ reportedPosts: await Promise.all(rawPosts.map((post) => transformPost(post))),
12
+ };
9
13
  };
10
14
  export const transformReports = async (reports) => Promise.all(reports.map(transformReport));
11
15
  export const createdReportConnector = connector(collectionInfos.profilesCollection, collectionInfos.reportsCollection, collectionInfos.createdReportCollection);
@@ -5,5 +5,5 @@ export declare const reportsMapping: import("../db/pg/map").Mapping<{
5
5
  uri?: string | undefined;
6
6
  forward?: boolean | undefined;
7
7
  ruleIds?: number[] | undefined;
8
- resolution?: "warn" | "remove" | "ignore" | "other" | "ban" | undefined;
8
+ resolution?: "remove" | "warn" | "ignore" | "other" | "ban" | undefined;
9
9
  }, ReportWithMeta, ReportWithMeta>;
@@ -15,11 +15,8 @@ export const createRole = (roleData) => allpeepDb().then(async ({ db }) => {
15
15
  }
16
16
  return rolesMapping.create(db, roleData);
17
17
  });
18
- const capabilitiesMatchFactory = (capabilities, factoryRole) => {
19
- var _a, _b;
20
- return capabilitySetsEqual(capabilities === null || capabilities === void 0 ? void 0 : capabilities.add, (_a = factoryRole.capabilities) === null || _a === void 0 ? void 0 : _a.add) &&
21
- capabilitySetsEqual(capabilities === null || capabilities === void 0 ? void 0 : capabilities.remove, (_b = factoryRole.capabilities) === null || _b === void 0 ? void 0 : _b.remove);
22
- };
18
+ const capabilitiesMatchFactory = (capabilities, factoryRole) => capabilitySetsEqual(capabilities?.add, factoryRole.capabilities?.add) &&
19
+ capabilitySetsEqual(capabilities?.remove, factoryRole.capabilities?.remove);
23
20
  /**
24
21
  * Effective default flag for a write: an explicit `true` wins, and
25
22
  * capabilities that exactly match the system defaults re-adopt the role as a
@@ -28,15 +25,18 @@ const capabilitiesMatchFactory = (capabilities, factoryRole) => {
28
25
  * the current defaults version when the write does not set one explicitly.
29
26
  */
30
27
  const withDefaultAdoption = (existingRole, roleData) => {
31
- var _a;
32
- const factoryRole = defaultRoles.find((role) => { var _a; return role.key === ((_a = roleData.key) !== null && _a !== void 0 ? _a : existingRole === null || existingRole === void 0 ? void 0 : existingRole.key); });
28
+ const factoryRole = defaultRoles.find((role) => role.key === (roleData.key ?? existingRole?.key));
33
29
  if (!factoryRole)
34
30
  return roleData;
35
- const matchesFactory = capabilitiesMatchFactory((_a = roleData.capabilities) !== null && _a !== void 0 ? _a : existingRole === null || existingRole === void 0 ? void 0 : existingRole.capabilities, factoryRole);
31
+ const matchesFactory = capabilitiesMatchFactory(roleData.capabilities ?? existingRole?.capabilities, factoryRole);
36
32
  const isDefault = roleData.default === true || matchesFactory;
37
- return Object.assign(Object.assign(Object.assign({}, roleData), { default: isDefault }), (matchesFactory && roleData.baseVersion === undefined
38
- ? { baseVersion: currentRoleDefaults.version }
39
- : {}));
33
+ return {
34
+ ...roleData,
35
+ default: isDefault,
36
+ ...(matchesFactory && roleData.baseVersion === undefined
37
+ ? { baseVersion: currentRoleDefaults.version }
38
+ : {}),
39
+ };
40
40
  };
41
41
  /**
42
42
  * Applies the base→current delta of the system defaults to a capability
@@ -45,16 +45,16 @@ const withDefaultAdoption = (existingRole, roleData) => {
45
45
  */
46
46
  const applyCapabilityDelta = (capabilities, base, current) => {
47
47
  const delta = (list, from, to) => {
48
- const removed = (from !== null && from !== void 0 ? from : []).filter((c) => !(to !== null && to !== void 0 ? to : []).includes(c));
49
- const added = (to !== null && to !== void 0 ? to : []).filter((c) => !(from !== null && from !== void 0 ? from : []).includes(c));
48
+ const removed = (from ?? []).filter((c) => !(to ?? []).includes(c));
49
+ const added = (to ?? []).filter((c) => !(from ?? []).includes(c));
50
50
  return [
51
- ...(list !== null && list !== void 0 ? list : []).filter((c) => !removed.includes(c)),
52
- ...added.filter((c) => !(list !== null && list !== void 0 ? list : []).includes(c)),
51
+ ...(list ?? []).filter((c) => !removed.includes(c)),
52
+ ...added.filter((c) => !(list ?? []).includes(c)),
53
53
  ];
54
54
  };
55
55
  return {
56
- add: delta(capabilities === null || capabilities === void 0 ? void 0 : capabilities.add, base === null || base === void 0 ? void 0 : base.add, current === null || current === void 0 ? void 0 : current.add),
57
- remove: delta(capabilities === null || capabilities === void 0 ? void 0 : capabilities.remove, base === null || base === void 0 ? void 0 : base.remove, current === null || current === void 0 ? void 0 : current.remove),
56
+ add: delta(capabilities?.add, base?.add, current?.add),
57
+ remove: delta(capabilities?.remove, base?.remove, current?.remove),
58
58
  };
59
59
  };
60
60
  /**
@@ -64,17 +64,16 @@ const applyCapabilityDelta = (capabilities, base, current) => {
64
64
  * role untouched — the anchor only moves when capabilities actually change.
65
65
  */
66
66
  const rebaseRoleToCurrentDefaults = (existingRole, factoryRole) => {
67
- var _a, _b, _c;
68
67
  const baseVersion = existingRole.baseVersion;
69
68
  if (!baseVersion || baseVersion === currentRoleDefaults.version) {
70
69
  return null;
71
70
  }
72
- const baseRole = (_a = findRoleDefaultsVersion(baseVersion)) === null || _a === void 0 ? void 0 : _a.roles.find((role) => role.key === factoryRole.key);
71
+ const baseRole = findRoleDefaultsVersion(baseVersion)?.roles.find((role) => role.key === factoryRole.key);
73
72
  if (!baseRole)
74
73
  return null;
75
74
  const capabilities = applyCapabilityDelta(existingRole.capabilities, baseRole.capabilities, factoryRole.capabilities);
76
- const unchanged = capabilitySetsEqual((_b = existingRole.capabilities) === null || _b === void 0 ? void 0 : _b.add, capabilities.add) &&
77
- capabilitySetsEqual((_c = existingRole.capabilities) === null || _c === void 0 ? void 0 : _c.remove, capabilities.remove);
75
+ const unchanged = capabilitySetsEqual(existingRole.capabilities?.add, capabilities.add) &&
76
+ capabilitySetsEqual(existingRole.capabilities?.remove, capabilities.remove);
78
77
  if (unchanged)
79
78
  return null;
80
79
  return { capabilities, baseVersion: currentRoleDefaults.version };
@@ -36,15 +36,27 @@ export const searchPosts = async (query, authData, limitOffset = { offset: 0, li
36
36
  const profile = requireProfile(authData);
37
37
  const { db } = await allpeepDb();
38
38
  const mapping = postSearchMapping(profile, query);
39
- return filterAndTransform(mapping, db, Object.assign({ transform: transformPostWithScore(profile), filter: await canReadPostFilter(authData) }, limitOffset));
39
+ return filterAndTransform(mapping, db, {
40
+ transform: transformPostWithScore(profile),
41
+ filter: await canReadPostFilter(authData),
42
+ ...limitOffset,
43
+ });
40
44
  });
41
45
  export const searchEvents = async (query, authData, limitOffset = { offset: 0, limit: 15 }) => {
42
46
  const profile = requireProfile(authData);
43
- return filterAndTransform(eventSearchMapping(profile, query), (await allpeepDb()).db, Object.assign({ transform: transformPostWithScore(profile), filter: await canReadPostFilter(authData) }, limitOffset));
47
+ return filterAndTransform(eventSearchMapping(profile, query), (await allpeepDb()).db, {
48
+ transform: transformPostWithScore(profile),
49
+ filter: await canReadPostFilter(authData),
50
+ ...limitOffset,
51
+ });
44
52
  };
45
53
  export const searchJams = async (query, authData, limitOffset = { offset: 0, limit: 15 }) => {
46
54
  const profile = requireProfile(authData);
47
- return filterAndTransform(jamSearchMapping(profile, query), (await allpeepDb()).db, Object.assign({ transform: transformPostWithScore(profile), filter: await canReadPostFilter(authData) }, limitOffset));
55
+ return filterAndTransform(jamSearchMapping(profile, query), (await allpeepDb()).db, {
56
+ transform: transformPostWithScore(profile),
57
+ filter: await canReadPostFilter(authData),
58
+ ...limitOffset,
59
+ });
48
60
  };
49
61
  export const searchResultCounts = async (query, authData) => {
50
62
  const profile = requireProfile(authData);
@@ -1 +1 @@
1
- export const queryParamsToLimit = (query) => { var _a, _b; return (query === null || query === void 0 ? void 0 : query.offset) ? [query.offset, (_a = query === null || query === void 0 ? void 0 : query.limit) !== null && _a !== void 0 ? _a : 15] : ((_b = query === null || query === void 0 ? void 0 : query.limit) !== null && _b !== void 0 ? _b : 15); };
1
+ export const queryParamsToLimit = (query) => query?.offset ? [query.offset, query?.limit ?? 15] : (query?.limit ?? 15);
@@ -10,7 +10,6 @@ export const SERVICE_TAG = 'service';
10
10
  * Strip scheme/port from `server.host` / `SERVER_HOST` for Sentry tags.
11
11
  */
12
12
  export const normalizeServerHostname = (host) => {
13
- var _a;
14
13
  const trimmed = host.trim();
15
14
  if (!trimmed)
16
15
  return 'unknown';
@@ -18,8 +17,8 @@ export const normalizeServerHostname = (host) => {
18
17
  const serverUrl = trimmed.includes('://') ? trimmed : `http://${trimmed}`;
19
18
  return new URL(serverUrl).hostname || 'unknown';
20
19
  }
21
- catch (_b) {
22
- return ((_a = trimmed.split('/')[0]) === null || _a === void 0 ? void 0 : _a.split(':')[0]) || 'unknown';
20
+ catch {
21
+ return trimmed.split('/')[0]?.split(':')[0] || 'unknown';
23
22
  }
24
23
  };
25
24
  export const getCommunityHostname = () => communityHostname;
@@ -30,14 +29,13 @@ export const getSentryService = () => serviceName;
30
29
  * — never fall back to `NODE_ENV` (Docker images always set that to production).
31
30
  */
32
31
  export const resolveSentryEnvironment = (explicit) => {
33
- var _a, _b;
34
- const fromExplicit = explicit === null || explicit === void 0 ? void 0 : explicit.trim();
32
+ const fromExplicit = explicit?.trim();
35
33
  if (fromExplicit)
36
34
  return fromExplicit;
37
- const fromSentryEnv = (_a = process.env.SENTRY_ENVIRONMENT) === null || _a === void 0 ? void 0 : _a.trim();
35
+ const fromSentryEnv = process.env.SENTRY_ENVIRONMENT?.trim();
38
36
  if (fromSentryEnv)
39
37
  return fromSentryEnv;
40
- const fromEnvironment = (_b = process.env.ENVIRONMENT) === null || _b === void 0 ? void 0 : _b.trim();
38
+ const fromEnvironment = process.env.ENVIRONMENT?.trim();
41
39
  if (fromEnvironment)
42
40
  return fromEnvironment;
43
41
  return 'local';
@@ -56,7 +54,6 @@ export const applyCommunitySentryTags = () => {
56
54
  * Always records hostname/service for local diagnostics even when Sentry is off.
57
55
  */
58
56
  export const initSentry = (options = {}) => {
59
- var _a, _b, _c, _d;
60
57
  if (options.hostname !== undefined) {
61
58
  communityHostname = normalizeServerHostname(options.hostname);
62
59
  }
@@ -76,8 +73,8 @@ export const initSentry = (options = {}) => {
76
73
  }
77
74
  return;
78
75
  }
79
- const dsn = (_a = options.dsn) !== null && _a !== void 0 ? _a : process.env.SENTRY_DSN;
80
- const enabled = (_b = options.enabled) !== null && _b !== void 0 ? _b : (Boolean(dsn) && process.env.SENTRY_ENABLED !== '0');
76
+ const dsn = options.dsn ?? process.env.SENTRY_DSN;
77
+ const enabled = options.enabled ?? (Boolean(dsn) && process.env.SENTRY_ENABLED !== '0');
81
78
  if (!enabled || !dsn) {
82
79
  log.info({
83
80
  communityHostname,
@@ -86,7 +83,8 @@ export const initSentry = (options = {}) => {
86
83
  initialized = true;
87
84
  return;
88
85
  }
89
- const tracesSampleRate = (_c = options.tracesSampleRate) !== null && _c !== void 0 ? _c : Number((_d = process.env.SENTRY_TRACES_SAMPLE_RATE) !== null && _d !== void 0 ? _d : '0.1');
86
+ const tracesSampleRate = options.tracesSampleRate ??
87
+ Number(process.env.SENTRY_TRACES_SAMPLE_RATE ?? '0.1');
90
88
  const environment = resolveSentryEnvironment(options.environment);
91
89
  Sentry.init({
92
90
  dsn,