@aws-sdk/core
Advanced tools
| import { RpcProtocol } from "@smithy/core/protocols"; | ||
| import { deref, NormalizedSchema } from "@smithy/core/schema"; | ||
| import { ProtocolLib } from "../ProtocolLib"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| import { loadJsonRpcErrorCode } from "./parseJsonBody"; | ||
@@ -21,3 +21,3 @@ export class AwsJsonRpcProtocol extends RpcProtocol { | ||
| jsonCodec ?? | ||
| new JsonCodec({ | ||
| new JsonCodec2({ | ||
| timestampFormat: { | ||
@@ -24,0 +24,0 @@ useTrait: true, |
| import { HttpBindingProtocol, HttpInterceptingShapeDeserializer, HttpInterceptingShapeSerializer, } from "@smithy/core/protocols"; | ||
| import { NormalizedSchema } from "@smithy/core/schema"; | ||
| import { ProtocolLib } from "../ProtocolLib"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| import { loadRestJsonErrorCode } from "./parseJsonBody"; | ||
@@ -11,3 +11,3 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol { | ||
| mixin = new ProtocolLib(); | ||
| constructor({ defaultNamespace, errorTypeRegistries, }) { | ||
| constructor({ defaultNamespace, errorTypeRegistries, jsonCodec, }) { | ||
| super({ | ||
@@ -25,3 +25,3 @@ defaultNamespace, | ||
| }; | ||
| this.codec = new JsonCodec(settings); | ||
| this.codec = jsonCodec ?? new JsonCodec2(settings); | ||
| this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings); | ||
@@ -28,0 +28,0 @@ this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings); |
@@ -111,3 +111,3 @@ import { determineTimestampFormat } from "@smithy/core/protocols"; | ||
| } | ||
| if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) { | ||
| if (value instanceof Uint8Array && ns.isBlobSchema()) { | ||
| if (ns === this.rootSchema) { | ||
@@ -152,3 +152,3 @@ return value; | ||
| } | ||
| if (typeof value === "number" && ns.isNumericSchema()) { | ||
| if (typeof value === "number") { | ||
| if (Math.abs(value) === Infinity || isNaN(value)) { | ||
@@ -170,2 +170,5 @@ return String(value); | ||
| if (isObject) { | ||
| if (value instanceof Uint8Array) { | ||
| return (this.serdeContext?.base64Encoder ?? toBase64)(value); | ||
| } | ||
| const out = Array.isArray(value) ? [] : {}; | ||
@@ -172,0 +175,0 @@ for (const k in value) { |
@@ -5,3 +5,2 @@ import { determineTimestampFormat } from "@smithy/core/protocols"; | ||
| import { SerdeContextConfig } from "../../ConfigurableSerdeContext"; | ||
| import { writeKey } from "../../writeKey"; | ||
| import { JsonBytesStringAdapter } from "./JsonBytesStringAdapter"; | ||
@@ -308,3 +307,3 @@ const encoder = new TextEncoder(); | ||
| if (typeof value === "number") { | ||
| if (ns.isNumericSchema() && (Math.abs(value) === Infinity || isNaN(value))) { | ||
| if (Math.abs(value) === Infinity || Number.isNaN(value)) { | ||
| this.writeAsciiQuoted(String(value)); | ||
@@ -401,3 +400,29 @@ return; | ||
| if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) { | ||
| const json = sparse ? JSON.stringify(value) : JSON.stringify(value.filter((_) => _ != null)); | ||
| let hasSpecials = false; | ||
| for (let i = 0; i < value.length; ++i) { | ||
| const v = value[i]; | ||
| if (Number.isNaN(v) || v === Infinity || v === -Infinity || (v == null && !sparse)) { | ||
| hasSpecials = true; | ||
| break; | ||
| } | ||
| } | ||
| let json; | ||
| if (!hasSpecials) { | ||
| json = JSON.stringify(value); | ||
| } | ||
| else { | ||
| const out = []; | ||
| for (let i = 0; i < value.length; ++i) { | ||
| const v = value[i]; | ||
| if (v == null && !sparse) | ||
| continue; | ||
| if (Number.isNaN(v) || v === Infinity || v === -Infinity) { | ||
| out.push(String(v)); | ||
| } | ||
| else { | ||
| out.push(v); | ||
| } | ||
| } | ||
| json = JSON.stringify(out); | ||
| } | ||
| this.ensure(json.length * 3); | ||
@@ -431,13 +456,18 @@ this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written; | ||
| if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) { | ||
| let input = value; | ||
| if (sparse) { | ||
| input = {}; | ||
| for (const k in value) { | ||
| if (k === "__proto__") { | ||
| writeKey(input); | ||
| } | ||
| input[k] = value[k] ?? null; | ||
| let modifications; | ||
| for (const k in value) { | ||
| const v = value[k]; | ||
| if (Number.isNaN(v) || v === Infinity || v === -Infinity) { | ||
| (modifications ??= {})[k] = v; | ||
| value[k] = String(v); | ||
| } | ||
| else if (v === null && !sparse) { | ||
| (modifications ??= {})[k] = null; | ||
| value[k] = undefined; | ||
| } | ||
| } | ||
| const json = JSON.stringify(input); | ||
| const json = JSON.stringify(value); | ||
| if (modifications) { | ||
| Object.assign(value, modifications); | ||
| } | ||
| this.ensure(json.length * 3); | ||
@@ -444,0 +474,0 @@ this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written; |
| import type { TypeRegistry } from "@smithy/core/schema"; | ||
| import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol"; | ||
| import type { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import type { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| /** | ||
@@ -14,3 +15,3 @@ * @public | ||
| awsQueryCompatible?: boolean; | ||
| jsonCodec?: JsonCodec; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
@@ -17,0 +18,0 @@ getShapeId(): string; |
| import type { TypeRegistry } from "@smithy/core/schema"; | ||
| import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol"; | ||
| import type { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import type { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| /** | ||
@@ -14,3 +15,3 @@ * @public | ||
| awsQueryCompatible?: boolean; | ||
| jsonCodec?: JsonCodec; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
@@ -17,0 +18,0 @@ getShapeId(): string; |
| import { RpcProtocol } from "@smithy/core/protocols"; | ||
| import type { TypeRegistry } from "@smithy/core/schema"; | ||
| import type { EndpointBearer, HandlerExecutionContext, HttpRequest, HttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import type { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| /** | ||
@@ -20,6 +21,6 @@ * @public | ||
| awsQueryCompatible?: boolean; | ||
| jsonCodec?: JsonCodec; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
| serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest>; | ||
| getPayloadCodec(): JsonCodec; | ||
| getPayloadCodec(): JsonCodec | JsonCodec2; | ||
| protected abstract getJsonRpcVersion(): "1.1" | "1.0"; | ||
@@ -26,0 +27,0 @@ /** |
| import { HttpBindingProtocol } from "@smithy/core/protocols"; | ||
| import type { TypeRegistry } from "@smithy/core/schema"; | ||
| import type { EndpointBearer, HandlerExecutionContext, HttpRequest, HttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import type { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| /** | ||
@@ -13,8 +14,9 @@ * @public | ||
| private readonly mixin; | ||
| constructor({ defaultNamespace, errorTypeRegistries, }: { | ||
| constructor({ defaultNamespace, errorTypeRegistries, jsonCodec, }: { | ||
| defaultNamespace: string; | ||
| errorTypeRegistries?: TypeRegistry[]; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
| getShapeId(): string; | ||
| getPayloadCodec(): JsonCodec; | ||
| getPayloadCodec(): JsonCodec | JsonCodec2; | ||
| setSerdeContext(serdeContext: SerdeFunctions): void; | ||
@@ -21,0 +23,0 @@ /** |
| import { TypeRegistry } from "@smithy/core/schema"; | ||
| import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| export declare class AwsJson1_0Protocol extends AwsJsonRpcProtocol { | ||
@@ -16,3 +17,3 @@ constructor({ | ||
| awsQueryCompatible?: boolean; | ||
| jsonCodec?: JsonCodec; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
@@ -19,0 +20,0 @@ getShapeId(): string; |
| import { TypeRegistry } from "@smithy/core/schema"; | ||
| import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| export declare class AwsJson1_1Protocol extends AwsJsonRpcProtocol { | ||
@@ -16,3 +17,3 @@ constructor({ | ||
| awsQueryCompatible?: boolean; | ||
| jsonCodec?: JsonCodec; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
@@ -19,0 +20,0 @@ getShapeId(): string; |
@@ -15,2 +15,3 @@ import { RpcProtocol } from "@smithy/core/protocols"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| export declare abstract class AwsJsonRpcProtocol extends RpcProtocol { | ||
@@ -34,3 +35,3 @@ protected serializer: ShapeSerializer<string | Uint8Array>; | ||
| awsQueryCompatible?: boolean; | ||
| jsonCodec?: JsonCodec; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
@@ -42,3 +43,3 @@ serializeRequest<Input extends object>( | ||
| ): Promise<HttpRequest>; | ||
| getPayloadCodec(): JsonCodec; | ||
| getPayloadCodec(): JsonCodec | JsonCodec2; | ||
| protected abstract getJsonRpcVersion(): "1.1" | "1.0"; | ||
@@ -45,0 +46,0 @@ protected handleError( |
@@ -16,2 +16,3 @@ import { HttpBindingProtocol } from "@smithy/core/protocols"; | ||
| import { JsonCodec } from "./codec-v1/JsonCodec"; | ||
| import { JsonCodec2 } from "./codec-v2/JsonCodec2"; | ||
| export declare class AwsRestJsonProtocol extends HttpBindingProtocol { | ||
@@ -25,8 +26,10 @@ protected serializer: ShapeSerializer<string | Uint8Array>; | ||
| errorTypeRegistries, | ||
| jsonCodec, | ||
| }: { | ||
| defaultNamespace: string; | ||
| errorTypeRegistries?: TypeRegistry[]; | ||
| jsonCodec?: JsonCodec | JsonCodec2; | ||
| }); | ||
| getShapeId(): string; | ||
| getPayloadCodec(): JsonCodec; | ||
| getPayloadCodec(): JsonCodec | JsonCodec2; | ||
| setSerdeContext(serdeContext: SerdeFunctions): void; | ||
@@ -33,0 +36,0 @@ serializeRequest<Input extends object>( |
+1
-1
| { | ||
| "name": "@aws-sdk/core", | ||
| "version": "3.977.4", | ||
| "version": "3.977.5", | ||
| "description": "Core functions & classes shared by multiple AWS SDK clients.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/core", |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
566292
0.6%13739
0.57%