inkdrop-model 2.6.2 → 2.7.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/lib/book.d.ts +20 -0
- package/lib/crypto.d.ts +9 -0
- package/lib/file.d.ts +34 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.esm.js +131 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +162 -71
- package/lib/index.js.map +1 -0
- package/lib/index.umd.js +1 -0
- package/lib/note.d.ts +38 -0
- package/lib/tag.d.ts +23 -0
- package/lib/validator.d.ts +7 -0
- package/package.json +22 -29
- package/validators/book.js +1 -1
- package/validators/file.js +1 -1
- package/validators/note.js +1 -1
- package/validators/tag.js +1 -1
- package/lib/book.js +0 -25
- package/lib/book.js.flow +0 -27
- package/lib/crypto.js +0 -1
- package/lib/crypto.js.flow +0 -12
- package/lib/file.js +0 -44
- package/lib/file.js.flow +0 -60
- package/lib/index.js.flow +0 -7
- package/lib/note.js +0 -41
- package/lib/note.js.flow +0 -53
- package/lib/tag.js +0 -43
- package/lib/tag.js.flow +0 -60
- package/lib/validate_book.js +0 -323
- package/lib/validate_file.js +0 -609
- package/lib/validate_note.js +0 -703
- package/lib/validate_tag.js +0 -340
- package/lib/validator.js +0 -38
- package/lib/validator.js.flow +0 -27
package/lib/validate_note.js
DELETED
|
@@ -1,703 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var ucs2length = require('ajv/lib/compile/ucs2length');
|
|
3
|
-
var equal = require('ajv/lib/compile/equal');
|
|
4
|
-
var validate = (function() {
|
|
5
|
-
var pattern0 = new RegExp('^note:');
|
|
6
|
-
var pattern1 = new RegExp('^(book:|trash$)');
|
|
7
|
-
var refVal = [];
|
|
8
|
-
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
|
9
|
-
'use strict'; /*# sourceURL=note */
|
|
10
|
-
var vErrors = null;
|
|
11
|
-
var errors = 0;
|
|
12
|
-
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
|
13
|
-
if (true) {
|
|
14
|
-
var errs__0 = errors;
|
|
15
|
-
var valid1 = true;
|
|
16
|
-
var data1 = data._id;
|
|
17
|
-
if (data1 === undefined) {
|
|
18
|
-
valid1 = false;
|
|
19
|
-
validate.errors = [{
|
|
20
|
-
keyword: 'required',
|
|
21
|
-
dataPath: (dataPath || '') + "",
|
|
22
|
-
schemaPath: '#/required',
|
|
23
|
-
params: {
|
|
24
|
-
missingProperty: '_id'
|
|
25
|
-
},
|
|
26
|
-
message: 'should have required property \'_id\''
|
|
27
|
-
}];
|
|
28
|
-
return false;
|
|
29
|
-
} else {
|
|
30
|
-
var errs_1 = errors;
|
|
31
|
-
if (typeof data1 === "string") {
|
|
32
|
-
if (ucs2length(data1) > 128) {
|
|
33
|
-
validate.errors = [{
|
|
34
|
-
keyword: 'maxLength',
|
|
35
|
-
dataPath: (dataPath || '') + '._id',
|
|
36
|
-
schemaPath: '#/properties/_id/maxLength',
|
|
37
|
-
params: {
|
|
38
|
-
limit: 128
|
|
39
|
-
},
|
|
40
|
-
message: 'should NOT be longer than 128 characters'
|
|
41
|
-
}];
|
|
42
|
-
return false;
|
|
43
|
-
} else {
|
|
44
|
-
if (ucs2length(data1) < 6) {
|
|
45
|
-
validate.errors = [{
|
|
46
|
-
keyword: 'minLength',
|
|
47
|
-
dataPath: (dataPath || '') + '._id',
|
|
48
|
-
schemaPath: '#/properties/_id/minLength',
|
|
49
|
-
params: {
|
|
50
|
-
limit: 6
|
|
51
|
-
},
|
|
52
|
-
message: 'should NOT be shorter than 6 characters'
|
|
53
|
-
}];
|
|
54
|
-
return false;
|
|
55
|
-
} else {
|
|
56
|
-
if (!pattern0.test(data1)) {
|
|
57
|
-
validate.errors = [{
|
|
58
|
-
keyword: 'pattern',
|
|
59
|
-
dataPath: (dataPath || '') + '._id',
|
|
60
|
-
schemaPath: '#/properties/_id/pattern',
|
|
61
|
-
params: {
|
|
62
|
-
pattern: '^note:'
|
|
63
|
-
},
|
|
64
|
-
message: 'should match pattern "^note:"'
|
|
65
|
-
}];
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
validate.errors = [{
|
|
72
|
-
keyword: 'type',
|
|
73
|
-
dataPath: (dataPath || '') + '._id',
|
|
74
|
-
schemaPath: '#/properties/_id/type',
|
|
75
|
-
params: {
|
|
76
|
-
type: 'string'
|
|
77
|
-
},
|
|
78
|
-
message: 'should be string'
|
|
79
|
-
}];
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
var valid1 = errors === errs_1;
|
|
83
|
-
}
|
|
84
|
-
if (valid1) {
|
|
85
|
-
if (data._rev === undefined) {
|
|
86
|
-
valid1 = true;
|
|
87
|
-
} else {
|
|
88
|
-
var errs_1 = errors;
|
|
89
|
-
if (typeof data._rev !== "string") {
|
|
90
|
-
validate.errors = [{
|
|
91
|
-
keyword: 'type',
|
|
92
|
-
dataPath: (dataPath || '') + '._rev',
|
|
93
|
-
schemaPath: '#/properties/_rev/type',
|
|
94
|
-
params: {
|
|
95
|
-
type: 'string'
|
|
96
|
-
},
|
|
97
|
-
message: 'should be string'
|
|
98
|
-
}];
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
var valid1 = errors === errs_1;
|
|
102
|
-
}
|
|
103
|
-
if (valid1) {
|
|
104
|
-
var data1 = data.bookId;
|
|
105
|
-
if (data1 === undefined) {
|
|
106
|
-
valid1 = false;
|
|
107
|
-
validate.errors = [{
|
|
108
|
-
keyword: 'required',
|
|
109
|
-
dataPath: (dataPath || '') + "",
|
|
110
|
-
schemaPath: '#/required',
|
|
111
|
-
params: {
|
|
112
|
-
missingProperty: 'bookId'
|
|
113
|
-
},
|
|
114
|
-
message: 'should have required property \'bookId\''
|
|
115
|
-
}];
|
|
116
|
-
return false;
|
|
117
|
-
} else {
|
|
118
|
-
var errs_1 = errors;
|
|
119
|
-
if (typeof data1 === "string") {
|
|
120
|
-
if (ucs2length(data1) > 128) {
|
|
121
|
-
validate.errors = [{
|
|
122
|
-
keyword: 'maxLength',
|
|
123
|
-
dataPath: (dataPath || '') + '.bookId',
|
|
124
|
-
schemaPath: '#/properties/bookId/maxLength',
|
|
125
|
-
params: {
|
|
126
|
-
limit: 128
|
|
127
|
-
},
|
|
128
|
-
message: 'should NOT be longer than 128 characters'
|
|
129
|
-
}];
|
|
130
|
-
return false;
|
|
131
|
-
} else {
|
|
132
|
-
if (ucs2length(data1) < 5) {
|
|
133
|
-
validate.errors = [{
|
|
134
|
-
keyword: 'minLength',
|
|
135
|
-
dataPath: (dataPath || '') + '.bookId',
|
|
136
|
-
schemaPath: '#/properties/bookId/minLength',
|
|
137
|
-
params: {
|
|
138
|
-
limit: 5
|
|
139
|
-
},
|
|
140
|
-
message: 'should NOT be shorter than 5 characters'
|
|
141
|
-
}];
|
|
142
|
-
return false;
|
|
143
|
-
} else {
|
|
144
|
-
if (!pattern1.test(data1)) {
|
|
145
|
-
validate.errors = [{
|
|
146
|
-
keyword: 'pattern',
|
|
147
|
-
dataPath: (dataPath || '') + '.bookId',
|
|
148
|
-
schemaPath: '#/properties/bookId/pattern',
|
|
149
|
-
params: {
|
|
150
|
-
pattern: '^(book:|trash$)'
|
|
151
|
-
},
|
|
152
|
-
message: 'should match pattern "^(book:|trash$)"'
|
|
153
|
-
}];
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
validate.errors = [{
|
|
160
|
-
keyword: 'type',
|
|
161
|
-
dataPath: (dataPath || '') + '.bookId',
|
|
162
|
-
schemaPath: '#/properties/bookId/type',
|
|
163
|
-
params: {
|
|
164
|
-
type: 'string'
|
|
165
|
-
},
|
|
166
|
-
message: 'should be string'
|
|
167
|
-
}];
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
var valid1 = errors === errs_1;
|
|
171
|
-
}
|
|
172
|
-
if (valid1) {
|
|
173
|
-
var data1 = data.title;
|
|
174
|
-
if (data1 === undefined) {
|
|
175
|
-
valid1 = false;
|
|
176
|
-
validate.errors = [{
|
|
177
|
-
keyword: 'required',
|
|
178
|
-
dataPath: (dataPath || '') + "",
|
|
179
|
-
schemaPath: '#/required',
|
|
180
|
-
params: {
|
|
181
|
-
missingProperty: 'title'
|
|
182
|
-
},
|
|
183
|
-
message: 'should have required property \'title\''
|
|
184
|
-
}];
|
|
185
|
-
return false;
|
|
186
|
-
} else {
|
|
187
|
-
var errs_1 = errors;
|
|
188
|
-
if (typeof data1 === "string") {
|
|
189
|
-
if (ucs2length(data1) > 128) {
|
|
190
|
-
validate.errors = [{
|
|
191
|
-
keyword: 'maxLength',
|
|
192
|
-
dataPath: (dataPath || '') + '.title',
|
|
193
|
-
schemaPath: '#/properties/title/maxLength',
|
|
194
|
-
params: {
|
|
195
|
-
limit: 128
|
|
196
|
-
},
|
|
197
|
-
message: 'should NOT be longer than 128 characters'
|
|
198
|
-
}];
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
validate.errors = [{
|
|
203
|
-
keyword: 'type',
|
|
204
|
-
dataPath: (dataPath || '') + '.title',
|
|
205
|
-
schemaPath: '#/properties/title/type',
|
|
206
|
-
params: {
|
|
207
|
-
type: 'string'
|
|
208
|
-
},
|
|
209
|
-
message: 'should be string'
|
|
210
|
-
}];
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
var valid1 = errors === errs_1;
|
|
214
|
-
}
|
|
215
|
-
if (valid1) {
|
|
216
|
-
var data1 = data.doctype;
|
|
217
|
-
if (data1 === undefined) {
|
|
218
|
-
valid1 = false;
|
|
219
|
-
validate.errors = [{
|
|
220
|
-
keyword: 'required',
|
|
221
|
-
dataPath: (dataPath || '') + "",
|
|
222
|
-
schemaPath: '#/required',
|
|
223
|
-
params: {
|
|
224
|
-
missingProperty: 'doctype'
|
|
225
|
-
},
|
|
226
|
-
message: 'should have required property \'doctype\''
|
|
227
|
-
}];
|
|
228
|
-
return false;
|
|
229
|
-
} else {
|
|
230
|
-
var errs_1 = errors;
|
|
231
|
-
if (typeof data1 !== "string") {
|
|
232
|
-
validate.errors = [{
|
|
233
|
-
keyword: 'type',
|
|
234
|
-
dataPath: (dataPath || '') + '.doctype',
|
|
235
|
-
schemaPath: '#/properties/doctype/type',
|
|
236
|
-
params: {
|
|
237
|
-
type: 'string'
|
|
238
|
-
},
|
|
239
|
-
message: 'should be string'
|
|
240
|
-
}];
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
var schema1 = validate.schema.properties.doctype.enum;
|
|
244
|
-
var valid1;
|
|
245
|
-
valid1 = false;
|
|
246
|
-
for (var i1 = 0; i1 < schema1.length; i1++)
|
|
247
|
-
if (equal(data1, schema1[i1])) {
|
|
248
|
-
valid1 = true;
|
|
249
|
-
break;
|
|
250
|
-
} if (!valid1) {
|
|
251
|
-
validate.errors = [{
|
|
252
|
-
keyword: 'enum',
|
|
253
|
-
dataPath: (dataPath || '') + '.doctype',
|
|
254
|
-
schemaPath: '#/properties/doctype/enum',
|
|
255
|
-
params: {
|
|
256
|
-
allowedValues: schema1
|
|
257
|
-
},
|
|
258
|
-
message: 'should be equal to one of the allowed values'
|
|
259
|
-
}];
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
var valid1 = errors === errs_1;
|
|
263
|
-
}
|
|
264
|
-
if (valid1) {
|
|
265
|
-
var data1 = data.body;
|
|
266
|
-
if (data1 === undefined) {
|
|
267
|
-
valid1 = false;
|
|
268
|
-
validate.errors = [{
|
|
269
|
-
keyword: 'required',
|
|
270
|
-
dataPath: (dataPath || '') + "",
|
|
271
|
-
schemaPath: '#/required',
|
|
272
|
-
params: {
|
|
273
|
-
missingProperty: 'body'
|
|
274
|
-
},
|
|
275
|
-
message: 'should have required property \'body\''
|
|
276
|
-
}];
|
|
277
|
-
return false;
|
|
278
|
-
} else {
|
|
279
|
-
var errs_1 = errors;
|
|
280
|
-
if (typeof data1 === "string") {
|
|
281
|
-
if (ucs2length(data1) > 1048576) {
|
|
282
|
-
validate.errors = [{
|
|
283
|
-
keyword: 'maxLength',
|
|
284
|
-
dataPath: (dataPath || '') + '.body',
|
|
285
|
-
schemaPath: '#/properties/body/maxLength',
|
|
286
|
-
params: {
|
|
287
|
-
limit: 1048576
|
|
288
|
-
},
|
|
289
|
-
message: 'should NOT be longer than 1048576 characters'
|
|
290
|
-
}];
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
validate.errors = [{
|
|
295
|
-
keyword: 'type',
|
|
296
|
-
dataPath: (dataPath || '') + '.body',
|
|
297
|
-
schemaPath: '#/properties/body/type',
|
|
298
|
-
params: {
|
|
299
|
-
type: 'string'
|
|
300
|
-
},
|
|
301
|
-
message: 'should be string'
|
|
302
|
-
}];
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
var valid1 = errors === errs_1;
|
|
306
|
-
}
|
|
307
|
-
if (valid1) {
|
|
308
|
-
if (data.updatedAt === undefined) {
|
|
309
|
-
valid1 = false;
|
|
310
|
-
validate.errors = [{
|
|
311
|
-
keyword: 'required',
|
|
312
|
-
dataPath: (dataPath || '') + "",
|
|
313
|
-
schemaPath: '#/required',
|
|
314
|
-
params: {
|
|
315
|
-
missingProperty: 'updatedAt'
|
|
316
|
-
},
|
|
317
|
-
message: 'should have required property \'updatedAt\''
|
|
318
|
-
}];
|
|
319
|
-
return false;
|
|
320
|
-
} else {
|
|
321
|
-
var errs_1 = errors;
|
|
322
|
-
if (typeof data.updatedAt !== "number") {
|
|
323
|
-
validate.errors = [{
|
|
324
|
-
keyword: 'type',
|
|
325
|
-
dataPath: (dataPath || '') + '.updatedAt',
|
|
326
|
-
schemaPath: '#/properties/updatedAt/type',
|
|
327
|
-
params: {
|
|
328
|
-
type: 'number'
|
|
329
|
-
},
|
|
330
|
-
message: 'should be number'
|
|
331
|
-
}];
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
var valid1 = errors === errs_1;
|
|
335
|
-
}
|
|
336
|
-
if (valid1) {
|
|
337
|
-
if (data.createdAt === undefined) {
|
|
338
|
-
valid1 = false;
|
|
339
|
-
validate.errors = [{
|
|
340
|
-
keyword: 'required',
|
|
341
|
-
dataPath: (dataPath || '') + "",
|
|
342
|
-
schemaPath: '#/required',
|
|
343
|
-
params: {
|
|
344
|
-
missingProperty: 'createdAt'
|
|
345
|
-
},
|
|
346
|
-
message: 'should have required property \'createdAt\''
|
|
347
|
-
}];
|
|
348
|
-
return false;
|
|
349
|
-
} else {
|
|
350
|
-
var errs_1 = errors;
|
|
351
|
-
if (typeof data.createdAt !== "number") {
|
|
352
|
-
validate.errors = [{
|
|
353
|
-
keyword: 'type',
|
|
354
|
-
dataPath: (dataPath || '') + '.createdAt',
|
|
355
|
-
schemaPath: '#/properties/createdAt/type',
|
|
356
|
-
params: {
|
|
357
|
-
type: 'number'
|
|
358
|
-
},
|
|
359
|
-
message: 'should be number'
|
|
360
|
-
}];
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
var valid1 = errors === errs_1;
|
|
364
|
-
}
|
|
365
|
-
if (valid1) {
|
|
366
|
-
var data1 = data.tags;
|
|
367
|
-
if (data1 === undefined) {
|
|
368
|
-
valid1 = true;
|
|
369
|
-
} else {
|
|
370
|
-
var errs_1 = errors;
|
|
371
|
-
if (Array.isArray(data1)) {
|
|
372
|
-
var errs__1 = errors;
|
|
373
|
-
var valid1;
|
|
374
|
-
for (var i1 = 0; i1 < data1.length; i1++) {
|
|
375
|
-
var errs_2 = errors;
|
|
376
|
-
if (typeof data1[i1] !== "string") {
|
|
377
|
-
validate.errors = [{
|
|
378
|
-
keyword: 'type',
|
|
379
|
-
dataPath: (dataPath || '') + '.tags[' + i1 + ']',
|
|
380
|
-
schemaPath: '#/properties/tags/items/type',
|
|
381
|
-
params: {
|
|
382
|
-
type: 'string'
|
|
383
|
-
},
|
|
384
|
-
message: 'should be string'
|
|
385
|
-
}];
|
|
386
|
-
return false;
|
|
387
|
-
}
|
|
388
|
-
var valid2 = errors === errs_2;
|
|
389
|
-
if (!valid2) break;
|
|
390
|
-
}
|
|
391
|
-
if (errs__1 == errors) {
|
|
392
|
-
var i = data1.length,
|
|
393
|
-
valid1 = true,
|
|
394
|
-
j;
|
|
395
|
-
if (i > 1) {
|
|
396
|
-
var itemIndices = {},
|
|
397
|
-
item;
|
|
398
|
-
for (; i--;) {
|
|
399
|
-
var item = data1[i];
|
|
400
|
-
if (typeof item !== "string") continue;
|
|
401
|
-
if (typeof itemIndices[item] == 'number') {
|
|
402
|
-
valid1 = false;
|
|
403
|
-
j = itemIndices[item];
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
itemIndices[item] = i;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
if (!valid1) {
|
|
410
|
-
validate.errors = [{
|
|
411
|
-
keyword: 'uniqueItems',
|
|
412
|
-
dataPath: (dataPath || '') + '.tags',
|
|
413
|
-
schemaPath: '#/properties/tags/uniqueItems',
|
|
414
|
-
params: {
|
|
415
|
-
i: i,
|
|
416
|
-
j: j
|
|
417
|
-
},
|
|
418
|
-
message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'
|
|
419
|
-
}];
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
} else {
|
|
424
|
-
validate.errors = [{
|
|
425
|
-
keyword: 'type',
|
|
426
|
-
dataPath: (dataPath || '') + '.tags',
|
|
427
|
-
schemaPath: '#/properties/tags/type',
|
|
428
|
-
params: {
|
|
429
|
-
type: 'array'
|
|
430
|
-
},
|
|
431
|
-
message: 'should be array'
|
|
432
|
-
}];
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
var valid1 = errors === errs_1;
|
|
436
|
-
}
|
|
437
|
-
if (valid1) {
|
|
438
|
-
if (data.numOfTasks === undefined) {
|
|
439
|
-
valid1 = true;
|
|
440
|
-
} else {
|
|
441
|
-
var errs_1 = errors;
|
|
442
|
-
if (typeof data.numOfTasks !== "number") {
|
|
443
|
-
validate.errors = [{
|
|
444
|
-
keyword: 'type',
|
|
445
|
-
dataPath: (dataPath || '') + '.numOfTasks',
|
|
446
|
-
schemaPath: '#/properties/numOfTasks/type',
|
|
447
|
-
params: {
|
|
448
|
-
type: 'number'
|
|
449
|
-
},
|
|
450
|
-
message: 'should be number'
|
|
451
|
-
}];
|
|
452
|
-
return false;
|
|
453
|
-
}
|
|
454
|
-
var valid1 = errors === errs_1;
|
|
455
|
-
}
|
|
456
|
-
if (valid1) {
|
|
457
|
-
if (data.numOfCheckedTasks === undefined) {
|
|
458
|
-
valid1 = true;
|
|
459
|
-
} else {
|
|
460
|
-
var errs_1 = errors;
|
|
461
|
-
if (typeof data.numOfCheckedTasks !== "number") {
|
|
462
|
-
validate.errors = [{
|
|
463
|
-
keyword: 'type',
|
|
464
|
-
dataPath: (dataPath || '') + '.numOfCheckedTasks',
|
|
465
|
-
schemaPath: '#/properties/numOfCheckedTasks/type',
|
|
466
|
-
params: {
|
|
467
|
-
type: 'number'
|
|
468
|
-
},
|
|
469
|
-
message: 'should be number'
|
|
470
|
-
}];
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
var valid1 = errors === errs_1;
|
|
474
|
-
}
|
|
475
|
-
if (valid1) {
|
|
476
|
-
var data1 = data.migratedBy;
|
|
477
|
-
if (data1 === undefined) {
|
|
478
|
-
valid1 = true;
|
|
479
|
-
} else {
|
|
480
|
-
var errs_1 = errors;
|
|
481
|
-
if (typeof data1 === "string") {
|
|
482
|
-
if (ucs2length(data1) > 128) {
|
|
483
|
-
validate.errors = [{
|
|
484
|
-
keyword: 'maxLength',
|
|
485
|
-
dataPath: (dataPath || '') + '.migratedBy',
|
|
486
|
-
schemaPath: '#/properties/migratedBy/maxLength',
|
|
487
|
-
params: {
|
|
488
|
-
limit: 128
|
|
489
|
-
},
|
|
490
|
-
message: 'should NOT be longer than 128 characters'
|
|
491
|
-
}];
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
|
-
} else {
|
|
495
|
-
validate.errors = [{
|
|
496
|
-
keyword: 'type',
|
|
497
|
-
dataPath: (dataPath || '') + '.migratedBy',
|
|
498
|
-
schemaPath: '#/properties/migratedBy/type',
|
|
499
|
-
params: {
|
|
500
|
-
type: 'string'
|
|
501
|
-
},
|
|
502
|
-
message: 'should be string'
|
|
503
|
-
}];
|
|
504
|
-
return false;
|
|
505
|
-
}
|
|
506
|
-
var valid1 = errors === errs_1;
|
|
507
|
-
}
|
|
508
|
-
if (valid1) {
|
|
509
|
-
var data1 = data.status;
|
|
510
|
-
if (data1 === undefined) {
|
|
511
|
-
valid1 = true;
|
|
512
|
-
} else {
|
|
513
|
-
var errs_1 = errors;
|
|
514
|
-
if (typeof data1 !== "string") {
|
|
515
|
-
validate.errors = [{
|
|
516
|
-
keyword: 'type',
|
|
517
|
-
dataPath: (dataPath || '') + '.status',
|
|
518
|
-
schemaPath: '#/properties/status/type',
|
|
519
|
-
params: {
|
|
520
|
-
type: 'string'
|
|
521
|
-
},
|
|
522
|
-
message: 'should be string'
|
|
523
|
-
}];
|
|
524
|
-
return false;
|
|
525
|
-
}
|
|
526
|
-
var schema1 = validate.schema.properties.status.enum;
|
|
527
|
-
var valid1;
|
|
528
|
-
valid1 = false;
|
|
529
|
-
for (var i1 = 0; i1 < schema1.length; i1++)
|
|
530
|
-
if (equal(data1, schema1[i1])) {
|
|
531
|
-
valid1 = true;
|
|
532
|
-
break;
|
|
533
|
-
} if (!valid1) {
|
|
534
|
-
validate.errors = [{
|
|
535
|
-
keyword: 'enum',
|
|
536
|
-
dataPath: (dataPath || '') + '.status',
|
|
537
|
-
schemaPath: '#/properties/status/enum',
|
|
538
|
-
params: {
|
|
539
|
-
allowedValues: schema1
|
|
540
|
-
},
|
|
541
|
-
message: 'should be equal to one of the allowed values'
|
|
542
|
-
}];
|
|
543
|
-
return false;
|
|
544
|
-
}
|
|
545
|
-
var valid1 = errors === errs_1;
|
|
546
|
-
}
|
|
547
|
-
if (valid1) {
|
|
548
|
-
var data1 = data.share;
|
|
549
|
-
if (data1 === undefined) {
|
|
550
|
-
valid1 = true;
|
|
551
|
-
} else {
|
|
552
|
-
var errs_1 = errors;
|
|
553
|
-
if (typeof data1 !== "string") {
|
|
554
|
-
validate.errors = [{
|
|
555
|
-
keyword: 'type',
|
|
556
|
-
dataPath: (dataPath || '') + '.share',
|
|
557
|
-
schemaPath: '#/properties/share/type',
|
|
558
|
-
params: {
|
|
559
|
-
type: 'string'
|
|
560
|
-
},
|
|
561
|
-
message: 'should be string'
|
|
562
|
-
}];
|
|
563
|
-
return false;
|
|
564
|
-
}
|
|
565
|
-
var schema1 = validate.schema.properties.share.enum;
|
|
566
|
-
var valid1;
|
|
567
|
-
valid1 = false;
|
|
568
|
-
for (var i1 = 0; i1 < schema1.length; i1++)
|
|
569
|
-
if (equal(data1, schema1[i1])) {
|
|
570
|
-
valid1 = true;
|
|
571
|
-
break;
|
|
572
|
-
} if (!valid1) {
|
|
573
|
-
validate.errors = [{
|
|
574
|
-
keyword: 'enum',
|
|
575
|
-
dataPath: (dataPath || '') + '.share',
|
|
576
|
-
schemaPath: '#/properties/share/enum',
|
|
577
|
-
params: {
|
|
578
|
-
allowedValues: schema1
|
|
579
|
-
},
|
|
580
|
-
message: 'should be equal to one of the allowed values'
|
|
581
|
-
}];
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
var valid1 = errors === errs_1;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
} else {
|
|
601
|
-
validate.errors = [{
|
|
602
|
-
keyword: 'type',
|
|
603
|
-
dataPath: (dataPath || '') + "",
|
|
604
|
-
schemaPath: '#/type',
|
|
605
|
-
params: {
|
|
606
|
-
type: 'object'
|
|
607
|
-
},
|
|
608
|
-
message: 'should be object'
|
|
609
|
-
}];
|
|
610
|
-
return false;
|
|
611
|
-
}
|
|
612
|
-
validate.errors = vErrors;
|
|
613
|
-
return errors === 0;
|
|
614
|
-
};
|
|
615
|
-
})();
|
|
616
|
-
validate.schema = {
|
|
617
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
618
|
-
"id": "note",
|
|
619
|
-
"title": "Note",
|
|
620
|
-
"description": "A note data",
|
|
621
|
-
"type": "object",
|
|
622
|
-
"properties": {
|
|
623
|
-
"_id": {
|
|
624
|
-
"description": "The unique document ID which should start with `note:` and the remains are randomly generated string",
|
|
625
|
-
"type": "string",
|
|
626
|
-
"minLength": 6,
|
|
627
|
-
"maxLength": 128,
|
|
628
|
-
"pattern": "^note:",
|
|
629
|
-
"example": "note:Bkl_9Vubx"
|
|
630
|
-
},
|
|
631
|
-
"_rev": {
|
|
632
|
-
"description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
|
|
633
|
-
"type": "string",
|
|
634
|
-
"example": "14-813af5085bb6a2648c3f0aca37fc821f"
|
|
635
|
-
},
|
|
636
|
-
"bookId": {
|
|
637
|
-
"description": "The notebook ID",
|
|
638
|
-
"type": "string",
|
|
639
|
-
"minLength": 5,
|
|
640
|
-
"maxLength": 128,
|
|
641
|
-
"pattern": "^(book:|trash$)"
|
|
642
|
-
},
|
|
643
|
-
"title": {
|
|
644
|
-
"description": "The note title",
|
|
645
|
-
"type": "string",
|
|
646
|
-
"maxLength": 128
|
|
647
|
-
},
|
|
648
|
-
"doctype": {
|
|
649
|
-
"description": "The format type of the body field. It currently can take markdown only, reserved for the future",
|
|
650
|
-
"type": "string",
|
|
651
|
-
"enum": ["markdown"]
|
|
652
|
-
},
|
|
653
|
-
"body": {
|
|
654
|
-
"description": "The content of the note represented with Markdown",
|
|
655
|
-
"type": "string",
|
|
656
|
-
"maxLength": 1048576
|
|
657
|
-
},
|
|
658
|
-
"updatedAt": {
|
|
659
|
-
"description": "The date time when the note was last updated, represented with Unix timestamps in milliseconds",
|
|
660
|
-
"type": "number"
|
|
661
|
-
},
|
|
662
|
-
"createdAt": {
|
|
663
|
-
"description": "The date time when the note was created, represented with Unix timestamps in milliseconds",
|
|
664
|
-
"type": "number"
|
|
665
|
-
},
|
|
666
|
-
"tags": {
|
|
667
|
-
"description": "The list of tag IDs",
|
|
668
|
-
"type": "array",
|
|
669
|
-
"items": {
|
|
670
|
-
"type": "string"
|
|
671
|
-
},
|
|
672
|
-
"uniqueItems": true,
|
|
673
|
-
"example": ["tag:a28ca207"]
|
|
674
|
-
},
|
|
675
|
-
"numOfTasks": {
|
|
676
|
-
"description": "The number of tasks, extracted from body",
|
|
677
|
-
"type": "number"
|
|
678
|
-
},
|
|
679
|
-
"numOfCheckedTasks": {
|
|
680
|
-
"description": "The number of checked tasks, extracted from body",
|
|
681
|
-
"type": "number"
|
|
682
|
-
},
|
|
683
|
-
"migratedBy": {
|
|
684
|
-
"description": "The type of the data migration",
|
|
685
|
-
"type": "string",
|
|
686
|
-
"example": "migrateAddingParentBookId",
|
|
687
|
-
"maxLength": 128
|
|
688
|
-
},
|
|
689
|
-
"status": {
|
|
690
|
-
"description": "The status of the note",
|
|
691
|
-
"type": "string",
|
|
692
|
-
"enum": ["none", "active", "onHold", "completed", "dropped"]
|
|
693
|
-
},
|
|
694
|
-
"share": {
|
|
695
|
-
"description": "The sharing mode of the note",
|
|
696
|
-
"type": "string",
|
|
697
|
-
"enum": ["private", "public"]
|
|
698
|
-
}
|
|
699
|
-
},
|
|
700
|
-
"required": ["_id", "bookId", "title", "doctype", "body", "updatedAt", "createdAt"]
|
|
701
|
-
};
|
|
702
|
-
validate.errors = null;
|
|
703
|
-
module.exports = validate;
|