@openpeepshq/core 0.1.34 → 0.1.35

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 (165) 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/index.d.ts +1 -0
  23. package/dist/config/index.js +9 -11
  24. package/dist/db/explorer/query.js +9 -8
  25. package/dist/db/explorer/sql.js +8 -8
  26. package/dist/db/helpers.js +15 -5
  27. package/dist/db/migration/importCollections.js +15 -18
  28. package/dist/db/migration/shared.js +15 -35
  29. package/dist/db/pg/client.js +4 -7
  30. package/dist/db/pg/filters/index.js +1 -1
  31. package/dist/db/pg/filters/posts.d.ts +2 -0
  32. package/dist/db/pg/filters/posts.js +2 -0
  33. package/dist/db/pg/helpers.js +2 -14
  34. package/dist/db/pg/map/filters.js +8 -8
  35. package/dist/db/pg/map/helpers.js +5 -1
  36. package/dist/db/pg/map/index.js +46 -51
  37. package/dist/db/pg/map/mutations.js +56 -21
  38. package/dist/db/pg/map/registry.js +87 -50
  39. package/dist/db/pg/map/relations.js +67 -63
  40. package/dist/db/pg/map/search.js +15 -37
  41. package/dist/db/pg/mappers.js +13 -7
  42. package/dist/db/pg/migrate.js +2 -3
  43. package/dist/db/pg/queries/activity.js +2 -2
  44. package/dist/db/pg/queries/derived.js +8 -12
  45. package/dist/db/pg/schema/documents.js +119 -18
  46. package/dist/db/pg/schema/edges.js +7 -1
  47. package/dist/db/pg/schema/index.js +5 -1
  48. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  49. package/dist/db/pg/sql/meta/_journal.json +8 -1
  50. package/dist/db/replaceOrigin.js +1 -1
  51. package/dist/email/queueStats.js +8 -11
  52. package/dist/email/render.js +7 -4
  53. package/dist/email/send.js +19 -17
  54. package/dist/email/smtpTest.js +10 -6
  55. package/dist/errors/index.js +1 -1
  56. package/dist/events/once.js +2 -4
  57. package/dist/federation/activities.js +1 -2
  58. package/dist/groups/helpers.js +1 -2
  59. package/dist/groups/mutations.js +1 -1
  60. package/dist/hashtags/finders.js +2 -2
  61. package/dist/inviteLinks/mutations.js +2 -3
  62. package/dist/jams/export.js +5 -7
  63. package/dist/jams/finders.js +4 -1
  64. package/dist/jams/health.d.ts +6 -4
  65. package/dist/jams/health.js +15 -11
  66. package/dist/jams/helpers.js +6 -2
  67. package/dist/jams/index.js +2 -2
  68. package/dist/jams/jobs.js +1 -2
  69. package/dist/jams/livekit.js +8 -8
  70. package/dist/jams/recording.js +1 -1
  71. package/dist/jams/token.js +13 -17
  72. package/dist/jobs/index.js +7 -6
  73. package/dist/jobs/jobDetail.js +5 -6
  74. package/dist/jobs/jobLog.js +2 -3
  75. package/dist/lib/streams.js +4 -39
  76. package/dist/lib/zodDeepPartial.d.ts +1 -1
  77. package/dist/lib/zodDeepPartial.js +1 -1
  78. package/dist/log/index.js +13 -29
  79. package/dist/media/index.js +50 -4
  80. package/dist/media/jobs.js +1 -2
  81. package/dist/media/openpeeps/index.js +11 -46
  82. package/dist/media/processing.js +7 -4
  83. package/dist/media/streaming.js +5 -5
  84. package/dist/media/streamingCleanupJobs.js +1 -2
  85. package/dist/media/streamingJobs.js +3 -4
  86. package/dist/media/streamingPrewarm.js +7 -11
  87. package/dist/mediaAttachments/index.js +6 -2
  88. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  89. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  90. package/dist/notifications/defaultNotifications/follow/index.js +14 -17
  91. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  92. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  93. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  94. package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
  95. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  96. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  97. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  98. package/dist/notifications/defaultNotifications/newGroupPost/index.js +6 -7
  99. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  100. package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
  101. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
  102. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  103. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  104. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  105. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  106. package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
  107. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
  108. package/dist/notifications/fcmCredential.js +1 -1
  109. package/dist/notifications/finders.js +1 -1
  110. package/dist/notifications/helpers.js +13 -10
  111. package/dist/notifications/jobs.js +10 -7
  112. package/dist/notifications/mutations.js +4 -1
  113. package/dist/notifications/push.js +11 -16
  114. package/dist/performance/index.js +3 -3
  115. package/dist/plugins/helpers.js +3 -6
  116. package/dist/plugins/index.js +2 -3
  117. package/dist/plugins/install.js +31 -17
  118. package/dist/plugins/pluginAuth.js +3 -4
  119. package/dist/plugins/state.js +2 -3
  120. package/dist/posts/activity.js +1 -2
  121. package/dist/posts/contextClosure.js +1 -2
  122. package/dist/posts/conversationQueries.js +2 -4
  123. package/dist/posts/eventAgenda.js +8 -5
  124. package/dist/posts/eventOccurrences.js +2 -2
  125. package/dist/posts/finders.d.ts +42 -2
  126. package/dist/posts/finders.js +21 -9
  127. package/dist/posts/helpers/filters.js +2 -3
  128. package/dist/posts/helpers/index.d.ts +152 -0
  129. package/dist/posts/helpers/index.js +43 -27
  130. package/dist/posts/mapping.d.ts +546 -14
  131. package/dist/posts/mapping.js +60 -18
  132. package/dist/posts/mutations.d.ts +76 -0
  133. package/dist/posts/mutations.js +46 -31
  134. package/dist/posts/pollEnd.js +3 -6
  135. package/dist/posts/rsvpConfirmationEmail.js +18 -8
  136. package/dist/posts/threadPreview.js +1 -1
  137. package/dist/processingStats/queries.js +6 -7
  138. package/dist/profileSettings/cache.js +1 -2
  139. package/dist/profiles/activitySummary.js +23 -28
  140. package/dist/profiles/cache.js +15 -8
  141. package/dist/profiles/export.js +30 -39
  142. package/dist/profiles/finders.js +7 -5
  143. package/dist/profiles/mutations.js +3 -5
  144. package/dist/redis/connection.js +1 -1
  145. package/dist/reports/helpers.js +7 -3
  146. package/dist/roles/mutations.js +20 -21
  147. package/dist/search/finders.js +15 -3
  148. package/dist/search/helpers.js +1 -1
  149. package/dist/sentry/index.js +9 -11
  150. package/dist/seo/index.d.ts +50 -0
  151. package/dist/seo/index.js +145 -0
  152. package/dist/seo/route.d.ts +18 -0
  153. package/dist/seo/route.js +19 -0
  154. package/dist/server/index.d.ts +1 -0
  155. package/dist/server/index.js +16 -11
  156. package/dist/server/status.js +6 -7
  157. package/dist/session/index.js +2 -2
  158. package/dist/stats/finders.js +13 -4
  159. package/dist/stats/helpers.js +4 -1
  160. package/dist/stats/mapping.d.ts +39 -1
  161. package/dist/stats/mapping.js +9 -2
  162. package/dist/stripe/cache.js +5 -6
  163. package/dist/stripe/connection.js +3 -4
  164. package/dist/stripe/helpers.js +15 -20
  165. package/package.json +5 -6
