typia 5.1.4 → 5.1.5-dev.20230929

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 (88) hide show
  1. package/lib/TypeGuardError.d.ts +2 -2
  2. package/lib/executable/TypiaGenerateWizard.js.map +1 -1
  3. package/lib/executable/TypiaSetupWizard.js +16 -7
  4. package/lib/executable/TypiaSetupWizard.js.map +1 -1
  5. package/lib/factories/internal/metadata/emplace_metadata_object.js +25 -6
  6. package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
  7. package/lib/programmers/CheckerProgrammer.d.ts +3 -3
  8. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  9. package/lib/programmers/FeatureProgrammer.d.ts +11 -11
  10. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  11. package/lib/schemas/json/IJsonComponents.d.ts +12 -12
  12. package/lib/schemas/json/IJsonSchema.d.ts +32 -32
  13. package/lib/schemas/metadata/IMetadataObject.d.ts +1 -1
  14. package/lib/transformers/ITransformOptions.d.ts +4 -4
  15. package/package.json +1 -1
  16. package/src/TypeGuardError.ts +2 -2
  17. package/src/executable/TypiaGenerateWizard.ts +2 -2
  18. package/src/executable/TypiaSetupWizard.ts +7 -3
  19. package/src/factories/MetadataCollection.ts +277 -277
  20. package/src/factories/MetadataFactory.ts +238 -238
  21. package/src/factories/MetadataTypeTagFactory.ts +325 -325
  22. package/src/factories/internal/metadata/emend_metadata_atomics.ts +41 -41
  23. package/src/factories/internal/metadata/emplace_metadata_object.ts +30 -8
  24. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +259 -259
  25. package/src/functional/$HeadersReader.ts +28 -28
  26. package/src/functional/$ParameterReader.ts +31 -31
  27. package/src/functional/$QueryReader.ts +56 -56
  28. package/src/functional/Namespace.ts +142 -142
  29. package/src/http.ts +1149 -1149
  30. package/src/json.ts +648 -648
  31. package/src/misc.ts +651 -651
  32. package/src/module.ts +657 -657
  33. package/src/programmers/CheckerProgrammer.ts +11 -9
  34. package/src/programmers/FeatureProgrammer.ts +25 -17
  35. package/src/programmers/helpers/HttpMetadataUtil.ts +21 -21
  36. package/src/programmers/helpers/RandomRanger.ts +1 -1
  37. package/src/programmers/http/HttpAssertHeadersProgrammer.ts +77 -77
  38. package/src/programmers/http/HttpAssertQueryProgrammer.ts +77 -77
  39. package/src/programmers/http/HttpHeadersProgrammer.ts +339 -339
  40. package/src/programmers/http/HttpIsHeadersProgrammer.ts +87 -87
  41. package/src/programmers/http/HttpIsQueryProgrammer.ts +87 -87
  42. package/src/programmers/http/HttpParameterProgrammer.ts +104 -104
  43. package/src/programmers/http/HttpQueryProgrammer.ts +273 -273
  44. package/src/programmers/http/HttpValidateHeadersProgrammer.ts +77 -77
  45. package/src/programmers/http/HttpValidateQueryProgrammer.ts +77 -77
  46. package/src/programmers/internal/application_boolean.ts +30 -30
  47. package/src/programmers/internal/application_number.ts +90 -90
  48. package/src/programmers/internal/application_object.ts +1 -1
  49. package/src/programmers/internal/application_schema.ts +180 -180
  50. package/src/programmers/internal/application_string.ts +54 -54
  51. package/src/programmers/internal/check_array_length.ts +44 -44
  52. package/src/programmers/internal/check_bigint.ts +48 -48
  53. package/src/programmers/internal/check_number.ts +108 -108
  54. package/src/programmers/internal/check_object.ts +2 -2
  55. package/src/programmers/internal/check_string.ts +48 -48
  56. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +882 -882
  57. package/src/protobuf.ts +887 -887
  58. package/src/schemas/json/IJsonComponents.ts +36 -34
  59. package/src/schemas/json/IJsonSchema.ts +112 -112
  60. package/src/schemas/metadata/IMetadataConstant.ts +25 -25
  61. package/src/schemas/metadata/IMetadataObject.ts +1 -1
  62. package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
  63. package/src/schemas/metadata/Metadata.ts +686 -686
  64. package/src/tags/Default.ts +15 -15
  65. package/src/tags/Format.ts +30 -30
  66. package/src/tags/Pattern.ts +9 -9
  67. package/src/tags/TagBase.ts +68 -68
  68. package/src/tags/index.ts +14 -14
  69. package/src/transformers/CallExpressionTransformer.ts +289 -289
  70. package/src/transformers/ITransformOptions.ts +4 -4
  71. package/src/transformers/features/http/CreateHttpAssertHeadersTransformer.ts +12 -12
  72. package/src/transformers/features/http/CreateHttpAssertQueryTransformer.ts +12 -12
  73. package/src/transformers/features/http/CreateHttpHeadersTransformer.ts +9 -9
  74. package/src/transformers/features/http/CreateHttpIsHeadersTransformer.ts +9 -9
  75. package/src/transformers/features/http/CreateHttpIsQueryTransformer.ts +9 -9
  76. package/src/transformers/features/http/CreateHttpParameterTransformer.ts +9 -9
  77. package/src/transformers/features/http/CreateHttpQueryTransformer.ts +9 -9
  78. package/src/transformers/features/http/CreateHttpValidateHeadersTransformer.ts +12 -12
  79. package/src/transformers/features/http/CreateHttpValidateQueryTransformer.ts +12 -12
  80. package/src/transformers/features/http/HttpAssertHeadersTransformer.ts +10 -10
  81. package/src/transformers/features/http/HttpAssertQueryTransformer.ts +10 -10
  82. package/src/transformers/features/http/HttpHeadersTransformer.ts +9 -9
  83. package/src/transformers/features/http/HttpIsHeadersTransformer.ts +9 -9
  84. package/src/transformers/features/http/HttpIsQueryTransformer.ts +9 -9
  85. package/src/transformers/features/http/HttpParameterTransformer.ts +9 -9
  86. package/src/transformers/features/http/HttpQueryTransformer.ts +9 -9
  87. package/src/transformers/features/http/HttpValidateHeadersTransformer.ts +10 -10
  88. package/src/transformers/features/http/HttpValidateQueryTransformer.ts +10 -10
