@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
@@ -0,0 +1,50 @@
1
+ /** A sitemap row: app-relative path plus modification time, when known. */
2
+ export type CrawlableEntry = {
3
+ path: string;
4
+ updatedAt?: string | null;
5
+ };
6
+ /** What a content page should be titled and summarised as, for crawlers. */
7
+ export type CrawlableMeta = {
8
+ title: string;
9
+ description: string;
10
+ /** Post routes only: the extra facts DiscussionForumPosting needs. */
11
+ kind?: 'post';
12
+ datePublished?: string;
13
+ dateModified?: string;
14
+ authorName?: string;
15
+ };
16
+ /**
17
+ * Metadata plus whether the route could render at all, so the server can answer
18
+ * 404 for a content path that will never show anything to a crawler instead of
19
+ * a 200 community shell.
20
+ */
21
+ export type SpaMeta = {
22
+ meta: CrawlableMeta | null;
23
+ notFound: boolean;
24
+ };
25
+ export { seoRoute, type SeoRoute, type SeoRouteKind } from './route';
26
+ /** Publicly readable pages, newest first. Events are posts and have no route of
27
+ * their own, so they are covered by the post paths.
28
+ *
29
+ * Profiles are opt-in: a crawled profile page is cached by search engines long
30
+ * after the member leaves. `listProfiles` applies no privacy filter — it is the
31
+ * same list `/members` shows — so enabling this exposes exactly the profiles an
32
+ * anonymous visitor can already browse.
33
+ */
34
+ export declare const crawlableEntries: ({ indexProfiles, }: {
35
+ indexProfiles: boolean;
36
+ }) => Promise<CrawlableEntry[]>;
37
+ /**
38
+ * Metadata for a content route, plus whether it can render at all, so a shared
39
+ * post is not described to every crawler as the community homepage and an
40
+ * unknown id is not served as a 200. Negatives are cached as well: a bot
41
+ * probing unknown ids should not turn each request into a query. Profile
42
+ * metadata additionally requires the `indexProfiles` flag.
43
+ */
44
+ export declare const spaMetaForPath: (pathname: string, { indexProfiles }: {
45
+ indexProfiles: boolean;
46
+ }) => Promise<SpaMeta>;
47
+ /** Convenience wrapper for callers that only need the metadata itself. */
48
+ export declare const metaForPath: (pathname: string, options: {
49
+ indexProfiles: boolean;
50
+ }) => Promise<CrawlableMeta | null>;
@@ -0,0 +1,145 @@
1
+ import { capabilitiesConfig } from '../config/index.js';
2
+ import { findGroupByHandle, listGroups } from '../groups/index.js';
3
+ import { findPost, listPosts } from '../posts/index.js';
4
+ import { canReadPost } from '../posts/helpers/filters.js';
5
+ import { findProfileByHandle, listProfiles } from '../profiles/index.js';
6
+ import { getSharedConnection } from '../redis/index.js';
7
+ import { seoRoute } from './route.js';
8
+ export { seoRoute } from './route.js';
9
+ /**
10
+ * Per entity kind. `listPosts` runs each row through `transformPost`, which
11
+ * hydrates reactions, mentions and thread previews we never render here, so the
12
+ * cap is what keeps a crawler sweep from turning into a full content scan.
13
+ */
14
+ const PER_KIND_LIMIT = 1_000;
15
+ // Versioned because the cached shape gained `notFound` and later the
16
+ // JSON-LD fields: an old entry must never be read as the new one during a
17
+ // rolling restart.
18
+ const META_CACHE_PREFIX = 'seo:meta:v3:';
19
+ const META_TTL_SECONDS = 5 * 60;
20
+ /**
21
+ * An anonymous visitor: no profile, no scopes. That is the whole access rule.
22
+ * `listPosts` filters with `canReadPost(config, authData)` after querying and
23
+ * `canSeeGroupFilter` falls through to `groupFilters.publiclyReadable()`, so
24
+ * reusing those guards — instead of writing a sitemap-specific visibility check —
25
+ * means any later change to what anonymous visitors may read applies here
26
+ * automatically. Soft-deleted documents are excluded by the map layer.
27
+ */
28
+ const ANONYMOUS = { scopes: [] };
29
+ const byNewest = (a, b) => (b.updatedAt ?? '').localeCompare(a.updatedAt ?? '');
30
+ /** Collapse whitespace and clip to something a search snippet can use. */
31
+ const excerpt = (value, fallback) => {
32
+ const text = (value ?? '').replace(/\s+/g, ' ').trim();
33
+ if (!text)
34
+ return fallback;
35
+ return text.length > 155 ? `${text.slice(0, 152).trimEnd()}...` : text;
36
+ };
37
+ /** Publicly readable pages, newest first. Events are posts and have no route of
38
+ * their own, so they are covered by the post paths.
39
+ *
40
+ * Profiles are opt-in: a crawled profile page is cached by search engines long
41
+ * after the member leaves. `listProfiles` applies no privacy filter — it is the
42
+ * same list `/members` shows — so enabling this exposes exactly the profiles an
43
+ * anonymous visitor can already browse.
44
+ */
45
+ export const crawlableEntries = async ({ indexProfiles, }) => {
46
+ const [posts, groups, profiles] = await Promise.all([
47
+ listPosts(ANONYMOUS, { limit: PER_KIND_LIMIT }),
48
+ listGroups(ANONYMOUS),
49
+ indexProfiles ? listProfiles() : Promise.resolve([]),
50
+ ]);
51
+ const entities = [
52
+ ...posts.map((post) => ({
53
+ path: `/posts/${post.id}`,
54
+ updatedAt: post.updatedAt,
55
+ })),
56
+ ...groups.slice(0, PER_KIND_LIMIT).map((group) => ({
57
+ path: `/groups/@${group.handle}`,
58
+ updatedAt: group.updatedAt,
59
+ })),
60
+ ...profiles.slice(0, PER_KIND_LIMIT).map((profile) => ({
61
+ path: `/@${profile.handle}`,
62
+ updatedAt: profile.updatedAt,
63
+ })),
64
+ ].sort(byNewest);
65
+ // A crawler arriving only through the sitemap otherwise never learns the
66
+ // homepage exists; no lastmod, the root has no single modification time.
67
+ return [{ path: '/' }, ...entities];
68
+ };
69
+ const resolveMeta = async (pathname, indexProfiles) => {
70
+ const route = seoRoute(pathname, { indexProfiles });
71
+ if (!route)
72
+ return { meta: null, notFound: false };
73
+ if (route.kind === 'post') {
74
+ const post = await findPost(route.handle);
75
+ // findPost has no visibility gate of its own — `toFilteredPostsList` applies
76
+ // it for lists — so the read rule is re-applied here rather than trusted.
77
+ if (!post ||
78
+ !(await canReadPost(await capabilitiesConfig(), ANONYMOUS)(post)))
79
+ return { meta: null, notFound: true };
80
+ const body = 'content' in post.data
81
+ ? post.data.content
82
+ : 'name' in post.data
83
+ ? post.data.name
84
+ : '';
85
+ const heading = 'title' in post.data && post.data.title
86
+ ? post.data.title
87
+ : excerpt(body, post.profile?.displayName ?? 'Post');
88
+ return {
89
+ meta: {
90
+ title: heading,
91
+ description: excerpt(body, heading),
92
+ kind: 'post',
93
+ datePublished: post.createdAt,
94
+ dateModified: post.updatedAt,
95
+ authorName: post.profile?.displayName ||
96
+ (post.profile?.handle ? `@${post.profile.handle}` : undefined),
97
+ },
98
+ notFound: false,
99
+ };
100
+ }
101
+ if (route.kind === 'group') {
102
+ const group = await findGroupByHandle(route.handle);
103
+ // Groups have no visibility column; this mirrors
104
+ // `groupFilters.publiclyReadable()`, which reads the same capability.
105
+ if (!group?.capabilities?.none?.add?.includes('core-groups-read'))
106
+ return { meta: null, notFound: true };
107
+ const groupTitle = group.displayName || `@${group.handle}`;
108
+ return {
109
+ meta: {
110
+ title: groupTitle,
111
+ description: excerpt(group.description, groupTitle),
112
+ },
113
+ notFound: false,
114
+ };
115
+ }
116
+ const profile = await findProfileByHandle(route.handle);
117
+ if (!profile)
118
+ return { meta: null, notFound: true };
119
+ return {
120
+ meta: {
121
+ title: profile.displayName || `@${profile.handle}`,
122
+ description: excerpt(profile.bio, `@${profile.handle}`),
123
+ },
124
+ notFound: false,
125
+ };
126
+ };
127
+ /**
128
+ * Metadata for a content route, plus whether it can render at all, so a shared
129
+ * post is not described to every crawler as the community homepage and an
130
+ * unknown id is not served as a 200. Negatives are cached as well: a bot
131
+ * probing unknown ids should not turn each request into a query. Profile
132
+ * metadata additionally requires the `indexProfiles` flag.
133
+ */
134
+ export const spaMetaForPath = async (pathname, { indexProfiles }) => {
135
+ const redis = await getSharedConnection();
136
+ const key = `${META_CACHE_PREFIX}${pathname}`;
137
+ const cached = await redis.get(key);
138
+ if (cached)
139
+ return JSON.parse(cached);
140
+ const resolved = await resolveMeta(pathname, indexProfiles);
141
+ await redis.set(key, JSON.stringify(resolved), { EX: META_TTL_SECONDS });
142
+ return resolved;
143
+ };
144
+ /** Convenience wrapper for callers that only need the metadata itself. */
145
+ export const metaForPath = async (pathname, options) => (await spaMetaForPath(pathname, options)).meta;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Pure parsing of the content routes the crawler layer recognises. Kept free of
3
+ * data-layer imports so the rules are unit-testable and so this can be loaded
4
+ * where opening a database connection would be wrong.
5
+ */
6
+ export type SeoRouteKind = 'post' | 'group' | 'profile';
7
+ export type SeoRoute = {
8
+ kind: SeoRouteKind;
9
+ handle: string;
10
+ };
11
+ /**
12
+ * A trailing slash addresses the same page as the bare path; `webNavigator`
13
+ * never emits one, so the canonical spelling has none. Tolerating it here stops
14
+ * `/posts/x/` from silently falling back to community-wide metadata.
15
+ */
16
+ export declare const seoRoute: (pathname: string, { indexProfiles }: {
17
+ indexProfiles: boolean;
18
+ }) => SeoRoute | null;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A trailing slash addresses the same page as the bare path; `webNavigator`
3
+ * never emits one, so the canonical spelling has none. Tolerating it here stops
4
+ * `/posts/x/` from silently falling back to community-wide metadata.
5
+ */
6
+ export const seoRoute = (pathname, { indexProfiles }) => {
7
+ const post = /^\/posts\/([\w-]+)\/?$/.exec(pathname)?.[1];
8
+ if (post)
9
+ return { kind: 'post', handle: post };
10
+ // Group and profile handles carry the leading @ in real URLs, and the web
11
+ // client also accepts it absent, so both spellings resolve.
12
+ const group = /^\/groups\/@?([^/]+?)\/?$/.exec(pathname)?.[1];
13
+ if (group)
14
+ return { kind: 'group', handle: group };
15
+ if (!indexProfiles)
16
+ return null;
17
+ const profile = /^\/@([^/]+?)\/?$/.exec(pathname)?.[1];
18
+ return profile ? { kind: 'profile', handle: profile } : null;
19
+ };
@@ -72,6 +72,7 @@ export declare const serverInfo: () => Promise<{
72
72
  defaultLanguage?: string | undefined;
73
73
  defaultTimeZone?: string | undefined;
74
74
  defaultFeedFormat?: "threaded" | "linear" | undefined;
75
+ indexProfiles?: boolean | undefined;
75
76
  };
