@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
@@ -36,7 +36,7 @@ export const backfillMissingEventOccurrences = async () => {
36
36
  let rebuilt = 0;
37
37
  for (const row of rows) {
38
38
  const event = row.body;
39
- if ((event === null || event === void 0 ? void 0 : event.type) !== 'event' || !event.start)
39
+ if (event?.type !== 'event' || !event.start)
40
40
  continue;
41
41
  await rebuildEventOccurrences(row.id, event);
42
42
  rebuilt += 1;
@@ -52,7 +52,7 @@ export const rebuildRecurringEventOccurrences = async () => {
52
52
  let rebuilt = 0;
53
53
  for (const row of rows) {
54
54
  const event = row.body;
55
- if ((event === null || event === void 0 ? void 0 : event.type) !== 'event' || !event.start)
55
+ if (event?.type !== 'event' || !event.start)
56
56
  continue;
57
57
  await rebuildEventOccurrences(row.id, event);
58
58
  rebuilt += 1;
@@ -18,7 +18,7 @@ export declare const baseFeed: ({ start, sort, profile, }: {
18
18
  profile?: ProfileWithMeta;
19
19
  }) => Mapping<DbPost>;
20
20
  export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
21
- type: "note" | "question" | "event" | "article";
21
+ type: "resource" | "note" | "question" | "event" | "article";
22
22
  visibility: "local" | "group" | "report" | "public" | "unlisted" | "private" | "direct";
23
23
  creatorId: string;
24
24
  capabilitiesNeeded?: string[] | undefined;
@@ -44,7 +44,7 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
44
44
  };
45
45
  description?: string | undefined;
46
46
  blurhash?: string | undefined;
47
- status?: "failed" | "processing" | "ready" | undefined;
47
+ status?: "failed" | "ready" | "processing" | undefined;
48
48
  error?: string | undefined;
49
49
  }[] | undefined;
50
50
  customEmojis?: {
@@ -81,7 +81,7 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
81
81
  };
82
82
  description?: string | undefined;
83
83
  blurhash?: string | undefined;
84
- status?: "failed" | "processing" | "ready" | undefined;
84
+ status?: "failed" | "ready" | "processing" | undefined;
85
85
  error?: string | undefined;
86
86
  }[] | undefined;
87
87
  customEmojis?: {
@@ -119,7 +119,7 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
119
119
  };
120
120
  description?: string | undefined;
121
121
  blurhash?: string | undefined;
122
- status?: "failed" | "processing" | "ready" | undefined;
122
+ status?: "failed" | "ready" | "processing" | undefined;
123
123
  error?: string | undefined;
124
124
  }[] | undefined;
125
125
  customEmojis?: {
@@ -201,7 +201,7 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
201
201
  };
202
202
  description?: string | undefined;
203
203
  blurhash?: string | undefined;
204
- status?: "failed" | "processing" | "ready" | undefined;
204
+ status?: "failed" | "ready" | "processing" | undefined;
205
205
  error?: string | undefined;
206
206
  }[] | undefined;
207
207
  customEmojis?: {
@@ -214,6 +214,44 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
214
214
  language?: string | undefined;
215
215
  image?: string | undefined;
216
216
  title?: string | undefined;
217
+ } | {
218
+ type: "resource";
219
+ title: string;
220
+ resourceKind: "file" | "link" | "video" | "gallery" | "audio";
221
+ content?: string | undefined;
222
+ sensitive?: boolean | undefined;
223
+ spoilerText?: string | undefined;
224
+ attachments?: {
225
+ type: string;
226
+ url: string;
227
+ previewUrl: string | null;
228
+ textUrl: null;
229
+ filename: string;
230
+ meta: {
231
+ usage?: string | undefined;
232
+ focus?: {
233
+ x: number;
234
+ y: number;
235
+ } | undefined;
236
+ mimetype?: string | undefined;
237
+ size?: number | undefined;
238
+ };
239
+ description?: string | undefined;
240
+ blurhash?: string | undefined;
241
+ status?: "failed" | "ready" | "processing" | undefined;
242
+ error?: string | undefined;
243
+ }[] | undefined;
244
+ customEmojis?: {
245
+ shortcode: string;
246
+ url: string;
247
+ staticUrl: string;
248
+ visibleInPicker: boolean;
249
+ category: string;
250
+ }[] | undefined;
251
+ language?: string | undefined;
252
+ tags?: string[] | undefined;
253
+ categoryPath?: string[] | undefined;
254
+ url?: string | undefined;
217
255
  } | undefined;
