Skip to content

Commit

Permalink
update interfaces to match functions
Browse files Browse the repository at this point in the history
fixes #11
  • Loading branch information
erikbrinkman committed Apr 8, 2024
1 parent 6208422 commit 1620b43
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,17 @@ export interface PutPdfOptions {
lastTool?: string;
}

/** options for getting responses */
export interface GetOptions {
/**
* whether to verify the types of the response
*
* Omitting will make the results always work, but they might nit return
* accurate types anymore.
*/
verify?: boolean | undefined;
}

/**
* the api for accessing remarkable functions
*/
Expand Down Expand Up @@ -692,7 +703,7 @@ export interface RemarkableApi {
getJson(hash: string): Promise<unknown>;

/** get metadata from hash */
getMetadata(hash: string): Promise<Metadata>;
getMetadata(hash: string, opts?: GetOptions): Promise<Metadata>;

/**
* get entries from a collection hash
Expand Down Expand Up @@ -889,7 +900,7 @@ export interface RemarkableApi {
* @remarks this uses a newer api, that returns metadata associated with all
* entries and their hash and documentId.
*/
getEntriesMetadata(): Promise<MetadataEntry[]>;
getEntriesMetadata(opts?: GetOptions): Promise<MetadataEntry[]>;

/**
* upload an epub
Expand All @@ -906,7 +917,11 @@ export interface RemarkableApi {
* @param visibleName - the name to show for the uploaded epub
* @param buffer - the epub contents
*/
uploadEpub(visibleName: string, buffer: ArrayBuffer): Promise<UploadEntry>;
uploadEpub(
visibleName: string,
buffer: ArrayBuffer,
opts?: GetOptions,
): Promise<UploadEntry>;

/**
* upload a pdf
Expand All @@ -927,7 +942,11 @@ export interface RemarkableApi {
* @param buffer - the epub contents
* @experimental
*/
uploadPdf(visibleName: string, buffer: ArrayBuffer): Promise<UploadEntry>;
uploadPdf(
visibleName: string,
buffer: ArrayBuffer,
opts?: GetOptions,
): Promise<UploadEntry>;

/**
* get the current state of the cache for persisting
Expand Down Expand Up @@ -1234,7 +1253,7 @@ class Remarkable implements RemarkableApi {
*/
async getMetadata(
hash: string,
{ verify = true }: { verify?: boolean } = {},
{ verify = true }: GetOptions = {},
): Promise<Metadata> {
const raw = await this.getJson(hash);
validate(metadataSchema, raw, verify);
Expand Down Expand Up @@ -1592,9 +1611,9 @@ class Remarkable implements RemarkableApi {
}

/** get entries and metadata for all files */
async getEntriesMetadata({
verify = true,
}: { verify?: boolean } = {}): Promise<MetadataEntry[]> {
async getEntriesMetadata({ verify = true }: GetOptions = {}): Promise<
MetadataEntry[]
> {
const resp = await this.#authedFetch(`${this.#syncHost}/doc/v2/files`, {
method: "GET",
headers: {
Expand Down Expand Up @@ -1637,7 +1656,7 @@ class Remarkable implements RemarkableApi {
async uploadEpub(
visibleName: string,
buffer: ArrayBuffer,
{ verify = true }: { verify?: boolean } = {},
{ verify = true }: GetOptions = {},
): Promise<UploadEntry> {
return await this.#uploadFile(
visibleName,
Expand All @@ -1651,7 +1670,7 @@ class Remarkable implements RemarkableApi {
async uploadPdf(
visibleName: string,
buffer: ArrayBuffer,
{ verify = true }: { verify?: boolean } = {},
{ verify = true }: GetOptions = {},
): Promise<UploadEntry> {
// TODO why doesn't this work
return await this.#uploadFile(
Expand Down

0 comments on commit 1620b43

Please sign in to comment.