@blogmcp/sdk 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/community/channels.d.ts +7 -6
  2. package/dist/community/channels.js +4 -4
  3. package/dist/community/client.d.ts +74 -4
  4. package/dist/community/client.js +143 -91
  5. package/dist/community/index.d.ts +11 -6
  6. package/dist/community/index.js +111 -80
  7. package/dist/community/links.d.ts +61 -1
  8. package/dist/community/links.js +94 -40
  9. package/dist/community/manifest/index.d.ts +54 -0
  10. package/dist/community/manifest/index.js +46 -0
  11. package/dist/community/mentions.d.ts +38 -0
  12. package/dist/community/mentions.js +25 -0
  13. package/dist/community/messages.cs.d.ts +73 -3
  14. package/dist/community/messages.cs.js +82 -3
  15. package/dist/community/messages.d.ts +11 -0
  16. package/dist/community/messages.en.d.ts +69 -1
  17. package/dist/community/messages.en.js +71 -1
  18. package/dist/community/messages.js +26 -16
  19. package/dist/community/outcome.d.ts +8 -3
  20. package/dist/community/outcome.js +72 -28
  21. package/dist/community/realtime/index.d.ts +118 -0
  22. package/dist/community/realtime/index.js +215 -0
  23. package/dist/community/routes.d.ts +12 -0
  24. package/dist/community/routes.js +41 -25
  25. package/dist/community/server/bff.js +25 -25
  26. package/dist/community/server/host-routes.js +12 -0
  27. package/dist/community/server/index.d.ts +1 -1
  28. package/dist/community/server/index.js +15 -14
  29. package/dist/community/server/route-decision.d.ts +8 -0
  30. package/dist/community/server/route-decision.js +28 -22
  31. package/dist/community/shapes.d.ts +214 -2
  32. package/dist/community/shapes.js +65 -25
  33. package/dist/community/store.d.ts +18 -1
  34. package/dist/community/store.js +316 -261
  35. package/dist/community/sw/index.d.ts +45 -0
  36. package/dist/community/sw/index.js +59 -0
  37. package/dist/community/ua.d.ts +12 -0
  38. package/dist/community/ua.js +9 -0
  39. package/package.json +20 -3
  40. package/src/community/channels.ts +8 -7
  41. package/src/community/client.ts +116 -5
  42. package/src/community/index.ts +59 -1
  43. package/src/community/links.ts +119 -2
  44. package/src/community/manifest/index.ts +107 -0
  45. package/src/community/mentions.ts +59 -0
  46. package/src/community/messages.cs.ts +88 -3
  47. package/src/community/messages.en.ts +77 -1
  48. package/src/community/messages.ts +19 -0
  49. package/src/community/outcome.ts +50 -1
  50. package/src/community/realtime/index.ts +522 -0
  51. package/src/community/routes.ts +16 -0
  52. package/src/community/server/bff.ts +2 -4
  53. package/src/community/server/host-routes.ts +12 -0
  54. package/src/community/server/index.ts +1 -0
  55. package/src/community/server/route-decision.ts +15 -0
  56. package/src/community/shapes.ts +256 -3
  57. package/src/community/store.ts +114 -0
  58. package/src/community/sw/index.ts +112 -0
  59. package/src/community/ua.ts +17 -0
