@kookee/sdk 0.0.35 → 0.0.37
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 +77 -12
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +121 -62
- package/dist/index.d.ts +121 -62
- package/dist/index.global.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -251,6 +251,9 @@ const categories = await kookee.entries.getCategories('help_article');
|
|
|
251
251
|
### Reading feedback
|
|
252
252
|
|
|
253
253
|
```typescript
|
|
254
|
+
// Get kanban columns (for roadmap rendering)
|
|
255
|
+
const columns = await kookee.feedback.getColumns();
|
|
256
|
+
|
|
254
257
|
// List feedback posts
|
|
255
258
|
const posts = await kookee.feedback.list({ page: 1, limit: 10 });
|
|
256
259
|
|
|
@@ -357,11 +360,18 @@ const posts = await kookee.blog.list({ locale: 'de' });
|
|
|
357
360
|
const post = await kookee.blog.getBySlug('hello-world', { locale: 'de', fallback: true });
|
|
358
361
|
```
|
|
359
362
|
|
|
360
|
-
Translation endpoints return a `
|
|
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:
|
|
361
364
|
|
|
362
365
|
```typescript
|
|
363
366
|
const translations = await kookee.blog.getTranslationsBySlug('hello-world');
|
|
364
|
-
// {
|
|
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' });
|
|
365
375
|
```
|
|
366
376
|
|
|
367
377
|
## Paginated Response
|
|
@@ -373,12 +383,33 @@ interface PaginatedResponse<T> {
|
|
|
373
383
|
data: T[];
|
|
374
384
|
total: number;
|
|
375
385
|
limit: number;
|
|
376
|
-
offset: number;
|
|
377
386
|
page: number;
|
|
378
387
|
totalPages: number;
|
|
379
388
|
}
|
|
380
389
|
```
|
|
381
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
|
+
Entries also expose `categoryId: string | null` — there is **no nested `category` object** on any entry response. If you need category metadata (name, slug, icon), fetch it separately via `kookee.help.categories()` (or the equivalent list) and join by `categoryId` on the client.
|
|
412
|
+
|
|
382
413
|
## Error Handling
|
|
383
414
|
|
|
384
415
|
```typescript
|
|
@@ -420,16 +451,9 @@ The SDK is written in TypeScript and provides full type definitions:
|
|
|
420
451
|
|
|
421
452
|
```typescript
|
|
422
453
|
import type {
|
|
423
|
-
// Entry
|
|
454
|
+
// Entry base & shared
|
|
424
455
|
BaseEntry,
|
|
425
|
-
|
|
426
|
-
BlogEntry,
|
|
427
|
-
PageEntry,
|
|
428
|
-
HelpArticleEntry,
|
|
429
|
-
ChangelogEntry,
|
|
430
|
-
AnnouncementEntry,
|
|
431
|
-
TypedEntry,
|
|
432
|
-
AnyEntry,
|
|
456
|
+
EntryDetailFields,
|
|
433
457
|
EntryType,
|
|
434
458
|
EntryStatus,
|
|
435
459
|
EntryAuthor,
|
|
@@ -437,6 +461,36 @@ import type {
|
|
|
437
461
|
EntryTagWithCount,
|
|
438
462
|
EntryCategory,
|
|
439
463
|
EntryComment,
|
|
464
|
+
EntryTranslationSummary,
|
|
465
|
+
EntryTranslationsMap,
|
|
466
|
+
|
|
467
|
+
// Entry variants — LIST responses (no contentHtml)
|
|
468
|
+
GenericEntryListItem,
|
|
469
|
+
BlogEntryListItem,
|
|
470
|
+
PageEntryListItem,
|
|
471
|
+
HelpArticleListItem,
|
|
472
|
+
ChangelogEntryListItem,
|
|
473
|
+
AnnouncementListItem,
|
|
474
|
+
TypedEntryListItem,
|
|
475
|
+
AnyEntryListItem,
|
|
476
|
+
|
|
477
|
+
// Entry variants — DETAIL responses (with contentHtml)
|
|
478
|
+
GenericEntryDetail,
|
|
479
|
+
BlogEntryDetail,
|
|
480
|
+
PageEntryDetail,
|
|
481
|
+
HelpArticleDetail,
|
|
482
|
+
ChangelogEntryDetail,
|
|
483
|
+
AnnouncementDetail,
|
|
484
|
+
TypedEntryDetail,
|
|
485
|
+
AnyEntryDetail,
|
|
486
|
+
|
|
487
|
+
// Type-specific metadata
|
|
488
|
+
TypeSpecific,
|
|
489
|
+
BlogTypeSpecific,
|
|
490
|
+
PageTypeSpecific,
|
|
491
|
+
HelpArticleTypeSpecific,
|
|
492
|
+
ChangelogTypeSpecific,
|
|
493
|
+
AnnouncementTypeSpecific,
|
|
440
494
|
|
|
441
495
|
// Changelog & Announcement specific
|
|
442
496
|
ChangelogType,
|
|
@@ -453,6 +507,7 @@ import type {
|
|
|
453
507
|
HelpChatStreamChunk,
|
|
454
508
|
|
|
455
509
|
// Feedback
|
|
510
|
+
FeedbackKanbanColumn,
|
|
456
511
|
FeedbackPost,
|
|
457
512
|
FeedbackPostListItem,
|
|
458
513
|
FeedbackColumnType,
|
|
@@ -493,6 +548,16 @@ import type {
|
|
|
493
548
|
} from '@kookee/sdk';
|
|
494
549
|
```
|
|
495
550
|
|
|
551
|
+
### Breaking type changes from 0.0.36
|
|
552
|
+
|
|
553
|
+
Version 0.0.37 aligns the SDK types with the real server response shapes. The old types lied about three things and crashed at runtime. If you're upgrading, note:
|
|
554
|
+
|
|
555
|
+
- **`BlogEntry`, `HelpArticleEntry`, `ChangelogEntry`, `PageEntry`, `AnnouncementEntry`, `GenericEntry`, `TypedEntry`, `AnyEntry` are gone.** Each one was split into a `*ListItem` (for list/search responses) and a `*Detail` (for single-entry responses). The compiler will now stop you from accessing `contentHtml` on a list item — it was never returned by the server there, and reading it crashed.
|
|
556
|
+
- **`BaseEntry.category` is gone.** The server never returned a nested `{ name, slug }` object; only `categoryId: string | null`. Join against `kookee.help.categories()` (or the equivalent) on the client if you need the full category.
|
|
557
|
+
- **`HelpSearchResult` is now an alias of `HelpArticleListItem`.** The fictional `matchedChunk` field is gone (the server never returned it). Same category rule as above.
|
|
558
|
+
- **`PaginatedResponse<T>.offset` is gone.** Entry list endpoints never returned it; use `page` instead.
|
|
559
|
+
- **Translation endpoints now return `EntryTranslationsMap`** (`{ id, slug, locale, title }` keyed by locale), not a full entry map. Fetch the full body with `getBySlug` / `getById` when needed.
|
|
560
|
+
|
|
496
561
|
## License
|
|
497
562
|
|
|
498
563
|
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
`);
|
|
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:
|
|
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,24 +78,20 @@ type HelpChatStreamChunk = {
|
|
|
79
78
|
type: 'error';
|
|
80
79
|
message: string;
|
|
81
80
|
};
|
|
82
|
-
|
|
81
|
+
type FeedbackColumnType = 'open' | 'closed';
|
|
82
|
+
interface FeedbackKanbanColumn {
|
|
83
83
|
id: string;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
slug: string;
|
|
90
|
-
};
|
|
91
|
-
locale: string;
|
|
92
|
-
matchedChunk?: string;
|
|
84
|
+
name: string;
|
|
85
|
+
color: string | null;
|
|
86
|
+
position: number;
|
|
87
|
+
type: FeedbackColumnType;
|
|
88
|
+
isVisible: boolean;
|
|
93
89
|
}
|
|
94
|
-
type FeedbackColumnType = 'open' | 'closed';
|
|
95
90
|
type FeedbackPostCategory = 'feature' | 'improvement' | 'bug' | 'other';
|
|
96
91
|
type FeedbackSortOption = 'newest' | 'top' | 'trending';
|
|
97
92
|
interface FeedbackAuthor {
|
|
98
93
|
id: string;
|
|
99
|
-
name: string;
|
|
94
|
+
name: string | null;
|
|
100
95
|
image: string | null;
|
|
101
96
|
isTeamMember?: boolean;
|
|
102
97
|
externalId?: string | null;
|
|
@@ -122,6 +117,7 @@ interface FeedbackPostListItem {
|
|
|
122
117
|
columnName: string | null;
|
|
123
118
|
columnColor: string | null;
|
|
124
119
|
columnType: FeedbackColumnType | null;
|
|
120
|
+
kanbanPosition: number;
|
|
125
121
|
category: FeedbackPostCategory;
|
|
126
122
|
voteCount: number;
|
|
127
123
|
commentCount: number;
|
|
@@ -135,7 +131,7 @@ interface FeedbackPost extends FeedbackPostListItem {
|
|
|
135
131
|
}
|
|
136
132
|
interface FeedbackTopContributor {
|
|
137
133
|
id: string;
|
|
138
|
-
name: string;
|
|
134
|
+
name: string | null;
|
|
139
135
|
image: string | null;
|
|
140
136
|
totalVotes: number;
|
|
141
137
|
}
|
|
@@ -206,12 +202,21 @@ type EntryType = 'blog' | 'page' | 'help_article' | 'changelog' | 'announcement'
|
|
|
206
202
|
type EntryStatus = 'draft' | 'published' | 'archived';
|
|
207
203
|
type ChangelogType = 'feature' | 'fix' | 'improvement' | 'breaking' | 'security' | 'deprecated' | 'other';
|
|
208
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
|
+
*/
|
|
209
210
|
interface EntryAuthor {
|
|
210
|
-
|
|
211
|
+
id: string;
|
|
212
|
+
name: string | null;
|
|
213
|
+
image: string | null;
|
|
211
214
|
}
|
|
212
215
|
interface EntryTag {
|
|
216
|
+
id: string;
|
|
213
217
|
name: string;
|
|
214
218
|
slug: string;
|
|
219
|
+
color: string | null;
|
|
215
220
|
}
|
|
216
221
|
interface EntryTagWithCount extends EntryTag {
|
|
217
222
|
count: number;
|
|
@@ -231,14 +236,15 @@ interface EntryComment {
|
|
|
231
236
|
updatedAt: string;
|
|
232
237
|
author: EntryAuthor;
|
|
233
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Fields that appear on BOTH list and detail entry responses.
|
|
241
|
+
*/
|
|
234
242
|
interface BaseEntry {
|
|
235
243
|
id: string;
|
|
236
244
|
type: string;
|
|
237
245
|
slug: string | null;
|
|
238
246
|
title: string;
|
|
239
247
|
excerptHtml: string | null;
|
|
240
|
-
contentHtml: string;
|
|
241
|
-
status: EntryStatus;
|
|
242
248
|
publishedAt: string | null;
|
|
243
249
|
locale: string;
|
|
244
250
|
translationGroupId: string;
|
|
@@ -249,15 +255,19 @@ interface BaseEntry {
|
|
|
249
255
|
metaTitle: string | null;
|
|
250
256
|
metaDescription: string | null;
|
|
251
257
|
metadata: Record<string, NonNullable<unknown>> | null;
|
|
258
|
+
reactions: Record<string, number>;
|
|
252
259
|
createdAt: string;
|
|
253
260
|
updatedAt: string;
|
|
254
261
|
author: EntryAuthor;
|
|
255
262
|
tags: EntryTag[];
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Fields added on entry DETAIL responses only.
|
|
266
|
+
*
|
|
267
|
+
* `contentHtml` is NOT returned on list endpoints.
|
|
268
|
+
*/
|
|
269
|
+
interface EntryDetailFields {
|
|
270
|
+
contentHtml: string;
|
|
261
271
|
}
|
|
262
272
|
interface BlogTypeSpecific {
|
|
263
273
|
_type: 'blog';
|
|
@@ -281,31 +291,79 @@ interface AnnouncementTypeSpecific {
|
|
|
281
291
|
unpublishAt: string | null;
|
|
282
292
|
}
|
|
283
293
|
type TypeSpecific = BlogTypeSpecific | PageTypeSpecific | HelpArticleTypeSpecific | ChangelogTypeSpecific | AnnouncementTypeSpecific;
|
|
284
|
-
interface
|
|
294
|
+
interface GenericEntryListItem extends BaseEntry {
|
|
295
|
+
typeSpecific: unknown;
|
|
296
|
+
}
|
|
297
|
+
interface GenericEntryDetail extends BaseEntry, EntryDetailFields {
|
|
285
298
|
typeSpecific: unknown;
|
|
286
299
|
}
|
|
287
|
-
interface
|
|
300
|
+
interface BlogEntryListItem extends BaseEntry {
|
|
301
|
+
type: 'blog';
|
|
302
|
+
typeSpecific: BlogTypeSpecific;
|
|
303
|
+
}
|
|
304
|
+
interface BlogEntryDetail extends BaseEntry, EntryDetailFields {
|
|
288
305
|
type: 'blog';
|
|
289
306
|
typeSpecific: BlogTypeSpecific;
|
|
290
307
|
}
|
|
291
|
-
interface
|
|
308
|
+
interface PageEntryListItem extends BaseEntry {
|
|
292
309
|
type: 'page';
|
|
293
310
|
typeSpecific: PageTypeSpecific;
|
|
294
311
|
}
|
|
295
|
-
interface
|
|
312
|
+
interface PageEntryDetail extends BaseEntry, EntryDetailFields {
|
|
313
|
+
type: 'page';
|
|
314
|
+
typeSpecific: PageTypeSpecific;
|
|
315
|
+
}
|
|
316
|
+
interface HelpArticleListItem extends BaseEntry {
|
|
317
|
+
type: 'help_article';
|
|
318
|
+
typeSpecific: HelpArticleTypeSpecific;
|
|
319
|
+
}
|
|
320
|
+
interface HelpArticleDetail extends BaseEntry, EntryDetailFields {
|
|
296
321
|
type: 'help_article';
|
|
297
322
|
typeSpecific: HelpArticleTypeSpecific;
|
|
298
323
|
}
|
|
299
|
-
interface
|
|
324
|
+
interface ChangelogEntryListItem extends BaseEntry {
|
|
300
325
|
type: 'changelog';
|
|
301
326
|
typeSpecific: ChangelogTypeSpecific;
|
|
302
327
|
}
|
|
303
|
-
interface
|
|
328
|
+
interface ChangelogEntryDetail extends BaseEntry, EntryDetailFields {
|
|
329
|
+
type: 'changelog';
|
|
330
|
+
typeSpecific: ChangelogTypeSpecific;
|
|
331
|
+
}
|
|
332
|
+
interface AnnouncementListItem extends BaseEntry {
|
|
333
|
+
type: 'announcement';
|
|
334
|
+
typeSpecific: AnnouncementTypeSpecific;
|
|
335
|
+
}
|
|
336
|
+
interface AnnouncementDetail extends BaseEntry, EntryDetailFields {
|
|
304
337
|
type: 'announcement';
|
|
305
338
|
typeSpecific: AnnouncementTypeSpecific;
|
|
306
339
|
}
|
|
307
|
-
type
|
|
308
|
-
type
|
|
340
|
+
type TypedEntryListItem = BlogEntryListItem | PageEntryListItem | HelpArticleListItem | ChangelogEntryListItem | AnnouncementListItem;
|
|
341
|
+
type TypedEntryDetail = BlogEntryDetail | PageEntryDetail | HelpArticleDetail | ChangelogEntryDetail | AnnouncementDetail;
|
|
342
|
+
type AnyEntryListItem = TypedEntryListItem | GenericEntryListItem;
|
|
343
|
+
type AnyEntryDetail = TypedEntryDetail | GenericEntryDetail;
|
|
344
|
+
/**
|
|
345
|
+
* Help search result — returned by `GET /v1/help/search`.
|
|
346
|
+
*
|
|
347
|
+
* The server returns the exact same shape as a help article list response,
|
|
348
|
+
* so we alias it to `HelpArticleListItem`. There is no nested `category`
|
|
349
|
+
* object or `matchedChunk` field on this response (SDK <= 0.0.36 lied
|
|
350
|
+
* about both).
|
|
351
|
+
*/
|
|
352
|
+
type HelpSearchResult = HelpArticleListItem;
|
|
353
|
+
/**
|
|
354
|
+
* Translation summary returned by the translations endpoints.
|
|
355
|
+
*
|
|
356
|
+
* The server returns a narrow { id, slug, locale, title } shape keyed by
|
|
357
|
+
* locale — NOT a full entry. Consumers that need the full body should
|
|
358
|
+
* fetch each translation individually via getBySlug / getById.
|
|
359
|
+
*/
|
|
360
|
+
interface EntryTranslationSummary {
|
|
361
|
+
id: string;
|
|
362
|
+
slug: string | null;
|
|
363
|
+
locale: string;
|
|
364
|
+
title: string;
|
|
365
|
+
}
|
|
366
|
+
type EntryTranslationsMap = Record<string, EntryTranslationSummary>;
|
|
309
367
|
|
|
310
368
|
declare class KookeeApiError extends Error {
|
|
311
369
|
readonly code: string;
|
|
@@ -347,11 +405,11 @@ interface EntriesGetCategoriesParams extends LocaleOptions {
|
|
|
347
405
|
declare class EntriesModule {
|
|
348
406
|
private readonly http;
|
|
349
407
|
constructor(http: HttpClient);
|
|
350
|
-
list(params: EntriesListParams): Promise<PaginatedResponse<
|
|
351
|
-
getById(id: string, params?: EntriesGetByIdParams): Promise<
|
|
352
|
-
getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<
|
|
353
|
-
getTranslationsById(id: string): Promise<
|
|
354
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
408
|
+
list(params: EntriesListParams): Promise<PaginatedResponse<GenericEntryListItem>>;
|
|
409
|
+
getById(id: string, params?: EntriesGetByIdParams): Promise<GenericEntryDetail>;
|
|
410
|
+
getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<GenericEntryDetail>;
|
|
411
|
+
getTranslationsById(id: string): Promise<EntryTranslationsMap>;
|
|
412
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
355
413
|
getComments(entryId: string, params?: EntriesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
356
414
|
react(entryId: string, params: ReactParams): Promise<ReactResponse>;
|
|
357
415
|
getTags(type: string): Promise<EntryTagWithCount[]>;
|
|
@@ -367,9 +425,9 @@ interface AnnouncementGetCommentsParams extends PaginationParams {
|
|
|
367
425
|
declare class AnnouncementModule {
|
|
368
426
|
private readonly entries;
|
|
369
427
|
constructor(entries: EntriesModule);
|
|
370
|
-
list(params?: AnnouncementListParams): Promise<PaginatedResponse<
|
|
371
|
-
getById(id: string, params?: AnnouncementGetByIdParams): Promise<
|
|
372
|
-
getTranslationsById(id: string): Promise<
|
|
428
|
+
list(params?: AnnouncementListParams): Promise<PaginatedResponse<AnnouncementListItem>>;
|
|
429
|
+
getById(id: string, params?: AnnouncementGetByIdParams): Promise<AnnouncementDetail>;
|
|
430
|
+
getTranslationsById(id: string): Promise<EntryTranslationsMap>;
|
|
373
431
|
getComments(entryId: string, params?: AnnouncementGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
374
432
|
}
|
|
375
433
|
|
|
@@ -386,12 +444,12 @@ interface BlogGetCommentsParams extends PaginationParams {
|
|
|
386
444
|
declare class BlogModule {
|
|
387
445
|
private readonly entries;
|
|
388
446
|
constructor(entries: EntriesModule);
|
|
389
|
-
list(params?: BlogListParams): Promise<PaginatedResponse<
|
|
390
|
-
getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<
|
|
391
|
-
getById(id: string, params?: BlogGetByIdParams): Promise<
|
|
447
|
+
list(params?: BlogListParams): Promise<PaginatedResponse<BlogEntryListItem>>;
|
|
448
|
+
getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<BlogEntryDetail>;
|
|
449
|
+
getById(id: string, params?: BlogGetByIdParams): Promise<BlogEntryDetail>;
|
|
392
450
|
getTags(): Promise<EntryTagWithCount[]>;
|
|
393
|
-
getTranslationsById(postId: string): Promise<
|
|
394
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
451
|
+
getTranslationsById(postId: string): Promise<EntryTranslationsMap>;
|
|
452
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
395
453
|
getComments(entryId: string, params?: BlogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
396
454
|
react(postId: string, params: ReactParams): Promise<ReactResponse>;
|
|
397
455
|
}
|
|
@@ -408,11 +466,11 @@ interface ChangelogGetCommentsParams extends PaginationParams {
|
|
|
408
466
|
declare class ChangelogModule {
|
|
409
467
|
private readonly entries;
|
|
410
468
|
constructor(entries: EntriesModule);
|
|
411
|
-
list(params?: ChangelogListParams): Promise<PaginatedResponse<
|
|
412
|
-
getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<
|
|
413
|
-
getById(id: string, params?: ChangelogGetByIdParams): Promise<
|
|
414
|
-
getTranslationsById(id: string): Promise<
|
|
415
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
469
|
+
list(params?: ChangelogListParams): Promise<PaginatedResponse<ChangelogEntryListItem>>;
|
|
470
|
+
getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<ChangelogEntryDetail>;
|
|
471
|
+
getById(id: string, params?: ChangelogGetByIdParams): Promise<ChangelogEntryDetail>;
|
|
472
|
+
getTranslationsById(id: string): Promise<EntryTranslationsMap>;
|
|
473
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
416
474
|
getComments(entryId: string, params?: ChangelogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
417
475
|
react(changelogId: string, params: ReactParams): Promise<ReactResponse>;
|
|
418
476
|
}
|
|
@@ -444,6 +502,7 @@ declare class FeedbackModule {
|
|
|
444
502
|
private readonly http;
|
|
445
503
|
private readonly getUserContext;
|
|
446
504
|
constructor(http: HttpClient, getUserContext: () => KookeeUser | null);
|
|
505
|
+
getColumns(): Promise<FeedbackKanbanColumn[]>;
|
|
447
506
|
list(params?: FeedbackListParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
|
|
448
507
|
getById(id: string): Promise<FeedbackPost>;
|
|
449
508
|
vote(postId: string, params: FeedbackVoteParams): Promise<FeedbackVoteResponse>;
|
|
@@ -476,12 +535,12 @@ declare class HelpModule {
|
|
|
476
535
|
private readonly entries;
|
|
477
536
|
constructor(http: HttpClient, entries: EntriesModule);
|
|
478
537
|
categories(params?: HelpCategoriesParams): Promise<EntryCategory[]>;
|
|
479
|
-
list(params?: HelpListParams): Promise<PaginatedResponse<
|
|
480
|
-
getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<
|
|
481
|
-
getById(id: string, params?: HelpGetByIdParams): Promise<
|
|
538
|
+
list(params?: HelpListParams): Promise<PaginatedResponse<HelpArticleListItem>>;
|
|
539
|
+
getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<HelpArticleDetail>;
|
|
540
|
+
getById(id: string, params?: HelpGetByIdParams): Promise<HelpArticleDetail>;
|
|
482
541
|
search(params: HelpSearchParams): Promise<HelpSearchResult[]>;
|
|
483
|
-
getTranslationsById(articleId: string): Promise<
|
|
484
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
542
|
+
getTranslationsById(articleId: string): Promise<EntryTranslationsMap>;
|
|
543
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
485
544
|
getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
486
545
|
react(articleId: string, params: ReactParams): Promise<ReactResponse>;
|
|
487
546
|
chat(params: HelpChatParams): Promise<HelpChatResponse>;
|
|
@@ -500,11 +559,11 @@ interface PagesGetCommentsParams extends PaginationParams {
|
|
|
500
559
|
declare class PagesModule {
|
|
501
560
|
private readonly entries;
|
|
502
561
|
constructor(entries: EntriesModule);
|
|
503
|
-
list(params?: PagesListParams): Promise<PaginatedResponse<
|
|
504
|
-
getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<
|
|
505
|
-
getById(id: string, params?: PagesGetByIdParams): Promise<
|
|
506
|
-
getTranslationsById(pageId: string): Promise<
|
|
507
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
562
|
+
list(params?: PagesListParams): Promise<PaginatedResponse<PageEntryListItem>>;
|
|
563
|
+
getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<PageEntryDetail>;
|
|
564
|
+
getById(id: string, params?: PagesGetByIdParams): Promise<PageEntryDetail>;
|
|
565
|
+
getTranslationsById(pageId: string): Promise<EntryTranslationsMap>;
|
|
566
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
508
567
|
getComments(entryId: string, params?: PagesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
509
568
|
}
|
|
510
569
|
|
|
@@ -526,4 +585,4 @@ declare class Kookee {
|
|
|
526
585
|
health(): Promise<HealthCheckResponse>;
|
|
527
586
|
}
|
|
528
587
|
|
|
529
|
-
export { type
|
|
588
|
+
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 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:
|
|
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,24 +78,20 @@ type HelpChatStreamChunk = {
|
|
|
79
78
|
type: 'error';
|
|
80
79
|
message: string;
|
|
81
80
|
};
|
|
82
|
-
|
|
81
|
+
type FeedbackColumnType = 'open' | 'closed';
|
|
82
|
+
interface FeedbackKanbanColumn {
|
|
83
83
|
id: string;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
slug: string;
|
|
90
|
-
};
|
|
91
|
-
locale: string;
|
|
92
|
-
matchedChunk?: string;
|
|
84
|
+
name: string;
|
|
85
|
+
color: string | null;
|
|
86
|
+
position: number;
|
|
87
|
+
type: FeedbackColumnType;
|
|
88
|
+
isVisible: boolean;
|
|
93
89
|
}
|
|
94
|
-
type FeedbackColumnType = 'open' | 'closed';
|
|
95
90
|
type FeedbackPostCategory = 'feature' | 'improvement' | 'bug' | 'other';
|
|
96
91
|
type FeedbackSortOption = 'newest' | 'top' | 'trending';
|
|
97
92
|
interface FeedbackAuthor {
|
|
98
93
|
id: string;
|
|
99
|
-
name: string;
|
|
94
|
+
name: string | null;
|
|
100
95
|
image: string | null;
|
|
101
96
|
isTeamMember?: boolean;
|
|
102
97
|
externalId?: string | null;
|
|
@@ -122,6 +117,7 @@ interface FeedbackPostListItem {
|
|
|
122
117
|
columnName: string | null;
|
|
123
118
|
columnColor: string | null;
|
|
124
119
|
columnType: FeedbackColumnType | null;
|
|
120
|
+
kanbanPosition: number;
|
|
125
121
|
category: FeedbackPostCategory;
|
|
126
122
|
voteCount: number;
|
|
127
123
|
commentCount: number;
|
|
@@ -135,7 +131,7 @@ interface FeedbackPost extends FeedbackPostListItem {
|
|
|
135
131
|
}
|
|
136
132
|
interface FeedbackTopContributor {
|
|
137
133
|
id: string;
|
|
138
|
-
name: string;
|
|
134
|
+
name: string | null;
|
|
139
135
|
image: string | null;
|
|
140
136
|
totalVotes: number;
|
|
141
137
|
}
|
|
@@ -206,12 +202,21 @@ type EntryType = 'blog' | 'page' | 'help_article' | 'changelog' | 'announcement'
|
|
|
206
202
|
type EntryStatus = 'draft' | 'published' | 'archived';
|
|
207
203
|
type ChangelogType = 'feature' | 'fix' | 'improvement' | 'breaking' | 'security' | 'deprecated' | 'other';
|
|
208
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
|
+
*/
|
|
209
210
|
interface EntryAuthor {
|
|
210
|
-
|
|
211
|
+
id: string;
|
|
212
|
+
name: string | null;
|
|
213
|
+
image: string | null;
|
|
211
214
|
}
|
|
212
215
|
interface EntryTag {
|
|
216
|
+
id: string;
|
|
213
217
|
name: string;
|
|
214
218
|
slug: string;
|
|
219
|
+
color: string | null;
|
|
215
220
|
}
|
|
216
221
|
interface EntryTagWithCount extends EntryTag {
|
|
217
222
|
count: number;
|
|
@@ -231,14 +236,15 @@ interface EntryComment {
|
|
|
231
236
|
updatedAt: string;
|
|
232
237
|
author: EntryAuthor;
|
|
233
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Fields that appear on BOTH list and detail entry responses.
|
|
241
|
+
*/
|
|
234
242
|
interface BaseEntry {
|
|
235
243
|
id: string;
|
|
236
244
|
type: string;
|
|
237
245
|
slug: string | null;
|
|
238
246
|
title: string;
|
|
239
247
|
excerptHtml: string | null;
|
|
240
|
-
contentHtml: string;
|
|
241
|
-
status: EntryStatus;
|
|
242
248
|
publishedAt: string | null;
|
|
243
249
|
locale: string;
|
|
244
250
|
translationGroupId: string;
|
|
@@ -249,15 +255,19 @@ interface BaseEntry {
|
|
|
249
255
|
metaTitle: string | null;
|
|
250
256
|
metaDescription: string | null;
|
|
251
257
|
metadata: Record<string, NonNullable<unknown>> | null;
|
|
258
|
+
reactions: Record<string, number>;
|
|
252
259
|
createdAt: string;
|
|
253
260
|
updatedAt: string;
|
|
254
261
|
author: EntryAuthor;
|
|
255
262
|
tags: EntryTag[];
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Fields added on entry DETAIL responses only.
|
|
266
|
+
*
|
|
267
|
+
* `contentHtml` is NOT returned on list endpoints.
|
|
268
|
+
*/
|
|
269
|
+
interface EntryDetailFields {
|
|
270
|
+
contentHtml: string;
|
|
261
271
|
}
|
|
262
272
|
interface BlogTypeSpecific {
|
|
263
273
|
_type: 'blog';
|
|
@@ -281,31 +291,79 @@ interface AnnouncementTypeSpecific {
|
|
|
281
291
|
unpublishAt: string | null;
|
|
282
292
|
}
|
|
283
293
|
type TypeSpecific = BlogTypeSpecific | PageTypeSpecific | HelpArticleTypeSpecific | ChangelogTypeSpecific | AnnouncementTypeSpecific;
|
|
284
|
-
interface
|
|
294
|
+
interface GenericEntryListItem extends BaseEntry {
|
|
295
|
+
typeSpecific: unknown;
|
|
296
|
+
}
|
|
297
|
+
interface GenericEntryDetail extends BaseEntry, EntryDetailFields {
|
|
285
298
|
typeSpecific: unknown;
|
|
286
299
|
}
|
|
287
|
-
interface
|
|
300
|
+
interface BlogEntryListItem extends BaseEntry {
|
|
301
|
+
type: 'blog';
|
|
302
|
+
typeSpecific: BlogTypeSpecific;
|
|
303
|
+
}
|
|
304
|
+
interface BlogEntryDetail extends BaseEntry, EntryDetailFields {
|
|
288
305
|
type: 'blog';
|
|
289
306
|
typeSpecific: BlogTypeSpecific;
|
|
290
307
|
}
|
|
291
|
-
interface
|
|
308
|
+
interface PageEntryListItem extends BaseEntry {
|
|
292
309
|
type: 'page';
|
|
293
310
|
typeSpecific: PageTypeSpecific;
|
|
294
311
|
}
|
|
295
|
-
interface
|
|
312
|
+
interface PageEntryDetail extends BaseEntry, EntryDetailFields {
|
|
313
|
+
type: 'page';
|
|
314
|
+
typeSpecific: PageTypeSpecific;
|
|
315
|
+
}
|
|
316
|
+
interface HelpArticleListItem extends BaseEntry {
|
|
317
|
+
type: 'help_article';
|
|
318
|
+
typeSpecific: HelpArticleTypeSpecific;
|
|
319
|
+
}
|
|
320
|
+
interface HelpArticleDetail extends BaseEntry, EntryDetailFields {
|
|
296
321
|
type: 'help_article';
|
|
297
322
|
typeSpecific: HelpArticleTypeSpecific;
|
|
298
323
|
}
|
|
299
|
-
interface
|
|
324
|
+
interface ChangelogEntryListItem extends BaseEntry {
|
|
300
325
|
type: 'changelog';
|
|
301
326
|
typeSpecific: ChangelogTypeSpecific;
|
|
302
327
|
}
|
|
303
|
-
interface
|
|
328
|
+
interface ChangelogEntryDetail extends BaseEntry, EntryDetailFields {
|
|
329
|
+
type: 'changelog';
|
|
330
|
+
typeSpecific: ChangelogTypeSpecific;
|
|
331
|
+
}
|
|
332
|
+
interface AnnouncementListItem extends BaseEntry {
|
|
333
|
+
type: 'announcement';
|
|
334
|
+
typeSpecific: AnnouncementTypeSpecific;
|
|
335
|
+
}
|
|
336
|
+
interface AnnouncementDetail extends BaseEntry, EntryDetailFields {
|
|
304
337
|
type: 'announcement';
|
|
305
338
|
typeSpecific: AnnouncementTypeSpecific;
|
|
306
339
|
}
|
|
307
|
-
type
|
|
308
|
-
type
|
|
340
|
+
type TypedEntryListItem = BlogEntryListItem | PageEntryListItem | HelpArticleListItem | ChangelogEntryListItem | AnnouncementListItem;
|
|
341
|
+
type TypedEntryDetail = BlogEntryDetail | PageEntryDetail | HelpArticleDetail | ChangelogEntryDetail | AnnouncementDetail;
|
|
342
|
+
type AnyEntryListItem = TypedEntryListItem | GenericEntryListItem;
|
|
343
|
+
type AnyEntryDetail = TypedEntryDetail | GenericEntryDetail;
|
|
344
|
+
/**
|
|
345
|
+
* Help search result — returned by `GET /v1/help/search`.
|
|
346
|
+
*
|
|
347
|
+
* The server returns the exact same shape as a help article list response,
|
|
348
|
+
* so we alias it to `HelpArticleListItem`. There is no nested `category`
|
|
349
|
+
* object or `matchedChunk` field on this response (SDK <= 0.0.36 lied
|
|
350
|
+
* about both).
|
|
351
|
+
*/
|
|
352
|
+
type HelpSearchResult = HelpArticleListItem;
|
|
353
|
+
/**
|
|
354
|
+
* Translation summary returned by the translations endpoints.
|
|
355
|
+
*
|
|
356
|
+
* The server returns a narrow { id, slug, locale, title } shape keyed by
|
|
357
|
+
* locale — NOT a full entry. Consumers that need the full body should
|
|
358
|
+
* fetch each translation individually via getBySlug / getById.
|
|
359
|
+
*/
|
|
360
|
+
interface EntryTranslationSummary {
|
|
361
|
+
id: string;
|
|
362
|
+
slug: string | null;
|
|
363
|
+
locale: string;
|
|
364
|
+
title: string;
|
|
365
|
+
}
|
|
366
|
+
type EntryTranslationsMap = Record<string, EntryTranslationSummary>;
|
|
309
367
|
|
|
310
368
|
declare class KookeeApiError extends Error {
|
|
311
369
|
readonly code: string;
|
|
@@ -347,11 +405,11 @@ interface EntriesGetCategoriesParams extends LocaleOptions {
|
|
|
347
405
|
declare class EntriesModule {
|
|
348
406
|
private readonly http;
|
|
349
407
|
constructor(http: HttpClient);
|
|
350
|
-
list(params: EntriesListParams): Promise<PaginatedResponse<
|
|
351
|
-
getById(id: string, params?: EntriesGetByIdParams): Promise<
|
|
352
|
-
getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<
|
|
353
|
-
getTranslationsById(id: string): Promise<
|
|
354
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
408
|
+
list(params: EntriesListParams): Promise<PaginatedResponse<GenericEntryListItem>>;
|
|
409
|
+
getById(id: string, params?: EntriesGetByIdParams): Promise<GenericEntryDetail>;
|
|
410
|
+
getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<GenericEntryDetail>;
|
|
411
|
+
getTranslationsById(id: string): Promise<EntryTranslationsMap>;
|
|
412
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
355
413
|
getComments(entryId: string, params?: EntriesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
356
414
|
react(entryId: string, params: ReactParams): Promise<ReactResponse>;
|
|
357
415
|
getTags(type: string): Promise<EntryTagWithCount[]>;
|
|
@@ -367,9 +425,9 @@ interface AnnouncementGetCommentsParams extends PaginationParams {
|
|
|
367
425
|
declare class AnnouncementModule {
|
|
368
426
|
private readonly entries;
|
|
369
427
|
constructor(entries: EntriesModule);
|
|
370
|
-
list(params?: AnnouncementListParams): Promise<PaginatedResponse<
|
|
371
|
-
getById(id: string, params?: AnnouncementGetByIdParams): Promise<
|
|
372
|
-
getTranslationsById(id: string): Promise<
|
|
428
|
+
list(params?: AnnouncementListParams): Promise<PaginatedResponse<AnnouncementListItem>>;
|
|
429
|
+
getById(id: string, params?: AnnouncementGetByIdParams): Promise<AnnouncementDetail>;
|
|
430
|
+
getTranslationsById(id: string): Promise<EntryTranslationsMap>;
|
|
373
431
|
getComments(entryId: string, params?: AnnouncementGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
374
432
|
}
|
|
375
433
|
|
|
@@ -386,12 +444,12 @@ interface BlogGetCommentsParams extends PaginationParams {
|
|
|
386
444
|
declare class BlogModule {
|
|
387
445
|
private readonly entries;
|
|
388
446
|
constructor(entries: EntriesModule);
|
|
389
|
-
list(params?: BlogListParams): Promise<PaginatedResponse<
|
|
390
|
-
getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<
|
|
391
|
-
getById(id: string, params?: BlogGetByIdParams): Promise<
|
|
447
|
+
list(params?: BlogListParams): Promise<PaginatedResponse<BlogEntryListItem>>;
|
|
448
|
+
getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<BlogEntryDetail>;
|
|
449
|
+
getById(id: string, params?: BlogGetByIdParams): Promise<BlogEntryDetail>;
|
|
392
450
|
getTags(): Promise<EntryTagWithCount[]>;
|
|
393
|
-
getTranslationsById(postId: string): Promise<
|
|
394
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
451
|
+
getTranslationsById(postId: string): Promise<EntryTranslationsMap>;
|
|
452
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
395
453
|
getComments(entryId: string, params?: BlogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
396
454
|
react(postId: string, params: ReactParams): Promise<ReactResponse>;
|
|
397
455
|
}
|
|
@@ -408,11 +466,11 @@ interface ChangelogGetCommentsParams extends PaginationParams {
|
|
|
408
466
|
declare class ChangelogModule {
|
|
409
467
|
private readonly entries;
|
|
410
468
|
constructor(entries: EntriesModule);
|
|
411
|
-
list(params?: ChangelogListParams): Promise<PaginatedResponse<
|
|
412
|
-
getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<
|
|
413
|
-
getById(id: string, params?: ChangelogGetByIdParams): Promise<
|
|
414
|
-
getTranslationsById(id: string): Promise<
|
|
415
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
469
|
+
list(params?: ChangelogListParams): Promise<PaginatedResponse<ChangelogEntryListItem>>;
|
|
470
|
+
getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<ChangelogEntryDetail>;
|
|
471
|
+
getById(id: string, params?: ChangelogGetByIdParams): Promise<ChangelogEntryDetail>;
|
|
472
|
+
getTranslationsById(id: string): Promise<EntryTranslationsMap>;
|
|
473
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
416
474
|
getComments(entryId: string, params?: ChangelogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
417
475
|
react(changelogId: string, params: ReactParams): Promise<ReactResponse>;
|
|
418
476
|
}
|
|
@@ -444,6 +502,7 @@ declare class FeedbackModule {
|
|
|
444
502
|
private readonly http;
|
|
445
503
|
private readonly getUserContext;
|
|
446
504
|
constructor(http: HttpClient, getUserContext: () => KookeeUser | null);
|
|
505
|
+
getColumns(): Promise<FeedbackKanbanColumn[]>;
|
|
447
506
|
list(params?: FeedbackListParams): Promise<PaginatedResponse<FeedbackPostListItem>>;
|
|
448
507
|
getById(id: string): Promise<FeedbackPost>;
|
|
449
508
|
vote(postId: string, params: FeedbackVoteParams): Promise<FeedbackVoteResponse>;
|
|
@@ -476,12 +535,12 @@ declare class HelpModule {
|
|
|
476
535
|
private readonly entries;
|
|
477
536
|
constructor(http: HttpClient, entries: EntriesModule);
|
|
478
537
|
categories(params?: HelpCategoriesParams): Promise<EntryCategory[]>;
|
|
479
|
-
list(params?: HelpListParams): Promise<PaginatedResponse<
|
|
480
|
-
getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<
|
|
481
|
-
getById(id: string, params?: HelpGetByIdParams): Promise<
|
|
538
|
+
list(params?: HelpListParams): Promise<PaginatedResponse<HelpArticleListItem>>;
|
|
539
|
+
getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<HelpArticleDetail>;
|
|
540
|
+
getById(id: string, params?: HelpGetByIdParams): Promise<HelpArticleDetail>;
|
|
482
541
|
search(params: HelpSearchParams): Promise<HelpSearchResult[]>;
|
|
483
|
-
getTranslationsById(articleId: string): Promise<
|
|
484
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
542
|
+
getTranslationsById(articleId: string): Promise<EntryTranslationsMap>;
|
|
543
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
485
544
|
getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
486
545
|
react(articleId: string, params: ReactParams): Promise<ReactResponse>;
|
|
487
546
|
chat(params: HelpChatParams): Promise<HelpChatResponse>;
|
|
@@ -500,11 +559,11 @@ interface PagesGetCommentsParams extends PaginationParams {
|
|
|
500
559
|
declare class PagesModule {
|
|
501
560
|
private readonly entries;
|
|
502
561
|
constructor(entries: EntriesModule);
|
|
503
|
-
list(params?: PagesListParams): Promise<PaginatedResponse<
|
|
504
|
-
getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<
|
|
505
|
-
getById(id: string, params?: PagesGetByIdParams): Promise<
|
|
506
|
-
getTranslationsById(pageId: string): Promise<
|
|
507
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
562
|
+
list(params?: PagesListParams): Promise<PaginatedResponse<PageEntryListItem>>;
|
|
563
|
+
getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<PageEntryDetail>;
|
|
564
|
+
getById(id: string, params?: PagesGetByIdParams): Promise<PageEntryDetail>;
|
|
565
|
+
getTranslationsById(pageId: string): Promise<EntryTranslationsMap>;
|
|
566
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
508
567
|
getComments(entryId: string, params?: PagesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
509
568
|
}
|
|
510
569
|
|
|
@@ -526,4 +585,4 @@ declare class Kookee {
|
|
|
526
585
|
health(): Promise<HealthCheckResponse>;
|
|
527
586
|
}
|
|
528
587
|
|
|
529
|
-
export { type
|
|
588
|
+
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 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.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(exports){'use strict';var
|
|
2
|
-
`);
|
|
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
|
|
2
|
-
`);
|
|
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};
|