@digital-realty/ui-knowledgebase 0.1.0 → 0.1.1-kb-linting.560093

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +45 -9
  2. package/package.json +13 -10
package/README.md CHANGED
@@ -52,32 +52,48 @@ through a configurable base. Base URLs come from `window.gpConfig['ui-knowledge-
52
52
  via the MFE's `config-helper.ts`, matching the other MFEs.
53
53
 
54
54
  **Scope**
55
- - A `StrapiClient` service reading `apiBaseUrl` and a media base URL from config; no hardcoded hosts.
55
+
56
+ - A `createKbApiClient({ apiBaseUrl, mediaBaseUrl, previewDrafts, locale, fetch })` factory —
57
+ all config is **passed in at initialization** (a `config-helper` supplies it during
58
+ integration, not here); no hardcoded hosts.
59
+ - **Draft vs published is fixed at init** via `previewDrafts`: acceptance/test/preview
60
+ environments pass `true` so unpublished editor content is visible (Strapi `status=draft`);
61
+ production passes `false`/omits it (`status=published`).
56
62
  - Typed methods for the four views:
57
63
  - `getLanding()` — index-page single type + categories + topics + featured + what's-new posts
58
- - `getCategory(uid)` — category by uid plus its published posts, with sort and topic-filter params
59
- - `getTopic(code)` — published posts for a topic
64
+ - `getCategory(uid)` — category by uid plus its posts, with sort and topic-filter params
65
+ - `getTopic(code)` — posts for a topic
60
66
  - `getPost(uid)` — single post, populating thumbnail, video, documents, topics, category
61
67
  - Normalization into KB view-model types: flatten Strapi shape, expose `documentId`, resolve media URLs to absolute.
62
- - Query building for `populate`, `locale`, `status=published`, pagination, and `filters`.
63
- - Consistent error handling: non-2xx and network failures surface as a typed error for page views to render.
68
+ - Query building for `populate`, `locale`, `status`, pagination, and `filters`.
69
+ - Consistent error handling: non-2xx and network failures surface as a typed `KbApiError`.
64
70
 
65
71
  **Out of scope**
72
+
66
73
  - Search (separate ticket), rich-text rendering, and any write operations.
67
74
  - Auth/token handling — assumes public read; an API token is a follow-up if gating is later required.
75
+ - Wiring into the MFE (config-helper reading `window.gpConfig`, views calling the client) — later.
68
76
 
69
77
  **Acceptance criteria**
78
+
70
79
  - All four methods return normalized view models; no component references `data.attributes` or raw Strapi fields.
71
- - Base URLs are config-driven; switching config points the client at local vs deployed Strapi with no code change.
80
+ - Base URLs are init params; switching them points the client at local vs deployed Strapi with no code change.
72
81
  - Media URLs in returned models are absolute and load in both local (Azurite) and deployed environments.
73
- - Only published content is returned by default; `locale` is honored when passed.
82
+ - `previewDrafts` controls draft vs published; `locale` is honored when passed.
74
83
  - Failures return a typed error; a smoke test covers a 404 and a network error.
75
84
  - Unit tests cover normalization and query building for each method.
76
85
 
86
+ **Implemented:** `src/api/` — `client.ts` (factory + methods), `types.ts` (view models +
87
+ `KbApiError`), `query.ts` (Strapi bracket query builder), `normalize.ts` (raw→view-model +
88
+ media resolver), `index.ts` (barrel). Typechecks clean; verified live against local Strapi
89
+ (query syntax, media resolution, all four methods, and `previewDrafts` → `status=draft`).
90
+ Not yet wired into views/config. A test runner + the AC unit tests are still to add.
91
+
77
92
  **Dependencies**
78
- - Config-helper + config keys ticket (provides `apiBaseUrl` / media base).
93
+
94
+ - Config-helper + config keys ticket (provides `apiBaseUrl` / media base / `previewDrafts`).
79
95
  - View-model types ticket.
80
- - Strapi public-role read access enabled.
96
+ - Strapi public-role read access enabled (incl. draft access for preview environments).
81
97
 
82
98
  ### KB-2 · Build sanitized rich-text (HTML) renderer
83
99
 
@@ -100,6 +116,7 @@ inline `/uploads/...` links. GPv1 already wrapped rendering in a reused `RawHtml
100
116
  we mirror that and add the missing sanitize step.
