Skip to content

Commit

Permalink
Merge pull request #1268 from samchon/v6.10
Browse files Browse the repository at this point in the history
V6.10
  • Loading branch information
samchon authored Sep 9, 2024
2 parents cd6ed78 + 84644be commit 04c1cbd
Show file tree
Hide file tree
Showing 451 changed files with 16,487 additions and 3,253 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ export function validate<T>(input: unknown): IValidation<T>; // detailed

// JSON FUNCTIONS
export namespace json {
export function application<T>(): IJsonApplication; // JSON schema
export function assertParse<T>(input: string): T; // type safe parser
export function assertStringify<T>(input: T): string; // safe and faster
export function application<T>(): IJsonApplication; // JSON schema
export function assertParse<T>(input: string): T; // type safe parser
export function assertStringify<T>(input: T): string; // safe and faster
}

// LLM FUNCTION CALLING APPLICATION
export namespace llm {
// LLM function calling application from a class or interface type
export function application<App>(): ILlmApplication;
export function schema<T>(): ILlmSchema; // LLM type schema
}

// PROTOCOL BUFFER
export namespace protobuf {
export function message<T>(): string; // Protocol Buffer message
export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
export function message<T>(): string; // Protocol Buffer message
export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
}

// RANDOM GENERATOR
Expand All @@ -36,6 +43,7 @@ Typia is a transformer library supporting below features:

- Super-fast Runtime Validators
- Enhanced JSON functions
- LLM function calling application composer
- Protocol Buffer encoder and decoder
- Random data generator

Expand All @@ -62,6 +70,7 @@ Also, `typia` is re-distributing half of donations to core contributors of `typi




## Playground
You can experience how typia works by [playground website](https://typia.io/playground):

Expand All @@ -86,9 +95,12 @@ Check out the document in the [website](https://typia.io/docs/):
- [Functional Module](https://typia.io/docs/validators/functional)
- [Special Tags](https://typia.io/docs/validators/tags/)
- Enhanced JSON
- [JSON Schema](https://typia.io/docs/json/schema)
- [JSON Schema](https://typia.io/docs/json/schema/)
- [`stringify()` functions](https://typia.io/docs/json/stringify/)
- [`parse()` functions](https://typia.io/docs/json/parse/)
- LLM Function Calling
- [`application()` function](https://typia.io/docs/llm/application/)
- [`schema()` function](https://typia.io/docs/llm/schema/)
- Protocol Buffer
- [Message Schema](https://typia.io/docs/protobuf/message)
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.0-dev.20240823.tgz"
"typia": "../typia-6.10.0-dev.20240910.tgz"
}
}
2 changes: 1 addition & 1 deletion debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"tstl": "^3.0.0",
"typia": "../typia-6.8.0.tgz",
"typia": "../typia-6.10.0.tgz",
"uuid": "^10.0.0"
}
}
5 changes: 5 additions & 0 deletions debug/src/llm.schema.recursive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ILlmSchema } from "@samchon/openapi";
import typia from "typia";

const schema: ILlmSchema = typia.llm.schema<Date>();
console.log(schema);
6 changes: 0 additions & 6 deletions debug/src/pattern.ts

This file was deleted.

2 changes: 1 addition & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "../typia-6.10.0-dev.20240823.tgz"
"typia": "../typia-6.10.0-dev.20240910.tgz"
}
}
7 changes: 7 additions & 0 deletions errors/src/llm/llm.application.bigint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import typia from "typia";

typia.llm.application<Controller>();

interface Controller {
plus(X: bigint, y: bigint): bigint;
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "6.10.0-dev.20240823",
"version": "6.10.0-dev.20240910",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -67,7 +67,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"@samchon/openapi": "^0.4.9",
"@samchon/openapi": "^1.0.0",
"commander": "^10.0.0",
"comment-json": "^4.2.3",
"inquirer": "^8.2.5",
Expand All @@ -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",
Expand Down
26 changes: 19 additions & 7 deletions packages/typescript-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@ export function validate<T>(input: unknown): IValidation<T>; // detailed

// JSON FUNCTIONS
export namespace json {
export function application<T>(): IJsonApplication; // JSON schema
export function assertParse<T>(input: string): T; // type safe parser
export function assertStringify<T>(input: T): string; // safe and faster
export function application<T>(): IJsonApplication; // JSON schema
export function assertParse<T>(input: string): T; // type safe parser
export function assertStringify<T>(input: T): string; // safe and faster
}

// LLM FUNCTION CALLING APPLICATION
export namespace llm {
// LLM function calling application from a class or interface type
export function application<App>(): ILlmApplication;
export function schema<T>(): ILlmSchema; // LLM type schema
}

// PROTOCOL BUFFER
export namespace protobuf {
export function message<T>(): string; // Protocol Buffer message
export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
export function message<T>(): string; // Protocol Buffer message
export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
}

// RANDOM GENERATOR
Expand All @@ -39,6 +46,7 @@ Typia is a transformer library supporting below features:

- Super-fast Runtime Validators
- Enhanced JSON functions
- LLM function calling application composer
- Protocol Buffer encoder and decoder
- Random data generator

Expand All @@ -65,6 +73,7 @@ Also, `typia` is re-distributing half of donations to core contributors of `typi




