From 0a2621a05120b0bc28d043bf26c9006bd0cedba9 Mon Sep 17 00:00:00 2001 From: Guido X Jansen Date: Sat, 7 Mar 2026 23:15:48 +0100 Subject: [PATCH] fix(firehose): align indexers and tests with richtext content schema (#162) The lexicon source updated content from plain string to { $type, value } richtext object and renamed topic createdAt to publishedAt, but the firehose indexers and tests still used the old format. Docker builds from source, causing type errors that blocked staging deploys. - Extract content.value for sanitizeHtml calls in topic/reply indexers - Use 'markdown' literal for contentFormat (derived from $type) - Use record.publishedAt for topic timestamps - Update all unit and integration test fixtures to match new schema --- src/firehose/indexers/reply.ts | 8 +-- src/firehose/indexers/topic.ts | 14 ++--- .../firehose/account-deletion.test.ts | 14 ++--- .../firehose/record-processing.test.ts | 62 +++++++++++-------- tests/unit/firehose/handlers/record.test.ts | 46 +++++++------- tests/unit/firehose/indexers/reply.test.ts | 28 ++++++--- tests/unit/firehose/indexers/topic.test.ts | 34 ++++++---- tests/unit/firehose/validation.test.ts | 13 ++-- 8 files changed, 125 insertions(+), 94 deletions(-) diff --git a/src/firehose/indexers/reply.ts b/src/firehose/indexers/reply.ts index 7d34f8e..c63e645 100644 --- a/src/firehose/indexers/reply.ts +++ b/src/firehose/indexers/reply.ts @@ -65,8 +65,8 @@ export class ReplyIndexer { uri, rkey, authorDid: did, - content: sanitizeHtml(record.content), - contentFormat: record.contentFormat ?? null, + content: sanitizeHtml(record.content.value), + contentFormat: 'markdown', rootUri: root.uri, rootCid: root.cid, parentUri: parent.uri, @@ -99,8 +99,8 @@ export class ReplyIndexer { await this.db .update(replies) .set({ - content: sanitizeHtml(record.content), - contentFormat: record.contentFormat ?? null, + content: sanitizeHtml(record.content.value), + contentFormat: 'markdown', cid, labels: record.labels ?? null, indexedAt: new Date(), diff --git a/src/firehose/indexers/topic.ts b/src/firehose/indexers/topic.ts index 8f127b9..471056f 100644 --- a/src/firehose/indexers/topic.ts +++ b/src/firehose/indexers/topic.ts @@ -31,7 +31,7 @@ export class TopicIndexer { async handleCreate(params: CreateParams): Promise { const { uri, rkey, did, cid, record, live, trustStatus } = params - const clientCreatedAt = new Date(record.createdAt) + const clientCreatedAt = new Date(record.publishedAt) const createdAt = live ? clampCreatedAt(clientCreatedAt) : clientCreatedAt await this.db @@ -41,8 +41,8 @@ export class TopicIndexer { rkey, authorDid: did, title: sanitizeText(record.title), - content: sanitizeHtml(record.content), - contentFormat: record.contentFormat ?? null, + content: sanitizeHtml(record.content.value), + contentFormat: 'markdown', category: record.category, tags: record.tags ?? null, communityDid: record.community, @@ -56,8 +56,8 @@ export class TopicIndexer { target: topics.uri, set: { title: sanitizeText(record.title), - content: sanitizeHtml(record.content), - contentFormat: record.contentFormat ?? null, + content: sanitizeHtml(record.content.value), + contentFormat: 'markdown', category: record.category, tags: record.tags ?? null, cid, @@ -76,8 +76,8 @@ export class TopicIndexer { .update(topics) .set({ title: sanitizeText(record.title), - content: sanitizeHtml(record.content), - contentFormat: record.contentFormat ?? null, + content: sanitizeHtml(record.content.value), + contentFormat: 'markdown', category: record.category, tags: record.tags ?? null, cid, diff --git a/tests/integration/firehose/account-deletion.test.ts b/tests/integration/firehose/account-deletion.test.ts index 66c0c37..e616dde 100644 --- a/tests/integration/firehose/account-deletion.test.ts +++ b/tests/integration/firehose/account-deletion.test.ts @@ -96,10 +96,10 @@ describe('firehose account deletion (integration)', () => { rkey: 'del-topic1', record: { title: 'Deleted user topic', - content: 'This will be purged', + content: { $type: 'forum.barazo.richtext#markdown', value: 'This will be purged' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafydeltopic1', live: true, @@ -115,7 +115,7 @@ describe('firehose account deletion (integration)', () => { collection: 'forum.barazo.topic.reply', rkey: 'del-reply1', record: { - content: 'Deleted user reply', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Deleted user reply' }, root: { uri: deletedTopicUri, cid: 'bafydeltopic1' }, parent: { uri: deletedTopicUri, cid: 'bafydeltopic1' }, community: 'did:plc:community', @@ -135,10 +135,10 @@ describe('firehose account deletion (integration)', () => { rkey: 'surv-topic1', record: { title: 'Surviving user topic', - content: 'This should remain', + content: { $type: 'forum.barazo.richtext#markdown', value: 'This should remain' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafysurvtopic1', live: true, @@ -293,10 +293,10 @@ describe('firehose account deletion (integration)', () => { rkey: 'ht-topic1', record: { title: 'Handle test', - content: 'Testing handle update', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Testing handle update' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafyht1', live: true, diff --git a/tests/integration/firehose/record-processing.test.ts b/tests/integration/firehose/record-processing.test.ts index 5fad76e..1d0bcfb 100644 --- a/tests/integration/firehose/record-processing.test.ts +++ b/tests/integration/firehose/record-processing.test.ts @@ -90,10 +90,13 @@ describe('firehose record processing (integration)', () => { rkey: 'topic1', record: { title: 'Integration Test Topic', - content: 'This is a test topic for integration testing.', + content: { + $type: 'forum.barazo.richtext#markdown', + value: 'This is a test topic for integration testing.', + }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafytopic1', live: true, @@ -134,10 +137,13 @@ describe('firehose record processing (integration)', () => { rkey: 'topic1', record: { title: 'Updated Topic Title', - content: 'Updated content for the topic.', + content: { + $type: 'forum.barazo.richtext#markdown', + value: 'Updated content for the topic.', + }, community: 'did:plc:community', category: 'discussion', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafytopic1v2', live: true, @@ -198,10 +204,10 @@ describe('firehose record processing (integration)', () => { rkey: 'topic1', record: { title: 'Parent Topic', - content: 'Topic for reply tests', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Topic for reply tests' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafytopic1', live: true, @@ -217,7 +223,7 @@ describe('firehose record processing (integration)', () => { collection: 'forum.barazo.topic.reply', rkey: 'reply1', record: { - content: 'This is a reply', + content: { $type: 'forum.barazo.richtext#markdown', value: 'This is a reply' }, root: { uri: topicUri, cid: 'bafytopic1' }, parent: { uri: topicUri, cid: 'bafytopic1' }, community: 'did:plc:community', @@ -255,7 +261,7 @@ describe('firehose record processing (integration)', () => { collection: 'forum.barazo.topic.reply', rkey: `reply${String(i)}`, record: { - content: `Reply ${String(i)}`, + content: { $type: 'forum.barazo.richtext#markdown', value: `Reply ${String(i)}` }, root: { uri: topicUri, cid: 'bafytopic1' }, parent: { uri: topicUri, cid: 'bafytopic1' }, community: 'did:plc:community', @@ -285,10 +291,10 @@ describe('firehose record processing (integration)', () => { rkey: 'topic1', record: { title: 'Reactable Topic', - content: 'Topic for reaction tests', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Topic for reaction tests' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafytopic1', live: true, @@ -344,10 +350,10 @@ describe('firehose record processing (integration)', () => { rkey: 'idem-topic1', record: { title: 'Idempotent Topic', - content: 'Original content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Original content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafyidem1', live: false, @@ -381,10 +387,10 @@ describe('firehose record processing (integration)', () => { rkey: 'idem-topic2', record: { title: 'Topic for replay test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafyidem2', live: false, @@ -398,7 +404,7 @@ describe('firehose record processing (integration)', () => { collection: 'forum.barazo.topic.reply', rkey: 'idem-reply1', record: { - content: 'Replay test reply', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Replay test reply' }, root: { uri: topicUri, cid: 'bafyidem2' }, parent: { uri: topicUri, cid: 'bafyidem2' }, community: 'did:plc:community', @@ -439,10 +445,10 @@ describe('firehose record processing (integration)', () => { rkey: 'edit-del-topic', record: { title: 'Original Title', - content: 'Original content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Original content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: originalCid, live: true, @@ -457,7 +463,10 @@ describe('firehose record processing (integration)', () => { collection: 'forum.barazo.topic.reply', rkey: 'edit-del-reply', record: { - content: 'Reply referencing original CID', + content: { + $type: 'forum.barazo.richtext#markdown', + value: 'Reply referencing original CID', + }, root: { uri: topicUri, cid: originalCid }, parent: { uri: topicUri, cid: originalCid }, community: 'did:plc:community', @@ -477,10 +486,10 @@ describe('firehose record processing (integration)', () => { rkey: 'edit-del-topic', record: { title: 'Updated Title', - content: 'Updated content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Updated content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: updatedCid, live: true, @@ -526,10 +535,10 @@ describe('firehose record processing (integration)', () => { rkey: 'rapid-topic', record: { title: 'Ephemeral Topic', - content: 'Gone before you know it', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Gone before you know it' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafyrapid1', live: true, @@ -563,10 +572,10 @@ describe('firehose record processing (integration)', () => { rkey: 'rapid-topic2', record: { title: 'Another Ephemeral Topic', - content: 'Will be deleted quickly', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Will be deleted quickly' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-15T10:00:00.000Z', + publishedAt: '2026-01-15T10:00:00.000Z', }, cid: 'bafyrapid2', live: true, @@ -581,7 +590,10 @@ describe('firehose record processing (integration)', () => { collection: 'forum.barazo.topic.reply', rkey: 'rapid-reply1', record: { - content: 'Quick reply before deletion', + content: { + $type: 'forum.barazo.richtext#markdown', + value: 'Quick reply before deletion', + }, root: { uri: topicUri, cid: 'bafyrapid2' }, parent: { uri: topicUri, cid: 'bafyrapid2' }, community: 'did:plc:community', diff --git a/tests/unit/firehose/handlers/record.test.ts b/tests/unit/firehose/handlers/record.test.ts index f074244..ca9d880 100644 --- a/tests/unit/firehose/handlers/record.test.ts +++ b/tests/unit/firehose/handlers/record.test.ts @@ -85,10 +85,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -109,7 +109,7 @@ describe('RecordHandler', () => { collection: 'forum.barazo.topic.reply', rkey: 'reply1', record: { - content: 'Reply', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Reply' }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/t1', cid: 'bafyt' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.post/t1', cid: 'bafyt' }, community: 'did:plc:community', @@ -157,10 +157,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Updated', - content: 'Updated content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Updated content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafynew', live: true, @@ -241,10 +241,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -267,10 +267,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -295,10 +295,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -322,10 +322,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -357,10 +357,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -391,10 +391,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -416,10 +416,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Updated', - content: 'Updated content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Updated content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafynew', live: true, @@ -446,10 +446,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: true, @@ -580,10 +580,10 @@ describe('RecordHandler', () => { rkey: 'abc123', record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Content' }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, cid: 'bafyabc', live: false, diff --git a/tests/unit/firehose/indexers/reply.test.ts b/tests/unit/firehose/indexers/reply.test.ts index bbcb8d3..22fbedb 100644 --- a/tests/unit/firehose/indexers/reply.test.ts +++ b/tests/unit/firehose/indexers/reply.test.ts @@ -66,7 +66,7 @@ describe('ReplyIndexer', () => { await indexer.handleCreate({ ...baseParams, record: { - content: 'A reply', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'A reply' }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, community: 'did:plc:community', @@ -107,7 +107,7 @@ describe('ReplyIndexer', () => { await indexer.handleCreate({ ...baseParams, record: { - content: 'Direct reply', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'Direct reply' }, root: { uri: topicUri, cid: 'bafytopic' }, parent: { uri: topicUri, cid: 'bafytopic' }, community: 'did:plc:community', @@ -148,7 +148,7 @@ describe('ReplyIndexer', () => { await indexer.handleCreate({ ...baseParams, record: { - content: 'Nested reply', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'Nested reply' }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.reply/reply2', cid: 'bafyreply2' }, community: 'did:plc:community', @@ -189,7 +189,10 @@ describe('ReplyIndexer', () => { await indexer.handleCreate({ ...baseParams, record: { - content: 'Orphaned nested reply', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: 'Orphaned nested reply', + }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.reply/missing', @@ -214,7 +217,7 @@ describe('ReplyIndexer', () => { await indexer.handleUpdate({ ...baseParams, record: { - content: 'Updated reply', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'Updated reply' }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, community: 'did:plc:community', @@ -251,7 +254,10 @@ describe('ReplyIndexer', () => { await indexer.handleCreate({ ...baseParams, record: { - content: '

Reply

', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: '

Reply

', + }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, community: 'did:plc:community', @@ -278,7 +284,10 @@ describe('ReplyIndexer', () => { await indexer.handleUpdate({ ...baseParams, record: { - content: '

Safe

', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: '

Safe

', + }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, community: 'did:plc:community', @@ -315,7 +324,10 @@ describe('ReplyIndexer', () => { await indexer.handleCreate({ ...baseParams, record: { - content: '

\u202AHello\u202E World\u200F

', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: '

\u202AHello\u202E World\u200F

', + }, root: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, parent: { uri: 'at://did:plc:test/forum.barazo.topic.post/topic1', cid: 'bafytopic' }, community: 'did:plc:community', diff --git a/tests/unit/firehose/indexers/topic.test.ts b/tests/unit/firehose/indexers/topic.test.ts index dae03b7..70983a9 100644 --- a/tests/unit/firehose/indexers/topic.test.ts +++ b/tests/unit/firehose/indexers/topic.test.ts @@ -47,12 +47,11 @@ describe('TopicIndexer', () => { ...baseParams, record: { title: 'Test Topic', - content: 'Content here', - contentFormat: 'markdown', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'Content here' }, community: 'did:plc:community', category: 'general', tags: ['test'], - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, }) @@ -68,11 +67,11 @@ describe('TopicIndexer', () => { ...baseParams, record: { title: 'Test', - content: 'Content', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'Content' }, community: 'did:plc:community', category: 'general', labels: { values: [{ val: 'nsfw' }] }, - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, }) @@ -90,11 +89,11 @@ describe('TopicIndexer', () => { ...baseParams, record: { title: 'Updated Title', - content: 'Updated content', + content: { $type: 'forum.barazo.richtext#markdown' as const, value: 'Updated content' }, community: 'did:plc:community', category: 'updated', tags: ['updated'], - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, }) @@ -118,10 +117,13 @@ describe('TopicIndexer', () => { ...baseParams, record: { title: 'Bold Title', - content: '

Good

', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: '

Good

', + }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, }) @@ -150,10 +152,13 @@ describe('TopicIndexer', () => { ...baseParams, record: { title: 'Clean ', - content: '

Safe

', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: '

Safe

', + }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, }) @@ -179,10 +184,13 @@ describe('TopicIndexer', () => { ...baseParams, record: { title: '\u202AHello\u202E World', - content: '

\u2066Content\u2069

', + content: { + $type: 'forum.barazo.richtext#markdown' as const, + value: '

\u2066Content\u2069

', + }, community: 'did:plc:community', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', }, }) diff --git a/tests/unit/firehose/validation.test.ts b/tests/unit/firehose/validation.test.ts index 2465cf5..5a3a32a 100644 --- a/tests/unit/firehose/validation.test.ts +++ b/tests/unit/firehose/validation.test.ts @@ -5,12 +5,11 @@ describe('validateRecord', () => { describe('topic post validation', () => { const validTopic = { title: 'Test Topic', - content: 'Some content here', - contentFormat: 'markdown', + content: { $type: 'forum.barazo.richtext#markdown', value: 'Some content here' }, community: 'did:plc:abc123', category: 'general', tags: ['test'], - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', } it('accepts a valid topic post', () => { @@ -27,7 +26,7 @@ describe('validateRecord', () => { it('rejects a topic post with empty content', () => { const result = validateRecord('forum.barazo.topic.post', { ...validTopic, - content: '', + content: { $type: 'forum.barazo.richtext#markdown', value: '' }, }) expect(result.success).toBe(false) }) @@ -35,7 +34,7 @@ describe('validateRecord', () => { describe('topic reply validation', () => { const validReply = { - content: 'A reply', + content: { $type: 'forum.barazo.richtext#markdown', value: 'A reply' }, root: { uri: 'at://did:plc:abc/forum.barazo.topic.post/123', cid: 'bafyabc' }, parent: { uri: 'at://did:plc:abc/forum.barazo.topic.post/123', cid: 'bafyabc' }, community: 'did:plc:abc123', @@ -120,10 +119,10 @@ describe('validateRecord', () => { it('rejects records exceeding 64KB', () => { const oversized = { title: 'Test', - content: 'x'.repeat(65_537), + content: { $type: 'forum.barazo.richtext#markdown', value: 'x'.repeat(65_537) }, community: 'did:plc:abc123', category: 'general', - createdAt: '2026-01-01T00:00:00.000Z', + publishedAt: '2026-01-01T00:00:00.000Z', } const result = validateRecord('forum.barazo.topic.post', oversized) expect(result.success).toBe(false) -- 2.51.2