@blogmcp/sdk 0.9.3 → 0.10.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 (61) hide show
  1. package/dist/community/channels.d.ts +7 -6
  2. package/dist/community/channels.js +4 -4
  3. package/dist/community/client.d.ts +74 -4
  4. package/dist/community/client.js +143 -91
  5. package/dist/community/index.d.ts +11 -6
  6. package/dist/community/index.js +111 -80
  7. package/dist/community/links.d.ts +61 -1
  8. package/dist/community/links.js +94 -40
  9. package/dist/community/manifest/index.d.ts +54 -0
  10. package/dist/community/manifest/index.js +46 -0
  11. package/dist/community/mentions.d.ts +38 -0
  12. package/dist/community/mentions.js +25 -0
  13. package/dist/community/messages.cs.d.ts +73 -3
  14. package/dist/community/messages.cs.js +82 -3
  15. package/dist/community/messages.d.ts +11 -0
  16. package/dist/community/messages.en.d.ts +69 -1
  17. package/dist/community/messages.en.js +71 -1
  18. package/dist/community/messages.js +26 -16
  19. package/dist/community/outcome.d.ts +8 -3
  20. package/dist/community/outcome.js +72 -28
  21. package/dist/community/realtime/index.d.ts +118 -0
  22. package/dist/community/realtime/index.js +215 -0
  23. package/dist/community/routes.d.ts +12 -0
  24. package/dist/community/routes.js +41 -25
  25. package/dist/community/server/bff.js +25 -25
  26. package/dist/community/server/host-routes.js +12 -0
  27. package/dist/community/server/index.d.ts +1 -1
  28. package/dist/community/server/index.js +15 -14
  29. package/dist/community/server/route-decision.d.ts +8 -0
  30. package/dist/community/server/route-decision.js +28 -22
  31. package/dist/community/shapes.d.ts +214 -2
  32. package/dist/community/shapes.js +65 -25
  33. package/dist/community/store.d.ts +18 -1
  34. package/dist/community/store.js +316 -261
  35. package/dist/community/sw/index.d.ts +45 -0
  36. package/dist/community/sw/index.js +59 -0
  37. package/dist/community/ua.d.ts +12 -0
  38. package/dist/community/ua.js +9 -0
  39. package/dist/packages/mdx-render-vue/dist/node_modules/dompurify/dist/purify.es.js +1342 -484
  40. package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
  41. package/package.json +21 -3
  42. package/src/community/channels.ts +8 -7
  43. package/src/community/client.ts +116 -5
  44. package/src/community/index.ts +59 -1
  45. package/src/community/links.ts +119 -2
  46. package/src/community/manifest/index.ts +107 -0
  47. package/src/community/mentions.ts +59 -0
  48. package/src/community/messages.cs.ts +88 -3
  49. package/src/community/messages.en.ts +77 -1
  50. package/src/community/messages.ts +19 -0
  51. package/src/community/outcome.ts +50 -1
  52. package/src/community/realtime/index.ts +522 -0
  53. package/src/community/routes.ts +16 -0
  54. package/src/community/server/bff.ts +2 -4
  55. package/src/community/server/host-routes.ts +12 -0
  56. package/src/community/server/index.ts +1 -0
  57. package/src/community/server/route-decision.ts +15 -0
  58. package/src/community/shapes.ts +256 -3
  59. package/src/community/store.ts +114 -0
  60. package/src/community/sw/index.ts +112 -0
  61. package/src/community/ua.ts +17 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `@handle` mentions in a message body (community M2, slice T8; docs/internal/m2-contracts.md §3.3 "Mentions"): the
