@blogmcp/sdk 0.10.1 → 0.12.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 (59) hide show
  1. package/dist/community/channels.d.ts +3 -2
  2. package/dist/community/client.d.ts +130 -3
  3. package/dist/community/client.js +232 -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 +164 -3
  11. package/dist/community/messages.cs.js +184 -3
  12. package/dist/community/messages.d.ts +19 -1
  13. package/dist/community/messages.en.d.ts +154 -3
  14. package/dist/community/messages.en.js +167 -3
  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 +649 -7
  30. package/dist/community/shapes.js +92 -61
  31. package/dist/community/store.d.ts +27 -0
  32. package/dist/community/store.js +84 -80
  33. package/dist/community/topic.d.ts +173 -0
  34. package/dist/community/topic.js +225 -0
  35. package/dist/nuxt/composables/useAsyncKb.d.ts +10 -4
  36. package/dist/packages/mdx-render-vue/dist/render/gallery/GalleryLightbox.vue.js +2 -2
  37. package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +36 -36
  38. package/package.json +3 -3
  39. package/src/community/channels.ts +3 -2
  40. package/src/community/client.ts +212 -7
  41. package/src/community/forum.ts +209 -0
  42. package/src/community/index.ts +146 -2
  43. package/src/community/links.ts +64 -4
  44. package/src/community/messages.cs.ts +185 -3
  45. package/src/community/messages.en.ts +168 -3
  46. package/src/community/messages.ts +25 -2
  47. package/src/community/outcome.ts +47 -1
  48. package/src/community/poll.ts +79 -17
  49. package/src/community/realtime/index.ts +124 -48
  50. package/src/community/routes.ts +42 -1
  51. package/src/community/server/bff.ts +89 -30
  52. package/src/community/server/host-routes.ts +20 -0
  53. package/src/community/server/index.ts +5 -1
  54. package/src/community/shapes.ts +677 -6
  55. package/src/community/store.ts +25 -7
  56. package/src/community/topic.ts +521 -0
  57. package/src/core/markdown.ts +1 -1
  58. package/src/nuxt/composables/useAsyncKb.ts +11 -4
  59. package/src/nuxt/nuxt-imports.d.ts +2 -2
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * What the community's operations answer (docs/internal/m1-contracts.md §7.3, §7.4, §7.7, §8.3) — the shapes of
3
- * kb-api's `routes/community-public.ts` and `routes/trust-notices.ts`, as types.
3
+ * kb-api's `routes/community-public.ts` and `routes/trust-notices.ts`, as types. M3 (m3-contracts.md §3.2–§3.5,
4
+ * §5.2): the forum's categories, topics, search, follows and a category moderator's queue and package.
4
5
  *
5
6
  * The enums a newer kb-api may extend are OPEN (community.md §3.7: the client is shaped so later surfaces add on
6
7
  * without breaking it): a message's `state`, an author's `kind`, a `need`, a restriction's `kind` and a
@@ -54,6 +55,10 @@ export const NOTIFICATION_CODES = Object.freeze([
54
55
  'mention',
55
56
  'module_push_reset',
56
57
  'age_limit_changed',
58
+ // M3 F3 (m3-contracts.md §4.3): a new visible message in a followed topic or article discussion; a new topic in a
59
+ // followed category (in-app and the digest, never push). Both switched by `notifyTopic`.
60
+ 'topic_update',
61
+ 'category_topic',
57
62
  ] as const)
58
63
  export type KnownNotificationCode = (typeof NOTIFICATION_CODES)[number]
59
64
  export type NotificationCode = Open<KnownNotificationCode>
