typia 4.0.0 → 4.0.1

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 (87) hide show
  1. package/lib/programmers/ApplicationProgrammer.js +1 -1
  2. package/lib/programmers/internal/application_array.js +19 -41
  3. package/lib/programmers/internal/application_array.js.map +1 -1
  4. package/lib/programmers/internal/application_definition.d.ts +1 -1
  5. package/lib/programmers/internal/application_definition.js +8 -8
  6. package/lib/programmers/internal/application_definition.js.map +1 -1
  7. package/lib/programmers/internal/application_native.js +3 -3
  8. package/lib/programmers/internal/application_object.js +4 -4
  9. package/lib/programmers/internal/application_schema.js +3 -3
  10. package/lib/programmers/internal/application_schema.js.map +1 -1
  11. package/lib/programmers/internal/application_tuple.js +8 -30
  12. package/lib/programmers/internal/application_tuple.js.map +1 -1
  13. package/lib/schemas/IJsonComponents.d.ts +1 -12
  14. package/lib/schemas/IJsonSchema.d.ts +1 -1
  15. package/package.json +1 -1
  16. package/src/IRandomGenerator.ts +34 -34
  17. package/src/factories/IdentifierFactory.ts +65 -65
  18. package/src/factories/MetadataCollection.ts +254 -254
  19. package/src/factories/MetadataFactory.ts +40 -40
  20. package/src/factories/MetadataTagFactory.ts +300 -300
  21. package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
  22. package/src/factories/internal/metadata/emplace_metadata_definition.ts +35 -35
  23. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  24. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
  25. package/src/factories/internal/metadata/explore_metadata.ts +66 -66
  26. package/src/factories/internal/metadata/iterate_metadata.ts +77 -77
  27. package/src/factories/internal/metadata/iterate_metadata_array.ts +25 -25
  28. package/src/factories/internal/metadata/iterate_metadata_collection.ts +130 -130
  29. package/src/factories/internal/metadata/iterate_metadata_definition.ts +30 -30
  30. package/src/factories/internal/metadata/iterate_metadata_object.ts +49 -49
  31. package/src/factories/internal/metadata/iterate_metadata_sort.ts +68 -68
  32. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
  33. package/src/factories/internal/metadata/iterate_metadata_union.ts +68 -68
  34. package/src/metadata/IMetadata.ts +27 -27
  35. package/src/metadata/IMetadataAlias.ts +12 -12
  36. package/src/metadata/IMetadataApplication.ts +7 -7
  37. package/src/metadata/IMetadataArray.ts +10 -10
  38. package/src/metadata/IMetadataCollection.ts +11 -11
  39. package/src/metadata/IMetadataDictionary.ts +14 -14
  40. package/src/metadata/IMetadataObject.ts +18 -18
  41. package/src/metadata/IMetadataProperty.ts +11 -11
  42. package/src/metadata/IMetadataTuple.ts +10 -10
  43. package/src/metadata/Metadata.ts +585 -585
  44. package/src/metadata/MetadataAlias.ts +61 -61
  45. package/src/metadata/MetadataArray.ts +52 -52
  46. package/src/metadata/MetadataObject.ts +114 -114
  47. package/src/metadata/MetadataProperty.ts +64 -64
  48. package/src/metadata/MetadataTuple.ts +53 -53
  49. package/src/programmers/ApplicationProgrammer.ts +55 -55
  50. package/src/programmers/AssertProgrammer.ts +291 -291
  51. package/src/programmers/CheckerProgrammer.ts +1182 -1182
  52. package/src/programmers/CloneProgrammer.ts +595 -595
  53. package/src/programmers/FeatureProgrammer.ts +495 -495
  54. package/src/programmers/IsProgrammer.ts +250 -250
  55. package/src/programmers/LiteralsProgrammer.ts +66 -66
  56. package/src/programmers/PruneProgrammer.ts +550 -550
  57. package/src/programmers/RandomProgrammer.ts +589 -589
  58. package/src/programmers/StringifyProgrammer.ts +990 -990
  59. package/src/programmers/ValidateProgrammer.ts +313 -313
  60. package/src/programmers/helpers/FunctionImporeter.ts +78 -78
  61. package/src/programmers/helpers/RandomJoiner.ts +173 -173
  62. package/src/programmers/helpers/UnionExplorer.ts +301 -301
  63. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  64. package/src/programmers/helpers/disable_function_importer_declare.ts +26 -26
  65. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  66. package/src/programmers/internal/application_array.ts +30 -64
  67. package/src/programmers/internal/application_boolean.ts +15 -15
  68. package/src/programmers/internal/application_constant.ts +26 -26
  69. package/src/programmers/internal/application_default.ts +17 -17
  70. package/src/programmers/internal/application_definition.ts +45 -45
  71. package/src/programmers/internal/application_native.ts +39 -39
  72. package/src/programmers/internal/application_number.ts +74 -74
  73. package/src/programmers/internal/application_object.ts +167 -167
  74. package/src/programmers/internal/application_schema.ts +156 -164
  75. package/src/programmers/internal/application_tuple.ts +47 -77
  76. package/src/programmers/internal/check_union_array_like.ts +329 -329
  77. package/src/programmers/internal/feature_object_entries.ts +63 -63
  78. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
  79. package/src/schemas/IJsonApplication.ts +8 -8
  80. package/src/schemas/IJsonComponents.ts +34 -45
  81. package/src/schemas/IJsonSchema.ts +134 -134
  82. package/src/transformers/CallExpressionTransformer.ts +179 -179
  83. package/src/transformers/FileTransformer.ts +47 -47
  84. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +104 -104
  85. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +53 -53
  86. package/src/utils/ArrayUtil.ts +45 -45
  87. package/src/utils/RandomGenerator.ts +81 -81
