typia 7.5.1 → 7.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/README.md +1 -0
- package/lib/programmers/json/JsonApplicationProgrammer.d.ts +12 -0
- package/lib/programmers/json/JsonApplicationProgrammer.js +22 -22
- package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js +15 -7
- package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +39 -15
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/package.json +4 -4
- package/src/programmers/json/JsonApplicationProgrammer.ts +27 -27
- package/src/programmers/llm/LlmApplicationOfValidateProgrammer.ts +16 -2
- package/src/programmers/llm/LlmApplicationProgrammer.ts +50 -12
package/README.md
CHANGED
|
@@ -131,6 +131,7 @@ Check out the document in the [website](https://typia.io/docs/):
|
|
|
131
131
|
- [`application()` function](https://typia.io/docs/llm/application/)
|
|
132
132
|
- [`parameters()` function](https://typia.io/docs/llm/parameters/)
|
|
133
133
|
- [`schema()` function](https://typia.io/docs/llm/schema/)
|
|
134
|
+
- [Documentation Strategy](https://typia.io/docs/llm/strategy/)
|
|
134
135
|
- Protocol Buffer
|
|
135
136
|
- [Message Schema](https://typia.io/docs/protobuf/message)
|
|
136
137
|
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MetadataFactory } from "../../factories/MetadataFactory";
|
|
2
2
|
import { __IJsonApplication } from "../../schemas/json/__IJsonApplication";
|
|
3
|
+
import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
|
|
3
4
|
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
4
5
|
import { MetadataProperty } from "../../schemas/metadata/MetadataProperty";
|
|
5
6
|
export declare namespace JsonApplicationProgrammer {
|
|
@@ -9,4 +10,15 @@ export declare namespace JsonApplicationProgrammer {
|
|
|
9
10
|
metadata: Metadata;
|
|
10
11
|
filter?: (prop: MetadataProperty) => boolean;
|
|
11
12
|
}) => __IJsonApplication<Version>;
|
|
13
|
+
const writeDescription: <Kind extends "summary" | "title">(props: {
|
|
14
|
+
description: string | null;
|
|
15
|
+
jsDocTags: IJsDocTagInfo[];
|
|
16
|
+
kind: Kind;
|
|
17
|
+
}) => Kind extends "summary" ? {
|
|
18
|
+
summary?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
} : {
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
};
|
|
12
24
|
}
|
|
@@ -86,6 +86,27 @@ var JsonApplicationProgrammer;
|
|
|
86
86
|
functions,
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
+
JsonApplicationProgrammer.writeDescription = (props) => {
|
|
90
|
+
var _a;
|
|
91
|
+
const title = (() => {
|
|
92
|
+
var _a;
|
|
93
|
+
const [explicit] = getJsDocTexts({
|
|
94
|
+
jsDocTags: props.jsDocTags,
|
|
95
|
+
name: props.kind,
|
|
96
|
+
});
|
|
97
|
+
if (explicit === null || explicit === void 0 ? void 0 : explicit.length)
|
|
98
|
+
return explicit;
|
|
99
|
+
else if (!((_a = props.description) === null || _a === void 0 ? void 0 : _a.length))
|
|
100
|
+
return undefined;
|
|
101
|
+
const index = props.description.indexOf("\n");
|
|
102
|
+
const top = (index === -1 ? props.description : props.description.substring(0, index)).trim();
|
|
103
|
+
return top.endsWith(".") ? top.substring(0, top.length - 1) : undefined;
|
|
104
|
+
})();
|
|
105
|
+
return {
|
|
106
|
+
[props.kind]: title,
|
|
107
|
+
description: ((_a = props.description) === null || _a === void 0 ? void 0 : _a.length) ? props.description : undefined,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
89
110
|
const collectFunction = (props) => {
|
|
90
111
|
var _a;
|
|
91
112
|
const deprecated = props.jsDocTags.some((tag) => tag.name === "deprecated");
|
|
@@ -105,7 +126,7 @@ var JsonApplicationProgrammer;
|
|
|
105
126
|
async: props.function.async,
|
|
106
127
|
parameters: props.function.parameters.map((param) => {
|
|
107
128
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
108
|
-
const appParam = Object.assign(Object.assign({ name: param.name }, writeDescription({
|
|
129
|
+
const appParam = Object.assign(Object.assign({ name: param.name }, JsonApplicationProgrammer.writeDescription({
|
|
109
130
|
description: (_h = (_e = (_a = param.description) !== null && _a !== void 0 ? _a : (_d = (_c = (_b = param.jsDocTags.find((tag) => tag.name === "description")) === null || _b === void 0 ? void 0 : _b.text) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : (_g = (_f = props.jsDocTags
|
|
110
131
|
.find((tag) => { var _a, _b; return tag.name === "param" && ((_b = (_a = tag.text) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) === param.name; })) === null || _f === void 0 ? void 0 : _f.text) === null || _g === void 0 ? void 0 : _g.map((e) => e.text).join("").substring(param.name.length)) !== null && _h !== void 0 ? _h : null,
|
|
111
132
|
jsDocTags: props.jsDocTags,
|
|
@@ -138,27 +159,6 @@ var JsonApplicationProgrammer;
|
|
|
138
159
|
};
|
|
139
160
|
};
|
|
140
161
|
})(JsonApplicationProgrammer || (exports.JsonApplicationProgrammer = JsonApplicationProgrammer = {}));
|
|
141
|
-
const writeDescription = (props) => {
|
|
142
|
-
var _a;
|
|
143
|
-
const title = (() => {
|
|
144
|
-
var _a;
|
|
145
|
-
const [explicit] = getJsDocTexts({
|
|
146
|
-
jsDocTags: props.jsDocTags,
|
|
147
|
-
name: props.kind,
|
|
148
|
-
});
|
|
149
|
-
if (explicit === null || explicit === void 0 ? void 0 : explicit.length)
|
|
150
|
-
return explicit;
|
|
151
|
-
else if (!((_a = props.description) === null || _a === void 0 ? void 0 : _a.length))
|
|
152
|
-
return undefined;
|
|
153
|
-
const index = props.description.indexOf("\n");
|
|
154
|
-
const top = (index === -1 ? props.description : props.description.substring(0, index)).trim();
|
|
155
|
-
return top.endsWith(".") ? top.substring(0, top.length - 1) : undefined;
|
|
156
|
-
})();
|
|
157
|
-
return {
|
|
158
|
-
[props.kind]: title,
|
|
159
|
-
description: ((_a = props.description) === null || _a === void 0 ? void 0 : _a.length) ? props.description : undefined,
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
162
|
const writeDescriptionFromJsDocTag = (props) => {
|
|
163
163
|
var _a, _b;
|
|
164
164
|
const parametric = props.parameter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonApplicationProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/json/JsonApplicationProgrammer.ts"],"names":[],"mappings":";;;AASA,mEAAgE;AAEhE,IAAiB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"JsonApplicationProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/json/JsonApplicationProgrammer.ts"],"names":[],"mappings":";;;AASA,mEAAgE;AAEhE,IAAiB,yBAAyB,CAyOzC;AAzOD,WAAiB,yBAAyB;IAC3B,kCAAQ,GAAG,CACtB,QAAkB,EAClB,OAAiC,EACvB,EAAE;;QACZ,IAAI,OAAO,CAAC,GAAG,KAAK,KAAK;YAAE,OAAO,6CAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE3E,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,KAAK,GACT,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;YACrB,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAC7B,QAAQ,CAAC,UAAU,EAAE,KAAK,IAAI;YAC9B,QAAQ,CAAC,QAAQ,KAAK,KAAK,CAAC;QAC9B,IAAI,KAAK,KAAK,KAAK;YACjB,MAAM,CAAC,IAAI,CACT,qEAAqE,CACtE,CAAC;QAEJ,MAAM,MAAM,GAAmC,MAAA,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,0CAAE,IAA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,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAE,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LlmApplicationOfValidateProgrammer = void 0;
|
|
4
|
+
const TypeFactory_1 = require("../../factories/TypeFactory");
|
|
4
5
|
const ValidateProgrammer_1 = require("../ValidateProgrammer");
|
|
5
6
|
const LlmApplicationProgrammer_1 = require("./LlmApplicationProgrammer");
|
|
6
7
|
var LlmApplicationOfValidateProgrammer;
|
|
@@ -18,15 +19,22 @@ var LlmApplicationOfValidateProgrammer;
|
|
|
18
19
|
p.key.getSoleLiteral(),
|
|
19
20
|
p.value.functions[0].parameters[0],
|
|
20
21
|
]));
|
|
21
|
-
return Object.assign(Object.assign({}, app), { functions: app.functions.map((func) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
return Object.assign(Object.assign({}, app), { functions: app.functions.map((func) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return (Object.assign(Object.assign({}, func), { validate: writeValidadtor({
|
|
25
|
+
context: props.context,
|
|
26
|
+
modulo: props.modulo,
|
|
27
|
+
className: props.name,
|
|
28
|
+
name: func.name,
|
|
29
|
+
parameter: (_a = parameters[func.name]) !== null && _a !== void 0 ? _a : null,
|
|
30
|
+
}) }));
|
|
31
|
+
}) });
|
|
28
32
|
};
|
|
29
33
|
const writeValidadtor = (props) => {
|
|
34
|
+
if (props.parameter === null)
|
|
35
|
+
return ValidateProgrammer_1.ValidateProgrammer.write(Object.assign(Object.assign({}, props), { type: props.context.checker.getTypeFromTypeNode(TypeFactory_1.TypeFactory.keyword("any")), config: {
|
|
36
|
+
equals: false,
|
|
37
|
+
}, name: undefined }));
|
|
30
38
|
const type = props.parameter.tsType;
|
|
31
39
|
if (type === undefined)
|
|
32
40
|
// unreachable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmApplicationOfValidateProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/llm/LlmApplicationOfValidateProgrammer.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"LlmApplicationOfValidateProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/llm/LlmApplicationOfValidateProgrammer.ts"],"names":[],"mappings":";;;AAGA,6DAA0D;AAS1D,8DAA2D;AAC3D,yEAAsE;AAEtE,IAAiB,kCAAkC,CAwFlD;AAxFD,WAAiB,kCAAkC;IACpC,2CAAQ,GAAG,CAAiC,KAGxD,EAAE,EAAE,CAAC,mDAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElC,wCAAK,GAAG,CAAiC,KAOrD,EAAoC,EAAE;QACrC,MAAM,GAAG,GAA2B,mDAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1E,MAAM,UAAU,GAAsC,MAAM,CAAC,WAAW,CACtE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAC/C,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE;YACrB,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;YACpB,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,KAAK;YAC1B,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,IAAI;YAC7B,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,CACjC;aACE,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,SAAS,CAAC,IAAI,CACd,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,CAC1D,KAA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AAM,EAAE;gBACN,MAAM,EAAE,KAAK;aACd,EACD,IAAI,EAAE,KAAK,CAAC,SAAS;gBACnB,CAAC,CAAC,cAAc,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;gBACpE,CAAC,CAAC,SAAS,IAGU,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,EAxFgB,kCAAkC,kDAAlC,kCAAkC,QAwFlD"}
|
|
@@ -9,7 +9,7 @@ var LlmApplicationProgrammer;
|
|
|
9
9
|
LlmApplicationProgrammer.validate = (props) => {
|
|
10
10
|
let top;
|
|
11
11
|
return (metadata, explore) => {
|
|
12
|
-
var _a, _b;
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13
13
|
top !== null && top !== void 0 ? top : (top = metadata);
|
|
14
14
|
if (explore.top === false)
|
|
15
15
|
if (explore.object === ((_a = top === null || top === void 0 ? void 0 : top.objects[0]) === null || _a === void 0 ? void 0 : _a.type) &&
|
|
@@ -22,11 +22,11 @@ var LlmApplicationProgrammer;
|
|
|
22
22
|
else
|
|
23
23
|
return LlmSchemaProgrammer_1.LlmSchemaProgrammer.validate(props)(metadata);
|
|
24
24
|
const output = [];
|
|
25
|
-
const
|
|
25
|
+
const validity = metadata.size() === 1 &&
|
|
26
26
|
metadata.objects.length === 1 &&
|
|
27
27
|
metadata.isRequired() === true &&
|
|
28
28
|
metadata.nullable === false;
|
|
29
|
-
if (
|
|
29
|
+
if (validity === false)
|
|
30
30
|
output.push("LLM application's generic arugment must be a class/interface type.");
|
|
31
31
|
const object = (_b = metadata.objects[0]) === null || _b === void 0 ? void 0 : _b.type;
|
|
32
32
|
if (object !== undefined) {
|
|
@@ -34,17 +34,25 @@ var LlmApplicationProgrammer;
|
|
|
34
34
|
output.push("LLM application does not allow dynamic keys on class/interface type.");
|
|
35
35
|
let least = false;
|
|
36
36
|
for (const p of object.properties) {
|
|
37
|
+
const name = JSON.stringify(p.key.getSoleLiteral());
|
|
37
38
|
const value = p.value;
|
|
38
39
|
if (value.functions.length) {
|
|
39
40
|
least || (least = true);
|
|
40
|
-
if (
|
|
41
|
+
if (validity === false) {
|
|
41
42
|
if (value.functions.length !== 1 || value.size() !== 1)
|
|
42
|
-
output.push(
|
|
43
|
+
output.push(`LLM application's function (${name}) type does not allow union type.`);
|
|
43
44
|
if (value.isRequired() === false)
|
|
44
|
-
output.push(
|
|
45
|
+
output.push(`LLM application's function (${name}) type must be required.`);
|
|
45
46
|
if (value.nullable === true)
|
|
46
|
-
output.push(
|
|
47
|
+
output.push(`LLM application's function (${name}) type must not be nullable.`);
|
|
47
48
|
}
|
|
49
|
+
const description = concatDescription(JsonApplicationProgrammer_1.JsonApplicationProgrammer.writeDescription({
|
|
50
|
+
description: (_g = (_c = p.description) !== null && _c !== void 0 ? _c : (_f = (_e = (_d = p.jsDocTags.find((tag) => tag.name === "description")) === null || _d === void 0 ? void 0 : _d.text) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.text) !== null && _g !== void 0 ? _g : null,
|
|
51
|
+
jsDocTags: p.jsDocTags,
|
|
52
|
+
kind: "summary",
|
|
53
|
+
}));
|
|
54
|
+
if (description !== undefined && description.length > 1024)
|
|
55
|
+
output.push(`LLM application's function (${name}) description must not exceed 1,024 characters.`);
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
if (least === false)
|
|
@@ -60,10 +68,12 @@ var LlmApplicationProgrammer;
|
|
|
60
68
|
if (func.output.size() && func.output.isRequired() === false)
|
|
61
69
|
output.push(`${prefix}'s return type must not be union type with undefined.`);
|
|
62
70
|
if (/^[0-9]/.test((_a = name[0]) !== null && _a !== void 0 ? _a : "") === true)
|
|
63
|
-
output.push(
|
|
71
|
+
output.push(`${prefix} name must not start with a number.`);
|
|
64
72
|
if (/^[a-zA-Z0-9_-]+$/.test(name) === false)
|
|
65
|
-
output.push(
|
|
66
|
-
if (
|
|
73
|
+
output.push(`${prefix} name must be alphanumeric with underscore or hypen.`);
|
|
74
|
+
if (name.length > 64)
|
|
75
|
+
output.push(`${prefix} name must not exceed 64 characters.`);
|
|
76
|
+
if (func.parameters.length !== 0 && func.parameters.length !== 1)
|
|
67
77
|
output.push(`${prefix} must have a single parameter.`);
|
|
68
78
|
if (func.parameters.length !== 0) {
|
|
69
79
|
const type = func.parameters[0].type;
|
|
@@ -154,14 +164,17 @@ var LlmApplicationProgrammer;
|
|
|
154
164
|
};
|
|
155
165
|
};
|
|
156
166
|
const writeParameters = (props) => {
|
|
157
|
-
var _a, _b, _c, _d, _e;
|
|
158
|
-
const schema = (_a = props.function.parameters[0]) === null || _a === void 0 ? void 0 : _a.schema
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
var _a, _b, _c, _d, _e, _f;
|
|
168
|
+
const schema = (_b = (_a = props.function.parameters[0]) === null || _a === void 0 ? void 0 : _a.schema) !== null && _b !== void 0 ? _b : {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {},
|
|
171
|
+
additionalProperties: false,
|
|
172
|
+
required: [],
|
|
173
|
+
};
|
|
161
174
|
const result = LlmSchemaComposer_1.LlmSchemaComposer.parameters(props.model)({
|
|
162
175
|
config: LlmSchemaComposer_1.LlmSchemaComposer.defaultConfig(props.model),
|
|
163
176
|
components: props.components,
|
|
164
|
-
schema: Object.assign(Object.assign({}, schema), { title: (
|
|
177
|
+
schema: Object.assign(Object.assign({}, schema), { title: (_c = schema.title) !== null && _c !== void 0 ? _c : (_d = props.function.parameters[0]) === null || _d === void 0 ? void 0 : _d.title, description: (_e = schema.description) !== null && _e !== void 0 ? _e : (_f = props.function.parameters[0]) === null || _f === void 0 ? void 0 : _f.description }),
|
|
165
178
|
accessor: props.accessor,
|
|
166
179
|
});
|
|
167
180
|
if (result.success === false) {
|
|
@@ -186,5 +199,16 @@ var LlmApplicationProgrammer;
|
|
|
186
199
|
}
|
|
187
200
|
return result.value;
|
|
188
201
|
};
|
|
202
|
+
const concatDescription = (p) => {
|
|
203
|
+
var _a, _b, _c;
|
|
204
|
+
if (!((_a = p.summary) === null || _a === void 0 ? void 0 : _a.length) || !((_b = p.description) === null || _b === void 0 ? void 0 : _b.length))
|
|
205
|
+
return (_c = p.summary) !== null && _c !== void 0 ? _c : p.description;
|
|
206
|
+
const summary = p.summary.endsWith(".")
|
|
207
|
+
? p.summary.slice(0, -1)
|
|
208
|
+
: p.summary;
|
|
209
|
+
return p.description.startsWith(summary)
|
|
210
|
+
? p.description
|
|
211
|
+
: summary + ".\n\n" + p.description;
|
|
212
|
+
};
|
|
189
213
|
})(LlmApplicationProgrammer || (exports.LlmApplicationProgrammer = LlmApplicationProgrammer = {}));
|
|
190
214
|
//# sourceMappingURL=LlmApplicationProgrammer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmApplicationProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/llm/LlmApplicationProgrammer.ts"],"names":[],"mappings":";;;AAOA,wFAAqF;AAUrF,iFAA8E;AAC9E,+DAA4D;AAE5D,IAAiB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"LlmApplicationProgrammer.js","sourceRoot":"","sources":["../../../src/programmers/llm/LlmApplicationProgrammer.ts"],"names":[],"mappings":";;;AAOA,wFAAqF;AAUrF,iFAA8E;AAC9E,+DAA4D;AAE5D,IAAiB,wBAAwB,CAkTxC;AAlTD,WAAiB,wBAAwB;IAC1B,iCAAQ,GAAG,CAAiC,KAGxD,EAAE,EAAE;QACH,IAAI,GAAyB,CAAC;QAC9B,OAAO,CACL,QAAkB,EAClB,OAAiC,EACvB,EAAE;;YACZ,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,QAAQ,EAAC;YACjB,IAAI,OAAO,CAAC,GAAG,KAAK,KAAK;gBACvB,IACE,OAAO,CAAC,MAAM,MAAK,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAA;oBACxC,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C,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC7C,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACd,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC;YACtC,CAAC,CAAC,CAAC,CAAC,WAAW;YACf,CAAC,CAAC,OAAO,GAAG,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC,EAlTgB,wBAAwB,wCAAxB,wBAAwB,QAkTxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.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": "^2.
|
|
44
|
+
"@samchon/openapi": "^2.4.0",
|
|
45
45
|
"commander": "^10.0.0",
|
|
46
46
|
"comment-json": "^4.2.3",
|
|
47
47
|
"inquirer": "^8.2.5",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"typescript": ">=4.8.0 <5.8.0",
|
|
53
|
-
"@samchon/openapi": ">=2.
|
|
53
|
+
"@samchon/openapi": ">=2.4.0 <3.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"rollup": "^4.18.0",
|
|
69
69
|
"suppress-warnings": "^1.0.2",
|
|
70
70
|
"ts-node": "^10.9.2",
|
|
71
|
-
"typescript": "~5.7.
|
|
71
|
+
"typescript": "~5.7.3"
|
|
72
72
|
},
|
|
73
73
|
"stackblitz": {
|
|
74
74
|
"startCommand": "npm install && npm run test"
|
|
@@ -130,6 +130,33 @@ export namespace JsonApplicationProgrammer {
|
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
export const writeDescription = <Kind extends "summary" | "title">(props: {
|
|
134
|
+
description: string | null;
|
|
135
|
+
jsDocTags: IJsDocTagInfo[];
|
|
136
|
+
kind: Kind;
|
|
137
|
+
}): Kind extends "summary"
|
|
138
|
+
? { summary?: string; description?: string }
|
|
139
|
+
: { title?: string; description?: string } => {
|
|
140
|
+
const title: string | undefined = (() => {
|
|
141
|
+
const [explicit] = getJsDocTexts({
|
|
142
|
+
jsDocTags: props.jsDocTags,
|
|
143
|
+
name: props.kind,
|
|
144
|
+
});
|
|
145
|
+
if (explicit?.length) return explicit;
|
|
146
|
+
else if (!props.description?.length) return undefined;
|
|
147
|
+
|
|
148
|
+
const index: number = props.description.indexOf("\n");
|
|
149
|
+
const top: string = (
|
|
150
|
+
index === -1 ? props.description : props.description.substring(0, index)
|
|
151
|
+
).trim();
|
|
152
|
+
return top.endsWith(".") ? top.substring(0, top.length - 1) : undefined;
|
|
153
|
+
})();
|
|
154
|
+
return {
|
|
155
|
+
[props.kind]: title,
|
|
156
|
+
description: props.description?.length ? props.description : undefined,
|
|
157
|
+
} as any;
|
|
158
|
+
};
|
|
159
|
+
|
|
133
160
|
const collectFunction = <Version extends "3.0" | "3.1">(props: {
|
|
134
161
|
version: Version;
|
|
135
162
|
name: string;
|
|
@@ -217,33 +244,6 @@ export namespace JsonApplicationProgrammer {
|
|
|
217
244
|
};
|
|
218
245
|
}
|
|
219
246
|
|
|
220
|
-
const writeDescription = <Kind extends "summary" | "title">(props: {
|
|
221
|
-
description: string | null;
|
|
222
|
-
jsDocTags: IJsDocTagInfo[];
|
|
223
|
-
kind: Kind;
|
|
224
|
-
}): Kind extends "summary"
|
|
225
|
-
? { summary?: string; description?: string }
|
|
226
|
-
: { title?: string; description?: string } => {
|
|
227
|
-
const title: string | undefined = (() => {
|
|
228
|
-
const [explicit] = getJsDocTexts({
|
|
229
|
-
jsDocTags: props.jsDocTags,
|
|
230
|
-
name: props.kind,
|
|
231
|
-
});
|
|
232
|
-
if (explicit?.length) return explicit;
|
|
233
|
-
else if (!props.description?.length) return undefined;
|
|
234
|
-
|
|
235
|
-
const index: number = props.description.indexOf("\n");
|
|
236
|
-
const top: string = (
|
|
237
|
-
index === -1 ? props.description : props.description.substring(0, index)
|
|
238
|
-
).trim();
|
|
239
|
-
return top.endsWith(".") ? top.substring(0, top.length - 1) : undefined;
|
|
240
|
-
})();
|
|
241
|
-
return {
|
|
242
|
-
[props.kind]: title,
|
|
243
|
-
description: props.description?.length ? props.description : undefined,
|
|
244
|
-
} as any;
|
|
245
|
-
};
|
|
246
|
-
|
|
247
247
|
const writeDescriptionFromJsDocTag = (props: {
|
|
248
248
|
jsDocTags: IJsDocTagInfo[];
|
|
249
249
|
name: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
|
|
4
|
+
import { TypeFactory } from "../../factories/TypeFactory";
|
|
5
|
+
|
|
4
6
|
import { ILlmApplicationOfValidate } from "../../schemas/llm/ILlmApplicationOfValidate";
|
|
5
7
|
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
6
8
|
import { MetadataParameter } from "../../schemas/metadata/MetadataParameter";
|
|
@@ -55,7 +57,7 @@ export namespace LlmApplicationOfValidateProgrammer {
|
|
|
55
57
|
modulo: props.modulo,
|
|
56
58
|
className: props.name,
|
|
57
59
|
name: func.name,
|
|
58
|
-
parameter: parameters[func.name]
|
|
60
|
+
parameter: parameters[func.name] ?? null,
|
|
59
61
|
}),
|
|
60
62
|
})),
|
|
61
63
|
};
|
|
@@ -64,10 +66,22 @@ export namespace LlmApplicationOfValidateProgrammer {
|
|
|
64
66
|
const writeValidadtor = (props: {
|
|
65
67
|
context: ITypiaContext;
|
|
66
68
|
modulo: ts.LeftHandSideExpression;
|
|
67
|
-
parameter: MetadataParameter;
|
|
69
|
+
parameter: MetadataParameter | null;
|
|
68
70
|
name: string;
|
|
69
71
|
className?: string;
|
|
70
72
|
}): ((props: object) => IValidation<unknown>) => {
|
|
73
|
+
if (props.parameter === null)
|
|
74
|
+
return ValidateProgrammer.write({
|
|
75
|
+
...props,
|
|
76
|
+
type: props.context.checker.getTypeFromTypeNode(
|
|
77
|
+
TypeFactory.keyword("any"),
|
|
78
|
+
),
|
|
79
|
+
config: {
|
|
80
|
+
equals: false,
|
|
81
|
+
},
|
|
82
|
+
name: undefined,
|
|
83
|
+
}) as any;
|
|
84
|
+
|
|
71
85
|
const type = props.parameter.tsType;
|
|
72
86
|
if (type === undefined)
|
|
73
87
|
// unreachable
|
|
@@ -42,12 +42,12 @@ export namespace LlmApplicationProgrammer {
|
|
|
42
42
|
else return LlmSchemaProgrammer.validate(props)(metadata);
|
|
43
43
|
|
|
44
44
|
const output: string[] = [];
|
|
45
|
-
const
|
|
45
|
+
const validity: boolean =
|
|
46
46
|
metadata.size() === 1 &&
|
|
47
47
|
metadata.objects.length === 1 &&
|
|
48
48
|
metadata.isRequired() === true &&
|
|
49
49
|
metadata.nullable === false;
|
|
50
|
-
if (
|
|
50
|
+
if (validity === false)
|
|
51
51
|
output.push(
|
|
52
52
|
"LLM application's generic arugment must be a class/interface type.",
|
|
53
53
|
);
|
|
@@ -60,23 +60,40 @@ export namespace LlmApplicationProgrammer {
|
|
|
60
60
|
);
|
|
61
61
|
let least: boolean = false;
|
|
62
62
|
for (const p of object.properties) {
|
|
63
|
+
const name: string = JSON.stringify(p.key.getSoleLiteral()!);
|
|
63
64
|
const value: Metadata = p.value;
|
|
64
65
|
if (value.functions.length) {
|
|
65
66
|
least ||= true;
|
|
66
|
-
if (
|
|
67
|
+
if (validity === false) {
|
|
67
68
|
if (value.functions.length !== 1 || value.size() !== 1)
|
|
68
69
|
output.push(
|
|
69
|
-
|
|
70
|
+
`LLM application's function (${name}) type does not allow union type.`,
|
|
70
71
|
);
|
|
71
72
|
if (value.isRequired() === false)
|
|
72
73
|
output.push(
|
|
73
|
-
|
|
74
|
+
`LLM application's function (${name}) type must be required.`,
|
|
74
75
|
);
|
|
75
76
|
if (value.nullable === true)
|
|
76
77
|
output.push(
|
|
77
|
-
|
|
78
|
+
`LLM application's function (${name}) type must not be nullable.`,
|
|
78
79
|
);
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
const description: string | undefined = concatDescription(
|
|
83
|
+
JsonApplicationProgrammer.writeDescription({
|
|
84
|
+
description:
|
|
85
|
+
p.description ??
|
|
86
|
+
p.jsDocTags.find((tag) => tag.name === "description")
|
|
87
|
+
?.text?.[0]?.text ??
|
|
88
|
+
null,
|
|
89
|
+
jsDocTags: p.jsDocTags,
|
|
90
|
+
kind: "summary",
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
if (description !== undefined && description.length > 1_024)
|
|
94
|
+
output.push(
|
|
95
|
+
`LLM application's function (${name}) description must not exceed 1,024 characters.`,
|
|
96
|
+
);
|
|
80
97
|
}
|
|
81
98
|
}
|
|
82
99
|
if (least === false)
|
|
@@ -96,10 +113,14 @@ export namespace LlmApplicationProgrammer {
|
|
|
96
113
|
`${prefix}'s return type must not be union type with undefined.`,
|
|
97
114
|
);
|
|
98
115
|
if (/^[0-9]/.test(name[0] ?? "") === true)
|
|
99
|
-
output.push(
|
|
116
|
+
output.push(`${prefix} name must not start with a number.`);
|
|
100
117
|
if (/^[a-zA-Z0-9_-]+$/.test(name) === false)
|
|
101
|
-
output.push(
|
|
102
|
-
|
|
118
|
+
output.push(
|
|
119
|
+
`${prefix} name must be alphanumeric with underscore or hypen.`,
|
|
120
|
+
);
|
|
121
|
+
if (name.length > 64)
|
|
122
|
+
output.push(`${prefix} name must not exceed 64 characters.`);
|
|
123
|
+
if (func.parameters.length !== 0 && func.parameters.length !== 1)
|
|
103
124
|
output.push(`${prefix} must have a single parameter.`);
|
|
104
125
|
if (func.parameters.length !== 0) {
|
|
105
126
|
const type: Metadata = func.parameters[0]!.type;
|
|
@@ -233,9 +254,12 @@ export namespace LlmApplicationProgrammer {
|
|
|
233
254
|
errors: string[];
|
|
234
255
|
accessor: string;
|
|
235
256
|
}): ILlmSchema.ModelParameters[Model] | null => {
|
|
236
|
-
const schema = props.function.parameters[0]?.schema
|
|
237
|
-
|
|
238
|
-
|
|
257
|
+
const schema = props.function.parameters[0]?.schema ?? {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: {},
|
|
260
|
+
additionalProperties: false,
|
|
261
|
+
required: [],
|
|
262
|
+
};
|
|
239
263
|
const result: IResult<
|
|
240
264
|
ILlmSchema.ModelParameters[Model],
|
|
241
265
|
IOpenApiSchemaError
|
|
@@ -286,4 +310,18 @@ export namespace LlmApplicationProgrammer {
|
|
|
286
310
|
}
|
|
287
311
|
return result.value;
|
|
288
312
|
};
|
|
313
|
+
|
|
314
|
+
const concatDescription = (p: {
|
|
315
|
+
summary?: string | undefined;
|
|
316
|
+
description?: string | undefined;
|
|
317
|
+
}): string | undefined => {
|
|
318
|
+
if (!p.summary?.length || !p.description?.length)
|
|
319
|
+
return p.summary ?? p.description;
|
|
320
|
+
const summary: string = p.summary.endsWith(".")
|
|
321
|
+
? p.summary.slice(0, -1)
|
|
322
|
+
: p.summary;
|
|
323
|
+
return p.description.startsWith(summary)
|
|
324
|
+
? p.description
|
|
325
|
+
: summary + ".\n\n" + p.description;
|
|
326
|
+
};
|
|
289
327
|
}
|