218
256
  }, DbPost, DbPost>;
219
257
  export declare const listPosts: (authData: AuthorizationData, { start, limit, filter, }?: {
@@ -236,11 +274,13 @@ export declare const listBookmarkedPosts: (authData: AuthorizationData, requeste
236
274
  }) => Promise<PostWithMeta[]>;
237
275
  export declare const listBookmarkedPostIds: (requestedProfile: ProfileWithMeta) => Promise<string[]>;
238
276
  export declare const getUnseenPostCounts: (authData: AuthorizationData) => Promise<UnseenPostCounts>;
239
- export declare const listPostsByType: (authData: AuthorizationData, type: PostType, { start, limit, filter, format, }?: {
277
+ export declare const listPostsByType: (authData: AuthorizationData, type: PostType, { start, limit, filter, format, groupId, ungrouped, }?: {
240
278
  start?: string;
241
279
  limit?: number;
242
280
  filter?: PgFilter<DbBasePost>;
243
281
  format?: string | null;
282
+ groupId?: string;
283
+ ungrouped?: boolean;
244
284
  }) => Promise<PostWithMeta[]>;
245
285
  export declare const listPostsByTag: (authData: AuthorizationData, tag: string, { start, limit, filter, format, }?: {
246
286
  start?: string;
@@ -30,14 +30,13 @@ const requireProfile = (authData) => {
30
30
  return authData.profile;
31
31
  };
32
32
  const hideBlockedAuthorPost = (post, profile) => {
33
- var _a, _b;
34
33
  if (!post)
35
34
  return undefined;
36
- const creatorId = (_a = post.creatorId) !== null && _a !== void 0 ? _a : (_b = post.profile) === null || _b === void 0 ? void 0 : _b.id;
35
+ const creatorId = post.creatorId ?? post.profile?.id;
37
36
  return isBlockedPair(profile, creatorId) ? undefined : post;
38
37
  };
39
38
  export const findPost = async (id, authData) => {
40
- const profile = authData === null || authData === void 0 ? void 0 : authData.profile;
39
+ const profile = authData?.profile;
41
40
  return allpeepDb()
42
41
  .then(({ db }) => postsMappingForProfile(profile).find(db, id))
43
42
  .then((post) => (post ? transformPost(post, profile) : undefined))
@@ -47,7 +46,7 @@ export const findPost = async (id, authData) => {
47
46
  export const findPostsForAuth = async (ids, authData) => {
48
47
  if (ids.length === 0)
49
48
  return [];
50
- const profile = authData === null || authData === void 0 ? void 0 : authData.profile;
49
+ const profile = authData?.profile;
51
50
  const { db } = await allpeepDb();
52
51
  const mapData = postsAuthMapping.data();
53
52
  const rows = await fetchRowsByIds(db, mapData.collection, ids, mapData.softDelete);
@@ -63,7 +62,7 @@ export const findPostsForAuth = async (ids, authData) => {
63
62
  export const postContext = async (authData, id, depth, direction, contextMapping) => {
64
63
  const profile = authData.profile;
65
64
  const mapping = postsMappingForProfile(profile);
66
- return toFilteredPostsList(mapping.relationsFrom({ id }, contextRelation(depth, direction, contextMapping !== null && contextMapping !== void 0 ? contextMapping : mapping)), { authData });
65
+ return toFilteredPostsList(mapping.relationsFrom({ id }, contextRelation(depth, direction, contextMapping ?? mapping)), { authData });
67
66
  };
68
67
  export const descendents = async (authData, post, depth, contextMapping) => postContext(authData, post.id, depth, 'descendents', contextMapping);
69
68
  export const ancestors = async (authData, post, depth, contextMapping) => postContext(authData, post.id, depth, 'ancestors', contextMapping);
@@ -158,11 +157,24 @@ export const getUnseenPostCounts = async (authData) => withSpan('unseen.counts',
158
157
  const { db } = await allpeepDb();
159
158
  return queryUnseenPostCounts(db, profile.id, groupIds);
160
159
  });
161
- export const listPostsByType = async (authData, type, { start, limit = 100, filter, format, } = {
160
+ export const listPostsByType = async (authData, type, { start, limit = 100, filter, format, groupId, ungrouped, } = {
162
161
  limit: 100,
163
- }) => toFilteredPostsList(conversationFeed({ start, profile: authData.profile, format })
164
- .filter(filter)
165
- .filter({ matches: { type } }), { authData, limit });
162
+ }) => {
163
+ let mapping = conversationFeed({
164
+ start,
165
+ profile: authData.profile,
166
+ format,
167
+ })
168
+ .filter(filter)
169
+ .filter({ matches: { type } });
170
+ if (groupId) {
171
+ mapping = mapping.filter(postFilters.inGroup(groupId));
172
+ }
173
+ else if (ungrouped) {
174
+ mapping = mapping.filter(postFilters.notInAnyGroup());
175
+ }
176
+ return toFilteredPostsList(mapping, { authData, limit });
177
+ };
166
178
  export const listPostsByTag = async (authData, tag, { start, limit = 100, filter, format, } = {
167
179
  limit: 100,
168
180
  }) => {
@@ -16,8 +16,7 @@ export const followFilter = (profile) => ({
16
16
  })),
17
17
  });
18
18
  export const myFeedFilter = (profile) => {
19
- var _a, _b;
20
- const hashtagFilterResult = postFilters.hasAnyHashtag((_b = (_a = profile.followedHashtags) === null || _a === void 0 ? void 0 : _a.map((h) => h.id)) !== null && _b !== void 0 ? _b : []);
19
+ const hashtagFilterResult = postFilters.hasAnyHashtag(profile.followedHashtags?.map((h) => h.id) ?? []);
21
20
  return {
22
21
  operator: '||',
23
22
  predicates: [
@@ -30,7 +29,7 @@ export const myFeedFilter = (profile) => {
30
29
  };
31
30
  export const myFeedGroupMembershipFilter = (profile) => (post) => post.visibility !== 'group' ||
32
31
  (!!post.group &&
33
- profile.memberships.some((m) => { var _a; return m.group.id === ((_a = post.group) === null || _a === void 0 ? void 0 : _a.id); }));
32
+ profile.memberships.some((m) => m.group.id === post.group?.id));
34
33
  export const localFeedFilter = (_profile) => ({
35
34
  matches: [{ visibility: 'local' }, { visibility: 'public' }],
36
35
  });
@@ -35,7 +35,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
35
35
  };
36
36
  description?: string | undefined;
37
37
  blurhash?: string | undefined;
38
- status?: "failed" | "processing" | "ready" | undefined;
38
+ status?: "failed" | "ready" | "processing" | undefined;
39
39
  error?: string | undefined;
40
40
  }[] | undefined;
41
41
  customEmojis?: {
@@ -72,7 +72,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
72
72
  };
73
73
  description?: string | undefined;
74
74
  blurhash?: string | undefined;
75
- status?: "failed" | "processing" | "ready" | undefined;
75
+ status?: "failed" | "ready" | "processing" | undefined;
76
76
  error?: string | undefined;
77
77
  }[] | undefined;
78
78
  customEmojis?: {
@@ -110,7 +110,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
110
110
  };
111
111
  description?: string | undefined;
112
112
  blurhash?: string | undefined;
113
- status?: "failed" | "processing" | "ready" | undefined;
113
+ status?: "failed" | "ready" | "processing" | undefined;
114
114
  error?: string | undefined;
115
115
  }[] | undefined;
116
116
  customEmojis?: {
@@ -192,7 +192,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
192
192
  };
193
193
  description?: string | undefined;
194
194
  blurhash?: string | undefined;
195
- status?: "failed" | "processing" | "ready" | undefined;
195
+ status?: "failed" | "ready" | "processing" | undefined;
196
196
  error?: string | undefined;
197
197
  }[] | undefined;
198
198
  customEmojis?: {
@@ -205,6 +205,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
205
205
  language?: string | undefined;
206
206
  image?: string | undefined;
207
207
  title?: string | undefined;
208
+ } | {
209
+ type: "resource";
210
+ title: string;
211
+ resourceKind: "file" | "link" | "video" | "gallery" | "audio";
212
+ content?: string | undefined;
213
+ sensitive?: boolean | undefined;
214
+ spoilerText?: string | undefined;
215
+ attachments?: {
216
+ type: string;
217
+ url: string;
218
+ previewUrl: string | null;
219
+ textUrl: null;
220
+ filename: string;
221
+ meta: {
222
+ usage?: string | undefined;
223
+ focus?: {
224
+ x: number;
225
+ y: number;
226
+ } | undefined;
227
+ mimetype?: string | undefined;
228
+ size?: number | undefined;
229
+ };
230
+ description?: string | undefined;
231
+ blurhash?: string | undefined;
232
+ status?: "failed" | "ready" | "processing" | undefined;
233
+ error?: string | undefined;
234
+ }[] | undefined;
235
+ customEmojis?: {
236
+ shortcode: string;
237
+ url: string;
238
+ staticUrl: string;
239
+ visibleInPicker: boolean;
240
+ category: string;
241
+ }[] | undefined;
242
+ language?: string | undefined;
243
+ tags?: string[] | undefined;
244
+ categoryPath?: string[] | undefined;
245
+ url?: string | undefined;
208
246
  };
209
247
  } | {
210
248
  type: "edit";
@@ -230,7 +268,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
230
268
  };
231
269
  description?: string | undefined;
232
270
  blurhash?: string | undefined;
233
- status?: "failed" | "processing" | "ready" | undefined;
271
+ status?: "failed" | "ready" | "processing" | undefined;
234
272
  error?: string | undefined;
235
273
  }[] | undefined;
236
274
  customEmojis?: {
@@ -267,7 +305,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
267
305
  };
268
306
  description?: string | undefined;
269
307
  blurhash?: string | undefined;
270
- status?: "failed" | "processing" | "ready" | undefined;
308
+ status?: "failed" | "ready" | "processing" | undefined;
271
309
  error?: string | undefined;
272
310
  }[] | undefined;
