typia 5.2.2 → 5.2.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.
Files changed (74) hide show
  1. package/lib/Primitive.d.ts +1 -1
  2. package/lib/executable/setup/CommandExecutor.js +2 -2
  3. package/lib/executable/setup/CommandExecutor.js.map +1 -1
  4. package/package.json +1 -2
  5. package/src/CamelCase.ts +116 -116
  6. package/src/PascalCase.ts +116 -116
  7. package/src/Primitive.ts +135 -135
  8. package/src/Resolved.ts +116 -116
  9. package/src/SnakeCase.ts +156 -156
  10. package/src/executable/TypiaSetupWizard.ts +142 -142
  11. package/src/executable/setup/CommandExecutor.ts +2 -2
  12. package/src/factories/JsonMetadataFactory.ts +50 -50
  13. package/src/factories/MetadataCollection.ts +282 -282
  14. package/src/functional/$convention.ts +40 -40
  15. package/src/functional/Namespace.ts +164 -164
  16. package/src/module.ts +662 -662
  17. package/src/notations.ts +855 -855
  18. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  19. package/src/programmers/helpers/NotationJoiner.ts +146 -146
  20. package/src/programmers/misc/MiscCloneProgrammer.ts +790 -790
  21. package/src/programmers/misc/MiscPruneProgrammer.ts +552 -552
  22. package/src/programmers/notations/NotationAssertGeneralProgrammer.ts +72 -72
  23. package/src/programmers/notations/NotationGeneralProgrammer.ts +720 -720
  24. package/src/programmers/notations/NotationIsGeneralProgrammer.ts +79 -79
  25. package/src/programmers/notations/NotationValidateGeneralProgrammer.ts +88 -88
  26. package/src/transformers/CallExpressionTransformer.ts +380 -380
  27. package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
  28. package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
  29. package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +12 -12
  30. package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
  31. package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
  32. package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +12 -12
  33. package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
  34. package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +12 -12
  35. package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
  36. package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
  37. package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
  38. package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
  39. package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
  40. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
  41. package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
  42. package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
  43. package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
  44. package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +12 -12
  45. package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +12 -12
  46. package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
  47. package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
  48. package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
  49. package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
  50. package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +12 -12
  51. package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +12 -12
  52. package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
  53. package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
  54. package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
  55. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
  56. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
  57. package/src/transformers/features/notations/NotationAssertGeneralTransformer.ts +15 -15
  58. package/src/transformers/features/notations/NotationCreateAssertGeneralTransformer.ts +15 -15
  59. package/src/transformers/features/notations/NotationCreateGeneralTransformer.ts +15 -15
  60. package/src/transformers/features/notations/NotationCreateIsGeneralTransformer.ts +15 -15
  61. package/src/transformers/features/notations/NotationCreateValidateGeneralTransformer.ts +17 -17
  62. package/src/transformers/features/notations/NotationGeneralTransformer.ts +11 -11
  63. package/src/transformers/features/notations/NotationIsGeneralTransformer.ts +15 -15
  64. package/src/transformers/features/notations/NotationValidateGeneralTransformer.ts +17 -17
  65. package/src/transformers/features/protobuf/ProtobufCreateAssertDecodeTransformer.ts +12 -12
  66. package/src/transformers/features/protobuf/ProtobufCreateAssertEncodeTransformer.ts +12 -12
  67. package/src/transformers/features/protobuf/ProtobufCreateDecodeTransformer.ts +9 -9
  68. package/src/transformers/features/protobuf/ProtobufCreateEncodeTransformer.ts +9 -9
  69. package/src/transformers/features/protobuf/ProtobufCreateIsDecodeTransformer.ts +12 -12
  70. package/src/transformers/features/protobuf/ProtobufCreateIsEncodeTransformer.ts +12 -12
  71. package/src/transformers/features/protobuf/ProtobufCreateValidateDecodeTransformer.ts +12 -12
  72. package/src/transformers/features/protobuf/ProtobufCreateValidateEncodeTransformer.ts +12 -12
  73. package/src/utils/NamingConvention.ts +91 -91
  74. package/src/utils/StringUtil.ts +4 -4
