flavor-code 1.2.13 → 1.2.15

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.
Files changed (136) hide show
  1. package/README.md +9 -1
  2. package/README.zh-CN.md +9 -1
  3. package/dist/agent/planner.d.ts +2 -0
  4. package/dist/{app-Z3YWFIBB.js → app-3KW2FTVJ.js} +2 -2
  5. package/dist/astgraph/db.mjs +237 -237
  6. package/dist/astgraph/extract.mjs +239 -239
  7. package/dist/astgraph/flavor-plugin.json +25 -25
  8. package/dist/astgraph/grammars.mjs +68 -68
  9. package/dist/astgraph/index.js +301 -301
  10. package/dist/astgraph/indexer.mjs +175 -175
  11. package/dist/astgraph/query.mjs +165 -165
  12. package/dist/astgraph/resolve.mjs +93 -93
  13. package/dist/astgraph/vendor/tree-sitter.js +3980 -3980
  14. package/dist/astgraph/vendor/zod/LICENSE +21 -21
  15. package/dist/astgraph/vendor/zod/index.js +4 -4
  16. package/dist/astgraph/vendor/zod/locales/index.js +1 -1
  17. package/dist/astgraph/vendor/zod/locales/package.json +7 -7
  18. package/dist/astgraph/vendor/zod/package.json +135 -135
  19. package/dist/astgraph/vendor/zod/v4/classic/checks.js +1 -1
  20. package/dist/astgraph/vendor/zod/v4/classic/coerce.js +17 -17
  21. package/dist/astgraph/vendor/zod/v4/classic/compat.js +31 -31
  22. package/dist/astgraph/vendor/zod/v4/classic/errors.js +48 -48
  23. package/dist/astgraph/vendor/zod/v4/classic/external.js +20 -20
  24. package/dist/astgraph/vendor/zod/v4/classic/from-json-schema.js +599 -599
  25. package/dist/astgraph/vendor/zod/v4/classic/index.js +4 -4
  26. package/dist/astgraph/vendor/zod/v4/classic/iso.js +30 -30
  27. package/dist/astgraph/vendor/zod/v4/classic/package.json +7 -7
  28. package/dist/astgraph/vendor/zod/v4/classic/parse.js +15 -15
  29. package/dist/astgraph/vendor/zod/v4/classic/schemas.js +1395 -1395
  30. package/dist/astgraph/vendor/zod/v4/core/api.js +1087 -1087
  31. package/dist/astgraph/vendor/zod/v4/core/checks.js +575 -575
  32. package/dist/astgraph/vendor/zod/v4/core/core.js +78 -78
  33. package/dist/astgraph/vendor/zod/v4/core/doc.js +35 -35
  34. package/dist/astgraph/vendor/zod/v4/core/errors.js +185 -185
  35. package/dist/astgraph/vendor/zod/v4/core/index.js +16 -16
  36. package/dist/astgraph/vendor/zod/v4/core/json-schema-generator.js +95 -95
  37. package/dist/astgraph/vendor/zod/v4/core/json-schema-processors.js +601 -601
  38. package/dist/astgraph/vendor/zod/v4/core/json-schema.js +1 -1
  39. package/dist/astgraph/vendor/zod/v4/core/package.json +7 -7
  40. package/dist/astgraph/vendor/zod/v4/core/parse.js +93 -93
  41. package/dist/astgraph/vendor/zod/v4/core/regexes.js +139 -139
  42. package/dist/astgraph/vendor/zod/v4/core/registries.js +51 -51
  43. package/dist/astgraph/vendor/zod/v4/core/schemas.js +2239 -2239
  44. package/dist/astgraph/vendor/zod/v4/core/standard-schema.js +1 -1
  45. package/dist/astgraph/vendor/zod/v4/core/to-json-schema.js +448 -448
  46. package/dist/astgraph/vendor/zod/v4/core/util.js +674 -674
  47. package/dist/astgraph/vendor/zod/v4/core/versions.js +5 -5
  48. package/dist/astgraph/vendor/zod/v4/index.js +3 -3
  49. package/dist/astgraph/vendor/zod/v4/locales/ar.js +106 -106
  50. package/dist/astgraph/vendor/zod/v4/locales/az.js +105 -105
  51. package/dist/astgraph/vendor/zod/v4/locales/be.js +156 -156
  52. package/dist/astgraph/vendor/zod/v4/locales/bg.js +120 -120
  53. package/dist/astgraph/vendor/zod/v4/locales/ca.js +107 -107
  54. package/dist/astgraph/vendor/zod/v4/locales/cs.js +111 -111
  55. package/dist/astgraph/vendor/zod/v4/locales/da.js +115 -115
  56. package/dist/astgraph/vendor/zod/v4/locales/de.js +108 -108
  57. package/dist/astgraph/vendor/zod/v4/locales/el.js +109 -109
  58. package/dist/astgraph/vendor/zod/v4/locales/en.js +113 -113
  59. package/dist/astgraph/vendor/zod/v4/locales/eo.js +109 -109
  60. package/dist/astgraph/vendor/zod/v4/locales/es.js +132 -132
  61. package/dist/astgraph/vendor/zod/v4/locales/fa.js +114 -114
  62. package/dist/astgraph/vendor/zod/v4/locales/fi.js +112 -112
  63. package/dist/astgraph/vendor/zod/v4/locales/fr-CA.js +107 -107
  64. package/dist/astgraph/vendor/zod/v4/locales/fr.js +125 -125
  65. package/dist/astgraph/vendor/zod/v4/locales/he.js +214 -214
  66. package/dist/astgraph/vendor/zod/v4/locales/hr.js +122 -122
  67. package/dist/astgraph/vendor/zod/v4/locales/hu.js +108 -108
  68. package/dist/astgraph/vendor/zod/v4/locales/hy.js +147 -147
  69. package/dist/astgraph/vendor/zod/v4/locales/id.js +106 -106
  70. package/dist/astgraph/vendor/zod/v4/locales/index.js +52 -52
  71. package/dist/astgraph/vendor/zod/v4/locales/is.js +109 -109
  72. package/dist/astgraph/vendor/zod/v4/locales/it.js +108 -108
  73. package/dist/astgraph/vendor/zod/v4/locales/ja.js +107 -107
  74. package/dist/astgraph/vendor/zod/v4/locales/ka.js +112 -112
  75. package/dist/astgraph/vendor/zod/v4/locales/kh.js +5 -5
  76. package/dist/astgraph/vendor/zod/v4/locales/km.js +110 -110
  77. package/dist/astgraph/vendor/zod/v4/locales/ko.js +111 -111
  78. package/dist/astgraph/vendor/zod/v4/locales/lt.js +203 -203
  79. package/dist/astgraph/vendor/zod/v4/locales/mk.js +109 -109
  80. package/dist/astgraph/vendor/zod/v4/locales/ms.js +107 -107
  81. package/dist/astgraph/vendor/zod/v4/locales/nl.js +110 -110
  82. package/dist/astgraph/vendor/zod/v4/locales/no.js +108 -108
  83. package/dist/astgraph/vendor/zod/v4/locales/ota.js +109 -109
  84. package/dist/astgraph/vendor/zod/v4/locales/package.json +7 -7
  85. package/dist/astgraph/vendor/zod/v4/locales/pl.js +109 -109
  86. package/dist/astgraph/vendor/zod/v4/locales/ps.js +114 -114
  87. package/dist/astgraph/vendor/zod/v4/locales/pt.js +108 -108
  88. package/dist/astgraph/vendor/zod/v4/locales/ro.js +119 -119
  89. package/dist/astgraph/vendor/zod/v4/locales/ru.js +156 -156
  90. package/dist/astgraph/vendor/zod/v4/locales/sl.js +109 -109
  91. package/dist/astgraph/vendor/zod/v4/locales/sv.js +110 -110
  92. package/dist/astgraph/vendor/zod/v4/locales/ta.js +110 -110
  93. package/dist/astgraph/vendor/zod/v4/locales/th.js +110 -110
  94. package/dist/astgraph/vendor/zod/v4/locales/tr.js +105 -105
  95. package/dist/astgraph/vendor/zod/v4/locales/ua.js +5 -5
  96. package/dist/astgraph/vendor/zod/v4/locales/uk.js +108 -108
  97. package/dist/astgraph/vendor/zod/v4/locales/ur.js +110 -110
  98. package/dist/astgraph/vendor/zod/v4/locales/uz.js +110 -110
  99. package/dist/astgraph/vendor/zod/v4/locales/vi.js +108 -108
  100. package/dist/astgraph/vendor/zod/v4/locales/yo.js +107 -107
  101. package/dist/astgraph/vendor/zod/v4/locales/zh-CN.js +109 -109
  102. package/dist/astgraph/vendor/zod/v4/locales/zh-TW.js +107 -107
  103. package/dist/astgraph/vendor/zod/v4/mini/checks.js +1 -1
  104. package/dist/astgraph/vendor/zod/v4/mini/coerce.js +22 -22
  105. package/dist/astgraph/vendor/zod/v4/mini/external.js +14 -14
  106. package/dist/astgraph/vendor/zod/v4/mini/index.js +3 -3
  107. package/dist/astgraph/vendor/zod/v4/mini/iso.js +34 -34
  108. package/dist/astgraph/vendor/zod/v4/mini/package.json +7 -7
  109. package/dist/astgraph/vendor/zod/v4/mini/parse.js +1 -1
  110. package/dist/astgraph/vendor/zod/v4/mini/schemas.js +961 -961
  111. package/dist/astgraph/vendor/zod/v4/package.json +7 -7
  112. package/dist/{chunk-Y5MZDG7I.js → chunk-5TG3E2EJ.js} +3253 -1909
  113. package/dist/{chunk-G6Q2Y2A7.js → chunk-BKARQJQZ.js} +1 -1
  114. package/dist/{chunk-XFCJXRJ2.js → chunk-IG4Z23CL.js} +6 -0
  115. package/dist/cli.js +80 -18
  116. package/dist/config/schema.d.ts +6 -0
  117. package/dist/desktop/main.js +6216 -4807
  118. package/dist/desktop-renderer/assets/{index-CCnSpff0.js → index-BCJjMvbX.js} +1 -1
  119. package/dist/desktop-renderer/index.html +1 -1
  120. package/dist/evolve/loader.d.ts +21 -0
  121. package/dist/evolve/service.d.ts +37 -0
  122. package/dist/evolve/store.d.ts +117 -0
  123. package/dist/git/insights.d.ts +52 -0
  124. package/dist/git/service.d.ts +43 -0
  125. package/dist/git/tools.d.ts +9 -0
  126. package/dist/hooks/types.d.ts +5 -1
  127. package/dist/{load-6ZMEBHSG.js → load-GKA7P6RJ.js} +1 -1
  128. package/dist/plugins/host.d.ts +9 -0
  129. package/dist/plugins/types.d.ts +1 -0
  130. package/dist/sdk/index.js +3 -3
  131. package/dist/session/store.d.ts +1 -0
  132. package/dist/tools/shell.d.ts +13 -0
  133. package/dist/ui/commands.d.ts +11 -2
  134. package/dist/ui/session.d.ts +3 -0
  135. package/package.json +1 -1
  136. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +303 -1
