flavor-code 1.4.0-beta.1 → 1.4.0-beta.4
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/agent/loop.d.ts +7 -2
- package/dist/{app-C5ZQUOKJ.js → app-UWIEIWBQ.js} +7 -7
- package/dist/{chunk-FOTMP4ZS.js → chunk-4RR5VVX4.js} +8 -2
- package/dist/{chunk-6MNOZ2TX.js → chunk-DCNUBQCH.js} +1376 -641
- package/dist/{chunk-ODRWR4KK.js → chunk-IQAZ42TM.js} +1 -1
- package/dist/{chunk-URUVFECH.js → chunk-KQMKY7C5.js} +8 -4
- package/dist/chunk-LKQTBL3R.js +107 -0
- package/dist/{chunk-3WCDZ6ZL.js → chunk-ZJCAQXA7.js} +2 -1
- package/dist/{claude-ink-LP32NSX5.js → claude-ink-ECZ6QF3P.js} +2 -2
- package/dist/cli-main.js +22 -15
- package/dist/cli.js +24 -5
- package/dist/config/schema.d.ts +4 -0
- package/dist/context/manager.d.ts +9 -0
- package/dist/desktop/main.js +1770 -949
- package/dist/desktop-renderer/assets/{index-CqRIr-hz.js → index-C0t1nGih.js} +2 -2
- package/dist/desktop-renderer/assets/{interactive-terminal-C4o7MNPO.js → interactive-terminal-BJqe96mZ.js} +1 -1
- package/dist/desktop-renderer/index.html +1 -1
- package/dist/git/service.d.ts +3 -3
- package/dist/git/tools.d.ts +1 -1
- package/dist/goal/classifier.d.ts +2 -0
- package/dist/goal/orchestrator.d.ts +18 -0
- package/dist/goal/planner.d.ts +2 -0
- package/dist/goal/store.d.ts +2 -0
- package/dist/goal/types.d.ts +8 -0
- package/dist/harness/journal.d.ts +2 -0
- package/dist/harness/local.d.ts +2 -0
- package/dist/init/project.d.ts +0 -6
- package/dist/jobs/registry.d.ts +7 -1
- package/dist/{load-V2UIYYQI.js → load-F4AYLCF6.js} +1 -1
- package/dist/loop/orchestrator.d.ts +18 -0
- package/dist/loop/types.d.ts +7 -0
- package/dist/production.d.ts +17 -0
- package/dist/sdk/index.js +5 -5
- package/dist/session/tree.d.ts +2 -0
- package/dist/tools/lsp.d.ts +13 -10
- package/dist/tools/runtime.d.ts +2 -1
- package/dist/tools/search.d.ts +1 -0
- package/dist/tools/types.d.ts +1 -1
- package/dist/ui/session.d.ts +9 -0
- package/dist/utils/abort.d.ts +4 -0
- package/dist/utils/execFileNoThrow.d.ts +1 -0
- package/dist/utils/heap.d.ts +58 -0
- package/dist/utils/memory-restart.d.ts +38 -3
- package/dist/utils/process-tree.d.ts +2 -0
- package/dist/utils/rotation-census.d.ts +36 -0
- package/package.json +2 -2
- package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +7 -7
- package/dist/astgraph/db.mjs +0 -237
- package/dist/astgraph/extract.mjs +0 -239
- package/dist/astgraph/flavor-plugin.json +0 -25
- package/dist/astgraph/grammars.mjs +0 -68
- package/dist/astgraph/index.js +0 -301
- package/dist/astgraph/indexer.mjs +0 -175
- package/dist/astgraph/query.mjs +0 -165
- package/dist/astgraph/resolve.mjs +0 -93
- package/dist/astgraph/vendor/tree-sitter-javascript.wasm +0 -0
- package/dist/astgraph/vendor/tree-sitter-tsx.wasm +0 -0
- package/dist/astgraph/vendor/tree-sitter-typescript.wasm +0 -0
- package/dist/astgraph/vendor/tree-sitter.js +0 -3980
- package/dist/astgraph/vendor/tree-sitter.wasm +0 -0
- package/dist/astgraph/vendor/zod/LICENSE +0 -21
- package/dist/astgraph/vendor/zod/index.js +0 -4
- package/dist/astgraph/vendor/zod/locales/index.js +0 -1
- package/dist/astgraph/vendor/zod/locales/package.json +0 -7
- package/dist/astgraph/vendor/zod/package.json +0 -135
- package/dist/astgraph/vendor/zod/v4/classic/checks.js +0 -1
- package/dist/astgraph/vendor/zod/v4/classic/coerce.js +0 -17
- package/dist/astgraph/vendor/zod/v4/classic/compat.js +0 -31
- package/dist/astgraph/vendor/zod/v4/classic/errors.js +0 -48
- package/dist/astgraph/vendor/zod/v4/classic/external.js +0 -20
- package/dist/astgraph/vendor/zod/v4/classic/from-json-schema.js +0 -599
- package/dist/astgraph/vendor/zod/v4/classic/index.js +0 -4
- package/dist/astgraph/vendor/zod/v4/classic/iso.js +0 -30
- package/dist/astgraph/vendor/zod/v4/classic/package.json +0 -7
- package/dist/astgraph/vendor/zod/v4/classic/parse.js +0 -15
- package/dist/astgraph/vendor/zod/v4/classic/schemas.js +0 -1395
- package/dist/astgraph/vendor/zod/v4/core/api.js +0 -1087
- package/dist/astgraph/vendor/zod/v4/core/checks.js +0 -575
- package/dist/astgraph/vendor/zod/v4/core/core.js +0 -78
- package/dist/astgraph/vendor/zod/v4/core/doc.js +0 -35
- package/dist/astgraph/vendor/zod/v4/core/errors.js +0 -185
- package/dist/astgraph/vendor/zod/v4/core/index.js +0 -16
- package/dist/astgraph/vendor/zod/v4/core/json-schema-generator.js +0 -95
- package/dist/astgraph/vendor/zod/v4/core/json-schema-processors.js +0 -601
- package/dist/astgraph/vendor/zod/v4/core/json-schema.js +0 -1
- package/dist/astgraph/vendor/zod/v4/core/package.json +0 -7
- package/dist/astgraph/vendor/zod/v4/core/parse.js +0 -93
- package/dist/astgraph/vendor/zod/v4/core/regexes.js +0 -139
- package/dist/astgraph/vendor/zod/v4/core/registries.js +0 -51
- package/dist/astgraph/vendor/zod/v4/core/schemas.js +0 -2239
- package/dist/astgraph/vendor/zod/v4/core/standard-schema.js +0 -1
- package/dist/astgraph/vendor/zod/v4/core/to-json-schema.js +0 -448
- package/dist/astgraph/vendor/zod/v4/core/util.js +0 -674
- package/dist/astgraph/vendor/zod/v4/core/versions.js +0 -5
- package/dist/astgraph/vendor/zod/v4/index.js +0 -3
- package/dist/astgraph/vendor/zod/v4/locales/ar.js +0 -106
- package/dist/astgraph/vendor/zod/v4/locales/az.js +0 -105
- package/dist/astgraph/vendor/zod/v4/locales/be.js +0 -156
- package/dist/astgraph/vendor/zod/v4/locales/bg.js +0 -120
- package/dist/astgraph/vendor/zod/v4/locales/ca.js +0 -107
- package/dist/astgraph/vendor/zod/v4/locales/cs.js +0 -111
- package/dist/astgraph/vendor/zod/v4/locales/da.js +0 -115
- package/dist/astgraph/vendor/zod/v4/locales/de.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/el.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/en.js +0 -113
- package/dist/astgraph/vendor/zod/v4/locales/eo.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/es.js +0 -132
- package/dist/astgraph/vendor/zod/v4/locales/fa.js +0 -114
- package/dist/astgraph/vendor/zod/v4/locales/fi.js +0 -112
- package/dist/astgraph/vendor/zod/v4/locales/fr-CA.js +0 -107
- package/dist/astgraph/vendor/zod/v4/locales/fr.js +0 -125
- package/dist/astgraph/vendor/zod/v4/locales/he.js +0 -214
- package/dist/astgraph/vendor/zod/v4/locales/hr.js +0 -122
- package/dist/astgraph/vendor/zod/v4/locales/hu.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/hy.js +0 -147
- package/dist/astgraph/vendor/zod/v4/locales/id.js +0 -106
- package/dist/astgraph/vendor/zod/v4/locales/index.js +0 -52
- package/dist/astgraph/vendor/zod/v4/locales/is.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/it.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/ja.js +0 -107
- package/dist/astgraph/vendor/zod/v4/locales/ka.js +0 -112
- package/dist/astgraph/vendor/zod/v4/locales/kh.js +0 -5
- package/dist/astgraph/vendor/zod/v4/locales/km.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/ko.js +0 -111
- package/dist/astgraph/vendor/zod/v4/locales/lt.js +0 -203
- package/dist/astgraph/vendor/zod/v4/locales/mk.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/ms.js +0 -107
- package/dist/astgraph/vendor/zod/v4/locales/nl.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/no.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/ota.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/package.json +0 -7
- package/dist/astgraph/vendor/zod/v4/locales/pl.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/ps.js +0 -114
- package/dist/astgraph/vendor/zod/v4/locales/pt.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/ro.js +0 -119
- package/dist/astgraph/vendor/zod/v4/locales/ru.js +0 -156
- package/dist/astgraph/vendor/zod/v4/locales/sl.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/sv.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/ta.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/th.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/tr.js +0 -105
- package/dist/astgraph/vendor/zod/v4/locales/ua.js +0 -5
- package/dist/astgraph/vendor/zod/v4/locales/uk.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/ur.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/uz.js +0 -110
- package/dist/astgraph/vendor/zod/v4/locales/vi.js +0 -108
- package/dist/astgraph/vendor/zod/v4/locales/yo.js +0 -107
- package/dist/astgraph/vendor/zod/v4/locales/zh-CN.js +0 -109
- package/dist/astgraph/vendor/zod/v4/locales/zh-TW.js +0 -107
- package/dist/astgraph/vendor/zod/v4/mini/checks.js +0 -1
- package/dist/astgraph/vendor/zod/v4/mini/coerce.js +0 -22
- package/dist/astgraph/vendor/zod/v4/mini/external.js +0 -14
- package/dist/astgraph/vendor/zod/v4/mini/index.js +0 -3
- package/dist/astgraph/vendor/zod/v4/mini/iso.js +0 -34
- package/dist/astgraph/vendor/zod/v4/mini/package.json +0 -7
- package/dist/astgraph/vendor/zod/v4/mini/parse.js +0 -1
- package/dist/astgraph/vendor/zod/v4/mini/schemas.js +0 -961
- package/dist/astgraph/vendor/zod/v4/package.json +0 -7
- package/dist/chunk-CIVPKHF4.js +0 -53
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import * as util from "../core/util.js";
|
|
2
|
-
const error = () => {
|
|
3
|
-
const Sizable = {
|
|
4
|
-
string: { unit: "àmi", verb: "ní" },
|
|
5
|
-
file: { unit: "bytes", verb: "ní" },
|
|
6
|
-
array: { unit: "nkan", verb: "ní" },
|
|
7
|
-
set: { unit: "nkan", verb: "ní" },
|
|
8
|
-
};
|
|
9
|
-
function getSizing(origin) {
|
|
10
|
-
return Sizable[origin] ?? null;
|
|
11
|
-
}
|
|
12
|
-
const FormatDictionary = {
|
|
13
|
-
regex: "ẹ̀rọ ìbáwọlé",
|
|
14
|
-
email: "àdírẹ́sì ìmẹ́lì",
|
|
15
|
-
url: "URL",
|
|
16
|
-
emoji: "emoji",
|
|
17
|
-
uuid: "UUID",
|
|
18
|
-
uuidv4: "UUIDv4",
|
|
19
|
-
uuidv6: "UUIDv6",
|
|
20
|
-
nanoid: "nanoid",
|
|
21
|
-
guid: "GUID",
|
|
22
|
-
cuid: "cuid",
|
|
23
|
-
cuid2: "cuid2",
|
|
24
|
-
ulid: "ULID",
|
|
25
|
-
xid: "XID",
|
|
26
|
-
ksuid: "KSUID",
|
|
27
|
-
datetime: "àkókò ISO",
|
|
28
|
-
date: "ọjọ́ ISO",
|
|
29
|
-
time: "àkókò ISO",
|
|
30
|
-
duration: "àkókò tó pé ISO",
|
|
31
|
-
ipv4: "àdírẹ́sì IPv4",
|
|
32
|
-
ipv6: "àdírẹ́sì IPv6",
|
|
33
|
-
cidrv4: "àgbègbè IPv4",
|
|
34
|
-
cidrv6: "àgbègbè IPv6",
|
|
35
|
-
base64: "ọ̀rọ̀ tí a kọ́ ní base64",
|
|
36
|
-
base64url: "ọ̀rọ̀ base64url",
|
|
37
|
-
json_string: "ọ̀rọ̀ JSON",
|
|
38
|
-
e164: "nọ́mbà E.164",
|
|
39
|
-
jwt: "JWT",
|
|
40
|
-
template_literal: "ẹ̀rọ ìbáwọlé",
|
|
41
|
-
};
|
|
42
|
-
const TypeDictionary = {
|
|
43
|
-
nan: "NaN",
|
|
44
|
-
number: "nọ́mbà",
|
|
45
|
-
array: "akopọ",
|
|
46
|
-
};
|
|
47
|
-
return (issue) => {
|
|
48
|
-
switch (issue.code) {
|
|
49
|
-
case "invalid_type": {
|
|
50
|
-
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
|
51
|
-
const receivedType = util.parsedType(issue.input);
|
|
52
|
-
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
53
|
-
if (/^[A-Z]/.test(issue.expected)) {
|
|
54
|
-
return `Ìbáwọlé aṣìṣe: a ní láti fi instanceof ${issue.expected}, àmọ̀ a rí ${received}`;
|
|
55
|
-
}
|
|
56
|
-
return `Ìbáwọlé aṣìṣe: a ní láti fi ${expected}, àmọ̀ a rí ${received}`;
|
|
57
|
-
}
|
|
58
|
-
case "invalid_value":
|
|
59
|
-
if (issue.values.length === 1)
|
|
60
|
-
return `Ìbáwọlé aṣìṣe: a ní láti fi ${util.stringifyPrimitive(issue.values[0])}`;
|
|
61
|
-
return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${util.joinValues(issue.values, "|")}`;
|
|
62
|
-
case "too_big": {
|
|
63
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
64
|
-
const sizing = getSizing(issue.origin);
|
|
65
|
-
if (sizing)
|
|
66
|
-
return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue.origin ?? "iye"} ${sizing.verb} ${adj}${issue.maximum} ${sizing.unit}`;
|
|
67
|
-
return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue.maximum}`;
|
|
68
|
-
}
|
|
69
|
-
case "too_small": {
|
|
70
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
71
|
-
const sizing = getSizing(issue.origin);
|
|
72
|
-
if (sizing)
|
|
73
|
-
return `Kéré ju: a ní láti jẹ́ pé ${issue.origin} ${sizing.verb} ${adj}${issue.minimum} ${sizing.unit}`;
|
|
74
|
-
return `Kéré ju: a ní láti jẹ́ ${adj}${issue.minimum}`;
|
|
75
|
-
}
|
|
76
|
-
case "invalid_format": {
|
|
77
|
-
const _issue = issue;
|
|
78
|
-
if (_issue.format === "starts_with")
|
|
79
|
-
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`;
|
|
80
|
-
if (_issue.format === "ends_with")
|
|
81
|
-
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`;
|
|
82
|
-
if (_issue.format === "includes")
|
|
83
|
-
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`;
|
|
84
|
-
if (_issue.format === "regex")
|
|
85
|
-
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`;
|
|
86
|
-
return `Aṣìṣe: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
87
|
-
}
|
|
88
|
-
case "not_multiple_of":
|
|
89
|
-
return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue.divisor}`;
|
|
90
|
-
case "unrecognized_keys":
|
|
91
|
-
return `Bọtìnì àìmọ̀: ${util.joinValues(issue.keys, ", ")}`;
|
|
92
|
-
case "invalid_key":
|
|
93
|
-
return `Bọtìnì aṣìṣe nínú ${issue.origin}`;
|
|
94
|
-
case "invalid_union":
|
|
95
|
-
return "Ìbáwọlé aṣìṣe";
|
|
96
|
-
case "invalid_element":
|
|
97
|
-
return `Iye aṣìṣe nínú ${issue.origin}`;
|
|
98
|
-
default:
|
|
99
|
-
return "Ìbáwọlé aṣìṣe";
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
export default function () {
|
|
104
|
-
return {
|
|
105
|
-
localeError: error(),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import * as util from "../core/util.js";
|
|
2
|
-
const error = () => {
|
|
3
|
-
const Sizable = {
|
|
4
|
-
string: { unit: "字符", verb: "包含" },
|
|
5
|
-
file: { unit: "字节", verb: "包含" },
|
|
6
|
-
array: { unit: "项", verb: "包含" },
|
|
7
|
-
set: { unit: "项", verb: "包含" },
|
|
8
|
-
};
|
|
9
|
-
function getSizing(origin) {
|
|
10
|
-
return Sizable[origin] ?? null;
|
|
11
|
-
}
|
|
12
|
-
const FormatDictionary = {
|
|
13
|
-
regex: "输入",
|
|
14
|
-
email: "电子邮件",
|
|
15
|
-
url: "URL",
|
|
16
|
-
emoji: "表情符号",
|
|
17
|
-
uuid: "UUID",
|
|
18
|
-
uuidv4: "UUIDv4",
|
|
19
|
-
uuidv6: "UUIDv6",
|
|
20
|
-
nanoid: "nanoid",
|
|
21
|
-
guid: "GUID",
|
|
22
|
-
cuid: "cuid",
|
|
23
|
-
cuid2: "cuid2",
|
|
24
|
-
ulid: "ULID",
|
|
25
|
-
xid: "XID",
|
|
26
|
-
ksuid: "KSUID",
|
|
27
|
-
datetime: "ISO日期时间",
|
|
28
|
-
date: "ISO日期",
|
|
29
|
-
time: "ISO时间",
|
|
30
|
-
duration: "ISO时长",
|
|
31
|
-
ipv4: "IPv4地址",
|
|
32
|
-
ipv6: "IPv6地址",
|
|
33
|
-
cidrv4: "IPv4网段",
|
|
34
|
-
cidrv6: "IPv6网段",
|
|
35
|
-
base64: "base64编码字符串",
|
|
36
|
-
base64url: "base64url编码字符串",
|
|
37
|
-
json_string: "JSON字符串",
|
|
38
|
-
e164: "E.164号码",
|
|
39
|
-
jwt: "JWT",
|
|
40
|
-
template_literal: "输入",
|
|
41
|
-
};
|
|
42
|
-
const TypeDictionary = {
|
|
43
|
-
nan: "NaN",
|
|
44
|
-
number: "数字",
|
|
45
|
-
array: "数组",
|
|
46
|
-
null: "空值(null)",
|
|
47
|
-
};
|
|
48
|
-
return (issue) => {
|
|
49
|
-
switch (issue.code) {
|
|
50
|
-
case "invalid_type": {
|
|
51
|
-
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
|
52
|
-
const receivedType = util.parsedType(issue.input);
|
|
53
|
-
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
54
|
-
if (/^[A-Z]/.test(issue.expected)) {
|
|
55
|
-
return `无效输入:期望 instanceof ${issue.expected},实际接收 ${received}`;
|
|
56
|
-
}
|
|
57
|
-
return `无效输入:期望 ${expected},实际接收 ${received}`;
|
|
58
|
-
}
|
|
59
|
-
case "invalid_value":
|
|
60
|
-
if (issue.values.length === 1)
|
|
61
|
-
return `无效输入:期望 ${util.stringifyPrimitive(issue.values[0])}`;
|
|
62
|
-
return `无效选项:期望以下之一 ${util.joinValues(issue.values, "|")}`;
|
|
63
|
-
case "too_big": {
|
|
64
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
65
|
-
const sizing = getSizing(issue.origin);
|
|
66
|
-
if (sizing)
|
|
67
|
-
return `数值过大:期望 ${issue.origin ?? "值"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "个元素"}`;
|
|
68
|
-
return `数值过大:期望 ${issue.origin ?? "值"} ${adj}${issue.maximum.toString()}`;
|
|
69
|
-
}
|
|
70
|
-
case "too_small": {
|
|
71
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
72
|
-
const sizing = getSizing(issue.origin);
|
|
73
|
-
if (sizing) {
|
|
74
|
-
return `数值过小:期望 ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
75
|
-
}
|
|
76
|
-
return `数值过小:期望 ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
|
77
|
-
}
|
|
78
|
-
case "invalid_format": {
|
|
79
|
-
const _issue = issue;
|
|
80
|
-
if (_issue.format === "starts_with")
|
|
81
|
-
return `无效字符串:必须以 "${_issue.prefix}" 开头`;
|
|
82
|
-
if (_issue.format === "ends_with")
|
|
83
|
-
return `无效字符串:必须以 "${_issue.suffix}" 结尾`;
|
|
84
|
-
if (_issue.format === "includes")
|
|
85
|
-
return `无效字符串:必须包含 "${_issue.includes}"`;
|
|
86
|
-
if (_issue.format === "regex")
|
|
87
|
-
return `无效字符串:必须满足正则表达式 ${_issue.pattern}`;
|
|
88
|
-
return `无效${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
89
|
-
}
|
|
90
|
-
case "not_multiple_of":
|
|
91
|
-
return `无效数字:必须是 ${issue.divisor} 的倍数`;
|
|
92
|
-
case "unrecognized_keys":
|
|
93
|
-
return `出现未知的键(key): ${util.joinValues(issue.keys, ", ")}`;
|
|
94
|
-
case "invalid_key":
|
|
95
|
-
return `${issue.origin} 中的键(key)无效`;
|
|
96
|
-
case "invalid_union":
|
|
97
|
-
return "无效输入";
|
|
98
|
-
case "invalid_element":
|
|
99
|
-
return `${issue.origin} 中包含无效值(value)`;
|
|
100
|
-
default:
|
|
101
|
-
return `无效输入`;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
export default function () {
|
|
106
|
-
return {
|
|
107
|
-
localeError: error(),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import * as util from "../core/util.js";
|
|
2
|
-
const error = () => {
|
|
3
|
-
const Sizable = {
|
|
4
|
-
string: { unit: "字元", verb: "擁有" },
|
|
5
|
-
file: { unit: "位元組", verb: "擁有" },
|
|
6
|
-
array: { unit: "項目", verb: "擁有" },
|
|
7
|
-
set: { unit: "項目", verb: "擁有" },
|
|
8
|
-
};
|
|
9
|
-
function getSizing(origin) {
|
|
10
|
-
return Sizable[origin] ?? null;
|
|
11
|
-
}
|
|
12
|
-
const FormatDictionary = {
|
|
13
|
-
regex: "輸入",
|
|
14
|
-
email: "郵件地址",
|
|
15
|
-
url: "URL",
|
|
16
|
-
emoji: "emoji",
|
|
17
|
-
uuid: "UUID",
|
|
18
|
-
uuidv4: "UUIDv4",
|
|
19
|
-
uuidv6: "UUIDv6",
|
|
20
|
-
nanoid: "nanoid",
|
|
21
|
-
guid: "GUID",
|
|
22
|
-
cuid: "cuid",
|
|
23
|
-
cuid2: "cuid2",
|
|
24
|
-
ulid: "ULID",
|
|
25
|
-
xid: "XID",
|
|
26
|
-
ksuid: "KSUID",
|
|
27
|
-
datetime: "ISO 日期時間",
|
|
28
|
-
date: "ISO 日期",
|
|
29
|
-
time: "ISO 時間",
|
|
30
|
-
duration: "ISO 期間",
|
|
31
|
-
ipv4: "IPv4 位址",
|
|
32
|
-
ipv6: "IPv6 位址",
|
|
33
|
-
cidrv4: "IPv4 範圍",
|
|
34
|
-
cidrv6: "IPv6 範圍",
|
|
35
|
-
base64: "base64 編碼字串",
|
|
36
|
-
base64url: "base64url 編碼字串",
|
|
37
|
-
json_string: "JSON 字串",
|
|
38
|
-
e164: "E.164 數值",
|
|
39
|
-
jwt: "JWT",
|
|
40
|
-
template_literal: "輸入",
|
|
41
|
-
};
|
|
42
|
-
const TypeDictionary = {
|
|
43
|
-
nan: "NaN",
|
|
44
|
-
};
|
|
45
|
-
return (issue) => {
|
|
46
|
-
switch (issue.code) {
|
|
47
|
-
case "invalid_type": {
|
|
48
|
-
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
|
49
|
-
const receivedType = util.parsedType(issue.input);
|
|
50
|
-
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
51
|
-
if (/^[A-Z]/.test(issue.expected)) {
|
|
52
|
-
return `無效的輸入值:預期為 instanceof ${issue.expected},但收到 ${received}`;
|
|
53
|
-
}
|
|
54
|
-
return `無效的輸入值:預期為 ${expected},但收到 ${received}`;
|
|
55
|
-
}
|
|
56
|
-
case "invalid_value":
|
|
57
|
-
if (issue.values.length === 1)
|
|
58
|
-
return `無效的輸入值:預期為 ${util.stringifyPrimitive(issue.values[0])}`;
|
|
59
|
-
return `無效的選項:預期為以下其中之一 ${util.joinValues(issue.values, "|")}`;
|
|
60
|
-
case "too_big": {
|
|
61
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
62
|
-
const sizing = getSizing(issue.origin);
|
|
63
|
-
if (sizing)
|
|
64
|
-
return `數值過大:預期 ${issue.origin ?? "值"} 應為 ${adj}${issue.maximum.toString()} ${sizing.unit ?? "個元素"}`;
|
|
65
|
-
return `數值過大:預期 ${issue.origin ?? "值"} 應為 ${adj}${issue.maximum.toString()}`;
|
|
66
|
-
}
|
|
67
|
-
case "too_small": {
|
|
68
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
69
|
-
const sizing = getSizing(issue.origin);
|
|
70
|
-
if (sizing) {
|
|
71
|
-
return `數值過小:預期 ${issue.origin} 應為 ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
72
|
-
}
|
|
73
|
-
return `數值過小:預期 ${issue.origin} 應為 ${adj}${issue.minimum.toString()}`;
|
|
74
|
-
}
|
|
75
|
-
case "invalid_format": {
|
|
76
|
-
const _issue = issue;
|
|
77
|
-
if (_issue.format === "starts_with") {
|
|
78
|
-
return `無效的字串:必須以 "${_issue.prefix}" 開頭`;
|
|
79
|
-
}
|
|
80
|
-
if (_issue.format === "ends_with")
|
|
81
|
-
return `無效的字串:必須以 "${_issue.suffix}" 結尾`;
|
|
82
|
-
if (_issue.format === "includes")
|
|
83
|
-
return `無效的字串:必須包含 "${_issue.includes}"`;
|
|
84
|
-
if (_issue.format === "regex")
|
|
85
|
-
return `無效的字串:必須符合格式 ${_issue.pattern}`;
|
|
86
|
-
return `無效的 ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
87
|
-
}
|
|
88
|
-
case "not_multiple_of":
|
|
89
|
-
return `無效的數字:必須為 ${issue.divisor} 的倍數`;
|
|
90
|
-
case "unrecognized_keys":
|
|
91
|
-
return `無法識別的鍵值${issue.keys.length > 1 ? "們" : ""}:${util.joinValues(issue.keys, "、")}`;
|
|
92
|
-
case "invalid_key":
|
|
93
|
-
return `${issue.origin} 中有無效的鍵值`;
|
|
94
|
-
case "invalid_union":
|
|
95
|
-
return "無效的輸入值";
|
|
96
|
-
case "invalid_element":
|
|
97
|
-
return `${issue.origin} 中有無效的值`;
|
|
98
|
-
default:
|
|
99
|
-
return `無效的輸入值`;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
export default function () {
|
|
104
|
-
return {
|
|
105
|
-
localeError: error(),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { _lt as lt, _lte as lte, _lte as maximum, _gt as gt, _gte as gte, _gte as minimum, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, } from "../core/index.js";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as core from "../core/index.js";
|
|
2
|
-
import * as schemas from "./schemas.js";
|
|
3
|
-
// @__NO_SIDE_EFFECTS__
|
|
4
|
-
export function string(params) {
|
|
5
|
-
return core._coercedString(schemas.ZodMiniString, params);
|
|
6
|
-
}
|
|
7
|
-
// @__NO_SIDE_EFFECTS__
|
|
8
|
-
export function number(params) {
|
|
9
|
-
return core._coercedNumber(schemas.ZodMiniNumber, params);
|
|
10
|
-
}
|
|
11
|
-
// @__NO_SIDE_EFFECTS__
|
|
12
|
-
export function boolean(params) {
|
|
13
|
-
return core._coercedBoolean(schemas.ZodMiniBoolean, params);
|
|
14
|
-
}
|
|
15
|
-
// @__NO_SIDE_EFFECTS__
|
|
16
|
-
export function bigint(params) {
|
|
17
|
-
return core._coercedBigint(schemas.ZodMiniBigInt, params);
|
|
18
|
-
}
|
|
19
|
-
// @__NO_SIDE_EFFECTS__
|
|
20
|
-
export function date(params) {
|
|
21
|
-
return core._coercedDate(schemas.ZodMiniDate, params);
|
|
22
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * as core from "../core/index.js";
|
|
2
|
-
export * from "./parse.js";
|
|
3
|
-
export * from "./schemas.js";
|
|
4
|
-
export * from "./checks.js";
|
|
5
|
-
export { globalRegistry, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, TimePrecision, util, NEVER, } from "../core/index.js";
|
|
6
|
-
export { toJSONSchema } from "../core/json-schema-processors.js";
|
|
7
|
-
export * as locales from "../locales/index.js";
|
|
8
|
-
/** A special constant with type `never` */
|
|
9
|
-
// export const NEVER = {} as never;
|
|
10
|
-
// iso
|
|
11
|
-
export * as iso from "./iso.js";
|
|
12
|
-
export { ZodMiniISODateTime, ZodMiniISODate, ZodMiniISOTime, ZodMiniISODuration, } from "./iso.js";
|
|
13
|
-
// coerce
|
|
14
|
-
export * as coerce from "./coerce.js";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as core from "../core/index.js";
|
|
2
|
-
import * as schemas from "./schemas.js";
|
|
3
|
-
export const ZodMiniISODateTime = /*@__PURE__*/ core.$constructor("ZodMiniISODateTime", (inst, def) => {
|
|
4
|
-
core.$ZodISODateTime.init(inst, def);
|
|
5
|
-
schemas.ZodMiniStringFormat.init(inst, def);
|
|
6
|
-
});
|
|
7
|
-
// @__NO_SIDE_EFFECTS__
|
|
8
|
-
export function datetime(params) {
|
|
9
|
-
return core._isoDateTime(ZodMiniISODateTime, params);
|
|
10
|
-
}
|
|
11
|
-
export const ZodMiniISODate = /*@__PURE__*/ core.$constructor("ZodMiniISODate", (inst, def) => {
|
|
12
|
-
core.$ZodISODate.init(inst, def);
|
|
13
|
-
schemas.ZodMiniStringFormat.init(inst, def);
|
|
14
|
-
});
|
|
15
|
-
// @__NO_SIDE_EFFECTS__
|
|
16
|
-
export function date(params) {
|
|
17
|
-
return core._isoDate(ZodMiniISODate, params);
|
|
18
|
-
}
|
|
19
|
-
export const ZodMiniISOTime = /*@__PURE__*/ core.$constructor("ZodMiniISOTime", (inst, def) => {
|
|
20
|
-
core.$ZodISOTime.init(inst, def);
|
|
21
|
-
schemas.ZodMiniStringFormat.init(inst, def);
|
|
22
|
-
});
|
|
23
|
-
// @__NO_SIDE_EFFECTS__
|
|
24
|
-
export function time(params) {
|
|
25
|
-
return core._isoTime(ZodMiniISOTime, params);
|
|
26
|
-
}
|
|
27
|
-
export const ZodMiniISODuration = /*@__PURE__*/ core.$constructor("ZodMiniISODuration", (inst, def) => {
|
|
28
|
-
core.$ZodISODuration.init(inst, def);
|
|
29
|
-
schemas.ZodMiniStringFormat.init(inst, def);
|
|
30
|
-
});
|
|
31
|
-
// @__NO_SIDE_EFFECTS__
|
|
32
|
-
export function duration(params) {
|
|
33
|
-
return core._isoDuration(ZodMiniISODuration, params);
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parse, safeParse, parseAsync, safeParseAsync, encode, decode, encodeAsync, decodeAsync, safeEncode, safeDecode, safeEncodeAsync, safeDecodeAsync, } from "../core/index.js";
|