@kookee/sdk 0.0.36 → 0.0.38

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
@@ -360,11 +360,18 @@ const posts = await kookee.blog.list({ locale: 'de' });
360
360
  const post = await kookee.blog.getBySlug('hello-world', { locale: 'de', fallback: true });
361
361
  ```
362
362
 
363
- Translation endpoints return a `Record<string, T>` keyed by locale code:
363
+ Translation endpoints return a narrow `EntryTranslationsMap` keyed by locale code. Each value is a lightweight summary (`id`, `slug`, `locale`, `title`) — **not** a full entry. To load the full body of a translation, fetch it with `getBySlug` / `getById` using the target locale:
364
364
 
365
365
  ```typescript
366
366
  const translations = await kookee.blog.getTranslationsBySlug('hello-world');
367
- // { en: BlogEntry, de: BlogEntry, fr: BlogEntry, ... }
367
+ // {
368
+ // en: { id, slug, locale: 'en', title },
369
+ // de: { id, slug, locale: 'de', title },
370
+ // ...
371
+ // }
372
+
373
+ // To load the full German version:
374
+ const germanPost = await kookee.blog.getBySlug('hello-world', { locale: 'de' });
368
375
  ```
369
376
 
370
377
  ## Paginated Response
@@ -376,12 +383,53 @@ interface PaginatedResponse<T> {
376
383
  data: T[];
377
384
  total: number;
378
385
  limit: number;
379
- offset: number;
380
386
  page: number;
381
387
  totalPages: number;
382
388
  }
383
389
  ```
384
390
 
391
+ ## List vs. Detail Responses
392
+
393
+ Entry endpoints come in two flavours with **different shapes**:
394
+
395
+ - **List responses** (`blog.list()`, `help.search()`, `entries.list()`, …) return `*ListItem` types — these do **not** include `contentHtml`. Use `excerptHtml` instead for previews.
396
+ - **Detail responses** (`blog.getBySlug()`, `help.getById()`, …) return `*Detail` types — these include `contentHtml` for full content rendering.
397
+
398
+ ```typescript
399
+ // List: no contentHtml, only excerptHtml
400
+ const posts = await kookee.blog.list({ limit: 10 });
401
+ for (const post of posts.data) {
402
+ renderPreview(post.excerptHtml); // ✅ available on list
403
+ // renderFull(post.contentHtml); // ❌ type error — not on list
404
+ }
405
+
406
+ // Detail: contentHtml is available
407
+ const post = await kookee.blog.getBySlug('hello-world');
408
+ renderFull(post.contentHtml); // ✅ available on detail
409
+ ```
410
+
411
+ ## Categories on entries
412
+
413
+ Every entry response (list *and* detail) includes both `categoryId: string | null` **and** a resolved `category: EntryCategoryRef | null`. No client-side join required:
414
+
415
+ ```typescript
416
+ const results = await kookee.help.search({ query: 'how to reset password' });
417
+ for (const result of results) {
418
+ // result.category is already populated by the server
419
+ console.log(result.title, '→', result.category?.name);
420
+ }
421
+
422
+ type EntryCategoryRef = {
423
+ id: string;
424
+ slug: string;
425
+ name: string;
426
+ icon: string | null;
427
+ description: string | null;
428
+ };
429
+ ```
430
+
431
+ When an entry has no category assigned, `category` is `null` and `categoryId` is `null` — guard accordingly.
432
+
385
433
  ## Error Handling
386
434
 
387
435
  ```typescript
@@ -423,23 +471,47 @@ The SDK is written in TypeScript and provides full type definitions:
423
471
 
424
472
  ```typescript
