@blogmcp/sdk 0.9.0 → 0.9.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.
- package/dist/community/index.d.ts +2 -2
- package/dist/community/index.js +56 -55
- package/dist/community/links.d.ts +9 -1
- package/dist/community/links.js +10 -6
- package/dist/community/shapes.d.ts +16 -1
- package/dist/community/shapes.js +38 -26
- package/dist/nuxt/composables/useAsyncKb.js +17 -16
- package/dist/packages/mdx-render-vue/dist/packages/sanitize/dist/html-core.js +5 -0
- package/dist/packages/mdx-render-vue/dist/render/button/Button.vue2.js +1 -1
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
- package/package.json +3 -3
- package/src/community/index.ts +2 -0
- package/src/community/links.ts +9 -1
- package/src/community/shapes.ts +29 -1
- package/src/nuxt/composables/useAsyncKb.ts +10 -11
- package/src/nuxt/nuxt-imports.d.ts +14 -0
- package/dist/packages/mdx-render-vue/dist/packages/sanitize/dist/html.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blogmcp/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Headless SDK for Knowledge Base blog — core client, Vue composables, Nuxt adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@blogmcp/mdx-schema": "^0.9.
|
|
86
|
-
"@blogmcp/sanitize": "^0.9.
|
|
85
|
+
"@blogmcp/mdx-schema": "^0.9.2",
|
|
86
|
+
"@blogmcp/sanitize": "^0.9.2",
|
|
87
87
|
"marked": "^15.0.7"
|
|
88
88
|
},
|
|
89
89
|
"optionalDependencies": {
|
package/src/community/index.ts
CHANGED
|
@@ -85,6 +85,7 @@ export {
|
|
|
85
85
|
isKnownNotificationCode,
|
|
86
86
|
isCaseCategory,
|
|
87
87
|
communityRulesOf,
|
|
88
|
+
communityLegalSectionsOf,
|
|
88
89
|
} from './shapes'
|
|
89
90
|
export type {
|
|
90
91
|
KnownMessageState,
|
|
@@ -129,6 +130,7 @@ export type {
|
|
|
129
130
|
ReportItem,
|
|
130
131
|
CurrentLegalText,
|
|
131
132
|
CommunityRule,
|
|
133
|
+
CommunityLegalSection,
|
|
132
134
|
MemberExport,
|
|
133
135
|
NoticeTarget,
|
|
134
136
|
NoticeReceipt,
|
package/src/community/links.ts
CHANGED
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
* Browser-safe; readReceiptFromHash is the one function that touches `window` (on call, never on import).
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The managed blog's community pages (router-relative; the blog prepends its own base). The three legal pages —
|
|
17
|
+
* `rules`, `terms`, `privacy` — are each the tenant's current `legal/current` text of that kind, rendered by the blog's
|
|
18
|
+
* server without JavaScript, with `/community/<kind>.json` as the machine-readable alternate (DSA art. 14(1)).
|
|
19
|
+
*/
|
|
16
20
|
export const COMMUNITY_ROUTES = Object.freeze({
|
|
17
21
|
/** The „Moje komunita" panel. */
|
|
18
22
|
myCommunity: '/community',
|
|
@@ -24,6 +28,10 @@ export const COMMUNITY_ROUTES = Object.freeze({
|
|
|
24
28
|
notices: '/community/notices',
|
|
25
29
|
/** The rules, rendered on the server without JavaScript. */
|
|
26
30
|
rules: '/community/rules',
|
|
31
|
+
/** The discussion terms (DSA art. 14), rendered on the server without JavaScript, as the rules. */
|
|
32
|
+
terms: '/community/terms',
|
|
33
|
+
/** The discussion privacy notice, rendered the same way. */
|
|
34
|
+
privacy: '/community/privacy',
|
|
27
35
|
} as const)
|
|
28
36
|
|
|
29
37
|
/** A decision's id (kb-api's UUIDs). */
|
package/src/community/shapes.ts
CHANGED
|
@@ -366,7 +366,10 @@ export interface CurrentLegalText {
|
|
|
366
366
|
* An element renders text only: it shows `communityRulesOf(bodyJson)` and links to that page.
|
|
367
367
|
*/
|
|
368
368
|
readonly body: string
|
|
369
|
-
/**
|
|
369
|
+
/**
|
|
370
|
+
* The machine-readable form (DSA art. 14(1)); for `rules` `{ version, rules: [{ id, title, summary?, anchor }] }`
|
|
371
|
+
* (communityRulesOf), for `terms` and `privacy` `{ sections: [{ id, title, anchor }] }` (communityLegalSectionsOf).
|
|
372
|
+
*/
|
|
370
373
|
readonly bodyJson: Readonly<Record<string, unknown>> | null
|
|
371
374
|
readonly reconsentRequired: boolean
|
|
372
375
|
readonly publishedAt: string | null
|
|
@@ -395,6 +398,31 @@ export function communityRulesOf(bodyJson: unknown): CommunityRule[] {
|
|
|
395
398
|
return out
|
|
396
399
|
}
|
|
397
400
|
|
|
401
|
+
/** One section of a `terms` or `privacy` text: what the page's contents list and link. */
|
|
402
|
+
export interface CommunityLegalSection {
|
|
403
|
+
readonly id: string
|
|
404
|
+
readonly title: string
|
|
405
|
+
/** The section's anchor on the page (`#<anchor>`). */
|
|
406
|
+
readonly anchor: string
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* The sections of a `terms` or `privacy` text's `bodyJson` (`{ sections: [{ id, title, anchor }] }`), in order; an
|
|
411
|
+
* entry without a string id, title and anchor is skipped. A `rules` text has none (its rules are communityRulesOf).
|
|
412
|
+
*/
|
|
413
|
+
export function communityLegalSectionsOf(bodyJson: unknown): CommunityLegalSection[] {
|
|
414
|
+
const sections = typeof bodyJson === 'object' && bodyJson !== null ? (bodyJson as { sections?: unknown }).sections : undefined
|
|
415
|
+
if (!Array.isArray(sections)) return []
|
|
416
|
+
const out: CommunityLegalSection[] = []
|
|
417
|
+
for (const s of sections) {
|
|
418
|
+
if (typeof s !== 'object' || s === null) continue
|
|
419
|
+
const { id, title, anchor } = s as Record<string, unknown>
|
|
420
|
+
if (typeof id !== 'string' || typeof title !== 'string' || typeof anchor !== 'string') continue
|
|
421
|
+
out.push(Object.freeze({ id, title, anchor }))
|
|
422
|
+
}
|
|
423
|
+
return out
|
|
424
|
+
}
|
|
425
|
+
|
|
398
426
|
/** `me/export`: every section, `providerEntity` on every row; offer it as a JSON download. */
|
|
399
427
|
export interface MemberExport {
|
|
400
428
|
readonly generatedAt: string
|
|
@@ -8,22 +8,21 @@
|
|
|
8
8
|
* const { articles, totalCount } = await useAsyncArticleList('home', { status: 'published' })
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
11
|
+
// `useAsyncData` comes from Nuxt through its `#imports` alias — an EXPLICIT import, the way a Nuxt
|
|
12
|
+
// module's runtime code takes it. Until 0.9.1 it was a bare identifier left to Nuxt's auto-import
|
|
13
|
+
// transform, which does not run over node_modules: the published package answered 500
|
|
14
|
+
// "useAsyncData is not defined" unless the consumer added
|
|
15
|
+
// `imports.transform.include: [/@blogmcp\/sdk\/dist\/nuxt\//]` (the headless kit did). With the
|
|
16
|
+
// alias the only requirement is `build.transpile: ['@blogmcp/sdk']`, so Vite resolves `#imports`
|
|
17
|
+
// inside this package instead of Node loading it raw. The alias is typed by ./nuxt-imports.d.ts for
|
|
18
|
+
// this package's own build; in a Nuxt app the app's own `#imports` types apply.
|
|
19
|
+
|
|
20
|
+
import { useAsyncData } from '#imports'
|
|
15
21
|
import type { Ref } from 'vue'
|
|
16
22
|
import { useArticleList, useArticle } from '../../vue/composables/useArticles'
|
|
17
23
|
import type { ArticleListParams } from '../../vue/composables/useArticles'
|
|
18
24
|
import { useNavigation } from '../../vue/composables/useNavigation'
|
|
19
25
|
|
|
20
|
-
// Nuxt's useAsyncData type (declared to avoid importing from #imports at compile time)
|
|
21
|
-
declare function useAsyncData<T>(
|
|
22
|
-
key: string,
|
|
23
|
-
handler: () => Promise<T>,
|
|
24
|
-
opts?: { watch?: unknown[] }
|
|
25
|
-
): Promise<{ data: Ref<T | null>; pending: Ref<boolean>; error: Ref<Error | null> }>
|
|
26
|
-
|
|
27
26
|
/**
|
|
28
27
|
* SSR-hydrated article list.
|
|
29
28
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `#imports` alias for THIS package's own build and typecheck (vite-tsc has no Nuxt app around
|
|
3
|
+
* it). Only what the Nuxt adapters use, with Nuxt's shape. A consuming Nuxt app never sees this
|
|
4
|
+
* file: the emitted dist/nuxt/**.d.ts does not reference `#imports` (the import is implementation-
|
|
5
|
+
* only), and the app's own `.nuxt/imports.d.ts` types the alias there.
|
|
6
|
+
*/
|
|
7
|
+
declare module '#imports' {
|
|
8
|
+
import type { Ref } from 'vue'
|
|
9
|
+
export function useAsyncData<T>(
|
|
10
|
+
key: string,
|
|
11
|
+
handler: () => Promise<T>,
|
|
12
|
+
opts?: { watch?: unknown[] },
|
|
13
|
+
): Promise<{ data: Ref<T | null>; pending: Ref<boolean>; error: Ref<Error | null> }>
|
|
14
|
+
}
|