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