@blogmcp/sdk 0.1.0 → 0.1.2

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,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();
@@ -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
+ };
@@ -27,6 +27,15 @@ export interface KbClient {
27
27
  getWithTranslation(filename: string, languageCode: string): Promise<{
28
28
  articleWithTranslation: ArticleWithTranslation | null;
29
29
  }>;
30
+ /**
31
+ * Fetch an article by its IMMUTABLE id (not filename), with the best available
32
+ * translation. Same server-side access gate as `getWithTranslation`. Use when a
33
+ * consumer pins to a specific article that may later be renamed (e.g. a storefront
34
+ * home-page composition keyed by id).
35
+ */
36
+ getWithTranslationById(id: string, languageCode: string): Promise<{
37
+ articleWithTranslationById: ArticleWithTranslation | null;
38
+ }>;
30
39
  /**
31
40
  * Resolve a retired article slug to the article's current slug (no
32
41
  * extension), or null if the slug was never an alias. Backs the blog
@@ -1,4 +1,4 @@
1
- import { UPDATE_MY_PROFILE as i, UPDATE_MY_REPORT_SETTINGS as A, MY_REPORT_SETTINGS as S, CHANGE_PASSWORD as _, RESEND_VERIFICATION as l, RESET_PASSWORD as c, FORGOT_PASSWORD as R, VERIFY_EMAIL as d, REGISTER as I, LOGIN as O, DELETE_COMMENT as C, UPDATE_COMMENT as N, CREATE_COMMENT as L, GET_COMMENT as u, ARTICLE_COMMENTS as h, 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 f, SEARCH_KNOWLEDGE_BASE as D, ARTICLE_ALIAS_TARGET as y, ARTICLE_WITH_TRANSLATION as w, ACCESSIBLE_ARTICLES as B } from "./queries.js";
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
2
  import { createMemoryTokenStorage as k } from "./auth.js";
3
3
  function v() {
4
4
  return async (n, o) => (await fetch(n, {
@@ -21,20 +21,21 @@ async function x(n, o, a) {
21
21
  throw new Error(t.errors[0].message);
22
22
  return t.data;
23
23
  }
24
- function K(n) {
24
+ function Y(n) {
25
25
  const o = n.fetcher || v(), 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(B, e),
32
- getWithTranslation: (e, r) => t(w, { filename: e, languageCode: r }),
31
+ list: (e) => t(w, e),
32
+ getWithTranslation: (e, r) => t(W, { filename: e, languageCode: r }),
33
+ getWithTranslationById: (e, r) => t(B, { id: e, languageCode: r }),
33
34
  resolveAlias: (e) => t(y, { filename: e })
34
35
  },
35
36
  search: {
36
- query: (e) => t(D, e),
37
- getContext: (e, r) => t(f, { query: e, maxChunks: r })
37
+ query: (e) => t(f, e),
38
+ getContext: (e, r) => t(D, { query: e, maxChunks: r })
38
39
  },
39
40
  tags: {
40
41
  list: () => t(P),
@@ -51,32 +52,32 @@ function K(n) {
51
52
  get: (e, r) => t(p, { sourceFilename: e, languageCode: r })
52
53
  },
53
54
  comments: {
54
- list: (e, r) => t(h, { articleId: e, languageCode: r }),
55
- get: (e, r) => t(u, { commentId: e, languageCode: r }),
55
+ list: (e, r) => t(u, { articleId: e, languageCode: r }),
56
+ get: (e, r) => t(h, { commentId: e, languageCode: r }),
56
57
  create: (e) => t(L, e),
57
- update: (e, r) => t(N, { commentId: e, content: r }),
58
- delete: (e) => t(C, { commentId: e })
58
+ update: (e, r) => t(C, { commentId: e, content: r }),
59
+ delete: (e) => t(O, { commentId: e })
59
60
  },
60
61
  auth: {
61
- login: (e, r) => t(O, { email: e, password: r }),
62
- register: (e, r, T) => t(I, { email: e, password: r, name: T }),
63
- verifyEmail: (e) => t(d, { token: e }),
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 }),
64
65
  forgotPassword: (e) => t(R, { email: e }),
65
- resetPassword: (e, r) => t(c, { token: e, password: r }),
66
- resendVerification: (e) => t(l, { email: e }),
66
+ resetPassword: (e, r) => t(l, { token: e, password: r }),
67
+ resendVerification: (e) => t(I, { email: e }),
67
68
  changePassword: (e, r) => t(_, { currentPassword: e, newPassword: r }),
68
- updateProfile: (e) => t(i, {
69
+ updateProfile: (e) => t(A, {
69
70
  name: e.name ?? null,
70
71
  email: e.email ?? null
71
72
  })
72
73
  },
73
74
  reportSettings: {
74
75
  get: () => t(S),
75
- update: (e) => t(A, e)
76
+ update: (e) => t(i, e)
76
77
  },
77
78
  executeGraphQL: t
78
79
  };
79
80
  }
80
81
  export {
81
- K as createKbClient
82
+ Y as createKbClient
82
83
  };
@@ -6,7 +6,8 @@
6
6
  * anyway — we skip the parse step entirely.
7
7
  */
8
8
  export declare const ACCESSIBLE_ARTICLES = "\n query AccessibleArticles($status: String, $tags: [String!], $tagMode: String, $limit: Int, $offset: Int) {\n accessibleKbArticles(status: $status, tags: $tags, tagMode: $tagMode, limit: $limit, offset: $offset) {\n articles {\n id\n filename\n title\n description\n contentType\n status\n publishedAt\n updatedAt\n tags\n featuredImageUrl\n }\n totalCount\n }\n }\n";
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";
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
+ 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";
10
11
  export declare const ARTICLE_ALIAS_TARGET = "\n query ArticleAliasTarget($filename: String!) {\n articleAliasTarget(filename: $filename)\n }\n";
11
12
  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";
12
13
  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";
@@ -1,4 +1,4 @@
1
- const t = `
1
+ const a = `
2
2
  query AccessibleArticles($status: String, $tags: [String!], $tagMode: String, $limit: Int, $offset: Int) {
3
3
  accessibleKbArticles(status: $status, tags: $tags, tagMode: $tagMode, limit: $limit, offset: $offset) {
4
4
  articles {
@@ -16,45 +16,49 @@ const t = `
16
16
  totalCount
17
17
  }
18
18
  }
19
- `, a = `
20
- query ArticleWithTranslation($filename: String!, $languageCode: String!) {
21
- articleWithTranslation(filename: $filename, languageCode: $languageCode) {
22
- id
23
- filename
24
- contentType
25
- status
26
- description
27
- sourceLanguageCode
28
- createdAt
29
- updatedAt
30
- publishedAt
31
- title
32
- content
33
- languageCode
34
- isSource
35
- isFallback
36
- featuredImageUrl
37
- featuredImageGeo {
38
- latitude
39
- longitude
40
- altitude
41
- placeName
42
- }
43
- contentImagesGeo {
44
- url
45
- latitude
46
- longitude
47
- altitude
48
- placeName
49
- }
50
- accessRights
19
+ `, t = `
20
+ id
21
+ filename
22
+ contentType
23
+ status
24
+ description
25
+ sourceLanguageCode
26
+ createdAt
27
+ updatedAt
28
+ publishedAt
29
+ title
30
+ content
31
+ languageCode
32
+ isSource
33
+ isFallback
34
+ featuredImageUrl
35
+ featuredImageGeo {
36
+ latitude
37
+ longitude
38
+ altitude
39
+ placeName
51
40
  }
52
- }
41
+ contentImagesGeo {
42
+ url
43
+ latitude
44
+ longitude
45
+ altitude
46
+ placeName
47
+ }
48
+ accessRights
53
49
  `, n = `
50
+ query ArticleWithTranslation($filename: String!, $languageCode: String!) {
51
+ articleWithTranslation(filename: $filename, languageCode: $languageCode) {${t}}
52
+ }
53
+ `, o = `
54
+ query ArticleWithTranslationById($id: ID!, $languageCode: String!) {
55
+ articleWithTranslationById(id: $id, languageCode: $languageCode) {${t}}
56
+ }
57
+ `, i = `
54
58
  query ArticleAliasTarget($filename: String!) {
55
59
  articleAliasTarget(filename: $filename)
56
60
  }
57
- `, o = `
61
+ `, r = `
58
62
  query SearchKnowledgeBase($query: String!, $tags: [String!], $contentType: String, $limit: Int, $minSimilarity: Float, $searchMode: SearchMode) {
59
63
  searchKnowledgeBase(query: $query, tags: $tags, contentType: $contentType, limit: $limit, minSimilarity: $minSimilarity, searchMode: $searchMode) {
60
64
  articleId
@@ -64,7 +68,7 @@ const t = `
64
68
  similarity
65
69
  }
66
70
  }
67
- `, r = `
71
+ `, s = `
68
72
  query GetKBContext($query: String!, $maxChunks: Int) {
69
73
  getKBContext(query: $query, maxChunks: $maxChunks) {
70
74
  chunks {
@@ -76,11 +80,11 @@ const t = `
76
80
  totalChunks
77
81
  }
78
82
  }
79
- `, i = `
83
+ `, c = `
80
84
  query KbNavigation($scope: String, $locale: String) {
81
85
  kbNavigation(scope: $scope, locale: $locale)
82
86
  }
83
- `, s = `
87
+ `, l = `
84
88
  query AccessibleTags {
85
89
  accessibleKbTags {
86
90
  tags {
@@ -93,7 +97,7 @@ const t = `
93
97
  totalCount
94
98
  }
95
99
  }
96
- `, c = `
100
+ `, d = `
97
101
  query LocalizedTags($languageCode: String!) {
98
102
  localizedTags(languageCode: $languageCode) {
99
103
  id
@@ -106,7 +110,7 @@ const t = `
106
110
  isFallback
107
111
  }
108
112
  }
109
- `, l = `
113
+ `, m = `
110
114
  query KBLanguages {
111
115
  kbLanguages {
112
116
  id
@@ -118,7 +122,7 @@ const t = `
118
122
  sortOrder
119
123
  }
120
124
  }
121
- `, m = `
125
+ `, u = `
122
126
  query ArticleTranslations($sourceFilename: String!) {
123
127
  listArticleTranslations(sourceFilename: $sourceFilename) {
124
128
  id
@@ -129,7 +133,7 @@ const t = `
129
133
  updatedAt
130
134
  }
131
135
  }
132
- `, u = `
136
+ `, g = `
133
137
  query GetTranslation($sourceFilename: String!, $languageCode: String!) {
134
138
  getTranslation(sourceFilename: $sourceFilename, languageCode: $languageCode) {
135
139
  id
@@ -157,7 +161,7 @@ const t = `
157
161
  isTranslated
158
162
  isEdited
159
163
  createdAt
160
- `, d = `
164
+ `, $ = `
161
165
  query ArticleComments($articleId: ID!, $languageCode: String!) {
162
166
  articleComments(articleId: $articleId, languageCode: $languageCode) {
163
167
  comments {
@@ -175,7 +179,7 @@ const t = `
175
179
  totalCount
176
180
  }
177
181
  }
178
- `, g = `
182
+ `, C = `
179
183
  query GetComment($commentId: ID!, $languageCode: String!) {
180
184
  comment(commentId: $commentId, languageCode: $languageCode) {
181
185
  ${e}
@@ -184,7 +188,7 @@ const t = `
184
188
  }
185
189
  }
186
190
  }
187
- `, $ = `
191
+ `, S = `
188
192
  mutation CreateComment($articleId: ID!, $content: String!, $sourceLanguageCode: String!, $parentCommentId: ID) {
189
193
  createComment(articleId: $articleId, content: $content, sourceLanguageCode: $sourceLanguageCode, parentCommentId: $parentCommentId) {
190
194
  success
@@ -194,7 +198,7 @@ const t = `
194
198
  }
195
199
  }
196
200
  }
197
- `, C = `
201
+ `, I = `
198
202
  mutation UpdateComment($commentId: ID!, $content: String!) {
199
203
  updateComment(commentId: $commentId, content: $content) {
200
204
  success
@@ -204,21 +208,21 @@ const t = `
204
208
  }
205
209
  }
206
210
  }
207
- `, S = `
211
+ `, T = `
208
212
  mutation DeleteComment($commentId: ID!) {
209
213
  deleteComment(commentId: $commentId) {
210
214
  success
211
215
  error
212
216
  }
213
217
  }
214
- `, I = `
218
+ `, p = `
215
219
  subscription CommentUpdates($articleId: ID!) {
216
220
  commentUpdates(articleId: $articleId) {
217
221
  type
218
222
  commentId
219
223
  }
220
224
  }
221
- `, p = `
225
+ `, E = `
222
226
  mutation Login($email: String!, $password: String!) {
223
227
  login(email: $email, password: $password) {
224
228
  success
@@ -232,7 +236,7 @@ const t = `
232
236
  error
233
237
  }
234
238
  }
235
- `, T = `
239
+ `, A = `
236
240
  mutation Register($email: String!, $password: String!, $name: String) {
237
241
  register(email: $email, password: $password, name: $name) {
238
242
  success
@@ -240,14 +244,14 @@ const t = `
240
244
  error
241
245
  }
242
246
  }
243
- `, E = `
247
+ `, R = `
244
248
  mutation VerifyEmail($token: String!) {
245
249
  verifyEmail(token: $token) {
246
250
  success
247
251
  error
248
252
  }
249
253
  }
250
- `, A = `
254
+ `, y = `
251
255
  mutation ForgotPassword($email: String!) {
252
256
  forgotPassword(email: $email) {
253
257
  success
@@ -255,14 +259,14 @@ const t = `
255
259
  error
256
260
  }
257
261
  }
258
- `, R = `
262
+ `, f = `
259
263
  mutation ResetPassword($token: String!, $password: String!) {
260
264
  resetPassword(token: $token, password: $password) {
261
265
  success
262
266
  error
263
267
  }
264
268
  }
265
- `, f = `
269
+ `, N = `
266
270
  mutation ResendVerification($email: String!) {
267
271
  resendVerification(email: $email) {
268
272
  success
@@ -270,14 +274,14 @@ const t = `
270
274
  error
271
275
  }
272
276
  }
273
- `, y = `
277
+ `, L = `
274
278
  mutation ChangePassword($currentPassword: String!, $newPassword: String!) {
275
279
  changePassword(currentPassword: $currentPassword, newPassword: $newPassword) {
276
280
  success
277
281
  error
278
282
  }
279
283
  }
280
- `, N = `
284
+ `, _ = `
281
285
  mutation UpdateMyProfile($name: String, $email: String) {
282
286
  updateMyProfile(name: $name, email: $email) {
283
287
  success
@@ -291,7 +295,7 @@ const t = `
291
295
  error
292
296
  }
293
297
  }
294
- `, L = `
298
+ `, P = `
295
299
  query MyReportSettings {
296
300
  myReportSettings {
297
301
  autoReportErrors
@@ -303,7 +307,7 @@ const t = `
303
307
  feedbackNotifications
304
308
  }
305
309
  }
306
- `, P = `
310
+ `, M = `
307
311
  mutation UpdateMyReportSettings(
308
312
  $autoReportErrors: String
309
313
  $autoReportContent: String
@@ -333,31 +337,32 @@ const t = `
333
337
  }
334
338
  `;
335
339
  export {
336
- t as ACCESSIBLE_ARTICLES,
337
- s as ACCESSIBLE_TAGS,
338
- n as ARTICLE_ALIAS_TARGET,
339
- d as ARTICLE_COMMENTS,
340
- m as ARTICLE_TRANSLATIONS,
341
- a as ARTICLE_WITH_TRANSLATION,
342
- y as CHANGE_PASSWORD,
343
- I as COMMENT_UPDATES_SUBSCRIPTION,
344
- $ as CREATE_COMMENT,
345
- S as DELETE_COMMENT,
346
- A as FORGOT_PASSWORD,
347
- g as GET_COMMENT,
348
- r as GET_KB_CONTEXT,
349
- u as GET_TRANSLATION,
350
- l as KB_LANGUAGES,
351
- i as KB_NAVIGATION,
352
- c as LOCALIZED_TAGS,
353
- p as LOGIN,
354
- L as MY_REPORT_SETTINGS,
355
- T as REGISTER,
356
- f as RESEND_VERIFICATION,
357
- R as RESET_PASSWORD,
358
- o as SEARCH_KNOWLEDGE_BASE,
359
- C as UPDATE_COMMENT,
360
- N as UPDATE_MY_PROFILE,
361
- P as UPDATE_MY_REPORT_SETTINGS,
362
- E as VERIFY_EMAIL
340
+ a as ACCESSIBLE_ARTICLES,
341
+ l as ACCESSIBLE_TAGS,
342
+ i as ARTICLE_ALIAS_TARGET,
343
+ $ as ARTICLE_COMMENTS,
344
+ u as ARTICLE_TRANSLATIONS,
345
+ n as ARTICLE_WITH_TRANSLATION,
346
+ 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,
366
+ M as UPDATE_MY_REPORT_SETTINGS,
367
+ R as VERIFY_EMAIL
363
368
  };
@@ -1,4 +1,4 @@
1
- import { __exports as s } from "../../../../_virtual/index2.js";
1
+ import { __exports as s } from "../../../../_virtual/index3.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/index3.js";
5
+ import "../../../_virtual/index2.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)" },
@@ -1,22 +1,54 @@
1
- import i from "../../../node_modules/dompurify/dist/purify.es.js";
2
- let e;
3
- function o() {
4
- if (e)
5
- return e;
1
+ import f from "../../../node_modules/dompurify/dist/purify.es.js";
2
+ let i;
3
+ function u() {
4
+ if (i)
5
+ return i;
6
6
  if (typeof window < "u" && typeof window.document < "u")
7
- e = i;
7
+ i = f;
8
8
  else {
9
9
  const { JSDOM: t } = require("jsdom");
10
- e = i(new t("").window), f(e);
10
+ i = f(new t("").window);
11
11
  }
12
- return e;
12
+ return a(i), m(i), i;
13
13
  }
14
- function f(t) {
15
- t.addHook("afterSanitizeAttributes", (r) => {
16
- r.tagName === "A" && r.getAttribute("target") === "_blank" && r.setAttribute("rel", "noopener noreferrer");
14
+ function a(t) {
15
+ t.addHook("afterSanitizeAttributes", (e) => {
16
+ e.tagName === "A" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
17
17
  });
18
18
  }
19
- const n = {
19
+ const c = /* @__PURE__ */ new Set([
20
+ "width",
21
+ "height",
22
+ "min-width",
23
+ "min-height",
24
+ "max-width",
25
+ "max-height",
26
+ "aspect-ratio",
27
+ "object-fit"
28
+ ]);
29
+ function A(t) {
30
+ return t.length > 0 && t.length <= 40 && /^[a-z0-9.%/\s-]+$/i.test(t) && !/url|expression|\\/i.test(t);
31
+ }
32
+ function S(t) {
33
+ const e = [];
34
+ for (const r of t.split(";")) {
35
+ const n = r.indexOf(":");
36
+ if (n < 0)
37
+ continue;
38
+ const o = r.slice(0, n).trim().toLowerCase(), s = r.slice(n + 1).trim();
39
+ c.has(o) && A(s) && e.push(`${o}:${s}`);
40
+ }
41
+ return e.join(";");
42
+ }
43
+ function m(t) {
44
+ t.addHook("afterSanitizeAttributes", (e) => {
45
+ if (!e.hasAttribute("style"))
46
+ return;
47
+ const r = S(e.getAttribute("style") || "");
48
+ r ? e.setAttribute("style", r) : e.removeAttribute("style");
49
+ });
50
+ }
51
+ const l = {
20
52
  USE_PROFILES: { html: !0 },
21
53
  ADD_ATTR: ["target", "rel"],
22
54
  FORBID_TAGS: ["style", "form", "input", "iframe"],
@@ -24,18 +56,23 @@ const n = {
24
56
  SANITIZE_NAMED_PROPS: !0,
25
57
  ALLOW_DATA_ATTR: !1
26
58
  };
27
- function a(t, r = n) {
28
- return o().sanitize(t, r);
59
+ function p(t, e = l) {
60
+ return u().sanitize(t, e);
29
61
  }
30
62
  ({
31
63
  // Derive from STRICT_CONFIG so its security posture — and any FUTURE hardening (a new
32
64
  // FORBID_TAGS/FORBID_ATTR entry) — propagates to this higher-risk host boundary automatically.
33
65
  // ADD_ATTR is overridden outright (it restates STRICT_CONFIG's target/rel + adds the two
34
- // structural attrs the overlay anchors on) — the one place the two configs intentionally differ.
35
- ...n
66
+ // structural attrs the overlay anchors on). FORBID_ATTR is overridden to DROP `style` from
67
+ // the forbid list (keeping only `formaction`): DOMPurify then lets `style` through, and the
68
+ // shared `installStyleAllowlistHook` narrows it to the SIZING-only allowlist — so a customer
69
+ // renderer's intrinsic sizing (icon width/height) survives, while nothing that can overlay or
70
+ // reflow the contained host does, and customer JS still cannot run. STRICT_CONFIG (blog
71
+ // content) keeps `style` forbidden, so this exception is scoped to the embed host only.
72
+ ...l
36
73
  });
37
74
  export {
38
- n as STRICT_CONFIG,
39
- o as getPurifier,
40
- a as sanitizeHtml
75
+ l as STRICT_CONFIG,
76
+ u as getPurifier,
77
+ p as sanitizeHtml
41
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogmcp/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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.0",
65
- "@blogmcp/sanitize": "^0.1.0",
64
+ "@blogmcp/mdx-schema": "^0.1.2",
65
+ "@blogmcp/sanitize": "^0.1.2",
66
66
  "marked": "^15.0.7"
67
67
  },
68
68
  "optionalDependencies": {
@@ -90,6 +90,18 @@ export interface KbClient {
90
90
  ): Promise<{
91
91
  articleWithTranslation: ArticleWithTranslation | null
92
92
  }>
93
+ /**
94
+ * Fetch an article by its IMMUTABLE id (not filename), with the best available
95
+ * translation. Same server-side access gate as `getWithTranslation`. Use when a
96
+ * consumer pins to a specific article that may later be renamed (e.g. a storefront
97
+ * home-page composition keyed by id).
98
+ */
99
+ getWithTranslationById(
100
+ id: string,
101
+ languageCode: string,
102
+ ): Promise<{
103
+ articleWithTranslationById: ArticleWithTranslation | null
104
+ }>
93
105
  /**
94
106
  * Resolve a retired article slug to the article's current slug (no
95
107
  * extension), or null if the slug was never an alias. Backs the blog
@@ -224,6 +236,8 @@ export function createKbClient(config: KbClientConfig): KbClient {
224
236
  list: (params) => exec(Q.ACCESSIBLE_ARTICLES, params),
225
237
  getWithTranslation: (filename, languageCode) =>
226
238
  exec(Q.ARTICLE_WITH_TRANSLATION, { filename, languageCode }),
239
+ getWithTranslationById: (id, languageCode) =>
240
+ exec(Q.ARTICLE_WITH_TRANSLATION_BY_ID, { id, languageCode }),
227
241
  resolveAlias: (filename) =>
228
242
  exec(Q.ARTICLE_ALIAS_TARGET, { filename }),
229
243
  },
@@ -28,39 +28,51 @@ export const ACCESSIBLE_ARTICLES = `
28
28
  }
29
29
  `
30
30
 
31
+ // Field selection shared by the by-filename and by-id article queries, so both
32
+ // lookups always return the identical ArticleWithTranslation shape.
33
+ const ARTICLE_WITH_TRANSLATION_FIELDS = `
34
+ id
35
+ filename
36
+ contentType
37
+ status
38
+ description
39
+ sourceLanguageCode
40
+ createdAt
41
+ updatedAt
42
+ publishedAt
43
+ title
44
+ content
45
+ languageCode
46
+ isSource
47
+ isFallback
48
+ featuredImageUrl
49
+ featuredImageGeo {
50
+ latitude
51
+ longitude
52
+ altitude
53
+ placeName
54
+ }
55
+ contentImagesGeo {
56
+ url
57
+ latitude
58
+ longitude
59
+ altitude
60
+ placeName
61
+ }
62
+ accessRights
63
+ `
64
+
31
65
  export const ARTICLE_WITH_TRANSLATION = `
32
66
  query ArticleWithTranslation($filename: String!, $languageCode: String!) {
33
- articleWithTranslation(filename: $filename, languageCode: $languageCode) {
34
- id
35
- filename
36
- contentType
37
- status
38
- description
39
- sourceLanguageCode
40
- createdAt
41
- updatedAt
42
- publishedAt
43
- title
44
- content
45
- languageCode
46
- isSource
47
- isFallback
48
- featuredImageUrl
49
- featuredImageGeo {
50
- latitude
51
- longitude
52
- altitude
53
- placeName
54
- }
55
- contentImagesGeo {
56
- url
57
- latitude
58
- longitude
59
- altitude
60
- placeName
61
- }
62
- accessRights
63
- }
67
+ articleWithTranslation(filename: $filename, languageCode: $languageCode) {${ARTICLE_WITH_TRANSLATION_FIELDS}}
68
+ }
69
+ `
70
+
71
+ // By IMMUTABLE id (not filename) — same shape + same server-side access gate. For
72
+ // consumers that pin to a specific article that may be renamed.
73
+ export const ARTICLE_WITH_TRANSLATION_BY_ID = `
74
+ query ArticleWithTranslationById($id: ID!, $languageCode: String!) {
75
+ articleWithTranslationById(id: $id, languageCode: $languageCode) {${ARTICLE_WITH_TRANSLATION_FIELDS}}
64
76
  }
65
77
  `
66
78