@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
@@ -1,14 +1,50 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`openApiTsClientGenerator - content type header > should not force Content-Type for multipart/form-data bodies > client.gen.ts 1`] = `
4
- "import type { PostUploadRequest } from './types.gen.js';
4
+ "import type {
5
+ PostUploadRequestContent,
6
+ PostUploadRequest,
7
+ } from './types.gen.js';
5
8
 
6
9
  /**
7
10
  * Utility for serialisation and deserialisation of API types.
8
11
  */
9
12
  export class $IO {
10
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
13
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
11
14
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
15
+
16
+ public static PostUploadRequestContent = {
17
+ toJson: (model: PostUploadRequestContent): any => {
18
+ if (model === undefined || model === null) {
19
+ return model;
20
+ }
21
+ return {
22
+ ...(model.file === undefined
23
+ ? {}
24
+ : {
25
+ file: model.file,
26
+ }),
27
+ ...(model.description === undefined
28
+ ? {}
29
+ : {
30
+ description: model.description,
31
+ }),
32
+ };
33
+ },
34
+ fromJson: (json: any): PostUploadRequestContent => {
35
+ if (json === undefined || json === null) {
36
+ return json;
37
+ }
38
+ return {
39
+ file: json['file'],
40
+ ...(json['description'] === undefined
41
+ ? {}
42
+ : {
43
+ description: json['description'],
44
+ }),
45
+ };
46
+ },
47
+ };
12
48
  }
13
49
 
14
50
  /**
@@ -49,11 +85,31 @@ export class TestApi {
49
85
  this.postUpload = this.postUpload.bind(this);
50
86
  }
51
87
 
88
+ private $collectionDelimiters: { [format: string]: string } = {
89
+ csv: ',',
90
+ ssv: ' ',
91
+ pipes: '|',
92
+ };
93
+
94
+ private $deepObject = (key: string, value: any): string[] => {
95
+ if (value === undefined || value === null) {
96
+ return [];
97
+ }
98
+ if (typeof value !== 'object') {
99
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
100
+ }
101
+ return Object.entries(value).flatMap(([prop, v]) =>
102
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
103
+ );
104
+ };
105
+
52
106
  private $url = (
53
107
  path: string,
54
108
  pathParameters: { [key: string]: any },
55
109
  queryParameters: { [key: string]: any },
56
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
110
+ collectionFormats?: {
111
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
112
+ },
57
113
  ): string => {
58
114
  const baseUrl = this.$config.url.endsWith('/')
59
115
  ? this.$config.url.slice(0, -1)
@@ -64,15 +120,24 @@ export class TestApi {
64
120
  path,
65
121
  );
66
122
  const queryString = Object.entries(queryParameters)
67
- .map(([key, value]) => {
123
+ .flatMap(([key, value]) => {
68
124
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
69
- return value
70
- .map(
71
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
72
- )
73
- .join('&');
125
+ return value.map(
126
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
127
+ );
74
128
  }
75
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
129
+ if (
130
+ collectionFormats?.[key] === 'deepObject' &&
131
+ value !== null &&
132
+ typeof value === 'object'
133
+ ) {
134
+ return this.$deepObject(encodeURIComponent(key), value);
135
+ }
136
+ const delimiter =
137
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
138
+ return [
139
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
140
+ ];
76
141
  })
77
142
  .join('&');
78
143
  return (
@@ -82,16 +147,45 @@ export class TestApi {
82
147
 
83
148
  private $headers = (
84
149
  headerParameters: { [key: string]: any },
85
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
150
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
86
151
  ): [string, string][] => {
87
152
  return Object.entries(headerParameters).flatMap(([key, value]) => {
88
153
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
89
154
  return value.map((v) => [key, String(v)]) as [string, string][];
90
155
  }
91
- return [[key, String(value)]];
156
+ const delimiter =
157
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
158
+ return [
159
+ [
160
+ key,
161
+ Array.isArray(value)
162
+ ? value.map(String).join(delimiter)
163
+ : String(value),
164
+ ],
165
+ ];
92
166
  });
93
167
  };
94
168
 
169
+ private $formData = (model: { [key: string]: any }): FormData => {
170
+ const formData = new FormData();
171
+ const append = (key: string, value: any): void => {
172
+ if (value === undefined || value === null) {
173
+ return;
174
+ }
175
+ if (value instanceof Blob || typeof value === 'string') {
176
+ formData.append(key, value);
177
+ } else if (Array.isArray(value)) {
178
+ value.forEach((v) => append(key, v));
179
+ } else if (typeof value === 'object') {
180
+ formData.append(key, JSON.stringify(value));
181
+ } else {
182
+ formData.append(key, String(value));
183
+ }
184
+ };
185
+ Object.entries(model).forEach(([key, value]) => append(key, value));
186
+ return formData;
187
+ };
188
+
95
189
  private $fetch: typeof fetch = (...args) =>
96
190
  (this.$config.fetch ?? fetch)(...args);
97
191
 
@@ -99,7 +193,7 @@ export class TestApi {
99
193
  const pathParameters: { [key: string]: any } = {};
100
194
  const queryParameters: { [key: string]: any } = {};
101
195
  const headerParameters: { [key: string]: any } = {};
102
- const body = input as any;
196
+ const body = this.$formData($IO.PostUploadRequestContent.toJson(input));
103
197
 
104
198
  const response = await this.$fetch(
105
199
  this.$url('/upload', pathParameters, queryParameters),
@@ -122,7 +216,12 @@ export class TestApi {
122
216
  `;