@@ -1,28 +1,28 @@
1
- export namespace $HeadersReader {
2
- export const boolean = (value: string | undefined) =>
3
- value !== undefined
4
- ? value === "true"
5
- ? true
6
- : value === "false"
7
- ? false
8
- : value
9
- : undefined;
10
- export const bigint = (value: string | undefined) =>
11
- value !== undefined ? toBigint(value) : undefined;
12
- export const number = (value: string | undefined) =>
13
- value !== undefined ? toNumber(value) : undefined;
14
- export const string = (value: string | undefined) => value;
15
- }
16
-
17
- const toNumber = (str: string): number | string => {
18
- const value: number = Number(str);
19
- return isNaN(value) ? str : value;
20
- };
21
-
22
- const toBigint = (str: string): bigint | string => {
23
- try {
24
- return BigInt(str);
25
- } catch {
26
- return str;
27
- }
28
- };
1
+ export namespace $HeadersReader {
2
+ export const boolean = (value: string | undefined) =>
3
+ value !== undefined
4
+ ? value === "true"
5
+ ? true
6
+ : value === "false"
7
+ ? false
8
+ : value
9
+ : undefined;
10
+ export const bigint = (value: string | undefined) =>
11
+ value !== undefined ? toBigint(value) : undefined;
12
+ export const number = (value: string | undefined) =>
13
+ value !== undefined ? toNumber(value) : undefined;
14
+ export const string = (value: string | undefined) => value;
15
+ }
16
+
17
+ const toNumber = (str: string): number | string => {
18
+ const value: number = Number(str);
19
+ return isNaN(value) ? str : value;
20
+ };
21
+
22
+ const toBigint = (str: string): bigint | string => {
23
+ try {
24
+ return BigInt(str);
25
+ } catch {
26
+ return str;
27
+ }
28
+ };
@@ -1,31 +1,31 @@
1
- export namespace $ParameterReader {
2
- export const boolean = (value: string) =>
3
- value !== "null"
4
- ? value === "true" || value === "1"
5
- ? true
6
- : value === "false" || value === "0"
7
- ? false
8
- : value
9
- : null;
10
-
11
- export const bigint = (value: string) =>
12
- value !== "null" ? toBigint(value) : null;
13
-
14
- export const number = (value: string) =>
15
- value !== "null" ? toNumber(value) : null;
16
-
17
- export const string = (value: string) => (value !== "null" ? value : null);
18
- }
19
-
20
- const toNumber = (str: string): number | string => {
21
- const value: number = Number(str);
22
- return isNaN(value) ? str : value;
23
- };
24
-
25
- const toBigint = (str: string): bigint | string => {
26
- try {
27
- return BigInt(str);
28
- } catch {
29
- return str;
30
- }
31
- };
1
+ export namespace $ParameterReader {
2
+ export const boolean = (value: string) =>
3
+ value !== "null"
4
+ ? value === "true" || value === "1"
5
+ ? true
6
+ : value === "false" || value === "0"
7
+ ? false
8
+ : value
9
+ : null;
10
+
11
+ export const bigint = (value: string) =>
12
+ value !== "null" ? toBigint(value) : null;
13
+
14
+ export const number = (value: string) =>
15
+ value !== "null" ? toNumber(value) : null;
16
+
17
+ export const string = (value: string) => (value !== "null" ? value : null);
18
+ }
19
+
20
+ const toNumber = (str: string): number | string => {
21
+ const value: number = Number(str);
22
+ return isNaN(value) ? str : value;
23
+ };
24
+
25
+ const toBigint = (str: string): bigint | string => {
26
+ try {
27
+ return BigInt(str);
28
+ } catch {
29
+ return str;
30
+ }
31
+ };
@@ -1,56 +1,56 @@
1
- export namespace $QueryReader {
2
- export const boolean = (str: string | null): boolean | null | undefined =>
3
- str === null
4
- ? undefined
5
- : str === "null"
6
- ? null
7
- : str.length === 0
8
- ? true
9
- : str === "true" || str === "1"
10
- ? true
11
- : str === "false" || str === "0"
12
- ? false
13
- : (str as any); // wrong type
14
-
15
- export const number = (str: string | null): number | null | undefined =>
16
- !!str?.length
17
- ? str === "null"
18
- ? null
19
- : (toNumber(str) as any)
20
- : undefined;
21
-
22
- export const bigint = (str: string | null): bigint | null | undefined =>
23
- !!str?.length
24
- ? str === "null"
25
- ? null
26
- : (toBigint(str) as any)
27
- : undefined;
28
-
29
- export const string = (str: string | null): string | null | undefined =>
30
- str === null ? undefined : str === "null" ? null : str;
31
-
32
- export const params = (input: string | URLSearchParams) => {
33
- if (typeof input === "string") {
34
- const index: number = input.indexOf("?");
35
- input = index === -1 ? "" : input.substring(index + 1);
36
- return new URLSearchParams(input);
37
- }
38
- return input;
39
- };
40
-
41
- export const array = (input: any[], alternative: null | undefined) =>
42
- input.length ? input : alternative;
43
- }
44
-
45
- const toNumber = (str: string): number | string => {
46
- const value: number = Number(str);
47
- return isNaN(value) ? str : value;
48
- };
49
-
50
- const toBigint = (str: string): bigint | string => {
51
- try {
52
- return BigInt(str);
53
- } catch {
54
- return str;
55
- }
56
- };
1
+ export namespace $QueryReader {
2
+ export const boolean = (str: string | null): boolean | null | undefined =>
3
+ str === null
4
+ ? undefined
5
+ : str === "null"
6
+ ? null
7
+ : str.length === 0
8
+ ? true
9
+ : str === "true" || str === "1"
10
+ ? true
11
+ : str === "false" || str === "0"
12
+ ? false
13
+ : (str as any); // wrong type
14
+
15
+ export const number = (str: string | null): number | null | undefined =>
16
+ !!str?.length
17
+ ? str === "null"
18
+ ? null
19
+ : (toNumber(str) as any)
20
+ : undefined;
21
+
22
+ export const bigint = (str: string | null): bigint | null | undefined =>
23
+ !!str?.length
24
+ ? str === "null"
25
+ ? null
26
+ : (toBigint(str) as any)
27
+ : undefined;
28
+
29
+ export const string = (str: string | null): string | null | undefined =>
30
+ str === null ? undefined : str === "null" ? null : str;
31
+
32
+ export const params = (input: string | URLSearchParams) => {
33
+ if (typeof input === "string") {
34
+ const index: number = input.indexOf("?");
35
+ input = index === -1 ? "" : input.substring(index + 1);
36
+ return new URLSearchParams(input);
37
+ }
38
+ return input;
39
+ };
40
+
41
+ export const array = (input: any[], alternative: null | undefined) =>
42
+ input.length ? input : alternative;
43
+ }
44
+
45
+ const toNumber = (str: string): number | string => {
46
+ const value: number = Number(str);
47
+ return isNaN(value) ? str : value;
48
+ };
49
+
50
+ const toBigint = (str: string): bigint | string => {
51
+ try {
52
+ return BigInt(str);
53
+ } catch {
54
+ return str;
55
+ }
56
+ };
@@ -1,142 +1,142 @@
1
- import { RandomGenerator } from "../utils/RandomGenerator";
2
-
3
- import { IValidation } from "../IValidation";
4
- import { TypeGuardError } from "../TypeGuardError";
5
- import { $HeadersReader } from "./$HeadersReader";
6
- import { $ParameterReader } from "./$ParameterReader";
7
- import { $ProtobufReader } from "./$ProtobufReader";
8
- import { $ProtobufSizer } from "./$ProtobufSizer";
9
- import { $ProtobufWriter } from "./$ProtobufWriter";
10
- import { $QueryReader } from "./$QueryReader";
11
- import { $any } from "./$any";
12
- import { $every } from "./$every";
13
- import { $guard } from "./$guard";
14
- import { $is_between } from "./$is_between";
15
- import { $join } from "./$join";
16
- import { $number } from "./$number";
17
- import { $report } from "./$report";
18
- import { $rest } from "./$rest";
19
- import { $string } from "./$string";
20
- import { $strlen } from "./$strlen";
21
- import { $tail } from "./$tail";
22
-
23
- /**
24
- * @internal
25
- */
26
- export namespace Namespace {
27
- export const is = () => ({
28
- is_between: $is_between,
29
- });
30
-
31
- export const assert = (method: string) => ({
32
- ...is(),
33
- join: $join,
34
- every: $every,
35
- guard: $guard(`typia.${method}`),
36
- predicate: (
37
- matched: boolean,
38
- exceptionable: boolean,
39
- closure: () => Omit<TypeGuardError.IProps, "method">,
40
- ): boolean => {
41
- if (matched === false && exceptionable === true)
42
- throw new TypeGuardError({
43
- ...closure(),
44
- method: `typia.${method}`,
45
- });
46
- return matched;
47
- },
48
- });
49
-
50
- export const validate = () => ({
51
- ...is(),
52
- join: $join,
53
- report: $report,
54
- predicate:
55
- (res: IValidation) =>
56
- (
57
- matched: boolean,
58
- exceptionable: boolean,
59
- closure: () => IValidation.IError,
60
- ) => {
61
- // CHECK FAILURE
62
- if (matched === false && exceptionable === true)
63
- (() => {
64
- res.success &&= false;
65
- const errorList = (res as IValidation.IFailure).errors;
66
-
67
- // TRACE ERROR
68
- const error = closure();
69
- if (errorList.length) {
70
- const last = errorList[errorList.length - 1]!.path;
71
- if (
72
- last.length >= error.path.length &&
73
- last.substring(0, error.path.length) ===
74
- error.path
75
- )
76
- return;
77
- }
78
- errorList.push(error);
79
- return;
80
- })();
81
- return matched;
82
- },
83
- });
84
-
85
- export namespace json {
86
- export const stringify = (method: string) => ({
87
- ...is(),
88
- number: $number,
89
- string: $string,
90
- tail: $tail,
91
- rest: $rest,
92
- throws: $throws(`json.${method}`),
93
- });
94
- }
95
-
96
- export namespace protobuf {
97
- export const decode = (method: string) => ({
98
- Reader: $ProtobufReader,
99
- throws: $throws(`protobuf.${method}`),
100
- });
101
-
102
- export const encode = (method: string) => ({
103
- Sizer: $ProtobufSizer,
104
- Writer: $ProtobufWriter,
105
- strlen: $strlen,
106
- throws: $throws(method),
107
- });
108
- }
109
-
110
- export namespace http {
111
- export const query = () => $QueryReader;
112
- export const headers = () => $HeadersReader;
113
- export const parameter = () => $ParameterReader;
114
- }
115
-
116
- export namespace misc {
117
- export const clone = (method: string) => ({
118
- ...is(),
119
- throws: $throws(`misc.${method}`),
120
- any: $any,
121
- });
122
-
123
- export const prune = (method: string) => ({
124
- ...is(),
125
- throws: $throws(`misc.${method}`),
126
- });
127
- }
128
-
129
- export const random = () => ({
130
- generator: RandomGenerator,
131
- pick: RandomGenerator.pick,
132
- });
133
-
134
- const $throws =
135
- (method: string) =>
136
- (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
137
- throw new TypeGuardError({
138
- ...props,
139
- method: `typia.${method}`,
140
- });
141
- };
142
- }
1
+ import { RandomGenerator } from "../utils/RandomGenerator";
2
+
3
+ import { IValidation } from "../IValidation";
4
+ import { TypeGuardError } from "../TypeGuardError";
5
+ import { $HeadersReader } from "./$HeadersReader";
6
+ import { $ParameterReader } from "./$ParameterReader";
7
+ import { $ProtobufReader } from "./$ProtobufReader";
8
+ import { $ProtobufSizer } from "./$ProtobufSizer";
9
+ import { $ProtobufWriter } from "./$ProtobufWriter";
10
+ import { $QueryReader } from "./$QueryReader";
11
+ import { $any } from "./$any";
12
+ import { $every } from "./$every";
13
+ import { $guard } from "./$guard";
14
+ import { $is_between } from "./$is_between";
15
+ import { $join } from "./$join";
16
+ import { $number } from "./$number";
17
+ import { $report } from "./$report";
18
+ import { $rest } from "./$rest";
19
+ import { $string } from "./$string";
20
+ import { $strlen } from "./$strlen";
21
+ import { $tail } from "./$tail";
22
+
23
+ /**
24
+ * @internal
25
+ */
26
+ export namespace Namespace {
27
+ export const is = () => ({
28
+ is_between: $is_between,
29
+ });
30
+
31
+ export const assert = (method: string) => ({
32
+ ...is(),
33
+ join: $join,
34
+ every: $every,
35
+ guard: $guard(`typia.${method}`),
36
+ predicate: (
37
+ matched: boolean,
38
+ exceptionable: boolean,
39
+ closure: () => Omit<TypeGuardError.IProps, "method">,
40
+ ): boolean => {
41
+ if (matched === false && exceptionable === true)
42
+ throw new TypeGuardError({
43
+ ...closure(),
44
+ method: `typia.${method}`,
45
+ });
46
+ return matched;
47
+ },
48
+ });
49
+
50
+ export const validate = () => ({
51
+ ...is(),
52
+ join: $join,
53
+ report: $report,
54
+ predicate:
55
+ (res: IValidation) =>
56
+ (
57
+ matched: boolean,
58
+ exceptionable: boolean,
59
+ closure: () => IValidation.IError,
60
+ ) => {
61
+ // CHECK FAILURE
62
+ if (matched === false && exceptionable === true)
63
+ (() => {
64
+ res.success &&= false;
65
+ const errorList = (res as IValidation.IFailure).errors;
66
+
67
+ // TRACE ERROR
68
+ const error = closure();
69
+ if (errorList.length) {
70
+ const last = errorList[errorList.length - 1]!.path;
71
+ if (
72
+ last.length >= error.path.length &&
73
+ last.substring(0, error.path.length) ===
74
+ error.path
75
+ )
76
+ return;
77
+ }
78
+ errorList.push(error);
79
+ return;
80
+ })();
81
+ return matched;
82
+ },
83
+ });
84
+
85
+ export namespace json {
86
+ export const stringify = (method: string) => ({
87
+ ...is(),
88
+ number: $number,
89
+ string: $string,
90
+ tail: $tail,
91
+ rest: $rest,
92
+ throws: $throws(`json.${method}`),
93
+ });
94
+ }
95
+
96
+ export namespace protobuf {
97
+ export const decode = (method: string) => ({
98
+ Reader: $ProtobufReader,
99
+ throws: $throws(`protobuf.${method}`),
100
+ });
101
+
102
+ export const encode = (method: string) => ({
103
+ Sizer: $ProtobufSizer,
104
+ Writer: $ProtobufWriter,
105
+ strlen: $strlen,
106
+ throws: $throws(method),
107
+ });
108
+ }
109
+
110
+ export namespace http {
111
+ export const query = () => $QueryReader;
112
+ export const headers = () => $HeadersReader;
113
+ export const parameter = () => $ParameterReader;
114
+ }
115
+
116
+ export namespace misc {
117
+ export const clone = (method: string) => ({
118
+ ...is(),
119
+ throws: $throws(`misc.${method}`),
120
+ any: $any,
121
+ });
122
+
123
+ export const prune = (method: string) => ({
124
+ ...is(),
125
+ throws: $throws(`misc.${method}`),
126
+ });
127
+ }
128
+
129
+ export const random = () => ({
130
+ generator: RandomGenerator,
131
+ pick: RandomGenerator.pick,
132
+ });
133
+
134
+ const $throws =
135
+ (method: string) =>
136
+ (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
137
+ throw new TypeGuardError({
138
+ ...props,
139
+ method: `typia.${method}`,
140
+ });
141
+ };
142
+ }