typia 5.2.4 → 5.2.5

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