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
@@ -1,238 +1,238 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../schemas/metadata/Metadata";
4
- import { MetadataAlias } from "../schemas/metadata/MetadataAlias";
5
- import { MetadataArrayType } from "../schemas/metadata/MetadataArrayType";
6
- import { MetadataObject } from "../schemas/metadata/MetadataObject";
7
- import { MetadataTupleType } from "../schemas/metadata/MetadataTupleType";
8
- import { explore_metadata } from "./internal/metadata/explore_metadata";
9
- import { iterate_metadata_collection } from "./internal/metadata/iterate_metadata_collection";
10
- import { iterate_metadata_sort } from "./internal/metadata/iterate_metadata_sort";
11
-
12
- import { ValidationPipe } from "../typings/ValidationPipe";
13
-
14
- import { MetadataCollection } from "./MetadataCollection";
15
-
16
- export namespace MetadataFactory {
17
- export type Validator = (meta: Metadata, explore: IExplore) => string[];
18
-
19
- export interface IOptions {
20
- escape: boolean;
21
- constant: boolean;
22
- absorb: boolean;
23
- validate?: Validator;
24
- onError?: (node: ts.Node | undefined, message: string) => void;
25
- }
26
-
27
- export interface IExplore {
28
- top: boolean;
29
- object: MetadataObject | null;
30
- property: string | object | null;
31
- nested: null | MetadataAlias | MetadataArrayType | MetadataTupleType;
32
- escaped: boolean;
33
- aliased: boolean;
34
- }
35
-
36
- export interface IError {
37
- name: string;
38
- explore: IExplore;
39
- messages: string[];
40
- }
41
-
42
- export const analyze =
43
- (checker: ts.TypeChecker) =>
44
- (options: IOptions) =>
45
- (collection: MetadataCollection) =>
46
- (type: ts.Type | null): ValidationPipe<Metadata, IError> => {
47
- const errors: IError[] = [];
48
- const meta: Metadata = explore_metadata(checker)(options)(
49
- collection,
50
- )(errors)(type, {
51
- top: true,
52
- object: null,
53
- property: null,
54
- nested: null,
55
- escaped: false,
56
- aliased: false,
57
- });
58
- iterate_metadata_collection(errors)(collection);
59
- iterate_metadata_sort(collection)(meta);
60
-
61
- if (options.validate)
62
- errors.push(...validate(options)(options.validate)(meta));
63
- return errors.length
64
- ? {
65
- success: false,
66
- errors,
67
- }
68
- : {
69
- success: true,
70
- data: meta,
71
- };
72
- };
73
-
74
- /**
75
- * @internal
76
- */
77
- export const soleLiteral = (value: string): Metadata => {
78
- const meta: Metadata = Metadata.initialize();
79
- meta.constants.push({
80
- values: [value],
81
- type: "string",
82
- });
83
- return meta;
84
- };
85
-
86
- const validate =
87
- (options: IOptions) =>
88
- (functor: Validator) =>
89
- (meta: Metadata): IError[] => {
90
- const visitor: IValidationVisitor = {
91
- functor,
92
- errors: [],
93
- objects: new Set(),
94
- arrays: new Set(),
95
- tuples: new Set(),
96
- aliases: new Set(),
97
- };
98
- validateMeta(options)(visitor)(meta, {
99
- object: null,
100
- property: null,
101
- nested: null,
102
- top: true,
103
- aliased: false,
104
- escaped: false,
105
- });
106
- return visitor.errors;
107
- };
108
-
109
- const validateMeta =
110
- (options: IOptions) =>
111
- (visitor: IValidationVisitor) =>
112
- (meta: Metadata, explore: IExplore) => {
113
- const result: Set<string> = new Set(visitor.functor(meta, explore));
114
- if (result.size)
115
- visitor.errors.push({
116
- name: meta.getName(),
117
- explore: { ...explore },
118
- messages: [...result],
119
- });
120
-
121
- for (const alias of meta.aliases)
122
- validateAlias(options)(visitor)(alias, explore);
123
- for (const array of meta.arrays)
124
- validateArray(options)(visitor)(array.type, explore);
125
- for (const tuple of meta.tuples)
126
- validateTuple(options)(visitor)(tuple.type, explore);
127
- for (const obj of meta.objects)
128
- validateObject(options)(visitor)(obj);
129
- for (const set of meta.sets)
130
- validateMeta(options)(visitor)(set, explore);
131
- for (const map of meta.maps) {
132
- validateMeta(options)(visitor)(map.key, explore);
133
- validateMeta(options)(visitor)(map.value, explore);
134
- }
135
-
136
- if (options.escape === true && meta.escaped !== null)
137
- validateMeta(options)(visitor)(meta.escaped.returns, {
138
- ...explore,
139
- escaped: true,
140
- });
141
- };
142
-
143
- const validateAlias =
144
- (options: IOptions) =>
145
- (visitor: IValidationVisitor) =>
146
- (alias: MetadataAlias, explore: IExplore) => {
147
- if (visitor.aliases.has(alias)) return;
148
- visitor.aliases.add(alias);
149
-
150
- validateMeta(options)(visitor)(alias.value, {
151
- ...explore,
152
- nested: alias,
153
- aliased: true,
154
- });
155
- };
156
-
157
- const validateArray =
158
- (options: IOptions) =>
159
- (visitor: IValidationVisitor) =>
160
- (array: MetadataArrayType, explore: IExplore) => {
161
- if (visitor.arrays.has(array)) return;
162
- visitor.arrays.add(array);
163
-
164
- validateMeta(options)(visitor)(array.value, {
165
- ...explore,
166
- nested: array,
167
- top: false,
168
- });
169
- };
170
-
171
- const validateTuple =
172
- (options: IOptions) =>
173
- (visitor: IValidationVisitor) =>
174
- (tuple: MetadataTupleType, explore: IExplore) => {
175
- if (visitor.tuples.has(tuple)) return;
176
- visitor.tuples.add(tuple);
177
-
178
- for (const elem of tuple.elements)
179
- validateMeta(options)(visitor)(elem, {
180
- ...explore,
181
- nested: tuple,
182
- top: false,
183
- });
184
- };
185
-
186
- const validateObject =
187
- (options: IOptions) =>
188
- (visitor: IValidationVisitor) =>
189
- (object: MetadataObject) => {
190
- if (visitor.objects.has(object)) return;
191
- visitor.objects.add(object);
192
-
193
- if (options.validate) {
194
- const explore: IExplore = {
195
- object,
196
- top: false,
197
- property: null,
198
- nested: null,
199
- escaped: false,
200
- aliased: false,
201
- };
202
- const errors: string[] = options.validate(
203
- Metadata.create({
204
- ...Metadata.initialize(),
205
- objects: [object],
206
- }),
207
- explore,
208
- );
209
- if (errors.length)
210
- visitor.errors.push({
211
- name: object.name,
212
- explore,
213
- messages: [...new Set(errors)],
214
- });
215
- }
216
-
217
- for (const property of object.properties)
218
- validateMeta(options)(visitor)(property.value, {
219
- object,
220
- property: property.key.isSoleLiteral()
221
- ? property.key.getSoleLiteral()!
222
- : {},
223
- nested: null,
224
- top: false,
225
- aliased: false,
226
- escaped: false,
227
- });
228
- };
229
-
230
- interface IValidationVisitor {
231
- functor: Validator;
232
- errors: IError[];
233
- objects: Set<MetadataObject>;
234
- arrays: Set<MetadataArrayType>;
235
- tuples: Set<MetadataTupleType>;
236
- aliases: Set<MetadataAlias>;
237
- }
238
- }
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../schemas/metadata/Metadata";
4
+ import { MetadataAlias } from "../schemas/metadata/MetadataAlias";
5
+ import { MetadataArrayType } from "../schemas/metadata/MetadataArrayType";
6
+ import { MetadataObject } from "../schemas/metadata/MetadataObject";
7
+ import { MetadataTupleType } from "../schemas/metadata/MetadataTupleType";
8
+ import { explore_metadata } from "./internal/metadata/explore_metadata";
9
+ import { iterate_metadata_collection } from "./internal/metadata/iterate_metadata_collection";
10
+ import { iterate_metadata_sort } from "./internal/metadata/iterate_metadata_sort";
11
+
12
+ import { ValidationPipe } from "../typings/ValidationPipe";
13
+
14
+ import { MetadataCollection } from "./MetadataCollection";
15
+
16
+ export namespace MetadataFactory {
17
+ export type Validator = (meta: Metadata, explore: IExplore) => string[];
18
+
19
+ export interface IOptions {
20
+ escape: boolean;
21
+ constant: boolean;
22
+ absorb: boolean;
23
+ validate?: Validator;
24
+ onError?: (node: ts.Node | undefined, message: string) => void;
25
+ }
26
+
27
+ export interface IExplore {
28
+ top: boolean;
29
+ object: MetadataObject | null;
30
+ property: string | object | null;
31
+ nested: null | MetadataAlias | MetadataArrayType | MetadataTupleType;
32
+ escaped: boolean;
33
+ aliased: boolean;
34
+ }
35
+
36
+ export interface IError {
37
+ name: string;
38
+ explore: IExplore;
39
+ messages: string[];
40
+ }
41
+
42
+ export const analyze =
43
+ (checker: ts.TypeChecker) =>
44
+ (options: IOptions) =>
45
+ (collection: MetadataCollection) =>
46
+ (type: ts.Type | null): ValidationPipe<Metadata, IError> => {
47
+ const errors: IError[] = [];
48
+ const meta: Metadata = explore_metadata(checker)(options)(
49
+ collection,
50
+ )(errors)(type, {
51
+ top: true,
52
+ object: null,
53
+ property: null,
54
+ nested: null,
55
+ escaped: false,
56
+ aliased: false,
57
+ });
58
+ iterate_metadata_collection(errors)(collection);
59
+ iterate_metadata_sort(collection)(meta);
60
+
61
+ if (options.validate)
62
+ errors.push(...validate(options)(options.validate)(meta));
63
+ return errors.length
64
+ ? {
65
+ success: false,
66
+ errors,
67
+ }
68
+ : {
69
+ success: true,
70
+ data: meta,
71
+ };
72
+ };
73
+
74
+ /**
75
+ * @internal
76
+ */
77
+ export const soleLiteral = (value: string): Metadata => {
78
+ const meta: Metadata = Metadata.initialize();
79
+ meta.constants.push({
80
+ values: [value],
81
+ type: "string",
82
+ });
83
+ return meta;
84
+ };
85
+
86
+ const validate =
87
+ (options: IOptions) =>
88
+ (functor: Validator) =>
89
+ (meta: Metadata): IError[] => {
90
+ const visitor: IValidationVisitor = {
91
+ functor,
92
+ errors: [],
93
+ objects: new Set(),
94
+ arrays: new Set(),
95
+ tuples: new Set(),
96
+ aliases: new Set(),
97
+ };
98
+ validateMeta(options)(visitor)(meta, {
99
+ object: null,
100
+ property: null,
101
+ nested: null,
102
+ top: true,
103
+ aliased: false,
104
+ escaped: false,
105
+ });
106
+ return visitor.errors;
107
+ };
108
+
109
+ const validateMeta =
110
+ (options: IOptions) =>
111
+ (visitor: IValidationVisitor) =>
112
+ (meta: Metadata, explore: IExplore) => {
113
+ const result: Set<string> = new Set(visitor.functor(meta, explore));
114
+ if (result.size)
115
+ visitor.errors.push({
116
+ name: meta.getName(),
117
+ explore: { ...explore },
118
+ messages: [...result],
119
+ });
120
+
121
+ for (const alias of meta.aliases)
122
+ validateAlias(options)(visitor)(alias, explore);
123
+ for (const array of meta.arrays)
124
+ validateArray(options)(visitor)(array.type, explore);
125
+ for (const tuple of meta.tuples)
126
+ validateTuple(options)(visitor)(tuple.type, explore);
127
+ for (const obj of meta.objects)
128
+ validateObject(options)(visitor)(obj);
129
+ for (const set of meta.sets)
130
+ validateMeta(options)(visitor)(set, explore);
131
+ for (const map of meta.maps) {
132
+ validateMeta(options)(visitor)(map.key, explore);
133
+ validateMeta(options)(visitor)(map.value, explore);
134
+ }
135
+
136
+ if (options.escape === true && meta.escaped !== null)
137
+ validateMeta(options)(visitor)(meta.escaped.returns, {
138
+ ...explore,
139
+ escaped: true,
140
+ });
141
+ };
142
+
143
+ const validateAlias =
144
+ (options: IOptions) =>
145
+ (visitor: IValidationVisitor) =>
146
+ (alias: MetadataAlias, explore: IExplore) => {
147
+ if (visitor.aliases.has(alias)) return;
148
+ visitor.aliases.add(alias);
149
+
150
+ validateMeta(options)(visitor)(alias.value, {
151
+ ...explore,
152
+ nested: alias,
153
+ aliased: true,
154
+ });
155
+ };
156
+
157
+ const validateArray =
158
+ (options: IOptions) =>
159
+ (visitor: IValidationVisitor) =>
160
+ (array: MetadataArrayType, explore: IExplore) => {
161
+ if (visitor.arrays.has(array)) return;
162
+ visitor.arrays.add(array);
163
+
164
+ validateMeta(options)(visitor)(array.value, {
165
+ ...explore,
166
+ nested: array,
167
+ top: false,
168
+ });
169
+ };
170
+
171
+ const validateTuple =
172
+ (options: IOptions) =>
173
+ (visitor: IValidationVisitor) =>
174
+ (tuple: MetadataTupleType, explore: IExplore) => {
175
+ if (visitor.tuples.has(tuple)) return;
176
+ visitor.tuples.add(tuple);
177
+
178
+ for (const elem of tuple.elements)
179
+ validateMeta(options)(visitor)(elem, {
180
+ ...explore,
181
+ nested: tuple,
182
+ top: false,
183
+ });
184
+ };
185
+
186
+ const validateObject =
187
+ (options: IOptions) =>
188
+ (visitor: IValidationVisitor) =>
189
+ (object: MetadataObject) => {
190
+ if (visitor.objects.has(object)) return;
191
+ visitor.objects.add(object);
192
+
193
+ if (options.validate) {
194
+ const explore: IExplore = {
195
+ object,
196
+ top: false,
197
+ property: null,
198
+ nested: null,
199
+ escaped: false,
200
+ aliased: false,
201
+ };
202
+ const errors: string[] = options.validate(
203
+ Metadata.create({
204
+ ...Metadata.initialize(),
205
+ objects: [object],
206
+ }),
207
+ explore,
208
+ );
209
+ if (errors.length)
210
+ visitor.errors.push({
211
+ name: object.name,
212
+ explore,
213
+ messages: [...new Set(errors)],
214
+ });
215
+ }
216
+
217
+ for (const property of object.properties)
218
+ validateMeta(options)(visitor)(property.value, {
219
+ object,
220
+ property: property.key.isSoleLiteral()
221
+ ? property.key.getSoleLiteral()!
222
+ : {},
223
+ nested: null,
224
+ top: false,
225
+ aliased: false,
226
+ escaped: false,
227
+ });
228
+ };
229
+
230
+ interface IValidationVisitor {
231
+ functor: Validator;
232
+ errors: IError[];
233
+ objects: Set<MetadataObject>;
234
+ arrays: Set<MetadataArrayType>;
235
+ tuples: Set<MetadataTupleType>;
236
+ aliases: Set<MetadataAlias>;
237
+ }
238
+ }