Skip to content

Commit b06d419

Browse files
committed
update type definition
1 parent 59f1857 commit b06d419

File tree

4 files changed

+41
-31
lines changed

4 files changed

+41
-31
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Import the `Omnivore` class and create a new instance with your **API Key** and
2020
import { Omnivore } from '@omnivore-app/api'
2121

2222
const omnivore = new Omnivore({
23-
authToken: 'your-auth-token',
23+
authToken: 'your api key',
2424
baseUrl: 'https://api-prod.omnivore.app',
2525
})
2626

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@omnivore-app/api",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Omnivore API Client Library for Node.js",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",

src/client.ts

+28-21
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface ClientOptions {
1313
timeoutMs?: number
1414
}
1515

16-
export type PageType =
16+
export type ItemType =
1717
| 'ARTICLE'
1818
| 'BOOK'
1919
| 'FILE'
@@ -27,6 +27,8 @@ export type PageType =
2727

2828
export interface Label {
2929
name: string
30+
color: string | null
31+
description: string | null
3032
}
3133

3234
export type HighlightType = 'HIGHLIGHT' | 'NOTE' | 'REDACTION'
@@ -44,7 +46,7 @@ export interface Highlight {
4446
highlightPositionAnchorIndex: number | null
4547
}
4648

47-
export interface Node {
49+
export interface Item {
4850
id: string
4951
title: string
5052
siteName: string | null
@@ -56,7 +58,7 @@ export interface Node {
5658
highlights: Highlight[] | null
5759
updatedAt: string | null
5860
savedAt: string
59-
pageType: PageType
61+
pageType: ItemType
6062
content: string | null
6163
publishedAt: string | null
6264
url: string
@@ -77,17 +79,19 @@ export interface PageInfo {
7779
totalCount: number | null
7880
}
7981

82+
export type ItemFormat = 'html' | 'markdown'
83+
8084
export interface SearchItemParameters {
81-
after?: string
85+
after?: number
8286
first?: number
83-
format?: 'html' | 'markdown'
87+
format?: ItemFormat
8488
includeContent?: boolean
8589
query?: string
8690
}
8791

8892
export interface SearchItemResponse {
8993
edges: {
90-
node: Node
94+
node: Item
9195
}[]
9296
pageInfo: PageInfo
9397
}
@@ -96,34 +100,34 @@ export interface ItemUpdatesParameters {
96100
since: string
97101
}
98102

103+
export type ItemUpdateReason = 'CREATED' | 'UPDATED' | 'DELETED'
104+
99105
export interface ItemUpdatesResponse {
100106
edges: {
101107
itemID: string
102-
updateReason: 'CREATED' | 'UPDATED' | 'DELETED'
103-
node: Node | null
108+
updateReason: ItemUpdateReason
109+
node: Item | null
104110
}[]
105111
pageInfo: PageInfo
106112
}
107113

114+
export type LibraryItemState =
115+
| 'DELETED'
116+
| 'ARCHIVED'
117+
| 'CONTENT_NOT_FETCHED'
118+
| 'FAILED'
119+
| 'PROCESSING'
120+
| 'SUCCEEDED'
121+
108122
export interface SaveItemByUrlParameters {
109123
url: string
110124
clientRequestId?: string
111125
source?: string
112-
state?:
113-
| 'DELETED'
114-
| 'ARCHIVED'
115-
| 'CONTENT_NOT_FETCHED'
116-
| 'FAILED'
117-
| 'PROCESSING'
118-
| 'SUCCEEDED'
126+
state?: LibraryItemState
119127
timezone?: string
120128
locale?: string
121129
folder?: string
122-
labels?: {
123-
name: string
124-
color?: string
125-
description?: string
126-
}[]
130+
labels?: Label[]
127131
publishedAt: string
128132
savedAt: string
129133
}
@@ -163,7 +167,10 @@ export class Omnivore {
163167
params: SearchItemParameters,
164168
): Promise<SearchItemResponse> => {
165169
const { data, error } = await this.client
166-
.query(SearchQuery, params)
170+
.query(SearchQuery, {
171+
...params,
172+
after: params.after ? String(params.after) : undefined,
173+
})
167174
.toPromise()
168175

169176
const search = data?.search

src/index.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
export {
22
ClientOptions,
3-
DeleteItemResponse as DeleteResponse,
3+
DeleteItemResponse,
44
Highlight,
55
HighlightType,
6+
Item,
7+
ItemFormat,
8+
ItemType,
9+
ItemUpdateReason,
10+
ItemUpdatesResponse,
611
Label,
7-
Node,
12+
LibraryItemState,
813
Omnivore,
914
PageInfo,
10-
PageType,
11-
SaveItemByUrlParameters as SaveByURLParameters,
12-
SaveItemByUrlResponse as SaveByURLResponse,
13-
SearchItemParameters as SearchParameters,
14-
SearchItemResponse as SearchResponse,
15-
ItemUpdatesResponse as UpdatesSinceResponse,
15+
SaveItemByUrlParameters,
16+
SaveItemByUrlResponse,
17+
SearchItemParameters,
18+
SearchItemResponse,
1619
} from './client'
1720

1821
export { OmnivoreError, OmnivoreErrorCode, isOmnivoreError } from './errors'

0 commit comments

Comments
 (0)