@aws/nx-plugin 0.38.1 → 0.38.3

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.
@@ -40,8 +40,6 @@ exports[`openApiTsClientGenerator - composite schemas > should generate valid Ty
40
40
  PutTestRequestContent,
41
41
  PutTestRequestContentOneOf,
42
42
  PutTestRequestContentOneOf1,
43
- PutTestRequestContentOneOf1Type,
44
- PutTestRequestContentOneOfType,
45
43
  PutTestRequest,
46
44
  } from './types.gen.js';
47
45
 
@@ -356,6 +354,457 @@ export class TestApi {
356
354
  "
357
355
  `;
358
356
 
357
+ exports[`openApiTsClientGenerator - composite schemas > should handle anyOf with any type 1`] = `
358
+ "export type TestAnyOfAny200Response = {
359
+ result?: string;
360
+ };
361
+ export type TestAnyOfAnyRequestContent = {
362
+ anyType?: TestAnyOfAnyRequestContentAnyType;
363
+ };
364
+ export type TestAnyOfAnyRequestContentAnyType = unknown | null;
365
+
366
+ export type TestAnyOfAnyRequest = TestAnyOfAnyRequestContent | undefined;
367
+ export type TestAnyOfAnyError = never;
368
+ "
369
+ `;
370
+
371
+ exports[`openApiTsClientGenerator - composite schemas > should handle anyOf with any type 2`] = `
372
+ "import type {
373
+ TestAnyOfAny200Response,
374
+ TestAnyOfAnyRequestContent,
375
+ TestAnyOfAnyRequestContentAnyType,
376
+ TestAnyOfAnyRequest,
377
+ } from './types.gen.js';
378
+
379
+ /**
380
+ * Utility for serialisation and deserialisation of API types.
381
+ */
382
+ export class $IO {
383
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
384
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
385
+
386
+ public static TestAnyOfAny200Response = {
387
+ toJson: (model: TestAnyOfAny200Response): any => {
388
+ if (model === undefined || model === null) {
389
+ return model;
390
+ }
391
+ return {
392
+ ...(model.result === undefined
393
+ ? {}
394
+ : {
395
+ result: model.result,
396
+ }),
397
+ };
398
+ },
399
+ fromJson: (json: any): TestAnyOfAny200Response => {
400
+ if (json === undefined || json === null) {
401
+ return json;
402
+ }
403
+ return {
404
+ ...(json['result'] === undefined
405
+ ? {}
406
+ : {
407
+ result: json['result'],
408
+ }),
409
+ };
410
+ },
411
+ };
412
+
413
+ public static TestAnyOfAnyRequestContent = {
414
+ toJson: (model: TestAnyOfAnyRequestContent): any => {
415
+ if (model === undefined || model === null) {
416
+ return model;
417
+ }
418
+ return {
419
+ ...(model.anyType === undefined
420
+ ? {}
421
+ : {
422
+ anyType: $IO.TestAnyOfAnyRequestContentAnyType.toJson(
423
+ model.anyType,
424
+ ),
425
+ }),
426
+ };
427
+ },
428
+ fromJson: (json: any): TestAnyOfAnyRequestContent => {
429
+ if (json === undefined || json === null) {
430
+ return json;
431
+ }
432
+ return {
433
+ ...(json['anyType'] === undefined
434
+ ? {}
435
+ : {
436
+ anyType: $IO.TestAnyOfAnyRequestContentAnyType.fromJson(
437
+ json['anyType'],
438
+ ),
439
+ }),
440
+ };
441
+ },
442
+ };
443
+
444
+ public static TestAnyOfAnyRequestContentAnyType = {
445
+ toJson: (model: TestAnyOfAnyRequestContentAnyType): any => {
446
+ if (model === undefined || model === null) {
447
+ return model;
448
+ }
449
+ return model;
450
+ },
451
+ fromJson: (json: any): TestAnyOfAnyRequestContentAnyType => {
452
+ if (json === undefined || json === null) {
453
+ return json;
454
+ }
455
+ return json;
456
+ },
457
+ };
458
+ }
459
+
460
+ /**
461
+ * Client configuration for TestApi
462
+ */
463
+ export interface TestApiConfig {
464
+ /**
465
+ * Base URL for the API
466
+ */
467
+ url: string;
468
+ /**
469
+ * Custom instance of fetch. By default the global 'fetch' is used.
470
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
471
+ */
472
+ fetch?: typeof fetch;
473
+ /**
474
+ * Additional configuration
475
+ */
476
+ options?: {
477
+ /**
478
+ * By default, the client will add a Content-Type header, set to the media type defined for
479
+ * the request in the OpenAPI specification.
480
+ * Set this to false to omit this header.
481
+ */
482
+ omitContentTypeHeader?: boolean;
483
+ };
484
+ }
485
+
486
+ /**
487
+ * API Client for TestApi
488
+ */
489
+ export class TestApi {
490
+ private $config: TestApiConfig;
491
+
492
+ constructor(config: TestApiConfig) {
493
+ this.$config = config;
494
+
495
+ this.testAnyOfAny = this.testAnyOfAny.bind(this);
496
+ }
497
+
498
+ private $url = (
499
+ path: string,
500
+ pathParameters: { [key: string]: any },
501
+ queryParameters: { [key: string]: any },
502
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
503
+ ): string => {
504
+ const baseUrl = this.$config.url.endsWith('/')
505
+ ? this.$config.url.slice(0, -1)
506
+ : this.$config.url;
507
+ const pathWithParameters = Object.entries(pathParameters).reduce(
508
+ (withParams, [key, value]) =>
509
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
510
+ path,
511
+ );
512
+ const queryString = Object.entries(queryParameters)
513
+ .map(([key, value]) => {
514
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
515
+ return value
516
+ .map(
517
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
518
+ )
519
+ .join('&');
520
+ }
521
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
522
+ })
523
+ .join('&');
524
+ return (
525
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
526
+ );
527
+ };
528
+
529
+ private $headers = (
530
+ headerParameters: { [key: string]: any },
531
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
532
+ ): [string, string][] => {
533
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
534
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
535
+ return value.map((v) => [key, String(v)]) as [string, string][];
536
+ }
537
+ return [[key, String(value)]];
538
+ });
539
+ };
540
+
541
+ private $fetch: typeof fetch = (...args) =>
542
+ (this.$config.fetch ?? fetch)(...args);
543
+
544
+ public async testAnyOfAny(
545
+ input?: TestAnyOfAnyRequest,
546
+ ): Promise<TestAnyOfAny200Response> {
547
+ const pathParameters: { [key: string]: any } = {};
548
+ const queryParameters: { [key: string]: any } = {};
549
+ const headerParameters: { [key: string]: any } = {};
550
+ if (!this.$config.options?.omitContentTypeHeader) {
551
+ headerParameters['Content-Type'] = 'application/json';
552
+ }
553
+ const body =
554
+ input === undefined
555
+ ? undefined
556
+ : typeof input === 'object'
557
+ ? JSON.stringify($IO.TestAnyOfAnyRequestContent.toJson(input))
558
+ : String($IO.TestAnyOfAnyRequestContent.toJson(input));
559
+
560
+ const response = await this.$fetch(
561
+ this.$url('/anyOfAny', pathParameters, queryParameters),
562
+ {
563
+ headers: this.$headers(headerParameters),
564
+ method: 'POST',
565
+ body,
566
+ },
567
+ );
568
+
569
+ if (response.status === 200) {
570
+ return $IO.TestAnyOfAny200Response.fromJson(await response.json());
571
+ }
572
+ throw new Error(
573
+ \`Unknown response status \${response.status} returned by API\`,
574
+ );
575
+ }
576
+ }
577
+ "
578
+ `;
579
+
580
+ exports[`openApiTsClientGenerator - composite schemas > should handle anyOf with enums 1`] = `
581
+ "export type TestAnyOfEnum200Response = {
582
+ result?: string;
583
+ };
584
+ export type TestAnyOfEnumRequestContent = {
585
+ anyType?: TestAnyOfEnumRequestContentAnyType;
586
+ };
587
+ export type TestAnyOfEnumRequestContentAnyType =
588
+ TestAnyOfEnumRequestContentAnyTypeAnyOf | null;
589
+ export type TestAnyOfEnumRequestContentAnyTypeAnyOf = 'a' | 'b' | 'c';
590
+
591
+ export type TestAnyOfEnumRequest = TestAnyOfEnumRequestContent | undefined;
592
+ export type TestAnyOfEnumError = never;
593
+ "
594
+ `;
595
+
596
+ exports[`openApiTsClientGenerator - composite schemas > should handle anyOf with enums 2`] = `
597
+ "import type {
598
+ TestAnyOfEnum200Response,
599
+ TestAnyOfEnumRequestContent,
600
+ TestAnyOfEnumRequestContentAnyType,
601
+ TestAnyOfEnumRequest,
602
+ } from './types.gen.js';
603
+
604
+ /**
605
+ * Utility for serialisation and deserialisation of API types.
606
+ */
607
+ export class $IO {
608
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
609
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
610
+
611
+ public static TestAnyOfEnum200Response = {
612
+ toJson: (model: TestAnyOfEnum200Response): any => {
613
+ if (model === undefined || model === null) {
614
+ return model;
615
+ }
616
+ return {
617
+ ...(model.result === undefined
618
+ ? {}
619
+ : {
620
+ result: model.result,
621
+ }),
622
+ };
623
+ },
624
+ fromJson: (json: any): TestAnyOfEnum200Response => {
625
+ if (json === undefined || json === null) {
626
+ return json;
627
+ }
628
+ return {
629
+ ...(json['result'] === undefined
630
+ ? {}
631
+ : {
632
+ result: json['result'],
633
+ }),
634
+ };
635
+ },
636
+ };
637
+
638
+ public static TestAnyOfEnumRequestContent = {
639
+ toJson: (model: TestAnyOfEnumRequestContent): any => {
640
+ if (model === undefined || model === null) {
641
+ return model;
642
+ }
643
+ return {
644
+ ...(model.anyType === undefined
645
+ ? {}
646
+ : {
647
+ anyType: $IO.TestAnyOfEnumRequestContentAnyType.toJson(
648
+ model.anyType,
649
+ ),
650
+ }),
651
+ };
652
+ },
653
+ fromJson: (json: any): TestAnyOfEnumRequestContent => {
654
+ if (json === undefined || json === null) {
655
+ return json;
656
+ }
657
+ return {
658
+ ...(json['anyType'] === undefined
659
+ ? {}
660
+ : {
661
+ anyType: $IO.TestAnyOfEnumRequestContentAnyType.fromJson(
662
+ json['anyType'],
663
+ ),
664
+ }),
665
+ };
666
+ },
667
+ };
668
+
669
+ public static TestAnyOfEnumRequestContentAnyType = {
670
+ toJson: (model: TestAnyOfEnumRequestContentAnyType): any => {
671
+ if (model === undefined || model === null) {
672
+ return model;
673
+ }
674
+ if (typeof model === 'string') {
675
+ return model;
676
+ }
677
+ return model;
678
+ },
679
+ fromJson: (json: any): TestAnyOfEnumRequestContentAnyType => {
680
+ if (json === undefined || json === null) {
681
+ return json;
682
+ }
683
+ return json;
684
+ },
685
+ };
686
+ }
687
+
688
+ /**
689
+ * Client configuration for TestApi
690
+ */
691
+ export interface TestApiConfig {
692
+ /**
693
+ * Base URL for the API
694
+ */
695
+ url: string;
696
+ /**
697
+ * Custom instance of fetch. By default the global 'fetch' is used.
698
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
699
+ */
700
+ fetch?: typeof fetch;
701
+ /**
702
+ * Additional configuration
703
+ */
704
+ options?: {
705
+ /**
706
+ * By default, the client will add a Content-Type header, set to the media type defined for
707
+ * the request in the OpenAPI specification.
708
+ * Set this to false to omit this header.
709
+ */
710
+ omitContentTypeHeader?: boolean;
711
+ };
712
+ }
713
+
714
+ /**
715
+ * API Client for TestApi
716
+ */
717
+ export class TestApi {
718
+ private $config: TestApiConfig;
719
+
720
+ constructor(config: TestApiConfig) {
721
+ this.$config = config;
722
+
723
+ this.testAnyOfEnum = this.testAnyOfEnum.bind(this);
724
+ }
725
+
726
+ private $url = (
727
+ path: string,
728
+ pathParameters: { [key: string]: any },
729
+ queryParameters: { [key: string]: any },
730
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
731
+ ): string => {
732
+ const baseUrl = this.$config.url.endsWith('/')
733
+ ? this.$config.url.slice(0, -1)
734
+ : this.$config.url;
735
+ const pathWithParameters = Object.entries(pathParameters).reduce(
736
+ (withParams, [key, value]) =>
737
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
738
+ path,
739
+ );
740
+ const queryString = Object.entries(queryParameters)
741
+ .map(([key, value]) => {
742
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
743
+ return value
744
+ .map(
745
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
746
+ )
747
+ .join('&');
748
+ }
749
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
750
+ })
751
+ .join('&');
752
+ return (
753
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
754
+ );
755
+ };
756
+
757
+ private $headers = (
758
+ headerParameters: { [key: string]: any },
759
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
760
+ ): [string, string][] => {
761
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
762
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
763
+ return value.map((v) => [key, String(v)]) as [string, string][];
764
+ }
765
+ return [[key, String(value)]];
766
+ });
767
+ };
768
+
769
+ private $fetch: typeof fetch = (...args) =>
770
+ (this.$config.fetch ?? fetch)(...args);
771
+
772
+ public async testAnyOfEnum(
773
+ input?: TestAnyOfEnumRequest,
774
+ ): Promise<TestAnyOfEnum200Response> {
775
+ const pathParameters: { [key: string]: any } = {};
776
+ const queryParameters: { [key: string]: any } = {};
777
+ const headerParameters: { [key: string]: any } = {};
778
+ if (!this.$config.options?.omitContentTypeHeader) {
779
+ headerParameters['Content-Type'] = 'application/json';
780
+ }
781
+ const body =
782
+ input === undefined
783
+ ? undefined
784
+ : typeof input === 'object'
785
+ ? JSON.stringify($IO.TestAnyOfEnumRequestContent.toJson(input))
786
+ : String($IO.TestAnyOfEnumRequestContent.toJson(input));
787
+
788
+ const response = await this.$fetch(
789
+ this.$url('/anyOfEnum', pathParameters, queryParameters),
790
+ {
791
+ headers: this.$headers(headerParameters),
792
+ method: 'POST',
793
+ body,
794
+ },
795
+ );
796
+
797
+ if (response.status === 200) {
798
+ return $IO.TestAnyOfEnum200Response.fromJson(await response.json());
799
+ }
800
+ throw new Error(
801
+ \`Unknown response status \${response.status} returned by API\`,
802
+ );
803
+ }
804
+ }
805
+ "
806
+ `;
807
+
359
808
  exports[`openApiTsClientGenerator - composite schemas > should handle composite primitive and array request bodies 1`] = `
360
809
  "export type CompositeRequestContent =
361
810
  | string
@@ -738,7 +1187,6 @@ exports[`openApiTsClientGenerator - composite schemas > should handle inline pri
738
1187
  TestComposites200ResponseAnyOf,
739
1188
  TestComposites200ResponseAnyOf1,
740
1189
  TestCompositesRequestContent,
741
- TestCompositesRequestContentOneOf,
742
1190
  TestEnums200Response,
743
1191
  TestArraysRequest,
744
1192
  TestArraysWithOtherParametersRequest,
@@ -953,9 +1401,6 @@ export class $IO {
953
1401
  if (typeof json === 'string') {
954
1402
  return json;
955
1403
  }
956
- if (typeof json === 'string') {
957
- return json;
958
- }
959
1404
  return json;
960
1405
  },
961
1406
  };