@nestia/sdk 2.5.0-dev.20240128 → 2.5.0-dev.20240129-2

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 (66) hide show
  1. package/lib/NestiaSdkApplication.js +1 -1
  2. package/lib/NestiaSdkApplication.js.map +1 -1
  3. package/lib/generates/CloneGenerator.d.ts +6 -0
  4. package/lib/generates/CloneGenerator.js +60 -0
  5. package/lib/generates/CloneGenerator.js.map +1 -0
  6. package/lib/generates/E2eGenerator.d.ts +2 -1
  7. package/lib/generates/E2eGenerator.js +2 -2
  8. package/lib/generates/E2eGenerator.js.map +1 -1
  9. package/lib/generates/SdkGenerator.js +3 -3
  10. package/lib/generates/SdkGenerator.js.map +1 -1
  11. package/lib/generates/internal/E2eFileProgrammer.d.ts +2 -1
  12. package/lib/generates/internal/E2eFileProgrammer.js +45 -51
  13. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  14. package/lib/generates/internal/SdkAliasCollection.d.ts +12 -0
  15. package/lib/generates/internal/SdkAliasCollection.js +89 -0
  16. package/lib/generates/internal/SdkAliasCollection.js.map +1 -0
  17. package/lib/generates/internal/SdkFileProgrammer.d.ts +2 -1
  18. package/lib/generates/internal/SdkFileProgrammer.js +12 -19
  19. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  20. package/lib/generates/internal/SdkFunctionProgrammer.js +6 -6
  21. package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
  22. package/lib/generates/internal/SdkInterfaceProgrammer.d.ts +12 -0
  23. package/lib/generates/internal/SdkInterfaceProgrammer.js +112 -0
  24. package/lib/generates/internal/SdkInterfaceProgrammer.js.map +1 -0
  25. package/lib/generates/internal/SdkNamespaceProgrammer.d.ts +1 -1
  26. package/lib/generates/internal/SdkNamespaceProgrammer.js +24 -23
  27. package/lib/generates/internal/SdkNamespaceProgrammer.js.map +1 -1
  28. package/lib/generates/internal/SdkRouteProgrammer.d.ts +1 -1
  29. package/lib/generates/internal/SdkRouteProgrammer.js +4 -4
  30. package/lib/generates/internal/SdkRouteProgrammer.js.map +1 -1
  31. package/lib/generates/internal/SdkSimulationProgrammer.d.ts +1 -1
  32. package/lib/generates/internal/SdkSimulationProgrammer.js +11 -12
  33. package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
  34. package/lib/generates/internal/{SdkDtoGenerator.d.ts → SdkTypeProgrammer.d.ts} +2 -4
  35. package/lib/generates/internal/SdkTypeProgrammer.js +160 -0
  36. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -0
  37. package/lib/utils/{NodeUtil.d.ts → FormatUtil.d.ts} +2 -1
  38. package/lib/utils/FormatUtil.js +38 -0
  39. package/lib/utils/FormatUtil.js.map +1 -0
  40. package/lib/utils/ImportDictionary.js +2 -2
  41. package/lib/utils/ImportDictionary.js.map +1 -1
  42. package/package.json +3 -3
  43. package/src/NestiaSdkApplication.ts +1 -1
  44. package/src/generates/CloneGenerator.ts +75 -0
  45. package/src/generates/E2eGenerator.ts +3 -1
  46. package/src/generates/SdkGenerator.ts +3 -3
  47. package/src/generates/internal/E2eFileProgrammer.ts +145 -77
  48. package/src/generates/internal/SdkAliasCollection.ts +145 -0
  49. package/src/generates/internal/SdkFileProgrammer.ts +16 -16
  50. package/src/generates/internal/SdkFunctionProgrammer.ts +9 -9
  51. package/src/generates/internal/SdkInterfaceProgrammer.ts +211 -0
  52. package/src/generates/internal/SdkNamespaceProgrammer.ts +36 -24
  53. package/src/generates/internal/SdkRouteProgrammer.ts +7 -3
  54. package/src/generates/internal/SdkSimulationProgrammer.ts +14 -16
  55. package/src/generates/internal/SdkTypeProgrammer.ts +252 -0
  56. package/src/utils/{NodeUtil.ts → FormatUtil.ts} +13 -1
  57. package/src/utils/ImportDictionary.ts +2 -2
  58. package/lib/generates/internal/SdkDtoGenerator.js +0 -294
  59. package/lib/generates/internal/SdkDtoGenerator.js.map +0 -1
  60. package/lib/generates/internal/SdkTypeDefiner.d.ts +0 -11
  61. package/lib/generates/internal/SdkTypeDefiner.js +0 -82
  62. package/lib/generates/internal/SdkTypeDefiner.js.map +0 -1
  63. package/lib/utils/NodeUtil.js +0 -16
  64. package/lib/utils/NodeUtil.js.map +0 -1
  65. package/src/generates/internal/SdkDtoGenerator.ts +0 -424
  66. package/src/generates/internal/SdkTypeDefiner.ts +0 -119
