@openpeepshq/core 0.1.33 → 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 (297) 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 +36 -33
  6. package/dist/analytics/cache.js +3 -3
  7. package/dist/analytics/clicks.js +14 -22
  8. package/dist/analytics/compile.js +17 -12
  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 +164 -140
  14. package/dist/analytics/report.d.ts +22 -1
  15. package/dist/analytics/report.js +2 -3
  16. package/dist/analytics/settings.js +3 -4
  17. package/dist/backups/index.js +82 -25
  18. package/dist/backups/metadata.d.ts +2 -3
  19. package/dist/backups/metadata.js +6 -2
  20. package/dist/config/db.js +2 -4
  21. package/dist/config/defaults/capabilities.js +13 -2
  22. package/dist/config/defaults/community.js +8 -3
  23. package/dist/config/defaults/core.d.ts +1 -1
  24. package/dist/config/defaults/core.js +16 -8
  25. package/dist/config/index.d.ts +22 -0
  26. package/dist/config/index.js +15 -11
  27. package/dist/db/explorer/query.js +9 -8
  28. package/dist/db/explorer/sql.js +8 -8
  29. package/dist/db/helpers.d.ts +1 -0
  30. package/dist/db/helpers.js +25 -7
  31. package/dist/db/index.d.ts +1 -1
  32. package/dist/db/index.js +1 -0
  33. package/dist/db/init.js +2 -3
  34. package/dist/db/migration/importCollections.d.ts +14 -9
  35. package/dist/db/migration/importCollections.js +121 -174
  36. package/dist/db/migration/shared.d.ts +2 -33
  37. package/dist/db/migration/shared.js +17 -87
  38. package/dist/db/pg/client.js +4 -7
  39. package/dist/db/pg/collections.d.ts +2 -2
  40. package/dist/db/pg/collections.js +2 -2
  41. package/dist/db/pg/filters/index.js +1 -1
  42. package/dist/db/pg/filters/posts.d.ts +12 -0
  43. package/dist/db/pg/filters/posts.js +30 -4
  44. package/dist/db/pg/filters/profiles.d.ts +1 -0
  45. package/dist/db/pg/filters/profiles.js +2 -1
  46. package/dist/db/pg/helpers.js +2 -14
  47. package/dist/db/pg/map/filters.js +40 -10
  48. package/dist/db/pg/map/helpers.js +5 -1
  49. package/dist/db/pg/map/index.js +46 -51
  50. package/dist/db/pg/map/mutations.js +65 -25
  51. package/dist/db/pg/map/registry.d.ts +5 -0
  52. package/dist/db/pg/map/registry.js +133 -56
  53. package/dist/db/pg/map/relations.js +76 -68
  54. package/dist/db/pg/map/search.js +15 -37
  55. package/dist/db/pg/mappers.js +13 -7
  56. package/dist/db/pg/migrate.d.ts +1 -2
  57. package/dist/db/pg/migrate.js +8 -9
  58. package/dist/db/pg/queries/activity.js +5 -5
  59. package/dist/db/pg/queries/derived.js +8 -12
  60. package/dist/db/pg/queries/sorts.d.ts +1 -0
  61. package/dist/db/pg/queries/sorts.js +4 -0
  62. package/dist/db/pg/schema/documents.d.ts +279 -41
  63. package/dist/db/pg/schema/documents.js +136 -22
  64. package/dist/db/pg/schema/edges.d.ts +116 -7
  65. package/dist/db/pg/schema/edges.js +9 -2
  66. package/dist/db/pg/schema/index.d.ts +362 -15
  67. package/dist/db/pg/schema/index.js +5 -1
  68. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  69. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  70. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  71. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  72. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  73. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  74. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  75. package/dist/db/pg/sql/meta/{0009_snapshot.json → 0015_snapshot.json} +291 -36
  76. package/dist/db/pg/sql/meta/_journal.json +49 -0
  77. package/dist/db/replaceOrigin.js +1 -1
  78. package/dist/email/queueStats.js +8 -11
  79. package/dist/email/render.js +14 -3
  80. package/dist/email/send.js +19 -17
  81. package/dist/email/smtpTest.js +10 -6
  82. package/dist/errors/index.js +1 -1
  83. package/dist/events/index.d.ts +4 -0
  84. package/dist/events/index.js +1 -0
  85. package/dist/events/once.js +2 -4
  86. package/dist/federation/activities.d.ts +17 -0
  87. package/dist/federation/activities.js +25 -0
  88. package/dist/federation/identity.d.ts +16 -0
  89. package/dist/federation/identity.js +52 -0
  90. package/dist/federation/index.d.ts +4 -0
  91. package/dist/federation/index.js +3 -0
  92. package/dist/federation/profiles.d.ts +3 -0
  93. package/dist/federation/profiles.js +14 -0
  94. package/dist/groups/finders.d.ts +2 -1
  95. package/dist/groups/helpers.d.ts +18 -0
  96. package/dist/groups/helpers.js +1 -2
  97. package/dist/groups/mapping.d.ts +4 -2
  98. package/dist/groups/mutations.js +1 -1
  99. package/dist/hashtags/finders.d.ts +6 -3
  100. package/dist/hashtags/finders.js +2 -0
  101. package/dist/hashtags/helpers.d.ts +8 -0
  102. package/dist/hashtags/helpers.js +4 -0
  103. package/dist/hashtags/index.d.ts +2 -0
  104. package/dist/hashtags/index.js +2 -0
  105. package/dist/hashtags/mutations.d.ts +3 -0
  106. package/dist/hashtags/mutations.js +13 -1
  107. package/dist/i18n/index.d.ts +1 -1
  108. package/dist/i18n/index.js +3 -1
  109. package/dist/i18n/pluginLocales.d.ts +6 -0
  110. package/dist/i18n/pluginLocales.js +15 -0
  111. package/dist/inviteLinks/mutations.js +2 -3
  112. package/dist/jams/export.d.ts +19 -0
  113. package/dist/jams/export.js +58 -0
  114. package/dist/jams/finders.js +4 -1
  115. package/dist/jams/health.d.ts +10 -0
  116. package/dist/jams/health.js +50 -0
  117. package/dist/jams/helpers.d.ts +2 -2
  118. package/dist/jams/helpers.js +6 -2
  119. package/dist/jams/index.d.ts +2 -0
  120. package/dist/jams/index.js +25 -18
  121. package/dist/jams/jobs.js +2 -3
  122. package/dist/jams/livekit.d.ts +49 -4
  123. package/dist/jams/livekit.js +62 -45
  124. package/dist/jams/mapping.d.ts +3 -3
  125. package/dist/jams/mutations.d.ts +1 -1
  126. package/dist/jams/recording.d.ts +10 -0
  127. package/dist/jams/recording.js +33 -1
  128. package/dist/jams/token.d.ts +13 -1
  129. package/dist/jams/token.js +25 -18
  130. package/dist/jams/waitingRoom.js +1 -1
  131. package/dist/jobs/index.d.ts +1 -0
  132. package/dist/jobs/index.js +9 -3
  133. package/dist/jobs/jobDetail.js +6 -12
  134. package/dist/jobs/jobLog.js +2 -3
  135. package/dist/lib/streams.js +4 -39
  136. package/dist/lib/zodDeepPartial.d.ts +1 -1
  137. package/dist/lib/zodDeepPartial.js +1 -1
  138. package/dist/log/index.js +13 -29
  139. package/dist/media/index.d.ts +1 -1
  140. package/dist/media/index.js +73 -12
  141. package/dist/media/jobs.js +1 -2
  142. package/dist/media/openpeeps/index.js +11 -46
  143. package/dist/media/processing.js +25 -11
  144. package/dist/media/streaming.js +5 -5
  145. package/dist/media/streamingCleanupJobs.js +1 -2
  146. package/dist/media/streamingJobs.js +3 -4
  147. package/dist/media/streamingPrewarm.js +7 -11
  148. package/dist/mediaAttachments/index.js +6 -2
  149. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  150. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  151. package/dist/notifications/defaultNotifications/follow/index.js +15 -18
  152. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  153. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  154. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  155. package/dist/notifications/defaultNotifications/index.js +4 -0
  156. package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
  157. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  158. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  159. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  160. package/dist/notifications/defaultNotifications/newGroupPost/index.js +11 -6
  161. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  162. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  163. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  164. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  165. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +17 -0
  166. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  167. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  168. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  169. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  170. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  171. package/dist/notifications/defaultNotifications/rsvp/index.js +31 -18
  172. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  173. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +82 -0
  174. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  175. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  176. package/dist/notifications/fcmCredential.js +1 -1
  177. package/dist/notifications/finders.js +1 -1
  178. package/dist/notifications/helpers.js +13 -10
  179. package/dist/notifications/jobs.js +10 -5
  180. package/dist/notifications/mutations.js +8 -1
  181. package/dist/notifications/push.js +11 -16
  182. package/dist/performance/index.js +3 -3
  183. package/dist/plugins/helpers.js +3 -6
  184. package/dist/plugins/index.js +39 -4
  185. package/dist/plugins/install.d.ts +28 -9
  186. package/dist/plugins/install.js +302 -56
  187. package/dist/plugins/pluginAuth.d.ts +1 -1
  188. package/dist/plugins/pluginAuth.js +13 -10
  189. package/dist/plugins/state.js +2 -3
  190. package/dist/posts/activity.d.ts +9 -0
  191. package/dist/posts/activity.js +34 -0
  192. package/dist/posts/contextClosure.d.ts +1 -9
  193. package/dist/posts/contextClosure.js +14 -44
  194. package/dist/posts/conversationQueries.d.ts +7 -0
  195. package/dist/posts/conversationQueries.js +76 -4
  196. package/dist/posts/eventAgenda.d.ts +1 -0
  197. package/dist/posts/eventAgenda.js +17 -8
  198. package/dist/posts/eventOccurrenceJobs.js +7 -2
  199. package/dist/posts/eventOccurrences.d.ts +6 -0
  200. package/dist/posts/eventOccurrences.js +22 -1
  201. package/dist/posts/finders.d.ts +56 -9
  202. package/dist/posts/finders.js +84 -23
  203. package/dist/posts/helpers/filters.js +13 -9
  204. package/dist/posts/helpers/index.d.ts +179 -14
  205. package/dist/posts/helpers/index.js +70 -34
  206. package/dist/posts/index.d.ts +5 -2
  207. package/dist/posts/index.js +5 -2
  208. package/dist/posts/mapping.d.ts +765 -30
  209. package/dist/posts/mapping.js +74 -31
  210. package/dist/posts/mutations.d.ts +516 -3
  211. package/dist/posts/mutations.js +179 -41
  212. package/dist/posts/pollEnd.d.ts +3 -0
  213. package/dist/posts/pollEnd.js +4 -0
  214. package/dist/posts/pollEndJobs.d.ts +8 -0
  215. package/dist/posts/pollEndJobs.js +49 -0
  216. package/dist/posts/replyClosure.d.ts +10 -0
  217. package/dist/posts/replyClosure.js +43 -0
  218. package/dist/posts/rsvpConfirmationEmail.js +23 -15
  219. package/dist/posts/threadPreview.d.ts +8 -0
  220. package/dist/posts/threadPreview.js +44 -0
  221. package/dist/posts/unseenCounts.js +4 -1
  222. package/dist/processingStats/queries.js +6 -7
  223. package/dist/profileSettings/cache.js +21 -5
  224. package/dist/profileSettings/mapping.d.ts +2 -0
  225. package/dist/profiles/activityQueries.d.ts +5 -0
  226. package/dist/profiles/activityQueries.js +85 -0
  227. package/dist/profiles/activitySummary.d.ts +3 -0
  228. package/dist/profiles/activitySummary.js +82 -0
  229. package/dist/profiles/blocks.d.ts +12 -0
  230. package/dist/profiles/blocks.js +73 -0
  231. package/dist/profiles/cache.d.ts +1 -0
  232. package/dist/profiles/cache.js +30 -10
  233. package/dist/profiles/export.js +30 -39
  234. package/dist/profiles/finders.d.ts +2 -1
  235. package/dist/profiles/finders.js +15 -8
  236. package/dist/profiles/helpers.d.ts +2 -0
  237. package/dist/profiles/index.d.ts +2 -0
  238. package/dist/profiles/index.js +2 -0
  239. package/dist/profiles/mapping.d.ts +10 -5
  240. package/dist/profiles/mapping.js +13 -1
  241. package/dist/profiles/mutations.d.ts +8 -4
  242. package/dist/profiles/mutations.js +31 -4
  243. package/dist/redis/connection.d.ts +2 -0
  244. package/dist/redis/connection.js +25 -6
  245. package/dist/reports/helpers.js +7 -3
  246. package/dist/roles/index.d.ts +1 -1
  247. package/dist/roles/index.js +1 -1
  248. package/dist/roles/mapping.d.ts +1 -0
  249. package/dist/roles/mutations.js +85 -3
  250. package/dist/search/finders.js +15 -3
  251. package/dist/search/helpers.js +1 -1
  252. package/dist/search/mapping.d.ts +1 -1
  253. package/dist/search/mapping.js +6 -2
  254. package/dist/sentry/index.js +9 -11
  255. package/dist/seo/index.d.ts +50 -0
  256. package/dist/seo/index.js +145 -0
  257. package/dist/seo/route.d.ts +18 -0
  258. package/dist/seo/route.js +19 -0
  259. package/dist/server/index.d.ts +19 -0
  260. package/dist/server/index.js +31 -14
  261. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  262. package/dist/server/stablePublicServerInfo.js +37 -0
  263. package/dist/server/status.d.ts +25 -0
  264. package/dist/server/status.js +97 -0
  265. package/dist/session/index.js +2 -2
  266. package/dist/stats/finders.d.ts +1 -17681
  267. package/dist/stats/finders.js +22 -9
  268. package/dist/stats/helpers.js +4 -1
  269. package/dist/stats/mapping.d.ts +39 -2
  270. package/dist/stats/mapping.js +8 -4
  271. package/dist/stripe/cache.js +5 -6
  272. package/dist/stripe/connection.js +3 -4
  273. package/dist/stripe/helpers.js +15 -20
  274. package/package.json +5 -7
  275. package/dist/db/migration/detect.d.ts +0 -3
  276. package/dist/db/migration/detect.js +0 -33
  277. package/dist/db/migration/importPostgres.d.ts +0 -3
  278. package/dist/db/migration/importPostgres.js +0 -18
  279. package/dist/db/migration/transform.d.ts +0 -20
  280. package/dist/db/migration/transform.js +0 -232
  281. package/dist/db/migration/validate.d.ts +0 -18
  282. package/dist/db/migration/validate.js +0 -69
  283. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  284. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  285. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  286. package/dist/db/pg/sql/meta/0006_snapshot.json +0 -4200
  287. package/dist/db/pg/sql/meta/0007_snapshot.json +0 -4179
  288. package/dist/mastodon/index.d.ts +0 -4
  289. package/dist/mastodon/index.js +0 -51
  290. package/dist/mastodon/types.d.ts +0 -7579
  291. package/dist/mastodon/types.js +0 -523
  292. package/dist/mastodon/typescript.d.ts +0 -1578
  293. package/dist/mastodon/typescript.js +0 -1
  294. package/dist/migration/index.d.ts +0 -4
  295. package/dist/migration/index.js +0 -4
  296. package/dist/roles/defaults.d.ts +0 -2
  297. package/dist/roles/defaults.js +0 -95
