founder-schema 0.28.0 → 0.30.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/domains/notifications/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,iBAAiB;IACjB,kBAAkB;IAClB,gBAAgB;IAChB,yBAAyB;IACzB,gBAAgB;IAChB,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,kBAAkB;IAClB,QAAQ;IACR,wBAAwB;IACxB,4BAA4B;IAC5B,kBAAkB;IAClB,wBAAwB;IACxB,8BAA8B;IAC9B,aAAa;IACb,YAAY;IACZ,kBAAkB;IAClB,cAAc;IACd,kBAAkB;IAClB,cAAc;IACd,wBAAwB;IACxB,SAAS;IACT,aAAa;IACb,gBAAgB;CACR,CAAC;AACX,MAAM,CAAC,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,CAAC","sourcesContent":["/**\n * founder-schema — Notifications: the bell\n *\n * The design the user approved on 2026-10-05 (\"Founder Circle Schema Review\"):\n *\n * - ONE ROW PER RECIPIENT, written when the event happens.\n * - REPEATS MERGE: a second comment on your post updates the same row\n * (\"2 new comments, latest from Asha\"), it never adds one. `count` is how\n * many events it holds and `actor` the latest. A member repeating the same\n * act (reacting, taking it back, reacting again) does not ring it again.\n * - THE ACTOR IS LOOKED UP WHEN READ, never copied in: a renamed member shows\n * their new name, and a deleted one shows as null (\"A former member\").\n * - PREFERENCES ARE CHECKED before writing (Jansathi stores them and never\n * reads them). A team invitation is always delivered: it needs an answer.\n * - KEPT `NOTIFICATION_RETENTION_DAYS`, then deleted.\n * - Nobody is notified of their own action.\n *\n * In-app only. Push stays chat's (async-service) until a channel is designed:\n * a client polls the unread count (on focus, and every minute while visible).\n *\n * Routes (all signed in):\n * GET /api/v1/notifications paginationQuerySchema -> notificationPageSchema\n * GET /api/v1/notifications/unread-count -> notificationUnreadCountSchema\n * POST /api/v1/notifications/read mark every one read -> notificationUnreadCountSchema\n * PUT /api/v1/notifications/:notificationId/read -> notificationSchema\n * GET /api/v1/notifications/preferences -> notificationPreferencesSchema\n * PUT /api/v1/notifications/preferences updateNotificationPreferencesBodySchema -> notificationPreferencesSchema\n *\n * @module founder-schema/domains/notifications\n */\n\nimport { z } from 'zod';\nimport { objectIdSchema } from '../../core/common.js';\nimport { NOTIFICATION_EXCERPT_MAX } from '../../core/limits.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport {\n communityChipSchema,\n communitySuggestionDecisionSchema,\n} from '../communities/communities.js';\nimport { contentKindSchema, reactionTypeSchema } from '../feed/feed.js';\nimport { planTierSchema } from '../membership/membership.js';\nimport { productChipSchema, productInvitableRoleSchema } from '../products/products.js';\nimport { memberBylineSchema } from '../profile/founder-profile.js';\n\n/**\n * What happened. ⚠ Stored per row: append only.\n *\n * comment_on_post someone commented on your post or poll\n * reply_to_comment someone replied to your comment\n * product_invite a team invited you (always delivered)\n * product_invite_accepted someone accepted your team's invitation\n * product_review someone reviewed a product you are on the team of\n * review_reply a product's team answered your review\n * feedback_helpful a team marked your feedback as having helped\n * tester_confirmed a team confirmed you tested their product\n * post_reaction someone reacted to your post or poll (0.8.0)\n * comment_reaction someone reacted to your comment (0.8.0)\n * repost someone reposted your post or poll (0.8.0)\n * community_join_request someone asked to join a community you moderate (0.9.0)\n * community_request_approved your request to join was approved (always delivered)\n * community_invite a community invited you (always delivered)\n * community_announcement a community you are in pinned an announcement for everyone\n * community_suggestion_decided your community suggestion was approved or declined (always delivered)\n * plan_ending your plan ends in 7 days, then in 1 day (0.12.0, always delivered)\n * plan_ended your plan ended; `paused` products were paused (0.12.0, always delivered)\n * payment_refunded staff refunded one of your payments (0.12.0, always delivered)\n * chat_message someone messaged you while you were not in that chat (always\n * delivered; the browser's permission is the off switch). One\n * row per conversation: more messages merge into it, and opening\n * the chat marks it read. No message text is stored on it.\n * free_plans_ended payments went live, so the top plan every member held free\n * while they were off ended; `paused` products were paused\n * (0.24.0, always delivered; only to owners it paused any for)\n * new_follower someone started following you (2026-11-20). Rings once while\n * unread; an unfollow takes the unread row back.\n * followed_member_posted someone you follow shared a new post or poll you can read\n * (2026-11-20). One row per post; never its text.\n * mention someone @mentioned you in a post, a poll's question or a\n * comment (2026-11-23). One row per post or poll: mentions in\n * it and in its comments merge. Never for naming yourself.\n * post_upvote someone up voted your post or poll (2026-11-23). Merged per\n * item like a reaction; a NEW up vote only (a down vote, a flip\n * and a clear are silent); in the bell, never a push.\n * comment_upvote someone up voted your comment (2026-11-23), as above.\n *\n * The three 0.8.0 kinds merge per target like the others. A reaction counts\n * once: changing it to another type is not a new event, and taking it back\n * does not take the event back.\n */\nexport const NOTIFICATION_KIND_VALUES = [\n 'comment_on_post',\n 'reply_to_comment',\n 'product_invite',\n 'product_invite_accepted',\n 'product_review',\n 'review_reply',\n 'feedback_helpful',\n 'tester_confirmed',\n 'post_reaction',\n 'comment_reaction',\n 'repost',\n 'community_join_request',\n 'community_request_approved',\n 'community_invite',\n 'community_announcement',\n 'community_suggestion_decided',\n 'plan_ending',\n 'plan_ended',\n 'payment_refunded',\n 'chat_message',\n 'free_plans_ended',\n 'new_follower',\n 'followed_member_posted',\n 'mention',\n 'post_upvote',\n 'comment_upvote',\n] as const;\nexport const notificationKindSchema = z.enum(NOTIFICATION_KIND_VALUES);\nexport type NotificationKind = z.infer<typeof notificationKindSchema>;\n\n/** The switches a member has, each covering one or more kinds. */\nexport const NOTIFICATION_PREFERENCE_VALUES = [\n 'comments',\n 'replies',\n 'productActivity',\n 'recognition',\n 'reactions',\n 'reposts',\n 'communities',\n 'followers',\n 'followedPosts',\n 'mentions',\n 'upvotes',\n] as const;\nexport type NotificationPreference = (typeof NOTIFICATION_PREFERENCE_VALUES)[number];\n\n/**\n * Which switch silences which kind. Null: always delivered. Exhaustive by\n * type, so a kind added without a decision here does not compile.\n */\nexport const NOTIFICATION_PREFERENCE_OF = {\n comment_on_post: 'comments',\n reply_to_comment: 'replies',\n product_invite: null,\n product_invite_accepted: 'productActivity',\n product_review: 'productActivity',\n review_reply: 'productActivity',\n feedback_helpful: 'recognition',\n tester_confirmed: 'recognition',\n post_reaction: 'reactions',\n comment_reaction: 'reactions',\n repost: 'reposts',\n community_join_request: 'communities',\n community_request_approved: null,\n community_invite: null,\n community_announcement: 'communities',\n community_suggestion_decided: null,\n plan_ending: null,\n plan_ended: null,\n payment_refunded: null,\n chat_message: null,\n free_plans_ended: null,\n new_follower: 'followers',\n followed_member_posted: 'followedPosts',\n mention: 'mentions',\n post_upvote: 'upvotes',\n comment_upvote: 'upvotes',\n} as const satisfies Record<NotificationKind, NotificationPreference | null>;\n\n/**\n * One row of the bell. Which of the optional targets are present depends on\n * `kind`:\n *\n * comment_on_post content, commentId\n * reply_to_comment content, commentId (the reply)\n * product_invite product, role\n * product_invite_accepted product\n * product_review product, reviewId\n * review_reply product, reviewId\n * feedback_helpful product, content, commentId\n * tester_confirmed product\n * post_reaction content, reaction\n * comment_reaction content, commentId, reaction, excerpt (your comment)\n * repost content (yours, the one reposted), repostId (the latest repost, to read their words)\n * community_join_request community\n * community_request_approved community\n * community_invite community\n * community_announcement community, content (the pinned post or poll)\n * community_suggestion_decided suggestion, community (once approved)\n * plan_ending plan (the tier, and when it ends)\n * plan_ended plan (the tier that ended), paused (how many products)\n * payment_refunded payment\n * chat_message conversationId (the chat to open)\n * free_plans_ended paused (how many products)\n * new_follower (the actor alone: who followed you)\n * followed_member_posted content (their new post or poll), community (when it is in one)\n * mention content (where), commentId (when it was in a comment), excerpt\n * post_upvote content\n * comment_upvote content, commentId, excerpt (your comment)\n *\n * Any row about something inside a community also carries `community`\n * (0.9.0), whatever its kind. When the recipient leaves the community, is\n * removed or is banned, its rows about that community lose their content,\n * comment, excerpt and repost: what they could read there, they no longer can.\n *\n * A target that no longer exists (a deleted post, product or review) is\n * absent rather than pointing at a 404; the row still says what happened.\n */\nexport const notificationSchema = z.object({\n id: objectIdSchema,\n kind: notificationKindSchema,\n /** The latest person to do it, live; null for a deleted account. */\n actor: memberBylineSchema.nullable(),\n /**\n * How many EVENTS this row merges, at least 1: three comments by one person\n * are 3. Word it as events (\"3 new comments, latest from Asha\"), never as\n * people (\"Asha and 2 others\"), which this count does not know.\n */\n count: z.number().int().positive(),\n content: z.object({ kind: contentKindSchema, id: objectIdSchema }).optional(),\n commentId: objectIdSchema.optional(),\n product: productChipSchema.optional(),\n reviewId: objectIdSchema.optional(),\n /**\n * For `repost` (0.8.0): the latest repost itself, so the row opens the\n * reposter's words above your post. Gone once that repost is.\n */\n repostId: objectIdSchema.optional(),\n /**\n * The community the row is about, or that its content is in (0.9.0). Absent\n * once that community is deleted, or the recipient may no longer see it.\n */\n community: communityChipSchema.optional(),\n /** For `community_suggestion_decided` (0.9.0): which suggestion, and how it went. */\n suggestion: z\n .object({\n id: objectIdSchema,\n name: z.string(),\n status: communitySuggestionDecisionSchema,\n /** Why it was declined. */\n reason: z.string().optional(),\n })\n .optional(),\n /** For `plan_ending` and `plan_ended` (0.12.0): which tier, and when it ends or ended. */\n plan: z.object({ tier: planTierSchema, endsAt: z.iso.datetime() }).optional(),\n /**\n * For `plan_ended` (0.12.0) and `free_plans_ended` (0.24.0): products paused\n * because the live places went. Nothing is deleted; the owner picks which stay live.\n */\n paused: z.number().int().nonnegative().optional(),\n /** For `payment_refunded` (0.12.0): which purchase, by its title. */\n payment: z.object({ id: objectIdSchema, title: z.string() }).optional(),\n /** For `chat_message`: the conversation, so the row opens that chat. */\n conversationId: objectIdSchema.optional(),\n /** For `product_invite`: the role offered. */\n role: productInvitableRoleSchema.optional(),\n /** For the reaction kinds: the latest reaction, as it is now (0.8.0). */\n reaction: reactionTypeSchema.optional(),\n /**\n * The first words of what was written, for the comment and review kinds\n * (the latest one, on a merged row), cut to `NOTIFICATION_EXCERPT_MAX`. Gone\n * when that comment or review is deleted or hidden, and when its writer's\n * account is.\n */\n excerpt: z.string().max(NOTIFICATION_EXCERPT_MAX).optional(),\n /** Null until opened (or until \"mark all read\"). A merged repeat makes it unread again. */\n readAt: z.iso.datetime().nullable(),\n /** When it last happened: the list's order. */\n lastAt: z.iso.datetime(),\n createdAt: z.iso.datetime(),\n});\nexport type Notification = z.infer<typeof notificationSchema>;\n\nexport const notificationPageSchema = paginatedSchema(notificationSchema);\nexport type NotificationPage = z.infer<typeof notificationPageSchema>;\n\n/**\n * A row by its group key, the caller's own: what a tapped push opens\n * (`PUT /notifications/by-key/:groupKey/read`). One push goes to many members\n * with one link; the key is the same for each of them and names no one.\n */\nexport const notificationKeyParamsSchema = z.object({\n groupKey: z.string().min(1).max(120),\n});\nexport type NotificationKeyParams = z.infer<typeof notificationKeyParamsSchema>;\n\n/** The badge. */\nexport const notificationUnreadCountSchema = z.object({\n unread: z.number().int().nonnegative(),\n});\nexport type NotificationUnreadCount = z.infer<typeof notificationUnreadCountSchema>;\n\nexport const notificationParamsSchema = z.object({ notificationId: objectIdSchema });\nexport type NotificationParams = z.infer<typeof notificationParamsSchema>;\n\n/** Every switch, as stored (on by default). */\nexport const notificationPreferencesSchema = z.object({\n comments: z.boolean(),\n replies: z.boolean(),\n productActivity: z.boolean(),\n recognition: z.boolean(),\n /** Reactions to your posts, polls and comments (0.8.0). */\n reactions: z.boolean(),\n /** Reposts of your posts and polls (0.8.0). */\n reposts: z.boolean(),\n /** Announcements in your communities, and join requests to communities you moderate (0.9.0). */\n communities: z.boolean(),\n /** Someone started following you (2026-11-20). */\n followers: z.boolean(),\n /** Someone you follow shared a new post or poll (2026-11-20). */\n followedPosts: z.boolean(),\n /** Someone @mentioned you (2026-11-23). On for an answer from before the switch. */\n mentions: z.boolean().default(true),\n /** Up votes on your posts, polls and comments (2026-11-23). */\n upvotes: z.boolean(),\n});\nexport type NotificationPreferences = z.infer<typeof notificationPreferencesSchema>;\n\n/** Only the switches that changed; no defaults (a patch states what was sent). */\nexport const updateNotificationPreferencesBodySchema = z.object({\n comments: z.boolean().optional(),\n replies: z.boolean().optional(),\n productActivity: z.boolean().optional(),\n recognition: z.boolean().optional(),\n reactions: z.boolean().optional(),\n reposts: z.boolean().optional(),\n communities: z.boolean().optional(),\n followers: z.boolean().optional(),\n followedPosts: z.boolean().optional(),\n mentions: z.boolean().optional(),\n upvotes: z.boolean().optional(),\n});\nexport type UpdateNotificationPreferencesBody = z.infer<\n typeof updateNotificationPreferencesBodySchema\n>;\n"]}
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/domains/notifications/notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,iCAAiC,GAClC,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,+DAA+D;IAC/D,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC;AAGH,kFAAkF;AAClF,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9D,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACnC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACnC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjC,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACrC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC","sourcesContent":["/**\n * founder-schema — Notifications: the bell\n *\n * The design the user approved on 2026-10-05 (\"Founder Circle Schema Review\"):\n *\n * - ONE ROW PER RECIPIENT, written when the event happens.\n * - REPEATS MERGE: a second comment on your post updates the same row\n * (\"2 new comments, latest from Asha\"), it never adds one. `count` is how\n * many events it holds and `actor` the latest. A member repeating the same\n * act (reacting, taking it back, reacting again) does not ring it again.\n * - THE ACTOR IS LOOKED UP WHEN READ, never copied in: a renamed member shows\n * their new name, and a deleted one shows as null (\"A former member\").\n * - PREFERENCES ARE CHECKED before writing (Jansathi stores them and never\n * reads them). A team invitation is always delivered: it needs an answer.\n * - KEPT `NOTIFICATION_RETENTION_DAYS`, then deleted.\n * - Nobody is notified of their own action.\n *\n * In-app only. Push stays chat's (async-service) until a channel is designed:\n * a client polls the unread count (on focus, and every minute while visible).\n *\n * Routes (all signed in):\n * GET /api/v1/notifications paginationQuerySchema -> notificationPageSchema\n * GET /api/v1/notifications/unread-count -> notificationUnreadCountSchema\n * POST /api/v1/notifications/read mark every one read -> notificationUnreadCountSchema\n * PUT /api/v1/notifications/:notificationId/read -> notificationSchema\n * GET /api/v1/notifications/preferences -> notificationPreferencesSchema\n * PUT /api/v1/notifications/preferences updateNotificationPreferencesBodySchema -> notificationPreferencesSchema\n *\n * @module founder-schema/domains/notifications\n */\n\nimport { z } from 'zod';\nimport { objectIdSchema } from '../../core/common.js';\nimport { NOTIFICATION_EXCERPT_MAX } from '../../core/limits.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport {\n communityChipSchema,\n communitySuggestionDecisionSchema,\n} from '../communities/communities.js';\nimport { contentKindSchema, reactionTypeSchema } from '../feed/feed.js';\nimport { planTierSchema } from '../membership/membership.js';\nimport { productChipSchema, productInvitableRoleSchema } from '../products/products.js';\nimport { memberBylineSchema } from '../profile/founder-profile.js';\n\n/**\n * What happened. ⚠ Stored per row: append only.\n *\n * comment_on_post someone commented on your post or poll\n * reply_to_comment someone replied to your comment\n * product_invite a team invited you (always delivered)\n * product_invite_accepted someone accepted your team's invitation\n * product_review someone reviewed a product you are on the team of\n * review_reply a product's team answered your review\n * feedback_helpful a team marked your feedback as having helped\n * tester_confirmed a team confirmed you tested their product\n * post_reaction someone reacted to your post or poll (0.8.0)\n * comment_reaction someone reacted to your comment (0.8.0)\n * repost someone reposted your post or poll (0.8.0)\n * community_join_request someone asked to join a community you moderate (0.9.0)\n * community_request_approved your request to join was approved (always delivered)\n * community_invite a community invited you (always delivered)\n * community_announcement a community you are in pinned an announcement for everyone\n * community_suggestion_decided your community suggestion was approved or declined (always delivered)\n * plan_ending your plan ends in 7 days, then in 1 day (0.12.0, always delivered)\n * plan_ended your plan ended; `paused` products were paused (0.12.0, always delivered)\n * payment_refunded staff refunded one of your payments (0.12.0, always delivered)\n * chat_message someone messaged you while you were not in that chat (always\n * delivered; the browser's permission is the off switch). One\n * row per conversation: more messages merge into it, and opening\n * the chat marks it read. No message text is stored on it.\n * free_plans_ended payments went live, so the top plan every member held free\n * while they were off ended; `paused` products were paused\n * (0.24.0, always delivered; only to owners it paused any for)\n * new_follower someone started following you (2026-11-20). Rings once while\n * unread; an unfollow takes the unread row back.\n * followed_member_posted someone you follow shared a new post or poll you can read\n * (2026-11-20). One row per post; never its text.\n * mention someone @mentioned you in a post, a poll's question or a\n * comment (2026-11-23). One row per post or poll: mentions in\n * it and in its comments merge. Never for naming yourself.\n * post_upvote someone up voted your post or poll (2026-11-23). Merged per\n * item like a reaction; a NEW up vote only (a down vote, a flip\n * and a clear are silent); in the bell, never a push.\n * comment_upvote someone up voted your comment (2026-11-23), as above.\n *\n * The three 0.8.0 kinds merge per target like the others. A reaction counts\n * once: changing it to another type is not a new event, and taking it back\n * does not take the event back.\n */\nexport const NOTIFICATION_KIND_VALUES = [\n 'comment_on_post',\n 'reply_to_comment',\n 'product_invite',\n 'product_invite_accepted',\n 'product_review',\n 'review_reply',\n 'feedback_helpful',\n 'tester_confirmed',\n 'post_reaction',\n 'comment_reaction',\n 'repost',\n 'community_join_request',\n 'community_request_approved',\n 'community_invite',\n 'community_announcement',\n 'community_suggestion_decided',\n 'plan_ending',\n 'plan_ended',\n 'payment_refunded',\n 'chat_message',\n 'free_plans_ended',\n 'new_follower',\n 'followed_member_posted',\n 'mention',\n 'post_upvote',\n 'comment_upvote',\n // Comments ON a product (2026-11-24): to its owner, and to a comment's writer for a reply.\n 'product_comment',\n 'product_comment_reply',\n] as const;\nexport const notificationKindSchema = z.enum(NOTIFICATION_KIND_VALUES);\nexport type NotificationKind = z.infer<typeof notificationKindSchema>;\n\n/** The switches a member has, each covering one or more kinds. */\nexport const NOTIFICATION_PREFERENCE_VALUES = [\n 'comments',\n 'replies',\n 'productActivity',\n 'recognition',\n 'reactions',\n 'reposts',\n 'communities',\n 'followers',\n 'followedPosts',\n 'mentions',\n 'upvotes',\n] as const;\nexport type NotificationPreference = (typeof NOTIFICATION_PREFERENCE_VALUES)[number];\n\n/**\n * Which switch silences which kind. Null: always delivered. Exhaustive by\n * type, so a kind added without a decision here does not compile.\n */\nexport const NOTIFICATION_PREFERENCE_OF = {\n comment_on_post: 'comments',\n reply_to_comment: 'replies',\n product_invite: null,\n product_invite_accepted: 'productActivity',\n product_review: 'productActivity',\n review_reply: 'productActivity',\n feedback_helpful: 'recognition',\n tester_confirmed: 'recognition',\n post_reaction: 'reactions',\n comment_reaction: 'reactions',\n repost: 'reposts',\n community_join_request: 'communities',\n community_request_approved: null,\n community_invite: null,\n community_announcement: 'communities',\n community_suggestion_decided: null,\n plan_ending: null,\n plan_ended: null,\n payment_refunded: null,\n chat_message: null,\n free_plans_ended: null,\n new_follower: 'followers',\n followed_member_posted: 'followedPosts',\n mention: 'mentions',\n post_upvote: 'upvotes',\n comment_upvote: 'upvotes',\n product_comment: 'comments',\n product_comment_reply: 'replies',\n} as const satisfies Record<NotificationKind, NotificationPreference | null>;\n\n/**\n * One row of the bell. Which of the optional targets are present depends on\n * `kind`:\n *\n * comment_on_post content, commentId\n * reply_to_comment content, commentId (the reply)\n * product_invite product, role\n * product_invite_accepted product\n * product_review product, reviewId\n * review_reply product, reviewId\n * feedback_helpful product, content, commentId\n * tester_confirmed product\n * post_reaction content, reaction\n * comment_reaction content, commentId, reaction, excerpt (your comment)\n * repost content (yours, the one reposted), repostId (the latest repost, to read their words)\n * community_join_request community\n * community_request_approved community\n * community_invite community\n * community_announcement community, content (the pinned post or poll)\n * community_suggestion_decided suggestion, community (once approved)\n * plan_ending plan (the tier, and when it ends)\n * plan_ended plan (the tier that ended), paused (how many products)\n * payment_refunded payment\n * chat_message conversationId (the chat to open)\n * free_plans_ended paused (how many products)\n * new_follower (the actor alone: who followed you)\n * followed_member_posted content (their new post or poll), community (when it is in one)\n * mention content (where), commentId (when it was in a comment), excerpt;\n * or, in a comment ON a product, product + commentId (no content)\n * post_upvote content\n * comment_upvote content, commentId, excerpt (your comment)\n * product_comment product, commentId, excerpt (to the product's owner)\n * product_comment_reply product, commentId (the reply), excerpt\n *\n * Any row about something inside a community also carries `community`\n * (0.9.0), whatever its kind. When the recipient leaves the community, is\n * removed or is banned, its rows about that community lose their content,\n * comment, excerpt and repost: what they could read there, they no longer can.\n *\n * A target that no longer exists (a deleted post, product or review) is\n * absent rather than pointing at a 404; the row still says what happened.\n */\nexport const notificationSchema = z.object({\n id: objectIdSchema,\n kind: notificationKindSchema,\n /** The latest person to do it, live; null for a deleted account. */\n actor: memberBylineSchema.nullable(),\n /**\n * How many EVENTS this row merges, at least 1: three comments by one person\n * are 3. Word it as events (\"3 new comments, latest from Asha\"), never as\n * people (\"Asha and 2 others\"), which this count does not know.\n */\n count: z.number().int().positive(),\n content: z.object({ kind: contentKindSchema, id: objectIdSchema }).optional(),\n commentId: objectIdSchema.optional(),\n product: productChipSchema.optional(),\n reviewId: objectIdSchema.optional(),\n /**\n * For `repost` (0.8.0): the latest repost itself, so the row opens the\n * reposter's words above your post. Gone once that repost is.\n */\n repostId: objectIdSchema.optional(),\n /**\n * The community the row is about, or that its content is in (0.9.0). Absent\n * once that community is deleted, or the recipient may no longer see it.\n */\n community: communityChipSchema.optional(),\n /** For `community_suggestion_decided` (0.9.0): which suggestion, and how it went. */\n suggestion: z\n .object({\n id: objectIdSchema,\n name: z.string(),\n status: communitySuggestionDecisionSchema,\n /** Why it was declined. */\n reason: z.string().optional(),\n })\n .optional(),\n /** For `plan_ending` and `plan_ended` (0.12.0): which tier, and when it ends or ended. */\n plan: z.object({ tier: planTierSchema, endsAt: z.iso.datetime() }).optional(),\n /**\n * For `plan_ended` (0.12.0) and `free_plans_ended` (0.24.0): products paused\n * because the live places went. Nothing is deleted; the owner picks which stay live.\n */\n paused: z.number().int().nonnegative().optional(),\n /** For `payment_refunded` (0.12.0): which purchase, by its title. */\n payment: z.object({ id: objectIdSchema, title: z.string() }).optional(),\n /** For `chat_message`: the conversation, so the row opens that chat. */\n conversationId: objectIdSchema.optional(),\n /** For `product_invite`: the role offered. */\n role: productInvitableRoleSchema.optional(),\n /** For the reaction kinds: the latest reaction, as it is now (0.8.0). */\n reaction: reactionTypeSchema.optional(),\n /**\n * The first words of what was written, for the comment and review kinds\n * (the latest one, on a merged row), cut to `NOTIFICATION_EXCERPT_MAX`. Gone\n * when that comment or review is deleted or hidden, and when its writer's\n * account is.\n */\n excerpt: z.string().max(NOTIFICATION_EXCERPT_MAX).optional(),\n /** Null until opened (or until \"mark all read\"). A merged repeat makes it unread again. */\n readAt: z.iso.datetime().nullable(),\n /** When it last happened: the list's order. */\n lastAt: z.iso.datetime(),\n createdAt: z.iso.datetime(),\n});\nexport type Notification = z.infer<typeof notificationSchema>;\n\nexport const notificationPageSchema = paginatedSchema(notificationSchema);\nexport type NotificationPage = z.infer<typeof notificationPageSchema>;\n\n/**\n * A row by its group key, the caller's own: what a tapped push opens\n * (`PUT /notifications/by-key/:groupKey/read`). One push goes to many members\n * with one link; the key is the same for each of them and names no one.\n */\nexport const notificationKeyParamsSchema = z.object({\n groupKey: z.string().min(1).max(120),\n});\nexport type NotificationKeyParams = z.infer<typeof notificationKeyParamsSchema>;\n\n/** The badge. */\nexport const notificationUnreadCountSchema = z.object({\n unread: z.number().int().nonnegative(),\n});\nexport type NotificationUnreadCount = z.infer<typeof notificationUnreadCountSchema>;\n\nexport const notificationParamsSchema = z.object({ notificationId: objectIdSchema });\nexport type NotificationParams = z.infer<typeof notificationParamsSchema>;\n\n/** Every switch, as stored (on by default). */\nexport const notificationPreferencesSchema = z.object({\n comments: z.boolean(),\n replies: z.boolean(),\n productActivity: z.boolean(),\n recognition: z.boolean(),\n /** Reactions to your posts, polls and comments (0.8.0). */\n reactions: z.boolean(),\n /** Reposts of your posts and polls (0.8.0). */\n reposts: z.boolean(),\n /** Announcements in your communities, and join requests to communities you moderate (0.9.0). */\n communities: z.boolean(),\n /** Someone started following you (2026-11-20). */\n followers: z.boolean(),\n /** Someone you follow shared a new post or poll (2026-11-20). */\n followedPosts: z.boolean(),\n /** Someone @mentioned you (2026-11-23). On for an answer from before the switch. */\n mentions: z.boolean().default(true),\n /** Up votes on your posts, polls and comments (2026-11-23). */\n upvotes: z.boolean(),\n});\nexport type NotificationPreferences = z.infer<typeof notificationPreferencesSchema>;\n\n/** Only the switches that changed; no defaults (a patch states what was sent). */\nexport const updateNotificationPreferencesBodySchema = z.object({\n comments: z.boolean().optional(),\n replies: z.boolean().optional(),\n productActivity: z.boolean().optional(),\n recognition: z.boolean().optional(),\n reactions: z.boolean().optional(),\n reposts: z.boolean().optional(),\n communities: z.boolean().optional(),\n followers: z.boolean().optional(),\n followedPosts: z.boolean().optional(),\n mentions: z.boolean().optional(),\n upvotes: z.boolean().optional(),\n});\nexport type UpdateNotificationPreferencesBody = z.infer<\n typeof updateNotificationPreferencesBodySchema\n>;\n"]}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Comments on a PRODUCT (2026-11-24, the user: the product card's comment
3
+ * button opens a comment drawer like the feed's).
4
+ *
5
+ * Their own collection on the server (`product_comments`), never the feed's
6
+ * comments: a feed comment hangs off a post or poll, and about 25 places read
7
+ * it that way (hary's ruling). The wire shapes follow the feed's so one
8
+ * drawer design serves both: one level of replies, up and down votes, the
9
+ * Top / Newest / Oldest order, a report.
10
+ *
11
+ * Votes only, no reactions (v1, hary's ruling 2026-11-24). Nothing here earns
12
+ * contribution points or moves a product's trending score.
13
+ *
14
+ * Routes (`/api/v1/products`):
15
+ *
16
+ * GET /:productId/comments productCommentsQuerySchema -> productCommentPageSchema
17
+ * POST /:productId/comments createProductCommentBodySchema -> IdResponse
18
+ * PATCH /comments/:commentId updateProductCommentBodySchema -> IdResponse
19
+ * DELETE /comments/:commentId -> IdResponse
20
+ * PUT /comments/:commentId/vote setScoreVoteBodySchema -> productCommentVoteResponseSchema
21
+ * POST /comments/:commentId/report createReportBodySchema -> CreateReportResponse
22
+ *
23
+ * Who may write: a member (a viewer is refused, `MEMBERSHIP_REQUIRED`) on a
24
+ * product they can see that is open (active, not hidden, not paused); an
25
+ * archived product's comments stay readable and take no new ones. Blocked
26
+ * either way with the product's owner: 404, as a post's author.
27
+ *
28
+ * Who may delete: its writer, the product's OWNER (moderating their own page,
29
+ * hary's ruling 2026-11-24: Instagram, YouTube and LinkedIn all allow it; a
30
+ * review stays the signal an owner cannot remove), and staff. Not the rest of
31
+ * the team.
32
+ */
33
+ import { z } from 'zod';
34
+ /** One comment on a product. A non-null `parentCommentId` names a top-level comment, never a reply. */
35
+ export declare const productCommentSchema: z.ZodObject<{
36
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
37
+ productId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
38
+ parentCommentId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
39
+ author: z.ZodObject<{
40
+ userId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
41
+ username: z.ZodNullable<z.ZodString>;
42
+ displayName: z.ZodString;
43
+ firstName: z.ZodString;
44
+ avatarUrl: z.ZodNullable<z.ZodURL>;
45
+ former: z.ZodBoolean;
46
+ headline: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strip>;
48
+ text: z.ZodString;
49
+ mentions: z.ZodDefault<z.ZodArray<z.ZodObject<{
50
+ handle: z.ZodString;
51
+ username: z.ZodString;
52
+ }, z.core.$strip>>>;
53
+ replyCount: z.ZodNumber;
54
+ score: z.ZodNumber;
55
+ byTeam: z.ZodBoolean;
56
+ createdAt: z.ZodISODateTime;
57
+ editedAt: z.ZodNullable<z.ZodISODateTime>;
58
+ viewer: z.ZodObject<{
59
+ canEdit: z.ZodBoolean;
60
+ canDelete: z.ZodBoolean;
61
+ canReport: z.ZodBoolean;
62
+ myVote: z.ZodNullable<z.ZodEnum<{
63
+ up: "up";
64
+ down: "down";
65
+ }>>;
66
+ isAuthor: z.ZodBoolean;
67
+ }, z.core.$strip>;
68
+ }, z.core.$strip>;
69
+ export type ProductComment = z.infer<typeof productCommentSchema>;
70
+ export declare const productCommentPageSchema: z.ZodObject<{
71
+ items: z.ZodArray<z.ZodObject<{
72
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
73
+ productId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
74
+ parentCommentId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
75
+ author: z.ZodObject<{
76
+ userId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
77
+ username: z.ZodNullable<z.ZodString>;
78
+ displayName: z.ZodString;
79
+ firstName: z.ZodString;
80
+ avatarUrl: z.ZodNullable<z.ZodURL>;
81
+ former: z.ZodBoolean;
82
+ headline: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ text: z.ZodString;
85
+ mentions: z.ZodDefault<z.ZodArray<z.ZodObject<{
86
+ handle: z.ZodString;
87
+ username: z.ZodString;
88
+ }, z.core.$strip>>>;
89
+ replyCount: z.ZodNumber;
90
+ score: z.ZodNumber;
91
+ byTeam: z.ZodBoolean;
92
+ createdAt: z.ZodISODateTime;
93
+ editedAt: z.ZodNullable<z.ZodISODateTime>;
94
+ viewer: z.ZodObject<{
95
+ canEdit: z.ZodBoolean;
96
+ canDelete: z.ZodBoolean;
97
+ canReport: z.ZodBoolean;
98
+ myVote: z.ZodNullable<z.ZodEnum<{
99
+ up: "up";
100
+ down: "down";
101
+ }>>;
102
+ isAuthor: z.ZodBoolean;
103
+ }, z.core.$strip>;
104
+ }, z.core.$strip>>;
105
+ nextCursor: z.ZodNullable<z.ZodString>;
106
+ }, z.core.$strip>;
107
+ export type ProductCommentPage = z.infer<typeof productCommentPageSchema>;
108
+ /**
109
+ * As the feed's: `parentCommentId` lists that comment's replies (oldest
110
+ * first), else the top-level comments in `sort` order (`top` by default).
111
+ */
112
+ export declare const productCommentsQuerySchema: z.ZodObject<{
113
+ limit: z.ZodPreprocess<z.ZodDefault<z.ZodCoercedNumber<unknown>>, unknown>;
114
+ cursor: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
115
+ parentCommentId: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>, unknown>;
116
+ sort: z.ZodPreprocess<z.ZodDefault<z.ZodEnum<{
117
+ top: "top";
118
+ newest: "newest";
119
+ oldest: "oldest";
120
+ }>>, unknown>;
121
+ }, z.core.$strip>;
122
+ export type ProductCommentsQuery = z.infer<typeof productCommentsQuerySchema>;
123
+ export type ProductCommentsQueryInput = z.input<typeof productCommentsQuerySchema>;
124
+ export declare const createProductCommentBodySchema: z.ZodObject<{
125
+ text: z.ZodString;
126
+ parentCommentId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
127
+ }, z.core.$strip>;
128
+ export type CreateProductCommentBody = z.infer<typeof createProductCommentBodySchema>;
129
+ /** Your own comment, within the feed's edit window (`EDIT_WINDOW_CLOSED` after). */
130
+ export declare const updateProductCommentBodySchema: z.ZodObject<{
131
+ text: z.ZodString;
132
+ }, z.core.$strip>;
133
+ export type UpdateProductCommentBody = z.infer<typeof updateProductCommentBodySchema>;
134
+ /** The vote as it now stands, so the arrows and the number render without a second read. */
135
+ export declare const productCommentVoteResponseSchema: z.ZodObject<{
136
+ commentId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
137
+ vote: z.ZodNullable<z.ZodEnum<{
138
+ up: "up";
139
+ down: "down";
140
+ }>>;
141
+ score: z.ZodNumber;
142
+ }, z.core.$strip>;
143
+ export type ProductCommentVoteResponse = z.infer<typeof productCommentVoteResponseSchema>;
144
+ //# sourceMappingURL=product-comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-comments.d.ts","sourceRoot":"","sources":["../../../src/domains/products/product-comments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,uGAAuG;AACvG,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsB/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAwC,CAAC;AAC9E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;iBAAsB,CAAC;AAC9D,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEnF,eAAO,MAAM,8BAA8B;;;iBAA0B,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,oFAAoF;AACpF,eAAO,MAAM,8BAA8B;;iBAA0B,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,4FAA4F;AAC5F,eAAO,MAAM,gCAAgC;;;;;;;iBAI3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Comments on a PRODUCT (2026-11-24, the user: the product card's comment
3
+ * button opens a comment drawer like the feed's).
4
+ *
5
+ * Their own collection on the server (`product_comments`), never the feed's
6
+ * comments: a feed comment hangs off a post or poll, and about 25 places read
7
+ * it that way (hary's ruling). The wire shapes follow the feed's so one
8
+ * drawer design serves both: one level of replies, up and down votes, the
9
+ * Top / Newest / Oldest order, a report.
10
+ *
11
+ * Votes only, no reactions (v1, hary's ruling 2026-11-24). Nothing here earns
12
+ * contribution points or moves a product's trending score.
13
+ *
14
+ * Routes (`/api/v1/products`):
15
+ *
16
+ * GET /:productId/comments productCommentsQuerySchema -> productCommentPageSchema
17
+ * POST /:productId/comments createProductCommentBodySchema -> IdResponse
18
+ * PATCH /comments/:commentId updateProductCommentBodySchema -> IdResponse
19
+ * DELETE /comments/:commentId -> IdResponse
20
+ * PUT /comments/:commentId/vote setScoreVoteBodySchema -> productCommentVoteResponseSchema
21
+ * POST /comments/:commentId/report createReportBodySchema -> CreateReportResponse
22
+ *
23
+ * Who may write: a member (a viewer is refused, `MEMBERSHIP_REQUIRED`) on a
24
+ * product they can see that is open (active, not hidden, not paused); an
25
+ * archived product's comments stay readable and take no new ones. Blocked
26
+ * either way with the product's owner: 404, as a post's author.
27
+ *
28
+ * Who may delete: its writer, the product's OWNER (moderating their own page,
29
+ * hary's ruling 2026-11-24: Instagram, YouTube and LinkedIn all allow it; a
30
+ * review stays the signal an owner cannot remove), and staff. Not the rest of
31
+ * the team.
32
+ */
33
+ import { z } from 'zod';
34
+ import { objectIdSchema } from '../../core/common.js';
35
+ import { paginatedSchema } from '../../core/responses.js';
36
+ import { COMMENT_MAX_BODY_CHARS, commentsQuerySchema, createCommentBodySchema, feedAuthorSchema, scoreVoteSchema, updateCommentBodySchema, viewerStateSchema, } from '../feed/feed.js';
37
+ import { mentionsSchema } from '../feed/mentions.js';
38
+ /** One comment on a product. A non-null `parentCommentId` names a top-level comment, never a reply. */
39
+ export const productCommentSchema = z.object({
40
+ id: objectIdSchema,
41
+ productId: objectIdSchema,
42
+ parentCommentId: objectIdSchema.nullable(),
43
+ author: feedAuthorSchema,
44
+ text: z.string().max(COMMENT_MAX_BODY_CHARS),
45
+ mentions: mentionsSchema,
46
+ /** Meaningful only on a top-level comment; always 0 on a reply. */
47
+ replyCount: z.number().int().nonnegative(),
48
+ /** Up votes minus down votes. May be negative. */
49
+ score: z.number().int(),
50
+ /** Written by someone on the product's team: the drawer marks it "Team". */
51
+ byTeam: z.boolean(),
52
+ createdAt: z.iso.datetime(),
53
+ editedAt: z.iso.datetime().nullable(),
54
+ viewer: viewerStateSchema.pick({
55
+ myVote: true,
56
+ isAuthor: true,
57
+ canEdit: true,
58
+ canDelete: true,
59
+ canReport: true,
60
+ }),
61
+ });
62
+ export const productCommentPageSchema = paginatedSchema(productCommentSchema);
63
+ /**
64
+ * As the feed's: `parentCommentId` lists that comment's replies (oldest
65
+ * first), else the top-level comments in `sort` order (`top` by default).
66
+ */
67
+ export const productCommentsQuerySchema = commentsQuerySchema;
68
+ export const createProductCommentBodySchema = createCommentBodySchema;
69
+ /** Your own comment, within the feed's edit window (`EDIT_WINDOW_CLOSED` after). */
70
+ export const updateProductCommentBodySchema = updateCommentBodySchema;
71
+ /** The vote as it now stands, so the arrows and the number render without a second read. */
72
+ export const productCommentVoteResponseSchema = z.object({
73
+ commentId: objectIdSchema,
74
+ vote: scoreVoteSchema.nullable(),
75
+ score: z.number().int(),
76
+ });
77
+ //# sourceMappingURL=product-comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-comments.js","sourceRoot":"","sources":["../../../src/domains/products/product-comments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,iBAAiB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AC,MAAM,CAAC;IACvD,SAAS,EAAE,cAAc;IACzB,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;CACxB,CAAC,CAAC","sourcesContent":["/**\n * Comments on a PRODUCT (2026-11-24, the user: the product card's comment\n * button opens a comment drawer like the feed's).\n *\n * Their own collection on the server (`product_comments`), never the feed's\n * comments: a feed comment hangs off a post or poll, and about 25 places read\n * it that way (hary's ruling). The wire shapes follow the feed's so one\n * drawer design serves both: one level of replies, up and down votes, the\n * Top / Newest / Oldest order, a report.\n *\n * Votes only, no reactions (v1, hary's ruling 2026-11-24). Nothing here earns\n * contribution points or moves a product's trending score.\n *\n * Routes (`/api/v1/products`):\n *\n * GET /:productId/comments productCommentsQuerySchema -> productCommentPageSchema\n * POST /:productId/comments createProductCommentBodySchema -> IdResponse\n * PATCH /comments/:commentId updateProductCommentBodySchema -> IdResponse\n * DELETE /comments/:commentId -> IdResponse\n * PUT /comments/:commentId/vote setScoreVoteBodySchema -> productCommentVoteResponseSchema\n * POST /comments/:commentId/report createReportBodySchema -> CreateReportResponse\n *\n * Who may write: a member (a viewer is refused, `MEMBERSHIP_REQUIRED`) on a\n * product they can see that is open (active, not hidden, not paused); an\n * archived product's comments stay readable and take no new ones. Blocked\n * either way with the product's owner: 404, as a post's author.\n *\n * Who may delete: its writer, the product's OWNER (moderating their own page,\n * hary's ruling 2026-11-24: Instagram, YouTube and LinkedIn all allow it; a\n * review stays the signal an owner cannot remove), and staff. Not the rest of\n * the team.\n */\n\nimport { z } from 'zod';\nimport { objectIdSchema } from '../../core/common.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport {\n COMMENT_MAX_BODY_CHARS,\n commentsQuerySchema,\n createCommentBodySchema,\n feedAuthorSchema,\n scoreVoteSchema,\n updateCommentBodySchema,\n viewerStateSchema,\n} from '../feed/feed.js';\nimport { mentionsSchema } from '../feed/mentions.js';\n\n/** One comment on a product. A non-null `parentCommentId` names a top-level comment, never a reply. */\nexport const productCommentSchema = z.object({\n id: objectIdSchema,\n productId: objectIdSchema,\n parentCommentId: objectIdSchema.nullable(),\n author: feedAuthorSchema,\n text: z.string().max(COMMENT_MAX_BODY_CHARS),\n mentions: mentionsSchema,\n /** Meaningful only on a top-level comment; always 0 on a reply. */\n replyCount: z.number().int().nonnegative(),\n /** Up votes minus down votes. May be negative. */\n score: z.number().int(),\n /** Written by someone on the product's team: the drawer marks it \"Team\". */\n byTeam: z.boolean(),\n createdAt: z.iso.datetime(),\n editedAt: z.iso.datetime().nullable(),\n viewer: viewerStateSchema.pick({\n myVote: true,\n isAuthor: true,\n canEdit: true,\n canDelete: true,\n canReport: true,\n }),\n});\nexport type ProductComment = z.infer<typeof productCommentSchema>;\n\nexport const productCommentPageSchema = paginatedSchema(productCommentSchema);\nexport type ProductCommentPage = z.infer<typeof productCommentPageSchema>;\n\n/**\n * As the feed's: `parentCommentId` lists that comment's replies (oldest\n * first), else the top-level comments in `sort` order (`top` by default).\n */\nexport const productCommentsQuerySchema = commentsQuerySchema;\nexport type ProductCommentsQuery = z.infer<typeof productCommentsQuerySchema>;\nexport type ProductCommentsQueryInput = z.input<typeof productCommentsQuerySchema>;\n\nexport const createProductCommentBodySchema = createCommentBodySchema;\nexport type CreateProductCommentBody = z.infer<typeof createProductCommentBodySchema>;\n\n/** Your own comment, within the feed's edit window (`EDIT_WINDOW_CLOSED` after). */\nexport const updateProductCommentBodySchema = updateCommentBodySchema;\nexport type UpdateProductCommentBody = z.infer<typeof updateProductCommentBodySchema>;\n\n/** The vote as it now stands, so the arrows and the number render without a second read. */\nexport const productCommentVoteResponseSchema = z.object({\n commentId: objectIdSchema,\n vote: scoreVoteSchema.nullable(),\n score: z.number().int(),\n});\nexport type ProductCommentVoteResponse = z.infer<typeof productCommentVoteResponseSchema>;\n"]}