typia 7.0.0-dev.20241010-2 → 7.0.0-dev.20241011

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 (49) hide show
  1. package/lib/index.mjs +7 -0
  2. package/lib/index.mjs.map +1 -1
  3. package/lib/json.d.ts +47 -13
  4. package/lib/json.js +7 -0
  5. package/lib/json.js.map +1 -1
  6. package/lib/module.d.ts +1 -0
  7. package/lib/module.js +1 -0
  8. package/lib/module.js.map +1 -1
  9. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +6 -2
  10. package/lib/programmers/json/JsonApplicationProgrammer.js +200 -75
  11. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  12. package/lib/programmers/json/JsonSchemasProgrammer.d.ts +6 -0
  13. package/lib/programmers/json/JsonSchemasProgrammer.js +109 -0
  14. package/lib/programmers/json/JsonSchemasProgrammer.js.map +1 -0
  15. package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +1 -1
  16. package/lib/programmers/llm/LlmApplicationProgrammer.js +57 -39
  17. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  18. package/lib/schemas/json/IJsonApplication.d.ts +31 -12
  19. package/lib/schemas/json/IJsonSchemaList.d.ts +16 -0
  20. package/lib/schemas/json/IJsonSchemaList.js +3 -0
  21. package/lib/schemas/json/IJsonSchemaList.js.map +1 -0
  22. package/lib/transformers/CallExpressionTransformer.js +3 -1
  23. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  24. package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +1 -1
  25. package/lib/transformers/features/json/JsonApplicationTransformer.js +27 -97
  26. package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
  27. package/lib/transformers/features/json/JsonSchemasTransformer.d.ts +5 -0
  28. package/lib/transformers/features/json/JsonSchemasTransformer.js +159 -0
  29. package/lib/transformers/features/json/JsonSchemasTransformer.js.map +1 -0
  30. package/lib/transformers/features/llm/LlmApplicationTransformer.js +1 -1
  31. package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/factories/MetadataFactory.ts +400 -400
  34. package/src/factories/internal/metadata/IMetadataIteratorProps.ts +16 -16
  35. package/src/factories/internal/metadata/emplace_metadata_object.ts +206 -206
  36. package/src/factories/internal/metadata/iterate_metadata_collection.ts +145 -145
  37. package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +32 -32
  38. package/src/factories/internal/metadata/iterate_metadata_function.ts +88 -88
  39. package/src/json.ts +63 -17
  40. package/src/module.ts +1 -0
  41. package/src/programmers/json/JsonApplicationProgrammer.ts +249 -72
  42. package/src/programmers/json/JsonSchemasProgrammer.ts +94 -0
  43. package/src/programmers/llm/LlmApplicationProgrammer.ts +66 -41
  44. package/src/schemas/json/IJsonApplication.ts +61 -22
  45. package/src/schemas/json/IJsonSchemaList.ts +22 -0
  46. package/src/transformers/CallExpressionTransformer.ts +3 -1
  47. package/src/transformers/features/json/JsonApplicationTransformer.ts +29 -54
  48. package/src/transformers/features/json/JsonSchemasTransformer.ts +130 -0
  49. package/src/transformers/features/llm/LlmApplicationTransformer.ts +1 -1