@@ -1,119 +1,119 @@
1
- import * as util from "../core/util.js";
2
- const error = () => {
3
- const Sizable = {
4
- string: { unit: "caractere", verb: "să aibă" },
5
- file: { unit: "octeți", verb: "să aibă" },
6
- array: { unit: "elemente", verb: "să aibă" },
7
- set: { unit: "elemente", verb: "să aibă" },
8
- map: { unit: "intrări", verb: "să aibă" },
9
- };
10
- function getSizing(origin) {
11
- return Sizable[origin] ?? null;
12
- }
13
- const FormatDictionary = {
14
- regex: "intrare",
15
- email: "adresă de email",
16
- url: "URL",
17
- emoji: "emoji",
18
- uuid: "UUID",
19
- uuidv4: "UUIDv4",
20
- uuidv6: "UUIDv6",
21
- nanoid: "nanoid",
22
- guid: "GUID",
23
- cuid: "cuid",
24
- cuid2: "cuid2",
25
- ulid: "ULID",
26
- xid: "XID",
27
- ksuid: "KSUID",
28
- datetime: "dată și oră ISO",
29
- date: "dată ISO",
30
- time: "oră ISO",
31
- duration: "durată ISO",
32
- ipv4: "adresă IPv4",
33
- ipv6: "adresă IPv6",
34
- mac: "adresă MAC",
35
- cidrv4: "interval IPv4",
36
- cidrv6: "interval IPv6",
37
- base64: "șir codat base64",
38
- base64url: "șir codat base64url",
39
- json_string: "șir JSON",
40
- e164: "număr E.164",
41
- jwt: "JWT",
42
- template_literal: "intrare",
43
- };
44
- const TypeDictionary = {
45
- nan: "NaN",
46
- string: "șir",
47
- number: "număr",
48
- boolean: "boolean",
49
- function: "funcție",
50
- array: "matrice",
51
- object: "obiect",
52
- undefined: "nedefinit",
53
- symbol: "simbol",
54
- bigint: "număr mare",
55
- void: "void",
56
- never: "never",
57
- map: "hartă",
58
- set: "set",
59
- };
60
- return (issue) => {
61
- switch (issue.code) {
62
- case "invalid_type": {
63
- const expected = TypeDictionary[issue.expected] ?? issue.expected;
64
- const receivedType = util.parsedType(issue.input);
65
- const received = TypeDictionary[receivedType] ?? receivedType;
66
- return `Intrare invalidă: așteptat ${expected}, primit ${received}`;
67
- }
68
- case "invalid_value":
69
- if (issue.values.length === 1)
70
- return `Intrare invalidă: așteptat ${util.stringifyPrimitive(issue.values[0])}`;
71
- return `Opțiune invalidă: așteptat una dintre ${util.joinValues(issue.values, "|")}`;
72
- case "too_big": {
73
- const adj = issue.inclusive ? "<=" : "<";
74
- const sizing = getSizing(issue.origin);
75
- if (sizing)
76
- return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemente"}`;
77
- return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} să fie ${adj}${issue.maximum.toString()}`;
78
- }
79
- case "too_small": {
80
- const adj = issue.inclusive ? ">=" : ">";
81
- const sizing = getSizing(issue.origin);
82
- if (sizing) {
83
- return `Prea mic: așteptat ca ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
84
- }
85
- return `Prea mic: așteptat ca ${issue.origin} să fie ${adj}${issue.minimum.toString()}`;
86
- }
87
- case "invalid_format": {
88
- const _issue = issue;
89
- if (_issue.format === "starts_with") {
90
- return `Șir invalid: trebuie să înceapă cu "${_issue.prefix}"`;
91
- }
92
- if (_issue.format === "ends_with")
93
- return `Șir invalid: trebuie să se termine cu "${_issue.suffix}"`;
94
- if (_issue.format === "includes")
95
- return `Șir invalid: trebuie să includă "${_issue.includes}"`;
96
- if (_issue.format === "regex")
97
- return `Șir invalid: trebuie să se potrivească cu modelul ${_issue.pattern}`;
98
- return `Format invalid: ${FormatDictionary[_issue.format] ?? issue.format}`;
99
- }
100
- case "not_multiple_of":
101
- return `Număr invalid: trebuie să fie multiplu de ${issue.divisor}`;
102
- case "unrecognized_keys":
103
- return `Chei nerecunoscute: ${util.joinValues(issue.keys, ", ")}`;
104
- case "invalid_key":
105
- return `Cheie invalidă în ${issue.origin}`;
106
- case "invalid_union":
107
- return "Intrare invalidă";
108
- case "invalid_element":
109
- return `Valoare invalidă în ${issue.origin}`;
110
- default:
111
- return `Intrare invalidă`;
112
- }
113
- };
114
- };
115
- export default function () {
116
- return {
117
- localeError: error(),
118
- };
119
- }
1
+ import * as util from "../core/util.js";
2
+ const error = () => {
3
+ const Sizable = {
4
+ string: { unit: "caractere", verb: "să aibă" },
5
+ file: { unit: "octeți", verb: "să aibă" },
6
+ array: { unit: "elemente", verb: "să aibă" },
7
+ set: { unit: "elemente", verb: "să aibă" },
8
+ map: { unit: "intrări", verb: "să aibă" },
9
+ };
10
+ function getSizing(origin) {
11
+ return Sizable[origin] ?? null;
12
+ }
13
+ const FormatDictionary = {
14
+ regex: "intrare",
15
+ email: "adresă de email",
16
+ url: "URL",
17
+ emoji: "emoji",
18
+ uuid: "UUID",
19
+ uuidv4: "UUIDv4",
20
+ uuidv6: "UUIDv6",
21
+ nanoid: "nanoid",
22
+ guid: "GUID",
23
+ cuid: "cuid",
24
+ cuid2: "cuid2",
25
+ ulid: "ULID",
26
+ xid: "XID",
27
+ ksuid: "KSUID",
28
+ datetime: "dată și oră ISO",
29
+ date: "dată ISO",
30
+ time: "oră ISO",
31
+ duration: "durată ISO",
32
+ ipv4: "adresă IPv4",
33
+ ipv6: "adresă IPv6",
34
+ mac: "adresă MAC",
35
+ cidrv4: "interval IPv4",
36
+ cidrv6: "interval IPv6",
37
+ base64: "șir codat base64",
38
+ base64url: "șir codat base64url",
39
+ json_string: "șir JSON",
40
+ e164: "număr E.164",
41
+ jwt: "JWT",
42
+ template_literal: "intrare",
43
+ };
44
+ const TypeDictionary = {
45
+ nan: "NaN",
46
+ string: "șir",
47
+ number: "număr",
48
+ boolean: "boolean",
49
+ function: "funcție",
50
+ array: "matrice",
51
+ object: "obiect",
52
+ undefined: "nedefinit",
53
+ symbol: "simbol",
54
+ bigint: "număr mare",
55
+ void: "void",
56
+ never: "never",
57
+ map: "hartă",
58
+ set: "set",
59
+ };
60
+ return (issue) => {
61
+ switch (issue.code) {
62
+ case "invalid_type": {
63
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
64
+ const receivedType = util.parsedType(issue.input);
65
+ const received = TypeDictionary[receivedType] ?? receivedType;
66
+ return `Intrare invalidă: așteptat ${expected}, primit ${received}`;
67
+ }
68
+ case "invalid_value":
69
+ if (issue.values.length === 1)
70
+ return `Intrare invalidă: așteptat ${util.stringifyPrimitive(issue.values[0])}`;
71
+ return `Opțiune invalidă: așteptat una dintre ${util.joinValues(issue.values, "|")}`;
72
+ case "too_big": {
73
+ const adj = issue.inclusive ? "<=" : "<";
74
+ const sizing = getSizing(issue.origin);
75
+ if (sizing)
76
+ return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemente"}`;
77
+ return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} să fie ${adj}${issue.maximum.toString()}`;
78
+ }
79
+ case "too_small": {
80
+ const adj = issue.inclusive ? ">=" : ">";
81
+ const sizing = getSizing(issue.origin);
82
+ if (sizing) {
83
+ return `Prea mic: așteptat ca ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
84
+ }
85
+ return `Prea mic: așteptat ca ${issue.origin} să fie ${adj}${issue.minimum.toString()}`;
86
+ }
87
+ case "invalid_format": {
88
+ const _issue = issue;
89
+ if (_issue.format === "starts_with") {
90
+ return `Șir invalid: trebuie să înceapă cu "${_issue.prefix}"`;
91
+ }
92
+ if (_issue.format === "ends_with")
93
+ return `Șir invalid: trebuie să se termine cu "${_issue.suffix}"`;
94
+ if (_issue.format === "includes")
95
+ return `Șir invalid: trebuie să includă "${_issue.includes}"`;
96
+ if (_issue.format === "regex")
97
+ return `Șir invalid: trebuie să se potrivească cu modelul ${_issue.pattern}`;
98
+ return `Format invalid: ${FormatDictionary[_issue.format] ?? issue.format}`;
99
+ }
100
+ case "not_multiple_of":
101
+ return `Număr invalid: trebuie să fie multiplu de ${issue.divisor}`;
102
+ case "unrecognized_keys":
103
+ return `Chei nerecunoscute: ${util.joinValues(issue.keys, ", ")}`;
104
+ case "invalid_key":
105
+ return `Cheie invalidă în ${issue.origin}`;
106
+ case "invalid_union":
107
+ return "Intrare invalidă";
108
+ case "invalid_element":
109
+ return `Valoare invalidă în ${issue.origin}`;
110
+ default:
111
+ return `Intrare invalidă`;
112
+ }
113
+ };
114
+ };
115
+ export default function () {
116
+ return {
117
+ localeError: error(),
118
+ };
119
+ }
@@ -1,156 +1,156 @@
1
- import * as util from "../core/util.js";
2
- function getRussianPlural(count, one, few, many) {
3
- const absCount = Math.abs(count);
4
- const lastDigit = absCount % 10;
5
- const lastTwoDigits = absCount % 100;
6
- if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
7
- return many;
8
- }
9
- if (lastDigit === 1) {
10
- return one;
11
- }
12
- if (lastDigit >= 2 && lastDigit <= 4) {
13
- return few;
14
- }
15
- return many;
16
- }
17
- const error = () => {
18
- const Sizable = {
19
- string: {
20
- unit: {
21
- one: "символ",
22
- few: "символа",
23
- many: "символов",
24
- },
25
- verb: "иметь",
26
- },
27
- file: {
28
- unit: {
29
- one: "байт",
30
- few: "байта",
31
- many: "байт",
32
- },
33
- verb: "иметь",
34
- },
35
- array: {
36
- unit: {
37
- one: "элемент",
38
- few: "элемента",
39
- many: "элементов",
40
- },
41
- verb: "иметь",
42
- },
43
- set: {
44
- unit: {
45
- one: "элемент",
46
- few: "элемента",
47
- many: "элементов",
48
- },
49
- verb: "иметь",
50
- },
51
- };
52
- function getSizing(origin) {
53
- return Sizable[origin] ?? null;
54
- }
55
- const FormatDictionary = {
56
- regex: "ввод",
57
- email: "email адрес",
58
- url: "URL",
59
- emoji: "эмодзи",
60
- uuid: "UUID",
61
- uuidv4: "UUIDv4",
62
- uuidv6: "UUIDv6",
63
- nanoid: "nanoid",
64
- guid: "GUID",
65
- cuid: "cuid",
66
- cuid2: "cuid2",
67
- ulid: "ULID",
68
- xid: "XID",
69
- ksuid: "KSUID",
70
- datetime: "ISO дата и время",
71
- date: "ISO дата",
72
- time: "ISO время",
73
- duration: "ISO длительность",
74
- ipv4: "IPv4 адрес",
75
- ipv6: "IPv6 адрес",
76
- cidrv4: "IPv4 диапазон",
77
- cidrv6: "IPv6 диапазон",
78
- base64: "строка в формате base64",
79
- base64url: "строка в формате base64url",
80
- json_string: "JSON строка",
81
- e164: "номер E.164",
82
- jwt: "JWT",
83
- template_literal: "ввод",
84
- };
85
- const TypeDictionary = {
86
- nan: "NaN",
87
- number: "число",
88
- array: "массив",
89
- };
90
- return (issue) => {
91
- switch (issue.code) {
92
- case "invalid_type": {
93
- const expected = TypeDictionary[issue.expected] ?? issue.expected;
94
- const receivedType = util.parsedType(issue.input);
95
- const received = TypeDictionary[receivedType] ?? receivedType;
96
- if (/^[A-Z]/.test(issue.expected)) {
97
- return `Неверный ввод: ожидалось instanceof ${issue.expected}, получено ${received}`;
98
- }
99
- return `Неверный ввод: ожидалось ${expected}, получено ${received}`;
100
- }
101
- case "invalid_value":
102
- if (issue.values.length === 1)
103
- return `Неверный ввод: ожидалось ${util.stringifyPrimitive(issue.values[0])}`;
104
- return `Неверный вариант: ожидалось одно из ${util.joinValues(issue.values, "|")}`;
105
- case "too_big": {
106
- const adj = issue.inclusive ? "<=" : "<";
107
- const sizing = getSizing(issue.origin);
108
- if (sizing) {
109
- const maxValue = Number(issue.maximum);
110
- const unit = getRussianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
111
- return `Слишком большое значение: ожидалось, что ${issue.origin ?? "значение"} будет иметь ${adj}${issue.maximum.toString()} ${unit}`;
112
- }
113
- return `Слишком большое значение: ожидалось, что ${issue.origin ?? "значение"} будет ${adj}${issue.maximum.toString()}`;
114
- }
115
- case "too_small": {
116
- const adj = issue.inclusive ? ">=" : ">";
117
- const sizing = getSizing(issue.origin);
118
- if (sizing) {
119
- const minValue = Number(issue.minimum);
120
- const unit = getRussianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
121
- return `Слишком маленькое значение: ожидалось, что ${issue.origin} будет иметь ${adj}${issue.minimum.toString()} ${unit}`;
122
- }
123
- return `Слишком маленькое значение: ожидалось, что ${issue.origin} будет ${adj}${issue.minimum.toString()}`;
124
- }
125
- case "invalid_format": {
126
- const _issue = issue;
127
- if (_issue.format === "starts_with")
128
- return `Неверная строка: должна начинаться с "${_issue.prefix}"`;
129
- if (_issue.format === "ends_with")
130
- return `Неверная строка: должна заканчиваться на "${_issue.suffix}"`;
131
- if (_issue.format === "includes")
132
- return `Неверная строка: должна содержать "${_issue.includes}"`;
133
- if (_issue.format === "regex")
134
- return `Неверная строка: должна соответствовать шаблону ${_issue.pattern}`;
135
- return `Неверный ${FormatDictionary[_issue.format] ?? issue.format}`;
136
- }
137
- case "not_multiple_of":
138
- return `Неверное число: должно быть кратным ${issue.divisor}`;
139
- case "unrecognized_keys":
140
- return `Нераспознанн${issue.keys.length > 1 ? "ые" : "ый"} ключ${issue.keys.length > 1 ? "и" : ""}: ${util.joinValues(issue.keys, ", ")}`;
141
- case "invalid_key":
142
- return `Неверный ключ в ${issue.origin}`;
143
- case "invalid_union":
144
- return "Неверные входные данные";
145
- case "invalid_element":
146
- return `Неверное значение в ${issue.origin}`;
147
- default:
148
- return `Неверные входные данные`;
149
- }
150
- };
151
- };
152
- export default function () {
153
- return {
154
- localeError: error(),
155
- };
156
- }
1
+ import * as util from "../core/util.js";
2
+ function getRussianPlural(count, one, few, many) {
3
+ const absCount = Math.abs(count);
4
+ const lastDigit = absCount % 10;
5
+ const lastTwoDigits = absCount % 100;
6
+ if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
7
+ return many;
8
+ }
9
+ if (lastDigit === 1) {
10
+ return one;
11
+ }
12
+ if (lastDigit >= 2 && lastDigit <= 4) {
13
+ return few;
14
+ }
15
+ return many;
16
+ }
17
+ const error = () => {
18
+ const Sizable = {
19
+ string: {
20
+ unit: {
21
+ one: "символ",
22
+ few: "символа",
23
+ many: "символов",
24
+ },
25
+ verb: "иметь",
26
+ },
27
+ file: {
28
+ unit: {
29
+ one: "байт",
30
+ few: "байта",
31
+ many: "байт",
32
+ },
33
+ verb: "иметь",
34
+ },
35
+ array: {
36
+ unit: {
37
+ one: "элемент",
38
+ few: "элемента",
39
+ many: "элементов",
40
+ },
41
+ verb: "иметь",
42
+ },
43
+ set: {
44
+ unit: {
45
+ one: "элемент",
46
+ few: "элемента",
47
+ many: "элементов",
48
+ },
49
+ verb: "иметь",
50
+ },
51
+ };
52
+ function getSizing(origin) {
53
+ return Sizable[origin] ?? null;
54
+ }
55
+ const FormatDictionary = {
56
+ regex: "ввод",
57
+ email: "email адрес",
58
+ url: "URL",
59
+ emoji: "эмодзи",
60
+ uuid: "UUID",
61
+ uuidv4: "UUIDv4",
62
+ uuidv6: "UUIDv6",
63
+ nanoid: "nanoid",
64
+ guid: "GUID",
65
+ cuid: "cuid",
66
+ cuid2: "cuid2",
67
+ ulid: "ULID",
68
+ xid: "XID",
69
+ ksuid: "KSUID",
70
+ datetime: "ISO дата и время",
71
+ date: "ISO дата",
72
+ time: "ISO время",
73
+ duration: "ISO длительность",
74
+ ipv4: "IPv4 адрес",
75
+ ipv6: "IPv6 адрес",
76
+ cidrv4: "IPv4 диапазон",
77
+ cidrv6: "IPv6 диапазон",
78
+ base64: "строка в формате base64",
79
+ base64url: "строка в формате base64url",
80
+ json_string: "JSON строка",
81
+ e164: "номер E.164",
82
+ jwt: "JWT",
83
+ template_literal: "ввод",
84
+ };
85
+ const TypeDictionary = {
86
+ nan: "NaN",
87
+ number: "число",
88
+ array: "массив",
89
+ };
90
+ return (issue) => {
91
+ switch (issue.code) {
92
+ case "invalid_type": {
93
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
94
+ const receivedType = util.parsedType(issue.input);
95
+ const received = TypeDictionary[receivedType] ?? receivedType;
96
+ if (/^[A-Z]/.test(issue.expected)) {
97
+ return `Неверный ввод: ожидалось instanceof ${issue.expected}, получено ${received}`;
98
+ }
99
+ return `Неверный ввод: ожидалось ${expected}, получено ${received}`;
100
+ }
101
+ case "invalid_value":
102
+ if (issue.values.length === 1)
103
+ return `Неверный ввод: ожидалось ${util.stringifyPrimitive(issue.values[0])}`;
104
+ return `Неверный вариант: ожидалось одно из ${util.joinValues(issue.values, "|")}`;
105
+ case "too_big": {
106
+ const adj = issue.inclusive ? "<=" : "<";
107
+ const sizing = getSizing(issue.origin);
108
+ if (sizing) {
109
+ const maxValue = Number(issue.maximum);
110
+ const unit = getRussianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
111
+ return `Слишком большое значение: ожидалось, что ${issue.origin ?? "значение"} будет иметь ${adj}${issue.maximum.toString()} ${unit}`;
112
+ }
113
+ return `Слишком большое значение: ожидалось, что ${issue.origin ?? "значение"} будет ${adj}${issue.maximum.toString()}`;
114
+ }
115
+ case "too_small": {
116
+ const adj = issue.inclusive ? ">=" : ">";
117
+ const sizing = getSizing(issue.origin);
118
+ if (sizing) {
119
+ const minValue = Number(issue.minimum);
120
+ const unit = getRussianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
121
+ return `Слишком маленькое значение: ожидалось, что ${issue.origin} будет иметь ${adj}${issue.minimum.toString()} ${unit}`;
122
+ }
123
+ return `Слишком маленькое значение: ожидалось, что ${issue.origin} будет ${adj}${issue.minimum.toString()}`;
124
+ }
125
+ case "invalid_format": {
126
+ const _issue = issue;
127
+ if (_issue.format === "starts_with")
128
+ return `Неверная строка: должна начинаться с "${_issue.prefix}"`;
129
+ if (_issue.format === "ends_with")
130
+ return `Неверная строка: должна заканчиваться на "${_issue.suffix}"`;
131
+ if (_issue.format === "includes")
132
+ return `Неверная строка: должна содержать "${_issue.includes}"`;
133
+ if (_issue.format === "regex")
134
+ return `Неверная строка: должна соответствовать шаблону ${_issue.pattern}`;
135
+ return `Неверный ${FormatDictionary[_issue.format] ?? issue.format}`;
136
+ }
137
+ case "not_multiple_of":
138
+ return `Неверное число: должно быть кратным ${issue.divisor}`;
139
+ case "unrecognized_keys":
140
+ return `Нераспознанн${issue.keys.length > 1 ? "ые" : "ый"} ключ${issue.keys.length > 1 ? "и" : ""}: ${util.joinValues(issue.keys, ", ")}`;
141
+ case "invalid_key":
142
+ return `Неверный ключ в ${issue.origin}`;
143
+ case "invalid_union":
144
+ return "Неверные входные данные";
145
+ case "invalid_element":
146
+ return `Неверное значение в ${issue.origin}`;
147
+ default:
148
+ return `Неверные входные данные`;
149
+ }
150
+ };
151
+ };
152
+ export default function () {
153
+ return {
154
+ localeError: error(),
155
+ };
156
+ }