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.esm.js CHANGED
@@ -1,544 +1,517 @@
1
- import validator from '../validators/note';
2
- import { webcrypto } from 'node:crypto';
3
- import validator$1 from '../validators/book';
4
- import validator$2 from '../validators/tag';
5
- import validator$3 from '../validators/file';
6
-
7
- var $schema$3 = "http://json-schema.org/draft-07/schema#";
8
- var $id$3 = "note";
9
- var title$3 = "Note";
10
- var description$3 = "A note data";
11
- var type$3 = "object";
12
- var properties$3 = {
13
- _id: {
14
- description: "The unique document ID which should start with `note:` and the remains are randomly generated string",
15
- type: "string",
16
- minLength: 6,
17
- maxLength: 128,
18
- pattern: "^note:"
19
- },
20
- _rev: {
21
- description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
22
- type: "string"
23
- },
24
- bookId: {
25
- description: "The notebook ID",
26
- type: "string",
27
- minLength: 5,
28
- maxLength: 128,
29
- pattern: "^(book:|trash$)"
30
- },
31
- title: {
32
- description: "The note title",
33
- type: "string",
34
- maxLength: 256
35
- },
36
- doctype: {
37
- description: "The format type of the body field. It currently can take markdown only, reserved for the future",
38
- type: "string",
39
- "enum": [
40
- "markdown"
41
- ]
42
- },
43
- body: {
44
- description: "The content of the note represented with Markdown",
45
- type: "string",
46
- maxLength: 1048576
47
- },
48
- updatedAt: {
49
- description: "The date time when the note was last updated, represented with Unix timestamps in milliseconds",
50
- type: "number"
51
- },
52
- createdAt: {
53
- description: "The date time when the note was created, represented with Unix timestamps in milliseconds",
54
- type: "number"
55
- },
56
- tags: {
57
- description: "The list of tag IDs",
58
- type: "array",
59
- items: {
60
- type: "string"
1
+ import validator from "../validators/note";
2
+ import validator$1 from "../validators/book";
3
+ import validator$2 from "../validators/tag";
4
+ import validator$3 from "../validators/file";
5
+ //#region json-schema/note.json
6
+ var note_default = {
7
+ $schema: "http://json-schema.org/draft-07/schema#",
8
+ $id: "note",
9
+ title: "Note",
10
+ description: "A note data",
11
+ type: "object",
12
+ properties: {
13
+ "_id": {
14
+ "description": "The unique document ID which should start with `note:` and the remains are randomly generated string",
15
+ "type": "string",
16
+ "minLength": 6,
17
+ "maxLength": 128,
18
+ "pattern": "^note:"
61
19
  },
62
- uniqueItems: true
63
- },
64
- numOfTasks: {
65
- description: "The number of tasks, extracted from body",
66
- type: "number"
67
- },
68
- numOfCheckedTasks: {
69
- description: "The number of checked tasks, extracted from body",
70
- type: "number"
71
- },
72
- migratedBy: {
73
- description: "The type of the data migration",
74
- type: "string",
75
- maxLength: 128
76
- },
77
- status: {
78
- description: "The status of the note",
79
- type: "string",
80
- "enum": [
81
- "none",
82
- "active",
83
- "onHold",
84
- "completed",
85
- "dropped"
86
- ]
87
- },
88
- share: {
89
- description: "The sharing mode of the note",
90
- type: "string",
91
- "enum": [
92
- "private",
93
- "public"
94
- ]
95
- },
96
- pinned: {
97
- description: "Whether the note is pinned to top",
98
- type: "boolean"
99
- },
100
- timestamp: {
101
- description: "The date time when the revision was written, represented with Unix timestamps in milliseconds",
102
- type: "number"
103
- },
104
- _conflicts: {
105
- description: "Conflicted revisions",
106
- type: "array",
107
- items: {
108
- type: "string"
20
+ "_rev": {
21
+ "description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
22
+ "type": "string"
109
23
  },
110
- uniqueItems: true
111
- }
112
- };
113
- var required$3 = [
114
- "_id",
115
- "bookId",
116
- "title",
117
- "doctype",
118
- "body",
119
- "updatedAt",
120
- "createdAt",
121
- "timestamp"
122
- ];
123
- var note = {
124
- $schema: $schema$3,
125
- $id: $id$3,
126
- title: title$3,
127
- description: description$3,
128
- type: type$3,
129
- properties: properties$3,
130
- required: required$3
24
+ "bookId": {
25
+ "description": "The notebook ID",
26
+ "type": "string",
27
+ "minLength": 5,
28
+ "maxLength": 128,
29
+ "pattern": "^(book:|trash$|template$)"
30
+ },
31
+ "title": {
32
+ "description": "The note title",
33
+ "type": "string",
34
+ "maxLength": 256
35
+ },
36
+ "doctype": {
37
+ "description": "The format type of the body field. It currently can take markdown only, reserved for the future",
38
+ "type": "string",
39
+ "enum": ["markdown"]
40
+ },
41
+ "body": {
42
+ "description": "The content of the note represented with Markdown",
43
+ "type": "string",
44
+ "maxLength": 1048576
45
+ },
46
+ "updatedAt": {
47
+ "description": "The date time when the note was last updated, represented with Unix timestamps in milliseconds",
48
+ "type": "number"
49
+ },
50
+ "createdAt": {
51
+ "description": "The date time when the note was created, represented with Unix timestamps in milliseconds",
52
+ "type": "number"
53
+ },
54
+ "tags": {
55
+ "description": "The list of tag IDs",
56
+ "type": "array",
57
+ "items": { "type": "string" },
58
+ "uniqueItems": true
59
+ },
60
+ "numOfTasks": {
61
+ "description": "The number of tasks, extracted from body",
62
+ "type": "number"
63
+ },
64
+ "numOfCheckedTasks": {
65
+ "description": "The number of checked tasks, extracted from body",
66
+ "type": "number"
67
+ },
68
+ "migratedBy": {
69
+ "description": "The type of the data migration",
70
+ "type": "string",
71
+ "maxLength": 128
72
+ },
73
+ "status": {
74
+ "description": "The status of the note",
75
+ "type": "string",
76
+ "enum": [
77
+ "none",
78
+ "active",
79
+ "onHold",
80
+ "completed",
81
+ "dropped"
82
+ ]
83
+ },
84
+ "share": {
85
+ "description": "The sharing mode of the note",
86
+ "type": "string",
87
+ "enum": ["private", "public"]
88
+ },
89
+ "pinned": {
90
+ "description": "Whether the note is pinned to top",
91
+ "type": "boolean"
92
+ },
93
+ "timestamp": {
94
+ "description": "The date time when the revision was written, represented with Unix timestamps in milliseconds",
95
+ "type": "number"
96
+ },
97
+ "_conflicts": {
98
+ "description": "Conflicted revisions",
99
+ "type": "array",
100
+ "items": { "type": "string" },
101
+ "uniqueItems": true
102
+ }
103
+ },
104
+ required: [
105
+ "_id",
106
+ "bookId",
107
+ "title",
108
+ "doctype",
109
+ "body",
110
+ "updatedAt",
111
+ "createdAt",
112
+ "timestamp"
113
+ ]
131
114
  };
132
-
133
- const urlAlphabet =
134
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
135
-
136
- const POOL_SIZE_MULTIPLIER = 128;
137
- let pool, poolOffset;
138
- function fillPool(bytes) {
139
- if (!pool || pool.length < bytes) {
140
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
141
- webcrypto.getRandomValues(pool);
142
- poolOffset = 0;
143
- } else if (poolOffset + bytes > pool.length) {
144
- webcrypto.getRandomValues(pool);
145
- poolOffset = 0;
146
- }
147
- poolOffset += bytes;
115
+ //#endregion
116
+ //#region node_modules/.pnpm/nanoid@6.0.0/node_modules/nanoid/url-alphabet/index.js
117
+ let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
118
+ //#endregion
119
+ //#region node_modules/.pnpm/nanoid@6.0.0/node_modules/nanoid/index.js
120
+ const GET_RANDOM_LIMIT = 65536;
121
+ function fillRandom(buffer) {
122
+ let from = 0;
123
+ while (from < buffer.length) {
124
+ let to = Math.min(from + GET_RANDOM_LIMIT, buffer.length);
125
+ crypto.getRandomValues(buffer.subarray(from, to));
126
+ from = to;
127
+ }
148
128
  }
149
- function nanoid(size = 21) {
150
- fillPool((size |= 0));
151
- let id = '';
152
- for (let i = poolOffset - size; i < poolOffset; i++) {
153
- id += urlAlphabet[pool[i] & 63];
154
- }
155
- return id
129
+ function random(bytes) {
130
+ bytes |= 0;
131
+ if (bytes < 0) throw new RangeError("Wrong ID size");
132
+ let buffer = Buffer.allocUnsafe(bytes);
133
+ fillRandom(buffer);
134
+ return buffer;
156
135
  }
157
-
136
+ function customRandom(alphabet, defaultSize, getRandom) {
137
+ let safeByteCutoff = 256 - 256 % alphabet.length;
138
+ if (safeByteCutoff === 256) {
139
+ let mask = alphabet.length - 1;
140
+ return (size = defaultSize) => {
141
+ if (!size) return "";
142
+ let id = "";
143
+ while (true) {
144
+ let bytes = getRandom(size);
145
+ let i = size;
146
+ while (i--) {
147
+ id += alphabet[bytes[i] & mask];
148
+ if (id.length >= size) return id;
149
+ }
150
+ }
151
+ };
152
+ }
153
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
154
+ return (size = defaultSize) => {
155
+ if (!size) return "";
156
+ let id = "";
157
+ while (true) {
158
+ let bytes = getRandom(step);
159
+ let i = step;
160
+ while (i--) if (bytes[i] < safeByteCutoff) {
161
+ id += alphabet[bytes[i] % alphabet.length];
162
+ if (id.length >= size) return id;
163
+ }
164
+ }
165
+ };
166
+ }
167
+ const POOL_MAX = GET_RANDOM_LIMIT / 2;
168
+ function customAlphabet(alphabet, defaultSize = 21) {
169
+ if (typeof alphabet !== "string" || !alphabet.length || alphabet.length > 256) return customRandom(alphabet, defaultSize, random);
170
+ for (let i = 0; i < alphabet.length; i++) if (alphabet.charCodeAt(i) > 255) return customRandom(alphabet, defaultSize, random);
171
+ let charCodes = Uint8Array.from(alphabet, (str) => {
172
+ return str.charCodeAt(0);
173
+ });
174
+ let alphabetLen = alphabet.length;
175
+ let mask = (2 << 31 - Math.clz32(alphabetLen - 1 | 1)) - 1;
176
+ let pool = "";
177
+ let poolOffset = 0;
178
+ let poolNext = 0;
179
+ return (size = defaultSize) => {
180
+ size |= 0;
181
+ if (size < 0) throw new RangeError("Wrong ID size");
182
+ if (size === 0) return "";
183
+ if (poolOffset + size > pool.length) {
184
+ let target = Math.max(poolNext, size);
185
+ poolNext = Math.min(target * 16, POOL_MAX);
186
+ let buffer = Buffer.allocUnsafe(target);
187
+ if (mask === alphabetLen - 1) {
188
+ fillRandom(buffer);
189
+ for (let i = 0; i < target; i++) buffer[i] = charCodes[buffer[i] & mask];
190
+ } else {
191
+ let randomBytes = Buffer.allocUnsafe(Math.ceil(1.6 * (mask + 1) * target / alphabetLen));
192
+ let accepted = 0;
193
+ while (accepted < target) {
194
+ fillRandom(randomBytes);
195
+ for (let i = 0; i < randomBytes.length; i++) {
196
+ let index = randomBytes[i] & mask;
197
+ if (index < alphabetLen) {
198
+ buffer[accepted++] = charCodes[index];
199
+ if (accepted === target) break;
200
+ }
201
+ }
202
+ }
203
+ }
204
+ pool = buffer.toString("latin1");
205
+ poolOffset = 0;
206
+ }
207
+ poolOffset += size;
208
+ return pool.substring(poolOffset - size, poolOffset);
209
+ };
210
+ }
211
+ const nanoid = customAlphabet(urlAlphabet);
212
+ //#endregion
213
+ //#region src/utils.ts
158
214
  function createDocId(prefix) {
159
- var id = nanoid(8);
160
- return "".concat(prefix).concat(id);
215
+ return `${prefix}${nanoid(8)}`;
161
216
  }
162
-
163
- /******************************************************************************
164
- Copyright (c) Microsoft Corporation.
165
-
166
- Permission to use, copy, modify, and/or distribute this software for any
167
- purpose with or without fee is hereby granted.
168
-
169
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
170
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
171
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
172
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
173
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
174
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
175
- PERFORMANCE OF THIS SOFTWARE.
176
- ***************************************************************************** */
177
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
178
-
179
- var extendStatics = function(d, b) {
180
- extendStatics = Object.setPrototypeOf ||
181
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
182
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
183
- return extendStatics(d, b);
184
- };
185
-
186
- function __extends(d, b) {
187
- if (typeof b !== "function" && b !== null)
188
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
189
- extendStatics(d, b);
190
- function __() { this.constructor = d; }
191
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
192
- }
193
-
194
- var __assign = function() {
195
- __assign = Object.assign || function __assign(t) {
196
- for (var s, i = 1, n = arguments.length; i < n; i++) {
197
- s = arguments[i];
198
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
199
- }
200
- return t;
201
- };
202
- return __assign.apply(this, arguments);
203
- };
204
-
205
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
206
- var e = new Error(message);
207
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
208
- };
209
-
217
+ //#endregion
218
+ //#region src/validator.ts
210
219
  function validationErrorsToMessage(errors) {
211
- if (errors instanceof Array) {
212
- return errors
213
- .map(function (e) {
214
- if (typeof e === 'object') {
215
- return "\"".concat(e.instancePath, "\" ").concat(e.message);
216
- }
217
- else {
218
- return e;
219
- }
220
- })
221
- .join(', ');
222
- }
223
- else {
224
- return errors;
225
- }
220
+ if (errors instanceof Array) return errors.map((e) => {
221
+ if (typeof e === "object") return `"${e.instancePath}" ${e.message}`;
222
+ else return e;
223
+ }).join(", ");
224
+ else return errors;
226
225
  }
227
- var InvalidDataError = /** @class */ (function (_super) {
228
- __extends(InvalidDataError, _super);
229
- function InvalidDataError(message, errors) {
230
- var _this = _super.call(this, message + ' ' + validationErrorsToMessage(errors)) || this;
231
- _this.name = 'InvalidDataError';
232
- _this.errors = errors;
233
- return _this;
234
- }
235
- return InvalidDataError;
236
- }(Error));
226
+ var InvalidDataError = class extends Error {
227
+ constructor(message, errors) {
228
+ super(message + " " + validationErrorsToMessage(errors));
229
+ this.name = "InvalidDataError";
230
+ this.errors = errors;
231
+ }
232
+ };
237
233
  function validateDocId(prefix, docId) {
238
- if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) {
239
- throw new Error('Invalid document ID');
240
- }
241
- return true;
234
+ if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) throw new Error("Invalid document ID");
235
+ return true;
242
236
  }
243
-
244
- var NOTE_DOCID_PREFIX = 'note:';
245
- var TRASH_BOOK_ID = 'trash';
246
- var NOTE_STATUS = {
247
- NONE: 'none',
248
- ACTIVE: 'active',
249
- ON_HOLD: 'onHold',
250
- COMPLETED: 'completed',
251
- DROPPED: 'dropped'
237
+ //#endregion
238
+ //#region src/note.ts
239
+ const NOTE_DOCID_PREFIX = "note:";
240
+ const TRASH_BOOK_ID = "trash";
241
+ const TEMPLATE_BOOK_ID = "template";
242
+ const NOTE_STATUS = {
243
+ NONE: "none",
244
+ ACTIVE: "active",
245
+ ON_HOLD: "onHold",
246
+ COMPLETED: "completed",
247
+ DROPPED: "dropped"
252
248
  };
253
- var NOTE_VISIBILITY = {
254
- PRIVATE: 'private',
255
- PUBLIC: 'public'
249
+ const NOTE_VISIBILITY = {
250
+ PRIVATE: "private",
251
+ PUBLIC: "public"
256
252
  };
257
- var validateNote = validator;
258
- var NOTE_TITLE_MAX_LENGTH = 256;
253
+ const validateNote = validator;
254
+ const NOTE_TITLE_MAX_LENGTH = 256;
259
255
  function createNoteId() {
260
- return createDocId(NOTE_DOCID_PREFIX);
256
+ return createDocId(NOTE_DOCID_PREFIX);
261
257
  }
262
258
  function validateNoteId(docId) {
263
- return validateDocId(NOTE_DOCID_PREFIX, docId);
259
+ return validateDocId(NOTE_DOCID_PREFIX, docId);
264
260
  }
265
-
266
- var $schema$2 = "http://json-schema.org/draft-07/schema#";
267
- var $id$2 = "book";
268
- var title$2 = "Book";
269
- var description$2 = "A notebook data";
270
- var type$2 = "object";
271
- var properties$2 = {
272
- _id: {
273
- description: "The unique notebook ID which should start with `book:` and the remains are randomly generated string",
274
- type: "string",
275
- minLength: 6,
276
- maxLength: 128,
277
- pattern: "^book:"
278
- },
279
- _rev: {
280
- description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
281
- type: "string"
282
- },
283
- name: {
284
- description: "The notebook name",
285
- type: "string",
286
- minLength: 1,
287
- maxLength: 64
288
- },
289
- updatedAt: {
290
- description: "The date time when the notebook was last updated, represented with Unix timestamps in milliseconds",
291
- type: "number"
292
- },
293
- createdAt: {
294
- description: "The date time when the notebook was created, represented with Unix timestamps in milliseconds",
295
- type: "number"
296
- },
297
- count: {
298
- description: "It indicates the number of notes in the notebook",
299
- type: "number"
300
- },
301
- parentBookId: {
302
- description: "The ID of the parent notebook",
303
- type: [
304
- "string",
305
- "null"
306
- ]
307
- },
308
- order: {
309
- 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.",
310
- type: "number"
311
- },
312
- icon: {
313
- description: "Custom icon for the notebook",
314
- type: "object",
315
- oneOf: [
316
- {
317
- properties: {
318
- type: {
319
- description: "Icon storage type",
261
+ //#endregion
262
+ //#region json-schema/book.json
263
+ var book_default = {
264
+ $schema: "http://json-schema.org/draft-07/schema#",
265
+ $id: "book",
266
+ title: "Book",
267
+ description: "A notebook data",
268
+ type: "object",
269
+ properties: {
270
+ "_id": {
271
+ "description": "The unique notebook ID which should start with `book:` and the remains are randomly generated string",
272
+ "type": "string",
273
+ "minLength": 6,
274
+ "maxLength": 128,
275
+ "pattern": "^book:"
276
+ },
277
+ "_rev": {
278
+ "description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
279
+ "type": "string"
280
+ },
281
+ "name": {
282
+ "description": "The notebook name",
283
+ "type": "string",
284
+ "minLength": 1,
285
+ "maxLength": 64
286
+ },
287
+ "updatedAt": {
288
+ "description": "The date time when the notebook was last updated, represented with Unix timestamps in milliseconds",
289
+ "type": "number"
290
+ },
291
+ "createdAt": {
292
+ "description": "The date time when the notebook was created, represented with Unix timestamps in milliseconds",
293
+ "type": "number"
294
+ },
295
+ "count": {
296
+ "description": "It indicates the number of notes in the notebook",
297
+ "type": "number"
298
+ },
299
+ "parentBookId": {
300
+ "description": "The ID of the parent notebook",
301
+ "type": ["string", "null"]
302
+ },
303
+ "order": {
304
+ "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.",
305
+ "type": "number"
306
+ },
307
+ "icon": {
308
+ "description": "Custom icon for the notebook",
309
+ "type": "object",
310
+ "oneOf": [{
311
+ "properties": {
312
+ "type": {
313
+ "description": "Icon storage type",
320
314
  "const": "inline"
321
315
  },
322
- svg: {
323
- description: "The SVG icon data. Must be less than 256kb",
324
- type: "string",
325
- maxLength: 262144
316
+ "svg": {
317
+ "description": "The SVG icon data. Must be less than 256kb",
318
+ "type": "string",
319
+ "maxLength": 262144
326
320
  }
327
321
  },
328
- required: [
329
- "type",
330
- "svg"
331
- ]
332
- },
333
- {
334
- properties: {
335
- type: {
336
- description: "Icon storage type",
322
+ "required": ["type", "svg"]
323
+ }, {
324
+ "properties": {
325
+ "type": {
326
+ "description": "Icon storage type",
337
327
  "const": "file"
338
328
  },
339
- docId: {
340
- description: "The document ID for the attachment file",
341
- type: "string",
342
- pattern: "^file:",
343
- minLength: 6,
344
- maxLength: 128
329
+ "docId": {
330
+ "description": "The document ID for the attachment file",
331
+ "type": "string",
332
+ "pattern": "^file:",
333
+ "minLength": 6,
334
+ "maxLength": 128
345
335
  }
346
336
  },
347
- required: [
348
- "type",
349
- "docId"
350
- ]
351
- }
352
- ]
353
- }
354
- };
355
- var required$2 = [
356
- "_id",
357
- "name",
358
- "updatedAt",
359
- "createdAt"
360
- ];
361
- var book = {
362
- $schema: $schema$2,
363
- $id: $id$2,
364
- title: title$2,
365
- description: description$2,
366
- type: type$2,
367
- properties: properties$2,
368
- required: required$2
337
+ "required": ["type", "docId"]
338
+ }]
339
+ }
340
+ },
341
+ required: [
342
+ "_id",
343
+ "name",
344
+ "updatedAt",
345
+ "createdAt"
346
+ ]
369
347
  };
370
-
371
- var BOOK_DOCID_PREFIX = 'book:';
372
- var validateBook = validator$1;
348
+ //#endregion
349
+ //#region src/book.ts
350
+ const BOOK_DOCID_PREFIX = "book:";
351
+ const validateBook = validator$1;
373
352
  function createBookId() {
374
- return createDocId(BOOK_DOCID_PREFIX);
353
+ return createDocId(BOOK_DOCID_PREFIX);
375
354
  }
376
355
  function validateBookId(docId) {
377
- return validateDocId(BOOK_DOCID_PREFIX, docId);
356
+ return validateDocId(BOOK_DOCID_PREFIX, docId);
378
357
  }
379
-
380
- var $schema$1 = "http://json-schema.org/draft-07/schema#";
381
- var $id$1 = "tag";
382
- var title$1 = "Tag";
383
- var description$1 = "A note tag";
384
- var type$1 = "object";
385
- var properties$1 = {
386
- _id: {
387
- description: "The unique tag ID which should start with `tag:` and the remains are randomly generated string",
388
- type: "string",
389
- minLength: 6,
390
- maxLength: 128,
391
- pattern: "^tag:"
392
- },
393
- _rev: {
394
- description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
395
- type: "string"
396
- },
397
- name: {
398
- description: "The name of the tag",
399
- type: "string",
400
- maxLength: 64
401
- },
402
- count: {
403
- description: "It indicates the number of notes with the tag",
404
- type: "number"
405
- },
406
- color: {
407
- description: "The color type of the tag",
408
- type: "string",
409
- "enum": [
410
- "default",
411
- "red",
412
- "orange",
413
- "yellow",
414
- "olive",
415
- "green",
416
- "teal",
417
- "blue",
418
- "violet",
419
- "purple",
420
- "pink",
421
- "brown",
422
- "grey",
423
- "black"
424
- ]
425
- },
426
- updatedAt: {
427
- description: "The date time when the tag was last updated, represented with Unix timestamps in milliseconds",
428
- type: "number"
429
- },
430
- createdAt: {
431
- description: "The date time when the tag was created, represented with Unix timestamps in milliseconds",
432
- type: "number"
433
- }
434
- };
435
- var required$1 = [
436
- "_id",
437
- "name",
438
- "count",
439
- "updatedAt",
440
- "createdAt"
441
- ];
442
- var tag = {
443
- $schema: $schema$1,
444
- $id: $id$1,
445
- title: title$1,
446
- description: description$1,
447
- type: type$1,
448
- properties: properties$1,
449
- required: required$1
358
+ //#endregion
359
+ //#region json-schema/tag.json
360
+ var tag_default = {
361
+ $schema: "http://json-schema.org/draft-07/schema#",
362
+ $id: "tag",
363
+ title: "Tag",
364
+ description: "A note tag",
365
+ type: "object",
366
+ properties: {
367
+ "_id": {
368
+ "description": "The unique tag ID which should start with `tag:` and the remains are randomly generated string",
369
+ "type": "string",
370
+ "minLength": 6,
371
+ "maxLength": 128,
372
+ "pattern": "^tag:"
373
+ },
374
+ "_rev": {
375
+ "description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
376
+ "type": "string"
377
+ },
378
+ "name": {
379
+ "description": "The name of the tag",
380
+ "type": "string",
381
+ "maxLength": 64
382
+ },
383
+ "count": {
384
+ "description": "It indicates the number of notes with the tag",
385
+ "type": "number"
386
+ },
387
+ "color": {
388
+ "description": "The color type of the tag",
389
+ "type": "string",
390
+ "enum": [
391
+ "default",
392
+ "red",
393
+ "orange",
394
+ "yellow",
395
+ "olive",
396
+ "green",
397
+ "teal",
398
+ "blue",
399
+ "violet",
400
+ "purple",
401
+ "pink",
402
+ "brown",
403
+ "grey",
404
+ "black"
405
+ ]
406
+ },
407
+ "updatedAt": {
408
+ "description": "The date time when the tag was last updated, represented with Unix timestamps in milliseconds",
409
+ "type": "number"
410
+ },
411
+ "createdAt": {
412
+ "description": "The date time when the tag was created, represented with Unix timestamps in milliseconds",
413
+ "type": "number"
414
+ }
415
+ },
416
+ required: [
417
+ "_id",
418
+ "name",
419
+ "count",
420
+ "updatedAt",
421
+ "createdAt"
422
+ ]
450
423
  };
451
-
452
- var TAG_COLOR = {
453
- DEFAULT: 'default',
454
- RED: 'red',
455
- ORANGE: 'orange',
456
- YELLOW: 'yellow',
457
- OLIVE: 'olive',
458
- GREEN: 'green',
459
- TEAL: 'teal',
460
- BLUE: 'blue',
461
- VIOLET: 'violet',
462
- PURPLE: 'purple',
463
- PINK: 'pink',
464
- BROWN: 'brown',
465
- GREY: 'grey',
466
- BLACK: 'black'
424
+ //#endregion
425
+ //#region src/tag.ts
426
+ const TAG_COLOR = {
427
+ DEFAULT: "default",
428
+ RED: "red",
429
+ ORANGE: "orange",
430
+ YELLOW: "yellow",
431
+ OLIVE: "olive",
432
+ GREEN: "green",
433
+ TEAL: "teal",
434
+ BLUE: "blue",
435
+ VIOLET: "violet",
436
+ PURPLE: "purple",
437
+ PINK: "pink",
438
+ BROWN: "brown",
439
+ GREY: "grey",
440
+ BLACK: "black"
467
441
  };
468
- var TAG_DOCID_PREFIX = 'tag:';
469
- var validateTag = validator$2;
442
+ const TAG_DOCID_PREFIX = "tag:";
443
+ const validateTag = validator$2;
470
444
  function createTagId() {
471
- return createDocId(TAG_DOCID_PREFIX);
445
+ return createDocId(TAG_DOCID_PREFIX);
472
446
  }
473
447
  function validateTagId(docId) {
474
- return validateDocId(TAG_DOCID_PREFIX, docId);
448
+ return validateDocId(TAG_DOCID_PREFIX, docId);
475
449
  }
476
-
477
- var $schema = "http://json-schema.org/draft-07/schema#";
478
- var $id = "file";
479
- var title = "File";
480
- var description = "An attachment file";
481
- var type = "object";
482
- var properties = {
483
- _id: {
484
- description: "The unique document ID which should start with `file:` and the remains are randomly generated string",
485
- type: "string",
486
- minLength: 6,
487
- maxLength: 128,
488
- pattern: "^file:"
489
- },
490
- _rev: {
491
- description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
492
- type: "string"
493
- },
494
- name: {
495
- description: "The file name",
496
- type: "string",
497
- minLength: 1,
498
- maxLength: 128
499
- },
500
- createdAt: {
501
- description: "The date time when the note was created, represented with Unix timestamps in milliseconds",
502
- type: "number"
503
- },
504
- contentType: {
505
- description: "The MIME type of the content",
506
- type: "string",
507
- "enum": [
508
- "image/png",
509
- "image/jpeg",
510
- "image/jpg",
511
- "image/svg+xml",
512
- "image/gif",
513
- "image/heic",
514
- "image/heif"
515
- ],
516
- maxLength: 128
517
- },
518
- contentLength: {
519
- description: "The content length of the file",
520
- type: "number",
521
- maximum: 10485760
522
- },
523
- publicIn: {
524
- description: "An array of the note IDs where the file is included",
525
- type: "array",
526
- items: {
527
- type: "string"
450
+ //#endregion
451
+ //#region json-schema/file.json
452
+ var file_default = {
453
+ $schema: "http://json-schema.org/draft-07/schema#",
454
+ $id: "file",
455
+ title: "File",
456
+ description: "An attachment file",
457
+ type: "object",
458
+ properties: {
459
+ "_id": {
460
+ "description": "The unique document ID which should start with `file:` and the remains are randomly generated string",
461
+ "type": "string",
462
+ "minLength": 6,
463
+ "maxLength": 128,
464
+ "pattern": "^file:"
528
465
  },
529
- uniqueItems: true
530
- },
531
- _attachments: {
532
- description: "The attachment file",
533
- type: "object",
534
- properties: {
535
- index: {
536
- description: "The attachment file",
537
- type: "object",
538
- properties: {
539
- content_type: {
540
- description: "The content type of the file",
541
- type: "string",
466
+ "_rev": {
467
+ "description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
468
+ "type": "string"
469
+ },
470
+ "name": {
471
+ "description": "The file name",
472
+ "type": "string",
473
+ "minLength": 1,
474
+ "maxLength": 128
475
+ },
476
+ "createdAt": {
477
+ "description": "The date time when the note was created, represented with Unix timestamps in milliseconds",
478
+ "type": "number"
479
+ },
480
+ "contentType": {
481
+ "description": "The MIME type of the content",
482
+ "type": "string",
483
+ "enum": [
484
+ "image/png",
485
+ "image/jpeg",
486
+ "image/jpg",
487
+ "image/svg+xml",
488
+ "image/gif",
489
+ "image/heic",
490
+ "image/heif"
491
+ ],
492
+ "maxLength": 128
493
+ },
494
+ "contentLength": {
495
+ "description": "The content length of the file",
496
+ "type": "number",
497
+ "maximum": 10485760
498
+ },
499
+ "publicIn": {
500
+ "description": "An array of the note IDs where the file is included",
501
+ "type": "array",
502
+ "items": { "type": "string" },
503
+ "uniqueItems": true
504
+ },
505
+ "_attachments": {
506
+ "description": "The attachment file",
507
+ "type": "object",
508
+ "properties": { "index": {
509
+ "description": "The attachment file",
510
+ "type": "object",
511
+ "properties": {
512
+ "content_type": {
513
+ "description": "The content type of the file",
514
+ "type": "string",
542
515
  "enum": [
543
516
  "image/png",
544
517
  "image/jpeg",
@@ -549,66 +522,54 @@ var properties = {
549
522
  "image/heif"
550
523
  ]
551
524
  },
552
- data: {
553
- description: "The file data",
554
- type: [
555
- "string",
556
- "object"
557
- ]
525
+ "data": {
526
+ "description": "The file data",
527
+ "type": ["string", "object"]
558
528
  }
559
529
  },
560
- required: [
561
- "content_type",
562
- "data"
563
- ]
564
- }
565
- },
566
- required: [
567
- "index"
568
- ]
569
- }
530
+ "required": ["content_type", "data"]
531
+ } },
532
+ "required": ["index"]
533
+ }
534
+ },
535
+ required: [
536
+ "_id",
537
+ "name",
538
+ "createdAt",
539
+ "contentType",
540
+ "contentLength",
541
+ "publicIn",
542
+ "_attachments"
543
+ ]
570
544
  };
571
- var required = [
572
- "_id",
573
- "name",
574
- "createdAt",
575
- "contentType",
576
- "contentLength",
577
- "publicIn",
578
- "_attachments"
545
+ //#endregion
546
+ //#region src/file.ts
547
+ const supportedImageFileTypes = [
548
+ "image/png",
549
+ "image/jpeg",
550
+ "image/jpg",
551
+ "image/svg+xml",
552
+ "image/gif",
553
+ "image/heic",
554
+ "image/heif"
579
555
  ];
580
- var file = {
581
- $schema: $schema,
582
- $id: $id,
583
- title: title,
584
- description: description,
585
- type: type,
586
- properties: properties,
587
- required: required
556
+ const SUPPORTED_IMAGE_MIME_TYPES = {
557
+ ...supportedImageFileTypes.reduce((hash, ft) => ({
558
+ ...hash,
559
+ [ft.split("/")[1]]: ft
560
+ }), {}),
561
+ jpg: "image/jpeg"
588
562
  };
589
-
590
- var supportedImageFileTypes = [
591
- 'image/png',
592
- 'image/jpeg',
593
- 'image/jpg',
594
- 'image/svg+xml',
595
- 'image/gif',
596
- 'image/heic',
597
- 'image/heif'
598
- ];
599
- var SUPPORTED_IMAGE_MIME_TYPES = __assign(__assign({}, supportedImageFileTypes.reduce(function (hash, ft) {
600
- var _a;
601
- return (__assign(__assign({}, hash), (_a = {}, _a[ft.split('/')[1]] = ft, _a)));
602
- }, {})), { jpg: 'image/jpeg' });
603
- var maxAttachmentFileSize = 10 * 1024 * 1024;
604
- var FILE_DOCID_PREFIX = 'file:';
605
- var validateFile = validator$3;
563
+ const maxAttachmentFileSize = 10 * 1024 * 1024;
564
+ const FILE_DOCID_PREFIX = "file:";
565
+ const validateFile = validator$3;
606
566
  function createFileId() {
607
- return createDocId(FILE_DOCID_PREFIX);
567
+ return createDocId(FILE_DOCID_PREFIX);
608
568
  }
609
569
  function validateFileId(docId) {
610
- return validateDocId(FILE_DOCID_PREFIX, docId);
570
+ return validateDocId(FILE_DOCID_PREFIX, docId);
611
571
  }
572
+ //#endregion
573
+ export { BOOK_DOCID_PREFIX, book_default as BookSchema, FILE_DOCID_PREFIX, file_default as FileSchema, InvalidDataError, NOTE_DOCID_PREFIX, NOTE_STATUS, NOTE_TITLE_MAX_LENGTH, NOTE_VISIBILITY, note_default as NoteSchema, SUPPORTED_IMAGE_MIME_TYPES, TAG_COLOR, TAG_DOCID_PREFIX, TEMPLATE_BOOK_ID, TRASH_BOOK_ID, tag_default as TagSchema, createBookId, createDocId, createFileId, createNoteId, createTagId, maxAttachmentFileSize, supportedImageFileTypes, validateBook, validateBookId, validateDocId, validateFile, validateFileId, validateNote, validateNoteId, validateTag, validateTagId, validationErrorsToMessage };
612
574
 
613
- export { BOOK_DOCID_PREFIX, book as BookSchema, FILE_DOCID_PREFIX, file as FileSchema, InvalidDataError, NOTE_DOCID_PREFIX, NOTE_STATUS, NOTE_TITLE_MAX_LENGTH, NOTE_VISIBILITY, note as NoteSchema, SUPPORTED_IMAGE_MIME_TYPES, TAG_COLOR, TAG_DOCID_PREFIX, TRASH_BOOK_ID, tag as TagSchema, createBookId, createDocId, createFileId, createNoteId, createTagId, maxAttachmentFileSize, supportedImageFileTypes, validateBook, validateBookId, validateDocId, validateFile, validateFileId, validateNote, validateNoteId, validateTag, validateTagId, validationErrorsToMessage };
614
- //# sourceMappingURL=index.esm.js.map
575
+ //# sourceMappingURL=index.esm.js.map