@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,39 +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 arangoConfig: () => {
26
- url: string;
27
- databaseName: string | undefined;
28
- };
29
- export declare const sha256: (value: string) => string;
30
- 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"];
31
3
  export declare const readJsonl: (filePath: string) => Promise<Record<string, unknown>[]>;
32
- export declare const readManifest: (exportDir: string) => Promise<MigrationManifest>;
33
- export declare const writeManifest: (exportDir: string, manifest: MigrationManifest) => Promise<void>;
34
- export declare const writeImportStats: (exportDir: string, collections: CollectionCounts) => Promise<void>;
35
- export declare const readImportStats: (exportDir: string) => Promise<ImportStats | null>;
36
- /** Prefer post-import counts when present (skips / remaps / dedupe). */
37
- export declare const expectedCollectionCount: (collection: string, manifestCounts: CollectionCounts, importedCounts: CollectionCounts | null) => number;
38
- export declare const assertExportDir: (exportDir: string) => Promise<void>;
39
4
  export declare const BATCH_SIZE = 500;
@@ -5,25 +5,11 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
5
5
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
6
6
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7
7
  };
8
- import { createHash } from 'node:crypto';
9
8
  import { createReadStream } from 'node:fs';
10
- import { access, readFile, writeFile } from 'node:fs/promises';
11
- import { constants } from 'node:fs';
12
9
  import { createInterface } from 'node:readline';
