inkdrop-model 2.7.1 → 2.7.3

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/lib/book.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- import type { ValidateFunction } from 'ajv';
2
- import BookSchema from '../json-schema/book.json';
3
- import type { EncryptedData } from './crypto';
4
- export declare type BookMetadata = {
5
- _id: string;
6
- _rev?: string;
7
- updatedAt: number;
8
- createdAt: number;
9
- count?: number;
10
- parentBookId?: null | string;
11
- migratedBy?: string;
12
- };
13
- export declare type Book = BookMetadata & {
14
- name: string;
15
- };
16
- export declare type EncryptedBook = BookMetadata & {
17
- encryptedData: EncryptedData;
18
- };
19
- declare const validateBook: ValidateFunction<Book>;
20
- export { BookSchema, validateBook };
1
+ import type { ValidateFunction } from 'ajv';
2
+ import BookSchema from '../json-schema/book.json';
3
+ import type { EncryptedData } from './crypto';
4
+ export type BookMetadata = {
5
+ _id: string;
6
+ _rev?: string;
7
+ updatedAt: number;
8
+ createdAt: number;
9
+ count?: number;
10
+ parentBookId?: null | string;
11
+ migratedBy?: string;
12
+ };
13
+ export type Book = BookMetadata & {
14
+ name: string;
15
+ };
16
+ export type EncryptedBook = BookMetadata & {
17
+ encryptedData: EncryptedData;
18
+ };
19
+ declare const validateBook: ValidateFunction<Book>;
20
+ export { BookSchema, validateBook };
package/lib/crypto.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- /// <reference types="node" />
2
- export declare type EncryptionMetadata = {
3
- algorithm: string;
4
- iv: string;
5
- tag: string;
6
- };
7
- export declare type EncryptedData = EncryptionMetadata & {
8
- content: string | Buffer;
9
- };
1
+ /// <reference types="node" />
2
+ export type EncryptionMetadata = {
3
+ algorithm: string;
4
+ iv: string;
5
+ tag: string;
6
+ };
7
+ export type EncryptedData = EncryptionMetadata & {
8
+ content: string | Buffer;
9
+ };
package/lib/file.d.ts CHANGED
@@ -1,34 +1,34 @@
1
- /// <reference types="node" />
2
- import type { ValidateFunction } from 'ajv';
3
- import FileSchema from '../json-schema/file.json';
4
- import type { EncryptionMetadata } from './crypto';
5
- export declare type ImageFileType = 'image/png' | 'image/jpeg' | 'image/jpg' | 'image/svg+xml' | 'image/gif' | 'image/heic' | 'image/heif';
6
- export declare const supportedImageFileTypes: ReadonlyArray<ImageFileType>;
7
- export declare const SUPPORTED_IMAGE_MIME_TYPES: {
8
- readonly [mime: string]: ImageFileType;
9
- };
10
- export declare const maxAttachmentFileSize: number;
11
- export declare type FileAttachmentItem = {
12
- digest?: string;
13
- content_type: ImageFileType;
14
- data: Buffer | string;
15
- length?: number;
16
- };
17
- export declare type File = {
18
- _id: string;
19
- _rev?: string;
20
- name: string;
21
- createdAt: number;
22
- contentType: ImageFileType;
23
- contentLength: number;
24
- publicIn: string[];
25
- _attachments: {
26
- index: FileAttachmentItem;
27
- };
28
- md5digest?: string;
29
- };
30
- export declare type EncryptedFile = File & {
31
- encryptionData: EncryptionMetadata;
32
- };
33
- declare const validateFile: ValidateFunction<File>;
34
- export { FileSchema, validateFile };
1
+ /// <reference types="node" />
2
+ import type { ValidateFunction } from 'ajv';
3
+ import FileSchema from '../json-schema/file.json';
4
+ import type { EncryptionMetadata } from './crypto';
5
+ export type ImageFileType = 'image/png' | 'image/jpeg' | 'image/jpg' | 'image/svg+xml' | 'image/gif' | 'image/heic' | 'image/heif';
6
+ export declare const supportedImageFileTypes: ReadonlyArray<ImageFileType>;
7
+ export declare const SUPPORTED_IMAGE_MIME_TYPES: {
8
+ readonly [mime: string]: ImageFileType;
9
+ };
10
+ export declare const maxAttachmentFileSize: number;
11
+ export type FileAttachmentItem = {
12
+ digest?: string;
13
+ content_type: ImageFileType;
14
+ data: Buffer | string;
15
+ length?: number;
16
+ };
17
+ export type File = {
18
+ _id: string;
19
+ _rev?: string;
20
+ name: string;
21
+ createdAt: number;
22
+ contentType: ImageFileType;
23
+ contentLength: number;
24
+ publicIn: string[];
25
+ _attachments: {
26
+ index: FileAttachmentItem;
27
+ };
28
+ md5digest?: string;
29
+ };
30
+ export type EncryptedFile = File & {
31
+ encryptionData: EncryptionMetadata;
32
+ };
33
+ declare const validateFile: ValidateFunction<File>;
34
+ export { FileSchema, validateFile };
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './note';
2
- export * from './book';
3
- export * from './tag';
4
- export * from './file';
5
- export * from './crypto';
6
- export * from './validator';
1
+ export * from './note';
2
+ export * from './book';
3
+ export * from './tag';
4
+ export * from './file';
5
+ export * from './crypto';
6
+ export * from './validator';
package/lib/index.esm.js CHANGED
@@ -1,47 +1,295 @@
1
- export { default as NoteSchema } from '../json-schema/note.json';
2
1
  import validator from '../validators/note';