76
77
  roles: {
77
78
  onRegistration: {
@@ -27,15 +27,13 @@ export const protocolForServerHost = (host, envProtocol = process.env.SERVER_PRO
27
27
  export const serverProtocol = async () => protocolForServerHost((await config()).server.host);
28
28
  export const serverRootUrl = async () => `${await serverProtocol()}://${(await config()).server.host}`;
29
29
  const lastAccessedFromPostViews = async () => {
30
- var _a;
31
30
  const db = await database();
32
31
  const rows = await db
33
32
  .select({ last: sql `max(${postSeen.createdAt})` })
34
33
  .from(postSeen);
35
- return normalizeComputedDatetime((_a = rows[0]) === null || _a === void 0 ? void 0 : _a.last);
34
+ return normalizeComputedDatetime(rows[0]?.last);
36
35
  };
37
36
  export const serverInfo = () => config().then(async (coreConfig) => {
38
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
39
37
  const [lastAccessed, disk, community] = await Promise.all([
40
38
  lastAccessedFromPostViews(),
41
39
  diskUsage(coreConfig.media.storage.params.path),
@@ -43,7 +41,7 @@ export const serverInfo = () => config().then(async (coreConfig) => {
43
41
  ]);
44
42
  return {
45
43
  version: coreConfig.version,
46
- build: ((_a = process.env.BUILD) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
44
+ build: process.env.BUILD?.trim() || undefined,
47
45
  environment: coreConfig.environment,
48
46
  publicContent: coreConfig.server.publicContent,
49
47
  startedAt: processStartedAt,
@@ -51,7 +49,14 @@ export const serverInfo = () => config().then(async (coreConfig) => {
51
49
  disk,
52
50
  lastAccessed,
53
51
  maxProfiles: coreConfig.server.maxProfiles || undefined,
54
- communityConfig: Object.assign(Object.assign({}, community), { theme: withLegacyThemeRoot(community.theme), settings: Object.assign(Object.assign({}, community.settings), { openRegistrations: !!coreConfig.server.signUpsOpen }) }),
52
+ communityConfig: {
53
+ ...community,
54
+ theme: withLegacyThemeRoot(community.theme),
55
+ settings: {
56
+ ...community.settings,
57
+ openRegistrations: !!coreConfig.server.signUpsOpen,
58
+ },
59
+ },
55
60
  jams: {
56
61
  livekit: {
57
62
  url: coreConfig.jams.livekit.url,
@@ -65,16 +70,16 @@ export const serverInfo = () => config().then(async (coreConfig) => {
65
70
  publicKey: coreConfig.vapid.publicKey,
66
71
  },
67
72
  sentryConfig: {
68
- enabled: !!((_c = (_b = coreConfig.services) === null || _b === void 0 ? void 0 : _b.sentry) === null || _c === void 0 ? void 0 : _c.enabled) &&
69
- !!((_e = (_d = coreConfig.services) === null || _d === void 0 ? void 0 : _d.sentry) === null || _e === void 0 ? void 0 : _e.dsn),
70
- dsn: (_g = (_f = coreConfig.services) === null || _f === void 0 ? void 0 : _f.sentry) === null || _g === void 0 ? void 0 : _g.dsn,
71
- replayEnabled: !!((_j = (_h = coreConfig.services) === null || _h === void 0 ? void 0 : _h.sentry) === null || _j === void 0 ? void 0 : _j.replayEnabled) &&
72
- !!((_l = (_k = coreConfig.services) === null || _k === void 0 ? void 0 : _k.sentry) === null || _l === void 0 ? void 0 : _l.dsn),
73
+ enabled: !!coreConfig.services?.sentry?.enabled &&
74
+ !!coreConfig.services?.sentry?.dsn,
75
+ dsn: coreConfig.services?.sentry?.dsn,
76
+ replayEnabled: !!coreConfig.services?.sentry?.replayEnabled &&
77
+ !!coreConfig.services?.sentry?.dsn,
73
78
  },
74
79
  payments: {
75
80
  stripe: {
76
81
  paidMembership: {
77
- enabled: !!((_p = (_o = (_m = coreConfig.payments) === null || _m === void 0 ? void 0 : _m.stripe) === null || _o === void 0 ? void 0 : _o.paidMembership) === null || _p === void 0 ? void 0 : _p.enabled),
82
+ enabled: !!coreConfig.payments?.stripe?.paidMembership?.enabled,
78
83
  },
79
84
  },
80
85
  },
@@ -2,7 +2,7 @@ import { readdir, stat, statfs } from 'node:fs/promises';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  export const processStartedAt = new Date(Date.now() - process.uptime() * 1000).toISOString();
5
- const FOLDER_SIZE_CACHE_MS = 30000;
5
+ const FOLDER_SIZE_CACHE_MS = 30_000;
6
6
  let folderSizeCache = null;
7
7
  /** Sum of regular files under dir. Skips unreadable entries. */
8
8
  export const folderSize = async (dir) => {
@@ -11,7 +11,7 @@ export const folderSize = async (dir) => {
11
11
  try {
12
12
  entries = await readdir(dir, { withFileTypes: true });
13
13
  }
14
- catch (_a) {
14
+ catch {
15
15
  return 0;
16
16
  }
17
17
  for (const entry of entries) {
@@ -27,7 +27,7 @@ export const folderSize = async (dir) => {
27
27
  total += (await stat(full)).size;
28
28
  }
29
29
  }
30
- catch (_b) {
30
+ catch {
31
31
  // Skip entries we cannot stat (permissions, races).
32
32
  }
33
33
  }
@@ -56,7 +56,7 @@ export const diskUsage = async (mediaPath) => {
56
56
  const folderBytes = await cachedFolderSize(mediaPath);
57
57
  return { folderBytes, totalBytes, freeBytes };
58
58
  }
59
- catch (_a) {
59
+ catch {
60
60
  return null;
61
61
  }
62
62
  };
@@ -85,14 +85,13 @@ export const memoryUsage = (totalBytes = os.totalmem(), freeBytes = os.freemem()
85
85
  };
86
86
  const CPU_SAMPLE_MS = 50;
87
87
  export const hostResources = async (wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) => {
88
- var _a, _b;
89
88
  const memory = memoryUsage();
90
89
  const previous = cpuTimes();
91
90
  await wait(CPU_SAMPLE_MS);
92
91
  const cpuPercent = Math.round(cpuUsedPercent(previous, cpuTimes()) * 10) / 10;
93
92
  return {
94
- memoryUsedBytes: (_a = memory === null || memory === void 0 ? void 0 : memory.usedBytes) !== null && _a !== void 0 ? _a : 0,
95
- memoryTotalBytes: (_b = memory === null || memory === void 0 ? void 0 : memory.totalBytes) !== null && _b !== void 0 ? _b : 0,
93
+ memoryUsedBytes: memory?.usedBytes ?? 0,
94
+ memoryTotalBytes: memory?.totalBytes ?? 0,
96
95
  cpuUsedPercent: cpuPercent,
97
96
  };
98
97
  };
@@ -50,9 +50,9 @@ export const getSessionPresence = async (profileId) => {
50
50
  const connections = Object.entries(raw).flatMap(([connectionId, value]) => {
51
51
  try {
52
52
  const parsed = JSON.parse(value);
53
- return [Object.assign({ connectionId }, parsed)];
53
+ return [{ connectionId, ...parsed }];
54
54
  }
55
- catch (_a) {
55
+ catch {
56
56
  return [];
57
57
  }
58
58
  });
@@ -120,25 +120,34 @@ const createIntervals = (duration) => {
120
120
  start: sub(new Date(), { days: i + 1 }),
121
121
  end: sub(new Date(), { days: i }),
122
122
  }))
123
- .map((interval) => (Object.assign({ name: interval.start.toISOString().split('T')[0] }, interval)));
123
+ .map((interval) => ({
124
+ name: interval.start.toISOString().split('T')[0],
125
+ ...interval,
126
+ }));
124
127
  case 'P4W':
125
128
  return [0, 1, 2, 3]
126
129
  .map((i) => ({
127
130
  start: sub(new Date(), { days: (i + 1) * 7 }),
128
131
  end: sub(new Date(), { days: i * 7 }),
129
132
  }))
130
- .map((interval) => (Object.assign({ name: `${interval.start.toISOString().split('T')[0]} - ${interval.end.toISOString().split('T')[0]}` }, interval)));
133
+ .map((interval) => ({
134
+ name: `${interval.start.toISOString().split('T')[0]} - ${interval.end.toISOString().split('T')[0]}`,
135
+ ...interval,
136
+ }));
131
137
  case 'P120D':
132
138
  return [0, 1, 2, 3]
133
139
  .map((i) => ({
134
140
  start: sub(new Date(), { days: (i + 1) * 30 }),
135
141
  end: sub(new Date(), { days: i * 30 }),
136
142
  }))
137
- .map((interval) => (Object.assign({ name: `${interval.start.toISOString().split('T')[0]} - ${interval.end.toISOString().split('T')[0]}` }, interval)));
143
+ .map((interval) => ({
144
+ name: `${interval.start.toISOString().split('T')[0]} - ${interval.end.toISOString().split('T')[0]}`,
145
+ ...interval,
146
+ }));
138
147
  }
139
148
  };
140
149
  export const signupsTimeline = (duration) => Promise.all(createIntervals(duration).map((interval) => newProfilesForInterval(interval.start, interval.end).then((count) => ({
141
- name: interval === null || interval === void 0 ? void 0 : interval.name,
150
+ name: interval?.name,
142
151
  count,
143
152
  }))));
144
153
  export const serverStats = async () => ({
@@ -31,4 +31,7 @@ export const compileStats = async (fn) => allpeepDb().then(async ({ db }) => ({
31
31
  lastPeriod: await fn(db, sub(new Date(), { years: 2 }), sub(new Date(), { years: 1 })),
32
32
  },
33
33
  }));
34
- export const compileStatsWithAll = async (fn) => allpeepDb().then(async ({ db }) => (Object.assign(Object.assign({}, (await compileStats(fn))), { all: await fn(db) })));
34
+ export const compileStatsWithAll = async (fn) => allpeepDb().then(async ({ db }) => ({
35
+ ...(await compileStats(fn)),
36
+ all: await fn(db),
37
+ }));
@@ -1,7 +1,7 @@
1
1
  import { DbPost } from '@openpeepshq/common/types';
2
2
  export declare const profileWithActivityScoreMapping: (start?: Date, end?: Date) => import("../db/pg/map").Mapping<object, import("../db/pg/map").WithId<object>, import("@openpeepshq/common").Profile>;
3
3
  export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mapping<{
4
- type: "note" | "question" | "event" | "article";
4
+ type: "resource" | "note" | "question" | "event" | "article";
5
5
  visibility: "local" | "group" | "report" | "public" | "unlisted" | "private" | "direct";
6
6
  creatorId: string;
7
7
  capabilitiesNeeded?: string[] | undefined;
@@ -27,7 +27,7 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
27
27
  };
28
28
  description?: string | undefined;
29
29
  blurhash?: string | undefined;
30
- status?: "failed" | "processing" | "ready" | undefined;
30
+ status?: "failed" | "ready" | "processing" | undefined;
31
31
  error?: string | undefined;
32
32
  }[] | undefined;
33
33
  customEmojis?: {
@@ -64,7 +64,7 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
64
64
  };
65
65
  description?: string | undefined;
66
66
  blurhash?: string | undefined;
67
- status?: "failed" | "processing" | "ready" | undefined;
67
+ status?: "failed" | "ready" | "processing" | undefined;
68
68
  error?: string | undefined;
69
69
  }[] | undefined;
70
70
  customEmojis?: {
@@ -102,7 +102,7 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
102
102
  };
103
103
  description?: string | undefined;
104
104
  blurhash?: string | undefined;
105
- status?: "failed" | "processing" | "ready" | undefined;
105
+ status?: "failed" | "ready" | "processing" | undefined;
106
106
  error?: string | undefined;
107
107
  }[] | undefined;
108
108
  customEmojis?: {
@@ -184,7 +184,7 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
184
184
  };
185
185
  description?: string | undefined;
186
186
  blurhash?: string | undefined;
187
- status?: "failed" | "processing" | "ready" | undefined;
187
+ status?: "failed" | "ready" | "processing" | undefined;
188
188
  error?: string | undefined;
189
189
  }[] | undefined;
190
190
  customEmojis?: {
@@ -197,6 +197,44 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
197
197
  language?: string | undefined;
198
198
  image?: string | undefined;
199
199
  title?: string | undefined;
200
+ } | {
201
+ type: "resource";
202
+ title: string;
203
+ resourceKind: "file" | "link" | "video" | "gallery" | "audio";
204
+ content?: string | undefined;
205
+ sensitive?: boolean | undefined;
206
+ spoilerText?: string | undefined;
207
+ attachments?: {
208
+ type: string;
209
+ url: string;
210
+ previewUrl: string | null;
211
+ textUrl: null;
212
+ filename: string;
213
+ meta: {
214
+ usage?: string | undefined;
215
+ focus?: {
216
+ x: number;
217
+ y: number;
218
+ } | undefined;
219
+ mimetype?: string | undefined;
220
+ size?: number | undefined;
221
+ };
222
+ description?: string | undefined;
223
+ blurhash?: string | undefined;
224
+ status?: "failed" | "ready" | "processing" | undefined;
225
+ error?: string | undefined;
226
+ }[] | undefined;
227
+ customEmojis?: {
228
+ shortcode: string;
229
+ url: string;
230
+ staticUrl: string;
231
+ visibleInPicker: boolean;
232
+ category: string;
233
+ }[] | undefined;
234
+ language?: string | undefined;
235
+ tags?: string[] | undefined;
236
+ categoryPath?: string[] | undefined;
237
+ url?: string | undefined;
200
238
  } | undefined;
201
239
  }, DbPost & {
202
240
  activityScore: number;
@@ -3,8 +3,15 @@ import { baseProfilesMapping } from '../profiles/index.js';
3
3
  import { postsMapping } from '../posts/index.js';
4
4
  import { map } from '../db/pg/map/index.js';
5
5
  import { computedFields } from '../db/pg/queries/index.js';
6
- export const profileWithActivityScoreMapping = (start, end) => map(Object.assign(Object.assign({}, baseProfilesMapping.data()), { activityWindow: { start, end }, computedFields: [computedFields.profileActivityScore({ start, end })] }));
7
- export const postsWithActivityScoreMapping = map(Object.assign(Object.assign({}, postsMapping.data()), { computedFields: [computedFields.postActivityScore()] }));
6
+ export const profileWithActivityScoreMapping = (start, end) => map({
7
+ ...baseProfilesMapping.data(),
8
+ activityWindow: { start, end },
9
+ computedFields: [computedFields.profileActivityScore({ start, end })],
10
+ });
11
+ export const postsWithActivityScoreMapping = map({
12
+ ...postsMapping.data(),
13
+ computedFields: [computedFields.postActivityScore()],
14
+ });
8
15
  export const followsMapping = map({
9
16
  collection: collectionInfos.followsCollection.name,
10
17
  });
@@ -6,14 +6,13 @@ export const stripeCache = createCache({
6
6
  refreshThreshold: 60 * 60 * 1000,
7
7
  });
8
8
  const loadStripeSubscription = async (customerId) => {
9
- var _a, _b, _c, _d, _e, _f;
10
9
  const subscriptions = await getStripe().then((stripe) => stripe.subscriptions.list({
11
10
  customer: customerId,
12
11
  limit: 1,
13
12
  status: 'all',
14
13
  expand: ['data.default_payment_method'],
15
14
  }));
16
- if (!(subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.data) || (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.data.length) === 0) {
15
+ if (!subscriptions?.data || subscriptions?.data.length === 0) {
17
16
  return { status: 'none' };
18
17
  }
19
18
  const subscription = subscriptions.data[0];
@@ -21,14 +20,14 @@ const loadStripeSubscription = async (customerId) => {
21
20
  subscriptionId: subscription.id,
22
21
  status: subscription.status,
23
22
  priceId: subscription.items.data[0].price.id,
24
- currentPeriodEnd: (_a = subscription.ended_at) !== null && _a !== void 0 ? _a : null,
25
- currentPeriodStart: (_b = subscription.start_date) !== null && _b !== void 0 ? _b : null,
23
+ currentPeriodEnd: subscription.ended_at ?? null,
24
+ currentPeriodStart: subscription.start_date ?? null,
26
25
  cancelAtPeriodEnd: subscription.cancel_at_period_end,
27
26
  paymentMethod: subscription.default_payment_method &&
28
27
  typeof subscription.default_payment_method !== 'string'
29
28
  ? {
30
- brand: (_d = (_c = subscription.default_payment_method.card) === null || _c === void 0 ? void 0 : _c.brand) !== null && _d !== void 0 ? _d : null,
31
- last4: (_f = (_e = subscription.default_payment_method.card) === null || _e === void 0 ? void 0 : _e.last4) !== null && _f !== void 0 ? _f : null,
29
+ brand: subscription.default_payment_method.card?.brand ?? null,
30
+ last4: subscription.default_payment_method.card?.last4 ?? null,
32
31
  }
33
32
  : null,
34
33
  };
@@ -1,18 +1,17 @@
1
1
  import Stripe from 'stripe';
2
2
  import { config } from '../config/index.js';
3
3
  import { hub } from '../events/index.js';
4
- export const initStripeWithCredentials = (data) => (data === null || data === void 0 ? void 0 : data.publishableKey) || (data === null || data === void 0 ? void 0 : data.secretKey) || (data === null || data === void 0 ? void 0 : data.webhookSecret)
5
- ? new Stripe(data === null || data === void 0 ? void 0 : data.secretKey, { apiVersion: '2025-07-30.basil' })
4
+ export const initStripeWithCredentials = (data) => data?.publishableKey || data?.secretKey || data?.webhookSecret
5
+ ? new Stripe(data?.secretKey, { apiVersion: '2025-07-30.basil' })
6
6
  : undefined;
7
7
  export const initStripe = async () => {
8
- var _a;
9
8
  hub.on('configUpdated', (namespace, name) => {
10
9
  if (namespace === 'openpeeps' && name === 'core') {
11
10
  _stripe = null;
12
11
  }
13
12
  });
14
13
  const cfg = await config();
15
- return initStripeWithCredentials((_a = cfg.payments) === null || _a === void 0 ? void 0 : _a.stripe);
14
+ return initStripeWithCredentials(cfg.payments?.stripe);
16
15
  };
17
16
  let _stripe = null;
18
17
  export const getStripe = async () => {