-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1259 from samchon/feature/llm-application
`typia.llm.application<T>()` function.
- Loading branch information
Showing
203 changed files
with
5,700 additions
and
3,217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import typia from "typia"; | ||
|
||
interface Something<T> { | ||
setValue: (x: T) => T; | ||
} | ||
|
||
typia.llm.application<Something<number>>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "typia", | ||
"version": "6.10.0-dev.20240906", | ||
"version": "6.10.0-dev.20240907", | ||
"description": "Superfast runtime validators with only one line", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
|
@@ -83,7 +83,7 @@ | |
"@trivago/prettier-plugin-sort-imports": "^4.3.0", | ||
"@types/inquirer": "^8.2.5", | ||
"@types/node": "^18.15.12", | ||
"@types/ts-expose-internals": "npm:[email protected].3", | ||
"@types/ts-expose-internals": "npm:[email protected].4", | ||
"@typescript-eslint/eslint-plugin": "^7.1.1", | ||
"@typescript-eslint/parser": "^7.1.1", | ||
"chalk": "^4.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/factories/internal/metadata/iterate_metadata_function.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import ts from "typescript"; | ||
|
||
import { FunctionalGeneralProgrammer } from "../../../programmers/functional/internal/FunctionalGeneralProgrammer"; | ||
|
||
import { Metadata } from "../../../schemas/metadata/Metadata"; | ||
import { MetadataFunction } from "../../../schemas/metadata/MetadataFunction"; | ||
import { MetadataParameter } from "../../../schemas/metadata/MetadataParameter"; | ||
|
||
import { CommentFactory } from "../../CommentFactory"; | ||
import { MetadataCollection } from "../../MetadataCollection"; | ||
import { MetadataFactory } from "../../MetadataFactory"; | ||
import { TypeFactory } from "../../TypeFactory"; | ||
import { explore_metadata } from "./explore_metadata"; | ||
|
||
export const iterate_metadata_function = | ||
(checker: ts.TypeChecker) => | ||
(options: MetadataFactory.IOptions) => | ||
(collection: MetadataCollection) => | ||
(errors: MetadataFactory.IError[]) => | ||
( | ||
metadata: Metadata, | ||
type: ts.Type, | ||
explore: MetadataFactory.IExplore, | ||
): boolean => { | ||
const declaration: ts.SignatureDeclaration | null = | ||
TypeFactory.getFunction(type); | ||
if (declaration === null) return false; | ||
else if (!options.functional) { | ||
if (metadata.functions.length === 0) | ||
metadata.functions.push( | ||
MetadataFunction.create({ | ||
parameters: [], | ||
output: Metadata.initialize(), | ||
async: false, | ||
}), | ||
); | ||
} else { | ||
const [signature] = type.getCallSignatures(); | ||
if (signature === undefined || signature.declaration === undefined) | ||
metadata.functions.push( | ||
MetadataFunction.create({ | ||
parameters: [], | ||
output: Metadata.initialize(), | ||
async: false, | ||
}), | ||
); | ||
else { | ||
const { async }: FunctionalGeneralProgrammer.IOutput = | ||
FunctionalGeneralProgrammer.getReturnType(checker)(declaration); | ||
metadata.functions.push( | ||
MetadataFunction.create({ | ||
parameters: signature.parameters.map((p) => | ||
MetadataParameter.create({ | ||
name: p.name, | ||
type: explore_metadata(checker)(options)(collection)(errors)( | ||
checker.getTypeOfSymbol(p), | ||
{ | ||
...explore, | ||
top: false, | ||
}, | ||
), | ||
description: CommentFactory.description(p) ?? null, | ||
jsDocTags: p?.getJsDocTags() ?? [], | ||
}), | ||
), | ||
async, | ||
output: explore_metadata(checker)({ | ||
...options, | ||
functional: false, | ||
})(collection)(errors)( | ||
async | ||
? (signature.getReturnType().aliasTypeArguments?.[0] ?? | ||
checker.getTypeFromTypeNode(TypeFactory.keyword("any"))) | ||
: signature.getReturnType(), | ||
{ | ||
...explore, | ||
top: false, | ||
}, | ||
), | ||
}), | ||
); | ||
} | ||
} | ||
return true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.