@@ -1,19 +1,23 @@
1
1
  import fs from "fs";
2
+ import ts from "typescript";
3
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
2
4
 
3
5
  import { INestiaConfig } from "../../INestiaConfig";
4
6
  import { IRoute } from "../../structures/IRoute";
7
+ import { FormatUtil } from "../../utils/FormatUtil";
5
8
  import { ImportDictionary } from "../../utils/ImportDictionary";
6
- import { SdkDtoGenerator } from "./SdkDtoGenerator";
9
+ import { SdkAliasCollection } from "./SdkAliasCollection";
7
10
  import { SdkImportWizard } from "./SdkImportWizard";
8
- import { SdkTypeDefiner } from "./SdkTypeDefiner";
11
+ import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
9
12
 
10
13
  export namespace E2eFileProgrammer {
11
14
  export const generate =
15
+ (checker: ts.TypeChecker) =>
12
16
  (config: INestiaConfig) =>
13
17
  (props: { api: string; current: string }) =>
14
18
  async (route: IRoute): Promise<void> => {
15
19
  const importer: ImportDictionary = new ImportDictionary(
16
- `${props.current}/${name(route)}.ts`,
20
+ `${props.current}/${getFunctionName(route)}.ts`,
17
21
  );
18
22
  if (config.clone !== true)
19
23
  for (const tuple of route.imports)
@@ -30,94 +34,158 @@ export namespace E2eFileProgrammer {
30
34
  name: "api",
31
35
  });
32
36
 
33
- const body: string = arrow(config)(importer)(route);
34
- const content: string = [importer.toScript(props.current), "", body].join(
35
- "\n",
36
- );
37
+ const functor = generate_function(checker)(config)(importer)(route);
37
38
 
38
- await fs.promises.writeFile(importer.file, content, "utf8");
39
+ await fs.promises.writeFile(
40
+ importer.file,
41
+ await FormatUtil.beautify(
42
+ ts
43
+ .createPrinter()
44
+ .printFile(
45
+ ts.factory.createSourceFile(
46
+ [
47
+ ...importer.toStatements(props.current),
48
+ FormatUtil.enter(),
49
+ functor,
50
+ ],
51
+ ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
52
+ ts.NodeFlags.None,
53
+ ),
54
+ ),
55
+ ),
56
+ "utf8",
57
+ );
39
58
  };
40
59
 
41
- const arrow =
60
+ const generate_function =
61
+ (checker: ts.TypeChecker) =>
42
62
  (config: INestiaConfig) =>
43
63
  (importer: ImportDictionary) =>