@@ -1,40 +1,40 @@
1
- export const $convention = (rename: (str: string) => string) => {
2
- const main = (input: any): any => {
3
- if (typeof input === "object")
4
- if (input === null) return null;
5
- else if (Array.isArray(input)) return input.map(main);
6
- else if (
7
- input instanceof Boolean ||
8
- input instanceof BigInt ||
9
- input instanceof Number ||
10
- input instanceof String
11
- )
12
- return input.valueOf();
13
- else if (input instanceof Date) return new Date(input);
14
- else if (
15
- input instanceof Uint8Array ||
16
- input instanceof Uint8ClampedArray ||
17
- input instanceof Uint16Array ||
18
- input instanceof Uint32Array ||
19
- input instanceof BigUint64Array ||
20
- input instanceof Int8Array ||
21
- input instanceof Int16Array ||
22
- input instanceof Int32Array ||
23
- input instanceof BigInt64Array ||
24
- input instanceof Float32Array ||
25
- input instanceof Float64Array ||
26
- input instanceof DataView
27
- )
28
- return input;
29
- else return object(input);
30
- return input;
31
- };
32
- const object = (input: Record<string, any>) =>
33
- Object.fromEntries(
34
- Object.entries(input).map(([key, value]) => [
35
- rename(key),
36
- main(value),
37
- ]),
38
- );
39
- return main;
40
- };
1
+ export const $convention = (rename: (str: string) => string) => {
2
+ const main = (input: any): any => {
3
+ if (typeof input === "object")
4
+ if (input === null) return null;
5
+ else if (Array.isArray(input)) return input.map(main);
6
+ else if (
7
+ input instanceof Boolean ||
8
+ input instanceof BigInt ||
9
+ input instanceof Number ||
10
+ input instanceof String
11
+ )
12
+ return input.valueOf();
13
+ else if (input instanceof Date) return new Date(input);
14
+ else if (
15
+ input instanceof Uint8Array ||
16
+ input instanceof Uint8ClampedArray ||
17
+ input instanceof Uint16Array ||
18
+ input instanceof Uint32Array ||
19
+ input instanceof BigUint64Array ||
20
+ input instanceof Int8Array ||
21
+ input instanceof Int16Array ||
22
+ input instanceof Int32Array ||
23
+ input instanceof BigInt64Array ||
24
+ input instanceof Float32Array ||
25
+ input instanceof Float64Array ||
26
+ input instanceof DataView
27
+ )
28
+ return input;
29
+ else return object(input);
30
+ return input;
31
+ };
32
+ const object = (input: Record<string, any>) =>
33
+ Object.fromEntries(
34
+ Object.entries(input).map(([key, value]) => [
35
+ rename(key),
36
+ main(value),
37
+ ]),
38
+ );
39
+ return main;
40
+ };
@@ -1,164 +1,164 @@
1
- import { NamingConvention } from "../utils/NamingConvention";
2
- import { RandomGenerator } from "../utils/RandomGenerator";
3
-
4
- import { IValidation } from "../IValidation";
5
- import { TypeGuardError } from "../TypeGuardError";
6
- import { $HeadersReader } from "./$HeadersReader";
7
- import { $ParameterReader } from "./$ParameterReader";
8
- import { $ProtobufReader } from "./$ProtobufReader";
9
- import { $ProtobufSizer } from "./$ProtobufSizer";
10
- import { $ProtobufWriter } from "./$ProtobufWriter";
11
- import { $QueryReader } from "./$QueryReader";
12
- import { $any } from "./$any";
13
- import { $convention } from "./$convention";
14
- import { $every } from "./$every";
15
- import { $guard } from "./$guard";
16
- import { $is_between } from "./$is_between";
17
- import { $join } from "./$join";
18
- import { $number } from "./$number";
19
- import { $report } from "./$report";
20
- import { $rest } from "./$rest";
21
- import { $string } from "./$string";
22
- import { $strlen } from "./$strlen";
23
- import { $tail } from "./$tail";
24
-
25
- /**
26
- * @internal
27
- */
28
- export namespace Namespace {
29
- export const is = () => ({
30
- is_between: $is_between,
31
- });
32
-
33
- export const assert = (method: string) => ({
34
- ...is(),
35
- join: $join,
36
- every: $every,
37
- guard: $guard(`typia.${method}`),
38
- predicate: (
39
- matched: boolean,
40
- exceptionable: boolean,
41
- closure: () => Omit<TypeGuardError.IProps, "method">,
42
- ): boolean => {
43
- if (matched === false && exceptionable === true)
44
- throw new TypeGuardError({
45
- ...closure(),
46
- method: `typia.${method}`,
47
- });
48
- return matched;
49
- },
50
- });
51
-
52
- export const validate = () => ({
53
- ...is(),
54
- join: $join,
55
- report: $report,
56
- predicate:
57
- (res: IValidation) =>
58
- (
59
- matched: boolean,
60
- exceptionable: boolean,
61
- closure: () => IValidation.IError,
62
- ) => {
63
- // CHECK FAILURE
64
- if (matched === false && exceptionable === true)
65
- (() => {
66
- res.success &&= false;
67
- const errorList = (res as IValidation.IFailure).errors;
68
-
69
- // TRACE ERROR
70
- const error = closure();
71
- if (errorList.length) {
72
- const last = errorList[errorList.length - 1]!.path;
73
- if (
74
- last.length >= error.path.length &&
75
- last.substring(0, error.path.length) ===
76
- error.path
77
- )
78
- return;
79
- }
80
- errorList.push(error);
81
- return;
82
- })();
83
- return matched;
84
- },
85
- });
86
-
87
- export namespace json {
88
- export const stringify = (method: string) => ({
89
- ...is(),
90
- number: $number,
91
- string: $string,
92
- tail: $tail,
93
- rest: $rest,
94
- throws: $throws(`json.${method}`),
95
- });
96
- }
97
-
98
- export namespace protobuf {
99
- export const decode = (method: string) => ({
100
- Reader: $ProtobufReader,
101
- throws: $throws(`protobuf.${method}`),
102
- });
103
-
104
- export const encode = (method: string) => ({
105
- Sizer: $ProtobufSizer,
106
- Writer: $ProtobufWriter,
107
- strlen: $strlen,
108
- throws: $throws(method),
109
- });
110
- }
111
-
112
- export namespace http {
113
- export const query = () => $QueryReader;
114
- export const headers = () => $HeadersReader;
115
- export const parameter = () => $ParameterReader;
116
- }
117
-
118
- export namespace misc {
119
- export const clone = (method: string) => ({
120
- ...is(),
121
- throws: $throws(`misc.${method}`),
122
- any: $any,
123
- });
124
-
125
- export const prune = (method: string) => ({
126
- ...is(),
127
- throws: $throws(`misc.${method}`),
128
- });
129
- }
130
-
131
- export namespace notations {
132
- export const camel = (method: string) => ({
133
- ...base(method),
134
- any: $convention(NamingConvention.camel),
135
- });
136
- export const pascal = (method: string) => ({
137
- ...base(method),
138
- any: $convention(NamingConvention.pascal),
139
- });
140
- export const snake = (method: string) => ({
141
- ...base(method),
142
- any: $convention(NamingConvention.snake),
143
- });
144
-
145
- const base = (method: string) => ({
146
- ...is(),
147
- throws: $throws(`notations.${method}`),
148
- });
149
- }
150
-
151
- export const random = () => ({
152
- generator: RandomGenerator,
153
- pick: RandomGenerator.pick,
154
- });
155
-
156
- const $throws =
157
- (method: string) =>
158
- (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
159
- throw new TypeGuardError({
160
- ...props,
161
- method: `typia.${method}`,
162
- });
163
- };
164
- }
1
+ import { NamingConvention } from "../utils/NamingConvention";
2
+ import { RandomGenerator } from "../utils/RandomGenerator";
3
+
4
+ import { IValidation } from "../IValidation";
5
+ import { TypeGuardError } from "../TypeGuardError";
6
+ import { $HeadersReader } from "./$HeadersReader";
7
+ import { $ParameterReader } from "./$ParameterReader";
8
+ import { $ProtobufReader } from "./$ProtobufReader";
9
+ import { $ProtobufSizer } from "./$ProtobufSizer";
10
+ import { $ProtobufWriter } from "./$ProtobufWriter";
11
+ import { $QueryReader } from "./$QueryReader";
12
+ import { $any } from "./$any";
13
+ import { $convention } from "./$convention";
14
+ import { $every } from "./$every";
15
+ import { $guard } from "./$guard";
16
+ import { $is_between } from "./$is_between";
17
+ import { $join } from "./$join";
18
+ import { $number } from "./$number";
19
+ import { $report } from "./$report";
20
+ import { $rest } from "./$rest";
21
+ import { $string } from "./$string";
22
+ import { $strlen } from "./$strlen";
23
+ import { $tail } from "./$tail";
24
+
25
+ /**
26
+ * @internal
27
+ */
28
+ export namespace Namespace {
29
+ export const is = () => ({
30
+ is_between: $is_between,
31
+ });
32
+
33
+ export const assert = (method: string) => ({
34
+ ...is(),
35
+ join: $join,
36
+ every: $every,
37
+ guard: $guard(`typia.${method}`),
38
+ predicate: (
39
+ matched: boolean,
40
+ exceptionable: boolean,
41
+ closure: () => Omit<TypeGuardError.IProps, "method">,
42
+ ): boolean => {
43
+ if (matched === false && exceptionable === true)
44
+ throw new TypeGuardError({
45
+ ...closure(),
46
+ method: `typia.${method}`,
47
+ });
48
+ return matched;
49
+ },
50
+ });
51
+
52
+ export const validate = () => ({
53
+ ...is(),
54
+ join: $join,
55
+ report: $report,
56
+ predicate:
57
+ (res: IValidation) =>
58
+ (
59
+ matched: boolean,
60
+ exceptionable: boolean,
61
+ closure: () => IValidation.IError,
62
+ ) => {
63
+ // CHECK FAILURE
64
+ if (matched === false && exceptionable === true)
65
+ (() => {
66
+ res.success &&= false;
67
+ const errorList = (res as IValidation.IFailure).errors;
68
+
69
+ // TRACE ERROR
70
+ const error = closure();
71
+ if (errorList.length) {
72
+ const last = errorList[errorList.length - 1]!.path;
73
+ if (
74
+ last.length >= error.path.length &&
75
+ last.substring(0, error.path.length) ===
76
+ error.path
77
+ )
78
+ return;
79
+ }
80
+ errorList.push(error);
81
+ return;
82
+ })();
83
+ return matched;
84
+ },
85
+ });
86
+
87
+ export namespace json {
88
+ export const stringify = (method: string) => ({
89
+ ...is(),
90
+ number: $number,
91
+ string: $string,
92
+ tail: $tail,
93
+ rest: $rest,
94
+ throws: $throws(`json.${method}`),
95
+ });
96
+ }
97
+
98
+ export namespace protobuf {
99
+ export const decode = (method: string) => ({
100
+ Reader: $ProtobufReader,
101
+ throws: $throws(`protobuf.${method}`),
102
+ });
103
+
104
+ export const encode = (method: string) => ({
105
+ Sizer: $ProtobufSizer,
106
+ Writer: $ProtobufWriter,
107
+ strlen: $strlen,
108
+ throws: $throws(method),
109
+ });
110
+ }
111
+
112
+ export namespace http {
113
+ export const query = () => $QueryReader;
114
+ export const headers = () => $HeadersReader;
115
+ export const parameter = () => $ParameterReader;
116
+ }
117
+
118
+ export namespace misc {
119
+ export const clone = (method: string) => ({
120
+ ...is(),
121
+ throws: $throws(`misc.${method}`),
122
+ any: $any,
123
+ });
124
+
125
+ export const prune = (method: string) => ({
126
+ ...is(),
127
+ throws: $throws(`misc.${method}`),
128
+ });
129
+ }
130
+
131
+ export namespace notations {
132
+ export const camel = (method: string) => ({
133
+ ...base(method),
134
+ any: $convention(NamingConvention.camel),
135
+ });
136
+ export const pascal = (method: string) => ({
137
+ ...base(method),
138
+ any: $convention(NamingConvention.pascal),
139
+ });
140
+ export const snake = (method: string) => ({
141
+ ...base(method),
142
+ any: $convention(NamingConvention.snake),
143
+ });
144
+
145
+ const base = (method: string) => ({
146
+ ...is(),
147
+ throws: $throws(`notations.${method}`),
148
+ });
149
+ }
150
+
151
+ export const random = () => ({
152
+ generator: RandomGenerator,
153
+ pick: RandomGenerator.pick,
154
+ });
155
+
156
+ const $throws =
157
+ (method: string) =>
158
+ (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
159
+ throw new TypeGuardError({
160
+ ...props,
161
+ method: `typia.${method}`,
162
+ });
163
+ };
164
+ }