@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
@@ -7,9 +7,9 @@ import { TypeFactory } from "typia/lib/factories/TypeFactory";
7
7
 
8
8
  import { INestiaProject } from "../../structures/INestiaProject";
9
9
  import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
10
- import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
11
10
  import { ImportDictionary } from "./ImportDictionary";
12
11
  import { SdkAliasCollection } from "./SdkAliasCollection";
12
+ import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
13
13
  import { SdkImportWizard } from "./SdkImportWizard";
14
14
 
15
15
  export namespace SdkHttpSimulationProgrammer {
@@ -60,14 +60,7 @@ export namespace SdkHttpSimulationProgrammer {
60
60
  export const simulate =
61
61
  (project: INestiaProject) =>
62
62
  (importer: ImportDictionary) =>
63
- (
64
- route: ITypedHttpRoute,
65
- props: {
66
- headers: ITypedHttpRouteParameter.IHeaders | undefined;
67
- query: ITypedHttpRouteParameter.IQuery | undefined;
68
- body: ITypedHttpRouteParameter.IBody | undefined;
69
- },
70
- ): ts.VariableStatement => {
63
+ (route: ITypedHttpRoute): ts.VariableStatement => {
71
64
  const output: boolean =
72
65
  project.config.propagate === true ||
73
66
  route.success.metadata.size() !== 0;
@@ -96,7 +89,6 @@ export namespace SdkHttpSimulationProgrammer {
96
89
  ),
97
90
  ],
98
91
  );
99
-
100
92
  return constant("simulate")(
101
93
  ts.factory.createArrowFunction(
102
94
  undefined,
@@ -106,9 +98,7 @@ export namespace SdkHttpSimulationProgrammer {
106
98
  "connection",
107
99
  ts.factory.createTypeReferenceNode(
108
100
  SdkImportWizard.IConnection(importer),
109
- route.parameters.some(
110
- (p) => p.category === "headers" && p.field === null,
111
- )
101
+ route.headerObject
112
102
  ? [
113
103
  ts.factory.createTypeReferenceNode(
114
104
  `${route.name}.Headers`,
@@ -117,42 +107,15 @@ export namespace SdkHttpSimulationProgrammer {
117
107
  : [],
118
108
  ),
119
109
  ),
120
- ...(project.config.keyword === true &&
121
- route.parameters.filter((p) => p.category !== "headers").length !==
122
- 0
123
- ? [
124
- ts.factory.createParameterDeclaration(
125
- [],
126
- undefined,
127
- "props",
128
- undefined,
129
- ts.factory.createTypeReferenceNode("IProps"),
130
- ),
131
- ]
132
- : route.parameters
133
- .filter((p) => p.category !== "headers")
134
- .map((p) =>
135
- ts.factory.createParameterDeclaration(
136
- [],
137
- undefined,
138
- p.name,
139
- p.metadata.optional
140
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
141
- : undefined,
142
- project.config.primitive !== false &&
143
- (p === props.query || p === props.body)
144
- ? ts.factory.createTypeReferenceNode(
145
- `${route.name}.${p === props.query ? "Query" : "Body"}`,
146
- )
147
- : project.config.clone === true
148
- ? SdkAliasCollection.from(project)(importer)(
149
- p.metadata,
150
- )
151
- : SdkAliasCollection.name(p),
152
- ),
153
- )),
110
+ ...SdkHttpParameterProgrammer.getParameterDeclarations({
111
+ project,
112
+ importer,
113
+ route,
114
+ body: true,
115
+ prefix: false,
116
+ }),
154
117
  ],
155
- ts.factory.createTypeReferenceNode(output ? "Response" : "void"),
118
+ ts.factory.createTypeReferenceNode(output ? "Output" : "void"),
156
119
  undefined,
157
120
  ts.factory.createBlock(
158
121
  [
@@ -183,7 +146,7 @@ export namespace SdkHttpSimulationProgrammer {
183
146
  ],
184
147
  true,
185
148
  ),
186
- ts.factory.createTypeReferenceNode("Response"),
149
+ ts.factory.createTypeReferenceNode("Output"),
187
150
  )
188
151
  : caller(),
189
152
  ),
@@ -198,15 +161,9 @@ export namespace SdkHttpSimulationProgrammer {
198
161
  (project: INestiaProject) =>
199
162
  (importer: ImportDictionary) =>
200
163
  (route: ITypedHttpRoute): ts.Statement[] => {
201
- const parameters = route.parameters.filter(
202
- (p) => p.category !== "headers",
203
- );
164
+ const parameters = SdkHttpParameterProgrammer.getSignificant(route, true);
204
165
  if (parameters.length === 0) return [];
205
166
 
206
- const access = (key: string) =>
207
- project.config.keyword === true
208
- ? IdentifierFactory.access(ts.factory.createIdentifier("props"), key)
209
- : ts.factory.createIdentifier(key);
210
167
  const typia = SdkImportWizard.typia(importer);
211
168
  const validator = StatementFactory.constant({
212
169
  name: "assert",
@@ -238,17 +195,11 @@ export namespace SdkHttpSimulationProgrammer {
238
195
  ts.factory.createCallExpression(
239
196
  ts.factory.createIdentifier("path"),
240
197
  undefined,
241
- project.config.keyword === true &&
242
- route.parameters.filter(
243
- (p) => p.category === "param" || p.category === "query",
244
- ).length !== 0
245
- ? [ts.factory.createIdentifier("props")]
246
- : route.parameters
247
- .filter(
248
- (p) =>
249
- p.category === "param" || p.category === "query",
250
- )
251
- .map((p) => ts.factory.createIdentifier(p.name)),
198
+ SdkHttpParameterProgrammer.getArguments({
199
+ project,
200
+ route,
201
+ body: false,
202
+ }),
252
203
  ),
253
204
  ),
254
205
  ts.factory.createPropertyAssignment(
@@ -290,14 +241,17 @@ export namespace SdkHttpSimulationProgrammer {
290
241
  "assert",
291
242
  ),
292
243
  undefined,
293
- [access(p.name)],
244
+ [
245
+ project.config.keyword === true
246
+ ? ts.factory.createIdentifier(`props.${p.name}`)
247
+ : ts.factory.createIdentifier(p.name),
248
+ ],
294
249
  ),
295
250
  ),
296
251
  ],
297
252
  ),
298
253
  )
299
254
  .map(ts.factory.createExpressionStatement);
300
-
301
255
  return [
302
256
  validator,
303
257
  ...(project.config.propagate !== true
@@ -75,19 +75,16 @@ export namespace SdkTypeProgrammer {
75
75
  (object: MetadataObjectType): ts.TypeNode => {
76
76
  const regular = object.properties.filter((p) => p.key.isSoleLiteral());
77
77
  const dynamic = object.properties.filter((p) => !p.key.isSoleLiteral());
78
- return FilePrinter.description(
79
- regular.length && dynamic.length
80
- ? ts.factory.createIntersectionTypeNode([
81
- write_regular_property(project)(importer)(regular),
82
- ...dynamic.map(write_dynamic_property(project)(importer)),
83
- ])
84
- : dynamic.length
85
- ? ts.factory.createIntersectionTypeNode(
86
- dynamic.map(write_dynamic_property(project)(importer)),
87
- )
88
- : write_regular_property(project)(importer)(regular),
89
- writeComment([])(object.description ?? null, object.jsDocTags),
90
- );
78
+ return regular.length && dynamic.length
79
+ ? ts.factory.createIntersectionTypeNode([
80
+ write_regular_property(project)(importer)(regular),
81
+ ...dynamic.map(write_dynamic_property(project)(importer)),
82
+ ])
83
+ : dynamic.length
84
+ ? ts.factory.createIntersectionTypeNode(
85
+ dynamic.map(write_dynamic_property(project)(importer)),
86
+ )
87
+ : write_regular_property(project)(importer)(regular);
91
88
  };
92
89
 
93
90
  const write_escaped =
@@ -238,25 +235,35 @@ export namespace SdkTypeProgrammer {
238
235
  (importer: ImportDictionary) =>
239
236
  (properties: MetadataProperty[]): ts.TypeLiteralNode =>
240
237
  ts.factory.createTypeLiteralNode(
241
- properties.map((p) =>
242
- FilePrinter.description(
243
- ts.factory.createPropertySignature(
244
- undefined,
245
- Escaper.variable(String(p.key.constants[0].values[0].value))
246
- ? ts.factory.createIdentifier(
247
- String(p.key.constants[0].values[0].value),
248
- )
249
- : ts.factory.createStringLiteral(
250
- String(p.key.constants[0].values[0].value),
251
- ),
252
- p.value.isRequired() === false
253
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
254
- : undefined,
255
- SdkTypeProgrammer.write(project)(importer)(p.value),
256
- ),
257
- writeComment(p.value.atomics)(p.description, p.jsDocTags),
258
- ),
259
- ),
238
+ properties
239
+ .map((p) => {
240
+ const description: string = writeComment(p.value.atomics)(
241
+ p.description,
242
+ p.jsDocTags,
243
+ );
244
+ const signature: ts.PropertySignature =
245
+ ts.factory.createPropertySignature(
246
+ undefined,
247
+ Escaper.variable(String(p.key.constants[0].values[0].value))
248
+ ? ts.factory.createIdentifier(
249
+ String(p.key.constants[0].values[0].value),
250
+ )
251
+ : ts.factory.createStringLiteral(
252
+ String(p.key.constants[0].values[0].value),
253
+ ),
254
+ p.value.isRequired() === false
255
+ ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
256
+ : undefined,
257
+ SdkTypeProgrammer.write(project)(importer)(p.value),
258
+ );
259
+ return !!description.length
260
+ ? [
261
+ ts.factory.createIdentifier("\n") as any,
262
+ FilePrinter.description(signature, description),
263
+ ]
264
+ : signature;
265
+ })
266
+ .flat(),
260
267
  );
261
268
 
262
269
  const write_dynamic_property =