typia 9.5.0 → 9.6.0
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/lib/internal/_llmApplicationFinalize.d.mts +3 -1
- package/lib/internal/_llmApplicationFinalize.d.ts +3 -1
- package/lib/internal/_llmApplicationFinalize.js +2 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -0
- package/lib/internal/_validateReport.js +9 -1
- package/lib/internal/_validateReport.js.map +1 -1
- package/lib/internal/_validateReport.mjs +8 -1
- package/lib/llm.d.mts +24 -2
- package/lib/llm.d.ts +24 -2
- package/lib/llm.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +14 -8
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.mjs +14 -8
- package/lib/programmers/internal/check_dynamic_properties.js +7 -1
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.mjs +7 -1
- package/lib/programmers/internal/check_object.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.d.mts +3 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +3 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +16 -14
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +15 -13
- package/lib/programmers/llm/LlmModelPredicator.d.mts +3 -1
- package/lib/programmers/llm/LlmModelPredicator.d.ts +3 -1
- package/lib/programmers/llm/LlmModelPredicator.js.map +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.d.mts +9 -0
- package/lib/transformers/features/llm/LlmApplicationTransformer.d.ts +9 -0
- package/lib/transformers/features/llm/LlmApplicationTransformer.js +32 -5
- package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.mjs +31 -4
- package/lib/transformers/features/llm/LlmControllerTransformer.js +8 -5
- package/lib/transformers/features/llm/LlmControllerTransformer.js.map +1 -1
- package/lib/transformers/features/llm/LlmControllerTransformer.mjs +7 -4
- package/package.json +2 -2
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_validateReport.ts +9 -1
- package/src/llm.ts +28 -2
- package/src/programmers/ValidateProgrammer.ts +19 -9
- package/src/programmers/internal/check_dynamic_properties.ts +30 -1
- package/src/programmers/internal/check_object.ts +4 -1
- package/src/programmers/llm/LlmApplicationProgrammer.ts +30 -14
- package/src/programmers/llm/LlmModelPredicator.ts +7 -1
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +95 -10
- package/src/transformers/features/llm/LlmControllerTransformer.ts +7 -8
|
@@ -68,26 +68,26 @@ var LlmApplicationProgrammer;
|
|
|
68
68
|
const output = [];
|
|
69
69
|
const prefix = `LLM application's function (${JSON.stringify(name)})`;
|
|
70
70
|
if (func.output.size() && func.output.isRequired() === false)
|
|
71
|
-
output.push(`${prefix}
|
|
71
|
+
output.push(`${prefix} return type cannot be optional (union with undefined).`);
|
|
72
72
|
if (/^[0-9]/.test(name[0] ?? "") === true)
|
|
73
|
-
output.push(`${prefix} name
|
|
73
|
+
output.push(`${prefix} name cannot start with a number.`);
|
|
74
74
|
if (/^[a-zA-Z0-9_-]+$/.test(name) === false)
|
|
75
|
-
output.push(`${prefix} name must
|
|
75
|
+
output.push(`${prefix} name must contain only alphanumeric characters, underscores, or hyphens.`);
|
|
76
76
|
if (name.length > 64)
|
|
77
|
-
output.push(`${prefix} name
|
|
77
|
+
output.push(`${prefix} name cannot exceed 64 characters.`);
|
|
78
78
|
if (func.parameters.length !== 0 && func.parameters.length !== 1)
|
|
79
|
-
output.push(`${prefix} must have
|
|
79
|
+
output.push(`${prefix} must have exactly one parameter or no parameters.`);
|
|
80
80
|
if (func.parameters.length !== 0) {
|
|
81
81
|
const type = func.parameters[0].type;
|
|
82
82
|
if (type.size() !== 1 || type.objects.length !== 1)
|
|
83
|
-
output.push(`${prefix}
|
|
83
|
+
output.push(`${prefix} parameter must be a single object type.`);
|
|
84
84
|
else {
|
|
85
85
|
if (type.objects[0].type.properties.some((p) => p.key.isSoleLiteral() === false))
|
|
86
|
-
output.push(`${prefix}
|
|
86
|
+
output.push(`${prefix} parameter cannot have dynamic property keys.`);
|
|
87
87
|
if (type.isRequired() === false)
|
|
88
|
-
output.push(`${prefix}
|
|
88
|
+
output.push(`${prefix} parameter cannot be optional (union with undefined).`);
|
|
89
89
|
if (type.nullable === true)
|
|
90
|
-
output.push(`${prefix}
|
|
90
|
+
output.push(`${prefix} parameter cannot be nullable.`);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return output;
|
|
@@ -115,6 +115,7 @@ var LlmApplicationProgrammer;
|
|
|
115
115
|
context: props.context,
|
|
116
116
|
modulo: props.modulo,
|
|
117
117
|
className: props.name,
|
|
118
|
+
config: props.config,
|
|
118
119
|
components: application.components,
|
|
119
120
|
function: func,
|
|
120
121
|
errors: errorMessages,
|
|
@@ -171,12 +172,13 @@ var LlmApplicationProgrammer;
|
|
|
171
172
|
})(),
|
|
172
173
|
deprecated: props.function.deprecated,
|
|
173
174
|
tags: props.function.tags,
|
|
174
|
-
validate:
|
|
175
|
+
validate: writeValidator({
|
|
175
176
|
context: props.context,
|
|
176
177
|
modulo: props.modulo,
|
|
177
178
|
parameter: props.parameter,
|
|
178
179
|
name: props.function.name,
|
|
179
180
|
className: props.className,
|
|
181
|
+
equals: props.config?.equals ?? false,
|
|
180
182
|
}),
|
|
181
183
|
};
|
|
182
184
|
};
|
|
@@ -219,13 +221,13 @@ var LlmApplicationProgrammer;
|
|
|
219
221
|
}
|
|
220
222
|
return result.value;
|
|
221
223
|
};
|
|
222
|
-
const
|
|
224
|
+
const writeValidator = (props) => {
|
|
223
225
|
if (props.parameter === null)
|
|
224
226
|
return ValidateProgrammer.write({
|
|
225
227
|
...props,
|
|
226
228
|
type: props.context.checker.getTypeFromTypeNode(TypeFactory.keyword("any")),
|
|
227
229
|
config: {
|
|
228
|
-
equals:
|
|
230
|
+
equals: props.equals,
|
|
229
231
|
},
|
|
230
232
|
name: undefined,
|
|
231
233
|
});
|
|
@@ -237,7 +239,7 @@ var LlmApplicationProgrammer;
|
|
|
237
239
|
...props,
|
|
238
240
|
type: props.parameter.tsType,
|
|
239
241
|
config: {
|
|
240
|
-
equals:
|
|
242
|
+
equals: props.equals,
|
|
241
243
|
},
|
|
242
244
|
name: props.className
|
|
243
245
|
? `Parameters<${props.className}[${JSON.stringify(props.name)}]>[0]`
|
|
@@ -7,7 +7,9 @@ export declare namespace LlmModelPredicator {
|
|
|
7
7
|
method: string;
|
|
8
8
|
model: ILlmSchema.Model;
|
|
9
9
|
node: ts.TypeNode | undefined;
|
|
10
|
-
}) => Partial<ILlmSchema.ModelConfig[ILlmSchema.Model]
|
|
10
|
+
}) => Partial<ILlmSchema.ModelConfig[ILlmSchema.Model] & {
|
|
11
|
+
equals: boolean;
|
|
12
|
+
}> | undefined;
|
|
11
13
|
const getModel: (props: {
|
|
12
14
|
checker: ts.TypeChecker;
|
|
13
15
|
method: string;
|
|
@@ -7,7 +7,9 @@ export declare namespace LlmModelPredicator {
|
|
|
7
7
|
method: string;
|
|
8
8
|
model: ILlmSchema.Model;
|
|
9
9
|
node: ts.TypeNode | undefined;
|
|
10
|
-
}) => Partial<ILlmSchema.ModelConfig[ILlmSchema.Model]
|
|
10
|
+
}) => Partial<ILlmSchema.ModelConfig[ILlmSchema.Model] & {
|
|
11
|
+
equals: boolean;
|
|
12
|
+
}> | undefined;
|
|
11
13
|
const getModel: (props: {
|
|
12
14
|
checker: ts.TypeChecker;
|
|
13
15
|
method: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmModelPredicator.js","sourceRoot":"","sources":["../../../src/programmers/llm/LlmModelPredicator.ts"],"names":[],"mappings":";;;;;;AACA,wFAAqF;AACrF,4DAA4B;AAE5B,2EAAwE;AACxE,qE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;IACnC,CAAC,CAAC;AACJ,CAAC,EArHgB,kBAAkB,kCAAlB,kBAAkB,QAqHlC"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import ts from "typescript";
|
|
2
3
|
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { ITypiaContext } from "../../ITypiaContext";
|
|
3
5
|
export declare namespace LlmApplicationTransformer {
|
|
4
6
|
const transform: (props: ITransformProps) => ts.Expression;
|
|
7
|
+
const finalize: (props: {
|
|
8
|
+
context: ITypiaContext;
|
|
9
|
+
value: ts.Expression;
|
|
10
|
+
argument: ts.Expression;
|
|
11
|
+
equals?: boolean;
|
|
12
|
+
model: ILlmSchema.Model;
|
|
13
|
+
}) => ts.CallExpression;
|
|
5
14
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import ts from "typescript";
|
|
2
3
|
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { ITypiaContext } from "../../ITypiaContext";
|
|
3
5
|
export declare namespace LlmApplicationTransformer {
|
|
4
6
|
const transform: (props: ITransformProps) => ts.Expression;
|
|
7
|
+
const finalize: (props: {
|
|
8
|
+
context: ITypiaContext;
|
|
9
|
+
value: ts.Expression;
|
|
10
|
+
argument: ts.Expression;
|
|
11
|
+
equals?: boolean;
|
|
12
|
+
model: ILlmSchema.Model;
|
|
13
|
+
}) => ts.CallExpression;
|
|
5
14
|
}
|
|
@@ -16,7 +16,7 @@ const TransformerError_1 = require("../../TransformerError");
|
|
|
16
16
|
var LlmApplicationTransformer;
|
|
17
17
|
(function (LlmApplicationTransformer) {
|
|
18
18
|
LlmApplicationTransformer.transform = (props) => {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
20
20
|
const dec = LlmApplicationTransformer.decompose("application", props);
|
|
21
21
|
if (dec === null)
|
|
22
22
|
return props.expression;
|
|
@@ -34,10 +34,13 @@ var LlmApplicationTransformer;
|
|
|
34
34
|
name: "application",
|
|
35
35
|
value: literal,
|
|
36
36
|
}),
|
|
37
|
-
typescript_1.default.factory.createExpressionStatement(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
typescript_1.default.factory.createExpressionStatement(LlmApplicationTransformer.finalize({
|
|
38
|
+
context: props.context,
|
|
39
|
+
value: typescript_1.default.factory.createIdentifier("application"),
|
|
40
|
+
argument: props.expression.arguments[0],
|
|
41
|
+
equals: (_b = dec.config) === null || _b === void 0 ? void 0 : _b.equals,
|
|
42
|
+
model: dec.application.model,
|
|
43
|
+
})),
|
|
41
44
|
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createIdentifier("application")),
|
|
42
45
|
], true));
|
|
43
46
|
};
|
|
@@ -110,7 +113,31 @@ var LlmApplicationTransformer;
|
|
|
110
113
|
}),
|
|
111
114
|
node: top,
|
|
112
115
|
type,
|
|
116
|
+
config,
|
|
113
117
|
};
|
|
114
118
|
};
|
|
119
|
+
LlmApplicationTransformer.finalize = (props) => {
|
|
120
|
+
const satisfiesTypeNode = typescript_1.default.factory.createTypeReferenceNode(typescript_1.default.factory.createIdentifier("Partial"), [
|
|
121
|
+
typescript_1.default.factory.createTypeReferenceNode(typescript_1.default.factory.createIdentifier("Pick"), [
|
|
122
|
+
typescript_1.default.factory.createImportTypeNode(typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral("@samchon/openapi")), undefined, typescript_1.default.factory.createQualifiedName(typescript_1.default.factory.createIdentifier("ILlmApplication"), typescript_1.default.factory.createIdentifier("IOptions")), [
|
|
123
|
+
typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral(props.model)),
|
|
124
|
+
], false),
|
|
125
|
+
typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral("separate")),
|
|
126
|
+
]),
|
|
127
|
+
]);
|
|
128
|
+
return typescript_1.default.factory.createCallExpression(props.context.importer.internal("llmApplicationFinalize"), undefined, [
|
|
129
|
+
props.value,
|
|
130
|
+
typescript_1.default.factory.createObjectLiteralExpression([
|
|
131
|
+
typescript_1.default.factory.createPropertyAssignment("separate", typescript_1.default.factory.createPropertyAccessChain(typescript_1.default.factory.createSatisfiesExpression(props.argument, satisfiesTypeNode), typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.QuestionDotToken), "separate")),
|
|
132
|
+
...(typeof props.equals === "boolean"
|
|
133
|
+
? [
|
|
134
|
+
typescript_1.default.factory.createPropertyAssignment("equals", props.equals === true
|
|
135
|
+
? typescript_1.default.factory.createTrue()
|
|
136
|
+
: typescript_1.default.factory.createFalse()),
|
|
137
|
+
]
|
|
138
|
+
: []),
|
|
139
|
+
], true),
|
|
140
|
+
]);
|
|
141
|
+
};
|
|
115
142
|
})(LlmApplicationTransformer || (exports.LlmApplicationTransformer = LlmApplicationTransformer = {}));
|
|
116
143
|
//# sourceMappingURL=LlmApplicationTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmApplicationTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmApplicationTransformer.ts"],"names":[],"mappings":";;;;;;AACA,4DAA4B;AAE5B,4EAAyE;AACzE,sEAAmE;AACnE,8EAA2E;AAC3E,wEAAqE;AACrE,0EAAuE;AAIvE,gGAA6F;AAC7F,oFAAiF;
|
|
1
|
+
{"version":3,"file":"LlmApplicationTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmApplicationTransformer.ts"],"names":[],"mappings":";;;;;;AACA,4DAA4B;AAE5B,4EAAyE;AACzE,sEAAmE;AACnE,8EAA2E;AAC3E,wEAAqE;AACrE,0EAAuE;AAIvE,gGAA6F;AAC7F,oFAAiF;AAMjF,6DAA0D;AAE1D,IAAiB,yBAAyB,CAiNzC;AAjND,WAAiB,yBAAyB;IAC3B,mCAAS,GAAG,CAAC,KAAsB,EAAiB,EAAE;;QACjE,MAAM,GAAG,G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,CAAC,OAAO,CAAC,wBAAwB,CACjC,QAAQ,EACR,KAAK,CAAC,MAAM,KAAK,IAAI;4BACnB,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,UAAU,EAAE;4BACzB,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAC7B;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR,EACD,IAAI,CACL;SACF,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EAjNgB,yBAAyB,yCAAzB,yBAAyB,QAiNzC"}
|
|
@@ -28,10 +28,13 @@ var LlmApplicationTransformer;
|
|
|
28
28
|
name: "application",
|
|
29
29
|
value: literal,
|
|
30
30
|
}),
|
|
31
|
-
ts.factory.createExpressionStatement(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
ts.factory.createExpressionStatement(LlmApplicationTransformer.finalize({
|
|
32
|
+
context: props.context,
|
|
33
|
+
value: ts.factory.createIdentifier("application"),
|
|
34
|
+
argument: props.expression.arguments[0],
|
|
35
|
+
equals: dec.config?.equals,
|
|
36
|
+
model: dec.application.model,
|
|
37
|
+
})),
|
|
35
38
|
ts.factory.createReturnStatement(ts.factory.createIdentifier("application")),
|
|
36
39
|
], true));
|
|
37
40
|
};
|
|
@@ -103,8 +106,32 @@ var LlmApplicationTransformer;
|
|
|
103
106
|
}),
|
|
104
107
|
node: top,
|
|
105
108
|
type,
|
|
109
|
+
config,
|
|
106
110
|
};
|
|
107
111
|
};
|
|
112
|
+
LlmApplicationTransformer.finalize = (props) => {
|
|
113
|
+
const satisfiesTypeNode = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("Partial"), [
|
|
114
|
+
ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("Pick"), [
|
|
115
|
+
ts.factory.createImportTypeNode(ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral("@samchon/openapi")), undefined, ts.factory.createQualifiedName(ts.factory.createIdentifier("ILlmApplication"), ts.factory.createIdentifier("IOptions")), [
|
|
116
|
+
ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(props.model)),
|
|
117
|
+
], false),
|
|
118
|
+
ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral("separate")),
|
|
119
|
+
]),
|
|
120
|
+
]);
|
|
121
|
+
return ts.factory.createCallExpression(props.context.importer.internal("llmApplicationFinalize"), undefined, [
|
|
122
|
+
props.value,
|
|
123
|
+
ts.factory.createObjectLiteralExpression([
|
|
124
|
+
ts.factory.createPropertyAssignment("separate", ts.factory.createPropertyAccessChain(ts.factory.createSatisfiesExpression(props.argument, satisfiesTypeNode), ts.factory.createToken(ts.SyntaxKind.QuestionDotToken), "separate")),
|
|
125
|
+
...(typeof props.equals === "boolean"
|
|
126
|
+
? [
|
|
127
|
+
ts.factory.createPropertyAssignment("equals", props.equals === true
|
|
128
|
+
? ts.factory.createTrue()
|
|
129
|
+
: ts.factory.createFalse()),
|
|
130
|
+
]
|
|
131
|
+
: []),
|
|
132
|
+
], true),
|
|
133
|
+
]);
|
|
134
|
+
};
|
|
108
135
|
})(LlmApplicationTransformer || (LlmApplicationTransformer = {}));
|
|
109
136
|
|
|
110
137
|
export { LlmApplicationTransformer };
|
|
@@ -13,7 +13,7 @@ const LlmApplicationTransformer_1 = require("./LlmApplicationTransformer");
|
|
|
13
13
|
var LlmControllerTransformer;
|
|
14
14
|
(function (LlmControllerTransformer) {
|
|
15
15
|
LlmControllerTransformer.transform = (props) => {
|
|
16
|
-
var _a;
|
|
16
|
+
var _a, _b;
|
|
17
17
|
const dec = LlmApplicationTransformer_1.LlmApplicationTransformer.decompose("application", props);
|
|
18
18
|
if (dec === null)
|
|
19
19
|
return props.expression;
|
|
@@ -47,10 +47,13 @@ var LlmControllerTransformer;
|
|
|
47
47
|
}),
|
|
48
48
|
...(((_a = props.expression.arguments) === null || _a === void 0 ? void 0 : _a[2]) !== undefined
|
|
49
49
|
? [
|
|
50
|
-
typescript_1.default.factory.createExpressionStatement(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
typescript_1.default.factory.createExpressionStatement(LlmApplicationTransformer_1.LlmApplicationTransformer.finalize({
|
|
51
|
+
context: props.context,
|
|
52
|
+
value: typescript_1.default.factory.createIdentifier("application"),
|
|
53
|
+
argument: props.expression.arguments[2],
|
|
54
|
+
equals: (_b = dec.config) === null || _b === void 0 ? void 0 : _b.equals,
|
|
55
|
+
model: dec.application.model,
|
|
56
|
+
})),
|
|
54
57
|
]
|
|
55
58
|
: []),
|
|
56
59
|
typescript_1.default.factory.createReturnStatement(value),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmControllerTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmControllerTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAE5B,4EAAyE;AACzE,sEAAmE;AACnE,0EAAuE;AAGvE,6DAA0D;AAC1D,2EAAwE;AAExE,IAAiB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"LlmControllerTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmControllerTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAE5B,4EAAyE;AACzE,sEAAmE;AACnE,0EAAuE;AAGvE,6DAA0D;AAC1D,2EAAwE;AAExE,IAAiB,wBAAwB,CAiFxC;AAjFD,WAAiB,wBAAwB;IAC1B,kCAAS,GAAG,CAAC,KAAsB,EAAiB,EAAE;;QACjE,MAAM,GAAG,GAAG,qDAAyB,CAAC,SAAS,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACtE,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC,UAAU,CAAC;aACrC,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS;YAClD,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,qBAAqB;aAC/B,CAAC,CAAC;a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ACF,GAAG,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAG,CAAC,CAAC,MAAK,SAAS;gBAC/C,CAAC,CAAC;oBACE,oBAAE,CAAC,OAAO,CAAC,yBAAyB,CAClC,qDAAyB,CAAC,QAAQ,CAAC;wBACjC,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,KAAK,EAAE,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC;wBACjD,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAE;wBACxC,MAAM,EAAE,MAAA,GAAG,CAAC,MAAM,0CAAE,MAAM;wBAC1B,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,KAAK;qBAC7B,CAAC,CACH;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,oBAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC;SACxC,EACD,IAAI,CACL,EACD,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC1B,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,gBAAgB;YACtB,SAAS,EAAE;gBACT,oBAAE,CAAC,OAAO,CAAC,qBAAqB,CAC9B,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CACtD;gBACD,GAAG,CAAC,IAAI;aACT;SACF,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EAjFgB,wBAAwB,wCAAxB,wBAAwB,QAiFxC"}
|
|
@@ -41,10 +41,13 @@ var LlmControllerTransformer;
|
|
|
41
41
|
}),
|
|
42
42
|
...(props.expression.arguments?.[2] !== undefined
|
|
43
43
|
? [
|
|
44
|
-
ts.factory.createExpressionStatement(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
ts.factory.createExpressionStatement(LlmApplicationTransformer.finalize({
|
|
45
|
+
context: props.context,
|
|
46
|
+
value: ts.factory.createIdentifier("application"),
|
|
47
|
+
argument: props.expression.arguments[2],
|
|
48
|
+
equals: dec.config?.equals,
|
|
49
|
+
model: dec.application.model,
|
|
50
|
+
})),
|
|
48
51
|
]
|
|
49
52
|
: []),
|
|
50
53
|
ts.factory.createReturnStatement(value),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.0",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://typia.io",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@samchon/openapi": "^4.
|
|
44
|
+
"@samchon/openapi": "^4.6.0",
|
|
45
45
|
"@standard-schema/spec": "^1.0.0",
|
|
46
46
|
"commander": "^10.0.0",
|
|
47
47
|
"comment-json": "^4.2.3",
|
|
@@ -3,7 +3,11 @@ import { LlmSchemaComposer } from "@samchon/openapi/lib/composers/LlmSchemaCompo
|
|
|
3
3
|
|
|
4
4
|
export const _llmApplicationFinalize = <Model extends ILlmSchema.Model>(
|
|
5
5
|
app: ILlmApplication<Model>,
|
|
6
|
-
options?: Partial<
|
|
6
|
+
options?: Partial<
|
|
7
|
+
Pick<ILlmApplication.IOptions<Model>, "separate"> & {
|
|
8
|
+
equals?: boolean;
|
|
9
|
+
}
|
|
10
|
+
>,
|
|
7
11
|
): void => {
|
|
8
12
|
app.options = {
|
|
9
13
|
...LlmSchemaComposer.defaultConfig(app.model),
|
|
@@ -16,5 +20,6 @@ export const _llmApplicationFinalize = <Model extends ILlmSchema.Model>(
|
|
|
16
20
|
func.parameters satisfies ILlmSchema.IParameters<Model> as any,
|
|
17
21
|
predicate: app.options
|
|
18
22
|
.separate as ILlmApplication.IOptions<Model>["separate"] as any,
|
|
23
|
+
equals: options?.equals ?? false,
|
|
19
24
|
}) as ILlmFunction.ISeparated<Model>;
|
|
20
25
|
};
|
|
@@ -7,7 +7,15 @@ export const _validateReport = (array: IValidation.IError[]) => {
|
|
|
7
7
|
return path.length > last.length || last.substring(0, path.length) !== path;
|
|
8
8
|
};
|
|
9
9
|
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
10
|
-
if (exceptable && reportable(error.path))
|
|
10
|
+
if (exceptable && reportable(error.path)) {
|
|
11
|
+
if (error.value === undefined)
|
|
12
|
+
error.description ??= [
|
|
13
|
+
"The value at this path is `undefined`.",
|
|
14
|
+
"",
|
|
15
|
+
`Please fill the \`${error.expected}\` typed value next time.`,
|
|
16
|
+
].join("\n");
|
|
17
|
+
array.push(error);
|
|
18
|
+
}
|
|
11
19
|
return false;
|
|
12
20
|
};
|
|
13
21
|
};
|
package/src/llm.ts
CHANGED
|
@@ -153,7 +153,20 @@ export function controller(
|
|
|
153
153
|
export function controller<
|
|
154
154
|
Class extends Record<string, any>,
|
|
155
155
|
Model extends ILlmSchema.Model,
|
|
156
|
-
Config extends Partial<
|
|
156
|
+
Config extends Partial<
|
|
157
|
+
ILlmSchema.ModelConfig[Model] & {
|
|
158
|
+
/**
|
|
159
|
+
* Whether to disallow superfluous properties or not.
|
|
160
|
+
*
|
|
161
|
+
* If configure as `true`, {@link validateEquals} function would be
|
|
162
|
+
* used for validation feedback, which is more strict than
|
|
163
|
+
* {@link validate} function.
|
|
164
|
+
*
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
equals: boolean;
|
|
168
|
+
}
|
|
169
|
+
> = {},
|
|
157
170
|
>(
|
|
158
171
|
name: string,
|
|
159
172
|
execute: Class,
|
|
@@ -280,7 +293,20 @@ export function application(
|
|
|
280
293
|
export function application<
|
|
281
294
|
Class extends Record<string, any>,
|
|
282
295
|
Model extends ILlmSchema.Model,
|
|
283
|
-
Config extends Partial<
|
|
296
|
+
Config extends Partial<
|
|
297
|
+
{
|
|
298
|
+
/**
|
|
299
|
+
* Whether to disallow superfluous properties or not.
|
|
300
|
+
*
|
|
301
|
+
* If configure as `true`, {@link validateEquals} function would be
|
|
302
|
+
* used for validation feedback, which is more strict than
|
|
303
|
+
* {@link validate} function.
|
|
304
|
+
*
|
|
305
|
+
* @default false
|
|
306
|
+
*/
|
|
307
|
+
equals: boolean;
|
|
308
|
+
} & ILlmSchema.ModelConfig[Model]
|
|
309
|
+
> = {},
|
|
284
310
|
>(
|
|
285
311
|
options?: Partial<Pick<ILlmApplication.IOptions<Model>, "separate">>,
|
|
286
312
|
): ILlmApplication<Model, Class>;
|
|
@@ -63,7 +63,7 @@ export namespace ValidateProgrammer {
|
|
|
63
63
|
: "_path",
|
|
64
64
|
),
|
|
65
65
|
expected: cond.expected,
|
|
66
|
-
|
|
66
|
+
value: next.input,
|
|
67
67
|
}),
|
|
68
68
|
),
|
|
69
69
|
)
|
|
@@ -89,7 +89,7 @@ export namespace ValidateProgrammer {
|
|
|
89
89
|
: "_path",
|
|
90
90
|
),
|
|
91
91
|
expected: next.entry.expected,
|
|
92
|
-
|
|
92
|
+
value: next.input,
|
|
93
93
|
}),
|
|
94
94
|
),
|
|
95
95
|
]),
|
|
@@ -295,7 +295,7 @@ const combine =
|
|
|
295
295
|
: ts.factory.createIdentifier("_exceptionable"),
|
|
296
296
|
path: ts.factory.createIdentifier(path),
|
|
297
297
|
expected: next.expected,
|
|
298
|
-
|
|
298
|
+
value: next.input,
|
|
299
299
|
}),
|
|
300
300
|
),
|
|
301
301
|
)
|
|
@@ -311,7 +311,7 @@ const combine =
|
|
|
311
311
|
: ts.factory.createIdentifier("_exceptionable"),
|
|
312
312
|
path: ts.factory.createIdentifier(path),
|
|
313
313
|
expected: next.expected,
|
|
314
|
-
|
|
314
|
+
value: next.input,
|
|
315
315
|
}),
|
|
316
316
|
);
|
|
317
317
|
};
|
|
@@ -330,7 +330,7 @@ const validate_object = (props: {
|
|
|
330
330
|
assert: false,
|
|
331
331
|
reduce: ts.factory.createLogicalAnd,
|
|
332
332
|
positive: ts.factory.createTrue(),
|
|
333
|
-
superfluous: (input) =>
|
|
333
|
+
superfluous: (input, description) =>
|
|
334
334
|
create_report_call({
|
|
335
335
|
path: ts.factory.createAdd(
|
|
336
336
|
ts.factory.createIdentifier("_path"),
|
|
@@ -341,7 +341,8 @@ const validate_object = (props: {
|
|
|
341
341
|
),
|
|
342
342
|
),
|
|
343
343
|
expected: "undefined",
|
|
344
|
-
input,
|
|
344
|
+
value: input,
|
|
345
|
+
description,
|
|
345
346
|
}),
|
|
346
347
|
halt: (expr) =>
|
|
347
348
|
ts.factory.createLogicalOr(
|
|
@@ -388,7 +389,7 @@ const joiner = (props: {
|
|
|
388
389
|
next.explore?.postfix ? `_path + ${next.explore.postfix}` : "_path",
|
|
389
390
|
),
|
|
390
391
|
expected: next.expected,
|
|
391
|
-
|
|
392
|
+
value: next.input,
|
|
392
393
|
}),
|
|
393
394
|
tuple: (binaries) =>
|
|
394
395
|
check_everything(ts.factory.createArrayLiteralExpression(binaries, true)),
|
|
@@ -426,7 +427,8 @@ const create_report_call = (props: {
|
|
|
426
427
|
exceptionable?: ts.Expression;
|
|
427
428
|
path: ts.Expression;
|
|
428
429
|
expected: string;
|
|
429
|
-
|
|
430
|
+
value: ts.Expression;
|
|
431
|
+
description?: ts.Expression;
|
|
430
432
|
}): ts.Expression =>
|
|
431
433
|
ts.factory.createCallExpression(
|
|
432
434
|
ts.factory.createIdentifier("_report"),
|
|
@@ -440,7 +442,15 @@ const create_report_call = (props: {
|
|
|
440
442
|
"expected",
|
|
441
443
|
ts.factory.createStringLiteral(props.expected),
|
|
442
444
|
),
|
|
443
|
-
ts.factory.createPropertyAssignment("value", props.
|
|
445
|
+
ts.factory.createPropertyAssignment("value", props.value),
|
|
446
|
+
...(props.description
|
|
447
|
+
? [
|
|
448
|
+
ts.factory.createPropertyAssignment(
|
|
449
|
+
"description",
|
|
450
|
+
props.description,
|
|
451
|
+
),
|
|
452
|
+
]
|
|
453
|
+
: []),
|
|
444
454
|
],
|
|
445
455
|
true,
|
|
446
456
|
),
|
|
@@ -159,7 +159,36 @@ const check_dynamic_property = (props: {
|
|
|
159
159
|
: [
|
|
160
160
|
ts.factory.createReturnStatement(
|
|
161
161
|
props.config.equals === true
|
|
162
|
-
? props.config.superfluous(
|
|
162
|
+
? props.config.superfluous(
|
|
163
|
+
value,
|
|
164
|
+
ts.factory.createCallExpression(
|
|
165
|
+
ts.factory.createPropertyAccessExpression(
|
|
166
|
+
ts.factory.createArrayLiteralExpression(
|
|
167
|
+
[
|
|
168
|
+
ts.factory.createTemplateExpression(
|
|
169
|
+
ts.factory.createTemplateHead("The property `"),
|
|
170
|
+
[
|
|
171
|
+
ts.factory.createTemplateSpan(
|
|
172
|
+
ts.factory.createIdentifier("key"),
|
|
173
|
+
ts.factory.createTemplateTail(
|
|
174
|
+
"` is not defined in the object type.",
|
|
175
|
+
),
|
|
176
|
+
),
|
|
177
|
+
],
|
|
178
|
+
),
|
|
179
|
+
ts.factory.createStringLiteral(""),
|
|
180
|
+
ts.factory.createStringLiteral(
|
|
181
|
+
"Please remove the property next time.",
|
|
182
|
+
),
|
|
183
|
+
],
|
|
184
|
+
true,
|
|
185
|
+
),
|
|
186
|
+
"join",
|
|
187
|
+
),
|
|
188
|
+
undefined,
|
|
189
|
+
[ts.factory.createStringLiteral("\n")],
|
|
190
|
+
),
|
|
191
|
+
)
|
|
163
192
|
: props.config.positive,
|
|
164
193
|
),
|
|
165
194
|
]),
|
|
@@ -56,7 +56,10 @@ export namespace check_object {
|
|
|
56
56
|
halt?: undefined | ((exp: ts.Expression) => ts.Expression);
|
|
57
57
|
reduce: (a: ts.Expression, b: ts.Expression) => ts.Expression;
|
|
58
58
|
positive: ts.Expression;
|
|
59
|
-
superfluous: (
|
|
59
|
+
superfluous: (
|
|
60
|
+
value: ts.Expression,
|
|
61
|
+
description?: ts.Expression,
|
|
62
|
+
) => ts.Expression;
|
|
60
63
|
entries?: undefined | ts.Identifier;
|
|
61
64
|
}
|
|
62
65
|
}
|