File tree Expand file tree Collapse file tree 10 files changed +82
-3
lines changed Expand file tree Collapse file tree 10 files changed +82
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @smithy/core " : minor
3
+ ---
4
+
5
+ add numeric value container for serde
Original file line number Diff line number Diff line change 45
45
"import" : " ./dist-es/submodules/protocols/index.js" ,
46
46
"require" : " ./dist-cjs/submodules/protocols/index.js" ,
47
47
"types" : " ./dist-types/submodules/protocols/index.d.ts"
48
+ },
49
+ "./serde" : {
50
+ "module" : " ./dist-es/submodules/serde/index.js" ,
51
+ "node" : " ./dist-cjs/submodules/serde/index.js" ,
52
+ "import" : " ./dist-es/submodules/serde/index.js" ,
53
+ "require" : " ./dist-cjs/submodules/serde/index.js" ,
54
+ "types" : " ./dist-types/submodules/serde/index.d.ts"
48
55
}
49
56
},
50
57
"author" : {
78
85
" ./cbor.js" ,
79
86
" ./protocols.d.ts" ,
80
87
" ./protocols.js" ,
88
+ " ./serde.d.ts" ,
89
+ " ./serde.js" ,
81
90
" dist-*/**"
82
91
],
83
92
"homepage" : " https://github.com/awslabs/smithy-typescript/tree/main/packages/core" ,
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Do not edit:
3
+ * This is a compatibility redirect for contexts that do not understand package.json exports field.
4
+ */
5
+ declare module "@smithy/core/serde" {
6
+ export * from "@smithy/core/dist-types/submodules/serde/index.d" ;
7
+ }
Original file line number Diff line number Diff line change
1
+
2
+ /**
3
+ * Do not edit:
4
+ * This is a compatibility redirect for contexts that do not understand package.json exports field.
5
+ */
6
+ module . exports = require ( "./dist-cjs/submodules/serde/index.js" ) ;
Original file line number Diff line number Diff line change
1
+ export * from "./value/NumericValue" ;
Original file line number Diff line number Diff line change
1
+ import { describe , expect , test as it } from "vitest" ;
2
+
3
+ import { NumericValue , nv } from "./NumericValue" ;
4
+
5
+ describe ( NumericValue . name , ( ) => {
6
+ it ( "holds a string representation of a numeric value" , ( ) => {
7
+ const num = nv ( "1.0" ) ;
8
+ expect ( num ) . toBeInstanceOf ( NumericValue ) ;
9
+ expect ( num . string ) . toEqual ( "1.0" ) ;
10
+ expect ( num . type ) . toEqual ( "bigDecimal" ) ;
11
+ } ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Types which may be represented by {@link NumericValue}.
3
+ *
4
+ * There is currently only one option, because BigInteger and Long should
5
+ * use JS BigInt directly, and all other numeric types can be contained in JS Number.
6
+ *
7
+ * @public
8
+ */
9
+ export type NumericType = "bigDecimal" ;
10
+
11
+ /**
12
+ * Serialization container for Smithy simple types that do not have a
13
+ * direct JavaScript runtime representation.
14
+ *
15
+ * This container does not perform numeric mathematical operations.
16
+ * It is a container for discerning a value's true type.
17
+ *
18
+ * It allows storage of numeric types not representable in JS without
19
+ * making a decision on what numeric library to use.
20
+ *
21
+ * @public
22
+ */
23
+ export class NumericValue {
24
+ public constructor (
25
+ public readonly string : string ,
26
+ public readonly type : NumericType
27
+ ) { }
28
+ }
29
+
30
+ /**
31
+ * Serde shortcut.
32
+ * @internal
33
+ */
34
+ export function nv ( string : string ) : NumericValue {
35
+ return new NumericValue ( string , "bigDecimal" ) ;
36
+ }
Original file line number Diff line number Diff line change 5
5
"rootDir" : " src" ,
6
6
"paths" : {
7
7
"@smithy/core/cbor" : [" ./src/submodules/cbor/index.ts" ],
8
- "@smithy/core/protocols" : [" ./src/submodules/protocols/index.ts" ]
8
+ "@smithy/core/protocols" : [" ./src/submodules/protocols/index.ts" ],
9
+ "@smithy/core/serde" : [" ./src/submodules/serde/index.ts" ]
9
10
}
10
11
},
11
12
"extends" : " ../../tsconfig.cjs.json" ,
Original file line number Diff line number Diff line change 6
6
"rootDir" : " src" ,
7
7
"paths" : {
8
8
"@smithy/core/cbor" : [" ./src/submodules/cbor/index.ts" ],
9
- "@smithy/core/protocols" : [" ./src/submodules/protocols/index.ts" ]
9
+ "@smithy/core/protocols" : [" ./src/submodules/protocols/index.ts" ],
10
+ "@smithy/core/serde" : [" ./src/submodules/serde/index.ts" ]
10
11
}
11
12
},
12
13
"extends" : " ../../tsconfig.es.json" ,
Original file line number Diff line number Diff line change 5
5
"rootDir" : " src" ,
6
6
"paths" : {
7
7
"@smithy/core/cbor" : [" ./src/submodules/cbor/index.ts" ],
8
- "@smithy/core/protocols" : [" ./src/submodules/protocols/index.ts" ]
8
+ "@smithy/core/protocols" : [" ./src/submodules/protocols/index.ts" ],
9
+ "@smithy/core/serde" : [" ./src/submodules/serde/index.ts" ]
9
10
}
10
11
},
11
12
"extends" : " ../../tsconfig.types.json" ,
You can’t perform that action at this time.
0 commit comments