@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.
- package/dist/community/channels.d.ts +12 -0
- package/dist/community/channels.js +7 -0
- package/dist/community/client.d.ts +211 -0
- package/dist/community/client.js +188 -0
- package/dist/community/index.d.ts +34 -0
- package/dist/community/index.js +93 -0
- package/dist/community/links.d.ts +73 -0
- package/dist/community/links.js +85 -0
- package/dist/community/messages.cs.d.ts +331 -0
- package/dist/community/messages.cs.js +342 -0
- package/dist/community/messages.d.ts +40 -0
- package/dist/community/messages.en.d.ts +315 -0
- package/dist/community/messages.en.js +313 -0
- package/dist/community/messages.js +66 -0
- package/dist/community/outcome.d.ts +96 -0
- package/dist/community/outcome.js +211 -0
- package/dist/community/poll.d.ts +35 -0
- package/dist/community/poll.js +70 -0
- package/dist/community/routes.d.ts +110 -0
- package/dist/community/routes.js +66 -0
- package/dist/community/server/bff.d.ts +123 -0
- package/dist/community/server/bff.js +214 -0
- package/dist/community/server/env.d.ts +20 -0
- package/dist/community/server/env.js +16 -0
- package/dist/community/server/host-routes.d.ts +15 -0
- package/dist/community/server/host-routes.js +35 -0
- package/dist/community/server/http.d.ts +64 -0
- package/dist/community/server/http.js +90 -0
- package/dist/community/server/index.d.ts +45 -0
- package/dist/community/server/index.js +19 -0
- package/dist/community/server/route-decision.d.ts +70 -0
- package/dist/community/server/route-decision.js +89 -0
- package/dist/community/server/unknown-path.d.ts +21 -0
- package/dist/community/server/unknown-path.js +11 -0
- package/dist/community/shapes.d.ts +472 -0
- package/dist/community/shapes.js +63 -0
- package/dist/community/store.d.ts +183 -0
- package/dist/community/store.js +423 -0
- package/dist/community/transport.d.ts +42 -0
- package/dist/community/transport.js +59 -0
- package/dist/core/client.d.ts +17 -0
- package/dist/core/client.js +58 -55
- package/dist/core/comments-legacy.d.ts +19 -0
- package/dist/core/comments-legacy.js +18 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +107 -101
- package/dist/core/queries.d.ts +46 -0
- package/dist/core/queries.js +128 -84
- package/dist/core/seo.js +40 -39
- package/dist/core/translations/cs.json.js +6 -6
- package/dist/core/translations/en.json.js +1 -1
- package/dist/core/types.d.ts +23 -1
- package/dist/core/view-model.d.ts +7 -0
- package/dist/core/view-model.js +29 -25
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
- package/dist/react/KbMdxContent.js +4 -3
- package/dist/vue/components/KbMdxContent.vue2.js +3 -2
- package/dist/vue/composables/useKbComments.d.ts +8 -0
- package/package.json +13 -4
- package/src/community/channels.ts +12 -0
- package/src/community/client.ts +437 -0
- package/src/community/index.ts +192 -0
- package/src/community/links.ts +174 -0
- package/src/community/messages.cs.ts +371 -0
- package/src/community/messages.en.ts +341 -0
- package/src/community/messages.ts +112 -0
- package/src/community/outcome.ts +317 -0
- package/src/community/poll.ts +154 -0
- package/src/community/routes.ts +139 -0
- package/src/community/server/bff.ts +530 -0
- package/src/community/server/env.ts +42 -0
- package/src/community/server/host-routes.ts +48 -0
- package/src/community/server/http.ts +175 -0
- package/src/community/server/index.ts +55 -0
- package/src/community/server/route-decision.ts +226 -0
- package/src/community/server/unknown-path.ts +32 -0
- package/src/community/shapes.ts +541 -0
- package/src/community/store.ts +786 -0
- package/src/community/transport.ts +111 -0
- package/src/core/client.ts +24 -1
- package/src/core/comments-legacy.ts +39 -0
- package/src/core/index.ts +8 -0
- package/src/core/queries.ts +93 -0
- package/src/core/seo.ts +5 -1
- package/src/core/translations/cs.json +3 -1
- package/src/core/translations/en.json +3 -1
- package/src/core/types.ts +19 -1
- package/src/core/view-model.ts +12 -1
- package/src/vue/composables/useKbComments.ts +8 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host-session route decision (docs/internal/m1-contracts.md §3.4; community.md §7.1, invariant 3): what a
|
|
3
|
+
* managed blog's `/api` proxy or a headless site's BFF does with a request for a kb-api path.
|
|
4
|
+
*
|
|
5
|
+
* kb-api's `/community` and `/trust` namespaces are open to a host session only through an allowlist of literal
|
|
6
|
+
* routes (COMMUNITY_HOST_ROUTES: kb-api's public and notice operations, host-routes.ts). The proxy answers
|
|
7
|
+
* everything else in them itself, with the uniform unknown-path answer, before it reads a cookie or computes a
|
|
8
|
+
* Bearer, and kb-api is never asked. Two surfaces stay closed to every proxy and BFF whatever the list holds: the
|
|
9
|
+
* private routes (only the member's browser calls them, directly, with a key-bound private session) and the staff
|
|
10
|
+
* routes (only the staff console).
|
|
11
|
+
*
|
|
12
|
+
* Deny by default, so the namespace test is conservative: a path is in a namespace when ANY reading of it is —
|
|
13
|
+
* raw and decoded once, twice, … until stable (an escape run that is no UTF-8 still decodes its ASCII bytes),
|
|
14
|
+
* lower-cased (Express routes case-insensitively), `\` read as `/`, empty and `.` segments dropped, `..` kept or
|
|
15
|
+
* resolved, cut at a `?` or `#` the decoding produced, with what a URL parser strips (tab, newline, blanks at the
|
|
16
|
+
* ends) or every control and blank removed, and leading `api` segments skipped. A false positive costs a 404 for
|
|
17
|
+
* a strange path; a false negative would hand kb-api a request the proxy promised never to send. The URL parser
|
|
18
|
+
* counts because the Next proxy forwards segments Next has already decoded once, and `fetch` then reads `%2e%2e`
|
|
19
|
+
* as `..` and drops a tab. A namespace path with a `..` segment, a malformed escape or a `%` left after decoding
|
|
20
|
+
* is denied, as is one that does not settle within MAX_DECODE_PASSES. The input is a path relative to kb-api's
|
|
21
|
+
* root: anything but a string, and an absolute URL (a caller passing `request.url`), fails closed.
|
|
22
|
+
*
|
|
23
|
+
* `allow` takes the canonical spelling of a listed route exactly — lower case, `[a-z0-9_-]` segments, no `%`, no
|
|
24
|
+
* `.`, no doubled or trailing slash, at most one leading `/` and one `api/` first segment, the route's method —
|
|
25
|
+
* and never a private or staff path, whatever the list says.
|
|
26
|
+
*/
|
|
27
|
+
import { COMMUNITY_HOST_ROUTES } from './host-routes.js';
|
|
28
|
+
/** The kb-api namespaces a host session may reach only through the allowlist. */
|
|
29
|
+
export declare const COMMUNITY_NAMESPACES: readonly ['community', 'trust'];
|
|
30
|
+
export interface CommunityHostRoute {
|
|
31
|
+
readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
32
|
+
/**
|
|
33
|
+
* The literal kb-api path as kb-api mounts it: `/community/v1/public/…` or `/trust/v1/…` — a leading `/`, lower
|
|
34
|
+
* case, no `/api` prefix, no query. A request matches only its canonical spelling.
|
|
35
|
+
*/
|
|
36
|
+
readonly path: string;
|
|
37
|
+
}
|
|
38
|
+
/** The host-session routes (method + literal path under the namespaces): kb-api's allowlist (host-routes.ts, S8). */
|
|
39
|
+
export { COMMUNITY_HOST_ROUTES };
|
|
40
|
+
/**
|
|
41
|
+
* The surfaces no host session ever reaches, whatever COMMUNITY_HOST_ROUTES holds (community.md invariant 3):
|
|
42
|
+
* the member's private routes and the staff console's routes. The only place under src/ that spells them out
|
|
43
|
+
* (test/community/server/boundary.spec.ts).
|
|
44
|
+
*/
|
|
45
|
+
export declare const COMMUNITY_CLOSED_PATHS: readonly ["community/v1/private", "community/v1/staff"];
|
|
46
|
+
/** What a proxy or BFF does with a request. */
|
|
47
|
+
export type CommunityRouteDecision =
|
|
48
|
+
/** Not a namespace path: the proxy's existing rules apply. */
|
|
49
|
+
{
|
|
50
|
+
kind: 'outside';
|
|
51
|
+
}
|
|
52
|
+
/** Answer `communityUnknownPath()`, call nothing upstream. */
|
|
53
|
+
| {
|
|
54
|
+
kind: 'deny';
|
|
55
|
+
}
|
|
56
|
+
/** A host route: forward to kb-api's `upstreamPath` (never in M0c). */
|
|
57
|
+
| {
|
|
58
|
+
kind: 'allow';
|
|
59
|
+
upstreamPath: string;
|
|
60
|
+
};
|
|
61
|
+
/** Is `path` (relative to kb-api's root, with or without an `api/` first segment) in a namespace — in any spelling? */
|
|
62
|
+
export declare function isCommunityNamespacePath(path: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The decision against a given allowlist — `communityRouteDecision` is this with COMMUNITY_HOST_ROUTES. Exported
|
|
65
|
+
* for the SDK's tests (an allowlist that names a private or staff path must still open nothing); not part of the
|
|
66
|
+
* entry.
|
|
67
|
+
*/
|
|
68
|
+
export declare function decideCommunityRoute(routes: readonly CommunityHostRoute[], method: string, path: string): CommunityRouteDecision;
|
|
69
|
+
/** What a proxy or BFF does with a request for `path`. */
|
|
70
|
+
export declare function communityRouteDecision(method: string, path: string): CommunityRouteDecision;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { COMMUNITY_HOST_ROUTES as C } from "./host-routes.js";
|
|
2
|
+
const E = Object.freeze(["community", "trust"]), R = Object.freeze(["community/v1/private", "community/v1/staff"]), O = Object.freeze({ kind: "outside" }), a = Object.freeze({ kind: "deny" }), l = 8, A = /^[\u0000-\u0020]*[a-z][a-z0-9+.-]*:\/\//i, g = /(?:%[0-9a-f]{2})+/gi, N = /%([0-7][0-9a-f])/gi, y = /%(?![0-9a-f]{2})/i, T = /[\t\n\r]/g, P = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, h = /[\u0000-\u0020\u007f]/g, D = new Set(E), M = R.map((e) => e.split("/")), U = new RegExp(`^/?(?:api/)?((?:${E.join("|")})(?:/[a-z0-9_-]+)+)$`);
|
|
3
|
+
function m(e) {
|
|
4
|
+
const t = e.search(/[?#]/);
|
|
5
|
+
return t === -1 ? e : e.slice(0, t);
|
|
6
|
+
}
|
|
7
|
+
function v(e) {
|
|
8
|
+
let t = y.test(e);
|
|
9
|
+
return { text: e.replace(g, (n) => {
|
|
10
|
+
try {
|
|
11
|
+
return decodeURIComponent(n);
|
|
12
|
+
} catch {
|
|
13
|
+
return t = !0, n.replace(N, (s, c) => String.fromCharCode(parseInt(c, 16)));
|
|
14
|
+
}
|
|
15
|
+
}), malformed: t };
|
|
16
|
+
}
|
|
17
|
+
function I(e) {
|
|
18
|
+
const t = /* @__PURE__ */ new Set(), o = [
|
|
19
|
+
e,
|
|
20
|
+
e.replace(T, "").replace(P, ""),
|
|
21
|
+
e.replace(h, "")
|
|
22
|
+
];
|
|
23
|
+
for (const n of o) {
|
|
24
|
+
t.add(n);
|
|
25
|
+
const s = n.search(/[?#]/);
|
|
26
|
+
s !== -1 && t.add(n.slice(0, s));
|
|
27
|
+
}
|
|
28
|
+
return [...t];
|
|
29
|
+
}
|
|
30
|
+
function L(e) {
|
|
31
|
+
return e.toLowerCase().replace(/\\/g, "/").split("/").filter((t) => t !== "" && t !== ".");
|
|
32
|
+
}
|
|
33
|
+
function w(e) {
|
|
34
|
+
const t = [];
|
|
35
|
+
for (const o of e)
|
|
36
|
+
o === ".." ? t.pop() : t.push(o);
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
function d(e) {
|
|
40
|
+
let t = 0;
|
|
41
|
+
for (; e[t] === "api"; ) t++;
|
|
42
|
+
return e.slice(t);
|
|
43
|
+
}
|
|
44
|
+
function p(e) {
|
|
45
|
+
const t = [m(e)];
|
|
46
|
+
let o = !1, n = !1;
|
|
47
|
+
for (let u = 0; u <= l; u++) {
|
|
48
|
+
const r = t[t.length - 1], i = v(r);
|
|
49
|
+
if (o ||= i.malformed, i.text === r) {
|
|
50
|
+
n = !0;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
u < l && t.push(i.text);
|
|
54
|
+
}
|
|
55
|
+
const s = [];
|
|
56
|
+
let c = !1;
|
|
57
|
+
for (const u of t)
|
|
58
|
+
for (const r of I(u)) {
|
|
59
|
+
const i = L(r);
|
|
60
|
+
i.includes("..") && (c = !0), s.push(d(i), d(w(i)));
|
|
61
|
+
}
|
|
62
|
+
const f = t[t.length - 1];
|
|
63
|
+
return { readings: s, suspicious: c || o || f.includes("%") || !n, unsettled: !n };
|
|
64
|
+
}
|
|
65
|
+
const _ = (e) => e.unsettled || e.readings.some((t) => t.length > 0 && D.has(t[0])), z = (e) => e.readings.some((t) => M.some((o) => o.every((n, s) => t[s] === n))), S = (e) => typeof e != "string" || A.test(e);
|
|
66
|
+
function x(e) {
|
|
67
|
+
return S(e) || _(p(e));
|
|
68
|
+
}
|
|
69
|
+
function b(e, t, o) {
|
|
70
|
+
if (S(o)) return a;
|
|
71
|
+
const n = p(o);
|
|
72
|
+
if (!_(n)) return O;
|
|
73
|
+
if (n.suspicious || z(n)) return a;
|
|
74
|
+
const s = U.exec(m(o))?.[1];
|
|
75
|
+
if (s === void 0) return a;
|
|
76
|
+
const c = `/${s}`, f = typeof t == "string" ? t.toUpperCase() : "";
|
|
77
|
+
return Array.isArray(e) && e.some((r) => r?.method === f && r.path === c) ? Object.freeze({ kind: "allow", upstreamPath: c }) : a;
|
|
78
|
+
}
|
|
79
|
+
function k(e, t) {
|
|
80
|
+
return b(C, e, t);
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
R as COMMUNITY_CLOSED_PATHS,
|
|
84
|
+
C as COMMUNITY_HOST_ROUTES,
|
|
85
|
+
E as COMMUNITY_NAMESPACES,
|
|
86
|
+
k as communityRouteDecision,
|
|
87
|
+
b as decideCommunityRoute,
|
|
88
|
+
x as isCommunityNamespacePath
|
|
89
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kb-api's one answer for a path it does not serve, the closed community routes included
|
|
3
|
+
* (docs/internal/m1-contracts.md §3.2), for a proxy or a BFF to send ITSELF: a request the boundary denies is
|
|
4
|
+
* answered without asking kb-api, so the answer must be the bytes kb-api would have sent. The body is pinned
|
|
5
|
+
* to kb-api's `routes/unknown-path-body.ts` (test/community/server/drift.spec.ts).
|
|
6
|
+
*
|
|
7
|
+
* `UNKNOWN_PATH`, not `NOT_FOUND`: NOT_FOUND is a route's answer for a resource that does not exist, and the
|
|
8
|
+
* platform's erasure ends a row for good on it; a call that lands on an unknown path must stay retryable. The
|
|
9
|
+
* answer never repeats the path, the method or the query.
|
|
10
|
+
*/
|
|
11
|
+
/** The body, byte for byte (`=== UNKNOWN_PATH_BODY` of kb-api). */
|
|
12
|
+
export declare const COMMUNITY_UNKNOWN_PATH_BODY = "{\"code\":\"UNKNOWN_PATH\",\"error\":\"Not found\"}";
|
|
13
|
+
export interface CommunityUnknownPathAnswer {
|
|
14
|
+
status: 404;
|
|
15
|
+
/** Exactly these, nothing else: `Content-Type` and `Cache-Control`. A fresh object on every call. */
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
/** {@link COMMUNITY_UNKNOWN_PATH_BODY}. A HEAD answer sends the status and the headers only. */
|
|
18
|
+
body: string;
|
|
19
|
+
}
|
|
20
|
+
/** The uniform unknown-path answer (§3.2). A fresh object on every call: a caller may add to its headers. */
|
|
21
|
+
export declare function communityUnknownPath(): CommunityUnknownPathAnswer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const o = '{"code":"UNKNOWN_PATH","error":"Not found"}', t = Object.freeze({
|
|
2
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
3
|
+
"Cache-Control": "no-store"
|
|
4
|
+
});
|
|
5
|
+
function n() {
|
|
6
|
+
return { status: 404, headers: { ...t }, body: o };
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
o as COMMUNITY_UNKNOWN_PATH_BODY,
|
|
10
|
+
n as communityUnknownPath
|
|
11
|
+
};
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the community's operations answer (docs/internal/m1-contracts.md §7.3, §7.4, §7.7, §8.3) — the shapes of
|
|
3
|
+
* kb-api's `routes/community-public.ts` and `routes/trust-notices.ts`, as types.
|
|
4
|
+
*
|
|
5
|
+
* The enums a newer kb-api may extend are OPEN (community.md §3.7: the client is shaped so later surfaces add on
|
|
6
|
+
* without breaking it): a message's `state`, an author's `kind`, a `need`, a restriction's `kind` and a
|
|
7
|
+
* notification's `code` are `KnownX | (string & {})`. A page renders only what it knows and skips the rest — the
|
|
8
|
+
* `isKnownX` guards below say which is which, and the discussion store (store.ts) drops a message whose author
|
|
9
|
+
* kind or state it does not know, and a need it does not know, without throwing.
|
|
10
|
+
*
|
|
11
|
+
* Types and pure guards only: nothing here does I/O.
|
|
12
|
+
*/
|
|
13
|
+
/** A string that is none of the known values (a newer kb-api's): keeps the known ones' autocompletion. */
|
|
14
|
+
type Open<Known extends string> = Known | (string & {});
|
|
15
|
+
/** A message's state: held and removed ones their author sees with the state; others get a placeholder or nothing. */
|
|
16
|
+
export declare const MESSAGE_STATES: readonly ["visible", "held", "removed", "deleted"];
|
|
17
|
+
export type KnownMessageState = (typeof MESSAGE_STATES)[number];
|
|
18
|
+
export type MessageState = Open<KnownMessageState>;
|
|
19
|
+
export declare const isKnownState: (state: unknown) => state is KnownMessageState;
|
|
20
|
+
export declare const AUTHOR_KINDS: readonly ["member", "staff", "system"];
|
|
21
|
+
export type KnownAuthorKind = (typeof AUTHOR_KINDS)[number];
|
|
22
|
+
export type AuthorKind = Open<KnownAuthorKind>;
|
|
23
|
+
export declare const isKnownAuthorKind: (kind: unknown) => kind is KnownAuthorKind;
|
|
24
|
+
/** What a viewer still needs before writing (kb-api computes it on every read and write). */
|
|
25
|
+
export declare const NEEDS: readonly ["sign_in", "onboarding", "reconsent_rules", "art9_consent"];
|
|
26
|
+
export type KnownNeed = (typeof NEEDS)[number];
|
|
27
|
+
export type Need = Open<KnownNeed>;
|
|
28
|
+
export declare const isKnownNeed: (need: unknown) => need is KnownNeed;
|
|
29
|
+
export declare const RESTRICTION_KINDS: readonly ["restriction", "suspension", "ban"];
|
|
30
|
+
export type KnownRestrictionKind = (typeof RESTRICTION_KINDS)[number];
|
|
31
|
+
export type RestrictionKind = Open<KnownRestrictionKind>;
|
|
32
|
+
export declare const isKnownRestrictionKind: (kind: unknown) => kind is KnownRestrictionKind;
|
|
33
|
+
/** In-app notifications: codes and ids only (`appeal_resolved` is a decision that supersedes another). */
|
|
34
|
+
export declare const NOTIFICATION_CODES: readonly ["decision", "appeal_resolved", "erasure_scheduled", "inactivity_warning"];
|
|
35
|
+
export type KnownNotificationCode = (typeof NOTIFICATION_CODES)[number];
|
|
36
|
+
export type NotificationCode = Open<KnownNotificationCode>;
|
|
37
|
+
export declare const isKnownNotificationCode: (code: unknown) => code is KnownNotificationCode;
|
|
38
|
+
/** The report and notice categories (kb-api's CASE_CATEGORIES; test/community/codes-drift.spec.ts pins them). */
|
|
39
|
+
export declare const CASE_CATEGORIES: readonly ["fraud_spam", "harassment", "hate", "threats", "sexual_content", "child_at_risk", "self_harm", "doxxing", "copyright", "terrorism", "drugs", "other_illegal", "rules", "adverse_event", "third_party_health_data", "suspected_minor"];
|
|
40
|
+
export type CaseCategory = (typeof CASE_CATEGORIES)[number];
|
|
41
|
+
export declare const isCaseCategory: (value: unknown) => value is CaseCategory;
|
|
42
|
+
/** The one category whose notice never carries a notifier's name or e-mail (kb-api: NOTIFIER_NOT_ALLOWED). */
|
|
43
|
+
export declare const CATEGORY_WITHOUT_NOTIFIER: CaseCategory;
|
|
44
|
+
export declare const AGE_BANDS: readonly ["16_17", "18_plus"];
|
|
45
|
+
export type AgeBand = (typeof AGE_BANDS)[number];
|
|
46
|
+
export declare const LEGAL_TEXT_KINDS: readonly ["rules", "terms", "privacy", "art9_consent"];
|
|
47
|
+
export type LegalTextKind = (typeof LEGAL_TEXT_KINDS)[number];
|
|
48
|
+
export type AcceptanceState = 'accepted' | 'reconsent_required' | 'never';
|
|
49
|
+
export interface MemberAuthor {
|
|
50
|
+
readonly kind: 'member';
|
|
51
|
+
readonly memberId: string;
|
|
52
|
+
readonly handle: string;
|
|
53
|
+
readonly displayName: string;
|
|
54
|
+
readonly avatarPreset: string | null;
|
|
55
|
+
readonly deleted?: undefined;
|
|
56
|
+
}
|
|
57
|
+
/** An erased member, a member without a profile, and every placeholder: the author is not told. */
|
|
58
|
+
export interface DeletedMemberAuthor {
|
|
59
|
+
readonly kind: 'member';
|
|
60
|
+
readonly memberId: null;
|
|
61
|
+
readonly handle: null;
|
|
62
|
+
readonly displayName: null;
|
|
63
|
+
readonly avatarPreset: null;
|
|
64
|
+
readonly deleted: true;
|
|
65
|
+
}
|
|
66
|
+
export interface StaffAuthor {
|
|
67
|
+
readonly kind: 'staff';
|
|
68
|
+
readonly staffId: string;
|
|
69
|
+
readonly displayName: string;
|
|
70
|
+
/** The badge identity's label code (`team` by default). */
|
|
71
|
+
readonly badge: string;
|
|
72
|
+
}
|
|
73
|
+
export interface SystemAuthor {
|
|
74
|
+
readonly kind: 'system';
|
|
75
|
+
}
|
|
76
|
+
export type KnownAuthor = MemberAuthor | DeletedMemberAuthor | StaffAuthor | SystemAuthor;
|
|
77
|
+
/** An author kind a newer kb-api added: skip what it wrote. */
|
|
78
|
+
export interface UnknownAuthor {
|
|
79
|
+
readonly kind: string & {};
|
|
80
|
+
}
|
|
81
|
+
export type Author = KnownAuthor | UnknownAuthor;
|
|
82
|
+
/** An author of a kind this SDK renders (a plain object whose `kind` is known). */
|
|
83
|
+
export declare function isKnownAuthor(author: unknown): author is KnownAuthor;
|
|
84
|
+
export interface ReactionSummary {
|
|
85
|
+
/** Emoji → count; in public spaces counts only, never who. */
|
|
86
|
+
readonly counts: Readonly<Record<string, number>>;
|
|
87
|
+
/** The viewer's own reaction, or null. */
|
|
88
|
+
readonly mine: string | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* One message as the viewer may see it. Another member's held, removed, held-back or tombstoned message reaches the
|
|
92
|
+
* viewer as a placeholder kb-api has already scrubbed (m1-contracts.md §7.14 P-RV11): `rev` 0 (it never moves while
|
|
93
|
+
* the hidden message is edited or moderated), `body`/`displayBody`/`displayLanguageCode`/`sourceLanguageCode` null,
|
|
94
|
+
* `isEdited`/`isTranslated` false, `editedAt`/`translationVersionId` null, no reactions and the author's place only —
|
|
95
|
+
* its place in the thread, its state and when it was written, nothing else. Their author reads their own such
|
|
96
|
+
* message whole, with its state.
|
|
97
|
+
*/
|
|
98
|
+
export interface PublicMessage {
|
|
99
|
+
readonly conversationId: string;
|
|
100
|
+
readonly seq: number;
|
|
101
|
+
readonly id: string;
|
|
102
|
+
/** 0 on a placeholder: it never moves while the hidden message changes. */
|
|
103
|
+
readonly rev: number;
|
|
104
|
+
readonly replyToSeq: number | null;
|
|
105
|
+
readonly author: Author;
|
|
106
|
+
readonly state: MessageState;
|
|
107
|
+
/** null on a placeholder and on a tombstone. */
|
|
108
|
+
readonly body: string | null;
|
|
109
|
+
/** The viewer's language when a translation of the current text exists, else `body`. */
|
|
110
|
+
readonly displayBody: string | null;
|
|
111
|
+
readonly displayLanguageCode: string | null;
|
|
112
|
+
readonly sourceLanguageCode: string | null;
|
|
113
|
+
readonly isTranslated: boolean;
|
|
114
|
+
readonly isEdited: boolean;
|
|
115
|
+
readonly createdAt: string;
|
|
116
|
+
readonly editedAt: string | null;
|
|
117
|
+
/** The viewer blocked the author (public-context blocks). */
|
|
118
|
+
readonly collapsed: boolean;
|
|
119
|
+
readonly reactions: ReactionSummary;
|
|
120
|
+
readonly translationVersionId: string | null;
|
|
121
|
+
/** The filters' notes for the author (`identification_safety`, `report_to_manufacturer`): post and edit answers only. */
|
|
122
|
+
readonly notes?: readonly string[];
|
|
123
|
+
/**
|
|
124
|
+
* `true` on the author's OWN message that the tenant's art. 9 policy (`require_art9_consent` with
|
|
125
|
+
* `art9_legacy_posts = 'hide_until_consent'`) keeps from everyone else until the author gives the art. 9
|
|
126
|
+
* consent; its `state` is then `held` (m1-contracts.md §7.14 P-RV3). Absent otherwise — never on another
|
|
127
|
+
* member's placeholder: nobody else learns a member's consent. Render it apart from a message awaiting review:
|
|
128
|
+
* nothing is being reviewed, the author's consent releases it.
|
|
129
|
+
*/
|
|
130
|
+
readonly hiddenUntilConsent?: boolean;
|
|
131
|
+
/** On a top-level message: its replies, oldest first. */
|
|
132
|
+
readonly replies: readonly PublicMessage[];
|
|
133
|
+
/** On a top-level message with more replies than COMMUNITY_REPLIES_MAX. */
|
|
134
|
+
readonly repliesTruncated?: boolean;
|
|
135
|
+
}
|
|
136
|
+
export interface RestrictionInEffect {
|
|
137
|
+
readonly kind: RestrictionKind;
|
|
138
|
+
readonly scope: string;
|
|
139
|
+
readonly endsAt: string | null;
|
|
140
|
+
/** The decision that imposed it: its statement explains it (statementPath). */
|
|
141
|
+
readonly decisionId: string;
|
|
142
|
+
}
|
|
143
|
+
export interface DiscussionViewerState {
|
|
144
|
+
readonly memberId: string | null;
|
|
145
|
+
/** kb-api's verdict: the composer may post now. */
|
|
146
|
+
readonly canPost: boolean;
|
|
147
|
+
readonly needs: readonly Need[];
|
|
148
|
+
readonly restrictions: readonly RestrictionInEffect[];
|
|
149
|
+
}
|
|
150
|
+
/** `discussions/list`: one page of an article's discussion. */
|
|
151
|
+
export interface Discussion {
|
|
152
|
+
readonly articleId: string;
|
|
153
|
+
/** null until the first message is posted. */
|
|
154
|
+
readonly conversationId: string | null;
|
|
155
|
+
/** The messages everyone is shown. */
|
|
156
|
+
readonly count: number;
|
|
157
|
+
/** The conversation's counter (every message, any state). */
|
|
158
|
+
readonly lastSeq: number;
|
|
159
|
+
/** The newest change of a message or a reaction. */
|
|
160
|
+
readonly lastChangeAt: string | null;
|
|
161
|
+
/** Top-level, oldest first, COMMUNITY_PAGE_SIZE a page. */
|
|
162
|
+
readonly messages: readonly PublicMessage[];
|
|
163
|
+
/** The next page's cursor (the last top-level `seq`), or null on the last page. */
|
|
164
|
+
readonly nextCursor: number | null;
|
|
165
|
+
readonly articleReactions: ReactionSummary;
|
|
166
|
+
/** The emoji a member may react with (the tenant's `reaction_set`). */
|
|
167
|
+
readonly reactionSet: readonly string[];
|
|
168
|
+
/** The tenant's preset id, or null. */
|
|
169
|
+
readonly preset: string | null;
|
|
170
|
+
readonly viewer: DiscussionViewerState;
|
|
171
|
+
}
|
|
172
|
+
/** `discussions/head`: the polling signal of one article. */
|
|
173
|
+
export interface DiscussionHead {
|
|
174
|
+
readonly articleId: string;
|
|
175
|
+
readonly count: number;
|
|
176
|
+
readonly lastSeq: number;
|
|
177
|
+
readonly lastChangeAt: string | null;
|
|
178
|
+
}
|
|
179
|
+
/** `messages/post`, `messages/edit`: the message as its author sees it. */
|
|
180
|
+
export interface WriteAnswer {
|
|
181
|
+
readonly message: PublicMessage;
|
|
182
|
+
/** The codes that hit with action `warn` (the message is visible). */
|
|
183
|
+
readonly warnings: readonly string[];
|
|
184
|
+
}
|
|
185
|
+
/** A reaction's target: the article, or one message. */
|
|
186
|
+
export type ReactionTarget = {
|
|
187
|
+
readonly articleId: string;
|
|
188
|
+
} | {
|
|
189
|
+
readonly conversationId: string;
|
|
190
|
+
readonly seq: number;
|
|
191
|
+
};
|
|
192
|
+
export interface BlockEntry {
|
|
193
|
+
readonly memberId: string;
|
|
194
|
+
readonly author: Author;
|
|
195
|
+
readonly blockedAt: string;
|
|
196
|
+
}
|
|
197
|
+
/** `profile/get`: the public projection. */
|
|
198
|
+
export interface PublicProfile {
|
|
199
|
+
readonly author: Author;
|
|
200
|
+
/** `YYYY-MM` (UTC). */
|
|
201
|
+
readonly memberSince: string;
|
|
202
|
+
readonly bio: string | null;
|
|
203
|
+
}
|
|
204
|
+
/** The member's own profile (MyState, `me/profile/update`). */
|
|
205
|
+
export interface OwnProfile {
|
|
206
|
+
readonly handle: string;
|
|
207
|
+
readonly displayName: string;
|
|
208
|
+
readonly avatarPreset: string | null;
|
|
209
|
+
readonly bio: string | null;
|
|
210
|
+
readonly handleChangedAt: string | null;
|
|
211
|
+
}
|
|
212
|
+
/** `me/get` and `me/onboard`. Anonymous: `member: null`, `needs: ['sign_in']`. */
|
|
213
|
+
export interface MyState {
|
|
214
|
+
readonly member: {
|
|
215
|
+
readonly memberId: string;
|
|
216
|
+
readonly status: string;
|
|
217
|
+
readonly identity: string;
|
|
218
|
+
readonly ageBand: AgeBand | null;
|
|
219
|
+
} | null;
|
|
220
|
+
readonly profile: OwnProfile | null;
|
|
221
|
+
readonly acceptances: {
|
|
222
|
+
readonly rules: AcceptanceState;
|
|
223
|
+
readonly art9Consent: AcceptanceState | null;
|
|
224
|
+
};
|
|
225
|
+
readonly needs: readonly Need[];
|
|
226
|
+
readonly restrictions: readonly RestrictionInEffect[];
|
|
227
|
+
readonly unreadDecisions: number;
|
|
228
|
+
readonly preset: string | null;
|
|
229
|
+
/** The tenant's own deep links (community.settings), when it set them. */
|
|
230
|
+
readonly links: {
|
|
231
|
+
readonly statementPath: string | null;
|
|
232
|
+
readonly myCommunityPath: string | null;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export interface NotificationItem {
|
|
236
|
+
readonly id: string;
|
|
237
|
+
readonly code: NotificationCode;
|
|
238
|
+
readonly conversationId: string | null;
|
|
239
|
+
readonly seq: number | null;
|
|
240
|
+
readonly caseId: string | null;
|
|
241
|
+
readonly decisionId: string | null;
|
|
242
|
+
readonly createdAt: string;
|
|
243
|
+
readonly readAt: string | null;
|
|
244
|
+
}
|
|
245
|
+
/** A keyset page, newest first: `cursor` is the last item's id. */
|
|
246
|
+
export interface CommunityPage<T> {
|
|
247
|
+
readonly items: readonly T[];
|
|
248
|
+
readonly nextCursor: string | null;
|
|
249
|
+
}
|
|
250
|
+
export interface DecisionSummary {
|
|
251
|
+
readonly decisionId: string;
|
|
252
|
+
readonly caseId: string;
|
|
253
|
+
readonly provider: 'tenant' | 'platform' | (string & {});
|
|
254
|
+
/** Who decided: the controller named in the statement (art. 17(3)). */
|
|
255
|
+
readonly providerEntity: string;
|
|
256
|
+
readonly restriction: string;
|
|
257
|
+
readonly restrictionUntil: string | null;
|
|
258
|
+
readonly basis: string;
|
|
259
|
+
readonly category: string;
|
|
260
|
+
readonly decidedAt: string;
|
|
261
|
+
readonly supersedes: string | null;
|
|
262
|
+
readonly appealWindowClosesAt: string;
|
|
263
|
+
readonly canAppeal: boolean;
|
|
264
|
+
}
|
|
265
|
+
/** What a statement is about, as its author may see it. */
|
|
266
|
+
export type StatementSubject = {
|
|
267
|
+
readonly kind: 'message';
|
|
268
|
+
readonly conversationId: string;
|
|
269
|
+
readonly seq: number;
|
|
270
|
+
readonly message: PublicMessage | null;
|
|
271
|
+
} | {
|
|
272
|
+
readonly kind: 'profile' | 'member';
|
|
273
|
+
readonly memberId: string;
|
|
274
|
+
} | {
|
|
275
|
+
readonly kind: 'article';
|
|
276
|
+
readonly articleId: string;
|
|
277
|
+
};
|
|
278
|
+
/** `me/decisions/get`: the stored art. 17(3) fields, the rendered statement and the redress. */
|
|
279
|
+
export interface Statement extends DecisionSummary {
|
|
280
|
+
readonly territorialScope: string;
|
|
281
|
+
/** The facts and circumstances: plain text, render it as text (`<pre>`). */
|
|
282
|
+
readonly facts: string;
|
|
283
|
+
readonly automatedDetection: boolean;
|
|
284
|
+
readonly automated: boolean;
|
|
285
|
+
readonly legalGround: string | null;
|
|
286
|
+
readonly legalExplanation: string | null;
|
|
287
|
+
readonly contractualGround: string | null;
|
|
288
|
+
readonly contractualExplanation: string | null;
|
|
289
|
+
readonly redress: string;
|
|
290
|
+
readonly templateId: string;
|
|
291
|
+
readonly locale: string;
|
|
292
|
+
/** The whole statement as kb-api rendered it (plain text). */
|
|
293
|
+
readonly statement: string;
|
|
294
|
+
readonly appeal: {
|
|
295
|
+
readonly appealId: string;
|
|
296
|
+
readonly status: string;
|
|
297
|
+
readonly submittedAt: string;
|
|
298
|
+
} | null;
|
|
299
|
+
readonly subject: StatementSubject;
|
|
300
|
+
}
|
|
301
|
+
export interface AppealItem {
|
|
302
|
+
readonly appealId: string;
|
|
303
|
+
readonly decisionId: string;
|
|
304
|
+
readonly caseId: string;
|
|
305
|
+
readonly status: string;
|
|
306
|
+
readonly submittedAt: string;
|
|
307
|
+
readonly resolvedAt: string | null;
|
|
308
|
+
readonly resolutionDecisionId: string | null;
|
|
309
|
+
}
|
|
310
|
+
/** One of the member's reports: never the package. */
|
|
311
|
+
export interface ReportItem {
|
|
312
|
+
readonly caseId: string;
|
|
313
|
+
readonly category: string;
|
|
314
|
+
readonly status: string;
|
|
315
|
+
readonly reportedAt: string;
|
|
316
|
+
readonly decidedAt: string | null;
|
|
317
|
+
}
|
|
318
|
+
/** `legal/current`: the tenant's current text of a kind. */
|
|
319
|
+
export interface CurrentLegalText {
|
|
320
|
+
readonly kind: LegalTextKind;
|
|
321
|
+
readonly textId: string;
|
|
322
|
+
readonly version: string;
|
|
323
|
+
readonly locale: string;
|
|
324
|
+
/**
|
|
325
|
+
* HTML with anchors, the tenant's own words — for a host page that renders it on its server (the rules page).
|
|
326
|
+
* An element renders text only: it shows `communityRulesOf(bodyJson)` and links to that page.
|
|
327
|
+
*/
|
|
328
|
+
readonly body: string;
|
|
329
|
+
/**
|
|
330
|
+
* The machine-readable form (DSA art. 14(1)); for `rules` `{ version, rules: [{ id, title, summary?, anchor }] }`
|
|
331
|
+
* (communityRulesOf), for `terms` and `privacy` `{ sections: [{ id, title, anchor }] }` (communityLegalSectionsOf).
|
|
332
|
+
*/
|
|
333
|
+
readonly bodyJson: Readonly<Record<string, unknown>> | null;
|
|
334
|
+
readonly reconsentRequired: boolean;
|
|
335
|
+
readonly publishedAt: string | null;
|
|
336
|
+
}
|
|
337
|
+
/** One rule of the tenant's rules text: its stable id is what a report and a statement cite. */
|
|
338
|
+
export interface CommunityRule {
|
|
339
|
+
readonly id: string;
|
|
340
|
+
readonly title: string;
|
|
341
|
+
readonly summary: string | null;
|
|
342
|
+
/** The rule's anchor on the rules page (`#<anchor>`). */
|
|
343
|
+
readonly anchor: string;
|
|
344
|
+
}
|
|
345
|
+
/** The rules of a `rules` text's `bodyJson`, in order; an entry without a string id, title and anchor is skipped. */
|
|
346
|
+
export declare function communityRulesOf(bodyJson: unknown): CommunityRule[];
|
|
347
|
+
/** One section of a `terms` or `privacy` text: what the page's contents list and link. */
|
|
348
|
+
export interface CommunityLegalSection {
|
|
349
|
+
readonly id: string;
|
|
350
|
+
readonly title: string;
|
|
351
|
+
/** The section's anchor on the page (`#<anchor>`). */
|
|
352
|
+
readonly anchor: string;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* The sections of a `terms` or `privacy` text's `bodyJson` (`{ sections: [{ id, title, anchor }] }`), in order; an
|
|
356
|
+
* entry without a string id, title and anchor is skipped. A `rules` text has none (its rules are communityRulesOf).
|
|
357
|
+
*/
|
|
358
|
+
export declare function communityLegalSectionsOf(bodyJson: unknown): CommunityLegalSection[];
|
|
359
|
+
/** `me/export`: every section, `providerEntity` on every row; offer it as a JSON download. */
|
|
360
|
+
export interface MemberExport {
|
|
361
|
+
readonly generatedAt: string;
|
|
362
|
+
readonly providerEntity: string;
|
|
363
|
+
readonly [section: string]: unknown;
|
|
364
|
+
}
|
|
365
|
+
/** What a notice names: a message, a member (by id or handle), or an article. */
|
|
366
|
+
export type NoticeTarget = {
|
|
367
|
+
readonly conversationId: string;
|
|
368
|
+
readonly seq: number;
|
|
369
|
+
} | {
|
|
370
|
+
readonly memberId: string;
|
|
371
|
+
} | {
|
|
372
|
+
readonly handle: string;
|
|
373
|
+
} | {
|
|
374
|
+
readonly articleId: string;
|
|
375
|
+
};
|
|
376
|
+
export interface NoticeReceipt {
|
|
377
|
+
readonly caseId: string;
|
|
378
|
+
/** The notifier's capability for `notices/status` and the appeal: put it in a link's fragment only (links.ts). */
|
|
379
|
+
readonly receipt: string;
|
|
380
|
+
/**
|
|
381
|
+
* The case keeps this notice's contact: the confirmation and the outcome go to its e-mail, and the receipt may
|
|
382
|
+
* appeal. False without a contact, or when another notifier's contact is kept: the receipt still reads the outcome.
|
|
383
|
+
*/
|
|
384
|
+
readonly contactKept: boolean;
|
|
385
|
+
}
|
|
386
|
+
export interface NoticeStatus {
|
|
387
|
+
readonly status: 'open' | 'decided' | 'appealed' | 'closed' | (string & {});
|
|
388
|
+
readonly category: CaseCategory;
|
|
389
|
+
readonly submittedAt: string;
|
|
390
|
+
readonly decidedAt: string | null;
|
|
391
|
+
/** The statement once decided (plain text), never the package. */
|
|
392
|
+
readonly statement: string | null;
|
|
393
|
+
readonly appeal: {
|
|
394
|
+
readonly canAppeal: boolean;
|
|
395
|
+
readonly closesAt: string | null;
|
|
396
|
+
readonly open: {
|
|
397
|
+
readonly submittedAt: string;
|
|
398
|
+
} | null;
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
export interface DiscussionListInput {
|
|
402
|
+
articleId: string;
|
|
403
|
+
/** The page's language: a translation of each message into it when one exists. */
|
|
404
|
+
languageCode?: string | null;
|
|
405
|
+
/** The previous page's `nextCursor`; absent for the first page. */
|
|
406
|
+
cursor?: number | null;
|
|
407
|
+
}
|
|
408
|
+
export interface MessagePostInput {
|
|
409
|
+
articleId: string;
|
|
410
|
+
body: string;
|
|
411
|
+
/** A reply names a top-level message of the same discussion. */
|
|
412
|
+
replyToSeq?: number | null;
|
|
413
|
+
/** newClientMsgId(), the same on a retry. */
|
|
414
|
+
clientMsgId: string;
|
|
415
|
+
/** The page's language (the language the member writes in). */
|
|
416
|
+
languageCode: string;
|
|
417
|
+
/** The codes of CONFIRMATION_REQUIRED the author confirmed. */
|
|
418
|
+
confirmations?: string[];
|
|
419
|
+
}
|
|
420
|
+
export interface MessageEditInput {
|
|
421
|
+
conversationId: string;
|
|
422
|
+
seq: number;
|
|
423
|
+
body: string;
|
|
424
|
+
confirmations?: string[];
|
|
425
|
+
}
|
|
426
|
+
export interface MessageReportInput {
|
|
427
|
+
conversationId: string;
|
|
428
|
+
seq: number;
|
|
429
|
+
category: CaseCategory;
|
|
430
|
+
/** For `rules`: the id of a rule of the current rules text. */
|
|
431
|
+
ruleId?: string | null;
|
|
432
|
+
/** The report's one free text (≤ COMMUNITY_REPORT_NOTE_MAX), seen by the team only. */
|
|
433
|
+
note?: string | null;
|
|
434
|
+
}
|
|
435
|
+
export interface OnboardInput {
|
|
436
|
+
ageBand: AgeBand;
|
|
437
|
+
/** The current `rules` text's id (`legal/current`). */
|
|
438
|
+
rulesTextId: string;
|
|
439
|
+
/** The current `art9_consent` text's id, when the tenant asks for the consent. */
|
|
440
|
+
art9TextId?: string | null;
|
|
441
|
+
/** Required on a member's first onboarding (no profile yet). */
|
|
442
|
+
displayName?: string | null;
|
|
443
|
+
/** Generated from the display name when absent. */
|
|
444
|
+
handle?: string | null;
|
|
445
|
+
avatarPreset?: string | null;
|
|
446
|
+
}
|
|
447
|
+
export interface ProfileUpdateInput {
|
|
448
|
+
displayName?: string;
|
|
449
|
+
/** At most once in COMMUNITY_HANDLE_CHANGE_DAYS. */
|
|
450
|
+
handle?: string;
|
|
451
|
+
avatarPreset?: string | null;
|
|
452
|
+
/** null or empty clears it. */
|
|
453
|
+
bio?: string | null;
|
|
454
|
+
}
|
|
455
|
+
export interface NoticeSubmitInput {
|
|
456
|
+
category: CaseCategory;
|
|
457
|
+
target: NoticeTarget;
|
|
458
|
+
/** Why the content is a problem (≤ COMMUNITY_NOTICE_DESCRIPTION_MAX). */
|
|
459
|
+
description: string;
|
|
460
|
+
ruleId?: string | null;
|
|
461
|
+
/** Optional; never for CATEGORY_WITHOUT_NOTIFIER. */
|
|
462
|
+
notifier?: {
|
|
463
|
+
name?: string | null;
|
|
464
|
+
email?: string | null;
|
|
465
|
+
locale: string;
|
|
466
|
+
} | null;
|
|
467
|
+
/** The Turnstile widget's one-shot token (action COMMUNITY_NOTICE_TURNSTILE_ACTION). */
|
|
468
|
+
turnstileToken?: string | null;
|
|
469
|
+
/** Must contain COMMUNITY_GOOD_FAITH. */
|
|
470
|
+
confirmations?: string[];
|
|
471
|
+
}
|
|
472
|
+
export {};
|