Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: samchon/nestia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.4.1
Choose a base ref
...
head repository: samchon/nestia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.4.2
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on Dec 17, 2024

  1. Fix missed LLM type checking cases: tuple type

    samchon committed Dec 17, 2024
    Copy the full SHA
    26d7b23 View commit details
  2. Merge pull request #1160 from samchon/feat/llm-validate

    Fix missed LLM type checking cases: tuple type
    samchon authored Dec 17, 2024

    Verified

    This commit was created on github.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1c9041a View commit details
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@nestia/station",
"version": "4.4.1",
"version": "4.4.2",
"description": "Nestia station",
"scripts": {
"build": "node deploy build",
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/core",
"version": "4.4.1-dev.20241216",
"version": "4.4.2-dev.20241217",
"description": "Super-fast validation decorators of NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
@@ -52,7 +52,7 @@
"ws": "^7.5.3"
},
"peerDependencies": {
"@nestia/fetcher": ">=4.4.1-dev.20241216",
"@nestia/fetcher": ">=4.4.2-dev.20241217",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
3 changes: 1 addition & 2 deletions packages/core/src/programmers/TypedBodyProgrammer.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";

import { INestiaTransformContext } from "../options/INestiaTransformProject";
import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
import { LlmValidatePredicator } from "./internal/LlmValidatePredicator";

export namespace TypedBodyProgrammer {
export const generate = (props: {
@@ -26,7 +25,7 @@ export namespace TypedBodyProgrammer {
checker: props.context.checker,
transformer: props.context.transformer,
type: props.type,
validate: LlmValidatePredicator.is(props.context.options.llm)
validate: props.context.options.llm
? LlmSchemaProgrammer.validate({
model: props.context.options.llm.model,
config: {
66 changes: 36 additions & 30 deletions packages/core/src/programmers/TypedQueryBodyProgrammer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ILlmSchema } from "@samchon/openapi";
import ts from "typescript";
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
@@ -6,12 +7,14 @@ import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryPro
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
import { TransformerError } from "typia/lib/transformers/TransformerError";
import { ValidationPipe } from "typia/lib/typings/ValidationPipe";

import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
import { INestiaTransformContext } from "../options/INestiaTransformProject";
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
import { LlmValidatePredicator } from "./internal/LlmValidatePredicator";

export namespace TypedQueryBodyProgrammer {
export const generate = (props: {
@@ -20,38 +23,41 @@ export namespace TypedQueryBodyProgrammer {
type: ts.Type;
}): ts.ObjectLiteralExpression => {
// VALIDATE TYPE
if (LlmValidatePredicator.is(props.context.options.llm)) {
const result = MetadataFactory.analyze({
checker: props.context.checker,
transformer: props.context.transformer,
options: {
escape: false,
constant: true,
absorb: true,
validate: (meta, explore) => {
const errors: string[] = HttpQueryProgrammer.validate(
meta,
explore,
true,
);
errors.push(
...LlmSchemaProgrammer.validate({
model: props.context.options.llm!.model,
config: {
strict: props.context.options.llm!.strict,
recursive: props.context.options.llm!.recursive,
},
})(meta),
);
return errors;
if (props.context.options.llm) {
const llm: INestiaTransformOptions.ILlm<ILlmSchema.Model> =
props.context.options.llm;
const result: ValidationPipe<Metadata, MetadataFactory.IError> =
MetadataFactory.analyze({
checker: props.context.checker,
transformer: props.context.transformer,
options: {
escape: false,
constant: true,
absorb: true,
validate: (meta, explore) => {
const errors: string[] = HttpQueryProgrammer.validate(
meta,
explore,
true,
);
errors.push(
...LlmSchemaProgrammer.validate({
model: llm.model,
config: {
strict: llm.strict,
recursive: llm.recursive,
},
})(meta),
);
return errors;
},
},
},
collection: new MetadataCollection(),
type: props.type,
});
collection: new MetadataCollection(),
type: props.type,
});
if (result.success === false)
throw TransformerError.from({
code: "@nestia.core.TypedQuery.Body",
code: props.modulo.getText(),
errors: result.errors,
});
}
64 changes: 35 additions & 29 deletions packages/core/src/programmers/TypedQueryProgrammer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ILlmSchema } from "@samchon/openapi";
import ts from "typescript";
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
@@ -6,12 +7,14 @@ import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryPro
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
import { TransformerError } from "typia/lib/transformers/TransformerError";
import { ValidationPipe } from "typia/lib/typings/ValidationPipe";

import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
import { INestiaTransformContext } from "../options/INestiaTransformProject";
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
import { LlmValidatePredicator } from "./internal/LlmValidatePredicator";

export namespace TypedQueryProgrammer {
export const generate = (props: {
@@ -20,35 +23,38 @@ export namespace TypedQueryProgrammer {
type: ts.Type;
}): ts.Expression => {
// VALIDATE TYPE
if (LlmValidatePredicator.is(props.context.options.llm)) {
const result = MetadataFactory.analyze({
checker: props.context.checker,
transformer: props.context.transformer,
options: {
escape: false,
constant: true,
absorb: true,
validate: (meta, explore) => {
const errors: string[] = HttpQueryProgrammer.validate(
meta,
explore,
true,
);
errors.push(
...LlmSchemaProgrammer.validate({
model: props.context.options.llm!.model,
config: {
strict: props.context.options.llm!.strict,
recursive: props.context.options.llm!.recursive,
},
})(meta),
);
return errors;
if (props.context.options.llm) {
const llm: INestiaTransformOptions.ILlm<ILlmSchema.Model> =
props.context.options.llm;
const result: ValidationPipe<Metadata, MetadataFactory.IError> =
MetadataFactory.analyze({
checker: props.context.checker,
transformer: props.context.transformer,
options: {
escape: false,
constant: true,
absorb: true,
validate: (meta, explore) => {
const errors: string[] = HttpQueryProgrammer.validate(
meta,
explore,
true,
);
errors.push(
...LlmSchemaProgrammer.validate({
model: llm.model,
config: {
strict: llm.strict,
recursive: llm.recursive,
},
})(meta),
);
return errors;
},
},
},
collection: new MetadataCollection(),
type: props.type,
});
collection: new MetadataCollection(),
type: props.type,
});
if (result.success === false)
throw TransformerError.from({
code: "@nestia.core.TypedQuery",
64 changes: 35 additions & 29 deletions packages/core/src/programmers/TypedQueryRouteProgrammer.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { ILlmSchema } from "@samchon/openapi";
import ts from "typescript";
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
import { TransformerError } from "typia/lib/transformers/TransformerError";
import { ValidationPipe } from "typia/lib/typings/ValidationPipe";

import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
import { INestiaTransformContext } from "../options/INestiaTransformProject";
import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
import { LlmValidatePredicator } from "./internal/LlmValidatePredicator";

export namespace TypedQueryRouteProgrammer {
export const generate = (props: {
@@ -20,35 +23,38 @@ export namespace TypedQueryRouteProgrammer {
type: ts.Type;
}): ts.Expression => {
// VALIDATE TYPE
if (LlmValidatePredicator.is(props.context.options.llm)) {
const result = MetadataFactory.analyze({
checker: props.context.checker,
transformer: props.context.transformer,
options: {
escape: false,
constant: true,
absorb: true,
validate: (meta, explore) => {
const errors: string[] = HttpQueryProgrammer.validate(
meta,
explore,
true,
);
errors.push(
...LlmSchemaProgrammer.validate({
model: props.context.options.llm!.model,
config: {
strict: props.context.options.llm!.strict,
recursive: props.context.options.llm!.recursive,
},
})(meta),
);
return errors;
if (props.context.options.llm) {
const llm: INestiaTransformOptions.ILlm<ILlmSchema.Model> =
props.context.options.llm;
const result: ValidationPipe<Metadata, MetadataFactory.IError> =
MetadataFactory.analyze({
checker: props.context.checker,
transformer: props.context.transformer,
options: {
escape: false,
constant: true,
absorb: true,
validate: (meta, explore) => {
const errors: string[] = HttpQueryProgrammer.validate(
meta,
explore,
true,
);
errors.push(
...LlmSchemaProgrammer.validate({
model: llm.model,
config: {
strict: llm.strict,
recursive: llm.recursive,
},
})(meta),
);
return errors;
},
},
},
collection: new MetadataCollection(),
type: props.type,
});
collection: new MetadataCollection(),
type: props.type,
});
if (result.success === false)
throw TransformerError.from({
code: props.modulo.getText(),
3 changes: 1 addition & 2 deletions packages/core/src/programmers/TypedRouteProgrammer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgramm
import { IProgrammerProps } from "typia/lib/transformers/IProgrammerProps";

import { INestiaTransformContext } from "../options/INestiaTransformProject";
import { LlmValidatePredicator } from "./internal/LlmValidatePredicator";

export namespace TypedRouteProgrammer {
export const generate = (props: {
@@ -17,7 +16,7 @@ export namespace TypedRouteProgrammer {
type: ts.Type;
}): ts.Expression => {
// VALIDATE TYPE
if (LlmValidatePredicator.is(props.context.options.llm))
if (props.context.options.llm)
JsonMetadataFactory.analyze({
method: "@nestia.core.TypedBody",
checker: props.context.checker,
16 changes: 0 additions & 16 deletions packages/core/src/programmers/internal/LlmValidatePredicator.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/fetcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/fetcher",
"version": "4.4.1-dev.20241216",
"version": "4.4.2-dev.20241217",
"description": "Fetcher library of Nestia SDK",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
6 changes: 3 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/sdk",
"version": "4.4.1-dev.20241216",
"version": "4.4.2-dev.20241217",
"description": "Nestia SDK and Swagger generator",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
@@ -47,8 +47,8 @@
"typia": "^7.4.1"
},
"peerDependencies": {
"@nestia/core": ">=4.4.1-dev.20241216",
"@nestia/fetcher": ">=4.4.1-dev.20241216",
"@nestia/core": ">=4.4.2-dev.20241217",
"@nestia/fetcher": ">=4.4.2-dev.20241217",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",