inkdrop-model 2.11.4 → 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 +453 -534
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +504 -540
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/package.json +21 -22
- 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,519 +1,450 @@
|
|
|
1
|
-
import validator from
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
|
121
|
+
const POOL_SIZE_MULTIPLIER = 128;
|
|
122
|
+
let pool, poolOffset;
|
|
123
|
+
function fillPool(bytes) {
|
|
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;
|
|
139
|
+
}
|
|
140
|
+
function nanoid(size = 21) {
|
|
141
|
+
fillPool(size |= 0);
|
|
142
|
+
let id = "";
|
|
143
|
+
for (let i = poolOffset - size; i < poolOffset; i++) id += urlAlphabet[pool[i] & 63];
|
|
144
|
+
return id;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/utils.ts
|
|
133
148
|
function createDocId(prefix) {
|
|
134
|
-
|
|
135
|
-
return "".concat(prefix).concat(id);
|
|
149
|
+
return `${prefix}${nanoid(8)}`;
|
|
136
150
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
Copyright (c) Microsoft Corporation.
|
|
140
|
-
|
|
141
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
142
|
-
purpose with or without fee is hereby granted.
|
|
143
|
-
|
|
144
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
145
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
146
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
147
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
148
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
149
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
150
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
151
|
-
***************************************************************************** */
|
|
152
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
153
|
-
|
|
154
|
-
var extendStatics = function(d, b) {
|
|
155
|
-
extendStatics = Object.setPrototypeOf ||
|
|
156
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
157
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
158
|
-
return extendStatics(d, b);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
function __extends(d, b) {
|
|
162
|
-
if (typeof b !== "function" && b !== null)
|
|
163
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
164
|
-
extendStatics(d, b);
|
|
165
|
-
function __() { this.constructor = d; }
|
|
166
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
var __assign = function() {
|
|
170
|
-
__assign = Object.assign || function __assign(t) {
|
|
171
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
172
|
-
s = arguments[i];
|
|
173
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
174
|
-
}
|
|
175
|
-
return t;
|
|
176
|
-
};
|
|
177
|
-
return __assign.apply(this, arguments);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
181
|
-
var e = new Error(message);
|
|
182
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
183
|
-
};
|
|
184
|
-
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/validator.ts
|
|
185
153
|
function validationErrorsToMessage(errors) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
return e;
|
|
194
|
-
}
|
|
195
|
-
})
|
|
196
|
-
.join(', ');
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
return errors;
|
|
200
|
-
}
|
|
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;
|
|
201
159
|
}
|
|
202
|
-
var InvalidDataError =
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
return InvalidDataError;
|
|
211
|
-
}(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
|
+
};
|
|
212
167
|
function validateDocId(prefix, docId) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
return true;
|
|
168
|
+
if (!docId.startsWith(prefix) || docId.length <= 5 || docId.length > 128) throw new Error("Invalid document ID");
|
|
169
|
+
return true;
|
|
217
170
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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"
|
|
227
181
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
182
|
+
const NOTE_VISIBILITY = {
|
|
183
|
+
PRIVATE: "private",
|
|
184
|
+
PUBLIC: "public"
|
|
231
185
|
};
|
|
232
|
-
|
|
233
|
-
|
|
186
|
+
const validateNote = validator;
|
|
187
|
+
const NOTE_TITLE_MAX_LENGTH = 256;
|
|
234
188
|
function createNoteId() {
|
|
235
|
-
|
|
189
|
+
return createDocId(NOTE_DOCID_PREFIX);
|
|
236
190
|
}
|
|
237
191
|
function validateNoteId(docId) {
|
|
238
|
-
|
|
192
|
+
return validateDocId(NOTE_DOCID_PREFIX, docId);
|
|
239
193
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
"
|
|
280
|
-
"null"
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
type: {
|
|
294
|
-
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",
|
|
295
247
|
"const": "inline"
|
|
296
248
|
},
|
|
297
|
-
svg: {
|
|
298
|
-
description: "The SVG icon data. Must be less than 256kb",
|
|
299
|
-
type: "string",
|
|
300
|
-
maxLength: 262144
|
|
249
|
+
"svg": {
|
|
250
|
+
"description": "The SVG icon data. Must be less than 256kb",
|
|
251
|
+
"type": "string",
|
|
252
|
+
"maxLength": 262144
|
|
301
253
|
}
|
|
302
254
|
},
|
|
303
|
-
required: [
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
{
|
|
309
|
-
properties: {
|
|
310
|
-
type: {
|
|
311
|
-
description: "Icon storage type",
|
|
255
|
+
"required": ["type", "svg"]
|
|
256
|
+
}, {
|
|
257
|
+
"properties": {
|
|
258
|
+
"type": {
|
|
259
|
+
"description": "Icon storage type",
|
|
312
260
|
"const": "file"
|
|
313
261
|
},
|
|
314
|
-
docId: {
|
|
315
|
-
description: "The document ID for the attachment file",
|
|
316
|
-
type: "string",
|
|
317
|
-
pattern: "^file:",
|
|
318
|
-
minLength: 6,
|
|
319
|
-
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
|
|
320
268
|
}
|
|
321
269
|
},
|
|
322
|
-
required: [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
270
|
+
"required": ["type", "docId"]
|
|
271
|
+
}]
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
required: [
|
|
275
|
+
"_id",
|
|
276
|
+
"name",
|
|
277
|
+
"updatedAt",
|
|
278
|
+
"createdAt"
|
|
279
|
+
]
|
|
329
280
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
"createdAt"
|
|
335
|
-
];
|
|
336
|
-
var book = {
|
|
337
|
-
$schema: $schema$2,
|
|
338
|
-
$id: $id$2,
|
|
339
|
-
title: title$2,
|
|
340
|
-
description: description$2,
|
|
341
|
-
type: type$2,
|
|
342
|
-
properties: properties$2,
|
|
343
|
-
required: required$2
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
var BOOK_DOCID_PREFIX = 'book:';
|
|
347
|
-
var validateBook = validator$1;
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/book.ts
|
|
283
|
+
const BOOK_DOCID_PREFIX = "book:";
|
|
284
|
+
const validateBook = validator$1;
|
|
348
285
|
function createBookId() {
|
|
349
|
-
|
|
286
|
+
return createDocId(BOOK_DOCID_PREFIX);
|
|
350
287
|
}
|
|
351
288
|
function validateBookId(docId) {
|
|
352
|
-
|
|
289
|
+
return validateDocId(BOOK_DOCID_PREFIX, docId);
|
|
353
290
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
var
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
-
$id: $id$1,
|
|
420
|
-
title: title$1,
|
|
421
|
-
description: description$1,
|
|
422
|
-
type: type$1,
|
|
423
|
-
properties: properties$1,
|
|
424
|
-
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
|
+
]
|
|
425
356
|
};
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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"
|
|
442
374
|
};
|
|
443
|
-
|
|
444
|
-
|
|
375
|
+
const TAG_DOCID_PREFIX = "tag:";
|
|
376
|
+
const validateTag = validator$2;
|
|
445
377
|
function createTagId() {
|
|
446
|
-
|
|
378
|
+
return createDocId(TAG_DOCID_PREFIX);
|
|
447
379
|
}
|
|
448
380
|
function validateTagId(docId) {
|
|
449
|
-
|
|
381
|
+
return validateDocId(TAG_DOCID_PREFIX, docId);
|
|
450
382
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
description: "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
|
|
467
|
-
type: "string"
|
|
468
|
-
},
|
|
469
|
-
name: {
|
|
470
|
-
description: "The file name",
|
|
471
|
-
type: "string",
|
|
472
|
-
minLength: 1,
|
|
473
|
-
maxLength: 128
|
|
474
|
-
},
|
|
475
|
-
createdAt: {
|
|
476
|
-
description: "The date time when the note was created, represented with Unix timestamps in milliseconds",
|
|
477
|
-
type: "number"
|
|
478
|
-
},
|
|
479
|
-
contentType: {
|
|
480
|
-
description: "The MIME type of the content",
|
|
481
|
-
type: "string",
|
|
482
|
-
"enum": [
|
|
483
|
-
"image/png",
|
|
484
|
-
"image/jpeg",
|
|
485
|
-
"image/jpg",
|
|
486
|
-
"image/svg+xml",
|
|
487
|
-
"image/gif",
|
|
488
|
-
"image/heic",
|
|
489
|
-
"image/heif"
|
|
490
|
-
],
|
|
491
|
-
maxLength: 128
|
|
492
|
-
},
|
|
493
|
-
contentLength: {
|
|
494
|
-
description: "The content length of the file",
|
|
495
|
-
type: "number",
|
|
496
|
-
maximum: 10485760
|
|
497
|
-
},
|
|
498
|
-
publicIn: {
|
|
499
|
-
description: "An array of the note IDs where the file is included",
|
|
500
|
-
type: "array",
|
|
501
|
-
items: {
|
|
502
|
-
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:"
|
|
503
398
|
},
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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",
|
|
517
448
|
"enum": [
|
|
518
449
|
"image/png",
|
|
519
450
|
"image/jpeg",
|
|
@@ -524,66 +455,54 @@ var properties = {
|
|
|
524
455
|
"image/heif"
|
|
525
456
|
]
|
|
526
457
|
},
|
|
527
|
-
data: {
|
|
528
|
-
description: "The file data",
|
|
529
|
-
type: [
|
|
530
|
-
"string",
|
|
531
|
-
"object"
|
|
532
|
-
]
|
|
458
|
+
"data": {
|
|
459
|
+
"description": "The file data",
|
|
460
|
+
"type": ["string", "object"]
|
|
533
461
|
}
|
|
534
462
|
},
|
|
535
|
-
required: [
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
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
|
+
]
|
|
545
477
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
"
|
|
550
|
-
"
|
|
551
|
-
"
|
|
552
|
-
"
|
|
553
|
-
"
|
|
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"
|
|
554
488
|
];
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
properties: properties,
|
|
562
|
-
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"
|
|
563
495
|
};
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
'image/jpeg',
|
|
568
|
-
'image/jpg',
|
|
569
|
-
'image/svg+xml',
|
|
570
|
-
'image/gif',
|
|
571
|
-
'image/heic',
|
|
572
|
-
'image/heif'
|
|
573
|
-
];
|
|
574
|
-
var SUPPORTED_IMAGE_MIME_TYPES = __assign(__assign({}, supportedImageFileTypes.reduce(function (hash, ft) {
|
|
575
|
-
var _a;
|
|
576
|
-
return (__assign(__assign({}, hash), (_a = {}, _a[ft.split('/')[1]] = ft, _a)));
|
|
577
|
-
}, {})), { jpg: 'image/jpeg' });
|
|
578
|
-
var maxAttachmentFileSize = 10 * 1024 * 1024;
|
|
579
|
-
var FILE_DOCID_PREFIX = 'file:';
|
|
580
|
-
var validateFile = validator$3;
|
|
496
|
+
const maxAttachmentFileSize = 10 * 1024 * 1024;
|
|
497
|
+
const FILE_DOCID_PREFIX = "file:";
|
|
498
|
+
const validateFile = validator$3;
|
|
581
499
|
function createFileId() {
|
|
582
|
-
|
|
500
|
+
return createDocId(FILE_DOCID_PREFIX);
|
|
583
501
|
}
|
|
584
502
|
function validateFileId(docId) {
|
|
585
|
-
|
|
503
|
+
return validateDocId(FILE_DOCID_PREFIX, docId);
|
|
586
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 };
|
|
587
507
|
|
|
588
|
-
|
|
589
|
-
//# sourceMappingURL=index.esm.js.map
|
|
508
|
+
//# sourceMappingURL=index.esm.js.map
|