273
311
  customEmojis?: {
@@ -305,7 +343,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
305
343
  };
306
344
  description?: string | undefined;
307
345
  blurhash?: string | undefined;
308
- status?: "failed" | "processing" | "ready" | undefined;
346
+ status?: "failed" | "ready" | "processing" | undefined;
309
347
  error?: string | undefined;
310
348
  }[] | undefined;
311
349
  customEmojis?: {
@@ -387,7 +425,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
387
425
  };
388
426
  description?: string | undefined;
389
427
  blurhash?: string | undefined;
390
- status?: "failed" | "processing" | "ready" | undefined;
428
+ status?: "failed" | "ready" | "processing" | undefined;
391
429
  error?: string | undefined;
392
430
  }[] | undefined;
393
431
  customEmojis?: {
@@ -400,6 +438,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
400
438
  language?: string | undefined;
401
439
  image?: string | undefined;
402
440
  title?: string | undefined;
441
+ } | {
442
+ type: "resource";
443
+ title: string;
444
+ resourceKind: "file" | "link" | "video" | "gallery" | "audio";
445
+ content?: string | undefined;
446
+ sensitive?: boolean | undefined;
447
+ spoilerText?: string | undefined;
448
+ attachments?: {
449
+ type: string;
450
+ url: string;
451
+ previewUrl: string | null;
452
+ textUrl: null;
453
+ filename: string;
454
+ meta: {
455
+ usage?: string | undefined;
456
+ focus?: {
457
+ x: number;
458
+ y: number;
459
+ } | undefined;
460
+ mimetype?: string | undefined;
461
+ size?: number | undefined;
462
+ };
463
+ description?: string | undefined;
464
+ blurhash?: string | undefined;
465
+ status?: "failed" | "ready" | "processing" | undefined;
466
+ error?: string | undefined;
467
+ }[] | undefined;
468
+ customEmojis?: {
469
+ shortcode: string;
470
+ url: string;
471
+ staticUrl: string;
472
+ visibleInPicker: boolean;
473
+ category: string;
474
+ }[] | undefined;
475
+ language?: string | undefined;
476
+ tags?: string[] | undefined;
477
+ categoryPath?: string[] | undefined;
478
+ url?: string | undefined;
403
479
  };
