@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
@@ -33,7 +33,7 @@ exports[`openApiTsClientGenerator - complex types > should generate valid TypeSc
33
33
  * Utility for serialisation and deserialisation of API types.
34
34
  */
35
35
  export class $IO {
36
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
36
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
37
37
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
38
38
 
39
39
  public static PostTest200ResponseItem = {
@@ -200,11 +200,31 @@ export class TestApi {
200
200
  this.postTest = this.postTest.bind(this);
201
201
  }
202
202
 
203
+ private $collectionDelimiters: { [format: string]: string } = {
204
+ csv: ',',
205
+ ssv: ' ',
206
+ pipes: '|',
207
+ };
208
+
209
+ private $deepObject = (key: string, value: any): string[] => {
210
+ if (value === undefined || value === null) {
211
+ return [];
212
+ }
213
+ if (typeof value !== 'object') {
214
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
215
+ }
216
+ return Object.entries(value).flatMap(([prop, v]) =>
217
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
218
+ );
219
+ };
220
+
203
221
  private $url = (
204
222
  path: string,
205
223
  pathParameters: { [key: string]: any },
206
224
  queryParameters: { [key: string]: any },
207
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
225
+ collectionFormats?: {
226
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
227
+ },
208
228
  ): string => {
209
229
  const baseUrl = this.$config.url.endsWith('/')
210
230
  ? this.$config.url.slice(0, -1)
@@ -215,15 +235,24 @@ export class TestApi {
215
235
  path,
216
236
  );
217
237
  const queryString = Object.entries(queryParameters)
218
- .map(([key, value]) => {
238
+ .flatMap(([key, value]) => {
219
239
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
220
- return value
221
- .map(
222
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
223
- )
224
- .join('&');
240
+ return value.map(
241
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
242
+ );
243
+ }
244
+ if (
245
+ collectionFormats?.[key] === 'deepObject' &&
246
+ value !== null &&
247
+ typeof value === 'object'
248
+ ) {
249
+ return this.$deepObject(encodeURIComponent(key), value);
225
250
  }
226
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
251
+ const delimiter =
252
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
253
+ return [
254
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
255
+ ];
227
256
  })
228
257
  .join('&');
229
258
  return (
@@ -233,13 +262,22 @@ export class TestApi {
233
262
 
234
263
  private $headers = (
235
264
  headerParameters: { [key: string]: any },
236
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
265
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
237
266
  ): [string, string][] => {
238
267
  return Object.entries(headerParameters).flatMap(([key, value]) => {
239
268
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
240
269
  return value.map((v) => [key, String(v)]) as [string, string][];
241
270
  }
242
- return [[key, String(value)]];
271
+ const delimiter =
272
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
273
+ return [
274
+ [
275
+ key,
276
+ Array.isArray(value)
277
+ ? value.map(String).join(delimiter)
278
+ : String(value),
279
+ ],
280
+ ];
243
281
  });
244
282
  };
245
283
 
@@ -332,7 +370,10 @@ export type TestNullableRequestQueryParameters = {
332
370
  queryInteger?: number | null;
333
371
  queryBoolean?: boolean | null;
334
372
  queryArray?: Array<string> | null;
335
- queryObject?: unknown | null;
373
+ queryObject?: TestNullableRequestQueryQueryObject;
374
+ };
375
+ export type TestNullableRequestQueryQueryObject = null | {
376
+ key?: string;
336
377
  };
337
378
 
338
379
  export type PostSingleNullableArrayRequest = Array<string> | undefined;
@@ -370,6 +411,7 @@ exports[`openApiTsClientGenerator - complex types > should handle nullable schem
370
411
  TestNullableRequestContentObjectWithNullablePropsNullableObject,
371
412
  TestNullableRequestPathParameters,
372
413
  TestNullableRequestQueryParameters,
414
+ TestNullableRequestQueryQueryObject,
373
415
  PostSingleNullableArrayRequest,
374
416
  PostSingleNullableBooleanRequest,
375
417
  PostSingleNullableNumberRequest,
@@ -382,7 +424,7 @@ exports[`openApiTsClientGenerator - complex types > should handle nullable schem
382
424
  * Utility for serialisation and deserialisation of API types.
383
425
  */
384
426
  export class $IO {
385
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
427
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
386
428
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
387
429
 
388
430
  public static PostSingleNullableObjectRequestContent = {
@@ -851,7 +893,9 @@ export class $IO {
851
893
  ...(model.queryObject === undefined
852
894
  ? {}
853
895
  : {
854
- queryObject: model.queryObject,
896
+ queryObject: $IO.TestNullableRequestQueryQueryObject.toJson(
897
+ model.queryObject,
898
+ ),
855
899
  }),
856
900
  };
857
901
  },
@@ -893,8 +937,36 @@ export class $IO {
893
937
  ...(json['queryObject'] === undefined
894
938
  ? {}
895
939
  : {
896
- queryObject:
897
- json['queryObject'] === null ? null : json['queryObject'],
940
+ queryObject: $IO.TestNullableRequestQueryQueryObject.fromJson(
941
+ json['queryObject'],
942
+ ),
943
+ }),
944
+ };
945
+ },
946
+ };
947
+
948
+ public static TestNullableRequestQueryQueryObject = {
949
+ toJson: (model: TestNullableRequestQueryQueryObject): any => {
950
+ if (model === undefined || model === null) {
951
+ return model;
952
+ }
953
+ return {
954
+ ...(model.key === undefined
955
+ ? {}
956
+ : {
957
+ key: model.key,
958
+ }),
959
+ };
960
+ },
961
+ fromJson: (json: any): TestNullableRequestQueryQueryObject => {
962
+ if (json === undefined || json === null) {
963
+ return json;
964
+ }
965
+ return {
966
+ ...(json['key'] === undefined
967
+ ? {}
968
+ : {
969
+ key: json['key'],
898
970
  }),
899
971
  };
900
972
  },
@@ -944,11 +1016,31 @@ export class TestApi {
944
1016
  this.testNullable = this.testNullable.bind(this);
945
1017
  }
946
1018
 
1019
+ private $collectionDelimiters: { [format: string]: string } = {
1020
+ csv: ',',
1021
+ ssv: ' ',
1022
+ pipes: '|',
1023
+ };
1024
+
1025
+ private $deepObject = (key: string, value: any): string[] => {
1026
+ if (value === undefined || value === null) {
1027
+ return [];
1028
+ }
1029
+ if (typeof value !== 'object') {
1030
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
1031
+ }
1032
+ return Object.entries(value).flatMap(([prop, v]) =>
1033
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
1034
+ );
1035
+ };
1036
+
947
1037
  private $url = (
948
1038
  path: string,
949
1039
  pathParameters: { [key: string]: any },
950
1040
  queryParameters: { [key: string]: any },
951
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1041
+ collectionFormats?: {
1042
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
1043
+ },
952
1044
  ): string => {
953
1045
  const baseUrl = this.$config.url.endsWith('/')
954
1046
  ? this.$config.url.slice(0, -1)
@@ -959,15 +1051,24 @@ export class TestApi {
959
1051
  path,
960
1052
  );
961
1053
  const queryString = Object.entries(queryParameters)
962
- .map(([key, value]) => {
1054
+ .flatMap(([key, value]) => {
963
1055
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
964
- return value
965
- .map(
966
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
967
- )
968
- .join('&');
1056
+ return value.map(
1057
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1058
+ );
1059
+ }
1060
+ if (
1061
+ collectionFormats?.[key] === 'deepObject' &&
1062
+ value !== null &&
1063
+ typeof value === 'object'
1064
+ ) {
1065
+ return this.$deepObject(encodeURIComponent(key), value);
969
1066
  }
970
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
1067
+ const delimiter =
1068
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1069
+ return [
1070
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
1071
+ ];
971
1072
  })
972
1073
  .join('&');
973
1074
  return (
@@ -977,13 +1078,22 @@ export class TestApi {
977
1078
 
978
1079
  private $headers = (
979
1080
  headerParameters: { [key: string]: any },
980
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1081
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
981
1082
  ): [string, string][] => {
982
1083
  return Object.entries(headerParameters).flatMap(([key, value]) => {
983
1084
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
984
1085
  return value.map((v) => [key, String(v)]) as [string, string][];
985
1086
  }
986
- return [[key, String(value)]];
1087
+ const delimiter =
1088
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1089
+ return [
1090
+ [
1091
+ key,
1092
+ Array.isArray(value)
1093
+ ? value.map(String).join(delimiter)
1094
+ : String(value),
1095
+ ],
1096
+ ];
987
1097
  });
988
1098
  };
989
1099
 
@@ -1151,7 +1261,7 @@ export class TestApi {
1151
1261
  if (!this.$config.options?.omitContentTypeHeader) {
1152
1262
  headerParameters['Content-Type'] = 'application/json';
1153
1263
  }
1154
- const collectionFormats = {
1264
+ const queryCollectionFormats = {
1155
1265
  queryString: 'multi',
1156
1266
  queryNumber: 'multi',
1157
1267
  queryInteger: 'multi',
@@ -1171,10 +1281,10 @@ export class TestApi {
1171
1281
  '/test/{pathParam}',
1172
1282
  pathParameters,
1173
1283
  queryParameters,
1174
- collectionFormats,
1284
+ queryCollectionFormats,
1175
1285
  ),
1176
1286
  {
1177
- headers: this.$headers(headerParameters, collectionFormats),
1287
+ headers: this.$headers(headerParameters),
1178
1288
  method: 'POST',
1179
1289
  body,
1180
1290
  },
@@ -1275,7 +1385,7 @@ exports[`openApiTsClientGenerator - complex types > should handle operations wit
1275
1385
  * Utility for serialisation and deserialisation of API types.
1276
1386
  */
1277
1387
  export class $IO {
1278
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
1388
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
1279
1389
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
1280
1390
 
1281
1391
  public static PostMapOfArraysOfObjectsRequestContent = {
@@ -1490,11 +1600,31 @@ export class TestApi {
1490
1600
  this.postMapOfObjects = this.postMapOfObjects.bind(this);
1491
1601
  }
1492
1602
 
1603
+ private $collectionDelimiters: { [format: string]: string } = {
1604
+ csv: ',',
1605
+ ssv: ' ',
1606
+ pipes: '|',
1607
+ };
1608
+
1609
+ private $deepObject = (key: string, value: any): string[] => {
1610
+ if (value === undefined || value === null) {
1611
+ return [];
1612
+ }
1613
+ if (typeof value !== 'object') {
1614
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
1615
+ }
1616
+ return Object.entries(value).flatMap(([prop, v]) =>
1617
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
1618
+ );
1619
+ };
1620
+
1493
1621
  private $url = (
1494
1622
  path: string,
1495
1623
  pathParameters: { [key: string]: any },
1496
1624
  queryParameters: { [key: string]: any },
1497
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1625
+ collectionFormats?: {
1626
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
1627
+ },
1498
1628
  ): string => {
1499
1629
  const baseUrl = this.$config.url.endsWith('/')
1500
1630
  ? this.$config.url.slice(0, -1)
@@ -1505,15 +1635,24 @@ export class TestApi {
1505
1635
  path,
1506
1636
  );
1507
1637
  const queryString = Object.entries(queryParameters)
1508
- .map(([key, value]) => {
1638
+ .flatMap(([key, value]) => {
1509
1639
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1510
- return value
1511
- .map(
1512
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1513
- )
1514
- .join('&');
1640
+ return value.map(
1641
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1642
+ );
1515
1643
  }
1516
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
1644
+ if (
1645
+ collectionFormats?.[key] === 'deepObject' &&
1646
+ value !== null &&
1647
+ typeof value === 'object'
1648
+ ) {
1649
+ return this.$deepObject(encodeURIComponent(key), value);
1650
+ }
1651
+ const delimiter =
1652
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1653
+ return [
1654
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
1655
+ ];
1517
1656
  })
1518
1657
  .join('&');
1519
1658
  return (
@@ -1523,13 +1662,22 @@ export class TestApi {
1523
1662
 
1524
1663
  private $headers = (
1525
1664
  headerParameters: { [key: string]: any },
1526
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1665
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
1527
1666
  ): [string, string][] => {
1528
1667
  return Object.entries(headerParameters).flatMap(([key, value]) => {
1529
1668
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1530
1669
  return value.map((v) => [key, String(v)]) as [string, string][];
1531
1670
  }
1532
- return [[key, String(value)]];
1671
+ const delimiter =
1672
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1673
+ return [
1674
+ [
1675
+ key,
1676
+ Array.isArray(value)
1677
+ ? value.map(String).join(delimiter)
1678
+ : String(value),
1679
+ ],
1680
+ ];
1533
1681
  });
1534
1682
  };
1535
1683
 
@@ -1796,7 +1944,7 @@ exports[`openApiTsClientGenerator - complex types > should handle recursive sche
1796
1944
  * Utility for serialisation and deserialisation of API types.
1797
1945
  */
1798
1946
  export class $IO {
1799
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
1947
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
1800
1948
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
1801
1949
 
1802
1950
  public static TreeNode = {
@@ -1880,11 +2028,31 @@ export class TestApi {
1880
2028
  this.getTree = this.getTree.bind(this);
1881
2029
  }
1882
2030
 
2031
+ private $collectionDelimiters: { [format: string]: string } = {
2032
+ csv: ',',
2033
+ ssv: ' ',
2034
+ pipes: '|',
2035
+ };
2036
+
2037
+ private $deepObject = (key: string, value: any): string[] => {
2038
+ if (value === undefined || value === null) {
2039
+ return [];
2040
+ }
2041
+ if (typeof value !== 'object') {
2042
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
2043
+ }
2044
+ return Object.entries(value).flatMap(([prop, v]) =>
2045
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
2046
+ );
2047
+ };
2048
+
1883
2049
  private $url = (
1884
2050
  path: string,
1885
2051
  pathParameters: { [key: string]: any },
1886
2052
  queryParameters: { [key: string]: any },
1887
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
2053
+ collectionFormats?: {
2054
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
2055
+ },
1888
2056
  ): string => {
1889
2057
  const baseUrl = this.$config.url.endsWith('/')
1890
2058
  ? this.$config.url.slice(0, -1)
@@ -1895,15 +2063,24 @@ export class TestApi {
1895
2063
  path,
1896
2064
  );
1897
2065
  const queryString = Object.entries(queryParameters)
1898
- .map(([key, value]) => {
2066
+ .flatMap(([key, value]) => {
1899
2067
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1900
- return value
1901
- .map(
1902
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1903
- )
1904
- .join('&');
2068
+ return value.map(
2069
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
2070
+ );
1905
2071
  }
1906
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
2072
+ if (
2073
+ collectionFormats?.[key] === 'deepObject' &&
2074
+ value !== null &&
2075
+ typeof value === 'object'
2076
+ ) {
2077
+ return this.$deepObject(encodeURIComponent(key), value);
2078
+ }
2079
+ const delimiter =
2080
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
2081
+ return [
2082
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
2083
+ ];
1907
2084
  })
1908
2085
  .join('&');
1909
2086
  return (
@@ -1913,13 +2090,22 @@ export class TestApi {
1913
2090
 
1914
2091
  private $headers = (
1915
2092
  headerParameters: { [key: string]: any },
1916
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
2093
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
1917
2094
  ): [string, string][] => {
1918
2095
  return Object.entries(headerParameters).flatMap(([key, value]) => {
1919
2096
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1920
2097
  return value.map((v) => [key, String(v)]) as [string, string][];
1921
2098
  }
1922
- return [[key, String(value)]];
2099
+ const delimiter =
2100
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
2101
+ return [
2102
+ [
2103
+ key,
2104
+ Array.isArray(value)
2105
+ ? value.map(String).join(delimiter)
2106
+ : String(value),
2107
+ ],
2108
+ ];
1923
2109
  });
1924
2110
  };
1925
2111
 
@@ -2024,7 +2210,7 @@ exports[`openApiTsClientGenerator - complex types > should handle refs and hoist
2024
2210
  * Utility for serialisation and deserialisation of API types.
2025
2211
  */
2026
2212
  export class $IO {
2027
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
2213
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
2028
2214
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
2029
2215
 
2030
2216
  public static _Error = {
@@ -2210,11 +2396,31 @@ export class TestApi {
2210
2396
  this.postTest = this.postTest.bind(this);
2211
2397
  }
2212
2398
 
2399
+ private $collectionDelimiters: { [format: string]: string } = {
2400
+ csv: ',',
2401
+ ssv: ' ',
2402
+ pipes: '|',
2403
+ };
2404
+
2405
+ private $deepObject = (key: string, value: any): string[] => {
2406
+ if (value === undefined || value === null) {
2407
+ return [];
2408
+ }
2409
+ if (typeof value !== 'object') {
2410
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
2411
+ }
2412
+ return Object.entries(value).flatMap(([prop, v]) =>
2413
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
2414
+ );
2415
+ };
2416
+
2213
2417
  private $url = (
2214
2418
  path: string,
2215
2419
  pathParameters: { [key: string]: any },
2216
2420
  queryParameters: { [key: string]: any },
2217
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
2421
+ collectionFormats?: {
2422
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
2423
+ },
2218
2424
  ): string => {
2219
2425
  const baseUrl = this.$config.url.endsWith('/')
2220
2426
  ? this.$config.url.slice(0, -1)
@@ -2225,15 +2431,24 @@ export class TestApi {
2225
2431
  path,
2226
2432
  );
2227
2433
  const queryString = Object.entries(queryParameters)
2228
- .map(([key, value]) => {
2434
+ .flatMap(([key, value]) => {
2229
2435
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
2230
- return value
2231
- .map(
2232
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
2233
- )
2234
- .join('&');
2436
+ return value.map(
2437
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
2438
+ );
2439
+ }
2440
+ if (
2441
+ collectionFormats?.[key] === 'deepObject' &&
2442
+ value !== null &&
2443
+ typeof value === 'object'
2444
+ ) {
2445
+ return this.$deepObject(encodeURIComponent(key), value);
2235
2446
  }
2236
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
2447
+ const delimiter =
2448
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
2449
+ return [
2450
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
2451
+ ];
2237
2452
  })
2238
2453
  .join('&');
2239
2454
  return (
@@ -2243,13 +2458,22 @@ export class TestApi {
2243
2458
 
2244
2459
  private $headers = (
2245
2460
  headerParameters: { [key: string]: any },
2246
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
2461
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
2247
2462
  ): [string, string][] => {
2248
2463
  return Object.entries(headerParameters).flatMap(([key, value]) => {
2249
2464
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
2250
2465
  return value.map((v) => [key, String(v)]) as [string, string][];
2251
2466
  }
2252
- return [[key, String(value)]];
2467
+ const delimiter =
2468
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
2469
+ return [
2470
+ [
2471
+ key,
2472
+ Array.isArray(value)
2473
+ ? value.map(String).join(delimiter)
2474
+ : String(value),
2475
+ ],
2476
+ ];
2253
2477
  });
2254
2478
  };
2255
2479