@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
@@ -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 declare const COMMUNITY_CHANNELS: Readonly<{
10
11
  readonly discussion: (conversationId: string) => string;
11
- readonly inbox: "u:inbox";
12
+ readonly inbox: "user:inbox";
12
13
  }>;
@@ -1,7 +1,7 @@
1
- const o = Object.freeze({
2
- discussion: (e) => `d:${e}`,
3
- inbox: "u:inbox"
1
+ const s = Object.freeze({
2
+ discussion: (e) => `disc:${e}`,
3
+ inbox: "user:inbox"
4
4
  });
5
5
  export {
6
- o as COMMUNITY_CHANNELS
6
+ s as COMMUNITY_CHANNELS
7
7
  };
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import { type CommunityLogger, type CommunityOutcome } from './outcome.js';
18
18
  import { type CommunityOpName } from './routes.js';
19
- import { type AppealItem, type BlockEntry, type CommunityPage, type CurrentLegalText, type DecisionSummary, type Discussion, type DiscussionHead, type DiscussionListInput, type LegalTextKind, type MemberExport, type MessageEditInput, type MessagePostInput, type MessageReportInput, type MyState, type NoticeReceipt, type NoticeStatus, type NoticeSubmitInput, type NotificationItem, type OnboardInput, type OwnProfile, type ProfileUpdateInput, type PublicMessage, type PublicProfile, type ReactionSummary, type ReactionTarget, type ReportItem, type Statement, type WriteAnswer } from './shapes.js';
19
+ import { type AppealItem, type BlockEntry, type CommunityPage, type CurrentLegalText, type DecisionSummary, type Discussion, type DiscussionHead, type DiscussionListInput, type LegalTextKind, type MemberExport, type MemberSettings, type MemberSettingsUpdate, type MuteEntry, type MuteTargetKind, type NotificationListInput, type PushStatusAnswer, type PushSubscribeAnswer, type PushSubscribeInput, type PushUnsubscribeAnswer, type PushVapidKey, type RealtimeSubscribeToken, type RealtimeToken, type MessageEditInput, type MessagePostInput, type MessageReportInput, type MyState, type NoticeReceipt, type NoticeStatus, type NoticeSubmitInput, type NotificationItem, type OnboardInput, type OwnProfile, type ProfileUpdateInput, type PublicMessage, type PublicProfile, type ReactionSummary, type ReactionTarget, type ReportItem, type Statement, type WriteAnswer } from './shapes.js';
20
20
  import { type CommunityTransport } from './transport.js';
21
21
  export interface CommunityClientConfig {
22
22
  /**
@@ -107,14 +107,78 @@ export interface CommunityClient {
107
107
  profile: OwnProfile;
108
108
  }>;
109
109
  notifications: {
110
- list: CallOptionalInput<{
111
- cursor?: string | null;
112
- }, CommunityPage<NotificationItem>>;
110
+ /** Newest first; M2 T3: `unreadOnly`, `codes` filter the centre. */
111
+ list: CallOptionalInput<NotificationListInput, CommunityPage<NotificationItem>>;
112
+ /** The given ids, or `{ all: true }`: every unread one of the member's. */
113
113
  markRead: Call<{
114
114
  ids: readonly string[];
115
+ } | {
116
+ all: true;
115
117
  }, {
116
118
  updated: number;
117
119
  }>;
120
+ /** M2 T3: the badge's number — a count only (poll it every 60 s while the page is visible). */
121
+ unreadCount: CallNoInput<{
122
+ count: number;
123
+ }>;
124
+ };
125
+ /** M2 T3: the member's notification switches. */
126
+ settings: {
127
+ get: CallNoInput<{
128
+ settings: MemberSettings;
129
+ }>;
130
+ /** The switches given change; the others keep their value. */
131
+ update: Call<MemberSettingsUpdate, {
132
+ settings: MemberSettings;
133
+ }>;
134
+ /**
135
+ * The digest's unsubscribe link (the `kbun_` token from the mail link's fragment): no session needed — it can
136
+ * only switch that member's digest off. A forged or stale token is `invalid`.
137
+ */
138
+ unsubscribeDigest: Call<{
139
+ token: string;
140
+ }, {
141
+ unsubscribed: true;
142
+ }>;
143
+ };
144
+ /** M2 T3: private, one-sided mutes — a muted discussion or member sends the member no notification. */
145
+ mutes: {
146
+ set: Call<{
147
+ targetKind: MuteTargetKind;
148
+ targetId: string;
149
+ muted: boolean;
150
+ }, {
151
+ targetKind: MuteTargetKind;
152
+ targetId: string;
153
+ muted: boolean;
154
+ }>;
155
+ list: CallNoInput<{
156
+ items: MuteEntry[];
157
+ }>;
158
+ };
159
+ /**
160
+ * M2 T4: web push — the VAPID key for `pushManager.subscribe`, the browser's subscription, its removal. Only
161
+ * after the member's click („Zapnout upozornění"), never on page load. An endpoint kb-api will not send to is
162
+ * `pushRefused`; more than 10 browsers, or too many new ones today, `quota`. `unsubscribe` is never refused.
163
+ * `status` (M2 T10, D-M2-10): whether kb-api still holds this browser's subscription (its `endpoint`) for the
164
+ * member viewing — read on load before the switch shows on; it never answers an endpoint and never subscribes.
165
+ */
166
+ push: {
167
+ vapid: CallNoInput<PushVapidKey>;
168
+ subscribe: Call<PushSubscribeInput, PushSubscribeAnswer>;
169
+ unsubscribe: Call<{
170
+ endpoint: string;
171
+ }, PushUnsubscribeAnswer>;
172
+ status: Call<{
173
+ endpoint: string;
174
+ }, PushStatusAnswer>;
175
+ };
176
+ /**
177
+ * M2 T5: the token community-rt takes and the URL to connect to (`realtimeOff` outside a live or braked module,
178
+ * or where live updates are not configured: poll instead). `@blogmcp/sdk/community/realtime` calls it.
179
+ */
180
+ realtime: {
181
+ token: CallNoInput<RealtimeToken>;
118
182
  };
119
183
  decisions: {
120
184
  list: CallOptionalInput<{
@@ -174,6 +238,12 @@ export interface CommunityClient {
174
238
  locale: string;
175
239
  }, CurrentLegalText>;
176
240
  };
241
+ /** M2 T5: a channel's token — `disc:<conversationId>` of a discussion the viewer may read, else `notFound`. */
242
+ realtime: {
243
+ subscribeToken: Call<{
244
+ channel: string;
245
+ }, RealtimeSubscribeToken>;
246
+ };
177
247
  notices: {
178
248
  /** Anyone, with or without a session; `confirmations` must hold COMMUNITY_GOOD_FAITH. */
179
249
  submit: Call<NoticeSubmitInput, NoticeReceipt>;
@@ -1,20 +1,20 @@
1
- import { communityFailureOf as j, isLoggedCommunityOutcome as x, communityOutcomeOf as L } from "./outcome.js";
2
- import { COMMUNITY_OPS as P } from "./routes.js";
3
- import { isKnownNeed as R } from "./shapes.js";
4
- import { assertCommunityBase as q, fetchTransport as F } from "./transport.js";
5
- const _ = 1e4, U = 2147483647;
1
+ import { communityFailureOf as R, isLoggedCommunityOutcome as j, communityOutcomeOf as D } from "./outcome.js";
2
+ import { COMMUNITY_OPS as L } from "./routes.js";
3
+ import { isKnownNeed as q } from "./shapes.js";
4
+ import { assertCommunityBase as P, fetchTransport as F } from "./transport.js";
5
+ const M = 1e4, U = 2147483647;
6
6
  let E = !1;
7
7
  function z(e) {
8
- if (e === void 0) return _;
8
+ if (e === void 0) return M;
9
9
  const n = typeof e == "number" ? Math.floor(e) : Number.NaN;
10
- return n >= 1 && n <= U ? n : (E || (E = !0, console.warn("[community] timeoutMs is not a number of milliseconds from 1 to 2147483647 — the default 10 s is used.")), _);
10
+ return n >= 1 && n <= U ? n : (E || (E = !0, console.warn("[community] timeoutMs is not a number of milliseconds from 1 to 2147483647 — the default 10 s is used.")), M);
11
11
  }
12
- const d = (e) => typeof e == "object" && e !== null && !Array.isArray(e), A = (e) => typeof e == "string", I = Array.isArray, D = Object.freeze({
13
- string: A,
12
+ const c = (e) => typeof e == "object" && e !== null && !Array.isArray(e), I = (e) => typeof e == "string", h = Array.isArray, K = Object.freeze({
13
+ string: I,
14
14
  number: (e) => typeof e == "number",
15
15
  boolean: (e) => typeof e == "boolean",
16
- array: I,
17
- record: d
16
+ array: h,
17
+ record: c
18
18
  }), s = (e) => Object.freeze({ ...e }), B = Object.freeze({
19
19
  "discussions.list": s({ articleId: "string", messages: "array", viewer: "record" }),
20
20
  "discussions.head": s({ heads: "array" }),
@@ -31,6 +31,18 @@ const d = (e) => typeof e == "object" && e !== null && !Array.isArray(e), A = (e
31
31
  "me.updateProfile": s({ profile: "record" }),
32
32
  "me.notifications.list": s({ items: "array" }),
33
33
  "me.notifications.markRead": s({ updated: "number" }),
34
+ "me.notifications.unreadCount": s({ count: "number" }),
35
+ "me.settings.get": s({ settings: "record" }),
36
+ "me.settings.update": s({ settings: "record" }),
37
+ "me.settings.unsubscribeDigest": s({ unsubscribed: "boolean" }),
38
+ "me.mutes.set": s({ muted: "boolean" }),
39
+ "me.mutes.list": s({ items: "array" }),
40
+ "me.push.vapid": s({ publicKey: "string", keyId: "string" }),
41
+ "me.push.subscribe": s({ subscribed: "boolean", keyId: "string" }),
42
+ "me.push.unsubscribe": s({ unsubscribed: "boolean" }),
43
+ "me.push.status": s({ subscribed: "boolean" }),
44
+ "me.realtime.token": s({ token: "string", url: "string", expiresInS: "number" }),
45
+ "realtime.subscribeToken": s({ token: "string" }),
34
46
  "me.decisions.list": s({ items: "array" }),
35
47
  "me.decisions.get": s({ decisionId: "string" }),
36
48
  "me.appeals.file": s({ appealId: "string" }),
@@ -46,143 +58,183 @@ const d = (e) => typeof e == "object" && e !== null && !Array.isArray(e), A = (e
46
58
  "notices.status": s({ status: "string" }),
47
59
  "notices.appeal": s({ appealId: "string" }),
48
60
  "notices.withdrawAppeal": s({ appealId: "string" })
49
- }), W = (e, n) => Object.entries(B[e]).every(([r, c]) => D[c](n[r]));
61
+ }), W = (e, n) => Object.entries(B[e]).every(([r, u]) => K[u](n[r]));
50
62
  function m(e, n) {
51
63
  const r = {};
52
- if (!d(e)) return r;
53
- for (const c of n) e[c] !== void 0 && (r[c] = e[c]);
64
+ if (!c(e)) return r;
65
+ for (const u of n) e[u] !== void 0 && (r[u] = e[u]);
54
66
  return r;
55
67
  }
56
- function C(e) {
57
- return d(e) ? "conversationId" in e ? m(e, ["conversationId", "seq"]) : "memberId" in e ? m(e, ["memberId"]) : "handle" in e ? m(e, ["handle"]) : m(e, ["articleId"]) : e;
68
+ function _(e) {
69
+ return c(e) ? "conversationId" in e ? m(e, ["conversationId", "seq"]) : "memberId" in e ? m(e, ["memberId"]) : "handle" in e ? m(e, ["handle"]) : m(e, ["articleId"]) : e;
70
+ }
71
+ const N = /^[A-Za-z0-9_.:-]{1,64}$/, S = 20;
72
+ function X(e) {
73
+ if (h(e))
74
+ return e.filter((n) => I(n) && N.test(n)).slice(0, S);
58
75
  }
59
- const X = /^[A-Za-z0-9_.:-]{1,64}$/, S = 20;
60
76
  function Y(e) {
61
- if (I(e))
62
- return e.filter((n) => A(n) && X.test(n)).slice(0, S);
77
+ return h(e) ? e.filter(q).slice(0, S) : void 0;
63
78
  }
64
- function K(e) {
65
- return I(e) ? e.filter(R).slice(0, S) : void 0;
79
+ function H(e) {
80
+ return h(e) ? e.map((r) => c(r) ? r.path : r).filter((r) => I(r) && r.length <= 128).slice(0, S) : void 0;
66
81
  }
67
82
  function Z(e) {
68
- return I(e) ? e.map((r) => d(r) ? r.path : r).filter((r) => A(r) && r.length <= 128).slice(0, S) : void 0;
83
+ if (!h(e)) return;
84
+ const n = e.map((r) => c(r) ? r.code : void 0).filter((r) => I(r) && N.test(r));
85
+ return n.length > 0 ? [...new Set(n)].slice(0, S) : void 0;
69
86
  }
70
87
  function v(e) {
71
88
  return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.ceil(e) : void 0;
72
89
  }
73
90
  function $(e, n) {
74
- const r = { ok: !1, code: L(e.code) }, c = v(e.retryAfterS) ?? v(n.retryAfterS);
75
- c !== void 0 && (r.retryAfterS = c);
76
- const p = K(e.needs);
77
- p && (r.needs = p);
78
- const l = Y(e.codes);
79
- l && (r.codes = l), A(e.until) && (r.until = e.until);
80
- const o = Z(e.issues);
81
- return o && (r.fields = o), r;
91
+ const r = { ok: !1, code: D(e.code) }, u = v(e.retryAfterS) ?? v(n.retryAfterS);
92
+ u !== void 0 && (r.retryAfterS = u);
93
+ const b = Y(e.needs);
94
+ b && (r.needs = b);
95
+ const l = X(e.codes);
96
+ l && (r.codes = l), I(e.until) && (r.until = e.until);
97
+ const i = H(e.issues);
98
+ i && (r.fields = i);
99
+ const a = Z(e.issues);
100
+ return a && (r.issueCodes = a), r;
82
101
  }
83
- function V(e) {
84
- q(e?.base);
85
- const n = e.transport ?? F(e.base, e.now ? { now: e.now } : {}), r = z(e.timeoutMs), c = e.logger, p = (t, i, a, w) => {
86
- if (!(!c || !x(i)))
102
+ function ee(e) {
103
+ P(e?.base);
104
+ const n = e.transport ?? F(e.base, e.now ? { now: e.now } : {}), r = z(e.timeoutMs), u = e.logger, b = (t, o, d, k) => {
105
+ if (!(!u || !j(o)))
87
106
  try {
88
- c({ op: t, outcome: i, kbCode: a, status: w });
107
+ u({ op: t, outcome: o, kbCode: d, status: k });
89
108
  } catch {
90
109
  }
91
110
  };
92
- async function l(t, i, a) {
93
- const w = P[t], k = new AbortController(), O = a?.signal, M = () => k.abort();
94
- O?.aborted ? k.abort() : O?.addEventListener("abort", M, { once: !0 });
95
- const N = setTimeout(() => k.abort(), r);
96
- let b;
111
+ async function l(t, o, d) {
112
+ const k = L[t], A = new AbortController(), O = d?.signal, T = () => A.abort();
113
+ O?.aborted ? A.abort() : O?.addEventListener("abort", T, { once: !0 });
114
+ const x = setTimeout(() => A.abort(), r);
115
+ let g;
97
116
  try {
98
- b = await n(w, i, k.signal);
99
- } catch (u) {
100
- const h = j(u);
101
- return O?.aborted || p(t, h.code, null, null), h;
117
+ g = await n(k, o, A.signal);
118
+ } catch (p) {
119
+ const w = R(p);
120
+ return O?.aborted || b(t, w.code, null, null), w;
102
121
  } finally {
103
- clearTimeout(N), O?.removeEventListener("abort", M);
122
+ clearTimeout(x), O?.removeEventListener("abort", T);
104
123
  }
105
- const y = typeof b?.status == "number" ? b.status : 0, f = b?.body;
106
- if (d(f) && f.ok === !1 && A(f.code) && f.code !== "") {
107
- const u = $(f, b);
108
- return p(t, u.code, f.code.slice(0, 64), y), u;
124
+ const y = typeof g?.status == "number" ? g.status : 0, f = g?.body;
125
+ if (c(f) && f.ok === !1 && I(f.code) && f.code !== "") {
126
+ const p = $(f, g);
127
+ return b(t, p.code, f.code.slice(0, 64), y), p;
109
128
  }
110
- if (y >= 200 && y < 300 && d(f) && f.ok === !0) {
111
- const { ok: u, ...h } = f;
112
- return W(t, h) ? { ok: !0, value: h } : (p(t, "unavailable", null, y), { ok: !1, code: "unavailable" });
129
+ if (y >= 200 && y < 300 && c(f) && f.ok === !0) {
130
+ const { ok: p, ...w } = f;
131
+ return W(t, w) ? { ok: !0, value: w } : (b(t, "unavailable", null, y), { ok: !1, code: "unavailable" });
113
132
  }
114
133
  if (y === 429) {
115
- const u = v(b.retryAfterS);
116
- return u === void 0 ? { ok: !1, code: "fast" } : { ok: !1, code: "fast", retryAfterS: u };
134
+ const p = v(g.retryAfterS);
135
+ return p === void 0 ? { ok: !1, code: "fast" } : { ok: !1, code: "fast", retryAfterS: p };
117
136
  }
118
- p(t, "unavailable", null, y);
119
- const T = y === 503 ? v(b.retryAfterS) : void 0;
120
- return T === void 0 ? { ok: !1, code: "unavailable" } : { ok: !1, code: "unavailable", retryAfterS: T };
137
+ b(t, "unavailable", null, y);
138
+ const C = y === 503 ? v(g.retryAfterS) : void 0;
139
+ return C === void 0 ? { ok: !1, code: "unavailable" } : { ok: !1, code: "unavailable", retryAfterS: C };
121
140
  }
122
- const o = (t, i) => (a, w) => l(t, m(a, i), w), g = (t) => (i) => l(t, {}, i);
141
+ const i = (t, o) => (d, k) => l(t, m(d, o), k), a = (t) => (o) => l(t, {}, o);
123
142
  return {
124
143
  discussions: {
125
- list: o("discussions.list", ["articleId", "languageCode", "cursor"]),
126
- head: (t, i) => l("discussions.head", { articleIds: d(t) && I(t.articleIds) ? [...t.articleIds] : [] }, i)
144
+ list: i("discussions.list", ["articleId", "languageCode", "cursor"]),
145
+ head: (t, o) => l("discussions.head", { articleIds: c(t) && h(t.articleIds) ? [...t.articleIds] : [] }, o)
127
146
  },
128
147
  messages: {
129
- post: o("messages.post", ["articleId", "body", "replyToSeq", "clientMsgId", "languageCode", "confirmations"]),
130
- edit: o("messages.edit", ["conversationId", "seq", "body", "confirmations"]),
131
- delete: o("messages.delete", ["conversationId", "seq"]),
132
- report: o("messages.report", ["conversationId", "seq", "category", "ruleId", "note"])
148
+ post: i("messages.post", ["articleId", "body", "replyToSeq", "clientMsgId", "languageCode", "confirmations"]),
149
+ edit: i("messages.edit", ["conversationId", "seq", "body", "confirmations"]),
150
+ delete: i("messages.delete", ["conversationId", "seq"]),
151
+ report: i("messages.report", ["conversationId", "seq", "category", "ruleId", "note"])
133
152
  },
134
153
  reactions: {
135
- set: (t, i) => l("reactions.set", { target: C(t?.target), emoji: t?.emoji ?? null }, i)
154
+ set: (t, o) => l("reactions.set", { target: _(t?.target), emoji: t?.emoji ?? null }, o)
136
155
  },
137
156
  blocks: {
138
- set: o("blocks.set", ["memberId", "blocked"]),
139
- list: g("blocks.list")
157
+ set: i("blocks.set", ["memberId", "blocked"]),
158
+ list: a("blocks.list")
140
159
  },
141
160
  profile: {
142
- get: (t, i) => l("profile.get", d(t) && "handle" in t ? m(t, ["handle"]) : m(t, ["memberId"]), i)
161
+ get: (t, o) => l("profile.get", c(t) && "handle" in t ? m(t, ["handle"]) : m(t, ["memberId"]), o)
143
162
  },
144
163
  me: {
145
- get: g("me.get"),
146
- onboard: o("me.onboard", ["ageBand", "rulesTextId", "art9TextId", "displayName", "handle", "avatarPreset"]),
147
- updateProfile: o("me.updateProfile", ["displayName", "handle", "avatarPreset", "bio"]),
164
+ get: a("me.get"),
165
+ onboard: i("me.onboard", ["ageBand", "rulesTextId", "art9TextId", "art9Refused", "displayName", "handle", "avatarPreset"]),
166
+ updateProfile: i("me.updateProfile", ["displayName", "handle", "avatarPreset", "bio"]),
148
167
  notifications: {
149
- list: o("me.notifications.list", ["cursor"]),
150
- markRead: (t, i) => l("me.notifications.markRead", { ids: d(t) && I(t.ids) ? [...t.ids] : [] }, i)
168
+ list: i("me.notifications.list", ["cursor", "unreadOnly", "codes"]),
169
+ markRead: (t, o) => l(
170
+ "me.notifications.markRead",
171
+ c(t) && "all" in t ? { all: t.all } : { ids: c(t) && h(t.ids) ? [...t.ids] : [] },
172
+ o
173
+ ),
174
+ unreadCount: a("me.notifications.unreadCount")
175
+ },
176
+ settings: {
177
+ get: a("me.settings.get"),
178
+ update: i("me.settings.update", ["notifyReply", "notifyMention", "notifyTopic", "pushEnabled", "digestEmail", "quietHours"]),
179
+ unsubscribeDigest: i("me.settings.unsubscribeDigest", ["token"])
180
+ },
181
+ mutes: {
182
+ set: i("me.mutes.set", ["targetKind", "targetId", "muted"]),
183
+ list: a("me.mutes.list")
184
+ },
185
+ push: {
186
+ vapid: a("me.push.vapid"),
187
+ subscribe: (t, o) => l(
188
+ "me.push.subscribe",
189
+ {
190
+ ...m(t, ["endpoint", "userAgentClass"]),
191
+ ...c(t) && c(t.keys) ? { keys: m(t.keys, ["p256dh", "auth"]) } : {}
192
+ },
193
+ o
194
+ ),
195
+ unsubscribe: i("me.push.unsubscribe", ["endpoint"]),
196
+ status: i("me.push.status", ["endpoint"])
197
+ },
198
+ realtime: {
199
+ token: a("me.realtime.token")
151
200
  },
152
201
  decisions: {
153
- list: o("me.decisions.list", ["cursor"]),
154
- get: o("me.decisions.get", ["decisionId"])
202
+ list: i("me.decisions.list", ["cursor"]),
203
+ get: i("me.decisions.get", ["decisionId"])
155
204
  },
156
205
  appeals: {
157
- file: o("me.appeals.file", ["decisionId", "body"]),
158
- withdraw: o("me.appeals.withdraw", ["appealId"]),
159
- list: g("me.appeals.list")
206
+ file: i("me.appeals.file", ["decisionId", "body"]),
207
+ withdraw: i("me.appeals.withdraw", ["appealId"]),
208
+ list: a("me.appeals.list")
160
209
  },
161
210
  reports: {
162
- list: g("me.reports.list")
211
+ list: a("me.reports.list")
163
212
  },
164
213
  consents: {
165
- withdraw: (t, i) => l("me.consents.withdraw", { kind: "art9_consent" }, i)
214
+ withdraw: (t, o) => l("me.consents.withdraw", { kind: "art9_consent" }, o)
166
215
  },
167
- export: g("me.export"),
168
- erase: g("me.erase"),
169
- cancelErase: g("me.cancelErase")
216
+ export: a("me.export"),
217
+ erase: a("me.erase"),
218
+ cancelErase: a("me.cancelErase")
170
219
  },
171
220
  legal: {
172
- current: o("legal.current", ["kind", "locale"])
221
+ current: i("legal.current", ["kind", "locale"])
222
+ },
223
+ realtime: {
224
+ subscribeToken: i("realtime.subscribeToken", ["channel"])
173
225
  },
174
226
  notices: {
175
- submit: (t, i) => {
176
- const a = m(t, ["category", "target", "description", "ruleId", "turnstileToken", "confirmations"]);
177
- return a.target !== void 0 && (a.target = C(a.target)), d(t?.notifier) ? a.notifier = m(t.notifier, ["name", "email", "locale"]) : t?.notifier === null && (a.notifier = null), l("notices.submit", a, i);
227
+ submit: (t, o) => {
228
+ const d = m(t, ["category", "target", "description", "ruleId", "turnstileToken", "confirmations"]);
229
+ return d.target !== void 0 && (d.target = _(d.target)), c(t?.notifier) ? d.notifier = m(t.notifier, ["name", "email", "locale"]) : t?.notifier === null && (d.notifier = null), l("notices.submit", d, o);
178
230
  },
179
- status: o("notices.status", ["receipt"]),
180
- appeal: o("notices.appeal", ["receipt", "body"]),
181
- withdrawAppeal: o("notices.withdrawAppeal", ["receipt"])
231
+ status: i("notices.status", ["receipt"]),
232
+ appeal: i("notices.appeal", ["receipt", "body"]),
233
+ withdrawAppeal: i("notices.withdrawAppeal", ["receipt"])
182
234
  }
183
235
  };
184
236
  }
185
237
  export {
186
238
  B as COMMUNITY_ANSWER_FIELDS,
187
- V as createCommunityClient
239
+ ee as createCommunityClient
188
240
  };
@@ -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
@@ -21,14 +23,17 @@ export type { CommunityOp, CommunityOpName, CommunitySurface } from './routes.js
21
23
  export { COMMUNITY_UI_CODES, COMMUNITY_API_CODES, COMMUNITY_OUTCOME_OF_KB, COMMUNITY_HOST_CODES, COMMUNITY_OUTCOME_OF_HOST, CommunityTransportError, isCommunityTransportError, isCommunityUiCode, isLoggedCommunityOutcome, communityOutcomeOf, communityFailureOf, } from './outcome.js';
22
24
  export type { CommunityUiCode, CommunityApiCode, CommunityHostCode, CommunityOutcome, CommunityFailure, CommunityLogger, } from './outcome.js';
23
25
  export { fetchTransport, isRelativeCommunityBase, assertCommunityBase, communityOpUrl } from './transport.js';
26
+ export { isInAppBrowser, IN_APP_BROWSER_RE } from './ua.js';
24
27
  export type { CommunityTransport, CommunityTransportAnswer, FetchTransportOptions } from './transport.js';
25
- export { MESSAGE_STATES, AUTHOR_KINDS, NEEDS, RESTRICTION_KINDS, NOTIFICATION_CODES, CASE_CATEGORIES, CATEGORY_WITHOUT_NOTIFIER, AGE_BANDS, LEGAL_TEXT_KINDS, isKnownState, isKnownAuthorKind, isKnownAuthor, isKnownNeed, isKnownRestrictionKind, isKnownNotificationCode, isCaseCategory, communityRulesOf, communityLegalSectionsOf, } from './shapes.js';
26
- export type { KnownMessageState, MessageState, KnownAuthorKind, AuthorKind, KnownNeed, Need, KnownRestrictionKind, RestrictionKind, KnownNotificationCode, NotificationCode, CaseCategory, AgeBand, LegalTextKind, AcceptanceState, MemberAuthor, DeletedMemberAuthor, StaffAuthor, SystemAuthor, KnownAuthor, UnknownAuthor, Author, ReactionSummary, PublicMessage, RestrictionInEffect, DiscussionViewerState, Discussion, DiscussionHead, WriteAnswer, ReactionTarget, BlockEntry, PublicProfile, OwnProfile, MyState, NotificationItem, CommunityPage, DecisionSummary, StatementSubject, Statement, AppealItem, ReportItem, CurrentLegalText, CommunityRule, CommunityLegalSection, MemberExport, NoticeTarget, NoticeReceipt, NoticeStatus, DiscussionListInput, MessagePostInput, MessageEditInput, MessageReportInput, OnboardInput, ProfileUpdateInput, NoticeSubmitInput, } from './shapes.js';
28
+ export { MESSAGE_STATES, AUTHOR_KINDS, NEEDS, RESTRICTION_KINDS, NOTIFICATION_CODES, MODULE_STATES, MUTE_TARGET_KINDS, PUSH_USER_AGENT_CLASSES, REALTIME_EVENT_KINDS, CASE_CATEGORIES, CATEGORY_WITHOUT_NOTIFIER, AGE_BANDS, LEGAL_TEXT_KINDS, isKnownState, isKnownAuthorKind, isKnownAuthor, isKnownNeed, isKnownRestrictionKind, isKnownNotificationCode, isKnownModuleState, isCaseCategory, communityRulesOf, communityLegalSectionsOf, ART9_CONSENT_LAYOUTS, ART9_REFUSALS, ART9_CONTROLLERS_MAX, art9ConsentLayoutOf, art9RefusalOf, art9ControllersOf, TRUST_LABELS, isKnownTrustLabel, } from './shapes.js';
29
+ export type { KnownMessageState, MessageState, KnownAuthorKind, AuthorKind, KnownNeed, Need, KnownRestrictionKind, RestrictionKind, KnownNotificationCode, NotificationCode, KnownModuleState, ModuleState, KnownTrustLabel, TrustLabel, ModuleInfo, MemberSettings, MemberSettingsUpdate, MuteEntry, MuteTargetKind, NotificationListInput, PushUserAgentClass, PushVapidKey, RealtimeToken, RealtimeSubscribeToken, RealtimeEvent, RealtimeEventKind, PushSubscribeInput, PushSubscribeAnswer, PushUnsubscribeAnswer, PushStatusAnswer, MemberCaps, CaseCategory, AgeBand, LegalTextKind, AcceptanceState, MemberAuthor, DeletedMemberAuthor, StaffAuthor, SystemAuthor, KnownAuthor, UnknownAuthor, Author, ReactionSummary, PublicMessage, RestrictionInEffect, DiscussionViewerState, Discussion, DiscussionHead, WriteAnswer, ReactionTarget, BlockEntry, PublicProfile, OwnProfile, MyState, NotificationItem, CommunityPage, DecisionSummary, StatementSubject, Statement, AppealItem, ReportItem, CurrentLegalText, CommunityRule, CommunityLegalSection, Art9ConsentLayout, Art9Refusal, Art9Controller, CommunityConsentSettings, MemberExport, NoticeTarget, NoticeReceipt, NoticeStatus, DiscussionListInput, MessagePostInput, MessageEditInput, MessageReportInput, OnboardInput, ProfileUpdateInput, NoticeSubmitInput, } from './shapes.js';
27
30
  export { createDiscussionStore, refreshDiscussion, loadMoreDiscussion, viewerNeeds, findMessage, isOwnMessage, reactionsFor, reactionAfter, } from './store.js';
28
- export type { DiscussionStore, DiscussionState, DiscussionMessage, DiscussionViewer, DiscussionRestriction, MessageChange, ViewerNeeds, } from './store.js';
31
+ export type { DiscussionStore, RealtimeEventOutcome, DiscussionState, DiscussionMessage, DiscussionViewer, DiscussionRestriction, MessageChange, ViewerNeeds, } from './store.js';
29
32
  export { pollDiscussionHead, POLL_INTERVAL_MS, POLL_MAX_BACKOFF_MS } from './poll.js';
30
33
  export type { PollDiscussionHeadOptions, DiscussionHeadPoller } from './poll.js';
31
34
  export { COMMUNITY_CHANNELS } from './channels.js';
32
- export { COMMUNITY_ROUTES, COMMUNITY_RECEIPT_RE, statementPath, myCommunityPath, noticeStatusLink, signInLink, receiptFromHash, readReceiptFromHash, } from './links.js';
33
- export { COMMUNITY_MESSAGES, communityMessage, communityMessageLanguage, hasCommunityMessage, warningMessageKey, confirmMessageKey, noteMessageKey, } from './messages.js';
35
+ export { COMMUNITY_ROUTES, COMMUNITY_RECEIPT_RE, statementPath, myCommunityPath, noticeStatusLink, signInLink, receiptFromHash, readReceiptFromHash, profilePath, COMMUNITY_MESSAGE_ANCHOR_PREFIX, communityMessageAnchor, communityMessageSeqFromHash, communityMessageLink, COMMUNITY_DIGEST_TOKEN_RE, digestTokenFromHash, readDigestTokenFromHash, forgetDigestToken, } from './links.js';
36
+ export { COMMUNITY_MENTION_RE, communityMentionSpans, communityMentionHandles } from './mentions.js';
37
+ export type { CommunityTextSpan } from './mentions.js';
38
+ export { COMMUNITY_MESSAGES, communityMessage, communityMessageLanguage, hasCommunityMessage, warningMessageKey, confirmMessageKey, noteMessageKey, notificationMessageKey, trustLabelMessageKey, } from './messages.js';
34
39
  export type { CommunityMessageKey, CommunityMessageLanguage } from './messages.js';