rmapi-js 8.1.1 → 8.3.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/error.d.ts +14 -0
- package/dist/error.js +21 -0
- package/dist/index.d.ts +50 -526
- package/dist/index.js +65 -450
- package/dist/raw.d.ts +558 -0
- package/dist/raw.js +427 -0
- package/dist/rmapi-js.esm.min.js +12 -12
- package/package.json +12 -12
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** an error that results from a failed request */
|
|
2
|
+
export declare class ValidationError extends Error {
|
|
3
|
+
/** the response status number */
|
|
4
|
+
readonly field: string;
|
|
5
|
+
/** the response status text */
|
|
6
|
+
readonly regex: RegExp;
|
|
7
|
+
constructor(field: string, regex: RegExp, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** an error that results while supplying a hash not found in the entries of the root hash */
|
|
10
|
+
export declare class HashNotFoundError extends Error {
|
|
11
|
+
/** the hash that couldn't be found */
|
|
12
|
+
readonly hash: string;
|
|
13
|
+
constructor(hash: string);
|
|
14
|
+
}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** an error that results from a failed request */
|
|
2
|
+
export class ValidationError extends Error {
|
|
3
|
+
/** the response status number */
|
|
4
|
+
field;
|
|
5
|
+
/** the response status text */
|
|
6
|
+
regex;
|
|
7
|
+
constructor(field, regex, message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.field = field;
|
|
10
|
+
this.regex = regex;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** an error that results while supplying a hash not found in the entries of the root hash */
|
|
14
|
+
export class HashNotFoundError extends Error {
|
|
15
|
+
/** the hash that couldn't be found */
|
|
16
|
+
hash;
|
|
17
|
+
constructor(hash) {
|
|
18
|
+
super(`'${hash}' not found in the root hash`);
|
|
19
|
+
this.hash = hash;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,68 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export interface Tag {
|
|
5
|
-
/** the name of the tag */
|
|
6
|
-
name: string;
|
|
7
|
-
/** the timestamp when this tag was added */
|
|
8
|
-
timestamp: number;
|
|
9
|
-
}
|
|
10
|
-
/** a tag for individual pages */
|
|
11
|
-
export interface PageTag extends Tag {
|
|
12
|
-
/** the id of the page this is on */
|
|
13
|
-
pageId: string;
|
|
14
|
-
}
|
|
15
|
-
/** the type of files reMarkable supports */
|
|
16
|
-
export type FileType = "epub" | "pdf" | "notebook";
|
|
17
|
-
/** all supported document orientations */
|
|
18
|
-
export type Orientation = "portrait" | "landscape";
|
|
19
|
-
/** all supported text alignments */
|
|
20
|
-
export type TextAlignment = "justify" | "left";
|
|
21
|
-
/** types of zoom modes for documents, applies primarily to pdf files */
|
|
22
|
-
export type ZoomMode = "bestFit" | "customFit" | "fitToHeight" | "fitToWidth";
|
|
23
|
-
/**
|
|
24
|
-
* types of background filter
|
|
25
|
-
*
|
|
26
|
-
* off has no background filter, best for images, full page applies the high
|
|
27
|
-
* contrast filter to the entire page. If this is omitted, reMarkable will try
|
|
28
|
-
* to apply the filter only to text areas.
|
|
29
|
-
*/
|
|
30
|
-
export type BackgroundFilter = "off" | "fullpage";
|
|
31
|
-
/**
|
|
32
|
-
* the low-level entry corresponding to a collection of files
|
|
33
|
-
*
|
|
34
|
-
* A collection could be for the root collection, or for an individual document,
|
|
35
|
-
* which is often a collection of files. If an entry represents a collection of
|
|
36
|
-
* files, the high level entry will have the same hash and id as the low-level
|
|
37
|
-
* entry for that collection.
|
|
38
|
-
*/
|
|
39
|
-
export interface RawListEntry {
|
|
40
|
-
/** collection type (80000000) */
|
|
41
|
-
type: 80000000;
|
|
42
|
-
/** the hash of the collection this points to */
|
|
43
|
-
hash: string;
|
|
44
|
-
/** the unique id of the collection */
|
|
45
|
-
id: string;
|
|
46
|
-
/** the number of subfiles */
|
|
47
|
-
subfiles: number;
|
|
48
|
-
/** the total size of everything in the collection */
|
|
49
|
-
size: number;
|
|
50
|
-
}
|
|
51
|
-
/** the low-level entry for a single file */
|
|
52
|
-
export interface RawFileEntry {
|
|
53
|
-
/** file type (0) */
|
|
54
|
-
type: 0;
|
|
55
|
-
/** the hash of the file this points to */
|
|
56
|
-
hash: string;
|
|
57
|
-
/** the unique id of the file */
|
|
58
|
-
id: string;
|
|
59
|
-
/** the number of subfiles, always zero */
|
|
60
|
-
subfiles: 0;
|
|
61
|
-
/** the size of the file in bytes */
|
|
62
|
-
size: number;
|
|
63
|
-
}
|
|
64
|
-
/** a low-level stored entry */
|
|
65
|
-
export type RawEntry = RawListEntry | RawFileEntry;
|
|
1
|
+
import { type BackgroundFilter, type CollectionContent, type Content, type DocumentContent, type Metadata, type Orientation, type RawRemarkableApi, type Tag, type TemplateContent, type TextAlignment, type ZoomMode } from "./raw";
|
|
2
|
+
export { HashNotFoundError, ValidationError } from "./error";
|
|
3
|
+
export type { BackgroundFilter, CollectionContent, Content, CPageNumberValue, CPagePage, CPages, CPageStringValue, CPageUUID, DocumentContent, DocumentMetadata, FileType, KeyboardMetadata, Metadata, Orientation, PageTag, RawEntry, RawFileEntry, RawListEntry, RawRemarkableApi, Tag, TemplateContent, TextAlignment, ZoomMode, } from "./raw";
|
|
66
4
|
/** common properties shared by collections and documents */
|
|
67
5
|
export interface EntryCommon {
|
|
68
6
|
/** the document id, a uuid4 */
|
|
@@ -149,20 +87,6 @@ export declare class ResponseError extends Error {
|
|
|
149
87
|
readonly statusText: string;
|
|
150
88
|
constructor(status: number, statusText: string, message: string);
|
|
151
89
|
}
|
|
152
|
-
/** an error that results from a failed request */
|
|
153
|
-
export declare class ValidationError extends Error {
|
|
154
|
-
/** the response status number */
|
|
155
|
-
readonly field: string;
|
|
156
|
-
/** the response status text */
|
|
157
|
-
readonly regex: RegExp;
|
|
158
|
-
constructor(field: string, regex: RegExp, message: string);
|
|
159
|
-
}
|
|
160
|
-
/** an error that results while supplying a hash not found in the entries of the root hash */
|
|
161
|
-
export declare class HashNotFoundError extends Error {
|
|
162
|
-
/** the hash that couldn't be found */
|
|
163
|
-
readonly hash: string;
|
|
164
|
-
constructor(hash: string);
|
|
165
|
-
}
|
|
166
90
|
/** options for registering with the api */
|
|
167
91
|
export interface RegisterOptions {
|
|
168
92
|
/**
|
|
@@ -195,272 +119,6 @@ export interface UploadOptions {
|
|
|
195
119
|
/** an optional parent id to set when uploading */
|
|
196
120
|
parent?: string;
|
|
197
121
|
}
|
|
198
|
-
/** document metadata stored in {@link Content} */
|
|
199
|
-
export interface DocumentMetadata {
|
|
200
|
-
/** a list of authors as a string */
|
|
201
|
-
authors?: string[];
|
|
202
|
-
/** the title as a string */
|
|
203
|
-
title?: string;
|
|
204
|
-
/** the publication date as an ISO date or timestamp */
|
|
205
|
-
publicationDate?: string;
|
|
206
|
-
/** the publisher */
|
|
207
|
-
publisher?: string;
|
|
208
|
-
}
|
|
209
|
-
/** [speculative] metadata stored about keyboard interactions */
|
|
210
|
-
export interface KeyboardMetadata {
|
|
211
|
-
/** [unknown] */
|
|
212
|
-
count: number;
|
|
213
|
-
/** [unknown] */
|
|
214
|
-
timestamp: number;
|
|
215
|
-
}
|
|
216
|
-
/** a c-page value who's type is a string */
|
|
217
|
-
export interface CPageStringValue {
|
|
218
|
-
/** a pseudo-timestamp of the form "1:1" or "1:2" */
|
|
219
|
-
timestamp: string;
|
|
220
|
-
/** the stored value */
|
|
221
|
-
value: string;
|
|
222
|
-
}
|
|
223
|
-
/** a c-page value who's type is a string */
|
|
224
|
-
export interface CPageNumberValue {
|
|
225
|
-
/** a pseudo-timestamp of the form "1:1" or "1:2" */
|
|
226
|
-
timestamp: string;
|
|
227
|
-
/** the stored value */
|
|
228
|
-
value: number;
|
|
229
|
-
}
|
|
230
|
-
/** [speculative] information about an individual page */
|
|
231
|
-
export interface CPagePage {
|
|
232
|
-
/** [speculative] the page id */
|
|
233
|
-
id: string;
|
|
234
|
-
/** [unknown] values are like "aa", "ab", "ba", etc. */
|
|
235
|
-
idx: CPageStringValue;
|
|
236
|
-
/** [unknown] */
|
|
237
|
-
redir?: CPageNumberValue;
|
|
238
|
-
/** [speculative] the template name of the page */
|
|
239
|
-
template?: CPageStringValue;
|
|
240
|
-
/** [unknown] the value is a timestamp */
|
|
241
|
-
scrollTime?: CPageStringValue;
|
|
242
|
-
/** [unknown] */
|
|
243
|
-
verticalScroll?: CPageNumberValue;
|
|
244
|
-
/** [unknown] */
|
|
245
|
-
deleted?: CPageNumberValue;
|
|
246
|
-
}
|
|
247
|
-
/** [unknown] */
|
|
248
|
-
export interface CPageUUID {
|
|
249
|
-
/** [unknown] */
|
|
250
|
-
first: string;
|
|
251
|
-
/** [unknown] */
|
|
252
|
-
second: number;
|
|
253
|
-
}
|
|
254
|
-
/** [unknown] metadata about pages */
|
|
255
|
-
export interface CPages {
|
|
256
|
-
/** [speculative] the last time the document was opened */
|
|
257
|
-
lastOpened: CPageStringValue;
|
|
258
|
-
/** [unknown] */
|
|
259
|
-
original: CPageNumberValue;
|
|
260
|
-
/** [speculative] information about individual pages */
|
|
261
|
-
pages: CPagePage[];
|
|
262
|
-
/** [unknown] */
|
|
263
|
-
uuids: CPageUUID[];
|
|
264
|
-
}
|
|
265
|
-
/** the content metadata for collections (folders) */
|
|
266
|
-
export interface CollectionContent {
|
|
267
|
-
/** the tags for the collection */
|
|
268
|
-
tags?: Tag[];
|
|
269
|
-
/** collections don't have a file type */
|
|
270
|
-
fileType?: undefined;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* content metadata, stored with the "content" extension
|
|
274
|
-
*
|
|
275
|
-
* This largely contains description of how to render the document, rather than
|
|
276
|
-
* metadata about it.
|
|
277
|
-
*/
|
|
278
|
-
export interface DocumentContent {
|
|
279
|
-
/**
|
|
280
|
-
* which page to use for the thumbnail
|
|
281
|
-
*
|
|
282
|
-
* -1 indicates the last visited page, whereas 0 is the first page.
|
|
283
|
-
*/
|
|
284
|
-
coverPageNumber: number;
|
|
285
|
-
/** metadata about the author, publishers, etc. */
|
|
286
|
-
documentMetadata: DocumentMetadata;
|
|
287
|
-
/** It's not known what this field is for */
|
|
288
|
-
dummyDocument?: boolean;
|
|
289
|
-
/** the largely contains metadata about what pens were used and their settings */
|
|
290
|
-
extraMetadata: Record<string, string>;
|
|
291
|
-
/** the underlying file type of this document */
|
|
292
|
-
fileType: FileType;
|
|
293
|
-
/**
|
|
294
|
-
* the name of the font to use for text rendering
|
|
295
|
-
*
|
|
296
|
-
* The reMarkable supports five fonts by default: "Noto Sans", "Noto Sans UI",
|
|
297
|
-
* "EB Garamond", "Noto Mono", and "Noto Serif". You can also set the font to
|
|
298
|
-
* the empty string or omit it for the default.
|
|
299
|
-
*/
|
|
300
|
-
fontName: string;
|
|
301
|
-
/** the format version, this should always be 1 */
|
|
302
|
-
formatVersion: number;
|
|
303
|
-
/** the last opened page, starts at zero */
|
|
304
|
-
lastOpenedPage?: number;
|
|
305
|
-
/**
|
|
306
|
-
* the line height
|
|
307
|
-
*
|
|
308
|
-
* The reMarkable uses three built-in line heights: 100, 150, 200, and
|
|
309
|
-
* uses -1 to indicate the default line height, but heights outside of these
|
|
310
|
-
* also work.
|
|
311
|
-
*/
|
|
312
|
-
lineHeight: number;
|
|
313
|
-
/**
|
|
314
|
-
* the document margin in pixels
|
|
315
|
-
*
|
|
316
|
-
* The reMarkable uses three built-in margins: 50, 125, 200, but other margins
|
|
317
|
-
* are possible. The reMarkable used to default to margins of 180.
|
|
318
|
-
*/
|
|
319
|
-
margins?: number;
|
|
320
|
-
/** the document orientation */
|
|
321
|
-
orientation: Orientation;
|
|
322
|
-
/** this specifies the number of pages, it's not clear how this is different than pageCount */
|
|
323
|
-
originalPageCount?: number;
|
|
324
|
-
/** the number of pages */
|
|
325
|
-
pageCount: number;
|
|
326
|
-
/** the page tags for the document */
|
|
327
|
-
pageTags?: PageTag[];
|
|
328
|
-
/** a list of the ids of each page in the document */
|
|
329
|
-
pages?: string[];
|
|
330
|
-
/** a mapping from page number to page id in pages */
|
|
331
|
-
redirectionPageMap?: number[];
|
|
332
|
-
/** ostensibly the size in bytes of the file, but this differs from other measurements */
|
|
333
|
-
sizeInBytes: string;
|
|
334
|
-
/** document tags for this document */
|
|
335
|
-
tags?: Tag[];
|
|
336
|
-
/** text alignment for this document */
|
|
337
|
-
textAlignment: TextAlignment;
|
|
338
|
-
/**
|
|
339
|
-
* the font size
|
|
340
|
-
*
|
|
341
|
-
* reMarkable uses six built-in text scales: 0.7, 0.8, 1, 1.2, 1.5, 2, but
|
|
342
|
-
* values outside of this range are valid.
|
|
343
|
-
*/
|
|
344
|
-
textScale: number;
|
|
345
|
-
/** [speculative] the center of the zoom for zoomed in documents */
|
|
346
|
-
customZoomCenterX?: number;
|
|
347
|
-
/** [speculative] the center of the zoom for zoomed in documents */
|
|
348
|
-
customZoomCenterY?: number;
|
|
349
|
-
/** [speculative] the orientation */
|
|
350
|
-
customZoomOrientation?: Orientation;
|
|
351
|
-
/** [speculative] the zoom height for zoomed in pages */
|
|
352
|
-
customZoomPageHeight?: number;
|
|
353
|
-
/** [speculative] the zoom width for zoomed in pages */
|
|
354
|
-
customZoomPageWidth?: number;
|
|
355
|
-
/** [speculative] the scale for zoomed in pages */
|
|
356
|
-
customZoomScale?: number;
|
|
357
|
-
/** what zoom mode is set for the page */
|
|
358
|
-
zoomMode?: ZoomMode;
|
|
359
|
-
/** [speculative] a transform matrix, a. la. css matrix transform */
|
|
360
|
-
transform?: Record<`m${"1" | "2" | "3"}${"1" | "2" | "3"}`, number>;
|
|
361
|
-
/** [speculative] metadata about keyboard use */
|
|
362
|
-
keyboardMetadata?: KeyboardMetadata;
|
|
363
|
-
/** [speculative] various other page metadata */
|
|
364
|
-
cPages?: CPages;
|
|
365
|
-
/**
|
|
366
|
-
* setting for the adaptive contrast filter
|
|
367
|
-
*
|
|
368
|
-
* off has no background filter, best for images, full page applies the high
|
|
369
|
-
* contrast filter to the entire page. If this is omitted, reMarkable will try
|
|
370
|
-
* to apply the filter only to text areas.
|
|
371
|
-
*/
|
|
372
|
-
viewBackgroundFilter?: BackgroundFilter;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* content metadata, stored with the "content" extension
|
|
376
|
-
*
|
|
377
|
-
* This largely contains description of how to render the document, rather than
|
|
378
|
-
* metadata about it.
|
|
379
|
-
*/
|
|
380
|
-
export interface TemplateContent {
|
|
381
|
-
/** the template name */
|
|
382
|
-
name: string;
|
|
383
|
-
/** the template's author */
|
|
384
|
-
author: string;
|
|
385
|
-
/** Base64-encoded SVG icon image */
|
|
386
|
-
iconData: string;
|
|
387
|
-
/** category names this template belongs to (eg: "Planning", "Productivity") */
|
|
388
|
-
categories: string[];
|
|
389
|
-
/** labels associated with this template (eg: "Project management") */
|
|
390
|
-
labels: string[];
|
|
391
|
-
/** the orientation of this template */
|
|
392
|
-
orientation: "portrait" | "landscape";
|
|
393
|
-
/** semantic version for this template */
|
|
394
|
-
templateVersion: string;
|
|
395
|
-
/** template configuration format version (currently just `1`) */
|
|
396
|
-
formatVersion: number;
|
|
397
|
-
/**
|
|
398
|
-
* which screens the template supports:
|
|
399
|
-
*
|
|
400
|
-
* - `rm2`: reMarkable 2
|
|
401
|
-
* - `rmPP`: reMarkable Paper Pro
|
|
402
|
-
*/
|
|
403
|
-
supportedScreens: ("rm2" | "rmPP")[];
|
|
404
|
-
/** constant values used by the commands in `items` */
|
|
405
|
-
constants?: {
|
|
406
|
-
[name: string]: number;
|
|
407
|
-
}[];
|
|
408
|
-
/** the template definition, an SVG-like DSL in JSON */
|
|
409
|
-
items: object[];
|
|
410
|
-
}
|
|
411
|
-
/** content metadata for any item */
|
|
412
|
-
export type Content = CollectionContent | DocumentContent | TemplateContent;
|
|
413
|
-
/**
|
|
414
|
-
* item level metadata
|
|
415
|
-
*
|
|
416
|
-
* Stored with the extension "metadata".
|
|
417
|
-
*/
|
|
418
|
-
export interface Metadata {
|
|
419
|
-
/** creation time, a string of the epoch timestamp */
|
|
420
|
-
createdTime?: string;
|
|
421
|
-
/** [speculative] true if the item has been actually deleted */
|
|
422
|
-
deleted?: boolean;
|
|
423
|
-
/** the last modify time, the string of the epoch timestamp */
|
|
424
|
-
lastModified: string;
|
|
425
|
-
/** the last opened epoch timestamp, isn't defined for CollectionType */
|
|
426
|
-
lastOpened?: string;
|
|
427
|
-
/** the last page opened, isn't defined for CollectionType, starts at 0*/
|
|
428
|
-
lastOpenedPage?: number;
|
|
429
|
-
/** [speculative] true if the metadata has been modified */
|
|
430
|
-
metadatamodified?: boolean;
|
|
431
|
-
/** [speculative] true if the item has been modified */
|
|
432
|
-
modified?: boolean;
|
|
433
|
-
/**
|
|
434
|
-
* the id of the parent collection
|
|
435
|
-
*
|
|
436
|
-
* This is the empty string for root (no parent), "trash" if it's in the
|
|
437
|
-
* trash, or the id of the parent.
|
|
438
|
-
*/
|
|
439
|
-
parent: string;
|
|
440
|
-
/** true of the item is starred */
|
|
441
|
-
pinned: boolean;
|
|
442
|
-
/** [unknown] */
|
|
443
|
-
synced?: boolean;
|
|
444
|
-
/**
|
|
445
|
-
* the type of item this corresponds to
|
|
446
|
-
*
|
|
447
|
-
* DocumentType is a document, an epub, pdf, or notebook, CollectionType is a
|
|
448
|
-
* folder.
|
|
449
|
-
*/
|
|
450
|
-
type: "DocumentType" | "CollectionType" | "TemplateType";
|
|
451
|
-
/** whether this is this a newly-installed template */
|
|
452
|
-
new?: boolean;
|
|
453
|
-
/**
|
|
454
|
-
* the provider from which this item was obtained/installed
|
|
455
|
-
*
|
|
456
|
-
* Example: a template from "com.remarkable.methods".
|
|
457
|
-
*/
|
|
458
|
-
source?: string;
|
|
459
|
-
/** [speculative] metadata version, always 0 */
|
|
460
|
-
version?: number;
|
|
461
|
-
/** the visible name of the item, what it's called on the reMarkable */
|
|
462
|
-
visibleName: string;
|
|
463
|
-
}
|
|
464
122
|
/**
|
|
465
123
|
* options for putting a file onto reMarkable
|
|
466
124
|
*
|
|
@@ -521,187 +179,6 @@ export interface PutOptions {
|
|
|
521
179
|
*/
|
|
522
180
|
refresh?: boolean;
|
|
523
181
|
}
|
|
524
|
-
/**
|
|
525
|
-
* access to the low-level reMarkable api
|
|
526
|
-
*
|
|
527
|
-
* This class gives more granualar access to the reMarkable cloud, but is more
|
|
528
|
-
* dangerous.
|
|
529
|
-
*
|
|
530
|
-
* ## Overview
|
|
531
|
-
*
|
|
532
|
-
* reMarkable uses an immutable file system, where each file is referenced by
|
|
533
|
-
* the 32 byte sha256 hash of its contents. Each file also has an id used to
|
|
534
|
-
* keep track of updates, so to "update" a file, you upload a new file, and
|
|
535
|
-
* change the hash associated with it's id.
|
|
536
|
-
*
|
|
537
|
-
* Each "item" (a document or a collection) is actually a list of files.
|
|
538
|
-
* The whole reMarkable state is then a list of these lists. Finally, the hash
|
|
539
|
-
* of that list is called the rootHash. To update anything, you have to update
|
|
540
|
-
* the root hash to point to a new list of updated items.
|
|
541
|
-
*
|
|
542
|
-
* This can be dangerous, as corrupting the root hash can destroy all of your
|
|
543
|
-
* files. It is therefore highly recommended to save your current root hash
|
|
544
|
-
* ({@link getRootHash | `getRootHash`}) before using this api to attempt file
|
|
545
|
-
* writes, so you can recover a previous "snapshot" should anything go wrong.
|
|
546
|
-
*
|
|
547
|
-
* ## Items
|
|
548
|
-
*
|
|
549
|
-
* Each item is a collection of individual files. Using
|
|
550
|
-
* {@link getEntries | `getEntries`} on the root hash will give you a list
|
|
551
|
-
* entries that correspond to items. Using `getEntries` on any of those items
|
|
552
|
-
* will get you the files that make up that item.
|
|
553
|
-
*
|
|
554
|
-
* The documented files are:
|
|
555
|
-
* - `<docid>.pdf` - a raw pdf document
|
|
556
|
-
* - `<docid>.epub` - a raw epub document
|
|
557
|
-
* - `<docid>.content` - a json file roughly describing document properties (see {@link DocumentContent | `DocumentContent`})
|
|
558
|
-
* - `<docid>.metadata` - metadata about the document (see {@link Metadata | `Metadata`})
|
|
559
|
-
* - `<docid>.pagedata` - a text file where each line is the template of that page
|
|
560
|
-
* - `<docid>/<pageid>.rm` - [speculative] raw remarkable vectors, text, etc
|
|
561
|
-
* - `<docid>/<pageid>-metadata.json` - [speculative] metadata about the individual page
|
|
562
|
-
* - `<docid>.highlights/<pageid>.json` - [speculative] highlights on the page
|
|
563
|
-
*
|
|
564
|
-
* Some items will have both a `.pdf` and `.epub` file, likely due to preparing
|
|
565
|
-
* for export. Collections only have `.content` and `.metadata` files, with
|
|
566
|
-
* `.content` only containing tags.
|
|
567
|
-
*
|
|
568
|
-
* ## Caching
|
|
569
|
-
*
|
|
570
|
-
* Since everything is tied to the hash of it's contents, we can agressively
|
|
571
|
-
* cache results. We assume that text contents are "small" and so fully cache
|
|
572
|
-
* them, where as binary files we treat as large and only store that we know
|
|
573
|
-
* they exist to prevent future writes.
|
|
574
|
-
*
|
|
575
|
-
* By default, this only persists as long as the api instance is alive. However,
|
|
576
|
-
* for performance reasons, you should call {@link dumpCache | `dumpCache`} to
|
|
577
|
-
* persist the cache between sessions.
|
|
578
|
-
*
|
|
579
|
-
* @remarks
|
|
580
|
-
*
|
|
581
|
-
* Generally all hashes are 64 character hex strings, and all ids are uuid4.
|
|
582
|
-
*/
|
|
583
|
-
export interface RawRemarkableApi {
|
|
584
|
-
/**
|
|
585
|
-
* gets the root hash and the current generation
|
|
586
|
-
*
|
|
587
|
-
* When calling `putRootHash`, you should pass the generation you got from
|
|
588
|
-
* this call. That way you tell reMarkable you're updating the previous state.
|
|
589
|
-
*
|
|
590
|
-
* @returns the root hash and the current generation
|
|
591
|
-
*/
|
|
592
|
-
getRootHash(): Promise<[string, number]>;
|
|
593
|
-
/**
|
|
594
|
-
* get the raw binary data associated with a hash
|
|
595
|
-
*
|
|
596
|
-
* @param hash - the hash to get the data for
|
|
597
|
-
* @returns the data
|
|
598
|
-
*/
|
|
599
|
-
getHash(hash: string): Promise<Uint8Array>;
|
|
600
|
-
/**
|
|
601
|
-
* get raw text data associated with a hash
|
|
602
|
-
*
|
|
603
|
-
* We assume text data are small, and so cache the entire text. If you want to
|
|
604
|
-
* avoid this, use {@link getHash | `getHash`} combined with a TextDecoder.
|
|
605
|
-
|
|
606
|
-
* @param hash - the hash to get text for
|
|
607
|
-
* @returns the text
|
|
608
|
-
*/
|
|
609
|
-
getText(hash: string): Promise<string>;
|
|
610
|
-
/**
|
|
611
|
-
* get the entries associated with a list hash
|
|
612
|
-
*
|
|
613
|
-
* A list hash is the root hash, or any hash with the type 80000000. NOTE
|
|
614
|
-
* these are hashed differently than files.
|
|
615
|
-
|
|
616
|
-
* @param hash - the hash to get entries for
|
|
617
|
-
* @returns the entries
|
|
618
|
-
*/
|
|
619
|
-
getEntries(hash: string): Promise<RawEntry[]>;
|
|
620
|
-
/**
|
|
621
|
-
* get the parsed and validated `Content` of a content hash
|
|
622
|
-
*
|
|
623
|
-
* Use {@link getText | `getText`} combined with `JSON.parse` to bypass
|
|
624
|
-
* validation
|
|
625
|
-
|
|
626
|
-
* @param hash - the hash to get Content for
|
|
627
|
-
* @returns the content
|
|
628
|
-
*/
|
|
629
|
-
getContent(hash: string): Promise<Content>;
|
|
630
|
-
/**
|
|
631
|
-
* get the parsed and validated `Metadata` of a metadata hash
|
|
632
|
-
*
|
|
633
|
-
* Use {@link getText | `getText`} combined with `JSON.parse` to bypass
|
|
634
|
-
* validation
|
|
635
|
-
|
|
636
|
-
* @param hash - the hash to get Metadata for
|
|
637
|
-
* @returns the metadata
|
|
638
|
-
*/
|
|
639
|
-
getMetadata(hash: string): Promise<Metadata>;
|
|
640
|
-
/**
|
|
641
|
-
* update the current root hash
|
|
642
|
-
*
|
|
643
|
-
* This will fail if generation doesn't match the current server generation.
|
|
644
|
-
* This ensures that you are updating what you expect. IF you get a
|
|
645
|
-
* {@link GenerationError | `GenerationError`}, that indicates that the server
|
|
646
|
-
* was updated after you last got the generation. You should call
|
|
647
|
-
* {@link getRootHash | `getRootHash`} and then recompute the changes you want
|
|
648
|
-
* from the new root hash. If you ignore the update hash value and just call
|
|
649
|
-
* `putRootHash` again, you will overwrite the changes made by the other
|
|
650
|
-
* update.
|
|
651
|
-
*
|
|
652
|
-
* @param hash - the new root hash
|
|
653
|
-
* @param generation - the generation of the current root hash
|
|
654
|
-
* @param broadcast - [unknown] an option in the request
|
|
655
|
-
*
|
|
656
|
-
* @throws GenerationError if the generation doesn't match the current server generation
|
|
657
|
-
* @returns the new root hash and the new generation
|
|
658
|
-
*/
|
|
659
|
-
putRootHash(hash: string, generation: number, broadcast?: boolean): Promise<[string, number]>;
|
|
660
|
-
/**
|
|
661
|
-
* put a raw onto the server
|
|
662
|
-
*
|
|
663
|
-
* This returns the new expeced entry of the file you uploaded, and a promise
|
|
664
|
-
* to finish the upload successful. By splitting these two operations you can
|
|
665
|
-
* start using the uploaded entry while file finishes uploading.
|
|
666
|
-
*
|
|
667
|
-
* NOTE: This won't update the state of the reMarkable until this entry is
|
|
668
|
-
* incorporated into the root hash.
|
|
669
|
-
*
|
|
670
|
-
* @param id - the id of the file to upload
|
|
671
|
-
* @param bytes - the bytes to upload
|
|
672
|
-
* @returns the new entry and a promise to finish the upload
|
|
673
|
-
*/
|
|
674
|
-
putFile(id: string, bytes: Uint8Array): Promise<[RawFileEntry, Promise<void>]>;
|
|
675
|
-
/** the same as {@link putFile | `putFile`} but with caching for text */
|
|
676
|
-
putText(id: string, content: string): Promise<[RawFileEntry, Promise<void>]>;
|
|
677
|
-
/** the same as {@link putText | `putText`} but with extra validation for Content */
|
|
678
|
-
putContent(id: string, content: Content): Promise<[RawFileEntry, Promise<void>]>;
|
|
679
|
-
/** the same as {@link putText | `putText`} but with extra validation for Metadata */
|
|
680
|
-
putMetadata(id: string, metadata: Metadata): Promise<[RawFileEntry, Promise<void>]>;
|
|
681
|
-
/**
|
|
682
|
-
* put a set of entries to make an entry list file
|
|
683
|
-
*
|
|
684
|
-
* To fully upload an item:
|
|
685
|
-
* 1. upload all the constituent files and metadata
|
|
686
|
-
* 2. call this with all of the entries
|
|
687
|
-
* 3. append this entry to the root entry and call this again to update this root list
|
|
688
|
-
* 4. put the new root hash
|
|
689
|
-
*
|
|
690
|
-
* @param id - the id of the list to upload - this should be the item id if
|
|
691
|
-
* uploading an item list, or "root" if uploading a new root list.
|
|
692
|
-
* @param entries - the entries to upload
|
|
693
|
-
* @returns the new list entry and a promise to finish the upload
|
|
694
|
-
*/
|
|
695
|
-
putEntries(id: string, entries: RawEntry[]): Promise<[RawListEntry, Promise<void>]>;
|
|
696
|
-
/**
|
|
697
|
-
* dump the current cache to a string to preserve between session
|
|
698
|
-
*
|
|
699
|
-
* @returns a serialized version of the cache to pass to a new api instance
|
|
700
|
-
*/
|
|
701
|
-
dumpCache(): string;
|
|
702
|
-
/** completely clear the cache */
|
|
703
|
-
clearCache(): void;
|
|
704
|
-
}
|
|
705
182
|
/**
|
|
706
183
|
* the api for accessing remarkable functions
|
|
707
184
|
*
|
|
@@ -876,6 +353,42 @@ export interface RemarkableApi {
|
|
|
876
353
|
* @param buffer - the epub contents
|
|
877
354
|
*/
|
|
878
355
|
uploadPdf(visibleName: string, buffer: Uint8Array, opts?: UploadOptions): Promise<SimpleEntry>;
|
|
356
|
+
/**
|
|
357
|
+
* update content metadata for a document
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* await api.updateDocument(doc.hash, { textAlignment: "left" });
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* @param hash - the hash of the file to update
|
|
365
|
+
* @param content - the fields of content to update
|
|
366
|
+
*/
|
|
367
|
+
updateDocument(hash: string, content: Partial<DocumentContent>, refresh?: boolean): Promise<HashEntry>;
|
|
368
|
+
/**
|
|
369
|
+
* update content metadata for a collection
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* await api.updateCollection(doc.hash, { textAlignment: "left" });
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @param hash - the hash of the file to update
|
|
377
|
+
* @param content - the fields of content to update
|
|
378
|
+
*/
|
|
379
|
+
updateCollection(hash: string, content: Partial<CollectionContent>, refresh?: boolean): Promise<HashEntry>;
|
|
380
|
+
/**
|
|
381
|
+
* update content metadata for a template
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* await api.updateTemplate(doc.hash, { textAlignment: "left" });
|
|
386
|
+
* ```
|
|
387
|
+
*
|
|
388
|
+
* @param hash - the hash of the file to update
|
|
389
|
+
* @param content - the fields of content to update
|
|
390
|
+
*/
|
|
391
|
+
updateTemplate(hash: string, content: Partial<TemplateContent>, refresh?: boolean): Promise<HashEntry>;
|
|
879
392
|
/**
|
|
880
393
|
* move an entry
|
|
881
394
|
*
|
|
@@ -909,6 +422,17 @@ export interface RemarkableApi {
|
|
|
909
422
|
* @param visibleName - the new name to assign
|
|
910
423
|
*/
|
|
911
424
|
rename(hash: string, visibleName: string, refresh?: boolean): Promise<HashEntry>;
|
|
425
|
+
/**
|
|
426
|
+
* set if an entry is stared
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* await api.stared(file.hash, true);
|
|
431
|
+
* ```
|
|
432
|
+
* @param hash - the hash of the entry to rename
|
|
433
|
+
* @param stared - whether the entry should be stared or not
|
|
434
|
+
*/
|
|
435
|
+
stared(hash: string, stared: boolean, refresh?: boolean): Promise<HashEntry>;
|
|
912
436
|
/**
|
|
913
437
|
* move many entries
|
|
914
438
|
*
|