101
117
 
102
118
  **Scope**
119
+
103
120
  - `sanitizeRichText(html, mediaBase): string` — pure helper using DOMPurify (allowlist
104
121
  tolerant of the legacy Word markup). Rewrite `<a href>` / `<img src>` via a DOMPurify
105
122
  `afterSanitizeAttributes` hook: resolve relative `/uploads/...` against the media base URL,
@@ -113,15 +130,18 @@ we mirror that and add the missing sanitize step.
113
130
  boundary, is the security control.
114
131
 
115
132
  **Out of scope**
133
+
116
134
  - Video embeds and document/attachment lists (separate components).
117
135
 
118
136
  **Acceptance criteria**
137
+
119
138
  - `<script>`, event handlers, and other unsafe content are stripped; a test asserts a script payload does not execute.
120
139
  - Relative media URLs resolve to absolute against the media base and load locally (Azurite) and deployed.
121
140
  - External links open in a new tab with `rel="noopener noreferrer"`.
122
141
  - Representative legacy content (incl. the pasted-Word Terms & Conditions post) renders without breaking layout.
123
142
 
124
143
  **Dependencies**
144
+
125
145
  - KB-1 (media base URL / normalized models).
126
146
 
127
147
  ### KB-3 · Build Knowledge Base landing page view
@@ -140,21 +160,25 @@ Topics, Featured Resources, and a What's New panel. This ticket is the page comp
140
160
  only — each section is its own component ticket.
141
161
 
142
162
  **Scope**
163
+
143
164
  - A Lit route view at `/` that calls `StrapiClient.getLanding()` (KB-1).
144
165
  - Compose the sections: hero + search, categories grid, topics list, featured resources, what's-new panel.
145
166
  - Wire clicks: category → `/category/:uid`, topic → `/topic/:code`, post → `/details/:uid`.
146
167
  - Render loading, empty, and error states from the client result.
147
168
 
148
169
  **Out of scope**
