Skip to content

Commit 53b2934

Browse files
committed
updates on bookmark endpoints and api keys
1 parent 90f519e commit 53b2934

File tree

4 files changed

+442
-362
lines changed

4 files changed

+442
-362
lines changed

src/sdks/bookmarks.ts

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {
22
BookmarkFileEntry,
33
BookmarkPagination,
4+
BookmarkTabsEntry,
45
ImageUploadType,
56
ManualBookmarkEntry,
67
ManualBookmarkEntryPayload,
@@ -25,12 +26,12 @@ export const bookmarks = sdk(client => ({
2526
},
2627

2728
/**
28-
* Get the article content of a bookmark
29+
* Get the reader (article) content of a bookmark
2930
*
3031
* @param {String} id - The ID of the bookmark
3132
*/
32-
async getArticle(id: string) {
33-
return await client.get('v1/bookmarks/:id/article', {id});
33+
async getReader(id: string) {
34+
return await client.get('v1/bookmarks/:id/reader', {id});
3435
},
3536

3637
/**
@@ -45,8 +46,8 @@ export const bookmarks = sdk(client => ({
4546
*
4647
* @param {String} url - The URL of the bookmark
4748
*/
48-
async exists(url: string) {
49-
return await client.post('v1/bookmarks/exists', {url}, {});
49+
async exists(url: string, collection: string | null = null) {
50+
return await client.post('v1/bookmarks/exists', {url, collection}, {});
5051
},
5152

5253
/**
@@ -94,29 +95,12 @@ export const bookmarks = sdk(client => ({
9495
collection: string | null = null,
9596
) {
9697
return await client.post(
97-
'v1/bookmarks/from-parsed-data',
98+
'v1/bookmarks/from-parsed-link',
9899
{data, collection},
99100
{},
100101
);
101102
},
102103

103-
/**
104-
* Create a new bookmark from manual data
105-
*/
106-
async createFromEntry(data: ManualBookmarkEntry) {
107-
let payload = {} as ManualBookmarkEntryPayload;
108-
109-
data.tags
110-
? (payload = {...data, tags: data.tags.join(',')})
111-
: (payload = data as unknown as ManualBookmarkEntryPayload);
112-
113-
if (data.cover) {
114-
payload = {...payload, coverType: 'default'};
115-
}
116-
117-
return await client.post('v1/bookmarks/manual', payload, {});
118-
},
119-
120104
/**
121105
* Create a new bookmark from file upload
122106
*/
@@ -143,6 +127,30 @@ export const bookmarks = sdk(client => ({
143127
return await client.post('v1/bookmarks/file', formData, {});
144128
},
145129

130+
/**
131+
* Create a new bookmark from browser extension tabs upload
132+
*/
133+
async createFromTabs(data: BookmarkTabsEntry) {
134+
return await client.post('v1/bookmarks/tabs', data, {});
135+
},
136+
137+
/**
138+
* Create a new bookmark from manual data
139+
*/
140+
async createFromEntry(data: ManualBookmarkEntry) {
141+
let payload = {} as ManualBookmarkEntryPayload;
142+
143+
data.tags
144+
? (payload = {...data, tags: data.tags.join(',')})
145+
: (payload = data as unknown as ManualBookmarkEntryPayload);
146+
147+
if (data.cover) {
148+
payload = {...payload, coverType: 'default'};
149+
}
150+
151+
return await client.post('v1/bookmarks/manual', payload, {});
152+
},
153+
146154
/**
147155
* Re-parse the data of a bookmark
148156
*

src/types/api-keys.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type {OBJECT_ID} from './generic';
2+
export type APIStatus = 'active' | 'inactive';
3+
4+
export type APIKey = {
5+
id: string;
6+
7+
/**
8+
* The secret key of the API key
9+
*
10+
* This can only be fetched once.
11+
*/
12+
secret?: string;
13+
14+
/**
15+
* The last time the API key was used
16+
*
17+
* Updated whenever a call is made using the API key
18+
*/
19+
lastUsed: number;
20+
21+
/**
22+
* The last time the API key was edited
23+
*/
24+
updateAt: number;
25+
26+
/**
27+
* The time the API key was created
28+
*/
29+
createdAt: number;
30+
31+
/**
32+
* The ID of the user who created the API key
33+
*/
34+
owner: OBJECT_ID;
35+
36+
/**
37+
* Current status of the API key
38+
*/
39+
status: APIStatus;
40+
41+
/**
42+
* The name of the API key
43+
*/
44+
name: string;
45+
46+
/**
47+
* Amount of requests made using the API key
48+
*/
49+
usageCount: number;
50+
};

0 commit comments

Comments
 (0)