@@ -1,400 +1,400 @@
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 { MetadataConstant } from "../schemas/metadata/MetadataConstant";
7
- import { MetadataFunction } from "../schemas/metadata/MetadataFunction";
8
- import { MetadataObject } from "../schemas/metadata/MetadataObject";
9
- import { MetadataTupleType } from "../schemas/metadata/MetadataTupleType";
10
- import { explore_metadata } from "./internal/metadata/explore_metadata";
11
- import { iterate_metadata_collection } from "./internal/metadata/iterate_metadata_collection";
12
- import { iterate_metadata_sort } from "./internal/metadata/iterate_metadata_sort";
13
-
14
- import { ValidationPipe } from "../typings/ValidationPipe";
15
-
16
- import { ExpressionFactory } from "./ExpressionFactory";
17
- import { MetadataCollection } from "./MetadataCollection";
18
-
19
- export namespace MetadataFactory {
20
- export type Validator = (meta: Metadata, explore: IExplore) => string[];
21
-
22
- export interface IProps {
23
- checker: ts.TypeChecker;
24
- transformer: ts.TransformationContext | undefined;
25
- options: IOptions;
26
- collection: MetadataCollection;
27
- type: ts.Type | null;
28
- }
29
- export interface IOptions {
30
- escape: boolean;
31
- constant: boolean;
32
- absorb: boolean;
33
- functional?: boolean;
34
- validate?: Validator;
35
- onError?: (node: ts.Node | undefined, message: string) => void;
36
- }
37
- export interface IExplore {
38
- top: boolean;
39
- object: MetadataObject | null;
40
- property: string | object | null;
41
- nested: null | MetadataAlias | MetadataArrayType | MetadataTupleType;
42
- parameter: string | null;
43
- output: boolean;
44
- escaped: boolean;
45
- aliased: boolean;
46
- }
47
-
48
- export interface IError {
49
- name: string;
50
- explore: IExplore;
51
- messages: string[];
52
- }
53
-
54
- export const analyze = (props: IProps): ValidationPipe<Metadata, IError> => {
55
- const errors: IError[] = [];
56
- const metadata: Metadata = explore_metadata({
57
- ...props,
58
- errors,
59
- explore: {
60
- top: true,
61
- object: null,
62
- property: null,
63
- parameter: null,
64
- nested: null,
65
- aliased: false,
66
- escaped: false,
67
- output: false,
68
- },
69
- });
70
- iterate_metadata_collection({
71
- errors,
72
- collection: props.collection,
73
- });
74
- iterate_metadata_sort({
75
- collection: props.collection,
76
- metadata: metadata,
77
- });
78
-
79
- if (props.options.validate)
80
- errors.push(
81
- ...validate({
82
- transformer: props.transformer,
83
- options: props.options,
84
- functor: props.options.validate,
85
- metadata,
86
- }),
87
- );
88
- return errors.length
89
- ? {
90
- success: false,
91
- errors,
92
- }
93
- : {
94
- success: true,
95
- data: metadata,
96
- };
97
- };
98
-
99
- /**
100
- * @internal
101
- */
102
- export const soleLiteral = (value: string): Metadata => {
103
- const meta: Metadata = Metadata.initialize();
104
- meta.constants.push(
105
- MetadataConstant.from({
106
- values: [
107
- {
108
- value,
109
- tags: undefined,
110
- },
111
- ],
112
- type: "string",
113
- }),
114
- );
115
- return meta;
116
- };
117
-
118
- export const validate = (props: {
119
- transformer?: ts.TransformationContext;
120
- options: IOptions;
121
- functor: Validator;
122
- metadata: Metadata;
123
- }): IError[] => {
124
- const visitor: IValidationVisitor = {
125
- functor: props.functor,
126
- errors: [],
127
- objects: new Set(),
128
- arrays: new Set(),
129
- tuples: new Set(),
130
- aliases: new Set(),
131
- functions: new Set(),
132
- };
133
- validateMeta({
134
- ...props,
135
- visitor,
136
- explore: {
137
- object: null,
138
- property: null,
139
- parameter: null,
140
- nested: null,
141
- top: true,
142
- aliased: false,
143
- escaped: false,
144
- output: false,
145
- },
146
- });
147
- return visitor.errors;
148
- };
149
-
150
- const validateMeta = (props: {
151
- transformer?: ts.TransformationContext;
152
- options: IOptions;
153
- visitor: IValidationVisitor;
154
- metadata: Metadata;
155
- explore: IExplore;
156
- }) => {
157
- const result: string[] = [];
158
- if (props.transformer !== undefined)
159
- for (const atomic of props.metadata.atomics)
160
- for (const row of atomic.tags)
161
- for (const tag of row.filter(
162
- (t) => t.validate !== undefined && t.predicate === undefined,
163
- ))
164
- try {
165
- tag.predicate = ExpressionFactory.transpile(
166
- props.transformer,
167
- tag.validate!,
168
- );
169
- } catch {
170
- result.push(
171
- `Unable to transpile type tag script: ${JSON.stringify(
172
- tag.validate,
173
- )}`,
174
- );
175
- tag.predicate = () => ts.factory.createTrue();
176
- }
177
- result.push(...props.visitor.functor(props.metadata, props.explore));
178
- if (result.length)
179
- props.visitor.errors.push({
180
- name: props.metadata.getName(),
181
- explore: { ...props.explore },
182
- messages: [...new Set(result)],
183
- });
184
-
185
- for (const alias of props.metadata.aliases)
186
- validateAlias({
187
- ...props,
188
- alias,
189
- });
190
- for (const array of props.metadata.arrays)
191
- validateArray({
192
- ...props,
193
- array: array.type,
194
- });
195
- for (const tuple of props.metadata.tuples)
196
- validateTuple({
197
- ...props,
198
- tuple: tuple.type,
199
- });
200
- for (const object of props.metadata.objects)
201
- validateObject({
202
- ...props,
203
- object,
204
- });
205
- for (const func of props.metadata.functions)
206
- validateFunction({
207
- ...props,
208
- function: func,
209
- });
210
- for (const set of props.metadata.sets)
211
- validateMeta({
212
- ...props,
213
- metadata: set,
214
- });
215
- for (const map of props.metadata.maps) {
216
- validateMeta({
217
- ...props,
218
- metadata: map.key,
219
- });
220
- validateMeta({
221
- ...props,
222
- metadata: map.value,
223
- });
224
- }
225
-
226
- if (props.options.escape === true && props.metadata.escaped !== null)
227
- validateMeta({
228
- ...props,
229
- metadata: props.metadata.escaped.returns,
230
- explore: {
231
- ...props.explore,
232
- escaped: true,
233
- },
234
- });
235
- };
236
-
237
- const validateAlias = (props: {
238
- transformer?: ts.TransformationContext;
239
- options: IOptions;
240
- visitor: IValidationVisitor;
241
- alias: MetadataAlias;
242
- explore: IExplore;
243
- }) => {
244
- if (props.visitor.aliases.has(props.alias)) return;
245
- props.visitor.aliases.add(props.alias);
246
-
247
- validateMeta({
248
- ...props,
249
- metadata: props.alias.value,
250
- explore: {
251
- ...props.explore,
252
- nested: props.alias,
253
- aliased: true,
254
- },
255
- });
256
- };
257
-
258
- const validateArray = (props: {
259
- transformer?: ts.TransformationContext;
260
- options: IOptions;
261
- visitor: IValidationVisitor;
262
- array: MetadataArrayType;
263
- explore: IExplore;
264
- }) => {
265
- if (props.visitor.arrays.has(props.array)) return;
266
- props.visitor.arrays.add(props.array);
267
-
268
- validateMeta({
269
- ...props,
270
- metadata: props.array.value,
271
- explore: {
272
- ...props.explore,
273
- nested: props.array,
274
- top: false,
275
- },
276
- });
277
- };
278
-
279
- const validateTuple = (props: {
280
- transformer?: ts.TransformationContext;
281
- options: IOptions;
282
- visitor: IValidationVisitor;
283
- tuple: MetadataTupleType;
284
- explore: IExplore;
285
- }) => {
286
- if (props.visitor.tuples.has(props.tuple)) return;
287
- props.visitor.tuples.add(props.tuple);
288
-
289
- for (const elem of props.tuple.elements)
290
- validateMeta({
291
- ...props,
292
- metadata: elem,
293
- explore: {
294
- ...props.explore,
295
- nested: props.tuple,
296
- top: false,
297
- },
298
- });
299
- };
300
-
301
- const validateObject = (props: {
302
- transformer?: ts.TransformationContext;
303
- options: IOptions;
304
- visitor: IValidationVisitor;
305
- object: MetadataObject;
306
- }) => {
307
- if (props.visitor.objects.has(props.object)) return;
308
- props.visitor.objects.add(props.object);
309
-
310
- if (props.options.validate) {
311
- const explore: IExplore = {
312
- object: props.object,
313
- top: false,
314
- property: null,
315
- parameter: null,
316
- nested: null,
317
- aliased: false,
318
- escaped: false,
319
- output: false,
320
- };
321
- const errors: string[] = props.options.validate(
322
- Metadata.create({
323
- ...Metadata.initialize(),
324
- objects: [props.object],
325
- }),
326
- explore,
327
- );
328
- if (errors.length)
329
- props.visitor.errors.push({
330
- name: props.object.name,
331
- explore,
332
- messages: [...new Set(errors)],
333
- });
334
- }
335
-
336
- for (const property of props.object.properties)
337
- validateMeta({
338
- ...props,
339
- metadata: property.value,
340
- explore: {
341
- object: props.object,
342
- property: property.key.isSoleLiteral()
343
- ? property.key.getSoleLiteral()!
344
- : {},
345
- parameter: null,
346
- nested: null,
347
- top: false,
348
- aliased: false,
349
- escaped: false,
350
- output: false,
351
- },
352
- });
353
- };
354
-
355
- const validateFunction = (props: {
356
- transformer?: ts.TransformationContext;
357
- options: IOptions;
358
- visitor: IValidationVisitor;
359
- function: MetadataFunction;
360
- explore: IExplore;
361
- }) => {
362
- if (props.visitor.functions.has(props.function)) return;
363
- props.visitor.functions.add(props.function);
364
-
365
- for (const param of props.function.parameters)
366
- validateMeta({
367
- ...props,
368
- metadata: param.type,
369
- explore: {
370
- ...props.explore,
371
- parameter: param.name,
372
- nested: null,
373
- top: false,
374
- output: false,
375
- },
376
- });
377
- if (props.function.output)
378
- validateMeta({
379
- ...props,
380
- metadata: props.function.output,
381
- explore: {
382
- ...props.explore,
383
- parameter: null,
384
- nested: null,
385
- top: false,
386
- output: true,
387
- },
388
- });
389
- };
390
-
391
- interface IValidationVisitor {
392
- functor: Validator;
393
- errors: IError[];
394
- objects: Set<MetadataObject>;
395
- arrays: Set<MetadataArrayType>;
396
- tuples: Set<MetadataTupleType>;
397
- aliases: Set<MetadataAlias>;
398
- functions: Set<MetadataFunction>;
399
- }
400
- }
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 { MetadataConstant } from "../schemas/metadata/MetadataConstant";
7
+ import { MetadataFunction } from "../schemas/metadata/MetadataFunction";
8
+ import { MetadataObject } from "../schemas/metadata/MetadataObject";
9
+ import { MetadataTupleType } from "../schemas/metadata/MetadataTupleType";
10
+ import { explore_metadata } from "./internal/metadata/explore_metadata";
11
+ import { iterate_metadata_collection } from "./internal/metadata/iterate_metadata_collection";
12
+ import { iterate_metadata_sort } from "./internal/metadata/iterate_metadata_sort";
13
+
14
+ import { ValidationPipe } from "../typings/ValidationPipe";
15
+
16
+ import { ExpressionFactory } from "./ExpressionFactory";
17
+ import { MetadataCollection } from "./MetadataCollection";
18
+
19
+ export namespace MetadataFactory {
20
+ export type Validator = (meta: Metadata, explore: IExplore) => string[];
21
+
22
+ export interface IProps {
23
+ checker: ts.TypeChecker;
24
+ transformer: ts.TransformationContext | undefined;
25
+ options: IOptions;
26
+ collection: MetadataCollection;
27
+ type: ts.Type | null;
28
+ }
29
+ export interface IOptions {
30
+ escape: boolean;
31
+ constant: boolean;
32
+ absorb: boolean;
33
+ functional?: boolean;
34
+ validate?: Validator;
35
+ onError?: (node: ts.Node | undefined, message: string) => void;
36
+ }
37
+ export interface IExplore {
38
+ top: boolean;
39
+ object: MetadataObject | null;
40
+ property: string | object | null;
41
+ nested: null | MetadataAlias | MetadataArrayType | MetadataTupleType;
42
+ parameter: string | null;
43
+ output: boolean;
44
+ escaped: boolean;
45
+ aliased: boolean;
46
+ }
47
+
48
+ export interface IError {
49
+ name: string;
50
+ explore: IExplore;
51
+ messages: string[];
52
+ }
53
+
54
+ export const analyze = (props: IProps): ValidationPipe<Metadata, IError> => {
55
+ const errors: IError[] = [];
56
+ const metadata: Metadata = explore_metadata({
57
+ ...props,
58
+ errors,
59
+ explore: {
60
+ top: true,
61
+ object: null,
62
+ property: null,
63
+ parameter: null,
64
+ nested: null,
65
+ aliased: false,
66
+ escaped: false,
67
+ output: false,
68
+ },
69
+ });
70
+ iterate_metadata_collection({
71
+ errors,
72
+ collection: props.collection,
73
+ });
74
+ iterate_metadata_sort({
75
+ collection: props.collection,
76
+ metadata: metadata,
77
+ });
78
+
79
+ if (props.options.validate)
80
+ errors.push(
81
+ ...validate({
82
+ transformer: props.transformer,
83
+ options: props.options,
84
+ functor: props.options.validate,
85
+ metadata,
86
+ }),
87
+ );
88
+ return errors.length
89
+ ? {
90
+ success: false,
91
+ errors,
92
+ }
93
+ : {
94
+ success: true,
95
+ data: metadata,
96
+ };
97
+ };
98
+
99
+ /**
100
+ * @internal
101
+ */
102
+ export const soleLiteral = (value: string): Metadata => {
103
+ const meta: Metadata = Metadata.initialize();
104
+ meta.constants.push(
105
+ MetadataConstant.from({
106
+ values: [
107
+ {
108
+ value,
109
+ tags: undefined,
110
+ },
111
+ ],
112
+ type: "string",
113
+ }),
114
+ );
115
+ return meta;
116
+ };
117
+
118
+ export const validate = (props: {
119
+ transformer?: ts.TransformationContext;
120
+ options: IOptions;
121
+ functor: Validator;
122
+ metadata: Metadata;
123
+ }): IError[] => {
124
+ const visitor: IValidationVisitor = {
125
+ functor: props.functor,
126
+ errors: [],
127
+ objects: new Set(),
128
+ arrays: new Set(),
129
+ tuples: new Set(),
130
+ aliases: new Set(),
131
+ functions: new Set(),
132
+ };
133
+ validateMeta({
134
+ ...props,
135
+ visitor,
136
+ explore: {
137
+ object: null,
138
+ property: null,
139
+ parameter: null,
140
+ nested: null,
141
+ top: true,
142
+ aliased: false,
143
+ escaped: false,
144
+ output: false,
145
+ },
146
+ });
147
+ return visitor.errors;
148
+ };
149
+
150
+ const validateMeta = (props: {
151
+ transformer?: ts.TransformationContext;
152
+ options: IOptions;
153
+ visitor: IValidationVisitor;
154
+ metadata: Metadata;
155
+ explore: IExplore;
156
+ }) => {
157
+ const result: string[] = [];
158
+ if (props.transformer !== undefined)
159
+ for (const atomic of props.metadata.atomics)
160
+ for (const row of atomic.tags)
161
+ for (const tag of row.filter(
162
+ (t) => t.validate !== undefined && t.predicate === undefined,
163
+ ))
164
+ try {
165
+ tag.predicate = ExpressionFactory.transpile(
166
+ props.transformer,
167
+ tag.validate!,
168
+ );
169
+ } catch {
170
+ result.push(
171
+ `Unable to transpile type tag script: ${JSON.stringify(
172
+ tag.validate,
173
+ )}`,
174
+ );
175
+ tag.predicate = () => ts.factory.createTrue();
176
+ }
177
+ result.push(...props.visitor.functor(props.metadata, props.explore));
178
+ if (result.length)
179
+ props.visitor.errors.push({
180
+ name: props.metadata.getName(),
181
+ explore: { ...props.explore },
182
+ messages: [...new Set(result)],
183
+ });
184
+
185
+ for (const alias of props.metadata.aliases)
186
+ validateAlias({
187
+ ...props,
188
+ alias,
189
+ });
190
+ for (const array of props.metadata.arrays)
191
+ validateArray({
192
+ ...props,
193
+ array: array.type,
194
+ });
195
+ for (const tuple of props.metadata.tuples)
196
+ validateTuple({
197
+ ...props,
198
+ tuple: tuple.type,
199
+ });
200
+ for (const object of props.metadata.objects)
201
+ validateObject({
202
+ ...props,
203
+ object,
204
+ });
205
+ for (const func of props.metadata.functions)
206
+ validateFunction({
207
+ ...props,
208
+ function: func,
209
+ });
210
+ for (const set of props.metadata.sets)
211
+ validateMeta({
212
+ ...props,
213
+ metadata: set,
214
+ });
215
+ for (const map of props.metadata.maps) {
216
+ validateMeta({
217
+ ...props,
218
+ metadata: map.key,
219
+ });
220
+ validateMeta({
221
+ ...props,
222
+ metadata: map.value,
223
+ });
224
+ }
225
+
226
+ if (props.options.escape === true && props.metadata.escaped !== null)
227
+ validateMeta({
228
+ ...props,
229
+ metadata: props.metadata.escaped.returns,
230
+ explore: {
231
+ ...props.explore,
232
+ escaped: true,
233
+ },
234
+ });
235
+ };
236
+
237
+ const validateAlias = (props: {
238
+ transformer?: ts.TransformationContext;
239
+ options: IOptions;
240
+ visitor: IValidationVisitor;
241
+ alias: MetadataAlias;
242
+ explore: IExplore;
243
+ }) => {
244
+ if (props.visitor.aliases.has(props.alias)) return;
245
+ props.visitor.aliases.add(props.alias);
246
+
247
+ validateMeta({
248
+ ...props,
249
+ metadata: props.alias.value,
250
+ explore: {
251
+ ...props.explore,
252
+ nested: props.alias,
253
+ aliased: true,
254
+ },
255
+ });
256
+ };
257
+
258
+ const validateArray = (props: {
259
+ transformer?: ts.TransformationContext;
260
+ options: IOptions;
261
+ visitor: IValidationVisitor;
262
+ array: MetadataArrayType;
263
+ explore: IExplore;
264
+ }) => {
265
+ if (props.visitor.arrays.has(props.array)) return;
266
+ props.visitor.arrays.add(props.array);
267
+
268
+ validateMeta({
269
+ ...props,
270
+ metadata: props.array.value,
271
+ explore: {
272
+ ...props.explore,
273
+ nested: props.array,
274
+ top: false,
275
+ },
276
+ });
277
+ };
278
+
279
+ const validateTuple = (props: {
280
+ transformer?: ts.TransformationContext;
281
+ options: IOptions;
282
+ visitor: IValidationVisitor;
283
+ tuple: MetadataTupleType;
284
+ explore: IExplore;
285
+ }) => {
286
+ if (props.visitor.tuples.has(props.tuple)) return;
287
+ props.visitor.tuples.add(props.tuple);
288
+
289
+ for (const elem of props.tuple.elements)
290
+ validateMeta({
291
+ ...props,
292
+ metadata: elem,
293
+ explore: {
294
+ ...props.explore,
295
+ nested: props.tuple,
296
+ top: false,
297
+ },
298
+ });
299
+ };
300
+
301
+ const validateObject = (props: {
302
+ transformer?: ts.TransformationContext;
303
+ options: IOptions;
304
+ visitor: IValidationVisitor;
305
+ object: MetadataObject;
306
+ }) => {
307
+ if (props.visitor.objects.has(props.object)) return;
308
+ props.visitor.objects.add(props.object);
309
+
310
+ if (props.options.validate) {
311
+ const explore: IExplore = {
312
+ object: props.object,
313
+ top: false,
314
+ property: null,
315
+ parameter: null,
316
+ nested: null,
317
+ aliased: false,
318
+ escaped: false,
319
+ output: false,
320
+ };
321
+ const errors: string[] = props.options.validate(
322
+ Metadata.create({
323
+ ...Metadata.initialize(),
324
+ objects: [props.object],
325
+ }),
326
+ explore,
327
+ );
328
+ if (errors.length)
329
+ props.visitor.errors.push({
330
+ name: props.object.name,
331
+ explore,
332
+ messages: [...new Set(errors)],
333
+ });
334
+ }
335
+
336
+ for (const property of props.object.properties)
337
+ validateMeta({
338
+ ...props,
339
+ metadata: property.value,
340
+ explore: {
341
+ object: props.object,
342
+ property: property.key.isSoleLiteral()
343
+ ? property.key.getSoleLiteral()!
344
+ : {},
345
+ parameter: null,
346
+ nested: null,
347
+ top: false,
348
+ aliased: false,
349
+ escaped: false,
350
+ output: false,
351
+ },
352
+ });
353
+ };
354
+
355
+ const validateFunction = (props: {
356
+ transformer?: ts.TransformationContext;
357
+ options: IOptions;
358
+ visitor: IValidationVisitor;
359
+ function: MetadataFunction;
360
+ explore: IExplore;
361
+ }) => {
362
+ if (props.visitor.functions.has(props.function)) return;
363
+ props.visitor.functions.add(props.function);
364
+
365
+ for (const param of props.function.parameters)
366
+ validateMeta({
367
+ ...props,
368
+ metadata: param.type,
369
+ explore: {
370
+ ...props.explore,
371
+ parameter: param.name,
372
+ nested: null,
373
+ top: false,
374
+ output: false,
375
+ },
376
+ });
377
+ if (props.function.output)
378
+ validateMeta({
379
+ ...props,
380
+ metadata: props.function.output,
381
+ explore: {
382
+ ...props.explore,
383
+ parameter: null,
384
+ nested: null,
385
+ top: false,
386
+ output: true,
387
+ },
388
+ });
389
+ };
390
+
391
+ interface IValidationVisitor {
392
+ functor: Validator;
393
+ errors: IError[];
394
+ objects: Set<MetadataObject>;
395
+ arrays: Set<MetadataArrayType>;
396
+ tuples: Set<MetadataTupleType>;
397
+ aliases: Set<MetadataAlias>;
398
+ functions: Set<MetadataFunction>;
399
+ }
400
+ }