inkdrop-model 2.11.5 → 2.12.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/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/nanoid/url-alphabet/index.js","../node_modules/nanoid/index.js","../src/utils.ts","../src/validator.ts","../src/note.ts","../src/book.ts","../src/tag.ts","../src/file.ts"],"sourcesContent":["export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { webcrypto as crypto } from 'node:crypto'\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nconst POOL_SIZE_MULTIPLIER = 128\nlet pool, poolOffset\nfunction fillPool(bytes) {\n if (!pool || pool.length < bytes) {\n pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)\n crypto.getRandomValues(pool)\n poolOffset = 0\n } else if (poolOffset + bytes > pool.length) {\n crypto.getRandomValues(pool)\n poolOffset = 0\n }\n poolOffset += bytes\n}\nexport function random(bytes) {\n fillPool((bytes |= 0))\n return pool.subarray(poolOffset - bytes, poolOffset)\n}\nexport function customRandom(alphabet, defaultSize, getRandom) {\n let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1\n let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let i = step\n while (i--) {\n id += alphabet[bytes[i] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport function customAlphabet(alphabet, size = 21) {\n return customRandom(alphabet, size, random)\n}\nexport function nanoid(size = 21) {\n fillPool((size |= 0))\n let id = ''\n for (let i = poolOffset - size; i < poolOffset; i++) {\n id += scopedUrlAlphabet[pool[i] & 63]\n }\n return id\n}\n","import { nanoid } from 'nanoid'\n\nexport function createDocId(prefix: string): string {\n const id = nanoid(8)\n return `${prefix}${id}`\n}\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\nexport function validateDocId(prefix: string, docId: string): boolean {\n if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {\n throw new Error('Invalid document ID')\n }\n return true\n}\n","import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\nexport type TrashBookId = 'trash'\nexport type NoteStatus = 'none' | 'active' | 'onHold' | 'completed' | 'dropped'\nexport type NoteVisibility = 'private' | 'public'\nexport type NoteMetadata = {\n _id: string\n _rev?: string\n bookId: string\n doctype: string\n updatedAt: number\n createdAt: number\n tags?: string[]\n numOfTasks?: number\n numOfCheckedTasks?: number\n migratedBy?: string\n status?: NoteStatus\n share?: NoteVisibility\n pinned?: boolean\n timestamp: number\n _conflicts?: string[]\n}\nexport const NOTE_DOCID_PREFIX = 'note:'\nexport type Note = NoteMetadata & {\n title: string\n body: string\n}\nexport type EncryptedNote = NoteMetadata & {\n encryptedData: EncryptedData\n}\nexport const TRASH_BOOK_ID = 'trash'\n\nexport const NOTE_STATUS: Readonly<{\n NONE: 'none'\n ACTIVE: 'active'\n ON_HOLD: 'onHold'\n COMPLETED: 'completed'\n DROPPED: 'dropped'\n}> = {\n NONE: 'none',\n ACTIVE: 'active',\n ON_HOLD: 'onHold',\n COMPLETED: 'completed',\n DROPPED: 'dropped'\n}\nexport const NOTE_VISIBILITY: Readonly<{\n PRIVATE: 'private'\n PUBLIC: 'public'\n}> = {\n PRIVATE: 'private',\n PUBLIC: 'public'\n}\nconst validateNote: ValidateFunction<Note> = validator as any\nexport { NoteSchema, validateNote }\n\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\n\nexport function createNoteId(): string {\n return createDocId(NOTE_DOCID_PREFIX)\n}\n\nexport function validateNoteId(docId: string): boolean {\n return validateDocId(NOTE_DOCID_PREFIX, docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\n\nexport type BookIconInline = {\n type: 'inline'\n svg: string\n}\nexport type BookIconFile = {\n type: 'file'\n docId: string\n}\nexport type BookIcon = BookIconInline | BookIconFile\n\nexport type BookMetadata = {\n _id: string\n _rev?: string\n updatedAt: number\n createdAt: number\n count?: number\n parentBookId?: null | string\n migratedBy?: string\n icon?: BookIcon\n order?: number\n}\nexport type Book = BookMetadata & {\n name: string\n}\nexport type EncryptedBook = BookMetadata & {\n encryptedData: EncryptedData\n}\n\nexport const BOOK_DOCID_PREFIX = 'book:'\n\nconst validateBook: ValidateFunction<Book> = validator as any\nexport { BookSchema, validateBook }\n\nexport function createBookId(): string {\n return createDocId(BOOK_DOCID_PREFIX)\n}\n\nexport function validateBookId(docId: string): boolean {\n return validateDocId(BOOK_DOCID_PREFIX, docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\nexport type TagColor =\n | 'default'\n | 'red'\n | 'orange'\n | 'yellow'\n | 'olive'\n | 'green'\n | 'teal'\n | 'blue'\n | 'violet'\n | 'purple'\n | 'pink'\n | 'brown'\n | 'grey'\n | 'black'\nexport const TAG_COLOR: Readonly<{\n DEFAULT: 'default'\n RED: 'red'\n ORANGE: 'orange'\n YELLOW: 'yellow'\n OLIVE: 'olive'\n GREEN: 'green'\n TEAL: 'teal'\n BLUE: 'blue'\n VIOLET: 'violet'\n PURPLE: 'purple'\n PINK: 'pink'\n BROWN: 'brown'\n GREY: 'grey'\n BLACK: 'black'\n}> = {\n DEFAULT: 'default',\n RED: 'red',\n ORANGE: 'orange',\n YELLOW: 'yellow',\n OLIVE: 'olive',\n GREEN: 'green',\n TEAL: 'teal',\n BLUE: 'blue',\n VIOLET: 'violet',\n PURPLE: 'purple',\n PINK: 'pink',\n BROWN: 'brown',\n GREY: 'grey',\n BLACK: 'black'\n}\nexport type TagMetadata = {\n _id: string\n _rev?: string\n count?: number\n color: TagColor\n updatedAt: number\n createdAt: number\n}\nexport type Tag = TagMetadata & {\n name: string\n}\nexport type EncryptedTag = TagMetadata & {\n encryptedData: EncryptedData\n}\n\nexport const TAG_DOCID_PREFIX = 'tag:'\n\nconst validateTag: ValidateFunction<Tag> = validator as any\nexport { TagSchema, validateTag }\n\nexport function createTagId(): string {\n return createDocId(TAG_DOCID_PREFIX)\n}\n\nexport function validateTagId(docId: string): boolean {\n return validateDocId(TAG_DOCID_PREFIX, docId)\n}\n","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\nexport type ImageFileType =\n | 'image/png'\n | 'image/jpeg'\n | 'image/jpg'\n | 'image/svg+xml'\n | 'image/gif'\n | 'image/heic'\n | 'image/heif'\nexport const supportedImageFileTypes: ReadonlyArray<ImageFileType> = [\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/svg+xml',\n 'image/gif',\n 'image/heic',\n 'image/heif'\n]\nexport const SUPPORTED_IMAGE_MIME_TYPES: {\n readonly [mime: string]: ImageFileType\n} = {\n ...supportedImageFileTypes.reduce(\n (hash, ft) => ({ ...hash, [ft.split('/')[1]]: ft }),\n {} as Record<string, ImageFileType>\n ),\n jpg: 'image/jpeg'\n}\nexport const maxAttachmentFileSize: number = 10 * 1024 * 1024\nexport type FileAttachmentItem = {\n digest?: string\n content_type: ImageFileType\n data: Buffer | string\n length?: number\n}\nexport type File = {\n _id: string\n _rev?: string\n name: string\n createdAt: number\n contentType: ImageFileType\n contentLength: number\n publicIn: string[]\n _attachments: {\n index: FileAttachmentItem\n }\n md5digest?: string\n}\nexport type EncryptedFile = File & {\n encryptionData: EncryptionMetadata\n}\n\nexport const FILE_DOCID_PREFIX = 'file:'\n\nconst validateFile: ValidateFunction<File> = validator as any\nexport { FileSchema, validateFile }\n\nexport function createFileId(): string {\n return createDocId(FILE_DOCID_PREFIX)\n}\n\nexport function validateFileId(docId: string): boolean {\n return validateDocId(FILE_DOCID_PREFIX, docId)\n}\n"],"names":["crypto","scopedUrlAlphabet","validator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,WAAW;AACxB,EAAE;;ACEF,MAAM,oBAAoB,GAAG;AAC7B,IAAI,IAAI,EAAE;AACV,SAAS,QAAQ,CAAC,KAAK,EAAE;AACzB,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE;AACpC,IAAI,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,oBAAoB;AAC1D,IAAIA,qBAAM,CAAC,eAAe,CAAC,IAAI;AAC/B,IAAI,UAAU,GAAG;AACjB,EAAE,CAAC,MAAM,IAAI,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;AAC/C,IAAIA,qBAAM,CAAC,eAAe,CAAC,IAAI;AAC/B,IAAI,UAAU,GAAG;AACjB,EAAE;AACF,EAAE,UAA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A,QAAA,CAAA,EAAA,EAAM,IAAI,CAAA,GAAA,EAAA,GAAA,EAAA,EAAA,EAAA,CAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA,GAAG,EAAE,EAAA,EAAA,EAAA;AAAlC,CAAqC,EACnD,EAAmC,CACpC,CAAA,EAAA,EACD,GAAG,EAAE,YAAY;IAEN,qBAAqB,GAAW,EAAE,GAAG,IAAI,GAAG;AAwBlD,IAAM,iBAAiB,GAAG;AAEjC,IAAM,YAAY,GAA2BA;SAG7B,YAAY,GAAA;AAC1B,IAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC;AACvC;AAEM,SAAU,cAAc,CAAC,KAAa,EAAA;AAC1C,IAAA,OAAO,aAAa,CAAC,iBAAiB,EAAE,KAAK,CAAC;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"index.js","names":["validator","validator","validator","validator"],"sources":["../json-schema/note.json","../node_modules/.pnpm/nanoid@6.0.0/node_modules/nanoid/url-alphabet/index.js","../node_modules/.pnpm/nanoid@6.0.0/node_modules/nanoid/index.js","../src/utils.ts","../src/validator.ts","../src/note.ts","../json-schema/book.json","../src/book.ts","../json-schema/tag.json","../src/tag.ts","../json-schema/file.json","../src/file.ts"],"sourcesContent":["","export let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { urlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet }\n\nconst GET_RANDOM_LIMIT = 65536\n\nfunction fillRandom(buffer) {\n let from = 0\n while (from < buffer.length) {\n let to = Math.min(from + GET_RANDOM_LIMIT, buffer.length)\n crypto.getRandomValues(buffer.subarray(from, to))\n from = to\n }\n}\n\nexport function random(bytes) {\n bytes |= 0\n if (bytes < 0) throw new RangeError('Wrong ID size')\n let buffer = Buffer.allocUnsafe(bytes)\n fillRandom(buffer)\n return buffer\n}\n\nexport function customRandom(alphabet, defaultSize, getRandom) {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let i = size\n while (i--) {\n id += alphabet[bytes[i] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let i = step\n while (i--) {\n if (bytes[i] < safeByteCutoff) {\n id += alphabet[bytes[i] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\n\n\nconst POOL_MAX = GET_RANDOM_LIMIT / 2\n\nexport function customAlphabet(alphabet, defaultSize = 21) {\n if (\n typeof alphabet !== 'string' ||\n !alphabet.length ||\n alphabet.length > 256\n ) {\n return customRandom(alphabet, defaultSize, random)\n }\n for (let i = 0; i < alphabet.length; i++) {\n if (alphabet.charCodeAt(i) > 255) {\n return customRandom(alphabet, defaultSize, random)\n }\n }\n\n let charCodes = Uint8Array.from(alphabet, str => {\n return str.charCodeAt(0)\n })\n let alphabetLen = alphabet.length\n let mask = (2 << (31 - Math.clz32((alphabetLen - 1) | 1))) - 1\n\n let pool = ''\n let poolOffset = 0\n let poolNext = 0\n\n return (size = defaultSize) => {\n size |= 0\n if (size < 0) throw new RangeError('Wrong ID size')\n if (size === 0) return ''\n if (poolOffset + size > pool.length) {\n let target = Math.max(poolNext, size)\n poolNext = Math.min(target * 16, POOL_MAX)\n let buffer = Buffer.allocUnsafe(target)\n if (mask === alphabetLen - 1) {\n fillRandom(buffer)\n for (let i = 0; i < target; i++) {\n buffer[i] = charCodes[buffer[i] & mask]\n }\n } else {\n let randomBytes = Buffer.allocUnsafe(\n Math.ceil((1.6 * (mask + 1) * target) / alphabetLen)\n )\n let accepted = 0\n while (accepted < target) {\n fillRandom(randomBytes)\n for (let i = 0; i < randomBytes.length; i++) {\n let index = randomBytes[i] & mask\n if (index < alphabetLen) {\n buffer[accepted++] = charCodes[index]\n if (accepted === target) break\n }\n }\n }\n }\n pool = buffer.toString('latin1')\n poolOffset = 0\n }\n poolOffset += size\n return pool.substring(poolOffset - size, poolOffset)\n }\n}\n\nexport const nanoid = customAlphabet(urlAlphabet)\n","import { nanoid } from 'nanoid'\n\nexport function createDocId(prefix: string): string {\n const id = nanoid(8)\n return `${prefix}${id}`\n}\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\nexport function validateDocId(prefix: string, docId: string): boolean {\n if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {\n throw new Error('Invalid document ID')\n }\n return true\n}\n","import type { ValidateFunction } from 'ajv'\nimport NoteSchema from '../json-schema/note.json'\nimport validator from '../validators/note'\nimport type { EncryptedData } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\nexport type TrashBookId = 'trash'\nexport type TemplateBookId = 'template'\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 const NOTE_DOCID_PREFIX = 'note:'\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'\nexport const TEMPLATE_BOOK_ID = 'template'\n\nexport const NOTE_STATUS: Readonly<{\n NONE: 'none'\n ACTIVE: 'active'\n ON_HOLD: 'onHold'\n COMPLETED: 'completed'\n DROPPED: 'dropped'\n}> = {\n NONE: 'none',\n ACTIVE: 'active',\n ON_HOLD: 'onHold',\n COMPLETED: 'completed',\n DROPPED: 'dropped'\n}\nexport const NOTE_VISIBILITY: Readonly<{\n PRIVATE: 'private'\n PUBLIC: 'public'\n}> = {\n PRIVATE: 'private',\n PUBLIC: 'public'\n}\nconst validateNote: ValidateFunction<Note> = validator as any\nexport { NoteSchema, validateNote }\n\nexport const NOTE_TITLE_MAX_LENGTH: number = 256\n\nexport function createNoteId(): string {\n return createDocId(NOTE_DOCID_PREFIX)\n}\n\nexport function validateNoteId(docId: string): boolean {\n return validateDocId(NOTE_DOCID_PREFIX, docId)\n}\n","","import type { ValidateFunction } from 'ajv'\nimport BookSchema from '../json-schema/book.json'\nimport validator from '../validators/book'\n\nimport type { EncryptedData } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\n\nexport type BookIconInline = {\n type: 'inline'\n svg: string\n}\nexport type BookIconFile = {\n type: 'file'\n docId: string\n}\nexport type BookIcon = BookIconInline | BookIconFile\n\nexport type BookMetadata = {\n _id: string\n _rev?: string\n updatedAt: number\n createdAt: number\n count?: number\n parentBookId?: null | string\n migratedBy?: string\n icon?: BookIcon\n order?: number\n}\nexport type Book = BookMetadata & {\n name: string\n}\nexport type EncryptedBook = BookMetadata & {\n encryptedData: EncryptedData\n}\n\nexport const BOOK_DOCID_PREFIX = 'book:'\n\nconst validateBook: ValidateFunction<Book> = validator as any\nexport { BookSchema, validateBook }\n\nexport function createBookId(): string {\n return createDocId(BOOK_DOCID_PREFIX)\n}\n\nexport function validateBookId(docId: string): boolean {\n return validateDocId(BOOK_DOCID_PREFIX, docId)\n}\n","","import type { ValidateFunction } from 'ajv'\nimport TagSchema from '../json-schema/tag.json'\nimport validator from '../validators/tag'\nimport type { EncryptedData } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\nexport type TagColor =\n | 'default'\n | 'red'\n | 'orange'\n | 'yellow'\n | 'olive'\n | 'green'\n | 'teal'\n | 'blue'\n | 'violet'\n | 'purple'\n | 'pink'\n | 'brown'\n | 'grey'\n | 'black'\nexport const TAG_COLOR: Readonly<{\n DEFAULT: 'default'\n RED: 'red'\n ORANGE: 'orange'\n YELLOW: 'yellow'\n OLIVE: 'olive'\n GREEN: 'green'\n TEAL: 'teal'\n BLUE: 'blue'\n VIOLET: 'violet'\n PURPLE: 'purple'\n PINK: 'pink'\n BROWN: 'brown'\n GREY: 'grey'\n BLACK: 'black'\n}> = {\n DEFAULT: 'default',\n RED: 'red',\n ORANGE: 'orange',\n YELLOW: 'yellow',\n OLIVE: 'olive',\n GREEN: 'green',\n TEAL: 'teal',\n BLUE: 'blue',\n VIOLET: 'violet',\n PURPLE: 'purple',\n PINK: 'pink',\n BROWN: 'brown',\n GREY: 'grey',\n BLACK: 'black'\n}\nexport type TagMetadata = {\n _id: string\n _rev?: string\n count?: number\n color: TagColor\n updatedAt: number\n createdAt: number\n}\nexport type Tag = TagMetadata & {\n name: string\n}\nexport type EncryptedTag = TagMetadata & {\n encryptedData: EncryptedData\n}\n\nexport const TAG_DOCID_PREFIX = 'tag:'\n\nconst validateTag: ValidateFunction<Tag> = validator as any\nexport { TagSchema, validateTag }\n\nexport function createTagId(): string {\n return createDocId(TAG_DOCID_PREFIX)\n}\n\nexport function validateTagId(docId: string): boolean {\n return validateDocId(TAG_DOCID_PREFIX, docId)\n}\n","","import type { ValidateFunction } from 'ajv'\nimport FileSchema from '../json-schema/file.json'\nimport validator from '../validators/file'\nimport type { EncryptionMetadata } from './crypto'\nimport { createDocId } from './utils'\nimport { validateDocId } from './validator'\nexport type ImageFileType =\n | 'image/png'\n | 'image/jpeg'\n | 'image/jpg'\n | 'image/svg+xml'\n | 'image/gif'\n | 'image/heic'\n | 'image/heif'\nexport const supportedImageFileTypes: ReadonlyArray<ImageFileType> = [\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/svg+xml',\n 'image/gif',\n 'image/heic',\n 'image/heif'\n]\nexport const SUPPORTED_IMAGE_MIME_TYPES: {\n readonly [mime: string]: ImageFileType\n} = {\n ...supportedImageFileTypes.reduce(\n (hash, ft) => ({ ...hash, [ft.split('/')[1]]: ft }),\n {} as Record<string, ImageFileType>\n ),\n jpg: 'image/jpeg'\n}\nexport const maxAttachmentFileSize: number = 10 * 1024 * 1024\nexport type FileAttachmentItem = {\n digest?: string\n content_type: ImageFileType\n data: Buffer | string\n length?: number\n}\nexport type File = {\n _id: string\n _rev?: string\n name: string\n createdAt: number\n contentType: ImageFileType\n contentLength: number\n publicIn: string[]\n _attachments: {\n index: FileAttachmentItem\n }\n md5digest?: string\n}\nexport type EncryptedFile = File & {\n encryptionData: EncryptionMetadata\n}\n\nexport const FILE_DOCID_PREFIX = 'file:'\n\nconst validateFile: ValidateFunction<File> = validator as any\nexport { FileSchema, validateFile }\n\nexport function createFileId(): string {\n return createDocId(FILE_DOCID_PREFIX)\n}\n\nexport function validateFileId(docId: string): boolean {\n return validateDocId(FILE_DOCID_PREFIX, docId)\n}\n"],"x_google_ignoreList":[1,2],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,IAAW,cACT;;;ACGF,MAAM,mBAAmB;AAEzB,SAAS,WAAW,QAAQ;CAC1B,IAAI,OAAO;CACX,OAAO,OAAO,OAAO,QAAQ;EAC3B,IAAI,KAAK,KAAK,IAAI,OAAO,kBAAkB,OAAO,MAAM;EACx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AQ;CACR,QAAQ;CACR,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;AACT;AAgBA,MAAa,mBAAmB;AAEhC,MAAM,cAAqCC,eAAAA;AAG3C,SAAgB,cAAsB;CACpC,OAAO,YAAY,gBAAgB;AACrC;AAEA,SAAgB,cAAc,OAAwB;CACpD,OAAO,cAAc,kBAAkB,KAAK;AAC9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEhEA,MAAa,0BAAwD;CACnE;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAa,6BAET;CACF,GAAG,wBAAwB,QACxB,MAAM,QAAQ;EAAE,GAAG;GAAO,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK;CAAG,IACjD,CAAC,CACH;CACA,KAAK;AACP;AACA,MAAa,wBAAgC,KAAK,OAAO;AAwBzD,MAAa,oBAAoB;AAEjC,MAAM,eAAuCC,gBAAAA;AAG7C,SAAgB,eAAuB;CACrC,OAAO,YAAY,iBAAiB;AACtC;AAEA,SAAgB,eAAe,OAAwB;CACrD,OAAO,cAAc,mBAAmB,KAAK;AAC/C"}
package/lib/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../validators/note"),require("node:crypto"),require("../validators/book"),require("../validators/tag"),require("../validators/file")):"function"==typeof define&&define.amd?define(["exports","../validators/note","node:crypto","../validators/book","../validators/tag","../validators/file"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).InkdropModel={},e.validator,e.node_crypto,e.validator$1,e.validator$2,e.validator$3)}(this,function(e,t,n,i,r,o){"use strict";var a={$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"]};let s,d;function p(e=21){var t;t=e|=0,!s||s.length<t?(s=Buffer.allocUnsafe(128*t),n.webcrypto.getRandomValues(s),d=0):d+t>s.length&&(n.webcrypto.getRandomValues(s),d=0),d+=t;let i="";for(let t=d-e;t<d;t++)i+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&s[t]];return i}function c(e){var t=p(8);return"".concat(e).concat(t)}var h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},h(e,t)};var m=function(){return m=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},m.apply(this,arguments)};function l(e){return e instanceof Array?e.map(function(e){return"object"==typeof e?'"'.concat(e.instancePath,'" ').concat(e.message):e}).join(", "):e}"function"==typeof SuppressedError&&SuppressedError;var u=function(e){function t(t,n){var i=e.call(this,t+" "+l(n))||this;return i.name="InvalidDataError",i.errors=n,i}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 n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t}(Error);function g(e,t){if(!t.startsWith(e)||t.length<=5||t.length>128)throw new Error("Invalid document ID");return!0}var f="note:",y=t;var b={$schema:"http://json-schema.org/draft-07/schema#",$id:"book",title:"Book",description:"A notebook data",type:"object",properties:{_id:{description:"The unique notebook ID which should start with `book:` and the remains are randomly generated string",type:"string",minLength:6,maxLength:128,pattern:"^book:"},_rev:{description:"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",type:"string"},name:{description:"The notebook name",type:"string",minLength:1,maxLength:64},updatedAt:{description:"The date time when the notebook was last updated, represented with Unix timestamps in milliseconds",type:"number"},createdAt:{description:"The date time when the notebook was created, represented with Unix timestamps in milliseconds",type:"number"},count:{description:"It indicates the number of notes in the notebook",type:"number"},parentBookId:{description:"The ID of the parent notebook",type:["string","null"]},order:{description:"A number used to manually sort notebooks. Notebooks are ordered by this value in ascending order. If not specified, notebooks fall back to alphabetical sorting by name.",type:"number"},icon:{description:"Custom icon for the notebook",type:"object",oneOf:[{properties:{type:{description:"Icon storage type",const:"inline"},svg:{description:"The SVG icon data. Must be less than 256kb",type:"string",maxLength:262144}},required:["type","svg"]},{properties:{type:{description:"Icon storage type",const:"file"},docId:{description:"The document ID for the attachment file",type:"string",pattern:"^file:",minLength:6,maxLength:128}},required:["type","docId"]}]}},required:["_id","name","updatedAt","createdAt"]},T="book:",v=i;var I={$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"]},w="tag:",k=r;var _={$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"]},E=["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"],L=m(m({},E.reduce(function(e,t){var n;return m(m({},e),((n={})[t.split("/")[1]]=t,n))},{})),{jpg:"image/jpeg"}),O="file:",x=o;e.BOOK_DOCID_PREFIX=T,e.BookSchema=b,e.FILE_DOCID_PREFIX=O,e.FileSchema=_,e.InvalidDataError=u,e.NOTE_DOCID_PREFIX=f,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=a,e.SUPPORTED_IMAGE_MIME_TYPES=L,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.TAG_DOCID_PREFIX=w,e.TRASH_BOOK_ID="trash",e.TagSchema=I,e.createBookId=function(){return c(T)},e.createDocId=c,e.createFileId=function(){return c(O)},e.createNoteId=function(){return c(f)},e.createTagId=function(){return c(w)},e.maxAttachmentFileSize=10485760,e.supportedImageFileTypes=E,e.validateBook=v,e.validateBookId=function(e){return g(T,e)},e.validateDocId=g,e.validateFile=x,e.validateFileId=function(e){return g(O,e)},e.validateNote=y,e.validateNoteId=function(e){return g(f,e)},e.validateTag=k,e.validateTagId=function(e){return g(w,e)},e.validationErrorsToMessage=l});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("../validators/note"),require("../validators/book"),require("../validators/tag"),require("../validators/file")):typeof define==`function`&&define.amd?define([`exports`,`../validators/note`,`../validators/book`,`../validators/tag`,`../validators/file`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.InkdropModel={},e.validators_note,e.validators_book,e.validators_tag,e.validators_file))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e));t=f(t),n=f(n),r=f(r),i=f(i);var p={$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$|template$)`},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`]};function m(e){let t=0;for(;t<e.length;){let n=Math.min(t+65536,e.length);crypto.getRandomValues(e.subarray(t,n)),t=n}}function h(e){if(e|=0,e<0)throw RangeError(`Wrong ID size`);let t=Buffer.allocUnsafe(e);return m(t),t}function g(e,t,n){let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(1.6*256*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}}function _(e,t=21){if(typeof e!=`string`||!e.length||e.length>256)return g(e,t,h);for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>255)return g(e,t,h);let n=Uint8Array.from(e,e=>e.charCodeAt(0)),r=e.length,i=(2<<31-Math.clz32(r-1|1))-1,a=``,o=0,s=0;return(e=t)=>{if(e|=0,e<0)throw RangeError(`Wrong ID size`);if(e===0)return``;if(o+e>a.length){let t=Math.max(s,e);s=Math.min(t*16,32768);let c=Buffer.allocUnsafe(t);if(i===r-1){m(c);for(let e=0;e<t;e++)c[e]=n[c[e]&i]}else{let e=Buffer.allocUnsafe(Math.ceil(1.6*(i+1)*t/r)),a=0;for(;a<t;){m(e);for(let o=0;o<e.length;o++){let s=e[o]&i;if(s<r&&(c[a++]=n[s],a===t))break}}}a=c.toString(`latin1`),o=0}return o+=e,a.substring(o-e,o)}}let v=_(`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`);function y(e){return`${e}${v(8)}`}function b(e){return e instanceof Array?e.map(e=>typeof e==`object`?`"${e.instancePath}" ${e.message}`:e).join(`, `):e}var x=class extends Error{constructor(e,t){super(e+` `+b(t)),this.name=`InvalidDataError`,this.errors=t}};function S(e,t){if(!t.startsWith(e)||t.length<=5||t.length>128)throw Error(`Invalid document ID`);return!0}let C=`note:`,w={NONE:`none`,ACTIVE:`active`,ON_HOLD:`onHold`,COMPLETED:`completed`,DROPPED:`dropped`},T={PRIVATE:`private`,PUBLIC:`public`},E=t.default;function D(){return y(C)}function O(e){return S(C,e)}var k={$schema:`http://json-schema.org/draft-07/schema#`,$id:`book`,title:`Book`,description:`A notebook data`,type:`object`,properties:{_id:{description:"The unique notebook ID which should start with `book:` and the remains are randomly generated string",type:`string`,minLength:6,maxLength:128,pattern:`^book:`},_rev:{description:`This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)`,type:`string`},name:{description:`The notebook name`,type:`string`,minLength:1,maxLength:64},updatedAt:{description:`The date time when the notebook was last updated, represented with Unix timestamps in milliseconds`,type:`number`},createdAt:{description:`The date time when the notebook was created, represented with Unix timestamps in milliseconds`,type:`number`},count:{description:`It indicates the number of notes in the notebook`,type:`number`},parentBookId:{description:`The ID of the parent notebook`,type:[`string`,`null`]},order:{description:`A number used to manually sort notebooks. Notebooks are ordered by this value in ascending order. If not specified, notebooks fall back to alphabetical sorting by name.`,type:`number`},icon:{description:`Custom icon for the notebook`,type:`object`,oneOf:[{properties:{type:{description:`Icon storage type`,const:`inline`},svg:{description:`The SVG icon data. Must be less than 256kb`,type:`string`,maxLength:262144}},required:[`type`,`svg`]},{properties:{type:{description:`Icon storage type`,const:`file`},docId:{description:`The document ID for the attachment file`,type:`string`,pattern:`^file:`,minLength:6,maxLength:128}},required:[`type`,`docId`]}]}},required:[`_id`,`name`,`updatedAt`,`createdAt`]};let A=`book:`,j=n.default;function M(){return y(A)}function N(e){return S(A,e)}var 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`]};let F={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`},I=`tag:`,L=r.default;function R(){return y(I)}function z(e){return S(I,e)}var B={$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`]};let V=[`image/png`,`image/jpeg`,`image/jpg`,`image/svg+xml`,`image/gif`,`image/heic`,`image/heif`],H={...V.reduce((e,t)=>({...e,[t.split(`/`)[1]]:t}),{}),jpg:`image/jpeg`},U=`file:`,W=i.default;function G(){return y(U)}function K(e){return S(U,e)}e.BOOK_DOCID_PREFIX=A,Object.defineProperty(e,"BookSchema",{enumerable:!0,get:function(){return k}}),e.FILE_DOCID_PREFIX=U,Object.defineProperty(e,"FileSchema",{enumerable:!0,get:function(){return B}}),e.InvalidDataError=x,e.NOTE_DOCID_PREFIX=C,e.NOTE_STATUS=w,e.NOTE_TITLE_MAX_LENGTH=256,e.NOTE_VISIBILITY=T,Object.defineProperty(e,"NoteSchema",{enumerable:!0,get:function(){return p}}),e.SUPPORTED_IMAGE_MIME_TYPES=H,e.TAG_COLOR=F,e.TAG_DOCID_PREFIX=I,e.TEMPLATE_BOOK_ID=`template`,e.TRASH_BOOK_ID=`trash`,Object.defineProperty(e,"TagSchema",{enumerable:!0,get:function(){return P}}),e.createBookId=M,e.createDocId=y,e.createFileId=G,e.createNoteId=D,e.createTagId=R,e.maxAttachmentFileSize=10485760,e.supportedImageFileTypes=V,e.validateBook=j,e.validateBookId=N,e.validateDocId=S,e.validateFile=W,e.validateFileId=K,e.validateNote=E,e.validateNoteId=O,e.validateTag=L,e.validateTagId=z,e.validationErrorsToMessage=b});
package/package.json CHANGED
@@ -1,47 +1,45 @@
1
1
  {
2
2
  "name": "inkdrop-model",
3
- "version": "2.11.5",
3
+ "version": "2.12.0",
4
4
  "description": "Data model for Inkdrop",
5
5
  "scripts": {
6
6
  "build": "npm-run-all build:schema build:lib doc",
7
- "build:lib": "rollup -c --bundleConfigAsCjs && mv lib/src/* lib/ && rm -r lib/src",
7
+ "build:lib": "rm -rf lib && tsdown",
8
8
  "build:schema": "./compile_schema.sh",
9
- "lint": "eslint src __tests__",
10
- "test": "jest --config jest.config.js",
9
+ "lint": "oxlint",
10
+ "format": "oxfmt",
11
+ "test": "vitest --run",
11
12
  "doc": "./generate_doc.sh",
12
- "prepublishOnly": "npm-run-all build:* lint test"
13
+ "typecheck": "tsc --noEmit",
14
+ "prepublishOnly": "npm-run-all build:* typecheck lint test"
13
15
  },
14
16
  "author": "Takuya Matsuyama <t@inkdrop.app>",
15
17
  "license": "MIT",
18
+ "packageManager": "pnpm@11.11.0",
16
19
  "repository": {
17
20
  "type": "git",
18
21
  "url": "https://github.com/inkdropapp/inkdrop-model.git"
19
22
  },
20
23
  "devDependencies": {
21
- "nanoid": "^5.1.6",
22
- "@rollup/plugin-json": "^6.1.0",
23
- "@rollup/plugin-node-resolve": "^16.0.3",
24
- "@rollup/plugin-terser": "^0.4.4",
25
- "@types/jest": "^30.0.0",
26
- "ajv": "^8.18.0",
24
+ "@types/node": "^26.1.1",
25
+ "ajv": "^8.20.0",
27
26
  "ajv-cli": "^5.0.0",
28
27
  "ajv-formats": "^3.0.1",
29
- "eslint": "^9.39.3",
30
- "eslint-config-prettier": "^10.1.8",
31
- "jest": "^30.2.0",
32
- "npm-run-all": "^4.1.5",
33
- "prettier": "^3.8.1",
34
- "rollup": "^4.59.0",
35
- "rollup-plugin-typescript2": "^0.36.0",
36
- "ts-jest": "^29.4.6",
37
- "typescript": "^5.9.3",
38
- "typescript-eslint": "^8.56.0",
39
- "yaml": "^2.8.2"
28
+ "nanoid": "^6.0.0",
29
+ "npm-run-all2": "^9.0.2",
30
+ "oxfmt": "0.58.0",
31
+ "oxlint": "1.73.0",
32
+ "tsdown": "0.22.5",
33
+ "typescript": "^6.0.3",
34
+ "vitest": "^4.1.10",
35
+ "yaml": "^2.9.0"
40
36
  },
41
37
  "types": "lib/index.d.ts",
42
38
  "main": "lib/index.js",
43
39
  "unpkg": "lib/index.umd.js",
44
40
  "module": "lib/index.esm.js",
41
+ "browser": "lib/index.browser.js",
42
+ "react-native": "lib/index.browser.js",
45
43
  "keywords": [
46
44
  "json-schema"
47
45
  ],
@@ -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":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;}
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$|template$)"},"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$|template$)", "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$|template$)"},message:"must match pattern \""+"^(book:|trash$|template$)"+"\""}];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;}
package/lib/book.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import type { ValidateFunction } from 'ajv';
2
- import BookSchema from '../json-schema/book.json';
3
- import type { EncryptedData } from './crypto';
4
- export type BookIconInline = {
5
- type: 'inline';
6
- svg: string;
7
- };
8
- export type BookIconFile = {
9
- type: 'file';
10
- docId: string;
11
- };
12
- export type BookIcon = BookIconInline | BookIconFile;
13
- export type BookMetadata = {
14
- _id: string;
15
- _rev?: string;
16
- updatedAt: number;
17
- createdAt: number;
18
- count?: number;
19
- parentBookId?: null | string;
20
- migratedBy?: string;
21
- icon?: BookIcon;
22
- order?: number;
23
- };
24
- export type Book = BookMetadata & {
25
- name: string;
26
- };
27
- export type EncryptedBook = BookMetadata & {
28
- encryptedData: EncryptedData;
29
- };
30
- export declare const BOOK_DOCID_PREFIX = "book:";
31
- declare const validateBook: ValidateFunction<Book>;
32
- export { BookSchema, validateBook };
33
- export declare function createBookId(): string;
34
- export declare function validateBookId(docId: string): boolean;
package/lib/crypto.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export type EncryptionMetadata = {
2
- algorithm: string;
3
- iv: string;
4
- tag: string;
5
- };
6
- export type EncryptedData = EncryptionMetadata & {
7
- content: string | Buffer;
8
- };
package/lib/file.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import type { ValidateFunction } from 'ajv';
2
- import FileSchema from '../json-schema/file.json';
3
- import type { EncryptionMetadata } from './crypto';
4
- export type ImageFileType = 'image/png' | 'image/jpeg' | 'image/jpg' | 'image/svg+xml' | 'image/gif' | 'image/heic' | 'image/heif';
5
- export declare const supportedImageFileTypes: ReadonlyArray<ImageFileType>;
6
- export declare const SUPPORTED_IMAGE_MIME_TYPES: {
7
- readonly [mime: string]: ImageFileType;
8
- };
9
- export declare const maxAttachmentFileSize: number;
10
- export type FileAttachmentItem = {
11
- digest?: string;
12
- content_type: ImageFileType;
13
- data: Buffer | string;
14
- length?: number;
15
- };
16
- export type File = {
17
- _id: string;
18
- _rev?: string;
19
- name: string;
20
- createdAt: number;
21
- contentType: ImageFileType;
22
- contentLength: number;
23
- publicIn: string[];
24
- _attachments: {
25
- index: FileAttachmentItem;
26
- };
27
- md5digest?: string;
28
- };
29
- export type EncryptedFile = File & {
30
- encryptionData: EncryptionMetadata;
31
- };
32
- export declare const FILE_DOCID_PREFIX = "file:";
33
- declare const validateFile: ValidateFunction<File>;
34
- export { FileSchema, validateFile };
35
- export declare function createFileId(): string;
36
- export declare function validateFileId(docId: string): boolean;
package/lib/note.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import type { ValidateFunction } from 'ajv';
2
- import NoteSchema from '../json-schema/note.json';
3
- import type { EncryptedData } from './crypto';
4
- export type TrashBookId = 'trash';
5
- export type NoteStatus = 'none' | 'active' | 'onHold' | 'completed' | 'dropped';
6
- export type NoteVisibility = 'private' | 'public';
7
- export type NoteMetadata = {
8
- _id: string;
9
- _rev?: string;
10
- bookId: string;
11
- doctype: string;
12
- updatedAt: number;
13
- createdAt: number;
14
- tags?: string[];
15
- numOfTasks?: number;
16
- numOfCheckedTasks?: number;
17
- migratedBy?: string;
18
- status?: NoteStatus;
19
- share?: NoteVisibility;
20
- pinned?: boolean;
21
- timestamp: number;
22
- _conflicts?: string[];
23
- };
24
- export declare const NOTE_DOCID_PREFIX = "note:";
25
- export type Note = NoteMetadata & {
26
- title: string;
27
- body: string;
28
- };
29
- export type EncryptedNote = NoteMetadata & {
30
- encryptedData: EncryptedData;
31
- };
32
- export declare const TRASH_BOOK_ID = "trash";
33
- export declare const NOTE_STATUS: Readonly<{
34
- NONE: 'none';
35
- ACTIVE: 'active';
36
- ON_HOLD: 'onHold';
37
- COMPLETED: 'completed';
38
- DROPPED: 'dropped';
39
- }>;
40
- export declare const NOTE_VISIBILITY: Readonly<{
41
- PRIVATE: 'private';
42
- PUBLIC: 'public';
43
- }>;
44
- declare const validateNote: ValidateFunction<Note>;
45
- export { NoteSchema, validateNote };
46
- export declare const NOTE_TITLE_MAX_LENGTH: number;
47
- export declare function createNoteId(): string;
48
- export declare function validateNoteId(docId: string): boolean;
package/lib/tag.d.ts DELETED
@@ -1,39 +0,0 @@
1
- import type { ValidateFunction } from 'ajv';
2
- import TagSchema from '../json-schema/tag.json';
3
- import type { EncryptedData } from './crypto';
4
- export type TagColor = 'default' | 'red' | 'orange' | 'yellow' | 'olive' | 'green' | 'teal' | 'blue' | 'violet' | 'purple' | 'pink' | 'brown' | 'grey' | 'black';
5
- export declare const TAG_COLOR: Readonly<{
6
- DEFAULT: 'default';
7
- RED: 'red';
8
- ORANGE: 'orange';
9
- YELLOW: 'yellow';
10
- OLIVE: 'olive';
11
- GREEN: 'green';
12
- TEAL: 'teal';
13
- BLUE: 'blue';
14
- VIOLET: 'violet';
15
- PURPLE: 'purple';
16
- PINK: 'pink';
17
- BROWN: 'brown';
18
- GREY: 'grey';
19
- BLACK: 'black';
20
- }>;
21
- export type TagMetadata = {
22
- _id: string;
23
- _rev?: string;
24
- count?: number;
25
- color: TagColor;
26
- updatedAt: number;
27
- createdAt: number;
28
- };
29
- export type Tag = TagMetadata & {
30
- name: string;
31
- };
32
- export type EncryptedTag = TagMetadata & {
33
- encryptedData: EncryptedData;
34
- };
35
- export declare const TAG_DOCID_PREFIX = "tag:";
36
- declare const validateTag: ValidateFunction<Tag>;
37
- export { TagSchema, validateTag };
38
- export declare function createTagId(): string;
39
- export declare function validateTagId(docId: string): boolean;
package/lib/utils.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function createDocId(prefix: string): string;
@@ -1,8 +0,0 @@
1
- import type { ErrorObject } from 'ajv';
2
- export declare function validationErrorsToMessage(errors: ErrorObject[]): string;
3
- export declare class InvalidDataError extends Error {
4
- name: string;
5
- errors: ErrorObject[];
6
- constructor(message: string, errors: ErrorObject[]);
7
- }
8
- export declare function validateDocId(prefix: string, docId: string): boolean;