typia 5.1.4 → 5.1.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 (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
@@ -67,22 +67,24 @@ export namespace CheckerProgrammer {
67
67
  entries: IExpressionEntry[],
68
68
  ): ts.Expression;
69
69
  array(input: ts.Expression, arrow: ts.ArrowFunction): ts.Expression;
70
- tuple?(exprs: ts.Expression[]): ts.Expression;
70
+ tuple?: undefined | ((exprs: ts.Expression[]) => ts.Expression);
71
71
 
72
72
  failure(
73
73
  value: ts.Expression,
74
74
  expected: string,
75
- explore?: FeatureProgrammer.IExplore,
75
+ explore?: undefined | FeatureProgrammer.IExplore,
76
76
  ): ts.Expression;
77
77
  is?(expression: ts.Expression): ts.Expression;
78
78
  required?(exp: ts.Expression): ts.Expression;
79
- full?: (
80
- condition: ts.Expression,
81
- ) => (
82
- input: ts.Expression,
83
- expected: string,
84
- explore: IExplore,
85
- ) => ts.Expression;
79
+ full?:
80
+ | undefined
81
+ | ((
82
+ condition: ts.Expression,
83
+ ) => (
84
+ input: ts.Expression,
85
+ expected: string,
86
+ explore: IExplore,
87
+ ) => ts.Expression);
86
88
  }
87
89
  }
88
90
  export type IExplore = FeatureProgrammer.IExplore;
@@ -40,7 +40,9 @@ export namespace FeatureProgrammer {
40
40
  */
41
41
  trace: boolean;
42
42
 
43
- addition?(collection: MetadataCollection): ts.Statement[];
43
+ addition?:
44
+ | undefined
45
+ | ((collection: MetadataCollection) => ts.Statement[]);
44
46
 
45
47
  /**
46
48
  * Initializer of metadata.
@@ -68,8 +70,8 @@ export namespace FeatureProgrammer {
68
70
  }
69
71
  export namespace IConfig {
70
72
  export interface ITypes {
71
- input: (type: ts.Type, name?: string) => ts.TypeNode;
72
- output: (type: ts.Type, name?: string) => ts.TypeNode;
73
+ input: (type: ts.Type, name?: undefined | string) => ts.TypeNode;
74
+ output: (type: ts.Type, name?: undefined | string) => ts.TypeNode;
73
75
  }
74
76
 
75
77
  export interface IObjector<
@@ -113,7 +115,7 @@ export namespace FeatureProgrammer {
113
115
  failure(
114
116
  value: ts.Expression,
115
117
  expected: string,
116
- explore?: IExplore,
118
+ explore?: undefined | IExplore,
117
119
  ): ts.Statement;
118
120
 
119
121
  /**
@@ -129,7 +131,7 @@ export namespace FeatureProgrammer {
129
131
  * @returns Transformed expression
130
132
  * @deprecated
131
133
  */
132
- is?(exp: ts.Expression): ts.Expression;
134
+ is?: undefined | ((exp: ts.Expression) => ts.Expression);
133
135
 
134
136
  /**
135
137
  * Transformer of non-undefined type checking by discrimination.
@@ -146,7 +148,7 @@ export namespace FeatureProgrammer {
146
148
  * @returns Transformed expression
147
149
  * @deprecated
148
150
  */
149
- required?(exp: ts.Expression): ts.Expression;
151
+ required?: undefined | ((exp: ts.Expression) => ts.Expression);
150
152
 
151
153
  /**
152
154
  * Conditon wrapper when unable to specify any object type.
@@ -158,22 +160,28 @@ export namespace FeatureProgrammer {
158
160
  * @param condition Current condition
159
161
  * @returns A function wrapped current condition
160
162
  */
161
- full?: (
162
- condition: ts.Expression,
163
- ) => (
164
- input: ts.Expression,
165
- expected: string,
166
- explore: IExplore,
167
- ) => ts.Expression;
163
+ full?:
164
+ | undefined
165
+ | ((
166
+ condition: ts.Expression,
167
+ ) => (
168
+ input: ts.Expression,
169
+ expected: string,
170
+ explore: IExplore,
171
+ ) => ts.Expression);
168
172
 
169
173
  /**
170
174
  * Return type.
171
175
  */
172
- type?: ts.TypeNode;
176
+ type?: undefined | ts.TypeNode;
173
177
  }
