inkdrop-model 2.11.5 → 2.11.6

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":["scopedUrlAlphabet","validator","validator","validator","validator"],"sources":["../json-schema/note.json","../node_modules/.pnpm/nanoid@5.1.15/node_modules/nanoid/url-alphabet/index.js","../node_modules/.pnpm/nanoid@5.1.15/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 { webcrypto as crypto } from 'node:crypto'\n\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet } from './url-alphabet/index.js'\n\nconst POOL_SIZE_MULTIPLIER = 128\nlet pool, poolOffset\n\nfunction fillPool(bytes) {\n if (bytes < 0) throw new RangeError('Wrong ID size')\n try {\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 } catch (e) {\n pool = undefined\n throw e\n }\n poolOffset += bytes\n}\n\nexport function random(bytes) {\n fillPool((bytes |= 0))\n return pool.subarray(poolOffset - bytes, poolOffset)\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\nexport function customAlphabet(alphabet, size = 21) {\n return customRandom(alphabet, size, random)\n}\n\nexport function nanoid(size = 21) {\n fillPool((size |= 0))\n\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"],"x_google_ignoreList":[1,2],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,IAAW,cACT;;;ACKF,MAAM,uBAAuB;AAC7B,IAAI,MAAM;AAEV,SAAS,SAAS,OAAO;CACvB,IAAI,QAAQ,GAAG,MAAM,IAAI,WAAW,eAAe;CACnD,IAAI;EACF,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO;GAChC,OAAO,OAAO,YAAY,QAAQ,oBAAoB;GACtD,YAAA,UAAO,gBAAgB,IAAI;GAC3B,aAAa;EACf,OAAO,IAAI,aAAa,QAAQ,KAAK,QAAQ;GAC3C,YAAA,UAAO,gBAAgB,IAAI;GAC3B,aAAa;EACf;CACF,SAAS,GAAG;EACV,OAAO,KAAA;EACP,MAAM;CACR;CACA,cAAc;AAChB;AAiDA,SAAgB,OAAO,OAAO,IAAI;CAChC,SAAU,QAAQ,CAAE;CAEpB,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,aAAa,MAAM,IAAI,YAAY,KAC9C,MAAMA,YAAkB,KAAK,KAAK;CAEpC,OAAO;AACT;;;AChFA,SAAgB,YAAY,QAAwB;CAElD,OAAO,GAAG,SADC,OAAO,CACE;AACtB;;;ACHA,SAAgB,0BAA0B,QAA+B;CACvE,IAAI,kBAAkB,OACpB,OAAO,OACJ,KAAI,MAAK;EACR,IAAI,OAAO,MAAM,UACf,OAAO,IAAI,EAAE,aAAa,IAAI,EAAE;OAEhC,OAAO;CAEX,CAAC,CAAC,CACD,KAAK,IAAI;MA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qCC,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("node:crypto"),require("../validators/book"),require("../validators/tag"),require("../validators/file")):typeof define==`function`&&define.amd?define([`exports`,`../validators/note`,`node:crypto`,`../validators/book`,`../validators/tag`,`../validators/file`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.InkdropModel={},e.validators_note,e.node_crypto,e.validators_book,e.validators_tag,e.validators_file))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},p=(e,t,n)=>(n=e==null?{}:o(u(e)),f(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));t=p(t),r=p(r),i=p(i),a=p(a);var m={$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 h,g;function _(e){if(e<0)throw RangeError(`Wrong ID size`);try{!h||h.length<e?(h=Buffer.allocUnsafe(e*128),n.webcrypto.getRandomValues(h),g=0):g+e>h.length&&(n.webcrypto.getRandomValues(h),g=0)}catch(e){throw h=void 0,e}g+=e}function v(e=21){_(e|=0);let t=``;for(let n=g-e;n<g;n++)t+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[h[n]&63];return t}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=r.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=i.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=a.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 m}}),e.SUPPORTED_IMAGE_MIME_TYPES=H,e.TAG_COLOR=F,e.TAG_DOCID_PREFIX=I,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,47 @@
1
1
  {
2
2
  "name": "inkdrop-model",
3
- "version": "2.11.5",
3
+ "version": "2.11.6",
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__",
9
+ "lint": "oxlint",
10
+ "format": "oxfmt",
10
11
  "test": "jest --config jest.config.js",
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.9.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
24
  "@types/jest": "^30.0.0",
26
- "ajv": "^8.18.0",
25
+ "@types/node": "^26.0.0",
26
+ "ajv": "^8.20.0",
27
27
  "ajv-cli": "^5.0.0",
28
28
  "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"
29
+ "jest": "^30.4.2",
30
+ "nanoid": "^5.1.15",
31
+ "npm-run-all2": "^9.0.2",
32
+ "oxfmt": "0.56.0",
33
+ "oxlint": "1.71.0",
34
+ "ts-jest": "^29.4.11",
35
+ "tsdown": "0.22.3",
36
+ "typescript": "^6.0.3",
37
+ "yaml": "^2.9.0"
40
38
  },
41
39
  "types": "lib/index.d.ts",
42
40
  "main": "lib/index.js",
43
41
  "unpkg": "lib/index.umd.js",
44
42
  "module": "lib/index.esm.js",
43
+ "browser": "lib/index.browser.js",
44
+ "react-native": "lib/index.browser.js",
45
45
  "keywords": [
46
46
  "json-schema"
47
47
  ],
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;