@blogmcp/sdk 0.10.1 → 0.12.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 +3 -2
- package/dist/community/client.d.ts +130 -3
- package/dist/community/client.js +232 -161
- package/dist/community/forum.d.ts +82 -0
- package/dist/community/forum.js +96 -0
- package/dist/community/index.d.ts +14 -7
- package/dist/community/index.js +185 -121
- package/dist/community/links.d.ts +38 -0
- package/dist/community/links.js +98 -71
- package/dist/community/messages.cs.d.ts +164 -3
- package/dist/community/messages.cs.js +184 -3
- package/dist/community/messages.d.ts +19 -1
- package/dist/community/messages.en.d.ts +154 -3
- package/dist/community/messages.en.js +167 -3
- package/dist/community/messages.js +37 -28
- package/dist/community/outcome.d.ts +8 -3
- package/dist/community/outcome.js +61 -20
- package/dist/community/poll.d.ts +28 -4
- package/dist/community/poll.js +70 -47
- package/dist/community/realtime/index.d.ts +19 -3
- package/dist/community/realtime/index.js +175 -145
- package/dist/community/routes.d.ts +36 -1
- package/dist/community/routes.js +51 -21
- package/dist/community/server/bff.d.ts +25 -2
- package/dist/community/server/bff.js +135 -118
- package/dist/community/server/host-routes.d.ts +3 -0
- package/dist/community/server/host-routes.js +17 -0
- package/dist/community/server/index.d.ts +5 -1
- package/dist/community/shapes.d.ts +649 -7
- package/dist/community/shapes.js +92 -61
- package/dist/community/store.d.ts +27 -0
- package/dist/community/store.js +84 -80
- package/dist/community/topic.d.ts +173 -0
- package/dist/community/topic.js +225 -0
- package/dist/nuxt/composables/useAsyncKb.d.ts +10 -4
- package/dist/packages/mdx-render-vue/dist/render/gallery/GalleryLightbox.vue.js +2 -2
- package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +36 -36
- package/package.json +3 -3
- package/src/community/channels.ts +3 -2
- package/src/community/client.ts +212 -7
- package/src/community/forum.ts +209 -0
- package/src/community/index.ts +146 -2
- package/src/community/links.ts +64 -4
- package/src/community/messages.cs.ts +185 -3
- package/src/community/messages.en.ts +168 -3
- package/src/community/messages.ts +25 -2
- package/src/community/outcome.ts +47 -1
- package/src/community/poll.ts +79 -17
- package/src/community/realtime/index.ts +124 -48
- package/src/community/routes.ts +42 -1
- package/src/community/server/bff.ts +89 -30
- package/src/community/server/host-routes.ts +20 -0
- package/src/community/server/index.ts +5 -1
- package/src/community/shapes.ts +677 -6
- package/src/community/store.ts +25 -7
- package/src/community/topic.ts +521 -0
- package/src/core/markdown.ts +1 -1
- package/src/nuxt/composables/useAsyncKb.ts +11 -4
- package/src/nuxt/nuxt-imports.d.ts +2 -2
package/dist/community/client.js
CHANGED
|
@@ -1,240 +1,311 @@
|
|
|
1
|
-
import { communityFailureOf as
|
|
2
|
-
import { COMMUNITY_OPS as
|
|
3
|
-
import { isKnownNeed as
|
|
4
|
-
import { assertCommunityBase as
|
|
5
|
-
const M = 1e4,
|
|
1
|
+
import { communityFailureOf as P, isLoggedCommunityOutcome as j, communityOutcomeOf as x } from "./outcome.js";
|
|
2
|
+
import { COMMUNITY_OPS as z } from "./routes.js";
|
|
3
|
+
import { isKnownNeed as D } from "./shapes.js";
|
|
4
|
+
import { assertCommunityBase as L, fetchTransport as U } from "./transport.js";
|
|
5
|
+
const M = 1e4, F = 2147483647;
|
|
6
6
|
let E = !1;
|
|
7
|
-
function
|
|
7
|
+
function B(e) {
|
|
8
8
|
if (e === void 0) return M;
|
|
9
9
|
const n = typeof e == "number" ? Math.floor(e) : Number.NaN;
|
|
10
|
-
return n >= 1 && n <=
|
|
10
|
+
return n >= 1 && n <= F ? 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 d = (e) => typeof e == "object" && e !== null && !Array.isArray(e), h = (e) => typeof e == "string", g = Array.isArray, K = Object.freeze({
|
|
13
|
+
string: h,
|
|
14
14
|
number: (e) => typeof e == "number",
|
|
15
15
|
boolean: (e) => typeof e == "boolean",
|
|
16
|
-
array:
|
|
17
|
-
record:
|
|
18
|
-
}),
|
|
19
|
-
"discussions.list":
|
|
20
|
-
"discussions.head":
|
|
21
|
-
"messages.post":
|
|
22
|
-
"messages.edit":
|
|
23
|
-
"messages.delete":
|
|
24
|
-
"messages.report":
|
|
25
|
-
"reactions.set":
|
|
26
|
-
"blocks.set":
|
|
27
|
-
"blocks.list":
|
|
28
|
-
"profile.get":
|
|
29
|
-
"me.get":
|
|
30
|
-
"me.onboard":
|
|
31
|
-
"me.updateProfile":
|
|
32
|
-
"me.notifications.list":
|
|
33
|
-
"me.notifications.markRead":
|
|
34
|
-
"me.notifications.unreadCount":
|
|
35
|
-
"me.settings.get":
|
|
36
|
-
"me.settings.update":
|
|
37
|
-
"me.settings.unsubscribeDigest":
|
|
38
|
-
"me.mutes.set":
|
|
39
|
-
"me.mutes.list":
|
|
40
|
-
"me.push.vapid":
|
|
41
|
-
"me.push.subscribe":
|
|
42
|
-
"me.push.unsubscribe":
|
|
43
|
-
"me.push.status":
|
|
44
|
-
"me.realtime.token":
|
|
45
|
-
"realtime.subscribeToken":
|
|
46
|
-
"me.decisions.list":
|
|
47
|
-
"me.decisions.get":
|
|
48
|
-
"me.appeals.file":
|
|
49
|
-
"me.appeals.withdraw":
|
|
50
|
-
"me.appeals.list":
|
|
51
|
-
"me.reports.list":
|
|
52
|
-
"me.consents.withdraw":
|
|
53
|
-
"me.export":
|
|
54
|
-
"me.erase":
|
|
55
|
-
"me.cancelErase":
|
|
56
|
-
"legal.current":
|
|
57
|
-
"notices.submit":
|
|
58
|
-
"notices.status":
|
|
59
|
-
"notices.appeal":
|
|
60
|
-
"notices.withdrawAppeal":
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
16
|
+
array: g,
|
|
17
|
+
record: d
|
|
18
|
+
}), t = (e) => Object.freeze({ ...e }), W = Object.freeze({
|
|
19
|
+
"discussions.list": t({ articleId: "string", messages: "array", viewer: "record" }),
|
|
20
|
+
"discussions.head": t({ heads: "array" }),
|
|
21
|
+
"messages.post": t({ message: "record", warnings: "array" }),
|
|
22
|
+
"messages.edit": t({ message: "record", warnings: "array" }),
|
|
23
|
+
"messages.delete": t({ message: "record" }),
|
|
24
|
+
"messages.report": t({ caseId: "string" }),
|
|
25
|
+
"reactions.set": t({ reactions: "record" }),
|
|
26
|
+
"blocks.set": t({ blocked: "boolean" }),
|
|
27
|
+
"blocks.list": t({ blocks: "array" }),
|
|
28
|
+
"profile.get": t({ author: "record" }),
|
|
29
|
+
"me.get": t({ needs: "array" }),
|
|
30
|
+
"me.onboard": t({ needs: "array" }),
|
|
31
|
+
"me.updateProfile": t({ profile: "record" }),
|
|
32
|
+
"me.notifications.list": t({ items: "array" }),
|
|
33
|
+
"me.notifications.markRead": t({ updated: "number" }),
|
|
34
|
+
"me.notifications.unreadCount": t({ count: "number" }),
|
|
35
|
+
"me.settings.get": t({ settings: "record" }),
|
|
36
|
+
"me.settings.update": t({ settings: "record" }),
|
|
37
|
+
"me.settings.unsubscribeDigest": t({ unsubscribed: "boolean" }),
|
|
38
|
+
"me.mutes.set": t({ muted: "boolean" }),
|
|
39
|
+
"me.mutes.list": t({ items: "array" }),
|
|
40
|
+
"me.push.vapid": t({ publicKey: "string", keyId: "string" }),
|
|
41
|
+
"me.push.subscribe": t({ subscribed: "boolean", keyId: "string" }),
|
|
42
|
+
"me.push.unsubscribe": t({ unsubscribed: "boolean" }),
|
|
43
|
+
"me.push.status": t({ subscribed: "boolean" }),
|
|
44
|
+
"me.realtime.token": t({ token: "string", url: "string", expiresInS: "number" }),
|
|
45
|
+
"realtime.subscribeToken": t({ token: "string" }),
|
|
46
|
+
"me.decisions.list": t({ items: "array" }),
|
|
47
|
+
"me.decisions.get": t({ decisionId: "string" }),
|
|
48
|
+
"me.appeals.file": t({ appealId: "string" }),
|
|
49
|
+
"me.appeals.withdraw": t({ appealId: "string" }),
|
|
50
|
+
"me.appeals.list": t({ items: "array" }),
|
|
51
|
+
"me.reports.list": t({ items: "array" }),
|
|
52
|
+
"me.consents.withdraw": t({ state: "string" }),
|
|
53
|
+
"me.export": t({ generatedAt: "string" }),
|
|
54
|
+
"me.erase": t({ purgeAfter: "string" }),
|
|
55
|
+
"me.cancelErase": t({ status: "string" }),
|
|
56
|
+
"legal.current": t({ textId: "string" }),
|
|
57
|
+
"notices.submit": t({ caseId: "string", receipt: "string" }),
|
|
58
|
+
"notices.status": t({ status: "string" }),
|
|
59
|
+
"notices.appeal": t({ appealId: "string" }),
|
|
60
|
+
"notices.withdrawAppeal": t({ appealId: "string" }),
|
|
61
|
+
// M3 (m3-contracts.md §3.2–§3.4).
|
|
62
|
+
"forum.categories.list": t({ categories: "array" }),
|
|
63
|
+
"forum.topics.list": t({ category: "record", items: "array" }),
|
|
64
|
+
"forum.topics.get": t({ topic: "record", messages: "array", viewer: "record" }),
|
|
65
|
+
"forum.topics.head": t({ heads: "array" }),
|
|
66
|
+
"forum.topics.create": t({ topic: "record", message: "record", warnings: "array" }),
|
|
67
|
+
"forum.search": t({ results: "array", page: "number", hasMore: "boolean" }),
|
|
68
|
+
"me.follows.set": t({ following: "boolean" }),
|
|
69
|
+
"me.follows.list": t({ follows: "array" }),
|
|
70
|
+
"moderation.queue": t({ items: "array" }),
|
|
71
|
+
"moderation.getCase": t({ case: "record" }),
|
|
72
|
+
"moderation.decide": t({ dryRun: "boolean", statement: "string" }),
|
|
73
|
+
"moderation.remove": t({ decision: "record", statement: "string" }),
|
|
74
|
+
// The bare envelope `{ ok: true }` (§3.4): the moderator learns nothing of the case it opened or joined.
|
|
75
|
+
"moderation.escalate": t({}),
|
|
76
|
+
"moderation.setTopicState": t({ topic: "record" }),
|
|
77
|
+
"moderation.moveTopic": t({ topic: "record" }),
|
|
78
|
+
"moderation.pinTopic": t({ topic: "record" }),
|
|
79
|
+
// A union: COMMUNITY_ANSWER_VARIANTS says which shapes count.
|
|
80
|
+
"moderation.reviewPremod": t({})
|
|
81
|
+
}), Y = Object.freeze({
|
|
82
|
+
// approve → the published message; reject → the removal and its statement (§3.4, §4.2).
|
|
83
|
+
"moderation.reviewPremod": Object.freeze([t({ message: "record" }), t({ decision: "record", statement: "string" })])
|
|
84
|
+
}), _ = (e, n) => Object.entries(e).every(([o, m]) => K[m](n[o])), X = (e, n) => {
|
|
85
|
+
if (!_(W[e], n)) return !1;
|
|
86
|
+
const o = Y[e];
|
|
87
|
+
return o === void 0 || o.some((m) => _(m, n));
|
|
88
|
+
};
|
|
89
|
+
function u(e, n) {
|
|
90
|
+
const o = {};
|
|
91
|
+
if (!d(e)) return o;
|
|
92
|
+
for (const m of n) e[m] !== void 0 && (o[m] = e[m]);
|
|
93
|
+
return o;
|
|
67
94
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
95
|
+
function R(e) {
|
|
96
|
+
return d(e) ? "conversationId" in e ? u(e, ["conversationId", "seq"]) : "memberId" in e ? u(e, ["memberId"]) : "handle" in e ? u(e, ["handle"]) : u(e, ["articleId"]) : e;
|
|
70
97
|
}
|
|
71
|
-
const
|
|
72
|
-
function
|
|
73
|
-
if (
|
|
74
|
-
return e.filter((n) =>
|
|
98
|
+
const q = /^[A-Za-z0-9_.:-]{1,64}$/, O = 20;
|
|
99
|
+
function $(e) {
|
|
100
|
+
if (g(e))
|
|
101
|
+
return e.filter((n) => h(n) && q.test(n)).slice(0, O);
|
|
75
102
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
103
|
+
function G(e) {
|
|
104
|
+
return g(e) ? e.filter(D).slice(0, O) : void 0;
|
|
78
105
|
}
|
|
79
106
|
function H(e) {
|
|
80
|
-
return
|
|
107
|
+
return g(e) ? e.map((o) => d(o) ? o.path : o).filter((o) => h(o) && o.length <= 128).slice(0, O) : void 0;
|
|
108
|
+
}
|
|
109
|
+
function V(e) {
|
|
110
|
+
if (!g(e)) return;
|
|
111
|
+
const n = e.map((o) => d(o) ? o.code : void 0).filter((o) => h(o) && q.test(o));
|
|
112
|
+
return n.length > 0 ? [...new Set(n)].slice(0, O) : void 0;
|
|
81
113
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return n.length > 0 ? [...new Set(n)].slice(0, S) : void 0;
|
|
114
|
+
const Z = /^[a-z][a-z0-9_]{0,63}$/;
|
|
115
|
+
function J(e) {
|
|
116
|
+
return h(e) && Z.test(e) ? e : void 0;
|
|
86
117
|
}
|
|
87
|
-
function
|
|
118
|
+
function Q(e) {
|
|
119
|
+
return d(e) ? "conversationId" in e ? u(e, ["conversationId"]) : u(e, ["categoryId"]) : e;
|
|
120
|
+
}
|
|
121
|
+
function T(e) {
|
|
88
122
|
return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.ceil(e) : void 0;
|
|
89
123
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const b =
|
|
94
|
-
b && (
|
|
95
|
-
const l =
|
|
96
|
-
l && (
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
124
|
+
function ee(e, n) {
|
|
125
|
+
const o = { ok: !1, code: x(e.code) }, m = T(e.retryAfterS) ?? T(n.retryAfterS);
|
|
126
|
+
m !== void 0 && (o.retryAfterS = m);
|
|
127
|
+
const b = G(e.needs);
|
|
128
|
+
b && (o.needs = b);
|
|
129
|
+
const l = $(e.codes);
|
|
130
|
+
l && (o.codes = l), h(e.until) && (o.until = e.until);
|
|
131
|
+
const r = J(e.surface);
|
|
132
|
+
r !== void 0 && (o.surface = r);
|
|
133
|
+
const c = H(e.issues);
|
|
134
|
+
c && (o.fields = c);
|
|
135
|
+
const s = V(e.issues);
|
|
136
|
+
return s && (o.issueCodes = s), o;
|
|
101
137
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
const n = e.transport ??
|
|
105
|
-
if (!(!
|
|
138
|
+
function ie(e) {
|
|
139
|
+
L(e?.base);
|
|
140
|
+
const n = e.transport ?? U(e.base, e.now ? { now: e.now } : {}), o = B(e.timeoutMs), m = e.logger, b = (s, i, a, v) => {
|
|
141
|
+
if (!(!m || !j(i)))
|
|
106
142
|
try {
|
|
107
|
-
|
|
143
|
+
m({ op: s, outcome: i, kbCode: a, status: v });
|
|
108
144
|
} catch {
|
|
109
145
|
}
|
|
110
146
|
};
|
|
111
|
-
async function l(
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
let
|
|
147
|
+
async function l(s, i, a) {
|
|
148
|
+
const v = z[s], k = new AbortController(), A = a?.signal, S = () => k.abort();
|
|
149
|
+
A?.aborted ? k.abort() : A?.addEventListener("abort", S, { once: !0 });
|
|
150
|
+
const N = setTimeout(() => k.abort(), o);
|
|
151
|
+
let y;
|
|
116
152
|
try {
|
|
117
|
-
|
|
153
|
+
y = await n(v, i, k.signal);
|
|
118
154
|
} catch (p) {
|
|
119
|
-
const w =
|
|
120
|
-
return
|
|
155
|
+
const w = P(p);
|
|
156
|
+
return A?.aborted || b(s, w.code, null, null), w;
|
|
121
157
|
} finally {
|
|
122
|
-
clearTimeout(
|
|
158
|
+
clearTimeout(N), A?.removeEventListener("abort", S);
|
|
123
159
|
}
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
const p =
|
|
127
|
-
return b(
|
|
160
|
+
const I = typeof y?.status == "number" ? y.status : 0, f = y?.body;
|
|
161
|
+
if (d(f) && f.ok === !1 && h(f.code) && f.code !== "") {
|
|
162
|
+
const p = ee(f, y);
|
|
163
|
+
return b(s, p.code, f.code.slice(0, 64), I), p;
|
|
128
164
|
}
|
|
129
|
-
if (
|
|
165
|
+
if (I >= 200 && I < 300 && d(f) && f.ok === !0) {
|
|
130
166
|
const { ok: p, ...w } = f;
|
|
131
|
-
return
|
|
167
|
+
return X(s, w) ? { ok: !0, value: w } : (b(s, "unavailable", null, I), { ok: !1, code: "unavailable" });
|
|
132
168
|
}
|
|
133
|
-
if (
|
|
134
|
-
const p =
|
|
169
|
+
if (I === 429) {
|
|
170
|
+
const p = T(y.retryAfterS);
|
|
135
171
|
return p === void 0 ? { ok: !1, code: "fast" } : { ok: !1, code: "fast", retryAfterS: p };
|
|
136
172
|
}
|
|
137
|
-
b(
|
|
138
|
-
const C =
|
|
173
|
+
b(s, "unavailable", null, I);
|
|
174
|
+
const C = I === 503 ? T(y.retryAfterS) : void 0;
|
|
139
175
|
return C === void 0 ? { ok: !1, code: "unavailable" } : { ok: !1, code: "unavailable", retryAfterS: C };
|
|
140
176
|
}
|
|
141
|
-
const
|
|
177
|
+
const r = (s, i) => (a, v) => l(s, u(a, i), v), c = (s) => (i) => l(s, {}, i);
|
|
142
178
|
return {
|
|
143
179
|
discussions: {
|
|
144
|
-
list:
|
|
145
|
-
head: (
|
|
180
|
+
list: r("discussions.list", ["articleId", "languageCode", "cursor"]),
|
|
181
|
+
head: (s, i) => l("discussions.head", { articleIds: d(s) && g(s.articleIds) ? [...s.articleIds] : [] }, i)
|
|
146
182
|
},
|
|
147
183
|
messages: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
184
|
+
// M3: `conversationId` (a topic) in place of `articleId`; the caller's type allows exactly one, and both are sent as given.
|
|
185
|
+
post: r("messages.post", ["articleId", "conversationId", "body", "replyToSeq", "clientMsgId", "languageCode", "confirmations"]),
|
|
186
|
+
edit: r("messages.edit", ["conversationId", "seq", "body", "title", "confirmations"]),
|
|
187
|
+
delete: r("messages.delete", ["conversationId", "seq"]),
|
|
188
|
+
report: r("messages.report", ["conversationId", "seq", "category", "ruleId", "note"])
|
|
152
189
|
},
|
|
153
190
|
reactions: {
|
|
154
|
-
set: (
|
|
191
|
+
set: (s, i) => l("reactions.set", { target: R(s?.target), emoji: s?.emoji ?? null }, i)
|
|
155
192
|
},
|
|
156
193
|
blocks: {
|
|
157
|
-
set:
|
|
158
|
-
list:
|
|
194
|
+
set: r("blocks.set", ["memberId", "blocked"]),
|
|
195
|
+
list: c("blocks.list")
|
|
159
196
|
},
|
|
160
197
|
profile: {
|
|
161
|
-
get: (
|
|
198
|
+
get: (s, i) => l("profile.get", d(s) && "handle" in s ? u(s, ["handle"]) : u(s, ["memberId"]), i)
|
|
162
199
|
},
|
|
163
200
|
me: {
|
|
164
|
-
get:
|
|
165
|
-
|
|
166
|
-
|
|
201
|
+
get: c("me.get"),
|
|
202
|
+
// O-16 / F-51: `termsTextId` goes only when the caller sets it (pick drops an absent key, so an older kb-api never sees it).
|
|
203
|
+
onboard: r("me.onboard", ["ageBand", "rulesTextId", "termsTextId", "art9TextId", "art9Refused", "displayName", "handle", "avatarPreset"]),
|
|
204
|
+
updateProfile: r("me.updateProfile", ["displayName", "handle", "avatarPreset", "bio"]),
|
|
167
205
|
notifications: {
|
|
168
|
-
list:
|
|
169
|
-
markRead: (
|
|
206
|
+
list: r("me.notifications.list", ["cursor", "unreadOnly", "codes"]),
|
|
207
|
+
markRead: (s, i) => l(
|
|
170
208
|
"me.notifications.markRead",
|
|
171
|
-
|
|
172
|
-
|
|
209
|
+
d(s) && "all" in s ? { all: s.all } : { ids: d(s) && g(s.ids) ? [...s.ids] : [] },
|
|
210
|
+
i
|
|
173
211
|
),
|
|
174
|
-
unreadCount:
|
|
212
|
+
unreadCount: c("me.notifications.unreadCount")
|
|
175
213
|
},
|
|
176
214
|
settings: {
|
|
177
|
-
get:
|
|
178
|
-
update:
|
|
179
|
-
unsubscribeDigest:
|
|
215
|
+
get: c("me.settings.get"),
|
|
216
|
+
update: r("me.settings.update", ["notifyReply", "notifyMention", "notifyTopic", "pushEnabled", "digestEmail", "quietHours"]),
|
|
217
|
+
unsubscribeDigest: r("me.settings.unsubscribeDigest", ["token"])
|
|
180
218
|
},
|
|
181
219
|
mutes: {
|
|
182
|
-
set:
|
|
183
|
-
list:
|
|
220
|
+
set: r("me.mutes.set", ["targetKind", "targetId", "muted"]),
|
|
221
|
+
list: c("me.mutes.list")
|
|
184
222
|
},
|
|
185
223
|
push: {
|
|
186
|
-
vapid:
|
|
187
|
-
subscribe: (
|
|
224
|
+
vapid: c("me.push.vapid"),
|
|
225
|
+
subscribe: (s, i) => l(
|
|
188
226
|
"me.push.subscribe",
|
|
189
227
|
{
|
|
190
|
-
...
|
|
191
|
-
...
|
|
228
|
+
...u(s, ["endpoint", "userAgentClass"]),
|
|
229
|
+
...d(s) && d(s.keys) ? { keys: u(s.keys, ["p256dh", "auth"]) } : {}
|
|
192
230
|
},
|
|
193
|
-
|
|
231
|
+
i
|
|
194
232
|
),
|
|
195
|
-
unsubscribe:
|
|
196
|
-
status:
|
|
233
|
+
unsubscribe: r("me.push.unsubscribe", ["endpoint"]),
|
|
234
|
+
status: r("me.push.status", ["endpoint"])
|
|
197
235
|
},
|
|
198
236
|
realtime: {
|
|
199
|
-
token:
|
|
237
|
+
token: c("me.realtime.token")
|
|
200
238
|
},
|
|
201
239
|
decisions: {
|
|
202
|
-
list:
|
|
203
|
-
get:
|
|
240
|
+
list: r("me.decisions.list", ["cursor"]),
|
|
241
|
+
get: r("me.decisions.get", ["decisionId"])
|
|
204
242
|
},
|
|
205
243
|
appeals: {
|
|
206
|
-
file:
|
|
207
|
-
withdraw:
|
|
208
|
-
list:
|
|
244
|
+
file: r("me.appeals.file", ["decisionId", "body"]),
|
|
245
|
+
withdraw: r("me.appeals.withdraw", ["appealId"]),
|
|
246
|
+
list: c("me.appeals.list")
|
|
209
247
|
},
|
|
210
248
|
reports: {
|
|
211
|
-
list:
|
|
249
|
+
list: c("me.reports.list")
|
|
212
250
|
},
|
|
213
251
|
consents: {
|
|
214
|
-
withdraw: (
|
|
252
|
+
withdraw: (s, i) => l("me.consents.withdraw", { kind: "art9_consent" }, i)
|
|
253
|
+
},
|
|
254
|
+
follows: {
|
|
255
|
+
set: (s, i) => {
|
|
256
|
+
const a = u(s, ["target", "following"]);
|
|
257
|
+
return a.target !== void 0 && (a.target = Q(a.target)), l("me.follows.set", a, i);
|
|
258
|
+
},
|
|
259
|
+
list: r("me.follows.list", ["cursor"])
|
|
215
260
|
},
|
|
216
|
-
export:
|
|
217
|
-
erase:
|
|
218
|
-
cancelErase:
|
|
261
|
+
export: c("me.export"),
|
|
262
|
+
erase: c("me.erase"),
|
|
263
|
+
cancelErase: c("me.cancelErase")
|
|
219
264
|
},
|
|
220
265
|
legal: {
|
|
221
|
-
current:
|
|
266
|
+
current: r("legal.current", ["kind", "locale"])
|
|
222
267
|
},
|
|
223
268
|
realtime: {
|
|
224
|
-
subscribeToken:
|
|
269
|
+
subscribeToken: r("realtime.subscribeToken", ["channel"])
|
|
270
|
+
},
|
|
271
|
+
forum: {
|
|
272
|
+
categories: {
|
|
273
|
+
list: c("forum.categories.list")
|
|
274
|
+
},
|
|
275
|
+
topics: {
|
|
276
|
+
// A category by its id or its slug: the caller's type allows exactly one, and what is given is sent.
|
|
277
|
+
list: r("forum.topics.list", ["categoryId", "categorySlug", "sort", "cursor", "limit"]),
|
|
278
|
+
get: r("forum.topics.get", ["conversationId", "languageCode", "cursor"]),
|
|
279
|
+
head: (s, i) => l("forum.topics.head", { conversationIds: d(s) && g(s.conversationIds) ? [...s.conversationIds] : [] }, i),
|
|
280
|
+
create: r("forum.topics.create", ["categoryId", "title", "body", "clientMsgId", "languageCode", "confirmations"])
|
|
281
|
+
},
|
|
282
|
+
search: r("forum.search", ["query", "categoryId", "space", "page"])
|
|
283
|
+
},
|
|
284
|
+
moderation: {
|
|
285
|
+
queue: r("moderation.queue", ["categoryId", "cursor"]),
|
|
286
|
+
getCase: r("moderation.getCase", ["caseId"]),
|
|
287
|
+
decide: r("moderation.decide", ["caseId", "restriction", "basis", "facts", "contractualGround", "locale", "dryRun"]),
|
|
288
|
+
remove: r("moderation.remove", ["conversationId", "seq", "ruleId", "facts", "locale"]),
|
|
289
|
+
escalate: r("moderation.escalate", ["conversationId", "seq", "category"]),
|
|
290
|
+
setTopicState: r("moderation.setTopicState", ["conversationId", "state"]),
|
|
291
|
+
moveTopic: r("moderation.moveTopic", ["conversationId", "categoryId"]),
|
|
292
|
+
pinTopic: r("moderation.pinTopic", ["conversationId", "pinned"]),
|
|
293
|
+
// M3 FX (R3): the rev of the text the moderator read.
|
|
294
|
+
reviewPremod: r("moderation.reviewPremod", ["conversationId", "seq", "rev", "outcome", "ruleId", "facts", "locale"])
|
|
225
295
|
},
|
|
226
296
|
notices: {
|
|
227
|
-
submit: (
|
|
228
|
-
const
|
|
229
|
-
return
|
|
297
|
+
submit: (s, i) => {
|
|
298
|
+
const a = u(s, ["category", "target", "description", "ruleId", "turnstileToken", "confirmations"]);
|
|
299
|
+
return a.target !== void 0 && (a.target = R(a.target)), d(s?.notifier) ? a.notifier = u(s.notifier, ["name", "email", "locale"]) : s?.notifier === null && (a.notifier = null), l("notices.submit", a, i);
|
|
230
300
|
},
|
|
231
|
-
status:
|
|
232
|
-
appeal:
|
|
233
|
-
withdrawAppeal:
|
|
301
|
+
status: r("notices.status", ["receipt"]),
|
|
302
|
+
appeal: r("notices.appeal", ["receipt", "body"]),
|
|
303
|
+
withdrawAppeal: r("notices.withdrawAppeal", ["receipt"])
|
|
234
304
|
}
|
|
235
305
|
};
|
|
236
306
|
}
|
|
237
307
|
export {
|
|
238
|
-
|
|
239
|
-
|
|
308
|
+
W as COMMUNITY_ANSWER_FIELDS,
|
|
309
|
+
Y as COMMUNITY_ANSWER_VARIANTS,
|
|
310
|
+
ie as createCommunityClient
|
|
240
311
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The forum's helpers (m3-contracts.md §3.2–§3.5, §4.3, §4.4, §4.8, §4.9, §5.2): what a page builds before it asks
|
|
3
|
+
* kb-api, and what it reads out of an answer — pure functions, no I/O.
|
|
4
|
+
*
|
|
5
|
+
* followTargetOf / followKeyOf `me/follows/set`'s target from a kind and an id (the follow button's attributes);
|
|
6
|
+
* forumTopicTitleOf a topic's title as kb-api takes it (1..200 UTF-16 units, as its schema counts);
|
|
7
|
+
* forumSearchQueryOf / nextSearchPage a query kb-api takes (2..200 characters) and the next of the 5 pages;
|
|
8
|
+
* knownTopicItemsOf a category's rows of the kinds this SDK renders (open enum: the rest is skipped);
|
|
9
|
+
* surfaceInfoOf / communityAwayOf MyState's surfaces and away mode, with an older kb-api's absence handled;
|
|
10
|
+
* isCategoryModerator whether the viewer moderates a category now (MyState `moderator`);
|
|
11
|
+
* brakedSurfaceOf which surface a BRAKED refusal paused (null: the module's brake, both).
|
|
12
|
+
*/
|
|
13
|
+
import type { CommunityFailure } from './outcome.js';
|
|
14
|
+
import { type CommunityAway, type FollowTarget, type KnownBrakeSurface, type KnownFollowTargetKind, type KnownTopicItem, type ForumSearchPage, type ModuleInfo, type MyState, type SurfaceInfo, type TopicItem } from './shapes.js';
|
|
15
|
+
/**
|
|
16
|
+
* `me/follows/set`'s target from a kind and an id — a follow button's `target-kind` and `target-id`: `conversation` (a
|
|
17
|
+
* topic, or an article discussion that has its conversation: the button appears once it has one) or `category`. Null
|
|
18
|
+
* for any other kind or for an id that is no UUID — no request is built from arbitrary text. The id goes lower case.
|
|
19
|
+
*/
|
|
20
|
+
export declare function followTargetOf(kind: unknown, id: unknown): FollowTarget | null;
|
|
21
|
+
/** A follow target's kind and id (the target `me/follows/list` names back as `targetKind` / `targetId`), or null. */
|
|
22
|
+
export declare function followTargetParts(target: unknown): {
|
|
23
|
+
readonly kind: KnownFollowTargetKind;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* One key per followed thing (`conversation:<id>`, `category:<id>`, lower case) — for a page's map of what the member
|
|
28
|
+
* follows, built from a FollowTarget or from a `me/follows/list` row (`targetKind`, `targetId`). Null for neither.
|
|
29
|
+
*/
|
|
30
|
+
export declare function followKeyOf(target: FollowTarget | {
|
|
31
|
+
readonly targetKind: unknown;
|
|
32
|
+
readonly targetId: unknown;
|
|
33
|
+
} | null | undefined): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The length of a title as kb-api counts it — both of its bounds, the larger: the UTF-16 units of the title as it is sent
|
|
36
|
+
* (forumTopicTitleOf; zod's `.max(200)`) and its characters as it is stored, NFC'd (the database's `char_length`). NFC
|
|
37
|
+
* may lengthen a text — U+0958 is one unit and two characters stored —, and kb-api refuses a title past either bound
|
|
38
|
+
* (M3 FX, the review of wave 1, R15), so a title this accepts is one kb-api accepts. For a composer's counter (an emoji
|
|
39
|
+
* outside the basic plane counts two).
|
|
40
|
+
*/
|
|
41
|
+
export declare function topicTitleLength(raw: unknown): number;
|
|
42
|
+
/**
|
|
43
|
+
* A topic's title as kb-api takes it (`forum/topics/create`, `messages/edit { title }`): trimmed and on one line, 1 to
|
|
44
|
+
* COMMUNITY_TOPIC_TITLE_MAX as topicTitleLength counts — or null for anything else, so the page says so instead of asking
|
|
45
|
+
* (kb-api would answer `invalid` with `fields: ['title']`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function forumTopicTitleOf(raw: unknown): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* The query as kb-api takes it: trimmed, inner runs of blanks as one space, at least COMMUNITY_SEARCH_QUERY_MIN
|
|
50
|
+
* characters and at most COMMUNITY_SEARCH_QUERY_MAX — counted the stricter way at each end (characters for the floor,
|
|
51
|
+
* UTF-16 units for the ceiling, as a schema's string length counts them), so kb-api never refuses one this accepts.
|
|
52
|
+
* Null for anything else — the page says so instead of asking (kb-api would answer VALIDATION and spend the quota).
|
|
53
|
+
*/
|
|
54
|
+
export declare function forumSearchQueryOf(raw: unknown): string | null;
|
|
55
|
+
/** The next page of a search, or null on the last one (`hasMore` false, or page COMMUNITY_SEARCH_PAGES_MAX). */
|
|
56
|
+
export declare function nextSearchPage(page: Pick<ForumSearchPage, 'page' | 'hasMore'> | null | undefined): number | null;
|
|
57
|
+
/** A row of a kind this SDK renders: a topic or an article discussion with the fields a row needs. */
|
|
58
|
+
export declare function isKnownTopicItem(item: unknown): item is KnownTopicItem;
|
|
59
|
+
/** A category's rows without the kinds this SDK does not know (a newer kb-api's), in order, never a throw. */
|
|
60
|
+
export declare function knownTopicItemsOf(items: readonly TopicItem[] | null | undefined): KnownTopicItem[];
|
|
61
|
+
/**
|
|
62
|
+
* One surface of MyState's `module.surfaces` — `forum` or `article_discussions` (a BRAKED refusal's spelling) — or null
|
|
63
|
+
* when kb-api did not report it (older than M3: no forum there). A brake without its end is no brake here: a surface
|
|
64
|
+
* brake always ends (≤ 24 h, the database's CHECK).
|
|
65
|
+
*/
|
|
66
|
+
export declare function surfaceInfoOf(module: Pick<ModuleInfo, 'surfaces'> | null | undefined, surface: KnownBrakeSurface): SurfaceInfo | null;
|
|
67
|
+
/**
|
|
68
|
+
* The team's away mode („nepřítomen", D-M3-9) while it lasts — MyState's `module.away` whose `until` is still ahead of
|
|
69
|
+
* `now` — else null (none, ended, or a kb-api older than M3). Show `state.away` meanwhile.
|
|
70
|
+
*/
|
|
71
|
+
export declare function communityAwayOf(module: Pick<ModuleInfo, 'away'> | null | undefined, now?: number): CommunityAway | null;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the viewer moderates `categoryId` now (MyState `moderator.categoryIds`; ids compared in lower case). A
|
|
74
|
+
* page shows the moderator's menu by it; kb-api re-checks the appointment on every moderator operation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isCategoryModerator(state: Pick<MyState, 'moderator'> | null | undefined, categoryId: string | null | undefined): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Which surface a BRAKED refusal paused — `forum` or `article_discussions`: show that surface paused and leave the
|
|
79
|
+
* other as it is — or null for the module's brake (both paused), for a surface this SDK does not know, and for any
|
|
80
|
+
* other refusal.
|
|
81
|
+
*/
|
|
82
|
+
export declare function brakedSurfaceOf(failure: Pick<CommunityFailure, 'code' | 'surface'> | null | undefined): KnownBrakeSurface | null;
|