inkdrop-model 2.9.1 → 2.10.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.
@@ -40,6 +40,48 @@
40
40
  "string",
41
41
  "null"
42
42
  ]
43
+ },
44
+ "icon": {
45
+ "description": "Custom icon for the notebook",
46
+ "type": "object",
47
+ "oneOf": [
48
+ {
49
+ "properties": {
50
+ "type": {
51
+ "description": "Icon storage type",
52
+ "const": "inline"
53
+ },
54
+ "svg": {
55
+ "description": "The SVG icon data. Must be less than 256kb",
56
+ "type": "string",
57
+ "maxLength": 262144
58
+ }
59
+ },
60
+ "required": [
61
+ "type",
62
+ "svg"
63
+ ]
64
+ },
65
+ {
66
+ "properties": {
67
+ "type": {
68
+ "description": "Icon storage type",
69
+ "const": "file"
70
+ },
71
+ "docId": {
72
+ "description": "The document ID for the attachment file",
73
+ "type": "string",
74
+ "pattern": "^file:",
75
+ "minLength": 6,
76
+ "maxLength": 128
77
+ }
78
+ },
79
+ "required": [
80
+ "type",
81
+ "docId"
82
+ ]
83
+ }
84
+ ]
43
85
  }
44
86
  },
45
87
  "required": [
package/lib/index.esm.js CHANGED
@@ -185,6 +185,48 @@ var properties$2 = {
185
185
  "string",
186
186
  "null"
187
187
  ]
188
+ },
189
+ icon: {
190
+ description: "Custom icon for the notebook",
191
+ type: "object",
192
+ oneOf: [
193
+ {
194
+ properties: {
195
+ type: {
196
+ description: "Icon storage type",
197
+ "const": "inline"
198
+ },
199
+ svg: {
200
+ description: "The SVG icon data. Must be less than 256kb",
201
+ type: "string",
202
+ maxLength: 262144
203
+ }
204
+ },
205
+ required: [
206
+ "type",
207
+ "svg"
208
+ ]
209
+ },
210
+ {
211
+ properties: {
212
+ type: {
213
+ description: "Icon storage type",
214
+ "const": "file"
215
+ },
216
+ docId: {
217
+ description: "The document ID for the attachment file",
218
+ type: "string",
219
+ pattern: "^file:",
220
+ minLength: 6,
221
+ maxLength: 128
222
+ }
223
+ },
224
+ required: [
225
+ "type",
226
+ "docId"
227
+ ]
228
+ }
229
+ ]
188
230
  }
189
231
  };
190
232
  var required$2 = [
@@ -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\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\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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/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\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\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;AAEtB,IAAM,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;;AAEJ,IAAM,eAAe,GAGvB;AACH,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,MAAM,EAAE;;AAEV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AAI,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;;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;YAC3C;iBAAO;AACL,gBAAA,OAAO,CAAC;YACV;AACF,QAAA,CAAC;aACA,IAAI,CAAC,IAAI,CAAC;IACf;SAAO;AACL,QAAA,OAAO,MAAM;IACf;AACF;AACA,IAAA,gBAAA,kBAAA,UAAA,MAAA,EAAA;IAAsC,SAAA,CAAA,gBAAA,EAAA,MAAA,CAAA;IAIpC,SAAA,gBAAA,CAAY,OAAe,EAAE,MAAqB,EAAA;QAChD,IAAA,KAAA,GAAA,MAAK,CAAA,IAAA,CAAA,IAAA,EAAC,OAAO,GAAG,GAAG,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC,IAAA,IAAA;QAJ1D,KAAA,CAAA,IAAI,GAAG,kBAAkB;AAKvB,QAAA,KAAI,CAAC,MAAM,GAAG,MAAM;;IACtB;IACF,OAAA,gBAAC;AAAD,CARA,CAAsC,KAAK,CAAA;;;;"}
package/lib/index.js CHANGED
@@ -187,6 +187,48 @@ var properties$2 = {
187
187
  "string",
188
188
  "null"
189
189
  ]
190
+ },
191
+ icon: {
192
+ description: "Custom icon for the notebook",
193
+ type: "object",
194
+ oneOf: [
195
+ {
196
+ properties: {
197
+ type: {
198
+ description: "Icon storage type",
199
+ "const": "inline"
200
+ },
201
+ svg: {
202
+ description: "The SVG icon data. Must be less than 256kb",
203
+ type: "string",
204
+ maxLength: 262144
205
+ }
206
+ },
207
+ required: [
208
+ "type",
209
+ "svg"
210
+ ]
211
+ },
212
+ {
213
+ properties: {
214
+ type: {
215
+ description: "Icon storage type",
216
+ "const": "file"
217
+ },
218
+ docId: {
219
+ description: "The document ID for the attachment file",
220
+ type: "string",
221
+ pattern: "^file:",
222
+ minLength: 6,
223
+ maxLength: 128
224
+ }
225
+ },
226
+ required: [
227
+ "type",
228
+ "docId"
229
+ ]
230
+ }
231
+ ]
190
232
  }
