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

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 (47) 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 +147 -33
  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.primitive-types.spec.ts.snap +351 -80
  15. package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
  16. package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
  17. package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
  18. package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
  19. package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
  20. package/src/open-api/ts-client/files/client.gen.ts.template +130 -18
  21. package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
  22. package/src/open-api/ts-client/generator.js +1 -1
  23. package/src/open-api/ts-client/generator.js.map +1 -1
  24. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
  25. package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
  26. package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
  27. package/src/open-api/utils/codegen-data/languages.js +23 -18
  28. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  29. package/src/open-api/utils/codegen-data/types.d.ts +240 -10
  30. package/src/open-api/utils/codegen-data/types.js +24 -1
  31. package/src/open-api/utils/codegen-data/types.js.map +1 -1
  32. package/src/open-api/utils/codegen-data.d.ts +2 -2
  33. package/src/open-api/utils/codegen-data.js +357 -617
  34. package/src/open-api/utils/codegen-data.js.map +1 -1
  35. package/src/open-api/utils/normalise.js +157 -19
  36. package/src/open-api/utils/normalise.js.map +1 -1
  37. package/src/open-api/utils/parser.d.ts +55 -0
  38. package/src/open-api/utils/parser.js +743 -0
  39. package/src/open-api/utils/parser.js.map +1 -0
  40. package/src/open-api/utils/types.d.ts +15 -0
  41. package/src/open-api/utils/types.js.map +1 -1
  42. package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
  43. package/src/utils/mcp.js +1 -1
  44. package/src/utils/mcp.js.map +1 -1
  45. package/src/utils/names.d.ts +6 -0
  46. package/src/utils/names.js +6 -1
  47. package/src/utils/names.js.map +1 -1
