@nestia/sdk 7.0.0-dev.20250605-3 → 7.0.0-dev.20250607

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 (75) hide show
  1. package/lib/analyses/TypedHttpRouteAnalyzer.js +12 -3
  2. package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
  3. package/lib/analyses/TypedWebSocketRouteAnalyzer.js +4 -1
  4. package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
  5. package/lib/generates/SdkGenerator.js +2 -1
  6. package/lib/generates/SdkGenerator.js.map +1 -1
  7. package/lib/generates/SwaggerGenerator.js +3 -3
  8. package/lib/generates/SwaggerGenerator.js.map +1 -1
  9. package/lib/generates/internal/E2eFileProgrammer.js +17 -22
  10. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  11. package/lib/generates/internal/SdkAliasCollection.d.ts +3 -1
  12. package/lib/generates/internal/SdkAliasCollection.js +37 -9
  13. package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
  14. package/lib/generates/internal/SdkFileProgrammer.js +1 -1
  15. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  16. package/lib/generates/internal/SdkHttpCloneProgrammer.js +4 -4
  17. package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
  18. package/lib/generates/internal/SdkHttpCloneReferencer.js +2 -1
  19. package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
  20. package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +1 -6
  21. package/lib/generates/internal/SdkHttpFunctionProgrammer.js +44 -53
  22. package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
  23. package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +1 -6
  24. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +46 -66
  25. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
  26. package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +41 -0
  27. package/lib/generates/internal/SdkHttpParameterProgrammer.js +110 -0
  28. package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -0
  29. package/lib/generates/internal/SdkHttpRouteProgrammer.js +6 -18
  30. package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
  31. package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +1 -6
  32. package/lib/generates/internal/SdkHttpSimulationProgrammer.js +23 -31
  33. package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
  34. package/lib/generates/internal/SdkTypeProgrammer.js +18 -8
  35. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
  36. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +2 -1
  37. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +33 -27
  38. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
  39. package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +22 -0
  40. package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +58 -0
  41. package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -0
  42. package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +2 -1
  43. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +65 -51
  44. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
  45. package/lib/generates/internal/SwaggerOperationComposer.js +9 -6
  46. package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
  47. package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +1 -1
  48. package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
  49. package/lib/structures/ITypedHttpRoute.d.ts +6 -1
  50. package/lib/structures/ITypedHttpRouteParameter.d.ts +2 -2
  51. package/lib/structures/ITypedWebSocketRoute.d.ts +5 -1
  52. package/package.json +5 -5
  53. package/src/analyses/TypedHttpRouteAnalyzer.ts +28 -10
  54. package/src/analyses/TypedWebSocketRouteAnalyzer.ts +15 -0
  55. package/src/generates/SdkGenerator.ts +2 -1
  56. package/src/generates/SwaggerGenerator.ts +5 -13
  57. package/src/generates/internal/E2eFileProgrammer.ts +34 -43
  58. package/src/generates/internal/SdkAliasCollection.ts +66 -15
  59. package/src/generates/internal/SdkFileProgrammer.ts +1 -1
  60. package/src/generates/internal/SdkHttpCloneProgrammer.ts +4 -4
  61. package/src/generates/internal/SdkHttpCloneReferencer.ts +5 -1
  62. package/src/generates/internal/SdkHttpFunctionProgrammer.ts +51 -100
  63. package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +58 -118
  64. package/src/generates/internal/SdkHttpParameterProgrammer.ts +178 -0
  65. package/src/generates/internal/SdkHttpRouteProgrammer.ts +9 -21
  66. package/src/generates/internal/SdkHttpSimulationProgrammer.ts +23 -69
  67. package/src/generates/internal/SdkTypeProgrammer.ts +39 -32
  68. package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +214 -210
  69. package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +87 -0
  70. package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +112 -98
  71. package/src/generates/internal/SwaggerOperationComposer.ts +9 -9
  72. package/src/generates/internal/SwaggerOperationParameterComposer.ts +1 -1
  73. package/src/structures/ITypedHttpRoute.ts +12 -1
  74. package/src/structures/ITypedHttpRouteParameter.ts +2 -2
  75. package/src/structures/ITypedWebSocketRoute.ts +5 -1