@@ -1,63 +1,63 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
-
5
- import { MetadataObject } from "../../metadata/MetadataObject";
6
-
7
- import { Escaper } from "../../utils/Escaper";
8
-
9
- import { FeatureProgrammer } from "../FeatureProgrammer";
10
- import { FunctionImporter } from "../helpers/FunctionImporeter";
11
-
12
- /**
13
- * @internal
14
- */
15
- export const feature_object_entries =
16
- <Output extends ts.ConciseBody>(
17
- config: Pick<
18
- FeatureProgrammer.IConfig<Output>,
19
- "decoder" | "path" | "trace"
20
- >,
21
- ) =>
22
- (importer: FunctionImporter) =>
23
- (obj: MetadataObject) =>
24
- (input: ts.Expression) =>
25
- obj.properties.map((prop) => {
26
- const sole: string | null = prop.key.getSoleLiteral();
27
- const propInput =
28
- sole === null
29
- ? ts.factory.createIdentifier("value")
30
- : Escaper.variable(sole)
31
- ? ts.factory.createPropertyAccessExpression(
32
- input,
33
- ts.factory.createIdentifier(sole),
34
- )
35
- : ts.factory.createElementAccessExpression(
36
- input,
37
- ts.factory.createStringLiteral(sole),
38
- );
39
-
40
- return {
41
- input: propInput,
42
- key: prop.key,
43
- meta: prop.value,
44
- expression: config.decoder()(
45
- propInput,
46
- prop.value,
47
- {
48
- tracable: config.path || config.trace,
49
- source: "function",
50
- from: "object",
51
- postfix:
52
- sole !== null
53
- ? IdentifierFactory.postfix(sole)
54
- : (() => {
55
- importer.use("join");
56
- return `$join(key)`;
57
- })(),
58
- },
59
- prop.tags,
60
- prop.jsDocTags,
61
- ),
62
- };
63
- });
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+
5
+ import { MetadataObject } from "../../metadata/MetadataObject";
6
+
7
+ import { Escaper } from "../../utils/Escaper";
8
+
9
+ import { FeatureProgrammer } from "../FeatureProgrammer";
10
+ import { FunctionImporter } from "../helpers/FunctionImporeter";
11
+
12
+ /**
13
+ * @internal
14
+ */
15
+ export const feature_object_entries =
16
+ <Output extends ts.ConciseBody>(
17
+ config: Pick<
18
+ FeatureProgrammer.IConfig<Output>,
19
+ "decoder" | "path" | "trace"
20
+ >,
21
+ ) =>
22
+ (importer: FunctionImporter) =>
23
+ (obj: MetadataObject) =>
24
+ (input: ts.Expression) =>
25
+ obj.properties.map((prop) => {
26
+ const sole: string | null = prop.key.getSoleLiteral();
27
+ const propInput =
28
+ sole === null
29
+ ? ts.factory.createIdentifier("value")
30
+ : Escaper.variable(sole)
31
+ ? ts.factory.createPropertyAccessExpression(
32
+ input,
33
+ ts.factory.createIdentifier(sole),
34
+ )
35
+ : ts.factory.createElementAccessExpression(
36
+ input,
37
+ ts.factory.createStringLiteral(sole),
38
+ );
39
+
40
+ return {
41
+ input: propInput,
42
+ key: prop.key,
43
+ meta: prop.value,
44
+ expression: config.decoder()(
45
+ propInput,
46
+ prop.value,
47
+ {
48
+ tracable: config.path || config.trace,
49
+ source: "function",
50
+ from: "object",
51
+ postfix:
52
+ sole !== null
53
+ ? IdentifierFactory.postfix(sole)
54
+ : (() => {
55
+ importer.use("join");
56
+ return `$join(key)`;
57
+ })(),
58
+ },
59
+ prop.tags,
60
+ prop.jsDocTags,
61
+ ),
62
+ };
63
+ });
@@ -1,16 +1,16 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { MetadataArray } from "../../metadata/MetadataArray";
3
-
4
- export const wrap_metadata_rest_tuple = (rest: Metadata) => {
5
- const wrapper: Metadata = Metadata.initialize();
6
- wrapper.arrays.push(
7
- MetadataArray.create({
8
- name: `...${rest.getName()}`,
9
- value: rest,
10
- nullables: [],
11
- recursive: false,
12
- index: null,
13
- }),
14
- );
15
- return wrapper;
16
- };
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { MetadataArray } from "../../metadata/MetadataArray";
3
+
4
+ export const wrap_metadata_rest_tuple = (rest: Metadata) => {
5
+ const wrapper: Metadata = Metadata.initialize();
6
+ wrapper.arrays.push(
7
+ MetadataArray.create({
8
+ name: `...${rest.getName()}`,
9
+ value: rest,
10
+ nullables: [],
11
+ recursive: false,
12
+ index: null,
13
+ }),
14
+ );
15
+ return wrapper;
16
+ };
@@ -1,8 +1,8 @@
1
- import { IJsonComponents } from "./IJsonComponents";
2
- import { IJsonSchema } from "./IJsonSchema";
3
-
4
- export interface IJsonApplication {
5
- schemas: IJsonSchema[];
6
- components: IJsonComponents;
7
- purpose: "swagger" | "ajv";
8
- }
1
+ import { IJsonComponents } from "./IJsonComponents";
2
+ import { IJsonSchema } from "./IJsonSchema";
3
+
4
+ export interface IJsonApplication {
5
+ schemas: IJsonSchema[];
6
+ components: IJsonComponents;
7
+ purpose: "swagger" | "ajv";
8
+ }
@@ -1,45 +1,34 @@
1
- import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
2
-
3
- import { IJsonSchema } from "./IJsonSchema";
4
-
5
- export interface IJsonComponents {
6
- objects?: Record<string, IJsonComponents.IObject>;
7
- aliases?: Record<string, IJsonComponents.IAlias>;
8
- arrays?: Record<string, IJsonComponents.IArray>;
9
- tuples?: Record<string, IJsonComponents.ITuple | IJsonComponents.IArray>;
10
- }
11
- export namespace IJsonComponents {
12
- export interface IArray extends IJsonSchema.IArray {
13
- $id?: string;
14
- $recursiveAnchor?: true;
15
- }
16
- export interface ITuple extends IJsonSchema.ITuple {
17
- $id?: string;
18
- $recursiveAnchor?: true;
19
- }
20
- export interface IObject {
21
- $id?: string;
22
- $recursiveAnchor?: boolean;
23
- type: "object";
24
-
25
- /**
26
- * Only when swagger mode.
27
- */
28
- nullable?: boolean;
29
-
30
- properties: Record<string, IJsonSchema>;
31
- patternProperties?: Record<string, IJsonSchema>;
32
- additionalProperties?: IJsonSchema;
33
-
34
- required?: string[];
35
- description?: string;
36
- "x-typia-jsDocTags"?: IJsDocTagInfo[];
37
- "x-typia-patternProperties"?: Record<string, IJsonSchema>;
38
- "x-typia-additionalProperties"?: IJsonSchema;
39
- }
40
-
41
- export type IAlias = IJsonSchema & {
42
- $id?: string;
43
- $recursiveAnchor?: boolean;
44
- };
45
- }
1
+ import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
2
+
3
+ import { IJsonSchema } from "./IJsonSchema";
4
+
5
+ export interface IJsonComponents {
6
+ schemas?: Record<string, IJsonComponents.IObject | IJsonComponents.IAlias>;
7
+ }
8
+ export namespace IJsonComponents {
9
+ export interface IObject {
10
+ $id?: string;
11
+ $recursiveAnchor?: boolean;
12
+ type: "object";
13
+
14
+ /**
15
+ * Only when swagger mode.
16
+ */
17
+ nullable?: boolean;
18
+
19
+ properties: Record<string, IJsonSchema>;
20
+ patternProperties?: Record<string, IJsonSchema>;
21
+ additionalProperties?: IJsonSchema;
22
+
23
+ required?: string[];
24
+ description?: string;
25
+ "x-typia-jsDocTags"?: IJsDocTagInfo[];
26
+ "x-typia-patternProperties"?: Record<string, IJsonSchema>;
27
+ "x-typia-additionalProperties"?: IJsonSchema;
28
+ }
29
+
30
+ export type IAlias = IJsonSchema & {
31
+ $id?: string;
32
+ $recursiveAnchor?: boolean;
33
+ };
34
+ }
@@ -1,134 +1,134 @@
1
- import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
2
- import { IMetadataTag } from "../metadata/IMetadataTag";
3
-
4
- import { Atomic } from "../typings/Atomic";
5
-
6
- export type IJsonSchema = IJsonSchema.Known | IJsonSchema.IUnknown;
7
- export namespace IJsonSchema {
8
- export type Known =
9
- | IEnumeration<"boolean">
10
- | IEnumeration<"number">
11
- | IEnumeration<"string">
12
- | IBoolean
13
- | IInteger
14
- | INumber
15
- | IString
16
- | IArray
17
- | ITuple
18
- | IOneOf
19
- | IReference
20
- | IRecursiveReference
21
- | INullOnly;
22
-
23
- export interface IUnknown extends IAttribute {
24
- type?: undefined;
25
- }
26
-
27
- /**
28
- * @deprecated Use {@link Known} type instead.
29
- */
30
- export type NotUnknown = Known;
31
-
32
- /* -----------------------------------------------------------
33
- ATOMICS
34
- ----------------------------------------------------------- */
35
- export interface IEnumeration<
36
- Literal extends Exclude<Atomic.Literal, "bigint">,
37
- > extends IAtomic<Literal> {
38
- enum: Array<Atomic.Mapper[Literal]>;
39
- }
40
- export interface IAtomic<Literal extends Exclude<Atomic.Literal, "bigint">>
41
- extends ISignificant<Literal> {
42
- default?: Atomic.Mapper[Literal];
43
- }
44
- export interface IString extends IAtomic<"string"> {
45
- /**
46
- * @type uint
47
- */
48
- minLength?: number;
49
- /**
50
- * @type uint
51
- */
52
- maxLength?: number;
53
- pattern?: string;
54
- format?: string;
55
- }
56
- export interface INumber extends IAtomic<"number"> {
57
- minimum?: number;
58
- maximum?: number;
59
- exclusiveMinimum?: boolean;
60
- exclusiveMaximum?: boolean;
61
- multipleOf?: number;
62
- }
63
- export interface IInteger extends IAtomic<"integer"> {
64
- /**
65
- * @type int
66
- */
67
- minimum?: number;
68
- /**
69
- * @type int
70
- */
71
- maximum?: number;
72
- exclusiveMinimum?: boolean;
73
- exclusiveMaximum?: boolean;
74
- /**
75
- * @type int
76
- */
77
- multipleOf?: number;
78
- }
79
- export interface IBoolean extends IAtomic<"boolean"> {}
80
-
81
- /* -----------------------------------------------------------
82
- OBJECTS
83
- ----------------------------------------------------------- */
84
- export interface IArray extends ISignificant<"array"> {
85
- items: IJsonSchema;
86
- /**
87
- * @type uint
88
- */
89
- minItems?: number;
90
- /**
91
- * @type uint
92
- */
93
- maxItems?: number;
94
- "x-typia-tuple"?: ITuple;
95
- }
96
- export interface ITuple extends ISignificant<"array"> {
97
- items: IJsonSchema[];
98
- "x-typia-rest": boolean;
99
- }
100
- export interface IReference extends IAttribute {
101
- $ref: string;
102
- }
103
- export interface IRecursiveReference extends IAttribute {
104
- $recursiveRef: string;
105
- }
106
- export interface INullOnly extends IAttribute {
107
- type: "null";
108
- }
109
-
110
- /* -----------------------------------------------------------
111
- MISCELLANEOUS
112
- ----------------------------------------------------------- */
113
- export interface IOneOf extends IAttribute {
114
- oneOf: IJsonSchema[];
115
- }
116
-
117
- export interface ISignificant<Literal extends string> extends IAttribute {
118
- type: Literal;
119
-
120
- /**
121
- * Only when swagger mode.
122
- */
123
- nullable?: boolean;
124
- }
125
- export interface IAttribute {
126
- deprecated?: boolean;
127
- title?: string;
128
- description?: string;
129
- "x-typia-metaTags"?: IMetadataTag[];
130
- "x-typia-jsDocTags"?: IJsDocTagInfo[];
131
- "x-typia-required"?: boolean;
132
- "x-typia-optional"?: boolean;
133
- }
134
- }
1
+ import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
2
+ import { IMetadataTag } from "../metadata/IMetadataTag";
3
+
4
+ import { Atomic } from "../typings/Atomic";
5
+
6
+ export type IJsonSchema = IJsonSchema.Known | IJsonSchema.IUnknown;
7
+ export namespace IJsonSchema {
8
+ export type Known =
9
+ | IEnumeration<"boolean">
10
+ | IEnumeration<"number">
11
+ | IEnumeration<"string">
12
+ | IBoolean
13
+ | IInteger
14
+ | INumber
15
+ | IString
16
+ | IArray
17
+ | ITuple
18
+ | IOneOf
19
+ | IReference
20
+ | IRecursiveReference
21
+ | INullOnly;
22
+
23
+ export interface IUnknown extends IAttribute {
24
+ type?: undefined;
25
+ }
26
+
27
+ /**
28
+ * @deprecated Use {@link Known} type instead.
29
+ */
30
+ export type NotUnknown = Known;
31
+
32
+ /* -----------------------------------------------------------
33
+ ATOMICS
34
+ ----------------------------------------------------------- */
35
+ export interface IEnumeration<
36
+ Literal extends Exclude<Atomic.Literal, "bigint">,
37
+ > extends IAtomic<Literal> {
38
+ enum: Array<Atomic.Mapper[Literal]>;
39
+ }
40
+ export interface IAtomic<Literal extends Exclude<Atomic.Literal, "bigint">>
41
+ extends ISignificant<Literal> {
42
+ default?: Atomic.Mapper[Literal];
43
+ }
44
+ export interface IString extends IAtomic<"string"> {
45
+ /**
46
+ * @type uint
47
+ */
48
+ minLength?: number;
49
+ /**
50
+ * @type uint
51
+ */
52
+ maxLength?: number;
53
+ pattern?: string;
54
+ format?: string;
55
+ }
56
+ export interface INumber extends IAtomic<"number"> {
57
+ minimum?: number;
58
+ maximum?: number;
59
+ exclusiveMinimum?: boolean;
60
+ exclusiveMaximum?: boolean;
61
+ multipleOf?: number;
62
+ }
63
+ export interface IInteger extends IAtomic<"integer"> {
64
+ /**
65
+ * @type int
66
+ */
67
+ minimum?: number;
68
+ /**
69
+ * @type int
70
+ */
71
+ maximum?: number;
72
+ exclusiveMinimum?: boolean;
73
+ exclusiveMaximum?: boolean;
74
+ /**
75
+ * @type int
76
+ */
77
+ multipleOf?: number;
78
+ }
79
+ export interface IBoolean extends IAtomic<"boolean"> {}
80
+
81
+ /* -----------------------------------------------------------
82
+ OBJECTS
83
+ ----------------------------------------------------------- */
84
+ export interface IArray extends ISignificant<"array"> {
85
+ items: IJsonSchema;
86
+ /**
87
+ * @type uint
88
+ */
89
+ minItems?: number;
90
+ /**
91
+ * @type uint
92
+ */
93
+ maxItems?: number;
94
+ "x-typia-tuple"?: ITuple;
95
+ }
96
+ export interface ITuple extends ISignificant<"array"> {
97
+ items: IJsonSchema[];
98
+ }
99
+ export interface IReference extends IAttribute {
100
+ $ref: string;
101
+ }
102
+ export interface IRecursiveReference extends IAttribute {
103
+ $recursiveRef: string;
104
+ }
105
+ export interface INullOnly extends IAttribute {
106
+ type: "null";
107
+ }
108
+
109
+ /* -----------------------------------------------------------
110
+ MISCELLANEOUS
111
+ ----------------------------------------------------------- */
112
+ export interface IOneOf extends IAttribute {
113
+ oneOf: IJsonSchema[];
114
+ }
115
+
116
+ export interface ISignificant<Literal extends string> extends IAttribute {
117
+ type: Literal;
118
+
119
+ /**
120
+ * Only when swagger mode.
121
+ */
122
+ nullable?: boolean;
123
+ }
124
+ export interface IAttribute {
125
+ deprecated?: boolean;
126
+ title?: string;
127
+ description?: string;
128
+ "x-typia-metaTags"?: IMetadataTag[];
129
+ "x-typia-jsDocTags"?: IJsDocTagInfo[];
130
+ "x-typia-required"?: boolean;
131
+ "x-typia-optional"?: boolean;
132
+ "x-typia-rest"?: boolean;
133
+ }
134
+ }