@blogmcp/sdk 0.9.4 → 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.
- package/dist/community/channels.d.ts +7 -6
- package/dist/community/channels.js +4 -4
- package/dist/community/client.d.ts +74 -4
- package/dist/community/client.js +143 -91
- package/dist/community/index.d.ts +11 -6
- package/dist/community/index.js +111 -80
- package/dist/community/links.d.ts +61 -1
- package/dist/community/links.js +94 -40
- package/dist/community/manifest/index.d.ts +54 -0
- package/dist/community/manifest/index.js +46 -0
- package/dist/community/mentions.d.ts +38 -0
- package/dist/community/mentions.js +25 -0
- package/dist/community/messages.cs.d.ts +73 -3
- package/dist/community/messages.cs.js +82 -3
- package/dist/community/messages.d.ts +11 -0
- package/dist/community/messages.en.d.ts +69 -1
- package/dist/community/messages.en.js +71 -1
- package/dist/community/messages.js +26 -16
- package/dist/community/outcome.d.ts +8 -3
- package/dist/community/outcome.js +72 -28
- package/dist/community/realtime/index.d.ts +118 -0
- package/dist/community/realtime/index.js +215 -0
- package/dist/community/routes.d.ts +12 -0
- package/dist/community/routes.js +41 -25
- package/dist/community/server/bff.js +25 -25
- package/dist/community/server/host-routes.js +12 -0
- package/dist/community/server/index.d.ts +1 -1
- package/dist/community/server/index.js +15 -14
- package/dist/community/server/route-decision.d.ts +8 -0
- package/dist/community/server/route-decision.js +28 -22
- package/dist/community/shapes.d.ts +214 -2
- package/dist/community/shapes.js +65 -25
- package/dist/community/store.d.ts +18 -1
- package/dist/community/store.js +316 -261
- package/dist/community/sw/index.d.ts +45 -0
- package/dist/community/sw/index.js +59 -0
- package/dist/community/ua.d.ts +12 -0
- package/dist/community/ua.js +9 -0
- package/package.json +20 -3
- package/src/community/channels.ts +8 -7
- package/src/community/client.ts +116 -5
- package/src/community/index.ts +59 -1
- package/src/community/links.ts +119 -2
- package/src/community/manifest/index.ts +107 -0
- package/src/community/mentions.ts +59 -0
- package/src/community/messages.cs.ts +88 -3
- package/src/community/messages.en.ts +77 -1
- package/src/community/messages.ts +19 -0
- package/src/community/outcome.ts +50 -1
- package/src/community/realtime/index.ts +522 -0
- package/src/community/routes.ts +16 -0
- package/src/community/server/bff.ts +2 -4
- package/src/community/server/host-routes.ts +12 -0
- package/src/community/server/index.ts +1 -0
- package/src/community/server/route-decision.ts +15 -0
- package/src/community/shapes.ts +256 -3
- package/src/community/store.ts +114 -0
- package/src/community/sw/index.ts +112 -0
- package/src/community/ua.ts +17 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The realtime channel names
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
-
* `
|
|
7
|
-
* codes only,
|
|
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: "
|
|
12
|
+
readonly inbox: "user:inbox";
|
|
12
13
|
}>;
|
|
@@ -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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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>;
|
package/dist/community/client.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { communityFailureOf as
|
|
2
|
-
import { COMMUNITY_OPS as
|
|
3
|
-
import { isKnownNeed as
|
|
4
|
-
import { assertCommunityBase as
|
|
5
|
-
const
|
|
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
|
|
13
|
-
string:
|
|
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:
|
|
17
|
-
record:
|
|
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,
|
|
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 (!
|
|
53
|
-
for (const
|
|
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
|
|
57
|
-
return
|
|
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
|
-
|
|
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
|
|
65
|
-
return
|
|
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
|
-
|
|
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:
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const l =
|
|
79
|
-
l && (r.codes = l),
|
|
80
|
-
const
|
|
81
|
-
|
|
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
|
|
84
|
-
|
|
85
|
-
const n = e.transport ?? F(e.base, e.now ? { now: e.now } : {}), r = z(e.timeoutMs),
|
|
86
|
-
if (!(!
|
|
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
|
-
|
|
107
|
+
u({ op: t, outcome: o, kbCode: d, status: k });
|
|
89
108
|
} catch {
|
|
90
109
|
}
|
|
91
110
|
};
|
|
92
|
-
async function l(t,
|
|
93
|
-
const
|
|
94
|
-
O?.aborted ?
|
|
95
|
-
const
|
|
96
|
-
let
|
|
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
|
-
|
|
99
|
-
} catch (
|
|
100
|
-
const
|
|
101
|
-
return O?.aborted ||
|
|
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(
|
|
122
|
+
clearTimeout(x), O?.removeEventListener("abort", T);
|
|
104
123
|
}
|
|
105
|
-
const y = typeof
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
return
|
|
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 &&
|
|
111
|
-
const { ok:
|
|
112
|
-
return W(t,
|
|
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
|
|
116
|
-
return
|
|
134
|
+
const p = v(g.retryAfterS);
|
|
135
|
+
return p === void 0 ? { ok: !1, code: "fast" } : { ok: !1, code: "fast", retryAfterS: p };
|
|
117
136
|
}
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
return
|
|
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
|
|
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:
|
|
126
|
-
head: (t,
|
|
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:
|
|
130
|
-
edit:
|
|
131
|
-
delete:
|
|
132
|
-
report:
|
|
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,
|
|
154
|
+
set: (t, o) => l("reactions.set", { target: _(t?.target), emoji: t?.emoji ?? null }, o)
|
|
136
155
|
},
|
|
137
156
|
blocks: {
|
|
138
|
-
set:
|
|
139
|
-
list:
|
|
157
|
+
set: i("blocks.set", ["memberId", "blocked"]),
|
|
158
|
+
list: a("blocks.list")
|
|
140
159
|
},
|
|
141
160
|
profile: {
|
|
142
|
-
get: (t,
|
|
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:
|
|
146
|
-
onboard:
|
|
147
|
-
updateProfile:
|
|
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:
|
|
150
|
-
markRead: (t,
|
|
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:
|
|
154
|
-
get:
|
|
202
|
+
list: i("me.decisions.list", ["cursor"]),
|
|
203
|
+
get: i("me.decisions.get", ["decisionId"])
|
|
155
204
|
},
|
|
156
205
|
appeals: {
|
|
157
|
-
file:
|
|
158
|
-
withdraw:
|
|
159
|
-
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:
|
|
211
|
+
list: a("me.reports.list")
|
|
163
212
|
},
|
|
164
213
|
consents: {
|
|
165
|
-
withdraw: (t,
|
|
214
|
+
withdraw: (t, o) => l("me.consents.withdraw", { kind: "art9_consent" }, o)
|
|
166
215
|
},
|
|
167
|
-
export:
|
|
168
|
-
erase:
|
|
169
|
-
cancelErase:
|
|
216
|
+
export: a("me.export"),
|
|
217
|
+
erase: a("me.erase"),
|
|
218
|
+
cancelErase: a("me.cancelErase")
|
|
170
219
|
},
|
|
171
220
|
legal: {
|
|
172
|
-
current:
|
|
221
|
+
current: i("legal.current", ["kind", "locale"])
|
|
222
|
+
},
|
|
223
|
+
realtime: {
|
|
224
|
+
subscribeToken: i("realtime.subscribeToken", ["channel"])
|
|
173
225
|
},
|
|
174
226
|
notices: {
|
|
175
|
-
submit: (t,
|
|
176
|
-
const
|
|
177
|
-
return
|
|
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:
|
|
180
|
-
appeal:
|
|
181
|
-
withdrawAppeal:
|
|
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
|
-
|
|
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 {
|
|
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';
|