13
- import { join } from 'node:path';
14
- import dotenv from 'dotenv';
15
- dotenv.config();
16
- export const DEFAULT_EXPORT_DIR = './arango-export';
17
- export const exportDirFromEnv = () => { var _a; return (_a = process.env.MIGRATION_EXPORT_DIR) !== null && _a !== void 0 ? _a : DEFAULT_EXPORT_DIR; };
18
- export const collectionsDir = (exportDir) => join(exportDir, 'collections');
19
- export const manifestPath = (exportDir) => join(exportDir, 'manifest.json');
20
- /** Counts actually inserted into Postgres (after skips / remaps / dedupe). */
21
- export const importStatsPath = (exportDir) => join(exportDir, 'import-stats.json');
22
- export const collectionFilePath = (exportDir, collection) => join(collectionsDir(exportDir), `${collection}.jsonl`);
23
10
  export const DOCUMENT_IMPORT_ORDER = [
24
11
  'configs',
25
12
  'i18n',
26
- 'dataMigrations',
27
13
  'accounts',
28
14
  'roles',
29
15
  'profiles',
@@ -43,12 +29,12 @@ export const DOCUMENT_IMPORT_ORDER = [
43
29
  export const EDGE_IMPORT_ORDER = [
44
30
  'controls',
45
31
  'follows',
32
+ 'blocks',
46
33
  'requestsFollow',
47
34
  'mentions',
48
35
  'audience',
49
36
  'postHashtags',
50
37
  'entries',
51
- 'reactions',
52
38
  'replyTo',
53
39
  'repost',
54
40
  'bookmarks',
@@ -66,16 +52,8 @@ export const EDGE_IMPORT_ORDER = [
66
52
  'inviteLinkCreators',
67
53
  'inviteLinkRedeemers',
68
54
  'jamRecordings',
55
+ 'profileHashtags',
69
56
  ];
70
- export const arangoConfig = () => {
71
- var _a;
72
- return ({
73
- url: (_a = process.env.DB_URL) !== null && _a !== void 0 ? _a : 'http://localhost:8529',
74
- databaseName: process.env.DB_NAME,
75
- });
76
- };
77
- export const sha256 = (value) => createHash('sha256').update(value).digest('hex');
78
- export const sortedChecksum = (values) => sha256(values.filter(Boolean).sort().join('\n'));
79
57
  export const readJsonl = async (filePath) => {
80
58
  var _a, e_1, _b, _c;
81
59
  const docs = [];
@@ -120,39 +98,4 @@ export const readJsonl = async (filePath) => {
120
98
  }
121
99
  return docs;
122
100
  };
123
- export const readManifest = async (exportDir) => {
124
- const raw = await readFile(manifestPath(exportDir), 'utf-8');
125
- return JSON.parse(raw);
126
- };
127
- export const writeManifest = async (exportDir, manifest) => {
128
- await writeFile(manifestPath(exportDir), JSON.stringify(manifest, null, 2));
129
- };
130
- export const writeImportStats = async (exportDir, collections) => {
131
- const stats = {
132
- importedAt: new Date().toISOString(),
133
- collections,
134
- };
135
- await writeFile(importStatsPath(exportDir), JSON.stringify(stats, null, 2));
136
- };
137
- export const readImportStats = async (exportDir) => {
138
- try {
139
- await access(importStatsPath(exportDir), constants.F_OK);
140
- }
141
- catch (_a) {
142
- return null;
143
- }
144
- const raw = await readFile(importStatsPath(exportDir), 'utf-8');
145
- return JSON.parse(raw);
146
- };
147
- /** Prefer post-import counts when present (skips / remaps / dedupe). */
148
- export const expectedCollectionCount = (collection, manifestCounts, importedCounts) => {
149
- var _a, _b;
150
- return importedCounts
151
- ? ((_a = importedCounts[collection]) !== null && _a !== void 0 ? _a : 0)
152
- : ((_b = manifestCounts[collection]) !== null && _b !== void 0 ? _b : 0);
153
- };
154
- export const assertExportDir = async (exportDir) => {
155
- await access(manifestPath(exportDir), constants.F_OK);
156
- await access(collectionsDir(exportDir), constants.F_OK);
157
- };
158
101
  export const BATCH_SIZE = 500;
@@ -95,6 +95,10 @@ export const closePostgres = async () => {
95
95
  await (pool === null || pool === void 0 ? void 0 : pool.end());
96
96
  pool = undefined;
97
97
  dbInstance = undefined;
98
+ // DROP SCHEMA / pool.end leaves allpeepDb() holding a dead Pool; next caller
99
+ // must re-run initDb() (e.g. setDefaultRoles after backup restore).
100
+ const { resetAllpeepDb } = await import('../index.js');
101
+ resetAllpeepDb();
98
102
  };
99
103
  /**
100
104
  * Drop and recreate app schemas. Drizzle stores its migration journal in
@@ -1,12 +1,12 @@
1
1
  import type { CollectionInfo } from './map/queryTypes';
2
2
  /** Named collection/edge refs aligned with `documentRegistry` and `edgeRegistry`. */
3
3
  export declare const collectionInfos: {
4
- readonly dataMigrationsCollection: CollectionInfo;
5
4
  readonly i18nCollection: CollectionInfo;
6
5
  readonly configCollection: CollectionInfo;
7
6
  readonly accountsCollection: CollectionInfo;
8
7
  readonly profilesCollection: CollectionInfo;
9
8
  readonly followsCollection: CollectionInfo;
9
+ readonly blocksCollection: CollectionInfo;
10
10
  readonly requestsFollowCollection: CollectionInfo;
11
11
  readonly controlsCollection: CollectionInfo;
12
12
  readonly postsCollection: CollectionInfo;
@@ -19,7 +19,6 @@ export declare const collectionInfos: {
19
19
  readonly isReportedProfileCollection: CollectionInfo;
20
20
  readonly isReportedObjectCollection: CollectionInfo;
21
21
  readonly entriesCollection: CollectionInfo;
22
- readonly reactionsCollection: CollectionInfo;
23
22
  readonly repliesCollection: CollectionInfo;
24
23
  readonly repostCollection: CollectionInfo;
25
24
  readonly mediaAttachmentsCollection: CollectionInfo;
@@ -44,5 +43,6 @@ export declare const collectionInfos: {
44
43
  readonly postSeenCollection: CollectionInfo;
45
44
  readonly profileSettingsCollection: CollectionInfo;
46
45
  readonly jamRecordingsCollection: CollectionInfo;
46
+ readonly profileHashtagsCollection: CollectionInfo;
47
47
  };
48
48
  export type CollectionInfoKey = keyof typeof collectionInfos;
@@ -7,12 +7,12 @@ const edge = (name) => ({
7
7
  });
8
8
  /** Named collection/edge refs aligned with `documentRegistry` and `edgeRegistry`. */
9
9
  export const collectionInfos = {
10
- dataMigrationsCollection: document('dataMigrations'),
11
10
  i18nCollection: document('i18n'),
12
11
  configCollection: document('configs'),
13
12
  accountsCollection: document('accounts'),
14
13
  profilesCollection: document('profiles'),
15
14
  followsCollection: edge('follows'),
15
+ blocksCollection: edge('blocks'),
16
16
  requestsFollowCollection: edge('requestsFollow'),
17
17
  controlsCollection: edge('controls'),
18
18
  postsCollection: document('posts'),
@@ -25,7 +25,6 @@ export const collectionInfos = {
25
25
  isReportedProfileCollection: edge('isReportedProfile'),
26
26
  isReportedObjectCollection: edge('isReportedObject'),
27
27
  entriesCollection: edge('entries'),
28
- reactionsCollection: edge('reactions'),
29
28
  repliesCollection: edge('replyTo'),
30
29
  repostCollection: edge('repost'),
31
30
  mediaAttachmentsCollection: document('mediaAttachments'),
@@ -50,4 +49,5 @@ export const collectionInfos = {
50
49
  postSeenCollection: edge('postSeen'),
51
50
  profileSettingsCollection: document('profileSettings'),
52
51
  jamRecordingsCollection: edge('jamRecordings'),
52
+ profileHashtagsCollection: edge('profileHashtags'),
53
53
  };
@@ -5,5 +5,5 @@ export declare const edgeFilters: {
5
5
  bodyFieldEq: (table: {
6
6
  body: unknown;
7
7
  }, field: string, value: string) => SqlFilter;
8
- groupAdminRole: () => SqlFilter;
8
+ groupOwnerRole: () => SqlFilter;
9
9
  };
@@ -6,5 +6,5 @@ export const edgeFilters = {
6
6
  entryType: (type) => pgSql(eq(sql `${entries.body}->>'type'`, type)),
7
7
  entryCreated: (start, end) => createdAtBetween(entries, start, end),
8
8
  bodyFieldEq: (table, field, value) => pgSql(eq(sql `${table.body}->>${field}`, value)),
9
- groupAdminRole: () => pgSql(sql `${userGroups.body}->'roles' ? 'admin'`),
9
+ groupOwnerRole: () => pgSql(sql `${userGroups.body}->'roles' ? 'owner'`),
10
10
  };
@@ -1,15 +1,26 @@
1
+ import type { FeedCursor } from '@openpeepshq/common';
1
2
  import { type SqlFilter } from './types';
2
3
  export declare const postFilters: {
3
4
  notDirect: () => SqlFilter;
4
5
  isDirect: () => SqlFilter;
6
+ /** Original posts only — replies belong in the parent thread, not the feed. */
7
+ notReply: () => SqlFilter;
8
+ /**
9
+ * Keyset for `ORDER BY last_activity_at DESC, id DESC`. A uuid-only cursor
10
+ * looks up the referenced row so older clients keep paginating.
11
+ */
12
+ afterActivity: (cursor: FeedCursor) => SqlFilter;
5
13
  hasJam: () => SqlFilter;
6
14
  creatorId: (id: string) => SqlFilter;
15
+ notCreatorIn: (ids: string[]) => SqlFilter | undefined;
16
+ myFeed: (profileId: string, followedProfileIds: string[], groupIds: string[]) => SqlFilter;
7
17
  type: (type: string) => SqlFilter;
8
18
  replyCount: (op: "==" | "!=" | ">" | ">=" | "<" | "<=", count: number) => SqlFilter;
9
19
  replyCountZero: () => SqlFilter;
10
20
  replyCountPositive: () => SqlFilter;
11
21
  isJamModerator: (profileId: string) => SqlFilter;
12
22
  hasYesOrMaybeRsvp: (profileId: string) => SqlFilter;
23
+ hasAnyHashtag: (hashtagIds: string[]) => SqlFilter | undefined;
13
24
  };
14
25
  export declare const eventTimeFilters: {
15
26
  upcoming: (now?: string) => SqlFilter;
@@ -1,25 +1,59 @@
1
- import { and, eq, isNotNull, ne, or, sql } from 'drizzle-orm';
1
+ import { and, eq, inArray, isNotNull, ne, notInArray, or, sql, } from 'drizzle-orm';
2
2
  import { posts } from '../schema/documents.js';
3
+ import { postGroups, postHashtags, replyTo } from '../schema/edges.js';
3
4
  import { postHasYesOrMaybeRsvpExpr, postReplyCountExpr, } from '../queries/activity.js';
4
5
  import { compareCount } from './common.js';
5
6
  import { pgSql } from './types.js';
6
7
  const eventStart = sql `${posts.body}->>'start'`;
7
8
  const eventEnd = sql `${posts.body}->>'end'`;
9
+ // Open-ended events count as one hour long when they are current or past.
10
+ const eventEffectiveEnd = sql `COALESCE(NULLIF(${eventEnd}, '')::timestamptz, ${eventStart}::timestamptz + interval '1 hour')`;
8
11
  const postsReplyCountExpr = postReplyCountExpr(posts);
9
12
  export const postFilters = {
10
13
  notDirect: () => pgSql(ne(posts.visibility, 'direct')),
11
14
  isDirect: () => pgSql(eq(posts.visibility, 'direct')),
15
+ /** Original posts only — replies belong in the parent thread, not the feed. */
16
+ notReply: () => pgSql(sql `NOT EXISTS (SELECT 1 FROM ${replyTo} WHERE ${replyTo.fromId} = ${posts.id}::text)`),
17
+ /**
18
+ * Keyset for `ORDER BY last_activity_at DESC, id DESC`. A uuid-only cursor
19
+ * looks up the referenced row so older clients keep paginating.
20
+ */
21
+ afterActivity: (cursor) => {
22
+ const activity = cursor.lastActivityAt
23
+ ? sql `${cursor.lastActivityAt}::timestamptz`
24
+ : sql `(SELECT p2.last_activity_at FROM posts p2 WHERE p2.id = ${cursor.id}::uuid)`;
25
+ return pgSql(sql `(
26
+ ${posts.lastActivityAt} < ${activity}
27
+ OR (
28
+ ${posts.lastActivityAt} = ${activity}
29
+ AND ${posts.id} < ${cursor.id}::uuid
30
+ )
31
+ )`);
32
+ },
12
33
  hasJam: () => pgSql(isNotNull(sql `${posts.body}->'jam'`)),
13
34
  creatorId: (id) => pgSql(eq(posts.creatorId, id)),
35
+ notCreatorIn: (ids) => ids.length ? pgSql(notInArray(posts.creatorId, ids)) : undefined,
36
+ myFeed: (profileId, followedProfileIds, groupIds) => {
37
+ const followed = followedProfileIds.length
38
+ ? inArray(posts.creatorId, followedProfileIds)
39
+ : sql `false`;
40
+ const groupMemberPost = groupIds.length
41
+ ? and(eq(posts.visibility, 'group'), sql `EXISTS (SELECT 1 FROM ${postGroups} WHERE ${postGroups.fromId} = ${posts.id}::text AND ${inArray(postGroups.toId, groupIds)})`)
42
+ : sql `false`;
43
+ return pgSql(or(eq(posts.creatorId, profileId), followed, groupMemberPost));
44
+ },
14
45
  type: (type) => pgSql(eq(posts.type, type)),
15
46
  replyCount: (op, count) => pgSql(compareCount(postsReplyCountExpr, op, count)),
16
47
  replyCountZero: () => postFilters.replyCount('==', 0),
17
48
  replyCountPositive: () => postFilters.replyCount('>', 0),
18
49
  isJamModerator: (profileId) => pgSql(sql `${posts.body}->'jam'->'moderators' ? ${profileId}`),
19
50
  hasYesOrMaybeRsvp: (profileId) => pgSql(postHasYesOrMaybeRsvpExpr(posts, profileId)),
51
+ hasAnyHashtag: (hashtagIds) => hashtagIds.length
52
+ ? pgSql(sql `EXISTS (SELECT 1 FROM ${postHashtags} WHERE ${postHashtags.fromId} = ${posts.id}::text AND ${inArray(postHashtags.toId, hashtagIds)})`)
53
+ : undefined,
20
54
  };
21
55
  export const eventTimeFilters = {
22
56
  upcoming: (now = new Date().toISOString()) => pgSql(or(sql `${eventStart} > ${now}`, and(sql `${posts.body}->'end' IS NOT NULL`, sql `${eventEnd} > ${now}`))),
23
- current: (now = new Date().toISOString()) => pgSql(and(sql `${eventStart} <= ${now}`, or(sql `${posts.body}->'end' IS NULL`, sql `${eventEnd} >= ${now}`))),
24
- past: (now = new Date().toISOString()) => pgSql(sql `COALESCE(${eventEnd}, ${eventStart}) < ${now}`),
57
+ current: (now = new Date().toISOString()) => pgSql(and(sql `${eventStart}::timestamptz <= ${now}::timestamptz`, sql `${eventEffectiveEnd} >= ${now}::timestamptz`)),
58
+ past: (now = new Date().toISOString()) => pgSql(sql `${eventEffectiveEnd} < ${now}::timestamptz`),
25
59
  };
@@ -2,5 +2,6 @@ import { type SqlFilter } from './types';
2
2
  export declare const profileFilters: {
3
3
  notGuest: () => SqlFilter;
4
4
  type: (type: string) => SqlFilter;
5
+ notIdIn: (ids: string[]) => SqlFilter | undefined;
5
6
  activityScorePositive: (start?: Date, end?: Date) => SqlFilter;
6
7
  };
@@ -1,9 +1,10 @@
1
- import { eq, gt, ne } from 'drizzle-orm';
1
+ import { eq, gt, ne, notInArray } from 'drizzle-orm';
2
2
  import { profiles } from '../schema/documents.js';
3
3
  import { profileActivityScoreExpr } from '../queries/activity.js';
4
4
  import { pgSql } from './types.js';
5
5
  export const profileFilters = {
6
6
  notGuest: () => pgSql(ne(profiles.type, 'guest')),
7
7
  type: (type) => pgSql(eq(profiles.type, type)),
8
+ notIdIn: (ids) => ids.length ? pgSql(notInArray(profiles.id, ids)) : undefined,
8
9
  activityScorePositive: (start, end) => pgSql(gt(profileActivityScoreExpr(profiles, { start, end }), 0)),
9
10
  };
@@ -5,8 +5,24 @@ import { groupLastPostAtExpr, postActivityScoreExpr, postReplyCountExpr, postRep
5
5
  import { asTable, edgeRegistry, getCollectionConfig, parseDocRef, } from './registry.js';
6
6
  const SCALAR_COLUMNS = {
7
7
  accounts: ['email', 'passwordHash', 'emailValidated', 'guest'],
8
- profiles: ['handle', 'type', 'activityPubDomain'],
9
- posts: ['type', 'visibility', 'creatorId'],
8
+ profiles: [
9
+ 'handle',
10
+ 'type',
11
+ 'activityPubDomain',
12
+ 'uri',
13
+ 'inboxUrl',
14
+ 'sharedInboxUrl',
15
+ 'keyId',
16
+ 'fetchedAt',
17
+ ],
18
+ posts: [
19
+ 'type',
20
+ 'visibility',
21
+ 'creatorId',
22
+ 'lastActivityAt',
23
+ 'uri',
24
+ 'inReplyToUri',
25
+ ],
10
26
  groups: ['handle'],
11
27
  hashtags: ['name'],
12
28
  roles: ['key', 'isDefault'],
@@ -92,6 +108,9 @@ const docFieldSql = (collection, table, fieldPath) => {
92
108
  return sql `${t.createdAt}`;
93
109
  if (fieldPath === 'updatedAt' && t.updatedAt)
94
110
  return sql `${t.updatedAt}`;
111
+ if (fieldPath === 'lastActivityAt' && t.lastActivityAt) {
112
+ return sql `${t.lastActivityAt}`;
113
+ }
95
114
  if (fieldPath === '_from' && t.fromId)
96
115
  return sql `${t.fromId}`;
97
116
  if (fieldPath === '_to' && t.toId)
@@ -399,6 +418,17 @@ const matchToSql = (collection, table, match) => {
399
418
  const config = getCollectionConfig(collection);
400
419
  if (!config)
401
420
  continue;
421
+ if (collection === 'profiles' &&
422
+ key === 'activityPub' &&
423
+ value &&
424
+ typeof value === 'object' &&
425
+ !Array.isArray(value)) {
426
+ const domain = value.domain;
427
+ if (typeof domain === 'string') {
428
+ conditions.push(eq(t.activityPubDomain, domain));
429
+ }
430
+ continue;
431
+ }
402
432
  if (config.kind === 'document') {
403
433
  const scalars = SCALAR_COLUMNS[collection];
404
434
  if (scalars === null || scalars === void 0 ? void 0 : scalars.includes(key)) {
@@ -438,6 +468,11 @@ export const filterToSql = (collection, table, filter) => {
438
468
  const matches = Array.isArray(filter.matches)
439
469
  ? filter.matches
440
470
  : [filter.matches];
471
+ // An empty match list is a valid predicate that can never match. Keeping
472
+ // it in SQL prevents an empty OR branch from demoting the whole filter to
473
+ // post-hydration evaluation.
474
+ if (!matches.length)
475
+ return sql `false`;
441
476
  const parts = matches
442
477
  .map((match) => matchToSql(collection, table, match))
443
478
  .filter(Boolean);
@@ -1,7 +1,7 @@
1
1
  import { eq } from 'drizzle-orm';
2
2
  import { uuidv7 } from 'uuidv7';
3
3
  import { nowIso } from '../mappers.js';
4
- import { asTable, documentRegistry, getCollectionConfig, getTableForCollection, } from './registry.js';
4
+ import { asTable, documentIdColumn, documentRegistry, getCollectionConfig, getTableForCollection, } from './registry.js';
5
5
  import { executeFind } from './relations.js';
6
6
  const EDGE_PATCH_META_KEYS = new Set([
7
7
  'id',
@@ -32,7 +32,9 @@ export const createDocument = async (db, mapData, data) => {
32
32
  const id = (_a = data.id) !== null && _a !== void 0 ? _a : uuidv7();
33
33
  const { scalars, body } = config.splitPatch(data);
34
34
  const ts = nowIso();
35
- await db.insert(config.table).values(Object.assign(Object.assign({ id }, scalars), { body, createdAt: ts, updatedAt: ts, deletedAt: null }));
35
+ await db.insert(config.table).values(Object.assign(Object.assign(Object.assign({ id }, scalars), { body, createdAt: ts, updatedAt: ts, deletedAt: null }), (collection === 'posts' && scalars.lastActivityAt === undefined
36
+ ? { lastActivityAt: ts }
37
+ : {})));
36
38
  const created = await executeFind(db, collection, mapData, id, true);
37
39
  if (!created) {
38
40
  throw new Error(`create ${collection}`);
@@ -50,7 +52,7 @@ export const updateDocument = async (db, mapData, id, patch) => {
50
52
  const existing = await db
51
53
  .select()
52
54
  .from(config.table)
53
- .where(eq(table.id, id))
55
+ .where(eq(documentIdColumn(collection, table), id))
54
56
  .limit(1);
55
57
  const row = existing[0];
56
58
  if (!row) {
@@ -64,7 +66,7 @@ export const updateDocument = async (db, mapData, id, patch) => {
64
66
  body: Object.assign(Object.assign({}, currentBody), edgeBodyPatch(patch)),
65
67
  updatedAt: nowIso(),
66
68
  })
67
- .where(eq(table.id, id));
69
+ .where(eq(documentIdColumn(collection, table), id));
68
70
  }
69
71
  else {
70
72
  const merged = Object.assign(Object.assign({}, rowToPatchInput(collection, row)), patch);
@@ -72,7 +74,7 @@ export const updateDocument = async (db, mapData, id, patch) => {
72
74
  await db
73
75
  .update(table)
74
76
  .set(Object.assign(Object.assign({}, scalars), { body, updatedAt: nowIso() }))
75
- .where(eq(table.id, id));
77
+ .where(eq(documentIdColumn(collection, table), id));
76
78
  }
77
79
  const updated = await executeFind(db, collection, mapData, id, true);
78
80
  if (!updated) {
@@ -87,10 +89,13 @@ const rowToPatchInput = (collection, row) => {
87
89
  type: row.type,
88
90
  visibility: row.visibility,
89
91
  creatorId: row.creatorId,
92
+ lastActivityAt: row.lastActivityAt,
93
+ uri: row.uri,
94
+ inReplyToUri: row.inReplyToUri,
90
95
  data: row.body,
91
96
  };
92
97
  case 'profiles':
93
- return Object.assign(Object.assign({ handle: row.handle, type: row.type }, (row.activityPubDomain
98
+ return Object.assign(Object.assign({ handle: row.handle, type: row.type, uri: row.uri, inboxUrl: row.inboxUrl, sharedInboxUrl: row.sharedInboxUrl, publicKeyPem: row.publicKeyPem, privateKeyPem: row.privateKeyPem, keyId: row.keyId, fetchedAt: row.fetchedAt }, (row.activityPubDomain
94
99
  ? { activityPub: { domain: row.activityPubDomain } }
95
100
  : {})), row.body);
96
101
  case 'groups':
@@ -126,10 +131,10 @@ export const deleteDocument = async (db, mapData, id) => {
126
131
  await db
127
132
  .update(getTableForCollection(mapData.collection))
128
133
  .set({ deletedAt: nowIso(), updatedAt: nowIso() })
129
- .where(eq(table.id, id));
134
+ .where(eq(documentIdColumn(mapData.collection, table), id));
130
135
  return;
131
136
  }
132
137
  await db
133
138
  .delete(getTableForCollection(mapData.collection))
134
- .where(eq(table.id, id));
139
+ .where(eq(documentIdColumn(mapData.collection, table), id));
135
140
  };
@@ -1,5 +1,10 @@
1
1
  export type PgTable = unknown;
2
2
  export declare const asTable: (table: PgTable) => Record<string, unknown>;
3
+ /**
4
+ * Column the map layer treats as a document's id. Profile settings are
5
+ * addressed by profile id; legacy rows keep a different primary key.
6
+ */
7
+ export declare const documentIdColumn: (collection: string, table: Record<string, unknown>) => unknown;
3
8
  export type DocumentConfig = {
4
9
  kind: 'document';
5
10
  table: PgTable;
@@ -11,8 +11,13 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import * as documents from '../schema/documents.js';
13
13
  import * as edges from '../schema/edges.js';
14
- import { modelTimestampsFromRow, rowToModel, } from '../mappers.js';
14
+ import { modelTimestampsFromRow, normalizeIsoDatetime, rowToModel, } from '../mappers.js';
15
15
  export const asTable = (table) => table;
16
+ /**
17
+ * Column the map layer treats as a document's id. Profile settings are
18
+ * addressed by profile id; legacy rows keep a different primary key.
19
+ */
20
+ export const documentIdColumn = (collection, table) => (collection === 'profileSettings' ? table.profileId : table.id);
16
21
  const bodyOnly = (data) => ({
17
22
  scalars: {},
18
23
  body: Object.assign({}, data),
@@ -29,7 +34,7 @@ const withScalars = (...scalarKeys) => (data) => {
29
34
  return { scalars, body };
30
35
  };
31
36
  const postsSplit = (data) => {
32
- const { type, visibility, creatorId, data: postBody } = data, rest = __rest(data, ["type", "visibility", "creatorId", "data"]);
37
+ const { type, visibility, creatorId, lastActivityAt, data: postBody, uri, inReplyToUri } = data, rest = __rest(data, ["type", "visibility", "creatorId", "lastActivityAt", "data", "uri", "inReplyToUri"]);
33
38
  const scalars = {};
34
39
  if (type !== undefined)
35
40
  scalars.type = type;
@@ -37,14 +42,32 @@ const postsSplit = (data) => {
37
42
  scalars.visibility = visibility;
38
43
  if (creatorId !== undefined)
39
44
  scalars.creatorId = creatorId;
45
+ if (lastActivityAt !== undefined)
46
+ scalars.lastActivityAt = lastActivityAt;
47
+ if (uri !== undefined)
48
+ scalars.uri = uri;
49
+ if (inReplyToUri !== undefined)
50
+ scalars.inReplyToUri = inReplyToUri;
40
51
  const body = postBody !== undefined ? Object.assign({}, postBody) : Object.assign({}, rest);
41
52
  if (postBody === undefined) {
42
53
  delete body.type;
43
54
  delete body.visibility;
44
55
  delete body.creatorId;
56
+ delete body.lastActivityAt;
57
+ delete body.uri;
58
+ delete body.inReplyToUri;
45
59
  }
46
60
  return { scalars, body };
47
61
  };
62
+ const ACTOR_SCALAR_KEYS = [
63
+ 'uri',
64
+ 'inboxUrl',
65
+ 'sharedInboxUrl',
66
+ 'publicKeyPem',
67
+ 'privateKeyPem',
68
+ 'keyId',
69
+ 'fetchedAt',
70
+ ];
48
71
  const profilesSplit = (data) => {
49
72
  const { handle, type, activityPub } = data, rest = __rest(data, ["handle", "type", "activityPub"]);
50
73
  const scalars = {};
@@ -57,7 +80,14 @@ const profilesSplit = (data) => {
57
80
  if (domain !== undefined)
58
81
  scalars.activityPubDomain = domain;
59
82
  }
60
- return { scalars, body: Object.assign({}, rest) };
83
+ const body = Object.assign({}, rest);
84
+ for (const key of ACTOR_SCALAR_KEYS) {
85
+ if (key in body) {
86
+ scalars[key] = body[key];
87
+ delete body[key];
88
+ }
89
+ }
90
+ return { scalars, body };
61
91
  };
62
92
  /** App model uses `tag`; Postgres column is `name`. */
63
93
  const hashtagsSplit = (data) => {
@@ -71,7 +101,7 @@ const hashtagsSplit = (data) => {
71
101
  }
72
102
  return withScalars('name')(normalized);
73
103
  };
74
- /** Arango jam events use jamId; Postgres column is post_id. */
104
+ /** Older jam events stored jamId; the column is post_id. */
75
105
  const jamEventsSplit = (data) => {
76
106
  const { postId, jamId } = data, rest = __rest(data, ["postId", "jamId"]);
77
107
  const scalars = {};
@@ -177,11 +207,6 @@ export const documentRegistry = {
177
207
  table: documents.i18nEntries,
178
208
  splitPatch: withScalars('locale', 'namespace'),
179
209
  },
180
- dataMigrations: {
181
- kind: 'document',
182
- table: documents.dataMigrations,
183
- splitPatch: bodyOnly,
184
- },
185
210
  };
186
211
  export const edgeRegistry = {
187
212
  follows: {
@@ -190,6 +215,12 @@ export const edgeRegistry = {
190
215
  fromCollection: 'profiles',
191
216
  toCollection: 'profiles',
192
217
  },
218
+ blocks: {
219
+ kind: 'edge',
220
+ table: edges.blocks,
221
+ fromCollection: 'profiles',
222
+ toCollection: 'profiles',
223
+ },
193
224
  requestsFollow: {
194
225
  kind: 'edge',
195
226
  table: edges.requestsFollow,
@@ -226,12 +257,6 @@ export const edgeRegistry = {
226
257
  fromCollection: 'profiles',
227
258
  toCollection: 'posts',
228
259
  },
229
- reactions: {
230
- kind: 'edge',
231
- table: edges.reactions,
232
- fromCollection: 'profiles',
233
- toCollection: 'posts',
234
- },
235
260
  replyTo: {
236
261
  kind: 'edge',
237
262
  table: edges.replyTo,
@@ -334,6 +359,12 @@ export const edgeRegistry = {
334
359
  fromCollection: 'profiles',
335
360
  toCollection: 'posts',
336
361
  },
362
+ profileHashtags: {
363
+ kind: 'edge',
364
+ table: edges.profileHashtags,
365
+ fromCollection: 'profiles',
366
+ toCollection: 'hashtags',
367
+ },
337
368
  };
338
369
  export const getCollectionConfig = (collection) => { var _a; return (_a = documentRegistry[collection]) !== null && _a !== void 0 ? _a : edgeRegistry[collection]; };
339
370
  export const getTableForCollection = (collection) => {
@@ -376,16 +407,25 @@ export const rowToDocument = (collection, row, keepMetadata = false) => {
376
407
  guest: (_b = row.guest) !== null && _b !== void 0 ? _b : undefined,
377
408
  }, timestamps);
378
409
  case 'profiles':
379
- return rowToModel(row.id, Object.assign(Object.assign({ handle: row.handle, type: row.type }, (row.activityPubDomain
410
+ return rowToModel(row.id, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ handle: row.handle, type: row.type }, (row.activityPubDomain
380
411
  ? { activityPub: { domain: row.activityPubDomain } }
381
- : {})), ((_c = row.body) !== null && _c !== void 0 ? _c : {})), timestamps);
382
- case 'posts':
383
- return rowToModel(row.id, {
384
- type: row.type,
385
- visibility: row.visibility,
386
- creatorId: row.creatorId,
387
- data: (_d = row.body) !== null && _d !== void 0 ? _d : {},
388
- }, timestamps);
412
+ : {})), ((_c = row.body) !== null && _c !== void 0 ? _c : {})), (typeof row.uri === 'string' ? { uri: row.uri } : {})), (typeof row.inboxUrl === 'string'
413
+ ? { inboxUrl: row.inboxUrl }
414
+ : {})), (typeof row.sharedInboxUrl === 'string'
415
+ ? { sharedInboxUrl: row.sharedInboxUrl }
416
+ : {})), (typeof row.publicKeyPem === 'string'
417
+ ? { publicKeyPem: row.publicKeyPem }
418
+ : {})), (typeof row.keyId === 'string' ? { keyId: row.keyId } : {})), (typeof row.fetchedAt === 'string'
419
+ ? { fetchedAt: normalizeIsoDatetime(row.fetchedAt) }
420
+ : {})), timestamps);
421
+ case 'posts': {
422
+ const lastActivityAt = row.lastActivityAt
423
+ ? normalizeIsoDatetime(row.lastActivityAt)
424
+ : timestamps.createdAt;
425
+ return Object.assign(Object.assign({}, rowToModel(row.id, Object.assign(Object.assign(Object.assign({ type: row.type, visibility: row.visibility, creatorId: row.creatorId }, (typeof row.uri === 'string' ? { uri: row.uri } : {})), (typeof row.inReplyToUri === 'string'
426
+ ? { inReplyToUri: row.inReplyToUri }
427
+ : {})), { data: (_d = row.body) !== null && _d !== void 0 ? _d : {} }), timestamps)), { lastActivityAt });
428
+ }
389
429
  case 'groups':
390
430
  return rowToModel(row.id, Object.assign({ handle: row.handle }, ((_e = row.body) !== null && _e !== void 0 ? _e : {})), timestamps);
391
431
  case 'hashtags':