v3: comments say what the code can't — the documentation pass wanted JSDoc on every export and every field of an exported interface, which filled the code with restatements ("The dump.", "Whether it is loading.", "The props of X.", "Renders the X.") and module docs that told a reader nothing ("The hot and new feeds, and the props every main feed of the index takes."); some were wrong as well as vague. Every comment in api/, shared/ and src/ is rewritten under one rule, now stated in the README's "Comments" section: every module and export still has a JSDoc, and it gives context (who uses it and where), usage (what a caller must know: a precondition, what it leaves to the caller, a side effect) or its place in the chain (where its input comes from, where its output goes); a field, parameter, private function or local gets one only when it adds to its parent's, and context about a whole type goes on the type; a type's doc is phrased from the value's side ("Returned to Y by X when Z", "Passed to Y by X"); full sentences, as short as they can be, no label-colon-list; // goes wherever the code isn't obvious and says why, and the section banners and narration go. Every claim was checked against the code, which turned up some forty comments that were wrong: DumpCard's claimed it was only used by the hot and new feeds, the WebSocket welcome claimed to be a socket's first message (presence comes first), UpdateUserRequest said null removes a description (it keeps it), deletedDumpIds leaves out that it also holds dumps made private, THEME_COLOR claimed to mirror index.html's, and the like. The routers' JSDoc now says where they are mounted and what becomes of a thrown APIException. doc-lint.ts lets a field without a doc through; a module or export without one still fails. No code changes; 204 backend and 628 frontend tests pass, and doc:lint, deno check, deno lint and tsc are clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
/**
|
||||
* Notifications: their types, and the data each type carries.
|
||||
* Types the notifications `api/services/notification-service.ts` makes, and
|
||||
* the data each kind carries. The client's `/notifications` page lists them
|
||||
* and turns each into a sentence and a link.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
|
||||
/** What a notification is about. */
|
||||
/**
|
||||
* Says which of the `…Data` interfaces a notification's `data` is. Each value
|
||||
* has one `notify…` trigger in `notification-service.ts`.
|
||||
*/
|
||||
export type NotificationType =
|
||||
| "playlist_followed"
|
||||
| "user_followed"
|
||||
@@ -15,69 +20,59 @@ export type NotificationType =
|
||||
| "dump_commented"
|
||||
| "comment_liked";
|
||||
|
||||
/** `playlist_followed`: someone followed one of the user's playlists. */
|
||||
/**
|
||||
* Carried by a `playlist_followed` notification, sent to a playlist's owner.
|
||||
*/
|
||||
export interface PlaylistFollowedData {
|
||||
/** The follower's id. */
|
||||
followerId: string;
|
||||
/** The follower's name. */
|
||||
followerUsername: string;
|
||||
/** The playlist's id. */
|
||||
playlistId: string;
|
||||
/** The playlist's title. */
|
||||
playlistTitle: string;
|
||||
}
|
||||
|
||||
/** `user_followed`: someone followed the user. */
|
||||
/** Carried by a `user_followed` notification, sent to the user followed. */
|
||||
export interface UserFollowedData {
|
||||
/** The follower's id. */
|
||||
followerId: string;
|
||||
/** The follower's name. */
|
||||
followerUsername: string;
|
||||
}
|
||||
|
||||
/** `user_dump_posted`: a user they follow posted a dump. */
|
||||
/**
|
||||
* Carried by a `user_dump_posted` notification, sent to the followers of a
|
||||
* user who posted a public dump.
|
||||
*/
|
||||
export interface UserDumpPostedData {
|
||||
/** The poster's id. */
|
||||
dumperId: string;
|
||||
/** The poster's name. */
|
||||
dumperUsername: string;
|
||||
/** The dump's id. */
|
||||
dumpId: string;
|
||||
/** The dump's title. */
|
||||
dumpTitle: string;
|
||||
}
|
||||
|
||||
/** `playlist_dump_added`: a dump was added to a playlist they follow. */
|
||||
/**
|
||||
* Carried by a `playlist_dump_added` notification, sent to the followers of a
|
||||
* public playlist when a public dump is added to it.
|
||||
*/
|
||||
export interface PlaylistDumpAddedData {
|
||||
/** The dump's id. */
|
||||
dumpId: string;
|
||||
/** The dump's title. */
|
||||
dumpTitle: string;
|
||||
/** The playlist's id. */
|
||||
playlistId: string;
|
||||
/** The playlist's title. */
|
||||
playlistTitle: string;
|
||||
}
|
||||
|
||||
/** `dump_upvoted`: someone upvoted one of the user's dumps. */
|
||||
/** Carried by a `dump_upvoted` notification, sent to the dump's poster. */
|
||||
export interface DumpUpvotedData {
|
||||
/** The voter's id. */
|
||||
voterId: string;
|
||||
/** The voter's name. */
|
||||
voterUsername: string;
|
||||
/** The dump's id. */
|
||||
dumpId: string;
|
||||
/** The dump's title. */
|
||||
dumpTitle: string;
|
||||
}
|
||||
|
||||
/** `user_mentioned`: someone @mentioned the user. */
|
||||
/**
|
||||
* Carried by a `user_mentioned` notification, sent to a user @mentioned in a
|
||||
* comment, a dump, a playlist's description or a chat message.
|
||||
*/
|
||||
export interface UserMentionedData {
|
||||
/** The mentioner's id. */
|
||||
mentionerId: string;
|
||||
/** The mentioner's name. */
|
||||
mentionerUsername: string;
|
||||
/** Where the mention was written. */
|
||||
contextType: "comment" | "dump" | "playlist" | "chat";
|
||||
/** The id of the comment, dump, playlist or chat message. */
|
||||
contextId: string;
|
||||
@@ -86,39 +81,36 @@ export interface UserMentionedData {
|
||||
* empty for the chat.
|
||||
*/
|
||||
contextTitle: string;
|
||||
/** The dump a comment is under, for a mention in a comment. */
|
||||
/**
|
||||
* Set only for a comment. It names the dump the comment is under, which the
|
||||
* notification's link opens.
|
||||
*/
|
||||
dumpId?: string;
|
||||
}
|
||||
|
||||
/** `dump_commented`: someone commented on one of the user's dumps. */
|
||||
/** Carried by a `dump_commented` notification, sent to the dump's poster. */
|
||||
export interface DumpCommentedData {
|
||||
/** The commenter's id. */
|
||||
commenterId: string;
|
||||
/** The commenter's name. */
|
||||
commenterUsername: string;
|
||||
/** The comment's id. */
|
||||
commentId: string;
|
||||
/** The dump's id. */
|
||||
dumpId: string;
|
||||
/** The dump's title. */
|
||||
dumpTitle: string;
|
||||
}
|
||||
|
||||
/** `comment_liked`: someone liked one of the user's comments. */
|
||||
/** Carried by a `comment_liked` notification, sent to the comment's author. */
|
||||
export interface CommentLikedData {
|
||||
/** The liker's id. */
|
||||
likerId: string;
|
||||
/** The liker's name. */
|
||||
likerUsername: string;
|
||||
/** The comment's id. */
|
||||
commentId: string;
|
||||
/** The id of the dump it is under. */
|
||||
dumpId: string;
|
||||
/** The title of the dump it is under. */
|
||||
dumpTitle: string;
|
||||
}
|
||||
|
||||
/** The data of any notification; its {@link NotificationType} says which. */
|
||||
/**
|
||||
* A snapshot taken when the notification is made: a name or title changed
|
||||
* later still shows the old one. The notification's `type` says which member
|
||||
* it is.
|
||||
*/
|
||||
export type NotificationData =
|
||||
| PlaylistFollowedData
|
||||
| UserFollowedData
|
||||
@@ -129,18 +121,15 @@ export type NotificationData =
|
||||
| DumpCommentedData
|
||||
| CommentLikedData;
|
||||
|
||||
/** A notification sent to a user. */
|
||||
/**
|
||||
* Pushed to its user's sockets in a `notification_created` message when it is
|
||||
* made, and returned by `GET /api/notifications`.
|
||||
*/
|
||||
export interface Notification {
|
||||
/** The notification's id. */
|
||||
id: string;
|
||||
/** The id of the user it is for. */
|
||||
userId: string;
|
||||
/** What it is about. */
|
||||
type: NotificationType;
|
||||
/** Its details, shaped by `type`. */
|
||||
data: NotificationData;
|
||||
/** Whether the user has read it. */
|
||||
read: boolean;
|
||||
/** When it was sent. */
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user