@typia/transform 12.0.0-dev.20260309 → 12.0.0-dev.20260311
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/package.json +4 -4
- package/src/CallExpressionTransformer.ts +579 -579
- package/src/FileTransformer.ts +143 -143
- package/src/ITransformProps.ts +20 -20
- package/src/ImportTransformer.ts +262 -262
- package/src/NodeTransformer.ts +25 -25
- package/src/TransformerError.ts +85 -85
- package/src/TypiaGenerator.ts +172 -172
- package/src/features/AssertTransformer.ts +24 -24
- package/src/features/CreateAssertTransformer.ts +24 -24
- package/src/features/CreateIsTransformer.ts +18 -18
- package/src/features/CreateRandomTransformer.ts +42 -42
- package/src/features/CreateValidateTransformer.ts +18 -18
- package/src/features/IsTransformer.ts +18 -18
- package/src/features/RandomTransformer.ts +40 -40
- package/src/features/ValidateTransformer.ts +18 -18
- package/src/features/functional/FunctionalGenericTransformer.ts +55 -55
- package/src/features/http/CreateHttpAssertFormDataTransformer.ts +13 -13
- package/src/features/http/CreateHttpAssertHeadersTransformer.ts +13 -13
- package/src/features/http/CreateHttpAssertQueryTransformer.ts +13 -13
- package/src/features/http/CreateHttpFormDataTransformer.ts +13 -13
- package/src/features/http/CreateHttpHeadersTransformer.ts +13 -13
- package/src/features/http/CreateHttpIsFormDataTransformer.ts +13 -13
- package/src/features/http/CreateHttpIsHeadersTransformer.ts +13 -13
- package/src/features/http/CreateHttpIsQueryTransformer.ts +13 -13
- package/src/features/http/CreateHttpParameterTransformer.ts +13 -13
- package/src/features/http/CreateHttpQueryTransformer.ts +13 -13
- package/src/features/http/CreateHttpValidateFormDataTransformer.ts +13 -13
- package/src/features/http/CreateHttpValidateHeadersTransformer.ts +13 -13
- package/src/features/http/CreateHttpValidateQueryTransformer.ts +13 -13
- package/src/features/http/HttpAssertFormDataTransformer.ts +13 -13
- package/src/features/http/HttpAssertHeadersTransformer.ts +13 -13
- package/src/features/http/HttpAssertQueryTransformer.ts +13 -13
- package/src/features/http/HttpFormDataTransformer.ts +13 -13
- package/src/features/http/HttpHeadersTransformer.ts +13 -13
- package/src/features/http/HttpIsFormDataTransformer.ts +13 -13
- package/src/features/http/HttpIsHeadersTransformer.ts +13 -13
- package/src/features/http/HttpIsQueryTransformer.ts +13 -13
- package/src/features/http/HttpParameterTransformer.ts +13 -13
- package/src/features/http/HttpQueryTransformer.ts +13 -13
- package/src/features/http/HttpValidateFormDataTransformer.ts +13 -13
- package/src/features/http/HttpValidateHeadersTransformer.ts +13 -13
- package/src/features/http/HttpValidateQueryTransformer.ts +13 -13
- package/src/features/json/JsonApplicationTransformer.ts +99 -99
- package/src/features/json/JsonAssertParseTransformer.ts +13 -13
- package/src/features/json/JsonAssertStringifyTransformer.ts +13 -13
- package/src/features/json/JsonCreateAssertParseTransformer.ts +13 -13
- package/src/features/json/JsonCreateAssertStringifyTransformer.ts +13 -13
- package/src/features/json/JsonCreateIsParseTransformer.ts +13 -13
- package/src/features/json/JsonCreateIsStringifyTransformer.ts +13 -13
- package/src/features/json/JsonCreateStringifyTransformer.ts +13 -13
- package/src/features/json/JsonCreateValidateParseTransformer.ts +13 -13
- package/src/features/json/JsonCreateValidateStringifyProgrammer.ts +13 -13
- package/src/features/json/JsonIsParseTransformer.ts +13 -13
- package/src/features/json/JsonIsStringifyTransformer.ts +13 -13
- package/src/features/json/JsonSchemaTransformer.ts +120 -120
- package/src/features/json/JsonSchemasTransformer.ts +130 -130
- package/src/features/json/JsonStringifyTransformer.ts +13 -13
- package/src/features/json/JsonValidateParseTransformer.ts +13 -13
- package/src/features/json/JsonValidateStringifyTransformer.ts +13 -13
- package/src/features/llm/LlmApplicationTransformer.ts +224 -224
- package/src/features/llm/LlmCoerceTransformer.ts +95 -95
- package/src/features/llm/LlmControllerTransformer.ts +81 -81
- package/src/features/llm/LlmCreateCoerceTransformer.ts +84 -84
- package/src/features/llm/LlmCreateParseTransformer.ts +84 -84
- package/src/features/llm/LlmParametersTransformer.ts +76 -76
- package/src/features/llm/LlmParseTransformer.ts +95 -95
- package/src/features/llm/LlmSchemaTransformer.ts +87 -87
- package/src/features/misc/MiscAssertCloneTransformer.ts +13 -13
- package/src/features/misc/MiscAssertPruneTransformer.ts +13 -13
- package/src/features/misc/MiscCloneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateAssertCloneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateAssertPruneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateCloneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateIsCloneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateIsPruneTransformer.ts +13 -13
- package/src/features/misc/MiscCreatePruneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateValidateCloneTransformer.ts +13 -13
- package/src/features/misc/MiscCreateValidatePruneTransformer.ts +13 -13
- package/src/features/misc/MiscIsCloneTransformer.ts +13 -13
- package/src/features/misc/MiscIsPruneTransformer.ts +13 -13
- package/src/features/misc/MiscLiteralsTransformer.ts +34 -34
- package/src/features/misc/MiscPruneTransformer.ts +13 -13
- package/src/features/misc/MiscValidateCloneTransformer.ts +13 -13
- package/src/features/misc/MiscValidatePruneTransformer.ts +13 -13
- package/src/features/notations/NotationAssertGeneralTransformer.ts +19 -19
- package/src/features/notations/NotationCreateAssertGeneralTransformer.ts +19 -19
- package/src/features/notations/NotationCreateGeneralTransformer.ts +19 -19
- package/src/features/notations/NotationCreateIsGeneralTransformer.ts +19 -19
- package/src/features/notations/NotationCreateValidateGeneralTransformer.ts +19 -19
- package/src/features/notations/NotationGeneralTransformer.ts +18 -18
- package/src/features/notations/NotationIsGeneralTransformer.ts +19 -19
- package/src/features/notations/NotationValidateGeneralTransformer.ts +19 -19
- package/src/features/protobuf/ProtobufAssertDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufAssertEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateAssertDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateAssertEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateIsDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateIsEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateValidateDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufCreateValidateEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufIsDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufIsEncodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufMessageTransformer.ts +34 -34
- package/src/features/protobuf/ProtobufValidateDecodeTransformer.ts +13 -13
- package/src/features/protobuf/ProtobufValidateEncodeTransformer.ts +13 -13
- package/src/features/reflect/ReflectMetadataTransformer.ts +69 -69
- package/src/features/reflect/ReflectNameTransformer.ts +81 -81
- package/src/features/reflect/ReflectSchemaTransformer.ts +65 -65
- package/src/features/reflect/ReflectSchemasTransformer.ts +69 -69
- package/src/index.ts +7 -7
- package/src/internal/GenericTransformer.ts +101 -101
- package/src/transform.ts +68 -68
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { RandomProgrammer } from "@typia/core";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { ITransformProps } from "../ITransformProps";
|
|
5
|
-
import { TransformerError } from "../TransformerError";
|
|
6
|
-
|
|
7
|
-
export namespace CreateRandomTransformer {
|
|
8
|
-
export const transform = (props: ITransformProps): ts.Expression => {
|
|
9
|
-
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
10
|
-
if (!props.expression.typeArguments?.[0])
|
|
11
|
-
throw new TransformerError({
|
|
12
|
-
code: "typia.createRandom",
|
|
13
|
-
message: "generic argument is not specified.",
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// GET TYPE INFO
|
|
17
|
-
const node: ts.TypeNode = props.expression.typeArguments[0];
|
|
18
|
-
const type: ts.Type = props.context.checker.getTypeFromTypeNode(node);
|
|
19
|
-
|
|
20
|
-
if (type.isTypeParameter())
|
|
21
|
-
throw new TransformerError({
|
|
22
|
-
code: "typia.createRandom",
|
|
23
|
-
message: "non-specified generic argument.",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// DO TRANSFORM
|
|
27
|
-
return RandomProgrammer.write({
|
|
28
|
-
context: {
|
|
29
|
-
...props.context,
|
|
30
|
-
options: {
|
|
31
|
-
...props.context.options,
|
|
32
|
-
functional: false,
|
|
33
|
-
numeric: false,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
modulo: props.modulo,
|
|
37
|
-
type,
|
|
38
|
-
name: node.getFullText().trim(),
|
|
39
|
-
init: props.expression.arguments?.[0],
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
}
|
|
1
|
+
import { RandomProgrammer } from "@typia/core";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
import { ITransformProps } from "../ITransformProps";
|
|
5
|
+
import { TransformerError } from "../TransformerError";
|
|
6
|
+
|
|
7
|
+
export namespace CreateRandomTransformer {
|
|
8
|
+
export const transform = (props: ITransformProps): ts.Expression => {
|
|
9
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
10
|
+
if (!props.expression.typeArguments?.[0])
|
|
11
|
+
throw new TransformerError({
|
|
12
|
+
code: "typia.createRandom",
|
|
13
|
+
message: "generic argument is not specified.",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const node: ts.TypeNode = props.expression.typeArguments[0];
|
|
18
|
+
const type: ts.Type = props.context.checker.getTypeFromTypeNode(node);
|
|
19
|
+
|
|
20
|
+
if (type.isTypeParameter())
|
|
21
|
+
throw new TransformerError({
|
|
22
|
+
code: "typia.createRandom",
|
|
23
|
+
message: "non-specified generic argument.",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return RandomProgrammer.write({
|
|
28
|
+
context: {
|
|
29
|
+
...props.context,
|
|
30
|
+
options: {
|
|
31
|
+
...props.context.options,
|
|
32
|
+
functional: false,
|
|
33
|
+
numeric: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
modulo: props.modulo,
|
|
37
|
+
type,
|
|
38
|
+
name: node.getFullText().trim(),
|
|
39
|
+
init: props.expression.arguments?.[0],
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ValidateProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateValidateTransformer {
|
|
7
|
-
export const transform =
|
|
8
|
-
(config: ValidateProgrammer.IConfig) => (props: ITransformProps) =>
|
|
9
|
-
GenericTransformer.factory({
|
|
10
|
-
...props,
|
|
11
|
-
method: config.equals ? "validateEquals" : "validate",
|
|
12
|
-
write: (x) =>
|
|
13
|
-
ValidateProgrammer.write({
|
|
14
|
-
...x,
|
|
15
|
-
config,
|
|
16
|
-
}),
|
|
17
|
-
});
|
|
18
|
-
}
|
|
1
|
+
import { ValidateProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateValidateTransformer {
|
|
7
|
+
export const transform =
|
|
8
|
+
(config: ValidateProgrammer.IConfig) => (props: ITransformProps) =>
|
|
9
|
+
GenericTransformer.factory({
|
|
10
|
+
...props,
|
|
11
|
+
method: config.equals ? "validateEquals" : "validate",
|
|
12
|
+
write: (x) =>
|
|
13
|
+
ValidateProgrammer.write({
|
|
14
|
+
...x,
|
|
15
|
+
config,
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { IsProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace IsTransformer {
|
|
7
|
-
export const transform =
|
|
8
|
-
(config: IsProgrammer.IConfig) => (props: ITransformProps) =>
|
|
9
|
-
GenericTransformer.scalar({
|
|
10
|
-
...props,
|
|
11
|
-
method: config.equals ? "equals" : "is",
|
|
12
|
-
write: (x) =>
|
|
13
|
-
IsProgrammer.write({
|
|
14
|
-
...x,
|
|
15
|
-
config,
|
|
16
|
-
}),
|
|
17
|
-
});
|
|
18
|
-
}
|
|
1
|
+
import { IsProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace IsTransformer {
|
|
7
|
+
export const transform =
|
|
8
|
+
(config: IsProgrammer.IConfig) => (props: ITransformProps) =>
|
|
9
|
+
GenericTransformer.scalar({
|
|
10
|
+
...props,
|
|
11
|
+
method: config.equals ? "equals" : "is",
|
|
12
|
+
write: (x) =>
|
|
13
|
+
IsProgrammer.write({
|
|
14
|
+
...x,
|
|
15
|
+
config,
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { RandomProgrammer } from "@typia/core";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { ITransformProps } from "../ITransformProps";
|
|
5
|
-
import { TransformerError } from "../TransformerError";
|
|
6
|
-
|
|
7
|
-
export namespace RandomTransformer {
|
|
8
|
-
export const transform = (props: ITransformProps): ts.Expression => {
|
|
9
|
-
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
10
|
-
if (!props.expression.typeArguments?.[0])
|
|
11
|
-
throw new TransformerError({
|
|
12
|
-
code: `typia.${props.modulo.getText()}`,
|
|
13
|
-
message: "generic argument is not specified.",
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// GET TYPE INFO
|
|
17
|
-
const node: ts.TypeNode = props.expression.typeArguments[0];
|
|
18
|
-
const type: ts.Type = props.context.checker.getTypeFromTypeNode(node);
|
|
19
|
-
|
|
20
|
-
if (type.isTypeParameter())
|
|
21
|
-
throw new TransformerError({
|
|
22
|
-
code: `typia.${props.modulo.getText()}`,
|
|
23
|
-
message: "non-specified generic argument.",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return ts.factory.createCallExpression(
|
|
27
|
-
RandomProgrammer.write({
|
|
28
|
-
context: props.context,
|
|
29
|
-
modulo: props.modulo,
|
|
30
|
-
type,
|
|
31
|
-
name: node.getFullText().trim(),
|
|
32
|
-
init: undefined,
|
|
33
|
-
}),
|
|
34
|
-
undefined,
|
|
35
|
-
props.expression.arguments.length
|
|
36
|
-
? [props.expression.arguments[0]!]
|
|
37
|
-
: undefined,
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
1
|
+
import { RandomProgrammer } from "@typia/core";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
import { ITransformProps } from "../ITransformProps";
|
|
5
|
+
import { TransformerError } from "../TransformerError";
|
|
6
|
+
|
|
7
|
+
export namespace RandomTransformer {
|
|
8
|
+
export const transform = (props: ITransformProps): ts.Expression => {
|
|
9
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
10
|
+
if (!props.expression.typeArguments?.[0])
|
|
11
|
+
throw new TransformerError({
|
|
12
|
+
code: `typia.${props.modulo.getText()}`,
|
|
13
|
+
message: "generic argument is not specified.",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const node: ts.TypeNode = props.expression.typeArguments[0];
|
|
18
|
+
const type: ts.Type = props.context.checker.getTypeFromTypeNode(node);
|
|
19
|
+
|
|
20
|
+
if (type.isTypeParameter())
|
|
21
|
+
throw new TransformerError({
|
|
22
|
+
code: `typia.${props.modulo.getText()}`,
|
|
23
|
+
message: "non-specified generic argument.",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return ts.factory.createCallExpression(
|
|
27
|
+
RandomProgrammer.write({
|
|
28
|
+
context: props.context,
|
|
29
|
+
modulo: props.modulo,
|
|
30
|
+
type,
|
|
31
|
+
name: node.getFullText().trim(),
|
|
32
|
+
init: undefined,
|
|
33
|
+
}),
|
|
34
|
+
undefined,
|
|
35
|
+
props.expression.arguments.length
|
|
36
|
+
? [props.expression.arguments[0]!]
|
|
37
|
+
: undefined,
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ValidateProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace ValidateTransformer {
|
|
7
|
-
export const transform =
|
|
8
|
-
(config: ValidateProgrammer.IConfig) => (props: ITransformProps) =>
|
|
9
|
-
GenericTransformer.scalar({
|
|
10
|
-
...props,
|
|
11
|
-
method: config.equals ? "validateEquals" : "validate",
|
|
12
|
-
write: (x) =>
|
|
13
|
-
ValidateProgrammer.write({
|
|
14
|
-
...x,
|
|
15
|
-
config,
|
|
16
|
-
}),
|
|
17
|
-
});
|
|
18
|
-
}
|
|
1
|
+
import { ValidateProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace ValidateTransformer {
|
|
7
|
+
export const transform =
|
|
8
|
+
(config: ValidateProgrammer.IConfig) => (props: ITransformProps) =>
|
|
9
|
+
GenericTransformer.scalar({
|
|
10
|
+
...props,
|
|
11
|
+
method: config.equals ? "validateEquals" : "validate",
|
|
12
|
+
write: (x) =>
|
|
13
|
+
ValidateProgrammer.write({
|
|
14
|
+
...x,
|
|
15
|
+
config,
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { ITypiaContext, TypeFactory } from "@typia/core";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
5
|
-
import { TransformerError } from "../../TransformerError";
|
|
6
|
-
|
|
7
|
-
export namespace FunctionalGenericTransformer {
|
|
8
|
-
export interface IConfig {
|
|
9
|
-
equals: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface ISpecification {
|
|
12
|
-
method: string;
|
|
13
|
-
config: IConfig;
|
|
14
|
-
programmer: (p: {
|
|
15
|
-
context: ITypiaContext;
|
|
16
|
-
modulo: ts.LeftHandSideExpression;
|
|
17
|
-
expression: ts.Expression;
|
|
18
|
-
declaration: ts.FunctionDeclaration;
|
|
19
|
-
config: IConfig;
|
|
20
|
-
init?: ts.Expression;
|
|
21
|
-
}) => ts.Expression;
|
|
22
|
-
}
|
|
23
|
-
export const transform =
|
|
24
|
-
(spec: ISpecification) =>
|
|
25
|
-
(props: ITransformProps): ts.Expression => {
|
|
26
|
-
// CHECK PARAMETER
|
|
27
|
-
if (props.expression.arguments.length === 0)
|
|
28
|
-
throw new TransformerError({
|
|
29
|
-
code: `typia.functional.${spec.method}`,
|
|
30
|
-
message: `no input value.`,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// GET TYPE INFO
|
|
34
|
-
const type: ts.Type =
|
|
35
|
-
props.expression.typeArguments && props.expression.typeArguments[0]
|
|
36
|
-
? props.context.checker.getTypeFromTypeNode(
|
|
37
|
-
props.expression.typeArguments[0],
|
|
38
|
-
)
|
|
39
|
-
: props.context.checker.getTypeAtLocation(
|
|
40
|
-
props.expression.arguments[0]!,
|
|
41
|
-
);
|
|
42
|
-
if (TypeFactory.isFunction(type) === false)
|
|
43
|
-
throw new TransformerError({
|
|
44
|
-
code: `typia.functional.${spec.method}`,
|
|
45
|
-
message: `input value is not a function.`,
|
|
46
|
-
});
|
|
47
|
-
return spec.programmer({
|
|
48
|
-
...props,
|
|
49
|
-
config: spec.config,
|
|
50
|
-
expression: props.expression.arguments[0] as ts.Expression,
|
|
51
|
-
declaration: type.symbol!.declarations![0] as ts.FunctionDeclaration,
|
|
52
|
-
init: props.expression.arguments[1],
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
}
|
|
1
|
+
import { ITypiaContext, TypeFactory } from "@typia/core";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
5
|
+
import { TransformerError } from "../../TransformerError";
|
|
6
|
+
|
|
7
|
+
export namespace FunctionalGenericTransformer {
|
|
8
|
+
export interface IConfig {
|
|
9
|
+
equals: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ISpecification {
|
|
12
|
+
method: string;
|
|
13
|
+
config: IConfig;
|
|
14
|
+
programmer: (p: {
|
|
15
|
+
context: ITypiaContext;
|
|
16
|
+
modulo: ts.LeftHandSideExpression;
|
|
17
|
+
expression: ts.Expression;
|
|
18
|
+
declaration: ts.FunctionDeclaration;
|
|
19
|
+
config: IConfig;
|
|
20
|
+
init?: ts.Expression;
|
|
21
|
+
}) => ts.Expression;
|
|
22
|
+
}
|
|
23
|
+
export const transform =
|
|
24
|
+
(spec: ISpecification) =>
|
|
25
|
+
(props: ITransformProps): ts.Expression => {
|
|
26
|
+
// CHECK PARAMETER
|
|
27
|
+
if (props.expression.arguments.length === 0)
|
|
28
|
+
throw new TransformerError({
|
|
29
|
+
code: `typia.functional.${spec.method}`,
|
|
30
|
+
message: `no input value.`,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// GET TYPE INFO
|
|
34
|
+
const type: ts.Type =
|
|
35
|
+
props.expression.typeArguments && props.expression.typeArguments[0]
|
|
36
|
+
? props.context.checker.getTypeFromTypeNode(
|
|
37
|
+
props.expression.typeArguments[0],
|
|
38
|
+
)
|
|
39
|
+
: props.context.checker.getTypeAtLocation(
|
|
40
|
+
props.expression.arguments[0]!,
|
|
41
|
+
);
|
|
42
|
+
if (TypeFactory.isFunction(type) === false)
|
|
43
|
+
throw new TransformerError({
|
|
44
|
+
code: `typia.functional.${spec.method}`,
|
|
45
|
+
message: `input value is not a function.`,
|
|
46
|
+
});
|
|
47
|
+
return spec.programmer({
|
|
48
|
+
...props,
|
|
49
|
+
config: spec.config,
|
|
50
|
+
expression: props.expression.arguments[0] as ts.Expression,
|
|
51
|
+
declaration: type.symbol!.declarations![0] as ts.FunctionDeclaration,
|
|
52
|
+
init: props.expression.arguments[1],
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpAssertFormDataProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpAssertFormDataTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createAssertFormData",
|
|
11
|
-
write: HttpAssertFormDataProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpAssertFormDataProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpAssertFormDataTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createAssertFormData",
|
|
11
|
+
write: HttpAssertFormDataProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpAssertHeadersProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpAssertHeadersTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createAssertHeaders",
|
|
11
|
-
write: HttpAssertHeadersProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpAssertHeadersProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpAssertHeadersTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createAssertHeaders",
|
|
11
|
+
write: HttpAssertHeadersProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpAssertQueryProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpAssertQueryTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createAssertQuery",
|
|
11
|
-
write: HttpAssertQueryProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpAssertQueryProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpAssertQueryTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createAssertQuery",
|
|
11
|
+
write: HttpAssertQueryProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpFormDataProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpFormDataTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createFormData",
|
|
11
|
-
write: HttpFormDataProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpFormDataProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpFormDataTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createFormData",
|
|
11
|
+
write: HttpFormDataProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpHeadersProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpHeadersTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createHeaders",
|
|
11
|
-
write: HttpHeadersProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpHeadersProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpHeadersTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createHeaders",
|
|
11
|
+
write: HttpHeadersProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpIsFormDataProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpIsFormDataTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createIsFormData",
|
|
11
|
-
write: HttpIsFormDataProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpIsFormDataProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpIsFormDataTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createIsFormData",
|
|
11
|
+
write: HttpIsFormDataProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpIsHeadersProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpIsHeadersTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createIsHeaders",
|
|
11
|
-
write: HttpIsHeadersProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpIsHeadersProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpIsHeadersTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createIsHeaders",
|
|
11
|
+
write: HttpIsHeadersProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpIsQueryProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpIsQueryTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createIsQuery",
|
|
11
|
-
write: HttpIsQueryProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpIsQueryProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpIsQueryTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createIsQuery",
|
|
11
|
+
write: HttpIsQueryProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { HttpParameterProgrammer } from "@typia/core";
|
|
2
|
-
|
|
3
|
-
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
-
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace CreateHttpParameterTransformer {
|
|
7
|
-
export const transform = (props: ITransformProps) =>
|
|
8
|
-
GenericTransformer.factory({
|
|
9
|
-
...props,
|
|
10
|
-
method: "http.createParameter",
|
|
11
|
-
write: HttpParameterProgrammer.write,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { HttpParameterProgrammer } from "@typia/core";
|
|
2
|
+
|
|
3
|
+
import { ITransformProps } from "../../ITransformProps";
|
|
4
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace CreateHttpParameterTransformer {
|
|
7
|
+
export const transform = (props: ITransformProps) =>
|
|
8
|
+
GenericTransformer.factory({
|
|
9
|
+
...props,
|
|
10
|
+
method: "http.createParameter",
|
|
11
|
+
write: HttpParameterProgrammer.write,
|
|
12
|
+
});
|
|
13
|
+
}
|