koatty_validation 1.0.6 → 1.1.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.
@@ -0,0 +1 @@
1
+ window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":1,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":1,"startTime":1645007506342,"success":false,"testResults":[{"leaks":false,"numFailingTests":0,"numPassingTests":1,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1645007508064,"runtime":1655,"slow":false,"start":1645007506409},"skipped":false,"testFilePath":"/Users/richen/Workspace/nodejs/koatty_validation/test/.test.ts","testResults":[{"ancestorTitles":["koatty_validation"],"duration":3,"failureDetails":[],"failureMessages":[],"fullName":"koatty_validation ClassValidator","invocations":1,"location":null,"numPassingAsserts":0,"status":"passed","title":"ClassValidator"}],"failureMessage":null}],"wasInterrupted":false,"config":{"bail":0,"changedFilesWithAncestor":false,"collectCoverage":true,"collectCoverageFrom":[],"coverageDirectory":"coverage","coverageProvider":"babel","coverageReporters":["html","lcov","json","text","clover","text-summary"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"passWithNoTests":true,"projects":[],"reporters":[["default",{}],["/Users/richen/Workspace/nodejs/koatty_validation/node_modules/jest-html-reporters/index.js",{}]],"rootDir":"/Users/richen/Workspace/nodejs/koatty_validation","runTestsByPath":false,"skipFilter":false,"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/Users/richen/Workspace/nodejs/koatty_validation/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"verbose":true,"watch":false,"watchAll":false,"watchman":true},"endTime":1645007508191,"_reporterOptions":{"publicPath":"/Users/richen/Workspace/nodejs/koatty_validation","filename":"jest_html_reporters.html","expand":false,"pageTitle":"","hideIcon":false,"testCommand":"npx jest","openReport":false,"failureMessageOnly":false,"enableMergeData":false,"dataMergeLevel":1},"attachInfos":{}})
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
1
  {
2
2
  "name": "koatty_validation",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "Validation Util for Koatty and ThinkORM.",
5
5
  "scripts": {
6
- "build": "del-cli --force dist && tsc",
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup -c",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
7
11
  "eslint": "eslint --ext .ts,.js ./",
8
12
  "prepublishOnly": "npm test && npm run build",
9
- "release": "npm run prepublishOnly && standard-version",
13
+ "prerelease": "npm test && npm run build",
14
+ "release": "standard-version",
15
+ "release:pre": "npm run release -- --prerelease",
16
+ "release:major": "npm run release -- --release-as major",
17
+ "release:minor": "npm run release -- --release-as minor",
10
18
  "pub": "git push --follow-tags origin && npm publish",
11
19
  "test": "npm run eslint && jest --passWithNoTests",
12
20
  "test:cov": "jest --collectCoverage --detectOpenHandles",
13
21
  "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
14
22
  },
15
23
  "main": "./dist/index.js",
24
+ "exports": {
25
+ "require": "./dist/index.js",
26
+ "import": "./dist/index.mjs"
27
+ },
16
28
  "repository": {
17
29
  "type": "git",
18
30
  "url": "git+https://github.com/koatty/koatty_validation.git"
19
31
  },
20
- "keywords": [
21
- "validation",
22
- "koatty",
23
- "thinkKoa"
24
- ],
25
32
  "engines": {
26
33
  "node": ">10.0.0"
27
34
  },
@@ -41,25 +48,27 @@
41
48
  }
42
49
  ],
43
50
  "devDependencies": {
44
- "@babel/core": "^7.x.x",
45
- "@babel/plugin-proposal-decorators": "^7.x.x",
46
- "@babel/preset-env": "^7.x.x",
47
- "@babel/preset-typescript": "^7.x.x",
48
- "@commitlint/cli": "^12.x.x",
49
- "@commitlint/config-conventional": "^15.x.x",
51
+ "@microsoft/api-documenter": "^7.x.x",
52
+ "@microsoft/api-extractor": "^7.x.x",
53
+ "@rollup/plugin-json": "^4.x.x",
50
54
  "@types/jest": "^27.x.x",
51
55
  "@types/koa": "^2.x.x",
52
56
  "@types/node": "^16.x.x",
53
- "@types/validator": "^13.7.0",
57
+ "@types/validator": "^13.x.x",
54
58
  "@typescript-eslint/eslint-plugin": "^5.x.x",
55
59
  "@typescript-eslint/parser": "^5.x.x",
60
+ "commitlint": "^15.x.x",
61
+ "commitlint-config-gitmoji": "^2.x.x",
56
62
  "conventional-changelog-cli": "^2.x.x",
63
+ "copyfiles": "^2.x.x",
57
64
  "del-cli": "^4.x.x",
58
65
  "eslint": "^8.x.x",
59
66
  "eslint-plugin-jest": "^25.x.x",
60
67
  "husky": "^7.x.x",
61
68
  "jest": "^27.x.x",
62
69
  "jest-html-reporters": "^2.x.x",
70
+ "rollup": "^2.x.x",
71
+ "rollup-plugin-typescript2": "^0.x.x",
63
72
  "standard-version": "^9.x.x",
64
73
  "ts-jest": "^27.x.x",
65
74
  "ts-node": "^10.x.x",
@@ -73,9 +82,9 @@
73
82
  "reflect-metadata": "^0.1.13",
74
83
  "tslib": "^2.3.1"
75
84
  },
76
- "husky": {
77
- "hooks": {
78
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
79
- }
85
+ "peerDependencies": {
86
+ "koatty_container": "^1.x.x",
87
+ "koatty_lib": "^1.x.x",
88
+ "koatty_logger": "^1.x.x"
80
89
  }
81
90
  }
package/.eslintignore DELETED
@@ -1,9 +0,0 @@
1
- node_modules
2
- .eslintrc.js
3
- **/package-lock.json
4
- **/yarn.lock
5
- **/*.config.js
6
- dist
7
- coverage
8
- test
9
- demo
package/.eslintrc.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- *
3
- */
4
- module.exports = {
5
- root: true,
6
- parser: '@typescript-eslint/parser',
7
- extends: [
8
- 'plugin:@typescript-eslint/recommended', // 使用@typescript-eslint/eslint-plugin的推荐规则
9
- 'plugin:jest/recommended',
10
- ],
11
- plugins: [
12
- '@typescript-eslint',
13
- 'jest',
14
- ],
15
- parserOptions: {
16
- project: './tsconfig.json',
17
- },
18
- env: {
19
- node: true,
20
- mongo: true,
21
- jest: true,
22
- },
23
- rules: {
24
- "@typescript-eslint/no-explicit-any": "off",
25
- // "@typescript-eslint/no-require-imports": "off",
26
- "@typescript-eslint/no-var-requires": "off",
27
- "@typescript-eslint/member-ordering": "off",
28
- "@typescript-eslint/consistent-type-assertions": "off",
29
- "@typescript-eslint/no-param-reassign": "off",
30
- "@typescript-eslint/no-empty-function": "off",
31
- "@typescript-eslint/no-empty-interface": "off",
32
- "@typescript-eslint/explicit-module-boundary-types": "off",
33
- "@typescript-eslint/ban-types": ["error",
34
- {
35
- "types": {
36
- "Object": false,
37
- "Function": false,
38
- },
39
- "extendDefaults": true
40
- }
41
- ],
42
- },
43
- };
package/babel.config.js DELETED
@@ -1,21 +0,0 @@
1
- /*
2
- * @Description : babel配置
3
- * @usage : 用于jest执行用例
4
- */
5
-
6
- module.exports = {
7
- presets: [
8
- [
9
- '@babel/preset-env',
10
- {
11
- targets: {
12
- node: 'current',
13
- },
14
- },
15
- ],
16
- '@babel/preset-typescript',
17
- ],
18
- plugins: [
19
- ['@babel/plugin-proposal-decorators', { 'legacy': true }]
20
- ],
21
- };
@@ -1,14 +0,0 @@
1
- /*
2
- *
3
- */
4
- module.exports = {
5
- extends: ['@commitlint/config-conventional'],
6
- rules: {
7
- 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
8
- 'type-empty': [2, 'never'],
9
- 'scope-enum': [0], // 不校验scope类型
10
- 'scope-empty': [0], // 不校验scope是否设置
11
- 'subject-case': [0], // 不校验描述的字符格式
12
- 'subject-min-length': [2, 'always', 5], // 描述至少5个字符
13
- },
14
- };
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA;;;;;GAKG;AACH,gEAAqC;AAErC,+BAAwD;AACxD,uDAAgD;AAEhD,iCAAiC;AACjC,6BAAsJ;AAA7I,kGAAA,WAAW,OAAA;AAAE,sGAAA,eAAe,OAAA;AAAE,wGAAA,iBAAiB,OAAA;AAAE,oGAAA,aAAa,OAAA;AAAE,mGAAA,YAAY,OAAA;AAAE,qGAAA,cAAc,OAAA;AAAE,qGAAA,cAAc,OAAA;AAAE,sGAAA,eAAe,OAAA;AACtI,sDAAuB;AACvB,yCAAyC;AACzC,4CAA4C;AAE5C;;;;;;;GAOG;AACH,SAAgB,KAAK,CAAC,IAA0C,EAAE,OAAgB;IAC9E,IAAI,KAAK,GAAQ,EAAE,CAAC;IACpB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACvB,KAAK,GAAY,IAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACrC;SAAM;QACH,KAAK,GAAG,IAAI,CAAC;KAChB;IACD,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAAe,EAAE,EAAE;QACzD,WAAW;QACX,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACjF,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;QAE9G,+BAAY,CAAC,kBAAkB,CAAC,oBAAc,EAAE;YAC5C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,KAAK;YACX,OAAO;YACP,KAAK,EAAE,UAAU;YACjB,IAAI;SACP,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC5B,CAAC,CAAC;AACN,CAAC;AApBD,sBAoBC;AAED;;;;;GAKG;AACH,SAAgB,SAAS;IACrB,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;QACxE,EAAE;QACF,+BAAY,CAAC,gBAAgB,CAAC,qBAAe,EAAE;YAC3C,QAAQ,EAAE,CAAC;SACd,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QAExB,WAAW;QACX,0FAA0F;QAE1F,0DAA0D;QAC1D,iBAAiB;QACjB,oBAAoB;QACpB,kBAAkB;QAClB,sBAAsB;QACtB,qDAAqD;QACrD,gCAAgC;QAChC,4DAA4D;QAC5D,6DAA6D;QAC7D,2GAA2G;QAC3G,0CAA0C;QAC1C,iFAAiF;QACjF,uBAAuB;QACvB,mDAAmD;QACnD,gBAAgB;QAChB,cAAc;QACd,+BAA+B;QAC/B,6CAA6C;QAC7C,YAAY;QACZ,uDAAuD;QACvD,2CAA2C;QAC3C,QAAQ;QACR,KAAK;QACL,qBAAqB;IACzB,CAAC,CAAC;AACN,CAAC;AAnCD,8BAmCC"}
package/dist/lib.d.ts DELETED
@@ -1,131 +0,0 @@
1
- /**
2
- * @ author: richen
3
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
4
- * @ license: MIT
5
- * @ version: 2020-03-20 11:34:38
6
- */
7
- import "reflect-metadata";
8
- export declare const PARAM_TYPE_KEY = "PARAM_TYPE_KEY";
9
- export declare const PARAM_RULE_KEY = "PARAM_RULE_KEY";
10
- export declare const PARAM_CHECK_KEY = "PARAM_CHECK_KEY";
11
- export declare const ENABLE_VALIDATED = "ENABLE_VALIDATED";
12
- export declare enum paramterTypes {
13
- "Number" = 0,
14
- "number" = 1,
15
- "String" = 2,
16
- "string" = 3,
17
- "Boolean" = 4,
18
- "boolean" = 5,
19
- "Array" = 6,
20
- "array" = 7,
21
- "Tuple" = 8,
22
- "tuple" = 9,
23
- "Object" = 10,
24
- "object" = 11,
25
- "Enum" = 12,
26
- "enum" = 13
27
- }
28
- /**
29
- * get metadata value of a metadata key on the prototype chain of an object and property
30
- * @param metadataKey metadata key
31
- * @param target the target of metadataKey
32
- */
33
- export declare function recursiveGetMetadata(metadataKey: any, target: any, propertyKey?: string | symbol): any[];
34
- /**
35
- * Dynamically add methods for target class types
36
- *
37
- * @param {Function} clazz
38
- * @param {string} protoName
39
- * @param {Function} func
40
- */
41
- export declare function defineNewProperty(clazz: Function, protoName: string, func: Function): void;
42
- /**
43
- *
44
- *
45
- * @param {(string | symbol)} metadataKey
46
- * @param {*} target
47
- * @param {(string | symbol)} [propertyKey]
48
- * @returns
49
- */
50
- export declare function getOriginMetadata(metadataKey: string | symbol, target: any, propertyKey?: string | symbol): any;
51
- /**
52
- * Convert parameter's type to defined.
53
- *
54
- * @param {*} param
55
- * @param {string} type
56
- * @returns
57
- */
58
- export declare const convertParamsType: (param: any, type: string) => any;
59
- /**
60
- * Check the base types.
61
- *
62
- * @param {*} value
63
- * @param {string} type
64
- * @returns {*}
65
- */
66
- export declare const checkParamsType: (value: any, type: string) => any;
67
- /**
68
- *
69
- *
70
- * @export
71
- * @param {*} clazz
72
- * @param {*} data
73
- * @param {boolean} [convert=false]
74
- * @returns
75
- */
76
- export declare function plainToClass(clazz: any, data: any, convert?: boolean): any;
77
- /**
78
- * Checks if value is a chinese name.
79
- *
80
- * @param {string} value
81
- * @returns {boolean}
82
- */
83
- export declare function cnName(value: string): boolean;
84
- /**
85
- * Checks if value is a idCard number.
86
- *
87
- * @param {string} value
88
- * @returns
89
- */
90
- export declare function idNumber(value: string): boolean;
91
- /**
92
- * Checks if value is a mobile phone number.
93
- *
94
- * @param {string} value
95
- * @returns {boolean}
96
- */
97
- export declare function mobile(value: string): boolean;
98
- /**
99
- * Checks if value is a zipCode.
100
- *
101
- * @param {string} value
102
- * @returns {boolean}
103
- */
104
- export declare function zipCode(value: string): boolean;
105
- /**
106
- * Checks if value is a plateNumber.
107
- *
108
- * @param {string} value
109
- * @returns {boolean}
110
- */
111
- export declare function plateNumber(value: string): boolean;
112
- interface ParamOptions {
113
- index: number;
114
- isDto: boolean;
115
- type: string;
116
- validRules: any[];
117
- dtoCheck: boolean;
118
- }
119
- /**
120
- * Check parameters against predefined rules
121
- *
122
- * @export
123
- * @param {*} param
124
- * @param {number} index
125
- * @param {ParamOptions} [paramOptions={
126
- * validRules: [],
127
- * dtoCheck: false
128
- * }]
129
- */
130
- export declare function checkParams(value: any, paramOptions: ParamOptions): Promise<any>;
131
- export {};