@blogmcp/sdk 0.8.1 → 0.9.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 (89) hide show
  1. package/dist/community/channels.d.ts +12 -0
  2. package/dist/community/channels.js +7 -0
  3. package/dist/community/client.d.ts +211 -0
  4. package/dist/community/client.js +188 -0
  5. package/dist/community/index.d.ts +34 -0
  6. package/dist/community/index.js +93 -0
  7. package/dist/community/links.d.ts +73 -0
  8. package/dist/community/links.js +85 -0
  9. package/dist/community/messages.cs.d.ts +331 -0
  10. package/dist/community/messages.cs.js +342 -0
  11. package/dist/community/messages.d.ts +40 -0
  12. package/dist/community/messages.en.d.ts +315 -0
  13. package/dist/community/messages.en.js +313 -0
  14. package/dist/community/messages.js +66 -0
  15. package/dist/community/outcome.d.ts +96 -0
  16. package/dist/community/outcome.js +211 -0
  17. package/dist/community/poll.d.ts +35 -0
  18. package/dist/community/poll.js +70 -0
  19. package/dist/community/routes.d.ts +110 -0
  20. package/dist/community/routes.js +66 -0
  21. package/dist/community/server/bff.d.ts +123 -0
  22. package/dist/community/server/bff.js +214 -0
  23. package/dist/community/server/env.d.ts +20 -0
  24. package/dist/community/server/env.js +16 -0
  25. package/dist/community/server/host-routes.d.ts +15 -0
  26. package/dist/community/server/host-routes.js +35 -0
  27. package/dist/community/server/http.d.ts +64 -0
  28. package/dist/community/server/http.js +90 -0
  29. package/dist/community/server/index.d.ts +45 -0
  30. package/dist/community/server/index.js +19 -0
  31. package/dist/community/server/route-decision.d.ts +70 -0
  32. package/dist/community/server/route-decision.js +89 -0
  33. package/dist/community/server/unknown-path.d.ts +21 -0
  34. package/dist/community/server/unknown-path.js +11 -0
  35. package/dist/community/shapes.d.ts +472 -0
  36. package/dist/community/shapes.js +63 -0
  37. package/dist/community/store.d.ts +183 -0
  38. package/dist/community/store.js +423 -0
  39. package/dist/community/transport.d.ts +42 -0
  40. package/dist/community/transport.js +59 -0
  41. package/dist/core/client.d.ts +17 -0
  42. package/dist/core/client.js +58 -55
  43. package/dist/core/comments-legacy.d.ts +19 -0
  44. package/dist/core/comments-legacy.js +18 -0
  45. package/dist/core/index.d.ts +3 -0
  46. package/dist/core/index.js +107 -101
  47. package/dist/core/queries.d.ts +46 -0
  48. package/dist/core/queries.js +128 -84
  49. package/dist/core/seo.js +40 -39
  50. package/dist/core/translations/cs.json.js +6 -6
  51. package/dist/core/translations/en.json.js +1 -1
  52. package/dist/core/types.d.ts +23 -1
  53. package/dist/core/view-model.d.ts +7 -0
  54. package/dist/core/view-model.js +29 -25
  55. package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
  56. package/dist/react/KbMdxContent.js +4 -3
  57. package/dist/vue/components/KbMdxContent.vue2.js +3 -2
  58. package/dist/vue/composables/useKbComments.d.ts +8 -0
  59. package/package.json +13 -4
  60. package/src/community/channels.ts +12 -0
  61. package/src/community/client.ts +437 -0
  62. package/src/community/index.ts +192 -0
  63. package/src/community/links.ts +174 -0
  64. package/src/community/messages.cs.ts +371 -0
  65. package/src/community/messages.en.ts +341 -0
  66. package/src/community/messages.ts +112 -0
  67. package/src/community/outcome.ts +317 -0
  68. package/src/community/poll.ts +154 -0
  69. package/src/community/routes.ts +139 -0
  70. package/src/community/server/bff.ts +530 -0
  71. package/src/community/server/env.ts +42 -0
  72. package/src/community/server/host-routes.ts +48 -0
  73. package/src/community/server/http.ts +175 -0
  74. package/src/community/server/index.ts +55 -0
  75. package/src/community/server/route-decision.ts +226 -0
  76. package/src/community/server/unknown-path.ts +32 -0
  77. package/src/community/shapes.ts +541 -0
  78. package/src/community/store.ts +786 -0
  79. package/src/community/transport.ts +111 -0
  80. package/src/core/client.ts +24 -1
  81. package/src/core/comments-legacy.ts +39 -0
  82. package/src/core/index.ts +8 -0
  83. package/src/core/queries.ts +93 -0
  84. package/src/core/seo.ts +5 -1
  85. package/src/core/translations/cs.json +3 -1
  86. package/src/core/translations/en.json +3 -1
  87. package/src/core/types.ts +19 -1
  88. package/src/core/view-model.ts +12 -1
  89. package/src/vue/composables/useKbComments.ts +8 -0
