inkdrop-model 2.6.0 → 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.
@@ -1,609 +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('^file:');
6
- var refVal = [];
7
- return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
8
- 'use strict'; /*# sourceURL=file */
9
- var vErrors = null;
10
- var errors = 0;
11
- if ((data && typeof data === "object" && !Array.isArray(data))) {
12
- if (true) {
13
- var errs__0 = errors;
14
- var valid1 = true;
15
- var data1 = data._id;
16
- if (data1 === undefined) {
17
- valid1 = false;
18
- validate.errors = [{
19
- keyword: 'required',
20
- dataPath: (dataPath || '') + "",
21
- schemaPath: '#/required',
22
- params: {
23
- missingProperty: '_id'
24
- },
25
- message: 'should have required property \'_id\''
26
- }];
27
- return false;
28
- } else {
29
- var errs_1 = errors;
30
- if (typeof data1 === "string") {
31
- if (ucs2length(data1) > 128) {
32
- validate.errors = [{
33
- keyword: 'maxLength',
34
- dataPath: (dataPath || '') + '._id',
35
- schemaPath: '#/properties/_id/maxLength',
36
- params: {
37
- limit: 128
38
- },
39
- message: 'should NOT be longer than 128 characters'
40
- }];
41
- return false;
42
- } else {
43
- if (ucs2length(data1) < 6) {
44
- validate.errors = [{
45
- keyword: 'minLength',
46
- dataPath: (dataPath || '') + '._id',
47
- schemaPath: '#/properties/_id/minLength',
48
- params: {
49
- limit: 6
50
- },
51
- message: 'should NOT be shorter than 6 characters'
52
- }];
53
- return false;
54
- } else {
55
- if (!pattern0.test(data1)) {
56
- validate.errors = [{
57
- keyword: 'pattern',
58
- dataPath: (dataPath || '') + '._id',
59
- schemaPath: '#/properties/_id/pattern',
60
- params: {
61
- pattern: '^file:'
62
- },
63
- message: 'should match pattern "^file:"'
64
- }];
65
- return false;
66
- }
67
- }
68
- }
69
- } else {
70
- validate.errors = [{
71
- keyword: 'type',
72
- dataPath: (dataPath || '') + '._id',
73
- schemaPath: '#/properties/_id/type',
74
- params: {
75
- type: 'string'
76
- },
77
- message: 'should be string'
78
- }];
79
- return false;
80
- }
81
- var valid1 = errors === errs_1;
82
- }
83
- if (valid1) {
84
- if (data._rev === undefined) {
85
- valid1 = true;
86
- } else {
87
- var errs_1 = errors;
88
- if (typeof data._rev !== "string") {
89
- validate.errors = [{
90
- keyword: 'type',
91
- dataPath: (dataPath || '') + '._rev',
92
- schemaPath: '#/properties/_rev/type',
93
- params: {
94
- type: 'string'
95
- },
96
- message: 'should be string'
97
- }];
98
- return false;
99
- }
100
- var valid1 = errors === errs_1;
101
- }
102
- if (valid1) {
103
- var data1 = data.name;
104
- if (data1 === undefined) {
105
- valid1 = false;
106
- validate.errors = [{
107
- keyword: 'required',
108
- dataPath: (dataPath || '') + "",
109
- schemaPath: '#/required',
110
- params: {
111
- missingProperty: 'name'
112
- },
113
- message: 'should have required property \'name\''
114
- }];
115
- return false;
116
- } else {
117
- var errs_1 = errors;
118
- if (typeof data1 === "string") {
119
- if (ucs2length(data1) > 128) {
120
- validate.errors = [{
121
- keyword: 'maxLength',
122
- dataPath: (dataPath || '') + '.name',
123
- schemaPath: '#/properties/name/maxLength',
124
- params: {
125
- limit: 128
126
- },
127
- message: 'should NOT be longer than 128 characters'
128
- }];
129
- return false;
130
- } else {
131
- if (ucs2length(data1) < 1) {
132
- validate.errors = [{
133
- keyword: 'minLength',
134
- dataPath: (dataPath || '') + '.name',
135
- schemaPath: '#/properties/name/minLength',
136
- params: {
137
- limit: 1
138
- },
139
- message: 'should NOT be shorter than 1 characters'
140
- }];
141
- return false;
142
- }
143
- }
144
- } else {
145
- validate.errors = [{
146
- keyword: 'type',
147
- dataPath: (dataPath || '') + '.name',
148
- schemaPath: '#/properties/name/type',
149
- params: {
150
- type: 'string'
151
- },
152
- message: 'should be string'
153
- }];
154
- return false;
155
- }
156
- var valid1 = errors === errs_1;
157
- }
158
- if (valid1) {
159
- if (data.createdAt === undefined) {
160
- valid1 = false;
161
- validate.errors = [{
162
- keyword: 'required',
163
- dataPath: (dataPath || '') + "",
164
- schemaPath: '#/required',
165
- params: {
166
- missingProperty: 'createdAt'
167
- },
168
- message: 'should have required property \'createdAt\''
169
- }];
170
- return false;
171
- } else {
172
- var errs_1 = errors;
173
- if (typeof data.createdAt !== "number") {
174
- validate.errors = [{
175
- keyword: 'type',
176
- dataPath: (dataPath || '') + '.createdAt',
177
- schemaPath: '#/properties/createdAt/type',
178
- params: {
179
- type: 'number'
180
- },
181
- message: 'should be number'
182
- }];
183
- return false;
184
- }
185
- var valid1 = errors === errs_1;
186
- }
187
- if (valid1) {
188
- var data1 = data.contentType;
189
- if (data1 === undefined) {
190
- valid1 = false;
191
- validate.errors = [{
192
- keyword: 'required',
193
- dataPath: (dataPath || '') + "",
194
- schemaPath: '#/required',
195
- params: {
196
- missingProperty: 'contentType'
197
- },
198
- message: 'should have required property \'contentType\''
199
- }];
200
- return false;
201
- } else {
202
- var errs_1 = errors;
203
- if (typeof data1 === "string") {
204
- if (ucs2length(data1) > 128) {
205
- validate.errors = [{
206
- keyword: 'maxLength',
207
- dataPath: (dataPath || '') + '.contentType',
208
- schemaPath: '#/properties/contentType/maxLength',
209
- params: {
210
- limit: 128
211
- },
212
- message: 'should NOT be longer than 128 characters'
213
- }];
214
- return false;
215
- }
216
- } else {
217
- validate.errors = [{
218
- keyword: 'type',
219
- dataPath: (dataPath || '') + '.contentType',
220
- schemaPath: '#/properties/contentType/type',
221
- params: {
222
- type: 'string'
223
- },
224
- message: 'should be string'
225
- }];
226
- return false;
227
- }
228
- if (errors === errs_1) {
229
- var schema1 = validate.schema.properties.contentType.enum;
230
- var valid1;
231
- valid1 = false;
232
- for (var i1 = 0; i1 < schema1.length; i1++)
233
- if (equal(data1, schema1[i1])) {
234
- valid1 = true;
235
- break;
236
- } if (!valid1) {
237
- validate.errors = [{
238
- keyword: 'enum',
239
- dataPath: (dataPath || '') + '.contentType',
240
- schemaPath: '#/properties/contentType/enum',
241
- params: {
242
- allowedValues: schema1
243
- },
244
- message: 'should be equal to one of the allowed values'
245
- }];
246
- return false;
247
- }
248
- }
249
- var valid1 = errors === errs_1;
250
- }
251
- if (valid1) {
252
- if (data.contentLength === undefined) {
253
- valid1 = false;
254
- validate.errors = [{
255
- keyword: 'required',
256
- dataPath: (dataPath || '') + "",
257
- schemaPath: '#/required',
258
- params: {
259
- missingProperty: 'contentLength'
260
- },
261
- message: 'should have required property \'contentLength\''
262
- }];
263
- return false;
264
- } else {
265
- var errs_1 = errors;
266
- if (typeof data.contentLength !== "number") {
267
- validate.errors = [{
268
- keyword: 'type',
269
- dataPath: (dataPath || '') + '.contentLength',
270
- schemaPath: '#/properties/contentLength/type',
271
- params: {
272
- type: 'number'
273
- },
274
- message: 'should be number'
275
- }];
276
- return false;
277
- }
278
- var valid1 = errors === errs_1;
279
- }
280
- if (valid1) {
281
- var data1 = data.publicIn;
282
- if (data1 === undefined) {
283
- valid1 = false;
284
- validate.errors = [{
285
- keyword: 'required',
286
- dataPath: (dataPath || '') + "",
287
- schemaPath: '#/required',
288
- params: {
289
- missingProperty: 'publicIn'
290
- },
291
- message: 'should have required property \'publicIn\''
292
- }];
293
- return false;
294
- } else {
295
- var errs_1 = errors;
296
- if (Array.isArray(data1)) {
297
- var errs__1 = errors;
298
- var valid1;
299
- for (var i1 = 0; i1 < data1.length; i1++) {
300
- var errs_2 = errors;
301
- if (typeof data1[i1] !== "string") {
302
- validate.errors = [{
303
- keyword: 'type',
304
- dataPath: (dataPath || '') + '.publicIn[' + i1 + ']',
305
- schemaPath: '#/properties/publicIn/items/type',
306
- params: {
307
- type: 'string'
308
- },
309
- message: 'should be string'
310
- }];
311
- return false;
312
- }
313
- var valid2 = errors === errs_2;
314
- if (!valid2) break;
315
- }
316
- if (errs__1 == errors) {
317
- var i = data1.length,
318
- valid1 = true,
319
- j;
320
- if (i > 1) {
321
- var itemIndices = {},
322
- item;
323
- for (; i--;) {
324
- var item = data1[i];
325
- if (typeof item !== "string") continue;
326
- if (typeof itemIndices[item] == 'number') {
327
- valid1 = false;
328
- j = itemIndices[item];
329
- break;
330
- }
331
- itemIndices[item] = i;
332
- }
333
- }
334
- if (!valid1) {
335
- validate.errors = [{
336
- keyword: 'uniqueItems',
337
- dataPath: (dataPath || '') + '.publicIn',
338
- schemaPath: '#/properties/publicIn/uniqueItems',
339
- params: {
340
- i: i,
341
- j: j
342
- },
343
- message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'
344
- }];
345
- return false;
346
- }
347
- }
348
- } else {
349
- validate.errors = [{
350
- keyword: 'type',
351
- dataPath: (dataPath || '') + '.publicIn',
352
- schemaPath: '#/properties/publicIn/type',
353
- params: {
354
- type: 'array'
355
- },
356
- message: 'should be array'
357
- }];
358
- return false;
359
- }
360
- var valid1 = errors === errs_1;
361
- }
362
- if (valid1) {
363
- var data1 = data._attachments;
364
- if (data1 === undefined) {
365
- valid1 = false;
366
- validate.errors = [{
367
- keyword: 'required',
368
- dataPath: (dataPath || '') + "",
369
- schemaPath: '#/required',
370
- params: {
371
- missingProperty: '_attachments'
372
- },
373
- message: 'should have required property \'_attachments\''
374
- }];
375
- return false;
376
- } else {
377
- var errs_1 = errors;
378
- if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
379
- if (true) {
380
- var errs__1 = errors;
381
- var valid2 = true;
382
- var data2 = data1.index;
383
- if (data2 === undefined) {
384
- valid2 = false;
385
- validate.errors = [{
386
- keyword: 'required',
387
- dataPath: (dataPath || '') + '._attachments',
388
- schemaPath: '#/properties/_attachments/required',
389
- params: {
390
- missingProperty: 'index'
391
- },
392
- message: 'should have required property \'index\''
393
- }];
394
- return false;
395
- } else {
396
- var errs_2 = errors;
397
- if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
398
- if (true) {
399
- var errs__2 = errors;
400
- var valid3 = true;
401
- var data3 = data2.content_type;
402
- if (data3 === undefined) {
403
- valid3 = false;
404
- validate.errors = [{
405
- keyword: 'required',
406
- dataPath: (dataPath || '') + '._attachments.index',
407
- schemaPath: '#/properties/_attachments/properties/index/required',
408
- params: {
409
- missingProperty: 'content_type'
410
- },
411
- message: 'should have required property \'content_type\''
412
- }];
413
- return false;
414
- } else {
415
- var errs_3 = errors;
416
- if (typeof data3 !== "string") {
417
- validate.errors = [{
418
- keyword: 'type',
419
- dataPath: (dataPath || '') + '._attachments.index.content_type',
420
- schemaPath: '#/properties/_attachments/properties/index/properties/content_type/type',
421
- params: {
422
- type: 'string'
423
- },
424
- message: 'should be string'
425
- }];
426
- return false;
427
- }
428
- var schema3 = validate.schema.properties._attachments.properties.index.properties.content_type.enum;
429
- var valid3;
430
- valid3 = false;
431
- for (var i3 = 0; i3 < schema3.length; i3++)
432
- if (equal(data3, schema3[i3])) {
433
- valid3 = true;
434
- break;
435
- } if (!valid3) {
436
- validate.errors = [{
437
- keyword: 'enum',
438
- dataPath: (dataPath || '') + '._attachments.index.content_type',
439
- schemaPath: '#/properties/_attachments/properties/index/properties/content_type/enum',
440
- params: {
441
- allowedValues: schema3
442
- },
443
- message: 'should be equal to one of the allowed values'
444
- }];
445
- return false;
446
- }
447
- var valid3 = errors === errs_3;
448
- }
449
- if (valid3) {
450
- var data3 = data2.data;
451
- if (data3 === undefined) {
452
- valid3 = false;
453
- validate.errors = [{
454
- keyword: 'required',
455
- dataPath: (dataPath || '') + '._attachments.index',
456
- schemaPath: '#/properties/_attachments/properties/index/required',
457
- params: {
458
- missingProperty: 'data'
459
- },
460
- message: 'should have required property \'data\''
461
- }];
462
- return false;
463
- } else {
464
- var errs_3 = errors;
465
- if (typeof data3 !== "string" && (!data3 || typeof data3 !== "object" || Array.isArray(data3))) {
466
- validate.errors = [{
467
- keyword: 'type',
468
- dataPath: (dataPath || '') + '._attachments.index.data',
469
- schemaPath: '#/properties/_attachments/properties/index/properties/data/type',
470
- params: {
471
- type: 'string,object'
472
- },
473
- message: 'should be string,object'
474
- }];
475
- return false;
476
- }
477
- var valid3 = errors === errs_3;
478
- }
479
- }
480
- }
481
- } else {
482
- validate.errors = [{
483
- keyword: 'type',
484
- dataPath: (dataPath || '') + '._attachments.index',
485
- schemaPath: '#/properties/_attachments/properties/index/type',
486
- params: {
487
- type: 'object'
488
- },
489
- message: 'should be object'
490
- }];
491
- return false;
492
- }
493
- var valid2 = errors === errs_2;
494
- }
495
- }
496
- } else {
497
- validate.errors = [{
498
- keyword: 'type',
499
- dataPath: (dataPath || '') + '._attachments',
500
- schemaPath: '#/properties/_attachments/type',
501
- params: {
502
- type: 'object'
503
- },
504
- message: 'should be object'
505
- }];
506
- return false;
507
- }
508
- var valid1 = errors === errs_1;
509
- }
510
- }
511
- }
512
- }
513
- }
514
- }
515
- }
516
- }
517
- }
518
- } else {
519
- validate.errors = [{
520
- keyword: 'type',
521
- dataPath: (dataPath || '') + "",
522
- schemaPath: '#/type',
523
- params: {
524
- type: 'object'
525
- },
526
- message: 'should be object'
527
- }];
528
- return false;
529
- }
530
- validate.errors = vErrors;
531
- return errors === 0;
532
- };
533
- })();
534
- validate.schema = {
535
- "$schema": "http://json-schema.org/draft-07/schema#",
536
- "id": "file",
537
- "title": "File",
538
- "description": "An attachment file",
539
- "type": "object",
540
- "properties": {
541
- "_id": {
542
- "description": "The unique document ID which should start with `file:` and the remains are randomly generated string",
543
- "type": "string",
544
- "minLength": 6,
545
- "maxLength": 128,
546
- "pattern": "^file:",
547
- "example": "file:By8_nQtce"
548
- },
549
- "_rev": {
550
- "description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).",
551
- "type": "string",
552
- "example": "14-813af5085bb6a2648c3f0aca37fc821f"
553
- },
554
- "name": {
555
- "description": "The file name",
556
- "type": "string",
557
- "minLength": 1,
558
- "maxLength": 128
559
- },
560
- "createdAt": {
561
- "description": "The date time when the note was created, represented with Unix timestamps in milliseconds",
562
- "type": "number"
563
- },
564
- "contentType": {
565
- "description": "The MIME type of the content",
566
- "type": "string",
567
- "enum": ["image/png", "image/jpeg", "image/jpg", "image/svg+xml", "image/gif", "image/heic", "image/heif"],
568
- "maxLength": 128
569
- },
570
- "contentLength": {
571
- "description": "The content length of the file",
572
- "type": "number"
573
- },
574
- "publicIn": {
575
- "description": "An array of the note IDs where the file is included",
576
- "type": "array",
577
- "items": {
578
- "type": "string"
579
- },
580
- "uniqueItems": true
581
- },
582
- "_attachments": {
583
- "description": "The attachment file",
584
- "type": "object",
585
- "properties": {
586
- "index": {
587
- "description": "The attachment file",
588
- "type": "object",
589
- "properties": {
590
- "content_type": {
591
- "description": "The content type of the file",
592
- "type": "string",
593
- "enum": ["image/png", "image/jpeg", "image/jpg", "image/svg+xml", "image/gif", "image/heic", "image/heif"]
594
- },
595
- "data": {
596
- "description": "The file data",
597
- "type": ["string", "object"]
598
- }
599
- },
600
- "required": ["content_type", "data"]
601
- }
602
- },
603
- "required": ["index"]
604
- }
605
- },
606
- "required": ["_id", "name", "createdAt", "contentType", "contentLength", "publicIn", "_attachments"]
607
- };
608
- validate.errors = null;
609
- module.exports = validate;