@openpeepshq/core 0.1.32 → 0.1.34

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 (261) hide show
  1. package/dist/accessTokens/helpers.d.ts +2 -2
  2. package/dist/accessTokens/tokens.js +14 -7
  3. package/dist/accounts/mutations.d.ts +2 -2
  4. package/dist/accounts/mutations.js +33 -35
  5. package/dist/analytics/cache.js +12 -7
  6. package/dist/analytics/compile.js +16 -10
  7. package/dist/analytics/pdfReport.d.ts +1 -0
  8. package/dist/analytics/pdfReport.js +5 -4
  9. package/dist/analytics/privacy.d.ts +18 -0
  10. package/dist/analytics/privacy.js +10 -0
  11. package/dist/analytics/read.js +75 -19
  12. package/dist/analytics/report.d.ts +21 -1
  13. package/dist/analytics/report.js +9 -2
  14. package/dist/backups/index.js +78 -15
  15. package/dist/backups/metadata.d.ts +8 -2
  16. package/dist/backups/metadata.js +6 -2
  17. package/dist/config/defaults/capabilities.js +13 -2
  18. package/dist/config/defaults/community.js +7 -9
  19. package/dist/config/defaults/core.d.ts +1 -1
  20. package/dist/config/defaults/core.js +3 -0
  21. package/dist/config/defaults/db.d.ts +0 -2
  22. package/dist/config/defaults/db.js +0 -2
  23. package/dist/config/index.d.ts +25 -3
  24. package/dist/config/index.js +7 -1
  25. package/dist/db/helpers.d.ts +7 -28
  26. package/dist/db/helpers.js +30 -152
  27. package/dist/db/index.d.ts +3 -1
  28. package/dist/db/index.js +5 -0
  29. package/dist/db/init.js +2 -2
  30. package/dist/db/migration/importCollections.d.ts +15 -10
  31. package/dist/db/migration/importCollections.js +121 -155
  32. package/dist/db/migration/shared.d.ts +2 -37
  33. package/dist/db/migration/shared.js +2 -59
  34. package/dist/db/pg/client.js +4 -0
  35. package/dist/db/pg/collections.d.ts +2 -2
  36. package/dist/db/pg/collections.js +2 -2
  37. package/dist/db/pg/filters/edges.d.ts +1 -1
  38. package/dist/db/pg/filters/edges.js +1 -1
  39. package/dist/db/pg/filters/posts.d.ts +11 -0
  40. package/dist/db/pg/filters/posts.js +37 -3
  41. package/dist/db/pg/filters/profiles.d.ts +1 -0
  42. package/dist/db/pg/filters/profiles.js +2 -1
  43. package/dist/db/pg/map/filters.js +37 -2
  44. package/dist/db/pg/map/mutations.js +13 -8
  45. package/dist/db/pg/map/registry.d.ts +5 -0
  46. package/dist/db/pg/map/registry.js +64 -24
  47. package/dist/db/pg/map/relations.d.ts +1 -1
  48. package/dist/db/pg/map/relations.js +98 -46
  49. package/dist/db/pg/migrate.d.ts +22 -0
  50. package/dist/db/pg/migrate.js +88 -2
  51. package/dist/db/pg/queries/activity.js +3 -3
  52. package/dist/db/pg/queries/sorts.d.ts +1 -0
  53. package/dist/db/pg/queries/sorts.js +4 -0
  54. package/dist/db/pg/schema/documents.d.ts +422 -41
  55. package/dist/db/pg/schema/documents.js +43 -9
  56. package/dist/db/pg/schema/edges.d.ts +117 -7
  57. package/dist/db/pg/schema/edges.js +4 -2
  58. package/dist/db/pg/schema/index.d.ts +505 -15
  59. package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
  60. package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
  61. package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
  62. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  63. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  64. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  65. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  66. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  67. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  68. package/dist/db/pg/sql/meta/{0006_snapshot.json → 0015_snapshot.json} +393 -39
  69. package/dist/db/pg/sql/meta/_journal.json +64 -1
  70. package/dist/db/replaceOrigin.js +6 -0
  71. package/dist/db/types.d.ts +0 -4
  72. package/dist/email/render.js +11 -3
  73. package/dist/events/index.d.ts +6 -1
  74. package/dist/events/index.js +55 -33
  75. package/dist/federation/activities.d.ts +17 -0
  76. package/dist/federation/activities.js +26 -0
  77. package/dist/federation/identity.d.ts +16 -0
  78. package/dist/federation/identity.js +52 -0
  79. package/dist/federation/index.d.ts +4 -0
  80. package/dist/federation/index.js +3 -0
  81. package/dist/federation/profiles.d.ts +3 -0
  82. package/dist/federation/profiles.js +14 -0
  83. package/dist/groups/finders.d.ts +3 -2
  84. package/dist/groups/helpers.d.ts +24 -6
  85. package/dist/groups/mapping.d.ts +6 -4
  86. package/dist/groups/mapping.js +2 -2
  87. package/dist/groups/mutations.js +1 -1
  88. package/dist/hashtags/finders.d.ts +6 -3
  89. package/dist/hashtags/finders.js +2 -0
  90. package/dist/hashtags/helpers.d.ts +8 -0
  91. package/dist/hashtags/helpers.js +4 -0
  92. package/dist/hashtags/index.d.ts +2 -0
  93. package/dist/hashtags/index.js +2 -0
  94. package/dist/hashtags/mutations.d.ts +3 -0
  95. package/dist/hashtags/mutations.js +13 -1
  96. package/dist/i18n/index.d.ts +1 -1
  97. package/dist/i18n/index.js +3 -1
  98. package/dist/i18n/pluginLocales.d.ts +6 -0
  99. package/dist/i18n/pluginLocales.js +15 -0
  100. package/dist/inviteLinks/helpers.d.ts +4 -4
  101. package/dist/jams/cache.d.ts +1 -1
  102. package/dist/jams/cache.js +2 -1
  103. package/dist/jams/export.d.ts +19 -0
  104. package/dist/jams/export.js +60 -0
  105. package/dist/jams/finders.d.ts +2 -1
  106. package/dist/jams/finders.js +18 -7
  107. package/dist/jams/health.d.ts +8 -0
  108. package/dist/jams/health.js +46 -0
  109. package/dist/jams/helpers.d.ts +6 -2
  110. package/dist/jams/index.d.ts +6 -3
  111. package/dist/jams/index.js +41 -27
  112. package/dist/jams/jobs.js +1 -1
  113. package/dist/jams/livekit.d.ts +93 -10
  114. package/dist/jams/livekit.js +151 -52
  115. package/dist/jams/mapping.d.ts +17 -7
  116. package/dist/jams/mutations.d.ts +3 -1
  117. package/dist/jams/recording.d.ts +10 -0
  118. package/dist/jams/recording.js +32 -0
  119. package/dist/jams/rtmp.d.ts +5 -0
  120. package/dist/jams/rtmp.js +8 -0
  121. package/dist/jams/token.d.ts +15 -3
  122. package/dist/jams/token.js +30 -16
  123. package/dist/jams/waitingRoom.d.ts +6 -6
  124. package/dist/jams/waitingRoom.js +24 -23
  125. package/dist/jobs/index.d.ts +1 -0
  126. package/dist/jobs/index.js +6 -1
  127. package/dist/jobs/jobDetail.js +1 -6
  128. package/dist/media/index.d.ts +1 -1
  129. package/dist/media/index.js +23 -8
  130. package/dist/media/processing.js +18 -7
  131. package/dist/notifications/defaultNotifications/follow/index.js +2 -2
  132. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
  133. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
  134. package/dist/notifications/defaultNotifications/index.js +4 -0
  135. package/dist/notifications/defaultNotifications/newGroupPost/index.js +12 -6
  136. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  137. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  138. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  139. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +18 -0
  140. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  141. package/dist/notifications/defaultNotifications/rsvp/index.js +7 -0
  142. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  143. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +75 -0
  144. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  145. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  146. package/dist/notifications/helpers.js +6 -2
  147. package/dist/notifications/jobs.js +3 -1
  148. package/dist/notifications/mutations.js +4 -0
  149. package/dist/notifications/push.js +11 -4
  150. package/dist/plugins/helpers.d.ts +1 -0
  151. package/dist/plugins/helpers.js +1 -8
  152. package/dist/plugins/index.d.ts +5 -0
  153. package/dist/plugins/index.js +78 -5
  154. package/dist/plugins/install.d.ts +39 -0
  155. package/dist/plugins/install.js +455 -0
  156. package/dist/plugins/pluginAuth.d.ts +1 -1
  157. package/dist/plugins/pluginAuth.js +10 -6
  158. package/dist/plugins/state.d.ts +4 -0
  159. package/dist/plugins/state.js +29 -0
  160. package/dist/posts/activity.d.ts +9 -0
  161. package/dist/posts/activity.js +35 -0
  162. package/dist/posts/contextClosure.d.ts +1 -9
  163. package/dist/posts/contextClosure.js +15 -44
  164. package/dist/posts/conversationQueries.d.ts +7 -0
  165. package/dist/posts/conversationQueries.js +76 -2
  166. package/dist/posts/eventAgenda.d.ts +166 -0
  167. package/dist/posts/eventAgenda.js +126 -0
  168. package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
  169. package/dist/posts/eventOccurrenceJobs.js +28 -0
  170. package/dist/posts/eventOccurrences.d.ts +10 -0
  171. package/dist/posts/eventOccurrences.js +61 -0
  172. package/dist/posts/finders.d.ts +47 -16
  173. package/dist/posts/finders.js +93 -62
  174. package/dist/posts/helpers/filters.js +14 -9
  175. package/dist/posts/helpers/index.d.ts +129 -30
  176. package/dist/posts/helpers/index.js +66 -33
  177. package/dist/posts/index.d.ts +7 -1
  178. package/dist/posts/index.js +7 -1
  179. package/dist/posts/mapping.d.ts +491 -13
  180. package/dist/posts/mapping.js +45 -10
  181. package/dist/posts/mutations.d.ts +441 -4
  182. package/dist/posts/mutations.js +177 -43
  183. package/dist/posts/pollEnd.d.ts +3 -0
  184. package/dist/posts/pollEnd.js +7 -0
  185. package/dist/posts/pollEndJobs.d.ts +8 -0
  186. package/dist/posts/pollEndJobs.js +49 -0
  187. package/dist/posts/replyClosure.d.ts +10 -0
  188. package/dist/posts/replyClosure.js +43 -0
  189. package/dist/posts/rsvpConfirmationEmail.js +14 -15
  190. package/dist/posts/threadPreview.d.ts +8 -0
  191. package/dist/posts/threadPreview.js +44 -0
  192. package/dist/posts/unseenCounts.d.ts +2 -0
  193. package/dist/posts/unseenCounts.js +28 -8
  194. package/dist/profileSettings/cache.js +22 -5
  195. package/dist/profileSettings/mapping.d.ts +2 -0
  196. package/dist/profiles/activityQueries.d.ts +5 -0
  197. package/dist/profiles/activityQueries.js +85 -0
  198. package/dist/profiles/activitySummary.d.ts +3 -0
  199. package/dist/profiles/activitySummary.js +87 -0
  200. package/dist/profiles/blocks.d.ts +12 -0
  201. package/dist/profiles/blocks.js +73 -0
  202. package/dist/profiles/cache.d.ts +4 -1
  203. package/dist/profiles/cache.js +28 -7
  204. package/dist/profiles/finders.d.ts +2 -1
  205. package/dist/profiles/finders.js +8 -3
  206. package/dist/profiles/helpers.d.ts +7 -5
  207. package/dist/profiles/index.d.ts +3 -1
  208. package/dist/profiles/index.js +3 -1
  209. package/dist/profiles/mapping.d.ts +10 -5
  210. package/dist/profiles/mapping.js +13 -1
  211. package/dist/profiles/mutations.d.ts +8 -4
  212. package/dist/profiles/mutations.js +42 -15
  213. package/dist/pushSubscriptions/helpers.d.ts +2 -2
  214. package/dist/pushSubscriptions/mutations.js +13 -1
  215. package/dist/redis/connection.d.ts +2 -0
  216. package/dist/redis/connection.js +25 -6
  217. package/dist/reports/helpers.d.ts +6 -6
  218. package/dist/roles/index.d.ts +1 -1
  219. package/dist/roles/index.js +1 -1
  220. package/dist/roles/mapping.d.ts +1 -0
  221. package/dist/roles/mutations.js +86 -3
  222. package/dist/search/mapping.d.ts +1 -1
  223. package/dist/search/mapping.js +6 -2
  224. package/dist/server/index.d.ts +19 -1
  225. package/dist/server/index.js +37 -18
  226. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  227. package/dist/server/stablePublicServerInfo.js +37 -0
  228. package/dist/server/status.d.ts +25 -0
  229. package/dist/server/status.js +98 -0
  230. package/dist/stats/finders.d.ts +1 -16131
  231. package/dist/stats/finders.js +9 -5
  232. package/dist/stats/mapping.d.ts +21 -1
  233. package/dist/stats/mapping.js +0 -3
  234. package/package.json +6 -12
  235. package/dist/db/arango.d.ts +0 -2
  236. package/dist/db/arango.js +0 -110
  237. package/dist/db/migration/autoMigrate.d.ts +0 -2
  238. package/dist/db/migration/autoMigrate.js +0 -111
  239. package/dist/db/migration/cli.d.ts +0 -1
  240. package/dist/db/migration/cli.js +0 -56
  241. package/dist/db/migration/detect.d.ts +0 -6
  242. package/dist/db/migration/detect.js +0 -87
  243. package/dist/db/migration/exportArango.d.ts +0 -4
  244. package/dist/db/migration/exportArango.js +0 -80
  245. package/dist/db/migration/importPostgres.d.ts +0 -3
  246. package/dist/db/migration/importPostgres.js +0 -18
  247. package/dist/db/migration/transform.d.ts +0 -18
  248. package/dist/db/migration/transform.js +0 -209
  249. package/dist/db/migration/validate.d.ts +0 -18
  250. package/dist/db/migration/validate.js +0 -69
  251. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  252. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  253. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  254. package/dist/mastodon/index.d.ts +0 -4
  255. package/dist/mastodon/index.js +0 -51
  256. package/dist/mastodon/types.d.ts +0 -7579
  257. package/dist/mastodon/types.js +0 -523
  258. package/dist/mastodon/typescript.d.ts +0 -1578
  259. package/dist/mastodon/typescript.js +0 -1
  260. package/dist/roles/defaults.d.ts +0 -2
  261. package/dist/roles/defaults.js +0 -94