@@ -7,7 +7,7 @@ exports[`openApiTsClientGenerator - content type header > should not force Conte
7
7
  * Utility for serialisation and deserialisation of API types.
8
8
  */
9
9
  export class $IO {
10
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
10
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
11
11
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
12
12
  }
13
13
 
@@ -49,11 +49,31 @@ export class TestApi {
49
49
  this.postUpload = this.postUpload.bind(this);
50
50
  }
51
51
 
52
+ private $collectionDelimiters: { [format: string]: string } = {
53
+ csv: ',',
54
+ ssv: ' ',
55
+ pipes: '|',
56
+ };
57
+
58
+ private $deepObject = (key: string, value: any): string[] => {
59
+ if (value === undefined || value === null) {
60
+ return [];
61
+ }
62
+ if (typeof value !== 'object') {
63
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
64
+ }
65
+ return Object.entries(value).flatMap(([prop, v]) =>
66
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
67
+ );
68
+ };
69
+
52
70
  private $url = (
53
71
  path: string,
54
72
  pathParameters: { [key: string]: any },
55
73
  queryParameters: { [key: string]: any },
56
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
74
+ collectionFormats?: {
75
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
76
+ },
57
77
  ): string => {
58
78
  const baseUrl = this.$config.url.endsWith('/')
59
79
  ? this.$config.url.slice(0, -1)
@@ -64,15 +84,24 @@ export class TestApi {
64
84
  path,
65
85
  );
66
86
  const queryString = Object.entries(queryParameters)
67
- .map(([key, value]) => {
87
+ .flatMap(([key, value]) => {
68
88
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
69
- return value
70
- .map(
71
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
72
- )
73
- .join('&');
89
+ return value.map(
90
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
91
+ );
92
+ }
93
+ if (
94
+ collectionFormats?.[key] === 'deepObject' &&
95
+ value !== null &&
96
+ typeof value === 'object'
97
+ ) {
98
+ return this.$deepObject(encodeURIComponent(key), value);
74
99
  }
75
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
100
+ const delimiter =
101
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
102
+ return [
103
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
104
+ ];
76
105
  })
77
106
  .join('&');
78
107
  return (
@@ -82,13 +111,22 @@ export class TestApi {
82
111
 
83
112
  private $headers = (
84
113
  headerParameters: { [key: string]: any },
85
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
114
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
86
115
  ): [string, string][] => {
87
116
  return Object.entries(headerParameters).flatMap(([key, value]) => {
88
117
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
89
118
  return value.map((v) => [key, String(v)]) as [string, string][];
90
119
  }
91
- return [[key, String(value)]];
120
+ const delimiter =
121
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
122
+ return [
123
+ [
124
+ key,
125
+ Array.isArray(value)
126
+ ? value.map(String).join(delimiter)
127
+ : String(value),
128
+ ],
129
+ ];
92
130
  });
93
131
  };
94
132
 
@@ -134,7 +172,7 @@ exports[`openApiTsClientGenerator - content type header > should pick a single w
134
172
  * Utility for serialisation and deserialisation of API types.
135
173
  */
136
174
  export class $IO {
137
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
175
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
138
176
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
139
177
 
140
178
  public static PostMultiRequestContent = {
@@ -203,11 +241,31 @@ export class TestApi {
203
241
  this.postMulti = this.postMulti.bind(this);
204
242
  }
205
243
 
244
+ private $collectionDelimiters: { [format: string]: string } = {
245
+ csv: ',',
246
+ ssv: ' ',
247
+ pipes: '|',
248
+ };
249
+
250
+ private $deepObject = (key: string, value: any): string[] => {
251
+ if (value === undefined || value === null) {
252
+ return [];
253
+ }
254
+ if (typeof value !== 'object') {
255
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
256
+ }
257
+ return Object.entries(value).flatMap(([prop, v]) =>
258
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
259
+ );
260
+ };
261
+
206
262
  private $url = (
207
263
  path: string,
208
264
  pathParameters: { [key: string]: any },
209
265
  queryParameters: { [key: string]: any },
210
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
266
+ collectionFormats?: {
267
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
268
+ },
211
269
  ): string => {
212
270
  const baseUrl = this.$config.url.endsWith('/')
213
271
  ? this.$config.url.slice(0, -1)
@@ -218,15 +276,24 @@ export class TestApi {
218
276
  path,
219
277
  );
220
278
  const queryString = Object.entries(queryParameters)
221
- .map(([key, value]) => {
279
+ .flatMap(([key, value]) => {
222
280
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
223
- return value
224
- .map(
225
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
226
- )
227
- .join('&');
281
+ return value.map(
282
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
283
+ );
284
+ }
285
+ if (
286
+ collectionFormats?.[key] === 'deepObject' &&
287
+ value !== null &&
288
+ typeof value === 'object'
289
+ ) {
290
+ return this.$deepObject(encodeURIComponent(key), value);
228
291
  }
229
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
292
+ const delimiter =
293
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
294
+ return [
295
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
296
+ ];
230
297
  })
231
298
  .join('&');
232
299
  return (
@@ -236,13 +303,22 @@ export class TestApi {
236
303
 
237
304
  private $headers = (
238
305
  headerParameters: { [key: string]: any },
239
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
306
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
240
307
  ): [string, string][] => {
241
308
  return Object.entries(headerParameters).flatMap(([key, value]) => {
242
309
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
243
310
  return value.map((v) => [key, String(v)]) as [string, string][];
244
311
  }
245
- return [[key, String(value)]];
312
+ const delimiter =
313
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
314
+ return [
315
+ [
316
+ key,
317
+ Array.isArray(value)
318
+ ? value.map(String).join(delimiter)
319
+ : String(value),
320
+ ],
321
+ ];
246
322
  });
247
323
  };
248
324
 
@@ -301,7 +377,7 @@ exports[`openApiTsClientGenerator - content type header > should serialise cooki
301
377
  * Utility for serialisation and deserialisation of API types.
302
378
  */
303
379
  export class $IO {
304
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
380
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
305
381
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
306
382
 
307
383
  public static GetSecretRequestCookieParameters = {
@@ -380,11 +456,31 @@ export class TestApi {
380
456
  this.getSecret = this.getSecret.bind(this);
381
457
  }
382
458
 
459
+ private $collectionDelimiters: { [format: string]: string } = {
460
+ csv: ',',
461
+ ssv: ' ',
462
+ pipes: '|',
463
+ };
464
+
465
+ private $deepObject = (key: string, value: any): string[] => {
466
+ if (value === undefined || value === null) {
467
+ return [];
468
+ }
469
+ if (typeof value !== 'object') {
470
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
471
+ }
472
+ return Object.entries(value).flatMap(([prop, v]) =>
473
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
474
+ );
475
+ };
476
+
383
477
  private $url = (
384
478
  path: string,
385
479
  pathParameters: { [key: string]: any },
386
480
  queryParameters: { [key: string]: any },
387
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
481
+ collectionFormats?: {
482
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
483
+ },
388
484
  ): string => {
389
485
  const baseUrl = this.$config.url.endsWith('/')
390
486
  ? this.$config.url.slice(0, -1)
@@ -395,15 +491,24 @@ export class TestApi {
395
491
  path,
396
492
  );
397
493
  const queryString = Object.entries(queryParameters)
398
- .map(([key, value]) => {
494
+ .flatMap(([key, value]) => {
399
495
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
400
- return value
401
- .map(
402
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
403
- )
404
- .join('&');
496
+ return value.map(
497
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
498
+ );
499
+ }
500
+ if (
501
+ collectionFormats?.[key] === 'deepObject' &&
502
+ value !== null &&
503
+ typeof value === 'object'
504
+ ) {
505
+ return this.$deepObject(encodeURIComponent(key), value);
405
506
  }
406
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
507
+ const delimiter =
508
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
509
+ return [
510
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
511
+ ];
407
512
  })
408
513
  .join('&');
409
514
  return (
@@ -413,13 +518,22 @@ export class TestApi {
413
518
 
414
519
  private $headers = (
415
520
  headerParameters: { [key: string]: any },
416
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
521
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
417
522
  ): [string, string][] => {
418
523
  return Object.entries(headerParameters).flatMap(([key, value]) => {
419
524
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
420
525
  return value.map((v) => [key, String(v)]) as [string, string][];
421
526
  }
422
- return [[key, String(value)]];
527
+ const delimiter =
528
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
529
+ return [
530
+ [
531
+ key,
532
+ Array.isArray(value)
533
+ ? value.map(String).join(delimiter)
534
+ : String(value),
535
+ ],
536
+ ];
423
537
  });
424
538
  };
425
539
 
@@ -21,7 +21,7 @@ exports[`openApiTsClientGenerator - duplicate types > should handle duplicated m
21
21
  * Utility for serialisation and deserialisation of API types.
22
22
  */
23
23
  export class $IO {
24
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
24
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
25
25
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
26
26
 
27
27
  public static Clash = {
@@ -134,11 +134,31 @@ export class TestApi {
134
134
  this.operation = this.operation.bind(this);
135
135
  }
136
136
 
137
+ private $collectionDelimiters: { [format: string]: string } = {
138
+ csv: ',',
139
+ ssv: ' ',
140
+ pipes: '|',
141
+ };
142
+
143
+ private $deepObject = (key: string, value: any): string[] => {
144
+ if (value === undefined || value === null) {
145
+ return [];
146
+ }
147
+ if (typeof value !== 'object') {
148
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
149
+ }
150
+ return Object.entries(value).flatMap(([prop, v]) =>
151
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
152
+ );
153
+ };
154
+
137
155
  private $url = (
138
156
  path: string,
139
157
  pathParameters: { [key: string]: any },
140
158
  queryParameters: { [key: string]: any },
141
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
159
+ collectionFormats?: {
160
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
161
+ },
142
162
  ): string => {
143
163
  const baseUrl = this.$config.url.endsWith('/')
144
164
  ? this.$config.url.slice(0, -1)
@@ -149,15 +169,24 @@ export class TestApi {
149
169
  path,
150
170
  );
151
171
  const queryString = Object.entries(queryParameters)
152
- .map(([key, value]) => {
172
+ .flatMap(([key, value]) => {
153
173
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
154
- return value
155
- .map(
156
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
157
- )
158
- .join('&');
174
+ return value.map(
175
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
176
+ );
177
+ }
178
+ if (
179
+ collectionFormats?.[key] === 'deepObject' &&
180
+ value !== null &&
181
+ typeof value === 'object'
182
+ ) {
183
+ return this.$deepObject(encodeURIComponent(key), value);
159
184
  }
160
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
185
+ const delimiter =
186
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
187
+ return [
188
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
189
+ ];
161
190
  })
162
191
  .join('&');
163
192
  return (
@@ -167,13 +196,22 @@ export class TestApi {
167
196
 
168
197
  private $headers = (
169
198
  headerParameters: { [key: string]: any },
170
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
199
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
171
200
  ): [string, string][] => {
172
201
  return Object.entries(headerParameters).flatMap(([key, value]) => {
173
202
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
174
203
  return value.map((v) => [key, String(v)]) as [string, string][];
175
204
  }
176
- return [[key, String(value)]];
205
+ const delimiter =
206
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
207
+ return [
208
+ [
209
+ key,
210
+ Array.isArray(value)
211
+ ? value.map(String).join(delimiter)
212
+ : String(value),
213
+ ],
214
+ ];
177
215
  });
178
216
  };
179
217
 
@@ -252,7 +290,7 @@ exports[`openApiTsClientGenerator - duplicate types > should handle many duplica
252
290
  * Utility for serialisation and deserialisation of API types.
253
291
  */
254
292
  export class $IO {
255
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
293
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
256
294
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
257
295
 
258
296
  public static AnotherModel = {
@@ -451,11 +489,31 @@ export class TestApi {
451
489
  this.operation = this.operation.bind(this);
452
490
  }
453
491
 
492
+ private $collectionDelimiters: { [format: string]: string } = {
493
+ csv: ',',
494
+ ssv: ' ',
495
+ pipes: '|',
496
+ };
497
+
498
+ private $deepObject = (key: string, value: any): string[] => {
499
+ if (value === undefined || value === null) {
500
+ return [];
501
+ }
502
+ if (typeof value !== 'object') {
503
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
504
+ }
505
+ return Object.entries(value).flatMap(([prop, v]) =>
506
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
507
+ );
508
+ };
509
+
454
510
  private $url = (
455
511
  path: string,
456
512
  pathParameters: { [key: string]: any },
457
513
  queryParameters: { [key: string]: any },
458
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
514
+ collectionFormats?: {
515
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
516
+ },
459
517
  ): string => {
460
518
  const baseUrl = this.$config.url.endsWith('/')
461
519
  ? this.$config.url.slice(0, -1)
@@ -466,15 +524,24 @@ export class TestApi {
466
524
  path,
467
525
  );
468
526
  const queryString = Object.entries(queryParameters)
469
- .map(([key, value]) => {
527
+ .flatMap(([key, value]) => {
470
528
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
471
- return value
472
- .map(
473
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
474
- )
475
- .join('&');
529
+ return value.map(
530
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
531
+ );
532
+ }
533
+ if (
534
+ collectionFormats?.[key] === 'deepObject' &&
535
+ value !== null &&
536
+ typeof value === 'object'
537
+ ) {
538
+ return this.$deepObject(encodeURIComponent(key), value);
476
539
  }
477
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
540
+ const delimiter =
541
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
542
+ return [
543
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
544
+ ];
478
545
  })
479
546
  .join('&');
480
547
  return (
@@ -484,13 +551,22 @@ export class TestApi {
484
551
 
485
552
  private $headers = (
486
553
  headerParameters: { [key: string]: any },
487
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
554
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
488
555
  ): [string, string][] => {
489
556
  return Object.entries(headerParameters).flatMap(([key, value]) => {
490
557
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
491
558
  return value.map((v) => [key, String(v)]) as [string, string][];
492
559
  }
493
- return [[key, String(value)]];
560
+ const delimiter =
561
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
562
+ return [
563
+ [
564
+ key,
565
+ Array.isArray(value)
566
+ ? value.map(String).join(delimiter)
567
+ : String(value),
568
+ ],
569
+ ];
494
570
  });
495
571
  };
496
572
 
@@ -557,7 +633,7 @@ exports[`openApiTsClientGenerator - duplicate types > should handle multiple ope
557
633
  * Utility for serialisation and deserialisation of API types.
558
634
  */
559
635
  export class $IO {
560
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
636
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
561
637
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
562
638
 
563
639
  public static OrderRequest = {
@@ -646,11 +722,31 @@ export class TestApi {
646
722
  this.user = this.user.bind(this);
647
723
  }
648
724
 
725
+ private $collectionDelimiters: { [format: string]: string } = {
726
+ csv: ',',
727
+ ssv: ' ',
728
+ pipes: '|',
729
+ };
730
+
731
+ private $deepObject = (key: string, value: any): string[] => {
732
+ if (value === undefined || value === null) {
733
+ return [];
734
+ }
735
+ if (typeof value !== 'object') {
736
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
737
+ }
738
+ return Object.entries(value).flatMap(([prop, v]) =>
739
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
740
+ );
741
+ };
742
+
649
743
  private $url = (
650
744
  path: string,
651
745
  pathParameters: { [key: string]: any },
652
746
  queryParameters: { [key: string]: any },
653
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
747
+ collectionFormats?: {
748
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
749
+ },
654
750
  ): string => {
655
751
  const baseUrl = this.$config.url.endsWith('/')
656
752
  ? this.$config.url.slice(0, -1)
@@ -661,15 +757,24 @@ export class TestApi {
661
757
  path,
662
758
  );
663
759
  const queryString = Object.entries(queryParameters)
664
- .map(([key, value]) => {
760
+ .flatMap(([key, value]) => {
665
761
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
666
- return value
667
- .map(
668
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
669
- )
670
- .join('&');
762
+ return value.map(
763
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
764
+ );
765
+ }
766
+ if (
767
+ collectionFormats?.[key] === 'deepObject' &&
768
+ value !== null &&
769
+ typeof value === 'object'
770
+ ) {
771
+ return this.$deepObject(encodeURIComponent(key), value);
671
772
  }
672
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
773
+ const delimiter =
774
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
775
+ return [
776
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
777
+ ];
673
778
  })
674
779
  .join('&');
675
780
  return (
@@ -679,13 +784,22 @@ export class TestApi {
679
784
 
680
785
  private $headers = (
681
786
  headerParameters: { [key: string]: any },
682
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
787
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
683
788
  ): [string, string][] => {
684
789
  return Object.entries(headerParameters).flatMap(([key, value]) => {
685
790
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
686
791
  return value.map((v) => [key, String(v)]) as [string, string][];
687
792
  }
688
- return [[key, String(value)]];
793
+ const delimiter =
794
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
795
+ return [
796
+ [
797
+ key,
798
+ Array.isArray(value)
799
+ ? value.map(String).join(delimiter)
800
+ : String(value),
801
+ ],
802
+ ];
689
803
  });
690
804
  };
691
805
 
@@ -770,7 +884,7 @@ exports[`openApiTsClientGenerator - duplicate types > should handle operation ID
770
884
  * Utility for serialisation and deserialisation of API types.
771
885
  */
772
886
  export class $IO {
773
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
887
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
774
888
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
775
889
 
776
890
  public static ChatRequest = {
@@ -835,11 +949,31 @@ export class TestApi {
835
949
  this.chat = this.chat.bind(this);
836
950
  }
837
951
 
952
+ private $collectionDelimiters: { [format: string]: string } = {
953
+ csv: ',',
954
+ ssv: ' ',
955
+ pipes: '|',
956
+ };
957
+
958
+ private $deepObject = (key: string, value: any): string[] => {
959
+ if (value === undefined || value === null) {
960
+ return [];
961
+ }
962
+ if (typeof value !== 'object') {
963
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
964
+ }
965
+ return Object.entries(value).flatMap(([prop, v]) =>
966
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
967
+ );
968
+ };
969
+
838
970
  private $url = (
839
971
  path: string,
840
972
  pathParameters: { [key: string]: any },
841
973
  queryParameters: { [key: string]: any },
842
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
974
+ collectionFormats?: {
975
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
976
+ },
843
977
  ): string => {
844
978
  const baseUrl = this.$config.url.endsWith('/')
845
979
  ? this.$config.url.slice(0, -1)
@@ -850,15 +984,24 @@ export class TestApi {
850
984
  path,
851
985
  );
852
986
  const queryString = Object.entries(queryParameters)
853
- .map(([key, value]) => {
987
+ .flatMap(([key, value]) => {
854
988
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
855
- return value
856
- .map(
857
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
858
- )
859
- .join('&');
989
+ return value.map(
990
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
991
+ );
992
+ }
993
+ if (
994
+ collectionFormats?.[key] === 'deepObject' &&
995
+ value !== null &&
996
+ typeof value === 'object'
997
+ ) {
998
+ return this.$deepObject(encodeURIComponent(key), value);
860
999
  }
861
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
1000
+ const delimiter =
1001
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1002
+ return [
1003
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
1004
+ ];
862
1005
  })
863
1006
  .join('&');
864
1007
  return (
@@ -868,13 +1011,22 @@ export class TestApi {
868
1011
 
869
1012
  private $headers = (
870
1013
  headerParameters: { [key: string]: any },
871
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
1014
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
872
1015
  ): [string, string][] => {
873
1016
  return Object.entries(headerParameters).flatMap(([key, value]) => {
874
1017
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
875
1018
  return value.map((v) => [key, String(v)]) as [string, string][];
876
1019
  }
877
- return [[key, String(value)]];
1020
+ const delimiter =
1021
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
1022
+ return [
1023
+ [
1024
+ key,
1025
+ Array.isArray(value)
1026
+ ? value.map(String).join(delimiter)
1027
+ : String(value),
1028
+ ],
1029
+ ];
878
1030
  });
879
1031
  };
880
1032