typia 7.0.0-dev.20241126 → 7.0.0-dev.20241126-2
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/executable/TypiaSetupWizard.js +7 -3
- package/lib/executable/TypiaSetupWizard.js.map +1 -1
- package/lib/index.mjs +3 -3
- package/lib/index.mjs.map +1 -1
- package/lib/json.d.ts +31 -43
- package/lib/json.js +4 -4
- package/lib/json.js.map +1 -1
- package/lib/programmers/json/JsonApplicationProgrammer.d.ts +2 -2
- package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
- package/lib/schemas/json/IJsonApplication.d.ts +12 -35
- package/lib/schemas/json/IJsonApplication.js +55 -0
- package/lib/schemas/json/IJsonApplication.js.map +1 -1
- package/lib/schemas/json/IJsonSchemaCollection.d.ts +7 -0
- package/lib/schemas/json/__IJsonApplication.d.ts +35 -0
- package/lib/schemas/json/__IJsonApplication.js +3 -0
- package/lib/schemas/json/__IJsonApplication.js.map +1 -0
- package/lib/transformers/CallExpressionTransformer.js +3 -2
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +0 -5
- package/lib/transformers/features/json/JsonApplicationTransformer.js +92 -85
- package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
- package/package.json +5 -4
- package/src/executable/TypiaSetupWizard.ts +7 -2
- package/src/json.ts +82 -27
- package/src/programmers/json/JsonApplicationProgrammer.ts +13 -13
- package/src/programmers/llm/LlmApplicationProgrammer.ts +4 -4
- package/src/schemas/json/IJsonApplication.ts +68 -56
- package/src/schemas/json/IJsonSchemaCollection.ts +7 -0
- package/src/schemas/json/__IJsonApplication.ts +63 -0
- package/src/transformers/CallExpressionTransformer.ts +3 -2
- package/src/transformers/features/json/JsonApplicationTransformer.ts +92 -92
|
@@ -1,87 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
2
|
+
// import ts from "typescript";
|
|
3
|
+
// import { LiteralFactory } from "../../../factories/LiteralFactory";
|
|
4
|
+
// import { MetadataCollection } from "../../../factories/MetadataCollection";
|
|
5
|
+
// import { MetadataFactory } from "../../../factories/MetadataFactory";
|
|
6
|
+
// import { IJsonApplication } from "../../../schemas/json/IJsonApplication";
|
|
7
|
+
// import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
8
|
+
// import { JsonApplicationProgrammer } from "../../../programmers/json/JsonApplicationProgrammer";
|
|
9
|
+
// import { ValidationPipe } from "../../../typings/ValidationPipe";
|
|
10
|
+
// import { ITransformProps } from "../../ITransformProps";
|
|
11
|
+
// import { TransformerError } from "../../TransformerError";
|
|
12
|
+
// export namespace JsonApplicationTransformer {
|
|
13
|
+
// export const transform = (props: ITransformProps): ts.Expression => {
|
|
14
|
+
// // GET GENERIC ARGUMENT
|
|
15
|
+
// if (!props.expression.typeArguments?.length)
|
|
16
|
+
// throw new TransformerError({
|
|
17
|
+
// code: "typia.json.application",
|
|
18
|
+
// message: "no generic argument.",
|
|
19
|
+
// });
|
|
20
|
+
// const top: ts.Node = props.expression.typeArguments[0]!;
|
|
21
|
+
// if (ts.isTypeNode(top) === false) return props.expression;
|
|
22
|
+
// const version: "3.0" | "3.1" = get_parameter<"3.0" | "3.1">({
|
|
23
|
+
// checker: props.context.checker,
|
|
24
|
+
// name: "Version",
|
|
25
|
+
// is: (str) => str === "3.0" || str === "3.1",
|
|
26
|
+
// cast: (str) => str as "3.0" | "3.1",
|
|
27
|
+
// default: () => "3.1",
|
|
28
|
+
// })(props.expression.typeArguments[1]);
|
|
29
|
+
// // GET TYPE
|
|
30
|
+
// const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
|
|
31
|
+
// const collection: MetadataCollection = new MetadataCollection({
|
|
32
|
+
// replace: MetadataCollection.replace,
|
|
33
|
+
// });
|
|
34
|
+
// const result: ValidationPipe<Metadata, MetadataFactory.IError> =
|
|
35
|
+
// MetadataFactory.analyze({
|
|
36
|
+
// checker: props.context.checker,
|
|
37
|
+
// transformer: props.context.transformer,
|
|
38
|
+
// options: {
|
|
39
|
+
// escape: true,
|
|
40
|
+
// constant: true,
|
|
41
|
+
// absorb: false,
|
|
42
|
+
// functional: true,
|
|
43
|
+
// validate: JsonApplicationProgrammer.validate,
|
|
44
|
+
// },
|
|
45
|
+
// collection,
|
|
46
|
+
// type,
|
|
47
|
+
// });
|
|
48
|
+
// if (result.success === false)
|
|
49
|
+
// throw TransformerError.from({
|
|
50
|
+
// code: "typia.json.application",
|
|
51
|
+
// errors: result.errors,
|
|
52
|
+
// });
|
|
53
|
+
// // GENERATE LLM APPLICATION
|
|
54
|
+
// const app: IJsonApplication<"3.0" | "3.1"> =
|
|
55
|
+
// JsonApplicationProgrammer.write({
|
|
56
|
+
// version,
|
|
57
|
+
// metadata: result.data,
|
|
58
|
+
// });
|
|
59
|
+
// const literal: ts.Expression = LiteralFactory.write(app);
|
|
60
|
+
// return literal;
|
|
61
|
+
// };
|
|
62
|
+
// const get_parameter =
|
|
63
|
+
// <Value>(props: {
|
|
64
|
+
// checker: ts.TypeChecker;
|
|
65
|
+
// name: string;
|
|
66
|
+
// is: (value: string) => boolean;
|
|
67
|
+
// cast: (value: string) => Value;
|
|
68
|
+
// default: () => Value;
|
|
69
|
+
// }) =>
|
|
70
|
+
// (node: ts.TypeNode | undefined): Value => {
|
|
71
|
+
// if (!node) return props.default();
|
|
72
|
+
// // CHECK LITERAL TYPE
|
|
73
|
+
// const type: ts.Type = props.checker.getTypeFromTypeNode(node);
|
|
74
|
+
// if (
|
|
75
|
+
// !type.isLiteral() &&
|
|
76
|
+
// (type.getFlags() & ts.TypeFlags.BooleanLiteral) === 0
|
|
77
|
+
// )
|
|
78
|
+
// throw new TransformerError({
|
|
79
|
+
// code: "typia.json.application",
|
|
80
|
+
// message: `generic argument "${props.name}" must be constant.`,
|
|
81
|
+
// });
|
|
82
|
+
// // GET VALUE AND VALIDATE IT
|
|
83
|
+
// const value = type.isLiteral()
|
|
84
|
+
// ? type.value
|
|
85
|
+
// : props.checker.typeToString(type);
|
|
86
|
+
// if (typeof value !== "string" || props.is(value) === false)
|
|
87
|
+
// throw new TransformerError({
|
|
88
|
+
// code: "typia.json.application",
|
|
89
|
+
// message: `invalid value on generic argument "${props.name}".`,
|
|
90
|
+
// });
|
|
91
|
+
// return props.cast(value);
|
|
92
|
+
// };
|
|
93
|
+
// }
|
|
87
94
|
//# sourceMappingURL=JsonApplicationTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonApplicationTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/json/JsonApplicationTransformer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"JsonApplicationTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/json/JsonApplicationTransformer.ts"],"names":[],"mappings":";AAAA,+BAA+B;AAE/B,sEAAsE;AACtE,8EAA8E;AAC9E,wEAAwE;AAExE,6EAA6E;AAC7E,iEAAiE;AAEjE,mGAAmG;AAEnG,oEAAoE;AAEpE,2DAA2D;AAC3D,6DAA6D;AAE7D,gDAAgD;AAChD,0EAA0E;AAC1E,8BAA8B;AAC9B,mDAAmD;AACnD,qCAAqC;AACrC,0CAA0C;AAC1C,2CAA2C;AAC3C,YAAY;AAEZ,+DAA+D;AAC/D,iEAAiE;AAEjE,oEAAoE;AACpE,wCAAwC;AACxC,yBAAyB;AACzB,qDAAqD;AACrD,6CAA6C;AAC7C,8BAA8B;AAC9B,6CAA6C;AAE7C,kBAAkB;AAClB,4EAA4E;AAC5E,sEAAsE;AACtE,6CAA6C;AAC7C,UAAU;AACV,uEAAuE;AACvE,kCAAkC;AAClC,0CAA0C;AAC1C,kDAAkD;AAClD,qBAAqB;AACrB,0BAA0B;AAC1B,4BAA4B;AAC5B,2BAA2B;AAC3B,8BAA8B;AAC9B,0DAA0D;AAC1D,aAAa;AACb,sBAAsB;AACtB,gBAAgB;AAChB,YAAY;AACZ,oCAAoC;AACpC,sCAAsC;AACtC,0CAA0C;AAC1C,iCAAiC;AACjC,YAAY;AAEZ,kCAAkC;AAClC,mDAAmD;AACnD,0CAA0C;AAC1C,mBAAmB;AACnB,iCAAiC;AACjC,YAAY;AACZ,gEAAgE;AAChE,sBAAsB;AACtB,OAAO;AAEP,0BAA0B;AAC1B,uBAAuB;AACvB,iCAAiC;AACjC,sBAAsB;AACtB,wCAAwC;AACxC,wCAAwC;AACxC,8BAA8B;AAC9B,YAAY;AACZ,kDAAkD;AAClD,2CAA2C;AAE3C,8BAA8B;AAC9B,uEAAuE;AACvE,aAAa;AACb,+BAA+B;AAC/B,gEAAgE;AAChE,UAAU;AACV,uCAAuC;AACvC,4CAA4C;AAC5C,2EAA2E;AAC3E,cAAc;AAEd,qCAAqC;AACrC,uCAAuC;AACvC,uBAAuB;AACvB,8CAA8C;AAC9C,oEAAoE;AACpE,uCAAuC;AACvC,4CAA4C;AAC5C,2EAA2E;AAC3E,cAAc;AACd,kCAAkC;AAClC,SAAS;AACT,IAAI"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "7.0.0-dev.20241126",
|
|
3
|
+
"version": "7.0.0-dev.20241126-2",
|
|
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": "
|
|
44
|
+
"@samchon/openapi": "2.0.0-dev.20241126",
|
|
45
45
|
"commander": "^10.0.0",
|
|
46
46
|
"comment-json": "^4.2.3",
|
|
47
47
|
"inquirer": "^8.2.5",
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"randexp": "^0.5.3"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"typescript": ">=4.8.0 <5.7.0"
|
|
52
|
+
"typescript": ">=4.8.0 <5.7.0",
|
|
53
|
+
"@samchon/openapi": ">=1.2.4 <2.0.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"rollup": "^4.18.0",
|
|
68
69
|
"suppress-warnings": "^1.0.2",
|
|
69
70
|
"ts-node": "^10.9.2",
|
|
70
|
-
"typescript": "
|
|
71
|
+
"typescript": "~5.6.3"
|
|
71
72
|
},
|
|
72
73
|
"stackblitz": {
|
|
73
74
|
"startCommand": "npm install && npm run test"
|
|
@@ -158,8 +158,13 @@ export namespace TypiaSetupWizard {
|
|
|
158
158
|
"npm" | "pnpm" | "yarn" | "bun" | null
|
|
159
159
|
> => {
|
|
160
160
|
const result: DetectResult | null = await detect({ cwd: process.cwd() });
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
switch (result?.name) {
|
|
162
|
+
case "npm":
|
|
163
|
+
case "deno":
|
|
164
|
+
return null; // NPM case is still selectable & Deno is not supported
|
|
165
|
+
default:
|
|
166
|
+
return result?.name ?? null;
|
|
167
|
+
}
|
|
163
168
|
};
|
|
164
169
|
|
|
165
170
|
const getTypeScriptVersion = async (): Promise<string> => {
|
package/src/json.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IJsonApplication } from "./schemas/json/IJsonApplication";
|
|
2
1
|
import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaCollection";
|
|
3
2
|
|
|
4
3
|
import { IValidation } from "./IValidation";
|
|
@@ -15,55 +14,59 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
15
14
|
METADATA
|
|
16
15
|
----------------------------------------------------------- */
|
|
17
16
|
/**
|
|
18
|
-
* > You must configure the generic argument `
|
|
17
|
+
* > You must configure the generic argument `Types`.
|
|
19
18
|
*
|
|
20
|
-
*
|
|
19
|
+
* JSON Schemas generator.
|
|
21
20
|
*
|
|
22
|
-
* Creates
|
|
23
|
-
*
|
|
21
|
+
* Creates a JSON schema list which contains both main JSON schemas
|
|
22
|
+
* and components. Note that, all of the named types are stored in the
|
|
23
|
+
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
26
|
+
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
27
|
+
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
|
|
27
28
|
*
|
|
28
|
-
* @template
|
|
29
|
+
* @template Types Tuple of target types
|
|
29
30
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
30
|
-
* @
|
|
31
|
+
* @return JSON schema list
|
|
31
32
|
*
|
|
32
33
|
* @author Jeongho Nam - https://github.com/samchon
|
|
33
34
|
*/
|
|
34
|
-
export function
|
|
35
|
+
export function schemas(): never;
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* JSON Schemas generator.
|
|
38
39
|
*
|
|
39
|
-
* Creates
|
|
40
|
-
*
|
|
40
|
+
* Creates a JSON schema list which contains both main JSON schemas
|
|
41
|
+
* and components. Note that, all of the named types are stored in the
|
|
42
|
+
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
41
43
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
+
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
45
|
+
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
46
|
+
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
|
|
44
47
|
*
|
|
45
|
-
* @template
|
|
48
|
+
* @template Types Tuple of target types
|
|
46
49
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
47
|
-
* @
|
|
50
|
+
* @return JSON schema list
|
|
48
51
|
*
|
|
49
52
|
* @author Jeongho Nam - https://github.com/samchon
|
|
50
53
|
*/
|
|
51
|
-
export function
|
|
52
|
-
|
|
54
|
+
export function schemas<
|
|
55
|
+
Types extends unknown[],
|
|
53
56
|
Version extends "3.0" | "3.1" = "3.1",
|
|
54
|
-
>():
|
|
57
|
+
>(): IJsonSchemaCollection<Version, Types>;
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* @internal
|
|
58
61
|
*/
|
|
59
|
-
export function
|
|
60
|
-
halt("
|
|
62
|
+
export function schemas(): never {
|
|
63
|
+
halt("schemas");
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
/**
|
|
64
67
|
* > You must configure the generic argument `Types`.
|
|
65
68
|
*
|
|
66
|
-
* JSON
|
|
69
|
+
* JSON Schemas generator.
|
|
67
70
|
*
|
|
68
71
|
* Creates a JSON schema list which contains both main JSON schemas
|
|
69
72
|
* and components. Note that, all of the named types are stored in the
|
|
@@ -77,12 +80,15 @@ export function application(): never {
|
|
|
77
80
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
78
81
|
* @return JSON schema list
|
|
79
82
|
*
|
|
83
|
+
* @deprcated Use {@link schemas} function instead please.
|
|
84
|
+
* This function would be changed to return {@linkk ILlmApplication} like
|
|
85
|
+
* structure in the future version (maybe next v8 major update).
|
|
80
86
|
* @author Jeongho Nam - https://github.com/samchon
|
|
81
87
|
*/
|
|
82
|
-
export function
|
|
88
|
+
export function application(): never;
|
|
83
89
|
|
|
84
90
|
/**
|
|
85
|
-
* JSON
|
|
91
|
+
* JSON Schemas generator.
|
|
86
92
|
*
|
|
87
93
|
* Creates a JSON schema list which contains both main JSON schemas
|
|
88
94
|
* and components. Note that, all of the named types are stored in the
|
|
@@ -96,9 +102,12 @@ export function schemas(): never;
|
|
|
96
102
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
97
103
|
* @return JSON schema list
|
|
98
104
|
*
|
|
105
|
+
* @deprcated Use {@link schemas} function instead please.
|
|
106
|
+
* This function would be changed to return {@linkk ILlmApplication} like
|
|
107
|
+
* structure in the future version (maybe next v8 major update).
|
|
99
108
|
* @author Jeongho Nam - https://github.com/samchon
|
|
100
109
|
*/
|
|
101
|
-
export function
|
|
110
|
+
export function application<
|
|
102
111
|
Types extends unknown[],
|
|
103
112
|
Version extends "3.0" | "3.1" = "3.1",
|
|
104
113
|
>(): IJsonSchemaCollection<Version, Types>;
|
|
@@ -106,10 +115,56 @@ export function schemas<
|
|
|
106
115
|
/**
|
|
107
116
|
* @internal
|
|
108
117
|
*/
|
|
109
|
-
export function
|
|
118
|
+
export function application(): never {
|
|
110
119
|
halt("application");
|
|
111
120
|
}
|
|
112
121
|
|
|
122
|
+
// /**
|
|
123
|
+
// * > You must configure the generic argument `App`.
|
|
124
|
+
// *
|
|
125
|
+
// * TypeScript functions to JSON schema based application schema.
|
|
126
|
+
// *
|
|
127
|
+
// * Creates an application schema collecting the functions' schema based on the
|
|
128
|
+
// * JSON schema specification.
|
|
129
|
+
// *
|
|
130
|
+
// * The default version of the OpenAPI specification is `"3.1"`, but you can
|
|
131
|
+
// * specify the version by configuring the second generic argument `Version`.
|
|
132
|
+
// *
|
|
133
|
+
// * @template App Target class or interface type collecting the functions
|
|
134
|
+
// * @template Version Version of OpenAPI specification. Default is 3.1
|
|
135
|
+
// * @returns Application schema of JSON schema based
|
|
136
|
+
// *
|
|
137
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
138
|
+
// */
|
|
139
|
+
// export function application(): never;
|
|
140
|
+
|
|
141
|
+
// /**
|
|
142
|
+
// * TypeScript functions to JSON schema based application schema.
|
|
143
|
+
// *
|
|
144
|
+
// * Creates an application schema collecting the functions' schema based on the
|
|
145
|
+
// * JSON schema specification.
|
|
146
|
+
// *
|
|
147
|
+
// * The default version of the OpenAPI specification is `"3.1"`, but you can
|
|
148
|
+
// * specify the version by configuring the second generic argument `Version`.
|
|
149
|
+
// *
|
|
150
|
+
// * @template App Target class or interface type collecting the functions
|
|
151
|
+
// * @template Version Version of OpenAPI specification. Default is 3.1
|
|
152
|
+
// * @returns Application schema of JSON schema based
|
|
153
|
+
// *
|
|
154
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
155
|
+
// */
|
|
156
|
+
// export function application<
|
|
157
|
+
// App extends object,
|
|
158
|
+
// Version extends "3.0" | "3.1" = "3.1",
|
|
159
|
+
// >(): IJsonApplication<Version, App>;
|
|
160
|
+
|
|
161
|
+
// /**
|
|
162
|
+
// * @internal
|
|
163
|
+
// */
|
|
164
|
+
// export function application(): never {
|
|
165
|
+
// halt("application");
|
|
166
|
+
// }
|
|
167
|
+
|
|
113
168
|
/* -----------------------------------------------------------
|
|
114
169
|
PARSE
|
|
115
170
|
----------------------------------------------------------- */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetadataFactory } from "../../factories/MetadataFactory";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { __IJsonApplication } from "../../schemas/json/__IJsonApplication";
|
|
4
4
|
import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
|
|
5
5
|
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
6
6
|
import { MetadataFunction } from "../../schemas/metadata/MetadataFunction";
|
|
@@ -60,7 +60,7 @@ export namespace JsonApplicationProgrammer {
|
|
|
60
60
|
export const write = <Version extends "3.0" | "3.1">(props: {
|
|
61
61
|
version: Version;
|
|
62
62
|
metadata: Metadata;
|
|
63
|
-
}):
|
|
63
|
+
}): __IJsonApplication<Version> => {
|
|
64
64
|
const errors: string[] = validate(props.metadata, {
|
|
65
65
|
top: true,
|
|
66
66
|
object: null,
|
|
@@ -76,18 +76,18 @@ export namespace JsonApplicationProgrammer {
|
|
|
76
76
|
|
|
77
77
|
const object: MetadataObjectType = props.metadata.objects[0]!.type;
|
|
78
78
|
const definitions: Metadata[] = [];
|
|
79
|
-
const setters: Array<(schema:
|
|
79
|
+
const setters: Array<(schema: __IJsonApplication.Schema<Version>) => void> =
|
|
80
80
|
[];
|
|
81
81
|
const collect = (
|
|
82
82
|
metadata: Metadata,
|
|
83
|
-
setter: (schema:
|
|
83
|
+
setter: (schema: __IJsonApplication.Schema<Version>) => void,
|
|
84
84
|
): void => {
|
|
85
85
|
definitions.push(metadata);
|
|
86
86
|
setters.push(setter);
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
const functions:
|
|
90
|
-
|
|
89
|
+
const functions: __IJsonApplication.IFunction<
|
|
90
|
+
__IJsonApplication.Schema<Version>
|
|
91
91
|
>[] = object.properties
|
|
92
92
|
.filter(
|
|
93
93
|
(p) =>
|
|
@@ -112,7 +112,7 @@ export namespace JsonApplicationProgrammer {
|
|
|
112
112
|
metadatas: definitions,
|
|
113
113
|
});
|
|
114
114
|
schemas.forEach((s, i) =>
|
|
115
|
-
setters[i]?.(s as
|
|
115
|
+
setters[i]?.(s as __IJsonApplication.Schema<Version>),
|
|
116
116
|
);
|
|
117
117
|
return {
|
|
118
118
|
version: props.version,
|
|
@@ -129,9 +129,9 @@ export namespace JsonApplicationProgrammer {
|
|
|
129
129
|
jsDocTags: IJsDocTagInfo[];
|
|
130
130
|
collect: (
|
|
131
131
|
metadata: Metadata,
|
|
132
|
-
setter: (schema:
|
|
132
|
+
setter: (schema: __IJsonApplication.Schema<Version>) => void,
|
|
133
133
|
) => void;
|
|
134
|
-
}):
|
|
134
|
+
}): __IJsonApplication.IFunction<__IJsonApplication.Schema<Version>> => {
|
|
135
135
|
const deprecated: boolean = props.jsDocTags.some(
|
|
136
136
|
(tag) => tag.name === "deprecated",
|
|
137
137
|
);
|
|
@@ -149,8 +149,8 @@ export namespace JsonApplicationProgrammer {
|
|
|
149
149
|
name: props.name,
|
|
150
150
|
async: props.function.async,
|
|
151
151
|
parameters: props.function.parameters.map((param) => {
|
|
152
|
-
const appParam:
|
|
153
|
-
|
|
152
|
+
const appParam: __IJsonApplication.IParameter<
|
|
153
|
+
__IJsonApplication.Schema<Version>
|
|
154
154
|
> = {
|
|
155
155
|
name: param.name,
|
|
156
156
|
...writeDescription({
|
|
@@ -178,8 +178,8 @@ export namespace JsonApplicationProgrammer {
|
|
|
178
178
|
}),
|
|
179
179
|
output: props.function.output.size()
|
|
180
180
|
? (() => {
|
|
181
|
-
const appOutput:
|
|
182
|
-
|
|
181
|
+
const appOutput: __IJsonApplication.IOutput<
|
|
182
|
+
__IJsonApplication.Schema<Version>
|
|
183
183
|
> = {
|
|
184
184
|
schema: null!,
|
|
185
185
|
required: props.function.output.isRequired(),
|
|
@@ -4,11 +4,11 @@ import { ILlmFunction } from "@samchon/openapi/lib/structures/ILlmFunction";
|
|
|
4
4
|
|
|
5
5
|
import { MetadataFactory } from "../../factories/MetadataFactory";
|
|
6
6
|
|
|
7
|
+
import { __IJsonApplication } from "../../schemas/json/__IJsonApplication";
|
|
7
8
|
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
8
9
|
import { MetadataFunction } from "../../schemas/metadata/MetadataFunction";
|
|
9
10
|
import { MetadataObjectType } from "../../schemas/metadata/MetadataObjectType";
|
|
10
11
|
|
|
11
|
-
import { IJsonApplication } from "../../module";
|
|
12
12
|
import { JsonApplicationProgrammer } from "../json/JsonApplicationProgrammer";
|
|
13
13
|
import { LlmSchemaProgrammer } from "./LlmSchemaProgrammer";
|
|
14
14
|
|
|
@@ -103,7 +103,7 @@ export namespace LlmApplicationProgrammer {
|
|
|
103
103
|
if (errors.length)
|
|
104
104
|
throw new Error("Failed to write LLM application: " + errors.join("\n"));
|
|
105
105
|
|
|
106
|
-
const application:
|
|
106
|
+
const application: __IJsonApplication<"3.1"> =
|
|
107
107
|
JsonApplicationProgrammer.write({
|
|
108
108
|
version: "3.1",
|
|
109
109
|
metadata: props.metadata,
|
|
@@ -127,7 +127,7 @@ export namespace LlmApplicationProgrammer {
|
|
|
127
127
|
const writeFunction = <Model extends ILlmApplication.Model>(props: {
|
|
128
128
|
model: Model;
|
|
129
129
|
components: OpenApi.IComponents;
|
|
130
|
-
function:
|
|
130
|
+
function: __IJsonApplication.IFunction<OpenApi.IJsonSchema>;
|
|
131
131
|
}): ILlmFunction<ILlmApplication.ModelParameters[Model]> => {
|
|
132
132
|
const parameters: ILlmApplication.ModelParameters[Model] =
|
|
133
133
|
writeParameters(props);
|
|
@@ -171,7 +171,7 @@ export namespace LlmApplicationProgrammer {
|
|
|
171
171
|
const writeParameters = <Model extends ILlmApplication.Model>(props: {
|
|
172
172
|
model: Model;
|
|
173
173
|
components: OpenApi.IComponents;
|
|
174
|
-
function:
|
|
174
|
+
function: __IJsonApplication.IFunction<OpenApi.IJsonSchema>;
|
|
175
175
|
}): ILlmApplication.ModelParameters[Model] => {
|
|
176
176
|
const schema: OpenApi.IJsonSchema.IObject = {
|
|
177
177
|
type: "object",
|