@kookee/sdk 0.0.32 → 0.0.34

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 CHANGED
@@ -44,6 +44,43 @@ const kookee = new Kookee({
44
44
  });
45
45
  ```
46
46
 
47
+ ## User Identification
48
+
49
+ Set user identity once and it's automatically used across all feedback operations:
50
+
51
+ ```typescript
52
+ // Set user identity globally
53
+ kookee.identify({
54
+ externalId: 'user-456',
55
+ name: 'Jane Doe',
56
+ email: 'jane@example.com', // optional
57
+ avatarUrl: 'https://...', // optional
58
+ });
59
+
60
+ // All feedback methods now auto-use the identified user
61
+ await kookee.feedback.createPost({ title: 'Feature request', category: 'feature' });
62
+ await kookee.feedback.createComment(postId, { content: 'Great idea!' });
63
+ const myPosts = await kookee.feedback.listMyPosts();
64
+
65
+ // Check current user
66
+ const user = kookee.getUser(); // KookeeUser | null
67
+
68
+ // Clear identity on logout
69
+ kookee.reset();
70
+ ```
71
+
72
+ ### React usage
73
+
74
+ ```typescript
75
+ useEffect(() => {
76
+ if (user) {
77
+ kookee.identify({ externalId: user.id, name: user.name, email: user.email });
78
+ } else {
79
+ kookee.reset();
80
+ }
81
+ }, [user]);
82
+ ```
83
+
47
84
  ## Blog
48
85
 
49
86
  ```typescript
@@ -65,6 +102,9 @@ const postById = await kookee.blog.getById('post-uuid');
65
102
  // Get all tags with post counts
66
103
  const tags = await kookee.blog.getTags();
67
104
 
105
+ // Get comments on a post
106
+ const comments = await kookee.blog.getComments('post-id', { page: 1, limit: 20 });
107
+
68
108
  // React to a post
69
109
  await kookee.blog.react('post-id', { reactionType: 'heart', action: 'add' });
70
110
 
@@ -96,6 +136,12 @@ const articleById = await kookee.help.getById('article-uuid');
96
136
  const translationsBySlug = await kookee.help.getTranslationsBySlug('getting-started');
97
137
  const translationsById = await kookee.help.getTranslationsById('article-uuid');
98
138
 
139
+ // Get comments on an article
140
+ const comments = await kookee.help.getComments('article-id', { page: 1, limit: 20 });
141
+
142
+ // React to an article
143
+ await kookee.help.react('article-id', { reactionType: 'heart', action: 'add' });
144
+
99
145
  // AI-powered chat