44
- (route: IRoute): string => {
45
- const tab: number = 2;
46
- const headers = route.parameters.find(
47
- (p) => p.category === "headers" && p.field === undefined,
64
+ (route: IRoute): ts.Statement =>
65
+ ts.factory.createVariableStatement(
66
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
67
+ ts.factory.createVariableDeclarationList(
68
+ [
69
+ ts.factory.createVariableDeclaration(
70
+ ts.factory.createIdentifier(getFunctionName(route)),
71
+ undefined,
72
+ undefined,
73
+ generate_arrow(checker)(config)(importer)(route),
74
+ ),
75
+ ],
76
+ ts.NodeFlags.Const,
77
+ ),
48
78
  );
49
- const output = [
50
- `await ${accessor(route)}(`,
51
- headers !== undefined
52
- ? [
53
- "{",
54
- " ...connection,",
55
- " headers: {",
56
- " ...(connection.headers ?? {}),",
57
- ` ...${SdkImportWizard.typia(
58
- importer,
59
- )}.random<${getTypeName(config)(importer)(headers)}>(),`,
60
- " },",
61
- "},",
62
- ]
63
- .map((line) => `${" ".repeat(tab * 4)}${line}`)
64
- .join("\n")
65
- : `${" ".repeat(tab * 4)}connection,`,
66
- ...route.parameters
67
- .filter((param) => param.category !== "headers")
68
- .map(parameter(config)(importer)(tab)),
69
- `${" ".repeat((tab - 1) * 4)});`,
70
- ].join("\n");
71
- return [
72
- `export const ${name(route)} = async (`,
73
- ` connection: api.IConnection`,
74
- `): Promise<void> => {`,
75
- ...(route.output.typeName === "void"
76
- ? [` ${output}`]
77
- : [
78
- ` const output: ${SdkTypeDefiner.output(config)(importer)(
79
- route,
80
- )} = ${output}`,
81
- ` ${SdkImportWizard.typia(importer)}.assert(output);`,
82
- ]),
83
- `};`,
84
- ].join("\n");
85
- };
86
79
 
87
- const parameter =
80
+ const generate_arrow =
81
+ (checker: ts.TypeChecker) =>
88
82
  (config: INestiaConfig) =>
89
83
  (importer: ImportDictionary) =>
90
- (tab: number) =>
91
- (param: IRoute.IParameter): string => {
92
- const middle: string = `${SdkImportWizard.typia(importer)}.random<${wrap(
93
- config,
94
- )(importer)(
95
- getTypeName(config)(importer)(param),
96
- param.category === "body",
97
- )}>()`;
98
- return `${" ".repeat(4 * tab)}${middle},`;
99
- };
84
+ (route: IRoute) => {
85
+ const headers = route.parameters.find(
86
+ (p) => p.category === "headers" && p.field === undefined,
87
+ );
88
+ const connection = headers
89
+ ? ts.factory.createObjectLiteralExpression(
90
+ [
91
+ ts.factory.createSpreadAssignment(
92
+ ts.factory.createIdentifier("connection"),
93
+ ),
94
+ ts.factory.createPropertyAssignment(
95
+ "headers",
96
+ ts.factory.createObjectLiteralExpression(
97
+ [
98
+ ts.factory.createSpreadAssignment(
99
+ IdentifierFactory.access(
100
+ ts.factory.createIdentifier("connection"),
101
+ )("headers"),
102
+ ),
103
+ ts.factory.createSpreadAssignment(
104
+ ts.factory.createCallExpression(
105
+ IdentifierFactory.access(
106
+ ts.factory.createIdentifier(
107
+ SdkImportWizard.typia(importer),
108
+ ),
109
+ )("random"),
110
+ [getTypeName(config)(importer)(headers)],
111
+ undefined,
112
+ ),
113
+ ),
114
+ ],
115
+ true,
116
+ ),
117
+ ),
118
+ ],
119
+ true,
120
+ )
121
+ : ts.factory.createIdentifier("connection");
122
+ const caller = ts.factory.createCallExpression(
123
+ ts.factory.createIdentifier(
124
+ ["api", "functional", ...route.accessors].join("."),
125
+ ),
126
+ undefined,
127
+ [
128
+ connection,
129
+ ...route.parameters
130
+ .filter((p) => p.category !== "headers")
131
+ .map((p) =>
132
+ ts.factory.createCallExpression(
133
+ IdentifierFactory.access(
134
+ ts.factory.createIdentifier(SdkImportWizard.typia(importer)),
135
+ )("random"),
136
+ [getTypeName(config)(importer)(p)],
137
+ undefined,
138
+ ),
139
+ ),
140
+ ],
141
+ );
142
+ const assert = ts.factory.createCallExpression(
143
+ IdentifierFactory.access(
144
+ ts.factory.createIdentifier(SdkImportWizard.typia(importer)),
145
+ )("assert"),
146
+ undefined,
147
+ [ts.factory.createIdentifier("output")],
148
+ );
100
149
 
101
- const name = (route: IRoute): string =>
102
- ["test", "api", ...route.accessors].join("_");
150
+ return ts.factory.createArrowFunction(
151
+ [ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword)],
152
+ undefined,
153
+ [
154
+ IdentifierFactory.parameter(
155
+ "connection",
156
+ ts.factory.createTypeReferenceNode("api.IConnection"),
157
+ ),
158
+ ],
159
+ undefined,
160
+ undefined,
161
+ ts.factory.createBlock([
162
+ ts.factory.createVariableStatement(
163
+ [],
164
+ ts.factory.createVariableDeclarationList(
165
+ [
166
+ ts.factory.createVariableDeclaration(
167
+ "output",
168
+ undefined,
169
+ SdkAliasCollection.output(checker)(config)(importer)(route),
170
+ ts.factory.createAwaitExpression(caller),
171
+ ),
172
+ ],
173
+ ts.NodeFlags.Const,
174
+ ),
175
+ ),
176
+ ts.factory.createExpressionStatement(assert),
177
+ ]),
178
+ );
179
+ };
180
+ }
103
181
 
