@blogmcp/sdk 0.1.2 → 0.1.3

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.
@@ -1,2 +1,4 @@
1
- import { __require as r } from "../node_modules/semver/index.js";
2
- r();
1
+ var r = {};
2
+ export {
3
+ r as __exports
4
+ };
@@ -1,4 +1,2 @@
1
- var r = {};
2
- export {
3
- r as __exports
4
- };
1
+ import { __require as r } from "../node_modules/semver/index.js";
2
+ r();
@@ -6,7 +6,7 @@
6
6
  * const data = await client.articles.list({ status: 'published', limit: 10 })
7
7
  */
8
8
  import type { KbClientConfig } from './client-types';
9
- import type { Article, ArticleWithTranslation, Tag, LocalizedTag, Language, SearchResult, KBContextChunk, Translation, Comment, CommentsConnection, CommentResult, AuthResult, RegisterResult, UpdateProfileResult, ReportSettings, UpdateReportSettingsInput } from './types';
9
+ import type { Article, ArticleWithTranslation, ArticleVersionContent, Tag, LocalizedTag, Language, SearchResult, KBContextChunk, Translation, Comment, CommentsConnection, CommentResult, AuthResult, RegisterResult, UpdateProfileResult, ReportSettings, UpdateReportSettingsInput } from './types';
10
10
  import type { NavNode } from './navigation';