425
473
  import type {
426
- // Entry types
474
+ // Entry base & shared
427
475
  BaseEntry,
428
- GenericEntry,
429
- BlogEntry,
430
- PageEntry,
431
- HelpArticleEntry,
432
- ChangelogEntry,
433
- AnnouncementEntry,
434
- TypedEntry,
435
- AnyEntry,
476
+ EntryDetailFields,
436
477
  EntryType,
437
478
  EntryStatus,
438
479
  EntryAuthor,
439
480
  EntryTag,
440
481
  EntryTagWithCount,
441
482
  EntryCategory,
483
+ EntryCategoryRef,
442
484
  EntryComment,
485
+ EntryTranslationSummary,
486
+ EntryTranslationsMap,
487
+
488
+ // Entry variants — LIST responses (no contentHtml)
489
+ GenericEntryListItem,
490
+ BlogEntryListItem,
491
+ PageEntryListItem,
492
+ HelpArticleListItem,
493
+ ChangelogEntryListItem,
494
+ AnnouncementListItem,
495
+ TypedEntryListItem,
496
+ AnyEntryListItem,
497
+
498
+ // Entry variants — DETAIL responses (with contentHtml)
499
+ GenericEntryDetail,
500
+ BlogEntryDetail,
501
+ PageEntryDetail,
502
+ HelpArticleDetail,
503
+ ChangelogEntryDetail,
504
+ AnnouncementDetail,
505
+ TypedEntryDetail,
506
+ AnyEntryDetail,
507
+
508
+ // Type-specific metadata
509
+ TypeSpecific,
510
+ BlogTypeSpecific,
511
+ PageTypeSpecific,
512
+ HelpArticleTypeSpecific,
513
+ ChangelogTypeSpecific,
514
+ AnnouncementTypeSpecific,
443
515
 
444
516
  // Changelog & Announcement specific
445
517
  ChangelogType,
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
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 getColumns(){return this.http.get("/v1/feedback/columns")}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;
1
+ 'use strict';var R="https://api.kookee.dev",I="Kookee-API-Key",B="Kookee-Project-Id",i=class n extends Error{constructor(t,s,o){super(s);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,n.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??R;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[I]=this.apiKey),this.projectId&&(e[B]=this.projectId),e}async get(e,t){let s=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,r]of Object.entries(t))if(r!=null)if(Array.isArray(r))for(let a of r)s.searchParams.append(h,String(a));else s.searchParams.set(h,String(r));}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,r="";try{for(;;){let{done:a,value:k}=await o.read();if(a)break;r+=h.decode(k,{stream:!0});let E=r.split(`
2
+ `);r=E.pop()??"";for(let x of E){let u=x.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let b=u.slice(6);if(b==="[DONE]")return;yield JSON.parse(b);}}}}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 l=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 c=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 g=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 getColumns(){return this.http.get("/v1/feedback/columns")}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 s=t.externalUser??this.getUserContext();if(!s)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:s})}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 s=t?.externalId??this.getUserContext()?.externalId;if(!s)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,{externalId:s})}async deleteComment(e,t){let s=t?.externalId??this.getUserContext()?.externalId;if(!s)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:s})}};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 g(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new l(this.entries),this.config=new c(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=l;exports.ConfigModule=c;exports.EntriesModule=g;exports.FeedbackModule=y;exports.HelpModule=d;exports.Kookee=f;exports.KookeeApiError=i;exports.PagesModule=P;
package/dist/index.d.cts CHANGED
@@ -15,7 +15,6 @@ interface PaginatedResponse<T> {
15
15
  data: T[];
16
16
  total: number;
17
17
  limit: number;
18
- offset: number;
19
18
  page: number;
20
19
  totalPages: number;
21
20
  }
@@ -61,11 +60,11 @@ interface HelpChatSourceCategory {
61
60
  }
62
61
  interface HelpChatSource {
63
62
  id: string;
64
- slug: string;
63
+ slug: string | null;
65
64
  title: string;
66
- visibility: HelpArticleVisibility;
65
+ visibility: string | null;
67
66
  metadata: Record<string, NonNullable<unknown>> | null;
68
- category: HelpChatSourceCategory;
67
+ category: HelpChatSourceCategory | null;
69
68
  }
70
69
  type HelpChatStreamChunk = {
71
70
  type: 'delta';
@@ -79,18 +78,6 @@ type HelpChatStreamChunk = {
79
78
  type: 'error';
80
79
  message: string;
81
80
  };
82
- interface HelpSearchResult {
83
- id: string;
84
- slug: string;
85
- title: string;
86
- excerptHtml: string | null;
87
- category: {
88
- name: string;
89
- slug: string;
90
- };
91
- locale: string;
92
- matchedChunk?: string;
93
- }
94
81
  type FeedbackColumnType = 'open' | 'closed';
95
82
  interface FeedbackKanbanColumn {
96
83
  id: string;
@@ -104,7 +91,7 @@ type FeedbackPostCategory = 'feature' | 'improvement' | 'bug' | 'other';
104
91
  type FeedbackSortOption = 'newest' | 'top' | 'trending';
105
92
  interface FeedbackAuthor {
106
93
  id: string;
107
- name: string;
94
+ name: string | null;
108
95
  image: string | null;
109
96
  isTeamMember?: boolean;
110
97
  externalId?: string | null;
@@ -130,6 +117,7 @@ interface FeedbackPostListItem {
130
117
  columnName: string | null;
131
118
  columnColor: string | null;
132
119
  columnType: FeedbackColumnType | null;
120
+ kanbanPosition: number;
133
121
  category: FeedbackPostCategory;
134
122
  voteCount: number;
135
123
  commentCount: number;
@@ -143,7 +131,7 @@ interface FeedbackPost extends FeedbackPostListItem {
143
131
  }
144
132
  interface FeedbackTopContributor {
145
133
  id: string;
146
- name: string;
134
+ name: string | null;
147
135
  image: string | null;
148
136
  totalVotes: number;
149
137
  }
@@ -214,12 +202,21 @@ type EntryType = 'blog' | 'page' | 'help_article' | 'changelog' | 'announcement'
214
202
  type EntryStatus = 'draft' | 'published' | 'archived';
215
203
  type ChangelogType = 'feature' | 'fix' | 'improvement' | 'breaking' | 'security' | 'deprecated' | 'other';
216
204
  type AnnouncementType = 'info' | 'warning' | 'critical' | 'promotion' | 'maintenance' | 'newFeature';
205
+ /**
206
+ * Author shape returned on public entry responses.
207
+ *
208
+ * NOTE: `name` and `image` can be `null` on the server side.
209
+ */
217
210
  interface EntryAuthor {
218
- name: string;
211
+ id: string;
212
+ name: string | null;
213
+ image: string | null;
219
214
  }
220
215
  interface EntryTag {
216
+ id: string;
221
217
  name: string;
222
218
  slug: string;
219
+ color: string | null;
223
220
  }
224
221
  interface EntryTagWithCount extends EntryTag {
225
222
  count: number;
@@ -239,33 +236,52 @@ interface EntryComment {
239
236
  updatedAt: string;
240
237
  author: EntryAuthor;
241
238
  }
239
+ /**
240
+ * Resolved category attached to a public entry response.
241
+ *
242
+ * This is the server's `EntryCategory` row projected down to the fields
243
+ * that are safe/useful to expose publicly.
244
+ */
245
+ interface EntryCategoryRef {
246
+ id: string;
247
+ slug: string;
248
+ name: string;
249
+ icon: string | null;
250
+ description: string | null;
251
+ }
252
+ /**
253
+ * Fields that appear on BOTH list and detail entry responses.
254
+ */
242
255
  interface BaseEntry {
243
256
  id: string;
244
257
  type: string;
245
258
  slug: string | null;
246
259
  title: string;
247
260
  excerptHtml: string | null;
248
- contentHtml: string;
249
- status: EntryStatus;
250
261
  publishedAt: string | null;
251
262
  locale: string;
252
263
  translationGroupId: string;
253
264
  categoryId: string | null;
265
+ category: EntryCategoryRef | null;
254
266
  coverImageUrl: string | null;
255
267
  position: number;
256
268
  views: number;
257
269
  metaTitle: string | null;
258
270
  metaDescription: string | null;
259
271
  metadata: Record<string, NonNullable<unknown>> | null;
272
+ reactions: Record<string, number>;
260
273
  createdAt: string;
261
274
  updatedAt: string;
262
275
  author: EntryAuthor;
263
276
  tags: EntryTag[];
264
- reactions: Record<string, number>;
265
- category: {
266
- name: string;
267
- slug: string;
268
- } | null;
277
+ }
278
+ /**
279
+ * Fields added on entry DETAIL responses only.
280
+ *
281
+ * `contentHtml` is NOT returned on list endpoints.
282
+ */
283
+ interface EntryDetailFields {
284
+ contentHtml: string;
269
285
  }
270
286
  interface BlogTypeSpecific {
271
287
  _type: 'blog';
@@ -289,31 +305,79 @@ interface AnnouncementTypeSpecific {
289
305
  unpublishAt: string | null;
290
306
  }
291
307
  type TypeSpecific = BlogTypeSpecific | PageTypeSpecific | HelpArticleTypeSpecific | ChangelogTypeSpecific | AnnouncementTypeSpecific;
292
- interface GenericEntry extends BaseEntry {
308
+ interface GenericEntryListItem extends BaseEntry {
293
309
  typeSpecific: unknown;
294
310
  }
295
- interface BlogEntry extends BaseEntry {
311
+ interface GenericEntryDetail extends BaseEntry, EntryDetailFields {
312
+ typeSpecific: unknown;
313
+ }
314
+ interface BlogEntryListItem extends BaseEntry {
296
315
  type: 'blog';
297
316
  typeSpecific: BlogTypeSpecific;
298
317
  }
299
- interface PageEntry extends BaseEntry {
318
+ interface BlogEntryDetail extends BaseEntry, EntryDetailFields {
319
+ type: 'blog';
320
+ typeSpecific: BlogTypeSpecific;
321
+ }
322
+ interface PageEntryListItem extends BaseEntry {
323
+ type: 'page';
324
+ typeSpecific: PageTypeSpecific;
325
+ }
326
+ interface PageEntryDetail extends BaseEntry, EntryDetailFields {
300
327
  type: 'page';
301
328
  typeSpecific: PageTypeSpecific;
302
329
  }
303
- interface HelpArticleEntry extends BaseEntry {
330
+ interface HelpArticleListItem extends BaseEntry {
331
+ type: 'help_article';
332
+ typeSpecific: HelpArticleTypeSpecific;
333
+ }
334
+ interface HelpArticleDetail extends BaseEntry, EntryDetailFields {
304
335
  type: 'help_article';
305
336
  typeSpecific: HelpArticleTypeSpecific;
306
337
  }
307
- interface ChangelogEntry extends BaseEntry {
338
+ interface ChangelogEntryListItem extends BaseEntry {
308
339
  type: 'changelog';
309
340
  typeSpecific: ChangelogTypeSpecific;
310
341
  }
311
- interface AnnouncementEntry extends BaseEntry {
342
+ interface ChangelogEntryDetail extends BaseEntry, EntryDetailFields {
343
+ type: 'changelog';
344
+ typeSpecific: ChangelogTypeSpecific;
345
+ }
346
+ interface AnnouncementListItem extends BaseEntry {
312
347
  type: 'announcement';
313
348
  typeSpecific: AnnouncementTypeSpecific;
314
349
  }
315
- type TypedEntry = BlogEntry | PageEntry | HelpArticleEntry | ChangelogEntry | AnnouncementEntry;
316
- type AnyEntry = TypedEntry | GenericEntry;
350
+ interface AnnouncementDetail extends BaseEntry, EntryDetailFields {
351
+ type: 'announcement';
352
+ typeSpecific: AnnouncementTypeSpecific;
353
+ }
354
+ type TypedEntryListItem = BlogEntryListItem | PageEntryListItem | HelpArticleListItem | ChangelogEntryListItem | AnnouncementListItem;
355
+ type TypedEntryDetail = BlogEntryDetail | PageEntryDetail | HelpArticleDetail | ChangelogEntryDetail | AnnouncementDetail;
356
+ type AnyEntryListItem = TypedEntryListItem | GenericEntryListItem;
357
+ type AnyEntryDetail = TypedEntryDetail | GenericEntryDetail;
358
+ /**
359
+ * Help search result — returned by `GET /v1/help/search`.
360
+ *
361
+ * The server returns the exact same shape as a help article list response,
362
+ * so we alias it to `HelpArticleListItem`. There is no nested `category`
363
+ * object or `matchedChunk` field on this response (SDK <= 0.0.36 lied
364
+ * about both).
365
+ */
366
+ type HelpSearchResult = HelpArticleListItem;
367
+ /**
368
+ * Translation summary returned by the translations endpoints.
369
+ *
370
+ * The server returns a narrow { id, slug, locale, title } shape keyed by
371
+ * locale — NOT a full entry. Consumers that need the full body should
372
+ * fetch each translation individually via getBySlug / getById.
373
+ */
374
+ interface EntryTranslationSummary {
375
+ id: string;
376
+ slug: string | null;
377
+ locale: string;
378
+ title: string;
379
+ }
380
+ type EntryTranslationsMap = Record<string, EntryTranslationSummary>;
317
381
 
318
382
  declare class KookeeApiError extends Error {
319
383
  readonly code: string;
@@ -355,11 +419,11 @@ interface EntriesGetCategoriesParams extends LocaleOptions {
355
419
  declare class EntriesModule {
356
420
  private readonly http;
357
421
  constructor(http: HttpClient);
358
- list(params: EntriesListParams): Promise<PaginatedResponse<GenericEntry>>;
359
- getById(id: string, params?: EntriesGetByIdParams): Promise<GenericEntry>;
360
- getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<GenericEntry>;
361
- getTranslationsById(id: string): Promise<Record<string, GenericEntry>>;
362
- getTranslationsBySlug(slug: string): Promise<Record<string, GenericEntry>>;
422
+ list(params: EntriesListParams): Promise<PaginatedResponse<GenericEntryListItem>>;
423
+ getById(id: string, params?: EntriesGetByIdParams): Promise<GenericEntryDetail>;
424
+ getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<GenericEntryDetail>;
425
+ getTranslationsById(id: string): Promise<EntryTranslationsMap>;
426
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
363
427
  getComments(entryId: string, params?: EntriesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
364
428
  react(entryId: string, params: ReactParams): Promise<ReactResponse>;
365
429
  getTags(type: string): Promise<EntryTagWithCount[]>;
@@ -375,9 +439,9 @@ interface AnnouncementGetCommentsParams extends PaginationParams {
375
439
  declare class AnnouncementModule {
376
440
  private readonly entries;
377
441
  constructor(entries: EntriesModule);
378
- list(params?: AnnouncementListParams): Promise<PaginatedResponse<AnnouncementEntry>>;
379
- getById(id: string, params?: AnnouncementGetByIdParams): Promise<AnnouncementEntry>;
380
- getTranslationsById(id: string): Promise<Record<string, AnnouncementEntry>>;
442
+ list(params?: AnnouncementListParams): Promise<PaginatedResponse<AnnouncementListItem>>;
443
+ getById(id: string, params?: AnnouncementGetByIdParams): Promise<AnnouncementDetail>;
444
+ getTranslationsById(id: string): Promise<EntryTranslationsMap>;
381
445
  getComments(entryId: string, params?: AnnouncementGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
382
446
  }
383
447
 
@@ -394,12 +458,12 @@ interface BlogGetCommentsParams extends PaginationParams {
394
458
  declare class BlogModule {
395
459
  private readonly entries;
396
460
  constructor(entries: EntriesModule);
397
- list(params?: BlogListParams): Promise<PaginatedResponse<BlogEntry>>;
398
- getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<BlogEntry>;
399
- getById(id: string, params?: BlogGetByIdParams): Promise<BlogEntry>;
461
+ list(params?: BlogListParams): Promise<PaginatedResponse<BlogEntryListItem>>;
462
+ getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<BlogEntryDetail>;
463
+ getById(id: string, params?: BlogGetByIdParams): Promise<BlogEntryDetail>;
400
464
  getTags(): Promise<EntryTagWithCount[]>;
401
- getTranslationsById(postId: string): Promise<Record<string, BlogEntry>>;
402
- getTranslationsBySlug(slug: string): Promise<Record<string, BlogEntry>>;
465
+ getTranslationsById(postId: string): Promise<EntryTranslationsMap>;
466
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
403
467
  getComments(entryId: string, params?: BlogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
404
468
  react(postId: string, params: ReactParams): Promise<ReactResponse>;
405
469
  }
@@ -416,11 +480,11 @@ interface ChangelogGetCommentsParams extends PaginationParams {
416
480
  declare class ChangelogModule {
417
481
  private readonly entries;
418
482
  constructor(entries: EntriesModule);
419
- list(params?: ChangelogListParams): Promise<PaginatedResponse<ChangelogEntry>>;
420
- getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<ChangelogEntry>;
421
- getById(id: string, params?: ChangelogGetByIdParams): Promise<ChangelogEntry>;
422
- getTranslationsById(id: string): Promise<Record<string, ChangelogEntry>>;
423
- getTranslationsBySlug(slug: string): Promise<Record<string, ChangelogEntry>>;
483
+ list(params?: ChangelogListParams): Promise<PaginatedResponse<ChangelogEntryListItem>>;
484
+ getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<ChangelogEntryDetail>;
485
+ getById(id: string, params?: ChangelogGetByIdParams): Promise<ChangelogEntryDetail>;
486
+ getTranslationsById(id: string): Promise<EntryTranslationsMap>;
487
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
424
488
  getComments(entryId: string, params?: ChangelogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
425
489
  react(changelogId: string, params: ReactParams): Promise<ReactResponse>;
426
490
  }
@@ -485,12 +549,12 @@ declare class HelpModule {
485
549
  private readonly entries;
486
550
  constructor(http: HttpClient, entries: EntriesModule);
487
551
  categories(params?: HelpCategoriesParams): Promise<EntryCategory[]>;
488
- list(params?: HelpListParams): Promise<PaginatedResponse<HelpArticleEntry>>;
489
- getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<HelpArticleEntry>;
490
- getById(id: string, params?: HelpGetByIdParams): Promise<HelpArticleEntry>;
552
+ list(params?: HelpListParams): Promise<PaginatedResponse<HelpArticleListItem>>;
553
+ getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<HelpArticleDetail>;
554
+ getById(id: string, params?: HelpGetByIdParams): Promise<HelpArticleDetail>;
491
555
  search(params: HelpSearchParams): Promise<HelpSearchResult[]>;
492
- getTranslationsById(articleId: string): Promise<Record<string, HelpArticleEntry>>;
493
- getTranslationsBySlug(slug: string): Promise<Record<string, HelpArticleEntry>>;
556
+ getTranslationsById(articleId: string): Promise<EntryTranslationsMap>;
557
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
494
558
  getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
495
559
  react(articleId: string, params: ReactParams): Promise<ReactResponse>;
496
560
  chat(params: HelpChatParams): Promise<HelpChatResponse>;
@@ -509,11 +573,11 @@ interface PagesGetCommentsParams extends PaginationParams {
509
573
  declare class PagesModule {
510
574
  private readonly entries;
511
575
  constructor(entries: EntriesModule);
512
- list(params?: PagesListParams): Promise<PaginatedResponse<PageEntry>>;
513
- getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<PageEntry>;
514
- getById(id: string, params?: PagesGetByIdParams): Promise<PageEntry>;
515
- getTranslationsById(pageId: string): Promise<Record<string, PageEntry>>;
516
- getTranslationsBySlug(slug: string): Promise<Record<string, PageEntry>>;
576
+ list(params?: PagesListParams): Promise<PaginatedResponse<PageEntryListItem>>;
577
+ getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<PageEntryDetail>;
578
+ getById(id: string, params?: PagesGetByIdParams): Promise<PageEntryDetail>;
579
+ getTranslationsById(pageId: string): Promise<EntryTranslationsMap>;
580
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
517
581
  getComments(entryId: string, params?: PagesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
518
582
  }
519
583
 
@@ -535,4 +599,4 @@ declare class Kookee {
535
599
  health(): Promise<HealthCheckResponse>;
536
600
  }
537
601
 
538
- 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 FeedbackColumnType, type FeedbackComment, type FeedbackKanbanColumn, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, 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 };
602
+ export { type AnnouncementDetail, type AnnouncementGetByIdParams, type AnnouncementGetCommentsParams, type AnnouncementListItem, type AnnouncementListParams, AnnouncementModule, type AnnouncementType, type AnnouncementTypeSpecific, type AnyEntryDetail, type AnyEntryListItem, type ApiError, type BaseEntry, type BlogEntryDetail, type BlogEntryListItem, type BlogGetByIdParams, type BlogGetBySlugParams, type BlogGetCommentsParams, type BlogListParams, BlogModule, type BlogTypeSpecific, type ChangelogEntryDetail, type ChangelogEntryListItem, 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 EntryCategoryRef, type EntryComment, type EntryDetailFields, type EntryStatus, type EntryTag, type EntryTagWithCount, type EntryTranslationSummary, type EntryTranslationsMap, type EntryType, type ExternalUser, type FeedbackAssignee, type FeedbackAuthor, type FeedbackColumnType, type FeedbackComment, type FeedbackKanbanColumn, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, type FeedbackSortOption, type FeedbackTopContributor, type FeedbackTopContributorsParams, type FeedbackVoteParams, type FeedbackVoteResponse, type GenericEntryDetail, type GenericEntryListItem, type HealthCheckResponse, type HelpArticleDetail, type HelpArticleListItem, 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 PageEntryDetail, type PageEntryListItem, 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 TypedEntryDetail, type TypedEntryListItem };
package/dist/index.d.ts CHANGED
@@ -15,7 +15,6 @@ interface PaginatedResponse<T> {
15
15
  data: T[];
16
16
  total: number;
17
17
  limit: number;
18
- offset: number;
19
18
  page: number;
20
19
  totalPages: number;
21
20
  }
@@ -61,11 +60,11 @@ interface HelpChatSourceCategory {
61
60
  }
62
61
  interface HelpChatSource {
63
62
  id: string;
64
- slug: string;
63
+ slug: string | null;
65
64
  title: string;
66
- visibility: HelpArticleVisibility;
65
+ visibility: string | null;
67
66
  metadata: Record<string, NonNullable<unknown>> | null;
68
- category: HelpChatSourceCategory;
67
+ category: HelpChatSourceCategory | null;
69
68
  }
70
69
  type HelpChatStreamChunk = {
71
70
  type: 'delta';
@@ -79,18 +78,6 @@ type HelpChatStreamChunk = {
79
78
  type: 'error';
80
79
  message: string;
81
80
  };
82
- interface HelpSearchResult {
83
- id: string;
84
- slug: string;
85
- title: string;
86
- excerptHtml: string | null;
87
- category: {
88
- name: string;
89
- slug: string;
90
- };
91
- locale: string;
92
- matchedChunk?: string;
93
- }
94
81
  type FeedbackColumnType = 'open' | 'closed';
95
82
  interface FeedbackKanbanColumn {
96
83
  id: string;
@@ -104,7 +91,7 @@ type FeedbackPostCategory = 'feature' | 'improvement' | 'bug' | 'other';
104
91
  type FeedbackSortOption = 'newest' | 'top' | 'trending';
105
92
  interface FeedbackAuthor {
106
93
  id: string;
107
- name: string;
94
+ name: string | null;
108
95
  image: string | null;
109
96
  isTeamMember?: boolean;
110
97
  externalId?: string | null;
@@ -130,6 +117,7 @@ interface FeedbackPostListItem {
130
117
  columnName: string | null;
131
118
  columnColor: string | null;
132
119
  columnType: FeedbackColumnType | null;
120
+ kanbanPosition: number;
133
121
  category: FeedbackPostCategory;
134
122
  voteCount: number;
135
123
  commentCount: number;
@@ -143,7 +131,7 @@ interface FeedbackPost extends FeedbackPostListItem {
143
131
  }
144
132
  interface FeedbackTopContributor {
145
133
  id: string;
146
- name: string;
134
+ name: string | null;
147
135
  image: string | null;
148
136
  totalVotes: number;
149
137
  }
@@ -214,12 +202,21 @@ type EntryType = 'blog' | 'page' | 'help_article' | 'changelog' | 'announcement'
214
202
  type EntryStatus = 'draft' | 'published' | 'archived';
215
203
  type ChangelogType = 'feature' | 'fix' | 'improvement' | 'breaking' | 'security' | 'deprecated' | 'other';
216
204
  type AnnouncementType = 'info' | 'warning' | 'critical' | 'promotion' | 'maintenance' | 'newFeature';
205
+ /**
206
+ * Author shape returned on public entry responses.
207
+ *
208
+ * NOTE: `name` and `image` can be `null` on the server side.
209
+ */
217
210
  interface EntryAuthor {
218
- name: string;
211
+ id: string;
212
+ name: string | null;
213
+ image: string | null;
219
214
  }
220
215
  interface EntryTag {
216
+ id: string;
221
217
  name: string;
222
218
  slug: string;
219
+ color: string | null;
223
220
  }
224
221
  interface EntryTagWithCount extends EntryTag {
225
222
  count: number;
@@ -239,33 +236,52 @@ interface EntryComment {
239
236
  updatedAt: string;
240
237
  author: EntryAuthor;
241
238
  }
239
+ /**
240
+ * Resolved category attached to a public entry response.
241
+ *
242
+ * This is the server's `EntryCategory` row projected down to the fields
243
+ * that are safe/useful to expose publicly.
244
+ */
245
+ interface EntryCategoryRef {
246
+ id: string;
247
+ slug: string;
248
+ name: string;
249
+ icon: string | null;
250
+ description: string | null;
251
+ }
252
+ /**
253
+ * Fields that appear on BOTH list and detail entry responses.
254
+ */
242
255
  interface BaseEntry {
243
256
  id: string;
244
257
  type: string;
245
258
  slug: string | null;
246
259
  title: string;
247
260
  excerptHtml: string | null;
248
- contentHtml: string;
249
- status: EntryStatus;
250
261
  publishedAt: string | null;
251
262
  locale: string;
252
263
  translationGroupId: string;
253
264
  categoryId: string | null;
265
+ category: EntryCategoryRef | null;
254
266
  coverImageUrl: string | null;
255
267
  position: number;
256
268
  views: number;
257
269
  metaTitle: string | null;
258
270
  metaDescription: string | null;
259
271
  metadata: Record<string, NonNullable<unknown>> | null;
272
+ reactions: Record<string, number>;
260
273
  createdAt: string;
261
274
  updatedAt: string;
262
275
  author: EntryAuthor;
263
276
  tags: EntryTag[];
264
- reactions: Record<string, number>;
265
- category: {
266
- name: string;
267
- slug: string;
268
- } | null;
277
+ }
278
+ /**
279
+ * Fields added on entry DETAIL responses only.
280
+ *
281
+ * `contentHtml` is NOT returned on list endpoints.
282
+ */
283
+ interface EntryDetailFields {
284
+ contentHtml: string;
269
285
  }
270
286
  interface BlogTypeSpecific {
271
287
  _type: 'blog';
@@ -289,31 +305,79 @@ interface AnnouncementTypeSpecific {
289
305
  unpublishAt: string | null;
290
306
  }
291
307
  type TypeSpecific = BlogTypeSpecific | PageTypeSpecific | HelpArticleTypeSpecific | ChangelogTypeSpecific | AnnouncementTypeSpecific;
292
- interface GenericEntry extends BaseEntry {
308
+ interface GenericEntryListItem extends BaseEntry {
293
309
  typeSpecific: unknown;
294
310
  }
295
- interface BlogEntry extends BaseEntry {
311
+ interface GenericEntryDetail extends BaseEntry, EntryDetailFields {
312
+ typeSpecific: unknown;
313
+ }
314
+ interface BlogEntryListItem extends BaseEntry {
296
315
  type: 'blog';
297
316
  typeSpecific: BlogTypeSpecific;
298
317
  }
299
- interface PageEntry extends BaseEntry {
318
+ interface BlogEntryDetail extends BaseEntry, EntryDetailFields {
319
+ type: 'blog';
320
+ typeSpecific: BlogTypeSpecific;
321
+ }
322
+ interface PageEntryListItem extends BaseEntry {
323
+ type: 'page';
324
+ typeSpecific: PageTypeSpecific;
325
+ }
326
+ interface PageEntryDetail extends BaseEntry, EntryDetailFields {
300
327
  type: 'page';
301
328
  typeSpecific: PageTypeSpecific;
302
329
  }
303
- interface HelpArticleEntry extends BaseEntry {
330
+ interface HelpArticleListItem extends BaseEntry {
331
+ type: 'help_article';
332
+ typeSpecific: HelpArticleTypeSpecific;
333
+ }
334
+ interface HelpArticleDetail extends BaseEntry, EntryDetailFields {
304
335
  type: 'help_article';
305
336
  typeSpecific: HelpArticleTypeSpecific;
306
337
  }
307
- interface ChangelogEntry extends BaseEntry {
338
+ interface ChangelogEntryListItem extends BaseEntry {
308
339
  type: 'changelog';
309
340
  typeSpecific: ChangelogTypeSpecific;
310
341
  }
311
- interface AnnouncementEntry extends BaseEntry {
342
+ interface ChangelogEntryDetail extends BaseEntry, EntryDetailFields {
343
+ type: 'changelog';
344
+ typeSpecific: ChangelogTypeSpecific;
345
+ }
346
+ interface AnnouncementListItem extends BaseEntry {
312
347
  type: 'announcement';
313
348
  typeSpecific: AnnouncementTypeSpecific;
314
349
  }
315
- type TypedEntry = BlogEntry | PageEntry | HelpArticleEntry | ChangelogEntry | AnnouncementEntry;
316
- type AnyEntry = TypedEntry | GenericEntry;
350
+ interface AnnouncementDetail extends BaseEntry, EntryDetailFields {
351
+ type: 'announcement';
352
+ typeSpecific: AnnouncementTypeSpecific;
353
+ }
354
+ type TypedEntryListItem = BlogEntryListItem | PageEntryListItem | HelpArticleListItem | ChangelogEntryListItem | AnnouncementListItem;
355
+ type TypedEntryDetail = BlogEntryDetail | PageEntryDetail | HelpArticleDetail | ChangelogEntryDetail | AnnouncementDetail;
356
+ type AnyEntryListItem = TypedEntryListItem | GenericEntryListItem;
357
+ type AnyEntryDetail = TypedEntryDetail | GenericEntryDetail;
358
+ /**
359
+ * Help search result — returned by `GET /v1/help/search`.
360
+ *
361
+ * The server returns the exact same shape as a help article list response,
362
+ * so we alias it to `HelpArticleListItem`. There is no nested `category`
363
+ * object or `matchedChunk` field on this response (SDK <= 0.0.36 lied
364
+ * about both).
365
+ */
366
+ type HelpSearchResult = HelpArticleListItem;
367
+ /**
368
+ * Translation summary returned by the translations endpoints.
369
+ *
370
+ * The server returns a narrow { id, slug, locale, title } shape keyed by
371
+ * locale — NOT a full entry. Consumers that need the full body should
372
+ * fetch each translation individually via getBySlug / getById.
373
+ */
374
+ interface EntryTranslationSummary {
375
+ id: string;
376
+ slug: string | null;
377
+ locale: string;
378
+ title: string;
379
+ }
380
+ type EntryTranslationsMap = Record<string, EntryTranslationSummary>;
317
381
 
318
382
  declare class KookeeApiError extends Error {
319
383
  readonly code: string;
@@ -355,11 +419,11 @@ interface EntriesGetCategoriesParams extends LocaleOptions {
355
419
  declare class EntriesModule {
356
420
  private readonly http;
357
421
  constructor(http: HttpClient);
358
- list(params: EntriesListParams): Promise<PaginatedResponse<GenericEntry>>;
359
- getById(id: string, params?: EntriesGetByIdParams): Promise<GenericEntry>;
360
- getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<GenericEntry>;
361
- getTranslationsById(id: string): Promise<Record<string, GenericEntry>>;
362
- getTranslationsBySlug(slug: string): Promise<Record<string, GenericEntry>>;
422
+ list(params: EntriesListParams): Promise<PaginatedResponse<GenericEntryListItem>>;
423
+ getById(id: string, params?: EntriesGetByIdParams): Promise<GenericEntryDetail>;
424
+ getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<GenericEntryDetail>;
425
+ getTranslationsById(id: string): Promise<EntryTranslationsMap>;
426
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
363
427
  getComments(entryId: string, params?: EntriesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
364
428
  react(entryId: string, params: ReactParams): Promise<ReactResponse>;
365
429
  getTags(type: string): Promise<EntryTagWithCount[]>;
@@ -375,9 +439,9 @@ interface AnnouncementGetCommentsParams extends PaginationParams {
375
439
  declare class AnnouncementModule {
376
440
  private readonly entries;
377
441
  constructor(entries: EntriesModule);
378
- list(params?: AnnouncementListParams): Promise<PaginatedResponse<AnnouncementEntry>>;
379
- getById(id: string, params?: AnnouncementGetByIdParams): Promise<AnnouncementEntry>;
380
- getTranslationsById(id: string): Promise<Record<string, AnnouncementEntry>>;
442
+ list(params?: AnnouncementListParams): Promise<PaginatedResponse<AnnouncementListItem>>;
443
+ getById(id: string, params?: AnnouncementGetByIdParams): Promise<AnnouncementDetail>;
444
+ getTranslationsById(id: string): Promise<EntryTranslationsMap>;
381
445
  getComments(entryId: string, params?: AnnouncementGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
382
446
  }
383
447
 
@@ -394,12 +458,12 @@ interface BlogGetCommentsParams extends PaginationParams {
394
458
  declare class BlogModule {
395
459
  private readonly entries;
396
460
  constructor(entries: EntriesModule);
397
- list(params?: BlogListParams): Promise<PaginatedResponse<BlogEntry>>;
398
- getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<BlogEntry>;
399
- getById(id: string, params?: BlogGetByIdParams): Promise<BlogEntry>;
461
+ list(params?: BlogListParams): Promise<PaginatedResponse<BlogEntryListItem>>;
462
+ getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<BlogEntryDetail>;
463
+ getById(id: string, params?: BlogGetByIdParams): Promise<BlogEntryDetail>;
400
464
  getTags(): Promise<EntryTagWithCount[]>;
401
- getTranslationsById(postId: string): Promise<Record<string, BlogEntry>>;
402
- getTranslationsBySlug(slug: string): Promise<Record<string, BlogEntry>>;
465
+ getTranslationsById(postId: string): Promise<EntryTranslationsMap>;
466
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
403
467
  getComments(entryId: string, params?: BlogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
404
468
  react(postId: string, params: ReactParams): Promise<ReactResponse>;
405
469
  }
@@ -416,11 +480,11 @@ interface ChangelogGetCommentsParams extends PaginationParams {
416
480
  declare class ChangelogModule {
417
481
  private readonly entries;
418
482
  constructor(entries: EntriesModule);
419
- list(params?: ChangelogListParams): Promise<PaginatedResponse<ChangelogEntry>>;
420
- getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<ChangelogEntry>;
421
- getById(id: string, params?: ChangelogGetByIdParams): Promise<ChangelogEntry>;
422
- getTranslationsById(id: string): Promise<Record<string, ChangelogEntry>>;
423
- getTranslationsBySlug(slug: string): Promise<Record<string, ChangelogEntry>>;
483
+ list(params?: ChangelogListParams): Promise<PaginatedResponse<ChangelogEntryListItem>>;
484
+ getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<ChangelogEntryDetail>;
485
+ getById(id: string, params?: ChangelogGetByIdParams): Promise<ChangelogEntryDetail>;
486
+ getTranslationsById(id: string): Promise<EntryTranslationsMap>;
487
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
424
488
  getComments(entryId: string, params?: ChangelogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
425
489
  react(changelogId: string, params: ReactParams): Promise<ReactResponse>;
426
490
  }
@@ -485,12 +549,12 @@ declare class HelpModule {
485
549
  private readonly entries;
486
550
  constructor(http: HttpClient, entries: EntriesModule);
487
551
  categories(params?: HelpCategoriesParams): Promise<EntryCategory[]>;
488
- list(params?: HelpListParams): Promise<PaginatedResponse<HelpArticleEntry>>;
489
- getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<HelpArticleEntry>;
490
- getById(id: string, params?: HelpGetByIdParams): Promise<HelpArticleEntry>;
552
+ list(params?: HelpListParams): Promise<PaginatedResponse<HelpArticleListItem>>;
553
+ getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<HelpArticleDetail>;
554
+ getById(id: string, params?: HelpGetByIdParams): Promise<HelpArticleDetail>;
491
555
  search(params: HelpSearchParams): Promise<HelpSearchResult[]>;
492
- getTranslationsById(articleId: string): Promise<Record<string, HelpArticleEntry>>;
493
- getTranslationsBySlug(slug: string): Promise<Record<string, HelpArticleEntry>>;
556
+ getTranslationsById(articleId: string): Promise<EntryTranslationsMap>;
557
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
494
558
  getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
495
559
  react(articleId: string, params: ReactParams): Promise<ReactResponse>;
496
560
  chat(params: HelpChatParams): Promise<HelpChatResponse>;
@@ -509,11 +573,11 @@ interface PagesGetCommentsParams extends PaginationParams {
509
573
  declare class PagesModule {
510
574
  private readonly entries;
511
575
  constructor(entries: EntriesModule);
512
- list(params?: PagesListParams): Promise<PaginatedResponse<PageEntry>>;
513
- getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<PageEntry>;
514
- getById(id: string, params?: PagesGetByIdParams): Promise<PageEntry>;
515
- getTranslationsById(pageId: string): Promise<Record<string, PageEntry>>;
516
- getTranslationsBySlug(slug: string): Promise<Record<string, PageEntry>>;
576
+ list(params?: PagesListParams): Promise<PaginatedResponse<PageEntryListItem>>;
577
+ getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<PageEntryDetail>;
578
+ getById(id: string, params?: PagesGetByIdParams): Promise<PageEntryDetail>;
579
+ getTranslationsById(pageId: string): Promise<EntryTranslationsMap>;
580
+ getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
517
581
  getComments(entryId: string, params?: PagesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
518
582
  }
519
583
 
@@ -535,4 +599,4 @@ declare class Kookee {
535
599
  health(): Promise<HealthCheckResponse>;
536
600
  }
537
601
 
538
- 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 FeedbackColumnType, type FeedbackComment, type FeedbackKanbanColumn, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, 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 };
602
+ export { type AnnouncementDetail, type AnnouncementGetByIdParams, type AnnouncementGetCommentsParams, type AnnouncementListItem, type AnnouncementListParams, AnnouncementModule, type AnnouncementType, type AnnouncementTypeSpecific, type AnyEntryDetail, type AnyEntryListItem, type ApiError, type BaseEntry, type BlogEntryDetail, type BlogEntryListItem, type BlogGetByIdParams, type BlogGetBySlugParams, type BlogGetCommentsParams, type BlogListParams, BlogModule, type BlogTypeSpecific, type ChangelogEntryDetail, type ChangelogEntryListItem, 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 EntryCategoryRef, type EntryComment, type EntryDetailFields, type EntryStatus, type EntryTag, type EntryTagWithCount, type EntryTranslationSummary, type EntryTranslationsMap, type EntryType, type ExternalUser, type FeedbackAssignee, type FeedbackAuthor, type FeedbackColumnType, type FeedbackComment, type FeedbackKanbanColumn, type FeedbackListParams, FeedbackModule, type FeedbackPost, type FeedbackPostCategory, type FeedbackPostListItem, type FeedbackSortOption, type FeedbackTopContributor, type FeedbackTopContributorsParams, type FeedbackVoteParams, type FeedbackVoteResponse, type GenericEntryDetail, type GenericEntryListItem, type HealthCheckResponse, type HelpArticleDetail, type HelpArticleListItem, 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 PageEntryDetail, type PageEntryListItem, 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 TypedEntryDetail, type TypedEntryListItem };
@@ -1,2 +1,2 @@
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 getColumns(){return this.http.get("/v1/feedback/columns")}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;})({});
1
+ (function(exports){'use strict';var R="https://api.kookee.dev",I="Kookee-API-Key",B="Kookee-Project-Id",i=class n extends Error{constructor(t,s,o){super(s);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,n.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??R;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[I]=this.apiKey),this.projectId&&(e[B]=this.projectId),e}async get(e,t){let s=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,r]of Object.entries(t))if(r!=null)if(Array.isArray(r))for(let a of r)s.searchParams.append(h,String(a));else s.searchParams.set(h,String(r));}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,r="";try{for(;;){let{done:a,value:k}=await o.read();if(a)break;r+=h.decode(k,{stream:!0});let E=r.split(`
2
+ `);r=E.pop()??"";for(let x of E){let u=x.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let b=u.slice(6);if(b==="[DONE]")return;yield JSON.parse(b);}}}}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 l=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 c=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 g=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 getColumns(){return this.http.get("/v1/feedback/columns")}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 s=t.externalUser??this.getUserContext();if(!s)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:s})}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 s=t?.externalId??this.getUserContext()?.externalId;if(!s)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,{externalId:s})}async deleteComment(e,t){let s=t?.externalId??this.getUserContext()?.externalId;if(!s)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:s})}};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 g(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new l(this.entries),this.config=new c(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=l;exports.ConfigModule=c;exports.EntriesModule=g;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",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 getColumns(){return this.http.get("/v1/feedback/columns")}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};
1
+ var R="https://api.kookee.dev",I="Kookee-API-Key",B="Kookee-Project-Id",i=class n extends Error{constructor(t,s,o){super(s);this.code=t;this.status=o;this.name="KookeeApiError",Object.setPrototypeOf(this,n.prototype);}},C=class{baseUrl;apiKey;projectId;constructor(e){this.apiKey=e.apiKey,this.projectId=e.projectId,this.baseUrl=e.baseUrl??R;}getHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e[I]=this.apiKey),this.projectId&&(e[B]=this.projectId),e}async get(e,t){let s=new URL(`${this.baseUrl}${e}`);if(t){for(let[h,r]of Object.entries(t))if(r!=null)if(Array.isArray(r))for(let a of r)s.searchParams.append(h,String(a));else s.searchParams.set(h,String(r));}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,r="";try{for(;;){let{done:a,value:k}=await o.read();if(a)break;r+=h.decode(k,{stream:!0});let E=r.split(`
2
+ `);r=E.pop()??"";for(let x of E){let u=x.trim();if(!(!u||u.startsWith(":"))&&u.startsWith("data: ")){let b=u.slice(6);if(b==="[DONE]")return;yield JSON.parse(b);}}}}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 l=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 c=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 g=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 getColumns(){return this.http.get("/v1/feedback/columns")}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 s=t.externalUser??this.getUserContext();if(!s)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:s})}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 s=t?.externalId??this.getUserContext()?.externalId;if(!s)throw new Error("No user identified. Call kookee.identify() first or pass externalId in params.");return this.http.delete(`/v1/feedback/${encodeURIComponent(e)}`,{externalId:s})}async deleteComment(e,t){let s=t?.externalId??this.getUserContext()?.externalId;if(!s)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:s})}};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 g(this.http),this.announcements=new m(this.entries),this.blog=new p(this.entries),this.changelog=new l(this.entries),this.config=new c(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,l as ChangelogModule,c as ConfigModule,g 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.36",
3
+ "version": "0.0.38",
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",