104
- const accessor = (route: IRoute): string =>
105
- ["api", "functional", ...route.accessors].join(".");
182
+ const getFunctionName = (route: IRoute): string =>
183
+ ["test", "api", ...route.accessors].join("_");
106
184
 
107
- const wrap =
108
- (config: INestiaConfig) =>
109
- (importer: ImportDictionary) =>
110
- (name: string, body: boolean): string =>
111
- config.primitive === false
112
- ? name
113
- : `${(body ? SdkImportWizard.Primitive : SdkImportWizard.Resolved)(
114
- importer,
115
- )}<${name}>`;
116
- }
117
185
  const getTypeName =
118
186
  (config: INestiaConfig) =>
119
187
  (importer: ImportDictionary) =>
120
188
  (p: IRoute.IParameter | IRoute.IOutput) =>
121
189
  p.metadata
122
- ? SdkDtoGenerator.decode(config)(importer)(p.metadata)
123
- : p.typeName;
190
+ ? SdkTypeProgrammer.decode(config)(importer)(p.metadata)
191
+ : ts.factory.createTypeReferenceNode(p.typeName);
@@ -0,0 +1,145 @@
1
+ import ts from "typescript";
2
+
3
+ import { INestiaConfig } from "../../INestiaConfig";
4
+ import { IRoute } from "../../structures/IRoute";
5
+ import { ImportDictionary } from "../../utils/ImportDictionary";
6
+ import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
7
+
8
+ export namespace SdkAliasCollection {
9
+ export const name =
10
+ (config: INestiaConfig) =>
11
+ (importer: ImportDictionary) =>
12
+ (p: IRoute.IParameter | IRoute.IOutput): ts.TypeNode =>
13
+ p.metadata
14
+ ? SdkTypeProgrammer.decode(config)(importer)(p.metadata)
15
+ : ts.factory.createTypeReferenceNode(p.typeName);
16
+
17
+ export const headers =
18
+ (config: INestiaConfig) =>
19
+ (importer: ImportDictionary) =>
20
+ (param: IRoute.IParameter): ts.TypeNode => {
21
+ const type: ts.TypeNode = name(config)(importer)(param);
22
+ if (config.primitive === false) return type;
23
+ return ts.factory.createTypeReferenceNode(
24
+ importer.external({
25
+ type: true,
26
+ library: "@nestia/fetcher",
27
+ instance: "Resolved",
28
+ }),
29
+ [type],
30
+ );
31
+ };
32
+
33
+ export const query =
34
+ (config: INestiaConfig) =>
35
+ (importer: ImportDictionary) =>
36
+ (param: IRoute.IParameter): ts.TypeNode => {
37
+ const type: ts.TypeNode = name(config)(importer)(param);
38
+ if (config.primitive === false) return type;
39
+ return ts.factory.createTypeReferenceNode(
40
+ importer.external({
41
+ type: true,
42
+ library: "@nestia/fetcher",
43
+ instance: "Resolved",
44
+ }),
45
+ [type],
46
+ );
47
+ };
48
+
49
+ export const input =
50
+ (config: INestiaConfig) =>
51
+ (importer: ImportDictionary) =>
52
+ (param: IRoute.IParameter): ts.TypeNode => {
53
+ const type: ts.TypeNode = name(config)(importer)(param);
54
+ if (config.primitive === false) return type;
55
+ return ts.factory.createTypeReferenceNode(
56
+ importer.external({
57
+ type: true,
58
+ library: "@nestia/fetcher",
59
+ instance: "Primitive",
60
+ }),
61
+ [type],
62
+ );
63
+ };
64
+
65
+ export const output =
66
+ (checker: ts.TypeChecker) =>
67
+ (config: INestiaConfig) =>
68
+ (importer: ImportDictionary) =>
69
+ (route: IRoute): ts.TypeNode => {
70
+ if (config.propagate !== true) {
71
+ const node: ts.TypeNode = name(config)(importer)(route.output);
72
+ const type = checker.getTypeAtLocation(node);
73
+ const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
74
+
75
+ if (
76
+ filter(ts.TypeFlags.Undefined) ||
77
+ filter(ts.TypeFlags.Never) ||
78
+ filter(ts.TypeFlags.Void) ||
79
+ filter(ts.TypeFlags.VoidLike) ||
80
+ config.primitive === false
81
+ )
82
+ return node;
83
+ return ts.factory.createTypeReferenceNode(
84
+ importer.external({
85
+ type: true,
86
+ library: "@nestia/fetcher",
87
+ instance:
88
+ route.output.contentType === "application/x-www-form-urlencoded"
89
+ ? "Resolved"
90
+ : "Primitive",
91
+ }),
92
+ [node],
93
+ );
94
+ }
95
+
96
+ const branches: IBranch[] = [
97
+ {
98
+ status: String(route.status ?? (route.method === "POST" ? 201 : 200)),
99
+ type: name(config)(importer)(route.output),
100
+ },
101
+ ...Object.entries(route.exceptions).map(([status, value]) => ({
102
+ status,
103
+ type: name(config)(importer)(value),
104
+ })),
105
+ ];
106
+ return ts.factory.createTypeReferenceNode(
107
+ importer.external({
108
+ type: true,
109
+ library: "@nestia/fetcher",
110
+ instance: "IPropagation",
111
+ }),
112
+ [
113
+ ts.factory.createTypeLiteralNode(
114
+ branches.map((b) =>
115
+ ts.factory.createPropertySignature(
116
+ undefined,
117
+ ts.factory.createNumericLiteral(b.status),
118
+ undefined,
119
+ b.type,
120
+ ),
121
+ ),
122
+ ),
123
+ ...(route.status
124
+ ? [
125
+ ts.factory.createLiteralTypeNode(
126
+ ts.factory.createNumericLiteral(route.status),
127
+ ),
128
+ ]
129
+ : []),
130
+ ],
131
+ );
132
+ };
133
+
134
+ export const responseBody =
135
+ (checker: ts.TypeChecker) =>
136
+ (config: INestiaConfig) =>
137
+ (importer: ImportDictionary) =>
138
+ (route: IRoute): ts.TypeNode =>
139
+ output(checker)({ ...config, propagate: false })(importer)(route);
140
+ }
141
+
142
+ interface IBranch {
143
+ status: string;
144
+ type: ts.TypeNode;
145
+ }
@@ -1,12 +1,11 @@
1
1
  import fs from "fs";
