typia 10.0.0 → 10.0.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.
Files changed (70) hide show
  1. package/README.md +4 -2
  2. package/lib/index.mjs +2 -2
  3. package/lib/json.d.mts +108 -21
  4. package/lib/json.d.ts +108 -21
  5. package/lib/json.js +8 -3
  6. package/lib/json.js.map +1 -1
  7. package/lib/json.mjs +7 -3
  8. package/lib/module.d.mts +1 -1
  9. package/lib/module.d.ts +1 -1
  10. package/lib/module.js +1 -1
  11. package/lib/module.js.map +1 -1
  12. package/lib/programmers/json/JsonApplicationProgrammer.d.mts +2 -2
  13. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +2 -2
  14. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  15. package/lib/programmers/json/JsonAssertStringifyProgrammer.js +1 -1
  16. package/lib/programmers/json/JsonAssertStringifyProgrammer.js.map +1 -1
  17. package/lib/programmers/json/JsonAssertStringifyProgrammer.mjs +1 -1
  18. package/lib/programmers/json/JsonIsStringifyProgrammer.js +1 -1
  19. package/lib/programmers/json/JsonIsStringifyProgrammer.js.map +1 -1
  20. package/lib/programmers/json/JsonIsStringifyProgrammer.mjs +1 -1
  21. package/lib/programmers/json/JsonValidateStringifyProgrammer.js +1 -1
  22. package/lib/programmers/json/JsonValidateStringifyProgrammer.js.map +1 -1
  23. package/lib/programmers/json/JsonValidateStringifyProgrammer.mjs +1 -1
  24. package/lib/programmers/protobuf/ProtobufAssertEncodeProgrammer.js +1 -1
  25. package/lib/programmers/protobuf/ProtobufAssertEncodeProgrammer.js.map +1 -1
  26. package/lib/programmers/protobuf/ProtobufAssertEncodeProgrammer.mjs +1 -1
  27. package/lib/programmers/protobuf/ProtobufIsEncodeProgrammer.js +1 -1
  28. package/lib/programmers/protobuf/ProtobufIsEncodeProgrammer.js.map +1 -1
  29. package/lib/programmers/protobuf/ProtobufIsEncodeProgrammer.mjs +1 -1
  30. package/lib/programmers/protobuf/ProtobufValidateEncodeProgrammer.js +1 -1
  31. package/lib/programmers/protobuf/ProtobufValidateEncodeProgrammer.js.map +1 -1
  32. package/lib/programmers/protobuf/ProtobufValidateEncodeProgrammer.mjs +1 -1
  33. package/lib/schemas/json/{__IJsonApplication.d.mts → IJsonSchemaApplication.d.mts} +4 -4
  34. package/lib/schemas/json/{__IJsonApplication.d.ts → IJsonSchemaApplication.d.ts} +4 -4
  35. package/lib/schemas/json/{__IJsonApplication.js → IJsonSchemaApplication.js} +1 -1
  36. package/lib/schemas/json/IJsonSchemaApplication.js.map +1 -0
  37. package/lib/schemas/json/IJsonSchemaApplication.mjs +2 -0
  38. package/lib/schemas/json/IJsonSchemaApplication.mjs.map +1 -0
  39. package/lib/transformers/CallExpressionTransformer.js +3 -1
  40. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  41. package/lib/transformers/CallExpressionTransformer.mjs +3 -1
  42. package/lib/transformers/features/json/JsonApplicationTransformer.d.mts +5 -0
  43. package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +5 -0
  44. package/lib/transformers/features/json/JsonApplicationTransformer.js +85 -92
  45. package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
  46. package/lib/transformers/features/json/JsonApplicationTransformer.mjs +81 -0
  47. package/package.json +2 -2
  48. package/src/json.ts +122 -25
  49. package/src/module.ts +1 -1
  50. package/src/programmers/json/JsonApplicationProgrammer.ts +17 -14
  51. package/src/programmers/json/JsonAssertStringifyProgrammer.ts +1 -1
  52. package/src/programmers/json/JsonIsStringifyProgrammer.ts +1 -1
  53. package/src/programmers/json/JsonValidateStringifyProgrammer.ts +1 -1
  54. package/src/programmers/llm/LlmApplicationProgrammer.ts +4 -4
  55. package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +1 -1
  56. package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +1 -1
  57. package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +1 -1
  58. package/src/schemas/json/{__IJsonApplication.ts → IJsonSchemaApplication.ts} +7 -5
  59. package/src/transformers/CallExpressionTransformer.ts +3 -1
  60. package/src/transformers/features/json/JsonApplicationTransformer.ts +92 -92
  61. package/lib/schemas/json/IJsonApplication.d.mts +0 -16
  62. package/lib/schemas/json/IJsonApplication.d.ts +0 -16
  63. package/lib/schemas/json/IJsonApplication.js +0 -58
  64. package/lib/schemas/json/IJsonApplication.js.map +0 -1
  65. package/lib/schemas/json/IJsonApplication.mjs +0 -2
  66. package/lib/schemas/json/IJsonApplication.mjs.map +0 -1
  67. package/lib/schemas/json/__IJsonApplication.js.map +0 -1
  68. package/lib/schemas/json/__IJsonApplication.mjs +0 -2
  69. package/lib/schemas/json/__IJsonApplication.mjs.map +0 -1
  70. package/src/schemas/json/IJsonApplication.ts +0 -77
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "10.0.0",
3
+ "version": "10.0.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": "^5.0.0",
44
+ "@samchon/openapi": "^5.0.1",
45
45
  "@standard-schema/spec": "^1.0.0",