3
+ * same token rule kb-api's `services/community/mentions.ts` applies when it notifies the mentioned member, so a page
4
+ * links exactly the handles kb-api counted (test/community/mentions.spec.ts pins the pattern to kb-api's source).
5
+ *
6
+ * A mention is TEXT with a link to the member's profile page (profilePath): the body is split into spans, never
7
+ * parsed as HTML — a page renders each span as a text node (a mention inside an `<a>` whose href profilePath built).
8
+ * Whether a handle names anyone is kb-api's to know; the page links every well-formed one (the profile page answers
9
+ * `notFound` for a handle nobody holds, the same answer as for one hidden from the viewer).
10
+ *
11
+ * Pure: no I/O, no globals.
12
+ */
13
+
14
+ import { COMMUNITY_HANDLE_RE } from './routes'
15
+
16
+ /**
17
+ * One `@handle` token: `@` at the start or after a character that is not a letter, a digit, `_`, `@`, `.` or `/`
18
+ * (so `jana@example.com` and a URL's `/@x` are no mentions), then a handle in any case, not followed by a handle
19
+ * character. Group 1 is the character before the `@`, group 2 the handle as typed. kb-api's MENTION_TOKEN_RE.
20
+ *
21
+ * ⚠️ The regex is global (`/g`, as kb-api's), so `.test()` and `.exec()` on it carry `lastIndex` from one call to the
22
+ * next. Use `communityMentionSpans`, `communityMentionHandles` or `text.matchAll(COMMUNITY_MENTION_RE)` — never
23
+ * `.test`/`.exec` on the shared object.
24
+ */
25
+ export const COMMUNITY_MENTION_RE = /(^|[^A-Za-z0-9_@./])@([A-Za-z0-9][A-Za-z0-9_]{2,29})(?![A-Za-z0-9_])/g
26
+
27
+ /** A piece of a message body: plain text, or a mention (`text` as typed, `@` included; `handle` lower-cased). */
28
+ export type CommunityTextSpan =
29
+ | { readonly kind: 'text'; readonly text: string }
30
+ | { readonly kind: 'mention'; readonly text: string; readonly handle: string }
31
+
32
+ /**
33
+ * The body as spans, in order: the text between mentions and each mention. Joining every span's `text` gives the
34
+ * body back unchanged. A body without a mention is one text span; an empty or absent body, none.
35
+ */
36
+ export function communityMentionSpans(text: string | null | undefined): CommunityTextSpan[] {
37
+ if (typeof text !== 'string' || text === '') return []
38
+ if (!text.includes('@')) return [{ kind: 'text', text }]
39
+ const out: CommunityTextSpan[] = []
40
+ let at = 0
41
+ for (const m of text.matchAll(new RegExp(COMMUNITY_MENTION_RE.source, 'g'))) {
42
+ const typed = m[2]!
43
+ const handle = typed.toLowerCase()
44
+ if (!COMMUNITY_HANDLE_RE.test(handle)) continue
45
+ const start = (m.index ?? 0) + m[1]!.length
46
+ if (start > at) out.push({ kind: 'text', text: text.slice(at, start) })
47
+ out.push({ kind: 'mention', text: `@${typed}`, handle })
48
+ at = start + 1 + typed.length
49
+ }
50
+ if (at < text.length) out.push({ kind: 'text', text: text.slice(at) })
51
+ return out
52
+ }
53
+
54
+ /** The distinct handles a body mentions, lower-cased, in the order they first appear (kb-api's mentionHandles). */
55
+ export function communityMentionHandles(text: string | null | undefined): string[] {
56
+ const out: string[] = []
57
+ for (const span of communityMentionSpans(text)) if (span.kind === 'mention' && !out.includes(span.handle)) out.push(span.handle)
58
+ return out
59
+ }
@@ -34,6 +34,11 @@ export const COMMUNITY_MESSAGES_CS = {
34
34
  'error.surfaceOff': 'Diskuse tu teď není k dispozici.',
35
35
  'error.notMoved': 'Diskusi teď připravujeme. Psát do ní půjde brzy.',
36
36
  'error.ledger': 'Teď se to nepodařilo uložit a všechno zůstalo, jak bylo. Zkuste to prosím znovu.',
37
+ 'error.readOnly': 'Tahle funkce komunity je teď vypnutá. Diskuse pod články běží dál.',
38
+ 'error.braked': 'Psaní je teď na chvíli pozastavené. Číst můžete dál, psát půjde zase brzy.',
39
+ 'error.mentionLimit': 'V jednom příspěvku jste zmínili víc lidí, než zatím jde. Některé zmínky odeberte a pošlete znovu.',
40
+ 'error.pushRefused': 'V tomhle prohlížeči upozornění zapnout nejde. Zkuste jiný prohlížeč, nebo sledujte stránku s upozorněními.',
41
+ 'error.realtimeOff': 'Nové příspěvky se tu teď neukazují hned. Diskuse se obnovuje sama každou chvíli.',
37
42
  'error.submit': 'Nepovedlo se to. Obnovte prosím stránku a zkuste to znovu.',
38
43
 
39
44
  // ── what the composer waits for (need.<Need>) ──
@@ -189,7 +194,13 @@ export const COMMUNITY_MESSAGES_CS = {
189
194
  'onboarding.rulesChanged': 'Pravidla diskuse se od vaší poslední návštěvy změnila. Přečtěte si prosím novou verzi a potvrďte ji.',
190
195
  'onboarding.art9Title': 'Souhlas se zpracováním',
191
196
  'onboarding.art9Lede': 'Pro psaní do diskuse potřebujeme váš souhlas podle textu níže.',
197
+ // art9Refusal = public_write: the consent is offered, writing in the public discussion does not depend on it (§9.8 q8).
198
+ 'onboarding.art9LedeOptional': 'Prosíme o váš souhlas podle textu níže. Psát ve veřejné diskusi můžete i bez něj.',
192
199
  'onboarding.art9Accept': 'Souhlasím se zpracováním podle textu výše.',
200
+ 'onboarding.art9Controller': 'Souhlas pro {label}',
201
+ 'onboarding.art9Refuse': 'Nesouhlasím',
202
+ 'onboarding.art9RefusedDone': 'Bez tohoto souhlasu můžete psát ve veřejné diskusi.',
203
+ 'onboarding.art9RequiredToWrite': 'Bez souhlasu můžete diskusi jen číst.',
193
204
  'onboarding.profileTitle': 'Jak vás uvidí ostatní',
194
205
  'onboarding.displayName': 'Jméno v diskusi',
195
206
  'onboarding.displayNameHint': 'Může to být i přezdívka. Uvidí ho všichni čtenáři.',
@@ -226,8 +237,8 @@ export const COMMUNITY_MESSAGES_CS = {
226
237
  'panel.statementsEmpty': 'Rozhodnutí o vašem obsahu uvidíte tady.',
227
238
  'panel.reports': 'Moje hlášení',
228
239
  'panel.reportsEmpty': 'Hlášení, která pošlete, uvidíte tady.',
229
- 'panel.notifications': 'Oznámení',
230
- 'panel.notificationsEmpty': 'Nová oznámení uvidíte tady.',
240
+ 'panel.notifications': 'Upozornění',
241
+ 'panel.notificationsEmpty': 'Nová upozornění uvidíte tady.',
231
242
  'panel.unread_one': '{count} nepřečtené oznámení',
232
243
  'panel.unread_few': '{count} nepřečtená oznámení',
233
244
  'panel.unread_many': '{count} nepřečteného oznámení',
@@ -238,9 +249,10 @@ export const COMMUNITY_MESSAGES_CS = {
238
249
  'panel.consents': 'Souhlasy',
239
250
  'panel.art9Given': 'Souhlas se zpracováním je udělený.',
240
251
  'panel.art9NotGiven': 'Souhlas se zpracováním jste zatím nedali.',
252
+ 'panel.art9Refused': 'Souhlas se zpracováním jste odmítli.',
241
253
  'panel.art9Withdraw': 'Odvolat souhlas',
242
254
  'panel.art9WithdrawTitle': 'Odvolat souhlas se zpracováním?',
243
- 'panel.art9WithdrawExplain': 'Diskusi můžete dál číst. Psát do ní půjde, až souhlas zase udělíte.',
255
+ 'panel.art9WithdrawExplain': 'Diskusi můžete dál číst. Jestli do ní půjde psát i bez souhlasu, nebo až ho zase udělíte, záleží na nastavení webu — řekne vám to před dalším komentářem.',
244
256
  'panel.art9WithdrawConfirm': 'Ano, odvolat souhlas',
245
257
  'panel.art9WithdrawCancel': 'Ponechat souhlas',
246
258
  'panel.art9Withdrawn': 'Souhlas jste odvolali.',
@@ -317,6 +329,79 @@ export const COMMUNITY_MESSAGES_CS = {
317
329
  'notification.appeal_resolved': 'Vaše odvolání je vyřízené.',
318
330
  'notification.erasure_scheduled': 'Smazání vašeho profilu v diskusi je naplánované.',
319
331
  'notification.inactivity_warning': 'Dlouho jste v diskusi nebyli. Bez další aktivity váš profil po čase smažeme.',
332
+ 'notification.module_read_only': 'Rozšířené funkce komunity jsou vypnuté. Diskuse pod články běží dál; co se pro vás mění, najdete na stránce Moje komunita.',
333
+ 'notification.module_braked': 'Psaní v komunitě je teď pozastavené. Číst můžete dál.',
334
+ 'notification.reply': 'Někdo odpověděl na váš příspěvek.',
335
+ 'notification.mention': 'Někdo vás zmínil v diskusi.',
336
+ 'notification.module_push_reset': 'Upozornění v prohlížeči je potřeba znovu zapnout v nastavení komunity.',
337
+ 'notification.age_limit_changed': 'Komunita je nově jen pro dospělé, váš profil je proto jen ke čtení. Podrobnosti najdete na stránce Moje komunita.',
338
+
339
+ // ── M2 T8: the notification centre (centre.*) and the header badge (badge.*) ──
340
+ 'centre.title': 'Upozornění',
341
+ 'centre.empty': 'Nová upozornění uvidíte tady.',
342
+ 'centre.markAllRead': 'Označit vše jako přečtené',
343
+ 'centre.settings': 'Nastavení upozornění',
344
+ 'centre.loadMore': 'Načíst starší',
345
+ 'centre.unreadOnly': 'Jen nepřečtené',
346
+ 'centre.signIn': 'Upozornění uvidíte po přihlášení.',
347
+ // M2 T10: a reply's or a mention's row links its message on the article page.
348
+ 'centre.openMessage': 'Zobrazit příspěvek',
349
+ 'badge.unread_one': '{count} nové upozornění',
350
+ 'badge.unread_few': '{count} nová upozornění',
351
+ 'badge.unread_many': '{count} nového upozornění',
352
+ 'badge.unread_other': '{count} nových upozornění',
353
+
354
+ // ── M2 T8: the member's settings (settings.*) ──
355
+ 'settings.title': 'Nastavení upozornění',
356
+ 'settings.signIn': 'Nastavení upozornění změníte po přihlášení.',
357
+ 'settings.notifyReply': 'Odpovědi na moje příspěvky',
358
+ 'settings.notifyMention': 'Když mě někdo zmíní',
359
+ 'settings.notifyTopic': 'Novinky v diskusích, které sleduji',
360
+ 'settings.pushEnabled': 'Upozornění v prohlížeči',
361
+ 'settings.digestEmail': 'Denní souhrn e-mailem',
362
+ 'settings.quietHours': 'Noční klid: mezi 22:00 a 7:00 počkají upozornění v prohlížeči do rána.',
363
+ 'settings.saved': 'Uloženo.',
364
+ 'settings.push.enable': 'Zapnout upozornění',
365
+ 'settings.push.disable': 'Vypnout upozornění',
366
+ 'settings.push.carries': 'Upozornění doručuje tento web. Samo upozornění nenese, co přišlo ani od koho.',
367
+ 'settings.push.unsupported': 'Tenhle prohlížeč upozornění neumí. Nové odpovědi a zmínky najdete na stránce s upozorněními.',
368
+ 'settings.push.refused': 'Upozornění se v tomhle prohlížeči zapnout nepodařilo. Zkuste to prosím později nebo v jiném prohlížeči.',
369
+ 'settings.push.denied': 'Upozornění má tenhle prohlížeč pro tento web zablokovaná. Povolit je můžete v nastavení prohlížeče.',
370
+ 'settings.push.inAppExplain': 'V aplikaci Facebooku nebo Instagramu upozornění zapnout nejdou. Otevřete stránku v prohlížeči.',
371
+ 'settings.push.openInBrowser': 'Otevřít v prohlížeči',
372
+ 'settings.push.iosGuide':
373
+ 'Na iPhonu a iPadu fungují upozornění jen u webu přidaného na plochu: v Safari klepněte na Sdílet a zvolte „Přidat na plochu“. Pak web otevřete z plochy a upozornění zapněte.',
374
+ 'settings.push.reset': 'Zapněte si upozornění znovu: nastavení webu se změnilo a dřívější zapnutí přestalo platit.',
375
+ 'settings.digest.prompt': 'Chcete přestat dostávat denní souhrn e-mailem?',
376
+ 'settings.digest.confirm': 'Odhlásit denní souhrn',
377
+ 'settings.digest.unsubscribed': 'Denní souhrn e-mailem jsme vypnuli.',
378
+ 'settings.digest.staleLink': 'Odkaz na odhlášení souhrnu už neplatí. Po přihlášení ho vypnete přepínačem v nastavení.',
379
+
380
+ // ── M2 T8: a member's public profile (profile.*) and the trust level's label (trust.<level>, from trustLabel) ──
381
+ 'profile.memberSince': 'Členem od {date}',
382
+ 'profile.bio': 'O mně',
383
+ 'profile.notFound': 'Tenhle profil jsme nenašli.',
384
+ 'profile.signIn': 'Profily členů uvidíte po přihlášení.',
385
+ 'trust.0': 'Nový člen',
386
+ 'trust.1': 'Člen',
387
+ 'trust.2': 'Stálý člen',
388
+ 'trust.3': 'Moderátor',
389
+
390
+ // ── M2 T8: the welcome page (welcome.*) ──
391
+ 'welcome.title': 'Vítejte v komunitě',
392
+ 'welcome.lede': 'Tady je pár věcí, které se vám na začátku hodí.',
393
+ 'welcome.rules': 'Jak to v diskusi chodí',
394
+ 'welcome.discussions': 'Projít diskuse',
395
+ 'welcome.settings': 'Nastavit upozornění',
396
+ 'welcome.profile': 'Můj profil',
397
+
398
+ // ── M2 T8: the discussion under the module's states ──
399
+ 'realtime.off': 'Živé aktualizace jsou teď vypnuté. Diskuse se sama obnovuje každou chvíli.',
400
+ // `state.readOnly` names what module `read_only` stops (realtime → polling, push; m2-contracts.md §3.1): the
401
+ // discussion stays writable — only a brake (`state.braked`) stops its writes — so the composer stays enabled.
402
+ 'state.readOnly': 'Rozšířené funkce komunity jsou teď vypnuté. Diskuse pod článkem běží dál.',
403
+ 'state.braked': 'Psaní je teď na chvíli pozastavené. Číst můžete dál.',
404
+ 'mention.limit': 'V jednom příspěvku jste zmínili víc lidí, než zatím jde.',
320
405
 
321
406
  // ── the notice form ──
322
407
  'notice.title': 'Nahlásit obsah',
@@ -32,6 +32,11 @@ export const COMMUNITY_MESSAGES_EN = {
32
32
  'error.surfaceOff': "The discussion isn't available here right now.",
33
33
  'error.notMoved': "We're preparing the discussion. You'll be able to write here soon.",
34
34
  'error.ledger': "That couldn't be saved just now, and everything is as it was. Please try again.",
35
+ 'error.readOnly': 'This community feature is switched off for now. The discussions under articles keep working.',
36
+ 'error.braked': 'Writing is paused for a while. You can keep reading, and writing will open again soon.',
37
+ 'error.mentionLimit': 'This post mentions more people than you can mention yet. Remove some of the mentions and send it again.',
38
+ 'error.pushRefused': 'Notifications cannot be switched on in this browser. Try another browser, or keep an eye on the notifications page.',
39
+ 'error.realtimeOff': 'New posts do not show up instantly here right now. The discussion refreshes itself every so often.',
35
40
  'error.submit': "That didn't work. Please reload the page and try again.",
36
41
 
37
42
  'need.sign_in': 'Sign in to write in the discussion.',
@@ -167,7 +172,13 @@ export const COMMUNITY_MESSAGES_EN = {
167
172
  'onboarding.rulesChanged': 'The discussion rules have changed since your last visit. Please read the new version and confirm it.',
168
173
  'onboarding.art9Title': 'Consent to processing',
169
174
  'onboarding.art9Lede': 'To write in the discussion, we need your consent as described below.',
175
+ // art9Refusal = public_write: the consent is offered, writing in the public discussion does not depend on it (§9.8 q8).
176
+ 'onboarding.art9LedeOptional': 'We ask for your consent as described below. You can write in the public discussion without it too.',
170
177
  'onboarding.art9Accept': 'I consent to the processing as described above.',
178
+ 'onboarding.art9Controller': 'Consent for {label}',
179
+ 'onboarding.art9Refuse': 'I do not consent',
180
+ 'onboarding.art9RefusedDone': 'You can write in the public discussion without this consent.',
181
+ 'onboarding.art9RequiredToWrite': 'Without the consent you can only read.',
171
182
  'onboarding.profileTitle': 'How others will see you',
172
183
  'onboarding.displayName': 'Name in the discussion',
173
184
  'onboarding.displayNameHint': 'It can be a nickname. Every reader will see it.',
@@ -212,9 +223,10 @@ export const COMMUNITY_MESSAGES_EN = {
212
223
  'panel.consents': 'Consents',
213
224
  'panel.art9Given': 'Consent to the processing is given.',
214
225
  'panel.art9NotGiven': "You haven't given consent to the processing yet.",
226
+ 'panel.art9Refused': 'You declined the consent to the processing.',
215
227
  'panel.art9Withdraw': 'Withdraw consent',
216
228
  'panel.art9WithdrawTitle': 'Withdraw your consent to the processing?',
217
- 'panel.art9WithdrawExplain': "You can keep reading the discussion. You'll be able to write again once you give the consent again.",
229
+ 'panel.art9WithdrawExplain': "You can keep reading the discussion. Whether you can write without the consent, or only once you give it again, depends on the website's settings — it tells you before your next comment.",
218
230
  'panel.art9WithdrawConfirm': 'Yes, withdraw consent',
219
231
  'panel.art9WithdrawCancel': 'Keep the consent',
220
232
  'panel.art9Withdrawn': "You've withdrawn your consent.",
@@ -289,6 +301,70 @@ export const COMMUNITY_MESSAGES_EN = {
289
301
  'notification.appeal_resolved': 'Your appeal has been resolved.',
290
302
  'notification.erasure_scheduled': 'The deletion of your discussion profile is scheduled.',
291
303
  'notification.inactivity_warning': "You haven't been active in the discussion for a long time. Without further activity, we'll delete your profile after a while.",
304
+ 'notification.module_read_only': "The community's extra features are switched off. The discussions under articles go on; what changes for you is on the My community page.",
305
+ 'notification.module_braked': 'Writing in the community is paused for now. You can keep reading.',
306
+ 'notification.reply': 'Someone replied to your post.',
307
+ 'notification.mention': 'Someone mentioned you in a discussion.',
308
+ 'notification.module_push_reset': 'Browser notifications need to be switched on again in your community settings.',
309
+ 'notification.age_limit_changed': 'The community is now for adults only, so your profile is read-only. The details are on the My community page.',
310
+
311
+ 'centre.title': 'Notifications',
312
+ 'centre.empty': 'New notifications will show here.',
313
+ 'centre.markAllRead': 'Mark all as read',
314
+ 'centre.settings': 'Notification settings',
315
+ 'centre.loadMore': 'Load older',
316
+ 'centre.unreadOnly': 'Unread only',
317
+ 'centre.signIn': 'Sign in to see your notifications.',
318
+ // M2 T10: a reply's or a mention's row links its message on the article page.
319
+ 'centre.openMessage': 'Show the post',
320
+ 'badge.unread_one': '{count} new notification',
321
+ 'badge.unread_other': '{count} new notifications',
322
+
323
+ 'settings.title': 'Notification settings',
324
+ 'settings.signIn': 'Sign in to change your notification settings.',
325
+ 'settings.notifyReply': 'Replies to my posts',
326
+ 'settings.notifyMention': 'When someone mentions me',
327
+ 'settings.notifyTopic': 'News in discussions I follow',
328
+ 'settings.pushEnabled': 'Browser notifications',
329
+ 'settings.digestEmail': 'Daily e-mail summary',
330
+ 'settings.quietHours': 'Quiet hours: between 22:00 and 7:00, browser notifications wait until the morning.',
331
+ 'settings.saved': 'Saved.',
332
+ 'settings.push.enable': 'Turn on notifications',
333
+ 'settings.push.disable': 'Turn off notifications',
334
+ 'settings.push.carries': "This website delivers the notifications. A notification doesn't say what arrived or who it's from.",
335
+ 'settings.push.unsupported': "This browser can't show notifications. You'll find new replies and mentions on the notifications page.",
336
+ 'settings.push.refused': "Notifications couldn't be turned on in this browser. Please try again later or in another browser.",
337
+ 'settings.push.denied': 'This browser blocks notifications for this site. You can allow them in the browser settings.',
338
+ 'settings.push.inAppExplain': "Notifications can't be turned on inside the Facebook or Instagram app. Open the page in your browser.",
339
+ 'settings.push.openInBrowser': 'Open in browser',
340
+ 'settings.push.iosGuide':
341
+ 'On an iPhone or iPad, notifications work only for a site added to the Home Screen: in Safari tap Share and choose “Add to Home Screen”. Then open the site from the Home Screen and turn notifications on.',
342
+ 'settings.push.reset': 'Turn notifications on again: a site setting changed, so the earlier setup no longer works.',
343
+ 'settings.digest.prompt': 'Do you want to stop receiving the daily e-mail summary?',
344
+ 'settings.digest.confirm': 'Stop the daily summary',
345
+ 'settings.digest.unsubscribed': "We've switched off the daily e-mail summary.",
346
+ 'settings.digest.staleLink': 'This unsubscribe link is no longer valid. Sign in to switch the summary off in the settings.',
347
+
348
+ 'profile.memberSince': 'Member since {date}',
349
+ 'profile.bio': 'About me',
350
+ 'profile.notFound': "We couldn't find this profile.",
351
+ 'profile.signIn': "Sign in to see members' profiles.",
352
+ 'trust.0': 'New member',
353
+ 'trust.1': 'Member',
354
+ 'trust.2': 'Regular',
355
+ 'trust.3': 'Moderator',
356
+
357
+ 'welcome.title': 'Welcome to the community',
358
+ 'welcome.lede': 'Here are a few things that help at the start.',
359
+ 'welcome.rules': 'How the discussion works',
360
+ 'welcome.discussions': 'Browse the discussions',
361
+ 'welcome.settings': 'Set up notifications',
362
+ 'welcome.profile': 'My profile',
363
+
364
+ 'realtime.off': 'Live updates are off right now. The discussion refreshes itself every so often.',
365
+ 'state.readOnly': "The community's extra features are switched off for now. The discussion under the article goes on.",
366
+ 'state.braked': 'Writing is paused for a while. You can keep reading.',
367
+ 'mention.limit': 'This post mentions more people than you can mention yet.',
292
368
 
293
369
  'notice.title': 'Report content',
294
370
  'notice.lede': 'You can report a comment, a profile or an article, even without signing in.',
@@ -11,6 +11,7 @@
11
11
 
12
12
  import { COMMUNITY_MESSAGES_CS } from './messages.cs'
13
13
  import { COMMUNITY_MESSAGES_EN } from './messages.en'
14
+ import { NOTIFICATION_CODES, TRUST_LABELS } from './shapes'
14
15
 
15
16
  type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'
16
17
  type BaseKey<K extends string> = K extends `${infer Base}_${PluralCategory}` ? Base : K
@@ -110,3 +111,21 @@ export function noteMessageKey(code: string): CommunityMessageKey | null {
110
111
  const key = `note.${code}`
111
112
  return hasCommunityMessage(key) ? key : null
112
113
  }
114
+
115
+ /**
116
+ * The sentence of a notification in the centre (`notification.<code>`), or null for a code this SDK has no text for
117
+ * (a newer kb-api's: skip the row's sentence, never show the code). The sentence names no member and quotes nothing:
118
+ * the page links the subject.
119
+ */
120
+ export function notificationMessageKey(code: string): CommunityMessageKey | null {
121
+ return (NOTIFICATION_CODES as readonly string[]).includes(code) ? (`notification.${code}` as CommunityMessageKey) : null
122
+ }
123
+
124
+ /**
125
+ * The label of a public trust level (`profile/get`'s `trustLabel`, m2-contracts.md §3.2, §3.10): `trust.0` „Nový člen"
126
+ * … `trust.3` „Moderátor" — a label, never the number. Null for a label this SDK does not know (show no label).
127
+ */
128
+ export function trustLabelMessageKey(label: string | null | undefined): CommunityMessageKey | null {
129
+ const level = typeof label === 'string' ? (TRUST_LABELS as readonly string[]).indexOf(label) : -1
130
+ return level < 0 ? null : (`trust.${level}` as CommunityMessageKey)
131
+ }
@@ -62,6 +62,16 @@ export const COMMUNITY_UI_CODES = [
62
62
  'notMoved',
63
63
  /** kb-api could not record the change; nothing changed — retry. */
64
64
  'ledger',
65
+ /** The community's extra features are off for now (MyState `module.until` says until when): the discussions under articles keep working, this feature does not. */
66
+ 'readOnly',
67
+ /** The community is paused for now (`until` when the pause has an end): reading works, writing does not. */
68
+ 'braked',
69
+ /** M2 T3: more @mentions in one message than the member may use yet. */
70
+ 'mentionLimit',
71
+ /** M2 T4: the browser's push service is not one the community sends to (or could not be reached): no notifications on this browser. */
72
+ 'pushRefused',
73
+ /** M2 T5: live updates are not on here: the discussion keeps itself fresh by polling (pollDiscussionHead). */
74
+ 'realtimeOff',
65
75
  /** Anything else: "that did not work, try again". */
66
76
  'submit',
67
77
  ] as const
@@ -85,10 +95,15 @@ export interface CommunityFailure {
85
95
  needs?: KnownNeed[]
86
96
  /** FILTER_BLOCKED, CONFIRMATION_REQUIRED: the filter codes (CONFIRMATION_REQUIRED: the ones to confirm). */
87
97
  codes?: string[]
88
- /** POSTING_RESTRICTED, ACCOUNT_SUSPENDED: when it ends (absent: no end set). */
98
+ /** POSTING_RESTRICTED, ACCOUNT_SUSPENDED, MODULE_READ_ONLY, BRAKED: when it ends (absent: no end set). */
89
99
  until?: string
90
100
  /** VALIDATION: the paths of the refused fields (`displayName`, `body`, …), never their values. */
91
101
  fields?: string[]
102
+ /**
103
+ * VALIDATION: the codes kb-api gave some of those fields (`issues[].code`; M2 T9: `art9_refusal_read_only` on
104
+ * `art9Refused`) — a code only, never zod's message. Absent when none was given.
105
+ */
106
+ issueCodes?: string[]
92
107
  }
93
108
 
94
109
  /** What every client method resolves to; none of them throws. */
@@ -125,6 +140,18 @@ export const COMMUNITY_API_CODES = [
125
140
  'STAFF_POSTING_OFF',
126
141
  'PRESET_CONFLICT',
127
142
  'INTERNAL',
143
+ 'MODULE_DARK',
144
+ 'MODULE_READ_ONLY',
145
+ 'BRAKED',
146
+ 'BRAKE_PLATFORM',
147
+ 'MODULE_CONDITIONS',
148
+ 'TRUST_LEVEL_INVALID',
149
+ 'MENTION_LIMIT',
150
+ 'DIGEST_UNSUBSCRIBE_INVALID',
151
+ 'PUSH_ENDPOINT_REFUSED',
152
+ 'PUSH_LIMIT',
153
+ 'REALTIME_OFF',
154
+ 'BUSY',
128
155
  'NOT_A_MEMBER_SESSION',
129
156
  'IDENTITY_NOT_ADMITTED',
130
157
  'ACCOUNT_NOT_ELIGIBLE',
@@ -148,6 +175,7 @@ export const COMMUNITY_API_CODES = [
148
175
  'INVALID_INPUT',
149
176
  'LEGAL_HOLD',
150
177
  'TEXT_MISSING',
178
+ 'AGE16_NOT_ALLOWED',
151
179
  'QUOTA_DAILY',
152
180
  'QUOTA_IP_HOURLY',
153
181
  ] as const
@@ -191,6 +219,25 @@ export const COMMUNITY_OUTCOME_OF_KB: Readonly<Record<CommunityApiCode, Communit
191
219
  STAFF_POSTING_OFF: 'submit',
192
220
  PRESET_CONFLICT: 'submit',
193
221
  INTERNAL: 'unavailable',
222
+ // M2 (m2-contracts.md §3.1): a Pro surface of a tenant without the module answers as one that is not there.
223
+ MODULE_DARK: 'unavailable',
224
+ MODULE_READ_ONLY: 'readOnly',
225
+ BRAKED: 'braked',
226
+ // The team's and the platform's own refusals: no public operation produces them.
227
+ BRAKE_PLATFORM: 'submit',
228
+ MODULE_CONDITIONS: 'submit',
229
+ // M2 T2: the team's members/set-trust-level with a level outside 0..3 (no public operation produces it).
230
+ TRUST_LEVEL_INVALID: 'invalid',
231
+ // M2 T3 (§3.3): too many @handles for the member's trust level; an unsubscribe link that is not (or no longer) valid.
232
+ MENTION_LIMIT: 'mentionLimit',
233
+ DIGEST_UNSUBSCRIBE_INVALID: 'invalid',
234
+ // M2 T4 (§3.4): a push endpoint kb-api will not send to; more than 10 subscriptions, or the push quota spent (retryAfterS).
235
+ PUSH_ENDPOINT_REFUSED: 'pushRefused',
236
+ PUSH_LIMIT: 'quota',
237
+ // M2 T5 (§3.5): the module is neither live nor braked, or live updates are not configured — poll instead.
238
+ REALTIME_OFF: 'realtimeOff',
239
+ // F-W0-M4: the team router's lock timeout or deadlock (module/enable's first ranking) — no public operation produces it.
240
+ BUSY: 'submit',
194
241
  // A session that is not a reader's (the team, a key) or an identity the tenant does not admit: sign in as a reader.
195
242
  NOT_A_MEMBER_SESSION: 'signIn',
196
243
  IDENTITY_NOT_ADMITTED: 'signIn',
@@ -219,6 +266,8 @@ export const COMMUNITY_OUTCOME_OF_KB: Readonly<Record<CommunityApiCode, Communit
219
266
  LEGAL_HOLD: 'submit',
220
267
  // The tenant has not published the text a join needs: the community cannot be joined yet.
221
268
  TEXT_MISSING: 'unavailable',
269
+ // M2 T9: the team's settings/update only (the age limit 16 for a tenant its size class does not allow it).
270
+ AGE16_NOT_ALLOWED: 'submit',
222
271
  QUOTA_DAILY: 'quota',
223
272
  QUOTA_IP_HOURLY: 'quota',
224
273
  } satisfies Record<CommunityApiCode, CommunityUiCode>)