diff --git a/README.md b/README.md index 1eccb45..01046fb 100644 --- a/README.md +++ b/README.md @@ -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 api key', + apiKey: 'your api key', baseUrl: 'https://api-prod.omnivore.app', }) @@ -175,7 +175,7 @@ The `Omnivore` class accepts an options object with the following properties: | Option | Default value | Type | Description | | ----------- | --------------------------------- | -------- | ------------------------------------------------------------------------------------ | -| `authToken` | `undefined` | `string` | API key required for authentication. | +| `apiKey` | `undefined` | `string` | API key required for authentication. | | `baseUrl` | `"https://api-prod.omnivore.app"` | `string` | The base URL for sending API requests. This can be changed to a local-hosted server. | | `timeoutMs` | `0` | `number` | Number of milliseconds to wait before timeout. | diff --git a/package.json b/package.json index 808d0a6..3df3845 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@omnivore-app/api", - "version": "1.0.3", + "version": "1.0.4", "description": "Omnivore API Client Library for Node.js", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", diff --git a/src/client.ts b/src/client.ts index 4cc4c5f..5fd5b5a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -8,7 +8,7 @@ import { } from './graphql' export interface ClientOptions { - authToken: string + apiKey: string baseUrl?: string timeoutMs?: number } @@ -98,6 +98,8 @@ export interface SearchItemResponse { export interface ItemUpdatesParameters { since: string + after?: number + first?: number } export type ItemUpdateReason = 'CREATED' | 'UPDATED' | 'DELETED' @@ -153,7 +155,7 @@ export class Omnivore { exchanges: [fetchExchange], fetchOptions: () => ({ headers: { - Authorization: clientOptions.authToken, + Authorization: clientOptions.apiKey, }, timeout: clientOptions.timeoutMs || 0, }), @@ -188,7 +190,10 @@ export class Omnivore { params: ItemUpdatesParameters, ): Promise => { const { data, error } = await this.client - .query(UpdatesSinceQuery, params) + .query(UpdatesSinceQuery, { + ...params, + after: params.after ? String(params.after) : undefined, + }) .toPromise() const updatesSince = data?.updatesSince diff --git a/src/graphql.ts b/src/graphql.ts index cd2a6b8..70778d0 100644 --- a/src/graphql.ts +++ b/src/graphql.ts @@ -128,8 +128,8 @@ export const SearchQuery = graphql( export const UpdatesSinceQuery = graphql( ` - query UpdatesSince($since: Date!) { - updatesSince(since: $since) { + query UpdatesSince($after: String, $first: Int, $since: Date!) { + updatesSince(after: $after, first: $first, since: $since) { __typename ... on UpdatesSinceSuccess { edges { diff --git a/src/index.ts b/src/index.ts index a1327d1..cdd3d43 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ export { ItemFormat, ItemType, ItemUpdateReason, + ItemUpdatesParameters, ItemUpdatesResponse, Label, LibraryItemState,