46
46
  "commander": "^10.0.0",
47
47
  "comment-json": "^4.2.3",
package/src/json.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { IJsonSchemaApplication } from "./schemas/json/IJsonSchemaApplication";
1
2
  import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaCollection";
2
3
  import { IJsonSchemaUnit } from "./schemas/json/IJsonSchemaUnit";
3
4
 
@@ -16,6 +17,54 @@ import { TypeGuardError } from "./TypeGuardError";
16
17
  ==============================================================
17
18
  METADATA
18
19
  ----------------------------------------------------------- */
20
+ /**
21
+ * > You must configure the generic argument `Type`.
22
+ *
23
+ * JSON schema generator.
24
+ *
25
+ * Creates a JSON schema unit which contains a main JSON schema and its
26
+ * components. Note that, all of the named types are stored in the
27
+ * {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
28
+ *
29
+ * Also, you can specify the OpenAPI version by configuring the second generic
30
+ * argument `Version`. For reference, the default version is `"3.1"`, and key
31
+ * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
32
+ * not.
33
+ *
34
+ * @author Jeongho Nam - https://github.com/samchon
35
+ * @template Type Target type
36
+ * @template Version Version of OpenAPI specification. Default is 3.1
37
+ * @returns JSON schema unit
38
+ */
39
+ export function schema(): never;
40
+
41
+ /**
42
+ * JSON schema generator.
43
+ *
44
+ * Creates a JSON schema unit which contains a main JSON schema and its
45
+ * components. Note that, all of the named types are stored in the
46
+ * {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
47
+ *
48
+ * Also, you can specify the OpenAPI version by configuring the second generic
49
+ * argument `Version`. For reference, the default version is `"3.1"`, and key
50
+ * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
51
+ * not.
52
+ *
53
+ * @author Jeongho Nam - https://github.com/samchon
54
+ * @template Type Target type
55
+ * @template Version Version of OpenAPI specification. Default is 3.1
56
+ * @returns JSON schema unit
57
+ */
58
+ export function schema<
59
+ Type extends unknown,
60
+ Version extends "3.0" | "3.1" = "3.1",
61
+ >(): IJsonSchemaUnit<Version, Type>;
62
+
63
+ /** @internal */
64
+ export function schema(): never {
65
+ NoTransformConfigurationError("json.schema");
66
+ }
67
+
19
68
  /**
20
69
  * > You must configure the generic argument `Types`.
21
70
  *
@@ -65,51 +114,99 @@ export function schemas(): never {
65
114
  }
66
115
 
67
116
  /**
68
- * > You must configure the generic argument `Type`.
117
+ * > You must configure the generic argument `Class`.
69
118
  *
70
- * JSON schema generator.
119
+ * TypeScript class to JSON function schema application.
71
120
  *
72
- * Creates a JSON schema unit which contains a main JSON schema and its
73
- * components. Note that, all of the named types are stored in the
74
- * {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
121
+ * Creates a JSON function schema application from a TypeScript class or
122
+ * interface type containing the target functions. This is an intermediate-level
123
+ * function designed for professional developers who want to build custom LLM
124
+ * function calling schemas or need to transform class methods into structured
125
+ * JSON schema representations.
126
+ *
127
+ * Unlike {@link schema} which creates a schema for a single type, this function
128
+ * analyzes an entire class/interface and generates JSON schemas for all its
129
+ * methods, their parameters, and return types. The returned
130
+ * {@link IJsonSchemaApplication} contains:
131
+ *
132
+ * - {@link IJsonSchemaApplication.functions}: Array of function metadata with
133
+ * parameter and return type schemas
134
+ * - {@link IJsonSchemaApplication.components}: Shared schema components for `$ref`
135
+ * referencing
136
+ *
137
+ * This function serves as the underlying implementation for
138
+ * {@link llm.application}, and can be used when you need to:
139
+ *
140
+ * - Create your own custom LLM function calling schema format
141
+ * - Transform class methods into structured JSON schema format
142
+ * - Build API documentation or code generation tools
143
+ * - Develop alternative LLM integrations beyond the built-in providers
144
+ *
145
+ * For direct LLM function calling implementations, consider using
146
+ * {@link llm.application} instead, which provides provider-specific schemas for
147
+ * ChatGPT, Claude, Gemini, and other LLM providers.
75
148
  *
76
149
  * Also, you can specify the OpenAPI version by configuring the second generic
77
- * argument `Version`. For reference, the default version is `"3.1"`, and key
78
- * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
79
- * not.
150
+ * argument `Version`. For reference, the default version is `"3.1"`, and the
151
+ * key difference between `"3.0"` and `"3.1"` is whether supporting the tuple
152
+ * type or not.
80
153
  *
81
154
  * @author Jeongho Nam - https://github.com/samchon
82
- * @template Type Target type
155
+ * @template Class Target class or interface type containing the functions
83
156
  * @template Version Version of OpenAPI specification. Default is 3.1
84
- * @returns JSON schema unit
157
+ * @returns JSON function schema application
85
158
  */