3
- export { default as BookSchema } from '../json-schema/book.json';
4
2
  import validator$1 from '../validators/book';
5
- export { default as TagSchema } from '../json-schema/tag.json';
6
3
  import validator$2 from '../validators/tag';
7
- export { default as FileSchema } from '../json-schema/file.json';
8
4
  import validator$3 from '../validators/file';
9
5
 
10
- var TRASH_BOOK_ID = 'trash';
11
- var NOTE_STATUS = {
12
- NONE: 'none',
13
- ACTIVE: 'active',
14
- ON_HOLD: 'onHold',
15
- COMPLETED: 'completed',
16
- DROPPED: 'dropped'
17
- };
18
- var NOTE_VISIBILITY = {
19
- PRIVATE: 'private',
20
- PUBLIC: 'public'
21
- };
6
+ var $schema$3 = "http://json-schema.org/draft-07/schema#";
7
+ var $id$3 = "note";
8
+ var title$3 = "Note";
9
+ var description$3 = "A note data";
10
+ var type$3 = "object";
11
+ var properties$3 = {
12
+ _id: {
13
+ description: "The unique document ID which should start with `note:` and the remains are randomly generated string",
14
+ type: "string",
15
+ minLength: 6,
16
+ maxLength: 128,
17
+ pattern: "^note:"
18
+ },
19
+ _rev: {
20
+ description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
21
+ type: "string"
22
+ },
23
+ bookId: {
24
+ description: "The notebook ID",
25
+ type: "string",
26
+ minLength: 5,
27
+ maxLength: 128,
28
+ pattern: "^(book:|trash$)"
29
+ },
30
+ title: {
31
+ description: "The note title",
32
+ type: "string",
33
+ maxLength: 128
34
+ },
35
+ doctype: {
36
+ description: "The format type of the body field. It currently can take markdown only, reserved for the future",
37
+ type: "string",
38
+ "enum": [
39
+ "markdown"
40
+ ]
41
+ },
42
+ body: {
43
+ description: "The content of the note represented with Markdown",
44
+ type: "string",
45
+ maxLength: 1048576
46
+ },
47
+ updatedAt: {
48
+ description: "The date time when the note was last updated, represented with Unix timestamps in milliseconds",
49
+ type: "number"
50
+ },
51
+ createdAt: {
52
+ description: "The date time when the note was created, represented with Unix timestamps in milliseconds",
53
+ type: "number"
54
+ },
55
+ tags: {
56
+ description: "The list of tag IDs",
57
+ type: "array",
58
+ items: {
59
+ type: "string"
60
+ },
61
+ uniqueItems: true
62
+ },
63
+ numOfTasks: {
64
+ description: "The number of tasks, extracted from body",
65
+ type: "number"
66
+ },
67
+ numOfCheckedTasks: {
68
+ description: "The number of checked tasks, extracted from body",
69
+ type: "number"
70
+ },
71
+ migratedBy: {
72
+ description: "The type of the data migration",
73
+ type: "string",
74
+ maxLength: 128
75
+ },
76
+ status: {
77
+ description: "The status of the note",
78
+ type: "string",
79
+ "enum": [
80
+ "none",
81
+ "active",
82
+ "onHold",
83
+ "completed",
84
+ "dropped"
85
+ ]
86
+ },
87
+ share: {
88
+ description: "The sharing mode of the note",
89
+ type: "string",
90
+ "enum": [
91
+ "private",
92
+ "public"
93
+ ]
94
+ },
95
+ pinned: {
96
+ description: "Whether the note is pinned to top",
97
+ type: "boolean"
98
+ },
99
+ _conflicts: {
100
+ description: "Conflicted revisions",
101
+ type: "array",
102
+ items: {
103
+ type: "string"
104
+ },
105
+ uniqueItems: true
106
+ }
107
+ };
108
+ var required$3 = [
109
+ "_id",
110
+ "bookId",
111
+ "title",
112
+ "doctype",
113
+ "body",
114
+ "updatedAt",
115
+ "createdAt"
116
+ ];
117
+ var note = {
118
+ $schema: $schema$3,
119
+ $id: $id$3,
120
+ title: title$3,
121
+ description: description$3,
122
+ type: type$3,
123
+ properties: properties$3,
124
+ required: required$3
125
+ };
126
+
127
+ var TRASH_BOOK_ID = 'trash';
128
+ var NOTE_STATUS = {
129
+ NONE: 'none',
130
+ ACTIVE: 'active',
131
+ ON_HOLD: 'onHold',
132
+ COMPLETED: 'completed',
133
+ DROPPED: 'dropped'
134
+ };
135
+ var NOTE_VISIBILITY = {
136
+ PRIVATE: 'private',
137
+ PUBLIC: 'public'
138
+ };
22
139
  var validateNote = validator;