404
480
  } | {
405
481
  type: "delete";
@@ -412,7 +488,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
412
488
  } | {
413
489
  type: "rsvp";
414
490
  data: {
415
- response: "removed" | "no" | "yes" | "tentative";
491
+ response: "no" | "yes" | "tentative" | "removed";
416
492
  recurrenceId?: string | undefined;
417
493
  };
418
494
  } | {
@@ -453,7 +529,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
453
529
  };
454
530
  description?: string | undefined;
455
531
  blurhash?: string | undefined;
456
- status?: "failed" | "processing" | "ready" | undefined;
532
+ status?: "failed" | "ready" | "processing" | undefined;
457
533
  error?: string | undefined;
458
534
  }[] | undefined;
459
535
  customEmojis?: {
@@ -490,7 +566,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
490
566
  };
491
567
  description?: string | undefined;
492
568
  blurhash?: string | undefined;
493
- status?: "failed" | "processing" | "ready" | undefined;
569
+ status?: "failed" | "ready" | "processing" | undefined;
494
570
  error?: string | undefined;
495
571
  }[] | undefined;
496
572
  customEmojis?: {
@@ -528,7 +604,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
528
604
  };
529
605
  description?: string | undefined;
530
606
  blurhash?: string | undefined;
531
- status?: "failed" | "processing" | "ready" | undefined;
607
+ status?: "failed" | "ready" | "processing" | undefined;
532
608
  error?: string | undefined;
