typia 6.7.2 → 6.8.0-dev.20240811

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 (63) hide show
  1. package/lib/programmers/internal/application_bigint.d.ts +1 -0
  2. package/lib/programmers/internal/application_bigint.js +14 -0
  3. package/lib/programmers/internal/application_bigint.js.map +1 -0
  4. package/lib/programmers/internal/application_v30_schema.js +10 -12
  5. package/lib/programmers/internal/application_v30_schema.js.map +1 -1
  6. package/lib/programmers/internal/application_v31_constant.js +3 -1
  7. package/lib/programmers/internal/application_v31_constant.js.map +1 -1
  8. package/lib/programmers/internal/application_v31_schema.js +10 -12
  9. package/lib/programmers/internal/application_v31_schema.js.map +1 -1
  10. package/lib/tags/Constant.d.ts +2 -2
  11. package/lib/tags/Default.d.ts +5 -1
  12. package/lib/tags/ExclusiveMaximum.d.ts +9 -5
  13. package/lib/tags/ExclusiveMinimum.d.ts +9 -5
  14. package/lib/tags/JsonSchemaPlugin.d.ts +1 -1
  15. package/lib/tags/Maximum.d.ts +8 -5
  16. package/lib/tags/Minimum.d.ts +8 -5
  17. package/lib/tags/MultipleOf.d.ts +7 -4
  18. package/package.json +2 -2
  19. package/src/factories/CommentFactory.ts +79 -79
  20. package/src/factories/MetadataCollection.ts +274 -274
  21. package/src/factories/MetadataFactory.ts +272 -272
  22. package/src/factories/StatementFactory.ts +74 -74
  23. package/src/factories/TypeFactory.ts +118 -118
  24. package/src/factories/internal/metadata/emplace_metadata_array_type.ts +42 -42
  25. package/src/factories/internal/metadata/emplace_metadata_object.ts +176 -176
  26. package/src/factories/internal/metadata/iterate_metadata.ts +94 -94
  27. package/src/factories/internal/metadata/iterate_metadata_array.ts +63 -63
  28. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
  29. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  30. package/src/factories/internal/metadata/iterate_metadata_constant.ts +76 -76
  31. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +213 -213
  32. package/src/factories/internal/metadata/iterate_metadata_map.ts +50 -50
  33. package/src/factories/internal/metadata/iterate_metadata_native.ts +220 -220
  34. package/src/factories/internal/metadata/iterate_metadata_object.ts +33 -33
  35. package/src/factories/internal/metadata/iterate_metadata_set.ts +41 -41
  36. package/src/factories/internal/metadata/iterate_metadata_template.ts +44 -44
  37. package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
  38. package/src/programmers/internal/application_bigint.ts +25 -0
  39. package/src/programmers/internal/application_v30_alias.ts +52 -52
  40. package/src/programmers/internal/application_v30_object.ts +149 -149
  41. package/src/programmers/internal/application_v30_schema.ts +162 -159
  42. package/src/programmers/internal/application_v30_tuple.ts +33 -33
  43. package/src/programmers/internal/application_v31_constant.ts +4 -1
  44. package/src/programmers/internal/application_v31_schema.ts +159 -157
  45. package/src/programmers/json/JsonApplicationProgrammer.ts +82 -82
  46. package/src/schemas/metadata/IMetadataConstantValue.ts +11 -11
  47. package/src/schemas/metadata/IMetadataTemplate.ts +7 -7
  48. package/src/tags/Constant.ts +2 -2
  49. package/src/tags/Default.ts +7 -3
  50. package/src/tags/ExclusiveMaximum.ts +12 -6
  51. package/src/tags/ExclusiveMinimum.ts +12 -6
  52. package/src/tags/JsonSchemaPlugin.ts +1 -1
  53. package/src/tags/Maximum.ts +9 -8
  54. package/src/tags/Minimum.ts +9 -8
  55. package/src/tags/MultipleOf.ts +9 -8
  56. package/src/tags/Type.ts +32 -32
  57. package/src/transformers/FileTransformer.ts +91 -91
  58. package/src/transformers/features/CreateRandomTransformer.ts +40 -40
  59. package/src/transformers/features/RandomTransformer.ts +44 -44
  60. package/src/transformers/features/json/JsonApplicationTransformer.ts +124 -124
  61. package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
  62. package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
  63. package/src/transformers/features/reflect/ReflectMetadataTransformer.ts +62 -62
