typia 7.0.0-dev.20241126 → 7.0.0-dev.20241126-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 (32) hide show
  1. package/README.md +1 -0
  2. package/lib/executable/TypiaSetupWizard.js +7 -3
  3. package/lib/executable/TypiaSetupWizard.js.map +1 -1
  4. package/lib/index.mjs +3 -3
  5. package/lib/index.mjs.map +1 -1
  6. package/lib/json.d.ts +31 -43
  7. package/lib/json.js +4 -4
  8. package/lib/json.js.map +1 -1
  9. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +2 -2
  10. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  11. package/lib/schemas/json/IJsonApplication.d.ts +12 -35
  12. package/lib/schemas/json/IJsonApplication.js +55 -0
  13. package/lib/schemas/json/IJsonApplication.js.map +1 -1
  14. package/lib/schemas/json/IJsonSchemaCollection.d.ts +7 -0
  15. package/lib/schemas/json/__IJsonApplication.d.ts +35 -0
  16. package/lib/schemas/json/__IJsonApplication.js +3 -0
  17. package/lib/schemas/json/__IJsonApplication.js.map +1 -0
  18. package/lib/transformers/CallExpressionTransformer.js +3 -2
  19. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  20. package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +0 -5
  21. package/lib/transformers/features/json/JsonApplicationTransformer.js +92 -85
  22. package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
  23. package/package.json +5 -4
  24. package/src/executable/TypiaSetupWizard.ts +7 -2
  25. package/src/json.ts +82 -27
  26. package/src/programmers/json/JsonApplicationProgrammer.ts +13 -13
  27. package/src/programmers/llm/LlmApplicationProgrammer.ts +4 -4
  28. package/src/schemas/json/IJsonApplication.ts +68 -56
  29. package/src/schemas/json/IJsonSchemaCollection.ts +7 -0
  30. package/src/schemas/json/__IJsonApplication.ts +63 -0
  31. package/src/transformers/CallExpressionTransformer.ts +3 -2
  32. package/src/transformers/features/json/JsonApplicationTransformer.ts +92 -92
@@ -1,61 +1,73 @@
1
- import { OpenApi, OpenApiV3 } from "@samchon/openapi";
1
+ import { IJsonSchemaCollection } from "./IJsonSchemaCollection";
2
2
 