@@ -1,4 +1,4 @@
1
- import { access, cp, mkdir, mkdtemp, readdir, rm, writeFile, readFile, } from 'node:fs/promises';
1
+ import { access, cp, mkdir, mkdtemp, readdir, rm, writeFile, readFile, stat, } from 'node:fs/promises';
2
2
  import { constants, createWriteStream } from 'node:fs';
3
3
  import { spawn } from 'node:child_process';
4
4
  import { emptyDir } from 'fs-extra';
@@ -7,15 +7,21 @@ import { tmpdir } from 'node:os';
7
7
  import archiver from 'archiver';
8
8
  import extract from 'extract-zip';
9
9
  import { collectionInfos } from '../db/index.js';
10
- import { communityConfig, config } from '../config/index.js';
11
- import { exportAllPostgresCollections, importAllArangoCollections, importAllPostgresCollections, } from '../db/migration/importCollections.js';
10
+ import { communityConfig, config, defaultConfig } from '../config/index.js';
11
+ import { exportAllPostgresCollections, importAllPostgresCollections, } from '../db/migration/importCollections.js';
12
+ import { getLatestSchemaVersion } from '../db/pg/migrate.js';
12
13
  import { replaceOrigin } from '../db/replaceOrigin.js';
13
14
  import { logger } from '../log/index.js';