11
11
  export interface KbClient {
12
12
  articles: {
@@ -44,6 +44,20 @@ export interface KbClient {
44
44
  resolveAlias(filename: string): Promise<{
45
45
  articleAliasTarget: string | null;
46
46
  }>;
47
+ /**
48
+ * Fetch ONE article version's content by its STABLE version id, for headless
49
+ * preview / A/B (test-before-publish, multi-variant serving). Bypasses publish
50
+ * status, so the server returns it only to an INTERNAL caller (server client
51
+ * holding the api token) OR a caller passing a valid `previewKey` minted for
52
+ * this exact versionId. Returns `{ articleVersion: null }` when missing or
53
+ * unauthorized. Versions are per-language; the returned `languageCode` is the
54
+ * version's own translation — no language argument is taken.
55
+ */
56
+ getVersion(versionId: string, opts?: {
57
+ previewKey?: string;
58
+ }): Promise<{
59
+ articleVersion: ArticleVersionContent | null;
60
+ }>;
47
61
  };
48
62
  search: {
49
63
  query(params: {
@@ -1,6 +1,6 @@
1
- import { UPDATE_MY_PROFILE as A, UPDATE_MY_REPORT_SETTINGS as i, MY_REPORT_SETTINGS as S, CHANGE_PASSWORD as _, RESEND_VERIFICATION as I, RESET_PASSWORD as l, FORGOT_PASSWORD as R, VERIFY_EMAIL as c, REGISTER as d, LOGIN as N, DELETE_COMMENT as O, UPDATE_COMMENT as C, CREATE_COMMENT as L, GET_COMMENT as h, ARTICLE_COMMENTS as u, GET_TRANSLATION as p, ARTICLE_TRANSLATIONS as G, KB_NAVIGATION as g, KB_LANGUAGES as m, LOCALIZED_TAGS as M, ACCESSIBLE_TAGS as P, GET_KB_CONTEXT as D, SEARCH_KNOWLEDGE_BASE as f, ARTICLE_ALIAS_TARGET as y, ARTICLE_WITH_TRANSLATION_BY_ID as B, ARTICLE_WITH_TRANSLATION as W, ACCESSIBLE_ARTICLES as w } from "./queries.js";
2
- import { createMemoryTokenStorage as k } from "./auth.js";
3
- function v() {
1
+ import { UPDATE_MY_PROFILE as i, ARTICLE_VERSION as A, UPDATE_MY_REPORT_SETTINGS as S, MY_REPORT_SETTINGS as _, CHANGE_PASSWORD as I, RESEND_VERIFICATION as l, RESET_PASSWORD as R, FORGOT_PASSWORD as c, VERIFY_EMAIL as d, REGISTER as N, LOGIN as O, DELETE_COMMENT as C, UPDATE_COMMENT as L, CREATE_COMMENT as u, GET_COMMENT as h, ARTICLE_COMMENTS as p, GET_TRANSLATION as g, ARTICLE_TRANSLATIONS as G, KB_NAVIGATION as m, KB_LANGUAGES as M, LOCALIZED_TAGS as P, ACCESSIBLE_TAGS as y, GET_KB_CONTEXT as D, SEARCH_KNOWLEDGE_BASE as f, ARTICLE_ALIAS_TARGET as w, ARTICLE_WITH_TRANSLATION_BY_ID as B, ARTICLE_WITH_TRANSLATION as v, ACCESSIBLE_ARTICLES as W } from "./queries.js";
2
+ import { createMemoryTokenStorage as K } from "./auth.js";
3
+ function k() {
4
4
  return async (n, o) => (await fetch(n, {
5
5
  method: o.method,
6
6
  headers: o.headers,
@@ -22,58 +22,59 @@ async function x(n, o, a) {
22
22
  return t.data;
23
23
  }
24
24
  function Y(n) {
25
- const o = n.fetcher || v(), a = n.tokenStorage || k(), s = { endpoint: n.isServer && n.serverEndpoint ? n.serverEndpoint : n.endpoint, fetcher: o, tokenStorage: a };
25
+ const o = n.fetcher || k(), a = n.tokenStorage || K(), s = { endpoint: n.isServer && n.serverEndpoint ? n.serverEndpoint : n.endpoint, fetcher: o, tokenStorage: a };
26
26
  function t(e, r) {
27
27
  return x(s, e, r);
28
28
  }
29
29
  return {
30
30
  articles: {
31
- list: (e) => t(w, e),
32
- getWithTranslation: (e, r) => t(W, { filename: e, languageCode: r }),
31
+ list: (e) => t(W, e),
32
+ getWithTranslation: (e, r) => t(v, { filename: e, languageCode: r }),
33
33
  getWithTranslationById: (e, r) => t(B, { id: e, languageCode: r }),
34
- resolveAlias: (e) => t(y, { filename: e })
34
+ resolveAlias: (e) => t(w, { filename: e }),
35
+ getVersion: (e, r) => t(A, { versionId: e, previewKey: r?.previewKey ?? null })
35
36
  },
36
37
  search: {
37
38
  query: (e) => t(f, e),
38
39
  getContext: (e, r) => t(D, { query: e, maxChunks: r })
39
40
  },
40
41
  tags: {
41
- list: () => t(P),
42
- listLocalized: (e) => t(M, { languageCode: e })
42
+ list: () => t(y),
43
+ listLocalized: (e) => t(P, { languageCode: e })
43
44
  },
44
45
  languages: {
45
- list: () => t(m)
46
+ list: () => t(M)
46
47
  },
47
48
  navigation: {
48
- get: (e) => t(g, e ?? {})
49
+ get: (e) => t(m, e ?? {})
49
50
  },
50
51
  translations: {
51
52
  list: (e) => t(G, { sourceFilename: e }),
52
- get: (e, r) => t(p, { sourceFilename: e, languageCode: r })
53
+ get: (e, r) => t(g, { sourceFilename: e, languageCode: r })
53
54
  },
54
55
  comments: {
55
- list: (e, r) => t(u, { articleId: e, languageCode: r }),
56
+ list: (e, r) => t(p, { articleId: e, languageCode: r }),
56
57
  get: (e, r) => t(h, { commentId: e, languageCode: r }),
57
- create: (e) => t(L, e),
58
- update: (e, r) => t(C, { commentId: e, content: r }),
59
- delete: (e) => t(O, { commentId: e })
58
+ create: (e) => t(u, e),
59
+ update: (e, r) => t(L, { commentId: e, content: r }),
60
+ delete: (e) => t(C, { commentId: e })
60
61
  },
61
62
  auth: {
62
- login: (e, r) => t(N, { email: e, password: r }),
63
- register: (e, r, T) => t(d, { email: e, password: r, name: T }),
64
- verifyEmail: (e) => t(c, { token: e }),
65
- forgotPassword: (e) => t(R, { email: e }),
66
- resetPassword: (e, r) => t(l, { token: e, password: r }),
67
- resendVerification: (e) => t(I, { email: e }),
68
- changePassword: (e, r) => t(_, { currentPassword: e, newPassword: r }),
69
- updateProfile: (e) => t(A, {
63
+ login: (e, r) => t(O, { email: e, password: r }),
64
+ register: (e, r, T) => t(N, { email: e, password: r, name: T }),
65
+ verifyEmail: (e) => t(d, { token: e }),
66
+ forgotPassword: (e) => t(c, { email: e }),
67
+ resetPassword: (e, r) => t(R, { token: e, password: r }),
68
+ resendVerification: (e) => t(l, { email: e }),
69
+ changePassword: (e, r) => t(I, { currentPassword: e, newPassword: r }),
70
+ updateProfile: (e) => t(i, {
70
71
  name: e.name ?? null,
71
72
  email: e.email ?? null
72
73
  })
73
74
  },
74
75
  reportSettings: {
75
- get: () => t(S),
76
- update: (e) => t(i, e)
76
+ get: () => t(_),
77
+ update: (e) => t(S, e)
77
78
  },
78
79
  executeGraphQL: t
79
80
  };
@@ -1,4 +1,4 @@
1
- export type { Article, ArticleWithTranslation, MediaGeo, ContentImageGeo, Tag, LocalizedTag, SearchResult, KBContextChunk, Translation, Language, AccessLevel, Comment, CommentSubscriptionEvent, CommentsConnection, CommentResult, AuthUser, AuthResult, RegisterResult, UpdateProfileResult, ReportSettings, ReportPolicyValue, EmailNotificationFrequency, FeedbackNotificationFrequency, UpdateReportSettingsInput, PaginatedResponse, } from './types';
1
+ export type { Article, ArticleWithTranslation, ArticleVersionContent, MediaGeo, ContentImageGeo, Tag, LocalizedTag, SearchResult, KBContextChunk, Translation, Language, AccessLevel, Comment, CommentSubscriptionEvent, CommentsConnection, CommentResult, AuthUser, AuthResult, RegisterResult, UpdateProfileResult, ReportSettings, ReportPolicyValue, EmailNotificationFrequency, FeedbackNotificationFrequency, UpdateReportSettingsInput, PaginatedResponse, } from './types';
2
2
  export { ACCESS_LEVEL_ORDER } from './types';
3
3
  export type { KbClientConfig, Fetcher, TokenStorage, ImageHtmlRenderer, SanitizeFn, } from './client-types';
4
4
  export type { KbClient } from './client';
@@ -9,6 +9,7 @@ export declare const ACCESSIBLE_ARTICLES = "\n query AccessibleArticles($status
9
9
  export declare const ARTICLE_WITH_TRANSLATION = "\n query ArticleWithTranslation($filename: String!, $languageCode: String!) {\n articleWithTranslation(filename: $filename, languageCode: $languageCode) {\n id\n filename\n contentType\n status\n description\n sourceLanguageCode\n createdAt\n updatedAt\n publishedAt\n title\n content\n languageCode\n isSource\n isFallback\n featuredImageUrl\n featuredImageGeo {\n latitude\n longitude\n altitude\n placeName\n }\n contentImagesGeo {\n url\n latitude\n longitude\n altitude\n placeName\n }\n accessRights\n}\n }\n";
10
10
  export declare const ARTICLE_WITH_TRANSLATION_BY_ID = "\n query ArticleWithTranslationById($id: ID!, $languageCode: String!) {\n articleWithTranslationById(id: $id, languageCode: $languageCode) {\n id\n filename\n contentType\n status\n description\n sourceLanguageCode\n createdAt\n updatedAt\n publishedAt\n title\n content\n languageCode\n isSource\n isFallback\n featuredImageUrl\n featuredImageGeo {\n latitude\n longitude\n altitude\n placeName\n }\n contentImagesGeo {\n url\n latitude\n longitude\n altitude\n placeName\n }\n accessRights\n}\n }\n";
11
11
  export declare const ARTICLE_ALIAS_TARGET = "\n query ArticleAliasTarget($filename: String!) {\n articleAliasTarget(filename: $filename)\n }\n";
12
+ export declare const ARTICLE_VERSION = "\n query ArticleVersion($versionId: ID!, $previewKey: String) {\n articleVersion(versionId: $versionId, previewKey: $previewKey) {\n versionId\n articleId\n filename\n versionNumber\n title\n content\n languageCode\n schemaVersion\n createdAt\n }\n }\n";
12
13
  export declare const SEARCH_KNOWLEDGE_BASE = "\n query SearchKnowledgeBase($query: String!, $tags: [String!], $contentType: String, $limit: Int, $minSimilarity: Float, $searchMode: SearchMode) {\n searchKnowledgeBase(query: $query, tags: $tags, contentType: $contentType, limit: $limit, minSimilarity: $minSimilarity, searchMode: $searchMode) {\n articleId\n filename\n title\n chunkText\n similarity\n }\n }\n";
13
14
  export declare const GET_KB_CONTEXT = "\n query GetKBContext($query: String!, $maxChunks: Int) {\n getKBContext(query: $query, maxChunks: $maxChunks) {\n chunks {\n filename\n title\n text\n similarity\n }\n totalChunks\n }\n }\n";
14
15
  export declare const KB_NAVIGATION = "\n query KbNavigation($scope: String, $locale: String) {\n kbNavigation(scope: $scope, locale: $locale)\n }\n";
@@ -59,6 +59,20 @@ const a = `
59
59
  articleAliasTarget(filename: $filename)
60
60
  }
61
61
  `, r = `
62
+ query ArticleVersion($versionId: ID!, $previewKey: String) {
63
+ articleVersion(versionId: $versionId, previewKey: $previewKey) {
64
+ versionId
65
+ articleId
66
+ filename
67
+ versionNumber
68
+ title
69
+ content
70
+ languageCode
71
+ schemaVersion
72
+ createdAt
73
+ }
74
+ }
75
+ `, s = `
62
76
  query SearchKnowledgeBase($query: String!, $tags: [String!], $contentType: String, $limit: Int, $minSimilarity: Float, $searchMode: SearchMode) {
63
77
  searchKnowledgeBase(query: $query, tags: $tags, contentType: $contentType, limit: $limit, minSimilarity: $minSimilarity, searchMode: $searchMode) {
64
78
  articleId
@@ -68,7 +82,7 @@ const a = `
68
82
  similarity
69
83
  }
70
84
  }
71
- `, s = `
85
+ `, c = `
72
86
  query GetKBContext($query: String!, $maxChunks: Int) {
73
87
  getKBContext(query: $query, maxChunks: $maxChunks) {
74
88
  chunks {
@@ -80,11 +94,11 @@ const a = `
80
94
  totalChunks
81
95
  }
82
96
  }
83
- `, c = `
97
+ `, l = `
84
98
  query KbNavigation($scope: String, $locale: String) {
85
99
  kbNavigation(scope: $scope, locale: $locale)
86
100
  }
87
- `, l = `
101
+ `, d = `
88
102
  query AccessibleTags {
89
103
  accessibleKbTags {
90
104
  tags {
@@ -97,7 +111,7 @@ const a = `
97
111
  totalCount
98
112
  }
99
113
  }
100
- `, d = `
114
+ `, m = `
101
115
  query LocalizedTags($languageCode: String!) {
102
116
  localizedTags(languageCode: $languageCode) {
103
117
  id
@@ -110,7 +124,7 @@ const a = `
110
124
  isFallback
111
125
  }
112
126
  }
113
- `, m = `
127
+ `, u = `
114
128
  query KBLanguages {
115
129
  kbLanguages {
116
130
  id
@@ -122,7 +136,7 @@ const a = `
122
136
  sortOrder
123
137
  }
124
138
  }
125
- `, u = `
139
+ `, g = `
126
140
  query ArticleTranslations($sourceFilename: String!) {
127
141
  listArticleTranslations(sourceFilename: $sourceFilename) {
128
142
  id
@@ -133,7 +147,7 @@ const a = `
133
147
  updatedAt
134
148
  }
135
149
  }
136
- `, g = `
150
+ `, $ = `
137
151
  query GetTranslation($sourceFilename: String!, $languageCode: String!) {
138
152
  getTranslation(sourceFilename: $sourceFilename, languageCode: $languageCode) {
139
153
  id
@@ -161,7 +175,7 @@ const a = `
161
175
  isTranslated
162
176
  isEdited
163
177
  createdAt
164
- `, $ = `
178
+ `, C = `
165
179
  query ArticleComments($articleId: ID!, $languageCode: String!) {
166
180
  articleComments(articleId: $articleId, languageCode: $languageCode) {
167
181
  comments {
@@ -179,7 +193,7 @@ const a = `
179
193
  totalCount
180
194
  }
181
195
  }
182
- `, C = `
196
+ `, S = `
183
197
  query GetComment($commentId: ID!, $languageCode: String!) {
184
198
  comment(commentId: $commentId, languageCode: $languageCode) {
185
199
  ${e}
@@ -188,7 +202,7 @@ const a = `
188
202
  }
189
203
  }
190
204
  }
191
- `, S = `
205
+ `, I = `
192
206
  mutation CreateComment($articleId: ID!, $content: String!, $sourceLanguageCode: String!, $parentCommentId: ID) {
193
207
  createComment(articleId: $articleId, content: $content, sourceLanguageCode: $sourceLanguageCode, parentCommentId: $parentCommentId) {
194
208
  success
@@ -198,7 +212,7 @@ const a = `
198
212
  }
199
213
  }
200
214
  }
201
- `, I = `
215
+ `, T = `
202
216
  mutation UpdateComment($commentId: ID!, $content: String!) {
203
217
  updateComment(commentId: $commentId, content: $content) {
204
218
  success
@@ -208,21 +222,21 @@ const a = `
208
222
  }
209
223
  }
210
224
  }
211
- `, T = `
225
+ `, p = `
212
226
  mutation DeleteComment($commentId: ID!) {
213
227
  deleteComment(commentId: $commentId) {
214
228
  success
215
229
  error
216
230
  }
217
231
  }
218
- `, p = `
232
+ `, E = `
219
233
  subscription CommentUpdates($articleId: ID!) {
220
234
  commentUpdates(articleId: $articleId) {
221
235
  type
222
236
  commentId
223
237
  }
224
238
  }
225
- `, E = `
239
+ `, A = `
226
240
  mutation Login($email: String!, $password: String!) {
227
241
  login(email: $email, password: $password) {
228
242
  success
@@ -236,7 +250,7 @@ const a = `
236
250
  error
237
251
  }
238
252
  }
239
- `, A = `
253
+ `, R = `
240
254
  mutation Register($email: String!, $password: String!, $name: String) {
241
255
  register(email: $email, password: $password, name: $name) {
242
256
  success
@@ -244,14 +258,14 @@ const a = `
244
258
  error
245
259
  }
246
260
  }
247
- `, R = `
261
+ `, y = `
248
262
  mutation VerifyEmail($token: String!) {
249
263
  verifyEmail(token: $token) {
250
264
  success
251
265
  error
252
266
  }
253
267
  }
254
- `, y = `
268
+ `, f = `
255
269
  mutation ForgotPassword($email: String!) {
256
270
  forgotPassword(email: $email) {
257
271
  success
@@ -259,14 +273,14 @@ const a = `
259
273
  error
260
274
  }
261
275
  }
262
- `, f = `
276
+ `, N = `
263
277
  mutation ResetPassword($token: String!, $password: String!) {
264
278
  resetPassword(token: $token, password: $password) {
265
279
  success
266
280
  error
267
281
  }
268
282
  }
269
- `, N = `
283
+ `, L = `
270
284
  mutation ResendVerification($email: String!) {
271
285
  resendVerification(email: $email) {
272
286
  success
@@ -274,14 +288,14 @@ const a = `
274
288
  error
275
289
  }
276
290
  }
277
- `, L = `
291
+ `, _ = `
278
292
  mutation ChangePassword($currentPassword: String!, $newPassword: String!) {
279
293
  changePassword(currentPassword: $currentPassword, newPassword: $newPassword) {
280
294
  success
281
295
  error
282
296
  }
283
297
  }
284
- `, _ = `
298
+ `, P = `
285
299
  mutation UpdateMyProfile($name: String, $email: String) {
286
300
  updateMyProfile(name: $name, email: $email) {
287
301
  success
@@ -295,7 +309,7 @@ const a = `
295
309
  error
296
310
  }
297
311
  }
298
- `, P = `
312
+ `, w = `
299
313
  query MyReportSettings {
300
314
  myReportSettings {
301
315
  autoReportErrors
@@ -338,31 +352,32 @@ const a = `
338
352
  `;
339
353
  export {
340
354
  a as ACCESSIBLE_ARTICLES,
341
- l as ACCESSIBLE_TAGS,
355
+ d as ACCESSIBLE_TAGS,
342
356
  i as ARTICLE_ALIAS_TARGET,
343
- $ as ARTICLE_COMMENTS,
344
- u as ARTICLE_TRANSLATIONS,
357
+ C as ARTICLE_COMMENTS,
358
+ g as ARTICLE_TRANSLATIONS,
359
+ r as ARTICLE_VERSION,
345
360
  n as ARTICLE_WITH_TRANSLATION,
346
361
  o as ARTICLE_WITH_TRANSLATION_BY_ID,
347
- L as CHANGE_PASSWORD,
348
- p as COMMENT_UPDATES_SUBSCRIPTION,
349
- S as CREATE_COMMENT,
350
- T as DELETE_COMMENT,
351
- y as FORGOT_PASSWORD,
352
- C as GET_COMMENT,
353
- s as GET_KB_CONTEXT,
354
- g as GET_TRANSLATION,
355
- m as KB_LANGUAGES,
356
- c as KB_NAVIGATION,
357
- d as LOCALIZED_TAGS,
358
- E as LOGIN,
359
- P as MY_REPORT_SETTINGS,
360
- A as REGISTER,
361
- N as RESEND_VERIFICATION,
362
- f as RESET_PASSWORD,
363
- r as SEARCH_KNOWLEDGE_BASE,
364
- I as UPDATE_COMMENT,
365
- _ as UPDATE_MY_PROFILE,
362
+ _ as CHANGE_PASSWORD,
363
+ E as COMMENT_UPDATES_SUBSCRIPTION,
364
+ I as CREATE_COMMENT,
365
+ p as DELETE_COMMENT,
366
+ f as FORGOT_PASSWORD,
367
+ S as GET_COMMENT,
368
+ c as GET_KB_CONTEXT,
369
+ $ as GET_TRANSLATION,
370
+ u as KB_LANGUAGES,
371
+ l as KB_NAVIGATION,
372
+ m as LOCALIZED_TAGS,
373
+ A as LOGIN,
374
+ w as MY_REPORT_SETTINGS,
375
+ R as REGISTER,
376
+ L as RESEND_VERIFICATION,
377
+ N as RESET_PASSWORD,
378
+ s as SEARCH_KNOWLEDGE_BASE,
379
+ T as UPDATE_COMMENT,
380
+ P as UPDATE_MY_PROFILE,
366
381
  M as UPDATE_MY_REPORT_SETTINGS,
367
- R as VERIFY_EMAIL
382
+ y as VERIFY_EMAIL
368
383
  };
@@ -51,6 +51,25 @@ export interface ArticleWithTranslation {
51
51
  contentImagesGeo?: ContentImageGeo[] | null;
52
52
  accessRights: string[];
53
53
  }
54
+ /**
55
+ * A single immutable article version's content, addressed by its STABLE version
56
+ * id. Returned by `client.articles.getVersion`. Generic preview / A/B exposure —
57
+ * the server bypasses publish status, so the fetch requires either an internal
58
+ * token or a valid `previewKey` for this exact versionId. Versions are
59
+ * per-language; `languageCode` is the version's own translation language.
60
+ */
61
+ export interface ArticleVersionContent {
62
+ versionId: string;
63
+ articleId: string;
64
+ filename: string;
65
+ versionNumber: number;
66
+ title: string;
67
+ content: string;
68
+ languageCode: string;
69
+ /** SCHEMA_VERSION the snapshot was authored under (lets consumers detect staleness). */
70
+ schemaVersion: string | null;
71
+ createdAt: string;
72
+ }
54
73
  export interface Tag {
55
74
  id: string;
56
75
  slug: string;
@@ -1,4 +1,4 @@
1
- import { __exports as s } from "../../../../_virtual/index3.js";
1
+ import { __exports as s } from "../../../../_virtual/index2.js";
2
2
  import { __require as v } from "./constants.js";
3
3
  var m;
4
4
  function U() {
@@ -2,7 +2,7 @@ import { defineAsyncComponent as m, defineComponent as u, h as f } from "vue";
2
2
  import { componentMetadata as b } from "../../mdx-schema/dist/metadata/index.js";
3
3
  import { getComponentMetadata as T, getComponentNames as W } from "../../mdx-schema/dist/metadata/index.js";
4
4
  import { prepareProps as g } from "../../mdx-schema/dist/prepareProps.js";
5
- import "../../../_virtual/index2.js";
5
+ import "../../../_virtual/index3.js";
6
6
  const s = "__mdxPreparePropsAppliedFor", C = {
7
7
  Callout: {
8
8
  editor: { icon: "info", color: "#569cd6", borderColor: "#569cd6", bgColor: "rgba(86, 156, 214, 0.08)" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogmcp/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Headless SDK for Knowledge Base blog — core client, Vue composables, Nuxt adapter",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -61,8 +61,8 @@
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
- "@blogmcp/mdx-schema": "^0.1.2",
65
- "@blogmcp/sanitize": "^0.1.2",
64
+ "@blogmcp/mdx-schema": "^0.1.3",
65
+ "@blogmcp/sanitize": "^0.1.3",
66
66
  "marked": "^15.0.7"
67
67
  },
68
68
  "optionalDependencies": {
@@ -10,6 +10,7 @@ import type { KbClientConfig, Fetcher, TokenStorage } from './client-types'
10
10
  import type {
11
11
  Article,
12
12
  ArticleWithTranslation,
13
+ ArticleVersionContent,
13
14
  Tag,
14
15
  LocalizedTag,
15
16
  Language,
@@ -110,6 +111,19 @@ export interface KbClient {
110
111
  resolveAlias(
111
112
  filename: string,
112
113
  ): Promise<{ articleAliasTarget: string | null }>
114
+ /**
115
+ * Fetch ONE article version's content by its STABLE version id, for headless
116
+ * preview / A/B (test-before-publish, multi-variant serving). Bypasses publish
117
+ * status, so the server returns it only to an INTERNAL caller (server client
118
+ * holding the api token) OR a caller passing a valid `previewKey` minted for
119
+ * this exact versionId. Returns `{ articleVersion: null }` when missing or
120
+ * unauthorized. Versions are per-language; the returned `languageCode` is the
121
+ * version's own translation — no language argument is taken.
122
+ */
123
+ getVersion(
124
+ versionId: string,
125
+ opts?: { previewKey?: string },
126
+ ): Promise<{ articleVersion: ArticleVersionContent | null }>
113
127
  }
114
128
  search: {
115
129
  query(params: {
@@ -240,6 +254,8 @@ export function createKbClient(config: KbClientConfig): KbClient {
240
254
  exec(Q.ARTICLE_WITH_TRANSLATION_BY_ID, { id, languageCode }),
241
255
  resolveAlias: (filename) =>
242
256
  exec(Q.ARTICLE_ALIAS_TARGET, { filename }),
257
+ getVersion: (versionId, opts) =>
258
+ exec(Q.ARTICLE_VERSION, { versionId, previewKey: opts?.previewKey ?? null }),
243
259
  },
244
260
  search: {
245
261
  query: (params) => exec(Q.SEARCH_KNOWLEDGE_BASE, params),
package/src/core/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export type {
3
3
  Article,
4
4
  ArticleWithTranslation,
5
+ ArticleVersionContent,
5
6
  MediaGeo,
6
7
  ContentImageGeo,
7
8
  Tag,
@@ -82,6 +82,25 @@ export const ARTICLE_ALIAS_TARGET = `
82
82
  }
83
83
  `
84
84
 
85
+ // Fetch ONE article version's content by its stable version id, for headless
86
+ // preview / A/B. Bypasses publish status, so the server serves it only to an
87
+ // internal caller OR a caller presenting a valid `previewKey` for this versionId.
88
+ export const ARTICLE_VERSION = `
89
+ query ArticleVersion($versionId: ID!, $previewKey: String) {
90
+ articleVersion(versionId: $versionId, previewKey: $previewKey) {
91
+ versionId
92
+ articleId
93
+ filename
94
+ versionNumber
95
+ title
96
+ content
97
+ languageCode
98
+ schemaVersion
99
+ createdAt
100
+ }
101
+ }
102
+ `
103
+
85
104
  // ==================== Search ====================
86
105
 
87
106
  export const SEARCH_KNOWLEDGE_BASE = `
package/src/core/types.ts CHANGED
@@ -57,6 +57,26 @@ export interface ArticleWithTranslation {
57
57
  accessRights: string[]
58
58
  }
59
59
 
60
+ /**
61
+ * A single immutable article version's content, addressed by its STABLE version
62
+ * id. Returned by `client.articles.getVersion`. Generic preview / A/B exposure —
63
+ * the server bypasses publish status, so the fetch requires either an internal
64
+ * token or a valid `previewKey` for this exact versionId. Versions are
65
+ * per-language; `languageCode` is the version's own translation language.
66
+ */
67
+ export interface ArticleVersionContent {
68
+ versionId: string
69
+ articleId: string
70
+ filename: string
71
+ versionNumber: number
72
+ title: string
73
+ content: string
74
+ languageCode: string
75
+ /** SCHEMA_VERSION the snapshot was authored under (lets consumers detect staleness). */
76
+ schemaVersion: string | null
77
+ createdAt: string
78
+ }
79
+
60
80
  // ==================== Tag Types ====================
61
81
 
62
82
  export interface Tag {