rmapi-js 5.0.0 → 6.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/README.md +32 -90
- package/dist/index.d.ts +101 -514
- package/dist/index.js +159 -706
- package/dist/rmapi-js.esm.min.js +1 -1
- package/package.json +14 -15
- package/dist/index.spec.d.ts +0 -1
- package/dist/index.spec.js +0 -800
- package/dist/test-utils.d.ts +0 -22
- package/dist/test-utils.js +0 -71
- package/dist/utils.d.ts +0 -6
- package/dist/utils.js +0 -22
- package/dist/utils.spec.d.ts +0 -1
- package/dist/utils.spec.js +0 -21
- package/dist/validate.d.ts +0 -3
- package/dist/validate.js +0 -8
- package/dist/validate.spec.d.ts +0 -1
- package/dist/validate.spec.js +0 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,76 +1,50 @@
|
|
|
1
1
|
/** request types */
|
|
2
|
-
export type RequestMethod = "POST" | "GET" | "PUT" | "DELETE";
|
|
3
|
-
/**
|
|
4
|
-
export
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
/** text scale options */
|
|
10
|
-
export declare const builtinTextScales: {
|
|
11
|
-
/** the smallest */
|
|
12
|
-
readonly xs: 0.7;
|
|
13
|
-
/** small */
|
|
14
|
-
readonly sm: 0.8;
|
|
15
|
-
/** medium / default */
|
|
16
|
-
readonly md: 1;
|
|
17
|
-
/** large */
|
|
18
|
-
readonly lg: 1.2;
|
|
19
|
-
/** extra large */
|
|
20
|
-
readonly xl: 1.5;
|
|
21
|
-
/** double extra large */
|
|
22
|
-
readonly xx: 2;
|
|
23
|
-
};
|
|
24
|
-
/** margin options */
|
|
25
|
-
export declare const builtinMargins: {
|
|
26
|
-
/** small */
|
|
27
|
-
readonly sm: 50;
|
|
28
|
-
/** medium */
|
|
29
|
-
readonly md: 125;
|
|
30
|
-
/** default for read on remarkable */
|
|
31
|
-
readonly rr: 180;
|
|
32
|
-
/** large */
|
|
33
|
-
readonly lg: 200;
|
|
34
|
-
};
|
|
35
|
-
/** line height options */
|
|
36
|
-
export declare const builtinLineHeights: {
|
|
37
|
-
/** default */
|
|
38
|
-
readonly df: -1;
|
|
39
|
-
/** normal */
|
|
40
|
-
readonly md: 100;
|
|
41
|
-
/** half */
|
|
42
|
-
readonly lg: 150;
|
|
43
|
-
/** double */
|
|
44
|
-
readonly xl: 200;
|
|
45
|
-
};
|
|
46
|
-
/** a remarkable entry for a cloud collection */
|
|
47
|
-
export interface CollectionEntry {
|
|
48
|
-
/** collection type */
|
|
49
|
-
type: "80000000";
|
|
50
|
-
/** the hash of the collection this points to */
|
|
51
|
-
hash: string;
|
|
52
|
-
/** the unique id of the collection */
|
|
53
|
-
documentId: string;
|
|
54
|
-
/** the number of subfiles */
|
|
55
|
-
subfiles: number;
|
|
56
|
-
/** collections don't have sizes */
|
|
57
|
-
size: bigint;
|
|
2
|
+
export type RequestMethod = "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
|
3
|
+
/** a tag for an entry */
|
|
4
|
+
export interface Tag {
|
|
5
|
+
/** the name of the tag */
|
|
6
|
+
name: string;
|
|
7
|
+
/** the timestamp when this tag was added */
|
|
8
|
+
timestamp: number;
|
|
58
9
|
}
|
|
59
|
-
/**
|
|
60
|
-
export interface
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
/** the hash of the
|
|
10
|
+
/** common properties shared by collections and documents */
|
|
11
|
+
export interface EntryCommon {
|
|
12
|
+
/** the document id, a uuid4 */
|
|
13
|
+
id: string;
|
|
14
|
+
/** the current hash of the state of this entry */
|
|
64
15
|
hash: string;
|
|
65
|
-
/** the
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
16
|
+
/** the visible display name of this entry */
|
|
17
|
+
visibleName: string;
|
|
18
|
+
/** the last modified timestamp */
|
|
19
|
+
lastModified: string;
|
|
20
|
+
/** true if the entry is starred in most ui elements */
|
|
21
|
+
pinned: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* the parent of this entry
|
|
24
|
+
*
|
|
25
|
+
* There are two special parents, "" (empty string) for the root directory,
|
|
26
|
+
* and "trash" for the trash
|
|
27
|
+
*/
|
|
28
|
+
parent?: string;
|
|
29
|
+
/** any tags the entry might have */
|
|
30
|
+
tags?: Tag[];
|
|
31
|
+
}
|
|
32
|
+
/** a folder, referred to in the api as a collection */
|
|
33
|
+
export interface CollectionEntry extends EntryCommon {
|
|
34
|
+
/** the key for this as a collection */
|
|
35
|
+
type: "CollectionType";
|
|
36
|
+
}
|
|
37
|
+
/** a file, referred to in the api as a document */
|
|
38
|
+
export interface DocumentType extends EntryCommon {
|
|
39
|
+
/** the key to identify this as a document */
|
|
40
|
+
type: "DocumentType";
|
|
41
|
+
/** the type of the file */
|
|
42
|
+
fileType: "epub" | "pdf" | "notebook";
|
|
43
|
+
/** the timestamp of the last time this entry was opened */
|
|
44
|
+
lastOpened: string;
|
|
71
45
|
}
|
|
72
46
|
/** a remarkable entry for cloud items */
|
|
73
|
-
export type Entry = CollectionEntry |
|
|
47
|
+
export type Entry = CollectionEntry | DocumentType;
|
|
74
48
|
/** an simple entry produced by the upload api */
|
|
75
49
|
export interface UploadEntry {
|
|
76
50
|
/** the document id */
|
|
@@ -78,117 +52,15 @@ export interface UploadEntry {
|
|
|
78
52
|
/** the document hash */
|
|
79
53
|
hash: string;
|
|
80
54
|
}
|
|
81
|
-
/**
|
|
82
|
-
export interface
|
|
83
|
-
/**
|
|
84
|
-
visibleName: string;
|
|
85
|
-
/** parent uuid (documentId) or "" for root or "trash" */
|
|
86
|
-
parent?: string;
|
|
87
|
-
/** last modified time */
|
|
88
|
-
lastModified?: string;
|
|
89
|
-
/** unknown significance */
|
|
90
|
-
version?: number;
|
|
91
|
-
/** unknown significance */
|
|
92
|
-
pinned?: boolean;
|
|
93
|
-
/** unknown significance */
|
|
94
|
-
synced?: boolean;
|
|
95
|
-
/** unknown significance */
|
|
96
|
-
modified?: boolean;
|
|
97
|
-
/** if file is deleted */
|
|
98
|
-
deleted?: boolean;
|
|
99
|
-
/** unknown significance */
|
|
100
|
-
metadatamodified?: boolean;
|
|
101
|
-
}
|
|
102
|
-
/** metadata for collection types */
|
|
103
|
-
export interface CollectionTypeMetadata extends CommonMetadata {
|
|
104
|
-
/** the key for collection types */
|
|
105
|
-
type: "CollectionType";
|
|
106
|
-
}
|
|
107
|
-
/** metadata for document types */
|
|
108
|
-
export interface DocumentTypeMetadata extends CommonMetadata {
|
|
109
|
-
/** the key for document types */
|
|
110
|
-
type: "DocumentType";
|
|
111
|
-
/** last opened time for documents */
|
|
112
|
-
lastOpened?: string;
|
|
113
|
-
/** last opened page for documents */
|
|
114
|
-
lastOpenedPage?: number;
|
|
115
|
-
/** created time */
|
|
116
|
-
createdTime?: string;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* metadata for a document or collection (folder)
|
|
120
|
-
*
|
|
121
|
-
* This is found in the the `.metadata` file.
|
|
122
|
-
*/
|
|
123
|
-
export type Metadata = CollectionTypeMetadata | DocumentTypeMetadata;
|
|
124
|
-
/** fields common to all {@link MetadataEntry | MetadataEntries} */
|
|
125
|
-
export interface BaseMetadataEntry {
|
|
126
|
-
/** the document id of the entry */
|
|
127
|
-
id: string;
|
|
128
|
-
/** the hash of the entry */
|
|
55
|
+
/** the new hash of a modified entry */
|
|
56
|
+
export interface HashEntry {
|
|
57
|
+
/** the actual hash */
|
|
129
58
|
hash: string;
|
|
130
59
|
}
|
|
131
|
-
/** the
|
|
132
|
-
export interface
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
export interface DocumentMetadataEntry extends BaseMetadataEntry, DocumentTypeMetadata {
|
|
136
|
-
/** the type of the document */
|
|
137
|
-
fileType: FileType;
|
|
138
|
-
}
|
|
139
|
-
/** a full metadata entry returned by {@link RemarkableApi.getEntriesMetadata} */
|
|
140
|
-
export type MetadataEntry = CollectionMetadataEntry | DocumentMetadataEntry;
|
|
141
|
-
/** extra content metadata */
|
|
142
|
-
export type ExtraMetadata = Record<string, string | undefined>;
|
|
143
|
-
/** remarkable file type; empty for notebook */
|
|
144
|
-
export type FileType = "notebook" | "pdf" | "epub" | "";
|
|
145
|
-
/** document matrix transform */
|
|
146
|
-
export type Transform = Record<`m${1 | 2 | 3}${1 | 2 | 3}`, number>;
|
|
147
|
-
/** content document metadata */
|
|
148
|
-
export interface DocumentMetadata {
|
|
149
|
-
/** document title */
|
|
150
|
-
title?: string;
|
|
151
|
-
/** document authors */
|
|
152
|
-
authors?: string[];
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* content metadata
|
|
156
|
-
*
|
|
157
|
-
* This is found in the `.content` file.
|
|
158
|
-
*/
|
|
159
|
-
export interface Content {
|
|
160
|
-
/** is this a dummy document */
|
|
161
|
-
dummyDocument: boolean;
|
|
162
|
-
/** document metadata */
|
|
163
|
-
documentMetadata?: DocumentMetadata;
|
|
164
|
-
/** extra metadata */
|
|
165
|
-
extraMetadata: ExtraMetadata;
|
|
166
|
-
/** file type */
|
|
167
|
-
fileType: FileType;
|
|
168
|
-
/** font */
|
|
169
|
-
fontName?: string;
|
|
170
|
-
/** last opened page */
|
|
171
|
-
lastOpenedPage: number;
|
|
172
|
-
/** line height */
|
|
173
|
-
lineHeight: number;
|
|
174
|
-
/** page margins in points */
|
|
175
|
-
margins: number;
|
|
176
|
-
/** orientation */
|
|
177
|
-
orientation?: "portrait" | "landscape";
|
|
178
|
-
/** number of pages */
|
|
179
|
-
pageCount: number;
|
|
180
|
-
/** page ids */
|
|
181
|
-
pages: string[];
|
|
182
|
-
/** number to use for the coverage page, -1 for last opened */
|
|
183
|
-
coverPageNumber: number;
|
|
184
|
-
/** text scale */
|
|
185
|
-
textScale: number;
|
|
186
|
-
/** page transform */
|
|
187
|
-
transform?: Transform;
|
|
188
|
-
/** format version */
|
|
189
|
-
formatVersion: number;
|
|
190
|
-
/** text alignment */
|
|
191
|
-
textAlignment?: TextAlignment;
|
|
60
|
+
/** the mapping from old hashes to new hashes after a bulk modify */
|
|
61
|
+
export interface HashesEntry {
|
|
62
|
+
/** the mapping from old to new hashes */
|
|
63
|
+
hashes: Record<string, string>;
|
|
192
64
|
}
|
|
193
65
|
/** stripped down version of RequestInit */
|
|
194
66
|
export interface RequestInitLike {
|
|
@@ -212,29 +84,13 @@ export interface ResponseLike {
|
|
|
212
84
|
status: number;
|
|
213
85
|
/** text associated with status */
|
|
214
86
|
statusText: string;
|
|
215
|
-
/** headers in response */
|
|
216
|
-
headers: HeadersLike;
|
|
217
87
|
/** get response body as text */
|
|
218
88
|
text(): Promise<string>;
|
|
219
|
-
/** get response body as an array buffer */
|
|
220
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
221
89
|
}
|
|
222
90
|
/** stripped down version of fetch */
|
|
223
91
|
export interface FetchLike {
|
|
224
92
|
/** the rough interface to fetch */
|
|
225
|
-
(url: string, options?: RequestInitLike
|
|
226
|
-
}
|
|
227
|
-
/** async storage, map like */
|
|
228
|
-
export interface CacheLike {
|
|
229
|
-
/** get value for key or undefined if missing */
|
|
230
|
-
get(key: string): Promise<string | undefined>;
|
|
231
|
-
/** set value for key */
|
|
232
|
-
set(key: string, value: string): Promise<void>;
|
|
233
|
-
}
|
|
234
|
-
/** stripped down version of subtle crypto */
|
|
235
|
-
export interface SubtleCryptoLike {
|
|
236
|
-
/** a digest function */
|
|
237
|
-
digest(algorithm: "SHA-256", data: BufferSource): Promise<ArrayBuffer>;
|
|
93
|
+
(url: string, options?: RequestInitLike): Promise<ResponseLike>;
|
|
238
94
|
}
|
|
239
95
|
/** an error that results from a failed request */
|
|
240
96
|
export declare class ResponseError extends Error {
|
|
@@ -244,14 +100,13 @@ export declare class ResponseError extends Error {
|
|
|
244
100
|
readonly statusText: string;
|
|
245
101
|
constructor(status: number, statusText: string, message: string);
|
|
246
102
|
}
|
|
247
|
-
/**
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
constructor();
|
|
103
|
+
/** an error that results from a failed request */
|
|
104
|
+
export declare class ValidationError extends Error {
|
|
105
|
+
/** the response status number */
|
|
106
|
+
readonly field: string;
|
|
107
|
+
/** the response status text */
|
|
108
|
+
readonly regex: RegExp;
|
|
109
|
+
constructor(field: string, regex: RegExp, message: string);
|
|
255
110
|
}
|
|
256
111
|
/** options for registering with the api */
|
|
257
112
|
export interface RegisterOptions {
|
|
@@ -282,67 +137,6 @@ export interface RegisterOptions {
|
|
|
282
137
|
* @returns the device token necessary for creating an api instace. These never expire so persist as long as necessary.
|
|
283
138
|
*/
|
|
284
139
|
export declare function register(code: string, { deviceDesc, uuid, authHost, fetch, }?: RegisterOptions): Promise<string>;
|
|
285
|
-
/** options for uploading an epub document */
|
|
286
|
-
export interface PutEpubOptions {
|
|
287
|
-
/** the parent id, default to root */
|
|
288
|
-
parent?: string | undefined;
|
|
289
|
-
/** the margins of the epub 180 is good for articles, 125 for books */
|
|
290
|
-
margins?: number | keyof typeof builtinMargins | undefined;
|
|
291
|
-
/** the height of lines */
|
|
292
|
-
lineHeight?: number | keyof typeof builtinLineHeights | undefined;
|
|
293
|
-
/** the scale of text */
|
|
294
|
-
textScale?: number | keyof typeof builtinTextScales | undefined;
|
|
295
|
-
/** the page orientation */
|
|
296
|
-
orientation?: "portrait" | "landscape" | undefined;
|
|
297
|
-
/** the text alignment */
|
|
298
|
-
textAlignment?: TextAlignment | undefined;
|
|
299
|
-
/** which page should be shone as the cover */
|
|
300
|
-
cover?: "first" | "visited" | undefined;
|
|
301
|
-
/** the font name, should probably come from `builtinFontNames` */
|
|
302
|
-
fontName?: string | undefined;
|
|
303
|
-
/** the tool to have enabled by default */
|
|
304
|
-
lastTool?: string;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* options for {@link RemarkableApi.getRootHash | `getRootHash`}
|
|
308
|
-
*/
|
|
309
|
-
export interface GetRootHashOptions {
|
|
310
|
-
/**
|
|
311
|
-
* whether to use the last known valid root hash
|
|
312
|
-
*
|
|
313
|
-
* @defaultValue true
|
|
314
|
-
*/
|
|
315
|
-
cache?: boolean;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* options for {@link RemarkableApi.create | `create`} and
|
|
319
|
-
* {@link RemarkableApi.move | `move`}
|
|
320
|
-
*/
|
|
321
|
-
export interface CreateMoveOptions {
|
|
322
|
-
/**
|
|
323
|
-
* whether to use the last known valid root hash
|
|
324
|
-
*
|
|
325
|
-
* @defaultValue true
|
|
326
|
-
*/
|
|
327
|
-
cache?: boolean;
|
|
328
|
-
/**
|
|
329
|
-
* whether broadcast syncing complete to other devices
|
|
330
|
-
*
|
|
331
|
-
* @defaultValue true
|
|
332
|
-
*/
|
|
333
|
-
sync?: boolean;
|
|
334
|
-
}
|
|
335
|
-
/** options for uploading a pdf */
|
|
336
|
-
export interface PutPdfOptions {
|
|
337
|
-
/** the parent id, default to root */
|
|
338
|
-
parent?: string | undefined;
|
|
339
|
-
/** the page orientation */
|
|
340
|
-
orientation?: "portrait" | "landscape" | undefined;
|
|
341
|
-
/** which page should be shone as the cover */
|
|
342
|
-
cover?: "first" | "visited" | undefined;
|
|
343
|
-
/** the tool to have enabled by default */
|
|
344
|
-
lastTool?: string;
|
|
345
|
-
}
|
|
346
140
|
/** options for getting responses */
|
|
347
141
|
export interface GetOptions {
|
|
348
142
|
/**
|
|
@@ -353,281 +147,106 @@ export interface GetOptions {
|
|
|
353
147
|
*/
|
|
354
148
|
verify?: boolean | undefined;
|
|
355
149
|
}
|
|
150
|
+
export interface UploadOptions extends GetOptions {
|
|
151
|
+
/** an optional parent id to set when uploading */
|
|
152
|
+
parent?: string;
|
|
153
|
+
}
|
|
356
154
|
/**
|
|
357
155
|
* the api for accessing remarkable functions
|
|
358
156
|
*/
|
|
359
157
|
export interface RemarkableApi {
|
|
360
158
|
/**
|
|
361
|
-
*
|
|
159
|
+
* list all files
|
|
362
160
|
*
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* write the root hash, incrimenting from the current generation
|
|
368
|
-
*
|
|
369
|
-
* This will fail if the current generation isn't equal to the passed in
|
|
370
|
-
* generation. Use this to preven race conditions. If this rejects, refetch
|
|
371
|
-
* the root hash, resync the updates, and then try to put again.
|
|
372
|
-
*
|
|
373
|
-
* @remarks Updating the root hash can be dangerous as it changes the full
|
|
374
|
-
* state of what's on the the remarkable. However, it's also the only way to
|
|
375
|
-
* change what's actually visible. If you're unsure if you're doing the right
|
|
376
|
-
* thing, make sure to first save your inital root hash. Then you can always
|
|
377
|
-
* recover by doing:
|
|
378
|
-
* ```
|
|
379
|
-
* let [, gen] = await api.getRootHash();
|
|
380
|
-
* await api.putRootHash(backup, gen);
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* await api.listFiles();
|
|
381
164
|
* ```
|
|
382
|
-
*
|
|
383
|
-
* @param hash - the hash of the new root collection
|
|
384
|
-
* @param generation - the current generation this builds off of
|
|
385
|
-
* @returns the new generation
|
|
386
|
-
* @throws {@link GenerationError} if the current cloud generation didn't
|
|
387
|
-
* match the expected pushed generation.
|
|
388
|
-
*/
|
|
389
|
-
putRootHash(hash: string, generation: bigint): Promise<bigint>;
|
|
390
|
-
/**
|
|
391
|
-
* get array buffer associated with a hash
|
|
392
|
-
*
|
|
393
|
-
* @param hash - the hash to get text data from
|
|
394
165
|
*/
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
|
|
398
|
-
*
|
|
399
|
-
* @param hash - the hash to get text data from
|
|
400
|
-
*/
|
|
401
|
-
getText(hash: string): Promise<string>;
|
|
402
|
-
/**
|
|
403
|
-
* get a json object associated with a hash
|
|
404
|
-
*
|
|
405
|
-
* This is identical to `getText(hash).then(JSON.parse)` and is only provided
|
|
406
|
-
* for consistency with {@link RemarkableApi.putJson | `putJson`}.
|
|
407
|
-
*/
|
|
408
|
-
getJson(hash: string): Promise<unknown>;
|
|
409
|
-
/** get metadata from hash */
|
|
410
|
-
getMetadata(hash: string, opts?: GetOptions): Promise<Metadata>;
|
|
411
|
-
/**
|
|
412
|
-
* get entries from a collection hash
|
|
413
|
-
*
|
|
414
|
-
* If omitted, this will use `getRootHash()`.
|
|
415
|
-
*/
|
|
416
|
-
getEntries(hash?: string): Promise<Entry[]>;
|
|
417
|
-
/** put a reference to a set of entries into the cloud */
|
|
418
|
-
putEntries(documentId: string, entries: Entry[]): Promise<CollectionEntry>;
|
|
419
|
-
/** put a raw buffer in the cloud */
|
|
420
|
-
putBuffer(documentId: string, buffer: ArrayBuffer): Promise<FileEntry>;
|
|
421
|
-
/**
|
|
422
|
-
* put a raw text in the cloud encoded as utf-8
|
|
423
|
-
*
|
|
424
|
-
* this is no different than using `putBuffer(..., new TextEncoder().encode(contents))`
|
|
425
|
-
*/
|
|
426
|
-
putText(documentId: string, contents: string): Promise<FileEntry>;
|
|
427
|
-
/**
|
|
428
|
-
* put json into the cloud
|
|
429
|
-
*
|
|
430
|
-
* This uses a stable (sorted keys) json serilization to preserve consistent
|
|
431
|
-
* hashes.
|
|
432
|
-
*/
|
|
433
|
-
putJson(documentId: string, contents: object): Promise<FileEntry>;
|
|
434
|
-
/**
|
|
435
|
-
* put metadata into the cloud
|
|
436
|
-
*
|
|
437
|
-
* This is a small wrapper around {@link RemarkableApi.putText | `putText`}.
|
|
438
|
-
*
|
|
439
|
-
* @param documentId - this should be the documentId of the item that this is
|
|
440
|
-
* metadata for; it should not end in `.metadata`
|
|
441
|
-
* @param metadata - the metadata to upload
|
|
442
|
-
*/
|
|
443
|
-
putMetadata(documentId: string, metadata: Metadata): Promise<FileEntry>;
|
|
444
|
-
/**
|
|
445
|
-
* create a new collection (folder)
|
|
446
|
-
*
|
|
447
|
-
* @param visibleName - the name of the new folder
|
|
448
|
-
* @param parent - the documentId of the parent collection (folder)
|
|
449
|
-
*/
|
|
450
|
-
putCollection(visibleName: string, parent?: string): Promise<CollectionEntry>;
|
|
166
|
+
listFiles(ops?: GetOptions): Promise<Entry[]>;
|
|
167
|
+
/** create a folder */
|
|
168
|
+
createFolder(visibleName: string, opts?: UploadOptions): Promise<UploadEntry>;
|
|
451
169
|
/**
|
|
452
170
|
* upload an epub
|
|
453
171
|
*
|
|
454
|
-
* @remarks this only uploads the raw data and returns an entry that could be
|
|
455
|
-
* uploaded as part of a larger collection. To make sure devices know about
|
|
456
|
-
* it, you'll still need to update the root hash, and potentially notify
|
|
457
|
-
* other devices.
|
|
458
|
-
*
|
|
459
172
|
* @example
|
|
460
|
-
* This example shows a full process upload. Note that it may fail if other
|
|
461
|
-
* devices are simultaneously syncing content. See {@link putRootHash} for
|
|
462
|
-
* more information.
|
|
463
|
-
*
|
|
464
173
|
* ```ts
|
|
465
|
-
*
|
|
466
|
-
* await api.create(entry);
|
|
174
|
+
* await api.uploadEpub("My EPub", ...);
|
|
467
175
|
* ```
|
|
468
176
|
*
|
|
469
177
|
* @param visibleName - the name to show for the uploaded epub
|
|
470
178
|
* @param buffer - the epub contents
|
|
471
|
-
* @param opts - extra options you can specify at upload
|
|
472
179
|
*/
|
|
473
|
-
|
|
180
|
+
uploadEpub(visibleName: string, buffer: ArrayBuffer, opts?: UploadOptions): Promise<UploadEntry>;
|
|
474
181
|
/**
|
|
475
182
|
* upload a pdf
|
|
476
183
|
*
|
|
477
|
-
* @remarks this only uploads the raw data and returns an entry that could be
|
|
478
|
-
* uploaded as part of a larger collection. To make sure devices know about
|
|
479
|
-
* it, you'll still need to update the root hash, and potentially notify
|
|
480
|
-
* other devices.
|
|
481
|
-
*
|
|
482
184
|
* @example
|
|
483
|
-
* This example shows a full process upload. Note that it may fail if other
|
|
484
|
-
* devices are simultaneously syncing content. See {@link putRootHash} for
|
|
485
|
-
* more information.
|
|
486
|
-
*
|
|
487
185
|
* ```ts
|
|
488
|
-
*
|
|
489
|
-
* await api.create(entry);
|
|
186
|
+
* await api.uploadPdf("My PDF", ...);
|
|
490
187
|
* ```
|
|
491
188
|
*
|
|
492
|
-
* @param visibleName - the name to show for the uploaded
|
|
493
|
-
* @param buffer - the
|
|
494
|
-
* @param opts - extra options you can specify at upload
|
|
495
|
-
*/
|
|
496
|
-
putPdf(visibleName: string, buffer: ArrayBuffer, opts?: PutPdfOptions): Promise<CollectionEntry>;
|
|
497
|
-
/**
|
|
498
|
-
* indicate that a sync is complete and push updates to other devices
|
|
499
|
-
*
|
|
500
|
-
* @remarks after successfully putting a new root hash, use this to indicate
|
|
501
|
-
* that other devices should pick up the change.
|
|
189
|
+
* @param visibleName - the name to show for the uploaded epub
|
|
190
|
+
* @param buffer - the epub contents
|
|
502
191
|
*/
|
|
503
|
-
|
|
192
|
+
uploadPdf(visibleName: string, buffer: ArrayBuffer, opts?: UploadOptions): Promise<UploadEntry>;
|
|
504
193
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
* After creating a collection entry with
|
|
508
|
-
* {@link RemarkableApi.putCollection | `putCollection`},
|
|
509
|
-
* {@link RemarkableApi.putEpub | `putEpub`}, or
|
|
510
|
-
* {@link RemarkableApi.putPdf | `putPdf`}, this is a high level API to try
|
|
511
|
-
* syncing the change to the remarkable.
|
|
512
|
-
*
|
|
513
|
-
* @remarks
|
|
514
|
-
* This API is provided to give a high level interface and to serve as an
|
|
515
|
-
* example of how to implement more advanced functionality, but it comes with
|
|
516
|
-
* a number of caveats:
|
|
517
|
-
* 1. For most use cases, it will repeat requests to remarkable's servers
|
|
518
|
-
* (even with a cache) making it slower than implementing similar steps
|
|
519
|
-
* manually.
|
|
520
|
-
* 2. It includes no handling of concurrent modification or other networking
|
|
521
|
-
* errors, requiring repeat network requests if anything fails.
|
|
522
|
-
*
|
|
523
|
-
* However, with recent changes in the way this library caches results, it
|
|
524
|
-
* won't be terribly inefficient to just do multiple retries of create after
|
|
525
|
-
* uploading the file itself.
|
|
194
|
+
* move an entry
|
|
526
195
|
*
|
|
527
196
|
* @example
|
|
528
197
|
* ```ts
|
|
529
|
-
*
|
|
530
|
-
* await api.create(entry);
|
|
198
|
+
* await api.move(doc.hash, dir.id);
|
|
531
199
|
* ```
|
|
532
200
|
*
|
|
533
|
-
* @param
|
|
534
|
-
* @param
|
|
535
|
-
* @returns synced - if sync was successful
|
|
536
|
-
* @throws error - if any error occurred, in this case, nothing will be
|
|
537
|
-
* changed
|
|
201
|
+
* @param hash - the hash of the file to move
|
|
202
|
+
* @param parent - the id of the directory to move the entry to, "" (root) and "trash" are special parents
|
|
538
203
|
*/
|
|
539
|
-
|
|
204
|
+
move(hash: string, parent: string, opts?: GetOptions): Promise<HashEntry>;
|
|
540
205
|
/**
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* Use this as a high level api to move files in the document tree.
|
|
544
|
-
*
|
|
545
|
-
* @remarks
|
|
546
|
-
* This API is provided to give a high level interface and to serve as an
|
|
547
|
-
* example of how to implement more advanced functionality, but it comes with
|
|
548
|
-
* a number of caveats:
|
|
549
|
-
* 1. For most use cases, it will repeat requests to remarkable's servers
|
|
550
|
-
* (even with a cache) making it slower than implementing similar steps
|
|
551
|
-
* manually.
|
|
552
|
-
* 2. It includes no handling of concurrent modification or other networking
|
|
553
|
-
* errors, requiring repeat network requests if anything fails.
|
|
554
|
-
*
|
|
555
|
-
* However, with changes to the way this caches results, it won't be terribly
|
|
556
|
-
* inefficient to just retry calling `move` if there's a failure.
|
|
206
|
+
* delete an entry
|
|
557
207
|
*
|
|
558
208
|
* @example
|
|
559
209
|
* ```ts
|
|
560
|
-
*
|
|
561
|
-
* const entries = await api.getEntries(root);
|
|
562
|
-
* const { documentId } = entries.find(...);
|
|
563
|
-
* await api.move(documentId, "trash");
|
|
210
|
+
* await api.delete(file.hash);
|
|
564
211
|
* ```
|
|
565
|
-
*
|
|
566
|
-
* @param documentId - the document id of the document or collection to move
|
|
567
|
-
* @param dest - the new parent of this collection or document; this should
|
|
568
|
-
* be the document id of an existing collection, an empty string for root,
|
|
569
|
-
* or the string `"trash"` to move to the trash
|
|
570
|
-
* @param opts - any extra options for moving
|
|
571
|
-
* @returns synced - true if synced successfully
|
|
572
|
-
* @throws error - if any error occurred, in this case, nothing will be
|
|
573
|
-
* changed
|
|
212
|
+
* @param hash - the hash of the entry to delete
|
|
574
213
|
*/
|
|
575
|
-
|
|
214
|
+
delete(hash: string, opts?: GetOptions): Promise<HashEntry>;
|
|
576
215
|
/**
|
|
577
|
-
*
|
|
216
|
+
* rename an entry
|
|
578
217
|
*
|
|
579
|
-
* @
|
|
580
|
-
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* await api.rename(file.hash, "new name");
|
|
221
|
+
* ```
|
|
222
|
+
* @param hash - the hash of the entry to rename
|
|
223
|
+
* @param visibleName - the new name to assign
|
|
581
224
|
*/
|
|
582
|
-
|
|
225
|
+
rename(hash: string, visibleName: string, opts?: GetOptions): Promise<HashEntry>;
|
|
583
226
|
/**
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* @remarks this uses a newer api that performs a full upload and sync, but
|
|
587
|
-
* doesn't allow adding the same level of extra content data. Useful if you
|
|
588
|
-
* just want to upload a document with no fuss.
|
|
227
|
+
* move many entries
|
|
589
228
|
*
|
|
590
229
|
* @example
|
|
591
230
|
* ```ts
|
|
592
|
-
* await api.
|
|
231
|
+
* await api.bulkMove([file.hash], dir.id);
|
|
593
232
|
* ```
|
|
594
233
|
*
|
|
595
|
-
* @param
|
|
596
|
-
* @param
|
|
234
|
+
* @param hashes - an array of entry hashes to move
|
|
235
|
+
* @param parent - the directory id to move the entries to, "" (root) and "trash" are special ids
|
|
597
236
|
*/
|
|
598
|
-
|
|
237
|
+
bulkMove(hashes: readonly string[], parent: string, opts?: GetOptions): Promise<HashesEntry>;
|
|
599
238
|
/**
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
* this currently uploads invalid pdfs, but it's not clear why, which is why
|
|
603
|
-
* this is marked as experimental. Potentially some tweak in the formatting
|
|
604
|
-
* of buffer will fix it.
|
|
605
|
-
*
|
|
606
|
-
* @remarks this uses a newer api that performs a full upload and sync, but
|
|
607
|
-
* doesn't allow adding the same level of extra information.
|
|
239
|
+
* delete many entries
|
|
608
240
|
*
|
|
609
241
|
* @example
|
|
610
242
|
* ```ts
|
|
611
|
-
* await api.
|
|
243
|
+
* await api.bulkDelete([file.hash]);
|
|
612
244
|
* ```
|
|
613
245
|
*
|
|
614
|
-
* @param
|
|
615
|
-
* @param buffer - the epub contents
|
|
616
|
-
* @experimental
|
|
617
|
-
*/
|
|
618
|
-
uploadPdf(visibleName: string, buffer: ArrayBuffer, opts?: GetOptions): Promise<UploadEntry>;
|
|
619
|
-
/**
|
|
620
|
-
* get the current state of the cache for persisting
|
|
621
|
-
*
|
|
622
|
-
* This won't include items that weren't cached because they were too big,
|
|
623
|
-
* meaning it won't prevent duplicate puts of large content across sessions.
|
|
246
|
+
* @param hashes - the hashes of the entries to delete
|
|
624
247
|
*/
|
|
625
|
-
|
|
248
|
+
bulkDelete(hashes: readonly string[], opts?: GetOptions): Promise<HashesEntry>;
|
|
626
249
|
}
|
|
627
|
-
/** format an entry */
|
|
628
|
-
export declare function formatEntry({ hash, type, documentId, subfiles, size, }: Entry): string;
|
|
629
|
-
/** parse an entry */
|
|
630
|
-
export declare function parseEntry(line: string): Entry;
|
|
631
250
|
/** options for a remarkable instance */
|
|
632
251
|
export interface RemarkableOptions {
|
|
633
252
|
/**
|
|
@@ -643,17 +262,6 @@ export interface RemarkableOptions {
|
|
|
643
262
|
* @defaultValue globalThis.fetch
|
|
644
263
|
*/
|
|
645
264
|
fetch?: FetchLike;
|
|
646
|
-
/**
|
|
647
|
-
* a subtle-crypto-like object
|
|
648
|
-
*
|
|
649
|
-
* This should have a digest function like the api of `crypto.subtle`, it's
|
|
650
|
-
* default value. In node try
|
|
651
|
-
* `import { webcrypto } from "crypto"; global.crypto = webcrypto` or pass in
|
|
652
|
-
* `webcrypto.subtle`.
|
|
653
|
-
*
|
|
654
|
-
* @defaultValue globalThis.crypto.subtle
|
|
655
|
-
*/
|
|
656
|
-
subtle?: SubtleCryptoLike;
|
|
657
265
|
/**
|
|
658
266
|
* the url for making authorization requests
|
|
659
267
|
*
|
|
@@ -666,27 +274,6 @@ export interface RemarkableOptions {
|
|
|
666
274
|
* @defaultValue "https://internal.cloud.remarkable.com"
|
|
667
275
|
*/
|
|
668
276
|
syncHost?: string;
|
|
669
|
-
/**
|
|
670
|
-
* the maximum size in bytes to cache the value of a stored object
|
|
671
|
-
*
|
|
672
|
-
* Since the remarkableApi is based around hashes, the value of a hash should
|
|
673
|
-
* never change (barring collisions in ASH256). Any known hash value that's
|
|
674
|
-
* less than this amount will be cached locally to prevent future network
|
|
675
|
-
* requests. In addition, all successful puts and gets will be cached to
|
|
676
|
-
* prevent duplicate puts in the future.
|
|
677
|
-
*
|
|
678
|
-
* To save memory and disable fetch caching, set to 0.
|
|
679
|
-
*
|
|
680
|
-
* @defaultValue 1 MiB
|
|
681
|
-
*/
|
|
682
|
-
cacheLimitBytes?: number;
|
|
683
|
-
/**
|
|
684
|
-
* a set of values to use to initialize the cache
|
|
685
|
-
*
|
|
686
|
-
* If this is inaccurate, then you could encounter errors with other methods.
|
|
687
|
-
* Often this will come from {@link RemarkableApi.getCache | `getCache`}.
|
|
688
|
-
*/
|
|
689
|
-
initCache?: Iterable<readonly [string, ArrayBuffer]>;
|
|
690
277
|
}
|
|
691
278
|
/**
|
|
692
279
|
* create an instance of the api
|
|
@@ -698,4 +285,4 @@ export interface RemarkableOptions {
|
|
|
698
285
|
* registered. Create one with {@link register}.
|
|
699
286
|
* @returns an api instance
|
|
700
287
|
*/
|
|
701
|
-
export declare function remarkable(deviceToken: string, { fetch,
|
|
288
|
+
export declare function remarkable(deviceToken: string, { fetch, authHost, syncHost, }?: RemarkableOptions): Promise<RemarkableApi>;
|