86
- export function schema(): never;
159
+ export function application(): never;
87
160
 
88
161
  /**
89
- * JSON schema generator.
162
+ * TypeScript class to JSON function schema application.
90
163
  *
91
- * Creates a JSON schema unit which contains a main JSON schema and its
92
- * components. Note that, all of the named types are stored in the
93
- * {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
164
+ * Creates a JSON function schema application from a TypeScript class or
165
+ * interface type containing the target functions. This is an intermediate-level
166
+ * function designed for professional developers who want to build custom LLM
167
+ * function calling schemas or need to transform class methods into structured
168
+ * JSON schema representations.
169
+ *
170
+ * Unlike {@link schema} which creates a schema for a single type, this function
171
+ * analyzes an entire class/interface and generates JSON schemas for all its
172
+ * methods, their parameters, and return types. The returned
173
+ * {@link IJsonSchemaApplication} contains:
174
+ *
175
+ * - {@link IJsonSchemaApplication.functions}: Array of function metadata with
176
+ * parameter and return type schemas
177
+ * - {@link IJsonSchemaApplication.components}: Shared schema components for `$ref`
178
+ * referencing
179
+ *
180
+ * This function serves as the underlying implementation for
181
+ * {@link llm.application}, and can be used when you need to:
182
+ *
183
+ * - Create your own custom LLM function calling schema format
184
+ * - Transform class methods into structured JSON schema format
185
+ * - Build API documentation or code generation tools
186
+ * - Develop alternative LLM integrations beyond the built-in providers
187
+ *
188
+ * For direct LLM function calling implementations, consider using
189
+ * {@link llm.application} instead, which provides provider-specific schemas for
190
+ * ChatGPT, Claude, Gemini, and other LLM providers.
94
191
  *
95
192
  * Also, you can specify the OpenAPI version by configuring the second generic
96
- * argument `Version`. For reference, the default version is `"3.1"`, and key
97
- * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
98
- * not.
193
+ * argument `Version`. For reference, the default version is `"3.1"`, and the
194
+ * key difference between `"3.0"` and `"3.1"` is whether supporting the tuple
195
+ * type or not.
99
196
  *
100
197
  * @author Jeongho Nam - https://github.com/samchon
101
- * @template Type Target type
198
+ * @template Class Target class or interface type containing the functions
102
199
  * @template Version Version of OpenAPI specification. Default is 3.1
103
- * @returns JSON schema unit
200
+ * @returns JSON function schema application
104
201
  */