174
178
  export interface IGenerator {
175
- objects?(): (col: MetadataCollection) => ts.VariableStatement[];
176
- unions?(): (col: MetadataCollection) => ts.VariableStatement[];
179
+ objects?:
180
+ | undefined
181
+ | (() => (col: MetadataCollection) => ts.VariableStatement[]);
182
+ unions?:
183
+ | undefined
184
+ | (() => (col: MetadataCollection) => ts.VariableStatement[]);
177
185
  arrays(): (col: MetadataCollection) => ts.VariableStatement[];
178
186
  tuples(): (col: MetadataCollection) => ts.VariableStatement[];
179
187
  }
@@ -184,7 +192,7 @@ export namespace FeatureProgrammer {
184
192
  source: "top" | "function";
185
193
  from: "top" | "array" | "object";
186
194
  postfix: string;
187
- start?: number;
195
+ start?: undefined | number;
188
196
  }
189
197
 
190
198
  export interface Decoder<
@@ -1,21 +1,21 @@
1
- import { Metadata } from "../../schemas/metadata/Metadata";
2
-
3
- export namespace HttpMetadataUtil {
4
- export const atomics = (
5
- meta: Metadata,
6
- ): Set<"boolean" | "bigint" | "number" | "string"> =>
7
- new Set([
8
- ...meta.atomics.map((a) => a.type),
9
- ...meta.constants.map((c) => c.type),
10
- ...(meta.templates.length ? (["string"] as const) : []),
11
- ]);
12
-
13
- export const isUnion = (meta: Metadata): boolean =>
14
- atomics(meta).size +
15
- meta.arrays.length +
16
- meta.tuples.length +
17
- meta.natives.length +
18
- meta.maps.length +
19
- meta.objects.length >
20
- 1;
21
- }
1
+ import { Metadata } from "../../schemas/metadata/Metadata";
2
+
3
+ export namespace HttpMetadataUtil {
4
+ export const atomics = (
5
+ meta: Metadata,
6
+ ): Set<"boolean" | "bigint" | "number" | "string"> =>
7
+ new Set([
8
+ ...meta.atomics.map((a) => a.type),
9
+ ...meta.constants.map((c) => c.type),
10
+ ...(meta.templates.length ? (["string"] as const) : []),
11
+ ]);
12
+
13
+ export const isUnion = (meta: Metadata): boolean =>
14
+ atomics(meta).size +
15
+ meta.arrays.length +
16
+ meta.tuples.length +
17
+ meta.natives.length +
18
+ meta.maps.length +
19
+ meta.objects.length >
20
+ 1;
21
+ }
@@ -168,6 +168,6 @@ interface IRange {
168
168
  maximum: IScalar;
169
169
  }
170
170
  interface IScalar {
171
- value?: number;
171
+ value?: undefined | number;
172
172
  exclusive: boolean;
173
173
  }
