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 4545 "import" : " ./dist-es/submodules/protocols/index.js" ,
4646 "require" : " ./dist-cjs/submodules/protocols/index.js" ,
4747 "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"
4855 }
4956 },
5057 "author" : {
7885 " ./cbor.js" ,
7986 " ./protocols.d.ts" ,
8087 " ./protocols.js" ,
88+ " ./serde.d.ts" ,
89+ " ./serde.js" ,
8190 " dist-*/**"
8291 ],
8392 "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 55 "rootDir" : " src" ,
66 "paths" : {
77 "@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" ]
910 }
1011 },
1112 "extends" : " ../../tsconfig.cjs.json" ,
Original file line number Diff line number Diff line change 66 "rootDir" : " src" ,
77 "paths" : {
88 "@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" ]
1011 }
1112 },
1213 "extends" : " ../../tsconfig.es.json" ,
Original file line number Diff line number Diff line change 55 "rootDir" : " src" ,
66 "paths" : {
77 "@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" ]
910 }
1011 },
1112 "extends" : " ../../tsconfig.types.json" ,
You can’t perform that action at this time.
0 commit comments