105
- export function schema<
106
- Type extends unknown,
202
+ export function application<
203
+ Class extends object,
107
204
  Version extends "3.0" | "3.1" = "3.1",
108
- >(): IJsonSchemaUnit<Version, Type>;
205
+ >(): IJsonSchemaApplication<Version, Class>;
109
206
 
110
207
  /** @internal */
111
- export function schema(): never {
112
- NoTransformConfigurationError("json.schema");
208
+ export function application(): never {
209
+ NoTransformConfigurationError("json.application");
113
210
  }
114
211
 
115
212
  /* -----------------------------------------------------------
package/src/module.ts CHANGED
@@ -19,7 +19,7 @@ export * as reflect from "./reflect";
19
19
  export * as tags from "./tags";
20
20
 
21
21
  export * from "./schemas/metadata/IJsDocTagInfo";
22
- export * from "./schemas/json/IJsonApplication";
22
+ export * from "./schemas/json/IJsonSchemaApplication";
23
23
  export * from "./schemas/json/IJsonSchemaCollection";
24
24
  export * from "./schemas/json/IJsonSchemaUnit";
25
25
  export * from "./AssertionGuard";
@@ -1,6 +1,6 @@
1
1
  import { MetadataFactory } from "../../factories/MetadataFactory";
2
2
 
3
- import { __IJsonApplication } from "../../schemas/json/__IJsonApplication";
3
+ import { IJsonSchemaApplication } from "../../schemas/json/IJsonSchemaApplication";
4
4
  import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
5
5
  import { Metadata } from "../../schemas/metadata/Metadata";
6
6
  import { MetadataFunction } from "../../schemas/metadata/MetadataFunction";
@@ -62,21 +62,22 @@ export namespace JsonApplicationProgrammer {
62
62
  version: Version;
63
63
  metadata: Metadata;
64
64
  filter?: (prop: MetadataProperty) => boolean;
65
- }): __IJsonApplication<Version> => {
65
+ }): IJsonSchemaApplication<Version> => {
66
66
  const object: MetadataObjectType = props.metadata.objects[0]!.type;
67
67
  const definitions: Metadata[] = [];
68
- const setters: Array<(schema: __IJsonApplication.Schema<Version>) => void> =
69
- [];
68
+ const setters: Array<
69
+ (schema: IJsonSchemaApplication.Schema<Version>) => void
70
+ > = [];
70
71
  const collect = (
71
72
  metadata: Metadata,
72
- setter: (schema: __IJsonApplication.Schema<Version>) => void,
73
+ setter: (schema: IJsonSchemaApplication.Schema<Version>) => void,
73
74
  ): void => {
74
75
  definitions.push(metadata);
75
76
  setters.push(setter);
76
77
  };
77
78
 
78
- const functions: __IJsonApplication.IFunction<
79
- __IJsonApplication.Schema<Version>
79
+ const functions: IJsonSchemaApplication.IFunction<
80
+ IJsonSchemaApplication.Schema<Version>
80
81
  >[] = object.properties
81
82
  .filter(
82
83
  (p) =>
@@ -108,7 +109,7 @@ export namespace JsonApplicationProgrammer {
108
109
  metadatas: definitions,
109
110
  });
110
111
  schemas.forEach((s, i) =>
111
- setters[i]?.(s as __IJsonApplication.Schema<Version>),
112
+ setters[i]?.(s as IJsonSchemaApplication.Schema<Version>),
112
113
  );
113
114
  return {
114
115
  version: props.version,
@@ -152,9 +153,11 @@ export namespace JsonApplicationProgrammer {
152
153
  jsDocTags: IJsDocTagInfo[];
153
154
  collect: (
154
155
  metadata: Metadata,
155
- setter: (schema: __IJsonApplication.Schema<Version>) => void,
156
+ setter: (schema: IJsonSchemaApplication.Schema<Version>) => void,
156
157
  ) => void;
157
- }): __IJsonApplication.IFunction<__IJsonApplication.Schema<Version>> => {
158
+ }): IJsonSchemaApplication.IFunction<
159
+ IJsonSchemaApplication.Schema<Version>
160
+ > => {
158
161
  const deprecated: boolean = props.jsDocTags.some(
159
162
  (tag) => tag.name === "deprecated",
160
163
  );
@@ -172,8 +175,8 @@ export namespace JsonApplicationProgrammer {
172
175
  name: props.name,
173
176
  async: props.function.async,
174
177
  parameters: props.function.parameters.map((param) => {
175
- const appParam: __IJsonApplication.IParameter<
176
- __IJsonApplication.Schema<Version>
178
+ const appParam: IJsonSchemaApplication.IParameter<
179
+ IJsonSchemaApplication.Schema<Version>
177
180
  > = {
178
181
  name: param.name,
179
182
  ...writeDescription({
@@ -201,8 +204,8 @@ export namespace JsonApplicationProgrammer {
201
204
  }),
202
205
  output: props.function.output.size()
203
206
  ? (() => {
204
- const appOutput: __IJsonApplication.IOutput<
205
- __IJsonApplication.Schema<Version>
207
+ const appOutput: IJsonSchemaApplication.IOutput<
208
+ IJsonSchemaApplication.Schema<Version>
206
209
  > = {
207
210
  schema: null!,
208
211
  required: props.function.output.isRequired(),
@@ -27,7 +27,7 @@ export namespace JsonAssertStringifyProgrammer {
27
27
  options: {
28
28
  ...props.context.options,
29
29
  functional: false,
30
- numeric: true,
30
+ finite: true,
31
31
  },
32
32
  },
33
33
  config: {
@@ -26,7 +26,7 @@ export namespace JsonIsStringifyProgrammer {
26
26
  options: {
27
27
  ...props.context.options,
28
28
  functional: false,
29
- numeric: true,
29
+ finite: true,
30
30
  },
31
31
  },
32
32
  config: {
@@ -28,7 +28,7 @@ export namespace JsonValidateStringifyProgrammer {
28
28
  options: {
29
29
  ...props.context.options,
30
30
  functional: false,
31
- numeric: true,
31
+ finite: true,
32
32
  },
33
33
  },
34
34
  config: {
@@ -14,7 +14,7 @@ import ts from "typescript";
14
14
  import { MetadataFactory } from "../../factories/MetadataFactory";
15
15
  import { TypeFactory } from "../../factories/TypeFactory";
16
16
 
17
- import { __IJsonApplication } from "../../schemas/json/__IJsonApplication";
17
+ import { IJsonSchemaApplication } from "../../schemas/json/IJsonSchemaApplication";
18
18
  import { Metadata } from "../../schemas/metadata/Metadata";
19
19
  import { MetadataFunction } from "../../schemas/metadata/MetadataFunction";
20
20
  import { MetadataObjectType } from "../../schemas/metadata/MetadataObjectType";
@@ -191,7 +191,7 @@ export namespace LlmApplicationProgrammer {
191
191
  );
192
192
 
193
193
  const errorMessages: string[] = [];
194
- const application: __IJsonApplication<"3.1"> =
194
+ const application: IJsonSchemaApplication<"3.1"> =
195
195
  JsonApplicationProgrammer.write({
196
196
  version: "3.1",
197
197
  metadata,
@@ -233,7 +233,7 @@ export namespace LlmApplicationProgrammer {
233
233
  context: ITypiaContext;
234
234
  modulo: ts.LeftHandSideExpression;
235
235
  components: OpenApi.IComponents;
236
- function: __IJsonApplication.IFunction<OpenApi.IJsonSchema>;
236
+ function: IJsonSchemaApplication.IFunction<OpenApi.IJsonSchema>;
237
237
  parameter: MetadataParameter | null;
238
238
  errors: string[];
239
239
  className?: string;
@@ -309,7 +309,7 @@ export namespace LlmApplicationProgrammer {
309
309
  const writeParameters = <Model extends ILlmSchema.Model>(props: {
310
310
  model: Model;
311
311
  components: OpenApi.IComponents;
312
- function: __IJsonApplication.IFunction<OpenApi.IJsonSchema>;
312
+ function: IJsonSchemaApplication.IFunction<OpenApi.IJsonSchema>;
313
313
  errors: string[];
314
314
  accessor: string;
315
315
  }): ILlmSchema.ModelParameters[Model] | null => {
@@ -28,7 +28,7 @@ export namespace ProtobufAssertEncodeProgrammer {
28
28
  options: {
29
29
  ...props.context.options,
30
30
  functional: false,
31
- numeric: true,
31
+ finite: true,
32
32
  },
33
33
  },
34
34
  config: {
@@ -27,7 +27,7 @@ export namespace ProtobufIsEncodeProgrammer {
27
27
  options: {
28
28
  ...props.context.options,
29
29
  functional: false,
30
- numeric: true,
30
+ finite: true,
31
31
  },
32
32
  },
33
33
  config: {
@@ -27,7 +27,7 @@ export namespace ProtobufValidateEncodeProgrammer {
27
27
  options: {
28
28
  ...props.context.options,
29
29
  functional: false,
30
- numeric: true,
30
+ finite: true,
31
31
  },
32
32
  },
33
33
  config: {
@@ -1,17 +1,19 @@
1
1
  import { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
2
 
3
- export interface __IJsonApplication<
3
+ export interface IJsonSchemaApplication<
4
4
  Version extends "3.0" | "3.1" = "3.1",
5
5
  App extends any = object,
6
6
  > {
7
7
  version: Version;
8
- components: __IJsonApplication.IComponents<
9
- __IJsonApplication.Schema<Version>
8
+ components: IJsonSchemaApplication.IComponents<
9
+ IJsonSchemaApplication.Schema<Version>
10
10
  >;
11
- functions: __IJsonApplication.IFunction<__IJsonApplication.Schema<Version>>[];
11
+ functions: IJsonSchemaApplication.IFunction<
12
+ IJsonSchemaApplication.Schema<Version>
13
+ >[];
12
14
  __application?: App | undefined;
13
15
  }
14
- export namespace __IJsonApplication {
16
+ export namespace IJsonSchemaApplication {
15
17
  export type Schema<Version extends "3.0" | "3.1"> = Version extends "3.1"
16
18
  ? OpenApi.IJsonSchema
17
19
  : OpenApiV3.IJsonSchema;
@@ -50,6 +50,7 @@ import { HttpQueryTransformer } from "./features/http/HttpQueryTransformer";
50
50
  import { HttpValidateFormDataTransformer } from "./features/http/HttpValidateFormDataTransformer";
51
51
  import { HttpValidateHeadersTransformer } from "./features/http/HttpValidateHeadersTransformer";
52
52
  import { HttpValidateQueryTransformer } from "./features/http/HttpValidateQueryTransformer";
53
+ import { JsonApplicationTransformer } from "./features/json/JsonApplicationTransformer";
53
54
  // import { JsonApplicationTransformer } from "./features/json/JsonApplicationTransformer";
54
55
  import { JsonAssertParseTransformer } from "./features/json/JsonAssertParseTransformer";
55
56
  import { JsonAssertStringifyTransformer } from "./features/json/JsonAssertStringifyTransformer";
@@ -410,8 +411,9 @@ const FUNCTORS: Record<string, Record<string, () => Task>> = {
410
411
  },
411
412
  json: {
412
413
  // METADATA
413
- schemas: () => JsonSchemasTransformer.transform,
414
414
  schema: () => JsonSchemaTransformer.transform,
415
+ schemas: () => JsonSchemasTransformer.transform,
416
+ application: () => JsonApplicationTransformer.transform,
415
417
 
416
418
  // PARSER
417
419
  isParse: () => JsonIsParseTransformer.transform,
@@ -1,105 +1,105 @@
1
- // import ts from "typescript";
1
+ import ts from "typescript";
2
2
 
3
- // import { LiteralFactory } from "../../../factories/LiteralFactory";
4
- // import { MetadataCollection } from "../../../factories/MetadataCollection";
5
- // import { MetadataFactory } from "../../../factories/MetadataFactory";
3
+ import { LiteralFactory } from "../../../factories/LiteralFactory";
4
+ import { MetadataCollection } from "../../../factories/MetadataCollection";
5
+ import { MetadataFactory } from "../../../factories/MetadataFactory";
6
6
 
7
- // import { IJsonApplication } from "../../../schemas/json/IJsonApplication";
8
- // import { Metadata } from "../../../schemas/metadata/Metadata";
7
+ import { IJsonSchemaApplication } from "../../../schemas/json/IJsonSchemaApplication";
8
+ import { Metadata } from "../../../schemas/metadata/Metadata";
9
9
 
10
- // import { JsonApplicationProgrammer } from "../../../programmers/json/JsonApplicationProgrammer";
10
+ import { JsonApplicationProgrammer } from "../../../programmers/json/JsonApplicationProgrammer";
11
11
 
12
- // import { ValidationPipe } from "../../../typings/ValidationPipe";
12
+ import { ValidationPipe } from "../../../typings/ValidationPipe";
13
13
 
14
- // import { ITransformProps } from "../../ITransformProps";
15
- // import { TransformerError } from "../../TransformerError";
14
+ import { ITransformProps } from "../../ITransformProps";
15
+ import { TransformerError } from "../../TransformerError";
16
16
 
17
- // export namespace JsonApplicationTransformer {
18
- // export const transform = (props: ITransformProps): ts.Expression => {
19
- // // GET GENERIC ARGUMENT
20
- // if (!props.expression.typeArguments?.length)
21
- // throw new TransformerError({
22
- // code: "typia.json.application",
23
- // message: "no generic argument.",
24
- // });
17
+ export namespace JsonApplicationTransformer {
18
+ export const transform = (props: ITransformProps): ts.Expression => {
19
+ // GET GENERIC ARGUMENT
20
+ if (!props.expression.typeArguments?.length)
21
+ throw new TransformerError({
22
+ code: "typia.json.application",
23
+ message: "no generic argument.",
24
+ });
25
25
 
26
- // const top: ts.Node = props.expression.typeArguments[0]!;
27
- // if (ts.isTypeNode(top) === false) return props.expression;
26
+ const top: ts.Node = props.expression.typeArguments[0]!;
27
+ if (ts.isTypeNode(top) === false) return props.expression;
28
28
 
29
- // const version: "3.0" | "3.1" = get_parameter<"3.0" | "3.1">({
30
- // checker: props.context.checker,
31
- // name: "Version",
32
- // is: (str) => str === "3.0" || str === "3.1",
33
- // cast: (str) => str as "3.0" | "3.1",
34
- // default: () => "3.1",
35
- // })(props.expression.typeArguments[1]);
29
+ const version: "3.0" | "3.1" = get_parameter<"3.0" | "3.1">({
30
+ checker: props.context.checker,
31
+ name: "Version",
32
+ is: (str) => str === "3.0" || str === "3.1",
33
+ cast: (str) => str as "3.0" | "3.1",
34
+ default: () => "3.1",
35
+ })(props.expression.typeArguments[1]);
36
36
 
37
- // // GET TYPE
38
- // const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
39
- // const collection: MetadataCollection = new MetadataCollection({
40
- // replace: MetadataCollection.replace,
41
- // });
42
- // const result: ValidationPipe<Metadata, MetadataFactory.IError> =
43
- // MetadataFactory.analyze({
44
- // checker: props.context.checker,
45
- // transformer: props.context.transformer,
46
- // options: {
47
- // escape: true,
48
- // constant: true,
49
- // absorb: false,
50
- // functional: true,
51
- // validate: JsonApplicationProgrammer.validate,
52
- // },
53
- // collection,
54
- // type,
55
- // });
56
- // if (result.success === false)
57
- // throw TransformerError.from({
58
- // code: "typia.json.application",
59
- // errors: result.errors,
60
- // });
37
+ // GET TYPE
38
+ const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
39
+ const collection: MetadataCollection = new MetadataCollection({
40
+ replace: MetadataCollection.replace,
41
+ });
42
+ const result: ValidationPipe<Metadata, MetadataFactory.IError> =
43
+ MetadataFactory.analyze({
44
+ checker: props.context.checker,
45
+ transformer: props.context.transformer,
46
+ options: {
47
+ escape: true,
48
+ constant: true,
49
+ absorb: false,
50
+ functional: true,
51
+ validate: JsonApplicationProgrammer.validate,
52
+ },
53
+ collection,
54
+ type,
55
+ });
56
+ if (result.success === false)
57
+ throw TransformerError.from({
58
+ code: "typia.json.application",
59
+ errors: result.errors,
60
+ });
61
61
 
62
- // // GENERATE LLM APPLICATION
63
- // const app: IJsonApplication<"3.0" | "3.1"> =
64
- // JsonApplicationProgrammer.write({
65
- // version,
66
- // metadata: result.data,
67
- // });
68
- // const literal: ts.Expression = LiteralFactory.write(app);
69
- // return literal;
70
- // };
62
+ // GENERATE LLM APPLICATION
63
+ const app: IJsonSchemaApplication<"3.0" | "3.1"> =
64
+ JsonApplicationProgrammer.write({
65
+ version,
66
+ metadata: result.data,
67
+ });
68
+ const literal: ts.Expression = LiteralFactory.write(app);
69
+ return literal;
70
+ };
71
71
 
72
- // const get_parameter =
73
- // <Value>(props: {
74
- // checker: ts.TypeChecker;
75
- // name: string;
76
- // is: (value: string) => boolean;
77
- // cast: (value: string) => Value;
78
- // default: () => Value;
79
- // }) =>
80
- // (node: ts.TypeNode | undefined): Value => {
81
- // if (!node) return props.default();
72
+ const get_parameter =
73
+ <Value>(props: {
74
+ checker: ts.TypeChecker;
75
+ name: string;
76
+ is: (value: string) => boolean;
77
+ cast: (value: string) => Value;
78
+ default: () => Value;
79
+ }) =>
80
+ (node: ts.TypeNode | undefined): Value => {
81
+ if (!node) return props.default();
82
82
 
83
- // // CHECK LITERAL TYPE
84
- // const type: ts.Type = props.checker.getTypeFromTypeNode(node);
85
- // if (
86
- // !type.isLiteral() &&
87
- // (type.getFlags() & ts.TypeFlags.BooleanLiteral) === 0
88
- // )
89
- // throw new TransformerError({
90
- // code: "typia.json.application",
91
- // message: `generic argument "${props.name}" must be constant.`,
92
- // });
83
+ // CHECK LITERAL TYPE
84
+ const type: ts.Type = props.checker.getTypeFromTypeNode(node);
85
+ if (
86
+ !type.isLiteral() &&
87
+ (type.getFlags() & ts.TypeFlags.BooleanLiteral) === 0
88
+ )
89
+ throw new TransformerError({
90
+ code: "typia.json.application",
91
+ message: `generic argument "${props.name}" must be constant.`,
92
+ });
93
93
 
94
- // // GET VALUE AND VALIDATE IT
95
- // const value = type.isLiteral()
96
- // ? type.value
97
- // : props.checker.typeToString(type);
98
- // if (typeof value !== "string" || props.is(value) === false)
99
- // throw new TransformerError({
100
- // code: "typia.json.application",
101
- // message: `invalid value on generic argument "${props.name}".`,
102
- // });
103
- // return props.cast(value);
104
- // };
105
- // }
94
+ // GET VALUE AND VALIDATE IT
95
+ const value = type.isLiteral()
96
+ ? type.value
97
+ : props.checker.typeToString(type);
98
+ if (typeof value !== "string" || props.is(value) === false)
99
+ throw new TransformerError({
100
+ code: "typia.json.application",
101
+ message: `invalid value on generic argument "${props.name}".`,
102
+ });
103
+ return props.cast(value);
104
+ };
105
+ }
@@ -1,16 +0,0 @@
1
- import { IJsonSchemaCollection } from "./IJsonSchemaCollection";
2
- /**
3
- * Collection of JSON schemas.
4
- *
5
- * @author Jeongho Nam - https://github.com/samchon
6
- * @deprecated Use {@link IJsonSchemaCollection} instead please. This interface
7
- * type would be changed to {@link ILlmApplication} like structure in the
8
- * future version (maybe next v8 major update).
9
- * @template Version Version of the OpenAPI specification.
10
- * @template Types Original TypeScript types used in the JSON schemas.
11
- */
12
- export type IJsonApplication = IJsonSchemaCollection;
13
- export declare namespace IJsonApplication {
14
- type IV3_0 = IJsonSchemaCollection.IV3_0;
15
- type IV3_1 = IJsonSchemaCollection.IV3_1;
16
- }