23
140
 
141
+ var $schema$2 = "http://json-schema.org/draft-07/schema#";
142
+ var $id$2 = "book";
143
+ var title$2 = "Book";
144
+ var description$2 = "A notebook data";
145
+ var type$2 = "object";
146
+ var properties$2 = {
147
+ _id: {
148
+ description: "The unique notebook ID which should start with `book:` and the remains are randomly generated string",
149
+ type: "string",
150
+ minLength: 6,
151
+ maxLength: 128,
152
+ pattern: "^book:"
153
+ },
154
+ _rev: {
155
+ description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
156
+ type: "string"
157
+ },
158
+ name: {
159
+ description: "The notebook name",
160
+ type: "string",
161
+ minLength: 1,
162
+ maxLength: 64
163
+ },
164
+ updatedAt: {
165
+ description: "The date time when the notebook was last updated, represented with Unix timestamps in milliseconds",
166
+ type: "number"
167
+ },
168
+ createdAt: {
169
+ description: "The date time when the notebook was created, represented with Unix timestamps in milliseconds",
170
+ type: "number"
171
+ },
172
+ count: {
173
+ description: "It indicates the number of notes in the notebook",
174
+ type: "number"
175
+ },
176
+ parentBookId: {
177
+ description: "The ID of the parent notebook",
178
+ type: [
179
+ "string",
180
+ "null"
181
+ ]
182
+ }
183
+ };
184
+ var required$2 = [
185
+ "_id",
186
+ "name",
187
+ "updatedAt",
188
+ "createdAt"
189
+ ];
190
+ var book = {
191
+ $schema: $schema$2,
192
+ $id: $id$2,
193
+ title: title$2,
194
+ description: description$2,
195
+ type: type$2,
196
+ properties: properties$2,
197
+ required: required$2
198
+ };
199
+
24
200
  var validateBook = validator$1;
25
201
 
