1- import { error , list , map , op , SCHEMA , struct , TypeRegistry } from "@smithy/core/schema" ;
1+ import { op , TypeRegistry } from "@smithy/core/schema" ;
22import { HttpRequest , HttpResponse } from "@smithy/protocol-http" ;
33import type {
4+ $SchemaRef ,
45 BlobSchema ,
56 BooleanSchema ,
67 MapSchemaModifier ,
78 NumericSchema ,
89 ResponseMetadata ,
910 RetryableTrait ,
10- SchemaRef ,
1111 StaticErrorSchema ,
12+ StaticOperationSchema ,
13+ StaticStructureSchema ,
1214 StringSchema ,
1315 TimestampDefaultSchema ,
1416} from "@smithy/types" ;
@@ -24,7 +26,7 @@ describe(SmithyRpcV2CborProtocol.name, () => {
2426 describe ( "serialization" , ( ) => {
2527 const testCases : Array < {
2628 name : string ;
27- schema : SchemaRef ;
29+ schema : $ SchemaRef;
2830 input : any ;
2931 expected : {
3032 request : any ;
@@ -33,16 +35,17 @@ describe(SmithyRpcV2CborProtocol.name, () => {
3335 } > = [
3436 {
3537 name : "document with timestamp and blob" ,
36- schema : struct (
38+ schema : [
39+ 3 ,
3740 "" ,
3841 "MyExtendedDocument" ,
3942 { } ,
4043 [ "timestamp" , "blob" ] ,
4144 [
4245 [ 4 satisfies TimestampDefaultSchema , 0 ] ,
4346 [ 21 satisfies BlobSchema , 0 ] ,
44- ]
45- ) ,
47+ ] ,
48+ ] ,
4649 input : {
4750 bool : true ,
4851 int : 5 ,
@@ -60,7 +63,8 @@ describe(SmithyRpcV2CborProtocol.name, () => {
6063 } ,
6164 {
6265 name : "do not write to header or query" ,
63- schema : struct (
66+ schema : [
67+ 3 ,
6468 "" ,
6569 "MyExtendedDocument" ,
6670 { } ,
@@ -71,8 +75,8 @@ describe(SmithyRpcV2CborProtocol.name, () => {
7175 [ 21 satisfies BlobSchema , { httpHeader : "blob" } ] ,
7276 [ ( 128 satisfies MapSchemaModifier ) | ( 0 satisfies StringSchema ) , { httpPrefixHeaders : "anti-" } ] ,
7377 [ ( 128 satisfies MapSchemaModifier ) | ( 0 satisfies StringSchema ) , { httpQueryParams : 1 } ] ,
74- ]
75- ) ,
78+ ] ,
79+ ] ,
7680 input : {
7781 bool : true ,
7882 timestamp : new Date ( 1_000_000 ) ,
@@ -108,18 +112,19 @@ describe(SmithyRpcV2CborProtocol.name, () => {
108112 } ,
109113 {
110114 name : "sparse list and map" ,
111- schema : struct (
115+ schema : [
116+ 3 ,
112117 "" ,
113118 "MyShape" ,
114119 0 ,
115120 [ "mySparseList" , "myRegularList" , "mySparseMap" , "myRegularMap" ] ,
116121 [
117- [ ( ) => list ( "" , "MySparseList" , { sparse : 1 } , 1 satisfies NumericSchema ) , { } ] ,
118- [ ( ) => list ( "" , "MyList" , { } , 1 satisfies NumericSchema ) , { } ] ,
119- [ ( ) => map ( "" , "MySparseMap" , { sparse : 1 } , 0 satisfies StringSchema , 1 satisfies NumericSchema ) , { } ] ,
120- [ ( ) => map ( "" , "MyMap" , { } , 0 satisfies StringSchema , 1 satisfies NumericSchema ) , { } ] ,
121- ]
122- ) ,
122+ [ ( ) => [ 1 , "" , "MySparseList" , { sparse : 1 } , 1 satisfies NumericSchema ] , { } ] ,
123+ [ ( ) => [ 1 , "" , "MyList" , { } , 1 satisfies NumericSchema ] , { } ] ,
124+ [ ( ) => [ 2 , "" , "MySparseMap" , { sparse : 1 } , 0 satisfies StringSchema , 1 satisfies NumericSchema ] , { } ] ,
125+ [ ( ) => [ 2 , "" , "MyMap" , { } , 0 satisfies StringSchema , 1 satisfies NumericSchema ] , { } ] ,
126+ ] ,
127+ ] ,
123128 input : {
124129 mySparseList : [ null , 1 , null , 2 , null ] ,
125130 myRegularList : [ null , 1 , null , 2 , null ] ,
@@ -211,18 +216,19 @@ describe(SmithyRpcV2CborProtocol.name, () => {
211216 const testCases = [
212217 {
213218 name : "sparse list and map" ,
214- schema : struct (
219+ schema : [
220+ 3 ,
215221 "" ,
216222 "MyShape" ,
217223 0 ,
218224 [ "mySparseList" , "myRegularList" , "mySparseMap" , "myRegularMap" ] ,
219225 [
220- [ ( ) => list ( "" , "MyList" , { sparse : 1 } , 1 satisfies NumericSchema ) , { } ] ,
221- [ ( ) => list ( "" , "MyList" , { } , 1 satisfies NumericSchema ) , { } ] ,
222- [ ( ) => map ( "" , "MyMap" , { sparse : 1 } , 0 satisfies StringSchema , 1 satisfies NumericSchema ) , { } ] ,
223- [ ( ) => map ( "" , "MyMap" , { } , 0 satisfies StringSchema , 1 satisfies NumericSchema ) , { } ] ,
224- ]
225- ) ,
226+ [ ( ) => [ 1 , "" , "MyList" , { sparse : 1 } , 1 satisfies NumericSchema ] , { } ] ,
227+ [ ( ) => [ 1 , "" , "MyList" , { } , 1 satisfies NumericSchema ] , { } ] ,
228+ [ ( ) => [ 2 , "" , "MyMap" , { sparse : 1 } , 0 satisfies StringSchema , 1 satisfies NumericSchema ] , { } ] ,
229+ [ ( ) => [ 2 , "" , "MyMap" , { } , 0 satisfies StringSchema , 1 satisfies NumericSchema ] , { } ] ,
230+ ] ,
231+ ] satisfies StaticStructureSchema ,
226232 mockOutput : {
227233 mySparseList : [ null , 1 , null , 2 , null ] ,
228234 myRegularList : [ null , 1 , null , 2 , null ] ,
@@ -290,12 +296,21 @@ describe(SmithyRpcV2CborProtocol.name, () => {
290296 describe ( "error handling" , ( ) => {
291297 const protocol = new SmithyRpcV2CborProtocol ( { defaultNamespace : "ns" } ) ;
292298
293- const operation = op (
299+ const staticOperation = [
300+ 9 ,
294301 "ns" ,
295302 "OperationWithModeledException" ,
296303 { } ,
297- struct ( "ns" , "Input" , 0 , [ ] , [ ] ) ,
298- struct ( "ns" , "Output" , 0 , [ ] , [ ] )
304+ [ 3 , "ns" , "Input" , 0 , [ ] , [ ] ] ,
305+ [ 3 , "ns" , "Output" , 0 , [ ] , [ ] ] ,
306+ ] satisfies StaticOperationSchema ;
307+
308+ const operation = op (
309+ staticOperation [ 1 ] ,
310+ staticOperation [ 2 ] ,
311+ staticOperation [ 3 ] ,
312+ staticOperation [ 4 ] ,
313+ staticOperation [ 5 ]
299314 ) ;
300315
301316 const errorResponse = new HttpResponse ( {
0 commit comments