@@ -95,6 +100,26 @@ export const isCaseCategory = (value: unknown): value is CaseCategory => has(CAS
95
100
  /** The one category whose notice never carries a notifier's name or e-mail (kb-api: NOTIFIER_NOT_ALLOWED). */
96
101
  export const CATEGORY_WITHOUT_NOTIFIER: CaseCategory = 'child_at_risk'
97
102
 
103
+ /**
104
+ * The categories of the illegal line — every report category but the rules line's four (`rules`, `adverse_event`,
105
+ * `third_party_health_data`, `suspected_minor`: kb-api's `lineOf`, which test/community/codes-drift.spec.ts reads) — in
106
+ * CASE_CATEGORIES' order: what a category moderator escalates to the team (`moderation/escalate`, m3-contracts.md §3.4;
107
+ * D-M3-6 „illegal-line cases escalate only").
108
+ */
109
+ export const ESCALATION_CATEGORIES: readonly CaseCategory[] = Object.freeze(
110
+ CASE_CATEGORIES.filter((c) => c !== 'rules' && c !== 'adverse_event' && c !== 'third_party_health_data' && c !== 'suspected_minor'),
111
+ )
112
+
113
+ /**
114
+ * M3 (m3-contracts.md §3.5, §4.7, D-M3-10): what the team recorded on an adverse-event case — `recorded` (in its
115
+ * register), `reported_to_authority`, `not_adverse` (kb-api's ADVERSE_EVENT_OUTCOMES, pinned by codes-drift). Open: an
116
+ * outcome a newer kb-api adds reads as none (show the case's status alone).
117
+ */
118
+ export const ADVERSE_EVENT_OUTCOMES = Object.freeze(['recorded', 'reported_to_authority', 'not_adverse'] as const)
119
+ export type KnownAdverseEventOutcome = (typeof ADVERSE_EVENT_OUTCOMES)[number]
120
+ export type AdverseEventOutcome = Open<KnownAdverseEventOutcome>
121
+ export const isKnownAdverseEventOutcome = (outcome: unknown): outcome is KnownAdverseEventOutcome => has(ADVERSE_EVENT_OUTCOMES, outcome)
122
+
98
123
  export const AGE_BANDS = Object.freeze(['16_17', '18_plus'] as const)
99
124
  export type AgeBand = (typeof AGE_BANDS)[number]
100
125
 
@@ -112,6 +137,11 @@ export interface MemberAuthor {
112
137
  readonly displayName: string
113
138
  readonly avatarPreset: string | null
114
139
  readonly deleted?: undefined
140
+ /**
141
+ * M3 (m3-contracts.md §3.5, §4.5): `true` on a member's message in a topic of a category the member moderates now —
142
+ * show „Moderátor" (`role.moderator`) beside it there, and nowhere else. Absent otherwise (and from an older kb-api).
143
+ */
144
+ readonly moderator?: true
115
145
  }
116
146
 
117
147
  /** An erased member, a member without a profile, and every placeholder: the author is not told. */
@@ -198,6 +228,12 @@ export interface PublicMessage {
198
228
  * nothing is being reviewed, the author's consent releases it.
199
229
  */
200
230
  readonly hiddenUntilConsent?: boolean
231
+ /**
232
+ * M3 (m3-contracts.md §4.2): `true` on the author's OWN message that waits in a category's pre-moderation queue —
233
+ * its `state` is then `held` („čeká na kontrolu", `state.held`). Nothing was restricted: an approval publishes it
234
+ * without a statement, a rejection is a decision with one. Never on anyone else's row: others see nothing of it.
235
+ */
236
+ readonly premoderated?: boolean
201
237
  /** On a top-level message: its replies, oldest first. */
202
238
  readonly replies: readonly PublicMessage[]
203
239
  /** On a top-level message with more replies than COMMUNITY_REPLIES_MAX. */
@@ -256,6 +292,8 @@ export interface WriteAnswer {
256
292
  readonly message: PublicMessage
257
293
  /** The codes that hit with action `warn` (the message is visible). */
258
294
  readonly warnings: readonly string[]
295
+ /** M3: `messages/edit` with a `title` (a topic's opening post): the topic with its new title. */
296
+ readonly topic?: Topic
259
297
  }
260
298
 
261
299
  /** A reaction's target: the article, or one message. */
@@ -280,6 +318,13 @@ export interface PublicProfile {
280
318
  * (no level is computed then).
281
319
  */
282
320
  readonly trustLabel?: TrustLabel
321
+ /**
322
+ * M3 (m3-contracts.md §3.5, §4.5): the listed categories the member moderates now — appointments that act now (TL3,
323
+ * a preset that admits member moderators); „Moderátor" (`role.moderator`) on the profile names an appointment, never
324
+ * a trust level (D-M3-7). kb-api sends it only to a viewer the forum admits (an onboarded member, the team at the
325
+ * keyboard): absent for anyone else, and from a kb-api older than M3 — so its absence says nothing.
326
+ */
327
+ readonly moderates?: readonly ForumCategoryRef[]
283
328
  }
284
329
 
285
330
  /** The member's own profile (MyState, `me/profile/update`). */
@@ -309,6 +354,49 @@ export interface ModuleInfo {
309
354
  /** The pause in effect, whatever the state (a tenant without the module may pause its discussions). */
310
355
  readonly brake?: { readonly kind: string; readonly until?: string; readonly reasonCode: string }
311
356
  readonly features: { readonly realtime: boolean; readonly push: boolean; readonly notifications: boolean; readonly profiles: boolean }
357
+ /**
358
+ * M3 (m3-contracts.md §3.5, §4.9): each public surface's switch and its own brake (beside the module's `brake`, which
359
+ * stops both). Absent from a kb-api older than M3 — read it through surfaceInfoOf.
360
+ */
361
+ readonly surfaces?: ModuleSurfaces
362
+ /**
363
+ * M3 (§4.8, D-M3-9): the team's away mode („nepřítomen") until when, or null — new topics wait for review meanwhile
364
+ * (`state.away`). Absent from a kb-api older than M3 — read it through communityAwayOf.
365
+ */
366
+ readonly away?: CommunityAway | null
367
+ }
368
+
369
+ /**
370
+ * The brake of one surface (M3 §2.3, §4.9): set by the team (≤ 24 h, `tenant`) or by the automatic brake (`auto`); it
371
+ * always ends (`until`, the database's CHECK). It pauses that surface's member writes only — the other surface works
372
+ * (BRAKED `{ surface }`, brakedSurfaceOf) — while the module's own `brake` pauses both.
373
+ */
374
+ export interface SurfaceBrake {
375
+ /** `tenant` | `auto` (an open set). */
376
+ readonly kind: string
377
+ readonly until: string
378
+ readonly reasonCode: string
379
+ }
380
+
381
+ /** One surface as `me/get` reports it (M3 §3.5): switched on, and its brake in effect (null: none). */
382
+ export interface SurfaceInfo {
383
+ readonly enabled: boolean
384
+ readonly brake: SurfaceBrake | null
385
+ }
386
+
387
+ /** MyState's `module.surfaces` (M3 §3.5): the forum and the article discussions; open groups (M5a) may join. */
388
+ export interface ModuleSurfaces {
389
+ readonly forum: SurfaceInfo
390
+ readonly articleDiscussions: SurfaceInfo
391
+ }
392
+
393
+ /**
394
+ * MyState's `module.away` (M3 §4.8, D-M3-9): the team is away until then (at most 14 days ahead) — new topics wait for
395
+ * review and every flagged message is held meanwhile; me/get carries it for anonymous viewers too. The elements say so
396
+ * in one sentence (`state.away`, read through communityAwayOf).
397
+ */
398
+ export interface CommunityAway {
399
+ readonly until: string
312
400
  }
313
401
 
314
402
  /**
@@ -344,6 +432,14 @@ export interface MyState {
344
432
  readonly profile: OwnProfile | null
345
433
  readonly acceptances: {
346
434
  readonly rules: AcceptanceState
435
+ /**
436
+ * O-16 / F-51 (the owner, 9. 11. 2026: the terms are accepted once, at onboarding, and never asked again): null when
437
+ * the tenant publishes no terms text, `accepted` once the member accepted any terms text (for good — never
438
+ * `reconsent_required`), `never` otherwise. No `need` ever asks for the terms; a first onboarding sends
439
+ * `termsTextId` (viewerNeeds(me).terms). Absent from a kb-api older than O-16 — that kb-api does not take
440
+ * `termsTextId` either (its strict schema refuses the key), so nothing is sent then.
441
+ */
442
+ readonly terms?: AcceptanceState | null
347
443
  readonly art9Consent: AcceptanceState | null
348
444
  /**
349
445
  * M2 T9 (§3.8): the member refused the art. 9 consent under `art9Refusal = public_write` and has not given it
@@ -375,6 +471,17 @@ export interface MyState {
375
471
  * Absent from a kb-api older than T10.
376
472
  */
377
473
  readonly caps?: MemberCaps
474
+ /**
475
+ * M3 (m3-contracts.md §3.5, §4.5, D-M3-6): the categories the member moderates now — active appointments that act
476
+ * (TL3, a preset that admits member moderators); null for everyone else. Absent from a kb-api older than M3. Read
477
+ * it through isCategoryModerator; the moderator's operations re-check it on every call (NOT_FOUND otherwise).
478
+ */
479
+ readonly moderator?: ModeratorInfo | null
480
+ }
481
+
482
+ /** MyState's `moderator` (M3): the categories the member moderates, by id. */
483
+ export interface ModeratorInfo {
484
+ readonly categoryIds: readonly string[]
378
485
  }
379
486
 
380
487
  /** MyState's `caps` (M2 T10). */
@@ -383,8 +490,10 @@ export interface MemberCaps {
383
490
  }
384
491
 
385
492
  /**
386
- * The member's notification switches (m2-contracts.md §3.3): replies, mentions, topic updates (off by default),
387
- * push (the master switch), the daily e-mail digest, the night's quiet hours for push (22–7, the site's time).
493
+ * The member's notification switches (m2-contracts.md §3.3): replies, mentions, topic updates, push (the master
494
+ * switch), the daily e-mail digest, the night's quiet hours for push (22–7, the site's time). M3 (m3-contracts.md §4.3,
495
+ * D-M3-4): `notifyTopic` switches `topic_update` and `category_topic`, and is on for a member who never set it (a
496
+ * follow is the opt-in); a switch the member saved keeps its value.
388
497
  */
389
498
  export interface MemberSettings {
390
499
  readonly notifyReply: boolean
@@ -488,6 +597,9 @@ export interface NotificationListInput {
488
597
  readonly codes?: readonly string[]
489
598
  }
490
599
 
600
+ /** M3 FX (R20): what a notification row's conversation is (an open enum: a newer kb-api may name another kind). */
601
+ export type NotificationConversationKind = 'topic' | 'article' | (string & {})
602
+
491
603
  export interface NotificationItem {
492
604
  readonly id: string
493
605
  readonly code: NotificationCode
@@ -497,10 +609,20 @@ export interface NotificationItem {
497
609
  /**
498
610
  * M2 T10: the article of the conversation a `reply` or `mention` row is about, else null (absent from a kb-api
499
611
  * older than T10). With `articleSlug` and `seq`, a page links the message on the article (communityMessageLink).
612
+ * M3 F3: also a `topic_update` of a followed article discussion and a `category_topic` of the „Články" category (a
613
+ * discussion new to its listing); a topic's row names no article — its link is `conversationId` (topicPath). Null too
614
+ * while the article is not readable at the viewer's level.
500
615
  */
501
616
  readonly articleId?: string | null
502
617
  /** M2 T10: that article's slug (never its title), else null; absent from a kb-api older than T10. */
503
618
  readonly articleSlug?: string | null
619
+ /**
620
+ * M3 FX (the review of wave 1, R20): the kind of the row's conversation — `topic` (link a `reply`, `mention` or
621
+ * `topic_update` with topicMessageLink, a `category_topic` with topicPath) or `article` (its article's page while
622
+ * `articleId` names it; one no longer readable is still an article's row, never a topic's) —, null for a row of no
623
+ * public conversation (a decision, a notice of the module). Absent from a kb-api older than M3's FX.
624
+ */
625
+ readonly conversationKind?: NotificationConversationKind | null
504
626
  readonly caseId: string | null
505
627
  readonly decisionId: string | null
506
628
  readonly createdAt: string
@@ -571,7 +693,14 @@ export interface ReportItem {
571
693
  readonly category: string
572
694
  readonly status: string
573
695
  readonly reportedAt: string
696
+ /** The last decision's time; M3: a case closed by an adverse-event outcome alone takes the outcome's (§3.5). */
574
697
  readonly decidedAt: string | null
698
+ /**
699
+ * M3 (m3-contracts.md §3.5, §4.7): an adverse-event case's outcome once the team recorded one (ADVERSE_EVENT_OUTCOMES,
700
+ * an open set), else null — the member reporter learns the result here, as M1 tells it a decision (adverseOutcome.<…>).
701
+ * Absent from a kb-api older than M3.
702
+ */
703
+ readonly outcome?: AdverseEventOutcome | null
575
704
  }
576
705
 
577
706
  /** `legal/current`: the tenant's current text of a kind. */
@@ -702,9 +831,18 @@ export interface NoticeStatus {
702
831
  readonly status: 'open' | 'decided' | 'appealed' | 'closed' | (string & {})
703
832
  readonly category: CaseCategory
704
833
  readonly submittedAt: string
834
+ /** The last decision's time; M3: a case closed by an adverse-event outcome alone takes the outcome's (§3.5). */
705
835
  readonly decidedAt: string | null
706
836
  /** The statement once decided (plain text), never the package. */
707
837
  readonly statement: string | null
838
+ /**
839
+ * M3 (m3-contracts.md §3.5, §4.7): an adverse-event case's outcome once the team recorded one (ADVERSE_EVENT_OUTCOMES,
840
+ * an open set), else null. A case closed by its outcome alone has no decision: `status` `closed`, `decidedAt` the
841
+ * outcome's time, `statement` null and `appeal.canAppeal` false — the page states the outcome in plain words
842
+ * (adverseOutcome.<…>) with the redress line (`notice.redress`), as the e-mail `notice_closed` does. Absent from a
843
+ * kb-api older than M3.
844
+ */
845
+ readonly outcome?: AdverseEventOutcome | null
708
846
  readonly appeal: {
709
847
  readonly canAppeal: boolean
710
848
  readonly closesAt: string | null
@@ -722,10 +860,10 @@ export interface DiscussionListInput {
722
860
  cursor?: number | null
723
861
  }
724
862
 
725
- export interface MessagePostInput {
726
- articleId: string
863
+ /** What every post carries, wherever it goes. */
864
+ export interface MessagePostFields {
727
865
  body: string
728
- /** A reply names a top-level message of the same discussion. */
866
+ /** A reply names a top-level message of the same discussion or topic. */
729
867
  replyToSeq?: number | null
730
868
  /** newClientMsgId(), the same on a retry. */
731
869
  clientMsgId: string
@@ -735,10 +873,33 @@ export interface MessagePostInput {
735
873
  confirmations?: string[]
736
874
  }
737
875
 
876
+ /** A post under an article: its discussion, by the article (created with the first message). */
877
+ export interface ArticleMessagePostInput extends MessagePostFields {
878
+ articleId: string
879
+ conversationId?: never
880
+ }
881
+
882
+ /**
883
+ * M3 (m3-contracts.md §3.3): a post into a forum topic, by the topic's conversation id. An article discussion is still
884
+ * posted to by `articleId` (Appendix B, choice 3) — kb-api refuses a `conversationId` that names one.
885
+ */
886
+ export interface TopicMessagePostInput extends MessagePostFields {
887
+ conversationId: string
888
+ articleId?: never
889
+ }
890
+
891
+ /** `messages/post`: exactly one of `articleId` and `conversationId`. */
892
+ export type MessagePostInput = ArticleMessagePostInput | TopicMessagePostInput
893
+
738
894
  export interface MessageEditInput {
739
895
  conversationId: string
740
896
  seq: number
741
897
  body: string
898
+ /**
899
+ * M3 (§3.3): a topic's new title (≤ COMMUNITY_TOPIC_TITLE_MAX) — only on its opening post (`seq` 1) by its author,
900
+ * else VALIDATION on `title`. The title and the body are filtered as one text.
901
+ */
902
+ title?: string
742
903
  confirmations?: string[]
743
904
  }
744
905
 
@@ -756,6 +917,13 @@ export interface OnboardInput {
756
917
  ageBand: AgeBand
757
918
  /** The current `rules` text's id (`legal/current`). */
758
919
  rulesTextId: string
920
+ /**
921
+ * O-16 / F-51: the current `terms` text's id (`legal/current { kind: 'terms' }`) — required on a member's first
922
+ * onboarding while the tenant has a terms text (MyState.acceptances.terms `never`): the key absent, null or another
923
+ * id is VALIDATION on `termsTextId` then. Recorded once and never asked again. Send it only to a kb-api whose me/get
924
+ * answers `acceptances.terms` (viewerNeeds(me).terms): an older one refuses the key.
925
+ */
926
+ termsTextId?: string | null
759
927
  /** The current `art9_consent` text's id, when the tenant asks for the consent. */
760
928
  art9TextId?: string | null
761
929
  /**
@@ -792,3 +960,506 @@ export interface NoticeSubmitInput {
792
960
  /** Must contain COMMUNITY_GOOD_FAITH. */
793
961
  confirmations?: string[]
794
962
  }
963
+
964
+ // ───────────────────────── the forum (M3, m3-contracts.md §1.1, §3.2–§3.5, §5.2) ─────────────────────────
965
+
966
+ /** A category's kind: members or the team open topics in it, or it lists the article discussions (D-M3-13 „Články"). */
967
+ export const FORUM_CATEGORY_KINDS = Object.freeze(['topics', 'article_discussions'] as const)
968
+ export type KnownForumCategoryKind = (typeof FORUM_CATEGORY_KINDS)[number]
969
+ export type ForumCategoryKind = Open<KnownForumCategoryKind>
970
+ export const isKnownForumCategoryKind = (kind: unknown): kind is KnownForumCategoryKind => has(FORUM_CATEGORY_KINDS, kind)
971
+
972
+ /**
973
+ * A category's mode (§4.1): `post` M1's pipeline, `hold_flagged` a flagged text is held, `pre` every post waits for
974
+ * review. The category's own mode — away mode raises it for every write meanwhile (MyState `module.away`).
975
+ */
976
+ export const FORUM_CATEGORY_MODES = Object.freeze(['post', 'hold_flagged', 'pre'] as const)
977
+ export type KnownForumCategoryMode = (typeof FORUM_CATEGORY_MODES)[number]
978
+ export type ForumCategoryMode = Open<KnownForumCategoryMode>
979
+ export const isKnownForumCategoryMode = (mode: unknown): mode is KnownForumCategoryMode => has(FORUM_CATEGORY_MODES, mode)
980
+
981
+ /** Who opens topics in a category: its members, or only the team (TOPIC_CREATION_CLOSED for a member). */
982
+ export const TOPIC_CREATIONS = Object.freeze(['members', 'team'] as const)
983
+ export type KnownTopicCreation = (typeof TOPIC_CREATIONS)[number]
984
+ export type TopicCreation = Open<KnownTopicCreation>
985
+
986
+ /**
987
+ * A topic's state (§1.1): `open`; `locked` — no new message (reading, reactions on what is there and reports go on);
988
+ * `archived` — locked and out of the default list. An unknown state reads as locked: offer no composer.
989
+ */
990
+ export const TOPIC_STATES = Object.freeze(['open', 'locked', 'archived'] as const)
991
+ export type KnownTopicState = (typeof TOPIC_STATES)[number]
992
+ export type TopicState = Open<KnownTopicState>
993
+ export const isKnownTopicState = (state: unknown): state is KnownTopicState => has(TOPIC_STATES, state)
994
+
995
+ /** What one row of a category's list is: a topic, or (in the „Články" category) an article's discussion. */
996
+ export const TOPIC_ITEM_KINDS = Object.freeze(['topic', 'article'] as const)
997
+ export type KnownTopicItemKind = (typeof TOPIC_ITEM_KINDS)[number]
998
+ export type TopicItemKind = Open<KnownTopicItemKind>
999
+
1000
+ /**
1001
+ * How `forum/topics/list` orders a category (closed: kb-api validates it): by the latest activity (pinned topics
1002
+ * first) or the newest first. There is no sort by reactions, votes or score in v1, for any tenant (§4.6).
1003
+ */
1004
+ export const FORUM_SORTS = Object.freeze(['activity', 'new'] as const)
1005
+ export type ForumSort = (typeof FORUM_SORTS)[number]
1006
+
1007
+ /** Where a message lives: a forum topic or an article's discussion (`forum/search`, `me/follows/list`). */
1008
+ export const FORUM_SPACES = Object.freeze(['forum', 'article'] as const)
1009
+ export type KnownForumSpace = (typeof FORUM_SPACES)[number]
1010
+ export type ForumSpace = Open<KnownForumSpace>
1011
+
1012
+ /** A search hit: a topic's title, or a message. */
1013
+ export const SEARCH_RESULT_KINDS = Object.freeze(['topic', 'message'] as const)
1014
+ export type KnownSearchResultKind = (typeof SEARCH_RESULT_KINDS)[number]
1015
+ export type SearchResultKind = Open<KnownSearchResultKind>
1016
+
1017
+ /** What a member follows: a conversation (a topic or an article discussion) or a category. */
1018
+ export const FOLLOW_TARGET_KINDS = Object.freeze(['conversation', 'category'] as const)
1019
+ export type KnownFollowTargetKind = (typeof FOLLOW_TARGET_KINDS)[number]
1020
+ export type FollowTargetKind = Open<KnownFollowTargetKind>
1021
+
1022
+ /**
1023
+ * The surface a BRAKED refusal names (M3 §1.2, §4.9): its own brake stopped the write — the other surface works.
1024
+ * Absent from the refusal: the module's brake, which stops both. Open: open groups (M5a) will be a third.
1025
+ */
1026
+ export const BRAKE_SURFACES = Object.freeze(['forum', 'article_discussions'] as const)
1027
+ export type KnownBrakeSurface = (typeof BRAKE_SURFACES)[number]
1028
+ export type BrakeSurface = Open<KnownBrakeSurface>
1029
+ export const isKnownBrakeSurface = (surface: unknown): surface is KnownBrakeSurface => has(BRAKE_SURFACES, surface)
1030
+
1031
+ /** A moderator's queue row: an open case, or a message waiting in pre-moderation. */
1032
+ export const MODERATION_ITEM_KINDS = Object.freeze(['case', 'premod'] as const)
1033
+ export type KnownModerationItemKind = (typeof MODERATION_ITEM_KINDS)[number]
1034
+ export type ModerationItemKind = Open<KnownModerationItemKind>
1035
+
1036
+ /**
1037
+ * A queued case's status (§3.4): `open`, or `decided` — a case a `system` decision already decided that still holds
1038
+ * its message (a filter hold is decided at birth; the moderator restores or removes it). Open: a status a newer kb-api
1039
+ * adds reads as `open`.
1040
+ */
1041
+ export const MODERATION_CASE_STATUSES = Object.freeze(['open', 'decided'] as const)
1042
+ export type KnownModerationCaseStatus = (typeof MODERATION_CASE_STATUSES)[number]
1043
+ export type ModerationCaseStatus = Open<KnownModerationCaseStatus>
1044
+
1045
+ /** Where a moderator's case came from (§3.4): a member's report, the filters or the provider's own initiative. */
1046
+ export const MODERATION_SOURCES = Object.freeze(['member_report', 'filter', 'staff'] as const)
1047
+ export type KnownModerationSource = (typeof MODERATION_SOURCES)[number]
1048
+ export type ModerationSource = Open<KnownModerationSource>
1049
+
1050
+ /** What a category moderator may decide (§4.5; closed: anything else is UNSUPPORTED_RESTRICTION). */
1051
+ export const MODERATION_RESTRICTIONS = Object.freeze(['no_action', 'visibility_restricted', 'removal'] as const)
1052
+ export type ModerationRestriction = (typeof MODERATION_RESTRICTIONS)[number]
1053
+
1054
+ /** A moderator's decision's basis: a notice (a report) or the provider's own initiative. */
1055
+ export const MODERATION_BASES = Object.freeze(['notice', 'own_initiative'] as const)
1056
+ export type ModerationBasis = (typeof MODERATION_BASES)[number]
1057
+
1058
+ /** The states a moderator sets (archiving is the team's). */
1059
+ export const MODERATOR_TOPIC_STATES = Object.freeze(['open', 'locked'] as const)
1060
+ export type ModeratorTopicState = (typeof MODERATOR_TOPIC_STATES)[number]
1061
+
1062
+ /** A pre-moderation review: publish (no statement), or refuse (a removal with its statement). */
1063
+ export const PREMOD_OUTCOMES = Object.freeze(['approve', 'reject'] as const)
1064
+ export type PremodOutcome = (typeof PREMOD_OUTCOMES)[number]
1065
+
1066
+ /** A category as a topic, a profile or a follow names it. */
1067
+ export interface ForumCategoryRef {
1068
+ readonly slug: string
1069
+ readonly name: string
1070
+ }
1071
+
1072
+ /** `forum/categories/list`: one listed category (the team's hidden ones never reach a member). */
1073
+ export interface ForumCategory extends ForumCategoryRef {
1074
+ readonly id: string
1075
+ /** Plain text: render it as text. */
1076
+ readonly description: string | null
1077
+ readonly kind: ForumCategoryKind
1078
+ readonly topicCreation: TopicCreation
1079
+ /**
1080
+ * The category's own mode (§4.1) — null for the article discussions' category („Články"), which has none (§2.1: M1's
1081
+ * pipeline with the preset's rules). Never away mode's raise: MyState `module.away` says that.
1082
+ */
1083
+ readonly mode: ForumCategoryMode | null
1084
+ readonly position: number
1085
+ /** The topics (in „Články": the article discussions) another member sees listed (§3.1's rule). */
1086
+ readonly topicCount: number
1087
+ readonly lastActivityAt: string | null
1088
+ /** The viewer follows the category (its new topics notify them). */
1089
+ readonly following: boolean
1090
+ /**
1091
+ * The category's moderators — the appointments that act now (TL3, a preset that admits member moderators; none under
1092
+ * the regulated preset, and none until category moderators exist): as members' messages name them.
1093
+ */
1094
+ readonly moderators: readonly Author[]
1095
+ }
1096
+
1097
+ /** A topic's row in its category's list (a topic is listed to a viewer exactly when `forum/topics/get` answers it). */
1098
+ export interface ForumTopicItem {
1099
+ readonly kind: 'topic'
1100
+ readonly conversationId: string
1101
+ /**
1102
+ * null when the viewer may not see it (§3.1's placeholder rule: the opening post is held, removed or held back, and a
1103
+ * reply keeps the topic readable) and once the opening post is deleted — topicTitleOf tells the two apart by
1104
+ * `openingState`: „Smazané téma" (`topic.deleted`) for `deleted` only, the withheld wording (`topic.withheld`)
1105
+ * otherwise. `author` is then the placeholder author.
1106
+ */
1107
+ readonly title: string | null
1108
+ readonly author: Author
1109
+ readonly state: TopicState
1110
+ readonly pinned: boolean
1111
+ /** The messages everyone is shown. */
1112
+ readonly count: number
1113
+ readonly createdAt: string
1114
+ readonly lastActivityAt: string
1115
+ readonly following: boolean
1116
+ /**
1117
+ * The opening post's state as the viewer sees it, whenever it is not `visible`: on the viewer's own topic `held` (also
1118
+ * while it waits for review: „čeká na kontrolu"); on another member's topic the placeholder's state — `held`,
1119
+ * `removed` or `deleted`. Absent when visible.
1120
+ */
1121
+ readonly openingState?: MessageState
1122
+ }
1123
+
1124
+ /** An article's discussion in the „Články" category's list (articles the viewer may read). */
1125
+ export interface ForumArticleItem {
1126
+ readonly kind: 'article'
1127
+ readonly conversationId: string
1128
+ readonly articleId: string
1129
+ /**
1130
+ * M3 FX (the review of wave 1, R20): what the row's link needs — the article's slug (its filename without `.md`/`.mdx`),
1131
+ * as `ForumSearchResult.articleSlug`: the host's `articlePath` filled with it (communityArticleLink).
1132
+ */
1133
+ readonly articleSlug: string
1134
+ readonly articleTitle: string | null
1135
+ readonly count: number
1136
+ readonly lastActivityAt: string
1137
+ readonly following: boolean
1138
+ }
1139
+
1140
+ /** A row of a kind a newer kb-api added: skip it. */
1141
+ export interface UnknownTopicItem {
1142
+ readonly kind: string & {}
1143
+ }
1144
+
1145
+ export type KnownTopicItem = ForumTopicItem | ForumArticleItem
1146
+ export type TopicItem = KnownTopicItem | UnknownTopicItem
1147
+
1148
+ /** `forum/topics/list`: one keyset page of a category (the cursor is opaque). */
1149
+ export interface ForumTopicsPage {
1150
+ readonly category: { readonly id: string; readonly slug: string; readonly name: string; readonly kind: ForumCategoryKind }
1151
+ readonly items: readonly TopicItem[]
1152
+ readonly nextCursor: string | null
1153
+ }
1154
+
1155
+ /** A topic's header (`forum/topics/get`, a new topic, a title edit, a moderator's change). */
1156
+ export interface Topic {
1157
+ readonly conversationId: string
1158
+ readonly category: { readonly id: string; readonly slug: string; readonly name: string }
1159
+ /**
1160
+ * null when §3.1's placeholder rule withholds it from the viewer (the opening post held, removed or held back; a
1161
+ * reply keeps the topic readable) and once the opening post is deleted — topicTitleOf tells the two apart by the
1162
+ * opening post's state. A re-read (a resync) may bring a withheld title back.
1163
+ */
1164
+ readonly title: string | null
1165
+ readonly state: TopicState
1166
+ readonly pinned: boolean
1167
+ readonly createdAt: string
1168
+ readonly author: Author
1169
+ readonly following: boolean
1170
+ }
1171
+
1172
+ /** The viewer of a topic: the discussion's viewer, and whether they moderate its category. */
1173
+ export interface TopicViewerState extends DiscussionViewerState {
1174
+ readonly moderator: boolean
1175
+ }
1176
+
1177
+ /**
1178
+ * `forum/topics/get`: one page of a topic — the messages, cursor, counters, reactions and preset exactly as
1179
+ * `discussions/list` answers them (the opening post is seq 1), with the topic's header in place of the article.
1180
+ */
1181
+ export interface TopicThread {
1182
+ readonly topic: Topic
1183
+ /** Top-level, oldest first, COMMUNITY_PAGE_SIZE a page. */
1184
+ readonly messages: readonly PublicMessage[]
1185
+ readonly nextCursor: number | null
1186
+ readonly count: number
1187
+ readonly lastSeq: number
1188
+ readonly lastChangeAt: string | null
1189
+ readonly reactionSet: readonly string[]
1190
+ readonly preset: string | null
1191
+ readonly viewer: TopicViewerState
1192
+ }
1193
+
1194
+ /** `forum/topics/head`: the polling signal of one topic (an id the viewer may not see is left out). */
1195
+ export interface TopicHead {
1196
+ readonly conversationId: string
1197
+ readonly count: number
1198
+ readonly lastSeq: number
1199
+ readonly lastChangeAt: string | null
1200
+ }
1201
+
1202
+ /**
1203
+ * One `forum/search` hit (§4.4): plain text only — render the title and the snippet as text. Not `SearchResult`: the
1204
+ * SDK's root entry exports the article search's type of that name (A34).
1205
+ */
1206
+ export interface ForumSearchResult {
1207
+ readonly kind: SearchResultKind
1208
+ readonly space: ForumSpace
1209
+ readonly conversationId: string
1210
+ /** The message's seq (a `message` hit), else null. */
1211
+ readonly seq: number | null
1212
+ /**
1213
+ * The topic's title (or the article's) as the viewer may see it — null for a `message` hit in a topic whose title
1214
+ * §3.1's rule withholds from the viewer, or whose opening post was deleted: `openingState` tells the two apart, as on
1215
+ * a category's row — read a forum hit's title through topicTitleOf (`topic.deleted` „Smazané téma" for a deleted
1216
+ * opening post, `topic.withheld` otherwise).
1217
+ */
1218
+ readonly title: string | null
1219
+ /**
1220
+ * M3 FX2 (m3-contracts.md §5.3; the review of wave 2, S12): `deleted` on a `message` hit of a topic whose opening post
1221
+ * was deleted (its title went with it). Absent otherwise — and from a kb-api older than M3 FX2, whose deleted opening
1222
+ * post then reads as withheld.
1223
+ */
1224
+ readonly openingState?: MessageState
1225
+ /** A topic's category; null for an article discussion's hit. */
1226
+ readonly categoryId: string | null
1227
+ /** An article discussion's article; null for a topic's hit. */
1228
+ readonly articleId: string | null
1229
+ /**
1230
+ * M3 F3 (the wave 2 integration): what an article discussion's hit needs for its link — the article's slug (its
1231
+ * filename without `.md`/`.mdx`, as the notification centre names it): `communityMessageLink(articlePath, articleSlug,
1232
+ * seq)`. Null for a topic's hit (link it by `conversationId`: topicPath, topicMessageLink).
1233
+ */
1234
+ readonly articleSlug: string | null
1235
+ /** At most 200 characters around the first hit, no markup. */
1236
+ readonly snippet: string | null
1237
+ readonly createdAt: string
1238
+ }
1239
+
1240
+ /** `forum/search`: one page of at most COMMUNITY_SEARCH_PAGE_SIZE hits; pages 1..COMMUNITY_SEARCH_PAGES_MAX only. */
1241
+ export interface ForumSearchPage {
1242
+ readonly results: readonly ForumSearchResult[]
1243
+ readonly page: number
1244
+ /** false on the last page (always on page COMMUNITY_SEARCH_PAGES_MAX). */
1245
+ readonly hasMore: boolean
1246
+ }
1247
+
1248
+ /** What `me/follows/set` names: a conversation (a topic or an article discussion with one) or a category. */
1249
+ export type FollowTarget = { readonly conversationId: string } | { readonly categoryId: string }
1250
+
1251
+ /** `me/follows/list`: one of the member's follows. */
1252
+ export interface Follow {
1253
+ readonly targetKind: FollowTargetKind
1254
+ readonly targetId: string
1255
+ /** `forum` | `article` for a conversation, null for a category. */
1256
+ readonly space: ForumSpace | null
1257
+ /** The topic's title, the category's name or the article's title as the member may see it now, else null. */
1258
+ readonly title: string | null
1259
+ /**
1260
+ * M3 F3 (the wave 2 integration): what a link needs while the member may read the target — a category's slug
1261
+ * (categoryPath), an article's slug (its filename without `.md`/`.mdx`: the host's articlePath); null for a topic (link
1262
+ * it by `targetId`: topicPath) and whenever `title` is null.
1263
+ */
1264
+ readonly slug: string | null
1265
+ readonly createdAt: string
1266
+ }
1267
+
1268
+ /** `me/follows/list`: a keyset page. */
1269
+ export interface FollowsPage {
1270
+ readonly follows: readonly Follow[]
1271
+ readonly nextCursor: string | null
1272
+ }
1273
+
1274
+ /**
1275
+ * A row of a category moderator's queue (§3.4): a case of category `rules` in the moderator's categories — open, or
1276
+ * decided while a `system` decision still holds its message — or a message waiting in pre-moderation (reasons
1277
+ * `category_pre`, `away`; a `health_third_party` item never reaches a moderator).
1278
+ */
1279
+ export interface ModerationItem {
1280
+ readonly kind: ModerationItemKind
1281
+ /** The case (a `case` row), else null. */
1282
+ readonly caseId: string | null
1283
+ /** The case's status (a `case` row: `open`, or `decided` while the system's hold stands), else null. */
1284
+ readonly caseStatus: ModerationCaseStatus | null
1285
+ readonly conversationId: string
1286
+ readonly seq: number
1287
+ readonly categoryId: string
1288
+ /** The case's category (a `case` row), else null. */
1289
+ readonly caseCategory: string | null
1290
+ readonly ruleId: string | null
1291
+ readonly source: ModerationSource | null
1292
+ readonly createdAt: string
1293
+ readonly deadlineAt: string | null
1294
+ /**
1295
+ * M3 FX (m3-contracts.md §3.4; the review of wave 1, R3): a `premod` row's message rev — `moderation.reviewPremod` takes
1296
+ * it back and decides that text only (an edit since answers `submit`: re-read the queue, show the new text, ask again);
1297
+ * null on a `case` row.
1298
+ */
1299
+ readonly rev: number | null
1300
+ /** M3 FX (R3): a `premod` row's text as written (render it as text); null on a `case` row (its package is `getCase`'s). */
1301
+ readonly body: string | null
1302
+ /** M3 FX (R3): a `premod` row of an opening post — its topic's title (render it as text). */
1303
+ readonly title?: string | null
1304
+ }
1305
+
1306
+ /** `moderation/queue`: a keyset page. */
1307
+ export interface ModerationQueuePage {
1308
+ readonly items: readonly ModerationItem[]
1309
+ readonly nextCursor: string | null
1310
+ }
1311
+
1312
+ /**
1313
+ * One item of a case's package, as written (render it as text); never who reported it. The case's subject is whole
1314
+ * (its text, title and handle null only once it was deleted); another message of the package only while everyone may
1315
+ * see it now and its author has not edited it since the package was written (M3 FX2, S4) — otherwise its `body`,
1316
+ * `title` and `authorHandle` are null (say so: `moderation.itemWithheld`; an opening post's title through
1317
+ * topicTitleOf: `topic.deleted` for a deleted opening post, `topic.withheld` otherwise).
1318
+ */
1319
+ export interface ModerationCaseItem {
1320
+ readonly itemNo: number
1321
+ /** On an opening post's item: the topic's title — null when withheld, or cleared with a deleted opening post (`openingState`). */
1322
+ readonly title?: string | null
1323
+ /**
1324
+ * M3 FX2 (S12): `deleted` on an opening post's item whose opening post was deleted — its title went with it. Absent
1325
+ * otherwise (and from a kb-api older than M3 FX2).
1326
+ */
1327
+ readonly openingState?: MessageState
1328
+ /** null when withheld (a message of the package other than the subject that others cannot see now). */
1329
+ readonly body: string | null
1330
+ readonly authorHandle: string | null
1331
+ /** When the message was written, as the package recorded it; null when the package holds no time. */
1332
+ readonly createdAt: string | null
1333
+ }
1334
+
1335
+ /** `moderation/cases/get`: the package; no reporter, no reporter's note, no notifier contact, no earlier deciders. */
1336
+ export interface ModerationCase {
1337
+ readonly id: string
1338
+ readonly caseCategory: string
1339
+ readonly ruleId: string | null
1340
+ readonly source: ModerationSource
1341
+ readonly status: string
1342
+ readonly createdAt: string
1343
+ readonly deadlineAt: string | null
1344
+ readonly subject: { readonly conversationId: string; readonly seq: number }
1345
+ readonly items: readonly ModerationCaseItem[]
1346
+ }
1347
+
1348
+ /** `moderation/decide`: the statement (a dry run writes nothing) and, when decided, the decision. */
1349
+ export interface ModerationDecideAnswer {
1350
+ readonly dryRun: boolean
1351
+ /** The statement of reasons as kb-api renders it (plain text). */
1352
+ readonly statement: string
1353
+ readonly decision?: { readonly id: string; readonly restriction: ModerationRestriction | (string & {}) }
1354
+ }
1355
+
1356
+ /** `moderation/remove` and a rejected pre-moderated message: the removal and its statement. */
1357
+ export interface ModerationRemovalAnswer {
1358
+ readonly decision: { readonly id: string }
1359
+ readonly statement: string
1360
+ }
1361
+
1362
+ /** `moderation/premod/review`: the published message (approve), or the removal with its statement (reject). */
1363
+ export type PremodReviewAnswer = { readonly message: PublicMessage } | ModerationRemovalAnswer
1364
+
1365
+ /** `forum/topics/create`: the topic, its opening post as its author sees it, the filters' warnings. */
1366
+ export interface TopicCreateAnswer {
1367
+ readonly topic: Topic
1368
+ readonly message: PublicMessage
1369
+ readonly warnings: readonly string[]
1370
+ }
1371
+
1372
+ // ───────────────────────── the forum's inputs ─────────────────────────
1373
+
1374
+ /** `forum/topics/list`: a category by its id or its slug; `cursor` is the previous page's `nextCursor`. */
1375
+ export type ForumTopicsListInput = ({ categoryId: string; categorySlug?: never } | { categorySlug: string; categoryId?: never }) & {
1376
+ sort?: ForumSort
1377
+ cursor?: string | null
1378
+ /** 1..COMMUNITY_TOPICS_PAGE_MAX (default COMMUNITY_TOPICS_PAGE_SIZE). */
1379
+ limit?: number
1380
+ }
1381
+
1382
+ export interface ForumTopicGetInput {
1383
+ conversationId: string
1384
+ /** The page's language: a translation of each message into it when one exists. */
1385
+ languageCode?: string | null
1386
+ /** The previous page's `nextCursor`; absent for the first page. */
1387
+ cursor?: number | null
1388
+ }
1389
+
1390
+ export interface ForumTopicCreateInput {
1391
+ categoryId: string
1392
+ /** ≤ COMMUNITY_TOPIC_TITLE_MAX characters. */
1393
+ title: string
1394
+ body: string
1395
+ /** newClientMsgId(), the same on a retry (a repeat answers the topic it created). */
1396
+ clientMsgId: string
1397
+ languageCode: string
1398
+ confirmations?: string[]
1399
+ }
1400
+
1401
+ export interface ForumSearchInput {
1402
+ /** COMMUNITY_SEARCH_QUERY_MIN..COMMUNITY_SEARCH_QUERY_MAX characters (forumSearchQueryOf). */
1403
+ query: string
1404
+ categoryId?: string | null
1405
+ space?: KnownForumSpace | null
1406
+ /** 1..COMMUNITY_SEARCH_PAGES_MAX. */
1407
+ page?: number
1408
+ }
1409
+
1410
+ /**
1411
+ * `me/follows/set` (§3.3, B16): `following: true` needs a target the member may read now — anything else (a topic the
1412
+ * member may not see, a hidden or deleted category, an internal or discussion-free article) is the one `notFound`, so
1413
+ * the button says „not available"; then the `community_profile` quota and `followLimit` above COMMUNITY_FOLLOWS_MAX.
1414
+ * `following: false` never fails on the target (an unknown one answers `{ following: false }`): an unfollow needs no
1415
+ * error path of its own.
1416
+ */
1417
+ export interface FollowSetInput {
1418
+ target: FollowTarget
1419
+ following: boolean
1420
+ }
1421
+
1422
+ export interface ModerationQueueInput {
1423
+ categoryId?: string | null
1424
+ cursor?: string | null
1425
+ }
1426
+
1427
+ export interface ModerationDecideInput {
1428
+ caseId: string
1429
+ restriction: ModerationRestriction
1430
+ basis: ModerationBasis
1431
+ /** The facts and circumstances, as the statement will state them. */
1432
+ facts: string
1433
+ /**
1434
+ * A rule id of the tenant's current rules text the restriction rests on (§3.4, A09); absent, the case's own rule id.
1435
+ * A restriction on a case without one and without this is `invalid` with `fields: ['contractualGround']`: ask the
1436
+ * moderator for the rule. `automatedDetection` is kb-api's, from the case — never an input.
1437
+ */
1438
+ contractualGround?: string | null
1439
+ locale?: string | null
1440
+ /** true: render the statement and write nothing (the preview the moderator confirms). */
1441
+ dryRun?: boolean
1442
+ }
1443
+
1444
+ export interface ModerationRemoveInput {
1445
+ conversationId: string
1446
+ seq: number
1447
+ ruleId: string
1448
+ facts: string
1449
+ locale?: string | null
1450
+ }
1451
+
1452
+ export interface ModerationEscalateInput {
1453
+ conversationId: string
1454
+ seq: number
1455
+ /** One of the illegal line's case categories (never `rules`). */
1456
+ category: CaseCategory
1457
+ }
1458
+
1459
+ /**
1460
+ * `moderation/premod/review`: approve, or reject on a rule with the facts; `locale` — the statement's language (reject).
1461
+ * M3 FX (R3): `rev` — the queue row's (`ModerationItem.rev`): the review decides the text the moderator read.
1462
+ */
1463
+ export type PremodReviewInput =
1464
+ | { conversationId: string; seq: number; rev: number; outcome: 'approve'; ruleId?: never; facts?: never; locale?: string | null }
1465
+ | { conversationId: string; seq: number; rev: number; outcome: 'reject'; ruleId: string; facts: string; locale?: string | null }