@blogmcp/sdk 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/community/links.d.ts +6 -0
- package/dist/community/links.js +9 -1
- package/dist/community/outcome.d.ts +1 -1
- package/dist/community/outcome.js +60 -23
- package/dist/community/private/browser.d.ts +18 -0
- package/dist/community/private/browser.js +17 -0
- package/dist/community/private/client.d.ts +259 -0
- package/dist/community/private/client.js +98 -0
- package/dist/community/private/dm.d.ts +547 -0
- package/dist/community/private/dm.js +852 -0
- package/dist/community/private/dpop.d.ts +59 -0
- package/dist/community/private/dpop.js +46 -0
- package/dist/community/private/encoding.d.ts +17 -0
- package/dist/community/private/encoding.js +50 -0
- package/dist/community/private/host-state.d.ts +20 -0
- package/dist/community/private/host-state.js +15 -0
- package/dist/community/private/index.d.ts +51 -0
- package/dist/community/private/index.js +71 -0
- package/dist/community/private/keystore.d.ts +73 -0
- package/dist/community/private/keystore.js +91 -0
- package/dist/community/private/marker.d.ts +17 -0
- package/dist/community/private/marker.js +11 -0
- package/dist/community/private/private-routes.d.ts +6 -0
- package/dist/community/private/private-routes.js +72 -0
- package/dist/community/private/promise.d.ts +65 -0
- package/dist/community/private/promise.js +39 -0
- package/dist/community/private/realtime.d.ts +127 -0
- package/dist/community/private/realtime.js +199 -0
- package/dist/community/private/session.d.ts +175 -0
- package/dist/community/private/session.js +441 -0
- package/dist/community/private/transport.d.ts +47 -0
- package/dist/community/private/transport.js +65 -0
- package/dist/community/server/grant-handoff.d.ts +53 -0
- package/dist/community/server/grant-handoff.js +96 -0
- package/dist/community/server/grant.d.ts +100 -0
- package/dist/community/server/grant.js +165 -0
- package/dist/community/server/index.d.ts +4 -0
- package/dist/community/server/index.js +20 -16
- package/dist/community/shapes.d.ts +27 -1
- package/dist/community/shapes.js +27 -17
- package/dist/core/client.d.ts +9 -0
- package/dist/core/client.js +54 -50
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +113 -103
- package/dist/core/queries.d.ts +1 -0
- package/dist/core/queries.js +76 -71
- package/dist/core/review/types.d.ts +7 -0
- package/dist/core/style-layers.d.ts +88 -0
- package/dist/core/style-layers.js +69 -0
- package/package.json +7 -3
- package/src/community/links.ts +8 -0
- package/src/community/outcome.ts +37 -0
- package/src/community/private/browser.ts +31 -0
- package/src/community/private/client.ts +304 -0
- package/src/community/private/dm.ts +1687 -0
- package/src/community/private/dpop.ts +110 -0
- package/src/community/private/encoding.ts +71 -0
- package/src/community/private/host-state.ts +37 -0
- package/src/community/private/index.ts +169 -0
- package/src/community/private/keystore.ts +179 -0
- package/src/community/private/marker.ts +28 -0
- package/src/community/private/private-routes.ts +80 -0
- package/src/community/private/promise.ts +125 -0
- package/src/community/private/realtime.ts +431 -0
- package/src/community/private/session.ts +848 -0
- package/src/community/private/transport.ts +125 -0
- package/src/community/server/grant-handoff.ts +179 -0
- package/src/community/server/grant.ts +292 -0
- package/src/community/server/index.ts +6 -0
- package/src/community/shapes.ts +46 -1
- package/src/core/client.ts +12 -0
- package/src/core/index.ts +14 -0
- package/src/core/queries.ts +8 -0
- package/src/core/review/types.ts +8 -0
- package/src/core/style-layers.ts +169 -0
package/dist/core/queries.js
CHANGED
|
@@ -78,7 +78,7 @@ const s = `
|
|
|
78
78
|
totalCount
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
`,
|
|
81
|
+
`, a = `
|
|
82
82
|
id
|
|
83
83
|
filename
|
|
84
84
|
contentType
|
|
@@ -116,13 +116,13 @@ const s = `
|
|
|
116
116
|
accessRights
|
|
117
117
|
`, c = `
|
|
118
118
|
query ArticleWithTranslation($filename: String!, $languageCode: String!) {
|
|
119
|
-
articleWithTranslation(filename: $filename, languageCode: $languageCode) {${
|
|
119
|
+
articleWithTranslation(filename: $filename, languageCode: $languageCode) {${a}}
|
|
120
120
|
}
|
|
121
121
|
`, u = `
|
|
122
122
|
query ArticleWithTranslationById($id: ID!, $languageCode: String!) {
|
|
123
|
-
articleWithTranslationById(id: $id, languageCode: $languageCode) {${
|
|
123
|
+
articleWithTranslationById(id: $id, languageCode: $languageCode) {${a}}
|
|
124
124
|
}
|
|
125
|
-
`,
|
|
125
|
+
`, o = `
|
|
126
126
|
id
|
|
127
127
|
filename
|
|
128
128
|
title
|
|
@@ -136,11 +136,11 @@ const s = `
|
|
|
136
136
|
excerpt
|
|
137
137
|
`, d = `
|
|
138
138
|
query ArticlePreview($filename: String!, $languageCode: String!) {
|
|
139
|
-
articlePreview(filename: $filename, languageCode: $languageCode) {${
|
|
139
|
+
articlePreview(filename: $filename, languageCode: $languageCode) {${o}}
|
|
140
140
|
}
|
|
141
141
|
`, g = `
|
|
142
142
|
query ArticlePreviewById($id: ID!, $languageCode: String!) {
|
|
143
|
-
articlePreviewById(id: $id, languageCode: $languageCode) {${
|
|
143
|
+
articlePreviewById(id: $id, languageCode: $languageCode) {${o}}
|
|
144
144
|
}
|
|
145
145
|
`, $ = `
|
|
146
146
|
query ArticleAliasTarget($filename: String!) {
|
|
@@ -187,6 +187,10 @@ const s = `
|
|
|
187
187
|
kbNavigation(scope: $scope, locale: $locale)
|
|
188
188
|
}
|
|
189
189
|
`, T = `
|
|
190
|
+
query KbStyleLayers {
|
|
191
|
+
kbStyleLayers
|
|
192
|
+
}
|
|
193
|
+
`, A = `
|
|
190
194
|
query AccessibleTags {
|
|
191
195
|
accessibleKbTags {
|
|
192
196
|
tags {
|
|
@@ -199,7 +203,7 @@ const s = `
|
|
|
199
203
|
totalCount
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
|
-
`,
|
|
206
|
+
`, E = `
|
|
203
207
|
query LocalizedTags($languageCode: String!) {
|
|
204
208
|
localizedTags(languageCode: $languageCode) {
|
|
205
209
|
id
|
|
@@ -212,7 +216,7 @@ const s = `
|
|
|
212
216
|
isFallback
|
|
213
217
|
}
|
|
214
218
|
}
|
|
215
|
-
`,
|
|
219
|
+
`, y = `
|
|
216
220
|
query KBLanguages {
|
|
217
221
|
kbLanguages {
|
|
218
222
|
id
|
|
@@ -224,7 +228,7 @@ const s = `
|
|
|
224
228
|
sortOrder
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
|
-
`,
|
|
231
|
+
`, _ = `
|
|
228
232
|
query ArticleTranslations($articleId: ID!) {
|
|
229
233
|
listArticleTranslations(articleId: $articleId) {
|
|
230
234
|
id
|
|
@@ -235,7 +239,7 @@ const s = `
|
|
|
235
239
|
updatedAt
|
|
236
240
|
}
|
|
237
241
|
}
|
|
238
|
-
`,
|
|
242
|
+
`, p = `
|
|
239
243
|
query GetTranslation($sourceFilename: String!, $languageCode: String!) {
|
|
240
244
|
getTranslation(sourceFilename: $sourceFilename, languageCode: $languageCode) {
|
|
241
245
|
id
|
|
@@ -263,7 +267,7 @@ const s = `
|
|
|
263
267
|
isTranslated
|
|
264
268
|
isEdited
|
|
265
269
|
createdAt
|
|
266
|
-
`,
|
|
270
|
+
`, L = `
|
|
267
271
|
query ArticleComments($articleId: ID!, $languageCode: String!) {
|
|
268
272
|
articleComments(articleId: $articleId, languageCode: $languageCode) {
|
|
269
273
|
comments {
|
|
@@ -290,7 +294,7 @@ const s = `
|
|
|
290
294
|
}
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
|
-
`,
|
|
297
|
+
`, R = `
|
|
294
298
|
mutation CreateComment($articleId: ID!, $content: String!, $sourceLanguageCode: String!, $parentCommentId: ID) {
|
|
295
299
|
createComment(articleId: $articleId, content: $content, sourceLanguageCode: $sourceLanguageCode, parentCommentId: $parentCommentId) {
|
|
296
300
|
success
|
|
@@ -300,7 +304,7 @@ const s = `
|
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
306
|
}
|
|
303
|
-
`,
|
|
307
|
+
`, f = `
|
|
304
308
|
mutation UpdateComment($commentId: ID!, $content: String!) {
|
|
305
309
|
updateComment(commentId: $commentId, content: $content) {
|
|
306
310
|
success
|
|
@@ -310,21 +314,21 @@ const s = `
|
|
|
310
314
|
}
|
|
311
315
|
}
|
|
312
316
|
}
|
|
313
|
-
`,
|
|
317
|
+
`, O = `
|
|
314
318
|
mutation DeleteComment($commentId: ID!) {
|
|
315
319
|
deleteComment(commentId: $commentId) {
|
|
316
320
|
success
|
|
317
321
|
error
|
|
318
322
|
}
|
|
319
323
|
}
|
|
320
|
-
`,
|
|
324
|
+
`, M = `
|
|
321
325
|
subscription CommentUpdates($articleId: ID!) {
|
|
322
326
|
commentUpdates(articleId: $articleId) {
|
|
323
327
|
type
|
|
324
328
|
commentId
|
|
325
329
|
}
|
|
326
330
|
}
|
|
327
|
-
`,
|
|
331
|
+
`, b = `
|
|
328
332
|
mutation Login($email: String!, $password: String!) {
|
|
329
333
|
login(email: $email, password: $password) {
|
|
330
334
|
success
|
|
@@ -338,7 +342,7 @@ const s = `
|
|
|
338
342
|
error
|
|
339
343
|
}
|
|
340
344
|
}
|
|
341
|
-
`,
|
|
345
|
+
`, P = `
|
|
342
346
|
mutation Register($email: String!, $password: String!, $name: String) {
|
|
343
347
|
register(email: $email, password: $password, name: $name) {
|
|
344
348
|
success
|
|
@@ -346,14 +350,14 @@ const s = `
|
|
|
346
350
|
error
|
|
347
351
|
}
|
|
348
352
|
}
|
|
349
|
-
`,
|
|
353
|
+
`, U = `
|
|
350
354
|
mutation VerifyEmail($token: String!) {
|
|
351
355
|
verifyEmail(token: $token) {
|
|
352
356
|
success
|
|
353
357
|
error
|
|
354
358
|
}
|
|
355
359
|
}
|
|
356
|
-
`,
|
|
360
|
+
`, q = `
|
|
357
361
|
mutation ForgotPassword($email: String!) {
|
|
358
362
|
forgotPassword(email: $email) {
|
|
359
363
|
success
|
|
@@ -368,7 +372,7 @@ const s = `
|
|
|
368
372
|
error
|
|
369
373
|
}
|
|
370
374
|
}
|
|
371
|
-
`,
|
|
375
|
+
`, D = `
|
|
372
376
|
mutation ResendVerification($email: String!) {
|
|
373
377
|
resendVerification(email: $email) {
|
|
374
378
|
success
|
|
@@ -376,7 +380,7 @@ const s = `
|
|
|
376
380
|
error
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
|
-
`,
|
|
383
|
+
`, k = `
|
|
380
384
|
mutation ChangePassword($currentPassword: String!, $newPassword: String!) {
|
|
381
385
|
changePassword(currentPassword: $currentPassword, newPassword: $newPassword) {
|
|
382
386
|
success
|
|
@@ -397,7 +401,7 @@ const s = `
|
|
|
397
401
|
error
|
|
398
402
|
}
|
|
399
403
|
}
|
|
400
|
-
`,
|
|
404
|
+
`, B = `
|
|
401
405
|
query MyReportSettings {
|
|
402
406
|
myReportSettings {
|
|
403
407
|
autoReportErrors
|
|
@@ -409,7 +413,7 @@ const s = `
|
|
|
409
413
|
feedbackNotifications
|
|
410
414
|
}
|
|
411
415
|
}
|
|
412
|
-
`,
|
|
416
|
+
`, v = `
|
|
413
417
|
mutation UpdateMyReportSettings(
|
|
414
418
|
$autoReportErrors: String
|
|
415
419
|
$autoReportContent: String
|
|
@@ -457,7 +461,7 @@ const s = `
|
|
|
457
461
|
error
|
|
458
462
|
duplicate
|
|
459
463
|
consultation {${n}}
|
|
460
|
-
`,
|
|
464
|
+
`, G = `
|
|
461
465
|
query ConsultationPublicConfig($locale: String!) {
|
|
462
466
|
consultationPublicConfig(locale: $locale) {
|
|
463
467
|
enabled
|
|
@@ -475,7 +479,7 @@ const s = `
|
|
|
475
479
|
}
|
|
476
480
|
}
|
|
477
481
|
}
|
|
478
|
-
`,
|
|
482
|
+
`, K = `
|
|
479
483
|
query MyConsultations($limit: Int, $offset: Int) {
|
|
480
484
|
myConsultations(limit: $limit, offset: $offset) {
|
|
481
485
|
id
|
|
@@ -485,23 +489,23 @@ const s = `
|
|
|
485
489
|
messageCount
|
|
486
490
|
}
|
|
487
491
|
}
|
|
488
|
-
`,
|
|
492
|
+
`, W = `
|
|
489
493
|
query MyConsultation($id: ID!) {
|
|
490
494
|
myConsultation(id: $id) {${n}}
|
|
491
495
|
}
|
|
492
|
-
`,
|
|
496
|
+
`, x = `
|
|
493
497
|
mutation CreateMyConsultation($input: CreateMyConsultationInput!) {
|
|
494
498
|
createMyConsultation(input: $input) {${t}}
|
|
495
499
|
}
|
|
496
|
-
`,
|
|
500
|
+
`, F = `
|
|
497
501
|
mutation PostMyConsultationMessage($consultationId: ID!, $body: String!, $clientRequestId: String!) {
|
|
498
502
|
postMyConsultationMessage(consultationId: $consultationId, body: $body, clientRequestId: $clientRequestId) {${t}}
|
|
499
503
|
}
|
|
500
|
-
`,
|
|
504
|
+
`, Y = `
|
|
501
505
|
mutation RequestMyConsultationErasure($consultationId: ID!) {
|
|
502
506
|
requestMyConsultationErasure(consultationId: $consultationId) {${t}}
|
|
503
507
|
}
|
|
504
|
-
`,
|
|
508
|
+
`, H = `
|
|
505
509
|
query MyConsultationConsent($locale: String!) {
|
|
506
510
|
myConsultationConsent(locale: $locale) {
|
|
507
511
|
mode
|
|
@@ -517,7 +521,7 @@ const s = `
|
|
|
517
521
|
}
|
|
518
522
|
}
|
|
519
523
|
}
|
|
520
|
-
`,
|
|
524
|
+
`, V = `
|
|
521
525
|
mutation WithdrawMyConsultationConsent {
|
|
522
526
|
withdrawMyConsultationConsent {
|
|
523
527
|
success
|
|
@@ -526,7 +530,7 @@ const s = `
|
|
|
526
530
|
threadsClosed
|
|
527
531
|
}
|
|
528
532
|
}
|
|
529
|
-
`,
|
|
533
|
+
`, z = `
|
|
530
534
|
mutation ExchangeConsultationLink($token: String!) {
|
|
531
535
|
exchangeConsultationLink(token: $token) {
|
|
532
536
|
success
|
|
@@ -537,27 +541,27 @@ const s = `
|
|
|
537
541
|
consultation {${n}}
|
|
538
542
|
}
|
|
539
543
|
}
|
|
540
|
-
`,
|
|
544
|
+
`, Q = `
|
|
541
545
|
query ConsultationBySession($session: String!) {
|
|
542
546
|
consultationBySession(session: $session) {${n}}
|
|
543
547
|
}
|
|
544
|
-
`,
|
|
548
|
+
`, Z = `
|
|
545
549
|
mutation PostConsultationMessageBySession($session: String!, $body: String!, $clientRequestId: String!) {
|
|
546
550
|
postConsultationMessageBySession(session: $session, body: $body, clientRequestId: $clientRequestId) {${t}}
|
|
547
551
|
}
|
|
548
|
-
`,
|
|
552
|
+
`, X = `
|
|
549
553
|
mutation RequestConsultationErasureBySession($session: String!) {
|
|
550
554
|
requestConsultationErasureBySession(session: $session) {${t}}
|
|
551
555
|
}
|
|
552
|
-
`,
|
|
556
|
+
`, j = `
|
|
553
557
|
mutation CloseConsultationSession($session: String!) {
|
|
554
558
|
closeConsultationSession(session: $session) {${t}}
|
|
555
559
|
}
|
|
556
|
-
`,
|
|
560
|
+
`, J = `
|
|
557
561
|
mutation AttachConsultationToMyAccount($session: String!) {
|
|
558
562
|
attachConsultationToMyAccount(session: $session) {${t}}
|
|
559
563
|
}
|
|
560
|
-
`,
|
|
564
|
+
`, ee = `
|
|
561
565
|
mutation RequestConsultationLink($email: String!) {
|
|
562
566
|
requestConsultationLink(email: $email)
|
|
563
567
|
}
|
|
@@ -567,49 +571,50 @@ export {
|
|
|
567
571
|
r as ACCESSIBLE_ARTICLES_LOCALIZED,
|
|
568
572
|
i as ACCESSIBLE_ARTICLES_WITH_LOCKED,
|
|
569
573
|
l as ACCESSIBLE_ARTICLES_WITH_LOCKED_LOCALIZED,
|
|
570
|
-
|
|
574
|
+
A as ACCESSIBLE_TAGS,
|
|
571
575
|
$ as ARTICLE_ALIAS_TARGET,
|
|
572
|
-
|
|
576
|
+
L as ARTICLE_COMMENTS,
|
|
573
577
|
d as ARTICLE_PREVIEW,
|
|
574
578
|
g as ARTICLE_PREVIEW_BY_ID,
|
|
575
|
-
|
|
579
|
+
_ as ARTICLE_TRANSLATIONS,
|
|
576
580
|
m as ARTICLE_VERSION,
|
|
577
581
|
c as ARTICLE_WITH_TRANSLATION,
|
|
578
582
|
u as ARTICLE_WITH_TRANSLATION_BY_ID,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
583
|
+
J as ATTACH_CONSULTATION_TO_MY_ACCOUNT,
|
|
584
|
+
k as CHANGE_PASSWORD,
|
|
585
|
+
j as CLOSE_CONSULTATION_SESSION,
|
|
586
|
+
M as COMMENT_UPDATES_SUBSCRIPTION,
|
|
587
|
+
Q as CONSULTATION_BY_SESSION,
|
|
588
|
+
G as CONSULTATION_PUBLIC_CONFIG,
|
|
589
|
+
R as CREATE_COMMENT,
|
|
590
|
+
x as CREATE_MY_CONSULTATION,
|
|
591
|
+
O as DELETE_COMMENT,
|
|
592
|
+
z as EXCHANGE_CONSULTATION_LINK,
|
|
593
|
+
q as FORGOT_PASSWORD,
|
|
590
594
|
N as GET_COMMENT,
|
|
591
595
|
S as GET_KB_CONTEXT,
|
|
592
|
-
|
|
593
|
-
|
|
596
|
+
p as GET_TRANSLATION,
|
|
597
|
+
y as KB_LANGUAGES,
|
|
594
598
|
I as KB_NAVIGATION,
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
599
|
+
T as KB_STYLE_LAYERS,
|
|
600
|
+
E as LOCALIZED_TAGS,
|
|
601
|
+
b as LOGIN,
|
|
602
|
+
W as MY_CONSULTATION,
|
|
603
|
+
K as MY_CONSULTATIONS,
|
|
604
|
+
H as MY_CONSULTATION_CONSENT,
|
|
605
|
+
B as MY_REPORT_SETTINGS,
|
|
606
|
+
Z as POST_CONSULTATION_MESSAGE_BY_SESSION,
|
|
607
|
+
F as POST_MY_CONSULTATION_MESSAGE,
|
|
608
|
+
P as REGISTER,
|
|
609
|
+
X as REQUEST_CONSULTATION_ERASURE_BY_SESSION,
|
|
610
|
+
ee as REQUEST_CONSULTATION_LINK,
|
|
611
|
+
Y as REQUEST_MY_CONSULTATION_ERASURE,
|
|
612
|
+
D as RESEND_VERIFICATION,
|
|
608
613
|
h as RESET_PASSWORD,
|
|
609
614
|
C as SEARCH_KNOWLEDGE_BASE,
|
|
610
|
-
|
|
615
|
+
f as UPDATE_COMMENT,
|
|
611
616
|
w as UPDATE_MY_PROFILE,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
617
|
+
v as UPDATE_MY_REPORT_SETTINGS,
|
|
618
|
+
U as VERIFY_EMAIL,
|
|
619
|
+
V as WITHDRAW_MY_CONSULTATION_CONSENT
|
|
615
620
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* your frontend"). Dependency-free: shared by the page (through `@blogmcp/review`)
|
|
4
4
|
* and by server code that formats a review for the agent.
|
|
5
5
|
*/
|
|
6
|
+
import type { StyleLayer } from '../style-layers.js';
|
|
6
7
|
/** The route a site serves the review page on; `{token}` is the link's token. */
|
|
7
8
|
export declare const REVIEW_PAGE_PATH = "/preview/review/{token}";
|
|
8
9
|
/** Express-style pattern of the same route. */
|
|
@@ -83,6 +84,12 @@ export interface ReviewSession {
|
|
|
83
84
|
article: ReviewArticle;
|
|
84
85
|
/** Media the working copy references, keyed by slug (signed URLs for non-public ones). */
|
|
85
86
|
media: Record<string, ReviewMediaItem>;
|
|
87
|
+
/**
|
|
88
|
+
* Style-layer versions this link pins: on the review page a pinned version stands in for the
|
|
89
|
+
* published version of its layer (`mergePinnedLayers`). Absent from a knowledge base older than
|
|
90
|
+
* style layers; read it with `parseStyleLayers`, which takes that as an empty list.
|
|
91
|
+
*/
|
|
92
|
+
styleLayers?: StyleLayer[];
|
|
86
93
|
}
|
|
87
94
|
export interface ReviewState {
|
|
88
95
|
status: 'open';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style layers: named CSS a tenant keeps in the knowledge base and its site applies ON TOP of the
|
|
3
|
+
* design that ships in the site's code — a token, a campaign accent, the print layout of one kind
|
|
4
|
+
* of article — without a deploy of the site.
|
|
5
|
+
*
|
|
6
|
+
* The knowledge base validates a layer when it is saved and hands a site CSS in which every
|
|
7
|
+
* selector already lives under a placeholder scope root (`LAYER_SCOPE_TOKEN`). A site decides what
|
|
8
|
+
* that root is on its pages and substitutes it — a plain string replace, so no site needs a CSS
|
|
9
|
+
* parser:
|
|
10
|
+
*
|
|
11
|
+
* const layers = await client.styleLayers.list() // published, in order
|
|
12
|
+
* for (const layer of matchLayers(layers, { articleSlug })) {
|
|
13
|
+
* const css = layerStyleText(layer, layerScope('.my-article-root', layer.match))
|
|
14
|
+
* if (css) render(<style data-kb-layer={layer.name}>{css}</style>) // after your own stylesheets
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* Three rules for a site:
|
|
18
|
+
* - render the layers AFTER its own stylesheets, in the order given (a later layer wins);
|
|
19
|
+
* - with no layer, render nothing; a failure to read the layers renders the page without them;
|
|
20
|
+
* - choose a scope root that leaves out what a layer must never restyle (a checkout, an account,
|
|
21
|
+
* a consent dialog). A layer cannot reach outside the root it is given.
|
|
22
|
+
*
|
|
23
|
+
* Pure and dependency-free: safe in a browser bundle, on a server and in a test.
|
|
24
|
+
*/
|
|
25
|
+
/** The scope root in the CSS the knowledge base serves. A type selector no element has. */
|
|
26
|
+
export declare const LAYER_SCOPE_TOKEN = "__KB_LAYER_SCOPE__";
|
|
27
|
+
/** What a layer applies to. `value` is an article slug (the filename without `.mdx`) or its start. */
|
|
28
|
+
export type StyleLayerMatch = {
|
|
29
|
+
kind: 'site';
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'article_prefix';
|
|
32
|
+
value: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'article';
|
|
35
|
+
value: string;
|
|
36
|
+
};
|
|
37
|
+
/** One version of a layer as a site receives it. */
|
|
38
|
+
export interface StyleLayer {
|
|
39
|
+
name: string;
|
|
40
|
+
match: StyleLayerMatch;
|
|
41
|
+
/** Layers apply in ascending position, ties by name. */
|
|
42
|
+
position: number;
|
|
43
|
+
version: number;
|
|
44
|
+
versionId: string;
|
|
45
|
+
/** Validated CSS with `LAYER_SCOPE_TOKEN` where the scope root goes. */
|
|
46
|
+
css: string;
|
|
47
|
+
}
|
|
48
|
+
/** The order layers apply in: ascending position, ties by name. Returns a new array. */
|
|
49
|
+
export declare function sortStyleLayers<T extends Pick<StyleLayer, 'position' | 'name'>>(layers: readonly T[]): T[];
|
|
50
|
+
/**
|
|
51
|
+
* The layers of an API answer — the `kbStyleLayers` field, a review session's `styleLayers`, or the
|
|
52
|
+
* REST list — as a sorted list. An entry that is not a layer is dropped, never thrown on: what a
|
|
53
|
+
* site does with a bad answer is render without it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseStyleLayers(payload: unknown): StyleLayer[];
|
|
56
|
+
/** Whether a layer applies to a page: a `site` layer always, an article layer by the page's article slug. */
|
|
57
|
+
export declare function layerMatches(match: StyleLayerMatch, page: {
|
|
58
|
+
articleSlug?: string | null;
|
|
59
|
+
}): boolean;
|
|
60
|
+
/** The layers that apply to a page, in order. */
|
|
61
|
+
export declare function matchLayers(layers: readonly StyleLayer[], page: {
|
|
62
|
+
articleSlug?: string | null;
|
|
63
|
+
}): StyleLayer[];
|
|
64
|
+
/**
|
|
65
|
+
* The layers of a review page: a version the review link pins stands in for the published version
|
|
66
|
+
* of the same layer, and a pinned layer that is not published is added. In order.
|
|
67
|
+
*/
|
|
68
|
+
export declare function mergePinnedLayers(published: readonly StyleLayer[], pinned: readonly StyleLayer[]): StyleLayer[];
|
|
69
|
+
/**
|
|
70
|
+
* The scope root of a layer on a site that marks an article's root element with its slug
|
|
71
|
+
* (`<div class="article" data-article="my-slug">`): `base` for a `site` layer, `base[attr="slug"]`
|
|
72
|
+
* for an article, `base[attr^="prefix"]` for an article prefix. `base` is the selector of the
|
|
73
|
+
* element that carries the attribute.
|
|
74
|
+
*/
|
|
75
|
+
export declare function layerScope(base: string, match: StyleLayerMatch, attribute?: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* The layer's CSS with the site's scope root in place of the placeholder.
|
|
78
|
+
*
|
|
79
|
+
* @throws TypeError when `scope` is not one selector (a list would scope only its last part).
|
|
80
|
+
*/
|
|
81
|
+
export declare function applyLayerScope(css: string, scope: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The text of a layer's `<style>` element, or null when the layer must not be rendered: an empty
|
|
84
|
+
* layer, a scope that is not one selector, or CSS holding `</` or `<!--`. The knowledge base
|
|
85
|
+
* refuses those sequences when a layer is saved; this is the same check at the last step before
|
|
86
|
+
* the text goes into a page, where a `</style` would end the element.
|
|
87
|
+
*/
|
|
88
|
+
export declare function layerStyleText(layer: Pick<StyleLayer, 'css'>, scope: string): string | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const o = "__KB_LAYER_SCOPE__", a = /^[a-z][a-z0-9-]{0,62}$/, c = /^[a-z0-9][a-z0-9-]{0,199}$/, u = /[,{}<;]|\/\*|^\s*$/;
|
|
2
|
+
function l(t) {
|
|
3
|
+
if (!t || typeof t != "object") return null;
|
|
4
|
+
const { kind: e, value: r } = t;
|
|
5
|
+
return e === "site" ? { kind: "site" } : (e === "article" || e === "article_prefix") && typeof r == "string" && c.test(r) ? { kind: e, value: r } : null;
|
|
6
|
+
}
|
|
7
|
+
function f(t) {
|
|
8
|
+
if (!t || typeof t != "object") return null;
|
|
9
|
+
const e = t, r = l(e.match);
|
|
10
|
+
return typeof e.name != "string" || !a.test(e.name) || !r || typeof e.css != "string" || typeof e.version != "number" || typeof e.versionId != "string" ? null : {
|
|
11
|
+
name: e.name,
|
|
12
|
+
match: r,
|
|
13
|
+
position: typeof e.position == "number" && Number.isFinite(e.position) ? e.position : 0,
|
|
14
|
+
version: e.version,
|
|
15
|
+
versionId: e.versionId,
|
|
16
|
+
css: e.css
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function i(t) {
|
|
20
|
+
return [...t].sort((e, r) => e.position - r.position || (e.name < r.name ? -1 : e.name > r.name ? 1 : 0));
|
|
21
|
+
}
|
|
22
|
+
function m(t) {
|
|
23
|
+
const e = Array.isArray(t) ? t : t && typeof t == "object" && Array.isArray(t.layers) ? t.layers : [], r = [];
|
|
24
|
+
for (const n of e) {
|
|
25
|
+
const s = f(n);
|
|
26
|
+
s && r.push(s);
|
|
27
|
+
}
|
|
28
|
+
return i(r);
|
|
29
|
+
}
|
|
30
|
+
function y(t, e) {
|
|
31
|
+
if (t.kind === "site") return !0;
|
|
32
|
+
const r = e.articleSlug;
|
|
33
|
+
return r ? t.kind === "article" ? r === t.value : r.startsWith(t.value) : !1;
|
|
34
|
+
}
|
|
35
|
+
function _(t, e) {
|
|
36
|
+
return i(t.filter((r) => y(r.match, e)));
|
|
37
|
+
}
|
|
38
|
+
function E(t, e) {
|
|
39
|
+
const r = new Set(e.map((n) => n.name));
|
|
40
|
+
return i([...t.filter((n) => !r.has(n.name)), ...e]);
|
|
41
|
+
}
|
|
42
|
+
function S(t, e, r = "data-article") {
|
|
43
|
+
return e.kind === "site" ? t : `${t}[${r}${e.kind === "article" ? "=" : "^="}"${e.value}"]`;
|
|
44
|
+
}
|
|
45
|
+
function p(t, e) {
|
|
46
|
+
if (typeof e != "string" || u.test(e))
|
|
47
|
+
throw new TypeError('applyLayerScope: the scope must be one selector, e.g. ".article" or ".article[data-article=\\"x\\"]"');
|
|
48
|
+
return t.split(o).join(e.trim());
|
|
49
|
+
}
|
|
50
|
+
function g(t, e) {
|
|
51
|
+
const r = t.css;
|
|
52
|
+
if (typeof r != "string" || r.trim() === "" || r.includes("</") || r.includes("<!--")) return null;
|
|
53
|
+
try {
|
|
54
|
+
return p(r, e);
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
o as LAYER_SCOPE_TOKEN,
|
|
61
|
+
p as applyLayerScope,
|
|
62
|
+
y as layerMatches,
|
|
63
|
+
S as layerScope,
|
|
64
|
+
g as layerStyleText,
|
|
65
|
+
_ as matchLayers,
|
|
66
|
+
E as mergePinnedLayers,
|
|
67
|
+
m as parseStyleLayers,
|
|
68
|
+
i as sortStyleLayers
|
|
69
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blogmcp/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Headless SDK for Knowledge Base blog — core client, Vue composables, Nuxt adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
"./community/realtime": {
|
|
60
60
|
"types": "./dist/community/realtime/index.d.ts",
|
|
61
61
|
"import": "./dist/community/realtime/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./community/private": {
|
|
64
|
+
"types": "./dist/community/private/index.d.ts",
|
|
65
|
+
"import": "./dist/community/private/index.js"
|
|
62
66
|
}
|
|
63
67
|
},
|
|
64
68
|
"main": "./dist/core/index.js",
|
|
@@ -98,8 +102,8 @@
|
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
"dependencies": {
|
|
101
|
-
"@blogmcp/mdx-schema": "^0.
|
|
102
|
-
"@blogmcp/sanitize": "^0.
|
|
105
|
+
"@blogmcp/mdx-schema": "^0.14.0",
|
|
106
|
+
"@blogmcp/sanitize": "^0.14.0",
|
|
103
107
|
"marked": "^15.0.7"
|
|
104
108
|
},
|
|
105
109
|
"optionalDependencies": {
|
package/src/community/links.ts
CHANGED
|
@@ -62,6 +62,14 @@ export const COMMUNITY_ROUTES = Object.freeze({
|
|
|
62
62
|
topic: '/community/t/{id}',
|
|
63
63
|
/** The forum's search. */
|
|
64
64
|
search: '/community/search',
|
|
65
|
+
// M4 PU1 (m4-contracts.md §6.1, A.2): the private view and the two grant routes the host's server serves. The
|
|
66
|
+
// storefront names its own (`/komunita/zpravy`, `/komunita/grant`, `/komunita/grant/handoff`).
|
|
67
|
+
/** The private view (the dock's „Soukromé zprávy"), client-only. */
|
|
68
|
+
messages: '/community/messages',
|
|
69
|
+
/** The grant route (POST, `createPrivateGrantHandler`): the page's private SDK posts its key's thumbprint. */
|
|
70
|
+
grant: '/community/grant',
|
|
71
|
+
/** The provider_page hand-off (GET, `createPrivateGrantHandoff`): the account host's `/zpravy` navigates here. */
|
|
72
|
+
grantHandoff: '/community/grant/handoff',
|
|
65
73
|
} as const)
|
|
66
74
|
|
|
67
75
|
/** A decision's id (kb-api's UUIDs). */
|
package/src/community/outcome.ts
CHANGED
|
@@ -179,6 +179,23 @@ export const COMMUNITY_API_CODES = [
|
|
|
179
179
|
'FOLLOW_LIMIT',
|
|
180
180
|
'STALE_REVISION',
|
|
181
181
|
'CASE_UNDECIDED',
|
|
182
|
+
'DPOP_INVALID',
|
|
183
|
+
'DPOP_NONCE',
|
|
184
|
+
'GRANT_INVALID',
|
|
185
|
+
'PRIVATE_IDENTITY',
|
|
186
|
+
'DEVICE_PENDING',
|
|
187
|
+
'DEVICE_REMOVED',
|
|
188
|
+
'APPROVAL_INVALID',
|
|
189
|
+
'APPROVAL_EXHAUSTED',
|
|
190
|
+
'ADDRESS_REQUIRED',
|
|
191
|
+
'ADDRESS_LOCKED',
|
|
192
|
+
'ACTIVATION_REQUIRED',
|
|
193
|
+
'TEXT_CHANGED',
|
|
194
|
+
'DM_NOT_ALLOWED',
|
|
195
|
+
'EDIT_WINDOW',
|
|
196
|
+
'DELETE_WINDOW',
|
|
197
|
+
'PRIVATE_RESTRICTED',
|
|
198
|
+
'STEP_UP_REQUIRED',
|
|
182
199
|
'NOT_A_MEMBER_SESSION',
|
|
183
200
|
'IDENTITY_NOT_ADMITTED',
|
|
184
201
|
'ACCOUNT_NOT_ELIGIBLE',
|
|
@@ -287,6 +304,26 @@ export const COMMUNITY_OUTCOME_OF_KB: Readonly<Record<CommunityApiCode, Communit
|
|
|
287
304
|
// CASE_UNDECIDED: the team's adverse-events/close while the case's message is held by no decision (decide it first).
|
|
288
305
|
STALE_REVISION: 'submit',
|
|
289
306
|
CASE_UNDECIDED: 'submit',
|
|
307
|
+
// M4 PX0 (m4-contracts.md Appendix A.6): the private, account, grant and staff surfaces' codes. No public, notice or
|
|
308
|
+
// forum operation produces them, and the private client that meets them (`@blogmcp/sdk/community/private`, PU1)
|
|
309
|
+
// handles most itself (a fresh nonce, a new key on DEVICE_REMOVED) — so here, as every code no element meets, `submit`.
|
|
310
|
+
DPOP_INVALID: 'submit',
|
|
311
|
+
DPOP_NONCE: 'submit',
|
|
312
|
+
GRANT_INVALID: 'submit',
|
|
313
|
+
PRIVATE_IDENTITY: 'submit',
|
|
314
|
+
DEVICE_PENDING: 'submit',
|
|
315
|
+
DEVICE_REMOVED: 'submit',
|
|
316
|
+
APPROVAL_INVALID: 'submit',
|
|
317
|
+
APPROVAL_EXHAUSTED: 'submit',
|
|
318
|
+
ADDRESS_REQUIRED: 'submit',
|
|
319
|
+
ADDRESS_LOCKED: 'submit',
|
|
320
|
+
ACTIVATION_REQUIRED: 'submit',
|
|
321
|
+
TEXT_CHANGED: 'submit',
|
|
322
|
+
DM_NOT_ALLOWED: 'submit',
|
|
323
|
+
EDIT_WINDOW: 'submit',
|
|
324
|
+
DELETE_WINDOW: 'submit',
|
|
325
|
+
PRIVATE_RESTRICTED: 'submit',
|
|
326
|
+
STEP_UP_REQUIRED: 'submit',
|
|
290
327
|
// A session that is not a reader's (the team, a key) or an identity the tenant does not admit: sign in as a reader.
|
|
291
328
|
NOT_A_MEMBER_SESSION: 'signIn',
|
|
292
329
|
IDENTITY_NOT_ADMITTED: 'signIn',
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The private entry runs in a browser only (docs/internal/m4-contracts.md §6.1, §7.7). Its key lives in IndexedDB and
|
|
3
|
+
* signs with WebCrypto, and the whole point of the device key is that it never leaves the member's browser: a copy of
|
|
4
|
+
* this code running on a server (an SSR pass of the host, a worker of the tenant's backend) would hold a key the
|
|
5
|
+
* member never approved and could not tell apart from their own device. So the entry refuses to load where `window`,
|
|
6
|
+
* `indexedDB` or `crypto.subtle` is missing — a structural test imports it on a server and expects the throw.
|
|
7
|
+
*
|
|
8
|
+
* Every module that holds or uses browser state calls `assertPrivateBrowser()` at load, not only the entry's index:
|
|
9
|
+
* the package is `sideEffects: false`, so a bundler may import a leaf module directly and skip the index.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** The message of the throw, so a host's error page can tell the case from a bug. */
|
|
13
|
+
export const PRIVATE_SERVER_IMPORT_MESSAGE =
|
|
14
|
+
'[blogmcp-sdk] @blogmcp/sdk/community/private runs only in a browser (it needs window, indexedDB and crypto.subtle): ' +
|
|
15
|
+
'the device key must never exist on a server. Import it from client-only code.'
|
|
16
|
+
|
|
17
|
+
/** True where the private entry may run: a global `window`, `indexedDB` and WebCrypto's `subtle`. */
|
|
18
|
+
export function isPrivateBrowser(): boolean {
|
|
19
|
+
const g = globalThis as { window?: unknown; indexedDB?: unknown; crypto?: { subtle?: unknown } }
|
|
20
|
+
return typeof g.window !== 'undefined' && g.window !== null && typeof g.indexedDB !== 'undefined' && g.indexedDB !== null && !!g.crypto?.subtle
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Throws everywhere but in a browser (see the module doc). */
|
|
24
|
+
export function assertPrivateBrowser(): void {
|
|
25
|
+
if (!isPrivateBrowser()) throw new Error(PRIVATE_SERVER_IMPORT_MESSAGE)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** WebCrypto's SubtleCrypto, read on every use (a test replaces the global between cases). */
|
|
29
|
+
export function subtle(): SubtleCrypto {
|
|
30
|
+
return globalThis.crypto.subtle
|
|
31
|
+
}
|