@wener/common 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ai/qwen3vl/index.js +2 -0
- package/lib/ai/qwen3vl/index.js.map +1 -0
- package/lib/ai/qwen3vl/utils.js +31 -0
- package/lib/ai/qwen3vl/utils.js.map +1 -0
- package/lib/ai/vision/DocLayoutElementTypeSchema.js +28 -0
- package/lib/ai/vision/DocLayoutElementTypeSchema.js.map +1 -0
- package/lib/ai/vision/ImageAnnotationSchema.js +50 -0
- package/lib/ai/vision/ImageAnnotationSchema.js.map +1 -0
- package/lib/ai/vision/index.js +3 -0
- package/lib/ai/vision/index.js.map +1 -0
- package/lib/ai/vision/resolveImageAnnotation.js +105 -0
- package/lib/ai/vision/resolveImageAnnotation.js.map +1 -0
- package/lib/cn/ChineseResidentIdNo.js +21 -14
- package/lib/cn/ChineseResidentIdNo.js.map +1 -0
- package/lib/cn/ChineseResidentIdNo.test.js +1 -1
- package/lib/cn/DivisionCode.js +30 -25
- package/lib/cn/DivisionCode.js.map +1 -0
- package/lib/cn/DivisionCode.test.js +1 -1
- package/lib/cn/Mod11.js +38 -81
- package/lib/cn/Mod11.js.map +1 -0
- package/lib/cn/Mod31.js +41 -90
- package/lib/cn/Mod31.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.js +43 -34
- package/lib/cn/UnifiedSocialCreditCode.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.test.js +1 -1
- package/lib/cn/formatChineseAmount.js +77 -0
- package/lib/cn/formatChineseAmount.js.map +1 -0
- package/lib/cn/index.js +7 -1
- package/lib/cn/index.js.map +1 -0
- package/lib/cn/parseChineseNumber.js +94 -0
- package/lib/cn/parseChineseNumber.js.map +1 -0
- package/lib/cn/parseChineseNumber.test.js +278 -0
- package/lib/cn/pinyin/cartesianProduct.js +22 -0
- package/lib/cn/pinyin/cartesianProduct.js.map +1 -0
- package/lib/cn/pinyin/cartesianProduct.test.js +179 -0
- package/lib/cn/pinyin/data.json +23573 -0
- package/lib/cn/pinyin/loader.js +14 -0
- package/lib/cn/pinyin/loader.js.map +1 -0
- package/lib/cn/pinyin/preload.js +3 -0
- package/lib/cn/pinyin/preload.js.map +1 -0
- package/lib/cn/pinyin/toPinyin.test.js +167 -0
- package/lib/cn/pinyin/toPinyinPure.js +33 -0
- package/lib/cn/pinyin/toPinyinPure.js.map +1 -0
- package/lib/cn/pinyin/transform.js +14 -0
- package/lib/cn/pinyin/transform.js.map +1 -0
- package/lib/cn/types.d.js +2 -0
- package/lib/cn/types.d.js.map +1 -0
- package/lib/consola/createStandardConsolaReporter.js +6 -6
- package/lib/consola/createStandardConsolaReporter.js.map +1 -0
- package/lib/consola/formatLogObject.js +65 -145
- package/lib/consola/formatLogObject.js.map +1 -0
- package/lib/consola/formatLogObject.test.js +184 -0
- package/lib/consola/index.js +1 -0
- package/lib/consola/index.js.map +1 -0
- package/lib/data/formatSort.js +6 -5
- package/lib/data/formatSort.js.map +1 -0
- package/lib/data/index.js +1 -0
- package/lib/data/index.js.map +1 -0
- package/lib/data/maybeNumber.js +5 -7
- package/lib/data/maybeNumber.js.map +1 -0
- package/lib/data/parseSort.js +22 -28
- package/lib/data/parseSort.js.map +1 -0
- package/lib/data/resolvePagination.js +13 -17
- package/lib/data/resolvePagination.js.map +1 -0
- package/lib/data/types.d.js +2 -0
- package/lib/data/types.d.js.map +1 -0
- package/lib/dayjs/dayjs.js +21 -19
- package/lib/dayjs/dayjs.js.map +1 -0
- package/lib/dayjs/formatDuration.js +15 -14
- package/lib/dayjs/formatDuration.js.map +1 -0
- package/lib/dayjs/index.js +2 -0
- package/lib/dayjs/index.js.map +1 -0
- package/lib/dayjs/parseDuration.js +5 -8
- package/lib/dayjs/parseDuration.js.map +1 -0
- package/lib/dayjs/parseRelativeTime.js +90 -0
- package/lib/dayjs/parseRelativeTime.js.map +1 -0
- package/lib/dayjs/parseRelativeTime.test.js +247 -0
- package/lib/dayjs/resolveRelativeTime.js +158 -0
- package/lib/dayjs/resolveRelativeTime.js.map +1 -0
- package/lib/dayjs/resolveRelativeTime.test.js +310 -0
- package/lib/decimal/index.js +1 -0
- package/lib/decimal/index.js.map +1 -0
- package/lib/decimal/parseDecimal.js +3 -1
- package/lib/decimal/parseDecimal.js.map +1 -0
- package/lib/emittery/emitter.js +10 -0
- package/lib/emittery/emitter.js.map +1 -0
- package/lib/emittery/index.js +2 -0
- package/lib/emittery/index.js.map +1 -0
- package/lib/foundation/schema/SexType.js +5 -3
- package/lib/foundation/schema/SexType.js.map +1 -0
- package/lib/foundation/schema/index.js +1 -0
- package/lib/foundation/schema/index.js.map +1 -0
- package/lib/foundation/schema/parseSexType.js +1 -0
- package/lib/foundation/schema/parseSexType.js.map +1 -0
- package/lib/foundation/schema/types.js +4 -2
- package/lib/foundation/schema/types.js.map +1 -0
- package/lib/fs/FileSystemError.js +23 -0
- package/lib/fs/FileSystemError.js.map +1 -0
- package/lib/fs/IFileSystem.d.js +3 -0
- package/lib/fs/IFileSystem.d.js.map +1 -0
- package/lib/fs/MemoryFileSystem.test.js +188 -0
- package/lib/fs/createBrowserFileSystem.js +248 -0
- package/lib/fs/createBrowserFileSystem.js.map +1 -0
- package/lib/fs/createMemoryFileSystem.js +516 -0
- package/lib/fs/createMemoryFileSystem.js.map +1 -0
- package/lib/fs/createSandboxFileSystem.js +108 -0
- package/lib/fs/createSandboxFileSystem.js.map +1 -0
- package/lib/fs/createWebDavFileSystem.js +137 -0
- package/lib/fs/createWebDavFileSystem.js.map +1 -0
- package/lib/fs/findMimeType.js +17 -0
- package/lib/fs/findMimeType.js.map +1 -0
- package/lib/fs/index.js +8 -0
- package/lib/fs/index.js.map +1 -0
- package/lib/fs/orpc/FileSystemContract.js +93 -0
- package/lib/fs/orpc/FileSystemContract.js.map +1 -0
- package/lib/fs/orpc/createContractClientFileSystem.js +93 -0
- package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -0
- package/lib/fs/orpc/index.js +3 -0
- package/lib/fs/orpc/index.js.map +1 -0
- package/lib/fs/orpc/server/createFileSystemContractImpl.js +63 -0
- package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -0
- package/lib/fs/orpc/server/index.js +2 -0
- package/lib/fs/orpc/server/index.js.map +1 -0
- package/lib/fs/s3/createS3MiniFileSystem.js +705 -0
- package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -0
- package/lib/fs/s3/index.js +2 -0
- package/lib/fs/s3/index.js.map +1 -0
- package/lib/fs/s3/s3mini.test.js +584 -0
- package/lib/fs/scandir.js +59 -0
- package/lib/fs/scandir.js.map +1 -0
- package/lib/fs/server/createDatabaseFileSystem.js +750 -0
- package/lib/fs/server/createDatabaseFileSystem.js.map +1 -0
- package/lib/fs/server/createNodeFileSystem.js +401 -0
- package/lib/fs/server/createNodeFileSystem.js.map +1 -0
- package/lib/fs/server/dbfs.test.js +221 -0
- package/lib/fs/server/index.js +2 -0
- package/lib/fs/server/index.js.map +1 -0
- package/lib/fs/server/loadTestDatabase.js +127 -0
- package/lib/fs/server/loadTestDatabase.js.map +1 -0
- package/lib/fs/tests/runFileSystemTest.js +318 -0
- package/lib/fs/tests/runFileSystemTest.js.map +1 -0
- package/lib/fs/types.js +27 -0
- package/lib/fs/types.js.map +1 -0
- package/lib/fs/utils/getFileUrl.js +35 -0
- package/lib/fs/utils/getFileUrl.js.map +1 -0
- package/lib/fs/utils.js +22 -0
- package/lib/fs/utils.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/jsonschema/JsonSchema.js +146 -172
- package/lib/jsonschema/JsonSchema.js.map +1 -0
- package/lib/jsonschema/forEachJsonSchema.js +44 -0
- package/lib/jsonschema/forEachJsonSchema.js.map +1 -0
- package/lib/jsonschema/index.js +2 -0
- package/lib/jsonschema/index.js.map +1 -0
- package/lib/jsonschema/types.d.js +2 -0
- package/lib/jsonschema/types.d.js.map +1 -0
- package/lib/meta/defineFileType.js +20 -103
- package/lib/meta/defineFileType.js.map +1 -0
- package/lib/meta/defineInit.js +31 -250
- package/lib/meta/defineInit.js.map +1 -0
- package/lib/meta/defineMetadata.js +24 -140
- package/lib/meta/defineMetadata.js.map +1 -0
- package/lib/meta/index.js +1 -0
- package/lib/meta/index.js.map +1 -0
- package/lib/orpc/createOpenApiContractClient.js +27 -0
- package/lib/orpc/createOpenApiContractClient.js.map +1 -0
- package/lib/orpc/createRpcContractClient.js +34 -0
- package/lib/orpc/createRpcContractClient.js.map +1 -0
- package/lib/orpc/index.js +3 -0
- package/lib/orpc/index.js.map +1 -0
- package/lib/orpc/resolveLinkPlugins.js +28 -0
- package/lib/orpc/resolveLinkPlugins.js.map +1 -0
- package/lib/password/PHC.js +63 -87
- package/lib/password/PHC.js.map +1 -0
- package/lib/password/PHC.test.js +11 -3
- package/lib/password/Password.js +29 -294
- package/lib/password/Password.js.map +1 -0
- package/lib/password/Password.test.js +35 -22
- package/lib/password/createArgon2PasswordAlgorithm.js +35 -191
- package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -0
- package/lib/password/createBase64PasswordAlgorithm.js +8 -141
- package/lib/password/createBase64PasswordAlgorithm.js.map +1 -0
- package/lib/password/createBcryptPasswordAlgorithm.js +13 -168
- package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -0
- package/lib/password/createPBKDF2PasswordAlgorithm.js +46 -228
- package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -0
- package/lib/password/createScryptPasswordAlgorithm.js +55 -211
- package/lib/password/createScryptPasswordAlgorithm.js.map +1 -0
- package/lib/password/index.js +1 -0
- package/lib/password/index.js.map +1 -0
- package/lib/password/server/index.js +1 -0
- package/lib/password/server/index.js.map +1 -0
- package/lib/resource/Identifiable.js +2 -0
- package/lib/resource/Identifiable.js.map +1 -0
- package/lib/resource/ListQuery.js +21 -93
- package/lib/resource/ListQuery.js.map +1 -0
- package/lib/resource/getTitleOfResource.js +3 -5
- package/lib/resource/getTitleOfResource.js.map +1 -0
- package/lib/resource/index.js +1 -0
- package/lib/resource/index.js.map +1 -0
- package/lib/resource/schema/AnyResourceSchema.js +2 -1
- package/lib/resource/schema/AnyResourceSchema.js.map +1 -0
- package/lib/resource/schema/BaseResourceSchema.js +2 -1
- package/lib/resource/schema/BaseResourceSchema.js.map +1 -0
- package/lib/resource/schema/ResourceActionType.js +6 -4
- package/lib/resource/schema/ResourceActionType.js.map +1 -0
- package/lib/resource/schema/ResourceStatus.js +5 -3
- package/lib/resource/schema/ResourceStatus.js.map +1 -0
- package/lib/resource/schema/ResourceType.js +5 -3
- package/lib/resource/schema/ResourceType.js.map +1 -0
- package/lib/resource/schema/index.js +1 -0
- package/lib/resource/schema/index.js.map +1 -0
- package/lib/resource/schema/types.js +16 -20
- package/lib/resource/schema/types.js.map +1 -0
- package/lib/s3/formatS3Url.js +65 -0
- package/lib/s3/formatS3Url.js.map +1 -0
- package/lib/s3/formatS3Url.test.js +262 -0
- package/lib/s3/index.js +3 -0
- package/lib/s3/index.js.map +1 -0
- package/lib/s3/parseS3Url.js +65 -0
- package/lib/s3/parseS3Url.js.map +1 -0
- package/lib/s3/parseS3Url.test.js +270 -0
- package/lib/schema/SchemaRegistry.js +38 -38
- package/lib/schema/SchemaRegistry.js.map +1 -0
- package/lib/schema/TypeSchema.d.js +2 -0
- package/lib/schema/TypeSchema.d.js.map +1 -0
- package/lib/schema/createSchemaData.js +26 -125
- package/lib/schema/createSchemaData.js.map +1 -0
- package/lib/schema/findJsonSchemaByPath.js +13 -36
- package/lib/schema/findJsonSchemaByPath.js.map +1 -0
- package/lib/schema/formatZodError.js +140 -0
- package/lib/schema/formatZodError.js.map +1 -0
- package/lib/schema/formatZodError.test.js +196 -0
- package/lib/schema/getSchemaCache.js +5 -5
- package/lib/schema/getSchemaCache.js.map +1 -0
- package/lib/schema/getSchemaOptions.js +8 -11
- package/lib/schema/getSchemaOptions.js.map +1 -0
- package/lib/schema/index.js +2 -1
- package/lib/schema/index.js.map +1 -0
- package/lib/schema/toJsonSchema.js +47 -290
- package/lib/schema/toJsonSchema.js.map +1 -0
- package/lib/schema/validate.js +33 -45
- package/lib/schema/validate.js.map +1 -0
- package/lib/tools/generateSchema.js +39 -197
- package/lib/tools/generateSchema.js.map +1 -0
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js +55 -143
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +1 -0
- package/lib/utils/buildBaseUrl.js +13 -0
- package/lib/utils/buildBaseUrl.js.map +1 -0
- package/lib/utils/buildRedactorFormSchema.js +59 -0
- package/lib/utils/buildRedactorFormSchema.js.map +1 -0
- package/lib/utils/getEstimateProcessTime.js +12 -11
- package/lib/utils/getEstimateProcessTime.js.map +1 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/resolveFeatureOptions.js +12 -0
- package/lib/utils/resolveFeatureOptions.js.map +1 -0
- package/package.json +61 -13
- package/src/ai/qwen3vl/index.ts +1 -0
- package/src/ai/qwen3vl/utils.ts +36 -0
- package/src/ai/vision/DocLayoutElementTypeSchema.ts +30 -0
- package/src/ai/vision/ImageAnnotationSchema.ts +60 -0
- package/src/ai/vision/index.ts +2 -0
- package/src/ai/vision/resolveImageAnnotation.ts +135 -0
- package/src/cn/ChineseResidentIdNo.test.ts +1 -1
- package/src/cn/ChineseResidentIdNo.ts +8 -0
- package/src/cn/DivisionCode.test.ts +1 -1
- package/src/cn/DivisionCode.ts +8 -0
- package/src/cn/UnifiedSocialCreditCode.test.ts +1 -1
- package/src/cn/UnifiedSocialCreditCode.ts +15 -0
- package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +23 -0
- package/src/cn/formatChineseAmount.ts +61 -0
- package/src/cn/index.ts +7 -1
- package/src/cn/parseChineseNumber.test.ts +159 -0
- package/src/cn/parseChineseNumber.ts +97 -0
- package/src/cn/pinyin/cartesianProduct.test.ts +64 -0
- package/src/cn/pinyin/cartesianProduct.ts +24 -0
- package/src/cn/pinyin/data.json +23573 -0
- package/src/cn/pinyin/loader.ts +12 -0
- package/src/cn/pinyin/preload.ts +3 -0
- package/src/cn/pinyin/toPinyin.test.ts +12 -0
- package/src/cn/pinyin/toPinyinPure.ts +43 -0
- package/src/cn/pinyin/transform.ts +12 -0
- package/src/consola/formatLogObject.test.ts +27 -0
- package/src/consola/formatLogObject.ts +34 -6
- package/src/dayjs/dayjs.ts +18 -18
- package/src/dayjs/index.ts +3 -1
- package/src/dayjs/parseRelativeTime.test.ts +185 -0
- package/src/dayjs/parseRelativeTime.ts +115 -0
- package/src/dayjs/resolveRelativeTime.test.ts +357 -0
- package/src/dayjs/resolveRelativeTime.ts +167 -0
- package/src/emittery/emitter.ts +9 -0
- package/src/emittery/index.ts +1 -0
- package/src/fs/FileSystemError.ts +26 -0
- package/src/fs/IFileSystem.d.ts +102 -0
- package/src/fs/MemoryFileSystem.test.ts +37 -0
- package/src/fs/createBrowserFileSystem.ts +291 -0
- package/src/fs/createMemoryFileSystem.ts +604 -0
- package/src/fs/createSandboxFileSystem.ts +136 -0
- package/src/fs/createWebDavFileSystem.ts +172 -0
- package/src/fs/findMimeType.ts +23 -0
- package/src/fs/index.ts +8 -0
- package/src/fs/orpc/FileSystemContract.ts +92 -0
- package/src/fs/orpc/createContractClientFileSystem.ts +115 -0
- package/src/fs/orpc/index.ts +2 -0
- package/src/fs/orpc/server/createFileSystemContractImpl.ts +64 -0
- package/src/fs/orpc/server/index.ts +1 -0
- package/src/fs/s3/createS3MiniFileSystem.ts +830 -0
- package/src/fs/s3/index.ts +1 -0
- package/src/fs/s3/s3mini.test.ts +264 -0
- package/src/fs/scandir.ts +75 -0
- package/src/fs/server/createDatabaseFileSystem.ts +668 -0
- package/src/fs/server/createNodeFileSystem.ts +499 -0
- package/src/fs/server/dbfs.test.ts +47 -0
- package/src/fs/server/index.ts +1 -0
- package/src/fs/server/loadTestDatabase.ts +131 -0
- package/src/fs/tests/runFileSystemTest.ts +288 -0
- package/src/fs/types.ts +29 -0
- package/src/fs/utils/getFileUrl.ts +44 -0
- package/src/fs/utils.ts +23 -0
- package/src/jsonschema/JsonSchema.ts +118 -110
- package/src/jsonschema/forEachJsonSchema.ts +50 -0
- package/src/jsonschema/index.ts +1 -0
- package/src/orpc/createOpenApiContractClient.ts +52 -0
- package/src/orpc/createRpcContractClient.ts +50 -0
- package/src/orpc/index.ts +2 -0
- package/src/orpc/resolveLinkPlugins.ts +29 -0
- package/src/password/PHC.ts +3 -3
- package/src/password/Password.test.ts +1 -1
- package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
- package/src/resource/schema/AnyResourceSchema.ts +16 -2
- package/src/s3/formatS3Url.test.ts +254 -0
- package/src/s3/formatS3Url.ts +84 -0
- package/src/s3/index.ts +2 -0
- package/src/s3/parseS3Url.test.ts +258 -0
- package/src/s3/parseS3Url.ts +88 -0
- package/src/schema/SchemaRegistry.ts +35 -33
- package/src/schema/formatZodError.test.ts +196 -0
- package/src/schema/formatZodError.ts +151 -0
- package/src/schema/getSchemaOptions.ts +2 -2
- package/src/schema/index.ts +1 -1
- package/src/utils/buildBaseUrl.ts +12 -0
- package/src/utils/buildRedactorFormSchema.ts +85 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/resolveFeatureOptions.ts +14 -0
- package/src/cn/ChineseResidentIdNo.mod.ts +0 -7
- package/src/cn/DivisionCode.mod.ts +0 -7
- package/src/cn/UnifiedSocialCreditCode.mod.ts +0 -7
- package/src/cn/mod.ts +0 -3
- package/src/schema/SchemaRegistry.mod.ts +0 -1
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
function _type_of(obj) {
|
|
2
|
-
"@swc/helpers - typeof";
|
|
3
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
-
}
|
|
5
1
|
import { getGlobalStates } from "@wener/utils";
|
|
6
2
|
import { toJsonSchema } from "./index.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return found;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
if (needle && typeof needle !== "string") {
|
|
18
|
-
return toJsonSchema(needle);
|
|
3
|
+
(function (SchemaRegistry) {
|
|
4
|
+
const types = getGlobalStates("@wener/common/resource/schema/SchemaRegistry", () => new Map());
|
|
5
|
+
function get(needle) {
|
|
6
|
+
let key = getKey(needle);
|
|
7
|
+
let found = types.get(key);
|
|
8
|
+
if (found) {
|
|
9
|
+
return found;
|
|
19
10
|
}
|
|
11
|
+
else {
|
|
12
|
+
if (needle && typeof needle !== "string") {
|
|
13
|
+
return toJsonSchema(needle);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Schema not found: ${key}`);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
SchemaRegistry.get = get;
|
|
19
|
+
function getKey(s) {
|
|
20
|
+
let key;
|
|
21
|
+
if (typeof s === "string") {
|
|
22
|
+
key = s;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
let js = toJsonSchema(s);
|
|
26
|
+
key = js.$id || js.title;
|
|
27
|
+
}
|
|
28
|
+
if (!key) {
|
|
29
|
+
throw new Error(`Schema must have $id or title`);
|
|
30
|
+
}
|
|
31
|
+
return key;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
throw new Error("Invalid schema definition for: ".concat(getKey(key)));
|
|
33
|
+
function set(key, def) {
|
|
34
|
+
if (!def) {
|
|
35
|
+
def = key;
|
|
36
|
+
if (!def || typeof def !== "object") {
|
|
37
|
+
throw new Error(`Invalid schema definition for: ${getKey(key)}`);
|
|
38
|
+
}
|
|
42
39
|
}
|
|
40
|
+
types.set(getKey(key), toJsonSchema(def));
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
}
|
|
42
|
+
SchemaRegistry.set = set;
|
|
43
|
+
})(SchemaRegistry || (SchemaRegistry = {}));
|
|
44
|
+
export var SchemaRegistry;
|
|
45
|
+
//# sourceMappingURL=SchemaRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/SchemaRegistry.ts"],"sourcesContent":["import { getGlobalStates } from '@wener/utils';\nimport type { JsonSchemaDef } from '../jsonschema';\nimport { toJsonSchema, type SchemaOutput, type TypeSchema } from './index';\n\nexport namespace SchemaRegistry {\n\tconst types = getGlobalStates('@wener/common/resource/schema/SchemaRegistry', () => new Map<string, JsonSchemaDef>());\n\n\texport function get(name: string): JsonSchemaDef;\n\texport function get<S extends TypeSchema>(schema: S): JsonSchemaDef<SchemaOutput<S>>;\n\texport function get(needle: TypeSchema | string) {\n\t\tlet key = getKey(needle);\n\t\tlet found = types.get(key);\n\t\tif (found) {\n\t\t\treturn found;\n\t\t} else {\n\t\t\tif (needle && typeof needle !== 'string') {\n\t\t\t\treturn toJsonSchema(needle);\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Schema not found: ${key}`);\n\t}\n\n\tfunction getKey(s: TypeSchema | string) {\n\t\tlet key;\n\t\tif (typeof s === 'string') {\n\t\t\tkey = s;\n\t\t} else {\n\t\t\tlet js = toJsonSchema(s);\n\t\t\tkey = js.$id || js.title;\n\t\t}\n\t\tif (!key) {\n\t\t\tthrow new Error(`Schema must have $id or title`);\n\t\t}\n\t\treturn key;\n\t}\n\n\texport function set(key: TypeSchema | string, def: TypeSchema): void;\n\texport function set(key: TypeSchema, def?: TypeSchema): void;\n\texport function set(key: TypeSchema | string, def?: TypeSchema) {\n\t\tif (!def) {\n\t\t\tdef = key as TypeSchema;\n\t\t\tif (!def || typeof def !== 'object') {\n\t\t\t\tthrow new Error(`Invalid schema definition for: ${getKey(key)}`);\n\t\t\t}\n\t\t}\n\t\ttypes.set(getKey(key), toJsonSchema(def));\n\t}\n}\n"],"names":["getGlobalStates","toJsonSchema","SchemaRegistry","types","Map","get","needle","key","getKey","found","Error","s","js","$id","title","set","def"],"mappings":"AAAA,SAASA,eAAe,QAAQ,eAAe;AAE/C,SAASC,YAAY,QAA4C,UAAU;UAE1DC;IAChB,MAAMC,QAAQH,gBAAgB,gDAAgD,IAAM,IAAII;IAIjF,SAASC,IAAIC,MAA2B;QAC9C,IAAIC,MAAMC,OAAOF;QACjB,IAAIG,QAAQN,MAAME,GAAG,CAACE;QACtB,IAAIE,OAAO;YACV,OAAOA;QACR,OAAO;YACN,IAAIH,UAAU,OAAOA,WAAW,UAAU;gBACzC,OAAOL,aAAaK;YACrB;QACD;QACA,MAAM,IAAII,MAAM,CAAC,kBAAkB,EAAEH,KAAK;IAC3C;mBAXgBF,MAAAA;IAahB,SAASG,OAAOG,CAAsB;QACrC,IAAIJ;QACJ,IAAI,OAAOI,MAAM,UAAU;YAC1BJ,MAAMI;QACP,OAAO;YACN,IAAIC,KAAKX,aAAaU;YACtBJ,MAAMK,GAAGC,GAAG,IAAID,GAAGE,KAAK;QACzB;QACA,IAAI,CAACP,KAAK;YACT,MAAM,IAAIG,MAAM,CAAC,6BAA6B,CAAC;QAChD;QACA,OAAOH;IACR;IAIO,SAASQ,IAAIR,GAAwB,EAAES,GAAgB;QAC7D,IAAI,CAACA,KAAK;YACTA,MAAMT;YACN,IAAI,CAACS,OAAO,OAAOA,QAAQ,UAAU;gBACpC,MAAM,IAAIN,MAAM,CAAC,+BAA+B,EAAEF,OAAOD,MAAM;YAChE;QACD;QACAJ,MAAMY,GAAG,CAACP,OAAOD,MAAMN,aAAae;IACrC;mBARgBD,MAAAA;AASjB,GA3CiBb,mBAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/TypeSchema.d.ts"],"sourcesContent":["import type {\n\tTSchema,\n\tStaticDecode as TypeBoxStaticDecode,\n\tStaticEncode as TypeBoxStaticEncode,\n} from '@sinclair/typebox';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { z } from 'zod/v4';\nimport type { JsonSchemaDef } from '../jsonschema';\n\nexport type TypeSchema<I = unknown, O = I> = TSchema | z.ZodSchema<O, I> | JsonSchemaDef | StandardSchemaV1<I, O>;\n\nexport type SchemaOutput<S extends TypeSchema> =\n\tS extends StandardSchemaV1<infer I, infer O>\n\t\t? O\n\t\t: S extends z.ZodSchema<infer O, infer I>\n\t\t\t? O\n\t\t\t: S extends TSchema\n\t\t\t\t? TypeBoxStaticEncode<S>\n\t\t\t\t: S extends JsonSchemaDef<infer I, infer O>\n\t\t\t\t\t? O\n\t\t\t\t\t: never;\n\nexport type SchemaInput<S extends TypeSchema> =\n\tS extends StandardSchemaV1<infer I, infer O>\n\t\t? I\n\t\t: S extends z.ZodSchema<infer O, infer I>\n\t\t\t? I\n\t\t\t: S extends TSchema\n\t\t\t\t? TypeBoxStaticDecode<S>\n\t\t\t\t: S extends JsonSchemaDef<infer I, infer O>\n\t\t\t\t\t? I\n\t\t\t\t\t: never;\n"],"names":[],"mappings":"AAsBA,WASa"}
|
|
@@ -1,91 +1,25 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length)
|
|
3
|
-
len = arr.length;
|
|
4
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
-
arr2[i] = arr[i];
|
|
6
|
-
return arr2;
|
|
7
|
-
}
|
|
8
|
-
function _array_with_holes(arr) {
|
|
9
|
-
if (Array.isArray(arr))
|
|
10
|
-
return arr;
|
|
11
|
-
}
|
|
12
|
-
function _iterable_to_array_limit(arr, i) {
|
|
13
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
14
|
-
if (_i == null)
|
|
15
|
-
return;
|
|
16
|
-
var _arr = [];
|
|
17
|
-
var _n = true;
|
|
18
|
-
var _d = false;
|
|
19
|
-
var _s, _e;
|
|
20
|
-
try {
|
|
21
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
22
|
-
_arr.push(_s.value);
|
|
23
|
-
if (i && _arr.length === i)
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
_d = true;
|
|
29
|
-
_e = err;
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
try {
|
|
33
|
-
if (!_n && _i["return"] != null)
|
|
34
|
-
_i["return"]();
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
if (_d)
|
|
38
|
-
throw _e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return _arr;
|
|
42
|
-
}
|
|
43
|
-
function _non_iterable_rest() {
|
|
44
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
45
|
-
}
|
|
46
|
-
function _sliced_to_array(arr, i) {
|
|
47
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
48
|
-
}
|
|
49
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
50
|
-
if (!o)
|
|
51
|
-
return;
|
|
52
|
-
if (typeof o === "string")
|
|
53
|
-
return _array_like_to_array(o, minLen);
|
|
54
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
-
if (n === "Object" && o.constructor)
|
|
56
|
-
n = o.constructor.name;
|
|
57
|
-
if (n === "Map" || n === "Set")
|
|
58
|
-
return Array.from(n);
|
|
59
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
60
|
-
return _array_like_to_array(o, minLen);
|
|
61
|
-
}
|
|
62
1
|
import { match, P } from "ts-pattern";
|
|
63
2
|
import { toJsonSchema } from "./toJsonSchema.js";
|
|
64
|
-
export function createSchemaData(ts) {
|
|
65
|
-
|
|
66
|
-
var schema = toJsonSchema(ts);
|
|
3
|
+
export function createSchemaData(ts, options = {}) {
|
|
4
|
+
const schema = toJsonSchema(ts);
|
|
67
5
|
return createJsonSchemaData(schema, options);
|
|
68
6
|
}
|
|
69
7
|
function createJsonSchemaData(schema, options) {
|
|
70
|
-
|
|
71
|
-
return Boolean(!ctx.required && s.nullable);
|
|
72
|
-
};
|
|
8
|
+
let skip = (s, ctx) => Boolean(!ctx.required && s.nullable);
|
|
73
9
|
if (options.all) {
|
|
74
|
-
skip =
|
|
75
|
-
return false;
|
|
76
|
-
};
|
|
10
|
+
skip = () => false;
|
|
77
11
|
}
|
|
78
12
|
if (options.skip) {
|
|
79
13
|
skip = options.skip;
|
|
80
14
|
}
|
|
81
15
|
return _create(schema, {
|
|
82
|
-
skip
|
|
16
|
+
skip
|
|
83
17
|
}, {
|
|
84
18
|
required: false
|
|
85
19
|
});
|
|
86
20
|
}
|
|
87
21
|
function _create(schema, options, ctx) {
|
|
88
|
-
|
|
22
|
+
const { skip } = options;
|
|
89
23
|
if (skip(schema, ctx)) {
|
|
90
24
|
return schema.default;
|
|
91
25
|
}
|
|
@@ -94,80 +28,47 @@ function _create(schema, options, ctx) {
|
|
|
94
28
|
}
|
|
95
29
|
return match(schema).returnType().with({
|
|
96
30
|
default: P.select()
|
|
97
|
-
},
|
|
98
|
-
return v;
|
|
99
|
-
}).with({
|
|
31
|
+
}, (v) => v).with({
|
|
100
32
|
const: P.nonNullable
|
|
101
|
-
},
|
|
102
|
-
return v.const;
|
|
103
|
-
}).with({
|
|
33
|
+
}, (v) => v.const).with({
|
|
104
34
|
anyOf: P.nonNullable
|
|
105
|
-
},
|
|
35
|
+
}, (schema) => {
|
|
106
36
|
return _create(schema.anyOf[0], options, {
|
|
107
37
|
required: false
|
|
108
38
|
});
|
|
109
39
|
}).with({
|
|
110
40
|
oneOf: P.nonNullable
|
|
111
|
-
},
|
|
41
|
+
}, (schema) => {
|
|
112
42
|
return _create(schema.oneOf[0], options, {
|
|
113
43
|
required: false
|
|
114
44
|
});
|
|
115
45
|
}).with({
|
|
116
46
|
type: "string"
|
|
117
|
-
},
|
|
118
|
-
return "";
|
|
119
|
-
}).with({
|
|
47
|
+
}, (schema) => "").with({
|
|
120
48
|
type: P.union("number", "integer")
|
|
121
|
-
},
|
|
122
|
-
return 0;
|
|
123
|
-
}).with({
|
|
49
|
+
}, (schema) => 0).with({
|
|
124
50
|
type: "object"
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
if (value === undefined) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
out[k] = value;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch (err) {
|
|
142
|
-
_didIteratorError = true;
|
|
143
|
-
_iteratorError = err;
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
try {
|
|
147
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
148
|
-
_iterator.return();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
if (_didIteratorError) {
|
|
153
|
-
throw _iteratorError;
|
|
154
|
-
}
|
|
51
|
+
}, () => {
|
|
52
|
+
const out = {};
|
|
53
|
+
let required = Array.isArray(schema.required) ? schema.required : [];
|
|
54
|
+
for (const [k, v] of Object.entries(schema.properties || {})) {
|
|
55
|
+
const value = _create(v, options, {
|
|
56
|
+
required: required.includes(k)
|
|
57
|
+
});
|
|
58
|
+
if (value === undefined) {
|
|
59
|
+
continue;
|
|
155
60
|
}
|
|
61
|
+
out[k] = value;
|
|
156
62
|
}
|
|
157
63
|
return out;
|
|
158
64
|
}).with({
|
|
159
65
|
type: "null"
|
|
160
|
-
},
|
|
161
|
-
return null;
|
|
162
|
-
}).with({
|
|
66
|
+
}, () => null).with({
|
|
163
67
|
type: "boolean"
|
|
164
|
-
},
|
|
165
|
-
return false;
|
|
166
|
-
}).with({
|
|
68
|
+
}, (schema) => false).with({
|
|
167
69
|
type: "array"
|
|
168
|
-
},
|
|
169
|
-
return [];
|
|
170
|
-
}).otherwise(function () {
|
|
70
|
+
}, (schema) => []).otherwise(() => {
|
|
171
71
|
return undefined;
|
|
172
72
|
});
|
|
173
73
|
}
|
|
74
|
+
//# sourceMappingURL=createSchemaData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/createSchemaData.ts"],"sourcesContent":["import { match, P } from 'ts-pattern';\nimport type { JsonSchemaDef } from '../jsonschema';\nimport { toJsonSchema } from './toJsonSchema';\nimport type { SchemaOutput, TypeSchema } from './TypeSchema';\n\nexport function createSchemaData<S extends TypeSchema>(\n\tts: S,\n\toptions: CreateSchemaDataOptions = {},\n): Partial<SchemaOutput<S>> {\n\tconst schema = toJsonSchema(ts);\n\treturn createJsonSchemaData(schema, options);\n}\n\ntype CreateSchemaDataOptions = Partial<CreateOptions> & {\n\tall?: boolean;\n};\n\nfunction createJsonSchemaData(schema: JsonSchemaDef, options: CreateSchemaDataOptions): any {\n\tlet skip: CreateOptions['skip'] = (s, ctx) => Boolean(!ctx.required && s.nullable);\n\tif (options.all) {\n\t\tskip = () => false;\n\t}\n\tif (options.skip) {\n\t\tskip = options.skip;\n\t}\n\treturn _create(\n\t\tschema,\n\t\t{\n\t\t\tskip,\n\t\t},\n\t\t{ required: false },\n\t);\n}\n\ntype CreateOptions = {\n\tskip: (schema: JsonSchemaDef, ctx: { required: boolean }) => boolean;\n};\n\nfunction _create(schema: JsonSchemaDef, options: CreateOptions, ctx: { required: boolean }): any {\n\tconst { skip } = options;\n\tif (skip(schema, ctx)) {\n\t\treturn schema.default;\n\t}\n\tif (schema.default !== undefined) {\n\t\treturn schema.default;\n\t}\n\treturn match(schema as JsonSchemaDef)\n\t\t.returnType<any>()\n\t\t.with({ default: P.select() }, (v) => v)\n\t\t.with({ const: P.nonNullable }, (v) => v.const)\n\t\t.with({ anyOf: P.nonNullable }, (schema) => {\n\t\t\treturn _create(schema.anyOf[0], options, { required: false });\n\t\t})\n\t\t.with({ oneOf: P.nonNullable }, (schema) => {\n\t\t\treturn _create(schema.oneOf[0], options, { required: false });\n\t\t})\n\t\t.with({ type: 'string' }, (schema) => '')\n\t\t.with({ type: P.union('number', 'integer') }, (schema) => 0)\n\t\t.with({ type: 'object' }, () => {\n\t\t\tconst out: Record<string, any> = {};\n\n\t\t\tlet required = Array.isArray(schema.required) ? schema.required : [];\n\t\t\tfor (const [k, v] of Object.entries(schema.properties || {}) as [string, JsonSchemaDef][]) {\n\t\t\t\tconst value = _create(v, options, {\n\t\t\t\t\trequired: required.includes(k),\n\t\t\t\t});\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tout[k] = value;\n\t\t\t}\n\n\t\t\treturn out;\n\t\t})\n\t\t.with({ type: 'null' }, () => null)\n\t\t.with({ type: 'boolean' }, (schema) => false)\n\t\t.with({ type: 'array' }, (schema) => [])\n\t\t.otherwise(() => {\n\t\t\treturn undefined;\n\t\t});\n}\n"],"names":["match","P","toJsonSchema","createSchemaData","ts","options","schema","createJsonSchemaData","skip","s","ctx","Boolean","required","nullable","all","_create","default","undefined","returnType","with","select","v","const","nonNullable","anyOf","oneOf","type","union","out","Array","isArray","k","Object","entries","properties","value","includes","otherwise"],"mappings":"AAAA,SAASA,KAAK,EAAEC,CAAC,QAAQ,aAAa;AAEtC,SAASC,YAAY,QAAQ,iBAAiB;AAG9C,OAAO,SAASC,iBACfC,EAAK,EACLC,UAAmC,CAAC,CAAC;IAErC,MAAMC,SAASJ,aAAaE;IAC5B,OAAOG,qBAAqBD,QAAQD;AACrC;AAMA,SAASE,qBAAqBD,MAAqB,EAAED,OAAgC;IACpF,IAAIG,OAA8B,CAACC,GAAGC,MAAQC,QAAQ,CAACD,IAAIE,QAAQ,IAAIH,EAAEI,QAAQ;IACjF,IAAIR,QAAQS,GAAG,EAAE;QAChBN,OAAO,IAAM;IACd;IACA,IAAIH,QAAQG,IAAI,EAAE;QACjBA,OAAOH,QAAQG,IAAI;IACpB;IACA,OAAOO,QACNT,QACA;QACCE;IACD,GACA;QAAEI,UAAU;IAAM;AAEpB;AAMA,SAASG,QAAQT,MAAqB,EAAED,OAAsB,EAAEK,GAA0B;IACzF,MAAM,EAAEF,IAAI,EAAE,GAAGH;IACjB,IAAIG,KAAKF,QAAQI,MAAM;QACtB,OAAOJ,OAAOU,OAAO;IACtB;IACA,IAAIV,OAAOU,OAAO,KAAKC,WAAW;QACjC,OAAOX,OAAOU,OAAO;IACtB;IACA,OAAOhB,MAAMM,QACXY,UAAU,GACVC,IAAI,CAAC;QAAEH,SAASf,EAAEmB,MAAM;IAAG,GAAG,CAACC,IAAMA,GACrCF,IAAI,CAAC;QAAEG,OAAOrB,EAAEsB,WAAW;IAAC,GAAG,CAACF,IAAMA,EAAEC,KAAK,EAC7CH,IAAI,CAAC;QAAEK,OAAOvB,EAAEsB,WAAW;IAAC,GAAG,CAACjB;QAChC,OAAOS,QAAQT,OAAOkB,KAAK,CAAC,EAAE,EAAEnB,SAAS;YAAEO,UAAU;QAAM;IAC5D,GACCO,IAAI,CAAC;QAAEM,OAAOxB,EAAEsB,WAAW;IAAC,GAAG,CAACjB;QAChC,OAAOS,QAAQT,OAAOmB,KAAK,CAAC,EAAE,EAAEpB,SAAS;YAAEO,UAAU;QAAM;IAC5D,GACCO,IAAI,CAAC;QAAEO,MAAM;IAAS,GAAG,CAACpB,SAAW,IACrCa,IAAI,CAAC;QAAEO,MAAMzB,EAAE0B,KAAK,CAAC,UAAU;IAAW,GAAG,CAACrB,SAAW,GACzDa,IAAI,CAAC;QAAEO,MAAM;IAAS,GAAG;QACzB,MAAME,MAA2B,CAAC;QAElC,IAAIhB,WAAWiB,MAAMC,OAAO,CAACxB,OAAOM,QAAQ,IAAIN,OAAOM,QAAQ,GAAG,EAAE;QACpE,KAAK,MAAM,CAACmB,GAAGV,EAAE,IAAIW,OAAOC,OAAO,CAAC3B,OAAO4B,UAAU,IAAI,CAAC,GAAiC;YAC1F,MAAMC,QAAQpB,QAAQM,GAAGhB,SAAS;gBACjCO,UAAUA,SAASwB,QAAQ,CAACL;YAC7B;YACA,IAAII,UAAUlB,WAAW;gBACxB;YACD;YACAW,GAAG,CAACG,EAAE,GAAGI;QACV;QAEA,OAAOP;IACR,GACCT,IAAI,CAAC;QAAEO,MAAM;IAAO,GAAG,IAAM,MAC7BP,IAAI,CAAC;QAAEO,MAAM;IAAU,GAAG,CAACpB,SAAW,OACtCa,IAAI,CAAC;QAAEO,MAAM;IAAQ,GAAG,CAACpB,SAAW,EAAE,EACtC+B,SAAS,CAAC;QACV,OAAOpB;IACR;AACF"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
function _type_of(obj) {
|
|
2
|
-
"@swc/helpers - typeof";
|
|
3
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
-
}
|
|
5
1
|
import { firstOfMaybeArray } from "@wener/utils";
|
|
6
2
|
import { toJsonSchema } from "./toJsonSchema.js";
|
|
7
3
|
export function findJsonSchemaByPath(schema, objectPath) {
|
|
@@ -9,41 +5,22 @@ export function findJsonSchemaByPath(schema, objectPath) {
|
|
|
9
5
|
if (!objectPath || !schema) {
|
|
10
6
|
return undefined;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (currentSchema && (typeof currentSchema === "undefined" ? "undefined" : _type_of(currentSchema)) === "object" && currentSchema.properties && currentSchema.properties[segment]) {
|
|
20
|
-
currentSchema = currentSchema.properties[segment];
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (/^\d$/.test(segment) || segment === "[]") {
|
|
24
|
-
if (currentSchema.items) {
|
|
25
|
-
currentSchema = firstOfMaybeArray(currentSchema.items);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
_didIteratorError = true;
|
|
34
|
-
_iteratorError = err;
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
try {
|
|
38
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
39
|
-
_iterator.return();
|
|
40
|
-
}
|
|
8
|
+
const segments = objectPath.split(".");
|
|
9
|
+
let currentSchema = schema;
|
|
10
|
+
for (const segment of segments) {
|
|
11
|
+
// 检查当前 schema 是否是对象类型且有 properties
|
|
12
|
+
if (currentSchema && typeof currentSchema === "object" && currentSchema.properties && currentSchema.properties[segment]) {
|
|
13
|
+
currentSchema = currentSchema.properties[segment];
|
|
14
|
+
continue;
|
|
41
15
|
}
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
16
|
+
if (/^\d$/.test(segment) || segment === "[]") {
|
|
17
|
+
if (currentSchema.items) {
|
|
18
|
+
currentSchema = firstOfMaybeArray(currentSchema.items);
|
|
19
|
+
continue;
|
|
45
20
|
}
|
|
46
21
|
}
|
|
22
|
+
return undefined;
|
|
47
23
|
}
|
|
48
24
|
return currentSchema;
|
|
49
25
|
}
|
|
26
|
+
//# sourceMappingURL=findJsonSchemaByPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/findJsonSchemaByPath.ts"],"sourcesContent":["import { firstOfMaybeArray } from '@wener/utils';\nimport { toJsonSchema } from './toJsonSchema';\nimport type { TypeSchema } from './TypeSchema';\n\nexport function findJsonSchemaByPath(schema: TypeSchema, objectPath: string) {\n\tschema = toJsonSchema(schema);\n\tif (!objectPath || !schema) {\n\t\treturn undefined;\n\t}\n\n\tconst segments = objectPath.split('.');\n\tlet currentSchema = schema;\n\n\tfor (const segment of segments) {\n\t\t// 检查当前 schema 是否是对象类型且有 properties\n\t\tif (\n\t\t\tcurrentSchema\n\t\t\t&& typeof currentSchema === 'object'\n\t\t\t&& currentSchema.properties\n\t\t\t&& currentSchema.properties[segment]\n\t\t) {\n\t\t\tcurrentSchema = currentSchema.properties[segment];\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (/^\\d$/.test(segment) || segment === '[]') {\n\t\t\tif (currentSchema.items) {\n\t\t\t\tcurrentSchema = firstOfMaybeArray(currentSchema.items);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\treturn currentSchema;\n}\n"],"names":["firstOfMaybeArray","toJsonSchema","findJsonSchemaByPath","schema","objectPath","undefined","segments","split","currentSchema","segment","properties","test","items"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,eAAe;AACjD,SAASC,YAAY,QAAQ,iBAAiB;AAG9C,OAAO,SAASC,qBAAqBC,MAAkB,EAAEC,UAAkB;IAC1ED,SAASF,aAAaE;IACtB,IAAI,CAACC,cAAc,CAACD,QAAQ;QAC3B,OAAOE;IACR;IAEA,MAAMC,WAAWF,WAAWG,KAAK,CAAC;IAClC,IAAIC,gBAAgBL;IAEpB,KAAK,MAAMM,WAAWH,SAAU;QAC/B,mCAAmC;QACnC,IACCE,iBACG,OAAOA,kBAAkB,YACzBA,cAAcE,UAAU,IACxBF,cAAcE,UAAU,CAACD,QAAQ,EACnC;YACDD,gBAAgBA,cAAcE,UAAU,CAACD,QAAQ;YACjD;QACD;QAEA,IAAI,OAAOE,IAAI,CAACF,YAAYA,YAAY,MAAM;YAC7C,IAAID,cAAcI,KAAK,EAAE;gBACxBJ,gBAAgBR,kBAAkBQ,cAAcI,KAAK;gBACrD;YACD;QACD;QAEA,OAAOP;IACR;IAEA,OAAOG;AACR"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { findJsonSchemaByPath } from "./findJsonSchemaByPath.js";
|
|
2
|
+
export function formatZodError(error, schema) {
|
|
3
|
+
if (!error.issues || error.issues.length === 0) {
|
|
4
|
+
return error.message || "\u9A8C\u8BC1\u5931\u8D25";
|
|
5
|
+
}
|
|
6
|
+
const messages = [];
|
|
7
|
+
// Iterate through issues and format each one
|
|
8
|
+
// We use manual iteration instead of error.format() to have better control
|
|
9
|
+
// over field name formatting with schema descriptions
|
|
10
|
+
for (const issue of error.issues) {
|
|
11
|
+
const formatted = formatIssueMessage(issue, schema);
|
|
12
|
+
if (formatted) {
|
|
13
|
+
const path = issue.path.map((p) => typeof p === "symbol" ? String(p) : p);
|
|
14
|
+
let fieldName = formatPath(path);
|
|
15
|
+
// Try to get field description from schema
|
|
16
|
+
if (schema && path.length > 0) {
|
|
17
|
+
const fieldPath = path.map(String).join(".");
|
|
18
|
+
const fieldSchema = findJsonSchemaByPath(schema, fieldPath);
|
|
19
|
+
if (fieldSchema?.description) {
|
|
20
|
+
fieldName = fieldSchema.description;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
messages.push(`${fieldName}: ${formatted}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return messages.join("\uFF1B");
|
|
27
|
+
}
|
|
28
|
+
function formatIssueMessage(issue, schema) {
|
|
29
|
+
let message = issue.message;
|
|
30
|
+
// 处理常见的错误类型,生成更友好的消息
|
|
31
|
+
// Use string comparison to avoid TypeScript narrowing issues with Zod v4
|
|
32
|
+
const code = issue.code;
|
|
33
|
+
switch (code) {
|
|
34
|
+
case "invalid_type":
|
|
35
|
+
{
|
|
36
|
+
const invalidTypeIssue = issue;
|
|
37
|
+
if (invalidTypeIssue.received === "undefined") {
|
|
38
|
+
message = "\u5FC5\u586B";
|
|
39
|
+
}
|
|
40
|
+
else if (invalidTypeIssue.received === "null") {
|
|
41
|
+
message = "\u4E0D\u80FD\u4E3A\u7A7A";
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
message = issue.message || `期望类型 ${invalidTypeIssue.expected},但收到 ${invalidTypeIssue.received}`;
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "invalid_string":
|
|
49
|
+
{
|
|
50
|
+
const invalidStringIssue = issue;
|
|
51
|
+
if (invalidStringIssue.validation === "email") {
|
|
52
|
+
message = "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u5730\u5740";
|
|
53
|
+
}
|
|
54
|
+
else if (invalidStringIssue.validation === "url") {
|
|
55
|
+
message = "\u8BF7\u8F93\u5165\u6709\u6548\u7684 URL";
|
|
56
|
+
}
|
|
57
|
+
else if (invalidStringIssue.validation === "uuid") {
|
|
58
|
+
message = "\u8BF7\u8F93\u5165\u6709\u6548\u7684 UUID";
|
|
59
|
+
}
|
|
60
|
+
else if (invalidStringIssue.validation === "date") {
|
|
61
|
+
message = "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65E5\u671F";
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "too_small":
|
|
66
|
+
{
|
|
67
|
+
const tooSmallIssue = issue;
|
|
68
|
+
if (tooSmallIssue.type === "string" && tooSmallIssue.minimum === 1) {
|
|
69
|
+
message = "\u4E0D\u80FD\u4E3A\u7A7A";
|
|
70
|
+
}
|
|
71
|
+
else if (tooSmallIssue.type === "number") {
|
|
72
|
+
message = `至少需要 ${tooSmallIssue.minimum}`;
|
|
73
|
+
}
|
|
74
|
+
else if (tooSmallIssue.type === "array") {
|
|
75
|
+
message = `至少需要 ${tooSmallIssue.minimum} 项`;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case "too_big":
|
|
80
|
+
{
|
|
81
|
+
const tooBigIssue = issue;
|
|
82
|
+
if (tooBigIssue.type === "string") {
|
|
83
|
+
message = `最多 ${tooBigIssue.maximum} 个字符`;
|
|
84
|
+
}
|
|
85
|
+
else if (tooBigIssue.type === "number") {
|
|
86
|
+
message = `最多 ${tooBigIssue.maximum}`;
|
|
87
|
+
}
|
|
88
|
+
else if (tooBigIssue.type === "array") {
|
|
89
|
+
message = `最多 ${tooBigIssue.maximum} 项`;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "invalid_enum_value":
|
|
94
|
+
{
|
|
95
|
+
const enumIssue = issue;
|
|
96
|
+
message = `必须是以下值之一: ${enumIssue.options?.map(String).join(", ") || "\u672A\u77E5\u9009\u9879"}`;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case "unrecognized_keys":
|
|
100
|
+
{
|
|
101
|
+
const unrecognizedIssue = issue;
|
|
102
|
+
message = `不支持的字段: ${unrecognizedIssue.keys?.join(", ") || "\u672A\u77E5\u5B57\u6BB5"}`;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "invalid_union":
|
|
106
|
+
{
|
|
107
|
+
message = "\u4E0D\u7B26\u5408\u4EFB\u4F55\u5141\u8BB8\u7684\u7C7B\u578B";
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case "invalid_union_discriminator":
|
|
111
|
+
{
|
|
112
|
+
const discriminatorIssue = issue;
|
|
113
|
+
message = `必须是以下值之一: ${discriminatorIssue.options?.map(String).join(", ") || "\u672A\u77E5\u9009\u9879"}`;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case "invalid_literal":
|
|
117
|
+
{
|
|
118
|
+
const literalIssue = issue;
|
|
119
|
+
message = `必须是 ${String(literalIssue.expected)}`;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case "custom":
|
|
123
|
+
{
|
|
124
|
+
// 保留自定义错误消息
|
|
125
|
+
message = issue.message;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
default:
|
|
129
|
+
// 保留原始消息
|
|
130
|
+
message = issue.message;
|
|
131
|
+
}
|
|
132
|
+
return message;
|
|
133
|
+
}
|
|
134
|
+
function formatPath(path) {
|
|
135
|
+
if (path.length === 0) {
|
|
136
|
+
return "\u8868\u5355";
|
|
137
|
+
}
|
|
138
|
+
return path.map(String).join(".");
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=formatZodError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/formatZodError.ts"],"sourcesContent":["import { ZodError } from 'zod/v4';\nimport { findJsonSchemaByPath } from './findJsonSchemaByPath';\nimport type { TypeSchema } from './TypeSchema';\n\nexport function formatZodError(error: ZodError, schema?: TypeSchema): string {\n\tif (!error.issues || error.issues.length === 0) {\n\t\treturn error.message || '验证失败';\n\t}\n\n\tconst messages: string[] = [];\n\n\t// Iterate through issues and format each one\n\t// We use manual iteration instead of error.format() to have better control\n\t// over field name formatting with schema descriptions\n\tfor (const issue of error.issues) {\n\t\tconst formatted = formatIssueMessage(issue, schema);\n\t\tif (formatted) {\n\t\t\tconst path = issue.path.map((p) => (typeof p === 'symbol' ? String(p) : p)) as (string | number)[];\n\t\t\tlet fieldName = formatPath(path);\n\n\t\t\t// Try to get field description from schema\n\t\t\tif (schema && path.length > 0) {\n\t\t\t\tconst fieldPath = path.map(String).join('.');\n\t\t\t\tconst fieldSchema = findJsonSchemaByPath(schema, fieldPath);\n\t\t\t\tif (fieldSchema?.description) {\n\t\t\t\t\tfieldName = fieldSchema.description;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmessages.push(`${fieldName}: ${formatted}`);\n\t\t}\n\t}\n\n\treturn messages.join(';');\n}\n\nfunction formatIssueMessage(issue: ZodError['issues'][number], schema?: TypeSchema): string {\n\tlet message = issue.message;\n\n\t// 处理常见的错误类型,生成更友好的消息\n\t// Use string comparison to avoid TypeScript narrowing issues with Zod v4\n\tconst code = issue.code as string;\n\tswitch (code) {\n\t\tcase 'invalid_type': {\n\t\t\tconst invalidTypeIssue = issue as typeof issue & {\n\t\t\t\texpected: string;\n\t\t\t\treceived: string;\n\t\t\t};\n\t\t\tif (invalidTypeIssue.received === 'undefined') {\n\t\t\t\tmessage = '必填';\n\t\t\t} else if (invalidTypeIssue.received === 'null') {\n\t\t\t\tmessage = '不能为空';\n\t\t\t} else {\n\t\t\t\tmessage = issue.message || `期望类型 ${invalidTypeIssue.expected},但收到 ${invalidTypeIssue.received}`;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'invalid_string': {\n\t\t\tconst invalidStringIssue = issue as typeof issue & {\n\t\t\t\tvalidation?: string;\n\t\t\t};\n\t\t\tif (invalidStringIssue.validation === 'email') {\n\t\t\t\tmessage = '请输入有效的邮箱地址';\n\t\t\t} else if (invalidStringIssue.validation === 'url') {\n\t\t\t\tmessage = '请输入有效的 URL';\n\t\t\t} else if (invalidStringIssue.validation === 'uuid') {\n\t\t\t\tmessage = '请输入有效的 UUID';\n\t\t\t} else if (invalidStringIssue.validation === 'date') {\n\t\t\t\tmessage = '请输入有效的日期';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'too_small': {\n\t\t\tconst tooSmallIssue = issue as typeof issue & {\n\t\t\t\ttype: string;\n\t\t\t\tminimum: number;\n\t\t\t};\n\t\t\tif (tooSmallIssue.type === 'string' && tooSmallIssue.minimum === 1) {\n\t\t\t\tmessage = '不能为空';\n\t\t\t} else if (tooSmallIssue.type === 'number') {\n\t\t\t\tmessage = `至少需要 ${tooSmallIssue.minimum}`;\n\t\t\t} else if (tooSmallIssue.type === 'array') {\n\t\t\t\tmessage = `至少需要 ${tooSmallIssue.minimum} 项`;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'too_big': {\n\t\t\tconst tooBigIssue = issue as typeof issue & {\n\t\t\t\ttype: string;\n\t\t\t\tmaximum: number;\n\t\t\t};\n\t\t\tif (tooBigIssue.type === 'string') {\n\t\t\t\tmessage = `最多 ${tooBigIssue.maximum} 个字符`;\n\t\t\t} else if (tooBigIssue.type === 'number') {\n\t\t\t\tmessage = `最多 ${tooBigIssue.maximum}`;\n\t\t\t} else if (tooBigIssue.type === 'array') {\n\t\t\t\tmessage = `最多 ${tooBigIssue.maximum} 项`;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'invalid_enum_value': {\n\t\t\tconst enumIssue = issue as typeof issue & {\n\t\t\t\toptions: readonly unknown[];\n\t\t\t};\n\t\t\tmessage = `必须是以下值之一: ${enumIssue.options?.map(String).join(', ') || '未知选项'}`;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'unrecognized_keys': {\n\t\t\tconst unrecognizedIssue = issue as typeof issue & {\n\t\t\t\tkeys: readonly string[];\n\t\t\t};\n\t\t\tmessage = `不支持的字段: ${unrecognizedIssue.keys?.join(', ') || '未知字段'}`;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'invalid_union': {\n\t\t\tmessage = '不符合任何允许的类型';\n\t\t\tbreak;\n\t\t}\n\t\tcase 'invalid_union_discriminator': {\n\t\t\tconst discriminatorIssue = issue as typeof issue & {\n\t\t\t\toptions: readonly unknown[];\n\t\t\t};\n\t\t\tmessage = `必须是以下值之一: ${discriminatorIssue.options?.map(String).join(', ') || '未知选项'}`;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'invalid_literal': {\n\t\t\tconst literalIssue = issue as typeof issue & {\n\t\t\t\texpected: unknown;\n\t\t\t};\n\t\t\tmessage = `必须是 ${String(literalIssue.expected)}`;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'custom': {\n\t\t\t// 保留自定义错误消息\n\t\t\tmessage = issue.message;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\t// 保留原始消息\n\t\t\tmessage = issue.message;\n\t}\n\n\treturn message;\n}\n\nfunction formatPath(path: (string | number)[]): string {\n\tif (path.length === 0) {\n\t\treturn '表单';\n\t}\n\treturn path.map(String).join('.');\n}\n"],"names":["findJsonSchemaByPath","formatZodError","error","schema","issues","length","message","messages","issue","formatted","formatIssueMessage","path","map","p","String","fieldName","formatPath","fieldPath","join","fieldSchema","description","push","code","invalidTypeIssue","received","expected","invalidStringIssue","validation","tooSmallIssue","type","minimum","tooBigIssue","maximum","enumIssue","options","unrecognizedIssue","keys","discriminatorIssue","literalIssue"],"mappings":"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"}
|