@@ -1,27 +1,27 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../../../schemas/metadata/Metadata";
4
-
5
- import { MetadataCollection } from "../../MetadataCollection";
6
- import { MetadataFactory } from "../../MetadataFactory";
7
- import { iterate_metadata } from "./iterate_metadata";
8
-
9
- export const iterate_metadata_union =
10
- (checker: ts.TypeChecker) =>
11
- (options: MetadataFactory.IOptions) =>
12
- (collection: MetadataCollection) =>
13
- (errors: MetadataFactory.IError[]) =>
14
- (
15
- meta: Metadata,
16
- type: ts.Type,
17
- explore: MetadataFactory.IExplore,
18
- ): boolean => {
19
- if (!type.isUnion()) return false;
20
- type.types.forEach((t) =>
21
- iterate_metadata(checker)(options)(collection)(errors)(meta, t, {
22
- ...explore,
23
- aliased: false,
24
- }),
25
- );
26
- return true;
27
- };
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../../../schemas/metadata/Metadata";
4
+
5
+ import { MetadataCollection } from "../../MetadataCollection";
6
+ import { MetadataFactory } from "../../MetadataFactory";
7
+ import { iterate_metadata } from "./iterate_metadata";
8
+
9
+ export const iterate_metadata_union =
10
+ (checker: ts.TypeChecker) =>
11
+ (options: MetadataFactory.IOptions) =>
12
+ (collection: MetadataCollection) =>
13
+ (errors: MetadataFactory.IError[]) =>
14
+ (
15
+ meta: Metadata,
16
+ type: ts.Type,
17
+ explore: MetadataFactory.IExplore,
18
+ ): boolean => {
19
+ if (!type.isUnion()) return false;
20
+ type.types.forEach((t) =>
21
+ iterate_metadata(checker)(options)(collection)(errors)(meta, t, {
22
+ ...explore,
23
+ aliased: false,
24
+ }),
25
+ );
26
+ return true;
27
+ };
@@ -0,0 +1,25 @@
1
+ import { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
+
3
+ import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
4
+
5
+ import { application_plugin } from "./application_plugin";
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export const application_bigint = <Version extends "3.0" | "3.1">(
11
+ atomic: MetadataAtomic,
12
+ ): Schema<Version>[] =>
13
+ application_plugin(
14
+ {
15
+ type: "integer",
16
+ } satisfies Schema<Version>,
17
+ atomic.tags,
18
+ );
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ type Schema<Version extends "3.0" | "3.1"> = Version extends "3.0"
24
+ ? OpenApiV3.IJsonSchema.IInteger
25
+ : OpenApi.IJsonSchema.IInteger;
@@ -1,52 +1,52 @@
1
- import { OpenApiV3 } from "@samchon/openapi";
2
-
3
- import { CommentFactory } from "../../factories/CommentFactory";
4
-
5
- import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
6
- import { MetadataAlias } from "../../schemas/metadata/MetadataAlias";
7
-
8
- import { application_description } from "./application_description";
9
- import { application_v30_object } from "./application_v30_object";
10
- import { application_v30_schema } from "./application_v30_schema";
11
-
12
- /**
13
- * @internal
14
- */
15
- export const application_v30_alias =
16
- <BlockNever extends boolean>(blockNever: BlockNever) =>
17
- (components: OpenApiV3.IComponents) =>
18
- (alias: MetadataAlias) =>
19
- (nullable: boolean): OpenApiV3.IJsonSchema.IReference => {
20
- if (alias.value.size() === 1 && alias.value.objects.length === 1)
21
- return application_v30_object(components)(alias.value.objects[0]!)(
22
- nullable,
23
- ) as OpenApiV3.IJsonSchema.IReference;
24
-
25
- const key: string = `${alias.name}${nullable ? ".Nullable" : ""}`;
26
- const $ref: string = `#/components/schemas/${key}`;
27
-
28
- if (components.schemas?.[key] === undefined) {
29
- // TEMPORARY ASSIGNMENT
30
- components.schemas ??= {};
31
- components.schemas[key] = {};
32
-
33
- // GENERATE SCHEMA
34
- const schema: OpenApiV3.IJsonSchema | null = application_v30_schema(
35
- blockNever,
36
- )(components)({
37
- deprecated:
38
- alias.jsDocTags.some((tag) => tag.name === "deprecated") || undefined,
39
- title: (() => {
40
- const info: IJsDocTagInfo | undefined = alias.jsDocTags.find(
41
- (tag) => tag.name === "title",
42
- );
43
- return info?.text?.length
44
- ? CommentFactory.merge(info.text)
45
- : undefined;
46
- })(),
47
- description: application_description(alias),
48
- })(alias.value);
49
- if (schema !== null) Object.assign(components.schemas[key]!, schema);
50
- }
51
- return { $ref };
52
- };
1
+ import { OpenApiV3 } from "@samchon/openapi";
2
+
3
+ import { CommentFactory } from "../../factories/CommentFactory";
4
+
5
+ import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
6
+ import { MetadataAlias } from "../../schemas/metadata/MetadataAlias";
7
+
8
+ import { application_description } from "./application_description";
9
+ import { application_v30_object } from "./application_v30_object";
10
+ import { application_v30_schema } from "./application_v30_schema";
11
+
12
+ /**
13
+ * @internal
14
+ */
15
+ export const application_v30_alias =
16
+ <BlockNever extends boolean>(blockNever: BlockNever) =>
17
+ (components: OpenApiV3.IComponents) =>
18
+ (alias: MetadataAlias) =>
19
+ (nullable: boolean): OpenApiV3.IJsonSchema.IReference => {
20
+ if (alias.value.size() === 1 && alias.value.objects.length === 1)
21
+ return application_v30_object(components)(alias.value.objects[0]!)(
22
+ nullable,
23
+ ) as OpenApiV3.IJsonSchema.IReference;
24
+
25
+ const key: string = `${alias.name}${nullable ? ".Nullable" : ""}`;
26
+ const $ref: string = `#/components/schemas/${key}`;
27
+
28
+ if (components.schemas?.[key] === undefined) {
29
+ // TEMPORARY ASSIGNMENT
30
+ components.schemas ??= {};
31
+ components.schemas[key] = {};
32
+
33
+ // GENERATE SCHEMA
34
+ const schema: OpenApiV3.IJsonSchema | null = application_v30_schema(
35
+ blockNever,
36
+ )(components)({
37
+ deprecated:
38
+ alias.jsDocTags.some((tag) => tag.name === "deprecated") || undefined,
39
+ title: (() => {
40
+ const info: IJsDocTagInfo | undefined = alias.jsDocTags.find(
41
+ (tag) => tag.name === "title",
42
+ );
43
+ return info?.text?.length
44
+ ? CommentFactory.merge(info.text)
45
+ : undefined;
46
+ })(),
47
+ description: application_description(alias),
48
+ })(alias.value);
49
+ if (schema !== null) Object.assign(components.schemas[key]!, schema);
50
+ }
51
+ return { $ref };
52
+ };
@@ -1,149 +1,149 @@
1
- import { OpenApiV3 } from "@samchon/openapi";
2
-
3
- import { CommentFactory } from "../../factories/CommentFactory";
4
-
5
- import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
6
- import { Metadata } from "../../schemas/metadata/Metadata";
7
- import { MetadataObject } from "../../schemas/metadata/MetadataObject";
8
-
9
- import { PatternUtil } from "../../utils/PatternUtil";
10
-
11
- import { application_description } from "./application_description";
12
- import { application_v30_schema } from "./application_v30_schema";
13
- import { metadata_to_pattern } from "./metadata_to_pattern";
14
-
15
- /**
16
- * @internal
17
- */
18
- export const application_v30_object =
19
- (components: OpenApiV3.IComponents) =>
20
- (obj: MetadataObject) =>
21
- (
22
- nullable: boolean,
23
- ): OpenApiV3.IJsonSchema.IReference | OpenApiV3.IJsonSchema.IObject => {
24
- if (obj.isLiteral() === true)
25
- return create_object_schema(components)(obj)(nullable);
26
-
27
- const key: string = `${obj.name}${nullable ? ".Nullable" : ""}`;
28
- const $ref: string = `#/components/schemas/${key}`;
29
- if (components.schemas?.[key] !== undefined) return { $ref };
30
-
31
- const object: OpenApiV3.IJsonSchema = {};
32
- components.schemas ??= {};
33
- components.schemas[key] = object;
34
- Object.assign(object, create_object_schema(components)(obj)(nullable));
35
- return { $ref };
36
- };
37
-
38
- /**
39
- * @internal
40
- */
41
- const create_object_schema =
42
- (components: OpenApiV3.IComponents) =>
43
- (obj: MetadataObject) =>
44
- (nullable: boolean): OpenApiV3.IJsonSchema.IObject => {
45
- // ITERATE PROPERTIES
46
- const properties: Record<string, any> = {};
47
- const extraMeta: ISuperfluous = {
48
- patternProperties: {},
49
- additionalProperties: undefined,
50
- };
51
- const required: string[] = [];
52
-
53
- for (const property of obj.properties) {
54
- if (
55
- // FUNCTIONAL TYPE
56
- property.value.functional === true &&
57
- property.value.nullable === false &&
58
- property.value.isRequired() === true &&
59
- property.value.size() === 0
60
- )
61
- continue;
62
- else if (property.jsDocTags.find((tag) => tag.name === "hidden"))
63
- continue; // THE HIDDEN TAG
64
-
65
- const key: string | null = property.key.getSoleLiteral();
66
- const schema: OpenApiV3.IJsonSchema | null = application_v30_schema(true)(
67
- components,
68
- )({
69
- deprecated:
70
- property.jsDocTags.some((tag) => tag.name === "deprecated") ||
71
- undefined,
72
- title: (() => {
73
- const info: IJsDocTagInfo | undefined = property.jsDocTags.find(
74
- (tag) => tag.name === "title",
75
- );
76
- if (info?.text?.length) return CommentFactory.merge(info.text);
77
- else if (!property.description?.length) return undefined;
78
-
79
- const index: number = property.description.indexOf("\n");
80
- const top: string = (
81
- index === -1
82
- ? property.description
83
- : property.description.substring(0, index)
84
- ).trim();
85
- return top.endsWith(".")
86
- ? top.substring(0, top.length - 1)
87
- : undefined;
88
- })(),
89
- description: application_description(property),
90
- })(property.value);
91
-
92
- if (schema === null) continue;
93
- if (key !== null) {
94
- properties[key] = schema;
95
- if (property.value.isRequired() === true) required.push(key);
96
- } else {
97
- const pattern: string = metadata_to_pattern(true)(property.key);
98
- if (pattern === PatternUtil.STRING)
99
- extraMeta.additionalProperties = [property.value, schema];
100
- else extraMeta.patternProperties[pattern] = [property.value, schema];
101
- }
102
- }
103
-
104
- return {
105
- type: "object",
106
- properties,
107
- nullable,
108
- required: required.length ? required : undefined,
109
- title: (() => {
110
- const info: IJsDocTagInfo | undefined = obj.jsDocTags.find(
111
- (tag) => tag.name === "title",
112
- );
113
- return info?.text?.length ? CommentFactory.merge(info.text) : undefined;
114
- })(),
115
- description: application_description(obj),
116
- additionalProperties: join(components)(extraMeta),
117
- };
118
- };
119
-
120
- /**
121
- * @internal
122
- */
123
- const join =
124
- (components: OpenApiV3.IComponents) =>
125
- (extra: ISuperfluous): OpenApiV3.IJsonSchema | undefined => {
126
- // LIST UP METADATA
127
- const elements: [Metadata, OpenApiV3.IJsonSchema][] = Object.values(
128
- extra.patternProperties || {},
129
- );
130
- if (extra.additionalProperties) elements.push(extra.additionalProperties);
131
-
132
- // SHORT RETURN
133
- if (elements.length === 0) return undefined;
134
- else if (elements.length === 1) return elements[0]![1]!;
135
-
136
- // MERGE METADATA AND GENERATE VULNERABLE SCHEMA
137
- const meta: Metadata = elements
138
- .map((tuple) => tuple[0])
139
- .reduce((x, y) => Metadata.merge(x, y));
140
- return application_v30_schema(true)(components)({})(meta) ?? undefined;
141
- };
142
-
143
- /**
144
- * @internal
145
- */
146
- interface ISuperfluous {
147
- additionalProperties?: undefined | [Metadata, OpenApiV3.IJsonSchema];
148
- patternProperties: Record<string, [Metadata, OpenApiV3.IJsonSchema]>;
149
- }
1
+ import { OpenApiV3 } from "@samchon/openapi";
2
+
3
+ import { CommentFactory } from "../../factories/CommentFactory";
4
+
5
+ import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
6
+ import { Metadata } from "../../schemas/metadata/Metadata";
7
+ import { MetadataObject } from "../../schemas/metadata/MetadataObject";
8
+
9
+ import { PatternUtil } from "../../utils/PatternUtil";
10
+
11
+ import { application_description } from "./application_description";
12
+ import { application_v30_schema } from "./application_v30_schema";
13
+ import { metadata_to_pattern } from "./metadata_to_pattern";
14
+
15
+ /**
16
+ * @internal
17
+ */
18
+ export const application_v30_object =
19
+ (components: OpenApiV3.IComponents) =>
20
+ (obj: MetadataObject) =>
21
+ (
22
+ nullable: boolean,
23
+ ): OpenApiV3.IJsonSchema.IReference | OpenApiV3.IJsonSchema.IObject => {
24
+ if (obj.isLiteral() === true)
25
+ return create_object_schema(components)(obj)(nullable);
26
+
27
+ const key: string = `${obj.name}${nullable ? ".Nullable" : ""}`;
28
+ const $ref: string = `#/components/schemas/${key}`;
29
+ if (components.schemas?.[key] !== undefined) return { $ref };
30
+
31
+ const object: OpenApiV3.IJsonSchema = {};
32
+ components.schemas ??= {};
33
+ components.schemas[key] = object;
34
+ Object.assign(object, create_object_schema(components)(obj)(nullable));
35
+ return { $ref };
36
+ };
37
+
38
+ /**
39
+ * @internal
40
+ */
41
+ const create_object_schema =
42
+ (components: OpenApiV3.IComponents) =>
43
+ (obj: MetadataObject) =>
44
+ (nullable: boolean): OpenApiV3.IJsonSchema.IObject => {
45
+ // ITERATE PROPERTIES
46
+ const properties: Record<string, any> = {};
47
+ const extraMeta: ISuperfluous = {
48
+ patternProperties: {},
49
+ additionalProperties: undefined,
50
+ };
51
+ const required: string[] = [];
52
+
53
+ for (const property of obj.properties) {
54
+ if (
55
+ // FUNCTIONAL TYPE
56
+ property.value.functional === true &&
57
+ property.value.nullable === false &&
58
+ property.value.isRequired() === true &&
59
+ property.value.size() === 0
60
+ )
61
+ continue;
62
+ else if (property.jsDocTags.find((tag) => tag.name === "hidden"))
63
+ continue; // THE HIDDEN TAG
64
+
65
+ const key: string | null = property.key.getSoleLiteral();
66
+ const schema: OpenApiV3.IJsonSchema | null = application_v30_schema(true)(
67
+ components,
68
+ )({
69
+ deprecated:
70
+ property.jsDocTags.some((tag) => tag.name === "deprecated") ||
71
+ undefined,
72
+ title: (() => {
73
+ const info: IJsDocTagInfo | undefined = property.jsDocTags.find(
74
+ (tag) => tag.name === "title",
75
+ );
76
+ if (info?.text?.length) return CommentFactory.merge(info.text);
77
+ else if (!property.description?.length) return undefined;
78
+
79
+ const index: number = property.description.indexOf("\n");
80
+ const top: string = (
81
+ index === -1
82
+ ? property.description
83
+ : property.description.substring(0, index)
84
+ ).trim();
85
+ return top.endsWith(".")
86
+ ? top.substring(0, top.length - 1)
87
+ : undefined;
88
+ })(),
89
+ description: application_description(property),
90
+ })(property.value);
91
+
92
+ if (schema === null) continue;
93
+ if (key !== null) {
94
+ properties[key] = schema;
95
+ if (property.value.isRequired() === true) required.push(key);
96
+ } else {
97
+ const pattern: string = metadata_to_pattern(true)(property.key);
98
+ if (pattern === PatternUtil.STRING)
99
+ extraMeta.additionalProperties = [property.value, schema];
100
+ else extraMeta.patternProperties[pattern] = [property.value, schema];
101
+ }
102
+ }
103
+
104
+ return {
105
+ type: "object",
106
+ properties,
107
+ nullable,
108
+ required: required.length ? required : undefined,
109
+ title: (() => {
110
+ const info: IJsDocTagInfo | undefined = obj.jsDocTags.find(
111
+ (tag) => tag.name === "title",
112
+ );
113
+ return info?.text?.length ? CommentFactory.merge(info.text) : undefined;
114
+ })(),
115
+ description: application_description(obj),
116
+ additionalProperties: join(components)(extraMeta),
117
+ };
118
+ };
119
+
120
+ /**
121
+ * @internal
122
+ */
123
+ const join =
124
+ (components: OpenApiV3.IComponents) =>
125
+ (extra: ISuperfluous): OpenApiV3.IJsonSchema | undefined => {
126
+ // LIST UP METADATA
127
+ const elements: [Metadata, OpenApiV3.IJsonSchema][] = Object.values(
128
+ extra.patternProperties || {},
129
+ );
130
+ if (extra.additionalProperties) elements.push(extra.additionalProperties);
131
+
132
+ // SHORT RETURN
133
+ if (elements.length === 0) return undefined;
134
+ else if (elements.length === 1) return elements[0]![1]!;
135
+
136
+ // MERGE METADATA AND GENERATE VULNERABLE SCHEMA
137
+ const meta: Metadata = elements
138
+ .map((tuple) => tuple[0])
139
+ .reduce((x, y) => Metadata.merge(x, y));
140
+ return application_v30_schema(true)(components)({})(meta) ?? undefined;
141
+ };
142
+
143
+ /**
144
+ * @internal
145
+ */
146
+ interface ISuperfluous {
147
+ additionalProperties?: undefined | [Metadata, OpenApiV3.IJsonSchema];
148
+ patternProperties: Record<string, [Metadata, OpenApiV3.IJsonSchema]>;
149
+ }