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.
package/package.json CHANGED
@@ -1,17 +1,15 @@
1
1
  {
2
2
  "name": "inkdrop-model",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Data model for Inkdrop",
5
- "main": "lib/index.js",
6
5
  "scripts": {
7
- "build": "npm-run-all build:* doc",
8
- "build:lib": "babel src/ -d lib && flow-copy-source src lib",
6
+ "build": "npm-run-all build:schema build:lib doc",
7
+ "build:lib": "rollup -c && mv lib/src/* lib/ && rm -r lib/src",
9
8
  "build:schema": "./compile_schema.sh",
10
- "lint": "eslint src test",
11
- "flow": "flow check",
12
- "test": "ava",
9
+ "lint": "eslint src __tests__",
10
+ "test": "jest --config jest.config.js",
13
11
  "doc": "./generate_doc.sh",
14
- "prepublishOnly": "npm-run-all build:* lint flow test"
12
+ "prepublishOnly": "npm-run-all build:* lint test"
15
13
  },
16
14
  "author": "Takuya Matsuyama <t@inkdrop.app>",
17
15
  "license": "MIT",
@@ -20,35 +18,30 @@
20
18
  "url": "https://github.com/inkdropapp/inkdrop-model.git"
21
19
  },
22
20
  "devDependencies": {
23
- "@ava/babel": "^1.0.1",
24
- "@babel/cli": "^7.13.16",
25
- "@babel/core": "^7.13.16",
26
- "@babel/plugin-proposal-class-properties": "^7.13.0",
27
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
28
- "@babel/polyfill": "^7.12.1",
29
- "@babel/preset-env": "^7.13.15",
30
- "@babel/preset-flow": "^7.13.13",
21
+ "@rollup/plugin-node-resolve": "^13.2.1",
22
+ "@types/jest": "^27.4.1",
23
+ "@typescript-eslint/eslint-plugin": "^5.20.0",
24
+ "@typescript-eslint/parser": "^5.20.0",
31
25
  "ajv": "^8.1.0",
32
26
  "ajv-cli": "^5.0.0",
33
- "ava": "^3.15.0",
34
- "babel-eslint": "^10.1.0",
35
27
  "eslint": "^7.25.0",
36
28
  "eslint-config-prettier": "^8.3.0",
37
- "eslint-plugin-flowtype": "^5.7.2",
38
- "eslint-plugin-prettier": "^3.4.0",
39
- "flow-bin": "^0.149.0",
40
- "flow-copy-source": "^2.0.9",
29
+ "jest": "^27.5.1",
41
30
  "npm-run-all": "^4.1.5",
42
- "prettier": "^2.2.1",
31
+ "prettier": "^2.6.2",
32
+ "rollup": "^2.70.2",
33
+ "rollup-plugin-terser": "^7.0.2",
34
+ "rollup-plugin-typescript2": "^0.31.2",
35
+ "ts-jest": "^27.1.4",
36
+ "typescript": "^4.6.3",
43
37
  "yamljs": "^0.3.0"
44
38
  },
45
- "dependencies": {},
46
- "ava": {
47
- "babel": true
48
- },
39
+ "types": "lib/index.d.ts",
40
+ "main": "lib/index.umd.js",
41
+ "unpkg": "lib/index.umd.js",
42
+ "module": "lib/index.esm.js",
49
43
  "keywords": [
50
- "json-schema",
51
- "flowtype"
44
+ "json-schema"
52
45
  ],
