@blogmcp/sdk 0.8.0 → 0.9.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 (97) 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 +92 -0
  7. package/dist/community/links.d.ts +65 -0
  8. package/dist/community/links.js +81 -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 +457 -0
  36. package/dist/community/shapes.js +51 -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/review/page.d.ts +1 -1
  50. package/dist/core/review/page.js +1 -1
  51. package/dist/core/review/plan.d.ts +1 -1
  52. package/dist/core/review/plan.js +8 -4
  53. package/dist/core/review/stamp.d.ts +4 -2
  54. package/dist/core/review/stamp.js +47 -47
  55. package/dist/core/seo.js +40 -39
  56. package/dist/core/translations/cs.json.js +6 -6
  57. package/dist/core/translations/en.json.js +1 -1
  58. package/dist/core/types.d.ts +23 -1
  59. package/dist/core/view-model.d.ts +7 -0
  60. package/dist/core/view-model.js +29 -25
  61. package/dist/react/KbMdxContent.js +4 -3
  62. package/dist/vue/components/KbMdxContent.vue2.js +3 -2
  63. package/dist/vue/composables/useKbComments.d.ts +8 -0
  64. package/package.json +13 -4
  65. package/src/community/channels.ts +12 -0
  66. package/src/community/client.ts +437 -0
  67. package/src/community/index.ts +190 -0
  68. package/src/community/links.ts +166 -0
  69. package/src/community/messages.cs.ts +371 -0
  70. package/src/community/messages.en.ts +341 -0
  71. package/src/community/messages.ts +112 -0
  72. package/src/community/outcome.ts +317 -0
  73. package/src/community/poll.ts +154 -0
  74. package/src/community/routes.ts +139 -0
  75. package/src/community/server/bff.ts +530 -0
  76. package/src/community/server/env.ts +42 -0
  77. package/src/community/server/host-routes.ts +48 -0
  78. package/src/community/server/http.ts +175 -0
  79. package/src/community/server/index.ts +55 -0
  80. package/src/community/server/route-decision.ts +226 -0
  81. package/src/community/server/unknown-path.ts +32 -0
  82. package/src/community/shapes.ts +513 -0
  83. package/src/community/store.ts +786 -0
  84. package/src/community/transport.ts +111 -0
  85. package/src/core/client.ts +24 -1
  86. package/src/core/comments-legacy.ts +39 -0
  87. package/src/core/index.ts +8 -0
  88. package/src/core/queries.ts +93 -0
  89. package/src/core/review/page.ts +1 -1
  90. package/src/core/review/plan.ts +4 -2
  91. package/src/core/review/stamp.ts +18 -5
  92. package/src/core/seo.ts +5 -1
  93. package/src/core/translations/cs.json +3 -1
  94. package/src/core/translations/en.json +3 -1
  95. package/src/core/types.ts +19 -1
  96. package/src/core/view-model.ts +12 -1
  97. package/src/vue/composables/useKbComments.ts +8 -0
