@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
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Jeongho Nam
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Jeongho Nam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# `@typia/transform`
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
6
|
-
[](https://www.npmjs.com/package/typia)
|
|
7
|
-
[](https://www.npmjs.com/package/typia)
|
|
8
|
-
[](https://github.com/samchon/typia/actions?query=workflow%3Atest)
|
|
9
|
-
[](https://typia.io/docs/)
|
|
10
|
-
[](https://gurubase.io/g/typia)
|
|
11
|
-
[](https://discord.gg/E94XhzrUCZ)
|
|
12
|
-
|
|
13
|
-
TypeScript transformer plugin for [`typia`](https://github.com/samchon/typia).
|
|
14
|
-
|
|
15
|
-
Transforms `typia.*<T>()` function calls into optimized runtime code at compile time by analyzing TypeScript types.
|
|
16
|
-
|
|
17
|
-
This is an **internal package** of `typia`. You don't need to install it directly — it is automatically included as a dependency of `typia`.
|
|
18
|
-
|
|
19
|
-
## Key Exports
|
|
20
|
-
|
|
21
|
-
| Export | Description |
|
|
22
|
-
|--------|-------------|
|
|
23
|
-
| `transform()` | TypeScript transformer factory — the main entry point for `ts-patch` and `ttypescript` |
|
|
24
|
-
| `TypiaGenerator.build()` | Programmatic build API for generating transformed output files |
|
|
25
|
-
| `ImportTransformer` | Rewrites import paths and removes unused typia imports after transformation |
|
|
1
|
+
# `@typia/transform`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
6
|
+
[](https://www.npmjs.com/package/typia)
|
|
7
|
+
[](https://www.npmjs.com/package/typia)
|
|
8
|
+
[](https://github.com/samchon/typia/actions?query=workflow%3Atest)
|
|
9
|
+
[](https://typia.io/docs/)
|
|
10
|
+
[](https://gurubase.io/g/typia)
|
|
11
|
+
[](https://discord.gg/E94XhzrUCZ)
|
|
12
|
+
|
|
13
|
+
TypeScript transformer plugin for [`typia`](https://github.com/samchon/typia).
|
|
14
|
+
|
|
15
|
+
Transforms `typia.*<T>()` function calls into optimized runtime code at compile time by analyzing TypeScript types.
|
|
16
|
+
|
|
17
|
+
This is an **internal package** of `typia`. You don't need to install it directly — it is automatically included as a dependency of `typia`.
|
|
18
|
+
|
|
19
|
+
## Key Exports
|
|
20
|
+
|
|
21
|
+
| Export | Description |
|
|
22
|
+
|--------|-------------|
|
|
23
|
+
| `transform()` | TypeScript transformer factory — the main entry point for `ts-patch` and `ttypescript` |
|
|
24
|
+
| `TypiaGenerator.build()` | Programmatic build API for generating transformed output files |
|
|
25
|
+
| `ImportTransformer` | Rewrites import paths and removes unused typia imports after transformation |
|
package/lib/FileTransformer.js
CHANGED
|
@@ -56,12 +56,14 @@ var FileTransformer;
|
|
|
56
56
|
if (!isTransformerError(exp))
|
|
57
57
|
throw exp;
|
|
58
58
|
// REPORT DIAGNOSTIC
|
|
59
|
-
const diagnostic =
|
|
60
|
-
|
|
59
|
+
const diagnostic = {
|
|
60
|
+
file: props.node.getSourceFile(),
|
|
61
|
+
start: props.node.getStart(),
|
|
62
|
+
length: props.node.getWidth(),
|
|
63
|
+
messageText: exp.message,
|
|
61
64
|
category: typescript_1.default.DiagnosticCategory.Error,
|
|
62
|
-
message: exp.message,
|
|
63
65
|
code: `(${exp.code})`,
|
|
64
|
-
}
|
|
66
|
+
};
|
|
65
67
|
props.context.extras.addDiagnostic(diagnostic);
|
|
66
68
|
return null;
|
|
67
69
|
}
|
|
@@ -85,13 +87,13 @@ const isTransformerError = (error) => typeof error === "object" &&
|
|
|
85
87
|
typeof error.code === "string" &&
|
|
86
88
|
typeof error.message === "string";
|
|
87
89
|
const checkJsDocParsingMode = new utils_1.Singleton((context, file) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
context.extras.addDiagnostic(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
const jsDocParsingMode = file.jsDocParsingMode;
|
|
91
|
+
if (typeof jsDocParsingMode === "number" && jsDocParsingMode !== 0) {
|
|
92
|
+
context.extras.addDiagnostic({
|
|
93
|
+
file,
|
|
94
|
+
start: 0,
|
|
95
|
+
length: 0,
|
|
96
|
+
messageText: [
|
|
95
97
|
`Run "npx typia setup" or "npx typia patch" command again.`,
|
|
96
98
|
``,
|
|
97
99
|
`Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments. Therefore, "typia" also cannot utilize those JSDoc comments too, and it damages on some features of "typia" like "comment tags" or "JSON schema" generator.`,
|
|
@@ -100,7 +102,9 @@ const checkJsDocParsingMode = new utils_1.Singleton((context, file) => {
|
|
|
100
102
|
``,
|
|
101
103
|
` - reference: https://github.com/microsoft/TypeScript/pull/55739`,
|
|
102
104
|
].join("\n"),
|
|
103
|
-
|
|
105
|
+
category: typescript_1.default.DiagnosticCategory.Warning,
|
|
106
|
+
code: `(typia setup)`,
|
|
107
|
+
});
|
|
104
108
|
}
|
|
105
109
|
});
|
|
106
110
|
//# sourceMappingURL=FileTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTransformer.js","sourceRoot":"","sources":["../src/FileTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,sCAA8D;AAC9D,wCAAyC;AACzC,4DAA4B;AAE5B,uDAAoD;AAGpD;;;;;;;;GAQG;AACH,IAAiB,eAAe,
|
|
1
|
+
{"version":3,"file":"FileTransformer.js","sourceRoot":"","sources":["../src/FileTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,sCAA8D;AAC9D,wCAAyC;AACzC,4DAA4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OSTIC
|
|
54
|
-
const diagnostic =
|
|
55
|
-
|
|
54
|
+
const diagnostic = {
|
|
55
|
+
file: props.node.getSourceFile(),
|
|
56
|
+
start: props.node.getStart(),
|
|
57
|
+
length: props.node.getWidth(),
|
|
58
|
+
messageText: exp.message,
|
|
56
59
|
category: ts.DiagnosticCategory.Error,
|
|
57
|
-
message: exp.message,
|
|
58
60
|
code: `(${exp.code})`,
|
|
59
|
-
}
|
|
61
|
+
};
|
|
60
62
|
props.context.extras.addDiagnostic(diagnostic);
|
|
61
63
|
return null;
|
|
62
64
|
}
|
|
@@ -80,13 +82,13 @@ const isTransformerError = (error) => typeof error === "object" &&
|
|
|
80
82
|
typeof error.code === "string" &&
|
|
81
83
|
typeof error.message === "string";
|
|
82
84
|
const checkJsDocParsingMode = new Singleton((context, file) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
context.extras.addDiagnostic(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
const jsDocParsingMode = file.jsDocParsingMode;
|
|
86
|
+
if (typeof jsDocParsingMode === "number" && jsDocParsingMode !== 0) {
|
|
87
|
+
context.extras.addDiagnostic({
|
|
88
|
+
file,
|
|
89
|
+
start: 0,
|
|
90
|
+
length: 0,
|
|
91
|
+
messageText: [
|
|
90
92
|
`Run "npx typia setup" or "npx typia patch" command again.`,
|
|
91
93
|
``,
|
|
92
94
|
`Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments. Therefore, "typia" also cannot utilize those JSDoc comments too, and it damages on some features of "typia" like "comment tags" or "JSON schema" generator.`,
|
|
@@ -95,7 +97,9 @@ const checkJsDocParsingMode = new Singleton((context, file) => {
|
|
|
95
97
|
``,
|
|
96
98
|
` - reference: https://github.com/microsoft/TypeScript/pull/55739`,
|
|
97
99
|
].join("\n"),
|
|
98
|
-
|
|
100
|
+
category: ts.DiagnosticCategory.Warning,
|
|
101
|
+
code: `(typia setup)`,
|
|
102
|
+
});
|
|
99
103
|
}
|
|
100
104
|
});
|
|
101
105
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTransformer.mjs","sources":["../src/FileTransformer.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAOA;;;;;;;;AAQG;AACG,IAAW;AAAjB,CAAA,UAAiB,eAAe,EAAA;AACjB,IAAA,eAAA,CAAA,SAAS,GACpB,CAAC,YAA6D,KAC9D,CAAC,WAAqC,KACtC,CAAC,IAAmB,KAAmB;QACrC,IAAI,IAAI,CAAC,iBAAiB;AAAE,YAAA,OAAO,IAAI;AAEvC,QAAA,MAAM,QAAQ,GAAqB,IAAI,gBAAgB,CAAC;AACtD,YAAA,cAAc,EAAE,kBAAkB;AAClC,YAAA,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO;AACtC,SAAA,CAAC;AACF,QAAA,MAAM,OAAO,GAAkB;AAC7B,YAAA,GAAG,YAAY;YACf,WAAW;YACX,QAAQ;SACT;AACD,QAAA,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC;AAExC,QAAA,IAAI,GAAG,EAAE,CAAC,cAAc,CACtB,IAAI,EACJ,CAAC,IAAI,KACH,YAAY,CAAC;YACX,OAAO;YACP,IAAI;SACL,CAAC,EACJ,WAAW,CACZ;AACD,QAAA,MAAM,KAAK,GAAW,2BAA2B,CAAC,IAAI,CAAC;AACvD,QAAA,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAChC,IAAI,EACJ;YACE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;YAClC,GAAG,QAAQ,CAAC,YAAY,EAAE;AAC1B,YAAA,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;AAChC,SAAA,EACD,KAAK,EACL,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,sBAAsB,CAC5B;AACH,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AE;AAClE,QAAA,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;YAC3B,IAAI;AACJ,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,WAAW,EAAE;gBACX,CAAA,yDAAA,CAA2D;gBAC3D,CAAA,CAAE;gBACF,CAAA,8NAAA,CAAgO;gBAChO,CAAA,CAAE;gBACF,CAAA,8IAAA,CAAgJ;gBAChJ,CAAA,CAAE;gBACF,CAAA,iEAAA,CAAmE;aACpE,CAAC,IAAI,CAAC,IAAI,CAAC;AACZ,YAAA,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO;AACvC,YAAA,IAAI,EAAE,CAAA,aAAA,CAAsB;AAC7B,SAAA,CAAC;IACJ;AACF,CAAC,CACF;;;;"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { ITypiaContext } from "@typia/core";
|
|
2
1
|
import ts from "typescript";
|
|
3
2
|
import { ITransformProps } from "../../ITransformProps";
|
|
4
3
|
export declare namespace LlmApplicationTransformer {
|
|
5
4
|
const transform: (props: ITransformProps) => ts.Expression;
|
|
6
|
-
const getConfigArgument: (props: {
|
|
7
|
-
context: ITypiaContext;
|
|
8
|
-
argument: ts.Expression;
|
|
9
|
-
equals?: boolean | undefined;
|
|
10
|
-
}) => ts.ObjectLiteralExpression;
|
|
11
5
|
}
|
|
@@ -10,7 +10,7 @@ const TransformerError_1 = require("../../TransformerError");
|
|
|
10
10
|
var LlmApplicationTransformer;
|
|
11
11
|
(function (LlmApplicationTransformer) {
|
|
12
12
|
LlmApplicationTransformer.transform = (props) => {
|
|
13
|
-
var _a;
|
|
13
|
+
var _a, _b;
|
|
14
14
|
// GET GENERIC ARGUMENT
|
|
15
15
|
if (!((_a = props.expression.typeArguments) === null || _a === void 0 ? void 0 : _a.length))
|
|
16
16
|
throw new TransformerError_1.TransformerError({
|
|
@@ -66,88 +66,10 @@ var LlmApplicationTransformer;
|
|
|
66
66
|
metadata: analyze(false),
|
|
67
67
|
name: top.getFullText().trim(),
|
|
68
68
|
config,
|
|
69
|
+
configArgument: ((_b = props.expression.arguments) === null || _b === void 0 ? void 0 : _b[0]) !== undefined
|
|
70
|
+
? props.expression.arguments[0]
|
|
71
|
+
: undefined,
|
|
69
72
|
});
|
|
70
73
|
};
|
|
71
|
-
/** @internal */
|
|
72
|
-
LlmApplicationTransformer.decompose = (method, props) => {
|
|
73
|
-
var _a;
|
|
74
|
-
// GET GENERIC ARGUMENT
|
|
75
|
-
if (!((_a = props.expression.typeArguments) === null || _a === void 0 ? void 0 : _a.length))
|
|
76
|
-
throw new TransformerError_1.TransformerError({
|
|
77
|
-
code: `typia.llm.${method}`,
|
|
78
|
-
message: "no generic argument.",
|
|
79
|
-
});
|
|
80
|
-
const top = props.expression.typeArguments[0];
|
|
81
|
-
if (typescript_1.default.isTypeNode(top) === false)
|
|
82
|
-
return null;
|
|
83
|
-
// GET TYPE
|
|
84
|
-
const config = core_1.LlmMetadataFactory.getConfig({
|
|
85
|
-
context: props.context,
|
|
86
|
-
method,
|
|
87
|
-
node: props.expression.typeArguments[1],
|
|
88
|
-
});
|
|
89
|
-
const type = props.context.checker.getTypeFromTypeNode(top);
|
|
90
|
-
// VALIDATE TYPE
|
|
91
|
-
const analyze = (validate) => {
|
|
92
|
-
const result = core_1.MetadataFactory.analyze({
|
|
93
|
-
checker: props.context.checker,
|
|
94
|
-
transformer: props.context.transformer,
|
|
95
|
-
options: {
|
|
96
|
-
absorb: validate,
|
|
97
|
-
escape: true,
|
|
98
|
-
constant: true,
|
|
99
|
-
functional: true,
|
|
100
|
-
validate: validate === true
|
|
101
|
-
? (next) => core_1.LlmApplicationProgrammer.validate({
|
|
102
|
-
config,
|
|
103
|
-
metadata: next.metadata,
|
|
104
|
-
explore: next.explore,
|
|
105
|
-
top: next.top,
|
|
106
|
-
})
|
|
107
|
-
: undefined,
|
|
108
|
-
},
|
|
109
|
-
components: new core_1.MetadataCollection({
|
|
110
|
-
replace: core_1.MetadataCollection.replace,
|
|
111
|
-
}),
|
|
112
|
-
type,
|
|
113
|
-
});
|
|
114
|
-
if (result.success === false)
|
|
115
|
-
throw TransformerError_1.TransformerError.from({
|
|
116
|
-
code: `typia.llm.${method}`,
|
|
117
|
-
errors: result.errors,
|
|
118
|
-
});
|
|
119
|
-
return result.data;
|
|
120
|
-
};
|
|
121
|
-
analyze(true);
|
|
122
|
-
// GENERATE LLM APPLICATION
|
|
123
|
-
return {
|
|
124
|
-
application: core_1.LlmApplicationProgrammer.writeApplication({
|
|
125
|
-
context: props.context,
|
|
126
|
-
modulo: props.modulo,
|
|
127
|
-
metadata: analyze(false),
|
|
128
|
-
config,
|
|
129
|
-
name: top.getFullText().trim(),
|
|
130
|
-
}),
|
|
131
|
-
node: top,
|
|
132
|
-
type,
|
|
133
|
-
config,
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
LlmApplicationTransformer.getConfigArgument = (props) => {
|
|
137
|
-
const satisfiesTypeNode = typescript_1.default.factory.createTypeReferenceNode(typescript_1.default.factory.createIdentifier("Partial"), [
|
|
138
|
-
typescript_1.default.factory.createTypeReferenceNode(typescript_1.default.factory.createIdentifier("Pick"), [
|
|
139
|
-
typescript_1.default.factory.createImportTypeNode(typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral("typia")), undefined, typescript_1.default.factory.createQualifiedName(typescript_1.default.factory.createIdentifier("ILlmApplication"), typescript_1.default.factory.createIdentifier("IConfig")), undefined, false),
|
|
140
|
-
typescript_1.default.factory.createUnionTypeNode([
|
|
141
|
-
typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral("validate")),
|
|
142
|
-
]),
|
|
143
|
-
]),
|
|
144
|
-
]);
|
|
145
|
-
return typescript_1.default.factory.createObjectLiteralExpression([
|
|
146
|
-
typescript_1.default.factory.createSpreadAssignment(typescript_1.default.factory.createSatisfiesExpression(props.argument, satisfiesTypeNode)),
|
|
147
|
-
typescript_1.default.factory.createPropertyAssignment("equals", props.equals === true
|
|
148
|
-
? typescript_1.default.factory.createTrue()
|
|
149
|
-
: typescript_1.default.factory.createFalse()),
|
|
150
|
-
], true);
|
|
151
|
-
};
|
|
152
74
|
})(LlmApplicationTransformer || (exports.LlmApplicationTransformer = LlmApplicationTransformer = {}));
|
|
153
75
|
//# sourceMappingURL=LlmApplicationTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmApplicationTransformer.js","sourceRoot":"","sources":["../../../src/features/llm/LlmApplicationTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"LlmApplicationTransformer.js","sourceRoot":"","sources":["../../../src/features/llm/LlmApplicationTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,sCAMqB;AAErB,4DAA4B;AAG5B,6DAA0D;AAE1D,IAAiB,yBAAyB,CA2EzC;AA3ED,WAAiB,yBAAyB;IAC3B,mCAAS,GAAG,CAAC,KAAsB,EAAiB,EAAE;;QACjE,uBAAuB;QACvB,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,aAAa,0CAAE,MAAM,CAAA;YACzC,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,sBAAsB;aAChC,CAAC,CAAC;QACL,MAAM,GAAG,GAAY,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC;QACxD,IAAI,oBAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC,UAAU,CAAC;QAE1D,aAAa;QACb,MAAM,MAAM,GAMI,yBAAkB,CAAC,SAAS,CAAC;YAC3C,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;SACxC,CAAC,CAAC;QACH,MAAM,IAAI,GAAY,KA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B,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;YAC9B,MAAM;YACN,cAAc,EACZ,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAG,CAAC,CAAC,MAAK,SAAS;gBAC3C,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC/B,CAAC,CAAC,SAAS;SAChB,CAAC,CAAC;IACL,CAAC,CAAC;AAEJ,CAAC,EA3EgB,yBAAyB,yCAAzB,yBAAyB,QA2EzC"}
|
|
@@ -60,88 +60,11 @@ var LlmApplicationTransformer;
|
|
|
60
60
|
metadata: analyze(false),
|
|
61
61
|
name: top.getFullText().trim(),
|
|
62
62
|
config,
|
|
63
|
+
configArgument: props.expression.arguments?.[0] !== undefined
|
|
64
|
+
? props.expression.arguments[0]
|
|
65
|
+
: undefined,
|
|
63
66
|
});
|
|
64
67
|
};
|
|
65
|
-
/** @internal */
|
|
66
|
-
LlmApplicationTransformer.decompose = (method, props) => {
|
|
67
|
-
// GET GENERIC ARGUMENT
|
|
68
|
-
if (!props.expression.typeArguments?.length)
|
|
69
|
-
throw new TransformerError({
|
|
70
|
-
code: `typia.llm.${method}`,
|
|
71
|
-
message: "no generic argument.",
|
|
72
|
-
});
|
|
73
|
-
const top = props.expression.typeArguments[0];
|
|
74
|
-
if (ts.isTypeNode(top) === false)
|
|
75
|
-
return null;
|
|
76
|
-
// GET TYPE
|
|
77
|
-
const config = LlmMetadataFactory.getConfig({
|
|
78
|
-
context: props.context,
|
|
79
|
-
method,
|
|
80
|
-
node: props.expression.typeArguments[1],
|
|
81
|
-
});
|
|
82
|
-
const type = props.context.checker.getTypeFromTypeNode(top);
|
|
83
|
-
// VALIDATE TYPE
|
|
84
|
-
const analyze = (validate) => {
|
|
85
|
-
const result = MetadataFactory.analyze({
|
|
86
|
-
checker: props.context.checker,
|
|
87
|
-
transformer: props.context.transformer,
|
|
88
|
-
options: {
|
|
89
|
-
absorb: validate,
|
|
90
|
-
escape: true,
|
|
91
|
-
constant: true,
|
|
92
|
-
functional: true,
|
|
93
|
-
validate: validate === true
|
|
94
|
-
? (next) => LlmApplicationProgrammer.validate({
|
|
95
|
-
config,
|
|
96
|
-
metadata: next.metadata,
|
|
97
|
-
explore: next.explore,
|
|
98
|
-
top: next.top,
|
|
99
|
-
})
|
|
100
|
-
: undefined,
|
|
101
|
-
},
|
|
102
|
-
components: new MetadataCollection({
|
|
103
|
-
replace: MetadataCollection.replace,
|
|
104
|
-
}),
|
|
105
|
-
type,
|
|
106
|
-
});
|
|
107
|
-
if (result.success === false)
|
|
108
|
-
throw TransformerError.from({
|
|
109
|
-
code: `typia.llm.${method}`,
|
|
110
|
-
errors: result.errors,
|
|
111
|
-
});
|
|
112
|
-
return result.data;
|
|
113
|
-
};
|
|
114
|
-
analyze(true);
|
|
115
|
-
// GENERATE LLM APPLICATION
|
|
116
|
-
return {
|
|
117
|
-
application: LlmApplicationProgrammer.writeApplication({
|
|
118
|
-
context: props.context,
|
|
119
|
-
modulo: props.modulo,
|
|
120
|
-
metadata: analyze(false),
|
|
121
|
-
config,
|
|
122
|
-
name: top.getFullText().trim(),
|
|
123
|
-
}),
|
|
124
|
-
node: top,
|
|
125
|
-
type,
|
|
126
|
-
config,
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
LlmApplicationTransformer.getConfigArgument = (props) => {
|
|
130
|
-
const satisfiesTypeNode = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("Partial"), [
|
|
131
|
-
ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("Pick"), [
|
|
132
|
-
ts.factory.createImportTypeNode(ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral("typia")), undefined, ts.factory.createQualifiedName(ts.factory.createIdentifier("ILlmApplication"), ts.factory.createIdentifier("IConfig")), undefined, false),
|
|
133
|
-
ts.factory.createUnionTypeNode([
|
|
134
|
-
ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral("validate")),
|
|
135
|
-
]),
|
|
136
|
-
]),
|
|
137
|
-
]);
|
|
138
|
-
return ts.factory.createObjectLiteralExpression([
|
|
139
|
-
ts.factory.createSpreadAssignment(ts.factory.createSatisfiesExpression(props.argument, satisfiesTypeNode)),
|
|
140
|
-
ts.factory.createPropertyAssignment("equals", props.equals === true
|
|
141
|
-
? ts.factory.createTrue()
|
|
142
|
-
: ts.factory.createFalse()),
|
|
143
|
-
], true);
|
|
144
|
-
};
|
|
145
68
|
})(LlmApplicationTransformer || (LlmApplicationTransformer = {}));
|
|
146
69
|
|
|
147
70
|
export { LlmApplicationTransformer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmApplicationTransformer.mjs","sources":["../../../src/features/llm/LlmApplicationTransformer.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"LlmApplicationTransformer.mjs","sources":["../../../src/features/llm/LlmApplicationTransformer.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAaM,IAAW;AAAjB,CAAA,UAAiB,yBAAyB,EAAA;AAC3B,IAAA,yBAAA,CAAA,SAAS,GAAG,CAAC,KAAsB,KAAmB;;AAEjE,QAAA,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,MAAM;YACzC,MAAM,IAAI,gBAAgB,CAAC;AACzB,gBAAA,IAAI,EAAE,uBAAuB;AAC7B,gBAAA,OAAO,EAAE,sBAAsB;AAChC,aAAA,CAAC;QACJ,MAAM,GAAG,GAAY,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAE;AACvD,QAAA,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC,UAAU;;AAGzD,QAAA,MAAM,MAAM,GAMI,kBAAkB,CAAC,SAAS,CAAC;YAC3C,OAAO,EAAE,KAAK,CAAC,OAAO;AACtB,YAAA,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,KAA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AM,EAAE,KAAK,CAAC,MAAM;AACpB,YAAA,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;AACxB,YAAA,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;YAC9B,MAAM;YACN,cAAc,EACZ,KAAK,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK;kBAChC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC9B,kBAAE,SAAS;AAChB,SAAA,CAAC;AACJ,IAAA,CAAC;AAEH,CAAC,EA3EgB,yBAAyB,KAAzB,yBAAyB,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -7,52 +7,80 @@ exports.LlmControllerTransformer = void 0;
|
|
|
7
7
|
const core_1 = require("@typia/core");
|
|
8
8
|
const typescript_1 = __importDefault(require("typescript"));
|
|
9
9
|
const TransformerError_1 = require("../../TransformerError");
|
|
10
|
-
const LlmApplicationTransformer_1 = require("./LlmApplicationTransformer");
|
|
11
10
|
var LlmControllerTransformer;
|
|
12
11
|
(function (LlmControllerTransformer) {
|
|
13
12
|
LlmControllerTransformer.transform = (props) => {
|
|
14
|
-
var _a
|
|
15
|
-
|
|
16
|
-
if (
|
|
13
|
+
var _a;
|
|
14
|
+
// GET GENERIC ARGUMENT
|
|
15
|
+
if (!((_a = props.expression.typeArguments) === null || _a === void 0 ? void 0 : _a.length))
|
|
16
|
+
throw new TransformerError_1.TransformerError({
|
|
17
|
+
code: "typia.llm.controller",
|
|
18
|
+
message: "no generic argument.",
|
|
19
|
+
});
|
|
20
|
+
const top = props.expression.typeArguments[0];
|
|
21
|
+
if (typescript_1.default.isTypeNode(top) === false)
|
|
17
22
|
return props.expression;
|
|
18
|
-
|
|
23
|
+
if (props.expression.arguments[0] === undefined)
|
|
19
24
|
throw new TransformerError_1.TransformerError({
|
|
20
|
-
code:
|
|
21
|
-
message:
|
|
25
|
+
code: "typia.llm.controller",
|
|
26
|
+
message: "no identifier name.",
|
|
22
27
|
});
|
|
23
|
-
|
|
28
|
+
if (props.expression.arguments[1] === undefined)
|
|
24
29
|
throw new TransformerError_1.TransformerError({
|
|
25
|
-
code:
|
|
26
|
-
message:
|
|
30
|
+
code: "typia.llm.controller",
|
|
31
|
+
message: "no executor.",
|
|
27
32
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
// GET CONFIG
|
|
34
|
+
const config = core_1.LlmMetadataFactory.getConfig({
|
|
35
|
+
context: props.context,
|
|
36
|
+
method: "controller",
|
|
37
|
+
node: props.expression.typeArguments[1],
|
|
32
38
|
});
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const type = props.context.checker.getTypeFromTypeNode(top);
|
|
40
|
+
// VALIDATE TYPE
|
|
41
|
+
const analyze = (validate) => {
|
|
42
|
+
const result = core_1.MetadataFactory.analyze({
|
|
43
|
+
checker: props.context.checker,
|
|
44
|
+
transformer: props.context.transformer,
|
|
45
|
+
options: {
|
|
46
|
+
absorb: validate,
|
|
47
|
+
escape: true,
|
|
48
|
+
constant: true,
|
|
49
|
+
functional: true,
|
|
50
|
+
validate: validate === true
|
|
51
|
+
? (next) => core_1.LlmApplicationProgrammer.validate({
|
|
52
|
+
config,
|
|
53
|
+
metadata: next.metadata,
|
|
54
|
+
explore: next.explore,
|
|
55
|
+
top: next.top,
|
|
56
|
+
})
|
|
57
|
+
: undefined,
|
|
58
|
+
},
|
|
59
|
+
components: new core_1.MetadataCollection({
|
|
60
|
+
replace: core_1.MetadataCollection.replace,
|
|
61
|
+
}),
|
|
62
|
+
type,
|
|
63
|
+
});
|
|
64
|
+
if (result.success === false)
|
|
65
|
+
throw TransformerError_1.TransformerError.from({
|
|
66
|
+
code: "typia.llm.controller",
|
|
67
|
+
errors: result.errors,
|
|
68
|
+
});
|
|
69
|
+
return result.data;
|
|
70
|
+
};
|
|
71
|
+
analyze(true);
|
|
72
|
+
// GENERATE LLM CONTROLLER
|
|
73
|
+
return core_1.LlmControllerProgrammer.write({
|
|
74
|
+
context: props.context,
|
|
75
|
+
modulo: props.modulo,
|
|
76
|
+
metadata: analyze(false),
|
|
77
|
+
className: top.getFullText().trim(),
|
|
78
|
+
config,
|
|
79
|
+
node: top,
|
|
80
|
+
nameArgument: props.expression.arguments[0],
|
|
81
|
+
executeArgument: props.expression.arguments[1],
|
|
82
|
+
configArgument: props.expression.arguments[2],
|
|
37
83
|
});
|
|
38
|
-
const value = typescript_1.default.factory.createObjectLiteralExpression([
|
|
39
|
-
typescript_1.default.factory.createPropertyAssignment("protocol", typescript_1.default.factory.createStringLiteral("class")),
|
|
40
|
-
typescript_1.default.factory.createPropertyAssignment("name", props.expression.arguments[0]),
|
|
41
|
-
typescript_1.default.factory.createPropertyAssignment("execute", props.expression.arguments[1]),
|
|
42
|
-
typescript_1.default.factory.createPropertyAssignment("application", typescript_1.default.factory.createCallExpression(props.context.importer.internal("llmApplicationFinalize"), undefined, [
|
|
43
|
-
typescript_1.default.factory.createAsExpression(typescript_1.default.factory.createSatisfiesExpression(core_1.LiteralFactory.write(dec.application), primitiveTypeNode), primitiveTypeNode),
|
|
44
|
-
...(((_a = props.expression.arguments) === null || _a === void 0 ? void 0 : _a[2]) !== undefined
|
|
45
|
-
? [
|
|
46
|
-
LlmApplicationTransformer_1.LlmApplicationTransformer.getConfigArgument({
|
|
47
|
-
context: props.context,
|
|
48
|
-
argument: props.expression.arguments[2],
|
|
49
|
-
equals: (_b = dec.config) === null || _b === void 0 ? void 0 : _b.equals,
|
|
50
|
-
}),
|
|
51
|
-
]
|
|
52
|
-
: []),
|
|
53
|
-
])),
|
|
54
|
-
], true);
|
|
55
|
-
return typescript_1.default.factory.createAsExpression(typescript_1.default.factory.createSatisfiesExpression(value, typeNode), typeNode);
|
|
56
84
|
};
|
|
57
85
|
})(LlmControllerTransformer || (exports.LlmControllerTransformer = LlmControllerTransformer = {}));
|
|
58
86
|
//# sourceMappingURL=LlmControllerTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmControllerTransformer.js","sourceRoot":"","sources":["../../../src/features/llm/LlmControllerTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"LlmControllerTransformer.js","sourceRoot":"","sources":["../../../src/features/llm/LlmControllerTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,sCAOqB;AAErB,4DAA4B;AAG5B,6DAA0D;AAE1D,IAAiB,wBAAwB,CAqFxC;AArFD,WAAiB,wBAAwB;IAC1B,kCAAS,GAAG,CAAC,KAAsB,EAAiB,EAAE;;QACjE,uBAAuB;QACvB,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,aAAa,0CAAE,MAAM,CAAA;YACzC,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,sBAAsB;aAChC,CAAC,CAAC;QACL,MAAM,GAAG,GAAY,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC;QACxD,IAAI,oBAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC,UAAU,CAAC;QAE1D,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS;YAC7C,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,qBAAqB;aAC/B,CAAC,CAAC;QACL,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS;YAC7C,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,cAAc;aACxB,CAAC,CAAC;QAEL,aAAa;QACb,MAAM,MAAM,GAMI,yBAAkB,CAAC,SAAS,CAAC;YAC3C,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAA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