Skip to content

Commit 2b1e364

Browse files
committed
API Keys & fixes
implemented API Keys stripped data field from the results
1 parent 435bd39 commit 2b1e364

File tree

12 files changed

+272
-211
lines changed

12 files changed

+272
-211
lines changed

TODO.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- [] implement /api/api-keys
2+
- [] implement /api/parser
3+
4+
- [] links parser
5+
- [] file - csv
6+
- [] file - html
7+
- [] file - text
8+
- [] file - import
9+
10+
- [] implement /api/files
11+
12+
- [] get file link
13+
- [] share file link
14+
15+
- [] implement /api/invites
16+
- [] implement /api/invite-links
17+
- [] implement /api/search
18+
- [] implement /api/highlights
19+
- [] implement /api/reminders
20+
- [] once the models are set, add prefixes to the IDs

src/linkvite.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {apiKeys} from './sdks/api_keys';
12
import {user, bookmarks, collections} from './sdks';
23
import {APIClient, type APIClientOptions} from './rest';
34

@@ -22,6 +23,7 @@ export class Linkvite {
2223
public readonly user;
2324
public readonly bookmarks;
2425
public readonly collections;
26+
public readonly apiKeys;
2527

2628
constructor(optionsOrKey: string | APIClientOptions) {
2729
if (
@@ -46,5 +48,6 @@ export class Linkvite {
4648
this.user = user(this.client);
4749
this.bookmarks = bookmarks(this.client);
4850
this.collections = collections(this.client);
51+
this.apiKeys = apiKeys(this.client);
4952
}
5053
}

src/rest/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class APIClient {
9494
init?: RequestInit,
9595
) {
9696
return this.request<
97-
T & Extract<Endpoints, {method: 'GET'; path: Path}>['res']['data']
97+
T & Extract<Endpoints, {method: 'GET'; path: Path}>['res']
9898
>('GET', path, undefined, query, init);
9999
}
100100

src/rest/endpoints.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
APIKeyEndpoints,
23
AuthEndpoints,
34
BookmarkEndpoints,
45
CollectionEndpoints,
@@ -62,4 +63,5 @@ export type Endpoints =
6263
| UserEndpoints
6364
| BookmarkEndpoints
6465
| CollectionEndpoints
65-
| AuthEndpoints;
66+
| AuthEndpoints
67+
| APIKeyEndpoints;

src/sdks/api_keys.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {sdk} from './create';
2+
import type {CreateOrUpdateAPIKeyEntry} from '../types';
3+
4+
/**
5+
* API keys SDK client
6+
* @public
7+
*/
8+
export const apiKeys = sdk(client => ({
9+
/**
10+
* Get all the user's API keys
11+
*/
12+
async getAll() {
13+
return await client.get('v1/api-keys', {});
14+
},
15+
16+
/**
17+
* Create a new API key
18+
*
19+
* @param {CreateOrUpdateAPIKeyEntry} data - Contains the name of the API key
20+
*/
21+
async create(data: CreateOrUpdateAPIKeyEntry) {
22+
return await client.post('v1/api-keys', data, {});
23+
},
24+
25+
/**
26+
* Update an API key
27+
*
28+
* @param {String} id - The ID of the API key
29+
* @param {CreateOrUpdateAPIKeyEntry} data - Contains the name of the API key
30+
*/
31+
async update(id: string, data: CreateOrUpdateAPIKeyEntry) {
32+
return await client.patch(`v1/api-keys/:id`, data, {id});
33+
},
34+
}));

0 commit comments

Comments
 (0)