@@ -0,0 +1,111 @@
1
+ /**
2
+ * The replaceable layer under the community client (docs/internal/m1-contracts.md §10.2; community.md §3.7): one
3
+ * function that takes an operation and its JSON body and answers the HTTP status and the parsed body. The client
4
+ * never touches `fetch` itself, so a test injects a transport, and the private client of a later milestone plugs
5
+ * in one that signs its requests — the client and its outcomes do not change.
6
+ *
7
+ * The default, fetchTransport(base), POSTs to the HOST: a relative base such as `/api/community` that a managed
8
+ * blog's proxy or a headless site's BFF serves. Never kb-api's origin — its community namespaces answer no CORS and
9
+ * a browser never calls them directly — so an absolute or protocol-relative base is refused when the client is
10
+ * built, and every request is `mode: 'same-origin'` with the host's own cookies (`credentials: 'same-origin'`): the
11
+ * host turns its session into the member's credential on its server.
12
+ */
13
+
14
+ import { CommunityTransportError } from './outcome'
15
+ import { communityOpPath, type CommunityOp } from './routes'
16
+
17
+ /** What a transport answers: the HTTP status and the parsed JSON body (null when the body is not JSON). */
18
+ export interface CommunityTransportAnswer {
19
+ status: number
20
+ body: unknown
21
+ /** `Retry-After` in seconds, when the answer carried one. */
22
+ retryAfterS?: number
23
+ }
24
+
25
+ /**
26
+ * The layer the client calls for every operation. It rejects (with a CommunityTransportError, ideally) when the
27
+ * host could not be asked at all; any answer, a 4xx or 5xx included, resolves.
28
+ */
29
+ export type CommunityTransport = (op: CommunityOp, body: unknown, signal: AbortSignal) => Promise<CommunityTransportAnswer>
30
+
31
+ /**
32
+ * A host base: an absolute path on the page's own origin, segments of URL-safe characters, no dot segments, no
33
+ * query or fragment — `/api/community`, `/blog/api/community`, `/`. Anything else (a URL, `//host`, a backslash, an
34
+ * encoded character) is refused.
35
+ */
36
+ const BASE_RE = /^(?:\/[A-Za-z0-9_~-][A-Za-z0-9._~-]*)*\/?$/
37
+
38
+ /** Whether `base` is a host base the client takes (see BASE_RE); `..` and `.` segments are refused too. */
39
+ export function isRelativeCommunityBase(base: unknown): base is string {
40
+ return typeof base === 'string' && base.startsWith('/') && BASE_RE.test(base) && !/(^|\/)\.\.?(\/|$)/.test(base)
41
+ }
42
+
43
+ /** The base, checked: a TypeError for anything but a relative host base (a programming error, visible at once). */
44
+ export function assertCommunityBase(base: unknown): string {
45
+ if (!isRelativeCommunityBase(base)) {
46
+ throw new TypeError(
47
+ '[blogmcp-sdk] the community client takes a relative base on the page’s own origin (e.g. "/api/community"), ' +
48
+ 'never an absolute URL: kb-api’s community routes are reached only through the host’s proxy or BFF',
49
+ )
50
+ }
51
+ return base.replace(/\/+$/, '')
52
+ }
53
+
54
+ /** The URL of an operation under a checked base: `${base}/v1/public/<resource>/<verb>`, `${base}/trust/v1/notices/<verb>`. */
55
+ export function communityOpUrl(base: string, o: Pick<CommunityOp, 'path' | 'surface'>): string {
56
+ return `${base.replace(/\/+$/, '')}${communityOpPath(o)}`
57
+ }
58
+
59
+ /** `Retry-After` as seconds (delta-seconds or an HTTP date), or undefined. */
60
+ function retryAfterOf(value: string | null, now: number): number | undefined {
61
+ if (value === null || value.trim() === '') return undefined
62
+ const trimmed = value.trim()
63
+ if (/^\d+$/.test(trimmed)) return Number(trimmed)
64
+ const at = Date.parse(trimmed)
65
+ return Number.isFinite(at) ? Math.max(0, Math.ceil((at - now) / 1000)) : undefined
66
+ }
67
+
68
+ export interface FetchTransportOptions {
69
+ /** The fetch to use; looked up on every call (default the page's `fetch`), so a test can stub it. */
70
+ fetch?: () => typeof fetch
71
+ now?: () => number
72
+ }
73
+
74
+ /**
75
+ * The default transport: `POST ${base}<the operation's path>` with a JSON body. The base is checked here as in the
76
+ * client (a TypeError for an absolute one). A network failure, a timeout or an abort rejects with a
77
+ * CommunityTransportError; a body that is not JSON resolves as `body: null`.
78
+ */
79
+ export function fetchTransport(base: string, opts: FetchTransportOptions = {}): CommunityTransport {
80
+ const root = assertCommunityBase(base)
81
+ const now = opts.now ?? Date.now
82
+ const fetchOf = opts.fetch ?? (() => globalThis.fetch)
83
+ return async (o, body, signal) => {
84
+ let res: Response
85
+ try {
86
+ res = await fetchOf()(communityOpUrl(root, o), {
87
+ method: o.method,
88
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
89
+ body: JSON.stringify(body ?? {}),
90
+ // The host's own origin only: its session cookie goes along, nothing leaves for another site.
91
+ mode: 'same-origin',
92
+ credentials: 'same-origin',
93
+ cache: 'no-store',
94
+ redirect: 'error',
95
+ signal,
96
+ })
97
+ } catch {
98
+ // The reason (a DOMException, a TypeError naming the URL) stays out of the message: it names what failed.
99
+ throw new CommunityTransportError(signal.aborted ? 'community request aborted or timed out' : 'community request failed')
100
+ }
101
+ let parsed: unknown = null
102
+ try {
103
+ const text = await res.text()
104
+ parsed = text === '' ? null : (JSON.parse(text) as unknown)
105
+ } catch {
106
+ parsed = null
107
+ }
108
+ const retryAfterS = retryAfterOf(res.headers.get('Retry-After'), now())
109
+ return retryAfterS === undefined ? { status: res.status, body: parsed } : { status: res.status, body: parsed, retryAfterS }
110
+ }
111
+ }
@@ -108,6 +108,15 @@ export interface KbClient {
108
108
  * `locked` with its `access` tiers. Needs a KB API with the locked-article preview.
109
109
  */
110
110
  includeLocked?: boolean
111
+ /**
112
+ * Localize the list: each article's title and description in this language (the
113
+ * page's locale). By default only articles translated into it are listed; each item
114
+ * carries `languageCode` and `isFallback`. Omit for the source language's text.
115
+ * Needs a KB API with localized lists (10. 10. 2026).
116
+ */
117
+ languageCode?: string
118
+ /** With `languageCode`: also list untranslated articles, `isFallback: true`, source text. */
119
+ includeUntranslated?: boolean
111
120
  }): Promise<{
112
121
  accessibleKbArticles: { articles: Article[]; totalCount: number }
113
122
  }>
