inkdrop-model 2.11.1 → 2.11.2
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 +1 -0
- package/lib/file.d.ts +1 -0
- package/lib/index.esm.js +93 -75
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +97 -74
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/note.d.ts +1 -0
- package/lib/tag.d.ts +1 -0
- package/lib/validator.d.ts +1 -0
- package/package.json +1 -1
package/lib/book.d.ts
CHANGED
package/lib/file.d.ts
CHANGED
package/lib/index.esm.js
CHANGED
|
@@ -129,6 +129,87 @@ var note = {
|
|
|
129
129
|
required: required$3
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
/******************************************************************************
|
|
133
|
+
Copyright (c) Microsoft Corporation.
|
|
134
|
+
|
|
135
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
136
|
+
purpose with or without fee is hereby granted.
|
|
137
|
+
|
|
138
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
139
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
140
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
141
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
142
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
143
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
144
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
145
|
+
***************************************************************************** */
|
|
146
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
147
|
+
|
|
148
|
+
var extendStatics = function(d, b) {
|
|
149
|
+
extendStatics = Object.setPrototypeOf ||
|
|
150
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
151
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
152
|
+
return extendStatics(d, b);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
function __extends(d, b) {
|
|
156
|
+
if (typeof b !== "function" && b !== null)
|
|
157
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
158
|
+
extendStatics(d, b);
|
|
159
|
+
function __() { this.constructor = d; }
|
|
160
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var __assign = function() {
|
|
164
|
+
__assign = Object.assign || function __assign(t) {
|
|
165
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
166
|
+
s = arguments[i];
|
|
167
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
168
|
+
}
|
|
169
|
+
return t;
|
|
170
|
+
};
|
|
171
|
+
return __assign.apply(this, arguments);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
175
|
+
var e = new Error(message);
|
|
176
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
function validationErrorsToMessage(errors) {
|
|
180
|
+
if (errors instanceof Array) {
|
|
181
|
+
return errors
|
|
182
|
+
.map(function (e) {
|
|
183
|
+
if (typeof e === 'object') {
|
|
184
|
+
return "\"".concat(e.instancePath, "\" ").concat(e.message);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
return e;
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
.join(', ');
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
return errors;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
var InvalidDataError = /** @class */ (function (_super) {
|
|
197
|
+
__extends(InvalidDataError, _super);
|
|
198
|
+
function InvalidDataError(message, errors) {
|
|
199
|
+
var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
|
|
200
|
+
_this.name = 'InvalidDataError';
|
|
201
|
+
_this.errors = errors;
|
|
202
|
+
return _this;
|
|
203
|
+
}
|
|
204
|
+
return InvalidDataError;
|
|
205
|
+
}(Error));
|
|
206
|
+
function validateDocId(prefix, docId) {
|
|
207
|
+
if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {
|
|
208
|
+
throw new Error('Invalid document ID');
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
|
|
132
213
|
var TRASH_BOOK_ID = 'trash';
|
|
133
214
|
var NOTE_STATUS = {
|
|
134
215
|
NONE: 'none',
|
|
@@ -143,6 +224,9 @@ var NOTE_VISIBILITY = {
|
|
|
143
224
|
};
|
|
144
225
|
var validateNote = validator;
|
|
145
226
|
var NOTE_TITLE_MAX_LENGTH = 256;
|
|
227
|
+
function validateNoteId(docId) {
|
|
228
|
+
return validateDocId('note:', docId);
|
|
229
|
+
}
|
|
146
230
|
|
|
147
231
|
var $schema$2 = "http://json-schema.org/draft-07/schema#";
|
|
148
232
|
var $id$2 = "book";
|
|
@@ -250,6 +334,9 @@ var book = {
|
|
|
250
334
|
};
|
|
251
335
|
|
|
252
336
|
var validateBook = validator$1;
|
|
337
|
+
function validateBookId(docId) {
|
|
338
|
+
return validateDocId('book:', docId);
|
|
339
|
+
}
|
|
253
340
|
|
|
254
341
|
var $schema$1 = "http://json-schema.org/draft-07/schema#";
|
|
255
342
|
var $id$1 = "tag";
|
|
@@ -340,53 +427,9 @@ var TAG_COLOR = {
|
|
|
340
427
|
BLACK: 'black'
|
|
341
428
|
};
|
|
342
429
|
var validateTag = validator$2;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
348
|
-
purpose with or without fee is hereby granted.
|
|
349
|
-
|
|
350
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
351
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
352
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
353
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
354
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
355
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
356
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
357
|
-
***************************************************************************** */
|
|
358
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
359
|
-
|
|
360
|
-
var extendStatics = function(d, b) {
|
|
361
|
-
extendStatics = Object.setPrototypeOf ||
|
|
362
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
363
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
364
|
-
return extendStatics(d, b);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
function __extends(d, b) {
|
|
368
|
-
if (typeof b !== "function" && b !== null)
|
|
369
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
370
|
-
extendStatics(d, b);
|
|
371
|
-
function __() { this.constructor = d; }
|
|
372
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var __assign = function() {
|
|
376
|
-
__assign = Object.assign || function __assign(t) {
|
|
377
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
378
|
-
s = arguments[i];
|
|
379
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
380
|
-
}
|
|
381
|
-
return t;
|
|
382
|
-
};
|
|
383
|
-
return __assign.apply(this, arguments);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
387
|
-
var e = new Error(message);
|
|
388
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
389
|
-
};
|
|
430
|
+
function validateTagId(docId) {
|
|
431
|
+
return validateDocId('tag:', docId);
|
|
432
|
+
}
|
|
390
433
|
|
|
391
434
|
var $schema = "http://json-schema.org/draft-07/schema#";
|
|
392
435
|
var $id = "file";
|
|
@@ -516,34 +559,9 @@ var SUPPORTED_IMAGE_MIME_TYPES = __assign(__assign({}, supportedImageFileTypes.r
|
|
|
516
559
|
}, {})), { jpg: 'image/jpeg' });
|
|
517
560
|
var maxAttachmentFileSize = 10 * 1024 * 1024;
|
|
518
561
|
var validateFile = validator$3;
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (errors instanceof Array) {
|
|
522
|
-
return errors
|
|
523
|
-
.map(function (e) {
|
|
524
|
-
if (typeof e === 'object') {
|
|
525
|
-
return "\"".concat(e.instancePath, "\" ").concat(e.message);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
return e;
|
|
529
|
-
}
|
|
530
|
-
})
|
|
531
|
-
.join(', ');
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
return errors;
|
|
535
|
-
}
|
|
562
|
+
function validateFileId(docId) {
|
|
563
|
+
return validateDocId('file:', docId);
|
|
536
564
|
}
|
|
537
|
-
var InvalidDataError = /** @class */ (function (_super) {
|
|
538
|
-
__extends(InvalidDataError, _super);
|
|
539
|
-
function InvalidDataError(message, errors) {
|
|
540
|
-
var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
|
|
541
|
-
_this.name = 'InvalidDataError';
|
|
542
|
-
_this.errors = errors;
|
|
543
|
-
return _this;
|
|
544
|
-
}
|
|
545
|
-
return InvalidDataError;
|
|
546
|
-
}(Error));
|
|
547
565
|
|
|
548
|
-
export { book as BookSchema, file as FileSchema, InvalidDataError, NOTE_STATUS, NOTE_TITLE_MAX_LENGTH, NOTE_VISIBILITY, note as NoteSchema, SUPPORTED_IMAGE_MIME_TYPES, TAG_COLOR, TRASH_BOOK_ID, tag as TagSchema, maxAttachmentFileSize, supportedImageFileTypes, validateBook, validateFile, validateNote, validateTag, validationErrorsToMessage };
|
|
566
|
+
export { book as BookSchema, file as FileSchema, InvalidDataError, NOTE_STATUS, NOTE_TITLE_MAX_LENGTH, NOTE_VISIBILITY, note as NoteSchema, SUPPORTED_IMAGE_MIME_TYPES, TAG_COLOR, TRASH_BOOK_ID, tag as TagSchema, maxAttachmentFileSize, supportedImageFileTypes, validateBook, validateBookId, validateDocId, validateFile, validateFileId, validateNote, validateNoteId, validateTag, validateTagId, validationErrorsToMessage };
|
|
549
567
|
//# sourceMappingURL=index.esm.js.map
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/validator.ts","../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts"],"sourcesContent":["import type { ErrorObject } from 'ajv'\n\nexport function validationErrorsToMessage(errors: ErrorObject[]): string {\n if (errors instanceof Array) {\n return errors\n .map(e => {\n if (typeof e === 'object') {\n return `\"${e.instancePath}\" ${e.message}`\n } else {\n return e\n }\n })\n .join(', ')\n } else {\n return errors\n }\n}\nexport class InvalidDataError extends Error {\n name = 'InvalidDataError'\n errors: ErrorObject[]\n\n constructor(message: string, errors: ErrorObject[]) {\n super(message + ' ' + validationErrorsToMessage(errors))\n this.errors = errors\n }\n}\n\nexport function validateDocId(prefix: string, docId: string): boolean {\n if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {\n throw new Error('Invalid document ID')\n }\n return true\n}\n","import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\nimport { validateDocId } from './validator'\nexport type TrashBookId = 'trash'\nexport type NoteStatus = 'none' | 'active' | 'onHold' | 'completed' | 'dropped'\nexport type NoteVisibility = 'private' | 'public'\nexport type NoteMetadata = {\n _id: string\n _rev?: string\n bookId: string\n doctype: string\n updatedAt: number\n createdAt: number\n tags?: string[]\n numOfTasks?: number\n numOfCheckedTasks?: number\n migratedBy?: string\n status?: NoteStatus\n share?: NoteVisibility\n pinned?: boolean\n timestamp: number\n _conflicts?: string[]\n}\nexport type Note = NoteMetadata & {\n title: string\n body: string\n}\nexport type EncryptedNote = NoteMetadata & {\n encryptedData: EncryptedData\n}\nexport const TRASH_BOOK_ID = 'trash'\n\nexport const NOTE_STATUS: Readonly<{\n NONE: 'none'\n ACTIVE: 'active'\n ON_HOLD: 'onHold'\n COMPLETED: 'completed'\n DROPPED: 'dropped'\n}> = {\n NONE: 'none',\n ACTIVE: 'active',\n ON_HOLD: 'onHold',\n COMPLETED: 'completed',\n DROPPED: 'dropped'\n}\nexport const NOTE_VISIBILITY: Readonly<{\n PRIVATE: 'private'\n PUBLIC: 'public'\n}> = {\n PRIVATE: 'private',\n PUBLIC: 'public'\n}\nconst validateNote: ValidateFunction<Note> = validator as any\nexport { NoteSchema, validateNote }\n\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\n\nexport function validateNoteId(docId: string): boolean {\n return validateDocId('note:', docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\nimport { validateDocId } from './validator'\n\nexport type BookIconInline = {\n type: 'inline'\n svg: string\n}\nexport type BookIconFile = {\n type: 'file'\n docId: string\n}\nexport type BookIcon = BookIconInline | BookIconFile\n\nexport type BookMetadata = {\n _id: string\n _rev?: string\n updatedAt: number\n createdAt: number\n count?: number\n parentBookId?: null | string\n migratedBy?: string\n icon?: BookIcon\n order?: number\n}\nexport type Book = BookMetadata & {\n name: string\n}\nexport type EncryptedBook = BookMetadata & {\n encryptedData: EncryptedData\n}\n\nconst validateBook: ValidateFunction<Book> = validator as any\nexport { BookSchema, validateBook }\n\nexport function validateBookId(docId: string): boolean {\n return validateDocId('book:', docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\nimport { validateDocId } from './validator'\nexport type TagColor =\n | 'default'\n | 'red'\n | 'orange'\n | 'yellow'\n | 'olive'\n | 'green'\n | 'teal'\n | 'blue'\n | 'violet'\n | 'purple'\n | 'pink'\n | 'brown'\n | 'grey'\n | 'black'\nexport const TAG_COLOR: Readonly<{\n DEFAULT: 'default'\n RED: 'red'\n ORANGE: 'orange'\n YELLOW: 'yellow'\n OLIVE: 'olive'\n GREEN: 'green'\n TEAL: 'teal'\n BLUE: 'blue'\n VIOLET: 'violet'\n PURPLE: 'purple'\n PINK: 'pink'\n BROWN: 'brown'\n GREY: 'grey'\n BLACK: 'black'\n}> = {\n DEFAULT: 'default',\n RED: 'red',\n ORANGE: 'orange',\n YELLOW: 'yellow',\n OLIVE: 'olive',\n GREEN: 'green',\n TEAL: 'teal',\n BLUE: 'blue',\n VIOLET: 'violet',\n PURPLE: 'purple',\n PINK: 'pink',\n BROWN: 'brown',\n GREY: 'grey',\n BLACK: 'black'\n}\nexport type TagMetadata = {\n _id: string\n _rev?: string\n count?: number\n color: TagColor\n updatedAt: number\n createdAt: number\n}\nexport type Tag = TagMetadata & {\n name: string\n}\nexport type EncryptedTag = TagMetadata & {\n encryptedData: EncryptedData\n}\nconst validateTag: ValidateFunction<Tag> = validator as any\nexport { TagSchema, validateTag }\n\nexport function validateTagId(docId: string): boolean {\n return validateDocId('tag:', docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\nimport { validateDocId } from './validator'\nexport type ImageFileType =\n | 'image/png'\n | 'image/jpeg'\n | 'image/jpg'\n | 'image/svg+xml'\n | 'image/gif'\n | 'image/heic'\n | 'image/heif'\nexport const supportedImageFileTypes: ReadonlyArray<ImageFileType> = [\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/svg+xml',\n 'image/gif',\n 'image/heic',\n 'image/heif'\n]\nexport const SUPPORTED_IMAGE_MIME_TYPES: {\n readonly [mime: string]: ImageFileType\n} = {\n ...supportedImageFileTypes.reduce(\n (hash, ft) => ({ ...hash, [ft.split('/')[1]]: ft }),\n {} as Record<string, ImageFileType>\n ),\n jpg: 'image/jpeg'\n}\nexport const maxAttachmentFileSize: number = 10 * 1024 * 1024\nexport type FileAttachmentItem = {\n digest?: string\n content_type: ImageFileType\n data: Buffer | string\n length?: number\n}\nexport type File = {\n _id: string\n _rev?: string\n name: string\n createdAt: number\n contentType: ImageFileType\n contentLength: number\n publicIn: string[]\n _attachments: {\n index: FileAttachmentItem\n }\n md5digest?: string\n}\nexport type EncryptedFile = File & {\n encryptionData: EncryptionMetadata\n}\nconst validateFile: ValidateFunction<File> = validator as any\nexport { FileSchema, validateFile }\n\nexport function validateFileId(docId: string): boolean {\n return validateDocId('file:', docId)\n}\n"],"names":["validator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEM,SAAU,yBAAyB,CAAC,MAAqB,EAAA;AAC7D,IAAA,IAAI,MAAM,YAAY,KAAK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;;;;;;;;;;;;;ACzDO,IAAM,uBAAuB,GAAiC;IACnE,WAAW;IACX,YAAY;IACZ,WAAW;IACX,eAAe;IACf,WAAW;IACX,YAAY;IACZ;;AAEK,IAAM,0BAA0B,GAAA,QAAA,CAAA,QAAA,CAAA,EAAA,EAGlC,uBAAuB,CAAC,MAAM,CAC/B,UAAC,IAAI,EAAE,EAAE,EAAA;;AAAK,IAAA,QAAA,QAAA,CAAA,QAAA,CAAA,EAAA,EAAM,IAAI,CAAA,GAAA,EAAA,GAAA,EAAA,EAAA,EAAA,CAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA,GAAG,EAAE,EAAA,EAAA,EAAA;AAAlC,CAAqC,EACnD,EAAmC,CACpC,CAAA,EAAA,EACD,GAAG,EAAE,YAAY;IAEN,qBAAqB,GAAW,EAAE,GAAG,IAAI,GAAG;AAuBzD,IAAM,YAAY,GAA2BA;AAGvC,SAAU,cAAc,CAAC,KAAa,EAAA;AAC1C,IAAA,OAAO,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AACtC;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -131,6 +131,87 @@ var note = {
|
|
|
131
131
|
required: required$3
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
/******************************************************************************
|
|
135
|
+
Copyright (c) Microsoft Corporation.
|
|
136
|
+
|
|
137
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
138
|
+
purpose with or without fee is hereby granted.
|
|
139
|
+
|
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
141
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
142
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
143
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
144
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
145
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
146
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
147
|
+
***************************************************************************** */
|
|
148
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
149
|
+
|
|
150
|
+
var extendStatics = function(d, b) {
|
|
151
|
+
extendStatics = Object.setPrototypeOf ||
|
|
152
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
153
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
154
|
+
return extendStatics(d, b);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
function __extends(d, b) {
|
|
158
|
+
if (typeof b !== "function" && b !== null)
|
|
159
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
160
|
+
extendStatics(d, b);
|
|
161
|
+
function __() { this.constructor = d; }
|
|
162
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var __assign = function() {
|
|
166
|
+
__assign = Object.assign || function __assign(t) {
|
|
167
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
168
|
+
s = arguments[i];
|
|
169
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
170
|
+
}
|
|
171
|
+
return t;
|
|
172
|
+
};
|
|
173
|
+
return __assign.apply(this, arguments);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
177
|
+
var e = new Error(message);
|
|
178
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
function validationErrorsToMessage(errors) {
|
|
182
|
+
if (errors instanceof Array) {
|
|
183
|
+
return errors
|
|
184
|
+
.map(function (e) {
|
|
185
|
+
if (typeof e === 'object') {
|
|
186
|
+
return "\"".concat(e.instancePath, "\" ").concat(e.message);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
return e;
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
.join(', ');
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
return errors;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
var InvalidDataError = /** @class */ (function (_super) {
|
|
199
|
+
__extends(InvalidDataError, _super);
|
|
200
|
+
function InvalidDataError(message, errors) {
|
|
201
|
+
var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
|
|
202
|
+
_this.name = 'InvalidDataError';
|
|
203
|
+
_this.errors = errors;
|
|
204
|
+
return _this;
|
|
205
|
+
}
|
|
206
|
+
return InvalidDataError;
|
|
207
|
+
}(Error));
|
|
208
|
+
function validateDocId(prefix, docId) {
|
|
209
|
+
if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {
|
|
210
|
+
throw new Error('Invalid document ID');
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
|
|
134
215
|
var TRASH_BOOK_ID = 'trash';
|
|
135
216
|
var NOTE_STATUS = {
|
|
136
217
|
NONE: 'none',
|
|
@@ -145,6 +226,9 @@ var NOTE_VISIBILITY = {
|
|
|
145
226
|
};
|
|
146
227
|
var validateNote = validator;
|
|
147
228
|
var NOTE_TITLE_MAX_LENGTH = 256;
|
|
229
|
+
function validateNoteId(docId) {
|
|
230
|
+
return validateDocId('note:', docId);
|
|
231
|
+
}
|
|
148
232
|
|
|
149
233
|
var $schema$2 = "http://json-schema.org/draft-07/schema#";
|
|
150
234
|
var $id$2 = "book";
|
|
@@ -252,6 +336,9 @@ var book = {
|
|
|
252
336
|
};
|
|
253
337
|
|
|
254
338
|
var validateBook = validator$1;
|
|
339
|
+
function validateBookId(docId) {
|
|
340
|
+
return validateDocId('book:', docId);
|
|
341
|
+
}
|
|
255
342
|
|
|
256
343
|
var $schema$1 = "http://json-schema.org/draft-07/schema#";
|
|
257
344
|
var $id$1 = "tag";
|
|
@@ -342,53 +429,9 @@ var TAG_COLOR = {
|
|
|
342
429
|
BLACK: 'black'
|
|
343
430
|
};
|
|
344
431
|
var validateTag = validator$2;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
350
|
-
purpose with or without fee is hereby granted.
|
|
351
|
-
|
|
352
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
353
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
354
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
355
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
356
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
357
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
358
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
359
|
-
***************************************************************************** */
|
|
360
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
361
|
-
|
|
362
|
-
var extendStatics = function(d, b) {
|
|
363
|
-
extendStatics = Object.setPrototypeOf ||
|
|
364
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
365
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
366
|
-
return extendStatics(d, b);
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
function __extends(d, b) {
|
|
370
|
-
if (typeof b !== "function" && b !== null)
|
|
371
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
372
|
-
extendStatics(d, b);
|
|
373
|
-
function __() { this.constructor = d; }
|
|
374
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
var __assign = function() {
|
|
378
|
-
__assign = Object.assign || function __assign(t) {
|
|
379
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
380
|
-
s = arguments[i];
|
|
381
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
382
|
-
}
|
|
383
|
-
return t;
|
|
384
|
-
};
|
|
385
|
-
return __assign.apply(this, arguments);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
389
|
-
var e = new Error(message);
|
|
390
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
391
|
-
};
|
|
432
|
+
function validateTagId(docId) {
|
|
433
|
+
return validateDocId('tag:', docId);
|
|
434
|
+
}
|
|
392
435
|
|
|
393
436
|
var $schema = "http://json-schema.org/draft-07/schema#";
|
|
394
437
|
var $id = "file";
|
|
@@ -518,34 +561,9 @@ var SUPPORTED_IMAGE_MIME_TYPES = __assign(__assign({}, supportedImageFileTypes.r
|
|
|
518
561
|
}, {})), { jpg: 'image/jpeg' });
|
|
519
562
|
var maxAttachmentFileSize = 10 * 1024 * 1024;
|
|
520
563
|
var validateFile = validator$3;
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
if (errors instanceof Array) {
|
|
524
|
-
return errors
|
|
525
|
-
.map(function (e) {
|
|
526
|
-
if (typeof e === 'object') {
|
|
527
|
-
return "\"".concat(e.instancePath, "\" ").concat(e.message);
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
return e;
|
|
531
|
-
}
|
|
532
|
-
})
|
|
533
|
-
.join(', ');
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
return errors;
|
|
537
|
-
}
|
|
564
|
+
function validateFileId(docId) {
|
|
565
|
+
return validateDocId('file:', docId);
|
|
538
566
|
}
|
|
539
|
-
var InvalidDataError = /** @class */ (function (_super) {
|
|
540
|
-
__extends(InvalidDataError, _super);
|
|
541
|
-
function InvalidDataError(message, errors) {
|
|
542
|
-
var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
|
|
543
|
-
_this.name = 'InvalidDataError';
|
|
544
|
-
_this.errors = errors;
|
|
545
|
-
return _this;
|
|
546
|
-
}
|
|
547
|
-
return InvalidDataError;
|
|
548
|
-
}(Error));
|
|
549
567
|
|
|
550
568
|
exports.BookSchema = book;
|
|
551
569
|
exports.FileSchema = file;
|
|
@@ -561,8 +579,13 @@ exports.TagSchema = tag;
|
|
|
561
579
|
exports.maxAttachmentFileSize = maxAttachmentFileSize;
|
|
562
580
|
exports.supportedImageFileTypes = supportedImageFileTypes;
|
|
563
581
|
exports.validateBook = validateBook;
|
|
582
|
+
exports.validateBookId = validateBookId;
|
|
583
|
+
exports.validateDocId = validateDocId;
|
|
564
584
|
exports.validateFile = validateFile;
|
|
585
|
+
exports.validateFileId = validateFileId;
|
|
565
586
|
exports.validateNote = validateNote;
|
|
587
|
+
exports.validateNoteId = validateNoteId;
|
|
566
588
|
exports.validateTag = validateTag;
|
|
589
|
+
exports.validateTagId = validateTagId;
|
|
567
590
|
exports.validationErrorsToMessage = validationErrorsToMessage;
|
|
568
591
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/validator.ts","../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts"],"sourcesContent":["import type { ErrorObject } from 'ajv'\n\nexport function validationErrorsToMessage(errors: ErrorObject[]): string {\n if (errors instanceof Array) {\n return errors\n .map(e => {\n if (typeof e === 'object') {\n return `\"${e.instancePath}\" ${e.message}`\n } else {\n return e\n }\n })\n .join(', ')\n } else {\n return errors\n }\n}\nexport class InvalidDataError extends Error {\n name = 'InvalidDataError'\n errors: ErrorObject[]\n\n constructor(message: string, errors: ErrorObject[]) {\n super(message + ' ' + validationErrorsToMessage(errors))\n this.errors = errors\n }\n}\n\nexport function validateDocId(prefix: string, docId: string): boolean {\n if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {\n throw new Error('Invalid document ID')\n }\n return true\n}\n","import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\nimport { validateDocId } from './validator'\nexport type TrashBookId = 'trash'\nexport type NoteStatus = 'none' | 'active' | 'onHold' | 'completed' | 'dropped'\nexport type NoteVisibility = 'private' | 'public'\nexport type NoteMetadata = {\n _id: string\n _rev?: string\n bookId: string\n doctype: string\n updatedAt: number\n createdAt: number\n tags?: string[]\n numOfTasks?: number\n numOfCheckedTasks?: number\n migratedBy?: string\n status?: NoteStatus\n share?: NoteVisibility\n pinned?: boolean\n timestamp: number\n _conflicts?: string[]\n}\nexport type Note = NoteMetadata & {\n title: string\n body: string\n}\nexport type EncryptedNote = NoteMetadata & {\n encryptedData: EncryptedData\n}\nexport const TRASH_BOOK_ID = 'trash'\n\nexport const NOTE_STATUS: Readonly<{\n NONE: 'none'\n ACTIVE: 'active'\n ON_HOLD: 'onHold'\n COMPLETED: 'completed'\n DROPPED: 'dropped'\n}> = {\n NONE: 'none',\n ACTIVE: 'active',\n ON_HOLD: 'onHold',\n COMPLETED: 'completed',\n DROPPED: 'dropped'\n}\nexport const NOTE_VISIBILITY: Readonly<{\n PRIVATE: 'private'\n PUBLIC: 'public'\n}> = {\n PRIVATE: 'private',\n PUBLIC: 'public'\n}\nconst validateNote: ValidateFunction<Note> = validator as any\nexport { NoteSchema, validateNote }\n\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\n\nexport function validateNoteId(docId: string): boolean {\n return validateDocId('note:', docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\nimport { validateDocId } from './validator'\n\nexport type BookIconInline = {\n type: 'inline'\n svg: string\n}\nexport type BookIconFile = {\n type: 'file'\n docId: string\n}\nexport type BookIcon = BookIconInline | BookIconFile\n\nexport type BookMetadata = {\n _id: string\n _rev?: string\n updatedAt: number\n createdAt: number\n count?: number\n parentBookId?: null | string\n migratedBy?: string\n icon?: BookIcon\n order?: number\n}\nexport type Book = BookMetadata & {\n name: string\n}\nexport type EncryptedBook = BookMetadata & {\n encryptedData: EncryptedData\n}\n\nconst validateBook: ValidateFunction<Book> = validator as any\nexport { BookSchema, validateBook }\n\nexport function validateBookId(docId: string): boolean {\n return validateDocId('book:', docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\nimport { validateDocId } from './validator'\nexport type TagColor =\n | 'default'\n | 'red'\n | 'orange'\n | 'yellow'\n | 'olive'\n | 'green'\n | 'teal'\n | 'blue'\n | 'violet'\n | 'purple'\n | 'pink'\n | 'brown'\n | 'grey'\n | 'black'\nexport const TAG_COLOR: Readonly<{\n DEFAULT: 'default'\n RED: 'red'\n ORANGE: 'orange'\n YELLOW: 'yellow'\n OLIVE: 'olive'\n GREEN: 'green'\n TEAL: 'teal'\n BLUE: 'blue'\n VIOLET: 'violet'\n PURPLE: 'purple'\n PINK: 'pink'\n BROWN: 'brown'\n GREY: 'grey'\n BLACK: 'black'\n}> = {\n DEFAULT: 'default',\n RED: 'red',\n ORANGE: 'orange',\n YELLOW: 'yellow',\n OLIVE: 'olive',\n GREEN: 'green',\n TEAL: 'teal',\n BLUE: 'blue',\n VIOLET: 'violet',\n PURPLE: 'purple',\n PINK: 'pink',\n BROWN: 'brown',\n GREY: 'grey',\n BLACK: 'black'\n}\nexport type TagMetadata = {\n _id: string\n _rev?: string\n count?: number\n color: TagColor\n updatedAt: number\n createdAt: number\n}\nexport type Tag = TagMetadata & {\n name: string\n}\nexport type EncryptedTag = TagMetadata & {\n encryptedData: EncryptedData\n}\nconst validateTag: ValidateFunction<Tag> = validator as any\nexport { TagSchema, validateTag }\n\nexport function validateTagId(docId: string): boolean {\n return validateDocId('tag:', docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\nimport { validateDocId } from './validator'\nexport type ImageFileType =\n | 'image/png'\n | 'image/jpeg'\n | 'image/jpg'\n | 'image/svg+xml'\n | 'image/gif'\n | 'image/heic'\n | 'image/heif'\nexport const supportedImageFileTypes: ReadonlyArray<ImageFileType> = [\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/svg+xml',\n 'image/gif',\n 'image/heic',\n 'image/heif'\n]\nexport const SUPPORTED_IMAGE_MIME_TYPES: {\n readonly [mime: string]: ImageFileType\n} = {\n ...supportedImageFileTypes.reduce(\n (hash, ft) => ({ ...hash, [ft.split('/')[1]]: ft }),\n {} as Record<string, ImageFileType>\n ),\n jpg: 'image/jpeg'\n}\nexport const maxAttachmentFileSize: number = 10 * 1024 * 1024\nexport type FileAttachmentItem = {\n digest?: string\n content_type: ImageFileType\n data: Buffer | string\n length?: number\n}\nexport type File = {\n _id: string\n _rev?: string\n name: string\n createdAt: number\n contentType: ImageFileType\n contentLength: number\n publicIn: string[]\n _attachments: {\n index: FileAttachmentItem\n }\n md5digest?: string\n}\nexport type EncryptedFile = File & {\n encryptionData: EncryptionMetadata\n}\nconst validateFile: ValidateFunction<File> = validator as any\nexport { FileSchema, validateFile }\n\nexport function validateFileId(docId: string): boolean {\n return validateDocId('file:', docId)\n}\n"],"names":["validator"],"mappings":";;;;;;;;;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AE,MAAM;AACZ,IAAA,KAAK,EAAE;;AAgBT,IAAM,WAAW,GAA0BA;AAGrC,SAAU,aAAa,CAAC,KAAa,EAAA;AACzC,IAAA,OAAO,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzDO,IAAM,uBAAuB,GAAiC;IACnE,WAAW;IACX,YAAY;IACZ,WAAW;IACX,eAAe;IACf,WAAW;IACX,YAAY;IACZ;;AAEK,IAAM,0BAA0B,GAAA,QAAA,CAAA,QAAA,CAAA,EAAA,EAGlC,uBAAuB,CAAC,MAAM,CAC/B,UAAC,IAAI,EAAE,EAAE,EAAA;;AAAK,IAAA,QAAA,QAAA,CAAA,QAAA,CAAA,EAAA,EAAM,IAAI,CAAA,GAAA,EAAA,GAAA,EAAA,EAAA,EAAA,CAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA,GAAG,EAAE,EAAA,EAAA,EAAA;AAAlC,CAAqC,EACnD,EAAmC,CACpC,CAAA,EAAA,EACD,GAAG,EAAE,YAAY;IAEN,qBAAqB,GAAW,EAAE,GAAG,IAAI,GAAG;AAuBzD,IAAM,YAAY,GAA2BA;AAGvC,SAAU,cAAc,CAAC,KAAa,EAAA;AAC1C,IAAA,OAAO,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../validators/note"),require("../validators/book"),require("../validators/tag"),require("../validators/file")):"function"==typeof define&&define.amd?define(["exports","../validators/note","../validators/book","../validators/tag","../validators/file"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).InkdropModel={},e.validator,e.validator$1,e.validator$2,e.validator$3)}(this,function(e,t,i,n,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../validators/note"),require("../validators/book"),require("../validators/tag"),require("../validators/file")):"function"==typeof define&&define.amd?define(["exports","../validators/note","../validators/book","../validators/tag","../validators/file"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).InkdropModel={},e.validator,e.validator$1,e.validator$2,e.validator$3)}(this,function(e,t,i,n,r){"use strict";var o={$schema:"http://json-schema.org/draft-07/schema#",$id:"note",title:"Note",description:"A note data",type:"object",properties:{_id:{description:"The unique document ID which should start with `note:` and the remains are randomly generated string",type:"string",minLength:6,maxLength:128,pattern:"^note:"},_rev:{description:"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",type:"string"},bookId:{description:"The notebook ID",type:"string",minLength:5,maxLength:128,pattern:"^(book:|trash$)"},title:{description:"The note title",type:"string",maxLength:256},doctype:{description:"The format type of the body field. It currently can take markdown only, reserved for the future",type:"string",enum:["markdown"]},body:{description:"The content of the note represented with Markdown",type:"string",maxLength:1048576},updatedAt:{description:"The date time when the note was last updated, represented with Unix timestamps in milliseconds",type:"number"},createdAt:{description:"The date time when the note was created, represented with Unix timestamps in milliseconds",type:"number"},tags:{description:"The list of tag IDs",type:"array",items:{type:"string"},uniqueItems:!0},numOfTasks:{description:"The number of tasks, extracted from body",type:"number"},numOfCheckedTasks:{description:"The number of checked tasks, extracted from body",type:"number"},migratedBy:{description:"The type of the data migration",type:"string",maxLength:128},status:{description:"The status of the note",type:"string",enum:["none","active","onHold","completed","dropped"]},share:{description:"The sharing mode of the note",type:"string",enum:["private","public"]},pinned:{description:"Whether the note is pinned to top",type:"boolean"},timestamp:{description:"The date time when the revision was written, represented with Unix timestamps in milliseconds",type:"number"},_conflicts:{description:"Conflicted revisions",type:"array",items:{type:"string"},uniqueItems:!0}},required:["_id","bookId","title","doctype","body","updatedAt","createdAt","timestamp"]},a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},a(e,t)};var s=function(){return s=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};function d(e){return e instanceof Array?e.map(function(e){return"object"==typeof e?'"'.concat(e.instancePath,'" ').concat(e.message):e}).join(", "):e}"function"==typeof SuppressedError&&SuppressedError;var p=function(e){function t(t,i){var n=e.call(this,t+" "+d(i))||this;return n.name="InvalidDataError",n.errors=i,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t}(Error);function c(e,t){if(!t.startsWith(e)||t.length<=5||t.length>128)throw new Error("Invalid document ID");return!0}var h=t;var m={$schema:"http://json-schema.org/draft-07/schema#",$id:"book",title:"Book",description:"A notebook data",type:"object",properties:{_id:{description:"The unique notebook ID which should start with `book:` and the remains are randomly generated string",type:"string",minLength:6,maxLength:128,pattern:"^book:"},_rev:{description:"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",type:"string"},name:{description:"The notebook name",type:"string",minLength:1,maxLength:64},updatedAt:{description:"The date time when the notebook was last updated, represented with Unix timestamps in milliseconds",type:"number"},createdAt:{description:"The date time when the notebook was created, represented with Unix timestamps in milliseconds",type:"number"},count:{description:"It indicates the number of notes in the notebook",type:"number"},parentBookId:{description:"The ID of the parent notebook",type:["string","null"]},order:{description:"A number used to manually sort notebooks. Notebooks are ordered by this value in ascending order. If not specified, notebooks fall back to alphabetical sorting by name.",type:"number"},icon:{description:"Custom icon for the notebook",type:"object",oneOf:[{properties:{type:{description:"Icon storage type",const:"inline"},svg:{description:"The SVG icon data. Must be less than 256kb",type:"string",maxLength:262144}},required:["type","svg"]},{properties:{type:{description:"Icon storage type",const:"file"},docId:{description:"The document ID for the attachment file",type:"string",pattern:"^file:",minLength:6,maxLength:128}},required:["type","docId"]}]}},required:["_id","name","updatedAt","createdAt"]},l=i;var u={$schema:"http://json-schema.org/draft-07/schema#",$id:"tag",title:"Tag",description:"A note tag",type:"object",properties:{_id:{description:"The unique tag ID which should start with `tag:` and the remains are randomly generated string",type:"string",minLength:6,maxLength:128,pattern:"^tag:"},_rev:{description:"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",type:"string"},name:{description:"The name of the tag",type:"string",maxLength:64},count:{description:"It indicates the number of notes with the tag",type:"number"},color:{description:"The color type of the tag",type:"string",enum:["default","red","orange","yellow","olive","green","teal","blue","violet","purple","pink","brown","grey","black"]},updatedAt:{description:"The date time when the tag was last updated, represented with Unix timestamps in milliseconds",type:"number"},createdAt:{description:"The date time when the tag was created, represented with Unix timestamps in milliseconds",type:"number"}},required:["_id","name","count","updatedAt","createdAt"]},g=n;var f={$schema:"http://json-schema.org/draft-07/schema#",$id:"file",title:"File",description:"An attachment file",type:"object",properties:{_id:{description:"The unique document ID which should start with `file:` and the remains are randomly generated string",type:"string",minLength:6,maxLength:128,pattern:"^file:"},_rev:{description:"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",type:"string"},name:{description:"The file name",type:"string",minLength:1,maxLength:128},createdAt:{description:"The date time when the note was created, represented with Unix timestamps in milliseconds",type:"number"},contentType:{description:"The MIME type of the content",type:"string",enum:["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"],maxLength:128},contentLength:{description:"The content length of the file",type:"number",maximum:10485760},publicIn:{description:"An array of the note IDs where the file is included",type:"array",items:{type:"string"},uniqueItems:!0},_attachments:{description:"The attachment file",type:"object",properties:{index:{description:"The attachment file",type:"object",properties:{content_type:{description:"The content type of the file",type:"string",enum:["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"]},data:{description:"The file data",type:["string","object"]}},required:["content_type","data"]}},required:["index"]}},required:["_id","name","createdAt","contentType","contentLength","publicIn","_attachments"]},y=["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"],b=s(s({},y.reduce(function(e,t){var i;return s(s({},e),((i={})[t.split("/")[1]]=t,i))},{})),{jpg:"image/jpeg"}),T=r;e.BookSchema=m,e.FileSchema=f,e.InvalidDataError=p,e.NOTE_STATUS={NONE:"none",ACTIVE:"active",ON_HOLD:"onHold",COMPLETED:"completed",DROPPED:"dropped"},e.NOTE_TITLE_MAX_LENGTH=256,e.NOTE_VISIBILITY={PRIVATE:"private",PUBLIC:"public"},e.NoteSchema=o,e.SUPPORTED_IMAGE_MIME_TYPES=b,e.TAG_COLOR={DEFAULT:"default",RED:"red",ORANGE:"orange",YELLOW:"yellow",OLIVE:"olive",GREEN:"green",TEAL:"teal",BLUE:"blue",VIOLET:"violet",PURPLE:"purple",PINK:"pink",BROWN:"brown",GREY:"grey",BLACK:"black"},e.TRASH_BOOK_ID="trash",e.TagSchema=u,e.maxAttachmentFileSize=10485760,e.supportedImageFileTypes=y,e.validateBook=l,e.validateBookId=function(e){return c("book:",e)},e.validateDocId=c,e.validateFile=T,e.validateFileId=function(e){return c("file:",e)},e.validateNote=h,e.validateNoteId=function(e){return c("note:",e)},e.validateTag=g,e.validateTagId=function(e){return c("tag:",e)},e.validationErrorsToMessage=d});
|
package/lib/note.d.ts
CHANGED
package/lib/tag.d.ts
CHANGED
package/lib/validator.d.ts
CHANGED