From 9f5f40c773278a2282080fe1bc42c593d4b5e5b3 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Mon, 14 Apr 2025 13:49:57 +0100 Subject: [PATCH 01/14] Initial draft --- lexicons/fyi/frontpage/feed/comment.json | 27 +++++++++++++++++++ lexicons/fyi/frontpage/feed/post.json | 33 ++++++++++++++++++++++++ lexicons/fyi/frontpage/feed/vote.json | 23 +++++++++++++++++ lexicons/fyi/frontpage/subject/url.json | 17 ++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 lexicons/fyi/frontpage/feed/comment.json create mode 100644 lexicons/fyi/frontpage/feed/post.json create mode 100644 lexicons/fyi/frontpage/feed/vote.json create mode 100644 lexicons/fyi/frontpage/subject/url.json diff --git a/lexicons/fyi/frontpage/feed/comment.json b/lexicons/fyi/frontpage/feed/comment.json new file mode 100644 index 00000000..cab5818c --- /dev/null +++ b/lexicons/fyi/frontpage/feed/comment.json @@ -0,0 +1,27 @@ +{ + "lexicon": 1, + "id": "fyi.unravel.frontpage.comment", + "defs": { + "main": { + "type": "record", + "description": "Record containing a Frontpage comment.", + "key": "tid", + "record": { + "type": "object", + "required": ["createdAt", "post"], + "properties": { + "content": { + // TODO: richtext + }, + "createdAt": { + "type": "string", + "format": "datetime", + "description": "Client-declared timestamp when this comment was originally created." + }, + "parent": { "type": "ref", "ref": "com.atproto.repo.strongRef" }, + "post": { "type": "ref", "ref": "com.atproto.repo.strongRef" } + } + } + } + } +} diff --git a/lexicons/fyi/frontpage/feed/post.json b/lexicons/fyi/frontpage/feed/post.json new file mode 100644 index 00000000..4105685c --- /dev/null +++ b/lexicons/fyi/frontpage/feed/post.json @@ -0,0 +1,33 @@ +{ + "lexicon": 1, + "id": "fyi.unravel.frontpage.post", + "defs": { + "main": { + "type": "record", + "description": "Record containing a Frontpage post.", + "key": "tid", + "record": { + "type": "object", + "required": ["title", "createdAt"], + "properties": { + "title": { + "type": "string", + "maxLength": 3000, + "maxGraphemes": 300, + "description": "The title of the post." + }, + "subject": { + "type": "union", + "description": "The piece of content that this Frontpage post is about.", + "refs": ["fyi.frontpage.subject.url"] + }, + "createdAt": { + "type": "string", + "format": "datetime", + "description": "Client-declared timestamp when this post was originally created." + } + } + } + } + } +} diff --git a/lexicons/fyi/frontpage/feed/vote.json b/lexicons/fyi/frontpage/feed/vote.json new file mode 100644 index 00000000..8d99543d --- /dev/null +++ b/lexicons/fyi/frontpage/feed/vote.json @@ -0,0 +1,23 @@ +{ + "lexicon": 1, + "id": "fyi.unravel.frontpage.vote", + "defs": { + "main": { + "type": "record", + "description": "Record containing a Frontpage vote.", + "key": "tid", + "record": { + "type": "object", + "required": ["subject", "createdAt"], + "properties": { + "subject": { "type": "ref", "ref": "com.atproto.repo.strongRef" }, + "createdAt": { + "type": "string", + "format": "datetime", + "description": "Client-declared timestamp when this vote was originally created." + } + } + } + } + } +} diff --git a/lexicons/fyi/frontpage/subject/url.json b/lexicons/fyi/frontpage/subject/url.json new file mode 100644 index 00000000..a6e1c484 --- /dev/null +++ b/lexicons/fyi/frontpage/subject/url.json @@ -0,0 +1,17 @@ +{ + "lexicon": 1, + "id": "fyi.frontpage.subject.url", + "description": "A link to a webpage URL.", + "defs": { + "main": { + "type": "object", + "required": ["url"], + "properties": { + "url": { + "type": "string", + "format": "uri" + } + } + } + } +} From 00bfeb2df62f54e5e30a14ea4cb4d19ea2091acc Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Mon, 14 Apr 2025 18:07:26 +0100 Subject: [PATCH 02/14] Flesh out rich text --- lexicons/fyi/frontpage/feed/comment.json | 10 +++++-- lexicons/fyi/frontpage/richtext/block.json | 35 ++++++++++++++++++++++ lexicons/fyi/frontpage/richtext/facet.json | 10 +++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 lexicons/fyi/frontpage/richtext/block.json create mode 100644 lexicons/fyi/frontpage/richtext/facet.json diff --git a/lexicons/fyi/frontpage/feed/comment.json b/lexicons/fyi/frontpage/feed/comment.json index cab5818c..d82ec12a 100644 --- a/lexicons/fyi/frontpage/feed/comment.json +++ b/lexicons/fyi/frontpage/feed/comment.json @@ -8,10 +8,14 @@ "key": "tid", "record": { "type": "object", - "required": ["createdAt", "post"], + "required": ["createdAt", "post", "blocks"], "properties": { - "content": { - // TODO: richtext + "blocks": { + "type": "array", + "items": { + "type": "ref", + "ref": "fyi.unravel.frontpage.richtext.block" + } }, "createdAt": { "type": "string", diff --git a/lexicons/fyi/frontpage/richtext/block.json b/lexicons/fyi/frontpage/richtext/block.json new file mode 100644 index 00000000..c4afb31f --- /dev/null +++ b/lexicons/fyi/frontpage/richtext/block.json @@ -0,0 +1,35 @@ +{ + "lexicon": 1, + "id": "fyi.unravel.frontpage.richtext.block", + "defs": { + "main": { + "type": "union", + "refs": ["#paragraph"] + }, + "paragraph": { + "type": "object", + "properties": { + "content": { "type": "ref", "ref": "#richtext" } + } + }, + "richtext": { + "type": "array", + "items": { + "type": "object", + "required": ["text"], + "properties": { + "text": { + "type": "string" + }, + "facets": { + "type": "array", + "items": { + "type": "ref", + "ref": "fyi.frontpage.richtext.facet" + } + } + } + } + } + } +} diff --git a/lexicons/fyi/frontpage/richtext/facet.json b/lexicons/fyi/frontpage/richtext/facet.json new file mode 100644 index 00000000..feed2a23 --- /dev/null +++ b/lexicons/fyi/frontpage/richtext/facet.json @@ -0,0 +1,10 @@ +{ + "lexicon": 1, + "id": "app.bsky.richtext.facet", + "defs": { + "main": { + "type": "union", + "refs": [] + } + } +} From 8e8cbc4d63265041809ba1aa971e28fe9ebf1f96 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Mon, 14 Apr 2025 19:01:38 +0100 Subject: [PATCH 03/14] Remove richtext from the proposal --- lexicons/fyi/frontpage/richtext/block.json | 25 +++------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/lexicons/fyi/frontpage/richtext/block.json b/lexicons/fyi/frontpage/richtext/block.json index c4afb31f..f51905e4 100644 --- a/lexicons/fyi/frontpage/richtext/block.json +++ b/lexicons/fyi/frontpage/richtext/block.json @@ -4,31 +4,12 @@ "defs": { "main": { "type": "union", - "refs": ["#paragraph"] + "refs": ["#plaintextParagraph"] }, - "paragraph": { + "plaintextParagraph": { "type": "object", "properties": { - "content": { "type": "ref", "ref": "#richtext" } - } - }, - "richtext": { - "type": "array", - "items": { - "type": "object", - "required": ["text"], - "properties": { - "text": { - "type": "string" - }, - "facets": { - "type": "array", - "items": { - "type": "ref", - "ref": "fyi.frontpage.richtext.facet" - } - } - } + "text": { "type": "string" } } } } From 31de79db27ed759ddb50a94fa3c7585c3c7723d6 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Tue, 15 Apr 2025 22:18:23 +0100 Subject: [PATCH 04/14] Add length constraints to comment --- lexicons/fyi/frontpage/feed/comment.json | 2 ++ lexicons/fyi/frontpage/richtext/block.json | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lexicons/fyi/frontpage/feed/comment.json b/lexicons/fyi/frontpage/feed/comment.json index d82ec12a..6bb9a6dc 100644 --- a/lexicons/fyi/frontpage/feed/comment.json +++ b/lexicons/fyi/frontpage/feed/comment.json @@ -12,6 +12,8 @@ "properties": { "blocks": { "type": "array", + "maxLength": 50, + "description": "The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit.", "items": { "type": "ref", "ref": "fyi.unravel.frontpage.richtext.block" diff --git a/lexicons/fyi/frontpage/richtext/block.json b/lexicons/fyi/frontpage/richtext/block.json index f51905e4..328322d4 100644 --- a/lexicons/fyi/frontpage/richtext/block.json +++ b/lexicons/fyi/frontpage/richtext/block.json @@ -9,7 +9,11 @@ "plaintextParagraph": { "type": "object", "properties": { - "text": { "type": "string" } + "text": { + "type": "string", + "maxLength": 100000, + "maxGraphemes": 10000 + } } } } From 658b5f933df8e41523bf0a464ec1d1aada7d880e Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Tue, 15 Apr 2025 22:27:40 +0100 Subject: [PATCH 05/14] Remove facet type --- lexicons/fyi/frontpage/richtext/facet.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 lexicons/fyi/frontpage/richtext/facet.json diff --git a/lexicons/fyi/frontpage/richtext/facet.json b/lexicons/fyi/frontpage/richtext/facet.json deleted file mode 100644 index feed2a23..00000000 --- a/lexicons/fyi/frontpage/richtext/facet.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "lexicon": 1, - "id": "app.bsky.richtext.facet", - "defs": { - "main": { - "type": "union", - "refs": [] - } - } -} From 878c0af2c17b3c49c203916ca3691225f69961f5 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Tue, 15 Apr 2025 22:34:33 +0100 Subject: [PATCH 06/14] Add vote subject description --- lexicons/fyi/frontpage/feed/vote.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lexicons/fyi/frontpage/feed/vote.json b/lexicons/fyi/frontpage/feed/vote.json index 8d99543d..354c90f9 100644 --- a/lexicons/fyi/frontpage/feed/vote.json +++ b/lexicons/fyi/frontpage/feed/vote.json @@ -10,7 +10,11 @@ "type": "object", "required": ["subject", "createdAt"], "properties": { - "subject": { "type": "ref", "ref": "com.atproto.repo.strongRef" }, + "subject": { + "type": "ref", + "description": "The post or comment that this Frontpage vote is for.", + "ref": "com.atproto.repo.strongRef" + }, "createdAt": { "type": "string", "format": "datetime", From 3cd4c6e8eb8e97f4823f47398a2b1127b35aec3a Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Tue, 15 Apr 2025 22:50:46 +0100 Subject: [PATCH 07/14] Fix NSIDs --- lexicons/fyi/frontpage/feed/comment.json | 2 +- lexicons/fyi/frontpage/feed/post.json | 2 +- lexicons/fyi/frontpage/feed/vote.json | 2 +- lexicons/fyi/frontpage/richtext/block.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lexicons/fyi/frontpage/feed/comment.json b/lexicons/fyi/frontpage/feed/comment.json index 6bb9a6dc..0f5d4815 100644 --- a/lexicons/fyi/frontpage/feed/comment.json +++ b/lexicons/fyi/frontpage/feed/comment.json @@ -1,6 +1,6 @@ { "lexicon": 1, - "id": "fyi.unravel.frontpage.comment", + "id": "fyi.frontpage.feed.comment", "defs": { "main": { "type": "record", diff --git a/lexicons/fyi/frontpage/feed/post.json b/lexicons/fyi/frontpage/feed/post.json index 4105685c..6a8ef1b8 100644 --- a/lexicons/fyi/frontpage/feed/post.json +++ b/lexicons/fyi/frontpage/feed/post.json @@ -1,6 +1,6 @@ { "lexicon": 1, - "id": "fyi.unravel.frontpage.post", + "id": "fyi.frontpage.feed.post", "defs": { "main": { "type": "record", diff --git a/lexicons/fyi/frontpage/feed/vote.json b/lexicons/fyi/frontpage/feed/vote.json index 354c90f9..96d86b05 100644 --- a/lexicons/fyi/frontpage/feed/vote.json +++ b/lexicons/fyi/frontpage/feed/vote.json @@ -1,6 +1,6 @@ { "lexicon": 1, - "id": "fyi.unravel.frontpage.vote", + "id": "fyi.frontpage.feed.vote", "defs": { "main": { "type": "record", diff --git a/lexicons/fyi/frontpage/richtext/block.json b/lexicons/fyi/frontpage/richtext/block.json index 328322d4..9be1c666 100644 --- a/lexicons/fyi/frontpage/richtext/block.json +++ b/lexicons/fyi/frontpage/richtext/block.json @@ -1,6 +1,6 @@ { "lexicon": 1, - "id": "fyi.unravel.frontpage.richtext.block", + "id": "fyi.frontpage.richtext.block", "defs": { "main": { "type": "union", From 6e0acd1020f9ee6155290d6ca9644479f0933d0c Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Sat, 26 Apr 2025 22:53:07 +0100 Subject: [PATCH 08/14] Move subject to feed group --- lexicons/fyi/frontpage/feed/post.json | 2 +- lexicons/fyi/frontpage/{ => feed}/subject/url.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename lexicons/fyi/frontpage/{ => feed}/subject/url.json (86%) diff --git a/lexicons/fyi/frontpage/feed/post.json b/lexicons/fyi/frontpage/feed/post.json index 6a8ef1b8..7f16be48 100644 --- a/lexicons/fyi/frontpage/feed/post.json +++ b/lexicons/fyi/frontpage/feed/post.json @@ -19,7 +19,7 @@ "subject": { "type": "union", "description": "The piece of content that this Frontpage post is about.", - "refs": ["fyi.frontpage.subject.url"] + "refs": ["fyi.frontpage.feed.subject.url"] }, "createdAt": { "type": "string", diff --git a/lexicons/fyi/frontpage/subject/url.json b/lexicons/fyi/frontpage/feed/subject/url.json similarity index 86% rename from lexicons/fyi/frontpage/subject/url.json rename to lexicons/fyi/frontpage/feed/subject/url.json index a6e1c484..60d4742f 100644 --- a/lexicons/fyi/frontpage/subject/url.json +++ b/lexicons/fyi/frontpage/feed/subject/url.json @@ -1,6 +1,6 @@ { "lexicon": 1, - "id": "fyi.frontpage.subject.url", + "id": "fyi.frontpage.feed.subject.url", "description": "A link to a webpage URL.", "defs": { "main": { From 0fb7a8d30076f93405c88b756ae443e04d06113e Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Sat, 26 Apr 2025 23:00:19 +0100 Subject: [PATCH 09/14] Ref plaintextParagraph directly --- lexicons/fyi/frontpage/feed/comment.json | 4 ++-- lexicons/fyi/frontpage/richtext/block.json | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lexicons/fyi/frontpage/feed/comment.json b/lexicons/fyi/frontpage/feed/comment.json index 0f5d4815..41d526b0 100644 --- a/lexicons/fyi/frontpage/feed/comment.json +++ b/lexicons/fyi/frontpage/feed/comment.json @@ -15,8 +15,8 @@ "maxLength": 50, "description": "The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit.", "items": { - "type": "ref", - "ref": "fyi.unravel.frontpage.richtext.block" + "type": "union", + "refs": ["fyi.frontpage.richtext.block#plaintextParagraph"] } }, "createdAt": { diff --git a/lexicons/fyi/frontpage/richtext/block.json b/lexicons/fyi/frontpage/richtext/block.json index 9be1c666..c7b93d17 100644 --- a/lexicons/fyi/frontpage/richtext/block.json +++ b/lexicons/fyi/frontpage/richtext/block.json @@ -2,10 +2,6 @@ "lexicon": 1, "id": "fyi.frontpage.richtext.block", "defs": { - "main": { - "type": "union", - "refs": ["#plaintextParagraph"] - }, "plaintextParagraph": { "type": "object", "properties": { From d6a28eca66e87f18c4318275999d24915a0b0aae Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Sat, 26 Apr 2025 23:05:25 +0100 Subject: [PATCH 10/14] Generate client code --- .../frontpage-atproto-client/src/index.ts | 233 ++++++++++++++++++ .../frontpage-atproto-client/src/lexicons.ts | 143 +++++++++++ .../src/types/fyi/frontpage/feed/comment.ts | 41 +++ .../src/types/fyi/frontpage/feed/post.ts | 36 +++ .../types/fyi/frontpage/feed/subject/url.ts | 30 +++ .../src/types/fyi/frontpage/feed/vote.ts | 34 +++ .../src/types/fyi/frontpage/richtext/block.ts | 30 +++ 7 files changed, 547 insertions(+) create mode 100644 packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts create mode 100644 packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts create mode 100644 packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts create mode 100644 packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/vote.ts create mode 100644 packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts diff --git a/packages/frontpage-atproto-client/src/index.ts b/packages/frontpage-atproto-client/src/index.ts index 5072765c..32b0d1e1 100644 --- a/packages/frontpage-atproto-client/src/index.ts +++ b/packages/frontpage-atproto-client/src/index.ts @@ -21,6 +21,11 @@ import * as ComAtprotoRepoListRecords from "./types/com/atproto/repo/listRecords import * as ComAtprotoRepoPutRecord from "./types/com/atproto/repo/putRecord.js"; import * as ComAtprotoRepoStrongRef from "./types/com/atproto/repo/strongRef.js"; import * as ComAtprotoRepoUploadBlob from "./types/com/atproto/repo/uploadBlob.js"; +import * as FyiFrontpageFeedComment from "./types/fyi/frontpage/feed/comment.js"; +import * as FyiFrontpageFeedPost from "./types/fyi/frontpage/feed/post.js"; +import * as FyiFrontpageFeedSubjectUrl from "./types/fyi/frontpage/feed/subject/url.js"; +import * as FyiFrontpageFeedVote from "./types/fyi/frontpage/feed/vote.js"; +import * as FyiFrontpageRichtextBlock from "./types/fyi/frontpage/richtext/block.js"; import * as FyiUnravelFrontpageComment from "./types/fyi/unravel/frontpage/comment.js"; import * as FyiUnravelFrontpagePost from "./types/fyi/unravel/frontpage/post.js"; import * as FyiUnravelFrontpageVote from "./types/fyi/unravel/frontpage/vote.js"; @@ -37,6 +42,11 @@ export * as ComAtprotoRepoListRecords from "./types/com/atproto/repo/listRecords export * as ComAtprotoRepoPutRecord from "./types/com/atproto/repo/putRecord.js"; export * as ComAtprotoRepoStrongRef from "./types/com/atproto/repo/strongRef.js"; export * as ComAtprotoRepoUploadBlob from "./types/com/atproto/repo/uploadBlob.js"; +export * as FyiFrontpageFeedComment from "./types/fyi/frontpage/feed/comment.js"; +export * as FyiFrontpageFeedPost from "./types/fyi/frontpage/feed/post.js"; +export * as FyiFrontpageFeedSubjectUrl from "./types/fyi/frontpage/feed/subject/url.js"; +export * as FyiFrontpageFeedVote from "./types/fyi/frontpage/feed/vote.js"; +export * as FyiFrontpageRichtextBlock from "./types/fyi/frontpage/richtext/block.js"; export * as FyiUnravelFrontpageComment from "./types/fyi/unravel/frontpage/comment.js"; export * as FyiUnravelFrontpagePost from "./types/fyi/unravel/frontpage/post.js"; export * as FyiUnravelFrontpageVote from "./types/fyi/unravel/frontpage/vote.js"; @@ -202,14 +212,237 @@ export class ComAtprotoRepoNS { export class FyiNS { _client: XrpcClient; + frontpage: FyiFrontpageNS; unravel: FyiUnravelNS; constructor(client: XrpcClient) { this._client = client; + this.frontpage = new FyiFrontpageNS(client); this.unravel = new FyiUnravelNS(client); } } +export class FyiFrontpageNS { + _client: XrpcClient; + feed: FyiFrontpageFeedNS; + + constructor(client: XrpcClient) { + this._client = client; + this.feed = new FyiFrontpageFeedNS(client); + } +} + +export class FyiFrontpageFeedNS { + _client: XrpcClient; + comment: FyiFrontpageFeedCommentRecord; + post: FyiFrontpageFeedPostRecord; + vote: FyiFrontpageFeedVoteRecord; + subject: FyiFrontpageFeedSubjectNS; + + constructor(client: XrpcClient) { + this._client = client; + this.subject = new FyiFrontpageFeedSubjectNS(client); + this.comment = new FyiFrontpageFeedCommentRecord(client); + this.post = new FyiFrontpageFeedPostRecord(client); + this.vote = new FyiFrontpageFeedVoteRecord(client); + } +} + +export class FyiFrontpageFeedSubjectNS { + _client: XrpcClient; + + constructor(client: XrpcClient) { + this._client = client; + } +} + +export class FyiFrontpageFeedCommentRecord { + _client: XrpcClient; + + constructor(client: XrpcClient) { + this._client = client; + } + + async list( + params: OmitKey, + ): Promise<{ + cursor?: string; + records: { uri: string; value: FyiFrontpageFeedComment.Record }[]; + }> { + const res = await this._client.call("com.atproto.repo.listRecords", { + collection: "fyi.frontpage.feed.comment", + ...params, + }); + return res.data; + } + + async get( + params: OmitKey, + ): Promise<{ + uri: string; + cid: string; + value: FyiFrontpageFeedComment.Record; + }> { + const res = await this._client.call("com.atproto.repo.getRecord", { + collection: "fyi.frontpage.feed.comment", + ...params, + }); + return res.data; + } + + async create( + params: OmitKey< + ComAtprotoRepoCreateRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.frontpage.feed.comment"; + const res = await this._client.call( + "com.atproto.repo.createRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + + async delete( + params: OmitKey, + headers?: Record, + ): Promise { + await this._client.call( + "com.atproto.repo.deleteRecord", + undefined, + { collection: "fyi.frontpage.feed.comment", ...params }, + { headers }, + ); + } +} + +export class FyiFrontpageFeedPostRecord { + _client: XrpcClient; + + constructor(client: XrpcClient) { + this._client = client; + } + + async list( + params: OmitKey, + ): Promise<{ + cursor?: string; + records: { uri: string; value: FyiFrontpageFeedPost.Record }[]; + }> { + const res = await this._client.call("com.atproto.repo.listRecords", { + collection: "fyi.frontpage.feed.post", + ...params, + }); + return res.data; + } + + async get( + params: OmitKey, + ): Promise<{ uri: string; cid: string; value: FyiFrontpageFeedPost.Record }> { + const res = await this._client.call("com.atproto.repo.getRecord", { + collection: "fyi.frontpage.feed.post", + ...params, + }); + return res.data; + } + + async create( + params: OmitKey< + ComAtprotoRepoCreateRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.frontpage.feed.post"; + const res = await this._client.call( + "com.atproto.repo.createRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + + async delete( + params: OmitKey, + headers?: Record, + ): Promise { + await this._client.call( + "com.atproto.repo.deleteRecord", + undefined, + { collection: "fyi.frontpage.feed.post", ...params }, + { headers }, + ); + } +} + +export class FyiFrontpageFeedVoteRecord { + _client: XrpcClient; + + constructor(client: XrpcClient) { + this._client = client; + } + + async list( + params: OmitKey, + ): Promise<{ + cursor?: string; + records: { uri: string; value: FyiFrontpageFeedVote.Record }[]; + }> { + const res = await this._client.call("com.atproto.repo.listRecords", { + collection: "fyi.frontpage.feed.vote", + ...params, + }); + return res.data; + } + + async get( + params: OmitKey, + ): Promise<{ uri: string; cid: string; value: FyiFrontpageFeedVote.Record }> { + const res = await this._client.call("com.atproto.repo.getRecord", { + collection: "fyi.frontpage.feed.vote", + ...params, + }); + return res.data; + } + + async create( + params: OmitKey< + ComAtprotoRepoCreateRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.frontpage.feed.vote"; + const res = await this._client.call( + "com.atproto.repo.createRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + + async delete( + params: OmitKey, + headers?: Record, + ): Promise { + await this._client.call( + "com.atproto.repo.deleteRecord", + undefined, + { collection: "fyi.frontpage.feed.vote", ...params }, + { headers }, + ); + } +} + export class FyiUnravelNS { _client: XrpcClient; frontpage: FyiUnravelFrontpageNS; diff --git a/packages/frontpage-atproto-client/src/lexicons.ts b/packages/frontpage-atproto-client/src/lexicons.ts index 7e216d1d..450c7a07 100644 --- a/packages/frontpage-atproto-client/src/lexicons.ts +++ b/packages/frontpage-atproto-client/src/lexicons.ts @@ -766,6 +766,144 @@ export const schemaDict = { }, }, }, + FyiFrontpageFeedComment: { + lexicon: 1, + id: "fyi.frontpage.feed.comment", + defs: { + main: { + type: "record", + description: "Record containing a Frontpage comment.", + key: "tid", + record: { + type: "object", + required: ["createdAt", "post", "blocks"], + properties: { + blocks: { + type: "array", + maxLength: 50, + description: + "The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit.", + items: { + type: "union", + refs: ["lex:fyi.frontpage.richtext.block#plaintextParagraph"], + }, + }, + createdAt: { + type: "string", + format: "datetime", + description: + "Client-declared timestamp when this comment was originally created.", + }, + parent: { + type: "ref", + ref: "lex:com.atproto.repo.strongRef", + }, + post: { + type: "ref", + ref: "lex:com.atproto.repo.strongRef", + }, + }, + }, + }, + }, + }, + FyiFrontpageFeedPost: { + lexicon: 1, + id: "fyi.frontpage.feed.post", + defs: { + main: { + type: "record", + description: "Record containing a Frontpage post.", + key: "tid", + record: { + type: "object", + required: ["title", "createdAt"], + properties: { + title: { + type: "string", + maxLength: 3000, + maxGraphemes: 300, + description: "The title of the post.", + }, + subject: { + type: "union", + description: + "The piece of content that this Frontpage post is about.", + refs: ["lex:fyi.frontpage.feed.subject.url"], + }, + createdAt: { + type: "string", + format: "datetime", + description: + "Client-declared timestamp when this post was originally created.", + }, + }, + }, + }, + }, + }, + FyiFrontpageFeedSubjectUrl: { + lexicon: 1, + id: "fyi.frontpage.feed.subject.url", + description: "A link to a webpage URL.", + defs: { + main: { + type: "object", + required: ["url"], + properties: { + url: { + type: "string", + format: "uri", + }, + }, + }, + }, + }, + FyiFrontpageFeedVote: { + lexicon: 1, + id: "fyi.frontpage.feed.vote", + defs: { + main: { + type: "record", + description: "Record containing a Frontpage vote.", + key: "tid", + record: { + type: "object", + required: ["subject", "createdAt"], + properties: { + subject: { + type: "ref", + description: + "The post or comment that this Frontpage vote is for.", + ref: "lex:com.atproto.repo.strongRef", + }, + createdAt: { + type: "string", + format: "datetime", + description: + "Client-declared timestamp when this vote was originally created.", + }, + }, + }, + }, + }, + }, + FyiFrontpageRichtextBlock: { + lexicon: 1, + id: "fyi.frontpage.richtext.block", + defs: { + plaintextParagraph: { + type: "object", + properties: { + text: { + type: "string", + maxLength: 100000, + maxGraphemes: 10000, + }, + }, + }, + }, + }, FyiUnravelFrontpageComment: { lexicon: 1, id: "fyi.unravel.frontpage.comment", @@ -909,6 +1047,11 @@ export const ids = { ComAtprotoRepoPutRecord: "com.atproto.repo.putRecord", ComAtprotoRepoStrongRef: "com.atproto.repo.strongRef", ComAtprotoRepoUploadBlob: "com.atproto.repo.uploadBlob", + FyiFrontpageFeedComment: "fyi.frontpage.feed.comment", + FyiFrontpageFeedPost: "fyi.frontpage.feed.post", + FyiFrontpageFeedSubjectUrl: "fyi.frontpage.feed.subject.url", + FyiFrontpageFeedVote: "fyi.frontpage.feed.vote", + FyiFrontpageRichtextBlock: "fyi.frontpage.richtext.block", FyiUnravelFrontpageComment: "fyi.unravel.frontpage.comment", FyiUnravelFrontpagePost: "fyi.unravel.frontpage.post", FyiUnravelFrontpageVote: "fyi.unravel.frontpage.vote", diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts new file mode 100644 index 00000000..a3706fa1 --- /dev/null +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts @@ -0,0 +1,41 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { type ValidationResult, BlobRef } from "@atproto/lexicon"; +import { CID } from "multiformats/cid"; +import { validate as _validate } from "../../../../lexicons"; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from "../../../../util"; +import type * as FyiFrontpageRichtextBlock from "../richtext/block.js"; +import type * as ComAtprotoRepoStrongRef from "../../../com/atproto/repo/strongRef.js"; + +const is$typed = _is$typed, + validate = _validate; +const id = "fyi.frontpage.feed.comment"; + +export interface Record { + $type: "fyi.frontpage.feed.comment"; + /** The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit. */ + blocks: ( + | $Typed + | { $type: string } + )[]; + /** Client-declared timestamp when this comment was originally created. */ + createdAt: string; + parent?: ComAtprotoRepoStrongRef.Main; + post: ComAtprotoRepoStrongRef.Main; + [k: string]: unknown; +} + +const hashRecord = "main"; + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord); +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord, true); +} diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts new file mode 100644 index 00000000..929fd2cf --- /dev/null +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts @@ -0,0 +1,36 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { type ValidationResult, BlobRef } from "@atproto/lexicon"; +import { CID } from "multiformats/cid"; +import { validate as _validate } from "../../../../lexicons"; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from "../../../../util"; +import type * as FyiFrontpageFeedSubjectUrl from "./subject/url.js"; + +const is$typed = _is$typed, + validate = _validate; +const id = "fyi.frontpage.feed.post"; + +export interface Record { + $type: "fyi.frontpage.feed.post"; + /** The title of the post. */ + title: string; + subject?: $Typed | { $type: string }; + /** Client-declared timestamp when this post was originally created. */ + createdAt: string; + [k: string]: unknown; +} + +const hashRecord = "main"; + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord); +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord, true); +} diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts new file mode 100644 index 00000000..a5f47f41 --- /dev/null +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts @@ -0,0 +1,30 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { type ValidationResult, BlobRef } from "@atproto/lexicon"; +import { CID } from "multiformats/cid"; +import { validate as _validate } from "../../../../../lexicons"; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from "../../../../../util"; + +const is$typed = _is$typed, + validate = _validate; +const id = "fyi.frontpage.feed.subject.url"; + +export interface Main { + $type?: "fyi.frontpage.feed.subject.url"; + url: string; +} + +const hashMain = "main"; + +export function isMain(v: V) { + return is$typed(v, id, hashMain); +} + +export function validateMain(v: V) { + return validate
(v, id, hashMain); +} diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/vote.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/vote.ts new file mode 100644 index 00000000..a3f17fd7 --- /dev/null +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/vote.ts @@ -0,0 +1,34 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { type ValidationResult, BlobRef } from "@atproto/lexicon"; +import { CID } from "multiformats/cid"; +import { validate as _validate } from "../../../../lexicons"; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from "../../../../util"; +import type * as ComAtprotoRepoStrongRef from "../../../com/atproto/repo/strongRef.js"; + +const is$typed = _is$typed, + validate = _validate; +const id = "fyi.frontpage.feed.vote"; + +export interface Record { + $type: "fyi.frontpage.feed.vote"; + subject: ComAtprotoRepoStrongRef.Main; + /** Client-declared timestamp when this vote was originally created. */ + createdAt: string; + [k: string]: unknown; +} + +const hashRecord = "main"; + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord); +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord, true); +} diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts new file mode 100644 index 00000000..25d5d711 --- /dev/null +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts @@ -0,0 +1,30 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { type ValidationResult, BlobRef } from "@atproto/lexicon"; +import { CID } from "multiformats/cid"; +import { validate as _validate } from "../../../../lexicons"; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from "../../../../util"; + +const is$typed = _is$typed, + validate = _validate; +const id = "fyi.frontpage.richtext.block"; + +export interface PlaintextParagraph { + $type?: "fyi.frontpage.richtext.block#plaintextParagraph"; + text?: string; +} + +const hashPlaintextParagraph = "plaintextParagraph"; + +export function isPlaintextParagraph(v: V) { + return is$typed(v, id, hashPlaintextParagraph); +} + +export function validatePlaintextParagraph(v: V) { + return validate(v, id, hashPlaintextParagraph); +} From ef5cb03db113d7b68868cce9f06819ca3299dcb8 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Fri, 3 Oct 2025 23:57:57 +0100 Subject: [PATCH 11/14] Move subjects into post schema --- lexicons/fyi/frontpage/feed/post.json | 12 +++++++++++- lexicons/fyi/frontpage/feed/subject/url.json | 17 ----------------- 2 files changed, 11 insertions(+), 18 deletions(-) delete mode 100644 lexicons/fyi/frontpage/feed/subject/url.json diff --git a/lexicons/fyi/frontpage/feed/post.json b/lexicons/fyi/frontpage/feed/post.json index 7f16be48..d7224de7 100644 --- a/lexicons/fyi/frontpage/feed/post.json +++ b/lexicons/fyi/frontpage/feed/post.json @@ -19,7 +19,7 @@ "subject": { "type": "union", "description": "The piece of content that this Frontpage post is about.", - "refs": ["fyi.frontpage.feed.subject.url"] + "refs": ["#urlSubject"] }, "createdAt": { "type": "string", @@ -28,6 +28,16 @@ } } } + }, + "urlSubject": { + "type": "object", + "required": ["url"], + "properties": { + "url": { + "type": "string", + "format": "uri" + } + } } } } diff --git a/lexicons/fyi/frontpage/feed/subject/url.json b/lexicons/fyi/frontpage/feed/subject/url.json deleted file mode 100644 index 60d4742f..00000000 --- a/lexicons/fyi/frontpage/feed/subject/url.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "lexicon": 1, - "id": "fyi.frontpage.feed.subject.url", - "description": "A link to a webpage URL.", - "defs": { - "main": { - "type": "object", - "required": ["url"], - "properties": { - "url": { - "type": "string", - "format": "uri" - } - } - } - } -} From 95ee9c3166a1c979f5855c9b67d8b249f48e6973 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Sat, 4 Oct 2025 00:05:37 +0100 Subject: [PATCH 12/14] Generate client code --- .../frontpage-atproto-client/src/index.ts | 120 ++++++++++++++++-- .../frontpage-atproto-client/src/lexicons.ts | 12 +- .../src/types/fyi/frontpage/feed/post.ts | 18 ++- .../types/fyi/frontpage/feed/subject/url.ts | 30 ----- 4 files changed, 126 insertions(+), 54 deletions(-) delete mode 100644 packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts diff --git a/packages/frontpage-atproto-client/src/index.ts b/packages/frontpage-atproto-client/src/index.ts index 32b0d1e1..6ed19926 100644 --- a/packages/frontpage-atproto-client/src/index.ts +++ b/packages/frontpage-atproto-client/src/index.ts @@ -23,7 +23,6 @@ import * as ComAtprotoRepoStrongRef from "./types/com/atproto/repo/strongRef.js" import * as ComAtprotoRepoUploadBlob from "./types/com/atproto/repo/uploadBlob.js"; import * as FyiFrontpageFeedComment from "./types/fyi/frontpage/feed/comment.js"; import * as FyiFrontpageFeedPost from "./types/fyi/frontpage/feed/post.js"; -import * as FyiFrontpageFeedSubjectUrl from "./types/fyi/frontpage/feed/subject/url.js"; import * as FyiFrontpageFeedVote from "./types/fyi/frontpage/feed/vote.js"; import * as FyiFrontpageRichtextBlock from "./types/fyi/frontpage/richtext/block.js"; import * as FyiUnravelFrontpageComment from "./types/fyi/unravel/frontpage/comment.js"; @@ -44,7 +43,6 @@ export * as ComAtprotoRepoStrongRef from "./types/com/atproto/repo/strongRef.js" export * as ComAtprotoRepoUploadBlob from "./types/com/atproto/repo/uploadBlob.js"; export * as FyiFrontpageFeedComment from "./types/fyi/frontpage/feed/comment.js"; export * as FyiFrontpageFeedPost from "./types/fyi/frontpage/feed/post.js"; -export * as FyiFrontpageFeedSubjectUrl from "./types/fyi/frontpage/feed/subject/url.js"; export * as FyiFrontpageFeedVote from "./types/fyi/frontpage/feed/vote.js"; export * as FyiFrontpageRichtextBlock from "./types/fyi/frontpage/richtext/block.js"; export * as FyiUnravelFrontpageComment from "./types/fyi/unravel/frontpage/comment.js"; @@ -237,25 +235,15 @@ export class FyiFrontpageFeedNS { comment: FyiFrontpageFeedCommentRecord; post: FyiFrontpageFeedPostRecord; vote: FyiFrontpageFeedVoteRecord; - subject: FyiFrontpageFeedSubjectNS; constructor(client: XrpcClient) { this._client = client; - this.subject = new FyiFrontpageFeedSubjectNS(client); this.comment = new FyiFrontpageFeedCommentRecord(client); this.post = new FyiFrontpageFeedPostRecord(client); this.vote = new FyiFrontpageFeedVoteRecord(client); } } -export class FyiFrontpageFeedSubjectNS { - _client: XrpcClient; - - constructor(client: XrpcClient) { - this._client = client; - } -} - export class FyiFrontpageFeedCommentRecord { _client: XrpcClient; @@ -308,6 +296,24 @@ export class FyiFrontpageFeedCommentRecord { return res.data; } + async put( + params: OmitKey< + ComAtprotoRepoPutRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.frontpage.feed.comment"; + const res = await this._client.call( + "com.atproto.repo.putRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + async delete( params: OmitKey, headers?: Record, @@ -369,6 +375,24 @@ export class FyiFrontpageFeedPostRecord { return res.data; } + async put( + params: OmitKey< + ComAtprotoRepoPutRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.frontpage.feed.post"; + const res = await this._client.call( + "com.atproto.repo.putRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + async delete( params: OmitKey, headers?: Record, @@ -430,6 +454,24 @@ export class FyiFrontpageFeedVoteRecord { return res.data; } + async put( + params: OmitKey< + ComAtprotoRepoPutRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.frontpage.feed.vote"; + const res = await this._client.call( + "com.atproto.repo.putRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + async delete( params: OmitKey, headers?: Record, @@ -519,6 +561,24 @@ export class FyiUnravelFrontpageCommentRecord { return res.data; } + async put( + params: OmitKey< + ComAtprotoRepoPutRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.unravel.frontpage.comment"; + const res = await this._client.call( + "com.atproto.repo.putRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + async delete( params: OmitKey, headers?: Record, @@ -584,6 +644,24 @@ export class FyiUnravelFrontpagePostRecord { return res.data; } + async put( + params: OmitKey< + ComAtprotoRepoPutRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.unravel.frontpage.post"; + const res = await this._client.call( + "com.atproto.repo.putRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + async delete( params: OmitKey, headers?: Record, @@ -649,6 +727,24 @@ export class FyiUnravelFrontpageVoteRecord { return res.data; } + async put( + params: OmitKey< + ComAtprotoRepoPutRecord.InputSchema, + "collection" | "record" + >, + record: Un$Typed, + headers?: Record, + ): Promise<{ uri: string; cid: string }> { + const collection = "fyi.unravel.frontpage.vote"; + const res = await this._client.call( + "com.atproto.repo.putRecord", + undefined, + { collection, ...params, record: { ...record, $type: collection } }, + { encoding: "application/json", headers }, + ); + return res.data; + } + async delete( params: OmitKey, headers?: Record, diff --git a/packages/frontpage-atproto-client/src/lexicons.ts b/packages/frontpage-atproto-client/src/lexicons.ts index 450c7a07..e69efdbd 100644 --- a/packages/frontpage-atproto-client/src/lexicons.ts +++ b/packages/frontpage-atproto-client/src/lexicons.ts @@ -829,7 +829,7 @@ export const schemaDict = { type: "union", description: "The piece of content that this Frontpage post is about.", - refs: ["lex:fyi.frontpage.feed.subject.url"], + refs: ["lex:fyi.frontpage.feed.post#urlSubject"], }, createdAt: { type: "string", @@ -840,14 +840,7 @@ export const schemaDict = { }, }, }, - }, - }, - FyiFrontpageFeedSubjectUrl: { - lexicon: 1, - id: "fyi.frontpage.feed.subject.url", - description: "A link to a webpage URL.", - defs: { - main: { + urlSubject: { type: "object", required: ["url"], properties: { @@ -1049,7 +1042,6 @@ export const ids = { ComAtprotoRepoUploadBlob: "com.atproto.repo.uploadBlob", FyiFrontpageFeedComment: "fyi.frontpage.feed.comment", FyiFrontpageFeedPost: "fyi.frontpage.feed.post", - FyiFrontpageFeedSubjectUrl: "fyi.frontpage.feed.subject.url", FyiFrontpageFeedVote: "fyi.frontpage.feed.vote", FyiFrontpageRichtextBlock: "fyi.frontpage.richtext.block", FyiUnravelFrontpageComment: "fyi.unravel.frontpage.comment", diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts index 929fd2cf..856b1dc0 100644 --- a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/post.ts @@ -9,7 +9,6 @@ import { is$typed as _is$typed, type OmitKey, } from "../../../../util"; -import type * as FyiFrontpageFeedSubjectUrl from "./subject/url.js"; const is$typed = _is$typed, validate = _validate; @@ -19,7 +18,7 @@ export interface Record { $type: "fyi.frontpage.feed.post"; /** The title of the post. */ title: string; - subject?: $Typed | { $type: string }; + subject?: $Typed | { $type: string }; /** Client-declared timestamp when this post was originally created. */ createdAt: string; [k: string]: unknown; @@ -34,3 +33,18 @@ export function isRecord(v: V) { export function validateRecord(v: V) { return validate(v, id, hashRecord, true); } + +export interface UrlSubject { + $type?: "fyi.frontpage.feed.post#urlSubject"; + url: string; +} + +const hashUrlSubject = "urlSubject"; + +export function isUrlSubject(v: V) { + return is$typed(v, id, hashUrlSubject); +} + +export function validateUrlSubject(v: V) { + return validate(v, id, hashUrlSubject); +} diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts deleted file mode 100644 index a5f47f41..00000000 --- a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/subject/url.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * GENERATED CODE - DO NOT MODIFY - */ -import { type ValidationResult, BlobRef } from "@atproto/lexicon"; -import { CID } from "multiformats/cid"; -import { validate as _validate } from "../../../../../lexicons"; -import { - type $Typed, - is$typed as _is$typed, - type OmitKey, -} from "../../../../../util"; - -const is$typed = _is$typed, - validate = _validate; -const id = "fyi.frontpage.feed.subject.url"; - -export interface Main { - $type?: "fyi.frontpage.feed.subject.url"; - url: string; -} - -const hashMain = "main"; - -export function isMain(v: V) { - return is$typed(v, id, hashMain); -} - -export function validateMain(v: V) { - return validate
(v, id, hashMain); -} From 0b98a2531ee63b592f4328a2d1daf810ad63b5d8 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Sat, 4 Oct 2025 10:13:59 +0100 Subject: [PATCH 13/14] Move richtext block union into block type --- lexicons/fyi/frontpage/feed/comment.json | 4 ++-- lexicons/fyi/frontpage/richtext/block.json | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lexicons/fyi/frontpage/feed/comment.json b/lexicons/fyi/frontpage/feed/comment.json index 41d526b0..8a7c8eb2 100644 --- a/lexicons/fyi/frontpage/feed/comment.json +++ b/lexicons/fyi/frontpage/feed/comment.json @@ -15,8 +15,8 @@ "maxLength": 50, "description": "The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit.", "items": { - "type": "union", - "refs": ["fyi.frontpage.richtext.block#plaintextParagraph"] + "type": "ref", + "ref": "fyi.frontpage.richtext.block" } }, "createdAt": { diff --git a/lexicons/fyi/frontpage/richtext/block.json b/lexicons/fyi/frontpage/richtext/block.json index c7b93d17..d90f3d6f 100644 --- a/lexicons/fyi/frontpage/richtext/block.json +++ b/lexicons/fyi/frontpage/richtext/block.json @@ -2,6 +2,16 @@ "lexicon": 1, "id": "fyi.frontpage.richtext.block", "defs": { + "main": { + "type": "object", + "required": ["content"], + "properties": { + "content": { + "type": "union", + "refs": ["#plaintextParagraph"] + } + } + }, "plaintextParagraph": { "type": "object", "properties": { From 3f57182dc70ef0d8176542f2ffc8454f02de0f52 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Sat, 4 Oct 2025 10:16:22 +0100 Subject: [PATCH 14/14] Generate client --- packages/frontpage-atproto-client/src/index.ts | 10 ++++++++++ packages/frontpage-atproto-client/src/lexicons.ts | 14 ++++++++++++-- .../src/types/fyi/frontpage/feed/comment.ts | 5 +---- .../src/types/fyi/frontpage/richtext/block.ts | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/frontpage-atproto-client/src/index.ts b/packages/frontpage-atproto-client/src/index.ts index 6ed19926..36771fad 100644 --- a/packages/frontpage-atproto-client/src/index.ts +++ b/packages/frontpage-atproto-client/src/index.ts @@ -223,10 +223,12 @@ export class FyiNS { export class FyiFrontpageNS { _client: XrpcClient; feed: FyiFrontpageFeedNS; + richtext: FyiFrontpageRichtextNS; constructor(client: XrpcClient) { this._client = client; this.feed = new FyiFrontpageFeedNS(client); + this.richtext = new FyiFrontpageRichtextNS(client); } } @@ -485,6 +487,14 @@ export class FyiFrontpageFeedVoteRecord { } } +export class FyiFrontpageRichtextNS { + _client: XrpcClient; + + constructor(client: XrpcClient) { + this._client = client; + } +} + export class FyiUnravelNS { _client: XrpcClient; frontpage: FyiUnravelFrontpageNS; diff --git a/packages/frontpage-atproto-client/src/lexicons.ts b/packages/frontpage-atproto-client/src/lexicons.ts index e69efdbd..1cd17b1d 100644 --- a/packages/frontpage-atproto-client/src/lexicons.ts +++ b/packages/frontpage-atproto-client/src/lexicons.ts @@ -784,8 +784,8 @@ export const schemaDict = { description: "The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit.", items: { - type: "union", - refs: ["lex:fyi.frontpage.richtext.block#plaintextParagraph"], + type: "ref", + ref: "lex:fyi.frontpage.richtext.block", }, }, createdAt: { @@ -885,6 +885,16 @@ export const schemaDict = { lexicon: 1, id: "fyi.frontpage.richtext.block", defs: { + main: { + type: "object", + required: ["content"], + properties: { + content: { + type: "union", + refs: ["lex:fyi.frontpage.richtext.block#plaintextParagraph"], + }, + }, + }, plaintextParagraph: { type: "object", properties: { diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts index a3706fa1..11bcb466 100644 --- a/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/feed/comment.ts @@ -19,10 +19,7 @@ const id = "fyi.frontpage.feed.comment"; export interface Record { $type: "fyi.frontpage.feed.comment"; /** The content of the comment. Note, there are additional constraints placed on the total size of the content within the Frontpage AppView that are not possible to express in lexicon. Generally a comment can have a maximum length of 10,000 graphemes, the Frontpage AppView will enforce this limit. */ - blocks: ( - | $Typed - | { $type: string } - )[]; + blocks: FyiFrontpageRichtextBlock.Main[]; /** Client-declared timestamp when this comment was originally created. */ createdAt: string; parent?: ComAtprotoRepoStrongRef.Main; diff --git a/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts b/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts index 25d5d711..9b6166d0 100644 --- a/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts +++ b/packages/frontpage-atproto-client/src/types/fyi/frontpage/richtext/block.ts @@ -14,6 +14,21 @@ const is$typed = _is$typed, validate = _validate; const id = "fyi.frontpage.richtext.block"; +export interface Main { + $type?: "fyi.frontpage.richtext.block"; + content: $Typed | { $type: string }; +} + +const hashMain = "main"; + +export function isMain(v: V) { + return is$typed(v, id, hashMain); +} + +export function validateMain(v: V) { + return validate
(v, id, hashMain); +} + export interface PlaintextParagraph { $type?: "fyi.frontpage.richtext.block#plaintextParagraph"; text?: string;