Skip to content

Commit ce99d23

Browse files
committed
replace authToken with apiKey
1 parent f8b6b64 commit ce99d23

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

README.md

+2-2
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 api key',
23+
apiKey: 'your api key',
2424
baseUrl: 'https://api-prod.omnivore.app',
2525
})
2626

@@ -175,7 +175,7 @@ The `Omnivore` class accepts an options object with the following properties:
175175

176176
| Option | Default value | Type | Description |
177177
| ----------- | --------------------------------- | -------- | ------------------------------------------------------------------------------------ |
178-
| `authToken` | `undefined` | `string` | API key required for authentication. |
178+
| `apiKey` | `undefined` | `string` | API key required for authentication. |
179179
| `baseUrl` | `"https://api-prod.omnivore.app"` | `string` | The base URL for sending API requests. This can be changed to a local-hosted server. |
180180
| `timeoutMs` | `0` | `number` | Number of milliseconds to wait before timeout. |
181181

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.3",
3+
"version": "1.0.4",
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

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from './graphql'
99

1010
export interface ClientOptions {
11-
authToken: string
11+
apiKey: string
1212
baseUrl?: string
1313
timeoutMs?: number
1414
}
@@ -98,6 +98,8 @@ export interface SearchItemResponse {
9898

9999
export interface ItemUpdatesParameters {
100100
since: string
101+
after?: number
102+
first?: number
101103
}
102104

103105
export type ItemUpdateReason = 'CREATED' | 'UPDATED' | 'DELETED'
@@ -153,7 +155,7 @@ export class Omnivore {
153155
exchanges: [fetchExchange],
154156
fetchOptions: () => ({
155157
headers: {
156-
Authorization: clientOptions.authToken,
158+
Authorization: clientOptions.apiKey,
157159
},
158160
timeout: clientOptions.timeoutMs || 0,
159161
}),
@@ -188,7 +190,10 @@ export class Omnivore {
188190
params: ItemUpdatesParameters,
189191
): Promise<ItemUpdatesResponse> => {
190192
const { data, error } = await this.client
191-
.query(UpdatesSinceQuery, params)
193+
.query(UpdatesSinceQuery, {
194+
...params,
195+
after: params.after ? String(params.after) : undefined,
196+
})
192197
.toPromise()
193198

194199
const updatesSince = data?.updatesSince

src/graphql.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ export const SearchQuery = graphql(
128128

129129
export const UpdatesSinceQuery = graphql(
130130
`
131-
query UpdatesSince($since: Date!) {
132-
updatesSince(since: $since) {
131+
query UpdatesSince($after: String, $first: Int, $since: Date!) {
132+
updatesSince(after: $after, first: $first, since: $since) {
133133
__typename
134134
... on UpdatesSinceSuccess {
135135
edges {

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {
77
ItemFormat,
88
ItemType,
99
ItemUpdateReason,
10+
ItemUpdatesParameters,
1011
ItemUpdatesResponse,
1112
Label,
1213
LibraryItemState,

0 commit comments

Comments
 (0)