inkdrop-model 2.8.0 → 2.9.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/json-schema/note.json +1 -1
- package/lib/crypto.d.ts +0 -1
- package/lib/file.d.ts +0 -1
- package/lib/index.esm.js +7 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +7 -2
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/package.json +14 -15
- package/validators/note.js +1 -1
package/json-schema/note.json
CHANGED
package/lib/crypto.d.ts
CHANGED
package/lib/file.d.ts
CHANGED
package/lib/index.esm.js
CHANGED
|
@@ -30,7 +30,7 @@ var properties$3 = {
|
|
|
30
30
|
title: {
|
|
31
31
|
description: "The note title",
|
|
32
32
|
type: "string",
|
|
33
|
-
maxLength:
|
|
33
|
+
maxLength: 256
|
|
34
34
|
},
|
|
35
35
|
doctype: {
|
|
36
36
|
description: "The format type of the body field. It currently can take markdown only, reserved for the future",
|
|
@@ -308,7 +308,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
308
308
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
309
309
|
PERFORMANCE OF THIS SOFTWARE.
|
|
310
310
|
***************************************************************************** */
|
|
311
|
-
/* global Reflect, Promise */
|
|
311
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
312
312
|
|
|
313
313
|
var extendStatics = function(d, b) {
|
|
314
314
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -334,6 +334,11 @@ var __assign = function() {
|
|
|
334
334
|
return t;
|
|
335
335
|
};
|
|
336
336
|
return __assign.apply(this, arguments);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
340
|
+
var e = new Error(message);
|
|
341
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
337
342
|
};
|
|
338
343
|
|
|
339
344
|
var $schema = "http://json-schema.org/draft-07/schema#";
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts","../src/validator.ts"],"sourcesContent":["import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\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}\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","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\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","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"],"names":["validator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,IAAM,aAAa,GAAG
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts","../src/validator.ts"],"sourcesContent":["import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\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}\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","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\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","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"],"names":["validator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,IAAM,aAAa,GAAG;AAEhB,IAAA,WAAW,GAMnB;AACH,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,OAAO,EAAE,QAAQ;AACjB,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,OAAO,EAAE;;AAEE,IAAA,eAAe,GAGvB;AACH,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE;;AAEJ,IAAA,YAAY,GAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChCvC,IAAA,YAAY,GAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACFhC,IAAA,SAAS,GAejB;AACH,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,KAAK,EAAE;;AAgBH,IAAA,WAAW,GAA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpD9B,IAAA,uBAAuB,GAAiC;IACnE,WAAW;IACX,YAAY;IACZ,WAAW;IACX,eAAe;IACf,WAAW;IACX,YAAY;IACZ;;AAEW,IAAA,0BAA0B,GAGlC,QAAA,CAAA,QAAA,CAAA,EAAA,EAAA,uBAAuB,CAAC,MAAM,CAC/B,UAAC,IAAI,EAAE,EAAE,EAAA;;AAAK,IAAA,QAAM,QAAA,CAAA,QAAA,CAAA,EAAA,EAAA,IAAI,CAAG,GAAA,EAAA,GAAA,EAAA,EAAA,EAAA,CAAA,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA,GAAG,EAAE,EAAG,EAAA,EAAA;AAArC,CAAqC,EACnD,EAAmC,CACpC,CAAA,EAAA,EACD,GAAG,EAAE,YAAY;IAEN,qBAAqB,GAAW,EAAE,GAAG,IAAI,GAAG;AAuBnD,IAAA,YAAY,GAA2BA;;ACnDvC,SAAU,yBAAyB,CAAC,MAAqB,EAAA;AAC7D,IAAA,IAAI,MAAM,YAAY,KAAK,EAAE;AAC3B,QAAA,OAAO;aACJ,GAAG,CAAC,UAAA,CAAC,EAAA;AACJ,YAAA,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;gBACzB,OAAO,IAAA,CAAA,MAAA,CAAI,CAAC,CAAC,YAAY,gBAAK,CAAC,CAAC,OAAO,CAAE;;iBACpC;AACL,gBAAA,OAAO,CAAC;;AAEZ,SAAC;aACA,IAAI,CAAC,IAAI,CAAC;;SACR;AACL,QAAA,OAAO,MAAM;;AAEjB;AACA,IAAA,gBAAA,kBAAA,UAAA,MAAA,EAAA;IAAsC,SAAK,CAAA,gBAAA,EAAA,MAAA,CAAA;IAIzC,SAAY,gBAAA,CAAA,OAAe,EAAE,MAAqB,EAAA;QAChD,IAAA,KAAA,GAAA,MAAK,CAAC,IAAA,CAAA,IAAA,EAAA,OAAO,GAAG,GAAG,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC,IAAA,IAAA;QAJ1D,KAAI,CAAA,IAAA,GAAG,kBAAkB;AAKvB,QAAA,KAAI,CAAC,MAAM,GAAG,MAAM;;;IAExB,OAAC,gBAAA;AAAD,CARA,CAAsC,KAAK,CAQ1C;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var properties$3 = {
|
|
|
32
32
|
title: {
|
|
33
33
|
description: "The note title",
|
|
34
34
|
type: "string",
|
|
35
|
-
maxLength:
|
|
35
|
+
maxLength: 256
|
|
36
36
|
},
|
|
37
37
|
doctype: {
|
|
38
38
|
description: "The format type of the body field. It currently can take markdown only, reserved for the future",
|
|
@@ -310,7 +310,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
310
310
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
311
311
|
PERFORMANCE OF THIS SOFTWARE.
|
|
312
312
|
***************************************************************************** */
|
|
313
|
-
/* global Reflect, Promise */
|
|
313
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
314
314
|
|
|
315
315
|
var extendStatics = function(d, b) {
|
|
316
316
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -336,6 +336,11 @@ var __assign = function() {
|
|
|
336
336
|
return t;
|
|
337
337
|
};
|
|
338
338
|
return __assign.apply(this, arguments);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
342
|
+
var e = new Error(message);
|
|
343
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
339
344
|
};
|
|
340
345
|
|
|
341
346
|
var $schema = "http://json-schema.org/draft-07/schema#";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts","../src/validator.ts"],"sourcesContent":["import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\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}\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","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\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","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"],"names":["validator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,IAAM,aAAa,GAAG
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts","../src/validator.ts"],"sourcesContent":["import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\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}\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","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\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","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\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","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"],"names":["validator"],"mappings":"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"}
|
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,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:
|
|
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=t,s={$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"]}},required:["_id","name","updatedAt","createdAt"]},d=i,p={$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"]},c=n,h=function(e,t){return h=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])},h(e,t)};var m=function(){return m=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},m.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var l={$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"]},u=["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"],g=m(m({},u.reduce((function(e,t){var i;return m(m({},e),((i={})[t.split("/")[1]]=t,i))}),{})),{jpg:"image/jpeg"}),y=r;function f(e){return e instanceof Array?e.map((function(e){return"object"==typeof e?'"'.concat(e.instancePath,'" ').concat(e.message):e})).join(", "):e}var b=function(e){function t(t,i){var n=e.call(this,t+" "+f(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}h(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t}(Error);e.BookSchema=s,e.FileSchema=l,e.InvalidDataError=b,e.NOTE_STATUS={NONE:"none",ACTIVE:"active",ON_HOLD:"onHold",COMPLETED:"completed",DROPPED:"dropped"},e.NOTE_VISIBILITY={PRIVATE:"private",PUBLIC:"public"},e.NoteSchema=o,e.SUPPORTED_IMAGE_MIME_TYPES=g,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=p,e.maxAttachmentFileSize=10485760,e.supportedImageFileTypes=u,e.validateBook=d,e.validateFile=y,e.validateNote=a,e.validateTag=c,e.validationErrorsToMessage=f}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inkdrop-model",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Data model for Inkdrop",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm-run-all build:schema build:lib doc",
|
|
@@ -18,22 +18,21 @@
|
|
|
18
18
|
"url": "https://github.com/inkdropapp/inkdrop-model.git"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@rollup/plugin-json": "^6.
|
|
22
|
-
"@rollup/plugin-terser": "^0.4.
|
|
23
|
-
"@types/jest": "^29.5.
|
|
24
|
-
"
|
|
25
|
-
"@typescript-eslint/parser": "^5.59.8",
|
|
26
|
-
"ajv": "^8.12.0",
|
|
21
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
22
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
23
|
+
"@types/jest": "^29.5.14",
|
|
24
|
+
"ajv": "^8.17.1",
|
|
27
25
|
"ajv-cli": "^5.0.0",
|
|
28
|
-
"eslint": "^
|
|
29
|
-
"eslint-config-prettier": "^
|
|
30
|
-
"jest": "^29.
|
|
26
|
+
"eslint": "^9.20.1",
|
|
27
|
+
"eslint-config-prettier": "^10.0.1",
|
|
28
|
+
"jest": "^29.7.0",
|
|
31
29
|
"npm-run-all": "^4.1.5",
|
|
32
|
-
"prettier": "^
|
|
33
|
-
"rollup": "^
|
|
34
|
-
"rollup-plugin-typescript2": "^0.
|
|
35
|
-
"ts-jest": "^29.
|
|
36
|
-
"typescript": "^5.
|
|
30
|
+
"prettier": "^3.5.0",
|
|
31
|
+
"rollup": "^4.34.6",
|
|
32
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
33
|
+
"ts-jest": "^29.2.5",
|
|
34
|
+
"typescript": "^5.7.3",
|
|
35
|
+
"typescript-eslint": "^8.24.0",
|
|
37
36
|
"yamljs": "^0.3.0"
|
|
38
37
|
},
|
|
39
38
|
"types": "lib/index.d.ts",
|
package/validators/note.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$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":128},"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":true},"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":true}},"required":["_id","bookId","title","doctype","body","updatedAt","createdAt","timestamp"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^note:", "u");const pattern1 = new RegExp("^(book:|trash$)", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="note" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((((((((data._id === undefined) && (missing0 = "_id")) || ((data.bookId === undefined) && (missing0 = "bookId"))) || ((data.title === undefined) && (missing0 = "title"))) || ((data.doctype === undefined) && (missing0 = "doctype"))) || ((data.body === undefined) && (missing0 = "body"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))) || ((data.timestamp === undefined) && (missing0 = "timestamp"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func4(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^note:"},message:"must match pattern \""+"^note:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.bookId !== undefined){let data2 = data.bookId;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 128){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data2) < 5){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/minLength",keyword:"minLength",params:{limit: 5},message:"must NOT have fewer than 5 characters"}];return false;}else {if(!pattern1.test(data2)){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/pattern",keyword:"pattern",params:{pattern: "^(book:|trash$)"},message:"must match pattern \""+"^(book:|trash$)"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.title !== undefined){let data3 = data.title;const _errs7 = errors;if(errors === _errs7){if(typeof data3 === "string"){if(func4(data3) > 128){validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.doctype !== undefined){let data4 = data.doctype;const _errs9 = errors;if(typeof data4 !== "string"){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(data4 === "markdown")){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/enum",keyword:"enum",params:{allowedValues: schema22.properties.doctype.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.body !== undefined){let data5 = data.body;const _errs11 = errors;if(errors === _errs11){if(typeof data5 === "string"){if(func4(data5) > 1048576){validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/maxLength",keyword:"maxLength",params:{limit: 1048576},message:"must NOT have more than 1048576 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data6 = data.updatedAt;const _errs13 = errors;if(!((typeof data6 == "number") && (isFinite(data6)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data7 = data.createdAt;const _errs15 = errors;if(!((typeof data7 == "number") && (isFinite(data7)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs15 === errors;}else {var valid0 = true;}if(valid0){if(data.tags !== undefined){let data8 = data.tags;const _errs17 = errors;if(errors === _errs17){if(Array.isArray(data8)){var valid1 = true;const len0 = data8.length;for(let i0=0; i0<len0; i0++){const _errs19 = errors;if(typeof data8[i0] !== "string"){validate20.errors = [{instancePath:instancePath+"/tags/" + i0,schemaPath:"#/properties/tags/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs19 === errors;if(!valid1){break;}}if(valid1){let i1 = data8.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data8[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}else {validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs17 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfTasks !== undefined){let data10 = data.numOfTasks;const _errs21 = errors;if(!((typeof data10 == "number") && (isFinite(data10)))){validate20.errors = [{instancePath:instancePath+"/numOfTasks",schemaPath:"#/properties/numOfTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs21 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfCheckedTasks !== undefined){let data11 = data.numOfCheckedTasks;const _errs23 = errors;if(!((typeof data11 == "number") && (isFinite(data11)))){validate20.errors = [{instancePath:instancePath+"/numOfCheckedTasks",schemaPath:"#/properties/numOfCheckedTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs23 === errors;}else {var valid0 = true;}if(valid0){if(data.migratedBy !== undefined){let data12 = data.migratedBy;const _errs25 = errors;if(errors === _errs25){if(typeof data12 === "string"){if(func4(data12) > 128){validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs25 === errors;}else {var valid0 = true;}if(valid0){if(data.status !== undefined){let data13 = data.status;const _errs27 = errors;if(typeof data13 !== "string"){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(((((data13 === "none") || (data13 === "active")) || (data13 === "onHold")) || (data13 === "completed")) || (data13 === "dropped"))){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema22.properties.status.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs27 === errors;}else {var valid0 = true;}if(valid0){if(data.share !== undefined){let data14 = data.share;const _errs29 = errors;if(typeof data14 !== "string"){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((data14 === "private") || (data14 === "public"))){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/enum",keyword:"enum",params:{allowedValues: schema22.properties.share.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs29 === errors;}else {var valid0 = true;}if(valid0){if(data.pinned !== undefined){const _errs31 = errors;if(typeof data.pinned !== "boolean"){validate20.errors = [{instancePath:instancePath+"/pinned",schemaPath:"#/properties/pinned/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs31 === errors;}else {var valid0 = true;}if(valid0){if(data.timestamp !== undefined){let data16 = data.timestamp;const _errs33 = errors;if(!((typeof data16 == "number") && (isFinite(data16)))){validate20.errors = [{instancePath:instancePath+"/timestamp",schemaPath:"#/properties/timestamp/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs33 === errors;}else {var valid0 = true;}if(valid0){if(data._conflicts !== undefined){let data17 = data._conflicts;const _errs35 = errors;if(errors === _errs35){if(Array.isArray(data17)){var valid3 = true;const len1 = data17.length;for(let i2=0; i2<len1; i2++){const _errs37 = errors;if(typeof data17[i2] !== "string"){validate20.errors = [{instancePath:instancePath+"/_conflicts/" + i2,schemaPath:"#/properties/_conflicts/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid3 = _errs37 === errors;if(!valid3){break;}}if(valid3){let i3 = data17.length;let j1;if(i3 > 1){const indices1 = {};for(;i3--;){let item1 = data17[i3];if(typeof item1 !== "string"){continue;}if(typeof indices1[item1] == "number"){j1 = indices1[item1];validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices1[item1] = i3;}}}}else {validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs35 === errors;}else {var valid0 = true;}}}}}}}}}}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
|
|
1
|
+
"use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$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":true},"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":true}},"required":["_id","bookId","title","doctype","body","updatedAt","createdAt","timestamp"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^note:", "u");const pattern1 = new RegExp("^(book:|trash$)", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="note" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((((((((data._id === undefined) && (missing0 = "_id")) || ((data.bookId === undefined) && (missing0 = "bookId"))) || ((data.title === undefined) && (missing0 = "title"))) || ((data.doctype === undefined) && (missing0 = "doctype"))) || ((data.body === undefined) && (missing0 = "body"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))) || ((data.timestamp === undefined) && (missing0 = "timestamp"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func4(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^note:"},message:"must match pattern \""+"^note:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.bookId !== undefined){let data2 = data.bookId;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 128){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data2) < 5){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/minLength",keyword:"minLength",params:{limit: 5},message:"must NOT have fewer than 5 characters"}];return false;}else {if(!pattern1.test(data2)){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/pattern",keyword:"pattern",params:{pattern: "^(book:|trash$)"},message:"must match pattern \""+"^(book:|trash$)"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.title !== undefined){let data3 = data.title;const _errs7 = errors;if(errors === _errs7){if(typeof data3 === "string"){if(func4(data3) > 256){validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/maxLength",keyword:"maxLength",params:{limit: 256},message:"must NOT have more than 256 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.doctype !== undefined){let data4 = data.doctype;const _errs9 = errors;if(typeof data4 !== "string"){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(data4 === "markdown")){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/enum",keyword:"enum",params:{allowedValues: schema22.properties.doctype.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.body !== undefined){let data5 = data.body;const _errs11 = errors;if(errors === _errs11){if(typeof data5 === "string"){if(func4(data5) > 1048576){validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/maxLength",keyword:"maxLength",params:{limit: 1048576},message:"must NOT have more than 1048576 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data6 = data.updatedAt;const _errs13 = errors;if(!((typeof data6 == "number") && (isFinite(data6)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data7 = data.createdAt;const _errs15 = errors;if(!((typeof data7 == "number") && (isFinite(data7)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs15 === errors;}else {var valid0 = true;}if(valid0){if(data.tags !== undefined){let data8 = data.tags;const _errs17 = errors;if(errors === _errs17){if(Array.isArray(data8)){var valid1 = true;const len0 = data8.length;for(let i0=0; i0<len0; i0++){const _errs19 = errors;if(typeof data8[i0] !== "string"){validate20.errors = [{instancePath:instancePath+"/tags/" + i0,schemaPath:"#/properties/tags/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs19 === errors;if(!valid1){break;}}if(valid1){let i1 = data8.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data8[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}else {validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs17 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfTasks !== undefined){let data10 = data.numOfTasks;const _errs21 = errors;if(!((typeof data10 == "number") && (isFinite(data10)))){validate20.errors = [{instancePath:instancePath+"/numOfTasks",schemaPath:"#/properties/numOfTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs21 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfCheckedTasks !== undefined){let data11 = data.numOfCheckedTasks;const _errs23 = errors;if(!((typeof data11 == "number") && (isFinite(data11)))){validate20.errors = [{instancePath:instancePath+"/numOfCheckedTasks",schemaPath:"#/properties/numOfCheckedTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs23 === errors;}else {var valid0 = true;}if(valid0){if(data.migratedBy !== undefined){let data12 = data.migratedBy;const _errs25 = errors;if(errors === _errs25){if(typeof data12 === "string"){if(func4(data12) > 128){validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs25 === errors;}else {var valid0 = true;}if(valid0){if(data.status !== undefined){let data13 = data.status;const _errs27 = errors;if(typeof data13 !== "string"){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(((((data13 === "none") || (data13 === "active")) || (data13 === "onHold")) || (data13 === "completed")) || (data13 === "dropped"))){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema22.properties.status.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs27 === errors;}else {var valid0 = true;}if(valid0){if(data.share !== undefined){let data14 = data.share;const _errs29 = errors;if(typeof data14 !== "string"){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((data14 === "private") || (data14 === "public"))){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/enum",keyword:"enum",params:{allowedValues: schema22.properties.share.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs29 === errors;}else {var valid0 = true;}if(valid0){if(data.pinned !== undefined){const _errs31 = errors;if(typeof data.pinned !== "boolean"){validate20.errors = [{instancePath:instancePath+"/pinned",schemaPath:"#/properties/pinned/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs31 === errors;}else {var valid0 = true;}if(valid0){if(data.timestamp !== undefined){let data16 = data.timestamp;const _errs33 = errors;if(!((typeof data16 == "number") && (isFinite(data16)))){validate20.errors = [{instancePath:instancePath+"/timestamp",schemaPath:"#/properties/timestamp/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs33 === errors;}else {var valid0 = true;}if(valid0){if(data._conflicts !== undefined){let data17 = data._conflicts;const _errs35 = errors;if(errors === _errs35){if(Array.isArray(data17)){var valid3 = true;const len1 = data17.length;for(let i2=0; i2<len1; i2++){const _errs37 = errors;if(typeof data17[i2] !== "string"){validate20.errors = [{instancePath:instancePath+"/_conflicts/" + i2,schemaPath:"#/properties/_conflicts/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid3 = _errs37 === errors;if(!valid3){break;}}if(valid3){let i3 = data17.length;let j1;if(i3 > 1){const indices1 = {};for(;i3--;){let item1 = data17[i3];if(typeof item1 !== "string"){continue;}if(typeof indices1[item1] == "number"){j1 = indices1[item1];validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices1[item1] = i3;}}}}else {validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs35 === errors;}else {var valid0 = true;}}}}}}}}}}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
|