533
609
  }[] | undefined;
534
610
  customEmojis?: {
@@ -610,7 +686,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
610
686
  };
611
687
  description?: string | undefined;
612
688
  blurhash?: string | undefined;
613
- status?: "failed" | "processing" | "ready" | undefined;
689
+ status?: "failed" | "ready" | "processing" | undefined;
614
690
  error?: string | undefined;
615
691
  }[] | undefined;
616
692
  customEmojis?: {
@@ -623,6 +699,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
623
699
  language?: string | undefined;
624
700
  image?: string | undefined;
625
701
  title?: string | undefined;
702
+ } | {
703
+ type: "resource";
704
+ title: string;
705
+ resourceKind: "file" | "link" | "video" | "gallery" | "audio";
706
+ content?: string | undefined;
707
+ sensitive?: boolean | undefined;
708
+ spoilerText?: string | undefined;
709
+ attachments?: {
710
+ type: string;
711
+ url: string;
712
+ previewUrl: string | null;
713
+ textUrl: null;
714
+ filename: string;
715
+ meta: {
716
+ usage?: string | undefined;
717
+ focus?: {
718
+ x: number;
719
+ y: number;
720
+ } | undefined;
721
+ mimetype?: string | undefined;
722
+ size?: number | undefined;
723
+ };
724
+ description?: string | undefined;
725
+ blurhash?: string | undefined;
726
+ status?: "failed" | "ready" | "processing" | undefined;
727
+ error?: string | undefined;
728
+ }[] | undefined;
729
+ customEmojis?: {
730
+ shortcode: string;
731
+ url: string;
732
+ staticUrl: string;
733
+ visibleInPicker: boolean;
734
+ category: string;
735
+ }[] | undefined;
736
+ language?: string | undefined;
737
+ tags?: string[] | undefined;
738
+ categoryPath?: string[] | undefined;
739
+ url?: string | undefined;
626
740
  };
