@blogmcp/sdk 0.10.1 → 0.11.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.
Files changed (53) hide show
  1. package/dist/community/channels.d.ts +3 -2
  2. package/dist/community/client.d.ts +129 -2
  3. package/dist/community/client.js +231 -161
  4. package/dist/community/forum.d.ts +82 -0
  5. package/dist/community/forum.js +96 -0
  6. package/dist/community/index.d.ts +14 -7
  7. package/dist/community/index.js +185 -121
  8. package/dist/community/links.d.ts +38 -0
  9. package/dist/community/links.js +98 -71
  10. package/dist/community/messages.cs.d.ts +160 -1
  11. package/dist/community/messages.cs.js +178 -1
  12. package/dist/community/messages.d.ts +19 -1
  13. package/dist/community/messages.en.d.ts +150 -1
  14. package/dist/community/messages.en.js +161 -1
  15. package/dist/community/messages.js +37 -28
  16. package/dist/community/outcome.d.ts +8 -3
  17. package/dist/community/outcome.js +61 -20
  18. package/dist/community/poll.d.ts +28 -4
  19. package/dist/community/poll.js +70 -47
  20. package/dist/community/realtime/index.d.ts +19 -3
  21. package/dist/community/realtime/index.js +175 -145
  22. package/dist/community/routes.d.ts +36 -1
  23. package/dist/community/routes.js +51 -21
  24. package/dist/community/server/bff.d.ts +25 -2
  25. package/dist/community/server/bff.js +135 -118
  26. package/dist/community/server/host-routes.d.ts +3 -0
  27. package/dist/community/server/host-routes.js +17 -0
  28. package/dist/community/server/index.d.ts +5 -1
  29. package/dist/community/shapes.d.ts +634 -7
  30. package/dist/community/shapes.js +92 -61
  31. package/dist/community/store.d.ts +15 -0
  32. package/dist/community/store.js +65 -61
  33. package/dist/community/topic.d.ts +173 -0
  34. package/dist/community/topic.js +225 -0
  35. package/package.json +3 -3
  36. package/src/community/channels.ts +3 -2
  37. package/src/community/client.ts +209 -5
  38. package/src/community/forum.ts +209 -0
  39. package/src/community/index.ts +146 -2
  40. package/src/community/links.ts +64 -4
  41. package/src/community/messages.cs.ts +179 -1
  42. package/src/community/messages.en.ts +162 -1
  43. package/src/community/messages.ts +25 -2
  44. package/src/community/outcome.ts +47 -1
  45. package/src/community/poll.ts +79 -17
  46. package/src/community/realtime/index.ts +124 -48
  47. package/src/community/routes.ts +42 -1
  48. package/src/community/server/bff.ts +89 -30
  49. package/src/community/server/host-routes.ts +20 -0
  50. package/src/community/server/index.ts +5 -1
  51. package/src/community/shapes.ts +662 -6
  52. package/src/community/store.ts +11 -5
  53. package/src/community/topic.ts +521 -0
@@ -4,8 +4,9 @@
4
4
  * before anything used them.
5
5
  *
6
6
  * `disc:<conversationId>` carries a public discussion's projection (`@blogmcp/sdk/community/realtime` subscribes to
7
- * it); `user:` is reserved for the member's own inbox of the private surfaces (ids and codes only, invariant 6) —
8
- * nothing mints a token for it in M2.
7
+ * it) — M3: a forum topic's too, its token minted for an onboarded member or an interactive team session only
8
+ * (m3-contracts.md §3.5). `user:` is reserved for the member's own inbox of the private surfaces (ids and codes only,
9
+ * invariant 6) — nothing mints a token for it in M2.
9
10
  */
