@blogmcp/sdk 0.8.1 → 0.9.1
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.
- package/dist/community/channels.d.ts +12 -0
- package/dist/community/channels.js +7 -0
- package/dist/community/client.d.ts +211 -0
- package/dist/community/client.js +188 -0
- package/dist/community/index.d.ts +34 -0
- package/dist/community/index.js +93 -0
- package/dist/community/links.d.ts +73 -0
- package/dist/community/links.js +85 -0
- package/dist/community/messages.cs.d.ts +331 -0
- package/dist/community/messages.cs.js +342 -0
- package/dist/community/messages.d.ts +40 -0
- package/dist/community/messages.en.d.ts +315 -0
- package/dist/community/messages.en.js +313 -0
- package/dist/community/messages.js +66 -0
- package/dist/community/outcome.d.ts +96 -0
- package/dist/community/outcome.js +211 -0
- package/dist/community/poll.d.ts +35 -0
- package/dist/community/poll.js +70 -0
- package/dist/community/routes.d.ts +110 -0
- package/dist/community/routes.js +66 -0
- package/dist/community/server/bff.d.ts +123 -0
- package/dist/community/server/bff.js +214 -0
- package/dist/community/server/env.d.ts +20 -0
- package/dist/community/server/env.js +16 -0
- package/dist/community/server/host-routes.d.ts +15 -0
- package/dist/community/server/host-routes.js +35 -0
- package/dist/community/server/http.d.ts +64 -0
- package/dist/community/server/http.js +90 -0
- package/dist/community/server/index.d.ts +45 -0
- package/dist/community/server/index.js +19 -0
- package/dist/community/server/route-decision.d.ts +70 -0
- package/dist/community/server/route-decision.js +89 -0
- package/dist/community/server/unknown-path.d.ts +21 -0
- package/dist/community/server/unknown-path.js +11 -0
- package/dist/community/shapes.d.ts +472 -0
- package/dist/community/shapes.js +63 -0
- package/dist/community/store.d.ts +183 -0
- package/dist/community/store.js +423 -0
- package/dist/community/transport.d.ts +42 -0
- package/dist/community/transport.js +59 -0
- package/dist/core/client.d.ts +17 -0
- package/dist/core/client.js +58 -55
- package/dist/core/comments-legacy.d.ts +19 -0
- package/dist/core/comments-legacy.js +18 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +107 -101
- package/dist/core/queries.d.ts +46 -0
- package/dist/core/queries.js +128 -84
- package/dist/core/seo.js +40 -39
- package/dist/core/translations/cs.json.js +6 -6
- package/dist/core/translations/en.json.js +1 -1
- package/dist/core/types.d.ts +23 -1
- package/dist/core/view-model.d.ts +7 -0
- package/dist/core/view-model.js +29 -25
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
- package/dist/react/KbMdxContent.js +4 -3
- package/dist/vue/components/KbMdxContent.vue2.js +3 -2
- package/dist/vue/composables/useKbComments.d.ts +8 -0
- package/package.json +13 -4
- package/src/community/channels.ts +12 -0
- package/src/community/client.ts +437 -0
- package/src/community/index.ts +192 -0
- package/src/community/links.ts +174 -0
- package/src/community/messages.cs.ts +371 -0
- package/src/community/messages.en.ts +341 -0
- package/src/community/messages.ts +112 -0
- package/src/community/outcome.ts +317 -0
- package/src/community/poll.ts +154 -0
- package/src/community/routes.ts +139 -0
- package/src/community/server/bff.ts +530 -0
- package/src/community/server/env.ts +42 -0
- package/src/community/server/host-routes.ts +48 -0
- package/src/community/server/http.ts +175 -0
- package/src/community/server/index.ts +55 -0
- package/src/community/server/route-decision.ts +226 -0
- package/src/community/server/unknown-path.ts +32 -0
- package/src/community/shapes.ts +541 -0
- package/src/community/store.ts +786 -0
- package/src/community/transport.ts +111 -0
- package/src/core/client.ts +24 -1
- package/src/core/comments-legacy.ts +39 -0
- package/src/core/index.ts +8 -0
- package/src/core/queries.ts +93 -0
- package/src/core/seo.ts +5 -1
- package/src/core/translations/cs.json +3 -1
- package/src/core/translations/en.json +3 -1
- package/src/core/types.ts +19 -1
- package/src/core/view-model.ts +12 -1
- package/src/vue/composables/useKbComments.ts +8 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
4
|
+
*
|
|
5
|
+
* The enums a newer kb-api may extend are OPEN (community.md §3.7: the client is shaped so later surfaces add on
|
|
6
|
+
* without breaking it): a message's `state`, an author's `kind`, a `need`, a restriction's `kind` and a
|
|
7
|
+
* notification's `code` are `KnownX | (string & {})`. A page renders only what it knows and skips the rest — the
|
|
8
|
+
* `isKnownX` guards below say which is which, and the discussion store (store.ts) drops a message whose author
|
|
9
|
+
* kind or state it does not know, and a need it does not know, without throwing.
|
|
10
|
+
*
|
|
11
|
+
* Types and pure guards only: nothing here does I/O.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A string that is none of the known values (a newer kb-api's): keeps the known ones' autocompletion. */
|
|
15
|
+
type Open<Known extends string> = Known | (string & {})
|
|
16
|
+
|
|
17
|
+
const has = (list: readonly string[], value: unknown): boolean => typeof value === 'string' && list.includes(value)
|
|
18
|
+
|
|
19
|
+
// ───────────────────────── the open enums ─────────────────────────
|
|
20
|
+
|
|
21
|
+
/** A message's state: held and removed ones their author sees with the state; others get a placeholder or nothing. */
|
|
22
|
+
export const MESSAGE_STATES = Object.freeze(['visible', 'held', 'removed', 'deleted'] as const)
|
|
23
|
+
export type KnownMessageState = (typeof MESSAGE_STATES)[number]
|
|
24
|
+
export type MessageState = Open<KnownMessageState>
|
|
25
|
+
export const isKnownState = (state: unknown): state is KnownMessageState => has(MESSAGE_STATES, state)
|
|
26
|
+
|
|
27
|
+
export const AUTHOR_KINDS = Object.freeze(['member', 'staff', 'system'] as const)
|
|
28
|
+
export type KnownAuthorKind = (typeof AUTHOR_KINDS)[number]
|
|
29
|
+
export type AuthorKind = Open<KnownAuthorKind>
|
|
30
|
+
export const isKnownAuthorKind = (kind: unknown): kind is KnownAuthorKind => has(AUTHOR_KINDS, kind)
|
|
31
|
+
|
|
32
|
+
/** What a viewer still needs before writing (kb-api computes it on every read and write). */
|
|
33
|
+
export const NEEDS = Object.freeze(['sign_in', 'onboarding', 'reconsent_rules', 'art9_consent'] as const)
|
|
34
|
+
export type KnownNeed = (typeof NEEDS)[number]
|
|
35
|
+
export type Need = Open<KnownNeed>
|
|
36
|
+
export const isKnownNeed = (need: unknown): need is KnownNeed => has(NEEDS, need)
|
|
37
|
+
|
|
38
|
+
export const RESTRICTION_KINDS = Object.freeze(['restriction', 'suspension', 'ban'] as const)
|
|
39
|
+
export type KnownRestrictionKind = (typeof RESTRICTION_KINDS)[number]
|
|
40
|
+
export type RestrictionKind = Open<KnownRestrictionKind>
|
|
41
|
+
export const isKnownRestrictionKind = (kind: unknown): kind is KnownRestrictionKind => has(RESTRICTION_KINDS, kind)
|
|
42
|
+
|
|
43
|
+
/** In-app notifications: codes and ids only (`appeal_resolved` is a decision that supersedes another). */
|
|
44
|
+
export const NOTIFICATION_CODES = Object.freeze(['decision', 'appeal_resolved', 'erasure_scheduled', 'inactivity_warning'] as const)
|
|
45
|
+
export type KnownNotificationCode = (typeof NOTIFICATION_CODES)[number]
|
|
46
|
+
export type NotificationCode = Open<KnownNotificationCode>
|
|
47
|
+
export const isKnownNotificationCode = (code: unknown): code is KnownNotificationCode => has(NOTIFICATION_CODES, code)
|
|
48
|
+
|
|
49
|
+
// ───────────────────────── closed vocabularies (kb-api validates them) ─────────────────────────
|
|
50
|
+
|
|
51
|
+
/** The report and notice categories (kb-api's CASE_CATEGORIES; test/community/codes-drift.spec.ts pins them). */
|
|
52
|
+
export const CASE_CATEGORIES = Object.freeze([
|
|
53
|
+
'fraud_spam',
|
|
54
|
+
'harassment',
|
|
55
|
+
'hate',
|
|
56
|
+
'threats',
|
|
57
|
+
'sexual_content',
|
|
58
|
+
'child_at_risk',
|
|
59
|
+
'self_harm',
|
|
60
|
+
'doxxing',
|
|
61
|
+
'copyright',
|
|
62
|
+
'terrorism',
|
|
63
|
+
'drugs',
|
|
64
|
+
'other_illegal',
|
|
65
|
+
'rules',
|
|
66
|
+
'adverse_event',
|
|
67
|
+
'third_party_health_data',
|
|
68
|
+
'suspected_minor',
|
|
69
|
+
] as const)
|
|
70
|
+
export type CaseCategory = (typeof CASE_CATEGORIES)[number]
|
|
71
|
+
export const isCaseCategory = (value: unknown): value is CaseCategory => has(CASE_CATEGORIES, value)
|
|
72
|
+
|
|
73
|
+
/** The one category whose notice never carries a notifier's name or e-mail (kb-api: NOTIFIER_NOT_ALLOWED). */
|
|
74
|
+
export const CATEGORY_WITHOUT_NOTIFIER: CaseCategory = 'child_at_risk'
|
|
75
|
+
|
|
76
|
+
export const AGE_BANDS = Object.freeze(['16_17', '18_plus'] as const)
|
|
77
|
+
export type AgeBand = (typeof AGE_BANDS)[number]
|
|
78
|
+
|
|
79
|
+
export const LEGAL_TEXT_KINDS = Object.freeze(['rules', 'terms', 'privacy', 'art9_consent'] as const)
|
|
80
|
+
export type LegalTextKind = (typeof LEGAL_TEXT_KINDS)[number]
|
|
81
|
+
|
|
82
|
+
export type AcceptanceState = 'accepted' | 'reconsent_required' | 'never'
|
|
83
|
+
|
|
84
|
+
// ───────────────────────── a discussion (§7.3) ─────────────────────────
|
|
85
|
+
|
|
86
|
+
export interface MemberAuthor {
|
|
87
|
+
readonly kind: 'member'
|
|
88
|
+
readonly memberId: string
|
|
89
|
+
readonly handle: string
|
|
90
|
+
readonly displayName: string
|
|
91
|
+
readonly avatarPreset: string | null
|
|
92
|
+
readonly deleted?: undefined
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** An erased member, a member without a profile, and every placeholder: the author is not told. */
|
|
96
|
+
export interface DeletedMemberAuthor {
|
|
97
|
+
readonly kind: 'member'
|
|
98
|
+
readonly memberId: null
|
|
99
|
+
readonly handle: null
|
|
100
|
+
readonly displayName: null
|
|
101
|
+
readonly avatarPreset: null
|
|
102
|
+
readonly deleted: true
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface StaffAuthor {
|
|
106
|
+
readonly kind: 'staff'
|
|
107
|
+
readonly staffId: string
|
|
108
|
+
readonly displayName: string
|
|
109
|
+
/** The badge identity's label code (`team` by default). */
|
|
110
|
+
readonly badge: string
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface SystemAuthor {
|
|
114
|
+
readonly kind: 'system'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type KnownAuthor = MemberAuthor | DeletedMemberAuthor | StaffAuthor | SystemAuthor
|
|
118
|
+
|
|
119
|
+
/** An author kind a newer kb-api added: skip what it wrote. */
|
|
120
|
+
export interface UnknownAuthor {
|
|
121
|
+
readonly kind: string & {}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type Author = KnownAuthor | UnknownAuthor
|
|
125
|
+
|
|
126
|
+
/** An author of a kind this SDK renders (a plain object whose `kind` is known). */
|
|
127
|
+
export function isKnownAuthor(author: unknown): author is KnownAuthor {
|
|
128
|
+
return typeof author === 'object' && author !== null && isKnownAuthorKind((author as { kind?: unknown }).kind)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ReactionSummary {
|
|
132
|
+
/** Emoji → count; in public spaces counts only, never who. */
|
|
133
|
+
readonly counts: Readonly<Record<string, number>>
|
|
134
|
+
/** The viewer's own reaction, or null. */
|
|
135
|
+
readonly mine: string | null
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* One message as the viewer may see it. Another member's held, removed, held-back or tombstoned message reaches the
|
|
140
|
+
* viewer as a placeholder kb-api has already scrubbed (m1-contracts.md §7.14 P-RV11): `rev` 0 (it never moves while
|
|
141
|
+
* the hidden message is edited or moderated), `body`/`displayBody`/`displayLanguageCode`/`sourceLanguageCode` null,
|
|
142
|
+
* `isEdited`/`isTranslated` false, `editedAt`/`translationVersionId` null, no reactions and the author's place only —
|
|
143
|
+
* its place in the thread, its state and when it was written, nothing else. Their author reads their own such
|
|
144
|
+
* message whole, with its state.
|
|
145
|
+
*/
|
|
146
|
+
export interface PublicMessage {
|
|
147
|
+
readonly conversationId: string
|
|
148
|
+
readonly seq: number
|
|
149
|
+
readonly id: string
|
|
150
|
+
/** 0 on a placeholder: it never moves while the hidden message changes. */
|
|
151
|
+
readonly rev: number
|
|
152
|
+
readonly replyToSeq: number | null
|
|
153
|
+
readonly author: Author
|
|
154
|
+
readonly state: MessageState
|
|
155
|
+
/** null on a placeholder and on a tombstone. */
|
|
156
|
+
readonly body: string | null
|
|
157
|
+
/** The viewer's language when a translation of the current text exists, else `body`. */
|
|
158
|
+
readonly displayBody: string | null
|
|
159
|
+
readonly displayLanguageCode: string | null
|
|
160
|
+
readonly sourceLanguageCode: string | null
|
|
161
|
+
readonly isTranslated: boolean
|
|
162
|
+
readonly isEdited: boolean
|
|
163
|
+
readonly createdAt: string
|
|
164
|
+
readonly editedAt: string | null
|
|
165
|
+
/** The viewer blocked the author (public-context blocks). */
|
|
166
|
+
readonly collapsed: boolean
|
|
167
|
+
readonly reactions: ReactionSummary
|
|
168
|
+
readonly translationVersionId: string | null
|
|
169
|
+
/** The filters' notes for the author (`identification_safety`, `report_to_manufacturer`): post and edit answers only. */
|
|
170
|
+
readonly notes?: readonly string[]
|
|
171
|
+
/**
|
|
172
|
+
* `true` on the author's OWN message that the tenant's art. 9 policy (`require_art9_consent` with
|
|
173
|
+
* `art9_legacy_posts = 'hide_until_consent'`) keeps from everyone else until the author gives the art. 9
|
|
174
|
+
* consent; its `state` is then `held` (m1-contracts.md §7.14 P-RV3). Absent otherwise — never on another
|
|
175
|
+
* member's placeholder: nobody else learns a member's consent. Render it apart from a message awaiting review:
|
|
176
|
+
* nothing is being reviewed, the author's consent releases it.
|
|
177
|
+
*/
|
|
178
|
+
readonly hiddenUntilConsent?: boolean
|
|
179
|
+
/** On a top-level message: its replies, oldest first. */
|
|
180
|
+
readonly replies: readonly PublicMessage[]
|
|
181
|
+
/** On a top-level message with more replies than COMMUNITY_REPLIES_MAX. */
|
|
182
|
+
readonly repliesTruncated?: boolean
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface RestrictionInEffect {
|
|
186
|
+
readonly kind: RestrictionKind
|
|
187
|
+
readonly scope: string
|
|
188
|
+
readonly endsAt: string | null
|
|
189
|
+
/** The decision that imposed it: its statement explains it (statementPath). */
|
|
190
|
+
readonly decisionId: string
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface DiscussionViewerState {
|
|
194
|
+
readonly memberId: string | null
|
|
195
|
+
/** kb-api's verdict: the composer may post now. */
|
|
196
|
+
readonly canPost: boolean
|
|
197
|
+
readonly needs: readonly Need[]
|
|
198
|
+
readonly restrictions: readonly RestrictionInEffect[]
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** `discussions/list`: one page of an article's discussion. */
|
|
202
|
+
export interface Discussion {
|
|
203
|
+
readonly articleId: string
|
|
204
|
+
/** null until the first message is posted. */
|
|
205
|
+
readonly conversationId: string | null
|
|
206
|
+
/** The messages everyone is shown. */
|
|
207
|
+
readonly count: number
|
|
208
|
+
/** The conversation's counter (every message, any state). */
|
|
209
|
+
readonly lastSeq: number
|
|
210
|
+
/** The newest change of a message or a reaction. */
|
|
211
|
+
readonly lastChangeAt: string | null
|
|
212
|
+
/** Top-level, oldest first, COMMUNITY_PAGE_SIZE a page. */
|
|
213
|
+
readonly messages: readonly PublicMessage[]
|
|
214
|
+
/** The next page's cursor (the last top-level `seq`), or null on the last page. */
|
|
215
|
+
readonly nextCursor: number | null
|
|
216
|
+
readonly articleReactions: ReactionSummary
|
|
217
|
+
/** The emoji a member may react with (the tenant's `reaction_set`). */
|
|
218
|
+
readonly reactionSet: readonly string[]
|
|
219
|
+
/** The tenant's preset id, or null. */
|
|
220
|
+
readonly preset: string | null
|
|
221
|
+
readonly viewer: DiscussionViewerState
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** `discussions/head`: the polling signal of one article. */
|
|
225
|
+
export interface DiscussionHead {
|
|
226
|
+
readonly articleId: string
|
|
227
|
+
readonly count: number
|
|
228
|
+
readonly lastSeq: number
|
|
229
|
+
readonly lastChangeAt: string | null
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** `messages/post`, `messages/edit`: the message as its author sees it. */
|
|
233
|
+
export interface WriteAnswer {
|
|
234
|
+
readonly message: PublicMessage
|
|
235
|
+
/** The codes that hit with action `warn` (the message is visible). */
|
|
236
|
+
readonly warnings: readonly string[]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** A reaction's target: the article, or one message. */
|
|
240
|
+
export type ReactionTarget = { readonly articleId: string } | { readonly conversationId: string; readonly seq: number }
|
|
241
|
+
|
|
242
|
+
export interface BlockEntry {
|
|
243
|
+
readonly memberId: string
|
|
244
|
+
readonly author: Author
|
|
245
|
+
readonly blockedAt: string
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** `profile/get`: the public projection. */
|
|
249
|
+
export interface PublicProfile {
|
|
250
|
+
readonly author: Author
|
|
251
|
+
/** `YYYY-MM` (UTC). */
|
|
252
|
+
readonly memberSince: string
|
|
253
|
+
readonly bio: string | null
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** The member's own profile (MyState, `me/profile/update`). */
|
|
257
|
+
export interface OwnProfile {
|
|
258
|
+
readonly handle: string
|
|
259
|
+
readonly displayName: string
|
|
260
|
+
readonly avatarPreset: string | null
|
|
261
|
+
readonly bio: string | null
|
|
262
|
+
readonly handleChangedAt: string | null
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ───────────────────────── the member's own surface (§7.3, §7.4, §8.3) ─────────────────────────
|
|
266
|
+
|
|
267
|
+
/** `me/get` and `me/onboard`. Anonymous: `member: null`, `needs: ['sign_in']`. */
|
|
268
|
+
export interface MyState {
|
|
269
|
+
readonly member: { readonly memberId: string; readonly status: string; readonly identity: string; readonly ageBand: AgeBand | null } | null
|
|
270
|
+
readonly profile: OwnProfile | null
|
|
271
|
+
readonly acceptances: { readonly rules: AcceptanceState; readonly art9Consent: AcceptanceState | null }
|
|
272
|
+
readonly needs: readonly Need[]
|
|
273
|
+
readonly restrictions: readonly RestrictionInEffect[]
|
|
274
|
+
readonly unreadDecisions: number
|
|
275
|
+
readonly preset: string | null
|
|
276
|
+
/** The tenant's own deep links (community.settings), when it set them. */
|
|
277
|
+
readonly links: { readonly statementPath: string | null; readonly myCommunityPath: string | null }
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface NotificationItem {
|
|
281
|
+
readonly id: string
|
|
282
|
+
readonly code: NotificationCode
|
|
283
|
+
readonly conversationId: string | null
|
|
284
|
+
readonly seq: number | null
|
|
285
|
+
readonly caseId: string | null
|
|
286
|
+
readonly decisionId: string | null
|
|
287
|
+
readonly createdAt: string
|
|
288
|
+
readonly readAt: string | null
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** A keyset page, newest first: `cursor` is the last item's id. */
|
|
292
|
+
export interface CommunityPage<T> {
|
|
293
|
+
readonly items: readonly T[]
|
|
294
|
+
readonly nextCursor: string | null
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface DecisionSummary {
|
|
298
|
+
readonly decisionId: string
|
|
299
|
+
readonly caseId: string
|
|
300
|
+
readonly provider: 'tenant' | 'platform' | (string & {})
|
|
301
|
+
/** Who decided: the controller named in the statement (art. 17(3)). */
|
|
302
|
+
readonly providerEntity: string
|
|
303
|
+
readonly restriction: string
|
|
304
|
+
readonly restrictionUntil: string | null
|
|
305
|
+
readonly basis: string
|
|
306
|
+
readonly category: string
|
|
307
|
+
readonly decidedAt: string
|
|
308
|
+
readonly supersedes: string | null
|
|
309
|
+
readonly appealWindowClosesAt: string
|
|
310
|
+
readonly canAppeal: boolean
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** What a statement is about, as its author may see it. */
|
|
314
|
+
export type StatementSubject =
|
|
315
|
+
| { readonly kind: 'message'; readonly conversationId: string; readonly seq: number; readonly message: PublicMessage | null }
|
|
316
|
+
| { readonly kind: 'profile' | 'member'; readonly memberId: string }
|
|
317
|
+
| { readonly kind: 'article'; readonly articleId: string }
|
|
318
|
+
|
|
319
|
+
/** `me/decisions/get`: the stored art. 17(3) fields, the rendered statement and the redress. */
|
|
320
|
+
export interface Statement extends DecisionSummary {
|
|
321
|
+
readonly territorialScope: string
|
|
322
|
+
/** The facts and circumstances: plain text, render it as text (`<pre>`). */
|
|
323
|
+
readonly facts: string
|
|
324
|
+
readonly automatedDetection: boolean
|
|
325
|
+
readonly automated: boolean
|
|
326
|
+
readonly legalGround: string | null
|
|
327
|
+
readonly legalExplanation: string | null
|
|
328
|
+
readonly contractualGround: string | null
|
|
329
|
+
readonly contractualExplanation: string | null
|
|
330
|
+
readonly redress: string
|
|
331
|
+
readonly templateId: string
|
|
332
|
+
readonly locale: string
|
|
333
|
+
/** The whole statement as kb-api rendered it (plain text). */
|
|
334
|
+
readonly statement: string
|
|
335
|
+
readonly appeal: { readonly appealId: string; readonly status: string; readonly submittedAt: string } | null
|
|
336
|
+
readonly subject: StatementSubject
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface AppealItem {
|
|
340
|
+
readonly appealId: string
|
|
341
|
+
readonly decisionId: string
|
|
342
|
+
readonly caseId: string
|
|
343
|
+
readonly status: string
|
|
344
|
+
readonly submittedAt: string
|
|
345
|
+
readonly resolvedAt: string | null
|
|
346
|
+
readonly resolutionDecisionId: string | null
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** One of the member's reports: never the package. */
|
|
350
|
+
export interface ReportItem {
|
|
351
|
+
readonly caseId: string
|
|
352
|
+
readonly category: string
|
|
353
|
+
readonly status: string
|
|
354
|
+
readonly reportedAt: string
|
|
355
|
+
readonly decidedAt: string | null
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** `legal/current`: the tenant's current text of a kind. */
|
|
359
|
+
export interface CurrentLegalText {
|
|
360
|
+
readonly kind: LegalTextKind
|
|
361
|
+
readonly textId: string
|
|
362
|
+
readonly version: string
|
|
363
|
+
readonly locale: string
|
|
364
|
+
/**
|
|
365
|
+
* HTML with anchors, the tenant's own words — for a host page that renders it on its server (the rules page).
|
|
366
|
+
* An element renders text only: it shows `communityRulesOf(bodyJson)` and links to that page.
|
|
367
|
+
*/
|
|
368
|
+
readonly body: string
|
|
369
|
+
/**
|
|
370
|
+
* The machine-readable form (DSA art. 14(1)); for `rules` `{ version, rules: [{ id, title, summary?, anchor }] }`
|
|
371
|
+
* (communityRulesOf), for `terms` and `privacy` `{ sections: [{ id, title, anchor }] }` (communityLegalSectionsOf).
|
|
372
|
+
*/
|
|
373
|
+
readonly bodyJson: Readonly<Record<string, unknown>> | null
|
|
374
|
+
readonly reconsentRequired: boolean
|
|
375
|
+
readonly publishedAt: string | null
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** One rule of the tenant's rules text: its stable id is what a report and a statement cite. */
|
|
379
|
+
export interface CommunityRule {
|
|
380
|
+
readonly id: string
|
|
381
|
+
readonly title: string
|
|
382
|
+
readonly summary: string | null
|
|
383
|
+
/** The rule's anchor on the rules page (`#<anchor>`). */
|
|
384
|
+
readonly anchor: string
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** The rules of a `rules` text's `bodyJson`, in order; an entry without a string id, title and anchor is skipped. */
|
|
388
|
+
export function communityRulesOf(bodyJson: unknown): CommunityRule[] {
|
|
389
|
+
const rules = typeof bodyJson === 'object' && bodyJson !== null ? (bodyJson as { rules?: unknown }).rules : undefined
|
|
390
|
+
if (!Array.isArray(rules)) return []
|
|
391
|
+
const out: CommunityRule[] = []
|
|
392
|
+
for (const r of rules) {
|
|
393
|
+
if (typeof r !== 'object' || r === null) continue
|
|
394
|
+
const { id, title, summary, anchor } = r as Record<string, unknown>
|
|
395
|
+
if (typeof id !== 'string' || typeof title !== 'string' || typeof anchor !== 'string') continue
|
|
396
|
+
out.push(Object.freeze({ id, title, summary: typeof summary === 'string' ? summary : null, anchor }))
|
|
397
|
+
}
|
|
398
|
+
return out
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** One section of a `terms` or `privacy` text: what the page's contents list and link. */
|
|
402
|
+
export interface CommunityLegalSection {
|
|
403
|
+
readonly id: string
|
|
404
|
+
readonly title: string
|
|
405
|
+
/** The section's anchor on the page (`#<anchor>`). */
|
|
406
|
+
readonly anchor: string
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* The sections of a `terms` or `privacy` text's `bodyJson` (`{ sections: [{ id, title, anchor }] }`), in order; an
|
|
411
|
+
* entry without a string id, title and anchor is skipped. A `rules` text has none (its rules are communityRulesOf).
|
|
412
|
+
*/
|
|
413
|
+
export function communityLegalSectionsOf(bodyJson: unknown): CommunityLegalSection[] {
|
|
414
|
+
const sections = typeof bodyJson === 'object' && bodyJson !== null ? (bodyJson as { sections?: unknown }).sections : undefined
|
|
415
|
+
if (!Array.isArray(sections)) return []
|
|
416
|
+
const out: CommunityLegalSection[] = []
|
|
417
|
+
for (const s of sections) {
|
|
418
|
+
if (typeof s !== 'object' || s === null) continue
|
|
419
|
+
const { id, title, anchor } = s as Record<string, unknown>
|
|
420
|
+
if (typeof id !== 'string' || typeof title !== 'string' || typeof anchor !== 'string') continue
|
|
421
|
+
out.push(Object.freeze({ id, title, anchor }))
|
|
422
|
+
}
|
|
423
|
+
return out
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** `me/export`: every section, `providerEntity` on every row; offer it as a JSON download. */
|
|
427
|
+
export interface MemberExport {
|
|
428
|
+
readonly generatedAt: string
|
|
429
|
+
readonly providerEntity: string
|
|
430
|
+
readonly [section: string]: unknown
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// ───────────────────────── the notice form (§7.7) ─────────────────────────
|
|
434
|
+
|
|
435
|
+
/** What a notice names: a message, a member (by id or handle), or an article. */
|
|
436
|
+
export type NoticeTarget =
|
|
437
|
+
| { readonly conversationId: string; readonly seq: number }
|
|
438
|
+
| { readonly memberId: string }
|
|
439
|
+
| { readonly handle: string }
|
|
440
|
+
| { readonly articleId: string }
|
|
441
|
+
|
|
442
|
+
export interface NoticeReceipt {
|
|
443
|
+
readonly caseId: string
|
|
444
|
+
/** The notifier's capability for `notices/status` and the appeal: put it in a link's fragment only (links.ts). */
|
|
445
|
+
readonly receipt: string
|
|
446
|
+
/**
|
|
447
|
+
* The case keeps this notice's contact: the confirmation and the outcome go to its e-mail, and the receipt may
|
|
448
|
+
* appeal. False without a contact, or when another notifier's contact is kept: the receipt still reads the outcome.
|
|
449
|
+
*/
|
|
450
|
+
readonly contactKept: boolean
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export interface NoticeStatus {
|
|
454
|
+
readonly status: 'open' | 'decided' | 'appealed' | 'closed' | (string & {})
|
|
455
|
+
readonly category: CaseCategory
|
|
456
|
+
readonly submittedAt: string
|
|
457
|
+
readonly decidedAt: string | null
|
|
458
|
+
/** The statement once decided (plain text), never the package. */
|
|
459
|
+
readonly statement: string | null
|
|
460
|
+
readonly appeal: {
|
|
461
|
+
readonly canAppeal: boolean
|
|
462
|
+
readonly closesAt: string | null
|
|
463
|
+
readonly open: { readonly submittedAt: string } | null
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ───────────────────────── the operations' inputs ─────────────────────────
|
|
468
|
+
|
|
469
|
+
export interface DiscussionListInput {
|
|
470
|
+
articleId: string
|
|
471
|
+
/** The page's language: a translation of each message into it when one exists. */
|
|
472
|
+
languageCode?: string | null
|
|
473
|
+
/** The previous page's `nextCursor`; absent for the first page. */
|
|
474
|
+
cursor?: number | null
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export interface MessagePostInput {
|
|
478
|
+
articleId: string
|
|
479
|
+
body: string
|
|
480
|
+
/** A reply names a top-level message of the same discussion. */
|
|
481
|
+
replyToSeq?: number | null
|
|
482
|
+
/** newClientMsgId(), the same on a retry. */
|
|
483
|
+
clientMsgId: string
|
|
484
|
+
/** The page's language (the language the member writes in). */
|
|
485
|
+
languageCode: string
|
|
486
|
+
/** The codes of CONFIRMATION_REQUIRED the author confirmed. */
|
|
487
|
+
confirmations?: string[]
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface MessageEditInput {
|
|
491
|
+
conversationId: string
|
|
492
|
+
seq: number
|
|
493
|
+
body: string
|
|
494
|
+
confirmations?: string[]
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface MessageReportInput {
|
|
498
|
+
conversationId: string
|
|
499
|
+
seq: number
|
|
500
|
+
category: CaseCategory
|
|
501
|
+
/** For `rules`: the id of a rule of the current rules text. */
|
|
502
|
+
ruleId?: string | null
|
|
503
|
+
/** The report's one free text (≤ COMMUNITY_REPORT_NOTE_MAX), seen by the team only. */
|
|
504
|
+
note?: string | null
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export interface OnboardInput {
|
|
508
|
+
ageBand: AgeBand
|
|
509
|
+
/** The current `rules` text's id (`legal/current`). */
|
|
510
|
+
rulesTextId: string
|
|
511
|
+
/** The current `art9_consent` text's id, when the tenant asks for the consent. */
|
|
512
|
+
art9TextId?: string | null
|
|
513
|
+
/** Required on a member's first onboarding (no profile yet). */
|
|
514
|
+
displayName?: string | null
|
|
515
|
+
/** Generated from the display name when absent. */
|
|
516
|
+
handle?: string | null
|
|
517
|
+
avatarPreset?: string | null
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export interface ProfileUpdateInput {
|
|
521
|
+
displayName?: string
|
|
522
|
+
/** At most once in COMMUNITY_HANDLE_CHANGE_DAYS. */
|
|
523
|
+
handle?: string
|
|
524
|
+
avatarPreset?: string | null
|
|
525
|
+
/** null or empty clears it. */
|
|
526
|
+
bio?: string | null
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export interface NoticeSubmitInput {
|
|
530
|
+
category: CaseCategory
|
|
531
|
+
target: NoticeTarget
|
|
532
|
+
/** Why the content is a problem (≤ COMMUNITY_NOTICE_DESCRIPTION_MAX). */
|
|
533
|
+
description: string
|
|
534
|
+
ruleId?: string | null
|
|
535
|
+
/** Optional; never for CATEGORY_WITHOUT_NOTIFIER. */
|
|
536
|
+
notifier?: { name?: string | null; email?: string | null; locale: string } | null
|
|
537
|
+
/** The Turnstile widget's one-shot token (action COMMUNITY_NOTICE_TURNSTILE_ACTION). */
|
|
538
|
+
turnstileToken?: string | null
|
|
539
|
+
/** Must contain COMMUNITY_GOOD_FAITH. */
|
|
540
|
+
confirmations?: string[]
|
|
541
|
+
}
|