@aws/nx-plugin 1.0.0-rc.30 → 1.0.0-rc.32

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 (59) hide show
  1. package/LICENSE-THIRD-PARTY +235 -1336
  2. package/README.md +1 -1
  3. package/package.json +1 -2
  4. package/src/mcp-server/tools/create-workspace-command.js +2 -2
  5. package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
  6. package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +147 -33
  7. package/src/open-api/ts-client/__snapshots__/generator.arrays.spec.ts.snap +308 -75
  8. package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +286 -62
  9. package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +674 -93
  10. package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +211 -36
  11. package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +196 -44
  12. package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5507 -0
  13. package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +219 -60
  14. package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +280 -0
  15. package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +351 -80
  16. package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
  17. package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
  18. package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
  19. package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
  20. package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
  21. package/src/open-api/ts-client/files/client.gen.ts.template +166 -19
  22. package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
  23. package/src/open-api/ts-client/generator.js +1 -1
  24. package/src/open-api/ts-client/generator.js.map +1 -1
  25. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
  26. package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
  27. package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
  28. package/src/open-api/utils/codegen-data/languages.js +23 -18
  29. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  30. package/src/open-api/utils/codegen-data/types.d.ts +240 -10
  31. package/src/open-api/utils/codegen-data/types.js +24 -1
  32. package/src/open-api/utils/codegen-data/types.js.map +1 -1
  33. package/src/open-api/utils/codegen-data.d.ts +2 -2
  34. package/src/open-api/utils/codegen-data.js +357 -617
  35. package/src/open-api/utils/codegen-data.js.map +1 -1
  36. package/src/open-api/utils/normalise.js +167 -22
  37. package/src/open-api/utils/normalise.js.map +1 -1
  38. package/src/open-api/utils/parser.d.ts +55 -0
  39. package/src/open-api/utils/parser.js +754 -0
  40. package/src/open-api/utils/parser.js.map +1 -0
  41. package/src/open-api/utils/types.d.ts +18 -0
  42. package/src/open-api/utils/types.js.map +1 -1
  43. package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
  44. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +414 -6
  45. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +276 -4
  46. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +414 -6
  47. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +0 -23
  48. package/src/ts/mcp-server/generator.js +10 -22
  49. package/src/ts/mcp-server/generator.js.map +1 -1
  50. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
  51. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
  52. package/src/utils/mcp.js +1 -1
  53. package/src/utils/mcp.js.map +1 -1
  54. package/src/utils/names.d.ts +6 -0
  55. package/src/utils/names.js +6 -1
  56. package/src/utils/names.js.map +1 -1
  57. package/src/utils/versions.d.ts +5 -5
  58. package/src/utils/versions.js +4 -4
  59. package/src/utils/versions.js.map +1 -1
