@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/shapes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t = (e, o) => typeof o == "string" && e.includes(o), f = Object.freeze(["visible", "held", "removed", "deleted"]), y = (e) => t(f, e), O = Object.freeze(["member", "staff", "system"]), l = (e) => t(O, e), u = Object.freeze(["sign_in", "onboarding", "reconsent_rules", "art9_consent"]), z = (e) => t(u, e), S = Object.freeze(["restriction", "suspension", "ban"]), I = (e) => t(S, e), E = Object.freeze([
|
|
2
2
|
"decision",
|
|
3
3
|
"appeal_resolved",
|
|
4
4
|
"erasure_scheduled",
|
|
@@ -10,8 +10,12 @@ const i = (e, t) => typeof t == "string" && e.includes(t), f = Object.freeze(["v
|
|
|
10
10
|
"reply",
|
|
11
11
|
"mention",
|
|
12
12
|
"module_push_reset",
|
|
13
|
-
"age_limit_changed"
|
|
14
|
-
|
|
13
|
+
"age_limit_changed",
|
|
14
|
+
// M3 F3 (m3-contracts.md §4.3): a new visible message in a followed topic or article discussion; a new topic in a
|
|
15
|
+
// followed category (in-app and the digest, never push). Both switched by `notifyTopic`.
|
|
16
|
+
"topic_update",
|
|
17
|
+
"category_topic"
|
|
18
|
+
]), C = (e) => t(E, e), d = Object.freeze(["new", "member", "regular", "trusted"]), N = (e) => t(d, e), a = Object.freeze([
|
|
15
19
|
"fraud_spam",
|
|
16
20
|
"harassment",
|
|
17
21
|
"hate",
|
|
@@ -28,76 +32,103 @@ const i = (e, t) => typeof t == "string" && e.includes(t), f = Object.freeze(["v
|
|
|
28
32
|
"adverse_event",
|
|
29
33
|
"third_party_health_data",
|
|
30
34
|
"suspected_minor"
|
|
31
|
-
]), g = (e) =>
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
]), g = (e) => t(a, e), h = "child_at_risk", K = Object.freeze(
|
|
36
|
+
a.filter((e) => e !== "rules" && e !== "adverse_event" && e !== "third_party_health_data" && e !== "suspected_minor")
|
|
37
|
+
), T = Object.freeze(["recorded", "reported_to_authority", "not_adverse"]), v = (e) => t(T, e), D = Object.freeze(["16_17", "18_plus"]), M = Object.freeze(["rules", "terms", "privacy", "art9_consent"]);
|
|
38
|
+
function w(e) {
|
|
39
|
+
return typeof e == "object" && e !== null && l(e.kind);
|
|
34
40
|
}
|
|
35
|
-
const
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
if (!Array.isArray(
|
|
39
|
-
const
|
|
40
|
-
for (const n of
|
|
41
|
+
const p = Object.freeze(["dark", "live", "read_only", "braked"]), U = (e) => t(p, e), L = Object.freeze(["joint", "split"]), k = Object.freeze(["read_only", "public_write"]), F = (e) => e === "split" ? "split" : "joint", G = (e) => e === "public_write" ? "public_write" : "read_only", P = Object.freeze(["conversation", "member"]), B = Object.freeze(["android", "ios", "desktop", "other"]), x = Object.freeze(["message", "edit", "delete", "reaction", "resync"]);
|
|
42
|
+
function H(e) {
|
|
43
|
+
const o = typeof e == "object" && e !== null ? e.rules : void 0;
|
|
44
|
+
if (!Array.isArray(o)) return [];
|
|
45
|
+
const r = [];
|
|
46
|
+
for (const n of o) {
|
|
41
47
|
if (typeof n != "object" || n === null) continue;
|
|
42
|
-
const { id:
|
|
43
|
-
typeof
|
|
48
|
+
const { id: s, title: c, summary: i, anchor: _ } = n;
|
|
49
|
+
typeof s != "string" || typeof c != "string" || typeof _ != "string" || r.push(Object.freeze({ id: s, title: c, summary: typeof i == "string" ? i : null, anchor: _ }));
|
|
44
50
|
}
|
|
45
|
-
return
|
|
51
|
+
return r;
|
|
46
52
|
}
|
|
47
|
-
const
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
if (!Array.isArray(
|
|
51
|
-
const
|
|
52
|
-
for (const n of
|
|
53
|
-
if (
|
|
53
|
+
const b = 2;
|
|
54
|
+
function Y(e) {
|
|
55
|
+
const o = typeof e == "object" && e !== null ? e.controllers : void 0;
|
|
56
|
+
if (!Array.isArray(o)) return [];
|
|
57
|
+
const r = [];
|
|
58
|
+
for (const n of o) {
|
|
59
|
+
if (r.length >= b) break;
|
|
54
60
|
if (typeof n != "object" || n === null) continue;
|
|
55
|
-
const { entity:
|
|
56
|
-
typeof
|
|
61
|
+
const { entity: s, label: c } = n;
|
|
62
|
+
typeof s != "string" || typeof c != "string" || s.trim() === "" || c.trim() === "" || r.push(Object.freeze({ entity: s, label: c.trim() }));
|
|
57
63
|
}
|
|
58
|
-
return
|
|
64
|
+
return r;
|
|
59
65
|
}
|
|
60
|
-
function
|
|
61
|
-
const
|
|
62
|
-
if (!Array.isArray(
|
|
63
|
-
const
|
|
64
|
-
for (const n of
|
|
66
|
+
function V(e) {
|
|
67
|
+
const o = typeof e == "object" && e !== null ? e.sections : void 0;
|
|
68
|
+
if (!Array.isArray(o)) return [];
|
|
69
|
+
const r = [];
|
|
70
|
+
for (const n of o) {
|
|
65
71
|
if (typeof n != "object" || n === null) continue;
|
|
66
|
-
const { id:
|
|
67
|
-
typeof
|
|
72
|
+
const { id: s, title: c, anchor: i } = n;
|
|
73
|
+
typeof s != "string" || typeof c != "string" || typeof i != "string" || r.push(Object.freeze({ id: s, title: c, anchor: i }));
|
|
68
74
|
}
|
|
69
|
-
return
|
|
75
|
+
return r;
|
|
70
76
|
}
|
|
77
|
+
const A = Object.freeze(["topics", "article_discussions"]), W = (e) => t(A, e), j = Object.freeze(["post", "hold_flagged", "pre"]), X = (e) => t(j, e), q = Object.freeze(["members", "team"]), m = Object.freeze(["open", "locked", "archived"]), Q = (e) => t(m, e), Z = Object.freeze(["topic", "article"]), $ = Object.freeze(["activity", "new"]), J = Object.freeze(["forum", "article"]), ee = Object.freeze(["topic", "message"]), te = Object.freeze(["conversation", "category"]), R = Object.freeze(["forum", "article_discussions"]), oe = (e) => t(R, e), ne = Object.freeze(["case", "premod"]), re = Object.freeze(["open", "decided"]), se = Object.freeze(["member_report", "filter", "staff"]), ce = Object.freeze(["no_action", "visibility_restricted", "removal"]), ie = Object.freeze(["notice", "own_initiative"]), _e = Object.freeze(["open", "locked"]), ae = Object.freeze(["approve", "reject"]);
|
|
71
78
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
T as ADVERSE_EVENT_OUTCOMES,
|
|
80
|
+
D as AGE_BANDS,
|
|
81
|
+
L as ART9_CONSENT_LAYOUTS,
|
|
82
|
+
b as ART9_CONTROLLERS_MAX,
|
|
83
|
+
k as ART9_REFUSALS,
|
|
84
|
+
O as AUTHOR_KINDS,
|
|
85
|
+
R as BRAKE_SURFACES,
|
|
86
|
+
a as CASE_CATEGORIES,
|
|
78
87
|
h as CATEGORY_WITHOUT_NOTIFIER,
|
|
79
|
-
|
|
88
|
+
K as ESCALATION_CATEGORIES,
|
|
89
|
+
te as FOLLOW_TARGET_KINDS,
|
|
90
|
+
A as FORUM_CATEGORY_KINDS,
|
|
91
|
+
j as FORUM_CATEGORY_MODES,
|
|
92
|
+
$ as FORUM_SORTS,
|
|
93
|
+
J as FORUM_SPACES,
|
|
94
|
+
M as LEGAL_TEXT_KINDS,
|
|
80
95
|
f as MESSAGE_STATES,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
ie as MODERATION_BASES,
|
|
97
|
+
re as MODERATION_CASE_STATUSES,
|
|
98
|
+
ne as MODERATION_ITEM_KINDS,
|
|
99
|
+
ce as MODERATION_RESTRICTIONS,
|
|
100
|
+
se as MODERATION_SOURCES,
|
|
101
|
+
_e as MODERATOR_TOPIC_STATES,
|
|
102
|
+
p as MODULE_STATES,
|
|
103
|
+
P as MUTE_TARGET_KINDS,
|
|
104
|
+
u as NEEDS,
|
|
105
|
+
E as NOTIFICATION_CODES,
|
|
106
|
+
ae as PREMOD_OUTCOMES,
|
|
107
|
+
B as PUSH_USER_AGENT_CLASSES,
|
|
108
|
+
x as REALTIME_EVENT_KINDS,
|
|
109
|
+
S as RESTRICTION_KINDS,
|
|
110
|
+
ee as SEARCH_RESULT_KINDS,
|
|
111
|
+
q as TOPIC_CREATIONS,
|
|
112
|
+
Z as TOPIC_ITEM_KINDS,
|
|
113
|
+
m as TOPIC_STATES,
|
|
114
|
+
d as TRUST_LABELS,
|
|
115
|
+
F as art9ConsentLayoutOf,
|
|
116
|
+
Y as art9ControllersOf,
|
|
117
|
+
G as art9RefusalOf,
|
|
118
|
+
V as communityLegalSectionsOf,
|
|
119
|
+
H as communityRulesOf,
|
|
94
120
|
g as isCaseCategory,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
121
|
+
v as isKnownAdverseEventOutcome,
|
|
122
|
+
w as isKnownAuthor,
|
|
123
|
+
l as isKnownAuthorKind,
|
|
124
|
+
oe as isKnownBrakeSurface,
|
|
125
|
+
W as isKnownForumCategoryKind,
|
|
126
|
+
X as isKnownForumCategoryMode,
|
|
127
|
+
U as isKnownModuleState,
|
|
128
|
+
z as isKnownNeed,
|
|
129
|
+
C as isKnownNotificationCode,
|
|
130
|
+
I as isKnownRestrictionKind,
|
|
131
|
+
y as isKnownState,
|
|
132
|
+
Q as isKnownTopicState,
|
|
133
|
+
N as isKnownTrustLabel
|
|
103
134
|
};
|
|
@@ -150,6 +150,12 @@ export interface DiscussionStore {
|
|
|
150
150
|
/** Back to the empty state (another article); the answers still on their way are dropped when they come. */
|
|
151
151
|
reset(): void;
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* A known author kind as the store renders it (a member short of its fields is the deleted placeholder); else null.
|
|
155
|
+
* M3: a member's `moderator: true` (a moderator's message in a category they moderate, §3.5) is kept, nothing else.
|
|
156
|
+
* The topic store (topic.ts) reads a topic's author through it too.
|
|
157
|
+
*/
|
|
158
|
+
export declare function authorOf(raw: unknown): KnownAuthor | null;
|
|
153
159
|
export declare function createDiscussionStore(): DiscussionStore;
|
|
154
160
|
/** What the composer waits for, from the viewer's known needs. */
|
|
155
161
|
export interface ViewerNeeds {
|
|
@@ -161,11 +167,23 @@ export interface ViewerNeeds {
|
|
|
161
167
|
readonly rules: boolean;
|
|
162
168
|
/** The consent the tenant asks for before writing. */
|
|
163
169
|
readonly art9: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* O-16 / F-51 (the owner, 9. 11. 2026: the terms once, never again): the first join also accepts the tenant's terms,
|
|
172
|
+
* so its me/onboard sends `termsTextId` — read from a MyState: a first join (`onboarding`) whose `acceptances.terms`
|
|
173
|
+
* is `never` (the tenant has a terms text, none accepted). Presence of the field is the rollout guard: a kb-api
|
|
174
|
+
* older than O-16 answers no `terms` and refuses the key, so nothing is sent to it. Never true for a member already
|
|
175
|
+
* onboarded (they are never asked) nor from a discussion state (no acceptances there), and not a need of its own:
|
|
176
|
+
* `any` does not count it — it rides on the onboarding.
|
|
177
|
+
*/
|
|
178
|
+
readonly terms: boolean;
|
|
164
179
|
/** Any of these. */
|
|
165
180
|
readonly any: boolean;
|
|
166
181
|
}
|
|
167
182
|
export declare function viewerNeeds(state: Pick<DiscussionState, 'viewer'> | {
|
|
168
183
|
needs: readonly unknown[];
|
|
184
|
+
acceptances?: {
|
|
185
|
+
readonly terms?: unknown;
|
|
186
|
+
} | null;
|
|
169
187
|
}): ViewerNeeds;
|
|
170
188
|
/** A loaded message (top-level or reply) by its seq, or null. */
|
|
171
189
|
export declare function findMessage(state: Pick<DiscussionState, 'messages'>, seq: number): DiscussionMessage | null;
|
|
@@ -179,6 +197,15 @@ export declare function reactionsFor(state: DiscussionState, target: ReactionTar
|
|
|
179
197
|
*/
|
|
180
198
|
export declare function reactionAfter(summary: ReactionSummary, emoji: string | null): ReactionSummary;
|
|
181
199
|
type ListClient = Pick<CommunityClient, 'discussions'>;
|
|
200
|
+
/**
|
|
201
|
+
* Where a store is (its generation, the article it shows), so a loader can tell whether it moved on — reset(), a
|
|
202
|
+
* page of another article — while a page was on its way. A store of another make has no generation: the article
|
|
203
|
+
* it shows is the sign. Internal: the topic store (topic.ts) tracks its own discussion store with it.
|
|
204
|
+
*/
|
|
205
|
+
export declare function placeOf(store: DiscussionStore): {
|
|
206
|
+
moved(): boolean;
|
|
207
|
+
mark(): void;
|
|
208
|
+
};
|
|
182
209
|
/**
|
|
183
210
|
* Loads the discussion, or brings the loaded pages up to date (after a newer head): the first page, then the next
|
|
184
211
|
* ones until the pages loaded before are covered — to the end when the end was loaded. The first failure is the
|
package/dist/community/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isKnownNeed as
|
|
1
|
+
import { isKnownNeed as $, isKnownAuthorKind as me, isKnownState as ge, isKnownRestrictionKind as be } from "./shapes.js";
|
|
2
2
|
const C = (e) => typeof e == "object" && e !== null && !Array.isArray(e), f = (e) => typeof e == "string" ? e : null, P = (e) => typeof e == "number" && Number.isSafeInteger(e) && e > 0, D = Object.freeze({ counts: Object.freeze({}), mine: null });
|
|
3
3
|
function L(e) {
|
|
4
4
|
if (!C(e)) return D;
|
|
@@ -8,7 +8,7 @@ function L(e) {
|
|
|
8
8
|
typeof r == "number" && Number.isSafeInteger(r) && r > 0 && (s[n] = r);
|
|
9
9
|
return Object.freeze({ counts: Object.freeze(s), mine: f(e.mine) });
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const J = Object.freeze({
|
|
12
12
|
kind: "member",
|
|
13
13
|
memberId: null,
|
|
14
14
|
handle: null,
|
|
@@ -16,31 +16,31 @@ const $ = Object.freeze({
|
|
|
16
16
|
avatarPreset: null,
|
|
17
17
|
deleted: !0
|
|
18
18
|
}), ye = Object.freeze({ kind: "system" });
|
|
19
|
-
function
|
|
20
|
-
if (!C(e) || !
|
|
19
|
+
function Q(e) {
|
|
20
|
+
if (!C(e) || !me(e.kind)) return null;
|
|
21
21
|
if (e.kind === "system") return ye;
|
|
22
22
|
if (e.kind === "staff")
|
|
23
23
|
return Object.freeze({ kind: "staff", staffId: f(e.staffId) ?? "", displayName: f(e.displayName) ?? "", badge: f(e.badge) ?? "" });
|
|
24
24
|
const s = f(e.memberId), n = f(e.handle), r = f(e.displayName);
|
|
25
|
-
return s === null || n === null || r === null || e.deleted === !0 ?
|
|
25
|
+
return s === null || n === null || r === null || e.deleted === !0 ? J : Object.freeze({ kind: "member", memberId: s, handle: n, displayName: r, avatarPreset: f(e.avatarPreset), ...e.moderator === !0 ? { moderator: !0 } : {} });
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function Z(e) {
|
|
28
28
|
if (Array.isArray(e))
|
|
29
29
|
return Object.freeze(e.filter((s) => typeof s == "string"));
|
|
30
30
|
}
|
|
31
31
|
function N(e, s) {
|
|
32
32
|
if (!C(e)) return null;
|
|
33
|
-
const n =
|
|
33
|
+
const n = Q(e.author);
|
|
34
34
|
if (n === null || !ge(e.state)) return null;
|
|
35
35
|
const r = f(e.conversationId), c = f(e.id);
|
|
36
36
|
if (r === null || c === null || !P(e.seq)) return null;
|
|
37
|
-
const
|
|
37
|
+
const m = f(e.body), g = [];
|
|
38
38
|
if (s && Array.isArray(e.replies))
|
|
39
39
|
for (const y of e.replies) {
|
|
40
40
|
const M = N(y, !1);
|
|
41
|
-
M &&
|
|
41
|
+
M && g.push(M);
|
|
42
42
|
}
|
|
43
|
-
const
|
|
43
|
+
const O = Z(e.notes);
|
|
44
44
|
return Object.freeze({
|
|
45
45
|
conversationId: r,
|
|
46
46
|
seq: e.seq,
|
|
@@ -49,8 +49,8 @@ function N(e, s) {
|
|
|
49
49
|
replyToSeq: s ? null : P(e.replyToSeq) ? e.replyToSeq : null,
|
|
50
50
|
author: n,
|
|
51
51
|
state: e.state,
|
|
52
|
-
body:
|
|
53
|
-
displayBody: f(e.displayBody) ??
|
|
52
|
+
body: m,
|
|
53
|
+
displayBody: f(e.displayBody) ?? m,
|
|
54
54
|
displayLanguageCode: f(e.displayLanguageCode),
|
|
55
55
|
sourceLanguageCode: f(e.sourceLanguageCode),
|
|
56
56
|
isTranslated: e.isTranslated === !0,
|
|
@@ -60,18 +60,20 @@ function N(e, s) {
|
|
|
60
60
|
collapsed: e.collapsed === !0,
|
|
61
61
|
reactions: L(e.reactions),
|
|
62
62
|
translationVersionId: f(e.translationVersionId),
|
|
63
|
-
...
|
|
63
|
+
...O && O.length > 0 ? { notes: O } : {},
|
|
64
64
|
// Only as kb-api sends it: true, on a `held` message (the author's own, held back by the art. 9 policy).
|
|
65
65
|
...e.hiddenUntilConsent === !0 && e.state === "held" ? { hiddenUntilConsent: !0 } : {},
|
|
66
|
-
|
|
66
|
+
// M3 (§4.2): the author's own message waiting in pre-moderation — true on a `held` row only, as kb-api sends it.
|
|
67
|
+
...e.premoderated === !0 && e.state === "held" ? { premoderated: !0 } : {},
|
|
68
|
+
replies: x(g),
|
|
67
69
|
...s && e.repliesTruncated === !0 ? { repliesTruncated: !0 } : {}
|
|
68
70
|
});
|
|
69
71
|
}
|
|
70
72
|
function Ie(e) {
|
|
71
|
-
const s = C(e) ? e : {}, n = Array.isArray(s.needs) ? s.needs.filter(
|
|
73
|
+
const s = C(e) ? e : {}, n = Array.isArray(s.needs) ? s.needs.filter($) : [], r = [];
|
|
72
74
|
if (Array.isArray(s.restrictions))
|
|
73
75
|
for (const c of s.restrictions)
|
|
74
|
-
!C(c) || !
|
|
76
|
+
!C(c) || !be(c.kind) || typeof c.decisionId != "string" || r.push(Object.freeze({ kind: c.kind, scope: f(c.scope) ?? "", endsAt: f(c.endsAt), decisionId: c.decisionId }));
|
|
75
77
|
return Object.freeze({
|
|
76
78
|
memberId: f(s.memberId),
|
|
77
79
|
canPost: s.canPost === !0,
|
|
@@ -102,16 +104,16 @@ function T(e, s) {
|
|
|
102
104
|
let n = !1;
|
|
103
105
|
const r = [];
|
|
104
106
|
for (const c of e) {
|
|
105
|
-
let
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
let m = s(c);
|
|
108
|
+
if (m !== null && m.replies.length > 0) {
|
|
109
|
+
const g = T(m.replies, s);
|
|
110
|
+
g !== m.replies && (m = Object.freeze({ ...m, replies: g }));
|
|
109
111
|
}
|
|
110
|
-
|
|
112
|
+
m !== c && (n = !0), m !== null && r.push(m);
|
|
111
113
|
}
|
|
112
114
|
return n ? Object.freeze(r) : e;
|
|
113
115
|
}
|
|
114
|
-
function
|
|
116
|
+
function k(e, s) {
|
|
115
117
|
for (const n of e) {
|
|
116
118
|
if (s(n)) return n;
|
|
117
119
|
for (const r of n.replies) if (s(r)) return r;
|
|
@@ -122,18 +124,18 @@ function K(e, s) {
|
|
|
122
124
|
return T(e, (n) => n.seq === s.seq ? n.replyToSeq === null && s.replyToSeq === null ? Object.freeze({ ...s, replies: n.replies }) : s : n);
|
|
123
125
|
}
|
|
124
126
|
function U(e, s) {
|
|
125
|
-
if (
|
|
127
|
+
if (k(e, (r) => r.seq === s.seq)) return K(e, s);
|
|
126
128
|
if (s.replyToSeq === null) return x([...e, s]);
|
|
127
129
|
const n = e.find((r) => r.seq === s.replyToSeq);
|
|
128
130
|
return n ? Object.freeze(e.map((r) => r === n ? Object.freeze({ ...r, replies: x([...r.replies, s]) }) : r)) : e;
|
|
129
131
|
}
|
|
130
|
-
const Y = (e) => e.replyToSeq === null && e.replies.length > 0, G = (e, s) => e.toLowerCase() === s.toLowerCase(), W = (e) => e.author.kind === "member" && e.author.memberId !== null ? e.author.memberId.toLowerCase() : null, Oe = 256,
|
|
132
|
+
const Y = (e) => e.replyToSeq === null && e.replies.length > 0, G = (e, s) => e.toLowerCase() === s.toLowerCase(), W = (e) => e.author.kind === "member" && e.author.memberId !== null ? e.author.memberId.toLowerCase() : null, Oe = 256, w = /* @__PURE__ */ new WeakMap();
|
|
131
133
|
function Ce() {
|
|
132
134
|
let e = V;
|
|
133
135
|
const s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
134
|
-
let c = 0,
|
|
135
|
-
const
|
|
136
|
-
c += 1,
|
|
136
|
+
let c = 0, m = -1;
|
|
137
|
+
const g = /* @__PURE__ */ new Set(), O = () => {
|
|
138
|
+
c += 1, g.clear();
|
|
137
139
|
for (const t of n.keys())
|
|
138
140
|
r.delete(t), r.add(t);
|
|
139
141
|
n.clear();
|
|
@@ -154,34 +156,34 @@ function Ce() {
|
|
|
154
156
|
function M(t, o = {}) {
|
|
155
157
|
if (!C(t)) return;
|
|
156
158
|
const u = f(t.articleId)?.toLowerCase() ?? null, l = e.articleId !== null && u !== null && u !== e.articleId, i = l ? V : e;
|
|
157
|
-
l &&
|
|
158
|
-
const b = typeof o.cursor == "number" && Number.isFinite(o.cursor) ? o.cursor : null, I = b ?? 0, q = typeof t.nextCursor == "number" && Number.isFinite(t.nextCursor) ? t.nextCursor : null,
|
|
159
|
+
l && O();
|
|
160
|
+
const b = typeof o.cursor == "number" && Number.isFinite(o.cursor) ? o.cursor : null, I = b ?? 0, q = typeof t.nextCursor == "number" && Number.isFinite(t.nextCursor) ? t.nextCursor : null, h = q ?? Number.POSITIVE_INFINITY, j = /* @__PURE__ */ new Map();
|
|
159
161
|
for (const d of Array.isArray(t.messages) ? t.messages : []) {
|
|
160
162
|
const a = N(d, !0);
|
|
161
|
-
a && a.seq > I && a.seq <=
|
|
163
|
+
a && a.seq > I && a.seq <= h && j.set(a.seq, a);
|
|
162
164
|
}
|
|
163
165
|
for (const d of j.values())
|
|
164
166
|
for (const a of [d, ...d.replies]) {
|
|
165
167
|
const S = W(a);
|
|
166
|
-
S === null || a.body === null || (a.collapsed ?
|
|
168
|
+
S === null || a.body === null || (a.collapsed ? g.add(S) : g.delete(S));
|
|
167
169
|
}
|
|
168
170
|
const p = /* @__PURE__ */ new Map();
|
|
169
171
|
for (const d of i.messages) {
|
|
170
172
|
const a = [d, ...d.replies];
|
|
171
173
|
for (const S of a) S.pending && S.pending !== "post" && S.clientMsgId && p.set(S.seq, S);
|
|
172
174
|
}
|
|
173
|
-
const
|
|
175
|
+
const v = (d) => {
|
|
174
176
|
const a = p.get(d.seq);
|
|
175
177
|
if (!a) return d;
|
|
176
178
|
const S = a.clientMsgId ? n.get(a.clientMsgId) : void 0;
|
|
177
179
|
return S && (S.before = d), a.replyToSeq === null ? Object.freeze({ ...a, replies: d.replies }) : a;
|
|
178
|
-
},
|
|
180
|
+
}, z = i.messages.filter((d) => d.seq < 0 || d.seq <= I || d.seq > h), R = /* @__PURE__ */ new Map();
|
|
179
181
|
for (const d of i.messages)
|
|
180
182
|
for (const a of d.replies)
|
|
181
183
|
a.seq < 0 && a.replyToSeq !== null && R.set(a.replyToSeq, [...R.get(a.replyToSeq) ?? [], a]);
|
|
182
|
-
const A = [...
|
|
184
|
+
const A = [...z.filter((d) => !j.has(d.seq)), ...j.values()].map((d) => {
|
|
183
185
|
if (!j.has(d.seq)) return d;
|
|
184
|
-
const a =
|
|
186
|
+
const a = v(d), S = a.replies.map(v), H = R.get(d.seq) ?? [];
|
|
185
187
|
return S.some((fe, pe) => fe !== a.replies[pe]) || H.length > 0 ? Object.freeze({ ...a, replies: x([...S, ...H]) }) : a;
|
|
186
188
|
}), _ = i.loaded ? i.nextCursor : 0, de = _ === null ? null : I > _ ? _ : q === null ? null : Math.max(_, q);
|
|
187
189
|
y({
|
|
@@ -204,9 +206,9 @@ function Ce() {
|
|
|
204
206
|
if (n.has(t.clientMsgId)) return;
|
|
205
207
|
const o = P(t.replyToSeq) ? t.replyToSeq : null;
|
|
206
208
|
if (o !== null && !e.messages.some((b) => b.seq === o)) return;
|
|
207
|
-
const u =
|
|
209
|
+
const u = Q(t.author) ?? J, l = Object.freeze({
|
|
208
210
|
conversationId: e.conversationId ?? "",
|
|
209
|
-
seq:
|
|
211
|
+
seq: m--,
|
|
210
212
|
id: `pending:${t.clientMsgId}`,
|
|
211
213
|
rev: 0,
|
|
212
214
|
replyToSeq: o,
|
|
@@ -233,7 +235,7 @@ function Ce() {
|
|
|
233
235
|
}
|
|
234
236
|
function te(t) {
|
|
235
237
|
if (n.has(t.clientMsgId)) return;
|
|
236
|
-
const o =
|
|
238
|
+
const o = k(e.messages, (l) => l.seq === t.seq);
|
|
237
239
|
if (!o || o.pending) return;
|
|
238
240
|
n.set(t.clientMsgId, { type: t.type, before: o });
|
|
239
241
|
const u = t.type === "edit" ? Object.freeze({
|
|
@@ -261,23 +263,23 @@ function Ce() {
|
|
|
261
263
|
i !== e.messages && y({ ...e, messages: i });
|
|
262
264
|
return;
|
|
263
265
|
}
|
|
264
|
-
const b = t.warnings ?
|
|
265
|
-
let
|
|
266
|
+
const b = t.warnings ? Z(t.warnings) : void 0, I = b && b.length > 0 ? Object.freeze({ ...l, warnings: b }) : l, q = k(i, (p) => p.seq === I.seq);
|
|
267
|
+
let h, j = e.count;
|
|
266
268
|
if (I.state === "deleted" || o?.type === "delete") {
|
|
267
|
-
const p = q ?? null,
|
|
268
|
-
|
|
269
|
+
const p = q ?? null, v = p?.state === "visible" && p.body !== null;
|
|
270
|
+
h = T(
|
|
269
271
|
i,
|
|
270
|
-
(
|
|
271
|
-
),
|
|
272
|
+
(z) => z.seq !== I.seq ? z : Y(z) ? Object.freeze({ ...I, replies: z.replies }) : null
|
|
273
|
+
), v && (j = Math.max(0, j - 1));
|
|
272
274
|
} else
|
|
273
|
-
|
|
275
|
+
h = U(i, I), !q && I.state === "visible" && (j += 1);
|
|
274
276
|
y({
|
|
275
277
|
...e,
|
|
276
278
|
// The answer to this store's own change names the new conversation; a row it never saw may be another article's.
|
|
277
279
|
conversationId: e.conversationId ?? (o ? I.conversationId : null),
|
|
278
280
|
lastSeq: Math.max(e.lastSeq, I.seq),
|
|
279
281
|
count: j,
|
|
280
|
-
messages:
|
|
282
|
+
messages: h
|
|
281
283
|
});
|
|
282
284
|
}
|
|
283
285
|
function ne(t) {
|
|
@@ -294,7 +296,7 @@ function Ce() {
|
|
|
294
296
|
}
|
|
295
297
|
function re(t) {
|
|
296
298
|
const o = N(t, t?.replyToSeq === null || t?.replyToSeq === void 0);
|
|
297
|
-
!o || !
|
|
299
|
+
!o || !k(e.messages, (u) => u.seq === o.seq && !u.pending && G(u.conversationId, o.conversationId)) || y({ ...e, messages: K(e.messages, o) });
|
|
298
300
|
}
|
|
299
301
|
function oe(t) {
|
|
300
302
|
if (C(t))
|
|
@@ -334,7 +336,7 @@ function Ce() {
|
|
|
334
336
|
function ce(t, o) {
|
|
335
337
|
if (typeof t != "string" || t === "") return;
|
|
336
338
|
const u = t.toLowerCase();
|
|
337
|
-
o ?
|
|
339
|
+
o ? g.add(u) : g.delete(u);
|
|
338
340
|
const l = T(
|
|
339
341
|
e.messages,
|
|
340
342
|
(i) => i.author.kind === "member" && i.author.memberId !== null && i.author.memberId.toLowerCase() === u && i.body !== null && i.collapsed !== o ? Object.freeze({ ...i, collapsed: o }) : i
|
|
@@ -342,7 +344,7 @@ function Ce() {
|
|
|
342
344
|
l !== e.messages && y({ ...e, messages: l });
|
|
343
345
|
}
|
|
344
346
|
function ue(t, o) {
|
|
345
|
-
const u = W(t), l = t.body !== null && u !== null &&
|
|
347
|
+
const u = W(t), l = t.body !== null && u !== null && g.has(u), i = o ? o.reactions.mine : null, b = i === t.reactions.mine ? t.reactions : Object.freeze({ counts: t.reactions.counts, mine: i }), I = o?.repliesTruncated === !0 && t.replyToSeq === null, q = o?.warnings;
|
|
346
348
|
return l === t.collapsed && b === t.reactions && !I && !q ? t : Object.freeze({
|
|
347
349
|
...t,
|
|
348
350
|
collapsed: l,
|
|
@@ -362,31 +364,31 @@ function Ce() {
|
|
|
362
364
|
return y({ ...e, articleReactions: Object.freeze({ counts: A.counts, mine: e.articleReactions.mine }) }), "applied";
|
|
363
365
|
}
|
|
364
366
|
if (!P(t.seq)) return "dropped";
|
|
365
|
-
const p = t.seq,
|
|
366
|
-
if (!
|
|
367
|
-
if (o >
|
|
368
|
-
const
|
|
369
|
-
return y({ ...e, messages: T(e.messages, (A) => A ===
|
|
367
|
+
const p = t.seq, v = k(e.messages, (A) => A.seq === p);
|
|
368
|
+
if (!v || v.pending || o < v.rev) return "dropped";
|
|
369
|
+
if (o > v.rev) return "resync";
|
|
370
|
+
const z = L(t.reactions), R = Object.freeze({ counts: z.counts, mine: v.reactions.mine });
|
|
371
|
+
return y({ ...e, messages: T(e.messages, (A) => A === v ? Object.freeze({ ...A, reactions: R }) : A) }), "applied";
|
|
370
372
|
}
|
|
371
373
|
if (t.kind !== "message" && t.kind !== "edit" && t.kind !== "delete") return "dropped";
|
|
372
374
|
const u = t.message, l = N(u, u?.replyToSeq === null || u?.replyToSeq === void 0);
|
|
373
375
|
if (!l || !F(l)) return "dropped";
|
|
374
|
-
const i =
|
|
376
|
+
const i = k(e.messages, (p) => p.seq === l.seq);
|
|
375
377
|
if (i?.pending) return "dropped";
|
|
376
378
|
const b = i?.rev ?? 0;
|
|
377
379
|
if (t.kind === "delete") {
|
|
378
380
|
if (!i || o <= b) return "dropped";
|
|
379
|
-
const p = i.state === "visible" && i.body !== null,
|
|
381
|
+
const p = i.state === "visible" && i.body !== null, v = T(
|
|
380
382
|
e.messages,
|
|
381
|
-
(
|
|
383
|
+
(z) => z.seq !== l.seq ? z : Y(z) ? Object.freeze({ ...l, replies: z.replies }) : null
|
|
382
384
|
);
|
|
383
|
-
return y({ ...e, messages:
|
|
385
|
+
return y({ ...e, messages: v, count: p ? Math.max(0, e.count - 1) : e.count, lastSeq: Math.max(e.lastSeq, l.seq) }), "applied";
|
|
384
386
|
}
|
|
385
387
|
const I = l.author.kind === "member" && l.author.memberId !== null && l.author.memberId === e.viewer.memberId;
|
|
386
388
|
if (!i && I && [...n.values()].some((p) => p.type === "post") || o <= b) return "dropped";
|
|
387
389
|
if (o > b + 1 || !i && l.replyToSeq !== null && !e.messages.some((p) => p.seq === l.replyToSeq)) return "resync";
|
|
388
|
-
const q = ue(l, i),
|
|
389
|
-
return y({ ...e, messages:
|
|
390
|
+
const q = ue(l, i), h = i ? K(e.messages, q) : U(e.messages, q), j = !i && l.state === "visible" ? e.count + 1 : e.count;
|
|
391
|
+
return y({ ...e, messages: h, count: j, lastSeq: Math.max(e.lastSeq, l.seq) }), "applied";
|
|
390
392
|
}
|
|
391
393
|
const B = {
|
|
392
394
|
getState: () => e,
|
|
@@ -402,31 +404,31 @@ function Ce() {
|
|
|
402
404
|
collapse: ce,
|
|
403
405
|
applyEvent: ae,
|
|
404
406
|
reset() {
|
|
405
|
-
|
|
407
|
+
O(), y(V);
|
|
406
408
|
}
|
|
407
409
|
};
|
|
408
|
-
return
|
|
410
|
+
return w.set(B, () => c), B;
|
|
409
411
|
}
|
|
410
412
|
function X(e) {
|
|
411
413
|
const { pending: s, clientMsgId: n, ...r } = e;
|
|
412
414
|
return Object.freeze(r);
|
|
413
415
|
}
|
|
414
416
|
function Te(e) {
|
|
415
|
-
const s = "viewer" in e ? e.viewer.needs : e.needs, n = new Set(s.filter(
|
|
416
|
-
return Object.freeze({ signIn: r, onboarding: c, rules:
|
|
417
|
+
const s = "viewer" in e ? e.viewer.needs : e.needs, n = new Set(s.filter($)), r = n.has("sign_in"), c = n.has("onboarding"), m = c || n.has("reconsent_rules"), g = n.has("art9_consent"), O = c && !("viewer" in e) && e.acceptances?.terms === "never";
|
|
418
|
+
return Object.freeze({ signIn: r, onboarding: c, rules: m, art9: g, terms: O, any: r || c || m || g });
|
|
417
419
|
}
|
|
418
420
|
function Me(e, s) {
|
|
419
|
-
return
|
|
421
|
+
return k(e.messages, (n) => n.seq === s);
|
|
420
422
|
}
|
|
421
423
|
function Ae(e, s) {
|
|
422
424
|
return s.author.kind === "member" && s.author.memberId !== null && s.author.memberId === e.viewer.memberId;
|
|
423
425
|
}
|
|
424
|
-
function
|
|
426
|
+
function he(e, s) {
|
|
425
427
|
if ("articleId" in s) return e.articleReactions;
|
|
426
428
|
const n = s.conversationId.toLowerCase();
|
|
427
|
-
return
|
|
429
|
+
return k(e.messages, (c) => c.seq === s.seq && c.conversationId.toLowerCase() === n)?.reactions ?? D;
|
|
428
430
|
}
|
|
429
|
-
function
|
|
431
|
+
function ke(e, s) {
|
|
430
432
|
const n = { ...e.counts }, r = e.mine;
|
|
431
433
|
if (r !== null) {
|
|
432
434
|
const c = (n[r] ?? 0) - 1;
|
|
@@ -436,7 +438,7 @@ function he(e, s) {
|
|
|
436
438
|
}
|
|
437
439
|
const ve = 20;
|
|
438
440
|
function ee(e) {
|
|
439
|
-
const s =
|
|
441
|
+
const s = w.get(e);
|
|
440
442
|
let n = s?.(), r = e.getState().articleId;
|
|
441
443
|
return {
|
|
442
444
|
moved: () => s !== void 0 && s() !== n || e.getState().articleId !== r,
|
|
@@ -447,32 +449,34 @@ function ee(e) {
|
|
|
447
449
|
}
|
|
448
450
|
const ze = (e) => typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
449
451
|
async function xe(e, s, n, r) {
|
|
450
|
-
const c = e.getState(),
|
|
451
|
-
let
|
|
452
|
+
const c = e.getState(), m = c.loaded ? c.nextCursor : 0, g = ee(e);
|
|
453
|
+
let O = null;
|
|
452
454
|
for (let y = 0; y < ve; y++) {
|
|
453
|
-
const M = await s.discussions.list({ articleId: n.articleId, languageCode: n.languageCode ?? null, cursor:
|
|
455
|
+
const M = await s.discussions.list({ articleId: n.articleId, languageCode: n.languageCode ?? null, cursor: O }, r);
|
|
454
456
|
if (!M.ok) return M;
|
|
455
|
-
if (
|
|
456
|
-
e.applyPage(M.value, { cursor:
|
|
457
|
+
if (g.moved()) break;
|
|
458
|
+
e.applyPage(M.value, { cursor: O }), g.mark();
|
|
457
459
|
const E = ze(M.value.nextCursor);
|
|
458
|
-
if (E === null ||
|
|
459
|
-
|
|
460
|
+
if (E === null || m !== null && E >= m || O !== null && E <= O) break;
|
|
461
|
+
O = E;
|
|
460
462
|
}
|
|
461
463
|
return { ok: !0, value: e.getState() };
|
|
462
464
|
}
|
|
463
465
|
async function Ee(e, s, n, r) {
|
|
464
466
|
const c = e.getState().nextCursor;
|
|
465
467
|
if (c === null) return { ok: !0, value: e.getState() };
|
|
466
|
-
const
|
|
467
|
-
return
|
|
468
|
+
const m = ee(e), g = await s.discussions.list({ articleId: n.articleId, languageCode: n.languageCode ?? null, cursor: c }, r);
|
|
469
|
+
return g.ok ? (m.moved() || e.applyPage(g.value, { cursor: c }), { ok: !0, value: e.getState() }) : g;
|
|
468
470
|
}
|
|
469
471
|
export {
|
|
472
|
+
Q as authorOf,
|
|
470
473
|
Ce as createDiscussionStore,
|
|
471
474
|
Me as findMessage,
|
|
472
475
|
Ae as isOwnMessage,
|
|
473
476
|
Ee as loadMoreDiscussion,
|
|
474
|
-
|
|
475
|
-
ke as
|
|
477
|
+
ee as placeOf,
|
|
478
|
+
ke as reactionAfter,
|
|
479
|
+
he as reactionsFor,
|
|
476
480
|
xe as refreshDiscussion,
|
|
477
481
|
Te as viewerNeeds
|
|
478
482
|
};
|