Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Expand Down
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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/programmers/TypedBodyProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
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";
Expand All @@ -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: {
Expand All @@ -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,
});
}
Expand Down
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";
Expand All @@ -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: {
Expand All @@ -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",
Expand Down
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: {
Expand All @@ -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(),
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/programmers/TypedRouteProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
Expand Down
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",
Expand Down
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",
Expand Down Expand Up @@ -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",
Expand Down
Loading