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,159 +1,162 @@
1
- import { OpenApiV3 } from "@samchon/openapi";
2
-
3
- import { Metadata } from "../../schemas/metadata/Metadata";
4
- import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
5
-
6
- import { AtomicPredicator } from "../helpers/AtomicPredicator";
7
- import { application_array } from "./application_array";
8
- import { application_boolean } from "./application_boolean";
9
- import { application_escaped } from "./application_escaped";
10
- import { application_number } from "./application_number";
11
- import { application_string } from "./application_string";
12
- import { application_templates } from "./application_templates";
13
- import { application_union_discriminator } from "./application_union_discriminator";
14
- import { application_v30_alias } from "./application_v30_alias";
15
- import { application_v30_constant } from "./application_v30_constant";
16
- import { application_v30_native } from "./application_v30_native";
17
- import { application_v30_object } from "./application_v30_object";
18
- import { application_v30_tuple } from "./application_v30_tuple";
19
-
20
- /**
21
- * @internal
22
- */
23
- export const application_v30_schema =
24
- <BlockNever extends boolean>(blockNever: BlockNever) =>
25
- (components: OpenApiV3.IComponents) =>
26
- (attribute: OpenApiV3.IJsonSchema.__IAttribute) =>
27
- (
28
- meta: Metadata,
29
- ): BlockNever extends true
30
- ? OpenApiV3.IJsonSchema | null
31
- : OpenApiV3.IJsonSchema => {
32
- // VULNERABLE CASE
33
- if (meta.any === true)
34
- return {
35
- ...attribute,
36
- type: undefined,
37
- };
38
- else if (meta.nullable && meta.empty())
39
- return { type: "null", ...attribute };
40
-
41
- //----
42
- // GATHER UNION SCHEMAS
43
- //----
44
- const union: OpenApiV3.IJsonSchema[] = [];
45
- const insert = meta.nullable
46
- ? (schema: OpenApiV3.IJsonSchema) =>
47
- union.push({
48
- ...schema,
49
- nullable: (schema as OpenApiV3.IJsonSchema.__ISignificant<any>).type
50
- ? true
51
- : undefined,
52
- } as OpenApiV3.IJsonSchema)
53
- : (schema: OpenApiV3.IJsonSchema) => union.push(schema);
54
-
55
- // toJSON() METHOD
56
- if (meta.escaped !== null)
57
- application_escaped<"3.0">(application_v30_schema(false)(components)({}))(
58
- meta.escaped,
59
- ).forEach(insert);
60
-
61
- // ATOMIC TYPES
62
- if (meta.templates.length && AtomicPredicator.template(meta))
63
- application_templates(meta).map(insert);
64
- for (const constant of meta.constants)
65
- if (constant.type === "bigint") throw new TypeError(NO_BIGINT);
66
- else if (AtomicPredicator.constant(meta)(constant.type) === false)
67
- continue;
68
- else insert(application_v30_constant(constant));
69
- for (const a of meta.atomics)
70
- if (a.type === "bigint") throw new TypeError(NO_BIGINT);
71
- else if (a.type === "boolean") application_boolean(a).forEach(insert);
72
- else if (a.type === "number") application_number(a).forEach(insert);
73
- else if (a.type === "string") application_string(a).forEach(insert);
74
-
75
- // ARRAY
76
- for (const array of meta.arrays)
77
- application_array<"3.0">(application_v30_schema(false)(components)({}))(
78
- components,
79
- )(array).forEach(insert);
80
-
81
- // TUPLE
82
- for (const tuple of meta.tuples)
83
- insert(application_v30_tuple(components)(tuple)(attribute));
84
-
85
- // NATIVES
86
- for (const native of meta.natives)
87
- if (AtomicPredicator.native(native)) {
88
- const type: string = native.toLowerCase();
89
- if (meta.atomics.some((a) => a.type === type)) continue;
90
- else if (type === "bigint") throw new TypeError(NO_BIGINT);
91
- else if (type === "boolean")
92
- insert(
93
- application_boolean(
94
- MetadataAtomic.create({
95
- type: "boolean",
96
- tags: [],
97
- }),
98
- )[0]!,
99
- );
100
- else if (type === "number")
101
- insert(
102
- application_number(
103
- MetadataAtomic.create({
104
- type: "number",
105
- tags: [],
106
- }),
107
- )[0]!,
108
- );
109
- else if (type === "string")
110
- insert(
111
- application_string(
112
- MetadataAtomic.create({
113
- type: "string",
114
- tags: [],
115
- }),
116
- )[0]!,
117
- );
118
- } else insert(application_v30_native(components)(native)(meta.nullable));
119
- if (meta.sets.length)
120
- insert(application_v30_native(components)(`Set`)(meta.nullable));
121
- if (meta.maps.length)
122
- insert(application_v30_native(components)(`Map`)(meta.nullable));
123
-
124
- // OBJECT
125
- for (const obj of meta.objects)
126
- insert(application_v30_object(components)(obj)(meta.nullable));
127
-
128
- // ALIASES
129
- for (const alias of meta.aliases)
130
- insert(
131
- application_v30_alias(blockNever)(components)(alias)(meta.nullable),
132
- );
133
-
134
- //----
135
- // RETURNS
136
- //----
137
- if (union.length === 0 && blockNever === true) return null!;
138
- const schema: OpenApiV3.IJsonSchema =
139
- union.length === 0
140
- ? { type: undefined }
141
- : union.length === 1
142
- ? union[0]!
143
- : {
144
- oneOf: union,
145
- discriminator: application_union_discriminator(meta),
146
- };
147
- return {
148
- ...schema,
149
- ...attribute,
150
- title: attribute.title ?? schema.title,
151
- description: attribute.description ?? schema.description,
152
- deprecated: attribute.deprecated ?? schema.deprecated,
153
- };
154
- };
155
-
156
- /**
157
- * @internal
158
- */
159
- const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
1
+ import { OpenApiV3 } from "@samchon/openapi";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+ import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
5
+
6
+ import { AtomicPredicator } from "../helpers/AtomicPredicator";
7
+ import { application_array } from "./application_array";
8
+ import { application_bigint } from "./application_bigint";
9
+ import { application_boolean } from "./application_boolean";
10
+ import { application_escaped } from "./application_escaped";
11
+ import { application_number } from "./application_number";
12
+ import { application_string } from "./application_string";
13
+ import { application_templates } from "./application_templates";
14
+ import { application_union_discriminator } from "./application_union_discriminator";
15
+ import { application_v30_alias } from "./application_v30_alias";
16
+ import { application_v30_constant } from "./application_v30_constant";
17
+ import { application_v30_native } from "./application_v30_native";
18
+ import { application_v30_object } from "./application_v30_object";
19
+ import { application_v30_tuple } from "./application_v30_tuple";
20
+
21
+ /**
22
+ * @internal
23
+ */
24
+ export const application_v30_schema =
25
+ <BlockNever extends boolean>(blockNever: BlockNever) =>
26
+ (components: OpenApiV3.IComponents) =>
27
+ (attribute: OpenApiV3.IJsonSchema.__IAttribute) =>
28
+ (
29
+ meta: Metadata,
30
+ ): BlockNever extends true
31
+ ? OpenApiV3.IJsonSchema | null
32
+ : OpenApiV3.IJsonSchema => {
33
+ // VULNERABLE CASE
34
+ if (meta.any === true)
35
+ return {
36
+ ...attribute,
37
+ type: undefined,
38
+ };
39
+ else if (meta.nullable && meta.empty())
40
+ return { type: "null", ...attribute };
41
+
42
+ //----
43
+ // GATHER UNION SCHEMAS
44
+ //----
45
+ const union: OpenApiV3.IJsonSchema[] = [];
46
+ const insert = meta.nullable
47
+ ? (schema: OpenApiV3.IJsonSchema) =>
48
+ union.push({
49
+ ...schema,
50
+ nullable: (schema as OpenApiV3.IJsonSchema.__ISignificant<any>).type
51
+ ? true
52
+ : undefined,
53
+ } as OpenApiV3.IJsonSchema)
54
+ : (schema: OpenApiV3.IJsonSchema) => union.push(schema);
55
+
56
+ // toJSON() METHOD
57
+ if (meta.escaped !== null)
58
+ application_escaped<"3.0">(application_v30_schema(false)(components)({}))(
59
+ meta.escaped,
60
+ ).forEach(insert);
61
+
62
+ // ATOMIC TYPES
63
+ if (meta.templates.length && AtomicPredicator.template(meta))
64
+ application_templates(meta).map(insert);
65
+ for (const constant of meta.constants)
66
+ if (AtomicPredicator.constant(meta)(constant.type) === false) continue;
67
+ else insert(application_v30_constant(constant));
68
+ for (const a of meta.atomics)
69
+ if (a.type === "boolean") application_boolean(a).forEach(insert);
70
+ else if (a.type === "bigint")
71
+ application_bigint(a).forEach(insert as any);
72
+ else if (a.type === "number") application_number(a).forEach(insert);
73
+ else if (a.type === "string") application_string(a).forEach(insert);
74
+
75
+ // ARRAY
76
+ for (const array of meta.arrays)
77
+ application_array<"3.0">(application_v30_schema(false)(components)({}))(
78
+ components,
79
+ )(array).forEach(insert);
80
+
81
+ // TUPLE
82
+ for (const tuple of meta.tuples)
83
+ insert(application_v30_tuple(components)(tuple)(attribute));
84
+
85
+ // NATIVES
86
+ for (const native of meta.natives)
87
+ if (AtomicPredicator.native(native)) {
88
+ const type: string = native.toLowerCase();
89
+ if (meta.atomics.some((a) => a.type === type)) continue;
90
+ else if (type === "boolean")
91
+ insert(
92
+ application_boolean(
93
+ MetadataAtomic.create({
94
+ type: "boolean",
95
+ tags: [],
96
+ }),
97
+ )[0]!,
98
+ );
99
+ else if (type === "bigint")
100
+ insert(
101
+ application_bigint(
102
+ MetadataAtomic.create({
103
+ type: "bigint",
104
+ tags: [],
105
+ }),
106
+ )[0]! as any,
107
+ );
108
+ else if (type === "number")
109
+ insert(
110
+ application_number(
111
+ MetadataAtomic.create({
112
+ type: "number",
113
+ tags: [],
114
+ }),
115
+ )[0]!,
116
+ );
117
+ else if (type === "string")
118
+ insert(
119
+ application_string(
120
+ MetadataAtomic.create({
121
+ type: "string",
122
+ tags: [],
123
+ }),
124
+ )[0]!,
125
+ );
126
+ } else insert(application_v30_native(components)(native)(meta.nullable));
127
+ if (meta.sets.length)
128
+ insert(application_v30_native(components)(`Set`)(meta.nullable));
129
+ if (meta.maps.length)
130
+ insert(application_v30_native(components)(`Map`)(meta.nullable));
131
+
132
+ // OBJECT
133
+ for (const obj of meta.objects)
134
+ insert(application_v30_object(components)(obj)(meta.nullable));
135
+
136
+ // ALIASES
137
+ for (const alias of meta.aliases)
138
+ insert(
139
+ application_v30_alias(blockNever)(components)(alias)(meta.nullable),
140
+ );
141
+
142
+ //----
143
+ // RETURNS
144
+ //----
145
+ if (union.length === 0 && blockNever === true) return null!;
146
+ const schema: OpenApiV3.IJsonSchema =
147
+ union.length === 0
148
+ ? { type: undefined }
149
+ : union.length === 1
150
+ ? union[0]!
151
+ : {
152
+ oneOf: union,
153
+ discriminator: application_union_discriminator(meta),
154
+ };
155
+ return {
156
+ ...schema,
157
+ ...attribute,
158
+ title: attribute.title ?? schema.title,
159
+ description: attribute.description ?? schema.description,
160
+ deprecated: attribute.deprecated ?? schema.deprecated,
161
+ };
162
+ };
@@ -1,33 +1,33 @@
1
- import { OpenApiV3 } from "@samchon/openapi";
2
-
3
- import { Metadata } from "../../schemas/metadata/Metadata";
4
- import { MetadataTuple } from "../../schemas/metadata/MetadataTuple";
5
-
6
- import { application_v30_schema } from "./application_v30_schema";
7
-
8
- /**
9
- * @internal
10
- */
11
- export const application_v30_tuple =
12
- (components: OpenApiV3.IComponents) =>
13
- (tuple: MetadataTuple) =>
14
- (
15
- attribute: OpenApiV3.IJsonSchema.__IAttribute,
16
- ): OpenApiV3.IJsonSchema.IArray => ({
17
- ...attribute,
18
- type: "array",
19
- items: application_v30_schema(false)(components)(
20
- tuple.type.recursive ? {} : attribute,
21
- )(
22
- tuple.type.elements.reduce(
23
- (x, y) => Metadata.merge(x.rest ?? x, y.rest ?? y),
24
- Metadata.initialize(),
25
- ),
26
- ),
27
- minItems: !!tuple.type.elements.at(-1)?.rest
28
- ? tuple.type.elements.length - 1
29
- : tuple.type.elements.filter((x) => !x.optional).length,
30
- maxItems: !!tuple.type.elements.at(-1)?.rest
31
- ? undefined!
32
- : tuple.type.elements.length,
33
- });
1
+ import { OpenApiV3 } from "@samchon/openapi";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+ import { MetadataTuple } from "../../schemas/metadata/MetadataTuple";
5
+
6
+ import { application_v30_schema } from "./application_v30_schema";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const application_v30_tuple =
12
+ (components: OpenApiV3.IComponents) =>
13
+ (tuple: MetadataTuple) =>
14
+ (
15
+ attribute: OpenApiV3.IJsonSchema.__IAttribute,
16
+ ): OpenApiV3.IJsonSchema.IArray => ({
17
+ ...attribute,
18
+ type: "array",
19
+ items: application_v30_schema(false)(components)(
20
+ tuple.type.recursive ? {} : attribute,
21
+ )(
22
+ tuple.type.elements.reduce(
23
+ (x, y) => Metadata.merge(x.rest ?? x, y.rest ?? y),
24
+ Metadata.initialize(),
25
+ ),
26
+ ),
27
+ minItems: !!tuple.type.elements.at(-1)?.rest
28
+ ? tuple.type.elements.length - 1
29
+ : tuple.type.elements.filter((x) => !x.optional).length,
30
+ maxItems: !!tuple.type.elements.at(-1)?.rest
31
+ ? undefined!
32
+ : tuple.type.elements.length,
33
+ });
@@ -16,7 +16,10 @@ export const application_v31_constant = (
16
16
  .map((value) =>
17
17
  application_plugin(
18
18
  {
19
- const: value.value as boolean | number | string,
19
+ const:
20
+ typeof value.value === "bigint"
21
+ ? Number(value.value)
22
+ : (value.value as boolean | number | string),
20
23
  title: application_title(value),
21
24
  description: application_description(value),
22
25
  } satisfies OpenApi.IJsonSchema.IConstant,