@@ -0,0 +1,12 @@
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.
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).
8
+ */
9
+ export declare const COMMUNITY_CHANNELS: Readonly<{
10
+ readonly discussion: (conversationId: string) => string;
11
+ readonly inbox: "u:inbox";
12
+ }>;
@@ -0,0 +1,7 @@
1
+ const o = Object.freeze({
2
+ discussion: (e) => `d:${e}`,
3
+ inbox: "u:inbox"
4
+ });
5
+ export {
6
+ o as COMMUNITY_CHANNELS
7
+ };
@@ -0,0 +1,211 @@
1
+ /**
2
+ * The community's public client (docs/internal/m1-contracts.md §10.2): one method per operation of kb-api's public
3
+ * API and notice form (§7.4, §7.7, §8.3), each a POST of a JSON body through the host — never to kb-api itself.
4
+ *
5
+ * const community = createCommunityClient({ base: '/api/community' })
6
+ * const page = await community.discussions.list({ articleId, languageCode: 'cs' })
7
+ * if (page.ok) store.applyPage(page.value)
8
+ * else show(communityMessage(lang, `error.${page.code}`))
9
+ *
10
+ * Every method resolves to a CommunityOutcome and never throws: a refusal is `{ ok: false, code }` with the page's
11
+ * code (outcome.ts), an unreachable host is `unavailable`. The body sent is built from the fields the operation
12
+ * takes — anything else the caller passed stays home (kb-api refuses unknown fields). The answer is what kb-api sent,
13
+ * typed (shapes.ts); its open enums are the page's to skip (the discussion store does it for a thread).
14
+ *
15
+ * Built once per page (or element): it holds no state but its configuration.
16
+ */
17
+ import { type CommunityLogger, type CommunityOutcome } from './outcome.js';
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';
20
+ import { type CommunityTransport } from './transport.js';
21
+ export interface CommunityClientConfig {
22
+ /**
23
+ * The HOST's relative base, e.g. `/api/community` (the managed blog's proxy, a headless site's BFF). Never
24
+ * kb-api's origin: an absolute URL throws a TypeError here.
25
+ */
26
+ base: string;
27
+ /** The replaceable layer (default `fetchTransport(base)`): a test injects one, a signing transport plugs in later. */
28
+ transport?: CommunityTransport;
29
+ /**
30
+ * Per request, in milliseconds (default 10 000): 1 … 2 147 483 647, the range a timer keeps; a fraction is rounded
31
+ * down. Anything else (0, a negative, `Infinity`, `NaN`, past the range) is the default, warned once.
32
+ */
33
+ timeoutMs?: number;
34
+ now?: () => number;
35
+ /** Sees operation, outcome, kb-api code and status of the failures worth an operator's eye — nothing else. */
36
+ logger?: CommunityLogger;
37
+ }
38
+ /** Per call: a signal that cancels the request (an element that unmounts). */
39
+ export interface CommunityCallOptions {
40
+ signal?: AbortSignal;
41
+ }
42
+ type Call<I, T> = (input: I, options?: CommunityCallOptions) => Promise<CommunityOutcome<T>>;
43
+ type CallOptionalInput<I, T> = (input?: I, options?: CommunityCallOptions) => Promise<CommunityOutcome<T>>;
44
+ type CallNoInput<T> = (options?: CommunityCallOptions) => Promise<CommunityOutcome<T>>;
45
+ export interface CommunityClient {
46
+ discussions: {
47
+ /** One page of an article's discussion (anonymous allowed); `cursor` is the previous page's `nextCursor`. */
48
+ list: Call<DiscussionListInput, Discussion>;
49
+ /** The polling signal of up to COMMUNITY_HEAD_ARTICLES_MAX articles (pollDiscussionHead). */
50
+ head: Call<{
51
+ articleIds: readonly string[];
52
+ }, {
53
+ heads: DiscussionHead[];
54
+ }>;
55
+ };
56
+ messages: {
57
+ post: Call<MessagePostInput, WriteAnswer>;
58
+ edit: Call<MessageEditInput, WriteAnswer>;
59
+ /** The member's own message becomes a tombstone (a placeholder only while it has visible replies). */
60
+ delete: Call<{
61
+ conversationId: string;
62
+ seq: number;
63
+ }, {
64
+ message: PublicMessage;
65
+ }>;
66
+ report: Call<MessageReportInput, {
67
+ caseId: string;
68
+ }>;
69
+ };
70
+ reactions: {
71
+ /** `emoji: null` removes the member's reaction. */
72
+ set: Call<{
73
+ target: ReactionTarget;
74
+ emoji: string | null;
75
+ }, {
76
+ target: ReactionTarget;
77
+ reactions: ReactionSummary;
78
+ }>;
79
+ };
80
+ blocks: {
81
+ /** Silent: the blocked member learns of it from nothing. Their messages come back `collapsed`. */
82
+ set: Call<{
83
+ memberId: string;
84
+ blocked: boolean;
85
+ }, {
86
+ memberId: string;
87
+ blocked: boolean;
88
+ }>;
89
+ list: CallNoInput<{
90
+ blocks: BlockEntry[];
91
+ }>;
92
+ };
93
+ profile: {
94
+ /** A signed-in viewer only; an unknown id or handle, an erased member are the same `notFound`. */
95
+ get: Call<{
96
+ memberId: string;
97
+ } | {
98
+ handle: string;
99
+ }, PublicProfile>;
100
+ };
101
+ me: {
102
+ /** Anonymous: `{ member: null, needs: ['sign_in'] }`. */
103
+ get: CallNoInput<MyState>;
104
+ /** The light onboarding: the age band, the rules (and the consent when asked), the profile. */
105
+ onboard: Call<OnboardInput, MyState>;
106
+ updateProfile: Call<ProfileUpdateInput, {
107
+ profile: OwnProfile;
108
+ }>;
109
+ notifications: {
110
+ list: CallOptionalInput<{
111
+ cursor?: string | null;
112
+ }, CommunityPage<NotificationItem>>;
113
+ markRead: Call<{
114
+ ids: readonly string[];
115
+ }, {
116
+ updated: number;
117
+ }>;
118
+ };
119
+ decisions: {
120
+ list: CallOptionalInput<{
121
+ cursor?: string | null;
122
+ }, CommunityPage<DecisionSummary>>;
123
+ /** The statement of reasons; a decision about someone else is `notFound`. */
124
+ get: Call<{
125
+ decisionId: string;
126
+ }, Statement>;
127
+ };
128
+ appeals: {
129
+ file: Call<{
130
+ decisionId: string;
131
+ body: string;
132
+ }, {
133
+ appealId: string;
134
+ submittedAt: string;
135
+ }>;
136
+ withdraw: Call<{
137
+ appealId: string;
138
+ }, {
139
+ appealId: string;
140
+ status: 'withdrawn';
141
+ }>;
142
+ list: CallNoInput<{
143
+ items: AppealItem[];
144
+ }>;
145
+ };
146
+ reports: {
147
+ list: CallNoInput<{
148
+ items: ReportItem[];
149
+ }>;
150
+ };
151
+ consents: {
152
+ /** As easy as giving it; later writes ask for it again where the tenant requires it. */
153
+ withdraw: CallOptionalInput<{
154
+ kind: 'art9_consent';
155
+ }, {
156
+ kind: 'art9_consent';
157
+ state: string;
158
+ }>;
159
+ };
160
+ /** Every section of the member's data, `providerEntity` on every row: offer it as a JSON download. */
161
+ export: CallNoInput<MemberExport>;
162
+ /** The profile's deletion, after the grace period (`purgeAfter`); writes are refused meanwhile. */
163
+ erase: CallNoInput<{
164
+ status: 'deletion_requested';
165
+ purgeAfter: string;
166
+ }>;
167
+ cancelErase: CallNoInput<{
168
+ status: 'active' | 'read_only';
169
+ }>;
170
+ };
171
+ legal: {
172
+ current: Call<{
173
+ kind: LegalTextKind;
174
+ locale: string;
175
+ }, CurrentLegalText>;
176
+ };
177
+ notices: {
178
+ /** Anyone, with or without a session; `confirmations` must hold COMMUNITY_GOOD_FAITH. */
179
+ submit: Call<NoticeSubmitInput, NoticeReceipt>;
180
+ status: Call<{
181
+ receipt: string;
182
+ }, NoticeStatus>;
183
+ appeal: Call<{
184
+ receipt: string;
185
+ body: string;
186
+ }, {
187
+ appealId: string;
188
+ submittedAt: string;
189
+ }>;
190
+ withdrawAppeal: Call<{
191
+ receipt: string;
192
+ }, {
193
+ appealId: string;
194
+ status: 'withdrawn';
195
+ resolvedAt: string;
196
+ }>;
197
+ };
198
+ }
199
+ /** The kind of a field an answer must hold. */
200
+ export type CommunityAnswerField = 'string' | 'number' | 'boolean' | 'array' | 'record';
201
+ /**
202
+ * What each operation's answer must hold to count as one (else `unavailable`: the host did not answer as the API
203
+ * does), field by field. test/community/ops-drift.spec.ts pins every field to kb-api's declaration of the answer.
204
+ */
205
+ export declare const COMMUNITY_ANSWER_FIELDS: Readonly<Record<CommunityOpName, Readonly<Record<string, CommunityAnswerField>>>>;
206
+ /**
207
+ * The client. Throws a TypeError for a base that is not relative — the one throw, at construction (a page that
208
+ * passes kb-api's URL has a bug to fix, not an outcome to show).
209
+ */
210
+ export declare function createCommunityClient(config: CommunityClientConfig): CommunityClient;
211
+ export {};
@@ -0,0 +1,188 @@
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;
6
+ let E = !1;
7
+ function z(e) {
8
+ if (e === void 0) return _;
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.")), _);
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,
14
+ number: (e) => typeof e == "number",
15
+ boolean: (e) => typeof e == "boolean",
16
+ array: I,
17
+ record: d
18
+ }), s = (e) => Object.freeze({ ...e }), B = Object.freeze({
19
+ "discussions.list": s({ articleId: "string", messages: "array", viewer: "record" }),
20
+ "discussions.head": s({ heads: "array" }),
21
+ "messages.post": s({ message: "record", warnings: "array" }),
22
+ "messages.edit": s({ message: "record", warnings: "array" }),
23
+ "messages.delete": s({ message: "record" }),
24
+ "messages.report": s({ caseId: "string" }),
25
+ "reactions.set": s({ reactions: "record" }),
26
+ "blocks.set": s({ blocked: "boolean" }),
27
+ "blocks.list": s({ blocks: "array" }),
28
+ "profile.get": s({ author: "record" }),
29
+ "me.get": s({ needs: "array" }),
30
+ "me.onboard": s({ needs: "array" }),
31
+ "me.updateProfile": s({ profile: "record" }),
32
+ "me.notifications.list": s({ items: "array" }),
33
+ "me.notifications.markRead": s({ updated: "number" }),
34
+ "me.decisions.list": s({ items: "array" }),
35
+ "me.decisions.get": s({ decisionId: "string" }),
36
+ "me.appeals.file": s({ appealId: "string" }),
37
+ "me.appeals.withdraw": s({ appealId: "string" }),
38
+ "me.appeals.list": s({ items: "array" }),
39
+ "me.reports.list": s({ items: "array" }),
40
+ "me.consents.withdraw": s({ state: "string" }),
41
+ "me.export": s({ generatedAt: "string" }),
42
+ "me.erase": s({ purgeAfter: "string" }),
43
+ "me.cancelErase": s({ status: "string" }),
44
+ "legal.current": s({ textId: "string" }),
45
+ "notices.submit": s({ caseId: "string", receipt: "string" }),
46
+ "notices.status": s({ status: "string" }),
47
+ "notices.appeal": s({ appealId: "string" }),
48
+ "notices.withdrawAppeal": s({ appealId: "string" })
49
+ }), W = (e, n) => Object.entries(B[e]).every(([r, c]) => D[c](n[r]));
50
+ function m(e, n) {
51
+ const r = {};
52
+ if (!d(e)) return r;
53
+ for (const c of n) e[c] !== void 0 && (r[c] = e[c]);
54
+ return r;
55
+ }
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;
58
+ }
59
+ const X = /^[A-Za-z0-9_.:-]{1,64}$/, S = 20;
60
+ function Y(e) {
61
+ if (I(e))
62
+ return e.filter((n) => A(n) && X.test(n)).slice(0, S);
63
+ }
64
+ function K(e) {
65
+ return I(e) ? e.filter(R).slice(0, S) : void 0;
66
+ }
67
+ 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;
69
+ }
70
+ function v(e) {
71
+ return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.ceil(e) : void 0;
72
+ }
73
+ 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;
82
+ }
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)))
87
+ try {
88
+ c({ op: t, outcome: i, kbCode: a, status: w });
89
+ } catch {
90
+ }
91
+ };
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;
97
+ 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;
102
+ } finally {
103
+ clearTimeout(N), O?.removeEventListener("abort", M);
104
+ }
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;
109
+ }
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" });
113
+ }
114
+ if (y === 429) {
115
+ const u = v(b.retryAfterS);
116
+ return u === void 0 ? { ok: !1, code: "fast" } : { ok: !1, code: "fast", retryAfterS: u };
117
+ }
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 };
121
+ }
122
+ const o = (t, i) => (a, w) => l(t, m(a, i), w), g = (t) => (i) => l(t, {}, i);
123
+ return {
124
+ 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)
127
+ },
128
+ 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"])
133
+ },
134
+ reactions: {
135
+ set: (t, i) => l("reactions.set", { target: C(t?.target), emoji: t?.emoji ?? null }, i)
136
+ },
137
+ blocks: {
138
+ set: o("blocks.set", ["memberId", "blocked"]),
139
+ list: g("blocks.list")
140
+ },
141
+ profile: {
142
+ get: (t, i) => l("profile.get", d(t) && "handle" in t ? m(t, ["handle"]) : m(t, ["memberId"]), i)
143
+ },
144
+ 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"]),
148
+ 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)
151
+ },
152
+ decisions: {
153
+ list: o("me.decisions.list", ["cursor"]),
154
+ get: o("me.decisions.get", ["decisionId"])
155
+ },
156
+ appeals: {
157
+ file: o("me.appeals.file", ["decisionId", "body"]),
158
+ withdraw: o("me.appeals.withdraw", ["appealId"]),
159
+ list: g("me.appeals.list")
160
+ },
161
+ reports: {
162
+ list: g("me.reports.list")
163
+ },
164
+ consents: {
165
+ withdraw: (t, i) => l("me.consents.withdraw", { kind: "art9_consent" }, i)
166
+ },
167
+ export: g("me.export"),
168
+ erase: g("me.erase"),
169
+ cancelErase: g("me.cancelErase")
170
+ },
171
+ legal: {
172
+ current: o("legal.current", ["kind", "locale"])
173
+ },
174
+ 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);
178
+ },
179
+ status: o("notices.status", ["receipt"]),
180
+ appeal: o("notices.appeal", ["receipt", "body"]),
181
+ withdrawAppeal: o("notices.withdrawAppeal", ["receipt"])
182
+ }
183
+ };
184
+ }
185
+ export {
186
+ B as COMMUNITY_ANSWER_FIELDS,
187
+ V as createCommunityClient
188
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `@blogmcp/sdk/community` — the community's browser client (docs/internal/m1-contracts.md §10.2; community.md
3
+ * §3.7, §7.7): the public discussion of an article, the member's „Moje komunita", the DSA notice form — through
4
+ * the host's relative base, never to kb-api directly.
5
+ *
6
+ * createCommunityClient one method per operation, every one a POST through the host, none ever throws;
7
+ * createDiscussionStore the immutable two-level thread, optimistic writes, open enums skipped;
8
+ * pollDiscussionHead the polling signal while the discussion is visible (no realtime in M1);
9
+ * communityMessage every text, cs and en, under the tone test;
10
+ * links statements, the panel, the notifier's receipt in the fragment.
11
+ *
12
+ * Browser-safe: nothing here takes a key, a session, a cookie or an IP, and nothing imports `node:*`. This entry
13
+ * never reaches the server entries (`@blogmcp/sdk/community/server`, `@blogmcp/sdk/consultations/server`), the
14
+ * adapter client or the delegated-identity minter — test/community/entry-boundary.spec.ts walks its import graph.
15
+ * It has no path to the private or staff routes; their client is its own entry, later.
16
+ */
17
+ export { createCommunityClient } from './client.js';
18
+ export type { CommunityClient, CommunityClientConfig, CommunityCallOptions } from './client.js';
19
+ export { COMMUNITY_OPS, communityOpPath, newClientMsgId, COMMUNITY_MESSAGE_MAX, COMMUNITY_MESSAGE_LINKS_MAX, COMMUNITY_REPORT_NOTE_MAX, COMMUNITY_APPEAL_MAX, COMMUNITY_NOTICE_DESCRIPTION_MAX, COMMUNITY_NOTIFIER_NAME_MAX, COMMUNITY_DISPLAY_NAME_MIN, COMMUNITY_DISPLAY_NAME_MAX, COMMUNITY_BIO_MAX, COMMUNITY_HANDLE_RE, COMMUNITY_HANDLE_CHANGE_DAYS, COMMUNITY_HEAD_ARTICLES_MAX, COMMUNITY_PAGE_SIZE, COMMUNITY_REPLIES_MAX, COMMUNITY_NOTICE_TURNSTILE_ACTION, COMMUNITY_GOOD_FAITH, COMMUNITY_CLIENT_MSG_ID_RE, } from './routes.js';
20
+ export type { CommunityOp, CommunityOpName, CommunitySurface } from './routes.js';
21
+ 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
+ export type { CommunityUiCode, CommunityApiCode, CommunityHostCode, CommunityOutcome, CommunityFailure, CommunityLogger, } from './outcome.js';
23
+ export { fetchTransport, isRelativeCommunityBase, assertCommunityBase, communityOpUrl } from './transport.js';
24
+ 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';
27
+ 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';
29
+ export { pollDiscussionHead, POLL_INTERVAL_MS, POLL_MAX_BACKOFF_MS } from './poll.js';
30
+ export type { PollDiscussionHeadOptions, DiscussionHeadPoller } from './poll.js';
31
+ 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';
34
+ export type { CommunityMessageKey, CommunityMessageLanguage } from './messages.js';
@@ -0,0 +1,93 @@
1
+ import { createCommunityClient as _ } from "./client.js";
2
+ import { COMMUNITY_APPEAL_MAX as O, COMMUNITY_BIO_MAX as t, COMMUNITY_CLIENT_MSG_ID_RE as I, COMMUNITY_DISPLAY_NAME_MAX as C, COMMUNITY_DISPLAY_NAME_MIN as T, COMMUNITY_GOOD_FAITH as i, COMMUNITY_HANDLE_CHANGE_DAYS as s, COMMUNITY_HANDLE_RE as n, COMMUNITY_HEAD_ARTICLES_MAX as N, COMMUNITY_MESSAGE_LINKS_MAX as E, COMMUNITY_MESSAGE_MAX as r, COMMUNITY_NOTICE_DESCRIPTION_MAX as m, COMMUNITY_NOTICE_TURNSTILE_ACTION as A, COMMUNITY_NOTIFIER_NAME_MAX as S, COMMUNITY_OPS as a, COMMUNITY_PAGE_SIZE as U, COMMUNITY_REPLIES_MAX as Y, COMMUNITY_REPORT_NOTE_MAX as u, communityOpPath as c, newClientMsgId as L } from "./routes.js";
3
+ import { COMMUNITY_API_CODES as y, COMMUNITY_HOST_CODES as D, COMMUNITY_OUTCOME_OF_HOST as f, COMMUNITY_OUTCOME_OF_KB as p, COMMUNITY_UI_CODES as g, CommunityTransportError as K, communityFailureOf as P, communityOutcomeOf as H, isCommunityTransportError as d, isCommunityUiCode as F, isLoggedCommunityOutcome as G } from "./outcome.js";
4
+ import { assertCommunityBase as h, communityOpUrl as l, fetchTransport as w, isRelativeCommunityBase as x } from "./transport.js";
5
+ import { AGE_BANDS as k, AUTHOR_KINDS as v, CASE_CATEGORIES as V, CATEGORY_WITHOUT_NOTIFIER as W, LEGAL_TEXT_KINDS as Z, MESSAGE_STATES as b, NEEDS as j, NOTIFICATION_CODES as q, RESTRICTION_KINDS as z, communityLegalSectionsOf as J, communityRulesOf as Q, isCaseCategory as $, isKnownAuthor as MM, isKnownAuthorKind as eM, isKnownNeed as _M, isKnownNotificationCode as oM, isKnownRestrictionKind as OM, isKnownState as tM } from "./shapes.js";
6
+ import { createDiscussionStore as CM, findMessage as TM, isOwnMessage as iM, loadMoreDiscussion as sM, reactionAfter as nM, reactionsFor as NM, refreshDiscussion as EM, viewerNeeds as rM } from "./store.js";
7
+ import { POLL_INTERVAL_MS as AM, POLL_MAX_BACKOFF_MS as SM, pollDiscussionHead as aM } from "./poll.js";
8
+ import { COMMUNITY_CHANNELS as YM } from "./channels.js";
9
+ import { COMMUNITY_RECEIPT_RE as cM, COMMUNITY_ROUTES as LM, myCommunityPath as RM, noticeStatusLink as yM, readReceiptFromHash as DM, receiptFromHash as fM, signInLink as pM, statementPath as gM } from "./links.js";
10
+ import { COMMUNITY_MESSAGES as PM, communityMessage as HM, communityMessageLanguage as dM, confirmMessageKey as FM, hasCommunityMessage as GM, noteMessageKey as XM, warningMessageKey as hM } from "./messages.js";
11
+ export {
12
+ k as AGE_BANDS,
13
+ v as AUTHOR_KINDS,
14
+ V as CASE_CATEGORIES,
15
+ W as CATEGORY_WITHOUT_NOTIFIER,
16
+ y as COMMUNITY_API_CODES,
17
+ O as COMMUNITY_APPEAL_MAX,
18
+ t as COMMUNITY_BIO_MAX,
19
+ YM as COMMUNITY_CHANNELS,
20
+ I as COMMUNITY_CLIENT_MSG_ID_RE,
21
+ C as COMMUNITY_DISPLAY_NAME_MAX,
22
+ T as COMMUNITY_DISPLAY_NAME_MIN,
23
+ i as COMMUNITY_GOOD_FAITH,
24
+ s as COMMUNITY_HANDLE_CHANGE_DAYS,
25
+ n as COMMUNITY_HANDLE_RE,
26
+ N as COMMUNITY_HEAD_ARTICLES_MAX,
27
+ D as COMMUNITY_HOST_CODES,
28
+ PM as COMMUNITY_MESSAGES,
29
+ E as COMMUNITY_MESSAGE_LINKS_MAX,
30
+ r as COMMUNITY_MESSAGE_MAX,
31
+ m as COMMUNITY_NOTICE_DESCRIPTION_MAX,
32
+ A as COMMUNITY_NOTICE_TURNSTILE_ACTION,
33
+ S as COMMUNITY_NOTIFIER_NAME_MAX,
34
+ a as COMMUNITY_OPS,
35
+ f as COMMUNITY_OUTCOME_OF_HOST,
36
+ p as COMMUNITY_OUTCOME_OF_KB,
37
+ U as COMMUNITY_PAGE_SIZE,
38
+ cM as COMMUNITY_RECEIPT_RE,
39
+ Y as COMMUNITY_REPLIES_MAX,
40
+ u as COMMUNITY_REPORT_NOTE_MAX,
41
+ LM as COMMUNITY_ROUTES,
42
+ g as COMMUNITY_UI_CODES,
43
+ K as CommunityTransportError,
44
+ Z as LEGAL_TEXT_KINDS,
45
+ b as MESSAGE_STATES,
46
+ j as NEEDS,
47
+ q as NOTIFICATION_CODES,
48
+ AM as POLL_INTERVAL_MS,
49
+ SM as POLL_MAX_BACKOFF_MS,
50
+ z as RESTRICTION_KINDS,
51
+ h as assertCommunityBase,
52
+ P as communityFailureOf,
53
+ J as communityLegalSectionsOf,
54
+ HM as communityMessage,
55
+ dM as communityMessageLanguage,
56
+ c as communityOpPath,
57
+ l as communityOpUrl,
58
+ H as communityOutcomeOf,
59
+ Q as communityRulesOf,
60
+ FM as confirmMessageKey,
61
+ _ as createCommunityClient,
62
+ CM as createDiscussionStore,
63
+ w as fetchTransport,
64
+ TM as findMessage,
65
+ GM as hasCommunityMessage,
66
+ $ as isCaseCategory,
67
+ d as isCommunityTransportError,
68
+ F as isCommunityUiCode,
69
+ MM as isKnownAuthor,
70
+ eM as isKnownAuthorKind,
71
+ _M as isKnownNeed,
72
+ oM as isKnownNotificationCode,
73
+ OM as isKnownRestrictionKind,
74
+ tM as isKnownState,
75
+ G as isLoggedCommunityOutcome,
76
+ iM as isOwnMessage,
77
+ x as isRelativeCommunityBase,
78
+ sM as loadMoreDiscussion,
79
+ RM as myCommunityPath,
80
+ L as newClientMsgId,
81
+ XM as noteMessageKey,
82
+ yM as noticeStatusLink,
83
+ aM as pollDiscussionHead,
84
+ nM as reactionAfter,
85
+ NM as reactionsFor,
86
+ DM as readReceiptFromHash,
87
+ fM as receiptFromHash,
88
+ EM as refreshDiscussion,
89
+ pM as signInLink,
90
+ gM as statementPath,
91
+ rM as viewerNeeds,
92
+ hM as warningMessageKey
93
+ };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The community's deep links (docs/internal/m1-contracts.md §7.9, §10.2, §12): a statement of reasons, the
3
+ * „Moje komunita" panel, a notifier's status page — and the notifier's receipt, which travels in a link's
4
+ * FRAGMENT only (`#t=<receipt>`): a fragment never reaches a server's log, a `Referer` or a proxy, a path or a
5
+ * query would (community.md invariant 8). The page that reads it removes it from the address bar at once.
6
+ *
7
+ * The host's pages are the host's: a tenant names its own in `community.settings` (`statement_link_path` with
8
+ * `{id}`, `notice_status_link_path`, `my_community_link_path` — they come back in MyState.links) and an element
9
+ * takes them as attributes. Without them the managed blog's pages apply, COMMUNITY_ROUTES — the paths kb-api's
10
+ * deliveries fall back to (a drift spec pins them to kb-api's).
11
+ *
12
+ * Browser-safe; readReceiptFromHash is the one function that touches `window` (on call, never on import).
13
+ */
14
+ /**
15
+ * The managed blog's community pages (router-relative; the blog prepends its own base). The three legal pages —
16
+ * `rules`, `terms`, `privacy` — are each the tenant's current `legal/current` text of that kind, rendered by the blog's
17
+ * server without JavaScript, with `/community/<kind>.json` as the machine-readable alternate (DSA art. 14(1)).
18
+ */
19
+ export declare const COMMUNITY_ROUTES: Readonly<{
20
+ /** The „Moje komunita" panel. */
21
+ readonly myCommunity: "/community";
22
+ /** A statement of reasons and its appeal; `{id}` is the decision's id (statementPath). */
23
+ readonly statement: "/community/statements/{id}";
24
+ /** The notice form (anyone, no sign-in needed). */
25
+ readonly report: "/community/report";
26
+ /** A notifier's status page; the receipt goes in its fragment (noticeStatusLink). */
27
+ readonly notices: "/community/notices";
28
+ /** The rules, rendered on the server without JavaScript. */
29
+ readonly rules: "/community/rules";
30
+ /** The discussion terms (DSA art. 14), rendered on the server without JavaScript, as the rules. */
31
+ readonly terms: "/community/terms";
32
+ /** The discussion privacy notice, rendered the same way. */
33
+ readonly privacy: "/community/privacy";
34
+ }>;
35
+ /** A notifier's receipt: kb-api's `kbnt_` capability token (≤ 512 characters, base64url). */
36
+ export declare const COMMUNITY_RECEIPT_RE: RegExp;
37
+ /**
38
+ * A statement's page: `{id}` of the template filled with the decision's id. The template is the host's (its
39
+ * attribute, MyState.links.statementPath); absent, the managed blog's. Null for an id that is not a decision id, or
40
+ * a template that is no site path, lacks `{id}` or holds another brace — no link is built from arbitrary text.
41
+ */
42
+ export declare function statementPath(template: string | null | undefined, decisionId: string): string | null;
43
+ /** The „Moje komunita" page: the host's path when it is a site path, else the managed blog's. */
44
+ export declare function myCommunityPath(path?: string | null): string;
45
+ /**
46
+ * A notifier's status link: the host's status page (absent: the managed blog's) with the receipt in the
47
+ * fragment. Null for a path that is no site path or already has a fragment, and for anything that is not a receipt.
48
+ */
49
+ export declare function noticeStatusLink(path: string | null | undefined, receipt: string): string | null;
50
+ /**
51
+ * The sign-in link for an anonymous viewer: `signInHref` with the page's path in the fragment (the storefront's
52
+ * rule: the sign-in page reads it and returns there). A `signInHref` that carries a fragment already is kept as it
53
+ * is; one that is no site path, or a `returnPath` that is none, gives the bare link (or null without a usable href).
54
+ */
55
+ export declare function signInLink(signInHref: string | null | undefined, returnPath?: string | null): string | null;
56
+ /**
57
+ * The receipt in a URL fragment (`#t=<receipt>`), or null. Nothing else is read from the fragment, and only
58
+ * kb-api's exact receipt shape is accepted: a link cut short by a mail client, or with a parameter appended, is
59
+ * "no receipt", never a token sent to the host.
60
+ */
61
+ export declare function receiptFromHash(hash: string): string | null;
62
+ /**
63
+ * The notifier's receipt from the address bar, which is then cleared of it — the URL and the router's copy in
64
+ * `history.state` (`history.replaceState`, keeping the query string and the router's other state).
65
+ *
66
+ * The receipt opens the notifier's case: left in the address bar it ends up in the history, a bookmark, a shared
67
+ * link. Only a `#t=` fragment is cleared (a valid receipt or a cut one alike); the page's own anchors stay. It is
68
+ * remembered per window, so a second call (React StrictMode mounts twice, Vue remounts) still gets it from an
69
+ * address bar that is already clean; a later `#t=` link pasted into the same tab replaces it.
70
+ *
71
+ * ⚠️ In a vue-router app follow it with `router.replace({ hash: '' })`, so the router forgets the fragment too.
72
+ */
73
+ export declare function readReceiptFromHash(win?: Window): string | null;