@@ -1,77 +1,77 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
- import { StatementFactory } from "../../factories/StatementFactory";
5
- import { TypeFactory } from "../../factories/TypeFactory";
6
-
7
- import { IProject } from "../../transformers/IProject";
8
-
9
- import { AssertProgrammer } from "../AssertProgrammer";
10
- import { HttpHeadersProgrammer } from "./HttpHeadersProgrammer";
11
-
12
- export namespace HttpAssertHeadersProgrammer {
13
- export const write =
14
- (project: IProject) =>
15
- (modulo: ts.LeftHandSideExpression) =>
16
- (type: ts.Type, name?: string): ts.ArrowFunction =>
17
- ts.factory.createArrowFunction(
18
- undefined,
19
- undefined,
20
- [
21
- IdentifierFactory.parameter(
22
- "input",
23
- ts.factory.createTypeReferenceNode(
24
- HttpHeadersProgrammer.INPUT_TYPE,
25
- ),
26
- ),
27
- ],
28
- ts.factory.createTypeReferenceNode(
29
- `typia.Resolved<${
30
- name ?? TypeFactory.getFullName(project.checker)(type)
31
- }>`,
32
- ),
33
- undefined,
34
- ts.factory.createBlock([
35
- StatementFactory.constant(
36
- "decode",
37
- HttpHeadersProgrammer.write({
38
- ...project,
39
- options: {
40
- ...project.options,
41
- functional: false,
42
- numeric: false,
43
- },
44
- })(modulo)(type, name),
45
- ),
46
- StatementFactory.constant(
47
- "assert",
48
- AssertProgrammer.write({
49
- ...project,
50
- options: {
51
- ...project.options,
52
- functional: false,
53
- numeric: false,
54
- },
55
- })(modulo)(false)(type, name),
56
- ),
57
- StatementFactory.constant(
58
- "output",
59
- ts.factory.createCallExpression(
60
- ts.factory.createIdentifier("decode"),
61
- undefined,
62
- [ts.factory.createIdentifier("input")],
63
- ),
64
- ),
65
- ts.factory.createReturnStatement(
66
- ts.factory.createAsExpression(
67
- ts.factory.createCallExpression(
68
- ts.factory.createIdentifier("assert"),
69
- undefined,
70
- [ts.factory.createIdentifier("output")],
71
- ),
72
- TypeFactory.keyword("any"),
73
- ),
74
- ),
75
- ]),
76
- );
77
- }
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../../factories/StatementFactory";
5
+ import { TypeFactory } from "../../factories/TypeFactory";
6
+
7
+ import { IProject } from "../../transformers/IProject";
8
+
9
+ import { AssertProgrammer } from "../AssertProgrammer";
10
+ import { HttpHeadersProgrammer } from "./HttpHeadersProgrammer";
11
+
12
+ export namespace HttpAssertHeadersProgrammer {
13
+ export const write =
14
+ (project: IProject) =>
15
+ (modulo: ts.LeftHandSideExpression) =>
16
+ (type: ts.Type, name?: string): ts.ArrowFunction =>
17
+ ts.factory.createArrowFunction(
18
+ undefined,
19
+ undefined,
20
+ [
21
+ IdentifierFactory.parameter(
22
+ "input",
23
+ ts.factory.createTypeReferenceNode(
24
+ HttpHeadersProgrammer.INPUT_TYPE,
25
+ ),
26
+ ),
27
+ ],
28
+ ts.factory.createTypeReferenceNode(
29
+ `typia.Resolved<${
30
+ name ?? TypeFactory.getFullName(project.checker)(type)
31
+ }>`,
32
+ ),
33
+ undefined,
34
+ ts.factory.createBlock([
35
+ StatementFactory.constant(
36
+ "decode",
37
+ HttpHeadersProgrammer.write({
38
+ ...project,
39
+ options: {
40
+ ...project.options,
41
+ functional: false,
42
+ numeric: false,
43
+ },
44
+ })(modulo)(type, name),
45
+ ),
46
+ StatementFactory.constant(
47
+ "assert",
48
+ AssertProgrammer.write({
49
+ ...project,
50
+ options: {
51
+ ...project.options,
52
+ functional: false,
53
+ numeric: false,
54
+ },
55
+ })(modulo)(false)(type, name),
56
+ ),
57
+ StatementFactory.constant(
58
+ "output",
59
+ ts.factory.createCallExpression(
60
+ ts.factory.createIdentifier("decode"),
61
+ undefined,
62
+ [ts.factory.createIdentifier("input")],
63
+ ),
64
+ ),
65
+ ts.factory.createReturnStatement(
66
+ ts.factory.createAsExpression(
67
+ ts.factory.createCallExpression(
68
+ ts.factory.createIdentifier("assert"),
69
+ undefined,
70
+ [ts.factory.createIdentifier("output")],
71
+ ),
72
+ TypeFactory.keyword("any"),
73
+ ),
74
+ ),
75
+ ]),
76
+ );
77
+ }
@@ -1,77 +1,77 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
- import { StatementFactory } from "../../factories/StatementFactory";
5
- import { TypeFactory } from "../../factories/TypeFactory";
6
-
7
- import { IProject } from "../../transformers/IProject";
8
-
9
- import { AssertProgrammer } from "../AssertProgrammer";
10
- import { HttpQueryProgrammer } from "./HttpQueryProgrammer";
11
-
12
- export namespace HttpAssertQueryProgrammer {
13
- export const write =
14
- (project: IProject) =>
15
- (modulo: ts.LeftHandSideExpression) =>
16
- (type: ts.Type, name?: string): ts.ArrowFunction =>
17
- ts.factory.createArrowFunction(
18
- undefined,
19
- undefined,
20
- [
21
- IdentifierFactory.parameter(
22
- "input",
23
- ts.factory.createTypeReferenceNode(
24
- HttpQueryProgrammer.INPUT_TYPE,
25
- ),
26
- ),
27
- ],
28
- ts.factory.createTypeReferenceNode(
29
- `typia.Resolved<${
30
- name ?? TypeFactory.getFullName(project.checker)(type)
31
- }>`,
32
- ),
33
- undefined,
34
- ts.factory.createBlock([
35
- StatementFactory.constant(
36
- "decode",
37
- HttpQueryProgrammer.write({
38
- ...project,
39
- options: {
40
- ...project.options,
41
- functional: false,
42
- numeric: false,
43
- },
44
- })(modulo)(type, name),
45
- ),
46
- StatementFactory.constant(
47
- "assert",
48
- AssertProgrammer.write({
49
- ...project,
50
- options: {
51
- ...project.options,
52
- functional: false,
53
- numeric: false,
54
- },
55
- })(modulo)(false)(type, name),
56
- ),
57
- StatementFactory.constant(
58
- "output",
59
- ts.factory.createCallExpression(
60
- ts.factory.createIdentifier("decode"),
61
- undefined,
62
- [ts.factory.createIdentifier("input")],
63
- ),
64
- ),
65
- ts.factory.createReturnStatement(
66
- ts.factory.createAsExpression(
67
- ts.factory.createCallExpression(
68
- ts.factory.createIdentifier("assert"),
69
- undefined,
70
- [ts.factory.createIdentifier("output")],
71
- ),
72
- TypeFactory.keyword("any"),
73
- ),
74
- ),
75
- ]),
76
- );
77
- }
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../../factories/StatementFactory";
5
+ import { TypeFactory } from "../../factories/TypeFactory";
6
+
7
+ import { IProject } from "../../transformers/IProject";
8
+
9
+ import { AssertProgrammer } from "../AssertProgrammer";
10
+ import { HttpQueryProgrammer } from "./HttpQueryProgrammer";
11
+
12
+ export namespace HttpAssertQueryProgrammer {
13
+ export const write =
14
+ (project: IProject) =>
15
+ (modulo: ts.LeftHandSideExpression) =>
16
+ (type: ts.Type, name?: string): ts.ArrowFunction =>
17
+ ts.factory.createArrowFunction(
18
+ undefined,
19
+ undefined,
20
+ [
21
+ IdentifierFactory.parameter(
22
+ "input",
23
+ ts.factory.createTypeReferenceNode(
24
+ HttpQueryProgrammer.INPUT_TYPE,
25
+ ),
26
+ ),
27
+ ],
28
+ ts.factory.createTypeReferenceNode(
29
+ `typia.Resolved<${
30
+ name ?? TypeFactory.getFullName(project.checker)(type)
31
+ }>`,
32
+ ),
33
+ undefined,
34
+ ts.factory.createBlock([
35
+ StatementFactory.constant(
36
+ "decode",
37
+ HttpQueryProgrammer.write({
38
+ ...project,
39
+ options: {
40
+ ...project.options,
41
+ functional: false,
42
+ numeric: false,
43
+ },
44
+ })(modulo)(type, name),
45
+ ),
46
+ StatementFactory.constant(
47
+ "assert",
48
+ AssertProgrammer.write({
49
+ ...project,
50
+ options: {
51
+ ...project.options,
52
+ functional: false,
53
+ numeric: false,
54
+ },
55
+ })(modulo)(false)(type, name),
56
+ ),
57
+ StatementFactory.constant(
58
+ "output",
59
+ ts.factory.createCallExpression(
60
+ ts.factory.createIdentifier("decode"),
61
+ undefined,
62
+ [ts.factory.createIdentifier("input")],
63
+ ),
64
+ ),
65
+ ts.factory.createReturnStatement(
66
+ ts.factory.createAsExpression(
67
+ ts.factory.createCallExpression(
68
+ ts.factory.createIdentifier("assert"),
69
+ undefined,
70
+ [ts.factory.createIdentifier("output")],
71
+ ),
72
+ TypeFactory.keyword("any"),
73
+ ),
74
+ ),
75
+ ]),
76
+ );
77
+ }