26
- var TAG_COLOR = {
27
- DEFAULT: 'default',
28
- RED: 'red',
29
- ORANGE: 'orange',
30
- YELLOW: 'yellow',
31
- OLIVE: 'olive',
32
- GREEN: 'green',
33
- TEAL: 'teal',
34
- BLUE: 'blue',
35
- VIOLET: 'violet',
36
- PURPLE: 'purple',
37
- PINK: 'pink',
38
- BROWN: 'brown',
39
- GREY: 'grey',
40
- BLACK: 'black'
41
- };
202
+ var $schema$1 = "http://json-schema.org/draft-07/schema#";
203
+ var $id$1 = "tag";
204
+ var title$1 = "Tag";
205
+ var description$1 = "A note tag";
206
+ var type$1 = "object";
207
+ var properties$1 = {
208
+ _id: {
209
+ description: "The unique tag ID which should start with `tag:` and the remains are randomly generated string",
210
+ type: "string",
211
+ minLength: 6,
212
+ maxLength: 128,
213
+ pattern: "^tag:"
214
+ },
215
+ _rev: {
216
+ description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
217
+ type: "string"
218
+ },
219
+ name: {
220
+ description: "The name of the tag",
221
+ type: "string",
222
+ maxLength: 64
223
+ },
224
+ count: {
225
+ description: "It indicates the number of notes with the tag",
226
+ type: "number"
227
+ },
228
+ color: {
229
+ description: "The color type of the tag",
230
+ type: "string",
231
+ "enum": [
232
+ "default",
233
+ "red",
234
+ "orange",
235
+ "yellow",
236
+ "olive",
237
+ "green",
238
+ "teal",
239
+ "blue",
240
+ "violet",
241
+ "purple",
242
+ "pink",
243
+ "brown",
244
+ "grey",
245
+ "black"
246
+ ]
247
+ },
248
+ updatedAt: {
249
+ description: "The date time when the tag was last updated, represented with Unix timestamps in milliseconds",
250
+ type: "number"
251
+ },
252
+ createdAt: {
253
+ description: "The date time when the tag was created, represented with Unix timestamps in milliseconds",
254
+ type: "number"
255
+ }
256
+ };
257
+ var required$1 = [
258
+ "_id",
259
+ "name",
260
+ "count",
261
+ "updatedAt",
262
+ "createdAt"
263
+ ];
264
+ var tag = {
265
+ $schema: $schema$1,
266
+ $id: $id$1,
267
+ title: title$1,
268
+ description: description$1,
269
+ type: type$1,
270
+ properties: properties$1,
271
+ required: required$1
272
+ };
273
+
274
+ var TAG_COLOR = {
275
+ DEFAULT: 'default',
276
+ RED: 'red',
277
+ ORANGE: 'orange',
278
+ YELLOW: 'yellow',
279
+ OLIVE: 'olive',
280
+ GREEN: 'green',
281
+ TEAL: 'teal',
282
+ BLUE: 'blue',
283
+ VIOLET: 'violet',
284
+ PURPLE: 'purple',
285
+ PINK: 'pink',
286
+ BROWN: 'brown',
287
+ GREY: 'grey',
288
+ BLACK: 'black'
289
+ };
42
290
  var validateTag = validator$2;
43
291
 
