@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,52 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LlmMetadataFactory, LlmControllerProgrammer, MetadataFactory, MetadataCollection, LlmApplicationProgrammer } from '@typia/core';
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { TransformerError } from '../../TransformerError.mjs';
|
|
4
|
-
import { LlmApplicationTransformer } from './LlmApplicationTransformer.mjs';
|
|
5
4
|
|
|
6
5
|
var LlmControllerTransformer;
|
|
7
6
|
(function (LlmControllerTransformer) {
|
|
8
7
|
LlmControllerTransformer.transform = (props) => {
|
|
9
|
-
|
|
10
|
-
if (
|
|
8
|
+
// GET GENERIC ARGUMENT
|
|
9
|
+
if (!props.expression.typeArguments?.length)
|
|
10
|
+
throw new TransformerError({
|
|
11
|
+
code: "typia.llm.controller",
|
|
12
|
+
message: "no generic argument.",
|
|
13
|
+
});
|
|
14
|
+
const top = props.expression.typeArguments[0];
|
|
15
|
+
if (ts.isTypeNode(top) === false)
|
|
11
16
|
return props.expression;
|
|
12
|
-
|
|
17
|
+
if (props.expression.arguments[0] === undefined)
|
|
13
18
|
throw new TransformerError({
|
|
14
|
-
code:
|
|
15
|
-
message:
|
|
19
|
+
code: "typia.llm.controller",
|
|
20
|
+
message: "no identifier name.",
|
|
16
21
|
});
|
|
17
|
-
|
|
22
|
+
if (props.expression.arguments[1] === undefined)
|
|
18
23
|
throw new TransformerError({
|
|
19
|
-
code:
|
|
20
|
-
message:
|
|
24
|
+
code: "typia.llm.controller",
|
|
25
|
+
message: "no executor.",
|
|
21
26
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
// GET CONFIG
|
|
28
|
+
const config = LlmMetadataFactory.getConfig({
|
|
29
|
+
context: props.context,
|
|
30
|
+
method: "controller",
|
|
31
|
+
node: props.expression.typeArguments[1],
|
|
26
32
|
});
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
const type = props.context.checker.getTypeFromTypeNode(top);
|
|
34
|
+
// VALIDATE TYPE
|
|
35
|
+
const analyze = (validate) => {
|
|
36
|
+
const result = MetadataFactory.analyze({
|
|
37
|
+
checker: props.context.checker,
|
|
38
|
+
transformer: props.context.transformer,
|
|
39
|
+
options: {
|
|
40
|
+
absorb: validate,
|
|
41
|
+
escape: true,
|
|
42
|
+
constant: true,
|
|
43
|
+
functional: true,
|
|
44
|
+
validate: validate === true
|
|
45
|
+
? (next) => LlmApplicationProgrammer.validate({
|
|
46
|
+
config,
|
|
47
|
+
metadata: next.metadata,
|
|
48
|
+
explore: next.explore,
|
|
49
|
+
top: next.top,
|
|
50
|
+
})
|
|
51
|
+
: undefined,
|
|
52
|
+
},
|
|
53
|
+
components: new MetadataCollection({
|
|
54
|
+
replace: MetadataCollection.replace,
|
|
55
|
+
}),
|
|
56
|
+
type,
|
|
57
|
+
});
|
|
58
|
+
if (result.success === false)
|
|
59
|
+
throw TransformerError.from({
|
|
60
|
+
code: "typia.llm.controller",
|
|
61
|
+
errors: result.errors,
|
|
62
|
+
});
|
|
63
|
+
return result.data;
|
|
64
|
+
};
|
|
65
|
+
analyze(true);
|
|
66
|
+
// GENERATE LLM CONTROLLER
|
|
67
|
+
return LlmControllerProgrammer.write({
|
|
68
|
+
context: props.context,
|
|
69
|
+
modulo: props.modulo,
|
|
70
|
+
metadata: analyze(false),
|
|
71
|
+
className: top.getFullText().trim(),
|
|
72
|
+
config,
|
|
73
|
+
node: top,
|
|
74
|
+
nameArgument: props.expression.arguments[0],
|
|
75
|
+
executeArgument: props.expression.arguments[1],
|
|
76
|
+
configArgument: props.expression.arguments[2],
|
|
31
77
|
});
|
|
32
|
-
const value = ts.factory.createObjectLiteralExpression([
|
|
33
|
-
ts.factory.createPropertyAssignment("protocol", ts.factory.createStringLiteral("class")),
|
|
34
|
-
ts.factory.createPropertyAssignment("name", props.expression.arguments[0]),
|
|
35
|
-
ts.factory.createPropertyAssignment("execute", props.expression.arguments[1]),
|
|
36
|
-
ts.factory.createPropertyAssignment("application", ts.factory.createCallExpression(props.context.importer.internal("llmApplicationFinalize"), undefined, [
|
|
37
|
-
ts.factory.createAsExpression(ts.factory.createSatisfiesExpression(LiteralFactory.write(dec.application), primitiveTypeNode), primitiveTypeNode),
|
|
38
|
-
...(props.expression.arguments?.[2] !== undefined
|
|
39
|
-
? [
|
|
40
|
-
LlmApplicationTransformer.getConfigArgument({
|
|
41
|
-
context: props.context,
|
|
42
|
-
argument: props.expression.arguments[2],
|
|
43
|
-
equals: dec.config?.equals,
|
|
44
|
-
}),
|
|
45
|
-
]
|
|
46
|
-
: []),
|
|
47
|
-
])),
|
|
48
|
-
], true);
|
|
49
|
-
return ts.factory.createAsExpression(ts.factory.createSatisfiesExpression(value, typeNode), typeNode);
|
|
50
78
|
};
|
|
51
79
|
})(LlmControllerTransformer || (LlmControllerTransformer = {}));
|
|
52
80
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmControllerTransformer.mjs","sources":["../../../src/features/llm/LlmControllerTransformer.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LlmControllerTransformer.mjs","sources":["../../../src/features/llm/LlmControllerTransformer.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAcM,IAAW;AAAjB,CAAA,UAAiB,wBAAwB,EAAA;AAC1B,IAAA,wBAAA,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,sBAAsB;AAC5B,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;QAEzD,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS;YAC7C,MAAM,IAAI,gBAAgB,CAAC;AACzB,gBAAA,IAAI,EAAE,sBAAsB;AAC5B,gBAAA,OAAO,EAAE,qBAAqB;AAC/B,aAAA,CAAC;QACJ,IAAI,KAAK,CAAC,UAAU,CAAC,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,KAAK;gBAC1B,MAAM,gBAAgB,CAAC,IAAI,CAAC;AAC1B,oBAAA,IAAI,EAAE,sBAAsB;oBAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;AACtB,iBAAA,CAAC;YACJ,OAAO,MAAM,CAAC,IAAI;AACpB,QAAA,CAAC;QACD,OAAO,CAAC,IAAI,CAAC;;QAGb,OAAO,uBAAuB,CAAC,KAAK,CAAC;YACnC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM;AACpB,YAAA,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;AACxB,YAAA,SAAS,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;YACnC,MAAM;AACN,YAAA,IAAI,EAAE,GAAG;YACT,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3C,eAAe,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;YAC9C,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAC9C,SAAA,CAAC;AACJ,IAAA,CAAC;AACH,CAAC,EArFgB,wBAAwB,KAAxB,wBAAwB,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typia/transform",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.1.0-dev.20260325",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://typia.io",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@typia/
|
|
26
|
-
"@typia/interface": "^12.0.
|
|
27
|
-
"@typia/
|
|
25
|
+
"@typia/core": "^12.1.0-dev.20260325",
|
|
26
|
+
"@typia/interface": "^12.1.0-dev.20260325",
|
|
27
|
+
"@typia/utils": "^12.1.0-dev.20260325"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"rollup-plugin-auto-external": "^2.0.0",
|
|
38
38
|
"rollup-plugin-node-externals": "^8.1.2",
|
|
39
39
|
"tinyglobby": "^0.2.12",
|
|
40
|
-
"typescript": "~
|
|
40
|
+
"typescript": "~6.0.2"
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"files": [
|