@@ -1,4 +1,17 @@
1
- const s = (e, t) => typeof t == "string" && e.includes(t), u = Object.freeze(["visible", "held", "removed", "deleted"]), O = (e) => s(u, e), a = Object.freeze(["member", "staff", "system"]), l = (e) => s(a, e), _ = Object.freeze(["sign_in", "onboarding", "reconsent_rules", "art9_consent"]), h = (e) => s(_, e), p = Object.freeze(["restriction", "suspension", "ban"]), m = (e) => s(p, e), d = Object.freeze(["decision", "appeal_resolved", "erasure_scheduled", "inactivity_warning"]), g = (e) => s(d, e), y = Object.freeze([
1
+ const i = (e, t) => typeof t == "string" && e.includes(t), f = Object.freeze(["visible", "held", "removed", "deleted"]), m = (e) => i(f, e), a = Object.freeze(["member", "staff", "system"]), u = (e) => i(a, e), _ = Object.freeze(["sign_in", "onboarding", "reconsent_rules", "art9_consent"]), T = (e) => i(_, e), d = Object.freeze(["restriction", "suspension", "ban"]), A = (e) => i(d, e), p = Object.freeze([
2
+ "decision",
3
+ "appeal_resolved",
4
+ "erasure_scheduled",
5
+ "inactivity_warning",
6
+ // M2 (m2-contracts.md §3.1): the module went read_only; a platform pause without an end.
7
+ "module_read_only",
8
+ "module_braked",
9
+ // M2 T3 (§3.3): a reply to the member's message, an @mention; T4: push was reset; T9: the age limit rose.
10
+ "reply",
11
+ "mention",
12
+ "module_push_reset",
13
+ "age_limit_changed"
14
+ ]), E = (e) => i(p, e), O = Object.freeze(["new", "member", "regular", "trusted"]), j = (e) => i(O, e), y = Object.freeze([
2
15
  "fraud_spam",
3
16
  "harassment",
4
17
  "hate",
@@ -15,49 +28,76 @@ const s = (e, t) => typeof t == "string" && e.includes(t), u = Object.freeze(["v
15
28
  "adverse_event",
16
29
  "third_party_health_data",
17
30
  "suspected_minor"
18
- ]), A = (e) => s(y, e), b = "child_at_risk", j = Object.freeze(["16_17", "18_plus"]), E = Object.freeze(["rules", "terms", "privacy", "art9_consent"]);
19
- function S(e) {
20
- return typeof e == "object" && e !== null && l(e.kind);
31
+ ]), g = (e) => i(y, e), h = "child_at_risk", R = Object.freeze(["16_17", "18_plus"]), z = Object.freeze(["rules", "terms", "privacy", "art9_consent"]);
32
+ function N(e) {
33
+ return typeof e == "object" && e !== null && u(e.kind);
21
34
  }
22
- function T(e) {
35
+ const b = Object.freeze(["dark", "live", "read_only", "braked"]), I = (e) => i(b, e), K = Object.freeze(["joint", "split"]), C = Object.freeze(["read_only", "public_write"]), L = (e) => e === "split" ? "split" : "joint", w = (e) => e === "public_write" ? "public_write" : "read_only", v = Object.freeze(["conversation", "member"]), D = Object.freeze(["android", "ios", "desktop", "other"]), U = Object.freeze(["message", "edit", "delete", "reaction", "resync"]);
36
+ function k(e) {
23
37
  const t = typeof e == "object" && e !== null ? e.rules : void 0;
24
38
  if (!Array.isArray(t)) return [];
25
39
  const o = [];
26
40
  for (const n of t) {
27
41
  if (typeof n != "object" || n === null) continue;
28
- const { id: r, title: i, summary: c, anchor: f } = n;
29
- typeof r != "string" || typeof i != "string" || typeof f != "string" || o.push(Object.freeze({ id: r, title: i, summary: typeof c == "string" ? c : null, anchor: f }));
42
+ const { id: r, title: s, summary: c, anchor: l } = n;
43
+ typeof r != "string" || typeof s != "string" || typeof l != "string" || o.push(Object.freeze({ id: r, title: s, summary: typeof c == "string" ? c : null, anchor: l }));
30
44
  }
31
45
  return o;
32
46
  }
33
- function I(e) {
47
+ const S = 2;
48
+ function G(e) {
49
+ const t = typeof e == "object" && e !== null ? e.controllers : void 0;
50
+ if (!Array.isArray(t)) return [];
51
+ const o = [];
52
+ for (const n of t) {
53
+ if (o.length >= S) break;
54
+ if (typeof n != "object" || n === null) continue;
55
+ const { entity: r, label: s } = n;
56
+ typeof r != "string" || typeof s != "string" || r.trim() === "" || s.trim() === "" || o.push(Object.freeze({ entity: r, label: s.trim() }));
57
+ }
58
+ return o;
59
+ }
60
+ function M(e) {
34
61
  const t = typeof e == "object" && e !== null ? e.sections : void 0;
35
62
  if (!Array.isArray(t)) return [];
36
63
  const o = [];
37
64
  for (const n of t) {
38
65
  if (typeof n != "object" || n === null) continue;
39
- const { id: r, title: i, anchor: c } = n;
40
- typeof r != "string" || typeof i != "string" || typeof c != "string" || o.push(Object.freeze({ id: r, title: i, anchor: c }));
66
+ const { id: r, title: s, anchor: c } = n;
67
+ typeof r != "string" || typeof s != "string" || typeof c != "string" || o.push(Object.freeze({ id: r, title: s, anchor: c }));
41
68
  }
42
69
  return o;
43
70
  }
44
71
  export {
45
- j as AGE_BANDS,
72
+ R as AGE_BANDS,
73
+ K as ART9_CONSENT_LAYOUTS,
74
+ S as ART9_CONTROLLERS_MAX,
75
+ C as ART9_REFUSALS,
46
76
  a as AUTHOR_KINDS,
47
77
  y as CASE_CATEGORIES,
48
- b as CATEGORY_WITHOUT_NOTIFIER,
49
- E as LEGAL_TEXT_KINDS,
50
- u as MESSAGE_STATES,
78
+ h as CATEGORY_WITHOUT_NOTIFIER,
79
+ z as LEGAL_TEXT_KINDS,
80
+ f as MESSAGE_STATES,
81
+ b as MODULE_STATES,
82
+ v as MUTE_TARGET_KINDS,
51
83
  _ as NEEDS,
52
- d as NOTIFICATION_CODES,
53
- p as RESTRICTION_KINDS,
54
- I as communityLegalSectionsOf,
55
- T as communityRulesOf,
56
- A as isCaseCategory,
57
- S as isKnownAuthor,
58
- l as isKnownAuthorKind,
59
- h as isKnownNeed,
60
- g as isKnownNotificationCode,
61
- m as isKnownRestrictionKind,
62
- O as isKnownState
84
+ p as NOTIFICATION_CODES,
85
+ D as PUSH_USER_AGENT_CLASSES,
86
+ U as REALTIME_EVENT_KINDS,
87
+ d as RESTRICTION_KINDS,
88
+ O as TRUST_LABELS,
89
+ L as art9ConsentLayoutOf,
90
+ G as art9ControllersOf,
91
+ w as art9RefusalOf,
92
+ M as communityLegalSectionsOf,
93
+ k as communityRulesOf,
94
+ g as isCaseCategory,
95
+ N as isKnownAuthor,
96
+ u as isKnownAuthorKind,
97
+ I as isKnownModuleState,
98
+ T as isKnownNeed,
99
+ E as isKnownNotificationCode,
100
+ A as isKnownRestrictionKind,
101
+ m as isKnownState,
102
+ j as isKnownTrustLabel
63
103
  };
@@ -9,6 +9,9 @@
9
9
  * applyHead a `discussions/head` answer: true when it is newer than what is loaded (→ refresh);
10
10
  * applyReaction a reaction summary (the server's, or reactionAfter's optimistic one);
11
11
  * collapse a member blocked or unblocked: their messages collapse or open;
12
+ * applyEvent M2 T5: a publication of the discussion's `disc:` channel, by its `rev` (m2-contracts.md §3.5):
13
+ * dropped when it is not newer than what is loaded, applied when it is the next revision, and
14
+ * answered `resync` (re-read: refreshDiscussion) when something between was missed;
12
15
  * viewerNeeds what the composer still waits for.
13
16
  *
14
17
  * Open enums (community.md §3.7): a message whose author kind or state this SDK does not know is dropped — with the
@@ -19,7 +22,7 @@
19
22
  */
20
23
  import type { CommunityCallOptions, CommunityClient } from './client.js';
21
24
  import type { CommunityOutcome } from './outcome.js';
22
- import { type Discussion, type DiscussionHead, type KnownAuthor, type KnownMessageState, type KnownNeed, type KnownRestrictionKind, type PublicMessage, type ReactionSummary, type ReactionTarget } from './shapes.js';
25
+ import { type Discussion, type DiscussionHead, type KnownAuthor, type KnownMessageState, type KnownNeed, type KnownRestrictionKind, type PublicMessage, type ReactionSummary, type ReactionTarget, type RealtimeEvent } from './shapes.js';
23
26
  /** A message as the store keeps it: a known author and state, and the optimistic change that waits, if any. */
24
27
  export interface DiscussionMessage extends Omit<PublicMessage, 'author' | 'state' | 'replies' | 'reactions'> {
25
28
  readonly author: KnownAuthor;
@@ -116,6 +119,8 @@ export type MessageChange =
116
119
  readonly type: 'server';
117
120
  readonly message: PublicMessage;
118
121
  };
122
+ /** What applyEvent did with a channel's publication: applied, dropped (stale, unknown, nothing loaded), or `resync`. */
123
+ export type RealtimeEventOutcome = 'applied' | 'dropped' | 'resync';
119
124
  export interface DiscussionStore {
120
125
  getState(): DiscussionState;
121
126
  /** Called after every change with the new state; returns the unsubscribe. */
@@ -130,6 +135,18 @@ export interface DiscussionStore {
130
135
  applyReaction(target: ReactionTarget, reactions: ReactionSummary): void;
131
136
  /** The viewer blocked (true) or unblocked (false) a member. */
132
137
  collapse(memberId: string, blocked: boolean): void;
138
+ /**
139
+ * M2 T5: a publication of the discussion's channel (`@blogmcp/sdk/community/realtime` hands each one over). By kind:
140
+ * `message`/`edit` — dropped when `rev` is not newer than the loaded row's (0 for one not loaded: a placeholder never
141
+ * applies), applied when it is the next one, `resync` when revisions were missed (or a reply's parent is not loaded);
142
+ * `delete` — applied to a loaded row with an older rev; `reaction` — the counts of a loaded row at that very rev (the
143
+ * viewer's own `mine` is kept: the channel never says whose a reaction is); `resync` — always `resync`. A publication
144
+ * is viewer-blind: a row applied keeps the viewer's view — collapsed when its author is blocked (the blocks the pages
145
+ * and collapse() told the store), the loaded row's `mine`, `repliesTruncated` and warnings. While a post of the
146
+ * viewer waits for its answer, every new row of the viewer's own is dropped (the answer shows that post; a post
147
+ * from another tab of theirs in that window comes with the next re-read).
148
+ */
149
+ applyEvent(event: RealtimeEvent): RealtimeEventOutcome;
133
150
  /** Back to the empty state (another article); the answers still on their way are dropped when they come. */
134
151
  reset(): void;
135
152
  }