123
217
 
124
218
  exports[`openApiTsClientGenerator - content type header > should not force Content-Type for multipart/form-data bodies > types.gen.ts 1`] = `
125
- "export type PostUploadRequest = unknown;
219
+ "export type PostUploadRequestContent = {
220
+ file: Blob;
221
+ description?: string;
222
+ };
223
+
224
+ export type PostUploadRequest = PostUploadRequestContent;
126
225
  export type PostUploadError = never;
127
226
  "
128
227
  `;
@@ -134,7 +233,7 @@ exports[`openApiTsClientGenerator - content type header > should pick a single w
134
233
  * Utility for serialisation and deserialisation of API types.
135
234
  */
136
235
  export class $IO {
137
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
236
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
138
237
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
139
238
 
140
239
  public static PostMultiRequestContent = {
@@ -203,11 +302,31 @@ export class TestApi {
203
302
  this.postMulti = this.postMulti.bind(this);
204
303
  }
205
304
 
305
+ private $collectionDelimiters: { [format: string]: string } = {
306
+ csv: ',',
307
+ ssv: ' ',
308
+ pipes: '|',
309
+ };
310
+
311
+ private $deepObject = (key: string, value: any): string[] => {
312
+ if (value === undefined || value === null) {
313
+ return [];
314
+ }
315
+ if (typeof value !== 'object') {
316
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
317
+ }
318
+ return Object.entries(value).flatMap(([prop, v]) =>
319
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
320
+ );
321
+ };
322
+
206
323
  private $url = (
207
324
  path: string,
208
325
  pathParameters: { [key: string]: any },
209
326
  queryParameters: { [key: string]: any },
210
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
327
+ collectionFormats?: {
328
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
329
+ },
211
330
  ): string => {
212
331
  const baseUrl = this.$config.url.endsWith('/')
213
332
  ? this.$config.url.slice(0, -1)
@@ -218,15 +337,24 @@ export class TestApi {
218
337
  path,
219
338
  );
220
339
  const queryString = Object.entries(queryParameters)
221
- .map(([key, value]) => {
340
+ .flatMap(([key, value]) => {
222
341
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
223
- return value
224
- .map(
225
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
226
- )
227
- .join('&');
342
+ return value.map(
343
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
344
+ );
228
345
  }
229
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
346
+ if (
347
+ collectionFormats?.[key] === 'deepObject' &&
348
+ value !== null &&
349
+ typeof value === 'object'
350
+ ) {
351
+ return this.$deepObject(encodeURIComponent(key), value);
352
+ }
353
+ const delimiter =
354
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
355
+ return [
356
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
357
+ ];
230
358
  })
231
359
  .join('&');
232
360
  return (
@@ -236,13 +364,22 @@ export class TestApi {
236
364
 
237
365
  private $headers = (
238
366
  headerParameters: { [key: string]: any },
239
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
367
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
240
368
  ): [string, string][] => {
241
369
  return Object.entries(headerParameters).flatMap(([key, value]) => {
242
370
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
243
371
  return value.map((v) => [key, String(v)]) as [string, string][];
244
372
  }
245
- return [[key, String(value)]];
373
+ const delimiter =
374
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
375
+ return [
376
+ [
377
+ key,
378
+ Array.isArray(value)
379
+ ? value.map(String).join(delimiter)
380
+ : String(value),
381
+ ],
382
+ ];
246
383
  });
247
384
  };
248
385
 
@@ -301,7 +438,7 @@ exports[`openApiTsClientGenerator - content type header > should serialise cooki
301
438
  * Utility for serialisation and deserialisation of API types.
302
439
  */
303
440
  export class $IO {
304
- protected static $mapValues = (data: any, fn: (item: any) => any) =>
441
+ public static $mapValues = (data: any, fn: (item: any) => any) =>
305
442
  Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
306
443
 
307
444
  public static GetSecretRequestCookieParameters = {
@@ -380,11 +517,31 @@ export class TestApi {
380
517
  this.getSecret = this.getSecret.bind(this);
381
518
  }
382
519
 
520
+ private $collectionDelimiters: { [format: string]: string } = {
521
+ csv: ',',
522
+ ssv: ' ',
523
+ pipes: '|',
524
+ };
525
+
526
+ private $deepObject = (key: string, value: any): string[] => {
527
+ if (value === undefined || value === null) {
528
+ return [];
529
+ }
530
+ if (typeof value !== 'object') {
531
+ return [\`\${key}=\${encodeURIComponent(String(value))}\`];
532
+ }
533
+ return Object.entries(value).flatMap(([prop, v]) =>
534
+ this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
535
+ );
536
+ };
537
+
383
538
  private $url = (
384
539
  path: string,
385
540
  pathParameters: { [key: string]: any },
386
541
  queryParameters: { [key: string]: any },
387
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
542
+ collectionFormats?: {
543
+ [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
544
+ },
388
545
  ): string => {
389
546
  const baseUrl = this.$config.url.endsWith('/')
390
547
  ? this.$config.url.slice(0, -1)
@@ -395,15 +552,24 @@ export class TestApi {
395
552
  path,
396
553
  );
397
554
  const queryString = Object.entries(queryParameters)
398
- .map(([key, value]) => {
555
+ .flatMap(([key, value]) => {
399
556
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
400
- return value
401
- .map(
402
- (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
403
- )
404
- .join('&');
557
+ return value.map(
558
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
559
+ );
560
+ }
561
+ if (
562
+ collectionFormats?.[key] === 'deepObject' &&
563
+ value !== null &&
564
+ typeof value === 'object'
565
+ ) {
566
+ return this.$deepObject(encodeURIComponent(key), value);
405
567
  }
406
- return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
568
+ const delimiter =
569
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
570
+ return [
571
+ \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
572
+ ];
407
573
  })
408
574
  .join('&');
409
575
  return (
@@ -413,13 +579,22 @@ export class TestApi {
413
579
 
414
580
  private $headers = (
415
581
  headerParameters: { [key: string]: any },
416
- collectionFormats?: { [key: string]: 'multi' | 'csv' },
582
+ collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
417
583
  ): [string, string][] => {
418
584
  return Object.entries(headerParameters).flatMap(([key, value]) => {
419
585
  if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
420
586
  return value.map((v) => [key, String(v)]) as [string, string][];
421
587
  }
422
- return [[key, String(value)]];
588
+ const delimiter =
589
+ this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
590
+ return [
591
+ [
592
+ key,
593
+ Array.isArray(value)
594
+ ? value.map(String).join(delimiter)
595
+ : String(value),
596
+ ],
597
+ ];
423
598
  });
424
599
  };
425
600