627
741
  } | {
628
742
  type: "edit";
@@ -648,7 +762,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
648
762
  };
649
763
  description?: string | undefined;
650
764
  blurhash?: string | undefined;
651
- status?: "failed" | "processing" | "ready" | undefined;
765
+ status?: "failed" | "ready" | "processing" | undefined;
652
766
  error?: string | undefined;
653
767
  }[] | undefined;
654
768
  customEmojis?: {
@@ -685,7 +799,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
685
799
  };
686
800
  description?: string | undefined;
687
801
  blurhash?: string | undefined;
688
- status?: "failed" | "processing" | "ready" | undefined;
802
+ status?: "failed" | "ready" | "processing" | undefined;
689
803
  error?: string | undefined;
690
804
  }[] | undefined;
691
805
  customEmojis?: {
@@ -723,7 +837,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
723
837
  };
724
838
  description?: string | undefined;
725
839
  blurhash?: string | undefined;
726
- status?: "failed" | "processing" | "ready" | undefined;
840
+ status?: "failed" | "ready" | "processing" | undefined;
727
841
  error?: string | undefined;
728
842
  }[] | undefined;
729
843
  customEmojis?: {
@@ -805,7 +919,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
805
919
  };
806
920
  description?: string | undefined;
807
921
  blurhash?: string | undefined;
808
- status?: "failed" | "processing" | "ready" | undefined;
922
+ status?: "failed" | "ready" | "processing" | undefined;
809
923
  error?: string | undefined;
810
924
  }[] | undefined;
811
925
  customEmojis?: {
@@ -818,6 +932,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
818
932
  language?: string | undefined;
819
933
  image?: string | undefined;
820
934
  title?: string | undefined;
935
+ } | {
936
+ type: "resource";
937
+ title: string;
938
+ resourceKind: "file" | "link" | "video" | "gallery" | "audio";
939
+ content?: string | undefined;
940
+ sensitive?: boolean | undefined;
941
+ spoilerText?: string | undefined;
942
+ attachments?: {
943
+ type: string;
944
+ url: string;
945
+ previewUrl: string | null;
946
+ textUrl: null;
947
+ filename: string;
948
+ meta: {
949
+ usage?: string | undefined;
950
+ focus?: {
951
+ x: number;
952
+ y: number;
953
+ } | undefined;
954
+ mimetype?: string | undefined;
955
+ size?: number | undefined;
956
+ };
957
+ description?: string | undefined;
958
+ blurhash?: string | undefined;
959
+ status?: "failed" | "ready" | "processing" | undefined;
960
+ error?: string | undefined;
961
+ }[] | undefined;
962
+ customEmojis?: {
963
+ shortcode: string;
964
+ url: string;
965
+ staticUrl: string;
966
+ visibleInPicker: boolean;
967
+ category: string;
968
+ }[] | undefined;
969
+ language?: string | undefined;
970
+ tags?: string[] | undefined;
971
+ categoryPath?: string[] | undefined;
972
+ url?: string | undefined;
821
973
  };
