schema-dsl 1.2.4 → 2.0.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/CHANGELOG.md +87 -210
- package/README.md +391 -2249
- package/dist/DslBuilder-DQDN0ZxZ.d.cts +341 -0
- package/dist/DslBuilder-DkLaOo9Q.d.ts +341 -0
- package/dist/Validator-C7GsVQOH.d.cts +192 -0
- package/dist/Validator-hFWKGxir.d.ts +192 -0
- package/dist/index.cjs +6594 -0
- package/dist/index.d.cts +1145 -0
- package/dist/index.d.ts +1145 -0
- package/dist/index.js +6528 -0
- package/dist/plugin-CIKtTMtS.d.cts +246 -0
- package/dist/plugin-CIKtTMtS.d.ts +246 -0
- package/dist/plugins/custom-format.cjs +3802 -0
- package/dist/plugins/custom-format.d.cts +12 -0
- package/dist/plugins/custom-format.d.ts +12 -0
- package/dist/plugins/custom-format.js +3772 -0
- package/dist/plugins/custom-type-example.cjs +3795 -0
- package/dist/plugins/custom-type-example.d.cts +8 -0
- package/dist/plugins/custom-type-example.d.ts +8 -0
- package/dist/plugins/custom-type-example.js +3765 -0
- package/dist/plugins/custom-validator.cjs +146 -0
- package/dist/plugins/custom-validator.d.cts +10 -0
- package/dist/plugins/custom-validator.d.ts +10 -0
- package/dist/plugins/custom-validator.js +121 -0
- package/docs/FEATURE-INDEX.md +102 -68
- package/docs/add-custom-locale.md +48 -35
- package/docs/add-keyword.md +24 -0
- package/docs/api-reference.md +396 -154
- package/docs/api.md +13 -0
- package/docs/best-practices-project-structure.md +19 -10
- package/docs/best-practices.md +93 -53
- package/docs/cache-manager.md +23 -15
- package/docs/compile.md +45 -0
- package/docs/conditional-api.md +40 -11
- package/docs/custom-extensions-guide.md +80 -152
- package/docs/design-philosophy.md +76 -71
- package/docs/doc-index.md +324 -0
- package/docs/dsl-syntax.md +69 -19
- package/docs/dynamic-locale.md +24 -14
- package/docs/enum.md +12 -5
- package/docs/error-handling.md +53 -44
- package/docs/export-guide.md +47 -8
- package/docs/export-limitations.md +27 -11
- package/docs/faq.md +86 -67
- package/docs/frontend-i18n-guide.md +26 -12
- package/docs/i18n-user-guide.md +60 -47
- package/docs/i18n.md +51 -32
- package/docs/index.md +48 -0
- package/docs/json-schema-basics.md +40 -0
- package/docs/label-vs-description.md +12 -3
- package/docs/markdown-exporter.md +15 -6
- package/docs/mongodb-exporter.md +11 -4
- package/docs/multi-language.md +26 -0
- package/docs/multi-type-support.md +26 -33
- package/docs/mysql-exporter.md +9 -2
- package/docs/number-operators.md +12 -5
- package/docs/optional-marker-guide.md +28 -23
- package/docs/performance-guide.md +49 -0
- package/docs/plugin-system.md +205 -366
- package/docs/plugin-type-registration.md +34 -0
- package/docs/postgresql-exporter.md +9 -2
- package/docs/public/favicon.svg +5 -0
- package/docs/quick-start.md +37 -363
- package/docs/runtime-locale-support.md +20 -9
- package/docs/schema-helper.md +10 -5
- package/docs/schema-utils-advanced-issues.md +23 -0
- package/docs/schema-utils-best-practices.md +20 -0
- package/docs/schema-utils-chaining.md +7 -0
- package/docs/schema-utils.md +76 -42
- package/docs/security-checklist.md +20 -0
- package/docs/string-extensions.md +17 -9
- package/docs/troubleshooting.md +36 -21
- package/docs/type-converter.md +41 -50
- package/docs/type-reference.md +38 -15
- package/docs/typescript-guide.md +53 -42
- package/docs/union-type-guide.md +11 -1
- package/docs/union-types.md +10 -3
- package/docs/validate-async.md +36 -25
- package/docs/validate-batch.md +49 -0
- package/docs/validate-dsl-object-support.md +33 -28
- package/docs/validate.md +36 -16
- package/docs/validation-guide.md +25 -7
- package/docs/validator.md +39 -0
- package/package.json +85 -27
- package/plugins/custom-format.cjs +8 -0
- package/plugins/custom-type-example.cjs +8 -0
- package/plugins/custom-validator.cjs +8 -0
- package/src/adapters/DslAdapter.ts +111 -0
- package/src/adapters/index.ts +1 -0
- package/src/config/constants.ts +83 -0
- package/src/config/index.ts +2 -0
- package/src/config/patterns.ts +77 -0
- package/src/core/CacheManager.ts +159 -0
- package/src/core/ConditionalBuilder.ts +382 -0
- package/src/core/ConditionalRuntime.ts +28 -0
- package/src/core/ConditionalValidator.ts +255 -0
- package/src/core/DslBuilder.ts +677 -0
- package/src/core/ErrorCodes.ts +38 -0
- package/src/core/ErrorFormatter.ts +271 -0
- package/src/core/JSONSchemaCore.ts +65 -0
- package/src/core/Locale.ts +187 -0
- package/src/core/MessageTemplate.ts +42 -0
- package/src/core/ObjectDslBuilder.ts +64 -0
- package/src/core/PluginManager.ts +326 -0
- package/src/core/StringExtensions.ts +140 -0
- package/src/core/TemplateEngine.ts +44 -0
- package/src/core/Validator.ts +448 -0
- package/src/errors/I18nError.ts +159 -0
- package/src/errors/ValidationError.ts +105 -0
- package/src/exporters/BaseExporter.ts +60 -0
- package/src/exporters/MarkdownExporter.ts +305 -0
- package/src/exporters/MongoDBExporter.ts +126 -0
- package/src/exporters/MySQLExporter.ts +155 -0
- package/src/exporters/PostgreSQLExporter.ts +222 -0
- package/src/exporters/index.ts +18 -0
- package/src/index.ts +633 -0
- package/{lib/locales/en-US.js → src/locales/en-US.ts} +21 -37
- package/{lib/locales/es-ES.js → src/locales/es-ES.ts} +63 -16
- package/{lib/locales/fr-FR.js → src/locales/fr-FR.ts} +74 -27
- package/src/locales/index.ts +103 -0
- package/{lib/locales/ja-JP.js → src/locales/ja-JP.ts} +59 -17
- package/src/locales/types.ts +156 -0
- package/{lib/locales/zh-CN.js → src/locales/zh-CN.ts} +21 -38
- package/src/parser/ConstraintParser.ts +101 -0
- package/src/parser/DslParser.ts +470 -0
- package/src/parser/SchemaCompiler.ts +66 -0
- package/src/parser/TypeRegistry.ts +250 -0
- package/src/parser/index.ts +6 -0
- package/src/plugins/custom-format.ts +126 -0
- package/src/plugins/custom-type-example.ts +108 -0
- package/src/plugins/custom-validator.ts +140 -0
- package/src/types/conditional.ts +28 -0
- package/src/types/config.ts +59 -0
- package/src/types/dsl.ts +131 -0
- package/src/types/error.ts +60 -0
- package/src/types/index.ts +17 -0
- package/src/types/infer.ts +128 -0
- package/src/types/plugin.ts +58 -0
- package/src/types/safe-regex.d.ts +9 -0
- package/src/types/schema.ts +66 -0
- package/src/types/validate.ts +71 -0
- package/src/utils/SchemaHelper.ts +196 -0
- package/src/utils/SchemaUtils.ts +346 -0
- package/src/utils/TypeConverter.ts +215 -0
- package/src/utils/index.ts +10 -0
- package/src/validators/CustomKeywords.ts +477 -0
- package/.eslintignore +0 -11
- package/.eslintrc.json +0 -27
- package/CONTRIBUTING.md +0 -368
- package/STATUS.md +0 -491
- package/changelogs/v1.0.0.md +0 -328
- package/changelogs/v1.0.9.md +0 -367
- package/changelogs/v1.1.0.md +0 -389
- package/changelogs/v1.1.1.md +0 -308
- package/changelogs/v1.1.2.md +0 -183
- package/changelogs/v1.1.3.md +0 -161
- package/changelogs/v1.1.4.md +0 -432
- package/changelogs/v1.1.5.md +0 -493
- package/changelogs/v1.1.6.md +0 -211
- package/changelogs/v1.1.8.md +0 -376
- package/changelogs/v1.2.3.md +0 -124
- package/docs/INDEX.md +0 -252
- package/docs/issues-resolved-summary.md +0 -196
- package/docs/performance-benchmark-report.md +0 -179
- package/docs/performance-quick-reference.md +0 -123
- package/docs/user-questions-answered.md +0 -353
- package/docs/validation-rules-v1.0.2.md +0 -1608
- package/examples/README.md +0 -81
- package/examples/array-dsl-example.js +0 -227
- package/examples/conditional-example.js +0 -288
- package/examples/conditional-non-object.js +0 -129
- package/examples/conditional-validate-example.js +0 -321
- package/examples/custom-extension.js +0 -85
- package/examples/dsl-match-example.js +0 -74
- package/examples/dsl-style.js +0 -118
- package/examples/dynamic-locale-configuration.js +0 -348
- package/examples/dynamic-locale-example.js +0 -287
- package/examples/enum.examples.js +0 -324
- package/examples/export-demo.js +0 -130
- package/examples/express-integration.js +0 -376
- package/examples/i18n-error-handling-complete.js +0 -381
- package/examples/i18n-error-handling-quickstart.md +0 -0
- package/examples/i18n-error.examples.js +0 -181
- package/examples/i18n-full-demo.js +0 -301
- package/examples/i18n-memory-safety.examples.js +0 -268
- package/examples/markdown-export.js +0 -71
- package/examples/middleware-usage.js +0 -93
- package/examples/new-features-comparison.js +0 -315
- package/examples/password-reset/README.md +0 -153
- package/examples/password-reset/schema.js +0 -26
- package/examples/password-reset/test.js +0 -101
- package/examples/plugin-system.examples.js +0 -205
- package/examples/schema-utils-chaining.examples.js +0 -250
- package/examples/simple-example.js +0 -122
- package/examples/slug.examples.js +0 -179
- package/examples/string-extensions.js +0 -297
- package/examples/union-type-example.js +0 -127
- package/examples/union-types-example.js +0 -77
- package/examples/user-registration/README.md +0 -156
- package/examples/user-registration/routes.js +0 -92
- package/examples/user-registration/schema.js +0 -150
- package/examples/user-registration/server.js +0 -74
- package/index.d.ts +0 -3540
- package/index.js +0 -457
- package/index.mjs +0 -60
- package/lib/adapters/DslAdapter.js +0 -871
- package/lib/adapters/index.js +0 -20
- package/lib/config/constants.js +0 -286
- package/lib/config/patterns/common.js +0 -47
- package/lib/config/patterns/creditCard.js +0 -9
- package/lib/config/patterns/idCard.js +0 -9
- package/lib/config/patterns/index.js +0 -9
- package/lib/config/patterns/licensePlate.js +0 -4
- package/lib/config/patterns/passport.js +0 -4
- package/lib/config/patterns/phone.js +0 -9
- package/lib/config/patterns/postalCode.js +0 -5
- package/lib/core/CacheManager.js +0 -376
- package/lib/core/ConditionalBuilder.js +0 -503
- package/lib/core/DslBuilder.js +0 -1400
- package/lib/core/ErrorCodes.js +0 -233
- package/lib/core/ErrorFormatter.js +0 -445
- package/lib/core/JSONSchemaCore.js +0 -347
- package/lib/core/Locale.js +0 -130
- package/lib/core/MessageTemplate.js +0 -98
- package/lib/core/PluginManager.js +0 -448
- package/lib/core/StringExtensions.js +0 -240
- package/lib/core/Validator.js +0 -654
- package/lib/errors/I18nError.js +0 -328
- package/lib/errors/ValidationError.js +0 -191
- package/lib/exporters/MarkdownExporter.js +0 -420
- package/lib/exporters/MongoDBExporter.js +0 -162
- package/lib/exporters/MySQLExporter.js +0 -212
- package/lib/exporters/PostgreSQLExporter.js +0 -289
- package/lib/exporters/index.js +0 -24
- package/lib/locales/index.js +0 -8
- package/lib/utils/LRUCache.js +0 -174
- package/lib/utils/SchemaHelper.js +0 -240
- package/lib/utils/SchemaUtils.js +0 -445
- package/lib/utils/TypeConverter.js +0 -245
- package/lib/utils/index.js +0 -13
- package/lib/validators/CustomKeywords.js +0 -616
- package/lib/validators/index.js +0 -11
package/docs/INDEX.md
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
# schema-dsl 文档索引
|
|
2
|
-
|
|
3
|
-
> **更新时间**: 2025-12-29
|
|
4
|
-
> **用途**: 所有文档的快速导航
|
|
5
|
-
> **文档数量**: 27个文档(总计 12,450+ 行)
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 📑 目录
|
|
10
|
-
|
|
11
|
-
### 快速导航
|
|
12
|
-
- [🚀 快速开始](#-快速开始) - 入门必读
|
|
13
|
-
- [📖 核心文档](#-核心文档) - 主要功能文档
|
|
14
|
-
- [🎯 功能索引](#-功能索引) - 按功能查找
|
|
15
|
-
- [🗄️ 导出器](#️-导出器) - 数据库Schema导出
|
|
16
|
-
- [🛠️ 工具类](#️-工具类utilities) - 辅助工具
|
|
17
|
-
- [📖 使用指南](#-使用指南guides) - 完整教程
|
|
18
|
-
- [🔧 故障排查](#-故障排查troubleshooting) - 问题解决
|
|
19
|
-
- [📝 示例代码](#-示例代码examples) - 完整示例
|
|
20
|
-
- [❓ 常见问题](#-常见问题faq) - FAQ
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## 🚀 快速开始
|
|
25
|
-
|
|
26
|
-
| 文档 | 阅读时间 | 说明 |
|
|
27
|
-
|------|----------|------|
|
|
28
|
-
| [README.md](../README.md) | 3分钟 | 项目介绍、安装和快速开始 ⭐ |
|
|
29
|
-
| [quick-start.md](quick-start.md) | 5分钟 | 5分钟快速上手教程 ⭐ |
|
|
30
|
-
| [design-philosophy.md](design-philosophy.md) | 15分钟 | **设计理念与性能权衡** ⭐⭐⭐ |
|
|
31
|
-
| [FEATURE-INDEX.md](FEATURE-INDEX.md) | 10分钟 | 完整功能索引 ⭐ |
|
|
32
|
-
| [best-practices.md](best-practices.md) | 15分钟 | 最佳实践指南 ⭐⭐⭐ |
|
|
33
|
-
| [faq.md](faq.md) | 5分钟 | 常见问题解答 |
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 📖 核心文档
|
|
38
|
-
|
|
39
|
-
### DSL 语法(核心功能)
|
|
40
|
-
|
|
41
|
-
| 文档 | 行数 | 说明 |
|
|
42
|
-
|------|------|------|
|
|
43
|
-
| [dsl-syntax.md](dsl-syntax.md) | 2815行 | **DSL语法完整指南**(最重要)⭐⭐⭐ |
|
|
44
|
-
| [string-extensions.md](string-extensions.md) | 465行 | **String扩展文档** ⭐⭐ |
|
|
45
|
-
| [plugin-system.md](plugin-system.md) | 580行 | **插件系统指南** ⭐⭐ |
|
|
46
|
-
| [api-reference.md](api-reference.md) | 534行 | API完整参考 ⭐⭐ |
|
|
47
|
-
| [validate.md](validate.md) | 452行 | validate方法详解 ⭐ |
|
|
48
|
-
| [**validate-async.md**](validate-async.md) | ~700行 | **异步验证方法详解** ⭐⭐⭐ |
|
|
49
|
-
| [**schema-utils-chaining.md**](schema-utils-chaining.md) | ~680行 | **Schema链式复用方法** ⭐⭐⭐ |
|
|
50
|
-
| [**schema-utils-best-practices.md**](schema-utils-best-practices.md) | ~500行 | **SchemaUtils最佳实践与常见陷阱** ⭐⭐⭐ |
|
|
51
|
-
| [**schema-utils-advanced-issues.md**](schema-utils-advanced-issues.md) | ~600行 | **SchemaUtils深入问题分析** ⭐⭐ |
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## 🎯 功能索引
|
|
56
|
-
|
|
57
|
-
### 核心API
|
|
58
|
-
|
|
59
|
-
| 功能 | 文档 | 代码位置 |
|
|
60
|
-
|------|------|---------|
|
|
61
|
-
| dsl() 函数 | [api-reference.md](api-reference.md#dsl-函数) | `lib/adapters/DslAdapter.js` |
|
|
62
|
-
| DslBuilder 类 | [api-reference.md](api-reference.md#dslbuilder-类) | `lib/core/DslBuilder.js` |
|
|
63
|
-
| String 扩展 | [string-extensions.md](string-extensions.md) | `lib/core/StringExtensions.js` |
|
|
64
|
-
| Validator 类 | [validate.md](validate.md) | `lib/core/Validator.js` |
|
|
65
|
-
| validate() 函数 | [api-reference.md](api-reference.md) | `index.js` |
|
|
66
|
-
| validateAsync() 函数 | [validate-async.md](validate-async.md) | `index.js` |
|
|
67
|
-
| ValidationError 类 | [validate-async.md](validate-async.md#validationerror) | `lib/errors/ValidationError.js` |
|
|
68
|
-
| SchemaUtils 链式调用 | [schema-utils-chaining.md](schema-utils-chaining.md) | `lib/utils/SchemaUtils.js` |
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## 🗄️ 导出器
|
|
74
|
-
|
|
75
|
-
> 将 JSON Schema 转换为数据库 DDL 和验证规则
|
|
76
|
-
|
|
77
|
-
> ⚠️ **重要提示**: 请先阅读 [**导出限制说明**](export-limitations.md),了解哪些特性无法导出到数据库 Schema。
|
|
78
|
-
|
|
79
|
-
### 导出限制说明 ⚠️
|
|
80
|
-
|
|
81
|
-
| 文档 | 说明 |
|
|
82
|
-
|------|------|
|
|
83
|
-
| [**export-limitations.md**](export-limitations.md) | **导出限制完整说明**(必读)⭐⭐⭐ |
|
|
84
|
-
|
|
85
|
-
**主要内容**:
|
|
86
|
-
- ❌ 不支持导出的特性(条件验证、自定义验证器等)
|
|
87
|
-
- ⚠️ 部分支持的特性(正则、范围、枚举等)
|
|
88
|
-
- ✅ 完全支持的特性(基础类型、必填约束等)
|
|
89
|
-
- 数据库特定限制对比(MongoDB/MySQL/PostgreSQL)
|
|
90
|
-
- 最佳实践建议(分层验证、文档化约束等)
|
|
91
|
-
|
|
92
|
-
### MongoDB 导出器
|
|
93
|
-
|
|
94
|
-
| 文档 | 行数 | 说明 |
|
|
95
|
-
|------|------|------|
|
|
96
|
-
| [mongodb-exporter.md](mongodb-exporter.md) | ~200行 | MongoDB 导出器完整指南 |
|
|
97
|
-
|
|
98
|
-
**主要功能**:
|
|
99
|
-
- `export()` - 导出 $jsonSchema 验证规则
|
|
100
|
-
- `generateCreateCommand()` - 生成创建集合命令(含验证)
|
|
101
|
-
- `generateCommand()` - 生成完整 runCommand 命令
|
|
102
|
-
- `MongoDBExporter.export()` - 静态快速导出方法
|
|
103
|
-
|
|
104
|
-
### MySQL 导出器
|
|
105
|
-
|
|
106
|
-
| 文档 | 行数 | 说明 |
|
|
107
|
-
|------|------|------|
|
|
108
|
-
| [mysql-exporter.md](mysql-exporter.md) | ~220行 | MySQL 导出器完整指南 |
|
|
109
|
-
|
|
110
|
-
**主要功能**:
|
|
111
|
-
- `export()` - 导出 CREATE TABLE DDL
|
|
112
|
-
- `generateIndex()` - 生成 CREATE INDEX DDL
|
|
113
|
-
- 支持 ENGINE、CHARSET、COLLATE 配置
|
|
114
|
-
|
|
115
|
-
### PostgreSQL 导出器
|
|
116
|
-
|
|
117
|
-
| 文档 | 行数 | 说明 |
|
|
118
|
-
|------|------|------|
|
|
119
|
-
| [postgresql-exporter.md](postgresql-exporter.md) | ~280行 | PostgreSQL 导出器完整指南 |
|
|
120
|
-
|
|
121
|
-
**主要功能**:
|
|
122
|
-
- `export()` - 导出 CREATE TABLE DDL(含 CHECK 约束)
|
|
123
|
-
- `generateIndex()` - 生成索引 DDL(支持 btree/gin/gist/hash)
|
|
124
|
-
- 支持 Schema 命名空间和 COMMENT
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## 🛠️ 工具类(Utilities)
|
|
129
|
-
|
|
130
|
-
| 文档 | 行数 | 说明 |
|
|
131
|
-
|------|------|------|
|
|
132
|
-
| [type-converter.md](type-converter.md) | ~250行 | TypeConverter - 类型转换工具 |
|
|
133
|
-
| [schema-helper.md](schema-helper.md) | ~220行 | SchemaHelper - Schema 辅助工具 |
|
|
134
|
-
| [cache-manager.md](cache-manager.md) | ~250行 | CacheManager - LRU缓存管理 |
|
|
135
|
-
|
|
136
|
-
### TypeConverter 主要功能
|
|
137
|
-
- `toMongoDBType()` - 转换为 MongoDB 类型
|
|
138
|
-
- `toMySQLType()` - 转换为 MySQL 类型
|
|
139
|
-
- `toPostgreSQLType()` - 转换为 PostgreSQL 类型
|
|
140
|
-
- `extractConstraints()` - 提取约束信息
|
|
141
|
-
- `mergeSchemas()` - 合并多个 Schema
|
|
142
|
-
|
|
143
|
-
### SchemaHelper 主要功能
|
|
144
|
-
- `isValidSchema()` - 验证 Schema 合法性
|
|
145
|
-
- `cloneSchema()` - 深度克隆 Schema
|
|
146
|
-
- `flattenSchema()` - 扁平化嵌套 Schema
|
|
147
|
-
- `getFieldPaths()` - 获取所有字段路径
|
|
148
|
-
- `summarizeSchema()` - 生成 Schema 摘要
|
|
149
|
-
|
|
150
|
-
### CacheManager 主要功能
|
|
151
|
-
- LRU 缓存策略(最近最少使用淘汰)
|
|
152
|
-
- TTL 过期支持
|
|
153
|
-
- 缓存统计(命中率、大小等)
|
|
154
|
-
- 线程安全设计
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## 📖 使用指南(Guides)
|
|
159
|
-
|
|
160
|
-
| 文档 | 行数 | 说明 |
|
|
161
|
-
|------|------|------|
|
|
162
|
-
| [validation-guide.md](validation-guide.md) | ~400行 | 数据验证完整指南 |
|
|
163
|
-
| [export-guide.md](export-guide.md) | ~350行 | 数据库导出完整指南 |
|
|
164
|
-
| [error-handling.md](error-handling.md) | ~640行 | 错误处理最佳实践 |
|
|
165
|
-
|
|
166
|
-
### 验证指南内容
|
|
167
|
-
- 基础验证流程
|
|
168
|
-
- 字段类型验证(字符串/数字/布尔/数组/对象)
|
|
169
|
-
- 常用业务验证模式
|
|
170
|
-
- 批量验证与性能优化
|
|
171
|
-
- 错误处理最佳实践
|
|
172
|
-
|
|
173
|
-
### 导出指南内容
|
|
174
|
-
- MongoDB/MySQL/PostgreSQL 导出对比
|
|
175
|
-
- 配置与自定义选项
|
|
176
|
-
- 自动化迁移脚本
|
|
177
|
-
- 版本管理与最佳实践
|
|
178
|
-
- **⚠️ [导出限制说明](export-limitations.md) - 哪些特性无法导出** ⭐⭐⭐
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
- 数据库导出概述
|
|
182
|
-
- MongoDB/MySQL/PostgreSQL 导出教程
|
|
183
|
-
- 多数据库同步方案
|
|
184
|
-
- 类型映射参考表
|
|
185
|
-
- 最佳实践与常见问题
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## 📝 示例代码(Examples)
|
|
190
|
-
|
|
191
|
-
| 文件 | 说明 |
|
|
192
|
-
|------|------|
|
|
193
|
-
| [simple-example.js](../examples/simple-example.js) | 简单示例 |
|
|
194
|
-
| [dsl-style.js](../examples/dsl-style.js) | DSL 风格完整示例 |
|
|
195
|
-
| [string-extensions.js](../examples/string-extensions.js) | String 扩展示例 |
|
|
196
|
-
| [password-reset/](../examples/password-reset/) | 密码重置表单示例 |
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## ❓ 常见问题(FAQ)
|
|
201
|
-
|
|
202
|
-
| 文档 | 说明 |
|
|
203
|
-
|------|------|
|
|
204
|
-
| [faq.md](faq.md) | 常见问题与解答 |
|
|
205
|
-
|
|
206
|
-
**热门问题**:
|
|
207
|
-
- DSL 语法与 Joi 语法的区别?
|
|
208
|
-
- 如何自定义验证规则?
|
|
209
|
-
- 如何优化验证性能?
|
|
210
|
-
- 不同数据库的类型映射?
|
|
211
|
-
- 如何处理验证错误?
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## 🔧 开发指南
|
|
216
|
-
|
|
217
|
-
| 文档 | 说明 |
|
|
218
|
-
|------|------|
|
|
219
|
-
| [CONTRIBUTING.md](../CONTRIBUTING.md) | 贡献指南 |
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## 📊 版本信息
|
|
224
|
-
|
|
225
|
-
| 文档 | 说明 |
|
|
226
|
-
|------|------|
|
|
227
|
-
| [STATUS.md](../STATUS.md) | 项目状态(243个测试全部通过)|
|
|
228
|
-
| [CHANGELOG.md](../CHANGELOG.md) | 更新日志 |
|
|
229
|
-
|
|
230
|
-
---
|
|
231
|
-
|
|
232
|
-
## 📁 文档统计
|
|
233
|
-
|
|
234
|
-
| 分类 | 文档数 | 总行数 |
|
|
235
|
-
|------|--------|--------|
|
|
236
|
-
| 核心文档 | 4 | ~4,266 |
|
|
237
|
-
| 导出器文档 | 3 | ~700 |
|
|
238
|
-
| 工具类文档 | 3 | ~720 |
|
|
239
|
-
| 使用指南 | 3 | ~1,390 |
|
|
240
|
-
| 其他文档 | 9 | ~500 |
|
|
241
|
-
| **合计** | **22** | **~7,576** |
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
**图例说明**:
|
|
246
|
-
- ⭐ 重点推荐文档
|
|
247
|
-
- ⭐⭐ 核心文档
|
|
248
|
-
- ⭐⭐⭐ 必读文档
|
|
249
|
-
|
|
250
|
-
**最后更新**: 2025-12-29
|
|
251
|
-
|
|
252
|
-
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# 问题解答总结
|
|
2
|
-
|
|
3
|
-
## 问题1:npm run test 没看到执行
|
|
4
|
-
|
|
5
|
-
### 问题描述
|
|
6
|
-
执行 `npm run test` 后,没有看到任何输出。
|
|
7
|
-
|
|
8
|
-
### 原因分析
|
|
9
|
-
这是 **Windows PowerShell 编码问题**,不是测试本身的问题。
|
|
10
|
-
|
|
11
|
-
### 验证结果
|
|
12
|
-
测试文件 `test-output.txt` 显示:
|
|
13
|
-
```
|
|
14
|
-
983 passing (5s)
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
**✅ 所有 983 个测试全部通过!**
|
|
18
|
-
|
|
19
|
-
测试完全正常执行,只是因为:
|
|
20
|
-
- Windows PowerShell 的编码问题导致中文显示为乱码
|
|
21
|
-
- PowerShell 的输出重定向机制导致终端显示为空
|
|
22
|
-
- 但测试本身没有任何问题
|
|
23
|
-
|
|
24
|
-
### 解决方案
|
|
25
|
-
|
|
26
|
-
**方式1:保存到文件查看**
|
|
27
|
-
```powershell
|
|
28
|
-
npm test > test-output.txt 2>&1
|
|
29
|
-
type test-output.txt
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**方式2:使用 Git Bash 或 WSL**
|
|
33
|
-
```bash
|
|
34
|
-
npm test
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**方式3:只看测试结果摘要**
|
|
38
|
-
```powershell
|
|
39
|
-
npm test 2>&1 | Select-String "passing|failing"
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## 问题2:直接用对象会有什么影响?
|
|
45
|
-
|
|
46
|
-
### 您的理解
|
|
47
|
-
|
|
48
|
-
> "我理解是如果要高性能,直接项目启动的时候就配置好 schema 对吗?如果直接在接口中配置的话每次都会重复转换"
|
|
49
|
-
|
|
50
|
-
### 答案
|
|
51
|
-
|
|
52
|
-
**✅ 您的理解完全正确!** 👍
|
|
53
|
-
|
|
54
|
-
### 详细说明
|
|
55
|
-
|
|
56
|
-
#### ❌ 性能较差:每次请求都转换
|
|
57
|
-
|
|
58
|
-
```javascript
|
|
59
|
-
app.post('/api/user', (req, res) => {
|
|
60
|
-
const result = validate(
|
|
61
|
-
{ email: 'email!', age: 'number!' }, // ❌ 每次请求都转换
|
|
62
|
-
req.body
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**问题**:
|
|
68
|
-
- 每次请求都执行 DSL → JSON Schema 转换
|
|
69
|
-
- 1000 次请求 = 1000 次转换
|
|
70
|
-
- 性能损失约 3-5%
|
|
71
|
-
- 高并发时影响明显
|
|
72
|
-
|
|
73
|
-
#### ✅ 性能最优:项目启动时配置
|
|
74
|
-
|
|
75
|
-
```javascript
|
|
76
|
-
// schemas/user.js - 项目启动时加载
|
|
77
|
-
const userSchemas = {
|
|
78
|
-
register: dsl({
|
|
79
|
-
email: 'email!',
|
|
80
|
-
age: 'number!'
|
|
81
|
-
})
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
module.exports = userSchemas;
|
|
85
|
-
|
|
86
|
-
// routes/user.js - 路由中使用
|
|
87
|
-
const userSchemas = require('../schemas/user');
|
|
88
|
-
|
|
89
|
-
app.post('/api/user', (req, res) => {
|
|
90
|
-
const result = validate(userSchemas.register, req.body); // ✅ 直接使用
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**优势**:
|
|
95
|
-
- 启动时转换 1 次
|
|
96
|
-
- 1000 次请求 = 0 次转换
|
|
97
|
-
- 性能最优
|
|
98
|
-
- 适合生产环境
|
|
99
|
-
|
|
100
|
-
### 性能对比
|
|
101
|
-
|
|
102
|
-
| 方式 | 1000次请求耗时 | 转换次数 | 适用场景 |
|
|
103
|
-
|------|---------------|---------|---------|
|
|
104
|
-
| 每次都转换 | ~3.4秒 | 1000次 | 原型开发、测试 |
|
|
105
|
-
| 启动时配置 | ~3.3秒 | 1次 | 生产环境、高并发 |
|
|
106
|
-
| **性能差异** | **约3-5%** | - | - |
|
|
107
|
-
|
|
108
|
-
### 使用建议
|
|
109
|
-
|
|
110
|
-
| 场景 | 推荐方式 | 原因 |
|
|
111
|
-
|------|---------|------|
|
|
112
|
-
| **生产环境 API** | ✅ 项目启动时配置 schema | 避免每次请求都转换 |
|
|
113
|
-
| **高并发服务** | ✅ 项目启动时配置 schema | 3-5% 的性能损失会被放大 |
|
|
114
|
-
| **微服务** | ✅ 项目启动时配置 schema | 保证响应时间稳定 |
|
|
115
|
-
| **单次脚本** | ✅ 直接用 DSL 对象 | 只执行一次,性能影响可忽略 |
|
|
116
|
-
| **原型开发** | ✅ 直接用 DSL 对象 | 快速迭代,无需在意性能 |
|
|
117
|
-
| **测试代码** | ✅ 直接用 DSL 对象 | 简洁清晰,易于维护 |
|
|
118
|
-
|
|
119
|
-
### 最佳实践示例
|
|
120
|
-
|
|
121
|
-
#### 1. 定义 Schema(schemas/user.js)
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
const { dsl } = require('schema-dsl');
|
|
125
|
-
|
|
126
|
-
// ✅ 项目启动时转换一次
|
|
127
|
-
module.exports = {
|
|
128
|
-
register: dsl({
|
|
129
|
-
username: 'string:3-32!',
|
|
130
|
-
email: 'email!',
|
|
131
|
-
password: 'password:strong!'
|
|
132
|
-
}),
|
|
133
|
-
|
|
134
|
-
login: dsl({
|
|
135
|
-
username: 'string!',
|
|
136
|
-
password: 'string!'
|
|
137
|
-
})
|
|
138
|
-
};
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### 2. 在路由中使用(routes/user.js)
|
|
142
|
-
|
|
143
|
-
```javascript
|
|
144
|
-
const userSchemas = require('../schemas/user');
|
|
145
|
-
const { validate } = require('schema-dsl');
|
|
146
|
-
|
|
147
|
-
// ✅ 直接使用,不再转换
|
|
148
|
-
app.post('/api/register', (req, res) => {
|
|
149
|
-
const result = validate(userSchemas.register, req.body);
|
|
150
|
-
// ...
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
app.post('/api/login', (req, res) => {
|
|
154
|
-
const result = validate(userSchemas.login, req.body);
|
|
155
|
-
// ...
|
|
156
|
-
});
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
#### 3. 主应用入口(app.js)
|
|
160
|
-
|
|
161
|
-
```javascript
|
|
162
|
-
// ✅ 应用启动时加载所有 schema
|
|
163
|
-
const schemas = require('./schemas');
|
|
164
|
-
console.log('✅ Schemas loaded:', Object.keys(schemas));
|
|
165
|
-
|
|
166
|
-
// 启动服务
|
|
167
|
-
app.listen(3000, () => {
|
|
168
|
-
console.log('✅ Server started');
|
|
169
|
-
console.log('✅ All schemas are pre-compiled and ready to use');
|
|
170
|
-
});
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## 相关文档
|
|
176
|
-
|
|
177
|
-
1. **validate-dsl-object-support.md** - 完整功能说明
|
|
178
|
-
2. **best-practices-project-structure.md** - 项目结构最佳实践(含完整示例)
|
|
179
|
-
3. **user-questions-answered.md** - 之前问题的详细解答
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## 总结
|
|
184
|
-
|
|
185
|
-
### 问题1
|
|
186
|
-
- ✅ 测试完全正常,983 个全部通过
|
|
187
|
-
- ✅ 只是 PowerShell 编码问题导致显示异常
|
|
188
|
-
- ✅ 可以通过保存到文件查看或使用其他终端
|
|
189
|
-
|
|
190
|
-
### 问题2
|
|
191
|
-
- ✅ 您的理解完全正确
|
|
192
|
-
- ✅ 生产环境应该在项目启动时配置好所有 schema
|
|
193
|
-
- ✅ 避免每次请求都重复转换,性能最优
|
|
194
|
-
- ✅ 已提供完整的项目结构和代码示例
|
|
195
|
-
|
|
196
|
-
**所有问题已完全解决!** 🎉
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
# schema-dsl 性能测试报告
|
|
2
|
-
|
|
3
|
-
## 📋 测试概述
|
|
4
|
-
|
|
5
|
-
**测试日期**: 2024-01-XX
|
|
6
|
-
**测试版本**: v1.0.4
|
|
7
|
-
**测试环境**: Node.js (运行环境)
|
|
8
|
-
**对比库**: Joi, Yup, Zod, Ajv
|
|
9
|
-
|
|
10
|
-
## 🎯 测试目标
|
|
11
|
-
|
|
12
|
-
验证 schema-dsl 在真实场景下的性能表现,并与主流验证库进行公平对比。
|
|
13
|
-
|
|
14
|
-
## 🔬 测试方法
|
|
15
|
-
|
|
16
|
-
### 公平性保证
|
|
17
|
-
|
|
18
|
-
1. **预编译Schema**: 所有库的 schema 均在测试前预编译,避免编译时间影响测试结果
|
|
19
|
-
2. **JIT预热**: 每个测试前执行 10% 的预热迭代,确保 V8 引擎充分优化
|
|
20
|
-
3. **多轮测试**: 每个测试执行 10 轮,移除最高/最低值,取平均值
|
|
21
|
-
4. **高精度计时**: 使用 `process.hrtime.bigint()` 实现纳秒级精度
|
|
22
|
-
5. **无异常处理干扰**: 移除性能关键路径中的 try-catch,避免 JIT 反优化
|
|
23
|
-
6. **统一测试数据**: 所有库使用完全相同的测试数据结构
|
|
24
|
-
|
|
25
|
-
### 测试配置
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
// 简单验证场景
|
|
29
|
-
iterations: 10000
|
|
30
|
-
rounds: 10
|
|
31
|
-
warmup: 1000 (10%)
|
|
32
|
-
|
|
33
|
-
// 复杂验证场景
|
|
34
|
-
iterations: 5000
|
|
35
|
-
rounds: 10
|
|
36
|
-
warmup: 500 (10%)
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 测试场景
|
|
40
|
-
|
|
41
|
-
#### 场景1: 简单对象验证
|
|
42
|
-
```javascript
|
|
43
|
-
{
|
|
44
|
-
username: 'john_doe',
|
|
45
|
-
email: 'john@example.com',
|
|
46
|
-
age: 25
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
#### 场景2: 复杂嵌套验证
|
|
51
|
-
```javascript
|
|
52
|
-
{
|
|
53
|
-
name: 'John Doe',
|
|
54
|
-
email: 'john@example.com',
|
|
55
|
-
profile: {
|
|
56
|
-
age: 30,
|
|
57
|
-
bio: 'Software developer',
|
|
58
|
-
tags: ['javascript', 'nodejs']
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## 📊 测试结果
|
|
64
|
-
|
|
65
|
-
### 10轮完整测试汇总
|
|
66
|
-
|
|
67
|
-
#### 简单验证性能
|
|
68
|
-
| 验证库 | 平均吞吐量 | 最低吞吐量 | 最高吞吐量 | 标准差 | 稳定性 |
|
|
69
|
-
|--------|-----------|-----------|-----------|--------|-------|
|
|
70
|
-
| **schema-dsl** | **4,130,506/s** | 3,694,035/s | 4,563,536/s | 266,785 | ⭐⭐⭐⭐ |
|
|
71
|
-
| Joi | 466,616/s | 448,739/s | 477,551/s | 7,941 | ⭐⭐⭐⭐⭐ |
|
|
72
|
-
| Yup | 318,888/s | 309,023/s | 324,891/s | 4,268 | ⭐⭐⭐⭐⭐ |
|
|
73
|
-
| Zod | 9,743,926/s | 8,247,990/s | 10,450,049/s | 646,068 | ⭐⭐⭐⭐ |
|
|
74
|
-
| Ajv | 21,456,535/s | 17,460,641/s | 25,036,512/s | 2,602,772 | ⭐⭐⭐ |
|
|
75
|
-
|
|
76
|
-
#### 复杂验证性能
|
|
77
|
-
| 验证库 | 平均吞吐量 | 最低吞吐量 | 最高吞吐量 | 标准差 | 稳定性 |
|
|
78
|
-
|--------|-----------|-----------|-----------|--------|-------|
|
|
79
|
-
| **schema-dsl** | **3,159,137/s** | 2,910,530/s | 3,345,526/s | 145,171 | ⭐⭐⭐⭐⭐ |
|
|
80
|
-
| Joi | 242,500/s | 233,608/s | 251,069/s | 4,410 | ⭐⭐⭐⭐⭐ |
|
|
81
|
-
| Yup | 70,313/s | 65,425/s | 72,158/s | 2,016 | ⭐⭐⭐⭐⭐ |
|
|
82
|
-
| Zod | 2,487,493/s | 2,313,726/s | 2,762,660/s | 130,431 | ⭐⭐⭐⭐⭐ |
|
|
83
|
-
| Ajv | 9,021,336/s | 8,012,179/s | 10,069,141/s | 632,381 | ⭐⭐⭐⭐ |
|
|
84
|
-
|
|
85
|
-
### 性能对比分析
|
|
86
|
-
|
|
87
|
-
#### schema-dsl vs 其他库
|
|
88
|
-
|
|
89
|
-
**简单验证场景**:
|
|
90
|
-
- **vs Joi**: 快 **8.85倍** (413万/s vs 47万/s)
|
|
91
|
-
- **vs Yup**: 快 **12.95倍** (413万/s vs 32万/s)
|
|
92
|
-
- **vs Zod**: 慢 0.42倍 (413万/s vs 974万/s)
|
|
93
|
-
- **vs Ajv**: 慢 0.19倍 (413万/s vs 2146万/s)
|
|
94
|
-
|
|
95
|
-
**复杂验证场景**:
|
|
96
|
-
- **vs Joi**: 快 **13.03倍** (316万/s vs 24万/s)
|
|
97
|
-
- **vs Yup**: 快 **44.93倍** (316万/s vs 7万/s)
|
|
98
|
-
- **vs Zod**: 快 **1.27倍** (316万/s vs 249万/s) ⭐
|
|
99
|
-
- **vs Ajv**: 慢 0.35倍 (316万/s vs 902万/s)
|
|
100
|
-
|
|
101
|
-
## 🎯 核心发现
|
|
102
|
-
|
|
103
|
-
### 1. 简洁性与性能的平衡
|
|
104
|
-
|
|
105
|
-
schema-dsl 在保持最简洁 DSL 语法的同时:
|
|
106
|
-
- 比 Joi 快 **9-13倍**
|
|
107
|
-
- 比 Yup 快 **13-45倍**
|
|
108
|
-
- **复杂场景超越 Zod 1.3倍**
|
|
109
|
-
|
|
110
|
-
### 2. 复杂场景优势明显
|
|
111
|
-
|
|
112
|
-
随着验证规则复杂度增加,schema-dsl 的优势更加明显:
|
|
113
|
-
- 简单场景: 优于 Joi/Yup,但不及 Zod/Ajv
|
|
114
|
-
- **复杂场景: 超越 Zod,仅次于 Ajv**
|
|
115
|
-
|
|
116
|
-
### 3. 性能稳定性
|
|
117
|
-
|
|
118
|
-
标准差分析显示:
|
|
119
|
-
- **schema-dsl**: 中等稳定性(简单: 266k, 复杂: 145k)
|
|
120
|
-
- **Joi/Yup/Zod**: 非常稳定(标准差 < 20k)
|
|
121
|
-
- **Ajv**: 波动较大(标准差 > 600k)
|
|
122
|
-
|
|
123
|
-
## 💡 选型建议
|
|
124
|
-
|
|
125
|
-
### 选择 schema-dsl 的理由
|
|
126
|
-
|
|
127
|
-
✅ **追求简洁性**: `'string:3-32!'` vs `Joi.string().min(3).max(32).required()`
|
|
128
|
-
✅ **复杂验证场景**: 嵌套对象、数组验证性能超越 Zod
|
|
129
|
-
✅ **平衡性能与可读性**: 比 Joi/Yup 快得多,语法比 Ajv 简单得多
|
|
130
|
-
✅ **多语言支持**: 内置 5 种语言错误消息自动翻译
|
|
131
|
-
|
|
132
|
-
### 其他库的优势
|
|
133
|
-
|
|
134
|
-
- **Ajv**: 极致性能要求(但需要学习 JSON Schema)
|
|
135
|
-
- **Zod**: TypeScript 类型推导(但复杂场景性能不如 schema-dsl)
|
|
136
|
-
- **Joi**: 生态成熟、稳定可靠(但性能和简洁性较差)
|
|
137
|
-
- **Yup**: 与 Formik 集成好(但性能最慢)
|
|
138
|
-
|
|
139
|
-
## 🔧 测试改进历史
|
|
140
|
-
|
|
141
|
-
### 之前的测试问题
|
|
142
|
-
|
|
143
|
-
1. ❌ Yup 测试中使用 try-catch 导致 JIT 反优化
|
|
144
|
-
2. ❌ 缺少 JIT 预热阶段,冷启动影响结果
|
|
145
|
-
3. ❌ 单次运行,受垃圾回收等因素影响
|
|
146
|
-
4. ❌ 使用 Date.now() 计时,精度不足(±1ms)
|
|
147
|
-
|
|
148
|
-
### 改进后的测试
|
|
149
|
-
|
|
150
|
-
1. ✅ 移除所有性能关键路径的 try-catch
|
|
151
|
-
2. ✅ 添加 10% 预热迭代确保 JIT 优化
|
|
152
|
-
3. ✅ 10 轮测试取平均值,移除异常值
|
|
153
|
-
4. ✅ 使用 process.hrtime.bigint() 纳秒级计时
|
|
154
|
-
|
|
155
|
-
### 性能数据修正
|
|
156
|
-
|
|
157
|
-
| 版本 | 简单验证 | 复杂验证 | 变化 |
|
|
158
|
-
|------|---------|---------|------|
|
|
159
|
-
| 旧测试 | 50万/s | 63万/s | 基准 |
|
|
160
|
-
| 新测试 | **413万/s** | **316万/s** | ⬆️ 8.3倍 / 5.0倍 |
|
|
161
|
-
|
|
162
|
-
**注**: 旧测试方法的不公平性导致低估了 schema-dsl 的真实性能。
|
|
163
|
-
|
|
164
|
-
## 📝 结论
|
|
165
|
-
|
|
166
|
-
schema-dsl 成功实现了 **"简洁性"** 与 **"性能"** 的平衡:
|
|
167
|
-
|
|
168
|
-
1. **DSL 语法最简洁**: `'string:3-32!'` 一行搞定
|
|
169
|
-
2. **复杂场景性能优异**: 超越 Zod,仅次于 Ajv
|
|
170
|
-
3. **生产级性能**: 100万+ QPS 足以应对绝大多数应用
|
|
171
|
-
4. **多语言支持**: 自动错误消息翻译
|
|
172
|
-
|
|
173
|
-
对于追求 **代码可读性** 和 **合理性能** 的开发者来说,schema-dsl 是理想选择!
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
**测试代码**: [test/performance/library-comparison.test.js](../test/performance/library-comparison.test.js)
|
|
178
|
-
**运行脚本**: [test/performance/run-benchmark.js](../test/performance/run-benchmark.js)
|
|
179
|
-
**复现方法**: `node test/performance/run-benchmark.js`
|