191
233
  };
192
234
  var required$2 = [
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\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\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;AAGtC,IAAM,qBAAqB,GAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnCvC,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,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AsC,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;;;;;;;;;;;;;;;;;;;;;"}
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\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\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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AA,gBAAA,CAAY,OAAe,EAAE,MAAqB,EAAA;QAChD,IAAA,KAAA,GAAA,MAAK,CAAA,IAAA,CAAA,IAAA,EAAC,OAAO,GAAG,GAAG,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC,IAAA,IAAA;QAJ1D,KAAA,CAAA,IAAI,GAAG,kBAAkB;AAKvB,QAAA,KAAI,CAAC,MAAM,GAAG,MAAM;;IACtB;IACF,OAAA,gBAAC;AAAD,CARA,CAAsC,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;"}
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: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 T=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=T,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=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}));
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"]},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"]},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 T=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=T,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=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.9.1",
3
+ "version": "2.10.0",
4
4
  "description": "Data model for Inkdrop",
5
5
  "scripts": {
6
6
  "build": "npm-run-all build:schema build:lib doc",
@@ -20,19 +20,19 @@
20
20
  "devDependencies": {
21
21
  "@rollup/plugin-json": "^6.1.0",
22
22
  "@rollup/plugin-terser": "^0.4.4",
23
- "@types/jest": "^29.5.14",
23
+ "@types/jest": "^30.0.0",
24
24
  "ajv": "^8.17.1",
25
25
  "ajv-cli": "^5.0.0",
26
- "eslint": "^9.20.1",
27
- "eslint-config-prettier": "^10.0.1",
28
- "jest": "^29.7.0",
26
+ "eslint": "^9.39.1",
27
+ "eslint-config-prettier": "^10.1.8",
28
+ "jest": "^30.2.0",
29
29
  "npm-run-all": "^4.1.5",
30
- "prettier": "^3.5.0",
31
- "rollup": "^4.34.6",
30
+ "prettier": "^3.7.4",
31
+ "rollup": "^4.53.3",
32
32
  "rollup-plugin-typescript2": "^0.36.0",
33
- "ts-jest": "^29.2.5",
34
- "typescript": "^5.7.3",
35
- "typescript-eslint": "^8.24.0",
33
+ "ts-jest": "^29.4.6",
34
+ "typescript": "^5.9.3",
35
+ "typescript-eslint": "^8.48.1",
36
36
  "yamljs": "^0.3.0"
37
37
  },
38
38
  "types": "lib/index.d.ts",
@@ -1 +1 @@
1
- "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$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"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^book:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="book" */;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.name === undefined) && (missing0 = "name"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){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: "^book:"},message:"must match pattern \""+"^book:"+"\""}];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.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 64){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"}];return false;}else {if(func4(data2) < 1){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}];return false;}}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data3 = data.updatedAt;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data4 = data.createdAt;const _errs9 = errors;if(!((typeof data4 == "number") && (isFinite(data4)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.count !== undefined){let data5 = data.count;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.parentBookId !== undefined){let data6 = data.parentBookId;const _errs13 = errors;if((typeof data6 !== "string") && (data6 !== null)){validate20.errors = [{instancePath:instancePath+"/parentBookId",schemaPath:"#/properties/parentBookId/type",keyword:"type",params:{type: schema22.properties.parentBookId.type},message:"must be string,null"}];return false;}var valid0 = _errs13 === 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":"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"]},"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"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^book:", "u");const pattern1 = new RegExp("^file:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="book" */;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.name === undefined) && (missing0 = "name"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){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: "^book:"},message:"must match pattern \""+"^book:"+"\""}];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.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 64){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"}];return false;}else {if(func4(data2) < 1){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}];return false;}}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data3 = data.updatedAt;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data4 = data.createdAt;const _errs9 = errors;if(!((typeof data4 == "number") && (isFinite(data4)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.count !== undefined){let data5 = data.count;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.parentBookId !== undefined){let data6 = data.parentBookId;const _errs13 = errors;if((typeof data6 !== "string") && (data6 !== null)){validate20.errors = [{instancePath:instancePath+"/parentBookId",schemaPath:"#/properties/parentBookId/type",keyword:"type",params:{type: schema22.properties.parentBookId.type},message:"must be string,null"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data.icon !== undefined){let data7 = data.icon;const _errs15 = errors;if(!(data7 && typeof data7 == "object" && !Array.isArray(data7))){validate20.errors = [{instancePath:instancePath+"/icon",schemaPath:"#/properties/icon/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}const _errs17 = errors;let valid1 = false;let passing0 = null;const _errs18 = errors;if(data7 && typeof data7 == "object" && !Array.isArray(data7)){let missing1;if(((data7.type === undefined) && (missing1 = "type")) || ((data7.svg === undefined) && (missing1 = "svg"))){const err0 = {instancePath:instancePath+"/icon",schemaPath:"#/properties/icon/oneOf/0/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}else {if(data7.type !== undefined){const _errs19 = errors;if("inline" !== data7.type){const err1 = {instancePath:instancePath+"/icon/type",schemaPath:"#/properties/icon/oneOf/0/properties/type/const",keyword:"const",params:{allowedValue: "inline"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}var valid2 = _errs19 === errors;}else {var valid2 = true;}if(valid2){if(data7.svg !== undefined){let data9 = data7.svg;const _errs20 = errors;if(errors === _errs20){if(typeof data9 === "string"){if(func4(data9) > 262144){const err2 = {instancePath:instancePath+"/icon/svg",schemaPath:"#/properties/icon/oneOf/0/properties/svg/maxLength",keyword:"maxLength",params:{limit: 262144},message:"must NOT have more than 262144 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/icon/svg",schemaPath:"#/properties/icon/oneOf/0/properties/svg/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var valid2 = _errs20 === errors;}else {var valid2 = true;}}}}var _valid0 = _errs18 === errors;if(_valid0){valid1 = true;passing0 = 0;}const _errs22 = errors;if(data7 && typeof data7 == "object" && !Array.isArray(data7)){let missing2;if(((data7.type === undefined) && (missing2 = "type")) || ((data7.docId === undefined) && (missing2 = "docId"))){const err4 = {instancePath:instancePath+"/icon",schemaPath:"#/properties/icon/oneOf/1/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}else {if(data7.type !== undefined){const _errs23 = errors;if("file" !== data7.type){const err5 = {instancePath:instancePath+"/icon/type",schemaPath:"#/properties/icon/oneOf/1/properties/type/const",keyword:"const",params:{allowedValue: "file"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}var valid3 = _errs23 === errors;}else {var valid3 = true;}if(valid3){if(data7.docId !== undefined){let data11 = data7.docId;const _errs24 = errors;if(errors === _errs24){if(typeof data11 === "string"){if(func4(data11) > 128){const err6 = {instancePath:instancePath+"/icon/docId",schemaPath:"#/properties/icon/oneOf/1/properties/docId/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}else {if(func4(data11) < 6){const err7 = {instancePath:instancePath+"/icon/docId",schemaPath:"#/properties/icon/oneOf/1/properties/docId/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}else {if(!pattern1.test(data11)){const err8 = {instancePath:instancePath+"/icon/docId",schemaPath:"#/properties/icon/oneOf/1/properties/docId/pattern",keyword:"pattern",params:{pattern: "^file:"},message:"must match pattern \""+"^file:"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}}}else {const err9 = {instancePath:instancePath+"/icon/docId",schemaPath:"#/properties/icon/oneOf/1/properties/docId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}var valid3 = _errs24 === errors;}else {var valid3 = true;}}}}var _valid0 = _errs22 === errors;if(_valid0 && valid1){valid1 = false;passing0 = [passing0, 1];}else {if(_valid0){valid1 = true;passing0 = 1;}}if(!valid1){const err10 = {instancePath:instancePath+"/icon",schemaPath:"#/properties/icon/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;validate20.errors = vErrors;return false;}else {errors = _errs17;if(vErrors !== null){if(_errs17){vErrors.length = _errs17;}else {vErrors = null;}}}var valid0 = _errs15 === 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;}