@blogmcp/sdk 0.9.4 → 0.10.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.
Files changed (59) 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 +75 -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/package.json +20 -3
  40. package/src/community/channels.ts +8 -7
  41. package/src/community/client.ts +116 -5
  42. package/src/community/index.ts +59 -1
  43. package/src/community/links.ts +119 -2
  44. package/src/community/manifest/index.ts +107 -0
  45. package/src/community/mentions.ts +59 -0
  46. package/src/community/messages.cs.ts +88 -3
  47. package/src/community/messages.en.ts +77 -1
  48. package/src/community/messages.ts +19 -0
  49. package/src/community/outcome.ts +53 -1
  50. package/src/community/realtime/index.ts +522 -0
  51. package/src/community/routes.ts +16 -0
  52. package/src/community/server/bff.ts +2 -4
  53. package/src/community/server/host-routes.ts +12 -0
  54. package/src/community/server/index.ts +1 -0
  55. package/src/community/server/route-decision.ts +15 -0
  56. package/src/community/shapes.ts +256 -3
  57. package/src/community/store.ts +114 -0
  58. package/src/community/sw/index.ts +112 -0
  59. package/src/community/ua.ts +17 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `@blogmcp/sdk/community/sw` — the community's service worker, as source text (community M2, slice T4;
3
+ * docs/internal/m2-contracts.md §3.4 "The service worker and the manifest"; community.md §7.5).
4
+ *
5
+ * A host serves the string this returns from one route, as `text/javascript` (COMMUNITY_SW_CONTENT_TYPE), at its
6
+ * base: the managed blogs' `/blog/sw.js` (scope `/blog/`), the storefront's `/sw.js` — no bundler step. The worker
7
+ * does two things and nothing else:
8
+ * - `push`: it shows ONE notification with the generic text („Novinky v komunitě <tenant>" / "News in the
9
+ * <tenant> community"), `tag: 'community'` (a newer one replaces it), `renotify: false`, the badge icon. The
10
+ * payload kb-api sends is exactly `{"t":"community"}`; the worker reads `t` and nothing else, and what it shows
11
+ * never depends on the payload (invariant 6: nothing of the event — no count, no name, no text — leaves kb-api);
12
+ * - `notificationclick`: it focuses a window of the notification centre, or opens one (`centrePath`).
13
+ * No `fetch` handler and no cache (`caches`): the site works exactly as it does without the worker. A structural
14
+ * test (test/community/sw.spec.ts) pins all of it on the returned string.
15
+ *
16
+ * The worker registers only from the settings page or the centre, on the member's click („Zapnout upozornění"),
17
+ * never on page load — that is the host's code, with `pushManager.subscribe({ userVisibleOnly: true,
18
+ * applicationServerKey })` and the key from `me.push.vapid()`.
19
+ *
20
+ * Pure: no DOM, no globals, no import (it runs on the host's server and returns text).
21
+ */
22
+ /** The Content-Type a host serves the worker with. */
23
+ export declare const COMMUNITY_SW_CONTENT_TYPE = "text/javascript; charset=utf-8";
24
+ /** The notification's tag: one community notification at a time, the newest replacing the last. */
25
+ export declare const COMMUNITY_SW_TAG = "community";
26
+ /** The generic notification text (the only text a push shows), per locale; `tenant` is the site's name. */
27
+ export declare const COMMUNITY_PUSH_TEXTS: Readonly<Record<'cs' | 'en', (tenant: string | null) => string>>;
28
+ /** The generic text for a locale (`cs-CZ` → cs; anything else → en). */
29
+ export declare function communityPushText(locale: string | null | undefined, tenant?: string | null): string;
30
+ export interface CommunityServiceWorkerOptions {
31
+ /** Where a click goes: the notification centre's path on this site (`/community/notifications`, `/komunita/upozorneni`). */
32
+ readonly centrePath: string;
33
+ /** The notification's one line; default communityPushText(locale, tenant). */
34
+ readonly badgeText?: string;
35
+ /** The site's name in the default text. */
36
+ readonly tenant?: string | null;
37
+ /** The default text's language (`cs`, `en`). */
38
+ readonly locale?: string | null;
39
+ /** The notification's icon, a path on this site. */
40
+ readonly icon?: string | null;
41
+ /** The monochrome badge (Android's status bar), a path on this site. */
42
+ readonly badge?: string | null;
43
+ }
44
+ /** The worker's source (see the module comment). Throws a TypeError for a path that is not this site's. */
45
+ export declare function communityServiceWorkerSource(options: CommunityServiceWorkerOptions): string;
@@ -0,0 +1,59 @@
1
+ const d = "text/javascript; charset=utf-8", r = "community", s = Object.freeze({
2
+ cs: (t) => t ? `Novinky v komunitě ${t}` : "Novinky v komunitě",
3
+ en: (t) => t ? `News in the ${t} community` : "News in the community"
4
+ });
5
+ function a(t, e) {
6
+ const n = typeof t == "string" && /^cs(?:-|$)/i.test(t) ? "cs" : "en", i = typeof e == "string" && e.trim() !== "" ? e.trim() : null;
7
+ return s[n](i);
8
+ }
9
+ const l = 120;
10
+ function o(t, e) {
11
+ if (typeof t != "string" || !/^\/(?!\/)[^\s\\]*$/.test(t) || t.length > 512)
12
+ throw new TypeError(`communityServiceWorkerSource: ${e} must be a path on this site (starting with a single /)`);
13
+ return t;
14
+ }
15
+ function u(t) {
16
+ return JSON.stringify(t).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
17
+ }
18
+ function m(t) {
19
+ const e = o(t?.centrePath, "centrePath"), n = t.icon == null ? null : o(t.icon, "icon"), i = t.badge == null ? null : o(t.badge, "badge"), c = { title: (typeof t.badgeText == "string" && t.badgeText.trim() !== "" ? t.badgeText : a(t.locale, t.tenant)).replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, l), centre: e, tag: r, icon: n, badge: i };
20
+ return `/* @blogmcp/sdk/community/sw — generated; a push shows one generic notification, a click opens the centre. */
21
+ 'use strict';
22
+ const CONFIG = ${u(c)};
23
+
24
+ self.addEventListener('push', (event) => {
25
+ // The payload is {"t":"community"}: only t is read, and nothing shown depends on it.
26
+ let t = null;
27
+ try {
28
+ const data = event.data ? event.data.json() : null;
29
+ t = data && typeof data.t === 'string' ? data.t : null;
30
+ } catch (err) {
31
+ t = null;
32
+ }
33
+ const options = { tag: CONFIG.tag, renotify: false, data: { kind: t === 'community' ? 'community' : 'other' } };
34
+ if (CONFIG.icon) options.icon = CONFIG.icon;
35
+ if (CONFIG.badge) options.badge = CONFIG.badge;
36
+ event.waitUntil(self.registration.showNotification(CONFIG.title, options));
37
+ });
38
+
39
+ self.addEventListener('notificationclick', (event) => {
40
+ event.notification.close();
41
+ const target = new URL(CONFIG.centre, self.registration.scope).href;
42
+ event.waitUntil(
43
+ self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windows) => {
44
+ for (const w of windows) {
45
+ if (w.url === target && 'focus' in w) return w.focus();
46
+ }
47
+ return self.clients.openWindow(target);
48
+ }),
49
+ );
50
+ });
51
+ `;
52
+ }
53
+ export {
54
+ s as COMMUNITY_PUSH_TEXTS,
55
+ d as COMMUNITY_SW_CONTENT_TYPE,
56
+ r as COMMUNITY_SW_TAG,
57
+ a as communityPushText,
58
+ m as communityServiceWorkerSource
59
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The one user-agent sniff of the SDK (community M2, slice T4; docs/internal/m2-contracts.md §3.4): Facebook's and
3
+ * Instagram's in-app browsers cannot take web push, so `<blogmcp-member-settings>` offers „Otevřít v prohlížeči"
4
+ * with the page's URL instead of „Zapnout upozornění". Nothing else in the SDK reads the user agent
5
+ * (test/community/ua.spec.ts pins it).
6
+ *
7
+ * Browser-safe: reads `navigator.userAgent` only when no string is given (and `navigator` exists).
8
+ */
9
+ /** The in-app browsers' markers: FBAN / FBAV (Facebook, Messenger) and Instagram. */
10
+ export declare const IN_APP_BROWSER_RE: RegExp;
11
+ /** Whether the page runs in Facebook's or Instagram's in-app browser. */
12
+ export declare function isInAppBrowser(userAgent?: string | null): boolean;
@@ -0,0 +1,9 @@
1
+ const r = /FBAN|FBAV|Instagram/;
2
+ function e(t) {
3
+ const n = typeof t == "string" ? t : typeof navigator < "u" && typeof navigator.userAgent == "string" ? navigator.userAgent : "";
4
+ return r.test(n);
5
+ }
6
+ export {
7
+ r as IN_APP_BROWSER_RE,
8
+ e as isInAppBrowser
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogmcp/sdk",
3
- "version": "0.9.4",
3
+ "version": "0.10.1",
4
4
  "description": "Headless SDK for Knowledge Base blog — core client, Vue composables, Nuxt adapter",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -47,6 +47,18 @@
47
47
  "./community/server": {
48
48
  "types": "./dist/community/server/index.d.ts",
49
49
  "import": "./dist/community/server/index.js"
50
+ },
51
+ "./community/sw": {
52
+ "types": "./dist/community/sw/index.d.ts",
53
+ "import": "./dist/community/sw/index.js"
54
+ },
55
+ "./community/manifest": {
56
+ "types": "./dist/community/manifest/index.d.ts",
57
+ "import": "./dist/community/manifest/index.js"
58
+ },
59
+ "./community/realtime": {
60
+ "types": "./dist/community/realtime/index.d.ts",
61
+ "import": "./dist/community/realtime/index.js"
50
62
  }
51
63
  },
52
64
  "main": "./dist/core/index.js",
@@ -66,11 +78,15 @@
66
78
  "postpack": "node scripts/postpack.mjs"
67
79
  },
68
80
  "peerDependencies": {
81
+ "centrifuge": ">=5.7.0",
69
82
  "react": ">=18",
70
83
  "react-dom": ">=18",
71
84
  "vue": "^3.4.0"
72
85
  },
73
86
  "peerDependenciesMeta": {
87
+ "centrifuge": {
88
+ "optional": true
89
+ },
74
90
  "react": {
75
91
  "optional": true
76
92
  },
@@ -82,8 +98,8 @@
82
98
  }
83
99
  },
84
100
  "dependencies": {
85
- "@blogmcp/mdx-schema": "^0.9.4",
86
- "@blogmcp/sanitize": "^0.9.4",
101
+ "@blogmcp/mdx-schema": "^0.10.1",
102
+ "@blogmcp/sanitize": "^0.10.1",
87
103
  "marked": "^15.0.7"
88
104
  },
89
105
  "optionalDependencies": {
@@ -96,6 +112,7 @@
96
112
  "@types/react-dom": "^18.3.0",
97
113
  "@vitejs/plugin-vue": "^6.0.0",
98
114
  "@vue/test-utils": "^2.4.0",
115
+ "centrifuge": "^5.8.0",
99
116
  "graphql": "^16.12.0",
100
117
  "happy-dom": "^17.4.0",
101
118
  "jsdom": "^25.0.1 || ^26.0.0 || ^27.0.0 || ^28.0.0 || ^29.0.0 || ^30.0.0",
@@ -1,12 +1,13 @@
1
1
  /**
2
- * The realtime channel names, reserved now so the later realtime (M2) adds on without renaming anything
3
- * (docs/internal/m1-contracts.md §10.2; community.md §3.7, §7.4). Constants only: M1 opens no socket — a
4
- * discussion is kept fresh by pollDiscussionHead.
2
+ * The realtime channel names (docs/internal/m2-contracts.md §3.5; community.md §3.7, §7.4). Centrifugo v6 refuses
3
+ * one-letter namespace names (`^[-a-zA-Z0-9_.]{2,}$`), so M1's reserved `d:` and `u:` became `disc:` and `user:`
4
+ * before anything used them.
5
5
  *
6
- * `d:<conversationId>` carries a public discussion's projection; `u:inbox` is the member's own channel (ids and
7
- * codes only, community.md invariant 6).
6
+ * `disc:<conversationId>` carries a public discussion's projection (`@blogmcp/sdk/community/realtime` subscribes to
7
+ * it); `user:` is reserved for the member's own inbox of the private surfaces (ids and codes only, invariant 6) —
8
+ * nothing mints a token for it in M2.
8
9
  */
9
10
  export const COMMUNITY_CHANNELS = Object.freeze({
10
- discussion: (conversationId: string): string => `d:${conversationId}`,
11
- inbox: 'u:inbox',
11
+ discussion: (conversationId: string): string => `disc:${conversationId}`,
12
+ inbox: 'user:inbox',
12
13
  } as const)
@@ -38,6 +38,18 @@ import {
38
38
  type KnownNeed,
39
39
  type LegalTextKind,
40
40
  type MemberExport,
41
+ type MemberSettings,
42
+ type MemberSettingsUpdate,
43
+ type MuteEntry,
44
+ type MuteTargetKind,
45
+ type NotificationListInput,
46
+ type PushStatusAnswer,
47
+ type PushSubscribeAnswer,
48
+ type PushSubscribeInput,
49
+ type PushUnsubscribeAnswer,
50
+ type PushVapidKey,
51
+ type RealtimeSubscribeToken,
52
+ type RealtimeToken,
41
53
  type MessageEditInput,
42
54
  type MessagePostInput,
43
55
  type MessageReportInput,
@@ -120,8 +132,48 @@ export interface CommunityClient {
120
132
  onboard: Call<OnboardInput, MyState>
121
133
  updateProfile: Call<ProfileUpdateInput, { profile: OwnProfile }>
122
134
  notifications: {
123
- list: CallOptionalInput<{ cursor?: string | null }, CommunityPage<NotificationItem>>
124
- markRead: Call<{ ids: readonly string[] }, { updated: number }>
135
+ /** Newest first; M2 T3: `unreadOnly`, `codes` filter the centre. */
136
+ list: CallOptionalInput<NotificationListInput, CommunityPage<NotificationItem>>
137
+ /** The given ids, or `{ all: true }`: every unread one of the member's. */
138
+ markRead: Call<{ ids: readonly string[] } | { all: true }, { updated: number }>
139
+ /** M2 T3: the badge's number — a count only (poll it every 60 s while the page is visible). */
140
+ unreadCount: CallNoInput<{ count: number }>
141
+ }
142
+ /** M2 T3: the member's notification switches. */
143
+ settings: {
144
+ get: CallNoInput<{ settings: MemberSettings }>
145
+ /** The switches given change; the others keep their value. */
146
+ update: Call<MemberSettingsUpdate, { settings: MemberSettings }>
147
+ /**
148
+ * The digest's unsubscribe link (the `kbun_` token from the mail link's fragment): no session needed — it can
149
+ * only switch that member's digest off. A forged or stale token is `invalid`.
150
+ */
151
+ unsubscribeDigest: Call<{ token: string }, { unsubscribed: true }>
152
+ }
153
+ /** M2 T3: private, one-sided mutes — a muted discussion or member sends the member no notification. */
154
+ mutes: {
155
+ set: Call<{ targetKind: MuteTargetKind; targetId: string; muted: boolean }, { targetKind: MuteTargetKind; targetId: string; muted: boolean }>
156
+ list: CallNoInput<{ items: MuteEntry[] }>
157
+ }
158
+ /**
159
+ * M2 T4: web push — the VAPID key for `pushManager.subscribe`, the browser's subscription, its removal. Only
160
+ * after the member's click („Zapnout upozornění"), never on page load. An endpoint kb-api will not send to is
161
+ * `pushRefused`; more than 10 browsers, or too many new ones today, `quota`. `unsubscribe` is never refused.
162
+ * `status` (M2 T10, D-M2-10): whether kb-api still holds this browser's subscription (its `endpoint`) for the
163
+ * member viewing — read on load before the switch shows on; it never answers an endpoint and never subscribes.
164
+ */
165
+ push: {
166
+ vapid: CallNoInput<PushVapidKey>
167
+ subscribe: Call<PushSubscribeInput, PushSubscribeAnswer>
168
+ unsubscribe: Call<{ endpoint: string }, PushUnsubscribeAnswer>
169
+ status: Call<{ endpoint: string }, PushStatusAnswer>
170
+ }
171
+ /**
172
+ * M2 T5: the token community-rt takes and the URL to connect to (`realtimeOff` outside a live or braked module,
173
+ * or where live updates are not configured: poll instead). `@blogmcp/sdk/community/realtime` calls it.
174
+ */
175
+ realtime: {
176
+ token: CallNoInput<RealtimeToken>
125
177
  }
126
178
  decisions: {
127
179
  list: CallOptionalInput<{ cursor?: string | null }, CommunityPage<DecisionSummary>>
@@ -149,6 +201,10 @@ export interface CommunityClient {
149
201
  legal: {
150
202
  current: Call<{ kind: LegalTextKind; locale: string }, CurrentLegalText>
151
203
  }
204
+ /** M2 T5: a channel's token — `disc:<conversationId>` of a discussion the viewer may read, else `notFound`. */
205
+ realtime: {
206
+ subscribeToken: Call<{ channel: string }, RealtimeSubscribeToken>
207
+ }
152
208
  notices: {
153
209
  /** Anyone, with or without a session; `confirmations` must hold COMMUNITY_GOOD_FAITH. */
154
210
  submit: Call<NoticeSubmitInput, NoticeReceipt>
@@ -219,6 +275,18 @@ export const COMMUNITY_ANSWER_FIELDS: Readonly<Record<CommunityOpName, Readonly<
219
275
  'me.updateProfile': fieldsOfAnswer({ profile: 'record' }),
220
276
  'me.notifications.list': fieldsOfAnswer({ items: 'array' }),
221
277
  'me.notifications.markRead': fieldsOfAnswer({ updated: 'number' }),
278
+ 'me.notifications.unreadCount': fieldsOfAnswer({ count: 'number' }),
279
+ 'me.settings.get': fieldsOfAnswer({ settings: 'record' }),
280
+ 'me.settings.update': fieldsOfAnswer({ settings: 'record' }),
281
+ 'me.settings.unsubscribeDigest': fieldsOfAnswer({ unsubscribed: 'boolean' }),
282
+ 'me.mutes.set': fieldsOfAnswer({ muted: 'boolean' }),
283
+ 'me.mutes.list': fieldsOfAnswer({ items: 'array' }),
284
+ 'me.push.vapid': fieldsOfAnswer({ publicKey: 'string', keyId: 'string' }),
285
+ 'me.push.subscribe': fieldsOfAnswer({ subscribed: 'boolean', keyId: 'string' }),
286
+ 'me.push.unsubscribe': fieldsOfAnswer({ unsubscribed: 'boolean' }),
287
+ 'me.push.status': fieldsOfAnswer({ subscribed: 'boolean' }),
288
+ 'me.realtime.token': fieldsOfAnswer({ token: 'string', url: 'string', expiresInS: 'number' }),
289
+ 'realtime.subscribeToken': fieldsOfAnswer({ token: 'string' }),
222
290
  'me.decisions.list': fieldsOfAnswer({ items: 'array' }),
223
291
  'me.decisions.get': fieldsOfAnswer({ decisionId: 'string' }),
224
292
  'me.appeals.file': fieldsOfAnswer({ appealId: 'string' }),
@@ -275,6 +343,13 @@ function fieldsOf(value: unknown): string[] | undefined {
275
343
  return paths.slice(0, MAX_LIST)
276
344
  }
277
345
 
346
+ /** The codes of a VALIDATION's issues (`{ path, code }`), as codes; an issue without one gives none. */
347
+ function issueCodesOf(value: unknown): string[] | undefined {
348
+ if (!isArray(value)) return undefined
349
+ const codes = value.map((i) => (isRecord(i) ? i.code : undefined)).filter((c): c is string => isString(c) && CODE_RE.test(c))
350
+ return codes.length > 0 ? [...new Set(codes)].slice(0, MAX_LIST) : undefined
351
+ }
352
+
278
353
  function secondsOf(value: unknown): number | undefined {
279
354
  return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.ceil(value) : undefined
280
355
  }
@@ -291,6 +366,8 @@ function refusalOf(body: Rec, answer: CommunityTransportAnswer): CommunityFailur
291
366
  if (isString(body.until)) out.until = body.until
292
367
  const fields = fieldsOf(body.issues)
293
368
  if (fields) out.fields = fields
369
+ const issueCodes = issueCodesOf(body.issues)
370
+ if (issueCodes) out.issueCodes = issueCodes
294
371
  return out
295
372
  }
296
373
 
@@ -392,12 +469,43 @@ export function createCommunityClient(config: CommunityClientConfig): CommunityC
392
469
  },
393
470
  me: {
394
471
  get: empty('me.get'),
395
- onboard: fields('me.onboard', ['ageBand', 'rulesTextId', 'art9TextId', 'displayName', 'handle', 'avatarPreset']),
472
+ onboard: fields('me.onboard', ['ageBand', 'rulesTextId', 'art9TextId', 'art9Refused', 'displayName', 'handle', 'avatarPreset']),
396
473
  updateProfile: fields('me.updateProfile', ['displayName', 'handle', 'avatarPreset', 'bio']),
397
474
  notifications: {
398
- list: fields('me.notifications.list', ['cursor']),
475
+ list: fields('me.notifications.list', ['cursor', 'unreadOnly', 'codes']),
399
476
  markRead: (input, options) =>
400
- call('me.notifications.markRead', { ids: isRecord(input) && isArray(input.ids) ? [...input.ids] : [] }, options),
477
+ call(
478
+ 'me.notifications.markRead',
479
+ isRecord(input) && 'all' in input ? { all: input.all } : { ids: isRecord(input) && isArray(input.ids) ? [...input.ids] : [] },
480
+ options,
481
+ ),
482
+ unreadCount: empty('me.notifications.unreadCount'),
483
+ },
484
+ settings: {
485
+ get: empty('me.settings.get'),
486
+ update: fields('me.settings.update', ['notifyReply', 'notifyMention', 'notifyTopic', 'pushEnabled', 'digestEmail', 'quietHours']),
487
+ unsubscribeDigest: fields('me.settings.unsubscribeDigest', ['token']),
488
+ },
489
+ mutes: {
490
+ set: fields('me.mutes.set', ['targetKind', 'targetId', 'muted']),
491
+ list: empty('me.mutes.list'),
492
+ },
493
+ push: {
494
+ vapid: empty('me.push.vapid'),
495
+ subscribe: (input, options) =>
496
+ call(
497
+ 'me.push.subscribe',
498
+ {
499
+ ...pick(input, ['endpoint', 'userAgentClass']),
500
+ ...(isRecord(input) && isRecord(input.keys) ? { keys: pick(input.keys, ['p256dh', 'auth']) } : {}),
501
+ },
502
+ options,
503
+ ),
504
+ unsubscribe: fields('me.push.unsubscribe', ['endpoint']),
505
+ status: fields('me.push.status', ['endpoint']),
506
+ },
507
+ realtime: {
508
+ token: empty('me.realtime.token'),
401
509
  },
402
510
  decisions: {
403
511
  list: fields('me.decisions.list', ['cursor']),
@@ -421,6 +529,9 @@ export function createCommunityClient(config: CommunityClientConfig): CommunityC
421
529
  legal: {
422
530
  current: fields('legal.current', ['kind', 'locale']),
423
531
  },
532
+ realtime: {
533
+ subscribeToken: fields('realtime.subscribeToken', ['channel']),
534
+ },
424
535
  notices: {
425
536
  submit: (input, options) => {
426
537
  const body = pick(input, ['category', 'target', 'description', 'ruleId', 'turnstileToken', 'confirmations'])
@@ -7,7 +7,9 @@
7
7
  * createDiscussionStore the immutable two-level thread, optimistic writes, open enums skipped;
8
8
  * pollDiscussionHead the polling signal while the discussion is visible (no realtime in M1);
9
9
  * communityMessage every text, cs and en, under the tone test;
10
- * links statements, the panel, the notifier's receipt in the fragment.
10
+ * links statements, the panel, the notifier's receipt in the fragment; M2: profiles, the
11
+ * module's pages and the digest's unsubscribe token in the fragment;
12
+ * communityMentionSpans `@handle` in a body as text spans a page links (never HTML).
11
13
  *
12
14
  * Browser-safe: nothing here takes a key, a session, a cookie or an IP, and nothing imports `node:*`. This entry
13
15
  * never reaches the server entries (`@blogmcp/sdk/community/server`, `@blogmcp/sdk/consultations/server`), the
@@ -65,6 +67,8 @@ export type {
65
67
  } from './outcome'
66
68
 
67
69
  export { fetchTransport, isRelativeCommunityBase, assertCommunityBase, communityOpUrl } from './transport'
70
+ // M2 T4 (m2-contracts.md §3.4): the one user-agent sniff — Facebook's and Instagram's in-app browsers take no push.
71
+ export { isInAppBrowser, IN_APP_BROWSER_RE } from './ua'
68
72
  export type { CommunityTransport, CommunityTransportAnswer, FetchTransportOptions } from './transport'
69
73
 
70
74
  export {
@@ -73,6 +77,10 @@ export {
73
77
  NEEDS,
74
78
  RESTRICTION_KINDS,
75
79
  NOTIFICATION_CODES,
80
+ MODULE_STATES,
81
+ MUTE_TARGET_KINDS,
82
+ PUSH_USER_AGENT_CLASSES,
83
+ REALTIME_EVENT_KINDS,
76
84
  CASE_CATEGORIES,
77
85
  CATEGORY_WITHOUT_NOTIFIER,
78
86
  AGE_BANDS,
@@ -83,9 +91,18 @@ export {
83
91
  isKnownNeed,
84
92
  isKnownRestrictionKind,
85
93
  isKnownNotificationCode,
94
+ isKnownModuleState,
86
95
  isCaseCategory,
87
96
  communityRulesOf,
88
97
  communityLegalSectionsOf,
98
+ ART9_CONSENT_LAYOUTS,
99
+ ART9_REFUSALS,
100
+ ART9_CONTROLLERS_MAX,
101
+ art9ConsentLayoutOf,
102
+ art9RefusalOf,
103
+ art9ControllersOf,
104
+ TRUST_LABELS,
105
+ isKnownTrustLabel,
89
106
  } from './shapes'
90
107
  export type {
91
108
  KnownMessageState,
@@ -98,6 +115,27 @@ export type {
98
115
  RestrictionKind,
99
116
  KnownNotificationCode,
100
117
  NotificationCode,
118
+ KnownModuleState,
119
+ ModuleState,
120
+ KnownTrustLabel,
121
+ TrustLabel,
122
+ ModuleInfo,
123
+ MemberSettings,
124
+ MemberSettingsUpdate,
125
+ MuteEntry,
126
+ MuteTargetKind,
127
+ NotificationListInput,
128
+ PushUserAgentClass,
129
+ PushVapidKey,
130
+ RealtimeToken,
131
+ RealtimeSubscribeToken,
132
+ RealtimeEvent,
133
+ RealtimeEventKind,
134
+ PushSubscribeInput,
135
+ PushSubscribeAnswer,
136
+ PushUnsubscribeAnswer,
137
+ PushStatusAnswer,
138
+ MemberCaps,
101
139
  CaseCategory,
102
140
  AgeBand,
103
141
  LegalTextKind,
@@ -131,6 +169,10 @@ export type {
131
169
  CurrentLegalText,
132
170
  CommunityRule,
133
171
  CommunityLegalSection,
172
+ Art9ConsentLayout,
173
+ Art9Refusal,
174
+ Art9Controller,
175
+ CommunityConsentSettings,
134
176
  MemberExport,
135
177
  NoticeTarget,
136
178
  NoticeReceipt,
@@ -156,6 +198,7 @@ export {
156
198
  } from './store'
157
199
  export type {
158
200
  DiscussionStore,
201
+ RealtimeEventOutcome,
159
202
  DiscussionState,
160
203
  DiscussionMessage,
161
204
  DiscussionViewer,
@@ -178,8 +221,21 @@ export {
178
221
  signInLink,
179
222
  receiptFromHash,
180
223
  readReceiptFromHash,
224
+ profilePath,
225
+ COMMUNITY_MESSAGE_ANCHOR_PREFIX,
226
+ communityMessageAnchor,
227
+ communityMessageSeqFromHash,
228
+ communityMessageLink,
229
+ COMMUNITY_DIGEST_TOKEN_RE,
230
+ digestTokenFromHash,
231
+ readDigestTokenFromHash,
232
+ forgetDigestToken,
181
233
  } from './links'
182
234
 
235
+ // M2 T8 (m2-contracts.md §3.3): `@handle` in a body as spans — text, and mentions a page links to profilePath.
236
+ export { COMMUNITY_MENTION_RE, communityMentionSpans, communityMentionHandles } from './mentions'
237
+ export type { CommunityTextSpan } from './mentions'
238
+
183
239
  export {
184
240
  COMMUNITY_MESSAGES,
185
241
  communityMessage,
@@ -188,5 +244,7 @@ export {
188
244
  warningMessageKey,
189
245
  confirmMessageKey,
190
246
  noteMessageKey,
247
+ notificationMessageKey,
248
+ trustLabelMessageKey,
191
249
  } from './messages'
192
250
  export type { CommunityMessageKey, CommunityMessageLanguage } from './messages'