@typia/transform 12.0.0 → 12.1.0-dev.20260325
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.
- package/LICENSE +21 -21
- package/README.md +25 -25
- package/lib/FileTransformer.js +16 -12
- package/lib/FileTransformer.js.map +1 -1
- package/lib/FileTransformer.mjs +16 -12
- package/lib/FileTransformer.mjs.map +1 -1
- package/lib/features/llm/LlmApplicationTransformer.d.ts +0 -6
- package/lib/features/llm/LlmApplicationTransformer.js +4 -82
- package/lib/features/llm/LlmApplicationTransformer.js.map +1 -1
- package/lib/features/llm/LlmApplicationTransformer.mjs +3 -80
- package/lib/features/llm/LlmApplicationTransformer.mjs.map +1 -1
- package/lib/features/llm/LlmControllerTransformer.js +64 -36
- package/lib/features/llm/LlmControllerTransformer.js.map +1 -1
- package/lib/features/llm/LlmControllerTransformer.mjs +64 -36
- package/lib/features/llm/LlmControllerTransformer.mjs.map +1 -1
- package/package.json +5 -5
- package/src/CallExpressionTransformer.ts +581 -581
- package/src/FileTransformer.ts +143 -143
- package/src/features/llm/LlmApplicationTransformer.ts +89 -226
- package/src/features/llm/LlmCoerceTransformer.ts +95 -95
- package/src/features/llm/LlmControllerTransformer.ts +100 -81
- package/src/features/llm/LlmCreateCoerceTransformer.ts +84 -84
- package/src/features/llm/LlmCreateParseTransformer.ts +84 -84
- package/src/features/llm/LlmParametersTransformer.ts +76 -76
- package/src/features/llm/LlmParseTransformer.ts +95 -95
- package/src/features/llm/LlmSchemaTransformer.ts +88 -88
- package/src/features/llm/LlmStructuredOutputTransformer.ts +86 -86
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LlmCoerceProgrammer,
|
|
3
|
-
LlmMetadataFactory,
|
|
4
|
-
MetadataCollection,
|
|
5
|
-
MetadataFactory,
|
|
6
|
-
MetadataSchema,
|
|
7
|
-
} from "@typia/core";
|
|
8
|
-
import { ILlmSchema, ValidationPipe } from "@typia/interface";
|
|
9
|
-
import ts from "typescript";
|
|
10
|
-
|
|
11
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
12
|
-
import { TransformerError } from "../../TransformerError";
|
|
13
|
-
|
|
14
|
-
export namespace LlmCoerceTransformer {
|
|
15
|
-
export const transform = (props: ITransformProps): ts.Expression => {
|
|
16
|
-
// CHECK PARAMETER
|
|
17
|
-
if (props.expression.arguments.length === 0)
|
|
18
|
-
throw new TransformerError({
|
|
19
|
-
code: "typia.llm.coerce",
|
|
20
|
-
message: "no input value.",
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// GET GENERIC ARGUMENT
|
|
24
|
-
if (!props.expression.typeArguments?.length)
|
|
25
|
-
throw new TransformerError({
|
|
26
|
-
code: "typia.llm.coerce",
|
|
27
|
-
message: "no generic argument.",
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const top: ts.Node = props.expression.typeArguments[0]!;
|
|
31
|
-
if (ts.isTypeNode(top) === false) return props.expression;
|
|
32
|
-
|
|
33
|
-
// GET TYPE AND CONFIG
|
|
34
|
-
const config: Partial<ILlmSchema.IConfig> = LlmMetadataFactory.getConfig({
|
|
35
|
-
context: props.context,
|
|
36
|
-
method: "coerce",
|
|
37
|
-
node: props.expression.typeArguments[1],
|
|
38
|
-
}) as Partial<ILlmSchema.IConfig>;
|
|
39
|
-
|
|
40
|
-
const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
|
|
41
|
-
|
|
42
|
-
if (type.isTypeParameter())
|
|
43
|
-
throw new TransformerError({
|
|
44
|
-
code: "typia.llm.coerce",
|
|
45
|
-
message: "non-specified generic argument.",
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// VALIDATE TYPE
|
|
49
|
-
const analyze = (validate: boolean): MetadataSchema => {
|
|
50
|
-
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
51
|
-
MetadataFactory.analyze({
|
|
52
|
-
checker: props.context.checker,
|
|
53
|
-
transformer: props.context.transformer,
|
|
54
|
-
options: {
|
|
55
|
-
absorb: validate,
|
|
56
|
-
escape: true,
|
|
57
|
-
constant: true,
|
|
58
|
-
validate:
|
|
59
|
-
validate === true
|
|
60
|
-
? (next) =>
|
|
61
|
-
LlmCoerceProgrammer.validate({
|
|
62
|
-
config,
|
|
63
|
-
metadata: next.metadata,
|
|
64
|
-
explore: next.explore,
|
|
65
|
-
})
|
|
66
|
-
: undefined,
|
|
67
|
-
},
|
|
68
|
-
components: new MetadataCollection({
|
|
69
|
-
replace: MetadataCollection.replace,
|
|
70
|
-
}),
|
|
71
|
-
type,
|
|
72
|
-
});
|
|
73
|
-
if (result.success === false)
|
|
74
|
-
throw TransformerError.from({
|
|
75
|
-
code: "typia.llm.coerce",
|
|
76
|
-
errors: result.errors,
|
|
77
|
-
});
|
|
78
|
-
return result.data;
|
|
79
|
-
};
|
|
80
|
-
analyze(true);
|
|
81
|
-
|
|
82
|
-
// GENERATE CODE
|
|
83
|
-
return ts.factory.createCallExpression(
|
|
84
|
-
LlmCoerceProgrammer.write({
|
|
85
|
-
context: props.context,
|
|
86
|
-
modulo: props.modulo,
|
|
87
|
-
metadata: analyze(false),
|
|
88
|
-
name: (top as ts.TypeNode).getFullText().trim(),
|
|
89
|
-
config,
|
|
90
|
-
}),
|
|
91
|
-
undefined,
|
|
92
|
-
props.expression.arguments,
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
LlmCoerceProgrammer,
|
|
3
|
+
LlmMetadataFactory,
|
|
4
|
+
MetadataCollection,
|
|
5
|
+
MetadataFactory,
|
|
6
|
+
MetadataSchema,
|
|
7
|
+
} from "@typia/core";
|
|
8
|
+
import { ILlmSchema, ValidationPipe } from "@typia/interface";
|
|
9
|
+
import ts from "typescript";
|
|
10
|
+
|
|
11
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
12
|
+
import { TransformerError } from "../../TransformerError";
|
|
13
|
+
|
|
14
|
+
export namespace LlmCoerceTransformer {
|
|
15
|
+
export const transform = (props: ITransformProps): ts.Expression => {
|
|
16
|
+
// CHECK PARAMETER
|
|
17
|
+
if (props.expression.arguments.length === 0)
|
|
18
|
+
throw new TransformerError({
|
|
19
|
+
code: "typia.llm.coerce",
|
|
20
|
+
message: "no input value.",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// GET GENERIC ARGUMENT
|
|
24
|
+
if (!props.expression.typeArguments?.length)
|
|
25
|
+
throw new TransformerError({
|
|
26
|
+
code: "typia.llm.coerce",
|
|
27
|
+
message: "no generic argument.",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const top: ts.Node = props.expression.typeArguments[0]!;
|
|
31
|
+
if (ts.isTypeNode(top) === false) return props.expression;
|
|
32
|
+
|
|
33
|
+
// GET TYPE AND CONFIG
|
|
34
|
+
const config: Partial<ILlmSchema.IConfig> = LlmMetadataFactory.getConfig({
|
|
35
|
+
context: props.context,
|
|
36
|
+
method: "coerce",
|
|
37
|
+
node: props.expression.typeArguments[1],
|
|
38
|
+
}) as Partial<ILlmSchema.IConfig>;
|
|
39
|
+
|
|
40
|
+
const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
|
|
41
|
+
|
|
42
|
+
if (type.isTypeParameter())
|
|
43
|
+
throw new TransformerError({
|
|
44
|
+
code: "typia.llm.coerce",
|
|
45
|
+
message: "non-specified generic argument.",
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// VALIDATE TYPE
|
|
49
|
+
const analyze = (validate: boolean): MetadataSchema => {
|
|
50
|
+
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
51
|
+
MetadataFactory.analyze({
|
|
52
|
+
checker: props.context.checker,
|
|
53
|
+
transformer: props.context.transformer,
|
|
54
|
+
options: {
|
|
55
|
+
absorb: validate,
|
|
56
|
+
escape: true,
|
|
57
|
+
constant: true,
|
|
58
|
+
validate:
|
|
59
|
+
validate === true
|
|
60
|
+
? (next) =>
|
|
61
|
+
LlmCoerceProgrammer.validate({
|
|
62
|
+
config,
|
|
63
|
+
metadata: next.metadata,
|
|
64
|
+
explore: next.explore,
|
|
65
|
+
})
|
|
66
|
+
: undefined,
|
|
67
|
+
},
|
|
68
|
+
components: new MetadataCollection({
|
|
69
|
+
replace: MetadataCollection.replace,
|
|
70
|
+
}),
|
|
71
|
+
type,
|
|
72
|
+
});
|
|
73
|
+
if (result.success === false)
|
|
74
|
+
throw TransformerError.from({
|
|
75
|
+
code: "typia.llm.coerce",
|
|
76
|
+
errors: result.errors,
|
|
77
|
+
});
|
|
78
|
+
return result.data;
|
|
79
|
+
};
|
|
80
|
+
analyze(true);
|
|
81
|
+
|
|
82
|
+
// GENERATE CODE
|
|
83
|
+
return ts.factory.createCallExpression(
|
|
84
|
+
LlmCoerceProgrammer.write({
|
|
85
|
+
context: props.context,
|
|
86
|
+
modulo: props.modulo,
|
|
87
|
+
metadata: analyze(false),
|
|
88
|
+
name: (top as ts.TypeNode).getFullText().trim(),
|
|
89
|
+
config,
|
|
90
|
+
}),
|
|
91
|
+
undefined,
|
|
92
|
+
props.expression.arguments,
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -1,81 +1,100 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import {
|
|
2
|
+
LlmApplicationProgrammer,
|
|
3
|
+
LlmControllerProgrammer,
|
|
4
|
+
LlmMetadataFactory,
|
|
5
|
+
MetadataCollection,
|
|
6
|
+
MetadataFactory,
|
|
7
|
+
MetadataSchema,
|
|
8
|
+
} from "@typia/core";
|
|
9
|
+
import { ILlmSchema, ValidationPipe } from "@typia/interface";
|
|
10
|
+
import ts from "typescript";
|
|
11
|
+
|
|
12
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
13
|
+
import { TransformerError } from "../../TransformerError";
|
|
14
|
+
|
|
15
|
+
export namespace LlmControllerTransformer {
|
|
16
|
+
export const transform = (props: ITransformProps): ts.Expression => {
|
|
17
|
+
// GET GENERIC ARGUMENT
|
|
18
|
+
if (!props.expression.typeArguments?.length)
|
|
19
|
+
throw new TransformerError({
|
|
20
|
+
code: "typia.llm.controller",
|
|
21
|
+
message: "no generic argument.",
|
|
22
|
+
});
|
|
23
|
+
const top: ts.Node = props.expression.typeArguments[0]!;
|
|
24
|
+
if (ts.isTypeNode(top) === false) return props.expression;
|
|
25
|
+
|
|
26
|
+
if (props.expression.arguments[0] === undefined)
|
|
27
|
+
throw new TransformerError({
|
|
28
|
+
code: "typia.llm.controller",
|
|
29
|
+
message: "no identifier name.",
|
|
30
|
+
});
|
|
31
|
+
if (props.expression.arguments[1] === undefined)
|
|
32
|
+
throw new TransformerError({
|
|
33
|
+
code: "typia.llm.controller",
|
|
34
|
+
message: "no executor.",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// GET CONFIG
|
|
38
|
+
const config:
|
|
39
|
+
| Partial<
|
|
40
|
+
ILlmSchema.IConfig & {
|
|
41
|
+
equals: boolean;
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
| undefined = LlmMetadataFactory.getConfig({
|
|
45
|
+
context: props.context,
|
|
46
|
+
method: "controller",
|
|
47
|
+
node: props.expression.typeArguments[1],
|
|
48
|
+
});
|
|
49
|
+
const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
|
|
50
|
+
|
|
51
|
+
// VALIDATE TYPE
|
|
52
|
+
const analyze = (validate: boolean): MetadataSchema => {
|
|
53
|
+
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
54
|
+
MetadataFactory.analyze({
|
|
55
|
+
checker: props.context.checker,
|
|
56
|
+
transformer: props.context.transformer,
|
|
57
|
+
options: {
|
|
58
|
+
absorb: validate,
|
|
59
|
+
escape: true,
|
|
60
|
+
constant: true,
|
|
61
|
+
functional: true,
|
|
62
|
+
validate:
|
|
63
|
+
validate === true
|
|
64
|
+
? (next) =>
|
|
65
|
+
LlmApplicationProgrammer.validate({
|
|
66
|
+
config,
|
|
67
|
+
metadata: next.metadata,
|
|
68
|
+
explore: next.explore,
|
|
69
|
+
top: next.top,
|
|
70
|
+
})
|
|
71
|
+
: undefined,
|
|
72
|
+
},
|
|
73
|
+
components: new MetadataCollection({
|
|
74
|
+
replace: MetadataCollection.replace,
|
|
75
|
+
}),
|
|
76
|
+
type,
|
|
77
|
+
});
|
|
78
|
+
if (result.success === false)
|
|
79
|
+
throw TransformerError.from({
|
|
80
|
+
code: "typia.llm.controller",
|
|
81
|
+
errors: result.errors,
|
|
82
|
+
});
|
|
83
|
+
return result.data;
|
|
84
|
+
};
|
|
85
|
+
analyze(true);
|
|
86
|
+
|
|
87
|
+
// GENERATE LLM CONTROLLER
|
|
88
|
+
return LlmControllerProgrammer.write({
|
|
89
|
+
context: props.context,
|
|
90
|
+
modulo: props.modulo,
|
|
91
|
+
metadata: analyze(false),
|
|
92
|
+
className: top.getFullText().trim(),
|
|
93
|
+
config,
|
|
94
|
+
node: top,
|
|
95
|
+
nameArgument: props.expression.arguments[0],
|
|
96
|
+
executeArgument: props.expression.arguments[1],
|
|
97
|
+
configArgument: props.expression.arguments[2],
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LlmCoerceProgrammer,
|
|
3
|
-
LlmMetadataFactory,
|
|
4
|
-
MetadataCollection,
|
|
5
|
-
MetadataFactory,
|
|
6
|
-
MetadataSchema,
|
|
7
|
-
} from "@typia/core";
|
|
8
|
-
import { ILlmSchema, ValidationPipe } from "@typia/interface";
|
|
9
|
-
import ts from "typescript";
|
|
10
|
-
|
|
11
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
12
|
-
import { TransformerError } from "../../TransformerError";
|
|
13
|
-
|
|
14
|
-
export namespace LlmCreateCoerceTransformer {
|
|
15
|
-
export const transform = (props: ITransformProps): ts.Expression => {
|
|
16
|
-
// GET GENERIC ARGUMENT
|
|
17
|
-
if (!props.expression.typeArguments?.length)
|
|
18
|
-
throw new TransformerError({
|
|
19
|
-
code: "typia.llm.createCoerce",
|
|
20
|
-
message: "no generic argument.",
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const top: ts.Node = props.expression.typeArguments[0]!;
|
|
24
|
-
if (ts.isTypeNode(top) === false) return props.expression;
|
|
25
|
-
|
|
26
|
-
// GET TYPE AND CONFIG
|
|
27
|
-
const config: Partial<ILlmSchema.IConfig> = LlmMetadataFactory.getConfig({
|
|
28
|
-
context: props.context,
|
|
29
|
-
method: "createCoerce",
|
|
30
|
-
node: props.expression.typeArguments[1],
|
|
31
|
-
}) as Partial<ILlmSchema.IConfig>;
|
|
32
|
-
|
|
33
|
-
const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
|
|
34
|
-
|
|
35
|
-
if (type.isTypeParameter())
|
|
36
|
-
throw new TransformerError({
|
|
37
|
-
code: "typia.llm.createCoerce",
|
|
38
|
-
message: "non-specified generic argument.",
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// VALIDATE TYPE
|
|
42
|
-
const analyze = (validate: boolean): MetadataSchema => {
|
|
43
|
-
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
44
|
-
MetadataFactory.analyze({
|
|
45
|
-
checker: props.context.checker,
|
|
46
|
-
transformer: props.context.transformer,
|
|
47
|
-
options: {
|
|
48
|
-
absorb: validate,
|
|
49
|
-
escape: true,
|
|
50
|
-
constant: true,
|
|
51
|
-
validate:
|
|
52
|
-
validate === true
|
|
53
|
-
? (next) =>
|
|
54
|
-
LlmCoerceProgrammer.validate({
|
|
55
|
-
config,
|
|
56
|
-
metadata: next.metadata,
|
|
57
|
-
explore: next.explore,
|
|
58
|
-
})
|
|
59
|
-
: undefined,
|
|
60
|
-
},
|
|
61
|
-
components: new MetadataCollection({
|
|
62
|
-
replace: MetadataCollection.replace,
|
|
63
|
-
}),
|
|
64
|
-
type,
|
|
65
|
-
});
|
|
66
|
-
if (result.success === false)
|
|
67
|
-
throw TransformerError.from({
|
|
68
|
-
code: "typia.llm.createCoerce",
|
|
69
|
-
errors: result.errors,
|
|
70
|
-
});
|
|
71
|
-
return result.data;
|
|
72
|
-
};
|
|
73
|
-
analyze(true);
|
|
74
|
-
|
|
75
|
-
// GENERATE CODE (factory returns the function directly)
|
|
76
|
-
return LlmCoerceProgrammer.write({
|
|
77
|
-
context: props.context,
|
|
78
|
-
modulo: props.modulo,
|
|
79
|
-
metadata: analyze(false),
|
|
80
|
-
name: (top as ts.TypeNode).getFullText().trim(),
|
|
81
|
-
config,
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
LlmCoerceProgrammer,
|
|
3
|
+
LlmMetadataFactory,
|
|
4
|
+
MetadataCollection,
|
|
5
|
+
MetadataFactory,
|
|
6
|
+
MetadataSchema,
|
|
7
|
+
} from "@typia/core";
|
|
8
|
+
import { ILlmSchema, ValidationPipe } from "@typia/interface";
|
|
9
|
+
import ts from "typescript";
|
|
10
|
+
|
|
11
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
12
|
+
import { TransformerError } from "../../TransformerError";
|
|
13
|
+
|
|
14
|
+
export namespace LlmCreateCoerceTransformer {
|
|
15
|
+
export const transform = (props: ITransformProps): ts.Expression => {
|
|
16
|
+
// GET GENERIC ARGUMENT
|
|
17
|
+
if (!props.expression.typeArguments?.length)
|
|
18
|
+
throw new TransformerError({
|
|
19
|
+
code: "typia.llm.createCoerce",
|
|
20
|
+
message: "no generic argument.",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const top: ts.Node = props.expression.typeArguments[0]!;
|
|
24
|
+
if (ts.isTypeNode(top) === false) return props.expression;
|
|
25
|
+
|
|
26
|
+
// GET TYPE AND CONFIG
|
|
27
|
+
const config: Partial<ILlmSchema.IConfig> = LlmMetadataFactory.getConfig({
|
|
28
|
+
context: props.context,
|
|
29
|
+
method: "createCoerce",
|
|
30
|
+
node: props.expression.typeArguments[1],
|
|
31
|
+
}) as Partial<ILlmSchema.IConfig>;
|
|
32
|
+
|
|
33
|
+
const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
|
|
34
|
+
|
|
35
|
+
if (type.isTypeParameter())
|
|
36
|
+
throw new TransformerError({
|
|
37
|
+
code: "typia.llm.createCoerce",
|
|
38
|
+
message: "non-specified generic argument.",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// VALIDATE TYPE
|
|
42
|
+
const analyze = (validate: boolean): MetadataSchema => {
|
|
43
|
+
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
44
|
+
MetadataFactory.analyze({
|
|
45
|
+
checker: props.context.checker,
|
|
46
|
+
transformer: props.context.transformer,
|
|
47
|
+
options: {
|
|
48
|
+
absorb: validate,
|
|
49
|
+
escape: true,
|
|
50
|
+
constant: true,
|
|
51
|
+
validate:
|
|
52
|
+
validate === true
|
|
53
|
+
? (next) =>
|
|
54
|
+
LlmCoerceProgrammer.validate({
|
|
55
|
+
config,
|
|
56
|
+
metadata: next.metadata,
|
|
57
|
+
explore: next.explore,
|
|
58
|
+
})
|
|
59
|
+
: undefined,
|
|
60
|
+
},
|
|
61
|
+
components: new MetadataCollection({
|
|
62
|
+
replace: MetadataCollection.replace,
|
|
63
|
+
}),
|
|
64
|
+
type,
|
|
65
|
+
});
|
|
66
|
+
if (result.success === false)
|
|
67
|
+
throw TransformerError.from({
|
|
68
|
+
code: "typia.llm.createCoerce",
|
|
69
|
+
errors: result.errors,
|
|
70
|
+
});
|
|
71
|
+
return result.data;
|
|
72
|
+
};
|
|
73
|
+
analyze(true);
|
|
74
|
+
|
|
75
|
+
// GENERATE CODE (factory returns the function directly)
|
|
76
|
+
return LlmCoerceProgrammer.write({
|
|
77
|
+
context: props.context,
|
|
78
|
+
modulo: props.modulo,
|
|
79
|
+
metadata: analyze(false),
|
|
80
|
+
name: (top as ts.TypeNode).getFullText().trim(),
|
|
81
|
+
config,
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
}
|