2
- import { format } from "prettier";
3
2
  import ts from "typescript";
4
3
 
5
4
  import { INestiaConfig } from "../../INestiaConfig";
6
5
  import { IRoute } from "../../structures/IRoute";
6
+ import { FormatUtil } from "../../utils/FormatUtil";
7
7
  import { ImportDictionary } from "../../utils/ImportDictionary";
8
8
  import { MapUtil } from "../../utils/MapUtil";
9
- import { NodeUtil } from "../../utils/NodeUtil";
10
9
  import { SdkRouteDirectory } from "./SdkRouteDirectory";
11
10
  import { SdkRouteProgrammer } from "./SdkRouteProgrammer";
12
11
 
@@ -15,6 +14,7 @@ export namespace SdkFileProgrammer {
15
14
  CONSTRUCTOR
16
15
  --------------------------------------------------------- */
17
16
  export const generate =
17
+ (checker: ts.TypeChecker) =>
18
18
  (config: INestiaConfig) =>
19
19
  async (routeList: IRoute[]): Promise<void> => {
20
20
  // CONSTRUCT FOLDER TREE
@@ -22,7 +22,7 @@ export namespace SdkFileProgrammer {
22
22
  for (const route of routeList) emplace(root)(route);
23
23
 
24
24
  // ITERATE FILES
25
- await iterate(config)(root)(config.output + "/functional");
25
+ await iterate(checker)(config)(root)(config.output + "/functional");
26
26
  };
27
27
 
28
28
  const emplace =
@@ -45,6 +45,7 @@ export namespace SdkFileProgrammer {
45
45
  FILE ITERATOR
46
46
  --------------------------------------------------------- */
47
47
  const iterate =
48
+ (checker: ts.TypeChecker) =>
48
49
  (config: INestiaConfig) =>
49
50
  (directory: SdkRouteDirectory) =>
50
51
  async (outDir: string): Promise<void> => {
@@ -56,7 +57,7 @@ export namespace SdkFileProgrammer {
56
57
  // ITERATE CHILDREN
57
58
  const statements: ts.Statement[] = [];
58
59
  for (const [key, value] of directory.children) {
59
- await iterate(config)(value)(`${outDir}/${key}`);
60
+ await iterate(checker)(config)(value)(`${outDir}/${key}`);
60
61
  statements.push(
61
62
  ts.factory.createExportDeclaration(
62
63
  undefined,
@@ -68,7 +69,7 @@ export namespace SdkFileProgrammer {
68
69
  );
69
70
  }
70
71
  if (statements.length && directory.routes.length)
71
- statements.push(NodeUtil.enter());
72
+ statements.push(FormatUtil.enter());
72
73
 
73
74
  // ITERATE ROUTES
74
75
  const importer: ImportDictionary = new ImportDictionary(
@@ -93,17 +94,19 @@ export namespace SdkFileProgrammer {
93
94
  type: true,
94
95
  });
95
96
  statements.push(
96
- ...SdkRouteProgrammer.generate(config)(importer)(route),
97
+ ...SdkRouteProgrammer.generate(checker)(config)(importer)(route),
97
98
  );
98
99
  if (i !== directory.routes.length - 1)
99
- statements.push(NodeUtil.enter());
100
+ statements.push(FormatUtil.enter());
100
101
  });
101
102
 
102
103
  // FINALIZE THE CONTENT
103
104
  if (directory.routes.length !== 0)
104
105
  statements.push(
105
106
  ...importer.toStatements(outDir),
106
- ...(!importer.empty() && statements.length ? [NodeUtil.enter()] : []),
107
+ ...(!importer.empty() && statements.length
108
+ ? [FormatUtil.enter()]
109
+ : []),
107
110
  ...statements.splice(0, statements.length),
108
111
  );
109
112
 
@@ -123,13 +126,10 @@ export namespace SdkFileProgrammer {
123
126
  ts.NodeFlags.None,
124
127
  ),
125
128
  );
126
- const beautify = async () => {
127
- try {
128
- return await format(script, { parser: "typescript" });
129
- } catch {
130
- return script;
131
- }
132
- };
133
- await fs.promises.writeFile(importer.file, await beautify(), "utf8");
129
+ await fs.promises.writeFile(
130
+ importer.file,
131
+ await FormatUtil.beautify(script),
132
+ "utf8",
133
+ );
134
134
  };
135
135
  }
@@ -6,8 +6,8 @@ import { INestiaConfig } from "../../INestiaConfig";
6
6
  import { IController } from "../../structures/IController";
7
7
  import { IRoute } from "../../structures/IRoute";
8
8
  import { ImportDictionary } from "../../utils/ImportDictionary";
9
- import { SdkDtoGenerator } from "./SdkDtoGenerator";
10
9
  import { SdkImportWizard } from "./SdkImportWizard";
10
+ import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
11
11
 
12
12
  export namespace SdkFunctionProgrammer {
13
13
  export const generate =
@@ -49,12 +49,12 @@ export namespace SdkFunctionProgrammer {
49
49
  p.optional
50
50
  ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
51
51
  : undefined,
52
- ts.factory.createTypeReferenceNode(
53
- config.primitive !== false &&
54
- (p === props.query || p === props.input)
55
- ? `${route.name}.${p === props.query ? "Query" : "Input"}`
56
- : getTypeName(config)(importer)(p),
57
- ),
52
+ config.primitive !== false &&
53
+ (p === props.query || p === props.input)
54
+ ? ts.factory.createTypeReferenceNode(
55
+ `${route.name}.${p === props.query ? "Query" : "Input"}`,
56
+ )
57
+ : getTypeName(config)(importer)(p),
58
58
  ),
59
59
  ),
60
60
  ],
@@ -215,5 +215,5 @@ const getTypeName =
215
215
  (importer: ImportDictionary) =>
216
216
  (p: IRoute.IParameter | IRoute.IOutput) =>
217
217
  p.metadata
218
- ? SdkDtoGenerator.decode(config)(importer)(p.metadata)
219
- : p.typeName;
218
+ ? SdkTypeProgrammer.decode(config)(importer)(p.metadata)
219
+ : ts.factory.createTypeReferenceNode(p.typeName);