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/tag.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "TagSchema", {
7
- enumerable: true,
8
- get: function () {
9
- return _tag.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "validateTag", {
13
- enumerable: true,
14
- get: function () {
15
- return _tag2.default;
16
- }
17
- });
18
- exports.TAG_COLOR = void 0;
19
-
20
- var _tag = _interopRequireDefault(require("../json-schema/tag.json"));
21
-
22
- var _tag2 = _interopRequireDefault(require("../validators/tag.js"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- delete _tag.default.id;
27
- const TAG_COLOR = {
28
- DEFAULT: 'default',
29
- RED: 'red',
30
- ORANGE: 'orange',
31
- YELLOW: 'yellow',
32
- OLIVE: 'olive',
33
- GREEN: 'green',
34
- TEAL: 'teal',
35
- BLUE: 'blue',
36
- VIOLET: 'violet',
37
- PURPLE: 'purple',
38
- PINK: 'pink',
39
- BROWN: 'brown',
40
- GREY: 'grey',
41
- BLACK: 'black'
42
- };
43
- exports.TAG_COLOR = TAG_COLOR;
package/lib/tag.js.flow DELETED
@@ -1,60 +0,0 @@
1
- // @flow
2
- import TagSchema from '../json-schema/tag.json'
3
- import validateTag from '../validators/tag.js'
4
- import type { EncryptedData } from './crypto'
5
-
6
- delete TagSchema.id
7
-
8
- export type TagColor =
9
- | 'default'
10
- | 'red'
11
- | 'orange'
12
- | 'yellow'
13
- | 'olive'
14
- | 'green'
15
- | 'teal'
16
- | 'blue'
17
- | 'violet'
18
- | 'purple'
19
- | 'pink'
20
- | 'brown'
21
- | 'grey'
22
- | 'black'
23
-
24
- export const TAG_COLOR: $ReadOnly<{ [string]: TagColor }> = {
25
- DEFAULT: 'default',
26
- RED: 'red',
27
- ORANGE: 'orange',
28
- YELLOW: 'yellow',
29
- OLIVE: 'olive',
30
- GREEN: 'green',
31
- TEAL: 'teal',
32
- BLUE: 'blue',
33
- VIOLET: 'violet',
34
- PURPLE: 'purple',
35
- PINK: 'pink',
36
- BROWN: 'brown',
37
- GREY: 'grey',
38
- BLACK: 'black'
39
- }
40
-
41
- export type TagMetadata = {
42
- _id: string,
43
- _rev?: string,
44
- count?: number,
45
- color: TagColor,
46
- updatedAt: number,
47
- createdAt: number
48
- }
49
-
50
- export type Tag = {
51
- ...$Exact<TagMetadata>,
52
- name: string
53
- }
54
-
55
- export type EncryptedTag = {
56
- ...$Exact<TagMetadata>,
57
- encryptedData: EncryptedData
58
- }
59
-
60
- export { TagSchema, validateTag }
@@ -1,323 +0,0 @@
1
- 'use strict';
2
- var ucs2length = require('ajv/lib/compile/ucs2length');
3
- var validate = (function() {
4
- var pattern0 = new RegExp('^book:');
5
- var refVal = [];
6
- return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
7
- 'use strict'; /*# sourceURL=book */
8
- var vErrors = null;
9
- var errors = 0;
10
- if ((data && typeof data === "object" && !Array.isArray(data))) {
11
- if (true) {
12
- var errs__0 = errors;
13
- var valid1 = true;
14
- var data1 = data._id;
15
- if (data1 === undefined) {
16
- valid1 = false;
17
- validate.errors = [{
18
- keyword: 'required',
19
- dataPath: (dataPath || '') + "",
20
- schemaPath: '#/required',
21
- params: {
22
- missingProperty: '_id'
23
- },
24
- message: 'should have required property \'_id\''
25
- }];
26
- return false;
27
- } else {
28
- var errs_1 = errors;
29
- if (typeof data1 === "string") {
30
- if (ucs2length(data1) > 128) {
31
- validate.errors = [{
32
- keyword: 'maxLength',
33
- dataPath: (dataPath || '') + '._id',
34
- schemaPath: '#/properties/_id/maxLength',
35
- params: {
36
- limit: 128
37
- },
38
- message: 'should NOT be longer than 128 characters'
39
- }];
40
- return false;
41
- } else {
42
- if (ucs2length(data1) < 6) {
43
- validate.errors = [{
44
- keyword: 'minLength',
45
- dataPath: (dataPath || '') + '._id',
46
- schemaPath: '#/properties/_id/minLength',
47
- params: {
48
- limit: 6
49
- },
50
- message: 'should NOT be shorter than 6 characters'
51
- }];
52
- return false;
53
- } else {
54
- if (!pattern0.test(data1)) {
55
- validate.errors = [{
56
- keyword: 'pattern',
57
- dataPath: (dataPath || '') + '._id',
58
- schemaPath: '#/properties/_id/pattern',
59
- params: {
60
- pattern: '^book:'
61
- },
62
- message: 'should match pattern "^book:"'
63
- }];
64
- return false;
65
- }
66
- }
67
- }
68
- } else {
69
- validate.errors = [{
70
- keyword: 'type',
71
- dataPath: (dataPath || '') + '._id',
72
- schemaPath: '#/properties/_id/type',
73
- params: {
74
- type: 'string'
75
- },
76
- message: 'should be string'
77
- }];
78
- return false;
79
- }
80
- var valid1 = errors === errs_1;
81
- }
82
- if (valid1) {
83
- if (data._rev === undefined) {
84
- valid1 = true;
85
- } else {
86
- var errs_1 = errors;
87
- if (typeof data._rev !== "string") {
88
- validate.errors = [{
89
- keyword: 'type',
90
- dataPath: (dataPath || '') + '._rev',
91
- schemaPath: '#/properties/_rev/type',
92
- params: {
93
- type: 'string'
94
- },
95
- message: 'should be string'
96
- }];
97
- return false;
98
- }
99
- var valid1 = errors === errs_1;
100
- }
101
- if (valid1) {
102
- var data1 = data.name;
103
- if (data1 === undefined) {
104
- valid1 = false;
105
- validate.errors = [{
106
- keyword: 'required',
107
- dataPath: (dataPath || '') + "",
108
- schemaPath: '#/required',
109
- params: {
110
- missingProperty: 'name'
111
- },
112
- message: 'should have required property \'name\''
113
- }];
114
- return false;
115
- } else {
116
- var errs_1 = errors;
117
- if (typeof data1 === "string") {
118
- if (ucs2length(data1) > 64) {
119
- validate.errors = [{
120
- keyword: 'maxLength',
121
- dataPath: (dataPath || '') + '.name',
122
- schemaPath: '#/properties/name/maxLength',
123
- params: {
124
- limit: 64
125
- },
126
- message: 'should NOT be longer than 64 characters'
127
- }];
128
- return false;
129
- } else {
130
- if (ucs2length(data1) < 1) {
131
- validate.errors = [{
132
- keyword: 'minLength',
133
- dataPath: (dataPath || '') + '.name',
134
- schemaPath: '#/properties/name/minLength',
135
- params: {
136
- limit: 1
137
- },
138
- message: 'should NOT be shorter than 1 characters'
139
- }];
140
- return false;
141
- }
142
- }
143
- } else {
144
- validate.errors = [{
145
- keyword: 'type',
146
- dataPath: (dataPath || '') + '.name',
147
- schemaPath: '#/properties/name/type',
148
- params: {
149
- type: 'string'
150
- },
151
- message: 'should be string'
152
- }];
153
- return false;
154
- }
155
- var valid1 = errors === errs_1;
156
- }
157
- if (valid1) {
158
- if (data.updatedAt === undefined) {
159
- valid1 = false;
160
- validate.errors = [{
161
- keyword: 'required',
162
- dataPath: (dataPath || '') + "",
163
- schemaPath: '#/required',
164
- params: {
165
- missingProperty: 'updatedAt'
166
- },
167
- message: 'should have required property \'updatedAt\''
168
- }];
169
- return false;
170
- } else {
171
- var errs_1 = errors;
172
- if (typeof data.updatedAt !== "number") {
173
- validate.errors = [{
174
- keyword: 'type',
175
- dataPath: (dataPath || '') + '.updatedAt',
176
- schemaPath: '#/properties/updatedAt/type',
177
- params: {
178
- type: 'number'
179
- },
180
- message: 'should be number'
181
- }];
182
- return false;
183
- }
184
- var valid1 = errors === errs_1;
185
- }
186
- if (valid1) {
187
- if (data.createdAt === undefined) {
188
- valid1 = false;
189
- validate.errors = [{
190
- keyword: 'required',
191
- dataPath: (dataPath || '') + "",
192
- schemaPath: '#/required',
193
- params: {
194
- missingProperty: 'createdAt'
195
- },
196
- message: 'should have required property \'createdAt\''
197
- }];
198
- return false;
199
- } else {
200
- var errs_1 = errors;
201
- if (typeof data.createdAt !== "number") {
202
- validate.errors = [{
203
- keyword: 'type',
204
- dataPath: (dataPath || '') + '.createdAt',
205
- schemaPath: '#/properties/createdAt/type',
206
- params: {
207
- type: 'number'
208
- },
209
- message: 'should be number'
210
- }];
211
- return false;
212
- }
213
- var valid1 = errors === errs_1;
214
- }
215
- if (valid1) {
216
- if (data.count === undefined) {
217
- valid1 = true;
218
- } else {
219
- var errs_1 = errors;
220
- if (typeof data.count !== "number") {
221
- validate.errors = [{
222
- keyword: 'type',
223
- dataPath: (dataPath || '') + '.count',
224
- schemaPath: '#/properties/count/type',
225
- params: {
226
- type: 'number'
227
- },
228
- message: 'should be number'
229
- }];
230
- return false;
231
- }
232
- var valid1 = errors === errs_1;
233
- }
234
- if (valid1) {
235
- var data1 = data.parentBookId;
236
- if (data1 === undefined) {
237
- valid1 = true;
238
- } else {
239
- var errs_1 = errors;
240
- if (typeof data1 !== "string" && data1 !== null) {
241
- validate.errors = [{
242
- keyword: 'type',
243
- dataPath: (dataPath || '') + '.parentBookId',
244
- schemaPath: '#/properties/parentBookId/type',
245
- params: {
246
- type: 'string,null'
247
- },
248
- message: 'should be string,null'
249
- }];
250
- return false;
251
- }
252
- var valid1 = errors === errs_1;
253
- }
254
- }
255
- }
256
- }
257
- }
258
- }
259
- }
260
- }
261
- } else {
262
- validate.errors = [{
263
- keyword: 'type',
264
- dataPath: (dataPath || '') + "",
265
- schemaPath: '#/type',
266
- params: {
267
- type: 'object'
268
- },
269
- message: 'should be object'
270
- }];
271
- return false;
272
- }
273
- validate.errors = vErrors;
274
- return errors === 0;
275
- };
276
- })();
277
- validate.schema = {
278
- "$schema": "http://json-schema.org/draft-07/schema#",
279
- "id": "book",
280
- "title": "Book",
281
- "description": "A notebook data",
282
- "type": "object",
283
- "properties": {
284
- "_id": {
285
- "description": "The unique notebook ID which should start with `book:` and the remains are randomly generated string",
286
- "type": "string",
287
- "minLength": 6,
288
- "maxLength": 128,
289
- "pattern": "^book:",
290
- "example": "book:9dc6a7a7"
291
- },
292
- "_rev": {
293
- "description": "This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)",
294
- "type": "string",
295
- "example": "14-813af5085bb6a2648c3f0aca37fc821f"
296
- },
297
- "name": {
298
- "description": "The notebook name",
299
- "type": "string",
300
- "minLength": 1,
301
- "maxLength": 64
302
- },
303
- "updatedAt": {
304
- "description": "The date time when the notebook was last updated, represented with Unix timestamps in milliseconds",
305
- "type": "number"
306
- },
307
- "createdAt": {
308
- "description": "The date time when the notebook was created, represented with Unix timestamps in milliseconds",
309
- "type": "number"
310
- },
311
- "count": {
312
- "description": "It indicates the number of notes in the notebook",
313
- "type": "number"
314
- },
315
- "parentBookId": {
316
- "description": "The ID of the parent notebook",
317
- "type": ["string", "null"]
318
- }
319
- },
320
- "required": ["_id", "name", "updatedAt", "createdAt"]
321
- };
322
- validate.errors = null;
323
- module.exports = validate;