@kookee/sdk 0.0.30 → 0.0.31
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/README.md +139 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Official TypeScript SDK for [Kookee](https://kookee.dev) - the headless CMS for
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Lightweight** - Only ~
|
|
7
|
+
- **Lightweight** - Only ~6.41 KB KB minified (ESM), no bloat
|
|
8
8
|
- **Zero dependencies** - Uses native `fetch`, nothing else
|
|
9
9
|
- **TypeScript-first** - Full type definitions out of the box
|
|
10
10
|
- **Tree-shakeable** - Import only what you need
|
|
@@ -36,6 +36,14 @@ const posts = await kookee.blog.list({ limit: 10 });
|
|
|
36
36
|
const post = await kookee.blog.getBySlug('hello-world');
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const kookee = new Kookee({
|
|
43
|
+
apiKey: 'your-api-key',
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
39
47
|
## Blog
|
|
40
48
|
|
|
41
49
|
```typescript
|
|
@@ -61,7 +69,8 @@ const tags = await kookee.blog.getTags();
|
|
|
61
69
|
await kookee.blog.react('post-id', { reactionType: 'heart', action: 'add' });
|
|
62
70
|
|
|
63
71
|
// Get translations
|
|
64
|
-
const
|
|
72
|
+
const translationsBySlug = await kookee.blog.getTranslationsBySlug('my-post');
|
|
73
|
+
const translationsById = await kookee.blog.getTranslationsById('post-uuid');
|
|
65
74
|
```
|
|
66
75
|
|
|
67
76
|
## Help Center
|
|
@@ -84,21 +93,31 @@ const article = await kookee.help.getBySlug('getting-started');
|
|
|
84
93
|
const articleById = await kookee.help.getById('article-uuid');
|
|
85
94
|
|
|
86
95
|
// Get article translations
|
|
87
|
-
const
|
|
96
|
+
const translationsBySlug = await kookee.help.getTranslationsBySlug('getting-started');
|
|
97
|
+
const translationsById = await kookee.help.getTranslationsById('article-uuid');
|
|
88
98
|
|
|
89
99
|
// AI-powered chat
|
|
90
100
|
const response = await kookee.help.chat({
|
|
91
101
|
messages: [{ role: 'user', content: 'How do I reset my password?' }],
|
|
102
|
+
sessionId: 'optional-session-id', // maintain conversation context across calls
|
|
92
103
|
});
|
|
93
104
|
|
|
94
105
|
// Streaming chat
|
|
95
106
|
for await (const chunk of kookee.help.chatStream({ messages })) {
|
|
96
107
|
if (chunk.type === 'delta') console.log(chunk.content);
|
|
97
108
|
if (chunk.type === 'sources') console.log('Sources:', chunk.sources);
|
|
109
|
+
if (chunk.type === 'done') console.log('Stream finished');
|
|
110
|
+
if (chunk.type === 'error') console.error(chunk.message);
|
|
98
111
|
}
|
|
99
112
|
|
|
100
113
|
// Vote on article usefulness
|
|
101
114
|
await kookee.help.voteUsefulness('article-id', 'yes');
|
|
115
|
+
|
|
116
|
+
// Change a previous vote
|
|
117
|
+
await kookee.help.voteUsefulness('article-id', 'no', 'yes');
|
|
118
|
+
|
|
119
|
+
// Remove a vote
|
|
120
|
+
await kookee.help.voteUsefulness('article-id', null, 'yes');
|
|
102
121
|
```
|
|
103
122
|
|
|
104
123
|
## Changelog
|
|
@@ -110,6 +129,9 @@ const entries = await kookee.changelog.list({ page: 1, limit: 10 });
|
|
|
110
129
|
// Filter by type: 'feature' | 'fix' | 'improvement' | 'breaking' | 'security' | 'deprecated' | 'other'
|
|
111
130
|
const fixes = await kookee.changelog.list({ type: 'fix' });
|
|
112
131
|
|
|
132
|
+
// Search entries
|
|
133
|
+
const results = await kookee.changelog.list({ search: 'authentication' });
|
|
134
|
+
|
|
113
135
|
// Order by version or date
|
|
114
136
|
const sorted = await kookee.changelog.list({ orderBy: 'version', order: 'desc' });
|
|
115
137
|
|
|
@@ -118,7 +140,8 @@ const entry = await kookee.changelog.getBySlug('v1-0-0');
|
|
|
118
140
|
const entryById = await kookee.changelog.getById('entry-uuid');
|
|
119
141
|
|
|
120
142
|
// Get translations
|
|
121
|
-
const
|
|
143
|
+
const translationsBySlug = await kookee.changelog.getTranslationsBySlug('v1-0-0');
|
|
144
|
+
const translationsById = await kookee.changelog.getTranslationsById('entry-uuid');
|
|
122
145
|
|
|
123
146
|
// React to an entry
|
|
124
147
|
await kookee.changelog.react('entry-id', { reactionType: 'fire', action: 'add' });
|
|
@@ -133,6 +156,9 @@ const announcements = await kookee.announcements.list({ page: 1, limit: 10 });
|
|
|
133
156
|
// Filter by type: 'info' | 'warning' | 'critical' | 'promotion' | 'maintenance' | 'newFeature'
|
|
134
157
|
const critical = await kookee.announcements.list({ type: 'critical' });
|
|
135
158
|
|
|
159
|
+
// Order announcements
|
|
160
|
+
const sorted = await kookee.announcements.list({ orderBy: 'publishedAt', order: 'desc' });
|
|
161
|
+
|
|
136
162
|
// Exclude already-seen announcements
|
|
137
163
|
const unseen = await kookee.announcements.list({ excludeIds: ['id1', 'id2'] });
|
|
138
164
|
|
|
@@ -157,11 +183,14 @@ const page = await kookee.pages.getBySlug('privacy-policy');
|
|
|
157
183
|
const pageById = await kookee.pages.getById('page-uuid');
|
|
158
184
|
|
|
159
185
|
// Get translations
|
|
160
|
-
const
|
|
186
|
+
const translationsBySlug = await kookee.pages.getTranslationsBySlug('privacy-policy');
|
|
187
|
+
const translationsById = await kookee.pages.getTranslationsById('page-uuid');
|
|
161
188
|
```
|
|
162
189
|
|
|
163
190
|
## Feedback
|
|
164
191
|
|
|
192
|
+
### Reading feedback
|
|
193
|
+
|
|
165
194
|
```typescript
|
|
166
195
|
// List feedback posts
|
|
167
196
|
const posts = await kookee.feedback.list({ page: 1, limit: 10 });
|
|
@@ -175,6 +204,9 @@ const bugs = await kookee.feedback.list({ category: 'bug' });
|
|
|
175
204
|
// Sort options: 'newest' | 'top' | 'trending'
|
|
176
205
|
const trending = await kookee.feedback.list({ sort: 'trending' });
|
|
177
206
|
|
|
207
|
+
// Search posts
|
|
208
|
+
const results = await kookee.feedback.list({ search: 'dark mode' });
|
|
209
|
+
|
|
178
210
|
// Get single post with comments
|
|
179
211
|
const post = await kookee.feedback.getById('post-uuid');
|
|
180
212
|
|
|
@@ -185,6 +217,52 @@ await kookee.feedback.vote('post-id', { action: 'upvote' });
|
|
|
185
217
|
const contributors = await kookee.feedback.getTopContributors({ limit: 10 });
|
|
186
218
|
```
|
|
187
219
|
|
|
220
|
+
### Creating and managing feedback
|
|
221
|
+
|
|
222
|
+
These operations require an `ExternalUser` to identify the author:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import type { ExternalUser } from '@kookee/sdk';
|
|
226
|
+
|
|
227
|
+
const user: ExternalUser = {
|
|
228
|
+
externalId: 'user-123', // your system's user ID
|
|
229
|
+
name: 'Jane Doe',
|
|
230
|
+
email: 'jane@example.com', // optional
|
|
231
|
+
avatarUrl: 'https://...', // optional
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// Create a feedback post
|
|
235
|
+
const newPost = await kookee.feedback.createPost({
|
|
236
|
+
title: 'Add dark mode',
|
|
237
|
+
description: 'It would be great to have a dark mode option.',
|
|
238
|
+
category: 'feature', // optional: 'feature' | 'improvement' | 'bug' | 'other'
|
|
239
|
+
externalUser: user,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Add a comment to a post
|
|
243
|
+
const comment = await kookee.feedback.createComment('post-id', {
|
|
244
|
+
content: 'Great idea, I would love this too!',
|
|
245
|
+
externalUser: user,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// List posts created by a specific user
|
|
249
|
+
const myPosts = await kookee.feedback.listMyPosts({
|
|
250
|
+
externalId: 'user-123',
|
|
251
|
+
page: 1,
|
|
252
|
+
limit: 10,
|
|
253
|
+
status: 'open', // optional filter
|
|
254
|
+
category: 'feature', // optional filter
|
|
255
|
+
search: 'dark mode', // optional search
|
|
256
|
+
sort: 'newest', // optional sort
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Delete a post (only the author can delete)
|
|
260
|
+
await kookee.feedback.deletePost('post-id', { externalId: 'user-123' });
|
|
261
|
+
|
|
262
|
+
// Delete a comment (only the author can delete)
|
|
263
|
+
await kookee.feedback.deleteComment('comment-id', { externalId: 'user-123' });
|
|
264
|
+
```
|
|
265
|
+
|
|
188
266
|
## Config
|
|
189
267
|
|
|
190
268
|
```typescript
|
|
@@ -195,6 +273,13 @@ const config = await kookee.config.getByKey('feature_flags');
|
|
|
195
273
|
const configs = await kookee.config.list({ keys: ['feature_flags', 'theme'] });
|
|
196
274
|
```
|
|
197
275
|
|
|
276
|
+
## Health Check
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const health = await kookee.health();
|
|
280
|
+
// { status: 'ok', projectId: '...', timestamp: '...' }
|
|
281
|
+
```
|
|
282
|
+
|
|
198
283
|
## Reactions
|
|
199
284
|
|
|
200
285
|
Blog posts and changelog entries support reactions:
|
|
@@ -219,6 +304,13 @@ const posts = await kookee.blog.list({ locale: 'de' });
|
|
|
219
304
|
const post = await kookee.blog.getBySlug('hello-world', { locale: 'de', fallback: true });
|
|
220
305
|
```
|
|
221
306
|
|
|
307
|
+
Translation endpoints return a `Record<string, T>` keyed by locale code:
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
const translations = await kookee.blog.getTranslationsBySlug('hello-world');
|
|
311
|
+
// { en: BlogPost, de: BlogPost, fr: BlogPost, ... }
|
|
312
|
+
```
|
|
313
|
+
|
|
222
314
|
## Paginated Response
|
|
223
315
|
|
|
224
316
|
All list endpoints return a paginated response:
|
|
@@ -249,21 +341,57 @@ try {
|
|
|
249
341
|
}
|
|
250
342
|
```
|
|
251
343
|
|
|
252
|
-
##
|
|
344
|
+
## Code Block Styles
|
|
345
|
+
|
|
346
|
+
The SDK ships an optional CSS file for styling code blocks in content HTML (VS Code Dark+ theme):
|
|
253
347
|
|
|
254
348
|
```typescript
|
|
255
|
-
|
|
256
|
-
apiKey: 'your-api-key',
|
|
257
|
-
baseUrl: 'https://api.kookee.dev', // optional, defaults to production API
|
|
258
|
-
});
|
|
349
|
+
import '@kookee/sdk/styles/code.css';
|
|
259
350
|
```
|
|
260
351
|
|
|
352
|
+
Or via CDN:
|
|
353
|
+
|
|
354
|
+
```html
|
|
355
|
+
<link rel="stylesheet" href="https://unpkg.com/@kookee/sdk/styles/code.css">
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
This provides:
|
|
359
|
+
- Syntax-highlighted code blocks with a dark theme
|
|
360
|
+
- Copy-to-clipboard button styling
|
|
361
|
+
- Language label display
|
|
362
|
+
- Inline code styling (red on pink background)
|
|
363
|
+
|
|
261
364
|
## TypeScript
|
|
262
365
|
|
|
263
366
|
The SDK is written in TypeScript and provides full type definitions:
|
|
264
367
|
|
|
265
368
|
```typescript
|
|
266
|
-
import type {
|
|
369
|
+
import type {
|
|
370
|
+
BlogPost,
|
|
371
|
+
BlogPostListItem,
|
|
372
|
+
BlogTag,
|
|
373
|
+
BlogTagWithCount,
|
|
374
|
+
Page,
|
|
375
|
+
PageListItem,
|
|
376
|
+
HelpArticle,
|
|
377
|
+
HelpArticleListItem,
|
|
378
|
+
HelpCategory,
|
|
379
|
+
HelpSearchResult,
|
|
380
|
+
HelpChatResponse,
|
|
381
|
+
HelpChatStreamChunk,
|
|
382
|
+
ChangelogEntry,
|
|
383
|
+
ChangelogEntryListItem,
|
|
384
|
+
Announcement,
|
|
385
|
+
AnnouncementListItem,
|
|
386
|
+
FeedbackPost,
|
|
387
|
+
FeedbackPostListItem,
|
|
388
|
+
FeedbackComment,
|
|
389
|
+
FeedbackTopContributor,
|
|
390
|
+
ExternalUser,
|
|
391
|
+
PublicConfig,
|
|
392
|
+
PaginatedResponse,
|
|
393
|
+
KookeeConfig,
|
|
394
|
+
} from '@kookee/sdk';
|
|
267
395
|
```
|
|
268
396
|
|
|
269
397
|
## License
|