@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
@@ -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();
@@ -74,7 +74,7 @@ export declare const listAdminGroups: () => Promise<{
74
74
  postsCount: number;
75
75
  owners: {
76
76
  handle: string;
77
- type: "guest" | "local" | "federated";
77
+ type: "local" | "guest" | "federated";
78
78
  id: string;
79
79
  createdAt: string;
80
80
  updatedAt: string;
@@ -107,7 +107,7 @@ export declare const listAdminGroups: () => Promise<{
107
107
  guestData?: {
108
108
  email?: string | undefined;
109
109
  resource?: {
110
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
110
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
111
111
  id?: string | undefined;
112
112
  } | undefined;
113
113
  } | undefined;
@@ -2,7 +2,7 @@ import type { GroupWithMeta, ProfileWithMeta } from '@openpeepshq/common/types';
2
2
  import type { PgFilter } from '../db/pg/map/queryTypes';
3
3
  export declare const addMember: (db: import("../db").PgDb, from: {
4
4
  id: string;
5
- type: "guest" | "local" | "federated";
5
+ type: "local" | "guest" | "federated";
6
6
  createdAt: string;
7
7
  updatedAt: string;
8
8
  handle: string;
@@ -77,18 +77,18 @@ export declare const addMember: (db: import("../db").PgDb, from: {
77
77
  lastPostAt?: string | null | undefined;
78
78
  deletedAt?: string | null | undefined;
79
79
  }, data?: {
80
- roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
80
+ roles?: ("local" | "member" | "none" | "owner" | "moderator" | "admin" | "invited")[] | null | undefined;
81
81
  } & {
82
82
  id?: string;
83
83
  }) => Promise<import("../db/pg/map").WithId<{
84
- roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
84
+ roles?: ("local" | "member" | "none" | "owner" | "moderator" | "admin" | "invited")[] | null | undefined;
85
85
  } & {
86
86
  _from: string;
87
87
  _to: string;
88
88
  }>>;
89
89
  export declare const removeMember: (db: import("../db").PgDb, from: {
90
90
  id: string;
91
- type: "guest" | "local" | "federated";
91
+ type: "local" | "guest" | "federated";
92
92
  createdAt: string;
93
93
  updatedAt: string;
94
94
  handle: string;
@@ -165,7 +165,7 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
165
165
  }) => Promise<void>;
166
166
  export declare const updateMember: (db: import("../db").PgDb, from: {
167
167
  id: string;
168
- type: "guest" | "local" | "federated";
168
+ type: "local" | "guest" | "federated";
169
169
  createdAt: string;
170
170
  updatedAt: string;
171
171
  handle: string;
@@ -240,6 +240,6 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
240
240
  lastPostAt?: string | null | undefined;
241
241
  deletedAt?: string | null | undefined;
242
242
  }, data?: {
243
- roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
243
+ roles?: ("local" | "member" | "none" | "owner" | "moderator" | "admin" | "invited")[] | null | undefined;
244
244
  } | undefined) => Promise<void>;
245
245
  export declare const canSeeGroupFilter: (profile?: ProfileWithMeta) => PgFilter<GroupWithMeta> | undefined;
@@ -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)) {
@@ -76,7 +76,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
76
76
  postsCount: number;
77
77
  owners: {
78
78
  handle: string;
79
- type: "guest" | "local" | "federated";
79
+ type: "local" | "guest" | "federated";
80
80
  id: string;
81
81
  createdAt: string;
82
82
  updatedAt: string;
@@ -109,7 +109,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
109
109
  guestData?: {
110
110
  email?: string | undefined;
111
111
  resource?: {
112
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
112
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
113
113
  id?: string | undefined;
114
114
  } | undefined;
115
115
  } | undefined;
@@ -138,7 +138,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
138
138
  postsCount: number;
139
139
  owners: {
140
140
  handle: string;
141
- type: "guest" | "local" | "federated";
141
+ type: "local" | "guest" | "federated";
142
142
  id: string;
143
143
  createdAt: string;
144
144
  updatedAt: string;
@@ -171,7 +171,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
171
171
  guestData?: {
172
172
  email?: string | undefined;
173
173
  resource?: {
174
- type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
174
+ type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
175
175
  id?: string | undefined;
176
176
  } | undefined;
177
177
  } | undefined;
@@ -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;