44
- /*! *****************************************************************************
292
+ /******************************************************************************
45
293
  Copyright (c) Microsoft Corporation.
46
294
 
47
295
  Permission to use, copy, modify, and/or distribute this software for any
@@ -83,49 +331,162 @@ var __assign = function() {
83
331
  return __assign.apply(this, arguments);
84
332
  };
85
333
 
86
- var supportedImageFileTypes = [
87
- 'image/png',
88
- 'image/jpeg',
89
- 'image/jpg',
90
- 'image/svg+xml',
91
- 'image/gif',
92
- 'image/heic',
93
- 'image/heif'
94
- ];
95
- var SUPPORTED_IMAGE_MIME_TYPES = __assign(__assign({}, supportedImageFileTypes.reduce(function (hash, ft) {
96
- var _a;
97
- return (__assign(__assign({}, hash), (_a = {}, _a[ft.split('/')[1]] = ft, _a)));
98
- }, {})), { jpg: 'image/jpeg' });
99
- var maxAttachmentFileSize = 10 * 1024 * 1024;
334
+ var $schema = "http://json-schema.org/draft-07/schema#";
335
+ var $id = "file";
336
+ var title = "File";
337
+ var description = "An attachment file";
338
+ var type = "object";
339
+ var properties = {
340
+ _id: {
341
+ description: "The unique document ID which should start with `file:` and the remains are randomly generated string",
342
+ type: "string",
343
+ minLength: 6,
344
+ maxLength: 128,
345
+ pattern: "^file:"
346
+ },
347
+ _rev: {
348
+ description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
349
+ type: "string"
350
+ },
351
+ name: {
352
+ description: "The file name",
353
+ type: "string",
354
+ minLength: 1,
355
+ maxLength: 128
356
+ },
357
+ createdAt: {
358
+ description: "The date time when the note was created, represented with Unix timestamps in milliseconds",
359
+ type: "number"
360
+ },
361
+ contentType: {
362
+ description: "The MIME type of the content",
363
+ type: "string",
364
+ "enum": [
365
+ "image/png",
366
+ "image/jpeg",
367
+ "image/jpg",
368
+ "image/svg+xml",
369
+ "image/gif",
370
+ "image/heic",
371
+ "image/heif"
372
+ ],
373
+ maxLength: 128
374
+ },
375
+ contentLength: {
376
+ description: "The content length of the file",
377
+ type: "number",
378
+ maximum: 10485760
379
+ },
380
+ publicIn: {
381
+ description: "An array of the note IDs where the file is included",
382
+ type: "array",
383
+ items: {
384
+ type: "string"
385
+ },
386
+ uniqueItems: true
387
+ },
388
+ _attachments: {
389
+ description: "The attachment file",
390
+ type: "object",
391
+ properties: {
392
+ index: {
393
+ description: "The attachment file",
394
+ type: "object",
395
+ properties: {
396
+ content_type: {
397
+ description: "The content type of the file",
398
+ type: "string",
399
+ "enum": [
400
+ "image/png",
401
+ "image/jpeg",
402
+ "image/jpg",
403
+ "image/svg+xml",
404
+ "image/gif",
405
+ "image/heic",
406
+ "image/heif"
407
+ ]
408
+ },
409
+ data: {
410
+ description: "The file data",
411
+ type: [
412
+ "string",
413
+ "object"
414
+ ]
415
+ }
416
+ },
417
+ required: [
418
+ "content_type",
419
+ "data"
420
+ ]
421
+ }
422
+ },
423
+ required: [
424
+ "index"
425
+ ]
426
+ }
427
+ };
428
+ var required = [
429
+ "_id",
430
+ "name",
431
+ "createdAt",
432
+ "contentType",
433
+ "contentLength",
434
+ "publicIn",
435
+ "_attachments"
436
+ ];
437
+ var file = {
438
+ $schema: $schema,
439
+ $id: $id,
440
+ title: title,
441
+ description: description,
442
+ type: type,
443
+ properties: properties,
444
+ required: required
445
+ };
446
+
447
+ var supportedImageFileTypes = [
448
+ 'image/png',
449
+ 'image/jpeg',
450
+ 'image/jpg',
451
+ 'image/svg+xml',
452
+ 'image/gif',
453
+ 'image/heic',
454
+ 'image/heif'
455
+ ];
456
+ var SUPPORTED_IMAGE_MIME_TYPES = __assign(__assign({}, supportedImageFileTypes.reduce(function (hash, ft) {
457
+ var _a;
458
+ return (__assign(__assign({}, hash), (_a = {}, _a[ft.split('/')[1]] = ft, _a)));
459
+ }, {})), { jpg: 'image/jpeg' });
460
+ var maxAttachmentFileSize = 10 * 1024 * 1024;
100
461
  var validateFile = validator$3;
101
462
 
102
- function validationErrorsToMessage(errors) {
103
- if (errors instanceof Array) {
104
- return errors
105
- .map(function (e) {
106
- if (typeof e === 'object') {
107
- return "\"".concat(e.instancePath, "\" ").concat(e.message);
108
- }
109
- else {
110
- return e;
111
- }
112
- })
113
- .join(', ');
114
- }
115
- else {
116
- return errors;
117
- }
118
- }
119
- var InvalidDataError = /** @class */ (function (_super) {
120
- __extends(InvalidDataError, _super);
121
- function InvalidDataError(message, errors) {
122
- var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
123
- _this.name = 'InvalidDataError';
124
- _this.errors = errors;
125
- return _this;
126
- }
127
- return InvalidDataError;
463
+ function validationErrorsToMessage(errors) {
464
+ if (errors instanceof Array) {
465
+ return errors
466
+ .map(function (e) {
467
+ if (typeof e === 'object') {
468
+ return "\"".concat(e.instancePath, "\" ").concat(e.message);
469
+ }
470
+ else {
471
+ return e;
472
+ }
473
+ })
474
+ .join(', ');
475
+ }
476
+ else {
477
+ return errors;
478
+ }
479
+ }
480
+ var InvalidDataError = /** @class */ (function (_super) {
481
+ __extends(InvalidDataError, _super);
482
+ function InvalidDataError(message, errors) {
483
+ var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
484
+ _this.name = 'InvalidDataError';
485
+ _this.errors = errors;
486
+ return _this;
487
+ }
488
+ return InvalidDataError;
128
489
  }(Error));
129
490
 
130
- export { InvalidDataError, NOTE_STATUS, NOTE_VISIBILITY, SUPPORTED_IMAGE_MIME_TYPES, TAG_COLOR, TRASH_BOOK_ID, maxAttachmentFileSize, supportedImageFileTypes, validateBook, validateFile, validateNote, validateTag, validationErrorsToMessage };
491
+ export { book as BookSchema, file as FileSchema, InvalidDataError, NOTE_STATUS, NOTE_VISIBILITY, note as NoteSchema, SUPPORTED_IMAGE_MIME_TYPES, TAG_COLOR, TRASH_BOOK_ID, tag as TagSchema, maxAttachmentFileSize, supportedImageFileTypes, validateBook, validateFile, validateNote, validateTag, validationErrorsToMessage };
131
492
  //# sourceMappingURL=index.esm.js.map