10
11
  export declare const COMMUNITY_CHANNELS: Readonly<{
11
12
  readonly discussion: (conversationId: string) => string;
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * The community's public client (docs/internal/m1-contracts.md §10.2): one method per operation of kb-api's public
3
3
  * API and notice form (§7.4, §7.7, §8.3), each a POST of a JSON body through the host — never to kb-api itself.
4
+ * M3 (m3-contracts.md §3.2–§3.4, §5.2): the forum (`forum.*`), the member's follows (`me.follows.*`) and a category
5
+ * moderator's operations (`moderation.*`) — the public router's, through the same host routes.
4
6
  *
5
7
  * const community = createCommunityClient({ base: '/api/community' })
6
8
  * const page = await community.discussions.list({ articleId, languageCode: 'cs' })
@@ -16,7 +18,7 @@
16
18
  */
17
19
  import { type CommunityLogger, type CommunityOutcome } from './outcome.js';
18
20
  import { type CommunityOpName } from './routes.js';
19
- import { type AppealItem, type BlockEntry, type CommunityPage, type CurrentLegalText, type DecisionSummary, type Discussion, type DiscussionHead, type DiscussionListInput, type LegalTextKind, type MemberExport, type MemberSettings, type MemberSettingsUpdate, type MuteEntry, type MuteTargetKind, type NotificationListInput, type PushStatusAnswer, type PushSubscribeAnswer, type PushSubscribeInput, type PushUnsubscribeAnswer, type PushVapidKey, type RealtimeSubscribeToken, type RealtimeToken, type MessageEditInput, type MessagePostInput, type MessageReportInput, type MyState, type NoticeReceipt, type NoticeStatus, type NoticeSubmitInput, type NotificationItem, type OnboardInput, type OwnProfile, type ProfileUpdateInput, type PublicMessage, type PublicProfile, type ReactionSummary, type ReactionTarget, type ReportItem, type Statement, type WriteAnswer } from './shapes.js';
21
+ import { type AppealItem, type BlockEntry, type FollowSetInput, type FollowsPage, type ForumCategory, type ForumSearchInput, type ForumTopicCreateInput, type ForumTopicGetInput, type ForumTopicsListInput, type ForumTopicsPage, type ModerationCase, type ModerationDecideAnswer, type ModerationDecideInput, type ModerationEscalateInput, type ModerationQueueInput, type ModerationQueuePage, type ModerationRemovalAnswer, type ModerationRemoveInput, type ModeratorTopicState, type PremodReviewAnswer, type PremodReviewInput, type ForumSearchPage, type Topic, type TopicCreateAnswer, type TopicHead, type TopicThread, type CommunityPage, type CurrentLegalText, type DecisionSummary, type Discussion, type DiscussionHead, type DiscussionListInput, type LegalTextKind, type MemberExport, type MemberSettings, type MemberSettingsUpdate, type MuteEntry, type MuteTargetKind, type NotificationListInput, type PushStatusAnswer, type PushSubscribeAnswer, type PushSubscribeInput, type PushUnsubscribeAnswer, type PushVapidKey, type RealtimeSubscribeToken, type RealtimeToken, type MessageEditInput, type MessagePostInput, type MessageReportInput, type MyState, type NoticeReceipt, type NoticeStatus, type NoticeSubmitInput, type NotificationItem, type OnboardInput, type OwnProfile, type ProfileUpdateInput, type PublicMessage, type PublicProfile, type ReactionSummary, type ReactionTarget, type ReportItem, type Statement, type WriteAnswer } from './shapes.js';
20
22
  import { type CommunityTransport } from './transport.js';
21
23
  export interface CommunityClientConfig {
22
24
  /**
@@ -53,8 +55,21 @@ export interface CommunityClient {
53
55
  heads: DiscussionHead[];
54
56
  }>;
55
57
  };
58
+ /**
59
+ * M3 (m3-contracts.md §3.1, A11): an operation addressed by a topic's conversation id — `messages.post { conversationId }`,
60
+ * `messages.edit|delete|report`, `reactions.set` of a topic's message — answers every refusal of the forum's gate (the
61
+ * forum switched off, the module dark, a viewer the forum is not open to, a topic the viewer may not see) as the one
62
+ * `notFound` an unknown id gets: re-read the topic (`forum.topics.get`, settleTopicFailure), which answers the
63
+ * surface's own code. An article discussion's `notFound` on `messages.post { articleId }` also covers a
64
+ * discussion-free article (D-M3-17).
65
+ */
56
66
  messages: {
67
+ /** Under an article (`articleId`) or, M3, into a forum topic (`conversationId`): exactly one of them. */
57
68
  post: Call<MessagePostInput, WriteAnswer>;
69
+ /**
70
+ * M3: `title` on a topic's opening post (seq 1) by its author (≤ COMMUNITY_TOPIC_TITLE_MAX UTF-16 units: check with
71
+ * forumTopicTitleOf); the answer then carries the `topic` — apply it (TopicStore.applyTopic).
72
+ */
58
73
  edit: Call<MessageEditInput, WriteAnswer>;
59
74
  /** The member's own message becomes a tombstone (a placeholder only while it has visible replies). */
60
75
  delete: Call<{
@@ -221,6 +236,22 @@ export interface CommunityClient {
221
236
  state: string;
222
237
  }>;
223
238
  };
239
+ /**
240
+ * M3 (m3-contracts.md §3.2–§3.3, §4.3): what the member follows — a topic or an article discussion by its
241
+ * conversation id, or a category. A follow is no content: never braked or refused read-only; FOLLOW_LIMIT
242
+ * (`followLimit`) above COMMUNITY_FOLLOWS_MAX. Build the target with followTargetOf. `set { following: true }` is
243
+ * `notFound` for a target the member may not read now (say „not available"); `set { following: false }` never
244
+ * fails on its target (B16).
245
+ */
246
+ follows: {
247
+ set: Call<FollowSetInput, {
248
+ following: boolean;
249
+ }>;
250
+ /** Newest first; `title` as the member may see it now (null when they cannot). */
251
+ list: CallOptionalInput<{
252
+ cursor?: string | null;
253
+ }, FollowsPage>;
254
+ };
224
255
  /** Every section of the member's data, `providerEntity` on every row: offer it as a JSON download. */
225
256
  export: CallNoInput<MemberExport>;
226
257
  /** The profile's deletion, after the grace period (`purgeAfter`); writes are refused meanwhile. */
@@ -238,12 +269,103 @@ export interface CommunityClient {
238
269
  locale: string;
239
270
  }, CurrentLegalText>;
240
271
  };
241
- /** M2 T5: a channel's token — `disc:<conversationId>` of a discussion the viewer may read, else `notFound`. */
272
+ /**
273
+ * M2 T5: a channel's token — `disc:<conversationId>` of a discussion the viewer may read, else `notFound`. M3: a
274
+ * topic's channel only for an onboarded member who may read the topic (a visitor's host session: `notFound`; the team
275
+ * and an internal key: `signIn` — they poll `forum.topics.head`, §3.5). A change of a topic's header (a title edit,
276
+ * a lock, a move, a pin) arrives as a `resync` publication: re-read the topic.
277
+ */
242
278
  realtime: {
243
279
  subscribeToken: Call<{
244
280
  channel: string;
245
281
  }, RealtimeSubscribeToken>;
246
282
  };
283
+ /**
284
+ * M3 (m3-contracts.md §3.1–§3.3): the forum — read by an onboarded member or an interactive team session only;
285
+ * anyone else is `membersOnly` (with `needs` for a member session short of its onboarding). The forum is
286
+ * switched off (`surfaceOff`) or the module is dark (`unavailable`) before anything else is looked at; a hidden
287
+ * category, a topic of one or an unknown id is `notFound`.
288
+ */
289
+ forum: {
290
+ categories: {
291
+ /** The listed categories, in their order; the team's hidden ones never reach a member. */
292
+ list: CallNoInput<{
293
+ categories: ForumCategory[];
294
+ }>;
295
+ };
296
+ topics: {
297
+ /** A category's topics (by `categoryId` or `categorySlug`): pinned first under `activity`, archived last. */
298
+ list: Call<ForumTopicsListInput, ForumTopicsPage>;
299
+ /** One page of a topic, as `discussions.list` pages a discussion (createTopicStore keeps it). */
300
+ get: Call<ForumTopicGetInput, TopicThread>;
301
+ /** The polling signal of up to COMMUNITY_HEAD_TOPICS_MAX topics (pollTopicHead); ids the viewer may not see are left out. */
302
+ head: Call<{
303
+ conversationIds: readonly string[];
304
+ }, {
305
+ heads: TopicHead[];
306
+ }>;
307
+ /**
308
+ * A new topic: its title and opening post, filtered as one text; `topicCreationClosed` where members open none.
309
+ * The same `clientMsgId` again answers the topic it created. Under pre-moderation (the category's, or away mode)
310
+ * the opening post waits for review: `message.state` is `held` with `premoderated`.
311
+ */
312
+ create: Call<ForumTopicCreateInput, TopicCreateAnswer>;
313
+ };
314
+ /** Titles and visible messages of topics and article discussions (forumSearchQueryOf; pages 1..5, a quota per call). */
315
+ search: Call<ForumSearchInput, ForumSearchPage>;
316
+ };
317
+ /**
318
+ * M3 (m3-contracts.md §3.4, §4.5): a category moderator's operations — a member session with an active appointment
319
+ * (MyState `moderator`). Anyone else, a category the member does not moderate, a case outside the rules line or of
320
+ * the moderator's own message: `notFound`, the same answer for each. Never refused by `read_only` or a brake.
321
+ */
322
+ moderation: {
323
+ /**
324
+ * The cases of category `rules` of the moderator's categories (or of `categoryId`) — open ones, and decided ones a
325
+ * `system` decision still holds (`caseStatus`) — and their pre-moderation items.
326
+ */
327
+ queue: CallOptionalInput<ModerationQueueInput, ModerationQueuePage>;
328
+ /** A case's package, as written: no reporter, no reporter's note, no notifier contact. */
329
+ getCase: Call<{
330
+ caseId: string;
331
+ }, {
332
+ case: ModerationCase;
333
+ }>;
334
+ /**
335
+ * A decision through the engine, with its statement of reasons (it names the provider, and that a category
336
+ * moderator decided on its behalf — never the moderator's handle). `dryRun: true` renders the statement and writes
337
+ * nothing: show it, then decide for real. A restriction needs a contractual ground: without `contractualGround` on a
338
+ * case without a rule id it is `invalid` with `fields: ['contractualGround']` (ask for the rule).
339
+ */
340
+ decide: Call<ModerationDecideInput, ModerationDecideAnswer>;
341
+ /** An own-initiative removal on the rules line (a case and a `removal` decision with its statement). */
342
+ remove: Call<ModerationRemoveInput, ModerationRemovalAnswer>;
343
+ /** An illegal-line matter goes to the team (opens or joins a case); the moderator sees nothing of it afterwards. */
344
+ escalate: Call<ModerationEscalateInput, Record<string, never>>;
345
+ /** Lock or reopen a topic (archiving is the team's). */
346
+ setTopicState: Call<{
347
+ conversationId: string;
348
+ state: ModeratorTopicState;
349
+ }, {
350
+ topic: Topic;
351
+ }>;
352
+ /** Into another category the member moderates; its pre-moderation items follow. */
353
+ moveTopic: Call<{
354
+ conversationId: string;
355
+ categoryId: string;
356
+ }, {
357
+ topic: Topic;
358
+ }>;
359
+ /** Pin or unpin; refused (`submit`, BRAND_RESTRICTED) under a preset without brand reactions. */
360
+ pinTopic: Call<{
361
+ conversationId: string;
362
+ pinned: boolean;
363
+ }, {
364
+ topic: Topic;
365
+ }>;
366
+ /** Publish a message waiting for review (no statement), or refuse it (`ruleId` and `facts`: a removal with one). */
367
+ reviewPremod: Call<PremodReviewInput, PremodReviewAnswer>;
368
+ };
247
369
  notices: {
248
370
  /** Anyone, with or without a session; `confirmations` must hold COMMUNITY_GOOD_FAITH. */
249
371
  submit: Call<NoticeSubmitInput, NoticeReceipt>;
@@ -273,6 +395,11 @@ export type CommunityAnswerField = 'string' | 'number' | 'boolean' | 'array' | '
273
395
  * does), field by field. test/community/ops-drift.spec.ts pins every field to kb-api's declaration of the answer.
274
396
  */
275
397
  export declare const COMMUNITY_ANSWER_FIELDS: Readonly<Record<CommunityOpName, Readonly<Record<string, CommunityAnswerField>>>>;
398
+ /**
399
+ * The operations whose answer is one of several shapes (a union kb-api declares): besides its COMMUNITY_ANSWER_FIELDS,
400
+ * an answer must hold every field of at least one variant (else `unavailable`, as for a missing field).
401
+ */
402
+ export declare const COMMUNITY_ANSWER_VARIANTS: Readonly<Partial<Record<CommunityOpName, readonly Readonly<Record<string, CommunityAnswerField>>[]>>>;
276
403
  /**
277
404
  * The client. Throws a TypeError for a base that is not relative — the one throw, at construction (a page that
278
405
  * passes kb-api's URL has a bug to fix, not an outcome to show).