@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.
- package/LICENSE-THIRD-PARTY +235 -1336
- package/README.md +1 -1
- package/package.json +1 -2
- package/src/mcp-server/tools/create-workspace-command.js +2 -2
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.arrays.spec.ts.snap +308 -75
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +286 -62
- package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +674 -93
- package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +211 -36
- package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +196 -44
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5507 -0
- package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +219 -60
- package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +280 -0
- package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +351 -80
- package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
- package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
- package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
- package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
- package/src/open-api/ts-client/files/client.gen.ts.template +166 -19
- package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
- package/src/open-api/ts-client/generator.js +1 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
- package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
- package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
- package/src/open-api/utils/codegen-data/languages.js +23 -18
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.d.ts +240 -10
- package/src/open-api/utils/codegen-data/types.js +24 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +2 -2
- package/src/open-api/utils/codegen-data.js +357 -617
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +167 -22
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.d.ts +55 -0
- package/src/open-api/utils/parser.js +754 -0
- package/src/open-api/utils/parser.js.map +1 -0
- package/src/open-api/utils/types.d.ts +18 -0
- package/src/open-api/utils/types.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +414 -6
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +276 -4
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +414 -6
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +0 -23
- package/src/ts/mcp-server/generator.js +10 -22
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
- package/src/utils/mcp.js +1 -1
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/names.d.ts +6 -0
- package/src/utils/names.js +6 -1
- package/src/utils/names.js.map +1 -1
- package/src/utils/versions.d.ts +5 -5
- package/src/utils/versions.js +4 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -29,7 +29,7 @@ exports[`openApiTsClientGenerator - arrays > should handle operation which accep
|
|
|
29
29
|
* Utility for serialisation and deserialisation of API types.
|
|
30
30
|
*/
|
|
31
31
|
export class $IO {
|
|
32
|
-
|
|
32
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
33
33
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
34
34
|
|
|
35
35
|
public static ProcessUsers200Response = {
|
|
@@ -155,11 +155,31 @@ export class TestApi {
|
|
|
155
155
|
this.processUsers = this.processUsers.bind(this);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
159
|
+
csv: ',',
|
|
160
|
+
ssv: ' ',
|
|
161
|
+
pipes: '|',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
165
|
+
if (value === undefined || value === null) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
if (typeof value !== 'object') {
|
|
169
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
170
|
+
}
|
|
171
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
172
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
158
176
|
private $url = (
|
|
159
177
|
path: string,
|
|
160
178
|
pathParameters: { [key: string]: any },
|
|
161
179
|
queryParameters: { [key: string]: any },
|
|
162
|
-
collectionFormats?: {
|
|
180
|
+
collectionFormats?: {
|
|
181
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
182
|
+
},
|
|
163
183
|
): string => {
|
|
164
184
|
const baseUrl = this.$config.url.endsWith('/')
|
|
165
185
|
? this.$config.url.slice(0, -1)
|
|
@@ -170,15 +190,24 @@ export class TestApi {
|
|
|
170
190
|
path,
|
|
171
191
|
);
|
|
172
192
|
const queryString = Object.entries(queryParameters)
|
|
173
|
-
.
|
|
193
|
+
.flatMap(([key, value]) => {
|
|
174
194
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
175
|
-
return value
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
)
|
|
179
|
-
.join('&');
|
|
195
|
+
return value.map(
|
|
196
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
197
|
+
);
|
|
180
198
|
}
|
|
181
|
-
|
|
199
|
+
if (
|
|
200
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
201
|
+
value !== null &&
|
|
202
|
+
typeof value === 'object'
|
|
203
|
+
) {
|
|
204
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
205
|
+
}
|
|
206
|
+
const delimiter =
|
|
207
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
208
|
+
return [
|
|
209
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
210
|
+
];
|
|
182
211
|
})
|
|
183
212
|
.join('&');
|
|
184
213
|
return (
|
|
@@ -188,13 +217,22 @@ export class TestApi {
|
|
|
188
217
|
|
|
189
218
|
private $headers = (
|
|
190
219
|
headerParameters: { [key: string]: any },
|
|
191
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
220
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
192
221
|
): [string, string][] => {
|
|
193
222
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
194
223
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
195
224
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
196
225
|
}
|
|
197
|
-
|
|
226
|
+
const delimiter =
|
|
227
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
228
|
+
return [
|
|
229
|
+
[
|
|
230
|
+
key,
|
|
231
|
+
Array.isArray(value)
|
|
232
|
+
? value.map(String).join(delimiter)
|
|
233
|
+
: String(value),
|
|
234
|
+
],
|
|
235
|
+
];
|
|
198
236
|
});
|
|
199
237
|
};
|
|
200
238
|
|
|
@@ -274,7 +312,7 @@ exports[`openApiTsClientGenerator - arrays > should handle operation which accep
|
|
|
274
312
|
* Utility for serialisation and deserialisation of API types.
|
|
275
313
|
*/
|
|
276
314
|
export class $IO {
|
|
277
|
-
|
|
315
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
278
316
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
279
317
|
|
|
280
318
|
public static BatchCreateCustomers201Response = {
|
|
@@ -455,11 +493,31 @@ export class TestApi {
|
|
|
455
493
|
this.batchCreateCustomers = this.batchCreateCustomers.bind(this);
|
|
456
494
|
}
|
|
457
495
|
|
|
496
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
497
|
+
csv: ',',
|
|
498
|
+
ssv: ' ',
|
|
499
|
+
pipes: '|',
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
503
|
+
if (value === undefined || value === null) {
|
|
504
|
+
return [];
|
|
505
|
+
}
|
|
506
|
+
if (typeof value !== 'object') {
|
|
507
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
508
|
+
}
|
|
509
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
510
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
511
|
+
);
|
|
512
|
+
};
|
|
513
|
+
|
|
458
514
|
private $url = (
|
|
459
515
|
path: string,
|
|
460
516
|
pathParameters: { [key: string]: any },
|
|
461
517
|
queryParameters: { [key: string]: any },
|
|
462
|
-
collectionFormats?: {
|
|
518
|
+
collectionFormats?: {
|
|
519
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
520
|
+
},
|
|
463
521
|
): string => {
|
|
464
522
|
const baseUrl = this.$config.url.endsWith('/')
|
|
465
523
|
? this.$config.url.slice(0, -1)
|
|
@@ -470,15 +528,24 @@ export class TestApi {
|
|
|
470
528
|
path,
|
|
471
529
|
);
|
|
472
530
|
const queryString = Object.entries(queryParameters)
|
|
473
|
-
.
|
|
531
|
+
.flatMap(([key, value]) => {
|
|
474
532
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
475
|
-
return value
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
533
|
+
return value.map(
|
|
534
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
if (
|
|
538
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
539
|
+
value !== null &&
|
|
540
|
+
typeof value === 'object'
|
|
541
|
+
) {
|
|
542
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
480
543
|
}
|
|
481
|
-
|
|
544
|
+
const delimiter =
|
|
545
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
546
|
+
return [
|
|
547
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
548
|
+
];
|
|
482
549
|
})
|
|
483
550
|
.join('&');
|
|
484
551
|
return (
|
|
@@ -488,13 +555,22 @@ export class TestApi {
|
|
|
488
555
|
|
|
489
556
|
private $headers = (
|
|
490
557
|
headerParameters: { [key: string]: any },
|
|
491
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
558
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
492
559
|
): [string, string][] => {
|
|
493
560
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
494
561
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
495
562
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
496
563
|
}
|
|
497
|
-
|
|
564
|
+
const delimiter =
|
|
565
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
566
|
+
return [
|
|
567
|
+
[
|
|
568
|
+
key,
|
|
569
|
+
Array.isArray(value)
|
|
570
|
+
? value.map(String).join(delimiter)
|
|
571
|
+
: String(value),
|
|
572
|
+
],
|
|
573
|
+
];
|
|
498
574
|
});
|
|
499
575
|
};
|
|
500
576
|
|
|
@@ -558,7 +634,7 @@ exports[`openApiTsClientGenerator - arrays > should handle operation which accep
|
|
|
558
634
|
* Utility for serialisation and deserialisation of API types.
|
|
559
635
|
*/
|
|
560
636
|
export class $IO {
|
|
561
|
-
|
|
637
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
562
638
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
563
639
|
|
|
564
640
|
public static ProcessTags200Response = {
|
|
@@ -629,11 +705,31 @@ export class TestApi {
|
|
|
629
705
|
this.processTags = this.processTags.bind(this);
|
|
630
706
|
}
|
|
631
707
|
|
|
708
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
709
|
+
csv: ',',
|
|
710
|
+
ssv: ' ',
|
|
711
|
+
pipes: '|',
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
715
|
+
if (value === undefined || value === null) {
|
|
716
|
+
return [];
|
|
717
|
+
}
|
|
718
|
+
if (typeof value !== 'object') {
|
|
719
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
720
|
+
}
|
|
721
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
722
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
723
|
+
);
|
|
724
|
+
};
|
|
725
|
+
|
|
632
726
|
private $url = (
|
|
633
727
|
path: string,
|
|
634
728
|
pathParameters: { [key: string]: any },
|
|
635
729
|
queryParameters: { [key: string]: any },
|
|
636
|
-
collectionFormats?: {
|
|
730
|
+
collectionFormats?: {
|
|
731
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
732
|
+
},
|
|
637
733
|
): string => {
|
|
638
734
|
const baseUrl = this.$config.url.endsWith('/')
|
|
639
735
|
? this.$config.url.slice(0, -1)
|
|
@@ -644,15 +740,24 @@ export class TestApi {
|
|
|
644
740
|
path,
|
|
645
741
|
);
|
|
646
742
|
const queryString = Object.entries(queryParameters)
|
|
647
|
-
.
|
|
743
|
+
.flatMap(([key, value]) => {
|
|
648
744
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
649
|
-
return value
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
)
|
|
653
|
-
.join('&');
|
|
745
|
+
return value.map(
|
|
746
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
747
|
+
);
|
|
654
748
|
}
|
|
655
|
-
|
|
749
|
+
if (
|
|
750
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
751
|
+
value !== null &&
|
|
752
|
+
typeof value === 'object'
|
|
753
|
+
) {
|
|
754
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
755
|
+
}
|
|
756
|
+
const delimiter =
|
|
757
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
758
|
+
return [
|
|
759
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
760
|
+
];
|
|
656
761
|
})
|
|
657
762
|
.join('&');
|
|
658
763
|
return (
|
|
@@ -662,13 +767,22 @@ export class TestApi {
|
|
|
662
767
|
|
|
663
768
|
private $headers = (
|
|
664
769
|
headerParameters: { [key: string]: any },
|
|
665
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
770
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
666
771
|
): [string, string][] => {
|
|
667
772
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
668
773
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
669
774
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
670
775
|
}
|
|
671
|
-
|
|
776
|
+
const delimiter =
|
|
777
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
778
|
+
return [
|
|
779
|
+
[
|
|
780
|
+
key,
|
|
781
|
+
Array.isArray(value)
|
|
782
|
+
? value.map(String).join(delimiter)
|
|
783
|
+
: String(value),
|
|
784
|
+
],
|
|
785
|
+
];
|
|
672
786
|
});
|
|
673
787
|
};
|
|
674
788
|
|
|
@@ -748,7 +862,7 @@ exports[`openApiTsClientGenerator - arrays > should handle operation which retur
|
|
|
748
862
|
* Utility for serialisation and deserialisation of API types.
|
|
749
863
|
*/
|
|
750
864
|
export class $IO {
|
|
751
|
-
|
|
865
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
752
866
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
753
867
|
|
|
754
868
|
public static GetProducts200ResponseItem = {
|
|
@@ -943,11 +1057,31 @@ export class TestApi {
|
|
|
943
1057
|
this.getProducts = this.getProducts.bind(this);
|
|
944
1058
|
}
|
|
945
1059
|
|
|
1060
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
1061
|
+
csv: ',',
|
|
1062
|
+
ssv: ' ',
|
|
1063
|
+
pipes: '|',
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
1067
|
+
if (value === undefined || value === null) {
|
|
1068
|
+
return [];
|
|
1069
|
+
}
|
|
1070
|
+
if (typeof value !== 'object') {
|
|
1071
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
1072
|
+
}
|
|
1073
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
1074
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
1075
|
+
);
|
|
1076
|
+
};
|
|
1077
|
+
|
|
946
1078
|
private $url = (
|
|
947
1079
|
path: string,
|
|
948
1080
|
pathParameters: { [key: string]: any },
|
|
949
1081
|
queryParameters: { [key: string]: any },
|
|
950
|
-
collectionFormats?: {
|
|
1082
|
+
collectionFormats?: {
|
|
1083
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
1084
|
+
},
|
|
951
1085
|
): string => {
|
|
952
1086
|
const baseUrl = this.$config.url.endsWith('/')
|
|
953
1087
|
? this.$config.url.slice(0, -1)
|
|
@@ -958,15 +1092,24 @@ export class TestApi {
|
|
|
958
1092
|
path,
|
|
959
1093
|
);
|
|
960
1094
|
const queryString = Object.entries(queryParameters)
|
|
961
|
-
.
|
|
1095
|
+
.flatMap(([key, value]) => {
|
|
962
1096
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
963
|
-
return value
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
)
|
|
967
|
-
.join('&');
|
|
1097
|
+
return value.map(
|
|
1098
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
1099
|
+
);
|
|
968
1100
|
}
|
|
969
|
-
|
|
1101
|
+
if (
|
|
1102
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
1103
|
+
value !== null &&
|
|
1104
|
+
typeof value === 'object'
|
|
1105
|
+
) {
|
|
1106
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
1107
|
+
}
|
|
1108
|
+
const delimiter =
|
|
1109
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1110
|
+
return [
|
|
1111
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
1112
|
+
];
|
|
970
1113
|
})
|
|
971
1114
|
.join('&');
|
|
972
1115
|
return (
|
|
@@ -976,13 +1119,22 @@ export class TestApi {
|
|
|
976
1119
|
|
|
977
1120
|
private $headers = (
|
|
978
1121
|
headerParameters: { [key: string]: any },
|
|
979
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1122
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
980
1123
|
): [string, string][] => {
|
|
981
1124
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
982
1125
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
983
1126
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
984
1127
|
}
|
|
985
|
-
|
|
1128
|
+
const delimiter =
|
|
1129
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1130
|
+
return [
|
|
1131
|
+
[
|
|
1132
|
+
key,
|
|
1133
|
+
Array.isArray(value)
|
|
1134
|
+
? value.map(String).join(delimiter)
|
|
1135
|
+
: String(value),
|
|
1136
|
+
],
|
|
1137
|
+
];
|
|
986
1138
|
});
|
|
987
1139
|
};
|
|
988
1140
|
|
|
@@ -999,7 +1151,7 @@ export class TestApi {
|
|
|
999
1151
|
const queryParameters: { [key: string]: any } =
|
|
1000
1152
|
$IO.GetProductsRequestQueryParameters.toJson(input);
|
|
1001
1153
|
const headerParameters: { [key: string]: any } = {};
|
|
1002
|
-
const
|
|
1154
|
+
const queryCollectionFormats = {
|
|
1003
1155
|
category: 'multi',
|
|
1004
1156
|
limit: 'multi',
|
|
1005
1157
|
} as const;
|
|
@@ -1011,10 +1163,10 @@ export class TestApi {
|
|
|
1011
1163
|
'/get-products',
|
|
1012
1164
|
pathParameters,
|
|
1013
1165
|
queryParameters,
|
|
1014
|
-
|
|
1166
|
+
queryCollectionFormats,
|
|
1015
1167
|
),
|
|
1016
1168
|
{
|
|
1017
|
-
headers: this.$headers(headerParameters
|
|
1169
|
+
headers: this.$headers(headerParameters),
|
|
1018
1170
|
method: 'GET',
|
|
1019
1171
|
body,
|
|
1020
1172
|
},
|
|
@@ -1086,7 +1238,7 @@ exports[`openApiTsClientGenerator - arrays > should handle operation which retur
|
|
|
1086
1238
|
* Utility for serialisation and deserialisation of API types.
|
|
1087
1239
|
*/
|
|
1088
1240
|
export class $IO {
|
|
1089
|
-
|
|
1241
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
1090
1242
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
1091
1243
|
|
|
1092
1244
|
public static GetOrdersRequestQueryParameters = {
|
|
@@ -1316,11 +1468,31 @@ export class TestApi {
|
|
|
1316
1468
|
this.getOrders = this.getOrders.bind(this);
|
|
1317
1469
|
}
|
|
1318
1470
|
|
|
1471
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
1472
|
+
csv: ',',
|
|
1473
|
+
ssv: ' ',
|
|
1474
|
+
pipes: '|',
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
1478
|
+
if (value === undefined || value === null) {
|
|
1479
|
+
return [];
|
|
1480
|
+
}
|
|
1481
|
+
if (typeof value !== 'object') {
|
|
1482
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
1483
|
+
}
|
|
1484
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
1485
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
1486
|
+
);
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1319
1489
|
private $url = (
|
|
1320
1490
|
path: string,
|
|
1321
1491
|
pathParameters: { [key: string]: any },
|
|
1322
1492
|
queryParameters: { [key: string]: any },
|
|
1323
|
-
collectionFormats?: {
|
|
1493
|
+
collectionFormats?: {
|
|
1494
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
1495
|
+
},
|
|
1324
1496
|
): string => {
|
|
1325
1497
|
const baseUrl = this.$config.url.endsWith('/')
|
|
1326
1498
|
? this.$config.url.slice(0, -1)
|
|
@@ -1331,15 +1503,24 @@ export class TestApi {
|
|
|
1331
1503
|
path,
|
|
1332
1504
|
);
|
|
1333
1505
|
const queryString = Object.entries(queryParameters)
|
|
1334
|
-
.
|
|
1506
|
+
.flatMap(([key, value]) => {
|
|
1335
1507
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1336
|
-
return value
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1508
|
+
return value.map(
|
|
1509
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
if (
|
|
1513
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
1514
|
+
value !== null &&
|
|
1515
|
+
typeof value === 'object'
|
|
1516
|
+
) {
|
|
1517
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
1341
1518
|
}
|
|
1342
|
-
|
|
1519
|
+
const delimiter =
|
|
1520
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1521
|
+
return [
|
|
1522
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
1523
|
+
];
|
|
1343
1524
|
})
|
|
1344
1525
|
.join('&');
|
|
1345
1526
|
return (
|
|
@@ -1349,13 +1530,22 @@ export class TestApi {
|
|
|
1349
1530
|
|
|
1350
1531
|
private $headers = (
|
|
1351
1532
|
headerParameters: { [key: string]: any },
|
|
1352
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1533
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
1353
1534
|
): [string, string][] => {
|
|
1354
1535
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
1355
1536
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1356
1537
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
1357
1538
|
}
|
|
1358
|
-
|
|
1539
|
+
const delimiter =
|
|
1540
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1541
|
+
return [
|
|
1542
|
+
[
|
|
1543
|
+
key,
|
|
1544
|
+
Array.isArray(value)
|
|
1545
|
+
? value.map(String).join(delimiter)
|
|
1546
|
+
: String(value),
|
|
1547
|
+
],
|
|
1548
|
+
];
|
|
1359
1549
|
});
|
|
1360
1550
|
};
|
|
1361
1551
|
|
|
@@ -1370,7 +1560,7 @@ export class TestApi {
|
|
|
1370
1560
|
const queryParameters: { [key: string]: any } =
|
|
1371
1561
|
$IO.GetOrdersRequestQueryParameters.toJson(input);
|
|
1372
1562
|
const headerParameters: { [key: string]: any } = {};
|
|
1373
|
-
const
|
|
1563
|
+
const queryCollectionFormats = {
|
|
1374
1564
|
customerId: 'multi',
|
|
1375
1565
|
status: 'multi',
|
|
1376
1566
|
limit: 'multi',
|
|
@@ -1379,9 +1569,14 @@ export class TestApi {
|
|
|
1379
1569
|
const body = undefined;
|
|
1380
1570
|
|
|
1381
1571
|
const response = await this.$fetch(
|
|
1382
|
-
this.$url(
|
|
1572
|
+
this.$url(
|
|
1573
|
+
'/orders',
|
|
1574
|
+
pathParameters,
|
|
1575
|
+
queryParameters,
|
|
1576
|
+
queryCollectionFormats,
|
|
1577
|
+
),
|
|
1383
1578
|
{
|
|
1384
|
-
headers: this.$headers(headerParameters
|
|
1579
|
+
headers: this.$headers(headerParameters),
|
|
1385
1580
|
method: 'GET',
|
|
1386
1581
|
body,
|
|
1387
1582
|
},
|
|
@@ -1421,7 +1616,7 @@ exports[`openApiTsClientGenerator - arrays > should handle operation which retur
|
|
|
1421
1616
|
* Utility for serialisation and deserialisation of API types.
|
|
1422
1617
|
*/
|
|
1423
1618
|
export class $IO {
|
|
1424
|
-
|
|
1619
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
1425
1620
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
1426
1621
|
|
|
1427
1622
|
public static GetCategoriesRequestQueryParameters = {
|
|
@@ -1490,11 +1685,31 @@ export class TestApi {
|
|
|
1490
1685
|
this.getCategories = this.getCategories.bind(this);
|
|
1491
1686
|
}
|
|
1492
1687
|
|
|
1688
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
1689
|
+
csv: ',',
|
|
1690
|
+
ssv: ' ',
|
|
1691
|
+
pipes: '|',
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1694
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
1695
|
+
if (value === undefined || value === null) {
|
|
1696
|
+
return [];
|
|
1697
|
+
}
|
|
1698
|
+
if (typeof value !== 'object') {
|
|
1699
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
1700
|
+
}
|
|
1701
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
1702
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
1703
|
+
);
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1493
1706
|
private $url = (
|
|
1494
1707
|
path: string,
|
|
1495
1708
|
pathParameters: { [key: string]: any },
|
|
1496
1709
|
queryParameters: { [key: string]: any },
|
|
1497
|
-
collectionFormats?: {
|
|
1710
|
+
collectionFormats?: {
|
|
1711
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
1712
|
+
},
|
|
1498
1713
|
): string => {
|
|
1499
1714
|
const baseUrl = this.$config.url.endsWith('/')
|
|
1500
1715
|
? this.$config.url.slice(0, -1)
|
|
@@ -1505,15 +1720,24 @@ export class TestApi {
|
|
|
1505
1720
|
path,
|
|
1506
1721
|
);
|
|
1507
1722
|
const queryString = Object.entries(queryParameters)
|
|
1508
|
-
.
|
|
1723
|
+
.flatMap(([key, value]) => {
|
|
1509
1724
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1510
|
-
return value
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1725
|
+
return value.map(
|
|
1726
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1729
|
+
if (
|
|
1730
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
1731
|
+
value !== null &&
|
|
1732
|
+
typeof value === 'object'
|
|
1733
|
+
) {
|
|
1734
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
1515
1735
|
}
|
|
1516
|
-
|
|
1736
|
+
const delimiter =
|
|
1737
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1738
|
+
return [
|
|
1739
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
1740
|
+
];
|
|
1517
1741
|
})
|
|
1518
1742
|
.join('&');
|
|
1519
1743
|
return (
|
|
@@ -1523,13 +1747,22 @@ export class TestApi {
|
|
|
1523
1747
|
|
|
1524
1748
|
private $headers = (
|
|
1525
1749
|
headerParameters: { [key: string]: any },
|
|
1526
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1750
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
1527
1751
|
): [string, string][] => {
|
|
1528
1752
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
1529
1753
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1530
1754
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
1531
1755
|
}
|
|
1532
|
-
|
|
1756
|
+
const delimiter =
|
|
1757
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1758
|
+
return [
|
|
1759
|
+
[
|
|
1760
|
+
key,
|
|
1761
|
+
Array.isArray(value)
|
|
1762
|
+
? value.map(String).join(delimiter)
|
|
1763
|
+
: String(value),
|
|
1764
|
+
],
|
|
1765
|
+
];
|
|
1533
1766
|
});
|
|
1534
1767
|
};
|
|
1535
1768
|
|
|
@@ -1546,7 +1779,7 @@ export class TestApi {
|
|
|
1546
1779
|
const queryParameters: { [key: string]: any } =
|
|
1547
1780
|
$IO.GetCategoriesRequestQueryParameters.toJson(input);
|
|
1548
1781
|
const headerParameters: { [key: string]: any } = {};
|
|
1549
|
-
const
|
|
1782
|
+
const queryCollectionFormats = {
|
|
1550
1783
|
filter: 'multi',
|
|
1551
1784
|
} as const;
|
|
1552
1785
|
|
|
@@ -1557,10 +1790,10 @@ export class TestApi {
|
|
|
1557
1790
|
'/get-categories',
|
|
1558
1791
|
pathParameters,
|
|
1559
1792
|
queryParameters,
|
|
1560
|
-
|
|
1793
|
+
queryCollectionFormats,
|
|
1561
1794
|
),
|
|
1562
1795
|
{
|
|
1563
|
-
headers: this.$headers(headerParameters
|
|
1796
|
+
headers: this.$headers(headerParameters),
|
|
1564
1797
|
method: 'GET',
|
|
1565
1798
|
body,
|
|
1566
1799
|
},
|