Rewrite domain objects as a Reader/Builder split
tests / tests (push) Failing after 5m8s

Replace the single DomainObject/EncryptableList classes with a read/write split
that removes the optional-event ambiguity:

- base.ts: EventReader<P> (static kind; fromEvent(event, signer?) eagerly computes
  a generic `plain`, validates leniently, throws-or-passes; lazy method accessors;
  group/protect/expires + extraTags carry-over; builder()) and EventBuilder<P>
  (chainable setters, buildTags/buildContent, validate-on-emit).
- List.ts: ListReader/ListBuilder for NIP-51 lists (decrypt-on-read into `plain`,
  re-encrypt-on-emit, tag mutators).
- Every kind converted to a <Noun> reader + <Noun>Builder pair; membership ops
  split into per-kind reader/builder pairs over a shared abstract base.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V67tPYdvh1qCkjEBhJGZUR
This commit is contained in:
2026-06-19 00:35:06 +00:00
parent 5e142e4db4
commit b6b129fdc9
45 changed files with 2304 additions and 1626 deletions
+11 -3
View File
@@ -6,13 +6,13 @@ import {
getTopicTagValues,
getTagValues,
} from "@welshman/util"
import {EncryptableList} from "./List.js"
import {ListReader, ListBuilder} from "./List.js"
// NIP-51 kind-10003 bookmark list. Mixed entries (notes via 'e', articles via
// 'a', hashtags via 't', urls via 'r') can be bookmarked publicly (tags) or
// privately (encrypted content); accessors treat both as one merged set.
export class BookmarkList extends EncryptableList {
readonly kind = BOOKMARKS
export class BookmarkList extends ListReader {
static kind = BOOKMARKS
ids() {
return uniq(getEventTagValues(this.tags()))
@@ -30,6 +30,14 @@ export class BookmarkList extends EncryptableList {
return uniq(getTagValues("r", this.tags()))
}
builder() {
return this.seedList(new BookmarkListBuilder())
}
}
export class BookmarkListBuilder extends ListBuilder {
static kind = BOOKMARKS
bookmarkPublicly(tag: string[]) {
return this.addPublicTags(tag)
}