@@ -219,6 +228,14 @@ export interface KbClient {
219
228
  languageCode: string,
220
229
  ): Promise<{ getTranslation: Translation }>
221
230
  }
231
+ /**
232
+ * The legacy comment API.
233
+ *
234
+ * @deprecated Since 0.9.0, removed in 1.0: discussions are Comments 2.0 — `@blogmcp/sdk/community`
235
+ * (`createCommunityClient`) and the `<blogmcp-discussion>` element of `@blogmcp/community`. The reads keep
236
+ * working through kb-api's compatible layer; the writes answer `COMMENTS_FROZEN` during a tenant's cutover and
237
+ * `COMMENTS_MOVED` after it (`commentErrorCode`, the `comments.frozen` / `comments.moved` texts).
238
+ */
222
239
  comments: {
223
240
  list(
224
241
  articleId: string,
@@ -314,7 +331,13 @@ export function createKbClient(config: KbClientConfig): KbClient {
314
331
  return {
315
332
  articles: {
316
333
  list: (params) => {
317
- const { includeLocked, ...variables } = params ?? {}
334
+ const { includeLocked, languageCode, includeUntranslated, ...variables } = params ?? {}
335
+ if (languageCode) {
336
+ return exec(
337
+ includeLocked ? Q.ACCESSIBLE_ARTICLES_WITH_LOCKED_LOCALIZED : Q.ACCESSIBLE_ARTICLES_LOCALIZED,
338
+ { ...variables, languageCode, includeUntranslated: includeUntranslated === true },
339
+ )
340
+ }
318
341
  return exec(includeLocked ? Q.ACCESSIBLE_ARTICLES_WITH_LOCKED : Q.ACCESSIBLE_ARTICLES, variables)
319
342
  },
320
343
  getWithTranslation: (filename, languageCode) =>
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The legacy comment API's two cutover codes (docs/internal/m1-contracts.md §9.3, §10.5): while a tenant's comments
3
+ * move to Comments 2.0, `createComment` / `updateComment` / `deleteComment` answer
4
+ * `CommentResult { success: false, error: 'COMMENTS_FROZEN' }` during the freeze and `'COMMENTS_MOVED'` from the move
5
+ * on, and the `commentUpdates` subscription ends with a `KbGraphQLError` of code `COMMENTS_MOVED`. A blog's current
6
+ * panel tells the reader what happened with the `comments.frozen` / `comments.moved` texts until its host embeds
7
+ * the discussion element.
8
+ *
9
+ * @deprecated With `client.comments.*`; removed in 1.0.
10
+ */
11
+
12
+ import { isKbGraphQLError } from './errors'
13
+
14
+ /** The legacy comment API's cutover codes. */
15
+ export type LegacyCommentErrorCode = 'COMMENTS_FROZEN' | 'COMMENTS_MOVED'
16
+
17
+ const CODE_RE = /^(COMMENTS_FROZEN|COMMENTS_MOVED)(?![A-Z0-9_])/
18
+
19
+ /**
20
+ * The cutover code of a failed comment write (a `CommentResult` whose `error` is the code) or of a thrown
21
+ * `KbGraphQLError` — null for anything else (another error, a success, free text).
22
+ */
23
+ export function commentErrorCode(result: unknown): LegacyCommentErrorCode | null {
24
+ if (isKbGraphQLError(result)) {
25
+ if (result.code === 'COMMENTS_FROZEN') return 'COMMENTS_FROZEN'
26
+ if (result.code === 'COMMENTS_MOVED') return 'COMMENTS_MOVED'
27
+ return null
28
+ }
29
+ if (typeof result !== 'object' || result === null) return null
30
+ const { success, error } = result as { success?: unknown; error?: unknown }
31
+ if (success === true || typeof error !== 'string') return null
32
+ const m = CODE_RE.exec(error.trim())
33
+ return m ? (m[1] as LegacyCommentErrorCode) : null
34
+ }
35
+
36
+ /** The `core/translations` key that explains a cutover code to the reader. */
37
+ export function commentErrorMessageKey(code: LegacyCommentErrorCode): 'comments.frozen' | 'comments.moved' {
38
+ return code === 'COMMENTS_FROZEN' ? 'comments.frozen' : 'comments.moved'
39
+ }
package/src/core/index.ts CHANGED
@@ -82,6 +82,11 @@ export type {
82
82
  RawGraphQLError,
83
83
  } from './errors'
84
84
 
85
+ // The legacy comment API's cutover codes (deprecated with `client.comments.*`; Comments 2.0 is
86
+ // `@blogmcp/sdk/community` and the discussion element)
87
+ export { commentErrorCode, commentErrorMessageKey } from './comments-legacy'
88
+ export type { LegacyCommentErrorCode } from './comments-legacy'
89
+
85
90
  // Client types
86
91
  export type {
87
92
  KbClientConfig,
@@ -220,6 +225,9 @@ export * as queries from './queries'
220
225
  // React tree) can preserve the same shim guarantee — propRename, enumValueRename,
221
226
  // and propBecameRequired defaults are applied identically across frameworks.
222
227
  export { prepareProps } from '@blogmcp/mdx-schema/prepareProps'
228
+ // Article titles as plain text (stored titles may carry inline Markdown) and the title a body
229
+ // declares through its first `# heading` — the same two functions kb-api uses on write.
230
+ export { inlineMarkdownToPlainText, extractTitleHeading } from '@blogmcp/mdx-schema/title'
223
231
  export {
224
232
  getComponentMetadata,
225
233
  getComponentNames,
@@ -54,6 +54,55 @@ export const ACCESSIBLE_ARTICLES_WITH_LOCKED = `
54
54
  }
55
55
  `
56
56
 
57
+ // Localized lists (10. 10. 2026): the same two documents with `languageCode` /
58
+ // `includeUntranslated` and the per-item `languageCode` + `isFallback`. Documents of their own,
59
+ // so a list without a language keeps validating against a KB API that predates the arguments.
60
+ export const ACCESSIBLE_ARTICLES_LOCALIZED = `
61
+ query AccessibleArticlesLocalized($status: String, $tags: [String!], $tagMode: String, $limit: Int, $offset: Int, $languageCode: String, $includeUntranslated: Boolean) {
62
+ accessibleKbArticles(status: $status, tags: $tags, tagMode: $tagMode, limit: $limit, offset: $offset, languageCode: $languageCode, includeUntranslated: $includeUntranslated) {
63
+ articles {
64
+ id
65
+ filename
66
+ title
67
+ description
68
+ contentType
69
+ status
70
+ publishedAt
71
+ updatedAt
72
+ tags
73
+ featuredImageUrl
74
+ languageCode
75
+ isFallback
76
+ }
77
+ totalCount
78
+ }
79
+ }
80
+ `
81
+
82
+ export const ACCESSIBLE_ARTICLES_WITH_LOCKED_LOCALIZED = `
83
+ query AccessibleArticlesWithLockedLocalized($status: String, $tags: [String!], $tagMode: String, $limit: Int, $offset: Int, $languageCode: String, $includeUntranslated: Boolean) {
84
+ accessibleKbArticles(status: $status, tags: $tags, tagMode: $tagMode, limit: $limit, offset: $offset, includeLocked: true, languageCode: $languageCode, includeUntranslated: $includeUntranslated) {
85
+ articles {
86
+ id
87
+ filename
88
+ title
89
+ description
90
+ contentType
91
+ status
92
+ publishedAt
93
+ updatedAt
94
+ tags
95
+ featuredImageUrl
96
+ access
97
+ locked
98
+ languageCode
99
+ isFallback
100
+ }
101
+ totalCount
102
+ }
103
+ }
104
+ `
105
+
57
106
  // Field selection shared by the by-filename and by-id article queries, so both
58
107
  // lookups always return the identical ArticleWithTranslation shape.
59
108
  const ARTICLE_WITH_TRANSLATION_FIELDS = `
@@ -296,6 +345,12 @@ const COMMENT_FIELDS = `
296
345
  createdAt
297
346
  `
298
347
 
348
+ /**
349
+ * The legacy comment API: an article's comment tree.
350
+ *
351
+ * @deprecated Since 0.9.0, removed in 1.0: Comments 2.0 replaces it — `@blogmcp/sdk/community`
352
+ * (`createCommunityClient`) and the `<blogmcp-discussion>` element of `@blogmcp/community`.
353
+ */
299
354
  export const ARTICLE_COMMENTS = `
300
355
  query ArticleComments($articleId: ID!, $languageCode: String!) {
301
356
  articleComments(articleId: $articleId, languageCode: $languageCode) {
@@ -316,6 +371,12 @@ export const ARTICLE_COMMENTS = `
316
371
  }
317
372
  `
318
373
 
374
+ /**
375
+ * The legacy comment API: one comment with its replies.
376
+ *
377
+ * @deprecated Since 0.9.0, removed in 1.0: Comments 2.0 replaces it — `@blogmcp/sdk/community`
378
+ * (`createCommunityClient`) and the `<blogmcp-discussion>` element of `@blogmcp/community`.
379
+ */
319
380
  export const GET_COMMENT = `
320
381
  query GetComment($commentId: ID!, $languageCode: String!) {
321
382
  comment(commentId: $commentId, languageCode: $languageCode) {
@@ -327,6 +388,14 @@ export const GET_COMMENT = `
327
388
  }
328
389
  `
329
390
 
391
+ /**
392
+ * The legacy comment API: a new comment.
393
+ *
394
+ * @deprecated Since 0.9.0, removed in 1.0: Comments 2.0 replaces it — `@blogmcp/sdk/community`
395
+ * (`createCommunityClient`) and the `<blogmcp-discussion>` element of `@blogmcp/community`.
396
+ * During a tenant's cutover it answers `CommentResult { success: false, error: 'COMMENTS_FROZEN' }`,
397
+ * and from the cutover's `move` on `'COMMENTS_MOVED'` (`commentErrorCode`).
398
+ */
330
399
  export const CREATE_COMMENT = `
331
400
  mutation CreateComment($articleId: ID!, $content: String!, $sourceLanguageCode: String!, $parentCommentId: ID) {
332
401
  createComment(articleId: $articleId, content: $content, sourceLanguageCode: $sourceLanguageCode, parentCommentId: $parentCommentId) {
@@ -339,6 +408,14 @@ export const CREATE_COMMENT = `
339
408
  }
340
409
  `
341
410
 
411
+ /**
412
+ * The legacy comment API: a comment's edit.
413
+ *
414
+ * @deprecated Since 0.9.0, removed in 1.0: Comments 2.0 replaces it — `@blogmcp/sdk/community`
415
+ * (`createCommunityClient`) and the `<blogmcp-discussion>` element of `@blogmcp/community`.
416
+ * During a tenant's cutover it answers `CommentResult { success: false, error: 'COMMENTS_FROZEN' }`,
417
+ * and from the cutover's `move` on `'COMMENTS_MOVED'` (`commentErrorCode`).
418
+ */
342
419
  export const UPDATE_COMMENT = `
343
420
  mutation UpdateComment($commentId: ID!, $content: String!) {
344
421
  updateComment(commentId: $commentId, content: $content) {
@@ -351,6 +428,14 @@ export const UPDATE_COMMENT = `
351
428
  }
352
429
  `
353
430
 
431
+ /**
432
+ * The legacy comment API: a comment's deletion.
433
+ *
434
+ * @deprecated Since 0.9.0, removed in 1.0: Comments 2.0 replaces it — `@blogmcp/sdk/community`
435
+ * (`createCommunityClient`) and the `<blogmcp-discussion>` element of `@blogmcp/community`.
436
+ * During a tenant's cutover it answers `CommentResult { success: false, error: 'COMMENTS_FROZEN' }`,
437
+ * and from the cutover's `move` on `'COMMENTS_MOVED'` (`commentErrorCode`).
438
+ */
354
439
  export const DELETE_COMMENT = `
355
440
  mutation DeleteComment($commentId: ID!) {
356
441
  deleteComment(commentId: $commentId) {
@@ -360,6 +445,14 @@ export const DELETE_COMMENT = `
360
445
  }
361
446
  `
362
447
 
448
+ /**
449
+ * The legacy comment API: an article's comment events.
450
+ *
451
+ * @deprecated Since 0.9.0, removed in 1.0: Comments 2.0 replaces it — `@blogmcp/sdk/community`
452
+ * (`createCommunityClient`, its poller) and the `<blogmcp-discussion>` element of `@blogmcp/community`.
453
+ * From a tenant's cutover `move` on, the subscription ends with a `KbGraphQLError` of code `COMMENTS_MOVED`
454
+ * (`commentErrorCode`).
455
+ */
363
456
  export const COMMENT_UPDATES_SUBSCRIPTION = `
364
457
  subscription CommentUpdates($articleId: ID!) {
365
458
  commentUpdates(articleId: $articleId) {
@@ -90,7 +90,7 @@ export function renderReviewStatusHtml(reason: ReviewFailureReason, opts: { lang
90
90
  * to an exact version: the page holds the review token, so what runs on it must not change under it.
91
91
  * Self-host the file (`@blogmcp/review/global`) under a strict CSP or to add Subresource Integrity.
92
92
  */
93
- export const REVIEW_LAYER_SCRIPT_URL = 'https://cdn.jsdelivr.net/npm/@blogmcp/review@0.1.0/dist/blogmcp-review.global.js'
93
+ export const REVIEW_LAYER_SCRIPT_URL = 'https://cdn.jsdelivr.net/npm/@blogmcp/review@0.1.1/dist/blogmcp-review.global.js'
94
94
  /** Id of the JSON island `reviewBootstrapHtml` writes the session into. */
95
95
  export const REVIEW_SESSION_ELEMENT_ID = 'blogmcp-review-session'
96
96
 
@@ -21,7 +21,7 @@ export interface ReviewPlanUnit {
21
21
  type: string
22
22
  /** Element tags (upper case) a site may render this block as; empty = any. Unused for components. */
23
23
  tags: readonly string[]
24
- /** The block's leading text, normalised (`normalizeReviewText`); '' when it has none. */
24
+ /** The block's leading text, normalised (`normalizeReviewText`); '' when it has none. For a component: its children's. */
25
25
  text: string
26
26
  }
27
27
 
@@ -110,7 +110,9 @@ export function createReviewPlan(content: string): ReviewPlan {
110
110
  bodyOffset: plan.bodyOffset,
111
111
  units: plan.units.map((u) =>
112
112
  u.kind === 'component'
113
- ? { nodeId: u.nodeId, sourceRange: u.sourceRange, kind: 'component', type: u.name, tags: [], text: '' }
113
+ ? // A component's text is its children's (a Callout's paragraph): it pairs the component
114
+ // with what a site renders when that site does not mark the root `data-mdx-component`.
115
+ { nodeId: u.nodeId, sourceRange: u.sourceRange, kind: 'component', type: u.name, tags: [], text: hint(u.children ?? '') }
114
116
  : { nodeId: u.nodeId, sourceRange: u.sourceRange, kind: 'markdown', ...describe(u.token) },
115
117
  ),
116
118
  }
@@ -8,8 +8,10 @@
8
8
  * attribute on that element: `data-mdx-node-id`. No element is added, moved or wrapped. `restore()`
9
9
  * takes the attributes off again.
10
10
  *
11
- * Blocks that cannot be paired (a raw HTML block, a custom component without `data-mdx-component`,
12
- * a heading the site moved into its own header) just stay unstamped: comments there fall back to
11
+ * A component the site renders without `data-mdx-component` is paired through its children's
12
+ * text (its first block gets the id). Blocks that cannot be paired (a raw HTML block, a component
13
+ * with no text of its own and no marker, a heading the site moved into its own header) just stay
14
+ * unstamped: comments there fall back to
13
15
  * quote + context (level 0), which works with any renderer. A renderer that already stamps
14
16
  * `data-mdx-node-id` (`@blogmcp/render-embed-*`) is left as it is.
15
17
  */
@@ -76,7 +78,12 @@ function textMatches(want: string, el: Element): boolean {
76
78
 
77
79
  function pairs(unit: ReviewPlanUnit, el: Element): boolean {
78
80
  const component = componentOf(el)
79
- if (unit.kind === 'component') return component === unit.type
81
+ if (unit.kind === 'component') {
82
+ if (component) return component === unit.type
83
+ // A site component without `data-mdx-component`: its first block, by the children's text.
84
+ // Components with no text of their own (a gallery) stay unpaired.
85
+ return !!unit.text && textMatches(unit.text, el)
86
+ }
80
87
  if (component) return false
81
88
  if (unit.tags.length > 0 && !unit.tags.includes(el.tagName.toUpperCase())) return false
82
89
  if (unit.text) return textMatches(unit.text, el)
@@ -160,8 +167,14 @@ export function stampReviewDom(root: Element, plan: ReviewPlan): ReviewStamp {
160
167
  const unit = byId.get(id)
161
168
  if (!unit) return null
162
169
  const named = componentOf(el)
163
- // A site's own attribute value must not make the round invalid: fall back to the tag.
164
- const component = named && COMPONENT_RE.test(named) ? named : el.tagName.toLowerCase()
170
+ // A site's own attribute value must not make the round invalid: fall back to the plan's
171
+ // component name (a component paired by its text), else the tag.
172
+ const component =
173
+ named && COMPONENT_RE.test(named)
174
+ ? named
175
+ : unit.kind === 'component' && COMPONENT_RE.test(unit.type)
176
+ ? unit.type
177
+ : el.tagName.toLowerCase()
165
178
  return { id, component, sourceRange: { ...unit.sourceRange } }
166
179
  }
167
180
 
package/src/core/seo.ts CHANGED
@@ -12,6 +12,7 @@
12
12
  * (page title pieces, brand suffix, description).
13
13
  */
14
14
 
15
+ import { inlineMarkdownToPlainText } from '@blogmcp/mdx-schema/title'
15
16
  import { generateDescription } from './article-seo'
16
17
  import type { MediaGeo, ContentImageGeo } from './types'
17
18
 
@@ -188,7 +189,10 @@ export interface BuildArticleSeoOptions {
188
189
  export function buildArticleSeo(opts: BuildArticleSeoOptions): SeoModel {
189
190
  const { article, config, locale, routePath, brandSuffix, fallbackTitle } = opts
190
191
 
191
- const displayTitle = article.title || ''
192
+ // The title is printed as TEXT everywhere below (<title>, og/twitter, JSON-LD headline), never
193
+ // rendered as Markdown — a stored `Outkovka pestrá (*Trametes versicolor*)` must not show its
194
+ // asterisks in the browser tab or a search result.
195
+ const displayTitle = inlineMarkdownToPlainText(article.title)
192
196
  const ogTitle = displayTitle || fallbackTitle
193
197
  const title = `${ogTitle} | ${brandSuffix}`
194
198
  const description =
@@ -156,7 +156,9 @@
156
156
  "charCount": "{count}/{max}",
157
157
  "submitHint": "Stiskněte {key}+Enter pro odeslání",
158
158
  "loadError": "Nepodařilo se načíst komentáře",
159
- "submitError": "Nepodařilo se odeslat komentář"
159
+ "submitError": "Nepodařilo se odeslat komentář",
160
+ "frozen": "Komentáře se právě přesouvají do nové diskuse. Psát půjde za chvíli.",
161
+ "moved": "Komentáře se přesunuly do nové diskuse. Obnovte prosím stránku."
160
162
  },
161
163
  "accessGate": {
162
164
  "signInToAccess": "Pro přístup k tomuto obsahu ({level}) se přihlaste.",
@@ -156,7 +156,9 @@
156
156
  "charCount": "{count}/{max}",
157
157
  "submitHint": "Press {key}+Enter to submit",
158
158
  "loadError": "Failed to load comments",
159
- "submitError": "Failed to submit comment"
159
+ "submitError": "Failed to submit comment",
160
+ "frozen": "Comments are moving to the new discussion right now. You can write again shortly.",
161
+ "moved": "Comments have moved to the new discussion. Please reload the page."
160
162
  },
161
163
  "accessGate": {
162
164
  "signInToAccess": "Sign in to access this {level} content.",
package/src/core/types.ts CHANGED
@@ -52,6 +52,16 @@ export interface Article {
52
52
  * article page, which shows `articles.getPreview` instead of the article.
53
53
  */
54
54
  locked?: boolean
55
+ /**
56
+ * Only from `articles.list({ languageCode })`: the language of `title` and `description` —
57
+ * the requested one, or the source language for a fallback.
58
+ */
59
+ languageCode?: string | null
60
+ /**
61
+ * Only from `articles.list({ languageCode, includeUntranslated: true })`: no translation into
62
+ * the requested language, so `title` and `description` are the source language's.
63
+ */
64
+ isFallback?: boolean
55
65
  }
56
66
 
57
67
  /** What a locked article shows to a reader without access (the tenant's choice). */
@@ -612,11 +622,19 @@ export interface ConsultationEraseInput {
612
622
  export interface ConsultationEraseResult {
613
623
  requestId: string
614
624
  dryRun: boolean
615
- /** `partial` when a thread under legal hold was kept (and marked for deletion once released). */
625
+ /**
626
+ * `partial` when a thread under legal hold was kept (and marked for deletion once released),
627
+ * or — on instances with M1 — a community message under legal hold was kept whole.
628
+ */
616
629
  status: 'done' | 'partial'
617
630
  threadsErased: number
618
631
  threadsHeld: number
619
632
  accountsAnonymised: number
633
+ /**
634
+ * The person's community member (m1-contracts.md §8.2): members erased, messages tombstoned,
635
+ * messages kept by a legal hold; a dry run counts the same way. Present on instances with M1.
636
+ */
637
+ community?: { membersErased: number; messagesTombstoned: number; messagesHeld: number }
620
638
  }
621
639
 
622
640
  export interface ConsultationOwnerRefsInput {
@@ -6,6 +6,7 @@
6
6
  * identical data and only differ in template markup.
7
7
  */
8
8
 
9
+ import { inlineMarkdownToPlainText } from '@blogmcp/mdx-schema/title'
9
10
  import type { Article, AccessLevel } from './types'
10
11
  import { ACCESS_LEVEL_ORDER } from './types'
11
12
  import { localizedHref, type SeoConfig } from './seo'
@@ -82,6 +83,13 @@ export interface ArticleListItemVM {
82
83
  locked: boolean
83
84
  /** For a locked article, the tier that opens it; null otherwise. */
84
85
  requiredAccess: 'premium' | 'partners' | null
86
+ /** Language of `title` / `description` (from a localized list), or null when unknown. */
87
+ languageCode: string | null
88
+ /**
89
+ * The list was asked for another language and the article has no translation into it
90
+ * (only with `includeUntranslated`): the card should say the article is in `languageCode`.
91
+ */
92
+ isFallback: boolean
85
93
  }
86
94
 
87
95
  export interface BuildArticleListItemOptions {
@@ -100,7 +108,8 @@ export function buildArticleListItem(opts: BuildArticleListItemOptions): Article
100
108
  return {
101
109
  slug,
102
110
  href: localizedHref(`/articles/${slug}`, locale, config),
103
- title: article.title || '',
111
+ // Cards print the title as text: plain text, never the stored Markdown.
112
+ title: inlineMarkdownToPlainText(article.title),
104
113
  description: article.description ?? null,
105
114
  image: article.featuredImageUrl ?? null,
106
115
  isoDate,
@@ -112,5 +121,7 @@ export function buildArticleListItem(opts: BuildArticleListItemOptions): Article
112
121
  })),
113
122
  locked: article.locked === true,
114
123
  requiredAccess: article.locked === true ? lockedRequiredAccess(article.access) : null,
124
+ languageCode: article.languageCode ?? null,
125
+ isFallback: article.isFallback === true,
115
126
  }
116
127
  }
@@ -11,6 +11,7 @@ import type { Comment, CommentsConnection, CommentResult, CommentSubscriptionEve
11
11
  import { useKbClient } from './useKbClient'
12
12
  import { useKbAuth } from './useKbAuth'
13
13
 
14
+ /** @deprecated Since 0.9.0, removed in 1.0 — see {@link useKbComments}. */
14
15
  export interface UseKbCommentsReturn {
15
16
  comments: DeepReadonly<Ref<Comment[]>>
16
17
  totalCount: DeepReadonly<Ref<number>>
@@ -34,6 +35,13 @@ export interface UseKbCommentsReturn {
34
35
  clearState: () => void
35
36
  }
36
37
 
38
+ /**
39
+ * The legacy comment thread of an article.
40
+ *
41
+ * @deprecated Since 0.9.0, removed in 1.0: discussions are Comments 2.0 — the `<blogmcp-discussion>` element of
42
+ * `@blogmcp/community` (`<KbDiscussion>` in Vue) over `@blogmcp/sdk/community`. Reads keep working through kb-api's
43
+ * compatible layer; writes answer `COMMENTS_FROZEN` / `COMMENTS_MOVED` during and after the tenant's cutover.
44
+ */
37
45
  export function useKbComments(): UseKbCommentsReturn {
38
46
  const client = useKbClient()
39
47
  const { user, isAuthenticated } = useKbAuth()