@@ -47,7 +47,7 @@ exports[`openApiTsClientGenerator - requests > should generate valid TypeScript
47
47
  * Utility for serialisation and deserialisation of API types.
48
48
  */
49
49
  export class $IO {
50
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
50
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
51
51
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
52
52
 
53
53
  public static GetTest200Response = {
@@ -226,11 +226,31 @@ export class TestApi {
226
226
  this.getTest = this.getTest.bind(this);
227
227
  }
228
228
 
229
+ private $collectionDelimiters: { [format: string]: string } = {
230
+ csv: ',',
231
+ ssv: ' ',
232
+ pipes: '|',
233
+ };
234
+
235
+ private $deepObject = (key: string, value: any): string[] => {
236
+ if (value === undefined || value === null) {
237
+ return [];
238
+ }
239
+ if (typeof value !== 'object') {
240
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
241
+ }
242
+ return Object.entries(value).flatMap(([prop, v]) =>
243
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
244
+ );
245
+ };
246
+
229
247
  private $url = (
230
248
  path: string,
231
249
  pathParameters: { [key: string]: any },
232
250
  queryParameters: { [key: string]: any },
233
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
251
+ collectionFormats?: {
252
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
253
+ },
234
254
  ): string => {
235
255
  const baseUrl = this.$config.url.endsWith('/')
236
256
  ? this.$config.url.slice(0, -1)
@@ -241,15 +261,24 @@ export class TestApi {
241
261
  path,
242
262
  );
243
263
  const queryString = Object.entries(queryParameters)
244
- .map(([key, value]) => {
264
+ .flatMap(([key, value]) => {
245
265
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
246
- return value
247
- .map(
248
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
249
- )
250
- .join('&');
266
+ return value.map(
267
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
268
+ );
251
269
  }
252
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
270
+ if (
271
+ collectionFormats?.[key] === 'deepObject' &&
272
+ value !== null &&
273
+ typeof value === 'object'
274
+ ) {
275
+ return this.$deepObject(encodeURIComponent(key), value);
276
+ }
277
+ const delimiter =
278
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
279
+ return [
280
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
281
+ ];
253
282
  })
254
283
  .join('&');
255
284
  return (
@@ -259,13 +288,22 @@ export class TestApi {
259
288
 
260
289
  private $headers = (
261
290
  headerParameters: { [key: string]: any },
262
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
291
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
263
292
  ): [string, string][] => {
264
293
  return Object.entries(headerParameters).flatMap(([key, value]) => {
265
294
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
266
295
  return value.map((v) => [key, String(v)]) as [string, string][];
267
296
  }
268
- return [[key, String(value)]];
297
+ const delimiter =
298
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
299
+ return [
300
+ [
301
+ key,
302
+ Array.isArray(value)
303
+ ? value.map(String).join(delimiter)
304
+ : String(value),
305
+ ],
306
+ ];
269
307
  });
270
308
  };
271
309
 
@@ -279,11 +317,13 @@ export class TestApi {
279
317
  $IO.GetTestRequestQueryParameters.toJson(input);
280
318
  const headerParameters: { [key: string]: any } =
281
319
  $IO.GetTestRequestHeaderParameters.toJson(input);
282
- const collectionFormats = {
283
- 'x-api-key': 'csv',
320
+ const queryCollectionFormats = {
284
321
  filter: 'multi',
285
322
  tags: 'multi',
286
323
  } as const;
324
+ const headerCollectionFormats = {
325
+ 'x-api-key': 'csv',
326
+ } as const;
287
327
 
288
328
  const body = undefined;
289
329
 
@@ -292,10 +332,10 @@ export class TestApi {
292
332
  '/test/{id}',
293
333
  pathParameters,
294
334
  queryParameters,
295
- collectionFormats,
335
+ queryCollectionFormats,
296
336
  ),
297
337
  {
298
- headers: this.$headers(headerParameters, collectionFormats),
338
+ headers: this.$headers(headerParameters, headerCollectionFormats),
299
339
  method: 'GET',
300
340
  body,
301
341
  },
@@ -389,7 +429,7 @@ exports[`openApiTsClientGenerator - requests > should handle operations with sim
389
429
  * Utility for serialisation and deserialisation of API types.
390
430
  */
391
431
  export class $IO {
392
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
432
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
393
433
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
394
434
 
395
435
  public static PostBooleanWithQueryRequestBodyParameters = {
@@ -598,11 +638,31 @@ export class TestApi {
598
638
  this.postStringWithQuery = this.postStringWithQuery.bind(this);
599
639
  }
600
640
 
641
+ private $collectionDelimiters: { [format: string]: string } = {
642
+ csv: ',',
643
+ ssv: ' ',
644
+ pipes: '|',
645
+ };
646
+
647
+ private $deepObject = (key: string, value: any): string[] => {
648
+ if (value === undefined || value === null) {
649
+ return [];
650
+ }
651
+ if (typeof value !== 'object') {
652
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
653
+ }
654
+ return Object.entries(value).flatMap(([prop, v]) =>
655
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
656
+ );
657
+ };
658
+
601
659
  private $url = (
602
660
  path: string,
603
661
  pathParameters: { [key: string]: any },
604
662
  queryParameters: { [key: string]: any },
605
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
663
+ collectionFormats?: {
664
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
665
+ },
606
666
  ): string => {
607
667
  const baseUrl = this.$config.url.endsWith('/')
608
668
  ? this.$config.url.slice(0, -1)
@@ -613,15 +673,24 @@ export class TestApi {
613
673
  path,
614
674
  );
615
675
  const queryString = Object.entries(queryParameters)
616
- .map(([key, value]) => {
676
+ .flatMap(([key, value]) => {
617
677
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
618
- return value
619
- .map(
620
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
621
- )
622
- .join('&');
678
+ return value.map(
679
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
680
+ );
681
+ }
682
+ if (
683
+ collectionFormats?.[key] === 'deepObject' &&
684
+ value !== null &&
685
+ typeof value === 'object'
686
+ ) {
687
+ return this.$deepObject(encodeURIComponent(key), value);
623
688
  }
624
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
689
+ const delimiter =
690
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
691
+ return [
692
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
693
+ ];
625
694
  })
626
695
  .join('&');
627
696
  return (
@@ -631,13 +700,22 @@ export class TestApi {
631
700
 
632
701
  private $headers = (
633
702
  headerParameters: { [key: string]: any },
634
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
703
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
635
704
  ): [string, string][] => {
636
705
  return Object.entries(headerParameters).flatMap(([key, value]) => {
637
706
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
638
707
  return value.map((v) => [key, String(v)]) as [string, string][];
639
708
  }
640
- return [[key, String(value)]];
709
+ const delimiter =
710
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
711
+ return [
712
+ [
713
+ key,
714
+ Array.isArray(value)
715
+ ? value.map(String).join(delimiter)
716
+ : String(value),
717
+ ],
718
+ ];
641
719
  });
642
720
  };
643
721
 
@@ -680,7 +758,7 @@ export class TestApi {
680
758
  if (!this.$config.options?.omitContentTypeHeader) {
681
759
  headerParameters['Content-Type'] = 'application/json';
682
760
  }
683
- const collectionFormats = {
761
+ const queryCollectionFormats = {
684
762
  filter: 'multi',
685
763
  } as const;
686
764
  const body = input === undefined ? undefined : String(input.body);
@@ -690,10 +768,10 @@ export class TestApi {
690
768
  '/boolean-with-query',
691
769
  pathParameters,
692
770
  queryParameters,
693
- collectionFormats,
771
+ queryCollectionFormats,
694
772
  ),
695
773
  {
696
- headers: this.$headers(headerParameters, collectionFormats),
774
+ headers: this.$headers(headerParameters),
697
775
  method: 'POST',
698
776
  body,
699
777
  },
@@ -743,7 +821,7 @@ export class TestApi {
743
821
  if (!this.$config.options?.omitContentTypeHeader) {
744
822
  headerParameters['Content-Type'] = 'application/json';
745
823
  }
746
- const collectionFormats = {
824
+ const queryCollectionFormats = {
747
825
  filter: 'multi',
748
826
  } as const;
749
827
  const body = input === undefined ? undefined : String(input.body);
@@ -753,10 +831,10 @@ export class TestApi {
753
831
  '/number-with-query',
754
832
  pathParameters,
755
833
  queryParameters,
756
- collectionFormats,
834
+ queryCollectionFormats,
757
835
  ),
758
836
  {
759
- headers: this.$headers(headerParameters, collectionFormats),
837
+ headers: this.$headers(headerParameters),
760
838
  method: 'POST',
761
839
  body,
762
840
  },
@@ -806,7 +884,7 @@ export class TestApi {
806
884
  if (!this.$config.options?.omitContentTypeHeader) {
807
885
  headerParameters['Content-Type'] = 'application/json';
808
886
  }
809
- const collectionFormats = {
887
+ const queryCollectionFormats = {
810
888
  filter: 'multi',
811
889
  } as const;
812
890
  const body = input === undefined ? undefined : String(input.body);
@@ -816,10 +894,10 @@ export class TestApi {
816
894
  '/string-with-query',
817
895
  pathParameters,
818
896
  queryParameters,
819
- collectionFormats,
897
+ queryCollectionFormats,
820
898
  ),
821
899
  {
822
- headers: this.$headers(headerParameters, collectionFormats),
900
+ headers: this.$headers(headerParameters),
823
901
  method: 'POST',
824
902
  body,
825
903
  },
@@ -874,7 +952,7 @@ exports[`openApiTsClientGenerator - requests > should handle request body proper
874
952
  * Utility for serialisation and deserialisation of API types.
875
953
  */
876
954
  export class $IO {
877
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
955
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
878
956
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
879
957
 
880
958
  public static PostTest200Response = {
@@ -1053,11 +1131,31 @@ export class TestApi {
1053
1131
  this.postTest = this.postTest.bind(this);
1054
1132
  }
1055
1133
 
1134
+ private $collectionDelimiters: { [format: string]: string } = {
1135
+ csv: ',',
1136
+ ssv: ' ',
1137
+ pipes: '|',
1138
+ };
1139
+
1140
+ private $deepObject = (key: string, value: any): string[] => {
1141
+ if (value === undefined || value === null) {
1142
+ return [];
1143
+ }
1144
+ if (typeof value !== 'object') {
1145
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
1146
+ }
1147
+ return Object.entries(value).flatMap(([prop, v]) =>
1148
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
1149
+ );
1150
+ };
1151
+
1056
1152
  private $url = (
1057
1153
  path: string,
1058
1154
  pathParameters: { [key: string]: any },
1059
1155
  queryParameters: { [key: string]: any },
1060
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1156
+ collectionFormats?: {
1157
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
1158
+ },
1061
1159
  ): string => {
1062
1160
  const baseUrl = this.$config.url.endsWith('/')
1063
1161
  ? this.$config.url.slice(0, -1)
@@ -1068,15 +1166,24 @@ export class TestApi {
1068
1166
  path,
1069
1167
  );
1070
1168
  const queryString = Object.entries(queryParameters)
1071
- .map(([key, value]) => {
1169
+ .flatMap(([key, value]) => {
1072
1170
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1073
- return value
1074
- .map(
1075
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1076
- )
1077
- .join('&');
1171
+ return value.map(
1172
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1173
+ );
1078
1174
  }
1079
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
1175
+ if (
1176
+ collectionFormats?.[key] === 'deepObject' &&
1177
+ value !== null &&
1178
+ typeof value === 'object'
1179
+ ) {
1180
+ return this.$deepObject(encodeURIComponent(key), value);
1181
+ }
1182
+ const delimiter =
1183
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1184
+ return [
1185
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
1186
+ ];
1080
1187
  })
1081
1188
  .join('&');
1082
1189
  return (
@@ -1086,13 +1193,22 @@ export class TestApi {
1086
1193
 
1087
1194
  private $headers = (
1088
1195
  headerParameters: { [key: string]: any },
1089
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1196
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
1090
1197
  ): [string, string][] => {
1091
1198
  return Object.entries(headerParameters).flatMap(([key, value]) => {
1092
1199
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1093
1200
  return value.map((v) => [key, String(v)]) as [string, string][];
1094
1201
  }
1095
- return [[key, String(value)]];
1202
+ const delimiter =
1203
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1204
+ return [
1205
+ [
1206
+ key,
1207
+ Array.isArray(value)
1208
+ ? value.map(String).join(delimiter)
1209
+ : String(value),
1210
+ ],
1211
+ ];
1096
1212
  });
1097
1213
  };
1098
1214
 
@@ -1107,7 +1223,7 @@ export class TestApi {
1107
1223
  if (!this.$config.options?.omitContentTypeHeader) {
1108
1224
  headerParameters['Content-Type'] = 'application/json';
1109
1225
  }
1110
- const collectionFormats = {
1226
+ const queryCollectionFormats = {
1111
1227
  filter: 'multi',
1112
1228
  } as const;
1113
1229
  const body =
@@ -1118,9 +1234,14 @@ export class TestApi {
1118
1234
  : String($IO.PostTestRequestBodyParameters.toJson(input).body);
1119
1235
 
1120
1236
  const response = await this.$fetch(
1121
- this.$url('/test', pathParameters, queryParameters, collectionFormats),
1237
+ this.$url(
1238
+ '/test',
1239
+ pathParameters,
1240
+ queryParameters,
1241
+ queryCollectionFormats,
1242
+ ),
1122
1243
  {
1123
- headers: this.$headers(headerParameters, collectionFormats),
1244
+ headers: this.$headers(headerParameters),
1124
1245
  method: 'POST',
1125
1246
  body,
1126
1247
  },
@@ -94,7 +94,7 @@ exports[`openApiTsClientGenerator - reserved keywords > should handle reserved T
94
94
  * Utility for serialisation and deserialisation of API types.
95
95
  */
96
96
  export class $IO {
97
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
97
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
98
98
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
99
99
 
100
100
  public static _Array = {
@@ -648,11 +648,31 @@ export class TestApi {
648
648
  this.testReservedModels = this.testReservedModels.bind(this);
649
649
  }
650
650
 
651
+ private $collectionDelimiters: { [format: string]: string } = {
652
+ csv: ',',
653
+ ssv: ' ',
654
+ pipes: '|',
655
+ };
656
+
657
+ private $deepObject = (key: string, value: any): string[] => {
658
+ if (value === undefined || value === null) {
659
+ return [];
660
+ }
661
+ if (typeof value !== 'object') {
662
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
663
+ }
664
+ return Object.entries(value).flatMap(([prop, v]) =>
665
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
666
+ );
667
+ };
668
+
651
669
  private $url = (
652
670
  path: string,
653
671
  pathParameters: { [key: string]: any },
654
672
  queryParameters: { [key: string]: any },
655
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
673
+ collectionFormats?: {
674
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
675
+ },
656
676
  ): string => {
657
677
  const baseUrl = this.$config.url.endsWith('/')
658
678
  ? this.$config.url.slice(0, -1)
@@ -663,15 +683,24 @@ export class TestApi {
663
683
  path,
664
684
  );
665
685
  const queryString = Object.entries(queryParameters)
666
- .map(([key, value]) => {
686
+ .flatMap(([key, value]) => {
667
687
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
668
- return value
669
- .map(
670
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
671
- )
672
- .join('&');
688
+ return value.map(
689
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
690
+ );
691
+ }
692
+ if (
693
+ collectionFormats?.[key] === 'deepObject' &&
694
+ value !== null &&
695
+ typeof value === 'object'
696
+ ) {
697
+ return this.$deepObject(encodeURIComponent(key), value);
673
698
  }
674
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
699
+ const delimiter =
700
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
701
+ return [
702
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
703
+ ];
675
704
  })
676
705
  .join('&');
677
706
  return (
@@ -681,13 +710,22 @@ export class TestApi {
681
710
 
682
711
  private $headers = (
683
712
  headerParameters: { [key: string]: any },
684
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
713
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
685
714
  ): [string, string][] => {
686
715
  return Object.entries(headerParameters).flatMap(([key, value]) => {
687
716
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
688
717
  return value.map((v) => [key, String(v)]) as [string, string][];
689
718
  }
690
- return [[key, String(value)]];
719
+ const delimiter =
720
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
721
+ return [
722
+ [
723
+ key,
724
+ Array.isArray(value)
725
+ ? value.map(String).join(delimiter)
726
+ : String(value),
727
+ ],
728
+ ];
691
729
  });
692
730
  };
693
731
 
@@ -885,7 +923,7 @@ exports[`openApiTsClientGenerator - reserved keywords > should handle reserved l
885
923
  * Utility for serialisation and deserialisation of API types.
886
924
  */
887
925
  export class $IO {
888
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
926
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
889
927
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
890
928
 
891
929
  public static As = {
@@ -2078,11 +2116,31 @@ export class TestApi {
2078
2116
  this.op = this.op.bind(this);
2079
2117
  }
2080
2118
 
2119
+ private $collectionDelimiters: { [format: string]: string } = {
2120
+ csv: ',',
2121
+ ssv: ' ',
2122
+ pipes: '|',
2123
+ };
2124
+
2125
+ private $deepObject = (key: string, value: any): string[] => {
2126
+ if (value === undefined || value === null) {
2127
+ return [];
2128
+ }
2129
+ if (typeof value !== 'object') {
2130
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
2131
+ }
2132
+ return Object.entries(value).flatMap(([prop, v]) =>
2133
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
2134
+ );
2135
+ };
2136
+
2081
2137
  private $url = (
2082
2138
  path: string,
2083
2139
  pathParameters: { [key: string]: any },
2084
2140
  queryParameters: { [key: string]: any },
2085
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
2141
+ collectionFormats?: {
2142
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
2143
+ },
2086
2144
  ): string => {
2087
2145
  const baseUrl = this.$config.url.endsWith('/')
2088
2146
  ? this.$config.url.slice(0, -1)
@@ -2093,15 +2151,24 @@ export class TestApi {
2093
2151
  path,
2094
2152
  );
2095
2153
  const queryString = Object.entries(queryParameters)
2096
- .map(([key, value]) => {
2154
+ .flatMap(([key, value]) => {
2097
2155
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
2098
- return value
2099
- .map(
2100
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
2101
- )
2102
- .join('&');
2156
+ return value.map(
2157
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
2158
+ );
2159
+ }
2160
+ if (
2161
+ collectionFormats?.[key] === 'deepObject' &&
2162
+ value !== null &&
2163
+ typeof value === 'object'
2164
+ ) {
2165
+ return this.$deepObject(encodeURIComponent(key), value);
2103
2166
  }
2104
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
2167
+ const delimiter =
2168
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
2169
+ return [
2170
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
2171
+ ];
2105
2172
  })
2106
2173
  .join('&');
2107
2174
  return (
@@ -2111,13 +2178,22 @@ export class TestApi {
2111
2178
 
2112
2179
  private $headers = (
2113
2180
  headerParameters: { [key: string]: any },
2114
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
2181
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
2115
2182
  ): [string, string][] => {
2116
2183
  return Object.entries(headerParameters).flatMap(([key, value]) => {
2117
2184
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
2118
2185
  return value.map((v) => [key, String(v)]) as [string, string][];
2119
2186
  }
2120
- return [[key, String(value)]];
2187
+ const delimiter =
2188
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
2189
+ return [
2190
+ [
2191
+ key,
2192
+ Array.isArray(value)
2193
+ ? value.map(String).join(delimiter)
2194
+ : String(value),
2195
+ ],
2196
+ ];
2121
2197
  });
2122
2198
  };
2123
2199