@@ -1,26 +1,85 @@
1
1
  import { boolean, index, jsonb, pgTable, text, timestamp, uniqueIndex, uuid, } from 'drizzle-orm/pg-core';
2
2
  import { sql } from 'drizzle-orm';
3
3
  import { idColumn, modelTimestamps, tsvector } from './base.js';
4
- export const configs = pgTable('configs', Object.assign({ key: text('key').primaryKey(), body: jsonb('body').notNull() }, modelTimestamps));
5
- export const i18nEntries = pgTable('i18n', Object.assign({ id: idColumn(), locale: text('locale').notNull(), namespace: text('namespace').notNull(), body: jsonb('body').notNull() }, modelTimestamps), (t) => [uniqueIndex('i18n_locale_namespace').on(t.locale, t.namespace)]);
6
- export const accounts = pgTable('accounts', Object.assign({ id: idColumn(), email: text('email').notNull(), passwordHash: text('password_hash').notNull(), emailValidated: boolean('email_validated').notNull().default(false), guest: boolean('guest') }, modelTimestamps), (t) => [uniqueIndex('accounts_email_unique').on(t.email)]);
7
- export const profiles = pgTable('profiles', Object.assign({ id: idColumn(), handle: text('handle').notNull(), activityPubDomain: text('activity_pub_domain'), type: text('type').notNull(), uri: text('uri'), inboxUrl: text('inbox_url'), sharedInboxUrl: text('shared_inbox_url'), publicKeyPem: text('public_key_pem'), privateKeyPem: text('private_key_pem'), keyId: text('key_id'), fetchedAt: timestamp('fetched_at', { withTimezone: true, mode: 'string' }), body: jsonb('body').notNull().default({}), searchVector: tsvector('search_vector') }, modelTimestamps), (t) => [
4
+ export const configs = pgTable('configs', {
5
+ key: text('key').primaryKey(),
6
+ body: jsonb('body').notNull(),
7
+ ...modelTimestamps,
8
+ });
9
+ export const i18nEntries = pgTable('i18n', {
10
+ id: idColumn(),
11
+ locale: text('locale').notNull(),
12
+ namespace: text('namespace').notNull(),
13
+ body: jsonb('body').notNull(),
14
+ ...modelTimestamps,
15
+ }, (t) => [uniqueIndex('i18n_locale_namespace').on(t.locale, t.namespace)]);
16
+ export const accounts = pgTable('accounts', {
17
+ id: idColumn(),
18
+ email: text('email').notNull(),
19
+ passwordHash: text('password_hash').notNull(),
20
+ emailValidated: boolean('email_validated').notNull().default(false),
21
+ guest: boolean('guest'),
22
+ ...modelTimestamps,
23
+ }, (t) => [uniqueIndex('accounts_email_unique').on(t.email)]);
24
+ export const profiles = pgTable('profiles', {
25
+ id: idColumn(),
26
+ handle: text('handle').notNull(),
27
+ activityPubDomain: text('activity_pub_domain'),
28
+ type: text('type').notNull(),
29
+ uri: text('uri'),
30
+ inboxUrl: text('inbox_url'),
31
+ sharedInboxUrl: text('shared_inbox_url'),
32
+ publicKeyPem: text('public_key_pem'),
33
+ privateKeyPem: text('private_key_pem'),
34
+ keyId: text('key_id'),
35
+ fetchedAt: timestamp('fetched_at', { withTimezone: true, mode: 'string' }),
36
+ body: jsonb('body').notNull().default({}),
37
+ searchVector: tsvector('search_vector'),
38
+ ...modelTimestamps,
39
+ }, (t) => [
8
40
  uniqueIndex('profiles_handle_domain_unique').on(t.handle, t.activityPubDomain),
9
41
  uniqueIndex('profiles_uri_unique').on(t.uri),
10
42
  index('profiles_search_vector_idx').using('gin', t.searchVector),
11
43
  ]);
12
- export const roles = pgTable('roles', Object.assign({ id: idColumn(), key: text('key').notNull(), isDefault: boolean('is_default').notNull().default(false), body: jsonb('body').notNull().default({}) }, modelTimestamps), (t) => [uniqueIndex('roles_key_unique').on(t.key)]);
13
- export const hashtags = pgTable('hashtags', Object.assign({ id: idColumn(), name: text('name').notNull() }, modelTimestamps), (t) => [uniqueIndex('hashtags_name_unique').on(t.name)]);
14
- export const groups = pgTable('groups', Object.assign({ id: idColumn(), handle: text('handle').notNull(), body: jsonb('body').notNull().default({}), searchVector: tsvector('search_vector') }, modelTimestamps), (t) => [
44
+ export const roles = pgTable('roles', {
45
+ id: idColumn(),
46
+ key: text('key').notNull(),
47
+ isDefault: boolean('is_default').notNull().default(false),
48
+ body: jsonb('body').notNull().default({}),
49
+ ...modelTimestamps,
50
+ }, (t) => [uniqueIndex('roles_key_unique').on(t.key)]);
51
+ export const hashtags = pgTable('hashtags', {
52
+ id: idColumn(),
53
+ name: text('name').notNull(),
54
+ ...modelTimestamps,
55
+ }, (t) => [uniqueIndex('hashtags_name_unique').on(t.name)]);
56
+ export const groups = pgTable('groups', {
57
+ id: idColumn(),
58
+ handle: text('handle').notNull(),
59
+ body: jsonb('body').notNull().default({}),
60
+ searchVector: tsvector('search_vector'),
61
+ ...modelTimestamps,
62
+ }, (t) => [
15
63
  uniqueIndex('groups_handle_unique').on(t.handle),
16
64
  index('groups_search_vector_idx').using('gin', t.searchVector),
17
65
  ]);
18
- export const posts = pgTable('posts', Object.assign({ id: idColumn(), type: text('type').notNull(), visibility: text('visibility').notNull(), creatorId: text('creator_id').notNull(), uri: text('uri'), inReplyToUri: text('in_reply_to_uri'), body: jsonb('body').notNull().default({}), searchVector: tsvector('search_vector'), lastActivityAt: timestamp('last_activity_at', {
66
+ export const posts = pgTable('posts', {
67
+ id: idColumn(),
68
+ type: text('type').notNull(),
69
+ visibility: text('visibility').notNull(),
70
+ creatorId: text('creator_id').notNull(),
71
+ uri: text('uri'),
72
+ inReplyToUri: text('in_reply_to_uri'),
73
+ body: jsonb('body').notNull().default({}),
74
+ searchVector: tsvector('search_vector'),
75
+ lastActivityAt: timestamp('last_activity_at', {
19
76
  withTimezone: true,
20
77
  mode: 'string',
21
78
  })
22
79
  .notNull()
23
- .default(sql `now()`) }, modelTimestamps), (t) => [
80
+ .default(sql `now()`),
81
+ ...modelTimestamps,
82
+ }, (t) => [
24
83
  index('posts_type_idx').on(t.type),
25
84
  index('posts_visibility_idx').on(t.visibility),
26
85
  index('posts_creator_idx').on(t.creatorId),
@@ -29,18 +88,60 @@ export const posts = pgTable('posts', Object.assign({ id: idColumn(), type: text
29
88
  index('posts_search_vector_idx').using('gin', t.searchVector),
30
89
  index('posts_last_activity_id_idx').on(t.lastActivityAt, t.id),
31
90
  ]);
32
- export const notifications = pgTable('notifications', Object.assign({ id: idColumn(), profileId: text('profile_id').notNull(), body: jsonb('body').notNull().default({}) }, modelTimestamps), (t) => [index('notifications_profile_idx').on(t.profileId)]);
33
- export const reports = pgTable('reports', Object.assign({ id: idColumn(), body: jsonb('body').notNull().default({}) }, modelTimestamps));
34
- export const accessTokens = pgTable('access_tokens', Object.assign({ id: idColumn(), body: jsonb('body').notNull().default({}) }, modelTimestamps));
35
- export const pushSubscriptions = pgTable('push_subscriptions', Object.assign({ id: idColumn(), body: jsonb('body').notNull().default({}) }, modelTimestamps));
36
- export const inviteLinks = pgTable('invite_links', Object.assign({ id: idColumn(), slug: text('slug').notNull(), body: jsonb('body').notNull().default({}) }, modelTimestamps), (t) => [uniqueIndex('invite_links_slug_unique').on(t.slug)]);
37
- export const jamEvents = pgTable('jam_events', Object.assign({ id: idColumn(), postId: text('post_id').notNull(), body: jsonb('body').notNull().default({}) }, modelTimestamps), (t) => [index('jam_events_post_idx').on(t.postId)]);
38
- export const mediaAttachments = pgTable('media_attachments', Object.assign({ id: idColumn(), body: jsonb('body').notNull().default({}) }, modelTimestamps));
39
- export const processingStats = pgTable('processing_stats', Object.assign({ id: idColumn(), filetype: text('filetype').notNull(), filesize: text('filesize').notNull(), body: jsonb('body').notNull().default({}) }, modelTimestamps), (t) => [
91
+ export const notifications = pgTable('notifications', {
92
+ id: idColumn(),
93
+ profileId: text('profile_id').notNull(),
94
+ body: jsonb('body').notNull().default({}),
95
+ ...modelTimestamps,
96
+ }, (t) => [index('notifications_profile_idx').on(t.profileId)]);
97
+ export const reports = pgTable('reports', {
98
+ id: idColumn(),
99
+ body: jsonb('body').notNull().default({}),
100
+ ...modelTimestamps,
101
+ });
102
+ export const accessTokens = pgTable('access_tokens', {
103
+ id: idColumn(),
104
+ body: jsonb('body').notNull().default({}),
105
+ ...modelTimestamps,
106
+ });
107
+ export const pushSubscriptions = pgTable('push_subscriptions', {
108
+ id: idColumn(),
109
+ body: jsonb('body').notNull().default({}),
110
+ ...modelTimestamps,
111
+ });
112
+ export const inviteLinks = pgTable('invite_links', {
113
+ id: idColumn(),
114
+ slug: text('slug').notNull(),
115
+ body: jsonb('body').notNull().default({}),
116
+ ...modelTimestamps,
117
+ }, (t) => [uniqueIndex('invite_links_slug_unique').on(t.slug)]);
118
+ export const jamEvents = pgTable('jam_events', {
119
+ id: idColumn(),
120
+ postId: text('post_id').notNull(),
121
+ body: jsonb('body').notNull().default({}),
122
+ ...modelTimestamps,
123
+ }, (t) => [index('jam_events_post_idx').on(t.postId)]);
124
+ export const mediaAttachments = pgTable('media_attachments', {
125
+ id: idColumn(),
126
+ body: jsonb('body').notNull().default({}),
127
+ ...modelTimestamps,
128
+ });
129
+ export const processingStats = pgTable('processing_stats', {
130
+ id: idColumn(),
131
+ filetype: text('filetype').notNull(),
132
+ filesize: text('filesize').notNull(),
133
+ body: jsonb('body').notNull().default({}),
134
+ ...modelTimestamps,
135
+ }, (t) => [
40
136
  index('processing_stats_filetype_idx').on(t.filetype),
41
137
  index('processing_stats_filetype_size_idx').on(t.filetype, t.filesize),
42
138
  ]);
43
- export const profileSettings = pgTable('profile_settings', Object.assign({ id: idColumn(), profileId: text('profile_id').notNull(), body: jsonb('body').notNull().default({}) }, modelTimestamps), (t) => [uniqueIndex('profile_settings_profile_unique').on(t.profileId)]);
139
+ export const profileSettings = pgTable('profile_settings', {
140
+ id: idColumn(),
141
+ profileId: text('profile_id').notNull(),
142
+ body: jsonb('body').notNull().default({}),
143
+ ...modelTimestamps,
144
+ }, (t) => [uniqueIndex('profile_settings_profile_unique').on(t.profileId)]);
44
145
  export const eventOccurrences = pgTable('event_occurrences', {
45
146
  id: idColumn(),
46
147
  postId: uuid('post_id').notNull(),
@@ -1,6 +1,12 @@
1
1
  import { index, jsonb, pgTable, text, uniqueIndex } from 'drizzle-orm/pg-core';
2
2
  import { edgeTimestamps, idColumn } from './base.js';
3
- const edgeTable = (name, uniqueFromTo = false) => pgTable(name, Object.assign({ id: idColumn(), fromId: text('from_id').notNull(), toId: text('to_id').notNull(), body: jsonb('body').default({}) }, edgeTimestamps), (t) => [
3
+ const edgeTable = (name, uniqueFromTo = false) => pgTable(name, {
4
+ id: idColumn(),
5
+ fromId: text('from_id').notNull(),
6
+ toId: text('to_id').notNull(),
7
+ body: jsonb('body').default({}),
8
+ ...edgeTimestamps,
9
+ }, (t) => [
4
10
  index(`${name}_from_idx`).on(t.fromId),
5
11
  index(`${name}_to_idx`).on(t.toId),
6
12
  ...(uniqueFromTo
@@ -4,4 +4,8 @@ export * from './analytics.js';
4
4
  import * as documents from './documents.js';
5
5
  import * as edges from './edges.js';
6
6
  import * as analytics from './analytics.js';
7
- export const schema = Object.assign(Object.assign(Object.assign({}, documents), edges), analytics);
7
+ export const schema = {
8
+ ...documents,
9
+ ...edges,
10
+ ...analytics,
11
+ };
@@ -0,0 +1,54 @@
1
+ CREATE OR REPLACE FUNCTION openpeeps_posts_search_vector(p_body jsonb) RETURNS tsvector
2
+ LANGUAGE sql
3
+ STABLE
4
+ AS $$
5
+ SELECT to_tsvector('english', trim(
6
+ coalesce(p_body->>'content', '') || ' ' ||
7
+ coalesce(p_body->>'title', '') || ' ' ||
8
+ coalesce(p_body->>'name', '') || ' ' ||
9
+ coalesce(p_body->'physicalLocation'->>'text', '') || ' ' ||
10
+ coalesce(p_body->>'url', '') || ' ' ||
11
+ coalesce((
12
+ SELECT string_agg(tag, ' ')
13
+ FROM jsonb_array_elements_text(
14
+ CASE
15
+ WHEN jsonb_typeof(p_body->'tags') = 'array' THEN p_body->'tags'
16
+ ELSE '[]'::jsonb
17
+ END
18
+ ) AS tag
19
+ ), '') || ' ' ||
20
+ coalesce((
21
+ SELECT string_agg(segment, ' ')
22
+ FROM jsonb_array_elements_text(
23
+ CASE
24
+ WHEN jsonb_typeof(p_body->'categoryPath') = 'array'
25
+ THEN p_body->'categoryPath'
26
+ ELSE '[]'::jsonb
27
+ END
28
+ ) AS segment
29
+ ), '') || ' ' ||
30
+ coalesce((
31
+ SELECT string_agg(o->>'content', ' ')
32
+ FROM jsonb_array_elements(
33
+ CASE
34
+ WHEN jsonb_typeof(p_body->'options') = 'array' THEN p_body->'options'
35
+ ELSE '[]'::jsonb
36
+ END
37
+ ) AS o
38
+ ), '') || ' ' ||
39
+ coalesce((
40
+ SELECT string_agg(
41
+ coalesce(a->>'description', '') || ' ' || coalesce(a->>'filename', ''),
42
+ ' '
43
+ )
44
+ FROM jsonb_array_elements(
45
+ CASE
46
+ WHEN jsonb_typeof(p_body->'attachments') = 'array' THEN p_body->'attachments'
47
+ ELSE '[]'::jsonb
48
+ END
49
+ ) AS a
50
+ ), '')
51
+ ));
52
+ $$;
53
+ --> statement-breakpoint
54
+ UPDATE "posts" SET "search_vector" = openpeeps_posts_search_vector("body");
@@ -113,6 +113,13 @@
113
113
  "when": 1790593758508,
114
114
  "tag": "0015_profile_hashtags",
115
115
  "breakpoints": true
116
+ },
117
+ {
118
+ "idx": 16,
119
+ "version": "7",
120
+ "when": 1791620000000,
121
+ "tag": "0016_posts_search_vector_title_tags_path",
122
+ "breakpoints": true
116
123
  }
117
124
  ]
118
- }
125
+ }
@@ -48,7 +48,7 @@ const replaceOriginInUrl = (urlValue, oldHostname, newOrigin) => {
48
48
  }
49
49
  return newOriginTrimmed + rest;
50
50
  }
51
- catch (_a) {
51
+ catch {
52
52
  return urlValue;
53
53
  }
54
54
  };
@@ -1,5 +1,5 @@
1
1
  import { SEND_EMAIL_QUEUE_NAME, sendEmailQueue } from './jobs.js';
2
- const n = (record, key) => { var _a; return (_a = record[key]) !== null && _a !== void 0 ? _a : 0; };
2
+ const n = (record, key) => record[key] ?? 0;
3
3
  export const getSendEmailQueueStats = async () => {
4
4
  const queue = sendEmailQueue();
5
5
  const raw = await queue.getJobCounts();
@@ -13,15 +13,12 @@ export const getSendEmailQueueStats = async () => {
13
13
  delayed: n(raw, 'delayed'),
14
14
  prioritized: n(raw, 'prioritized'),
15
15
  },
16
- recentFailures: failedJobs.map((j) => {
17
- var _a, _b, _c;
18
- return ({
19
- queue: SEND_EMAIL_QUEUE_NAME,
20
- id: (_a = j.id) !== null && _a !== void 0 ? _a : null,
21
- name: j.name,
22
- failedReason: (_b = j.failedReason) !== null && _b !== void 0 ? _b : '',
23
- finishedOn: (_c = j.finishedOn) !== null && _c !== void 0 ? _c : null,
24
- });
25
- }),
16
+ recentFailures: failedJobs.map((j) => ({
17
+ queue: SEND_EMAIL_QUEUE_NAME,
18
+ id: j.id ?? null,
19
+ name: j.name,
20
+ failedReason: j.failedReason ?? '',
21
+ finishedOn: j.finishedOn ?? null,
22
+ })),
26
23
  };
27
24
  };
@@ -5,11 +5,10 @@ import { registeredTemplates } from './registry.js';
5
5
  import { serverRootUrl } from '../server/index.js';
6
6
  import { initI18nEmailContext } from '../i18n/index.js';
7
7
  const localTimeZone = (locals) => {
8
- const value = locals === null || locals === void 0 ? void 0 : locals.timeZone;
8
+ const value = locals?.timeZone;
9
9
  return typeof value === 'string' ? value : undefined;
10
10
  };
11
11
  const globals = async (locals) => {
12
- var _a;
13
12
  const serverConfig = await config();
14
13
  const rootUrl = await serverRootUrl();
15
14
  const community = await communityConfig();
@@ -21,7 +20,7 @@ const globals = async (locals) => {
21
20
  androidUrl: serverConfig.apps.android.url,
22
21
  },
23
22
  i18nContext: await initI18nEmailContext(),
24
- timeZone: resolveTimeZone(localTimeZone(locals), (_a = community.settings) === null || _a === void 0 ? void 0 : _a.defaultTimeZone, FALLBACK_TIME_ZONE),
23
+ timeZone: resolveTimeZone(localTimeZone(locals), community.settings?.defaultTimeZone, FALLBACK_TIME_ZONE),
25
24
  };
26
25
  };
27
26
  export const render = async (emailData) => {
@@ -30,7 +29,11 @@ export const render = async (emailData) => {
30
29
  if (!render) {
31
30
  throw Error(`No renderer registered for ${emailData.template}`);
32
31
  }
33
- const { html, subject } = await render(Object.assign(Object.assign({}, emailData), { globals: await globals(locals), locals: locals || {} }));
32
+ const { html, subject } = await render({
33
+ ...emailData,
34
+ globals: await globals(locals),
35
+ locals: locals || {},
36
+ });
34
37
  const text = convert(html);
35
38
  return {
36
39
  to: emailData.to,
@@ -10,16 +10,15 @@ const logStep = async (log, message) => {
10
10
  serverLog.info(message);
11
11
  };
12
12
  const formatTransportSummary = (transportConfig) => {
13
- var _a;
14
13
  if (!transportConfig)
15
14
  return '(no transport config)';
16
15
  const { host, port, secure, auth } = transportConfig;
17
16
  return JSON.stringify({
18
- host: host !== null && host !== void 0 ? host : null,
19
- port: port !== null && port !== void 0 ? port : null,
20
- secure: secure !== null && secure !== void 0 ? secure : null,
21
- authUser: (_a = auth === null || auth === void 0 ? void 0 : auth.user) !== null && _a !== void 0 ? _a : null,
22
- authPass: (auth === null || auth === void 0 ? void 0 : auth.pass) ? '[set]' : auth ? '[empty]' : null,
17
+ host: host ?? null,
18
+ port: port ?? null,
19
+ secure: secure ?? null,
20
+ authUser: auth?.user ?? null,
21
+ authPass: auth?.pass ? '[set]' : auth ? '[empty]' : null,
23
22
  });
24
23
  };
25
24
  const formatErrorDetail = (err) => {
@@ -48,11 +47,10 @@ const logFailure = async (log, err) => {
48
47
  }
49
48
  };
50
49
  export const sendEmail = async (emailData, coreConfig, options) => {
51
- var _a, _b, _c, _d, _e, _f;
52
- const log = options === null || options === void 0 ? void 0 : options.log;
53
- const localKeys = Object.keys((_a = emailData.locals) !== null && _a !== void 0 ? _a : {});
50
+ const log = options?.log;
51
+ const localKeys = Object.keys(emailData.locals ?? {});
54
52
  await logStep(log, `Template "${emailData.template}" → ${emailData.to}${localKeys.length ? ` (locals: ${localKeys.join(', ')})` : ''}`);
55
- await logStep(log, `defaultFrom=${(_b = coreConfig.email.defaultFrom) !== null && _b !== void 0 ? _b : '(unset)'}`);
53
+ await logStep(log, `defaultFrom=${coreConfig.email.defaultFrom ?? '(unset)'}`);
56
54
  await logStep(log, `SMTP transport: ${formatTransportSummary(coreConfig.email.transportConfig)}`);
57
55
  let renderedEmail;
58
56
  await logStep(log, 'Render in-process (worker templates)');
@@ -72,11 +70,16 @@ export const sendEmail = async (emailData, coreConfig, options) => {
72
70
  }
73
71
  const emailTransport = nodemailer.createTransport(coreConfig.email.transportConfig);
74
72
  try {
75
- const result = await emailTransport.sendMail(Object.assign(Object.assign({ from, replyTo: communityConf.info.contactEmail }, renderedEmail), (((_c = emailData.attachments) === null || _c === void 0 ? void 0 : _c.length)
76
- ? { attachments: emailData.attachments }
77
- : {})));
78
- await logStep(log, `SMTP accepted message (messageId: ${(_d = result.messageId) !== null && _d !== void 0 ? _d : 'n/a'}, response: ${(_e = result.response) !== null && _e !== void 0 ? _e : 'n/a'})`);
79
- if ((_f = result.rejected) === null || _f === void 0 ? void 0 : _f.length) {
73
+ const result = await emailTransport.sendMail({
74
+ from,
75
+ replyTo: communityConf.info.contactEmail,
76
+ ...renderedEmail,
77
+ ...(emailData.attachments?.length
78
+ ? { attachments: emailData.attachments }
79
+ : {}),
80
+ });
81
+ await logStep(log, `SMTP accepted message (messageId: ${result.messageId ?? 'n/a'}, response: ${result.response ?? 'n/a'})`);
82
+ if (result.rejected?.length) {
80
83
  await logStep(log, `SMTP rejected recipients: ${result.rejected.join(', ')}`);
81
84
  }
82
85
  return result;
@@ -87,10 +90,9 @@ export const sendEmail = async (emailData, coreConfig, options) => {
87
90
  }
88
91
  };
89
92
  export const send = async (job) => {
90
- var _a;
91
93
  const log = (message) => job.log(message).then(() => undefined);
92
94
  const attempt = job.attemptsMade + 1;
93
- await logStep(log, `Job ${job.id} started (attempt ${attempt}/${(_a = job.opts.attempts) !== null && _a !== void 0 ? _a : 1}, name="${job.name}")`);
95
+ await logStep(log, `Job ${job.id} started (attempt ${attempt}/${job.opts.attempts ?? 1}, name="${job.name}")`);
94
96
  const coreConfig = await config();
95
97
  await logStep(log, 'Loaded core config');
96
98
  return sendEmail(job.data, coreConfig, { log });
@@ -3,24 +3,28 @@ import { passwordPlaceHolder } from '@openpeepshq/common/types';
3
3
  import { config } from '../config/index.js';
4
4
  import { sendEmail } from './send.js';
5
5
  const mergeEmailForTest = (base, override) => {
6
- var _a, _b, _c;
7
6
  if (!override) {
8
7
  return base;
9
8
  }
10
9
  const merged = deepmerge(base, override);
11
- const pass = (_b = (_a = override.transportConfig) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.pass;
10
+ const pass = override.transportConfig?.auth?.pass;
12
11
  if (pass === undefined || pass === '' || pass === passwordPlaceHolder) {
13
- merged.transportConfig = Object.assign(Object.assign({}, merged.transportConfig), { auth: Object.assign(Object.assign({}, merged.transportConfig.auth), { pass: (_c = base.transportConfig.auth) === null || _c === void 0 ? void 0 : _c.pass }) });
12
+ merged.transportConfig = {
13
+ ...merged.transportConfig,
14
+ auth: {
15
+ ...merged.transportConfig.auth,
16
+ pass: base.transportConfig.auth?.pass,
17
+ },
18
+ };
14
19
  }
15
20
  return merged;
16
21
  };
17
22
  export const sendSmtpTestEmail = async (input) => {
18
- var _a;
19
23
  const saved = await config();
20
24
  const emailSettings = mergeEmailForTest(saved.email, input.email);
21
- if (!((_a = emailSettings.defaultFrom) === null || _a === void 0 ? void 0 : _a.trim())) {
25
+ if (!emailSettings.defaultFrom?.trim()) {
22
26
  throw new Error('defaultFrom is required to send mail');
23
27
  }
24
- const draftConfig = Object.assign(Object.assign({}, saved), { email: emailSettings });
28
+ const draftConfig = { ...saved, email: emailSettings };
25
29
  await sendEmail({ to: input.to, template: 'test' }, draftConfig);
26
30
  };
@@ -10,4 +10,4 @@ export const notFound = ({ errorKey = 'notFound', parameters, }) => allPeepError
10
10
  export const conflict = ({ errorKey = 'conflict', parameters, }) => allPeepError({ code: 409, errorKey, parameters });
11
11
  export const unprocessableRequest = ({ errorKey = 'unprocessableRequest', parameters, }) => allPeepError({ code: 422, errorKey, parameters });
12
12
  export const internalError = ({ errorKey = 'internalError', parameters, }) => allPeepError({ code: 500, errorKey, parameters });
13
- export const isOpenpeepsError = (o) => o === null || o === void 0 ? void 0 : o.__allPeepError__;
13
+ export const isOpenpeepsError = (o) => o?.__allPeepError__;
@@ -1,19 +1,17 @@
1
1
  import { queueAndWorker } from '../jobs/index.js';
2
2
  export const registeredHandlers = new Map();
3
3
  export const registerOnceHandler = (qualifiedEventType, handler) => {
4
- var _a;
5
4
  if (registeredHandlers.has(qualifiedEventType)) {
6
- (_a = registeredHandlers.get(qualifiedEventType)) === null || _a === void 0 ? void 0 : _a.push(handler);
5
+ registeredHandlers.get(qualifiedEventType)?.push(handler);
7
6
  }
8
7
  else {
9
8
  registeredHandlers.set(qualifiedEventType, [handler]);
10
9
  }
11
10
  };
12
11
  const [onceQueue, onceWorker] = queueAndWorker('once', async (job) => {
13
- var _a;
14
12
  const event = job.name;
15
13
  const args = job.data;
16
- return Promise.all(((_a = registeredHandlers.get(event)) !== null && _a !== void 0 ? _a : []).map((handler) => handler(...args)));
14
+ return Promise.all((registeredHandlers.get(event) ?? []).map((handler) => handler(...args)));
17
15
  }, {
18
16
  defaultJobOptions: {
19
17
  removeOnComplete: { age: 3600 }, // Remove successful tasks after 1 hour
@@ -2,7 +2,6 @@ import { eq } from 'drizzle-orm';
2
2
  import { pgDb } from '../db/pg/client.js';
3
3
  import { apActivities } from '../db/pg/schema/documents.js';
4
4
  export const recordApActivity = async (activity) => {
5
- var _a;
6
5
  const db = pgDb();
7
6
  await db
8
7
  .insert(apActivities)
@@ -10,7 +9,7 @@ export const recordApActivity = async (activity) => {
10
9
  uri: activity.uri,
11
10
  type: activity.type,
12
11
  actorUri: activity.actorUri,
13
- objectUri: (_a = activity.objectUri) !== null && _a !== void 0 ? _a : null,
12
+ objectUri: activity.objectUri ?? null,
14
13
  direction: activity.direction,
15
14
  })
16
15
  .onConflictDoNothing();
@@ -6,8 +6,7 @@ export const addMember = connector(collectionInfos.profilesCollection, collectio
6
6
  export const removeMember = disconnector(collectionInfos.profilesCollection, collectionInfos.groupsCollection, collectionInfos.userGroupsCollection);
7
7
  export const updateMember = connectionUpdater(collectionInfos.profilesCollection, collectionInfos.groupsCollection, collectionInfos.userGroupsCollection);
8
8
  export const canSeeGroupFilter = (profile) => {
9
- var _a;
10
- if (checkRoleCapabilities((_a = profile === null || profile === void 0 ? void 0 : profile.roles) !== null && _a !== void 0 ? _a : [], ['core-groups-read']).success) {
9
+ if (checkRoleCapabilities(profile?.roles ?? [], ['core-groups-read']).success) {
11
10
  return undefined;
12
11
  }
13
12
  if (!profile || !isLocal(profile)) {
@@ -13,7 +13,7 @@ export const createGroup = async (groupData, profile, members = []) => {
13
13
  roles: ['owner'],
14
14
  });
15
15
  profilesCache.del(profile.id);
16
- const filteredMembers = members === null || members === void 0 ? void 0 : members.filter((member) => member.id !== profile.id);
16
+ const filteredMembers = members?.filter((member) => member.id !== profile.id);
17
17
  const uniqueMembers = filteredMembers
18
18
  ? Array.from(new Set(filteredMembers.map((m) => m.id))).map((id) => filteredMembers.find((m) => m.id === id))
19
19
  : [];
@@ -20,5 +20,5 @@ export const findOrCreateHashtag = async (tag) => {
20
20
  }
21
21
  return hashtagsMapping.create(db, { tag: normalizedTag });
22
22
  };
23
- export const listFollowedHashtags = (profile) => { var _a; return (_a = profile.followedHashtags) !== null && _a !== void 0 ? _a : []; };
24
- export const isFollowingHashtag = (profile, hashtag) => { var _a, _b; return (_b = (_a = profile.followedHashtags) === null || _a === void 0 ? void 0 : _a.some((h) => h.id === hashtag.id)) !== null && _b !== void 0 ? _b : false; };
23
+ export const listFollowedHashtags = (profile) => profile.followedHashtags ?? [];
24
+ export const isFollowingHashtag = (profile, hashtag) => profile.followedHashtags?.some((h) => h.id === hashtag.id) ?? false;
@@ -18,12 +18,11 @@ export const updateInviteLink = async (id, inviteLinkData) => {
18
18
  return inviteLinksMapping.update(db, id, inviteLinkData);
19
19
  };
20
20
  export const redeemInviteLink = async (inviteLink, profile) => {
21
- var _a, _b;
22
- if (((_a = inviteLink.profile) === null || _a === void 0 ? void 0 : _a.id) === profile.id) {
21
+ if (inviteLink.profile?.id === profile.id) {
23
22
  throw new Error('Invite link creator and redeemer cannot be the same');
24
23
  }
25
24
  await allpeepDb().then(({ db }) => redeemInviteLinkConnector(db, profile, inviteLink));
26
- const groupIds = [...new Set((_b = inviteLink.groupIds) !== null && _b !== void 0 ? _b : [])];
25
+ const groupIds = [...new Set(inviteLink.groupIds ?? [])];
27
26
  const adder = inviteLink.profile;
28
27
  for (const groupId of groupIds) {
29
28
  const group = await findGroup(groupId);
@@ -12,14 +12,13 @@ export const jamAttendanceExportHeaders = [
12
12
  'Joined At',
13
13
  ];
14
14
  export const jamAttendanceRowFromJoin = (join, profile) => {
15
- var _a, _b, _c, _d;
16
- const isPublic = (profile === null || profile === void 0 ? void 0 : profile.type) === 'guest';
15
+ const isPublic = profile?.type === 'guest';
17
16
  return {
18
17
  kind: profile ? (isPublic ? 'public' : 'community') : '',
19
- name: (profile === null || profile === void 0 ? void 0 : profile.displayName) || (isPublic ? '' : ((_a = profile === null || profile === void 0 ? void 0 : profile.handle) !== null && _a !== void 0 ? _a : '')),
18
+ name: profile?.displayName || (isPublic ? '' : (profile?.handle ?? '')),
20
19
  // Community emails aren't here: several accounts can control one profile.
21
- email: isPublic ? ((_c = (_b = profile === null || profile === void 0 ? void 0 : profile.guestData) === null || _b === void 0 ? void 0 : _b.email) !== null && _c !== void 0 ? _c : '') : '',
22
- handle: isPublic ? '' : ((_d = profile === null || profile === void 0 ? void 0 : profile.handle) !== null && _d !== void 0 ? _d : ''),
20
+ email: isPublic ? (profile?.guestData?.email ?? '') : '',
21
+ handle: isPublic ? '' : (profile?.handle ?? ''),
23
22
  joinedAt: join.createdAt,
24
23
  };
25
24
  };
@@ -38,8 +37,7 @@ const listJamJoinEvents = async (jamId) => {
38
37
  .where(and(eq(jamEvents.postId, jamId), isNull(jamEvents.deletedAt), sql `${jamEvents.body}->>'type' = 'join'`))
39
38
  .orderBy(asc(jamEvents.createdAt), asc(jamEvents.id));
40
39
  return rows.flatMap((row) => {
41
- var _a;
42
- const profileId = (_a = row.body) === null || _a === void 0 ? void 0 : _a.profileId;
40
+ const profileId = row.body?.profileId;
43
41
  if (typeof profileId !== 'string' || !profileId) {
44
42
  return [];
45
43
  }
@@ -10,7 +10,10 @@ export const listJamEvents = (jamId, { start, limit } = {}) => allpeepDb().then(
10
10
  export const listAttendance = (jamId, { start, limit } = {}) => allpeepDb().then(({ db }) => baseListJam({ jamId, type: 'join' }, { start, limit }).all(db));
11
11
  export const findJamState = async (jam, hideParticipants, recurrenceId) => {
12
12
  const state = await getJamState(jam, recurrenceId);
13
- return Object.assign(Object.assign({}, state), { participants: hideParticipants ? [] : state.participants });
13
+ return {
14
+ ...state,
15
+ participants: hideParticipants ? [] : state.participants,
16
+ };
14
17
  };
15
18
  export const findJamRecording = async (recordingId) => allpeepDb()
16
19
  .then(({ db }) => jamRecordingsMapping.find(db, recordingId))
@@ -1,8 +1,10 @@
1
- export declare const LIVEKIT_HEALTH_TIMEOUT_MS = 1500;
1
+ export declare const LIVEKIT_HEALTH_TIMEOUT_MS = 5000;
2
+ export declare const LIVEKIT_HEALTH_MAX_ATTEMPTS = 3;
2
3
  /**
3
- * True when a LiveKit RoomService call succeeds. Credentials in config are not
4
- * enough — invalid keys still construct a client, then fail on first RPC.
4
+ * True when a LiveKit RoomService call succeeds within maxAttempts. Retries so a
5
+ * single transient failure does not disable jams for a full /server/info bucket.
6
+ * Credentials in config are not enough — invalid keys fail on first RPC.
5
7
  */
6
- export declare const probeLivekitConnection: (listRooms: () => Promise<unknown>, timeoutMs?: number) => Promise<boolean>;
8
+ export declare const probeLivekitConnection: (listRooms: () => Promise<unknown>, timeoutMs?: number, maxAttempts?: number) => Promise<boolean>;
7
9
  /** Cached LiveKit reachability. False when unset, unauthorized, or unreachable. */
8
10
  export declare const isLivekitConnected: () => Promise<boolean>;