@@ -1,8 +1,9 @@
1
+ import { parseFeedCursor } from '@openpeepshq/common';
2
+ import { and, eq } from 'drizzle-orm';
1
3
  import { deleteEdge as deletePgEdge, insertEdge } from './pg/helpers.js';
2
4
  import { asTable, edgeRegistry } from './pg/map/registry.js';
3
5
  import { nowIso } from './pg/mappers.js';
4
- import { and, eq } from 'drizzle-orm';
5
- import { documentKeyAfter, documentKeyBefore } from './pg/filters/index.js';
6
+ import { documentKeyAfter, documentKeyBefore, postFilters } from './pg/filters/index.js';
6
7
  import { sorts } from './pg/queries/index.js';
7
8
  const getPgEdge = async (db, edgeCollectionName, fromId, toId) => {
8
9
  const edgeConfig = edgeRegistry[edgeCollectionName];
@@ -18,7 +19,12 @@ const getPgEdge = async (db, edgeCollectionName, fromId, toId) => {
18
19
  const row = rows[0];
19
20
  if (!row)
20
21
  return undefined;
21
- return Object.assign(Object.assign({}, row.body), { id: row.id, _from: `${edgeConfig.fromCollection}/${row.fromId}`, _to: `${edgeConfig.toCollection}/${row.toId}` });
22
+ return {
23
+ ...row.body,
24
+ id: row.id,
25
+ _from: `${edgeConfig.fromCollection}/${row.fromId}`,
26
+ _to: `${edgeConfig.toCollection}/${row.toId}`,
27
+ };
22
28
  };
23
29
  export const connector = (fromCollectionInfo, toCollectionInfo, edgeCollectionInfo) => async (db, from, to, data = {}) => {
24
30
  const edgeConfig = edgeRegistry[edgeCollectionInfo.name];
@@ -26,7 +32,12 @@ export const connector = (fromCollectionInfo, toCollectionInfo, edgeCollectionIn
26
32
  throw new Error(`Unknown edge collection: ${edgeCollectionInfo.name}`);
27
33
  }
28
34
  const id = await insertEdge(db, edgeConfig.table, from.id, to.id, data);
29
- return Object.assign(Object.assign({}, data), { id, _from: `${fromCollectionInfo.name}/${from.id}`, _to: `${toCollectionInfo.name}/${to.id}` });
35
+ return {
36
+ ...data,
37
+ id,
38
+ _from: `${fromCollectionInfo.name}/${from.id}`,
39
+ _to: `${toCollectionInfo.name}/${to.id}`,
40
+ };
30
41
  };
31
42
  export const disconnector = (_fromCollectionInfo, _toCollectionInfo, edgeCollectionInfo) => async (db, from, to) => {
32
43
  const edgeConfig = edgeRegistry[edgeCollectionInfo.name];
@@ -44,7 +55,7 @@ export const connectionUpdater = (_fromCollectionInfo, _toCollectionInfo, edgeCo
44
55
  await db
45
56
  .update(edgeConfig.table)
46
57
  .set({
47
- body: data !== null && data !== void 0 ? data : {},
58
+ body: data ?? {},
48
59
  updatedAt: nowIso(),
49
60
  })
50
61
  .where(and(eq(table.fromId, from.id), eq(table.toId, to.id)));
@@ -56,11 +67,18 @@ export const filterBefore = (mapping, id) => id
56
67
  export const filterAfter = (mapping, id) => id
57
68
  ? mapping.filter(documentKeyAfter(mapping.data().collection, id))
58
69
  : mapping;
59
- export const addQuerySort = (mapping, sort) => ((sort === null || sort === void 0 ? void 0 : sort.length) ? mapping.sort(sort) : mapping);
70
+ export const addQuerySort = (mapping, sort) => (sort?.length ? mapping.sort(sort) : mapping);
60
71
  export const sortNewestFirst = (mapping) => mapping.sort(sorts.idDesc);
61
72
  export const sortOldestFirst = (mapping) => mapping.sort(sorts.idAsc);
62
73
  export const addStartLimit = (mapping, start, limit = 100) => filterBefore(sortNewestFirst(mapping.limit(limit)), start);
63
- export const addStart = (mapping, start) => filterBefore(sortNewestFirst(mapping), start);
74
+ export const addStart = (mapping, start) => filterBefore(sortNewestFirst(mapping), parseFeedCursor(start)?.id);
75
+ export const addActivityStart = (mapping, start) => {
76
+ const sorted = mapping.sort(sorts.lastActivityDesc);
77
+ const cursor = parseFeedCursor(start);
78
+ if (!cursor)
79
+ return sorted;
80
+ return sorted.filter(postFilters.afterActivity(cursor));
81
+ };
64
82
  const buildLimit = (limit, offset) => limit && offset ? [offset, limit] : limit;
65
83
  /**
66
84
  * Ceiling on base rows read for one page, as a multiple of the page size. A
@@ -5,7 +5,7 @@ export * from './explorer';
5
5
  export { map } from './pg/map';
6
6
  export { collectionInfos } from './pg/collections';
7
7
  export type { CollectionInfoKey } from './pg/collections';
8
- export type { PgDb } from './pg/client';
8
+ export { closePostgres, type PgDb } from './pg/client';
9
9
  export type { PgFilter, SqlFilter } from './pg/map/queryTypes';
10
10
  export { combine, createdAtBetween, documentKeyAfter, documentKeyBefore, edgeFilters, eventTimeFilters, groupFilters, isSqlFilter, notificationFilters, pgSql, postFilters, profileFilters, } from './pg/filters';
11
11
  export { computedFields, sorts } from './pg/queries';
package/dist/db/index.js CHANGED
@@ -3,6 +3,7 @@ export { empty } from './examples.js';
3
3
  export * from './explorer/index.js';
4
4
  export { map } from './pg/map/index.js';
5
5
  export { collectionInfos } from './pg/collections.js';
6
+ export { closePostgres } from './pg/client.js';
6
7
  export { combine, createdAtBetween, documentKeyAfter, documentKeyBefore, edgeFilters, eventTimeFilters, groupFilters, isSqlFilter, notificationFilters, pgSql, postFilters, profileFilters, } from './pg/filters/index.js';
7
8
  export { computedFields, sorts } from './pg/queries/index.js';
8
9
  let dbPromise;
package/dist/db/init.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { logger } from '../log/index.js';
2
2
  import { initPostgres } from './pg/client.js';
3
+ import { backfillLocalFederationIdentities } from '../federation/identity.js';
3
4
  const log = logger('openpeeps:db');
4
5
  export const initDb = async () => {
5
6
  log.info('Initializing Postgres');
6
- if (process.env.AUTO_MIGRATE_FROM_ARANGO === 'true') {
7
- log.warn('AUTO_MIGRATE_FROM_ARANGO is ignored at runtime. Use @openpeepshq/arango-migrate (archive/arango-migrate) for Arango cutover.');
8
- }
9
7
  const db = await initPostgres();
8
+ await backfillLocalFederationIdentities();
10
9
  return { db };
11
10
  };
@@ -1,17 +1,22 @@
1
- import { type ImportContext } from './transform';
2
- /** Arango exports can contain duplicate _key lines; keep the last row per id. */
1
+ /** Keep the last row per id when a JSONL file repeats keys. */
3
2
  export declare const dedupeRowsById: <T extends Record<string, unknown>>(rows: T[]) => T[];
4
3
  export declare const collectionJsonlPath: (collectionsDir: string, collection: string) => string;
5
4
  export declare const truncateAllTables: () => Promise<void>;
6
5
  export declare const isUuid: (value: unknown) => value is string;
7
- /** Collapse empty / duplicate hashtag names onto one row (unique on name). */
8
- export declare const prepareHashtagRows: (rows: Record<string, unknown>[], context: ImportContext) => Record<string, unknown>[];
9
- export declare const importArangoCollection: (collection: string, collectionsDir: string, context?: ImportContext) => Promise<number>;
10
6
  export declare const importPostgresRowCollection: (collection: string, collectionsDir: string) => Promise<number>;
11
- export declare const importAllArangoCollections: (collectionsDir: string) => Promise<{
12
- imported: Record<string, number>;
13
- total: number;
14
- }>;
7
+ /** Legacy reactions rows become append-only reaction entries. */
8
+ export declare const wrapReactionEntryBody: (body: Record<string, unknown> | null | undefined) => {
9
+ type: "reaction";
10
+ data: {
11
+ reaction: string;
12
+ };
13
+ };
14
+ /** Older dumps may still have reactions.jsonl; store them as entries. */
15
+ export declare const importLegacyReactionsAsEntries: (collectionsDir: string) => Promise<number>;
16
+ export type PlaceholderColumn = {
17
+ table: string;
18
+ column: string;
19
+ };
15
20
  export declare const importAllPostgresCollections: (collectionsDir: string, schemaVersionFromBackup?: string) => Promise<{
16
21
  imported: Record<string, number>;
17
22
  total: number;
@@ -2,23 +2,33 @@ import { randomUUID } from 'node:crypto';
2
2
  import { appendFile, access } from 'node:fs/promises';
3
3
  import { constants } from 'node:fs';
4
4
  import { join } from 'node:path';
5
- import { getTableName, sql } from 'drizzle-orm';
5
+ import { getTableColumns, getTableName, sql } from 'drizzle-orm';
6
6
  import { logger } from '../../log/index.js';
7
7
  import { pgDb } from '../pg/client.js';
8
8
  import { resetAndMigrateToSchemaVersion, resolveRestoreSchemaVersion, runMigrations, } from '../pg/migrate.js';
9
- import { documentRegistry, edgeRegistry, getTableForCollection, } from '../pg/map/registry.js';
10
- import { arangoDocToDocumentRow, arangoDocToEdgeRow, buildPostCreatorIdByPostId, isEdgeCollection, normalizeImportId, } from './transform.js';
9
+ import { documentRegistry, edgeRegistry, getTableForCollection, isEdgeCollection, } from '../pg/map/registry.js';
11
10
  import { BATCH_SIZE, DOCUMENT_IMPORT_ORDER, EDGE_IMPORT_ORDER, readJsonl, } from './shared.js';
12
11
  const log = logger('core:db:import');
13
- const rowDedupeKey = (row) => { var _a; return normalizeImportId((_a = row.id) !== null && _a !== void 0 ? _a : row.key); };
14
- /** Arango exports can contain duplicate _key lines; keep the last row per id. */
12
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13
+ const normalizeImportId = (value) => {
14
+ if (typeof value !== 'string') {
15
+ return undefined;
16
+ }
17
+ const trimmed = value.trim();
18
+ if (!trimmed) {
19
+ return undefined;
20
+ }
21
+ return UUID_RE.test(trimmed) ? trimmed.toLowerCase() : trimmed;
22
+ };
23
+ const rowDedupeKey = (row) => normalizeImportId(row.id ?? row.key);
24
+ /** Keep the last row per id when a JSONL file repeats keys. */
15
25
  export const dedupeRowsById = (rows) => {
16
26
  const byKey = new Map();
17
27
  const withoutKey = [];
18
28
  for (const row of rows) {
19
29
  const key = rowDedupeKey(row);
20
30
  if (key) {
21
- byKey.set(key, typeof row.id === 'string' ? Object.assign(Object.assign({}, row), { id: key }) : row);
31
+ byKey.set(key, typeof row.id === 'string' ? { ...row, id: key } : row);
22
32
  }
23
33
  else {
24
34
  withoutKey.push(row);
@@ -29,7 +39,6 @@ export const dedupeRowsById = (rows) => {
29
39
  export const collectionJsonlPath = (collectionsDir, collection) => join(collectionsDir, `${collection}.jsonl`);
30
40
  const isKnownCollection = (collection) => collection in documentRegistry || collection in edgeRegistry;
31
41
  export const truncateAllTables = async () => {
32
- var _a;
33
42
  const db = pgDb();
34
43
  const tableNames = [
35
44
  ...EDGE_IMPORT_ORDER.map((collection) => getTableName(edgeRegistry[collection].table)),
@@ -40,7 +49,7 @@ export const truncateAllTables = async () => {
40
49
  const existing = [];
41
50
  for (const name of tableNames) {
42
51
  const result = await db.execute(sql.raw(`SELECT to_regclass('public.${name}')::text AS regclass`));
43
- if (((_a = result.rows[0]) === null || _a === void 0 ? void 0 : _a.regclass) != null) {
52
+ if (result.rows[0]?.regclass != null) {
44
53
  existing.push(name);
45
54
  }
46
55
  }
@@ -49,98 +58,20 @@ export const truncateAllTables = async () => {
49
58
  }
50
59
  await db.execute(sql.raw(`TRUNCATE TABLE ${existing.map((name) => `"${name}"`).join(', ')} RESTART IDENTITY CASCADE`));
51
60
  };
52
- const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
53
61
  export const isUuid = (value) => typeof value === 'string' && UUID_RE.test(value);
54
- /**
55
- * Edge `id` columns are uuid. Legacy Arango edge `_key`s are sometimes numeric
56
- * (or otherwise non-UUID); replace those so the insert does not fail. Document
57
- * collections are left alone (`data_migrations.id` is text, not uuid).
58
- */
59
62
  const ensureEdgeUuidId = (collection, row) => {
60
- var _a;
61
63
  if (!isEdgeCollection(collection)) {
62
64
  return row;
63
65
  }
64
66
  if (isUuid(row.id)) {
65
- const normalized = (_a = normalizeImportId(row.id)) !== null && _a !== void 0 ? _a : String(row.id);
66
- return normalized === row.id ? row : Object.assign(Object.assign({}, row), { id: normalized });
67
+ const normalized = normalizeImportId(row.id) ?? String(row.id);
68
+ return normalized === row.id ? row : { ...row, id: normalized };
67
69
  }
68
- const next = Object.assign(Object.assign({}, row), { id: randomUUID() });
70
+ const next = { ...row, id: randomUUID() };
69
71
  log.warn('Replaced non-UUID %s edge id %s with %s', collection, String(row.id), next.id);
70
72
  return next;
71
73
  };
72
- const documentRowIsImportable = (collection, row) => {
73
- if (collection === 'posts' && !row.creatorId) {
74
- log.warn('Skipping post %s: missing creatorId', row.id);
75
- return false;
76
- }
77
- if (collection === 'jamEvents' && !row.postId) {
78
- log.warn('Skipping jam event %s: missing postId', row.id);
79
- return false;
80
- }
81
- if (collection === 'profileSettings' && !row.profileId) {
82
- log.warn('Skipping profile settings %s: missing profileId', row.id);
83
- return false;
84
- }
85
- return true;
86
- };
87
- /** Collapse empty / duplicate hashtag names onto one row (unique on name). */
88
- export const prepareHashtagRows = (rows, context) => {
89
- var _a;
90
- const remap = (_a = context.hashtagIdRemap) !== null && _a !== void 0 ? _a : new Map();
91
- context.hashtagIdRemap = remap;
92
- const byName = new Map();
93
- const prepared = [];
94
- for (const row of rows) {
95
- const id = typeof row.id === 'string' ? row.id : undefined;
96
- const name = typeof row.name === 'string' ? row.name.trim().toLowerCase() : '';
97
- if (!name) {
98
- if (id)
99
- remap.set(id, '');
100
- log.warn('Skipping hashtag %s: empty name', id !== null && id !== void 0 ? id : '(no id)');
101
- continue;
102
- }
103
- row.name = name;
104
- const existing = byName.get(name);
105
- if (existing) {
106
- const keptId = typeof existing.id === 'string' ? existing.id : '';
107
- if (id)
108
- remap.set(id, keptId);
109
- log.warn('Skipping duplicate hashtag name "%s" (id %s → %s)', name, id, keptId || '(unknown)');
110
- continue;
111
- }
112
- byName.set(name, row);
113
- prepared.push(row);
114
- }
115
- return prepared;
116
- };
117
- const applyHashtagEdgeRemap = (collection, rows, context) => {
118
- var _a;
119
- if (collection !== 'postHashtags' || !((_a = context.hashtagIdRemap) === null || _a === void 0 ? void 0 : _a.size)) {
120
- return rows;
121
- }
122
- const remap = context.hashtagIdRemap;
123
- const out = [];
124
- let dropped = 0;
125
- for (const row of rows) {
126
- const toId = typeof row.toId === 'string' ? row.toId : undefined;
127
- if (!toId || !remap.has(toId)) {
128
- out.push(row);
129
- continue;
130
- }
131
- const mapped = remap.get(toId);
132
- if (!mapped) {
133
- dropped += 1;
134
- continue;
135
- }
136
- out.push(Object.assign(Object.assign({}, row), { toId: mapped }));
137
- }
138
- if (dropped > 0) {
139
- log.warn('Dropped %d postHashtags edge(s) pointing at skipped hashtags', dropped);
140
- }
141
- return out;
142
- };
143
- export const importArangoCollection = async (collection, collectionsDir, context = {}) => {
74
+ export const importPostgresRowCollection = async (collection, collectionsDir) => {
144
75
  if (!isKnownCollection(collection)) {
145
76
  return 0;
146
77
  }
@@ -148,123 +79,136 @@ export const importArangoCollection = async (collection, collectionsDir, context
148
79
  try {
149
80
  await access(filePath, constants.F_OK);
150
81
  }
151
- catch (_a) {
82
+ catch {
152
83
  return 0;
153
84
  }
154
- const docs = await readJsonl(filePath);
155
- if (docs.length === 0) {
85
+ const mapped = await readJsonl(filePath);
86
+ if (mapped.length === 0) {
156
87
  return 0;
157
88
  }
89
+ const withValidIds = mapped.map((row) => ensureEdgeUuidId(collection, row));
90
+ const rows = dedupeRowsById(withValidIds);
91
+ if (rows.length < mapped.length) {
92
+ log.warn('Dropped %d duplicate row(s) while importing %s', mapped.length - rows.length, collection);
93
+ }
158
94
  const table = getTableForCollection(collection);
159
95
  const db = pgDb();
160
- let mapped = docs.map((doc) => isEdgeCollection(collection)
161
- ? arangoDocToEdgeRow(collection, doc)
162
- : arangoDocToDocumentRow(collection, doc, context));
163
- if (collection === 'hashtags') {
164
- mapped = prepareHashtagRows(mapped, context);
165
- }
166
- else {
167
- mapped = mapped.filter((row) => documentRowIsImportable(collection, row));
168
- }
169
- mapped = applyHashtagEdgeRemap(collection, mapped, context);
170
- mapped = mapped.map((row) => ensureEdgeUuidId(collection, row));
171
- const beforeDedupe = mapped.length;
172
- const rows = dedupeRowsById(mapped);
173
- if (rows.length < beforeDedupe) {
174
- log.warn('Dropped %d duplicate row(s) while importing %s (e.g. remapped config keys or duplicate _key)', beforeDedupe - rows.length, collection);
175
- }
176
- if (rows.length === 0) {
177
- return 0;
178
- }
179
96
  let imported = 0;
180
97
  for (let offset = 0; offset < rows.length; offset += BATCH_SIZE) {
181
98
  const batch = rows.slice(offset, offset + BATCH_SIZE);
182
- try {
183
- await db.insert(table).values(batch);
184
- }
185
- catch (err) {
186
- const cause = err && typeof err === 'object' && 'cause' in err
187
- ? err.cause
188
- : undefined;
189
- const detail = cause instanceof Error
190
- ? cause.message
191
- : err instanceof Error
192
- ? err.message
193
- : String(err);
194
- throw new Error(`Failed importing ${collection} batch at offset ${offset} (${batch.length} rows): ${detail}`);
195
- }
99
+ await db.insert(table).values(batch);
196
100
  imported += batch.length;
197
101
  }
198
- log.info('Imported %d rows into %s from Arango JSONL', imported, collection);
102
+ log.info('Imported %d rows into %s from Postgres JSONL', imported, collection);
199
103
  return imported;
200
104
  };
201
- export const importPostgresRowCollection = async (collection, collectionsDir) => {
202
- if (!isKnownCollection(collection)) {
105
+ /** Legacy reactions rows become append-only reaction entries. */
106
+ export const wrapReactionEntryBody = (body) => {
107
+ if (body?.type === 'reaction') {
108
+ const reaction = typeof body.data?.reaction ===
109
+ 'string'
110
+ ? body.data.reaction
111
+ : typeof body.reaction === 'string'
112
+ ? body.reaction
113
+ : '👍';
114
+ return { type: 'reaction', data: { reaction } };
115
+ }
116
+ const reaction = typeof body?.reaction === 'string' ? body.reaction : '👍';
117
+ return { type: 'reaction', data: { reaction } };
118
+ };
119
+ const insertEntryRows = async (rows) => {
120
+ if (rows.length === 0)
203
121
  return 0;
122
+ const table = getTableForCollection('entries');
123
+ const db = pgDb();
124
+ let imported = 0;
125
+ for (let offset = 0; offset < rows.length; offset += BATCH_SIZE) {
126
+ const batch = rows.slice(offset, offset + BATCH_SIZE);
127
+ await db.insert(table).values(batch);
128
+ imported += batch.length;
204
129
  }
205
- const filePath = collectionJsonlPath(collectionsDir, collection);
130
+ return imported;
131
+ };
132
+ /** Older dumps may still have reactions.jsonl; store them as entries. */
133
+ export const importLegacyReactionsAsEntries = async (collectionsDir) => {
134
+ const filePath = collectionJsonlPath(collectionsDir, 'reactions');
206
135
  try {
207
136
  await access(filePath, constants.F_OK);
208
137
  }
209
- catch (_a) {
138
+ catch {
210
139
  return 0;
211
140
  }
212
- const mapped = await readJsonl(filePath);
213
- if (mapped.length === 0) {
141
+ const docs = await readJsonl(filePath);
142
+ if (docs.length === 0) {
214
143
  return 0;
215
144
  }
216
- const withValidIds = mapped.map((row) => ensureEdgeUuidId(collection, row));
217
- const rows = dedupeRowsById(withValidIds);
218
- if (rows.length < mapped.length) {
219
- log.warn('Dropped %d duplicate row(s) while importing %s', mapped.length - rows.length, collection);
220
- }
221
- const table = getTableForCollection(collection);
222
- const db = pgDb();
223
- let imported = 0;
224
- for (let offset = 0; offset < rows.length; offset += BATCH_SIZE) {
225
- const batch = rows.slice(offset, offset + BATCH_SIZE);
226
- await db.insert(table).values(batch);
227
- imported += batch.length;
228
- }
229
- log.info('Imported %d rows into %s from Postgres JSONL', imported, collection);
145
+ const mapped = docs.map((doc) => ensureEdgeUuidId('entries', {
146
+ ...doc,
147
+ body: wrapReactionEntryBody(doc.body ?? doc),
148
+ }));
149
+ const rows = dedupeRowsById(mapped);
150
+ const imported = await insertEntryRows(rows);
151
+ log.info('Imported %d legacy reactions as entries', imported);
230
152
  return imported;
231
153
  };
232
154
  const sumImported = (imported) => Object.values(imported).reduce((sum, count) => sum + count, 0);
233
- const prepareSchemaForRestore = async (databaseType, schemaVersionFromBackup) => {
234
- const schemaVersion = resolveRestoreSchemaVersion(databaseType, schemaVersionFromBackup);
235
- log.info('Preparing %s restore at schema %s', databaseType, schemaVersion);
155
+ const liveColumnNames = async (table) => {
156
+ const result = await pgDb().execute(sql `SELECT column_name FROM information_schema.columns
157
+ WHERE table_schema = 'public' AND table_name = ${table}`);
158
+ return new Set(result.rows.map((row) => row.column_name));
159
+ };
160
+ /**
161
+ * A restore loads rows at an older schema version, but Drizzle names every
162
+ * column of the current table objects in its INSERT, so a column a later
163
+ * migration adds (e.g. `search_vector` in 0001) breaks the load. Add those as
164
+ * nullable placeholders and drop them again before migrating forward, so the
165
+ * migration still creates them itself and runs its backfill.
166
+ */
167
+ const addPlaceholderColumns = async () => {
168
+ const db = pgDb();
169
+ const added = [];
170
+ for (const collection of [...DOCUMENT_IMPORT_ORDER, ...EDGE_IMPORT_ORDER]) {
171
+ const table = getTableForCollection(collection);
172
+ const tableName = getTableName(table);
173
+ const live = await liveColumnNames(tableName);
174
+ if (live.size === 0) {
175
+ continue;
176
+ }
177
+ for (const column of Object.values(getTableColumns(table))) {
178
+ if (live.has(column.name)) {
179
+ continue;
180
+ }
181
+ await db.execute(sql.raw(`ALTER TABLE "${tableName}" ADD COLUMN "${column.name}" ${column.getSQLType()}`));
182
+ added.push({ table: tableName, column: column.name });
183
+ }
184
+ }
185
+ if (added.length > 0) {
186
+ log.info('Added %d placeholder column(s) for the restore: %s', added.length, added.map(({ table, column }) => `${table}.${column}`).join(', '));
187
+ }
188
+ return added;
189
+ };
190
+ const dropPlaceholderColumns = async (columns) => {
191
+ for (const { table, column } of columns) {
192
+ await pgDb().execute(sql.raw(`ALTER TABLE "${table}" DROP COLUMN IF EXISTS "${column}"`));
193
+ }
194
+ };
195
+ const backfillFederationIdentities = async () => {
196
+ const { backfillLocalFederationIdentities } = await import('../../federation/identity.js');
197
+ await backfillLocalFederationIdentities();
198
+ };
199
+ const prepareSchemaForRestore = async (schemaVersionFromBackup) => {
200
+ const schemaVersion = resolveRestoreSchemaVersion(schemaVersionFromBackup);
201
+ log.info('Preparing postgres restore at schema %s', schemaVersion);
236
202
  await resetAndMigrateToSchemaVersion(schemaVersion);
237
203
  // 0006 added a unique (from_id, to_id) on post_seen; that was wrong for
238
204
  // impressions. Drop it before import so pre-0007 backups with duplicate
239
205
  // view rows can restore. 0007 (and later) drop it permanently.
240
206
  await pgDb().execute(sql.raw('DROP INDEX IF EXISTS "post_seen_from_to_unique"'));
241
207
  await truncateAllTables();
242
- };
243
- export const importAllArangoCollections = async (collectionsDir) => {
244
- await prepareSchemaForRestore('arango');
245
- const imported = {};
246
- const context = {
247
- postCreatorIdByPostId: await buildPostCreatorIdByPostId(collectionsDir),
248
- hashtagIdRemap: new Map(),
249
- };
250
- // Skip dataMigrations — Arango-era migration ledger is unused on Postgres.
251
- for (const collection of DOCUMENT_IMPORT_ORDER) {
252
- if (collection === 'dataMigrations') {
253
- continue;
254
- }
255
- imported[collection] = await importArangoCollection(collection, collectionsDir, context);
256
- }
257
- for (const collection of EDGE_IMPORT_ORDER) {
258
- imported[collection] = await importArangoCollection(collection, collectionsDir, context);
259
- }
260
- log.info('Arango rows loaded; migrating schema forward to latest');
261
- await runMigrations();
262
- const total = sumImported(imported);
263
- log.info('Arango JSONL import complete: %d rows across %d collections', total, Object.keys(imported).filter((key) => imported[key] > 0).length);
264
- return { imported, total };
208
+ return addPlaceholderColumns();
265
209
  };
266
210
  export const importAllPostgresCollections = async (collectionsDir, schemaVersionFromBackup) => {
267
- await prepareSchemaForRestore('postgres', schemaVersionFromBackup);
211
+ const placeholders = await prepareSchemaForRestore(schemaVersionFromBackup);
268
212
  const imported = {};
269
213
  for (const collection of DOCUMENT_IMPORT_ORDER) {
270
214
  imported[collection] = await importPostgresRowCollection(collection, collectionsDir);
@@ -272,8 +216,11 @@ export const importAllPostgresCollections = async (collectionsDir, schemaVersion
272
216
  for (const collection of EDGE_IMPORT_ORDER) {
273
217
  imported[collection] = await importPostgresRowCollection(collection, collectionsDir);
274
218
  }
219
+ imported.reactions = await importLegacyReactionsAsEntries(collectionsDir);
275
220
  log.info('Postgres rows loaded; ensuring schema is at latest');
221
+ await dropPlaceholderColumns(placeholders);
276
222
  await runMigrations();
223
+ await backfillFederationIdentities();
277
224
  const total = sumImported(imported);
278
225
  log.info('Postgres JSONL import complete: %d rows across %d collections', total, Object.keys(imported).filter((key) => imported[key] > 0).length);
279
226
  return { imported, total };
@@ -1,35 +1,4 @@
1
- export declare const DEFAULT_EXPORT_DIR = "./arango-export";
2
- export declare const exportDirFromEnv: () => string;
3
- export declare const collectionsDir: (exportDir: string) => string;
4
- export declare const manifestPath: (exportDir: string) => string;
5
- /** Counts actually inserted into Postgres (after skips / remaps / dedupe). */
6
- export declare const importStatsPath: (exportDir: string) => string;
7
- export type ImportStats = {
8
- importedAt: string;
9
- collections: CollectionCounts;
10
- };
11
- export declare const collectionFilePath: (exportDir: string, collection: string) => string;
12
- export declare const DOCUMENT_IMPORT_ORDER: readonly ["configs", "i18n", "dataMigrations", "accounts", "roles", "profiles", "groups", "hashtags", "posts", "notifications", "reports", "accessTokens", "pushSubscriptions", "inviteLinks", "jamEvents", "mediaAttachments", "processingStats", "profileSettings"];
13
- export declare const EDGE_IMPORT_ORDER: readonly ["controls", "follows", "requestsFollow", "mentions", "audience", "postHashtags", "entries", "reactions", "replyTo", "repost", "bookmarks", "postSeen", "hasSeen", "hasRead", "userGroups", "postGroups", "hasRole", "profileAccessTokens", "accountToPushSubscription", "createdReport", "isReportedProfile", "isReportedObject", "inviteLinkCreators", "inviteLinkRedeemers", "jamRecordings"];
14
- export type CollectionCounts = Record<string, number>;
15
- export type MigrationManifest = {
16
- exportedAt: string;
17
- dbUrl: string;
18
- dbName?: string;
19
- collections: CollectionCounts;
20
- checksums: {
21
- accountEmails: string;
22
- postIds: string;
23
- };
24
- };
25
- export declare const sha256: (value: string) => string;
26
- export declare const sortedChecksum: (values: string[]) => string;
1
+ export declare const DOCUMENT_IMPORT_ORDER: readonly ["configs", "i18n", "accounts", "roles", "profiles", "groups", "hashtags", "posts", "notifications", "reports", "accessTokens", "pushSubscriptions", "inviteLinks", "jamEvents", "mediaAttachments", "processingStats", "profileSettings"];
2
+ export declare const EDGE_IMPORT_ORDER: readonly ["controls", "follows", "blocks", "requestsFollow", "mentions", "audience", "postHashtags", "entries", "replyTo", "repost", "bookmarks", "postSeen", "hasSeen", "hasRead", "userGroups", "postGroups", "hasRole", "profileAccessTokens", "accountToPushSubscription", "createdReport", "isReportedProfile", "isReportedObject", "inviteLinkCreators", "inviteLinkRedeemers", "jamRecordings", "profileHashtags"];
27
3
  export declare const readJsonl: (filePath: string) => Promise<Record<string, unknown>[]>;
28
- export declare const readManifest: (exportDir: string) => Promise<MigrationManifest>;
29
- export declare const writeManifest: (exportDir: string, manifest: MigrationManifest) => Promise<void>;
30
- export declare const writeImportStats: (exportDir: string, collections: CollectionCounts) => Promise<void>;
31
- export declare const readImportStats: (exportDir: string) => Promise<ImportStats | null>;
32
- /** Prefer post-import counts when present (skips / remaps / dedupe). */
33
- export declare const expectedCollectionCount: (collection: string, manifestCounts: CollectionCounts, importedCounts: CollectionCounts | null) => number;
34
- export declare const assertExportDir: (exportDir: string) => Promise<void>;
35
4
  export declare const BATCH_SIZE = 500;