@smithy/core 3.5.3 → 3.7.0
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.
- package/dist-cjs/submodules/cbor/index.js +55 -8
- package/dist-cjs/submodules/protocols/index.js +20 -20
- package/dist-cjs/submodules/schema/index.js +80 -6
- package/dist-cjs/submodules/serde/index.js +34 -2
- package/dist-es/submodules/cbor/byte-printer.js +3 -0
- package/dist-es/submodules/cbor/cbor-decode.js +24 -4
- package/dist-es/submodules/cbor/cbor-encode.js +33 -3
- package/dist-es/submodules/protocols/HttpBindingProtocol.js +20 -20
- package/dist-es/submodules/schema/schemas/ErrorSchema.js +10 -0
- package/dist-es/submodules/schema/schemas/ListSchema.js +10 -0
- package/dist-es/submodules/schema/schemas/MapSchema.js +10 -0
- package/dist-es/submodules/schema/schemas/NormalizedSchema.js +10 -0
- package/dist-es/submodules/schema/schemas/SimpleSchema.js +10 -0
- package/dist-es/submodules/schema/schemas/StructureSchema.js +10 -0
- package/dist-es/submodules/serde/value/NumericValue.js +32 -2
- package/dist-types/submodules/cbor/byte-printer.d.ts +6 -0
- package/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
- package/dist-types/submodules/schema/schemas/ListSchema.d.ts +3 -0
- package/dist-types/submodules/schema/schemas/MapSchema.d.ts +3 -0
- package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
- package/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
- package/dist-types/submodules/schema/schemas/StructureSchema.d.ts +3 -0
- package/dist-types/submodules/serde/value/NumericValue.d.ts +3 -1
- package/dist-types/ts3.4/submodules/cbor/byte-printer.d.ts +6 -0
- package/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
- package/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +3 -0
- package/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +3 -0
- package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
- package/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
- package/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +3 -0
- package/dist-types/ts3.4/submodules/serde/value/NumericValue.d.ts +3 -1
- package/package.json +2 -2
|
@@ -36,6 +36,7 @@ __export(cbor_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(cbor_exports);
|
|
37
37
|
|
|
38
38
|
// src/submodules/cbor/cbor-decode.ts
|
|
39
|
+
var import_serde = require("@smithy/core/serde");
|
|
39
40
|
var import_util_utf8 = require("@smithy/util-utf8");
|
|
40
41
|
|
|
41
42
|
// src/submodules/cbor/cbor-types.ts
|
|
@@ -131,10 +132,27 @@ function decode(at, to) {
|
|
|
131
132
|
_offset = offset;
|
|
132
133
|
return castBigInt(negativeInt);
|
|
133
134
|
} else {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
if (minor === 2 || minor === 3) {
|
|
136
|
+
const length = decodeCount(at + offset, to);
|
|
137
|
+
let b = BigInt(0);
|
|
138
|
+
const start = at + offset + _offset;
|
|
139
|
+
for (let i = start; i < start + length; ++i) {
|
|
140
|
+
b = b << BigInt(8) | BigInt(payload[i]);
|
|
141
|
+
}
|
|
142
|
+
_offset = offset + length;
|
|
143
|
+
return minor === 3 ? -b - BigInt(1) : b;
|
|
144
|
+
} else if (minor === 4) {
|
|
145
|
+
const decimalFraction = decode(at + offset, to);
|
|
146
|
+
const [exponent, mantissa] = decimalFraction;
|
|
147
|
+
const s = mantissa.toString();
|
|
148
|
+
const numericString = exponent === 0 ? s : s.slice(0, s.length + exponent) + "." + s.slice(exponent);
|
|
149
|
+
return new import_serde.NumericValue(numericString, "bigDecimal");
|
|
150
|
+
} else {
|
|
151
|
+
const value = decode(at + offset, to);
|
|
152
|
+
const valueOffset = _offset;
|
|
153
|
+
_offset = offset + valueOffset;
|
|
154
|
+
return tag({ tag: castBigInt(unsignedInt), value });
|
|
155
|
+
}
|
|
138
156
|
}
|
|
139
157
|
case majorUtf8String:
|
|
140
158
|
case majorMap:
|
|
@@ -440,6 +458,7 @@ function castBigInt(bigInt) {
|
|
|
440
458
|
}
|
|
441
459
|
|
|
442
460
|
// src/submodules/cbor/cbor-encode.ts
|
|
461
|
+
var import_serde2 = require("@smithy/core/serde");
|
|
443
462
|
var import_util_utf82 = require("@smithy/util-utf8");
|
|
444
463
|
var USE_BUFFER2 = typeof Buffer !== "undefined";
|
|
445
464
|
var initialSize = 2048;
|
|
@@ -557,10 +576,28 @@ function encode(_input) {
|
|
|
557
576
|
data[cursor++] = major << 5 | extendedFloat32;
|
|
558
577
|
dataView2.setUint32(cursor, n);
|
|
559
578
|
cursor += 4;
|
|
560
|
-
} else {
|
|
579
|
+
} else if (value < BigInt("18446744073709551616")) {
|
|
561
580
|
data[cursor++] = major << 5 | extendedFloat64;
|
|
562
581
|
dataView2.setBigUint64(cursor, value);
|
|
563
582
|
cursor += 8;
|
|
583
|
+
} else {
|
|
584
|
+
const binaryBigInt = value.toString(2);
|
|
585
|
+
const bigIntBytes = new Uint8Array(Math.ceil(binaryBigInt.length / 8));
|
|
586
|
+
let b = value;
|
|
587
|
+
let i = 0;
|
|
588
|
+
while (bigIntBytes.byteLength - ++i >= 0) {
|
|
589
|
+
bigIntBytes[bigIntBytes.byteLength - i] = Number(b & BigInt(255));
|
|
590
|
+
b >>= BigInt(8);
|
|
591
|
+
}
|
|
592
|
+
ensureSpace(bigIntBytes.byteLength * 2);
|
|
593
|
+
data[cursor++] = nonNegative ? 194 : 195;
|
|
594
|
+
if (USE_BUFFER2) {
|
|
595
|
+
encodeHeader(majorUnstructuredByteString, Buffer.byteLength(bigIntBytes));
|
|
596
|
+
} else {
|
|
597
|
+
encodeHeader(majorUnstructuredByteString, bigIntBytes.byteLength);
|
|
598
|
+
}
|
|
599
|
+
data.set(bigIntBytes, cursor);
|
|
600
|
+
cursor += bigIntBytes.byteLength;
|
|
564
601
|
}
|
|
565
602
|
continue;
|
|
566
603
|
} else if (input === null) {
|
|
@@ -584,6 +621,16 @@ function encode(_input) {
|
|
|
584
621
|
cursor += input.byteLength;
|
|
585
622
|
continue;
|
|
586
623
|
} else if (typeof input === "object") {
|
|
624
|
+
if (input instanceof import_serde2.NumericValue) {
|
|
625
|
+
const decimalIndex = input.string.indexOf(".");
|
|
626
|
+
const exponent = decimalIndex === -1 ? 0 : decimalIndex - input.string.length + 1;
|
|
627
|
+
const mantissa = BigInt(input.string.replace(".", ""));
|
|
628
|
+
data[cursor++] = 196;
|
|
629
|
+
encodeStack.push(mantissa);
|
|
630
|
+
encodeStack.push(exponent);
|
|
631
|
+
encodeHeader(majorList, 2);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
587
634
|
if (input[tagSymbol]) {
|
|
588
635
|
if ("tag" in input && "value" in input) {
|
|
589
636
|
encodeStack.push(input.value);
|
|
@@ -732,7 +779,7 @@ var import_util_middleware = require("@smithy/util-middleware");
|
|
|
732
779
|
|
|
733
780
|
// src/submodules/cbor/CborCodec.ts
|
|
734
781
|
var import_schema = require("@smithy/core/schema");
|
|
735
|
-
var
|
|
782
|
+
var import_serde3 = require("@smithy/core/serde");
|
|
736
783
|
var CborCodec = class {
|
|
737
784
|
createSerializer() {
|
|
738
785
|
const serializer = new CborShapeSerializer();
|
|
@@ -753,7 +800,7 @@ var CborShapeSerializer = class {
|
|
|
753
800
|
this.serdeContext = serdeContext;
|
|
754
801
|
}
|
|
755
802
|
write(schema, value) {
|
|
756
|
-
this.value = (0,
|
|
803
|
+
this.value = (0, import_serde3.copyDocumentWithTransform)(value, schema, (_, schemaRef) => {
|
|
757
804
|
if (_ instanceof Date) {
|
|
758
805
|
return dateToTag(_);
|
|
759
806
|
}
|
|
@@ -802,7 +849,7 @@ var CborShapeDeserializer = class {
|
|
|
802
849
|
const schema = ns.getSchema();
|
|
803
850
|
if (typeof schema === "number") {
|
|
804
851
|
if (ns.isTimestampSchema()) {
|
|
805
|
-
return (0,
|
|
852
|
+
return (0, import_serde3.parseEpochTimestamp)(value);
|
|
806
853
|
}
|
|
807
854
|
if (ns.isBlobSchema()) {
|
|
808
855
|
return value;
|
|
@@ -225,7 +225,10 @@ var HttpProtocol = class {
|
|
|
225
225
|
|
|
226
226
|
// src/submodules/protocols/HttpBindingProtocol.ts
|
|
227
227
|
var HttpBindingProtocol = class extends HttpProtocol {
|
|
228
|
-
async serializeRequest(operationSchema,
|
|
228
|
+
async serializeRequest(operationSchema, _input, context) {
|
|
229
|
+
const input = {
|
|
230
|
+
..._input ?? {}
|
|
231
|
+
};
|
|
229
232
|
const serializer = this.serializer;
|
|
230
233
|
const query = {};
|
|
231
234
|
const headers = {};
|
|
@@ -260,16 +263,12 @@ var HttpBindingProtocol = class extends HttpProtocol {
|
|
|
260
263
|
Object.assign(query, Object.fromEntries(traitSearchParams));
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const memberNs = ns.getMemberSchema(memberName);
|
|
268
|
-
if (memberNs === void 0) {
|
|
266
|
+
for (const [memberName, memberNs] of ns.structIterator()) {
|
|
267
|
+
const memberTraits = memberNs.getMergedTraits() ?? {};
|
|
268
|
+
const inputMemberValue = input[memberName];
|
|
269
|
+
if (inputMemberValue == null) {
|
|
269
270
|
continue;
|
|
270
271
|
}
|
|
271
|
-
const memberTraits = memberNs.getMergedTraits();
|
|
272
|
-
const inputMember = _input[memberName];
|
|
273
272
|
if (memberTraits.httpPayload) {
|
|
274
273
|
const isStreaming = memberNs.isStreaming();
|
|
275
274
|
if (isStreaming) {
|
|
@@ -277,14 +276,15 @@ var HttpBindingProtocol = class extends HttpProtocol {
|
|
|
277
276
|
if (isEventStream) {
|
|
278
277
|
throw new Error("serialization of event streams is not yet implemented");
|
|
279
278
|
} else {
|
|
280
|
-
payload =
|
|
279
|
+
payload = inputMemberValue;
|
|
281
280
|
}
|
|
282
281
|
} else {
|
|
283
|
-
serializer.write(memberNs,
|
|
282
|
+
serializer.write(memberNs, inputMemberValue);
|
|
284
283
|
payload = serializer.flush();
|
|
285
284
|
}
|
|
285
|
+
delete input[memberName];
|
|
286
286
|
} else if (memberTraits.httpLabel) {
|
|
287
|
-
serializer.write(memberNs,
|
|
287
|
+
serializer.write(memberNs, inputMemberValue);
|
|
288
288
|
const replacement = serializer.flush();
|
|
289
289
|
if (request.path.includes(`{${memberName}+}`)) {
|
|
290
290
|
request.path = request.path.replace(
|
|
@@ -294,27 +294,27 @@ var HttpBindingProtocol = class extends HttpProtocol {
|
|
|
294
294
|
} else if (request.path.includes(`{${memberName}}`)) {
|
|
295
295
|
request.path = request.path.replace(`{${memberName}}`, extendedEncodeURIComponent(replacement));
|
|
296
296
|
}
|
|
297
|
-
delete
|
|
297
|
+
delete input[memberName];
|
|
298
298
|
} else if (memberTraits.httpHeader) {
|
|
299
|
-
serializer.write(memberNs,
|
|
299
|
+
serializer.write(memberNs, inputMemberValue);
|
|
300
300
|
headers[memberTraits.httpHeader.toLowerCase()] = String(serializer.flush());
|
|
301
|
-
delete
|
|
301
|
+
delete input[memberName];
|
|
302
302
|
} else if (typeof memberTraits.httpPrefixHeaders === "string") {
|
|
303
|
-
for (const [key, val] of Object.entries(
|
|
303
|
+
for (const [key, val] of Object.entries(inputMemberValue)) {
|
|
304
304
|
const amalgam = memberTraits.httpPrefixHeaders + key;
|
|
305
305
|
serializer.write([memberNs.getValueSchema(), { httpHeader: amalgam }], val);
|
|
306
306
|
headers[amalgam.toLowerCase()] = serializer.flush();
|
|
307
307
|
}
|
|
308
|
-
delete
|
|
308
|
+
delete input[memberName];
|
|
309
309
|
} else if (memberTraits.httpQuery || memberTraits.httpQueryParams) {
|
|
310
|
-
this.serializeQuery(memberNs,
|
|
311
|
-
delete
|
|
310
|
+
this.serializeQuery(memberNs, inputMemberValue, query);
|
|
311
|
+
delete input[memberName];
|
|
312
312
|
} else {
|
|
313
313
|
hasNonHttpBindingMember = true;
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
if (hasNonHttpBindingMember && input) {
|
|
317
|
-
serializer.write(schema,
|
|
317
|
+
serializer.write(schema, input);
|
|
318
318
|
payload = serializer.flush();
|
|
319
319
|
}
|
|
320
320
|
request.headers = headers;
|
|
@@ -247,12 +247,24 @@ var Schema = class {
|
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
// src/submodules/schema/schemas/ListSchema.ts
|
|
250
|
-
var ListSchema = class extends Schema {
|
|
250
|
+
var ListSchema = class _ListSchema extends Schema {
|
|
251
251
|
constructor(name, traits, valueSchema) {
|
|
252
252
|
super(name, traits);
|
|
253
253
|
this.name = name;
|
|
254
254
|
this.traits = traits;
|
|
255
255
|
this.valueSchema = valueSchema;
|
|
256
|
+
this.symbol = _ListSchema.symbol;
|
|
257
|
+
}
|
|
258
|
+
static {
|
|
259
|
+
this.symbol = Symbol.for("@smithy/core/schema::ListSchema");
|
|
260
|
+
}
|
|
261
|
+
static [Symbol.hasInstance](lhs) {
|
|
262
|
+
const isPrototype = _ListSchema.prototype.isPrototypeOf(lhs);
|
|
263
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
264
|
+
const list2 = lhs;
|
|
265
|
+
return list2.symbol === _ListSchema.symbol;
|
|
266
|
+
}
|
|
267
|
+
return isPrototype;
|
|
256
268
|
}
|
|
257
269
|
};
|
|
258
270
|
function list(namespace, name, traits = {}, valueSchema) {
|
|
@@ -266,13 +278,25 @@ function list(namespace, name, traits = {}, valueSchema) {
|
|
|
266
278
|
}
|
|
267
279
|
|
|
268
280
|
// src/submodules/schema/schemas/MapSchema.ts
|
|
269
|
-
var MapSchema = class extends Schema {
|
|
281
|
+
var MapSchema = class _MapSchema extends Schema {
|
|
270
282
|
constructor(name, traits, keySchema, valueSchema) {
|
|
271
283
|
super(name, traits);
|
|
272
284
|
this.name = name;
|
|
273
285
|
this.traits = traits;
|
|
274
286
|
this.keySchema = keySchema;
|
|
275
287
|
this.valueSchema = valueSchema;
|
|
288
|
+
this.symbol = _MapSchema.symbol;
|
|
289
|
+
}
|
|
290
|
+
static {
|
|
291
|
+
this.symbol = Symbol.for("@smithy/core/schema::MapSchema");
|
|
292
|
+
}
|
|
293
|
+
static [Symbol.hasInstance](lhs) {
|
|
294
|
+
const isPrototype = _MapSchema.prototype.isPrototypeOf(lhs);
|
|
295
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
296
|
+
const map2 = lhs;
|
|
297
|
+
return map2.symbol === _MapSchema.symbol;
|
|
298
|
+
}
|
|
299
|
+
return isPrototype;
|
|
276
300
|
}
|
|
277
301
|
};
|
|
278
302
|
function map(namespace, name, traits = {}, keySchema, valueSchema) {
|
|
@@ -303,18 +327,30 @@ function op(namespace, name, traits = {}, input, output) {
|
|
|
303
327
|
}
|
|
304
328
|
|
|
305
329
|
// src/submodules/schema/schemas/StructureSchema.ts
|
|
306
|
-
var StructureSchema = class extends Schema {
|
|
330
|
+
var StructureSchema = class _StructureSchema extends Schema {
|
|
307
331
|
constructor(name, traits, memberNames, memberList) {
|
|
308
332
|
super(name, traits);
|
|
309
333
|
this.name = name;
|
|
310
334
|
this.traits = traits;
|
|
311
335
|
this.memberNames = memberNames;
|
|
312
336
|
this.memberList = memberList;
|
|
337
|
+
this.symbol = _StructureSchema.symbol;
|
|
313
338
|
this.members = {};
|
|
314
339
|
for (let i = 0; i < memberNames.length; ++i) {
|
|
315
340
|
this.members[memberNames[i]] = Array.isArray(memberList[i]) ? memberList[i] : [memberList[i], 0];
|
|
316
341
|
}
|
|
317
342
|
}
|
|
343
|
+
static {
|
|
344
|
+
this.symbol = Symbol.for("@smithy/core/schema::StructureSchema");
|
|
345
|
+
}
|
|
346
|
+
static [Symbol.hasInstance](lhs) {
|
|
347
|
+
const isPrototype = _StructureSchema.prototype.isPrototypeOf(lhs);
|
|
348
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
349
|
+
const struct2 = lhs;
|
|
350
|
+
return struct2.symbol === _StructureSchema.symbol;
|
|
351
|
+
}
|
|
352
|
+
return isPrototype;
|
|
353
|
+
}
|
|
318
354
|
};
|
|
319
355
|
function struct(namespace, name, traits, memberNames, memberList) {
|
|
320
356
|
const schema = new StructureSchema(namespace + "#" + name, traits, memberNames, memberList);
|
|
@@ -323,7 +359,7 @@ function struct(namespace, name, traits, memberNames, memberList) {
|
|
|
323
359
|
}
|
|
324
360
|
|
|
325
361
|
// src/submodules/schema/schemas/ErrorSchema.ts
|
|
326
|
-
var ErrorSchema = class extends StructureSchema {
|
|
362
|
+
var ErrorSchema = class _ErrorSchema extends StructureSchema {
|
|
327
363
|
constructor(name, traits, memberNames, memberList, ctor) {
|
|
328
364
|
super(name, traits, memberNames, memberList);
|
|
329
365
|
this.name = name;
|
|
@@ -331,6 +367,18 @@ var ErrorSchema = class extends StructureSchema {
|
|
|
331
367
|
this.memberNames = memberNames;
|
|
332
368
|
this.memberList = memberList;
|
|
333
369
|
this.ctor = ctor;
|
|
370
|
+
this.symbol = _ErrorSchema.symbol;
|
|
371
|
+
}
|
|
372
|
+
static {
|
|
373
|
+
this.symbol = Symbol.for("@smithy/core/schema::ErrorSchema");
|
|
374
|
+
}
|
|
375
|
+
static [Symbol.hasInstance](lhs) {
|
|
376
|
+
const isPrototype = _ErrorSchema.prototype.isPrototypeOf(lhs);
|
|
377
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
378
|
+
const err = lhs;
|
|
379
|
+
return err.symbol === _ErrorSchema.symbol;
|
|
380
|
+
}
|
|
381
|
+
return isPrototype;
|
|
334
382
|
}
|
|
335
383
|
};
|
|
336
384
|
function error(namespace, name, traits = {}, memberNames, memberList, ctor) {
|
|
@@ -372,12 +420,24 @@ var SCHEMA = {
|
|
|
372
420
|
};
|
|
373
421
|
|
|
374
422
|
// src/submodules/schema/schemas/SimpleSchema.ts
|
|
375
|
-
var SimpleSchema = class extends Schema {
|
|
423
|
+
var SimpleSchema = class _SimpleSchema extends Schema {
|
|
376
424
|
constructor(name, schemaRef, traits) {
|
|
377
425
|
super(name, traits);
|
|
378
426
|
this.name = name;
|
|
379
427
|
this.schemaRef = schemaRef;
|
|
380
428
|
this.traits = traits;
|
|
429
|
+
this.symbol = _SimpleSchema.symbol;
|
|
430
|
+
}
|
|
431
|
+
static {
|
|
432
|
+
this.symbol = Symbol.for("@smithy/core/schema::SimpleSchema");
|
|
433
|
+
}
|
|
434
|
+
static [Symbol.hasInstance](lhs) {
|
|
435
|
+
const isPrototype = _SimpleSchema.prototype.isPrototypeOf(lhs);
|
|
436
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
437
|
+
const sim2 = lhs;
|
|
438
|
+
return sim2.symbol === _SimpleSchema.symbol;
|
|
439
|
+
}
|
|
440
|
+
return isPrototype;
|
|
381
441
|
}
|
|
382
442
|
};
|
|
383
443
|
function sim(namespace, name, schemaRef, traits) {
|
|
@@ -395,6 +455,7 @@ var NormalizedSchema = class _NormalizedSchema {
|
|
|
395
455
|
constructor(ref, memberName) {
|
|
396
456
|
this.ref = ref;
|
|
397
457
|
this.memberName = memberName;
|
|
458
|
+
this.symbol = _NormalizedSchema.symbol;
|
|
398
459
|
const traitStack = [];
|
|
399
460
|
let _ref = ref;
|
|
400
461
|
let schema = ref;
|
|
@@ -434,10 +495,23 @@ var NormalizedSchema = class _NormalizedSchema {
|
|
|
434
495
|
this.name = (typeof this.schema === "object" ? this.schema?.name : void 0) ?? this.memberName ?? this.getSchemaName();
|
|
435
496
|
if (this._isMemberSchema && !memberName) {
|
|
436
497
|
throw new Error(
|
|
437
|
-
`@smithy/core/schema - NormalizedSchema member schema ${this.getName(
|
|
498
|
+
`@smithy/core/schema - NormalizedSchema member schema ${this.getName(
|
|
499
|
+
true
|
|
500
|
+
)} must initialize with memberName argument.`
|
|
438
501
|
);
|
|
439
502
|
}
|
|
440
503
|
}
|
|
504
|
+
static {
|
|
505
|
+
this.symbol = Symbol.for("@smithy/core/schema::NormalizedSchema");
|
|
506
|
+
}
|
|
507
|
+
static [Symbol.hasInstance](lhs) {
|
|
508
|
+
const isPrototype = _NormalizedSchema.prototype.isPrototypeOf(lhs);
|
|
509
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
510
|
+
const ns = lhs;
|
|
511
|
+
return ns.symbol === _NormalizedSchema.symbol;
|
|
512
|
+
}
|
|
513
|
+
return isPrototype;
|
|
514
|
+
}
|
|
441
515
|
/**
|
|
442
516
|
* Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
|
|
443
517
|
*/
|
|
@@ -671,10 +671,42 @@ var NumericValue = class {
|
|
|
671
671
|
constructor(string, type) {
|
|
672
672
|
this.string = string;
|
|
673
673
|
this.type = type;
|
|
674
|
+
let dot = 0;
|
|
675
|
+
for (let i = 0; i < string.length; ++i) {
|
|
676
|
+
const char = string.charCodeAt(i);
|
|
677
|
+
if (i === 0 && char === 45) {
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
if (char === 46) {
|
|
681
|
+
if (dot) {
|
|
682
|
+
throw new Error("@smithy/core/serde - NumericValue must contain at most one decimal point.");
|
|
683
|
+
}
|
|
684
|
+
dot = 1;
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (char < 48 || char > 57) {
|
|
688
|
+
throw new Error(
|
|
689
|
+
`@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".`
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
toString() {
|
|
695
|
+
return this.string;
|
|
696
|
+
}
|
|
697
|
+
[Symbol.hasInstance](object) {
|
|
698
|
+
if (!object || typeof object !== "object") {
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
const _nv = object;
|
|
702
|
+
if (typeof _nv.string === "string" && typeof _nv.type === "string" && _nv.constructor?.name === "NumericValue") {
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
return false;
|
|
674
706
|
}
|
|
675
707
|
};
|
|
676
|
-
function nv(
|
|
677
|
-
return new NumericValue(
|
|
708
|
+
function nv(input) {
|
|
709
|
+
return new NumericValue(String(input), "bigDecimal");
|
|
678
710
|
}
|
|
679
711
|
// Annotate the CommonJS export names for ESM import in node:
|
|
680
712
|
0 && (module.exports = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumericValue } from "@smithy/core/serde";
|
|
1
2
|
import { toUtf8 } from "@smithy/util-utf8";
|
|
2
3
|
import { alloc, extendedFloat16, extendedFloat32, extendedFloat64, extendedOneByte, majorList, majorMap, majorNegativeInt64, majorTag, majorUint64, majorUnstructuredByteString, majorUtf8String, minorIndefinite, specialFalse, specialNull, specialTrue, specialUndefined, tag, } from "./cbor-types";
|
|
3
4
|
const USE_TEXT_DECODER = typeof TextDecoder !== "undefined";
|
|
@@ -72,10 +73,29 @@ export function decode(at, to) {
|
|
|
72
73
|
return castBigInt(negativeInt);
|
|
73
74
|
}
|
|
74
75
|
else {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
if (minor === 2 || minor === 3) {
|
|
77
|
+
const length = decodeCount(at + offset, to);
|
|
78
|
+
let b = BigInt(0);
|
|
79
|
+
const start = at + offset + _offset;
|
|
80
|
+
for (let i = start; i < start + length; ++i) {
|
|
81
|
+
b = (b << BigInt(8)) | BigInt(payload[i]);
|
|
82
|
+
}
|
|
83
|
+
_offset = offset + length;
|
|
84
|
+
return minor === 3 ? -b - BigInt(1) : b;
|
|
85
|
+
}
|
|
86
|
+
else if (minor === 4) {
|
|
87
|
+
const decimalFraction = decode(at + offset, to);
|
|
88
|
+
const [exponent, mantissa] = decimalFraction;
|
|
89
|
+
const s = mantissa.toString();
|
|
90
|
+
const numericString = exponent === 0 ? s : s.slice(0, s.length + exponent) + "." + s.slice(exponent);
|
|
91
|
+
return new NumericValue(numericString, "bigDecimal");
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const value = decode(at + offset, to);
|
|
95
|
+
const valueOffset = _offset;
|
|
96
|
+
_offset = offset + valueOffset;
|
|
97
|
+
return tag({ tag: castBigInt(unsignedInt), value });
|
|
98
|
+
}
|
|
79
99
|
}
|
|
80
100
|
case majorUtf8String:
|
|
81
101
|
case majorMap:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { NumericValue } from "@smithy/core/serde";
|
|
1
2
|
import { fromUtf8 } from "@smithy/util-utf8";
|
|
2
|
-
import { extendedFloat16, extendedFloat32, extendedFloat64, majorList, majorMap, majorNegativeInt64, majorSpecial, majorTag, majorUint64, majorUnstructuredByteString, majorUtf8String, specialFalse, specialNull, specialTrue, tagSymbol, } from "./cbor-types";
|
|
3
|
-
import { alloc } from "./cbor-types";
|
|
3
|
+
import { alloc, extendedFloat16, extendedFloat32, extendedFloat64, majorList, majorMap, majorNegativeInt64, majorSpecial, majorTag, majorUint64, majorUnstructuredByteString, majorUtf8String, specialFalse, specialNull, specialTrue, tagSymbol, } from "./cbor-types";
|
|
4
4
|
const USE_BUFFER = typeof Buffer !== "undefined";
|
|
5
5
|
const initialSize = 2048;
|
|
6
6
|
let data = alloc(initialSize);
|
|
@@ -134,11 +134,31 @@ export function encode(_input) {
|
|
|
134
134
|
dataView.setUint32(cursor, n);
|
|
135
135
|
cursor += 4;
|
|
136
136
|
}
|
|
137
|
-
else {
|
|
137
|
+
else if (value < BigInt("18446744073709551616")) {
|
|
138
138
|
data[cursor++] = (major << 5) | extendedFloat64;
|
|
139
139
|
dataView.setBigUint64(cursor, value);
|
|
140
140
|
cursor += 8;
|
|
141
141
|
}
|
|
142
|
+
else {
|
|
143
|
+
const binaryBigInt = value.toString(2);
|
|
144
|
+
const bigIntBytes = new Uint8Array(Math.ceil(binaryBigInt.length / 8));
|
|
145
|
+
let b = value;
|
|
146
|
+
let i = 0;
|
|
147
|
+
while (bigIntBytes.byteLength - ++i >= 0) {
|
|
148
|
+
bigIntBytes[bigIntBytes.byteLength - i] = Number(b & BigInt(255));
|
|
149
|
+
b >>= BigInt(8);
|
|
150
|
+
}
|
|
151
|
+
ensureSpace(bigIntBytes.byteLength * 2);
|
|
152
|
+
data[cursor++] = nonNegative ? 194 : 195;
|
|
153
|
+
if (USE_BUFFER) {
|
|
154
|
+
encodeHeader(majorUnstructuredByteString, Buffer.byteLength(bigIntBytes));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
encodeHeader(majorUnstructuredByteString, bigIntBytes.byteLength);
|
|
158
|
+
}
|
|
159
|
+
data.set(bigIntBytes, cursor);
|
|
160
|
+
cursor += bigIntBytes.byteLength;
|
|
161
|
+
}
|
|
142
162
|
continue;
|
|
143
163
|
}
|
|
144
164
|
else if (input === null) {
|
|
@@ -167,6 +187,16 @@ export function encode(_input) {
|
|
|
167
187
|
continue;
|
|
168
188
|
}
|
|
169
189
|
else if (typeof input === "object") {
|
|
190
|
+
if (input instanceof NumericValue) {
|
|
191
|
+
const decimalIndex = input.string.indexOf(".");
|
|
192
|
+
const exponent = decimalIndex === -1 ? 0 : decimalIndex - input.string.length + 1;
|
|
193
|
+
const mantissa = BigInt(input.string.replace(".", ""));
|
|
194
|
+
data[cursor++] = 196;
|
|
195
|
+
encodeStack.push(mantissa);
|
|
196
|
+
encodeStack.push(exponent);
|
|
197
|
+
encodeHeader(majorList, 2);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
170
200
|
if (input[tagSymbol]) {
|
|
171
201
|
if ("tag" in input && "value" in input) {
|
|
172
202
|
encodeStack.push(input.value);
|
|
@@ -4,7 +4,10 @@ import { collectBody } from "./collect-stream-body";
|
|
|
4
4
|
import { extendedEncodeURIComponent } from "./extended-encode-uri-component";
|
|
5
5
|
import { HttpProtocol } from "./HttpProtocol";
|
|
6
6
|
export class HttpBindingProtocol extends HttpProtocol {
|
|
7
|
-
async serializeRequest(operationSchema,
|
|
7
|
+
async serializeRequest(operationSchema, _input, context) {
|
|
8
|
+
const input = {
|
|
9
|
+
...(_input ?? {}),
|
|
10
|
+
};
|
|
8
11
|
const serializer = this.serializer;
|
|
9
12
|
const query = {};
|
|
10
13
|
const headers = {};
|
|
@@ -40,16 +43,12 @@ export class HttpBindingProtocol extends HttpProtocol {
|
|
|
40
43
|
Object.assign(query, Object.fromEntries(traitSearchParams));
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const memberNs = ns.getMemberSchema(memberName);
|
|
48
|
-
if (memberNs === undefined) {
|
|
46
|
+
for (const [memberName, memberNs] of ns.structIterator()) {
|
|
47
|
+
const memberTraits = memberNs.getMergedTraits() ?? {};
|
|
48
|
+
const inputMemberValue = input[memberName];
|
|
49
|
+
if (inputMemberValue == null) {
|
|
49
50
|
continue;
|
|
50
51
|
}
|
|
51
|
-
const memberTraits = memberNs.getMergedTraits();
|
|
52
|
-
const inputMember = _input[memberName];
|
|
53
52
|
if (memberTraits.httpPayload) {
|
|
54
53
|
const isStreaming = memberNs.isStreaming();
|
|
55
54
|
if (isStreaming) {
|
|
@@ -58,16 +57,17 @@ export class HttpBindingProtocol extends HttpProtocol {
|
|
|
58
57
|
throw new Error("serialization of event streams is not yet implemented");
|
|
59
58
|
}
|
|
60
59
|
else {
|
|
61
|
-
payload =
|
|
60
|
+
payload = inputMemberValue;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
else {
|
|
65
|
-
serializer.write(memberNs,
|
|
64
|
+
serializer.write(memberNs, inputMemberValue);
|
|
66
65
|
payload = serializer.flush();
|
|
67
66
|
}
|
|
67
|
+
delete input[memberName];
|
|
68
68
|
}
|
|
69
69
|
else if (memberTraits.httpLabel) {
|
|
70
|
-
serializer.write(memberNs,
|
|
70
|
+
serializer.write(memberNs, inputMemberValue);
|
|
71
71
|
const replacement = serializer.flush();
|
|
72
72
|
if (request.path.includes(`{${memberName}+}`)) {
|
|
73
73
|
request.path = request.path.replace(`{${memberName}+}`, replacement.split("/").map(extendedEncodeURIComponent).join("/"));
|
|
@@ -75,31 +75,31 @@ export class HttpBindingProtocol extends HttpProtocol {
|
|
|
75
75
|
else if (request.path.includes(`{${memberName}}`)) {
|
|
76
76
|
request.path = request.path.replace(`{${memberName}}`, extendedEncodeURIComponent(replacement));
|
|
77
77
|
}
|
|
78
|
-
delete
|
|
78
|
+
delete input[memberName];
|
|
79
79
|
}
|
|
80
80
|
else if (memberTraits.httpHeader) {
|
|
81
|
-
serializer.write(memberNs,
|
|
81
|
+
serializer.write(memberNs, inputMemberValue);
|
|
82
82
|
headers[memberTraits.httpHeader.toLowerCase()] = String(serializer.flush());
|
|
83
|
-
delete
|
|
83
|
+
delete input[memberName];
|
|
84
84
|
}
|
|
85
85
|
else if (typeof memberTraits.httpPrefixHeaders === "string") {
|
|
86
|
-
for (const [key, val] of Object.entries(
|
|
86
|
+
for (const [key, val] of Object.entries(inputMemberValue)) {
|
|
87
87
|
const amalgam = memberTraits.httpPrefixHeaders + key;
|
|
88
88
|
serializer.write([memberNs.getValueSchema(), { httpHeader: amalgam }], val);
|
|
89
89
|
headers[amalgam.toLowerCase()] = serializer.flush();
|
|
90
90
|
}
|
|
91
|
-
delete
|
|
91
|
+
delete input[memberName];
|
|
92
92
|
}
|
|
93
93
|
else if (memberTraits.httpQuery || memberTraits.httpQueryParams) {
|
|
94
|
-
this.serializeQuery(memberNs,
|
|
95
|
-
delete
|
|
94
|
+
this.serializeQuery(memberNs, inputMemberValue, query);
|
|
95
|
+
delete input[memberName];
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
hasNonHttpBindingMember = true;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
if (hasNonHttpBindingMember && input) {
|
|
102
|
-
serializer.write(schema,
|
|
102
|
+
serializer.write(schema, input);
|
|
103
103
|
payload = serializer.flush();
|
|
104
104
|
}
|
|
105
105
|
request.headers = headers;
|
|
@@ -8,8 +8,18 @@ export class ErrorSchema extends StructureSchema {
|
|
|
8
8
|
this.memberNames = memberNames;
|
|
9
9
|
this.memberList = memberList;
|
|
10
10
|
this.ctor = ctor;
|
|
11
|
+
this.symbol = ErrorSchema.symbol;
|
|
12
|
+
}
|
|
13
|
+
static [Symbol.hasInstance](lhs) {
|
|
14
|
+
const isPrototype = ErrorSchema.prototype.isPrototypeOf(lhs);
|
|
15
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
16
|
+
const err = lhs;
|
|
17
|
+
return err.symbol === ErrorSchema.symbol;
|
|
18
|
+
}
|
|
19
|
+
return isPrototype;
|
|
11
20
|
}
|
|
12
21
|
}
|
|
22
|
+
ErrorSchema.symbol = Symbol.for("@smithy/core/schema::ErrorSchema");
|
|
13
23
|
export function error(namespace, name, traits = {}, memberNames, memberList, ctor) {
|
|
14
24
|
const schema = new ErrorSchema(namespace + "#" + name, traits, memberNames, memberList, ctor);
|
|
15
25
|
TypeRegistry.for(namespace).register(name, schema);
|
|
@@ -6,8 +6,18 @@ export class ListSchema extends Schema {
|
|
|
6
6
|
this.name = name;
|
|
7
7
|
this.traits = traits;
|
|
8
8
|
this.valueSchema = valueSchema;
|
|
9
|
+
this.symbol = ListSchema.symbol;
|
|
10
|
+
}
|
|
11
|
+
static [Symbol.hasInstance](lhs) {
|
|
12
|
+
const isPrototype = ListSchema.prototype.isPrototypeOf(lhs);
|
|
13
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
14
|
+
const list = lhs;
|
|
15
|
+
return list.symbol === ListSchema.symbol;
|
|
16
|
+
}
|
|
17
|
+
return isPrototype;
|
|
9
18
|
}
|
|
10
19
|
}
|
|
20
|
+
ListSchema.symbol = Symbol.for("@smithy/core/schema::ListSchema");
|
|
11
21
|
export function list(namespace, name, traits = {}, valueSchema) {
|
|
12
22
|
const schema = new ListSchema(namespace + "#" + name, traits, typeof valueSchema === "function" ? valueSchema() : valueSchema);
|
|
13
23
|
TypeRegistry.for(namespace).register(name, schema);
|
|
@@ -7,8 +7,18 @@ export class MapSchema extends Schema {
|
|
|
7
7
|
this.traits = traits;
|
|
8
8
|
this.keySchema = keySchema;
|
|
9
9
|
this.valueSchema = valueSchema;
|
|
10
|
+
this.symbol = MapSchema.symbol;
|
|
11
|
+
}
|
|
12
|
+
static [Symbol.hasInstance](lhs) {
|
|
13
|
+
const isPrototype = MapSchema.prototype.isPrototypeOf(lhs);
|
|
14
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
15
|
+
const map = lhs;
|
|
16
|
+
return map.symbol === MapSchema.symbol;
|
|
17
|
+
}
|
|
18
|
+
return isPrototype;
|
|
10
19
|
}
|
|
11
20
|
}
|
|
21
|
+
MapSchema.symbol = Symbol.for("@smithy/core/schema::MapSchema");
|
|
12
22
|
export function map(namespace, name, traits = {}, keySchema, valueSchema) {
|
|
13
23
|
const schema = new MapSchema(namespace + "#" + name, traits, keySchema, typeof valueSchema === "function" ? valueSchema() : valueSchema);
|
|
14
24
|
TypeRegistry.for(namespace).register(name, schema);
|
|
@@ -8,6 +8,7 @@ export class NormalizedSchema {
|
|
|
8
8
|
constructor(ref, memberName) {
|
|
9
9
|
this.ref = ref;
|
|
10
10
|
this.memberName = memberName;
|
|
11
|
+
this.symbol = NormalizedSchema.symbol;
|
|
11
12
|
const traitStack = [];
|
|
12
13
|
let _ref = ref;
|
|
13
14
|
let schema = ref;
|
|
@@ -52,6 +53,14 @@ export class NormalizedSchema {
|
|
|
52
53
|
throw new Error(`@smithy/core/schema - NormalizedSchema member schema ${this.getName(true)} must initialize with memberName argument.`);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
56
|
+
static [Symbol.hasInstance](lhs) {
|
|
57
|
+
const isPrototype = NormalizedSchema.prototype.isPrototypeOf(lhs);
|
|
58
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
59
|
+
const ns = lhs;
|
|
60
|
+
return ns.symbol === NormalizedSchema.symbol;
|
|
61
|
+
}
|
|
62
|
+
return isPrototype;
|
|
63
|
+
}
|
|
55
64
|
static of(ref, memberName) {
|
|
56
65
|
if (ref instanceof NormalizedSchema) {
|
|
57
66
|
return ref;
|
|
@@ -292,3 +301,4 @@ export class NormalizedSchema {
|
|
|
292
301
|
return "Unknown";
|
|
293
302
|
}
|
|
294
303
|
}
|
|
304
|
+
NormalizedSchema.symbol = Symbol.for("@smithy/core/schema::NormalizedSchema");
|
|
@@ -6,8 +6,18 @@ export class SimpleSchema extends Schema {
|
|
|
6
6
|
this.name = name;
|
|
7
7
|
this.schemaRef = schemaRef;
|
|
8
8
|
this.traits = traits;
|
|
9
|
+
this.symbol = SimpleSchema.symbol;
|
|
10
|
+
}
|
|
11
|
+
static [Symbol.hasInstance](lhs) {
|
|
12
|
+
const isPrototype = SimpleSchema.prototype.isPrototypeOf(lhs);
|
|
13
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
14
|
+
const sim = lhs;
|
|
15
|
+
return sim.symbol === SimpleSchema.symbol;
|
|
16
|
+
}
|
|
17
|
+
return isPrototype;
|
|
9
18
|
}
|
|
10
19
|
}
|
|
20
|
+
SimpleSchema.symbol = Symbol.for("@smithy/core/schema::SimpleSchema");
|
|
11
21
|
export function sim(namespace, name, schemaRef, traits) {
|
|
12
22
|
const schema = new SimpleSchema(namespace + "#" + name, schemaRef, traits);
|
|
13
23
|
TypeRegistry.for(namespace).register(name, schema);
|
|
@@ -7,6 +7,7 @@ export class StructureSchema extends Schema {
|
|
|
7
7
|
this.traits = traits;
|
|
8
8
|
this.memberNames = memberNames;
|
|
9
9
|
this.memberList = memberList;
|
|
10
|
+
this.symbol = StructureSchema.symbol;
|
|
10
11
|
this.members = {};
|
|
11
12
|
for (let i = 0; i < memberNames.length; ++i) {
|
|
12
13
|
this.members[memberNames[i]] = Array.isArray(memberList[i])
|
|
@@ -14,7 +15,16 @@ export class StructureSchema extends Schema {
|
|
|
14
15
|
: [memberList[i], 0];
|
|
15
16
|
}
|
|
16
17
|
}
|
|
18
|
+
static [Symbol.hasInstance](lhs) {
|
|
19
|
+
const isPrototype = StructureSchema.prototype.isPrototypeOf(lhs);
|
|
20
|
+
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
|
|
21
|
+
const struct = lhs;
|
|
22
|
+
return struct.symbol === StructureSchema.symbol;
|
|
23
|
+
}
|
|
24
|
+
return isPrototype;
|
|
25
|
+
}
|
|
17
26
|
}
|
|
27
|
+
StructureSchema.symbol = Symbol.for("@smithy/core/schema::StructureSchema");
|
|
18
28
|
export function struct(namespace, name, traits, memberNames, memberList) {
|
|
19
29
|
const schema = new StructureSchema(namespace + "#" + name, traits, memberNames, memberList);
|
|
20
30
|
TypeRegistry.for(namespace).register(name, schema);
|
|
@@ -2,8 +2,38 @@ export class NumericValue {
|
|
|
2
2
|
constructor(string, type) {
|
|
3
3
|
this.string = string;
|
|
4
4
|
this.type = type;
|
|
5
|
+
let dot = 0;
|
|
6
|
+
for (let i = 0; i < string.length; ++i) {
|
|
7
|
+
const char = string.charCodeAt(i);
|
|
8
|
+
if (i === 0 && char === 45) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (char === 46) {
|
|
12
|
+
if (dot) {
|
|
13
|
+
throw new Error("@smithy/core/serde - NumericValue must contain at most one decimal point.");
|
|
14
|
+
}
|
|
15
|
+
dot = 1;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (char < 48 || char > 57) {
|
|
19
|
+
throw new Error(`@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return this.string;
|
|
25
|
+
}
|
|
26
|
+
[Symbol.hasInstance](object) {
|
|
27
|
+
if (!object || typeof object !== "object") {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const _nv = object;
|
|
31
|
+
if (typeof _nv.string === "string" && typeof _nv.type === "string" && _nv.constructor?.name === "NumericValue") {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
5
35
|
}
|
|
6
36
|
}
|
|
7
|
-
export function nv(
|
|
8
|
-
return new NumericValue(
|
|
37
|
+
export function nv(input) {
|
|
38
|
+
return new NumericValue(String(input), "bigDecimal");
|
|
9
39
|
}
|
|
@@ -9,7 +9,7 @@ import { HttpProtocol } from "./HttpProtocol";
|
|
|
9
9
|
* @alpha
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class HttpBindingProtocol extends HttpProtocol {
|
|
12
|
-
serializeRequest<Input extends object>(operationSchema: OperationSchema,
|
|
12
|
+
serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
|
|
13
13
|
protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;
|
|
14
14
|
deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
|
|
15
15
|
}
|
|
@@ -17,11 +17,14 @@ export declare class ErrorSchema extends StructureSchema {
|
|
|
17
17
|
* Constructor for a modeled service exception class that extends Error.
|
|
18
18
|
*/
|
|
19
19
|
ctor: any;
|
|
20
|
+
static symbol: symbol;
|
|
21
|
+
protected symbol: symbol;
|
|
20
22
|
constructor(name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[],
|
|
21
23
|
/**
|
|
22
24
|
* Constructor for a modeled service exception class that extends Error.
|
|
23
25
|
*/
|
|
24
26
|
ctor: any);
|
|
27
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is ErrorSchema;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* Factory for ErrorSchema, to reduce codegen output and register the schema.
|
|
@@ -10,7 +10,10 @@ export declare class ListSchema extends Schema implements IListSchema {
|
|
|
10
10
|
name: string;
|
|
11
11
|
traits: SchemaTraits;
|
|
12
12
|
valueSchema: SchemaRef;
|
|
13
|
+
static symbol: symbol;
|
|
14
|
+
protected symbol: symbol;
|
|
13
15
|
constructor(name: string, traits: SchemaTraits, valueSchema: SchemaRef);
|
|
16
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is ListSchema;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Factory for ListSchema.
|
|
@@ -12,11 +12,14 @@ export declare class MapSchema extends Schema implements IMapSchema {
|
|
|
12
12
|
*/
|
|
13
13
|
keySchema: SchemaRef;
|
|
14
14
|
valueSchema: SchemaRef;
|
|
15
|
+
static symbol: symbol;
|
|
16
|
+
protected symbol: symbol;
|
|
15
17
|
constructor(name: string, traits: SchemaTraits,
|
|
16
18
|
/**
|
|
17
19
|
* This is expected to be StringSchema, but may have traits.
|
|
18
20
|
*/
|
|
19
21
|
keySchema: SchemaRef, valueSchema: SchemaRef);
|
|
22
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is MapSchema;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Factory for MapSchema.
|
|
@@ -8,6 +8,8 @@ import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISc
|
|
|
8
8
|
export declare class NormalizedSchema implements INormalizedSchema {
|
|
9
9
|
private readonly ref;
|
|
10
10
|
private memberName?;
|
|
11
|
+
static symbol: symbol;
|
|
12
|
+
protected symbol: symbol;
|
|
11
13
|
private readonly name;
|
|
12
14
|
private readonly traits;
|
|
13
15
|
private _isMemberSchema;
|
|
@@ -19,6 +21,7 @@ export declare class NormalizedSchema implements INormalizedSchema {
|
|
|
19
21
|
* @param memberName - optional memberName if this NormalizedSchema should be considered a member schema.
|
|
20
22
|
*/
|
|
21
23
|
constructor(ref: SchemaRef, memberName?: string | undefined);
|
|
24
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is NormalizedSchema;
|
|
22
25
|
/**
|
|
23
26
|
* Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
|
|
24
27
|
*/
|
|
@@ -10,7 +10,10 @@ export declare class SimpleSchema extends Schema implements TraitsSchema {
|
|
|
10
10
|
name: string;
|
|
11
11
|
schemaRef: SchemaRef;
|
|
12
12
|
traits: SchemaTraits;
|
|
13
|
+
static symbol: symbol;
|
|
14
|
+
protected symbol: symbol;
|
|
13
15
|
constructor(name: string, schemaRef: SchemaRef, traits: SchemaTraits);
|
|
16
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is SimpleSchema;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Factory for simple schema class objects.
|
|
@@ -10,8 +10,11 @@ export declare class StructureSchema extends Schema implements IStructureSchema
|
|
|
10
10
|
traits: SchemaTraits;
|
|
11
11
|
memberNames: string[];
|
|
12
12
|
memberList: SchemaRef[];
|
|
13
|
+
static symbol: symbol;
|
|
14
|
+
protected symbol: symbol;
|
|
13
15
|
members: Record<string, [SchemaRef, SchemaTraits]>;
|
|
14
16
|
constructor(name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[]);
|
|
17
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is StructureSchema;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Factory for StructureSchema.
|
|
@@ -23,9 +23,11 @@ export declare class NumericValue {
|
|
|
23
23
|
readonly string: string;
|
|
24
24
|
readonly type: NumericType;
|
|
25
25
|
constructor(string: string, type: NumericType);
|
|
26
|
+
toString(): string;
|
|
27
|
+
[Symbol.hasInstance](object: unknown): boolean;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Serde shortcut.
|
|
29
31
|
* @internal
|
|
30
32
|
*/
|
|
31
|
-
export declare function nv(
|
|
33
|
+
export declare function nv(input: string | unknown): NumericValue;
|
|
@@ -9,7 +9,7 @@ import { HttpProtocol } from "./HttpProtocol";
|
|
|
9
9
|
* @alpha
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class HttpBindingProtocol extends HttpProtocol {
|
|
12
|
-
serializeRequest<Input extends object>(operationSchema: OperationSchema,
|
|
12
|
+
serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
|
|
13
13
|
protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;
|
|
14
14
|
deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
|
|
15
15
|
}
|
|
@@ -17,11 +17,14 @@ export declare class ErrorSchema extends StructureSchema {
|
|
|
17
17
|
* Constructor for a modeled service exception class that extends Error.
|
|
18
18
|
*/
|
|
19
19
|
ctor: any;
|
|
20
|
+
static symbol: symbol;
|
|
21
|
+
protected symbol: symbol;
|
|
20
22
|
constructor(name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[],
|
|
21
23
|
/**
|
|
22
24
|
* Constructor for a modeled service exception class that extends Error.
|
|
23
25
|
*/
|
|
24
26
|
ctor: any);
|
|
27
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is ErrorSchema;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* Factory for ErrorSchema, to reduce codegen output and register the schema.
|
|
@@ -10,7 +10,10 @@ export declare class ListSchema extends Schema implements IListSchema {
|
|
|
10
10
|
name: string;
|
|
11
11
|
traits: SchemaTraits;
|
|
12
12
|
valueSchema: SchemaRef;
|
|
13
|
+
static symbol: symbol;
|
|
14
|
+
protected symbol: symbol;
|
|
13
15
|
constructor(name: string, traits: SchemaTraits, valueSchema: SchemaRef);
|
|
16
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is ListSchema;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Factory for ListSchema.
|
|
@@ -12,11 +12,14 @@ export declare class MapSchema extends Schema implements IMapSchema {
|
|
|
12
12
|
*/
|
|
13
13
|
keySchema: SchemaRef;
|
|
14
14
|
valueSchema: SchemaRef;
|
|
15
|
+
static symbol: symbol;
|
|
16
|
+
protected symbol: symbol;
|
|
15
17
|
constructor(name: string, traits: SchemaTraits,
|
|
16
18
|
/**
|
|
17
19
|
* This is expected to be StringSchema, but may have traits.
|
|
18
20
|
*/
|
|
19
21
|
keySchema: SchemaRef, valueSchema: SchemaRef);
|
|
22
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is MapSchema;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Factory for MapSchema.
|
|
@@ -8,6 +8,8 @@ import { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema,
|
|
|
8
8
|
export declare class NormalizedSchema implements INormalizedSchema {
|
|
9
9
|
private readonly ref;
|
|
10
10
|
private memberName?;
|
|
11
|
+
static symbol: symbol;
|
|
12
|
+
protected symbol: symbol;
|
|
11
13
|
private readonly name;
|
|
12
14
|
private readonly traits;
|
|
13
15
|
private _isMemberSchema;
|
|
@@ -19,6 +21,7 @@ export declare class NormalizedSchema implements INormalizedSchema {
|
|
|
19
21
|
* @param memberName - optional memberName if this NormalizedSchema should be considered a member schema.
|
|
20
22
|
*/
|
|
21
23
|
constructor(ref: SchemaRef, memberName?: string | undefined);
|
|
24
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is NormalizedSchema;
|
|
22
25
|
/**
|
|
23
26
|
* Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
|
|
24
27
|
*/
|
|
@@ -10,7 +10,10 @@ export declare class SimpleSchema extends Schema implements TraitsSchema {
|
|
|
10
10
|
name: string;
|
|
11
11
|
schemaRef: SchemaRef;
|
|
12
12
|
traits: SchemaTraits;
|
|
13
|
+
static symbol: symbol;
|
|
14
|
+
protected symbol: symbol;
|
|
13
15
|
constructor(name: string, schemaRef: SchemaRef, traits: SchemaTraits);
|
|
16
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is SimpleSchema;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Factory for simple schema class objects.
|
|
@@ -10,11 +10,14 @@ export declare class StructureSchema extends Schema implements IStructureSchema
|
|
|
10
10
|
traits: SchemaTraits;
|
|
11
11
|
memberNames: string[];
|
|
12
12
|
memberList: SchemaRef[];
|
|
13
|
+
static symbol: symbol;
|
|
14
|
+
protected symbol: symbol;
|
|
13
15
|
members: Record<string, [
|
|
14
16
|
SchemaRef,
|
|
15
17
|
SchemaTraits
|
|
16
18
|
]>;
|
|
17
19
|
constructor(name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[]);
|
|
20
|
+
static [Symbol.hasInstance](lhs: unknown): lhs is StructureSchema;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Factory for StructureSchema.
|
|
@@ -23,9 +23,11 @@ export declare class NumericValue {
|
|
|
23
23
|
readonly string: string;
|
|
24
24
|
readonly type: NumericType;
|
|
25
25
|
constructor(string: string, type: NumericType);
|
|
26
|
+
toString(): string;
|
|
27
|
+
[Symbol.hasInstance](object: unknown): boolean;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Serde shortcut.
|
|
29
31
|
* @internal
|
|
30
32
|
*/
|
|
31
|
-
export declare function nv(
|
|
33
|
+
export declare function nv(input: string | unknown): NumericValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "node ../../scripts/inline core",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@smithy/util-base64": "^4.0.0",
|
|
76
76
|
"@smithy/util-body-length-browser": "^4.0.0",
|
|
77
77
|
"@smithy/util-middleware": "^4.0.4",
|
|
78
|
-
"@smithy/util-stream": "^4.2.
|
|
78
|
+
"@smithy/util-stream": "^4.2.3",
|
|
79
79
|
"@smithy/util-utf8": "^4.0.0",
|
|
80
80
|
"tslib": "^2.6.2"
|
|
81
81
|
},
|