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