14
15
  import { setDefaultRoles } from '../roles/index.js';
16
+ import { backfillMissingEventOccurrences } from '../posts/eventOccurrences.js';
15
17
  import { serverRootUrl } from '../server/index.js';
16
- import { resolveBackupDatabaseType, } from './metadata.js';
18
+ import { linkHostPeerDependencies } from '../plugins/index.js';
19
+ import { resolveBackupDatabaseType } from './metadata.js';
17
20
  export { resolveBackupDatabaseType } from './metadata.js';
18
21
  const log = logger('core:backups');
22
+ const pathExists = (p) => access(p)
23
+ .then(() => true)
24
+ .catch(() => false);
19
25
  /** Safety net if extraction stalls (normal 1 GiB restore finishes in a few minutes). */
20
26
  const EXTRACT_TIMEOUT_MS = 30 * 60 * 1000;
21
27
  const extractWithUnzipCli = (zipPath, tempDir) => {
@@ -103,6 +109,41 @@ const zipDirectory = (sourceDir, zipPath) => new Promise((resolve, reject) => {
103
109
  archive.directory(sourceDir, false);
104
110
  void archive.finalize();
105
111
  });
112
+ /**
113
+ * Peer-dependency symlinks in a restored plugin were created against the host
114
+ * packages of the image the backup came from. Re-anchor them to the current
115
+ * host tree so restored plugins resolve even after an image update.
116
+ */
117
+ const relinkRestoredPlugins = async (pluginsPath) => {
118
+ var _a, _b;
119
+ const namespaces = await readdir(pluginsPath).catch(() => []);
120
+ for (const namespace of namespaces) {
121
+ const namespaceDir = join(pluginsPath, namespace);
122
+ if (!(await stat(namespaceDir)
123
+ .then((s) => s.isDirectory())
124
+ .catch(() => false))) {
125
+ continue;
126
+ }
127
+ const names = await readdir(namespaceDir).catch(() => []);
128
+ for (const name of names) {
129
+ const pluginDir = join(namespaceDir, name);
130
+ let pkg;
131
+ try {
132
+ pkg = JSON.parse(await readFile(join(pluginDir, 'package.json'), 'utf8'));
133
+ }
134
+ catch (_c) {
135
+ continue;
136
+ }
137
+ const peers = Object.keys((_a = pkg.peerDependencies) !== null && _a !== void 0 ? _a : {});
138
+ if (peers.length === 0)
139
+ continue;
140
+ const linked = await linkHostPeerDependencies(pluginDir, peers);
141
+ if (!linked.success) {
142
+ log.warn(`Restored plugin ${(_b = pkg.name) !== null && _b !== void 0 ? _b : pluginDir} peer re-link failed: ${linked.error}`);
143
+ }
144
+ }
145
+ }
146
+ };
106
147
  const withTimeout = (promise, ms, message, onTimeout) => {
107
148
  let timeoutId;
108
149
  return Promise.race([
@@ -137,8 +178,7 @@ const assertBackupExtracted = async (tempDir) => {
137
178
  await access(metadataPath, constants.F_OK);
138
179
  }
139
180
  catch (_a) {
140
- // Legacy Arango JSONL templates (e.g. test-backup.zip) omit metadata.json.
141
- log.warn(`Backup has no metadata.json under ${tempDir}; treating as legacy Arango JSONL`);
181
+ throw new Error('Backup invalid: missing metadata.json (Postgres JSONL archives only)');
142
182
  }
143
183
  try {
144
184
  await access(collectionsPath, constants.F_OK);
@@ -153,15 +193,14 @@ const assertBackupExtracted = async (tempDir) => {
153
193
  }
154
194
  log.info(`Found ${jsonlFiles.length} collection backup files in archive`);
155
195
  };
156
- const restoreDatabaseFromBackup = async (collectionsDir, databaseType) => {
157
- log.info('Restoring %s database from JSONL collections', databaseType);
158
- const { total } = databaseType === 'postgres'
159
- ? await importAllPostgresCollections(collectionsDir)
160
- : await importAllArangoCollections(collectionsDir);
196
+ const restoreDatabaseFromBackup = async (collectionsDir, schemaVersion) => {
197
+ log.info('Restoring postgres database from JSONL collections');
198
+ const { total } = await importAllPostgresCollections(collectionsDir, schemaVersion);
161
199
  if (total === 0) {
162
200
  throw new Error('Backup restore completed with zero rows; archive may be empty or corrupt');
163
201
  }
164
- log.info('Restored %d database rows from backup', total);
202
+ const backfilled = await backfillMissingEventOccurrences();
203
+ log.info('Restored %d database rows from backup; indexed %d events', total, backfilled);
165
204
  };
166
205
  export const createBackup = async () => {
167
206
  try {
@@ -186,9 +225,19 @@ export const createBackup = async () => {
186
225
  await cp(coreConfig.logs.local.path, logsDir, {
187
226
  recursive: true,
188
227
  });
228
+ // Admin-installed plugins, so restores and moves carry them with the
229
+ // instance. Missing (e.g. fresh installs) is not an error.
230
+ const pluginsPath = defaultConfig.plugins.path;
231
+ if (await pathExists(pluginsPath)) {
232
+ const backupPluginsDir = join(backupDir, 'plugins');
233
+ await mkdir(backupPluginsDir);
234
+ await cp(pluginsPath, backupPluginsDir, { recursive: true });
235
+ }
189
236
  await writeFile(join(metaDir, 'collectionInfos.json'), JSON.stringify(collectionInfos, null, 2));
190
237
  await writeFile(join(backupDir, 'metadata.json'), JSON.stringify({
191
238
  databaseType: 'postgres',
239
+ createdAt: new Date().toISOString(),
240
+ schemaVersion: getLatestSchemaVersion(),
192
241
  config: {
193
242
  hostname: hostnameFromServerHost(coreConfig.server.host),
194
243
  },
@@ -241,7 +290,7 @@ export const restoreBackups = async (zipFilePath) => {
241
290
  const backupMetadata = await readFile(join(tempDir, 'metadata.json'), 'utf-8')
242
291
  .then(JSON.parse)
243
292
  .catch(() => undefined);
244
- const databaseType = resolveBackupDatabaseType(backupMetadata);
293
+ resolveBackupDatabaseType(backupMetadata);
245
294
  log.info(`Emptying media directory ${coreConfig.media.storage.params.path}`);
246
295
  await emptyDir(coreConfig.media.storage.params.path);
247
296
  log.info(`Copying media from backup to ${coreConfig.media.storage.params.path}`);
@@ -254,12 +303,26 @@ export const restoreBackups = async (zipFilePath) => {
254
303
  await cp(join(tempDir, 'logs'), coreConfig.logs.local.path, {
255
304
  recursive: true,
256
305
  });
257
- await restoreDatabaseFromBackup(collectionsDir, databaseType);
306
+ // Older images never archived plugins; never wipe a live plugins tree for
307
+ // such a backup.
308
+ const pluginsPath = defaultConfig.plugins.path;
309
+ const backupPluginsDir = join(tempDir, 'plugins');
310
+ if (await pathExists(backupPluginsDir)) {
311
+ log.info(`Emptying plugins directory ${pluginsPath}`);
312
+ await emptyDir(pluginsPath);
313
+ log.info(`Copying plugins from backup to ${pluginsPath}`);
314
+ await cp(backupPluginsDir, pluginsPath, { recursive: true });
315
+ await relinkRestoredPlugins(pluginsPath);
316
+ }
317
+ else {
318
+ log.info('Backup contains no plugins; leaving existing plugins in place.');
319
+ }
320
+ await restoreDatabaseFromBackup(collectionsDir, backupMetadata === null || backupMetadata === void 0 ? void 0 : backupMetadata.schemaVersion);
258
321
  // Repoint the backup's absolute URLs at this server's full origin (scheme +
259
322
  // host + port). Matching by the backup hostname means a prod backup on
260
323
  // `https://host` restores cleanly onto `http://localhost:5174` without
261
324
  // stranding the old scheme/port.
262
325
  await replaceOrigin((_a = backupMetadata === null || backupMetadata === void 0 ? void 0 : backupMetadata.config) === null || _a === void 0 ? void 0 : _a.hostname, await serverRootUrl());
263
- log.info(`Restored ${databaseType} backup (hostname was ${(_c = (_b = backupMetadata === null || backupMetadata === void 0 ? void 0 : backupMetadata.config) === null || _b === void 0 ? void 0 : _b.hostname) !== null && _c !== void 0 ? _c : 'unknown'})`);
326
+ log.info(`Restored postgres backup (hostname was ${(_c = (_b = backupMetadata === null || backupMetadata === void 0 ? void 0 : backupMetadata.config) === null || _b === void 0 ? void 0 : _b.hostname) !== null && _c !== void 0 ? _c : 'unknown'})`);
264
327
  await setDefaultRoles();
265
328
  };
@@ -1,9 +1,15 @@
1
- export type BackupDatabaseType = 'arango' | 'postgres';
1
+ export type BackupDatabaseType = 'postgres';
2
2
  export type BackupMetadata = {
3
3
  databaseType?: BackupDatabaseType;
4
+ /** When this backup archive was created (ISO-8601). */
5
+ createdAt?: string;
6
+ /**
7
+ * Drizzle journal tag the database was on when the backup was created
8
+ * (e.g. `0007_shallow_oracle`).
9
+ */
10
+ schemaVersion?: string;
4
11
  config?: {
5
12
  hostname?: string;
6
13
  };
7
14
  };
8
- /** Legacy Arango backups omit databaseType; treat them as Arango JSONL. */
9
15
  export declare const resolveBackupDatabaseType: (metadata?: BackupMetadata) => BackupDatabaseType;
@@ -1,2 +1,6 @@
1
- /** Legacy Arango backups omit databaseType; treat them as Arango JSONL. */
2
- export const resolveBackupDatabaseType = (metadata) => (metadata === null || metadata === void 0 ? void 0 : metadata.databaseType) === 'postgres' ? 'postgres' : 'arango';
1
+ export const resolveBackupDatabaseType = (metadata) => {
2
+ if ((metadata === null || metadata === void 0 ? void 0 : metadata.databaseType) === 'postgres') {
3
+ return 'postgres';
4
+ }
5
+ throw new Error('Backup is not a Postgres JSONL archive (missing metadata.json databaseType: "postgres")');
6
+ };
@@ -35,8 +35,19 @@ export const defaultCapabilitiesConfig = {
35
35
  ],
36
36
  },
37
37
  self: { add: ['core-profiles-update', ...postCapabilities] },
38
- blocked: { remove: ['*'] },
39
- blockedBy: { remove: ['*'] },
38
+ blocked: {
39
+ remove: [
40
+ 'core-posts-*',
41
+ 'core-profiles-read',
42
+ 'core-profiles-follow',
43
+ 'core-profiles-unfollow',
44
+ 'core-profiles-requestFollow',
45
+ 'core-profiles-block',
46
+ 'core-profiles-mute',
47
+ 'core-profiles-unmute',
48
+ ],
49
+ },
50
+ 'blocked-by': { remove: ['*'] },
40
51
  },
41
52
  report: {
42
53
  reporter: { add: ['core-reports-read'] },
@@ -3,24 +3,22 @@ dotenv.config();
3
3
  export const defaultCommunityConfig = {
4
4
  theme: {
5
5
  base: 'OpenpeepsLight',
6
- primaryHex: '#15678a',
7
- logoFull: '/img/logo-full.png',
8
- logoSmall: '/img/logo-small.png',
9
- defaultProfileAvatar: '/img/default-avatar.png',
10
- defaultGroupAvatar: '/img/default-group-avatar.svg',
11
- backgroundAuth: '/img/background-auth.png',
12
6
  icon: '/img/icon.svg',
13
7
  light: {
14
8
  primaryHex: '#15678a',
15
9
  logoSmall: '/img/logo-small.png',
16
- defaultProfileAvatar: '/img/default-avatar.png',
10
+ // No defaultProfileAvatar — profiles without a custom avatar fall back
11
+ // to letter initials in the Avatar component.
17
12
  defaultGroupAvatar: '/img/default-group-avatar.svg',
18
13
  backgroundAuth: '/img/background-auth.png',
19
14
  },
20
15
  dark: {
21
- primaryHex: '#15678a',
16
+ // Lighter than the light-mode primary so it stays readable on the
17
+ // near-black dark background.
18
+ primaryHex: '#38aee1',
22
19
  logoSmall: '/img/logo-small-white.png',
23
- defaultProfileAvatar: '/img/default-avatar.png',
20
+ // No defaultProfileAvatar — profiles without a custom avatar fall back
21
+ // to letter initials in the Avatar component.
24
22
  defaultGroupAvatar: '/img/default-group-avatar.svg',
25
23
  backgroundAuth: '/img/background-auth.png',
26
24
  },
@@ -1,2 +1,2 @@
1
- import type { CoreConfig } from '@openpeepshq/common/types';
1
+ import { type CoreConfig } from '@openpeepshq/common/types';
2
2
  export declare const defaultConfig: CoreConfig;
@@ -1,3 +1,4 @@
1
+ import { DEFAULT_MAX_MEDIA_UPLOAD_MB, } from '@openpeepshq/common/types';
1
2
  import db from './db.js';
2
3
  import redis from './redis.js';
3
4
  import { readEnvInteger, resolveJwtSecret } from '../helpers.js';
@@ -31,6 +32,7 @@ export const defaultConfig = {
31
32
  },
32
33
  logs,
33
34
  media: {
35
+ maxUploadMb: DEFAULT_MAX_MEDIA_UPLOAD_MB,
34
36
  storage: {
35
37
  driver: 'openpeeps',
36
38
  params: {
@@ -65,6 +67,7 @@ export const defaultConfig = {
65
67
  },
66
68
  federation: {
67
69
  active: false,
70
+ allowedHosts: [],
68
71
  },
69
72
  activityPub: {
70
73
  defaultDomain: process.env.ACTIVITY_PUB_DEFAULT_DOMAIN || 'localhost',
@@ -1,6 +1,4 @@
1
1
  declare const _default: {
2
- url: string;
3
- databaseName: string | undefined;
4
2
  databaseUrl: string;
5
3
  };
6
4
  export default _default;
@@ -1,8 +1,6 @@
1
1
  import dotenv from 'dotenv';
2
2
  dotenv.config();
3
3
  export default {
4
- url: process.env.DB_URL || 'http://localhost:8529',
5
- databaseName: process.env.DB_NAME || undefined,
6
4
  databaseUrl: process.env.DATABASE_URL ||
7
5
  'postgresql://openpeeps:openpeeps@localhost:5432/openpeeps',
8
6
  };
@@ -24,8 +24,8 @@ export declare const config: <T = {
24
24
  maxProfiles?: number | undefined;
25
25
  };
26
26
  db: {
27
- url: string;
28
27
  databaseUrl: string;
28
+ url?: string | undefined;
29
29
  databaseName?: string | undefined;
30
30
  };
31
31
  redis: {
@@ -51,6 +51,7 @@ export declare const config: <T = {
51
51
  };
52
52
  };
53
53
  media: {
54
+ maxUploadMb: number;
54
55
  storage: {
55
56
  driver: "openpeeps";
56
57
  params: {
@@ -84,6 +85,7 @@ export declare const config: <T = {
84
85
  };
85
86
  federation: {
86
87
  active: boolean;
88
+ allowedHosts: string[];
87
89
  };
88
90
  activityPub: {
89
91
  defaultDomain: string;
@@ -95,6 +97,8 @@ export declare const config: <T = {
95
97
  };
96
98
  sso: {
97
99
  generic: {
100
+ id: string;
101
+ name: string;
98
102
  userProfileRequest: {
99
103
  url: string;
100
104
  authHeader?: string | undefined;
@@ -105,6 +109,7 @@ export declare const config: <T = {
105
109
  avatar?: string | undefined;
106
110
  displayName?: string | undefined;
107
111
  };
112
+ loginLink?: string | undefined;
108
113
  createAccounts?: boolean | undefined;
109
114
  createProfiles?: boolean | undefined;
110
115
  }[];
@@ -115,6 +120,10 @@ export declare const config: <T = {
115
120
  tokenUrl: string;
116
121
  userinfoUrl: string;
117
122
  clientId: string;
123
+ kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
124
+ instanceUrl?: string | undefined;
125
+ tenant?: string | undefined;
126
+ emailsUrl?: string | undefined;
118
127
  jwksUri?: string | undefined;
119
128
  clientSecret?: string | undefined;
120
129
  scope?: string | undefined;
@@ -126,6 +135,7 @@ export declare const config: <T = {
126
135
  } | undefined;
127
136
  approvalRequired?: boolean | undefined;
128
137
  }[];
138
+ onlySSO?: boolean | undefined;
129
139
  };
130
140
  services: {
131
141
  sentry: {
@@ -171,7 +181,6 @@ export declare const config: <T = {
171
181
  export declare const communityConfig: () => Promise<{
172
182
  theme: {
173
183
  base: string;
174
- primaryHex: string;
175
184
  light: {
176
185
  primaryHex: string;
177
186
  secondaryHex?: string | undefined;
@@ -198,6 +207,7 @@ export declare const communityConfig: () => Promise<{
198
207
  };
199
208
  icon?: string | undefined;
200
209
  mobileIcon?: string | undefined;
210
+ primaryHex?: string | undefined;
201
211
  logoFull?: string | undefined;
202
212
  logoSmall?: string | undefined;
203
213
  defaultProfileAvatar?: string | undefined;
@@ -222,6 +232,8 @@ export declare const communityConfig: () => Promise<{
222
232
  settings: {
223
233
  openRegistrations: boolean;
224
234
  defaultLanguage?: string | undefined;
235
+ defaultTimeZone?: string | undefined;
236
+ defaultFeedFormat?: "threaded" | "linear" | undefined;
225
237
  };
226
238
  roles: {
227
239
  onRegistration: {
@@ -253,8 +265,8 @@ export declare const sanitizedConfigWithDefaults: <T = {
253
265
  maxProfiles?: number | undefined;
254
266
  };
255
267
  db: {
256
- url: string;
257
268
  databaseUrl: string;
269
+ url?: string | undefined;
258
270
  databaseName?: string | undefined;
259
271
  };
260
272
  redis: {
@@ -280,6 +292,7 @@ export declare const sanitizedConfigWithDefaults: <T = {
280
292
  };
281
293
  };
282
294
  media: {
295
+ maxUploadMb: number;
283
296
  storage: {
284
297
  driver: "openpeeps";
285
298
  params: {
@@ -313,6 +326,7 @@ export declare const sanitizedConfigWithDefaults: <T = {
313
326
  };
314
327
  federation: {
315
328
  active: boolean;
329
+ allowedHosts: string[];
316
330
  };
317
331
  activityPub: {
318
332
  defaultDomain: string;
@@ -324,6 +338,8 @@ export declare const sanitizedConfigWithDefaults: <T = {
324
338
  };
325
339
  sso: {
326
340
  generic: {
341
+ id: string;
342
+ name: string;
327
343
  userProfileRequest: {
328
344
  url: string;
329
345
  authHeader?: string | undefined;
@@ -334,6 +350,7 @@ export declare const sanitizedConfigWithDefaults: <T = {
334
350
  avatar?: string | undefined;
335
351
  displayName?: string | undefined;
336
352
  };
353
+ loginLink?: string | undefined;
337
354
  createAccounts?: boolean | undefined;
338
355
  createProfiles?: boolean | undefined;
339
356
  }[];
@@ -344,6 +361,10 @@ export declare const sanitizedConfigWithDefaults: <T = {
344
361
  tokenUrl: string;
345
362
  userinfoUrl: string;
346
363
  clientId: string;
364
+ kind?: "oidc" | "github" | "gitlab" | "gitlab-selfhosted" | "google" | "entra" | "auth0" | "keycloak" | "authentik" | "okta" | "discord" | "pocketid" | undefined;
365
+ instanceUrl?: string | undefined;
366
+ tenant?: string | undefined;
367
+ emailsUrl?: string | undefined;
347
368
  jwksUri?: string | undefined;
348
369
  clientSecret?: string | undefined;
349
370
  scope?: string | undefined;
@@ -355,6 +376,7 @@ export declare const sanitizedConfigWithDefaults: <T = {
355
376
  } | undefined;
356
377
  approvalRequired?: boolean | undefined;
357
378
  }[];
379
+ onlySSO?: boolean | undefined;
358
380
  };
359
381
  services: {
360
382
  sentry: {
@@ -1,11 +1,13 @@
1
1
  import { deepmergeCustom } from 'deepmerge-ts';
2
2
  import { coreConfigSchemaFactory, communityConfigSchemaFactory, capabilitiesConfigSchemaFactory, } from '@openpeepshq/common/types';
3
+ import { restorePasswordPlaceholders } from '@openpeepshq/common/lib';
3
4
  import { zodDeepPartialSchema } from '../lib/zodDeepPartial.js';
4
5
  import { defaultConfig } from './defaults/core.js';
5
6
  import { defaultCommunityConfig } from './defaults/community.js';
6
7
  import { default as logsConfig } from './defaults/logs.js';
7
8
  import { default as dbConfig } from './defaults/db.js';
8
9
  import { hub } from '../events/index.js';
10
+ import { stablePublicServerInfo } from '../server/stablePublicServerInfo.js';
9
11
  import { loadConfig, storeConfig } from './db.js';
10
12
  import { defaultCapabilitiesConfig } from './defaults/capabilities.js';
11
13
  import { pruneEmptyConfigStrings } from './pruneEmptyConfigStrings.js';
@@ -38,6 +40,9 @@ const initConfig = async (namespace, name) => {
38
40
  };
39
41
  export const refreshConfig = (namespace = 'openpeeps', name = 'core') => {
40
42
  configPromises.set(configKey(namespace, name), initConfig(namespace, name));
43
+ // /server/info is bucket-cached so RN clients do not remount. Drop that
44
+ // snapshot when config changes or SSO/theme patches stay invisible.
45
+ stablePublicServerInfo.reset();
41
46
  };
42
47
  /** Full-document write. Prefer `updateConfigValues` for patches. */
43
48
  const replaceStoredConfig = (config, namespace = 'openpeeps', name = 'core') => storeConfig(configKey(namespace, name), {
@@ -52,7 +57,8 @@ const replaceStoredConfig = (config, namespace = 'openpeeps', name = 'core') =>
52
57
  */
53
58
  export const updateConfigValues = (configValues, namespace = 'openpeeps', name = 'core') => loadConfig(configKey(namespace, name)).then((configDocument) => {
54
59
  var _a;
55
- return replaceStoredConfig(deepmerge((_a = configDocument === null || configDocument === void 0 ? void 0 : configDocument.config) !== null && _a !== void 0 ? _a : {}, configValues), namespace, name);
60
+ const stored = (_a = configDocument === null || configDocument === void 0 ? void 0 : configDocument.config) !== null && _a !== void 0 ? _a : {};
61
+ return replaceStoredConfig(deepmerge(stored, restorePasswordPlaceholders(configValues, stored)), namespace, name);
56
62
  });
57
63
  export const config = (namespace = 'openpeeps', name = 'core') => {
58
64
  const key = configKey(namespace, name);
@@ -1,35 +1,13 @@
1
- import { Database } from 'arangojs';
2
- import { DocumentCollection, EdgeCollection } from 'arangojs/collections';
3
- import { Document, DocumentMetadata, Edge, EdgeMetadata, Patch } from 'arangojs/documents';
4
- import type { Base } from '@openpeepshq/common/types';
5
- import { type Filter } from '@openpeepshq/arango-querybuilder';
6
- import type { CollectionInfo, ViewInfo } from './pg/map/queryTypes';
1
+ import type { FilterAndTransformOptions, ObjectFilter } from './types';
2
+ import type { CollectionInfo } from './pg/map/queryTypes';
7
3
  import type { Mapping, ObjectSort, WithId } from './pg/map';
8
4
  import type { PgQueryResult } from './pg/map/types';
9
5
  import type { PgDb } from './pg/client';
10
- import { EdgeDefinitionOptions } from 'arangojs/graphs';
11
- import { EnsureIndexOptions } from 'arangojs/indexes';
12
- import { FilterAndTransformOptions, ObjectFilter, UserFunctionDefinition } from './types';
13
- export declare const addModificationDates: (collection: DocumentCollection) => Promise<void>;
14
- export declare const addIndices: (collection: DocumentCollection | EdgeCollection, indices: EnsureIndexOptions[]) => Promise<void>;
15
- export declare const ensureIndexedCollection: <T extends Record<string, unknown>>(db: Database, collectionInfo: CollectionInfo) => Promise<DocumentCollection<Base<T>, T>>;
16
- export declare const ensureView: (db: Database, viewInfo: ViewInfo) => Promise<import("arangojs/views").View | undefined>;
17
- export declare const ensureGraph: (db: Database, name: string, edgeDefinitions: EdgeDefinitionOptions[]) => Promise<import("arangojs/graphs").Graph>;
18
- export declare const ensureFunction: (db: Database, { name, dbFunction }: UserFunctionDefinition) => Promise<void>;
19
- export declare const createEdge: <T extends object | {} = {}>(collection: EdgeCollection<Base<T>, T>, document: T & EdgeMetadata & {
20
- id?: string;
21
- }) => Promise<WithId<Base<T>>>;
22
- export declare const updateEdge: <T extends Record<string, unknown> & EdgeMetadata>(collection: EdgeCollection<Base<T>>, documentKey: string, document: Patch<Document<Base<T>>>) => Promise<Document<Base<T>> | undefined>;
23
- export declare const deleteEdge: <T extends Record<string, unknown> & Base<EdgeMetadata>>(collection: EdgeCollection<Base<T>>, documentKey: string) => Promise<DocumentMetadata & {
24
- old?: Edge<Base<T>> | undefined;
25
- }>;
26
- export declare const findOneBy: <O extends object>(db: Database, collectionInfo: CollectionInfo) => (filter: Filter) => Promise<O | undefined>;
27
- export declare const edgeCollections: (database: Database) => Promise<(DocumentCollection<any, any> & EdgeCollection<any, any>)[]>;
28
6
  export declare const connector: <F extends {
29
7
  id: string;
30
8
  }, T extends {
31
9
  id: string;
32
- }, E extends object | {} = {}>(fromCollectionInfo: CollectionInfo, toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T, data?: E & {
10
+ }, E extends object = object>(fromCollectionInfo: CollectionInfo, toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T, data?: E & {
33
11
  id?: string;
34
12
  }) => Promise<WithId<E & {
35
13
  _from: string;
@@ -39,17 +17,17 @@ export declare const disconnector: <F extends {
39
17
  id: string;
40
18
  }, T extends {
41
19
  id: string;
42
- }>(fromCollectionInfo: CollectionInfo, toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T) => Promise<void>;
20
+ }>(_fromCollectionInfo: CollectionInfo, _toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T) => Promise<void>;
43
21
  export declare const connectionUpdater: <F extends {
44
22
  id: string;
45
23
  }, T extends {
46
24
  id: string;
47
- }, C extends Record<string, unknown> | undefined = {}>(fromCollectionInfo: CollectionInfo, toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T, data?: C) => Promise<void>;
25
+ }, C extends Record<string, unknown> | undefined = Record<string, unknown>>(_fromCollectionInfo: CollectionInfo, _toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T, data?: C) => Promise<void>;
48
26
  export declare const connectionFinder: <F extends {
49
27
  id: string;
50
28
  }, T extends {
51
29
  id: string;
52
- }, C extends Record<string, unknown> = {}>(_fromCollectionInfo: CollectionInfo, _toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T) => Promise<C | undefined>;
30
+ }, C extends Record<string, unknown> = Record<string, unknown>>(_fromCollectionInfo: CollectionInfo, _toCollectionInfo: CollectionInfo, edgeCollectionInfo: CollectionInfo) => (db: PgDb, from: F, to: T) => Promise<C | undefined>;
53
31
  export declare const filterBefore: <T extends object>(mapping: Mapping<T>, id?: string) => Mapping<T>;
54
32
  export declare const filterAfter: <T extends object>(mapping: Mapping<T>, id?: string) => Mapping<T>;
55
33
  export declare const addQuerySort: <T extends object>(mapping: Mapping<T>, sort?: ObjectSort) => Mapping<T>;
@@ -57,6 +35,7 @@ export declare const sortNewestFirst: <T extends object>(mapping: Mapping<T>) =>
57
35
  export declare const sortOldestFirst: <T extends object>(mapping: Mapping<T>) => Mapping<T, WithId<T>, WithId<T>>;
58
36
  export declare const addStartLimit: <T extends object>(mapping: Mapping<T>, start?: string, limit?: number) => Mapping<T>;
59
37
  export declare const addStart: <T extends object>(mapping: Mapping<T>, start?: string) => Mapping<T>;
38
+ export declare const addActivityStart: <T extends object>(mapping: Mapping<T>, start?: string) => Mapping<T>;
60
39
  export declare const filterAndTransform: <I extends object, O extends object = I>(queryResult: PgQueryResult<I>, db: PgDb, options: FilterAndTransformOptions<I, O>) => Promise<O[]>;
61
40
  export declare const composeFilters: <O extends object>(...filters: ObjectFilter<O>[]) => ObjectFilter<O>;
62
41
  export declare const retrievePaged: <T extends object>(queryResult: PgQueryResult<T>, db: PgDb, options?: {