@kookee/sdk 0.0.36 → 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 +73 -12
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +113 -63
- package/dist/index.d.ts +113 -63
- package/dist/index.global.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
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 `
|
|
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
|
-
// {
|
|
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,33 @@ 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
|
+
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
|
+
|
|
385
413
|
## Error Handling
|
|
386
414
|
|
|
387
415
|
```typescript
|
|
@@ -423,16 +451,9 @@ The SDK is written in TypeScript and provides full type definitions:
|
|
|
423
451
|
|
|
424
452
|
```typescript
|
|
425
453
|
import type {
|
|
426
|
-
// Entry
|
|
454
|
+
// Entry base & shared
|
|
427
455
|
BaseEntry,
|
|
428
|
-
|
|
429
|
-
BlogEntry,
|
|
430
|
-
PageEntry,
|
|
431
|
-
HelpArticleEntry,
|
|
432
|
-
ChangelogEntry,
|
|
433
|
-
AnnouncementEntry,
|
|
434
|
-
TypedEntry,
|
|
435
|
-
AnyEntry,
|
|
456
|
+
EntryDetailFields,
|
|
436
457
|
EntryType,
|
|
437
458
|
EntryStatus,
|
|
438
459
|
EntryAuthor,
|
|
@@ -440,6 +461,36 @@ import type {
|
|
|
440
461
|
EntryTagWithCount,
|
|
441
462
|
EntryCategory,
|
|
442
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,
|
|
443
494
|
|
|
444
495
|
// Changelog & Announcement specific
|
|
445
496
|
ChangelogType,
|
|
@@ -497,6 +548,16 @@ import type {
|
|
|
497
548
|
} from '@kookee/sdk';
|
|
498
549
|
```
|
|
499
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
|
+
|
|
500
561
|
## License
|
|
501
562
|
|
|
502
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,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
|
-
|
|
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,14 +236,15 @@ interface EntryComment {
|
|
|
239
236
|
updatedAt: string;
|
|
240
237
|
author: EntryAuthor;
|
|
241
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Fields that appear on BOTH list and detail entry responses.
|
|
241
|
+
*/
|
|
242
242
|
interface BaseEntry {
|
|
243
243
|
id: string;
|
|
244
244
|
type: string;
|
|
245
245
|
slug: string | null;
|
|
246
246
|
title: string;
|
|
247
247
|
excerptHtml: string | null;
|
|
248
|
-
contentHtml: string;
|
|
249
|
-
status: EntryStatus;
|
|
250
248
|
publishedAt: string | null;
|
|
251
249
|
locale: string;
|
|
252
250
|
translationGroupId: string;
|
|
@@ -257,15 +255,19 @@ interface BaseEntry {
|
|
|
257
255
|
metaTitle: string | null;
|
|
258
256
|
metaDescription: string | null;
|
|
259
257
|
metadata: Record<string, NonNullable<unknown>> | null;
|
|
258
|
+
reactions: Record<string, number>;
|
|
260
259
|
createdAt: string;
|
|
261
260
|
updatedAt: string;
|
|
262
261
|
author: EntryAuthor;
|
|
263
262
|
tags: EntryTag[];
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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;
|
|
269
271
|
}
|
|
270
272
|
interface BlogTypeSpecific {
|
|
271
273
|
_type: 'blog';
|
|
@@ -289,31 +291,79 @@ interface AnnouncementTypeSpecific {
|
|
|
289
291
|
unpublishAt: string | null;
|
|
290
292
|
}
|
|
291
293
|
type TypeSpecific = BlogTypeSpecific | PageTypeSpecific | HelpArticleTypeSpecific | ChangelogTypeSpecific | AnnouncementTypeSpecific;
|
|
292
|
-
interface
|
|
294
|
+
interface GenericEntryListItem extends BaseEntry {
|
|
295
|
+
typeSpecific: unknown;
|
|
296
|
+
}
|
|
297
|
+
interface GenericEntryDetail extends BaseEntry, EntryDetailFields {
|
|
293
298
|
typeSpecific: unknown;
|
|
294
299
|
}
|
|
295
|
-
interface
|
|
300
|
+
interface BlogEntryListItem extends BaseEntry {
|
|
301
|
+
type: 'blog';
|
|
302
|
+
typeSpecific: BlogTypeSpecific;
|
|
303
|
+
}
|
|
304
|
+
interface BlogEntryDetail extends BaseEntry, EntryDetailFields {
|
|
296
305
|
type: 'blog';
|
|
297
306
|
typeSpecific: BlogTypeSpecific;
|
|
298
307
|
}
|
|
299
|
-
interface
|
|
308
|
+
interface PageEntryListItem extends BaseEntry {
|
|
300
309
|
type: 'page';
|
|
301
310
|
typeSpecific: PageTypeSpecific;
|
|
302
311
|
}
|
|
303
|
-
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 {
|
|
304
321
|
type: 'help_article';
|
|
305
322
|
typeSpecific: HelpArticleTypeSpecific;
|
|
306
323
|
}
|
|
307
|
-
interface
|
|
324
|
+
interface ChangelogEntryListItem extends BaseEntry {
|
|
308
325
|
type: 'changelog';
|
|
309
326
|
typeSpecific: ChangelogTypeSpecific;
|
|
310
327
|
}
|
|
311
|
-
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 {
|
|
312
337
|
type: 'announcement';
|
|
313
338
|
typeSpecific: AnnouncementTypeSpecific;
|
|
314
339
|
}
|
|
315
|
-
type
|
|
316
|
-
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>;
|
|
317
367
|
|
|
318
368
|
declare class KookeeApiError extends Error {
|
|
319
369
|
readonly code: string;
|
|
@@ -355,11 +405,11 @@ interface EntriesGetCategoriesParams extends LocaleOptions {
|
|
|
355
405
|
declare class EntriesModule {
|
|
356
406
|
private readonly http;
|
|
357
407
|
constructor(http: HttpClient);
|
|
358
|
-
list(params: EntriesListParams): Promise<PaginatedResponse<
|
|
359
|
-
getById(id: string, params?: EntriesGetByIdParams): Promise<
|
|
360
|
-
getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<
|
|
361
|
-
getTranslationsById(id: string): Promise<
|
|
362
|
-
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>;
|
|
363
413
|
getComments(entryId: string, params?: EntriesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
364
414
|
react(entryId: string, params: ReactParams): Promise<ReactResponse>;
|
|
365
415
|
getTags(type: string): Promise<EntryTagWithCount[]>;
|
|
@@ -375,9 +425,9 @@ interface AnnouncementGetCommentsParams extends PaginationParams {
|
|
|
375
425
|
declare class AnnouncementModule {
|
|
376
426
|
private readonly entries;
|
|
377
427
|
constructor(entries: EntriesModule);
|
|
378
|
-
list(params?: AnnouncementListParams): Promise<PaginatedResponse<
|
|
379
|
-
getById(id: string, params?: AnnouncementGetByIdParams): Promise<
|
|
380
|
-
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>;
|
|
381
431
|
getComments(entryId: string, params?: AnnouncementGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
382
432
|
}
|
|
383
433
|
|
|
@@ -394,12 +444,12 @@ interface BlogGetCommentsParams extends PaginationParams {
|
|
|
394
444
|
declare class BlogModule {
|
|
395
445
|
private readonly entries;
|
|
396
446
|
constructor(entries: EntriesModule);
|
|
397
|
-
list(params?: BlogListParams): Promise<PaginatedResponse<
|
|
398
|
-
getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<
|
|
399
|
-
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>;
|
|
400
450
|
getTags(): Promise<EntryTagWithCount[]>;
|
|
401
|
-
getTranslationsById(postId: string): Promise<
|
|
402
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
451
|
+
getTranslationsById(postId: string): Promise<EntryTranslationsMap>;
|
|
452
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
403
453
|
getComments(entryId: string, params?: BlogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
404
454
|
react(postId: string, params: ReactParams): Promise<ReactResponse>;
|
|
405
455
|
}
|
|
@@ -416,11 +466,11 @@ interface ChangelogGetCommentsParams extends PaginationParams {
|
|
|
416
466
|
declare class ChangelogModule {
|
|
417
467
|
private readonly entries;
|
|
418
468
|
constructor(entries: EntriesModule);
|
|
419
|
-
list(params?: ChangelogListParams): Promise<PaginatedResponse<
|
|
420
|
-
getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<
|
|
421
|
-
getById(id: string, params?: ChangelogGetByIdParams): Promise<
|
|
422
|
-
getTranslationsById(id: string): Promise<
|
|
423
|
-
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>;
|
|
424
474
|
getComments(entryId: string, params?: ChangelogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
425
475
|
react(changelogId: string, params: ReactParams): Promise<ReactResponse>;
|
|
426
476
|
}
|
|
@@ -485,12 +535,12 @@ declare class HelpModule {
|
|
|
485
535
|
private readonly entries;
|
|
486
536
|
constructor(http: HttpClient, entries: EntriesModule);
|
|
487
537
|
categories(params?: HelpCategoriesParams): Promise<EntryCategory[]>;
|
|
488
|
-
list(params?: HelpListParams): Promise<PaginatedResponse<
|
|
489
|
-
getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<
|
|
490
|
-
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>;
|
|
491
541
|
search(params: HelpSearchParams): Promise<HelpSearchResult[]>;
|
|
492
|
-
getTranslationsById(articleId: string): Promise<
|
|
493
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
542
|
+
getTranslationsById(articleId: string): Promise<EntryTranslationsMap>;
|
|
543
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
494
544
|
getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
495
545
|
react(articleId: string, params: ReactParams): Promise<ReactResponse>;
|
|
496
546
|
chat(params: HelpChatParams): Promise<HelpChatResponse>;
|
|
@@ -509,11 +559,11 @@ interface PagesGetCommentsParams extends PaginationParams {
|
|
|
509
559
|
declare class PagesModule {
|
|
510
560
|
private readonly entries;
|
|
511
561
|
constructor(entries: EntriesModule);
|
|
512
|
-
list(params?: PagesListParams): Promise<PaginatedResponse<
|
|
513
|
-
getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<
|
|
514
|
-
getById(id: string, params?: PagesGetByIdParams): Promise<
|
|
515
|
-
getTranslationsById(pageId: string): Promise<
|
|
516
|
-
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>;
|
|
517
567
|
getComments(entryId: string, params?: PagesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
518
568
|
}
|
|
519
569
|
|
|
@@ -535,4 +585,4 @@ declare class Kookee {
|
|
|
535
585
|
health(): Promise<HealthCheckResponse>;
|
|
536
586
|
}
|
|
537
587
|
|
|
538
|
-
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,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
|
-
|
|
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,14 +236,15 @@ interface EntryComment {
|
|
|
239
236
|
updatedAt: string;
|
|
240
237
|
author: EntryAuthor;
|
|
241
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Fields that appear on BOTH list and detail entry responses.
|
|
241
|
+
*/
|
|
242
242
|
interface BaseEntry {
|
|
243
243
|
id: string;
|
|
244
244
|
type: string;
|
|
245
245
|
slug: string | null;
|
|
246
246
|
title: string;
|
|
247
247
|
excerptHtml: string | null;
|
|
248
|
-
contentHtml: string;
|
|
249
|
-
status: EntryStatus;
|
|
250
248
|
publishedAt: string | null;
|
|
251
249
|
locale: string;
|
|
252
250
|
translationGroupId: string;
|
|
@@ -257,15 +255,19 @@ interface BaseEntry {
|
|
|
257
255
|
metaTitle: string | null;
|
|
258
256
|
metaDescription: string | null;
|
|
259
257
|
metadata: Record<string, NonNullable<unknown>> | null;
|
|
258
|
+
reactions: Record<string, number>;
|
|
260
259
|
createdAt: string;
|
|
261
260
|
updatedAt: string;
|
|
262
261
|
author: EntryAuthor;
|
|
263
262
|
tags: EntryTag[];
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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;
|
|
269
271
|
}
|
|
270
272
|
interface BlogTypeSpecific {
|
|
271
273
|
_type: 'blog';
|
|
@@ -289,31 +291,79 @@ interface AnnouncementTypeSpecific {
|
|
|
289
291
|
unpublishAt: string | null;
|
|
290
292
|
}
|
|
291
293
|
type TypeSpecific = BlogTypeSpecific | PageTypeSpecific | HelpArticleTypeSpecific | ChangelogTypeSpecific | AnnouncementTypeSpecific;
|
|
292
|
-
interface
|
|
294
|
+
interface GenericEntryListItem extends BaseEntry {
|
|
295
|
+
typeSpecific: unknown;
|
|
296
|
+
}
|
|
297
|
+
interface GenericEntryDetail extends BaseEntry, EntryDetailFields {
|
|
293
298
|
typeSpecific: unknown;
|
|
294
299
|
}
|
|
295
|
-
interface
|
|
300
|
+
interface BlogEntryListItem extends BaseEntry {
|
|
301
|
+
type: 'blog';
|
|
302
|
+
typeSpecific: BlogTypeSpecific;
|
|
303
|
+
}
|
|
304
|
+
interface BlogEntryDetail extends BaseEntry, EntryDetailFields {
|
|
296
305
|
type: 'blog';
|
|
297
306
|
typeSpecific: BlogTypeSpecific;
|
|
298
307
|
}
|
|
299
|
-
interface
|
|
308
|
+
interface PageEntryListItem extends BaseEntry {
|
|
300
309
|
type: 'page';
|
|
301
310
|
typeSpecific: PageTypeSpecific;
|
|
302
311
|
}
|
|
303
|
-
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 {
|
|
304
321
|
type: 'help_article';
|
|
305
322
|
typeSpecific: HelpArticleTypeSpecific;
|
|
306
323
|
}
|
|
307
|
-
interface
|
|
324
|
+
interface ChangelogEntryListItem extends BaseEntry {
|
|
308
325
|
type: 'changelog';
|
|
309
326
|
typeSpecific: ChangelogTypeSpecific;
|
|
310
327
|
}
|
|
311
|
-
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 {
|
|
312
337
|
type: 'announcement';
|
|
313
338
|
typeSpecific: AnnouncementTypeSpecific;
|
|
314
339
|
}
|
|
315
|
-
type
|
|
316
|
-
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>;
|
|
317
367
|
|
|
318
368
|
declare class KookeeApiError extends Error {
|
|
319
369
|
readonly code: string;
|
|
@@ -355,11 +405,11 @@ interface EntriesGetCategoriesParams extends LocaleOptions {
|
|
|
355
405
|
declare class EntriesModule {
|
|
356
406
|
private readonly http;
|
|
357
407
|
constructor(http: HttpClient);
|
|
358
|
-
list(params: EntriesListParams): Promise<PaginatedResponse<
|
|
359
|
-
getById(id: string, params?: EntriesGetByIdParams): Promise<
|
|
360
|
-
getBySlug(slug: string, params: EntriesGetBySlugParams): Promise<
|
|
361
|
-
getTranslationsById(id: string): Promise<
|
|
362
|
-
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>;
|
|
363
413
|
getComments(entryId: string, params?: EntriesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
364
414
|
react(entryId: string, params: ReactParams): Promise<ReactResponse>;
|
|
365
415
|
getTags(type: string): Promise<EntryTagWithCount[]>;
|
|
@@ -375,9 +425,9 @@ interface AnnouncementGetCommentsParams extends PaginationParams {
|
|
|
375
425
|
declare class AnnouncementModule {
|
|
376
426
|
private readonly entries;
|
|
377
427
|
constructor(entries: EntriesModule);
|
|
378
|
-
list(params?: AnnouncementListParams): Promise<PaginatedResponse<
|
|
379
|
-
getById(id: string, params?: AnnouncementGetByIdParams): Promise<
|
|
380
|
-
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>;
|
|
381
431
|
getComments(entryId: string, params?: AnnouncementGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
382
432
|
}
|
|
383
433
|
|
|
@@ -394,12 +444,12 @@ interface BlogGetCommentsParams extends PaginationParams {
|
|
|
394
444
|
declare class BlogModule {
|
|
395
445
|
private readonly entries;
|
|
396
446
|
constructor(entries: EntriesModule);
|
|
397
|
-
list(params?: BlogListParams): Promise<PaginatedResponse<
|
|
398
|
-
getBySlug(slug: string, params?: BlogGetBySlugParams): Promise<
|
|
399
|
-
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>;
|
|
400
450
|
getTags(): Promise<EntryTagWithCount[]>;
|
|
401
|
-
getTranslationsById(postId: string): Promise<
|
|
402
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
451
|
+
getTranslationsById(postId: string): Promise<EntryTranslationsMap>;
|
|
452
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
403
453
|
getComments(entryId: string, params?: BlogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
404
454
|
react(postId: string, params: ReactParams): Promise<ReactResponse>;
|
|
405
455
|
}
|
|
@@ -416,11 +466,11 @@ interface ChangelogGetCommentsParams extends PaginationParams {
|
|
|
416
466
|
declare class ChangelogModule {
|
|
417
467
|
private readonly entries;
|
|
418
468
|
constructor(entries: EntriesModule);
|
|
419
|
-
list(params?: ChangelogListParams): Promise<PaginatedResponse<
|
|
420
|
-
getBySlug(slug: string, params?: ChangelogGetBySlugParams): Promise<
|
|
421
|
-
getById(id: string, params?: ChangelogGetByIdParams): Promise<
|
|
422
|
-
getTranslationsById(id: string): Promise<
|
|
423
|
-
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>;
|
|
424
474
|
getComments(entryId: string, params?: ChangelogGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
425
475
|
react(changelogId: string, params: ReactParams): Promise<ReactResponse>;
|
|
426
476
|
}
|
|
@@ -485,12 +535,12 @@ declare class HelpModule {
|
|
|
485
535
|
private readonly entries;
|
|
486
536
|
constructor(http: HttpClient, entries: EntriesModule);
|
|
487
537
|
categories(params?: HelpCategoriesParams): Promise<EntryCategory[]>;
|
|
488
|
-
list(params?: HelpListParams): Promise<PaginatedResponse<
|
|
489
|
-
getBySlug(slug: string, params?: HelpGetBySlugParams): Promise<
|
|
490
|
-
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>;
|
|
491
541
|
search(params: HelpSearchParams): Promise<HelpSearchResult[]>;
|
|
492
|
-
getTranslationsById(articleId: string): Promise<
|
|
493
|
-
getTranslationsBySlug(slug: string): Promise<
|
|
542
|
+
getTranslationsById(articleId: string): Promise<EntryTranslationsMap>;
|
|
543
|
+
getTranslationsBySlug(slug: string): Promise<EntryTranslationsMap>;
|
|
494
544
|
getComments(entryId: string, params?: HelpGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
495
545
|
react(articleId: string, params: ReactParams): Promise<ReactResponse>;
|
|
496
546
|
chat(params: HelpChatParams): Promise<HelpChatResponse>;
|
|
@@ -509,11 +559,11 @@ interface PagesGetCommentsParams extends PaginationParams {
|
|
|
509
559
|
declare class PagesModule {
|
|
510
560
|
private readonly entries;
|
|
511
561
|
constructor(entries: EntriesModule);
|
|
512
|
-
list(params?: PagesListParams): Promise<PaginatedResponse<
|
|
513
|
-
getBySlug(slug: string, params?: PagesGetBySlugParams): Promise<
|
|
514
|
-
getById(id: string, params?: PagesGetByIdParams): Promise<
|
|
515
|
-
getTranslationsById(pageId: string): Promise<
|
|
516
|
-
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>;
|
|
517
567
|
getComments(entryId: string, params?: PagesGetCommentsParams): Promise<PaginatedResponse<EntryComment>>;
|
|
518
568
|
}
|
|
519
569
|
|
|
@@ -535,4 +585,4 @@ declare class Kookee {
|
|
|
535
585
|
health(): Promise<HealthCheckResponse>;
|
|
536
586
|
}
|
|
537
587
|
|
|
538
|
-
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};
|