@aws/nx-plugin 0.55.0 → 0.55.2

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.
@@ -616,3 +616,1305 @@ export class TestApi {
616
616
  }
617
617
  "
618
618
  `;
619
+
620
+ exports[`openApiTsClientGenerator - FastAPI > should handle schemas with hyphens as generated by fastapi >=0.119.0 1`] = `
621
+ "export type ContentBlockInput = {
622
+ image?: ContentBlockInputImage;
623
+ text?: Text;
624
+ toolResult?: ContentBlockInputToolResult;
625
+ toolUse?: ContentBlockInputToolUse;
626
+ };
627
+ export type ContentBlockInputImage = ImageContent | null;
628
+ export type ContentBlockInputToolResult = ToolResultInput | null;
629
+ export type ContentBlockInputToolUse = ToolUse | null;
630
+ export type ContentBlockOutput = {
631
+ image?: ContentBlockOutputImage;
632
+ text?: Text1;
633
+ toolResult?: ContentBlockOutputToolResult;
634
+ toolUse?: ContentBlockOutputToolUse;
635
+ };
636
+ export type ContentBlockOutputImage = ImageContent | null;
637
+ export type ContentBlockOutputToolResult = ToolResultOutput | null;
638
+ export type ContentBlockOutputToolUse = ToolUse | null;
639
+ export type HTTPValidationError = {
640
+ detail?: Array<ValidationError>;
641
+ };
642
+ export type ImageContent = {
643
+ format: ImageFormat;
644
+ source: ImageSource;
645
+ };
646
+ /**
647
+ * Supported image formats.
648
+ */
649
+ export type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp';
650
+ export type ImageSource = {
651
+ bytes: Blob;
652
+ };
653
+ export type InternalServerErrorDetails = {
654
+ detail: string;
655
+ };
656
+ export type InvokeInput = {
657
+ message: string;
658
+ sessionId: string;
659
+ };
660
+ export type Json = unknown | null;
661
+ export type Json1 = unknown | null;
662
+ export type ListMessagesOutput = {
663
+ messages: Array<MessageOutput>;
664
+ };
665
+ export type ListMessagesRequestQueryParameters = {
666
+ sessionId: string;
667
+ };
668
+ export type LocationItem = string | number;
669
+ export type MessageInput = {
670
+ content: Array<ContentBlockInput>;
671
+ role: Role;
672
+ };
673
+ export type MessageOutput = {
674
+ content: Array<ContentBlockOutput>;
675
+ role: Role;
676
+ };
677
+ /**
678
+ * Role of a message sender.
679
+
680
+ - USER: Messages from the user to the assistant
681
+ - ASSISTANT: Messages from the assistant to the user
682
+ */
683
+ export type Role = 'user' | 'assistant';
684
+ export type Text = string | null;
685
+ export type Text1 = string | null;
686
+ export type Text2 = string | null;
687
+ export type Text3 = string | null;
688
+ export type ToolResultContentInput = {
689
+ image?: ToolResultContentInputImage;
690
+ json?: Json;
691
+ text?: Text2;
692
+ };
693
+ export type ToolResultContentInputImage = ImageContent | null;
694
+ /**
695
+ * Content returned by a tool execution.
696
+
697
+ Attributes:
698
+ image: Image content returned by the tool.
699
+ json: JSON-serializable data returned by the tool.
700
+ text: Text content returned by the tool.
701
+ */
702
+ export type ToolResultContentOutput = {
703
+ image?: ToolResultContentOutputImage;
704
+ json?: Json1;
705
+ text?: Text3;
706
+ };
707
+ export type ToolResultContentOutputImage = ImageContent | null;
708
+ export type ToolResultInput = {
709
+ content: Array<ToolResultContentInput>;
710
+ status: ToolResultStatus;
711
+ toolUseId: string;
712
+ };
713
+ export type ToolResultOutput = {
714
+ content: Array<ToolResultContentOutput>;
715
+ status: ToolResultStatus;
716
+ toolUseId: string;
717
+ };
718
+ /**
719
+ * Status of a tool execution result.
720
+ */
721
+ export type ToolResultStatus = 'success' | 'error';
722
+ export type ToolUse = {
723
+ input: unknown;
724
+ name: string;
725
+ toolUseId: string;
726
+ };
727
+ export type ValidationError = {
728
+ loc: Array<LocationItem>;
729
+ msg: string;
730
+ type: string;
731
+ };
732
+
733
+ export type InvokeRequest = InvokeInput;
734
+ export type Invoke422Error = {
735
+ status: 422;
736
+ error: HTTPValidationError;
737
+ };
738
+ export type Invoke500Error = {
739
+ status: 500;
740
+ error: InternalServerErrorDetails;
741
+ };
742
+ export type InvokeError = Invoke422Error | Invoke500Error;
743
+
744
+ export type ListMessagesRequest = ListMessagesRequestQueryParameters;
745
+ export type ListMessages422Error = {
746
+ status: 422;
747
+ error: HTTPValidationError;
748
+ };
749
+ export type ListMessages500Error = {
750
+ status: 500;
751
+ error: InternalServerErrorDetails;
752
+ };
753
+ export type ListMessagesError = ListMessages422Error | ListMessages500Error;
754
+ export type Ping500Error = {
755
+ status: 500;
756
+ error: InternalServerErrorDetails;
757
+ };
758
+ export type PingError = Ping500Error;
759
+ "
760
+ `;
761
+
762
+ exports[`openApiTsClientGenerator - FastAPI > should handle schemas with hyphens as generated by fastapi >=0.119.0 2`] = `
763
+ "import type {
764
+ ContentBlockInput,
765
+ ContentBlockInputImage,
766
+ ContentBlockInputToolResult,
767
+ ContentBlockInputToolUse,
768
+ ContentBlockOutput,
769
+ ContentBlockOutputImage,
770
+ ContentBlockOutputToolResult,
771
+ ContentBlockOutputToolUse,
772
+ HTTPValidationError,
773
+ ImageContent,
774
+ ImageSource,
775
+ InternalServerErrorDetails,
776
+ InvokeInput,
777
+ Json,
778
+ Json1,
779
+ ListMessagesOutput,
780
+ ListMessagesRequestQueryParameters,
781
+ LocationItem,
782
+ MessageInput,
783
+ MessageOutput,
784
+ Text,
785
+ Text1,
786
+ Text2,
787
+ Text3,
788
+ ToolResultContentInput,
789
+ ToolResultContentInputImage,
790
+ ToolResultContentOutput,
791
+ ToolResultContentOutputImage,
792
+ ToolResultInput,
793
+ ToolResultOutput,
794
+ ToolUse,
795
+ ValidationError,
796
+ InvokeRequest,
797
+ ListMessagesRequest,
798
+ } from './types.gen.js';
799
+
800
+ /**
801
+ * Utility for serialisation and deserialisation of API types.
802
+ */
803
+ export class $IO {
804
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
805
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
806
+
807
+ public static ContentBlockInput = {
808
+ toJson: (model: ContentBlockInput): any => {
809
+ if (model === undefined || model === null) {
810
+ return model;
811
+ }
812
+ return {
813
+ ...(model.image === undefined
814
+ ? {}
815
+ : {
816
+ image: $IO.ContentBlockInputImage.toJson(model.image),
817
+ }),
818
+ ...(model.text === undefined
819
+ ? {}
820
+ : {
821
+ text: $IO.Text.toJson(model.text),
822
+ }),
823
+ ...(model.toolResult === undefined
824
+ ? {}
825
+ : {
826
+ toolResult: $IO.ContentBlockInputToolResult.toJson(
827
+ model.toolResult,
828
+ ),
829
+ }),
830
+ ...(model.toolUse === undefined
831
+ ? {}
832
+ : {
833
+ toolUse: $IO.ContentBlockInputToolUse.toJson(model.toolUse),
834
+ }),
835
+ };
836
+ },
837
+ fromJson: (json: any): ContentBlockInput => {
838
+ if (json === undefined || json === null) {
839
+ return json;
840
+ }
841
+ return {
842
+ ...(json['image'] === undefined
843
+ ? {}
844
+ : {
845
+ image: $IO.ContentBlockInputImage.fromJson(json['image']),
846
+ }),
847
+ ...(json['text'] === undefined
848
+ ? {}
849
+ : {
850
+ text: $IO.Text.fromJson(json['text']),
851
+ }),
852
+ ...(json['toolResult'] === undefined
853
+ ? {}
854
+ : {
855
+ toolResult: $IO.ContentBlockInputToolResult.fromJson(
856
+ json['toolResult'],
857
+ ),
858
+ }),
859
+ ...(json['toolUse'] === undefined
860
+ ? {}
861
+ : {
862
+ toolUse: $IO.ContentBlockInputToolUse.fromJson(json['toolUse']),
863
+ }),
864
+ };
865
+ },
866
+ };
867
+
868
+ public static ContentBlockInputImage = {
869
+ toJson: (model: ContentBlockInputImage): any => {
870
+ if (model === undefined || model === null) {
871
+ return model;
872
+ }
873
+ return {
874
+ ...$IO.ImageContent.toJson(model as ImageContent),
875
+ };
876
+ },
877
+ fromJson: (json: any): ContentBlockInputImage => {
878
+ if (json === undefined || json === null) {
879
+ return json;
880
+ }
881
+ return {
882
+ ...$IO.ImageContent.fromJson(json),
883
+ };
884
+ },
885
+ };
886
+
887
+ public static ContentBlockInputToolResult = {
888
+ toJson: (model: ContentBlockInputToolResult): any => {
889
+ if (model === undefined || model === null) {
890
+ return model;
891
+ }
892
+ return {
893
+ ...$IO.ToolResultInput.toJson(model as ToolResultInput),
894
+ };
895
+ },
896
+ fromJson: (json: any): ContentBlockInputToolResult => {
897
+ if (json === undefined || json === null) {
898
+ return json;
899
+ }
900
+ return {
901
+ ...$IO.ToolResultInput.fromJson(json),
902
+ };
903
+ },
904
+ };
905
+
906
+ public static ContentBlockInputToolUse = {
907
+ toJson: (model: ContentBlockInputToolUse): any => {
908
+ if (model === undefined || model === null) {
909
+ return model;
910
+ }
911
+ return {
912
+ ...$IO.ToolUse.toJson(model as ToolUse),
913
+ };
914
+ },
915
+ fromJson: (json: any): ContentBlockInputToolUse => {
916
+ if (json === undefined || json === null) {
917
+ return json;
918
+ }
919
+ return {
920
+ ...$IO.ToolUse.fromJson(json),
921
+ };
922
+ },
923
+ };
924
+
925
+ public static ContentBlockOutput = {
926
+ toJson: (model: ContentBlockOutput): any => {
927
+ if (model === undefined || model === null) {
928
+ return model;
929
+ }
930
+ return {
931
+ ...(model.image === undefined
932
+ ? {}
933
+ : {
934
+ image: $IO.ContentBlockOutputImage.toJson(model.image),
935
+ }),
936
+ ...(model.text === undefined
937
+ ? {}
938
+ : {
939
+ text: $IO.Text1.toJson(model.text),
940
+ }),
941
+ ...(model.toolResult === undefined
942
+ ? {}
943
+ : {
944
+ toolResult: $IO.ContentBlockOutputToolResult.toJson(
945
+ model.toolResult,
946
+ ),
947
+ }),
948
+ ...(model.toolUse === undefined
949
+ ? {}
950
+ : {
951
+ toolUse: $IO.ContentBlockOutputToolUse.toJson(model.toolUse),
952
+ }),
953
+ };
954
+ },
955
+ fromJson: (json: any): ContentBlockOutput => {
956
+ if (json === undefined || json === null) {
957
+ return json;
958
+ }
959
+ return {
960
+ ...(json['image'] === undefined
961
+ ? {}
962
+ : {
963
+ image: $IO.ContentBlockOutputImage.fromJson(json['image']),
964
+ }),
965
+ ...(json['text'] === undefined
966
+ ? {}
967
+ : {
968
+ text: $IO.Text1.fromJson(json['text']),
969
+ }),
970
+ ...(json['toolResult'] === undefined
971
+ ? {}
972
+ : {
973
+ toolResult: $IO.ContentBlockOutputToolResult.fromJson(
974
+ json['toolResult'],
975
+ ),
976
+ }),
977
+ ...(json['toolUse'] === undefined
978
+ ? {}
979
+ : {
980
+ toolUse: $IO.ContentBlockOutputToolUse.fromJson(json['toolUse']),
981
+ }),
982
+ };
983
+ },
984
+ };
985
+
986
+ public static ContentBlockOutputImage = {
987
+ toJson: (model: ContentBlockOutputImage): any => {
988
+ if (model === undefined || model === null) {
989
+ return model;
990
+ }
991
+ return {
992
+ ...$IO.ImageContent.toJson(model as ImageContent),
993
+ };
994
+ },
995
+ fromJson: (json: any): ContentBlockOutputImage => {
996
+ if (json === undefined || json === null) {
997
+ return json;
998
+ }
999
+ return {
1000
+ ...$IO.ImageContent.fromJson(json),
1001
+ };
1002
+ },
1003
+ };
1004
+
1005
+ public static ContentBlockOutputToolResult = {
1006
+ toJson: (model: ContentBlockOutputToolResult): any => {
1007
+ if (model === undefined || model === null) {
1008
+ return model;
1009
+ }
1010
+ return {
1011
+ ...$IO.ToolResultOutput.toJson(model as ToolResultOutput),
1012
+ };
1013
+ },
1014
+ fromJson: (json: any): ContentBlockOutputToolResult => {
1015
+ if (json === undefined || json === null) {
1016
+ return json;
1017
+ }
1018
+ return {
1019
+ ...$IO.ToolResultOutput.fromJson(json),
1020
+ };
1021
+ },
1022
+ };
1023
+
1024
+ public static ContentBlockOutputToolUse = {
1025
+ toJson: (model: ContentBlockOutputToolUse): any => {
1026
+ if (model === undefined || model === null) {
1027
+ return model;
1028
+ }
1029
+ return {
1030
+ ...$IO.ToolUse.toJson(model as ToolUse),
1031
+ };
1032
+ },
1033
+ fromJson: (json: any): ContentBlockOutputToolUse => {
1034
+ if (json === undefined || json === null) {
1035
+ return json;
1036
+ }
1037
+ return {
1038
+ ...$IO.ToolUse.fromJson(json),
1039
+ };
1040
+ },
1041
+ };
1042
+
1043
+ public static HTTPValidationError = {
1044
+ toJson: (model: HTTPValidationError): any => {
1045
+ if (model === undefined || model === null) {
1046
+ return model;
1047
+ }
1048
+ return {
1049
+ ...(model.detail === undefined
1050
+ ? {}
1051
+ : {
1052
+ detail: model.detail.map($IO.ValidationError.toJson),
1053
+ }),
1054
+ };
1055
+ },
1056
+ fromJson: (json: any): HTTPValidationError => {
1057
+ if (json === undefined || json === null) {
1058
+ return json;
1059
+ }
1060
+ return {
1061
+ ...(json['detail'] === undefined
1062
+ ? {}
1063
+ : {
1064
+ detail: (json['detail'] as Array<any>).map(
1065
+ $IO.ValidationError.fromJson,
1066
+ ),
1067
+ }),
1068
+ };
1069
+ },
1070
+ };
1071
+
1072
+ public static ImageContent = {
1073
+ toJson: (model: ImageContent): any => {
1074
+ if (model === undefined || model === null) {
1075
+ return model;
1076
+ }
1077
+ return {
1078
+ ...(model.format === undefined
1079
+ ? {}
1080
+ : {
1081
+ format: model.format,
1082
+ }),
1083
+ ...(model.source === undefined
1084
+ ? {}
1085
+ : {
1086
+ source: $IO.ImageSource.toJson(model.source),
1087
+ }),
1088
+ };
1089
+ },
1090
+ fromJson: (json: any): ImageContent => {
1091
+ if (json === undefined || json === null) {
1092
+ return json;
1093
+ }
1094
+ return {
1095
+ format: json['format'],
1096
+ source: $IO.ImageSource.fromJson(json['source']),
1097
+ };
1098
+ },
1099
+ };
1100
+
1101
+ public static ImageSource = {
1102
+ toJson: (model: ImageSource): any => {
1103
+ if (model === undefined || model === null) {
1104
+ return model;
1105
+ }
1106
+ return {
1107
+ ...(model.bytes === undefined
1108
+ ? {}
1109
+ : {
1110
+ bytes: model.bytes,
1111
+ }),
1112
+ };
1113
+ },
1114
+ fromJson: (json: any): ImageSource => {
1115
+ if (json === undefined || json === null) {
1116
+ return json;
1117
+ }
1118
+ return {
1119
+ bytes: json['bytes'],
1120
+ };
1121
+ },
1122
+ };
1123
+
1124
+ public static InternalServerErrorDetails = {
1125
+ toJson: (model: InternalServerErrorDetails): any => {
1126
+ if (model === undefined || model === null) {
1127
+ return model;
1128
+ }
1129
+ return {
1130
+ ...(model.detail === undefined
1131
+ ? {}
1132
+ : {
1133
+ detail: model.detail,
1134
+ }),
1135
+ };
1136
+ },
1137
+ fromJson: (json: any): InternalServerErrorDetails => {
1138
+ if (json === undefined || json === null) {
1139
+ return json;
1140
+ }
1141
+ return {
1142
+ detail: json['detail'],
1143
+ };
1144
+ },
1145
+ };
1146
+
1147
+ public static InvokeInput = {
1148
+ toJson: (model: InvokeInput): any => {
1149
+ if (model === undefined || model === null) {
1150
+ return model;
1151
+ }
1152
+ return {
1153
+ ...(model.message === undefined
1154
+ ? {}
1155
+ : {
1156
+ message: model.message,
1157
+ }),
1158
+ ...(model.sessionId === undefined
1159
+ ? {}
1160
+ : {
1161
+ session_id: model.sessionId,
1162
+ }),
1163
+ };
1164
+ },
1165
+ fromJson: (json: any): InvokeInput => {
1166
+ if (json === undefined || json === null) {
1167
+ return json;
1168
+ }
1169
+ return {
1170
+ message: json['message'],
1171
+ sessionId: json['session_id'],
1172
+ };
1173
+ },
1174
+ };
1175
+
1176
+ public static Json = {
1177
+ toJson: (model: Json): any => {
1178
+ if (model === undefined || model === null) {
1179
+ return model;
1180
+ }
1181
+ return model;
1182
+ },
1183
+ fromJson: (json: any): Json => {
1184
+ if (json === undefined || json === null) {
1185
+ return json;
1186
+ }
1187
+ return json;
1188
+ },
1189
+ };
1190
+
1191
+ public static Json1 = {
1192
+ toJson: (model: Json1): any => {
1193
+ if (model === undefined || model === null) {
1194
+ return model;
1195
+ }
1196
+ return model;
1197
+ },
1198
+ fromJson: (json: any): Json1 => {
1199
+ if (json === undefined || json === null) {
1200
+ return json;
1201
+ }
1202
+ return json;
1203
+ },
1204
+ };
1205
+
1206
+ public static ListMessagesOutput = {
1207
+ toJson: (model: ListMessagesOutput): any => {
1208
+ if (model === undefined || model === null) {
1209
+ return model;
1210
+ }
1211
+ return {
1212
+ ...(model.messages === undefined
1213
+ ? {}
1214
+ : {
1215
+ messages: model.messages.map($IO.MessageOutput.toJson),
1216
+ }),
1217
+ };
1218
+ },
1219
+ fromJson: (json: any): ListMessagesOutput => {
1220
+ if (json === undefined || json === null) {
1221
+ return json;
1222
+ }
1223
+ return {
1224
+ messages: (json['messages'] as Array<any>).map(
1225
+ $IO.MessageOutput.fromJson,
1226
+ ),
1227
+ };
1228
+ },
1229
+ };
1230
+
1231
+ public static ListMessagesRequestQueryParameters = {
1232
+ toJson: (model: ListMessagesRequestQueryParameters): any => {
1233
+ if (model === undefined || model === null) {
1234
+ return model;
1235
+ }
1236
+ return {
1237
+ ...(model.sessionId === undefined
1238
+ ? {}
1239
+ : {
1240
+ session_id: model.sessionId,
1241
+ }),
1242
+ };
1243
+ },
1244
+ fromJson: (json: any): ListMessagesRequestQueryParameters => {
1245
+ if (json === undefined || json === null) {
1246
+ return json;
1247
+ }
1248
+ return {
1249
+ sessionId: json['session_id'],
1250
+ };
1251
+ },
1252
+ };
1253
+
1254
+ public static LocationItem = {
1255
+ toJson: (model: LocationItem): any => {
1256
+ if (model === undefined || model === null) {
1257
+ return model;
1258
+ }
1259
+ if (typeof model === 'string') {
1260
+ return model;
1261
+ }
1262
+ if (typeof model === 'number') {
1263
+ return model;
1264
+ }
1265
+ return model;
1266
+ },
1267
+ fromJson: (json: any): LocationItem => {
1268
+ if (json === undefined || json === null) {
1269
+ return json;
1270
+ }
1271
+ if (typeof json === 'string') {
1272
+ return json;
1273
+ }
1274
+ if (typeof json === 'number') {
1275
+ return json;
1276
+ }
1277
+ return json;
1278
+ },
1279
+ };
1280
+
1281
+ public static MessageInput = {
1282
+ toJson: (model: MessageInput): any => {
1283
+ if (model === undefined || model === null) {
1284
+ return model;
1285
+ }
1286
+ return {
1287
+ ...(model.content === undefined
1288
+ ? {}
1289
+ : {
1290
+ content: model.content.map($IO.ContentBlockInput.toJson),
1291
+ }),
1292
+ ...(model.role === undefined
1293
+ ? {}
1294
+ : {
1295
+ role: model.role,
1296
+ }),
1297
+ };
1298
+ },
1299
+ fromJson: (json: any): MessageInput => {
1300
+ if (json === undefined || json === null) {
1301
+ return json;
1302
+ }
1303
+ return {
1304
+ content: (json['content'] as Array<any>).map(
1305
+ $IO.ContentBlockInput.fromJson,
1306
+ ),
1307
+ role: json['role'],
1308
+ };
1309
+ },
1310
+ };
1311
+
1312
+ public static MessageOutput = {
1313
+ toJson: (model: MessageOutput): any => {
1314
+ if (model === undefined || model === null) {
1315
+ return model;
1316
+ }
1317
+ return {
1318
+ ...(model.content === undefined
1319
+ ? {}
1320
+ : {
1321
+ content: model.content.map($IO.ContentBlockOutput.toJson),
1322
+ }),
1323
+ ...(model.role === undefined
1324
+ ? {}
1325
+ : {
1326
+ role: model.role,
1327
+ }),
1328
+ };
1329
+ },
1330
+ fromJson: (json: any): MessageOutput => {
1331
+ if (json === undefined || json === null) {
1332
+ return json;
1333
+ }
1334
+ return {
1335
+ content: (json['content'] as Array<any>).map(
1336
+ $IO.ContentBlockOutput.fromJson,
1337
+ ),
1338
+ role: json['role'],
1339
+ };
1340
+ },
1341
+ };
1342
+
1343
+ public static Text = {
1344
+ toJson: (model: Text): any => {
1345
+ if (model === undefined || model === null) {
1346
+ return model;
1347
+ }
1348
+ if (typeof model === 'string') {
1349
+ return model;
1350
+ }
1351
+ return model;
1352
+ },
1353
+ fromJson: (json: any): Text => {
1354
+ if (json === undefined || json === null) {
1355
+ return json;
1356
+ }
1357
+ if (typeof json === 'string') {
1358
+ return json;
1359
+ }
1360
+ return json;
1361
+ },
1362
+ };
1363
+
1364
+ public static Text1 = {
1365
+ toJson: (model: Text1): any => {
1366
+ if (model === undefined || model === null) {
1367
+ return model;
1368
+ }
1369
+ if (typeof model === 'string') {
1370
+ return model;
1371
+ }
1372
+ return model;
1373
+ },
1374
+ fromJson: (json: any): Text1 => {
1375
+ if (json === undefined || json === null) {
1376
+ return json;
1377
+ }
1378
+ if (typeof json === 'string') {
1379
+ return json;
1380
+ }
1381
+ return json;
1382
+ },
1383
+ };
1384
+
1385
+ public static Text2 = {
1386
+ toJson: (model: Text2): any => {
1387
+ if (model === undefined || model === null) {
1388
+ return model;
1389
+ }
1390
+ if (typeof model === 'string') {
1391
+ return model;
1392
+ }
1393
+ return model;
1394
+ },
1395
+ fromJson: (json: any): Text2 => {
1396
+ if (json === undefined || json === null) {
1397
+ return json;
1398
+ }
1399
+ if (typeof json === 'string') {
1400
+ return json;
1401
+ }
1402
+ return json;
1403
+ },
1404
+ };
1405
+
1406
+ public static Text3 = {
1407
+ toJson: (model: Text3): any => {
1408
+ if (model === undefined || model === null) {
1409
+ return model;
1410
+ }
1411
+ if (typeof model === 'string') {
1412
+ return model;
1413
+ }
1414
+ return model;
1415
+ },
1416
+ fromJson: (json: any): Text3 => {
1417
+ if (json === undefined || json === null) {
1418
+ return json;
1419
+ }
1420
+ if (typeof json === 'string') {
1421
+ return json;
1422
+ }
1423
+ return json;
1424
+ },
1425
+ };
1426
+
1427
+ public static ToolResultContentInput = {
1428
+ toJson: (model: ToolResultContentInput): any => {
1429
+ if (model === undefined || model === null) {
1430
+ return model;
1431
+ }
1432
+ return {
1433
+ ...(model.image === undefined
1434
+ ? {}
1435
+ : {
1436
+ image: $IO.ToolResultContentInputImage.toJson(model.image),
1437
+ }),
1438
+ ...(model.json === undefined
1439
+ ? {}
1440
+ : {
1441
+ json: $IO.Json.toJson(model.json),
1442
+ }),
1443
+ ...(model.text === undefined
1444
+ ? {}
1445
+ : {
1446
+ text: $IO.Text2.toJson(model.text),
1447
+ }),
1448
+ };
1449
+ },
1450
+ fromJson: (json: any): ToolResultContentInput => {
1451
+ if (json === undefined || json === null) {
1452
+ return json;
1453
+ }
1454
+ return {
1455
+ ...(json['image'] === undefined
1456
+ ? {}
1457
+ : {
1458
+ image: $IO.ToolResultContentInputImage.fromJson(json['image']),
1459
+ }),
1460
+ ...(json['json'] === undefined
1461
+ ? {}
1462
+ : {
1463
+ json: $IO.Json.fromJson(json['json']),
1464
+ }),
1465
+ ...(json['text'] === undefined
1466
+ ? {}
1467
+ : {
1468
+ text: $IO.Text2.fromJson(json['text']),
1469
+ }),
1470
+ };
1471
+ },
1472
+ };
1473
+
1474
+ public static ToolResultContentInputImage = {
1475
+ toJson: (model: ToolResultContentInputImage): any => {
1476
+ if (model === undefined || model === null) {
1477
+ return model;
1478
+ }
1479
+ return {
1480
+ ...$IO.ImageContent.toJson(model as ImageContent),
1481
+ };
1482
+ },
1483
+ fromJson: (json: any): ToolResultContentInputImage => {
1484
+ if (json === undefined || json === null) {
1485
+ return json;
1486
+ }
1487
+ return {
1488
+ ...$IO.ImageContent.fromJson(json),
1489
+ };
1490
+ },
1491
+ };
1492
+
1493
+ public static ToolResultContentOutput = {
1494
+ toJson: (model: ToolResultContentOutput): any => {
1495
+ if (model === undefined || model === null) {
1496
+ return model;
1497
+ }
1498
+ return {
1499
+ ...(model.image === undefined
1500
+ ? {}
1501
+ : {
1502
+ image: $IO.ToolResultContentOutputImage.toJson(model.image),
1503
+ }),
1504
+ ...(model.json === undefined
1505
+ ? {}
1506
+ : {
1507
+ json: $IO.Json1.toJson(model.json),
1508
+ }),
1509
+ ...(model.text === undefined
1510
+ ? {}
1511
+ : {
1512
+ text: $IO.Text3.toJson(model.text),
1513
+ }),
1514
+ };
1515
+ },
1516
+ fromJson: (json: any): ToolResultContentOutput => {
1517
+ if (json === undefined || json === null) {
1518
+ return json;
1519
+ }
1520
+ return {
1521
+ ...(json['image'] === undefined
1522
+ ? {}
1523
+ : {
1524
+ image: $IO.ToolResultContentOutputImage.fromJson(json['image']),
1525
+ }),
1526
+ ...(json['json'] === undefined
1527
+ ? {}
1528
+ : {
1529
+ json: $IO.Json1.fromJson(json['json']),
1530
+ }),
1531
+ ...(json['text'] === undefined
1532
+ ? {}
1533
+ : {
1534
+ text: $IO.Text3.fromJson(json['text']),
1535
+ }),
1536
+ };
1537
+ },
1538
+ };
1539
+
1540
+ public static ToolResultContentOutputImage = {
1541
+ toJson: (model: ToolResultContentOutputImage): any => {
1542
+ if (model === undefined || model === null) {
1543
+ return model;
1544
+ }
1545
+ return {
1546
+ ...$IO.ImageContent.toJson(model as ImageContent),
1547
+ };
1548
+ },
1549
+ fromJson: (json: any): ToolResultContentOutputImage => {
1550
+ if (json === undefined || json === null) {
1551
+ return json;
1552
+ }
1553
+ return {
1554
+ ...$IO.ImageContent.fromJson(json),
1555
+ };
1556
+ },
1557
+ };
1558
+
1559
+ public static ToolResultInput = {
1560
+ toJson: (model: ToolResultInput): any => {
1561
+ if (model === undefined || model === null) {
1562
+ return model;
1563
+ }
1564
+ return {
1565
+ ...(model.content === undefined
1566
+ ? {}
1567
+ : {
1568
+ content: model.content.map($IO.ToolResultContentInput.toJson),
1569
+ }),
1570
+ ...(model.status === undefined
1571
+ ? {}
1572
+ : {
1573
+ status: model.status,
1574
+ }),
1575
+ ...(model.toolUseId === undefined
1576
+ ? {}
1577
+ : {
1578
+ toolUseId: model.toolUseId,
1579
+ }),
1580
+ };
1581
+ },
1582
+ fromJson: (json: any): ToolResultInput => {
1583
+ if (json === undefined || json === null) {
1584
+ return json;
1585
+ }
1586
+ return {
1587
+ content: (json['content'] as Array<any>).map(
1588
+ $IO.ToolResultContentInput.fromJson,
1589
+ ),
1590
+ status: json['status'],
1591
+ toolUseId: json['toolUseId'],
1592
+ };
1593
+ },
1594
+ };
1595
+
1596
+ public static ToolResultOutput = {
1597
+ toJson: (model: ToolResultOutput): any => {
1598
+ if (model === undefined || model === null) {
1599
+ return model;
1600
+ }
1601
+ return {
1602
+ ...(model.content === undefined
1603
+ ? {}
1604
+ : {
1605
+ content: model.content.map($IO.ToolResultContentOutput.toJson),
1606
+ }),
1607
+ ...(model.status === undefined
1608
+ ? {}
1609
+ : {
1610
+ status: model.status,
1611
+ }),
1612
+ ...(model.toolUseId === undefined
1613
+ ? {}
1614
+ : {
1615
+ toolUseId: model.toolUseId,
1616
+ }),
1617
+ };
1618
+ },
1619
+ fromJson: (json: any): ToolResultOutput => {
1620
+ if (json === undefined || json === null) {
1621
+ return json;
1622
+ }
1623
+ return {
1624
+ content: (json['content'] as Array<any>).map(
1625
+ $IO.ToolResultContentOutput.fromJson,
1626
+ ),
1627
+ status: json['status'],
1628
+ toolUseId: json['toolUseId'],
1629
+ };
1630
+ },
1631
+ };
1632
+
1633
+ public static ToolUse = {
1634
+ toJson: (model: ToolUse): any => {
1635
+ if (model === undefined || model === null) {
1636
+ return model;
1637
+ }
1638
+ return {
1639
+ ...(model.input === undefined
1640
+ ? {}
1641
+ : {
1642
+ input: model.input,
1643
+ }),
1644
+ ...(model.name === undefined
1645
+ ? {}
1646
+ : {
1647
+ name: model.name,
1648
+ }),
1649
+ ...(model.toolUseId === undefined
1650
+ ? {}
1651
+ : {
1652
+ toolUseId: model.toolUseId,
1653
+ }),
1654
+ };
1655
+ },
1656
+ fromJson: (json: any): ToolUse => {
1657
+ if (json === undefined || json === null) {
1658
+ return json;
1659
+ }
1660
+ return {
1661
+ input: json['input'],
1662
+ name: json['name'],
1663
+ toolUseId: json['toolUseId'],
1664
+ };
1665
+ },
1666
+ };
1667
+
1668
+ public static ValidationError = {
1669
+ toJson: (model: ValidationError): any => {
1670
+ if (model === undefined || model === null) {
1671
+ return model;
1672
+ }
1673
+ return {
1674
+ ...(model.loc === undefined
1675
+ ? {}
1676
+ : {
1677
+ loc: model.loc.map((item0) => item0),
1678
+ }),
1679
+ ...(model.msg === undefined
1680
+ ? {}
1681
+ : {
1682
+ msg: model.msg,
1683
+ }),
1684
+ ...(model.type === undefined
1685
+ ? {}
1686
+ : {
1687
+ type: model.type,
1688
+ }),
1689
+ };
1690
+ },
1691
+ fromJson: (json: any): ValidationError => {
1692
+ if (json === undefined || json === null) {
1693
+ return json;
1694
+ }
1695
+ return {
1696
+ loc: (json['loc'] as Array<any>).map((item0) => item0),
1697
+ msg: json['msg'],
1698
+ type: json['type'],
1699
+ };
1700
+ },
1701
+ };
1702
+ }
1703
+
1704
+ /**
1705
+ * Client configuration for TestApi
1706
+ */
1707
+ export interface TestApiConfig {
1708
+ /**
1709
+ * Base URL for the API
1710
+ */
1711
+ url: string;
1712
+ /**
1713
+ * Custom instance of fetch. By default the global 'fetch' is used.
1714
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
1715
+ */
1716
+ fetch?: typeof fetch;
1717
+ /**
1718
+ * Additional configuration
1719
+ */
1720
+ options?: {
1721
+ /**
1722
+ * By default, the client will add a Content-Type header, set to the media type defined for
1723
+ * the request in the OpenAPI specification.
1724
+ * Set this to false to omit this header.
1725
+ */
1726
+ omitContentTypeHeader?: boolean;
1727
+ };
1728
+ }
1729
+
1730
+ /**
1731
+ * API Client for TestApi
1732
+ */
1733
+ export class TestApi {
1734
+ private $config: TestApiConfig;
1735
+
1736
+ constructor(config: TestApiConfig) {
1737
+ this.$config = config;
1738
+
1739
+ this.invoke = this.invoke.bind(this);
1740
+ this.listMessages = this.listMessages.bind(this);
1741
+ this.ping = this.ping.bind(this);
1742
+ }
1743
+
1744
+ private $url = (
1745
+ path: string,
1746
+ pathParameters: { [key: string]: any },
1747
+ queryParameters: { [key: string]: any },
1748
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
1749
+ ): string => {
1750
+ const baseUrl = this.$config.url.endsWith('/')
1751
+ ? this.$config.url.slice(0, -1)
1752
+ : this.$config.url;
1753
+ const pathWithParameters = Object.entries(pathParameters).reduce(
1754
+ (withParams, [key, value]) =>
1755
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
1756
+ path,
1757
+ );
1758
+ const queryString = Object.entries(queryParameters)
1759
+ .map(([key, value]) => {
1760
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1761
+ return value
1762
+ .map(
1763
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
1764
+ )
1765
+ .join('&');
1766
+ }
1767
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
1768
+ })
1769
+ .join('&');
1770
+ return (
1771
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
1772
+ );
1773
+ };
1774
+
1775
+ private $headers = (
1776
+ headerParameters: { [key: string]: any },
1777
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
1778
+ ): [string, string][] => {
1779
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
1780
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
1781
+ return value.map((v) => [key, String(v)]) as [string, string][];
1782
+ }
1783
+ return [[key, String(value)]];
1784
+ });
1785
+ };
1786
+
1787
+ private $fetch: typeof fetch = (...args) =>
1788
+ (this.$config.fetch ?? fetch)(...args);
1789
+
1790
+ /**
1791
+ * Handler for agent invocation
1792
+ */
1793
+ public async *invoke(input: InvokeRequest): AsyncIterableIterator<string> {
1794
+ const pathParameters: { [key: string]: any } = {};
1795
+ const queryParameters: { [key: string]: any } = {};
1796
+ const headerParameters: { [key: string]: any } = {};
1797
+ if (!this.$config.options?.omitContentTypeHeader) {
1798
+ headerParameters['Content-Type'] = 'application/json';
1799
+ }
1800
+ const body =
1801
+ typeof input === 'object'
1802
+ ? JSON.stringify($IO.InvokeInput.toJson(input))
1803
+ : String($IO.InvokeInput.toJson(input));
1804
+
1805
+ const response = await this.$fetch(
1806
+ this.$url('/invocations', pathParameters, queryParameters),
1807
+ {
1808
+ headers: this.$headers(headerParameters),
1809
+ method: 'POST',
1810
+ body,
1811
+ },
1812
+ );
1813
+
1814
+ if (response.status === 200) {
1815
+ const reader = response.body
1816
+ ?.pipeThrough(new TextDecoderStream())
1817
+ .getReader();
1818
+ while (reader) {
1819
+ const { value, done } = await reader.read();
1820
+ if (done) return;
1821
+ yield value;
1822
+ }
1823
+ return;
1824
+ }
1825
+ if (response.status === 422) {
1826
+ throw {
1827
+ status: response.status,
1828
+ error: $IO.HTTPValidationError.fromJson(await response.json()),
1829
+ };
1830
+ }
1831
+ if (response.status === 500) {
1832
+ throw {
1833
+ status: response.status,
1834
+ error: $IO.InternalServerErrorDetails.fromJson(await response.json()),
1835
+ };
1836
+ }
1837
+ throw new Error(
1838
+ \`Unknown response status \${response.status} returned by API\`,
1839
+ );
1840
+ }
1841
+
1842
+ public async listMessages(
1843
+ input: ListMessagesRequest,
1844
+ ): Promise<ListMessagesOutput> {
1845
+ const pathParameters: { [key: string]: any } = {};
1846
+ const queryParameters: { [key: string]: any } =
1847
+ $IO.ListMessagesRequestQueryParameters.toJson(input);
1848
+ const headerParameters: { [key: string]: any } = {};
1849
+ const collectionFormats = {
1850
+ session_id: 'multi',
1851
+ } as const;
1852
+
1853
+ const body = undefined;
1854
+
1855
+ const response = await this.$fetch(
1856
+ this.$url(
1857
+ '/messages',
1858
+ pathParameters,
1859
+ queryParameters,
1860
+ collectionFormats,
1861
+ ),
1862
+ {
1863
+ headers: this.$headers(headerParameters, collectionFormats),
1864
+ method: 'GET',
1865
+ body,
1866
+ },
1867
+ );
1868
+
1869
+ if (response.status === 200) {
1870
+ return $IO.ListMessagesOutput.fromJson(await response.json());
1871
+ }
1872
+ if (response.status === 422) {
1873
+ throw {
1874
+ status: response.status,
1875
+ error: $IO.HTTPValidationError.fromJson(await response.json()),
1876
+ };
1877
+ }
1878
+ if (response.status === 500) {
1879
+ throw {
1880
+ status: response.status,
1881
+ error: $IO.InternalServerErrorDetails.fromJson(await response.json()),
1882
+ };
1883
+ }
1884
+ throw new Error(
1885
+ \`Unknown response status \${response.status} returned by API\`,
1886
+ );
1887
+ }
1888
+
1889
+ public async ping(): Promise<string> {
1890
+ const pathParameters: { [key: string]: any } = {};
1891
+ const queryParameters: { [key: string]: any } = {};
1892
+ const headerParameters: { [key: string]: any } = {};
1893
+
1894
+ const body = undefined;
1895
+
1896
+ const response = await this.$fetch(
1897
+ this.$url('/ping', pathParameters, queryParameters),
1898
+ {
1899
+ headers: this.$headers(headerParameters),
1900
+ method: 'GET',
1901
+ body,
1902
+ },
1903
+ );
1904
+
1905
+ if (response.status === 200) {
1906
+ return await response.text();
1907
+ }
1908
+ if (response.status === 500) {
1909
+ throw {
1910
+ status: response.status,
1911
+ error: $IO.InternalServerErrorDetails.fromJson(await response.json()),
1912
+ };
1913
+ }
1914
+ throw new Error(
1915
+ \`Unknown response status \${response.status} returned by API\`,
1916
+ );
1917
+ }
1918
+ }
1919
+ "
1920
+ `;