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