@quanxiaoxiao/datav 0.5.0 → 0.5.1
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/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/validateExpressSchema.d.ts.map +1 -1
- package/dist/validateExpressSchema.js +2 -5
- package/dist/validateExpressSchema.js.map +1 -1
- package/package.json +2 -3
- package/src/validateExpressSchema.ts +2 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDataTransformer } from './createDataTransformer.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export { createDataTransformer,
|
|
2
|
+
import { type DataType, parseValueByType } from './parseValueByType.js';
|
|
3
|
+
import { type ExpressSchema, validateExpressSchema } from './validateExpressSchema.js';
|
|
4
|
+
export { createDataTransformer, type DataType, type ExpressSchema, parseValueByType, validateExpressSchema, };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,KAAK,QAAQ,EAAC,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,aAAa,EAAC,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEtF,OAAO,EACL,qBAAqB,EACrB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAgB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAqB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEtF,OAAO,EACL,qBAAqB,EAGrB,gBAAgB,EAChB,qBAAqB,GACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateExpressSchema.d.ts","sourceRoot":"","sources":["../src/validateExpressSchema.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;CACtD;
|
|
1
|
+
{"version":3,"file":"validateExpressSchema.d.ts","sourceRoot":"","sources":["../src/validateExpressSchema.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;CACtD;AA8CD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAMjE"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import Ajv from 'ajv';
|
|
2
|
-
const ajv = new Ajv
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
const ajv = new Ajv();
|
|
3
3
|
const schemaValidationRules = {
|
|
4
4
|
type: 'object',
|
|
5
5
|
anyOf: [
|
|
6
|
-
// 对象类型规则
|
|
7
6
|
{
|
|
8
7
|
properties: {
|
|
9
8
|
type: { enum: ['object'] },
|
|
@@ -11,7 +10,6 @@ const schemaValidationRules = {
|
|
|
11
10
|
},
|
|
12
11
|
required: ['type', 'properties'],
|
|
13
12
|
},
|
|
14
|
-
// 数组类型规则
|
|
15
13
|
{
|
|
16
14
|
properties: {
|
|
17
15
|
type: { enum: ['array'] },
|
|
@@ -33,7 +31,6 @@ const schemaValidationRules = {
|
|
|
33
31
|
},
|
|
34
32
|
required: ['type', 'properties'],
|
|
35
33
|
},
|
|
36
|
-
// 基础类型规则
|
|
37
34
|
{
|
|
38
35
|
properties: {
|
|
39
36
|
type: { enum: ['string', 'number', 'boolean', 'integer'] },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateExpressSchema.js","sourceRoot":"","sources":["../src/validateExpressSchema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"validateExpressSchema.js","sourceRoot":"","sources":["../src/validateExpressSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAQ1B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AAEtB,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACL;YACE,UAAU,EAAE;gBACV,IAAI,E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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quanxiaoxiao/datav",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Data transformation utility with type conversion, path access, and schema-driven data transformation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "
|
|
32
|
+
"test": "TSX_TSCONFIG=tsconfig.test.json node --import tsx --test 'src/**/*.test.ts'",
|
|
33
33
|
"build": "tsc && rm -rf dist/*.test.* dist/**/*.test.*",
|
|
34
34
|
"check": "tsc --noEmit",
|
|
35
35
|
"lint": "eslint .",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
".": {
|
|
43
43
|
"types": "./dist/index.d.ts",
|
|
44
44
|
"import": "./dist/index.js",
|
|
45
|
-
"require": "./dist/index.cjs",
|
|
46
45
|
"default": "./dist/index.js"
|
|
47
46
|
},
|
|
48
47
|
"./package.json": "./package.json"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Ajv from 'ajv';
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
2
|
|
|
3
3
|
export interface ExpressSchema {
|
|
4
4
|
type: 'string' | 'number' | 'boolean' | 'integer' | 'object' | 'array';
|
|
@@ -6,12 +6,11 @@ export interface ExpressSchema {
|
|
|
6
6
|
resolve?: (value: unknown, root: unknown) => unknown;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const ajv = new Ajv
|
|
9
|
+
const ajv = new Ajv();
|
|
10
10
|
|
|
11
11
|
const schemaValidationRules = {
|
|
12
12
|
type: 'object',
|
|
13
13
|
anyOf: [
|
|
14
|
-
// 对象类型规则
|
|
15
14
|
{
|
|
16
15
|
properties: {
|
|
17
16
|
type: { enum: ['object'] },
|
|
@@ -19,7 +18,6 @@ const schemaValidationRules = {
|
|
|
19
18
|
},
|
|
20
19
|
required: ['type', 'properties'],
|
|
21
20
|
},
|
|
22
|
-
// 数组类型规则
|
|
23
21
|
{
|
|
24
22
|
properties: {
|
|
25
23
|
type: { enum: ['array'] },
|
|
@@ -41,7 +39,6 @@ const schemaValidationRules = {
|
|
|
41
39
|
},
|
|
42
40
|
required: ['type', 'properties'],
|
|
43
41
|
},
|
|
44
|
-
// 基础类型规则
|
|
45
42
|
{
|
|
46
43
|
properties: {
|
|
47
44
|
type: { enum: ['string', 'number', 'boolean', 'integer'] },
|