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