rmapi-js 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -5
- package/dist/index.js +10 -5
- package/dist/index.spec.d.ts +1 -0
- package/dist/index.spec.js +800 -0
- package/dist/rmapi-js.esm.min.js +1 -0
- package/dist/test-utils.d.ts +22 -0
- package/dist/test-utils.js +71 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -3
- package/dist/utils.spec.d.ts +1 -0
- package/dist/utils.spec.js +21 -0
- package/dist/validate.spec.d.ts +1 -0
- package/dist/validate.spec.js +15 -0
- package/package.json +17 -129
- package/CHANGELOG.md +0 -93
- package/bundle/rmapi-js.cjs.min.js +0 -12
- package/bundle/rmapi-js.esm.min.js +0 -12
- package/bundle/rmapi-js.iife.min.js +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -234,7 +234,7 @@ export interface CacheLike {
|
|
|
234
234
|
/** stripped down version of subtle crypto */
|
|
235
235
|
export interface SubtleCryptoLike {
|
|
236
236
|
/** a digest function */
|
|
237
|
-
digest(algorithm: "SHA-256", data:
|
|
237
|
+
digest(algorithm: "SHA-256", data: BufferSource): Promise<ArrayBuffer>;
|
|
238
238
|
}
|
|
239
239
|
/** an error that results from a failed request */
|
|
240
240
|
export declare class ResponseError extends Error {
|
|
@@ -343,6 +343,16 @@ export interface PutPdfOptions {
|
|
|
343
343
|
/** the tool to have enabled by default */
|
|
344
344
|
lastTool?: string;
|
|
345
345
|
}
|
|
346
|
+
/** options for getting responses */
|
|
347
|
+
export interface GetOptions {
|
|
348
|
+
/**
|
|
349
|
+
* whether to verify the types of the response
|
|
350
|
+
*
|
|
351
|
+
* Omitting will make the results always work, but they might nit return
|
|
352
|
+
* accurate types anymore.
|
|
353
|
+
*/
|
|
354
|
+
verify?: boolean | undefined;
|
|
355
|
+
}
|
|
346
356
|
/**
|
|
347
357
|
* the api for accessing remarkable functions
|
|
348
358
|
*/
|
|
@@ -397,7 +407,7 @@ export interface RemarkableApi {
|
|
|
397
407
|
*/
|
|
398
408
|
getJson(hash: string): Promise<unknown>;
|
|
399
409
|
/** get metadata from hash */
|
|
400
|
-
getMetadata(hash: string): Promise<Metadata>;
|
|
410
|
+
getMetadata(hash: string, opts?: GetOptions): Promise<Metadata>;
|
|
401
411
|
/**
|
|
402
412
|
* get entries from a collection hash
|
|
403
413
|
*
|
|
@@ -569,7 +579,7 @@ export interface RemarkableApi {
|
|
|
569
579
|
* @remarks this uses a newer api, that returns metadata associated with all
|
|
570
580
|
* entries and their hash and documentId.
|
|
571
581
|
*/
|
|
572
|
-
getEntriesMetadata(): Promise<MetadataEntry[]>;
|
|
582
|
+
getEntriesMetadata(opts?: GetOptions): Promise<MetadataEntry[]>;
|
|
573
583
|
/**
|
|
574
584
|
* upload an epub
|
|
575
585
|
*
|
|
@@ -585,7 +595,7 @@ export interface RemarkableApi {
|
|
|
585
595
|
* @param visibleName - the name to show for the uploaded epub
|
|
586
596
|
* @param buffer - the epub contents
|
|
587
597
|
*/
|
|
588
|
-
uploadEpub(visibleName: string, buffer: ArrayBuffer): Promise<UploadEntry>;
|
|
598
|
+
uploadEpub(visibleName: string, buffer: ArrayBuffer, opts?: GetOptions): Promise<UploadEntry>;
|
|
589
599
|
/**
|
|
590
600
|
* upload a pdf
|
|
591
601
|
*
|
|
@@ -605,7 +615,7 @@ export interface RemarkableApi {
|
|
|
605
615
|
* @param buffer - the epub contents
|
|
606
616
|
* @experimental
|
|
607
617
|
*/
|
|
608
|
-
uploadPdf(visibleName: string, buffer: ArrayBuffer): Promise<UploadEntry>;
|
|
618
|
+
uploadPdf(visibleName: string, buffer: ArrayBuffer, opts?: GetOptions): Promise<UploadEntry>;
|
|
609
619
|
/**
|
|
610
620
|
* get the current state of the cache for persisting
|
|
611
621
|
*
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ const GENERATION_HEADER = "x-goog-generation";
|
|
|
52
52
|
const GENERATION_RACE_HEADER = "x-goog-if-generation-match";
|
|
53
53
|
const CONTENT_LENGTH_RANGE_HEADER = "x-goog-content-length-range";
|
|
54
54
|
/** tool options */
|
|
55
|
+
/* eslint-disable spellcheck/spell-checker */
|
|
55
56
|
export const builtinTools = [
|
|
56
57
|
"Ballpoint",
|
|
57
58
|
"Ballpointv2",
|
|
@@ -74,7 +75,9 @@ export const builtinTools = [
|
|
|
74
75
|
"SolidPen",
|
|
75
76
|
"ZoomTool",
|
|
76
77
|
];
|
|
78
|
+
/* eslint-enable spellcheck/spell-checker */
|
|
77
79
|
/** font name options */
|
|
80
|
+
/* eslint-disable spellcheck/spell-checker */
|
|
78
81
|
export const builtinFontNames = [
|
|
79
82
|
"Maison Neue",
|
|
80
83
|
"EB Garamond",
|
|
@@ -83,6 +86,7 @@ export const builtinFontNames = [
|
|
|
83
86
|
"Noto Mono",
|
|
84
87
|
"Noto Sans UI",
|
|
85
88
|
];
|
|
89
|
+
/* eslint-enable spellcheck/spell-checker */
|
|
86
90
|
/** text scale options */
|
|
87
91
|
export const builtinTextScales = {
|
|
88
92
|
/** the smallest */
|
|
@@ -550,10 +554,10 @@ class Remarkable {
|
|
|
550
554
|
entries.sort((a, b) => a.documentId.localeCompare(b.documentId));
|
|
551
555
|
const hashes = concatBuffers(entries.map((ent) => fromHex(ent.hash)));
|
|
552
556
|
const digest = await this.#subtle.digest("SHA-256", hashes);
|
|
553
|
-
const hash = toHex(digest);
|
|
557
|
+
const hash = toHex(new Uint8Array(digest));
|
|
554
558
|
const entryContents = entries.map(formatEntry).join("");
|
|
555
559
|
const contents = `${SCHEMA_VERSION}\n${entryContents}`;
|
|
556
|
-
const buffer = enc.encode(contents);
|
|
560
|
+
const buffer = enc.encode(contents).buffer;
|
|
557
561
|
await this.#putHash(hash, buffer);
|
|
558
562
|
return {
|
|
559
563
|
hash,
|
|
@@ -566,7 +570,7 @@ class Remarkable {
|
|
|
566
570
|
/** put a raw buffer in the cloud */
|
|
567
571
|
async putBuffer(documentId, buffer) {
|
|
568
572
|
const digest = await this.#subtle.digest("SHA-256", buffer);
|
|
569
|
-
const hash = toHex(digest);
|
|
573
|
+
const hash = toHex(new Uint8Array(digest));
|
|
570
574
|
await this.#putHash(hash, buffer);
|
|
571
575
|
return {
|
|
572
576
|
hash,
|
|
@@ -579,7 +583,8 @@ class Remarkable {
|
|
|
579
583
|
/** put text in the cloud */
|
|
580
584
|
async putText(documentId, contents) {
|
|
581
585
|
const enc = new TextEncoder();
|
|
582
|
-
|
|
586
|
+
const encoded = enc.encode(contents).buffer;
|
|
587
|
+
return await this.putBuffer(documentId, encoded);
|
|
583
588
|
}
|
|
584
589
|
/** put json in the cloud */
|
|
585
590
|
async putJson(documentId, contents) {
|
|
@@ -770,7 +775,7 @@ class Remarkable {
|
|
|
770
775
|
return await this.#tryPutRootEntries(gen, rootEntries, sync);
|
|
771
776
|
}
|
|
772
777
|
/** get entries and metadata for all files */
|
|
773
|
-
async getEntriesMetadata({ verify = true
|
|
778
|
+
async getEntriesMetadata({ verify = true } = {}) {
|
|
774
779
|
const resp = await this.#authedFetch(`${this.#syncHost}/doc/v2/files`, {
|
|
775
780
|
method: "GET",
|
|
776
781
|
headers: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|