rmapi-js 12.0.2 → 13.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 +182 -36
- package/dist/index.js +730 -236
- package/dist/lru.d.ts +4 -4
- package/dist/lru.js +4 -4
- package/dist/raw.d.ts +172 -36
- package/dist/raw.js +220 -75
- package/dist/rm5.d.ts +1 -1
- package/dist/rm6.d.ts +38 -13
- package/dist/rm6.js +418 -39
- package/dist/rmapi-js.esm.min.js +13 -9
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type BackgroundFilter, type CollectionContent, type Content, type DocumentContent, type ItemRef, type Metadata, type Orientation, RawRemarkable, type RmPage, type Tag, type TemplateContent, type TextAlignment, type ZoomMode } from "./raw.js";
|
|
1
|
+
import { type BackgroundFilter, type CollectionContent, type Content, type DocumentContent, type Highlight, type ItemRef, type Metadata, type Orientation, type PageMetadata, RawRemarkable, type RmPage, type Tag, type TemplateContent, type TextAlignment, type ZoomMode } from "./raw.js";
|
|
2
2
|
export { type DeviceModel, type DeviceScreen, deviceScreens, } from "./devices.js";
|
|
3
3
|
export { HashNotFoundError, ValidationError } from "./error.js";
|
|
4
|
-
export type { BackgroundFilter, CollectionContent, Content, CPageNumberValue, CPagePage, CPageStringValue, CPages, CPageUUID, DocumentContent, DocumentMetadata, Entries, FileType, ItemRef, KeyboardMetadata, LegacyCollectionContent, LegacyDocumentContent, Metadata, Orientation, PageTag, RawEntry, RawRemarkableApi, RmPage, SchemaVersion, Tag, TemplateContent, TextAlignment, UploadMimeType, ZoomMode, } from "./raw.js";
|
|
4
|
+
export type { BackgroundFilter, CollectionContent, Content, CPageNumberValue, CPagePage, CPageStringValue, CPages, CPageUUID, DocumentContent, DocumentMetadata, Entries, EntryType, FileType, Highlight, HighlightRect, ItemRef, KeyboardMetadata, LegacyCollectionContent, LegacyDocumentContent, Metadata, Orientation, PageLayer, PageMetadata, PageTag, PendingEntry, RawEntry, RawRemarkableApi, RmPage, SchemaVersion, Tag, TemplateContent, TextAlignment, UploadMimeType, ZoomMode, } from "./raw.js";
|
|
5
5
|
export type { RmBrush, RmLayer, RmLine, RmPageV5, RmPoint, RmVersion, } from "./rm5.js";
|
|
6
6
|
export { decodeBrush, rmColors } from "./rm5.js";
|
|
7
|
-
export type { AuthorIdsBlock, CrdtId, GlyphRange, LwwValue, MigrationInfoBlock, PageInfoBlock, Rectangle, RmBlock, RmScene, RmSceneItem, RmSceneLayer, RmV6Line, RmV6Point, RmV6Text, RmV6TextValue, RootTextBlock, SceneGlyphItemBlock, SceneGroupItemBlock, SceneInfoBlock, SceneItem, SceneLineItemBlock, SceneTextItemBlock, SceneTombstoneItemBlock, SceneTreeBlock, TreeNodeBlock, UnknownBlock, } from "./rm6.js";
|
|
8
|
-
export { crdtKey
|
|
7
|
+
export type { AuthorIdsBlock, CrdtId, GlyphRange, LwwValue, MigrationInfoBlock, PageInfoBlock, Rectangle, RmBlock, RmScene, RmSceneItem, RmSceneLayer, RmV6Line, RmV6Point, RmV6Text, RmV6TextValue, RootTextBlock, SceneGlyphItemBlock, SceneGroupItemBlock, SceneInfoBlock, SceneItem, SceneLineItemBlock, SceneTextItemBlock, SceneTombstoneItemBlock, SceneTreeBlock, TreeNodeAnchor, TreeNodeBlock, UnknownBlock, } from "./rm6.js";
|
|
8
|
+
export { crdtKey } from "./rm6.js";
|
|
9
9
|
/** common properties shared by collections and documents */
|
|
10
10
|
export interface EntryCommon extends ItemRef {
|
|
11
11
|
/** the visible display name of this entry */
|
|
@@ -30,7 +30,7 @@ export interface CollectionEntry extends EntryCommon {
|
|
|
30
30
|
type: "CollectionType";
|
|
31
31
|
}
|
|
32
32
|
/** a file, referred to in the api as a document */
|
|
33
|
-
export interface
|
|
33
|
+
export interface DocumentEntry extends EntryCommon {
|
|
34
34
|
/** the key to identify this as a document */
|
|
35
35
|
type: "DocumentType";
|
|
36
36
|
/** the type of the file */
|
|
@@ -39,7 +39,7 @@ export interface DocumentType extends EntryCommon {
|
|
|
39
39
|
lastOpened: string;
|
|
40
40
|
}
|
|
41
41
|
/** a template, such as from methods.remarkable.com */
|
|
42
|
-
export interface
|
|
42
|
+
export interface TemplateEntry extends EntryCommon {
|
|
43
43
|
/** the key to identify this as a template */
|
|
44
44
|
type: "TemplateType";
|
|
45
45
|
/** the timestamp of when the template was added/created */
|
|
@@ -50,7 +50,7 @@ export interface TemplateType extends EntryCommon {
|
|
|
50
50
|
new?: boolean;
|
|
51
51
|
}
|
|
52
52
|
/** a remarkable entry for cloud items */
|
|
53
|
-
export type Entry = CollectionEntry |
|
|
53
|
+
export type Entry = CollectionEntry | DocumentEntry | TemplateEntry;
|
|
54
54
|
/** options for creating a folder */
|
|
55
55
|
export interface FolderOptions {
|
|
56
56
|
/** the id of the folder's parent directory, "" or omitted for root */
|
|
@@ -64,13 +64,6 @@ export interface PutDocumentOptions {
|
|
|
64
64
|
parent?: string;
|
|
65
65
|
/** the visible name to use, overriding the archived value */
|
|
66
66
|
visibleName?: string;
|
|
67
|
-
/**
|
|
68
|
-
* reuse this document id instead of generating a fresh one
|
|
69
|
-
*
|
|
70
|
-
* By default a new uuid is generated so re-uploading an archive to the same
|
|
71
|
-
* account doesn't collide with the original. Pass an id to restore in place.
|
|
72
|
-
*/
|
|
73
|
-
id?: string;
|
|
74
67
|
}
|
|
75
68
|
/** An error that gets thrown when the backend while trying to update
|
|
76
69
|
*
|
|
@@ -211,7 +204,7 @@ declare class Remarkable {
|
|
|
211
204
|
#private;
|
|
212
205
|
/** scoped access to the raw low-level api */
|
|
213
206
|
readonly raw: RawRemarkable;
|
|
214
|
-
constructor(sessionToken: string, rawHost: string, uploadHost: string, cache: Map<string,
|
|
207
|
+
constructor(sessionToken: string, rawHost: string, uploadHost: string, cache: Map<string, Uint8Array | null>, maxGenerationRetries: number, maxTransientRetries: number, maxCachedBytes: number);
|
|
215
208
|
/**
|
|
216
209
|
* list all items
|
|
217
210
|
*
|
|
@@ -233,11 +226,14 @@ declare class Remarkable {
|
|
|
233
226
|
*/
|
|
234
227
|
listItems(refresh?: boolean): Promise<Entry[]>;
|
|
235
228
|
/**
|
|
236
|
-
*
|
|
229
|
+
* list a reference to every item, backed by the low level api
|
|
230
|
+
*
|
|
231
|
+
* Unlike {@link listItems | `listItems`} this doesn't read each item's
|
|
232
|
+
* metadata, so it's cheaper but only gives you ids and hashes.
|
|
237
233
|
*
|
|
238
234
|
* @param refresh - if true, refresh the root hash before listing
|
|
239
235
|
*/
|
|
240
|
-
|
|
236
|
+
listRefs(refresh?: boolean): Promise<ItemRef[]>;
|
|
241
237
|
/**
|
|
242
238
|
* get the content metadata for an item
|
|
243
239
|
*
|
|
@@ -246,10 +242,10 @@ declare class Remarkable {
|
|
|
246
242
|
* the low-level api to get the raw text of the `.content` file in the
|
|
247
243
|
* `RawEntry` for this hash.
|
|
248
244
|
*
|
|
249
|
-
* @param ref - a reference to the item (e.g. from `listItems` or `
|
|
245
|
+
* @param ref - a reference to the item (e.g. from `listItems` or `listRefs`)
|
|
250
246
|
* @returns the content
|
|
251
247
|
*/
|
|
252
|
-
getContent(
|
|
248
|
+
getContent(ref: ItemRef): Promise<Content>;
|
|
253
249
|
/**
|
|
254
250
|
* get the metadata for an item
|
|
255
251
|
*
|
|
@@ -258,10 +254,10 @@ declare class Remarkable {
|
|
|
258
254
|
* the low-level api to get the raw text of the `.metadata` file in the
|
|
259
255
|
* `RawEntry` for this hash.
|
|
260
256
|
*
|
|
261
|
-
* @param ref - a reference to the item (e.g. from `listItems` or `
|
|
257
|
+
* @param ref - a reference to the item (e.g. from `listItems` or `listRefs`)
|
|
262
258
|
* @returns the metadata
|
|
263
259
|
*/
|
|
264
|
-
getMetadata(
|
|
260
|
+
getMetadata(ref: ItemRef): Promise<Metadata>;
|
|
265
261
|
/**
|
|
266
262
|
* get the pdf associated with a document
|
|
267
263
|
*
|
|
@@ -270,7 +266,7 @@ declare class Remarkable {
|
|
|
270
266
|
* @param ref - a reference to the document (e.g. from `listItems`)
|
|
271
267
|
* @returns the pdf bytes
|
|
272
268
|
*/
|
|
273
|
-
getPdf(
|
|
269
|
+
getPdf(ref: ItemRef): Promise<Uint8Array>;
|
|
274
270
|
/**
|
|
275
271
|
* get the epub associated with a document
|
|
276
272
|
*
|
|
@@ -279,7 +275,7 @@ declare class Remarkable {
|
|
|
279
275
|
* @param ref - a reference to the document (e.g. from `listItems`)
|
|
280
276
|
* @returns the epub bytes
|
|
281
277
|
*/
|
|
282
|
-
getEpub(
|
|
278
|
+
getEpub(ref: ItemRef): Promise<Uint8Array>;
|
|
283
279
|
/**
|
|
284
280
|
* get a single page's parsed reMarkable lines (`.rm`) drawing
|
|
285
281
|
*
|
|
@@ -303,6 +299,147 @@ declare class Remarkable {
|
|
|
303
299
|
* @returns the drawn pages, keyed by page id, in document order
|
|
304
300
|
*/
|
|
305
301
|
getRmPages(ref: ItemRef): Promise<Map<string, RmPage>>;
|
|
302
|
+
/**
|
|
303
|
+
* write a single page's reMarkable lines (`.rm`) drawing
|
|
304
|
+
*
|
|
305
|
+
* @param ref - a reference to the document
|
|
306
|
+
* @param pageId - the id of the page, from the document's `.content` page list
|
|
307
|
+
* @param page - the drawing to write, replacing any already there
|
|
308
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
309
|
+
* @throws if `pageId` is not a page of the document
|
|
310
|
+
* @returns a reference to the updated document, with its new hash
|
|
311
|
+
*/
|
|
312
|
+
putRmPage(ref: ItemRef, pageId: string, page: RmPage, refresh?: boolean): Promise<ItemRef>;
|
|
313
|
+
/**
|
|
314
|
+
* write several pages' reMarkable lines (`.rm`) drawings in one commit
|
|
315
|
+
*
|
|
316
|
+
* @param ref - a reference to the document
|
|
317
|
+
* @param pages - the drawings to write, keyed by page id, replacing any
|
|
318
|
+
* already on those pages and leaving every other page alone
|
|
319
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
320
|
+
* @throws if any key is not a page of the document
|
|
321
|
+
* @returns a reference to the updated document, with its new hash
|
|
322
|
+
*/
|
|
323
|
+
putRmPages(ref: ItemRef, pages: ReadonlyMap<string, RmPage>, refresh?: boolean): Promise<ItemRef>;
|
|
324
|
+
/**
|
|
325
|
+
* get a single page's text highlights
|
|
326
|
+
*
|
|
327
|
+
* These are separate from the highlighter strokes drawn in a `.rm` scene.
|
|
328
|
+
*
|
|
329
|
+
* @param ref - a reference to the document
|
|
330
|
+
* @param pageId - the id of the page, from the document's `.content` page list
|
|
331
|
+
* @returns the page's highlights, or `undefined` if the page has none
|
|
332
|
+
* @throws if `pageId` is not a page of the document
|
|
333
|
+
*/
|
|
334
|
+
getHighlights(ref: ItemRef, pageId: string): Promise<Highlight[][] | undefined>;
|
|
335
|
+
/**
|
|
336
|
+
* get every highlighted page of a document, keyed by page id
|
|
337
|
+
*
|
|
338
|
+
* @param ref - a reference to the document
|
|
339
|
+
* @returns the highlights in page order, omitting pages with none
|
|
340
|
+
*/
|
|
341
|
+
getHighlightPages(ref: ItemRef): Promise<Map<string, Highlight[][]>>;
|
|
342
|
+
/**
|
|
343
|
+
* write a single page's text highlights, replacing any already there
|
|
344
|
+
*
|
|
345
|
+
* @param ref - a reference to the document
|
|
346
|
+
* @param pageId - the id of the page, from the document's `.content` page list
|
|
347
|
+
* @param highlights - the highlights to write
|
|
348
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
349
|
+
* @throws if `pageId` is not a page of the document
|
|
350
|
+
* @returns a reference to the updated document, with its new hash
|
|
351
|
+
*/
|
|
352
|
+
putHighlights(ref: ItemRef, pageId: string, highlights: readonly Highlight[][], refresh?: boolean): Promise<ItemRef>;
|
|
353
|
+
/**
|
|
354
|
+
* write several pages' text highlights in one commit
|
|
355
|
+
*
|
|
356
|
+
* @param ref - a reference to the document
|
|
357
|
+
* @param pages - the highlights to write, keyed by page id, replacing any
|
|
358
|
+
* already on those pages and leaving every other page alone
|
|
359
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
360
|
+
* @throws if any key is not a page of the document
|
|
361
|
+
* @returns a reference to the updated document, with its new hash
|
|
362
|
+
*/
|
|
363
|
+
putHighlightPages(ref: ItemRef, pages: ReadonlyMap<string, readonly Highlight[][]>, refresh?: boolean): Promise<ItemRef>;
|
|
364
|
+
/**
|
|
365
|
+
* get a template attached to an item as a `.template` sidecar
|
|
366
|
+
*
|
|
367
|
+
* This is distinct from a {@link TemplateEntry | `TemplateEntry`} (whose
|
|
368
|
+
* template is its `.content`); collections and documents can carry a template
|
|
369
|
+
* this way.
|
|
370
|
+
*
|
|
371
|
+
* @param ref - a reference to the item
|
|
372
|
+
* @returns the template content, or `undefined` if the item has no `.template`
|
|
373
|
+
*/
|
|
374
|
+
getTemplate(ref: ItemRef): Promise<TemplateContent | undefined>;
|
|
375
|
+
/**
|
|
376
|
+
* attach a template to an item as a `.template` sidecar
|
|
377
|
+
*
|
|
378
|
+
* @param ref - a reference to the item
|
|
379
|
+
* @param template - the template to attach, replacing any already there
|
|
380
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
381
|
+
* @returns a reference to the updated item, with its new hash
|
|
382
|
+
*/
|
|
383
|
+
putTemplate(ref: ItemRef, template: TemplateContent, refresh?: boolean): Promise<ItemRef>;
|
|
384
|
+
/**
|
|
385
|
+
* get a document's per-page template names
|
|
386
|
+
*
|
|
387
|
+
* The `.pagedata` file lists one template name per page, in page order (an
|
|
388
|
+
* empty string for a page with no template).
|
|
389
|
+
*
|
|
390
|
+
* @param ref - a reference to the document
|
|
391
|
+
* @returns the per-page template names, or `undefined` if the document has
|
|
392
|
+
* no `.pagedata`
|
|
393
|
+
*/
|
|
394
|
+
getPagedata(ref: ItemRef): Promise<string[] | undefined>;
|
|
395
|
+
/**
|
|
396
|
+
* set a document's per-page template names
|
|
397
|
+
*
|
|
398
|
+
* @param ref - a reference to the document
|
|
399
|
+
* @param templates - one template name per page, in page order, an empty
|
|
400
|
+
* string for a page with no template
|
|
401
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
402
|
+
* @returns a reference to the updated document, with its new hash
|
|
403
|
+
*/
|
|
404
|
+
putPagedata(ref: ItemRef, templates: readonly string[], refresh?: boolean): Promise<ItemRef>;
|
|
405
|
+
/**
|
|
406
|
+
* get a single page's layer metadata
|
|
407
|
+
*
|
|
408
|
+
* @param ref - a reference to the document
|
|
409
|
+
* @param pageId - the id of the page, from the document's `.content` page list
|
|
410
|
+
* @returns the page's layer metadata, or `undefined` if the page has none
|
|
411
|
+
* @throws if `pageId` is not a page of the document
|
|
412
|
+
*/
|
|
413
|
+
getPageMetadata(ref: ItemRef, pageId: string): Promise<PageMetadata | undefined>;
|
|
414
|
+
/**
|
|
415
|
+
* get every page's layer metadata, keyed by page id
|
|
416
|
+
*
|
|
417
|
+
* @param ref - a reference to the document
|
|
418
|
+
* @returns the layer metadata in page order, omitting pages with none
|
|
419
|
+
*/
|
|
420
|
+
getPageMetadataPages(ref: ItemRef): Promise<Map<string, PageMetadata>>;
|
|
421
|
+
/**
|
|
422
|
+
* write a single page's layer metadata, replacing any already there
|
|
423
|
+
*
|
|
424
|
+
* @param ref - a reference to the document
|
|
425
|
+
* @param pageId - the id of the page, from the document's `.content` page list
|
|
426
|
+
* @param meta - the layer metadata to write
|
|
427
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
428
|
+
* @throws if `pageId` is not a page of the document
|
|
429
|
+
* @returns a reference to the updated document, with its new hash
|
|
430
|
+
*/
|
|
431
|
+
putPageMetadata(ref: ItemRef, pageId: string, meta: PageMetadata, refresh?: boolean): Promise<ItemRef>;
|
|
432
|
+
/**
|
|
433
|
+
* write several pages' layer metadata in one commit
|
|
434
|
+
*
|
|
435
|
+
* @param ref - a reference to the document
|
|
436
|
+
* @param pages - the layer metadata to write, keyed by page id, replacing any
|
|
437
|
+
* already on those pages and leaving every other page alone
|
|
438
|
+
* @throws GenerationError if the generation doesn't match the current server generation
|
|
439
|
+
* @throws if any key is not a page of the document
|
|
440
|
+
* @returns a reference to the updated document, with its new hash
|
|
441
|
+
*/
|
|
442
|
+
putPageMetadataPages(ref: ItemRef, pages: ReadonlyMap<string, PageMetadata>, refresh?: boolean): Promise<ItemRef>;
|
|
306
443
|
/**
|
|
307
444
|
* get a document's entire contents as a zip archive
|
|
308
445
|
*
|
|
@@ -315,7 +452,7 @@ declare class Remarkable {
|
|
|
315
452
|
*
|
|
316
453
|
* @param ref - a reference to the document (e.g. from `listItems`)
|
|
317
454
|
*/
|
|
318
|
-
getDocumentArchive(
|
|
455
|
+
getDocumentArchive(ref: ItemRef): Promise<Uint8Array>;
|
|
319
456
|
/**
|
|
320
457
|
* upload a document archive produced by {@link getDocumentArchive | `getDocumentArchive`}
|
|
321
458
|
*
|
|
@@ -323,16 +460,16 @@ declare class Remarkable {
|
|
|
323
460
|
* as a blob, and commits a new document into the root.
|
|
324
461
|
*
|
|
325
462
|
* @remarks
|
|
326
|
-
* This is an experimental feature.
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
463
|
+
* This is an experimental feature. A fresh document id is generated, so
|
|
464
|
+
* re-uploading to the same account doesn't collide with the original. Like
|
|
465
|
+
* the other low-level puts, this may throw a
|
|
466
|
+
* {@link GenerationError | `GenerationError`} if the generation is stale,
|
|
467
|
+
* requiring a retry.
|
|
331
468
|
*
|
|
332
469
|
* @param buffer - the archive bytes, as returned by `getDocumentArchive`
|
|
333
|
-
* @param options - overrides for parent
|
|
470
|
+
* @param options - overrides for parent and visible name
|
|
334
471
|
*/
|
|
335
|
-
putDocumentArchive(buffer: Uint8Array, { refresh, parent, visibleName
|
|
472
|
+
putDocumentArchive(buffer: Uint8Array, { refresh, parent, visibleName }?: PutDocumentOptions): Promise<ItemRef>;
|
|
336
473
|
/**
|
|
337
474
|
* use the low-level api to add a pdf document
|
|
338
475
|
*
|
|
@@ -599,15 +736,24 @@ export interface RemarkableSessionOptions {
|
|
|
599
736
|
*/
|
|
600
737
|
cache?: string;
|
|
601
738
|
/**
|
|
602
|
-
* the maximum size of the cache in
|
|
739
|
+
* the maximum size of the cache, in bytes of cached content plus key length
|
|
603
740
|
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* the data stored.
|
|
741
|
+
* The total memory usage of the cache will be somewhat larger than this,
|
|
742
|
+
* since it counts only the stored data.
|
|
607
743
|
*
|
|
608
744
|
* @defaultValue Infinity
|
|
609
745
|
*/
|
|
610
746
|
maxCacheSize?: number;
|
|
747
|
+
/**
|
|
748
|
+
* the largest stored file to keep the contents of, in bytes
|
|
749
|
+
*
|
|
750
|
+
* Anything larger is fetched normally but only its existence is recorded, so
|
|
751
|
+
* one big pdf can't evict everything else. Set to `0` to cache nothing but
|
|
752
|
+
* existence, or `Infinity` to keep whatever is read.
|
|
753
|
+
*
|
|
754
|
+
* @defaultValue 1048576
|
|
755
|
+
*/
|
|
756
|
+
maxCachedBytes?: number;
|
|
611
757
|
/**
|
|
612
758
|
* how many times to retry updating the root hash after a generation conflict
|
|
613
759
|
*
|
|
@@ -649,7 +795,7 @@ export declare function auth(deviceToken: string, { authHost }?: AuthOptions): P
|
|
|
649
795
|
* @param sessionToken - the session token used for authorization
|
|
650
796
|
* @returns an api instance
|
|
651
797
|
*/
|
|
652
|
-
export declare function session(sessionToken: string, { rawHost, uploadHost, cache, maxCacheSize, maxGenerationRetries, maxTransientRetries, }?: RemarkableSessionOptions): Remarkable;
|
|
798
|
+
export declare function session(sessionToken: string, { rawHost, uploadHost, cache, maxCacheSize, maxCachedBytes, maxGenerationRetries, maxTransientRetries, }?: RemarkableSessionOptions): Remarkable;
|
|
653
799
|
/**
|
|
654
800
|
* create an instance of the api
|
|
655
801
|
*
|