822
974
  } | {
823
975
  type: "delete";
@@ -830,7 +982,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
830
982
  } | {
831
983
  type: "rsvp";
832
984
  data: {
833
- response: "removed" | "no" | "yes" | "tentative";
985
+ response: "no" | "yes" | "tentative" | "removed";
834
986
  recurrenceId?: string | undefined;
835
987
  };
836
988
  } | {
@@ -21,10 +21,11 @@ const getTags = (text) => {
21
21
  return (text.match(hashtagRegex) || []).map((tag) => normalizeHashtagTag(tag.substring(1)));
22
22
  };
23
23
  export const extractHashtags = (data) => {
24
- switch (data.type) {
25
- default:
26
- return getTags(data === null || data === void 0 ? void 0 : data.content);
27
- }
24
+ const fromContent = getTags(data?.content);
25
+ if (data.type !== 'resource')
26
+ return fromContent;
27
+ const fromTags = (data.tags ?? []).map((tag) => normalizeHashtagTag(tag.replace(/^#/, '')));
28
+ return [...new Set([...fromContent, ...fromTags])];
28
29
  };
29
30
  export const extractMentionHandles = (text) => matchMentionHandles(text);
30
31
  export const resolveMentionsForPost = async (data) => {
@@ -52,20 +53,24 @@ export const bookmarkConnector = connector(collectionInfos.profilesCollection, c
52
53
  export const bookmarkDisconnector = disconnector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.bookmarksCollection);
53
54
  export const postSeenConnector = connector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.postSeenCollection);
54
55
  const loadPublicProfile = async (profileId, ignoreSoftDelete = false) => tombstoneProfileWithMetaIfDeleted(await getPublicProfile(profileId, ignoreSoftDelete));
55
- const addProfileForEntry = async (rawEntry) => (Object.assign(Object.assign({}, rawEntry), {
56
+ const addProfileForEntry = async (rawEntry) => ({
57
+ ...rawEntry,
56
58
  // ignoreSoftDelete: authorship must survive account removal
57
- profile: (await loadPublicProfile(rawEntry.profile.id, true)) }));
58
- const addProfileForMention = async (rawMention) => (Object.assign(Object.assign({}, rawMention), { profile: (await loadPublicProfile(rawMention.profile.id, true)) }));
59
+ profile: (await loadPublicProfile(rawEntry.profile.id, true)),
60
+ });
61
+ const addProfileForMention = async (rawMention) => ({
62
+ ...rawMention,
63
+ profile: (await loadPublicProfile(rawMention.profile.id, true)),
64
+ });
59
65
  const leanRepostsFromWrappers = async (wrappers) => {
60
- if (!(wrappers === null || wrappers === void 0 ? void 0 : wrappers.length))
66
+ if (!wrappers?.length)
61
67
  return [];
62
68
  const withProfiles = await Promise.all(wrappers.map(async (wrapper) => {
63
- var _a, _b, _c;
64
- const createEntry = (_a = wrapper.entries) === null || _a === void 0 ? void 0 : _a.find((entry) => entry.type === 'create');
65
- const profileId = (_c = (_b = createEntry === null || createEntry === void 0 ? void 0 : createEntry.profile) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : wrapper.creatorId;
69
+ const createEntry = wrapper.entries?.find((entry) => entry.type === 'create');
70
+ const profileId = createEntry?.profile?.id ?? wrapper.creatorId;
66
71
  if (!profileId)
67
72
  return null;
68
- const profile = (createEntry === null || createEntry === void 0 ? void 0 : createEntry.profile)
73
+ const profile = createEntry?.profile
69
74
  ? await loadPublicProfile(createEntry.profile.id, true)
70
75
  : await loadPublicProfile(profileId, true);
71
76
  if (!profile)
@@ -81,8 +86,7 @@ const leanRepostsFromWrappers = async (wrappers) => {
81
86
  .slice(0, EMBEDDED_REPOSTS_LIMIT);
82
87
  };
83
88
  export const transformPost = async (post, currentProfile, options = {}) => {
84
- var _a, _b, _c;
85
- const embedThreadPreview = (_a = options.embedThreadPreview) !== null && _a !== void 0 ? _a : true;
89
+ const embedThreadPreview = options.embedThreadPreview ?? true;
86
90
  const nested = { embedThreadPreview: false };
87
91
  const allEntries = post.entries
88
92
  ? await Promise.all(post.entries.map(addProfileForEntry))
@@ -101,38 +105,50 @@ export const transformPost = async (post, currentProfile, options = {}) => {
101
105
  const mentions = post.mentions
102
106
  ? await Promise.all(post.mentions.map(addProfileForMention))
103
107
  : [];
104
- const createProfile = (_b = entries.find((entry) => entry.type === 'create')) === null || _b === void 0 ? void 0 : _b.profile;
105
- const profile = createProfile !== null && createProfile !== void 0 ? createProfile : (post.creatorId
106
- ? await loadPublicProfile(post.creatorId, true)
107
- : undefined);
108
+ const createProfile = entries.find((entry) => entry.type === 'create')?.profile;
109
+ const profile = createProfile ??
110
+ (post.creatorId
111
+ ? await loadPublicProfile(post.creatorId, true)
112
+ : undefined);
108
113
  const preview = embedThreadPreview
109
114
  ? await loadThreadPreviewReplies(post.id, currentProfile)
110
115
  : {
111
- replies: ((_c = post.latestReplies) !== null && _c !== void 0 ? _c : []),
116
+ replies: (post.latestReplies ?? []),
112
117
  hasMore: !!post.latestRepliesHasMore,
113
118
  };
114
119
  const latestReplies = (await Promise.all(preview.replies.map((reply) => transformPost(reply, currentProfile, nested)))).filter((reply) => !!reply.profile);
115
- return Object.assign(Object.assign({}, post), { data: post.data ? normalizePostDataFromDb(post.data) : post.data, seen: currentProfile ? post.seen : undefined, replyTo: post.replyTo
120
+ return {
121
+ ...post,
122
+ data: post.data ? normalizePostDataFromDb(post.data) : post.data,
123
+ seen: currentProfile ? post.seen : undefined,
124
+ replyTo: post.replyTo
116
125
  ? withBlockTombstone(await transformPost(post.replyTo, currentProfile, nested), currentProfile)
117
- : undefined, latestReplies: latestReplies.map((reply) => withBlockTombstone(reply, currentProfile)), latestRepliesHasMore: preview.hasMore, repost: post.repost
126
+ : undefined,
127
+ latestReplies: latestReplies.map((reply) => withBlockTombstone(reply, currentProfile)),
128
+ latestRepliesHasMore: preview.hasMore,
129
+ repost: post.repost
118
130
  ? await transformPost(post.repost, currentProfile, {
119
131
  embedThreadPreview,
120
132
  })
121
- : undefined, rsvps: entries
133
+ : undefined,
134
+ rsvps: entries
122
135
  .filter((entry) => entry.type === 'rsvp')
123
136
  .map((entry) => ({
124
137
  profile: entry.profile,
125
138
  response: entry.data.response,
126
139
  recurrenceId: entry.data.recurrenceId,
127
140
  createdAt: entry.createdAt,
128
- })), audience,
129
- mentions, profile: profile, entries,
141
+ })),
142
+ audience,
143
+ mentions,
144
+ profile: profile,
145
+ entries,
130
146
  reactions,
131
- reposts });
147
+ reposts,
148
+ };
132
149
  };
133
150
  const withBlockTombstone = (post, currentProfile) => {
134
- var _a, _b;
135
- const creatorId = (_a = post.creatorId) !== null && _a !== void 0 ? _a : (_b = post.profile) === null || _b === void 0 ? void 0 : _b.id;
151
+ const creatorId = post.creatorId ?? post.profile?.id;
136
152
  return creatorId && isBlockedPair(currentProfile, creatorId)
137
153
  ? toHiddenPost(post)
138
154
  : post;