## Playground
You can experience how typia works by [playground website](https://typia.io/playground):

Expand All @@ -89,9 +98,12 @@ Check out the document in the [website](https://typia.io/docs/):
- [Functional Module](https://typia.io/docs/validators/functional)
- [Special Tags](https://typia.io/docs/validators/tags/)
- Enhanced JSON
- [JSON Schema](https://typia.io/docs/json/schema)
- [JSON Schema](https://typia.io/docs/json/schema/)
- [`stringify()` functions](https://typia.io/docs/json/stringify/)
- [`parse()` functions](https://typia.io/docs/json/parse/)
- LLM Function Calling
- [`application()` function](https://typia.io/docs/llm/application/)
- [`schema()` function](https://typia.io/docs/llm/schema/)
- Protocol Buffer
- [Message Schema](https://typia.io/docs/protobuf/message)
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "6.10.0-dev.20240823",
"version": "6.10.0-dev.20240910",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "6.10.0-dev.20240823"
"typia": "6.10.0-dev.20240910"
},
"peerDependencies": {
"typescript": ">=4.8.0 <5.6.0"
Expand Down
46 changes: 44 additions & 2 deletions src/factories/MetadataFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Metadata } from "../schemas/metadata/Metadata";
import { MetadataAlias } from "../schemas/metadata/MetadataAlias";
import { MetadataArrayType } from "../schemas/metadata/MetadataArrayType";
import { MetadataConstant } from "../schemas/metadata/MetadataConstant";
import { MetadataFunction } from "../schemas/metadata/MetadataFunction";
import { MetadataObject } from "../schemas/metadata/MetadataObject";
import { MetadataTupleType } from "../schemas/metadata/MetadataTupleType";
import { explore_metadata } from "./internal/metadata/explore_metadata";
Expand All @@ -22,6 +23,7 @@ export namespace MetadataFactory {
escape: boolean;
constant: boolean;
absorb: boolean;
functional?: boolean;
validate?: Validator;
onError?: (node: ts.Node | undefined, message: string) => void;
}
Expand All @@ -31,6 +33,8 @@ export namespace MetadataFactory {
object: MetadataObject | null;
property: string | object | null;
nested: null | MetadataAlias | MetadataArrayType | MetadataTupleType;
parameter: string | null;
output: boolean;
escaped: boolean;
aliased: boolean;
}
Expand All @@ -53,9 +57,11 @@ export namespace MetadataFactory {
top: true,
object: null,
property: null,
parameter: null,
nested: null,
escaped: false,
aliased: false,
escaped: false,
output: false,
});
iterate_metadata_collection(errors)(collection);
iterate_metadata_sort(collection)(meta);
Expand Down Expand Up @@ -104,14 +110,17 @@ export namespace MetadataFactory {
arrays: new Set(),
tuples: new Set(),
aliases: new Set(),
functions: new Set(),
};
validateMeta(context)(options)(visitor)(meta, {
object: null,
property: null,
parameter: null,
nested: null,
top: true,
aliased: false,
escaped: false,
output: false,
});
return visitor.errors;
};
Expand Down Expand Up @@ -156,6 +165,8 @@ export namespace MetadataFactory {
validateTuple(context)(options)(visitor)(tuple.type, explore);
for (const obj of meta.objects)
validateObject(context)(options)(visitor)(obj);
for (const func of meta.functions)
validateFunction(context)(options)(visitor)(func, explore);
for (const set of meta.sets)
validateMeta(context)(options)(visitor)(set, explore);
for (const map of meta.maps) {
Expand Down Expand Up @@ -229,9 +240,11 @@ export namespace MetadataFactory {
object,
top: false,
property: null,
parameter: null,
nested: null,
escaped: false,
aliased: false,
escaped: false,
output: false,
};
const errors: string[] = options.validate(
Metadata.create({
Expand All @@ -254,10 +267,38 @@ export namespace MetadataFactory {
property: property.key.isSoleLiteral()
? property.key.getSoleLiteral()!
: {},
parameter: null,
nested: null,
top: false,
aliased: false,
escaped: false,
output: false,
});
};

const validateFunction =
(context?: ts.TransformationContext) =>
(options: IOptions) =>
(visitor: IValidationVisitor) =>
(func: MetadataFunction, explore: IExplore) => {
if (visitor.functions.has(func)) return;
visitor.functions.add(func);

for (const param of func.parameters)
validateMeta(context)(options)(visitor)(param.type, {
...explore,
parameter: param.name,
nested: null,
top: false,
output: false,
});
if (func.output)
validateMeta(context)(options)(visitor)(func.output, {
...explore,
parameter: null,
nested: null,
top: false,
output: true,
});
};

Expand All @@ -268,5 +309,6 @@ export namespace MetadataFactory {
arrays: Set<MetadataArrayType>;
tuples: Set<MetadataTupleType>;
aliases: Set<MetadataAlias>;
functions: Set<MetadataFunction>;
}
}
2 changes: 1 addition & 1 deletion src/factories/MetadataTypeTagSchemaFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export namespace MetadataTypeTagSchemaFactory {
meta.atomics.length ||
meta.arrays.length ||
meta.natives.length ||
meta.functional
meta.functions.length
)
report(`${parent.object.name}.${parent.key} has non-literal type`);
else if (meta.size() > 1)
Expand Down
2 changes: 1 addition & 1 deletion src/factories/ProtobufFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export namespace ProtobufFactory {
// PROHIBIT ANY TYPE
if (meta.any) noSupport("any type");
// PROHIBIT FUNCTIONAL TYPE
if (meta.functional) noSupport("functional type");
if (meta.functions.length) noSupport("functional type");
// PROHIBIT TUPLE TYPE
if (meta.tuples.length) noSupport("tuple type");
// PROHIBIT SET TYPE
Expand Down
2 changes: 1 addition & 1 deletion src/factories/TypeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export namespace TypeFactory {
export const isFunction = (type: ts.Type): boolean =>
getFunction(type) !== null;

const getFunction = (type: ts.Type) => {
export const getFunction = (type: ts.Type) => {
const node = type.symbol?.declarations?.[0];
if (node === undefined) return null;

Expand Down
Loading

0 comments on commit 04c1cbd

Please sign in to comment.