53
46
  "files": [
54
47
  "lib",
@@ -1 +1 @@
1
- "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"book","title":"Book","description":"A notebook data","type":"object","properties":{"_id":{"description":"The unique notebook ID which should start with `book:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^book:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)","type":"string"},"name":{"description":"The notebook name","type":"string","minLength":1,"maxLength":64},"updatedAt":{"description":"The date time when the notebook was last updated, represented with Unix timestamps in milliseconds","type":"number"},"createdAt":{"description":"The date time when the notebook was created, represented with Unix timestamps in milliseconds","type":"number"},"count":{"description":"It indicates the number of notes in the notebook","type":"number"},"parentBookId":{"description":"The ID of the parent notebook","type":["string","null"]}},"required":["_id","name","updatedAt","createdAt"]};const func8 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^book:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="book" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((((data._id === undefined) && (missing0 = "_id")) || ((data.name === undefined) && (missing0 = "name"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func8(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func8(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^book:"},message:"must match pattern \""+"^book:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func8(data2) > 64){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"}];return false;}else {if(func8(data2) < 1){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}];return false;}}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data3 = data.updatedAt;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data4 = data.createdAt;const _errs9 = errors;if(!((typeof data4 == "number") && (isFinite(data4)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.count !== undefined){let data5 = data.count;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.parentBookId !== undefined){let data6 = data.parentBookId;const _errs13 = errors;if((typeof data6 !== "string") && (data6 !== null)){validate20.errors = [{instancePath:instancePath+"/parentBookId",schemaPath:"#/properties/parentBookId/type",keyword:"type",params:{type: schema22.properties.parentBookId.type},message:"must be string,null"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
1
+ "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"book","title":"Book","description":"A notebook data","type":"object","properties":{"_id":{"description":"The unique notebook ID which should start with `book:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^book:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)","type":"string"},"name":{"description":"The notebook name","type":"string","minLength":1,"maxLength":64},"updatedAt":{"description":"The date time when the notebook was last updated, represented with Unix timestamps in milliseconds","type":"number"},"createdAt":{"description":"The date time when the notebook was created, represented with Unix timestamps in milliseconds","type":"number"},"count":{"description":"It indicates the number of notes in the notebook","type":"number"},"parentBookId":{"description":"The ID of the parent notebook","type":["string","null"]}},"required":["_id","name","updatedAt","createdAt"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^book:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="book" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if(((((data._id === undefined) && (missing0 = "_id")) || ((data.name === undefined) && (missing0 = "name"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func4(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^book:"},message:"must match pattern \""+"^book:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 64){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"}];return false;}else {if(func4(data2) < 1){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}];return false;}}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data3 = data.updatedAt;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data4 = data.createdAt;const _errs9 = errors;if(!((typeof data4 == "number") && (isFinite(data4)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.count !== undefined){let data5 = data.count;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.parentBookId !== undefined){let data6 = data.parentBookId;const _errs13 = errors;if((typeof data6 !== "string") && (data6 !== null)){validate20.errors = [{instancePath:instancePath+"/parentBookId",schemaPath:"#/properties/parentBookId/type",keyword:"type",params:{type: schema22.properties.parentBookId.type},message:"must be string,null"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
@@ -1 +1 @@
1
- "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"file","title":"File","description":"An attachment file","type":"object","properties":{"_id":{"description":"The unique document ID which should start with `file:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^file:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).","type":"string"},"name":{"description":"The file name","type":"string","minLength":1,"maxLength":128},"createdAt":{"description":"The date time when the note was created, represented with Unix timestamps in milliseconds","type":"number"},"contentType":{"description":"The MIME type of the content","type":"string","enum":["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"],"maxLength":128},"contentLength":{"description":"The content length of the file","type":"number"},"publicIn":{"description":"An array of the note IDs where the file is included","type":"array","items":{"type":"string"},"uniqueItems":true},"_attachments":{"description":"The attachment file","type":"object","properties":{"index":{"description":"The attachment file","type":"object","properties":{"content_type":{"description":"The content type of the file","type":"string","enum":["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"]},"data":{"description":"The file data","type":["string","object"]}},"required":["content_type","data"]}},"required":["index"]}},"required":["_id","name","createdAt","contentType","contentLength","publicIn","_attachments"]};const func8 = require("ajv/dist/runtime/ucs2length").default;const func0 = require("ajv/dist/runtime/equal").default;const pattern0 = new RegExp("^file:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="file" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((((data._id === undefined) && (missing0 = "_id")) || ((data.name === undefined) && (missing0 = "name"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))) || ((data.contentType === undefined) && (missing0 = "contentType"))) || ((data.contentLength === undefined) && (missing0 = "contentLength"))) || ((data.publicIn === undefined) && (missing0 = "publicIn"))) || ((data._attachments === undefined) && (missing0 = "_attachments"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func8(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func8(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^file:"},message:"must match pattern \""+"^file:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func8(data2) > 128){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func8(data2) < 1){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}];return false;}}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data3 = data.createdAt;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.contentType !== undefined){let data4 = data.contentType;const _errs9 = errors;if(!(((((((data4 === "image/png") || (data4 === "image/jpeg")) || (data4 === "image/jpg")) || (data4 === "image/svg+xml")) || (data4 === "image/gif")) || (data4 === "image/heic")) || (data4 === "image/heif"))){validate20.errors = [{instancePath:instancePath+"/contentType",schemaPath:"#/properties/contentType/enum",keyword:"enum",params:{allowedValues: schema22.properties.contentType.enum},message:"must be equal to one of the allowed values"}];return false;}if(errors === _errs9){if(typeof data4 === "string"){if(func8(data4) > 128){validate20.errors = [{instancePath:instancePath+"/contentType",schemaPath:"#/properties/contentType/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/contentType",schemaPath:"#/properties/contentType/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.contentLength !== undefined){let data5 = data.contentLength;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/contentLength",schemaPath:"#/properties/contentLength/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.publicIn !== undefined){let data6 = data.publicIn;const _errs13 = errors;if(errors === _errs13){if(Array.isArray(data6)){var valid1 = true;const len0 = data6.length;for(let i0=0; i0<len0; i0++){const _errs15 = errors;if(typeof data6[i0] !== "string"){validate20.errors = [{instancePath:instancePath+"/publicIn/" + i0,schemaPath:"#/properties/publicIn/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs15 === errors;if(!valid1){break;}}if(valid1){let i1 = data6.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data6[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/publicIn",schemaPath:"#/properties/publicIn/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}else {validate20.errors = [{instancePath:instancePath+"/publicIn",schemaPath:"#/properties/publicIn/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data._attachments !== undefined){let data8 = data._attachments;const _errs17 = errors;if(errors === _errs17){if(data8 && typeof data8 == "object" && !Array.isArray(data8)){let missing1;if((data8.index === undefined) && (missing1 = "index")){validate20.errors = [{instancePath:instancePath+"/_attachments",schemaPath:"#/properties/_attachments/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data8.index !== undefined){let data9 = data8.index;const _errs19 = errors;if(errors === _errs19){if(data9 && typeof data9 == "object" && !Array.isArray(data9)){let missing2;if(((data9.content_type === undefined) && (missing2 = "content_type")) || ((data9.data === undefined) && (missing2 = "data"))){validate20.errors = [{instancePath:instancePath+"/_attachments/index",schemaPath:"#/properties/_attachments/properties/index/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}];return false;}else {if(data9.content_type !== undefined){let data10 = data9.content_type;const _errs21 = errors;if(typeof data10 !== "string"){validate20.errors = [{instancePath:instancePath+"/_attachments/index/content_type",schemaPath:"#/properties/_attachments/properties/index/properties/content_type/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(((((((data10 === "image/png") || (data10 === "image/jpeg")) || (data10 === "image/jpg")) || (data10 === "image/svg+xml")) || (data10 === "image/gif")) || (data10 === "image/heic")) || (data10 === "image/heif"))){validate20.errors = [{instancePath:instancePath+"/_attachments/index/content_type",schemaPath:"#/properties/_attachments/properties/index/properties/content_type/enum",keyword:"enum",params:{allowedValues: schema22.properties._attachments.properties.index.properties.content_type.enum},message:"must be equal to one of the allowed values"}];return false;}var valid4 = _errs21 === errors;}else {var valid4 = true;}if(valid4){if(data9.data !== undefined){let data11 = data9.data;const _errs23 = errors;if((typeof data11 !== "string") && (!(data11 && typeof data11 == "object" && !Array.isArray(data11)))){validate20.errors = [{instancePath:instancePath+"/_attachments/index/data",schemaPath:"#/properties/_attachments/properties/index/properties/data/type",keyword:"type",params:{type: schema22.properties._attachments.properties.index.properties.data.type},message:"must be string,object"}];return false;}var valid4 = _errs23 === errors;}else {var valid4 = true;}}}}else {validate20.errors = [{instancePath:instancePath+"/_attachments/index",schemaPath:"#/properties/_attachments/properties/index/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate20.errors = [{instancePath:instancePath+"/_attachments",schemaPath:"#/properties/_attachments/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs17 === errors;}else {var valid0 = true;}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
1
+ "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"file","title":"File","description":"An attachment file","type":"object","properties":{"_id":{"description":"The unique document ID which should start with `file:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^file:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).","type":"string"},"name":{"description":"The file name","type":"string","minLength":1,"maxLength":128},"createdAt":{"description":"The date time when the note was created, represented with Unix timestamps in milliseconds","type":"number"},"contentType":{"description":"The MIME type of the content","type":"string","enum":["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"],"maxLength":128},"contentLength":{"description":"The content length of the file","type":"number","maximum":10485760},"publicIn":{"description":"An array of the note IDs where the file is included","type":"array","items":{"type":"string"},"uniqueItems":true},"_attachments":{"description":"The attachment file","type":"object","properties":{"index":{"description":"The attachment file","type":"object","properties":{"content_type":{"description":"The content type of the file","type":"string","enum":["image/png","image/jpeg","image/jpg","image/svg+xml","image/gif","image/heic","image/heif"]},"data":{"description":"The file data","type":["string","object"]}},"required":["content_type","data"]}},"required":["index"]}},"required":["_id","name","createdAt","contentType","contentLength","publicIn","_attachments"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^file:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="file" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((((data._id === undefined) && (missing0 = "_id")) || ((data.name === undefined) && (missing0 = "name"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))) || ((data.contentType === undefined) && (missing0 = "contentType"))) || ((data.contentLength === undefined) && (missing0 = "contentLength"))) || ((data.publicIn === undefined) && (missing0 = "publicIn"))) || ((data._attachments === undefined) && (missing0 = "_attachments"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func4(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^file:"},message:"must match pattern \""+"^file:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 128){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data2) < 1){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"}];return false;}}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data3 = data.createdAt;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.contentType !== undefined){let data4 = data.contentType;const _errs9 = errors;if(!(((((((data4 === "image/png") || (data4 === "image/jpeg")) || (data4 === "image/jpg")) || (data4 === "image/svg+xml")) || (data4 === "image/gif")) || (data4 === "image/heic")) || (data4 === "image/heif"))){validate20.errors = [{instancePath:instancePath+"/contentType",schemaPath:"#/properties/contentType/enum",keyword:"enum",params:{allowedValues: schema22.properties.contentType.enum},message:"must be equal to one of the allowed values"}];return false;}if(errors === _errs9){if(typeof data4 === "string"){if(func4(data4) > 128){validate20.errors = [{instancePath:instancePath+"/contentType",schemaPath:"#/properties/contentType/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/contentType",schemaPath:"#/properties/contentType/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.contentLength !== undefined){let data5 = data.contentLength;const _errs11 = errors;if(errors === _errs11){if((typeof data5 == "number") && (isFinite(data5))){if(data5 > 10485760 || isNaN(data5)){validate20.errors = [{instancePath:instancePath+"/contentLength",schemaPath:"#/properties/contentLength/maximum",keyword:"maximum",params:{comparison: "<=", limit: 10485760},message:"must be <= 10485760"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/contentLength",schemaPath:"#/properties/contentLength/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.publicIn !== undefined){let data6 = data.publicIn;const _errs13 = errors;if(errors === _errs13){if(Array.isArray(data6)){var valid1 = true;const len0 = data6.length;for(let i0=0; i0<len0; i0++){const _errs15 = errors;if(typeof data6[i0] !== "string"){validate20.errors = [{instancePath:instancePath+"/publicIn/" + i0,schemaPath:"#/properties/publicIn/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs15 === errors;if(!valid1){break;}}if(valid1){let i1 = data6.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data6[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/publicIn",schemaPath:"#/properties/publicIn/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}else {validate20.errors = [{instancePath:instancePath+"/publicIn",schemaPath:"#/properties/publicIn/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data._attachments !== undefined){let data8 = data._attachments;const _errs17 = errors;if(errors === _errs17){if(data8 && typeof data8 == "object" && !Array.isArray(data8)){let missing1;if((data8.index === undefined) && (missing1 = "index")){validate20.errors = [{instancePath:instancePath+"/_attachments",schemaPath:"#/properties/_attachments/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data8.index !== undefined){let data9 = data8.index;const _errs19 = errors;if(errors === _errs19){if(data9 && typeof data9 == "object" && !Array.isArray(data9)){let missing2;if(((data9.content_type === undefined) && (missing2 = "content_type")) || ((data9.data === undefined) && (missing2 = "data"))){validate20.errors = [{instancePath:instancePath+"/_attachments/index",schemaPath:"#/properties/_attachments/properties/index/required",keyword:"required",params:{missingProperty: missing2},message:"must have required property '"+missing2+"'"}];return false;}else {if(data9.content_type !== undefined){let data10 = data9.content_type;const _errs21 = errors;if(typeof data10 !== "string"){validate20.errors = [{instancePath:instancePath+"/_attachments/index/content_type",schemaPath:"#/properties/_attachments/properties/index/properties/content_type/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(((((((data10 === "image/png") || (data10 === "image/jpeg")) || (data10 === "image/jpg")) || (data10 === "image/svg+xml")) || (data10 === "image/gif")) || (data10 === "image/heic")) || (data10 === "image/heif"))){validate20.errors = [{instancePath:instancePath+"/_attachments/index/content_type",schemaPath:"#/properties/_attachments/properties/index/properties/content_type/enum",keyword:"enum",params:{allowedValues: schema22.properties._attachments.properties.index.properties.content_type.enum},message:"must be equal to one of the allowed values"}];return false;}var valid4 = _errs21 === errors;}else {var valid4 = true;}if(valid4){if(data9.data !== undefined){let data11 = data9.data;const _errs23 = errors;if((typeof data11 !== "string") && (!(data11 && typeof data11 == "object" && !Array.isArray(data11)))){validate20.errors = [{instancePath:instancePath+"/_attachments/index/data",schemaPath:"#/properties/_attachments/properties/index/properties/data/type",keyword:"type",params:{type: schema22.properties._attachments.properties.index.properties.data.type},message:"must be string,object"}];return false;}var valid4 = _errs23 === errors;}else {var valid4 = true;}}}}else {validate20.errors = [{instancePath:instancePath+"/_attachments/index",schemaPath:"#/properties/_attachments/properties/index/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate20.errors = [{instancePath:instancePath+"/_attachments",schemaPath:"#/properties/_attachments/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs17 === errors;}else {var valid0 = true;}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
@@ -1 +1 @@
1
- "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"note","title":"Note","description":"A note data","type":"object","properties":{"_id":{"description":"The unique document ID which should start with `note:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^note:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).","type":"string"},"bookId":{"description":"The notebook ID","type":"string","minLength":5,"maxLength":128,"pattern":"^(book:|trash$)"},"title":{"description":"The note title","type":"string","maxLength":128},"doctype":{"description":"The format type of the body field. It currently can take markdown only, reserved for the future","type":"string","enum":["markdown"]},"body":{"description":"The content of the note represented with Markdown","type":"string","maxLength":1048576},"updatedAt":{"description":"The date time when the note was last updated, represented with Unix timestamps in milliseconds","type":"number"},"createdAt":{"description":"The date time when the note was created, represented with Unix timestamps in milliseconds","type":"number"},"tags":{"description":"The list of tag IDs","type":"array","items":{"type":"string"},"uniqueItems":true},"numOfTasks":{"description":"The number of tasks, extracted from body","type":"number"},"numOfCheckedTasks":{"description":"The number of checked tasks, extracted from body","type":"number"},"migratedBy":{"description":"The type of the data migration","type":"string","maxLength":128},"status":{"description":"The status of the note","type":"string","enum":["none","active","onHold","completed","dropped"]},"share":{"description":"The sharing mode of the note","type":"string","enum":["private","public"]},"pinned":{"description":"Whether the note is pinned to top","type":"boolean"},"_conflicts":{"description":"Conflicted revisions","type":"array","items":{"type":"string"},"uniqueItems":true}},"required":["_id","bookId","title","doctype","body","updatedAt","createdAt"]};const func8 = require("ajv/dist/runtime/ucs2length").default;const func0 = require("ajv/dist/runtime/equal").default;const pattern0 = new RegExp("^note:", "u");const pattern1 = new RegExp("^(book:|trash$)", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="note" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((((data._id === undefined) && (missing0 = "_id")) || ((data.bookId === undefined) && (missing0 = "bookId"))) || ((data.title === undefined) && (missing0 = "title"))) || ((data.doctype === undefined) && (missing0 = "doctype"))) || ((data.body === undefined) && (missing0 = "body"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func8(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func8(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^note:"},message:"must match pattern \""+"^note:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.bookId !== undefined){let data2 = data.bookId;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func8(data2) > 128){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func8(data2) < 5){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/minLength",keyword:"minLength",params:{limit: 5},message:"must NOT have fewer than 5 characters"}];return false;}else {if(!pattern1.test(data2)){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/pattern",keyword:"pattern",params:{pattern: "^(book:|trash$)"},message:"must match pattern \""+"^(book:|trash$)"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.title !== undefined){let data3 = data.title;const _errs7 = errors;if(errors === _errs7){if(typeof data3 === "string"){if(func8(data3) > 128){validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.doctype !== undefined){let data4 = data.doctype;const _errs9 = errors;if(typeof data4 !== "string"){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(data4 === "markdown")){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/enum",keyword:"enum",params:{allowedValues: schema22.properties.doctype.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.body !== undefined){let data5 = data.body;const _errs11 = errors;if(errors === _errs11){if(typeof data5 === "string"){if(func8(data5) > 1048576){validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/maxLength",keyword:"maxLength",params:{limit: 1048576},message:"must NOT have more than 1048576 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data6 = data.updatedAt;const _errs13 = errors;if(!((typeof data6 == "number") && (isFinite(data6)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data7 = data.createdAt;const _errs15 = errors;if(!((typeof data7 == "number") && (isFinite(data7)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs15 === errors;}else {var valid0 = true;}if(valid0){if(data.tags !== undefined){let data8 = data.tags;const _errs17 = errors;if(errors === _errs17){if(Array.isArray(data8)){var valid1 = true;const len0 = data8.length;for(let i0=0; i0<len0; i0++){const _errs19 = errors;if(typeof data8[i0] !== "string"){validate20.errors = [{instancePath:instancePath+"/tags/" + i0,schemaPath:"#/properties/tags/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs19 === errors;if(!valid1){break;}}if(valid1){let i1 = data8.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data8[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}else {validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs17 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfTasks !== undefined){let data10 = data.numOfTasks;const _errs21 = errors;if(!((typeof data10 == "number") && (isFinite(data10)))){validate20.errors = [{instancePath:instancePath+"/numOfTasks",schemaPath:"#/properties/numOfTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs21 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfCheckedTasks !== undefined){let data11 = data.numOfCheckedTasks;const _errs23 = errors;if(!((typeof data11 == "number") && (isFinite(data11)))){validate20.errors = [{instancePath:instancePath+"/numOfCheckedTasks",schemaPath:"#/properties/numOfCheckedTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs23 === errors;}else {var valid0 = true;}if(valid0){if(data.migratedBy !== undefined){let data12 = data.migratedBy;const _errs25 = errors;if(errors === _errs25){if(typeof data12 === "string"){if(func8(data12) > 128){validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs25 === errors;}else {var valid0 = true;}if(valid0){if(data.status !== undefined){let data13 = data.status;const _errs27 = errors;if(typeof data13 !== "string"){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(((((data13 === "none") || (data13 === "active")) || (data13 === "onHold")) || (data13 === "completed")) || (data13 === "dropped"))){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema22.properties.status.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs27 === errors;}else {var valid0 = true;}if(valid0){if(data.share !== undefined){let data14 = data.share;const _errs29 = errors;if(typeof data14 !== "string"){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((data14 === "private") || (data14 === "public"))){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/enum",keyword:"enum",params:{allowedValues: schema22.properties.share.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs29 === errors;}else {var valid0 = true;}if(valid0){if(data.pinned !== undefined){const _errs31 = errors;if(typeof data.pinned !== "boolean"){validate20.errors = [{instancePath:instancePath+"/pinned",schemaPath:"#/properties/pinned/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs31 === errors;}else {var valid0 = true;}if(valid0){if(data._conflicts !== undefined){let data16 = data._conflicts;const _errs33 = errors;if(errors === _errs33){if(Array.isArray(data16)){var valid3 = true;const len1 = data16.length;for(let i2=0; i2<len1; i2++){const _errs35 = errors;if(typeof data16[i2] !== "string"){validate20.errors = [{instancePath:instancePath+"/_conflicts/" + i2,schemaPath:"#/properties/_conflicts/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid3 = _errs35 === errors;if(!valid3){break;}}if(valid3){let i3 = data16.length;let j1;if(i3 > 1){const indices1 = {};for(;i3--;){let item1 = data16[i3];if(typeof item1 !== "string"){continue;}if(typeof indices1[item1] == "number"){j1 = indices1[item1];validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices1[item1] = i3;}}}}else {validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs33 === errors;}else {var valid0 = true;}}}}}}}}}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
1
+ "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"note","title":"Note","description":"A note data","type":"object","properties":{"_id":{"description":"The unique document ID which should start with `note:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^note:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).","type":"string"},"bookId":{"description":"The notebook ID","type":"string","minLength":5,"maxLength":128,"pattern":"^(book:|trash$)"},"title":{"description":"The note title","type":"string","maxLength":128},"doctype":{"description":"The format type of the body field. It currently can take markdown only, reserved for the future","type":"string","enum":["markdown"]},"body":{"description":"The content of the note represented with Markdown","type":"string","maxLength":1048576},"updatedAt":{"description":"The date time when the note was last updated, represented with Unix timestamps in milliseconds","type":"number"},"createdAt":{"description":"The date time when the note was created, represented with Unix timestamps in milliseconds","type":"number"},"tags":{"description":"The list of tag IDs","type":"array","items":{"type":"string"},"uniqueItems":true},"numOfTasks":{"description":"The number of tasks, extracted from body","type":"number"},"numOfCheckedTasks":{"description":"The number of checked tasks, extracted from body","type":"number"},"migratedBy":{"description":"The type of the data migration","type":"string","maxLength":128},"status":{"description":"The status of the note","type":"string","enum":["none","active","onHold","completed","dropped"]},"share":{"description":"The sharing mode of the note","type":"string","enum":["private","public"]},"pinned":{"description":"Whether the note is pinned to top","type":"boolean"},"_conflicts":{"description":"Conflicted revisions","type":"array","items":{"type":"string"},"uniqueItems":true}},"required":["_id","bookId","title","doctype","body","updatedAt","createdAt"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^note:", "u");const pattern1 = new RegExp("^(book:|trash$)", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="note" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((((data._id === undefined) && (missing0 = "_id")) || ((data.bookId === undefined) && (missing0 = "bookId"))) || ((data.title === undefined) && (missing0 = "title"))) || ((data.doctype === undefined) && (missing0 = "doctype"))) || ((data.body === undefined) && (missing0 = "body"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func4(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^note:"},message:"must match pattern \""+"^note:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.bookId !== undefined){let data2 = data.bookId;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 128){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data2) < 5){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/minLength",keyword:"minLength",params:{limit: 5},message:"must NOT have fewer than 5 characters"}];return false;}else {if(!pattern1.test(data2)){validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/pattern",keyword:"pattern",params:{pattern: "^(book:|trash$)"},message:"must match pattern \""+"^(book:|trash$)"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/bookId",schemaPath:"#/properties/bookId/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.title !== undefined){let data3 = data.title;const _errs7 = errors;if(errors === _errs7){if(typeof data3 === "string"){if(func4(data3) > 128){validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/title",schemaPath:"#/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.doctype !== undefined){let data4 = data.doctype;const _errs9 = errors;if(typeof data4 !== "string"){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(data4 === "markdown")){validate20.errors = [{instancePath:instancePath+"/doctype",schemaPath:"#/properties/doctype/enum",keyword:"enum",params:{allowedValues: schema22.properties.doctype.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.body !== undefined){let data5 = data.body;const _errs11 = errors;if(errors === _errs11){if(typeof data5 === "string"){if(func4(data5) > 1048576){validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/maxLength",keyword:"maxLength",params:{limit: 1048576},message:"must NOT have more than 1048576 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data6 = data.updatedAt;const _errs13 = errors;if(!((typeof data6 == "number") && (isFinite(data6)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data7 = data.createdAt;const _errs15 = errors;if(!((typeof data7 == "number") && (isFinite(data7)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs15 === errors;}else {var valid0 = true;}if(valid0){if(data.tags !== undefined){let data8 = data.tags;const _errs17 = errors;if(errors === _errs17){if(Array.isArray(data8)){var valid1 = true;const len0 = data8.length;for(let i0=0; i0<len0; i0++){const _errs19 = errors;if(typeof data8[i0] !== "string"){validate20.errors = [{instancePath:instancePath+"/tags/" + i0,schemaPath:"#/properties/tags/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs19 === errors;if(!valid1){break;}}if(valid1){let i1 = data8.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data8[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}else {validate20.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs17 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfTasks !== undefined){let data10 = data.numOfTasks;const _errs21 = errors;if(!((typeof data10 == "number") && (isFinite(data10)))){validate20.errors = [{instancePath:instancePath+"/numOfTasks",schemaPath:"#/properties/numOfTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs21 === errors;}else {var valid0 = true;}if(valid0){if(data.numOfCheckedTasks !== undefined){let data11 = data.numOfCheckedTasks;const _errs23 = errors;if(!((typeof data11 == "number") && (isFinite(data11)))){validate20.errors = [{instancePath:instancePath+"/numOfCheckedTasks",schemaPath:"#/properties/numOfCheckedTasks/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs23 === errors;}else {var valid0 = true;}if(valid0){if(data.migratedBy !== undefined){let data12 = data.migratedBy;const _errs25 = errors;if(errors === _errs25){if(typeof data12 === "string"){if(func4(data12) > 128){validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/migratedBy",schemaPath:"#/properties/migratedBy/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs25 === errors;}else {var valid0 = true;}if(valid0){if(data.status !== undefined){let data13 = data.status;const _errs27 = errors;if(typeof data13 !== "string"){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!(((((data13 === "none") || (data13 === "active")) || (data13 === "onHold")) || (data13 === "completed")) || (data13 === "dropped"))){validate20.errors = [{instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema22.properties.status.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs27 === errors;}else {var valid0 = true;}if(valid0){if(data.share !== undefined){let data14 = data.share;const _errs29 = errors;if(typeof data14 !== "string"){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((data14 === "private") || (data14 === "public"))){validate20.errors = [{instancePath:instancePath+"/share",schemaPath:"#/properties/share/enum",keyword:"enum",params:{allowedValues: schema22.properties.share.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs29 === errors;}else {var valid0 = true;}if(valid0){if(data.pinned !== undefined){const _errs31 = errors;if(typeof data.pinned !== "boolean"){validate20.errors = [{instancePath:instancePath+"/pinned",schemaPath:"#/properties/pinned/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid0 = _errs31 === errors;}else {var valid0 = true;}if(valid0){if(data._conflicts !== undefined){let data16 = data._conflicts;const _errs33 = errors;if(errors === _errs33){if(Array.isArray(data16)){var valid3 = true;const len1 = data16.length;for(let i2=0; i2<len1; i2++){const _errs35 = errors;if(typeof data16[i2] !== "string"){validate20.errors = [{instancePath:instancePath+"/_conflicts/" + i2,schemaPath:"#/properties/_conflicts/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid3 = _errs35 === errors;if(!valid3){break;}}if(valid3){let i3 = data16.length;let j1;if(i3 > 1){const indices1 = {};for(;i3--;){let item1 = data16[i3];if(typeof item1 !== "string"){continue;}if(typeof indices1[item1] == "number"){j1 = indices1[item1];validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices1[item1] = i3;}}}}else {validate20.errors = [{instancePath:instancePath+"/_conflicts",schemaPath:"#/properties/_conflicts/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs33 === errors;}else {var valid0 = true;}}}}}}}}}}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
package/validators/tag.js CHANGED
@@ -1 +1 @@
1
- "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"tag","title":"Tag","description":"A note tag","type":"object","properties":{"_id":{"description":"The unique tag ID which should start with `tag:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^tag:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)","type":"string"},"name":{"description":"The name of the tag","type":"string","maxLength":64},"count":{"description":"It indicates the number of notes with the tag","type":"number"},"color":{"description":"The color type of the tag","type":"string","enum":["default","red","orange","yellow","olive","green","teal","blue","violet","purple","pink","brown","grey","black"]},"updatedAt":{"description":"The date time when the tag was last updated, represented with Unix timestamps in milliseconds","type":"number"},"createdAt":{"description":"The date time when the tag was created, represented with Unix timestamps in milliseconds","type":"number"}},"required":["_id","name","count","updatedAt","createdAt"]};const func8 = require("ajv/dist/runtime/ucs2length").default;const func0 = require("ajv/dist/runtime/equal").default;const pattern0 = new RegExp("^tag:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="tag" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((data._id === undefined) && (missing0 = "_id")) || ((data.name === undefined) && (missing0 = "name"))) || ((data.count === undefined) && (missing0 = "count"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func8(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func8(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^tag:"},message:"must match pattern \""+"^tag:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func8(data2) > 64){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.count !== undefined){let data3 = data.count;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.color !== undefined){let data4 = data.color;const _errs9 = errors;if(typeof data4 !== "string"){validate20.errors = [{instancePath:instancePath+"/color",schemaPath:"#/properties/color/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((((((((((((((data4 === "default") || (data4 === "red")) || (data4 === "orange")) || (data4 === "yellow")) || (data4 === "olive")) || (data4 === "green")) || (data4 === "teal")) || (data4 === "blue")) || (data4 === "violet")) || (data4 === "purple")) || (data4 === "pink")) || (data4 === "brown")) || (data4 === "grey")) || (data4 === "black"))){validate20.errors = [{instancePath:instancePath+"/color",schemaPath:"#/properties/color/enum",keyword:"enum",params:{allowedValues: schema22.properties.color.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data5 = data.updatedAt;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data6 = data.createdAt;const _errs13 = errors;if(!((typeof data6 == "number") && (isFinite(data6)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
1
+ "use strict";module.exports = validate20;module.exports.default = validate20;const schema22 = {"$schema":"http://json-schema.org/draft-07/schema#","$id":"tag","title":"Tag","description":"A note tag","type":"object","properties":{"_id":{"description":"The unique tag ID which should start with `tag:` and the remains are randomly generated string","type":"string","minLength":6,"maxLength":128,"pattern":"^tag:"},"_rev":{"description":"This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable)","type":"string"},"name":{"description":"The name of the tag","type":"string","maxLength":64},"count":{"description":"It indicates the number of notes with the tag","type":"number"},"color":{"description":"The color type of the tag","type":"string","enum":["default","red","orange","yellow","olive","green","teal","blue","violet","purple","pink","brown","grey","black"]},"updatedAt":{"description":"The date time when the tag was last updated, represented with Unix timestamps in milliseconds","type":"number"},"createdAt":{"description":"The date time when the tag was created, represented with Unix timestamps in milliseconds","type":"number"}},"required":["_id","name","count","updatedAt","createdAt"]};const func4 = require("ajv/dist/runtime/ucs2length").default;const pattern0 = new RegExp("^tag:", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){/*# sourceURL="tag" */;let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((((data._id === undefined) && (missing0 = "_id")) || ((data.name === undefined) && (missing0 = "name"))) || ((data.count === undefined) && (missing0 = "count"))) || ((data.updatedAt === undefined) && (missing0 = "updatedAt"))) || ((data.createdAt === undefined) && (missing0 = "createdAt"))){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data._id !== undefined){let data0 = data._id;const _errs1 = errors;if(errors === _errs1){if(typeof data0 === "string"){if(func4(data0) > 128){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"}];return false;}else {if(func4(data0) < 6){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/minLength",keyword:"minLength",params:{limit: 6},message:"must NOT have fewer than 6 characters"}];return false;}else {if(!pattern0.test(data0)){validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/pattern",keyword:"pattern",params:{pattern: "^tag:"},message:"must match pattern \""+"^tag:"+"\""}];return false;}}}}else {validate20.errors = [{instancePath:instancePath+"/_id",schemaPath:"#/properties/_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data._rev !== undefined){const _errs3 = errors;if(typeof data._rev !== "string"){validate20.errors = [{instancePath:instancePath+"/_rev",schemaPath:"#/properties/_rev/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.name !== undefined){let data2 = data.name;const _errs5 = errors;if(errors === _errs5){if(typeof data2 === "string"){if(func4(data2) > 64){validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"}];return false;}}else {validate20.errors = [{instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}}var valid0 = _errs5 === errors;}else {var valid0 = true;}if(valid0){if(data.count !== undefined){let data3 = data.count;const _errs7 = errors;if(!((typeof data3 == "number") && (isFinite(data3)))){validate20.errors = [{instancePath:instancePath+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}if(valid0){if(data.color !== undefined){let data4 = data.color;const _errs9 = errors;if(typeof data4 !== "string"){validate20.errors = [{instancePath:instancePath+"/color",schemaPath:"#/properties/color/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}if(!((((((((((((((data4 === "default") || (data4 === "red")) || (data4 === "orange")) || (data4 === "yellow")) || (data4 === "olive")) || (data4 === "green")) || (data4 === "teal")) || (data4 === "blue")) || (data4 === "violet")) || (data4 === "purple")) || (data4 === "pink")) || (data4 === "brown")) || (data4 === "grey")) || (data4 === "black"))){validate20.errors = [{instancePath:instancePath+"/color",schemaPath:"#/properties/color/enum",keyword:"enum",params:{allowedValues: schema22.properties.color.enum},message:"must be equal to one of the allowed values"}];return false;}var valid0 = _errs9 === errors;}else {var valid0 = true;}if(valid0){if(data.updatedAt !== undefined){let data5 = data.updatedAt;const _errs11 = errors;if(!((typeof data5 == "number") && (isFinite(data5)))){validate20.errors = [{instancePath:instancePath+"/updatedAt",schemaPath:"#/properties/updatedAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs11 === errors;}else {var valid0 = true;}if(valid0){if(data.createdAt !== undefined){let data6 = data.createdAt;const _errs13 = errors;if(!((typeof data6 == "number") && (isFinite(data6)))){validate20.errors = [{instancePath:instancePath+"/createdAt",schemaPath:"#/properties/createdAt/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}var valid0 = _errs13 === errors;}else {var valid0 = true;}}}}}}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}
package/lib/book.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BookSchema", {
7
- enumerable: true,
8
- get: function () {
9
- return _book.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "validateBook", {
13
- enumerable: true,
14
- get: function () {
15
- return _book2.default;
16
- }
17
- });
18
-
19
- var _book = _interopRequireDefault(require("../json-schema/book.json"));
20
-
21
- var _book2 = _interopRequireDefault(require("../validators/book.js"));
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
-
25
- delete _book.default.id;
package/lib/book.js.flow DELETED
@@ -1,27 +0,0 @@
1
- // @flow
2
- import BookSchema from '../json-schema/book.json'
3
- import validateBook from '../validators/book.js'
4
- import type { EncryptedData } from './crypto'
5
-
6
- delete BookSchema.id
7
-
8
- export type BookMetadata = {
9
- _id: string,
10
- _rev?: string,
11
- updatedAt: number,
12
- createdAt: number,
13
- count?: number,
14
- parentBookId?: null | string
15
- }
16
-
17
- export type Book = {
18
- ...$Exact<BookMetadata>,
19
- name: string
20
- }
21
-
22
- export type EncryptedBook = {
23
- ...$Exact<BookMetadata>,
24
- encryptedData: EncryptedData
25
- }
26
-
27
- export { BookSchema, validateBook }
package/lib/crypto.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,12 +0,0 @@
1
- // @flow
2
-
3
- export type EncryptionMetadata = {
4
- algorithm: string,
5
- iv: string,
6
- tag: string
7
- }
8
-
9
- export type EncryptedData = {
10
- ...$Exact<EncryptionMetadata>,
11
- content: string | Buffer
12
- }
package/lib/file.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "FileSchema", {
7
- enumerable: true,
8
- get: function () {
9
- return _file.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "validateFile", {
13
- enumerable: true,
14
- get: function () {
15
- return _file2.default;
16
- }
17
- });
18
- exports.maxAttachmentFileSize = exports.SUPPORTED_IMAGE_MIME_TYPES = exports.supportedImageFileTypes = void 0;
19
-
20
- var _file = _interopRequireDefault(require("../json-schema/file.json"));
21
-
22
- var _file2 = _interopRequireDefault(require("../validators/file.js"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
-
30
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
32
- delete _file.default.id;
33
- const supportedImageFileTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/svg+xml', 'image/gif', 'image/heic', 'image/heif'];
34
- exports.supportedImageFileTypes = supportedImageFileTypes;
35
-
36
- const SUPPORTED_IMAGE_MIME_TYPES = _objectSpread(_objectSpread({}, supportedImageFileTypes.reduce((hash, ft) => _objectSpread(_objectSpread({}, hash), {}, {
37
- [ft.split('/')[1]]: ft
38
- }), {})), {}, {
39
- jpg: 'image/jpeg'
40
- });
41
-
42
- exports.SUPPORTED_IMAGE_MIME_TYPES = SUPPORTED_IMAGE_MIME_TYPES;
43
- const maxAttachmentFileSize = 10 * 1024 * 1024;
44
- exports.maxAttachmentFileSize = maxAttachmentFileSize;
package/lib/file.js.flow DELETED
@@ -1,60 +0,0 @@
1
- // @flow
2
- import FileSchema from '../json-schema/file.json'
3
- import validateFile from '../validators/file.js'
4
- import type { EncryptionMetadata } from './crypto'
5
-
6
- delete FileSchema.id
7
-
8
- export type ImageFileType =
9
- | 'image/png'
10
- | 'image/jpeg'
11
- | 'image/jpg'
12
- | 'image/svg+xml'
13
- | 'image/gif'
14
- | 'image/heic'
15
- | 'image/heif'
16
- export const supportedImageFileTypes: $ReadOnlyArray<ImageFileType> = [
17
- 'image/png',
18
- 'image/jpeg',
19
- 'image/jpg',
20
- 'image/svg+xml',
21
- 'image/gif',
22
- 'image/heic',
23
- 'image/heif'
24
- ]
25
- export const SUPPORTED_IMAGE_MIME_TYPES: $ReadOnly<{
26
- [string]: ImageFileType
27
- }> = {
28
- ...supportedImageFileTypes.reduce(
29
- (hash, ft) => ({ ...hash, [ft.split('/')[1]]: ft }),
30
- ({}: { [string]: ImageFileType })
31
- ),
32
- jpg: 'image/jpeg'
33
- }
34
- export const maxAttachmentFileSize: number = 10 * 1024 * 1024
35
-
36
- export type FileAttachmentItem = {
37
- content_type: ImageFileType,
38
- data: Buffer | string
39
- }
40
-
41
- export type File = {
42
- _id: string,
43
- _rev?: string,
44
- name: string,
45
- createdAt: number,
46
- contentType: ImageFileType,
47
- contentLength: number,
48
- publicIn: string[],
49
- _attachments: {
50
- index: FileAttachmentItem
51
- },
52
- md5digest?: string
53
- }
54
-
55
- export type EncryptedFile = {
56
- ...$Exact<File>,
57
- encryptionData: EncryptionMetadata
58
- }
59
-
60
- export { FileSchema, validateFile }
package/lib/index.js.flow DELETED
@@ -1,6 +0,0 @@
1
- // @flow
2
- export * from './note'
3
- export * from './book'
4
- export * from './tag'
5
- export * from './file'
6
- export * from './crypto'
package/lib/note.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "NoteSchema", {
7
- enumerable: true,
8
- get: function () {
9
- return _note.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "validateNote", {
13
- enumerable: true,
14
- get: function () {
15
- return _note2.default;
16
- }
17
- });
18
- exports.NOTE_VISIBILITY = exports.NOTE_STATUS = exports.TRASH_BOOK_ID = void 0;
19
-
20
- var _note = _interopRequireDefault(require("../json-schema/note.json"));
21
-
22
- var _note2 = _interopRequireDefault(require("../validators/note.js"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- delete _note.default.id;
27
- const TRASH_BOOK_ID = 'trash';
28
- exports.TRASH_BOOK_ID = TRASH_BOOK_ID;
29
- const NOTE_STATUS = {
30
- NONE: 'none',
31
- ACTIVE: 'active',
32
- ON_HOLD: 'onHold',
33
- COMPLETED: 'completed',
34
- DROPPED: 'dropped'
35
- };
36
- exports.NOTE_STATUS = NOTE_STATUS;
37
- const NOTE_VISIBILITY = {
38
- PRIVATE: 'private',
39
- PUBLIC: 'public'
40
- };
41
- exports.NOTE_VISIBILITY = NOTE_VISIBILITY;
package/lib/note.js.flow DELETED
@@ -1,53 +0,0 @@
1
- // @flow
2
- import NoteSchema from '../json-schema/note.json'
3
- import validateNote from '../validators/note.js'
4
- import type { EncryptedData } from './crypto'
5
-
6
- export type TrashBookId = 'trash'
7
- export type NoteStatus = 'none' | 'active' | 'onHold' | 'completed' | 'dropped'
8
- export type NoteVisibility = 'private' | 'public'
9
-
10
- export type NoteMetadata = {
11
- _id: string,
12
- _rev?: string,
13
- bookId: string,
14
- doctype: string,
15
- updatedAt: number,
16
- createdAt: number,
17
- tags?: string[],
18
- numOfTasks?: number,
19
- numOfCheckedTasks?: number,
20
- migratedBy?: string,
21
- status?: NoteStatus,
22
- share?: NoteVisibility,
23
- pinned?: boolean,
24
- _conflicts?: string[]
25
- }
26
-
27
- export type Note = {
28
- ...$Exact<NoteMetadata>,
29
- title: string,
30
- body: string
31
- }
32
-
33
- export type EncryptedNote = {
34
- ...$Exact<NoteMetadata>,
35
- encryptedData: EncryptedData
36
- }
37
-
38
- delete NoteSchema.id
39
- export const TRASH_BOOK_ID = 'trash'
40
-
41
- export const NOTE_STATUS: $ReadOnly<{ [string]: NoteStatus }> = {
42
- NONE: 'none',
43
- ACTIVE: 'active',
44
- ON_HOLD: 'onHold',
45
- COMPLETED: 'completed',
46
- DROPPED: 'dropped'
47
- }
48
- export const NOTE_VISIBILITY: $ReadOnly<{ [string]: NoteVisibility }> = {
49
- PRIVATE: 'private',
50
- PUBLIC: 'public'
51
- }
52
-
53
- export { NoteSchema, validateNote }
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;