@@ -10,8 +10,8 @@ import { Metadata } from "typia/lib/schemas/metadata/Metadata";
10
10
  import { INestiaConfig } from "../INestiaConfig";
11
11
  import { ITypedApplication } from "../structures/ITypedApplication";
12
12
  import { ITypedHttpRoute } from "../structures/ITypedHttpRoute";
13
- import { ITypedHttpRouteParameter } from "../structures/ITypedHttpRouteParameter";
14
13
  import { FileRetriever } from "../utils/FileRetriever";
14
+ import { SdkHttpParameterProgrammer } from "./internal/SdkHttpParameterProgrammer";
15
15
  import { SwaggerOperationComposer } from "./internal/SwaggerOperationComposer";
16
16
 
17
17
  export namespace SwaggerGenerator {
@@ -79,7 +79,7 @@ export namespace SwaggerGenerator {
79
79
  const metadatas: Metadata[] = routes
80
80
  .map((r) => [
81
81
  r.success.metadata,
82
- ...r.parameters.map((p) => p.metadata),
82
+ ...SdkHttpParameterProgrammer.getAll(r).map((p) => p.metadata),
83
83
  ...Object.values(r.exceptions).map((e) => e.metadata),
84
84
  ])
85
85
  .flat()
@@ -128,9 +128,7 @@ export namespace SwaggerGenerator {
128
128
  | string
129
129
  | {
130
130
  type: string;
131
- /**
132
- * @format uri
133
- */
131
+ /** @format uri */
134
132
  url: string;
135
133
  };
136
134
  }>(content);
@@ -267,15 +265,9 @@ export namespace SwaggerGenerator {
267
265
  for (const fn of customizers) fn();
268
266
  };
269
267
 
270
- const getPath = (route: {
271
- path: string;
272
- parameters: ITypedHttpRouteParameter[];
273
- }): string => {
268
+ const getPath = (route: ITypedHttpRoute): string => {
274
269
  let str: string = route.path;
275
- const filtered: ITypedHttpRouteParameter.IParam[] = route.parameters.filter(
276
- (param) => param.category === "param",
277
- );
278
- for (const param of filtered)
270
+ for (const param of route.pathParameters)
279
271
  str = str.replace(`:${param.field}`, `{${param.field}}`);
280
272
  return str;
281
273
  };
@@ -7,6 +7,7 @@ import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
7
7
  import { FilePrinter } from "./FilePrinter";
8
8
  import { ImportDictionary } from "./ImportDictionary";
9
9
  import { SdkAliasCollection } from "./SdkAliasCollection";
10
+ import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
10
11
  import { SdkImportWizard } from "./SdkImportWizard";
11
12
 
12
13
  export namespace E2eFileProgrammer {
@@ -66,14 +67,11 @@ export namespace E2eFileProgrammer {
66
67
  (project: INestiaProject) =>
67
68
  (importer: ImportDictionary) =>
68
69
  (route: ITypedHttpRoute) => {
69
- const headers = route.parameters.find(
70
- (p) => p.category === "headers" && p.field === null,
71
- );
72
70
  const random = IdentifierFactory.access(
73
71
  ts.factory.createIdentifier(SdkImportWizard.typia(importer)),
74
72
  "random",
75
73
  );
76
- const connection = headers
74
+ const connection = route.headerObject
77
75
  ? ts.factory.createObjectLiteralExpression(
78
76
  [
79
77
  ts.factory.createSpreadAssignment(
@@ -95,9 +93,9 @@ export namespace E2eFileProgrammer {
95
93
  [
96
94
  project.config.clone === true
97
95
  ? SdkAliasCollection.from(project)(importer)(
98
- headers.metadata,
96
+ route.headerObject.metadata,
99
97
  )
100
- : SdkAliasCollection.name(headers),
98
+ : SdkAliasCollection.name(route.headerObject),
101
99
  ],
102
100
  undefined,
103
101
  ),
@@ -110,6 +108,14 @@ export namespace E2eFileProgrammer {
110
108
  true,
111
109
  )
112
110
  : ts.factory.createIdentifier("connection");
111
+ const entries = SdkHttpParameterProgrammer.getEntries({
112
+ project,
113
+ importer,
114
+ route,
115
+ body: true,
116
+ e2e: true,
117
+ prefix: ["api", "functional", ...route.accessor].join(".") + ".",
118
+ });
113
119
  const fetch = ts.factory.createCallExpression(
114
120
  ts.factory.createIdentifier(
115
121
  ["api", "functional", ...route.accessor].join("."),
@@ -117,53 +123,38 @@ export namespace E2eFileProgrammer {
117
123
  undefined,
118
124
  [
119
125
  connection,
120
- ...(project.config.keyword === true &&
121
- route.parameters.filter((p) => p.category !== "headers").length !== 0
126
+ ...(project.config.keyword === true && entries.length !== 0
122
127
  ? [
123
128
  LiteralFactory.write(
124
129
  Object.fromEntries(
125
- route.parameters
126
- .filter((p) => p.category !== "headers")
127
- .map((p) => [
128
- p.name,
129
- ts.factory.createCallExpression(
130
- IdentifierFactory.access(
131
- ts.factory.createIdentifier(
132
- SdkImportWizard.typia(importer),
133
- ),
134
- "random",
130
+ entries.map((e) => [
131
+ e.key,
132
+ ts.factory.createCallExpression(
133
+ IdentifierFactory.access(
134
+ ts.factory.createIdentifier(
135
+ SdkImportWizard.typia(importer),
135
136
  ),
136
- [
137
- project.config.clone === true
138
- ? SdkAliasCollection.from(project)(importer)(
139
- p.metadata,
140
- )
141
- : SdkAliasCollection.name(p),
142
- ],
143
- undefined,
137
+ "random",
144
138
  ),
145
- ]),
139
+ [e.type],
140
+ undefined,
141
+ ),
142
+ ]),
146
143
  ),
147
144
  ),
148
145
  ]
149
- : route.parameters
150
- .filter((p) => p.category !== "headers")
151
- .map((p) =>
152
- ts.factory.createCallExpression(
153
- IdentifierFactory.access(
154
- ts.factory.createIdentifier(
155
- SdkImportWizard.typia(importer),
156
- ),
157
- "random",
146
+ : entries.map((e) =>
147
+ ts.factory.createCallExpression(
148
+ IdentifierFactory.access(
149
+ ts.factory.createIdentifier(
150
+ SdkImportWizard.typia(importer),
158
151
  ),
159
- [
160
- project.config.clone === true
161
- ? SdkAliasCollection.from(project)(importer)(p.metadata)
162
- : SdkAliasCollection.name(p),
163
- ],
164
- undefined,
152
+ "random",
165
153
  ),
166
- )),
154
+ [e.type],
155
+ undefined,
156
+ ),
157
+ )),
167
158
  ],
168
159
  );
169
160
  const assert = ts.factory.createCallExpression(
@@ -6,7 +6,10 @@ import { INestiaProject } from "../../structures/INestiaProject";
6
6
  import { IReflectType } from "../../structures/IReflectType";
7
7
  import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
8
8
  import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
9
+ import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
10
+ import { FilePrinter } from "./FilePrinter";
9
11
  import { ImportDictionary } from "./ImportDictionary";
12
+ import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
10
13
  import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
11
14
 
12
15
  export namespace SdkAliasCollection {
@@ -24,28 +27,76 @@ export namespace SdkAliasCollection {
24
27
  (metadata: Metadata) =>
25
28
  SdkTypeProgrammer.write(project)(importer)(metadata);
26
29
 
27
- export const props =
30
+ export const httpProps =
28
31
  (project: INestiaProject) =>
29
32
  (importer: ImportDictionary) =>
30
33
  (route: ITypedHttpRoute): ts.TypeNode =>
31
34
  ts.factory.createTypeLiteralNode(
32
- route.parameters
33
- .filter((p) => p.category !== "headers")
34
- .map((param) =>
35
+ SdkHttpParameterProgrammer.getEntries({
36
+ project,
37
+ importer,
38
+ route,
39
+ body: true,
40
+ prefix: false,
41
+ })
42
+ .map((e) => {
43
+ const signature: ts.PropertySignature =
44
+ ts.factory.createPropertySignature(
45
+ undefined,
46
+ e.key,
47
+ e.required
48
+ ? undefined
49
+ : ts.factory.createToken(ts.SyntaxKind.QuestionToken),
50
+ e.type,
51
+ );
52
+ const description: string | null =
53
+ e.parameter.description ??
54
+ route.jsDocTags
55
+ ?.find(
56
+ (tag) =>
57
+ tag.name === "param" &&
58
+ tag.text?.[0]?.kind === "parameterName" &&
59
+ tag.text?.[0]?.text === e.key,
60
+ )
61
+ ?.text?.find((t) => t.kind === "text")?.text ??
62
+ null;
63
+ return description?.length
64
+ ? [
65
+ ts.factory.createIdentifier("\n") as any,
66
+ FilePrinter.description(signature, description),
67
+ ]
68
+ : [signature];
69
+ })
70
+ .flat(),
71
+ );
72
+
73
+ export const websocketProps = (route: ITypedWebSocketRoute): ts.TypeNode =>
74
+ ts.factory.createTypeLiteralNode([
75
+ ...route.pathParameters.map((p) =>
76
+ ts.factory.createPropertySignature(
77
+ undefined,
78
+ p.name,
79
+ undefined,
80
+ SdkAliasCollection.name(p),
81
+ ),
82
+ ),
83
+ ...(route.query
84
+ ? [
35
85
  ts.factory.createPropertySignature(
36
86
  undefined,
37
- param.name,
38
- param.metadata.isRequired() === false
39
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
40
- : undefined,
41
- param.category === "body"
42
- ? ts.factory.createTypeReferenceNode("Body")
43
- : param.category === "query" && param.field === null
44
- ? ts.factory.createTypeReferenceNode("Query")
45
- : SdkTypeProgrammer.write(project)(importer)(param.metadata),
87
+ "query",
88
+ undefined,
89
+ ts.factory.createTypeReferenceNode("Query"),
46
90
  ),
47
- ),
48
- );
91
+ ]
92
+ : []),
93
+ ts.factory.createPropertySignature(
94
+ undefined,
95
+ "provider",
96
+ undefined,
97
+ ts.factory.createTypeReferenceNode("Provider"),
98
+ ),
99
+ ]);
49
100
 
50
101
  export const headers =
51
102
  (project: INestiaProject) =>
@@ -86,7 +86,7 @@ export namespace SdkFileProgrammer {
86
86
  statements.push(
87
87
  ...(route.protocol === "http"
88
88
  ? SdkHttpRouteProgrammer.write(project)(importer)(route)
89
- : SdkWebSocketRouteProgrammer.write(importer)(route)),
89
+ : SdkWebSocketRouteProgrammer.write(project)(importer)(route)),
90
90
  );
91
91
  if (i !== directory.routes.length - 1)
92
92
  statements.push(FilePrinter.enter());
@@ -30,14 +30,14 @@ export namespace SdkHttpCloneProgrammer {
30
30
  prepare({
31
31
  dict,
32
32
  name: k,
33
- programmer: (importer) => write_object(app.project)(importer)(v),
33
+ programmer: (importer) => writeObject(app.project)(importer)(v),
34
34
  });
35
35
  for (const [k, v] of app.collection.aliases.entries())
36
36
  if (StringUtil.isImplicit(k) === false)
37
37
  prepare({
38
38
  dict,
39
39
  name: k,
40
- programmer: (importer) => write_alias(app.project)(importer)(v),
40
+ programmer: (importer) => writeAlias(app.project)(importer)(v),
41
41
  });
42
42
  return dict;
43
43
  };
@@ -64,7 +64,7 @@ export namespace SdkHttpCloneProgrammer {
64
64
  return modulo!;
65
65
  };
66
66
 
67
- const write_alias =
67
+ const writeAlias =
68
68
  (project: INestiaProject) =>
69
69
  (importer: ImportDictionary) =>
70
70
  (alias: MetadataAliasType): ts.TypeAliasDeclaration =>
@@ -78,7 +78,7 @@ export namespace SdkHttpCloneProgrammer {
78
78
  writeComment([])(alias.description, alias.jsDocTags),
79
79
  );
80
80
 
81
- const write_object =
81
+ const writeObject =
82
82
  (project: INestiaProject) =>
83
83
  (importer: ImportDictionary) =>
84
84
  (object: MetadataObjectType): ts.TypeAliasDeclaration => {
@@ -4,6 +4,7 @@ import { IReflectType } from "../../structures/IReflectType";
4
4
  import { ITypedApplication } from "../../structures/ITypedApplication";
5
5
  import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
6
6
  import { StringUtil } from "../../utils/StringUtil";
7
+ import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
7
8
 
8
9
  export namespace SdkHttpCloneReferencer {
9
10
  export const replace = (app: ITypedApplication): void => {
@@ -21,7 +22,10 @@ export namespace SdkHttpCloneReferencer {
21
22
  route: ITypedHttpRoute;
22
23
  }): void => {
23
24
  const unique: Set<string> = new Set();
24
- for (const p of props.route.parameters)
25
+ for (const p of SdkHttpParameterProgrammer.getSignificant(
26
+ props.route,
27
+ true,
28
+ ))
25
29
  visitType({
26
30
  unique,
27
31
  metadata: p.metadata,
@@ -4,25 +4,18 @@ import { TypeFactory } from "typia/lib/factories/TypeFactory";
4
4
 
5
5
  import { INestiaProject } from "../../structures/INestiaProject";
6
6
  import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
7
- import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
8
7
  import { StringUtil } from "../../utils/StringUtil";
9
8
  import { ImportDictionary } from "./ImportDictionary";
10
9
  import { SdkAliasCollection } from "./SdkAliasCollection";
10
+ import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
11
11
  import { SdkImportWizard } from "./SdkImportWizard";
12
12
 
13
13
  export namespace SdkHttpFunctionProgrammer {
14
14
  export const write =
15
15
  (project: INestiaProject) =>
16
16
  (importer: ImportDictionary) =>
17
- (
18
- route: ITypedHttpRoute,
19
- props: {
20
- headers: ITypedHttpRouteParameter.IHeaders | undefined;
21
- query: ITypedHttpRouteParameter.IQuery | undefined;
22
- body: ITypedHttpRouteParameter.IBody | undefined;
23
- },
24
- ): ts.FunctionDeclaration =>
25
- ts.factory.createFunctionDeclaration(
17
+ (route: ITypedHttpRoute): ts.FunctionDeclaration => {
18
+ return ts.factory.createFunctionDeclaration(
26
19
  [
27
20
  ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
28
21
  ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
@@ -35,67 +28,34 @@ export namespace SdkHttpFunctionProgrammer {
35
28
  "connection",
36
29
  ts.factory.createTypeReferenceNode(
37
30
  SdkImportWizard.IConnection(importer),
38
- props.headers
31
+ route.headerObject !== null
39
32
  ? [ts.factory.createTypeReferenceNode(`${route.name}.Headers`)]
40
33
  : undefined,
41
34
  ),
42
35
  ),
43
- ...(project.config.keyword === true &&
44
- route.parameters.filter((p) => p.category !== "headers").length !== 0
45
- ? [
46
- ts.factory.createParameterDeclaration(
47
- [],
48
- undefined,
49
- "props",
50
- undefined,
51
- ts.factory.createTypeReferenceNode(`${route.name}.IProps`),
52
- ),
53
- ]
54
- : route.parameters
55
- .filter((p) => p.category !== "headers")
56
- .map((p) =>
57
- ts.factory.createParameterDeclaration(
58
- [],
59
- undefined,
60
- p.name,
61
- p.metadata.optional === true
62
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
63
- : undefined,
64
- project.config.primitive !== false &&
65
- (p === props.query || p === props.body)
66
- ? ts.factory.createTypeReferenceNode(
67
- `${route.name}.${p === props.query ? "Query" : "Body"}`,
68
- )
69
- : project.config.clone === true
70
- ? SdkAliasCollection.from(project)(importer)(p.metadata)
71
- : SdkAliasCollection.name(p),
72
- ),
73
- )),
36
+ ...SdkHttpParameterProgrammer.getParameterDeclarations({
37
+ project,
38
+ importer,
39
+ route,
40
+ body: true,
41
+ prefix: true,
42
+ }),
74
43
  ],
75
44
  ts.factory.createTypeReferenceNode("Promise", [
76
45
  project.config.propagate === true ||
77
46
  route.success.metadata.size() !== 0
78
- ? ts.factory.createTypeReferenceNode(`${route.name}.Response`)
47
+ ? ts.factory.createTypeReferenceNode(`${route.name}.Output`)
79
48
  : ts.factory.createTypeReferenceNode("void"),
80
49
  ]),
81
- ts.factory.createBlock(
82
- writeBody(project)(importer)(route, props),
83
- true,
84
- ),
50
+ ts.factory.createBlock(writeBody(project)(importer)(route), true),
85
51
  );
52
+ };
86
53
 
87
54
  const writeBody =
88
55
  (project: INestiaProject) =>
89
56
  (importer: ImportDictionary) =>
90
- (
91
- route: ITypedHttpRoute,
92
- props: {
93
- headers: ITypedHttpRouteParameter.IHeaders | undefined;
94
- query: ITypedHttpRouteParameter.IQuery | undefined;
95
- body: ITypedHttpRouteParameter.IBody | undefined;
96
- },
97
- ): ts.Statement[] => {
98
- const property = (name: string): ts.Expression =>
57
+ (route: ITypedHttpRoute): ts.Statement[] => {
58
+ const access = (name: string): ts.Expression =>
99
59
  project.config.keyword === true
100
60
  ? IdentifierFactory.access(ts.factory.createIdentifier("props"), name)
101
61
  : ts.factory.createIdentifier(name);
@@ -104,7 +64,7 @@ export namespace SdkHttpFunctionProgrammer {
104
64
  IdentifierFactory.access(
105
65
  ts.factory.createIdentifier(
106
66
  SdkImportWizard.Fetcher(
107
- !!props.body?.encrypted || route.success.encrypted,
67
+ !!route.body?.encrypted || route.success.encrypted,
108
68
  )(importer),
109
69
  ),
110
70
  project.config.propagate ? "propagate" : "fetch",
@@ -116,7 +76,7 @@ export namespace SdkHttpFunctionProgrammer {
116
76
  : [TypeFactory.keyword("any"), TypeFactory.keyword("any")]
117
77
  : undefined,
118
78
  [
119
- props.body && props.body.contentType !== "multipart/form-data"
79
+ route.body && route.body.contentType !== "multipart/form-data"
120
80
  ? ts.factory.createObjectLiteralExpression(
121
81
  [
122
82
  ts.factory.createSpreadAssignment(
@@ -135,7 +95,7 @@ export namespace SdkHttpFunctionProgrammer {
135
95
  ts.factory.createPropertyAssignment(
136
96
  ts.factory.createStringLiteral("Content-Type"),
137
97
  ts.factory.createStringLiteral(
138
- props.body?.contentType ?? "application/json",
98
+ route.body?.contentType ?? "application/json",
139
99
  ),
140
100
  ),
141
101
  ],
@@ -172,17 +132,21 @@ export namespace SdkHttpFunctionProgrammer {
172
132
  "path",
173
133
  ),
174
134
  undefined,
175
- getArguments(project, route, false),
135
+ SdkHttpParameterProgrammer.getArguments({
136
+ project,
137
+ route,
138
+ body: false,
139
+ }),
176
140
  ),
177
141
  ),
178
142
  ],
179
143
  true,
180
144
  ),
181
- ...(props.body ? [property(props.body.name)] : []),
145
+ ...(route.body ? [access(route.body.name)] : []),
182
146
  ...(project.config.json &&
183
- props.body !== undefined &&
184
- (props.body.contentType === "application/json" ||
185
- props.body.encrypted === true)
147
+ route.body !== null &&
148
+ (route.body.contentType === "application/json" ||
149
+ route.body.encrypted === true)
186
150
  ? [ts.factory.createIdentifier(`${route.name}.stringify`)]
187
151
  : []),
188
152
  ],
@@ -197,7 +161,11 @@ export namespace SdkHttpFunctionProgrammer {
197
161
  [],
198
162
  [
199
163
  ts.factory.createIdentifier("connection"),
200
- ...getArguments(project, route, true),
164
+ ...SdkHttpParameterProgrammer.getArguments({
165
+ project,
166
+ route,
167
+ body: true,
168
+ }),
201
169
  ],
202
170
  ),
203
171
  undefined,
@@ -208,26 +176,24 @@ export namespace SdkHttpFunctionProgrammer {
208
176
  : fetch();
209
177
  return [
210
178
  ...(project.config.assert
211
- ? route.parameters
212
- .filter((p) => p.category !== "headers")
213
- .map((p) =>
214
- ts.factory.createExpressionStatement(
215
- ts.factory.createCallExpression(
216
- IdentifierFactory.access(
217
- ts.factory.createIdentifier(
218
- SdkImportWizard.typia(importer),
219
- ),
220
- "assert",
179
+ ? SdkHttpParameterProgrammer.getSignificant(route, true).map((p) =>
180
+ ts.factory.createExpressionStatement(
181
+ ts.factory.createCallExpression(
182
+ IdentifierFactory.access(
183
+ ts.factory.createIdentifier(
184
+ SdkImportWizard.typia(importer),
221
185
  ),
222
- [
223
- ts.factory.createTypeQueryNode(
224
- ts.factory.createIdentifier(p.name),
225
- ),
226
- ],
227
- [ts.factory.createIdentifier(p.name)],
186
+ "assert",
228
187
  ),
188
+ [
189
+ ts.factory.createTypeQueryNode(
190
+ ts.factory.createIdentifier(p.name),
191
+ ),
192
+ ],
193
+ [ts.factory.createIdentifier(p.name)],
229
194
  ),
230
- )
195
+ ),
196
+ )
231
197
  : []),
232
198
  ...(route.success.setHeaders.length === 0
233
199
  ? [ts.factory.createReturnStatement(output(false))]
@@ -244,7 +210,9 @@ export namespace SdkHttpFunctionProgrammer {
244
210
  x[0] === "[" ? `${x}${y}` : `${x}.${y}`;
245
211
  const output: string = StringUtil.escapeDuplicate([
246
212
  "connection",
247
- ...route.parameters.map((p) => p.name),
213
+ ...SdkHttpParameterProgrammer.getSignificant(route, true).map(
214
+ (p) => p.name,
215
+ ),
248
216
  ])("output");
249
217
  const headers: string = accessor("connection")("headers");
250
218
  const data: string = project.config.propagate
@@ -305,21 +273,4 @@ export namespace SdkHttpFunctionProgrammer {
305
273
  ts.factory.createReturnStatement(ts.factory.createIdentifier(output)),
306
274
  ];
307
275
  };
308
-
309
- const getArguments = (
310
- project: INestiaProject,
311
- route: ITypedHttpRoute,
312
- body: boolean,
313
- ): ts.Expression[] => {
314
- const parameters = route.parameters.filter(
315
- (p) =>
316
- p.category === "param" ||
317
- p.category === "query" ||
318
- (body === true && p.category === "body"),
319
- );
320
- if (parameters.length === 0) return [];
321
- else if (project.config.keyword === true)
322
- return [ts.factory.createIdentifier("props")];
323
- return parameters.map((p) => ts.factory.createIdentifier(p.name));
324
- };
325
276
  }