Skip to content

Commit

Permalink
update type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Mar 8, 2024
1 parent 59f1857 commit b06d419
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Import the `Omnivore` class and create a new instance with your **API Key** and
import { Omnivore } from '@omnivore-app/api'

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@omnivore-app/api",
"version": "1.0.1",
"version": "1.0.2",
"description": "Omnivore API Client Library for Node.js",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down
49 changes: 28 additions & 21 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ClientOptions {
timeoutMs?: number
}

export type PageType =
export type ItemType =
| 'ARTICLE'
| 'BOOK'
| 'FILE'
Expand All @@ -27,6 +27,8 @@ export type PageType =

export interface Label {
name: string
color: string | null
description: string | null
}

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

export interface Node {
export interface Item {
id: string
title: string
siteName: string | null
Expand All @@ -56,7 +58,7 @@ export interface Node {
highlights: Highlight[] | null
updatedAt: string | null
savedAt: string
pageType: PageType
pageType: ItemType
content: string | null
publishedAt: string | null
url: string
Expand All @@ -77,17 +79,19 @@ export interface PageInfo {
totalCount: number | null
}

export type ItemFormat = 'html' | 'markdown'

export interface SearchItemParameters {
after?: string
after?: number
first?: number
format?: 'html' | 'markdown'
format?: ItemFormat
includeContent?: boolean
query?: string
}

export interface SearchItemResponse {
edges: {
node: Node
node: Item
}[]
pageInfo: PageInfo
}
Expand All @@ -96,34 +100,34 @@ export interface ItemUpdatesParameters {
since: string
}

export type ItemUpdateReason = 'CREATED' | 'UPDATED' | 'DELETED'

export interface ItemUpdatesResponse {
edges: {
itemID: string
updateReason: 'CREATED' | 'UPDATED' | 'DELETED'
node: Node | null
updateReason: ItemUpdateReason
node: Item | null
}[]
pageInfo: PageInfo
}

export type LibraryItemState =
| 'DELETED'
| 'ARCHIVED'
| 'CONTENT_NOT_FETCHED'
| 'FAILED'
| 'PROCESSING'
| 'SUCCEEDED'

export interface SaveItemByUrlParameters {
url: string
clientRequestId?: string
source?: string
state?:
| 'DELETED'
| 'ARCHIVED'
| 'CONTENT_NOT_FETCHED'
| 'FAILED'
| 'PROCESSING'
| 'SUCCEEDED'
state?: LibraryItemState
timezone?: string
locale?: string
folder?: string
labels?: {
name: string
color?: string
description?: string
}[]
labels?: Label[]
publishedAt: string
savedAt: string
}
Expand Down Expand Up @@ -163,7 +167,10 @@ export class Omnivore {
params: SearchItemParameters,
): Promise<SearchItemResponse> => {
const { data, error } = await this.client
.query(SearchQuery, params)
.query(SearchQuery, {
...params,
after: params.after ? String(params.after) : undefined,
})
.toPromise()

const search = data?.search
Expand Down
19 changes: 11 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
export {
ClientOptions,
DeleteItemResponse as DeleteResponse,
DeleteItemResponse,
Highlight,
HighlightType,
Item,
ItemFormat,
ItemType,
ItemUpdateReason,
ItemUpdatesResponse,
Label,
Node,
LibraryItemState,
Omnivore,
PageInfo,
PageType,
SaveItemByUrlParameters as SaveByURLParameters,
SaveItemByUrlResponse as SaveByURLResponse,
SearchItemParameters as SearchParameters,
SearchItemResponse as SearchResponse,
ItemUpdatesResponse as UpdatesSinceResponse,
SaveItemByUrlParameters,
SaveItemByUrlResponse,
SearchItemParameters,
SearchItemResponse,
} from './client'

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

0 comments on commit b06d419

Please sign in to comment.