100
146
  const response = await kookee.help.chat({
101
147
  messages: [{ role: 'user', content: 'How do I reset my password?' }],
@@ -109,15 +155,6 @@ for await (const chunk of kookee.help.chatStream({ messages })) {
109
155
  if (chunk.type === 'done') console.log('Stream finished');
110
156
  if (chunk.type === 'error') console.error(chunk.message);
111
157
  }
112
-
113
- // Vote on article usefulness
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');
121
158
  ```
122
159
 
123
160
  ## Changelog
@@ -126,15 +163,9 @@ await kookee.help.voteUsefulness('article-id', null, 'yes');
126
163
  // List entries
127
164
  const entries = await kookee.changelog.list({ page: 1, limit: 10 });
128
165
 
129
- // Filter by type: 'feature' | 'fix' | 'improvement' | 'breaking' | 'security' | 'deprecated' | 'other'
130
- const fixes = await kookee.changelog.list({ type: 'fix' });
131
-
132
166
  // Search entries
133
167
  const results = await kookee.changelog.list({ search: 'authentication' });
134
168
 
135
- // Order by version or date
136
- const sorted = await kookee.changelog.list({ orderBy: 'version', order: 'desc' });
137
-
138
169
  // Get single entry
139
170
  const entry = await kookee.changelog.getBySlug('v1-0-0');
140
171
  const entryById = await kookee.changelog.getById('entry-uuid');
@@ -143,6 +174,9 @@ const entryById = await kookee.changelog.getById('entry-uuid');
143
174
  const translationsBySlug = await kookee.changelog.getTranslationsBySlug('v1-0-0');
144
175
  const translationsById = await kookee.changelog.getTranslationsById('entry-uuid');
145
176
 
177
+ // Get comments on an entry
178
+ const comments = await kookee.changelog.getComments('entry-id', { page: 1, limit: 20 });
179
+
146
180
  // React to an entry
147
181
  await kookee.changelog.react('entry-id', { reactionType: 'fire', action: 'add' });
148
182
  ```
@@ -153,20 +187,14 @@ await kookee.changelog.react('entry-id', { reactionType: 'fire', action: 'add' }
153
187
  // List announcements
154
188
  const announcements = await kookee.announcements.list({ page: 1, limit: 10 });
155
189
 
156
- // Filter by type: 'info' | 'warning' | 'critical' | 'promotion' | 'maintenance' | 'newFeature'
157
- const critical = await kookee.announcements.list({ type: 'critical' });
158
-
159
- // Order announcements
160
- const sorted = await kookee.announcements.list({ orderBy: 'publishedAt', order: 'desc' });
161
-
162
- // Exclude already-seen announcements
163
- const unseen = await kookee.announcements.list({ excludeIds: ['id1', 'id2'] });
164
-
165
190
  // Get single announcement
166
191
  const announcement = await kookee.announcements.getById('announcement-uuid');
167
192
 
168
193
  // Get translations
169
194
  const translations = await kookee.announcements.getTranslationsById('announcement-uuid');
195
+
196
+ // Get comments on an announcement
197
+ const comments = await kookee.announcements.getComments('announcement-id', { page: 1, limit: 20 });
170
198
  ```
171
199
 
172
200
  ## Pages
@@ -185,6 +213,37 @@ const pageById = await kookee.pages.getById('page-uuid');
185
213
  // Get translations
186
214
  const translationsBySlug = await kookee.pages.getTranslationsBySlug('privacy-policy');
187
215
  const translationsById = await kookee.pages.getTranslationsById('page-uuid');
216
+
217
+ // Get comments on a page
218
+ const comments = await kookee.pages.getComments('page-id', { page: 1, limit: 20 });
219
+ ```
220
+
221
+ ## Entries (Generic)
222
+
223
+ The `entries` module provides low-level access to all entry types through a unified API:
224
+
225
+ ```typescript
226
+ // List entries by type
227
+ const blogPosts = await kookee.entries.list({ type: 'blog', page: 1, limit: 10 });
228
+ const articles = await kookee.entries.list({ type: 'help_article', category: 'getting-started' });
229
+
230
+ // Get entry by slug or ID
231
+ const entry = await kookee.entries.getBySlug('my-post', { type: 'blog' });
232
+ const entryById = await kookee.entries.getById('entry-uuid');
233
+
234
+ // Get translations
235
+ const translationsBySlug = await kookee.entries.getTranslationsBySlug('my-post');
236
+ const translationsById = await kookee.entries.getTranslationsById('entry-uuid');
237
+
238
+ // Get comments
239
+ const comments = await kookee.entries.getComments('entry-id', { page: 1, limit: 20 });
240
+
241
+ // React to any entry
242
+ await kookee.entries.react('entry-id', { reactionType: 'heart', action: 'add' });
243
+
244
+ // Get tags or categories for a type
245
+ const tags = await kookee.entries.getTags('blog');
246
+ const categories = await kookee.entries.getCategories('help_article');
188
247
  ```
189
248
 
190
249
  ## Feedback
@@ -219,48 +278,39 @@ const contributors = await kookee.feedback.getTopContributors({ limit: 10 });
219
278
 
220
279
  ### Creating and managing feedback
221
280
 
222
- These operations require an `ExternalUser` to identify the author:
281
+ These operations require user identification — either globally via `kookee.identify()` or per-call via `externalUser`/`externalId`:
223
282
 
224
283
  ```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
- };
284
+ // With global identity (recommended see User Identification section above)
285
+ kookee.identify({ externalId: 'user-123', name: 'Jane Doe' });
233
286
 
234
- // Create a feedback post
235
287
  const newPost = await kookee.feedback.createPost({
236
288
  title: 'Add dark mode',
237
289
  description: 'It would be great to have a dark mode option.',
238
- category: 'feature', // optional: 'feature' | 'improvement' | 'bug' | 'other'
239
- externalUser: user,
290
+ category: 'feature',
240
291
  });
241
292
 
242
- // Add a comment to a post
243
293
  const comment = await kookee.feedback.createComment('post-id', {
244
294
  content: 'Great idea, I would love this too!',
245
- externalUser: user,
246
295
  });
247
296
 
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
- });
297
+ const myPosts = await kookee.feedback.listMyPosts();
298
+
299
+ await kookee.feedback.deletePost('post-id');
300
+ await kookee.feedback.deleteComment('comment-id');
301
+ ```
258
302
 
259
- // Delete a post (only the author can delete)
260
- await kookee.feedback.deletePost('post-id', { externalId: 'user-123' });
303
+ Per-call override still works (takes precedence over global identity):
261
304
 
262
- // Delete a comment (only the author can delete)
263
- await kookee.feedback.deleteComment('comment-id', { externalId: 'user-123' });
305
+ ```typescript
306
+ const newPost = await kookee.feedback.createPost({
307
+ title: 'Add dark mode',
308
+ externalUser: { externalId: 'other-user', name: 'John' },
309
+ });
310
+
311
+ const myPosts = await kookee.feedback.listMyPosts({ externalId: 'other-user' });
312
+ await kookee.feedback.deletePost('post-id', { externalId: 'other-user' });
313
+ await kookee.feedback.deleteComment('comment-id', { externalId: 'other-user' });
264
314
  ```
265
315
 
266
316
  ## Config
@@ -282,7 +332,7 @@ const health = await kookee.health();
282
332
 
283
333
  ## Reactions
284
334
 
285
- Blog posts and changelog entries support reactions:
335
+ Blog posts, help articles, and changelog entries support reactions:
286
336
 
287
337
  ```typescript
288
338
  // Available reaction types: 'fire' | 'heart' | 'rocket' | 'eyes' | 'mindblown'
@@ -308,7 +358,7 @@ Translation endpoints return a `Record<string, T>` keyed by locale code:
308
358
 
309
359
  ```typescript
310
360
  const translations = await kookee.blog.getTranslationsBySlug('hello-world');
311
- // { en: BlogPost, de: BlogPost, fr: BlogPost, ... }
361
+ // { en: BlogEntry, de: BlogEntry, fr: BlogEntry, ... }
312
362
  ```
313
363
 
314
364
  ## Paginated Response
@@ -367,30 +417,76 @@ The SDK is written in TypeScript and provides full type definitions:
367
417
 
368
418
  ```typescript
369
419
  import type {
370
- BlogPost,
371
- BlogPostListItem,
372
- BlogTag,
373
- BlogTagWithCount,
374
- Page,
375
- PageListItem,
376
- HelpArticle,
377
- HelpArticleListItem,
378
- HelpCategory,
420
+ // Entry types
421
+ BaseEntry,
422
+ GenericEntry,
423
+ BlogEntry,
424
+ PageEntry,
425
+ HelpArticleEntry,
426
+ ChangelogEntry,
427
+ AnnouncementEntry,
428
+ TypedEntry,
429
+ AnyEntry,
430
+ EntryType,
431
+ EntryStatus,
432
+ EntryAuthor,
433
+ EntryTag,
434
+ EntryTagWithCount,
435
+ EntryCategory,
436
+ EntryComment,
437
+
438
+ // Changelog & Announcement specific
439
+ ChangelogType,
440
+ AnnouncementType,
441
+
442
+ // Help Center
379
443
  HelpSearchResult,
444
+ HelpArticleVisibility,
445
+ HelpChatMessage,
446
+ HelpChatParams,
380
447
  HelpChatResponse,
448
+ HelpChatSource,
449
+ HelpChatSourceCategory,
381
450
  HelpChatStreamChunk,
382
- ChangelogEntry,
383
- ChangelogEntryListItem,
384
- Announcement,
385
- AnnouncementListItem,
451
+
452
+ // Feedback
386
453
  FeedbackPost,
387
454
  FeedbackPostListItem,
455
+ FeedbackPostStatus,
456
+ FeedbackPostCategory,
457
+ FeedbackSortOption,
458
+ FeedbackAuthor,
459
+ FeedbackAssignee,
388
460
  FeedbackComment,
389
461
  FeedbackTopContributor,
462
+ FeedbackVoteResponse,
463
+ CreateFeedbackPostParams,
464
+ CreateFeedbackCommentParams,
465
+ CreatedFeedbackPost,
466
+ CreatedFeedbackComment,
467
+ ListMyFeedbackPostsParams,
468
+ DeleteFeedbackPostParams,
469
+ DeleteFeedbackPostResponse,
470
+ DeleteFeedbackCommentParams,
471
+ DeleteFeedbackCommentResponse,
472
+
473
+ // User & Identity
474
+ KookeeUser,
390
475
  ExternalUser,
476
+
477
+ // Reactions
478
+ ReactionType,
479
+ ReactParams,
480
+ ReactResponse,
481
+
482
+ // Common
391
483
  PublicConfig,
392
484
  PaginatedResponse,
485
+ PaginationParams,
486
+ LocaleOptions,
487
+ OrderDirection,
393
488
  KookeeConfig,
489
+ HealthCheckResponse,
394
490
  } from '@kookee/sdk';
395
491
  ```
396
492
 
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var k="https://api.kookee.dev",x="Kookee-API-Key",I="Kookee-Project-Id",i=class r extends Error{constructor(t,s,o){super(s);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,r.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??k;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[x]=this.apiKey),this.projectId&&(e[I]=this.projectId),e}async get(e,t){let s=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,n]of Object.entries(t))if(n!=null)if(Array.isArray(n))for(let a of n)s.searchParams.append(h,String(a));else s.searchParams.set(h,String(n));}let o=await fetch(s.toString(),{method:"GET",headers:this.getHeaders()});return this.handleResponse(o)}async post(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(s)}async delete(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(s)}async*streamPost(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{...this.getHeaders(),Accept:"text/event-stream"},body:t?JSON.stringify(t):void 0});if(!s.ok){let a=null;try{a=await s.json();}catch{}throw new i(a?.code??"UNKNOWN_ERROR",a?.message??`Request failed with status ${s.status}`,s.status)}if(!s.body)return;let o=s.body.getReader(),h=new TextDecoder,n="";try{for(;;){let{done:a,value:b}=await o.read();if(a)break;n+=h.decode(b,{stream:!0});let f=n.split(`
2
- `);n=f.pop()??"";for(let B of f){let u=B.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let R=u.slice(6);if(R==="[DONE]")return;yield JSON.parse(R);}}}}finally{o.releaseLock();}}async handleResponse(e){if(!e.ok){let t=null;try{t=await e.json();}catch{}throw new i(t?.code??"UNKNOWN_ERROR",t?.message??`Request failed with status ${e.status}`,e.status)}return e.json()}};var m=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"announcement",...e})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var p=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"blog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"blog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTags(){return this.entries.getTags("blog")}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var c=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"changelog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"changelog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var g=class{constructor(e){this.http=e;}async getByKey(e){return this.http.get(`/v1/config/${encodeURIComponent(e)}`)}async list(e){return this.http.get("/v1/config",e)}};var l=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/entries",e)}async getById(e,t){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}`,t)}async getBySlug(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}`,t)}async getTranslationsById(e){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}/translations`)}async getTranslationsBySlug(e){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/translations`)}async getComments(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/comments`,t)}async react(e,t){return this.http.post(`/v1/entries/${encodeURIComponent(e)}/reactions`,t)}async getTags(e){return this.http.get("/v1/tags",{type:e})}async getCategories(e,t){return this.http.get("/v1/categories",{type:e,...t})}};var y=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/feedback",e)}async getById(e){return this.http.get(`/v1/feedback/by-id/${encodeURIComponent(e)}`)}async vote(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/vote`,t)}async getTopContributors(e){return this.http.get("/v1/feedback/top-contributors",e)}async createPost(e){return this.http.post("/v1/feedback",e)}async createComment(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/comments`,t)}async listMyPosts(e){return this.http.get("/v1/feedback/mine",e)}async deletePost(e,t){return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,t)}async deleteComment(e,t){return this.http.delete(`/v1/feedback/comments/${encodeURIComponent(e)}`,t)}};var P=class{http;entries;constructor(e,t){this.http=e,this.entries=t;}async categories(e){return this.entries.getCategories("help_article",e)}async list(e){return this.entries.list({type:"help_article",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"help_article",...t})}async getById(e,t){return this.entries.getById(e,t)}async search(e){return this.http.get("/v1/help/search",e)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async chat(e){return this.http.post("/v1/help/chat",e)}chatStream(e){return this.http.streamPost("/v1/help/chat/stream",e)}async voteUsefulness(e,t,s){return this.http.post(`/v1/help/articles/by-id/${encodeURIComponent(e)}/vote-usefulness`,{vote:t,previousVote:s})}};var d=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"page",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"page",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var E=class{http;entries;announcements;blog;changelog;config;feedback;help;pages;constructor(e){if(!e.apiKey&&!e.projectId)throw new Error("Either apiKey or projectId is required");this.http=new C({apiKey:e.apiKey,projectId:e.projectId,baseUrl:e.baseUrl}),this.entries=new l(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new c(this.entries),this.config=new g(this.http),this.feedback=new y(this.http),this.help=new P(this.http,this.entries),this.pages=new d(this.entries);}async health(){return this.http.get("/v1/health")}};exports.AnnouncementModule=m;exports.BlogModule=p;exports.ChangelogModule=c;exports.ConfigModule=g;exports.EntriesModule=l;exports.FeedbackModule=y;exports.HelpModule=P;exports.Kookee=E;exports.KookeeApiError=i;exports.PagesModule=d;
1
+ 'use strict';var k="https://api.kookee.dev",B="Kookee-API-Key",I="Kookee-Project-Id",i=class s extends Error{constructor(t,r,o){super(r);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,s.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??k;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[B]=this.apiKey),this.projectId&&(e[I]=this.projectId),e}async get(e,t){let r=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,n]of Object.entries(t))if(n!=null)if(Array.isArray(n))for(let a of n)r.searchParams.append(h,String(a));else r.searchParams.set(h,String(n));}let o=await fetch(r.toString(),{method:"GET",headers:this.getHeaders()});return this.handleResponse(o)}async post(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(r)}async delete(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(r)}async*streamPost(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{...this.getHeaders(),Accept:"text/event-stream"},body:t?JSON.stringify(t):void 0});if(!r.ok){let a=null;try{a=await r.json();}catch{}throw new i(a?.code??"UNKNOWN_ERROR",a?.message??`Request failed with status ${r.status}`,r.status)}if(!r.body)return;let o=r.body.getReader(),h=new TextDecoder,n="";try{for(;;){let{done:a,value:b}=await o.read();if(a)break;n+=h.decode(b,{stream:!0});let E=n.split(`
2
+ `);n=E.pop()??"";for(let x of E){let u=x.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let R=u.slice(6);if(R==="[DONE]")return;yield JSON.parse(R);}}}}finally{o.releaseLock();}}async handleResponse(e){if(!e.ok){let t=null;try{t=await e.json();}catch{}throw new i(t?.code??"UNKNOWN_ERROR",t?.message??`Request failed with status ${e.status}`,e.status)}return e.json()}};var m=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"announcement",...e})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var p=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"blog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"blog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTags(){return this.entries.getTags("blog")}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var c=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"changelog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"changelog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var g=class{constructor(e){this.http=e;}async getByKey(e){return this.http.get(`/v1/config/${encodeURIComponent(e)}`)}async list(e){return this.http.get("/v1/config",e)}};var l=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/entries",e)}async getById(e,t){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}`,t)}async getBySlug(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}`,t)}async getTranslationsById(e){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}/translations`)}async getTranslationsBySlug(e){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/translations`)}async getComments(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/comments`,t)}async react(e,t){return this.http.post(`/v1/entries/${encodeURIComponent(e)}/reactions`,t)}async getTags(e){return this.http.get("/v1/tags",{type:e})}async getCategories(e,t){return this.http.get("/v1/categories",{type:e,...t})}};var y=class{constructor(e,t){this.http=e;this.getUserContext=t;}async list(e){return this.http.get("/v1/feedback",e)}async getById(e){return this.http.get(`/v1/feedback/by-id/${encodeURIComponent(e)}`)}async vote(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/vote`,t)}async getTopContributors(e){return this.http.get("/v1/feedback/top-contributors",e)}async createPost(e){let t=e.externalUser??this.getUserContext();if(!t)throw new Error("No user identified. Call kookee.identify() first or pass externalUser in params.");return this.http.post("/v1/feedback",{...e,externalUser:t})}async createComment(e,t){let r=t.externalUser??this.getUserContext();if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalUser in params.");return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/comments`,{...t,externalUser:r})}async listMyPosts(e){let t=e?.externalId??this.getUserContext()?.externalId;if(!t)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.get("/v1/feedback/mine",{...e,externalId:t})}async deletePost(e,t){let r=t?.externalId??this.getUserContext()?.externalId;if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,{externalId:r})}async deleteComment(e,t){let r=t?.externalId??this.getUserContext()?.externalId;if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/comments/${encodeURIComponent(e)}`,{externalId:r})}};var d=class{http;entries;constructor(e,t){this.http=e,this.entries=t;}async categories(e){return this.entries.getCategories("help_article",e)}async list(e){return this.entries.list({type:"help_article",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"help_article",...t})}async getById(e,t){return this.entries.getById(e,t)}async search(e){return this.http.get("/v1/help/search",e)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}async chat(e){return this.http.post("/v1/help/chat",e)}chatStream(e){return this.http.streamPost("/v1/help/chat/stream",e)}};var P=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"page",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"page",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var f=class{http;user=null;entries;announcements;blog;changelog;config;feedback;help;pages;constructor(e){if(!e.apiKey&&!e.projectId)throw new Error("Either apiKey or projectId is required");this.http=new C({apiKey:e.apiKey,projectId:e.projectId,baseUrl:e.baseUrl}),this.entries=new l(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new c(this.entries),this.config=new g(this.http),this.feedback=new y(this.http,()=>this.user),this.help=new d(this.http,this.entries),this.pages=new P(this.entries);}identify(e){this.user=e;}reset(){this.user=null;}getUser(){return this.user}async health(){return this.http.get("/v1/health")}};exports.AnnouncementModule=m;exports.BlogModule=p;exports.ChangelogModule=c;exports.ConfigModule=g;exports.EntriesModule=l;exports.FeedbackModule=y;exports.HelpModule=d;exports.Kookee=f;exports.KookeeApiError=i;exports.PagesModule=P;
package/dist/index.d.cts CHANGED
@@ -34,16 +34,12 @@ interface HealthCheckResponse {
34
34
  }
35
35
  type ReactionType = 'fire' | 'heart' | 'rocket' | 'eyes' | 'mindblown';
36
36
  interface ReactParams {
37
- reactionType: ReactionType;
37
+ reactionType: string;
38
38
  action: 'add' | 'remove';
39
39
  }
40
40
  interface ReactResponse {
41
41
  reactions: Record<string, number>;
42
42
  }
43
- interface VoteUsefulnessResponse {
44
- usefulYesCount: number;
45
- usefulNoCount: number;
46
- }
47
43
  type OrderDirection = 'asc' | 'desc';
48
44
  interface HelpChatMessage {
49
45
  role: 'user' | 'assistant';
@@ -94,8 +90,6 @@ interface HelpSearchResult {
94
90
  };
95
91
  locale: string;
96
92
  matchedChunk?: string;
97
- usefulYesCount: number;
98
- usefulNoCount: number;
99
93
  }
100
94
  type FeedbackPostStatus = 'open' | 'under_review' | 'planned' | 'in_progress' | 'completed' | 'declined';
101
95
  type FeedbackPostCategory = 'feature' | 'improvement' | 'bug' | 'other';
@@ -145,21 +139,23 @@ interface FeedbackTopContributor {
145
139
  interface FeedbackVoteResponse {
146
140
  voteCount: number;
147
141
  }
148
- interface ExternalUser {
142
+ interface KookeeUser {
149
143
  externalId: string;
150
144
  name: string;
151
145
  email?: string;
152
146
  avatarUrl?: string;
147
+ [key: string]: unknown;
153
148
  }
149
+ type ExternalUser = KookeeUser;
154
150
  interface CreateFeedbackPostParams {
155
151
  title: string;
156
152
  description?: string;
157
153
  category?: FeedbackPostCategory;
158
- externalUser: ExternalUser;
154
+ externalUser?: ExternalUser;
159
155
  }
160
156
  interface CreateFeedbackCommentParams {
161
157
  content: string;
162
- externalUser: ExternalUser;
158
+ externalUser?: ExternalUser;
163
159
  }
164
160
  interface CreatedFeedbackPost {
165
161
  id: string;
@@ -182,7 +178,7 @@ interface CreatedFeedbackComment {
182
178
  updatedAt: string;
183
179
  }
184
180
  interface ListMyFeedbackPostsParams {
185
- externalId: string;
181
+ externalId?: string;
186
182
  page?: number;
187
183
  limit?: number;
188
184
  status?: FeedbackPostStatus;
@@ -191,13 +187,13 @@ interface ListMyFeedbackPostsParams {
191
187
  sort?: FeedbackSortOption;
192
188
  }
193
189
  interface DeleteFeedbackPostParams {
194
- externalId: string;
190
+ externalId?: string;
195
191
  }
196
192
  interface DeleteFeedbackPostResponse {
197
193
  success: boolean;
198
194
  }
199
195
  interface DeleteFeedbackCommentParams {
200
- externalId: string;
196
+ externalId?: string;
201
197
  }
202
198
  interface DeleteFeedbackCommentResponse {
203
199
  success: boolean;
@@ -268,8 +264,6 @@ interface PageTypeSpecific {
268
264
  interface HelpArticleTypeSpecific {
269
265
  _type: 'help_article';
270
266
  visibility: HelpArticleVisibility;
271
- usefulYesCount: number;
272
- usefulNoCount: number;
273
267
  }
274
268
  interface ChangelogTypeSpecific {
275
269
  _type: 'changelog';
@@ -443,16 +437,17 @@ interface FeedbackTopContributorsParams {
443
437
  }
444
438
  declare class FeedbackModule {
445
439
  private readonly http;
446
- constructor(http: HttpClient);
440
+ private readonly getUserContext;
441
+ constructor(http: HttpClient, getUserContext: () => KookeeUser | null);
447
442
  list(params?: FeedbackListParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
448
443
  getById(id: string): Promise<FeedbackPost>;
449
444
  vote(postId: string, params: FeedbackVoteParams): Promise<FeedbackVoteResponse>;
450
445
  getTopContributors(params?: FeedbackTopContributorsParams): Promise<FeedbackTopContributor[]>;
451
446
  createPost(params: CreateFeedbackPostParams): Promise<CreatedFeedbackPost>;
452
447
  createComment(postId: string, params: CreateFeedbackCommentParams): Promise<CreatedFeedbackComment>;
453
- listMyPosts(params: ListMyFeedbackPostsParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
454
- deletePost(postId: string, params: DeleteFeedbackPostParams): Promise<DeleteFeedbackPostResponse>;
455
- deleteComment(commentId: string, params: DeleteFeedbackCommentParams): Promise<DeleteFeedbackCommentResponse>;
448
+ listMyPosts(params?: ListMyFeedbackPostsParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
449
+ deletePost(postId: string, params?: DeleteFeedbackPostParams): Promise<DeleteFeedbackPostResponse>;
450
+ deleteComment(commentId: string, params?: DeleteFeedbackCommentParams): Promise<DeleteFeedbackCommentResponse>;
456
451
  }
457
452
 
458
453
  interface HelpCategoriesParams extends LocaleOptions {
@@ -483,9 +478,9 @@ declare class HelpModule {
483
478
  getTranslationsById(articleId: string): Promise<Record<string, HelpArticleEntry>>;
484
479
  getTranslationsBySlug(slug: string): Promise<Record<string, HelpArticleEntry>>;
485
480
  getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
481
+ react(articleId: string, params: ReactParams): Promise<ReactResponse>;
486
482
  chat(params: HelpChatParams): Promise<HelpChatResponse>;
487
483
  chatStream(params: HelpChatParams): AsyncIterable<HelpChatStreamChunk>;
488
- voteUsefulness(articleId: string, vote: 'yes' | 'no' | null, previousVote?: 'yes' | 'no' | null): Promise<VoteUsefulnessResponse>;
489
484
  }
490
485
 
491
486
  interface PagesListParams extends PaginationParams, LocaleOptions {
@@ -510,6 +505,7 @@ declare class PagesModule {
510
505
 
511
506
  declare class Kookee {
512
507
  private readonly http;
508
+ private user;
513
509
  readonly entries: EntriesModule;
514
510
  readonly announcements: AnnouncementModule;
515
511
  readonly blog: BlogModule;
@@ -519,7 +515,10 @@ declare class Kookee {
519
515
  readonly help: HelpModule;
520
516
  readonly pages: PagesModule;
521
517
  constructor(config: KookeeConfig);
518
+ identify(user: KookeeUser): void;
519
+ reset(): void;
520
+ getUser(): KookeeUser | null;
522
521
  health(): Promise<HealthCheckResponse>;
523
522
  }
524
523
 
525
- export { type AnnouncementEntry, type AnnouncementGetByIdParams, type AnnouncementGetCommentsParams, type AnnouncementListParams, AnnouncementModule, type AnnouncementType, type AnnouncementTypeSpecific, type AnyEntry, type ApiError, type BaseEntry, type BlogEntry, type BlogGetByIdParams, type BlogGetBySlugParams, type BlogGetCommentsParams, type BlogListParams, BlogModule, type BlogTypeSpecific, type ChangelogEntry, type ChangelogGetByIdParams, type ChangelogGetBySlugParams, type ChangelogGetCommentsParams, type ChangelogListParams, ChangelogModule, type ChangelogType, type ChangelogTypeSpecific, type ConfigListParams, ConfigModule, type CreateFeedbackCommentParams, type CreateFeedbackPostParams, type CreatedFeedbackComment, type CreatedFeedbackPost, type DeleteFeedbackCommentParams, type DeleteFeedbackCommentResponse, type DeleteFeedbackPostParams, type DeleteFeedbackPostResponse, type EntriesGetByIdParams, type EntriesGetBySlugParams, type EntriesGetCategoriesParams, type EntriesGetCommentsParams, type EntriesListParams, EntriesModule, type EntryAuthor, type EntryCategory, type EntryComment, type EntryStatus, type EntryTag, type EntryTagWithCount, type EntryType, type ExternalUser, type FeedbackAssignee, type FeedbackAuthor, type FeedbackComment, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, type FeedbackPostStatus, type FeedbackSortOption, type FeedbackTopContributor, type FeedbackTopContributorsParams, type FeedbackVoteParams, type FeedbackVoteResponse, type GenericEntry, type HealthCheckResponse, type HelpArticleEntry, type HelpArticleTypeSpecific, type HelpArticleVisibility, type HelpCategoriesParams, type HelpChatMessage, type HelpChatParams, type HelpChatResponse, type HelpChatSource, type HelpChatSourceCategory, type HelpChatStreamChunk, type HelpGetByIdParams, type HelpGetBySlugParams, type HelpGetCommentsParams, type HelpListParams, HelpModule, type HelpSearchParams, type HelpSearchResult, Kookee, KookeeApiError, type KookeeConfig, type ListMyFeedbackPostsParams, type LocaleOptions, type OrderDirection, type PageEntry, type PageTypeSpecific, type PagesGetByIdParams, type PagesGetBySlugParams, type PagesGetCommentsParams, type PagesListParams, PagesModule, type PaginatedResponse, type PaginationParams, type PublicConfig, type ReactParams, type ReactResponse, type ReactionType, type TypeSpecific, type TypedEntry, type VoteUsefulnessResponse };
524
+ export { type AnnouncementEntry, type AnnouncementGetByIdParams, type AnnouncementGetCommentsParams, type AnnouncementListParams, AnnouncementModule, type AnnouncementType, type AnnouncementTypeSpecific, type AnyEntry, type ApiError, type BaseEntry, type BlogEntry, type BlogGetByIdParams, type BlogGetBySlugParams, type BlogGetCommentsParams, type BlogListParams, BlogModule, type BlogTypeSpecific, type ChangelogEntry, type ChangelogGetByIdParams, type ChangelogGetBySlugParams, type ChangelogGetCommentsParams, type ChangelogListParams, ChangelogModule, type ChangelogType, type ChangelogTypeSpecific, type ConfigListParams, ConfigModule, type CreateFeedbackCommentParams, type CreateFeedbackPostParams, type CreatedFeedbackComment, type CreatedFeedbackPost, type DeleteFeedbackCommentParams, type DeleteFeedbackCommentResponse, type DeleteFeedbackPostParams, type DeleteFeedbackPostResponse, type EntriesGetByIdParams, type EntriesGetBySlugParams, type EntriesGetCategoriesParams, type EntriesGetCommentsParams, type EntriesListParams, EntriesModule, type EntryAuthor, type EntryCategory, type EntryComment, type EntryStatus, type EntryTag, type EntryTagWithCount, type EntryType, type ExternalUser, type FeedbackAssignee, type FeedbackAuthor, type FeedbackComment, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, type FeedbackPostStatus, type FeedbackSortOption, type FeedbackTopContributor, type FeedbackTopContributorsParams, type FeedbackVoteParams, type FeedbackVoteResponse, type GenericEntry, type HealthCheckResponse, type HelpArticleEntry, type HelpArticleTypeSpecific, type HelpArticleVisibility, type HelpCategoriesParams, type HelpChatMessage, type HelpChatParams, type HelpChatResponse, type HelpChatSource, type HelpChatSourceCategory, type HelpChatStreamChunk, type HelpGetByIdParams, type HelpGetBySlugParams, type HelpGetCommentsParams, type HelpListParams, HelpModule, type HelpSearchParams, type HelpSearchResult, Kookee, KookeeApiError, type KookeeConfig, type KookeeUser, type ListMyFeedbackPostsParams, type LocaleOptions, type OrderDirection, type PageEntry, type PageTypeSpecific, type PagesGetByIdParams, type PagesGetBySlugParams, type PagesGetCommentsParams, type PagesListParams, PagesModule, type PaginatedResponse, type PaginationParams, type PublicConfig, type ReactParams, type ReactResponse, type ReactionType, type TypeSpecific, type TypedEntry };
package/dist/index.d.ts CHANGED
@@ -34,16 +34,12 @@ interface HealthCheckResponse {
34
34
  }
35
35
  type ReactionType = 'fire' | 'heart' | 'rocket' | 'eyes' | 'mindblown';
36
36
  interface ReactParams {
37
- reactionType: ReactionType;
37
+ reactionType: string;
38
38
  action: 'add' | 'remove';
39
39
  }
40
40
  interface ReactResponse {
41
41
  reactions: Record<string, number>;
42
42
  }
43
- interface VoteUsefulnessResponse {
44
- usefulYesCount: number;
45
- usefulNoCount: number;
46
- }
47
43
  type OrderDirection = 'asc' | 'desc';
48
44
  interface HelpChatMessage {
49
45
  role: 'user' | 'assistant';
@@ -94,8 +90,6 @@ interface HelpSearchResult {
94
90
  };
95
91
  locale: string;
96
92
  matchedChunk?: string;
97
- usefulYesCount: number;
98
- usefulNoCount: number;
99
93
  }
100
94
  type FeedbackPostStatus = 'open' | 'under_review' | 'planned' | 'in_progress' | 'completed' | 'declined';
101
95
  type FeedbackPostCategory = 'feature' | 'improvement' | 'bug' | 'other';
@@ -145,21 +139,23 @@ interface FeedbackTopContributor {
145
139
  interface FeedbackVoteResponse {
146
140
  voteCount: number;
147
141
  }
148
- interface ExternalUser {
142
+ interface KookeeUser {
149
143
  externalId: string;
150
144
  name: string;
151
145
  email?: string;
152
146
  avatarUrl?: string;
147
+ [key: string]: unknown;
153
148
  }
149
+ type ExternalUser = KookeeUser;
154
150
  interface CreateFeedbackPostParams {
155
151
  title: string;
156
152
  description?: string;
157
153
  category?: FeedbackPostCategory;
158
- externalUser: ExternalUser;
154
+ externalUser?: ExternalUser;
159
155
  }
160
156
  interface CreateFeedbackCommentParams {
161
157
  content: string;
162
- externalUser: ExternalUser;
158
+ externalUser?: ExternalUser;
163
159
  }
164
160
  interface CreatedFeedbackPost {
165
161
  id: string;
@@ -182,7 +178,7 @@ interface CreatedFeedbackComment {
182
178
  updatedAt: string;
183
179
  }
184
180
  interface ListMyFeedbackPostsParams {
185
- externalId: string;
181
+ externalId?: string;
186
182
  page?: number;
187
183
  limit?: number;
188
184
  status?: FeedbackPostStatus;
@@ -191,13 +187,13 @@ interface ListMyFeedbackPostsParams {
191
187
  sort?: FeedbackSortOption;
192
188
  }
193
189
  interface DeleteFeedbackPostParams {
194
- externalId: string;
190
+ externalId?: string;
195
191
  }
196
192
  interface DeleteFeedbackPostResponse {
197
193
  success: boolean;
198
194
  }
199
195
  interface DeleteFeedbackCommentParams {
200
- externalId: string;
196
+ externalId?: string;
201
197
  }
202
198
  interface DeleteFeedbackCommentResponse {
203
199
  success: boolean;
@@ -268,8 +264,6 @@ interface PageTypeSpecific {
268
264
  interface HelpArticleTypeSpecific {
269
265
  _type: 'help_article';
270
266
  visibility: HelpArticleVisibility;
271
- usefulYesCount: number;
272
- usefulNoCount: number;
273
267
  }
274
268
  interface ChangelogTypeSpecific {
275
269
  _type: 'changelog';
@@ -443,16 +437,17 @@ interface FeedbackTopContributorsParams {
443
437
  }
444
438
  declare class FeedbackModule {
445
439
  private readonly http;
446
- constructor(http: HttpClient);
440
+ private readonly getUserContext;
441
+ constructor(http: HttpClient, getUserContext: () => KookeeUser | null);
447
442
  list(params?: FeedbackListParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
448
443
  getById(id: string): Promise<FeedbackPost>;
449
444
  vote(postId: string, params: FeedbackVoteParams): Promise<FeedbackVoteResponse>;
450
445
  getTopContributors(params?: FeedbackTopContributorsParams): Promise<FeedbackTopContributor[]>;
451
446
  createPost(params: CreateFeedbackPostParams): Promise<CreatedFeedbackPost>;
452
447
  createComment(postId: string, params: CreateFeedbackCommentParams): Promise<CreatedFeedbackComment>;
453
- listMyPosts(params: ListMyFeedbackPostsParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
454
- deletePost(postId: string, params: DeleteFeedbackPostParams): Promise<DeleteFeedbackPostResponse>;
455
- deleteComment(commentId: string, params: DeleteFeedbackCommentParams): Promise<DeleteFeedbackCommentResponse>;
448
+ listMyPosts(params?: ListMyFeedbackPostsParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
449
+ deletePost(postId: string, params?: DeleteFeedbackPostParams): Promise<DeleteFeedbackPostResponse>;
450
+ deleteComment(commentId: string, params?: DeleteFeedbackCommentParams): Promise<DeleteFeedbackCommentResponse>;
456
451
  }
457
452
 
458
453
  interface HelpCategoriesParams extends LocaleOptions {
@@ -483,9 +478,9 @@ declare class HelpModule {
483
478
  getTranslationsById(articleId: string): Promise<Record<string, HelpArticleEntry>>;
484
479
  getTranslationsBySlug(slug: string): Promise<Record<string, HelpArticleEntry>>;
485
480
  getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
481
+ react(articleId: string, params: ReactParams): Promise<ReactResponse>;
486
482
  chat(params: HelpChatParams): Promise<HelpChatResponse>;
487
483
  chatStream(params: HelpChatParams): AsyncIterable<HelpChatStreamChunk>;
488
- voteUsefulness(articleId: string, vote: 'yes' | 'no' | null, previousVote?: 'yes' | 'no' | null): Promise<VoteUsefulnessResponse>;
489
484
  }
490
485
 
491
486
  interface PagesListParams extends PaginationParams, LocaleOptions {
@@ -510,6 +505,7 @@ declare class PagesModule {
510
505
 
511
506
  declare class Kookee {
512
507
  private readonly http;
508
+ private user;
513
509
  readonly entries: EntriesModule;
514
510
  readonly announcements: AnnouncementModule;
515
511
  readonly blog: BlogModule;
@@ -519,7 +515,10 @@ declare class Kookee {
519
515
  readonly help: HelpModule;
520
516
  readonly pages: PagesModule;
521
517
  constructor(config: KookeeConfig);
518
+ identify(user: KookeeUser): void;
519
+ reset(): void;
520
+ getUser(): KookeeUser | null;
522
521
  health(): Promise<HealthCheckResponse>;
523
522
  }
524
523
 
525
- export { type AnnouncementEntry, type AnnouncementGetByIdParams, type AnnouncementGetCommentsParams, type AnnouncementListParams, AnnouncementModule, type AnnouncementType, type AnnouncementTypeSpecific, type AnyEntry, type ApiError, type BaseEntry, type BlogEntry, type BlogGetByIdParams, type BlogGetBySlugParams, type BlogGetCommentsParams, type BlogListParams, BlogModule, type BlogTypeSpecific, type ChangelogEntry, type ChangelogGetByIdParams, type ChangelogGetBySlugParams, type ChangelogGetCommentsParams, type ChangelogListParams, ChangelogModule, type ChangelogType, type ChangelogTypeSpecific, type ConfigListParams, ConfigModule, type CreateFeedbackCommentParams, type CreateFeedbackPostParams, type CreatedFeedbackComment, type CreatedFeedbackPost, type DeleteFeedbackCommentParams, type DeleteFeedbackCommentResponse, type DeleteFeedbackPostParams, type DeleteFeedbackPostResponse, type EntriesGetByIdParams, type EntriesGetBySlugParams, type EntriesGetCategoriesParams, type EntriesGetCommentsParams, type EntriesListParams, EntriesModule, type EntryAuthor, type EntryCategory, type EntryComment, type EntryStatus, type EntryTag, type EntryTagWithCount, type EntryType, type ExternalUser, type FeedbackAssignee, type FeedbackAuthor, type FeedbackComment, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, type FeedbackPostStatus, type FeedbackSortOption, type FeedbackTopContributor, type FeedbackTopContributorsParams, type FeedbackVoteParams, type FeedbackVoteResponse, type GenericEntry, type HealthCheckResponse, type HelpArticleEntry, type HelpArticleTypeSpecific, type HelpArticleVisibility, type HelpCategoriesParams, type HelpChatMessage, type HelpChatParams, type HelpChatResponse, type HelpChatSource, type HelpChatSourceCategory, type HelpChatStreamChunk, type HelpGetByIdParams, type HelpGetBySlugParams, type HelpGetCommentsParams, type HelpListParams, HelpModule, type HelpSearchParams, type HelpSearchResult, Kookee, KookeeApiError, type KookeeConfig, type ListMyFeedbackPostsParams, type LocaleOptions, type OrderDirection, type PageEntry, type PageTypeSpecific, type PagesGetByIdParams, type PagesGetBySlugParams, type PagesGetCommentsParams, type PagesListParams, PagesModule, type PaginatedResponse, type PaginationParams, type PublicConfig, type ReactParams, type ReactResponse, type ReactionType, type TypeSpecific, type TypedEntry, type VoteUsefulnessResponse };
524
+ export { type AnnouncementEntry, type AnnouncementGetByIdParams, type AnnouncementGetCommentsParams, type AnnouncementListParams, AnnouncementModule, type AnnouncementType, type AnnouncementTypeSpecific, type AnyEntry, type ApiError, type BaseEntry, type BlogEntry, type BlogGetByIdParams, type BlogGetBySlugParams, type BlogGetCommentsParams, type BlogListParams, BlogModule, type BlogTypeSpecific, type ChangelogEntry, type ChangelogGetByIdParams, type ChangelogGetBySlugParams, type ChangelogGetCommentsParams, type ChangelogListParams, ChangelogModule, type ChangelogType, type ChangelogTypeSpecific, type ConfigListParams, ConfigModule, type CreateFeedbackCommentParams, type CreateFeedbackPostParams, type CreatedFeedbackComment, type CreatedFeedbackPost, type DeleteFeedbackCommentParams, type DeleteFeedbackCommentResponse, type DeleteFeedbackPostParams, type DeleteFeedbackPostResponse, type EntriesGetByIdParams, type EntriesGetBySlugParams, type EntriesGetCategoriesParams, type EntriesGetCommentsParams, type EntriesListParams, EntriesModule, type EntryAuthor, type EntryCategory, type EntryComment, type EntryStatus, type EntryTag, type EntryTagWithCount, type EntryType, type ExternalUser, type FeedbackAssignee, type FeedbackAuthor, type FeedbackComment, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, type FeedbackPostStatus, type FeedbackSortOption, type FeedbackTopContributor, type FeedbackTopContributorsParams, type FeedbackVoteParams, type FeedbackVoteResponse, type GenericEntry, type HealthCheckResponse, type HelpArticleEntry, type HelpArticleTypeSpecific, type HelpArticleVisibility, type HelpCategoriesParams, type HelpChatMessage, type HelpChatParams, type HelpChatResponse, type HelpChatSource, type HelpChatSourceCategory, type HelpChatStreamChunk, type HelpGetByIdParams, type HelpGetBySlugParams, type HelpGetCommentsParams, type HelpListParams, HelpModule, type HelpSearchParams, type HelpSearchResult, Kookee, KookeeApiError, type KookeeConfig, type KookeeUser, type ListMyFeedbackPostsParams, type LocaleOptions, type OrderDirection, type PageEntry, type PageTypeSpecific, type PagesGetByIdParams, type PagesGetBySlugParams, type PagesGetCommentsParams, type PagesListParams, PagesModule, type PaginatedResponse, type PaginationParams, type PublicConfig, type ReactParams, type ReactResponse, type ReactionType, type TypeSpecific, type TypedEntry };
@@ -1,2 +1,2 @@
1
- (function(exports){'use strict';var k="https://api.kookee.dev",x="Kookee-API-Key",I="Kookee-Project-Id",i=class r extends Error{constructor(t,s,o){super(s);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,r.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??k;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[x]=this.apiKey),this.projectId&&(e[I]=this.projectId),e}async get(e,t){let s=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,n]of Object.entries(t))if(n!=null)if(Array.isArray(n))for(let a of n)s.searchParams.append(h,String(a));else s.searchParams.set(h,String(n));}let o=await fetch(s.toString(),{method:"GET",headers:this.getHeaders()});return this.handleResponse(o)}async post(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(s)}async delete(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(s)}async*streamPost(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{...this.getHeaders(),Accept:"text/event-stream"},body:t?JSON.stringify(t):void 0});if(!s.ok){let a=null;try{a=await s.json();}catch{}throw new i(a?.code??"UNKNOWN_ERROR",a?.message??`Request failed with status ${s.status}`,s.status)}if(!s.body)return;let o=s.body.getReader(),h=new TextDecoder,n="";try{for(;;){let{done:a,value:b}=await o.read();if(a)break;n+=h.decode(b,{stream:!0});let f=n.split(`
2
- `);n=f.pop()??"";for(let B of f){let u=B.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let R=u.slice(6);if(R==="[DONE]")return;yield JSON.parse(R);}}}}finally{o.releaseLock();}}async handleResponse(e){if(!e.ok){let t=null;try{t=await e.json();}catch{}throw new i(t?.code??"UNKNOWN_ERROR",t?.message??`Request failed with status ${e.status}`,e.status)}return e.json()}};var m=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"announcement",...e})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var p=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"blog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"blog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTags(){return this.entries.getTags("blog")}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var c=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"changelog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"changelog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var g=class{constructor(e){this.http=e;}async getByKey(e){return this.http.get(`/v1/config/${encodeURIComponent(e)}`)}async list(e){return this.http.get("/v1/config",e)}};var l=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/entries",e)}async getById(e,t){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}`,t)}async getBySlug(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}`,t)}async getTranslationsById(e){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}/translations`)}async getTranslationsBySlug(e){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/translations`)}async getComments(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/comments`,t)}async react(e,t){return this.http.post(`/v1/entries/${encodeURIComponent(e)}/reactions`,t)}async getTags(e){return this.http.get("/v1/tags",{type:e})}async getCategories(e,t){return this.http.get("/v1/categories",{type:e,...t})}};var y=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/feedback",e)}async getById(e){return this.http.get(`/v1/feedback/by-id/${encodeURIComponent(e)}`)}async vote(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/vote`,t)}async getTopContributors(e){return this.http.get("/v1/feedback/top-contributors",e)}async createPost(e){return this.http.post("/v1/feedback",e)}async createComment(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/comments`,t)}async listMyPosts(e){return this.http.get("/v1/feedback/mine",e)}async deletePost(e,t){return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,t)}async deleteComment(e,t){return this.http.delete(`/v1/feedback/comments/${encodeURIComponent(e)}`,t)}};var P=class{http;entries;constructor(e,t){this.http=e,this.entries=t;}async categories(e){return this.entries.getCategories("help_article",e)}async list(e){return this.entries.list({type:"help_article",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"help_article",...t})}async getById(e,t){return this.entries.getById(e,t)}async search(e){return this.http.get("/v1/help/search",e)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async chat(e){return this.http.post("/v1/help/chat",e)}chatStream(e){return this.http.streamPost("/v1/help/chat/stream",e)}async voteUsefulness(e,t,s){return this.http.post(`/v1/help/articles/by-id/${encodeURIComponent(e)}/vote-usefulness`,{vote:t,previousVote:s})}};var d=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"page",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"page",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var E=class{http;entries;announcements;blog;changelog;config;feedback;help;pages;constructor(e){if(!e.apiKey&&!e.projectId)throw new Error("Either apiKey or projectId is required");this.http=new C({apiKey:e.apiKey,projectId:e.projectId,baseUrl:e.baseUrl}),this.entries=new l(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new c(this.entries),this.config=new g(this.http),this.feedback=new y(this.http),this.help=new P(this.http,this.entries),this.pages=new d(this.entries);}async health(){return this.http.get("/v1/health")}};exports.AnnouncementModule=m;exports.BlogModule=p;exports.ChangelogModule=c;exports.ConfigModule=g;exports.EntriesModule=l;exports.FeedbackModule=y;exports.HelpModule=P;exports.Kookee=E;exports.KookeeApiError=i;exports.PagesModule=d;return exports;})({});
1
+ (function(exports){'use strict';var k="https://api.kookee.dev",B="Kookee-API-Key",I="Kookee-Project-Id",i=class s extends Error{constructor(t,r,o){super(r);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,s.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??k;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[B]=this.apiKey),this.projectId&&(e[I]=this.projectId),e}async get(e,t){let r=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,n]of Object.entries(t))if(n!=null)if(Array.isArray(n))for(let a of n)r.searchParams.append(h,String(a));else r.searchParams.set(h,String(n));}let o=await fetch(r.toString(),{method:"GET",headers:this.getHeaders()});return this.handleResponse(o)}async post(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(r)}async delete(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(r)}async*streamPost(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{...this.getHeaders(),Accept:"text/event-stream"},body:t?JSON.stringify(t):void 0});if(!r.ok){let a=null;try{a=await r.json();}catch{}throw new i(a?.code??"UNKNOWN_ERROR",a?.message??`Request failed with status ${r.status}`,r.status)}if(!r.body)return;let o=r.body.getReader(),h=new TextDecoder,n="";try{for(;;){let{done:a,value:b}=await o.read();if(a)break;n+=h.decode(b,{stream:!0});let E=n.split(`
2
+ `);n=E.pop()??"";for(let x of E){let u=x.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let R=u.slice(6);if(R==="[DONE]")return;yield JSON.parse(R);}}}}finally{o.releaseLock();}}async handleResponse(e){if(!e.ok){let t=null;try{t=await e.json();}catch{}throw new i(t?.code??"UNKNOWN_ERROR",t?.message??`Request failed with status ${e.status}`,e.status)}return e.json()}};var m=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"announcement",...e})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var p=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"blog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"blog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTags(){return this.entries.getTags("blog")}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var c=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"changelog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"changelog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var g=class{constructor(e){this.http=e;}async getByKey(e){return this.http.get(`/v1/config/${encodeURIComponent(e)}`)}async list(e){return this.http.get("/v1/config",e)}};var l=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/entries",e)}async getById(e,t){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}`,t)}async getBySlug(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}`,t)}async getTranslationsById(e){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}/translations`)}async getTranslationsBySlug(e){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/translations`)}async getComments(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/comments`,t)}async react(e,t){return this.http.post(`/v1/entries/${encodeURIComponent(e)}/reactions`,t)}async getTags(e){return this.http.get("/v1/tags",{type:e})}async getCategories(e,t){return this.http.get("/v1/categories",{type:e,...t})}};var y=class{constructor(e,t){this.http=e;this.getUserContext=t;}async list(e){return this.http.get("/v1/feedback",e)}async getById(e){return this.http.get(`/v1/feedback/by-id/${encodeURIComponent(e)}`)}async vote(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/vote`,t)}async getTopContributors(e){return this.http.get("/v1/feedback/top-contributors",e)}async createPost(e){let t=e.externalUser??this.getUserContext();if(!t)throw new Error("No user identified. Call kookee.identify() first or pass externalUser in params.");return this.http.post("/v1/feedback",{...e,externalUser:t})}async createComment(e,t){let r=t.externalUser??this.getUserContext();if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalUser in params.");return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/comments`,{...t,externalUser:r})}async listMyPosts(e){let t=e?.externalId??this.getUserContext()?.externalId;if(!t)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.get("/v1/feedback/mine",{...e,externalId:t})}async deletePost(e,t){let r=t?.externalId??this.getUserContext()?.externalId;if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,{externalId:r})}async deleteComment(e,t){let r=t?.externalId??this.getUserContext()?.externalId;if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/comments/${encodeURIComponent(e)}`,{externalId:r})}};var d=class{http;entries;constructor(e,t){this.http=e,this.entries=t;}async categories(e){return this.entries.getCategories("help_article",e)}async list(e){return this.entries.list({type:"help_article",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"help_article",...t})}async getById(e,t){return this.entries.getById(e,t)}async search(e){return this.http.get("/v1/help/search",e)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}async chat(e){return this.http.post("/v1/help/chat",e)}chatStream(e){return this.http.streamPost("/v1/help/chat/stream",e)}};var P=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"page",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"page",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var f=class{http;user=null;entries;announcements;blog;changelog;config;feedback;help;pages;constructor(e){if(!e.apiKey&&!e.projectId)throw new Error("Either apiKey or projectId is required");this.http=new C({apiKey:e.apiKey,projectId:e.projectId,baseUrl:e.baseUrl}),this.entries=new l(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new c(this.entries),this.config=new g(this.http),this.feedback=new y(this.http,()=>this.user),this.help=new d(this.http,this.entries),this.pages=new P(this.entries);}identify(e){this.user=e;}reset(){this.user=null;}getUser(){return this.user}async health(){return this.http.get("/v1/health")}};exports.AnnouncementModule=m;exports.BlogModule=p;exports.ChangelogModule=c;exports.ConfigModule=g;exports.EntriesModule=l;exports.FeedbackModule=y;exports.HelpModule=d;exports.Kookee=f;exports.KookeeApiError=i;exports.PagesModule=P;return exports;})({});
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var k="https://api.kookee.dev",x="Kookee-API-Key",I="Kookee-Project-Id",i=class r extends Error{constructor(t,s,o){super(s);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,r.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??k;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[x]=this.apiKey),this.projectId&&(e[I]=this.projectId),e}async get(e,t){let s=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,n]of Object.entries(t))if(n!=null)if(Array.isArray(n))for(let a of n)s.searchParams.append(h,String(a));else s.searchParams.set(h,String(n));}let o=await fetch(s.toString(),{method:"GET",headers:this.getHeaders()});return this.handleResponse(o)}async post(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(s)}async delete(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(s)}async*streamPost(e,t){let s=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{...this.getHeaders(),Accept:"text/event-stream"},body:t?JSON.stringify(t):void 0});if(!s.ok){let a=null;try{a=await s.json();}catch{}throw new i(a?.code??"UNKNOWN_ERROR",a?.message??`Request failed with status ${s.status}`,s.status)}if(!s.body)return;let o=s.body.getReader(),h=new TextDecoder,n="";try{for(;;){let{done:a,value:b}=await o.read();if(a)break;n+=h.decode(b,{stream:!0});let f=n.split(`
2
- `);n=f.pop()??"";for(let B of f){let u=B.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let R=u.slice(6);if(R==="[DONE]")return;yield JSON.parse(R);}}}}finally{o.releaseLock();}}async handleResponse(e){if(!e.ok){let t=null;try{t=await e.json();}catch{}throw new i(t?.code??"UNKNOWN_ERROR",t?.message??`Request failed with status ${e.status}`,e.status)}return e.json()}};var m=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"announcement",...e})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var p=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"blog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"blog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTags(){return this.entries.getTags("blog")}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var c=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"changelog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"changelog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var g=class{constructor(e){this.http=e;}async getByKey(e){return this.http.get(`/v1/config/${encodeURIComponent(e)}`)}async list(e){return this.http.get("/v1/config",e)}};var l=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/entries",e)}async getById(e,t){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}`,t)}async getBySlug(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}`,t)}async getTranslationsById(e){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}/translations`)}async getTranslationsBySlug(e){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/translations`)}async getComments(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/comments`,t)}async react(e,t){return this.http.post(`/v1/entries/${encodeURIComponent(e)}/reactions`,t)}async getTags(e){return this.http.get("/v1/tags",{type:e})}async getCategories(e,t){return this.http.get("/v1/categories",{type:e,...t})}};var y=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/feedback",e)}async getById(e){return this.http.get(`/v1/feedback/by-id/${encodeURIComponent(e)}`)}async vote(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/vote`,t)}async getTopContributors(e){return this.http.get("/v1/feedback/top-contributors",e)}async createPost(e){return this.http.post("/v1/feedback",e)}async createComment(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/comments`,t)}async listMyPosts(e){return this.http.get("/v1/feedback/mine",e)}async deletePost(e,t){return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,t)}async deleteComment(e,t){return this.http.delete(`/v1/feedback/comments/${encodeURIComponent(e)}`,t)}};var P=class{http;entries;constructor(e,t){this.http=e,this.entries=t;}async categories(e){return this.entries.getCategories("help_article",e)}async list(e){return this.entries.list({type:"help_article",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"help_article",...t})}async getById(e,t){return this.entries.getById(e,t)}async search(e){return this.http.get("/v1/help/search",e)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async chat(e){return this.http.post("/v1/help/chat",e)}chatStream(e){return this.http.streamPost("/v1/help/chat/stream",e)}async voteUsefulness(e,t,s){return this.http.post(`/v1/help/articles/by-id/${encodeURIComponent(e)}/vote-usefulness`,{vote:t,previousVote:s})}};var d=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"page",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"page",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var E=class{http;entries;announcements;blog;changelog;config;feedback;help;pages;constructor(e){if(!e.apiKey&&!e.projectId)throw new Error("Either apiKey or projectId is required");this.http=new C({apiKey:e.apiKey,projectId:e.projectId,baseUrl:e.baseUrl}),this.entries=new l(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new c(this.entries),this.config=new g(this.http),this.feedback=new y(this.http),this.help=new P(this.http,this.entries),this.pages=new d(this.entries);}async health(){return this.http.get("/v1/health")}};export{m as AnnouncementModule,p as BlogModule,c as ChangelogModule,g as ConfigModule,l as EntriesModule,y as FeedbackModule,P as HelpModule,E as Kookee,i as KookeeApiError,d as PagesModule};
1
+ var k="https://api.kookee.dev",B="Kookee-API-Key",I="Kookee-Project-Id",i=class s extends Error{constructor(t,r,o){super(r);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,s.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??k;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[B]=this.apiKey),this.projectId&&(e[I]=this.projectId),e}async get(e,t){let r=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,n]of Object.entries(t))if(n!=null)if(Array.isArray(n))for(let a of n)r.searchParams.append(h,String(a));else r.searchParams.set(h,String(n));}let o=await fetch(r.toString(),{method:"GET",headers:this.getHeaders()});return this.handleResponse(o)}async post(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(r)}async delete(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:this.getHeaders(),body:t?JSON.stringify(t):void 0});return this.handleResponse(r)}async*streamPost(e,t){let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{...this.getHeaders(),Accept:"text/event-stream"},body:t?JSON.stringify(t):void 0});if(!r.ok){let a=null;try{a=await r.json();}catch{}throw new i(a?.code??"UNKNOWN_ERROR",a?.message??`Request failed with status ${r.status}`,r.status)}if(!r.body)return;let o=r.body.getReader(),h=new TextDecoder,n="";try{for(;;){let{done:a,value:b}=await o.read();if(a)break;n+=h.decode(b,{stream:!0});let E=n.split(`
2
+ `);n=E.pop()??"";for(let x of E){let u=x.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let R=u.slice(6);if(R==="[DONE]")return;yield JSON.parse(R);}}}}finally{o.releaseLock();}}async handleResponse(e){if(!e.ok){let t=null;try{t=await e.json();}catch{}throw new i(t?.code??"UNKNOWN_ERROR",t?.message??`Request failed with status ${e.status}`,e.status)}return e.json()}};var m=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"announcement",...e})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var p=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"blog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"blog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTags(){return this.entries.getTags("blog")}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var c=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"changelog",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"changelog",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}};var g=class{constructor(e){this.http=e;}async getByKey(e){return this.http.get(`/v1/config/${encodeURIComponent(e)}`)}async list(e){return this.http.get("/v1/config",e)}};var l=class{constructor(e){this.http=e;}async list(e){return this.http.get("/v1/entries",e)}async getById(e,t){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}`,t)}async getBySlug(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}`,t)}async getTranslationsById(e){return this.http.get(`/v1/entries/by-id/${encodeURIComponent(e)}/translations`)}async getTranslationsBySlug(e){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/translations`)}async getComments(e,t){return this.http.get(`/v1/entries/${encodeURIComponent(e)}/comments`,t)}async react(e,t){return this.http.post(`/v1/entries/${encodeURIComponent(e)}/reactions`,t)}async getTags(e){return this.http.get("/v1/tags",{type:e})}async getCategories(e,t){return this.http.get("/v1/categories",{type:e,...t})}};var y=class{constructor(e,t){this.http=e;this.getUserContext=t;}async list(e){return this.http.get("/v1/feedback",e)}async getById(e){return this.http.get(`/v1/feedback/by-id/${encodeURIComponent(e)}`)}async vote(e,t){return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/vote`,t)}async getTopContributors(e){return this.http.get("/v1/feedback/top-contributors",e)}async createPost(e){let t=e.externalUser??this.getUserContext();if(!t)throw new Error("No user identified. Call kookee.identify() first or pass externalUser in params.");return this.http.post("/v1/feedback",{...e,externalUser:t})}async createComment(e,t){let r=t.externalUser??this.getUserContext();if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalUser in params.");return this.http.post(`/v1/feedback/${encodeURIComponent(e)}/comments`,{...t,externalUser:r})}async listMyPosts(e){let t=e?.externalId??this.getUserContext()?.externalId;if(!t)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.get("/v1/feedback/mine",{...e,externalId:t})}async deletePost(e,t){let r=t?.externalId??this.getUserContext()?.externalId;if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,{externalId:r})}async deleteComment(e,t){let r=t?.externalId??this.getUserContext()?.externalId;if(!r)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/comments/${encodeURIComponent(e)}`,{externalId:r})}};var d=class{http;entries;constructor(e,t){this.http=e,this.entries=t;}async categories(e){return this.entries.getCategories("help_article",e)}async list(e){return this.entries.list({type:"help_article",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"help_article",...t})}async getById(e,t){return this.entries.getById(e,t)}async search(e){return this.http.get("/v1/help/search",e)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}async react(e,t){return this.entries.react(e,t)}async chat(e){return this.http.post("/v1/help/chat",e)}chatStream(e){return this.http.streamPost("/v1/help/chat/stream",e)}};var P=class{constructor(e){this.entries=e;}async list(e){return this.entries.list({type:"page",...e})}async getBySlug(e,t){return this.entries.getBySlug(e,{type:"page",...t})}async getById(e,t){return this.entries.getById(e,t)}async getTranslationsById(e){return this.entries.getTranslationsById(e)}async getTranslationsBySlug(e){return this.entries.getTranslationsBySlug(e)}async getComments(e,t){return this.entries.getComments(e,t)}};var f=class{http;user=null;entries;announcements;blog;changelog;config;feedback;help;pages;constructor(e){if(!e.apiKey&&!e.projectId)throw new Error("Either apiKey or projectId is required");this.http=new C({apiKey:e.apiKey,projectId:e.projectId,baseUrl:e.baseUrl}),this.entries=new l(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new c(this.entries),this.config=new g(this.http),this.feedback=new y(this.http,()=>this.user),this.help=new d(this.http,this.entries),this.pages=new P(this.entries);}identify(e){this.user=e;}reset(){this.user=null;}getUser(){return this.user}async health(){return this.http.get("/v1/health")}};export{m as AnnouncementModule,p as BlogModule,c as ChangelogModule,g as ConfigModule,l as EntriesModule,y as FeedbackModule,d as HelpModule,f as Kookee,i as KookeeApiError,P as PagesModule};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kookee/sdk",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Official Kookee SDK - Access your blog, changelog, help center, and more",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",