170
+
149
171
  - The section components themselves (hero, category card, topics list, featured card, what's-new) — separate tickets.
150
172
  - Search behaviour (separate ticket); this view only places the search input.
151
173
 
152
174
  **Acceptance criteria**
175
+
153
176
  - Landing renders all five sections from a single `getLanding()` call.
154
177
  - Category, topic, and post links navigate to the correct routes.
155
178
  - Loading, empty, and error states render; an error from the client shows the error state, not a blank page.
156
179
 
157
180
  **Dependencies**
181
+
158
182
  - KB-1 (client + `getLanding()`).
159
183
  - Content components: `kb-category-tile`, `kb-topic-tile`, featured post cards, `kb-whats-new-panel` (hero inline or `kb-hero`).
160
184
 
@@ -316,6 +340,7 @@ video_card | document_card`) decides which post component renders its posts, and
316
340
  controls appear.
317
341
 
318
342
  **Scope**
343
+
319
344
  - A Lit route view at `/category/:uid` calling `StrapiClient.getCategory(uid)` (KB-1).
320
345
  - Header from the category (title, subtitle, icon/image).
321
346
  - Render the posts by selecting the post component from the category `behavior`
@@ -324,9 +349,11 @@ controls appear.
324
349
  - Post click → `/details/:uid`; loading, empty, and error states.
325
350
 
326
351
  **Out of scope**
352
+
327
353
  - The post components themselves (KB-9–12); search.
328
354
 
329
355
  **Acceptance criteria**
356
+
330
357
  - Posts render with the component matching the category `behavior`.
331
358
  - Sort / topic-filter controls appear only when their flags are set, and filter/sort the list.
332
359
  - Loading, empty, and error states render.
@@ -348,15 +375,18 @@ Mirrors the legacy topic page. Unlike a category, a topic's posts span categorie
348
375
  each post renders according to its own `behavior` field.
349
376
 
350
377
  **Scope**
378
+
351
379
  - A Lit route view at `/topic/:code` calling `StrapiClient.getTopic(code)` (KB-1).
352
380
  - Header showing the topic (icon + name).
353
381
  - Render each post by selecting the post component from that post's `behavior` (KB-9–12).
354
382
  - Post click → `/details/:uid`; loading, empty, and error states.
355
383
 
356
384
  **Out of scope**
385
+
357
386
  - The post components themselves (KB-9–12); search.
358
387
 
359
388
  **Acceptance criteria**
389
+
360
390
  - Each post renders with the component matching its own `behavior`.
361
391
  - Loading, empty, and error states render.
362
392
 
@@ -377,15 +407,18 @@ video or document attachments. Keep the `/details/:uid` path; deep links and the
377
407
  launchpad widget depend on it.
378
408
 
379
409
  **Scope**
410
+
380
411
  - A Lit route view at `/details/:uid` calling `StrapiClient.getPost(uid)` (KB-1).
381
412
  - Render: title, topic chips, `dateAdded`, body HTML via `<kb-rich-text>` (KB-2),
382
413
  the `video` if present, and the `documents[]` as downloadable links.
383
414
  - Loading, not-found (bad uid), and error states.
384
415
 
385
416
  **Out of scope**
417
+
386
418
  - Search; related-posts / navigation beyond back.
387
419
 
388
420
  **Acceptance criteria**
421
+
389
422
  - A post renders its title, body, and any video/documents.
390
423
  - Body HTML is sanitized via `<kb-rich-text>` and media links resolve.
391
424
  - An unknown `uid` shows a not-found state, not a blank page.
@@ -406,6 +439,7 @@ The legacy KB hero has a search box. Content is small, so a simple substring mat
406
439
  enough — no ranking engine. Runs against Strapi REST.
407
440
 
408
441
  **Scope**
442
+
409
443
  - Add `StrapiClient.search(query)` (KB-1) using Strapi filters (`$containsi` on `title`,
410
444
  `abstract`, `text`), published-only and locale-aware, returning normalized post previews.
411
445
  - Wire the hero search input (KB-4): debounce input, call `search`, and show results.
@@ -413,9 +447,11 @@ enough — no ranking engine. Runs against Strapi REST.
413
447
  - Handle empty query, no-results, and error states.
414
448
 
415
449
  **Out of scope**
450
+
416
451
  - Ranking / relevance scoring, faceting, and search analytics.
417
452
 
418
453
  **Acceptance criteria**
454
+
419
455
  - Typing a query returns matching published posts; matches are case-insensitive across title/abstract/text.
420
456
  - Selecting a result navigates to `/details/:uid`.
421
457
  - Empty query clears results; no-results and error states render.
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@digital-realty/ui-knowledgebase",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-kb-linting.560093",
4
4
  "type": "module",
5
- "packageManager": "pnpm@11.7.0",
6
5
  "publishConfig": {
7
6
  "access": "public"
8
7
  },
@@ -12,20 +11,24 @@
12
11
  "exports": {
13
12
  "./ui-knowledgebase.js": "./dist/ui-knowledgebase.js"
14
13
  },
15
- "scripts": {
16
- "dev": "vite",
17
- "build": "tsc --noEmit && vite build",
18
- "build:workspace": "pnpm run build",
19
- "preview": "vite preview",
20
- "clean": "rimraf node_modules dist"
21
- },
22
14
  "dependencies": {
23
15
  "@vaadin/router": "^1.7.5",
24
16
  "lit": "^3.1.4"
25
17
  },
26
18
  "devDependencies": {
19
+ "prettier": "^3.9.9",
27
20
  "rimraf": "^6.0.1",
28
21
  "typescript": "^5.5.3",
29
22
  "vite": "^8.1.0"
23
+ },
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "tsc --noEmit && vite build",
27
+ "build:workspace": "pnpm run build",
28
+ "test": "echo \"ui-knowledgebase: no test suite yet\"",
29
+ "preview": "vite preview",
30
+ "format": "prettier --write .",
31
+ "format:check": "prettier --check .",
32
+ "clean": "rimraf node_modules dist"
30
33
  }
31
- }
34
+ }