3
- export interface IJsonApplication<
4
- Version extends "3.0" | "3.1" = "3.1",
5
- App extends any = object,
6
- > {
7
- version: Version;
8
- components: IJsonApplication.IComponents<IJsonApplication.Schema<Version>>;
9
- functions: IJsonApplication.IFunction<IJsonApplication.Schema<Version>>[];
10
- __application?: App | undefined;
11
- }
12
- export namespace IJsonApplication {
13
- export type Schema<Version extends "3.0" | "3.1"> = Version extends "3.1"
14
- ? OpenApi.IJsonSchema
15
- : OpenApiV3.IJsonSchema;
3
+ /**
4
+ * Collection of JSON schemas.
5
+ *
6
+ * @deprecated Use {@link IJsonSchemaCollection} instead please.
7
+ * This interface type would be changed to {@link ILlmApplication} like
8
+ * structure in the 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
+ * @author Jeongho Nam - https://github.com/samchon
12
+ */
13
+ export import IJsonApplication = IJsonSchemaCollection;
16
14
 
17
- export interface IComponents<
18
- Schema extends
19
- | OpenApi.IJsonSchema
20
- | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
21
- > {
22
- schemas?: Record<string, Schema>;
23
- }
15
+ // export interface IJsonApplication<
16
+ // Version extends "3.0" | "3.1" = "3.1",
17
+ // App extends any = object,
18
+ // > {
19
+ // version: Version;
20
+ // components: IJsonApplication.IComponents<IJsonApplication.Schema<Version>>;
21
+ // functions: IJsonApplication.IFunction<IJsonApplication.Schema<Version>>[];
22
+ // __application?: App | undefined;
23
+ // }
24
+ // export namespace IJsonApplication {
25
+ // export type Schema<Version extends "3.0" | "3.1"> = Version extends "3.1"
26
+ // ? OpenApi.IJsonSchema
27
+ // : OpenApiV3.IJsonSchema;
24
28
 
25
- export interface IFunction<
26
- Schema extends
27
- | OpenApi.IJsonSchema
28
- | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
29
- > {
30
- async: boolean;
31
- name: string;
32
- parameters: IParameter<Schema>[];
33
- output: IOutput<Schema> | undefined;
34
- summary?: string | undefined;
35
- description?: string | undefined;
36
- deprecated?: boolean;
37
- tags?: string[];
38
- }
29
+ // export interface IComponents<
30
+ // Schema extends
31
+ // | OpenApi.IJsonSchema
32
+ // | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
33
+ // > {
34
+ // schemas?: Record<string, Schema>;
35
+ // }
39
36
 
40
- export interface IParameter<
41
- Schema extends
42
- | OpenApi.IJsonSchema
43
- | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
44
- > {
45
- name: string;
46
- required: boolean;
47
- schema: Schema;
48
- title?: string | undefined;
49
- description?: string | undefined;
50
- }
37
+ // export interface IFunction<
38
+ // Schema extends
39
+ // | OpenApi.IJsonSchema
40
+ // | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
41
+ // > {
42
+ // async: boolean;
43
+ // name: string;
44
+ // parameters: IParameter<Schema>[];
45
+ // output: IOutput<Schema> | undefined;
46
+ // summary?: string | undefined;
47
+ // description?: string | undefined;
48
+ // deprecated?: boolean;
49
+ // tags?: string[];
50
+ // }
51
51
 
52
- export interface IOutput<
53
- Schema extends
54
- | OpenApi.IJsonSchema
55
- | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
56
- > {
57
- schema: Schema;
58
- required: boolean;
59
- description?: string | undefined;
60
- }
61
- }
52
+ // export interface IParameter<
53
+ // Schema extends
54
+ // | OpenApi.IJsonSchema
55
+ // | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
56
+ // > {
57
+ // name: string;
58
+ // required: boolean;
59
+ // schema: Schema;
60
+ // title?: string | undefined;
61
+ // description?: string | undefined;
62
+ // }
63
+
64
+ // export interface IOutput<
65
+ // Schema extends
66
+ // | OpenApi.IJsonSchema
67
+ // | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
68
+ // > {
69
+ // schema: Schema;
70
+ // required: boolean;
71
+ // description?: string | undefined;
72
+ // }
73
+ // }
@@ -1,5 +1,12 @@
1
1
  import type { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
2
 
3
+ /**
4
+ * Collection of JSON schemas.
5
+ *
6
+ * @template Version Version of the OpenAPI specification.
7
+ * @template Types Original TypeScript types used in the JSON schemas.
8
+ * @author Jeongho Nam - https://github.com/samchon
9
+ */
3
10
  export type IJsonSchemaCollection<
4
11
  Version extends "3.0" | "3.1" = "3.1",
5
12
  Types = unknown[],
@@ -0,0 +1,63 @@
1
+ import { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
+
3
+ export interface __IJsonApplication<
4
+ Version extends "3.0" | "3.1" = "3.1",
5
+ App extends any = object,
6
+ > {
7
+ version: Version;
8
+ components: __IJsonApplication.IComponents<
9
+ __IJsonApplication.Schema<Version>
10
+ >;
11
+ functions: __IJsonApplication.IFunction<__IJsonApplication.Schema<Version>>[];
12
+ __application?: App | undefined;
13
+ }
14
+ export namespace __IJsonApplication {
15
+ export type Schema<Version extends "3.0" | "3.1"> = Version extends "3.1"
16
+ ? OpenApi.IJsonSchema
17
+ : OpenApiV3.IJsonSchema;
18
+
19
+ export interface IComponents<
20
+ Schema extends
21
+ | OpenApi.IJsonSchema
22
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
23
+ > {
24
+ schemas?: Record<string, Schema>;
25
+ }
26
+
27
+ export interface IFunction<
28
+ Schema extends
29
+ | OpenApi.IJsonSchema
30
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
31
+ > {
32
+ async: boolean;
33
+ name: string;
34
+ parameters: IParameter<Schema>[];
35
+ output: IOutput<Schema> | undefined;
36
+ summary?: string | undefined;
37
+ description?: string | undefined;
38
+ deprecated?: boolean;
39
+ tags?: string[];
40
+ }
41
+
42
+ export interface IParameter<
43
+ Schema extends
44
+ | OpenApi.IJsonSchema
45
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
46
+ > {
47
+ name: string;
48
+ required: boolean;
49
+ schema: Schema;
50
+ title?: string | undefined;
51
+ description?: string | undefined;
52
+ }
53
+
54
+ export interface IOutput<
55
+ Schema extends
56
+ | OpenApi.IJsonSchema
57
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
58
+ > {
59
+ schema: Schema;
60
+ required: boolean;
61
+ description?: string | undefined;
62
+ }
63
+ }
@@ -50,7 +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
+ // import { JsonApplicationTransformer } from "./features/json/JsonApplicationTransformer";
54
54
  import { JsonAssertParseTransformer } from "./features/json/JsonAssertParseTransformer";
55
55
  import { JsonAssertStringifyTransformer } from "./features/json/JsonAssertStringifyTransformer";
56
56
  import { JsonCreateAssertParseTransformer } from "./features/json/JsonCreateAssertParseTransformer";
@@ -400,7 +400,8 @@ const FUNCTORS: Record<string, Record<string, () => Task>> = {
400
400
  },
401
401
  json: {
402
402
  // METADATA
403
- application: () => JsonApplicationTransformer.transform,
403
+ // application: () => JsonApplicationTransformer.transform,
404
+ application: () => JsonSchemasTransformer.transform,
404
405
  schemas: () => JsonSchemasTransformer.transform,
405
406
 
406
407
  // PARSER
@@ -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 { IJsonApplication } from "../../../schemas/json/IJsonApplication";
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: 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
+ // };
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
+ // }