typia 4.1.0 → 4.1.1-dev.20230621
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.
- package/lib/factories/internal/metadata/iterate_metadata_array.js +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_array.js.map +1 -1
- package/lib/module.d.ts +2 -2
- package/package.json +3 -2
- package/src/factories/CommentFactory.ts +64 -64
- package/src/factories/IdentifierFactory.ts +59 -59
- package/src/factories/MetadataFactory.ts +30 -30
- package/src/factories/internal/metadata/iterate_metadata_array.ts +1 -2
- package/src/metadata/MetadataObject.ts +118 -118
- package/src/module.ts +2038 -2038
- package/src/programmers/ApplicationProgrammer.ts +47 -47
- package/src/programmers/AssertCloneProgrammer.ts +71 -71
- package/src/programmers/AssertParseProgrammer.ts +66 -66
- package/src/programmers/AssertProgrammer.ts +279 -279
- package/src/programmers/AssertPruneProgrammer.ts +68 -68
- package/src/programmers/AssertStringifyProgrammer.ts +66 -66
- package/src/programmers/CloneProgrammer.ts +587 -587
- package/src/programmers/IsCloneProgrammer.ts +78 -78
- package/src/programmers/IsParseProgrammer.ts +72 -72
- package/src/programmers/IsProgrammer.ts +239 -239
- package/src/programmers/IsPruneProgrammer.ts +73 -73
- package/src/programmers/IsStringifyProgrammer.ts +76 -76
- package/src/programmers/LiteralsProgrammer.ts +60 -60
- package/src/programmers/PruneProgrammer.ts +542 -542
- package/src/programmers/RandomProgrammer.ts +581 -581
- package/src/programmers/StringifyProgrammer.ts +978 -978
- package/src/programmers/ValidateCloneProgrammer.ts +85 -85
- package/src/programmers/ValidateParseProgrammer.ts +70 -70
- package/src/programmers/ValidateProgrammer.ts +305 -305
- package/src/programmers/ValidatePruneProgrammer.ts +78 -78
- package/src/programmers/ValidateStringifyProgrammer.ts +84 -84
- package/src/programmers/internal/application_tuple.ts +57 -57
- package/src/programmers/internal/feature_object_entries.ts +63 -63
- package/src/schemas/IJsonSchema.ts +133 -133
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { Metadata } from "../metadata/Metadata";
|
|
2
|
-
import { IJsonApplication } from "../schemas/IJsonApplication";
|
|
3
|
-
import { IJsonComponents } from "../schemas/IJsonComponents";
|
|
4
|
-
import { IJsonSchema } from "../schemas/IJsonSchema";
|
|
5
|
-
|
|
6
|
-
import { application_schema } from "./internal/application_schema";
|
|
7
|
-
|
|
8
|
-
export namespace ApplicationProgrammer {
|
|
9
|
-
export interface IOptions {
|
|
10
|
-
purpose: "ajv" | "swagger";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export namespace IOptions {
|
|
17
|
-
export const complement = (options?: Partial<IOptions>): IOptions => {
|
|
18
|
-
const purpose: "swagger" | "ajv" = options?.purpose ?? "swagger";
|
|
19
|
-
return {
|
|
20
|
-
purpose,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const write =
|
|
26
|
-
(options?: Partial<IOptions>) =>
|
|
27
|
-
(metadatas: Array<Metadata>): IJsonApplication => {
|
|
28
|
-
const fullOptions: IOptions = IOptions.complement(options);
|
|
29
|
-
const components: IJsonComponents = {
|
|
30
|
-
schemas: {},
|
|
31
|
-
};
|
|
32
|
-
const generator = application_schema(fullOptions)(true)(components);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
schemas: metadatas.map((meta, i) => {
|
|
36
|
-
const schema: IJsonSchema | null = generator(meta)({});
|
|
37
|
-
if (schema === null)
|
|
38
|
-
throw new Error(
|
|
39
|
-
`Error on typia.application(): invalid type on argument - (${meta.getName()}, ${i})`,
|
|
40
|
-
);
|
|
41
|
-
return schema;
|
|
42
|
-
}),
|
|
43
|
-
components,
|
|
44
|
-
...fullOptions,
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
}
|
|
1
|
+
import { Metadata } from "../metadata/Metadata";
|
|
2
|
+
import { IJsonApplication } from "../schemas/IJsonApplication";
|
|
3
|
+
import { IJsonComponents } from "../schemas/IJsonComponents";
|
|
4
|
+
import { IJsonSchema } from "../schemas/IJsonSchema";
|
|
5
|
+
|
|
6
|
+
import { application_schema } from "./internal/application_schema";
|
|
7
|
+
|
|
8
|
+
export namespace ApplicationProgrammer {
|
|
9
|
+
export interface IOptions {
|
|
10
|
+
purpose: "ajv" | "swagger";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export namespace IOptions {
|
|
17
|
+
export const complement = (options?: Partial<IOptions>): IOptions => {
|
|
18
|
+
const purpose: "swagger" | "ajv" = options?.purpose ?? "swagger";
|
|
19
|
+
return {
|
|
20
|
+
purpose,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const write =
|
|
26
|
+
(options?: Partial<IOptions>) =>
|
|
27
|
+
(metadatas: Array<Metadata>): IJsonApplication => {
|
|
28
|
+
const fullOptions: IOptions = IOptions.complement(options);
|
|
29
|
+
const components: IJsonComponents = {
|
|
30
|
+
schemas: {},
|
|
31
|
+
};
|
|
32
|
+
const generator = application_schema(fullOptions)(true)(components);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
schemas: metadatas.map((meta, i) => {
|
|
36
|
+
const schema: IJsonSchema | null = generator(meta)({});
|
|
37
|
+
if (schema === null)
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Error on typia.application(): invalid type on argument - (${meta.getName()}, ${i})`,
|
|
40
|
+
);
|
|
41
|
+
return schema;
|
|
42
|
+
}),
|
|
43
|
+
components,
|
|
44
|
+
...fullOptions,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { IdentifierFactory } from "../factories/IdentifierFactory";
|
|
4
|
-
import { StatementFactory } from "../factories/StatementFactory";
|
|
5
|
-
import { TypeFactory } from "../factories/TypeFactory";
|
|
6
|
-
|
|
7
|
-
import { IProject } from "../transformers/IProject";
|
|
8
|
-
|
|
9
|
-
import { AssertProgrammer } from "./AssertProgrammer";
|
|
10
|
-
import { CloneProgrammer } from "./CloneProgrammer";
|
|
11
|
-
|
|
12
|
-
export namespace AssertCloneProgrammer {
|
|
13
|
-
export const write =
|
|
14
|
-
(project: IProject) =>
|
|
15
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
16
|
-
(type: ts.Type, name?: string) =>
|
|
17
|
-
ts.factory.createArrowFunction(
|
|
18
|
-
undefined,
|
|
19
|
-
undefined,
|
|
20
|
-
[
|
|
21
|
-
IdentifierFactory.parameter(
|
|
22
|
-
"input",
|
|
23
|
-
TypeFactory.keyword("any"),
|
|
24
|
-
),
|
|
25
|
-
],
|
|
26
|
-
ts.factory.createTypeReferenceNode(
|
|
27
|
-
`typia.Primitive<${
|
|
28
|
-
name ?? TypeFactory.getFullName(project.checker)(type)
|
|
29
|
-
}>`,
|
|
30
|
-
),
|
|
31
|
-
undefined,
|
|
32
|
-
ts.factory.createBlock([
|
|
33
|
-
StatementFactory.constant(
|
|
34
|
-
"assert",
|
|
35
|
-
AssertProgrammer.write(project)(modulo)(false)(
|
|
36
|
-
type,
|
|
37
|
-
name,
|
|
38
|
-
),
|
|
39
|
-
),
|
|
40
|
-
StatementFactory.constant(
|
|
41
|
-
"clone",
|
|
42
|
-
CloneProgrammer.write({
|
|
43
|
-
...project,
|
|
44
|
-
options: {
|
|
45
|
-
...project.options,
|
|
46
|
-
functional: false,
|
|
47
|
-
numeric: false,
|
|
48
|
-
},
|
|
49
|
-
})(modulo)(type, name),
|
|
50
|
-
),
|
|
51
|
-
ts.factory.createExpressionStatement(
|
|
52
|
-
ts.factory.createCallExpression(
|
|
53
|
-
ts.factory.createIdentifier("assert"),
|
|
54
|
-
undefined,
|
|
55
|
-
[ts.factory.createIdentifier("input")],
|
|
56
|
-
),
|
|
57
|
-
),
|
|
58
|
-
StatementFactory.constant(
|
|
59
|
-
"output",
|
|
60
|
-
ts.factory.createCallExpression(
|
|
61
|
-
ts.factory.createIdentifier("clone"),
|
|
62
|
-
undefined,
|
|
63
|
-
[ts.factory.createIdentifier("input")],
|
|
64
|
-
),
|
|
65
|
-
),
|
|
66
|
-
ts.factory.createReturnStatement(
|
|
67
|
-
ts.factory.createIdentifier("output"),
|
|
68
|
-
),
|
|
69
|
-
]),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IdentifierFactory } from "../factories/IdentifierFactory";
|
|
4
|
+
import { StatementFactory } from "../factories/StatementFactory";
|
|
5
|
+
import { TypeFactory } from "../factories/TypeFactory";
|
|
6
|
+
|
|
7
|
+
import { IProject } from "../transformers/IProject";
|
|
8
|
+
|
|
9
|
+
import { AssertProgrammer } from "./AssertProgrammer";
|
|
10
|
+
import { CloneProgrammer } from "./CloneProgrammer";
|
|
11
|
+
|
|
12
|
+
export namespace AssertCloneProgrammer {
|
|
13
|
+
export const write =
|
|
14
|
+
(project: IProject) =>
|
|
15
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
16
|
+
(type: ts.Type, name?: string) =>
|
|
17
|
+
ts.factory.createArrowFunction(
|
|
18
|
+
undefined,
|
|
19
|
+
undefined,
|
|
20
|
+
[
|
|
21
|
+
IdentifierFactory.parameter(
|
|
22
|
+
"input",
|
|
23
|
+
TypeFactory.keyword("any"),
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
ts.factory.createTypeReferenceNode(
|
|
27
|
+
`typia.Primitive<${
|
|
28
|
+
name ?? TypeFactory.getFullName(project.checker)(type)
|
|
29
|
+
}>`,
|
|
30
|
+
),
|
|
31
|
+
undefined,
|
|
32
|
+
ts.factory.createBlock([
|
|
33
|
+
StatementFactory.constant(
|
|
34
|
+
"assert",
|
|
35
|
+
AssertProgrammer.write(project)(modulo)(false)(
|
|
36
|
+
type,
|
|
37
|
+
name,
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
StatementFactory.constant(
|
|
41
|
+
"clone",
|
|
42
|
+
CloneProgrammer.write({
|
|
43
|
+
...project,
|
|
44
|
+
options: {
|
|
45
|
+
...project.options,
|
|
46
|
+
functional: false,
|
|
47
|
+
numeric: false,
|
|
48
|
+
},
|
|
49
|
+
})(modulo)(type, name),
|
|
50
|
+
),
|
|
51
|
+
ts.factory.createExpressionStatement(
|
|
52
|
+
ts.factory.createCallExpression(
|
|
53
|
+
ts.factory.createIdentifier("assert"),
|
|
54
|
+
undefined,
|
|
55
|
+
[ts.factory.createIdentifier("input")],
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
StatementFactory.constant(
|
|
59
|
+
"output",
|
|
60
|
+
ts.factory.createCallExpression(
|
|
61
|
+
ts.factory.createIdentifier("clone"),
|
|
62
|
+
undefined,
|
|
63
|
+
[ts.factory.createIdentifier("input")],
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
ts.factory.createReturnStatement(
|
|
67
|
+
ts.factory.createIdentifier("output"),
|
|
68
|
+
),
|
|
69
|
+
]),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { IdentifierFactory } from "../factories/IdentifierFactory";
|
|
4
|
-
import { StatementFactory } from "../factories/StatementFactory";
|
|
5
|
-
import { TypeFactory } from "../factories/TypeFactory";
|
|
6
|
-
|
|
7
|
-
import { IProject } from "../transformers/IProject";
|
|
8
|
-
|
|
9
|
-
import { AssertProgrammer } from "./AssertProgrammer";
|
|
10
|
-
|
|
11
|
-
export namespace AssertParseProgrammer {
|
|
12
|
-
export const write =
|
|
13
|
-
(project: IProject) =>
|
|
14
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
15
|
-
(type: ts.Type, name?: string) =>
|
|
16
|
-
ts.factory.createArrowFunction(
|
|
17
|
-
undefined,
|
|
18
|
-
undefined,
|
|
19
|
-
[
|
|
20
|
-
IdentifierFactory.parameter(
|
|
21
|
-
"input",
|
|
22
|
-
TypeFactory.keyword("string"),
|
|
23
|
-
),
|
|
24
|
-
],
|
|
25
|
-
ts.factory.createTypeReferenceNode(
|
|
26
|
-
`typia.Primitive<${
|
|
27
|
-
name ?? TypeFactory.getFullName(project.checker)(type)
|
|
28
|
-
}>`,
|
|
29
|
-
),
|
|
30
|
-
undefined,
|
|
31
|
-
ts.factory.createBlock([
|
|
32
|
-
StatementFactory.constant(
|
|
33
|
-
"assert",
|
|
34
|
-
AssertProgrammer.write({
|
|
35
|
-
...project,
|
|
36
|
-
options: {
|
|
37
|
-
...project.options,
|
|
38
|
-
functional: false,
|
|
39
|
-
numeric: false,
|
|
40
|
-
},
|
|
41
|
-
})(modulo)(false)(type, name),
|
|
42
|
-
),
|
|
43
|
-
ts.factory.createExpressionStatement(
|
|
44
|
-
ts.factory.createBinaryExpression(
|
|
45
|
-
ts.factory.createIdentifier("input"),
|
|
46
|
-
ts.SyntaxKind.EqualsToken,
|
|
47
|
-
ts.factory.createCallExpression(
|
|
48
|
-
ts.factory.createIdentifier("JSON.parse"),
|
|
49
|
-
undefined,
|
|
50
|
-
[ts.factory.createIdentifier("input")],
|
|
51
|
-
),
|
|
52
|
-
),
|
|
53
|
-
),
|
|
54
|
-
ts.factory.createReturnStatement(
|
|
55
|
-
ts.factory.createAsExpression(
|
|
56
|
-
ts.factory.createCallExpression(
|
|
57
|
-
ts.factory.createIdentifier("assert"),
|
|
58
|
-
undefined,
|
|
59
|
-
[ts.factory.createIdentifier("input")],
|
|
60
|
-
),
|
|
61
|
-
ts.factory.createTypeReferenceNode("any"),
|
|
62
|
-
),
|
|
63
|
-
),
|
|
64
|
-
]),
|
|
65
|
-
);
|
|
66
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IdentifierFactory } from "../factories/IdentifierFactory";
|
|
4
|
+
import { StatementFactory } from "../factories/StatementFactory";
|
|
5
|
+
import { TypeFactory } from "../factories/TypeFactory";
|
|
6
|
+
|
|
7
|
+
import { IProject } from "../transformers/IProject";
|
|
8
|
+
|
|
9
|
+
import { AssertProgrammer } from "./AssertProgrammer";
|
|
10
|
+
|
|
11
|
+
export namespace AssertParseProgrammer {
|
|
12
|
+
export const write =
|
|
13
|
+
(project: IProject) =>
|
|
14
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
15
|
+
(type: ts.Type, name?: string) =>
|
|
16
|
+
ts.factory.createArrowFunction(
|
|
17
|
+
undefined,
|
|
18
|
+
undefined,
|
|
19
|
+
[
|
|
20
|
+
IdentifierFactory.parameter(
|
|
21
|
+
"input",
|
|
22
|
+
TypeFactory.keyword("string"),
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
ts.factory.createTypeReferenceNode(
|
|
26
|
+
`typia.Primitive<${
|
|
27
|
+
name ?? TypeFactory.getFullName(project.checker)(type)
|
|
28
|
+
}>`,
|
|
29
|
+
),
|
|
30
|
+
undefined,
|
|
31
|
+
ts.factory.createBlock([
|
|
32
|
+
StatementFactory.constant(
|
|
33
|
+
"assert",
|
|
34
|
+
AssertProgrammer.write({
|
|
35
|
+
...project,
|
|
36
|
+
options: {
|
|
37
|
+
...project.options,
|
|
38
|
+
functional: false,
|
|
39
|
+
numeric: false,
|
|
40
|
+
},
|
|
41
|
+
})(modulo)(false)(type, name),
|
|
42
|
+
),
|
|
43
|
+
ts.factory.createExpressionStatement(
|
|
44
|
+
ts.factory.createBinaryExpression(
|
|
45
|
+
ts.factory.createIdentifier("input"),
|
|
46
|
+
ts.SyntaxKind.EqualsToken,
|
|
47
|
+
ts.factory.createCallExpression(
|
|
48
|
+
ts.factory.createIdentifier("JSON.parse"),
|
|
49
|
+
undefined,
|
|
50
|
+
[ts.factory.createIdentifier("input")],
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
),
|
|
54
|
+
ts.factory.createReturnStatement(
|
|
55
|
+
ts.factory.createAsExpression(
|
|
56
|
+
ts.factory.createCallExpression(
|
|
57
|
+
ts.factory.createIdentifier("assert"),
|
|
58
|
+
undefined,
|
|
59
|
+
[ts.factory.createIdentifier("input")],
|
|
60
|
+
),
|
|
61
|
+
ts.factory.createTypeReferenceNode("any"),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
]),
|
|
65
|
+
);
|
|
66
|
+
}
|